From: Steve B. <sb...@us...> - 2002-07-11 16:31:07
|
CVS Root: /cvsroot/gstreamer Module: gst-player Changes by: sbaker3 Date: Thu Jul 11 2002 09:31:06 PDT Log message: - add a status area which shows state, filename, time and stream length - remove playlist for now - it probably doesn't belong in gstmediaplay.c anyway. Might replace it with hadess's playlist widget when its ready - some api cleanups - use "location" throughout Modified files: libs/gst/player : Makefile.am gstcontrol.c gstmediainfo.c gstmediainfo.h gstmediaplay.c gstmediaplay.h gstplayer-marshal.list gstplayer-private.h gstplaylist.c gstplaylist.h gststatusarea.c gststatusarea.h Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/Makefile.am.diff?r1=1.19&r2=1.20 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstcontrol.c.diff?r1=1.26&r2=1.27 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstmediainfo.c.diff?r1=1.1&r2=1.2 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstmediainfo.h.diff?r1=1.1&r2=1.2 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstmediaplay.c.diff?r1=1.52&r2=1.53 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstmediaplay.h.diff?r1=1.19&r2=1.20 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstplayer-marshal.list.diff?r1=1.3&r2=1.4 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstplayer-private.h.diff?r1=1.2&r2=1.3 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstplaylist.c.diff?r1=1.4&r2=1.5 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstplaylist.h.diff?r1=1.4&r2=1.5 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gststatusarea.c.diff?r1=1.4&r2=1.5 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gststatusarea.h.diff?r1=1.1&r2=1.2 ====Begin Diffs==== Index: Makefile.am =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/Makefile.am,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- Makefile.am 26 Jun 2002 17:56:24 -0000 1.19 +++ Makefile.am 11 Jul 2002 16:30:53 -0000 1.20 @@ -7,7 +7,6 @@ lib_LTLIBRARIES = libgstplayer.la libgstplayer_la_SOURCES = \ - songinfo.c \ gstmediaplay.c \ gstpreferences.c \ stockicons.c \ @@ -15,6 +14,7 @@ gstplayer-marshal.c \ gstmediainfo.c \ gstcontrol.c \ + gststatusarea.c \ utils.c \ gstplaylist.c @@ -29,7 +29,6 @@ noinst_HEADERS = \ - songinfo.h \ gstplayer-private.h \ gstpreferences.h \ gstmediaplay.h \ @@ -38,6 +37,7 @@ i18n-support.h \ gstmediainfo.h \ gstcontrol.h \ + gststatusarea.h \ utils.h \ gstplaylist.h Index: gstcontrol.c =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstcontrol.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- gstcontrol.c 9 Jul 2002 11:07:51 -0000 1.26 +++ gstcontrol.c 11 Jul 2002 16:30:53 -0000 1.27 @@ -35,6 +35,7 @@ GtkWidget *image_paused_bot; GtkWidget *image_playlist; + GtkWidget *separator_playlist; GtkWidget *image_volume; GtkWidget *image_volume_mute; @@ -284,7 +285,7 @@ G_CALLBACK (gst_control_event_check), control); /* seek slider */ - priv->adjustment_seek = G_OBJECT (gtk_adjustment_new (0.0, 0.0, 1.0, 0.1, 0.10, 0.10)); + priv->adjustment_seek = G_OBJECT (gtk_adjustment_new (0.0, 0.0, 1.0, 0.1, 0.1, 0.01)); priv->seek_handle = gtk_hscale_new (GTK_ADJUSTMENT (priv->adjustment_seek)); gtk_scale_set_draw_value (GTK_SCALE (priv->seek_handle), FALSE); @@ -354,7 +355,21 @@ g_signal_connect (G_OBJECT (priv->button_next), "clicked", G_CALLBACK (gst_control_event_check), control); - gtk_box_pack_start (GTK_BOX (priv->hbox_bot), gtk_vseparator_new(), FALSE, FALSE, 0); + /* playlist button */ + priv->image_playlist = gtk_image_new_from_stock (GST_STOCK_BOOK, GTK_ICON_SIZE_BUTTON); + + priv->button_list = gtk_toggle_button_new (); + hbox = gtk_hbox_new (1, 0); + gtk_container_add (GTK_CONTAINER (priv->button_list), hbox); + gtk_box_pack_start (GTK_BOX (hbox), priv->image_playlist, TRUE, TRUE, 0); + + gtk_box_pack_start (GTK_BOX (priv->hbox_bot), priv->button_list, FALSE, FALSE, 0); + gtk_button_set_relief (GTK_BUTTON(priv->button_list), GTK_RELIEF_NONE); + g_signal_connect (G_OBJECT (priv->button_list), "clicked", + G_CALLBACK (gst_control_event_check), control); + + priv->separator_playlist = gtk_vseparator_new(); + gtk_box_pack_start (GTK_BOX (priv->hbox_bot), priv->separator_playlist, FALSE, FALSE, 0); /* volume slider */ priv->image_volume = gtk_image_new_from_stock (GST_STOCK_VOLUME, GTK_ICON_SIZE_BUTTON); @@ -381,19 +396,6 @@ gtk_box_pack_start (GTK_BOX (priv->hbox_bot), gtk_vseparator_new(), FALSE, FALSE, 0); - /* playlist button */ - priv->image_playlist = gtk_image_new_from_stock (GST_STOCK_BOOK, GTK_ICON_SIZE_BUTTON); - - priv->button_list = gtk_toggle_button_new (); - hbox = gtk_hbox_new (1, 0); - gtk_container_add (GTK_CONTAINER (priv->button_list), hbox); - gtk_box_pack_start (GTK_BOX (hbox), priv->image_playlist, TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (priv->hbox_bot), priv->button_list, FALSE, FALSE, 0); - gtk_button_set_relief (GTK_BUTTON(priv->button_list), GTK_RELIEF_NONE); - g_signal_connect (G_OBJECT (priv->button_list), "clicked", - G_CALLBACK (gst_control_event_check), control); - /* display mode buttons */ image = gtk_image_new_from_stock (GST_STOCK_DEMAXIMIZE, GTK_ICON_SIZE_BUTTON); @@ -420,6 +422,10 @@ gtk_widget_hide(priv->image_paused_bot); gtk_widget_hide(priv->image_paused_top); gtk_widget_hide(priv->image_volume_mute); + gtk_widget_hide(priv->button_prev); + gtk_widget_hide(priv->button_next); + gtk_widget_hide(priv->button_list); + gtk_widget_hide(priv->separator_playlist); gst_control_set_display_mode(control, GST_MEDIA_PLAY_NORMAL); } Index: gstmediainfo.c =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstmediainfo.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gstmediainfo.c 3 May 2002 07:02:40 -0000 1.1 +++ gstmediainfo.c 11 Jul 2002 16:30:53 -0000 1.2 @@ -12,12 +12,12 @@ GNOME_CLASS_BOILERPLATE (GstMediaInfo, gst_media_info, GtkDialog, GTK_TYPE_DIALOG) static gchar* -build_string_for_display (const gchar *uri) +build_string_for_display (const gchar *location) { gchar *tmp = NULL; gchar **ampersand; - tmp = g_strdup_printf ("%s", uri); + tmp = g_strdup_printf ("%s", location); if (tmp != NULL && strlen (tmp) > 40) { @@ -234,26 +234,26 @@ } GtkWidget* -gst_media_info_new (const gchar *uri) +gst_media_info_new (const gchar *location) { GstMediaInfo *media_info; - g_return_val_if_fail (uri != NULL, NULL); + g_return_val_if_fail (location != NULL, NULL); media_info = g_object_new (GST_TYPE_MEDIA_INFO, NULL); - gst_media_info_construct (media_info, uri); + gst_media_info_construct (media_info, location); return GTK_WIDGET (media_info); } void -gst_media_info_construct (GstMediaInfo *media_info, const gchar *uri) +gst_media_info_construct (GstMediaInfo *media_info, const gchar *location) { gchar *tmp; - gtk_window_set_title (GTK_WINDOW (media_info), g_strdup_printf ("%s info", uri)); + gtk_window_set_title (GTK_WINDOW (media_info), g_strdup_printf ("%s info", location)); - tmp = build_string_for_display (uri); + tmp = build_string_for_display (location); gnome_canvas_item_set (media_info->_priv->label_filename, "markup", tmp, NULL); g_free (tmp); Index: gstmediainfo.h =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstmediainfo.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gstmediainfo.h 3 May 2002 07:02:40 -0000 1.1 +++ gstmediainfo.h 11 Jul 2002 16:30:53 -0000 1.2 @@ -28,8 +28,8 @@ }; GType gst_media_info_get_type (void) G_GNUC_CONST; -GtkWidget* gst_media_info_new (const gchar *uri); -void gst_media_info_construct (GstMediaInfo *media_info, const gchar *uri); +GtkWidget* gst_media_info_new (const gchar *location); +void gst_media_info_construct (GstMediaInfo *media_info, const gchar *location); G_END_DECLS Index: gstmediaplay.c =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstmediaplay.c,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- gstmediaplay.c 6 Jul 2002 20:04:18 -0000 1.52 +++ gstmediaplay.c 11 Jul 2002 16:30:53 -0000 1.53 @@ -3,6 +3,7 @@ #include <locale.h> #include <config.h> #include <i18n-support.h> +#include <libgnomevfs/gnome-vfs.h> #include <gnome.h> #include "gstmediaplay.h" @@ -10,7 +11,8 @@ #include "gstpreferences.h" #include "gstmediainfo.h" #include "gstcontrol.h" -#include "gstplaylist.h" +#include "gststatusarea.h" +#include "gstplayer-marshal.h" static void gst_media_play_class_init (GstMediaPlayClass *klass); static void gst_media_play_init (GstMediaPlay *play); @@ -21,17 +23,13 @@ static void gst_media_play_seek_to_pos (GtkWidget *widget, gdouble value, GstMediaPlay *mplay); static void gst_media_play_toggle_play_pause (GtkWidget *widget, GstMediaPlay *mplay); static void gst_media_play_stop (GtkWidget *widget, GstMediaPlay *mplay); -static void gst_media_play_show_playlist (GtkWidget *widget, GstMediaPlay *mplay); static void gst_media_play_display_mode_change (GtkWidget *widget, GstMediaPlayMode display_mode, GstMediaPlay *mplay); static void gst_media_play_toggle_display_mode (GtkWidget *widget, GstMediaPlay *mplay); static void gst_media_play_fullscreen (GtkWidget *widget, GstMediaPlay *mplay); static void gst_media_play_volume_changed (GtkWidget *widget, gdouble value, GstMediaPlay *mplay); -/* signal handlers for playlist */ -static void gst_media_play_play_next (GtkWidget *widget, GstMediaPlay *mplay); -static void gst_media_play_set_selected (GtkWidget *widget, GstMediaPlay *mplay); - /* signal handlers for GstPlay */ +static void gst_media_play_stream_end (GstPlay *play, GstMediaPlay *mplay); static void gst_media_play_time_tick (GstPlay *play, gint64 time_nanos, GstMediaPlay *mplay); static void gst_media_play_got_length (GstPlay *play, gint64 length_nanos, GstMediaPlay *mplay); static void gst_media_play_have_xid (GstPlay *play, gint xid, GstMediaPlay *mplay); @@ -43,6 +41,7 @@ enum { STATE_CHANGE, DISPLAY_MODE_CHANGE, + CURRENT_LOCATION, LAST_SIGNAL }; @@ -105,11 +104,19 @@ g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT); + gst_media_play_signals [CURRENT_LOCATION] = + g_signal_new ("current_location", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GstMediaPlayClass, current_location), + NULL, NULL, + gst_play_marshal_VOID__STRING_STRING, + G_TYPE_NONE, 2, + G_TYPE_STRING, G_TYPE_STRING); } static void gst_media_play_init (GstMediaPlay *mplay) { - GtkWidget *playlist; /* play object */ mplay->play = gst_play_new (GST_PLAY_PIPE_VIDEO); @@ -117,7 +124,7 @@ g_return_if_fail(mplay->play != NULL); g_signal_connect (G_OBJECT (mplay->play), "stream_end", - G_CALLBACK (gst_media_play_play_next), mplay); + G_CALLBACK (gst_media_play_stream_end), mplay); g_signal_connect (G_OBJECT (mplay->play), "time_tick", G_CALLBACK (gst_media_play_time_tick), mplay); g_signal_connect (G_OBJECT (mplay->play), "stream_length", @@ -138,7 +145,7 @@ mplay->control = gst_control_new (); g_return_if_fail(mplay->control != NULL); - + gtk_box_pack_start (GTK_BOX (mplay), mplay->video_widget, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (mplay), GTK_WIDGET (mplay->control), FALSE, FALSE, 0); @@ -146,8 +153,6 @@ G_CALLBACK (gst_media_play_toggle_play_pause), mplay); g_signal_connect (G_OBJECT (mplay->control), "button_stop", G_CALLBACK (gst_media_play_stop), mplay); - g_signal_connect (G_OBJECT (mplay->control), "button_list", - G_CALLBACK (gst_media_play_show_playlist), mplay); g_signal_connect (G_OBJECT (mplay->control), "button_mute", G_CALLBACK (gst_media_play_toggle_mute), mplay); g_signal_connect (G_OBJECT (mplay->control), "volume_change", @@ -159,16 +164,14 @@ mplay->display_mode = GST_MEDIA_PLAY_NORMAL; - mplay->playlist = gst_playlist_new (); - g_return_if_fail(mplay->playlist != NULL); - - gtk_box_pack_start (GTK_BOX (mplay), GTK_WIDGET (mplay->playlist), TRUE, TRUE, 0); - g_signal_connect (G_OBJECT (mplay->playlist), "selection_change", - G_CALLBACK (gst_media_play_set_selected), mplay); + mplay->statusarea = gst_status_area_new(); + gtk_box_pack_start (GTK_BOX (mplay), mplay->statusarea, FALSE, FALSE, 0); + + gtk_widget_show (mplay->statusarea); gtk_widget_show (mplay->control); - mplay->uri = NULL; + mplay->location = NULL; } GstMediaPlay* @@ -240,75 +243,29 @@ } void -gst_media_play_load_uri (GstMediaPlay *mplay, const gchar *uri) +gst_media_play_set_location (GstMediaPlay *mplay, const gchar *location) { + GnomeVFSFileInfo info; g_return_if_fail(GST_IS_MEDIA_PLAY(mplay)); + g_return_if_fail(location != NULL); - mplay->uri = uri; + mplay->location_short = NULL; + mplay->location = location; - /* FIXME send a signal - gtk_window_set_title (GTK_WINDOW (mplay->window), g_strdup_printf ("%s", uri));*/ - - /*g_print ("loading %s\n", uri);*/ - gst_play_set_location (mplay->play, uri); -} - -static void -gst_media_play_play_next (GtkWidget *widget, GstMediaPlay *mplay) -{ - g_return_if_fail(GST_IS_MEDIA_PLAY(mplay)); - gst_media_play_next_uri(mplay); -} - -static void -gst_media_play_set_selected (GtkWidget *widget, GstMediaPlay *mplay) -{ - gchar *uri; - - g_return_if_fail(GST_IS_MEDIA_PLAY(mplay)); - - uri = gst_playlist_get_selected (GST_PLAYLIST (mplay->playlist)); - gst_media_play_load_uri (mplay, g_strdup_printf ("%s", uri)); -} - -void -gst_media_play_add_uri(GstMediaPlay *mplay, const gchar *uri) -{ - g_return_if_fail(GST_IS_MEDIA_PLAY(mplay)); - - gst_playlist_append (GST_PLAYLIST (mplay->playlist), uri); - - if (mplay->uri == NULL) { - gst_playlist_set_selected (GST_PLAYLIST (mplay->playlist), "0"); + /* get a short filename if we can */ + if (GNOME_VFS_OK != gnome_vfs_get_file_info(location, &info, GNOME_VFS_FILE_INFO_DEFAULT)){ + mplay->location_short = location; } -} - -void -gst_media_play_clear_uri_list(GstMediaPlay *mplay) -{ - g_return_if_fail(GST_IS_MEDIA_PLAY(mplay)); - gst_playlist_clear (GST_PLAYLIST (mplay->playlist)); -} - -void -gst_media_play_next_uri(GstMediaPlay *mplay) -{ - gboolean ret; - gchar *uri; - g_return_if_fail(GST_IS_MEDIA_PLAY(mplay)); - - ret = gst_playlist_get_next (GST_PLAYLIST (mplay->playlist), &uri); - - if (ret != FALSE) { - gst_media_play_load_uri (mplay, g_strdup_printf ("%s", uri)); + else { + mplay->location_short = info.name; } -} + + g_signal_emit (mplay, gst_media_play_signals [CURRENT_LOCATION], 0, mplay->location, mplay->location_short); -void -gst_media_play_prev_uri(GstMediaPlay *mplay) -{ - g_return_if_fail(GST_IS_MEDIA_PLAY(mplay)); + gst_media_play_set_state (mplay, GST_STATE_READY); + gst_status_area_set_location(GST_STATUS_AREA(mplay->statusarea), mplay->location_short); + gst_play_set_location (mplay->play, mplay->location); } static void @@ -350,8 +307,8 @@ g_return_if_fail(GST_IS_MEDIA_PLAY(mplay)); - if (mplay->uri != NULL) { - media_info = gst_media_info_new (mplay->uri); + if (mplay->location != NULL) { + media_info = gst_media_info_new (mplay->location); } else { media_info = gst_media_info_new ("no file loaded"); @@ -410,21 +367,6 @@ gtk_widget_show (about); } -static void -gst_media_play_show_playlist (GtkWidget *widget, GstMediaPlay *mplay) -{ - g_return_if_fail(GST_IS_MEDIA_PLAY(mplay)); - - if (GTK_WIDGET_VISIBLE (mplay->playlist) == TRUE) - { - gtk_widget_hide (mplay->playlist); - } - else - { - gtk_widget_show (mplay->playlist); - } -} - void gst_media_play_fullscreen (GtkWidget *widget, GstMediaPlay *mplay) { @@ -547,9 +489,10 @@ if (mplay->display_mode == GST_MEDIA_PLAY_FULLSCREEN){ gst_media_play_set_fullscreen (mplay, FALSE); } + gtk_widget_show (mplay->statusarea); break; case GST_MEDIA_PLAY_MINI: - gtk_widget_hide (mplay->playlist); + gtk_widget_hide (mplay->statusarea); break; default: g_warning("unknown mode %d\n", display_mode); @@ -586,6 +529,14 @@ } static void +gst_media_play_stream_end (GstPlay *play, GstMediaPlay *mplay) +{ + g_return_if_fail(GST_IS_MEDIA_PLAY(mplay)); + + gst_media_play_set_state (mplay, GST_STATE_READY); +} + +static void gst_media_play_time_tick (GstPlay *play, gint64 time_nanos, GstMediaPlay *mplay) { gdouble seek_pos; @@ -596,6 +547,7 @@ seek_pos = ((gdouble) time_nanos) / ((gdouble) mplay->length_nanos); seconds = (gint) (time_nanos / GST_SECOND); gst_control_set_seek_pos (mplay->control, seek_pos); + gst_status_area_set_time(GST_STATUS_AREA(mplay->statusarea), time_nanos); } static void @@ -608,6 +560,7 @@ seconds = (gint) (length_nanos / GST_SECOND); mplay->length_nanos = length_nanos; gst_control_set_enable_seek (GST_CONTROL (mplay->control), TRUE); + gst_status_area_set_length(GST_STATUS_AREA(mplay->statusarea), length_nanos); } static void @@ -616,8 +569,8 @@ g_return_if_fail(GST_IS_MEDIA_PLAY(mplay)); gst_control_set_state (GST_CONTROL (mplay->control), new_state); + gst_status_area_set_state (GST_STATUS_AREA (mplay->statusarea), old_state, new_state); } - static void gst_media_play_have_xid (GstPlay *play, gint xid, GstMediaPlay *mplay) Index: gstmediaplay.h =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstmediaplay.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- gstmediaplay.h 29 Jun 2002 07:17:40 -0000 1.19 +++ gstmediaplay.h 11 Jul 2002 16:30:53 -0000 1.20 @@ -30,9 +30,11 @@ GtkWidget *fs_vbox; GtkWidget *control; - GtkWidget *playlist; - const gchar *uri; + GtkWidget *statusarea; + + const gchar *location; + const gchar *location_short; gint64 length_nanos; GstMediaPlayMode display_mode; @@ -44,6 +46,7 @@ /* signals */ void (*state_changed) (GstMediaPlay *mplay, GstElementState old_state, GstElementState new_state); void (*display_mode_change) (GstMediaPlay *mplay, GstMediaPlayMode display_mode); + void (*current_location) (GstMediaPlay *mplay, gchar *location, gchar *location_short); }; GType gst_media_play_get_type (void); @@ -65,10 +68,6 @@ void gst_media_play_show_preferences (GstMediaPlay *mplay); void gst_media_play_show_about (GstMediaPlay *mplay); -void gst_media_play_load_uri (GstMediaPlay *mplay, const gchar *uri); -void gst_media_play_add_uri (GstMediaPlay *mplay, const gchar *uri); -void gst_media_play_clear_uri_list (GstMediaPlay *mplay); -void gst_media_play_next_uri (GstMediaPlay *mplay); -void gst_media_play_prev_uri (GstMediaPlay *mplay); +void gst_media_play_set_location (GstMediaPlay *mplay, const gchar *location); #endif /* __GST_MEDIA_PLAY_H__ */ Index: gstplayer-marshal.list =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstplayer-marshal.list,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- gstplayer-marshal.list 6 May 2002 08:42:56 -0000 1.3 +++ gstplayer-marshal.list 11 Jul 2002 16:30:53 -0000 1.4 @@ -1,3 +1,4 @@ VOID:OBJECT,PARAM VOID:INT,INT VOID:VOID +VOID:STRING,STRING Index: gstplayer-private.h =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstplayer-private.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gstplayer-private.h 19 Mar 2002 04:09:37 -0000 1.2 +++ gstplayer-private.h 11 Jul 2002 16:30:53 -0000 1.3 @@ -17,7 +17,7 @@ GstElement *cache; GstElement *typefind; - guchar *uri; + guchar *location; gboolean muted; gboolean can_seek; Index: gstplaylist.c =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstplaylist.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gstplaylist.c 29 Jun 2002 07:17:40 -0000 1.4 +++ gstplaylist.c 11 Jul 2002 16:30:53 -0000 1.5 @@ -139,7 +139,7 @@ } void -gst_playlist_append (GstPlaylist *playlist, const gchar *uri) +gst_playlist_append (GstPlaylist *playlist, const gchar *location) { GstPlaylistPrivate *priv; @@ -147,7 +147,7 @@ gtk_list_store_append (priv->store, &priv->iter); gtk_list_store_set (priv->store, &priv->iter, - TITLE_COLUMN, uri, + TITLE_COLUMN, location, -1); } @@ -156,10 +156,25 @@ { GstPlaylistPrivate *priv; GtkTreeSelection *selection; + GtkTreeIter iter; + GtkTreeModel *model; + priv = playlist->_priv; + + g_print("getting selection\n"); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree)); + g_print("select_all\n"); gtk_tree_selection_unselect_all(selection); - gtk_list_store_clear (priv->store); + + g_print("getting model\n"); + model = gtk_tree_view_get_model(GTK_TREE_VIEW (priv->tree)); + + g_print("getting iter\n"); + /* delete all items in list */ + while (gtk_tree_model_get_iter_from_string (model, &iter, "0")){ + gtk_list_store_remove(priv->store, &iter); + g_print("removed item\n"); + } } gchar* @@ -169,16 +184,16 @@ GtkTreeSelection *selection; GtkTreeIter iter; GtkTreeModel *model; - gchar *uri; + gchar *location; priv = playlist->_priv; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree)); gtk_tree_selection_get_selected (selection, &model, &iter); - gtk_tree_model_get (model, &iter, TITLE_COLUMN, &uri, -1); + gtk_tree_model_get (model, &iter, TITLE_COLUMN, &location, -1); - return uri; + return location; } void @@ -188,7 +203,7 @@ GtkTreeSelection *selection; GtkTreeIter iter; GtkTreeModel *model; - gchar *uri; + gchar *location; priv = playlist->_priv; @@ -200,7 +215,7 @@ } gboolean -gst_playlist_get_next (GstPlaylist *playlist, gchar **uri) +gst_playlist_get_next (GstPlaylist *playlist, gchar **location) { GstPlaylistPrivate *priv; GtkTreeSelection *selection; @@ -220,13 +235,13 @@ gtk_tree_model_get (model, &iter, TITLE_COLUMN, &tmp, -1); } - *uri = tmp; + *location = tmp; return ret; } gboolean -gst_playlist_get_prev(GstPlaylist *playlist, gchar **uri) +gst_playlist_get_prev(GstPlaylist *playlist, gchar **location) { GstPlaylistPrivate *priv; GtkTreeSelection *selection; @@ -247,7 +262,7 @@ gtk_tree_model_get (model, &iter, TITLE_COLUMN, &tmp, -1); } - *uri = tmp; + *location = tmp; return ret; } Index: gstplaylist.h =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstplaylist.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gstplaylist.h 29 Jun 2002 07:17:40 -0000 1.4 +++ gstplaylist.h 11 Jul 2002 16:30:53 -0000 1.5 @@ -32,12 +32,12 @@ GtkType gst_playlist_get_type (void) G_GNUC_CONST; GtkWidget* gst_playlist_new (void); -void gst_playlist_append (GstPlaylist *playlist, const gchar *uri); +void gst_playlist_append (GstPlaylist *playlist, const gchar *location); void gst_playlist_clear (GstPlaylist *playlist); gchar* gst_playlist_get_selected (GstPlaylist *playlist); void gst_playlist_set_selected (GstPlaylist *playlist, const gchar *path); -gboolean gst_playlist_get_next (GstPlaylist *playlist, gchar **uri); -gboolean gst_playlist_get_prev (GstPlaylist *playlist, gchar **uri); +gboolean gst_playlist_get_next (GstPlaylist *playlist, gchar **location); +gboolean gst_playlist_get_prev (GstPlaylist *playlist, gchar **location); G_END_DECLS Index: gststatusarea.c =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gststatusarea.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gststatusarea.c 18 Apr 2002 13:49:22 -0000 1.4 +++ gststatusarea.c 11 Jul 2002 16:30:53 -0000 1.5 @@ -4,16 +4,8 @@ #include "gststatusarea.h" static void gst_status_area_class_init (GstStatusAreaClass *klass); -static void gst_status_area_init (GstStatusArea *status_area); - -static void gst_status_area_set_arg (GtkObject *object, GtkArg *arg, guint id); -static void gst_status_area_get_arg (GtkObject *object, GtkArg *arg, guint id); - -static void gst_status_area_realize (GtkWidget *status_area); -static gint gst_status_area_expose (GtkWidget *widget, GdkEventExpose *event); - -#define DEFAULT_HEIGHT 20 -#define DEFAULT_EXPANDED_HEIGHT 100 +static void gst_status_area_init (GstStatusArea *area); +static gint gst_status_area_text_width (GtkWidget *widget, const gchar *text); /* signals and args */ enum { @@ -24,8 +16,12 @@ ARG_0, }; +#define STR_READY "Ready" +#define STR_PLAYING "Playing" +#define STR_PAUSED "Paused" +#define STR_STOPPED "Stopped" + static GtkDrawingArea *parent_class = NULL; -/* static guint gst_status_area_signals[LAST_SIGNAL] = { 0 }; */ GtkType gst_status_area_get_type (void) @@ -43,7 +39,7 @@ NULL, (GtkClassInitFunc)NULL, }; - status_area_type = gtk_type_unique (gtk_widget_get_type (),&status_area_info); + status_area_type = gtk_type_unique (gtk_hbox_get_type (),&status_area_info); } return status_area_type; } @@ -58,253 +54,147 @@ object_class = (GtkObjectClass*)klass; widget_class = (GtkWidgetClass*)klass; - - object_class->set_arg = gst_status_area_set_arg; - object_class->get_arg = gst_status_area_get_arg; - - widget_class->realize = gst_status_area_realize; - widget_class->expose_event = gst_status_area_expose; } static void -gst_status_area_init (GstStatusArea *status_area) -{ - GTK_WIDGET(status_area)->requisition.height = DEFAULT_HEIGHT; - - status_area->state = GST_STATUS_AREA_STATE_INIT; - status_area->expanded = FALSE; -} - -GstStatusArea * -gst_status_area_new (void) -{ - return GST_STATUS_AREA (gtk_type_new (GST_TYPE_STATUS_AREA)); -} - -static void -gst_status_area_realize (GtkWidget *widget) +gst_status_area_init (GstStatusArea *area) { - GdkWindowAttr attributes; - gint attributes_mask; - GstStatusArea *status_area; + GtkWidget *separator; + gint width; + gtk_box_set_homogeneous(GTK_BOX(area), FALSE); + gtk_box_set_spacing(GTK_BOX(area), 5); - g_return_if_fail (widget != NULL); - g_return_if_fail(GST_IS_STATUS_AREA(widget)); + area->state_label = gtk_label_new(STR_READY); + area->location_label = gtk_label_new("No file"); + area->time_label = gtk_label_new("00:00"); - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - status_area = GST_STATUS_AREA(widget); + area->time_str = NULL; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.event_mask = gtk_widget_get_events (widget) - | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK; + gtk_box_pack_start (GTK_BOX (area), area->state_label, FALSE, FALSE, 0); + gtk_widget_show (area->state_label); - attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); + separator = gtk_vseparator_new(); + gtk_box_pack_start (GTK_BOX (area), separator, FALSE, FALSE, 0); + gtk_widget_show (separator); - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + gtk_box_pack_start (GTK_BOX (area), area->location_label, TRUE, TRUE, 0); + gtk_widget_show (area->location_label); + + separator = gtk_vseparator_new(); + gtk_box_pack_start (GTK_BOX (area), separator, FALSE, FALSE, 0); + gtk_widget_show (separator); + + gtk_box_pack_start (GTK_BOX (area), area->time_label, FALSE, FALSE, 0); + gtk_widget_show (area->time_label); - widget->style = gtk_style_attach (widget->style, widget->window); + gtk_misc_set_alignment(GTK_MISC(area->state_label), 0, 0); + gtk_misc_set_alignment(GTK_MISC(area->location_label), 0, 0); + gtk_misc_set_alignment(GTK_MISC(area->time_label), 1, 0); + + /* find the maximum space that the state label will take up */ + width = gst_status_area_text_width(area->state_label, STR_READY); + width = MAX(width, gst_status_area_text_width(area->state_label, STR_PAUSED)); + width = MAX(width, gst_status_area_text_width(area->state_label, STR_PLAYING)); + width = MAX(width, gst_status_area_text_width(area->state_label, STR_STOPPED)); + gtk_widget_set_size_request (area->state_label, width, 1); + + width = gst_status_area_text_width(area->time_label, "00:00 / 00:00"); + gtk_widget_set_size_request (area->time_label, width, 1); } -static gint -gst_status_area_expose(GtkWidget *widget, GdkEventExpose *event) +GtkWidget * +gst_status_area_new (void) { - GstStatusArea *status_area; - guchar *statustext; - - g_return_val_if_fail (GST_IS_STATUS_AREA (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - status_area = GST_STATUS_AREA (widget); - - if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget)) { - GdkFont *font; - - font = gtk_style_get_font(widget->style); - - gdk_draw_rectangle (widget->window, - widget->style->black_gc, - TRUE, - 0, 0, - widget->allocation.width, - widget->allocation.height); - - if (status_area->expanded) { - gint width; - - gdk_draw_line (widget->window, - widget->style->dark_gc[0], - 0, widget->allocation.height - 20, - widget->allocation.width, widget->allocation.height - 20); - - width = gdk_string_width (font, "Show:"); - - gdk_draw_string (widget->window, - font, - widget->style->white_gc, - 80-width, 15, - "Show:"); - - width = gdk_string_width (font, "Clip:"); - - gdk_draw_string (widget->window, - font, - widget->style->white_gc, - 80-width, 40, - "Clip:"); - - width = gdk_string_width (font, "Author:"); - - gdk_draw_string (widget->window, - font, - widget->style->white_gc, - 80-width, 55, - "Author:"); - - width = gdk_string_width (font, "Copyright:"); - - gdk_draw_string (widget->window, - font, - widget->style->white_gc, - 80-width, 70, - "Copyright:"); - - gdk_draw_line (widget->window, - widget->style->dark_gc[0], - 0, widget->allocation.height - 80, - widget->allocation.width, widget->allocation.height - 80); - - - - - } - - switch (status_area->state) { - case GST_STATUS_AREA_STATE_INIT: - statustext = _("Initializing"); - break; - case GST_STATUS_AREA_STATE_PLAYING: - statustext = _("Playing"); - break; - case GST_STATUS_AREA_STATE_PAUSED: - statustext = _("Paused"); - break; - case GST_STATUS_AREA_STATE_STOPPED: - statustext = _("Stopped"); - break; - default: - statustext = ""; - break; - } - - gdk_draw_string (widget->window, - font, - widget->style->white_gc, - 8, widget->allocation.height-5, - statustext); - - if (status_area->playtime) { - gint width = gdk_string_width (font, status_area->playtime); - - gdk_draw_string (widget->window, - font, - widget->style->white_gc, - widget->allocation.width-width-20, - widget->allocation.height-5, - status_area->playtime); - } - } - - return FALSE; + return GTK_WIDGET (gtk_type_new (GST_TYPE_STATUS_AREA)); } void -gst_status_area_set_state (GstStatusArea *area, GstStatusAreaState state) +gst_status_area_set_state (GstStatusArea *area, GstElementState old_state, GstElementState new_state) { - g_return_if_fail(area != NULL); g_return_if_fail(GST_IS_STATUS_AREA(area)); + g_return_if_fail(area->state_label != NULL); - area->state = state; - - if (GTK_WIDGET_VISIBLE(area)) - gtk_widget_queue_draw(GTK_WIDGET(area)); + switch (new_state){ + case GST_STATE_PLAYING: + gtk_label_set_text(GTK_LABEL(area->state_label), STR_PLAYING); + break; + case GST_STATE_PAUSED: + gtk_label_set_text(GTK_LABEL(area->state_label), STR_PAUSED); + break; + case GST_STATE_READY: + if (old_state = GST_STATE_PAUSED){ + gtk_label_set_text(GTK_LABEL(area->state_label), STR_STOPPED); + } + else { + gtk_label_set_text(GTK_LABEL(area->state_label), STR_READY); + } + break; + default: + gtk_label_set_text(GTK_LABEL(area->state_label), STR_READY); + break; + } } -void -gst_status_area_set_playtime (GstStatusArea *area, const guchar *time) +void +gst_status_area_set_location (GstStatusArea *area, const gchar *location) { - g_return_if_fail(area != NULL); g_return_if_fail(GST_IS_STATUS_AREA(area)); - g_return_if_fail(time != NULL); - - if (area->playtime) g_free (area->playtime); - - area->playtime = g_strdup (time); - - if (GTK_WIDGET_VISIBLE(area)) - gtk_widget_queue_draw(GTK_WIDGET(area)); + g_return_if_fail(location != NULL); + gtk_label_set_text(GTK_LABEL(area->location_label), location); } -void -gst_status_area_set_streamtype (GstStatusArea *area, const guchar *type) +static void +gst_status_area_update_time_label(GstStatusArea *area) { -} + gchar *time_str; + gint time_seconds = (gint) (area->time_nanos / GST_SECOND); + gint length_seconds = (gint) (area->length_nanos / GST_SECOND); -void -cb_gst_toggle_extended (void) -{ - /* get pointer to status area */ + if (area->length_nanos <= 0LL){ + time_str = g_strdup_printf("%02d:%02d", time_seconds / 60, time_seconds % 60); + } + else { + time_str = g_strdup_printf("%02d:%02d / %02d:%02d", + time_seconds / 60, time_seconds % 60, + length_seconds / 60, length_seconds % 60); + } - /* grab current extended status */ + gtk_label_set_text(GTK_LABEL(area->time_label), time_str); - /* reverse truth on that by gst_status_show_extended */ + if (area->time_str){ + g_free(area->time_str); + } + area->time_str = time_str; } -void -gst_status_area_show_extended (GstStatusArea *area, gboolean show) +void +gst_status_area_set_time(GstStatusArea *area, gint64 time_nanos) { - area->expanded = show; + g_return_if_fail(GST_IS_STATUS_AREA(area)); + area->time_nanos = time_nanos; + gst_status_area_update_time_label(area); - if (show) { - GTK_WIDGET(area)->requisition.height = DEFAULT_EXPANDED_HEIGHT; - } - else { - GTK_WIDGET(area)->requisition.height = DEFAULT_HEIGHT; - } - gtk_widget_queue_resize (GTK_WIDGET (area)); } -static void -gst_status_area_set_arg(GtkObject *object, GtkArg *arg, guint id) +void +gst_status_area_set_length(GstStatusArea *area, gint64 length_nanos) { - GstStatusArea *status_area; - - status_area = GST_STATUS_AREA(object); - - switch (id) { - default: - g_warning("GstStatusArea: unknown arg!"); - break; - } + g_return_if_fail(GST_IS_STATUS_AREA(area)); + area->length_nanos = length_nanos; + gst_status_area_update_time_label(area); } -static void -gst_status_area_get_arg(GtkObject *object, GtkArg *arg, guint id) +static gint +gst_status_area_text_width (GtkWidget *widget, const gchar *text) { - GstStatusArea *status_area; + PangoLayout *layout; + gint width, height; - status_area = GST_STATUS_AREA(object); + layout = gtk_widget_create_pango_layout(widget, text); + pango_layout_get_pixel_size(layout, &width, &height); - switch (id) { - default: - arg->type = GTK_TYPE_INVALID; - break; - } + g_object_unref(G_OBJECT(layout)); + + return width; } + Index: gststatusarea.h =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gststatusarea.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gststatusarea.h 3 Feb 2002 21:12:32 -0000 1.1 +++ gststatusarea.h 11 Jul 2002 16:30:53 -0000 1.2 @@ -13,35 +13,30 @@ typedef struct _GstStatusArea GstStatusArea; typedef struct _GstStatusAreaClass GstStatusAreaClass; -typedef enum { - GST_STATUS_AREA_STATE_INIT, - GST_STATUS_AREA_STATE_PLAYING, - GST_STATUS_AREA_STATE_PAUSED, - GST_STATUS_AREA_STATE_STOPPED, -} GstStatusAreaState; - struct _GstStatusArea { - GtkWidget parent; + GtkHBox parent; - GstStatusAreaState state; - guchar *playtime; - gboolean expanded; + GtkWidget *state_label; + GtkWidget *location_label; + GtkWidget *time_label; + + gint64 time_nanos; + gint64 length_nanos; + gchar *time_str; }; struct _GstStatusAreaClass { - GtkWidgetClass parent_class; + GtkHBoxClass parent_class; }; GtkType gst_status_area_get_type (void); -GstStatusArea* gst_status_area_new (void); - -void gst_status_area_set_state (GstStatusArea *area, GstStatusAreaState state); -void gst_status_area_set_playtime (GstStatusArea *area, const guchar *time); -void gst_status_area_set_streamtype (GstStatusArea *area, const guchar *type); +GtkWidget* gst_status_area_new (void); -void cb_gst_toggle_extended (void); -void gst_status_area_show_extended (GstStatusArea *area, gboolean show); +void gst_status_area_set_state (GstStatusArea *area, GstElementState old_state, GstElementState new_state); +void gst_status_area_set_location (GstStatusArea *area, const gchar *location); +void gst_status_area_set_time (GstStatusArea *area, gint64 time_nanos); +void gst_status_area_set_length (GstStatusArea *area, gint64 length_nanos); #endif /* __GST_STATUS_AREA_H__ */ |