]> icculus.org git repositories - dana/obconf.git/blob - src/windows.c
fix conflicting mnemonic
[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_ALL    0
26 #define PLACE_ON_ACTIVE 1
27
28 static void enable_stuff();
29
30 void windows_setup_tab()
31 {
32     GtkWidget *w;
33     gchar *s;
34
35     mapping = TRUE;
36
37     w = get_widget("focus_new");
38     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
39                                  tree_get_bool("focus/focusNew", TRUE));
40
41     w = get_widget("place_mouse");
42     s = tree_get_string("placement/policy", "Smart");
43     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
44                                  !g_ascii_strcasecmp(s, "UnderMouse"));
45     g_free(s);
46
47     w = get_widget("place_center");
48     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
49                                  tree_get_bool("placement/center", TRUE));
50
51     w = get_widget("place_active_popup");
52     if (tree_get_bool("placement/active", FALSE))
53         gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_ACTIVE);
54     else
55         gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_ALL);
56
57     enable_stuff();
58
59     mapping = FALSE;
60 }
61
62 static void enable_stuff()
63 {
64     GtkWidget *w;
65     gboolean b;
66
67     w = get_widget("place_mouse");
68     b = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
69     w = get_widget("place_center");
70     gtk_widget_set_sensitive(w, !b);
71 }
72
73 void on_focus_new_toggled(GtkToggleButton *w, gpointer data)
74 {
75     if (mapping) return;
76
77     tree_set_bool("focus/focusNew", gtk_toggle_button_get_active(w));
78 }
79
80 void on_place_mouse_toggled(GtkToggleButton *w, gpointer data)
81 {
82     if (mapping) return;
83
84     tree_set_string("placement/policy",
85                     (gtk_toggle_button_get_active(w) ?
86                      "UnderMouse" : "Smart"));
87     enable_stuff();
88 }
89
90 void on_place_center_toggled(GtkToggleButton *w, gpointer data)
91 {
92     if (mapping) return;
93
94     tree_set_bool("placement/center", gtk_toggle_button_get_active(w));
95 }
96
97 void on_place_active_popup_all_activate(GtkMenuItem *w, gpointer data)
98 {
99     if (mapping) return;
100
101     tree_set_bool("placement/active", FALSE);
102 }
103
104 void on_place_active_popup_active_activate(GtkMenuItem *w, gpointer data)
105 {
106     if (mapping) return;
107
108     tree_set_bool("placement/active", TRUE);
109 }