1 #include "preview_update.h"
4 static gboolean restart_theme_preview_update = TRUE;
6 static GtkTreeView *tree_view = NULL;
7 static GtkListStore *list_store = NULL;
8 static gchar *title_layout = NULL;
9 static RrFont *active_window_font = NULL;
10 static RrFont *inactive_window_font = NULL;
11 static RrFont *menu_title_font = NULL;
12 static RrFont *menu_item_font = NULL;
13 static RrFont *osd_font = NULL;
15 static gboolean update_theme_preview_iterate(gpointer data);
17 void preview_update_all()
19 if (!list_store) return;
21 g_idle_remove_by_data(list_store);
23 if (!(title_layout && active_window_font && inactive_window_font &&
24 menu_title_font && menu_item_font && osd_font))
25 return; /* not set up */
27 restart_theme_preview_update = TRUE;
28 g_idle_add_full(G_PRIORITY_LOW,
29 update_theme_preview_iterate,
33 void preview_update_set_tree_view(GtkTreeView *tr, GtkListStore *ls)
35 g_assert(!!tr == !!ls);
37 if (list_store) g_idle_remove_by_data(list_store);
42 if (list_store) preview_update_all();
45 void preview_update_set_active_font(RrFont *f)
47 RrFontClose(active_window_font);
48 active_window_font = f;
52 void preview_update_set_inactive_font(RrFont *f)
54 RrFontClose(inactive_window_font);
55 inactive_window_font = f;
59 void preview_update_set_menu_header_font(RrFont *f)
61 RrFontClose(menu_title_font);
66 void preview_update_set_menu_item_font(RrFont *f)
68 RrFontClose(menu_item_font);
73 void preview_update_set_osd_font(RrFont *f)
75 RrFontClose(osd_font);
80 void preview_update_set_title_layout(const gchar *layout)
83 title_layout = g_strdup(layout);
87 static gboolean update_theme_preview_iterate(gpointer data)
89 GtkListStore *ls = data;
90 static GtkTreeIter iter;
93 if (restart_theme_preview_update) {
94 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ls), &iter)) {
99 restart_theme_preview_update = FALSE;
101 if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(ls), &iter)) {
104 restart_theme_preview_update = TRUE;
106 gtk_tree_view_get_cursor(tree_view, &path, NULL);
108 gtk_tree_view_scroll_to_cell(tree_view, path, NULL,
110 gtk_tree_path_free(path);
119 gtk_tree_model_get(GTK_TREE_MODEL(ls), &iter, 0, &name, -1);
121 gtk_list_store_set(GTK_LIST_STORE(ls), &iter, 1,
122 preview_theme(name, title_layout, active_window_font,
123 inactive_window_font, menu_title_font,
124 menu_item_font, osd_font),