From 28e5262d541d66b204f1017b5cdb12571593fb2a Mon Sep 17 00:00:00 2001 From: Johnny Jacob Date: Fri, 23 May 2008 06:19:26 +0000 Subject: Attachment Reminder - Fixes Bug #529995. Disable the plugin when user says - do not show this message again svn path=/trunk/; revision=35529 --- plugins/attachment-reminder/ChangeLog | 14 + .../apps-evolution-attachment-reminder.schemas.in | 15 -- plugins/attachment-reminder/attachment-reminder.c | 60 ++--- .../attachment-reminder/attachment-reminder.glade | 284 ++++++++------------- 4 files changed, 141 insertions(+), 232 deletions(-) diff --git a/plugins/attachment-reminder/ChangeLog b/plugins/attachment-reminder/ChangeLog index 2bcf880ff1..c06349e093 100644 --- a/plugins/attachment-reminder/ChangeLog +++ b/plugins/attachment-reminder/ChangeLog @@ -1,5 +1,19 @@ 2008-05-22 Johnny Jacob + + ** Fixes Bug #529995 + + * attachment-reminder.c (ask_for_missing_attachment): Disable the plugin. + + * apps-evolution-attachment-reminder.schemas.in: Removed GConf key. + * attachment-reminder.c (toggle_cb): Removed. + (e_plugin_lib_get_configure_widget): Remove "Remind missing attachments" + check button. + (org_gnome_evolution_attachment_reminder): Removed Gconf key + for enable/disable . + +2008-05-22 Johnny Jacob + * attachment-reminder.c (strip_text_msg): Wrong condition check 2008-05-20 Johnny Jacob diff --git a/plugins/attachment-reminder/apps-evolution-attachment-reminder.schemas.in b/plugins/attachment-reminder/apps-evolution-attachment-reminder.schemas.in index bec59ae40a..c75bc34247 100644 --- a/plugins/attachment-reminder/apps-evolution-attachment-reminder.schemas.in +++ b/plugins/attachment-reminder/apps-evolution-attachment-reminder.schemas.in @@ -1,20 +1,5 @@ - - /schemas/apps/evolution/mail/prompts/attachment_presend_check - /apps/evolution/mail/prompts/attachment_presend_check - evolution-mail - bool - true - - Enable attachment reminder plugin - Enable attachment reminder plugin. - - - - - - /schemas/apps/evolution/mail/attachment_reminder_clues /apps/evolution/mail/attachment_reminder_clues diff --git a/plugins/attachment-reminder/attachment-reminder.c b/plugins/attachment-reminder/attachment-reminder.c index 10c69bd59a..506bd53669 100644 --- a/plugins/attachment-reminder/attachment-reminder.c +++ b/plugins/attachment-reminder/attachment-reminder.c @@ -45,8 +45,6 @@ #include "widgets/misc/e-attachment-bar.h" #include "composer/e-msg-composer.h" - -#define GCONF_KEY_ATTACHMENT_REMINDER "/apps/evolution/mail/prompts/attachment_presend_check" #define GCONF_KEY_ATTACH_REMINDER_CLUES "/apps/evolution/mail/attachment_reminder_clues" #define SIGNATURE "-- " @@ -73,11 +71,10 @@ GtkWidget *e_plugin_lib_get_configure_widget (EPlugin *epl); void org_gnome_evolution_attachment_reminder (EPlugin *ep, EMEventTargetComposer *t); GtkWidget* org_gnome_attachment_reminder_config_option (struct _EPlugin *epl, struct _EConfigHookItemFactoryData *data); -static gboolean ask_for_missing_attachment (GtkWindow *widget); +static gboolean ask_for_missing_attachment (EPlugin *ep, GtkWindow *widget); static gboolean check_for_attachment_clues (gchar *msg); static gboolean check_for_attachment (EMsgComposer *composer); static gchar* strip_text_msg (gchar *msg); -static void toggle_cb (GtkWidget *widget, UIData *ui); static void commit_changes (UIData *ui); static void cell_edited_callback (GtkCellRendererText *cell, gchar *path_string, @@ -94,18 +91,10 @@ e_plugin_lib_enable (EPluginLib *ep, int enable) void org_gnome_evolution_attachment_reminder (EPlugin *ep, EMEventTargetComposer *t) { - GConfClient *gconf; GByteArray *raw_msg_barray; gchar *filtered_str = NULL; - gconf = gconf_client_get_default (); - if (!gconf_client_get_bool (gconf, GCONF_KEY_ATTACHMENT_REMINDER, NULL)){ - g_object_unref (gconf); - return; - } else - g_object_unref (gconf); - raw_msg_barray = e_msg_composer_get_raw_message_text (t->composer); if (!raw_msg_barray) @@ -114,20 +103,38 @@ org_gnome_evolution_attachment_reminder (EPlugin *ep, EMEventTargetComposer *t) raw_msg_barray = g_byte_array_append (raw_msg_barray, (const guint8 *)"", 1); filtered_str = strip_text_msg ((gchar *) raw_msg_barray->data); + g_byte_array_free (raw_msg_barray, TRUE); /* Set presend_check_status for the composer*/ if (check_for_attachment_clues (filtered_str) && !check_for_attachment (t->composer)) - if (!ask_for_missing_attachment ((GtkWindow *)t->composer)) + if (!ask_for_missing_attachment (ep, (GtkWindow *)t->composer)) g_object_set_data ((GObject *) t->composer, "presend_check_status", GINT_TO_POINTER(1)); g_free (filtered_str); } static gboolean -ask_for_missing_attachment (GtkWindow *window) +ask_for_missing_attachment (EPlugin *ep, GtkWindow *window) { - return em_utils_prompt_user(window, GCONF_KEY_ATTACHMENT_REMINDER ,"org.gnome.evolution.plugins.attachment_reminder:attachment-reminder", NULL); + GtkWidget *mbox, *check = NULL; + gint response; + + mbox = e_error_new(window, "org.gnome.evolution.plugins.attachment_reminder:attachment-reminder", NULL); + + check = gtk_check_button_new_with_mnemonic (_("_Do not show this message again.")); + gtk_container_set_border_width((GtkContainer *)check, 12); + gtk_box_pack_start ((GtkBox *)((GtkDialog *) mbox)->vbox, check, TRUE, TRUE, 0); + gtk_widget_show (check); + + response = gtk_dialog_run ((GtkDialog *) mbox); + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) + e_plugin_enable (ep, FALSE); + + gtk_widget_destroy(mbox); + + return response == GTK_RESPONSE_YES; } /* check for the clues */ @@ -135,7 +142,6 @@ static gboolean check_for_attachment_clues (gchar *msg) { /* TODO : Add more strings. RegEx ??? */ - GConfClient *gconf; GSList *clue_list = NULL, *list; gboolean ret_val = FALSE; @@ -150,7 +156,6 @@ check_for_attachment_clues (gchar *msg) g_object_unref (gconf); msg_length = strlen (msg); - for (list = clue_list;list && !ret_val;list=g_slist_next(list)) { gchar *needle = g_utf8_strdown (list->data, -1); if (g_strstr_len (msg, msg_length, needle)) { @@ -403,17 +408,6 @@ clue_edit_clicked (GtkButton *button, UIData *ui) } } -static void -toggle_cb (GtkWidget *widget, UIData *ui) -{ - - gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - ui->gconf = gconf_client_get_default(); - - gconf_client_set_bool (ui->gconf, GCONF_KEY_ATTACHMENT_REMINDER, active, NULL); - gtk_widget_set_sensitive (ui->clue_container, active); -} - static void selection_changed (GtkTreeSelection *selection, UIData *ui) { @@ -449,10 +443,9 @@ e_plugin_lib_get_configure_widget (EPlugin *epl) GtkTreeSelection *selection; GtkTreeIter iter; GConfClient *gconf = gconf_client_get_default(); - GtkWidget *button, *hbox; + GtkWidget *hbox; GSList *clue_list = NULL, *list; GtkTreeModel *model; - gboolean enable_ui; UIData *ui = g_new0 (UIData, 1); @@ -465,7 +458,6 @@ e_plugin_lib_get_configure_widget (EPlugin *epl) g_free (gladefile); ui->gconf = gconf_client_get_default (); - enable_ui = gconf_client_get_bool (ui->gconf, GCONF_KEY_ATTACHMENT_REMINDER, NULL); ui->treeview = glade_xml_get_widget (ui->xml, "clue_treeview"); @@ -511,14 +503,8 @@ e_plugin_lib_get_configure_widget (EPlugin *epl) g_slist_free (clue_list); } - /* Enable / Disable */ - button = glade_xml_get_widget (ui->xml, "reminder_enable_check"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button) , enable_ui); - g_signal_connect (G_OBJECT (button), "toggled", G_CALLBACK (toggle_cb), ui); - /* Add the list here */ ui->clue_container = glade_xml_get_widget (ui->xml, "clue_container"); - gtk_widget_set_sensitive (ui->clue_container, enable_ui); hbox = gtk_vbox_new (FALSE, 0); diff --git a/plugins/attachment-reminder/attachment-reminder.glade b/plugins/attachment-reminder/attachment-reminder.glade index 1e54944e34..dbf953d2a5 100644 --- a/plugins/attachment-reminder/attachment-reminder.glade +++ b/plugins/attachment-reminder/attachment-reminder.glade @@ -1,182 +1,106 @@ - - - + + + - - - True - window1 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_NORMAL - GDK_GRAVITY_NORTH_WEST - True - False - - - - 385 - 189 - True - False - 5 - - - - True - True - Remind _missing attachments - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - False - False - - - - - - True - 1 - 3 - False - 6 - 7 - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - 1 - True - True - True - False - False - True - False - False - False - - - - - 1 - 2 - 0 - 1 - fill - - - - - - True - GTK_BUTTONBOX_START - 6 - - - - True - True - True - gtk-add - True - GTK_RELIEF_NORMAL - True - - - - - - True - True - True - gtk-edit - True - GTK_RELIEF_NORMAL - True - - - - - - True - True - True - gtk-remove - True - GTK_RELIEF_NORMAL - True - - - - - 2 - 3 - 0 - 1 - - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 0 - 1 - 12 - - - - - - - 0 - False - False - - - - - - + + True + window1 + + + 385 + 189 + True + 5 + + + + + + True + 1 + 3 + 7 + 6 + + + + + + True + 6 + GTK_BUTTONBOX_START + + + True + True + True + gtk-add + True + 0 + + + + + True + True + True + gtk-edit + True + 0 + + + 1 + + + + + True + True + True + gtk-remove + True + 0 + + + 2 + + + + + 2 + 3 + + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + + + True + True + 1 + + + + + 1 + 2 + GTK_FILL + + + + + False + False + 1 + + + + + -- cgit v1.2.3