1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#include "window_config.h"
#include "config_ui.h"
#include "walls_conf.h"
#include "preload.h"
#include "wallpapers.h"
struct window_config_t *window_config_new(GtkWindow *parent) {
GtkBuilder *builder;
GtkDialog *dialog;
GtkComboBox *interp_combo;
GtkHScale *preload_scale;
GtkListStore *liststore;
GtkTreeIter iter;
GError *error = NULL;
GtkCellRenderer *cell;
struct window_config_t *wct;
builder = gtk_builder_new();
if(!gtk_builder_add_from_string(builder, config_ui_string, -1, &error)) {
g_warning("%s", error->message);
g_error_free(error);
return NULL;
}
interp_combo = GTK_COMBO_BOX(gtk_builder_get_object(builder, "interp_combo"));
liststore = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
gtk_list_store_append(liststore, &iter);
gtk_list_store_set(liststore, &iter, 0, "Nearest", 1, GDK_INTERP_NEAREST, -1);
gtk_list_store_append(liststore, &iter);
gtk_list_store_set(liststore, &iter, 0, "Tiles", 1, GDK_INTERP_TILES, -1);
gtk_list_store_append(liststore, &iter);
gtk_list_store_set(liststore, &iter, 0, "Bilinear", 1, GDK_INTERP_BILINEAR, -1);
gtk_list_store_append(liststore, &iter);
gtk_list_store_set(liststore, &iter, 0, "Hyper", 1, GDK_INTERP_HYPER, -1);
gtk_combo_box_set_model(interp_combo, GTK_TREE_MODEL(liststore));
g_object_unref(liststore);
cell = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(interp_combo), cell, TRUE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(interp_combo), cell, "text", 0, NULL);
switch(config.interp_type) {
case GDK_INTERP_TILES:
gtk_combo_box_set_active(interp_combo, 1);
break;
case GDK_INTERP_BILINEAR:
gtk_combo_box_set_active(interp_combo, 2);
break;
case GDK_INTERP_HYPER:
gtk_combo_box_set_active(interp_combo, 3);
break;
default:
gtk_combo_box_set_active(interp_combo, 0);
}
preload_scale = GTK_HSCALE(gtk_builder_get_object(builder, "preload_scale"));
gtk_range_set_value(GTK_RANGE(preload_scale), config.max_preload);
dialog = GTK_DIALOG(gtk_builder_get_object(builder, "config_dialog"));
gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
gtk_builder_connect_signals(builder, dialog);
g_object_unref(G_OBJECT(builder));
wct = g_malloc(sizeof(struct window_config_t));
wct->dialog = dialog;
wct->interp_combo = interp_combo;
wct->preload_scale = GTK_RANGE(preload_scale);
return wct;
}
void window_config_save(struct window_config_t *wct) {
GValue value = {0};
GtkListStore *liststore = GTK_LIST_STORE(gtk_combo_box_get_model(wct->interp_combo));
GtkTreeIter iter;
gtk_combo_box_get_active_iter(wct->interp_combo, &iter);
gtk_tree_model_get_value(GTK_TREE_MODEL(liststore), &iter, 1, &value);
config.interp_type = g_value_get_int(&value);
g_value_unset(&value);
config.max_preload = gtk_range_get_value(wct->preload_scale);
conf_save();
}
|