2008-03-11 Matthew Barnes <mbarnes@redhat.com> ** Fixes bug #513951 * addressbook/gui/component/addressbook-component.c (ensure_sources): * addressbook/gui/component/addressbook-migrate.c (addressbook_migrate): * calendar/gui/cal-search-bar.c (cal_search_bar_construct): * calendar/gui/migration.c (create_calendar_sources), (create_task_sources), (migrate_calendars), (migrate_tasks), (create_memo_sources): * calendar/gui/e-memos.c (e_memos_setup_view_menus): * calendar/gui/tasks-component.c (ensure_sources): * calendar/gui/gnome-cal.c (gnome_calendar_setup_view_menus): * calendar/gui/calendar-component.c (ensure_sources): * calendar/gui/memos-component.c (ensure_sources): * mail/mail-config.c (gconf_mime_types_changed): Adapt to new meaning of xxx_component_peek_base_directory(). * addressbook/gui/component/addressbook-component.c (addressbook_component_init): * addressbook/gui/component/addressbook-migrate.c (create_groups): * calendar/gui/tasks-component.c (tasks_component_init): * calendar/gui/calendar-component.c (calendar_component_init): * calendar/gui/memos-component.c (memos_component_init): * composer/e-msg-composer.c (autosave_manager_query_load_orphans), (autosave_init_file): * e-util/e-mktemp.c (get_dir): * e-util/e-util.c (get_lock_filename): * mail/mail-component.c: * plugins/face/face.c (org_gnome_composer_face): * smime/lib/e-cert-db.c (initialize_nss): Use e_get_user_data_dir() instead of constructing the full path. * calendar/gui/migration.c (add_gw_esource): * composer/e-msg-composer.c (e_msg-composer_unrealize), (e_msg_composer_set_view_from), (e_msg_composer_set_view_replyto), (e_msg_composer_set_view_to), (e_msg_composer_set_view_postto), (e_msg_composer_set_view_cc), (e_msg_composer_set_view_bcc): * e-util/e-util.c (e_file_update_save_path), (e_file_get_save_path): Emit warnings if saving to GConf fails. * e-util/e-util.c (e_get_user_data_dir): New function returns the base directory for Evolution user data. This should be the /only/ place in the application where this directory is hard-coded. svn path=/trunk/; revision=35175
120 lines
3.7 KiB
C
120 lines
3.7 KiB
C
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
|
/*
|
|
* Author: Sankar P <psankar@novell.com>
|
|
*
|
|
* Copyright 2004 Novell, Inc. (www.novell.com)
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include <config.h>
|
|
#endif
|
|
|
|
#include "composer/e-msg-composer.h"
|
|
#include <gtk/gtk.h>
|
|
#include <glib/gi18n.h>
|
|
#include <mail/em-menu.h>
|
|
#include <e-util/e-error.h>
|
|
#include <e-util/e-util.h>
|
|
|
|
#define d(x) x
|
|
|
|
void org_gnome_composer_face (EPlugin * ep, EMMenuTargetWidget * target);
|
|
int e_plugin_lib_configure (EPlugin * ep);
|
|
|
|
void org_gnome_composer_face (EPlugin * ep, EMMenuTargetWidget * t)
|
|
{
|
|
EMsgComposer *composer;
|
|
gchar *filename, *file_contents;
|
|
GError *error = NULL;
|
|
|
|
composer = (EMsgComposer *) t->target.widget;
|
|
filename = g_build_filename (e_get_user_data_dir (), "faces", NULL);
|
|
g_file_get_contents (filename, &file_contents, NULL, &error);
|
|
|
|
if (error) {
|
|
|
|
GtkWidget *filesel;
|
|
const char *image_filename;
|
|
gsize length;
|
|
|
|
GtkFileFilter *filter;
|
|
|
|
filesel = gtk_file_chooser_dialog_new (_
|
|
("Select a (48*48) png of size < 700bytes"),
|
|
NULL,
|
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
|
GTK_STOCK_CANCEL,
|
|
GTK_RESPONSE_CANCEL,
|
|
GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_OK);
|
|
|
|
filter = gtk_file_filter_new ();
|
|
gtk_file_filter_set_name (filter, _("PNG files"));
|
|
gtk_file_filter_add_mime_type (filter, "image/png");
|
|
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (filesel), filter);
|
|
|
|
if (GTK_RESPONSE_OK == gtk_dialog_run (GTK_DIALOG (filesel))) {
|
|
image_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filesel));
|
|
|
|
error = NULL;
|
|
file_contents = NULL;
|
|
g_file_get_contents (image_filename, &file_contents, &length, &error);
|
|
|
|
if (!error) {
|
|
error = NULL;
|
|
if (length < 720) {
|
|
|
|
GdkPixbuf *pixbuf;
|
|
GdkPixbufLoader *loader = gdk_pixbuf_loader_new();
|
|
|
|
gdk_pixbuf_loader_write (loader, (guchar *)file_contents, length, NULL);
|
|
gdk_pixbuf_loader_close (loader, NULL);
|
|
|
|
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
|
|
if (pixbuf) {
|
|
int width, height;
|
|
|
|
g_object_ref (pixbuf);
|
|
|
|
height = gdk_pixbuf_get_height (pixbuf);
|
|
width = gdk_pixbuf_get_width (pixbuf);
|
|
|
|
if (height != 48 || width != 48) {
|
|
d (printf ("\n\a Invalid Image Size. Please choose a 48*48 image\n\a"));
|
|
e_error_run (NULL, "org.gnome.evolution.plugins.face:invalid-image-size", NULL, NULL);
|
|
} else {
|
|
file_contents = g_base64_encode ((guchar *) file_contents, length);
|
|
g_file_set_contents (filename, file_contents, -1, &error);
|
|
}
|
|
}
|
|
} else {
|
|
d (printf ("File too big"));
|
|
e_error_run (NULL, "org.gnome.evolution.plugins.face:invalid-file-size", NULL, NULL);
|
|
}
|
|
|
|
} else {
|
|
d (printf ("\n\a File cannot be read\n\a"));
|
|
e_error_run (NULL, "org.gnome.evolution.plugins.face:file-not-found", NULL, NULL);
|
|
}
|
|
}
|
|
gtk_widget_destroy (filesel);
|
|
}
|
|
e_msg_composer_modify_header (composer, "Face", file_contents);
|
|
}
|