Author: jtn
Date: Fri Jan  2 11:10:19 2015
New Revision: 27487

URL: http://svn.gna.org/viewcvs/freeciv?rev=27487&view=rev
Log:
In Gtk clients' "Pick nation" dialog, suppress the notebook tabs if only
hidden nation groups exist.

See gna bug #23129.

Modified:
    trunk/client/gui-gtk-2.0/dialogs.c
    trunk/client/gui-gtk-3.0/dialogs.c

Modified: trunk/client/gui-gtk-2.0/dialogs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/dialogs.c?rev=27487&r1=27486&r2=27487&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/dialogs.c  (original)
+++ trunk/client/gui-gtk-2.0/dialogs.c  Fri Jan  2 11:10:19 2015
@@ -994,19 +994,28 @@
     gtk_notebook_set_tab_pos(GTK_NOTEBOOK(races_notebook), GTK_POS_LEFT);  
 
     /* Suppress notebook tabs if there will be only one ("All") */
-    if (nation_group_count() == 0) {
-      gtk_notebook_set_show_tabs(GTK_NOTEBOOK(races_notebook), FALSE);
-    } else {
-      label = g_object_new(GTK_TYPE_LABEL,
-          "use-underline", TRUE,
-          "label", _("Nation _Groups:"),
-          "xalign", 0.0,
-          "yalign", 0.5,
-          NULL);
-      gtk_label_set_mnemonic_widget(GTK_LABEL(label), races_notebook);
-      gtk_box_pack_start(GTK_BOX(nation_selection_list), label,
-                         FALSE, FALSE, 0);  
-      gtk_notebook_set_show_tabs(GTK_NOTEBOOK(races_notebook), TRUE);
+    {
+      bool show_groups = FALSE;
+      nation_groups_iterate(pgroup) {
+        if (!is_nation_group_hidden(pgroup)) {
+          show_groups = TRUE;
+          break;
+        }
+      } nation_groups_iterate_end;
+      if (!show_groups) {
+        gtk_notebook_set_show_tabs(GTK_NOTEBOOK(races_notebook), FALSE);
+      } else {
+        label = g_object_new(GTK_TYPE_LABEL,
+            "use-underline", TRUE,
+            "label", _("Nation _Groups:"),
+            "xalign", 0.0,
+            "yalign", 0.5,
+            NULL);
+        gtk_label_set_mnemonic_widget(GTK_LABEL(label), races_notebook);
+        gtk_box_pack_start(GTK_BOX(nation_selection_list), label,
+                           FALSE, FALSE, 0);  
+        gtk_notebook_set_show_tabs(GTK_NOTEBOOK(races_notebook), TRUE);
+      }
     }
 
     gtk_box_pack_start(GTK_BOX(nation_selection_list), races_notebook,

Modified: trunk/client/gui-gtk-3.0/dialogs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/dialogs.c?rev=27487&r1=27486&r2=27487&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/dialogs.c  (original)
+++ trunk/client/gui-gtk-3.0/dialogs.c  Fri Jan  2 11:10:19 2015
@@ -1007,19 +1007,28 @@
                     0, 2, 2, 1);
 
     /* Suppress notebook tabs if there will be only one ("All") */
-    if (nation_group_count() == 0) {
-      gtk_notebook_set_show_tabs(GTK_NOTEBOOK(races_notebook), FALSE);
-    } else {
-      label = g_object_new(GTK_TYPE_LABEL,
-          "use-underline", TRUE,
-          "label", _("Nation _Groups:"),
-          "xalign", 0.0,
-          "yalign", 0.5,
-          NULL);
-      gtk_label_set_mnemonic_widget(GTK_LABEL(label), races_notebook);
-      gtk_grid_attach(GTK_GRID(nation_selection_list), label,
-                      0, 1, 2, 1);
-      gtk_notebook_set_show_tabs(GTK_NOTEBOOK(races_notebook), TRUE);
+    {
+      bool show_groups = FALSE;
+      nation_groups_iterate(pgroup) {
+        if (!is_nation_group_hidden(pgroup)) {
+          show_groups = TRUE;
+          break;
+        }
+      } nation_groups_iterate_end;
+      if (!show_groups) {
+        gtk_notebook_set_show_tabs(GTK_NOTEBOOK(races_notebook), FALSE);
+      } else {
+        label = g_object_new(GTK_TYPE_LABEL,
+            "use-underline", TRUE,
+            "label", _("Nation _Groups:"),
+            "xalign", 0.0,
+            "yalign", 0.5,
+            NULL);
+        gtk_label_set_mnemonic_widget(GTK_LABEL(label), races_notebook);
+        gtk_grid_attach(GTK_GRID(nation_selection_list), label,
+                        0, 1, 2, 1);
+        gtk_notebook_set_show_tabs(GTK_NOTEBOOK(races_notebook), TRUE);
+      }
     }
 
     /* Populate treeview */


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

Reply via email to