1
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3
windows.c for ObConf, the configuration tool for Openbox
4
Copyright (c) 2003-2008 Dana Jansens
5
Copyright (c) 2003 Tim Riley
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
See the COPYING file for a copy of the GNU General Public License.
23
static gboolean mapping = FALSE;
25
#define POPUP_NONPIXEL 0
26
#define POPUP_ALWAYS 1
29
#define POSITION_CENTER 0
30
#define POSITION_TOP 1
31
#define POSITION_FIXED 2
37
static void enable_stuff();
38
static void write_fixed_position(const gchar *coord);
40
void moveresize_setup_tab()
42
GtkWidget *w, *w1, *w2, *w3;
49
w1 = get_widget("resist_window");
50
w2 = get_widget("resist_edge");
51
w3 = get_widget("drag_threshold");
52
group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
53
gtk_size_group_add_widget(group, w1);
54
gtk_size_group_add_widget(group, w2);
55
gtk_size_group_add_widget(group, w3);
57
w1 = get_widget("resist_window_label");
58
w2 = get_widget("resist_edge_label");
59
w3 = get_widget("drag_threshold_label");
60
group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
61
gtk_size_group_add_widget(group, w1);
62
gtk_size_group_add_widget(group, w2);
63
gtk_size_group_add_widget(group, w3);
65
w = get_widget("resize_contents");
66
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
67
tree_get_bool("resize/drawContents", TRUE));
69
w = get_widget("resist_window");
70
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
71
tree_get_int("resistance/strength", 10));
73
w = get_widget("resist_edge");
74
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
75
tree_get_int("resistance/screen_edge_strength",
78
w = get_widget("resize_popup");
79
s = tree_get_string("resize/popupShow", "NonPixel");
80
if (!strcasecmp(s, "Always")) pos = POPUP_ALWAYS;
81
else if (!strcasecmp(s, "Never")) pos = POPUP_NEVER;
82
else pos = POPUP_NONPIXEL;
84
gtk_option_menu_set_history(GTK_OPTION_MENU(w), pos);
86
w = get_widget("drag_threshold");
87
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
88
tree_get_int("mouse/dragThreshold", 8));
90
w = get_widget("resize_position");
91
s = tree_get_string("resize/popupPosition", "Center");
92
if (!strcasecmp(s, "Top")) pos = POSITION_TOP;
93
if (!strcasecmp(s, "Fixed")) pos = POSITION_FIXED;
94
else pos = POSITION_CENTER;
96
gtk_option_menu_set_history(GTK_OPTION_MENU(w), pos);
98
w = get_widget("fixed_x_pos");
99
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
100
tree_get_int("resize/popupFixedPosition/x", 0));
102
w = get_widget("fixed_y_pos");
103
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
104
tree_get_int("resize/popupFixedPosition/y", 0));
106
i = tree_get_int("mouse/screenEdgeWarpTime", 400);
108
w = get_widget("warp_edge");
109
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), i != 0);
111
w = get_widget("warp_edge_time");
112
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), i ? i : 400);
119
static void enable_stuff()
124
w = get_widget("resize_popup");
125
b = gtk_option_menu_get_history(GTK_OPTION_MENU(w)) != POPUP_NEVER;
126
w = get_widget("resize_position");
127
gtk_widget_set_sensitive(w, b);
129
w = get_widget("warp_edge");
130
b = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
131
w = get_widget("warp_edge_time");
132
gtk_widget_set_sensitive(w, b);
134
w = get_widget("resize_position");
135
b = gtk_option_menu_get_history(GTK_OPTION_MENU(w)) == POSITION_FIXED;
136
w = get_widget("fixed_x_popup");
137
gtk_widget_set_sensitive(w, b);
138
w = get_widget("fixed_y_popup");
139
gtk_widget_set_sensitive(w, b);
141
w = get_widget("fixed_x_pos");
142
gtk_widget_set_sensitive(w, FALSE);
143
w = get_widget("fixed_y_pos");
144
gtk_widget_set_sensitive(w, FALSE);
147
w = get_widget("fixed_x_popup");
148
b = gtk_option_menu_get_history(GTK_OPTION_MENU(w)) != EDGE_CENTER;
149
w = get_widget("fixed_x_pos");
150
gtk_widget_set_sensitive(w, b);
152
w = get_widget("fixed_y_popup");
153
b = gtk_option_menu_get_history(GTK_OPTION_MENU(w)) != EDGE_CENTER;
154
w = get_widget("fixed_y_pos");
155
gtk_widget_set_sensitive(w, b);
159
void on_resist_window_value_changed(GtkSpinButton *w, gpointer data)
163
tree_set_int("resistance/strength", gtk_spin_button_get_value_as_int(w));
166
void on_resist_edge_value_changed(GtkSpinButton *w, gpointer data)
170
tree_set_int("resistance/screen_edge_strength",
171
gtk_spin_button_get_value_as_int(w));
174
void on_resize_contents_toggled(GtkToggleButton *w, gpointer data)
178
tree_set_bool("resize/drawContents", gtk_toggle_button_get_active(w));
181
void on_resize_popup_nonpixel_activate(GtkMenuItem *w, gpointer data)
185
tree_set_string("resize/popupShow", "NonPixel");
189
void on_resize_popup_always_activate(GtkMenuItem *w, gpointer data)
193
tree_set_string("resize/popupShow", "Always");
197
void on_resize_popup_never_activate(GtkMenuItem *w, gpointer data)
201
tree_set_string("resize/popupShow", "Never");
205
void on_drag_threshold_value_changed(GtkSpinButton *w, gpointer data)
209
tree_set_int("mouse/dragThreshold",
210
gtk_spin_button_get_value_as_int(w));
213
void on_resize_position_center_activate(GtkMenuItem *w, gpointer data)
217
tree_set_string("resize/popupPosition", "Center");
221
void on_resize_position_top_activate(GtkMenuItem *w, gpointer data)
225
tree_set_string("resize/popupPosition", "Top");
229
void on_resize_position_fixed_activate(GtkMenuItem *w, gpointer data)
233
tree_set_string("resize/popupPosition", "Fixed");
237
static void write_fixed_position(const gchar *coord)
245
g_assert(!strcmp(coord, "x") || !strcmp(coord, "y"));
247
popupname = g_strdup_printf("fixed_%s_popup", coord);
248
popup = get_widget(popupname);
251
edge = gtk_option_menu_get_history(GTK_OPTION_MENU(popup));
252
g_assert(edge == EDGE_CENTER || edge == EDGE_LEFT || edge == EDGE_RIGHT);
254
if (edge == EDGE_CENTER)
255
val = g_strdup("center");
261
spinname = g_strdup_printf("fixed_%s_pos", coord);
262
spin = get_widget(spinname);
265
i = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));
267
if (edge == EDGE_LEFT)
268
val = g_strdup_printf("%d", i);
270
val = g_strdup_printf("-%d", i);
273
valname = g_strdup_printf("resize/popupFixedPosition/%s", coord);
274
tree_set_string(valname, val);
280
void on_fixed_x_position_left_activate(GtkMenuItem *w, gpointer data)
284
write_fixed_position("x");
288
void on_fixed_x_position_right_activate(GtkMenuItem *w, gpointer data)
292
write_fixed_position("x");
296
void on_fixed_x_position_center_activate(GtkMenuItem *w, gpointer data)
300
write_fixed_position("x");
304
void on_fixed_y_position_left_activate(GtkMenuItem *w, gpointer data)
308
write_fixed_position("y");
312
void on_fixed_y_position_right_activate(GtkMenuItem *w, gpointer data)
316
write_fixed_position("y");
320
void on_fixed_y_position_center_activate(GtkMenuItem *w, gpointer data)
324
write_fixed_position("y");
328
void on_fixed_x_pos_value_changed(GtkSpinButton *w, gpointer data)
332
write_fixed_position("x");
335
void on_fixed_y_pos_value_changed(GtkSpinButton *w, gpointer data)
339
write_fixed_position("y");
342
void on_warp_edge_toggled(GtkToggleButton *w, gpointer data)
346
if (gtk_toggle_button_get_active(w)) {
349
w2 = get_widget("warp_edge_time");
350
tree_set_int("mouse/screenEdgeWarpTime",
351
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w2)));
354
tree_set_int("mouse/screenEdgeWarpTime", 0);
358
void on_warp_edge_time_value_changed(GtkSpinButton *w, gpointer data)
362
tree_set_int("mouse/screenEdgeWarpTime",
363
gtk_spin_button_get_value_as_int(w));