[maemo-commits] [maemo-commits] r12074 - in projects/haf/trunk/hildon-plugins-settings: . data src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri Jun 1 23:37:36 EEST 2007
Author: moimart
Date: 2007-06-01 23:37:34 +0300 (Fri, 01 Jun 2007)
New Revision: 12074

Added:
   projects/haf/trunk/hildon-plugins-settings/data/
   projects/haf/trunk/hildon-plugins-settings/data/Makefile.am
   projects/haf/trunk/hildon-plugins-settings/data/hildon-plugins-settings.desktop.in
Modified:
   projects/haf/trunk/hildon-plugins-settings/ChangeLog
   projects/haf/trunk/hildon-plugins-settings/configure.ac
   projects/haf/trunk/hildon-plugins-settings/src/Makefile.am
   projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-config-parser.c
   projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings.c
Log:
2007-06-01  Moises Martinez  <moises.martinez at nokia.com>

        * configure.ac: Updated.
        * src/hildon-plugin-config-parser.c:
        - Several bugfixes.
        - Added position field.
        * src/hildon-plugin-settings.c:
        - It is still a unit test.
        * src/Makefile.am: Updated
        * data/hildon-plugins-settings.desktop.in: Filled
        * data/Makefile.am: Added
	* ChangeLog updated.



Modified: projects/haf/trunk/hildon-plugins-settings/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-plugins-settings/ChangeLog	2007-06-01 17:00:05 UTC (rev 12073)
+++ projects/haf/trunk/hildon-plugins-settings/ChangeLog	2007-06-01 20:37:34 UTC (rev 12074)
@@ -1,5 +1,17 @@
 2007-06-01  Moises Martinez  <moises.martinez at nokia.com>
 
+	* configure.ac: Updated.
+	* src/hildon-plugin-config-parser.c:
+	- Several bugfixes.
+	- Added position field.
+	* src/hildon-plugin-settings.c:
+	- It is still a unit test.
+	* src/Makefile.am: Updated
+	* data/hildon-plugins-settings.desktop.in: Filled
+	* data/Makefile.am: Added
+
+2007-06-01  Moises Martinez  <moises.martinez at nokia.com>
+
 	* +++ src/hildon-plugin-config-parser.[ch]:
 	- Fixed several bugs to get it built and working.
 	* src/hildon-plugin-settings.c:

Modified: projects/haf/trunk/hildon-plugins-settings/configure.ac
===================================================================
--- projects/haf/trunk/hildon-plugins-settings/configure.ac	2007-06-01 17:00:05 UTC (rev 12073)
+++ projects/haf/trunk/hildon-plugins-settings/configure.ac	2007-06-01 20:37:34 UTC (rev 12074)
@@ -81,5 +81,6 @@
 
 AC_OUTPUT(Makefile \
 	  src/Makefile \
-	  data/hildon-plugins-settings.desktop)
+	  data/hildon-plugins-settings.desktop \
+	  data/Makefile)
 

Added: projects/haf/trunk/hildon-plugins-settings/data/Makefile.am
===================================================================
--- projects/haf/trunk/hildon-plugins-settings/data/Makefile.am	2007-06-01 17:00:05 UTC (rev 12073)
+++ projects/haf/trunk/hildon-plugins-settings/data/Makefile.am	2007-06-01 20:37:34 UTC (rev 12074)
@@ -0,0 +1,2 @@
+desktopentry_DATA = hildon-plugins-settings.desktop
+

Added: projects/haf/trunk/hildon-plugins-settings/data/hildon-plugins-settings.desktop.in
===================================================================
--- projects/haf/trunk/hildon-plugins-settings/data/hildon-plugins-settings.desktop.in	2007-06-01 17:00:05 UTC (rev 12073)
+++ projects/haf/trunk/hildon-plugins-settings/data/hildon-plugins-settings.desktop.in	2007-06-01 20:37:34 UTC (rev 12074)
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Name=tncpa_ap_task_navigator
+Comment=Panel Plugins Settins
+Type=HildonControlPanelPlugin
+Icon=qgn_list_cp_tana
+Categories=personalisation
+X-control-panel-plugin=libhildonpluginsettings.so

Modified: projects/haf/trunk/hildon-plugins-settings/src/Makefile.am
===================================================================
--- projects/haf/trunk/hildon-plugins-settings/src/Makefile.am	2007-06-01 17:00:05 UTC (rev 12073)
+++ projects/haf/trunk/hildon-plugins-settings/src/Makefile.am	2007-06-01 20:37:34 UTC (rev 12074)
@@ -12,7 +12,6 @@
 
 LDFLAGS = -module -avoid-version
 
-desktopentry_DATA = hildon-plugins-settings.desktop
 
 pluginlib_LTLIBRARIES = libhildonpluginsettings.la
 

Modified: projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-config-parser.c
===================================================================
--- projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-config-parser.c	2007-06-01 17:00:05 UTC (rev 12073)
+++ projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-config-parser.c	2007-06-01 20:37:34 UTC (rev 12074)
@@ -28,11 +28,15 @@
 #include <gtk/gtk.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
+#include <glib/gi18n.h>
+
 #define HP_DESKTOP_GROUP "Desktop Entry"
+#define HP_PREDEFINED_COLS 3
 
 #define HILDON_PLUGIN_CONFIG_PARSER_GET_PRIVATE(object) \
 	                (G_TYPE_INSTANCE_GET_PRIVATE ((object), HILDON_PLUGIN_TYPE_CONFIG_PARSER, HildonPluginConfigParserPrivate))
 
+
 G_DEFINE_TYPE (HildonPluginConfigParser, hildon_plugin_config_parser, G_TYPE_OBJECT);
 
 typedef enum 
@@ -60,12 +64,15 @@
   
   gchar *path_to_read;
   gchar *path_to_save;
+
+  GtkIconTheme *icon_theme;
 };
 
 enum
 {
   HP_COL_DESKTOP_FILE,
-  HP_COL_CHECKBOX
+  HP_COL_CHECKBOX,
+  HP_COL_POSITION
 };  
 
 static void hildon_plugin_config_parser_get_property    (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
@@ -93,7 +100,9 @@
   parser->keys = g_hash_table_new_full (g_str_hash,
 		  			g_str_equal,
 					g_free,
-					NULL);
+					g_free);
+
+  parser->priv->icon_theme = gtk_icon_theme_get_default ();
 }
 
 static void 
@@ -187,21 +196,22 @@
 hildon_plugin_config_parser_finalize (GObject *object)
 {
   HildonPluginConfigParser *parser = HILDON_PLUGIN_CONFIG_PARSER (object);
-
+/*
   if (parser->tm)
     gtk_widget_destroy (GTK_WIDGET (parser->tm));
+*/
+  if (parser->priv->keys)
+    g_list_free (parser->priv->keys);
+ 
+  if (parser->priv->keys_types)
+    g_list_free (parser->priv->keys_types);
 
-  if (parser->keys)
-  {
-    /*g_list_foreach (parser->priv->keys,
-		    (GFunc)g_free,
-		    NULL);*/
+  g_hash_table_destroy (parser->keys);
 
-    g_list_free (parser->priv->keys);
-  }	  
-
   g_free (parser->priv->path_to_read);
   g_free (parser->priv->path_to_save); 
+
+  G_OBJECT_CLASS (hildon_plugin_config_parser_parent_class)->finalize (object);
 }	
 
 static GQuark
@@ -211,21 +221,18 @@
 }
 
 static GdkPixbuf *
-hildon_plugin_config_parser_get_icon (HildonPluginConfigParser *parser, const gchar *icon_name)
+hildon_plugin_config_parser_get_icon (HildonPluginConfigParser *parser, 
+				      const gchar *icon_name,
+				      gint icon_size)
 {
-  GtkIconTheme *icon_theme;
   GdkPixbuf *pixbuf = NULL;
   GError *error = NULL;
 
-  gint icon_size = 32; /* FIXME: NOOOOOOOO! */
-
   if (icon_name)
   {
-    icon_theme = gtk_icon_theme_get_default ();
-
     pixbuf = 
       gtk_icon_theme_load_icon 
-        (icon_theme,
+        (parser->priv->icon_theme,
          icon_name,
          icon_size,
          GTK_ICON_LOOKUP_NO_SVG, &error);
@@ -239,12 +246,12 @@
      g_error_free(error);
      error = NULL;
    }
-   else
-   {	   
-     g_warning("Error loading icon: no icon name\n");
-     pixbuf = NULL;
-   }
  }
+ else
+ {	   
+   g_warning("Error loading icon: no icon name\n");
+   pixbuf = NULL;
+ }
  
  return pixbuf;
 }
@@ -258,6 +265,7 @@
   GError *external_error = NULL;
   GtkTreeIter iter;
   GList *l;
+  gint *icon_sizes = NULL;
 
   if (!g_key_file_load_from_file 
         (keyfile,filename,G_KEY_FILE_NONE,&external_error))
@@ -274,111 +282,131 @@
   gtk_list_store_append (GTK_LIST_STORE (parser->tm), &iter);
   gtk_list_store_set (GTK_LIST_STORE (parser->tm), &iter,
 		      HP_COL_DESKTOP_FILE, filename,
-		      HP_COL_CHECKBOX, FALSE, -1);
+		      HP_COL_CHECKBOX, FALSE,
+		      HP_COL_POSITION,0,
+		      -1);
 
   for (l = parser->priv->keys; l != NULL; l = g_list_next (l))
   {
-    gchar *_string = NULL;
-    gint _integer;
-    gboolean _boolean;
-    GdkPixbuf *_pixbuf = NULL;
+     gchar *_string = NULL;
+     gint _integer;
+     gboolean _boolean;
+     GdkPixbuf *_pixbuf = NULL;
 
-    GType *type = 
-      (GType *)g_hash_table_lookup (parser->keys, (gchar *)l->data);
+     GType *type = 
+       (GType *)g_hash_table_lookup (parser->keys, (gchar *)l->data);
 
-    if (!type)
-      continue;
+     if (!type)
+       continue;
   
-    if (*type == G_TYPE_STRING)
-    {	    
-	_string = 
-	  g_key_file_get_string 
+     if (*type == G_TYPE_STRING)
+     {	    
+       _string = 
+	 g_key_file_get_locale_string 
            (keyfile,
             HP_DESKTOP_GROUP,
 	    (gchar *)l->data,
+	    NULL,
 	    &external_error);
         
-        if (!external_error)
-        {
-          gtk_list_store_set 
-            (GTK_LIST_STORE (parser->tm), &iter,
-	     hildon_plugin_config_parser_get_key_id (parser,(const gchar *)l->data)+2,
-	     _string,
-	    -1);g_debug ("String name %s id: %d",_string,hildon_plugin_config_parser_get_key_id (parser,(const gchar *)l->data)+2);
-        }
-	else
-          g_free (_string);
-   }
-   else
-   if (*type == G_TYPE_INT)
-   {	   
-        _integer = 
-          g_key_file_get_integer 
-           (keyfile,
-            HP_DESKTOP_GROUP,
-            (gchar *)l->data,
-	    &external_error);
-       
-	if (!external_error)
-        {
-          gtk_list_store_set 
-            (GTK_LIST_STORE (parser->tm), &iter,
-	     hildon_plugin_config_parser_get_key_id (parser,(const gchar *)l->data)+2,
-	     &_integer,
+       if (!external_error)
+       {
+         gtk_list_store_set 
+           (GTK_LIST_STORE (parser->tm), &iter,
+	    hildon_plugin_config_parser_get_key_id 
+	      (parser,(const gchar *)l->data)+HP_PREDEFINED_COLS,
+	    _(_string),
 	    -1);
-        } 
-   }
-   else
-   if (*type == G_TYPE_BOOLEAN)
-   {	   
-	_boolean = 
-          g_key_file_get_boolean
-           (keyfile,
-            HP_DESKTOP_GROUP,
-	    (gchar *)l->data,
-	    &external_error);
+       }
+       else
+         g_free (_string);
+    }
+    else
+    if (*type == G_TYPE_INT)
+    {	   
+      _integer = 
+        g_key_file_get_integer 
+          (keyfile,
+           HP_DESKTOP_GROUP,
+           (gchar *)l->data,
+	   &external_error);
        
-	if (!external_error)
-        {
-          gtk_list_store_set 
-            (GTK_LIST_STORE (parser->tm), &iter,
-	     hildon_plugin_config_parser_get_key_id (parser,(const gchar *)l->data)+2,
-	     &_boolean,
-	    -1);
-        } 
-   }
-   else
-   if (*type == GDK_TYPE_PIXBUF)
-   {
-   	_string =
-          g_key_file_get_string
-           (keyfile,
-            HP_DESKTOP_GROUP,
-            (gchar *)l->data,
-            &external_error);
+      if (!external_error)
+      {
+        gtk_list_store_set 
+          (GTK_LIST_STORE (parser->tm), &iter,
+	   hildon_plugin_config_parser_get_key_id 
+	     (parser,(const gchar *)l->data)+HP_PREDEFINED_COLS,
+	   &_integer,
+	   -1);
+      } 
+    }
+    else
+    if (*type == G_TYPE_BOOLEAN)
+    {	   
+      _boolean = 
+        g_key_file_get_boolean
+          (keyfile,
+           HP_DESKTOP_GROUP,
+	   (gchar *)l->data,
+	   &external_error);
+       
+      if (!external_error)
+      {
+        gtk_list_store_set 
+          (GTK_LIST_STORE (parser->tm), &iter,
+	   hildon_plugin_config_parser_get_key_id 
+	     (parser,(const gchar *)l->data)+HP_PREDEFINED_COLS,
+	   &_boolean,
+	   -1);
+      } 
+    }
+    else
+    if (*type == GDK_TYPE_PIXBUF)
+    {
+      _string =
+        g_key_file_get_string
+          (keyfile,
+           HP_DESKTOP_GROUP,
+           (gchar *)l->data,
+           &external_error);
+        
+      if (!external_error) 
+      {
+	gint icon_size;
 
+        icon_sizes = 
+          gtk_icon_theme_get_icon_sizes
+            (parser->priv->icon_theme, _string); 
+
+	if (icon_sizes)
+	  icon_size = (icon_sizes[0] > 0) ? icon_sizes[0] : 64;
+	else
+          icon_size = 64;		
+	      
+        _pixbuf = 
+  	  hildon_plugin_config_parser_get_icon (parser, _string, icon_size);
+
+	g_free (icon_sizes);
         
-	if (!external_error) 
+	if (!_pixbuf)
         {
-  	  _pixbuf = hildon_plugin_config_parser_get_icon (parser, _string);
+          g_free (_string);		  
+          continue;
+        }
 
-	  if (!_pixbuf)
-          {
-            g_free (_string);		  
-            continue;
-	  }
-
-          gtk_list_store_set 
-            (GTK_LIST_STORE (parser->tm), &iter,
-	     hildon_plugin_config_parser_get_key_id (parser,(const gchar *)l->data)+2,
-	     _pixbuf,
-	    -1);
-        }	
-	else
-	  g_free (_string);
-   } 
-   else 
-     g_warning ("OOOPS I couldn't guess type");
+        gtk_list_store_set 
+          (GTK_LIST_STORE (parser->tm), &iter,
+           hildon_plugin_config_parser_get_key_id 
+	     (parser,(const gchar *)l->data)+HP_PREDEFINED_COLS,
+           _pixbuf,
+	   -1);
+      }	
+      else
+        g_free (_string);
+    }  
+    else 
+      g_warning ("OOOPS I couldn't guess type");
    
     if (external_error)
     {
@@ -438,7 +466,7 @@
       *type = key_type;
 	    
       g_hash_table_insert (parser->keys,
-		      	   last_key,
+		      	   g_strdup (last_key),
 			   type);
 
       parser->priv->keys_types = 
@@ -484,10 +512,11 @@
   if (parser->tm)
     gtk_widget_destroy (GTK_WIDGET (parser->tm));
 
-  _keys = g_new0 (GType,parser->priv->n_keys+1);
+  _keys = g_new0 (GType,parser->priv->n_keys+HP_PREDEFINED_COLS);
 
   _keys [i++] = G_TYPE_STRING; /* Desktop file name */
   _keys [i++] = G_TYPE_BOOLEAN; /* Checkbox */
+  _keys [i++] = G_TYPE_INT; /* position */
 
   for (l = parser->priv->keys_types;
        l != NULL || i < parser->priv->n_keys;

Modified: projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings.c
===================================================================
--- projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings.c	2007-06-01 17:00:05 UTC (rev 12073)
+++ projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings.c	2007-06-01 20:37:34 UTC (rev 12074)
@@ -39,13 +39,20 @@
   GError *error = NULL;
   gint ret;
 
+  GtkCellRenderer   *renderer_pb   = gtk_cell_renderer_pixbuf_new();
   GtkCellRenderer   *renderer_text = gtk_cell_renderer_text_new();
   GtkTreeViewColumn *text_column;
+  GtkTreeViewColumn *pixbuf_column;
 
   GtkWidget *dialog = gtk_dialog_new ();
+
+  gtk_dialog_add_button (GTK_DIALOG (dialog),
+		  	 "Ok",
+			 GTK_RESPONSE_OK);
+  
   HildonPluginConfigParser *cp = 
     HILDON_PLUGIN_CONFIG_PARSER 
-      (hildon_plugin_config_parser_new ("/usr/share/applications/hildon-navigator","/tmp/hello.tmp"));
+      (hildon_plugin_config_parser_new ("/usr/share/applications/hildon-status-bar","/tmp/hello.tmp"));
 
   hildon_plugin_config_parser_set_keys (cp,
 		  			"Name", G_TYPE_STRING,
@@ -61,8 +68,13 @@
 
     text_column = 
       gtk_tree_view_column_new_with_attributes
-        (NULL, renderer_text, "text", 2, NULL);
+        (NULL, renderer_text, "text", 3, NULL);
 
+    pixbuf_column = 
+      gtk_tree_view_column_new_with_attributes
+        (NULL, renderer_pb,"pixbuf", 4, NULL);
+    
+    gtk_tree_view_append_column(GTK_TREE_VIEW (tw), pixbuf_column);
     gtk_tree_view_append_column(GTK_TREE_VIEW (tw), text_column);
 
     gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
@@ -75,7 +87,11 @@
   ret = gtk_dialog_run (GTK_DIALOG (dialog));
 
   if (ret == GTK_RESPONSE_OK)
+  {
+    g_object_unref (G_OBJECT (cp));	  
+    gtk_widget_destroy (dialog);
     return OSSO_OK;
+  }
     
   return OSSO_ERROR;  
 }


More information about the maemo-commits mailing list