move mouse focus options to mouse tab
[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 void windows_setup_tab()
26 {
27     GtkWidget *w, *w1, *w2;
28     GtkSizeGroup *group;
29     gchar *s;
30
31     mapping = TRUE;
32
33     w1    = get_widget("resist_window");
34     w2    = get_widget("resist_edge");
35     group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
36     gtk_size_group_add_widget(group, w1);
37     gtk_size_group_add_widget(group, w2);
38
39     w1    = get_widget("resist_window_label");
40     w2    = get_widget("resist_edge_label");
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
45     w = get_widget("focus_new");
46     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
47                                  tree_get_bool("focus/focusNew", TRUE));
48
49     w = get_widget("resize_contents");
50     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
51                                  tree_get_bool("resize/drawContents", TRUE));
52
53     w = get_widget("resist_window");
54     gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
55                               tree_get_int("resistance/strength", 10));
56
57     w = get_widget("resist_edge");
58     gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
59                               tree_get_int("resistance/screen_edge_strength",
60                                            20));
61
62     w = get_widget("place_mouse");
63     s = tree_get_string("placement/policy", "Smart");
64     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
65                                  !g_ascii_strcasecmp(s, "UnderMouse"));
66     g_free(s);
67
68     mapping = FALSE;
69 }
70
71 void on_focus_new_toggled(GtkToggleButton *w, gpointer data)
72 {
73     if (mapping) return;
74
75     tree_set_bool("focus/focusNew", gtk_toggle_button_get_active(w));
76 }
77
78 void on_place_mouse_toggled(GtkToggleButton *w, gpointer data)
79 {
80     if (mapping) return;
81
82     tree_set_string("placement/policy",
83                     (gtk_toggle_button_get_active(w) ?
84                      "UnderMouse" : "Smart"));
85 }
86
87 void on_resist_window_value_changed(GtkSpinButton *w, gpointer data)
88 {
89     if (mapping) return;
90
91     tree_set_int("resistance/strength", gtk_spin_button_get_value_as_int(w));
92 }
93
94 void on_resist_edge_value_changed(GtkSpinButton *w, gpointer data)
95 {
96     if (mapping) return;
97
98     tree_set_int("resistance/screen_edge_strength",
99                  gtk_spin_button_get_value_as_int(w));
100 }
101
102 void on_resize_contents_toggled(GtkToggleButton *w, gpointer data)
103 {
104     if (mapping) return;
105
106     tree_set_bool("resize/drawContents", gtk_toggle_button_get_active(w));
107 }
108