aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Jardón <javier.jardon@codethink.co.uk>2011-06-28 16:03:17 +0100
committerJavier Jardón <javier.jardon@codethink.co.uk>2011-06-28 16:03:17 +0100
commita7497869e9014f6c7e13d7c1f2bb929b738fef38 (patch)
tree6189e19c6563535cdfd13ca509c198d93e94de47
parentdcec51a181995abbbed81f570fc173a9c0c1a93a (diff)
downloadayatana-indicator-power-a7497869e9014f6c7e13d7c1f2bb929b738fef38.tar.gz
ayatana-indicator-power-a7497869e9014f6c7e13d7c1f2bb929b738fef38.tar.bz2
ayatana-indicator-power-a7497869e9014f6c7e13d7c1f2bb929b738fef38.zip
Remove power service for now
We are going to use gnome-settings-daemon directly
-rw-r--r--Makefile.am46
-rw-r--r--configure.ac15
-rw-r--r--src/dbus-shared-names.h3
-rw-r--r--src/indicator-power.c25
-rw-r--r--src/power-service-dbus.c188
-rw-r--r--src/power-service-dbus.h57
-rw-r--r--src/power-service.c146
-rw-r--r--src/power-service.xml11
8 files changed, 7 insertions, 484 deletions
diff --git a/Makefile.am b/Makefile.am
index 2812ec6..a2af6a5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,20 +2,6 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
SUBDIRS = po
-############################################################
-
-# DBus service file
-dbus_servicesdir = $(DBUSSERVICEDIR)
-dbus_services_DATA = data/indicator-power.service
-
-# Rule to make the service file with libexecdir expanded
-%.service: %.service.in
- sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
-
-############################################################
-
-libexec_PROGRAMS = indicator-power-service
-
###################
# Indicator Stuff
###################
@@ -36,38 +22,6 @@ libpower_la_LDFLAGS = \
-module \
-avoid-version
-################
-# Status Stuff
-################
-
-indicator_power_service_SOURCES = \
- src/gen-power-service.xml.c \
- src/power-service-dbus.h \
- src/power-service-dbus.c \
- src/power-service.c
-indicator_power_service_CFLAGS = \
- $(POWERSERVICE_CFLAGS) \
- -Wall -Werror \
- -DLOCALEDIR=\"$(localedir)\" \
- -DG_LOG_DOMAIN=\"Indicator-Power\"
-indicator_power_service_LDADD = \
- $(POWERSERVICE_LIBS)
-
-src/gen-%.xml.c: src/%.xml
- @echo "Building $@ from $<"
- @echo "const char * _$(subst -,_,$(subst .,_,$(notdir $(basename $<)))) = " > $@
- @sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@
- @echo ";" >> $@
-
-src/gen-%.xml.h: src/%.xml
- @echo "Building $@ from $<"
- @echo "extern const char * _$(subst -,_,$(subst .,_,$(notdir $(basename $<))));" > $@
-
-BUILT_SOURCES = \
- src/gen-power-service.xml.c \
- src/gen-power-service.xml.h
-
-
############################################################
EXTRA_DIST = autogen.sh
diff --git a/configure.ac b/configure.ac
index 4ce3451..0d58a89 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,15 +35,6 @@ GTK_REQUIRED_VERSION=2.24
GTK3_REQUIRED_VERSION=3.0
INDICATOR_DISPLAY_OBJECTS=0.2
INDICATOR_REQUIRED_VERSION=0.3.0
-DBUSMENUGLIB_REQUIRED_VERSION=0.4
-DBUSMENUGTK_REQUIRED_VERSION=0.4
-
-PKG_CHECK_MODULES([POWERSERVICE],[
- dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION
- glib-2.0 >= $GLIB_REQUIRED_VERSION
- indicator3 >= $INDICATOR_REQUIRED_VERSION
- gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION
-])
AC_ARG_WITH([gtk],
[AS_HELP_STRING([--with-gtk],
@@ -55,14 +46,12 @@ AS_IF([test "x$with_gtk" = x3],
[PKG_CHECK_MODULES([INDICATOR],[
gtk+-3.0 >= $GTK3_REQUIRED_VERSION
indicator3 >= $INDICATOR_REQUIRED_VERSION
- libido3-0.1 >= $INDICATOR_DISPLAY_OBJECTS
- dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION])],
+ libido3-0.1 >= $INDICATOR_DISPLAY_OBJECTS])],
[test "x$with_gtk" = x2],
[PKG_CHECK_MODULES([INDICATOR],[
gtk+-2.0 >= $GTK_REQUIRED_VERSION
indicator >= $INDICATOR_REQUIRED_VERSION
- libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS
- dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION])],
+ libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS])],
[AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])]
)
AC_SUBST(INDICATOR_CFLAGS)
diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h
index 14d20b9..aec725c 100644
--- a/src/dbus-shared-names.h
+++ b/src/dbus-shared-names.h
@@ -24,11 +24,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef __DBUS_SHARED_NAMES_H__
#define __DBUS_SHARED_NAMES_H__
+
#define INDICATOR_POWER_DBUS_NAME "com.canonical.indicator.power"
#define INDICATOR_POWER_DBUS_VERSION 1
#define INDICATOR_POWER_DBUS_OBJECT "/com/canonical/indicator/power/menu"
-#define INDICATOR_POWER_SERVICE_DBUS_OBJECT "/com/canonical/indicator/power/service"
-#define INDICATOR_POWER_SERVICE_DBUS_INTERFACE "com.canonical.indicator.power.service"
#endif /* __DBUS_SHARED_NAMES_H__ */
diff --git a/src/indicator-power.c b/src/indicator-power.c
index f54f689..8685d80 100644
--- a/src/indicator-power.c
+++ b/src/indicator-power.c
@@ -34,16 +34,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libindicator/indicator-object.h>
#include <libindicator/indicator-service-manager.h>
#include <libindicator/indicator-image-helper.h>
-
-/* DBusMenu */
#include <libido/libido.h>
-#if GTK_CHECK_VERSION(3, 0, 0)
-#include <libdbusmenu-gtk3/menu.h>
-#include <libdbusmenu-gtk3/menuitem.h>
-#else
-#include <libdbusmenu-gtk/menu.h>
-#include <libdbusmenu-gtk/menuitem.h>
-#endif
#include "dbus-shared-names.h"
@@ -79,8 +70,7 @@ struct _IndicatorPowerPrivate
{
IndicatorServiceManager *service;
- DbusmenuGtkMenu *menu;
- DbusmenuGtkClient *client;
+ GtkMenu *menu;
GtkLabel *label;
GtkImage *status_image;
@@ -202,7 +192,6 @@ indicator_power_init (IndicatorPower *self)
/* Init variables */
priv->service = NULL;
priv->menu = NULL;
- priv->client = NULL;
/* Do stuff with them */
priv->service = indicator_service_manager_new_version (INDICATOR_POWER_DBUS_NAME,
@@ -214,16 +203,10 @@ indicator_power_init (IndicatorPower *self)
self);
*/
- /* Builds the dbusmenu for the service. */
- priv->menu = dbusmenu_gtkmenu_new (INDICATOR_POWER_DBUS_NAME,
- INDICATOR_POWER_DBUS_OBJECT);
- priv->client = dbusmenu_gtkmenu_get_client (priv->menu);
+ priv->menu = GTK_MENU (gtk_menu_new ());
+ gtk_menu_set_title (priv->menu, _("Power"));
-/*
- dbusmenu_client_add_type_handler (DBUSMENU_CLIENT (client),
- DBUSMENU_ENTRY_MENUITEM_TYPE,
- new_entry_item);
-*/
+ gtk_menu_popup (priv->menu, NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
priv->service_proxy_cancel = g_cancellable_new();
diff --git a/src/power-service-dbus.c b/src/power-service-dbus.c
deleted file mode 100644
index a5783e1..0000000
--- a/src/power-service-dbus.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
-An indicator to power related information in the menubar.
-
-Copyright 2011 Canonical Ltd.
-
-Authors:
- Javier Jardon <javier.jardon@codethink.co.uk>
-
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
-by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "power-service-dbus.h"
-
-#include <gio/gio.h>
-
-#include "dbus-shared-names.h"
-#include "gen-power-service.xml.h"
-
-struct _PowerServiceDbusPrivate
-{
- GDBusConnection *bus;
- GCancellable *bus_cancel;
- guint dbus_registration;
-};
-
-/* GDBus Stuff */
-static GDBusNodeInfo *node_info = NULL;
-static GDBusInterfaceInfo *interface_info = NULL;
-
-static void power_service_dbus_class_init (PowerServiceDbusClass *klass);
-static void power_service_dbus_init (PowerServiceDbus *self);
-static void power_service_dbus_dispose (GObject *object);
-static void power_service_dbus_finalize (GObject *object);
-static void bus_get_cb (GObject *object,
- GAsyncResult *res,
- gpointer user_data);
-
-
-G_DEFINE_TYPE (PowerServiceDbus, power_service_dbus, G_TYPE_OBJECT);
-
-static void
-bus_get_cb (GObject *object,
- GAsyncResult *res,
- gpointer user_data)
-{
- PowerServiceDbus *self = POWER_SERVICE_DBUS (user_data);
- PowerServiceDbusPrivate *priv = self->priv;
- GError *error = NULL;
- GDBusConnection *connection = g_bus_get_finish (res, &error);
-
- if (error != NULL)
- {
- g_error("OMG! Unable to get a connection to DBus: %s", error->message);
- g_error_free(error);
-
- return;
- }
-
- priv->bus = connection;
-
- if (priv->bus_cancel != NULL)
- {
- g_object_unref (priv->bus_cancel);
- priv->bus_cancel = NULL;
- }
-
- /* Now register our object on our new connection */
- priv->dbus_registration = g_dbus_connection_register_object (priv->bus,
- INDICATOR_POWER_SERVICE_DBUS_OBJECT,
- interface_info,
- NULL,
- user_data,
- NULL,
- &error);
- if (error != NULL)
- {
- g_error ("Unable to register the object to DBus: %s", error->message);
- g_error_free(error);
-
- return;
- }
-}
-
-static void
-power_service_dbus_class_init (PowerServiceDbusClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = power_service_dbus_dispose;
- object_class->finalize = power_service_dbus_finalize;
-
- /* Setting up the DBus interfaces */
- if (node_info == NULL)
- {
- GError * error = NULL;
-
- node_info = g_dbus_node_info_new_for_xml (_power_service, &error);
- if (error != NULL)
- {
- g_error ("Unable to parse Power Service Dbus description: %s", error->message);
- g_error_free (error);
- }
- }
-
- if (interface_info == NULL)
- {
- interface_info = g_dbus_node_info_lookup_interface (node_info, INDICATOR_POWER_SERVICE_DBUS_INTERFACE);
-
- if (interface_info == NULL)
- {
- g_error ("Unable to find interface '" INDICATOR_POWER_SERVICE_DBUS_INTERFACE "'");
- }
- }
-
- g_type_class_add_private (klass, sizeof (PowerServiceDbusPrivate));
-}
-
-static void
-power_service_dbus_init (PowerServiceDbus *self)
-{
- PowerServiceDbusPrivate *priv;
-
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- POWER_SERVICE_DBUS_TYPE,
- PowerServiceDbusPrivate);
- priv = self->priv;
-
- priv->bus = NULL;
- priv->bus_cancel = NULL;
- priv->dbus_registration = 0;
-
- self->priv->bus_cancel = g_cancellable_new ();
- g_bus_get (G_BUS_TYPE_SESSION,
- priv->bus_cancel,
- bus_get_cb,
- self);
-}
-
-static void
-power_service_dbus_dispose (GObject *object)
-{
- PowerServiceDbus *self = POWER_SERVICE_DBUS (object);
- PowerServiceDbusPrivate *priv = self->priv;
-
- if (priv->dbus_registration != 0)
- {
- g_dbus_connection_unregister_object (priv->bus,
- priv->dbus_registration);
- /* Don't care if it fails, there's nothing we can do */
- priv->dbus_registration = 0;
- }
-
- if (priv->bus != NULL)
- {
- g_object_unref (priv->bus);
- priv->bus = NULL;
- }
-
- if (priv->bus_cancel != NULL)
- {
- g_cancellable_cancel (priv->bus_cancel);
- g_object_unref (priv->bus_cancel);
- priv->bus_cancel = NULL;
- }
-
- G_OBJECT_CLASS (power_service_dbus_parent_class)->dispose (object);
-}
-
-static void
-power_service_dbus_finalize (GObject *object)
-{
- G_OBJECT_CLASS (power_service_dbus_parent_class)->finalize (object);
-}
-
diff --git a/src/power-service-dbus.h b/src/power-service-dbus.h
deleted file mode 100644
index ae78ccc..0000000
--- a/src/power-service-dbus.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-An indicator to time and date related information in the menubar.
-
-Copyright 2011 Canonical Ltd.
-
-Authors:
- Javier Jardon <javier.jardon@codethink.co.uk>
-
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
-by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef __POWER_SERVICE_DBUS_H__
-#define __POWER_SERVICE_DBUS_H__
-
-#include <glib.h>
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define POWER_SERVICE_DBUS_TYPE (power_service_dbus_get_type ())
-#define POWER_SERVICE_DBUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POWER_SERVICE_DBUS_TYPE, PowerServiceDbus))
-#define POWER_SERVICE_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), POWER_SERVICE_DBUS_TYPE, PowerServiceDbusClass))
-#define IS_POWER_SERVICE_DBUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POWER_SERVICE_DBUS_TYPE))
-#define IS_POWER_SERVICE_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), POWER_SERVICE_DBUS_TYPE))
-#define POWER_SERVICE_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), POWER_SERVICE_DBUS_TYPE, PowerServiceDbusClass))
-
-typedef struct _PowerServiceDbus PowerServiceDbus;
-typedef struct _PowerServiceDbusClass PowerServiceDbusClass;
-typedef struct _PowerServiceDbusPrivate PowerServiceDbusPrivate;
-
-struct _PowerServiceDbus
-{
- GObject parent_instance;
-
- PowerServiceDbusPrivate *priv;
-};
-
-struct _PowerServiceDbusClass
-{
- GObjectClass parent_class;
-};
-
-GType power_service_dbus_get_type (void) G_GNUC_CONST;
-
-G_END_DECLS
-
-#endif /* __POWER_SERVICE_DBUS_H__ */
diff --git a/src/power-service.c b/src/power-service.c
deleted file mode 100644
index 1d21bec..0000000
--- a/src/power-service.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
-An indicator to power related information in the menubar.
-
-Copyright 2011 Canonical Ltd.
-
-Authors:
- Javier Jardon <javier.jardon@codethink.co.uk>
-
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
-by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <glib.h>
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-#include <gio/gio.h>
-
-#include <libdbusmenu-gtk/menuitem.h>
-#include <libdbusmenu-glib/server.h>
-#include <libdbusmenu-glib/client.h>
-#include <libdbusmenu-glib/menuitem.h>
-
-#include <libindicator/indicator-service.h>
-
-#include "power-service-dbus.h"
-#include "dbus-shared-names.h"
-
-static IndicatorService *service = NULL;
-static GMainLoop *mainloop = NULL;
-static DbusmenuServer *server = NULL;
-static PowerServiceDbus *dbus_interface = NULL;
-
-/* Repsonds to the service object saying it's time to shutdown.
- It stops the mainloop. */
-static void
-service_shutdown (IndicatorService *service,
- gpointer user_data)
-{
- g_warning("Shutting down service!");
-
- g_main_loop_quit(mainloop);
-}
-
-static void
-spawn_on_activate_cb (DbusmenuMenuitem *mi,
- guint timestamp,
- gpointer user_data)
-{
- GError * error = NULL;
-
- if (!g_spawn_command_line_async (user_data, &error))
- {
- g_warning ("Unable to start %s: %s", (char *)user_data, error->message);
- g_error_free (error);
- }
-}
-
-static void
-build_menus (DbusmenuMenuitem *root_menuitem)
-{
- DbusmenuMenuitem *power_mi = NULL;
- DbusmenuMenuitem *separator_mi = NULL;
- DbusmenuMenuitem *settings_mi = NULL;
-
- power_mi = dbusmenu_menuitem_new ();
- dbusmenu_menuitem_property_set (power_mi,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Laptop Battery 0:25")); /*TODO*/
- g_signal_connect (G_OBJECT (power_mi),
- DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- G_CALLBACK (spawn_on_activate_cb),
- "gnome-power-statistic");
-
- settings_mi = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set (settings_mi,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Power Settings..."));
- g_signal_connect (G_OBJECT (power_mi),
- DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- G_CALLBACK (spawn_on_activate_cb),
- "gnome-power-preferences");
-
- separator_mi = dbusmenu_menuitem_new ();
- dbusmenu_menuitem_property_set (separator_mi,
- DBUSMENU_MENUITEM_PROP_TYPE,
- DBUSMENU_CLIENT_TYPES_SEPARATOR);
-
-
- dbusmenu_menuitem_child_append (root_menuitem, power_mi);
- dbusmenu_menuitem_child_append (root_menuitem, separator_mi);
- dbusmenu_menuitem_child_append (root_menuitem, settings_mi);
-}
-
-gint
-main (gint argc,
- gchar **argv)
-{
- DbusmenuMenuitem *root_menuitem = NULL;
-
- g_type_init();
-
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
- setlocale (LC_ALL, "");
-
- /* Acknowledging the service init and setting up the interface */
- service = indicator_service_new_version (INDICATOR_POWER_DBUS_NAME,
- INDICATOR_POWER_DBUS_VERSION);
- g_signal_connect (service,
- INDICATOR_SERVICE_SIGNAL_SHUTDOWN,
- G_CALLBACK (service_shutdown),
- NULL);
-
- /* Building the base menu */
- server = dbusmenu_server_new (INDICATOR_POWER_DBUS_OBJECT);
- root_menuitem = dbusmenu_menuitem_new ();
- dbusmenu_server_set_root (server, root_menuitem);
-
- build_menus (root_menuitem);
-
- /* Setup dbus interface */
- dbus_interface = g_object_new (POWER_SERVICE_DBUS_TYPE, NULL);
-
- mainloop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run(mainloop);
-
- g_object_unref (G_OBJECT (service));
- g_object_unref (G_OBJECT (server));
- g_object_unref (G_OBJECT (root_menuitem));
-
- return 0;
-}
diff --git a/src/power-service.xml b/src/power-service.xml
deleted file mode 100644
index d63fe25..0000000
--- a/src/power-service.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<node name="/">
- <interface name="com.canonical.indicator.power.service">
-
-<!-- Methods -->
-
-<!-- Signals -->
-
- </interface>
-</node>
-