]> icculus.org git repositories - dana/obconf.git/blob - src/behavior.c
forgot to set mapping=TRUE while setting up behavior tab
[dana/obconf.git] / src / behavior.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    behavior.h for ObConf, the configuration tool for Openbox
4    Copyright (c) 2003-2007   Dana Jansens
5    Copyright (c) 2003        Tim Riley
6
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.
11
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.
16
17    See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #include "main.h"
21 #include "tree.h"
22
23 static gboolean mapping = FALSE;
24
25 static void behavior_enable_stuff();
26
27 void behavior_setup_tab()
28 {
29     GtkWidget *w, *winresist, *edgeresist;
30     GtkSizeGroup *group;
31     gchar *s;
32
33     mapping = TRUE;
34
35     winresist  = get_widget("resist_window");
36     edgeresist = get_widget("resist_edge");
37     group      = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
38     gtk_size_group_add_widget(group, winresist);
39     gtk_size_group_add_widget(group, edgeresist);
40
41     winresist  = get_widget("resist_window_label");
42     edgeresist = get_widget("resist_edge_label");
43     group      = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
44     gtk_size_group_add_widget(group, winresist);
45     gtk_size_group_add_widget(group, edgeresist);
46
47     w = get_widget("focus_mouse");
48     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
49                                  tree_get_bool("focus/followMouse", FALSE));
50
51     w = get_widget("focus_delay");
52     gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
53                               tree_get_int("focus/focusDelay", 0));
54
55     w = get_widget("focus_raise");
56     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
57                                  tree_get_bool("focus/raiseOnFocus", FALSE));
58
59     w = get_widget("focus_last");
60     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
61                                  tree_get_bool("focus/focusLast", FALSE));
62
63     w = get_widget("focus_new");
64     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
65                                  tree_get_bool("focus/focusNew", TRUE));
66
67     w = get_widget("resize_contents");
68     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
69                                  tree_get_bool("resize/drawContents", TRUE));
70
71     w = get_widget("resist_window");
72     gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
73                               tree_get_int("resistance/strength", 10));
74
75     w = get_widget("resist_edge");
76     gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
77                               tree_get_int("resistance/screen_edge_strength",
78                                            20));
79
80     w = get_widget("place_mouse");
81     s = tree_get_string("placement/policy", "Smart");
82     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
83                                  !g_ascii_strcasecmp(s, "UnderMouse"));
84     g_free(s);
85
86     mapping = FALSE;
87 }
88
89 static void behavior_enable_stuff()
90 {
91     GtkWidget *w;
92     gboolean b;
93
94     w = get_widget("focus_mouse");
95     b = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
96
97     w = get_widget("focus_delay");
98     gtk_widget_set_sensitive(w, b);
99     w = get_widget("focus_delay_label");
100     gtk_widget_set_sensitive(w, b);
101     w = get_widget("focus_delay_label_units");
102     gtk_widget_set_sensitive(w, b);
103     w = get_widget("focus_raise");
104     gtk_widget_set_sensitive(w, b);
105     w = get_widget("focus_last");
106     gtk_widget_set_sensitive(w, b);
107 }
108
109 void on_focus_mouse_toggled(GtkToggleButton *w, gpointer data)
110 {
111     gboolean b;
112
113     if (mapping) return;
114
115     b = gtk_toggle_button_get_active(w);
116     tree_set_bool("focus/followMouse", b);
117
118     {
119         GtkWidget *delay   = get_widget("focus_delay");
120         GtkWidget *delay_l = get_widget("focus_delay_label");
121         GtkWidget *delay_u = get_widget("focus_delay_label_units");
122         GtkWidget *raise   = get_widget("focus_raise");
123         GtkWidget *last    = get_widget("focus_last");
124         gtk_widget_set_sensitive(delay, b);
125         gtk_widget_set_sensitive(delay_l, b);
126         gtk_widget_set_sensitive(delay_u, b);
127         gtk_widget_set_sensitive(raise, b);
128         gtk_widget_set_sensitive(last, b);
129     }
130 }
131
132 void on_focus_delay_value_changed(GtkSpinButton *w, gpointer data)
133 {
134     if (mapping) return;
135
136     tree_set_int("focus/focusDelay",
137                  gtk_spin_button_get_value_as_int(w));
138 }
139
140 void on_focus_raise_toggled(GtkToggleButton *w, gpointer data)
141 {
142     if (mapping) return;
143
144     tree_set_bool("focus/raiseOnFocus", gtk_toggle_button_get_active(w));
145 }
146
147 void on_focus_last_toggled(GtkToggleButton *w, gpointer data)
148 {
149     if (mapping) return;
150
151     tree_set_bool("focus/focusLast", gtk_toggle_button_get_active(w));
152 }
153
154 void on_focus_new_toggled(GtkToggleButton *w, gpointer data)
155 {
156     if (mapping) return;
157
158     tree_set_bool("focus/focusNew", gtk_toggle_button_get_active(w));
159 }
160
161 void on_place_mouse_toggled(GtkToggleButton *w, gpointer data)
162 {
163     if (mapping) return;
164
165     tree_set_string("placement/policy",
166                     (gtk_toggle_button_get_active(w) ?
167                      "UnderMouse" : "Smart"));
168 }
169
170 void on_resist_window_value_changed(GtkSpinButton *w, gpointer data)
171 {
172     if (mapping) return;
173
174     tree_set_int("resistance/strength", gtk_spin_button_get_value_as_int(w));
175 }
176
177 void on_resist_edge_value_changed(GtkSpinButton *w, gpointer data)
178 {
179     if (mapping) return;
180
181     tree_set_int("resistance/screen_edge_strength",
182                  gtk_spin_button_get_value_as_int(w));
183 }
184
185 void on_resize_contents_toggled(GtkToggleButton *w, gpointer data)
186 {
187     if (mapping) return;
188
189     tree_set_bool("resize/drawContents", gtk_toggle_button_get_active(w));
190 }