[balsa] Rely on "select-part" signal for enabling menus



commit eeb7e02dc564a7686eca0f1c033b9fca15b5ee6f
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sat Jan 23 11:09:19 2010 -0500

    Rely on "select-part" signal for enabling menus
    
    	* src/balsa-message.c (balsa_message_set): clear tree before
    	selecting part;
    	(select_part): emit signal also for NULL part;
    	(balsa_message_can_zoom): check for NULL widget.
    	* src/main-window.c: rely on "select-part" signal for enabling
    	menus.

 ChangeLog           |    9 +++++++++
 src/balsa-message.c |   20 ++++++++------------
 src/main-window.c   |   21 +--------------------
 3 files changed, 18 insertions(+), 32 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 196180b..33700ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2010-01-23  Peter Bloomfield
 
+	* src/balsa-message.c (balsa_message_set): clear tree before
+	selecting part;
+	(select_part): emit signal also for NULL part;
+	(balsa_message_can_zoom): check for NULL widget.
+	* src/main-window.c: rely on "select-part" signal for enabling
+	menus.
+
+2010-01-23  Peter Bloomfield
+
 	* src/main-window.c: update menus only if they will not be
 	updated when a message is shown.
 
diff --git a/src/balsa-message.c b/src/balsa-message.c
index fe8cfe4..1915d5b 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -1115,13 +1115,13 @@ balsa_message_set(BalsaMessage * bm, LibBalsaMailbox * mailbox, guint msgno)
 
     gtk_widget_hide(GTK_WIDGET(bm));
     bm_disable_find_entry(bm);
+    balsa_message_clear_tree(bm);
     select_part(bm, NULL);
     if (bm->message != NULL) {
         libbalsa_message_body_unref(bm->message);
         g_object_unref(bm->message);
         bm->message = NULL;
     }
-    balsa_message_clear_tree(bm);
 
     if (mailbox == NULL || msgno == 0) {
         gtk_notebook_set_show_tabs(GTK_NOTEBOOK(bm), FALSE);
@@ -2261,6 +2261,7 @@ hide_all_parts(BalsaMessage * bm)
 static void
 select_part(BalsaMessage * bm, BalsaPartInfo *info)
 {
+    LibBalsaMessageBody *body;
     GtkViewport *viewport = GTK_VIEWPORT(bm->cont_viewport);
 
     hide_all_parts(bm);
@@ -2268,12 +2269,10 @@ select_part(BalsaMessage * bm, BalsaPartInfo *info)
     if (bm->current_part)
         g_object_unref(bm->current_part);
 
-    bm->current_part =
-        part_info_from_body(bm,
-                            add_part(bm, info, bm->bm_widget->container));
+    body = add_part(bm, info, bm->bm_widget->container);
+    bm->current_part = part_info_from_body(bm, body);
 
-    if(bm->current_part)
-        g_signal_emit(G_OBJECT(bm), balsa_message_signals[SELECT_PART], 0);
+    g_signal_emit(G_OBJECT(bm), balsa_message_signals[SELECT_PART], 0);
 
     gtk_adjustment_set_value(gtk_viewport_get_hadjustment(viewport), 0);
     gtk_adjustment_set_value(gtk_viewport_get_vadjustment(viewport), 0);
@@ -2310,11 +2309,7 @@ balsa_get_parent_window(GtkWidget * widget)
 
 /*
  * This function informs the caller if the currently selected part 
- * supports selection/copying etc. Currently only the GtkEditable derived 
- * widgets
- * and GtkTextView
- * are supported for this (GtkHTML could be, but I don't have a 
- * working build right now)
+ * supports selection/copying etc.
  */
 gboolean
 balsa_message_can_select(BalsaMessage * bmessage)
@@ -2636,7 +2631,8 @@ mdn_dialog_response(GtkWidget * dialog, gint response, gpointer user_data)
 gboolean
 balsa_message_can_zoom(BalsaMessage * bm)
 {
-    return libbalsa_html_can_zoom(bm->current_part->mime_widget->widget);
+    return bm->current_part
+        && libbalsa_html_can_zoom(bm->current_part->mime_widget->widget);
 }
 
 /* Zoom an html item. */
diff --git a/src/main-window.c b/src/main-window.c
index f044552..842769f 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -153,7 +153,6 @@ static gboolean bw_imap_check_test(const gchar * path);
 
 static void bw_enable_mailbox_menus(BalsaWindow * window, BalsaIndex * index);
 static void bw_enable_message_menus(BalsaWindow * window, guint msgno);
-static void bw_enable_edit_menus(BalsaWindow * window, BalsaMessage * bm);
 #ifdef HAVE_GTKHTML
 static void bw_enable_view_menus(BalsaWindow * window, BalsaMessage * bm);
 #endif				/* HAVE_GTKHTML */
@@ -1836,7 +1835,6 @@ balsa_window_new()
     balsa_window_update_book_menus(window);
     bw_enable_mailbox_menus(window, NULL);
     bw_enable_message_menus(window, 0);
-    bw_enable_edit_menus(window, NULL);
 #ifdef HAVE_GTKHTML
     bw_enable_view_menus(window, NULL);
 #endif				/* HAVE_GTKHTML */
@@ -2025,7 +2023,7 @@ bw_enable_edit_menus(BalsaWindow * window, BalsaMessage * bm)
 #if !defined(ENABLE_TOUCH_UI)
     gboolean enable = (bm && balsa_message_can_select(bm));
 
-    bw_set_sensitive(window, "Copy",        bm != NULL);
+    bw_set_sensitive(window, "Copy",        enable);
     bw_set_sensitive(window, "CopyMessage", enable);
     bw_set_sensitive(window, "SelectText",  enable);
 #endif /* ENABLE_TOUCH_UI */
@@ -2483,7 +2481,6 @@ balsa_window_real_close_mbnode(BalsaWindow * window,
             /* Disable menus */
             bw_enable_mailbox_menus(window, NULL);
             bw_enable_message_menus(window, 0);
-            bw_enable_edit_menus(window, NULL);
 	    if (window->current_index)
 		g_object_remove_weak_pointer(G_OBJECT(window->current_index),
 					     (gpointer)
@@ -3754,8 +3751,6 @@ bw_next_part_cb(GtkAction * action, gpointer data)
 {
     BalsaWindow *bw = BALSA_WINDOW(data);
     balsa_message_next_part(BALSA_MESSAGE(bw->preview));
-    bw_enable_edit_menus(bw, BALSA_MESSAGE(bw->preview));
-    bw_enable_part_menu_items(bw);
 }
 
 static void
@@ -3763,8 +3758,6 @@ bw_previous_part_cb(GtkAction * action, gpointer data)
 {
     BalsaWindow *bw = BALSA_WINDOW(data);
     balsa_message_previous_part(BALSA_MESSAGE(bw->preview));
-    bw_enable_edit_menus(bw, BALSA_MESSAGE(bw->preview));
-    bw_enable_part_menu_items(bw);
 }
 #endif /* ENABLE_TOUCH_UI */
 
@@ -4946,15 +4939,6 @@ bw_notebook_switch_page_cb(GtkWidget * notebook,
     balsa_index_refresh_size(index);
     balsa_index_ensure_visible(index);
 
-    if (!index->current_msgno) {
-        /* If we're setting a message, the menus will be updated;
-         * otherwise, we'll reset them now. */
-        bw_enable_edit_menus(window, NULL);
-#if !defined(ENABLE_TOUCH_UI)
-        bw_enable_part_menu_items(window);
-#endif                          /*ENABLE_TOUCH_UI */
-    }
-
     g_free(balsa_app.current_mailbox_url);
     balsa_app.current_mailbox_url = g_strdup(mailbox->url);
 }
@@ -4972,9 +4956,6 @@ bw_index_changed_cb(GtkWidget * widget, gpointer data)
     index = BALSA_INDEX(widget);
     bw_enable_message_menus(window, index->current_msgno);
     bw_enable_mailbox_menus(window, index);
-    if (index->current_msgno == 0) {
-        bw_enable_edit_menus(window, NULL);
-    }
 
     current_msgno = BALSA_MESSAGE(window->preview)->message ?
         BALSA_MESSAGE(window->preview)->message->msgno : 0;



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