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