summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerberos <[email protected]>2011-11-06 10:21:31 -0300
committerPerberos <[email protected]>2011-11-06 10:21:31 -0300
commit8e617a6b7b9742e055148b0e8ebb5982fe64bf9b (patch)
treecd2a8d36ae78a86262ad1b2a8ca8e87026028c53 /src
parent43cee15f735cfdf2615306209990a3cecae21724 (diff)
downloadmate-screensaver-8e617a6b7b9742e055148b0e8ebb5982fe64bf9b.tar.bz2
mate-screensaver-8e617a6b7b9742e055148b0e8ebb5982fe64bf9b.tar.xz
allman
Diffstat (limited to 'src')
-rw-r--r--src/gs-monitor.c419
-rw-r--r--src/mate-screensaver-dialog.c583
-rw-r--r--src/mate-screensaver.c91
-rw-r--r--src/mate-screensaver.h2
4 files changed, 490 insertions, 605 deletions
diff --git a/src/gs-monitor.c b/src/gs-monitor.c
index 2703ba3..c8fdc48 100644
--- a/src/gs-monitor.c
+++ b/src/gs-monitor.c
@@ -41,107 +41,98 @@
#include "gs-prefs.h"
#include "gs-debug.h"
-static void gs_monitor_class_init (GSMonitorClass *klass);
-static void gs_monitor_init (GSMonitor *monitor);
-static void gs_monitor_finalize (GObject *object);
-
-#define GS_MONITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GS_TYPE_MONITOR, GSMonitorPrivate))
-
-struct GSMonitorPrivate
-{
- GSWatcher *watcher;
- GSListener *listener;
- GSManager *manager;
- GSPrefs *prefs;
- GSFade *fade;
- GSGrab *grab;
- guint release_grab_id;
+static void gs_monitor_class_init(GSMonitorClass* klass);
+static void gs_monitor_init(GSMonitor* monitor);
+static void gs_monitor_finalize(GObject* object);
+
+#define GS_MONITOR_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((o), GS_TYPE_MONITOR, GSMonitorPrivate))
+
+struct GSMonitorPrivate {
+ GSWatcher* watcher;
+ GSListener* listener;
+ GSManager* manager;
+ GSPrefs* prefs;
+ GSFade* fade;
+ GSGrab* grab;
+ guint release_grab_id;
};
#define FADE_TIMEOUT 10000
-G_DEFINE_TYPE (GSMonitor, gs_monitor, G_TYPE_OBJECT)
+G_DEFINE_TYPE(GSMonitor, gs_monitor, G_TYPE_OBJECT)
-static void
-gs_monitor_class_init (GSMonitorClass *klass)
+static void gs_monitor_class_init(GSMonitorClass* klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass* object_class = G_OBJECT_CLASS(klass);
object_class->finalize = gs_monitor_finalize;
- g_type_class_add_private (klass, sizeof (GSMonitorPrivate));
+ g_type_class_add_private(klass, sizeof(GSMonitorPrivate));
}
-static void
-manager_activated_cb (GSManager *manager,
- GSMonitor *monitor)
+static void manager_activated_cb(GSManager* manager, GSMonitor* monitor)
{
+ /* Nothing */
}
-static void
-manager_deactivated_cb (GSManager *manager,
- GSMonitor *monitor)
+static void manager_deactivated_cb(GSManager* manager, GSMonitor* monitor)
{
gs_listener_set_active (monitor->priv->listener, FALSE);
}
-static gboolean
-watcher_idle_cb (GSWatcher *watcher,
- gboolean is_idle,
- GSMonitor *monitor)
+static gboolean watcher_idle_cb(GSWatcher* watcher, gboolean is_idle, GSMonitor* monitor)
{
gboolean res;
gs_debug ("Idle signal detected: %d", is_idle);
- res = gs_listener_set_session_idle (monitor->priv->listener, is_idle);
+ res = gs_listener_set_session_idle(monitor->priv->listener, is_idle);
return res;
}
-static gboolean
-release_grab_timeout (GSMonitor *monitor)
+static gboolean release_grab_timeout(GSMonitor* monitor)
{
gboolean manager_active;
- manager_active = gs_manager_get_active (monitor->priv->manager);
+ manager_active = gs_manager_get_active(monitor->priv->manager);
+
if (! manager_active)
{
- gs_grab_release (monitor->priv->grab);
+ gs_grab_release(monitor->priv->grab);
}
monitor->priv->release_grab_id = 0;
return FALSE;
}
-static gboolean
-watcher_idle_notice_cb (GSWatcher *watcher,
- gboolean in_effect,
- GSMonitor *monitor)
+static gboolean watcher_idle_notice_cb(GSWatcher* watcher, gboolean in_effect, GSMonitor* monitor)
{
gboolean activation_enabled;
gboolean inhibited;
gboolean handled;
- gs_debug ("Idle notice signal detected: %d", in_effect);
+ gs_debug("Idle notice signal detected: %d", in_effect);
/* only fade if screensaver can activate */
- activation_enabled = gs_listener_get_activation_enabled (monitor->priv->listener);
- inhibited = gs_listener_is_inhibited (monitor->priv->listener);
+ activation_enabled = gs_listener_get_activation_enabled(monitor->priv->listener);
+ inhibited = gs_listener_is_inhibited(monitor->priv->listener);
handled = FALSE;
+
if (in_effect)
{
if (activation_enabled && ! inhibited)
{
/* start slow fade */
- if (gs_grab_grab_offscreen (monitor->priv->grab, FALSE))
+ if (gs_grab_grab_offscreen(monitor->priv->grab, FALSE))
{
- gs_fade_async (monitor->priv->fade, FADE_TIMEOUT, NULL, NULL);
+ gs_fade_async(monitor->priv->fade, FADE_TIMEOUT, NULL, NULL);
}
else
{
- gs_debug ("Could not grab the keyboard so not performing idle warning fade-out");
+ gs_debug("Could not grab the keyboard so not performing idle warning fade-out");
}
handled = TRUE;
@@ -151,23 +142,24 @@ watcher_idle_notice_cb (GSWatcher *watcher,
{
gboolean manager_active;
- manager_active = gs_manager_get_active (monitor->priv->manager);
+ manager_active = gs_manager_get_active(monitor->priv->manager);
/* cancel the fade unless manager was activated */
if (! manager_active)
{
- gs_debug ("manager not active, performing fade cancellation");
- gs_fade_reset (monitor->priv->fade);
+ gs_debug("manager not active, performing fade cancellation");
+ gs_fade_reset(monitor->priv->fade);
/* don't release the grab immediately to prevent typing passwords into windows */
if (monitor->priv->release_grab_id != 0)
{
- g_source_remove (monitor->priv->release_grab_id);
+ g_source_remove(monitor->priv->release_grab_id);
}
- monitor->priv->release_grab_id = g_timeout_add (1000, (GSourceFunc)release_grab_timeout, monitor);
+
+ monitor->priv->release_grab_id = g_timeout_add(1000, (GSourceFunc) release_grab_timeout, monitor);
}
else
{
- gs_debug ("manager active, skipping fade cancellation");
+ gs_debug("manager active, skipping fade cancellation");
}
handled = TRUE;
@@ -176,131 +168,108 @@ watcher_idle_notice_cb (GSWatcher *watcher,
return handled;
}
-static void
-gs_monitor_lock_screen (GSMonitor *monitor)
+static void gs_monitor_lock_screen(GSMonitor* monitor)
{
gboolean res;
gboolean locked;
/* set lock flag before trying to activate screensaver
in case something tries to react to the ActiveChanged signal */
+ gs_manager_get_lock_active(monitor->priv->manager, &locked);
+ gs_manager_set_lock_active(monitor->priv->manager, TRUE);
+ res = gs_listener_set_active(monitor->priv->listener, TRUE);
- gs_manager_get_lock_active (monitor->priv->manager, &locked);
- gs_manager_set_lock_active (monitor->priv->manager, TRUE);
- res = gs_listener_set_active (monitor->priv->listener, TRUE);
if (! res)
{
/* If we've failed then restore lock status */
- gs_manager_set_lock_active (monitor->priv->manager, locked);
- gs_debug ("Unable to lock the screen");
+ gs_manager_set_lock_active(monitor->priv->manager, locked);
+ gs_debug("Unable to lock the screen");
}
}
-static void
-gs_monitor_simulate_user_activity (GSMonitor *monitor)
+static void gs_monitor_simulate_user_activity(GSMonitor* monitor)
{
/* FIXME: reset the xsync timer? */
/* request that the manager unlock -
will pop up a dialog if necessary */
- gs_manager_request_unlock (monitor->priv->manager);
+ gs_manager_request_unlock(monitor->priv->manager);
}
-static void
-listener_lock_cb (GSListener *listener,
- GSMonitor *monitor)
+static void listener_lock_cb(GSListener* listener, GSMonitor* monitor)
{
- if (! monitor->priv->prefs->lock_disabled)
+ if (!monitor->priv->prefs->lock_disabled)
{
- gs_monitor_lock_screen (monitor);
+ gs_monitor_lock_screen(monitor);
}
else
{
- gs_debug ("Locking disabled by the administrator");
+ gs_debug("Locking disabled by the administrator");
}
}
-static void
-listener_quit_cb (GSListener *listener,
- GSMonitor *monitor)
+static void listener_quit_cb(GSListener* listener, GSMonitor* monitor)
{
- gs_listener_set_active (monitor->priv->listener, FALSE);
- mate_screensaver_quit ();
+ gs_listener_set_active(monitor->priv->listener, FALSE);
+ mate_screensaver_quit();
}
-static void
-listener_cycle_cb (GSListener *listener,
- GSMonitor *monitor)
+static void listener_cycle_cb(GSListener* listener, GSMonitor* monitor)
{
- gs_manager_cycle (monitor->priv->manager);
+ gs_manager_cycle(monitor->priv->manager);
}
-static void
-listener_show_message_cb (GSListener *listener,
- const char *summary,
- const char *body,
- const char *icon,
- GSMonitor *monitor)
+static void listener_show_message_cb(GSListener* listener, const char* summary, const char* body, const char* icon, GSMonitor* monitor)
{
- gs_manager_show_message (monitor->priv->manager,
- summary,
- body,
- icon);
+ gs_manager_show_message(monitor->priv->manager, summary, body, icon);
}
-static gboolean
-listener_active_changed_cb (GSListener *listener,
- gboolean active,
- GSMonitor *monitor)
+static gboolean listener_active_changed_cb(GSListener* listener, gboolean active, GSMonitor* monitor)
{
gboolean res;
gboolean ret;
gboolean idle_watch_enabled;
- res = gs_manager_set_active (monitor->priv->manager, active);
+ res = gs_manager_set_active(monitor->priv->manager, active);
+
if (! res)
{
- gs_debug ("Unable to set manager active: %d", active);
+ gs_debug("Unable to set manager active: %d", active);
ret = FALSE;
goto done;
}
ret = TRUE;
-done:
+ done:
+
+ idle_watch_enabled = gs_watcher_get_enabled(monitor->priv->watcher);
- idle_watch_enabled = gs_watcher_get_enabled (monitor->priv->watcher);
if (ret && idle_watch_enabled)
{
- res = gs_watcher_set_active (monitor->priv->watcher, !active);
- if (! res)
+ res = gs_watcher_set_active(monitor->priv->watcher, !active);
+
+ if (!res)
{
- gs_debug ("Unable to set the idle watcher active: %d", !active);
+ gs_debug("Unable to set the idle watcher active: %d", !active);
}
}
return ret;
}
-static void
-listener_throttle_changed_cb (GSListener *listener,
- gboolean throttled,
- GSMonitor *monitor)
+static void listener_throttle_changed_cb(GSListener* listener, gboolean throttled, GSMonitor* monitor)
{
- gs_manager_set_throttled (monitor->priv->manager, throttled);
+ gs_manager_set_throttled(monitor->priv->manager, throttled);
}
-static void
-listener_simulate_user_activity_cb (GSListener *listener,
- GSMonitor *monitor)
+static void listener_simulate_user_activity_cb(GSListener* listener, GSMonitor* monitor)
{
- gs_monitor_simulate_user_activity (monitor);
+ gs_monitor_simulate_user_activity(monitor);
}
-static void
-_gs_monitor_update_from_prefs (GSMonitor *monitor,
- GSPrefs *prefs)
+static void _gs_monitor_update_from_prefs(GSMonitor* monitor, GSPrefs* prefs)
{
gboolean idle_detection_enabled;
gboolean idle_detection_active;
@@ -312,214 +281,182 @@ _gs_monitor_update_from_prefs (GSMonitor *monitor,
lock_enabled = (monitor->priv->prefs->lock_enabled && !monitor->priv->prefs->lock_disabled);
user_switch_enabled = (monitor->priv->prefs->user_switch_enabled && !monitor->priv->prefs->user_switch_disabled);
- gs_manager_set_lock_enabled (monitor->priv->manager, lock_enabled);
- gs_manager_set_lock_timeout (monitor->priv->manager, monitor->priv->prefs->lock_timeout);
- gs_manager_set_logout_enabled (monitor->priv->manager, monitor->priv->prefs->logout_enabled);
- gs_manager_set_user_switch_enabled (monitor->priv->manager, user_switch_enabled);
- gs_manager_set_keyboard_enabled (monitor->priv->manager, monitor->priv->prefs->keyboard_enabled);
- gs_manager_set_logout_timeout (monitor->priv->manager, monitor->priv->prefs->logout_timeout);
- gs_manager_set_logout_command (monitor->priv->manager, monitor->priv->prefs->logout_command);
- gs_manager_set_keyboard_command (monitor->priv->manager, monitor->priv->prefs->keyboard_command);
- gs_manager_set_cycle_timeout (monitor->priv->manager, monitor->priv->prefs->cycle);
- gs_manager_set_mode (monitor->priv->manager, monitor->priv->prefs->mode);
- gs_manager_set_themes (monitor->priv->manager, monitor->priv->prefs->themes);
+ gs_manager_set_lock_enabled(monitor->priv->manager, lock_enabled);
+ gs_manager_set_lock_timeout(monitor->priv->manager, monitor->priv->prefs->lock_timeout);
+ gs_manager_set_logout_enabled(monitor->priv->manager, monitor->priv->prefs->logout_enabled);
+ gs_manager_set_user_switch_enabled(monitor->priv->manager, user_switch_enabled);
+ gs_manager_set_keyboard_enabled(monitor->priv->manager, monitor->priv->prefs->keyboard_enabled);
+ gs_manager_set_logout_timeout(monitor->priv->manager, monitor->priv->prefs->logout_timeout);
+ gs_manager_set_logout_command(monitor->priv->manager, monitor->priv->prefs->logout_command);
+ gs_manager_set_keyboard_command(monitor->priv->manager, monitor->priv->prefs->keyboard_command);
+ gs_manager_set_cycle_timeout(monitor->priv->manager, monitor->priv->prefs->cycle);
+ gs_manager_set_mode(monitor->priv->manager, monitor->priv->prefs->mode);
+ gs_manager_set_themes(monitor->priv->manager, monitor->priv->prefs->themes);
/* enable activation when allowed */
- gs_listener_set_activation_enabled (monitor->priv->listener,
- monitor->priv->prefs->idle_activation_enabled);
+ gs_listener_set_activation_enabled(monitor->priv->listener, monitor->priv->prefs->idle_activation_enabled);
/* idle detection always enabled */
idle_detection_enabled = TRUE;
- gs_watcher_set_enabled (monitor->priv->watcher, idle_detection_enabled);
+ gs_watcher_set_enabled(monitor->priv->watcher, idle_detection_enabled);
/* in the case where idle detection is reenabled we may need to
activate the watcher too */
- manager_active = gs_manager_get_active (monitor->priv->manager);
- idle_detection_active = gs_watcher_get_active (monitor->priv->watcher);
- activate_watch = (! manager_active
- && ! idle_detection_active
- && idle_detection_enabled);
+ manager_active = gs_manager_get_active(monitor->priv->manager);
+ idle_detection_active = gs_watcher_get_active(monitor->priv->watcher);
+
+ activate_watch = (! manager_active && ! idle_detection_active && idle_detection_enabled);
+
if (activate_watch)
{
- gs_watcher_set_active (monitor->priv->watcher, TRUE);
+ gs_watcher_set_active(monitor->priv->watcher, TRUE);
}
if (monitor->priv->prefs->status_message_enabled)
{
- char *text;
- g_object_get (monitor->priv->watcher,
- "status-message", &text,
- NULL);
- gs_manager_set_status_message (monitor->priv->manager, text);
- g_free (text);
+ char* text;
+ g_object_get(monitor->priv->watcher, "status-message", &text, NULL);
+ gs_manager_set_status_message(monitor->priv->manager, text);
+ g_free(text);
}
else
{
- gs_manager_set_status_message (monitor->priv->manager, NULL);
+ gs_manager_set_status_message(monitor->priv->manager, NULL);
}
}
-static void
-disconnect_listener_signals (GSMonitor *monitor)
+static void disconnect_listener_signals(GSMonitor* monitor)
{
- g_signal_handlers_disconnect_by_func (monitor->priv->listener, listener_lock_cb, monitor);
- g_signal_handlers_disconnect_by_func (monitor->priv->listener, listener_quit_cb, monitor);
- g_signal_handlers_disconnect_by_func (monitor->priv->listener, listener_cycle_cb, monitor);
- g_signal_handlers_disconnect_by_func (monitor->priv->listener, listener_active_changed_cb, monitor);
- g_signal_handlers_disconnect_by_func (monitor->priv->listener, listener_throttle_changed_cb, monitor);
- g_signal_handlers_disconnect_by_func (monitor->priv->listener, listener_simulate_user_activity_cb, monitor);
- g_signal_handlers_disconnect_by_func (monitor->priv->listener, listener_show_message_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_lock_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_quit_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_cycle_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_active_changed_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_throttle_changed_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_simulate_user_activity_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_show_message_cb, monitor);
}
-static void
-connect_listener_signals (GSMonitor *monitor)
+static void connect_listener_signals(GSMonitor* monitor)
{
- g_signal_connect (monitor->priv->listener, "lock",
- G_CALLBACK (listener_lock_cb), monitor);
- g_signal_connect (monitor->priv->listener, "quit",
- G_CALLBACK (listener_quit_cb), monitor);
- g_signal_connect (monitor->priv->listener, "cycle",
- G_CALLBACK (listener_cycle_cb), monitor);
- g_signal_connect (monitor->priv->listener, "active-changed",
- G_CALLBACK (listener_active_changed_cb), monitor);
- g_signal_connect (monitor->priv->listener, "throttle-changed",
- G_CALLBACK (listener_throttle_changed_cb), monitor);
- g_signal_connect (monitor->priv->listener, "simulate-user-activity",
- G_CALLBACK (listener_simulate_user_activity_cb), monitor);
- g_signal_connect (monitor->priv->listener, "show-message",
- G_CALLBACK (listener_show_message_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "lock", G_CALLBACK(listener_lock_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "quit", G_CALLBACK(listener_quit_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "cycle", G_CALLBACK(listener_cycle_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "active-changed", G_CALLBACK(listener_active_changed_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "throttle-changed", G_CALLBACK(listener_throttle_changed_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "simulate-user-activity", G_CALLBACK(listener_simulate_user_activity_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "show-message", G_CALLBACK(listener_show_message_cb), monitor);
}
-static void
-on_watcher_status_message_changed (GSWatcher *watcher,
- GParamSpec *pspec,
- GSMonitor *monitor)
+static void on_watcher_status_message_changed(GSWatcher* watcher, GParamSpec* pspec, GSMonitor* monitor)
{
- char *text;
- g_object_get (watcher, "status-message", &text, NULL);
- gs_manager_set_status_message (monitor->priv->manager, text);
- g_free (text);
+ char* text;
+ g_object_get(watcher, "status-message", &text, NULL);
+ gs_manager_set_status_message(monitor->priv->manager, text);
+ g_free(text);
}
-static void
-disconnect_watcher_signals (GSMonitor *monitor)
+static void disconnect_watcher_signals(GSMonitor *monitor)
{
- g_signal_handlers_disconnect_by_func (monitor->priv->watcher, watcher_idle_cb, monitor);
- g_signal_handlers_disconnect_by_func (monitor->priv->watcher, watcher_idle_notice_cb, monitor);
- g_signal_handlers_disconnect_by_func (monitor->priv->watcher, on_watcher_status_message_changed, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->watcher, watcher_idle_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->watcher, watcher_idle_notice_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->watcher, on_watcher_status_message_changed, monitor);
}
-static void
-connect_watcher_signals (GSMonitor *monitor)
+static void connect_watcher_signals(GSMonitor *monitor)
{
- g_signal_connect (monitor->priv->watcher, "idle-changed",
- G_CALLBACK (watcher_idle_cb), monitor);
- g_signal_connect (monitor->priv->watcher, "idle-notice-changed",
- G_CALLBACK (watcher_idle_notice_cb), monitor);
- g_signal_connect (monitor->priv->watcher, "notify::status-message",
- G_CALLBACK (on_watcher_status_message_changed), monitor);
+ g_signal_connect(monitor->priv->watcher, "idle-changed", G_CALLBACK(watcher_idle_cb), monitor);
+ g_signal_connect(monitor->priv->watcher, "idle-notice-changed", G_CALLBACK(watcher_idle_notice_cb), monitor);
+ g_signal_connect(monitor->priv->watcher, "notify::status-message", G_CALLBACK(on_watcher_status_message_changed), monitor);
}
-static void
-disconnect_manager_signals (GSMonitor *monitor)
+static void disconnect_manager_signals(GSMonitor* monitor)
{
- g_signal_handlers_disconnect_by_func (monitor->priv->manager, manager_activated_cb, monitor);
- g_signal_handlers_disconnect_by_func (monitor->priv->manager, manager_deactivated_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->manager, manager_activated_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->manager, manager_deactivated_cb, monitor);
}
-static void
-connect_manager_signals (GSMonitor *monitor)
+static void connect_manager_signals(GSMonitor* monitor)
{
- g_signal_connect (monitor->priv->manager, "activated",
- G_CALLBACK (manager_activated_cb), monitor);
- g_signal_connect (monitor->priv->manager, "deactivated",
- G_CALLBACK (manager_deactivated_cb), monitor);
+ g_signal_connect(monitor->priv->manager, "activated", G_CALLBACK(manager_activated_cb), monitor);
+ g_signal_connect(monitor->priv->manager, "deactivated", G_CALLBACK(manager_deactivated_cb), monitor);
}
-static void
-disconnect_prefs_signals (GSMonitor *monitor)
+static void disconnect_prefs_signals(GSMonitor* monitor)
{
- g_signal_handlers_disconnect_by_func (monitor->priv->prefs, _gs_monitor_update_from_prefs, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->prefs, _gs_monitor_update_from_prefs, monitor);
}
-static void
-connect_prefs_signals (GSMonitor *monitor)
+static void connect_prefs_signals(GSMonitor* monitor)
{
- g_signal_connect_swapped (monitor->priv->prefs, "changed",
- G_CALLBACK (_gs_monitor_update_from_prefs), monitor);
+ g_signal_connect_swapped(monitor->priv->prefs, "changed", G_CALLBACK(_gs_monitor_update_from_prefs), monitor);
}
-static void
-gs_monitor_init (GSMonitor *monitor)
+static void gs_monitor_init(GSMonitor* monitor)
{
- monitor->priv = GS_MONITOR_GET_PRIVATE (monitor);
+ monitor->priv = GS_MONITOR_GET_PRIVATE(monitor);
- monitor->priv->prefs = gs_prefs_new ();
- connect_prefs_signals (monitor);
+ monitor->priv->prefs = gs_prefs_new();
+ connect_prefs_signals(monitor);
- monitor->priv->listener = gs_listener_new ();
- connect_listener_signals (monitor);
+ monitor->priv->listener = gs_listener_new();
+ connect_listener_signals(monitor);
- monitor->priv->fade = gs_fade_new ();
- monitor->priv->grab = gs_grab_new ();
+ monitor->priv->fade = gs_fade_new();
+ monitor->priv->grab = gs_grab_new();
- monitor->priv->watcher = gs_watcher_new ();
- connect_watcher_signals (monitor);
+ monitor->priv->watcher = gs_watcher_new();
+ connect_watcher_signals(monitor);
- monitor->priv->manager = gs_manager_new ();
- connect_manager_signals (monitor);
+ monitor->priv->manager = gs_manager_new();
+ connect_manager_signals(monitor);
- _gs_monitor_update_from_prefs (monitor, monitor->priv->prefs);
+ _gs_monitor_update_from_prefs(monitor, monitor->priv->prefs);
}
-static void
-gs_monitor_finalize (GObject *object)
+static void gs_monitor_finalize(GObject* object)
{
- GSMonitor *monitor;
+ GSMonitor* monitor;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GS_IS_MONITOR (object));
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GS_IS_MONITOR(object));
- monitor = GS_MONITOR (object);
+ monitor = GS_MONITOR(object);
- g_return_if_fail (monitor->priv != NULL);
+ g_return_if_fail(monitor->priv != NULL);
- disconnect_watcher_signals (monitor);
- disconnect_listener_signals (monitor);
- disconnect_manager_signals (monitor);
- disconnect_prefs_signals (monitor);
+ disconnect_watcher_signals(monitor);
+ disconnect_listener_signals(monitor);
+ disconnect_manager_signals(monitor);
+ disconnect_prefs_signals(monitor);
- g_object_unref (monitor->priv->fade);
- g_object_unref (monitor->priv->grab);
- g_object_unref (monitor->priv->watcher);
- g_object_unref (monitor->priv->listener);
- g_object_unref (monitor->priv->manager);
- g_object_unref (monitor->priv->prefs);
+ g_object_unref(monitor->priv->fade);
+ g_object_unref(monitor->priv->grab);
+ g_object_unref(monitor->priv->watcher);
+ g_object_unref(monitor->priv->listener);
+ g_object_unref(monitor->priv->manager);
+ g_object_unref(monitor->priv->prefs);
- G_OBJECT_CLASS (gs_monitor_parent_class)->finalize (object);
+ G_OBJECT_CLASS(gs_monitor_parent_class)->finalize(object);
}
-GSMonitor *
-gs_monitor_new (void)
+GSMonitor* gs_monitor_new(void)
{
- GSMonitor *monitor;
+ GSMonitor* monitor;
- monitor = g_object_new (GS_TYPE_MONITOR, NULL);
+ monitor = g_object_new(GS_TYPE_MONITOR, NULL);
- return GS_MONITOR (monitor);
+ return GS_MONITOR(monitor);
}
-gboolean
-gs_monitor_start (GSMonitor *monitor,
- GError **error)
+gboolean gs_monitor_start(GSMonitor* monitor, GError** error)
{
- g_return_val_if_fail (GS_IS_MONITOR (monitor), FALSE);
+ g_return_val_if_fail(GS_IS_MONITOR(monitor), FALSE);
- if (! gs_listener_acquire (monitor->priv->listener, error))
+ if (!gs_listener_acquire(monitor->priv->listener, error))
{
return FALSE;
}
diff --git a/src/mate-screensaver-dialog.c b/src/mate-screensaver-dialog.c
index d698159..10083aa 100644
--- a/src/mate-screensaver-dialog.c
+++ b/src/mate-screensaver-dialog.c
@@ -44,146 +44,114 @@
#define MAX_FAILURES 5
-static gboolean verbose = FALSE;
-static gboolean show_version = FALSE;
-static gboolean enable_logout = FALSE;
-static gboolean enable_switch = FALSE;
-static char *logout_command = NULL;
-static char *status_message = NULL;
-static char *away_message = NULL;
-
-static GOptionEntry entries [] =
-{
- {
- "verbose", 0, 0, G_OPTION_ARG_NONE, &verbose,
- N_("Show debugging output"), NULL
- },
- {
- "version", 0, 0, G_OPTION_ARG_NONE, &show_version,
- N_("Version of this application"), NULL
- },
- {
- "enable-logout", 0, 0, G_OPTION_ARG_NONE, &enable_logout,
- N_("Show the logout button"), NULL
- },
- {
- "logout-command", 0, 0, G_OPTION_ARG_STRING, &logout_command,
- N_("Command to invoke from the logout button"), NULL
- },
- {
- "enable-switch", 0, 0, G_OPTION_ARG_NONE, &enable_switch,
- N_("Show the switch user button"), NULL
- },
- {
- "status-message", 0, 0, G_OPTION_ARG_STRING, &status_message,
- N_("Message to show in the dialog"), N_("MESSAGE")
- },
- {
- "away-message", 0, 0, G_OPTION_ARG_STRING, &away_message,
- N_("Not used"), N_("MESSAGE")
- },
- { NULL }
+static gboolean verbose = FALSE;
+static gboolean show_version = FALSE;
+static gboolean enable_logout = FALSE;
+static gboolean enable_switch = FALSE;
+static char* logout_command = NULL;
+static char* status_message = NULL;
+static char* away_message = NULL;
+
+static GOptionEntry entries[] = {
+ {"verbose", 0, 0, G_OPTION_ARG_NONE, &verbose, N_("Show debugging output"), NULL},
+ {"version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL},
+ {"enable-logout", 0, 0, G_OPTION_ARG_NONE, &enable_logout, N_("Show the logout button"), NULL},
+ {"logout-command", 0, 0, G_OPTION_ARG_STRING, &logout_command, N_("Command to invoke from the logout button"), NULL},
+ {"enable-switch", 0, 0, G_OPTION_ARG_NONE, &enable_switch, N_("Show the switch user button"), NULL},
+ {"status-message", 0, 0, G_OPTION_ARG_STRING, &status_message, N_("Message to show in the dialog"), N_("MESSAGE")},
+ {"away-message", 0, 0, G_OPTION_ARG_STRING, &away_message, N_("Not used"), N_("MESSAGE")},
+ {NULL}
};
-static char *
-get_id_string (GtkWidget *widget)
+static char* get_id_string(GtkWidget* widget)
{
- char *id = NULL;
+ char* id = NULL;
- g_return_val_if_fail (widget != NULL, NULL);
- g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail(widget != NULL, NULL);
+ g_return_val_if_fail(GTK_IS_WIDGET(widget), NULL);
- id = g_strdup_printf ("%" G_GUINT32_FORMAT,
- (guint32) GDK_WINDOW_XID (widget->window));
+ id = g_strdup_printf("%" G_GUINT32_FORMAT, (guint32) GDK_WINDOW_XID(widget->window));
return id;
}
-static gboolean
-print_id (GtkWidget *widget)
+static gboolean print_id(GtkWidget* widget)
{
- char *id;
+ char* id;
- gs_profile_start (NULL);
+ gs_profile_start(NULL);
- id = get_id_string (widget);
- printf ("WINDOW ID=%s\n", id);
- fflush (stdout);
+ id = get_id_string(widget);
+ printf("WINDOW ID=%s\n", id);
+ fflush(stdout);
- gs_profile_end (NULL);
+ gs_profile_end(NULL);
- g_free (id);
+ g_free(id);
return FALSE;
}
-static void
-response_cancel (void)
+static void response_cancel(void)
{
- printf ("RESPONSE=CANCEL\n");
- fflush (stdout);
+ printf("RESPONSE=CANCEL\n");
+ fflush(stdout);
}
-static void
-response_ok (void)
+static void response_ok(void)
{
- printf ("RESPONSE=OK\n");
- fflush (stdout);
+ printf("RESPONSE=OK\n");
+ fflush(stdout);
}
-static gboolean
-quit_response_ok (void)
+static gboolean quit_response_ok(void)
{
- response_ok ();
- gtk_main_quit ();
+ response_ok();
+ gtk_main_quit();
return FALSE;
}
-static gboolean
-quit_response_cancel (void)
+static gboolean quit_response_cancel(void)
{
- response_cancel ();
- gtk_main_quit ();
+ response_cancel();
+ gtk_main_quit();
return FALSE;
}
-static void
-response_lock_init_failed (void)
+static void response_lock_init_failed(void)
{
/* if we fail to lock then we should drop the dialog */
- response_ok ();
+ response_ok();
}
-static char *
-request_response (GSLockPlug *plug,
- const char *prompt,
- gboolean visible)
+static char* request_response(GSLockPlug* plug, const char* prompt, gboolean visible)
{
- int response;
- char *text;
+ int response;
+ char* text;
- gs_lock_plug_set_sensitive (plug, TRUE);
- gs_lock_plug_enable_prompt (plug, prompt, visible);
- response = gs_lock_plug_run (plug);
+ gs_lock_plug_set_sensitive(plug, TRUE);
+ gs_lock_plug_enable_prompt(plug, prompt, visible);
+ response = gs_lock_plug_run(plug);
gs_debug ("got response: %d", response);
text = NULL;
+
if (response == GS_LOCK_PLUG_RESPONSE_OK)
{
- gs_lock_plug_get_text (plug, &text);
+ gs_lock_plug_get_text(plug, &text);
}
- gs_lock_plug_disable_prompt (plug);
+
+ gs_lock_plug_disable_prompt(plug);
return text;
}
/* Adapted from MDM2 daemon/verify-pam.c on 2006-06-13 */
-static const char *
-maybe_translate_message (const char *msg)
+static const char* maybe_translate_message(const char* msg)
{
- char *s;
- const char *ret;
- static GHashTable *hash = NULL;
+ char* s;
+ const char* ret;
+ static GHashTable* hash = NULL;
if (hash == NULL)
{
@@ -193,31 +161,31 @@ maybe_translate_message (const char *msg)
some of these messages to be more sane. */
hash = g_hash_table_new (g_str_hash, g_str_equal);
/* login: is whacked always translate to Username: */
- g_hash_table_insert (hash, "login:", _("Username:"));
- g_hash_table_insert (hash, "Username:", _("Username:"));
- g_hash_table_insert (hash, "username:", _("Username:"));
- g_hash_table_insert (hash, "Password:", _("Password:"));
- g_hash_table_insert (hash, "password:", _("Password:"));
- g_hash_table_insert (hash, "You are required to change your password immediately (password aged)", _("You are required to change your password immediately (password aged)"));
- g_hash_table_insert (hash, "You are required to change your password immediately (root enforced)", _("You are required to change your password immediately (root enforced)"));
- g_hash_table_insert (hash, "Your account has expired; please contact your system administrator", _("Your account has expired; please contact your system administrator"));
- g_hash_table_insert (hash, "No password supplied", _("No password supplied"));
- g_hash_table_insert (hash, "Password unchanged", _("Password unchanged"));
- g_hash_table_insert (hash, "Can not get username", _("Can not get username"));
- g_hash_table_insert (hash, "Retype new UNIX password:", _("Retype new UNIX password:"));
- g_hash_table_insert (hash, "Enter new UNIX password:", _("Enter new UNIX password:"));
- g_hash_table_insert (hash, "(current) UNIX password:", _("(current) UNIX password:"));
- g_hash_table_insert (hash, "Error while changing NIS password.", _("Error while changing NIS password."));
- g_hash_table_insert (hash, "You must choose a longer password", _("You must choose a longer password"));
- g_hash_table_insert (hash, "Password has been already used. Choose another.", _("Password has been already used. Choose another."));
- g_hash_table_insert (hash, "You must wait longer to change your password", _("You must wait longer to change your password"));
- g_hash_table_insert (hash, "Sorry, passwords do not match", _("Sorry, passwords do not match"));
+ g_hash_table_insert(hash, "login:", _("Username:"));
+ g_hash_table_insert(hash, "Username:", _("Username:"));
+ g_hash_table_insert(hash, "username:", _("Username:"));
+ g_hash_table_insert(hash, "Password:", _("Password:"));
+ g_hash_table_insert(hash, "password:", _("Password:"));
+ g_hash_table_insert(hash, "You are required to change your password immediately (password aged)", _("You are required to change your password immediately (password aged)"));
+ g_hash_table_insert(hash, "You are required to change your password immediately (root enforced)", _("You are required to change your password immediately (root enforced)"));
+ g_hash_table_insert(hash, "Your account has expired; please contact your system administrator", _("Your account has expired; please contact your system administrator"));
+ g_hash_table_insert(hash, "No password supplied", _("No password supplied"));
+ g_hash_table_insert(hash, "Password unchanged", _("Password unchanged"));
+ g_hash_table_insert(hash, "Can not get username", _("Can not get username"));
+ g_hash_table_insert(hash, "Retype new UNIX password:", _("Retype new UNIX password:"));
+ g_hash_table_insert(hash, "Enter new UNIX password:", _("Enter new UNIX password:"));
+ g_hash_table_insert(hash, "(current) UNIX password:", _("(current) UNIX password:"));
+ g_hash_table_insert(hash, "Error while changing NIS password.", _("Error while changing NIS password."));
+ g_hash_table_insert(hash, "You must choose a longer password", _("You must choose a longer password"));
+ g_hash_table_insert(hash, "Password has been already used. Choose another.", _("Password has been already used. Choose another."));
+ g_hash_table_insert(hash, "You must wait longer to change your password", _("You must wait longer to change your password"));
+ g_hash_table_insert(hash, "Sorry, passwords do not match", _("Sorry, passwords do not match"));
/* FIXME: what about messages which have some variables in them, perhaps try to do those as well */
}
- s = g_strstrip (g_strdup (msg));
- ret = g_hash_table_lookup (hash, s);
- g_free (s);
+ s = g_strstrip(g_strdup(msg));
+ ret = g_hash_table_lookup(hash, s);
+ g_free(s);
if (ret != NULL)
{
@@ -229,165 +197,154 @@ maybe_translate_message (const char *msg)
}
}
-static gboolean
-auth_message_handler (GSAuthMessageStyle style,
- const char *msg,
- char **response,
- gpointer data)
+static gboolean auth_message_handler(GSAuthMessageStyle style, const char* msg, char** response, gpointer data)
{
- gboolean ret;
- GSLockPlug *plug;
- const char *message;
+ gboolean ret;
+ GSLockPlug* plug;
+ const char* message;
- plug = GS_LOCK_PLUG (data);
+ plug = GS_LOCK_PLUG(data);
- gs_profile_start (NULL);
- gs_debug ("Got message style %d: '%s'", style, msg);
+ gs_profile_start(NULL);
+ gs_debug("Got message style %d: '%s'", style, msg);
- gtk_widget_show (GTK_WIDGET (plug));
- gs_lock_plug_set_ready (plug);
+ gtk_widget_show(GTK_WIDGET(plug));
+ gs_lock_plug_set_ready(plug);
ret = TRUE;
*response = NULL;
- message = maybe_translate_message (msg);
+ message = maybe_translate_message(msg);
switch (style)
{
- case GS_AUTH_MESSAGE_PROMPT_ECHO_ON:
- if (msg != NULL)
- {
- char *resp;
- resp = request_response (plug, message, TRUE);
- *response = resp;
- }
- break;
- case GS_AUTH_MESSAGE_PROMPT_ECHO_OFF:
- if (msg != NULL)
- {
- char *resp;
- resp = request_response (plug, message, FALSE);
- *response = resp;
- }
- break;
- case GS_AUTH_MESSAGE_ERROR_MSG:
- gs_lock_plug_show_message (plug, message);
- break;
- case GS_AUTH_MESSAGE_TEXT_INFO:
- gs_lock_plug_show_message (plug, message);
- break;
- default:
- g_assert_not_reached ();
+ case GS_AUTH_MESSAGE_PROMPT_ECHO_ON:
+ if (msg != NULL)
+ {
+ char *resp;
+ resp = request_response(plug, message, TRUE);
+ *response = resp;
+ }
+ break;
+ case GS_AUTH_MESSAGE_PROMPT_ECHO_OFF:
+ if (msg != NULL)
+ {
+ char *resp;
+ resp = request_response(plug, message, FALSE);
+ *response = resp;
+ }
+ break;
+ case GS_AUTH_MESSAGE_ERROR_MSG:
+ gs_lock_plug_show_message(plug, message);
+ break;
+ case GS_AUTH_MESSAGE_TEXT_INFO:
+ gs_lock_plug_show_message(plug, message);
+ break;
+ default:
+ g_assert_not_reached();
}
if (*response == NULL)
{
- gs_debug ("Got no response");
+ gs_debug("Got no response");
ret = FALSE;
}
else
{
- gs_lock_plug_show_message (plug, _("Checking..."));
- gs_lock_plug_set_sensitive (plug, FALSE);
+ gs_lock_plug_show_message(plug, _("Checking..."));
+ gs_lock_plug_set_sensitive(plug, FALSE);
}
/* we may have pending events that should be processed before continuing back into PAM */
- while (gtk_events_pending ())
+ while (gtk_events_pending())
{
- gtk_main_iteration ();
+ gtk_main_iteration();
}
- gs_lock_plug_set_busy (plug);
- gs_profile_end (NULL);
+ gs_lock_plug_set_busy(plug);
+ gs_profile_end(NULL);
return ret;
}
-static gboolean
-reset_idle_cb (GSLockPlug *plug)
+static gboolean reset_idle_cb(GSLockPlug* plug)
{
- gs_lock_plug_set_sensitive (plug, TRUE);
- gs_lock_plug_show_message (plug, NULL);
+ gs_lock_plug_set_sensitive(plug, TRUE);
+ gs_lock_plug_show_message(plug, NULL);
return FALSE;
}
-static gboolean
-do_auth_check (GSLockPlug *plug)
+static gboolean do_auth_check(GSLockPlug* plug)
{
- GError *error;
+ GError* error;
gboolean res;
error = NULL;
- gs_lock_plug_disable_prompt (plug);
- gs_lock_plug_set_busy (plug);
- res = gs_auth_verify_user (g_get_user_name (), g_getenv ("DISPLAY"), auth_message_handler, plug, &error);
+ gs_lock_plug_disable_prompt(plug);
+ gs_lock_plug_set_busy(plug);
+ res = gs_auth_verify_user(g_get_user_name(), g_getenv("DISPLAY"), auth_message_handler, plug, &error);
+
+ gs_debug("Verify user returned: %s", res ? "TRUE" : "FALSE");
- gs_debug ("Verify user returned: %s", res ? "TRUE" : "FALSE");
if (! res)
{
if (error != NULL)
{
- gs_debug ("Verify user returned error: %s", error->message);
- gs_lock_plug_show_message (plug, error->message);
+ gs_debug("Verify user returned error: %s", error->message);
+ gs_lock_plug_show_message(plug, error->message);
}
else
{
- gs_lock_plug_show_message (plug, _("Authentication failed."));
+ gs_lock_plug_show_message(plug, _("Authentication failed."));
}
- printf ("NOTICE=AUTH FAILED\n");
- fflush (stdout);
+ printf("NOTICE=AUTH FAILED\n");
+ fflush(stdout);
if (error != NULL)
{
- g_error_free (error);
+ g_error_free(error);
}
}
return res;
}
-static void
-response_cb (GSLockPlug *plug,
- gint response_id)
+static void response_cb(GSLockPlug* plug, gint response_id)
{
- if ((response_id == GS_LOCK_PLUG_RESPONSE_CANCEL) ||
- (response_id == GTK_RESPONSE_DELETE_EVENT))
+ if ((response_id == GS_LOCK_PLUG_RESPONSE_CANCEL) || (response_id == GTK_RESPONSE_DELETE_EVENT))
{
- quit_response_cancel ();
+ quit_response_cancel();
}
}
-static gboolean
-response_request_quit (void)
+static gboolean response_request_quit(void)
{
- printf ("REQUEST QUIT\n");
- fflush (stdout);
+ printf("REQUEST QUIT\n");
+ fflush(stdout);
return FALSE;
}
-static gboolean
-quit_timeout_cb (gpointer data)
+static gboolean quit_timeout_cb(gpointer data)
{
- gtk_main_quit ();
+ gtk_main_quit();
return FALSE;
}
-static gboolean
-auth_check_idle (GSLockPlug *plug)
+static gboolean auth_check_idle(GSLockPlug* plug)
{
- gboolean res;
- gboolean again;
+ gboolean res;
+ gboolean again;
static guint loop_counter = 0;
again = TRUE;
- res = do_auth_check (plug);
+ res = do_auth_check(plug);
if (res)
{
again = FALSE;
- g_idle_add ((GSourceFunc)quit_response_ok, NULL);
+ g_idle_add((GSourceFunc) quit_response_ok, NULL);
}
else
{
@@ -396,7 +353,7 @@ auth_check_idle (GSLockPlug *plug)
if (loop_counter < MAX_FAILURES)
{
gs_debug ("Authentication failed, retrying (%u)", loop_counter);
- g_timeout_add (3000, (GSourceFunc)reset_idle_cb, plug);
+ g_timeout_add (3000, (GSourceFunc) reset_idle_cb, plug);
}
else
{
@@ -405,58 +362,55 @@ auth_check_idle (GSLockPlug *plug)
/* Don't quit immediately, but rather request that mate-screensaver
* terminates us after it has finished the dialog shake. Time out
* after 5 seconds and quit anyway if this doesn't happen though */
- g_idle_add ((GSourceFunc)response_request_quit, NULL);
- g_timeout_add (5000, (GSourceFunc)quit_timeout_cb, NULL);
+ g_idle_add((GSourceFunc) response_request_quit, NULL);
+ g_timeout_add(5000, (GSourceFunc) quit_timeout_cb, NULL);
}
}
return again;
}
-static void
-show_cb (GtkWidget *widget,
- gpointer data)
+static void show_cb(GtkWidget* widget, gpointer data)
{
- print_id (widget);
+ print_id(widget);
}
-static gboolean
-popup_dialog_idle (void)
+static gboolean popup_dialog_idle(void)
{
- GtkWidget *widget;
+ GtkWidget* widget;
- gs_profile_start (NULL);
+ gs_profile_start(NULL);
- widget = gs_lock_plug_new ();
+ widget = gs_lock_plug_new();
if (enable_logout)
{
- g_object_set (widget, "logout-enabled", TRUE, NULL);
+ g_object_set(widget, "logout-enabled", TRUE, NULL);
}
if (logout_command)
{
- g_object_set (widget, "logout-command", logout_command, NULL);
+ g_object_set(widget, "logout-command", logout_command, NULL);
}
if (enable_switch)
{
- g_object_set (widget, "switch-enabled", TRUE, NULL);
+ g_object_set(widget, "switch-enabled", TRUE, NULL);
}
if (status_message)
{
- g_object_set (widget, "status-message", status_message, NULL);
+ g_object_set(widget, "status-message", status_message, NULL);
}
- g_signal_connect (GS_LOCK_PLUG (widget), "response", G_CALLBACK (response_cb), NULL);
- g_signal_connect (widget, "show", G_CALLBACK (show_cb), NULL);
+ g_signal_connect(GS_LOCK_PLUG(widget), "response", G_CALLBACK(response_cb), NULL);
+ g_signal_connect(widget, "show", G_CALLBACK(show_cb), NULL);
- gtk_widget_realize (widget);
+ gtk_widget_realize(widget);
- g_idle_add ((GSourceFunc)auth_check_idle, widget);
+ g_idle_add((GSourceFunc) auth_check_idle, widget);
- gs_profile_end (NULL);
+ gs_profile_end(NULL);
return FALSE;
}
@@ -470,42 +424,37 @@ popup_dialog_idle (void)
If the executable is setuid root, then these initializations
are run as root, before discarding privileges.
*/
-static gboolean
-privileged_initialization (int *argc,
- char **argv,
- gboolean verbose)
+static gboolean privileged_initialization(int* argc, char** argv, gboolean verbose)
{
gboolean ret;
- char *nolock_reason;
- char *orig_uid;
- char *uid_message;
+ char* nolock_reason;
+ char* orig_uid;
+ char* uid_message;
- gs_profile_start (NULL);
+ gs_profile_start(NULL);
-#ifndef NO_LOCKING
- /* before hack_uid () for proper permissions */
- gs_auth_priv_init ();
-#endif /* NO_LOCKING */
+ #ifndef NO_LOCKING
+ /* before hack_uid () for proper permissions */
+ gs_auth_priv_init();
+ #endif /* NO_LOCKING */
- ret = hack_uid (&nolock_reason,
- &orig_uid,
- &uid_message);
+ ret = hack_uid(&nolock_reason, &orig_uid, &uid_message);
if (nolock_reason)
{
- g_debug ("Locking disabled: %s", nolock_reason);
+ g_debug("Locking disabled: %s", nolock_reason);
}
if (uid_message && verbose)
{
- g_print ("Modified UID: %s", uid_message);
+ g_print("Modified UID: %s", uid_message);
}
- g_free (nolock_reason);
- g_free (orig_uid);
- g_free (uid_message);
+ g_free(nolock_reason);
+ g_free(orig_uid);
+ g_free(uid_message);
- gs_profile_end (NULL);
+ gs_profile_end(NULL);
return ret;
}
@@ -517,149 +466,147 @@ privileged_initialization (int *argc,
*
* Figure out what locking mechanisms are supported.
*/
-static gboolean
-lock_initialization (int *argc,
- char **argv,
- char **nolock_reason,
- gboolean verbose)
+static gboolean lock_initialization (int* argc, char** argv, char** nolock_reason, gboolean verbose)
{
if (nolock_reason != NULL)
{
*nolock_reason = NULL;
}
-#ifdef NO_LOCKING
- if (nolock_reason != NULL)
- {
- *nolock_reason = g_strdup ("not compiled with locking support");
- }
+ #ifdef NO_LOCKING
- return FALSE;
-#else /* !NO_LOCKING */
-
- /* Finish initializing locking, now that we're out of privileged code. */
- if (! gs_auth_init ())
- {
if (nolock_reason != NULL)
{
- *nolock_reason = g_strdup ("error getting password");
+ *nolock_reason = g_strdup("not compiled with locking support");
}
return FALSE;
- }
+ #else /* !NO_LOCKING */
- /* If locking is currently enabled, but the environment indicates that
- we have been launched as MDM's "Background" program, then disable
- locking just in case.
- */
- if (getenv ("RUNNING_UNDER_MDM"))
- {
- if (nolock_reason != NULL)
+ /* Finish initializing locking, now that we're out of privileged code. */
+ if (!gs_auth_init())
{
- *nolock_reason = g_strdup ("running under MDM");
- }
+ if (nolock_reason != NULL)
+ {
+ *nolock_reason = g_strdup("error getting password");
+ }
- return FALSE;
- }
+ return FALSE;
+ }
- /* If the server is XDarwin (MacOS X) then disable locking.
- (X grabs only affect X programs, so you can use Command-Tab
- to bring any other Mac program to the front, e.g., Terminal.)
- */
- {
- gboolean macos = FALSE;
-
-#ifdef __APPLE__
- /* Disable locking if *running* on Apple hardware, since we have no
- reliable way to determine whether the server is running on MacOS.
- Hopefully __APPLE__ means "MacOS" and not "Linux on Mac hardware"
- but I'm not really sure about that.
- */
- macos = TRUE;
-#endif
-
- if (macos)
+ /* If locking is currently enabled, but the environment indicates that
+ * we have been launched as MDM's "Background" program, then disable
+ * locking just in case.
+ */
+ if (getenv("RUNNING_UNDER_MDM"))
{
if (nolock_reason != NULL)
{
- *nolock_reason = g_strdup ("Cannot lock securely on MacOS X");
+ *nolock_reason = g_strdup("running under MDM");
}
return FALSE;
}
- }
-#endif /* NO_LOCKING */
+ /* If the server is XDarwin (MacOS X) then disable locking.
+ * (X grabs only affect X programs, so you can use Command-Tab
+ * to bring any other Mac program to the front, e.g., Terminal.)
+ */
+ {
+ gboolean macos = FALSE;
+
+ #ifdef __APPLE__
+ /* Disable locking if *running* on Apple hardware, since we have no
+ * reliable way to determine whether the server is running on MacOS.
+ * Hopefully __APPLE__ means "MacOS" and not "Linux on Mac hardware"
+ * but I'm not really sure about that.
+ */
+ macos = TRUE;
+ #endif /* __APPLE__ */
+
+ if (macos)
+ {
+ if (nolock_reason != NULL)
+ {
+ *nolock_reason = g_strdup("Cannot lock securely on MacOS X");
+ }
+
+ return FALSE;
+ }
+ }
+
+ #endif /* NO_LOCKING */
return TRUE;
}
-int
-main (int argc,
- char **argv)
+int main(int argc, char** argv)
{
- GError *error = NULL;
- char *nolock_reason = NULL;
-
-#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
-# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-# endif
- textdomain (GETTEXT_PACKAGE);
-#endif
-
- if (! g_thread_supported ())
+ GError* error = NULL;
+ char* nolock_reason = NULL;
+
+ #ifdef ENABLE_NLS
+ bindtextdomain(GETTEXT_PACKAGE, MATELOCALEDIR);
+ #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ #endif
+ textdomain(GETTEXT_PACKAGE);
+ #endif
+
+ if (!g_thread_supported())
{
- g_thread_init (NULL);
+ g_thread_init(NULL);
}
- g_type_init ();
+ g_type_init();
- gs_profile_start (NULL);
+ gs_profile_start(NULL);
- if (! privileged_initialization (&argc, argv, verbose))
+ if (!privileged_initialization(&argc, argv, verbose))
{
- response_lock_init_failed ();
- exit (1);
+ response_lock_init_failed();
+ exit(1);
}
error = NULL;
- if (! gtk_init_with_args (&argc, &argv, NULL, entries, NULL, &error))
+
+ if (!gtk_init_with_args(&argc, &argv, NULL, entries, NULL, &error))
{
if (error != NULL)
{
- fprintf (stderr, "%s", error->message);
- g_error_free (error);
+ fprintf(stderr, "%s", error->message);
+ g_error_free(error);
}
- exit (1);
+
+ exit(1);
}
if (show_version)
{
- g_print ("%s %s\n", argv [0], VERSION);
- exit (1);
+ g_print("%s %s\n", argv[0], VERSION);
+ exit(1);
}
- if (! lock_initialization (&argc, argv, &nolock_reason, verbose))
+ if (!lock_initialization(&argc, argv, &nolock_reason, verbose))
{
if (nolock_reason != NULL)
{
g_debug ("Screen locking disabled: %s", nolock_reason);
g_free (nolock_reason);
}
- response_lock_init_failed ();
+
+ response_lock_init_failed();
exit (1);
}
- gs_debug_init (verbose, FALSE);
+ gs_debug_init(verbose, FALSE);
- g_idle_add ((GSourceFunc)popup_dialog_idle, NULL);
+ g_idle_add((GSourceFunc) popup_dialog_idle, NULL);
- gtk_main ();
+ gtk_main();
- gs_profile_end (NULL);
- gs_debug_shutdown ();
+ gs_profile_end(NULL);
+ gs_debug_shutdown();
return 0;
}
diff --git a/src/mate-screensaver.c b/src/mate-screensaver.c
index 1e76fe6..cee3a97 100644
--- a/src/mate-screensaver.c
+++ b/src/mate-screensaver.c
@@ -37,62 +37,61 @@
#include "gs-monitor.h"
#include "gs-debug.h"
-void
-mate_screensaver_quit (void)
+void mate_screensaver_quit(void)
{
- gtk_main_quit ();
+ gtk_main_quit();
}
-int
-main (int argc,
- char **argv)
+int main(int argc, char **argv)
{
- GSMonitor *monitor;
- GError *error = NULL;
- static gboolean show_version = FALSE;
- static gboolean no_daemon = FALSE;
- static gboolean debug = FALSE;
- static GOptionEntry entries [] =
- {
- { "version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL },
- { "no-daemon", 0, 0, G_OPTION_ARG_NONE, &no_daemon, N_("Don't become a daemon"), NULL },
- { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL },
- { NULL }
+ GSMonitor* monitor;
+ GError* error = NULL;
+
+ static gboolean show_version = FALSE;
+ static gboolean no_daemon = FALSE;
+ static gboolean debug = FALSE;
+
+ static GOptionEntry entries[] = {
+ {"version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL},
+ {"no-daemon", 0, 0, G_OPTION_ARG_NONE, &no_daemon, N_("Don't become a daemon"), NULL},
+ {"debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL},
+ {NULL}
};
-#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
-# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-# endif
- textdomain (GETTEXT_PACKAGE);
-#endif
+ #ifdef ENABLE_NLS
+ bindtextdomain(GETTEXT_PACKAGE, MATELOCALEDIR);
+ #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ #endif
+ textdomain(GETTEXT_PACKAGE);
+ #endif
- if (! gtk_init_with_args (&argc, &argv, NULL, entries, NULL, &error))
+ if (!gtk_init_with_args(&argc, &argv, NULL, entries, NULL, &error))
{
if (error)
{
- g_warning ("%s", error->message);
- g_error_free (error);
+ g_warning("%s", error->message);
+ g_error_free(error);
}
else
{
- g_warning ("Unable to initialize GTK+");
+ g_warning("Unable to initialize GTK+");
}
- exit (1);
+
+ exit(1);
}
if (show_version)
{
- g_print ("%s %s\n", argv [0], VERSION);
- exit (1);
+ g_print("%s %s\n", argv[0], VERSION);
+ exit(1);
}
/* debug to a file if in deamon mode */
- gs_debug_init (debug, ! no_daemon);
- gs_debug ("initializing mate-screensaver %s", VERSION);
+ gs_debug_init(debug, !no_daemon);
+ gs_debug("initializing mate-screensaver %s", VERSION);
- monitor = gs_monitor_new ();
+ monitor = gs_monitor_new();
if (monitor == NULL)
{
@@ -100,33 +99,35 @@ main (int argc,
}
error = NULL;
- if (! gs_monitor_start (monitor, &error))
+
+ if (!gs_monitor_start(monitor, &error))
{
if (error)
{
- g_warning ("%s", error->message);
- g_error_free (error);
+ g_warning("%s", error->message);
+ g_error_free(error);
}
else
{
- g_warning ("Unable to start screensaver");
+ g_warning("Unable to start screensaver");
}
- exit (1);
+
+ exit(1);
}
/* Don't close stdout and stderr for now */
- if (! no_daemon && daemon (0, 1))
+ if (!no_daemon && daemon(0, 1))
{
- g_error ("Could not daemonize: %s", g_strerror (errno));
+ g_error("Could not daemonize: %s", g_strerror (errno));
}
- gtk_main ();
+ gtk_main();
- g_object_unref (monitor);
+ g_object_unref(monitor);
- gs_debug ("mate-screensaver finished");
+ gs_debug("mate-screensaver finished");
- gs_debug_shutdown ();
+ gs_debug_shutdown();
return 0;
}
diff --git a/src/mate-screensaver.h b/src/mate-screensaver.h
index 34b3a7c..8934653 100644
--- a/src/mate-screensaver.h
+++ b/src/mate-screensaver.h
@@ -25,7 +25,7 @@
G_BEGIN_DECLS
-void mate_screensaver_quit (void);
+void mate_screensaver_quit(void);
G_END_DECLS