* src/widgets/modest-msg-edit-window.h:
authorJose Dapena Paz <jdapena@igalia.com>
Tue, 18 Sep 2007 16:13:36 +0000 (16:13 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Tue, 18 Sep 2007 16:13:36 +0000 (16:13 +0000)
        * Added method *_get_clipboard_text to get the last clipboard
          text in selection clipboard.
* src/maemo/modest-msg-edit-window.c:
        * Added implementation of *_get_clipboard_text. We set this on
          clipboard change handler.
* src/maemo/modest-msg-edit-window-ui-dimming.h:
        * Now we set check the paste dimming rule in standard menu
          group, as now this rule does not use clipboard wait functions.
          This way we can check if paste should be dimmed.
* src/modest-ui-dimming-rules.[ch]:
        * Now paste dimming rule for editor also sets it dimmed when
          focus is on a toggle button (just as when you're focusing
          the from combobox (fixes NB#65204).

pmo-trunk-r3329

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

index c22e90d..648638f 100644 (file)
@@ -21,6 +21,7 @@ static const ModestDimmingEntry modest_msg_edit_window_menu_dimming_entries [] =
        { "/MenuBar/EditMenu/SelectAllMenu", G_CALLBACK (modest_ui_dimming_rules_on_select_all) },      
        { "/MenuBar/EditMenu/UndoMenu", G_CALLBACK (modest_ui_dimming_rules_on_undo) }, 
        { "/MenuBar/EditMenu/RedoMenu", G_CALLBACK (modest_ui_dimming_rules_on_redo) }, 
+       { "/MenuBar/EditMenu/PasteMenu", G_CALLBACK (modest_ui_dimming_rules_on_editor_paste) },        
        { "/MenuBar/AttachmentsMenu/RemoveAttachmentsMenu", G_CALLBACK (modest_ui_dimming_rules_on_editor_remove_attachment) }, 
 
 };
index 80ea20a..3dfd3f6 100644 (file)
@@ -251,6 +251,7 @@ struct _ModestMsgEditWindowPrivate {
        gboolean    can_undo, can_redo;
        gulong      clipboard_change_handler_id;
        gulong      default_clipboard_change_handler_id;
+       gchar       *clipboard_text;
 
        TnyMsg      *draft_msg;
        TnyMsg      *outbox_msg;
@@ -365,6 +366,7 @@ modest_msg_edit_window_init (ModestMsgEditWindow *obj)
        priv->can_redo = FALSE;
        priv->clipboard_change_handler_id = 0;
        priv->default_clipboard_change_handler_id = 0;
+       priv->clipboard_text = NULL;
        priv->sent = FALSE;
 
        priv->last_vadj_upper = 0;
@@ -633,6 +635,11 @@ modest_msg_edit_window_finalize (GObject *obj)
        /* Sanity check: shouldn't be needed, the window mgr should
           call this function before */
        modest_msg_edit_window_disconnect_signals (MODEST_WINDOW (obj));
+
+       if (priv->clipboard_text != NULL) {
+               g_free (priv->clipboard_text);
+               priv->clipboard_text = NULL;
+       }
        
        if (priv->draft_msg != NULL) {
                TnyHeader *header = tny_msg_get_header (priv->draft_msg);
@@ -2758,14 +2765,30 @@ modest_msg_edit_window_add_attachment_clicked (GtkButton *button,
        modest_msg_edit_window_offer_attach_file (window);
 }
 
+const gchar *
+modest_msg_edit_window_get_clipboard_text (ModestMsgEditWindow *win)
+{
+       ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (win);
+
+       return priv->clipboard_text;
+}
+
 static void
 modest_msg_edit_window_clipboard_owner_change (GtkClipboard *clipboard,
                                               GdkEvent *event,
                                               ModestMsgEditWindow *window)
 {
+       ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+       GtkClipboard *selection_clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
        if (!GTK_WIDGET_VISIBLE (window))
                return;
 
+       if (priv->clipboard_text != NULL) {
+               g_free (priv->clipboard_text);
+       }
+
+       priv->clipboard_text = gtk_clipboard_wait_for_text (selection_clipboard);
+
        modest_window_check_dimming_rules_group (MODEST_WINDOW (window), "ModestClipboardDimmingRules");
 }
 static void 
@@ -3126,3 +3149,4 @@ modest_msg_edit_window_get_child_widget (ModestMsgEditWindow *win,
                return NULL;
        }
 }
+
index 8c2617d..0b7f3f6 100644 (file)
@@ -1465,10 +1465,13 @@ modest_ui_dimming_rules_on_editor_paste (ModestWindow *win, gpointer user_data)
        }
 
        if (!dimmed) {
-               GtkClipboard *clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+               dimmed = GTK_IS_TOGGLE_BUTTON (focused);
+       }
+
+       if (!dimmed) {
                ModestEmailClipboard *e_clipboard = modest_runtime_get_email_clipboard ();
                dimmed = modest_email_clipboard_cleared (e_clipboard) && 
-                       !gtk_clipboard_wait_is_text_available (clipboard);
+                       (modest_msg_edit_window_get_clipboard_text(MODEST_MSG_EDIT_WINDOW (win)) != NULL);
        }
        
        return dimmed;
index eea079f..52ef55e 100644 (file)
@@ -80,6 +80,7 @@ gboolean modest_ui_dimming_rules_on_zoom (ModestWindow *win, gpointer user_data)
 gboolean modest_ui_dimming_rules_on_send (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_editor_remove_attachment (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_editor_paste (ModestWindow *win, gpointer user_data);
+gboolean modest_ui_dimming_rules_on_editor_paste_show_menu (ModestWindow *win, gpointer user_data);
 
 G_END_DECLS
 #endif 
index f182cc9..ade9895 100644 (file)
@@ -418,6 +418,17 @@ GtkWidget *
 modest_msg_edit_window_get_child_widget (ModestMsgEditWindow *win,
                                         ModestMsgEditWindowWidgetType widget_type);
 
+/**
+ * modest_msg_edit_window_get_clipboard_text:
+ * @win: a #ModestMsgEditWindow
+ *
+ * Obtains the currently selected text in selection clipboard
+ *
+ * Returns: a string
+ */
+const gchar *
+modest_msg_edit_window_get_clipboard_text (ModestMsgEditWindow *win);
+
 G_END_DECLS
 
 #endif /* __MODEST_MSG_EDIT_WINDOW_H__ */