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_active_font = NULL;
14 static RrFont *osd_inactive_font = NULL;
16 static gboolean update_theme_preview_iterate(gpointer data);
18 void preview_update_all()
20 if (!list_store) return;
21 if (!RR_CHECK_VERSION(3,5,0)) return;
23 g_idle_remove_by_data(list_store);
25 if (!(title_layout && active_window_font && inactive_window_font &&
26 menu_title_font && menu_item_font &&
27 osd_active_font && osd_inactive_font))
28 return; /* not set up */
30 restart_theme_preview_update = TRUE;
31 g_idle_add_full(G_PRIORITY_LOW,
32 update_theme_preview_iterate,
36 void preview_update_set_tree_view(GtkTreeView *tr, GtkListStore *ls)
38 g_assert(!!tr == !!ls);
40 if (list_store) g_idle_remove_by_data(list_store);
45 if (list_store) preview_update_all();
48 void preview_update_set_active_font(RrFont *f)
50 RrFontClose(active_window_font);
51 active_window_font = f;
55 void preview_update_set_inactive_font(RrFont *f)
57 RrFontClose(inactive_window_font);
58 inactive_window_font = f;
62 void preview_update_set_menu_header_font(RrFont *f)
64 RrFontClose(menu_title_font);
69 void preview_update_set_menu_item_font(RrFont *f)
71 RrFontClose(menu_item_font);
76 void preview_update_set_osd_active_font(RrFont *f)
78 RrFontClose(osd_active_font);
83 void preview_update_set_osd_inactive_font(RrFont *f)
85 RrFontClose(osd_inactive_font);
86 osd_inactive_font = f;
90 void preview_update_set_title_layout(const gchar *layout)
93 title_layout = g_strdup(layout);
97 static gboolean update_theme_preview_iterate(gpointer data)
99 GtkListStore *ls = data;
100 static GtkTreeIter iter;
103 if (restart_theme_preview_update) {
104 /* get the first iterator position if there is such a thing */
105 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ls), &iter)) {
106 /* nothing to show */
110 restart_theme_preview_update = FALSE;
112 /* get the next iterator position if there is such a thing */
113 if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(ls), &iter)) {
116 restart_theme_preview_update = TRUE;
118 gtk_tree_view_get_cursor(tree_view, &path, NULL);
120 gtk_tree_view_scroll_to_cell(tree_view, path, NULL,
122 gtk_tree_path_free(path);
131 gtk_tree_model_get(GTK_TREE_MODEL(ls), &iter, 0, &name, -1);
133 gtk_list_store_set(GTK_LIST_STORE(ls), &iter, 1,
134 preview_theme(name, title_layout, active_window_font,
135 inactive_window_font, menu_title_font,
136 menu_item_font, osd_active_font,