[Xfce4-commits] <parole:master> Show buffering status
Ali Abdallah
noreply at xfce.org
Fri Nov 27 10:04:03 CET 2009
Updating branch refs/heads/master
to 6fc1995ba8b0a255e199f9160ef592490a7d4970 (commit)
from 8dd927ddb1802222e4ecca4cc69a781dfc40cc93 (commit)
commit 6fc1995ba8b0a255e199f9160ef592490a7d4970
Author: Ali Abdallah <ali at ali-xfce.org>
Date: Fri Nov 27 10:00:40 2009 +0100
Show buffering status
.../media-plugin/org.parole.media.plugin.xml | 3 +
browser-plugin/media-plugin/parole-plugin-player.c | 58 ++++++++++++++++++--
browser-plugin/media-plugin/parole-plugin-player.h | 2 +
browser-plugin/parole-plugin.c | 11 ++++-
4 files changed, 67 insertions(+), 7 deletions(-)
diff --git a/browser-plugin/media-plugin/org.parole.media.plugin.xml b/browser-plugin/media-plugin/org.parole.media.plugin.xml
index f357516..abcdb9a 100644
--- a/browser-plugin/media-plugin/org.parole.media.plugin.xml
+++ b/browser-plugin/media-plugin/org.parole.media.plugin.xml
@@ -18,6 +18,9 @@
<arg type="s" name="url" direction="in"/>
</method>
+ <signal name="Error">
+ </signal>
+
<signal name="Finished">
</signal>
diff --git a/browser-plugin/media-plugin/parole-plugin-player.c b/browser-plugin/media-plugin/parole-plugin-player.c
index f51b302..aed5d3c 100644
--- a/browser-plugin/media-plugin/parole-plugin-player.c
+++ b/browser-plugin/media-plugin/parole-plugin-player.c
@@ -72,6 +72,7 @@ struct ParolePluginPlayerPrivate
GtkWidget *range;
GtkWidget *full_screen;
GtkWidget *volume;
+ GtkWidget *buffering;
ParoleScreenSaver *saver;
@@ -97,6 +98,7 @@ enum
enum
{
+ SIG_ERROR,
SIG_FINISHED,
SIG_EXITING,
SIG_READY,
@@ -456,12 +458,6 @@ parole_plugin_player_gst_widget_button_release (GtkWidget *widget,
}
static void
-parole_plugin_player_error_cb (ParoleGst *gst, const gchar *error, ParolePluginPlayer *player)
-{
- parole_screen_saver_uninhibit (player->priv->saver);
-}
-
-static void
parole_plugin_player_fullscreen_clicked_cb (ParolePluginPlayer *player)
{
parole_plugin_player_fullscreen (player, !player->priv->fullscreen);
@@ -548,6 +544,33 @@ parole_plugin_player_dispose (GObject *object)
}
static void
+parole_plugin_player_error_cb (ParoleGst *gst, const gchar *error, ParolePluginPlayer *player)
+{
+ player->priv->finished = TRUE;
+ parole_screen_saver_uninhibit (player->priv->saver);
+ parole_gst_stop (gst);
+}
+
+static void
+parole_plugin_player_buffering_cb (ParoleGst *gst, const ParoleStream *stream,
+ gint percentage, ParolePluginPlayer *player)
+{
+ if ( percentage == 100 )
+ {
+ gtk_widget_hide (player->priv->buffering);
+ }
+ else
+ {
+ gchar *text;
+
+ text = g_strdup_printf ("%s %d%%...", _("Buffering"), percentage);
+ gtk_label_set_text (GTK_LABEL (player->priv->buffering), text);
+ g_free (text);
+ gtk_widget_show (player->priv->buffering);
+ }
+}
+
+static void
parole_plugin_player_construct (GObject *object)
{
ParolePluginPlayer *player;
@@ -573,6 +596,12 @@ parole_plugin_player_construct (GObject *object)
g_signal_connect (G_OBJECT (player->priv->gst), "media-state",
G_CALLBACK (parole_plugin_player_media_state_cb), player);
+ g_signal_connect (G_OBJECT (player->priv->gst), "error",
+ G_CALLBACK (parole_plugin_player_error_cb), player);
+
+ g_signal_connect (G_OBJECT (player->priv->gst), "buffering",
+ G_CALLBACK (parole_plugin_player_buffering_cb), player);
+
g_signal_connect (G_OBJECT (player->priv->gst), "media-progressed",
G_CALLBACK (parole_plugin_player_media_progressed_cb), player);
@@ -674,6 +703,14 @@ parole_plugin_player_construct (GObject *object)
G_CALLBACK (parole_plugin_player_volume_changed_cb), player);
+ /*
+ * buffering
+ */
+ player->priv->buffering = gtk_label_new (NULL);
+ gtk_widget_hide (player->priv->buffering);
+ gtk_box_pack_start (GTK_BOX (vbox), player->priv->buffering,
+ FALSE, FALSE, 0);
+
gtk_box_pack_start (GTK_BOX (vbox), hbox,
FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (player->priv->plug), vbox);
@@ -702,6 +739,15 @@ parole_plugin_player_class_init (ParolePluginPlayerClass *klass)
object_class->constructed = parole_plugin_player_construct;
+ signals[SIG_ERROR] =
+ g_signal_new ("error",
+ PAROLE_TYPE_PLUGIN_PLAYER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ParolePluginPlayerClass, error),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0, G_TYPE_NONE);
+
signals[SIG_FINISHED] =
g_signal_new ("finished",
PAROLE_TYPE_PLUGIN_PLAYER,
diff --git a/browser-plugin/media-plugin/parole-plugin-player.h b/browser-plugin/media-plugin/parole-plugin-player.h
index e7efe7f..e154ec8 100644
--- a/browser-plugin/media-plugin/parole-plugin-player.h
+++ b/browser-plugin/media-plugin/parole-plugin-player.h
@@ -43,6 +43,8 @@ typedef struct
{
GObjectClass parent_class;
+ void (*error) (ParolePluginPlayer *player);
+
void (*finished) (ParolePluginPlayer *player);
void (*exiting) (ParolePluginPlayer *player);
diff --git a/browser-plugin/parole-plugin.c b/browser-plugin/parole-plugin.c
index 15bb6a2..2ec8d8d 100644
--- a/browser-plugin/parole-plugin.c
+++ b/browser-plugin/parole-plugin.c
@@ -180,7 +180,12 @@ parole_plugin_player_finished_cb (DBusGProxy *proxy, ParolePlugin *plugin)
parole_plugin_send_play (plugin, parole_file_get_uri (file));
}
}
-
+}
+
+static void
+parole_plugin_player_error_cb (DBusGProxy *proxy, ParolePlugin *plugin)
+{
+ parole_plugin_player_finished_cb (NULL, plugin);
}
static void
@@ -287,10 +292,14 @@ parole_plugin_get_proxy (ParolePlugin *plugin)
g_critical ("Unable to create proxy for %s", dbus_name);
else
{
+ dbus_g_proxy_add_signal (plugin->proxy, "Error", G_TYPE_INVALID);
dbus_g_proxy_add_signal (plugin->proxy, "Finished", G_TYPE_INVALID);
dbus_g_proxy_add_signal (plugin->proxy, "Exiting", G_TYPE_INVALID);
dbus_g_proxy_add_signal (plugin->proxy, "Ready", G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (plugin->proxy, "Error",
+ G_CALLBACK (parole_plugin_player_error_cb), plugin, NULL);
+
dbus_g_proxy_connect_signal (plugin->proxy, "Finished",
G_CALLBACK (parole_plugin_player_finished_cb), plugin, NULL);
More information about the Xfce4-commits
mailing list