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;
25 #define POSITION_TOPLEFT 0
26 #define POSITION_TOP 1
27 #define POSITION_TOPRIGHT 2
28 #define POSITION_LEFT 3
29 #define POSITION_RIGHT 4
30 #define POSITION_BOTTOMLEFT 5
31 #define POSITION_BOTTOM 6
32 #define POSITION_BOTTOMRIGHT 7
33 #define POSITION_FLOATING 8
35 #define DIRECTION_VERTICAL 0
36 #define DIRECTION_HORIZONTAL 1
40 GtkWidget *w, *posi, *dir;
47 posi = get_widget("dock_position");
48 dir = get_widget("dock_direction");
49 group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
50 gtk_size_group_add_widget(group, posi);
51 gtk_size_group_add_widget(group, dir);
53 posi = get_widget("dock_position_label");
54 dir = get_widget("dock_direction_label");
55 group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
56 gtk_size_group_add_widget(group, posi);
57 gtk_size_group_add_widget(group, dir);
59 w = get_widget("dock_position");
60 s = tree_get_string("dock/position", "TopLeft");
61 if (!strcasecmp(s, "Top")) pos = POSITION_TOP;
62 else if (!strcasecmp(s, "Left")) pos = POSITION_LEFT;
63 else if (!strcasecmp(s, "Right")) pos = POSITION_RIGHT;
64 else if (!strcasecmp(s, "BottomLeft")) pos = POSITION_BOTTOMLEFT;
65 else if (!strcasecmp(s, "Bottom")) pos = POSITION_BOTTOM;
66 else if (!strcasecmp(s, "BottomRight")) pos = POSITION_BOTTOMRIGHT;
67 else if (!strcasecmp(s, "Floating")) pos = POSITION_FLOATING;
68 else pos = POSITION_TOPLEFT;
70 gtk_option_menu_set_history(GTK_OPTION_MENU(w), pos);
72 w = get_widget("dock_float_x");
73 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
74 tree_get_int("dock/floatingX", 0));
76 w = get_widget("dock_float_y");
77 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
78 tree_get_int("dock/floatingY", 0));
80 s = tree_get_string("dock/stacking", "Top");
81 if(!strcasecmp(s, "Normal"))
82 w = get_widget("dock_stack_normal");
83 else if(!strcasecmp(s, "Bottom"))
84 w = get_widget("dock_stack_bottom");
86 w = get_widget("dock_stack_top");
88 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), TRUE);
90 w = get_widget("dock_direction");
91 s = tree_get_string("dock/direction", "Vertical");
92 if (!strcasecmp(s, "Horizontal")) pos = DIRECTION_HORIZONTAL;
93 else pos = DIRECTION_VERTICAL;
95 gtk_option_menu_set_history(GTK_OPTION_MENU(w), pos);
97 w = get_widget("dock_hide");
98 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
99 tree_get_bool("dock/autoHide", FALSE));
101 w = get_widget("dock_hide_delay");
102 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
103 tree_get_int("dock/hideDelay", 300));
110 void dock_enable_stuff()
115 w = get_widget("dock_position");
116 b = gtk_option_menu_get_history(GTK_OPTION_MENU(w)) == POSITION_FLOATING;
118 s = get_widget("dock_float_x");
119 gtk_widget_set_sensitive(s, b);
120 s = get_widget("dock_float_y");
121 gtk_widget_set_sensitive(s, b);
122 s = get_widget("dock_float_label");
123 gtk_widget_set_sensitive(s, b);
124 s = get_widget("dock_float_label_x");
125 gtk_widget_set_sensitive(s, b);
127 w = get_widget("dock_hide");
128 b = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
130 s = get_widget("dock_hide_delay");
131 gtk_widget_set_sensitive(s, b);
132 s = get_widget("dock_hide_label");
133 gtk_widget_set_sensitive(s, b);
134 s = get_widget("dock_hide_label_units");
135 gtk_widget_set_sensitive(s, b);
138 void on_dock_top_left_activate(GtkMenuItem *w, gpointer data)
142 tree_set_string("dock/position", "TopLeft");
146 void on_dock_top_activate(GtkMenuItem *w, gpointer data)
150 tree_set_string("dock/position", "Top");
154 void on_dock_top_right_activate(GtkMenuItem *w, gpointer data)
158 tree_set_string("dock/position", "TopRight");
162 void on_dock_left_activate(GtkMenuItem *w, gpointer data)
166 tree_set_string("dock/position", "Left");
170 void on_dock_right_activate(GtkMenuItem *w, gpointer data)
174 tree_set_string("dock/position", "Right");
178 void on_dock_bottom_left_activate(GtkMenuItem *w, gpointer data)
182 tree_set_string("dock/position", "BottomLeft");
186 void on_dock_bottom_activate(GtkMenuItem *w, gpointer data)
190 tree_set_string("dock/position", "Bottom");
194 void on_dock_bottom_right_activate(GtkMenuItem *w, gpointer data)
198 tree_set_string("dock/position", "BottomRight");
202 void on_dock_floating_activate(GtkMenuItem *w, gpointer data)
206 tree_set_string("dock/position", "Floating");
210 void on_dock_float_x_value_changed(GtkSpinButton *w, gpointer data)
214 tree_set_int("dock/floatingX", gtk_spin_button_get_value_as_int(w));
217 void on_dock_float_y_value_changed(GtkSpinButton *w, gpointer data)
221 tree_set_int("dock/floatingY", gtk_spin_button_get_value_as_int(w));
224 void on_dock_stacking_top_toggled(GtkToggleButton *w, gpointer data)
228 if(gtk_toggle_button_get_active(w))
229 tree_set_string("dock/stacking", "Top");
232 void on_dock_stacking_normal_toggled(GtkToggleButton *w, gpointer data)
236 if(gtk_toggle_button_get_active(w))
237 tree_set_string("dock/stacking", "Normal");
240 void on_dock_stacking_bottom_toggled(GtkToggleButton *w, gpointer data)
244 if(gtk_toggle_button_get_active(w))
245 tree_set_string("dock/stacking", "Bottom");
248 void on_dock_horizontal_activate(GtkMenuItem *w, gpointer data)
252 tree_set_string("dock/direction", "Horizontal");
255 void on_dock_vertical_activate(GtkMenuItem *w, gpointer data)
259 tree_set_string("dock/direction", "Vertical");
262 void on_dock_hide_toggled(GtkToggleButton *w, gpointer data)
266 tree_set_bool("dock/autoHide", gtk_toggle_button_get_active(w));
270 void on_dock_hide_delay_value_changed(GtkSpinButton *w, gpointer data)
274 tree_set_int("dock/hideDelay",
275 gtk_spin_button_get_value_as_int(w));