1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 windows.c for ObConf, the configuration tool for Openbox
4 Copyright (c) 2003-2008 Dana Jansens
5 Copyright (c) 2003 Tim Riley
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.
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.
17 See the COPYING file for a copy of the GNU General Public License.
23 static gboolean mapping = FALSE;
25 #define PLACE_ON_ALL 0
26 #define PLACE_ON_FIXED 0
27 #define PLACE_ON_ACTIVE 1
28 #define PLACE_ON_MOUSE 2
30 static void enable_stuff();
32 void windows_setup_tab()
39 w = get_widget("focus_new");
40 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
41 tree_get_bool("focus/focusNew", TRUE));
43 w = get_widget("place_mouse");
44 s = tree_get_string("placement/policy", "Smart");
45 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
46 !g_ascii_strcasecmp(s, "UnderMouse"));
49 w = get_widget("place_center");
50 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
51 tree_get_bool("placement/center", TRUE));
53 w = get_widget("place_active_popup");
54 s = tree_get_string("placement/monitor", "Any");
55 if (!g_ascii_strcasecmp(s, "Active"))
56 gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_ACTIVE);
57 else if (!g_ascii_strcasecmp(s, "Mouse"))
58 gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_MOUSE);
60 gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_ALL);
63 w = get_widget("primary_monitor_popup");
64 s = tree_get_string("placement/primaryMonitor", "");
65 if (!g_ascii_strcasecmp(s, "Active"))
66 gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_ACTIVE);
67 else if (!g_ascii_strcasecmp(s, "Mouse"))
68 gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_MOUSE);
70 gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_FIXED);
72 w = get_widget("fixed_monitor");
73 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
74 tree_get_int("placement/primaryMonitor", 1));
83 static void enable_stuff()
88 w = get_widget("place_mouse");
89 b = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
91 w = get_widget("place_center");
92 gtk_widget_set_sensitive(w, !b);
94 w = get_widget("primary_monitor_popup");
95 b = gtk_option_menu_get_history(GTK_OPTION_MENU(w)) == PLACE_ON_FIXED;
96 w = get_widget("fixed_monitor");
97 gtk_widget_set_sensitive(w, b);
100 void on_primary_monitor_active_activate(GtkMenuItem *w, gpointer data)
104 tree_set_string("placement/primaryMonitor", "Active");
108 void on_primary_monitor_mouse_activate(GtkMenuItem *w, gpointer data)
112 tree_set_string("placement/primaryMonitor", "Mouse");
116 void on_primary_monitor_fixed_activate(GtkMenuItem *w, gpointer data)
122 w2 = get_widget("fixed_monitor");
123 tree_set_int("placement/primaryMonitor",
124 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w2)));
128 void on_fixed_monitor_value_changed(GtkSpinButton *w, gpointer data)
132 tree_set_int("placement/primaryMonitor",
133 gtk_spin_button_get_value_as_int(w));
136 void on_focus_new_toggled(GtkToggleButton *w, gpointer data)
140 tree_set_bool("focus/focusNew", gtk_toggle_button_get_active(w));
143 void on_place_mouse_toggled(GtkToggleButton *w, gpointer data)
147 tree_set_string("placement/policy",
148 (gtk_toggle_button_get_active(w) ?
149 "UnderMouse" : "Smart"));
153 void on_place_center_toggled(GtkToggleButton *w, gpointer data)
157 tree_set_bool("placement/center", gtk_toggle_button_get_active(w));
160 void on_place_active_popup_all_activate(GtkMenuItem *w, gpointer data)
164 tree_set_string("placement/monitor", "Any");
167 void on_place_active_popup_active_activate(GtkMenuItem *w, gpointer data)
171 tree_set_string("placement/monitor", "Active");
174 void on_place_active_popup_mouse_activate(GtkMenuItem *w, gpointer data)
178 tree_set_string("placement/monitor", "Mouse");