fixed gcc warnings
[livewp] / applet / src / livewp-settings.c
index e5c3b37..5a515e9 100644 (file)
@@ -101,7 +101,7 @@ create_rich_animation_button (gboolean active)
     GtkWidget *button;
     button = hildon_check_button_new (HILDON_SIZE_AUTO);
     gtk_button_set_label (GTK_BUTTON (button), _("Rich Animation"));
-    hildon_check_button_set_active(button, active);
+    hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active);
     return button;
 }
 /*******************************************************************************/
@@ -111,7 +111,7 @@ create_enable_button (gboolean active)
     GtkWidget *button;
     button = hildon_check_button_new (HILDON_SIZE_AUTO);
     gtk_button_set_label (GTK_BUTTON (button), _("Enable"));
-    hildon_check_button_set_active(button, active);
+    hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active);
     return button;
 }
 
@@ -157,6 +157,7 @@ lw_settings(Animation_WallpaperPrivate *priv, gpointer data){
 
     switch(result){
         case GTK_RESPONSE_YES:
+            /* Check theme */
             if (hildon_button_get_value(HILDON_BUTTON (theme_button))){
                 if (priv->theme)
                     g_free(priv->theme);
@@ -166,23 +167,28 @@ lw_settings(Animation_WallpaperPrivate *priv, gpointer data){
                     priv->theme = g_strdup("Modern");
                 if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Matrix")))
                     priv->theme = g_strdup("Matrix");
-                if (hildon_check_button_get_active (rich_animation_button))
-                    priv->rich_animation = TRUE;
-                else
-                    priv->rich_animation = FALSE;
-                if (hildon_check_button_get_active (enable_button)){
-                    if (!check_applet_state())
-                        start_applet();
-                }else
-                    if (check_applet_state())
-                        stop_applet();
             }
+            /* Check rich animation */
+            if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(rich_animation_button)))
+                priv->rich_animation = TRUE;
+            else
+                priv->rich_animation = FALSE;
+            /* Save config */
             save_config(priv);
-            send_dbus_signal (priv,
+            /* action with applet */
+            if (hildon_check_button_get_active (HILDON_CHECK_BUTTON(enable_button))){
+                    if (!check_applet_state())
+                        start_applet();
+                    else
+                        send_dbus_signal (priv,
                               LIVEWP_SIGNAL_INTERFACE,
                               LIVEWP_SIGNAL_PATH,
                               LIVEWP_RELOAD_CONFIG);
-        break;
+            }else
+                    if (check_applet_state())
+                        stop_applet();
+
+            break;
         default:
         case GTK_RESPONSE_OK:
         break;
@@ -199,7 +205,6 @@ lw_settings(Animation_WallpaperPrivate *priv, gpointer data){
 gboolean
 check_applet_state(void){
     FILE    *file_in;
-    FILE    *file_out;
     gchar buffer[2048];
     gboolean result = FALSE;
 
@@ -207,8 +212,8 @@ check_applet_state(void){
     while (!feof(file_in)) {
             memset(buffer, 0, sizeof(buffer));
             fgets(buffer, sizeof(buffer) - 1, file_in);
-            if (buffer &&
-                !strcmp(buffer, "X-Desktop-File=/usr/share/applications/hildon-home/livewp-home-widget.desktop\n")){
+            if (!strcmp(buffer, 
+                        "X-Desktop-File=/usr/share/applications/hildon-home/livewp-home-widget.desktop\n")){
                 result = TRUE;
                 break;
             }
@@ -218,10 +223,10 @@ check_applet_state(void){
     return result;
 }
 /*******************************************************************************/
+void
 start_applet(void){
-    FILE    *file_in;
     FILE    *file_out;
-    gchar buffer[2048];
+
     file_out = fopen("/home/user/.config/hildon-desktop/home.plugins","w+");
     if (file_out){
         fputs("\n", file_out);
@@ -231,6 +236,7 @@ start_applet(void){
     }
 }
 /*******************************************************************************/
+void
 stop_applet(void){
     FILE    *file_in;
     FILE    *file_out;
@@ -242,7 +248,7 @@ stop_applet(void){
         while (!feof(file_in)) {
             memset(buffer, 0, sizeof(buffer));
             fgets(buffer, sizeof(buffer) - 1, file_in);
-            if (buffer && strcmp(buffer, "[livewp-home-widget.desktop-0]\n") &&
+            if (strcmp(buffer, "[livewp-home-widget.desktop-0]\n") &&
                 strcmp(buffer, "X-Desktop-File=/usr/share/applications/hildon-home/livewp-home-widget.desktop\n"))
                 fputs(buffer, file_out);
         }