annotate src/layout_config.c @ 1518:4eed0789a828

optimized sidecar file check
author nadvornik
date Mon, 06 Apr 2009 19:09:55 +0000
parents a005287bffc7
children 956aab097ea7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /*
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 9
diff changeset
2 * Geeqie
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2004 John Ellis
1284
8b89e3ff286b Add year 2009 to copyright info everywhere.
zas_
parents: 1055
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 196
diff changeset
13 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 #include "layout_config.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include "layout.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 COLUMN_TEXT = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 COLUMN_KEY
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 typedef struct _LayoutStyle LayoutStyle;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29 struct _LayoutStyle
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 LayoutLocation a, b, c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 typedef struct _LayoutConfig LayoutConfig;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 struct _LayoutConfig
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 GList *style_widgets;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 GtkWidget *listview;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 gint style;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 gint a, b, c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 static LayoutStyle layout_config_styles[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 /* 1, 2, 3 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 { LAYOUT_LEFT | LAYOUT_TOP, LAYOUT_LEFT | LAYOUT_BOTTOM, LAYOUT_RIGHT },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 { LAYOUT_LEFT | LAYOUT_TOP, LAYOUT_RIGHT | LAYOUT_TOP, LAYOUT_BOTTOM },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 { LAYOUT_LEFT, LAYOUT_RIGHT | LAYOUT_TOP, LAYOUT_RIGHT | LAYOUT_BOTTOM },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 { LAYOUT_TOP, LAYOUT_LEFT | LAYOUT_BOTTOM, LAYOUT_RIGHT | LAYOUT_BOTTOM }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 475
diff changeset
56 static gint layout_config_style_count = sizeof(layout_config_styles) / sizeof(LayoutStyle);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 static gchar *layout_titles[] = { N_("Tools"), N_("Files"), N_("Image") };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 static void layout_config_destroy(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 LayoutConfig * lc = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 g_list_free(lc->style_widgets);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 g_free(lc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 static void layout_config_set_order(LayoutLocation l, gint n,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 LayoutLocation *a, LayoutLocation *b, LayoutLocation *c)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 switch (n)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 case 0:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 *a = l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 case 1:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 *b = l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 case 2: default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 *c = l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 static void layout_config_from_data(gint style, gint oa, gint ob, gint oc,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 LayoutLocation *la, LayoutLocation *lb, LayoutLocation *lc)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 LayoutStyle ls;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 style = CLAMP(style, 0, layout_config_style_count);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 ls = layout_config_styles[style];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 layout_config_set_order(ls.a, oa, la, lb, lc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 layout_config_set_order(ls.b, ob, la, lb, lc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 layout_config_set_order(ls.c, oc, la, lb, lc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 void layout_config_parse(gint style, const gchar *order,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 LayoutLocation *a, LayoutLocation *b, LayoutLocation *c)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 gint na, nb, nc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 layout_config_order_from_text(order, &na, &nb, &nc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 layout_config_from_data(style, na, nb, nc, a, b, c);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 static void layout_config_list_order_set(LayoutConfig *lc, gint src, gint dest)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 GtkTreeIter iter;
1444
a005287bffc7 gint -> gboolean.
zas_
parents: 1284
diff changeset
113 gboolean valid;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(lc->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 n = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 if (n == dest)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 gtk_list_store_set(store, &iter, COLUMN_TEXT, _(layout_titles[src]), COLUMN_KEY, src, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 static gint layout_config_list_order_get(LayoutConfig *lc, gint n)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 GtkTreeIter iter;
1444
a005287bffc7 gint -> gboolean.
zas_
parents: 1284
diff changeset
136 gboolean valid;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 gint c = 0;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 281
diff changeset
138
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 store = gtk_tree_view_get_model(GTK_TREE_VIEW(lc->listview));
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 281
diff changeset
140
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 if (c == n)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 gint val;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 gtk_tree_model_get(store, &iter, COLUMN_KEY, &val, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 return val;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 c++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 void layout_config_set(GtkWidget *widget, gint style, const gchar *order)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 LayoutConfig *lc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 gint a, b, c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 lc = g_object_get_data(G_OBJECT(widget), "layout_config");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 if (!lc) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 style = CLAMP(style, 0, layout_config_style_count);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 button = g_list_nth_data(lc->style_widgets, style);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 if (!button) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 layout_config_order_from_text(order, &a, &b, &c);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 layout_config_list_order_set(lc, a, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 layout_config_list_order_set(lc, b, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 layout_config_list_order_set(lc, c, 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 gchar *layout_config_get(GtkWidget *widget, gint *style)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 LayoutConfig *lc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 lc = g_object_get_data(G_OBJECT(widget), "layout_config");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 /* this should not happen */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 if (!lc) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 *style = lc->style;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 lc->a = layout_config_list_order_get(lc, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 lc->b = layout_config_list_order_get(lc, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 lc->c = layout_config_list_order_get(lc, 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 return layout_config_order_to_text(lc->a, lc->b, lc->c);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 static void layout_config_widget_click_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 LayoutConfig *lc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 lc = g_object_get_data(G_OBJECT(widget), "layout_config");
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 281
diff changeset
202
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 if (lc) lc->style = GPOINTER_TO_INT(data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 static void layout_config_table_button(GtkWidget *table, LayoutLocation l, const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 gint x1, y1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 gint x2, y2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 x1 = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 y1 = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 x2 = 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 y2 = 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 if (l & LAYOUT_LEFT) x2 = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 if (l & LAYOUT_RIGHT) x1 = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 if (l & LAYOUT_TOP) y2 = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 if (l & LAYOUT_BOTTOM) y1 = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 button = gtk_button_new_with_label(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 gtk_widget_set_sensitive(button, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 gtk_table_attach_defaults(GTK_TABLE(table), button, x1, x2, y1, y2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 #define LAYOUT_STYLE_SIZE 48
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 static GtkWidget *layout_config_widget(GtkWidget *group, GtkWidget *box, gint style, LayoutConfig *lc)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 LayoutStyle ls;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 ls = layout_config_styles[style];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 if (group)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 group = gtk_radio_button_new(gtk_radio_button_get_group(GTK_RADIO_BUTTON(group)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 group = gtk_radio_button_new(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 g_object_set_data(G_OBJECT(group), "layout_config", lc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 g_signal_connect(G_OBJECT(group), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 G_CALLBACK(layout_config_widget_click_cb), GINT_TO_POINTER(style));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 gtk_box_pack_start(GTK_BOX(box), group, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 table = gtk_table_new(2, 2, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 layout_config_table_button(table, ls.a, "1");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 layout_config_table_button(table, ls.b, "2");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 layout_config_table_button(table, ls.c, "3");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 gtk_widget_set_size_request(table, LAYOUT_STYLE_SIZE, LAYOUT_STYLE_SIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 gtk_container_add(GTK_CONTAINER(group), table);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 gtk_widget_show(table);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 gtk_widget_show(group);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 281
diff changeset
263
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 return group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 static void layout_config_row_move(GtkWidget *clist, gint source_row, gint dest_row, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 gint i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 for (i = 0; i < 3; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 text = g_strdup_printf("%d", i + 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 gtk_clist_set_text(GTK_CLIST(clist), i, 0, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 static void layout_config_number_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 GtkTreeModel *store, GtkTreeIter *iter, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 gint *indices;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 tpath = gtk_tree_model_get_path(store, iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 indices = gtk_tree_path_get_indices(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 buf = g_strdup_printf("%d", indices[0] + 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 g_object_set(G_OBJECT(cell), "text", buf, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 GtkWidget *layout_config_new(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 LayoutConfig *lc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 GtkWidget *group = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 gint i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 lc = g_new0(LayoutConfig, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 lc->box = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 g_object_set_data(G_OBJECT(lc->box), "layout_config", lc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 g_signal_connect(G_OBJECT(lc->box), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 G_CALLBACK(layout_config_destroy), lc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 hbox = gtk_hbox_new(TRUE, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 gtk_box_pack_start(GTK_BOX(lc->box), hbox, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 for (i = 0; i < layout_config_style_count; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 group = layout_config_widget(group, hbox, i, lc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 lc->style_widgets = g_list_append(lc->style_widgets, group);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 GTK_POLICY_NEVER, GTK_POLICY_NEVER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 gtk_box_pack_start(GTK_BOX(lc->box), scrolled, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 lc->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(lc->listview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(lc->listview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(lc->listview), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 gtk_tree_view_column_pack_start(column, renderer, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 gtk_tree_view_column_set_cell_data_func(column, renderer, layout_config_number_cb, lc, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 gtk_tree_view_column_add_attribute(column, renderer, "text", COLUMN_TEXT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 gtk_tree_view_append_column(GTK_TREE_VIEW(lc->listview), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 for (i = 0; i < 3; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 gtk_list_store_set(store, &iter, COLUMN_TEXT, _(layout_titles[i]), COLUMN_KEY, i, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 281
diff changeset
360
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 gtk_container_add(GTK_CONTAINER(scrolled), lc->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 gtk_widget_show(lc->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 pref_label_new(lc->box, _("(drag to change order)"));
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 281
diff changeset
365
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 return lc->box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 513
diff changeset
369 static gchar num_to_text_char(gint n)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 switch (n)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 case 1:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 return '2';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 case 2:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 return '3';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 return '1';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 gchar *layout_config_order_to_text(gint a, gint b, gint c)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 text = g_strdup(" ");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 text[0] = num_to_text_char(a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 text[1] = num_to_text_char(b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 text[2] = num_to_text_char(c);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 return text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 static gint text_char_to_num(const gchar *text, gint n)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 if (text[n] == '3') return 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 if (text[n] == '2') return 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 void layout_config_order_from_text(const gchar *text, gint *a, gint *b, gint *c)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 if (!text || strlen(text) < 3)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 *a = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 *b = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 *c = 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 *a = text_char_to_num(text, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 *b = text_char_to_num(text, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 *c = text_char_to_num(text, 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1000
diff changeset
418 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */