[gimp] app: the manual language can now be customized through the Preferences.



commit 3061333fdbf0a08b0a3bf37e833fd9be8349d362
Author: Jehan <jehan girinstud io>
Date:   Tue Oct 3 20:47:06 2017 +0200

    app: the manual language can now be customized through the Preferences.

 app/dialogs/preferences-dialog.c   |  213 +++++++++++++++++++++++++++---------
 app/widgets/gimphelp.c             |    3 +-
 app/widgets/gimplanguagecombobox.c |   18 +++-
 app/widgets/gimplanguagecombobox.h |    3 +-
 app/widgets/gimppropwidgets.c      |    2 +-
 app/widgets/gimptranslationstore.c |   23 +++-
 app/widgets/gimptranslationstore.h |    3 +-
 7 files changed, 201 insertions(+), 64 deletions(-)
---
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index e1339a3..0e10b20 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -47,6 +47,7 @@
 #include "widgets/gimphelp.h"
 #include "widgets/gimphelp-ids.h"
 #include "widgets/gimpiconsizescale.h"
+#include "widgets/gimplanguagecombobox.h"
 #include "widgets/gimpmessagebox.h"
 #include "widgets/gimpmessagedialog.h"
 #include "widgets/gimppluginview.h"
@@ -77,57 +78,61 @@
 
 /*  preferences local functions  */
 
-static GtkWidget * prefs_dialog_new               (Gimp       *gimp,
-                                                   GimpConfig *config);
-static void        prefs_config_notify            (GObject    *config,
-                                                   GParamSpec *param_spec,
-                                                   GObject    *config_copy);
-static void        prefs_config_copy_notify       (GObject    *config_copy,
-                                                   GParamSpec *param_spec,
-                                                   GObject    *config);
-static void        prefs_response                 (GtkWidget  *widget,
-                                                   gint        response_id,
-                                                   GtkWidget  *dialog);
-
-static void        prefs_message                  (GtkMessageType  type,
-                                                   gboolean        destroy,
-                                                   const gchar    *message);
-
-static void   prefs_color_management_reset        (GtkWidget  *widget,
-                                                   GObject    *config);
-static void   prefs_dialog_defaults_reset         (GtkWidget  *widget,
-                                                   GObject    *config);
-
-static void   prefs_import_raw_procedure_callback (GtkWidget  *widget,
-                                                   GObject    *config);
-static void   prefs_resolution_source_callback    (GtkWidget  *widget,
-                                                   GObject    *config);
-static void   prefs_resolution_calibrate_callback (GtkWidget  *widget,
-                                                   GtkWidget  *entry);
-static void   prefs_input_devices_dialog          (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_keyboard_shortcuts_dialog     (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_menus_save_callback           (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_menus_clear_callback          (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_menus_remove_callback         (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_session_save_callback         (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_session_clear_callback        (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_devices_save_callback         (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_devices_clear_callback        (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_search_clear_callback         (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_tool_options_save_callback    (GtkWidget  *widget,
-                                                   Gimp       *gimp);
-static void   prefs_tool_options_clear_callback   (GtkWidget  *widget,
-                                                   Gimp       *gimp);
+static GtkWidget * prefs_dialog_new                (Gimp       *gimp,
+                                                    GimpConfig *config);
+static void        prefs_config_notify             (GObject    *config,
+                                                    GParamSpec *param_spec,
+                                                    GObject    *config_copy);
+static void        prefs_config_copy_notify        (GObject    *config_copy,
+                                                    GParamSpec *param_spec,
+                                                    GObject    *config);
+static void        prefs_response                  (GtkWidget  *widget,
+                                                    gint        response_id,
+                                                    GtkWidget  *dialog);
+
+static void        prefs_message                   (GtkMessageType  type,
+                                                    gboolean        destroy,
+                                                    const gchar    *message);
+
+static void   prefs_color_management_reset         (GtkWidget    *widget,
+                                                    GObject      *config);
+static void   prefs_dialog_defaults_reset          (GtkWidget    *widget,
+                                                    GObject      *config);
+
+static void   prefs_import_raw_procedure_callback  (GtkWidget    *widget,
+                                                    GObject      *config);
+static void   prefs_resolution_source_callback     (GtkWidget    *widget,
+                                                    GObject      *config);
+static void   prefs_resolution_calibrate_callback  (GtkWidget    *widget,
+                                                    GtkWidget    *entry);
+static void   prefs_input_devices_dialog           (GtkWidget    *widget,
+                                                    Gimp         *gimp);
+static void   prefs_keyboard_shortcuts_dialog      (GtkWidget    *widget,
+                                                    Gimp         *gimp);
+static void   prefs_menus_save_callback            (GtkWidget    *widget,
+                                                    Gimp         *gimp);
+static void   prefs_menus_clear_callback           (GtkWidget    *widget,
+                                                    Gimp         *gimp);
+static void   prefs_menus_remove_callback          (GtkWidget    *widget,
+                                                    Gimp         *gimp);
+static void   prefs_session_save_callback          (GtkWidget    *widget,
+                                                    Gimp         *gimp);
+static void   prefs_session_clear_callback         (GtkWidget    *widget,
+                                                    Gimp         *gimp);
+static void   prefs_devices_save_callback          (GtkWidget    *widget,
+                                                    Gimp         *gimp);
+static void   prefs_devices_clear_callback         (GtkWidget    *widget,
+                                                    Gimp         *gimp);
+static void   prefs_search_clear_callback          (GtkWidget    *widget,
+                                                    Gimp         *gimp);
+static void   prefs_tool_options_save_callback     (GtkWidget    *widget,
+                                                    Gimp         *gimp);
+static void   prefs_tool_options_clear_callback    (GtkWidget    *widget,
+                                                    Gimp         *gimp);
+static void   prefs_help_language_change_callback  (GtkComboBox  *combo,
+                                                    Gimp         *gimp);
+static void   prefs_help_language_change_callback2 (GtkComboBox  *combo,
+                                                    GtkContainer *box);
 
 /*  private variables  */
 
@@ -763,6 +768,74 @@ prefs_tool_options_clear_callback (GtkWidget *widget,
 }
 
 static void
+prefs_help_language_change_callback (GtkComboBox *combo,
+                                     Gimp        *gimp)
+{
+  gchar *help_locales = NULL;
+  gchar *code;
+
+  code = gimp_language_combo_box_get_code (GIMP_LANGUAGE_COMBO_BOX (combo));
+  if (code && g_strcmp0 ("", code) != 0)
+    {
+      help_locales = g_strdup_printf ("%s:", code);
+    }
+  g_object_set (gimp->config,
+                "help-locales", help_locales? help_locales : "",
+                NULL);
+  g_free (code);
+  if (help_locales)
+    g_free (help_locales);
+}
+
+static void
+prefs_help_language_change_callback2 (GtkComboBox  *combo,
+                                      GtkContainer *box)
+{
+  Gimp        *gimp;
+  GtkLabel    *label = NULL;
+  GtkImage    *icon  = NULL;
+  GList       *children;
+  GList       *iter;
+  const gchar *text;
+  const gchar *icon_name;
+
+  gimp = g_object_get_data (G_OBJECT (box), "gimp");
+  children = gtk_container_get_children (box);
+  for (iter = children; iter; iter = iter->next)
+    {
+      if (GTK_IS_LABEL (iter->data))
+        {
+          label = iter->data;
+        }
+      else if (GTK_IS_IMAGE (iter->data))
+        {
+          icon = iter->data;
+        }
+    }
+  if (gimp_help_user_manual_is_installed (gimp))
+    {
+      text = _("There's a local installation of the user manual.");
+      icon_name = GIMP_ICON_DIALOG_INFORMATION;
+    }
+  else
+    {
+      text = _("The user manual is not installed locally.");
+      icon_name = GIMP_ICON_DIALOG_WARNING;
+    }
+  if (label)
+    {
+      gtk_label_set_text (label, text);
+    }
+  if (icon)
+    {
+      gtk_image_set_from_icon_name (icon, icon_name,
+                                    GTK_ICON_SIZE_BUTTON);
+    }
+
+  g_list_free (children);
+}
+
+static void
 prefs_format_string_select_callback (GtkTreeSelection *sel,
                                      GtkEntry         *entry)
 {
@@ -999,6 +1072,7 @@ prefs_dialog_new (Gimp       *gimp,
   GtkWidget         *calibrate_button;
   GSList            *group;
   GtkWidget         *editor;
+  gchar             *help_locales = NULL;
   gint               i;
 
   GObject           *object;
@@ -2215,7 +2289,7 @@ prefs_dialog_new (Gimp       *gimp,
                           _("Show help _buttons"),
                           GTK_BOX (vbox2));
 
-  table = prefs_table_new (2, GTK_CONTAINER (vbox2));
+  table = prefs_table_new (3, GTK_CONTAINER (vbox2));
   button = prefs_boolean_combo_box_add (object, "user-manual-online",
                                         _("Use the online version"),
                                         _("Use a locally installed copy"),
@@ -2223,6 +2297,35 @@ prefs_dialog_new (Gimp       *gimp,
                                         GTK_TABLE (table), 0, size_group);
   gimp_help_set_help_data (button, NULL, NULL);
 
+  g_object_get (config, "help-locales", &help_locales, NULL);
+  if (help_locales && strlen (help_locales))
+    {
+      gchar *sep;
+
+      sep = strchr (help_locales, ':');
+      if (sep)
+        *sep = '\0';
+    }
+
+  entry = gimp_language_combo_box_new (TRUE,
+                                       _("User interface language"));
+  if (help_locales)
+    {
+      gimp_language_combo_box_set_code (GIMP_LANGUAGE_COMBO_BOX (entry),
+                                        help_locales);
+      g_free (help_locales);
+    }
+  else
+    {
+      gimp_language_combo_box_set_code (GIMP_LANGUAGE_COMBO_BOX (entry),
+                                        "");
+    }
+  g_signal_connect (entry, "changed",
+                    G_CALLBACK (prefs_help_language_change_callback),
+                    gimp);
+  gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 1, 2);
+  gtk_widget_show (entry);
+
   if (gimp_help_user_manual_is_installed (gimp))
     {
       hbox = prefs_hint_box_new (GIMP_ICON_DIALOG_INFORMATION,
@@ -2235,8 +2338,12 @@ prefs_dialog_new (Gimp       *gimp,
                                  _("The user manual is not installed "
                                    "locally."));
     }
+  g_object_set_data (G_OBJECT (hbox), "gimp", gimp);
+  g_signal_connect (entry, "changed",
+                    G_CALLBACK (prefs_help_language_change_callback2),
+                    hbox);
 
-  gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 1, 2);
+  gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 2, 3);
   gtk_widget_show (hbox);
 
   /*  Help Browser  */
diff --git a/app/widgets/gimphelp.c b/app/widgets/gimphelp.c
index 407ee2d..159d0dd 100644
--- a/app/widgets/gimphelp.c
+++ b/app/widgets/gimphelp.c
@@ -820,7 +820,8 @@ gimp_help_query_alt_user_manual (GimpIdleHelp *idle_help)
                              _("Read Selected _Language"),
                              GTK_RESPONSE_YES);
       /* And a dropdown list of available manuals. */
-      lang_combo = gimp_language_combo_box_new (TRUE);
+      lang_combo = gimp_language_combo_box_new (TRUE,
+                                                _("Available manuals..."));
       gtk_combo_box_set_active (GTK_COMBO_BOX (lang_combo), 0);
       gtk_dialog_set_response_sensitive (idle_help->query_dialog,
                                          GTK_RESPONSE_YES, FALSE);
diff --git a/app/widgets/gimplanguagecombobox.c b/app/widgets/gimplanguagecombobox.c
index 188beb2..0947442 100644
--- a/app/widgets/gimplanguagecombobox.c
+++ b/app/widgets/gimplanguagecombobox.c
@@ -64,14 +64,26 @@ gimp_language_combo_box_init (GimpLanguageComboBox *combo)
                                   NULL);
 }
 
+/**
+ * gimp_language_combo_box_new:
+ * @manual_l18n: get only the sublist of manual languages.
+ * @empty_label: the label for empty language code.
+ *
+ * Returns a combo box containing all GUI localization languages if
+ * @manual_l18n is #FALSE, or all manual localization languages
+ * otherwise. If @empty_label is not #NULL, an entry with this label
+ * will be created for the language code "", otherwise if @empty_label
+ * is #NULL and @manual_l18n is #FALSE, the entry will be "System
+ * Language" localized in itself (not in the GUI language).
+ */
 GtkWidget *
-gimp_language_combo_box_new (gboolean manual_l18n)
+gimp_language_combo_box_new (gboolean     manual_l18n,
+                             const gchar *empty_label)
 {
   GtkWidget    *combo;
   GtkListStore *store;
 
-  store = gimp_translation_store_new (manual_l18n);
-
+  store = gimp_translation_store_new (manual_l18n, empty_label);
   combo = g_object_new (GIMP_TYPE_LANGUAGE_COMBO_BOX,
                         "model", store,
                         NULL);
diff --git a/app/widgets/gimplanguagecombobox.h b/app/widgets/gimplanguagecombobox.h
index 198acc7..e6da4ec 100644
--- a/app/widgets/gimplanguagecombobox.h
+++ b/app/widgets/gimplanguagecombobox.h
@@ -40,7 +40,8 @@ struct _GimpLanguageComboBoxClass
 
 GType       gimp_language_combo_box_get_type (void) G_GNUC_CONST;
 
-GtkWidget * gimp_language_combo_box_new      (gboolean manual_l18n);
+GtkWidget * gimp_language_combo_box_new      (gboolean              manual_l18n,
+                                              const gchar          *empty_label);
 
 gchar     * gimp_language_combo_box_get_code (GimpLanguageComboBox *combo);
 gboolean    gimp_language_combo_box_set_code (GimpLanguageComboBox *combo,
diff --git a/app/widgets/gimppropwidgets.c b/app/widgets/gimppropwidgets.c
index b95a017..c5a8ec2 100644
--- a/app/widgets/gimppropwidgets.c
+++ b/app/widgets/gimppropwidgets.c
@@ -1351,7 +1351,7 @@ gimp_prop_language_combo_box_new (GObject     *config,
   if (! param_spec)
     return NULL;
 
-  combo = gimp_language_combo_box_new (FALSE);
+  combo = gimp_language_combo_box_new (FALSE, NULL);
 
   g_object_get (config,
                 property_name, &value,
diff --git a/app/widgets/gimptranslationstore.c b/app/widgets/gimptranslationstore.c
index bd957fe..ca6d935 100644
--- a/app/widgets/gimptranslationstore.c
+++ b/app/widgets/gimptranslationstore.c
@@ -38,7 +38,8 @@
 enum
 {
   PROP_0,
-  PROP_MANUAL_L18N
+  PROP_MANUAL_L18N,
+  PROP_EMPTY_LABEL
 };
 
 struct _GimpTranslationStoreClass
@@ -51,6 +52,7 @@ struct _GimpTranslationStore
   GimpLanguageStore  parent_instance;
 
   gboolean           manual_l18n;
+  gchar             *empty_label;
 };
 
 
@@ -85,6 +87,11 @@ gimp_translation_store_class_init (GimpTranslationStoreClass *klass)
                                                          FALSE,
                                                          GIMP_PARAM_READWRITE |
                                                          G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (object_class, PROP_EMPTY_LABEL,
+                                   g_param_spec_string ("empty-label", NULL, NULL,
+                                                         NULL,
+                                                         GIMP_PARAM_READWRITE |
+                                                         G_PARAM_CONSTRUCT_ONLY));
 }
 
 static void
@@ -109,10 +116,10 @@ gimp_translation_store_constructed (GObject *object)
 
   g_hash_table_iter_init (&lang_iter, lang_list);
 
-  if (sublist)
+  if (sublist && GIMP_TRANSLATION_STORE (object)->empty_label)
     {
       GIMP_LANGUAGE_STORE_GET_CLASS (object)->add (GIMP_LANGUAGE_STORE (object),
-                                                   _("Available manuals..."),
+                                                   GIMP_TRANSLATION_STORE (object)->empty_label,
                                                    "");
     }
   while (g_hash_table_iter_next (&lang_iter, &code, &name))
@@ -140,6 +147,9 @@ gimp_translation_store_set_property (GObject      *object,
     case PROP_MANUAL_L18N:
       store->manual_l18n = g_value_get_boolean (value);
       break;
+    case PROP_EMPTY_LABEL:
+      store->empty_label = g_value_dup_string (value);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -160,6 +170,9 @@ gimp_translation_store_get_property (GObject    *object,
     case PROP_MANUAL_L18N:
       g_value_set_boolean (value, store->manual_l18n);
       break;
+    case PROP_EMPTY_LABEL:
+      g_value_set_string (value, store->empty_label);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -168,9 +181,11 @@ gimp_translation_store_get_property (GObject    *object,
 }
 
 GtkListStore *
-gimp_translation_store_new (gboolean manual_l18n)
+gimp_translation_store_new (gboolean     manual_l18n,
+                            const gchar *empty_label)
 {
   return g_object_new (GIMP_TYPE_TRANSLATION_STORE,
                        "manual-l18n", manual_l18n,
+                       "empty-label", empty_label,
                        NULL);
 }
diff --git a/app/widgets/gimptranslationstore.h b/app/widgets/gimptranslationstore.h
index 7283b2b..47bf747 100644
--- a/app/widgets/gimptranslationstore.h
+++ b/app/widgets/gimptranslationstore.h
@@ -38,7 +38,8 @@ typedef struct _GimpTranslationStoreClass  GimpTranslationStoreClass;
 
 GType          gimp_translation_store_get_type (void) G_GNUC_CONST;
 
-GtkListStore * gimp_translation_store_new      (gboolean manual_l18n);
+GtkListStore * gimp_translation_store_new      (gboolean     manual_l18n,
+                                                const gchar *empty_label);
 
 
 #endif  /* __GIMP_TRANSLATION_STORE_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]