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-2007 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
32 #define PLACE_ON_ALL 0
33 #define PLACE_ON_ACTIVE 1
35 static void enable_stuff();
37 void windows_setup_tab()
39 GtkWidget *w, *w1, *w2, *w3;
46 w1 = get_widget("resist_window");
47 w2 = get_widget("resist_edge");
48 w3 = get_widget("drag_threshold");
49 group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
50 gtk_size_group_add_widget(group, w1);
51 gtk_size_group_add_widget(group, w2);
52 gtk_size_group_add_widget(group, w3);
54 w1 = get_widget("resist_window_label");
55 w2 = get_widget("resist_edge_label");
56 w3 = get_widget("drag_threshold_label");
57 group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
58 gtk_size_group_add_widget(group, w1);
59 gtk_size_group_add_widget(group, w2);
60 gtk_size_group_add_widget(group, w3);
62 w = get_widget("focus_new");
63 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
64 tree_get_bool("focus/focusNew", TRUE));
66 w = get_widget("resize_contents");
67 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
68 tree_get_bool("resize/drawContents", TRUE));
70 w = get_widget("resist_window");
71 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
72 tree_get_int("resistance/strength", 10));
74 w = get_widget("resist_edge");
75 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
76 tree_get_int("resistance/screen_edge_strength",
79 w = get_widget("place_mouse");
80 s = tree_get_string("placement/policy", "Smart");
81 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
82 !g_ascii_strcasecmp(s, "UnderMouse"));
85 w = get_widget("place_center");
86 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
87 tree_get_bool("placement/center", TRUE));
89 w = get_widget("place_active_popup");
90 if (tree_get_bool("placement/active", FALSE))
91 gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_ACTIVE);
93 gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_ALL);
95 w = get_widget("resize_popup");
96 s = tree_get_string("resize/popupShow", "NonPixel");
97 if (!strcasecmp(s, "Always")) pos = POPUP_ALWAYS;
98 else if (!strcasecmp(s, "Never")) pos = POPUP_NEVER;
99 else pos = POPUP_NONPIXEL;
101 gtk_option_menu_set_history(GTK_OPTION_MENU(w), pos);
103 w = get_widget("drag_threshold");
104 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
105 tree_get_int("mouse/dragThreshold", 8));
107 w = get_widget("resize_position");
108 s = tree_get_string("resize/popupPosition", "Center");
109 if (!strcasecmp(s, "Top")) pos = POSITION_TOP;
110 else pos = POSITION_CENTER;
112 gtk_option_menu_set_history(GTK_OPTION_MENU(w), pos);
114 i = tree_get_int("mouse/screenEdgeWarpTime", 400);
116 w = get_widget("warp_edge");
117 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), i != 0);
119 w = get_widget("warp_edge_time");
120 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), i ? i : 400);
127 static void enable_stuff()
132 w = get_widget("resize_popup");
133 b = gtk_option_menu_get_history(GTK_OPTION_MENU(w)) != POPUP_NEVER;
134 w = get_widget("resize_position");
135 gtk_widget_set_sensitive(w, b);
137 w = get_widget("place_mouse");
138 b = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
139 w = get_widget("place_center");
140 gtk_widget_set_sensitive(w, !b);
142 w = get_widget("warp_edge");
143 b = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
144 w = get_widget("warp_edge_time");
145 gtk_widget_set_sensitive(w, b);
148 void on_focus_new_toggled(GtkToggleButton *w, gpointer data)
152 tree_set_bool("focus/focusNew", gtk_toggle_button_get_active(w));
155 void on_place_mouse_toggled(GtkToggleButton *w, gpointer data)
159 tree_set_string("placement/policy",
160 (gtk_toggle_button_get_active(w) ?
161 "UnderMouse" : "Smart"));
165 void on_place_center_toggled(GtkToggleButton *w, gpointer data)
169 tree_set_bool("placement/center", gtk_toggle_button_get_active(w));
172 void on_place_active_popup_all_activate(GtkMenuItem *w, gpointer data)
176 tree_set_bool("placement/active", FALSE);
179 void on_place_active_popup_active_activate(GtkMenuItem *w, gpointer data)
183 tree_set_bool("placement/active", TRUE);
186 void on_resist_window_value_changed(GtkSpinButton *w, gpointer data)
190 tree_set_int("resistance/strength", gtk_spin_button_get_value_as_int(w));
193 void on_resist_edge_value_changed(GtkSpinButton *w, gpointer data)
197 tree_set_int("resistance/screen_edge_strength",
198 gtk_spin_button_get_value_as_int(w));
201 void on_resize_contents_toggled(GtkToggleButton *w, gpointer data)
205 tree_set_bool("resize/drawContents", gtk_toggle_button_get_active(w));
208 void on_resize_popup_nonpixel_activate(GtkMenuItem *w, gpointer data)
212 tree_set_string("resize/popupShow", "NonPixel");
216 void on_resize_popup_always_activate(GtkMenuItem *w, gpointer data)
220 tree_set_string("resize/popupShow", "Always");
224 void on_resize_popup_never_activate(GtkMenuItem *w, gpointer data)
228 tree_set_string("resize/popupShow", "Never");
232 void on_drag_threshold_value_changed(GtkSpinButton *w, gpointer data)
236 tree_set_int("mouse/dragThreshold",
237 gtk_spin_button_get_value_as_int(w));
240 void on_resize_position_center_activate(GtkMenuItem *w, gpointer data)
244 tree_set_string("resize/popupPosition", "Center");
249 void on_resize_position_top_activate(GtkMenuItem *w, gpointer data)
253 tree_set_string("resize/popupPosition", "Top");
257 void on_warp_edge_toggled(GtkToggleButton *w, gpointer data)
261 if (gtk_toggle_button_get_active(w)) {
264 w2 = get_widget("warp_edge_time");
265 tree_set_int("mouse/screenEdgeWarpTime",
266 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w2)));
269 tree_set_int("mouse/screenEdgeWarpTime", 0);
273 void on_warp_edge_time_value_changed(GtkSpinButton *w, gpointer data)
277 tree_set_int("mouse/screenEdgeWarpTime",
278 gtk_spin_button_get_value_as_int(w));