[gpm] Resend of patches to add osd for keyboard backlight
- From: Alex Murray <murray alex gmail com>
- To: gnome-power-manager-list gnome org
- Subject: [gpm] Resend of patches to add osd for keyboard backlight
- Date: Thu, 3 Mar 2011 09:25:45 +1030
Resending of patches sent previously but this time sending as attachments.
The first patch adds on-screen-display of keyboard brightness level
(which is basically copied and pasted from that in gpm-brightness).
The second patch then gets rid of this duplicated code and unifies it
out into a separate file - gpm-osd-dialog.[ch]
Cheers,
Alex
From 44f648590611935c78ca11d591c24e29f7026f9e Mon Sep 17 00:00:00 2001
From: Alex Murray <murray alex gmail com>
Date: Sat, 26 Feb 2011 09:41:57 +1030
Subject: [PATCH 1/2] Add on screen display of keyboard brightness level
Signed-off-by: Alex Murray <murray alex gmail com>
---
src/gpm-kbd-backlight.c | 116 +++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 112 insertions(+), 4 deletions(-)
diff --git a/src/gpm-kbd-backlight.c b/src/gpm-kbd-backlight.c
index e640ad6..6478172 100644
--- a/src/gpm-kbd-backlight.c
+++ b/src/gpm-kbd-backlight.c
@@ -25,6 +25,7 @@
#include "gpm-button.h"
#include "gpm-common.h"
+#include "gsd-media-keys-window.h"
#include "gpm-control.h"
#include "gpm-idle.h"
#include "gpm-kbd-backlight.h"
@@ -52,6 +53,7 @@ struct GpmKbdBacklightPrivate
GpmButton *button;
GSettings *settings;
GSettings *settings_gsd;
+ GtkWidget *popup;
GpmControl *control;
GpmIdle *idle;
gboolean can_dim;
@@ -376,6 +378,97 @@ gpm_kbd_backlight_register_dbus (GpmKbdBacklight *backlight,
g_dbus_node_info_unref (node_info);
}
+/**
+ * gpm_kbd_backlight_dialog_init:
+ *
+ * Initialises the popup, and makes sure that it matches the compositing of the screen.
+ **/
+static void
+gpm_kbd_backlight_dialog_init (GpmKbdBacklight *backlight)
+{
+ if (backlight->priv->popup != NULL
+ && !gsd_osd_window_is_valid (GSD_OSD_WINDOW (backlight->priv->popup))) {
+ gtk_widget_destroy (backlight->priv->popup);
+ backlight->priv->popup = NULL;
+ }
+
+ if (backlight->priv->popup == NULL) {
+ backlight->priv->popup= gsd_media_keys_window_new ();
+ gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
+ "gpm-brightness-kbd",
+ TRUE);
+ gtk_window_set_position (GTK_WINDOW (backlight->priv->popup), GTK_WIN_POS_NONE);
+ }
+}
+
+/**
+ * gpm_kbd_backlight_dialog_show:
+ *
+ * Show the brightness popup, and place it nicely on the screen.
+ **/
+static void
+gpm_kbd_backlight_dialog_show (GpmKbdBacklight *backlight)
+{
+ int orig_w;
+ int orig_h;
+ int screen_w;
+ int screen_h;
+ int x;
+ int y;
+ int pointer_x;
+ int pointer_y;
+ GtkRequisition win_req;
+ GdkScreen *pointer_screen;
+ GdkRectangle geometry;
+ int monitor;
+ GdkDisplay *display;
+ GdkDeviceManager *device_manager;
+ GdkDevice *device;
+
+ /*
+ * get the window size
+ * if the window hasn't been mapped, it doesn't necessarily
+ * 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_get_preferred_size(backlight->priv->popup, &win_req, NULL);
+
+ if (win_req.width > orig_w) {
+ orig_w = win_req.width;
+ }
+ if (win_req.height > orig_h) {
+ orig_h = win_req.height;
+ }
+
+ pointer_screen = NULL;
+ 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);
+ monitor = gdk_screen_get_monitor_at_point (pointer_screen,
+ pointer_x,
+ pointer_y);
+
+ gdk_screen_get_monitor_geometry (pointer_screen,
+ monitor,
+ &geometry);
+
+ screen_w = geometry.width;
+ screen_h = geometry.height;
+
+ x = ((screen_w - orig_w) / 2) + geometry.x;
+ y = geometry.y + (screen_h / 2) + (screen_h / 2 - orig_h) / 2;
+
+ gtk_window_move (GTK_WINDOW (backlight->priv->popup), x, y);
+
+ gtk_widget_show (backlight->priv->popup);
+
+ gdk_display_sync (gtk_widget_get_display (backlight->priv->popup));
+}
+
static gboolean
gpm_kbd_backlight_evaluate_power_source_and_set (GpmKbdBacklight *backlight)
{
@@ -461,25 +554,32 @@ gpm_kbd_backlight_button_pressed_cb (GpmButton *button,
GpmKbdBacklight *backlight)
{
static guint saved_brightness;
+ gboolean ret = FALSE;
saved_brightness = backlight->priv->master_percentage;
if (g_strcmp0 (type, GPM_BUTTON_KBD_BRIGHT_UP) == 0) {
- gpm_kbd_backlight_brightness_up (backlight);
+ ret = gpm_kbd_backlight_brightness_up (backlight);
} else if (g_strcmp0 (type, GPM_BUTTON_KBD_BRIGHT_DOWN) == 0) {
- gpm_kbd_backlight_brightness_down (backlight);
+ ret = gpm_kbd_backlight_brightness_down (backlight);
} else if (g_strcmp0 (type, GPM_BUTTON_KBD_BRIGHT_TOGGLE) == 0) {
if (backlight->priv->master_percentage == 0) {
/* backlight is off turn it back on */
- gpm_kbd_backlight_set (backlight, saved_brightness);
+ ret = gpm_kbd_backlight_set (backlight, saved_brightness);
} else {
/* backlight is on, turn it off and save current value */
saved_brightness = backlight->priv->master_percentage;
- gpm_kbd_backlight_set (backlight, 0);
+ ret = gpm_kbd_backlight_set (backlight, 0);
}
}
+ if (ret) {
+ gpm_kbd_backlight_dialog_init (backlight);
+ gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
+ backlight->priv->brightness_percent);
+ gpm_kbd_backlight_dialog_show (backlight);
+ }
}
/**
@@ -568,6 +668,7 @@ gpm_kbd_backlight_finalize (GObject *object)
}
g_timer_destroy (backlight->priv->idle_timer);
+ gtk_widget_destroy (backlight->priv->popup);
g_object_unref (backlight->priv->control);
g_object_unref (backlight->priv->settings);
@@ -711,6 +812,13 @@ noerr:
backlight->priv->idle_dim_timeout = g_settings_get_int (backlight->priv->settings_gsd, GSD_SETTINGS_IDLE_DIM_TIME);
gpm_idle_set_timeout_dim (backlight->priv->idle, backlight->priv->idle_dim_timeout);
+ /* use a visual widget */
+ backlight->priv->popup = gsd_media_keys_window_new ();
+ gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
+ "gpm-brightness-kbd",
+ TRUE);
+
+ gtk_window_set_position (GTK_WINDOW (backlight->priv->popup), GTK_WIN_POS_NONE);
/* make sure we turn the keyboard backlight back on after resuming */
backlight->priv->control = gpm_control_new ();
g_signal_connect (backlight->priv->control, "resume",
--
1.7.1
From f347a22c23c280c1b6c4f3055448452a06ee53f4 Mon Sep 17 00:00:00 2001
From: Alex Murray <murray alex gmail com>
Date: Sat, 26 Feb 2011 11:55:31 +1030
Subject: [PATCH 2/2] Unify osd popup dialog into separate file to avoid code duplication
Signed-off-by: Alex Murray <murray alex gmail com>
---
src/Makefile.am | 2 +
src/gpm-backlight.c | 111 +++------------------------------------------
src/gpm-kbd-backlight.c | 103 ++----------------------------------------
src/gpm-osd-dialog.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++
src/gpm-osd-dialog.h | 31 +++++++++++++
5 files changed, 160 insertions(+), 202 deletions(-)
create mode 100644 src/gpm-osd-dialog.c
create mode 100644 src/gpm-osd-dialog.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 009e7a8..73d184b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -91,6 +91,8 @@ gnome_power_manager_SOURCES = \
gpm-dpms.c \
gpm-phone.h \
gpm-phone.c \
+ gpm-osd-dialog.h \
+ gpm-osd-dialog.c \
gpm-backlight.h \
gpm-backlight.c \
gpm-idle.h \
diff --git a/src/gpm-backlight.c b/src/gpm-backlight.c
index 49ae9e1..e6e5494 100644
--- a/src/gpm-backlight.c
+++ b/src/gpm-backlight.c
@@ -45,7 +45,7 @@
#include "gpm-brightness.h"
#include "gpm-control.h"
#include "gpm-common.h"
-#include "gsd-media-keys-window.h"
+#include "gpm-osd-dialog.h"
#include "gpm-dpms.h"
#include "gpm-idle.h"
#include "gpm-marshal.h"
@@ -184,97 +184,6 @@ gpm_backlight_set_brightness (GpmBacklight *backlight, guint percentage, GError
}
/**
- * gpm_backlight_dialog_init:
- *
- * Initialises the popup, and makes sure that it matches the compositing of the screen.
- **/
-static void
-gpm_backlight_dialog_init (GpmBacklight *backlight)
-{
- if (backlight->priv->popup != NULL
- && !gsd_osd_window_is_valid (GSD_OSD_WINDOW (backlight->priv->popup))) {
- gtk_widget_destroy (backlight->priv->popup);
- backlight->priv->popup = NULL;
- }
-
- if (backlight->priv->popup == NULL) {
- backlight->priv->popup= gsd_media_keys_window_new ();
- gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
- "gpm-brightness-lcd",
- TRUE);
- gtk_window_set_position (GTK_WINDOW (backlight->priv->popup), GTK_WIN_POS_NONE);
- }
-}
-
-/**
- * gpm_backlight_dialog_show:
- *
- * Show the brightness popup, and place it nicely on the screen.
- **/
-static void
-gpm_backlight_dialog_show (GpmBacklight *backlight)
-{
- int orig_w;
- int orig_h;
- int screen_w;
- int screen_h;
- int x;
- int y;
- int pointer_x;
- int pointer_y;
- GtkRequisition win_req;
- GdkScreen *pointer_screen;
- GdkRectangle geometry;
- int monitor;
- GdkDisplay *display;
- GdkDeviceManager *device_manager;
- GdkDevice *device;
-
- /*
- * get the window size
- * if the window hasn't been mapped, it doesn't necessarily
- * 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_get_preferred_size(backlight->priv->popup, &win_req, NULL);
-
- if (win_req.width > orig_w) {
- orig_w = win_req.width;
- }
- if (win_req.height > orig_h) {
- orig_h = win_req.height;
- }
-
- pointer_screen = NULL;
- 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);
- monitor = gdk_screen_get_monitor_at_point (pointer_screen,
- pointer_x,
- pointer_y);
-
- gdk_screen_get_monitor_geometry (pointer_screen,
- monitor,
- &geometry);
-
- screen_w = geometry.width;
- screen_h = geometry.height;
-
- x = ((screen_w - orig_w) / 2) + geometry.x;
- y = geometry.y + (screen_h / 2) + (screen_h / 2 - orig_h) / 2;
-
- gtk_window_move (GTK_WINDOW (backlight->priv->popup), x, y);
-
- gtk_widget_show (backlight->priv->popup);
-
- gdk_display_sync (gtk_widget_get_display (backlight->priv->popup));
-}
-
-/**
* gpm_common_sum_scale:
*
* Finds the average between value1 and value2 set on a scale factor
@@ -369,10 +278,10 @@ gpm_backlight_brightness_evaluate_and_set (GpmBacklight *backlight, gboolean int
/* only show dialog if interactive */
if (interactive) {
- gpm_backlight_dialog_init (backlight);
+ gpm_osd_dialog_init (&backlight->priv->popup, "gpm-brightness-lcd");
gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
round (brightness));
- gpm_backlight_dialog_show (backlight);
+ gpm_osd_dialog_show (backlight->priv->popup);
}
ret = gpm_brightness_set (backlight->priv->brightness, value, &hw_changed);
@@ -457,10 +366,10 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli
/* show the new value */
if (ret) {
gpm_brightness_get (backlight->priv->brightness, &percentage);
- gpm_backlight_dialog_init (backlight);
+ gpm_osd_dialog_init (&backlight->priv->popup, "gpm-brightness-lcd");
gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
percentage);
- gpm_backlight_dialog_show (backlight);
+ gpm_osd_dialog_show (backlight->priv->popup);
/* save the new percentage */
backlight->priv->master_percentage = percentage;
}
@@ -476,10 +385,10 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli
/* show the new value */
if (ret) {
gpm_brightness_get (backlight->priv->brightness, &percentage);
- gpm_backlight_dialog_init (backlight);
+ gpm_osd_dialog_init (&backlight->priv->popup, "gpm-brightness-lcd");
gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
percentage);
- gpm_backlight_dialog_show (backlight);
+ gpm_osd_dialog_show (backlight->priv->popup);
/* save the new percentage */
backlight->priv->master_percentage = percentage;
}
@@ -876,11 +785,7 @@ gpm_backlight_init (GpmBacklight *backlight)
gpm_idle_set_timeout_dim (backlight->priv->idle, backlight->priv->idle_dim_timeout);
/* use a visual widget */
- backlight->priv->popup = gsd_media_keys_window_new ();
- gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
- "gpm-brightness-lcd",
- TRUE);
- gtk_window_set_position (GTK_WINDOW (backlight->priv->popup), GTK_WIN_POS_NONE);
+ gpm_osd_dialog_init (&backlight->priv->popup, "gpm-brightness-lcd");
/* DPMS mode poll class */
backlight->priv->dpms = gpm_dpms_new ();
diff --git a/src/gpm-kbd-backlight.c b/src/gpm-kbd-backlight.c
index 6478172..3e06f35 100644
--- a/src/gpm-kbd-backlight.c
+++ b/src/gpm-kbd-backlight.c
@@ -25,7 +25,7 @@
#include "gpm-button.h"
#include "gpm-common.h"
-#include "gsd-media-keys-window.h"
+#include "gpm-osd-dialog.h"
#include "gpm-control.h"
#include "gpm-idle.h"
#include "gpm-kbd-backlight.h"
@@ -378,97 +378,6 @@ gpm_kbd_backlight_register_dbus (GpmKbdBacklight *backlight,
g_dbus_node_info_unref (node_info);
}
-/**
- * gpm_kbd_backlight_dialog_init:
- *
- * Initialises the popup, and makes sure that it matches the compositing of the screen.
- **/
-static void
-gpm_kbd_backlight_dialog_init (GpmKbdBacklight *backlight)
-{
- if (backlight->priv->popup != NULL
- && !gsd_osd_window_is_valid (GSD_OSD_WINDOW (backlight->priv->popup))) {
- gtk_widget_destroy (backlight->priv->popup);
- backlight->priv->popup = NULL;
- }
-
- if (backlight->priv->popup == NULL) {
- backlight->priv->popup= gsd_media_keys_window_new ();
- gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
- "gpm-brightness-kbd",
- TRUE);
- gtk_window_set_position (GTK_WINDOW (backlight->priv->popup), GTK_WIN_POS_NONE);
- }
-}
-
-/**
- * gpm_kbd_backlight_dialog_show:
- *
- * Show the brightness popup, and place it nicely on the screen.
- **/
-static void
-gpm_kbd_backlight_dialog_show (GpmKbdBacklight *backlight)
-{
- int orig_w;
- int orig_h;
- int screen_w;
- int screen_h;
- int x;
- int y;
- int pointer_x;
- int pointer_y;
- GtkRequisition win_req;
- GdkScreen *pointer_screen;
- GdkRectangle geometry;
- int monitor;
- GdkDisplay *display;
- GdkDeviceManager *device_manager;
- GdkDevice *device;
-
- /*
- * get the window size
- * if the window hasn't been mapped, it doesn't necessarily
- * 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_get_preferred_size(backlight->priv->popup, &win_req, NULL);
-
- if (win_req.width > orig_w) {
- orig_w = win_req.width;
- }
- if (win_req.height > orig_h) {
- orig_h = win_req.height;
- }
-
- pointer_screen = NULL;
- 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);
- monitor = gdk_screen_get_monitor_at_point (pointer_screen,
- pointer_x,
- pointer_y);
-
- gdk_screen_get_monitor_geometry (pointer_screen,
- monitor,
- &geometry);
-
- screen_w = geometry.width;
- screen_h = geometry.height;
-
- x = ((screen_w - orig_w) / 2) + geometry.x;
- y = geometry.y + (screen_h / 2) + (screen_h / 2 - orig_h) / 2;
-
- gtk_window_move (GTK_WINDOW (backlight->priv->popup), x, y);
-
- gtk_widget_show (backlight->priv->popup);
-
- gdk_display_sync (gtk_widget_get_display (backlight->priv->popup));
-}
-
static gboolean
gpm_kbd_backlight_evaluate_power_source_and_set (GpmKbdBacklight *backlight)
{
@@ -575,10 +484,10 @@ gpm_kbd_backlight_button_pressed_cb (GpmButton *button,
}
}
if (ret) {
- gpm_kbd_backlight_dialog_init (backlight);
+ gpm_osd_dialog_init (&backlight->priv->popup, "gpm-brightness-kbd");
gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
backlight->priv->brightness_percent);
- gpm_kbd_backlight_dialog_show (backlight);
+ gpm_osd_dialog_show (backlight->priv->popup);
}
}
@@ -813,12 +722,8 @@ noerr:
gpm_idle_set_timeout_dim (backlight->priv->idle, backlight->priv->idle_dim_timeout);
/* use a visual widget */
- backlight->priv->popup = gsd_media_keys_window_new ();
- gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
- "gpm-brightness-kbd",
- TRUE);
+ gpm_osd_dialog_init(&backlight->priv->popup, "gpm-brightness-kbd");
- gtk_window_set_position (GTK_WINDOW (backlight->priv->popup), GTK_WIN_POS_NONE);
/* make sure we turn the keyboard backlight back on after resuming */
backlight->priv->control = gpm_control_new ();
g_signal_connect (backlight->priv->control, "resume",
diff --git a/src/gpm-osd-dialog.c b/src/gpm-osd-dialog.c
new file mode 100644
index 0000000..927efb4
--- /dev/null
+++ b/src/gpm-osd-dialog.c
@@ -0,0 +1,115 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2011 Alex Murray <murray alex gmail com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "gpm-osd-dialog.h"
+
+/**
+ * gpm_osd_dialog_init:
+ *
+ * Initialises a popup dialog, and makes sure that it matches the compositing of the screen.
+ **/
+void
+gpm_osd_dialog_init (GtkWidget **popup,
+ const gchar *icon_name)
+{
+ if (*popup != NULL
+ && !gsd_osd_window_is_valid (GSD_OSD_WINDOW (*popup))) {
+ gtk_widget_destroy (*popup);
+ *popup = NULL;
+ }
+
+ if (*popup == NULL) {
+ *popup= gsd_media_keys_window_new ();
+ gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (*popup),
+ icon_name,
+ TRUE);
+ gtk_window_set_position (GTK_WINDOW (*popup), GTK_WIN_POS_NONE);
+ }
+}
+
+/**
+ * gpm_osd_dialog_show:
+ *
+ * Show the brightness popup, and place it nicely on the screen.
+ **/
+void
+gpm_osd_dialog_show (GtkWidget *popup)
+{
+ int orig_w;
+ int orig_h;
+ int screen_w;
+ int screen_h;
+ int x;
+ int y;
+ int pointer_x;
+ int pointer_y;
+ GtkRequisition win_req;
+ GdkScreen *pointer_screen;
+ GdkRectangle geometry;
+ int monitor;
+ GdkDisplay *display;
+ GdkDeviceManager *device_manager;
+ GdkDevice *device;
+
+ /*
+ * get the window size
+ * if the window hasn't been mapped, it doesn't necessarily
+ * know its true size, yet, so we need to jump through hoops
+ */
+ gtk_window_get_default_size (GTK_WINDOW (popup), &orig_w, &orig_h);
+ gtk_widget_get_preferred_size(popup, &win_req, NULL);
+
+ if (win_req.width > orig_w) {
+ orig_w = win_req.width;
+ }
+ if (win_req.height > orig_h) {
+ orig_h = win_req.height;
+ }
+
+ pointer_screen = NULL;
+ display = gtk_widget_get_display (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);
+ monitor = gdk_screen_get_monitor_at_point (pointer_screen,
+ pointer_x,
+ pointer_y);
+
+ gdk_screen_get_monitor_geometry (pointer_screen,
+ monitor,
+ &geometry);
+
+ screen_w = geometry.width;
+ screen_h = geometry.height;
+
+ x = ((screen_w - orig_w) / 2) + geometry.x;
+ y = geometry.y + (screen_h / 2) + (screen_h / 2 - orig_h) / 2;
+
+ gtk_window_move (GTK_WINDOW (popup), x, y);
+
+ gtk_widget_show (popup);
+
+ gdk_display_sync (gtk_widget_get_display (popup));
+}
+
diff --git a/src/gpm-osd-dialog.h b/src/gpm-osd-dialog.h
new file mode 100644
index 0000000..77104c7
--- /dev/null
+++ b/src/gpm-osd-dialog.h
@@ -0,0 +1,31 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2011 Alex Murray <murray alex gmail com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPM_OSD_DIALOG_H
+#define __GPM_OSD_DIALOG_H
+
+#include "gsd-media-keys-window.h"
+
+void gpm_osd_dialog_init (GtkWidget **popup,
+ const gchar *icon_name);
+void gpm_osd_dialog_show (GtkWidget *popup);
+
+#endif /* __GPM_OSD_DIALOG_H */
--
1.7.1
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]