gnome-session r4749 - in branches/dbus_based: . gnome-session
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r4749 - in branches/dbus_based: . gnome-session
- Date: Mon, 16 Jun 2008 03:38:21 +0000 (UTC)
Author: mccann
Date: Mon Jun 16 03:38:21 2008
New Revision: 4749
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4749&view=rev
Log:
2008-06-15 William Jon McCann <jmccann redhat com>
* gnome-session/Makefile.am:
* gnome-session/gconf.c (gsm_gconf_shutdown):
* gnome-session/gdm.c (gdm_send_protocol_msg),
(get_display_number), (gdm_authenticate_connection),
(gdm_shutdown_protocol_connection), (gdm_init_protocol_connection),
(gdm_parse_query_response), (gdm_update_logout_actions),
(gdm_is_available), (gdm_set_logout_action), (gdm_new_login):
* gnome-session/gsm-logout-dialog.c:
* gnome-session/gsm-manager.c:
* gnome-session/gsm-power-manager.c (on_name_owner_changed),
(ensure_gpm_connection), (gsm_power_manager_init),
(gsm_power_manager_finalize), (gsm_power_manager_get_property),
(gsm_power_manager_can_suspend), (gsm_power_manager_can_hibernate),
(gsm_power_manager_attempt_suspend),
(gsm_power_manager_attempt_hibernate), (gsm_get_power_manager):
* gnome-session/gsm-power-manager.h:
* gnome-session/logout-dialog.c:
* gnome-session/logout-dialog.h:
* gnome-session/power-manager.c:
* gnome-session/power-manager.h:
Strip trailing whitespace. Make pretty.
Added:
branches/dbus_based/gnome-session/gsm-logout-dialog.c
- copied, changed from r4748, /branches/dbus_based/gnome-session/logout-dialog.c
branches/dbus_based/gnome-session/gsm-logout-dialog.h
- copied unchanged from r4748, /branches/dbus_based/gnome-session/logout-dialog.h
branches/dbus_based/gnome-session/gsm-power-manager.c
- copied, changed from r4747, /branches/dbus_based/gnome-session/power-manager.c
branches/dbus_based/gnome-session/gsm-power-manager.h
- copied, changed from r4747, /branches/dbus_based/gnome-session/power-manager.h
Removed:
branches/dbus_based/gnome-session/logout-dialog.c
branches/dbus_based/gnome-session/logout-dialog.h
branches/dbus_based/gnome-session/power-manager.c
branches/dbus_based/gnome-session/power-manager.h
Modified:
branches/dbus_based/ChangeLog
branches/dbus_based/gnome-session/Makefile.am
branches/dbus_based/gnome-session/gconf.c
branches/dbus_based/gnome-session/gdm.c
branches/dbus_based/gnome-session/gsm-manager.c
branches/dbus_based/gnome-session/util.c
Modified: branches/dbus_based/gnome-session/Makefile.am
==============================================================================
--- branches/dbus_based/gnome-session/Makefile.am (original)
+++ branches/dbus_based/gnome-session/Makefile.am Mon Jun 16 03:38:21 2008
@@ -40,15 +40,15 @@
gsm-marshal.c \
gsm-consolekit.c \
gsm-consolekit.h \
+ gsm-logout-dialog.h \
+ gsm-logout-dialog.c \
+ gsm-power-manager.h \
+ gsm-power-manager.c \
gconf.c \
gconf.h \
gdm.h \
gdm.c \
- logout-dialog.h \
- logout-dialog.c \
main.c \
- power-manager.h \
- power-manager.c \
gsm-client-store.h \
gsm-client-store.c \
gsm-manager.c \
Modified: branches/dbus_based/gnome-session/gconf.c
==============================================================================
--- branches/dbus_based/gnome-session/gconf.c (original)
+++ branches/dbus_based/gnome-session/gconf.c Mon Jun 16 03:38:21 2008
@@ -162,4 +162,3 @@
g_free (command);
}
-
Modified: branches/dbus_based/gnome-session/gdm.c
==============================================================================
--- branches/dbus_based/gnome-session/gdm.c (original)
+++ branches/dbus_based/gnome-session/gdm.c Mon Jun 16 03:38:21 2008
@@ -1,8 +1,9 @@
-/* gdm.c
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
* Copyright (C) 2005 Raffaele Sandrini
* Copyright (C) 2005 Red Hat, Inc.
* Copyright (C) 2002, 2003 George Lebl
- * Copyright (C) 2001 Queen of England,
+ * Copyright (C) 2001 Queen of England,
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -58,91 +59,97 @@
#define GDM_ACTION_STR_SUSPEND "SUSPEND"
typedef struct {
- int fd;
- char *auth_cookie;
+ int fd;
+ char *auth_cookie;
GdmLogoutAction available_actions;
GdmLogoutAction current_actions;
- time_t last_update;
+ time_t last_update;
} GdmProtocolData;
static GdmProtocolData gdm_protocol_data = {
- 0,
- NULL,
- GDM_LOGOUT_ACTION_NONE,
- GDM_LOGOUT_ACTION_NONE,
- 0
+ 0,
+ NULL,
+ GDM_LOGOUT_ACTION_NONE,
+ GDM_LOGOUT_ACTION_NONE,
+ 0
};
static char *
gdm_send_protocol_msg (GdmProtocolData *data,
const char *msg)
{
- GString *retval;
- char buf[256];
- char *p;
- int len;
-
- p = g_strconcat (msg, "\n", NULL);
-
- if (write (data->fd, p, strlen (p)) < 0)
- {
- g_free (p);
-
- g_warning ("Failed to send message to GDM: %s",
- g_strerror (errno));
-
- return NULL;
- }
-
- g_free (p);
-
- p = NULL;
- retval = NULL;
-
- while ((len = read (data->fd, buf, sizeof (buf) - 1)) > 0)
- {
- buf[len] = '\0';
-
- if (!retval)
- retval = g_string_new (buf);
- else
- retval = g_string_append (retval, buf);
-
- if ((p = strchr (retval->str, '\n')))
- break;
- }
-
- if (p) *p = '\0';
-
- return retval ? g_string_free (retval, FALSE) : NULL;
+ GString *retval;
+ char buf[256];
+ char *p;
+ int len;
+
+ p = g_strconcat (msg, "\n", NULL);
+
+ if (write (data->fd, p, strlen (p)) < 0) {
+ g_free (p);
+
+ g_warning ("Failed to send message to GDM: %s",
+ g_strerror (errno));
+
+ return NULL;
+ }
+
+ g_free (p);
+
+ p = NULL;
+ retval = NULL;
+
+ while ((len = read (data->fd, buf, sizeof (buf) - 1)) > 0) {
+ buf[len] = '\0';
+
+ if (!retval) {
+ retval = g_string_new (buf);
+ } else {
+ retval = g_string_append (retval, buf);
+ }
+
+ if ((p = strchr (retval->str, '\n'))) {
+ break;
+ }
+ }
+
+ if (p) {
+ *p = '\0';
+ }
+
+ return retval ? g_string_free (retval, FALSE) : NULL;
}
static char *
get_display_number (void)
{
- const char *display_name;
- char *retval;
- char *p;
-
- display_name = gdk_display_get_name (gdk_display_get_default ());
-
- p = strchr (display_name, ':');
-
- if (!p)
- return g_strdup ("0");
-
- while (*p == ':') p++;
-
- retval = g_strdup (p);
-
- p = strchr (retval, '.');
-
- if (p != NULL)
- *p = '\0';
-
- return retval;
+ const char *display_name;
+ char *retval;
+ char *p;
+
+ display_name = gdk_display_get_name (gdk_display_get_default ());
+
+ p = strchr (display_name, ':');
+
+ if (!p) {
+ return g_strdup ("0");
+ }
+
+ while (*p == ':') {
+ p++;
+ }
+
+ retval = g_strdup (p);
+
+ p = strchr (retval, '.');
+
+ if (p != NULL) {
+ *p = '\0';
+ }
+
+ return retval;
}
static gboolean
@@ -150,85 +157,81 @@
{
#define GDM_MIT_MAGIC_COOKIE_LEN 16
- const char *xau_path;
- FILE *f;
- Xauth *xau;
- char *display_number;
- gboolean retval;
-
- if (data->auth_cookie)
- {
- char *msg;
- char *response;
-
- msg = g_strdup_printf (GDM_PROTOCOL_MSG_AUTHENTICATE " %s",
- data->auth_cookie);
- response = gdm_send_protocol_msg (data, msg);
- g_free (msg);
-
- if (response && !strcmp (response, "OK"))
- {
- g_free (response);
- return TRUE;
- }
- else
- {
- g_free (response);
- g_free (data->auth_cookie);
- data->auth_cookie = NULL;
- }
- }
-
- if (!(xau_path = XauFileName ()))
- return FALSE;
-
- if (!(f = fopen (xau_path, "r")))
- return FALSE;
-
- retval = FALSE;
- display_number = get_display_number ();
-
- while ((xau = XauReadAuth (f)))
- {
- char buffer[40]; /* 2*16 == 32, so 40 is enough */
- char *msg;
- char *response;
- int i;
-
- if (xau->family != FamilyLocal ||
- strncmp (xau->number, display_number, xau->number_length) ||
- strncmp (xau->name, "MIT-MAGIC-COOKIE-1", xau->name_length) ||
- xau->data_length != GDM_MIT_MAGIC_COOKIE_LEN)
- {
- XauDisposeAuth (xau);
- continue;
- }
-
- for (i = 0; i < GDM_MIT_MAGIC_COOKIE_LEN; i++)
- g_snprintf (buffer + 2*i, 3, "%02x", (guint)(guchar)xau->data[i]);
-
- XauDisposeAuth (xau);
-
- msg = g_strdup_printf (GDM_PROTOCOL_MSG_AUTHENTICATE " %s", buffer);
- response = gdm_send_protocol_msg (data, msg);
- g_free (msg);
-
- if (response && !strcmp (response, "OK"))
- {
- data->auth_cookie = g_strdup (buffer);
- g_free (response);
- retval = TRUE;
- break;
- }
-
- g_free (response);
- }
-
- g_free (display_number);
-
- fclose (f);
-
- return retval;
+ const char *xau_path;
+ FILE *f;
+ Xauth *xau;
+ char *display_number;
+ gboolean retval;
+
+ if (data->auth_cookie) {
+ char *msg;
+ char *response;
+
+ msg = g_strdup_printf (GDM_PROTOCOL_MSG_AUTHENTICATE " %s",
+ data->auth_cookie);
+ response = gdm_send_protocol_msg (data, msg);
+ g_free (msg);
+
+ if (response && !strcmp (response, "OK")) {
+ g_free (response);
+ return TRUE;
+ } else {
+ g_free (response);
+ g_free (data->auth_cookie);
+ data->auth_cookie = NULL;
+ }
+ }
+
+ if (!(xau_path = XauFileName ())) {
+ return FALSE;
+ }
+
+ if (!(f = fopen (xau_path, "r"))) {
+ return FALSE;
+ }
+
+ retval = FALSE;
+ display_number = get_display_number ();
+
+ while ((xau = XauReadAuth (f))) {
+ char buffer[40]; /* 2*16 == 32, so 40 is enough */
+ char *msg;
+ char *response;
+ int i;
+
+ if (xau->family != FamilyLocal ||
+ strncmp (xau->number, display_number, xau->number_length) ||
+ strncmp (xau->name, "MIT-MAGIC-COOKIE-1", xau->name_length) ||
+ xau->data_length != GDM_MIT_MAGIC_COOKIE_LEN) {
+ XauDisposeAuth (xau);
+ continue;
+ }
+
+ for (i = 0; i < GDM_MIT_MAGIC_COOKIE_LEN; i++) {
+ g_snprintf (buffer + 2*i, 3, "%02x", (guint)(guchar)xau->data[i]);
+ }
+
+ XauDisposeAuth (xau);
+
+ msg = g_strdup_printf (GDM_PROTOCOL_MSG_AUTHENTICATE " %s", buffer);
+ response = gdm_send_protocol_msg (data, msg);
+ g_free (msg);
+
+ if (response && !strcmp (response, "OK")) {
+ data->auth_cookie = g_strdup (buffer);
+ g_free (response);
+ retval = TRUE;
+ break;
+ }
+
+ g_free (response);
+ }
+
+ g_free (display_number);
+
+ fclose (f);
+
+ return retval;
#undef GDM_MIT_MAGIC_COOKIE_LEN
}
@@ -236,230 +239,233 @@
static void
gdm_shutdown_protocol_connection (GdmProtocolData *data)
{
- if (data->fd)
- close (data->fd);
+ if (data->fd) {
+ close (data->fd);
+ }
- data->fd = 0;
+ data->fd = 0;
}
static gboolean
gdm_init_protocol_connection (GdmProtocolData *data)
{
- struct sockaddr_un addr;
- char *response;
+ struct sockaddr_un addr;
+ char *response;
+
+ g_assert (data->fd <= 0);
+
+ if (g_file_test (GDM_PROTOCOL_SOCKET_PATH, G_FILE_TEST_EXISTS)) {
+ strcpy (addr.sun_path, GDM_PROTOCOL_SOCKET_PATH);
+ } else if (g_file_test ("/tmp/.gdm_socket", G_FILE_TEST_EXISTS)) {
+ strcpy (addr.sun_path, "/tmp/.gdm_socket");
+ } else {
+ return FALSE;
+ }
+
+ data->fd = socket (AF_UNIX, SOCK_STREAM, 0);
+
+ if (data->fd < 0) {
+ g_warning ("Failed to create GDM socket: %s",
+ g_strerror (errno));
+
+ gdm_shutdown_protocol_connection (data);
+
+ return FALSE;
+ }
- g_assert (data->fd <= 0);
+ addr.sun_family = AF_UNIX;
- if (g_file_test (GDM_PROTOCOL_SOCKET_PATH, G_FILE_TEST_EXISTS))
- strcpy (addr.sun_path, GDM_PROTOCOL_SOCKET_PATH);
- else if (g_file_test ("/tmp/.gdm_socket", G_FILE_TEST_EXISTS))
- strcpy (addr.sun_path, "/tmp/.gdm_socket");
- else
- return FALSE;
-
- data->fd = socket (AF_UNIX, SOCK_STREAM, 0);
-
- if (data->fd < 0)
- {
- g_warning ("Failed to create GDM socket: %s",
- g_strerror (errno));
-
- gdm_shutdown_protocol_connection (data);
-
- return FALSE;
- }
-
- addr.sun_family = AF_UNIX;
-
- if (connect (data->fd, (struct sockaddr *) &addr, sizeof (addr)) < 0)
- {
- g_warning ("Failed to establish a connection with GDM: %s",
- g_strerror (errno));
-
- gdm_shutdown_protocol_connection (data);
-
- return FALSE;
- }
-
- response = gdm_send_protocol_msg (data, GDM_PROTOCOL_MSG_VERSION);
-
- if (!response || strncmp (response, "GDM ", strlen ("GDM ") != 0))
- {
- g_free (response);
-
- g_warning ("Failed to get protocol version from GDM");
- gdm_shutdown_protocol_connection (data);
-
- return FALSE;
- }
-
- g_free (response);
-
- if (!gdm_authenticate_connection (data))
- {
- g_warning ("Failed to authenticate with GDM");
- gdm_shutdown_protocol_connection (data);
- return FALSE;
- }
+ if (connect (data->fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) {
+ g_warning ("Failed to establish a connection with GDM: %s",
+ g_strerror (errno));
- return TRUE;
+ gdm_shutdown_protocol_connection (data);
+
+ return FALSE;
+ }
+
+ response = gdm_send_protocol_msg (data, GDM_PROTOCOL_MSG_VERSION);
+
+ if (!response || strncmp (response, "GDM ", strlen ("GDM ") != 0)) {
+ g_free (response);
+
+ g_warning ("Failed to get protocol version from GDM");
+ gdm_shutdown_protocol_connection (data);
+
+ return FALSE;
+ }
+
+ g_free (response);
+
+ if (!gdm_authenticate_connection (data)) {
+ g_warning ("Failed to authenticate with GDM");
+ gdm_shutdown_protocol_connection (data);
+ return FALSE;
+ }
+
+ return TRUE;
}
static void
gdm_parse_query_response (GdmProtocolData *data,
const char *response)
{
- char **actions;
- int i;
-
- data->available_actions = GDM_LOGOUT_ACTION_NONE;
- data->current_actions = GDM_LOGOUT_ACTION_NONE;
-
- if (strncmp (response, "OK ", 3) != 0)
- return;
-
- response += 3;
-
- actions = g_strsplit (response, ";", -1);
-
- for (i = 0; actions[i]; i++)
- {
- GdmLogoutAction action = GDM_LOGOUT_ACTION_NONE;
- gboolean selected = FALSE;
- char *str = actions [i];
- int len;
-
- len = strlen (str);
-
- if (!len)
- continue;
-
- if (str[len - 1] == '!')
- {
- selected = TRUE;
- str[len - 1] = '\0';
- }
-
- if (!strcmp (str, GDM_ACTION_STR_SHUTDOWN))
- action = GDM_LOGOUT_ACTION_SHUTDOWN;
- else if (!strcmp (str, GDM_ACTION_STR_REBOOT))
- action = GDM_LOGOUT_ACTION_REBOOT;
- else if (!strcmp (str, GDM_ACTION_STR_SUSPEND))
- action = GDM_LOGOUT_ACTION_SUSPEND;
-
- data->available_actions |= action;
-
- if (selected)
- data->current_actions |= action;
- }
-
- g_strfreev (actions);
+ char **actions;
+ int i;
+
+ data->available_actions = GDM_LOGOUT_ACTION_NONE;
+ data->current_actions = GDM_LOGOUT_ACTION_NONE;
+
+ if (strncmp (response, "OK ", 3) != 0) {
+ return;
+ }
+
+ response += 3;
+
+ actions = g_strsplit (response, ";", -1);
+
+ for (i = 0; actions[i]; i++) {
+ GdmLogoutAction action = GDM_LOGOUT_ACTION_NONE;
+ gboolean selected = FALSE;
+ char *str = actions [i];
+ int len;
+
+ len = strlen (str);
+
+ if (!len) {
+ continue;
+ }
+
+ if (str[len - 1] == '!') {
+ selected = TRUE;
+ str[len - 1] = '\0';
+ }
+
+ if (!strcmp (str, GDM_ACTION_STR_SHUTDOWN)) {
+ action = GDM_LOGOUT_ACTION_SHUTDOWN;
+ } else if (!strcmp (str, GDM_ACTION_STR_REBOOT)) {
+ action = GDM_LOGOUT_ACTION_REBOOT;
+ } else if (!strcmp (str, GDM_ACTION_STR_SUSPEND)) {
+ action = GDM_LOGOUT_ACTION_SUSPEND;
+ }
+
+ data->available_actions |= action;
+
+ if (selected) {
+ data->current_actions |= action;
+ }
+ }
+
+ g_strfreev (actions);
}
static void
gdm_update_logout_actions (GdmProtocolData *data)
{
- time_t current_time;
- char *response;
-
- current_time = time (NULL);
-
- if (current_time <= (data->last_update + GDM_PROTOCOL_UPDATE_INTERVAL))
- return;
-
- data->last_update = current_time;
-
- if (!gdm_init_protocol_connection (data))
- return;
-
- if ((response = gdm_send_protocol_msg (data, GDM_PROTOCOL_MSG_QUERY_ACTION)))
- {
- gdm_parse_query_response (data, response);
- g_free (response);
- }
-
- gdm_shutdown_protocol_connection (data);
+ time_t current_time;
+ char *response;
+
+ current_time = time (NULL);
+
+ if (current_time <= (data->last_update + GDM_PROTOCOL_UPDATE_INTERVAL)) {
+ return;
+ }
+
+ data->last_update = current_time;
+
+ if (!gdm_init_protocol_connection (data)) {
+ return;
+ }
+
+ if ((response = gdm_send_protocol_msg (data, GDM_PROTOCOL_MSG_QUERY_ACTION))) {
+ gdm_parse_query_response (data, response);
+ g_free (response);
+ }
+
+ gdm_shutdown_protocol_connection (data);
}
gboolean
gdm_is_available (void)
{
- if (!gdm_init_protocol_connection (&gdm_protocol_data))
- return FALSE;
+ if (!gdm_init_protocol_connection (&gdm_protocol_data)) {
+ return FALSE;
+ }
- gdm_shutdown_protocol_connection (&gdm_protocol_data);
+ gdm_shutdown_protocol_connection (&gdm_protocol_data);
- return TRUE;
+ return TRUE;
}
gboolean
gdm_supports_logout_action (GdmLogoutAction action)
{
- gdm_update_logout_actions (&gdm_protocol_data);
+ gdm_update_logout_actions (&gdm_protocol_data);
- return (gdm_protocol_data.available_actions & action) != 0;
+ return (gdm_protocol_data.available_actions & action) != 0;
}
GdmLogoutAction
gdm_get_logout_action (void)
{
- gdm_update_logout_actions (&gdm_protocol_data);
-
- return gdm_protocol_data.current_actions;
+ gdm_update_logout_actions (&gdm_protocol_data);
+
+ return gdm_protocol_data.current_actions;
}
void
gdm_set_logout_action (GdmLogoutAction action)
{
- char *action_str = NULL;
- char *msg;
- char *response;
-
- if (!gdm_init_protocol_connection (&gdm_protocol_data))
- return;
-
- switch (action)
- {
- case GDM_LOGOUT_ACTION_NONE:
- action_str = GDM_ACTION_STR_NONE;
- break;
- case GDM_LOGOUT_ACTION_SHUTDOWN:
- action_str = GDM_ACTION_STR_SHUTDOWN;
- break;
- case GDM_LOGOUT_ACTION_REBOOT:
- action_str = GDM_ACTION_STR_REBOOT;
- break;
- case GDM_LOGOUT_ACTION_SUSPEND:
- action_str = GDM_ACTION_STR_SUSPEND;
- break;
- }
-
- msg = g_strdup_printf (GDM_PROTOCOL_MSG_SET_ACTION " %s", action_str);
-
- response = gdm_send_protocol_msg (&gdm_protocol_data, msg);
-
- g_free (msg);
- g_free (response);
-
- gdm_protocol_data.last_update = 0;
-
- gdm_shutdown_protocol_connection (&gdm_protocol_data);
+ char *action_str = NULL;
+ char *msg;
+ char *response;
+
+ if (!gdm_init_protocol_connection (&gdm_protocol_data)) {
+ return;
+ }
+
+ switch (action) {
+ case GDM_LOGOUT_ACTION_NONE:
+ action_str = GDM_ACTION_STR_NONE;
+ break;
+ case GDM_LOGOUT_ACTION_SHUTDOWN:
+ action_str = GDM_ACTION_STR_SHUTDOWN;
+ break;
+ case GDM_LOGOUT_ACTION_REBOOT:
+ action_str = GDM_ACTION_STR_REBOOT;
+ break;
+ case GDM_LOGOUT_ACTION_SUSPEND:
+ action_str = GDM_ACTION_STR_SUSPEND;
+ break;
+ }
+
+ msg = g_strdup_printf (GDM_PROTOCOL_MSG_SET_ACTION " %s", action_str);
+
+ response = gdm_send_protocol_msg (&gdm_protocol_data, msg);
+
+ g_free (msg);
+ g_free (response);
+
+ gdm_protocol_data.last_update = 0;
+
+ gdm_shutdown_protocol_connection (&gdm_protocol_data);
}
void
gdm_new_login (void)
{
- char *response;
-
- if (!gdm_init_protocol_connection (&gdm_protocol_data))
- return;
-
- response = gdm_send_protocol_msg (&gdm_protocol_data,
- GDM_PROTOCOL_MSG_FLEXI_XSERVER);
-
- g_free (response);
-
- gdm_protocol_data.last_update = 0;
-
- gdm_shutdown_protocol_connection (&gdm_protocol_data);
+ char *response;
+
+ if (!gdm_init_protocol_connection (&gdm_protocol_data)) {
+ return;
+ }
+
+ response = gdm_send_protocol_msg (&gdm_protocol_data,
+ GDM_PROTOCOL_MSG_FLEXI_XSERVER);
+
+ g_free (response);
+
+ gdm_protocol_data.last_update = 0;
+
+ gdm_shutdown_protocol_connection (&gdm_protocol_data);
}
Copied: branches/dbus_based/gnome-session/gsm-logout-dialog.c (from r4748, /branches/dbus_based/gnome-session/logout-dialog.c)
==============================================================================
--- /branches/dbus_based/gnome-session/logout-dialog.c (original)
+++ branches/dbus_based/gnome-session/gsm-logout-dialog.c Mon Jun 16 03:38:21 2008
@@ -26,12 +26,10 @@
#endif
#include <glib/gi18n.h>
-#include <gtk/gtkimage.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkstock.h>
+#include <gtk/gtk.h>
-#include "logout-dialog.h"
-#include "power-manager.h"
+#include "gsm-logout-dialog.h"
+#include "gsm-power-manager.h"
#include "gsm-consolekit.h"
#include "gdm.h"
Modified: branches/dbus_based/gnome-session/gsm-manager.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-manager.c (original)
+++ branches/dbus_based/gnome-session/gsm-manager.c Mon Jun 16 03:38:21 2008
@@ -48,9 +48,9 @@
#include "gsm-resumed-app.h"
#include "util.h"
#include "gdm.h"
-#include "logout-dialog.h"
+#include "gsm-logout-dialog.h"
#include "gsm-consolekit.h"
-#include "power-manager.h"
+#include "gsm-power-manager.h"
#define GSM_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_MANAGER, GsmManagerPrivate))
Copied: branches/dbus_based/gnome-session/gsm-power-manager.c (from r4747, /branches/dbus_based/gnome-session/power-manager.c)
==============================================================================
--- /branches/dbus_based/gnome-session/power-manager.c (original)
+++ branches/dbus_based/gnome-session/gsm-power-manager.c Mon Jun 16 03:38:21 2008
@@ -1,4 +1,6 @@
-/* power-manager.h: functions for powering down, restarting, and
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * power-manager.h: functions for powering down, restarting, and
* suspending the computer
* Copyright (C) 2006 Ray Strode <rstrode redhat com>
*
@@ -22,7 +24,7 @@
#include "config.h"
#endif
-#include "power-manager.h"
+#include "gsm-power-manager.h"
#include <errno.h>
#include <string.h>
@@ -33,12 +35,12 @@
#include <dbus/dbus-glib.h>
-struct _GsmPowerManagerPrivate
+struct _GsmPowerManagerPrivate
{
- DBusGConnection *dbus_connection;
- DBusGProxy *bus_proxy;
- DBusGProxy *gpm_proxy;
- guint32 is_connected : 1;
+ DBusGConnection *dbus_connection;
+ DBusGProxy *bus_proxy;
+ DBusGProxy *gpm_proxy;
+ guint32 is_connected : 1;
};
static void gsm_power_manager_finalize (GObject *object);
@@ -48,23 +50,21 @@
static void gsm_power_manager_class_install_properties (GsmPowerManagerClass *manager_class);
static void gsm_power_manager_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
static gboolean ensure_gpm_connection (GsmPowerManager *manager,
- GError **error);
+ GError **error);
-enum
-{
- PROP_0 = 0,
- PROP_IS_CONNECTED
+enum {
+ PROP_0 = 0,
+ PROP_IS_CONNECTED
};
-enum
-{
- REQUEST_FAILED = 0,
- LAST_SIGNAL
+enum {
+ REQUEST_FAILED = 0,
+ LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
@@ -74,432 +74,407 @@
static void
gsm_power_manager_class_init (GsmPowerManagerClass *manager_class)
{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (manager_class);
-
- object_class->finalize = gsm_power_manager_finalize;
-
- gsm_power_manager_class_install_properties (manager_class);
- gsm_power_manager_class_install_signals (manager_class);
-
- g_type_class_add_private (manager_class,
- sizeof (GsmPowerManagerPrivate));
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (manager_class);
+
+ object_class->finalize = gsm_power_manager_finalize;
+
+ gsm_power_manager_class_install_properties (manager_class);
+ gsm_power_manager_class_install_signals (manager_class);
+
+ g_type_class_add_private (manager_class,
+ sizeof (GsmPowerManagerPrivate));
}
static void
gsm_power_manager_class_install_signals (GsmPowerManagerClass *manager_class)
{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (manager_class);
-
- signals[REQUEST_FAILED] =
- g_signal_new ("request-failed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GsmPowerManagerClass, request_failed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1, G_TYPE_POINTER);
-
- manager_class->request_failed = NULL;
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (manager_class);
+
+ signals[REQUEST_FAILED] =
+ g_signal_new ("request-failed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GsmPowerManagerClass, request_failed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1, G_TYPE_POINTER);
+
+ manager_class->request_failed = NULL;
}
static void
gsm_power_manager_class_install_properties (GsmPowerManagerClass *manager_class)
{
- GObjectClass *object_class;
- GParamSpec *param_spec;
-
- object_class = G_OBJECT_CLASS (manager_class);
- object_class->get_property = gsm_power_manager_get_property;
-
- param_spec = g_param_spec_boolean ("is-connected",
- "Is connected",
- "Whether the session is connected to "
- "the power manager",
- FALSE,
- G_PARAM_READABLE);
-
- g_object_class_install_property (object_class, PROP_IS_CONNECTED,
- param_spec);
+ GObjectClass *object_class;
+ GParamSpec *param_spec;
+
+ object_class = G_OBJECT_CLASS (manager_class);
+ object_class->get_property = gsm_power_manager_get_property;
+
+ param_spec = g_param_spec_boolean ("is-connected",
+ "Is connected",
+ "Whether the session is connected to "
+ "the power manager",
+ FALSE,
+ G_PARAM_READABLE);
+
+ g_object_class_install_property (object_class, PROP_IS_CONNECTED,
+ param_spec);
}
static void
on_name_owner_changed (DBusGProxy *bus_proxy,
- const char *name,
- const char *prev_owner,
- const char *new_owner,
- GsmPowerManager *manager)
-{
- if (strcmp (name, "org.freedesktop.PowerManagement") != 0)
- return;
-
- if (manager->priv->gpm_proxy != NULL)
- {
- g_object_unref (manager->priv->gpm_proxy);
- manager->priv->gpm_proxy = NULL;
- }
-
- ensure_gpm_connection (manager, NULL);
+ const char *name,
+ const char *prev_owner,
+ const char *new_owner,
+ GsmPowerManager *manager)
+{
+ if (strcmp (name, "org.freedesktop.PowerManagement") != 0) {
+ return;
+ }
+
+ if (manager->priv->gpm_proxy != NULL) {
+ g_object_unref (manager->priv->gpm_proxy);
+ manager->priv->gpm_proxy = NULL;
+ }
+
+ ensure_gpm_connection (manager, NULL);
}
static gboolean
ensure_gpm_connection (GsmPowerManager *manager,
- GError **error)
+ GError **error)
{
- GError *connection_error;
- gboolean is_connected;
-
- connection_error = NULL;
- if (manager->priv->dbus_connection == NULL)
- {
- manager->priv->dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION,
- &connection_error);
-
- if (manager->priv->dbus_connection == NULL)
- {
- g_propagate_error (error, connection_error);
- is_connected = FALSE;
- goto out;
- }
- }
-
- if (manager->priv->bus_proxy == NULL)
- {
- manager->priv->bus_proxy =
- dbus_g_proxy_new_for_name_owner (manager->priv->dbus_connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS,
- &connection_error);
-
- if (manager->priv->bus_proxy == NULL)
- {
- g_propagate_error (error, connection_error);
- is_connected = FALSE;
- goto out;
- }
-
- dbus_g_proxy_add_signal (manager->priv->bus_proxy,
- "NameOwnerChanged",
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (manager->priv->bus_proxy,
- "NameOwnerChanged",
- G_CALLBACK (on_name_owner_changed),
- manager, NULL);
- }
-
- if (manager->priv->gpm_proxy == NULL)
- {
- manager->priv->gpm_proxy =
- dbus_g_proxy_new_for_name_owner (
- manager->priv->dbus_connection,
- "org.freedesktop.PowerManagement",
- "/org/freedesktop/PowerManagement",
- "org.freedesktop.PowerManagement",
- &connection_error);
-
- if (manager->priv->gpm_proxy == NULL)
- {
- g_propagate_error (error, connection_error);
- is_connected = FALSE;
- goto out;
- }
- }
-
- is_connected = TRUE;
-
-out:
- if (manager->priv->is_connected != is_connected)
- {
- manager->priv->is_connected = is_connected;
- g_object_notify (G_OBJECT (manager), "is-connected");
- }
-
- if (!is_connected)
- {
- if (manager->priv->dbus_connection == NULL)
- {
- if (manager->priv->bus_proxy != NULL)
- {
- g_object_unref (manager->priv->bus_proxy);
- manager->priv->bus_proxy = NULL;
- }
-
- if (manager->priv->gpm_proxy != NULL)
- {
- g_object_unref (manager->priv->gpm_proxy);
- manager->priv->gpm_proxy = NULL;
- }
- }
- else if (manager->priv->bus_proxy == NULL)
- {
- if (manager->priv->gpm_proxy != NULL)
- {
- g_object_unref (manager->priv->gpm_proxy);
- manager->priv->gpm_proxy = NULL;
- }
- }
- }
-
- return is_connected;
+ GError *connection_error;
+ gboolean is_connected;
+
+ connection_error = NULL;
+ if (manager->priv->dbus_connection == NULL) {
+ manager->priv->dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION,
+ &connection_error);
+
+ if (manager->priv->dbus_connection == NULL) {
+ g_propagate_error (error, connection_error);
+ is_connected = FALSE;
+ goto out;
+ }
+ }
+
+ if (manager->priv->bus_proxy == NULL) {
+ manager->priv->bus_proxy =
+ dbus_g_proxy_new_for_name_owner (manager->priv->dbus_connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ &connection_error);
+
+ if (manager->priv->bus_proxy == NULL) {
+ g_propagate_error (error, connection_error);
+ is_connected = FALSE;
+ goto out;
+ }
+
+ dbus_g_proxy_add_signal (manager->priv->bus_proxy,
+ "NameOwnerChanged",
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+
+ dbus_g_proxy_connect_signal (manager->priv->bus_proxy,
+ "NameOwnerChanged",
+ G_CALLBACK (on_name_owner_changed),
+ manager, NULL);
+ }
+
+ if (manager->priv->gpm_proxy == NULL) {
+ manager->priv->gpm_proxy =
+ dbus_g_proxy_new_for_name_owner (
+ manager->priv->dbus_connection,
+ "org.freedesktop.PowerManagement",
+ "/org/freedesktop/PowerManagement",
+ "org.freedesktop.PowerManagement",
+ &connection_error);
+
+ if (manager->priv->gpm_proxy == NULL) {
+ g_propagate_error (error, connection_error);
+ is_connected = FALSE;
+ goto out;
+ }
+ }
+
+ is_connected = TRUE;
+
+ out:
+ if (manager->priv->is_connected != is_connected) {
+ manager->priv->is_connected = is_connected;
+ g_object_notify (G_OBJECT (manager), "is-connected");
+ }
+
+ if (!is_connected) {
+ if (manager->priv->dbus_connection == NULL) {
+ if (manager->priv->bus_proxy != NULL) {
+ g_object_unref (manager->priv->bus_proxy);
+ manager->priv->bus_proxy = NULL;
+ }
+
+ if (manager->priv->gpm_proxy != NULL) {
+ g_object_unref (manager->priv->gpm_proxy);
+ manager->priv->gpm_proxy = NULL;
+ }
+ } else if (manager->priv->bus_proxy == NULL) {
+ if (manager->priv->gpm_proxy != NULL) {
+ g_object_unref (manager->priv->gpm_proxy);
+ manager->priv->gpm_proxy = NULL;
+ }
+ }
+ }
+
+ return is_connected;
}
static void
gsm_power_manager_init (GsmPowerManager *manager)
{
- GError *error;
-
- manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
- GSM_TYPE_POWER_MANAGER,
- GsmPowerManagerPrivate);
-
- manager->priv->dbus_connection = NULL;
- manager->priv->bus_proxy = NULL;
- manager->priv->gpm_proxy = NULL;
- manager->priv->is_connected = FALSE;
-
- error = NULL;
-
- if (!ensure_gpm_connection (manager, &error))
- {
- g_message ("Could not connect to power manager: %s",
- error->message);
- g_error_free (error);
- }
+ GError *error;
+
+ manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
+ GSM_TYPE_POWER_MANAGER,
+ GsmPowerManagerPrivate);
+
+ manager->priv->dbus_connection = NULL;
+ manager->priv->bus_proxy = NULL;
+ manager->priv->gpm_proxy = NULL;
+ manager->priv->is_connected = FALSE;
+
+ error = NULL;
+
+ if (!ensure_gpm_connection (manager, &error)) {
+ g_message ("Could not connect to power manager: %s",
+ error->message);
+ g_error_free (error);
+ }
}
static void
gsm_power_manager_finalize (GObject *object)
{
- GsmPowerManager *manager;
- GObjectClass *parent_class;
-
- manager = GSM_POWER_MANAGER (object);
-
- parent_class = G_OBJECT_CLASS (gsm_power_manager_parent_class);
-
- if (parent_class->finalize != NULL)
- parent_class->finalize (object);
+ GsmPowerManager *manager;
+ GObjectClass *parent_class;
+
+ manager = GSM_POWER_MANAGER (object);
+
+ parent_class = G_OBJECT_CLASS (gsm_power_manager_parent_class);
+
+ if (parent_class->finalize != NULL) {
+ parent_class->finalize (object);
+ }
}
static void
gsm_power_manager_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GsmPowerManager *manager = GSM_POWER_MANAGER (object);
-
- switch (prop_id)
- {
- case PROP_IS_CONNECTED:
- g_value_set_boolean (value,
- manager->priv->is_connected);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
- prop_id,
- pspec);
- }
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GsmPowerManager *manager = GSM_POWER_MANAGER (object);
+
+ switch (prop_id) {
+ case PROP_IS_CONNECTED:
+ g_value_set_boolean (value,
+ manager->priv->is_connected);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+ prop_id,
+ pspec);
+ }
}
GQuark
gsm_power_manager_error_quark (void)
{
- static GQuark error_quark = 0;
-
- if (error_quark == 0)
- error_quark = g_quark_from_static_string ("gsm-power-manager-error");
-
- return error_quark;
+ static GQuark error_quark = 0;
+
+ if (error_quark == 0)
+ error_quark = g_quark_from_static_string ("gsm-power-manager-error");
+
+ return error_quark;
}
GsmPowerManager *
gsm_power_manager_new (void)
{
- GsmPowerManager *manager;
-
- manager = g_object_new (GSM_TYPE_POWER_MANAGER, NULL);
-
- return manager;
+ GsmPowerManager *manager;
+
+ manager = g_object_new (GSM_TYPE_POWER_MANAGER, NULL);
+
+ return manager;
}
gboolean
gsm_power_manager_can_suspend (GsmPowerManager *manager)
{
- GError *error;
- gboolean can_suspend;
-
- error = NULL;
-
- if (!ensure_gpm_connection (manager, &error))
- {
- g_message ("Could not connect to power manager: %s",
- error->message);
-
- g_error_free (error);
-
- return FALSE;
- }
-
- can_suspend = FALSE;
-
- if (!dbus_g_proxy_call (manager->priv->gpm_proxy, "CanSuspend",
- &error,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &can_suspend, G_TYPE_INVALID))
- {
- if (error != NULL)
- {
- g_message ("Could not ask power manager if user can suspend: %s",
- error->message);
-
- g_error_free (error);
- }
-
- can_suspend = FALSE;
- }
-
- return can_suspend;
+ GError *error;
+ gboolean can_suspend;
+
+ error = NULL;
+
+ if (!ensure_gpm_connection (manager, &error)) {
+ g_message ("Could not connect to power manager: %s",
+ error->message);
+
+ g_error_free (error);
+
+ return FALSE;
+ }
+
+ can_suspend = FALSE;
+
+ if (!dbus_g_proxy_call (manager->priv->gpm_proxy, "CanSuspend",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN, &can_suspend, G_TYPE_INVALID)) {
+ if (error != NULL) {
+ g_message ("Could not ask power manager if user can suspend: %s",
+ error->message);
+
+ g_error_free (error);
+ }
+
+ can_suspend = FALSE;
+ }
+
+ return can_suspend;
}
gboolean
gsm_power_manager_can_hibernate (GsmPowerManager *manager)
{
- GError *error;
- gboolean can_hibernate;
-
- error = NULL;
-
- if (!ensure_gpm_connection (manager, &error))
- {
- g_message ("Could not connect to power manager: %s",
- error->message);
-
- g_error_free (error);
-
- return FALSE;
- }
-
- can_hibernate = FALSE;
-
- if (!dbus_g_proxy_call (manager->priv->gpm_proxy, "CanHibernate",
- &error,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &can_hibernate, G_TYPE_INVALID))
- {
- if (error != NULL)
- {
- g_message ("Could not ask power manager if user can suspend: %s",
- error->message);
-
- g_error_free (error);
- }
-
- can_hibernate = FALSE;
- }
-
- return can_hibernate;
+ GError *error;
+ gboolean can_hibernate;
+
+ error = NULL;
+
+ if (!ensure_gpm_connection (manager, &error)) {
+ g_message ("Could not connect to power manager: %s",
+ error->message);
+
+ g_error_free (error);
+
+ return FALSE;
+ }
+
+ can_hibernate = FALSE;
+
+ if (!dbus_g_proxy_call (manager->priv->gpm_proxy, "CanHibernate",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN, &can_hibernate, G_TYPE_INVALID)) {
+ if (error != NULL) {
+ g_message ("Could not ask power manager if user can suspend: %s",
+ error->message);
+
+ g_error_free (error);
+ }
+
+ can_hibernate = FALSE;
+ }
+
+ return can_hibernate;
}
void
gsm_power_manager_attempt_suspend (GsmPowerManager *manager)
{
- GError *error;
-
- error = NULL;
-
- if (!ensure_gpm_connection (manager, &error))
- {
- g_warning ("Could not connect to power manager: %s",
- error->message);
- g_error_free (error);
- return;
- }
-
- if (!dbus_g_proxy_call (manager->priv->gpm_proxy, "Suspend",
- &error,
- G_TYPE_INVALID, G_TYPE_INVALID) &&
- error != NULL)
- {
- GError *call_error;
-
- g_warning ("Could not ask power manager to suspend: %s",
- error->message);
-
- call_error = g_error_new_literal (GSM_POWER_MANAGER_ERROR,
- GSM_POWER_MANAGER_ERROR_SUSPENDING,
- error->message);
-
- g_error_free (error);
-
- g_signal_emit (G_OBJECT (manager),
- signals[REQUEST_FAILED],
- 0, call_error);
+ GError *error;
- g_error_free (call_error);
- }
+ error = NULL;
+
+ if (!ensure_gpm_connection (manager, &error)) {
+ g_warning ("Could not connect to power manager: %s",
+ error->message);
+ g_error_free (error);
+ return;
+ }
+
+ if (!dbus_g_proxy_call (manager->priv->gpm_proxy, "Suspend",
+ &error,
+ G_TYPE_INVALID, G_TYPE_INVALID) &&
+ error != NULL) {
+ GError *call_error;
+
+ g_warning ("Could not ask power manager to suspend: %s",
+ error->message);
+
+ call_error = g_error_new_literal (GSM_POWER_MANAGER_ERROR,
+ GSM_POWER_MANAGER_ERROR_SUSPENDING,
+ error->message);
+
+ g_error_free (error);
+
+ g_signal_emit (G_OBJECT (manager),
+ signals[REQUEST_FAILED],
+ 0, call_error);
+
+ g_error_free (call_error);
+ }
}
void
gsm_power_manager_attempt_hibernate (GsmPowerManager *manager)
{
- GError *error;
-
- error = NULL;
-
- if (!ensure_gpm_connection (manager, &error))
- {
- g_warning ("Could not connect to power manager: %s",
- error->message);
-
- g_error_free (error);
-
- return;
- }
-
- if (!dbus_g_proxy_call (manager->priv->gpm_proxy, "Hibernate",
- &error,
- G_TYPE_INVALID, G_TYPE_INVALID) &&
- error != NULL)
- {
- GError *call_error;
-
- g_warning ("Could not ask power manager to hibernate: %s",
- error->message);
-
- call_error = g_error_new_literal (GSM_POWER_MANAGER_ERROR,
- GSM_POWER_MANAGER_ERROR_HIBERNATING,
- error->message);
-
- g_error_free (error);
-
- g_signal_emit (G_OBJECT (manager),
- signals[REQUEST_FAILED],
- 0, call_error);
+ GError *error;
- g_error_free (call_error);
- }
+ error = NULL;
+ if (!ensure_gpm_connection (manager, &error)) {
+ g_warning ("Could not connect to power manager: %s",
+ error->message);
+
+ g_error_free (error);
+
+ return;
+ }
+
+ if (!dbus_g_proxy_call (manager->priv->gpm_proxy, "Hibernate",
+ &error,
+ G_TYPE_INVALID, G_TYPE_INVALID) &&
+ error != NULL) {
+ GError *call_error;
+
+ g_warning ("Could not ask power manager to hibernate: %s",
+ error->message);
+
+ call_error = g_error_new_literal (GSM_POWER_MANAGER_ERROR,
+ GSM_POWER_MANAGER_ERROR_HIBERNATING,
+ error->message);
+
+ g_error_free (error);
+
+ g_signal_emit (G_OBJECT (manager),
+ signals[REQUEST_FAILED],
+ 0, call_error);
+
+ g_error_free (call_error);
+ }
}
GsmPowerManager *
gsm_get_power_manager (void)
{
- static GsmPowerManager *manager = NULL;
-
- if (manager == NULL)
- manager = gsm_power_manager_new ();
-
- return g_object_ref (manager);
+ static GsmPowerManager *manager = NULL;
+
+ if (manager == NULL) {
+ manager = gsm_power_manager_new ();
+ }
+
+ return g_object_ref (manager);
}
Copied: branches/dbus_based/gnome-session/gsm-power-manager.h (from r4747, /branches/dbus_based/gnome-session/power-manager.h)
==============================================================================
--- /branches/dbus_based/gnome-session/power-manager.h (original)
+++ branches/dbus_based/gnome-session/gsm-power-manager.h Mon Jun 16 03:38:21 2008
@@ -1,4 +1,6 @@
-/* power-manager.h: functions for powering down, restarting, and
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * power-manager.h: functions for powering down, restarting, and
* suspending the computer
* Copyright (C) 2006 Ray Strode <rstrode redhat com>
*
@@ -15,7 +17,7 @@
* 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., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * 02111-1307, USA.
*/
#ifndef __GSM_POWER_MANAGER_H__
@@ -26,35 +28,35 @@
G_BEGIN_DECLS
-#define GSM_TYPE_POWER_MANAGER (gsm_power_manager_get_type ())
-#define GSM_POWER_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_POWER_MANAGER, GsmPowerManager))
-#define GSM_POWER_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_POWER_MANAGER, GsmPowerManagerClass))
-#define GSM_IS_POWER_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_POWER_MANAGER))
+#define GSM_TYPE_POWER_MANAGER (gsm_power_manager_get_type ())
+#define GSM_POWER_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_POWER_MANAGER, GsmPowerManager))
+#define GSM_POWER_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_POWER_MANAGER, GsmPowerManagerClass))
+#define GSM_IS_POWER_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_POWER_MANAGER))
#define GSM_IS_POWER_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSM_TYPE_POWER_MANAGER))
#define GSM_POWER_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GSM_TYPE_POWER_MANAGER, GsmPowerManagerClass))
-#define GSM_POWER_MANAGER_ERROR (gsm_power_manager_error_quark ())
+#define GSM_POWER_MANAGER_ERROR (gsm_power_manager_error_quark ())
-typedef struct _GsmPowerManager GsmPowerManager;
+typedef struct _GsmPowerManager GsmPowerManager;
typedef struct _GsmPowerManagerClass GsmPowerManagerClass;
typedef struct _GsmPowerManagerPrivate GsmPowerManagerPrivate;
typedef enum _GsmPowerManagerError GsmPowerManagerError;
-struct _GsmPowerManager
+struct _GsmPowerManager
{
GObject parent;
-
+
GsmPowerManagerPrivate *priv;
};
-struct _GsmPowerManagerClass
+struct _GsmPowerManagerClass
{
GObjectClass parent_class;
-
- void (* request_failed) (GsmPowerManager *manager,
+
+ void (* request_failed) (GsmPowerManager *manager,
GError *error);
};
-enum _GsmPowerManagerError
+enum _GsmPowerManagerError
{
GSM_POWER_MANAGER_ERROR_SUSPENDING = 0,
GSM_POWER_MANAGER_ERROR_HIBERNATING
Modified: branches/dbus_based/gnome-session/util.c
==============================================================================
--- branches/dbus_based/gnome-session/util.c (original)
+++ branches/dbus_based/gnome-session/util.c Mon Jun 16 03:38:21 2008
@@ -38,27 +38,27 @@
dirs = g_ptr_array_new ();
- g_ptr_array_add (dirs,
- g_build_filename (g_get_user_config_dir (),
+ g_ptr_array_add (dirs,
+ g_build_filename (g_get_user_config_dir (),
"autostart", NULL));
system_data_dirs = g_get_system_data_dirs ();
for (i = 0; system_data_dirs[i]; i++)
{
- g_ptr_array_add (dirs,
- g_build_filename (system_data_dirs[i],
+ g_ptr_array_add (dirs,
+ g_build_filename (system_data_dirs[i],
"gnome", "autostart", NULL));
- g_ptr_array_add (dirs,
- g_build_filename (system_data_dirs[i],
+ g_ptr_array_add (dirs,
+ g_build_filename (system_data_dirs[i],
"autostart", NULL));
}
system_config_dirs = g_get_system_config_dirs ();
for (i = 0; system_config_dirs[i]; i++)
{
- g_ptr_array_add (dirs,
- g_build_filename (system_config_dirs[i],
+ g_ptr_array_add (dirs,
+ g_build_filename (system_config_dirs[i],
"autostart", NULL));
}
@@ -79,12 +79,12 @@
system_data_dirs = g_get_system_data_dirs ();
for (i = 0; system_data_dirs[i]; i++)
{
- g_ptr_array_add (dirs,
- g_build_filename (system_data_dirs[i], "applications",
+ g_ptr_array_add (dirs,
+ g_build_filename (system_data_dirs[i], "applications",
NULL));
- g_ptr_array_add (dirs,
- g_build_filename (system_data_dirs[i], "gnome", "wm-properties",
+ g_ptr_array_add (dirs,
+ g_build_filename (system_data_dirs[i], "gnome", "wm-properties",
NULL));
}
@@ -99,7 +99,7 @@
if (str == NULL)
return TRUE;
- while (*str)
+ while (*str)
{
if (!isspace(*str))
return FALSE;
@@ -150,7 +150,7 @@
GTK_BUTTONS_CLOSE, "%s", msg);
g_free (msg);
-
+
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
gtk_dialog_run (GTK_DIALOG (dialog));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]