gnome-power-manager r2917 - in trunk: . libunique src



Author: rhughes
Date: Thu Sep  4 10:16:44 2008
New Revision: 2917
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=2917&view=rev

Log:
2008-09-04  Richard Hughes  <richard hughsie com>

* Makefile.am:
* RELEASE:
* configure.ac:
* libunique/Makefile.am:
* libunique/libunique.c:
* libunique/libunique.h:
* src/Makefile.am:
* src/egg-unique.c: (egg_unique_message_cb), (egg_unique_assign),
(egg_unique_class_init), (egg_unique_init), (egg_unique_finalize),
(egg_unique_new):
* src/egg-unique.h:
* src/gpm-prefs.c: (gpm_prefs_activated_cb), (main):
* src/gpm-statistics.c: (gpm_statistics_activated_cb), (main):
Move from LibUnique to EggUnique


Added:
   trunk/src/egg-unique.c
   trunk/src/egg-unique.h
Removed:
   trunk/libunique/
Modified:
   trunk/ChangeLog
   trunk/Makefile.am
   trunk/RELEASE
   trunk/configure.ac
   trunk/src/Makefile.am
   trunk/src/gpm-prefs.c
   trunk/src/gpm-statistics.c

Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am	(original)
+++ trunk/Makefile.am	Thu Sep  4 10:16:44 2008
@@ -5,7 +5,6 @@
 	libdbus-glib					\
 	libhal-glib					\
 	libidletime					\
-	libunique					\
 	src						\
 	po						\
 	docs						\

Modified: trunk/RELEASE
==============================================================================
--- trunk/RELEASE	(original)
+++ trunk/RELEASE	Thu Sep  4 10:16:44 2008
@@ -7,9 +7,9 @@
 â Create a tag:
 
 svn copy \
-svn+ssh://rhughes svn gnome org/svn/gnome-power-manager/branches/gnome-2-22 \
-svn+ssh://rhughes svn gnome org/svn/gnome-power-manager/tags/GNOME_POWER_MANAGER_2_22_1 \
--m "Tagged for release 2.22.1"
+svn+ssh://rhughes svn gnome org/svn/gnome-power-manager/branches/gnome-2-24 \
+svn+ssh://rhughes svn gnome org/svn/gnome-power-manager/tags/GNOME_POWER_MANAGER_2_24_1 \
+-m "Tagged for release 2.24.1"
 
 svn copy \
 svn+ssh://rhughes svn gnome org/svn/gnome-power-manager/trunk \
@@ -33,9 +33,9 @@
 GNOME Power Manager is a session daemon that makes it easy to manage the
 power on your laptop or desktop system.
 
-This _unstable_ release contains lots of crazy new code since 2.21.1 was released. WARNING, this code may impregnate your cat called Dave and steal all of the magazines from the bathroom.
+This _unstable_ release contains lots of crazy new code since 2.23.1 was released. WARNING, this code may impregnate your cat called Dave and steal all of the magazines from the bathroom.
 
-This stable release contains important fixes since 2.22.1 was released. Distributions should consider upgrading gnome-power-manager via errata packages if possible.
+This stable release contains important fixes since 2.24.1 was released. Distributions should consider upgrading gnome-power-manager via errata packages if possible.
 
 There are a few fixes focused on polishing for the new release.
 
@@ -44,6 +44,6 @@
 Making a Branch
 ===============
 
-svn cp svn+ssh://rhughes svn gnome org/svn/gnome-power-manager/trunk svn+ssh://rhughes svn gnome org/svn/gnome-power-manager/branches/gnome-2-22  -m "Branched for gnome-2-22"
+svn cp svn+ssh://rhughes svn gnome org/svn/gnome-power-manager/trunk svn+ssh://rhughes svn gnome org/svn/gnome-power-manager/branches/gnome-2-24  -m "Branched for gnome-2-24"
 
 Additionally, gnome-power-manager has branched, with future development work being done in trunk.

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Thu Sep  4 10:16:44 2008
@@ -591,7 +591,6 @@
 libhal-glib/Makefile
 libdbus-glib/Makefile
 libidletime/Makefile
-libunique/Makefile
 docs/Makefile
 man/Makefile
 help/Makefile

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Thu Sep  4 10:16:44 2008
@@ -14,6 +14,7 @@
 	$(HAL_CFLAGS)					\
 	$(DBUS_CFLAGS)					\
 	$(GNOME_CFLAGS)					\
+	$(UNIQUE_CFLAGS)				\
 	$(XRANDR_CFLAGS)				\
 	$(LIBNOTIFY_CFLAGS)				\
 	$(UNIQUE_CFLAGS)				\
@@ -30,7 +31,6 @@
 	-DGPM_DATA=\"$(pkgdatadir)\"			\
 	-DEGG_LOG_FILE=\""$(PK_LOG_DIR)/gnome-power-manager"\"	\
 	-I$(top_srcdir)					\
-	-I$(top_srcdir)/libunique			\
 	-I$(top_srcdir)/libhal-glib			\
 	-I$(top_srcdir)/libdbus-glib			\
 	$(NULL)
@@ -47,9 +47,6 @@
 	$(top_builddir)/libdbus-glib/libdbus-watch.la		\
 	$(top_builddir)/libdbus-glib/libdbus-proxy.la
 
-LOCAL_LIBUNIQUE_LIBS =						\
-	$(top_builddir)/libunique/libunique.la
-
 bin_PROGRAMS =						\
 	gnome-power-manager				\
 	gnome-power-preferences				\
@@ -64,6 +61,8 @@
 	egg-color.h					\
 	egg-debug.h					\
 	egg-debug.c					\
+	egg-unique.h					\
+	egg-unique.c					\
 	gpm-statistics.c				\
 	gpm-statistics-core.h				\
 	gpm-statistics-core.c				\
@@ -86,7 +85,6 @@
 	$(GNOME_LIBS)					\
 	$(DBUS_LIBS)					\
 	$(LOCAL_LIBDBUS_LIBS)				\
-	$(LOCAL_LIBUNIQUE_LIBS)				\
 	$(NULL)
 
 if HAVE_UNIQUE
@@ -97,6 +95,8 @@
 gnome_power_preferences_SOURCES =			\
 	egg-debug.h					\
 	egg-debug.c					\
+	egg-unique.h					\
+	egg-unique.c					\
 	gpm-dpms.h					\
 	gpm-dpms.c					\
 	gpm-conf.h					\
@@ -126,7 +126,6 @@
 	$(GPM_EXTRA_LIBS)				\
 	$(LOCAL_LIBHAL_LIBS)				\
 	$(LOCAL_LIBDBUS_LIBS)				\
-	$(LOCAL_LIBUNIQUE_LIBS)				\
 	$(NULL)
 
 if HAVE_UNIQUE

Added: trunk/src/egg-unique.c
==============================================================================
--- (empty file)
+++ trunk/src/egg-unique.c	Thu Sep  4 10:16:44 2008
@@ -0,0 +1,177 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard hughsie com>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <glib.h>
+
+#if HAVE_UNIQUE
+#include <unique/unique.h>
+#endif
+
+#include "egg-unique.h"
+#include "egg-debug.h"
+
+static void     egg_unique_class_init (EggUniqueClass *klass);
+static void     egg_unique_init       (EggUnique      *unique);
+static void     egg_unique_finalize   (GObject        *object);
+
+#define EGG_UNIQUE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EGG_UNIQUE_TYPE, EggUniquePrivate))
+
+struct EggUniquePrivate
+{
+#if HAVE_UNIQUE
+	UniqueApp		*uniqueapp;
+#else
+	gpointer		 uniqueapp;
+#endif
+};
+
+enum {
+	ACTIVATED,
+	LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (EggUnique, egg_unique, G_TYPE_OBJECT)
+
+#if HAVE_UNIQUE
+/**
+ * egg_unique_message_cb:
+ **/
+static void
+egg_unique_message_cb (UniqueApp *app, UniqueCommand command, UniqueMessageData *message_data,
+		      guint time, EggUnique *egg_unique)
+{
+	g_return_if_fail (EGG_IS_UNIQUE (egg_unique));
+	if (command == UNIQUE_ACTIVATE)
+		g_signal_emit (egg_unique, signals [ACTIVATED], 0);
+}
+
+/**
+ * egg_unique_assign:
+ * @egg_unique: This class instance
+ * @service: The service name
+ * Return value: %FALSE if we should exit as another instance is running
+ **/
+gboolean
+egg_unique_assign (EggUnique *egg_unique, const gchar *service)
+{
+	g_return_val_if_fail (EGG_IS_UNIQUE (egg_unique), FALSE);
+	g_return_val_if_fail (service != NULL, FALSE);
+
+	if (egg_unique->priv->uniqueapp != NULL) {
+		g_warning ("already assigned!");
+		return FALSE;
+	}
+
+	/* check to see if the user has another instance open */
+	egg_unique->priv->uniqueapp = unique_app_new (service, NULL);
+	if (unique_app_is_running (egg_unique->priv->uniqueapp)) {
+		egg_debug ("You have another instance running. This program will now close");
+		unique_app_send_message (egg_unique->priv->uniqueapp, UNIQUE_ACTIVATE, NULL);
+		return FALSE;
+	}
+
+	/* Listen for messages from another instances */
+	g_signal_connect (G_OBJECT (egg_unique->priv->uniqueapp), "message-received",
+			  G_CALLBACK (egg_unique_message_cb), egg_unique);
+	return TRUE;
+}
+#else
+
+/**
+ * egg_unique_assign:
+ * @egg_unique: This class instance
+ * @service: The service name
+ * Return value: always %TRUE
+ **/
+gboolean
+egg_unique_assign (EggUnique *egg_unique, const gchar *service)
+{
+	g_return_val_if_fail (EGG_IS_UNIQUE (egg_unique), FALSE);
+	return TRUE;
+}
+#endif
+
+/**
+ * egg_unique_class_init:
+ * @egg_unique: This class instance
+ **/
+static void
+egg_unique_class_init (EggUniqueClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = egg_unique_finalize;
+	g_type_class_add_private (klass, sizeof (EggUniquePrivate));
+
+	signals [ACTIVATED] =
+		g_signal_new ("activated",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (EggUniqueClass, activated),
+			      NULL, NULL, g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE, 0);
+}
+
+/**
+ * egg_unique_init:
+ * @egg_unique: This class instance
+ **/
+static void
+egg_unique_init (EggUnique *egg_unique)
+{
+	egg_unique->priv = EGG_UNIQUE_GET_PRIVATE (egg_unique);
+	egg_unique->priv->uniqueapp = NULL;
+}
+
+/**
+ * egg_unique_finalize:
+ * @object: This class instance
+ **/
+static void
+egg_unique_finalize (GObject *object)
+{
+	EggUnique *egg_unique;
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (EGG_IS_UNIQUE (object));
+
+	egg_unique = EGG_UNIQUE_OBJECT (object);
+	egg_unique->priv = EGG_UNIQUE_GET_PRIVATE (egg_unique);
+
+	if (egg_unique->priv->uniqueapp != NULL)
+		g_object_unref (egg_unique->priv->uniqueapp);
+	G_OBJECT_CLASS (egg_unique_parent_class)->finalize (object);
+}
+
+/**
+ * egg_unique_new:
+ * Return value: new class instance.
+ **/
+EggUnique *
+egg_unique_new (void)
+{
+	EggUnique *egg_unique;
+	egg_unique = g_object_new (EGG_UNIQUE_TYPE, NULL);
+	return EGG_UNIQUE_OBJECT (egg_unique);
+}
+

Added: trunk/src/egg-unique.h
==============================================================================
--- (empty file)
+++ trunk/src/egg-unique.h	Thu Sep  4 10:16:44 2008
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard hughsie com>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __EGG_UNIQUE_H
+#define __EGG_UNIQUE_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define EGG_UNIQUE_TYPE		(egg_unique_get_type ())
+#define EGG_UNIQUE_OBJECT(o)	(G_TYPE_CHECK_INSTANCE_CAST ((o), EGG_UNIQUE_TYPE, EggUnique))
+#define EGG_UNIQUE_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), EGG_UNIQUE_TYPE, EggUniqueClass))
+#define EGG_IS_UNIQUE(o)	(G_TYPE_CHECK_INSTANCE_TYPE ((o), EGG_UNIQUE_TYPE))
+#define EGG_IS_UNIQUE_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), EGG_UNIQUE_TYPE))
+#define EGG_UNIQUE_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), EGG_UNIQUE_TYPE, EggUniqueClass))
+
+typedef struct EggUniquePrivate EggUniquePrivate;
+
+typedef struct
+{
+	GObject		parent;
+	EggUniquePrivate *priv;
+} EggUnique;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+	void		(* activated)		(EggUnique	*unique);
+} EggUniqueClass;
+
+GType		 egg_unique_get_type		(void);
+EggUnique	*egg_unique_new			(void);
+
+gboolean	 egg_unique_assign		(EggUnique	*unique,
+						 const gchar	*service);
+
+G_END_DECLS
+
+#endif	/* __EGG_UNIQUE_H */
+

Modified: trunk/src/gpm-prefs.c
==============================================================================
--- trunk/src/gpm-prefs.c	(original)
+++ trunk/src/gpm-prefs.c	Thu Sep  4 10:16:44 2008
@@ -31,7 +31,7 @@
 #include <gtk/gtk.h>
 
 /* local .la */
-#include <libunique.h>
+#include <egg-unique.h>
 
 #include "gpm-common.h"
 #include "gpm-prefs.h"
@@ -69,7 +69,7 @@
  * We have been asked to show the window
  **/
 static void
-gpm_prefs_activated_cb (LibUnique *libunique, GpmPrefs *prefs)
+gpm_prefs_activated_cb (EggUnique *egg_unique, GpmPrefs *prefs)
 {
 	gpm_prefs_activate_window (prefs);
 }
@@ -84,7 +84,7 @@
 	GOptionContext *context;
 	GpmPrefs *prefs = NULL;
 	gboolean ret;
-	LibUnique *libunique;
+	EggUnique *egg_unique;
 
 	const GOptionEntry options[] = {
 		{ "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose,
@@ -107,15 +107,15 @@
 	egg_debug_init (verbose);
 
 	/* are we already activated? */
-	libunique = libunique_new ();
-	ret = libunique_assign (libunique, "org.freedesktop.PowerManagement.Preferences");
+	egg_unique = egg_unique_new ();
+	ret = egg_unique_assign (egg_unique, "org.freedesktop.PowerManagement.Preferences");
 	if (!ret) {
 		goto unique_out;
 	}
 
 	prefs = gpm_prefs_new ();
 
-	g_signal_connect (libunique, "activated",
+	g_signal_connect (egg_unique, "activated",
 			  G_CALLBACK (gpm_prefs_activated_cb), prefs);
 	g_signal_connect (prefs, "action-help",
 			  G_CALLBACK (gpm_prefs_help_cb), prefs);
@@ -125,7 +125,7 @@
 	g_object_unref (prefs);
 
 unique_out:
-	g_object_unref (libunique);
+	g_object_unref (egg_unique);
 
 /* seems to not work...
 	g_option_context_free (context); */

Modified: trunk/src/gpm-statistics.c
==============================================================================
--- trunk/src/gpm-statistics.c	(original)
+++ trunk/src/gpm-statistics.c	Thu Sep  4 10:16:44 2008
@@ -31,7 +31,7 @@
 #include <gtk/gtk.h>
 
 /* local .la */
-#include <libunique.h>
+#include <egg-unique.h>
 
 #include "gpm-common.h"
 #include "gpm-conf.h"
@@ -69,7 +69,7 @@
  * We have been asked to show the window
  **/
 static void
-gpm_statistics_activated_cb (LibUnique *libunique, GpmStatistics *statistics)
+gpm_statistics_activated_cb (EggUnique *egg_unique, GpmStatistics *statistics)
 {
 	gpm_statistics_activate_window (statistics);
 }
@@ -84,7 +84,7 @@
 	GOptionContext *context;
 	GpmStatistics *statistics = NULL;
 	gboolean ret;
-	LibUnique *libunique;
+	EggUnique *egg_unique;
 
 	const GOptionEntry options[] = {
 		{ "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose,
@@ -107,14 +107,14 @@
 	egg_debug_init (verbose);
 
 	/* are we already activated? */
-	libunique = libunique_new ();
-	ret = libunique_assign (libunique, "org.freedesktop.PowerManagement.Statistics");
+	egg_unique = egg_unique_new ();
+	ret = egg_unique_assign (egg_unique, "org.freedesktop.PowerManagement.Statistics");
 	if (!ret) {
 		goto unique_out;
 	}
 
 	statistics = gpm_statistics_new ();
-	g_signal_connect (libunique, "activated",
+	g_signal_connect (egg_unique, "activated",
 			  G_CALLBACK (gpm_statistics_activated_cb), statistics);
 	g_signal_connect (statistics, "action-help",
 			  G_CALLBACK (gpm_statistics_help_cb), statistics);
@@ -124,7 +124,7 @@
 	g_object_unref (statistics);
 
 unique_out:
-	g_object_unref (libunique);
+	g_object_unref (egg_unique);
 
 /* seems to not work...
 	g_option_context_free (context); */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]