Commit 861256b0 authored by Arik Devens's avatar Arik Devens
Browse files

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.
parent 4212a8df
......@@ -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
......
#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)
{
printf ("file1 activate\n");
}
void
on_media2_activate (GtkMenuItem *menuitem, gpointer user_data)
{
printf ("file1 activate\n");
}
void
on_save_as1_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_media2_activate (GtkMenuItem *menuitem,
gpointer user_data)
on_double_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, 1);
}
void
on_preferences1_activate (GtkMenuItem *menuitem,
gpointer user_data)
on_full_screen_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, 2);
}
void
on_preferences1_activate (GtkMenuItem *menuitem, gpointer user_data)
{
printf ("file1 activate\n");
}
void on_about_activate(GtkWidget *widget, gpointer data)
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);
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)
void on_gstplay_destroy (GtkWidget *widget, gpointer data)
{
gst_main_quit();
gst_main_quit();
}
#include <gnome.h>
void
on_file1_activate (GtkMenuItem *menuitem,
gpointer user_data);
on_file1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_open1_activate (GtkMenuItem *menuitem,
gpointer user_data);
on_open1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_close1_activate (GtkMenuItem *menuitem,
gpointer user_data);
on_close1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_media1_activate (GtkMenuItem *menuitem,
gpointer user_data);
on_media1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_play2_activate (GtkMenuItem *menuitem,
gpointer user_data);
on_play2_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_pause1_activate (GtkMenuItem *menuitem,
gpointer user_data);
on_pause1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_stop1_activate (GtkMenuItem *menuitem,
gpointer user_data);
on_stop1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_about1_activate (GtkMenuItem *menuitem,
gpointer user_data);
on_about1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_hscale1_value_changed (GtkAdjustment *adj,
gpointer user_data);
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);
#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;
}
#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
This diff is collapsed.
......@@ -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>
......
/*
* 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;
GladeXML *xml;
GstPlay *play;
GtkWidget *play_button;
GtkWidget *pause_button;