Commit | Line | Data |
---|---|---|
460b9539 | 1 | /* |
2 | * This file is part of DisOrder. | |
3697ed99 | 3 | * Copyright (C) 2006-2009, 2011, 2013 Richard Kettlewell |
460b9539 | 4 | * |
e7eb3a27 | 5 | * This program is free software: you can redistribute it and/or modify |
460b9539 | 6 | * it under the terms of the GNU General Public License as published by |
e7eb3a27 | 7 | * the Free Software Foundation, either version 3 of the License, or |
460b9539 | 8 | * (at your option) any later version. |
9 | * | |
e7eb3a27 RK |
10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
460b9539 | 15 | * You should have received a copy of the GNU General Public License |
e7eb3a27 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
460b9539 | 17 | */ |
2c348789 RK |
18 | /** @file disobedience/menu.c |
19 | * @brief Main menu | |
20 | */ | |
460b9539 | 21 | |
22 | #include "disobedience.h" | |
23 | ||
96295b25 RK |
24 | static void toggled_minimode(GtkCheckMenuItem *item, gpointer userdata); |
25 | ||
460b9539 | 26 | static GtkWidget *selectall_widget; |
fb009628 | 27 | static GtkWidget *selectnone_widget; |
460b9539 | 28 | static GtkWidget *properties_widget; |
5b36cfe3 | 29 | GtkWidget *menu_playlists_widget; |
f9b20469 | 30 | GtkWidget *playlists_menu; |
5b36cfe3 | 31 | GtkWidget *menu_editplaylists_widget; |
96295b25 | 32 | static GtkWidget *menu_minimode_widget; |
a2364abb | 33 | static GtkWidget *apis_menu; |
460b9539 | 34 | |
ac6bf2ba RK |
35 | /** @brief Main menu widgets */ |
36 | GtkItemFactory *mainmenufactory; | |
37 | ||
96295b25 | 38 | /** @brief Set for full mode, clear for mini mode */ |
01237e47 | 39 | int full_mode = 1; |
96295b25 | 40 | |
06bfbba4 | 41 | static void about_popup_got_version(void *v, |
e2717131 | 42 | const char *err, |
06bfbba4 | 43 | const char *value); |
460b9539 | 44 | |
2c348789 RK |
45 | /** @brief Called when the quit option is activated |
46 | * | |
47 | * Just exits. | |
48 | */ | |
460b9539 | 49 | static void quit_program(gpointer attribute((unused)) callback_data, |
50 | guint attribute((unused)) callback_action, | |
51 | GtkWidget attribute((unused)) *menu_item) { | |
52 | D(("quit_program")); | |
53 | exit(0); | |
54 | } | |
55 | ||
d9a92920 | 56 | /** @brief Called when an edit menu item is selected |
2c348789 | 57 | * |
d9a92920 RK |
58 | * Shared by several menu items; callback_action is expected to be the offset |
59 | * of the activate member of struct tabtype. | |
2c348789 | 60 | */ |
d9a92920 RK |
61 | static void menu_tab_action(gpointer attribute((unused)) callback_data, |
62 | guint callback_action, | |
460b9539 | 63 | GtkWidget attribute((unused)) *menu_item) { |
64 | GtkWidget *tab = gtk_notebook_get_nth_page | |
65 | (GTK_NOTEBOOK(tabs), gtk_notebook_current_page(GTK_NOTEBOOK(tabs))); | |
66 | const struct tabtype *t = g_object_get_data(G_OBJECT(tab), "type"); | |
67 | ||
d9a92920 RK |
68 | void (**activatep)(GtkMenuItem *, gpointer) |
69 | = (void *)((const char *)t + callback_action); | |
70 | void (*activate)(GtkMenuItem *, gpointer) = *activatep; | |
71 | ||
72 | if(activate) | |
73 | activate(NULL, t->extra); | |
460b9539 | 74 | } |
75 | ||
73f1b9f3 RK |
76 | /** @brief Called when the login option is activated */ |
77 | static void login(gpointer attribute((unused)) callback_data, | |
78 | guint attribute((unused)) callback_action, | |
79 | GtkWidget attribute((unused)) *menu_item) { | |
80 | login_box(); | |
81 | } | |
82 | ||
ffc4dbaf RK |
83 | /** @brief Called when the login option is activated */ |
84 | static void users(gpointer attribute((unused)) callback_data, | |
85 | guint attribute((unused)) callback_action, | |
86 | GtkWidget attribute((unused)) *menu_item) { | |
87 | manage_users(); | |
88 | } | |
89 | ||
46fb1b05 RK |
90 | #if 0 |
91 | /** @brief Called when the settings option is activated */ | |
92 | static void settings(gpointer attribute((unused)) callback_data, | |
93 | guint attribute((unused)) callback_action, | |
94 | GtkWidget attribute((unused)) *menu_item) { | |
95 | popup_settings(); | |
96 | } | |
97 | #endif | |
98 | ||
229d327f | 99 | /** @brief Called when edit menu is shown |
2c348789 RK |
100 | * |
101 | * Determines option sensitivity according to the current tab and adjusts the | |
102 | * widgets accordingly. Knows about @ref DISORDER_CONNECTED so the callbacks | |
103 | * need not. | |
104 | */ | |
229d327f RK |
105 | static void edit_menu_show(GtkWidget attribute((unused)) *widget, |
106 | gpointer attribute((unused)) user_data) { | |
961d31f6 RK |
107 | if(tabs) { |
108 | GtkWidget *tab = gtk_notebook_get_nth_page | |
109 | (GTK_NOTEBOOK(tabs), | |
229d327f | 110 | gtk_notebook_current_page(GTK_NOTEBOOK(tabs))); |
961d31f6 RK |
111 | const struct tabtype *t = g_object_get_data(G_OBJECT(tab), "type"); |
112 | ||
113 | assert(t != 0); | |
114 | gtk_widget_set_sensitive(properties_widget, | |
ee7552f8 RK |
115 | (t->properties_sensitive |
116 | && t->properties_sensitive(t->extra) | |
961d31f6 RK |
117 | && (disorder_eclient_state(client) & DISORDER_CONNECTED))); |
118 | gtk_widget_set_sensitive(selectall_widget, | |
ee7552f8 RK |
119 | t->selectall_sensitive |
120 | && t->selectall_sensitive(t->extra)); | |
961d31f6 | 121 | gtk_widget_set_sensitive(selectnone_widget, |
ee7552f8 RK |
122 | t->selectnone_sensitive |
123 | && t->selectnone_sensitive(t->extra)); | |
961d31f6 | 124 | } |
460b9539 | 125 | } |
fc36ecb7 | 126 | |
2c348789 | 127 | /** @brief Fetch version in order to display the about... popup */ |
460b9539 | 128 | static void about_popup(gpointer attribute((unused)) callback_data, |
129 | guint attribute((unused)) callback_action, | |
130 | GtkWidget attribute((unused)) *menu_item) { | |
131 | D(("about_popup")); | |
132 | ||
133 | gtk_label_set_text(GTK_LABEL(report_label), "getting server version"); | |
134 | disorder_eclient_version(client, | |
135 | about_popup_got_version, | |
136 | 0); | |
137 | } | |
138 | ||
13affe66 RK |
139 | static void manual_popup(gpointer attribute((unused)) callback_data, |
140 | guint attribute((unused)) callback_action, | |
141 | GtkWidget attribute((unused)) *menu_item) { | |
142 | D(("manual_popup")); | |
143 | ||
ad424400 | 144 | popup_help(NULL); |
13affe66 RK |
145 | } |
146 | ||
883a4e96 | 147 | /** @brief Called when version arrives, displays about... popup */ |
460b9539 | 148 | static void about_popup_got_version(void attribute((unused)) *v, |
abf99697 | 149 | const char attribute((unused)) *err, |
460b9539 | 150 | const char *value) { |
151 | GtkWidget *w; | |
152 | char *server_version_string; | |
54cca6d6 | 153 | char *short_version_string; |
413b30a4 | 154 | GtkWidget *hbox, *vbox, *title; |
460b9539 | 155 | |
06bfbba4 RK |
156 | if(!value) |
157 | value = "[error]"; | |
3697ed99 | 158 | byte_xasprintf(&server_version_string, "DisOrder server version %s", value); |
54cca6d6 RK |
159 | byte_xasprintf(&short_version_string, "Disobedience %s", |
160 | disorder_short_version_string); | |
413b30a4 | 161 | w = gtk_dialog_new_with_buttons("About Disobedience", |
460b9539 | 162 | GTK_WINDOW(toplevel), |
163 | (GTK_DIALOG_MODAL | |
164 | |GTK_DIALOG_DESTROY_WITH_PARENT), | |
165 | GTK_STOCK_OK, | |
166 | GTK_RESPONSE_ACCEPT, | |
167 | (char *)NULL); | |
413b30a4 RK |
168 | hbox = gtk_hbox_new(FALSE/*homogeneous*/, 1/*padding*/); |
169 | vbox = gtk_vbox_new(FALSE/*homogeneous*/, 1/*padding*/); | |
170 | gtk_box_pack_start(GTK_BOX(hbox), | |
171 | gtk_image_new_from_pixbuf(find_image("duck.png")), | |
172 | FALSE/*expand*/, | |
173 | FALSE/*fill*/, | |
174 | 4/*padding*/); | |
175 | gtk_box_pack_start(GTK_BOX(vbox), | |
54cca6d6 | 176 | gtk_label_new(short_version_string), |
413b30a4 RK |
177 | FALSE/*expand*/, |
178 | FALSE/*fill*/, | |
179 | 1/*padding*/); | |
180 | gtk_box_pack_start(GTK_BOX(vbox), | |
181 | gtk_label_new(server_version_string), | |
182 | FALSE/*expand*/, | |
183 | FALSE/*fill*/, | |
184 | 1/*padding*/); | |
185 | gtk_box_pack_start(GTK_BOX(vbox), | |
3697ed99 | 186 | gtk_label_new("\xC2\xA9 2003-2013 Richard Kettlewell et al"), |
413b30a4 RK |
187 | FALSE/*expand*/, |
188 | FALSE/*fill*/, | |
189 | 1/*padding*/); | |
190 | gtk_box_pack_end(GTK_BOX(hbox), | |
191 | vbox, | |
192 | FALSE/*expand*/, | |
193 | FALSE/*fill*/, | |
194 | 0/*padding*/); | |
195 | title = gtk_label_new(0); | |
196 | gtk_label_set_markup(GTK_LABEL(title), | |
197 | "<span font_desc=\"Sans 36\">Disobedience</span>"); | |
198 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(w)->vbox), title, | |
199 | FALSE/*expand*/, | |
200 | FALSE/*fill*/, | |
201 | 0/*padding*/); | |
202 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(w)->vbox), hbox, | |
203 | FALSE/*expand*/, | |
204 | FALSE/*fill*/, | |
205 | 0/*padding*/); | |
76fc02c5 | 206 | set_tool_colors(w); |
460b9539 | 207 | gtk_widget_show_all(w); |
208 | gtk_dialog_run(GTK_DIALOG(w)); | |
209 | gtk_widget_destroy(w); | |
210 | } | |
211 | ||
c73bd6c1 RK |
212 | /** @brief Set 'Manage Users' menu item sensitivity */ |
213 | void users_set_sensitive(int sensitive) { | |
214 | GtkWidget *w = gtk_item_factory_get_widget(mainmenufactory, | |
215 | "<GdisorderMain>/Server/Manage users"); | |
216 | gtk_widget_set_sensitive(w, sensitive); | |
217 | } | |
218 | ||
73acd48d RK |
219 | static void menu_check_userman(void attribute((unused)) *v, |
220 | const char *err, | |
221 | const char attribute((unused)) *value) { | |
222 | if(err && !strncmp(err, "510", 3)) | |
223 | users_set_sensitive(FALSE); | |
224 | else | |
225 | users_set_sensitive(TRUE); | |
226 | } | |
227 | ||
6f09d54d RK |
228 | /** @brief Called when our rights change */ |
229 | static void menu_rights_changed(const char attribute((unused)) *event, | |
230 | void attribute((unused)) *eventdata, | |
231 | void attribute((unused)) *callbackdata) { | |
73acd48d RK |
232 | if(last_rights & RIGHT_ADMIN) |
233 | disorder_eclient_userinfo(client, menu_check_userman, "", "email", 0); | |
234 | else | |
235 | users_set_sensitive(FALSE); | |
c73bd6c1 RK |
236 | } |
237 | ||
a2364abb RK |
238 | /** @brief Called to select the network playback API */ |
239 | static void rtp_menu_activate(GtkMenuItem *menuitem, | |
240 | gpointer user_data) { | |
241 | if(GTK_CHECK_MENU_ITEM(menuitem)->active) | |
242 | change_rtp_api(user_data); | |
243 | } | |
244 | ||
2c348789 | 245 | /** @brief Create the menu bar widget */ |
5602a92f | 246 | GtkWidget *menubar(GtkWidget *window) { |
d4ef4132 RK |
247 | GtkWidget *m; |
248 | ||
460b9539 | 249 | static const GtkItemFactoryEntry entries[] = { |
2d504956 | 250 | { |
eb80584d | 251 | (char *)"/Server", /* path */ |
2d504956 RK |
252 | 0, /* accelerator */ |
253 | 0, /* callback */ | |
254 | 0, /* callback_action */ | |
255 | (char *)"<Branch>", /* item_type */ | |
256 | 0 /* extra_data */ | |
257 | }, | |
258 | { | |
eb80584d | 259 | (char *)"/Server/Login", /* path */ |
2d504956 RK |
260 | (char *)"<CTRL>L", /* accelerator */ |
261 | login, /* callback */ | |
262 | 0, /* callback_action */ | |
263 | 0, /* item_type */ | |
264 | 0 /* extra_data */ | |
265 | }, | |
ffc4dbaf | 266 | { |
eb80584d | 267 | (char *)"/Server/Manage users", /* path */ |
ffc4dbaf RK |
268 | 0, /* accelerator */ |
269 | users, /* callback */ | |
270 | 0, /* callback_action */ | |
271 | 0, /* item_type */ | |
272 | 0 /* extra_data */ | |
273 | }, | |
46fb1b05 RK |
274 | #if 0 |
275 | { | |
eb80584d | 276 | (char *)"/Server/Settings", /* path */ |
46fb1b05 RK |
277 | 0, /* accelerator */ |
278 | settings, /* callback */ | |
279 | 0, /* callback_action */ | |
280 | 0, /* item_type */ | |
281 | 0 /* extra_data */ | |
282 | }, | |
283 | #endif | |
2d504956 | 284 | { |
eb80584d | 285 | (char *)"/Server/Quit Disobedience", /* path */ |
2d504956 RK |
286 | (char *)"<CTRL>Q", /* accelerator */ |
287 | quit_program, /* callback */ | |
288 | 0, /* callback_action */ | |
289 | (char *)"<StockItem>", /* item_type */ | |
290 | GTK_STOCK_QUIT /* extra_data */ | |
291 | }, | |
ac6bf2ba | 292 | |
2d504956 RK |
293 | { |
294 | (char *)"/Edit", /* path */ | |
295 | 0, /* accelerator */ | |
296 | 0, /* callback */ | |
297 | 0, /* callback_action */ | |
298 | (char *)"<Branch>", /* item_type */ | |
299 | 0 /* extra_data */ | |
300 | }, | |
301 | { | |
302 | (char *)"/Edit/Select all tracks", /* path */ | |
a99b7c50 | 303 | (char *)"<CTRL>A", /* accelerator */ |
d9a92920 RK |
304 | menu_tab_action, /* callback */ |
305 | offsetof(struct tabtype, selectall_activate), /* callback_action */ | |
5170c61b RK |
306 | (char *)"<StockItem>", /* item_type */ |
307 | GTK_STOCK_SELECT_ALL, /* extra_data */ | |
2d504956 | 308 | }, |
fb009628 RK |
309 | { |
310 | (char *)"/Edit/Deselect all tracks", /* path */ | |
a99b7c50 | 311 | (char *)"<CTRL><SHIFT>A", /* accelerator */ |
d9a92920 RK |
312 | menu_tab_action, /* callback */ |
313 | offsetof(struct tabtype, selectnone_activate), /* callback_action */ | |
fb009628 RK |
314 | 0, /* item_type */ |
315 | 0 /* extra_data */ | |
316 | }, | |
2d504956 RK |
317 | { |
318 | (char *)"/Edit/Track properties", /* path */ | |
319 | 0, /* accelerator */ | |
d9a92920 RK |
320 | menu_tab_action, /* callback */ |
321 | offsetof(struct tabtype, properties_activate), /* callback_action */ | |
5170c61b RK |
322 | (char *)"<StockItem>", /* item_type */ |
323 | GTK_STOCK_PROPERTIES, /* extra_data */ | |
2d504956 | 324 | }, |
fc36ecb7 RK |
325 | { |
326 | (char *)"/Edit/Edit playlists", /* path */ | |
327 | 0, /* accelerator */ | |
f06a754c | 328 | playlist_window_create, /* callback */ |
fc36ecb7 RK |
329 | 0, /* callback_action */ |
330 | 0, /* item_type */ | |
331 | 0 /* extra_data */ | |
332 | }, | |
333 | ||
2d504956 RK |
334 | |
335 | { | |
336 | (char *)"/Control", /* path */ | |
337 | 0, /* accelerator */ | |
338 | 0, /* callback */ | |
339 | 0, /* callback_action */ | |
340 | (char *)"<Branch>", /* item_type */ | |
341 | 0 /* extra_data */ | |
342 | }, | |
343 | { | |
344 | (char *)"/Control/Scratch", /* path */ | |
345 | (char *)"<CTRL>S", /* accelerator */ | |
346 | 0, /* callback */ | |
347 | 0, /* callback_action */ | |
5170c61b RK |
348 | (char *)"<StockItem>", /* item_type */ |
349 | GTK_STOCK_STOP, /* extra_data */ | |
2d504956 | 350 | }, |
685bdfbd RK |
351 | { |
352 | (char *)"/Control/Playing", /* path */ | |
353 | (char *)"<CTRL>P", /* accelerator */ | |
354 | 0, /* callback */ | |
355 | 0, /* callback_action */ | |
356 | (char *)"<CheckItem>", /* item_type */ | |
357 | 0 /* extra_data */ | |
358 | }, | |
2d504956 RK |
359 | { |
360 | (char *)"/Control/Random play", /* path */ | |
361 | (char *)"<CTRL>R", /* accelerator */ | |
362 | 0, /* callback */ | |
685bdfbd RK |
363 | 0, /* callback_action */ |
364 | (char *)"<CheckItem>", /* item_type */ | |
365 | 0 /* extra_data */ | |
366 | }, | |
367 | { | |
368 | (char *)"/Control/Network player", /* path */ | |
369 | (char *)"<CTRL>N", /* accelerator */ | |
370 | 0, /* callback */ | |
2d504956 RK |
371 | 0, /* callback_action */ |
372 | (char *)"<CheckItem>", /* item_type */ | |
373 | 0 /* extra_data */ | |
374 | }, | |
96295b25 RK |
375 | { |
376 | (char *)"/Control/Compact mode", /* path */ | |
377 | (char *)"<CTRL>M", /* accelerator */ | |
378 | 0, /* callback */ | |
379 | 0, /* callback_action */ | |
380 | (char *)"<CheckItem>", /* item_type */ | |
381 | 0 /* extra_data */ | |
382 | }, | |
7791f6cf | 383 | { |
e5cce183 RK |
384 | (char *)"/Control/Global Preferences", /* path */ |
385 | (char *)"<CTRL>G", /* accelerator */ | |
386 | popup_globals, /* callback */ | |
7791f6cf RK |
387 | 0, /* callback_action */ |
388 | 0, /* item_type */ | |
389 | 0 /* extra_data */ | |
390 | }, | |
fc36ecb7 RK |
391 | { |
392 | (char *)"/Control/Activate playlist", /* path */ | |
393 | 0, /* accelerator */ | |
394 | 0, /* callback */ | |
395 | 0, /* callback_action */ | |
396 | (char *)"<Branch>", /* item_type */ | |
397 | 0 /* extra_data */ | |
398 | }, | |
a2364abb RK |
399 | { |
400 | (char *)"/Control/Network Playback API", /* path */ | |
401 | 0, /* accelerator */ | |
402 | 0, /* callback */ | |
403 | 0, /* callback_action */ | |
404 | (char *)"<Branch>", /* item_type */ | |
405 | 0 /* extra_data */ | |
406 | }, | |
aeec47be | 407 | |
2d504956 RK |
408 | { |
409 | (char *)"/Help", /* path */ | |
410 | 0, /* accelerator */ | |
411 | 0, /* callback */ | |
412 | 0, /* callback_action */ | |
413 | (char *)"<Branch>", /* item_type */ | |
414 | 0 /* extra_data */ | |
415 | }, | |
13affe66 | 416 | { |
7e960883 | 417 | (char *)"/Help/Manual", /* path */ |
13affe66 RK |
418 | 0, /* accelerator */ |
419 | manual_popup, /* callback */ | |
420 | 0, /* callback_action */ | |
5170c61b RK |
421 | (char *)"<StockItem>", /* item_type */ |
422 | GTK_STOCK_HELP, /* extra_data */ | |
13affe66 | 423 | }, |
2d504956 | 424 | { |
3697ed99 | 425 | (char *)"/Help/About Disobedience", /* path */ |
2d504956 RK |
426 | 0, /* accelerator */ |
427 | about_popup, /* callback */ | |
428 | 0, /* callback_action */ | |
429 | (char *)"<StockItem>", /* item_type */ | |
430 | GTK_STOCK_ABOUT /* extra_data */ | |
431 | }, | |
460b9539 | 432 | }; |
433 | ||
460b9539 | 434 | GtkAccelGroup *accel = gtk_accel_group_new(); |
435 | ||
436 | D(("add_menubar")); | |
437 | /* TODO: item factories are deprecated in favour of some XML thing */ | |
ac6bf2ba RK |
438 | mainmenufactory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<GdisorderMain>", |
439 | accel); | |
440 | gtk_item_factory_create_items(mainmenufactory, | |
460b9539 | 441 | sizeof entries / sizeof *entries, |
442 | (GtkItemFactoryEntry *)entries, | |
443 | 0); | |
5602a92f | 444 | gtk_window_add_accel_group(GTK_WINDOW(window), accel); |
ac6bf2ba | 445 | selectall_widget = gtk_item_factory_get_widget(mainmenufactory, |
39fe1014 | 446 | "<GdisorderMain>/Edit/Select all tracks"); |
fb009628 RK |
447 | selectnone_widget = gtk_item_factory_get_widget(mainmenufactory, |
448 | "<GdisorderMain>/Edit/Deselect all tracks"); | |
ac6bf2ba | 449 | properties_widget = gtk_item_factory_get_widget(mainmenufactory, |
39fe1014 | 450 | "<GdisorderMain>/Edit/Track properties"); |
fdea9f40 | 451 | menu_playlists_widget = gtk_item_factory_get_item(mainmenufactory, |
fc36ecb7 RK |
452 | "<GdisorderMain>/Control/Activate playlist"); |
453 | playlists_menu = gtk_item_factory_get_widget(mainmenufactory, | |
454 | "<GdisorderMain>/Control/Activate playlist"); | |
a2364abb RK |
455 | apis_menu = gtk_item_factory_get_widget(mainmenufactory, |
456 | "<GdisorderMain>/Control/Network Playback API"); | |
fdea9f40 | 457 | menu_editplaylists_widget = gtk_item_factory_get_widget(mainmenufactory, |
6acdbba4 | 458 | "<GdisorderMain>/Edit/Edit playlists"); |
96295b25 RK |
459 | menu_minimode_widget = gtk_item_factory_get_widget(mainmenufactory, |
460 | "<GdisorderMain>/Control/Compact mode"); | |
460b9539 | 461 | assert(selectall_widget != 0); |
fb009628 | 462 | assert(selectnone_widget != 0); |
460b9539 | 463 | assert(properties_widget != 0); |
5b36cfe3 | 464 | assert(menu_playlists_widget != 0); |
fc36ecb7 | 465 | assert(playlists_menu != 0); |
5b36cfe3 | 466 | assert(menu_editplaylists_widget != 0); |
a2364abb | 467 | assert(apis_menu != 0); |
229d327f | 468 | |
229d327f RK |
469 | GtkWidget *edit_widget = gtk_item_factory_get_widget(mainmenufactory, |
470 | "<GdisorderMain>/Edit"); | |
229d327f | 471 | g_signal_connect(edit_widget, "show", G_CALLBACK(edit_menu_show), 0); |
fc36ecb7 | 472 | |
6f09d54d RK |
473 | event_register("rights-changed", menu_rights_changed, 0); |
474 | users_set_sensitive(0); | |
d4ef4132 RK |
475 | m = gtk_item_factory_get_widget(mainmenufactory, |
476 | "<GdisorderMain>"); | |
477 | set_tool_colors(m); | |
96295b25 RK |
478 | if(menu_minimode_widget) |
479 | g_signal_connect(G_OBJECT(menu_minimode_widget), "toggled", | |
480 | G_CALLBACK(toggled_minimode), NULL); | |
a2364abb RK |
481 | |
482 | /* Populate the APIs menu */ | |
483 | GSList *playback_menu_group = NULL; | |
484 | load_rtp_config(); | |
485 | assert(rtp_api != NULL); | |
486 | for(int n = 0; uaudio_apis[n]; ++n) { | |
487 | if(uaudio_apis[n]->flags & UAUDIO_API_CLIENT) { | |
488 | GtkWidget *mw = gtk_radio_menu_item_new_with_label(playback_menu_group, | |
489 | uaudio_apis[n]->name); | |
490 | playback_menu_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(mw)); | |
491 | gtk_menu_shell_append(GTK_MENU_SHELL(apis_menu), mw); | |
492 | /* Tick the currently selected API... */ | |
493 | if(!strcmp(uaudio_apis[n]->name, rtp_api)) | |
494 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mw), TRUE); | |
495 | /* ...and only then connect the signal */ | |
496 | g_signal_connect(mw, "toggled", G_CALLBACK(rtp_menu_activate), | |
497 | (char *)uaudio_apis[n]->name); | |
498 | } | |
499 | } | |
500 | ||
d4ef4132 | 501 | return m; |
460b9539 | 502 | } |
503 | ||
96295b25 RK |
504 | static void toggled_minimode(GtkCheckMenuItem *item, |
505 | gpointer attribute((unused)) userdata) { | |
ecf9efdb RK |
506 | int new_full_mode = !gtk_check_menu_item_get_active(item); |
507 | if(full_mode != new_full_mode) { | |
508 | full_mode = new_full_mode; | |
509 | event_raise("mini-mode-changed", NULL); | |
510 | } | |
96295b25 RK |
511 | } |
512 | ||
460b9539 | 513 | /* |
514 | Local Variables: | |
515 | c-basic-offset:2 | |
516 | comment-column:40 | |
517 | fill-column:79 | |
518 | indent-tabs-mode:nil | |
519 | End: | |
520 | */ |