From ced59d817dfb545a7219326ecc28fed5667235d5 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 31 May 2007 06:34:39 +0000 Subject: [PATCH] don't show the main window until the theme previews are done. scroll to the current theme whenever theme previews are re-done. --- src/appearance.c | 10 ++++++++++ src/main.c | 5 ++--- src/obconf.glade | 14 ++++++-------- src/preview_update.c | 23 ++++++++++++++++++++--- src/preview_update.h | 2 +- src/strings.c | 3 +-- src/theme.c | 24 +++++++++++++----------- 7 files changed, 53 insertions(+), 28 deletions(-) diff --git a/src/appearance.c b/src/appearance.c index 6d28228..61d2228 100644 --- a/src/appearance.c +++ b/src/appearance.c @@ -145,26 +145,36 @@ void on_title_layout_changed(GtkEntry *w, gpointer data) void on_font_active_font_set(GtkFontButton *w, gpointer data) { + if (mapping) return; + preview_update_set_active_font(write_font(w, "ActiveWindow")); } void on_font_inactive_font_set(GtkFontButton *w, gpointer data) { + if (mapping) return; + preview_update_set_inactive_font(write_font(w, "InactiveWindow")); } void on_font_menu_header_font_set(GtkFontButton *w, gpointer data) { + if (mapping) return; + preview_update_set_menu_header_font(write_font(w, "MenuHeader")); } void on_font_menu_item_font_set(GtkFontButton *w, gpointer data) { + if (mapping) return; + preview_update_set_menu_item_font(write_font(w, "MenuItem")); } void on_font_display_font_set(GtkFontButton *w, gpointer data) { + if (mapping) return; + preview_update_set_osd_font(write_font(w, "OnScreenDisplay")); } diff --git a/src/main.c b/src/main.c index f038a1b..5302c72 100644 --- a/src/main.c +++ b/src/main.c @@ -197,8 +197,6 @@ int main(int argc, char **argv) sn_launchee_context_setup_window (sn_cx, GDK_WINDOW_XWINDOW(GDK_WINDOW(mainwin->window))); - gtk_widget_show_all(mainwin); - if (sn_cx) sn_launchee_context_complete(sn_cx); @@ -209,9 +207,10 @@ int main(int argc, char **argv) if (obc_theme_install) theme_install(obc_theme_install); + /* the main window is not shown here ! it is shown when the theme previews + are completed */ gtk_main(); - preview_update_set_list_store(NULL); preview_update_set_active_font(NULL); preview_update_set_inactive_font(NULL); preview_update_set_menu_header_font(NULL); diff --git a/src/obconf.glade b/src/obconf.glade index 5e22772..f0c1ca2 100644 --- a/src/obconf.glade +++ b/src/obconf.glade @@ -5,7 +5,6 @@ 13 - True Openbox Configuration Manager GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE @@ -711,7 +710,7 @@ C - The close button True True True - True + False False True @@ -732,7 +731,7 @@ C - The close button True True True - True + False False True @@ -753,7 +752,7 @@ C - The close button True True True - True + False False True @@ -774,7 +773,7 @@ C - The close button True True True - True + False False True @@ -940,7 +939,7 @@ C - The close button True True True - True + False False True @@ -2981,8 +2980,7 @@ C - The close button True Copyright (c) 2003-2007 Dana Jansens <danakj@orodu.net> -Tim Riley <tr@slackzone.org> -Javeed Shaikh <syscrash2k@gmail.com> +Tim Riley <tr@slackzone.org> False False GTK_JUSTIFY_CENTER diff --git a/src/preview_update.c b/src/preview_update.c index 64a5fec..bc45f07 100644 --- a/src/preview_update.c +++ b/src/preview_update.c @@ -1,7 +1,9 @@ #include "preview_update.h" +#include "main.h" static gboolean restart_theme_preview_update = TRUE; +static GtkTreeView *tree_view = NULL; static GtkListStore *list_store = NULL; static gchar *title_layout = NULL; static RrFont *active_window_font = NULL; @@ -28,10 +30,13 @@ void preview_update_all() list_store, NULL); } -void preview_update_set_list_store(GtkListStore *ls) +void preview_update_set_tree_view(GtkTreeView *tr, GtkListStore *ls) { + g_assert(!!tr == !!ls); + if (list_store) g_idle_remove_by_data(list_store); + tree_view = tr; list_store = ls; if (list_store) preview_update_all(); @@ -87,12 +92,22 @@ static gboolean update_theme_preview_iterate(gpointer data) if (restart_theme_preview_update) { if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ls), &iter)) - return; + return FALSE; restart_theme_preview_update = FALSE; } else { if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(ls), &iter)) { + GtkTreePath *path; + restart_theme_preview_update = TRUE; - return; + + gtk_tree_view_get_cursor(tree_view, &path, NULL); + gtk_tree_view_scroll_to_cell(tree_view, path, NULL, + FALSE, 0, 0); + gtk_tree_path_free(path); + + gtk_widget_show_all(mainwin); + + return FALSE; } } @@ -103,4 +118,6 @@ static gboolean update_theme_preview_iterate(gpointer data) inactive_window_font, menu_title_font, menu_item_font, osd_font), -1); + + return TRUE; } diff --git a/src/preview_update.h b/src/preview_update.h index 6d5b788..1fe9674 100644 --- a/src/preview_update.h +++ b/src/preview_update.h @@ -6,7 +6,7 @@ void preview_update_all(); -void preview_update_set_list_store (GtkListStore *ls); +void preview_update_set_tree_view (GtkTreeView *tr, GtkListStore *ls); void preview_update_set_active_font (RrFont *f); void preview_update_set_inactive_font (RrFont *f); void preview_update_set_menu_header_font (RrFont *f); diff --git a/src/strings.c b/src/strings.c index 851bc7c..b9700e1 100644 --- a/src/strings.c +++ b/src/strings.c @@ -92,5 +92,4 @@ gchar *s = N_("ObConf VERSION"); gchar *s = N_("A preferences manager for Openbox"); gchar *s = N_("Copyright (c) 2003-2007\n" "Dana Jansens \n" - "Tim Riley \n" - "Javeed Shaikh "); + "Tim Riley "); diff --git a/src/theme.c b/src/theme.c index a6e297f..08a190a 100644 --- a/src/theme.c +++ b/src/theme.c @@ -23,6 +23,7 @@ #include "gettext.h" #include "archive.h" #include "theme.h" +#include "preview.h" static gboolean mapping = FALSE; @@ -48,7 +49,7 @@ void theme_setup_tab() /* widget setup */ theme_store = gtk_list_store_new(2, G_TYPE_STRING, GDK_TYPE_PIXBUF); gtk_tree_view_set_model(GTK_TREE_VIEW(w), GTK_TREE_MODEL(theme_store)); - preview_update_set_list_store(theme_store); + preview_update_set_tree_view(GTK_TREE_VIEW(w), theme_store); g_object_unref (theme_store); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(w)), @@ -160,7 +161,6 @@ void theme_install(const gchar *path) if ((name = archive_install(path))) { GtkWidget *w; - GtkTreePath *path; GList *it; gint i; @@ -173,10 +173,11 @@ void theme_install(const gchar *path) 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_view_scroll_to_cell(GTK_TREE_VIEW(w), path, NULL, - FALSE, 0, 0); + gtk_tree_path_free(path); } g_free(name); @@ -194,6 +195,7 @@ static void reset_theme_names(GtkWidget *w) gchar *p; GList *it, *next; gint i; + GtkTreePath *path = NULL; RrFont *active, *inactive, *menu_t, *menu_i, *osd; @@ -243,20 +245,20 @@ static void reset_theme_names(GtkWidget *w) 1, NULL, -1); - if(!strcmp(name, it->data)) { - GtkTreePath *path; + if(!strcmp(name, it->data)) 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); - } - ++i; } preview_update_all(); + /* do this after starting the preview update */ + if (path) { + gtk_tree_view_set_cursor(GTK_TREE_VIEW(w), path, NULL, FALSE); + gtk_tree_path_free(path); + } + g_free(name); } -- 2.39.2