playing at double size, general code cleanup and what not.

Original commit message from CVS:
added the begninnings of full-screen support (crashes atm), playing at double size, general code cleanup and what not.
This commit is contained in:
Arik Devens 2001-05-21 01:19:06 +00:00
parent 4212a8dfdc
commit 861256b0db
14 changed files with 1453 additions and 1126 deletions

View file

@ -20,7 +20,8 @@ libgstmediaplay_la_SOURCES = \
gstplay.c \
gstmediaplay.c \
gststatusarea.c \
callbacks.c
callbacks.c \
full-screen.c
gstmediaplay_SOURCES = \
main.c
@ -33,8 +34,8 @@ noinst_HEADERS = \
gstmediaplay.h \
gststatusarea.h \
callbacks.h \
gstplayprivate.h
gstplayprivate.h \
full-screen.h
libgstmediaplay_la_LDFLAGS = -rdynamic

View file

@ -1,68 +1,95 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#include <config.h>
#endif
#include <gnome.h>
#include <glade/glade.h>
#include <gst/gst.h>
#include <sys/stat.h>
#include <unistd.h>
#include "gstmediaplay.h"
#include "gstplay.h"
#include "callbacks.h"
GtkFileSelection *open_file_selection;
void
on_save1_activate (GtkMenuItem *menuitem,
gpointer user_data)
on_save1_activate (GtkMenuItem *menuitem, gpointer user_data)
{
printf("file1 activate\n");
printf ("file1 activate\n");
}
void
on_save_as1_activate (GtkMenuItem *menuitem,
gpointer user_data)
on_save_as1_activate (GtkMenuItem *menuitem, gpointer user_data)
{
printf("file1 activate\n");
printf ("file1 activate\n");
}
void
on_media2_activate (GtkMenuItem *menuitem,
gpointer user_data)
on_media2_activate (GtkMenuItem *menuitem, gpointer user_data)
{
printf("file1 activate\n");
printf ("file1 activate\n");
}
void
on_preferences1_activate (GtkMenuItem *menuitem,
gpointer user_data)
on_original_size_activate (GtkMenuItem *menuitem, gpointer user_data)
{
printf("file1 activate\n");
GstMediaPlay *mplay;
GstPlay *play;
mplay = GST_MEDIA_PLAY (user_data);
play = mplay->play;
gst_play_set_display_size (play, 0);
}
void on_about_activate(GtkWidget *widget, gpointer data)
void
on_double_size_activate (GtkMenuItem *menuitem, gpointer user_data)
{
GladeXML *xml;
struct stat statbuf;
GstMediaPlay *mplay;
GstPlay *play;
mplay = GST_MEDIA_PLAY (user_data);
play = mplay->play;
if (stat(DATADIR"gstmediaplay.glade", &statbuf) == 0) {
xml = glade_xml_new (DATADIR"gstmediaplay.glade", "about");
}
else {
xml = glade_xml_new ("gstmediaplay.glade", "about");
}
/* connect the signals in the interface */
glade_xml_signal_autoconnect(xml);
gst_play_set_display_size (play, 1);
}
void on_gstplay_destroy(GtkWidget *widget, gpointer data)
void
on_full_screen_activate (GtkMenuItem *menuitem, gpointer user_data)
{
gst_main_quit();
GstMediaPlay *mplay;
GstPlay *play;
mplay = GST_MEDIA_PLAY (user_data);
play = mplay->play;
gst_play_set_display_size (play, 2);
}
void
on_preferences1_activate (GtkMenuItem *menuitem, gpointer user_data)
{
printf ("file1 activate\n");
}
void on_about_activate (GtkWidget *widget, gpointer data)
{
GladeXML *xml;
struct stat statbuf;
if (stat (DATADIR"gstmediaplay.glade", &statbuf) == 0) {
xml = glade_xml_new (DATADIR"gstmediaplay.glade", "about");
}
else
xml = glade_xml_new ("gstmediaplay.glade", "about");
/* connect the signals in the interface */
glade_xml_signal_autoconnect (xml);
}
void on_gstplay_destroy (GtkWidget *widget, gpointer data)
{
gst_main_quit();
}

View file

@ -1,42 +1,35 @@
#include <gnome.h>
void
on_file1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_open1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_close1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_media1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_play2_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_pause1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_stop1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_file1_activate (GtkMenuItem *menuitem,
gpointer user_data);
on_about1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_open1_activate (GtkMenuItem *menuitem,
gpointer user_data);
on_hscale1_value_changed (GtkAdjustment *adj,
gpointer user_data);
void
on_close1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_media1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_play2_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_pause1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_stop1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_about1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_hscale1_value_changed (GtkAdjustment *adj,
gpointer user_data);
void
on_drawingarea1_configure_event (GtkWidget *widget, GdkEventConfigure *event,
gpointer user_data);
on_drawingarea1_configure_event (GtkWidget *widget,
GdkEventConfigure *event,
gpointer user_data);

247
gstplay/full-screen.c Normal file
View file

@ -0,0 +1,247 @@
#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;
};
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);
}
/* 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;
}
/**
* 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;
}

44
gstplay/full-screen.h Normal file
View file

@ -0,0 +1,44 @@
#ifndef FULL_SCREEN_H
#define FULL_SCREEN_H
#include <libgnome/gnome-defs.h>
#include <gtk/gtkwindow.h>
#include "gstplay.h"
BEGIN_GNOME_DECLS
#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

View file

@ -1,8 +1,3 @@
/*
* Initial main.c file generated by Glade. Edit as required.
* Glade will not overwrite this file.
*/
#include <config.h>
#include <sys/stat.h>
@ -12,26 +7,26 @@
#include "gstmediaplay.h"
#include "callbacks.h"
static void gst_media_play_class_init (GstMediaPlayClass *klass);
static void gst_media_play_init (GstMediaPlay *play);
static void gst_media_play_class_init (GstMediaPlayClass *klass);
static void gst_media_play_init (GstMediaPlay *play);
static void gst_media_play_set_arg (GtkObject *object,GtkArg *arg,guint id);
static void gst_media_play_get_arg (GtkObject *object,GtkArg *arg,guint id);
static void gst_media_play_set_arg (GtkObject *object, GtkArg *arg, guint id);
static void gst_media_play_get_arg (GtkObject *object, GtkArg *arg, guint id);
static void gst_media_play_frame_displayed (GstPlay *play, GstMediaPlay *mplay);
static void gst_media_play_state_changed (GstPlay *play, GstPlayState state, GstMediaPlay *mplay);
static void gst_media_play_slider_changed (GtkAdjustment *adj, GstMediaPlay *mplay);
static void gst_media_play_frame_displayed (GstPlay *play, GstMediaPlay *mplay);
static void gst_media_play_state_changed (GstPlay *play, GstPlayState state, GstMediaPlay *mplay);
static void gst_media_play_slider_changed (GtkAdjustment *adj, GstMediaPlay *mplay);
static void update_buttons (GstMediaPlay *mplay, GstPlayState state);
static void update_slider (GstMediaPlay *mplay, GtkAdjustment *adjustment, gfloat value);
static void update_buttons (GstMediaPlay *mplay, GstPlayState state);
static void update_slider (GstMediaPlay *mplay, GtkAdjustment *adjustment, gfloat value);
/* signals and args */
enum {
LAST_SIGNAL
LAST_SIGNAL
};
enum {
ARG_0,
ARG_0,
};
static void
@ -44,58 +39,58 @@ target_drag_data_received (GtkWidget *widget,
guint time,
GstMediaPlay *play)
{
if (strstr (data->data, "file:")) {
g_print ("Got: %s\n",&data->data[5]);
gdk_threads_leave ();
gst_media_play_start_uri (play, g_strchomp(&data->data[5]));
gdk_threads_enter ();
}
if (strstr (data->data, "file:")) {
g_print ("Got: %s\n", &data->data[5]);
gdk_threads_leave ();
gst_media_play_start_uri (play, g_strchomp (&data->data[5]));
gdk_threads_enter ();
}
}
static GtkTargetEntry target_table[] = {
{ "text/plain", 0, 0 }
{ "text/plain", 0, 0 }
};
static GtkObject *parent_class = NULL;
//static guint gst_media_play_signals[LAST_SIGNAL] = { 0 };
GtkType
gst_media_play_get_type(void)
gst_media_play_get_type (void)
{
static GtkType play_type = 0;
static GtkType play_type = 0;
if (!play_type) {
static const GtkTypeInfo play_info = {
"GstMediaPlay",
sizeof(GstMediaPlay),
sizeof(GstMediaPlayClass),
(GtkClassInitFunc)gst_media_play_class_init,
(GtkObjectInitFunc)gst_media_play_init,
NULL,
NULL,
(GtkClassInitFunc)NULL,
};
play_type = gtk_type_unique(gtk_object_get_type(),&play_info);
}
return play_type;
if (!play_type) {
static const GtkTypeInfo play_info = {
"GstMediaPlay",
sizeof (GstMediaPlay),
sizeof (GstMediaPlayClass),
(GtkClassInitFunc) gst_media_play_class_init,
(GtkObjectInitFunc) gst_media_play_init,
NULL,
NULL,
(GtkClassInitFunc) NULL,
};
play_type = gtk_type_unique (gtk_object_get_type(), &play_info);
}
return play_type;
}
static void
gst_media_play_class_init (GstMediaPlayClass *klass)
{
GtkObjectClass *object_class;
GtkObjectClass *object_class;
parent_class = gtk_type_class (gtk_object_get_type ());
parent_class = gtk_type_class (gtk_object_get_type ());
object_class = (GtkObjectClass*)klass;
object_class = (GtkObjectClass*) klass;
object_class->set_arg = gst_media_play_set_arg;
object_class->get_arg = gst_media_play_get_arg;
object_class->set_arg = gst_media_play_set_arg;
object_class->get_arg = gst_media_play_get_arg;
}
typedef struct {
GstMediaPlay *play;
GModule *symbols;
GstMediaPlay *play;
GModule *symbols;
} connect_struct;
/* we need more control here so... */
@ -108,107 +103,107 @@ gst_media_play_connect_func (const gchar *handler_name,
gboolean after,
gpointer user_data)
{
GtkSignalFunc func;
connect_struct *data = (connect_struct *)user_data;
GtkSignalFunc func;
connect_struct *data = (connect_struct *) user_data;
if (!g_module_symbol (data->symbols, handler_name, (gpointer *)&func))
g_warning("gsteditorproperty: could not find signal handler '%s'.", handler_name);
else {
if (after)
gtk_signal_connect_after (object, signal_name, func, (gpointer) data->play);
else
gtk_signal_connect (object, signal_name, func, (gpointer) data->play);
}
if (!g_module_symbol (data->symbols, handler_name, (gpointer *)&func))
g_warning ("gsteditorproperty: could not find signal handler '%s'.", handler_name);
else {
if (after)
gtk_signal_connect_after (object, signal_name, func, (gpointer) data->play);
else
gtk_signal_connect (object, signal_name, func, (gpointer) data->play);
}
}
static void
gst_media_play_init(GstMediaPlay *mplay)
gst_media_play_init (GstMediaPlay *mplay)
{
GModule *symbols;
connect_struct data;
struct stat statbuf;
GModule *symbols;
connect_struct data;
struct stat statbuf;
/* load the interface */
if (stat(DATADIR"gstmediaplay.glade", &statbuf) == 0) {
mplay->xml = glade_xml_new (DATADIR"gstmediaplay.glade", "gstplay");
}
else {
mplay->xml = glade_xml_new ("gstmediaplay.glade", "gstplay");
}
g_assert (mplay->xml != NULL);
/* load the interface */
if (stat (DATADIR"gstmediaplay.glade", &statbuf) == 0) {
mplay->xml = glade_xml_new (DATADIR"gstmediaplay.glade", "gstplay");
}
else {
mplay->xml = glade_xml_new ("gstmediaplay.glade", "gstplay");
}
g_assert (mplay->xml != NULL);
mplay->slider = glade_xml_get_widget(mplay->xml, "slider");
g_assert (mplay->slider != NULL);
{
GtkArg arg;
GtkRange *range;
mplay->slider = glade_xml_get_widget (mplay->xml, "slider");
g_assert (mplay->slider != NULL);
{
GtkArg arg;
GtkRange *range;
arg.name = "adjustment";
gtk_object_getv (GTK_OBJECT (mplay->slider), 1, &arg);
range = GTK_RANGE (GTK_VALUE_POINTER (arg));
mplay->adjustment = gtk_range_get_adjustment (range);
arg.name = "adjustment";
gtk_object_getv (GTK_OBJECT (mplay->slider), 1, &arg);
range = GTK_RANGE (GTK_VALUE_POINTER (arg));
mplay->adjustment = gtk_range_get_adjustment (range);
gtk_signal_connect (GTK_OBJECT (mplay->adjustment), "value_changed",
GTK_SIGNAL_FUNC (gst_media_play_slider_changed), mplay);
}
gtk_signal_connect (GTK_OBJECT (mplay->adjustment), "value_changed",
GTK_SIGNAL_FUNC (gst_media_play_slider_changed), mplay);
}
mplay->play_button = glade_xml_get_widget (mplay->xml, "toggle_play");
g_assert (mplay->play_button != NULL);
mplay->pause_button = glade_xml_get_widget (mplay->xml, "toggle_pause");
g_assert (mplay->pause_button != NULL);
mplay->stop_button = glade_xml_get_widget (mplay->xml, "toggle_stop");
g_assert (mplay->stop_button != NULL);
mplay->play_button = glade_xml_get_widget (mplay->xml, "toggle_play");
g_assert (mplay->play_button != NULL);
mplay->pause_button = glade_xml_get_widget (mplay->xml, "toggle_pause");
g_assert (mplay->pause_button != NULL);
mplay->stop_button = glade_xml_get_widget (mplay->xml, "toggle_stop");
g_assert (mplay->stop_button != NULL);
mplay->window = glade_xml_get_widget (mplay->xml, "gstplay");
g_assert (mplay->window != NULL);
mplay->window = glade_xml_get_widget (mplay->xml, "gstplay");
g_assert (mplay->window != NULL);
gtk_drag_dest_set (mplay->window,
GTK_DEST_DEFAULT_ALL,
target_table, 1,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (mplay->window), "drag_data_received",
GTK_SIGNAL_FUNC (target_drag_data_received),
mplay);
gtk_drag_dest_set (mplay->window,
GTK_DEST_DEFAULT_ALL,
target_table, 1,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (mplay->window), "drag_data_received",
GTK_SIGNAL_FUNC (target_drag_data_received),
mplay);
mplay->play = gst_play_new();
mplay->play = gst_play_new();
gtk_signal_connect (GTK_OBJECT (mplay->play), "frame_displayed",
GTK_SIGNAL_FUNC (gst_media_play_frame_displayed),
mplay);
gtk_signal_connect (GTK_OBJECT (mplay->play), "frame_displayed",
GTK_SIGNAL_FUNC (gst_media_play_frame_displayed),
mplay);
gtk_signal_connect (GTK_OBJECT (mplay->play), "audio_played",
GTK_SIGNAL_FUNC (gst_media_play_frame_displayed),
mplay);
gtk_signal_connect (GTK_OBJECT (mplay->play), "audio_played",
GTK_SIGNAL_FUNC (gst_media_play_frame_displayed),
mplay);
gtk_signal_connect (GTK_OBJECT (mplay->play), "playing_state_changed",
GTK_SIGNAL_FUNC (gst_media_play_state_changed),
mplay);
gtk_signal_connect (GTK_OBJECT (mplay->play), "playing_state_changed",
GTK_SIGNAL_FUNC (gst_media_play_state_changed),
mplay);
gnome_dock_set_client_area (GNOME_DOCK (glade_xml_get_widget(mplay->xml, "dock1")),
GTK_WIDGET (mplay->play));
gnome_dock_set_client_area (GNOME_DOCK (glade_xml_get_widget(mplay->xml, "dock1")),
GTK_WIDGET (mplay->play));
gtk_widget_show (GTK_WIDGET (mplay->play));
gtk_widget_show (GTK_WIDGET (mplay->play));
mplay->status = (GstStatusArea *)glade_xml_get_widget (mplay->xml, "status_area");
gst_status_area_set_state (mplay->status, GST_STATUS_AREA_STATE_INIT);
gst_status_area_set_playtime (mplay->status, "00:00 / 00:00");
mplay->status = (GstStatusArea *) glade_xml_get_widget (mplay->xml, "status_area");
gst_status_area_set_state (mplay->status, GST_STATUS_AREA_STATE_INIT);
gst_status_area_set_playtime (mplay->status, "00:00 / 00:00");
symbols = g_module_open (NULL, 0);
symbols = g_module_open (NULL, 0);
data.play = mplay;
data.symbols = symbols;
data.play = mplay;
data.symbols = symbols;
glade_xml_signal_autoconnect_full (mplay->xml, gst_media_play_connect_func, &data);
glade_xml_signal_autoconnect_full (mplay->xml, gst_media_play_connect_func, &data);
mplay->last_time = 0;
mplay->last_time = 0;
}
GstMediaPlay *
gst_media_play_new ()
{
return GST_MEDIA_PLAY (gtk_type_new (GST_TYPE_MEDIA_PLAY));
return GST_MEDIA_PLAY (gtk_type_new (GST_TYPE_MEDIA_PLAY));
}
static void
@ -216,84 +211,84 @@ gst_media_play_update_status_area (GstMediaPlay *play,
gulong current_time,
gulong total_time)
{
gchar time[14];
gchar time[14];
sprintf(time, "%02lu:%02lu / %02lu:%02lu",
current_time/60, current_time%60,
total_time/60, total_time%60);
sprintf (time, "%02lu:%02lu / %02lu:%02lu",
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 (play->status, time);
}
void
gst_media_play_start_uri (GstMediaPlay *play,
const guchar *uri)
{
GstPlayReturn ret;
GstPlayReturn ret;
g_return_if_fail (play != NULL);
g_return_if_fail (GST_IS_MEDIA_PLAY (play));
g_return_if_fail (play != NULL);
g_return_if_fail (GST_IS_MEDIA_PLAY (play));
if (uri != NULL) {
ret = gst_play_set_uri (play->play, uri);
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 (!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));
gtk_window_set_title (GTK_WINDOW (play->window),
g_strconcat ( "Gstplay - ", uri, NULL));
gst_play_play (play->play);
}
gst_play_play (play->play);
}
}
typedef struct {
GtkWidget *selection;
GstMediaPlay *play;
GtkWidget *selection;
GstMediaPlay *play;
} file_select;
static void
on_load_file_selected (GtkWidget *button,
file_select *data)
{
GtkWidget *selector = data->selection;
GstMediaPlay *play = data->play;
GtkWidget *selector = data->selection;
GstMediaPlay *play = data->play;
gchar *file_name = gtk_file_selection_get_filename (GTK_FILE_SELECTION(selector));
gdk_threads_leave();
gst_media_play_start_uri (play, file_name);
gdk_threads_enter();
gchar *file_name = gtk_file_selection_get_filename (GTK_FILE_SELECTION (selector));
gdk_threads_leave();
gst_media_play_start_uri (play, file_name);
gdk_threads_enter();
g_free (data);
g_free (data);
}
void
on_open2_activate (GtkWidget *widget,
GstMediaPlay *play)
{
GtkWidget *file_selector;
file_select *file_data = g_new0 (file_select, 1);
GtkWidget *file_selector;
file_select *file_data = g_new0 (file_select, 1);
file_selector = gtk_file_selection_new("Please select a file to load.");
file_selector = gtk_file_selection_new ("Please select a file to load.");
file_data->selection = file_selector;
file_data->play = play;
file_data->selection = file_selector;
file_data->play = play;
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->ok_button),
"clicked", GTK_SIGNAL_FUNC (on_load_file_selected),
file_data);
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button),
"clicked", GTK_SIGNAL_FUNC (on_load_file_selected),
file_data);
/* Ensure that the dialog box is destroyed when the user clicks a button. */
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->ok_button),
"clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
(gpointer) file_selector);
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->cancel_button),
"clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
(gpointer) file_selector);
/* Ensure that the dialog box is destroyed when the user clicks a button. */
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button),
"clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
(gpointer) file_selector);
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->cancel_button),
"clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
(gpointer) file_selector);
/* Display that dialog */
gtk_widget_show (file_selector);
/* Display that dialog */
gtk_widget_show (file_selector);
}
@ -302,14 +297,14 @@ gst_media_play_set_arg (GtkObject *object,
GtkArg *arg,
guint id)
{
GstMediaPlay *play;
play = GST_MEDIA_PLAY (object);
GstMediaPlay *play;
play = GST_MEDIA_PLAY (object);
switch (id) {
default:
g_warning("GstMediaPlay: unknown arg!");
break;
}
switch (id) {
default:
g_warning ("GstMediaPlay: unknown arg!");
break;
}
}
static void
@ -317,63 +312,61 @@ gst_media_play_get_arg (GtkObject *object,
GtkArg *arg,
guint id)
{
GstMediaPlay *play;
GstMediaPlay *play;
play = GST_MEDIA_PLAY (object);
play = GST_MEDIA_PLAY (object);
switch (id) {
default:
arg->type = GTK_TYPE_INVALID;
break;
}
switch (id) {
default:
arg->type = GTK_TYPE_INVALID;
break;
}
}
static void
gst_media_play_state_changed (GstPlay *play,
GstPlayState state,
GstMediaPlay *mplay)
gst_media_play_state_changed (GstPlay *play,
GstPlayState state,
GstMediaPlay *mplay)
{
GstStatusAreaState area_state;
GstStatusAreaState area_state;
g_return_if_fail (GST_IS_PLAY (play));
g_return_if_fail (GST_IS_MEDIA_PLAY (mplay));
g_return_if_fail (GST_IS_PLAY (play));
g_return_if_fail (GST_IS_MEDIA_PLAY (mplay));
gdk_threads_enter ();
update_buttons (mplay, state);
gdk_threads_enter ();
update_buttons (mplay, state);
switch (state) {
case GST_PLAY_STOPPED:
area_state = GST_STATUS_AREA_STATE_STOPPED;
break;
case GST_PLAY_PLAYING:
area_state = GST_STATUS_AREA_STATE_PLAYING;
break;
case GST_PLAY_PAUSED:
area_state = GST_STATUS_AREA_STATE_PAUSED;
break;
default:
area_state = GST_STATUS_AREA_STATE_INIT;
}
gst_status_area_set_state (mplay->status, area_state);
gdk_threads_leave ();
switch (state) {
case GST_PLAY_STOPPED:
area_state = GST_STATUS_AREA_STATE_STOPPED;
break;
case GST_PLAY_PLAYING:
area_state = GST_STATUS_AREA_STATE_PLAYING;
break;
case GST_PLAY_PAUSED:
area_state = GST_STATUS_AREA_STATE_PAUSED;
break;
default:
area_state = GST_STATUS_AREA_STATE_INIT;
}
gst_status_area_set_state (mplay->status, area_state);
gdk_threads_leave ();
}
void
on_gst_media_play_destroy (GtkWidget *widget,
GstMediaPlay *mplay)
on_gst_media_play_destroy (GtkWidget *widget, GstMediaPlay *mplay)
{
gst_main_quit ();
gst_main_quit ();
}
void
on_exit_menu_activate (GtkWidget *widget,
GstMediaPlay *mplay)
on_exit_menu_activate (GtkWidget *widget, GstMediaPlay *mplay)
{
gdk_threads_leave ();
gst_play_stop (mplay->play);
gdk_threads_enter ();
gst_main_quit ();
gdk_threads_leave ();
gst_play_stop (mplay->play);
gdk_threads_enter ();
gst_main_quit ();
}
gint
@ -381,128 +374,121 @@ on_gst_media_play_delete_event (GtkWidget *widget,
GdkEvent *event,
GstMediaPlay *mplay)
{
gdk_threads_leave ();
gst_play_stop (mplay->play);
gdk_threads_enter ();
return FALSE;
gdk_threads_leave ();
gst_play_stop (mplay->play);
gdk_threads_enter ();
return FALSE;
}
void
on_extended1_activate (GtkCheckMenuItem *item,
GstMediaPlay *mplay)
on_extended1_activate (GtkCheckMenuItem *item, GstMediaPlay *mplay)
{
gdk_threads_leave ();
gst_status_area_show_extended (mplay->status, item->active);
gdk_threads_enter ();
gdk_threads_leave ();
gst_status_area_show_extended (mplay->status, item->active);
gdk_threads_enter ();
}
static void
gst_media_play_frame_displayed (GstPlay *play,
GstMediaPlay *mplay)
gst_media_play_frame_displayed (GstPlay *play, GstMediaPlay *mplay)
{
gulong current_time;
gulong total_time;
gulong size, current_offset;
gulong current_time;
gulong total_time;
gulong size, current_offset;
g_return_if_fail (GST_IS_PLAY (play));
g_return_if_fail (GST_IS_MEDIA_PLAY (mplay));
g_return_if_fail (GST_IS_PLAY (play));
g_return_if_fail (GST_IS_MEDIA_PLAY (mplay));
current_time = gst_play_get_media_current_time (play);
total_time = gst_play_get_media_total_time (play);
size = gst_play_get_media_size (play);
current_offset = gst_play_get_media_offset (play);
current_time = gst_play_get_media_current_time (play);
total_time = gst_play_get_media_total_time (play);
size = gst_play_get_media_size (play);
current_offset = gst_play_get_media_offset (play);
//g_print ("%lu %lu %lu %lu\n", current_time, total_time, size, current_offset);
//g_print ("%lu %lu %lu %lu\n", current_time, total_time, size, current_offset);
if (current_time != mplay->last_time) {
gdk_threads_enter ();
gst_media_play_update_status_area (mplay, current_time, total_time);
update_slider (mplay, mplay->adjustment, current_offset*100.0/size);
mplay->last_time = current_time;
gdk_threads_leave ();
}
if (current_time != mplay->last_time) {
gdk_threads_enter ();
gst_media_play_update_status_area (mplay, current_time, total_time);
update_slider (mplay, mplay->adjustment, current_offset*100.0/size);
mplay->last_time = current_time;
gdk_threads_leave ();
}
}
static void
gst_media_play_slider_changed (GtkAdjustment *adj,
GstMediaPlay *mplay)
gst_media_play_slider_changed (GtkAdjustment *adj, GstMediaPlay *mplay)
{
gulong size;
gulong size;
g_return_if_fail (GST_IS_MEDIA_PLAY (mplay));
g_return_if_fail (GST_IS_MEDIA_PLAY (mplay));
size = gst_play_get_media_size (mplay->play);
size = gst_play_get_media_size (mplay->play);
gst_play_media_seek(mplay->play, (int)(adj->value*size/100.0));
gst_play_media_seek (mplay->play, (int)(adj->value*size/100.0));
}
void
on_toggle_play_toggled (GtkToggleButton *togglebutton,
GstMediaPlay *play)
on_toggle_play_toggled (GtkToggleButton *togglebutton, GstMediaPlay *play)
{
gdk_threads_leave ();
gst_play_play (play->play);
gdk_threads_enter ();
update_buttons (play, GST_PLAY_STATE(play->play));
gdk_threads_leave ();
gst_play_play (play->play);
gdk_threads_enter ();
update_buttons (play, GST_PLAY_STATE(play->play));
}
void
on_toggle_pause_toggled (GtkToggleButton *togglebutton,
GstMediaPlay *play)
on_toggle_pause_toggled (GtkToggleButton *togglebutton, GstMediaPlay *play)
{
gdk_threads_leave ();
gst_play_pause (play->play);
gdk_threads_enter ();
update_buttons (play, GST_PLAY_STATE(play->play));
gdk_threads_leave ();
gst_play_pause (play->play);
gdk_threads_enter ();
update_buttons (play, GST_PLAY_STATE(play->play));
}
void
on_toggle_stop_toggled (GtkToggleButton *togglebutton,
GstMediaPlay *play)
on_toggle_stop_toggled (GtkToggleButton *togglebutton, GstMediaPlay *play)
{
gdk_threads_leave ();
gst_play_stop (play->play);
gdk_threads_enter ();
update_buttons (play, GST_PLAY_STATE(play->play));
gdk_threads_leave ();
gst_play_stop (play->play);
gdk_threads_enter ();
update_buttons (play, GST_PLAY_STATE(play->play));
}
static void
update_buttons (GstMediaPlay *mplay,
GstPlayState state)
update_buttons (GstMediaPlay *mplay, GstPlayState state)
{
gtk_signal_handler_block_by_func (GTK_OBJECT (mplay->play_button),
GTK_SIGNAL_FUNC (on_toggle_play_toggled),
mplay);
gtk_signal_handler_block_by_func (GTK_OBJECT (mplay->pause_button),
GTK_SIGNAL_FUNC (on_toggle_pause_toggled),
mplay);
gtk_signal_handler_block_by_func (GTK_OBJECT (mplay->stop_button),
GTK_SIGNAL_FUNC (on_toggle_stop_toggled),
mplay);
gtk_signal_handler_block_by_func (GTK_OBJECT (mplay->play_button),
GTK_SIGNAL_FUNC (on_toggle_play_toggled),
mplay);
gtk_signal_handler_block_by_func (GTK_OBJECT (mplay->pause_button),
GTK_SIGNAL_FUNC (on_toggle_pause_toggled),
mplay);
gtk_signal_handler_block_by_func (GTK_OBJECT (mplay->stop_button),
GTK_SIGNAL_FUNC (on_toggle_stop_toggled),
mplay);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mplay->play_button), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mplay->pause_button), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mplay->stop_button), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mplay->play_button), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mplay->pause_button), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mplay->stop_button), FALSE);
if (state == GST_PLAY_PLAYING) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mplay->play_button), TRUE);
}
else if (state == GST_PLAY_PAUSED) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mplay->pause_button), TRUE);
}
else if (state == GST_PLAY_STOPPED) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mplay->stop_button), TRUE);
}
gtk_signal_handler_unblock_by_func (GTK_OBJECT (mplay->play_button),
GTK_SIGNAL_FUNC (on_toggle_play_toggled),
mplay);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (mplay->pause_button),
GTK_SIGNAL_FUNC (on_toggle_pause_toggled),
mplay);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (mplay->stop_button),
GTK_SIGNAL_FUNC (on_toggle_stop_toggled),
mplay);
if (state == GST_PLAY_PLAYING) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mplay->play_button), TRUE);
}
else if (state == GST_PLAY_PAUSED) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mplay->pause_button), TRUE);
}
else if (state == GST_PLAY_STOPPED) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mplay->stop_button), TRUE);
}
gtk_signal_handler_unblock_by_func (GTK_OBJECT (mplay->play_button),
GTK_SIGNAL_FUNC (on_toggle_play_toggled),
mplay);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (mplay->pause_button),
GTK_SIGNAL_FUNC (on_toggle_pause_toggled),
mplay);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (mplay->stop_button),
GTK_SIGNAL_FUNC (on_toggle_stop_toggled),
mplay);
}
static void
@ -510,12 +496,11 @@ update_slider (GstMediaPlay *mplay,
GtkAdjustment *adjustment,
gfloat value)
{
gtk_signal_handler_block_by_func (GTK_OBJECT (adjustment),
GTK_SIGNAL_FUNC (gst_media_play_slider_changed),
mplay);
gtk_adjustment_set_value (adjustment, value);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (adjustment),
GTK_SIGNAL_FUNC (gst_media_play_slider_changed),
mplay);
gtk_signal_handler_block_by_func (GTK_OBJECT (adjustment),
GTK_SIGNAL_FUNC (gst_media_play_slider_changed),
mplay);
gtk_adjustment_set_value (adjustment, value);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (adjustment),
GTK_SIGNAL_FUNC (gst_media_play_slider_changed),
mplay);
}

View file

@ -138,6 +138,70 @@
<class>GtkMenu</class>
<name>view1_menu</name>
<widget>
<class>GtkMenuItem</class>
<name>present_movie</name>
<label>P_resent Movie</label>
<right_justify>False</right_justify>
<widget>
<class>GtkMenu</class>
<name>present_movie_menu</name>
<widget>
<class>GtkMenuItem</class>
<name>original_size</name>
<accelerator>
<modifiers>GDK_MOD1_MASK</modifiers>
<key>GDK_1</key>
<signal>activate</signal>
</accelerator>
<signal>
<name>activate</name>
<handler>on_original_size_activate</handler>
<data>mplay</data>
<last_modification_time>Sun, 06 May 2001 01:58:18 GMT</last_modification_time>
</signal>
<label>Original Size</label>
<right_justify>False</right_justify>
</widget>
<widget>
<class>GtkMenuItem</class>
<name>double_size</name>
<accelerator>
<modifiers>GDK_MOD1_MASK</modifiers>
<key>GDK_2</key>
<signal>activate</signal>
</accelerator>
<signal>
<name>activate</name>
<handler>on_double_size_activate</handler>
<last_modification_time>Sun, 06 May 2001 01:34:06 GMT</last_modification_time>
</signal>
<label>Double Size</label>
<right_justify>False</right_justify>
</widget>
<widget>
<class>GtkMenuItem</class>
<name>full_screen</name>
<accelerator>
<modifiers>GDK_MOD1_MASK</modifiers>
<key>GDK_3</key>
<signal>activate</signal>
</accelerator>
<signal>
<name>activate</name>
<handler>on_full_screen_activate</handler>
<last_modification_time>Sun, 06 May 2001 01:34:06 GMT</last_modification_time>
</signal>
<label>Full Screen</label>
<right_justify>False</right_justify>
</widget>
</widget>
</widget>
<widget>
<class>GtkCheckMenuItem</class>
<name>extended1</name>
@ -443,7 +507,6 @@ Ronald Bultje &lt;rbultje@ronald.bitfreak.net&gt;
<last_modification_time>Sun, 06 Aug 2000 15:55:52 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
<relief>GTK_RELIEF_NORMAL</relief>
</widget>
<widget>
@ -459,7 +522,6 @@ Ronald Bultje &lt;rbultje@ronald.bitfreak.net&gt;
<last_modification_time>Sun, 06 Aug 2000 15:53:48 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
<relief>GTK_RELIEF_NORMAL</relief>
</widget>
</widget>

View file

@ -1,54 +1,41 @@
/*
* Initial main.c file generated by Glade. Edit as required.
* Glade will not overwrite this file.
*/
#ifndef __GST_MEDIA_PLAY_H__
#define __GST_MEDIA_PLAY_H__
#include <glade/glade.h>
#include "gstplay.h"
#include "gststatusarea.h"
#define GST_TYPE_MEDIA_PLAY (gst_media_play_get_type())
#define GST_MEDIA_PLAY(obj) (GTK_CHECK_CAST ((obj), GST_TYPE_MEDIA_PLAY, GstMediaPlay))
#define GST_MEDIA_PLAY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GST_TYPE_MEDIA_PLAY, GstMediaPlayClass))
#define GST_IS_MEDIA_PLAY(obj) (GTK_CHECK_TYPE ((obj), GST_TYPE_MEDIA_PLAY))
#define GST_IS_MEDIA_PLAY_CLASS(obj) (GTK_CHECK_CLASS_TYPE ((klass), GST_TYPE_MEDIA_PLAY))
typedef struct _GstMediaPlay GstMediaPlay;
typedef struct _GstMediaPlayClass GstMediaPlayClass;
#define GST_TYPE_MEDIA_PLAY \
(gst_media_play_get_type())
#define GST_MEDIA_PLAY(obj) \
(GTK_CHECK_CAST((obj),GST_TYPE_MEDIA_PLAY,GstMediaPlay))
#define GST_MEDIA_PLAY_CLASS(klass) \
(GTK_CHECK_CLASS_CAST((klass),GST_TYPE_MEDIA_PLAY,GstMediaPlayClass))
#define GST_IS_MEDIA_PLAY(obj) \
(GTK_CHECK_TYPE((obj),GST_TYPE_MEDIA_PLAY))
#define GST_IS_MEDIA_PLAY_CLASS(obj) \
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_MEDIA_PLAY))
struct _GstMediaPlay {
GtkObject parent;
GtkObject parent;
GladeXML *xml;
GstPlay *play;
GtkWidget *play_button;
GtkWidget *pause_button;
GtkWidget *stop_button;
GtkWidget *window;
GstStatusArea *status;
// the slider
GtkAdjustment *adjustment;
GtkWidget *slider;
gulong last_time;
GladeXML *xml;
GstPlay *play;
GtkWidget *play_button;
GtkWidget *pause_button;
GtkWidget *stop_button;
GtkWidget *window;
GstStatusArea *status;
// the slider
GtkAdjustment *adjustment;
GtkWidget *slider;
gulong last_time;
};
struct _GstMediaPlayClass {
GtkObjectClass parent_class;
GtkObjectClass parent_class;
};

File diff suppressed because it is too large Load diff

View file

@ -1,65 +1,55 @@
/*
* Initial main.c file generated by Glade. Edit as required.
* Glade will not overwrite this file.
*/
#ifndef __GSTPLAY_H__
#define __GSTPLAY_H__
#include <gst/gst.h>
#define GST_TYPE_PLAY (gst_play_get_type ())
#define GST_PLAY(obj) (GTK_CHECK_CAST ((obj), GST_TYPE_PLAY, GstPlay))
#define GST_PLAY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAY, GstPlayClass))
#define GST_IS_PLAY(obj) (GTK_CHECK_TYPE ((obj), GST_TYPE_PLAY))
#define GST_IS_PLAY_CLASS(obj) (GTK_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLAY))
typedef struct _GstPlay GstPlay;
typedef struct _GstPlayClass GstPlayClass;
#define GST_TYPE_PLAY \
(gst_play_get_type())
#define GST_PLAY(obj) \
(GTK_CHECK_CAST((obj),GST_TYPE_PLAY,GstPlay))
#define GST_PLAY_CLASS(klass) \
(GTK_CHECK_CLASS_CAST((klass),GST_TYPE_PLAY,GstPlayClass))
#define GST_IS_PLAY(obj) \
(GTK_CHECK_TYPE((obj),GST_TYPE_PLAY))
#define GST_IS_PLAY_CLASS(obj) \
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_PLAY))
typedef enum {
GST_PLAY_STOPPED,
GST_PLAY_PLAYING,
GST_PLAY_PAUSED,
GST_PLAY_STOPPED,
GST_PLAY_PLAYING,
GST_PLAY_PAUSED,
} GstPlayState;
typedef enum {
GST_PLAY_OK,
GST_PLAY_UNKNOWN_MEDIA,
GST_PLAY_CANNOT_PLAY,
GST_PLAY_ERROR,
GST_PLAY_OK,
GST_PLAY_UNKNOWN_MEDIA,
GST_PLAY_CANNOT_PLAY,
GST_PLAY_ERROR,
} GstPlayReturn;
typedef enum {
GST_PLAY_TYPE_AUDIO = (1 << 0),
GST_PLAY_TYPE_VIDEO = (1 << 1),
GST_PLAY_TYPE_AUDIO = (1 << 0),
GST_PLAY_TYPE_VIDEO = (1 << 1),
} GstPlayMediaTypeFlags;
struct _GstPlay {
GtkHBox parent;
GstPlayState state;
GstPlayMediaTypeFlags flags;
gpointer priv;
GtkHBox parent;
GstPlayState state;
GstPlayMediaTypeFlags flags;
gpointer priv;
};
#define GST_PLAY_STATE(play) ((play)->state)
#define GST_PLAY_MEDIA_TYPE(play) ((play)->flags)
#define GST_PLAY_STATE(play) ((play)->state)
#define GST_PLAY_MEDIA_TYPE(play) ((play)->flags)
#define GST_PLAY_IS_AUDIO_TYPE(play) ((play)->flags & GST_PLAY_TYPE_AUDIO)
#define GST_PLAY_IS_VIDEO_TYPE(play) ((play)->flags & GST_PLAY_TYPE_VIDEO)
struct _GstPlayClass {
GtkHBoxClass parent_class;
GtkHBoxClass parent_class;
void (*state_changed) (GstPlay *play, GstPlayState state);
void (*frame_displayed) (GstPlay *play);
void (*audio_played) (GstPlay *play);
void (*state_changed) (GstPlay *play, GstPlayState state);
void (*frame_displayed) (GstPlay *play);
void (*audio_played) (GstPlay *play);
};
@ -85,6 +75,9 @@ void gst_play_media_seek (GstPlay *play, gulong offset);
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 ();
/* the autoplugged pipeline */
GstElement* gst_play_get_pipeline (GstPlay *play);

View file

@ -1,8 +1,3 @@
/*
* Initial main.c file generated by Glade. Edit as required.
* Glade will not overwrite this file.
*/
#ifndef __GSTPLAY_PRIVATE_H__
#define __GSTPLAY_PRIVATE_H__
@ -11,21 +6,24 @@
typedef struct _GstPlayPrivate GstPlayPrivate;
struct _GstPlayPrivate {
GstElement *thread;
GstElement *bin;
GstElement *video_element, *audio_element;
GstElement *video_show;
GtkWidget *video_widget;
GstElement *src;
GstElement *thread;
GstElement *bin;
GstElement *video_element, *audio_element;
GstElement *video_show;
GtkWidget *video_widget;
GstElement *src;
guchar *uri;
gboolean muted;
gboolean can_seek;
GstElement *offset_element;
GstElement *bit_rate_element;
GstElement *media_time_element;
GstElement *current_time_element;
guchar *uri;
gboolean muted;
gboolean can_seek;
GstElement *offset_element;
GstElement *bit_rate_element;
GstElement *media_time_element;
GstElement *current_time_element;
guint source_width;
guint source_height;
};
#endif /* __GSTPLAY_PRIVATE_H__ */

View file

@ -1,31 +1,25 @@
/*
* Initial main.c file generated by Glade. Edit as required.
* Glade will not overwrite this file.
*/
#include <config.h>
#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_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_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);
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
/* signals and args */
enum {
LAST_SIGNAL
LAST_SIGNAL
};
enum {
ARG_0,
ARG_0,
};
static GtkDrawingArea *parent_class = NULL;
@ -34,277 +28,267 @@ static GtkDrawingArea *parent_class = NULL;
GtkType
gst_status_area_get_type (void)
{
static GtkType status_area_type = 0;
static GtkType status_area_type = 0;
if (!status_area_type) {
static const GtkTypeInfo status_area_info = {
"GstStatusArea",
sizeof(GstStatusArea),
sizeof(GstStatusAreaClass),
(GtkClassInitFunc)gst_status_area_class_init,
(GtkObjectInitFunc)gst_status_area_init,
NULL,
NULL,
(GtkClassInitFunc)NULL,
};
status_area_type = gtk_type_unique (gtk_widget_get_type (),&status_area_info);
}
return status_area_type;
if (!status_area_type) {
static const GtkTypeInfo status_area_info = {
"GstStatusArea",
sizeof(GstStatusArea),
sizeof(GstStatusAreaClass),
(GtkClassInitFunc)gst_status_area_class_init,
(GtkObjectInitFunc)gst_status_area_init,
NULL,
NULL,
(GtkClassInitFunc)NULL,
};
status_area_type = gtk_type_unique (gtk_widget_get_type (),&status_area_info);
}
return status_area_type;
}
static void
gst_status_area_class_init (GstStatusAreaClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
parent_class = gtk_type_class (gtk_widget_get_type ());
parent_class = gtk_type_class (gtk_widget_get_type ());
object_class = (GtkObjectClass*)klass;
widget_class = (GtkWidgetClass*)klass;
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;
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;
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;
GTK_WIDGET(status_area)->requisition.height = DEFAULT_HEIGHT;
status_area->state = GST_STATUS_AREA_STATE_INIT;
status_area->expanded = FALSE;
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));
return GST_STATUS_AREA (gtk_type_new (GST_TYPE_STATUS_AREA));
}
static void
gst_status_area_realize (GtkWidget *widget)
{
GdkWindowAttr attributes;
gint attributes_mask;
GstStatusArea *status_area;
GdkWindowAttr attributes;
gint attributes_mask;
GstStatusArea *status_area;
g_return_if_fail (widget != NULL);
g_return_if_fail(GST_IS_STATUS_AREA(widget));
g_return_if_fail (widget != NULL);
g_return_if_fail(GST_IS_STATUS_AREA(widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
status_area = GST_STATUS_AREA(widget);
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
status_area = GST_STATUS_AREA(widget);
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;
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;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
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);
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);
widget->style = gtk_style_attach (widget->style, widget->window);
widget->style = gtk_style_attach (widget->style, widget->window);
}
static gint
gst_status_area_expose(GtkWidget *widget,
GdkEventExpose *event)
gst_status_area_expose(GtkWidget *widget, GdkEventExpose *event)
{
GstStatusArea *status_area;
guchar *statustext;
GstStatusArea *status_area;
guchar *statustext;
g_return_val_if_fail (GST_IS_STATUS_AREA (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
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);
status_area = GST_STATUS_AREA (widget);
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget)) {
gdk_draw_rectangle (widget->window,
widget->style->black_gc,
TRUE,
0, 0,
widget->allocation.width,
widget->allocation.height);
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget)) {
gdk_draw_rectangle (widget->window,
widget->style->black_gc,
TRUE,
0, 0,
widget->allocation.width,
widget->allocation.height);
if (status_area->expanded) {
gint width;
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);
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 (widget->style->font, "Show:");
width = gdk_string_width (widget->style->font, "Show:");
gdk_draw_string (widget->window,
widget->style->font,
widget->style->white_gc,
80-width, 15,
"Show:");
gdk_draw_string (widget->window,
widget->style->font,
widget->style->white_gc,
80-width, 15,
"Show:");
width = gdk_string_width (widget->style->font, "Clip:");
width = gdk_string_width (widget->style->font, "Clip:");
gdk_draw_string (widget->window,
widget->style->font,
widget->style->white_gc,
80-width, 40,
"Clip:");
gdk_draw_string (widget->window,
widget->style->font,
widget->style->white_gc,
80-width, 40,
"Clip:");
width = gdk_string_width (widget->style->font, "Author:");
width = gdk_string_width (widget->style->font, "Author:");
gdk_draw_string (widget->window,
widget->style->font,
widget->style->white_gc,
80-width, 55,
"Author:");
gdk_draw_string (widget->window,
widget->style->font,
widget->style->white_gc,
80-width, 55,
"Author:");
width = gdk_string_width (widget->style->font, "Copyright:");
width = gdk_string_width (widget->style->font, "Copyright:");
gdk_draw_string (widget->window,
widget->style->font,
widget->style->white_gc,
80-width, 70,
"Copyright:");
gdk_draw_string (widget->window,
widget->style->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);
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;
}
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,
widget->style->font,
widget->style->white_gc,
8, widget->allocation.height-5,
statustext);
gdk_draw_string (widget->window,
widget->style->font,
widget->style->white_gc,
8, widget->allocation.height-5,
statustext);
if (status_area->playtime) {
gint width = gdk_string_width (widget->style->font, status_area->playtime);
if (status_area->playtime) {
gint width = gdk_string_width (widget->style->font, status_area->playtime);
gdk_draw_string (widget->window,
widget->style->font,
widget->style->white_gc,
widget->allocation.width-width-20,
widget->allocation.height-5,
status_area->playtime);
}
}
gdk_draw_string (widget->window,
widget->style->font,
widget->style->white_gc,
widget->allocation.width-width-20,
widget->allocation.height-5,
status_area->playtime);
}
}
return FALSE;
return FALSE;
}
void
gst_status_area_set_state (GstStatusArea *area,
GstStatusAreaState state)
gst_status_area_set_state (GstStatusArea *area, GstStatusAreaState state)
{
g_return_if_fail(area != NULL);
g_return_if_fail(GST_IS_STATUS_AREA(area));
g_return_if_fail(area != NULL);
g_return_if_fail(GST_IS_STATUS_AREA(area));
area->state = state;
area->state = state;
if (GTK_WIDGET_VISIBLE(area))
gtk_widget_queue_draw(GTK_WIDGET(area));
if (GTK_WIDGET_VISIBLE(area))
gtk_widget_queue_draw(GTK_WIDGET(area));
}
void
gst_status_area_set_playtime (GstStatusArea *area,
const guchar *time)
gst_status_area_set_playtime (GstStatusArea *area, const guchar *time)
{
g_return_if_fail(area != NULL);
g_return_if_fail(GST_IS_STATUS_AREA(area));
g_return_if_fail(time != NULL);
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);
if (area->playtime) g_free (area->playtime);
area->playtime = g_strdup (time);
area->playtime = g_strdup (time);
if (GTK_WIDGET_VISIBLE(area))
gtk_widget_queue_draw(GTK_WIDGET(area));
if (GTK_WIDGET_VISIBLE(area))
gtk_widget_queue_draw(GTK_WIDGET(area));
}
void
gst_status_area_set_streamtype (GstStatusArea *area,
const guchar *type)
gst_status_area_set_streamtype (GstStatusArea *area, const guchar *type)
{
}
void
gst_status_area_show_extended (GstStatusArea *area,
gboolean show)
gst_status_area_show_extended (GstStatusArea *area, gboolean show)
{
area->expanded = show;
area->expanded = show;
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));
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)
gst_status_area_set_arg(GtkObject *object, GtkArg *arg, guint id)
{
GstStatusArea *status_area;
GstStatusArea *status_area;
status_area = GST_STATUS_AREA(object);
status_area = GST_STATUS_AREA(object);
switch (id) {
default:
g_warning("GstStatusArea: unknown arg!");
break;
}
switch (id) {
default:
g_warning("GstStatusArea: unknown arg!");
break;
}
}
static void
gst_status_area_get_arg(GtkObject *object,
GtkArg *arg,
guint id)
gst_status_area_get_arg(GtkObject *object, GtkArg *arg, guint id)
{
GstStatusArea *status_area;
GstStatusArea *status_area;
status_area = GST_STATUS_AREA(object);
status_area = GST_STATUS_AREA(object);
switch (id) {
default:
arg->type = GTK_TYPE_INVALID;
break;
}
switch (id) {
default:
arg->type = GTK_TYPE_INVALID;
break;
}
}

View file

@ -4,38 +4,32 @@
#include <gst/gst.h>
#include <gtk/gtk.h>
#define GST_TYPE_STATUS_AREA (gst_status_area_get_type ())
#define GST_STATUS_AREA(obj) (GTK_CHECK_CAST ((obj), GST_TYPE_STATUS_AREA, GstStatusArea))
#define GST_STATUS_AREA_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GST_TYPE_STATUS_AREA, GstStatusAreaClass))
#define GST_IS_STATUS_AREA(obj) (GTK_CHECK_TYPE ((obj), GST_TYPE_STATUS_AREA))
#define GST_IS_STATUS_AREA_CLASS(obj) (GTK_CHECK_CLASS_TYPE ((klass), GST_TYPE_STATUS_AREA))
typedef struct _GstStatusArea GstStatusArea;
typedef struct _GstStatusAreaClass GstStatusAreaClass;
#define GST_TYPE_STATUS_AREA \
(gst_status_area_get_type())
#define GST_STATUS_AREA(obj) \
(GTK_CHECK_CAST((obj),GST_TYPE_STATUS_AREA,GstStatusArea))
#define GST_STATUS_AREA_CLASS(klass) \
(GTK_CHECK_CLASS_CAST((klass),GST_TYPE_STATUS_AREA,GstStatusAreaClass))
#define GST_IS_STATUS_AREA(obj) \
(GTK_CHECK_TYPE((obj),GST_TYPE_STATUS_AREA))
#define GST_IS_STATUS_AREA_CLASS(obj) \
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_STATUS_AREA))
typedef enum {
GST_STATUS_AREA_STATE_INIT,
GST_STATUS_AREA_STATE_PLAYING,
GST_STATUS_AREA_STATE_PAUSED,
GST_STATUS_AREA_STATE_STOPPED,
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;
GstStatusAreaState state;
guchar *playtime;
gboolean expanded;
GtkWidget parent;
GstStatusAreaState state;
guchar *playtime;
gboolean expanded;
};
struct _GstStatusAreaClass {
GtkWidgetClass parent_class;
GtkWidgetClass parent_class;
};

View file

@ -1,35 +1,28 @@
/*
* Initial main.c file generated by Glade. Edit as required.
* Glade will not overwrite this file.
*/
#include <config.h>
#include <gnome.h>
#include "gstmediaplay.h"
int
main (int argc, char *argv[])
{
GstMediaPlay *play;
GstMediaPlay *play;
gst_init (&argc,&argv);
gnome_init ("gstreamer", VERSION, argc, argv);
glade_init();
glade_gnome_init();
play = gst_media_play_new ();
if (argc > 1) {
gst_media_play_start_uri (play, argv[1]);
}
xmlSaveFile("gstmediaplay.gst", gst_xml_write(gst_play_get_pipeline(play->play)));
gdk_threads_enter ();
gst_main ();
gdk_threads_leave ();
return 0;
gst_init (&argc,&argv);
gnome_init ("gstreamer", VERSION, argc, argv);
glade_init();
glade_gnome_init();
play = gst_media_play_new ();
if (argc > 1) {
gst_media_play_start_uri (play, argv[1]);
}
xmlSaveFile ("gstmediaplay.gst", gst_xml_write (gst_play_get_pipeline (play->play)));
gdk_threads_enter();
gst_main();
gdk_threads_leave();
return 0;
}