Author: cazfi
Date: Sun Dec  6 11:35:51 2015
New Revision: 30865

URL: http://svn.gna.org/viewcvs/freeciv?rev=30865&view=rev
Log:
Made gtk3-client citydialog production tab lower on tiny screen layout

See patch #6605

Modified:
    trunk/client/gui-gtk-3.0/citydlg.c
    trunk/client/gui-gtk-3.0/wldlg.c

Modified: trunk/client/gui-gtk-3.0/citydlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/citydlg.c?rev=30865&r1=30864&r2=30865&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/citydlg.c  (original)
+++ trunk/client/gui-gtk-3.0/citydlg.c  Sun Dec  6 11:35:51 2015
@@ -1080,44 +1080,14 @@
 }
 
 /****************************************************************
-  Create buildings list page for small screens
-*****************************************************************/
-static void create_and_append_buildings_page(struct city_dialog *pdialog)
-{
-  if (low_citydlg) {
-    GtkWidget *page;
-    GtkWidget *label;
-    GtkWidget *vbox;
-    GtkWidget *view;
-    const char *tab_title = _("Buildings");
-
-    page = gtk_grid_new();
-    gtk_orientable_set_orientation(GTK_ORIENTABLE(page),
-                                   GTK_ORIENTATION_VERTICAL);
-    gtk_container_set_border_width(GTK_CONTAINER(page), 8);
-    label = gtk_label_new_with_mnemonic(tab_title);
-    gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
-
-    vbox = gtk_grid_new();
-    gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
-                                   GTK_ORIENTATION_VERTICAL);
-    gtk_container_add(GTK_CONTAINER(page), vbox);
-
-    view = create_citydlg_improvement_list(pdialog, vbox);
-
-    gtk_container_add(GTK_CONTAINER(vbox), view);
-
-    gtk_widget_show_all(page);
-  }
-}
-
-/****************************************************************
-  Something dragged to worklist dialog
-*****************************************************************/
-static void
-target_drag_data_received(GtkWidget *w, GdkDragContext *context,
-                         gint x, gint y, GtkSelectionData *data,
-                         guint info, guint time, gpointer user_data)
+  Something dragged to worklist dialog.
+*****************************************************************/
+static void target_drag_data_received(GtkWidget *w,
+                                      GdkDragContext *context,
+                                      gint x, gint y,
+                                      GtkSelectionData *data,
+                                      guint info, guint time,
+                                      gpointer user_data)
 {
   struct city_dialog *pdialog = (struct city_dialog *) user_data;
   GtkTreeModel *model;
@@ -1127,7 +1097,7 @@
       && city_owner(pdialog->pcity) != client.conn.playing) {
     gtk_drag_finish(context, FALSE, FALSE, time);
   }
-    
+
   if (gtk_tree_get_row_drag_data(data, &model, &path)) {
     GtkTreeIter it;
 
@@ -1145,32 +1115,17 @@
 }
 
 /****************************************************************
-                    **** Production Page **** 
-*****************************************************************/
-static void create_and_append_worklist_page(struct city_dialog *pdialog)
-{
-  const char *tab_title = _("P_roduction");
-  GtkWidget *label = gtk_label_new_with_mnemonic(tab_title);
-  GtkWidget *page, *hbox, *editor, *bar;
-
-  page = gtk_grid_new();
-  gtk_orientable_set_orientation(GTK_ORIENTABLE(page),
-                                 GTK_ORIENTATION_VERTICAL);
-  gtk_container_set_border_width(GTK_CONTAINER(page), 8);
-  gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
-
-  /* stuff that's being currently built */
-
-  label = g_object_new(GTK_TYPE_LABEL,
-                      "label", _("Production:"),
-                      "xalign", 0.0, "yalign", 0.5, NULL);
-  pdialog->production.production_label = label;
-  gtk_container_add(GTK_CONTAINER(page), label);
+  Create production page header - what tab this actually is,
+  depends on screen size and layout.
+*****************************************************************/
+static void create_production_header(struct city_dialog *pdialog, GtkContainer 
*contain)
+{
+  GtkWidget *hbox, *bar;
 
   hbox = gtk_grid_new();
   g_object_set(hbox, "margin", 2, NULL);
   gtk_grid_set_column_spacing(GTK_GRID(hbox), 10);
-  gtk_container_add(GTK_CONTAINER(page), hbox);
+  gtk_container_add(contain, hbox);
 
   /* The label is set in city_dialog_update_building() */
   bar = gtk_progress_bar_new();
@@ -1181,16 +1136,79 @@
   gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns"));
 
   add_worklist_dnd_target(bar);
+
   g_signal_connect(bar, "drag_data_received",
-                  G_CALLBACK(target_drag_data_received), pdialog);
+                   G_CALLBACK(target_drag_data_received), pdialog);
 
   pdialog->production.buy_command = gtk_stockbutton_new(GTK_STOCK_EXECUTE,
-                                                     _("_Buy"));
+                                                        _("_Buy"));
   gtk_container_add(GTK_CONTAINER(hbox), pdialog->production.buy_command);
 
   g_signal_connect(pdialog->production.buy_command, "clicked",
-                  G_CALLBACK(buy_callback), pdialog);
-
+                   G_CALLBACK(buy_callback), pdialog);
+}
+
+/****************************************************************
+  Create buildings list page for small screens
+*****************************************************************/
+static void create_and_append_buildings_page(struct city_dialog *pdialog)
+{
+  if (low_citydlg) {
+    GtkWidget *page;
+    GtkWidget *label;
+    GtkWidget *vbox;
+    GtkWidget *view;
+    const char *tab_title = _("Buildings");
+
+    page = gtk_grid_new();
+    gtk_orientable_set_orientation(GTK_ORIENTABLE(page),
+                                   GTK_ORIENTATION_VERTICAL);
+    gtk_container_set_border_width(GTK_CONTAINER(page), 8);
+    label = gtk_label_new_with_mnemonic(tab_title);
+
+    create_production_header(pdialog, GTK_CONTAINER(page));
+    gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
+
+    vbox = gtk_grid_new();
+    gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
+                                   GTK_ORIENTATION_VERTICAL);
+    gtk_container_add(GTK_CONTAINER(page), vbox);
+
+    view = create_citydlg_improvement_list(pdialog, vbox);
+
+    gtk_container_add(GTK_CONTAINER(vbox), view);
+
+    gtk_widget_show_all(page);
+  }
+}
+
+/****************************************************************
+                    **** Production Page **** 
+*****************************************************************/
+static void create_and_append_worklist_page(struct city_dialog *pdialog)
+{
+  const char *tab_title = _("P_roduction");
+  GtkWidget *label = gtk_label_new_with_mnemonic(tab_title);
+  GtkWidget *page, *editor;
+
+  page = gtk_grid_new();
+  gtk_orientable_set_orientation(GTK_ORIENTABLE(page),
+                                 GTK_ORIENTATION_VERTICAL);
+  gtk_container_set_border_width(GTK_CONTAINER(page), 8);
+  gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
+
+  /* stuff that's being currently built */
+  if (!low_citydlg) {
+    label = g_object_new(GTK_TYPE_LABEL,
+                         "label", _("Production:"),
+                         "xalign", 0.0, "yalign", 0.5, NULL);
+    pdialog->production.production_label = label;
+    gtk_container_add(GTK_CONTAINER(page), label);
+
+    create_production_header(pdialog, GTK_CONTAINER(page));
+  } else {
+    pdialog->production.production_label = NULL;
+  }
 
   editor = create_worklist();
   g_object_set(editor, "margin", 6, NULL);
@@ -1847,15 +1865,18 @@
   if (pdialog->overview.buy_command != NULL) {
     gtk_widget_set_sensitive(pdialog->overview.buy_command, sensitive);
   }
-  gtk_widget_set_sensitive(pdialog->production.buy_command, sensitive);
+  if (pdialog->production.buy_command != NULL) {
+    gtk_widget_set_sensitive(pdialog->production.buy_command, sensitive);
+  }
 
   /* Make sure build slots info is up to date */
-  {
+  if (pdialog->production.production_label != NULL) {
     int build_slots = city_build_slots(pcity);
+
     /* Only display extra info if more than one slot is available */
     if (build_slots > 1) {
       fc_snprintf(buf2, sizeof(buf2),
-                  /* TRANS: never actually used with built_slots<=1 */
+                  /* TRANS: never actually used with built_slots <= 1 */
                   PL_("Production (up to %d unit per turn):",
                       "Production (up to %d units per turn):", build_slots),
                   build_slots);
@@ -1886,12 +1907,14 @@
       GTK_PROGRESS_BAR(pdialog->overview.production_bar), pct);
   }
 
-  fc_snprintf(buf2, sizeof(buf2), "%s%s: %s", descr,
-              worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
-  gtk_progress_bar_set_text(
-    GTK_PROGRESS_BAR(pdialog->production.production_bar), buf2);
-  gtk_progress_bar_set_fraction(
-    GTK_PROGRESS_BAR(pdialog->production.production_bar), pct);
+  if (pdialog->production.production_bar != NULL) {
+    fc_snprintf(buf2, sizeof(buf2), "%s%s: %s", descr,
+                worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
+    gtk_progress_bar_set_text(
+      GTK_PROGRESS_BAR(pdialog->production.production_bar), buf2);
+    gtk_progress_bar_set_fraction(
+      GTK_PROGRESS_BAR(pdialog->production.production_bar), pct);
+  }
 
   if (pdialog->overview.production_combo != NULL) {
     gtk_combo_box_set_active(GTK_COMBO_BOX(pdialog->overview.production_combo),
@@ -1938,7 +1961,9 @@
   if (pdialog->overview.production_bar != NULL) {
     gtk_widget_queue_resize(pdialog->overview.production_bar);
   }
-  gtk_widget_queue_resize(pdialog->production.production_bar);
+  if (pdialog->production.production_bar != NULL) {
+    gtk_widget_queue_resize(pdialog->production.production_bar);
+  }
 }
 
 /****************************************************************

Modified: trunk/client/gui-gtk-3.0/wldlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/wldlg.c?rev=30865&r1=30864&r2=30865&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/wldlg.c    (original)
+++ trunk/client/gui-gtk-3.0/wldlg.c    Sun Dec  6 11:35:51 2015
@@ -1078,7 +1078,6 @@
   ptr->dst = dst_store;
   ptr->future = FALSE;
 
-
   /* create shell. */ 
   editor = gtk_grid_new();
   gtk_grid_set_row_spacing(GTK_GRID(editor), 6);
@@ -1097,9 +1096,9 @@
 
   sw = gtk_scrolled_window_new(NULL, NULL);
   gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
-                                     GTK_SHADOW_ETCHED_IN);
+                                      GTK_SHADOW_ETCHED_IN);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
-                                GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+                                 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
   gtk_grid_attach(GTK_GRID(table), sw, 3, 1, 2, 1);
 
   src_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(src_store));
@@ -1123,7 +1122,6 @@
   gtk_grid_attach(GTK_GRID(table), check, 4, 0, 1, 1);
   g_signal_connect(check, "toggled", G_CALLBACK(future_callback), ptr);
 
-
   table2 = gtk_grid_new();
   gtk_grid_attach(GTK_GRID(table), table2, 2, 1, 1, 1);
 
@@ -1137,7 +1135,7 @@
   arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE);
   gtk_container_add(GTK_CONTAINER(button), arrow);
   g_signal_connect_swapped(button, "clicked",
-                          G_CALLBACK(queue_prepend), ptr);
+                           G_CALLBACK(queue_prepend), ptr);
   gtk_widget_set_sensitive(ptr->prepend_cmd, FALSE);
 
   button = gtk_button_new();
@@ -1148,7 +1146,7 @@
   arrow = gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_NONE);
   gtk_container_add(GTK_CONTAINER(button), arrow);
   g_signal_connect_swapped(button, "clicked",
-                          G_CALLBACK(queue_bubble_up), ptr);
+                           G_CALLBACK(queue_bubble_up), ptr);
   gtk_widget_set_sensitive(ptr->up_cmd, FALSE);
 
   button = gtk_button_new();
@@ -1159,7 +1157,7 @@
   arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_IN);
   gtk_container_add(GTK_CONTAINER(button), arrow);
   g_signal_connect_swapped(button, "clicked",
-                          G_CALLBACK(queue_bubble_down), ptr);
+                           G_CALLBACK(queue_bubble_down), ptr);
   gtk_widget_set_sensitive(ptr->down_cmd, FALSE);
 
   button = gtk_button_new();
@@ -1172,7 +1170,7 @@
   arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE);
   gtk_container_add(GTK_CONTAINER(button), arrow);
   g_signal_connect_swapped(button, "clicked",
-                          G_CALLBACK(queue_append), ptr);
+                           G_CALLBACK(queue_append), ptr);
   gtk_widget_set_sensitive(ptr->append_cmd, FALSE);
 
   button = gtk_button_new();
@@ -1181,7 +1179,7 @@
   ptr->remove_cmd = button;
   gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
   gtk_grid_attach(GTK_GRID(table2), button, 0, 4, 1, 1);
-  
+
   arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_IN);
   gtk_container_add(GTK_CONTAINER(button), arrow);
   g_signal_connect_swapped(button, "clicked",


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

Reply via email to