From d9b18c2e3b0c62cb44c4e1ca08a5188cca4a53a7 Mon Sep 17 00:00:00 2001 From: tanya Date: Thu, 12 Aug 2010 15:31:47 +0300 Subject: [PATCH] added icons for external themes --- applet/data/Makefile.am | 4 ++++ applet/src/livewp-exthemes.c | 3 ++- applet/src/livewp-settings.c | 48 +++++++++++++++++++++++++++++++----------- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/applet/data/Makefile.am b/applet/data/Makefile.am index 47ebcbe..eb4e5fa 100644 --- a/applet/data/Makefile.am +++ b/applet/data/Makefile.am @@ -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) diff --git a/applet/src/livewp-exthemes.c b/applet/src/livewp-exthemes.c index 7be9cee..d489a29 100644 --- a/applet/src/livewp-exthemes.c +++ b/applet/src/livewp-exthemes.c @@ -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))); } diff --git a/applet/src/livewp-settings.c b/applet/src/livewp-settings.c index 1f9dc5a..c4ee4fa 100644 --- a/applet/src/livewp-settings.c +++ b/applet/src/livewp-settings.c @@ -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: -- 1.7.9.5