[Evolution-hackers] Wallpaper Patch
- From: "Beril S." <berils gmx net>
- To: evolution-hackers lists ximian com
- Subject: [Evolution-hackers] Wallpaper Patch
- Date: Tue, 25 Nov 2003 02:39:22 +0100
Hello,
Attached is a patch for the wallpaper bounty. I'll be happy to hear
about it. It's the first I work on gnome code and it took me a lot of
time to figure out things work...
Some newbie questions, in case someone cares to answer (or send me
pointers):
- is there a libdb3 3.1.17 debian package somewhere?
- right now I "make" and "make install" each time I want to test my
changes. This takes a lot of time. Is there a faster way?
Thanks,
BS.
Index: mail/em-popup.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-popup.c,v
retrieving revision 1.7
diff -u -r1.7 em-popup.c
--- mail/em-popup.c 12 Nov 2003 21:12:59 -0000 1.7
+++ mail/em-popup.c 25 Nov 2003 01:21:26 -0000
@@ -13,6 +13,8 @@
#include <libgnome/gnome-url.h>
+#include <gconf/gconf-client.h>
+
#include <glib.h>
#include "em-popup.h"
@@ -23,6 +25,10 @@
#include <camel/camel-mime-message.h>
#include <camel/camel-string-utils.h>
+#define BG_PREFERENCES_DRAW_BACKGROUND "/desktop/gnome/background/draw_background"
+#define BG_PREFERENCES_PICTURE_OPTIONS "/desktop/gnome/background/picture_options"
+#define BG_PREFERENCES_PICTURE_FILENAME "/desktop/gnome/background/picture_filename"
+
static void emp_standard_menu_factory(EMPopup *emp, EMPopupTarget *target, void *data);
struct _EMPopupFactory {
@@ -593,16 +599,50 @@
/* ********************************************************************** */
static void
-emp_part_popup_saveas(GtkWidget *w, EMPopupTarget *t)
+emp_part_popup_saveas (GtkWidget *w, EMPopupTarget *t)
{
- em_utils_save_part(w, _("Save As..."), t->data.part.part);
+ em_utils_save_part_prompt(w, _("Save As..."), t->data.part.part);
}
static void
-emp_part_popup_set_background(GtkWidget *w, EMPopupTarget *t)
+emp_part_popup_set_background (GtkWidget *w, EMPopupTarget *t)
{
- /* set as background ... */
- printf("UNIMPLEMENTED: set background, but it would be cool, no?\n");
+ char *path = g_build_filename (g_get_home_dir (), ".evolution/desktop-background", NULL);
+
+ if (em_utils_save_part (t->data.part.part, path)) {
+ GConfClient *client;
+ GConfChangeSet *cs;
+ gchar *picture_option;
+ gchar *picture_filename;
+
+ client = gconf_client_get_default ();
+ cs = gconf_change_set_new ();
+
+ picture_option = gconf_client_get_string (client, BG_PREFERENCES_PICTURE_OPTIONS, NULL);
+ picture_filename = gconf_client_get_string (client, BG_PREFERENCES_PICTURE_FILENAME, NULL);
+
+ if ((picture_option == NULL) || !strcmp (picture_option, "none")) {
+ gconf_change_set_set_string (cs, BG_PREFERENCES_PICTURE_OPTIONS, "wallpaper");
+ } else if (!strcmp (picture_filename, path)) {
+ /* make sure something changes, otherwise the background won't be updated.
+ FIXME: this causes the desktop background to flicker */
+ gconf_client_set_string (client, BG_PREFERENCES_PICTURE_OPTIONS, "none", NULL);
+ gconf_change_set_set_string (cs, BG_PREFERENCES_PICTURE_OPTIONS, picture_option);
+ }
+
+ gconf_change_set_set_string (cs, BG_PREFERENCES_PICTURE_FILENAME, path);
+ gconf_change_set_set_bool (cs, BG_PREFERENCES_DRAW_BACKGROUND, TRUE);
+
+ gconf_client_commit_change_set (client, cs, TRUE, NULL);
+ gconf_client_suggest_sync (client, NULL);
+
+ g_free (picture_filename);
+ g_free (picture_option);
+ gconf_change_set_unref (cs);
+ g_object_unref (G_OBJECT (client));
+ }
+
+ g_free (path);
}
static void
Index: mail/em-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-utils.c,v
retrieving revision 1.8
diff -u -r1.8 em-utils.c
--- mail/em-utils.c 19 Nov 2003 21:22:12 -0000 1.8
+++ mail/em-utils.c 25 Nov 2003 01:21:29 -0000
@@ -1334,6 +1334,32 @@
}
static void
+emu_save_part_done(CamelMimePart *part, char *name, int done, void *data)
+{
+ ((int *)data)[0] = done;
+}
+
+/**
+ * em_utils_save_part:
+ * @parent:
+ * @part:
+ * @path:
+ *
+ * Save a part's content to a file.
+ *
+ * Return value: %TRUE for success.
+ **/
+gboolean
+em_utils_save_part(CamelMimePart *part, const char *path)
+{
+ int done;
+
+ mail_msg_wait(mail_save_part(part, path, emu_save_part_done, &done));
+
+ return done != 0;
+}
+
+static void
emu_save_part_response(GtkFileSelection *filesel, int response, CamelMimePart *part)
{
if (response == GTK_RESPONSE_OK) {
@@ -1344,7 +1370,7 @@
emu_update_save_path(path);
/* FIXME: popup error if it fails? */
- mail_save_part(part, path, NULL, NULL);
+ em_utils_save_part(part, path);
}
gtk_widget_destroy((GtkWidget *)filesel);
@@ -1352,7 +1378,7 @@
}
/**
- * em_utils_save_part:
+ * em_utils_save_part_prompt:
* @parent: parent window
* @prompt: prompt string
* @part: part to save
@@ -1360,7 +1386,7 @@
* Saves a mime part to disk (prompting the user for filename).
**/
void
-em_utils_save_part(GtkWidget *parent, const char *prompt, CamelMimePart *part)
+em_utils_save_part_prompt(GtkWidget *parent, const char *prompt, CamelMimePart *part)
{
const char *name;
GtkFileSelection *filesel;
@@ -1867,12 +1893,6 @@
}
}
-static void
-emu_save_part_done(CamelMimePart *part, char *name, int done, void *data)
-{
- ((int *)data)[0] = done;
-}
-
/**
* em_utils_temp_save_part:
* @parent:
Index: mail/em-utils.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-utils.h,v
retrieving revision 1.4
diff -u -r1.4 em-utils.h
--- mail/em-utils.h 27 Oct 2003 21:31:19 -0000 1.4
+++ mail/em-utils.h 25 Nov 2003 01:21:29 -0000
@@ -85,7 +85,8 @@
void em_utils_post_reply_to_message_by_uid (struct _CamelFolder *folder, const char *uid);
-void em_utils_save_part(struct _GtkWidget *parent, const char *prompt, struct _CamelMimePart *part);
+gboolean em_utils_save_part (struct _CamelMimePart *part, const char* path);
+void em_utils_save_part_prompt (struct _GtkWidget *parent, const char *prompt, struct _CamelMimePart *part);
void em_utils_save_messages (struct _GtkWidget *parent, struct _CamelFolder *folder, GPtrArray *uids);
void em_utils_flag_for_followup (struct _GtkWidget *parent, struct _CamelFolder *folder, GPtrArray *uids);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]