Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] (PR#10169) Move messages to toplevel window.
Home

[Freeciv-Dev] (PR#10169) Move messages to toplevel window.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#10169) Move messages to toplevel window.
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Fri, 17 Sep 2004 13:43:27 -0700
Reply-to: rt@xxxxxxxxxxx

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

This patch moves the messages to the toplevel window, like in the
attached screenshot.

PNG image

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.76
diff -u -r1.76 gui_main.c
--- client/gui-gtk-2.0/gui_main.c       6 Sep 2004 17:13:06 -0000       1.76
+++ client/gui-gtk-2.0/gui_main.c       17 Sep 2004 20:39:50 -0000
@@ -60,6 +60,7 @@
 #include "mapctrl.h"
 #include "mapview.h"
 #include "menu.h"
+#include "messagewin.h"
 #include "optiondlg.h"
 #include "options.h"
 #include "spaceshipdlg.h"
@@ -862,7 +863,7 @@
   g_signal_connect(map_canvas, "button_release_event",
                    G_CALLBACK(butt_release_mapcanvas), NULL);
 
-  g_signal_connect(toplevel, "key_press_event",
+  g_signal_connect(map_canvas, "key_press_event",
                    G_CALLBACK(keyboard_handler), NULL);
 
   /* *** The message window -- this is a detachable widget *** */
@@ -871,14 +872,22 @@
   gtk_paned_pack2(GTK_PANED(paned), sbox, TRUE, TRUE);
   avbox = detached_widget_fill(sbox);
 
+{
+  GtkWidget *notebook, *messages;
+
+  notebook = gtk_notebook_new();
+  gtk_box_pack_start(GTK_BOX(avbox), notebook, TRUE, TRUE, 0);
+
   sw = gtk_scrolled_window_new(NULL, NULL);
   gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
                                      GTK_SHADOW_ETCHED_IN);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
                                 GTK_POLICY_ALWAYS);
-  gtk_box_pack_start(GTK_BOX(avbox), sw, TRUE, TRUE, 0);
   gtk_widget_set_size_request(sw, 600, 100);
 
+  label = gtk_label_new_with_mnemonic("_Chat");
+  gtk_notebook_append_page(GTK_NOTEBOOK(notebook), sw, label);
+
   text = gtk_text_view_new();
   gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
   gtk_container_add(GTK_CONTAINER(sw), text);
@@ -896,6 +905,10 @@
       " it\nunder certain conditions; See the \"Copying\" item on the Help"
       " menu.\nNow.. Go give'em hell!") );
 
+  label = gtk_label_new_with_mnemonic("_Messages");
+  messages = create_meswin_area();
+  gtk_notebook_append_page(GTK_NOTEBOOK(notebook), messages, label);
+
   /* the chat line */
   inputline = gtk_entry_new();
   gtk_box_pack_start(GTK_BOX(avbox), inputline, FALSE, FALSE, 3);
@@ -908,7 +921,7 @@
   g_signal_connect(inputline, "focus_out_event",
                   G_CALLBACK(inputline_focus), GINT_TO_POINTER(0));
 
-
+}
   /* Other things to take care of */
 
   gtk_widget_show_all(paned);
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.25
diff -u -r1.25 messagewin.c
--- client/gui-gtk-2.0/messagewin.c     11 May 2004 17:52:25 -0000      1.25
+++ client/gui-gtk-2.0/messagewin.c     17 Sep 2004 20:39:51 -0000
@@ -39,12 +39,10 @@
 
 #include "messagewin.h"
 
-static GtkWidget *meswin_shell;
 static GtkListStore *meswin_store;
 static GtkTreeSelection *meswin_selection;
 
-static void create_meswin_dialog(void);
-static void meswin_response(GtkWidget *w, gint response);
+static GtkWidget *goto_cmd, *popcity_cmd;
 
 static void meswin_selection_callback(GtkTreeSelection *selection,
                                       gpointer data);
@@ -55,10 +53,6 @@
 static void meswin_goto_callback(GtkWidget *w, gpointer data);
 static void meswin_popcity_callback(GtkWidget *w, gpointer data);
 
-enum {
-    CMD_GOTO = 1, CMD_POPCITY
-};
-
 #define N_MSG_VIEW 24         /* max before scrolling happens */
 
 /****************************************************************
@@ -66,18 +60,6 @@
 *****************************************************************/
 void popup_meswin_dialog(void)
 {
-  int updated = 0;
-  
-  if(!meswin_shell) {
-    create_meswin_dialog();
-    gtk_set_relative_position(toplevel, meswin_shell, 25, 25);
-    updated = 1;              /* create_ calls update_ */
-  }
-
-  gtk_window_present(GTK_WINDOW(meswin_shell));
-
-  if(!updated) 
-    update_meswin_dialog();
 }
 
 /**************************************************************************
@@ -85,9 +67,6 @@
 **************************************************************************/
 void popdown_meswin_dialog(void)
 {
-  if (meswin_shell) {
-    gtk_widget_destroy(meswin_shell);
-  }
 }
 
 /****************************************************************
@@ -95,7 +74,7 @@
 *****************************************************************/
 bool is_meswin_open(void)
 {
-  return meswin_shell != NULL;
+  return TRUE;
 }
 
 /****************************************************************
@@ -148,40 +127,18 @@
 /****************************************************************
 ...
 *****************************************************************/
-static void create_meswin_dialog(void)
+GtkWidget *create_meswin_area(void)
 {
-  static const char *titles[1] = { N_("Messages") };
-  static bool titles_done;
   GtkCellRenderer *renderer;
   GtkTreeViewColumn *col;
-  GtkWidget *view, *sw;
-  GtkWidget *cmd;
+  GtkWidget *view, *sw, *cmd;
 
-  intl_slist(ARRAY_SIZE(titles), titles, &titles_done);
+  GtkWidget *vbox, *hbox, *bbox;
 
-  meswin_shell = gtk_dialog_new_with_buttons(_("Messages"),
-       NULL,
-       0,
-       NULL);
-  setup_dialog(meswin_shell, toplevel);
-  gtk_dialog_set_default_response(GTK_DIALOG(meswin_shell),
-       GTK_RESPONSE_CLOSE);
-  gtk_window_set_default_size(GTK_WINDOW(meswin_shell), 520, 300);
+  vbox = gtk_vbox_new(FALSE, 0);
 
-  cmd = gtk_stockbutton_new(GTK_STOCK_JUMP_TO, _("_Goto location"));
-  gtk_widget_set_sensitive(cmd, FALSE);
-  gtk_dialog_add_action_widget(GTK_DIALOG(meswin_shell), cmd, CMD_GOTO);
-
-  g_signal_connect(cmd, "clicked", G_CALLBACK(meswin_goto_callback), NULL);
-  
-  cmd = gtk_stockbutton_new(GTK_STOCK_ZOOM_IN, _("_Popup City"));
-  gtk_widget_set_sensitive(cmd, FALSE);
-  gtk_dialog_add_action_widget(GTK_DIALOG(meswin_shell), cmd, CMD_POPCITY);
-
-  g_signal_connect(cmd, "clicked", G_CALLBACK(meswin_popcity_callback), NULL);
-
-  gtk_dialog_add_button(GTK_DIALOG(meswin_shell),
-                       GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+  hbox = gtk_hbox_new(FALSE, 0);
+  gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
 
   meswin_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
 
@@ -190,16 +147,16 @@
                                      GTK_SHADOW_ETCHED_IN);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
                           GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(meswin_shell)->vbox),
-                    sw, TRUE, TRUE, 0);
+  gtk_box_pack_start(GTK_BOX(hbox), sw, TRUE, TRUE, 0);
 
   view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(meswin_store));
   meswin_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
   g_object_unref(meswin_store);
   gtk_tree_view_columns_autosize(GTK_TREE_VIEW(view));
+  gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
 
   renderer = gtk_cell_renderer_text_new();
-  col = gtk_tree_view_column_new_with_attributes(titles[0], renderer,
+  col = gtk_tree_view_column_new_with_attributes(NULL, renderer,
        "text", 0, NULL);
   gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
   gtk_tree_view_column_set_cell_data_func(col, renderer,
@@ -210,14 +167,27 @@
                   G_CALLBACK(meswin_selection_callback), NULL);
   g_signal_connect(view, "row_activated",
                   G_CALLBACK(meswin_row_activated_callback), NULL);
-  g_signal_connect(meswin_shell, "response",
-                  G_CALLBACK(meswin_response), NULL);
-  g_signal_connect(meswin_shell, "destroy",
-                  G_CALLBACK(gtk_widget_destroyed), &meswin_shell);
 
-  gtk_widget_show_all(GTK_DIALOG(meswin_shell)->vbox);
+  bbox = gtk_vbutton_box_new();
+  gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_SPREAD);
 
-  real_update_meswin_dialog();
+  gtk_box_pack_start(GTK_BOX(hbox), bbox, FALSE, FALSE, 5);
+
+  cmd = gtk_stockbutton_new(GTK_STOCK_JUMP_TO, _("Goto _location"));
+  gtk_container_add(GTK_CONTAINER(bbox), cmd);
+  gtk_widget_set_sensitive(cmd, FALSE);
+  goto_cmd = cmd;
+
+  g_signal_connect(cmd, "clicked", G_CALLBACK(meswin_goto_callback), NULL);
+  
+  cmd = gtk_stockbutton_new(GTK_STOCK_ZOOM_IN, _("_Popup City"));
+  gtk_container_add(GTK_CONTAINER(bbox), cmd);
+  gtk_widget_set_sensitive(cmd, FALSE);
+  popcity_cmd = cmd;
+
+  g_signal_connect(cmd, "clicked", G_CALLBACK(meswin_popcity_callback), NULL);
+
+  return vbox;
 }
 
 /**************************************************************************
@@ -246,11 +216,9 @@
       meswin_not_visited_item(i);
     }
   }
-  
-  gtk_dialog_set_response_sensitive(GTK_DIALOG(meswin_shell), CMD_GOTO,
-                                   FALSE);
-  gtk_dialog_set_response_sensitive(GTK_DIALOG(meswin_shell), CMD_POPCITY,
-                                   FALSE);
+
+  gtk_widget_set_sensitive(goto_cmd, FALSE);
+  gtk_widget_set_sensitive(popcity_cmd, FALSE);
 }
 
 /**************************************************************************
@@ -264,10 +232,8 @@
   if (row != -1) {
     struct message *message = get_message(row);
 
-    gtk_dialog_set_response_sensitive(GTK_DIALOG(meswin_shell), CMD_GOTO,
-                                     message->location_ok);
-    gtk_dialog_set_response_sensitive(GTK_DIALOG(meswin_shell), CMD_POPCITY,
-                                     message->city_ok);
+    gtk_widget_set_sensitive(goto_cmd, message->location_ok);
+    gtk_widget_set_sensitive(popcity_cmd, message->city_ok);
   }
 }
 
@@ -285,19 +251,8 @@
   meswin_double_click(row);
   meswin_visited_item(row);
 
-  gtk_dialog_set_response_sensitive(GTK_DIALOG(meswin_shell), CMD_GOTO,
-                                   message->location_ok);
-  gtk_dialog_set_response_sensitive(GTK_DIALOG(meswin_shell), CMD_POPCITY,
-                                   message->city_ok);
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-static void meswin_response(GtkWidget *w, gint response)
-{
-  if (response <= 0)
-    gtk_widget_destroy(w);
+  gtk_widget_set_sensitive(goto_cmd, message->location_ok);
+  gtk_widget_set_sensitive(popcity_cmd, message->city_ok);
 }
 
 /**************************************************************************
Index: client/gui-gtk-2.0/messagewin.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/messagewin.h,v
retrieving revision 1.2
diff -u -r1.2 messagewin.h
--- client/gui-gtk-2.0/messagewin.h     15 Dec 2002 00:38:23 -0000      1.2
+++ client/gui-gtk-2.0/messagewin.h     17 Sep 2004 20:39:51 -0000
@@ -15,6 +15,8 @@
 
 #include "messagewin_g.h"
 
+GtkWidget *create_meswin_area(void);
+
 void popdown_meswin_dialog(void);
 
 #endif  /* FC__MESSAGEWIN_H */

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