[gnome-power-manager] Add a GConf key to show or hide the sleep quirk site
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-power-manager] Add a GConf key to show or hide the sleep quirk site
- Date: Thu, 23 Jul 2009 07:16:06 +0000 (UTC)
commit 5c01e6357d22624e6dbf24fd1f5c2306e78f9540
Author: Richard Hughes <richard hughsie com>
Date: Thu Jul 23 08:16:00 2009 +0100
Add a GConf key to show or hide the sleep quirk site
data/gnome-power-manager.schemas.in | 12 +++++++++
src/gpm-common.h | 1 +
src/gpm-manager.c | 46 +++++++++++++++++++++++++++++++---
3 files changed, 55 insertions(+), 4 deletions(-)
---
diff --git a/data/gnome-power-manager.schemas.in b/data/gnome-power-manager.schemas.in
index e8336bb..eafa45a 100644
--- a/data/gnome-power-manager.schemas.in
+++ b/data/gnome-power-manager.schemas.in
@@ -528,6 +528,18 @@
</schema>
<schema>
+ <key>/schemas/apps/gnome-power-manager/notify/sleep_failed_uri</key>
+ <applyto>/apps/gnome-power-manager/notify/sleep_failed_uri</applyto>
+ <owner>gnome-power-manager</owner>
+ <type>string</type>
+ <default>http://people.freedesktop.org/~hughsient/quirk/</default>
+ <locale name="C">
+ <short>The URI to show to the user on sleep failure</short>
+ <long>When sleep fails we can show the user a button to help fix the situation. Leave this blank if the button should not be shown.</long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/gnome-power-manager/notify/low_power</key>
<applyto>/apps/gnome-power-manager/notify/low_power</applyto>
<owner>gnome-power-manager</owner>
diff --git a/src/gpm-common.h b/src/gpm-common.h
index fb30a19..373466a 100644
--- a/src/gpm-common.h
+++ b/src/gpm-common.h
@@ -115,6 +115,7 @@ G_BEGIN_DECLS
#define GPM_CONF_NOTIFY_DISCHARGING GPM_CONF_DIR "/notify/discharging"
#define GPM_CONF_NOTIFY_FULLY_CHARGED GPM_CONF_DIR "/notify/fully_charged"
#define GPM_CONF_NOTIFY_SLEEP_FAILED GPM_CONF_DIR "/notify/sleep_failed"
+#define GPM_CONF_NOTIFY_SLEEP_FAILED_URI GPM_CONF_DIR "/notify/sleep_failed_uri"
#define GPM_CONF_NOTIFY_LOW_POWER GPM_CONF_DIR "/notify/low_power"
#define GPM_CONF_NOTIFY_ESTIMATED_DATA GPM_CONF_DIR "/notify/estimated_data"
#define GPM_CONF_NOTIFY_INHIBIT_LID GPM_CONF_DIR "/notify/inhibit_lid"
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index 33c3850..1e9154c 100644
--- a/src/gpm-manager.c
+++ b/src/gpm-manager.c
@@ -1211,14 +1211,44 @@ out:
}
/**
- * control_sleep_failure_cb:
+ * gpm_manager_sleep_failure_response_cb:
**/
static void
-control_sleep_failure_cb (GpmControl *control, GpmControlAction action, GpmManager *manager)
+gpm_manager_sleep_failure_response_cb (GtkDialog *dialog, gint response_id, GpmManager *manager)
+{
+ GdkScreen *screen;
+ GtkWidget *dialog_error;
+ GError *error = NULL;
+ gboolean ret;
+ gchar *uri = NULL;
+
+ /* user clicked the help button */
+ if (response_id == GTK_RESPONSE_HELP) {
+ uri = gconf_client_get_string (manager->priv->conf, GPM_CONF_NOTIFY_SLEEP_FAILED_URI, NULL);
+ screen = gdk_screen_get_default();
+ ret = gtk_show_uri (screen, uri, gtk_get_current_event_time (), &error);
+ if (!ret) {
+ dialog_error = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
+ "Failed to show uri %s", error->message);
+ gtk_dialog_run (GTK_DIALOG (dialog_error));
+ g_error_free (error);
+ }
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_free (uri);
+}
+
+/**
+ * gpm_manager_sleep_failure_cb:
+ **/
+static void
+gpm_manager_sleep_failure_cb (GpmControl *control, GpmControlAction action, GpmManager *manager)
{
gboolean show_sleep_failed;
gchar *message = NULL;
gchar *title = NULL;
+ gchar *uri = NULL;
const gchar *icon;
GtkWidget *dialog;
@@ -1250,10 +1280,18 @@ control_sleep_failure_cb (GpmControl *control, GpmControlAction action, GpmManag
"<span size='larger'><b>%s</b></span>", title);
gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", message);
+ /* show a button? */
+ uri = gconf_client_get_string (manager->priv->conf, GPM_CONF_NOTIFY_SLEEP_FAILED_URI, NULL);
+ if (uri != NULL && uri[0] != '\0') {
+ /* TRANSLATORS: button text, visit the suspend help website */
+ gtk_dialog_add_button (GTK_DIALOG (dialog), _("Visit help page"), GTK_RESPONSE_HELP);
+ }
+
/* wait async for close */
gtk_widget_show (dialog);
- g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
+ g_signal_connect (dialog, "response", G_CALLBACK (gpm_manager_sleep_failure_response_cb), manager);
out:
+ g_free (uri);
g_free (title);
g_free (message);
}
@@ -1718,7 +1756,7 @@ gpm_manager_init (GpmManager *manager)
egg_debug ("creating new control instance");
manager->priv->control = gpm_control_new ();
g_signal_connect (manager->priv->control, "sleep-failure",
- G_CALLBACK (control_sleep_failure_cb), manager);
+ G_CALLBACK (gpm_manager_sleep_failure_cb), manager);
egg_debug ("creating new tray icon");
manager->priv->tray_icon = gpm_tray_icon_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]