2006-08-02 [colin] 2.4.0cvs18
[claws.git] / src / messageview.c
index 03ef58a3e63839991e9ccb80ab906d5734f2d777..eb3295f6eeb48e915bc6a94997ff1761ff432371 100644 (file)
@@ -120,6 +120,9 @@ static void view_source_cb          (gpointer        data,
 static void show_all_header_cb         (gpointer        data,
                                         guint           action,
                                         GtkWidget      *widget);
+static void hide_quotes_cb             (gpointer        data,
+                                        guint           action,
+                                        GtkWidget      *widget);
 
 static void compose_cb                 (gpointer        data,
                                         guint           action,
@@ -274,6 +277,10 @@ static GtkItemFactoryEntry msgview_entries[] =
        {N_("/_View/---"),              NULL, NULL, 0, "<Separator>"},
        {N_("/_View/Mess_age source"),  "<control>U", view_source_cb, 0, NULL},
        {N_("/_View/Show all _headers"),"<control>H", show_all_header_cb, 0, "<ToggleItem>"},
+       {N_("/_View/Quotes"),                   NULL, NULL, 0, "<Branch>"},
+       {N_("/_View/Quotes/_Hide all"),         "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
+       {N_("/_View/Quotes/Hide from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
+       {N_("/_View/Quotes/Hide from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
 
        {N_("/_Message"),               NULL, NULL, 0, "<Branch>"},
        {N_("/_Message/Compose _new message"),
@@ -1512,6 +1519,40 @@ static void show_all_header_cb(gpointer data, guint action, GtkWidget *widget)
        main_window_set_menu_sensitive(messageview->mainwin);
 }
 
+#define SET_CHECK_MENU_ACTIVE(path, active) \
+{ \
+       menuitem = gtk_item_factory_get_widget(ifactory, path); \
+       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
+}
+
+static void hide_quotes_cb(gpointer data, guint action, GtkWidget *widget)
+{
+       MessageView *messageview = (MessageView *)data;
+       MsgInfo *msginfo = messageview->msginfo;
+       static gboolean updating_menu = FALSE;
+       GtkItemFactory *ifactory = gtk_item_factory_from_widget(messageview->menubar);
+       GtkWidget *menuitem;
+       if (updating_menu)
+               return;
+
+       prefs_common.hide_quotes = 
+                       GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
+       
+       updating_menu=TRUE;
+       SET_CHECK_MENU_ACTIVE("/View/Quotes/Hide all", FALSE);
+       SET_CHECK_MENU_ACTIVE("/View/Quotes/Hide from level 2", FALSE);
+       SET_CHECK_MENU_ACTIVE("/View/Quotes/Hide from level 3", FALSE);
+       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);      
+       updating_menu=FALSE;
+       if (!msginfo) return;
+       messageview->msginfo = NULL;
+       messageview_show(messageview, msginfo,
+                        messageview->all_headers);
+       procmsg_msginfo_free(msginfo);
+       main_window_set_menu_sensitive(messageview->mainwin);
+}
+#undef SET_CHECK_MENU_ACTIVE
+
 static void compose_cb(gpointer data, guint action, GtkWidget *widget)
 {
        MessageView *messageview = (MessageView *)data;
@@ -1626,6 +1667,20 @@ void messageview_set_menu_sensitive(MessageView *messageview)
                gtk_check_menu_item_set_active
                        (GTK_CHECK_MENU_ITEM(menuitem),
                         messageview->mimeview->textview->show_all_headers);
+               if (prefs_common.hide_quotes) {
+                       if (prefs_common.hide_quotes == 1)
+                               menuitem = gtk_item_factory_get_widget(ifactory, 
+                                               "/View/Quotes/Hide all");
+                       if (prefs_common.hide_quotes == 2)
+                               menuitem = gtk_item_factory_get_widget(ifactory, 
+                                               "/View/Quotes/Hide from level 2");
+                       if (prefs_common.hide_quotes == 3)
+                               menuitem = gtk_item_factory_get_widget(ifactory, 
+                                               "/View/Quotes/Hide from level 3");
+                       gtk_check_menu_item_set_active
+                               (GTK_CHECK_MENU_ITEM(menuitem),
+                                TRUE);
+               }
        }
 }