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

> [book - Wed Feb 04 07:00:22 2009]:
> 
> 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.

Updated to recent S2_1 and trunk.


-----------------------------------------------------------------------
シンクロ率が低下しています。
 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 c3c0a70..b1ebd21 100644
--- a/client/gui-gtk-2.0/gui_main.c
+++ b/client/gui-gtk-2.0/gui_main.c
@@ -95,13 +95,15 @@ int overview_canvas_store_height = 2 * 50;
 bool enable_tabs = TRUE;
 bool better_fog = TRUE;
 bool show_chat_message_time = FALSE;
+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;
@@ -147,6 +149,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"),
@@ -186,7 +190,13 @@ client_option gui_options[] = {
                   N_("If this option is enabled then all chat messages "
                      "will be prefixed by a time string of the form "
                      "[hour:minute:second]."),
-                  COC_INTERFACE)
+                  COC_INTERFACE),
+  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);
 
@@ -892,7 +902,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;
@@ -1198,10 +1208,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);
 
@@ -1961,3 +1983,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 9f9205e..db15136 100644
--- a/client/gui-gtk-2.0/gui_main.h
+++ b/client/gui-gtk-2.0/gui_main.h
@@ -27,6 +27,7 @@ extern PangoFontDescription *        city_productions_font;
 extern bool enable_tabs;
 extern bool better_fog;
 extern bool show_chat_message_time;
+extern bool split_bottom_notebook;
 
 extern GdkGC *          civ_gc;
 extern GdkGC *          mask_fg_gc;
@@ -73,6 +74,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);
 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 12e66c0..c5fe7a1 100644
--- a/client/gui-gtk-2.0/gui_main.c
+++ b/client/gui-gtk-2.0/gui_main.c
@@ -98,13 +98,15 @@ int overview_canvas_store_height = 2 * 50;
 bool enable_tabs = TRUE;
 bool better_fog = TRUE;
 bool show_chat_message_time = FALSE;
+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;
@@ -166,6 +168,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"),
@@ -206,6 +210,12 @@ client_option gui_options[] = {
                      "will be prefixed by a time string of the form "
                      "[hour:minute:second]."),
                   COC_INTERFACE),
+  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"),
@@ -998,7 +1008,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;
@@ -1325,10 +1335,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);
 
@@ -2121,3 +2143,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 98e5a7a..38567d9 100644
--- a/client/gui-gtk-2.0/gui_main.h
+++ b/client/gui-gtk-2.0/gui_main.h
@@ -27,6 +27,7 @@ extern PangoFontDescription *        city_productions_font;
 extern bool enable_tabs;
 extern bool better_fog;
 extern bool show_chat_message_time;
+extern bool split_bottom_notebook;
 
 extern GdkGC *          civ_gc;
 extern GdkGC *          mask_fg_gc;
@@ -74,6 +75,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);
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to