From: Darren S. <ds...@us...> - 2005-01-07 18:53:12
|
Update of /cvsroot/xine/gnome-xine/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12468/src Modified Files: globals.h key_events.c noskin_window.c playlist.c Log Message: GTK+2.2 compatibility (shout if it's broken). GTK+2.6 stock icon usage. Compatibility macros intended to allow gxine to work with GTK+ 2.2, 2.4 or 2.6 regardless of which was present at build time. Index: globals.h =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/globals.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- globals.h 25 Dec 2004 01:58:25 -0000 1.20 +++ globals.h 7 Jan 2005 18:52:46 -0000 1.21 @@ -74,4 +74,43 @@ #define CONFIG_DATA_NONE ((void *)1) +/* GTK+ 2.6 compatibility */ +#ifdef GXINE_GTK_COMPAT +# define GTK_COMPAT_2_6(NEWER,OLDER) \ + (gtk_binary_age >= 600 ? (NEWER) : (OLDER)) +#else /* compatibility not requested */ +# if GTK_CHECK_VERSION(2,6,0) /* 2.6 or later */ +# define GTK_COMPAT_2_6(NEWER,OLDER) (NEWER) +# else /* 2.4 or earlier */ +# define GTK_COMPAT_2_6(NEWER,OLDER) (OLDER) +# endif +#endif +#define GTK_TEST_COMPAT_2_6 (GTK_COMPAT_2_6 (TRUE, FALSE)) + +/* GTK+ 2.4 is the preferred version */ + +/* GTK+ 2.2 compatibility */ +#ifdef GXINE_GTK_COMPAT +# define GTK_COMPAT_CALL(FUNC,...) \ + do { if (FUNC) (FUNC)(__VA_ARGS__); } while (0) +void gtk_window_set_keep_above () __attribute__ ((weak)); +void gtk_window_set_default_icon () __attribute__ ((weak)); +void gtk_window_set_accept_focus () __attribute__ ((weak)); +gboolean gtk_window_activate_key () __attribute__ ((weak)); +# define gtk_window_set_keep_above(...) \ + GTK_COMPAT_CALL(gtk_window_set_keep_above,__VA_ARGS__) +# define gtk_window_set_default_icon(...) \ + GTK_COMPAT_CALL(gtk_window_set_default_icon,__VA_ARGS__) +# define gtk_window_set_accept_focus(...) \ + GTK_COMPAT_CALL(gtk_window_set_accept_focus,__VA_ARGS__) +#else /* compatibility not requested */ +# if GTK_CHECK_VERSION(2,4,0) /* 2.4 or later */ +# else /* 2.2 */ +# define gtk_window_set_keep_above(...) +# define gtk_window_set_default_icon(...) +# define gtk_window_set_accept_focus(...) +# define gtk_window_activate_key(...) (0) +# endif +#endif + #endif Index: key_events.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/key_events.c,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- key_events.c 3 Jan 2005 22:06:03 -0000 1.49 +++ key_events.c 7 Jan 2005 18:52:46 -0000 1.50 @@ -772,7 +772,10 @@ gtk_widget_grab_focus (kb_binding_quote); return TRUE; } - + /* GTK+ 2.2 compatibility */ + /* gtk_window_activate_key isn't marked "since 2.4" in the 2.4.x docs :-| */ + if (!gtk_window_activate_key) + return FALSE; if (gtk_window_activate_key (GTK_WINDOW (kb_binding_edit_dlg), event)) return TRUE; } @@ -1378,7 +1381,8 @@ g_signal_connect (GTK_OBJECT(b), "clicked", G_CALLBACK(kb_new_binding), kb_bindings_list_dlg); - b = gtk_button_new_with_mnemonic (_("_Edit")); + b = GTK_COMPAT_2_6 (gtk_button_new_from_stock ("gtk-edit"), + gtk_button_new_with_mnemonic (_("_Edit"))); gtk_box_pack_start (GTK_BOX(hbox), b, FALSE, FALSE, 0); g_signal_connect (GTK_OBJECT(b), "clicked", G_CALLBACK(kb_edit_binding), kb_bindings_list_dlg); Index: noskin_window.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/noskin_window.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- noskin_window.c 15 Dec 2004 23:59:59 -0000 1.35 +++ noskin_window.c 7 Jan 2005 18:52:46 -0000 1.36 @@ -93,10 +93,23 @@ ui_set_status (UI_CURRENT_STATE); } +static GtkWidget *create_empty_button (gboolean toggle) +{ + if (toggle) + { + GtkWidget *button = gtk_toggle_button_new (); + g_signal_connect (GTK_OBJECT(button), "toggled", + G_CALLBACK(toggle_cb), NULL); + return button; + } + return gtk_button_new (); +} + static GtkWidget *add_pix_button_common (GtkWidget *box, GtkWidget *button, char *cmd, char *tip, gboolean start) { gtk_button_set_relief (GTK_BUTTON(button), GTK_RELIEF_NONE); + if (start) gtk_box_pack_start (GTK_BOX(box), button, FALSE, FALSE, 2); else @@ -123,20 +136,23 @@ char *cmd, char *tip, gboolean toggle, gboolean start) { - GtkWidget *button; - - if (toggle) - { - button = gtk_toggle_button_new (); - g_signal_connect (GTK_OBJECT(button), "toggled", - G_CALLBACK(toggle_cb), NULL); - } - else - button = gtk_button_new (); + GtkWidget *button = create_empty_button (toggle); gtk_container_add (GTK_CONTAINER(button), new_pixmap (pixmap_array)); return add_pix_button_common (box, button, cmd, tip, start); } +#ifdef USE_GTK_STOCK_MEDIA +static GtkWidget *add_pix_button_from_stock (GtkWidget *box, const char *stock, + char *cmd, char *tip, + gboolean toggle, gboolean start) +{ + GtkWidget *button = create_empty_button (toggle); + gtk_container_add (GTK_CONTAINER(button), + gtk_image_new_from_stock (stock, GTK_ICON_SIZE_SMALL_TOOLBAR)); + return add_pix_button_common (box, button, cmd, tip, start); +} +#endif + static GtkWidget *add_pix_flip_button (GtkWidget *box, gchar **inactive, gchar **active, char * cmd, char *tip, gboolean start) @@ -456,22 +472,49 @@ /* buttons */ - ui_register_control_button - (Control_PLAY, - add_pix_button (ctrl, play_xpm, "play ();", _("Play"), TRUE, TRUE)); - ui_register_control_button - (Control_FASTFWD, - add_pix_button (ctrl, fast_forward_xpm, - "if (!is_live_stream ()) set_speed (16);", - _("Fast forward"), TRUE, TRUE)); - ui_register_control_button - (Control_PAUSE, - add_pix_button (ctrl, pause_xpm, - "if (!is_live_stream ()) pause ();", - _("Pause"), TRUE, TRUE)); - ui_register_control_button - (Control_STOP, - add_pix_button (ctrl, stop_xpm, "stop ();", _("Stop"), TRUE, TRUE)); +#ifdef USE_GTK_STOCK_MEDIA + /* We don't want the GTK_STOCK_MEDIA_* just yet. */ + if (GTK_TEST_COMPAT_2_6) + { + ui_register_control_button + (Control_PLAY, + add_pix_button_from_stock (ctrl, "gtk-media-play", + "play ();", _("Play"), TRUE, TRUE)); + ui_register_control_button + (Control_FASTFWD, + add_pix_button_from_stock (ctrl, "gtk-media-forward", + "if (!is_live_stream ()) set_speed (16);", + _("Fast forward"), TRUE, TRUE)); + ui_register_control_button + (Control_PAUSE, + add_pix_button_from_stock (ctrl, "gtk-media-pause", + "if (!is_live_stream ()) pause ();", + _("Pause"), TRUE, TRUE)); + ui_register_control_button + (Control_STOP, + add_pix_button_from_stock (ctrl, "gtk-new", //media-stop", + "stop ();", _("Stop"), TRUE, TRUE)); + } + else +#endif + { + ui_register_control_button + (Control_PLAY, + add_pix_button (ctrl, play_xpm, "play ();", _("Play"), TRUE, TRUE)); + ui_register_control_button + (Control_FASTFWD, + add_pix_button (ctrl, fast_forward_xpm, + "if (!is_live_stream ()) set_speed (16);", + _("Fast forward"), TRUE, TRUE)); + ui_register_control_button + (Control_PAUSE, + add_pix_button (ctrl, pause_xpm, + "if (!is_live_stream ()) pause ();", + _("Pause"), TRUE, TRUE)); + ui_register_control_button + (Control_STOP, + add_pix_button (ctrl, stop_xpm, "stop ();", _("Stop"), TRUE, TRUE)); + } add_pix_button (ctrl, playlist_xpm, "playlist_show ()", _("Playlist"), FALSE, TRUE); Index: playlist.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/playlist.c,v retrieving revision 1.101 retrieving revision 1.102 diff -u -r1.101 -r1.102 --- playlist.c 30 Dec 2004 21:04:02 -0000 1.101 +++ playlist.c 7 Jan 2005 18:52:46 -0000 1.102 @@ -1686,7 +1686,8 @@ G_CALLBACK(add_cb), tree_view); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 2); - button = gtk_button_new_with_mnemonic (_("_Edit")); + button = GTK_COMPAT_2_6 (gtk_button_new_from_stock ("gtk-edit"), + gtk_button_new_with_mnemonic (_("_Edit"))); g_signal_connect (GTK_OBJECT(button), "clicked", G_CALLBACK(edit_cb), tree_view); |