fixed start only one copy of some themes
authortanya <tanyshk@gmail.com>
Tue, 14 Sep 2010 13:06:37 +0000 (16:06 +0300)
committertanya <tanyshk@gmail.com>
Tue, 14 Sep 2010 13:06:37 +0000 (16:06 +0300)
applet/data/external_themes/fifteen.xml
applet/src/livewp-config.c
applet/src/livewp-settings.c
applet/src/livewp-settings.h

index 9e71745..5a8e655 100644 (file)
@@ -6,4 +6,5 @@
  <icon_on>/usr/share/livewp/theme/Fifteen/icon.png</icon_on>       
  <icon_off>/usr/share/livewp/theme/Fifteen/icond.png</icon_off>       
  <view>-v</view>
+ <copies>1</copies>
 </theme>
index 2275a10..b84c644 100644 (file)
@@ -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;
+}
+
index f105b4d..b1be895 100644 (file)
@@ -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;
                     }
index e3ba33d..53798ba 100644 (file)
@@ -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);