Adding upstream version 0.5.6.
[debian/lxappearance.git] / src / utils.c
index 2ae5b46..bd13ab7 100644 (file)
@@ -118,7 +118,7 @@ static gboolean install_icon_theme_package(const char* package_path)
     GPid pid = -1;
     const char* user_icons_dir = icon_theme_dirs[0];
     char* tmp_dir = g_build_filename(user_icons_dir, "tmp.XXXXXX", NULL);
-    char* argv[]= {
+    const char* argv[]= {
         "tar",
         NULL,
         "-C",
@@ -141,11 +141,11 @@ static gboolean install_icon_theme_package(const char* package_path)
     else /* the file format is not supported */
         goto _out;
 
-    char* cmd = g_strjoinv(" ", argv);
+    char* cmd = g_strjoinv(" ", (char**)argv);
     g_debug("extract: %s", cmd);
     g_free(cmd);
 
-    if(g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, NULL))
+    if(g_spawn_async(NULL, (char**)argv, NULL, G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, NULL))
     {
         g_debug("pid = %d", pid);
         /* show progress UI for this pid */
@@ -163,8 +163,8 @@ static gboolean install_icon_theme_package(const char* package_path)
             dir = g_dir_open(tmp_dir, 0, NULL);
             if(dir)
             {
-                char* name;
-                while((name = (char*)g_dir_read_name(dir)) != NULL)
+                const char* name;
+                while((name = g_dir_read_name(dir)) != NULL)
                 {
                     char* index_theme = g_build_filename(tmp_dir, name, "index.theme", NULL);
                     gboolean is_theme = g_file_test(index_theme, G_FILE_TEST_EXISTS);
@@ -192,14 +192,13 @@ static gboolean install_icon_theme_package(const char* package_path)
                         g_free(theme_target);
                         g_free(theme_tmp);
                     }
-                    g_free(name);
                 }
                 g_dir_close(dir);
 
                 /* remove remaining files. FIXME: will this cause problems? */
-                name = g_strdup_printf("rm -rf '%s'", tmp_dir);
-                g_spawn_command_line_sync(name, NULL, NULL, NULL, NULL);
-                g_free(name);
+                cmd = g_strdup_printf("rm -rf '%s'", tmp_dir);
+                g_spawn_command_line_sync(cmd, NULL, NULL, NULL, NULL);
+                g_free(cmd);
             }
         }
     }
@@ -250,14 +249,14 @@ g_debug("tmp_dir = %s", tmp_dir);
         char* tmp_dest = g_build_filename(tmp_dir, theme->name, NULL);
         if(g_rename(dir, tmp_dest) == 0)
         {
-            char* argv[] = {
+            const char* argv[] = {
                 "rm",
                 "-rf",
                 tmp_dir,
                 NULL
             };
             GPid pid;
-            if(g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, NULL))
+            if(g_spawn_async(NULL, (char**)argv, NULL, G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, NULL))
             {
                 ret = show_progress_for_pid(GTK_WINDOW(app.dlg), "Remove icon theme", "Removing...", pid);
             }