]> icculus.org git repositories - dana/obconf.git/blob - src/windows.c
move the mouse doubleclick time and drag threshold around
[dana/obconf.git] / src / windows.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    windows.c 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 #define POPUP_NONPIXEL 0
26 #define POPUP_ALWAYS   1
27 #define POPUP_NEVER    2
28
29 void windows_setup_tab()
30 {
31     GtkWidget *w, *w1, *w2, *w3;
32     GtkSizeGroup *group;
33     gchar *s;
34     gint pos;
35
36     mapping = TRUE;
37
38     w1    = get_widget("resist_window");
39     w2    = get_widget("resist_edge");
40     w3    = get_widget("drag_threshold");
41     group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
42     gtk_size_group_add_widget(group, w1);
43     gtk_size_group_add_widget(group, w2);
44     gtk_size_group_add_widget(group, w3);
45
46     w1    = get_widget("resist_window_label");
47     w2    = get_widget("resist_edge_label");
48     w3    = get_widget("drag_threshold_label");
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);
53
54     w = get_widget("focus_new");
55     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
56                                  tree_get_bool("focus/focusNew", TRUE));
57
58     w = get_widget("resize_contents");
59     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
60                                  tree_get_bool("resize/drawContents", TRUE));
61
62     w = get_widget("resist_window");
63     gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
64                               tree_get_int("resistance/strength", 10));
65
66     w = get_widget("resist_edge");
67     gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
68                               tree_get_int("resistance/screen_edge_strength",
69                                            20));
70
71     w = get_widget("place_mouse");
72     s = tree_get_string("placement/policy", "Smart");
73     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
74                                  !g_ascii_strcasecmp(s, "UnderMouse"));
75     g_free(s);
76
77     w = get_widget("resize_popup");
78     s = tree_get_string("resize/popupShow", "NonPixel");
79     if (!strcasecmp(s, "Always"))     pos = POPUP_ALWAYS;
80     else if (!strcasecmp(s, "Never")) pos = POPUP_NEVER;
81     else                              pos = POPUP_NONPIXEL;
82     g_free(s);
83     gtk_option_menu_set_history(GTK_OPTION_MENU(w), pos);
84
85     w = get_widget("drag_threshold");
86     gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
87                               tree_get_int("mouse/dragThreshold", 8));
88
89     mapping = FALSE;
90 }
91
92 void on_focus_new_toggled(GtkToggleButton *w, gpointer data)
93 {
94     if (mapping) return;
95
96     tree_set_bool("focus/focusNew", gtk_toggle_button_get_active(w));
97 }
98
99 void on_place_mouse_toggled(GtkToggleButton *w, gpointer data)
100 {
101     if (mapping) return;
102
103     tree_set_string("placement/policy",
104                     (gtk_toggle_button_get_active(w) ?
105                      "UnderMouse" : "Smart"));
106 }
107
108 void on_resist_window_value_changed(GtkSpinButton *w, gpointer data)
109 {
110     if (mapping) return;
111
112     tree_set_int("resistance/strength", gtk_spin_button_get_value_as_int(w));
113 }
114
115 void on_resist_edge_value_changed(GtkSpinButton *w, gpointer data)
116 {
117     if (mapping) return;
118
119     tree_set_int("resistance/screen_edge_strength",
120                  gtk_spin_button_get_value_as_int(w));
121 }
122
123 void on_resize_contents_toggled(GtkToggleButton *w, gpointer data)
124 {
125     if (mapping) return;
126
127     tree_set_bool("resize/drawContents", gtk_toggle_button_get_active(w));
128 }
129
130 void on_resize_popup_nonpixel_activate(GtkMenuItem *w, gpointer data)
131 {
132     if (mapping) return;
133
134     tree_set_string("resize/popupShow", "NonPixel");
135 }
136
137 void on_resize_popup_always_activate(GtkMenuItem *w, gpointer data)
138 {
139     if (mapping) return;
140
141     tree_set_string("resize/popupShow", "Always");
142 }
143
144 void on_resize_popup_never_activate(GtkMenuItem *w, gpointer data)
145 {
146     if (mapping) return;
147
148     tree_set_string("resize/popupShow", "Never");
149 }
150
151 void on_drag_threshold_value_changed(GtkSpinButton *w, gpointer data)
152 {
153     if (mapping) return;
154
155     tree_set_int("mouse/dragThreshold",
156                  gtk_spin_button_get_value_as_int(w));
157 }