1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 dock.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;
27 GtkWidget *posi, *dir;
28 GtkWidget *posi_l, *dir_l;
29 GtkSizeGroup *group1, *group2;
31 posi = get_widget("dock_position");
32 dir = get_widget("dock_direction");
33 group1 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
35 gtk_size_group_add_widget(group1, posi);
36 gtk_size_group_add_widget(group1, dir);
38 posi_l = get_widget("dock_position_label");
39 dir_l = get_widget("dock_direction_label");
40 group2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
42 gtk_size_group_add_widget(group2, posi_l);
43 gtk_size_group_add_widget(group2, dir_l);
46 void dock_setup_position(GtkWidget *w)
53 s = tree_get_string("dock/position", "TopLeft");
56 if (!strcasecmp(s, "Top"))
57 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 1);
58 else if (!strcasecmp(s, "TopRight"))
59 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 2);
60 else if (!strcasecmp(s, "Left"))
61 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 3);
62 else if (!strcasecmp(s, "Right"))
63 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 4);
64 else if (!strcasecmp(s, "BottomLeft"))
65 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 5);
66 else if (!strcasecmp(s, "Bottom"))
67 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 6);
68 else if (!strcasecmp(s, "BottomRight"))
69 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 7);
70 else if (!strcasecmp(s, "Floating")) {
71 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 8);
74 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 0);
79 s = get_widget("dock_float_x");
80 gtk_widget_set_sensitive(s, f);
81 s = get_widget("dock_float_y");
82 gtk_widget_set_sensitive(s, f);
83 s = get_widget("dock_float_label");
84 gtk_widget_set_sensitive(s, f);
85 s = get_widget("dock_float_label_x");
86 gtk_widget_set_sensitive(s, f);
92 void dock_setup_float_x(GtkWidget *w)
96 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
97 tree_get_int("dock/floatingX", 0));
102 void dock_setup_float_y(GtkWidget *w)
106 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
107 tree_get_int("dock/floatingY", 0));
112 void dock_setup_stacking(GtkWidget *top, GtkWidget *normal, GtkWidget *bottom)
118 s = tree_get_string("dock/stacking", "Top");
120 if(!strcasecmp(s, "Normal"))
121 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(normal), TRUE);
122 else if(!strcasecmp(s, "Bottom"))
123 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bottom), TRUE);
125 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(top), TRUE);
131 void dock_setup_direction(GtkWidget *w)
137 s = tree_get_string("dock/direction", "Vertical");
139 if (!strcasecmp(s, "Horizontal"))
140 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 1);
142 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 0);
148 void dock_setup_hide(GtkWidget *w)
154 b = tree_get_bool("dock/autoHide", FALSE);
155 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), b);
158 GtkWidget *delay = get_widget("dock_hide_delay");
159 GtkWidget *delay_l = get_widget("dock_hide_label");
160 GtkWidget *delay_u = get_widget("dock_hide_label_units");
161 gtk_widget_set_sensitive(delay, b);
162 gtk_widget_set_sensitive(delay_l, b);
163 gtk_widget_set_sensitive(delay_u, b);
169 void dock_setup_hide_delay(GtkWidget *w)
173 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
174 tree_get_int("dock/hideDelay", 300));
180 void on_dock_top_left_activate(GtkMenuItem *w, gpointer data)
184 tree_set_string("dock/position", "TopLeft");
188 s = get_widget("dock_float_x");
189 gtk_widget_set_sensitive(s, FALSE);
190 s = get_widget("dock_float_y");
191 gtk_widget_set_sensitive(s, FALSE);
192 s = get_widget("dock_float_label");
193 gtk_widget_set_sensitive(s, FALSE);
194 s = get_widget("dock_float_label_x");
195 gtk_widget_set_sensitive(s, FALSE);
199 void on_dock_top_activate(GtkMenuItem *w, gpointer data)
203 tree_set_string("dock/position", "Top");
207 s = get_widget("dock_float_x");
208 gtk_widget_set_sensitive(s, FALSE);
209 s = get_widget("dock_float_y");
210 gtk_widget_set_sensitive(s, FALSE);
211 s = get_widget("dock_float_label");
212 gtk_widget_set_sensitive(s, FALSE);
213 s = get_widget("dock_float_label_x");
214 gtk_widget_set_sensitive(s, FALSE);
218 void on_dock_top_right_activate(GtkMenuItem *w, gpointer data)
222 tree_set_string("dock/position", "TopRight");
226 s = get_widget("dock_float_x");
227 gtk_widget_set_sensitive(s, FALSE);
228 s = get_widget("dock_float_y");
229 gtk_widget_set_sensitive(s, FALSE);
230 s = get_widget("dock_float_label");
231 gtk_widget_set_sensitive(s, FALSE);
232 s = get_widget("dock_float_label_x");
233 gtk_widget_set_sensitive(s, FALSE);
237 void on_dock_left_activate(GtkMenuItem *w, gpointer data)
241 tree_set_string("dock/position", "Left");
245 s = get_widget("dock_float_x");
246 gtk_widget_set_sensitive(s, FALSE);
247 s = get_widget("dock_float_y");
248 gtk_widget_set_sensitive(s, FALSE);
249 s = get_widget("dock_float_label");
250 gtk_widget_set_sensitive(s, FALSE);
251 s = get_widget("dock_float_label_x");
252 gtk_widget_set_sensitive(s, FALSE);
256 void on_dock_right_activate(GtkMenuItem *w, gpointer data)
260 tree_set_string("dock/position", "Right");
264 s = get_widget("dock_float_x");
265 gtk_widget_set_sensitive(s, FALSE);
266 s = get_widget("dock_float_y");
267 gtk_widget_set_sensitive(s, FALSE);
268 s = get_widget("dock_float_label");
269 gtk_widget_set_sensitive(s, FALSE);
270 s = get_widget("dock_float_label_x");
271 gtk_widget_set_sensitive(s, FALSE);
275 void on_dock_bottom_left_activate(GtkMenuItem *w, gpointer data)
279 tree_set_string("dock/position", "BottomLeft");
283 s = get_widget("dock_float_x");
284 gtk_widget_set_sensitive(s, FALSE);
285 s = get_widget("dock_float_y");
286 gtk_widget_set_sensitive(s, FALSE);
287 s = get_widget("dock_float_label");
288 gtk_widget_set_sensitive(s, FALSE);
289 s = get_widget("dock_float_label_x");
290 gtk_widget_set_sensitive(s, FALSE);
294 void on_dock_bottom_activate(GtkMenuItem *w, gpointer data)
298 tree_set_string("dock/position", "Bottom");
302 s = get_widget("dock_float_x");
303 gtk_widget_set_sensitive(s, FALSE);
304 s = get_widget("dock_float_y");
305 gtk_widget_set_sensitive(s, FALSE);
306 s = get_widget("dock_float_label");
307 gtk_widget_set_sensitive(s, FALSE);
308 s = get_widget("dock_float_label_x");
309 gtk_widget_set_sensitive(s, FALSE);
313 void on_dock_bottom_right_activate(GtkMenuItem *w, gpointer data)
317 tree_set_string("dock/position", "BottomRight");
321 s = get_widget("dock_float_x");
322 gtk_widget_set_sensitive(s, FALSE);
323 s = get_widget("dock_float_y");
324 gtk_widget_set_sensitive(s, FALSE);
325 s = get_widget("dock_float_label");
326 gtk_widget_set_sensitive(s, FALSE);
327 s = get_widget("dock_float_label_x");
328 gtk_widget_set_sensitive(s, FALSE);
332 void on_dock_floating_activate(GtkMenuItem *w, gpointer data)
336 tree_set_string("dock/position", "Floating");
340 s = get_widget("dock_float_x");
341 gtk_widget_set_sensitive(s, TRUE);
342 s = get_widget("dock_float_y");
343 gtk_widget_set_sensitive(s, TRUE);
344 s = get_widget("dock_float_label");
345 gtk_widget_set_sensitive(s, TRUE);
346 s = get_widget("dock_float_label_x");
347 gtk_widget_set_sensitive(s, TRUE);
351 void on_dock_float_x_value_changed(GtkSpinButton *w, gpointer data)
355 tree_set_int("dock/floatingX", gtk_spin_button_get_value_as_int(w));
358 void on_dock_float_y_value_changed(GtkSpinButton *w, gpointer data)
362 tree_set_int("dock/floatingY", gtk_spin_button_get_value_as_int(w));
365 void on_dock_stacking_top_toggled(GtkToggleButton *w, gpointer data)
369 if(gtk_toggle_button_get_active(w))
370 tree_set_string("dock/stacking", "Top");
373 void on_dock_stacking_normal_toggled(GtkToggleButton *w, gpointer data)
377 if(gtk_toggle_button_get_active(w))
378 tree_set_string("dock/stacking", "Normal");
381 void on_dock_stacking_bottom_toggled(GtkToggleButton *w, gpointer data)
385 if(gtk_toggle_button_get_active(w))
386 tree_set_string("dock/stacking", "Bottom");
389 void on_dock_horizontal_activate(GtkMenuItem *w, gpointer data)
393 tree_set_string("dock/direction", "Horizontal");
396 void on_dock_vertical_activate(GtkMenuItem *w, gpointer data)
400 tree_set_string("dock/direction", "Vertical");
403 void on_dock_hide_toggled(GtkToggleButton *w, gpointer data)
407 tree_set_bool("dock/autoHide", gtk_toggle_button_get_active(w));
409 GtkWidget *delay = glade_xml_get_widget(glade, "dock_hide_delay");
410 GtkWidget *delay_l = glade_xml_get_widget(glade, "dock_hide_label");
411 GtkWidget *delay_u = glade_xml_get_widget(glade,
412 "dock_hide_label_units");
413 gtk_widget_set_sensitive(delay, gtk_toggle_button_get_active(w));
414 gtk_widget_set_sensitive(delay_l, gtk_toggle_button_get_active(w));
415 gtk_widget_set_sensitive(delay_u, gtk_toggle_button_get_active(w));
419 void on_dock_hide_delay_value_changed(GtkSpinButton *w, gpointer data)
423 tree_set_int("dock/hideDelay",
424 gtk_spin_button_get_value_as_int(w));