Only allow editing of desktop bookmarks.
authorSalvatore Iovene <salvatore@iovene.com>
Sun, 13 Dec 2009 12:37:08 +0000 (14:37 +0200)
committerSalvatore Iovene <salvatore@iovene.com>
Sun, 13 Dec 2009 12:37:08 +0000 (14:37 +0200)
modules/tweakr-desktop.c

index e66b296..fd6b27a 100644 (file)
@@ -34,6 +34,8 @@
         TWEAKR_TYPE_DESKTOP_SECTION))
 
 #define GCONF_BOOKMARKS "/apps/osso/hildon-home/bookmarks"
+#define GCONF_APPLETS   "/apps/osso/hildon-desktop/applets"
+
 enum
 {
     SNAP_NONE,
@@ -255,35 +257,51 @@ _add_bookmark (gchar *bookmark, TweakrDesktopSection *section)
     gchar *title, *value, *url;
     GtkWidget *button;
 
+    gchar *bookmark_name;
+    gchar *applet_path;
+
     b = g_new0 (bookmark_t, 1);
     b->path = g_strconcat (bookmark, "/label", NULL);
 
     url   = g_strconcat (bookmark, "/url",   NULL);
     title = gconf_client_get_string (section->gconf, b->path, NULL);
-    value = gconf_client_get_string (section->gconf, url,   NULL);
+    value = gconf_client_get_string (section->gconf, url,     NULL);
 
     g_free (url);
 
-    button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT,
-                                          HILDON_BUTTON_ARRANGEMENT_VERTICAL,
-                                          title, value);
-    gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
-    gtk_box_pack_start (GTK_BOX (section->bookmarks_box), button,
-                        FALSE, FALSE, 0);
+    bookmark_name = g_path_get_basename (bookmark);
+    applet_path = g_strconcat (GCONF_APPLETS, "/BookmarkShortcut:",
+                               bookmark_name, NULL);
+    if (applet_path &&
+        gconf_client_dir_exists (section->gconf, applet_path, NULL))
+    {
+        button = hildon_button_new_with_text
+            (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL,
+             title, value);
+        gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
+        gtk_box_pack_start (GTK_BOX (section->bookmarks_box), button,
+                            FALSE, FALSE, 0);
 
-    g_signal_connect (button, "clicked", G_CALLBACK (_bookmark_clicked),
-                                          section);
+        g_signal_connect (button, "clicked", G_CALLBACK (_bookmark_clicked),
+                                              section);
 
-    if (section->bookmarks_table == NULL)
+        if (section->bookmarks_table == NULL)
+        {
+            section->bookmarks_table = g_hash_table_new_full
+                (g_direct_hash, g_direct_equal, NULL,
+                 (GDestroyNotify) _bookmark_t_destroy);
+        }
+        g_hash_table_insert (section->bookmarks_table, button, b);
+    }
+    else
     {
-        section->bookmarks_table = g_hash_table_new_full
-            (g_direct_hash, g_direct_equal, NULL,
-             (GDestroyNotify) _bookmark_t_destroy);
+        _bookmark_t_destroy (b);
     }
-    g_hash_table_insert (section->bookmarks_table, button, b);
 
     g_free (title);
     g_free (value);
+    g_free (bookmark_name);
+    g_free (applet_path);
 }
 
 static void