Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2004:
[Freeciv-Dev] (PR#10435) Repodlg tabs in GTK+2 client
Home

[Freeciv-Dev] (PR#10435) Repodlg tabs in GTK+2 client

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: akaquinn@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#10435) Repodlg tabs in GTK+2 client
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Fri, 29 Oct 2004 20:20:08 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10435 >

Make Kauf happy, plug memory leak, fixed bugs, don't display close
button when in tabbed mode (since we have one in the tab already), make
tabbed mode the default, other minor fixes.

Index: client/plrdlg_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/plrdlg_common.c,v
retrieving revision 1.11
diff -u -r1.11 plrdlg_common.c
--- client/plrdlg_common.c      23 Oct 2004 20:02:52 -0000      1.11
+++ client/plrdlg_common.c      30 Oct 2004 03:18:34 -0000
@@ -223,9 +223,9 @@
   {TRUE, COL_TEXT, N_("Vision"), col_vision, NULL, "vision"},
   {TRUE, COL_TEXT, N_("Reputation"), col_reputation, NULL, "reputation"},
   {TRUE, COL_TEXT, N_("State"), col_state, NULL, "state"},
-  {TRUE, COL_TEXT, N_("?Player_dlg:Host"), col_host, NULL, "host"},
-  {TRUE, COL_RIGHT_TEXT, N_("?Player_dlg:Idle"), col_idle, NULL, "idle"},
-  {TRUE, COL_RIGHT_TEXT, N_("Ping"), get_ping_time_text, NULL, "ping"}
+  {FALSE, COL_TEXT, N_("?Player_dlg:Host"), col_host, NULL, "host"},
+  {FALSE, COL_RIGHT_TEXT, N_("?Player_dlg:Idle"), col_idle, NULL, "idle"},
+  {FALSE, COL_RIGHT_TEXT, N_("Ping"), get_ping_time_text, NULL, "ping"}
 };
 
 const int num_player_dlg_columns = ARRAY_SIZE(player_dlg_columns);
Index: client/gui-gtk-2.0/cityrep.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/cityrep.c,v
retrieving revision 1.64
diff -u -r1.64 cityrep.c
--- client/gui-gtk-2.0/cityrep.c        16 Oct 2004 22:26:03 -0000      1.64
+++ client/gui-gtk-2.0/cityrep.c        30 Oct 2004 03:18:35 -0000
@@ -63,12 +63,11 @@
 static void create_city_report_dialog(bool make_modal);
 static void city_model_init(void);
 
-static void city_center_callback(GtkWidget *w, gpointer data);
-static void city_popup_callback(GtkWidget *w, gpointer data);
 static void city_activated_callback(GtkTreeView *view, GtkTreePath *path,
                                    GtkTreeViewColumn *col, gpointer data);
 
-static void city_buy_callback(GtkWidget *w, gpointer data);
+static void city_command_callback(struct gui_dialog *dlg, int response);
+
 static void city_selection_changed_callback(GtkTreeSelection *selection);
 
 static void create_select_menu(GtkWidget *item);
@@ -77,7 +76,11 @@
 static void create_first_menu(GtkWidget *item);
 static void create_next_menu(GtkWidget *item);
 
-static GtkWidget *city_dialog_shell=NULL;
+static struct gui_dialog *city_dialog_shell = NULL;
+
+enum {
+  CITY_CENTER = 1, CITY_POPUP, CITY_BUY
+};
 
 static GtkWidget *city_view;
 static GtkTreeSelection *city_selection;
@@ -162,12 +165,11 @@
     city_dialog_shell_is_modal = make_modal;
     
     create_city_report_dialog(make_modal);
-    gtk_set_relative_position(toplevel, city_dialog_shell, 10, 10);
 
     select_menu_cached = FALSE;
   }
 
-  gtk_window_present(GTK_WINDOW(city_dialog_shell));
+  gui_dialog_present(city_dialog_shell);
   hilite_cities_from_canvas();
 }
 
@@ -177,7 +179,7 @@
 void popdown_city_report_dialog(void)
 {
   if (city_dialog_shell) {
-    gtk_widget_destroy(city_dialog_shell);
+    gui_dialog_destroy(city_dialog_shell);
   }
 }
 
@@ -767,53 +769,38 @@
   GtkWidget *w, *sw, *menubar;
   int i;
   
-  city_dialog_shell = gtk_dialog_new_with_buttons(_("Cities"),
-       NULL,
-       0,
-       NULL);
-  setup_dialog(city_dialog_shell, toplevel);
-  gtk_window_set_default_size(GTK_WINDOW(city_dialog_shell), -1, 420);
-  gtk_dialog_set_default_response(GTK_DIALOG(city_dialog_shell),
-                                 GTK_RESPONSE_CLOSE);
+  gui_dialog_new(&city_dialog_shell, GTK_NOTEBOOK(top_notebook));
+  gui_dialog_set_title(city_dialog_shell, _("Cities"));
 
-  if (make_modal) {
-    gtk_window_set_transient_for(GTK_WINDOW(city_dialog_shell),
-                                GTK_WINDOW(toplevel));
-    gtk_window_set_modal(GTK_WINDOW(city_dialog_shell), TRUE);
-  }
+  gui_dialog_set_default_size(city_dialog_shell, -1, 420);
 
-  g_signal_connect(city_dialog_shell, "response",
-                  G_CALLBACK(gtk_widget_destroy), NULL);
-  g_signal_connect(city_dialog_shell, "destroy",
-                  G_CALLBACK(gtk_widget_destroyed), &city_dialog_shell);
+  gui_dialog_response_set_callback(city_dialog_shell,
+      city_command_callback);
 
   /* menubar */
   menubar = create_city_report_menubar();
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(city_dialog_shell)->vbox),
+  gtk_box_pack_start(GTK_BOX(city_dialog_shell->vbox),
        menubar, FALSE, FALSE, 0);
 
   /* buttons */
-  w = gtk_stockbutton_new(GTK_STOCK_ZOOM_FIT, _("Cen_ter"));
-  gtk_box_pack_end(GTK_BOX(GTK_DIALOG(city_dialog_shell)->action_area),
-       w, FALSE, TRUE, 0);
-  g_signal_connect(w, "clicked", G_CALLBACK(city_center_callback), NULL);
+  w = gui_dialog_add_stockbutton(city_dialog_shell, GTK_STOCK_ZOOM_FIT,
+      _("Cen_ter"), CITY_CENTER);
   city_center_command = w;
 
-  w = gtk_stockbutton_new(GTK_STOCK_ZOOM_IN, _("_Popup"));
-  gtk_box_pack_end(GTK_BOX(GTK_DIALOG(city_dialog_shell)->action_area),
-       w, FALSE, TRUE, 0);
-  g_signal_connect(w, "clicked", G_CALLBACK(city_popup_callback), NULL);
+  w = gui_dialog_add_stockbutton(city_dialog_shell, GTK_STOCK_ZOOM_IN,
+      _("_Popup"), CITY_POPUP);
   city_popup_command = w;
 
-  w = gtk_stockbutton_new(GTK_STOCK_EXECUTE, _("_Buy"));
-  gtk_box_pack_end(GTK_BOX(GTK_DIALOG(city_dialog_shell)->action_area),
-       w, FALSE, TRUE, 0);
-  g_signal_connect(w, "clicked", G_CALLBACK(city_buy_callback), NULL);
+  w = gui_dialog_add_stockbutton(city_dialog_shell, GTK_STOCK_EXECUTE,
+      _("_Buy"), CITY_BUY);
   city_buy_command = w;
 
-  gtk_dialog_add_button(GTK_DIALOG(city_dialog_shell),
+  gui_dialog_add_button(city_dialog_shell,
                        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
 
+  gui_dialog_set_default_response(city_dialog_shell,
+                                 GTK_RESPONSE_CLOSE);
+
   /* tree view */
   for (i=0; i<NUM_CREPORT_COLS; i++)
     titles[i] = buf[i];
@@ -856,11 +843,10 @@
                                  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
   gtk_container_add(GTK_CONTAINER(sw), city_view);
 
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(city_dialog_shell)->vbox),
+  gtk_box_pack_start(GTK_BOX(city_dialog_shell->vbox),
        sw, TRUE, TRUE, 0);
 
-  gtk_widget_show_all(GTK_DIALOG(city_dialog_shell)->vbox);
-  gtk_widget_show_all(GTK_DIALOG(city_dialog_shell)->action_area);
+  gui_dialog_show_all(city_dialog_shell);
   city_model_init();
 
   city_selection_changed_callback(city_selection);
@@ -1000,14 +986,6 @@
 /****************************************************************
 ...
 *****************************************************************/
-static void city_buy_callback(GtkWidget *w, gpointer data)
-{
-  gtk_tree_selection_selected_foreach(city_selection, buy_iterate, NULL);
-}
-
-/****************************************************************
-...
-*****************************************************************/
 static void center_iterate(GtkTreeModel *model, GtkTreePath *path,
                           GtkTreeIter *it, gpointer data)
 {
@@ -1022,14 +1000,6 @@
 /****************************************************************
 ...
 *****************************************************************/
-static void city_center_callback(GtkWidget *w, gpointer data)
-{
-  gtk_tree_selection_selected_foreach(city_selection, center_iterate, NULL);
-}
-
-/****************************************************************
-...
-*****************************************************************/
 static void popup_iterate(GtkTreeModel *model, GtkTreePath *path,
                          GtkTreeIter *it, gpointer data)
 {
@@ -1049,9 +1019,22 @@
 /****************************************************************
 ...
 *****************************************************************/
-static void city_popup_callback(GtkWidget *w, gpointer data)
+static void city_command_callback(struct gui_dialog *dlg, int response)
 {
-  gtk_tree_selection_selected_foreach(city_selection, popup_iterate, NULL);
+  switch (response) {
+  case CITY_CENTER:
+    gtk_tree_selection_selected_foreach(city_selection, center_iterate, NULL);
+    break;
+  case CITY_POPUP:
+    gtk_tree_selection_selected_foreach(city_selection, popup_iterate, NULL);
+    break;
+  case CITY_BUY:
+    gtk_tree_selection_selected_foreach(city_selection, buy_iterate, NULL);
+    break;
+  default:
+    gui_dialog_destroy(dlg);
+    break;
+  }
 }
 
 /****************************************************************
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.86
diff -u -r1.86 gui_main.c
--- client/gui-gtk-2.0/gui_main.c       24 Oct 2004 23:18:07 -0000      1.86
+++ client/gui-gtk-2.0/gui_main.c       30 Oct 2004 03:18:36 -0000
@@ -84,11 +84,13 @@
 int overview_canvas_store_height = 2 * 50;
 
 bool fullscreen_mode = FALSE;
+bool enable_tabs = TRUE;
 
 GtkWidget *toplevel;
+GdkWindow *root_window;
 GtkWidget *toplevel_tabs;
 GtkWidget *top_vbox;
-GdkWindow *root_window;
+GtkWidget *top_notebook, *bottom_notebook;
 
 PangoFontDescription *main_font;
 PangoFontDescription *city_productions_font;
@@ -136,6 +138,7 @@
   GEN_BOOL_OPTION(dialogs_on_top,      N_("Keep dialogs on top")),
   GEN_BOOL_OPTION(show_task_icons,     N_("Show worklist task icons")),
   GEN_BOOL_OPTION(fullscreen_mode,     N_("Fullscreen Mode")),
+  GEN_BOOL_OPTION(enable_tabs,         N_("Enable status report tabs")),
 };
 const int num_gui_options = ARRAY_SIZE(gui_options);
 
@@ -620,7 +623,7 @@
   int i;
   struct Sprite *sprite;
 
-  GtkWidget *notebook, *messages, *statusbar;
+  GtkWidget *notebook, *statusbar;
 
   message_buffer = gtk_text_buffer_new(NULL);
 
@@ -842,10 +845,17 @@
   unit_pixmap_table = table;
   populate_unit_pixmap_table();
 
+  top_notebook = gtk_notebook_new();  
+  gtk_notebook_set_tab_pos(GTK_NOTEBOOK(top_notebook), GTK_POS_BOTTOM);
+  gtk_notebook_set_scrollable(GTK_NOTEBOOK(top_notebook), TRUE);
+  gtk_box_pack_start(GTK_BOX(hbox), top_notebook, TRUE, TRUE, 0);
+
   /* Map canvas and scrollbars */
 
   table = gtk_table_new(2, 2, FALSE);
-  gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 0);
+
+  label = gtk_label_new_with_mnemonic(_("M_ap"));
+  gtk_notebook_append_page(GTK_NOTEBOOK(top_notebook), table, label);
 
   frame = gtk_frame_new(NULL);
   gtk_table_attach(GTK_TABLE(table), frame, 0, 1, 0, 1,
@@ -903,8 +913,10 @@
   gtk_paned_pack2(GTK_PANED(paned), sbox, TRUE, TRUE);
   avbox = detached_widget_fill(sbox);
 
-  notebook = gtk_notebook_new();
-  gtk_box_pack_start(GTK_BOX(avbox), notebook, TRUE, TRUE, 0);
+  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);
 
   vbox = gtk_vbox_new(FALSE, 0);
 
@@ -917,7 +929,7 @@
   gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
 
   label = gtk_label_new_with_mnemonic(_("_Chat"));
-  gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label);
+  gtk_notebook_append_page(GTK_NOTEBOOK(bottom_notebook), vbox, label);
 
   text = gtk_text_view_new_with_buffer(message_buffer);
   gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
@@ -951,21 +963,22 @@
   g_signal_connect(inputline, "key_press_event",
                    G_CALLBACK(inputline_handler), NULL);
 
-  label = gtk_label_new_with_mnemonic(_("_Messages"));
-
-  messages = create_meswin_area();
-  gtk_notebook_append_page(GTK_NOTEBOOK(notebook), messages, label);
+  if (enable_tabs) {
+    popup_meswin_dialog();
+  }
 
   /* Other things to take care of */
 
   gtk_widget_show_all(gtk_bin_get_child(GTK_BIN(toplevel)));
   gtk_widget_hide(more_arrow_pixmap);
 
+  gtk_notebook_set_current_page(GTK_NOTEBOOK(top_notebook), 0);
+  gtk_notebook_set_current_page(GTK_NOTEBOOK(bottom_notebook), 0);
+
   if (!map_scrollbars) {
     gtk_widget_hide(map_horizontal_scrollbar);
     gtk_widget_hide(map_vertical_scrollbar);
   }
-
 }
 
 /**************************************************************************
Index: client/gui-gtk-2.0/gui_main.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.h,v
retrieving revision 1.15
diff -u -r1.15 gui_main.h
--- client/gui-gtk-2.0/gui_main.h       18 Oct 2004 23:49:27 -0000      1.15
+++ client/gui-gtk-2.0/gui_main.h       30 Oct 2004 03:18:36 -0000
@@ -42,6 +42,7 @@
 extern PangoFontDescription *        city_productions_font;
 
 extern bool fullscreen_mode;
+extern bool enable_tabs;
 
 extern GdkGC *          civ_gc;
 extern GdkGC *          mask_fg_gc;
@@ -84,6 +85,8 @@
 extern GdkWindow *      root_window;
 
 extern GtkWidget *     toplevel_tabs;
+extern GtkWidget *     top_notebook;
+extern GtkWidget *     bottom_notebook;
 extern GtkTextBuffer * message_buffer;
 
 void enable_menus(bool enable);
Index: client/gui-gtk-2.0/gui_stuff.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_stuff.c,v
retrieving revision 1.14
diff -u -r1.14 gui_stuff.c
--- client/gui-gtk-2.0/gui_stuff.c      17 Sep 2004 16:07:48 -0000      1.14
+++ client/gui-gtk-2.0/gui_stuff.c      30 Oct 2004 03:18:37 -0000
@@ -26,6 +26,7 @@
 #include "fcintl.h"
 #include "mem.h"
 
+#include "colors.h"
 #include "options.h"
 #include "gui_main.h"
 
@@ -269,3 +270,378 @@
   }
 }
 
+
+
+
+
+static void gui_dialog_response(struct gui_dialog *dlg, int response)
+{
+  if (dlg->response_callback) {
+    (*dlg->response_callback)(dlg, response);
+  }
+}
+
+static void gui_dialog_destroyed(struct gui_dialog *dlg, int response)
+{
+  gui_dialog_destroy(dlg);
+}
+
+static void gui_dialog_destroy_handler(GtkWidget *w, struct gui_dialog **pdlg)
+{
+  if ((*pdlg)->type == GUI_DIALOG_TAB) {
+    GtkWidget *notebook = (*pdlg)->v.tab.notebook;
+    gulong handler_id = (*pdlg)->v.tab.handler_id;
+
+    g_signal_handler_disconnect(notebook, handler_id);
+  }
+
+  free(*pdlg);
+  *pdlg = NULL;
+}
+
+static gint gui_dialog_delete_handler(GtkWidget *widget,
+                                     GdkEventAny *ev, gpointer data)
+{
+  struct gui_dialog *dlg = data;
+
+  /* emit response signal. */
+  gui_dialog_response(dlg, GTK_RESPONSE_DELETE_EVENT);
+                                                                               
+  /* do the destroy by default. */
+  return FALSE;
+}
+
+static gboolean gui_dialog_key_press_handler(GtkWidget *w, GdkEventKey *ev,
+                                            gpointer data)
+{
+  if (ev->keyval == GDK_Escape) {
+    GdkEvent *event;
+
+    /* synthesize delete_event to close dialog. */
+    event = gdk_event_new(GDK_DELETE);
+
+    event->any.window = g_object_ref(w->window);
+    event->any.send_event = TRUE;
+
+    gtk_main_do_event(event);
+    gdk_event_free(event);
+  }
+
+  /* propagate event further. */
+  return FALSE;
+}
+
+static void gui_dialog_switch_page_handler(GtkNotebook *notebook,
+                                          GtkNotebookPage *page,
+                                          guint num,
+                                          struct gui_dialog *dlg)
+{
+  gint n;
+
+  n = gtk_notebook_page_num(GTK_NOTEBOOK(dlg->v.tab.notebook), dlg->vbox);
+
+  if (n == num) {
+    GtkRcStyle *rc_style = gtk_widget_get_modifier_style(dlg->v.tab.label);
+
+    rc_style->color_flags[GTK_STATE_ACTIVE] &= ~GTK_RC_FG;
+    gtk_widget_modify_style(dlg->v.tab.label, rc_style);
+  }
+}
+
+void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook)
+{
+  struct gui_dialog *dlg;
+  GtkWidget *vbox, *action_area;
+
+  dlg = fc_malloc(sizeof(*dlg));
+  *pdlg = dlg;
+
+  vbox = gtk_vbox_new(FALSE, 0);
+  gtk_widget_show(vbox);
+
+  action_area = gtk_hbutton_box_new();
+  gtk_button_box_set_layout(GTK_BUTTON_BOX(action_area), GTK_BUTTONBOX_END);
+  gtk_box_pack_end(GTK_BOX(vbox), action_area, FALSE, TRUE, 0);
+  gtk_widget_show(action_area);
+ 
+  gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
+  gtk_box_set_spacing(GTK_BOX(action_area), 10);
+  gtk_container_set_border_width(GTK_CONTAINER(action_area), 5);
+
+  if (enable_tabs) {
+    dlg->type = GUI_DIALOG_TAB;
+  } else {
+    dlg->type = GUI_DIALOG_WINDOW;
+  }
+
+  switch (dlg->type) {
+  case GUI_DIALOG_WINDOW:
+    {
+      GtkWidget *window;
+
+      window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+      gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_MOUSE);
+      setup_dialog(window, toplevel);
+
+      gtk_container_add(GTK_CONTAINER(window), vbox);
+      dlg->v.window = window;
+    }
+    break;
+  case GUI_DIALOG_TAB:
+    {
+      GtkWidget *hbox, *label, *image, *button;
+      gint w, h;
+
+      gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &w, &h);
+
+      hbox = gtk_hbox_new(FALSE, 0);
+
+      label = gtk_label_new(NULL);
+      gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+      gtk_misc_set_padding(GTK_MISC(label), 4, 0);
+      gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+
+      button = gtk_button_new();
+      gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
+      g_signal_connect_swapped(button, "clicked",
+         G_CALLBACK(gui_dialog_destroy), dlg);
+
+      image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+      gtk_widget_set_size_request(button, w, h);
+      gtk_container_add(GTK_CONTAINER(button), image);
+
+      gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+
+      gtk_widget_show_all(hbox);
+
+      gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, hbox);
+      dlg->v.tab.handler_id =
+       g_signal_connect(notebook, "switch_page",
+           G_CALLBACK(gui_dialog_switch_page_handler), dlg);
+
+      dlg->v.tab.label = label;
+      dlg->v.tab.notebook = GTK_WIDGET(notebook);
+    }
+    break;
+  }
+
+  dlg->vbox = vbox;
+  dlg->action_area = action_area;
+
+  dlg->response_callback = gui_dialog_destroyed;
+
+  g_signal_connect(vbox, "destroy",
+      G_CALLBACK(gui_dialog_destroy_handler), pdlg);
+  g_signal_connect(vbox, "delete_event",
+      G_CALLBACK(gui_dialog_delete_handler), dlg);
+  g_signal_connect(vbox, "key_press_event",
+      G_CALLBACK(gui_dialog_key_press_handler), pdlg);
+
+  g_object_set_data(G_OBJECT(vbox), "gui-dialog-data", dlg);
+}
+
+static void action_widget_activated(GtkWidget *button, GtkWidget *vbox)
+{
+  struct gui_dialog *dlg =
+    g_object_get_data(G_OBJECT(vbox), "gui-dialog-data");
+  gpointer arg2 =
+    g_object_get_data(G_OBJECT(button), "gui-dialog-response-data");
+
+  gui_dialog_response(dlg, GPOINTER_TO_INT(arg2));
+}
+
+static void gui_dialog_pack_button(struct gui_dialog *dlg, GtkWidget *button,
+                                  int response)
+{
+  gint signal_id;
+
+  g_return_if_fail(GTK_IS_BUTTON(button));
+
+  g_object_set_data(G_OBJECT(button), "gui-dialog-response-data",
+      GINT_TO_POINTER(response));
+
+  if ((signal_id = g_signal_lookup("clicked", GTK_TYPE_BUTTON))) {
+    GClosure *closure;
+
+    closure = g_cclosure_new_object(G_CALLBACK(action_widget_activated),
+       G_OBJECT(dlg->vbox));
+    g_signal_connect_closure_by_id(button, signal_id, 0, closure, FALSE);
+  }
+
+  gtk_box_pack_end(GTK_BOX(dlg->action_area), button, FALSE, TRUE, 0);
+}
+
+GtkWidget *gui_dialog_add_stockbutton(struct gui_dialog *dlg,
+                                     const char *stock,
+                                     const char *text, int response)
+{
+  GtkWidget *button;
+
+  button = gtk_stockbutton_new(stock, text);
+  GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+  gtk_widget_show(button);
+  gui_dialog_pack_button(dlg, button, response);
+
+  return button;
+}
+
+GtkWidget *gui_dialog_add_button(struct gui_dialog *dlg,
+                                const char *text, int response)
+{
+  GtkWidget *button;
+
+  button = gtk_button_new_from_stock(text);
+  GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+  gtk_widget_show(button);
+  gui_dialog_pack_button(dlg, button, response);
+
+  return button;
+}
+
+void gui_dialog_set_default_response(struct gui_dialog *dlg, int response)
+{
+  GList *children;
+  GList *list;
+
+  children = gtk_container_get_children(GTK_CONTAINER(dlg->action_area));
+
+  for (list = children; list; list = g_list_next(list)) {
+    GtkWidget *button = list->data;
+    gpointer data = g_object_get_data(G_OBJECT(button),
+       "gui-dialog-response-data");
+
+    if (response == GPOINTER_TO_INT(data)) {
+      gtk_widget_grab_default(button);
+    }
+  }
+
+  g_list_free(children);
+}
+
+void gui_dialog_set_response_sensitive(struct gui_dialog *dlg,
+                                      int response, bool setting)
+{
+  GList *children;
+  GList *list;
+
+  children = gtk_container_get_children(GTK_CONTAINER(dlg->action_area));
+
+  for (list = children; list; list = g_list_next(list)) {
+    GtkWidget *button = list->data;
+    gpointer data = g_object_get_data(G_OBJECT(button),
+       "gui-dialog-response-data");
+
+    if (response == GPOINTER_TO_INT(data)) {
+      gtk_widget_set_sensitive(button, setting);
+    }
+  }
+
+  g_list_free(children);
+}
+
+GtkWidget *gui_dialog_get_toplevel(struct gui_dialog *dlg)
+{
+  return gtk_widget_get_toplevel(dlg->vbox);
+}
+
+void gui_dialog_show_all(struct gui_dialog *dlg)
+{
+  gtk_widget_show_all(dlg->vbox);
+
+  if (dlg->type == GUI_DIALOG_TAB) {
+    GList *children;
+    GList *list;
+    gint num_visible = 0;
+
+    children = gtk_container_get_children(GTK_CONTAINER(dlg->action_area));
+
+    for (list = children; list; list = g_list_next(list)) {
+      GtkWidget *button = list->data;
+      gpointer data = g_object_get_data(G_OBJECT(button),
+         "gui-dialog-response-data");
+
+      if (GPOINTER_TO_INT(data) != GTK_RESPONSE_CLOSE) {
+       num_visible++;
+      } else {
+       gtk_widget_hide(button);
+      }
+    }
+    g_list_free(children);
+
+    if (num_visible == 0) {
+      gtk_widget_hide(dlg->action_area);
+    }
+  }
+}
+
+void gui_dialog_present(struct gui_dialog *dlg)
+{
+  switch (dlg->type) {
+  case GUI_DIALOG_WINDOW:
+    gtk_window_present(GTK_WINDOW(dlg->v.window));
+    break;
+  case GUI_DIALOG_TAB:
+    {
+      GtkNotebook *notebook = GTK_NOTEBOOK(dlg->v.tab.notebook);
+      gint current, n;
+
+      current = gtk_notebook_get_current_page(notebook);
+      n = gtk_notebook_page_num(notebook, dlg->vbox);
+
+      if (current != n) {
+       GtkWidget *label = dlg->v.tab.label;
+
+       gtk_widget_modify_fg(label, GTK_STATE_ACTIVE,
+           colors_standard[COLOR_STD_RED]);
+      }
+    }
+    break;
+  }
+}
+
+void gui_dialog_set_default_size(struct gui_dialog *dlg, int width, int height)
+{
+  switch (dlg->type) {
+  case GUI_DIALOG_WINDOW:
+    gtk_window_set_default_size(GTK_WINDOW(dlg->v.window), width, height);
+    break;
+  case GUI_DIALOG_TAB:
+    break;
+  }
+}
+
+void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
+{
+  switch (dlg->type) {
+  case GUI_DIALOG_WINDOW:
+    gtk_window_set_title(GTK_WINDOW(dlg->v.window), title);
+    break;
+  case GUI_DIALOG_TAB:
+    gtk_label_set_text_with_mnemonic(GTK_LABEL(dlg->v.tab.label), title);
+    break;
+  }
+}
+
+void gui_dialog_destroy(struct gui_dialog *dlg)
+{
+  switch (dlg->type) {
+  case GUI_DIALOG_WINDOW:
+    gtk_widget_destroy(dlg->v.window);
+    break;
+  case GUI_DIALOG_TAB:
+    {
+      gint n;
+
+      n = gtk_notebook_page_num(GTK_NOTEBOOK(dlg->v.tab.notebook), dlg->vbox);
+      gtk_notebook_remove_page(GTK_NOTEBOOK(dlg->v.tab.notebook), n);
+    }
+    break;
+  }
+}
+
+void gui_dialog_response_set_callback(struct gui_dialog *dlg,
+    GUI_DIALOG_RESPONSE_FUN fun)
+{
+  dlg->response_callback = fun;
+}
+
Index: client/gui-gtk-2.0/gui_stuff.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_stuff.h,v
retrieving revision 1.9
diff -u -r1.9 gui_stuff.h
--- client/gui-gtk-2.0/gui_stuff.h      11 May 2004 17:52:25 -0000      1.9
+++ client/gui-gtk-2.0/gui_stuff.h      30 Oct 2004 03:18:37 -0000
@@ -51,4 +51,54 @@
 void gtk_tree_view_focus(GtkTreeView *view);
 void setup_dialog(GtkWidget *shell, GtkWidget *parent);
 
+
+
+enum gui_dialog_type {
+  GUI_DIALOG_WINDOW,
+  GUI_DIALOG_TAB
+};
+
+struct gui_dialog;
+
+typedef void (*GUI_DIALOG_RESPONSE_FUN)(struct gui_dialog *, int);
+
+struct gui_dialog
+{
+  /* public. */
+  GtkWidget *vbox;
+  GtkWidget *action_area;
+
+  /* private. */
+  enum gui_dialog_type type;
+
+  union {
+    GtkWidget *window;
+    struct {
+      GtkWidget *label;
+      GtkWidget *notebook;
+      gulong handler_id;
+    } tab;
+  } v;
+
+  GUI_DIALOG_RESPONSE_FUN response_callback;
+};
+
+void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook);
+void gui_dialog_set_default_response(struct gui_dialog *dlg, int response);
+GtkWidget *gui_dialog_add_button(struct gui_dialog *dlg,
+    const char *text, int response);
+GtkWidget *gui_dialog_add_stockbutton(struct gui_dialog *dlg,
+    const char *stock, const char *text, int response);
+void gui_dialog_set_default_size(struct gui_dialog *dlg,
+    int width, int height);
+void gui_dialog_set_title(struct gui_dialog *dlg, const char *title);
+void gui_dialog_set_response_sensitive(struct gui_dialog *dlg,
+    int response, bool setting);
+void gui_dialog_show_all(struct gui_dialog *dlg);
+void gui_dialog_present(struct gui_dialog *dlg);
+void gui_dialog_destroy(struct gui_dialog *dlg);
+GtkWidget *gui_dialog_get_toplevel(struct gui_dialog *dlg);
+void gui_dialog_response_set_callback(struct gui_dialog *dlg,
+    GUI_DIALOG_RESPONSE_FUN fun);
+
 #endif  /* FC__GUI_STUFF_H */
Index: client/gui-gtk-2.0/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/menu.c,v
retrieving revision 1.48
diff -u -r1.48 menu.c
--- client/gui-gtk-2.0/menu.c   26 Oct 2004 18:03:04 -0000      1.48
+++ client/gui-gtk-2.0/menu.c   30 Oct 2004 03:18:39 -0000
@@ -850,6 +850,8 @@
        reports_menu_callback,  MENU_REPORT_WOW                                 
        },
   { "/" N_("Reports") "/" N_("_Top Five Cities"),      "F8",
        reports_menu_callback,  MENU_REPORT_TOP_CITIES                          
        },
+  { "/" N_("Reports") "/" N_("_Messages"),             "F9",
+       reports_menu_callback,  MENU_REPORT_MESSAGES                            
        },
   { "/" N_("Reports") "/" N_("_Demographics"),         "F11",
        reports_menu_callback,  MENU_REPORT_DEMOGRAPHIC                         
        },
   { "/" N_("Reports") "/" N_("S_paceship"),            "F12",
Index: client/gui-gtk-2.0/messagewin.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/messagewin.c,v
retrieving revision 1.26
diff -u -r1.26 messagewin.c
--- client/gui-gtk-2.0/messagewin.c     18 Sep 2004 17:24:20 -0000      1.26
+++ client/gui-gtk-2.0/messagewin.c     30 Oct 2004 03:18:39 -0000
@@ -39,11 +39,13 @@
 
 #include "messagewin.h"
 
+static struct gui_dialog *meswin_shell;
 static GtkListStore *meswin_store;
 static GtkTreeSelection *meswin_selection;
 
 static GtkWidget *goto_cmd, *popcity_cmd;
 
+static void create_meswin_dialog(void);
 static void meswin_selection_callback(GtkTreeSelection *selection,
                                       gpointer data);
 static void meswin_row_activated_callback(GtkTreeView *view,
@@ -60,6 +62,13 @@
 *****************************************************************/
 void popup_meswin_dialog(void)
 {
+  if (!meswin_shell) {
+    create_meswin_dialog();
+  }
+
+  update_meswin_dialog();
+
+  gui_dialog_present(meswin_shell);
 }
 
 /**************************************************************************
@@ -67,6 +76,9 @@
 **************************************************************************/
 void popdown_meswin_dialog(void)
 {
+  if (meswin_shell) {
+    gui_dialog_destroy(meswin_shell);
+  }
 }
 
 /****************************************************************
@@ -74,7 +86,7 @@
 *****************************************************************/
 bool is_meswin_open(void)
 {
-  return TRUE;
+  return (meswin_shell != NULL);
 }
 
 /****************************************************************
@@ -127,18 +139,19 @@
 /****************************************************************
 ...
 *****************************************************************/
-GtkWidget *create_meswin_area(void)
+static void create_meswin_dialog(void)
 {
   GtkCellRenderer *renderer;
   GtkTreeViewColumn *col;
   GtkWidget *view, *sw, *cmd;
 
-  GtkWidget *vbox, *hbox, *bbox;
+  GtkWidget *hbox, *bbox;
 
-  vbox = gtk_vbox_new(FALSE, 0);
+  gui_dialog_new(&meswin_shell, GTK_NOTEBOOK(bottom_notebook));
+  gui_dialog_set_title(meswin_shell, _("Messages"));
 
   hbox = gtk_hbox_new(FALSE, 0);
-  gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+  gtk_box_pack_start(GTK_BOX(meswin_shell->vbox), hbox, TRUE, TRUE, 0);
 
   meswin_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
 
@@ -187,7 +200,9 @@
 
   g_signal_connect(cmd, "clicked", G_CALLBACK(meswin_popcity_callback), NULL);
 
-  return vbox;
+  gui_dialog_set_default_size(meswin_shell, 520, 300);
+
+  gui_dialog_show_all(meswin_shell);
 }
 
 /**************************************************************************
@@ -195,30 +210,32 @@
 **************************************************************************/
 void real_update_meswin_dialog(void)
 {
-  int i, num = get_num_messages();
-  GtkTreeIter it;
-
-  gtk_list_store_clear(meswin_store);
-
-  for (i = 0; i < num; i++) {
-    GValue value = { 0, };
-
-    gtk_list_store_append(meswin_store, &it);
-
-    g_value_init(&value, G_TYPE_STRING);
-    g_value_set_static_string(&value, get_message(i)->descr);
-    gtk_list_store_set_value(meswin_store, &it, 0, &value);
-    g_value_unset(&value);
-
-    if (get_message(i)->visited) {
-      meswin_visited_item(i);
-    } else {
-      meswin_not_visited_item(i);
+  if (meswin_shell) {
+    int i, num = get_num_messages();
+    GtkTreeIter it;
+
+    gtk_list_store_clear(meswin_store);
+
+    for (i = 0; i < num; i++) {
+      GValue value = { 0, };
+
+      gtk_list_store_append(meswin_store, &it);
+
+      g_value_init(&value, G_TYPE_STRING);
+      g_value_set_static_string(&value, get_message(i)->descr);
+      gtk_list_store_set_value(meswin_store, &it, 0, &value);
+      g_value_unset(&value);
+
+      if (get_message(i)->visited) {
+       meswin_visited_item(i);
+      } else {
+       meswin_not_visited_item(i);
+      }
     }
-  }
 
-  gtk_widget_set_sensitive(goto_cmd, FALSE);
-  gtk_widget_set_sensitive(popcity_cmd, FALSE);
+    gtk_widget_set_sensitive(goto_cmd, FALSE);
+    gtk_widget_set_sensitive(popcity_cmd, FALSE);
+  }
 }
 
 /**************************************************************************
Index: client/gui-gtk-2.0/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/plrdlg.c,v
retrieving revision 1.39
diff -u -r1.39 plrdlg.c
--- client/gui-gtk-2.0/plrdlg.c 1 May 2004 17:28:47 -0000       1.39
+++ client/gui-gtk-2.0/plrdlg.c 30 Oct 2004 03:18:39 -0000
@@ -47,7 +47,7 @@
 
 #include "plrdlg.h"
 
-static GtkWidget *players_dialog_shell;
+static struct gui_dialog *players_dialog_shell;
 static GtkWidget *players_list;
 static GtkTreeSelection *players_selection;
 static GtkWidget *players_int_command;
@@ -74,10 +74,8 @@
 {
   if (!players_dialog_shell){
     create_players_dialog();
-    gtk_window_set_position(GTK_WINDOW(players_dialog_shell),
-       GTK_WIN_POS_MOUSE);
   }
-  gtk_window_present(GTK_WINDOW(players_dialog_shell));
+  gui_dialog_present(players_dialog_shell);
 }
 
 /****************************************************************
@@ -86,21 +84,13 @@
 void popdown_players_dialog(void)
 {
   if (players_dialog_shell) {
-    gtk_widget_destroy(players_dialog_shell);
+    gui_dialog_destroy(players_dialog_shell);
   }
 }
 
 /**************************************************************************
 ...
 **************************************************************************/
-static void players_destroy_callback(GtkObject *object, gpointer data)
-{
-  players_dialog_shell = NULL;
-}
-
-/**************************************************************************
-...
-**************************************************************************/
 static void update_players_menu(void)
 {
   GtkTreeModel *model;
@@ -258,19 +248,13 @@
   GtkWidget *sep, *sw;
   GtkWidget *menubar, *menu, *item;
 
-  players_dialog_shell = gtk_dialog_new_with_buttons(_("Players"),
-    NULL,
-    0,
-    GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
-    NULL);
-  setup_dialog(players_dialog_shell, toplevel);
-
-  gtk_window_set_default_size(GTK_WINDOW(players_dialog_shell), -1, 270);
-
-  g_signal_connect(players_dialog_shell, "destroy",
-    G_CALLBACK(players_destroy_callback), NULL);
-  g_signal_connect_swapped(players_dialog_shell, "response",
-    G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(players_dialog_shell));
+  gui_dialog_new(&players_dialog_shell, GTK_NOTEBOOK(top_notebook));
+  gui_dialog_set_title(players_dialog_shell, _("Players"));
+
+  gui_dialog_add_button(players_dialog_shell,
+      GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+
+  gui_dialog_set_default_size(players_dialog_shell, -1, 270);
 
   create_store();
 
@@ -349,9 +333,9 @@
   gtk_container_add(GTK_CONTAINER(sw), players_list);
 
   menubar = gtk_menu_bar_new();
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(players_dialog_shell)->vbox), menubar,
+  gtk_box_pack_start(GTK_BOX(players_dialog_shell->vbox), menubar,
                     FALSE, FALSE, 0);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(players_dialog_shell)->vbox), sw,
+  gtk_box_pack_start(GTK_BOX(players_dialog_shell->vbox), sw,
                     TRUE, TRUE, 5);
 
   item = gtk_menu_item_new_with_mnemonic(_("_Player"));
@@ -403,8 +387,9 @@
   gtk_widget_add_accelerator(players_sship_command,
     "activate", accel, GDK_S, 0, GTK_ACCEL_VISIBLE);
 
-  gtk_window_add_accel_group(GTK_WINDOW(players_dialog_shell), accel);
-  gtk_widget_show_all(GTK_DIALOG(players_dialog_shell)->vbox);
+  gtk_window_add_accel_group(
+      GTK_WINDOW(gui_dialog_get_toplevel(players_dialog_shell)), accel);
+  gui_dialog_show_all(players_dialog_shell);
 
   g_signal_connect(players_meet_command, "activate",
     G_CALLBACK(players_meet_callback), NULL);
@@ -420,7 +405,7 @@
   gtk_list_store_clear(store);
   update_players_dialog();
 
-  gtk_dialog_set_default_response(GTK_DIALOG(players_dialog_shell),
+  gui_dialog_set_default_response(players_dialog_shell,
     GTK_RESPONSE_CLOSE);
 }
 
Index: client/gui-gtk-2.0/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/repodlgs.c,v
retrieving revision 1.60
diff -u -r1.60 repodlgs.c
--- client/gui-gtk-2.0/repodlgs.c       29 Sep 2004 02:24:21 -0000      1.60
+++ client/gui-gtk-2.0/repodlgs.c       30 Oct 2004 03:18:39 -0000
@@ -58,7 +58,7 @@
 static void science_goal_callback(GtkWidget * widget, gpointer data);
 
 /******************************************************************/
-static GtkWidget *science_dialog_shell = NULL;
+static struct gui_dialog *science_dialog_shell = NULL;
 static GtkWidget *science_label;
 static GtkWidget *science_current_label, *science_goal_label;
 static GtkWidget *science_change_menu_button, *science_goal_menu_button;
@@ -73,7 +73,7 @@
 };
 
 static void create_economy_report_dialog(bool make_modal);
-static void economy_command_callback(GtkWidget *w, gint response_id);
+static void economy_command_callback(struct gui_dialog *dlg, int response);
 static void economy_selection_callback(GtkTreeSelection *selection,
                                       gpointer data);
 struct economy_row {
@@ -82,7 +82,7 @@
 };
 static struct economy_row economy_row_type[U_LAST + B_LAST];
 
-static GtkWidget *economy_dialog_shell = NULL;
+static struct gui_dialog *economy_dialog_shell = NULL;
 static GtkWidget *economy_label2;
 static GtkListStore *economy_store;
 static GtkTreeSelection *economy_selection;
@@ -91,11 +91,11 @@
 
 /******************************************************************/
 static void create_activeunits_report_dialog(bool make_modal);
-static void activeunits_command_callback(GtkWidget *w, gint response_id);
+static void activeunits_command_callback(struct gui_dialog *dlg, int response);
 static void activeunits_selection_callback(GtkTreeSelection *selection,
                                           gpointer data);
 static int activeunits_type[U_LAST];
-static GtkWidget *activeunits_dialog_shell = NULL;
+static struct gui_dialog *activeunits_dialog_shell = NULL;
 static GtkListStore *activeunits_store;
 static GtkTreeSelection *activeunits_selection;
 
@@ -142,10 +142,9 @@
     science_dialog_shell_is_modal = make_modal;
     
     create_science_dialog(make_modal);
-    gtk_set_relative_position(toplevel, science_dialog_shell, 10, 10);
   }
 
-  gtk_window_present(GTK_WINDOW(science_dialog_shell));
+  gui_dialog_present(science_dialog_shell);
 }
 
 
@@ -155,7 +154,7 @@
 void popdown_science_dialog(void)
 {
   if (science_dialog_shell) {
-    gtk_widget_destroy(science_dialog_shell);
+    gui_dialog_destroy(science_dialog_shell);
   }
 }
  
@@ -168,35 +167,22 @@
   GtkWidget *frame, *hbox, *w;
   int i;
 
-  science_dialog_shell = gtk_dialog_new_with_buttons(_("Science"),
-       NULL,
-       0,
-       GTK_STOCK_CLOSE,
-       GTK_RESPONSE_CLOSE,
-       NULL);
-  setup_dialog(science_dialog_shell, toplevel);
-  gtk_dialog_set_default_response(GTK_DIALOG(science_dialog_shell),
-       GTK_RESPONSE_CLOSE);
-
-  if (make_modal) {
-    gtk_window_set_transient_for(GTK_WINDOW(science_dialog_shell),
-                                GTK_WINDOW(toplevel));
-    gtk_window_set_modal(GTK_WINDOW(science_dialog_shell), TRUE);
-  }
-
-  g_signal_connect(science_dialog_shell, "response",
-                  G_CALLBACK(gtk_widget_destroy), NULL);
-  g_signal_connect(science_dialog_shell, "destroy",
-                  G_CALLBACK(gtk_widget_destroyed), &science_dialog_shell);
+  gui_dialog_new(&science_dialog_shell, GTK_NOTEBOOK(top_notebook));
+  gui_dialog_set_title(science_dialog_shell, _("Science"));
+
+  gui_dialog_add_button(science_dialog_shell,
+      GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+  gui_dialog_set_default_response(science_dialog_shell,
+      GTK_RESPONSE_CLOSE);
 
   science_label = gtk_label_new("no text set yet");
 
-  gtk_box_pack_start( GTK_BOX( GTK_DIALOG(science_dialog_shell)->vbox ),
-        science_label, FALSE, FALSE, 0 );
+  gtk_box_pack_start(GTK_BOX(science_dialog_shell->vbox),
+        science_label, FALSE, FALSE, 0);
 
   frame = gtk_frame_new(_("Researching"));
-  gtk_box_pack_start( GTK_BOX( GTK_DIALOG(science_dialog_shell)->vbox ),
-        frame, FALSE, FALSE, 0 );
+  gtk_box_pack_start(GTK_BOX(science_dialog_shell->vbox),
+        frame, FALSE, FALSE, 0);
 
   hbox = gtk_hbox_new( TRUE, 5 );
   gtk_container_add(GTK_CONTAINER(frame), hbox);
@@ -215,8 +201,8 @@
   gtk_box_pack_start( GTK_BOX( hbox ), science_help_toggle, TRUE, FALSE, 0 );
 
   frame = gtk_frame_new( _("Goal"));
-  gtk_box_pack_start( GTK_BOX( GTK_DIALOG(science_dialog_shell)->vbox ),
-        frame, FALSE, FALSE, 0 );
+  gtk_box_pack_start(GTK_BOX(science_dialog_shell->vbox),
+        frame, FALSE, FALSE, 0);
 
   hbox = gtk_hbox_new( TRUE, 5 );
   gtk_container_add(GTK_CONTAINER(frame),hbox);
@@ -235,7 +221,7 @@
   gtk_box_pack_start( GTK_BOX( hbox ), w,TRUE, FALSE, 0 );
 
   hbox = gtk_hbox_new(TRUE, 0);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(science_dialog_shell)->vbox),
+  gtk_box_pack_start(GTK_BOX(science_dialog_shell->vbox),
                     hbox, TRUE, TRUE, 5);
 
 
@@ -263,11 +249,10 @@
                     G_CALLBACK(science_help_callback), science_model[i]);
   }
 
-  gtk_widget_show_all(GTK_DIALOG(science_dialog_shell)->vbox);
+  gui_dialog_show_all(science_dialog_shell);
 
   science_dialog_update();
-  gtk_window_set_focus(GTK_WINDOW(science_dialog_shell),
-       science_change_menu_button);
+  gtk_widget_grab_focus(science_change_menu_button);
 }
 
 /****************************************************************
@@ -594,10 +579,9 @@
     economy_dialog_shell_is_modal = make_modal;
 
     create_economy_report_dialog(make_modal);
-    gtk_set_relative_position(toplevel, economy_dialog_shell, 10, 10);
   }
 
-  gtk_window_present(GTK_WINDOW(economy_dialog_shell));
+  gui_dialog_present(economy_dialog_shell);
 }
 
 
@@ -607,11 +591,10 @@
 void popdown_economy_report_dialog(void)
 {
   if (economy_dialog_shell) {
-    gtk_widget_destroy(economy_dialog_shell);
+    gui_dialog_destroy(economy_dialog_shell);
   }
 }
  
-
 /****************************************************************
 ...
 *****************************************************************/
@@ -636,19 +619,8 @@
 
   intl_slist(ARRAY_SIZE(titles), titles, &titles_done);
   
-  economy_dialog_shell = gtk_dialog_new_with_buttons(_("Economy"),
-       NULL,
-       0,
-       NULL);
-  setup_dialog(economy_dialog_shell, toplevel);
-  gtk_dialog_set_default_response(GTK_DIALOG(economy_dialog_shell),
-       GTK_RESPONSE_CLOSE);
-
-  if (make_modal) {
-    gtk_window_set_transient_for(GTK_WINDOW(economy_dialog_shell),
-                                GTK_WINDOW(toplevel));
-    gtk_window_set_modal(GTK_WINDOW(economy_dialog_shell), TRUE);
-  }
+  gui_dialog_new(&economy_dialog_shell, GTK_NOTEBOOK(top_notebook));
+  gui_dialog_set_title(economy_dialog_shell, _("Economy"));
 
   economy_store = gtk_list_store_newv(ARRAY_SIZE(model_types), model_types);
 
@@ -657,8 +629,7 @@
                                      GTK_SHADOW_ETCHED_IN);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
                                 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(economy_dialog_shell)->vbox),
-       sw, TRUE, TRUE, 0);
+  gtk_box_pack_start(GTK_BOX(economy_dialog_shell->vbox), sw, TRUE, TRUE, 0);
 
   view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(economy_store));
   g_object_unref(economy_store);
@@ -691,33 +662,32 @@
   gtk_container_add(GTK_CONTAINER(sw), view);
 
   economy_label2 = gtk_label_new(_("Total Cost:"));
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(economy_dialog_shell)->vbox),
-       economy_label2, FALSE, FALSE, 0);
+  gtk_box_pack_start(GTK_BOX(economy_dialog_shell->vbox), economy_label2,
+      FALSE, FALSE, 0);
   gtk_misc_set_padding(GTK_MISC(economy_label2), 5, 5);
 
-  sellobsolete_command = gtk_button_new_with_mnemonic(_("Sell _Obsolete"));
-  gtk_dialog_add_action_widget(GTK_DIALOG(economy_dialog_shell),
-                              sellobsolete_command, ECONOMY_SELL_OBSOLETE);
+  sellobsolete_command =
+    gui_dialog_add_button(economy_dialog_shell, _("Sell _Obsolete"),
+       ECONOMY_SELL_OBSOLETE);
   gtk_widget_set_sensitive(sellobsolete_command, FALSE);
 
-  sellall_command = gtk_button_new_with_mnemonic(_("Sell _All"));
-  gtk_dialog_add_action_widget(GTK_DIALOG(economy_dialog_shell),
-                              sellall_command, ECONOMY_SELL_ALL);
+  sellall_command =
+    gui_dialog_add_button(economy_dialog_shell, _("Sell _All"),
+       ECONOMY_SELL_ALL);
   gtk_widget_set_sensitive(sellall_command, FALSE);
 
-  gtk_dialog_add_button(GTK_DIALOG(economy_dialog_shell),
-                       GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+  gui_dialog_add_button(economy_dialog_shell,
+      GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
 
-  g_signal_connect(economy_dialog_shell, "response",
-                  G_CALLBACK(economy_command_callback), NULL);
-  g_signal_connect(economy_dialog_shell, "destroy",
-                  G_CALLBACK(gtk_widget_destroyed), &economy_dialog_shell);
+  gui_dialog_response_set_callback(economy_dialog_shell,
+      economy_command_callback);
 
   economy_report_dialog_update();
-  gtk_window_set_default_size(GTK_WINDOW(economy_dialog_shell), -1, 350);
+  gui_dialog_set_default_size(economy_dialog_shell, -1, 350);
 
-  gtk_widget_show_all(GTK_DIALOG(economy_dialog_shell)->vbox);
-  gtk_widget_show_all(GTK_DIALOG(economy_dialog_shell)->action_area);
+  gui_dialog_set_default_response(economy_dialog_shell, GTK_RESPONSE_CLOSE);
+
+  gui_dialog_show_all(economy_dialog_shell);
 
   gtk_tree_view_focus(GTK_TREE_VIEW(view));
 }
@@ -756,16 +726,15 @@
 /****************************************************************
 ...
 *****************************************************************/
-static void economy_command_callback(GtkWidget *w, gint response_id)
+static void economy_command_callback(struct gui_dialog *dlg, int response)
 {
   int i, is_impr;
   gint row;
   GtkWidget *shell;
   char buf[1024];
 
-  if (response_id != ECONOMY_SELL_OBSOLETE
-      && response_id != ECONOMY_SELL_ALL) {
-    gtk_widget_destroy(economy_dialog_shell);
+  if (response != ECONOMY_SELL_OBSOLETE && response != ECONOMY_SELL_ALL) {
+    gui_dialog_destroy(dlg);
     return;
   }
 
@@ -775,9 +744,9 @@
   i = economy_row_type[row].type;
 
   if (is_impr == TRUE) {
-    if (response_id == ECONOMY_SELL_ALL) {
+    if (response == ECONOMY_SELL_ALL) {
       shell = gtk_message_dialog_new(
-         GTK_WINDOW(economy_dialog_shell),
+         GTK_WINDOW(gui_dialog_get_toplevel(dlg)),
          GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
          GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
          _("Do you really wish to sell your %s?\n"),
@@ -792,19 +761,19 @@
       }
     }
 
-    sell_all_improvements(i, response_id != ECONOMY_SELL_ALL,
-                         buf, sizeof(buf));
+    sell_all_improvements(i, response!= ECONOMY_SELL_ALL, buf, sizeof(buf));
   } else {
-    if (response_id == ECONOMY_SELL_OBSOLETE) {
+    if (response== ECONOMY_SELL_OBSOLETE) {
       return;
     }
     disband_all_units(i, FALSE, buf, sizeof(buf));
   }
 
-  shell = gtk_message_dialog_new(GTK_WINDOW(economy_dialog_shell),
-                                GTK_DIALOG_DESTROY_WITH_PARENT,
-                                GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
-                                buf);
+  shell = gtk_message_dialog_new(
+      GTK_WINDOW(gui_dialog_get_toplevel(dlg)),
+      GTK_DIALOG_DESTROY_WITH_PARENT,
+      GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
+      buf);
 
   g_signal_connect(shell, "response", G_CALLBACK(gtk_widget_destroy), NULL);
   gtk_window_set_title(GTK_WINDOW(shell), _("Sell-Off: Results"));
@@ -888,10 +857,9 @@
     activeunits_dialog_shell_is_modal = make_modal;
     
     create_activeunits_report_dialog(make_modal);
-    gtk_set_relative_position(toplevel, activeunits_dialog_shell, 10, 10);
   }
 
-  gtk_window_present(GTK_WINDOW(activeunits_dialog_shell));
+  gui_dialog_present(activeunits_dialog_shell);
 }
 
 
@@ -901,7 +869,7 @@
 void popdown_activeunits_report_dialog(void)
 {
   if (activeunits_dialog_shell) {
-    gtk_widget_destroy(activeunits_dialog_shell);
+    gui_dialog_destroy(activeunits_dialog_shell);
   }
 }
 
@@ -934,23 +902,11 @@
     G_TYPE_BOOLEAN
   };
   GtkWidget *view, *sw;
-  GtkWidget *command;
 
   intl_slist(ARRAY_SIZE(titles), titles, &titles_done);
 
-  activeunits_dialog_shell = gtk_dialog_new_with_buttons(_("Units"),
-       NULL,
-       0,
-       NULL);
-  setup_dialog(activeunits_dialog_shell, toplevel);
-  gtk_dialog_set_default_response(GTK_DIALOG(activeunits_dialog_shell),
-       GTK_RESPONSE_CLOSE);
-
-  if (make_modal) {
-    gtk_window_set_transient_for(GTK_WINDOW(activeunits_dialog_shell),
-                                GTK_WINDOW(toplevel));
-    gtk_window_set_modal(GTK_WINDOW(activeunits_dialog_shell), TRUE);
-  }
+  gui_dialog_new(&activeunits_dialog_shell, GTK_NOTEBOOK(top_notebook));
+  gui_dialog_set_title(activeunits_dialog_shell, _("Units"));
 
   activeunits_store = gtk_list_store_newv(ARRAY_SIZE(model_types), 
model_types);
 
@@ -959,7 +915,7 @@
                                      GTK_SHADOW_ETCHED_IN);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
                                 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(activeunits_dialog_shell)->vbox),
+  gtk_box_pack_start(GTK_BOX(activeunits_dialog_shell->vbox),
        sw, TRUE, TRUE, 0);
 
   view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(activeunits_store));
@@ -993,31 +949,29 @@
   }
   gtk_container_add(GTK_CONTAINER(sw), view);
 
-  command = gtk_stockbutton_new(GTK_STOCK_FIND, _("Find _Nearest"));
-  gtk_dialog_add_action_widget(GTK_DIALOG(activeunits_dialog_shell),
-                              command, ACTIVEUNITS_NEAREST);
-  gtk_dialog_set_response_sensitive(GTK_DIALOG(activeunits_dialog_shell),
+  gui_dialog_add_stockbutton(activeunits_dialog_shell, GTK_STOCK_FIND,
+      _("Find _Nearest"), ACTIVEUNITS_NEAREST);
+  gui_dialog_set_response_sensitive(activeunits_dialog_shell,
                                    ACTIVEUNITS_NEAREST, FALSE);        
   
-  command = gtk_button_new_with_mnemonic(_("_Upgrade"));
-  gtk_dialog_add_action_widget(GTK_DIALOG(activeunits_dialog_shell),
-                              command, ACTIVEUNITS_UPGRADE);
-  gtk_dialog_set_response_sensitive(GTK_DIALOG(activeunits_dialog_shell),
+  gui_dialog_add_button(activeunits_dialog_shell,
+      _("_Upgrade"), ACTIVEUNITS_UPGRADE);
+  gui_dialog_set_response_sensitive(activeunits_dialog_shell,
                                    ACTIVEUNITS_UPGRADE, FALSE);        
 
-  gtk_dialog_add_button(GTK_DIALOG(activeunits_dialog_shell),
-                       GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+  gui_dialog_add_button(activeunits_dialog_shell, GTK_STOCK_CLOSE,
+      GTK_RESPONSE_CLOSE);
+
+  gui_dialog_set_default_response(activeunits_dialog_shell,
+      GTK_RESPONSE_CLOSE);
 
-  g_signal_connect(activeunits_dialog_shell, "response",
-                  G_CALLBACK(activeunits_command_callback), NULL);
-  g_signal_connect(activeunits_dialog_shell, "destroy",
-                  G_CALLBACK(gtk_widget_destroyed), &activeunits_dialog_shell);
+  gui_dialog_response_set_callback(activeunits_dialog_shell,
+      activeunits_command_callback);
 
   activeunits_report_dialog_update();
-  gtk_window_set_default_size(GTK_WINDOW(activeunits_dialog_shell), -1, 350);
+  gui_dialog_set_default_size(activeunits_dialog_shell, -1, 350);
 
-  gtk_widget_show_all(GTK_DIALOG(activeunits_dialog_shell)->vbox);
-  gtk_widget_show_all(GTK_DIALOG(activeunits_dialog_shell)->action_area);
+  gui_dialog_show_all(activeunits_dialog_shell);
 
   gtk_tree_view_focus(GTK_TREE_VIEW(view));
 }
@@ -1046,22 +1000,22 @@
   }
 
   if (!is_unit_type) {
-    gtk_dialog_set_response_sensitive(GTK_DIALOG(activeunits_dialog_shell),
+    gui_dialog_set_response_sensitive(activeunits_dialog_shell,
                                      ACTIVEUNITS_NEAREST, FALSE);
 
-    gtk_dialog_set_response_sensitive(GTK_DIALOG(activeunits_dialog_shell),
+    gui_dialog_set_response_sensitive(activeunits_dialog_shell,
                                      ACTIVEUNITS_UPGRADE, FALSE);
   } else {
-    gtk_dialog_set_response_sensitive(GTK_DIALOG(activeunits_dialog_shell),
+    gui_dialog_set_response_sensitive(activeunits_dialog_shell,
                                      ACTIVEUNITS_NEAREST,
                                      can_client_issue_orders());       
     
     if (can_upgrade_unittype(game.player_ptr, activeunits_type[row]) != -1) {
-      gtk_dialog_set_response_sensitive(GTK_DIALOG(activeunits_dialog_shell),
+      gui_dialog_set_response_sensitive(activeunits_dialog_shell,
                                        ACTIVEUNITS_UPGRADE,
                                        can_client_issue_orders());     
     } else {
-      gtk_dialog_set_response_sensitive(GTK_DIALOG(activeunits_dialog_shell),
+      gui_dialog_set_response_sensitive(activeunits_dialog_shell,
                                        ACTIVEUNITS_UPGRADE, FALSE);
     }
   }
@@ -1097,18 +1051,18 @@
 /****************************************************************
 ...
 *****************************************************************/
-static void activeunits_command_callback(GtkWidget *w, gint response_id)
+static void activeunits_command_callback(struct gui_dialog *dlg, int response)
 {
   int        ut1, ut2;
   gint       row;
   GtkWidget *shell;
 
-  switch (response_id) {
+  switch (response) {
     case ACTIVEUNITS_NEAREST:
     case ACTIVEUNITS_UPGRADE:
       break;
     default:
-      gtk_widget_destroy(activeunits_dialog_shell);
+      gui_dialog_destroy(dlg);
       return;
   }
 
@@ -1120,7 +1074,7 @@
     return;
   }
 
-  if (response_id == ACTIVEUNITS_NEAREST) {
+  if (response == ACTIVEUNITS_NEAREST) {
     struct tile *ptile;
     struct unit *punit;
 
@@ -1134,7 +1088,7 @@
     ut2 = can_upgrade_unittype(game.player_ptr, activeunits_type[row]);
 
     shell = gtk_message_dialog_new(
-         GTK_WINDOW(activeunits_dialog_shell),
+         GTK_WINDOW(gui_dialog_get_toplevel(dlg)),
          GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
          GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
          _("Upgrade as many %s to %s as possible for %d gold each?\n"

[Prev in Thread] Current Thread [Next in Thread]