Author: cazfi
Date: Sun Sep  4 21:40:43 2016
New Revision: 33761

URL: http://svn.gna.org/viewcvs/freeciv?rev=33761&view=rev
Log:
Added scenario authors display to scenario page of gtk3-client.

See patch #7329

Modified:
    branches/S2_6/client/gui-gtk-3.0/pages.c

Modified: branches/S2_6/client/gui-gtk-3.0/pages.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/pages.c?rev=33761&r1=33760&r2=33761&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/pages.c    (original)
+++ branches/S2_6/client/gui-gtk-3.0/pages.c    Sun Sep  4 21:40:43 2016
@@ -61,6 +61,7 @@
 
 
 static GtkWidget *scenario_description;
+static GtkWidget *scenario_authors;
 static GtkWidget *scenario_filename;
 static GtkWidget *scenario_version;
 
@@ -2948,6 +2949,7 @@
   GtkTreeIter it;
   GtkTextBuffer *buffer;
   char *description;
+  char *authors;
   char *filename;
   int ver;
   char vername[50];
@@ -2956,9 +2958,11 @@
     gtk_tree_model_get(GTK_TREE_MODEL(scenario_store), &it,
                       2, &description, -1);
     gtk_tree_model_get(GTK_TREE_MODEL(scenario_store), &it,
+                       3, &authors, -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);
+                      4, &ver, -1);
     filename = skip_to_basename(filename);
     if (ver > 0) {
       int maj;
@@ -2974,12 +2978,15 @@
     }
   } else {
     description = "";
+    authors = "";
     filename = "";
     vername[0] = '\0';
   }
 
   buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(scenario_description));
   gtk_text_buffer_set_text(buffer, description, -1);
+  buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(scenario_authors));
+  gtk_text_buffer_set_text(buffer, authors, -1);
   gtk_label_set_text(GTK_LABEL(scenario_filename), filename);
   gtk_label_set_text(GTK_LABEL(scenario_version), vername);
 }
@@ -3026,7 +3033,7 @@
 
     if ((sf = secfile_load_section(pfile->fullname, "scenario", TRUE))
         && secfile_lookup_bool_default(sf, TRUE, "scenario.is_scenario")) {
-      const char *sname, *sdescription;
+      const char *sname, *sdescription, *sauthors;
       int fcver;
       int current_ver = MAJOR_VERSION *10000 + MINOR_VERSION *100;
 
@@ -3035,6 +3042,7 @@
       sname = secfile_lookup_str_default(sf, NULL, "scenario.name");
       sdescription = secfile_lookup_str_default(sf, NULL,
                                                 "scenario.description");
+      sauthors = secfile_lookup_str_default(sf, NULL, "scenario.authors");
       log_debug("scenario file: %s from %s", sname, pfile->fullname);
 
       /* Ignore scenarios for newer freeciv versions than we are */
@@ -3057,7 +3065,7 @@
               int existing;
 
               gtk_tree_model_get(GTK_TREE_MODEL(scenario_store), &it,
-                                 3, &existing, -1);
+                                 4, &existing, -1);
               log_debug("Duplicate %s (%d vs %d)", sname, existing, fcver);
 
               if (existing > fcver) {
@@ -3072,7 +3080,9 @@
                                    1, pfile->fullname,
                                    2, (NULL != sdescription && '\0' != 
sdescription[0]
                                        ? Q_(sdescription) : ""),
-                                   3, fcver,
+                                   3, (NULL != sauthors && sauthors[0] != '\0'
+                                       ? Q_(sauthors) : ""),
+                                   4, fcver,
                                    -1);
               } else {
                 /* Same version number -> list both */
@@ -3091,7 +3101,9 @@
                              1, pfile->fullname,
                              2, (NULL != sdescription && '\0' != 
sdescription[0]
                                  ? Q_(sdescription) : ""),
-                             3, fcver,
+                             3, (NULL != sauthors && sauthors[0] != '\0'
+                                 ? Q_(sauthors) : ""),
+                             4, fcver,
                              -1);
         }
       }
@@ -3110,7 +3122,7 @@
 {
   GtkWidget *vbox, *hbox, *sbox, *bbox, *filenamebox, *descbox;
   GtkWidget *versionbox, *vertext;
-  GtkWidget *button, *label, *view, *sw, *text;
+  GtkWidget *button, *label, *view, *sw, *swa, *text;
   GtkCellRenderer *rend;
 
   vbox = gtk_grid_new();
@@ -3119,7 +3131,8 @@
   gtk_grid_set_row_spacing(GTK_GRID(vbox), 18);
   gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
 
-  scenario_store = gtk_list_store_new(4, G_TYPE_STRING,
+  scenario_store = gtk_list_store_new(5, G_TYPE_STRING,
+                                         G_TYPE_STRING,
                                          G_TYPE_STRING,
                                          G_TYPE_STRING,
                                          G_TYPE_INT);
@@ -3186,6 +3199,21 @@
                                 GTK_POLICY_AUTOMATIC);
   gtk_container_add(GTK_CONTAINER(sw), text);
 
+  text = gtk_text_view_new();
+  gtk_widget_set_hexpand(text, TRUE);
+  gtk_widget_set_vexpand(text, TRUE);
+  gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
+  gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 2);
+  gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
+  scenario_authors = text;
+
+  swa = gtk_scrolled_window_new(NULL, NULL);
+  gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swa),
+                                      GTK_SHADOW_ETCHED_IN);
+  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swa), 
GTK_POLICY_AUTOMATIC,
+                                 GTK_POLICY_AUTOMATIC);
+  gtk_container_add(GTK_CONTAINER(swa), text);
+
   text = gtk_label_new(_("Filename:"));
   scenario_filename = gtk_label_new("");
   gtk_widget_set_halign(scenario_filename, GTK_ALIGN_START);
@@ -3218,9 +3246,10 @@
                                  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), swa);
   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);
+  gtk_grid_attach(GTK_GRID(sbox), descbox, 1, 0, 1, 2);
 
   bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
   gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);


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

Reply via email to