382
399
#ifndef MAKE_TRANSLATION_SOURCE
383
400
GtkWidget *button;
384
401
static const char *relief[] = { "none", "half", NULL };
403
typedef GtkWidget *(*button_new_t) (const char *);
404
typedef GtkWidget *(*plain_new_t) (void);
405
static const struct {
406
button_new_t stock[2], mnemonic[2], label[2];
407
plain_new_t plain[2];
409
{ gxine_toggle_button_new_from_stock, gtk_button_new_from_stock },
410
{ gtk_toggle_button_new_with_mnemonic, gtk_button_new_with_mnemonic },
411
{ gtk_toggle_button_new_with_label, gtk_button_new_with_label },
412
{ gtk_toggle_button_new, gtk_button_new },
387
416
alt = xml_parser_get_property (node, "alt");
399
428
if (check_stock (image))
400
button = gtk_button_new_from_stock (image);
429
button = newbtn.stock[click] (image);
402
431
button = xml_parser_get_bool (node, "mnemonic")
403
? gtk_button_new_with_mnemonic (TRANSLATE (alt))
404
: gtk_button_new_with_label (TRANSLATE (alt));
432
? newbtn.mnemonic[click] (TRANSLATE (alt))
433
: newbtn.label[click] (TRANSLATE (alt));
407
button = gtk_button_new ();
436
button = newbtn.plain[click] ();
409
438
g_object_set (G_OBJECT (button), "image",
410
439
check_stock (image)
490
519
gtk_button_set_relief (GTK_BUTTON (button),
491
520
2 - lookup_type (node, "relief", relief));
492
/* set the command which is executed when the button is clicked */
493
label = xml_parser_get_property (node, "onclick");
495
command_attach (button, "clicked", "js-onclick", label,
496
_("XML button click"));
523
/* set the command which is executed when the button is clicked */
524
label = xml_parser_get_property (node, "onclick");
526
command_attach (button, "clicked", "js-onclick", label,
527
_("XML button click"));
498
530
#endif /* ! MAKE_TRANSLATION_SOURCE */
559
591
TRANSLATE (*stock->tip ? stock->tip : stock->name),
596
slider_button_cb (GtkWidget *widget, GdkEventButton *ev, gpointer data)
598
gtk_grab_remove (widget);
599
gdk_keyboard_ungrab (ev->time);
600
gdk_pointer_ungrab (ev->time);
601
gtk_widget_hide (widget);
602
gtk_toggle_button_set_active (data, FALSE);
607
slider_widget_button_cb (GtkWidget *widget, GdkEventButton *ev, gpointer data)
609
return slider_button_cb (gtk_widget_get_toplevel (widget), ev, data);
612
#include <gdk/gdkkeysyms.h>
614
slider_key_cb (GtkWidget *window, GdkEventKey *ev, gpointer data)
622
return slider_button_cb (window, (GdkEventButton *) ev, data);
629
slider_window_cb (GtkWidget *button, gpointer window)
631
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
634
gtk_window_set_transient_for (window,
635
GTK_WINDOW (gtk_widget_get_toplevel (button)));
637
GdkWindow *parent = gtk_widget_get_parent_window (button);
639
gdk_window_get_position (parent, &ppos.x, &ppos.y);
640
gdk_drawable_get_size (GDK_DRAWABLE (parent), &ppos.width, &ppos.height);
642
GdkScreen *screen = gtk_widget_get_screen (button);
643
gint monitor = gdk_screen_get_monitor_at_window (screen, parent);
645
gdk_screen_get_monitor_geometry (screen, monitor, &geom);
649
gtk_widget_size_request (window, &req);
650
gtk_window_get_default_size (window, &wx, &wy);
656
wx = button->allocation.x + ppos.x; /* button left */
657
wy = button->allocation.y + ppos.y; /* button top */
659
if (GTK_IS_VSCALE (((GtkBin *) window)->child))
661
/* arrange vertically, preferably below */
662
wx += (button->allocation.width - req.width) / 2; /* centre-aligned */
663
wy += (wy + req.height + button->allocation.height > geom.y + geom.height)
664
? -req.height /* below (if enough space) */
665
: button->allocation.height; /* above */
667
else if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
669
/* arrange vertically, preferably to the left (RTL) */
670
wx -= (wx - req.width < geom.x)
671
? -button->allocation.width /* left (if enough space) */
672
: req.width; /* right */
673
wy += (button->allocation.height - req.height) / 2; /* centre-aligned */
677
/* arrange vertically, preferably to the right (LTR) */
678
wx += (wx + req.width + button->allocation.width > geom.x + geom.width)
679
? -req.width /* right (if enough space) */
680
: button->allocation.width; /* left */
681
wy += (button->allocation.height - req.height) / 2; /* centre-aligned */
684
gtk_window_move (GTK_WINDOW (window), wx, wy);
685
gtk_widget_show_all (window);
687
gdk_keyboard_grab (((GtkWidget *)window)->window, TRUE, GDK_CURRENT_TIME);
688
gdk_pointer_grab (((GtkWidget *)window)->window, TRUE,
689
GDK_BUTTON_RELEASE_MASK, NULL, NULL, GDK_CURRENT_TIME);
690
gtk_grab_add (window);
564
696
static GtkWidget *
567
699
* type string none widget identifer (see stock[].name)
568
700
* vertical bool FALSE slider orientation
701
* inverted bool FALSE slider direction reversal
569
702
* show-value bool FALSE show slider value numerically
703
* popup bool FALSE slider is a popup
704
* (use button properties except onclick)
705
* window-width int -1 popup window width
706
* window-height int -1 popup window height
572
709
#ifndef MAKE_TRANSLATION_SOURCE
710
static const stock_t stock[] = {
574
711
{ BUTTON, Control_PLAY, "play", TN_("Start or resume a stream\n(at normal speed)"),
575
712
GTK_STOCK_MEDIA_PLAY, NULL, "play ();" },
576
713
{ BUTTON, Control_FASTFWD, "forward", TN_("Fast forward"),
588
725
{ SLIDER, Control_COMPRESSOR, TN_("Compressor"), "" },
589
726
{ SLIDER, Control_AMPLIFIER, TN_("Amplifier"), "" },
590
727
{ SLIDER, Control_AV_SYNC, TN_("A/V sync"), "" },
728
{ SLIDER, Control_SPU_SYNC, TN_("SPU sync"), "" },
591
729
{ SLIDER, Control_HUE, TN_("Hue"), "" },
592
730
{ SLIDER, Control_SATURATION, TN_("Saturation"), "" },
593
731
{ SLIDER, Control_CONTRAST, TN_("Contrast"), "" },
685
823
goto do_spin_slider_again;
826
ui_register_adjustment_widget (stock[i].control, w);
688
828
if (GTK_IS_SCALE (w))
830
gtk_scale_set_digits (GTK_SCALE (w), 0);
690
831
gtk_scale_set_draw_value
691
832
(GTK_SCALE (w), xml_parser_get_bool (node, "show-value"));
692
833
gtk_range_set_inverted
693
834
(GTK_RANGE (w), xml_parser_get_bool (node, "inverted"));
835
if (xml_parser_get_bool (node, "popup"))
837
GtkWindow *window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_POPUP));
838
gtk_window_set_default_size (window,
839
xml_parser_get_property_int (node, "window-width", -1),
840
xml_parser_get_property_int (node, "window-height", -1));
841
gtk_window_set_decorated (window, FALSE);
842
gtk_window_set_skip_pager_hint (window, TRUE);
843
gtk_window_set_skip_taskbar_hint (window, TRUE);
844
gtk_container_add (GTK_CONTAINER (window), w);
845
gtk_widget_add_events ((GtkWidget *)window, GDK_BUTTON_RELEASE_MASK);
847
GtkWidget *btn = create_button (node, FALSE);
848
g_object_connect (G_OBJECT (window),
849
"signal::destroy-event", gtk_widget_hide_on_delete, btn,
850
"signal::button-release-event", G_CALLBACK (slider_button_cb), btn,
851
"signal::key-press-event", G_CALLBACK (slider_key_cb), btn,
853
g_signal_connect (G_OBJECT (w), "button-release-event",
854
G_CALLBACK (slider_widget_button_cb), btn);
855
g_signal_connect (G_OBJECT (btn), "toggled",
856
G_CALLBACK (slider_window_cb), window);
857
w = btn; /* for popups, we return the button, not the slider */
696
861
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (w), TRUE);