[Goodies-commits] r7863 - parole/trunk/parole

Ali Abdallah aliov at xfce.org
Wed Jul 29 17:14:16 CEST 2009


Author: aliov
Date: 2009-07-29 15:14:16 +0000 (Wed, 29 Jul 2009)
New Revision: 7863

Added:
   parole/trunk/parole/parole-session.c
   parole/trunk/parole/parole-session.h
Log:
Add missing files in the previous commit

Added: parole/trunk/parole/parole-session.c
===================================================================
--- parole/trunk/parole/parole-session.c	                        (rev 0)
+++ parole/trunk/parole/parole-session.c	2009-07-29 15:14:16 UTC (rev 7863)
@@ -0,0 +1,166 @@
+/*
+ * * 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 <libxfce4util/libxfce4util.h>
+#include <libxfcegui4/libxfcegui4.h>
+
+#include "parole-session.h"
+
+static void parole_session_finalize   (GObject *object);
+
+#define PAROLE_SESSION_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), PAROLE_TYPE_SESSION, ParoleSessionPrivate))
+
+struct ParoleSessionPrivate
+{
+    SessionClient *client;
+    gboolean	   managed;
+};
+
+enum
+{
+    DIE,
+    SAVE_STATE,
+    LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (ParoleSession, parole_session, G_TYPE_OBJECT)
+
+static void
+parole_session_die (gpointer client_data)
+{
+    ParoleSession *session;
+    
+    session = parole_session_get ();
+    
+    if ( session->priv->managed )
+	g_signal_emit (G_OBJECT (session), signals [DIE], 0);
+}
+
+static void
+parole_session_class_init (ParoleSessionClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    signals [DIE] = 
+        g_signal_new ("die",
+                      PAROLE_TYPE_SESSION,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(ParoleSessionClass, die),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE, 0, G_TYPE_NONE);
+		      
+
+    signals [SAVE_STATE] = 
+        g_signal_new ("save-state",
+                      PAROLE_TYPE_SESSION,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(ParoleSessionClass, save_state),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE, 0, G_TYPE_NONE);
+
+    object_class->finalize = parole_session_finalize;
+
+    g_type_class_add_private (klass, sizeof (ParoleSessionPrivate));
+}
+
+static void
+parole_session_init (ParoleSession *session)
+{
+    session->priv = PAROLE_SESSION_GET_PRIVATE (session);
+    
+    session->priv->client = NULL;
+    
+    session->priv->client = client_session_new_full (NULL,
+						     SESSION_RESTART_NEVER,
+						     40,
+						     NULL,
+						     (gchar *) PACKAGE_NAME,
+						     NULL,
+						     NULL,
+						     NULL,
+						     NULL,
+						     NULL,
+						     NULL);
+						     
+    if ( G_UNLIKELY (session->priv->client == NULL ) )
+    {
+	g_warning ("Failed to connect to session manager");
+	return;
+    }
+    
+    session->priv->managed 	   = session_init (session->priv->client);
+    session->priv->client->die     = parole_session_die;
+}
+
+static void
+parole_session_finalize (GObject *object)
+{
+    ParoleSession *session;
+
+    session = PAROLE_SESSION (object);
+    
+    if ( session->priv->client != NULL )
+    {
+	client_session_free (session->priv->client);
+    }
+
+    G_OBJECT_CLASS (parole_session_parent_class)->finalize (object);
+}
+
+ParoleSession *
+parole_session_get (void)
+{
+    static gpointer parole_session_obj = NULL;
+    
+    if ( G_LIKELY (parole_session_obj != NULL ) )
+    {
+	g_object_ref (parole_session_obj);
+    }
+    else
+    {
+	parole_session_obj = g_object_new (PAROLE_TYPE_SESSION, NULL);
+	g_object_add_weak_pointer (parole_session_obj, &parole_session_obj);
+    }
+    
+    return PAROLE_SESSION (parole_session_obj);
+}
+
+void parole_session_set_client_id (ParoleSession *session, const gchar *client_id)
+{
+    g_return_if_fail (PAROLE_IS_SESSION (session));
+    
+    if ( G_UNLIKELY (session->priv->client == NULL) )
+	return;
+    
+    client_session_set_client_id (session->priv->client, client_id);
+}

Added: parole/trunk/parole/parole-session.h
===================================================================
--- parole/trunk/parole/parole-session.h	                        (rev 0)
+++ parole/trunk/parole/parole-session.h	2009-07-29 15:14:16 UTC (rev 7863)
@@ -0,0 +1,59 @@
+/*
+ * * 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 __PAROLE_SESSION_H
+#define __PAROLE_SESSION_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define PAROLE_TYPE_SESSION        (parole_session_get_type () )
+#define PAROLE_SESSION(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), PAROLE_TYPE_SESSION, ParoleSession))
+#define PAROLE_IS_SESSION(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAROLE_TYPE_SESSION))
+
+typedef struct ParoleSessionPrivate ParoleSessionPrivate;
+
+typedef struct
+{
+    GObject         		parent;
+    ParoleSessionPrivate       *priv;
+    
+} ParoleSession;
+
+typedef struct
+{
+    GObjectClass 		parent_class;
+    
+    void			(*die)			       (ParoleSession *session);
+    
+    void			(*save_state)		       (ParoleSession *session);
+    
+} ParoleSessionClass;
+
+GType        			parole_session_get_type        (void) G_GNUC_CONST;
+
+ParoleSession       	       *parole_session_get             (void);
+
+void 				parole_session_set_client_id   (ParoleSession *session, 
+								const gchar *client_id);
+G_END_DECLS
+
+#endif /* __PAROLE_SESSION_H */




More information about the Goodies-commits mailing list