]> Dogcows Code - chaz/openbox/blob - openbox/client_menu.c
1) translate all of openbox's output
[chaz/openbox] / openbox / client_menu.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 client_menu.c for the Openbox window manager
4 Copyright (c) 2003-2007 Dana Jansens
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #include "debug.h"
20 #include "menu.h"
21 #include "menuframe.h"
22 #include "screen.h"
23 #include "client.h"
24 #include "openbox.h"
25 #include "frame.h"
26 #include "gettext.h"
27
28 #include <glib.h>
29
30 #define CLIENT_MENU_NAME "client-menu"
31 #define SEND_TO_MENU_NAME "client-send-to-menu"
32 #define LAYER_MENU_NAME "client-layer-menu"
33
34 enum {
35 LAYER_TOP,
36 LAYER_NORMAL,
37 LAYER_BOTTOM
38 };
39
40 enum {
41 CLIENT_SEND_TO,
42 CLIENT_LAYER,
43 CLIENT_ICONIFY,
44 CLIENT_MAXIMIZE,
45 CLIENT_RAISE,
46 CLIENT_LOWER,
47 CLIENT_SHADE,
48 CLIENT_DECORATE,
49 CLIENT_MOVE,
50 CLIENT_RESIZE,
51 CLIENT_CLOSE
52 };
53
54 static void client_update(ObMenuFrame *frame, gpointer data)
55 {
56 ObMenu *menu = frame->menu;
57 ObMenuEntry *e;
58 GList *it;
59
60 for (it = menu->entries; it; it = g_list_next(it)) {
61 e = it->data;
62 if (e->type == OB_MENU_ENTRY_TYPE_NORMAL)
63 e->data.normal.enabled = !!frame->client;
64 }
65
66 if (!frame->client)
67 return;
68
69 e = menu_find_entry_id(menu, CLIENT_ICONIFY);
70 e->data.normal.enabled = frame->client->functions & OB_CLIENT_FUNC_ICONIFY;
71
72 e = menu_find_entry_id(menu, CLIENT_MAXIMIZE);
73 g_free(e->data.normal.label);
74 e->data.normal.label =
75 g_strdup(frame->client->max_vert || frame->client->max_horz ?
76 _("Restore") : _("Maximize"));
77 e->data.normal.enabled =frame->client->functions & OB_CLIENT_FUNC_MAXIMIZE;
78
79 e = menu_find_entry_id(menu, CLIENT_SHADE);
80 g_free(e->data.normal.label);
81 e->data.normal.label = g_strdup(frame->client->shaded ?
82 _("Roll down") : _("Roll up"));
83 e->data.normal.enabled = frame->client->functions & OB_CLIENT_FUNC_SHADE;
84
85 e = menu_find_entry_id(menu, CLIENT_MOVE);
86 e->data.normal.enabled = frame->client->functions & OB_CLIENT_FUNC_MOVE;
87
88 e = menu_find_entry_id(menu, CLIENT_RESIZE);
89 e->data.normal.enabled = frame->client->functions & OB_CLIENT_FUNC_RESIZE;
90
91 e = menu_find_entry_id(menu, CLIENT_CLOSE);
92 e->data.normal.enabled = frame->client->functions & OB_CLIENT_FUNC_CLOSE;
93
94 e = menu_find_entry_id(menu, CLIENT_DECORATE);
95 e->data.normal.enabled = client_normal(frame->client);
96 }
97
98 static void layer_update(ObMenuFrame *frame, gpointer data)
99 {
100 ObMenu *menu = frame->menu;
101 ObMenuEntry *e;
102 GList *it;
103
104 for (it = menu->entries; it; it = g_list_next(it)) {
105 e = it->data;
106 if (e->type == OB_MENU_ENTRY_TYPE_NORMAL)
107 e->data.normal.enabled = !!frame->client;
108 }
109
110 if (!frame->client)
111 return;
112
113 e = menu_find_entry_id(menu, LAYER_TOP);
114 e->data.normal.enabled = !frame->client->above;
115
116 e = menu_find_entry_id(menu, LAYER_NORMAL);
117 e->data.normal.enabled = (frame->client->above || frame->client->below);
118
119 e = menu_find_entry_id(menu, LAYER_BOTTOM);
120 e->data.normal.enabled = !frame->client->below;
121 }
122
123 static void send_to_update(ObMenuFrame *frame, gpointer data)
124 {
125 ObMenu *menu = frame->menu;
126 guint i;
127 GSList *acts;
128 ObAction *act;
129 ObMenuEntry *e;;
130
131 menu_clear_entries(menu);
132
133 if (!frame->client)
134 return;
135
136 for (i = 0; i <= screen_num_desktops; ++i) {
137 const gchar *name;
138 guint desk;
139
140 if (i >= screen_num_desktops) {
141 menu_add_separator(menu, -1, NULL);
142
143 desk = DESKTOP_ALL;
144 name = _("All desktops");
145 } else {
146 desk = i;
147 name = screen_desktop_names[i];
148 }
149
150 act = action_from_string("SendToDesktop",
151 OB_USER_ACTION_MENU_SELECTION);
152 act->data.sendto.desk = desk;
153 act->data.sendto.follow = FALSE;
154 acts = g_slist_prepend(NULL, act);
155 e = menu_add_normal(menu, desk, name, acts);
156
157 if (frame->client->desktop == desk)
158 e->data.normal.enabled = FALSE;
159 }
160 }
161
162 void client_menu_startup()
163 {
164 GSList *acts;
165 ObMenu *menu;
166 ObMenuEntry *e;
167
168 menu = menu_new(LAYER_MENU_NAME, _("Layer"), NULL);
169 menu_set_update_func(menu, layer_update);
170
171 acts = g_slist_prepend(NULL, action_from_string
172 ("SendToTopLayer", OB_USER_ACTION_MENU_SELECTION));
173 menu_add_normal(menu, LAYER_TOP, _("Always on top"), acts);
174
175 acts = g_slist_prepend(NULL, action_from_string
176 ("SendToNormalLayer",
177 OB_USER_ACTION_MENU_SELECTION));
178 menu_add_normal(menu, LAYER_NORMAL, _("Normal"), acts);
179
180 acts = g_slist_prepend(NULL, action_from_string
181 ("SendToBottomLayer",
182 OB_USER_ACTION_MENU_SELECTION));
183 menu_add_normal(menu, LAYER_BOTTOM, _("Always on bottom"),acts);
184
185
186 menu = menu_new(SEND_TO_MENU_NAME, _("Send to desktop"), NULL);
187 menu_set_update_func(menu, send_to_update);
188
189
190 menu = menu_new(CLIENT_MENU_NAME, _("Client menu"), NULL);
191 menu_set_update_func(menu, client_update);
192
193 menu_add_submenu(menu, CLIENT_SEND_TO, SEND_TO_MENU_NAME);
194
195 menu_add_submenu(menu, CLIENT_LAYER, LAYER_MENU_NAME);
196
197 acts = g_slist_prepend(NULL, action_from_string
198 ("Iconify", OB_USER_ACTION_MENU_SELECTION));
199 e = menu_add_normal(menu, CLIENT_ICONIFY, _("Iconify"), acts);
200 e->data.normal.mask = ob_rr_theme->iconify_mask;
201 e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
202 e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;
203 e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color;
204
205 acts = g_slist_prepend(NULL, action_from_string
206 ("ToggleMaximizeFull",
207 OB_USER_ACTION_MENU_SELECTION));
208 e = menu_add_normal(menu, CLIENT_MAXIMIZE, "MAXIMIZE", acts);
209 e->data.normal.mask = ob_rr_theme->max_mask;
210 e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
211 e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;
212 e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color;
213
214 acts = g_slist_prepend(NULL, action_from_string
215 ("Raise", OB_USER_ACTION_MENU_SELECTION));
216 menu_add_normal(menu, CLIENT_RAISE, _("Raise to top"), acts);
217
218 acts = g_slist_prepend(NULL, action_from_string
219 ("Lower", OB_USER_ACTION_MENU_SELECTION));
220 menu_add_normal(menu, CLIENT_LOWER, _("Lower to bottom"),acts);
221
222 acts = g_slist_prepend(NULL, action_from_string
223 ("ToggleShade", OB_USER_ACTION_MENU_SELECTION));
224 e = menu_add_normal(menu, CLIENT_SHADE, "SHADE", acts);
225 e->data.normal.mask = ob_rr_theme->shade_mask;
226 e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
227 e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;
228 e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color;
229
230 acts = g_slist_prepend(NULL, action_from_string
231 ("ToggleDecorations",
232 OB_USER_ACTION_MENU_SELECTION));
233 menu_add_normal(menu, CLIENT_DECORATE, _("Decorate"), acts);
234
235 menu_add_separator(menu, -1, NULL);
236
237 acts = g_slist_prepend(NULL, action_from_string
238 ("Move", OB_USER_ACTION_MENU_SELECTION));
239 menu_add_normal(menu, CLIENT_MOVE, _("Move"), acts);
240
241 acts = g_slist_prepend(NULL, action_from_string
242 ("Resize", OB_USER_ACTION_MENU_SELECTION));
243 menu_add_normal(menu, CLIENT_RESIZE, _("Resize"), acts);
244
245 menu_add_separator(menu, -1, NULL);
246
247 acts = g_slist_prepend(NULL, action_from_string
248 ("Close", OB_USER_ACTION_MENU_SELECTION));
249 e = menu_add_normal(menu, CLIENT_CLOSE, _("Close"), acts);
250 e->data.normal.mask = ob_rr_theme->close_mask;
251 e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
252 e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;
253 e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color;
254 }
This page took 0.043726 seconds and 4 git commands to generate.