From b9269bd09862b22a89d44a61a5eb728c28ec3761 Mon Sep 17 00:00:00 2001 From: Michael Zucci Date: Fri, 6 May 2005 09:24:13 +0000 Subject: fix names so that intltool will parse as xml remove use of e-error-tool tag xml for translations where appropriate svn path=/trunk/; revision=29304 --- plugins/new-mail-notify/ChangeLog | 21 ++++ plugins/new-mail-notify/Makefile.am | 3 +- plugins/new-mail-notify/new-mail-notify.c | 125 ++++++++------------- .../org-gnome-new-mail-notify.eplug.in | 33 ------ .../org-gnome-new-mail-notify.eplug.xml | 33 ++++++ 5 files changed, 102 insertions(+), 113 deletions(-) delete mode 100644 plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.in create mode 100644 plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.xml (limited to 'plugins/new-mail-notify') diff --git a/plugins/new-mail-notify/ChangeLog b/plugins/new-mail-notify/ChangeLog index 45d2bcede2..dd8e768577 100644 --- a/plugins/new-mail-notify/ChangeLog +++ b/plugins/new-mail-notify/ChangeLog @@ -1,3 +1,24 @@ +2005-05-06 Not Zed + + * new-mail-notify.c: make the bus connection global and keep track + of the gconf state directly too. + (org_gnome_new_mail_config): removed configuration section, + implicitly enabled by enabling the plugin now. + +2005-04-06 Timo Hoenig + + * new-mail-notify.c (send_dbus_message): added two checks to prevent + Evolution to crash if the D-BUS session bus is not running or if + D-BUS is not able to allocate memory for the message + * new-mail-notify.c (e_plugin_lib_enable): refuse to load the plugin + if the address of the D-BUS session bus can not be determined + * new-mail-notify.c (e_plugin_lib_enable): new function + +2005-05-06 Not Zed + + * Makefile.am: + * org-gnome-new-mail-notify.eplug.xml: s/.in/.xml/ & i18n. + 2005-03-11 David Malcolm * new-mail-notify.c: preprocessor hackery using the value of diff --git a/plugins/new-mail-notify/Makefile.am b/plugins/new-mail-notify/Makefile.am index 31c868b1ff..0b217cc260 100644 --- a/plugins/new-mail-notify/Makefile.am +++ b/plugins/new-mail-notify/Makefile.am @@ -16,4 +16,5 @@ plugin_LTLIBRARIES = liborg-gnome-new-mail-notify.la liborg_gnome_new_mail_notify_la_SOURCES = new-mail-notify.c liborg_gnome_new_mail_notify_la_LDFLAGS = -module -avoid-version -EXTRA_DIST = org-gnome-new-mail-notify.eplug.in +EXTRA_DIST = org-gnome-new-mail-notify.eplug.xml + diff --git a/plugins/new-mail-notify/new-mail-notify.c b/plugins/new-mail-notify/new-mail-notify.c index 230a7fb8b1..872fa80c62 100644 --- a/plugins/new-mail-notify/new-mail-notify.c +++ b/plugins/new-mail-notify/new-mail-notify.c @@ -35,7 +35,6 @@ #include #include -#define GCONF_KEY "/apps/evolution/mail/notify/gen_dbus_msg" #define DBUS_PATH "/org/gnome/evolution/mail/newmail" #define DBUS_INTERFACE "org.gnome.evolution.mail.dbus.Signal" @@ -43,95 +42,37 @@ GtkWidget *org_gnome_new_mail_config (EPlugin *ep, EConfigHookItemFactoryData *h void org_gnome_new_mail_notify (EPlugin *ep, EMEventTargetFolder *t); void org_gnome_message_reading_notify (EPlugin *ep, EMEventTargetMessage *t); -static void -toggled_cb (GtkWidget *widget, EConfig *config) -{ - 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); -} - -GtkWidget * -org_gnome_new_mail_config (EPlugin *ep, EConfigHookItemFactoryData *hook_data) -{ - GtkWidget *notify; - - 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 (_("_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)); - - /* Listen for the item being toggled on and off */ - 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); - gtk_widget_show (notify); - - return notify; -} +static DBusConnection *bus; static void send_dbus_message (const char *message_name, const char *data) { - GConfClient *client = gconf_client_get_default (); + DBusMessage *message; - if (gconf_client_get_bool(client, GCONF_KEY, NULL)) { - DBusConnection *bus; - DBusError error; - DBusMessage *message; + if (bus == NULL) + return; - /* Get a connection to the session bus */ - dbus_error_init (&error); - bus = dbus_bus_get (DBUS_BUS_SESSION, - &error); + /* Create a new message on the DBUS_INTERFACE */ + message = dbus_message_new_signal (DBUS_PATH, + DBUS_INTERFACE, + message_name); - if (!bus) { - printf ("Failed to connect to the D-BUS daemon: %s\n", error.message); - dbus_error_free (&error); - } - - /* Set up this connection to work in a GLib event loop */ - dbus_connection_setup_with_g_main (bus, NULL); - - /* Create a new message on the DBUS_INTERFACE */ - message = dbus_message_new_signal (DBUS_PATH, - DBUS_INTERFACE, - message_name); - - /* Appends the data as an argument to the message */ - dbus_message_append_args (message, + /* Appends the data as an argument to the message */ + dbus_message_append_args (message, #if DBUS_VERSION >= 310 - DBUS_TYPE_STRING, &data, + DBUS_TYPE_STRING, &data, #else - DBUS_TYPE_STRING, data, -#endif - DBUS_TYPE_INVALID); - - /* Sends the message */ - dbus_connection_send (bus, - message, - NULL); + DBUS_TYPE_STRING, data, +#endif + DBUS_TYPE_INVALID); - /* Frees the message */ - dbus_message_unref (message); + /* Sends the message */ + dbus_connection_send (bus, + message, + NULL); - /* printf("New message [%s] with arg [%s]!\n", message_name, data); */ - } - - g_object_unref (client); + /* Frees the message */ + dbus_message_unref (message); } void @@ -145,3 +86,29 @@ org_gnome_new_mail_notify (EPlugin *ep, EMEventTargetFolder *t) { send_dbus_message ("Newmail", t->uri); } + +int +e_plugin_lib_enable (EPluginLib *ep, int enable) +{ + if (enable) { + DBusError error; + + dbus_error_init (&error); + bus = dbus_bus_get (DBUS_BUS_SESSION, &error); + if (!bus) { + g_warning("Failed to connect to the D-BUS daemon: %s\n", error.message); + + /* Could not determine address of the D-BUS session bus */ + /* Plugin will be disabled */ + dbus_error_free (&error); + return 1; + } + + /* Set up this connection to work in a GLib event loop */ + dbus_connection_setup_with_g_main (bus, NULL); + } + /* else unref the bus if set? */ + + return 0; +} + diff --git a/plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.in b/plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.in deleted file mode 100644 index c759159347..0000000000 --- a/plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.in +++ /dev/null @@ -1,33 +0,0 @@ - - - - Generates a D-BUS message when new mail arrives. - - - - - - - - - - - - - - - - - diff --git a/plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.xml b/plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.xml new file mode 100644 index 0000000000..f5fb48eb7f --- /dev/null +++ b/plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.xml @@ -0,0 +1,33 @@ + + + + <_description>Generates a D-BUS message when new mail arrives. + + + + + + + + + + + + + + + + + -- cgit v1.2.3