alternative main window layout patch



Recently there have been requests for alternative main window layout (large message preview window at the bottom) and because I personally know ppl who like such window layout I've made patch that makes them happy. :-) The patch allows turning alternative window layout on/off (in preferences), but the layout change becomes effective only AFTER balsa restart.

slon!

-- 
To me, M$ is a big kid who needs to have the whole sandbox for himself. 
Until that child can learn to share, I'll play with the kids that do share the sandbox.
--- balsa-1.0.0/src/balsa-app.h	Tue Nov  7 08:55:21 2000
+++ balsa/src/balsa-app.h	Sun Nov 19 18:28:35 2000
@@ -219,6 +219,8 @@
     gchar *selected_headers;
     gboolean show_mblist;
     gboolean show_notebook_tabs;
+    gboolean alternative_layout;
+    gboolean alt_layout_is_active;
 
     gboolean empty_trash_on_exit;
     gboolean previewpane;
--- balsa-1.0.0/src/main-window.c	Sat Nov 11 17:19:49 2000
+++ balsa/src/main-window.c	Sun Nov 19 18:29:13 2000
@@ -163,6 +163,7 @@
 static void mailbox_empty_trash(GtkWidget * widget, gpointer data);
 
 static void show_mbtree_cb(GtkWidget * widget, gpointer data);
+static void show_previewpane_cb(GtkWidget * widget, gpointer data);
 static void show_mbtabs_cb(GtkWidget * widget, gpointer data);
 static void about_box_destroy_cb(void);
 
@@ -280,12 +281,16 @@
     GNOMEUIINFO_TOGGLEITEM(N_("_Show Mailbox Tree"),
 			   "Toggle display of mailbox and folder tree",
 			   show_mbtree_cb, NULL),
-#define MENU_VIEW_MAILBOX_TABS_POS 1
+#define MENU_VIEW_PREVIEWPANE_POS 1
+    GNOMEUIINFO_TOGGLEITEM(N_("_Show Messege Preview"),
+			   "Toggle display of message preview pane",
+			   show_previewpane_cb, NULL),
+#define MENU_VIEW_MAILBOX_TABS_POS 2
     GNOMEUIINFO_TOGGLEITEM(N_("Show Mailbox _Tabs"),
 			   "Toggle display of mailbox notebook tabs",
 			   show_mbtabs_cb, NULL),
     GNOMEUIINFO_SEPARATOR,
-#define MENU_VIEW_WRAP_POS 3
+#define MENU_VIEW_WRAP_POS 4
     GNOMEUIINFO_TOGGLEITEM(N_("_Wrap"), "Wrap message lines",
 			   wrap_message_cb, NULL),
     GNOMEUIINFO_SEPARATOR,
@@ -632,26 +637,38 @@
     gtk_container_add(GTK_CONTAINER(scroll), window->preview);
     gtk_widget_show(scroll);
 
-    gnome_app_set_contents(GNOME_APP(window), hpaned);
-
     /* XXX */
     window->mblist = balsa_mailbox_list_window_new(window);
+
+    if  (balsa_app.alt_layout_is_active){
+	gnome_app_set_contents(GNOME_APP(window), vpaned);
+	gtk_paned_pack1(GTK_PANED(hpaned), window->mblist, TRUE, TRUE);
+	gtk_paned_pack2(GTK_PANED(hpaned), window->notebook, TRUE, TRUE);
+	gtk_paned_pack1(GTK_PANED(vpaned), hpaned, TRUE, TRUE);
+	gtk_paned_pack2(GTK_PANED(vpaned), scroll, TRUE, TRUE);
+    } else {
+	gnome_app_set_contents(GNOME_APP(window), hpaned);
     gtk_paned_pack1(GTK_PANED(hpaned), window->mblist, TRUE, TRUE);
     gtk_paned_pack2(GTK_PANED(hpaned), vpaned, TRUE, TRUE);
+	gtk_paned_pack1(GTK_PANED(vpaned), window->notebook, TRUE, TRUE);
+    	gtk_paned_pack2(GTK_PANED(vpaned), scroll, TRUE, TRUE);
+    }
+
     /*PKGW: do it this way, without the usizes. */
     if (balsa_app.show_mblist)
 	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
 				       (view_menu[MENU_VIEW_MAILBOX_LIST_POS].widget),
 				       balsa_app.show_mblist);
 
-    gtk_paned_pack1(GTK_PANED(vpaned), window->notebook, TRUE, TRUE);
-    gtk_paned_pack2(GTK_PANED(vpaned), scroll, TRUE, TRUE);
-
     /*PKGW: do it this way, without the usizes. */
-    if (balsa_app.previewpane)
+    if (balsa_app.previewpane){
+	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
+				       (view_menu[MENU_VIEW_PREVIEWPANE_POS].widget),
+    			    		balsa_app.previewpane);
+
 	gtk_paned_set_position(GTK_PANED(vpaned),
 			       balsa_app.notebook_height);
-    else
+    } else
 	/* Set it to something really high */
 	gtk_paned_set_position(GTK_PANED(vpaned), G_MAXINT);
 
@@ -1045,12 +1062,21 @@
 
     index = balsa_window_find_current_index(window);
     if (index) {
+
+	if (balsa_app.alt_layout_is_active)
+	    paned = GTK_WIDGET(balsa_app.notebook)->parent->parent;
+	else    
 	paned = GTK_WIDGET(balsa_app.notebook)->parent;
+	    g_assert(paned != NULL);
 
 	if (balsa_app.previewpane) {
 	    balsa_index_redraw_current(BALSA_INDEX(index));
 	    gtk_paned_set_position(GTK_PANED(paned),
 				   balsa_app.notebook_height);
+	    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
+				       (view_menu[MENU_VIEW_PREVIEWPANE_POS].widget),
+    			    		balsa_app.previewpane);
+				   
 	} else {
 	    bmsg = BALSA_MESSAGE(BALSA_WINDOW(window)->preview);
 	    if (bmsg)
@@ -1872,6 +1898,42 @@
     gtk_notebook_set_show_tabs(GTK_NOTEBOOK(balsa_app.notebook),
 			       balsa_app.show_notebook_tabs);
 }
+
+static void
+show_previewpane_cb(GtkWidget * widget, gpointer data)
+{
+    GtkWidget *paned;
+    BalsaMessage *bmsg;
+    GtkWidget *index;
+
+    if (balsa_app.alt_layout_is_active)
+	paned = GTK_WIDGET(balsa_app.notebook)->parent->parent;
+    else    
+        paned = GTK_WIDGET(balsa_app.notebook)->parent;
+
+    g_assert(paned != NULL);
+
+    balsa_app.previewpane = GTK_CHECK_MENU_ITEM(widget)->active;
+
+    if (balsa_app.previewpane) {
+
+	index = balsa_window_find_current_index(balsa_app.main_window);
+
+	if (index)
+    	    balsa_index_redraw_current(BALSA_INDEX(index));
+
+        gtk_paned_set_position(GTK_PANED(paned), balsa_app.notebook_height);
+    } else {
+	bmsg = BALSA_MESSAGE(balsa_app.main_window->preview);
+
+	if (bmsg)
+	    balsa_message_clear(bmsg);
+
+        gtk_paned_set_position(GTK_PANED(paned), G_MAXINT);
+    }
+}
+
+
 
 static void
 about_box_destroy_cb(void)
--- balsa-1.0.0/src/pref-manager.c	Tue Oct 17 01:26:10 2000
+++ balsa/src/pref-manager.c	Sun Nov 19 18:19:13 2000
@@ -52,6 +52,7 @@
     GtkWidget *check_mail_minutes;
 
     GtkWidget *previewpane;
+    GtkWidget *alternative_layout;
     GtkWidget *view_allheaders;
     GtkWidget *debug;		/* enable/disable debugging */
     GtkWidget *empty_trash;
@@ -301,6 +302,9 @@
     gtk_signal_connect(GTK_OBJECT(pui->previewpane), "toggled",
 		       GTK_SIGNAL_FUNC(properties_modified_cb),
 		       property_box);
+    gtk_signal_connect(GTK_OBJECT(pui->alternative_layout), "toggled",
+		       GTK_SIGNAL_FUNC(properties_modified_cb),
+		       property_box);
     gtk_signal_connect(GTK_OBJECT(pui->debug), "toggled",
 		       GTK_SIGNAL_FUNC(properties_modified_cb),
 		       property_box);
@@ -559,6 +563,7 @@
     
     balsa_app.debug = GTK_TOGGLE_BUTTON(pui->debug)->active;
     balsa_app.previewpane = GTK_TOGGLE_BUTTON(pui->previewpane)->active;
+    balsa_app.alternative_layout = GTK_TOGGLE_BUTTON(pui->alternative_layout)->active;
     balsa_app.smtp = GTK_TOGGLE_BUTTON(pui->rb_smtp_server)->active;
 
     if (balsa_app.mblist_show_mb_content_info !=
@@ -768,6 +773,8 @@
 
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->previewpane),
 				 balsa_app.previewpane);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->alternative_layout),
+				 balsa_app.alternative_layout);
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->debug),
 				 balsa_app.debug);
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->rb_smtp_server),
@@ -1523,6 +1530,13 @@
     gtk_widget_show(pui->previewpane);
     gtk_box_pack_start(GTK_BOX(vbox7), pui->previewpane, FALSE, TRUE, 0);
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->previewpane),
+				 TRUE);
+
+    pui->alternative_layout =
+	gtk_check_button_new_with_label(_("use alternative window layout (requires restart)"));
+    gtk_widget_show(pui->alternative_layout);
+    gtk_box_pack_start(GTK_BOX(vbox7), pui->alternative_layout, FALSE, TRUE, 0);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->alternative_layout),
 				 TRUE);
 
     pui->mblist_show_mb_content_info =
--- balsa-1.0.0/src/save-restore.c	Sun Oct  8 15:49:30 2000
+++ balsa/src/save-restore.c	Sun Nov 19 18:28:07 2000
@@ -379,6 +379,9 @@
     balsa_app.show_mblist = gnome_config_get_bool("ShowMailboxList=true");
     balsa_app.show_notebook_tabs = gnome_config_get_bool("ShowTabs=false");
 
+    /* ... alternative ayout of main window */
+    balsa_app.alt_layout_is_active = balsa_app.alternative_layout = gnome_config_get_bool("AlternativeLayout=false");
+
     /* ... style */
     balsa_app.toolbar_style = d_get_gint("ToolbarStyle", GTK_TOOLBAR_BOTH);
     /* ... Progress Window Dialog */
@@ -566,6 +569,7 @@
     gnome_config_set_bool("ShowTabs", balsa_app.show_notebook_tabs);
     gnome_config_set_int("ToolbarStyle", balsa_app.toolbar_style);
     gnome_config_set_int("ProgressWindow", balsa_app.pwindow_option);
+    gnome_config_set_bool("AlternativeLayout", balsa_app.alternative_layout);
 
     gnome_config_pop_prefix();
 


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