[Freeciv-Dev] (PR#40710) Patch adding traderoutes list in Economic report

2009-06-19 Thread Madeline Book

http://bugs.freeciv.org/Ticket/Display.html?id=40710 >

I will close this ticket; if you want to try submitting
a corrected patch for this feature, please use the gna
bugtracker:
https://gna.org/bugs/?func=additem&group=freeciv


---
でもすべての店が閉まっている。
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40710) Patch adding traderoutes list in Economic report

2009-06-19 Thread Madeline Book

http://bugs.freeciv.org/Ticket/Display.html?id=40710 >

> [jmarda...@ifrance.com - Sat Feb 07 21:26:04 2009]:
> 
> I have made a patch adding in the Economic report dialog
> (GTK client only) a list of all the traderoutes. The total
> amount of trade is also displayed.
> 
> The patch is based on SVN version 15463.

I apologize for not getting to this patch sooner.

There are some problems with committing these code
changes as they are now:

- You must follow the patch creation guidelines:
  http://freeciv.wikia.com/wiki/How_to_Contribute
  even if there is only one file is changed.
- You must follow the coding style:
  http://freeciv.wikia.com/wiki/Coding_Style
  even if you are copying from older code already
  in the repository.

There are some design problems too:

- Traderoutes to your own cities are listed twice
  (the information is the same).
- The improvement related buttons in the economic
  report should be grouped with the improvement list.
- With all those columns in the traderoute list the
  economy window may be too wide.

I started to fix these problems but stopped since
it was taking too long and really you should be the
one to do it (if you are still interested). I will
attach though a "work in progress" patch which you
can base a better patch on. In particular I took the
time to greatly improve the gtk coding style since
you had unfortunately mimicked a particularly bad
section of old gui code. :(


---
怠け者じゃないの?
diff --git a/client/gui-gtk-2.0/repodlgs.c b/client/gui-gtk-2.0/repodlgs.c
index d3172a0..e3c46f0 100644
--- a/client/gui-gtk-2.0/repodlgs.c
+++ b/client/gui-gtk-2.0/repodlgs.c
@@ -49,6 +49,7 @@
 #include "packhand_gen.h"
 #include "control.h"
 #include "reqtree.h"
+#include "plrdlg.h" /* for get_flag() */
 #include "text.h"
 
 #include "canvas.h"
@@ -76,6 +77,7 @@ enum {
 };
 
 static void create_economy_report_dialog(bool make_modal);
+static void traderoutes_selection_changed(GtkTreeSelection *selection);
 static void economy_command_callback(struct gui_dialog *dlg, int response,
  gpointer data);
 static void economy_selection_callback(GtkTreeSelection *selection,
@@ -85,6 +87,7 @@ static struct universal economy_row_type[U_LAST + B_LAST];
 static struct gui_dialog *economy_dialog_shell = NULL;
 static GtkWidget *economy_label2;
 static GtkListStore *economy_store;
+static GtkWidget *traderoutes_view;
 static GtkTreeSelection *economy_selection;
 static GtkWidget *sellall_command, *sellobsolete_command;
 static int economy_dialog_shell_is_modal;
@@ -637,6 +640,14 @@ void popdown_economy_report_dialog(void)
 */
 void create_economy_report_dialog(bool make_modal)
 {
+  GtkWidget *frame, *hbox, *vbox, *view, *sw, *label;
+  GtkListStore *store;
+  GtkTreeSelection *sel;
+  GtkCellRenderer *renderer;
+  GtkTreeViewColumn *col;
+  const char *title;
+  int i;
+
   const char *titles[5] = {
 /* TRANS: Image header */
 _("Type"),
@@ -646,8 +657,6 @@ void create_economy_report_dialog(bool make_modal)
 /* TRANS: Upkeep total, count*cost */
 _("U Total")
   };
-  int i;
-
   static GType model_types[5] = {
 G_TYPE_NONE,
 G_TYPE_STRING,
@@ -655,16 +664,45 @@ void create_economy_report_dialog(bool make_modal)
 G_TYPE_INT,
 G_TYPE_INT
   };
-  GtkWidget *view, *sw, *align;
+
+  const char *traderoutes_titles[8] = {
+_("Source City"),
+Q_("?City:Size"),
+_("Dest. City"),
+_("Flag"),
+_("Nation"),
+Q_("?City:Size"),
+_("Distance"),
+_("Trade")
+  };
+  static GType traderoutes_types[8] = {
+G_TYPE_STRING,
+G_TYPE_INT,
+G_TYPE_STRING,
+G_TYPE_NONE, /* GDK_TYPE_PIXBUF */
+G_TYPE_STRING,
+G_TYPE_INT,
+G_TYPE_INT,
+G_TYPE_INT
+  };
 
   model_types[0] = GDK_TYPE_PIXBUF;
+  traderoutes_types[3] = GDK_TYPE_PIXBUF;
 
   gui_dialog_new(&economy_dialog_shell, GTK_NOTEBOOK(top_notebook), NULL);
   gui_dialog_set_title(economy_dialog_shell, _("Economy"));
 
-  align = gtk_alignment_new(0.5, 0.0, 0.0, 1.0);
-  gtk_box_pack_start(GTK_BOX(economy_dialog_shell->vbox), align,
-  TRUE, TRUE, 0);
+  vbox = economy_dialog_shell->vbox;
+
+  hbox = gtk_hbox_new(FALSE, 8);
+  gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+
+  /* Improvement list on the left side. */
+  frame = gtk_frame_new(_("Buildings"));
+  gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 2);
+
+  vbox = gtk_vbox_new(FALSE, 0);
+  gtk_container_add(GTK_CONTAINER(frame), vbox);
 
   economy_store = gtk_list_store_newv(ARRAY_SIZE(model_types), model_types);
 
@@ -673,7 +711,7 @@ void create_economy_report_dialog(bool make_modal)
   GTK_SHADOW_ETCHED_IN);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-  gtk_container_add(GTK_CONTAINER(align), sw);
+  gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0

[Freeciv-Dev] (PR#40710) Patch adding traderoutes list in Economic report

2009-02-07 Thread Jean-Michel Ardantz

http://bugs.freeciv.org/Ticket/Display.html?id=40710 >

This transaction appears to have no content
Hi,

I have made a patch adding in the Economic report dialog (GTK client
only) a list of all the traderoutes. The total amount of trade is also
displayed.

The patch is based on SVN version 15463.

Only one file modified client/gui-gtk-2.0/repodlgs.c

Hope that's help.
Mitchum







Hi,

I have made a patch adding in the Economic report dialog (GTK client only) a list of all the traderoutes. The total amount of trade is also displayed.

The patch is based on SVN version 15463.

Only one file modified client/gui-gtk-2.0/repodlgs.c

Hope that's help.
Mitchum











--- SAV_repodlgs.c	2009-02-01 20:18:55.0 +0100
+++ repodlgs.c	2009-02-07 10:02:25.0 +0100
@@ -49,6 +49,7 @@
 #include "packhand_gen.h"
 #include "control.h"
 #include "reqtree.h"
+#include "plrdlg.h" /* for get_flag() */
 #include "text.h"
 
 #include "canvas.h"
@@ -76,6 +77,7 @@
 };
 
 static void create_economy_report_dialog(bool make_modal);
+static void traderoutes_selection_changed_callback(GtkTreeSelection *selection);
 static void economy_command_callback(struct gui_dialog *dlg, int response,
  gpointer data);
 static void economy_selection_callback(GtkTreeSelection *selection,
@@ -85,7 +87,12 @@
 static struct gui_dialog *economy_dialog_shell = NULL;
 static GtkWidget *economy_label2;
 static GtkListStore *economy_store;
+static GtkWidget *traderoutes_label;
+static GtkWidget *traderoutes_view;
+static GtkListStore *traderoutes_store;
+static int total_trade=0;
 static GtkTreeSelection *economy_selection;
+static GtkTreeSelection *traderoutes_selection;
 static GtkWidget *sellall_command, *sellobsolete_command;
 static int economy_dialog_shell_is_modal;
 
@@ -646,6 +653,16 @@
 /* TRANS: Upkeep total, count*cost */
 _("U Total")
   };
+  const char *titlestrade[8] = {
+_("Our City"),
+_("Size"),
+_("Dest City"),
+_("Flag"),
+_("Nation"),
+_("Size"),
+_("Distance"),
+_("Trade")
+  };
   int i;
 
   static GType model_types[5] = {
@@ -655,16 +672,37 @@
 G_TYPE_INT,
 G_TYPE_INT
   };
-  GtkWidget *view, *sw, *align;
+  static GType traderoutes[8] = {
+G_TYPE_STRING,
+G_TYPE_INT,
+G_TYPE_STRING,
+G_TYPE_NONE,
+G_TYPE_STRING,
+G_TYPE_INT,
+G_TYPE_INT,
+G_TYPE_INT
+  };
+  GtkWidget *frame, *hbox, *vbox, *view, *sw, *align;
 
   model_types[0] = GDK_TYPE_PIXBUF;
+  traderoutes[3] = GDK_TYPE_PIXBUF;
 
   gui_dialog_new(&economy_dialog_shell, GTK_NOTEBOOK(top_notebook), NULL);
   gui_dialog_set_title(economy_dialog_shell, _("Economy"));
-
+
   align = gtk_alignment_new(0.5, 0.0, 0.0, 1.0);
   gtk_box_pack_start(GTK_BOX(economy_dialog_shell->vbox), align,
   TRUE, TRUE, 0);
+
+  hbox = gtk_hbox_new(FALSE, 0);
+  gtk_container_add(GTK_CONTAINER(align), hbox);
+
+  /* Model list in left side  */
+  frame = gtk_frame_new(_("Buildings"));
+  gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, FALSE, 2);
+
+  vbox = gtk_vbox_new(FALSE, 0);
+  gtk_container_add(GTK_CONTAINER(frame), vbox);
 
   economy_store = gtk_list_store_newv(ARRAY_SIZE(model_types), model_types);
 
@@ -673,7 +711,7 @@
   GTK_SHADOW_ETCHED_IN);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-  gtk_container_add(GTK_CONTAINER(align), sw);
+  gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
 
   view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(economy_store));
   g_object_unref(economy_store);
@@ -715,8 +753,7 @@
   gtk_container_add(GTK_CONTAINER(sw), view);
 
   economy_label2 = gtk_label_new(_("Total Cost:"));
-  gtk_box_pack_start(GTK_BOX(economy_dialog_shell->vbox), economy_label2,
-  FALSE, FALSE, 0);
+  gtk_box_pack_start(GTK_BOX(vbox), economy_label2, FALSE, FALSE, 0);
   gtk_misc_set_padding(GTK_MISC(economy_label2), 5, 5);
 
   sellobsolete_command =
@@ -728,7 +765,58 @@
 gui_dialog_add_button(economy_dialog_shell, _("Sell _All"),
 	ECONOMY_SELL_ALL);
   gtk_widget_set_sensitive(sellall_command, FALSE);
+
+  /* The traderoutes list in right side  */
+  frame = gtk_frame_new(_("City Traderoutes"));
+  gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, FALSE, 2);
+
+  vbox = gtk_vbox_new(FALSE, 0);
+  gtk_container_add(GTK_CONTAINER(frame), vbox);
+
+  traderoutes_store = gtk_list_store_newv(ARRAY_SIZE(traderoutes), traderoutes);
+
+  sw = gtk_scrolled_window_new(NULL,NULL);
+  gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
+  GTK_SHADOW_ETCHED_IN);
+  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+  gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
 
+  traderoutes_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(traderoutes_store));
+  g_object_unref(traderoutes_store);
+  gtk_widget_set_name(traderoutes_view, "small_font");
+  gtk_tree_view_columns_autosize(GTK_TREE_