From befbfb279a3cb5d3f7b9507912c9d67eb1027727 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 14 May 2007 21:19:52 +0000 Subject: Move the skipto dialog into a new plugin. (Closes #428293) 2007-05-14 Philip Withnall * configure.in: * data/Makefile.am: * data/skip_to.glade: * data/totem-ui.xml: * src/Makefile.am: * src/plugins/skipto/Makefile.am: * src/plugins/skipto/skip_to.glade: * src/plugins/skipto/skipto.totem-plugin.in: * src/plugins/skipto/totem-skipto-plugin.c: (totem_skipto_plugin_class_init), (totem_skipto_plugin_init), (destroy_dialog), (totem_skipto_plugin_finalize), (totem_skipto_update_from_state), (property_notify_cb), (skip_to_response_callback), (run_skip_to_dialog), (skip_to_action_callback), (on_window_key_press_event), (impl_activate), (impl_deactivate): * src/plugins/skipto/totem-skipto.c: (totem_skipto_class_init), (totem_skipto_response_cb), (totem_skipto_init), (totem_skipto_finalize), (totem_skipto_update_range), (totem_skipto_get_range), (totem_skipto_set_seekable), (totem_skipto_set_current), (spin_button_activate_cb), (spin_button_value_changed_cb), (totem_skipto_new): * src/plugins/skipto/totem-skipto.h: * src/plugins/totem-plugin.h: * src/totem-menu.c: * src/totem-object.c: (totem_object_class_init), (totem_object_get_property), (totem_get_ui_manager), (totem_get_current_time), (totem_remove_sidebar_page): * src/totem-private.h: * src/totem-skipto.c: * src/totem-skipto.h: * src/totem.c: (update_mrl_label), (totem_action_seek_relative), (totem_action_seek_time), (update_seekable), (update_current_time), (totem_is_fullscreen), (totem_is_playing), (totem_is_seekable), (totem_action_handle_key_press), (totem_callback_connect): * src/totem.h: Move the skipto dialog into a new plugin. (Closes #428293) svn path=/trunk/; revision=4308 --- ChangeLog | 39 ++++ configure.in | 3 +- data/Makefile.am | 1 - data/skip_to.glade | 207 ---------------------- data/totem-ui.xml | 1 - po/ChangeLog | 5 + po/POTFILES.in | 4 +- src/Makefile.am | 1 - src/plugins/skipto/Makefile.am | 47 +++++ src/plugins/skipto/skip_to.glade | 207 ++++++++++++++++++++++ src/plugins/skipto/skipto.totem-plugin.in | 9 + src/plugins/skipto/totem-skipto-plugin.c | 285 ++++++++++++++++++++++++++++++ src/plugins/skipto/totem-skipto.c | 215 ++++++++++++++++++++++ src/plugins/skipto/totem-skipto.h | 69 ++++++++ src/plugins/totem-plugin.h | 15 +- src/totem-menu.c | 7 - src/totem-object.c | 35 +++- src/totem-private.h | 6 - src/totem-skipto.c | 195 -------------------- src/totem-skipto.h | 58 ------ src/totem.c | 135 +++++--------- src/totem.h | 6 +- 22 files changed, 981 insertions(+), 569 deletions(-) delete mode 100644 data/skip_to.glade create mode 100644 src/plugins/skipto/Makefile.am create mode 100644 src/plugins/skipto/skip_to.glade create mode 100644 src/plugins/skipto/skipto.totem-plugin.in create mode 100644 src/plugins/skipto/totem-skipto-plugin.c create mode 100644 src/plugins/skipto/totem-skipto.c create mode 100644 src/plugins/skipto/totem-skipto.h delete mode 100644 src/totem-skipto.c delete mode 100644 src/totem-skipto.h diff --git a/ChangeLog b/ChangeLog index 77fb29a6..4aa2a9c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,42 @@ +2007-05-14 Philip Withnall + + * configure.in: + * data/Makefile.am: + * data/skip_to.glade: + * data/totem-ui.xml: + * src/Makefile.am: + * src/plugins/skipto/Makefile.am: + * src/plugins/skipto/skip_to.glade: + * src/plugins/skipto/skipto.totem-plugin.in: + * src/plugins/skipto/totem-skipto-plugin.c: + (totem_skipto_plugin_class_init), (totem_skipto_plugin_init), + (destroy_dialog), (totem_skipto_plugin_finalize), + (totem_skipto_update_from_state), (property_notify_cb), + (skip_to_response_callback), (run_skip_to_dialog), + (skip_to_action_callback), (on_window_key_press_event), + (impl_activate), (impl_deactivate): + * src/plugins/skipto/totem-skipto.c: (totem_skipto_class_init), + (totem_skipto_response_cb), (totem_skipto_init), + (totem_skipto_finalize), (totem_skipto_update_range), + (totem_skipto_get_range), (totem_skipto_set_seekable), + (totem_skipto_set_current), (spin_button_activate_cb), + (spin_button_value_changed_cb), (totem_skipto_new): + * src/plugins/skipto/totem-skipto.h: + * src/plugins/totem-plugin.h: + * src/totem-menu.c: + * src/totem-object.c: (totem_object_class_init), + (totem_object_get_property), (totem_get_ui_manager), + (totem_get_current_time), (totem_remove_sidebar_page): + * src/totem-private.h: + * src/totem-skipto.c: + * src/totem-skipto.h: + * src/totem.c: (update_mrl_label), (totem_action_seek_relative), + (totem_action_seek_time), (update_seekable), (update_current_time), + (totem_is_fullscreen), (totem_is_playing), (totem_is_seekable), + (totem_action_handle_key_press), (totem_callback_connect): + * src/totem.h: Move the skipto dialog into a + new plugin. (Closes #428293) + 2007-05-14 Bastien Nocera * src/bacon-volume.c: (bacon_volume_button_new): Fix the ATK diff --git a/configure.in b/configure.in index dbac9985..74f5e890 100644 --- a/configure.in +++ b/configure.in @@ -63,7 +63,7 @@ AC_SUBST(TOTEM_PL_PARSER_VERSION_MINOR) AC_SUBST(TOTEM_PL_PARSER_VERSION_MICRO) # The full list of plugins -allowed_plugins="screensaver ontop galago gromit lirc media-player-keys sidebar-test" +allowed_plugins="screensaver ontop galago gromit lirc media-player-keys sidebar-test skipto" PLUGINDIR='${libdir}/totem/plugins' AC_SUBST(PLUGINDIR) @@ -873,6 +873,7 @@ src/plugins/gromit/Makefile src/plugins/lirc/Makefile src/plugins/media-player-keys/Makefile src/plugins/sidebar-test/Makefile +src/plugins/skipto/Makefile src/backend/Makefile src/plparse/Makefile src/plparse/totem-pl-parser-features.h diff --git a/data/Makefile.am b/data/Makefile.am index e7644c3e..1daec973 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -14,7 +14,6 @@ stuff_DATA = \ plugins.glade \ mozilla-viewer.glade \ properties.glade \ - skip_to.glade \ uri.glade \ totem-ui.xml \ totem_logo.png diff --git a/data/skip_to.glade b/data/skip_to.glade deleted file mode 100644 index 23ecbafc..00000000 --- a/data/skip_to.glade +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - 5 - Skip to - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER_ON_PARENT - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_NORMAL - GDK_GRAVITY_NORTH_WEST - True - False - False - - - - True - False - 2 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - -6 - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - -5 - - - - - 0 - False - True - GTK_PACK_END - - - - - - 5 - True - False - 6 - - - - 4 - True - False - 12 - - - - True - _Skip to: - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - tstw_skip_spinbutton - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - True - False - 6 - - - - True - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 0 0 0 1 10 10 - - - 0 - True - True - - - - - - True - seconds - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - 0 - True - True - - - - - 0 - False - True - - - - - - True - 0 seconds - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - 0 - True - True - - - - - - - diff --git a/data/totem-ui.xml b/data/totem-ui.xml index 314cc41b..44ac5b89 100644 --- a/data/totem-ui.xml +++ b/data/totem-ui.xml @@ -63,7 +63,6 @@ - diff --git a/po/ChangeLog b/po/ChangeLog index 241cfa0c..095f7869 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,8 @@ +2007-05-14 Philip Withnall + + * POTFILES.in: Move the skipto dialog into a + new plugin. (Closes #428293) + 2007-05-13 Philip Withnall * POTFILES.skip: Remove a non-existent file from the list, diff --git a/po/POTFILES.in b/po/POTFILES.in index 61896cc7..82b34fbc 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -21,7 +21,6 @@ src/totem-properties-main.c src/totem-properties-view.c src/totem-screenshot.c src/totem-sidebar.c -src/totem-skipto.c src/totem-statusbar.c src/totem-subtitle-encoding.c src/totem-time-label.c @@ -46,4 +45,7 @@ src/plugins/lirc/totem-lirc.c [type: gettext/ini]src/plugins/media-player-keys/media-player-keys.totem-plugin.in [type: gettext/ini]src/plugins/ontop/ontop.totem-plugin.in [type: gettext/ini]src/plugins/screensaver/screensaver.totem-plugin.in +[type: gettext/ini]src/plugins/skipto/skipto.totem-plugin.in +src/plugins/skipto/totem-skipto.c +src/plugins/skipto/totem-skipto-plugin.c browser-plugin/totem-plugin-viewer.c diff --git a/src/Makefile.am b/src/Makefile.am index 9f5e5890..3dc261b9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -108,7 +108,6 @@ totem_SOURCES = \ totem-screenshot.h \ totem-session.c totem-session.h \ totem-sidebar.c totem-sidebar.h \ - totem-skipto.c totem-skipto.h \ totem-menu.c totem-menu.h \ totem-missing-plugins.c totem-missing-plugins.h \ totem-time-label.c totem-time-label.h \ diff --git a/src/plugins/skipto/Makefile.am b/src/plugins/skipto/Makefile.am new file mode 100644 index 00000000..8388c10c --- /dev/null +++ b/src/plugins/skipto/Makefile.am @@ -0,0 +1,47 @@ +modules_flags = -export_dynamic -avoid-version -module + +plugindir = $(PLUGINDIR)/skipto +gladedir = $(plugindir) +plugin_LTLIBRARIES = libskipto.la + +plugin_in_files = skipto.totem-plugin.in + +%.totem-plugin: %.totem-plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache + +plugin_DATA = $(plugin_in_files:.totem-plugin.desktop.in=.totem-plugin) +glade_DATA = skip_to.glade + +common_defines = \ + -D_REENTRANT \ + -DDBUS_API_SUBJECT_TO_CHANGE \ + -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ + -DGCONF_PREFIX=\""/apps/totem"\" \ + -DDATADIR=\""$(datadir)"\" \ + -DLIBEXECDIR=\""$(libexecdir)"\" \ + -DBINDIR=\""$(bindir)"\" \ + -DTOTEM_PLUGIN_DIR=\""$(libdir)/totem/plugins"\"\ + $(DISABLE_DEPRECATED) + +libskipto_la_SOURCES = \ + totem-skipto-plugin.c \ + totem-skipto.c \ + totem-skipto.h +libskipto_la_LDFLAGS = $(modules_flags) +libskipto_la_CPPFLAGS = \ + $(common_defines) \ + -I$(top_srcdir)/src/backend \ + -I$(top_srcdir)/src/plparse + +libskipto_la_CFLAGS = \ + $(EXTRA_GNOME_CFLAGS) \ + $(WARN_CFLAGS) \ + $(DBUS_CFLAGS) \ + $(AM_CFLAGS) \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/plugins + +EXTRA_DIST = $(plugin_in_files) $(glade_DATA) + +CLEANFILES = $(plugin_DATA) $(BUILT_SOURCES) +DISTCLEANFILES = $(plugin_DATA) diff --git a/src/plugins/skipto/skip_to.glade b/src/plugins/skipto/skip_to.glade new file mode 100644 index 00000000..88fdce4c --- /dev/null +++ b/src/plugins/skipto/skip_to.glade @@ -0,0 +1,207 @@ + + + + + + + 5 + Skip to + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ON_PARENT + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + False + + + + True + False + 2 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 5 + True + False + 6 + + + + 4 + True + False + 12 + + + + True + _Skip to: + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + tstw_skip_spinbutton + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 6 + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 0 0 0 1 10 10 + + + 0 + True + True + + + + + + True + seconds + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + False + True + + + + + + True + 0 seconds + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + 0 + True + True + + + + + + + diff --git a/src/plugins/skipto/skipto.totem-plugin.in b/src/plugins/skipto/skipto.totem-plugin.in new file mode 100644 index 00000000..648dc8ad --- /dev/null +++ b/src/plugins/skipto/skipto.totem-plugin.in @@ -0,0 +1,9 @@ +[Totem Plugin] +Module=skipto +IAge=1 +Builtin=true +_Name=Skipto +_Description=Provides the "Skip to" dialog. +Authors=Philip Withnall, Bastien Nocera +Copyright=Copyright © 2007 Philip Withnall +Website=http://www.gnome.org/projects/totem/ diff --git a/src/plugins/skipto/totem-skipto-plugin.c b/src/plugins/skipto/totem-skipto-plugin.c new file mode 100644 index 00000000..32a2c054 --- /dev/null +++ b/src/plugins/skipto/totem-skipto-plugin.c @@ -0,0 +1,285 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2007 Philip Withnall + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Totem project hereby grant permission for non-gpl compatible GStreamer + * plugins to be used and distributed together with GStreamer and Totem. This + * permission are above and beyond the permissions granted by the GPL license + * Totem is covered by. + * + * Monday 7th February 2005: Christian Schaller: Add excemption clause. + * See license_change file for details. + * + * Author: Bastien Nocera , Philip Withnall + */ + +#include "config.h" + +#include +#include +#include +#include +#include +#include + +#include "totem-plugin.h" +#include "totem.h" +#include "totem-skipto.h" + +#define TOTEM_TYPE_SKIPTO_PLUGIN (totem_skipto_plugin_get_type ()) +#define TOTEM_SKIPTO_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TOTEM_TYPE_SKIPTO_PLUGIN, TotemSkiptoPlugin)) +#define TOTEM_SKIPTO_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TOTEM_TYPE_SKIPTO_PLUGIN, TotemSkiptoPluginClass)) +#define TOTEM_IS_SKIPTO_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TOTEM_TYPE_SKIPTO_PLUGIN)) +#define TOTEM_IS_SKIPTO_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TOTEM_TYPE_SKIPTO_PLUGIN)) +#define TOTEM_SKIPTO_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TOTEM_TYPE_SKIPTO_PLUGIN, TotemSkiptoPluginClass)) + +typedef struct +{ + TotemPlugin parent; + + TotemObject *totem; + TotemSkipto *st; + guint handler_id_stream_length; + guint handler_id_seekable; + guint handler_id_key_press; + guint ui_merge_id; + GtkActionGroup *action_group; +} TotemSkiptoPlugin; + +typedef struct +{ + TotemPluginClass parent_class; +} TotemSkiptoPluginClass; + + +G_MODULE_EXPORT GType register_totem_plugin (GTypeModule *module); +GType totem_skipto_plugin_get_type (void) G_GNUC_CONST; + +static void totem_skipto_plugin_init (TotemSkiptoPlugin *plugin); +static void totem_skipto_plugin_finalize (GObject *object); +static gboolean impl_activate (TotemPlugin *plugin, TotemObject *totem, GError **error); +static void impl_deactivate (TotemPlugin *plugin, TotemObject *totem); + +TOTEM_PLUGIN_REGISTER_EXTENDED(TotemSkiptoPlugin, totem_skipto_plugin, TOTEM_PLUGIN_REGISTER_TYPE(totem_skipto)) + +static void +totem_skipto_plugin_class_init (TotemSkiptoPluginClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + TotemPluginClass *plugin_class = TOTEM_PLUGIN_CLASS (klass); + + object_class->finalize = totem_skipto_plugin_finalize; + + plugin_class->activate = impl_activate; + plugin_class->deactivate = impl_deactivate; +} + +static void +totem_skipto_plugin_init (TotemSkiptoPlugin *plugin) +{ + plugin->st = NULL; +} + +static void +destroy_dialog (TotemSkiptoPlugin *plugin) +{ + if (plugin->st != NULL) { + g_object_remove_weak_pointer (G_OBJECT (plugin->st), (gpointer *)&(plugin->st)); + gtk_widget_destroy (GTK_WIDGET (plugin->st)); + plugin->st = NULL; + } +} + +static void +totem_skipto_plugin_finalize (GObject *object) +{ + TotemSkiptoPlugin *plugin = TOTEM_SKIPTO_PLUGIN (object); + + destroy_dialog (plugin); + + G_OBJECT_CLASS (totem_skipto_plugin_parent_class)->finalize (object); +} + +static void +totem_skipto_update_from_state (TotemObject *totem, + TotemSkiptoPlugin *plugin) +{ + gint64 time; + gboolean seekable; + GtkAction *action; + + g_object_get (G_OBJECT (totem), + "stream-length", &time, + "seekable", &seekable, + NULL); + + if (plugin->st != NULL) { + totem_skipto_update_range (plugin->st, time); + totem_skipto_set_seekable (plugin->st, seekable); + } + + /* Update the action's sensitivity */ + action = gtk_action_group_get_action (plugin->action_group, "skip-to"); + gtk_action_set_sensitive (action, seekable); +} + +static void +property_notify_cb (TotemObject *totem, + GParamSpec *spec, + TotemSkiptoPlugin *plugin) +{ + totem_skipto_update_from_state (totem, plugin); +} + +static void +skip_to_response_callback (GtkDialog *dialog, gint response, TotemSkiptoPlugin *plugin) +{ + if (response != GTK_RESPONSE_OK) { + destroy_dialog (plugin); + return; + } + + gtk_widget_hide (GTK_WIDGET (dialog)); + + totem_action_seek_time (plugin->totem, totem_skipto_get_range (plugin->st)); + destroy_dialog (plugin); +} + +static void +run_skip_to_dialog (TotemSkiptoPlugin *plugin) +{ + if (totem_is_seekable (plugin->totem) == FALSE) + return; + + if (plugin->st != NULL) { + gtk_window_present (GTK_WINDOW (plugin->st)); + totem_skipto_set_current (plugin->st, totem_get_current_time (plugin->totem)); + return; + } + + plugin->st = TOTEM_SKIPTO (totem_skipto_new (totem_plugin_find_file (TOTEM_PLUGIN (plugin), "skip_to.glade"), plugin->totem)); + g_signal_connect (G_OBJECT (plugin->st), "delete-event", + G_CALLBACK (gtk_widget_destroy), NULL); + g_signal_connect (G_OBJECT (plugin->st), "response", + G_CALLBACK (skip_to_response_callback), plugin); + g_object_add_weak_pointer (G_OBJECT (plugin->st), (gpointer *)&(plugin->st)); + totem_skipto_update_from_state (plugin->totem, plugin); + totem_skipto_set_current (plugin->st, totem_get_current_time (plugin->totem)); +} + +static void +skip_to_action_callback (GtkAction *action, TotemSkiptoPlugin *plugin) +{ + run_skip_to_dialog (plugin); +} + +static gboolean +on_window_key_press_event (GtkWidget *window, GdkEventKey *event, TotemSkiptoPlugin *plugin) +{ + + if (event->state != 0 + && ((event->state & GDK_CONTROL_MASK) + || (event->state & GDK_MOD1_MASK) + || (event->state & GDK_MOD3_MASK) + || (event->state & GDK_MOD4_MASK) + || (event->state & GDK_MOD5_MASK))) + return FALSE; + + switch (event->keyval) { + case GDK_s: + case GDK_S: + run_skip_to_dialog (plugin); + break; + default: + return FALSE; + } + + return TRUE; +} + +static gboolean +impl_activate (TotemPlugin *plugin, + TotemObject *totem, + GError **error) +{ + GtkWindow *window; + GtkUIManager *manager; + TotemSkiptoPlugin *pi = TOTEM_SKIPTO_PLUGIN (plugin); + const GtkActionEntry menu_entries[] = { + { "skip-to", GTK_STOCK_JUMP_TO, N_("_Skip to..."), "s", N_("Skip to a specific time"), G_CALLBACK (skip_to_action_callback) } + }; + + pi->totem = totem; + pi->handler_id_stream_length = g_signal_connect (G_OBJECT (totem), + "notify::stream-length", + G_CALLBACK (property_notify_cb), + pi); + pi->handler_id_seekable = g_signal_connect (G_OBJECT (totem), + "notify::seekable", + G_CALLBACK (property_notify_cb), + pi); + + /* Key press handler */ + window = totem_get_main_window (totem); + pi->handler_id_key_press = g_signal_connect (G_OBJECT(window), + "key-press-event", + G_CALLBACK (on_window_key_press_event), + pi); + g_object_unref (window); + + /* Install the menu */ + pi->action_group = gtk_action_group_new ("skip-to_group"); + gtk_action_group_add_actions (pi->action_group, menu_entries, + G_N_ELEMENTS (menu_entries), pi); + + manager = totem_get_ui_manager (totem); + + gtk_ui_manager_insert_action_group (manager, pi->action_group, -1); + g_object_unref (pi->action_group); + + pi->ui_merge_id = gtk_ui_manager_new_merge_id (manager); + gtk_ui_manager_add_ui (manager, pi->ui_merge_id, "/ui/tmw-menubar/go/skip-forward", "skip-to", "skip-to", + GTK_UI_MANAGER_AUTO, TRUE); + + totem_skipto_update_from_state (totem, pi); + + return TRUE; +} + +static void +impl_deactivate (TotemPlugin *plugin, + TotemObject *totem) +{ + GtkWindow *window; + GtkUIManager *manager; + TotemSkiptoPlugin *pi = TOTEM_SKIPTO_PLUGIN (plugin); + + g_signal_handler_disconnect (G_OBJECT (totem), pi->handler_id_stream_length); + g_signal_handler_disconnect (G_OBJECT (totem), pi->handler_id_seekable); + + if (pi->handler_id_key_press != 0) { + window = totem_get_main_window (totem); + g_signal_handler_disconnect (G_OBJECT(window), pi->handler_id_key_press); + pi->handler_id_key_press = 0; + g_object_unref (window); + } + + /* Remove the menu */ + manager = totem_get_ui_manager (totem); + gtk_ui_manager_remove_ui (manager, pi->ui_merge_id); + gtk_ui_manager_remove_action_group (manager, pi->action_group); +} diff --git a/src/plugins/skipto/totem-skipto.c b/src/plugins/skipto/totem-skipto.c new file mode 100644 index 00000000..f067f054 --- /dev/null +++ b/src/plugins/skipto/totem-skipto.c @@ -0,0 +1,215 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2007 Bastien Nocera + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Totem project hereby grant permission for non-gpl compatible GStreamer + * plugins to be used and distributed together with GStreamer and Totem. This + * permission are above and beyond the permissions granted by the GPL license + * Totem is covered by. + * + * Monday 7th February 2005: Christian Schaller: Add excemption clause. + * See license_change file for details. + * + * Author: Bastien Nocera , Philip Withnall + */ + +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "totem-skipto.h" +#include "totem.h" +#include "totem-plugin.h" +#include "totem-uri.h" +#include "video-utils.h" +#include "bacon-video-widget.h" + +static GObjectClass *parent_class = NULL; +static void totem_skipto_class_init (TotemSkiptoClass *class); +static void totem_skipto_init (TotemSkipto *ggo); +static void totem_skipto_finalize (GObject *object); + +struct TotemSkiptoPrivate { + GladeXML *xml; + GtkWidget *label; + GtkWidget *spinbutton; + gint64 time; + Totem *totem; +}; + +TOTEM_PLUGIN_DEFINE_TYPE (TotemSkipto, totem_skipto, GTK_TYPE_DIALOG) + +static void +totem_skipto_class_init (TotemSkiptoClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (TotemSkiptoPrivate)); + + object_class->finalize = totem_skipto_finalize; +} + +static void +totem_skipto_response_cb (GtkDialog *dialog, gint response_id, gpointer data) +{ + TotemSkipto *skipto; + + skipto = TOTEM_SKIPTO (dialog); + gtk_spin_button_update (GTK_SPIN_BUTTON (skipto->priv->spinbutton)); +} + +static void +totem_skipto_init (TotemSkipto *skipto) +{ + skipto->priv = G_TYPE_INSTANCE_GET_PRIVATE (skipto, TOTEM_TYPE_SKIPTO, TotemSkiptoPrivate); + + g_signal_connect (skipto, "response", + G_CALLBACK (totem_skipto_response_cb), NULL); +} + +static void +totem_skipto_finalize (GObject *object) +{ + g_return_if_fail (object != NULL); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +void +totem_skipto_update_range (TotemSkipto *skipto, gint64 time) +{ + g_return_if_fail (TOTEM_IS_SKIPTO (skipto)); + + if (time == skipto->priv->time) + return; + + gtk_spin_button_set_range (GTK_SPIN_BUTTON (skipto->priv->spinbutton), + 0, (gdouble) time / 1000); + skipto->priv->time = time; +} + +gint64 +totem_skipto_get_range (TotemSkipto *skipto) +{ + gint64 time; + + g_return_val_if_fail (TOTEM_IS_SKIPTO (skipto), 0); + + time = gtk_spin_button_get_value (GTK_SPIN_BUTTON (skipto->priv->spinbutton)) * 1000; + + return time; +} + +void +totem_skipto_set_seekable (TotemSkipto *skipto, gboolean seekable) +{ + g_return_if_fail (TOTEM_IS_SKIPTO (skipto)); + + gtk_dialog_set_response_sensitive (GTK_DIALOG (skipto), + GTK_RESPONSE_OK, seekable); +} + +void +totem_skipto_set_current (TotemSkipto *skipto, gint64 time) +{ + g_return_if_fail (TOTEM_IS_SKIPTO (skipto)); + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (skipto->priv->spinbutton), + (gdouble) (time / 1000)); +} + +static void +spin_button_activate_cb (GtkEntry *entry, TotemSkipto *skipto) +{ + gtk_dialog_response (GTK_DIALOG (skipto), GTK_RESPONSE_OK); +} + +static void +spin_button_value_changed_cb (GtkSpinButton *spinbutton, TotemSkipto *skipto) +{ + int sec; + char *str; + + sec = (int) gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinbutton)); + str = totem_time_to_string_text (sec * 1000); + gtk_label_set_text (GTK_LABEL (skipto->priv->label), str); + g_free (str); +} + +GtkWidget* +totem_skipto_new (const char *glade_filename, Totem *totem) +{ + TotemSkipto *skipto; + GtkWidget *container; + + g_return_val_if_fail (glade_filename != NULL, NULL); + + skipto = TOTEM_SKIPTO (g_object_new (TOTEM_TYPE_SKIPTO, NULL)); + + /* TODO: Since we're only loading part of the thing from Glade, why have the dialog stuff in the Glade file? */ + skipto->priv->totem = totem; + skipto->priv->xml = glade_xml_new (glade_filename, + "tstw_skip_vbox", NULL); + if (skipto->priv->xml == NULL) + { + g_object_unref (skipto); + return NULL; + } + skipto->priv->label = glade_xml_get_widget + (skipto->priv->xml, "tstw_position_label"); + skipto->priv->spinbutton = glade_xml_get_widget + (skipto->priv->xml, "tstw_skip_spinbutton"); + + gtk_window_set_title (GTK_WINDOW (skipto), _("Skip to")); + gtk_dialog_set_has_separator (GTK_DIALOG (skipto), FALSE); + gtk_dialog_add_buttons (GTK_DIALOG (skipto), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_OK, + NULL); + + /* Skipto dialog */ + g_signal_connect (G_OBJECT (skipto->priv->spinbutton), "value-changed", + G_CALLBACK (spin_button_value_changed_cb), skipto); + g_signal_connect_after (G_OBJECT (skipto->priv->spinbutton), "activate", + G_CALLBACK (spin_button_activate_cb), skipto); + g_signal_connect (G_OBJECT (skipto), "delete-event", + G_CALLBACK (gtk_widget_destroy), skipto); + + container = glade_xml_get_widget (skipto->priv->xml, + "tstw_skip_vbox"); + gtk_container_set_border_width (GTK_CONTAINER (skipto), 5); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (skipto)->vbox), + container, + TRUE, /* expand */ + TRUE, /* fill */ + 0); /* padding */ + + gtk_window_set_transient_for (GTK_WINDOW (skipto), + totem_get_main_window (totem)); + + gtk_widget_show_all (GTK_WIDGET (skipto)); + + return GTK_WIDGET (skipto); +} diff --git a/src/plugins/skipto/totem-skipto.h b/src/plugins/skipto/totem-skipto.h new file mode 100644 index 00000000..dadb1803 --- /dev/null +++ b/src/plugins/skipto/totem-skipto.h @@ -0,0 +1,69 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2007 Bastien Nocera + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Totem project hereby grant permission for non-gpl compatible GStreamer + * plugins to be used and distributed together with GStreamer and Totem. This + * permission are above and beyond the permissions granted by the GPL license + * Totem is covered by. + * + * Monday 7th February 2005: Christian Schaller: Add excemption clause. + * See license_change file for details. + * + * Author: Bastien Nocera , Philip Withnall + */ + +#ifndef TOTEM_SKIPTO_H +#define TOTEM_SKIPTO_H + +#include + +#include "totem.h" + +G_BEGIN_DECLS + +#define TOTEM_TYPE_SKIPTO (totem_skipto_get_type ()) +#define TOTEM_SKIPTO(obj) (GTK_CHECK_CAST ((obj), TOTEM_TYPE_SKIPTO, TotemSkipto)) +#define TOTEM_SKIPTO_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TOTEM_TYPE_SKIPTO, TotemSkiptoClass)) +#define TOTEM_IS_SKIPTO(obj) (GTK_CHECK_TYPE ((obj), TOTEM_TYPE_SKIPTO)) +#define TOTEM_IS_SKIPTO_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TOTEM_TYPE_SKIPTO)) + +GType totem_skipto_register_type (GTypeModule *module); + +typedef struct TotemSkipto TotemSkipto; +typedef struct TotemSkiptoClass TotemSkiptoClass; +typedef struct TotemSkiptoPrivate TotemSkiptoPrivate; + +struct TotemSkipto { + GtkDialog parent; + TotemSkiptoPrivate *priv; +}; + +struct TotemSkiptoClass { + GtkDialogClass parent_class; +}; + +GtkType totem_skipto_get_type (void); +GtkWidget *totem_skipto_new (const char *glade_filename, Totem *totem); +gint64 totem_skipto_get_range (TotemSkipto *skipto); +void totem_skipto_update_range (TotemSkipto *skipto, gint64 time); +void totem_skipto_set_seekable (TotemSkipto *skipto, gboolean seekable); +void totem_skipto_set_current (TotemSkipto *skipto, gint64 time); + +G_END_DECLS + +#endif /* TOTEM_SKIPTO_H */ diff --git a/src/plugins/totem-plugin.h b/src/plugins/totem-plugin.h index 851d0a48..3ffe70ec 100644 --- a/src/plugins/totem-plugin.h +++ b/src/plugins/totem-plugin.h @@ -114,9 +114,15 @@ GList * totem_get_plugin_paths (void); */ #define TOTEM_PLUGIN_REGISTER(PluginName, plugin_name) \ + TOTEM_PLUGIN_REGISTER_EXTENDED(PluginName, plugin_name, {}) + +#define TOTEM_PLUGIN_REGISTER_EXTENDED(PluginName, plugin_name, _C_) \ + _TOTEM_PLUGIN_REGISTER_EXTENDED_BEGIN (PluginName, plugin_name) {_C_;} _TOTEM_PLUGIN_REGISTER_EXTENDED_END(plugin_name) + +#define _TOTEM_PLUGIN_REGISTER_EXTENDED_BEGIN(PluginName, plugin_name) \ \ static GType plugin_name##_type = 0; \ -static GTypeModule *plugin_module_type = 0; \ +static GTypeModule *plugin_module_type = 0; \ \ GType \ plugin_name##_get_type (void) \ @@ -136,7 +142,7 @@ static void plugin_name##_class_intern_init (gpointer klass) \ G_MODULE_EXPORT GType \ register_totem_plugin (GTypeModule *module) \ { \ - const GTypeInfo our_info = \ + const GTypeInfo our_info = \ { \ sizeof (PluginName##Class), \ NULL, /* base_init */ \ @@ -159,6 +165,11 @@ register_totem_plugin (GTypeModule *module) \ #PluginName, \ &our_info, \ 0); \ + { /* custom code follows */ + +#define _TOTEM_PLUGIN_REGISTER_EXTENDED_END(plugin_name) \ + /* following custom code */ \ + } \ return plugin_name##_type; \ } diff --git a/src/totem-menu.c b/src/totem-menu.c index a8e0292b..d115c6e2 100644 --- a/src/totem-menu.c +++ b/src/totem-menu.c @@ -1054,12 +1054,6 @@ previous_chapter_action_callback (GtkAction *action, Totem *totem) TOTEM_PROFILE (totem_action_previous (totem)); } -static void -skip_to_action_callback (GtkAction *action, Totem *totem) -{ - totem_action_skip_to (totem); -} - static void skip_forward_action_callback (GtkAction *action, Totem *totem) { @@ -1292,7 +1286,6 @@ static const GtkActionEntry entries[] = { { "dvd-chapter-menu", GTK_STOCK_INDEX, N_("_Chapter Menu"), "c", N_("Go to the chapter menu"), G_CALLBACK (dvd_chapter_menu_action_callback) }, { "next-chapter", GTK_STOCK_MEDIA_NEXT, N_("_Next Chapter/Movie"), "n", N_("Next chapter or movie"), G_CALLBACK (next_chapter_action_callback) }, { "previous-chapter", GTK_STOCK_MEDIA_PREVIOUS, N_("_Previous Chapter/Movie"), "b", N_("Previous chapter or movie"), G_CALLBACK (previous_chapter_action_callback) }, - { "skip-to", GTK_STOCK_JUMP_TO, N_("_Skip to..."), "S", N_("Skip to a specific time"), G_CALLBACK (skip_to_action_callback) }, { "sound-menu", NULL, N_("_Sound") }, /* { "languages-menu", NULL, N_("_Languages") }, */ diff --git a/src/totem-object.c b/src/totem-object.c index 9d2c0ba0..ebf34bf1 100644 --- a/src/totem-object.c +++ b/src/totem-object.c @@ -39,7 +39,9 @@ enum { PROP_0, PROP_FULLSCREEN, - PROP_PLAYING + PROP_PLAYING, + PROP_STREAM_LENGTH, + PROP_SEEKABLE }; static void totem_object_set_property (GObject *object, @@ -71,6 +73,14 @@ totem_object_class_init (TotemObjectClass *klass) g_object_class_install_property (object_class, PROP_PLAYING, g_param_spec_boolean ("playing", NULL, NULL, FALSE, G_PARAM_READABLE)); + g_object_class_install_property (object_class, PROP_STREAM_LENGTH, + g_param_spec_int64 ("stream-length", NULL, NULL, + G_MININT64, G_MAXINT64, 0, + G_PARAM_READABLE)); + g_object_class_install_property (object_class, PROP_SEEKABLE, + g_param_spec_boolean ("seekable", NULL, NULL, + FALSE, G_PARAM_READABLE)); + //FIXME properties and signals } @@ -114,6 +124,12 @@ totem_object_get_property (GObject *object, case PROP_PLAYING: g_value_set_boolean (value, totem_is_playing (totem)); break; + case PROP_STREAM_LENGTH: + g_value_set_int64 (value, bacon_video_widget_get_stream_length (totem->bvw)); + break; + case PROP_SEEKABLE: + g_value_set_boolean (value, totem_is_seekable (totem)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -141,6 +157,22 @@ totem_get_main_window (Totem *totem) return GTK_WINDOW (totem->win); } +GtkUIManager * +totem_get_ui_manager (Totem *totem) +{ + g_return_val_if_fail (TOTEM_IS_OBJECT (totem), NULL); + + return totem->ui_manager; +} + +gint64 +totem_get_current_time (Totem *totem) +{ + g_return_val_if_fail (TOTEM_IS_OBJECT (totem), 0); + + return bacon_video_widget_get_current_time (totem->bvw); +} + void totem_add_sidebar_page (Totem *totem, const char *page_id, @@ -160,4 +192,3 @@ totem_remove_sidebar_page (Totem *totem, ev_sidebar_remove_page (EV_SIDEBAR (totem->sidebar), page_id); } - diff --git a/src/totem-private.h b/src/totem-private.h index bd9e0113..3ba10f6e 100644 --- a/src/totem-private.h +++ b/src/totem-private.h @@ -36,7 +36,6 @@ #include "totem-playlist.h" #include "bacon-message-connection.h" #include "bacon-video-widget.h" -#include "totem-skipto.h" #define totem_signal_block_by_data(obj, data) (g_signal_handlers_block_matched (obj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, data)) #define totem_signal_unblock_by_data(obj, data) (g_signal_handlers_unblock_matched (obj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, data)) @@ -101,10 +100,6 @@ struct TotemObject { int sidebar_w; GtkWidget *properties; - /* Skip to dialogue */ - TotemSkipto *skipto; - gint64 last_length; - /* Play/Pause */ GtkWidget *pp_button; /* fullscreen Play/Pause */ @@ -194,7 +189,6 @@ void totem_action_take_screenshot (Totem *totem); void totem_action_zoom_relative (Totem *totem, int off_pct); void totem_action_zoom_reset (Totem *totem); void totem_action_show_help (Totem *totem); -void totem_action_skip_to (Totem *totem); void totem_action_show_properties (Totem *totem); void show_controls (Totem *totem, gboolean was_fullscreen); diff --git a/src/totem-skipto.c b/src/totem-skipto.c deleted file mode 100644 index 6612be19..00000000 --- a/src/totem-skipto.c +++ /dev/null @@ -1,195 +0,0 @@ -/* totem-skipto.c - - Copyright (C) 2004 Bastien Nocera - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera - */ - -#include "config.h" -#include "totem-skipto.h" -#include "video-utils.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "debug.h" - -struct TotemSkiptoPrivate -{ - GladeXML *xml; - GtkWidget *label; - GtkWidget *spinbutton; - gint64 time; -}; - -static void totem_skipto_class_init (TotemSkiptoClass *class); -static void totem_skipto_init (TotemSkipto *skipto); - -G_DEFINE_TYPE(TotemSkipto, totem_skipto, GTK_TYPE_DIALOG) - -static void -totem_skipto_response_cb (GtkDialog *dialog, gint response_id, gpointer data) -{ - TotemSkipto *skipto; - - skipto = TOTEM_SKIPTO (dialog); - gtk_spin_button_update (GTK_SPIN_BUTTON (skipto->_priv->spinbutton)); -} - -static void -totem_skipto_init (TotemSkipto *skipto) -{ - skipto->_priv = g_new0 (TotemSkiptoPrivate, 1); - gtk_container_set_border_width (GTK_CONTAINER (skipto), 5); - - g_signal_connect (skipto, "response", - G_CALLBACK (totem_skipto_response_cb), NULL); -} - -static void -totem_skipto_finalize (GObject *object) -{ - g_return_if_fail (object != NULL); - - if (G_OBJECT_CLASS (totem_skipto_parent_class)->finalize != NULL) { - (* G_OBJECT_CLASS (totem_skipto_parent_class)->finalize) (object); - } -} - -void -totem_skipto_update_range (TotemSkipto *skipto, gint64 time) -{ - g_return_if_fail (TOTEM_IS_SKIPTO (skipto)); - - if (time == skipto->_priv->time) - return; - - gtk_spin_button_set_range (GTK_SPIN_BUTTON (skipto->_priv->spinbutton), - 0, (gdouble) time / 1000); - skipto->_priv->time = time; -} - -gint64 -totem_skipto_get_range (TotemSkipto *skipto) -{ - gint64 time; - - g_return_val_if_fail (TOTEM_IS_SKIPTO (skipto), 0); - - time = gtk_spin_button_get_value (GTK_SPIN_BUTTON (skipto->_priv->spinbutton)) * 1000; - - return time; -} - -void -totem_skipto_set_seekable (TotemSkipto *skipto, gboolean seekable) -{ - g_return_if_fail (TOTEM_IS_SKIPTO (skipto)); - - gtk_dialog_set_response_sensitive (GTK_DIALOG (skipto), - GTK_RESPONSE_OK, seekable); -} - -void -totem_skipto_set_current (TotemSkipto *skipto, gint64 time) -{ - g_return_if_fail (TOTEM_IS_SKIPTO (skipto)); - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (skipto->_priv->spinbutton), - (gdouble) (time / 1000)); -} - -static void -spin_button_activate_cb (GtkEntry *entry, TotemSkipto *skipto) -{ - gtk_dialog_response (GTK_DIALOG (skipto), GTK_RESPONSE_OK); -} - -static void -spin_button_value_changed_cb (GtkSpinButton *spinbutton, TotemSkipto *skipto) -{ - int sec; - char *str; - - sec = (int) gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinbutton)); - str = totem_time_to_string_text (sec * 1000); - gtk_label_set_text (GTK_LABEL (skipto->_priv->label), str); - g_free (str); -} - -GtkWidget* -totem_skipto_new (const char *glade_filename) -{ - TotemSkipto *skipto; - GtkWidget *container, *item; - - g_return_val_if_fail (glade_filename != NULL, NULL); - - skipto = TOTEM_SKIPTO (g_object_new (GTK_TYPE_SKIPTO, NULL)); - - skipto->_priv->xml = glade_xml_new (glade_filename, "tstw_skip_vbox", NULL); - if (skipto->_priv->xml == NULL) - { - totem_skipto_finalize (G_OBJECT (skipto)); - return NULL; - } - skipto->_priv->label = glade_xml_get_widget - (skipto->_priv->xml, "tstw_position_label"); - skipto->_priv->spinbutton = glade_xml_get_widget - (skipto->_priv->xml, "tstw_skip_spinbutton"); - - gtk_window_set_title (GTK_WINDOW (skipto), _("Skip to")); - gtk_dialog_set_has_separator (GTK_DIALOG (skipto), FALSE); - gtk_dialog_add_buttons (GTK_DIALOG (skipto), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - - /* Skipto dialog */ - item = glade_xml_get_widget (skipto->_priv->xml, - "totem_skipto_window"); - g_signal_connect (G_OBJECT (skipto->_priv->spinbutton), "value-changed", - G_CALLBACK (spin_button_value_changed_cb), skipto); - g_signal_connect_after (G_OBJECT (skipto->_priv->spinbutton), "activate", - G_CALLBACK (spin_button_activate_cb), skipto); - - container = glade_xml_get_widget (skipto->_priv->xml, - "tstw_skip_vbox"); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (skipto)->vbox), - container, - TRUE, /* expand */ - TRUE, /* fill */ - 0); /* padding */ - - gtk_widget_show_all (GTK_DIALOG (skipto)->vbox); - - return GTK_WIDGET (skipto); -} - -static void -totem_skipto_class_init (TotemSkiptoClass *klass) -{ - G_OBJECT_CLASS (klass)->finalize = totem_skipto_finalize; -} - diff --git a/src/totem-skipto.h b/src/totem-skipto.h deleted file mode 100644 index bff3bbc2..00000000 --- a/src/totem-skipto.h +++ /dev/null @@ -1,58 +0,0 @@ -/* totem-skipto.h - - Copyright (C) 2004 Bastien Nocera - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Bastien Nocera - */ - -#ifndef TOTEM_SKIPTO_H -#define TOTEM_SKIPTO_H - -#include - -G_BEGIN_DECLS - -#define GTK_TYPE_SKIPTO (totem_skipto_get_type ()) -#define TOTEM_SKIPTO(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_SKIPTO, TotemSkipto)) -#define TOTEM_SKIPTO_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_SKIPTO, TotemSkiptoClass)) -#define TOTEM_IS_SKIPTO(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_SKIPTO)) -#define TOTEM_IS_SKIPTO_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SKIPTO)) - -typedef struct TotemSkipto TotemSkipto; -typedef struct TotemSkiptoClass TotemSkiptoClass; -typedef struct TotemSkiptoPrivate TotemSkiptoPrivate; - -struct TotemSkipto { - GtkDialog parent; - TotemSkiptoPrivate *_priv; -}; - -struct TotemSkiptoClass { - GtkDialogClass parent_class; -}; - -GtkType totem_skipto_get_type (void); -GtkWidget *totem_skipto_new (const char *glade_filename); -gint64 totem_skipto_get_range (TotemSkipto *skipto); -void totem_skipto_update_range (TotemSkipto *skipto, gint64 time); -void totem_skipto_set_seekable (TotemSkipto *skipto, gboolean seekable); -void totem_skipto_set_current (TotemSkipto *skipto, gint64 time); - -G_END_DECLS - -#endif /* TOTEM_SKIPTO_H */ diff --git a/src/totem.c b/src/totem.c index c7ab05a4..d304f66a 100644 --- a/src/totem.c +++ b/src/totem.c @@ -906,18 +906,6 @@ totem_get_nice_name_for_stream (Totem *totem) return retval; } -static void -update_skip_to (Totem *totem, gint64 time) -{ - if (time == totem->last_length) - return; - - totem->last_length = time; - - if (totem->skipto != NULL) - totem_skipto_update_range (totem->skipto, time); -} - static void update_mrl_label (Totem *totem, const char *name) { @@ -934,7 +922,7 @@ update_mrl_label (Totem *totem, const char *name) totem_statusbar_set_time_and_length (TOTEM_STATUSBAR (totem->statusbar), 0, time / 1000); - update_skip_to (totem, time); + g_object_notify (G_OBJECT (totem), "stream-length"); /* Update the mrl label */ escaped = g_markup_escape_text (name, strlen (name)); @@ -955,7 +943,7 @@ update_mrl_label (Totem *totem, const char *name) totem_statusbar_set_text (TOTEM_STATUSBAR (totem->statusbar), _("Stopped")); - update_skip_to (totem, 0); + g_object_notify (G_OBJECT (totem), "stream-length"); /* Update the mrl label */ text = g_strdup_printf @@ -1171,7 +1159,34 @@ totem_action_seek_relative (Totem *totem, int off_sec) char *msg, *disp; disp = totem_uri_escape_for_display (totem->mrl); - msg = g_strdup_printf(_("Totem could not play '%s'."), totem->mrl); + msg = g_strdup_printf(_("Totem could not play '%s'."), disp); + g_free (disp); + + totem_action_stop (totem); + totem_action_error (msg, err->message, totem); + g_free (msg); + g_error_free (err); + } +} + +void +totem_action_seek_time (Totem *totem, gint64 sec) +{ + GError *err = NULL; + + if (totem->mrl == NULL) + return; + if (bacon_video_widget_is_seekable (totem->bvw) == FALSE) + return; + + bacon_video_widget_seek_time (totem->bvw, sec, &err); + + if (err != NULL) + { + char *msg, *disp; + + disp = totem_uri_escape_for_display (totem->mrl); + msg = g_strdup_printf(_("Totem could not play '%s'."), disp); g_free (disp); totem_action_stop (totem); @@ -1578,9 +1593,8 @@ update_seekable (Totem *totem) totem_action_set_sensitivity ("skip-forward", seekable); totem_action_set_sensitivity ("skip-backwards", seekable); - totem_action_set_sensitivity ("skip-to", seekable); - if (totem->skipto) - totem_skipto_set_seekable (totem->skipto, seekable); + + g_object_notify (G_OBJECT (totem), "seekable"); } static void @@ -1590,7 +1604,7 @@ update_current_time (BaconVideoWidget *bvw, float current_position, gboolean seekable, Totem *totem) { - update_skip_to (totem, stream_length); + g_object_notify (G_OBJECT (totem), "stream-length"); if (totem->seek_lock == FALSE) { @@ -1869,71 +1883,6 @@ totem_action_open_files_list (Totem *totem, GSList *list) return changed; } -static void -commit_hide_skip_to (GtkDialog *dialog, gint response, Totem *totem) -{ - GError *err = NULL; - - if (response != GTK_RESPONSE_OK) - { - gtk_widget_destroy (GTK_WIDGET (totem->skipto)); - return; - } - - gtk_widget_hide (GTK_WIDGET (dialog)); - - bacon_video_widget_seek_time (totem->bvw, - totem_skipto_get_range (totem->skipto), &err); - - gtk_widget_destroy (GTK_WIDGET (totem->skipto)); - - if (err != NULL) - { - char *msg, *disp; - - disp = totem_uri_escape_for_display (totem->mrl); - msg = g_strdup_printf(_("Totem could not seek in '%s'."), disp); - g_free (disp); - totem_action_stop (totem); - totem_action_error (msg, err->message, totem); - g_free (msg); - g_error_free (err); - } -} - -void -totem_action_skip_to (Totem *totem) -{ - char *filename; - TotemSkipto **skipto; - - if (totem->seekable == FALSE) - return; - - if (totem->skipto != NULL) { - gtk_window_present (GTK_WINDOW (totem->skipto)); - return; - } - - filename = totem_interface_get_full_path ("skip_to.glade"); - totem->skipto = TOTEM_SKIPTO (totem_skipto_new (filename)); - g_free (filename); - totem_skipto_update_range (totem->skipto, totem->last_length); - - g_signal_connect (G_OBJECT (totem->skipto), "delete-event", - G_CALLBACK (gtk_widget_destroy), NULL); - g_signal_connect (G_OBJECT (totem->skipto), "response", - G_CALLBACK (commit_hide_skip_to), totem); - - skipto = &totem->skipto; - g_object_add_weak_pointer (G_OBJECT (totem->skipto), - (gpointer *) skipto); - - gtk_window_set_transient_for (GTK_WINDOW (totem->skipto), - GTK_WINDOW (totem->win)); - gtk_widget_show (GTK_WIDGET (totem->skipto)); -} - static void on_fs_exit1_activate (GtkButton *button, Totem *totem) { @@ -2320,18 +2269,33 @@ update_fullscreen_size (Totem *totem) gboolean totem_is_fullscreen (Totem *totem) { + g_return_val_if_fail (TOTEM_IS_OBJECT (totem), FALSE); + return (totem->controls_visibility == TOTEM_CONTROLS_FULLSCREEN); } gboolean totem_is_playing (Totem *totem) { + g_return_val_if_fail (TOTEM_IS_OBJECT (totem), FALSE); + if (totem->bvw == NULL) return FALSE; return bacon_video_widget_is_playing (totem->bvw) != FALSE; } +gboolean +totem_is_seekable (Totem *totem) +{ + g_return_val_if_fail (TOTEM_IS_OBJECT (totem), FALSE); + + if (totem->bvw == NULL) + return FALSE; + + return bacon_video_widget_is_seekable (totem->bvw) != FALSE; +} + static void move_popups (Totem *totem) { @@ -2671,7 +2635,7 @@ totem_action_handle_key_press (Totem *totem, GdkEventKey *event) if (event->state & GDK_CONTROL_MASK) { totem_action_take_screenshot (totem); } else { - totem_action_skip_to (totem); + return FALSE; } break; case GDK_t: @@ -3235,7 +3199,6 @@ totem_callback_connect (Totem *totem) totem_action_set_sensitivity ("previous-chapter", FALSE); totem_action_set_sensitivity ("skip-forward", FALSE); totem_action_set_sensitivity ("skip-backwards", FALSE); - totem_action_set_sensitivity ("skip-to", FALSE); } static void diff --git a/src/totem.h b/src/totem.h index 85deb6d0..454b6d3c 100644 --- a/src/totem.h +++ b/src/totem.h @@ -29,7 +29,7 @@ #define __TOTEM_H__ #include -#include +#include #include "plparse/totem-disc.h" @@ -100,6 +100,7 @@ void totem_action_fullscreen_toggle (Totem *totem); void totem_action_fullscreen (Totem *totem, gboolean state); void totem_action_next (Totem *totem); void totem_action_previous (Totem *totem); +void totem_action_seek_time (Totem *totem, gint64 sec); void totem_action_seek_relative (Totem *totem, int off_sec); void totem_action_volume_relative (Totem *totem, int off_pct); gboolean totem_action_set_mrl (Totem *totem, @@ -129,7 +130,10 @@ void totem_action_play_media_device (Totem *totem, gboolean totem_is_fullscreen (Totem *totem); gboolean totem_is_playing (Totem *totem); +gboolean totem_is_seekable (Totem *totem); GtkWindow *totem_get_main_window (Totem *totem); +GtkUIManager *totem_get_ui_manager (Totem *totem); +gint64 totem_get_current_time (Totem *totem); void totem_add_sidebar_page (Totem *totem, const char *page_id, -- cgit v1.2.3