Author: cazfi
Date: Fri Oct 14 15:23:13 2016
New Revision: 34120

URL: http://svn.gna.org/viewcvs/freeciv?rev=34120&view=rev
Log:
Added icon_label_button_new() to gtk3.22-client for creating buttons with icon 
and/or label.
Whether icon or label, or both, get shown, is considered "undefined" - do not 
rely on things
not changing on underlying widget libraries or in the function itself.

See patch #6708

Modified:
    branches/S2_6/client/gui-gtk-3.22/cma_fe.c
    branches/S2_6/client/gui-gtk-3.22/dialogs.c
    branches/S2_6/client/gui-gtk-3.22/finddlg.c
    branches/S2_6/client/gui-gtk-3.22/gui_stuff.c
    branches/S2_6/client/gui-gtk-3.22/gui_stuff.h
    branches/S2_6/client/gui-gtk-3.22/luaconsole.c
    branches/S2_6/client/gui-gtk-3.22/messagedlg.c
    branches/S2_6/client/gui-gtk-3.22/messagewin.c
    branches/S2_6/client/gui-gtk-3.22/pages.c
    branches/S2_6/client/gui-gtk-3.22/plrdlg.c
    branches/S2_6/client/gui-gtk-3.22/repodlgs.c
    branches/S2_6/client/gui-gtk-3.22/spaceshipdlg.c
    branches/S2_6/m4/gtk3.22-client.m4

Modified: branches/S2_6/client/gui-gtk-3.22/cma_fe.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/cma_fe.c?rev=34120&r1=34119&r2=34120&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/cma_fe.c  (original)
+++ branches/S2_6/client/gui-gtk-3.22/cma_fe.c  Fri Oct 14 15:23:13 2016
@@ -215,7 +215,7 @@
   struct cma_dialog *pdialog;
   struct cm_parameter param;
   GtkWidget *frame, *page, *hbox, *label, *table;
-  GtkWidget *vbox, *sw, *hscale, *button, *image;
+  GtkWidget *vbox, *sw, *hscale, *button;
   GtkListStore *store;
   GtkCellRenderer *rend;
   GtkWidget *view;
@@ -295,15 +295,13 @@
   gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_EDGE);
   gtk_container_add(GTK_CONTAINER(vbox), hbox);
 
-  button = gtk_button_new_with_mnemonic(_("Ne_w"));
-  image = gtk_image_new_from_stock(GTK_STOCK_NEW, GTK_ICON_SIZE_BUTTON);
-  gtk_button_set_image(GTK_BUTTON(button), image);
+  button = icon_label_button_new("document-new", _("Ne_w"));
   gtk_container_add(GTK_CONTAINER(hbox), button);
   g_signal_connect(button, "clicked",
                    G_CALLBACK(cma_add_preset_callback), pdialog);
   pdialog->add_preset_command = button;
 
-  pdialog->del_preset_command = gtk_button_new_from_stock(GTK_STOCK_DELETE);
+  pdialog->del_preset_command = icon_label_button_new("edit-delete", 
_("Delete"));
   gtk_container_add(GTK_CONTAINER(hbox), pdialog->del_preset_command);
   g_signal_connect(pdialog->del_preset_command, "clicked",
                    G_CALLBACK(cma_del_preset_callback), pdialog);
@@ -425,7 +423,7 @@
   gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_EDGE);
   gtk_container_add(GTK_CONTAINER(vbox), hbox);
 
-  button = gtk_button_new_from_stock(GTK_STOCK_HELP);
+  button = icon_label_button_new("help-browser", _("Help"));
   g_signal_connect(button, "clicked",
                    G_CALLBACK(help_callback), NULL);
   gtk_container_add(GTK_CONTAINER(hbox), button);

Modified: branches/S2_6/client/gui-gtk-3.22/dialogs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/dialogs.c?rev=34120&r1=34119&r2=34120&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/dialogs.c (original)
+++ branches/S2_6/client/gui-gtk-3.22/dialogs.c Fri Oct 14 15:23:13 2016
@@ -108,7 +108,8 @@
   gui_dialog_new(&shell, GTK_NOTEBOOK(bottom_notebook), NULL, TRUE);
   gui_dialog_set_title(shell, caption);
 
-  gui_dialog_add_button(shell, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); 
+  gui_dialog_add_button(shell, "window-close", _("Close"),
+                        GTK_RESPONSE_CLOSE);
   gui_dialog_set_default_response(shell, GTK_RESPONSE_CLOSE);
 
   vbox = gtk_grid_new();

Modified: branches/S2_6/client/gui-gtk-3.22/finddlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/finddlg.c?rev=34120&r1=34119&r2=34120&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/finddlg.c (original)
+++ branches/S2_6/client/gui-gtk-3.22/finddlg.c Fri Oct 14 15:23:13 2016
@@ -72,10 +72,10 @@
     gui_dialog_set_title(find_dialog_shell, _("Find City"));
     gui_dialog_set_default_size(find_dialog_shell, -1, 240);
 
-    gui_dialog_add_button(find_dialog_shell,
-       GTK_STOCK_FIND, GTK_RESPONSE_ACCEPT);
-    gui_dialog_add_button(find_dialog_shell,
-       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+    gui_dialog_add_button(find_dialog_shell, "edit-find", _("Find"),
+                          GTK_RESPONSE_ACCEPT);
+    gui_dialog_add_button(find_dialog_shell, NULL, _("Cancel"),
+                          GTK_RESPONSE_CANCEL);
 
     gui_dialog_set_default_response(find_dialog_shell, GTK_RESPONSE_ACCEPT);
 

Modified: branches/S2_6/client/gui-gtk-3.22/gui_stuff.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/gui_stuff.c?rev=34120&r1=34119&r2=34120&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/gui_stuff.c       (original)
+++ branches/S2_6/client/gui-gtk-3.22/gui_stuff.c       Fri Oct 14 15:23:13 2016
@@ -79,6 +79,25 @@
   button = gtk_button_new_with_mnemonic(label_text);
   image = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_BUTTON);
   gtk_button_set_image(GTK_BUTTON(button), image);
+
+  return button;
+}
+
+/**************************************************************************
+  Create new icon button with label
+**************************************************************************/
+GtkWidget *icon_label_button_new(const gchar *icon_name,
+                                 const gchar *label_text)
+{
+  GtkWidget *button;
+  GtkWidget *image;
+
+  button = gtk_button_new_with_mnemonic(label_text);
+
+  if (icon_name != NULL) {
+    image = gtk_image_new_from_icon_name(icon_name, GTK_ICON_SIZE_BUTTON);
+    gtk_button_set_image(GTK_BUTTON(button), image);
+  }
 
   return button;
 }
@@ -704,11 +723,12 @@
   Adds a button to a dialog.
 **************************************************************************/
 GtkWidget *gui_dialog_add_button(struct gui_dialog *dlg,
-                                const char *text, int response)
+                                 const char *icon_name,
+                                 const char *text, int response)
 {
   GtkWidget *button;
 
-  button = gtk_button_new_from_stock(text);
+  button = icon_label_button_new(icon_name, text);
   gtk_widget_set_can_default(button, TRUE);
   gui_dialog_pack_button(dlg, button, response);
 

Modified: branches/S2_6/client/gui-gtk-3.22/gui_stuff.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/gui_stuff.h?rev=34120&r1=34119&r2=34120&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/gui_stuff.h       (original)
+++ branches/S2_6/client/gui-gtk-3.22/gui_stuff.h       Fri Oct 14 15:23:13 2016
@@ -19,6 +19,8 @@
 #include "shared.h"
 
 GtkWidget *gtk_stockbutton_new(const gchar *stock, const gchar *label_text);
+GtkWidget *icon_label_button_new(const gchar *icon_name,
+                                 const gchar *label_text);
 void gtk_stockbutton_set_label(GtkWidget *button, const gchar *label_text);
 void gtk_expose_now(GtkWidget *w);
 void set_relative_window_position(GtkWindow *ref, GtkWindow *w, int px, int 
py);
@@ -102,7 +104,8 @@
                     gpointer user_data, bool check_top);
 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);
+                                 const char *icon_name,
+                                 const char *text, int response);
 GtkWidget *gui_dialog_add_stockbutton(struct gui_dialog *dlg,
     const char *stock, const char *text, int response);
 GtkWidget *gui_dialog_add_widget(struct gui_dialog *dlg,

Modified: branches/S2_6/client/gui-gtk-3.22/luaconsole.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/luaconsole.c?rev=34120&r1=34119&r2=34120&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/luaconsole.c      (original)
+++ branches/S2_6/client/gui-gtk-3.22/luaconsole.c      Fri Oct 14 15:23:13 2016
@@ -239,10 +239,11 @@
                    &pdialog->entry);
 
   /* Load lua script command button. */
-  gui_dialog_add_button(pdialog->shell, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
-
-  gui_dialog_add_stockbutton(pdialog->shell, GTK_STOCK_OPEN,
-                             _("Load Lua Script"), LUACONSOLE_RES_OPEN);
+  gui_dialog_add_button(pdialog->shell, "window-close", _("Close"),
+                        GTK_RESPONSE_CLOSE);
+
+  gui_dialog_add_button(pdialog->shell, "document-open",
+                        _("Load Lua Script"), LUACONSOLE_RES_OPEN);
   gui_dialog_response_set_callback(pdialog->shell,
                                    luaconsole_response_callback);
 

Modified: branches/S2_6/client/gui-gtk-3.22/messagedlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/messagedlg.c?rev=34120&r1=34119&r2=34120&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/messagedlg.c      (original)
+++ branches/S2_6/client/gui-gtk-3.22/messagedlg.c      Fri Oct 14 15:23:13 2016
@@ -69,8 +69,8 @@
 
   gui_dialog_set_default_size(shell, -1, 450);
 
-  gui_dialog_add_button(shell, GTK_STOCK_OK, GTK_RESPONSE_OK);
-  gui_dialog_add_button(shell, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+  gui_dialog_add_button(shell, NULL, _("OK"), GTK_RESPONSE_OK);
+  gui_dialog_add_button(shell, NULL, _("Cancel"), GTK_RESPONSE_CANCEL);
 
   explanation = gtk_label_new(NULL);
   g_object_set(explanation, "margin", 4, NULL);

Modified: branches/S2_6/client/gui-gtk-3.22/messagewin.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/messagewin.c?rev=34120&r1=34119&r2=34120&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/messagewin.c      (original)
+++ branches/S2_6/client/gui-gtk-3.22/messagewin.c      Fri Oct 14 15:23:13 2016
@@ -376,7 +376,8 @@
   g_signal_connect(selection, "changed",
                    G_CALLBACK(meswin_dialog_selection_callback), pdialog);
 
-  gui_dialog_add_button(pdialog->shell, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+  gui_dialog_add_button(pdialog->shell, "window-close", _("Close"),
+                        GTK_RESPONSE_CLOSE);
 
   if (GUI_GTK_OPTION(show_message_window_buttons)) {
     cmd = gui_dialog_add_stockbutton(pdialog->shell, GTK_STOCK_ZOOM_IN,

Modified: branches/S2_6/client/gui-gtk-3.22/pages.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/pages.c?rev=34120&r1=34119&r2=34120&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/pages.c   (original)
+++ branches/S2_6/client/gui-gtk-3.22/pages.c   Fri Oct 14 15:23:13 2016
@@ -338,7 +338,7 @@
   gtk_grid_attach(GTK_GRID(table), button, 1, 1, 1, 1);
   g_signal_connect(button, "clicked", open_settings, NULL);
 
-  button = gtk_button_new_from_stock(GTK_STOCK_QUIT);
+  button = icon_label_button_new("application-exit", _("Exit"));
   gtk_size_group_add_widget(size, button);
   g_object_unref(size);
   gtk_grid_attach(GTK_GRID(table), button, 1, 2, 1, 1);
@@ -2685,8 +2685,8 @@
                        NULL);
   gtk_grid_attach(GTK_GRID(table), label, 0, 2, 1, 1);
 
-  button = gtk_stockbutton_new(GTK_STOCK_PREFERENCES,
-      _("_More Game Options..."));
+  button = icon_label_button_new("preferences-system",
+                                 _("_More Game Options..."));
   g_object_set(button, "margin", 8, NULL);
   gtk_widget_set_halign(button, GTK_ALIGN_CENTER);
   gtk_widget_set_valign(button, GTK_ALIGN_CENTER);
@@ -2774,18 +2774,18 @@
   inputline_toolkit_view_append_button(toolkit_view, button);
   g_signal_connect(button, "clicked", G_CALLBACK(main_callback), NULL);
 
-  nation_button = gtk_stockbutton_new(GTK_STOCK_PROPERTIES,
-                                      _("Pick _Nation"));
+  nation_button = icon_label_button_new("document-properties",
+                                        _("Pick _Nation"));
   inputline_toolkit_view_append_button(toolkit_view, nation_button);
   g_signal_connect(nation_button, "clicked",
                    G_CALLBACK(nation_button_callback), NULL);
 
-  observe_button = gtk_stockbutton_new(GTK_STOCK_ZOOM_IN, _("_Observe"));
+  observe_button = icon_label_button_new("zoom-in", _("_Observe"));
   inputline_toolkit_view_append_button(toolkit_view, observe_button);
   g_signal_connect(observe_button, "clicked",
                    G_CALLBACK(observe_button_callback), NULL);
 
-  ready_button = gtk_stockbutton_new(GTK_STOCK_EXECUTE, _("_Ready"));
+  ready_button = icon_label_button_new("system-run", _("_Ready"));
   inputline_toolkit_view_append_button(toolkit_view, ready_button);
   g_signal_connect(ready_button, "clicked",
                    G_CALLBACK(ready_button_callback), NULL);

Modified: branches/S2_6/client/gui-gtk-3.22/plrdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/plrdlg.c?rev=34120&r1=34119&r2=34120&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/plrdlg.c  (original)
+++ branches/S2_6/client/gui-gtk-3.22/plrdlg.c  Fri Oct 14 15:23:13 2016
@@ -425,8 +425,8 @@
   /* TRANS: Nations report title */
   gui_dialog_set_title(players_dialog_shell, _("Nations"));
 
-  gui_dialog_add_button(players_dialog_shell,
-      GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+  gui_dialog_add_button(players_dialog_shell, "window-close", _("Close"),
+                        GTK_RESPONSE_CLOSE);
 
   gui_dialog_set_default_size(players_dialog_shell, -1, 270);
 

Modified: branches/S2_6/client/gui-gtk-3.22/repodlgs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/repodlgs.c?rev=34120&r1=34119&r2=34120&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/repodlgs.c        (original)
+++ branches/S2_6/client/gui-gtk-3.22/repodlgs.c        Fri Oct 14 15:23:13 2016
@@ -555,7 +555,8 @@
   /* TRANS: Research report title */
   gui_dialog_set_title(preport->shell, _("Research"));
 
-  gui_dialog_add_button(preport->shell, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+  gui_dialog_add_button(preport->shell, "window-close", _("Close"),
+                        GTK_RESPONSE_CLOSE);
   gui_dialog_set_default_response(preport->shell, GTK_RESPONSE_CLOSE);
 
   vbox = GTK_CONTAINER(preport->shell->vbox);
@@ -1152,17 +1153,18 @@
   gtk_widget_set_margin_bottom(label, 5);
   preport->label = GTK_LABEL(label);
 
-  gui_dialog_add_button(preport->shell, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
-
-  button = gui_dialog_add_button(preport->shell, _("_Disband"),
+  gui_dialog_add_button(preport->shell, "window-close", _("Close"),
+                        GTK_RESPONSE_CLOSE);
+
+  button = gui_dialog_add_button(preport->shell, NULL, _("_Disband"),
                                  ERD_RES_DISBAND_UNITS);
   gtk_widget_set_sensitive(button, FALSE);
 
-  button = gui_dialog_add_button(preport->shell, _("Sell _All"),
+  button = gui_dialog_add_button(preport->shell, NULL, _("Sell _All"),
                                  ERD_RES_SELL_ALL);
   gtk_widget_set_sensitive(button, FALSE);
 
-  button = gui_dialog_add_button(preport->shell, _("Sell _Redundant"),
+  button = gui_dialog_add_button(preport->shell, NULL, _("Sell _Redundant"),
                                  ERD_RES_SELL_REDUNDANT);
   gtk_widget_set_sensitive(button, FALSE);
 
@@ -1673,9 +1675,10 @@
     }
   }
 
-  gui_dialog_add_button(preport->shell, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
-
-  button = gui_dialog_add_button(preport->shell, _("_Upgrade"),
+  gui_dialog_add_button(preport->shell, "window-close", _("Close"),
+                        GTK_RESPONSE_CLOSE);
+
+  button = gui_dialog_add_button(preport->shell, NULL, _("_Upgrade"),
                                  URD_RES_UPGRADE);
   gtk_widget_set_sensitive(button, FALSE);
 

Modified: branches/S2_6/client/gui-gtk-3.22/spaceshipdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/spaceshipdlg.c?rev=34120&r1=34119&r2=34120&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/spaceshipdlg.c    (original)
+++ branches/S2_6/client/gui-gtk-3.22/spaceshipdlg.c    Fri Oct 14 15:23:13 2016
@@ -228,10 +228,10 @@
   gui_dialog_new(&pdialog->shell, GTK_NOTEBOOK(top_notebook), NULL, TRUE);
   gui_dialog_set_title(pdialog->shell, player_name(pplayer));
 
-  gui_dialog_add_button(pdialog->shell,
-      GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
-  gui_dialog_add_button(pdialog->shell,
-      _("_Launch"), GTK_RESPONSE_ACCEPT);
+  gui_dialog_add_button(pdialog->shell, "window-close", _("Close"),
+                        GTK_RESPONSE_CLOSE);
+  gui_dialog_add_button(pdialog->shell, NULL, _("_Launch"),
+                        GTK_RESPONSE_ACCEPT);
 
   g_signal_connect(pdialog->shell->vbox, "destroy",
                   G_CALLBACK(spaceship_destroy_callback), pdialog);

Modified: branches/S2_6/m4/gtk3.22-client.m4
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/m4/gtk3.22-client.m4?rev=34120&r1=34119&r2=34120&view=diff
==============================================================================
--- branches/S2_6/m4/gtk3.22-client.m4  (original)
+++ branches/S2_6/m4/gtk3.22-client.m4  Fri Oct 14 15:23:13 2016
@@ -8,7 +8,7 @@
   # Add check "x$client" = "xauto"  when this becomes supported client
   if test "x$gui_gtk3_22" = "xyes" ||
      test "x$client" = "xall" ; then
-    PKG_CHECK_MODULES([GTK3_22], [gtk+-3.0 >= 3.8.0],
+    PKG_CHECK_MODULES([GTK3_22], [gtk+-3.0 >= 3.10.0],
       [
         GTK3_22_CFLAGS="$GTK3_22_CFLAGS 
-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_8"
         GTK3_22_CFLAGS="$GTK3_22_CFLAGS 
-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36"


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to