From 4361a3c1666d261540334a60eefc55c237e3f423 Mon Sep 17 00:00:00 2001 From: Arik Devens Date: Wed, 15 Aug 2001 22:32:30 +0000 Subject: [PATCH] Added a bunch of new stuff including better fullscreen handling and some new playlist stuff that's not hooked up yet. Original commit message from CVS: Added a bunch of new stuff including better fullscreen handling and some new playlist stuff that's not hooked up yet. --- gstplay/ChangeLog | 37 +++++++++++++++- gstplay/gstmediaplay.c | 104 +++++++++++++++++++++++++++++++++++++++------ gstplay/gstmediaplay.glade | 58 +++++++++++++++++++++++++ gstplay/gstmediaplay.h | 10 +++++ gstplay/gstplay.c | 5 +-- gstplay/main.c | 7 +++ 6 files changed, 205 insertions(+), 16 deletions(-) diff --git a/gstplay/ChangeLog b/gstplay/ChangeLog index aa134d0..1c5586a 100644 --- a/gstplay/ChangeLog +++ b/gstplay/ChangeLog @@ -1,4 +1,39 @@ -2001-06-12 Arik Devens +2001-08-15 Arik Devens + + * main.c (main): Disabled the showing of the playlist till it + works. ;-) + + * gstmediaplay.c (gst_media_play_play_item): New function to play + an item when selected in the playlist. + (gst_media_play_show_playlist): New function to show the + playlist. This is temporary till i do an interface overhaul on the + player. + (gst_media_play_addto_playlist): New function to add files to the + playlist. + + * main.c (main): Added stuff for playlist and for handling + multiple files from the console. + + * gstmediaplay.h: Added new items to the GstMediaPlay struct for + playlist stuff and for the fullscreen keypress connection. + + * gstmediaplay.c (fullscreen_key_press_event): New function to + handle keypress stuff so that we leave fullscreen when the user + hits the escape key. + (gst_media_play_set_fullscreen): Added a signal connect/disconnect + for keypress handling. + (gst_media_play_set_original_size): Added checking to see if we + are still in fullscreen mode and if we are leaving it before + sizing to original size. + (gst_media_play_set_double_size): Ditto except for double size. + +2001-08-12 Arik Devens + + * gstmediaplay.c (gst_media_play_set_fullscreen): Added the hiding + and reshowing of the status area when entering and leaving + fullscreen. + +2001-06-12 Arik Devens * gstmediaplay.glade: Added a basic preferences dialog, not hooked up yet. diff --git a/gstplay/gstmediaplay.c b/gstplay/gstmediaplay.c index 936029e..873f682 100644 --- a/gstplay/gstmediaplay.c +++ b/gstplay/gstmediaplay.c @@ -208,7 +208,58 @@ gst_media_play_new () } static void -gst_media_play_update_status_area (GstMediaPlay *play, +gst_media_play_play_item (GtkCList *clist, + gint row, + gint column, + GdkEventButton *event, + GstMediaPlay *mplay) +{ + gchar *text; + + gtk_clist_get_text (clist, row, column, &text); + + gdk_threads_leave (); + gst_media_play_start_uri (mplay, text); + gdk_threads_enter (); +} + +void +gst_media_play_show_playlist (GstMediaPlay *mplay) +{ + struct stat statbuf; + + /* load the interface */ + if (stat (DATADIR"gstmediaplay.glade", &statbuf) == 0) { + mplay->playlist_xml = glade_xml_new (DATADIR"gstmediaplay.glade", "playlist_window"); + } + else { + mplay->playlist_xml = glade_xml_new ("gstmediaplay.glade", "playlist_window"); + } + g_assert (mplay->playlist_xml != NULL); + + mplay->playlist_window = glade_xml_get_widget (mplay->playlist_xml, "playlist_window"); + mplay->playlist_clist = glade_xml_get_widget (mplay->playlist_xml, "playlist_clist"); + + gtk_signal_connect (GTK_OBJECT (mplay->playlist_clist), "select_row", + GTK_SIGNAL_FUNC (gst_media_play_play_item), mplay); + + gtk_window_set_default_size (GTK_WINDOW (mplay->playlist_window), 215, 280); + + gtk_widget_show (mplay->playlist_window); +} + +void +gst_media_play_addto_playlist (GstMediaPlay *mplay, char *uri) +{ + gchar *text[2]; + + text[0] = uri; + + gtk_clist_append (GTK_CLIST (mplay->playlist_clist), text); +} + +static void +gst_media_play_update_status_area (GstMediaPlay *mplay, gulong current_time, gulong total_time) { @@ -218,32 +269,32 @@ gst_media_play_update_status_area (GstMediaPlay *play, current_time / 60, current_time % 60, total_time / 60, total_time % 60); - gst_status_area_set_playtime (play->status, time); + gst_status_area_set_playtime (mplay->status, time); } void -gst_media_play_start_uri (GstMediaPlay *play, +gst_media_play_start_uri (GstMediaPlay *mplay, const guchar *uri) { GstPlayReturn ret; - g_return_if_fail (play != NULL); - g_return_if_fail (GST_IS_MEDIA_PLAY (play)); + g_return_if_fail (mplay != NULL); + g_return_if_fail (GST_IS_MEDIA_PLAY (mplay)); if (uri != NULL) { - ret = gst_play_set_uri (play->play, uri); + ret = gst_play_set_uri (mplay->play, uri); if (ret == GST_PLAY_CANNOT_PLAY) { printf ("*** Cannot load file: %s ***\n", uri); } else { - if (!gst_play_media_can_seek (play->play)) { - gtk_widget_set_sensitive (play->slider, FALSE); + if (!gst_play_media_can_seek (mplay->play)) { + gtk_widget_set_sensitive (mplay->slider, FALSE); } - gtk_window_set_title (GTK_WINDOW (play->window), + gtk_window_set_title (GTK_WINDOW (mplay->window), g_strconcat ( "Gstplay - ", uri, NULL)); - - gst_play_play (play->play); + + gst_play_play (mplay->play); } } } @@ -265,6 +316,8 @@ on_load_file_selected (GtkWidget *button, gst_media_play_start_uri (play, file_name); gdk_threads_enter(); + gst_media_play_addto_playlist (play, file_name); + g_free (data); } @@ -402,6 +455,9 @@ gst_media_play_set_original_size (GstMediaPlay *mplay) play = mplay->play; + if (fullscreen_active) + gst_media_play_set_fullscreen (mplay); + video_widget = gst_play_get_video_widget (play); width = gst_play_get_source_width (play); height = gst_play_get_source_height (play); @@ -418,6 +474,9 @@ gst_media_play_set_double_size (GstMediaPlay *mplay) play = mplay->play; + if (fullscreen_active) + gst_media_play_set_fullscreen (mplay); + video_widget = gst_play_get_video_widget (play); width = gst_play_get_source_width (play); height = gst_play_get_source_height (play); @@ -425,6 +484,20 @@ gst_media_play_set_double_size (GstMediaPlay *mplay) gtk_widget_set_usize (video_widget, width * 1.5, height * 1.5); } +static int +fullscreen_key_press_event (GtkWidget *widget, + GdkEventKey *event, + GstMediaPlay *mplay) +{ + switch (event->keyval) { + case GDK_Escape: + gst_media_play_set_fullscreen (mplay); + break; + } + + return TRUE; +} + void gst_media_play_set_fullscreen (GstMediaPlay *mplay) { @@ -446,6 +519,7 @@ gst_media_play_set_fullscreen (GstMediaPlay *mplay) gtk_widget_hide (glade_xml_get_widget (mplay->xml, "dockitem2")); gtk_widget_hide (glade_xml_get_widget (mplay->xml, "dockitem3")); gtk_widget_hide (glade_xml_get_widget (mplay->xml, "dockitem4")); + gtk_widget_hide (GTK_WIDGET (mplay->status)); gdk_window_get_origin (gdk_window, &root_x, &root_y); gdk_window_get_geometry (gdk_window, &client_x, &client_y, @@ -458,19 +532,25 @@ gst_media_play_set_fullscreen (GstMediaPlay *mplay) mplay->y = root_y - client_y; mplay->width = width; mplay->height = height; - + fullscreen_active = TRUE; + + mplay->fullscreen_connection_id = gtk_signal_connect (GTK_OBJECT (mplay->window), "key_press_event", + (GtkSignalFunc) fullscreen_key_press_event, mplay); } else { gtk_widget_show (glade_xml_get_widget (mplay->xml, "dockitem1")); gtk_widget_show (glade_xml_get_widget (mplay->xml, "dockitem2")); gtk_widget_show (glade_xml_get_widget (mplay->xml, "dockitem3")); gtk_widget_show (glade_xml_get_widget (mplay->xml, "dockitem4")); + gtk_widget_show (GTK_WIDGET (mplay->status)); gtk_widget_queue_resize (glade_xml_get_widget (mplay->xml, "dock1")); gdk_window_move (gdk_window, mplay->x, mplay->y); gtk_widget_set_usize (video_widget, source_width, source_height); + gtk_signal_disconnect (GTK_OBJECT (mplay->window), mplay->fullscreen_connection_id); + fullscreen_active = FALSE; } } diff --git a/gstplay/gstmediaplay.glade b/gstplay/gstmediaplay.glade index e508eb6..3705547 100644 --- a/gstplay/gstmediaplay.glade +++ b/gstplay/gstmediaplay.glade @@ -626,4 +626,62 @@ Arik Devens <arik@gnome.org> + + GtkWindow + playlist_window + playlist + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + + + GtkScrolledWindow + scrolledwindow1 + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + + GtkCList + playlist_clist + True + 2 + 273,80 + GTK_SELECTION_SINGLE + True + GTK_SHADOW_IN + + + GtkLabel + CList:title + track_name + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + track_lengthe + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + diff --git a/gstplay/gstmediaplay.h b/gstplay/gstmediaplay.h index a009406..43f79a7 100644 --- a/gstplay/gstmediaplay.h +++ b/gstplay/gstmediaplay.h @@ -18,6 +18,7 @@ struct _GstMediaPlay { GtkObject parent; GladeXML *xml; + GladeXML *playlist_xml; GstPlay *play; GtkWidget *play_button; @@ -30,6 +31,12 @@ struct _GstMediaPlay { // the slider GtkAdjustment *adjustment; GtkWidget *slider; + + // the playlist + GtkWidget *playlist_window; + GtkWidget *playlist_clist; + + guint fullscreen_connection_id; gulong last_time; @@ -48,6 +55,9 @@ GstMediaPlay* gst_media_play_new (void); void gst_media_play_start_uri (GstMediaPlay *play, const guchar *uri); +void gst_media_play_show_playlist (GstMediaPlay *mplay); +void gst_media_play_addto_playlist (GstMediaPlay *mplay, char *uri); + void gst_media_play_set_original_size (GstMediaPlay *mplay); void gst_media_play_set_double_size (GstMediaPlay *mplay); void gst_media_play_set_fullscreen (GstMediaPlay *mplay); diff --git a/gstplay/gstplay.c b/gstplay/gstplay.c index 1bd39d7..ffd6cbb 100644 --- a/gstplay/gstplay.c +++ b/gstplay/gstplay.c @@ -251,7 +251,7 @@ gst_play_object_introspect (GstObject *object, const gchar *property, GstElement } else { *target = element; - GST_DEBUG(0, "gstplay: using element \"%s\" for %s property\n", + GST_DEBUG(0, "gstplay: using element \"%s\" for %s property\n", gst_element_get_name(element), property); } } @@ -382,7 +382,7 @@ gst_play_set_uri (GstPlay *play, const guchar *uri) g_return_val_if_fail (play != NULL, GST_PLAY_ERROR); g_return_val_if_fail (GST_IS_PLAY (play), GST_PLAY_ERROR); g_return_val_if_fail (uri != NULL, GST_PLAY_ERROR); - + priv = (GstPlayPrivate *)play->priv; if (priv->uri) @@ -413,7 +413,6 @@ gst_play_set_uri (GstPlay *play, const guchar *uri) gtk_object_set (G_OBJECT (priv->src), "location", priv->uri, NULL); - priv->cache = gst_elementfactory_make ("autoplugcache", "cache"); g_return_val_if_fail (priv->cache != NULL, GST_PLAY_CANNOT_PLAY); diff --git a/gstplay/main.c b/gstplay/main.c index 44338b7..0d968dc 100644 --- a/gstplay/main.c +++ b/gstplay/main.c @@ -15,7 +15,14 @@ main (int argc, char *argv[]) play = gst_media_play_new (); if (argc > 1) { + int i; + + //gst_media_play_show_playlist (play); gst_media_play_start_uri (play, argv[1]); + + for (i=1;iplay))); -- 2.7.4