Fix dimming rules for add to contacts action (fixes NB#59174).
authorJose Dapena Paz <jdapena@igalia.com>
Tue, 19 Jun 2007 08:25:35 +0000 (08:25 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Tue, 19 Jun 2007 08:25:35 +0000 (08:25 +0000)
* src/modest-ui-dimming-rules.[ch]:
        * Added dimming rule for add to contacts.
* src/maemo/modest-msg-view-window.c:
        * Added new dimming rule for add to contacts action.

pmo-trunk-r2304

src/maemo/modest-msg-view-window-ui-dimming.h
src/modest-ui-dimming-rules.c
src/modest-ui-dimming-rules.h

index 7b6e16f..359e96c 100644 (file)
@@ -36,12 +36,12 @@ static const ModestDimmingEntry modest_msg_view_menu_dimming_entries [] = {
        /* Attachments Menu */
        { "/MenuBar/AttachmentsMenu", NULL },
        { "/MenuBar/AttachmentsMenu/ViewAttachmentMenu", G_CALLBACK(modest_ui_dimming_rules_on_view_attachments) },
-       { "/MenuBar/AttachmentsMenu/SaveAttachmentMenu", G_CALLBACK(modest_ui_dimming_rules_on_view_attachments) },
+       { "/MenuBar/AttachmentsMenu/SaveAttachmentMenu", G_CALLBACK(modest_ui_dimming_rules_on_save_attachments) },
        { "/MenuBar/AttachmentsMenu/RemoveAttachmentMenu", G_CALLBACK(modest_ui_dimming_rules_on_remove_attachments) },
 
        /* Tools Menu */
        { "/MenuBar/ToolsMenu", NULL },
-       { "/MenuBar/ToolsMenu/ToolsContactsMenu",  },
+       { "/MenuBar/ToolsMenu/ToolsAddToContactsMenu", G_CALLBACK (modest_ui_dimming_rules_on_add_to_contacts) },
 
        /* Close Menu */
        { "/MenuBar/CloseMenu", NULL },
index 4d2f6c5..a5109d3 100644 (file)
@@ -35,6 +35,7 @@
 #include "modest-ui-dimming-rules.h"
 #include "modest-dimming-rule.h"
 #include "modest-tny-folder.h"
+#include "modest-text-utils.h"
 #include <widgets/modest-attachments-view.h>
 #include <modest-runtime.h>
 #include <tny-simple-list.h>
@@ -654,6 +655,27 @@ modest_ui_dimming_rules_on_send_receive (ModestWindow *win, gpointer user_data)
        return dimmed;
 }
 
+gboolean
+modest_ui_dimming_rules_on_add_to_contacts (ModestWindow *win, gpointer user_data)
+{
+       ModestDimmingRule *rule = NULL;
+       gboolean dimmed = FALSE;
+
+       g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE);
+       rule = MODEST_DIMMING_RULE (user_data);
+
+       /* Check dimmed rule */
+       if (!dimmed) {
+               GtkClipboard *clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+               gchar *selection = NULL;
+               selection = gtk_clipboard_wait_for_text (clipboard);
+
+               dimmed = !((selection != NULL) && (modest_text_utils_validate_recipient (selection)));
+       }
+
+       return dimmed;
+}
+
 /* *********************** static utility functions ******************** */
 
 static gboolean 
index 5acc342..e5e5537 100644 (file)
@@ -65,6 +65,7 @@ gboolean modest_ui_dimming_rules_on_view_next (ModestWindow *win, gpointer user_
 gboolean modest_ui_dimming_rules_on_tools_smtp_servers (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_cancel_sending (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_send_receive (ModestWindow *win, gpointer user_data);
+gboolean modest_ui_dimming_rules_on_add_to_contacts (ModestWindow *win, gpointer user_data);
 
 G_END_DECLS
 #endif