Author: cazfi
Date: Mon May  9 14:45:14 2016
New Revision: 32626

URL: http://svn.gna.org/viewcvs/freeciv?rev=32626&view=rev
Log:
Show scenario format version on gtk-clients.

See patch #7191

Modified:
    trunk/client/gui-gtk-2.0/pages.c
    trunk/client/gui-gtk-3.0/pages.c
    trunk/client/gui-gtk-3.x/pages.c

Modified: trunk/client/gui-gtk-2.0/pages.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/pages.c?rev=32626&r1=32625&r2=32626&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/pages.c    (original)
+++ trunk/client/gui-gtk-2.0/pages.c    Mon May  9 14:45:14 2016
@@ -62,6 +62,7 @@
 
 static GtkWidget *scenario_description;
 static GtkWidget *scenario_filename;
+static GtkWidget *scenario_version;
 
 static GtkListStore *load_store, *scenario_store, *meta_store, *lan_store; 
 
@@ -2866,21 +2867,39 @@
   GtkTextBuffer *buffer;
   char *description;
   char *filename;
+  int ver;
+  char vername[50];
 
   if (gtk_tree_selection_get_selected(scenario_selection, NULL, &it)) {
     gtk_tree_model_get(GTK_TREE_MODEL(scenario_store), &it,
                       2, &description, -1);
     gtk_tree_model_get(GTK_TREE_MODEL(scenario_store), &it,
                       1, &filename, -1);
+    gtk_tree_model_get(GTK_TREE_MODEL(scenario_store), &it,
+                       3, &ver, -1);
     filename = skip_to_basename(filename);
+    if (ver > 0) {
+      int maj;
+      int min;
+
+      maj = ver / 1000000;
+      ver %= 1000000;
+      min = ver / 10000;
+      fc_snprintf(vername, sizeof(vername), "%d.%d", maj, min);
+    } else {
+      /* TRANS: Old scenario format version */
+      fc_snprintf(vername, sizeof(vername), _("pre-2.6"));
+    }
   } else {
     description = "";
     filename = "";
+    vername[0] = '\0';
   }
 
   buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(scenario_description));
   gtk_text_buffer_set_text(buffer, description, -1);
   gtk_label_set_text(GTK_LABEL(scenario_filename), filename);
+  gtk_label_set_text(GTK_LABEL(scenario_version), vername);
 }
 
 /**************************************************************************
@@ -3014,7 +3033,7 @@
 GtkWidget *create_scenario_page(void)
 {
   GtkWidget *vbox, *hbox, *sbox, *bbox, *filenamebox, *descbox;
-
+  GtkWidget *versionbox, *vertext;
   GtkWidget *align, *button, *label, *view, *sw, *text;
   GtkCellRenderer *rend;
 
@@ -3091,9 +3110,21 @@
   gtk_box_pack_start(GTK_BOX(filenamebox), text, FALSE, TRUE, 0);
   gtk_box_pack_start(GTK_BOX(filenamebox), scenario_filename, FALSE, TRUE, 0);
 
+  /* TRANS: Scenario format version */
+  vertext = gtk_label_new(_("Format:"));
+  scenario_version = gtk_label_new("");
+  gtk_misc_set_alignment(GTK_MISC(scenario_version), 0.0, 0.5);
+  gtk_label_set_selectable(GTK_LABEL(scenario_version), TRUE);
+
+  versionbox = gtk_hbox_new(FALSE, 12);
+
+  gtk_box_pack_start(GTK_BOX(versionbox), vertext, FALSE, TRUE, 0);
+  gtk_box_pack_start(GTK_BOX(versionbox), scenario_version, FALSE, TRUE, 0);
+
   descbox = gtk_vbox_new(FALSE, 6);
   gtk_box_pack_start(GTK_BOX(descbox), sw, TRUE, TRUE, 0);
   gtk_box_pack_start(GTK_BOX(descbox), filenamebox, FALSE, FALSE, 5);
+  gtk_box_pack_start(GTK_BOX(descbox), versionbox, FALSE, FALSE, 5);
   gtk_container_add(GTK_CONTAINER(align), descbox);
 
   bbox = gtk_hbutton_box_new();

Modified: trunk/client/gui-gtk-3.0/pages.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/pages.c?rev=32626&r1=32625&r2=32626&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/pages.c    (original)
+++ trunk/client/gui-gtk-3.0/pages.c    Mon May  9 14:45:14 2016
@@ -62,6 +62,7 @@
 
 static GtkWidget *scenario_description;
 static GtkWidget *scenario_filename;
+static GtkWidget *scenario_version;
 
 static GtkListStore *load_store, *scenario_store, *meta_store, *lan_store; 
 
@@ -2936,21 +2937,39 @@
   GtkTextBuffer *buffer;
   char *description;
   char *filename;
+  int ver;
+  char vername[50];
 
   if (gtk_tree_selection_get_selected(scenario_selection, NULL, &it)) {
     gtk_tree_model_get(GTK_TREE_MODEL(scenario_store), &it,
                       2, &description, -1);
     gtk_tree_model_get(GTK_TREE_MODEL(scenario_store), &it,
                       1, &filename, -1);
+    gtk_tree_model_get(GTK_TREE_MODEL(scenario_store), &it,
+                      3, &ver, -1);
     filename = skip_to_basename(filename);
+    if (ver > 0) {
+      int maj;
+      int min;
+
+      maj = ver / 1000000;
+      ver %= 1000000;
+      min = ver / 10000;
+      fc_snprintf(vername, sizeof(vername), "%d.%d", maj, min);
+    } else {
+      /* TRANS: Old scenario format version */
+      fc_snprintf(vername, sizeof(vername), _("pre-2.6"));
+    }
   } else {
     description = "";
     filename = "";
+    vername[0] = '\0';
   }
 
   buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(scenario_description));
   gtk_text_buffer_set_text(buffer, description, -1);
   gtk_label_set_text(GTK_LABEL(scenario_filename), filename);
+  gtk_label_set_text(GTK_LABEL(scenario_version), vername);
 }
 
 /**************************************************************************
@@ -3084,7 +3103,7 @@
 GtkWidget *create_scenario_page(void)
 {
   GtkWidget *vbox, *hbox, *sbox, *bbox, *filenamebox, *descbox;
-
+  GtkWidget *versionbox, *vertext;
   GtkWidget *button, *label, *view, *sw, *text;
   GtkCellRenderer *rend;
 
@@ -3174,12 +3193,27 @@
   gtk_container_add(GTK_CONTAINER(filenamebox), text);
   gtk_container_add(GTK_CONTAINER(filenamebox), scenario_filename);
 
+  /* TRANS: Scenario format version */
+  vertext = gtk_label_new(_("Format:"));
+  scenario_version = gtk_label_new("");
+  gtk_widget_set_halign(scenario_version, GTK_ALIGN_START);
+  gtk_widget_set_valign(scenario_version, GTK_ALIGN_CENTER);
+  gtk_label_set_selectable(GTK_LABEL(scenario_version), TRUE);
+
+  versionbox = gtk_grid_new();
+  gtk_grid_set_column_spacing(GTK_GRID(hbox), 12);
+  g_object_set(versionbox, "margin", 5, NULL);
+
+  gtk_container_add(GTK_CONTAINER(versionbox), vertext);
+  gtk_container_add(GTK_CONTAINER(versionbox), scenario_version);
+
   descbox = gtk_grid_new();
   gtk_orientable_set_orientation(GTK_ORIENTABLE(descbox),
                                  GTK_ORIENTATION_VERTICAL);
   gtk_grid_set_row_spacing(GTK_GRID(descbox), 6);
   gtk_container_add(GTK_CONTAINER(descbox), sw);
   gtk_container_add(GTK_CONTAINER(descbox), filenamebox);
+  gtk_container_add(GTK_CONTAINER(descbox), versionbox);
   gtk_grid_attach(GTK_GRID(sbox), descbox, 1, 0, 1, 1);
 
   bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);

Modified: trunk/client/gui-gtk-3.x/pages.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/pages.c?rev=32626&r1=32625&r2=32626&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/pages.c    (original)
+++ trunk/client/gui-gtk-3.x/pages.c    Mon May  9 14:45:14 2016
@@ -62,6 +62,7 @@
 
 static GtkWidget *scenario_description;
 static GtkWidget *scenario_filename;
+static GtkWidget *scenario_version;
 
 static GtkListStore *load_store, *scenario_store, *meta_store, *lan_store; 
 
@@ -2936,21 +2937,39 @@
   GtkTextBuffer *buffer;
   char *description;
   char *filename;
+  int ver;
+  char vername[50];
 
   if (gtk_tree_selection_get_selected(scenario_selection, NULL, &it)) {
     gtk_tree_model_get(GTK_TREE_MODEL(scenario_store), &it,
                       2, &description, -1);
     gtk_tree_model_get(GTK_TREE_MODEL(scenario_store), &it,
                       1, &filename, -1);
+    gtk_tree_model_get(GTK_TREE_MODEL(scenario_store), &it,
+                       3, &ver, -1);
     filename = skip_to_basename(filename);
+    if (ver > 0) {
+      int maj;
+      int min;
+
+      maj = ver / 1000000;
+      ver %= 1000000;
+      min = ver / 10000;
+      fc_snprintf(vername, sizeof(vername), "%d.%d", maj, min);
+    } else {
+      /* TRANS: Old scenario format version */
+      fc_snprintf(vername, sizeof(vername), _("pre-2.6"));
+    }
   } else {
     description = "";
     filename = "";
+    vername[0] = '\0';
   }
 
   buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(scenario_description));
   gtk_text_buffer_set_text(buffer, description, -1);
   gtk_label_set_text(GTK_LABEL(scenario_filename), filename);
+  gtk_label_set_text(GTK_LABEL(scenario_version), vername);
 }
 
 /**************************************************************************
@@ -3084,7 +3103,7 @@
 GtkWidget *create_scenario_page(void)
 {
   GtkWidget *vbox, *hbox, *sbox, *bbox, *filenamebox, *descbox;
-
+  GtkWidget *versionbox, *vertext;
   GtkWidget *button, *label, *view, *sw, *text;
   GtkCellRenderer *rend;
 
@@ -3174,12 +3193,27 @@
   gtk_container_add(GTK_CONTAINER(filenamebox), text);
   gtk_container_add(GTK_CONTAINER(filenamebox), scenario_filename);
 
+  /* TRANS: Scenario format version */
+  vertext = gtk_label_new(_("Format:"));
+  scenario_version = gtk_label_new("");
+  gtk_widget_set_halign(scenario_version, GTK_ALIGN_START);
+  gtk_widget_set_valign(scenario_version, GTK_ALIGN_CENTER);
+  gtk_label_set_selectable(GTK_LABEL(scenario_version), TRUE);
+
+  versionbox = gtk_grid_new();
+  gtk_grid_set_column_spacing(GTK_GRID(hbox), 12);
+  g_object_set(versionbox, "margin", 5, NULL);
+
+  gtk_container_add(GTK_CONTAINER(versionbox), vertext);
+  gtk_container_add(GTK_CONTAINER(versionbox), scenario_version);
+
   descbox = gtk_grid_new();
   gtk_orientable_set_orientation(GTK_ORIENTABLE(descbox),
                                  GTK_ORIENTATION_VERTICAL);
   gtk_grid_set_row_spacing(GTK_GRID(descbox), 6);
   gtk_container_add(GTK_CONTAINER(descbox), sw);
   gtk_container_add(GTK_CONTAINER(descbox), filenamebox);
+  gtk_container_add(GTK_CONTAINER(descbox), versionbox);
   gtk_grid_attach(GTK_GRID(sbox), descbox, 1, 0, 1, 1);
 
   bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);


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

Reply via email to