288
321
if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget))) {
289
322
xine_cfg_entry_t vis_entry;
291
if (gtk_xine_config_lookup_entry (GTK_XINE (gtx), "misc.vis",
324
if (xine_config_lookup_entry (xine, "misc.vis", &vis_entry))
293
326
vis_entry.str_value = "none";
294
gtk_xine_config_update_entry (GTK_XINE(gtx), &vis_entry);
327
xine_config_update_entry (xine, &vis_entry);
296
action_exec ("set_vis (\"none\");", NULL, NULL);
329
engine_exec ("set_vis (\"none\");", NULL, NULL);
300
static void sub_auto_cb (gpointer callback_data,
301
guint callback_action,
303
if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
304
action_exec ("set_sub (-1);", NULL, NULL);
307
static void sub_none_cb (gpointer callback_data,
308
guint callback_action,
310
if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
311
action_exec ("set_sub (-2);", NULL, NULL);
314
static void sub_ch0_cb(gpointer callback_data,
315
guint callback_action,
317
if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
318
action_exec ("set_sub (0);", NULL, NULL);
321
static void sub_ch1_cb(gpointer callback_data,
322
guint callback_action,
324
if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
325
action_exec ("set_sub (1);", NULL, NULL);
328
static void sub_ch2_cb(gpointer callback_data,
329
guint callback_action,
331
if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
332
action_exec ("set_sub (2);", NULL, NULL);
335
static void sub_ch3_cb(gpointer callback_data,
336
guint callback_action,
338
if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
339
action_exec ("set_sub (3);", NULL, NULL);
342
static void sub_ch4_cb(gpointer callback_data,
343
guint callback_action,
345
if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
346
action_exec ("set_sub (4);", NULL, NULL);
349
static void sub_ch5_cb(gpointer callback_data,
350
guint callback_action,
352
if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
353
action_exec ("set_sub (5);", NULL, NULL);
356
static void sub_ch6_cb(gpointer callback_data,
357
guint callback_action,
359
if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
360
action_exec ("set_sub (6);", NULL, NULL);
363
static void sub_ch7_cb(gpointer callback_data,
364
guint callback_action,
366
if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
367
action_exec ("set_sub (7);", NULL, NULL);
333
static void settings_cb(void) {
334
engine_exec ("settings_show ();", NULL, NULL);
337
static void sub_cb (gpointer data, guint action, GtkWidget *widget)
339
if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
340
v_engine_exec ("set_sub (%d);", NULL, NULL, action);
343
static void popdown_idle_cb (GtkWidget *widget)
345
gdk_threads_enter ();
346
gtk_menu_popdown (GTK_MENU(widget));
347
gdk_threads_leave ();
350
static gboolean popup_key_cb (GtkWidget *widget, GdkEventKey *event,
353
if (event->keyval != GDK_F10 || (event->state & GXINE_MODIFIER_MASK))
355
g_idle_add ((GSourceFunc) popdown_idle_cb, widget);
359
#define STOCK(x) "<StockItem>", GTK_STOCK_##x
360
#define ASPECT(x) aspect_cb, XINE_VO_ASPECT_##x
370
361
static GtkItemFactoryEntry menu_items[] = {
371
{ "/_File", NULL, NULL, 0, "<Branch>" },
372
{ "/File/_Open...", "<control>O", open_cb, 0, NULL },
373
{ "/File/Open _MRL...", "<control>M", open_mrl_cb, 0, NULL },
374
{ "/File/sep0", NULL, NULL, 0, "<Separator>" },
375
{ "/File/Preferences...", NULL, preferences_cb, 0, NULL },
376
{ "/File/Keybindings...", NULL, keybindings_cb, 0, NULL },
377
{ "/File/sep1", NULL, NULL, 0, "<Separator>" },
378
{ "/File/sep2", NULL, NULL, 0, "<Separator>" },
379
{ "/File/Snapshot...", "<control>S", snapshot_cb, 0, NULL },
380
{ "/File/sep3", NULL, NULL, 0, "<Separator>" },
381
{ "/File/Quit", "<control>Q", exit_cb, 0, NULL },
382
{ "/_View", NULL, NULL, 0, "<Branch>" },
383
{ "/View/_Fullscreen mode", "<control>F", fullscreen_cb, 0, NULL },
384
{ "/View/sep3", NULL, NULL, 0, "<Separator>" },
385
{ "/View/_50%", NULL, factor_50_cb, 0, NULL },
386
{ "/View/_100%", NULL, factor_100_cb, 0, NULL },
387
{ "/View/_200%", NULL, factor_200_cb, 0, NULL },
388
{ "/View/sep4", NULL, NULL, 0, "<Separator>" },
389
{ "/View/Zoom in", NULL, zoom_in_cb, 0, NULL },
390
{ "/View/Zoom out", NULL, zoom_out_cb, 0, NULL },
391
{ "/View/sep5", NULL, NULL, 0, "<Separator>" },
392
{ "/View/_DeInterlace", "<control>I", deinterlace_cb, 0, "<CheckItem>" },
393
{ "/View/_Aspect ratio", NULL, NULL, 0, "<Branch>" },
394
{ "/View/Aspect ratio/Auto", NULL, aspect_auto_cb, 0, NULL},
395
{ "/View/Aspect ratio/Square",NULL, aspect_square_cb, 0, NULL},
396
{ "/View/Aspect ratio/4:3", NULL, aspect_4_3_cb, 0, NULL},
397
{ "/View/Aspect ratio/16:9", NULL, aspect_16_9_cb, 0, NULL},
398
{ "/View/Aspect ratio/Don't touch", NULL, aspect_dt_cb, 0, NULL},
399
{ "/View/sep6", NULL, NULL, 0, "<Separator>" },
400
{ "/View/_Visualizations", NULL, NULL, 0, "<Branch>" },
401
{ "/View/Visualizations/None", NULL, vis_none_cb, 0, "<RadioItem>"},
402
{ "/View/sep7", NULL, NULL, 0, "<Separator>" },
403
{ "/View/_Subtitles", NULL, NULL, 0, "<Branch>" },
404
{ "/View/Subtitles/Auto", NULL, sub_auto_cb, 0, "<RadioItem>"},
405
{ "/View/Subtitles/None", NULL, sub_none_cb, 0, "/View/Subtitles/Auto"},
406
{ "/View/Subtitles/Channel 0", NULL, sub_ch0_cb, 0, "/View/Subtitles/Auto"},
407
{ "/View/Subtitles/Channel 1", NULL, sub_ch1_cb, 0, "/View/Subtitles/Auto"},
408
{ "/View/Subtitles/Channel 2", NULL, sub_ch2_cb, 0, "/View/Subtitles/Auto"},
409
{ "/View/Subtitles/Channel 3", NULL, sub_ch3_cb, 0, "/View/Subtitles/Auto"},
410
{ "/View/Subtitles/Channel 4", NULL, sub_ch4_cb, 0, "/View/Subtitles/Auto"},
411
{ "/View/Subtitles/Channel 5", NULL, sub_ch5_cb, 0, "/View/Subtitles/Auto"},
412
{ "/View/Subtitles/Channel 6", NULL, sub_ch6_cb, 0, "/View/Subtitles/Auto"},
413
{ "/View/Subtitles/Channel 7", NULL, sub_ch7_cb, 0, "/View/Subtitles/Auto"},
414
{ "/_Media", NULL, NULL, 0, "<Branch>" },
415
{ "/Media/_Add Mediamark...","<control>D", mediamarks_add_cb, 0, NULL },
416
{ "/Media/_Manage Medimarks...","<control>B", mediamarks_manage_cb, 0, NULL },
417
{ "/Media/_Import Medimarks...",NULL, mediamarks_import_cb, 0, NULL },
418
{ "/Media/sep8", NULL, NULL, 0, "<Separator>" },
419
{ "/_Help", NULL, NULL, 0, "<LastBranch>" },
420
{ "/Help/About...", NULL, about_cb, 0, NULL },
421
{ "/Help/Engine _Log...", "<control>L", log_cb, 0, NULL },
422
{ "/Help/Stream _Info...", NULL, stream_info_cb, 0, NULL },
423
{ "/Help/sep6", NULL, NULL, 0, "<Separator>" },
424
{ "/Help/_Re-run setup wizards...", NULL, wizards_cb, 0, NULL },
362
{ N_("/_File"), NULL, NULL, 0, "<Branch>" },
363
{ N_("/File/_Open..."), "<control>O", open_cb, 0, STOCK(OPEN) },
364
{ N_("/File/Open _MRL..."), "<control>M", open_mrl_cb, 0, NULL },
365
{ N_("/File/Play_list..."), NULL, playlist_cb, 0, NULL },
366
{ "/File/sep0", NULL, NULL, 0, "<Separator>" },
367
{ N_("/File/_Preferences..."), NULL, preferences_cb, 0, STOCK(PREFERENCES) },
368
{ N_("/File/_Keybindings..."), NULL, keybindings_cb, 0, NULL },
369
{ "/File/sep1", NULL, NULL, 0, "<Separator>" },
370
{ "/File/sep2", NULL, NULL, 0, "<Separator>" },
371
{ N_("/File/_Snapshot..."), "<control>S", snapshot_cb, 0, NULL },
372
{ "/File/sep3", NULL, NULL, 0, "<Separator>" },
373
{ N_("/File/_Quit"), "<control>Q", exit_cb, 0, STOCK(QUIT) },
374
{ N_("/_View"), NULL, NULL, 0, "<Branch>" },
375
{ N_("/View/_Fullscreen mode"), "<control>F", fullscreen_cb, 0, "<CheckItem>" },
376
{ N_("/View/Fullscreen _toolbar"), NULL, NULL, 0, "<Branch>" },
377
{ N_("/View/Fullscreen toolbar/_Visible"), NULL, tbar_toggle_cb, 0, "<CheckItem>" },
378
{ N_("/View/Fullscreen toolbar/At _top"), NULL, tbar_position_cb, 1, "<RadioItem>" },
379
{ N_("/View/Fullscreen toolbar/At _bottom"), NULL, tbar_position_cb, 0, "/View/Fullscreen toolbar/At top" },
380
{ "/View/sep3", NULL, NULL, 0, "<Separator>" },
381
{ N_("/View/_50%"), NULL, factor_cb, 50, NULL },
382
{ N_("/View/_100%"), NULL, factor_cb, 100, NULL },
383
{ N_("/View/_200%"), NULL, factor_cb, 200, NULL },
384
{ "/View/sep4", NULL, NULL, 0, "<Separator>" },
385
{ N_("/View/Zoom _in"), NULL, zoom_in_cb, 0, STOCK(ZOOM_IN) },
386
{ N_("/View/Zoom _out"), NULL, zoom_out_cb, 0, STOCK(ZOOM_OUT) },
387
{ N_("/View/_Zoom 100%"), NULL, zoom_100_cb, 0, STOCK(ZOOM_100) },
388
{ "/View/sep5", NULL, NULL, 0, "<Separator>" },
389
{ N_("/View/_Deinterlace"), "<control>I", deinterlace_cb, 0, "<CheckItem>" },
390
{ N_("/View/Auto _resize"), NULL, auto_resize_cb, 0, "<CheckItem>" },
391
{ N_("/View/_Aspect ratio"), NULL, NULL, 0, "<Branch>" },
392
{ N_("/View/Aspect ratio/_Auto"), NULL, ASPECT(AUTO), "<RadioItem>" },
393
{ N_("/View/Aspect ratio/_Square"), NULL, ASPECT(SQUARE), "/View/Aspect ratio/Auto"},
394
{ N_("/View/Aspect ratio/_4:3"), NULL, ASPECT(4_3), "/View/Aspect ratio/Auto"},
395
{ N_("/View/Aspect ratio/_16:9"), NULL, ASPECT(ANAMORPHIC), "/View/Aspect ratio/Auto"},
396
{ N_("/View/Aspect ratio/_2:1"), NULL, ASPECT(DVB), "/View/Aspect ratio/Auto"},
397
{ N_("/View/A\\/V _settings..."), NULL, settings_cb, 0, NULL },
398
{ "/View/sep6", NULL, NULL, 0, "<Separator>" },
399
{ N_("/View/_Visualisations"), NULL, NULL, 0, "<Branch>" },
400
{ N_("/View/Visualisations/_None"), NULL, vis_none_cb, 0, "<RadioItem>"},
401
{ "/View/sep7", NULL, NULL, 0, "<Separator>" },
402
{ N_("/View/_Subtitles"), NULL, NULL, 0, "<Branch>" },
403
{ N_("/View/Subtitles/_Auto"), NULL, sub_cb, -1, "<RadioItem>"},
404
{ N_("/View/Subtitles/_None"), NULL, sub_cb, -2, "/View/Subtitles/Auto"},
405
{ N_("/View/Subtitles/Channel _0"), NULL, sub_cb, 0, "/View/Subtitles/Auto"},
406
{ N_("/View/Subtitles/Channel _1"), NULL, sub_cb, 1, "/View/Subtitles/Auto"},
407
{ N_("/View/Subtitles/Channel _2"), NULL, sub_cb, 2, "/View/Subtitles/Auto"},
408
{ N_("/View/Subtitles/Channel _3"), NULL, sub_cb, 3, "/View/Subtitles/Auto"},
409
{ N_("/View/Subtitles/Channel _4"), NULL, sub_cb, 4, "/View/Subtitles/Auto"},
410
{ N_("/View/Subtitles/Channel _5"), NULL, sub_cb, 5, "/View/Subtitles/Auto"},
411
{ N_("/View/Subtitles/Channel _6"), NULL, sub_cb, 6, "/View/Subtitles/Auto"},
412
{ N_("/View/Subtitles/Channel _7"), NULL, sub_cb, 7, "/View/Subtitles/Auto"},
413
{ N_("/_Media"), NULL, NULL, 0, "<Branch>" },
414
{ N_("/Media/_Add media mark..."), "<control>D", mediamarks_add_cb, 0, STOCK(NEW) },
415
{ N_("/Media/_Manage media marks..."), "<control>B", mediamarks_manage_cb, 0, NULL },
416
{ N_("/Media/_Import media marks..."), NULL, mediamarks_import_cb, 0, STOCK(OPEN) },
417
{ "/Media/sep8", NULL, NULL, 0, "<Separator>" },
418
{ N_("/_Help"), NULL, NULL, 0, "<LastBranch>" },
419
{ N_("/Help/_About..."), NULL, about_cb, 0, NULL },
420
{ N_("/Help/Engine _Log..."), "<control>L", log_cb, 0, NULL },
421
{ N_("/Help/Stream _Info..."), NULL, stream_info_cb, 0, NULL },
422
{ "/Help/sep6", NULL, NULL, 0, "<Separator>" },
423
{ N_("/Help/_Re-run setup wizards..."), NULL, wizards_cb, 0, NULL },
427
GtkWidget *create_menus (GtkWidget *window) {
429
GtkAccelGroup *accel_group;
430
gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
426
GtkWidget *create_menu_tree (GtkItemFactory **factory, GtkWidget *window,
427
GtkAccelGroup **accel,
428
GtkItemFactoryEntry *menu_items,
433
GtkAccelGroup *accel_group =
434
(accel && *accel) ? *accel : gtk_accel_group_new ();
436
*accel = accel_group;
437
*factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>",
440
gtk_item_factory_set_translate_func (GTK_ITEM_FACTORY (*factory),
441
(GtkTranslateFunc) gettext,
444
gtk_item_factory_create_items (*factory, nmenu_items, menu_items, NULL);
445
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
449
*factory = gtk_item_factory_new (GTK_TYPE_MENU, "<main>", NULL);
451
gtk_item_factory_set_translate_func (GTK_ITEM_FACTORY (*factory),
452
(GtkTranslateFunc) gettext,
455
gtk_item_factory_create_items (*factory, nmenu_items, menu_items, NULL);
458
return gtk_item_factory_get_widget (*factory, "<main>");
462
void create_menus (GtkWidget *window)
464
GtkItemFactory *item_factory[2];
431
465
GtkRadioMenuItem *none_item;
433
accel_group = gtk_accel_group_new ();
435
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>",
438
gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
440
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
442
media_menu = GTK_MENU_SHELL (gtk_item_factory_get_widget (item_factory, "/Media"));
444
add_autoplay_entries (GTK_MENU_SHELL (gtk_item_factory_get_widget (item_factory, "/File")));
445
none_item = GTK_RADIO_MENU_ITEM (gtk_item_factory_get_item (item_factory, "/View/Visualizations/None"));
446
add_vis_entries (GTK_MENU_SHELL (gtk_item_factory_get_widget (item_factory, "/View/Visualizations")), none_item) ;
449
return gtk_item_factory_get_widget (item_factory, "<main>");
469
menubar = create_menu_tree (&item_factory[0], window, NULL,
470
menu_items, num_menu_items (menu_items));
471
popup_menu = create_menu_tree (&item_factory[1], NULL, NULL,
472
menu_items, num_menu_items (menu_items));
474
for (i = !window; i < 2; ++i)
477
xine_cfg_entry_t entry;
479
media_menu[i] = GTK_MENU_SHELL (gtk_item_factory_get_widget (item_factory[i], "/Media"));
481
fullscreen_menu_item[i] = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Fullscreen mode"));
483
deinterlace_menu_item[i] = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Deinterlace"));
484
if (xine_config_lookup_entry (xine, "gui.deinterlace_by_default", &entry))
485
deinterlace_menu_item[i]->active = entry.num_value;
487
auto_resize_menu_item[i] = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Auto resize"));
488
auto_resize_menu_item[i]->active = TRUE;
490
toolbar_item[0][i] = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Fullscreen toolbar/Visible"));
491
toolbar_item[1][i] = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Fullscreen toolbar/At bottom"));
492
toolbar_item[2][i] = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Fullscreen toolbar/At top"));
493
if (xine_config_lookup_entry (xine, "gui.fullscreen_toolbar", &entry))
495
toolbar_item[0][i]->active = (entry.num_value >> 1) & 1;
496
toolbar_item[1][i]->active = (entry.num_value & 1);
497
toolbar_item[2][i]->active = !(entry.num_value & 1);
500
none_item = GTK_RADIO_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Aspect ratio/Auto"));
501
aspect_menu_items[i] = gtk_radio_menu_item_get_group (none_item);
503
menu = GTK_MENU_SHELL (gtk_item_factory_get_widget (item_factory[i],
505
add_autoplay_entries (menu, g_list_index (menu->children,
506
gtk_item_factory_get_widget (item_factory[i],
509
none_item = GTK_RADIO_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Visualisations/None"));
510
add_vis_entries (GTK_MENU_SHELL (gtk_item_factory_get_widget (item_factory[i], "/View/Visualisations")), none_item);
514
g_signal_connect (GTK_OBJECT(popup_menu), "key-press-event",
515
G_CALLBACK(popup_key_cb), NULL);