annotate src/ui_misc.c @ 635:eaca3e910ecd

Move a part of pop up menu common code to view_file.[ch].
author zas_
date Sun, 11 May 2008 23:47:59 +0000
parents 985fdfebd89e
children c414002a1f27
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 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2 * (SLIK) SimpLIstic sKin functions
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2004 John Ellis
475
48c8e49b571c updated copyright in source files
nadvornik
parents: 448
diff changeset
4 * Copyright (C) 2008 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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13 #ifdef HAVE_CONFIG_H
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 # include "config.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 #include "intl.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include <stdio.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include <stdlib.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include <string.h>
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 #include <gtk/gtk.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include <gdk/gdkkeysyms.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 442
diff changeset
25 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 #include "ui_misc.h"
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 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29
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 /*
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 * widget and layout utilities
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 */
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 *pref_box_new(GtkWidget *parent_box, gint fill,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 GtkOrientation orientation, gint padding)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 if (orientation == GTK_ORIENTATION_HORIZONTAL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 box = gtk_hbox_new(FALSE, padding);
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 else
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 box = gtk_vbox_new(FALSE, padding);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 gtk_box_pack_start(GTK_BOX(parent_box), box, fill, fill, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 gtk_widget_show(box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 return box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 GtkWidget *pref_group_new(GtkWidget *parent_box, gint fill,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 const gchar *text, GtkOrientation orientation)
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 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 GtkWidget *label;
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 vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 /* add additional spacing if necessary */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 if (GTK_IS_VBOX(parent_box) && GTK_BOX(parent_box)->children != NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 pref_spacer(vbox, PREF_PAD_GROUP - PREF_PAD_GAP);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 gtk_box_pack_start(GTK_BOX(parent_box), vbox, fill, fill, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 label = gtk_label_new(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 pref_label_bold(label, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 hbox = gtk_hbox_new(FALSE, PREF_PAD_INDENT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 /* indent using empty box */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 pref_spacer(hbox, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 if (orientation == GTK_ORIENTATION_HORIZONTAL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 box = gtk_hbox_new(FALSE, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 box = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 gtk_box_pack_start(GTK_BOX(hbox), box, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 gtk_widget_show(box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 g_object_set_data(G_OBJECT(box), "pref_group", vbox);
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 return box;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 GtkWidget *pref_group_parent(GtkWidget *child)
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 GtkWidget *parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 parent = child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 while (parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 GtkWidget *group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 group = g_object_get_data(G_OBJECT(parent), "pref_group");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 if (group && GTK_IS_WIDGET(group)) return group;
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 parent = gtk_widget_get_parent(parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 return child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 }
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 GtkWidget *pref_frame_new(GtkWidget *parent_box, gint fill,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 const gchar *text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 GtkOrientation orientation, gint padding)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 GtkWidget *frame = NULL;
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 frame = gtk_frame_new(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 gtk_box_pack_start(GTK_BOX(parent_box), frame, fill, fill, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 gtk_widget_show(frame);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 if (orientation == GTK_ORIENTATION_HORIZONTAL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 box = gtk_hbox_new(FALSE, padding);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 box = gtk_vbox_new(FALSE, padding);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 gtk_container_add(GTK_CONTAINER(frame), box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 gtk_container_set_border_width(GTK_CONTAINER(box), PREF_PAD_BORDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 gtk_widget_show(box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 return box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 }
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 GtkWidget *pref_spacer(GtkWidget *parent_box, gint padding)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 GtkWidget *spacer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 spacer = gtk_hbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 gtk_box_pack_start(GTK_BOX(parent_box), spacer, FALSE, FALSE, padding / 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 gtk_widget_show(spacer);
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 return spacer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 GtkWidget *pref_line(GtkWidget *parent_box, gint padding)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 GtkWidget *spacer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 if (GTK_IS_HBOX(parent_box))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 spacer = gtk_vseparator_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 spacer = gtk_hseparator_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 }
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 gtk_box_pack_start(GTK_BOX(parent_box), spacer, FALSE, FALSE, padding / 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 gtk_widget_show(spacer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 return spacer;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 GtkWidget *pref_label_new(GtkWidget *parent_box, const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 label = gtk_label_new(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 gtk_box_pack_start(GTK_BOX(parent_box), label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 gtk_widget_show(label);
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 return label;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 GtkWidget *pref_label_new_mnemonic(GtkWidget *parent_box, const gchar *text, GtkWidget *widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 label = gtk_label_new_with_mnemonic(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 gtk_label_set_mnemonic_widget(GTK_LABEL(label), widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 gtk_box_pack_start(GTK_BOX(parent_box), label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 return label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 void pref_label_bold(GtkWidget *label, gint bold, gint increase_size)
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 PangoAttrList *pal;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 PangoAttribute *pa;
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 if (!bold && !increase_size) return;
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 pal = pango_attr_list_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 if (bold)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 pa = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 pa->start_index = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 pa->end_index = G_MAXINT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 pango_attr_list_insert(pal, pa);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 if (increase_size)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 pa = pango_attr_scale_new(PANGO_SCALE_LARGE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 pa->start_index = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 pa->end_index = G_MAXINT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 pango_attr_list_insert(pal, pa);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 gtk_label_set_attributes(GTK_LABEL(label), pal);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 pango_attr_list_unref(pal);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 }
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 GtkWidget *pref_button_new(GtkWidget *parent_box, const gchar *stock_id,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 const gchar *text, gint hide_stock_text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 if (stock_id && !text && !hide_stock_text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 button = gtk_button_new_from_stock(stock_id);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 GtkWidget *image = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 GtkWidget *label = 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 button = gtk_button_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 if (stock_id) image = gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_BUTTON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 if (text)
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 label = gtk_label_new_with_mnemonic(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 if (image && label)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 GtkWidget *align;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 475
diff changeset
262 hbox = gtk_hbox_new(FALSE, PREF_PAD_BUTTON_ICON_GAP);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 gtk_container_add(GTK_CONTAINER(button), align);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 gtk_widget_show(align);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 gtk_container_add(GTK_CONTAINER(align), hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 if (image)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 gtk_container_add(GTK_CONTAINER(button), image);
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 else if (label)
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 gtk_container_add(GTK_CONTAINER(button), label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 if (image) gtk_widget_show(image);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 if (label) gtk_widget_show(label);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 if (func) g_signal_connect(G_OBJECT(button), "clicked", func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 if (parent_box)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 gtk_box_pack_start(GTK_BOX(parent_box), button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 gtk_widget_show(button);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 return button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 static GtkWidget *real_pref_checkbox_new(GtkWidget *parent_box, const gchar *text, gint mnemonic_text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 gint active, GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 if (mnemonic_text)
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 button = gtk_check_button_new_with_mnemonic(text);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312 button = gtk_check_button_new_with_label(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 if (func) g_signal_connect(G_OBJECT(button), "clicked", func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 gtk_box_pack_start(GTK_BOX(parent_box), button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 gtk_widget_show(button);
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 return button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 }
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 GtkWidget *pref_checkbox_new(GtkWidget *parent_box, const gchar *text, gint active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 return real_pref_checkbox_new(parent_box, text, FALSE, active, func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 GtkWidget *pref_checkbox_new_mnemonic(GtkWidget *parent_box, const gchar *text, gint active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 GCallback func, gpointer data)
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 return real_pref_checkbox_new(parent_box, text, TRUE, active, func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 static void pref_checkbox_int_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 gint *result = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 *result = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 GtkWidget *pref_checkbox_new_int(GtkWidget *parent_box, const gchar *text, gint active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 gint *result)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 GtkWidget *button;
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 button = pref_checkbox_new(parent_box, text, active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 G_CALLBACK(pref_checkbox_int_cb), result);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 *result = active;
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 return button;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 static void pref_checkbox_link_sensitivity_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 GtkWidget *widget = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 gtk_widget_set_sensitive(widget, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 void pref_checkbox_link_sensitivity(GtkWidget *button, GtkWidget *widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 g_signal_connect(G_OBJECT(button), "toggled",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 G_CALLBACK(pref_checkbox_link_sensitivity_cb), widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 pref_checkbox_link_sensitivity_cb(button, widget);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 static void pref_checkbox_link_sensitivity_swap_cb(GtkWidget *button, gpointer data)
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 GtkWidget *widget = data;
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 gtk_widget_set_sensitive(widget, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 void pref_checkbox_link_sensitivity_swap(GtkWidget *button, GtkWidget *widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 g_signal_connect(G_OBJECT(button), "toggled",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 G_CALLBACK(pref_checkbox_link_sensitivity_swap_cb), widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 pref_checkbox_link_sensitivity_swap_cb(button, widget);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 static GtkWidget *real_pref_radiobutton_new(GtkWidget *parent_box, GtkWidget *sibling,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 const gchar *text, gint mnemonic_text, gint active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 GSList* group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 if (sibling)
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 group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(sibling));
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 group = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 if (mnemonic_text)
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 button = gtk_radio_button_new_with_mnemonic(group, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 button = gtk_radio_button_new_with_label(group, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 if (active) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 if (func) g_signal_connect(G_OBJECT(button), "clicked", func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 gtk_box_pack_start(GTK_BOX(parent_box), button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 return button;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 GtkWidget *pref_radiobutton_new(GtkWidget *parent_box, GtkWidget *sibling,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 const gchar *text, gint active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 return real_pref_radiobutton_new(parent_box, sibling, text, FALSE, active, func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 GtkWidget *pref_radiobutton_new_mnemonic(GtkWidget *parent_box, GtkWidget *sibling,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 const gchar *text, gint active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429 return real_pref_radiobutton_new(parent_box, sibling, text, TRUE, active, func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 #define PREF_RADIO_VALUE_KEY "pref_radio_value"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 static void pref_radiobutton_int_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 gint *result = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 *result = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), PREF_RADIO_VALUE_KEY));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 GtkWidget *pref_radiobutton_new_int(GtkWidget *parent_box, GtkWidget *sibling,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 const gchar *text, gint active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 gint *result, gint value,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 button = pref_radiobutton_new(parent_box, sibling, text, active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 G_CALLBACK(pref_radiobutton_int_cb), result);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 g_object_set_data(G_OBJECT(button), PREF_RADIO_VALUE_KEY, GINT_TO_POINTER(value));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 if (active) *result = value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 return button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 static GtkWidget *real_pref_spin_new(GtkWidget *parent_box, const gchar *text, const gchar *suffix,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 gint mnemonic_text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 gdouble min, gdouble max, gdouble step, gint digits,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 gdouble value,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 GtkWidget *spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 box = pref_box_new(parent_box, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 spin = gtk_spin_button_new_with_range(min, max, step);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), digits);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 if (func)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 g_signal_connect(G_OBJECT(spin), "value_changed", G_CALLBACK(func), data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 if (text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 if (mnemonic_text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 label = pref_label_new_mnemonic(box, text, spin);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 label = pref_label_new(box, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 pref_link_sensitivity(label, spin);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 gtk_box_pack_start(GTK_BOX(box), spin, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 gtk_widget_show(spin);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 /* perhaps this should only be PREF_PAD_GAP distance from spinbutton ? */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 if (suffix)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 label = pref_label_new(box, suffix);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 pref_link_sensitivity(label, spin);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 return spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 GtkWidget *pref_spin_new(GtkWidget *parent_box, const gchar *text, const gchar *suffix,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 gdouble min, gdouble max, gdouble step, gint digits,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 gdouble value,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 return real_pref_spin_new(parent_box, text, suffix, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 min, max, step, digits, value, func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515 GtkWidget *pref_spin_new_mnemonic(GtkWidget *parent_box, const gchar *text, const gchar *suffix,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516 gdouble min, gdouble max, gdouble step, gint digits,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 gdouble value,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 return real_pref_spin_new(parent_box, text, suffix, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 min, max, step, digits, value, func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 static void pref_spin_int_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 gint *var = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 *var = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 GtkWidget *pref_spin_new_int(GtkWidget *parent_box, const gchar *text, const gchar *suffix,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 gint min, gint max, gint step,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532 gint value, gint *value_var)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 *value_var = value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 return pref_spin_new(parent_box, text, suffix,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 (gdouble)min, (gdouble)max, (gdouble)step, 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 value,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 G_CALLBACK(pref_spin_int_cb), value_var);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 void pref_spin_set_blocking(GtkWidget *spin, gdouble value, gpointer block_data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 g_signal_handlers_block_matched(G_OBJECT(spin), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, block_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 g_signal_handlers_unblock_matched(G_OBJECT(spin), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, block_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 static void pref_link_sensitivity_cb(GtkWidget *watch, GtkStateType prev_state, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 GtkWidget *widget = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 gtk_widget_set_sensitive(widget, GTK_WIDGET_IS_SENSITIVE(watch));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 void pref_link_sensitivity(GtkWidget *widget, GtkWidget *watch)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 g_signal_connect(G_OBJECT(watch), "state_changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 G_CALLBACK(pref_link_sensitivity_cb), widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 void pref_signal_block_data(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 g_signal_handlers_block_matched(widget, G_SIGNAL_MATCH_DATA,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 0, 0, NULL, NULL, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 void pref_signal_unblock_data(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 g_signal_handlers_unblock_matched(widget, G_SIGNAL_MATCH_DATA,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 0, 0, NULL, NULL, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 GtkWidget *pref_table_new(GtkWidget *parent_box, gint columns, gint rows,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576 gint homogenious, gint fill)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 table = gtk_table_new(rows, columns, homogenious);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 gtk_table_set_row_spacings(GTK_TABLE(table), PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 gtk_table_set_col_spacings(GTK_TABLE(table), PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 if (parent_box)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 gtk_box_pack_start(GTK_BOX(parent_box), table, fill, fill, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587 gtk_widget_show(table);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 return table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 GtkWidget *pref_table_box(GtkWidget *table, gint column, gint row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 GtkOrientation orientation, const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 GtkWidget *shell;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 if (text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 shell = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 box = pref_group_new(shell, TRUE, text, orientation);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 if (orientation == GTK_ORIENTATION_HORIZONTAL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608 box = gtk_hbox_new(FALSE, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 box = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 shell = box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 gtk_table_attach(GTK_TABLE(table), shell, column, column + 1, row, row + 1,
113
55166d93498d Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents: 88
diff changeset
618 GTK_EXPAND | GTK_FILL, 0, 0, 0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620 gtk_widget_show(shell);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 return box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 GtkWidget *pref_table_label(GtkWidget *table, gint column, gint row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 const gchar *text, gfloat alignment)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 GtkWidget *align;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 align = gtk_alignment_new(alignment, 0.50, 0.0, 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 gtk_table_attach(GTK_TABLE(table), align, column, column + 1, row, row + 1,
113
55166d93498d Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents: 88
diff changeset
633 GTK_FILL, 0, 0, 0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 gtk_widget_show(align);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 label = gtk_label_new(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 gtk_container_add(GTK_CONTAINER(align), label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 return label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 GtkWidget *pref_table_button(GtkWidget *table, gint column, gint row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 const gchar *stock_id, const gchar *text, gint hide_stock_text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 button = pref_button_new(NULL, stock_id, text, hide_stock_text, func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 gtk_table_attach(GTK_TABLE(table), button, column, column + 1, row, row + 1,
113
55166d93498d Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents: 88
diff changeset
650 GTK_FILL, 0, 0, 0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 return button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 static GtkWidget *pref_table_checkbox(GtkWidget *table, gint column, gint row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 const gchar *text, gint active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 button = gtk_check_button_new_with_label(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 if (func) g_signal_connect(G_OBJECT(button), "clicked", func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667 gtk_table_attach(GTK_TABLE(table), button, column, column + 1, row, row + 1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 return button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675 GtkWidget *pref_table_spin(GtkWidget *table, gint column, gint row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 const gchar *text, const gchar *suffix,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 gdouble min, gdouble max, gdouble step, gint digits,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 gdouble value,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 GtkWidget *spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 spin = gtk_spin_button_new_with_range(min, max, step);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), digits);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 if (func)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690 g_signal_connect(G_OBJECT(spin), "value_changed", G_CALLBACK(func), data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 if (text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 label = pref_table_label(table, column, row, text, 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 pref_link_sensitivity(label, spin);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 column++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 if (suffix)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 box = gtk_hbox_new(FALSE, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 gtk_box_pack_start(GTK_BOX(box), spin, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 gtk_widget_show(spin);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706 label = pref_label_new(box, suffix);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 pref_link_sensitivity(label, spin);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711 box = spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 gtk_table_attach(GTK_TABLE(table), box, column, column + 1, row, row + 1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 gtk_widget_show(box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718 return spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 static void pref_toolbar_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 GtkTooltips *tips = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 g_object_unref(G_OBJECT(tips));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 GtkWidget *pref_toolbar_new(GtkWidget *parent_box, GtkToolbarStyle style)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 GtkWidget *tbar;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 GtkTooltips *tips;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 tbar = gtk_toolbar_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 gtk_toolbar_set_style(GTK_TOOLBAR(tbar), style);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 if (parent_box)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 gtk_box_pack_start(GTK_BOX(parent_box), tbar, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 gtk_widget_show(tbar);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742 tips = gtk_tooltips_new();
88
2099ee3f9a8d Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
743
2099ee3f9a8d Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
744 /* take ownership of tooltips */
2099ee3f9a8d Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
745 #ifdef GTK_OBJECT_FLOATING
2099ee3f9a8d Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
746 /* GTK+ < 2.10 */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 g_object_ref(G_OBJECT(tips));
88
2099ee3f9a8d Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
748 gtk_object_sink(GTK_OBJECT(tips));
2099ee3f9a8d Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
749 #else
2099ee3f9a8d Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
750 /* GTK+ >= 2.10 */
2099ee3f9a8d Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
751 g_object_ref_sink(G_OBJECT(tips));
2099ee3f9a8d Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
752 #endif
2099ee3f9a8d Fri Oct 27 19:45:32 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
753
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754 g_object_set_data(G_OBJECT(tbar), "tooltips", tips);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 g_signal_connect(G_OBJECT(tbar), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 G_CALLBACK(pref_toolbar_destroy_cb), tips);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 gtk_tooltips_enable(tips);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 return tbar;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762
41
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
763 GtkWidget *pref_toolbar_button(GtkWidget *toolbar,
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
764 const gchar *stock_id, const gchar *label, gint toggle,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 const gchar *description,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 GtkWidget *item;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769
41
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
770 if (toggle)
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
771 {
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
772 if (stock_id)
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
773 {
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
774 item = GTK_WIDGET(gtk_toggle_tool_button_new_from_stock(stock_id));
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
775 }
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
776 else
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
777 {
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
778 item = GTK_WIDGET(gtk_toggle_tool_button_new());
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
779 }
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
780 }
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
781 else
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
782 {
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
783 if (stock_id)
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
784 {
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
785 item = GTK_WIDGET(gtk_tool_button_new_from_stock(stock_id));
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
786 }
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
787 else
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
788 {
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
789 item = GTK_WIDGET(gtk_tool_button_new(NULL, NULL));
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
790 }
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
791 }
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
792 gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(item), TRUE);
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
793
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 if (label) gtk_tool_button_set_label(GTK_TOOL_BUTTON(item), label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 if (func) g_signal_connect(item, "clicked", func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 gtk_container_add(GTK_CONTAINER(toolbar), item);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 gtk_widget_show(item);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800 if (description)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 GtkTooltips *tips;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 tips = g_object_get_data(G_OBJECT(toolbar), "tooltips");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(item), tips, description, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 return item;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810
41
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
811 void pref_toolbar_button_set_icon(GtkWidget *button, GtkWidget *widget, const gchar *stock_id)
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
812 {
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
813 if (widget)
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
814 {
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
815 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), widget);
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
816 }
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
817 else if (stock_id)
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
818 {
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
819 gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(button), stock_id);
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
820 }
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
821 }
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
822
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 GtkWidget *pref_toolbar_spacer(GtkWidget *toolbar)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 GtkWidget *item;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 item = GTK_WIDGET(gtk_separator_tool_item_new());
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 gtk_container_add(GTK_CONTAINER(toolbar), item);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829 gtk_widget_show(item);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 return item;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 * date selection entry
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 #define DATE_SELECION_KEY "date_selection_data"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844 typedef struct _DateSelection DateSelection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 struct _DateSelection
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 GtkWidget *spin_d;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 GtkWidget *spin_m;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 GtkWidget *spin_y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 GtkWidget *window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856 GtkWidget *calendar;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 static void date_selection_popup_hide(DateSelection *ds)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 if (!ds->window) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 if (GTK_WIDGET_HAS_GRAB(ds->window))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866 gtk_grab_remove(ds->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 gdk_keyboard_ungrab(GDK_CURRENT_TIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 gdk_pointer_ungrab(GDK_CURRENT_TIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 gtk_widget_hide(ds->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 gtk_widget_destroy(ds->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 ds->window = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 ds->calendar = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ds->button), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 static gint date_selection_popup_release_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 DateSelection *ds = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884 date_selection_popup_hide(ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 static gint date_selection_popup_press_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890 DateSelection *ds = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 gint w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 gint xr, yr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895 xr = (gint)event->x_root;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896 yr = (gint)event->y_root;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 gdk_window_get_origin(ds->window->window, &x, &y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 gdk_drawable_get_size(ds->window->window, &w, &h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901 if (xr < x || yr < y || xr > x + w || yr > y + h)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 g_signal_connect(G_OBJECT(ds->window), "button_release_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 G_CALLBACK(date_selection_popup_release_cb), ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 static void date_selection_popup_sync(DateSelection *ds)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 {
64
04ff0df3ad2f Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
913 guint day, month, year;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915 gtk_calendar_get_date(GTK_CALENDAR(ds->calendar), &year, &month, &day);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 date_selection_set(ds->box, day, month + 1, year);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
918
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 static gint date_selection_popup_keypress_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 DateSelection *ds = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925 case GDK_Return:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 case GDK_KP_Enter:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 case GDK_Tab:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 case GDK_ISO_Left_Tab:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929 date_selection_popup_sync(ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 date_selection_popup_hide(ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 case GDK_Escape:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 date_selection_popup_hide(ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 static void date_selection_day_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944 DateSelection *ds = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946 date_selection_popup_sync(ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949 static void date_selection_doubleclick_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951 DateSelection *ds = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 date_selection_popup_hide(ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 static void date_selection_popup(DateSelection *ds)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 gint wx, wy;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 gint day, month, year;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 if (ds->window) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 ds->window = gtk_window_new(GTK_WINDOW_POPUP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 gtk_window_set_resizable(GTK_WINDOW(ds->window), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
966 g_signal_connect(G_OBJECT(ds->window), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967 G_CALLBACK(date_selection_popup_press_cb), ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 g_signal_connect(G_OBJECT(ds->window), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 G_CALLBACK(date_selection_popup_keypress_cb), ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971 ds->calendar = gtk_calendar_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 gtk_container_add(GTK_CONTAINER(ds->window), ds->calendar);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973 gtk_widget_show(ds->calendar);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 date_selection_get(ds->box, &day, &month, &year);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 gtk_calendar_select_month(GTK_CALENDAR(ds->calendar), month - 1, year);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 gtk_calendar_select_day(GTK_CALENDAR(ds->calendar), day);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979 g_signal_connect(G_OBJECT(ds->calendar), "day_selected",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 G_CALLBACK(date_selection_day_cb), ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 g_signal_connect(G_OBJECT(ds->calendar), "day_selected_double_click",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982 G_CALLBACK(date_selection_doubleclick_cb), ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 gtk_widget_realize(ds->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 gdk_window_get_origin(ds->button->window, &wx, &wy);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 x = wx + ds->button->allocation.x + ds->button->allocation.width - ds->window->allocation.width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 y = wy + ds->button->allocation.y + ds->button->allocation.height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
991 if (y + ds->window->allocation.height > gdk_screen_height())
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993 y = wy + ds->button->allocation.y - ds->window->allocation.height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 if (x < 0) x = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 if (y < 0) y = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 gtk_window_move(GTK_WINDOW(ds->window), x, y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 gtk_widget_show(ds->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 gtk_widget_grab_focus(ds->calendar);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002 gdk_pointer_grab(ds->window->window, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 NULL, NULL, GDK_CURRENT_TIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005 gdk_keyboard_grab(ds->window->window, TRUE, GDK_CURRENT_TIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 gtk_grab_add(ds->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ds->button), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011 static void date_selection_button_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013 DateSelection *ds = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ds->button)) == (!ds->window))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 date_selection_popup(ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021 static void button_size_allocate_cb(GtkWidget *button, GtkAllocation *allocation, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 GtkWidget *spin = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025 if (allocation->height > spin->requisition.height)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 GtkAllocation button_allocation;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 button_allocation = button->allocation;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030 button_allocation.height = spin->requisition.height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031 button_allocation.y = spin->allocation.y +
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 (spin->allocation.height - spin->requisition.height) / 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 gtk_widget_size_allocate(button, &button_allocation);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037 static void spin_increase(GtkWidget *spin, gint value)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 GtkRequisition req;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 gtk_widget_size_request(spin, &req);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042 gtk_widget_set_size_request(spin, req.width + value, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 static void date_selection_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 DateSelection *ds = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 date_selection_popup_hide(ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051 g_free(ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054 GtkWidget *date_selection_new(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 DateSelection *ds;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057 GtkWidget *arrow;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 ds = g_new0(DateSelection, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 ds->box = gtk_hbox_new(FALSE, 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 g_signal_connect(G_OBJECT(ds->box), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 G_CALLBACK(date_selection_destroy_cb), ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 /* FIXME: use option menu with text format of month instead of a spin button */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 ds->spin_m = pref_spin_new(ds->box, NULL, NULL, 1, 12, 1, 0, 1, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 ds->spin_d = pref_spin_new(ds->box, NULL, NULL, 1, 31, 1, 0, 1, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 ds->spin_y = pref_spin_new(ds->box, NULL, NULL, 1900, 9999, 1, 0, 1900, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069 spin_increase(ds->spin_y, 5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 ds->button = gtk_toggle_button_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072 g_signal_connect(G_OBJECT(ds->button), "size_allocate",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 G_CALLBACK(button_size_allocate_cb), ds->spin_y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 gtk_container_add(GTK_CONTAINER(ds->button), arrow);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 gtk_widget_show(arrow);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079 gtk_box_pack_start(GTK_BOX(ds->box), ds->button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 g_signal_connect(G_OBJECT(ds->button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081 G_CALLBACK(date_selection_button_cb), ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1082 gtk_widget_show(ds->button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084 g_object_set_data(G_OBJECT(ds->box), DATE_SELECION_KEY, ds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086 return ds->box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1087 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 339
diff changeset
1088
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089 void date_selection_set(GtkWidget *widget, gint day, gint month, gint year)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091 DateSelection *ds;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093 ds = g_object_get_data(G_OBJECT(widget), DATE_SELECION_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1094 if (!ds) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ds->spin_d), (gdouble)day);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1097 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ds->spin_m), (gdouble)month);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ds->spin_y), (gdouble)year);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102 void date_selection_get(GtkWidget *widget, gint *day, gint *month, gint *year)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104 DateSelection *ds;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 ds = g_object_get_data(G_OBJECT(widget), DATE_SELECION_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107 if (!ds) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1109 if (day) *day = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ds->spin_d));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1110 if (month) *month = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ds->spin_m));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 if (year) *year = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ds->spin_y));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 339
diff changeset
1113
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 void date_selection_time_set(GtkWidget *widget, time_t t)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116 struct tm *lt;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118 lt = localtime(&t);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119 if (!lt) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1120
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1121 date_selection_set(widget, lt->tm_mday, lt->tm_mon + 1, lt->tm_year + 1900);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1123
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1124 time_t date_selection_time_get(GtkWidget *widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1125 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126 struct tm lt;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127 gint day = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 gint month = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 gint year = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1130
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 date_selection_get(widget, &day, &month ,&year);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 lt.tm_sec = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134 lt.tm_min = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1135 lt.tm_hour = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1136 lt.tm_mday = day;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137 lt.tm_mon = month - 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 lt.tm_year = year - 1900;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 lt.tm_isdst = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141 return mktime(&lt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1144
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147 * Sizer, without using a GtkPaned
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1151 #define SIZER_DATA_KEY "sizer_data"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153 typedef struct _SizerData SizerData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 struct _SizerData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156 GtkWidget *sizer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157 GtkWidget *parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 GtkWidget *bounding_widget;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 SizerPositionType position;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161 gint hsize_min;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 gint hsize_max;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163 gint vsize_min;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1164 gint vsize_max;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 gint in_drag;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167 gint press_x;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 gint press_y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1169 gint press_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170 gint press_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172 gint handle_prelit;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 static gint sizer_default_handle_size(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 gint handle_size = 5;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 GtkWidget *paned;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 GtkStyle *style;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 paned = gtk_hpaned_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 style = gtk_rc_get_style(paned);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185 gtk_widget_set_style(paned, style);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186 gtk_widget_style_get(paned, "handle_size", &handle_size, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 gtk_widget_destroy(paned);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190 return handle_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 static gint sizer_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 SizerData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197 gint w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199 if (!sd->in_drag) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 x = sd->press_x - bevent->x_root;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 y = sd->press_y - bevent->y_root;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1203
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 w = sd->press_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 h = sd->press_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1207 if (sd->position & SIZER_POS_LEFT)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209 w += x;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211 else if (sd->position & SIZER_POS_RIGHT)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213 w -= x;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216 if (sd->position & SIZER_POS_TOP)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 h += y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220 else if (sd->position & SIZER_POS_BOTTOM)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 h -= y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225 if (sd->hsize_min >= 0) w = MAX(w, sd->hsize_min);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 if (sd->vsize_min >= 0) h = MAX(h, sd->vsize_min);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228 if (sd->bounding_widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 w = CLAMP(w, sd->sizer->allocation.width, sd->bounding_widget->allocation.width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231 h = CLAMP(h, sd->sizer->allocation.height, sd->bounding_widget->allocation.height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 if (w < sd->sizer->allocation.width) w = sd->sizer->allocation.width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236 if (h < sd->sizer->allocation.height) h = sd->sizer->allocation.height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1239 if (sd->hsize_max >= 0) w = MIN(w, sd->hsize_max);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240 if (sd->vsize_max >= 0) h = MIN(h, sd->vsize_max);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1242 if (w == sd->parent->allocation.width) w = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243 if (h == sd->parent->allocation.height) h = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1244
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245 if (w > 0 || h > 0) gtk_widget_set_size_request(sd->parent, w, h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1249
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1250 static gint sizer_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1251 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252 SizerData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 442
diff changeset
1254 if (bevent->button != MOUSE_BUTTON_LEFT) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256 sd->in_drag = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257 sd->press_x = bevent->x_root;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258 sd->press_y = bevent->y_root;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1259
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1260 sd->press_width = sd->parent->allocation.width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1261 sd->press_height = sd->parent->allocation.height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1262
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1263 gdk_pointer_grab(sd->sizer->window, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264 GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1265 NULL, NULL, bevent->time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266 gtk_grab_add(sd->sizer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271 static gint sizer_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273 SizerData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 442
diff changeset
1275 if (bevent->button != MOUSE_BUTTON_LEFT) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1276
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277 if (gdk_pointer_is_grabbed() && GTK_WIDGET_HAS_GRAB(sd->sizer))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 gtk_grab_remove(sd->sizer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280 gdk_pointer_ungrab(bevent->time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1283 sd->in_drag = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1285 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1286 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1288 static void sizer_set_prelight(SizerData *sd, gint prelit)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1289 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290 sd->handle_prelit = prelit;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1291 gtk_widget_queue_draw_area(sd->sizer, 0, 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 sd->sizer->allocation.width, sd->sizer->allocation.height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1294
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 static gint sizer_enter_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1297 SizerData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1298
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1299 sizer_set_prelight(sd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1300 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1301 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1302
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1303 static gint sizer_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1304 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1305 SizerData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1306
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1307 sizer_set_prelight(sd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1308 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1309 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1310
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1311 static gint sizer_expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1312 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1313 SizerData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1314 GdkRectangle clip;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1315 GtkOrientation orientation;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1316 GtkStateType state;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1317
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1318 gdk_region_get_clipbox(event->region, &clip);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1319
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1320 if (sd->position & SIZER_POS_LEFT || sd->position & SIZER_POS_RIGHT)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1321 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1322 orientation = GTK_ORIENTATION_VERTICAL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1323 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1324 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1325 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1326 orientation = GTK_ORIENTATION_HORIZONTAL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1327 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1328
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1329 if (sd->handle_prelit)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1330 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1331 state = GTK_STATE_PRELIGHT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1332 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1333 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1334 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1335 state = widget->state;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1336 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1337
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1338 gtk_paint_handle(widget->style, widget->window, state,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1339 GTK_SHADOW_NONE, &clip, widget, "paned",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1340 0, 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1341 widget->allocation.width, widget->allocation.height,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1342 orientation);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1343
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1344 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1345 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1346
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1347 static void sizer_realize_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1348 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1349 SizerData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1350 GdkCursorType n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1351
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1352 n = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1353 if (sd->position & SIZER_POS_TOP || sd->position & SIZER_POS_BOTTOM)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1354 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1355 n = GDK_SB_V_DOUBLE_ARROW;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1356 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1357 if (sd->position & SIZER_POS_LEFT || sd->position & SIZER_POS_RIGHT)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1358 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1359 n = (n != 0) ? GDK_FLEUR : GDK_SB_H_DOUBLE_ARROW;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1360 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1361
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1362 if (n != 0 && widget->window)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1363 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1364 GdkCursor *cursor;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1365 cursor = gdk_cursor_new(n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1366 gdk_window_set_cursor(widget->window, cursor);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1367 gdk_cursor_unref(cursor);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1368 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1369 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1370
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1371 static void sizer_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1372 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1373 SizerData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1374
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1375 g_free(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1376 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1377
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1378 GtkWidget *sizer_new(GtkWidget *parent, GtkWidget *bounding_widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1379 SizerPositionType position)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1380 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1381 SizerData *sd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1382 gint handle_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1383
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1384 sd = g_new0(SizerData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1385
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1386 sd->sizer = gtk_event_box_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1387 sd->parent = parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1388 sd->bounding_widget = bounding_widget;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1389 sd->position = position;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1390 sd->hsize_min = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1391 sd->hsize_max = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1392 sd->vsize_min = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1393 sd->vsize_max = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1394
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1395 sd->in_drag = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1396 sd->handle_prelit = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1397
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1398 g_signal_connect(G_OBJECT(sd->sizer), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1399 G_CALLBACK(sizer_destroy_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1400
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1401 g_signal_connect(G_OBJECT(sd->sizer), "motion_notify_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1402 G_CALLBACK(sizer_motion_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1403 g_signal_connect(G_OBJECT(sd->sizer), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1404 G_CALLBACK(sizer_press_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1405 g_signal_connect(G_OBJECT(sd->sizer), "button_release_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1406 G_CALLBACK(sizer_release_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1407
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1408 g_signal_connect(G_OBJECT(sd->sizer), "enter_notify_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1409 G_CALLBACK(sizer_enter_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1410 g_signal_connect(G_OBJECT(sd->sizer), "leave_notify_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1411 G_CALLBACK(sizer_leave_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1412
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1413 gtk_widget_set_events(sd->sizer, GDK_POINTER_MOTION_MASK |
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1414 GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK |
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1415 GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1416
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1417 g_signal_connect(sd->sizer, "realize",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1418 G_CALLBACK(sizer_realize_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1419 g_signal_connect(sd->sizer, "expose_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1420 G_CALLBACK(sizer_expose_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1421
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1422 handle_size = sizer_default_handle_size();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1423
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1424 gtk_widget_set_size_request(sd->sizer, handle_size, handle_size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1425 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1426 /* use this if you add a shadow border to the handle */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1427 gtk_widget_set_size_request(sd->sizer, handle_size + sd->sizer->style->xthickness * 2,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1428 handle_size + sd->sizer->style->ythickness * 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1429 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1430
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1431 g_object_set_data(G_OBJECT(sd->sizer), SIZER_DATA_KEY,sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1432
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1433 return sd->sizer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1434 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1435
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1436 void sizer_set_limits(GtkWidget *sizer,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1437 gint hsize_min, gint hsize_max,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1438 gint vsize_min, gint vsize_max)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1439 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1440 SizerData *sd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1441
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1442 sd = g_object_get_data(G_OBJECT(sizer), SIZER_DATA_KEY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1443 if (!sd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1444
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1445 sd->hsize_min = hsize_min;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1446 sd->hsize_max = hsize_max;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1447 sd->vsize_min = vsize_min;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1448 sd->vsize_max = vsize_max;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1449 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1450
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1451
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1452 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1453 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1454 * storing data in a history list with key,data pairs
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1455 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1456 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1457
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1458 #define PREF_LIST_MARKER_INT "[INT]:"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1459 #define PREF_LIST_MARKER_DOUBLE "[DOUBLE]:"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1460 #define PREF_LIST_MARKER_STRING "[STRING]:"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1461
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1462 static GList *pref_list_find(const gchar *group, const gchar *token)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1463 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1464 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1465 gint l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1466
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1467 l = strlen(token);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1468
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1469 work = history_list_get_by_key(group);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1470 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1471 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1472 const gchar *text = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1473
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1474 if (strncmp(text, token, l) == 0) return work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1475
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1476 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1477 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1478
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1479 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1480 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1481
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1482 static gint pref_list_get(const gchar *group, const gchar *key, const gchar *marker, const gchar **result)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1483 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1484 gchar *token;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1485 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1486 gint ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1487
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1488 if (!group || !key || !marker)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1489 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1490 *result = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1491 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1492 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1493
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1494 token = g_strconcat(key, marker, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1495
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1496 work = pref_list_find(group, token);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1497 if (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1498 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1499 *result = (const gchar *)work->data + strlen(token);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1500 if (strlen(*result) == 0) *result = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1501 ret = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1502 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1503 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1504 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1505 *result = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1506 ret = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1507 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1508
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1509 g_free(token);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1510
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 339
diff changeset
1511 return ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1512 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1513
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1514 static void pref_list_set(const gchar *group, const gchar *key, const gchar *marker, const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1515 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1516 gchar *token;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1517 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1518 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1519
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1520 if (!group || !key || !marker) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1521
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1522 token = g_strconcat(key, marker, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1523 path = g_strconcat(token, text, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1524
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1525 work = pref_list_find(group, token);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1526 if (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1527 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1528 gchar *old_path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1529
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1530 if (text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1531 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1532 work->data = path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1533 path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1534
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1535 g_free(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1536 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1537 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1538 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1539 history_list_item_remove(group, old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1540 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1541 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1542 else if (text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1543 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1544 history_list_add_to_key(group, path, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1545 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1546
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1547 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1548 g_free(token);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1549 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1550
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1551 void pref_list_int_set(const gchar *group, const gchar *key, gint value)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1552 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1553 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1554
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1555 text = g_strdup_printf("%d", value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1556 pref_list_set(group, key, PREF_LIST_MARKER_INT, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1557 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1558 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1559
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1560 gint pref_list_int_get(const gchar *group, const gchar *key, gint *result)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1561 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1562 const gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1563
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1564 if (!group || !key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1565 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1566 *result = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1567 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1568 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1569
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1570 if (pref_list_get(group, key, PREF_LIST_MARKER_INT, &text) && text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1571 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1572 *result = (gint)strtol(text, NULL, 10);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1573 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1574 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1575
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1576 *result = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1577 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1578 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1579
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1580 void pref_list_double_set(const gchar *group, const gchar *key, gdouble value)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1581 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1582 gchar text[G_ASCII_DTOSTR_BUF_SIZE];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1583
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1584 g_ascii_dtostr(text, sizeof(text), value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1585 pref_list_set(group, key, PREF_LIST_MARKER_DOUBLE, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1586 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1587
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1588 gint pref_list_double_get(const gchar *group, const gchar *key, gdouble *result)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1589 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1590 const gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1591
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1592 if (!group || !key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1593 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1594 *result = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1595 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1596 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1597
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1598 if (pref_list_get(group, key, PREF_LIST_MARKER_DOUBLE, &text) && text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1599 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1600 *result = g_ascii_strtod(text, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1601 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1602 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1603
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1604 *result = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1605 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1606 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1607
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1608 void pref_list_string_set(const gchar *group, const gchar *key, const gchar *value)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1609 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1610 pref_list_set(group, key, PREF_LIST_MARKER_STRING, value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1611 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1612
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1613 gint pref_list_string_get(const gchar *group, const gchar *key, const gchar **result)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1614 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1615 return pref_list_get(group, key, PREF_LIST_MARKER_STRING, result);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1616 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1617
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1618
339
de1c2cd06fce Rename user_specified_window_background and window_background_color
zas_
parents: 208
diff changeset
1619 void pref_color_button_set_cb(GtkWidget *widget, gpointer data)
208
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1620 {
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1621 GdkColor *color = data;
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1622
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1623 gtk_color_button_get_color(GTK_COLOR_BUTTON(widget), color);
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1624 }
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1625
339
de1c2cd06fce Rename user_specified_window_background and window_background_color
zas_
parents: 208
diff changeset
1626 GtkWidget *pref_color_button_new(GtkWidget *parent_box,
de1c2cd06fce Rename user_specified_window_background and window_background_color
zas_
parents: 208
diff changeset
1627 const gchar *title, const GdkColor *color,
de1c2cd06fce Rename user_specified_window_background and window_background_color
zas_
parents: 208
diff changeset
1628 GCallback func, gpointer data)
208
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1629 {
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1630 GtkWidget *button;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 339
diff changeset
1631
208
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1632 if (color)
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1633 {
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1634 button = gtk_color_button_new_with_color(color);
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1635 }
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1636 else
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1637 {
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1638 button = gtk_color_button_new();
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1639 }
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1640
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1641 if (func) g_signal_connect(G_OBJECT(button), "color-set", func, data);
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1642
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1643 if (title)
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1644 {
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1645 GtkWidget *label;
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1646 GtkWidget *hbox;
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1647
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1648 gtk_color_button_set_title(GTK_COLOR_BUTTON(button), title);
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1649 label = gtk_label_new(title);
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1650
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1651 hbox = gtk_hbox_new(TRUE, 0);
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1652 gtk_box_pack_start(GTK_BOX(parent_box), hbox, TRUE, TRUE, 0);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 339
diff changeset
1653
208
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1654 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1655 gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1656
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1657 gtk_widget_show_all(hbox);
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1658 }
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1659 else
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1660 {
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1661 gtk_widget_show(button);
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1662 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 339
diff changeset
1663
208
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1664 return button;
fa0e05f985c3 set user-defined color as image background - patch by Laurent MONIN
nadvornik
parents: 113
diff changeset
1665 }