themes = g_list_sort(themes, (GCompareFunc) strcasecmp);
+ gtk_list_store_clear(theme_store);
+
/* return to regular scheduled programming */
i = 0;
for (it = themes; it; it = next) {
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_view_scroll_to_cell(GTK_TREE_VIEW(w), path, NULL,
+ FALSE, 0, 0);
}
gtk_widget_destroy(d);
if (path != NULL) {
- gchar *name;
-
- if ((name = theme_install(path))) {
- GtkWidget *w;
- GtkTreePath *path;
- 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) {
- path = gtk_tree_path_new_from_indices(i, -1);
- gtk_tree_view_set_cursor(GTK_TREE_VIEW(w), path, NULL, FALSE);
- }
-
- g_free(name);
- }
+ handlers_install_theme(path);
g_free(path);
}
}
g_free(path);
}
}
+
+void handlers_install_theme(gchar *path)
+{
+ gchar *name;
+
+ if ((name = theme_install(path))) {
+ GtkWidget *w;
+ GtkTreePath *path;
+ 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) {
+ path = gtk_tree_path_new_from_indices(i, -1);
+ gtk_tree_view_set_cursor(GTK_TREE_VIEW(w), path, NULL, FALSE);
+ gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(w), path, NULL,
+ FALSE, 0, 0);
+ }
+
+ g_free(name);
+ }
+}
void setup_desktop_num(GtkWidget *w);
void setup_desktop_names(GtkWidget *w);
+void handlers_install_theme(gchar *path);
+
#endif
#include "main.h"
#include "handlers.h"
+#include "theme.h"
+#include "gettext.h"
#include <gdk/gdkx.h>
#define SN_API_NOT_YET_FROZEN
#include <libsn/sn.h>
#undef SN_API_NOT_YET_FROZEN
-GtkWidget *mainwin;
+GtkWidget *mainwin = NULL;
GladeXML *glade;
xmlDocPtr doc;
xmlNodePtr root;
+static gchar *obc_theme_install = NULL;
+static gchar *obc_theme_archive = NULL;
+
void obconf_error(gchar *msg)
{
GtkWidget *d;
gtk_widget_show(d);
}
+static void parse_args(int argc, char **argv)
+{
+ int i;
+
+ for (i = 1; i < argc; ++i) {
+ if (!strcmp(argv[i], "--install")) {
+ if (i == argc - 1) /* no args left */
+ g_printerr(_("--install requires an argument\n"));
+ else
+ obc_theme_install = argv[++i];
+ }
+ else if (!strcmp(argv[i], "--archive")) {
+ if (i == argc - 1) /* no args left */
+ g_printerr(_("--archive requires an argument\n"));
+ else
+ obc_theme_archive = argv[++i];
+ }
+ }
+}
+
int main(int argc, char **argv)
{
SnDisplay *sn_d;
SnLauncheeContext *sn_cx;
gchar *p;
- parse_paths_startup();
-
gtk_init(&argc, &argv);
+ parse_args(argc, argv);
+
+ if (obc_theme_archive) {
+ theme_archive(obc_theme_archive);
+ return;
+ }
+
+ parse_paths_startup();
p = g_build_filename(GLADEDIR, "obconf.glade", NULL);
glade = glade_xml_new(p, NULL, NULL);
sn_launchee_context_unref(sn_cx);
sn_display_unref(sn_d);
+ if (obc_theme_install)
+ handlers_install_theme(obc_theme_install);
+
gtk_main();
parse_paths_shutdown();
gchar* theme_install(gchar *path)
{
gchar *dest;
- gchar *curdir;
gchar *name;
if (!(dest = get_theme_dir()))
return NULL;
- curdir = g_get_current_dir();
- if (!change_dir(dest)) {
- g_free(curdir);
- return NULL;
- }
-
if (!(name = name_from_file(path)))
return NULL;
g_free(dest);
- change_dir(curdir);
- g_free(curdir);
-
return name;
}
TAR *t;
gchar *glob;
gint r;
+ gchar *curdir;
if (tar_open(&t, file, &funcs, O_RDONLY, 0666, TAR_GNU) == -1) {
gtk_msg(GTK_MESSAGE_ERROR,
return FALSE;
}
+ curdir = g_get_current_dir();
+ if (!change_dir(to)) {
+ g_free(curdir);
+ tar_close(t);
+ return FALSE;
+ }
+
glob = g_strdup_printf("%s/openbox-3/*", theme);
- r = tar_extract_glob(t, glob, to);
+ r = tar_extract_glob(t, glob, ".");
g_free(glob);
+ change_dir(curdir);
+
+ g_free(curdir);
tar_close(t);
if (r != 0)