* src/maemo/modest-msg-edit-window.c:
authorJose Dapena Paz <jdapena@igalia.com>
Thu, 10 May 2007 08:26:18 +0000 (08:26 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Thu, 10 May 2007 08:26:18 +0000 (08:26 +0000)
        * Implemented cut/copy dimming in message editor (not working completely yet
          as it needs to update the status at startup).
* src/widgets/modest-attachment-view.[ch]:
        * Removed commented code and any other reminiscence of activate signal
          in attachment view (now it's implemented in ModestAttachmentsView).
* src/widgets/modest-attachments-view.c:
        * Removed "activate" signal assignment to ModestAttachmentView as it's
          not used now.

pmo-trunk-r1819

src/maemo/modest-msg-edit-window.c
src/widgets/modest-attachment-view.c
src/widgets/modest-attachment-view.h
src/widgets/modest-attachments-view.c

index d7eca1c..95a0a9d 100644 (file)
@@ -112,6 +112,9 @@ static gboolean modest_msg_edit_window_zoom_minus (ModestWindow *window);
 static gboolean modest_msg_edit_window_zoom_plus (ModestWindow *window);
 static void modest_msg_edit_window_show_toolbar   (ModestWindow *window,
                                                   gboolean show_toolbar);
+static void modest_msg_edit_window_clipboard_owner_change (GtkClipboard *clipboard,
+                                                          GdkEvent *event,
+                                                          ModestMsgEditWindow *window);
 static void update_dimmed (ModestMsgEditWindow *window);
 
 
@@ -157,6 +160,8 @@ struct _ModestMsgEditWindowPrivate {
        TnyHeaderFlags priority_flags;
 
        gdouble zoom_level;
+       
+       gulong      clipboard_change_handler_id;
 
        TnyMsg      *draft_msg;
 };
@@ -256,6 +261,7 @@ modest_msg_edit_window_init (ModestMsgEditWindow *obj)
        priv->priority_flags = 0;
 
        priv->draft_msg = NULL;
+       priv->clipboard_change_handler_id = 0;
 }
 
 
@@ -456,6 +462,9 @@ init_window (ModestMsgEditWindow *obj)
        gtk_container_add (GTK_CONTAINER (frame), scroll_area);
        gtk_container_set_focus_vadjustment (GTK_CONTAINER (scroll_area), 
                                             gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->scroll)));
+
+       priv->clipboard_change_handler_id = g_signal_connect (G_OBJECT (gtk_clipboard_get (GDK_SELECTION_PRIMARY)), "owner-change",
+                                                             G_CALLBACK (modest_msg_edit_window_clipboard_owner_change), obj);
 }
        
 
@@ -463,6 +472,12 @@ init_window (ModestMsgEditWindow *obj)
 static void
 modest_msg_edit_window_finalize (GObject *obj)
 {
+       ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (obj);
+
+       if (priv->clipboard_change_handler_id > 0) {
+               g_signal_handler_disconnect (gtk_clipboard_get (GDK_SELECTION_PRIMARY), priv->clipboard_change_handler_id);
+               priv->clipboard_change_handler_id = 0;
+       }
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
 
@@ -2258,3 +2273,23 @@ modest_msg_edit_window_add_attachment_clicked (GtkButton *button,
 {
        modest_msg_edit_window_attach_file (window);
 }
+
+static void
+modest_msg_edit_window_clipboard_owner_change (GtkClipboard *clipboard,
+                                              GdkEvent *event,
+                                              ModestMsgEditWindow *window)
+{
+       ModestWindowPrivate *parent_priv;
+       GtkAction *action;
+       gchar *selection;
+       GtkWidget *focused;
+
+       parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
+       selection = gtk_clipboard_wait_for_text (clipboard);
+       focused = gtk_window_get_focus (GTK_WINDOW (window));
+
+       action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/CutMenu");
+       gtk_action_set_sensitive (action, (selection != NULL) && (!MODEST_IS_ATTACHMENTS_VIEW (focused)));
+       action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/CopyMenu");
+       gtk_action_set_sensitive (action, (selection != NULL) && (!MODEST_IS_ATTACHMENTS_VIEW (focused)));
+}
index ec3c2ca..13a0dbd 100644 (file)
 
 static GObjectClass *parent_class = NULL;
 
-/* /\* signals *\/ */
-/* enum { */
-/*     LAST_SIGNAL */
-/* }; */
-
 typedef struct _ModestAttachmentViewPriv ModestAttachmentViewPriv;
 
 struct _ModestAttachmentViewPriv
@@ -70,8 +65,6 @@ struct _ModestAttachmentViewPriv
 #define MODEST_ATTACHMENT_VIEW_GET_PRIVATE(o)  \
        (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_ATTACHMENT_VIEW, ModestAttachmentViewPriv))
 
-/* static guint signals[LAST_SIGNAL] = {0}; */
-
 /* TnyMimePartView functions */
 static TnyMimePart *modest_attachment_view_get_part (TnyMimePartView *self);
 static TnyMimePart *modest_attachment_view_get_part_default (TnyMimePartView *self);
@@ -400,7 +393,6 @@ modest_attachment_view_class_init (ModestAttachmentViewClass *klass)
        klass->get_part_func = modest_attachment_view_get_part_default;
        klass->set_part_func = modest_attachment_view_set_part_default;
        klass->clear_func = modest_attachment_view_clear_default;
-       klass->activate = NULL;
 
        widget_class->size_allocate = size_allocate;
 
index 343767a..cd5a4a8 100644 (file)
@@ -60,8 +60,6 @@ struct _ModestAttachmentViewClass
        void (*set_part_func) (TnyMimePartView *self, TnyMimePart *part);
        void (*clear_func) (TnyMimePartView *self);
 
-       /* signals */
-       void (*activate)           (ModestAttachmentView *attachment_view);
 };
 
 GType modest_attachment_view_get_type (void);
index 12f85a7..056b733 100644 (file)
@@ -79,17 +79,6 @@ static void own_clipboard (ModestAttachmentsView *atts_view);
 
 static guint signals[LAST_SIGNAL] = {0};
 
-static void
-activate_attachment (ModestAttachmentView *attachment_view,
-                    gpointer userdata)
-{
-       TnyMimePart *mime_part;
-      
-       mime_part = tny_mime_part_view_get_part (TNY_MIME_PART_VIEW (attachment_view));
-       g_signal_emit (G_OBJECT (userdata), signals[ACTIVATE_SIGNAL], 0, mime_part);
-       g_object_unref (mime_part);
-}
-
 /**
  * modest_attachments_view_new:
  * @msg: a #TnyMsg
@@ -165,7 +154,6 @@ modest_attachments_view_add_attachment (ModestAttachmentsView *attachments_view,
        att_view = modest_attachment_view_new (part);
        gtk_box_pack_end (GTK_BOX (priv->box), att_view, FALSE, FALSE, 0);
        gtk_widget_show_all (att_view);
-       g_signal_connect (G_OBJECT (att_view), "activate", G_CALLBACK (activate_attachment), (gpointer) attachments_view);
 }
 
 void