evolution r35529 - trunk/plugins/attachment-reminder



Author: jjohnny
Date: Fri May 23 06:19:26 2008
New Revision: 35529
URL: http://svn.gnome.org/viewvc/evolution?rev=35529&view=rev

Log:
Attachment Reminder - Fixes Bug #529995. Disable the plugin when user says - do not show this message again


Modified:
   trunk/plugins/attachment-reminder/ChangeLog
   trunk/plugins/attachment-reminder/apps-evolution-attachment-reminder.schemas.in
   trunk/plugins/attachment-reminder/attachment-reminder.c
   trunk/plugins/attachment-reminder/attachment-reminder.glade

Modified: trunk/plugins/attachment-reminder/apps-evolution-attachment-reminder.schemas.in
==============================================================================
--- trunk/plugins/attachment-reminder/apps-evolution-attachment-reminder.schemas.in	(original)
+++ trunk/plugins/attachment-reminder/apps-evolution-attachment-reminder.schemas.in	Fri May 23 06:19:26 2008
@@ -1,21 +1,6 @@
 <gconfschemafile>
   <schemalist>
     <schema>
-      <key>/schemas/apps/evolution/mail/prompts/attachment_presend_check</key>
-      <applyto>/apps/evolution/mail/prompts/attachment_presend_check</applyto>
-      <owner>evolution-mail</owner>
-      <type>bool</type>
-      <default>true</default>
-      <locale name="C">
-        <short>Enable attachment reminder plugin</short>
-        <long>Enable attachment reminder plugin.</long>
-      </locale>
-    </schema>
-
-
-    <!-- Labels and Colours -->
-
-    <schema>
       <key>/schemas/apps/evolution/mail/attachment_reminder_clues</key>
       <applyto>/apps/evolution/mail/attachment_reminder_clues</applyto>
       <owner>evolution-mail</owner>

Modified: trunk/plugins/attachment-reminder/attachment-reminder.c
==============================================================================
--- trunk/plugins/attachment-reminder/attachment-reminder.c	(original)
+++ trunk/plugins/attachment-reminder/attachment-reminder.c	Fri May 23 06:19:26 2008
@@ -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 @@
 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 @@
 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 @@
 	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 @@
 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 @@
 	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)) {
@@ -404,17 +409,6 @@
 }
 
 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)
 {
 	GtkTreeModel *model;
@@ -449,10 +443,9 @@
 	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 @@
 	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 @@
 		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);
 

Modified: trunk/plugins/attachment-reminder/attachment-reminder.glade
==============================================================================
--- trunk/plugins/attachment-reminder/attachment-reminder.glade	(original)
+++ trunk/plugins/attachment-reminder/attachment-reminder.glade	Fri May 23 06:19:26 2008
@@ -1,182 +1,106 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd";>
-
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
 <glade-interface>
-
-<widget class="GtkWindow" id="window1">
-  <property name="visible">True</property>
-  <property name="title" translatable="no">window1</property>
-  <property name="type">GTK_WINDOW_TOPLEVEL</property>
-  <property name="window_position">GTK_WIN_POS_NONE</property>
-  <property name="modal">False</property>
-  <property name="resizable">True</property>
-  <property name="destroy_with_parent">False</property>
-  <property name="decorated">True</property>
-  <property name="skip_taskbar_hint">False</property>
-  <property name="skip_pager_hint">False</property>
-  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
-  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
-  <property name="focus_on_map">True</property>
-  <property name="urgency_hint">False</property>
-
-  <child>
-    <widget class="GtkVBox" id="reminder_configuration_box">
-      <property name="width_request">385</property>
-      <property name="height_request">189</property>
-      <property name="visible">True</property>
-      <property name="homogeneous">False</property>
-      <property name="spacing">5</property>
-
-      <child>
-	<widget class="GtkCheckButton" id="reminder_enable_check">
-	  <property name="visible">True</property>
-	  <property name="can_focus">True</property>
-	  <property name="label" translatable="yes">Remind _missing attachments</property>
-	  <property name="use_underline">True</property>
-	  <property name="relief">GTK_RELIEF_NORMAL</property>
-	  <property name="focus_on_click">True</property>
-	  <property name="active">False</property>
-	  <property name="inconsistent">False</property>
-	  <property name="draw_indicator">True</property>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">False</property>
-	  <property name="fill">False</property>
-	</packing>
-      </child>
-
-      <child>
-	<widget class="GtkTable" id="clue_container">
-	  <property name="visible">True</property>
-	  <property name="n_rows">1</property>
-	  <property name="n_columns">3</property>
-	  <property name="homogeneous">False</property>
-	  <property name="row_spacing">6</property>
-	  <property name="column_spacing">7</property>
-
-	  <child>
-	    <widget class="GtkScrolledWindow" id="scrolledwindow1">
-	      <property name="visible">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-	      <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-	      <property name="shadow_type">GTK_SHADOW_NONE</property>
-	      <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
-	      <child>
-		<widget class="GtkTreeView" id="clue_treeview">
-		  <property name="border_width">1</property>
-		  <property name="visible">True</property>
-		  <property name="can_focus">True</property>
-		  <property name="headers_visible">True</property>
-		  <property name="rules_hint">False</property>
-		  <property name="reorderable">False</property>
-		  <property name="enable_search">True</property>
-		  <property name="fixed_height_mode">False</property>
-		  <property name="hover_selection">False</property>
-		  <property name="hover_expand">False</property>
-		</widget>
-	      </child>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">1</property>
-	      <property name="right_attach">2</property>
-	      <property name="top_attach">0</property>
-	      <property name="bottom_attach">1</property>
-	      <property name="y_options">fill</property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkVButtonBox" id="vbuttonbox2">
-	      <property name="visible">True</property>
-	      <property name="layout_style">GTK_BUTTONBOX_START</property>
-	      <property name="spacing">6</property>
-
-	      <child>
-		<widget class="GtkButton" id="clue_add">
-		  <property name="visible">True</property>
-		  <property name="can_default">True</property>
-		  <property name="can_focus">True</property>
-		  <property name="label">gtk-add</property>
-		  <property name="use_stock">True</property>
-		  <property name="relief">GTK_RELIEF_NORMAL</property>
-		  <property name="focus_on_click">True</property>
-		</widget>
-	      </child>
-
-	      <child>
-		<widget class="GtkButton" id="clue_edit">
-		  <property name="visible">True</property>
-		  <property name="can_default">True</property>
-		  <property name="can_focus">True</property>
-		  <property name="label">gtk-edit</property>
-		  <property name="use_stock">True</property>
-		  <property name="relief">GTK_RELIEF_NORMAL</property>
-		  <property name="focus_on_click">True</property>
-		</widget>
-	      </child>
-
-	      <child>
-		<widget class="GtkButton" id="clue_remove">
-		  <property name="visible">True</property>
-		  <property name="can_default">True</property>
-		  <property name="can_focus">True</property>
-		  <property name="label">gtk-remove</property>
-		  <property name="use_stock">True</property>
-		  <property name="relief">GTK_RELIEF_NORMAL</property>
-		  <property name="focus_on_click">True</property>
-		</widget>
-	      </child>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">2</property>
-	      <property name="right_attach">3</property>
-	      <property name="top_attach">0</property>
-	      <property name="bottom_attach">1</property>
-	      <property name="x_options"></property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkLabel" id="label1">
-	      <property name="visible">True</property>
-	      <property name="label" translatable="yes"></property>
-	      <property name="use_underline">False</property>
-	      <property name="use_markup">False</property>
-	      <property name="justify">GTK_JUSTIFY_LEFT</property>
-	      <property name="wrap">False</property>
-	      <property name="selectable">False</property>
-	      <property name="xalign">0</property>
-	      <property name="yalign">0.5</property>
-	      <property name="xpad">0</property>
-	      <property name="ypad">0</property>
-	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-	      <property name="width_chars">-1</property>
-	      <property name="single_line_mode">False</property>
-	      <property name="angle">0</property>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">0</property>
-	      <property name="right_attach">1</property>
-	      <property name="top_attach">0</property>
-	      <property name="bottom_attach">1</property>
-	      <property name="x_padding">12</property>
-	      <property name="x_options"></property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">False</property>
-	  <property name="fill">False</property>
-	</packing>
-      </child>
-    </widget>
-  </child>
-</widget>
-
+  <widget class="GtkWindow" id="window1">
+    <property name="visible">True</property>
+    <property name="title">window1</property>
+    <child>
+      <widget class="GtkVBox" id="reminder_configuration_box">
+        <property name="width_request">385</property>
+        <property name="height_request">189</property>
+        <property name="visible">True</property>
+        <property name="spacing">5</property>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <widget class="GtkTable" id="clue_container">
+            <property name="visible">True</property>
+            <property name="n_rows">1</property>
+            <property name="n_columns">3</property>
+            <property name="column_spacing">7</property>
+            <property name="row_spacing">6</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <widget class="GtkVButtonBox" id="vbuttonbox2">
+                <property name="visible">True</property>
+                <property name="spacing">6</property>
+                <property name="layout_style">GTK_BUTTONBOX_START</property>
+                <child>
+                  <widget class="GtkButton" id="clue_add">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="label">gtk-add</property>
+                    <property name="use_stock">True</property>
+                    <property name="response_id">0</property>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="clue_edit">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="label">gtk-edit</property>
+                    <property name="use_stock">True</property>
+                    <property name="response_id">0</property>
+                  </widget>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="clue_remove">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="label">gtk-remove</property>
+                    <property name="use_stock">True</property>
+                    <property name="response_id">0</property>
+                  </widget>
+                  <packing>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="right_attach">3</property>
+                <property name="x_options"></property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkScrolledWindow" id="scrolledwindow1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                <child>
+                  <widget class="GtkTreeView" id="clue_treeview">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="border_width">1</property>
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </glade-interface>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]