From: Julien M. <do...@us...> - 2003-01-21 14:04:56
|
CVS Root: /cvsroot/gstreamer Module: gst-player Changes by: dolphy Date: Tue Jan 21 2003 06:04:54 PST Log message: Gtk-Playlist should now work uninstalled Added GCONF_PREFIX in config.h for Gtk-Playlist repeat toggle Repeat toggle added in the schemas file Integrated more recent Gtk-Playlist sources from Totem thanks to hadess Modified files: . : configure.ac gst-player.schemas libs/gst/player : gstmediaplay.c gtk-playlist.c gtk-playlist.h Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/configure.ac.diff?r1=1.54&r2=1.55 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/gst-player.schemas.diff?r1=1.3&r2=1.4 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstmediaplay.c.diff?r1=1.78&r2=1.79 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gtk-playlist.c.diff?r1=1.1&r2=1.2 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gtk-playlist.h.diff?r1=1.1&r2=1.2 ====Begin Diffs==== Index: configure.ac =================================================================== RCS file: /cvsroot/gstreamer/gst-player/configure.ac,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- configure.ac 19 Jan 2003 09:56:26 -0000 1.54 +++ configure.ac 21 Jan 2003 14:04:40 -0000 1.55 @@ -17,6 +17,10 @@ AC_DEFINE_UNQUOTED(GLADEUI_UNINSTALLED_DIR,"`pwd`/ui",[path to glade ui dir]) AC_SUBST(GLADEUI_UNINSTALLED_DIR) +dnl gconf prefix for gst-player +AC_DEFINE_UNQUOTED(GCONF_PREFIX,"/apps/gst-player",[gconf keys prefix for gst-player]) +AC_SUBST(GCONF_PREFIX) + ACLOCAL="$ACLOCAL -I common/m4 $ACLOCAL_FLAGS" AC_PROG_CC Index: gst-player.schemas =================================================================== RCS file: /cvsroot/gstreamer/gst-player/gst-player.schemas,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- gst-player.schemas 22 Sep 2002 17:33:20 -0000 1.3 +++ gst-player.schemas 21 Jan 2003 14:04:40 -0000 1.4 @@ -12,10 +12,11 @@ <long>Default TRUE booleans</long> </locale> </schema> - + <schema> <key>/schemas/apps/gst-player/default-FALSE-booleans</key> <applyto>/apps/gst-player/play-on-startup</applyto> + <applyto>/apps/gst-player/repeat</applyto> <owner>gst-player</owner> <type>bool</type> <default>FALSE</default> Index: gstmediaplay.c =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstmediaplay.c,v retrieving revision 1.78 retrieving revision 1.79 diff -u -d -r1.78 -r1.79 --- gstmediaplay.c 21 Jan 2003 08:56:59 -0000 1.78 +++ gstmediaplay.c 21 Jan 2003 14:04:40 -0000 1.79 @@ -40,7 +40,14 @@ static void gst_media_play_have_video_size (GstPlay *play, gint width, gint height, GstMediaPlay *mplay); static void gst_media_play_state_change (GstPlay *play, GstElementState old_state, GstElementState new_state, GstMediaPlay *mplay); static void gst_media_play_information (GstPlay *play, GstElement* element, GParamSpec *param, GstMediaPlay *mplay); -static GladeXML* gst_media_play_get_glade_xml (const char *fname, const char *root, const char *domain); + +gchar* gst_media_play_get_glade_file ( const char *fname); +GladeXML* gst_media_play_get_glade_xml_from_file ( const char *fname, + const char *root, + const char *domain); +GladeXML* gst_media_play_get_glade_xml ( const char *fname, + const char *root, + const char *domain); static gboolean gst_media_play_hide_mouse_cursor (GstMediaPlay *mplay); @@ -233,7 +240,9 @@ if (logo_path) g_free(logo_path); - mplay->playlist = gtk_playlist_new (); + mplay->playlist = gtk_playlist_new ( + gst_media_play_get_glade_file("playlist.glade"), + NULL); g_return_if_fail(mplay->playlist != NULL); gtk_box_pack_start (GTK_BOX (mplay), mplay->video_widget, TRUE, TRUE, 0); @@ -724,30 +733,52 @@ g_return_if_fail(GST_IS_MEDIA_PLAY(mplay)); } -static GladeXML* -gst_media_play_get_glade_xml(const char *fname, const char *root, const char *domain) +gchar* +gst_media_play_get_glade_file (const char *fname) { - GladeXML *xml = NULL; gchar *full_fname; + /* Searching for glade file in uninstalled dir */ + full_fname = g_strjoin("/", GLADEUI_UNINSTALLED_DIR, fname, NULL); - if (g_file_test(full_fname, G_FILE_TEST_IS_REGULAR)){ - /* g_print("loading %s\n", full_fname); */ - xml = glade_xml_new(full_fname, root, domain); - g_free(full_fname); - return xml; - } - - g_free(full_fname); + if ( g_file_test(full_fname, G_FILE_TEST_IS_REGULAR) ) + return full_fname; + + if (full_fname) g_free(full_fname); + + /* Searching for glade file in installed dir */ + full_fname = g_strjoin("/", GLADEUI_DIR, fname, NULL); - if (g_file_test(full_fname, G_FILE_TEST_IS_REGULAR)){ - /* g_print("loading %s\n", full_fname); */ - xml = glade_xml_new(full_fname, root, domain); - g_free(full_fname); - return xml; - } - g_free(full_fname); + if ( g_file_test(full_fname, G_FILE_TEST_IS_REGULAR) ) + return full_fname; + + /* Not found */ + + if (full_fname) g_free(full_fname); + + return NULL; +} + +GladeXML* +gst_media_play_get_glade_xml_from_file ( const char *fname, + const char *root, + const char *domain) +{ return glade_xml_new(fname, root, domain); +} + +GladeXML* +gst_media_play_get_glade_xml ( const char *fname, + const char *root, + const char *domain) +{ + gchar *full_fname = NULL; + GladeXML *xml = NULL; + full_fname = gst_media_play_get_glade_file (fname); + g_return_val_if_fail(full_fname != NULL, NULL); + xml = gst_media_play_get_glade_xml_from_file (full_fname, root, domain); + if (full_fname) g_free (full_fname); + return xml; } /* FIXME: move this function ? */ Index: gtk-playlist.c =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gtk-playlist.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gtk-playlist.c 18 Jan 2003 21:36:48 -0000 1.1 +++ gtk-playlist.c 21 Jan 2003 14:04:41 -0000 1.2 @@ -23,7 +23,7 @@ #include "config.h" #include "gtk-playlist.h" -#include <gnome.h> +#include <gtk/gtk.h> #include <libxml/tree.h> #include <libxml/parser.h> #include <glade/glade.h> @@ -31,8 +31,9 @@ #include <libgnomevfs/gnome-vfs.h> #include <libgnomevfs/gnome-vfs-mime-utils.h> #include <string.h> +#include <libgnome/gnome-i18n.h> -/*#include "debug.h" */ +/*#include "debug.h"*/ #define READ_CHUNK_SIZE 8192 @@ -57,12 +58,15 @@ gboolean repeat; GConfClient *gc; + + int x, y; }; /* Signals */ enum { CHANGED, CURRENT_REMOVED, + REPEAT_TOGGLED, LAST_SIGNAL }; @@ -82,7 +86,7 @@ static GtkWidgetClass *parent_class = NULL; static void gtk_playlist_class_init (GtkPlaylistClass *class); -static void gtk_playlist_init (GtkPlaylist *label); +static void gtk_playlist_init (GtkPlaylist *playlist); static void init_treeview (GtkWidget *treeview, GtkPlaylist *playlist); static gboolean gtk_playlist_unset_playing (GtkPlaylist *playlist); @@ -350,7 +354,6 @@ | G_FILE_TEST_EXISTS) || strstr (filename, "://") != NULL)) { - g_message ("drop_cb: adding %s", filename); gtk_playlist_add_mrl (playlist, filename, NULL); } g_free (filename); @@ -616,9 +619,13 @@ gboolean repeat; repeat = gtk_toggle_button_get_active (togglebutton); - gconf_client_set_bool (playlist->_priv->gc, "/apps/totem/repeat", + gconf_client_set_bool (playlist->_priv->gc, GCONF_PREFIX"/repeat", repeat, NULL); playlist->_priv->repeat = repeat; + + g_signal_emit (G_OBJECT (playlist), + gtk_playlist_table_signals[REPEAT_TOGGLED], 0, + repeat, NULL); } static void @@ -630,11 +637,12 @@ gboolean repeat; repeat = gconf_client_get_bool (client, - "/apps/totem/repeat", NULL); + GCONF_PREFIX"/repeat", NULL); button = glade_xml_get_widget (playlist->_priv->xml, "repeat_button"); g_signal_handlers_disconnect_by_func (G_OBJECT (button), repeat_button_toggled, playlist); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), repeat); + playlist->_priv->repeat = repeat; g_signal_connect (G_OBJECT (button), "toggled", G_CALLBACK (repeat_button_toggled), (gpointer) playlist); @@ -642,6 +650,9 @@ g_signal_emit (G_OBJECT (playlist), gtk_playlist_table_signals[CHANGED], 0, NULL); + g_signal_emit (G_OBJECT (playlist), + gtk_playlist_table_signals[REPEAT_TOGGLED], 0, + repeat, NULL); } static void @@ -654,12 +665,12 @@ playlist->_priv->gc = gconf_client_get_default (); repeat = gconf_client_get_bool (playlist->_priv->gc, - "/apps/totem/repeat", NULL); + GCONF_PREFIX"/repeat", NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), repeat); - gconf_client_add_dir (playlist->_priv->gc, "/apps/totem", + gconf_client_add_dir (playlist->_priv->gc, GCONF_PREFIX, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - gconf_client_notify_add (playlist->_priv->gc, "/apps/totem/repeat", + gconf_client_notify_add (playlist->_priv->gc, GCONF_PREFIX"/repeat", update_repeat_cb, playlist, NULL, NULL); g_signal_connect (G_OBJECT (button), "toggled", G_CALLBACK (repeat_button_toggled), @@ -704,18 +715,44 @@ g_return_if_fail (widget != NULL); - gtk_window_get_position (GTK_WINDOW (widget), &x, &y); - gconf_client_set_int (playlist->_priv->gc, "/apps/totem/playlist_x", + if (GTK_WIDGET_MAPPED (widget) == TRUE) + { + gtk_window_get_position (GTK_WINDOW (widget), &x, &y); + } else { + x = playlist->_priv->x; + y = playlist->_priv->y; + } + + gconf_client_set_int (playlist->_priv->gc, GCONF_PREFIX"/playlist_x", x, NULL); - gconf_client_set_int (playlist->_priv->gc, "/apps/totem/playlist_y", + gconf_client_set_int (playlist->_priv->gc, GCONF_PREFIX"/playlist_y", y, NULL); + GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED); + if (GTK_WIDGET_CLASS (parent_class)->unrealize != NULL) { (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); } } static void +gtk_playlist_unmap (GtkWidget *widget) +{ + GtkPlaylist *playlist = GTK_PLAYLIST (widget); + int x, y; + + g_return_if_fail (widget != NULL); + + gtk_window_get_position (GTK_WINDOW (widget), &x, &y); + playlist->_priv->x = x; + playlist->_priv->y = y; + + if (GTK_WIDGET_CLASS (parent_class)->unmap != NULL) { + (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget); + } +} + +static void gtk_playlist_realize (GtkWidget *widget) { GtkPlaylist *playlist = GTK_PLAYLIST (widget); @@ -723,14 +760,16 @@ g_return_if_fail (widget != NULL); + GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + if (GTK_WIDGET_CLASS (parent_class)->realize != NULL) { (* GTK_WIDGET_CLASS (parent_class)->realize) (widget); } x = gconf_client_get_int (playlist->_priv->gc, - "/apps/totem/playlist_x", NULL); + GCONF_PREFIX"/playlist_x", NULL); y = gconf_client_get_int (playlist->_priv->gc, - "/apps/totem/playlist_y", NULL); + GCONF_PREFIX"/playlist_y", NULL); if (x == -1 || y == -1 || x > gdk_screen_width () || y > gdk_screen_height ()) @@ -740,32 +779,22 @@ } GtkWidget* -gtk_playlist_new (void) +gtk_playlist_new (const char *glade_filename, GdkPixbuf *playing_pix) { GtkPlaylist *playlist; GtkWidget *container, *item; - char *filename; + + if (glade_filename == NULL) + return NULL; playlist = GTK_PLAYLIST (g_object_new (GTK_TYPE_PLAYLIST, NULL)); - filename = g_build_path ( G_DIR_SEPARATOR_S, - DATADIR, - "gst-player", - "ui", - "playlist.glade", NULL); - - if (filename == NULL) - { - gtk_playlist_finalize (G_OBJECT (playlist)); - return NULL; - } - playlist->_priv->xml = glade_xml_new (filename, "vbox4", NULL); + playlist->_priv->xml = glade_xml_new (glade_filename, "vbox4", NULL); if (playlist->_priv->xml == NULL) { gtk_playlist_finalize (G_OBJECT (playlist)); return NULL; } - g_free (filename); gtk_window_set_title (GTK_WINDOW (playlist), _("Playlist")); gtk_dialog_add_buttons (GTK_DIALOG (playlist), @@ -804,17 +833,7 @@ /* The configuration */ init_config (playlist); - filename = gnome_program_locate_file (NULL, - GNOME_FILE_DOMAIN_APP_DATADIR, - "totem/playlist-playing.png", TRUE, NULL); - if (filename != NULL) - { - playlist->_priv->icon = gdk_pixbuf_new_from_file - (filename, NULL); - g_free (filename); - } else { - playlist->_priv->icon = NULL; - } + playlist->_priv->icon = playing_pix; gtk_widget_show_all (GTK_DIALOG (playlist)->vbox); @@ -1085,7 +1104,7 @@ if (mimetype == NULL) { - g_message ("trying to add '%s' with no mimetype", mrl); + g_message("trying to add '%s' with no mimetype", mrl); return gtk_playlist_add_one_mrl (playlist, mrl, display_name); } else if (strcmp ("audio/x-mpegurl", mimetype) == 0) { return gtk_playlist_add_m3u (playlist, mrl); @@ -1100,7 +1119,7 @@ if (strncmp ("audio/", mimetype, 6) != 0 && strncmp ("video/", mimetype, 6) != 0) { - g_message ("trying to add '%s' with mimetype '%s'", + g_message("trying to add '%s' with mimetype '%s'", mrl, mimetype); return FALSE; } @@ -1311,6 +1330,25 @@ (playlist->_priv->model, &iter); } +gboolean +gtk_playlist_get_repeat (GtkPlaylist *playlist) +{ + g_return_val_if_fail (GTK_IS_PLAYLIST (playlist), FALSE); + + return playlist->_priv->repeat; +} + +void +gtk_playlist_set_repeat (GtkPlaylist *playlist, gboolean repeat) +{ + GtkWidget *button; + + g_return_if_fail (GTK_IS_PLAYLIST (playlist)); + + button = glade_xml_get_widget (playlist->_priv->xml, "repeat_button"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), repeat); +} + void gtk_playlist_set_at_start (GtkPlaylist *playlist) { @@ -1356,6 +1394,7 @@ G_OBJECT_CLASS (klass)->finalize = gtk_playlist_finalize; GTK_WIDGET_CLASS (klass)->realize = gtk_playlist_realize; GTK_WIDGET_CLASS (klass)->unrealize = gtk_playlist_unrealize; + GTK_WIDGET_CLASS (klass)->unmap = gtk_playlist_unmap; /* Signals */ gtk_playlist_table_signals[CHANGED] = @@ -1375,5 +1414,15 @@ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + gtk_playlist_table_signals[REPEAT_TOGGLED] = + g_signal_new ("repeat-toggled", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkPlaylistClass, + repeat_toggled), + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); } + Index: gtk-playlist.h =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gtk-playlist.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gtk-playlist.h 18 Jan 2003 21:36:49 -0000 1.1 +++ gtk-playlist.h 21 Jan 2003 14:04:41 -0000 1.2 @@ -25,6 +25,8 @@ #include <gtk/gtkdialog.h> +G_BEGIN_DECLS + #define GTK_TYPE_PLAYLIST (gtk_playlist_get_type ()) #define GTK_PLAYLIST(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_PLAYLIST, GtkPlaylist)) #define GTK_PLAYLIST_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_PLAYLIST, GtkPlaylistClass)) @@ -45,10 +47,12 @@ void (*changed) (GtkPlaylist *playlist); void (*current_removed) (GtkPlaylist *playlist); + void (*repeat_toggled) (GtkPlaylist *playlist, gboolean repeat); }; GtkType gtk_playlist_get_type (void); -GtkWidget *gtk_playlist_new (); +GtkWidget *gtk_playlist_new (const char *glade_filename, + GdkPixbuf *playing_pix); /* The application is responsible for checking that the mrl is correct * Handles directories, m3u playlists, and shoutcast playlists @@ -69,6 +73,9 @@ void gtk_playlist_set_previous (GtkPlaylist *playlist); void gtk_playlist_set_next (GtkPlaylist *playlist); +gboolean gtk_playlist_get_repeat (GtkPlaylist *playlist); +void gtk_playlist_set_repeat (GtkPlaylist *playlist, gboolean repeat); + gboolean gtk_playlist_set_title (GtkPlaylist *playlist, const gchar *title); gboolean gtk_playlist_set_playing (GtkPlaylist *playlist, gboolean state); @@ -77,5 +84,7 @@ gchar * gtk_playlist_mrl_to_title (const gchar *mrl); +G_END_DECLS #endif /* GTK_PLAYLIST_H */ + |