]> icculus.org git repositories - dana/obconf.git/blob - src/windows.c
Remove the center placement option, and add Primary monitor to the monitor placement...
[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-2008   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 PLACE_ON_FIXED 0
26 #define PLACE_ON_PRIMARY 0
27 #define PLACE_ON_ACTIVE 1
28 #define PLACE_ON_MOUSE 2
29 #define PLACE_ON_ALL 3
30
31 static void enable_stuff();
32
33 void windows_setup_tab()
34 {
35     GtkWidget *w;
36     gchar *s;
37
38     mapping = TRUE;
39
40     w = get_widget("focus_new");
41     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
42                                  tree_get_bool("focus/focusNew", TRUE));
43
44     w = get_widget("place_mouse");
45     s = tree_get_string("placement/policy", "Smart");
46     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
47                                  !g_ascii_strcasecmp(s, "UnderMouse"));
48     g_free(s);
49
50     w = get_widget("place_active_popup");
51     s = tree_get_string("placement/monitor", "Any");
52     if (!g_ascii_strcasecmp(s, "Active"))
53         gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_ACTIVE);
54     else if (!g_ascii_strcasecmp(s, "Mouse"))
55         gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_MOUSE);
56     else if (!g_ascii_strcasecmp(s, "Primary"))
57         gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_PRIMARY);
58     else
59         gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_ALL);
60     g_free(s);
61
62     w = get_widget("primary_monitor_popup");
63     s = tree_get_string("placement/primaryMonitor", "");
64     if (!g_ascii_strcasecmp(s, "Active"))
65         gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_ACTIVE);
66     else if (!g_ascii_strcasecmp(s, "Mouse"))
67         gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_MOUSE);
68     else {
69         gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_FIXED);
70
71         w = get_widget("fixed_monitor");
72         gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
73                                   tree_get_int("placement/primaryMonitor", 1));
74     }
75     g_free(s);
76
77     enable_stuff();
78
79     mapping = FALSE;
80 }
81
82 static void enable_stuff()
83 {
84     GtkWidget *w;
85     gboolean b;
86
87     w = get_widget("place_mouse");
88     b = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
89
90     w = get_widget("primary_monitor_popup");
91     b = gtk_option_menu_get_history(GTK_OPTION_MENU(w)) == PLACE_ON_FIXED;
92     w = get_widget("fixed_monitor");
93     gtk_widget_set_sensitive(w, b);
94 }
95
96 void on_primary_monitor_active_activate(GtkMenuItem *w, gpointer data)
97 {
98     if (mapping) return;
99
100     tree_set_string("placement/primaryMonitor", "Active");
101     enable_stuff();
102 }
103
104 void on_primary_monitor_mouse_activate(GtkMenuItem *w, gpointer data)
105 {
106     if (mapping) return;
107
108     tree_set_string("placement/primaryMonitor", "Mouse");
109     enable_stuff();
110 }
111
112 void on_primary_monitor_fixed_activate(GtkMenuItem *w, gpointer data)
113 {
114     GtkWidget *w2;
115
116     if (mapping) return;
117
118     w2 = get_widget("fixed_monitor");
119     tree_set_int("placement/primaryMonitor",
120                  gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w2)));
121     enable_stuff();
122 }
123
124 void on_fixed_monitor_value_changed(GtkSpinButton *w, gpointer data)
125 {
126     if (mapping) return;
127
128     tree_set_int("placement/primaryMonitor",
129                  gtk_spin_button_get_value_as_int(w));
130 }
131
132 void on_focus_new_toggled(GtkToggleButton *w, gpointer data)
133 {
134     if (mapping) return;
135
136     tree_set_bool("focus/focusNew", gtk_toggle_button_get_active(w));
137 }
138
139 void on_place_mouse_toggled(GtkToggleButton *w, gpointer data)
140 {
141     if (mapping) return;
142
143     tree_set_string("placement/policy",
144                     (gtk_toggle_button_get_active(w) ?
145                      "UnderMouse" : "Smart"));
146     enable_stuff();
147 }
148
149 void on_place_active_popup_all_activate(GtkMenuItem *w, gpointer data)
150 {
151     if (mapping) return;
152
153     tree_set_string("placement/monitor", "Any");
154 }
155
156 void on_place_active_popup_active_activate(GtkMenuItem *w, gpointer data)
157 {
158     if (mapping) return;
159
160     tree_set_string("placement/monitor", "Active");
161 }
162
163 void on_place_active_popup_mouse_activate(GtkMenuItem *w, gpointer data)
164 {
165     if (mapping) return;
166
167     tree_set_string("placement/monitor", "Mouse");
168 }
169
170 void on_place_active_popup_primary_activate(GtkMenuItem *w, gpointer data)
171 {
172     if (mapping) return;
173
174     tree_set_string("placement/monitor", "Primary");
175 }