[gtk+/parasite2] inspector: Make translatable



commit e7606f8473b31eed5ce0cf0224a1fe358e139260
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed May 7 00:13:00 2014 -0400

    inspector: Make translatable
    
    Mark strings in the source and in the templates as translatable.
    We use the same extract-strings utility as for libgtk itself.

 modules/inspector/Makefile.am         |   26 +++++++++++++++++++++++-
 modules/inspector/button-path.ui      |    4 +-
 modules/inspector/classes-list.c      |   10 +++++---
 modules/inspector/classes-list.ui     |    8 +++---
 modules/inspector/css-editor.c        |   34 ++++++++++++++++++--------------
 modules/inspector/css-editor.ui       |    4 +-
 modules/inspector/inspect-button.c    |    4 ++-
 modules/inspector/object-hierarchy.ui |    4 +-
 modules/inspector/prop-list.ui        |    8 +++---
 modules/inspector/themes.ui           |    8 +++---
 modules/inspector/widget-tree.ui      |   14 ++++++------
 modules/inspector/window.c            |    4 ++-
 modules/inspector/window.ui           |   24 +++++++++++-----------
 po/POTFILES.in                        |   12 +++++++++++
 14 files changed, 104 insertions(+), 60 deletions(-)
---
diff --git a/modules/inspector/Makefile.am b/modules/inspector/Makefile.am
index 97dcd32..6cc8f60 100644
--- a/modules/inspector/Makefile.am
+++ b/modules/inspector/Makefile.am
@@ -6,7 +6,7 @@ resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --gener
 resources.h: inspector.gresource.xml
        $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/inspector.gresource.xml \
                --target=$@ --sourcedir=$(srcdir) --c-name gtk_inspector --generate-header --manual-register
-resources.c: inspector.gresource.xml $(resource_files)
+resources.c: inspector.gresource.xml $(resource_files) $(template_headers)
        $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/inspector.gresource.xml \
                --target=$@ --sourcedir=$(srcdir) --c-name gtk_inspector --generate-source --manual-register
 
@@ -63,7 +63,29 @@ libgtkinspector_la_LIBADD = \
        $(top_builddir)/gtk/libgtk-3.la \
        $(GTK_DEP_LIBS)
 
-EXTRA_DIST= \
+templates = \ 
+       button-path.ui \
+       classes-list.ui \
+       css-editor.ui \
+       object-hierarchy.ui \
+       prop-list.ui \
+       themes.ui \
+       widget-tree.ui \
+       window.ui
+
+template_headers = $(templates:.ui=.ui.h)
+
+extract_strings = $(top_builddir)/gtk/extract-strings$(BUILD_EXEEXT)
+
+%.ui.h: %.ui $(extract_strings)
+       $(AM_V_GEN) $(extract_strings) $< > $@
+
+distclean-local:
+       if test $(srcdir) != .; then \
+         rm -f $(template_headers); \
+       fi
+
+EXTRA_DIST=
        $(resource_files)
 
 -include $(top_srcdir)/git.mk
diff --git a/modules/inspector/button-path.ui b/modules/inspector/button-path.ui
index e4addfb..b586f41 100644
--- a/modules/inspector/button-path.ui
+++ b/modules/inspector/button-path.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<interface>
+<interface domain="gtk30">
   <template class="GtkInspectorButtonPath" parent="GtkBox">
     <property name="orientation">horizontal</property>
     <child>
@@ -22,7 +22,7 @@
             <child>
               <object class="GtkLabel">
                 <property name="visible">True</property>
-                <property name="label">Choose a widget through the inspector</property>
+                <property name="label" translatable="yes">Choose a widget through the inspector</property>
                 <property name="hexpand">True</property>
                 <property name="xalign">0.5</property>
               </object>
diff --git a/modules/inspector/classes-list.c b/modules/inspector/classes-list.c
index 86d078e..7c0d52a 100644
--- a/modules/inspector/classes-list.c
+++ b/modules/inspector/classes-list.c
@@ -20,6 +20,8 @@
  * THE SOFTWARE.
  */
 
+#include "config.h"
+#include <glib/gi18n-lib.h>
 #include "classes-list.h"
 
 enum
@@ -99,18 +101,18 @@ add_clicked (GtkButton               *button,
 {
   GtkWidget *dialog, *content_area, *entry;
 
-  dialog = gtk_dialog_new_with_buttons ("New class",
+  dialog = gtk_dialog_new_with_buttons (_("New class"),
                                         GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (cl))),
                                          GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | 
GTK_DIALOG_USE_HEADER_BAR,
-                                         "_OK", GTK_RESPONSE_OK,
-                                         "Cancel", GTK_RESPONSE_CANCEL,
+                                         _("_OK"), GTK_RESPONSE_OK,
+                                         _("Cancel"), GTK_RESPONSE_CANCEL,
                                          NULL);
   gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
 
   entry = g_object_new (GTK_TYPE_ENTRY,
                         "visible", TRUE,
                         "margin", 5,
-                        "placeholder-text", "Class name",
+                        "placeholder-text", _("Class name"),
                         "activates-default", TRUE,
                         NULL);
   content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
diff --git a/modules/inspector/classes-list.ui b/modules/inspector/classes-list.ui
index 363b1ea..b7198a3 100644
--- a/modules/inspector/classes-list.ui
+++ b/modules/inspector/classes-list.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<interface>
+<interface domain="gtk30">
   <object class="GtkListStore" id="model">
     <columns>
       <column type="gboolean"/>
@@ -18,7 +18,7 @@
           <object class="GtkToolButton">
             <property name="visible">True</property>
             <property name="icon-name">list-add</property>
-            <property name="tooltip-text">Add a class</property>
+            <property name="tooltip-text" translatable="yes">Add a class</property>
             <signal name="clicked" handler="add_clicked"/>
           </object>
         </child>
@@ -26,7 +26,7 @@
           <object class="GtkToolButton">
             <property name="visible">True</property>
             <property name="icon-name">document-revert</property>
-            <property name="tooltip-text">Restore defaults for this widget</property>
+            <property name="tooltip-text" translatable="yes">Restore defaults for this widget</property>
             <signal name="clicked" handler="restore_defaults_clicked"/>
           </object>
         </child>
@@ -42,7 +42,7 @@
             <property name="model">model</property>
             <child>
               <object class="GtkTreeViewColumn" id="column">
-                <property name="title">Name</property>
+                <property name="title" translatable="yes">Name</property>
                 <child>
                   <object class="GtkCellRendererToggle">
                     <signal name="toggled" handler="enabled_toggled"/>
diff --git a/modules/inspector/css-editor.c b/modules/inspector/css-editor.c
index e7f6a8c..1d49146 100644
--- a/modules/inspector/css-editor.c
+++ b/modules/inspector/css-editor.c
@@ -20,6 +20,8 @@
  * THE SOFTWARE.
  */
 
+#include "config.h"
+#include <glib/gi18n-lib.h>
 #include "css-editor.h"
 
 #define GTK_INSPECTOR_CSS_EDITOR_TEXT "inspector-css-editor-text"
@@ -60,28 +62,30 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorCssEditor, gtk_inspector_css_editor, GTK
 static void
 set_initial_text (GtkInspectorCssEditor *editor)
 {
-  const gchar *initial_text_global =
-    "/*\n"
-    "You can type here any CSS rule recognized by GTK+.\n"
-    "You can temporarily disable this custom CSS by clicking on the \"Pause\" button above.\n\n"
-    "Changes are applied instantly and globally, for the whole application.\n"
-    "*/\n\n";
-  const gchar *initial_text_widget =
-    "/*\n"
-    "You can type here any CSS rule recognized by GTK+.\n"
-    "You can temporarily disable this custom CSS by clicking on the \"Pause\" button above.\n\n"
-    "Changes are applied instantly, only for this selected widget.\n"
-    "*/\n\n";
   const gchar *text = NULL;
 
   if (editor->priv->selected_context)
     text = g_object_get_data (G_OBJECT (editor->priv->selected_context), GTK_INSPECTOR_CSS_EDITOR_TEXT);
   if (text)
     gtk_text_buffer_set_text (GTK_TEXT_BUFFER (editor->priv->text), text, -1);
-  else if (editor->priv->global)
-    gtk_text_buffer_set_text (GTK_TEXT_BUFFER (editor->priv->text), initial_text_global, -1);
   else
-    gtk_text_buffer_set_text (GTK_TEXT_BUFFER (editor->priv->text), initial_text_widget, -1);
+    {
+      gchar *initial_text;
+      if (editor->priv->global)
+        initial_text = g_strconcat ("/*\n",
+                                    _("You can type here any CSS rule recognized by GTK+."), "\n",
+                                    _("You can temporarily disable this custom CSS by clicking on the 
\"Pause\" button above."), "\n\n",
+                                    _("Changes are applied instantly and globally, for the whole 
application."), "\n",
+                                    "*/\n\n", NULL);
+      else
+        initial_text = g_strconcat ("/*\n",
+                                    _("You can type here any CSS rule recognized by GTK+."), "\n",
+                                    _("You can temporarily disable this custom CSS by clicking on the 
\"Pause\" button above."), "\n\n",
+                                    _("Changes are applied instantly, only for this selected widget."), "\n",
+                                    "*/\n\n", NULL);
+      gtk_text_buffer_set_text (GTK_TEXT_BUFFER (editor->priv->text), initial_text, -1);
+      g_free (initial_text);
+    }
 }
 
 static void
diff --git a/modules/inspector/css-editor.ui b/modules/inspector/css-editor.ui
index 7987d8a..7a6d921 100644
--- a/modules/inspector/css-editor.ui
+++ b/modules/inspector/css-editor.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<interface>
+<interface domain="gtk30">
   <object class="GtkTextTagTable" id="tags">
     <child type="tag">
       <object class="GtkTextTag">
@@ -26,7 +26,7 @@
           <object class="GtkToggleToolButton" id="disable_button">
             <property name="visible">True</property>
             <property name="icon-name">media-playback-pause</property>
-            <property name="tooltip-text">Disable this custom CSS</property>
+            <property name="tooltip-text" translatable="yes">Disable this custom CSS</property>
             <signal name="toggled" handler="disable_toggled"/>
           </object>
         </child>
diff --git a/modules/inspector/inspect-button.c b/modules/inspector/inspect-button.c
index 6c6fbb5..a7ea24c 100644
--- a/modules/inspector/inspect-button.c
+++ b/modules/inspector/inspect-button.c
@@ -21,6 +21,8 @@
  * THE SOFTWARE.
  */
 
+#include "config.h"
+#include <glib/gi18n-lib.h>
 #include "window.h"
 #include "widget-tree.h"
 
@@ -296,7 +298,7 @@ gtk_inspector_inspect_button_new (GtkInspectorWindow *iw)
   GtkWidget *button;
 
   button = gtk_button_new_from_icon_name ("edit-find", GTK_ICON_SIZE_BUTTON);
-  gtk_widget_set_tooltip_text (button, "Inspect");
+  gtk_widget_set_tooltip_text (button, _("Inspect"));
   g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_inspect), iw);
 
   return button;
diff --git a/modules/inspector/object-hierarchy.ui b/modules/inspector/object-hierarchy.ui
index 04d54e1..fd5dd0b 100644
--- a/modules/inspector/object-hierarchy.ui
+++ b/modules/inspector/object-hierarchy.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<interface>
+<interface domain="gtk30">
   <object class="GtkTreeStore" id="model">
     <columns>
       <column type="gchararray"/>
@@ -17,7 +17,7 @@
             <property name="model">model</property>
             <child>
               <object class="GtkTreeViewColumn">
-                <property name="title">Object Hierarchy</property>
+                <property name="title" translatable="yes">Object Hierarchy</property>
                 <child>
                   <object class="GtkCellRendererText">
                     <property name="scale">0.8</property>
diff --git a/modules/inspector/prop-list.ui b/modules/inspector/prop-list.ui
index a3064ac..ed92009 100644
--- a/modules/inspector/prop-list.ui
+++ b/modules/inspector/prop-list.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<interface>
+<interface domain="gtk30">
   <object class="GtkListStore" id="model">
     <columns>
       <column type="gchararray"/>
@@ -15,7 +15,7 @@
     <property name="tooltip-column">4</property>
     <child>
       <object class="GtkTreeViewColumn">
-        <property name="title">Property</property>
+        <property name="title" translatable="yes">Property</property>
         <property name="resizable">True</property>
         <property name="sort-order">ascending</property>
         <property name="sort-column-id">0</property>
@@ -32,7 +32,7 @@
     </child>
     <child>
       <object class="GtkTreeViewColumn">
-        <property name="title">Value</property>
+        <property name="title" translatable="yes">Value</property>
         <property name="resizable">True</property>
         <child>
           <object class="GtkInspectorPropertyCellRenderer" id="value_renderer">
@@ -50,7 +50,7 @@
     </child>
     <child>
       <object class="GtkTreeViewColumn">
-        <property name="title">Defined At</property>
+        <property name="title" translatable="yes">Defined At</property>
         <child>
           <object class="GtkCellRendererText">
             <property name="scale">0.8</property>
diff --git a/modules/inspector/themes.ui b/modules/inspector/themes.ui
index 1e94264..73ca432 100644
--- a/modules/inspector/themes.ui
+++ b/modules/inspector/themes.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<interface>
+<interface domain="gtk30">
   <template class="GtkInspectorThemes" parent="GtkListBox">
     <property name="selection-mode">none</property>
     <child>
@@ -10,7 +10,7 @@
         <child>
           <object class="GtkLabel">
             <property name="visible">True</property>
-            <property name="label">Use dark variant</property>
+            <property name="label" translatable="yes">Use dark variant</property>
             <property name="hexpand">True</property>
             <property name="xalign">0.0</property>
           </object>
@@ -30,7 +30,7 @@
         <child>
           <object class="GtkLabel">
             <property name="visible">True</property>
-            <property name="label">GTK+ Theme</property>
+            <property name="label" translatable="yes">GTK+ Theme</property>
             <property name="hexpand">True</property>
             <property name="xalign">0.0</property>
           </object>
@@ -51,7 +51,7 @@
         <child>
           <object class="GtkLabel">
             <property name="visible">True</property>
-            <property name="label">Icon Theme</property>
+            <property name="label" translatable="yes">Icon Theme</property>
             <property name="hexpand">True</property>
             <property name="xalign">0.0</property>
           </object>
diff --git a/modules/inspector/widget-tree.ui b/modules/inspector/widget-tree.ui
index 9a53d5f..1b01f72 100644
--- a/modules/inspector/widget-tree.ui
+++ b/modules/inspector/widget-tree.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<interface>
+<interface domain="gtk30">
   <object class="GtkTreeStore" id="model">
     <columns>
       <column type="gpointer"/>
@@ -23,7 +23,7 @@
     </child>
     <child>
       <object class="GtkTreeViewColumn">
-        <property name="title">Widget</property>
+        <property name="title" translatable="yes">Widget</property>
         <property name="resizable">True</property>
         <child>
           <object class="GtkCellRendererText">
@@ -38,7 +38,7 @@
     </child>
     <child>
       <object class="GtkTreeViewColumn">
-        <property name="title">Name</property>
+        <property name="title" translatable="yes">Name</property>
         <property name="resizable">True</property>
         <child>
           <object class="GtkCellRendererText">
@@ -53,7 +53,7 @@
     </child>
     <child>
       <object class="GtkTreeViewColumn">
-        <property name="title">Realized</property>
+        <property name="title" translatable="yes">Realized</property>
         <child>
           <object class="GtkCellRendererToggle">
             <property name="activatable">True</property>
@@ -67,7 +67,7 @@
     </child>
     <child>
       <object class="GtkTreeViewColumn">
-        <property name="title">Mapped</property>
+        <property name="title" translatable="yes">Mapped</property>
         <child>
           <object class="GtkCellRendererToggle">
             <property name="activatable">True</property>
@@ -81,7 +81,7 @@
     </child>
     <child>
       <object class="GtkTreeViewColumn">
-        <property name="title">Visible</property>
+        <property name="title" translatable="yes">Visible</property>
         <child>
           <object class="GtkCellRendererToggle">
             <property name="activatable">True</property>
@@ -95,7 +95,7 @@
     </child>
     <child>
       <object class="GtkTreeViewColumn">
-        <property name="title">Address</property>
+        <property name="title" translatable="yes">Address</property>
         <property name="resizable">True</property>
         <child>
           <object class="GtkCellRendererText">
diff --git a/modules/inspector/window.c b/modules/inspector/window.c
index 4383e48..db420be 100644
--- a/modules/inspector/window.c
+++ b/modules/inspector/window.c
@@ -22,6 +22,8 @@
  * THE SOFTWARE.
  */
 
+#include "config.h"
+#include <glib/gi18n-lib.h>
 #include <stdlib.h>
 #include "window.h"
 #include "prop-list.h"
@@ -119,7 +121,7 @@ gtk_inspector_window_init (GtkInspectorWindow *iw)
 
   gtk_window_group_add_window (gtk_window_group_new (), GTK_WINDOW (iw));
 
-  title = g_strdup_printf ("GTK+ Inspector — %s", g_get_application_name ());
+  title = g_strdup_printf (_("GTK+ Inspector — %s"), g_get_application_name ());
   gtk_window_set_title (GTK_WINDOW (iw), title);
   g_free (title);
 
diff --git a/modules/inspector/window.ui b/modules/inspector/window.ui
index a1d7a45..287628f 100644
--- a/modules/inspector/window.ui
+++ b/modules/inspector/window.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<interface>
+<interface domain="gtk30">
   <object class="GtkImage" id="update_image">
     <property name="visible">True</property>
     <property name="icon-name">view-refresh</property>
@@ -15,7 +15,7 @@
     <child>
       <object class="GtkMenuItem">
         <property name="visible">True</property>
-        <property name="label">Send Widget to Shell</property>
+        <property name="label" translatable="yes">Send Widget to Shell</property>
         <signal name="activate" handler="on_send_widget_to_shell_activate"/>
       </object>
     </child>
@@ -37,7 +37,7 @@
               <object class="GtkButton">
                 <property name="visible">True</property>
                 <property name="image">inspect_image</property>
-                <property name="tooltip-text">Inspect</property>
+                <property name="tooltip-text" translatable="yes">Inspect</property>
                 <signal name="clicked" handler="on_inspect"/>
               </object>
             </child>
@@ -45,7 +45,7 @@
               <object class="GtkToggleButton">
                 <property name="visible">True</property>
                 <property name="image">update_image</property>
-                <property name="tooltip-text">Show Graphic Updates</property>
+                <property name="tooltip-text" translatable="yes">Show Graphic Updates</property>
                 <signal name="toggled" handler="on_graphic_updates_toggled"/>
               </object>
             </child>
@@ -135,7 +135,7 @@
                     <child type="tab">
                       <object class="GtkLabel">
                         <property name="visible">True</property>
-                        <property name="label">Properties</property>
+                        <property name="label" translatable="yes">Properties</property>
                       </object>
                     </child> 
                     <child>
@@ -156,7 +156,7 @@
                     <child type="tab">
                       <object class="GtkLabel">
                         <property name="visible">True</property>
-                        <property name="label">Child Properties</property>
+                        <property name="label" translatable="yes">Child Properties</property>
                       </object>
                     </child> 
                     <child>
@@ -167,7 +167,7 @@
                     <child type="tab">
                       <object class="GtkLabel">
                         <property name="visible">True</property>
-                        <property name="label">Hierarchy</property>
+                        <property name="label" translatable="yes">Hierarchy</property>
                       </object>
                     </child> 
                     <child>
@@ -178,7 +178,7 @@
                     <child type="tab">
                       <object class="GtkLabel">
                         <property name="visible">True</property>
-                        <property name="label">CSS Classes</property>
+                        <property name="label" translatable="yes">CSS Classes</property>
                       </object>
                     </child> 
                     <child>
@@ -190,7 +190,7 @@
                     <child type="tab">
                       <object class="GtkLabel">
                         <property name="visible">True</property>
-                        <property name="label">Custom CSS</property>
+                        <property name="label" translatable="yes">Custom CSS</property>
                       </object>
                     </child> 
                   </object>
@@ -206,7 +206,7 @@
         <child type="tab">
           <object class="GtkLabel">
             <property name="visible">True</property>
-            <property name="label">Widget Tree</property>
+            <property name="label" translatable="yes">Widget Tree</property>
           </object>
         </child>
         <child>
@@ -217,7 +217,7 @@
         <child type="tab">
           <object class="GtkLabel">
             <property name="visible">True</property>
-            <property name="label">Themes</property>
+            <property name="label" translatable="yes">Themes</property>
           </object>
         </child>
         <child>
@@ -229,7 +229,7 @@
         <child type="tab">
           <object class="GtkLabel">
             <property name="visible">True</property>
-            <property name="label">Custom CSS</property>
+            <property name="label" translatable="yes">Custom CSS</property>
           </object>
         </child>
       </object>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 73a1125..85bf439 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -282,6 +282,18 @@ modules/input/imti-er.c
 modules/input/imti-et.c
 modules/input/imviqr.c
 modules/input/imxim.c
+modules/inspector/classes-list.c
+modules/inspector/css-editor.c
+modules/inspector/inspect-button.c
+modules/inspector/window.c
+modules/inspector/button-path.ui.h
+modules/inspector/classes-list.ui.h
+modules/inspector/css-editor.ui.h
+modules/inspector/object-hierarchy.ui.h
+modules/inspector/prop-list.ui.h
+modules/inspector/themes.ui.h
+modules/inspector/widget-tree.ui.h
+modules/inspector/window.ui.h
 modules/printbackends/cloudprint/gtkprintbackendcloudprint.c
 modules/printbackends/cloudprint/gtkprintercloudprint.c
 modules/printbackends/cups/gtkprintbackendcups.c


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