summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am33
-rw-r--r--src/egg-dbus-monitor.c251
-rw-r--r--src/egg-dbus-monitor.h65
-rw-r--r--src/egg-dbus-proxy.c301
-rw-r--r--src/egg-dbus-proxy.h66
-rw-r--r--src/egg-unique.c151
-rw-r--r--src/egg-unique.h59
-rw-r--r--src/gpm-backlight-helper.c1
-rw-r--r--src/gpm-backlight.c42
-rw-r--r--src/gpm-brightness.c55
-rw-r--r--src/gpm-button.c2
-rw-r--r--src/gpm-common.c10
-rw-r--r--src/gpm-control.c2
-rw-r--r--src/gpm-dpms.c5
-rw-r--r--src/gpm-engine.c78
-rw-r--r--src/gpm-engine.h2
-rw-r--r--src/gpm-graph-widget.c76
-rw-r--r--src/gpm-icon-names.h (renamed from src/gpm-stock-icons.h)24
-rw-r--r--src/gpm-idle.c18
-rw-r--r--src/gpm-kbd-backlight.c20
-rw-r--r--src/gpm-main.c6
-rw-r--r--src/gpm-manager.c33
-rw-r--r--src/gpm-networkmanager.c2
-rw-r--r--src/gpm-networkmanager.h2
-rw-r--r--src/gpm-phone.c75
-rw-r--r--src/gpm-prefs-core.c27
-rw-r--r--src/gpm-prefs-core.h3
-rw-r--r--src/gpm-prefs.c47
-rw-r--r--src/gpm-session.c18
-rw-r--r--src/gpm-statistics.c62
-rw-r--r--src/gpm-tray-icon.c169
-rw-r--r--src/gpm-tray-icon.h2
-rw-r--r--src/gpm-upower.c21
-rw-r--r--src/gpm-upower.h2
-rw-r--r--src/gsd-media-keys-window.c65
-rw-r--r--src/msd-osd-window.c359
-rw-r--r--src/msd-osd-window.h15
37 files changed, 557 insertions, 1612 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index b7469ea..48d071b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,9 +13,8 @@ EXTRA_DIST = \
AM_CPPFLAGS = \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
- $(MATE_CFLAGS) \
+ $(CAIRO_CFLAGS) \
$(KEYRING_CFLAGS) \
- $(UNIQUE_CFLAGS) \
$(X11_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
$(CANBERRA_CFLAGS) \
@@ -38,8 +37,9 @@ AM_CPPFLAGS = \
-DEGG_LOGGING="\"GPM_LOGGING\"" \
-DEGG_CONSOLE="\"GPM_CONSOLE\"" \
-I$(top_srcdir) \
- $(DISABLE_DEPRECATED) \
- $(NULL)
+ $(DISABLE_DEPRECATED)
+
+AM_CPPFLAGS += $(NULL)
bin_PROGRAMS = \
mate-power-manager \
@@ -62,18 +62,12 @@ libgpmshared_a_SOURCES = \
egg-color.h \
egg-debug.h \
egg-debug.c \
- egg-unique.h \
- egg-unique.c \
egg-precision.h \
egg-precision.c \
egg-array-float.c \
egg-array-float.h \
egg-idletime.h \
egg-idletime.c \
- egg-dbus-proxy.h \
- egg-dbus-proxy.c \
- egg-dbus-monitor.h \
- egg-dbus-monitor.c \
egg-discrete.h \
egg-discrete.c \
egg-console-kit.h \
@@ -85,8 +79,7 @@ libgpmshared_a_SOURCES = \
gpm-marshal.h \
gpm-marshal.c \
gpm-upower.c \
- gpm-upower.h \
- $(NULL)
+ gpm-upower.h
mate_power_backlight_helper_SOURCES = \
gpm-backlight-helper.c \
@@ -114,8 +107,7 @@ mate_power_statistics_LDADD = \
$(GLIB_LIBS) \
$(X11_LIBS) \
$(UPOWER_LIBS) \
- $(MATE_LIBS) \
- $(UNIQUE_LIBS) \
+ $(CAIRO_LIBS) \
$(DBUS_LIBS) \
-lm
@@ -133,9 +125,8 @@ mate_power_preferences_LDADD = \
libgpmshared.a \
$(GLIB_LIBS) \
$(X11_LIBS) \
- $(MATE_LIBS) \
+ $(CAIRO_LIBS) \
$(DBUS_LIBS) \
- $(UNIQUE_LIBS) \
$(GPM_EXTRA_LIBS) \
$(UPOWER_LIBS) \
-lm
@@ -172,7 +163,7 @@ mate_power_manager_SOURCES = \
gpm-session.c \
gpm-networkmanager.h \
gpm-networkmanager.c \
- gpm-stock-icons.h \
+ gpm-icon-names.h \
gsd-media-keys-window.h \
gsd-media-keys-window.c \
msd-osd-window.h \
@@ -186,7 +177,7 @@ mate_power_manager_LDADD = \
$(GLIB_LIBS) \
$(X11_LIBS) \
$(GSTREAMER_LIBS) \
- $(MATE_LIBS) \
+ $(CAIRO_LIBS) \
$(KEYRING_LIBS) \
$(DBUS_LIBS) \
$(X11_LIBS) \
@@ -209,10 +200,6 @@ mate_power_self_test_SOURCES = \
egg-test.c \
egg-debug.h \
egg-debug.c \
- egg-dbus-monitor.h \
- egg-dbus-monitor.c \
- egg-dbus-proxy.h \
- egg-dbus-proxy.c \
egg-precision.h \
egg-precision.c \
egg-idletime.h \
@@ -254,7 +241,7 @@ mate_power_self_test_SOURCES = \
mate_power_self_test_LDADD = \
$(GLIB_LIBS) \
$(X11_LIBS) \
- $(MATE_LIBS) \
+ $(CAIRO_LIBS) \
$(KEYRING_LIBS) \
$(GSTREAMER_LIBS) \
$(UPOWER_LIBS) \
diff --git a/src/egg-dbus-monitor.c b/src/egg-dbus-monitor.c
deleted file mode 100644
index b8238d1..0000000
--- a/src/egg-dbus-monitor.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2006-2008 Richard Hughes <[email protected]>
- *
- * 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.
- */
-
-#include "config.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus.h>
-
-#include "egg-debug.h"
-#include "egg-dbus-monitor.h"
-
-static void egg_dbus_monitor_finalize (GObject *object);
-
-#define EGG_DBUS_MONITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorPrivate))
-
-struct EggDbusMonitorPrivate
-{
- gchar *service;
- DBusGProxy *proxy;
- DBusGConnection *connection;
- const gchar *unique_name;
-};
-
-enum {
- EGG_DBUS_MONITOR_CONNECTION_CHANGED,
- EGG_DBUS_MONITOR_CONNECTION_REPLACED,
- EGG_DBUS_MONITOR_LAST_SIGNAL
-};
-
-static guint signals [EGG_DBUS_MONITOR_LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (EggDbusMonitor, egg_dbus_monitor, G_TYPE_OBJECT)
-
-/**
- * egg_dbus_monitor_name_owner_changed_cb:
- **/
-static void
-egg_dbus_monitor_name_owner_changed_cb (DBusGProxy *proxy, const gchar *name,
- const gchar *prev, const gchar *new,
- EggDbusMonitor *monitor)
-{
- guint new_len;
- guint prev_len;
-
- g_return_if_fail (EGG_IS_DBUS_MONITOR (monitor));
- if (monitor->priv->proxy == NULL)
- return;
-
- /* not us */
- if (strcmp (name, monitor->priv->service) != 0)
- return;
-
- /* ITS4: ignore, not used for allocation */
- new_len = strlen (new);
- /* ITS4: ignore, not used for allocation */
- prev_len = strlen (prev);
-
- /* something --> nothing */
- if (prev_len != 0 && new_len == 0) {
- g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, FALSE);
- return;
- }
-
- /* nothing --> something */
- if (prev_len == 0 && new_len != 0) {
- g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, TRUE);
- return;
- }
-
- /* something --> something (we've replaced the old process) */
- if (prev_len != 0 && new_len != 0) {
- /* only send this to the prev client */
- if (strcmp (monitor->priv->unique_name, prev) == 0)
- g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_REPLACED], 0);
- return;
- }
-}
-
-/**
- * egg_dbus_monitor_assign:
- * @monitor: This class instance
- * @connection: The bus connection
- * @service: The EGG_DBUS_MONITOR service name
- * Return value: success
- *
- * Emits connection-changed(TRUE) if connection is alive - this means you
- * have to connect up the callback before this function is called.
- **/
-gboolean
-egg_dbus_monitor_assign (EggDbusMonitor *monitor, DBusGConnection *connection, const gchar *service)
-{
- GError *error = NULL;
- gboolean connected;
- DBusConnection *conn;
-
- g_return_val_if_fail (EGG_IS_DBUS_MONITOR (monitor), FALSE);
- g_return_val_if_fail (service != NULL, FALSE);
- g_return_val_if_fail (connection != NULL, FALSE);
-
- if (monitor->priv->proxy != NULL) {
- egg_warning ("already assigned!");
- return FALSE;
- }
-
- monitor->priv->service = g_strdup (service);
- monitor->priv->connection = connection;
- monitor->priv->proxy = dbus_g_proxy_new_for_name_owner (monitor->priv->connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS,
- &error);
- if (error != NULL) {
- egg_warning ("Cannot connect to DBUS: %s", error->message);
- g_error_free (error);
- return FALSE;
- }
- dbus_g_proxy_add_signal (monitor->priv->proxy, "NameOwnerChanged",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (monitor->priv->proxy, "NameOwnerChanged",
- G_CALLBACK (egg_dbus_monitor_name_owner_changed_cb),
- monitor, NULL);
-
- /* coldplug */
- connected = egg_dbus_monitor_is_connected (monitor);
- if (connected)
- g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, TRUE);
-
- /* save this for the replaced check */
- conn = dbus_g_connection_get_connection (monitor->priv->connection);
- monitor->priv->unique_name = dbus_bus_get_unique_name (conn);
- return TRUE;
-}
-
-/**
- * egg_dbus_monitor_is_connected:
- * @monitor: This class instance
- * Return value: if we are connected to a valid watch
- **/
-gboolean
-egg_dbus_monitor_is_connected (EggDbusMonitor *monitor)
-{
- DBusError error;
- DBusConnection *conn;
- gboolean ret;
- g_return_val_if_fail (EGG_IS_DBUS_MONITOR (monitor), FALSE);
-
- /* get raw connection */
- conn = dbus_g_connection_get_connection (monitor->priv->connection);
- dbus_error_init (&error);
- ret = dbus_bus_name_has_owner (conn, monitor->priv->service, &error);
- if (dbus_error_is_set (&error)) {
- egg_debug ("error: %s", error.message);
- dbus_error_free (&error);
- }
-
- return ret;
-}
-
-/**
- * egg_dbus_monitor_class_init:
- * @klass: The EggDbusMonitorClass
- **/
-static void
-egg_dbus_monitor_class_init (EggDbusMonitorClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = egg_dbus_monitor_finalize;
- g_type_class_add_private (klass, sizeof (EggDbusMonitorPrivate));
- signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED] =
- g_signal_new ("connection-changed",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggDbusMonitorClass, connection_changed),
- NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
- signals [EGG_DBUS_MONITOR_CONNECTION_REPLACED] =
- g_signal_new ("connection-replaced",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggDbusMonitorClass, connection_replaced),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-/**
- * egg_dbus_monitor_init:
- * @monitor: This class instance
- **/
-static void
-egg_dbus_monitor_init (EggDbusMonitor *monitor)
-{
- monitor->priv = EGG_DBUS_MONITOR_GET_PRIVATE (monitor);
- monitor->priv->service = NULL;
- monitor->priv->connection = NULL;
- monitor->priv->proxy = NULL;
-}
-
-/**
- * egg_dbus_monitor_finalize:
- * @object: The object to finalize
- **/
-static void
-egg_dbus_monitor_finalize (GObject *object)
-{
- EggDbusMonitor *monitor;
-
- g_return_if_fail (EGG_IS_DBUS_MONITOR (object));
-
- monitor = EGG_DBUS_MONITOR (object);
-
- g_return_if_fail (monitor->priv != NULL);
- if (monitor->priv->proxy != NULL)
- g_object_unref (monitor->priv->proxy);
-
- G_OBJECT_CLASS (egg_dbus_monitor_parent_class)->finalize (object);
-}
-
-/**
- * egg_dbus_monitor_new:
- *
- * Return value: a new EggDbusMonitor object.
- **/
-EggDbusMonitor *
-egg_dbus_monitor_new (void)
-{
- EggDbusMonitor *monitor;
- monitor = g_object_new (EGG_TYPE_DBUS_MONITOR, NULL);
- return EGG_DBUS_MONITOR (monitor);
-}
-
diff --git a/src/egg-dbus-monitor.h b/src/egg-dbus-monitor.h
deleted file mode 100644
index 9efa8b9..0000000
--- a/src/egg-dbus-monitor.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <[email protected]>
- *
- * 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 __EGG_DBUS_MONITOR_H
-#define __EGG_DBUS_MONITOR_H
-
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-
-G_BEGIN_DECLS
-
-#define EGG_TYPE_DBUS_MONITOR (egg_dbus_monitor_get_type ())
-#define EGG_DBUS_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitor))
-#define EGG_DBUS_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorClass))
-#define EGG_IS_DBUS_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGG_TYPE_DBUS_MONITOR))
-#define EGG_IS_DBUS_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGG_TYPE_DBUS_MONITOR))
-#define EGG_DBUS_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorClass))
-#define EGG_DBUS_MONITOR_ERROR (egg_dbus_monitor_error_quark ())
-#define EGG_DBUS_MONITOR_TYPE_ERROR (egg_dbus_monitor_error_get_type ())
-
-typedef struct EggDbusMonitorPrivate EggDbusMonitorPrivate;
-
-typedef struct
-{
- GObject parent;
- EggDbusMonitorPrivate *priv;
-} EggDbusMonitor;
-
-typedef struct
-{
- GObjectClass parent_class;
- void (* connection_changed) (EggDbusMonitor *watch,
- gboolean connected);
- void (* connection_replaced) (EggDbusMonitor *watch);
-} EggDbusMonitorClass;
-
-GType egg_dbus_monitor_get_type (void);
-EggDbusMonitor *egg_dbus_monitor_new (void);
-gboolean egg_dbus_monitor_assign (EggDbusMonitor *monitor,
- DBusGConnection *connection,
- const gchar *service);
-gboolean egg_dbus_monitor_is_connected (EggDbusMonitor *monitor);
-
-G_END_DECLS
-
-#endif /* __EGG_DBUS_MONITOR_H */
-
diff --git a/src/egg-dbus-proxy.c b/src/egg-dbus-proxy.c
deleted file mode 100644
index 8490682..0000000
--- a/src/egg-dbus-proxy.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2006-2008 Richard Hughes <[email protected]>
- *
- * 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.
- */
-
-#include "config.h"
-
-#include <string.h>
-#include <glib.h>
-#include <glib/gi18n.h>
-#include <dbus/dbus-glib.h>
-
-#include "egg-debug.h"
-#include "egg-dbus-monitor.h"
-#include "egg-dbus-proxy.h"
-
-static void egg_dbus_proxy_finalize (GObject *object);
-
-#define EGG_DBUS_PROXY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EGG_TYPE_DBUS_PROXY, EggDbusProxyPrivate))
-
-/* this is a managed proxy, i.e. a proxy that handles messagebus and DBUS service restarts. */
-struct EggDbusProxyPrivate
-{
- gchar *service;
- gchar *interface;
- gchar *path;
- DBusGProxy *proxy;
- EggDbusMonitor *monitor;
- gboolean assigned;
- DBusGConnection *connection;
- gulong monitor_callback_id;
-};
-
-enum {
- PROXY_STATUS,
- LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (EggDbusProxy, egg_dbus_proxy, G_TYPE_OBJECT)
-
-/**
- * egg_dbus_proxy_connect:
- * @proxy: This class instance
- * Return value: success
- **/
-static gboolean
-egg_dbus_proxy_connect (EggDbusProxy *proxy)
-{
- GError *error = NULL;
-
- g_return_val_if_fail (EGG_IS_DBUS_PROXY (proxy), FALSE);
-
- /* are already connected? */
- if (proxy->priv->proxy != NULL) {
- egg_debug ("already connected to %s", proxy->priv->service);
- return FALSE;
- }
-
- proxy->priv->proxy = dbus_g_proxy_new_for_name_owner (proxy->priv->connection,
- proxy->priv->service,
- proxy->priv->path,
- proxy->priv->interface,
- &error);
- /* check for any possible error */
- if (error) {
- egg_warning ("DBUS error: %s", error->message);
- g_error_free (error);
- proxy->priv->proxy = NULL;
- }
-
- /* shouldn't be, but make sure proxy valid */
- if (proxy->priv->proxy == NULL) {
- egg_debug ("proxy is NULL, maybe the daemon responsible "
- "for %s is not running?", proxy->priv->service);
- return FALSE;
- }
-
- g_signal_emit (proxy, signals [PROXY_STATUS], 0, TRUE);
-
- return TRUE;
-}
-
-/**
- * egg_dbus_proxy_disconnect:
- * @proxy: This class instance
- * Return value: success
- **/
-static gboolean
-egg_dbus_proxy_disconnect (EggDbusProxy *proxy)
-{
- g_return_val_if_fail (EGG_IS_DBUS_PROXY (proxy), FALSE);
-
- /* are already disconnected? */
- if (proxy->priv->proxy == NULL) {
- if (proxy->priv->service)
- egg_debug ("already disconnected from %s", proxy->priv->service);
- else
- egg_debug ("already disconnected.");
- return FALSE;
- }
-
- g_signal_emit (proxy, signals [PROXY_STATUS], 0, FALSE);
-
- g_object_unref (proxy->priv->proxy);
- proxy->priv->proxy = NULL;
-
- return TRUE;
-}
-
-/**
- * dbus_monitor_connection_cb:
- * @proxy: The dbus raw proxy
- * @status: The status of the service, where TRUE is connected
- * @screensaver: This class instance
- **/
-static void
-dbus_monitor_connection_cb (EggDbusMonitor *monitor, gboolean status, EggDbusProxy *proxy)
-{
- g_return_if_fail (EGG_IS_DBUS_PROXY (proxy));
- if (proxy->priv->assigned == FALSE)
- return;
- if (status)
- egg_dbus_proxy_connect (proxy);
- else
- egg_dbus_proxy_disconnect (proxy);
-}
-
-/**
- * egg_dbus_proxy_assign:
- * @proxy: This class instance
- * @connections: The bus connection
- * @service: The DBUS service name
- * @interface: The DBUS interface
- * @path: The DBUS path
- * Return value: The DBUS proxy, or NULL if we haven't connected yet.
- **/
-DBusGProxy *
-egg_dbus_proxy_assign (EggDbusProxy *proxy, DBusGConnection *connection,
- const gchar *service, const gchar *path, const gchar *interface)
-{
- g_return_val_if_fail (EGG_IS_DBUS_PROXY (proxy), NULL);
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (service != NULL, NULL);
- g_return_val_if_fail (interface != NULL, NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- if (proxy->priv->assigned) {
- egg_warning ("already assigned proxy!");
- return NULL;
- }
-
- proxy->priv->service = g_strdup (service);
- proxy->priv->interface = g_strdup (interface);
- proxy->priv->path = g_strdup (path);
- proxy->priv->connection = connection;
- proxy->priv->assigned = TRUE;
-
- /* We have to save the connection and remove the signal id later as
- instances of this object are likely to be registering with a
- singleton object many times */
- egg_dbus_monitor_assign (proxy->priv->monitor, connection, service);
-
- /* try to connect and return proxy (or NULL if invalid) */
- egg_dbus_proxy_connect (proxy);
-
- return proxy->priv->proxy;
-}
-
-/**
- * egg_dbus_proxy_get_proxy:
- * @proxy: This class instance
- * Return value: The DBUS proxy, or NULL if we are not connected
- **/
-DBusGProxy *
-egg_dbus_proxy_get_proxy (EggDbusProxy *proxy)
-{
- g_return_val_if_fail (EGG_IS_DBUS_PROXY (proxy), NULL);
- if (proxy->priv->assigned == FALSE)
- return NULL;
- return proxy->priv->proxy;
-}
-
-/**
- * egg_dbus_proxy_is_connected:
- * @proxy: This class instance
- * Return value: if we are connected to a valid proxy
- **/
-gboolean
-egg_dbus_proxy_is_connected (EggDbusProxy *proxy)
-{
- g_return_val_if_fail (EGG_IS_DBUS_PROXY (proxy), FALSE);
- if (proxy->priv->assigned == FALSE)
- return FALSE;
- if (proxy->priv->proxy == NULL)
- return FALSE;
- return TRUE;
-}
-
-/**
- * egg_dbus_proxy_class_init:
- * @proxy: This class instance
- **/
-static void
-egg_dbus_proxy_class_init (EggDbusProxyClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = egg_dbus_proxy_finalize;
- g_type_class_add_private (klass, sizeof (EggDbusProxyPrivate));
-
- signals [PROXY_STATUS] =
- g_signal_new ("proxy-status",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggDbusProxyClass, proxy_status),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-}
-
-/**
- * egg_dbus_proxy_init:
- * @egg_dbus_proxy: This class instance
- **/
-static void
-egg_dbus_proxy_init (EggDbusProxy *proxy)
-{
- proxy->priv = EGG_DBUS_PROXY_GET_PRIVATE (proxy);
-
- proxy->priv->connection = NULL;
- proxy->priv->proxy = NULL;
- proxy->priv->service = NULL;
- proxy->priv->interface = NULL;
- proxy->priv->path = NULL;
- proxy->priv->assigned = FALSE;
- proxy->priv->monitor = egg_dbus_monitor_new ();
- proxy->priv->monitor_callback_id =
- g_signal_connect (proxy->priv->monitor, "connection-changed",
- G_CALLBACK (dbus_monitor_connection_cb), proxy);
- proxy->priv->monitor_callback_id = 0;
-}
-
-/**
- * egg_dbus_proxy_finalize:
- * @object: This class instance
- **/
-static void
-egg_dbus_proxy_finalize (GObject *object)
-{
- EggDbusProxy *proxy;
- g_return_if_fail (object != NULL);
- g_return_if_fail (EGG_IS_DBUS_PROXY (object));
-
- proxy = EGG_DBUS_PROXY (object);
- proxy->priv = EGG_DBUS_PROXY_GET_PRIVATE (proxy);
-
- if (proxy->priv->monitor_callback_id != 0)
- g_signal_handler_disconnect (proxy->priv->monitor,
- proxy->priv->monitor_callback_id);
-
- egg_dbus_proxy_disconnect (proxy);
-
- if (proxy->priv->proxy != NULL)
- g_object_unref (proxy->priv->proxy);
- g_object_unref (proxy->priv->monitor);
- g_free (proxy->priv->service);
- g_free (proxy->priv->interface);
- g_free (proxy->priv->path);
-
- G_OBJECT_CLASS (egg_dbus_proxy_parent_class)->finalize (object);
-}
-
-/**
- * egg_dbus_proxy_new:
- * Return value: new class instance.
- **/
-EggDbusProxy *
-egg_dbus_proxy_new (void)
-{
- EggDbusProxy *proxy;
- proxy = g_object_new (EGG_TYPE_DBUS_PROXY, NULL);
- return EGG_DBUS_PROXY (proxy);
-}
-
diff --git a/src/egg-dbus-proxy.h b/src/egg-dbus-proxy.h
deleted file mode 100644
index 30a00cf..0000000
--- a/src/egg-dbus-proxy.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2006-2008 Richard Hughes <[email protected]>
- *
- * 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 __DBUSPROXY_H
-#define __DBUSPROXY_H
-
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-
-G_BEGIN_DECLS
-
-#define EGG_TYPE_DBUS_PROXY (egg_dbus_proxy_get_type ())
-#define EGG_DBUS_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGG_TYPE_DBUS_PROXY, EggDbusProxy))
-#define EGG_DBUS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EGG_TYPE_DBUS_PROXY, EggDbusProxyClass))
-#define EGG_IS_DBUS_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGG_TYPE_DBUS_PROXY))
-#define EGG_IS_DBUS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGG_TYPE_DBUS_PROXY))
-#define EGG_DBUS_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGG_TYPE_DBUS_PROXY, EggDbusProxyClass))
-
-typedef struct EggDbusProxyPrivate EggDbusProxyPrivate;
-
-typedef struct
-{
- GObject parent;
- EggDbusProxyPrivate *priv;
-} EggDbusProxy;
-
-typedef struct
-{
- GObjectClass parent_class;
- void (* proxy_status) (EggDbusProxy *proxy,
- gboolean status);
-} EggDbusProxyClass;
-
-GType egg_dbus_proxy_get_type (void);
-EggDbusProxy *egg_dbus_proxy_new (void);
-
-DBusGProxy *egg_dbus_proxy_assign (EggDbusProxy *dbus_proxy,
- DBusGConnection *connection,
- const gchar *service,
- const gchar *path,
- const gchar *interface);
-DBusGProxy *egg_dbus_proxy_get_proxy (EggDbusProxy *egg_dbus_proxy);
-gboolean egg_dbus_proxy_is_connected (EggDbusProxy *egg_dbus_proxy);
-
-G_END_DECLS
-
-#endif /* __DBUSPROXY_H */
-
diff --git a/src/egg-unique.c b/src/egg-unique.c
deleted file mode 100644
index 41a5182..0000000
--- a/src/egg-unique.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <[email protected]>
- *
- * 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.
- */
-
-#include "config.h"
-
-#include <string.h>
-#include <glib.h>
-#include <unique/unique.h>
-
-#include "egg-unique.h"
-#include "egg-debug.h"
-
-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
-{
- UniqueApp *uniqueapp;
-};
-
-enum {
- ACTIVATED,
- LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (EggUnique, egg_unique, G_TYPE_OBJECT)
-
-/**
- * egg_unique_message_cb:
- **/
-static void
-egg_unique_message_cb (UniqueApp *app, UniqueCommand command, UniqueMessageData *message_data, guint time_s, 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;
-}
-
-/**
- * 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);
-}
-
diff --git a/src/egg-unique.h b/src/egg-unique.h
deleted file mode 100644
index 7259135..0000000
--- a/src/egg-unique.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <[email protected]>
- *
- * 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 __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 */
-
diff --git a/src/gpm-backlight-helper.c b/src/gpm-backlight-helper.c
index 4350f16..682ddac 100644
--- a/src/gpm-backlight-helper.c
+++ b/src/gpm-backlight-helper.c
@@ -51,6 +51,7 @@ gcm_backlight_helper_get_best_backlight ()
/* available kernel interfaces in priority order */
static const gchar *backlight_interfaces[] = {
+ "gmux_backlight",
"nv_backlight",
"nvidia_backlight",
"intel_backlight",
diff --git a/src/gpm-backlight.c b/src/gpm-backlight.c
index d2938a4..0989640 100644
--- a/src/gpm-backlight.c
+++ b/src/gpm-backlight.c
@@ -21,7 +21,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
@@ -38,6 +38,7 @@
#endif /* HAVE_UNISTD_H */
#include <glib/gi18n.h>
+#include <gtk/gtk.h>
#include <dbus/dbus-glib.h>
#include <libupower-glib/upower.h>
@@ -51,7 +52,7 @@
#include "gpm-dpms.h"
#include "gpm-idle.h"
#include "gpm-marshal.h"
-#include "gpm-stock-icons.h"
+#include "gpm-icon-names.h"
#include "egg-console-kit.h"
#define GPM_BACKLIGHT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPM_TYPE_BACKLIGHT, GpmBacklightPrivate))
@@ -209,6 +210,9 @@ gpm_backlight_dialog_show (GpmBacklight *backlight)
GdkScreen *pointer_screen;
GdkRectangle geometry;
int monitor;
+ GdkDisplay *display;
+ GdkDeviceManager *device_manager;
+ GdkDevice *device;
/*
* get the window size
@@ -216,7 +220,7 @@ gpm_backlight_dialog_show (GpmBacklight *backlight)
* know its true size, yet, so we need to jump through hoops
*/
gtk_window_get_default_size (GTK_WINDOW (backlight->priv->popup), &orig_w, &orig_h);
- gtk_widget_size_request (backlight->priv->popup, &win_req);
+ gtk_widget_get_preferred_size (backlight->priv->popup, NULL, &win_req);
if (win_req.width > orig_w) {
orig_w = win_req.width;
@@ -226,11 +230,14 @@ gpm_backlight_dialog_show (GpmBacklight *backlight)
}
pointer_screen = NULL;
- gdk_display_get_pointer (gtk_widget_get_display (backlight->priv->popup),
+ display = gtk_widget_get_display (backlight->priv->popup);
+ device_manager = gdk_display_get_device_manager (display);
+ device = gdk_device_manager_get_client_pointer (device_manager);
+ gdk_device_get_position (device,
&pointer_screen,
&pointer_x,
- &pointer_y,
- NULL);
+ &pointer_y);
+
monitor = gdk_screen_get_monitor_at_point (pointer_screen,
pointer_x,
pointer_y);
@@ -380,7 +387,7 @@ gpm_settings_key_changed_cb (GSettings *settings, const gchar *key, GpmBacklight
"on-battery", &on_battery,
NULL);
- if (!on_battery && g_strcmp0 (key, GPM_SETTINGS_BRIGHTNESS_AC) == 0) {
+ if (g_strcmp0 (key, GPM_SETTINGS_BRIGHTNESS_AC) == 0) {
backlight->priv->master_percentage = g_settings_get_double (settings, key);
gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
@@ -433,6 +440,7 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli
GError *error = NULL;
guint percentage;
gboolean hw_changed;
+ gboolean on_battery;
egg_debug ("Button press event type=%s", type);
if (g_strcmp0 (type, GPM_BUTTON_BRIGHT_UP) == 0) {
@@ -448,6 +456,13 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli
gpm_backlight_dialog_show (backlight);
/* save the new percentage */
backlight->priv->master_percentage = percentage;
+ /* if using AC power supply, save the new brightness settings */
+ g_object_get (backlight->priv->client, "on-battery", &on_battery, NULL);
+ if (!on_battery) {
+ egg_debug ("saving brightness for ac supply: %i", percentage);
+ g_settings_set_double (backlight->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC,
+ percentage*1.0);
+ }
}
/* we emit a signal for the brightness applet */
if (ret && hw_changed) {
@@ -467,6 +482,13 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli
gpm_backlight_dialog_show (backlight);
/* save the new percentage */
backlight->priv->master_percentage = percentage;
+ /* if using AC power supply, save the new brightness settings */
+ g_object_get (backlight->priv->client, "on-battery", &on_battery, NULL);
+ if (!on_battery) {
+ egg_debug ("saving brightness for ac supply: %i", percentage);
+ g_settings_set_double (backlight->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC,
+ percentage*1.0);
+ }
}
/* we emit a signal for the brightness applet */
if (ret && hw_changed) {
@@ -567,7 +589,7 @@ idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight)
if (mode == GPM_IDLE_MODE_NORMAL) {
/* sync lcd brightness */
gpm_backlight_notify_system_idle_changed (backlight, FALSE);
- gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, FALSE);
+ gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
/* ensure backlight is on */
ret = gpm_dpms_set_mode (backlight->priv->dpms, GPM_DPMS_MODE_ON, &error);
@@ -580,7 +602,7 @@ idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight)
/* sync lcd brightness */
gpm_backlight_notify_system_idle_changed (backlight, TRUE);
- gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, FALSE);
+ gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
/* ensure backlight is on */
ret = gpm_dpms_set_mode (backlight->priv->dpms, GPM_DPMS_MODE_ON, &error);
@@ -593,7 +615,7 @@ idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight)
/* sync lcd brightness */
gpm_backlight_notify_system_idle_changed (backlight, TRUE);
- gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, FALSE);
+ gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
/* get the DPMS state we're supposed to use on the power state */
g_object_get (backlight->priv->client,
diff --git a/src/gpm-brightness.c b/src/gpm-brightness.c
index fcf2eb6..8987c7f 100644
--- a/src/gpm-brightness.c
+++ b/src/gpm-brightness.c
@@ -20,7 +20,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
@@ -61,9 +61,6 @@ struct GpmBrightnessPrivate
GdkWindow *root_window;
guint shared_value;
gboolean has_extension;
-#ifdef HAVE_XRANDR_13
- gboolean has_randr13;
-#endif
gboolean hw_changed;
/* A cache of XRRScreenResources is used as XRRGetScreenResources is expensive */
GPtrArray *resources;
@@ -269,7 +266,7 @@ gpm_brightness_setup_display (GpmBrightness *brightness)
egg_debug ("RandR extension missing");
return FALSE;
}
- if (major < 1 || (major == 1 && minor < 2)) {
+ if (major < 1 || (major == 1 && minor < 3)) {
egg_debug ("RandR version %d.%d too old", major, minor);
return FALSE;
}
@@ -286,34 +283,6 @@ gpm_brightness_setup_display (GpmBrightness *brightness)
return TRUE;
}
-#ifdef HAVE_XRANDR_13
-/**
- * gpm_brightness_setup_version: Check whether xserver really supports xrandr-1.3 features.
- **/
-static gboolean
-gpm_brightness_setup_version (GpmBrightness *brightness)
-{
- gint major, minor;
-
- g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
-
- /* get the display */
- brightness->priv->dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default());
- if (!brightness->priv->dpy) {
- egg_error ("Cannot open display");
- return FALSE;
- }
- if (!XRRQueryVersion (brightness->priv->dpy, &major, &minor)) {
- return FALSE;
- }
- if (major == 1 && minor < 3) {
- egg_debug ("RandR version %d.%d does not support XRRGetScreenResourcesCurrent", major, minor);
- return FALSE;
- }
- return TRUE;
-}
-#endif
-
/**
* gpm_brightness_output_get_limits:
**/
@@ -881,17 +850,12 @@ gpm_brightness_update_cache (GpmBrightness *brightness)
}
root = RootWindow (brightness->priv->dpy, screen);
- /* XRRGetScreenResourcesCurrent is less expensive than
- XRRGetScreenResources, however it is available only
- in RandR 1.3 or higher and of course xserver needs
- to support it.
- */
-#ifdef HAVE_XRANDR_13
- if (brightness->priv->has_randr13)
- resource = XRRGetScreenResourcesCurrent (brightness->priv->dpy, root);
- else
-#endif
- resource = XRRGetScreenResources (brightness->priv->dpy, root);
+
+ gdk_error_trap_push ();
+ resource = XRRGetScreenResourcesCurrent (brightness->priv->dpy, root);
+ if (gdk_error_trap_pop () || resource == NULL) {
+ egg_warning ("failed to XRRGetScreenResourcesCurrent");
+ }
if (resource != NULL) {
egg_debug ("adding resource %p", resource);
@@ -978,9 +942,6 @@ gpm_brightness_init (GpmBrightness *brightness)
/* can we do this */
brightness->priv->has_extension = gpm_brightness_setup_display (brightness);
-#ifdef HAVE_XRANDR_13
- brightness->priv->has_randr13 = gpm_brightness_setup_version (brightness);
-#endif
if (brightness->priv->has_extension == FALSE)
egg_debug ("no XRANDR extension");
diff --git a/src/gpm-button.c b/src/gpm-button.c
index b331cf6..cbf7f45 100644
--- a/src/gpm-button.c
+++ b/src/gpm-button.c
@@ -171,7 +171,7 @@ gpm_button_grab_keystring (GpmButton *button, guint64 keycode)
/* we are not processing the error */
gdk_flush ();
- gdk_error_trap_pop ();
+ gdk_error_trap_pop_ignored ();
egg_debug ("Grabbed modmask=%x, keycode=%li", modmask, (long int) keycode);
return TRUE;
diff --git a/src/gpm-common.c b/src/gpm-common.c
index f71aada..c0c3c94 100644
--- a/src/gpm-common.c
+++ b/src/gpm-common.c
@@ -91,6 +91,9 @@ gpm_get_timestring (guint time_secs)
guint
gpm_discrete_from_percent (guint percentage, guint levels)
{
+ /* for levels < 10 min value is 0 */
+ gint factor;
+ factor = levels < 10 ? 0 : 1;
/* check we are in range */
if (percentage > 100)
return levels;
@@ -98,7 +101,7 @@ gpm_discrete_from_percent (guint percentage, guint levels)
g_warning ("levels is 0!");
return 0;
}
- return (guint) ((((gfloat) percentage * (gfloat) (levels - 1)) / 100.0f) + 0.5f);
+ return (guint) ((((gfloat) percentage * (gfloat) (levels - factor)) / 100.0f) + 0.5f);
}
/**
@@ -113,6 +116,9 @@ gpm_discrete_from_percent (guint percentage, guint levels)
guint
gpm_discrete_to_percent (guint discrete, guint levels)
{
+ /* for levels < 10 min value is 0 */
+ gint factor;
+ factor = levels < 10 ? 0 : 1;
/* check we are in range */
if (discrete > levels)
return 100;
@@ -120,7 +126,7 @@ gpm_discrete_to_percent (guint discrete, guint levels)
g_warning ("levels is 0!");
return 0;
}
- return (guint) (((gfloat) discrete * (100.0f / (gfloat) (levels - 1))) + 0.5f);
+ return (guint) (((gfloat) discrete * (100.0f / (gfloat) (levels - factor))) + 0.5f);
}
diff --git a/src/gpm-control.c b/src/gpm-control.c
index 4091e0c..c334fb5 100644
--- a/src/gpm-control.c
+++ b/src/gpm-control.c
@@ -20,7 +20,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
diff --git a/src/gpm-dpms.c b/src/gpm-dpms.c
index 8eaf704..bb1e718 100644
--- a/src/gpm-dpms.c
+++ b/src/gpm-dpms.c
@@ -301,6 +301,7 @@ gpm_dpms_init (GpmDpms *dpms)
dpms->priv->display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default());
dpms->priv->dpms_capable = DPMSCapable (dpms->priv->display);
dpms->priv->timer_id = g_timeout_add_seconds (GPM_DPMS_POLL_TIME, (GSourceFunc)gpm_dpms_poll_mode_cb, dpms);
+ g_source_set_name_by_id (dpms->priv->timer_id, "[GpmDpms] poll");
/* ensure we clear the default timeouts (Standby: 1200s, Suspend: 1800s, Off: 2400s) */
gpm_dpms_clear_timeouts (dpms);
@@ -321,8 +322,10 @@ gpm_dpms_finalize (GObject *object)
g_return_if_fail (dpms->priv != NULL);
- if (dpms->priv->timer_id != 0)
+ if (dpms->priv->timer_id != 0) {
g_source_remove (dpms->priv->timer_id);
+ dpms->priv->timer_id = 0;
+ }
G_OBJECT_CLASS (gpm_dpms_parent_class)->finalize (object);
}
diff --git a/src/gpm-engine.c b/src/gpm-engine.c
index f1ae198..022916e 100644
--- a/src/gpm-engine.c
+++ b/src/gpm-engine.c
@@ -32,7 +32,7 @@
#include "gpm-upower.h"
#include "gpm-marshal.h"
#include "gpm-engine.h"
-#include "gpm-stock-icons.h"
+#include "gpm-icon-names.h"
#include "gpm-phone.h"
static void gpm_engine_finalize (GObject *object);
@@ -72,6 +72,7 @@ enum {
CHARGE_ACTION,
DISCHARGING,
LOW_CAPACITY,
+ DEVICES_CHANGED,
LAST_SIGNAL
};
@@ -443,7 +444,7 @@ gpm_engine_get_icon (GpmEngine *engine)
/* we fallback to the ac_adapter icon */
egg_debug ("Using fallback");
- return g_strdup (GPM_STOCK_AC_ADAPTER);
+ return g_strdup (GPM_ICON_AC_ADAPTER);
}
/**
@@ -536,6 +537,8 @@ gpm_engine_recalculate_state (GpmEngine *engine)
gpm_engine_recalculate_state_icon (engine);
gpm_engine_recalculate_state_summary (engine);
+
+ g_signal_emit (engine, signals [DEVICES_CHANGED], 0);
}
/**
@@ -608,8 +611,14 @@ gpm_engine_get_composite_device (GpmEngine *engine, UpDevice *original_device)
GPtrArray *array;
UpDevice *device;
UpDeviceKind kind;
+ UpDeviceKind original_kind;
guint i;
+ /* get the type of the original device */
+ g_object_get (original_device,
+ "kind", &original_kind,
+ NULL);
+
/* find out how many batteries in the system */
array = engine->priv->array;
for (i=0;i<array->len;i++) {
@@ -617,7 +626,7 @@ gpm_engine_get_composite_device (GpmEngine *engine, UpDevice *original_device)
g_object_get (device,
"kind", &kind,
NULL);
- if (kind == UP_DEVICE_KIND_BATTERY)
+ if (kind == original_kind)
battery_devices++;
}
@@ -672,12 +681,18 @@ gpm_engine_update_composite_device (GpmEngine *engine, UpDevice *original_device
UpDevice *device;
UpDeviceState state;
UpDeviceKind kind;
+ UpDeviceKind original_kind;
gboolean debug;
gchar *text;
/* are we printing to console? */
debug = egg_debug_enabled ();
+ /* get the type of the original device */
+ g_object_get (original_device,
+ "kind", &original_kind,
+ NULL);
+
/* update the composite device */
array = engine->priv->array;
for (i=0;i<array->len;i++) {
@@ -689,7 +704,7 @@ gpm_engine_update_composite_device (GpmEngine *engine, UpDevice *original_device
"energy-full", &energy_full,
"energy-rate", &energy_rate,
NULL);
- if (kind != UP_DEVICE_KIND_BATTERY)
+ if (kind != original_kind)
continue;
if (debug) {
@@ -997,6 +1012,50 @@ gpm_engine_get_devices (GpmEngine *engine)
}
/**
+ * gpm_engine_get_primary_device:
+ *
+ * Return value: the #UpDevice, free with g_object_unref()
+ **/
+UpDevice *
+gpm_engine_get_primary_device (GpmEngine *engine)
+{
+ guint i;
+ UpDevice *device = NULL;
+ UpDevice *device_tmp;
+ UpDeviceKind kind;
+ UpDeviceState state;
+ gboolean is_present;
+
+ for (i=0; i<engine->priv->array->len; i++) {
+ device_tmp = g_ptr_array_index (engine->priv->array, i);
+
+ /* get device properties */
+ g_object_get (device_tmp,
+ "kind", &kind,
+ "state", &state,
+ "is-present", &is_present,
+ NULL);
+
+ /* not present */
+ if (!is_present)
+ continue;
+
+ /* not discharging */
+ if (state != UP_DEVICE_STATE_DISCHARGING)
+ continue;
+
+ /* not battery */
+ if (kind != UP_DEVICE_KIND_BATTERY)
+ continue;
+
+ /* use composite device to cope with multiple batteries */
+ device = g_object_ref (gpm_engine_get_composite_device (engine, device_tmp));
+ break;
+ }
+ return device;
+}
+
+/**
* phone_device_added_cb:
**/
static void
@@ -1100,6 +1159,7 @@ gpm_engine_init (GpmEngine *engine)
GPtrArray *array = NULL;
guint i;
#endif
+ guint idle_id;
engine->priv = GPM_ENGINE_GET_PRIVATE (engine);
engine->priv->array = g_ptr_array_new_with_free_func (g_object_unref);
@@ -1164,7 +1224,8 @@ gpm_engine_init (GpmEngine *engine)
else
egg_debug ("Using percentage notification policy");
- g_idle_add ((GSourceFunc) gpm_engine_coldplug_idle_cb, engine);
+ idle_id = g_idle_add ((GSourceFunc) gpm_engine_coldplug_idle_cb, engine);
+ g_source_set_name_by_id (idle_id, "[GpmEngine] coldplug");
}
/**
@@ -1234,6 +1295,13 @@ gpm_engine_class_init (GpmEngineClass *klass)
G_STRUCT_OFFSET (GpmEngineClass, charge_critical),
NULL, NULL, g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
+ signals [DEVICES_CHANGED] =
+ g_signal_new ("devices-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GpmEngineClass, devices_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
/**
diff --git a/src/gpm-engine.h b/src/gpm-engine.h
index 43f8956..8dbefbc 100644
--- a/src/gpm-engine.h
+++ b/src/gpm-engine.h
@@ -61,6 +61,7 @@ typedef struct
UpDevice *device);
void (* discharging) (GpmEngine *engine,
UpDevice *device);
+ void (* devices_changed) (GpmEngine *engine);
} GpmEngineClass;
GType gpm_engine_get_type (void);
@@ -68,6 +69,7 @@ GpmEngine *gpm_engine_new (void);
gchar *gpm_engine_get_icon (GpmEngine *engine);
gchar *gpm_engine_get_summary (GpmEngine *engine);
GPtrArray *gpm_engine_get_devices (GpmEngine *engine);
+UpDevice *gpm_engine_get_primary_device (GpmEngine *engine);
G_END_DECLS
diff --git a/src/gpm-graph-widget.c b/src/gpm-graph-widget.c
index 1f6f9ed..a8acf46 100644
--- a/src/gpm-graph-widget.c
+++ b/src/gpm-graph-widget.c
@@ -24,6 +24,7 @@
#include <pango/pangocairo.h>
#include <glib/gi18n.h>
#include <stdlib.h>
+#include <math.h>
#include "gpm-common.h"
#include "gpm-point-obj.h"
@@ -33,10 +34,6 @@
#include "egg-color.h"
#include "egg-precision.h"
-#if GTK_CHECK_VERSION (3, 0, 0)
-#include <math.h>
-#endif
-
G_DEFINE_TYPE (GpmGraphWidget, gpm_graph_widget, GTK_TYPE_DRAWING_AREA);
#define GPM_GRAPH_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPM_TYPE_GRAPH_WIDGET, GpmGraphWidgetPrivate))
#define GPM_GRAPH_WIDGET_FONT "Sans 8"
@@ -73,11 +70,7 @@ struct GpmGraphWidgetPrivate
GPtrArray *plot_list;
};
-#if GTK_CHECK_VERSION (3, 0, 0)
static gboolean gpm_graph_widget_draw (GtkWidget *graph, cairo_t *cr);
-#else
-static gboolean gpm_graph_widget_expose (GtkWidget *graph, GdkEventExpose *event);
-#endif
static void gpm_graph_widget_finalize (GObject *object);
enum
@@ -241,11 +234,7 @@ gpm_graph_widget_class_init (GpmGraphWidgetClass *class)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GObjectClass *object_class = G_OBJECT_CLASS (class);
-#if GTK_CHECK_VERSION (3, 0, 0)
widget_class->draw = gpm_graph_widget_draw;
-#else
- widget_class->expose_event = gpm_graph_widget_expose;
-#endif
object_class->get_property = up_graph_get_property;
object_class->set_property = up_graph_set_property;
object_class->finalize = gpm_graph_widget_finalize;
@@ -1076,14 +1065,14 @@ gpm_graph_widget_legend_calculate_size (GpmGraphWidget *graph, cairo_t *cr,
}
/**
- * gpm_graph_widget_draw_graph:
+ * gpm_graph_widget_draw:
* @graph: This class instance
- * @cr: Cairo drawing context
+ * @event: The expose event
*
- * Draw the complete graph, with the box, the grid, the labels and the line.
+ * Just repaint the entire graph widget on expose.
**/
-static void
-gpm_graph_widget_draw_graph (GtkWidget *graph_widget, cairo_t *cr)
+static gboolean
+gpm_graph_widget_draw (GtkWidget *widget, cairo_t *cr)
{
GtkAllocation allocation;
gint legend_x = 0;
@@ -1093,9 +1082,9 @@ gpm_graph_widget_draw_graph (GtkWidget *graph_widget, cairo_t *cr)
gfloat data_x;
gfloat data_y;
- GpmGraphWidget *graph = (GpmGraphWidget*) graph_widget;
- g_return_if_fail (graph != NULL);
- g_return_if_fail (GPM_IS_GRAPH_WIDGET (graph));
+ GpmGraphWidget *graph = (GpmGraphWidget*) widget;
+ g_return_val_if_fail (graph != NULL, FALSE);
+ g_return_val_if_fail (GPM_IS_GRAPH_WIDGET (graph), FALSE);
gpm_graph_widget_legend_calculate_size (graph, cr, &legend_width, &legend_height);
cairo_save (cr);
@@ -1109,7 +1098,7 @@ gpm_graph_widget_draw_graph (GtkWidget *graph_widget, cairo_t *cr)
graph->priv->box_x = gpm_graph_widget_get_y_label_max_width (graph, cr) + 10;
graph->priv->box_y = 5;
- gtk_widget_get_allocation (graph_widget, &allocation);
+ gtk_widget_get_allocation (widget, &allocation);
graph->priv->box_height = allocation.height - (20 + graph->priv->box_y);
/* make size adjustment for legend */
@@ -1142,51 +1131,6 @@ gpm_graph_widget_draw_graph (GtkWidget *graph_widget, cairo_t *cr)
gpm_graph_widget_draw_legend (graph, legend_x, legend_y, legend_width, legend_height);
cairo_restore (cr);
-}
-
-/**
- * gpm_graph_widget_expose:
- * @graph: This class instance
- * @event: The expose event
- *
- * Just repaint the entire graph widget on expose.
- **/
-static gboolean
-#if GTK_CHECK_VERSION (3, 0, 0)
-gpm_graph_widget_draw (GtkWidget *graph, cairo_t *cr)
-#else
-gpm_graph_widget_expose (GtkWidget *graph, GdkEventExpose *event)
-#endif
-{
-#if GTK_CHECK_VERSION (3, 0, 0)
- GdkRectangle area;
- gdouble x1, y1, x2, y2;
-
- cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
- area.x = floor (x1);
- area.y = floor (y1);
- area.width = ceil (x2) - area.x;
- area.height = ceil (y2) - area.y;
- cairo_rectangle (cr,
- area.x, area.y,
- area.width, area.height);
-#else
- cairo_t *cr;
-
- /* get a cairo_t */
- cr = gdk_cairo_create (gtk_widget_get_window (graph));
- cairo_rectangle (cr,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
-#endif
- cairo_clip (cr);
- ((GpmGraphWidget *)graph)->priv->cr = cr;
-
- gpm_graph_widget_draw_graph (graph, cr);
-
-#if !GTK_CHECK_VERSION (3, 0, 0)
- cairo_destroy (cr);
-#endif
return FALSE;
}
diff --git a/src/gpm-stock-icons.h b/src/gpm-icon-names.h
index 395d612..004e70e 100644
--- a/src/gpm-stock-icons.h
+++ b/src/gpm-icon-names.h
@@ -21,21 +21,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef __GPM_STOCK_ICONS_H
-#define __GPM_STOCK_ICONS_H
+#ifndef __GPM_ICON_NAMES_H
+#define __GPM_ICON_NAMES_H
G_BEGIN_DECLS
-#define GPM_STOCK_APP_ICON "mate-power-manager"
-#define GPM_STOCK_AC_ADAPTER "gpm-ac-adapter"
-#define GPM_STOCK_BATTERY_CHARGED "gpm-primary-charged"
-#define GPM_STOCK_HIBERNATE "gpm-hibernate"
-#define GPM_STOCK_SUSPEND "gpm-suspend"
-#define GPM_STOCK_STATISTICS "mate-power-statistics"
-#define GPM_STOCK_BRIGHTNESS_LCD "gpm-brightness-lcd"
-#define GPM_STOCK_BRIGHTNESS_KBD "gpm-brightness-kbd"
-#define GPM_STOCK_INHIBIT "gpm-inhibit"
+#define GPM_ICON_APP_ICON "mate-power-manager"
+#define GPM_ICON_AC_ADAPTER "gpm-ac-adapter"
+#define GPM_ICON_BATTERY_CHARGED "gpm-primary-charged"
+#define GPM_ICON_SUSPEND "gpm-suspend"
+#define GPM_ICON_HIBERNATE "gpm-hibernate"
+#define GPM_ICON_STATISTICS "mate-power-statistics"
+#define GPM_ICON_BRIGHTNESS_LCD "gpm-brightness-lcd"
+#define GPM_ICON_BRIGHTNESS_KBD "gpm-brightness-kbd"
+#define GPM_ICON_INHIBIT "gpm-inhibit"
G_END_DECLS
-#endif /* __GPM_STOCK_ICONS_H */
+#endif /* __GPM_ICON_NAMES_H */
diff --git a/src/gpm-idle.c b/src/gpm-idle.c
index a7132fa..d2e92e0 100644
--- a/src/gpm-idle.c
+++ b/src/gpm-idle.c
@@ -36,7 +36,6 @@
#include <glib.h>
#include <glib/gi18n.h>
-#include <gtk/gtk.h>
#include "egg-debug.h"
#include "egg-idletime.h"
@@ -227,7 +226,9 @@ gpm_idle_evaluate (GpmIdle *idle)
if (idle->priv->timeout_blank_id == 0 &&
idle->priv->timeout_blank != 0) {
egg_debug ("setting up blank callback for %is", idle->priv->timeout_blank);
- idle->priv->timeout_blank_id = g_timeout_add_seconds (idle->priv->timeout_blank, (GSourceFunc) gpm_idle_blank_cb, idle);
+ idle->priv->timeout_blank_id = g_timeout_add_seconds (idle->priv->timeout_blank,
+ (GSourceFunc) gpm_idle_blank_cb, idle);
+ g_source_set_name_by_id (idle->priv->timeout_blank_id, "[GpmIdle] blank");
}
/* are we inhibited from sleeping */
@@ -242,7 +243,9 @@ gpm_idle_evaluate (GpmIdle *idle)
if (idle->priv->timeout_sleep_id == 0 &&
idle->priv->timeout_sleep != 0) {
egg_debug ("setting up sleep callback %is", idle->priv->timeout_sleep);
- idle->priv->timeout_sleep_id = g_timeout_add_seconds (idle->priv->timeout_sleep, (GSourceFunc) gpm_idle_sleep_cb, idle);
+ idle->priv->timeout_sleep_id = g_timeout_add_seconds (idle->priv->timeout_sleep,
+ (GSourceFunc) gpm_idle_sleep_cb, idle);
+ g_source_set_name_by_id (idle->priv->timeout_sleep_id, "[GpmIdle] sleep");
}
}
out:
@@ -411,10 +414,15 @@ gpm_idle_finalize (GObject *object)
g_return_if_fail (idle->priv != NULL);
- if (idle->priv->timeout_blank_id != 0)
+ if (idle->priv->timeout_blank_id != 0) {
g_source_remove (idle->priv->timeout_blank_id);
- if (idle->priv->timeout_sleep_id != 0)
+ idle->priv->timeout_blank_id = 0;
+ }
+
+ if (idle->priv->timeout_sleep_id != 0) {
g_source_remove (idle->priv->timeout_sleep_id);
+ idle->priv->timeout_sleep_id = 0;
+ }
g_object_unref (idle->priv->load);
g_object_unref (idle->priv->session);
diff --git a/src/gpm-kbd-backlight.c b/src/gpm-kbd-backlight.c
index b3091ac..ae8e0fa 100644
--- a/src/gpm-kbd-backlight.c
+++ b/src/gpm-kbd-backlight.c
@@ -22,6 +22,7 @@
#include <gio/gio.h>
#include <glib.h>
#include <libupower-glib/upower.h>
+#include <gtk/gtk.h>
#include "egg-debug.h"
#include "gpm-button.h"
@@ -121,6 +122,11 @@ gpm_kbd_backlight_set (GpmKbdBacklight *backlight,
goal = gpm_discrete_from_percent (percentage, backlight->priv->max_brightness);
scale = percentage > backlight->priv->brightness_percent ? 1 : -1;
+ /* if percentage change too small force next value */
+ if (goal == backlight->priv->brightness) {
+ goal += percentage == backlight->priv->brightness_percent ? 0 : scale;
+ }
+
/* step loop down by 1 for a dimming effect */
while (backlight->priv->brightness != goal) {
backlight->priv->brightness += scale;
@@ -180,6 +186,9 @@ gpm_kbd_backlight_dialog_show (GpmKbdBacklight *backlight)
GdkScreen *pointer_screen;
GdkRectangle geometry;
int monitor;
+ GdkDisplay *display;
+ GdkDeviceManager *device_manager;
+ GdkDevice *device;
/*
* get the window size
@@ -187,7 +196,7 @@ gpm_kbd_backlight_dialog_show (GpmKbdBacklight *backlight)
* know its true size, yet, so we need to jump through hoops
*/
gtk_window_get_default_size (GTK_WINDOW (backlight->priv->popup), &orig_w, &orig_h);
- gtk_widget_size_request (backlight->priv->popup, &win_req);
+ gtk_widget_get_preferred_size (backlight->priv->popup, NULL, &win_req);
if (win_req.width > orig_w) {
orig_w = win_req.width;
@@ -197,11 +206,14 @@ gpm_kbd_backlight_dialog_show (GpmKbdBacklight *backlight)
}
pointer_screen = NULL;
- gdk_display_get_pointer (gtk_widget_get_display (backlight->priv->popup),
+ display = gtk_widget_get_display (backlight->priv->popup);
+ device_manager = gdk_display_get_device_manager (display);
+ device = gdk_device_manager_get_client_pointer (device_manager);
+ gdk_device_get_position (device,
&pointer_screen,
&pointer_x,
- &pointer_y,
- NULL);
+ &pointer_y);
+
monitor = gdk_screen_get_monitor_at_point (pointer_screen,
pointer_x,
pointer_y);
diff --git a/src/gpm-main.c b/src/gpm-main.c
index 30cf481..3244e00 100644
--- a/src/gpm-main.c
+++ b/src/gpm-main.c
@@ -36,7 +36,7 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include "gpm-stock-icons.h"
+#include "gpm-icon-names.h"
#include "gpm-common.h"
#include "gpm-manager.h"
#include "gpm-session.h"
@@ -165,6 +165,7 @@ main (int argc, char *argv[])
GError *error = NULL;
GOptionContext *context;
gint ret;
+ guint timer_id;
const GOptionEntry options[] = {
{ "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose,
@@ -264,7 +265,8 @@ main (int argc, char *argv[])
/* Only timeout and close the mainloop if we have specified it
* on the command line */
if (timed_exit) {
- g_timeout_add_seconds (20, (GSourceFunc) timed_exit_cb, loop);
+ timer_id = g_timeout_add_seconds (20, (GSourceFunc) timed_exit_cb, loop);
+ g_source_set_name_by_id (timer_id, "[GpmMain] timed-exit");
}
if (immediate_exit == FALSE) {
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index f6c498e..ce2b695 100644
--- a/src/gpm-manager.c
+++ b/src/gpm-manager.c
@@ -56,7 +56,7 @@
#include "gpm-backlight.h"
#include "gpm-kbd-backlight.h"
#include "gpm-session.h"
-#include "gpm-stock-icons.h"
+#include "gpm-icon-names.h"
#include "gpm-tray-icon.h"
#include "gpm-engine.h"
#include "gpm-upower.h"
@@ -239,6 +239,8 @@ gpm_manager_play_loop_start (GpmManager *manager, GpmManagerSound action, gboole
(GSourceFunc) gpm_manager_play_loop_timeout_cb,
manager);
+ g_source_set_name_by_id (manager->priv->critical_alert_timeout_id, "[GpmManager] play-loop");
+
/* play the sound, using sounds from the naming spec */
context = ca_gtk_context_get_for_screen (gdk_screen_get_default ());
retval = ca_context_play (context, 0,
@@ -579,13 +581,13 @@ gpm_manager_sleep_failure (GpmManager *manager, gboolean is_suspend, const gchar
g_string_append (string, _("Computer failed to suspend."));
/* TRANSLATORS: title text */
title = _("Failed to suspend");
- icon = GPM_STOCK_SUSPEND;
+ icon = GPM_ICON_SUSPEND;
} else {
/* TRANSLATORS: message text */
g_string_append (string, _("Computer failed to hibernate."));
/* TRANSLATORS: title text */
title = _("Failed to hibernate");
- icon = GPM_STOCK_HIBERNATE;
+ icon = GPM_ICON_HIBERNATE;
}
/* TRANSLATORS: message text */
@@ -926,7 +928,7 @@ gpm_manager_button_pressed_cb (GpmButton *button, const gchar *type, GpmManager
_("Power Information"),
message,
GPM_MANAGER_NOTIFY_TIMEOUT_LONG,
- GTK_STOCK_DIALOG_INFO,
+ "dialog-information",
NOTIFY_URGENCY_NORMAL);
g_free (message);
}
@@ -1116,7 +1118,7 @@ gpm_manager_engine_low_capacity_cb (GpmEngine *engine, UpDevice *device, GpmMana
message = g_strdup_printf (_("Battery has a very low capacity (%1.1f%%), "
"which means that it may be old or broken."), capacity);
gpm_manager_notify (manager, &manager->priv->notification_general, title, message, GPM_MANAGER_NOTIFY_TIMEOUT_SHORT,
- GTK_STOCK_DIALOG_INFO, NOTIFY_URGENCY_LOW);
+ "dialog-information", NOTIFY_URGENCY_LOW);
out:
g_free (message);
}
@@ -1165,7 +1167,7 @@ gpm_manager_engine_fully_charged_cb (GpmEngine *engine, UpDevice *device, GpmMan
title = ngettext ("Battery Charged", "Batteries Charged", plural);
gpm_manager_notify (manager, &manager->priv->notification_fully_charged,
title, NULL, GPM_MANAGER_NOTIFY_TIMEOUT_SHORT,
- GTK_STOCK_DIALOG_INFO, NOTIFY_URGENCY_LOW);
+ "dialog-information", NOTIFY_URGENCY_LOW);
}
out:
g_free (native_path);
@@ -1204,7 +1206,7 @@ gpm_manager_engine_discharging_cb (GpmEngine *engine, UpDevice *device, GpmManag
/* only show text if there is a valid time */
if (time_to_empty > 0)
remaining_text = gpm_get_timestring (time_to_empty);
- kind_desc = gpm_device_kind_to_localised_text (kind, 1);
+ kind_desc = gpm_device_kind_to_localised_string (kind, 1);
if (kind == UP_DEVICE_KIND_BATTERY) {
/* TRANSLATORS: laptop battery is now discharging */
@@ -1560,6 +1562,7 @@ gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmMan
gchar *icon = NULL;
UpDeviceKind kind;
GpmActionPolicy policy;
+ guint timer_id;
/* get device properties */
g_object_get (device,
@@ -1608,7 +1611,8 @@ gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmMan
}
/* wait 20 seconds for user-panic */
- g_timeout_add_seconds (20, (GSourceFunc) manager_critical_action_do, manager);
+ timer_id = g_timeout_add_seconds (20, (GSourceFunc) manager_critical_action_do, manager);
+ g_source_set_name_by_id (timer_id, "[GpmManager] battery critical-action");
} else if (kind == UP_DEVICE_KIND_UPS) {
/* TRANSLATORS: UPS is really, really, low */
@@ -1636,7 +1640,8 @@ gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmMan
}
/* wait 20 seconds for user-panic */
- g_timeout_add_seconds (20, (GSourceFunc) manager_critical_action_do, manager);
+ timer_id = g_timeout_add_seconds (20, (GSourceFunc) manager_critical_action_do, manager);
+ g_source_set_name_by_id (timer_id, "[GpmManager] ups critical-action");
}
@@ -1708,8 +1713,10 @@ gpm_manager_reset_just_resumed_cb (gpointer user_data)
static void
gpm_manager_control_resume_cb (GpmControl *control, GpmControlAction action, GpmManager *manager)
{
+ guint timer_id;
manager->priv->just_resumed = TRUE;
- g_timeout_add_seconds (1, gpm_manager_reset_just_resumed_cb, manager);
+ timer_id = g_timeout_add_seconds (1, gpm_manager_reset_just_resumed_cb, manager);
+ g_source_set_name_by_id (timer_id, "[GpmManager] just-resumed");
}
/**
@@ -1790,7 +1797,6 @@ static void
gpm_manager_init (GpmManager *manager)
{
gboolean check_type_cpu;
- gint timeout;
DBusGConnection *connection;
GDBusConnection *g_connection;
GError *error = NULL;
@@ -1945,8 +1951,11 @@ gpm_manager_finalize (GObject *object)
gpm_manager_notify_close (manager, manager->priv->notification_discharging);
if (manager->priv->notification_fully_charged != NULL)
gpm_manager_notify_close (manager, manager->priv->notification_fully_charged);
- if (manager->priv->critical_alert_timeout_id != 0)
+
+ if (manager->priv->critical_alert_timeout_id != 0) {
g_source_remove (manager->priv->critical_alert_timeout_id);
+ manager->priv->critical_alert_timeout_id = 0;
+ }
g_object_unref (manager->priv->settings);
g_object_unref (manager->priv->dpms);
diff --git a/src/gpm-networkmanager.c b/src/gpm-networkmanager.c
index 3b62406..add8fc0 100644
--- a/src/gpm-networkmanager.c
+++ b/src/gpm-networkmanager.c
@@ -20,7 +20,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <glib.h>
diff --git a/src/gpm-networkmanager.h b/src/gpm-networkmanager.h
index b60208b..e7eaa4c 100644
--- a/src/gpm-networkmanager.h
+++ b/src/gpm-networkmanager.h
@@ -22,6 +22,8 @@
#ifndef __GPM_NETWORKMANAGER_H
#define __GPM_NETWORKMANAGER_H
+#include <glib.h>
+
G_BEGIN_DECLS
gboolean gpm_networkmanager_sleep (void);
diff --git a/src/gpm-phone.c b/src/gpm-phone.c
index 0732c91..e31c72b 100644
--- a/src/gpm-phone.c
+++ b/src/gpm-phone.c
@@ -24,14 +24,13 @@
#include <string.h>
#include <glib.h>
#include <glib/gi18n.h>
+#include <gio/gio.h>
#include <dbus/dbus-glib.h>
#include "gpm-phone.h"
#include "egg-debug.h"
#include "gpm-marshal.h"
-#include "egg-dbus-monitor.h"
-
static void gpm_phone_finalize (GObject *object);
#define GPM_PHONE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPM_TYPE_PHONE, GpmPhonePrivate))
@@ -40,7 +39,7 @@ struct GpmPhonePrivate
{
DBusGProxy *proxy;
DBusGConnection *connection;
- EggDbusMonitor *monitor;
+ guint watch_id;
gboolean present;
guint percentage;
gboolean onac;
@@ -225,15 +224,16 @@ gpm_phone_class_init (GpmPhoneClass *klass)
}
/**
- * gpm_phone_dbus_connect:
- **/
-static gboolean
-gpm_phone_dbus_connect (GpmPhone *phone)
+ * gpm_phone_service_appeared_cb:
+ */
+static void
+gpm_phone_service_appeared_cb (GDBusConnection *connection,
+ const gchar *name, const gchar *name_owner,
+ GpmPhone *phone)
{
GError *error = NULL;
- g_return_val_if_fail (phone != NULL, FALSE);
- g_return_val_if_fail (GPM_IS_PHONE (phone), FALSE);
+ g_return_if_fail (GPM_IS_PHONE (phone));
if (phone->priv->connection == NULL) {
egg_debug ("get connection");
@@ -243,7 +243,7 @@ gpm_phone_dbus_connect (GpmPhone *phone)
egg_warning ("Could not connect to DBUS daemon: %s", error->message);
g_error_free (error);
phone->priv->connection = NULL;
- return FALSE;
+ return;
}
}
if (phone->priv->proxy == NULL) {
@@ -258,7 +258,7 @@ gpm_phone_dbus_connect (GpmPhone *phone)
egg_warning ("Cannot connect, maybe the daemon is not running: %s", error->message);
g_error_free (error);
phone->priv->proxy = NULL;
- return FALSE;
+ return;
}
/* complicated type. ick */
@@ -281,17 +281,17 @@ gpm_phone_dbus_connect (GpmPhone *phone)
phone, NULL);
}
- return TRUE;
}
/**
- * gpm_phone_dbus_disconnect:
- **/
-static gboolean
-gpm_phone_dbus_disconnect (GpmPhone *phone)
+ * gpm_phone_service_vanished_cb:
+ */
+static void
+gpm_phone_service_vanished_cb (GDBusConnection *connection,
+ const gchar *name,
+ GpmPhone *phone)
{
- g_return_val_if_fail (phone != NULL, FALSE);
- g_return_val_if_fail (GPM_IS_PHONE (phone), FALSE);
+ g_return_if_fail (GPM_IS_PHONE (phone));
if (phone->priv->proxy != NULL) {
egg_debug ("removing proxy");
@@ -304,24 +304,7 @@ gpm_phone_dbus_disconnect (GpmPhone *phone)
g_signal_emit (phone, signals [DEVICE_REMOVED], 0, 0);
}
}
- return TRUE;
-}
-
-/**
- * monitor_connection_cb:
- * @proxy: The dbus raw proxy
- * @status: The status of the service, where TRUE is connected
- * @screensaver: This class instance
- **/
-static void
-monitor_connection_cb (EggDbusMonitor *monitor,
- gboolean status,
- GpmPhone *phone)
-{
- if (status)
- gpm_phone_dbus_connect (phone);
- else
- gpm_phone_dbus_disconnect (phone);
+ return;
}
/**
@@ -331,7 +314,6 @@ monitor_connection_cb (EggDbusMonitor *monitor,
static void
gpm_phone_init (GpmPhone *phone)
{
- DBusGConnection *connection;
phone->priv = GPM_PHONE_GET_PRIVATE (phone);
phone->priv->connection = NULL;
@@ -340,12 +322,12 @@ gpm_phone_init (GpmPhone *phone)
phone->priv->percentage = 0;
phone->priv->onac = FALSE;
- phone->priv->monitor = egg_dbus_monitor_new ();
- g_signal_connect (phone->priv->monitor, "connection-changed",
- G_CALLBACK (monitor_connection_cb), phone);
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
- egg_dbus_monitor_assign (phone->priv->monitor, connection, MATE_PHONE_MANAGER_DBUS_SERVICE);
- gpm_phone_dbus_connect (phone);
+ phone->priv->watch_id = g_bus_watch_name (G_BUS_TYPE_SESSION,
+ MATE_PHONE_MANAGER_DBUS_SERVICE,
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ (GBusNameAppearedCallback) gpm_phone_service_appeared_cb,
+ (GBusNameVanishedCallback) gpm_phone_service_vanished_cb,
+ phone, NULL);
}
/**
@@ -356,15 +338,14 @@ static void
gpm_phone_finalize (GObject *object)
{
GpmPhone *phone;
- g_return_if_fail (object != NULL);
g_return_if_fail (GPM_IS_PHONE (object));
phone = GPM_PHONE (object);
phone->priv = GPM_PHONE_GET_PRIVATE (phone);
- gpm_phone_dbus_disconnect (phone);
- if (phone->priv->monitor != NULL)
- g_object_unref (phone->priv->monitor);
+ if (phone->priv->proxy != NULL)
+ g_object_unref (phone->priv->proxy);
+ g_bus_unwatch_name (phone->priv->watch_id);
G_OBJECT_CLASS (gpm_phone_parent_class)->finalize (object);
}
diff --git a/src/gpm-prefs-core.c b/src/gpm-prefs-core.c
index ddb1bd7..b33ff22 100644
--- a/src/gpm-prefs-core.c
+++ b/src/gpm-prefs-core.c
@@ -39,7 +39,7 @@
#include "gpm-tray-icon.h"
#include "gpm-common.h"
#include "gpm-prefs-core.h"
-#include "gpm-stock-icons.h"
+#include "gpm-icon-names.h"
#include "gpm-brightness.h"
static void gpm_prefs_finalize (GObject *object);
@@ -110,10 +110,11 @@ gpm_prefs_class_init (GpmPrefsClass *klass)
* Activates (shows) the window.
**/
void
-gpm_prefs_activate_window (GpmPrefs *prefs)
+gpm_prefs_activate_window (GtkApplication *app, GpmPrefs *prefs)
{
GtkWindow *window;
window = GTK_WINDOW (gtk_builder_get_object (prefs->priv->builder, "dialog_preferences"));
+ gtk_application_add_window (GTK_APPLICATION (app), window);
gtk_window_present (window);
}
@@ -632,6 +633,7 @@ prefs_setup_general (GpmPrefs *prefs)
GPM_ACTION_POLICY_SUSPEND,
GPM_ACTION_POLICY_HIBERNATE,
GPM_ACTION_POLICY_SHUTDOWN,
+ GPM_ACTION_POLICY_NOTHING,
-1};
const GpmActionPolicy suspend_button_actions[] =
{GPM_ACTION_POLICY_NOTHING,
@@ -712,7 +714,7 @@ gpm_prefs_init (GpmPrefs *prefs)
&error
);
if (error == NULL && res != NULL) {
- g_variant_get(res,"(s)", &r);
+ g_variant_get(res,"(&s)", &r);
prefs->priv->can_shutdown = g_strcmp0(r,"yes")==0?TRUE:FALSE;
g_variant_unref (res);
} else if (error != NULL ) {
@@ -728,7 +730,7 @@ gpm_prefs_init (GpmPrefs *prefs)
&error
);
if (error == NULL && res != NULL) {
- g_variant_get(res,"(s)", &r);
+ g_variant_get(res,"(&s)", &r);
prefs->priv->can_suspend = g_strcmp0(r,"yes")==0?TRUE:FALSE;
g_variant_unref (res);
} else if (error != NULL ) {
@@ -744,7 +746,7 @@ gpm_prefs_init (GpmPrefs *prefs)
&error
);
if (error == NULL && res != NULL) {
- g_variant_get(res,"(s)", &r);
+ g_variant_get(res,"(&s)", &r);
prefs->priv->can_hibernate = g_strcmp0(r,"yes")==0?TRUE:FALSE;
g_variant_unref (res);
} else if (error != NULL ) {
@@ -841,7 +843,7 @@ gpm_prefs_init (GpmPrefs *prefs)
/* Hide window first so that the dialogue resizes itself without redrawing */
gtk_widget_hide (main_window);
- gtk_window_set_default_icon_name (GPM_STOCK_APP_ICON);
+ gtk_window_set_default_icon_name (GPM_ICON_APP_ICON);
/* Get the main window quit */
g_signal_connect (main_window, "delete_event",
@@ -863,8 +865,6 @@ gpm_prefs_init (GpmPrefs *prefs)
prefs_setup_ups (prefs);
prefs_setup_general (prefs);
prefs_setup_notification (prefs);
-
- gtk_widget_show (main_window);
}
/**
@@ -884,6 +884,7 @@ gpm_prefs_finalize (GObject *object)
g_object_unref (prefs->priv->settings);
g_object_unref (prefs->priv->client);
g_object_unref (prefs->priv->console);
+ g_object_unref (prefs->priv->builder);
G_OBJECT_CLASS (gpm_prefs_parent_class)->finalize (object);
}
@@ -899,3 +900,13 @@ gpm_prefs_new (void)
prefs = g_object_new (GPM_TYPE_PREFS, NULL);
return GPM_PREFS (prefs);
}
+
+/**
+ * gpm_window:
+ * Return value: Prefs window widget.
+ **/
+GtkWidget *
+gpm_window (GpmPrefs *prefs)
+{
+ return GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "dialog_preferences"));
+}
diff --git a/src/gpm-prefs-core.h b/src/gpm-prefs-core.h
index 39c536c..6810d4d 100644
--- a/src/gpm-prefs-core.h
+++ b/src/gpm-prefs-core.h
@@ -50,7 +50,8 @@ typedef struct
GType gpm_prefs_get_type (void);
GpmPrefs *gpm_prefs_new (void);
-void gpm_prefs_activate_window (GpmPrefs *prefs);
+GtkWidget *gpm_window (GpmPrefs *prefs);
+void gpm_prefs_activate_window (GtkApplication *app, GpmPrefs *prefs);
G_END_DECLS
diff --git a/src/gpm-prefs.c b/src/gpm-prefs.c
index b209641..4785cc0 100644
--- a/src/gpm-prefs.c
+++ b/src/gpm-prefs.c
@@ -30,9 +30,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-/* local .la */
-#include <egg-unique.h>
-
#include "gpm-common.h"
#include "egg-debug.h"
#include "gpm-prefs-core.h"
@@ -50,27 +47,15 @@ gpm_prefs_help_cb (GpmPrefs *prefs)
}
/**
- * gpm_prefs_close_cb
- * @prefs: This prefs class instance
- *
- * What to do when we are asked to close for whatever reason
- **/
-static void
-gpm_prefs_close_cb (GpmPrefs *prefs)
-{
- gtk_main_quit ();
-}
-
-/**
* gpm_prefs_activated_cb
* @prefs: This prefs class instance
*
* We have been asked to show the window
**/
static void
-gpm_prefs_activated_cb (EggUnique *egg_unique, GpmPrefs *prefs)
+gpm_prefs_activated_cb (GtkApplication *app, GpmPrefs *prefs)
{
- gpm_prefs_activate_window (prefs);
+ gpm_prefs_activate_window (app, prefs);
}
/**
@@ -83,7 +68,9 @@ main (int argc, char **argv)
GOptionContext *context;
GpmPrefs *prefs = NULL;
gboolean ret;
- EggUnique *egg_unique;
+ GtkApplication *app;
+ GtkWidget *window;
+ gint status;
const GOptionEntry options[] = {
{ "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose,
@@ -102,32 +89,28 @@ main (int argc, char **argv)
g_option_context_add_group (context, gtk_get_option_group (FALSE));
g_option_context_parse (context, &argc, &argv, NULL);
- gtk_init (&argc, &argv);
egg_debug_init (verbose);
- /* are we already activated? */
- egg_unique = egg_unique_new ();
- ret = egg_unique_assign (egg_unique, "org.mate.PowerManager.Preferences");
- if (!ret) {
- goto unique_out;
- }
+ gdk_init (&argc, &argv);
+ app = gtk_application_new("org.mate.PowerManager.Preferences", 0);
prefs = gpm_prefs_new ();
- g_signal_connect (egg_unique, "activated",
+ window = gpm_window (prefs);
+ g_signal_connect (app, "activate",
G_CALLBACK (gpm_prefs_activated_cb), prefs);
g_signal_connect (prefs, "action-help",
G_CALLBACK (gpm_prefs_help_cb), prefs);
- g_signal_connect (prefs, "action-close",
- G_CALLBACK (gpm_prefs_close_cb), prefs);
- gtk_main ();
+ g_signal_connect_swapped (prefs, "action-close",
+ G_CALLBACK (gtk_widget_destroy), window);
+
+ status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (prefs);
-unique_out:
- g_object_unref (egg_unique);
+ g_object_unref (app);
/* seems to not work...
g_option_context_free (context); */
- return 0;
+ return status;
}
diff --git a/src/gpm-session.c b/src/gpm-session.c
index ffe3f61..3baa818 100644
--- a/src/gpm-session.c
+++ b/src/gpm-session.c
@@ -35,12 +35,12 @@ static void gpm_session_finalize (GObject *object);
#define GPM_SESSION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPM_TYPE_SESSION, GpmSessionPrivate))
-#define GPM_SESSION_MANAGER_SERVICE "org.mate.SessionManager"
-#define GPM_SESSION_MANAGER_PATH "/org/mate/SessionManager"
-#define GPM_SESSION_MANAGER_INTERFACE "org.mate.SessionManager"
-#define GPM_SESSION_MANAGER_PRESENCE_PATH "/org/mate/SessionManager/Presence"
-#define GPM_SESSION_MANAGER_PRESENCE_INTERFACE "org.mate.SessionManager.Presence"
-#define GPM_SESSION_MANAGER_CLIENT_PRIVATE_INTERFACE "org.mate.SessionManager.ClientPrivate"
+#define GPM_SESSION_MANAGER_SERVICE "org.gnome.SessionManager"
+#define GPM_SESSION_MANAGER_PATH "/org/gnome/SessionManager"
+#define GPM_SESSION_MANAGER_INTERFACE "org.gnome.SessionManager"
+#define GPM_SESSION_MANAGER_PRESENCE_PATH "/org/gnome/SessionManager/Presence"
+#define GPM_SESSION_MANAGER_PRESENCE_INTERFACE "org.gnome.SessionManager.Presence"
+#define GPM_SESSION_MANAGER_CLIENT_PRIVATE_INTERFACE "org.gnome.SessionManager.ClientPrivate"
#define GPM_DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
typedef enum {
@@ -342,7 +342,7 @@ gpm_session_register_client (GpmSession *session, const gchar *app_id, const gch
goto out;
}
- /* get org.mate.Session.ClientPrivate interface */
+ /* get org.gnome.SessionManager.ClientPrivate interface */
connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
session->priv->proxy_client_private = dbus_g_proxy_new_for_name_owner (connection, GPM_SESSION_MANAGER_SERVICE,
client_id, GPM_SESSION_MANAGER_CLIENT_PRIVATE_INTERFACE, &error);
@@ -462,7 +462,7 @@ gpm_session_init (GpmSession *session)
connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
- /* get org.mate.Session interface */
+ /* get org.gnome.SessionManager interface */
session->priv->proxy = dbus_g_proxy_new_for_name_owner (connection, GPM_SESSION_MANAGER_SERVICE,
GPM_SESSION_MANAGER_PATH,
GPM_SESSION_MANAGER_INTERFACE, &error);
@@ -472,7 +472,7 @@ gpm_session_init (GpmSession *session)
return;
}
- /* get org.mate.Session.Presence interface */
+ /* get org.gnome.SessionManager.Presence interface */
session->priv->proxy_presence = dbus_g_proxy_new_for_name_owner (connection, GPM_SESSION_MANAGER_SERVICE,
GPM_SESSION_MANAGER_PRESENCE_PATH,
GPM_SESSION_MANAGER_PRESENCE_INTERFACE, &error);
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index a9436bd..d6bcaf1 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -33,10 +33,9 @@
#include "egg-debug.h"
#include "egg-color.h"
#include "egg-array-float.h"
-#include "egg-unique.h"
#include "gpm-common.h"
-#include "gpm-stock-icons.h"
+#include "gpm-icon-names.h"
#include "gpm-upower.h"
#include "gpm-graph-widget.h"
@@ -403,7 +402,7 @@ gpm_stats_update_info_page_details (UpDevice *device)
gpm_stats_add_info_data (_("Device"), device_path);
g_free (device_path);
- gpm_stats_add_info_data (_("Type"), gpm_device_kind_to_localised_text (kind, 1));
+ gpm_stats_add_info_data (_("Type"), gpm_device_kind_to_localised_string (kind, 1));
if (vendor != NULL && vendor[0] != '\0')
gpm_stats_add_info_data (_("Vendor"), vendor);
if (model != NULL && model[0] != '\0')
@@ -1129,6 +1128,10 @@ static void
gpm_stats_button_update_ui (void)
{
UpDevice *device;
+
+ if (current_device == NULL)
+ return;
+
device = up_device_new ();
up_device_set_object_path_sync (device, current_device, NULL, NULL);
gpm_stats_update_info_data (device);
@@ -1175,10 +1178,11 @@ gpm_stats_devices_treeview_clicked_cb (GtkTreeSelection *selection, gboolean dat
* gpm_stats_window_activated_cb
**/
static void
-gpm_stats_window_activated_cb (EggUnique *egg_unique, gpointer data)
+gpm_stats_window_activated_cb (GtkApplication *app, gpointer data)
{
GtkWidget *widget;
widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_stats"));
+ gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (widget));
gtk_window_present (GTK_WINDOW (widget));
}
@@ -1216,6 +1220,7 @@ gpm_stats_add_device (UpDevice *device)
const gchar *text;
const gchar *icon;
UpDeviceKind kind;
+ gchar *label, *vendor, *model;
#if UP_CHECK_VERSION(0, 99, 0)
if (devices != NULL)
@@ -1228,17 +1233,27 @@ gpm_stats_add_device (UpDevice *device)
/* get device properties */
g_object_get (device,
"kind", &kind,
+ "vendor", &vendor,
+ "model", &model,
NULL);
id = up_device_get_object_path (device);
- text = gpm_device_kind_to_localised_text (kind, 1);
+ if ((vendor != NULL && strlen(vendor) != 0) && (model != NULL && strlen(model) != 0)) {
+ label = g_strdup_printf ("%s %s", vendor, model);
+ }
+ else {
+ label = g_strdup_printf ("%s", gpm_device_kind_to_localised_string (kind, 1));
+ }
icon = gpm_upower_get_device_icon (device);
gtk_list_store_append (list_store_devices, &iter);
gtk_list_store_set (list_store_devices, &iter,
GPM_DEVICES_COLUMN_ID, id,
- GPM_DEVICES_COLUMN_TEXT, text,
+ GPM_DEVICES_COLUMN_TEXT, label,
GPM_DEVICES_COLUMN_ICON, icon, -1);
+ g_free (label);
+ g_free (vendor);
+ g_free (model);
}
/**
@@ -1549,9 +1564,10 @@ main (int argc, char *argv[])
gboolean verbose = FALSE;
GOptionContext *context;
GtkBox *box;
- GtkWidget *widget;
+ GtkWidget *widget, *window;
GtkTreeSelection *selection;
- EggUnique *egg_unique;
+ GtkApplication *app;
+ gint status;
gboolean ret;
UpClient *client;
GPtrArray *devices = NULL;
@@ -1592,12 +1608,9 @@ main (int argc, char *argv[])
egg_debug_init (verbose);
gtk_init (&argc, &argv);
- /* are we already activated? */
- egg_unique = egg_unique_new ();
- ret = egg_unique_assign (egg_unique, "org.mate.PowerManager.Statistics");
- if (!ret)
- goto unique_out;
- g_signal_connect (egg_unique, "activated",
+ app = gtk_application_new ("org.mate.PowerManager.Statistics", 0);
+
+ g_signal_connect (app, "activate",
G_CALLBACK (gpm_stats_window_activated_cb), NULL);
/* add application specific icons to search path */
@@ -1629,15 +1642,14 @@ main (int argc, char *argv[])
gtk_widget_set_size_request (graph_statistics, 400, 250);
gtk_widget_show (graph_statistics);
- widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_stats"));
- gtk_window_set_default_size (GTK_WINDOW(widget), 800, 500);
- gtk_window_set_default_icon_name (GPM_STOCK_APP_ICON);
+ window = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_stats"));
+ gtk_window_set_default_size (GTK_WINDOW(window), 800, 500);
+ gtk_window_set_default_icon_name (GPM_ICON_APP_ICON);
/* Get the main window quit */
- g_signal_connect_swapped (widget, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
-
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_close"));
- g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect_swapped (window, "delete_event", G_CALLBACK (gtk_widget_destroy), window);
+ g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_widget_destroy), window);
gtk_widget_grab_default (widget);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_help"));
@@ -1802,8 +1814,6 @@ main (int argc, char *argv[])
#else
g_signal_connect (client, "device-added", G_CALLBACK (gpm_stats_device_added_cb), NULL);
g_signal_connect (client, "device-removed", G_CALLBACK (gpm_stats_device_removed_cb), NULL);
-#endif
-#if !UP_CHECK_VERSION(0, 99, 0)
g_signal_connect (client, "device-changed", G_CALLBACK (gpm_stats_device_changed_cb), NULL);
#endif
@@ -1840,9 +1850,8 @@ main (int argc, char *argv[])
gpm_stats_type_combo_changed_cb (widget, NULL);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_stats"));
- gtk_widget_show (widget);
- gtk_main ();
+ status = g_application_run (G_APPLICATION (app), argc, argv);
#if !UP_CHECK_VERSION(0, 99, 0)
out:
#endif
@@ -1854,8 +1863,7 @@ out:
g_object_unref (wakeups);
g_object_unref (builder);
g_object_unref (list_store_info);
-unique_out:
- g_object_unref (egg_unique);
+ g_object_unref (app);
g_free (last_device);
- return 0;
+ return status;
}
diff --git a/src/gpm-tray-icon.c b/src/gpm-tray-icon.c
index fa7f5da..3bcd09b 100644
--- a/src/gpm-tray-icon.c
+++ b/src/gpm-tray-icon.c
@@ -39,14 +39,13 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <libupower-glib/upower.h>
-#include <libmate-desktop/mate-aboutdialog.h>
#include "egg-debug.h"
#include "gpm-upower.h"
#include "gpm-engine.h"
#include "gpm-common.h"
-#include "gpm-stock-icons.h"
+#include "gpm-icon-names.h"
#include "gpm-tray-icon.h"
static void gpm_tray_icon_finalize (GObject *object);
@@ -111,20 +110,21 @@ gpm_tray_icon_get_status_icon (GpmTrayIcon *icon)
}
/**
- * gpm_tray_icon_set_image_from_stock:
- * @filename: The icon name, e.g. GPM_STOCK_APP_ICON, or NULL to remove.
+ * gpm_tray_icon_set_icon:
+ * @icon_name: The icon name, e.g. GPM_ICON_APP_ICON, or NULL to remove.
*
- * Loads a pixmap from disk, and sets as the tooltip icon
+ * Loads a pixmap from disk, and sets as the tooltip icon.
**/
gboolean
-gpm_tray_icon_set_icon (GpmTrayIcon *icon, const gchar *filename)
+gpm_tray_icon_set_icon (GpmTrayIcon *icon, const gchar *icon_name)
{
g_return_val_if_fail (icon != NULL, FALSE);
g_return_val_if_fail (GPM_IS_TRAY_ICON (icon), FALSE);
- if (filename != NULL) {
- egg_debug ("Setting icon to %s", filename);
- gtk_status_icon_set_from_icon_name (icon->priv->status_icon, filename);
+ if (icon_name != NULL) {
+ egg_debug ("Setting icon to %s", icon_name);
+ gtk_status_icon_set_from_icon_name (icon->priv->status_icon,
+ icon_name);
/* make sure that we are visible */
gpm_tray_icon_show (icon, TRUE);
@@ -182,35 +182,20 @@ gpm_tray_icon_show_about_cb (GtkMenuItem *item, gpointer data)
NULL
};
- mate_show_about_dialog (NULL,
- "program-name", _("Power Manager"),
- "version", VERSION,
- "comments", _("Power management daemon"),
- "copyright", _("Copyright \xC2\xA9 2011-2014 MATE developers"),
- "authors", authors,
- /* Translators should localize the following string
- * which will be displayed at the bottom of the about
- * box to give credit to the translator(s).
- */
- "translator-credits", _("translator-credits"),
- "logo-icon-name", "mate-power-manager",
- "website", "http://www.mate-desktop.org",
- NULL);
-}
-
-/**
- * gpm_tray_icon_popup_cleared_cd:
- * @widget: The popup Gtkwidget
- *
- * We have to re-enable the tooltip when the popup is removed
- **/
-static void
-gpm_tray_icon_popup_cleared_cd (GtkWidget *widget, GpmTrayIcon *icon)
-{
- g_return_if_fail (GPM_IS_TRAY_ICON (icon));
- egg_debug ("clear tray");
- g_object_ref_sink (widget);
- g_object_unref (widget);
+ gtk_show_about_dialog (NULL,
+ "program-name", _("Power Manager"),
+ "version", VERSION,
+ "comments", _("Power management daemon"),
+ "copyright", _("Copyright \xC2\xA9 2011-2016 MATE developers"),
+ "authors", authors,
+ /* Translators should localize the following string
+ * which will be displayed at the bottom of the about
+ * box to give credit to the translator(s).
+ */
+ "translator-credits", _("translator-credits"),
+ "logo-icon-name", "mate-power-manager",
+ "website", "http://www.mate-desktop.org",
+ NULL);
}
/**
@@ -234,11 +219,10 @@ gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, const GPtrArray *arr
guint i;
guint added = 0;
gchar *icon_name;
- gchar *label;
+ gchar *label, *vendor, *model;
GtkWidget *item;
GtkWidget *image;
const gchar *object_path;
- const gchar *desc;
UpDevice *device;
UpDeviceKind kind_tmp;
gdouble percentage;
@@ -251,6 +235,8 @@ gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, const GPtrArray *arr
g_object_get (device,
"kind", &kind_tmp,
"percentage", &percentage,
+ "vendor", &vendor,
+ "model", &model,
NULL);
if (kind != kind_tmp)
@@ -261,8 +247,12 @@ gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, const GPtrArray *arr
added++;
/* generate the label */
- desc = gpm_device_kind_to_localised_text (kind, 1);
- label = g_strdup_printf ("%s (%.1f%%)", desc, percentage);
+ if ((vendor != NULL && strlen(vendor) != 0) && (model != NULL && strlen(model) != 0)) {
+ label = g_strdup_printf ("%s %s (%.1f%%)", vendor, model, percentage);
+ }
+ else {
+ label = g_strdup_printf ("%s (%.1f%%)", gpm_device_kind_to_localised_string (kind, 1), percentage);
+ }
item = gtk_image_menu_item_new_with_label (label);
/* generate the image */
@@ -278,23 +268,61 @@ gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, const GPtrArray *arr
g_free (icon_name);
g_free (label);
+ g_free (vendor);
+ g_free (model);
}
return added;
}
/**
+ * gpm_tray_icon_add_primary_device:
+ **/
+static void
+gpm_tray_icon_add_primary_device (GpmTrayIcon *icon, GtkMenu *menu, UpDevice *device)
+{
+ GtkWidget *item;
+ gchar *time_str;
+ gchar *string;
+ gint64 time_to_empty = 0;
+
+ /* get details */
+ g_object_get (device,
+ "time-to-empty", &time_to_empty,
+ NULL);
+
+ /* convert time to string */
+ time_str = gpm_get_timestring (time_to_empty);
+
+ /* TRANSLATORS: % is a timestring, e.g. "6 hours 10 minutes" */
+ string = g_strdup_printf (_("%s remaining"), time_str);
+ item = gtk_image_menu_item_new_with_label (string);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ g_free (time_str);
+ g_free (string);
+}
+
+/**
* gpm_tray_icon_create_menu:
*
- * Display the popup menu.
+ * Create the popup menu.
**/
-static void
-gpm_tray_icon_create_menu (GpmTrayIcon *icon, guint32 timestamp)
+static GtkMenu *
+gpm_tray_icon_create_menu (GpmTrayIcon *icon)
{
GtkMenu *menu = (GtkMenu*) gtk_menu_new ();
GtkWidget *item;
GtkWidget *image;
guint dev_cnt = 0;
GPtrArray *array;
+ UpDevice *device = NULL;
+
+ /* show the primary device time remaining */
+ device = gpm_engine_get_primary_device (icon->priv->engine);
+ if (device != NULL) {
+ gpm_tray_icon_add_primary_device (icon, menu, device);
+ item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ }
/* add all device types to the drop down menu */
array = gpm_engine_get_devices (icon->priv->engine);
@@ -321,11 +349,23 @@ gpm_tray_icon_create_menu (GpmTrayIcon *icon, guint32 timestamp)
/* preferences */
item = gtk_image_menu_item_new_with_mnemonic (_("_Preferences"));
- image = gtk_image_new_from_icon_name (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
+ image = gtk_image_new_from_icon_name ("preferences-system", GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
g_signal_connect (G_OBJECT (item), "activate",
G_CALLBACK (gpm_tray_icon_show_preferences_cb), icon);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ /*Set up custom panel menu theme support-gtk3 only */
+ GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu));
+ /* Fix any failures of compiz/other wm's to communicate with gtk for transparency in menu theme */
+ GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel));
+ GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
+ gtk_widget_set_visual(GTK_WIDGET(toplevel), visual);
+ /* Set menu and it's toplevel window to follow panel theme */
+ GtkStyleContext *context;
+ context = gtk_widget_get_style_context (GTK_WIDGET(toplevel));
+ gtk_style_context_add_class(context,"gnome-panel-menu-bar");
+ gtk_style_context_add_class(context,"mate-panel-menu-bar");
/* about */
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
@@ -334,6 +374,38 @@ gpm_tray_icon_create_menu (GpmTrayIcon *icon, guint32 timestamp)
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
skip_prefs:
+ if (device != NULL)
+ g_object_unref (device);
+ return menu;
+}
+
+/**
+ * gpm_tray_icon_popup_cleared_cd:
+ * @widget: The popup Gtkwidget
+ *
+ * We have to re-enable the tooltip when the popup is removed
+ **/
+static void
+gpm_tray_icon_popup_cleared_cd (GtkWidget *widget, GpmTrayIcon *icon)
+{
+ g_return_if_fail (GPM_IS_TRAY_ICON (icon));
+ egg_debug ("clear tray");
+ g_object_ref_sink (widget);
+ g_object_unref (widget);
+}
+
+/**
+ * gpm_tray_icon_popup_menu:
+ *
+ * Display the popup menu.
+ **/
+static void
+gpm_tray_icon_popup_menu (GpmTrayIcon *icon, guint32 timestamp)
+{
+ GtkMenu *menu;
+
+ menu = gpm_tray_icon_create_menu (icon);
+
/* show the menu */
gtk_widget_show_all (GTK_WIDGET (menu));
gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
@@ -353,7 +425,7 @@ static void
gpm_tray_icon_popup_menu_cb (GtkStatusIcon *status_icon, guint button, guint32 timestamp, GpmTrayIcon *icon)
{
egg_debug ("icon right clicked");
- gpm_tray_icon_create_menu (icon, timestamp);
+ gpm_tray_icon_popup_menu (icon, timestamp);
}
@@ -367,7 +439,7 @@ static void
gpm_tray_icon_activate_cb (GtkStatusIcon *status_icon, GpmTrayIcon *icon)
{
egg_debug ("icon left clicked");
- gpm_tray_icon_create_menu (icon, gtk_get_current_event_time());
+ gpm_tray_icon_popup_menu (icon, gtk_get_current_event_time());
}
/**
@@ -405,6 +477,7 @@ gpm_tray_icon_init (GpmTrayIcon *icon)
G_CALLBACK (gpm_tray_icon_settings_changed_cb), icon);
icon->priv->status_icon = gtk_status_icon_new ();
+ gpm_tray_icon_show (icon, FALSE);
g_signal_connect_object (G_OBJECT (icon->priv->status_icon),
"popup_menu",
G_CALLBACK (gpm_tray_icon_popup_menu_cb),
diff --git a/src/gpm-tray-icon.h b/src/gpm-tray-icon.h
index 5ff828f..03bc943 100644
--- a/src/gpm-tray-icon.h
+++ b/src/gpm-tray-icon.h
@@ -55,7 +55,7 @@ GpmTrayIcon *gpm_tray_icon_new (void);
gboolean gpm_tray_icon_set_tooltip (GpmTrayIcon *icon,
const gchar *tooltip);
gboolean gpm_tray_icon_set_icon (GpmTrayIcon *icon,
- const gchar *filename);
+ const gchar *icon_name);
GtkStatusIcon *gpm_tray_icon_get_status_icon (GpmTrayIcon *icon);
G_END_DECLS
diff --git a/src/gpm-upower.c b/src/gpm-upower.c
index 82d12e9..168e879 100644
--- a/src/gpm-upower.c
+++ b/src/gpm-upower.c
@@ -203,10 +203,13 @@ gpm_upower_get_device_summary (UpDevice *device)
"time-to-empty", &time_to_empty,
NULL);
- if (!is_present)
- return NULL;
+ kind_desc = gpm_device_kind_to_localised_string (kind, 1);
- kind_desc = gpm_device_kind_to_localised_text (kind, 1);
+ /* not installed */
+ if (!is_present) {
+ /* TRANSLATORS: device not present */
+ return g_strdup_printf (_("%s not present"), kind_desc);
+ }
/* don't display all the extra stuff for keyboards and mice */
if (kind == UP_DEVICE_KIND_MOUSE ||
@@ -297,11 +300,17 @@ gpm_upower_get_device_summary (UpDevice *device)
/* TRANSLATORS: this is only shown for laptops with multiple batteries */
description = g_strdup_printf (_("%s waiting to charge (%.1f%%)"), kind_desc, percentage);
+ } else if (state == UP_DEVICE_STATE_EMPTY) {
+
+ /* TRANSLATORS: when the device has no charge left */
+ description = g_strdup_printf (_("%s empty"), kind_desc);
+
} else {
egg_warning ("in an undefined state we are not charging or "
"discharging and the batteries are also not charged");
description = g_strdup_printf ("%s (%.1f%%)", kind_desc, percentage);
}
+
return description;
}
@@ -352,7 +361,7 @@ gpm_upower_get_device_description (UpDevice *device)
NULL);
details = g_string_new ("");
- text = gpm_device_kind_to_localised_text (kind, 1);
+ text = gpm_device_kind_to_localised_string (kind, 1);
/* TRANSLATORS: the type of data, e.g. Laptop battery */
g_string_append_printf (details, "<b>%s</b> %s\n", _("Product:"), text);
@@ -466,10 +475,10 @@ gpm_upower_get_device_description (UpDevice *device)
}
/**
- * gpm_device_kind_to_localised_text:
+ * gpm_device_kind_to_localised_string:
**/
const gchar *
-gpm_device_kind_to_localised_text (UpDeviceKind kind, guint number)
+gpm_device_kind_to_localised_string (UpDeviceKind kind, guint number)
{
const gchar *text = NULL;
switch (kind) {
diff --git a/src/gpm-upower.h b/src/gpm-upower.h
index 3f43e64..a60d906 100644
--- a/src/gpm-upower.h
+++ b/src/gpm-upower.h
@@ -27,7 +27,7 @@
G_BEGIN_DECLS
-const gchar *gpm_device_kind_to_localised_text (UpDeviceKind kind,
+const gchar *gpm_device_kind_to_localised_string (UpDeviceKind kind,
guint number);
const gchar *gpm_device_kind_to_icon (UpDeviceKind kind);
const gchar *gpm_device_technology_to_localised_string (UpDeviceTechnology technology_enum);
diff --git a/src/gsd-media-keys-window.c b/src/gsd-media-keys-window.c
index 67d2402..e59ba44 100644
--- a/src/gsd-media-keys-window.c
+++ b/src/gsd-media-keys-window.c
@@ -402,45 +402,33 @@ draw_volume_boxes (MsdMediaKeysWindow *window,
double height)
{
gdouble x1;
- GdkColor color;
- double r, g, b;
- GtkStyle *style;
+ GtkStyleContext *context;
- _x0 += 0.5;
- _y0 += 0.5;
height = round (height) - 1;
width = round (width) - 1;
x1 = round ((width - 1) * percentage);
- style = gtk_widget_get_style (GTK_WIDGET (window));
+ context = gtk_widget_get_style_context (GTK_WIDGET (window));
/* bar background */
- msd_osd_window_color_reverse (&style->dark[GTK_STATE_NORMAL], &color);
- r = (float)color.red / 65535.0;
- g = (float)color.green / 65535.0;
- b = (float)color.blue / 65535.0;
- msd_osd_window_draw_rounded_rectangle (cr, 1.0, _x0, _y0, height / 6, width, height);
- cairo_set_source_rgba (cr, r, g, b, MSD_OSD_WINDOW_FG_ALPHA / 2);
- cairo_fill_preserve (cr);
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_TROUGH);
- /* bar border */
- msd_osd_window_color_reverse (&style->light[GTK_STATE_NORMAL], &color);
- r = (float)color.red / 65535.0;
- g = (float)color.green / 65535.0;
- b = (float)color.blue / 65535.0;
- cairo_set_source_rgba (cr, r, g, b, MSD_OSD_WINDOW_FG_ALPHA / 2);
- cairo_set_line_width (cr, 1);
- cairo_stroke (cr);
+ gtk_render_background (context, cr, _x0, _y0, width, height);
+ gtk_render_frame (context, cr, _x0, _y0, width, height);
+
+ gtk_style_context_restore (context);
/* bar progress */
if (percentage < 0.01)
return;
- color = style->bg[GTK_STATE_NORMAL];
- r = (float)color.red / 65535.0;
- g = (float)color.green / 65535.0;
- b = (float)color.blue / 65535.0;
- msd_osd_window_draw_rounded_rectangle (cr, 1.0, _x0 + 0.5, _y0 + 0.5, height / 6 - 0.5, x1, height - 1);
- cairo_set_source_rgba (cr, r, g, b, MSD_OSD_WINDOW_FG_ALPHA);
- cairo_fill (cr);
+
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
+
+ gtk_render_background (context, cr, _x0 + 0.5, _y0 + 0.5, x1, height -1 );
+ gtk_render_frame (context, cr, _x0 + 0.5, _y0 + 0.5, x1, height -1 );
+
+ gtk_style_context_restore (context);
}
static void
@@ -471,19 +459,6 @@ draw_action_volume (MsdMediaKeysWindow *window,
volume_box_x0 = round (icon_box_x0);
volume_box_y0 = round (icon_box_height + icon_box_y0);
-#if 0
- g_message ("icon box: w=%f h=%f _x0=%f _y0=%f",
- icon_box_width,
- icon_box_height,
- icon_box_x0,
- icon_box_y0);
- g_message ("volume box: w=%f h=%f _x0=%f _y0=%f",
- volume_box_width,
- volume_box_height,
- volume_box_x0,
- volume_box_y0);
-#endif
-
res = render_speaker (window,
cr,
icon_box_x0, icon_box_y0,
@@ -645,11 +620,7 @@ draw_action_custom (MsdMediaKeysWindow *window,
}
static void
-#if GTK_CHECK_VERSION (3, 0, 0)
msd_media_keys_window_draw_when_composited (MsdOsdWindow *osd_window,
-#else
-msd_media_keys_window_expose_when_composited (MsdOsdWindow *osd_window,
-#endif
cairo_t *cr)
{
MsdMediaKeysWindow *window = MSD_MEDIA_KEYS_WINDOW (osd_window);
@@ -671,11 +642,7 @@ msd_media_keys_window_class_init (MsdMediaKeysWindowClass *klass)
{
MsdOsdWindowClass *osd_window_class = MSD_OSD_WINDOW_CLASS (klass);
-#if GTK_CHECK_VERSION (3, 0, 0)
osd_window_class->draw_when_composited = msd_media_keys_window_draw_when_composited;
-#else
- osd_window_class->expose_when_composited = msd_media_keys_window_expose_when_composited;
-#endif
g_type_class_add_private (klass, sizeof (MsdMediaKeysWindowPrivate));
}
diff --git a/src/msd-osd-window.c b/src/msd-osd-window.c
index 46dfebd..11c26d7 100644
--- a/src/msd-osd-window.c
+++ b/src/msd-osd-window.c
@@ -55,7 +55,7 @@ struct MsdOsdWindowPrivate
};
enum {
- EXPOSE_WHEN_COMPOSITED,
+ DRAW_WHEN_COMPOSITED,
LAST_SIGNAL
};
@@ -139,122 +139,27 @@ add_hide_timeout (MsdOsdWindow *window)
window);
}
-void
-msd_osd_window_draw_rounded_rectangle (cairo_t* cr,
- gdouble aspect,
- gdouble x,
- gdouble y,
- gdouble corner_radius,
- gdouble width,
- gdouble height)
-{
- gdouble radius = corner_radius / aspect;
-
- cairo_move_to (cr, x + radius, y);
-
- cairo_line_to (cr,
- x + width - radius,
- y);
- cairo_arc (cr,
- x + width - radius,
- y + radius,
- radius,
- -90.0f * G_PI / 180.0f,
- 0.0f * G_PI / 180.0f);
- cairo_line_to (cr,
- x + width,
- y + height - radius);
- cairo_arc (cr,
- x + width - radius,
- y + height - radius,
- radius,
- 0.0f * G_PI / 180.0f,
- 90.0f * G_PI / 180.0f);
- cairo_line_to (cr,
- x + radius,
- y + height);
- cairo_arc (cr,
- x + radius,
- y + height - radius,
- radius,
- 90.0f * G_PI / 180.0f,
- 180.0f * G_PI / 180.0f);
- cairo_line_to (cr,
- x,
- y + radius);
- cairo_arc (cr,
- x + radius,
- y + radius,
- radius,
- 180.0f * G_PI / 180.0f,
- 270.0f * G_PI / 180.0f);
- cairo_close_path (cr);
-}
-
-void
-msd_osd_window_color_reverse (const GdkColor *a,
- GdkColor *b)
-{
- gdouble red;
- gdouble green;
- gdouble blue;
- gdouble h;
- gdouble s;
- gdouble v;
-
- red = (gdouble) a->red / 65535.0;
- green = (gdouble) a->green / 65535.0;
- blue = (gdouble) a->blue / 65535.0;
-
- gtk_rgb_to_hsv (red, green, blue, &h, &s, &v);
-
- v = 0.5 + (0.5 - v);
- if (v > 1.0)
- v = 1.0;
- else if (v < 0.0)
- v = 0.0;
-
- gtk_hsv_to_rgb (h, s, v, &red, &green, &blue);
-
- b->red = red * 65535.0;
- b->green = green * 65535.0;
- b->blue = blue * 65535.0;
-}
-
-/* This is our expose-event handler when the window is in a compositing manager.
+/* This is our draw-event handler when the window is in a compositing manager.
* We draw everything by hand, using Cairo, so that we can have a nice
* transparent/rounded look.
*/
static void
-#if GTK_CHECK_VERSION (3, 0, 0)
-draw_when_composited (GtkWidget *widget, cairo_t *context)
-#else
-expose_when_composited (GtkWidget *widget, GdkEventExpose *event)
-#endif
+draw_when_composited (GtkWidget *widget, cairo_t *orig_cr)
{
MsdOsdWindow *window;
-#if !GTK_CHECK_VERSION (3, 0, 0)
- cairo_t *context;
-#endif
cairo_t *cr;
cairo_surface_t *surface;
int width;
int height;
- GtkStyle *style;
- GdkColor color;
- double r, g, b;
+ GtkStyleContext *context;
window = MSD_OSD_WINDOW (widget);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- context = gdk_cairo_create (gtk_widget_get_window (widget));
-#endif
-
- style = gtk_widget_get_style (widget);
- cairo_set_operator (context, CAIRO_OPERATOR_SOURCE);
+ context = gtk_widget_get_style_context (widget);
+ cairo_set_operator (orig_cr, CAIRO_OPERATOR_SOURCE);
gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
- surface = cairo_surface_create_similar (cairo_get_target (context),
+ surface = cairo_surface_create_similar (cairo_get_target (orig_cr),
CAIRO_CONTENT_COLOR_ALPHA,
width,
height);
@@ -267,137 +172,73 @@ expose_when_composited (GtkWidget *widget, GdkEventExpose *event)
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
goto done;
}
- cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_paint (cr);
-
- /* draw a box */
- msd_osd_window_draw_rounded_rectangle (cr, 1.0, 0.5, 0.5, height / 10, width-1, height-1);
- msd_osd_window_color_reverse (&style->bg[GTK_STATE_NORMAL], &color);
- r = (float)color.red / 65535.0;
- g = (float)color.green / 65535.0;
- b = (float)color.blue / 65535.0;
- cairo_set_source_rgba (cr, r, g, b, BG_ALPHA);
- cairo_fill_preserve (cr);
-
- msd_osd_window_color_reverse (&style->text_aa[GTK_STATE_NORMAL], &color);
- r = (float)color.red / 65535.0;
- g = (float)color.green / 65535.0;
- b = (float)color.blue / 65535.0;
- cairo_set_source_rgba (cr, r, g, b, BG_ALPHA / 2);
- cairo_set_line_width (cr, 1);
- cairo_stroke (cr);
-
- g_signal_emit (window, signals[EXPOSE_WHEN_COMPOSITED], 0, cr);
+
+ gtk_render_background (context, cr, 0, 0, width, height);
+ gtk_render_frame (context, cr, 0, 0, width, height);
+
+ g_signal_emit (window, signals[DRAW_WHEN_COMPOSITED], 0, cr);
cairo_destroy (cr);
/* Make sure we have a transparent background */
- cairo_rectangle (context, 0, 0, width, height);
- cairo_set_source_rgba (context, 0.0, 0.0, 0.0, 0.0);
- cairo_fill (context);
+ cairo_rectangle (orig_cr, 0, 0, width, height);
+ cairo_set_source_rgba (orig_cr, 0.0, 0.0, 0.0, 0.0);
+ cairo_fill (orig_cr);
- cairo_set_source_surface (context, surface, 0, 0);
- cairo_paint_with_alpha (context, window->priv->fade_out_alpha);
+ cairo_set_source_surface (orig_cr, surface, 0, 0);
+ cairo_paint_with_alpha (orig_cr, window->priv->fade_out_alpha);
- done:
+done:
if (surface != NULL) {
cairo_surface_destroy (surface);
}
-#if !GTK_CHECK_VERSION (3, 0, 0)
- cairo_destroy (context);
-#endif
}
-/* This is our expose-event handler when the window is *not* in a compositing manager.
+/* This is our expose/draw-event handler when the window is *not* in a compositing manager.
* We just draw a rectangular frame by hand. We do this with hardcoded drawing code,
* instead of GtkFrame, to avoid changing the window's internal widget hierarchy: in
* either case (composited or non-composited), callers can assume that this works
* identically to a GtkWindow without any intermediate widgetry.
*/
static void
-#if GTK_CHECK_VERSION (3, 0, 0)
draw_when_not_composited (GtkWidget *widget, cairo_t *cr)
-#else
-expose_when_not_composited (GtkWidget *widget, GdkEventExpose *event)
-#endif
{
- MsdOsdWindow *window;
-#if GTK_CHECK_VERSION (3, 0, 0)
- int width;
- int height;
-#else
- GtkAllocation allocation;
-#endif
-
- window = MSD_OSD_WINDOW (widget);
-
-#if GTK_CHECK_VERSION (3, 0, 0)
- width = gtk_widget_get_allocated_width (widget);
- height = gtk_widget_get_allocated_width (widget);
-#else
- gtk_widget_get_allocation (widget, &allocation);
-#endif
+ GtkStyleContext *context;
+ int width;
+ int height;
- gtk_paint_shadow (gtk_widget_get_style (widget),
-#if GTK_CHECK_VERSION (3, 0, 0)
- cr,
-#else
- gtk_widget_get_window (widget),
-#endif
- gtk_widget_get_state (widget),
- GTK_SHADOW_OUT,
-#if !GTK_CHECK_VERSION (3, 0, 0)
- &event->area,
-#endif
- widget,
- NULL, /* NULL detail -> themes should use the MsdOsdWindow widget name, probably */
- 0,
- 0,
-#if GTK_CHECK_VERSION (3, 0, 0)
- width,
- height);
-#else
- allocation.width,
- allocation.height);
-#endif
+ gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
+ context = gtk_widget_get_style_context (widget);
+
+ gtk_style_context_set_state (context, GTK_STATE_FLAG_ACTIVE);
+ gtk_style_context_add_class(context,"msd-osd-window-solid");
+ gtk_render_frame (context,
+ cr,
+ 0,
+ 0,
+ width,
+ height);
}
static gboolean
-#if GTK_CHECK_VERSION (3, 0, 0)
msd_osd_window_draw (GtkWidget *widget,
- cairo_t *cr)
-#else
-msd_osd_window_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
-#endif
+ cairo_t *cr)
{
MsdOsdWindow *window;
GtkWidget *child;
window = MSD_OSD_WINDOW (widget);
-#if GTK_CHECK_VERSION (3, 0, 0)
if (window->priv->is_composited)
draw_when_composited (widget, cr);
else
draw_when_not_composited (widget, cr);
-#else
- if (window->priv->is_composited)
- expose_when_composited (widget, event);
- else
- expose_when_not_composited (widget, event);
-#endif
child = gtk_bin_get_child (GTK_BIN (window));
if (child)
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_container_propagate_draw (GTK_CONTAINER (window), child, cr);
-#else
- gtk_container_propagate_expose (GTK_CONTAINER (window), child, event);
-#endif
- return FALSE;
+ return FALSE;
}
static void
@@ -430,129 +271,84 @@ msd_osd_window_real_hide (GtkWidget *widget)
static void
msd_osd_window_real_realize (GtkWidget *widget)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkScreen *screen;
GdkVisual *visual;
cairo_region_t *region;
-#else
- GdkColormap *colormap;
- GtkAllocation allocation;
- GdkBitmap *mask;
- cairo_t *cr;
-#endif
-#if GTK_CHECK_VERSION (3, 0, 0)
screen = gtk_widget_get_screen (widget);
visual = gdk_screen_get_rgba_visual (screen);
if (visual == NULL) {
visual = gdk_screen_get_system_visual (screen);
}
- gtk_widget_set_visual (widget, visual);
-#else
- colormap = gdk_screen_get_rgba_colormap (gtk_widget_get_screen (widget));
- if (colormap != NULL) {
- gtk_widget_set_colormap (widget, colormap);
- }
-#endif
+ gtk_widget_set_visual (widget, visual);
if (GTK_WIDGET_CLASS (msd_osd_window_parent_class)->realize) {
GTK_WIDGET_CLASS (msd_osd_window_parent_class)->realize (widget);
}
-#if GTK_CHECK_VERSION (3, 0, 0)
/* make the whole window ignore events */
region = cairo_region_create ();
gtk_widget_input_shape_combine_region (widget, region);
cairo_region_destroy (region);
-#else
- gtk_widget_get_allocation (widget, &allocation);
- mask = gdk_pixmap_new (gtk_widget_get_window (widget),
- allocation.width,
- allocation.height,
- 1);
- cr = gdk_cairo_create (mask);
-
- cairo_set_source_rgba (cr, 1., 1., 1., 0.);
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- cairo_paint (cr);
-
- /* make the whole window ignore events */
- gdk_window_input_shape_combine_mask (gtk_widget_get_window (widget), mask, 0, 0);
- g_object_unref (mask);
- cairo_destroy (cr);
-#endif
}
static void
-msd_osd_window_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
+msd_osd_window_style_updated (GtkWidget *widget)
{
- GtkStyle *style;
+ GtkStyleContext *context;
+ GtkBorder padding;
- GTK_WIDGET_CLASS (msd_osd_window_parent_class)->style_set (widget, previous_style);
+ GTK_WIDGET_CLASS (msd_osd_window_parent_class)->style_updated (widget);
/* We set our border width to 12 (per the MATE standard), plus the
- * thickness of the frame that we draw in our expose handler. This will
+ * padding of the frame that we draw in our expose handler. This will
* make our child be 12 pixels away from the frame.
*/
- style = gtk_widget_get_style (widget);
- gtk_container_set_border_width (GTK_CONTAINER (widget), 12 + MAX (style->xthickness, style->ythickness));
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &padding);
+ gtk_container_set_border_width (GTK_CONTAINER (widget), 12 + MAX (padding.left, padding.top));
}
-#if GTK_CHECK_VERSION (3, 0, 0)
static void
msd_osd_window_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
+ gint *minimum,
+ gint *natural)
{
- GtkStyle *style;
+ GtkStyleContext *context;
+ GtkBorder padding;
- GTK_WIDGET_CLASS (msd_osd_window_parent_class)->get_preferred_width (widget, minimum_width, natural_width);
+ GTK_WIDGET_CLASS (msd_osd_window_parent_class)->get_preferred_width (widget, minimum, natural);
- /* See the comment in msd_osd_window_style_set() for why we add the thickness here */
+ /* See the comment in msd_osd_window_style_updated() for why we add the padding here */
- style = gtk_widget_get_style (widget);
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &padding);
- *minimum_width += style->xthickness;
- *natural_width += style->xthickness;
+ *minimum += padding.left;
+ *natural += padding.left;
}
static void
msd_osd_window_get_preferred_height (GtkWidget *widget,
- gint *minimum_height,
- gint *natural_height)
+ gint *minimum,
+ gint *natural)
{
- GtkStyle *style;
+ GtkStyleContext *context;
+ GtkBorder padding;
- GTK_WIDGET_CLASS (msd_osd_window_parent_class)->get_preferred_height (widget, minimum_height, natural_height);
+ GTK_WIDGET_CLASS (msd_osd_window_parent_class)->get_preferred_height (widget, minimum, natural);
- /* See the comment in msd_osd_window_style_set() for why we add the thickness here */
+ /* See the comment in msd_osd_window_style_updated() for why we add the padding here */
- style = gtk_widget_get_style (widget);
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &padding);
- *minimum_height += style->ythickness;
- *natural_height += style->ythickness;
+ *minimum += padding.top;
+ *natural += padding.top;
}
-#else
-static void
-msd_osd_window_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GtkStyle *style;
-
- GTK_WIDGET_CLASS (msd_osd_window_parent_class)->size_request (widget, requisition);
-
- /* See the comment in msd_osd_window_style_set() for why we add the thickness here */
-
- style = gtk_widget_get_style (widget);
-
- requisition->width += style->xthickness;
- requisition->height += style->ythickness;
-}
-#endif
static GObject *
msd_osd_window_constructor (GType type,
@@ -571,6 +367,10 @@ msd_osd_window_constructor (GType type,
"focus-on-map", FALSE,
NULL);
+ GtkWidget *widget = GTK_WIDGET (object);
+ GtkStyleContext *style_context = gtk_widget_get_style_context (widget);
+ gtk_style_context_add_class (style_context, "osd");
+
return object;
}
@@ -585,33 +385,23 @@ msd_osd_window_class_init (MsdOsdWindowClass *klass)
widget_class->show = msd_osd_window_real_show;
widget_class->hide = msd_osd_window_real_hide;
widget_class->realize = msd_osd_window_real_realize;
- widget_class->style_set = msd_osd_window_style_set;
-#if GTK_CHECK_VERSION (3, 0, 0)
+ widget_class->style_updated = msd_osd_window_style_updated;
widget_class->get_preferred_width = msd_osd_window_get_preferred_width;
widget_class->get_preferred_height = msd_osd_window_get_preferred_height;
widget_class->draw = msd_osd_window_draw;
-#else
- widget_class->size_request = msd_osd_window_size_request;
- widget_class->expose_event = msd_osd_window_expose_event;
-#endif
-#if GTK_CHECK_VERSION (3, 0, 0)
- signals[EXPOSE_WHEN_COMPOSITED] = g_signal_new ("draw-when-composited",
-#else
- signals[EXPOSE_WHEN_COMPOSITED] = g_signal_new ("expose-when-composited",
-#endif
+ signals[DRAW_WHEN_COMPOSITED] = g_signal_new ("draw-when-composited",
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
-#if GTK_CHECK_VERSION (3, 0, 0)
G_STRUCT_OFFSET (MsdOsdWindowClass, draw_when_composited),
-#else
- G_STRUCT_OFFSET (MsdOsdWindowClass, expose_when_composited),
-#endif
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
+#if GTK_CHECK_VERSION (3, 20, 0)
+ gtk_widget_class_set_css_name (widget_class, "MsdOsdWindow");
+#endif
g_type_class_add_private (klass, sizeof (MsdOsdWindowPrivate));
}
@@ -659,6 +449,9 @@ msd_osd_window_init (MsdOsdWindow *window)
gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
+ GtkStyleContext *style = gtk_widget_get_style_context (GTK_WIDGET (window));
+ gtk_style_context_add_class (style, "window-frame");
+
/* assume 130x130 on a 640x480 display and scale from there */
scalew = gdk_screen_get_width (screen) / 640.0;
scaleh = gdk_screen_get_height (screen) / 480.0;
diff --git a/src/msd-osd-window.h b/src/msd-osd-window.h
index fd33d36..ac3325a 100644
--- a/src/msd-osd-window.h
+++ b/src/msd-osd-window.h
@@ -70,11 +70,7 @@ struct MsdOsdWindow {
struct MsdOsdWindowClass {
GtkWindowClass parent_class;
-#if GTK_CHECK_VERSION (3, 0, 0)
void (* draw_when_composited) (MsdOsdWindow *window, cairo_t *cr);
-#else
- void (* expose_when_composited) (MsdOsdWindow *window, cairo_t *cr);
-#endif
};
GType msd_osd_window_get_type (void);
@@ -84,17 +80,6 @@ gboolean msd_osd_window_is_composited (MsdOsdWindow *windo
gboolean msd_osd_window_is_valid (MsdOsdWindow *window);
void msd_osd_window_update_and_hide (MsdOsdWindow *window);
-void msd_osd_window_draw_rounded_rectangle (cairo_t *cr,
- gdouble aspect,
- gdouble x,
- gdouble y,
- gdouble corner_radius,
- gdouble width,
- gdouble height);
-
-void msd_osd_window_color_reverse (const GdkColor *a,
- GdkColor *b);
-
#ifdef __cplusplus
}
#endif