Author: sveinung
Date: Sun Jun 15 14:42:25 2014
New Revision: 25146

URL: http://svn.gna.org/viewcvs/freeciv?rev=25146&view=rev
Log:
Gtk2 client: Change the way spy action probabilities are displayed.

- Show the action success probability as "?%" in stead of showing a warning
  icon when the probability is known to be unknown.
- Add a tool tip when the action probability is known.

See patch #4800

Modified:
    trunk/client/gui-gtk-2.0/choice_dialog.c
    trunk/client/gui-gtk-2.0/choice_dialog.h
    trunk/client/gui-gtk-2.0/dialogs.c
    trunk/client/gui-gtk-2.0/diplomat_dialog.c

Modified: trunk/client/gui-gtk-2.0/choice_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/choice_dialog.c?rev=25146&r1=25145&r2=25146&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/choice_dialog.c    (original)
+++ trunk/client/gui-gtk-2.0/choice_dialog.c    Sun Jun 15 14:42:25 2014
@@ -121,7 +121,8 @@
   Add button to choice dialog.
 *****************************************************************/
 void choice_dialog_add(GtkWidget *dshell, const gchar *label,
-                       GCallback handler, gpointer data, bool warn)
+                       GCallback handler, gpointer data,
+                       const gchar *tool_tip)
 {
   GtkWidget *button, *bbox;
   char name[512];
@@ -144,26 +145,8 @@
   g_signal_connect_after(button, "clicked",
                         G_CALLBACK(choice_dialog_clicked), dshell);
 
-  if (warn) {
-    /* Add the warning icon if it can be found */
-    GtkIconTheme *theme = gtk_icon_theme_get_default();
-
-    /* TODO: What should be done if no icon is found? */
-    if (gtk_icon_theme_has_icon(theme, "dialog-warning")) {
-      GdkPixbuf *icon;
-      GtkWidget *converted;
-
-      icon = gtk_icon_theme_load_icon(theme, "dialog-warning",
-                                      16, 0, NULL);
-      converted = gtk_image_new_from_pixbuf(icon);
-      gtk_button_set_image(GTK_BUTTON(button), converted);
-      g_object_unref(icon);
-    }
-
-    /* Add a tool tip as well */
-    gtk_widget_set_tooltip_text(button,
-                                _("Starting to do this"
-                                  " may currently be impossible."));
+  if (tool_tip != NULL) {
+    gtk_widget_set_tooltip_text(button, tool_tip);
   }
 }
 
@@ -209,7 +192,7 @@
     handler = va_arg(args, GCallback);
     data = va_arg(args, gpointer);
 
-    choice_dialog_add(dshell, name, handler, data, FALSE);
+    choice_dialog_add(dshell, name, handler, data, NULL);
   }
 
   va_end(args);

Modified: trunk/client/gui-gtk-2.0/choice_dialog.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/choice_dialog.h?rev=25146&r1=25145&r2=25146&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/choice_dialog.h    (original)
+++ trunk/client/gui-gtk-2.0/choice_dialog.h    Sun Jun 15 14:42:25 2014
@@ -23,7 +23,8 @@
 GtkWidget *choice_dialog_start(GtkWindow *parent, const gchar *name,
                                       const gchar *text);
 void choice_dialog_add(GtkWidget *dshell, const gchar *label,
-                       GCallback handler, gpointer data, bool warn);
+                       GCallback handler, gpointer data,
+                       const gchar *tool_tip);
 void choice_dialog_end(GtkWidget *dshell);
 void choice_dialog_button_set_sensitive(GtkWidget *shl, int button,
                                         gboolean state);

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=25146&r1=25145&r2=25146&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/dialogs.c  (original)
+++ trunk/client/gui-gtk-2.0/dialogs.c  Sun Jun 15 14:42:25 2014
@@ -364,10 +364,10 @@
 
       choice_dialog_add(shl, get_infrastructure_text(what_extras),
                         G_CALLBACK(pillage_callback), GINT_TO_POINTER(what),
-                        FALSE);
-    }
-
-    choice_dialog_add(shl, GTK_STOCK_CANCEL, 0, 0, FALSE);
+                        NULL);
+    }
+
+    choice_dialog_add(shl, GTK_STOCK_CANCEL, 0, 0, NULL);
 
     choice_dialog_end(shl);
 

Modified: trunk/client/gui-gtk-2.0/diplomat_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/diplomat_dialog.c?rev=25146&r1=25145&r2=25146&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/diplomat_dialog.c  (original)
+++ trunk/client/gui-gtk-2.0/diplomat_dialog.c  Sun Jun 15 14:42:25 2014
@@ -660,6 +660,7 @@
                          GCallback handler)
 {
   const gchar *label;
+  const gchar *tooltip;
   action_probability success_propability;
   gchar *chance_text;
 
@@ -674,15 +675,16 @@
   case ACTPROB_NOT_KNOWN:
     /* Unknown because the player don't have the required knowledge to
      * determine the probability of success for this action. */
-    label = action_prepare_ui_name(action_id, "_", "");
-
-    choice_dialog_add(shl, label, handler, NULL, TRUE);
+    label = action_prepare_ui_name(action_id, "_", _(" (?%)"));
+
+    choice_dialog_add(shl, label, handler, NULL,
+        _("Starting to do this may currently be impossible."));
     break;
   case ACTPROB_NOT_IMPLEMENTED:
     /* Unknown because of missing server support. */
     label = action_prepare_ui_name(action_id, "_", "");
 
-    choice_dialog_add(shl, label, handler, NULL, FALSE);
+    choice_dialog_add(shl, label, handler, NULL, NULL);
     break;
   default:
     /* Should be in the range 1 (0.5%) to 200 (100%) */
@@ -690,13 +692,16 @@
                   "Diplomat action probability out of range");
 
     /* TRANS: the probability that a diplomat action will succeed. */
-    chance_text = g_strdup_printf(_(" (%.1f%% chance of success)"),
+    chance_text = g_strdup_printf(_(" (%.1f%%)"),
                                   (double)success_propability / 2);
 
     label = action_prepare_ui_name(action_id, "_", chance_text);
 
+    tooltip = g_strdup_printf(_("The probability of success is %.1f%%."),
+                              (double)success_propability / 2);
+
     /* The unit of success_propability is 0.5% chance of success. */
-    choice_dialog_add(shl, label, handler, NULL, FALSE);
+    choice_dialog_add(shl, label, handler, NULL, tooltip);
 
     free(chance_text);
 
@@ -797,16 +802,16 @@
     if (pcity) {
       choice_dialog_add(shl, _("_Keep moving"),
                         (GCallback)diplomat_keep_moving_city_callback,
-                        NULL, FALSE);
+                        NULL, NULL);
     } else {
       choice_dialog_add(shl, _("_Keep moving"),
                         (GCallback)diplomat_keep_moving_unit_callback,
-                        NULL, FALSE);
+                        NULL, NULL);
     }
   }
 
   choice_dialog_add(shl, GTK_STOCK_CANCEL,
-                    (GCallback)diplomat_cancel_callback, NULL, FALSE);
+                    (GCallback)diplomat_cancel_callback, NULL, NULL);
 
   choice_dialog_end(shl);
 


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

Reply via email to