added icons for external themes
authortanya <tanyshk@gmail.com>
Thu, 12 Aug 2010 12:31:47 +0000 (15:31 +0300)
committertanya <tanyshk@gmail.com>
Thu, 12 Aug 2010 12:31:47 +0000 (15:31 +0300)
applet/data/Makefile.am
applet/src/livewp-exthemes.c
applet/src/livewp-settings.c

index 47ebcbe..eb4e5fa 100644 (file)
@@ -40,6 +40,9 @@ xsnowtheme_DATA = theme/Xsnow/*
 externalthemedir = $(datadir)/livewp/external_themes
 externaltheme_DATA = external_themes/* 
 
+externalicondir = $(datadir)/livewp/external_icons
+externalicon_DATA = external_icons/* 
+
 dbus_servicedir = $(datadir)/dbus-1/services
 dbus_service_DATA = org.maemo.livewp.service
 
@@ -75,6 +78,7 @@ EXTRA_DIST = $(berlintheme_DATA) \
             $(videotheme_DATA) \
             $(xshowtheme_DATA) \
             $(externaltheme_DATA) \
+            $(externalicon_DATA) \
             $(dbus_service_DATA)
 
 
index 7be9cee..d489a29 100644 (file)
@@ -39,7 +39,7 @@ parse_theme(gchar *file){
           //  child = 
         //}
         if (node->type == XML_ELEMENT_NODE){ 
-            fprintf(stderr, "%s => %s\n", node->name, xmlNodeGetContent(node));
+            //fprintf(stderr, "%s => %s\n", node->name, xmlNodeGetContent(node));
             g_hash_table_insert(hash, g_strdup(node->name), g_strdup(xmlNodeGetContent(node)));
         }
     }
@@ -61,6 +61,7 @@ get_list_exthemes(void){
             
             if(!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
                 continue;
+            /* TO DO read only *.xml files */
             if(dp->d_type == DT_REG || dp->d_type == DT_LNK){
                 store = g_slist_append(store, parse_theme(g_strdup_printf("%s%s", EXTHEME_PATH, dp->d_name)));
             }
index 1f9dc5a..c4ee4fa 100644 (file)
@@ -78,22 +78,45 @@ theme_button_clicked(GtkButton *button, Animation_WallpaperPrivate *priv){
 }
 /********************************************************************************/
 void
-set_button_image(GtkWidget * button, gchar *theme, gboolean enable){
+set_button_image(GtkWidget * button, Animation_WallpaperPrivate *priv, gboolean enable){
     GtkWidget * image = NULL; 
     GdkPixbuf * pixbuf = NULL;
     gchar *str = NULL;
-    if (enable)
-        str = g_strdup_printf( "%s/%s/%s", THEME_PATH, 
-                        theme, "icon.png");
-    else 
-        str = g_strdup_printf( "%s/%s/%s", THEME_PATH, 
-                        theme, "icond.png");
+    gchar *icon_on = NULL;
+    gchar *icon_off = NULL;
+    GSList *store = priv->extheme_list;
+    while (store){
+        if (!strcmp(priv->theme, g_hash_table_lookup(store->data, "name"))){
+            icon_on = g_strdup(g_hash_table_lookup(store->data, "icon_on"));
+            icon_off = g_strdup(g_hash_table_lookup(store->data, "icon_off"));
+            break;
+        }
+        store = g_list_next(store);
+    }
+    if (enable){
+        if (icon_on)
+            str = g_strdup_printf("%s", icon_on);
+        else 
+            str = g_strdup_printf( "%s/%s/%s", THEME_PATH, 
+                            priv->theme, "icon.png");
+    }else {
+        if (icon_off)
+            str = g_strdup_printf("%s", icon_off);
+        else
+            str = g_strdup_printf( "%s/%s/%s", THEME_PATH, 
+                            priv->theme, "icond.png");
+    }
+    fprintf(stderr, "icon = %s\n", str);
     pixbuf = gdk_pixbuf_new_from_file_at_size (str, 
-                                             100, 
-                                             60, 
-                                             NULL);
+                                                 100, 
+                                                 60, 
+                                                 NULL);
     if (str)
         g_free(str);
+    if (icon_on)
+        g_free(icon_on);
+    if (icon_off)
+        g_free(icon_off);
     if (pixbuf){
         image = gtk_image_new_from_pixbuf (pixbuf);
         g_object_unref(G_OBJECT(pixbuf));
@@ -118,7 +141,7 @@ create_image_button (gint view, DBusConnection *conn_sess){
                                     HILDON_BUTTON_ARRANGEMENT_VERTICAL);
     g_object_set_data(G_OBJECT(button), "view", GINT_TO_POINTER(view));
     g_object_set_data(G_OBJECT(button), "priv", priv);
-    set_button_image(button, priv->theme, check_applet_state(view));
+    set_button_image(button, priv, check_applet_state(view));
     g_signal_connect(button, "clicked", G_CALLBACK(theme_button_clicked), priv);
     hildon_button_set_image_position (HILDON_BUTTON (button), GTK_POS_RIGHT);
     return button;
@@ -462,6 +485,7 @@ lw_theme_settings(GtkWidget *button, Animation_WallpaperPrivate *priv) {
                 while (store){
                     if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _(g_hash_table_lookup(store->data, "name")))){
                         priv->theme = g_strdup(g_hash_table_lookup(store->data, "name"));
+                        //priv->hash_theme = store->data;
                         break;
                     }
                     store = g_slist_next(store);
@@ -493,7 +517,7 @@ lw_theme_settings(GtkWidget *button, Animation_WallpaperPrivate *priv) {
                     if (check_applet_state(view))
                         stop_applet(view);
 
-            set_button_image(button, priv->theme, check_applet_state(view));
+            set_button_image(button, priv, check_applet_state(view));
             break;
         default:
         case GTK_RESPONSE_OK: