[Xfce4-commits] <parole:master> Added power manager plugin to inhibit the power manager while playing DVD/VCD/DVB...

Ali Abdallah noreply at xfce.org
Wed Nov 25 10:40:03 CET 2009


Updating branch refs/heads/master
         to 6150772a10bea9b6c15eef941f8a79124bc3e8b6 (commit)
       from e397d1eb61351ec607351f0a5ee9fae8c35f1e9c (commit)

commit 6150772a10bea9b6c15eef941f8a79124bc3e8b6
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Wed Nov 25 10:16:11 2009 +0100

    Added power manager plugin to inhibit the power manager
    while playing DVD/VCD/DVB...

 configure.ac.in                                    |   11 +-
 gst/parole-stream.c                                |  664 --------------------
 plugins/Makefile.am                                |    4 +
 plugins/{tray => power-manager}/Makefile.am        |   25 +-
 .../power-manager-plugin.c}                        |    6 +-
 plugins/power-manager/power-manager-provider.c     |  213 +++++++
 plugins/power-manager/power-manager-provider.h     |   44 ++
 plugins/power-manager/power-manager.desktop.in     |    6 +
 po/POTFILES.in                                     |    1 +
 9 files changed, 292 insertions(+), 682 deletions(-)

diff --git a/configure.ac.in b/configure.ac.in
index 561c1d9..5de93b8 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -189,6 +189,14 @@ AC_MSG_CHECKING([whether to build the window title plugin])
 AM_CONDITIONAL([WINDOW_TITLE_PLUGIN], [test x"$ac_window_title_plugin" = x"yes"])
 AC_MSG_RESULT([$ac_window_title_plugin])
 
+# Power Manager
+#--------------------------
+AC_ARG_ENABLE([power-manager-plugin], AC_HELP_STRING([--disable-power-manager-plugin], [Don't build the power manager plugin]),
+  [ac_power_manager_plugin=$enableval], [ac_power_manager_plugin=yes])
+AC_MSG_CHECKING([whether to build the power manager plugin])
+AM_CONDITIONAL([POWER_MANAGER_PLUGIN], [test x"$ac_power_manager_plugin" = x"yes"])
+AC_MSG_RESULT([$ac_power_manager_plugin])
+
 #=======================================================#
 #              Build browser plugin?                    #
 #=======================================================#
@@ -251,6 +259,7 @@ plugins/sample/Makefile
 plugins/properties/Makefile
 plugins/tray/Makefile
 plugins/window-title/Makefile
+plugins/power-manager/Makefile
 browser-plugin/Makefile
 browser-plugin/media-plugin/Makefile
 docs/Makefile
@@ -276,7 +285,7 @@ echo "
 	Stream Properties:       	${ac_properties_plugin} (With taglib $TAGLIB_FOUND)
 	System Tray icon:       	${ac_tray_plugin} (With notification $LIBNOTIFY_FOUND)
 	Window title:			${ac_window_title_plugin}
-	
+	Power Manager:			${ac_power_manager_plugin}
 
 	Browser plugin:
 	===============
diff --git a/gst/parole-stream.c b/gst/parole-stream.c
deleted file mode 100644
index f4d3047..0000000
--- a/gst/parole-stream.c
+++ /dev/null
@@ -1,664 +0,0 @@
-/*
- * * Copyright (C) 2009 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-
-#include "parole-stream.h"
-#include "gst-enum-types.h"
-
-#define PAROLE_STREAM_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), PAROLE_TYPE_STREAM, ParoleStreamPrivate))
-
-#define PAROLE_STREAM_FREE_STR_PROP(str)	    \
-    if ( str )					    \
-	g_free (str);				    \
-    str = NULL;					    \
-
-#define PAROLE_STREAM_DUP_GVALUE_STRING(str, value) \
-    PAROLE_STREAM_FREE_STR_PROP (str);		    \
-    str = g_value_dup_string (value);		    \
-
-typedef struct _ParoleStreamPrivate ParoleStreamPrivate;
-
-struct _ParoleStreamPrivate
-{
-    /*Properties*/
-    gchar      *uri;
-    gchar      *subtitles;
-    gboolean 	has_audio;
-    gboolean    has_video;
-    gboolean 	live;
-    gboolean 	seekable;
-    gboolean 	tag_available;
-    gdouble   	duration;
-    gint        video_w;
-    gint        video_h;
-    gint64  	absolute_duration;
-    guint	tracks;
-    guint       track;
-    guint	disp_par_n;
-    guint	disp_par_d;
-    gchar      *title;
-    gchar      *artist;
-    gchar      *year;
-    gchar      *album;
-    gchar      *comment;
-    
-    ParoleMediaType media_type; 
-};
-
-enum
-{
-    PROP_0,
-    PROP_URI,
-    PROP_SUBTITLES,
-    PROP_LIVE,
-    PROP_MEDIA_TYPE,
-    PROP_HAS_AUDIO,
-    PROP_HAS_VIDEO,
-    PROP_SEEKABLE,
-    PROP_DISP_PAR_N,
-    PROP_DISP_PAR_D,
-    PROP_TRACKS,
-    PROP_TRACK,
-    PROP_TAG_AVAILABLE,
-    PROP_DURATION,
-    PROP_ABSOLUTE_DURATION,
-    PROP_VIDEO_WIDTH,
-    PROP_VIDEO_HEIGHT,
-    PROP_TITLE,
-    PROP_ARTIST,
-    PROP_YEAR,
-    PROP_ALBUM,
-    PROP_COMMENT
-};
-
-G_DEFINE_TYPE (ParoleStream, parole_stream, G_TYPE_OBJECT)
-
-static void
-parole_stream_get_media_type_from_uri (ParoleStream *stream, const gchar *uri)
-{
-    GValue val = { 0, };
-    
-    ParoleMediaType type = PAROLE_MEDIA_TYPE_UNKNOWN;
-    
-    if ( g_str_has_prefix (uri, "file:/") )
-	type = PAROLE_MEDIA_TYPE_LOCAL_FILE;
-    else if ( g_str_has_prefix (uri, "dvd:/") )
-	type = PAROLE_MEDIA_TYPE_DVD;
-    else if ( g_str_has_prefix (uri, "vcd:") )
-	type = PAROLE_MEDIA_TYPE_VCD;
-    else if ( g_str_has_prefix (uri, "svcd:/") )
-	type = PAROLE_MEDIA_TYPE_SVCD;
-    else if ( g_str_has_prefix (uri, "cdda:/") )
-	type = PAROLE_MEDIA_TYPE_CDDA;
-    else if ( g_str_has_prefix (uri, "dvb:/") )
-	type = PAROLE_MEDIA_TYPE_DVB;
-    else 
-	type = PAROLE_MEDIA_TYPE_UNKNOWN;
-    
-    g_value_init (&val, GST_ENUM_TYPE_MEDIA_TYPE);
-    g_value_set_enum (&val, type);
-    g_object_set_property (G_OBJECT (stream), "media-type", &val);
-    g_value_unset (&val);
-}
-
-static void parole_stream_set_property (GObject *object,
-				        guint prop_id,
-				        const GValue *value,
-				        GParamSpec *pspec)
-{
-    ParoleStream *stream;
-    stream = PAROLE_STREAM (object);
-
-    switch (prop_id)
-    {
-	case PROP_URI:
-	{
-	    ParoleStreamPrivate *priv;
-	    priv = PAROLE_STREAM_GET_PRIVATE (stream);
-	    priv->uri = g_value_dup_string (value);
-	    parole_stream_get_media_type_from_uri (stream, priv->uri);
-	    break;
-	}
-	case PROP_SUBTITLES:
-	    PAROLE_STREAM_DUP_GVALUE_STRING (PAROLE_STREAM_GET_PRIVATE (stream)->subtitles, value);
-	    break;
-	case PROP_LIVE:
-	    PAROLE_STREAM_GET_PRIVATE (stream)->live = g_value_get_boolean (value);
-	    break;
-	case PROP_MEDIA_TYPE:
-	    PAROLE_STREAM_GET_PRIVATE (stream)->media_type = g_value_get_enum (value);
-	    break;
-	case PROP_HAS_AUDIO:
-	    PAROLE_STREAM_GET_PRIVATE (stream)->has_audio = g_value_get_boolean (value);
-	    break;
-	case PROP_HAS_VIDEO:
-	    PAROLE_STREAM_GET_PRIVATE (stream)->has_video = g_value_get_boolean (value);
-	    break;
-	case PROP_SEEKABLE:
-	    PAROLE_STREAM_GET_PRIVATE (stream)->seekable = g_value_get_boolean (value);
-	    break;
-	case PROP_DISP_PAR_D:
-	    PAROLE_STREAM_GET_PRIVATE (stream)->disp_par_d = g_value_get_uint (value);
-	    break;
-	case PROP_DISP_PAR_N:
-	    PAROLE_STREAM_GET_PRIVATE (stream)->disp_par_n = g_value_get_uint (value);
-	    break;
-	case PROP_TRACKS:
-	    PAROLE_STREAM_GET_PRIVATE (stream)->tracks = g_value_get_uint (value);
-	    break;
-	case PROP_TRACK:
-	    PAROLE_STREAM_GET_PRIVATE (stream)->track = g_value_get_uint (value);
-	    break;
-	case PROP_TAG_AVAILABLE:
-	    PAROLE_STREAM_GET_PRIVATE (stream)->tag_available = g_value_get_boolean (value);
-	    break;
-	case PROP_DURATION:
-	    PAROLE_STREAM_GET_PRIVATE (stream)->duration = g_value_get_double (value);
-	    break;
-	case PROP_ABSOLUTE_DURATION:
-	    PAROLE_STREAM_GET_PRIVATE (stream)->absolute_duration = g_value_get_int64 (value);
-	    break;
-	case PROP_VIDEO_HEIGHT:
-	    PAROLE_STREAM_GET_PRIVATE (stream)->video_h = g_value_get_int (value);
-	    break;
-	case PROP_VIDEO_WIDTH:
-	    PAROLE_STREAM_GET_PRIVATE (stream)->video_w = g_value_get_int (value);
-	    break;
-	case PROP_TITLE:
-	    PAROLE_STREAM_DUP_GVALUE_STRING (PAROLE_STREAM_GET_PRIVATE (stream)->title, value);
-	    break;
-	case PROP_ARTIST:
-	    PAROLE_STREAM_DUP_GVALUE_STRING (PAROLE_STREAM_GET_PRIVATE (stream)->artist, value);
-	    break;
-	case PROP_YEAR:
-	    PAROLE_STREAM_DUP_GVALUE_STRING (PAROLE_STREAM_GET_PRIVATE (stream)->year, value);
-	    break;
-	case PROP_ALBUM:
-	    PAROLE_STREAM_DUP_GVALUE_STRING (PAROLE_STREAM_GET_PRIVATE (stream)->album, value);
-	    break;
-	case PROP_COMMENT:
-	    PAROLE_STREAM_DUP_GVALUE_STRING (PAROLE_STREAM_GET_PRIVATE (stream)->comment, value);
-	    break;
-	default:
-           G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-           break;
-    }
-}
-
-static void parole_stream_get_property (GObject *object,
-				        guint prop_id,
-				        GValue *value,
-				        GParamSpec *pspec)
-{
-    ParoleStream *stream;
-    stream = PAROLE_STREAM (object);
-
-    switch (prop_id)
-    {
-	case PROP_URI:
-	    g_value_set_string (value, PAROLE_STREAM_GET_PRIVATE (stream)->uri);
-	    break;
-	case PROP_SUBTITLES:
-	    g_value_set_string (value, PAROLE_STREAM_GET_PRIVATE (stream)->subtitles);
-	    break;
-	case PROP_LIVE:
-	    g_value_set_boolean (value, PAROLE_STREAM_GET_PRIVATE (stream)->live);
-	    break;
-	case PROP_MEDIA_TYPE:
-	    g_value_set_enum (value, PAROLE_STREAM_GET_PRIVATE (stream)->media_type);
-	    break;
-	case PROP_HAS_AUDIO:
-	    g_value_set_boolean (value, PAROLE_STREAM_GET_PRIVATE (stream)->has_audio);
-	    break;
-	case PROP_HAS_VIDEO:
-	    g_value_set_boolean (value, PAROLE_STREAM_GET_PRIVATE (stream)->has_video);
-	    break;
-	case PROP_SEEKABLE:
-	    g_value_set_boolean (value, PAROLE_STREAM_GET_PRIVATE (stream)->seekable);
-	    break;
-	case PROP_DISP_PAR_D:
-	    g_value_set_uint (value, PAROLE_STREAM_GET_PRIVATE (stream)->disp_par_d);
-	    break;
-	case PROP_DISP_PAR_N:
-	    g_value_set_uint (value, PAROLE_STREAM_GET_PRIVATE (stream)->disp_par_n);
-	    break;
-	case PROP_DURATION:
-	    g_value_set_double (value, PAROLE_STREAM_GET_PRIVATE (stream)->duration);
-	    break;
-	case PROP_TRACKS:
-	    g_value_set_uint (value, PAROLE_STREAM_GET_PRIVATE (stream)->tracks);
-	    break;
-	case PROP_TRACK:
-	    g_value_set_uint (value, PAROLE_STREAM_GET_PRIVATE (stream)->track);
-	    break;
-	case PROP_TAG_AVAILABLE:
-	    g_value_set_double (value, PAROLE_STREAM_GET_PRIVATE (stream)->tag_available);
-	    break;
-	case PROP_ABSOLUTE_DURATION:
-	    g_value_set_int64 (value, PAROLE_STREAM_GET_PRIVATE (stream)->absolute_duration);
-	    break;
-	case PROP_VIDEO_HEIGHT:
-	    g_value_set_int (value, PAROLE_STREAM_GET_PRIVATE (stream)->video_h);
-	    break;
-	case PROP_VIDEO_WIDTH:
-	    g_value_set_int (value, PAROLE_STREAM_GET_PRIVATE (stream)->video_w);
-	    break;
-	case PROP_TITLE:
-	    g_value_set_string (value, PAROLE_STREAM_GET_PRIVATE (stream)->title);
-	    break;
-	case PROP_ARTIST:
-	    g_value_set_string (value, PAROLE_STREAM_GET_PRIVATE (stream)->artist);
-	    break;
-	case PROP_YEAR:
-	    g_value_set_string (value, PAROLE_STREAM_GET_PRIVATE (stream)->year);
-	    break;
-	case PROP_ALBUM:
-	    g_value_set_string (value, PAROLE_STREAM_GET_PRIVATE (stream)->album);
-	    break;
-	case PROP_COMMENT:
-	    g_value_set_string (value, PAROLE_STREAM_GET_PRIVATE (stream)->comment);
-	    break;
-	default:
-	    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-	    break;
-    }
-}
-
-static void
-parole_stream_finalize (GObject *object)
-{
-    ParoleStream *stream;
-
-    stream = PAROLE_STREAM (object);
-    
-    parole_stream_init_properties (stream);
-
-    G_OBJECT_CLASS (parole_stream_parent_class)->finalize (object);
-}
-
-static void
-parole_stream_class_init (ParoleStreamClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-    object_class->finalize = parole_stream_finalize;
-
-    object_class->get_property = parole_stream_get_property;
-    object_class->set_property = parole_stream_set_property;
-
-    /**
-     * ParoleStream:uri:
-     * 
-     * Currently loaded uri.
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_URI,
-				     g_param_spec_string ("uri",
-							  NULL, NULL,
-							  NULL,
-							  G_PARAM_READWRITE));
-    
-    /**
-     * ParoleStream:subtitles:
-     * 
-     * Subtitles path, this is only valid for local files
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_SUBTITLES,
-				     g_param_spec_string ("subtitles",
-							  NULL, NULL,
-							  NULL,
-							  G_PARAM_READWRITE));
-    
-    /**
-     * ParoleStream:has-audio:
-     * 
-     * Whether the stream has audio.
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_HAS_AUDIO,
-				     g_param_spec_boolean ("has-audio",
-							   NULL, NULL,
-							   FALSE,
-							   G_PARAM_READWRITE));
-    /**
-     * ParoleStream:has-video:
-     * 
-     * Whether the stream has video.
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_HAS_VIDEO,
-				     g_param_spec_boolean ("has-video",
-							   NULL, NULL,
-							   FALSE,
-							   G_PARAM_READWRITE));
-    
-    /**
-     * ParoleStream:live:
-     * 
-     * Whether the stream is a live stream.
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_LIVE,
-				     g_param_spec_boolean ("live",
-							   NULL, NULL,
-							   FALSE,
-							   G_PARAM_READWRITE));
-
-    /**
-     * ParoleStream:media-type:
-     * 
-     *
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_MEDIA_TYPE,
-				     g_param_spec_enum ("media-type",
-							NULL, NULL,
-							GST_ENUM_TYPE_MEDIA_TYPE,
-							PAROLE_MEDIA_TYPE_UNKNOWN,
-							G_PARAM_READWRITE));
-
-    /**
-     * ParoleStream:seekable:
-     * 
-     * Whether the stream is seekable, for example live 
-     * streams are not seekable.
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_SEEKABLE,
-				     g_param_spec_boolean ("seekable",
-							   NULL, NULL,
-							   FALSE,
-							   G_PARAM_READWRITE));
-
-    /**
-     * ParoleStream:duration:
-     * 
-     * 
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_DURATION,
-				     g_param_spec_double("duration",
-							 NULL, NULL,
-							 0, G_MAXDOUBLE,
-							 0,
-							 G_PARAM_READWRITE));
-
-    /**
-     * ParoleStream:tag-available:
-     * 
-     * Whether tags information are available on the current stream.
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_SEEKABLE,
-				     g_param_spec_boolean ("tag-available",
-							   NULL, NULL,
-							   FALSE,
-							   G_PARAM_READWRITE));
-
-    /**
-     * ParoleStream:absolute-duration:
-     * 
-     * 
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_ABSOLUTE_DURATION,
-				     g_param_spec_int64 ("absolute-duration",
-							  NULL, NULL,
-							  0, G_MAXINT64,
-							  0,
-							  G_PARAM_READWRITE));
-
-    /**
-     * ParoleStream:disp-par-n:
-     * 
-     * 
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_DISP_PAR_N,
-				     g_param_spec_uint ("disp-par-n",
-							NULL, NULL,
-							1, G_MAXUINT,
-							1,
-							G_PARAM_READWRITE));
-							  
-    /**
-     * ParoleStream:disp-par-n:
-     * 
-     * 
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_DISP_PAR_D,
-				     g_param_spec_uint ("disp-par-d",
-							NULL, NULL,
-							1, G_MAXUINT,
-							1,
-							G_PARAM_READWRITE));
-							
-    /**
-     * ParoleStream:video-width:
-     * 
-     * 
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_VIDEO_WIDTH,
-				     g_param_spec_int    ("video-width",
-							  NULL, NULL,
-							  0, G_MAXINT,
-							  0,
-							  G_PARAM_READWRITE));
-							  
-    /**
-     * ParoleStream:video-height:
-     * 
-     * 
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_VIDEO_HEIGHT,
-				     g_param_spec_int    ("video-height",
-							  NULL, NULL,
-							  0, G_MAXINT,
-							  0,
-							  G_PARAM_READWRITE));
-	
-    /**
-     * ParoleStream:num-tracks:
-     * 
-     * Number of tracks in the cdda source, only valid if
-     * ParoleStream:media-type: is PAROLE_MEDIA_TYPE_CDDA.
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_TRACKS,
-				     g_param_spec_uint   ("num-tracks",
-							  NULL, NULL,
-							  1, 99,
-							  1,
-							  G_PARAM_READWRITE));
-							  
-    /**
-     * ParoleStream:track:
-     * 
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_TRACK,
-				     g_param_spec_uint   ("track",
-							  NULL, NULL,
-							  1, 99,
-							  1,
-							  G_PARAM_READWRITE));
-    /**
-     * ParoleStream:title:
-     * 
-     * 
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_TITLE,
-				     g_param_spec_string ("title",
-							  NULL, NULL,
-							  NULL,
-							  G_PARAM_READWRITE));
-
-
-    /**
-     * ParoleStream:artist:
-     * 
-     * 
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_ARTIST,
-				     g_param_spec_string ("artist",
-							  NULL, NULL,
-							  NULL,
-							  G_PARAM_READWRITE));
-							  
-    /**
-     * ParoleStream:year:
-     * 
-     * 
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_YEAR,
-				     g_param_spec_string ("year",
-							  NULL, NULL,
-							  NULL,
-							  G_PARAM_READWRITE));
-							  
-    /**
-     * ParoleStream:album:
-     * 
-     * 
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_ALBUM,
-				     g_param_spec_string ("album",
-							  NULL, NULL,
-							  NULL,
-							  G_PARAM_READWRITE));
-							  
-    /**
-     * ParoleStream:comment:
-     * 
-     * 
-     * 
-     * Since: 0.2 
-     **/
-    g_object_class_install_property (object_class,
-				     PROP_COMMENT,
-				     g_param_spec_string ("comment",
-							  NULL, NULL,
-							  NULL,
-							  G_PARAM_READWRITE));
-							  
-    g_type_class_add_private (klass, sizeof (ParoleStreamPrivate));
-}
-
-static void
-parole_stream_init (ParoleStream *stream)
-{
-    parole_stream_init_properties (stream);
-}
-
-ParoleStream *
-parole_stream_new (void)
-{
-    ParoleStream *stream = NULL;
-    stream = g_object_new (PAROLE_TYPE_STREAM, NULL);
-    return stream;
-}
-
-void parole_stream_init_properties (ParoleStream *stream)
-{
-    ParoleStreamPrivate *priv;
-    
-    priv = PAROLE_STREAM_GET_PRIVATE (stream);
-    
-    priv->live = FALSE;
-    priv->seekable = FALSE;
-    priv->has_audio = FALSE;
-    priv->has_video = FALSE;
-    priv->absolute_duration = 0;
-    priv->duration = 0;
-    priv->tag_available = FALSE;
-    priv->media_type = PAROLE_MEDIA_TYPE_UNKNOWN;
-    priv->video_h = 0;
-    priv->video_w = 0;
-    priv->tracks = 1;
-    priv->track = 1;
-    priv->disp_par_n = 1;
-    priv->disp_par_d = 1;
-    
-    PAROLE_STREAM_FREE_STR_PROP (priv->title);
-    PAROLE_STREAM_FREE_STR_PROP (priv->uri);
-    PAROLE_STREAM_FREE_STR_PROP (priv->subtitles);
-    PAROLE_STREAM_FREE_STR_PROP (priv->artist);
-    PAROLE_STREAM_FREE_STR_PROP (priv->year);
-    PAROLE_STREAM_FREE_STR_PROP (priv->album);
-    PAROLE_STREAM_FREE_STR_PROP (priv->comment);
-}
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index d351044..a122328 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -11,3 +11,7 @@ endif
 if WINDOW_TITLE_PLUGIN
 SUBDIRS+=window-title
 endif
+
+if POWER_MANAGER_PLUGIN
+SUBDIRS+=power-manager
+endif
\ No newline at end of file
diff --git a/plugins/tray/Makefile.am b/plugins/power-manager/Makefile.am
similarity index 64%
copy from plugins/tray/Makefile.am
copy to plugins/power-manager/Makefile.am
index a240229..7e0cb2b 100644
--- a/plugins/tray/Makefile.am
+++ b/plugins/power-manager/Makefile.am
@@ -1,7 +1,7 @@
 INCLUDES =					\
 	-I$(top_builddir)			\
 	-I$(top_srcdir)				\
-	-DG_LOG_DOMAIN=\"parole_tray\"    	\
+	-DG_LOG_DOMAIN=\"power-manager_plugin\" \
 	-DLIBEXECDIR=\"$(libexecdir)\"		\
 	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"
 
@@ -9,33 +9,30 @@ pluginsdir = 					\
 	$(libdir)/parole-$(PAROLE_VERSION_API)
 
 plugins_LTLIBRARIES =				\
-	tray-icon.la
+	power-manager-plugin.la
 
-tray_icon_la_SOURCES =				\
-	tray-plugin.c				\
-	tray-provider.c				\
-	tray-provider.h
+power_manager_plugin_la_SOURCES =		\
+	power-manager-plugin.c			\
+	power-manager-provider.c		\
+	power-manager-provider.h
 
-tray_icon_la_CFLAGS =				\
+power_manager_plugin_la_CFLAGS =		\
 	$(PLATFORM_CFLAGS)			\
 	$(GTK_CFLAGS)				\
-	$(LIBXFCE4GUI_CFLAGS)			\
 	$(LIBXFCE4UTIL_CFLAGS)			\
-	$(LIBNOTIFY_CFLAGS)
+	$(DBUS_GLIB_CFLAGS)
+	
 
-tray_icon_la_LDFLAGS =				\
+power_manager_plugin_la_LDFLAGS =		\
 	-avoid-version				\
 	-export-dynamic				\
 	-module					\
 	$(PLATFORM_LDFLAGS)
 
-tray_icon_la_LIBADD =				\
-	$(LIBNOTIFY_LIBS)
-
 #
 # .desktop file
 #
-desktop_in_files = system-tray.desktop.in
+desktop_in_files = power-manager.desktop.in
 desktopdir = $(datadir)/parole/parole-plugins-$(PAROLE_VERSION_API)
 desktop_DATA =  $(desktop_in_files:.desktop.in=.desktop)
 @INTLTOOL_DESKTOP_RULE@
diff --git a/plugins/sample/sample-plugin.c b/plugins/power-manager/power-manager-plugin.c
similarity index 92%
copy from plugins/sample/sample-plugin.c
copy to plugins/power-manager/power-manager-plugin.c
index 5e19a2e..fdadc93 100644
--- a/plugins/sample/sample-plugin.c
+++ b/plugins/power-manager/power-manager-plugin.c
@@ -24,7 +24,7 @@
 
 #include <libxfce4util/libxfce4util.h>
 
-#include "sample-provider.h"
+#include "power-manager-provider.h"
 
 G_MODULE_EXPORT GType	parole_plugin_initialize (ParoleProviderPlugin *plugin);
 						  
@@ -34,8 +34,8 @@ G_MODULE_EXPORT GType
 parole_plugin_initialize (ParoleProviderPlugin *plugin)
 {
     xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
-    sample_provider_register_type (plugin);
-    return SAMPLE_TYPE_PROVIDER;
+    pm_provider_register_type (plugin);
+    return PM_TYPE_PROVIDER;
 }
 
 G_MODULE_EXPORT void
diff --git a/plugins/power-manager/power-manager-provider.c b/plugins/power-manager/power-manager-provider.c
new file mode 100644
index 0000000..a485519
--- /dev/null
+++ b/plugins/power-manager/power-manager-provider.c
@@ -0,0 +1,213 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <dbus/dbus-glib.h>
+
+#include <libxfce4util/libxfce4util.h>
+
+#include "power-manager-provider.h"
+
+static void   pm_provider_iface_init 	   (ParoleProviderPluginIface *iface);
+static void   pm_provider_finalize         (GObject 	              *object);
+
+
+struct _PmProviderClass
+{
+    GObjectClass 	  parent_class;
+};
+
+struct _PmProvider
+{
+    GObject      	  parent;
+    
+    
+    DBusGConnection 	 *bus;
+    DBusGProxy           *proxy;
+    ParoleProviderPlayer *player;
+    guint 		  cookie;
+    gboolean		  inhibitted;
+};
+
+PAROLE_DEFINE_TYPE_WITH_CODE (PmProvider, 
+			      pm_provider, 
+			      G_TYPE_OBJECT,
+			      PAROLE_IMPLEMENT_INTERFACE (PAROLE_TYPE_PROVIDER_PLUGIN, 
+							  pm_provider_iface_init));
+
+static void
+pm_provider_inhibit (PmProvider *provider)
+{
+    GError *error = NULL;
+    
+#ifdef debug
+    if ( G_UNLIKELY (provider->inhibitted) )
+    {
+	g_warning ("Power manager already inhibitted!!!");
+	return;
+    }
+#endif
+
+    if ( provider->proxy )
+    {
+	TRACE ("Inhibit");
+	provider->inhibitted = dbus_g_proxy_call (provider->proxy, "Inhibit", &error,
+						  G_TYPE_STRING , "Parole",
+						  G_TYPE_STRING, "Playing DVD",
+						  G_TYPE_INVALID, 
+						  G_TYPE_UINT, &provider->cookie,
+						  G_TYPE_INVALID);
+    }
+
+    if ( error )
+    {
+	g_warning ("Unable to inhibit the power manager : %s", error->message);
+	g_error_free (error);
+    }
+}
+
+static void
+pm_provider_uninhibit (PmProvider *provider)
+{
+    if ( provider->inhibitted && provider->cookie != 0 && provider->proxy )
+    {
+	GError *error = NULL;
+	
+	TRACE ("UnInhibit");
+	
+	dbus_g_proxy_call (provider->proxy, "UnInhibit", &error,
+			   G_TYPE_UINT, provider->cookie,
+			   G_TYPE_INVALID,
+			   G_TYPE_INVALID);
+			   
+	if ( error )
+	{
+	    g_warning ("Unable to inhibit the power manager : %s", error->message);
+	    g_error_free (error);
+	}
+	
+	provider->inhibitted = FALSE;
+	provider->cookie = 0;
+    }
+}
+
+static void
+pm_provider_state_changed_cb (ParoleProviderPlayer *player, 
+			      const ParoleStream *stream, 
+			      ParoleState state, 
+			      PmProvider *provider)
+{
+    ParoleMediaType media_type;
+    
+    g_object_get (G_OBJECT (stream),
+		  "media-type", &media_type,
+		  NULL);
+    
+    if ( (state == PAROLE_STATE_PLAYING) && 
+	 ( media_type == PAROLE_MEDIA_TYPE_VCD || 
+	   media_type == PAROLE_MEDIA_TYPE_DVB || 
+	   media_type == PAROLE_MEDIA_TYPE_DVD) )
+    {
+	pm_provider_inhibit (provider);
+    }
+    else
+    {
+	pm_provider_uninhibit (provider);
+    }
+}
+							  
+static gboolean pm_provider_is_configurable (ParoleProviderPlugin *plugin)
+{
+    return FALSE;
+}
+
+static void
+pm_provider_set_player (ParoleProviderPlugin *plugin, ParoleProviderPlayer *player)
+{
+    PmProvider *provider;
+    provider = PM_PROVIDER (plugin);
+    
+    provider->player = player;
+    
+    g_signal_connect (player, "state-changed", 
+		      G_CALLBACK (pm_provider_state_changed_cb), provider);
+}
+
+static void
+pm_provider_iface_init (ParoleProviderPluginIface *iface)
+{
+    iface->get_is_configurable = pm_provider_is_configurable;
+    iface->set_player = pm_provider_set_player;
+}
+
+static void pm_provider_class_init (PmProviderClass *klass)
+{
+    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+    
+    gobject_class->finalize = pm_provider_finalize;
+}
+
+static void pm_provider_init (PmProvider *provider)
+{
+    GError *error = NULL;
+    provider->player = NULL;
+    provider->cookie = 0;
+    provider->proxy = NULL;
+    provider->inhibitted = FALSE;
+    
+    provider->bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+    
+    if ( error )
+    {
+	g_warning ("Unable to get session bus : %s", error->message);
+	g_error_free (error);
+	return;
+    }
+    
+    provider->proxy = dbus_g_proxy_new_for_name (provider->bus,
+						 "org.freedesktop.PowerManagement",
+						 "/org/freedesktop/PowerManagement/Inhibit",
+						 "org.freedesktop.PowerManagement.Inhibit");
+    
+    if ( !provider->proxy )
+    {
+	g_warning ("Unable to get proxy for interface 'org.freedesktop.PowerManagement.Inhibit'");
+    }
+}
+
+static void pm_provider_finalize (GObject *object)
+{
+    PmProvider *provider;
+    
+    provider = PM_PROVIDER (object);
+
+    pm_provider_uninhibit (provider);
+    
+    if ( provider->proxy )
+	g_object_unref (provider->proxy);
+    
+    if ( provider->bus )
+	dbus_g_connection_unref (provider->bus);
+    
+    G_OBJECT_CLASS (pm_provider_parent_class)->finalize (object);
+}
diff --git a/plugins/power-manager/power-manager-provider.h b/plugins/power-manager/power-manager-provider.h
new file mode 100644
index 0000000..82b798c
--- /dev/null
+++ b/plugins/power-manager/power-manager-provider.h
@@ -0,0 +1,44 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef PM_PROVIDER_H_
+#define PM_PROVIDER_H_
+
+#include <parole/parole.h>
+
+G_BEGIN_DECLS
+
+typedef struct _PmProviderClass PmProviderClass;
+typedef struct _PmProvider      PmProvider;
+
+#define PM_TYPE_PROVIDER             (pm_provider_get_type ())
+#define PM_PROVIDER(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), PM_TYPE_PROVIDER, PmProvider))
+#define PM_PROVIDER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), PM_TYPE_PROVIDER, PmProviderClass))
+#define PM_IS_PROVIDER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PM_TYPE_PROVIDER))
+#define PM_IS_PROVIDER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), PM_TYPE_PROVIDER))
+#define PM_PROVIDER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), PM_TYPE_PROVIDER, PmProviderClass))
+
+GType pm_provider_get_type      	(void) G_GNUC_CONST G_GNUC_INTERNAL;
+
+void  pm_provider_register_type	(ParoleProviderPlugin *plugin);
+
+G_END_DECLS
+
+#endif /*PM_PROVIDER_H_*/
diff --git a/plugins/power-manager/power-manager.desktop.in b/plugins/power-manager/power-manager.desktop.in
new file mode 100644
index 0000000..4dbb26f
--- /dev/null
+++ b/plugins/power-manager/power-manager.desktop.in
@@ -0,0 +1,6 @@
+[Parole Plugin]
+Module=power-manager-plugin
+_Name=Power Manager Plugin
+_Description=Inhibit Power Manager from suspending the machine while playing DVD.
+Authors=Ali Abdallah aliov at xfce.org
+Website=http://goodies.xfce.org/projects/applications/parole
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 61d35f5..3962ade 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -32,5 +32,6 @@ plugins/window-title/window-title-plugin.c
 plugins/window-title/window-title-provider.c
 plugins/window-title/window-title-provider.h
 plugins/window-title/window-title.desktop.in
+plugins/power-manager/power-manager.desktop.in
 browser-plugin/media-plugin/main.c
 browser-plugin/media-plugin/parole-plugin-player.c



More information about the Xfce4-commits mailing list