balsa r7920 - in trunk: . src



Author: PeterB
Date: Mon Apr 28 14:45:36 2008
New Revision: 7920
URL: http://svn.gnome.org/viewvc/balsa?rev=7920&view=rev

Log:
manage menu item sensitivity

Modified:
   trunk/ChangeLog
   trunk/src/balsa-index.c
   trunk/src/balsa-index.h
   trunk/src/main-window.c
   trunk/src/main-window.h

Modified: trunk/src/balsa-index.c
==============================================================================
--- trunk/src/balsa-index.c	(original)
+++ trunk/src/balsa-index.c	Mon Apr 28 14:45:36 2008
@@ -2463,4 +2463,15 @@
     g_signal_handler_block(selection, bindex->selection_changed_id);
     gtk_tree_selection_select_all(selection);
     g_signal_handler_unblock(selection, bindex->selection_changed_id);
+    g_signal_emit(bindex, balsa_index_signals[INDEX_CHANGED], 0);
+}
+
+gint
+balsa_index_count_selected_messages(BalsaIndex * bindex)
+{
+    g_return_val_if_fail(BALSA_IS_INDEX(bindex), -1);
+
+    return
+        gtk_tree_selection_count_selected_rows(gtk_tree_view_get_selection
+                                               (GTK_TREE_VIEW(bindex)));
 }

Modified: trunk/src/balsa-index.h
==============================================================================
--- trunk/src/balsa-index.h	(original)
+++ trunk/src/balsa-index.h	Mon Apr 28 14:45:36 2008
@@ -175,6 +175,9 @@
     /* Select all without previewing any. */
     void balsa_index_select_all(BalsaIndex * bindex);
 
+    /* Count of selected messages. */
+    gint balsa_index_count_selected_messages(BalsaIndex * bindex);
+
 #define BALSA_INDEX_VIEW_ON_OPEN "balsa-index-view-on-open"
 
 #ifdef __cplusplus

Modified: trunk/src/main-window.c
==============================================================================
--- trunk/src/main-window.c	(original)
+++ trunk/src/main-window.c	Mon Apr 28 14:45:36 2008
@@ -475,11 +475,9 @@
 #endif /* ENABLE_TOUCH_UI */
 };
 
-/* Actions that are sensitive only when a message is selected: */
+/* Actions that are sensitive only when one or more messages are
+ * selected: */
 static const GtkActionEntry message_entries[] = { 
-    /* File menu item */
-    {"Print", GTK_STOCK_PRINT, N_("_Print..."), "<control>P",
-     N_("Print current message"), G_CALLBACK(bw_message_print_cb)},
     /* Message menu items */
     {"Reply", BALSA_PIXMAP_REPLY, N_("_Reply..."), "R",
      N_("Reply to the current message"), G_CALLBACK(bw_replyto_message_cb)},
@@ -491,9 +489,6 @@
     {"StoreAddress", BALSA_PIXMAP_BOOK_RED, N_("_Store Address..."), "S",
      N_("Store address of sender in addressbook"),
      G_CALLBACK(bw_store_address_cb)},
-    {"SavePart", GTK_STOCK_SAVE, N_("Save Current Part..."), "<control>S",
-     N_("Save currently displayed part of message"),
-     G_CALLBACK(bw_save_current_part_cb)},
     {"ViewSource", BALSA_PIXMAP_BOOK_OPEN, N_("_View Source..."),
      "<control>U", N_("View source form of the message"),
      G_CALLBACK(bw_view_msg_source_cb)},
@@ -514,6 +509,18 @@
     {"Pipe", BALSA_PIXMAP_FORWARD, N_("_Pipe through..."), NULL,
      N_("Pipe the message through another program"),
      G_CALLBACK(bw_pipe_message_cb)},
+#endif /* ENABLE_TOUCH_UI */
+};
+
+/* Actions that are sensitive only when some message is current: */
+static const GtkActionEntry current_message_entries[] = {
+    /* File menu item */
+    {"Print", GTK_STOCK_PRINT, N_("_Print..."), "<control>P",
+     N_("Print current message"), G_CALLBACK(bw_message_print_cb)},
+    {"SavePart", GTK_STOCK_SAVE, N_("Save Current Part..."), "<control>S",
+     N_("Save currently displayed part of message"),
+     G_CALLBACK(bw_save_current_part_cb)},
+#if !defined(ENABLE_TOUCH_UI)
     {"NextPart", BALSA_PIXMAP_NEXT_PART, N_("_Next Part"), "<control>period",
      N_("Next part in message"), G_CALLBACK(bw_next_part_cb)},
     {"PreviousPart", BALSA_PIXMAP_PREVIOUS_PART, N_("_Previous Part"),
@@ -1246,6 +1253,11 @@
                                      action_name)))
         return action;
 
+    if ((action =
+         gtk_action_group_get_action(window->current_message_action_group,
+                                     action_name)))
+        return action;
+
     return gtk_action_group_get_action(window->message_action_group,
                                        action_name);
 }
@@ -1358,6 +1370,8 @@
                                     G_N_ELEMENTS(mailbox_entries));
     balsa_toolbar_model_add_actions(model, message_entries,
                                     G_N_ELEMENTS(message_entries));
+    balsa_toolbar_model_add_actions(model, current_message_entries,
+                                    G_N_ELEMENTS(current_message_entries));
     balsa_toolbar_model_add_actions(model, modify_message_entries,
                                     G_N_ELEMENTS(modify_message_entries));
     balsa_toolbar_model_add_toggle_actions(model, toggle_entries,
@@ -1446,6 +1460,16 @@
     action_group = gtk_action_group_new("BalsaWindow");
     gtk_action_group_set_translation_domain(action_group, NULL);
     if (window)
+        window->current_message_action_group = action_group;
+    gtk_action_group_add_actions(action_group, current_message_entries,
+                                 G_N_ELEMENTS(current_message_entries),
+                                 window);
+
+    gtk_ui_manager_insert_action_group(ui_manager, action_group, 0);
+
+    action_group = gtk_action_group_new("BalsaWindow");
+    gtk_action_group_set_translation_domain(action_group, NULL);
+    if (window)
         window->modify_message_action_group = action_group;
     gtk_action_group_add_actions(action_group, modify_message_entries,
                                  G_N_ELEMENTS(modify_message_entries),
@@ -1833,6 +1857,11 @@
     BalsaIndex *bindex = BALSA_INDEX(window->current_index);
 
     enable = (msgno != 0 && bindex != NULL);
+    gtk_action_group_set_sensitive(window->current_message_action_group,
+                                   enable);
+
+    enable = (bindex != NULL
+              && balsa_index_count_selected_messages(bindex) > 0);
     gtk_action_group_set_sensitive(window->message_action_group, enable);
 
     enable_mod = (enable && !bindex->mailbox_node->mailbox->readonly);

Modified: trunk/src/main-window.h
==============================================================================
--- trunk/src/main-window.h	(original)
+++ trunk/src/main-window.h	Mon Apr 28 14:45:36 2008
@@ -66,6 +66,7 @@
     GtkActionGroup *action_group;
     GtkActionGroup *mailbox_action_group;
     GtkActionGroup *message_action_group;
+    GtkActionGroup *current_message_action_group;
     GtkActionGroup *modify_message_action_group;
 
     /* Progress bar stuff: */



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