cleanups
authorDana Jansens <danakj@orodu.net>
Thu, 31 May 2007 06:58:28 +0000 (06:58 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 31 May 2007 06:58:28 +0000 (06:58 +0000)
make obconf <file> work for relative paths

src/archive.c
src/main.c
src/theme.c
src/theme.h

index 04ea3e58e1bfe2e8b603691069cd42f9fa91418b..6430f40827da918ec594ca86b366ba4479d38a5e 100644 (file)
@@ -91,15 +91,17 @@ static gboolean create_theme_archive(const gchar *dir, const gchar *name,
 
     parentdir = g_build_path(G_DIR_SEPARATOR_S, dir, "..", NULL);
 
-    argv = g_new(gchar*, 7);
+    argv = g_new(gchar*, 9);
     argv[0] = g_strdup("tar");
     argv[1] = g_strdup("-c");
     argv[2] = g_strdup("-z");
     argv[3] = g_strdup("-f");
     argv[4] = g_strdup(to);
-    argv[5] = g_strdup(glob);
-    argv[6] = NULL;
-    if (g_spawn_sync(parentdir, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
+    argv[5] = g_strdup("-C");
+    argv[6] = g_strdup(parentdir);
+    argv[7] = g_strdup(glob);
+    argv[8] = NULL;
+    if (g_spawn_sync(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
                      NULL, &errtxt, &exitcode, &e))
     {
         if (exitcode != EXIT_SUCCESS)
@@ -202,15 +204,17 @@ static gboolean install_theme_to(const gchar *name, const gchar *file,
 
     glob = g_strdup_printf("%s/openbox-3/", name);
 
-    argv = g_new(gchar*, 7);
+    argv = g_new(gchar*, 9);
     argv[0] = g_strdup("tar");
     argv[1] = g_strdup("-x");
     argv[2] = g_strdup("-z");
     argv[3] = g_strdup("-f");
     argv[4] = g_strdup(file);
-    argv[5] = g_strdup(glob);
-    argv[6] = NULL;
-    if (!g_spawn_sync(to, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
+    argv[5] = g_strdup("-C");
+    argv[6] = g_strdup(to);
+    argv[7] = g_strdup(glob);
+    argv[8] = NULL;
+    if (!g_spawn_sync(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
                       NULL, &errtxt, &exitcode, &e))
         gtk_msg(GTK_MESSAGE_ERROR, _("Unable to run the \"tar\" command: %s"),
                 e->message);
index a3243eb298268f7c662ed54aa35627286abd9b6b..31d72d82423703ae84e4850c46bfe03e241793f5 100644 (file)
@@ -174,6 +174,7 @@ int main(int argc, char **argv)
 
     if (obc_theme_install)
         theme_install(obc_theme_install);
+    theme_load_all();
 
     /* the main window is not shown here ! it is shown when the theme previews
        are completed */
index 08a190a29c167d8ee60c1d8748df9903867f6d4e..9ffc607b675a43eb59356d2d9e8c7372784db874 100644 (file)
@@ -31,7 +31,6 @@ static GList *themes;
 static GtkListStore *theme_store;
 
 static void add_theme_dir(const gchar *dirname);
-static void reset_theme_names(GtkWidget *w);
 static void on_theme_names_selection_changed(GtkTreeSelection *sel,
                                              gpointer data);
 
@@ -75,8 +74,6 @@ void theme_setup_tab()
                       G_CALLBACK(on_theme_names_selection_changed),
                       NULL);
 
-    reset_theme_names(w);
-
     mapping = FALSE;
 }
 
@@ -159,46 +156,24 @@ void theme_install(const gchar *path)
 {
     gchar *name;
 
-    if ((name = archive_install(path))) {
-        GtkWidget *w;
-        GList *it;
-        gint i;
-
-        w = glade_xml_get_widget(glade, "theme_names");
-        mapping = TRUE;
-        reset_theme_names(w);
-        mapping = FALSE;
-
-        /* go to the newly installed theme */
-        for (it = themes, i = 0; it; it = g_list_next(it), ++i)
-            if (!strcmp(it->data, name)) break;
-        if (it) {
-            GtkTreePath *path;
-
-            path = gtk_tree_path_new_from_indices(i, -1);
-            gtk_tree_view_set_cursor(GTK_TREE_VIEW(w), path, NULL, FALSE);
-            gtk_tree_path_free(path);
-        }
-
-        g_free(name);
-    }
+    if ((name = archive_install(path)))
+        tree_set_string("theme/name", name);
+    g_free(name);
 }
 
-
-
-
-
-
-static void reset_theme_names(GtkWidget *w)
+void theme_load_all()
 {
     gchar *name;
     gchar *p;
     GList *it, *next;
     gint i;
+    GtkWidget *w;
     GtkTreePath *path = NULL;
-
     RrFont *active, *inactive, *menu_t, *menu_i, *osd;
 
+    mapping = TRUE;
+
+    w = get_widget("theme_names");
     name = tree_get_string("theme/name", "TheBear");
 
     for (it = themes; it; it = g_list_next(it))
@@ -260,6 +235,8 @@ static void reset_theme_names(GtkWidget *w)
     }
 
     g_free(name);
+
+    mapping = FALSE;
 }
 
 static void add_theme_dir(const gchar *dirname)
index 4acc72c3eeb83494c6be6e922532c948207c8c32..9d75af32fad7056e408a62b5e2d5c981b837e3d2 100644 (file)
@@ -24,6 +24,7 @@
 
 void theme_setup_tab();
 
+void theme_load_all();
 void theme_install(const gchar *path);
 
 #endif