<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40705 >

Patch implements an option to have the lower notebook split into
two notebooks so that the chat tab and the message tab are both
visible at the same time. If enabled the message tab is hard-
coded to appear in the right notebook.

The next step would be to implement the ability to move tabs
between the two notebooks and to save the layout over program
restart.


-----------------------------------------------------------------------
うわ〜〜〜〜っ!分裂される。
 client/gui-gtk-2.0/gui_main.c   |   43 ++++++++++++++++++++++++++++++++++++--
 client/gui-gtk-2.0/gui_main.h   |    2 +
 client/gui-gtk-2.0/messagewin.c |    9 ++++++-
 3 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/client/gui-gtk-2.0/gui_main.c b/client/gui-gtk-2.0/gui_main.c
index 6448d26..eeccb0a 100644
--- a/client/gui-gtk-2.0/gui_main.c
+++ b/client/gui-gtk-2.0/gui_main.c
@@ -97,13 +97,15 @@ int overview_canvas_store_height = 2 * 50;
 
 bool enable_tabs = TRUE;
 bool better_fog = TRUE;
+bool split_bottom_notebook = FALSE;
 
 GtkWidget *toplevel;
 GdkWindow *root_window;
 GtkWidget *toplevel_tabs;
 GtkWidget *top_vbox;
-GtkWidget *top_notebook, *bottom_notebook;
+GtkWidget *top_notebook, *bottom_notebook, *right_notebook;
 GtkWidget *map_widget;
+static GtkWidget *bottom_hpaned;
 
 int city_names_font_size = 0, city_productions_font_size = 0;
 PangoFontDescription *main_font;
@@ -164,6 +166,8 @@ char font_comment_label[512] = "Sans Italic 9";
 char font_city_names[512] = "Sans Bold 10";
 char font_city_productions[512] = "Serif 10";
 
+static void split_bottom_notebook_callback(struct client_option *op);
+
 client_option gui_options[] = {
   /* This option is the same as the one in gui-gtk */
   GEN_BOOL_OPTION(map_scrollbars, N_("Show Map Scrollbars"),
@@ -198,6 +202,12 @@ client_option gui_options[] = {
 			"for drawing fog-of-war.  It is not any slower but "
 			"will consume about twice as much memory."),
 		     COC_GRAPHICS, mapview_redraw_callback),
+  GEN_BOOL_OPTION_CB(split_bottom_notebook,
+                     N_("Split bottom notebook area"),
+                     N_("Enabling this option will split the bottom "
+                        "notebook into a left and right notebook so that "
+                        "two tabs may be viewed at once."),
+                     COC_INTERFACE, split_bottom_notebook_callback),
   GEN_FONT_OPTION(font_city_label,
   		  city_label,
 		  N_("City Label"),
@@ -990,7 +1000,7 @@ void enable_menus(bool enable)
 static void setup_widgets(void)
 {
   GtkWidget *box, *ebox, *hbox, *sbox, *align, *label;
-  GtkWidget *frame, *table, *table2, *paned, *sw, *text;
+  GtkWidget *frame, *table, *table2, *paned, *hpaned, *sw, *text;
   int i;
   char buf[256];
   struct sprite *sprite;
@@ -1317,10 +1327,22 @@ static void setup_widgets(void)
   gtk_paned_pack2(GTK_PANED(paned), sbox, TRUE, TRUE);
   avbox = detached_widget_fill(sbox);
 
+  hpaned = gtk_hpaned_new();
+  gtk_box_pack_start(GTK_BOX(avbox), hpaned, TRUE, TRUE, 0);
+  bottom_hpaned = hpaned;
+
   bottom_notebook = gtk_notebook_new();
   gtk_notebook_set_tab_pos(GTK_NOTEBOOK(bottom_notebook), GTK_POS_TOP);
   gtk_notebook_set_scrollable(GTK_NOTEBOOK(bottom_notebook), TRUE);
-  gtk_box_pack_start(GTK_BOX(avbox), bottom_notebook, TRUE, TRUE, 0);
+  gtk_paned_pack1(GTK_PANED(hpaned), bottom_notebook, TRUE, TRUE);
+
+  right_notebook = gtk_notebook_new();
+  g_object_ref(right_notebook);
+  gtk_notebook_set_tab_pos(GTK_NOTEBOOK(right_notebook), GTK_POS_TOP);
+  gtk_notebook_set_scrollable(GTK_NOTEBOOK(right_notebook), TRUE);
+  if (split_bottom_notebook) {
+    gtk_paned_pack2(GTK_PANED(hpaned), right_notebook, TRUE, TRUE);
+  }
 
   vbox = gtk_vbox_new(FALSE, 0);
 
@@ -2110,3 +2132,18 @@ void add_idle_callback(void (callback)(void *), void *data)
   cb->data = data;
   gtk_idle_add(idle_callback_wrapper, cb);
 }
+
+/****************************************************************************
+  Option callback for the 'split_bottom_notebook' option.
+****************************************************************************/
+static void split_bottom_notebook_callback(struct client_option *op)
+{
+  popdown_meswin_dialog();
+  if (*op->p_bool_value) {
+    gtk_paned_pack2(GTK_PANED(bottom_hpaned), right_notebook, TRUE, TRUE);
+    gtk_widget_show_all(right_notebook);
+  } else {
+    gtk_container_remove(GTK_CONTAINER(bottom_hpaned), right_notebook);
+  }
+  popup_meswin_dialog(FALSE);
+}
diff --git a/client/gui-gtk-2.0/gui_main.h b/client/gui-gtk-2.0/gui_main.h
index f5ed3fa..fda9ddd 100644
--- a/client/gui-gtk-2.0/gui_main.h
+++ b/client/gui-gtk-2.0/gui_main.h
@@ -26,6 +26,7 @@ extern PangoFontDescription *        city_productions_font;
 
 extern bool enable_tabs;
 extern bool better_fog;
+extern bool split_bottom_notebook;
 
 extern GdkGC *          civ_gc;
 extern GdkGC *          mask_fg_gc;
@@ -72,6 +73,7 @@ extern GtkWidget *	toplevel_tabs;
 extern GtkWidget *	top_notebook;
 extern GtkWidget *      map_widget;
 extern GtkWidget *	bottom_notebook;
+extern GtkWidget *	right_notebook;
 extern GtkTextBuffer *	message_buffer;
 
 /* NB: Must match creation arugments in
diff --git a/client/gui-gtk-2.0/messagewin.c b/client/gui-gtk-2.0/messagewin.c
index 63a9436..295792d 100644
--- a/client/gui-gtk-2.0/messagewin.c
+++ b/client/gui-gtk-2.0/messagewin.c
@@ -148,9 +148,14 @@ static void create_meswin_dialog(void)
 {
   GtkCellRenderer *renderer;
   GtkTreeViewColumn *col;
-  GtkWidget *view, *sw, *cmd;
+  GtkWidget *view, *sw, *cmd, *notebook;
 
-  gui_dialog_new(&meswin_shell, GTK_NOTEBOOK(bottom_notebook), NULL);
+  if (split_bottom_notebook) {
+    notebook = right_notebook;
+  } else {
+    notebook = bottom_notebook;
+  }
+  gui_dialog_new(&meswin_shell, GTK_NOTEBOOK(notebook), NULL);
   gui_dialog_set_title(meswin_shell, _("Messages"));
 
   meswin_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
 client/gui-gtk-2.0/gui_main.c   |   45 +++++++++++++++++++++++++++++++++++---
 client/gui-gtk-2.0/gui_main.h   |    2 +
 client/gui-gtk-2.0/messagewin.c |    9 ++++++-
 3 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/client/gui-gtk-2.0/gui_main.c b/client/gui-gtk-2.0/gui_main.c
index 93ce820..2f6256d 100644
--- a/client/gui-gtk-2.0/gui_main.c
+++ b/client/gui-gtk-2.0/gui_main.c
@@ -94,13 +94,15 @@ int overview_canvas_store_height = 2 * 50;
 
 bool enable_tabs = TRUE;
 bool better_fog = TRUE;
+bool split_bottom_notebook = FALSE;
 
 GtkWidget *toplevel;
 GdkWindow *root_window;
 GtkWidget *toplevel_tabs;
 GtkWidget *top_vbox;
-GtkWidget *top_notebook, *bottom_notebook;
+GtkWidget *top_notebook, *bottom_notebook, *right_notebook;
 GtkWidget *map_widget;
+static GtkWidget *bottom_hpaned;
 
 int city_names_font_size = 0, city_productions_font_size = 0;
 PangoFontDescription *main_font;
@@ -145,6 +147,8 @@ GtkWidget *government_ebox;
 const char * const gui_character_encoding = "UTF-8";
 const bool gui_use_transliteration = FALSE;
 
+static void split_bottom_notebook_callback(struct client_option *op);
+
 client_option gui_options[] = {
   /* This option is the same as the one in gui-gtk */
   GEN_BOOL_OPTION(map_scrollbars, N_("Show Map Scrollbars"),
@@ -178,7 +182,13 @@ client_option gui_options[] = {
 		     N_("If this is enabled then a better method is used "
 			"for drawing fog-of-war.  It is not any slower but "
 			"will consume about twice as much memory."),
-		     COC_GRAPHICS, mapview_redraw_callback)
+		     COC_GRAPHICS, mapview_redraw_callback),
+  GEN_BOOL_OPTION_CB(split_bottom_notebook,
+                     N_("Split bottom notebook area"),
+                     N_("Enabling this option will split the bottom "
+                        "notebook into a left and right notebook so that "
+                        "two tabs may be viewed at once."),
+                     COC_INTERFACE, split_bottom_notebook_callback)
 };
 const int num_gui_options = ARRAY_SIZE(gui_options);
 
@@ -884,7 +894,7 @@ void enable_menus(bool enable)
 static void setup_widgets(void)
 {
   GtkWidget *box, *ebox, *hbox, *sbox, *align, *label;
-  GtkWidget *frame, *table, *table2, *paned, *sw, *text;
+  GtkWidget *frame, *table, *table2, *paned, *hpaned, *sw, *text;
   int i;
   char buf[256];
   struct sprite *sprite;
@@ -1190,10 +1200,22 @@ static void setup_widgets(void)
   gtk_paned_pack2(GTK_PANED(paned), sbox, TRUE, TRUE);
   avbox = detached_widget_fill(sbox);
 
+  hpaned = gtk_hpaned_new();
+  gtk_box_pack_start(GTK_BOX(avbox), hpaned, TRUE, TRUE, 0);
+  bottom_hpaned = hpaned;
+
   bottom_notebook = gtk_notebook_new();
   gtk_notebook_set_tab_pos(GTK_NOTEBOOK(bottom_notebook), GTK_POS_TOP);
   gtk_notebook_set_scrollable(GTK_NOTEBOOK(bottom_notebook), TRUE);
-  gtk_box_pack_start(GTK_BOX(avbox), bottom_notebook, TRUE, TRUE, 0);
+  gtk_paned_pack1(GTK_PANED(hpaned), bottom_notebook, TRUE, TRUE);
+
+  right_notebook = gtk_notebook_new();
+  g_object_ref(right_notebook);
+  gtk_notebook_set_tab_pos(GTK_NOTEBOOK(right_notebook), GTK_POS_TOP);
+  gtk_notebook_set_scrollable(GTK_NOTEBOOK(right_notebook), TRUE);
+  if (split_bottom_notebook) {
+    gtk_paned_pack2(GTK_PANED(hpaned), right_notebook, TRUE, TRUE);
+  }
 
   vbox = gtk_vbox_new(FALSE, 0);
 
@@ -1950,3 +1972,18 @@ void add_idle_callback(void (callback)(void *), void *data)
   cb->data = data;
   gtk_idle_add(idle_callback_wrapper, cb);
 }
+
+/****************************************************************************
+  Option callback for the 'split_bottom_notebook' option.
+****************************************************************************/
+static void split_bottom_notebook_callback(struct client_option *op)
+{
+  popdown_meswin_dialog();
+  if (*op->p_bool_value) {
+    gtk_paned_pack2(GTK_PANED(bottom_hpaned), right_notebook, TRUE, TRUE);
+    gtk_widget_show_all(right_notebook);
+  } else {
+    gtk_container_remove(GTK_CONTAINER(bottom_hpaned), right_notebook);
+  }
+  popup_meswin_dialog(FALSE);
+}
diff --git a/client/gui-gtk-2.0/gui_main.h b/client/gui-gtk-2.0/gui_main.h
index 0b4c063..5e53faf 100644
--- a/client/gui-gtk-2.0/gui_main.h
+++ b/client/gui-gtk-2.0/gui_main.h
@@ -26,6 +26,7 @@ extern PangoFontDescription *        city_productions_font;
 
 extern bool enable_tabs;
 extern bool better_fog;
+extern bool split_bottom_notebook;
 
 extern GdkGC *          civ_gc;
 extern GdkGC *          mask_fg_gc;
@@ -71,6 +72,7 @@ extern GtkWidget *	toplevel_tabs;
 extern GtkWidget *	top_notebook;
 extern GtkWidget *	map_widget;
 extern GtkWidget *	bottom_notebook;
+extern GtkWidget *	right_notebook;
 extern GtkTextBuffer *	message_buffer;
 extern GtkTreeStore *conn_model;
 
diff --git a/client/gui-gtk-2.0/messagewin.c b/client/gui-gtk-2.0/messagewin.c
index 0f5dfcf..647a7be 100644
--- a/client/gui-gtk-2.0/messagewin.c
+++ b/client/gui-gtk-2.0/messagewin.c
@@ -149,9 +149,14 @@ static void create_meswin_dialog(void)
 {
   GtkCellRenderer *renderer;
   GtkTreeViewColumn *col;
-  GtkWidget *view, *sw, *cmd;
+  GtkWidget *view, *sw, *cmd, *notebook;
 
-  gui_dialog_new(&meswin_shell, GTK_NOTEBOOK(bottom_notebook), NULL);
+  if (split_bottom_notebook) {
+    notebook = right_notebook;
+  } else {
+    notebook = bottom_notebook;
+  }
+  gui_dialog_new(&meswin_shell, GTK_NOTEBOOK(notebook), NULL);
   gui_dialog_set_title(meswin_shell, _("Messages"));
 
   meswin_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to