From 11900dab7f647802d2061598c57649c1dcfb886e Mon Sep 17 00:00:00 2001 From: tanya Date: Tue, 14 Sep 2010 16:06:37 +0300 Subject: [PATCH] fixed start only one copy of some themes --- applet/data/external_themes/fifteen.xml | 1 + applet/src/livewp-config.c | 30 ++++++++++++++++++++++++++++++ applet/src/livewp-settings.c | 20 +++++++++++++++++++- applet/src/livewp-settings.h | 1 + 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/applet/data/external_themes/fifteen.xml b/applet/data/external_themes/fifteen.xml index 9e71745..5a8e655 100644 --- a/applet/data/external_themes/fifteen.xml +++ b/applet/data/external_themes/fifteen.xml @@ -6,4 +6,5 @@ /usr/share/livewp/theme/Fifteen/icon.png /usr/share/livewp/theme/Fifteen/icond.png -v + 1 diff --git a/applet/src/livewp-config.c b/applet/src/livewp-config.c index 2275a10..b84c644 100644 --- a/applet/src/livewp-config.c +++ b/applet/src/livewp-config.c @@ -243,3 +243,33 @@ save_config(Animation_WallpaperPrivate *priv) { } } } +/*******************************************************************************/ +gint +get_count_themes_from_config(gchar *theme_name){ + GConfClient *gconf_client; + gint i, count; + gchar *str, *value; + + gconf_client = gconf_client_get_default(); + if (!gconf_client) { + fprintf(stderr, _("Failed to initialize GConf. Quitting.\n")); + return FALSE; + } + /* get count such themes */ + count = 0; + for (i=1; i<=9; i++){ + str = g_strdup_printf("%s%i", GCONF_KEY_THEME, i); + value = gconf_client_get_string(gconf_client, str, NULL); + if (str){ + g_free(str); + str = NULL; + } + if (value && !strcmp(value, theme_name)){ + count++; + } + + } + //fprintf(stderr, "get count_theme from config = %d\n", count); + return count; +} + diff --git a/applet/src/livewp-settings.c b/applet/src/livewp-settings.c index f105b4d..b1be895 100644 --- a/applet/src/livewp-settings.c +++ b/applet/src/livewp-settings.c @@ -644,6 +644,15 @@ show_problem_package (GtkWidget *widget, gchar *package_name){ g_free(text); } /*******************************************************************************/ +void +show_duplicate_theme (GtkWidget *widget, gchar *theme_name){ + gchar *text; + text = g_strdup_printf(_("Theme %s has already been selected"), theme_name); + hildon_banner_show_information(GTK_WIDGET(widget), NULL, text); + g_free(text); +} + +/*******************************************************************************/ void lw_theme_settings(GtkWidget *button, Animation_WallpaperPrivate *priv) { gint result; @@ -659,6 +668,7 @@ lw_theme_settings(GtkWidget *button, Animation_WallpaperPrivate *priv) { GtkWidget *button1 = NULL; GtkWidget *rich_animation_button = NULL; gint view = priv->view; + gint count; window = gtk_dialog_new(); priv->window = window; @@ -800,7 +810,15 @@ lw_theme_settings(GtkWidget *button, Animation_WallpaperPrivate *priv) { GSList *store = priv->extheme_list; 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")); + gchar *copies = g_hash_table_lookup(store->data, "copies"); + //fprintf(stderr, "copies = %s\n", copies); + if (copies){ + count = atoi(copies); + }else count = 10; + if (count > get_count_themes_from_config(g_hash_table_lookup(store->data, "name"))) + priv->theme = g_strdup(g_hash_table_lookup(store->data, "name")); + else + show_duplicate_theme(button, g_hash_table_lookup(store->data, "name")); //priv->hash_theme = store->data; break; } diff --git a/applet/src/livewp-settings.h b/applet/src/livewp-settings.h index e3ba33d..53798ba 100644 --- a/applet/src/livewp-settings.h +++ b/applet/src/livewp-settings.h @@ -44,6 +44,7 @@ void rich_animation_additional_parametr(GtkWidget *vbox, Animation_WallpaperPriv void additional_parametr_for_theme_video(GtkWidget *vbox, Animation_WallpaperPrivate *priv); GSList * get_list_exthemes(void); void show_problem_package (GtkWidget *widget, gchar *package_name); +void show_duplicate_theme (GtkWidget *widget, gchar *theme_name); void changed_value_one_in_all_cb (GtkWidget *toggle, Animation_WallpaperPrivate *priv); void save_one_in_all_views_to_config(gboolean one_in_all_views); gboolean cb_timeout_settings(GtkWidget *window); -- 1.7.9.5