aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
6 files changed, 5 insertions, 425 deletions
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>
-