[maemo-commits] [maemo-commits] r12363 - in projects/haf/branches/hildon-control-panel/refactoring: . src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Jun 19 13:58:33 EEST 2007
Author: lucasr
Date: 2007-06-19 13:58:31 +0300 (Tue, 19 Jun 2007)
New Revision: 12363

Modified:
   projects/haf/branches/hildon-control-panel/refactoring/ChangeLog
   projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-list.c
   projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-list.h
   projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-view.c
   projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app.c
Log:
2007-06-19  Lucas Rocha  <lucas.rocha at nokia.com>

	* src/hcp-app-list.[ch], src/hcp-app.c: added support for defining the
	translation domain in the applet's desktop file with the
	"X-Text-Domain" key.


Modified: projects/haf/branches/hildon-control-panel/refactoring/ChangeLog
===================================================================
--- projects/haf/branches/hildon-control-panel/refactoring/ChangeLog	2007-06-19 10:45:34 UTC (rev 12362)
+++ projects/haf/branches/hildon-control-panel/refactoring/ChangeLog	2007-06-19 10:58:31 UTC (rev 12363)
@@ -1,3 +1,9 @@
+2007-06-19  Lucas Rocha  <lucas.rocha at nokia.com>
+
+	* src/hcp-app-list.[ch], src/hcp-app.c: added support for defining the
+	translation domain in the applet's desktop file with the
+	"X-Text-Domain" key.
+
 2007-06-15  Lucas Rocha  <lucas.rocha at nokia.com>
 
 	* configure.ac: release 1.9.2

Modified: projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-list.c
===================================================================
--- projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-list.c	2007-06-19 10:45:34 UTC (rev 12362)
+++ projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-list.c	2007-06-19 10:58:31 UTC (rev 12363)
@@ -389,6 +389,7 @@
     gchar *plugin = NULL;
     gchar *icon = NULL;
     gchar *category = NULL;
+    gchar *text_domain = NULL;
 
     desktop_path = g_build_filename (dir_path, filename, NULL);
 
@@ -455,21 +456,47 @@
       error = NULL;
     }
 
+    text_domain = g_key_file_get_string (keyfile,
+                                         HCP_DESKTOP_GROUP,
+                                         HCP_DESKTOP_KEY_TEXT_DOMAIN,
+                                         &error);
+
+    g_debug ("TEM DOMAIN!!! %s", text_domain); 
+
+    if (error)
+    {
+      g_warning ("Error reading applet desktop file: %s", error->message);
+      g_error_free (error);
+      error = NULL;
+    }
+
     app = hcp_app_new ();
 
     g_object_set (G_OBJECT (app), 
                   "name", name,
                   "plugin", plugin,
                   "icon", icon,
-                  "category", category,
                   NULL); 
 
+    if (category != NULL)
+      g_object_set (G_OBJECT (app), 
+                    "category", category,
+                    NULL); 
+    
+    if (text_domain != NULL)
+    {
+      g_object_set (G_OBJECT (app), 
+                    "text-domain", text_domain,
+                    NULL);
+    }
+   
     g_hash_table_insert (priv->apps, g_strdup (plugin), app);
 
     g_free (name);
     g_free (plugin);
     g_free (icon);
     g_free (category);
+    g_free (text_domain);
   }
 
   g_key_file_free (keyfile);

Modified: projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-list.h
===================================================================
--- projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-list.h	2007-06-19 10:45:34 UTC (rev 12362)
+++ projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-list.h	2007-06-19 10:58:31 UTC (rev 12363)
@@ -61,6 +61,7 @@
 #define HCP_DESKTOP_KEY_ICON            "Icon"
 #define HCP_DESKTOP_KEY_CATEGORY        "Categories"
 #define HCP_DESKTOP_KEY_PLUGIN          "X-control-panel-plugin"
+#define HCP_DESKTOP_KEY_TEXT_DOMAIN     "X-Text-Domain"
 
 typedef struct _HCPCategory {
   gchar   *id;

Modified: projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-view.c
===================================================================
--- projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-view.c	2007-06-19 10:45:34 UTC (rev 12362)
+++ projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app-view.c	2007-06-19 10:58:31 UTC (rev 12363)
@@ -186,17 +186,22 @@
   GtkTreePath *path;
   GtkTreeIter iter;
   gchar *name = NULL;
+  gchar *text_domain = NULL;
 
   store = gtk_icon_view_get_model (GTK_ICON_VIEW (grid));
 
   g_object_get (G_OBJECT (app),
                 "name", &name,
+                "text-domain", &text_domain,
                 NULL); 
 
   gtk_list_store_append (GTK_LIST_STORE (store), &iter);
 
+  g_debug ("ADDING APP: %s (%s)", name, text_domain);
+  
   gtk_list_store_set (GTK_LIST_STORE (store), &iter, 
-                      HCP_STORE_LABEL, _(name),
+                      HCP_STORE_LABEL, ((text_domain && *text_domain) ? 
+			                dgettext(text_domain, name) : _(name)),
                       HCP_STORE_APP, app,
                       -1);
 

Modified: projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app.c
===================================================================
--- projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app.c	2007-06-19 10:45:34 UTC (rev 12362)
+++ projects/haf/branches/hildon-control-panel/refactoring/src/hcp-app.c	2007-06-19 10:58:31 UTC (rev 12363)
@@ -45,7 +45,8 @@
   PROP_CATEGORY,
   PROP_IS_RUNNING,
   PROP_GRID,
-  PROP_ITEM_POS
+  PROP_ITEM_POS,
+  PROP_TEXT_DOMAIN
 };
 
 struct _HCPAppPrivate 
@@ -57,6 +58,7 @@
     gboolean                 is_running;
     GtkWidget               *grid;
     gint                     item_pos;
+    gchar                   *text_domain;
     void                    *handle;
     hcp_plugin_exec_f       *exec;
     hcp_plugin_save_state_f *save_state;
@@ -83,6 +85,7 @@
   app->priv->is_running = FALSE;
   app->priv->grid = NULL;
   app->priv->item_pos = -1;
+  app->priv->text_domain = NULL;
   app->priv->save_state = NULL;
 }
 
@@ -111,7 +114,6 @@
 
   if (!priv->handle)
   {
-    g_debug ("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ LOADING APPLET");
     priv->handle = dlopen (plugin_path, RTLD_LAZY);
   }
  
@@ -257,6 +259,12 @@
     priv->grid = NULL;
   }
 
+  if (priv->text_domain != NULL) 
+  {
+    g_free (priv->text_domain);
+    priv->text_domain = NULL;
+  }
+
   G_OBJECT_CLASS (hcp_app_parent_class)->finalize (object);
 }
 
@@ -300,6 +308,10 @@
       g_value_set_int (value, priv->item_pos);
       break;
 
+    case PROP_TEXT_DOMAIN:
+      g_value_set_string (value, priv->text_domain);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
       break;
@@ -352,6 +364,11 @@
       priv->item_pos = g_value_get_int (value);
       break;
 
+    case PROP_TEXT_DOMAIN:
+      g_free (priv->text_domain);
+      priv->text_domain = g_strdup (g_value_get_string (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
       break;
@@ -426,6 +443,14 @@
                                                      -1,
                                                       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
 
+  g_object_class_install_property (g_object_class,
+                                   PROP_TEXT_DOMAIN,
+                                   g_param_spec_string ("text-domain",
+                                                        "Text Domain",
+                                                        "Set app's text domain",
+                                                        NULL,
+                                                        (G_PARAM_READABLE | G_PARAM_WRITABLE)));
+ 
   g_type_class_add_private (g_object_class, sizeof (HCPAppPrivate));
 }
 


More information about the maemo-commits mailing list