Re: [evolution-patches] Fix the lack of message reading signal in new mail notify plugin
- From: Miguel Angel López Hernández <miguel gulev org mx>
- To: Not Zed <notzed ximian com>
- Cc: evolution-patches lists ximian com
- Subject: Re: [evolution-patches] Fix the lack of message reading signal in new mail notify plugin
- Date: Wed, 12 Jan 2005 13:46:46 -0600
El mié, 12-01-2005 a las 16:53 +0800, Not Zed escribió:
>
> You should copy all the common code into a single function, you have a
> lot of duplication here (all the comments are wrong for starters).
Sorry,
I think this is better :)
Greetings,
Miguel
? Makefile
? Makefile.in
? org-gnome-new-mail-notify.eplug
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/new-mail-notify/ChangeLog,v
retrieving revision 1.2
diff -u -r1.2 ChangeLog
--- ChangeLog 11 Jan 2005 03:03:07 -0000 1.2
+++ ChangeLog 12 Jan 2005 19:40:24 -0000
@@ -1,3 +1,17 @@
+2005-01-12 Miguel Angel Lopez Hernandez <miguel gulev org mx>
+
+ * new-mail-notify.[ch]: Fix author's name, changes in code
+ to maintain coding style
+ (org_gnome_new_mail_notify): Now sends the dbus message using
+ the send_dbus_message function
+ (org_gnome_message_reading_notify): Added function, called when
+ a message.reading event is fired
+ (send_dbus_message): Added function, generic function to send
+ dbus messages
+
+ * org-gnome-new-mail-notify.eplug.in: define the message reading
+ event
+
2005-01-11 Not Zed <NotZed Ximian com>
* new-mail-notify.c (org_gnome_new_mail_config)
Index: new-mail-notify.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/new-mail-notify/new-mail-notify.c,v
retrieving revision 1.2
diff -u -r1.2 new-mail-notify.c
--- new-mail-notify.c 11 Jan 2005 03:03:07 -0000 1.2
+++ new-mail-notify.c 12 Jan 2005 19:40:25 -0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Author: Miguel Angel Lopez Hernandex <miguel gulev org mx>
+ * Author: Miguel Angel Lopez Hernandez <miguel gulev org mx>
*
* Copyright 2004 Novell, Inc.
*
@@ -33,6 +33,7 @@
#include <mail/em-event.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
+#include <camel/camel-folder.h>
#include "new-mail-notify.h"
static void
@@ -41,7 +42,10 @@
EMConfigTargetPrefs *target = (EMConfigTargetPrefs *) config->target;
/* Save the new setting to gconf */
- gconf_client_set_bool (target->gconf, GCONF_KEY, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)), NULL);
+ gconf_client_set_bool (target->gconf,
+ GCONF_KEY,
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)),
+ NULL);
}
GtkWidget *
@@ -52,13 +56,18 @@
EMConfigTargetPrefs *target = (EMConfigTargetPrefs *) hook_data->config->target;
/* Create the checkbox we will display, complete with mnemonic that is unique in the dialog */
- notify = gtk_check_button_new_with_mnemonic (_("_Generate a D-BUS message when new mail arrives"));
+ notify = gtk_check_button_new_with_mnemonic (_("_Generates a D-BUS message when new mail arrives"));
/* Set the toggle button to the current gconf setting */
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (notify), gconf_client_get_bool (target->gconf, GCONF_KEY, NULL));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (notify),
+ gconf_client_get_bool (target->gconf,
+ GCONF_KEY, NULL));
/* Listen for the item being toggled on and off */
- g_signal_connect (GTK_TOGGLE_BUTTON (notify), "toggled", G_CALLBACK (toggled_cb), hook_data->config);
+ g_signal_connect (GTK_TOGGLE_BUTTON (notify),
+ "toggled",
+ G_CALLBACK (toggled_cb),
+ hook_data->config);
/* Pack the checkbox in the parent widget and show it */
gtk_box_pack_start (GTK_BOX (hook_data->parent), notify, FALSE, FALSE, 0);
@@ -68,9 +77,23 @@
}
void
+org_gnome_message_reading_notify (EPlugin *ep, EMEventTargetMessage *t)
+{
+ send_dbus_message ("MessageReading", t->folder->name);
+}
+
+void
org_gnome_new_mail_notify (EPlugin *ep, EMEventTargetFolder *t)
{
- if (gconf_client_get_bool(gconf_client_get_default(), GCONF_KEY, NULL)) {
+ send_dbus_message ("Newmail", t->uri);
+}
+
+void
+send_dbus_message (const char *message_name, const char *data)
+{
+ GConfClient *client = gconf_client_get_default ();
+
+ if (gconf_client_get_bool(client, GCONF_KEY, NULL)) {
DBusConnection *bus;
DBusError error;
DBusMessage *message;
@@ -88,24 +111,26 @@
/* Set up this connection to work in a GLib event loop */
dbus_connection_setup_with_g_main (bus, NULL);
- /* Create a new signal "Newmail" on the DBUS_INTERFACE */
+ /* Create a new message on the DBUS_INTERFACE */
message = dbus_message_new_signal (DBUS_PATH,
DBUS_INTERFACE,
- "Newmail");
+ message_name);
- /* Append the folder uri as an argument */
+ /* Appends the data as an argument to the message */
dbus_message_append_args (message,
- DBUS_TYPE_STRING, t->uri,
+ DBUS_TYPE_STRING, data,
DBUS_TYPE_INVALID);
- /* Send the signal */
+ /* Sends the message */
dbus_connection_send (bus,
message,
NULL);
- /* Free the signal */
+ /* Frees the message */
dbus_message_unref (message);
- /* printf("Got new mail in folder '%s'!\n", t->uri); */
+ /* printf("New message [%s] with arg [%s]!\n", message_name, data); */
}
+
+ g_object_unref (client);
}
Index: new-mail-notify.h
===================================================================
RCS file: /cvs/gnome/evolution/plugins/new-mail-notify/new-mail-notify.h,v
retrieving revision 1.2
diff -u -r1.2 new-mail-notify.h
--- new-mail-notify.h 11 Jan 2005 03:03:07 -0000 1.2
+++ new-mail-notify.h 12 Jan 2005 19:40:25 -0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Author: Miguel Angel Lopez Hernandex <miguel gulev org mx>
+ * Author: Miguel Angel Lopez Hernandez <miguel gulev org mx>
*
* Copyright 2004 Novell, Inc.
*
@@ -32,5 +32,10 @@
void
org_gnome_new_mail_notify (EPlugin *ep, EMEventTargetFolder *t);
+void
+org_gnome_message_reading_notify (EPlugin *ep, EMEventTargetMessage *t);
+
+void
+send_dbus_message (const char *message_name, const char *data);
#endif /* __NMN_H__ */
Index: org-gnome-new-mail-notify.eplug.in
===================================================================
RCS file: /cvs/gnome/evolution/plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.in,v
retrieving revision 1.1
diff -u -r1.1 org-gnome-new-mail-notify.eplug.in
--- org-gnome-new-mail-notify.eplug.in 11 Jan 2005 01:46:06 -0000 1.1
+++ org-gnome-new-mail-notify.eplug.in 12 Jan 2005 19:40:25 -0000
@@ -15,6 +15,12 @@
target="folder"/>
</hook>
+ <hook class="org.gnome.evolution.mail.events:1.0">
+ <event id="message.reading"
+ handle="org_gnome_message_reading_notify"
+ target="message"/>
+ </hook>
+
<hook class="org.gnome.evolution.mail.config:1.0">
<group target="prefs">
<item type="item"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]