~ubuntu-branches/debian/squeeze/obconf/squeeze

« back to all changes in this revision

Viewing changes to src/preview_update.c

  • Committer: Bazaar Package Importer
  • Author(s): Nico Golde
  • Date: 2008-06-04 10:25:18 UTC
  • mfrom: (3.1.3 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080604102518-xajvpzkmj3058vkk
Tags: 2.0.3-3
Fix bashism in debian/rules (Closes: #484420).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "preview_update.h"
 
2
#include "main.h"
 
3
 
 
4
static gboolean restart_theme_preview_update = TRUE;
 
5
 
 
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;
 
14
 
 
15
static gboolean update_theme_preview_iterate(gpointer data);
 
16
 
 
17
void preview_update_all()
 
18
{
 
19
    if (!list_store) return;
 
20
 
 
21
    g_idle_remove_by_data(list_store);
 
22
 
 
23
    if (!(title_layout && active_window_font && inactive_window_font &&
 
24
          menu_title_font && menu_item_font && osd_font))
 
25
        return; /* not set up */
 
26
 
 
27
    restart_theme_preview_update = TRUE;
 
28
    g_idle_add_full(G_PRIORITY_LOW,
 
29
                    update_theme_preview_iterate,
 
30
                    list_store, NULL);
 
31
}
 
32
 
 
33
void preview_update_set_tree_view(GtkTreeView *tr, GtkListStore *ls)
 
34
{
 
35
    g_assert(!!tr == !!ls);
 
36
 
 
37
    if (list_store) g_idle_remove_by_data(list_store);
 
38
 
 
39
    tree_view = tr;
 
40
    list_store = ls;
 
41
 
 
42
    if (list_store) preview_update_all();
 
43
}
 
44
 
 
45
void preview_update_set_active_font(RrFont *f)
 
46
{
 
47
    RrFontClose(active_window_font);
 
48
    active_window_font = f;
 
49
    preview_update_all();
 
50
}
 
51
 
 
52
void preview_update_set_inactive_font(RrFont *f)
 
53
{
 
54
    RrFontClose(inactive_window_font);
 
55
    inactive_window_font = f;
 
56
    preview_update_all();
 
57
}
 
58
 
 
59
void preview_update_set_menu_header_font(RrFont *f)
 
60
{
 
61
    RrFontClose(menu_title_font);
 
62
    menu_title_font = f;
 
63
    preview_update_all();
 
64
}
 
65
 
 
66
void preview_update_set_menu_item_font(RrFont *f)
 
67
{
 
68
    RrFontClose(menu_item_font);
 
69
    menu_item_font = f;
 
70
    preview_update_all();
 
71
}
 
72
 
 
73
void preview_update_set_osd_font(RrFont *f)
 
74
{
 
75
    RrFontClose(osd_font);
 
76
    osd_font = f;
 
77
    preview_update_all();
 
78
}
 
79
 
 
80
void preview_update_set_title_layout(const gchar *layout)
 
81
{
 
82
    g_free(title_layout);
 
83
    title_layout = g_strdup(layout);
 
84
    preview_update_all();
 
85
}
 
86
 
 
87
static gboolean update_theme_preview_iterate(gpointer data)
 
88
{
 
89
    GtkListStore *ls = data;
 
90
    static GtkTreeIter iter;
 
91
    gchar *name;
 
92
 
 
93
    if (restart_theme_preview_update) {
 
94
        /* get the first iterator position if there is such a thing */
 
95
        if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ls), &iter)) {
 
96
            /* nothing to show */
 
97
            obconf_show_main();
 
98
            return FALSE;
 
99
        }
 
100
        restart_theme_preview_update = FALSE;
 
101
    } else {
 
102
        /* get the next iterator position if there is such a thing */
 
103
        if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(ls), &iter)) {
 
104
            GtkTreePath *path;
 
105
 
 
106
            restart_theme_preview_update = TRUE;
 
107
 
 
108
            gtk_tree_view_get_cursor(tree_view, &path, NULL);
 
109
            if (path) {
 
110
                gtk_tree_view_scroll_to_cell(tree_view, path, NULL,
 
111
                                             FALSE, 0, 0);
 
112
                gtk_tree_path_free(path);
 
113
            }
 
114
 
 
115
            obconf_show_main();
 
116
 
 
117
            return FALSE;
 
118
        }
 
119
    }
 
120
 
 
121
    gtk_tree_model_get(GTK_TREE_MODEL(ls), &iter, 0, &name, -1);
 
122
 
 
123
    gtk_list_store_set(GTK_LIST_STORE(ls), &iter, 1,
 
124
                       preview_theme(name, title_layout, active_window_font,
 
125
                                     inactive_window_font, menu_title_font,
 
126
                                     menu_item_font, osd_font),
 
127
                       -1);
 
128
 
 
129
    return TRUE;
 
130
}