From 3a8f86fca5620d3a3e2501690ea92d0e3d702d17 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 31 May 2007 06:58:28 +0000 Subject: [PATCH] cleanups make obconf work for relative paths --- src/archive.c | 20 ++++++++++++-------- src/main.c | 1 + src/theme.c | 43 ++++++++++--------------------------------- src/theme.h | 1 + 4 files changed, 24 insertions(+), 41 deletions(-) diff --git a/src/archive.c b/src/archive.c index 04ea3e5..6430f40 100644 --- a/src/archive.c +++ b/src/archive.c @@ -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); diff --git a/src/main.c b/src/main.c index a3243eb..31d72d8 100644 --- a/src/main.c +++ b/src/main.c @@ -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 */ diff --git a/src/theme.c b/src/theme.c index 08a190a..9ffc607 100644 --- a/src/theme.c +++ b/src/theme.c @@ -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) diff --git a/src/theme.h b/src/theme.h index 4acc72c..9d75af3 100644 --- a/src/theme.h +++ b/src/theme.h @@ -24,6 +24,7 @@ void theme_setup_tab(); +void theme_load_all(); void theme_install(const gchar *path); #endif -- 2.39.2