Hmm, added working (if hacked) full-screen play, shuffled things around, added error...
authorArik Devens <arik@gnome.org>
Wed, 13 Jun 2001 01:18:12 +0000 (01:18 +0000)
committerArik Devens <arik@gnome.org>
Wed, 13 Jun 2001 01:18:12 +0000 (01:18 +0000)
Original commit message from CVS:
Hmm, added working (if hacked) full-screen play, shuffled things around, added error checking so we don't crash on file not found, added the beginnings of a preferences dialog.

gstplay/ChangeLog
gstplay/Makefile.am
gstplay/callbacks.c
gstplay/full-screen.c [deleted file]
gstplay/full-screen.h [deleted file]
gstplay/gstmediaplay.c
gstplay/gstmediaplay.glade
gstplay/gstmediaplay.h
gstplay/gstplay.c
gstplay/gstplay.h
gstplay/main.c

index 946e3077f0fb1c2e5b20970e2369861ecc56a13c..aa134d00a763941d3e64999542d6dab7d9a35831 100644 (file)
@@ -1,3 +1,44 @@
+2001-06-12  Arik Devens  <adevens@antioch-college.edu>
+
+       * gstmediaplay.glade: Added a basic preferences dialog, not hooked
+       up yet.
+
+       * callbacks.c (on_preferences1_activate): Added loading the new
+       preferences dialog.
+
+       * Makefile.am: Removed full-screen.[c,h] from the build.
+
+       * full-screen.h: Removed this file, no longer needed.
+
+       * full-screen.c: Removed this file, no longer needed.
+
+       * gstplay.c (gst_play_get_video_widget): New function to return
+       the actual video_widget.
+       (gst_play_get_source_width): New function to get the width of the
+       source media.
+       (gst_play_get_source_height): New function to get the height of
+       the source media.
+       (gst_play_set_uri): Added check to make sure the file we are
+       trying to play actually exists. i wonder if this fails with
+       gnomevfs?
+
+       * callbacks.c (on_original_size_activate): Use the new function.
+       (on_double_size_activate): Use the new function.
+       (on_full_screen_activate): Use the new function.
+       
+       * gstmediaplay.h (gst_media_play_set_fullscreen): Added function
+       prototypes for the new functions.
+
+       * gstmediaplay.c (gst_media_play_start_uri): Added a check for the
+       return value of set_uri so that we don't crash on not being able
+       to load a file.
+       (gst_media_play_set_original_size): New function to size the
+       video_widget to its default size.
+       (gst_media_play_set_fullscreen): New function to do
+       full-screen. Still a hack but at least this one works.
+       (gst_media_play_set_double_size): New function to size the
+       video_widget to double its default size.
+
 2001-06-06  Arik Devens  <arik@gnome.org>
 
        * gstmediaplay.glade: Dissabled full-screen for the moment till it
index 552490962e544027db68d64ee5c39b3cdbad2f2d..eed8ea90c3d70605f44e723209889b4d6f1b9423 100644 (file)
@@ -20,8 +20,7 @@ libgstmediaplay_la_SOURCES = \
        gstplay.c \
        gstmediaplay.c \
        gststatusarea.c \
-       callbacks.c \
-       full-screen.c
+       callbacks.c
 
 gstmediaplay_SOURCES = \
        main.c 
@@ -34,9 +33,7 @@ noinst_HEADERS = \
        gstmediaplay.h \
        gststatusarea.h \
        callbacks.h \
-       gstplayprivate.h \
-       full-screen.h
-
+       gstplayprivate.h
 
 libgstmediaplay_la_LDFLAGS = -rdynamic
 
index 585efae70dd02b48324c5db99d8a64e7f9fb117c..8e4e92ffca829af4121a446bae96884d3b75310d 100644 (file)
@@ -35,42 +35,43 @@ void
 on_original_size_activate (GtkMenuItem *menuitem, gpointer user_data)
 {
        GstMediaPlay *mplay;
-       GstPlay *play;
 
        mplay = GST_MEDIA_PLAY (user_data);
-       play = mplay->play;
 
-       gst_play_set_display_size (play, 0);
+       gst_media_play_set_original_size (mplay);
 }
 
 void
 on_double_size_activate (GtkMenuItem *menuitem, gpointer user_data)
 {
        GstMediaPlay *mplay;
-       GstPlay *play;
        
        mplay = GST_MEDIA_PLAY (user_data);
-       play = mplay->play;
 
-       gst_play_set_display_size (play, 1);
+       gst_media_play_set_double_size (mplay);
 }
 
 void
 on_full_screen_activate (GtkMenuItem *menuitem, gpointer user_data)
 {
        GstMediaPlay *mplay;
-       GstPlay *play;
 
        mplay = GST_MEDIA_PLAY (user_data);
-       play = mplay->play;
-       
-       gst_play_set_display_size (play, 2);
+
+       gst_media_play_set_fullscreen (mplay);
 }
 
 void
 on_preferences1_activate (GtkMenuItem *menuitem, gpointer user_data)
 {
-       printf ("file1 activate\n");
+       GladeXML *xml;
+       struct stat statbuf;
+
+       if (stat (DATADIR"gstmediaplay.glade", &statbuf) == 0) {
+               xml = glade_xml_new (DATADIR"gstmediaplay.glade", "preferences");
+       }
+       else
+               xml = glade_xml_new ("gstmediaplay.glade", "preferences");
 }
 
 void on_about_activate (GtkWidget *widget, gpointer data)
diff --git a/gstplay/full-screen.c b/gstplay/full-screen.c
deleted file mode 100644 (file)
index c68d7f5..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-#include <config.h>
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtkmain.h>
-#include "full-screen.h"
-#include "gstplay.h"
-
-/* Private part of the FullScreen structure */
-struct _FullScreenPrivate {
-       GstPlay *play;
-
-       /* Whether we have a keyboard grab */
-       guint have_grab : 1;
-};
-
-\f
-
-static void full_screen_class_init (FullScreenClass *class);
-static void full_screen_init (FullScreen *fs);
-static void full_screen_finalize (GtkObject *object);
-
-static void full_screen_show (GtkWidget *widget);
-static void full_screen_hide (GtkWidget *widget);
-
-static gint full_screen_key_press (GtkWidget *widget, GdkEventKey *event);
-
-static GtkWindowClass *parent_class;
-
-/**
-
- * @void:
- *
- * Registers the #FullScreen class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the #FullScreen class.
- **/
-GtkType
-full_screen_get_type (void)
-{
-       static GtkType full_screen_type = 0;
-
-       if (!full_screen_type) {
-               static GtkTypeInfo full_screen_info = {
-                       "FullScreen",
-                       sizeof (FullScreen),
-                       sizeof (FullScreenClass),
-                       (GtkClassInitFunc) full_screen_class_init,
-                       (GtkObjectInitFunc) full_screen_init,
-                       NULL, /* reserved_1 */
-                       NULL, /* reserved_2 */
-                       (GtkClassInitFunc) NULL
-               };
-
-               full_screen_type = gtk_type_unique (GTK_TYPE_WINDOW, &full_screen_info);
-       }
-
-       return full_screen_type;
-}
-
-/* Class initialization function for the full screen mode */
-static void
-full_screen_class_init (FullScreenClass *class)
-{
-       GtkObjectClass *object_class;
-       GtkWidgetClass *widget_class;
-
-       object_class = (GtkObjectClass *) class;
-       widget_class = (GtkWidgetClass *) class;
-
-       parent_class = gtk_type_class (GTK_TYPE_WINDOW);
-
-       object_class->finalize = full_screen_finalize;
-
-       widget_class->show = full_screen_show;
-       widget_class->hide = full_screen_hide;
-       widget_class->key_press_event = full_screen_key_press;
-}
-
-/* Object initialization function for the full screen view */
-static void
-full_screen_init (FullScreen *fs)
-{
-       FullScreenPrivate *priv;
-
-       priv = g_new0 (FullScreenPrivate, 1);
-       fs->priv = priv;
-
-       GTK_WINDOW (fs)->type = GTK_WINDOW_POPUP;
-       g_assert (fs != NULL);
-       gtk_widget_set_usize (GTK_WIDGET (fs), gdk_screen_width (), gdk_screen_height ());
-       gtk_widget_set_uposition (GTK_WIDGET (fs), 0, 0);
-
-       priv->play = gst_play_new();
-       gtk_container_add (GTK_CONTAINER (fs), GTK_WIDGET (priv->play));
-       gtk_widget_show (priv->play);
-}
-
-/* Finalize handler for the full screen view */
-static void
-full_screen_finalize (GtkObject *object)
-{
-       FullScreen *fs;
-       FullScreenPrivate *priv;
-
-       g_return_if_fail (object != NULL);
-       g_return_if_fail (IS_FULL_SCREEN (object));
-
-       fs = FULL_SCREEN (object);
-       priv = fs->priv;
-
-       g_free (priv);
-       fs->priv = NULL;
-
-       if (GTK_OBJECT_CLASS (parent_class)->finalize)
-               (* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-\f
-
-/* Widget methods */
-
-/* Show handler for the full screen view */
-static void
-full_screen_show (GtkWidget *widget)
-{
-       FullScreen *fs;
-       FullScreenPrivate *priv;
-
-       fs = FULL_SCREEN (widget);
-       priv = fs->priv;
-
-       if (GTK_WIDGET_CLASS (parent_class)->show)
-               (* GTK_WIDGET_CLASS (parent_class)->show) (widget);
-
-       priv->have_grab = gdk_keyboard_grab (widget->window, TRUE, GDK_CURRENT_TIME) == 0;
-       gtk_grab_add (widget);
-
-       //gtk_widget_grab_focus (ui_image_get_image_view (UI_IMAGE (priv->ui)));
-}
-
-/* Hide handler for the full screen view */
-static void
-full_screen_hide (GtkWidget *widget)
-{
-       FullScreen *fs;
-       FullScreenPrivate *priv;
-
-       fs = FULL_SCREEN (widget);
-       priv = fs->priv;
-
-       if (priv->have_grab) {
-               priv->have_grab = FALSE;
-               gdk_keyboard_ungrab (GDK_CURRENT_TIME);
-       }
-
-       if (GTK_WIDGET_CLASS (parent_class)->show)
-               (* GTK_WIDGET_CLASS (parent_class)->show) (widget);
-
-       gtk_widget_destroy (widget);
-}
-
-/* Key press handler for the full screen view */
-static gint
-full_screen_key_press (GtkWidget *widget, GdkEventKey *event)
-{
-       gint result;
-       gboolean do_hide;
-
-       result = FALSE;
-
-       if (GTK_WIDGET_CLASS (parent_class)->key_press_event)
-               result = (* GTK_WIDGET_CLASS (parent_class)->key_press_event) (widget, event);
-
-       if (result)
-               return result;
-
-       do_hide = FALSE;
-
-       switch (event->keyval) {
-       case GDK_Escape:
-               do_hide = TRUE;
-               break;
-
-       case GDK_W:
-       case GDK_w:
-               if (event->state & GDK_CONTROL_MASK)
-                       do_hide = TRUE;
-               break;
-
-       case GDK_Q:
-       case GDK_q:
-               do_hide = TRUE;
-               break;
-
-       default:
-               return FALSE;
-       }
-
-       if (do_hide)
-               gtk_widget_hide (widget);
-
-       return TRUE;
-}
-
-\f
-
-/**
- * full_screen_new:
- * @void:
- *
- * Creates a new empty full screen image viewer.
- *
- * Return value: A newly-created full screen image viewer.
- **/
-GtkWidget *
-full_screen_new (void)
-{
-       return GTK_WIDGET (gtk_type_new (TYPE_FULL_SCREEN));
-}
-
-void
-full_screen_set_uri (FullScreen *fs, 
-                    GstPlay *play, 
-                    const guchar *uri)
-{
-       g_return_if_fail (fs != NULL);
-       g_return_if_fail (play != NULL);
-       g_return_if_fail (uri != NULL);
-
-       g_return_if_fail (IS_FULL_SCREEN (fs));
-       g_return_if_fail (GST_IS_PLAY (play));
-
-       gst_play_set_uri (play, uri);
-
-       gst_play_play (play);
-}      
-
-GstPlay *
-full_screen_get_gst_play (FullScreen *fs)
-{
-       FullScreenPrivate *priv;
-       g_return_val_if_fail (fs != NULL, 0);
-
-       priv = fs->priv;
-
-       return priv->play;
-}
diff --git a/gstplay/full-screen.h b/gstplay/full-screen.h
deleted file mode 100644 (file)
index 5e57f61..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef FULL_SCREEN_H
-#define FULL_SCREEN_H
-
-#include <libgnome/gnome-defs.h>
-#include <gtk/gtkwindow.h>
-#include "gstplay.h"
-
-BEGIN_GNOME_DECLS
-
-\f
-
-#define TYPE_FULL_SCREEN            (full_screen_get_type ())
-#define FULL_SCREEN(obj)            (GTK_CHECK_CAST ((obj), TYPE_FULL_SCREEN, FullScreen))
-#define FULL_SCREEN_CLASS(klass)    (GTK_CHECK_CLASS_CAST ((klass), TYPE_FULL_SCREEN,  \
-                                    FullScreenClass))
-#define IS_FULL_SCREEN(obj)         (GTK_CHECK_TYPE ((obj), TYPE_FULL_SCREEN))
-#define IS_FULL_SCREEN_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_FULL_SCREEN))
-
-typedef struct _FullScreen FullScreen;
-typedef struct _FullScreenClass FullScreenClass;
-
-typedef struct _FullScreenPrivate FullScreenPrivate;
-
-struct _FullScreen {
-       GtkWindow window;
-
-       /* Private data */
-       FullScreenPrivate *priv;
-};
-
-struct _FullScreenClass {
-       GtkWindowClass parent_class;
-};
-
-GtkType full_screen_get_type (void);
-
-GtkWidget *full_screen_new (void);
-
-void full_screen_set_uri (FullScreen *fs, GstPlay *play, const guchar *uri);
-GstPlay * full_screen_get_gst_play (FullScreen *fs);
-
-END_GNOME_DECLS
-
-#endif
index e42cc3bfc85bb23b15f7ca665dbe67bb94d6b3ce..936029e0570ceac7671d3285de38e13c0d90a12e 100644 (file)
@@ -20,6 +20,8 @@ static void gst_media_play_slider_changed   (GtkAdjustment   *adj, GstMediaPlay
 static void update_buttons                 (GstMediaPlay *mplay, GstPlayState state);
 static void update_slider                  (GstMediaPlay *mplay, GtkAdjustment *adjustment, gfloat value);
 
+gboolean fullscreen_active = FALSE;
+
 /* signals and args */
 enum {
        LAST_SIGNAL
@@ -230,15 +232,19 @@ gst_media_play_start_uri (GstMediaPlay *play,
 
        if (uri != NULL) {
                ret = gst_play_set_uri (play->play, uri);
-
-               if (!gst_play_media_can_seek (play->play)) {
-                       gtk_widget_set_sensitive (play->slider, FALSE);
+               
+               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);
+                       }
+
+                       gtk_window_set_title (GTK_WINDOW (play->window),
+                                             g_strconcat ( "Gstplay - ", uri, NULL));
+                       
+                       gst_play_play (play->play);
                }
-
-               gtk_window_set_title (GTK_WINDOW (play->window),
-                                     g_strconcat ( "Gstplay - ", uri, NULL));
-
-               gst_play_play (play->play);
        }
 }
 
@@ -387,6 +393,88 @@ on_extended1_activate (GtkCheckMenuItem *item, GstMediaPlay *mplay)
        gdk_threads_enter ();
 }
 
+void
+gst_media_play_set_original_size (GstMediaPlay *mplay)
+{
+       GstPlay *play;
+       GtkWidget *video_widget;
+       gint width, height;
+
+       play = mplay->play;
+
+       video_widget = gst_play_get_video_widget (play);
+       width = gst_play_get_source_width (play);
+       height = gst_play_get_source_height (play);
+
+       gtk_widget_set_usize (video_widget, width, height);
+}
+
+void
+gst_media_play_set_double_size (GstMediaPlay *mplay)
+{
+       GstPlay *play;
+       GtkWidget *video_widget;
+       gint width, height;
+
+       play = mplay->play;
+
+       video_widget = gst_play_get_video_widget (play);
+       width = gst_play_get_source_width (play);
+       height = gst_play_get_source_height (play);
+
+       gtk_widget_set_usize (video_widget, width * 1.5, height * 1.5);
+}
+
+void
+gst_media_play_set_fullscreen (GstMediaPlay *mplay)
+{
+       GdkWindow *gdk_window;
+       gint client_x, client_y, root_x, root_y;
+       gint width, height, source_width, source_height;
+       GstPlay *play;
+       GtkWidget *video_widget;
+
+       gdk_window = mplay->window->window;
+       play = mplay->play;
+
+       video_widget = gst_play_get_video_widget (play);
+       source_width = gst_play_get_source_width (play);
+       source_height = gst_play_get_source_height (play);
+
+       if (!fullscreen_active) {
+               gtk_widget_hide (glade_xml_get_widget (mplay->xml, "dockitem1"));
+               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"));
+
+               gdk_window_get_origin (gdk_window, &root_x, &root_y);
+               gdk_window_get_geometry (gdk_window, &client_x, &client_y,
+                                        &width, &height, NULL);
+               gdk_window_move (gdk_window, -client_x, -client_y);
+               gtk_widget_set_usize (video_widget, gdk_screen_width () + 1,
+                                     gdk_screen_height () + 1);
+
+               mplay->x = root_x - client_x;
+               mplay->y = root_y - client_y;
+               mplay->width = width;
+               mplay->height = height;
+               
+               fullscreen_active = TRUE;
+       } 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_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);
+
+               fullscreen_active = FALSE;
+       }
+}
+
 static void
 gst_media_play_frame_displayed (GstPlay *play, GstMediaPlay *mplay)
 {
index 7ce075b123859ba1a0fb65d86f81ce7cbb0cefdb..e508eb69a794045e4daabc9405c7c9067226b4f7 100644 (file)
                <widget>
                  <class>GtkMenuItem</class>
                  <name>full_screen</name>
-                 <sensitive>False</sensitive>
                  <accelerator>
                    <modifiers>GDK_CONTROL_MASK</modifiers>
                    <key>GDK_3</key>
   <modal>True</modal>
   <wmclass_name>about</wmclass_name>
   <wmclass_class>GstMediaPlay</wmclass_class>
-  <copyright>(C) 1999-2001 Erik Walthinsen</copyright>
+  <copyright>(C) 1999-2001 Erik Walthinsen, Arik Devens</copyright>
   <authors>Erik Walthinsen &lt;omega@cse.ogi.edu&gt;
 Wim Taymans &lt;wim.taymans@tvd.be&gt;
 Richard Boulton &lt;richard@tartarus.org&gt;
@@ -532,4 +531,99 @@ Arik Devens &lt;arik@gnome.org&gt;
   </widget>
 </widget>
 
+<widget>
+  <class>GtkWindow</class>
+  <name>preferences</name>
+  <title>GstMediaPlayer Preferences</title>
+  <type>GTK_WINDOW_TOPLEVEL</type>
+  <position>GTK_WIN_POS_NONE</position>
+  <modal>False</modal>
+  <allow_shrink>False</allow_shrink>
+  <allow_grow>True</allow_grow>
+  <auto_shrink>False</auto_shrink>
+
+  <widget>
+    <class>GtkNotebook</class>
+    <name>notebook1</name>
+    <can_focus>True</can_focus>
+    <show_tabs>True</show_tabs>
+    <show_border>True</show_border>
+    <tab_pos>GTK_POS_TOP</tab_pos>
+    <scrollable>False</scrollable>
+    <tab_hborder>2</tab_hborder>
+    <tab_vborder>2</tab_vborder>
+    <popup_enable>False</popup_enable>
+
+    <widget>
+      <class>GtkFrame</class>
+      <name>frame1</name>
+      <label>Full Screen</label>
+      <label_xalign>0</label_xalign>
+      <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
+
+      <widget>
+       <class>GtkVBox</class>
+       <name>vbox1</name>
+       <homogeneous>False</homogeneous>
+       <spacing>0</spacing>
+
+       <widget>
+         <class>GtkCheckButton</class>
+         <name>checkbutton1</name>
+         <can_focus>True</can_focus>
+         <label>Show file menu</label>
+         <active>False</active>
+         <draw_indicator>True</draw_indicator>
+         <child>
+           <padding>0</padding>
+           <expand>False</expand>
+           <fill>False</fill>
+         </child>
+       </widget>
+
+       <widget>
+         <class>GtkCheckButton</class>
+         <name>checkbutton2</name>
+         <can_focus>True</can_focus>
+         <label>Show player controls</label>
+         <active>False</active>
+         <draw_indicator>True</draw_indicator>
+         <child>
+           <padding>0</padding>
+           <expand>False</expand>
+           <fill>False</fill>
+         </child>
+       </widget>
+
+       <widget>
+         <class>GtkCheckButton</class>
+         <name>checkbutton3</name>
+         <can_focus>True</can_focus>
+         <label>Show status area</label>
+         <active>False</active>
+         <draw_indicator>True</draw_indicator>
+         <child>
+           <padding>0</padding>
+           <expand>False</expand>
+           <fill>False</fill>
+         </child>
+       </widget>
+      </widget>
+    </widget>
+
+    <widget>
+      <class>GtkLabel</class>
+      <child_name>Notebook:tab</child_name>
+      <name>label1</name>
+      <label>Viewers</label>
+      <justify>GTK_JUSTIFY_CENTER</justify>
+      <wrap>False</wrap>
+      <xalign>0.5</xalign>
+      <yalign>0.5</yalign>
+      <xpad>0</xpad>
+      <ypad>0</ypad>
+    </widget>
+  </widget>
+</widget>
+
 </GTK-Interface>
index 4454362208fc914593772122cc6f6db27c642b6f..a009406edf6564875dfea2d526b08fea62d5f989 100644 (file)
@@ -32,6 +32,8 @@ struct _GstMediaPlay {
        GtkWidget *slider;
        
        gulong last_time;
+
+       gint x, y, width, height;
 };
 
 struct _GstMediaPlayClass {
@@ -42,8 +44,12 @@ struct _GstMediaPlayClass {
 GtkType        gst_media_play_get_type         (void);
 
 /* setup the player */
-GstMediaPlay*  gst_media_play_new              (void);
+GstMediaPlay*  gst_media_play_new                (void);
+
+void           gst_media_play_start_uri          (GstMediaPlay *play, const guchar *uri);
 
-void           gst_media_play_start_uri        (GstMediaPlay *play, const guchar *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);
 
 #endif /* __GST_MEDIA_PLAY_H__ */
index 279b1c522d94fc6ec5df0b301bcd6b9c5cb71651..9956dc2fdc1479fe2bbcb3bd7c22708c1bf09439 100644 (file)
@@ -4,7 +4,6 @@
 
 #include "gstplay.h"
 #include "gstplayprivate.h"
-#include "full-screen.h"
 
 static void gst_play_class_init                (GstPlayClass *klass);
 static void gst_play_init              (GstPlay *play);
@@ -165,6 +164,9 @@ gst_play_init (GstPlay *play)
        priv->offset_element = NULL;
        priv->bit_rate_element = NULL;
        priv->media_time_element = NULL;
+
+       priv->source_width = 100;
+       priv->source_height = 100;
 }
 
 GstPlay *
@@ -374,6 +376,7 @@ GstPlayReturn
 gst_play_set_uri (GstPlay *play, const guchar *uri)
 {
        GstPlayPrivate *priv;
+       FILE *file;
        gchar* uriloc;
 
        g_return_val_if_fail (play != NULL, GST_PLAY_ERROR);
@@ -385,6 +388,10 @@ gst_play_set_uri (GstPlay *play, const guchar *uri)
        if (priv->uri)
                g_free (priv->uri);
 
+       /* see if the file actually exists */
+       file = fopen (uri, "r");
+       if (!file)
+               return GST_PLAY_CANNOT_PLAY;
 
        /* see if it looks like an URI */
        if ((uriloc = strstr (uri, ":/"))) {
@@ -498,7 +505,7 @@ gst_play_pause (GstPlay *play)
 
        if (play->state != GST_PLAY_PLAYING) return;
 
-       gst_element_set_state (GST_ELEMENT (priv->pipeline),GST_STATE_PAUSED);
+       gst_element_set_state (GST_ELEMENT (priv->pipeline), GST_STATE_PAUSED);
 
        play->state = GST_PLAY_PAUSED;
        g_idle_remove_by_data (priv->pipeline);
@@ -515,13 +522,13 @@ gst_play_stop (GstPlay *play)
        g_return_if_fail (play != NULL);
        g_return_if_fail (GST_IS_PLAY (play));
 
-       if (play->state == GST_PLAY_STOPPED) return;
-
        priv = (GstPlayPrivate *)play->priv;
 
+       if (play->state == GST_PLAY_STOPPED) return;
+
        // FIXME until state changes are handled properly
-       gst_element_set_state (GST_ELEMENT (priv->pipeline),GST_STATE_READY);
-       gtk_object_set (GTK_OBJECT (priv->src),"offset",0,NULL);
+       gst_element_set_state (GST_ELEMENT (priv->pipeline), GST_STATE_READY);
+       gtk_object_set (GTK_OBJECT (priv->src), "offset", 0, NULL);
        //gst_element_set_state (GST_ELEMENT (priv->pipeline),GST_STATE_NULL);
 
        play->state = GST_PLAY_STOPPED;
@@ -531,37 +538,43 @@ gst_play_stop (GstPlay *play)
                         play->state);
 }
 
-void
-gst_play_set_display_size (GstPlay *play, gint display_preference)
+GtkWidget *
+gst_play_get_video_widget (GstPlay *play)
 {
        GstPlayPrivate *priv;
 
-       g_return_if_fail (play != NULL);
-       g_return_if_fail (GST_IS_PLAY (play));
+       g_return_val_if_fail (play != NULL, 0);
+       g_return_val_if_fail (GST_IS_PLAY (play), 0);
 
        priv = (GstPlayPrivate *)play->priv;
-  
-       if (display_preference == 0) {
-               gtk_widget_set_usize (GTK_WIDGET (priv->video_widget), priv->source_width, priv->source_height);
-       }
-       else if (display_preference == 1) {
-               gtk_widget_set_usize (GTK_WIDGET (priv->video_widget), priv->source_width * 2, priv->source_height * 2);
-       }
-       else if (display_preference == 2) {
-               GtkWidget *fs;
-               GstPlay *fs_play;
-         
-               fs = full_screen_new ();
 
-               fs_play = full_screen_get_gst_play (FULL_SCREEN (fs));
+       return priv->video_widget;
+}
 
-               if (priv->uri != NULL) {
-                       //gst_play_stop (play);
-                       full_screen_set_uri (FULL_SCREEN (fs), fs_play, priv->uri);
+gint
+gst_play_get_source_width (GstPlay *play)
+{
+       GstPlayPrivate *priv;
 
-                       gtk_widget_show (fs);
-               }
-       }
+       g_return_val_if_fail (play != NULL, 0);
+       g_return_val_if_fail (GST_IS_PLAY (play), 0);
+
+       priv = (GstPlayPrivate *)play->priv;
+
+       return priv->source_width;
+}
+
+gint
+gst_play_get_source_height (GstPlay *play)
+{
+       GstPlayPrivate *priv;
+
+       g_return_val_if_fail (play != NULL, 0);
+       g_return_val_if_fail (GST_IS_PLAY (play), 0);
+
+       priv = (GstPlayPrivate *)play->priv;
+
+       return priv->source_height;
 }
 
 gulong
index 8356dd1ee903dd9807caec5bf58c97391780d397..23d578e1ca6f3ddd54cfb6392071225a772306a5 100644 (file)
@@ -76,7 +76,9 @@ gulong                gst_play_get_media_total_time   (GstPlay *play);
 gulong                 gst_play_get_media_current_time (GstPlay *play);
 
 /* set display stuff */
-void            gst_play_set_display_size       ();
+GtkWidget *     gst_play_get_video_widget       (GstPlay *play);
+gint            gst_play_get_source_width       (GstPlay *play);
+gint            gst_play_get_source_height      (GstPlay *play);
 
 /* the autoplugged pipeline */
 GstElement*    gst_play_get_pipeline           (GstPlay *play);
index 765baf5e69899d0d39ff5610ea3c0a3194606013..44338b7d54c4cb1f3405555531bde2041d706f9b 100644 (file)
@@ -11,7 +11,7 @@ main (int argc, char *argv[])
        gnome_init ("gstreamer", VERSION, argc, argv);
        glade_init();
        glade_gnome_init();
-       
+
        play = gst_media_play_new ();
        
        if (argc > 1) {