1 #include "preview_update.h"
3 static gboolean restart_theme_preview_update = TRUE;
5 static GtkListStore *list_store = NULL;
6 static gchar *title_layout = NULL;
7 static RrFont *active_window_font = NULL;
8 static RrFont *inactive_window_font = NULL;
9 static RrFont *menu_title_font = NULL;
10 static RrFont *menu_item_font = NULL;
11 static RrFont *osd_font = NULL;
13 static gboolean update_theme_preview_iterate(gpointer data);
15 void preview_update_all()
17 if (!list_store) return;
19 g_idle_remove_by_data(list_store);
21 if (!(title_layout && active_window_font && inactive_window_font &&
22 menu_title_font && menu_item_font && osd_font))
23 return; /* not set up */
25 restart_theme_preview_update = TRUE;
26 g_idle_add_full(G_PRIORITY_LOW,
27 update_theme_preview_iterate,
31 void preview_update_set_list_store(GtkListStore *ls)
33 if (list_store) g_idle_remove_by_data(list_store);
37 if (list_store) preview_update_all();
40 void preview_update_set_active_font(RrFont *f)
42 RrFontClose(active_window_font);
43 active_window_font = f;
47 void preview_update_set_inactive_font(RrFont *f)
49 RrFontClose(inactive_window_font);
50 inactive_window_font = f;
54 void preview_update_set_menu_header_font(RrFont *f)
56 RrFontClose(menu_title_font);
61 void preview_update_set_menu_item_font(RrFont *f)
63 RrFontClose(menu_item_font);
68 void preview_update_set_osd_font(RrFont *f)
70 RrFontClose(osd_font);
75 void preview_update_set_title_layout(const gchar *layout)
78 title_layout = g_strdup(layout);
82 static gboolean update_theme_preview_iterate(gpointer data)
84 GtkListStore *ls = data;
85 static GtkTreeIter iter;
88 if (restart_theme_preview_update) {
89 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ls), &iter))
91 restart_theme_preview_update = FALSE;
93 if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(ls), &iter)) {
94 restart_theme_preview_update = TRUE;
99 gtk_tree_model_get(GTK_TREE_MODEL(ls), &iter, 0, &name, -1);
101 gtk_list_store_set(GTK_LIST_STORE(ls), &iter, 1,
102 preview_theme(name, title_layout, active_window_font,
103 inactive_window_font, menu_title_font,
104 menu_item_font, osd_font),