diff options
Diffstat (limited to 'src/gpm-manager.c')
-rw-r--r-- | src/gpm-manager.c | 219 |
1 files changed, 70 insertions, 149 deletions
diff --git a/src/gpm-manager.c b/src/gpm-manager.c index ec787be..9ee8781 100644 --- a/src/gpm-manager.c +++ b/src/gpm-manager.c @@ -38,7 +38,6 @@ #include <gtk/gtk.h> #include <dbus/dbus-glib.h> #include <dbus/dbus-glib-lowlevel.h> -#include <mateconf/mateconf-client.h> #include <canberra-gtk.h> #include <libupower-glib/upower.h> #include <libmatenotify/notify.h> @@ -54,9 +53,9 @@ #include "gpm-manager.h" #include "gpm-screensaver.h" #include "gpm-backlight.h" +#include "gpm-kbd-backlight.h" #include "gpm-session.h" #include "gpm-stock-icons.h" -#include "gpm-prefs-server.h" #include "gpm-tray-icon.h" #include "gpm-engine.h" #include "gpm-upower.h" @@ -77,16 +76,16 @@ static void gpm_manager_finalize (GObject *object); struct GpmManagerPrivate { GpmButton *button; - MateConfClient *conf; + GSettings *settings; GpmDisks *disks; GpmDpms *dpms; GpmIdle *idle; - GpmPrefsServer *prefs_server; GpmControl *control; GpmScreensaver *screensaver; GpmTrayIcon *tray_icon; GpmEngine *engine; GpmBacklight *backlight; + GpmKbdBacklight *kbd_backlight; EggConsoleKit *console; guint32 screensaver_ac_throttle_id; guint32 screensaver_dpms_throttle_id; @@ -200,7 +199,7 @@ gpm_manager_play_loop_start (GpmManager *manager, GpmManagerSound action, gboole gint retval; ca_context *context; - ret = mateconf_client_get_bool (manager->priv->conf, GPM_CONF_UI_ENABLE_SOUND, NULL); + ret = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_ENABLE_SOUND); if (!ret && !force) { egg_debug ("ignoring sound due to policy"); return FALSE; @@ -261,7 +260,7 @@ gpm_manager_play (GpmManager *manager, GpmManagerSound action, gboolean force) gint retval; ca_context *context; - ret = mateconf_client_get_bool (manager->priv->conf, GPM_CONF_UI_ENABLE_SOUND, NULL); + ret = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_ENABLE_SOUND); if (!ret && !force) { egg_debug ("ignoring sound due to policy"); return FALSE; @@ -356,11 +355,11 @@ gpm_manager_sync_policy_sleep (GpmManager *manager) guint sleep_computer; if (!manager->priv->on_battery) { - sleep_computer = mateconf_client_get_int (manager->priv->conf, GPM_CONF_TIMEOUT_SLEEP_COMPUTER_AC, NULL); - sleep_display = mateconf_client_get_int (manager->priv->conf, GPM_CONF_TIMEOUT_SLEEP_DISPLAY_AC, NULL); + sleep_computer = g_settings_get_int (manager->priv->settings, GPM_SETTINGS_SLEEP_COMPUTER_AC); + sleep_display = g_settings_get_int (manager->priv->settings, GPM_SETTINGS_SLEEP_DISPLAY_AC); } else { - sleep_computer = mateconf_client_get_int (manager->priv->conf, GPM_CONF_TIMEOUT_SLEEP_COMPUTER_BATT, NULL); - sleep_display = mateconf_client_get_int (manager->priv->conf, GPM_CONF_TIMEOUT_SLEEP_DISPLAY_BATT, NULL); + sleep_computer = g_settings_get_int (manager->priv->settings, GPM_SETTINGS_SLEEP_COMPUTER_BATT); + sleep_display = g_settings_get_int (manager->priv->settings, GPM_SETTINGS_SLEEP_DISPLAY_BATT); } /* set the new sleep (inactivity) value */ @@ -375,7 +374,7 @@ gpm_manager_sync_policy_sleep (GpmManager *manager) * Turn off the backlight of the LCD when we shut the lid, and lock * if required. This is required because some laptops do not turn off the * LCD backlight when the lid is closed. - * See http://bugzilla.mate.org/show_bug.cgi?id=321313 + * See http://bugzilla.gnome.org/show_bug.cgi?id=321313 * * Return value: Success. **/ @@ -387,7 +386,7 @@ gpm_manager_blank_screen (GpmManager *manager, GError **noerror) GError *error = NULL; do_lock = gpm_control_get_lock_policy (manager->priv->control, - GPM_CONF_LOCK_ON_BLANK_SCREEN); + GPM_SETTINGS_LOCK_ON_BLANK_SCREEN); if (do_lock) { if (!gpm_screensaver_lock (manager->priv->screensaver)) egg_debug ("Could not lock screen via mate-screensaver"); @@ -423,7 +422,7 @@ gpm_manager_unblank_screen (GpmManager *manager, GError **noerror) ret = FALSE; } - do_lock = gpm_control_get_lock_policy (manager->priv->control, GPM_CONF_LOCK_ON_BLANK_SCREEN); + do_lock = gpm_control_get_lock_policy (manager->priv->control, GPM_SETTINGS_LOCK_ON_BLANK_SCREEN); if (do_lock) gpm_screensaver_poke (manager->priv->screensaver); return ret; @@ -534,7 +533,7 @@ gpm_manager_sleep_failure_response_cb (GtkDialog *dialog, gint response_id, GpmM /* user clicked the help button */ if (response_id == GTK_RESPONSE_HELP) { - uri = mateconf_client_get_string (manager->priv->conf, GPM_CONF_NOTIFY_SLEEP_FAILED_URI, NULL); + uri = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_NOTIFY_SLEEP_FAILED_URI); screen = gdk_screen_get_default(); ret = gtk_show_uri (screen, uri, gtk_get_current_event_time (), &error); if (!ret) { @@ -562,13 +561,13 @@ gpm_manager_sleep_failure (GpmManager *manager, gboolean is_suspend, const gchar const gchar *icon; GtkWidget *dialog; - /* only show this if specified in mateconf */ - show_sleep_failed = mateconf_client_get_bool (manager->priv->conf, GPM_CONF_NOTIFY_SLEEP_FAILED, NULL); + /* only show this if specified in settings */ + show_sleep_failed = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_NOTIFY_SLEEP_FAILED); egg_debug ("sleep failed"); gpm_manager_play (manager, GPM_MANAGER_SOUND_SUSPEND_ERROR, TRUE); - /* only emit if in MateConf */ + /* only emit if specified in settings */ if (!show_sleep_failed) goto out; @@ -599,7 +598,7 @@ gpm_manager_sleep_failure (GpmManager *manager, gboolean is_suspend, const gchar gtk_window_set_icon_name (GTK_WINDOW(dialog), icon); /* show a button? */ - uri = mateconf_client_get_string (manager->priv->conf, GPM_CONF_NOTIFY_SLEEP_FAILED_URI, NULL); + uri = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_NOTIFY_SLEEP_FAILED_URI); if (uri != NULL && uri[0] != '\0') { /* TRANSLATORS: button text, visit the suspend help website */ gtk_dialog_add_button (GTK_DIALOG (dialog), _("Visit help page"), GTK_RESPONSE_HELP); @@ -665,21 +664,19 @@ gpm_manager_action_hibernate (GpmManager *manager, const gchar *reason) * @policy: The policy that we should do, e.g. "suspend" * @reason: The reason we are performing the policy action, e.g. "battery critical" * - * Does one of the policy actions specified in mateconf. + * Does one of the policy actions specified in the settings. **/ static gboolean gpm_manager_perform_policy (GpmManager *manager, const gchar *policy_key, const gchar *reason) { - gchar *action = NULL; GpmActionPolicy policy; /* are we inhibited? */ if (gpm_manager_is_inhibit_valid (manager, FALSE, "policy action") == FALSE) return FALSE; - action = mateconf_client_get_string (manager->priv->conf, policy_key, NULL); - egg_debug ("action: %s set to %s (%s)", policy_key, action, reason); - policy = gpm_action_policy_from_string (action); + policy = g_settings_get_enum (manager->priv->settings, policy_key); + egg_debug ("action: %s set to %i (%s)", policy_key, policy, reason); if (policy == GPM_ACTION_POLICY_NOTHING) { egg_debug ("doing nothing, reason: %s", reason); @@ -703,44 +700,30 @@ gpm_manager_perform_policy (GpmManager *manager, const gchar *policy_key, const gpm_session_logout (session); g_object_unref (session); } else { - egg_warning ("unknown action %s", action); + egg_warning ("unknown action %i", policy); } - g_free (action); return TRUE; } /** - * gpm_manager_get_preferences_options: - **/ -gboolean -gpm_manager_get_preferences_options (GpmManager *manager, gint *capability, GError **error) -{ - g_return_val_if_fail (manager != NULL, FALSE); - g_return_val_if_fail (GPM_IS_MANAGER (manager), FALSE); - return gpm_prefs_server_get_capability (manager->priv->prefs_server, capability); -} - -/** * gpm_manager_idle_do_sleep: * @manager: This class instance * * This callback is called when we want to sleep. Use the users - * preference from mateconf, but change it if we can't do the action. + * preference from the settings, but change it if we can't do the action. **/ static void gpm_manager_idle_do_sleep (GpmManager *manager) { - gchar *action = NULL; gboolean ret; GError *error = NULL; GpmActionPolicy policy; if (!manager->priv->on_battery) - action = mateconf_client_get_string (manager->priv->conf, GPM_CONF_ACTIONS_SLEEP_TYPE_AC, NULL); + policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_SLEEP_TYPE_AC); else - action = mateconf_client_get_string (manager->priv->conf, GPM_CONF_ACTIONS_SLEEP_TYPE_BATT, NULL); - policy = gpm_action_policy_from_string (action); + policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_SLEEP_TYPE_BATT); if (policy == GPM_ACTION_POLICY_NOTHING) { egg_debug ("doing nothing as system idle action"); @@ -773,7 +756,6 @@ gpm_manager_idle_do_sleep (GpmManager *manager) } } } - g_free (action); } /** @@ -837,13 +819,13 @@ gpm_manager_lid_button_pressed (GpmManager *manager, gboolean pressed) if (!manager->priv->on_battery) { egg_debug ("Performing AC policy"); - gpm_manager_perform_policy (manager, GPM_CONF_BUTTON_LID_AC, + gpm_manager_perform_policy (manager, GPM_SETTINGS_BUTTON_LID_AC, "The lid has been closed on ac power."); return; } egg_debug ("Performing battery policy"); - gpm_manager_perform_policy (manager, GPM_CONF_BUTTON_LID_BATT, + gpm_manager_perform_policy (manager, GPM_SETTINGS_BUTTON_LID_BATT, "The lid has been closed on battery power."); } @@ -926,13 +908,13 @@ gpm_manager_button_pressed_cb (GpmButton *button, const gchar *type, GpmManager } if (g_strcmp0 (type, GPM_BUTTON_POWER) == 0) { - gpm_manager_perform_policy (manager, GPM_CONF_BUTTON_POWER, "The power button has been pressed."); + gpm_manager_perform_policy (manager, GPM_SETTINGS_BUTTON_POWER, "The power button has been pressed."); } else if (g_strcmp0 (type, GPM_BUTTON_SLEEP) == 0) { - gpm_manager_perform_policy (manager, GPM_CONF_BUTTON_SUSPEND, "The suspend button has been pressed."); + gpm_manager_perform_policy (manager, GPM_SETTINGS_BUTTON_SUSPEND, "The suspend button has been pressed."); } else if (g_strcmp0 (type, GPM_BUTTON_SUSPEND) == 0) { - gpm_manager_perform_policy (manager, GPM_CONF_BUTTON_SUSPEND, "The suspend button has been pressed."); + gpm_manager_perform_policy (manager, GPM_SETTINGS_BUTTON_SUSPEND, "The suspend button has been pressed."); } else if (g_strcmp0 (type, GPM_BUTTON_HIBERNATE) == 0) { - gpm_manager_perform_policy (manager, GPM_CONF_BUTTON_HIBERNATE, "The hibernate button has been pressed."); + gpm_manager_perform_policy (manager, GPM_SETTINGS_BUTTON_HIBERNATE, "The hibernate button has been pressed."); } else if (g_strcmp0 (type, GPM_BUTTON_LID_OPEN) == 0) { gpm_manager_lid_button_pressed (manager, FALSE); } else if (g_strcmp0 (type, GPM_BUTTON_LID_CLOSED) == 0) { @@ -971,11 +953,11 @@ gpm_manager_get_spindown_timeout (GpmManager *manager) /* get policy */ if (!manager->priv->on_battery) { - enabled = mateconf_client_get_bool (manager->priv->conf, GPM_CONF_DISKS_SPINDOWN_ENABLE_AC, NULL); - timeout = mateconf_client_get_int (manager->priv->conf, GPM_CONF_DISKS_SPINDOWN_TIMEOUT_AC, NULL); + enabled = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_SPINDOWN_ENABLE_AC); + timeout = g_settings_get_int (manager->priv->settings, GPM_SETTINGS_SPINDOWN_TIMEOUT_AC); } else { - enabled = mateconf_client_get_bool (manager->priv->conf, GPM_CONF_DISKS_SPINDOWN_ENABLE_BATT, NULL); - timeout = mateconf_client_get_int (manager->priv->conf, GPM_CONF_DISKS_SPINDOWN_TIMEOUT_BATT, NULL); + enabled = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_SPINDOWN_ENABLE_BATT); + timeout = g_settings_get_int (manager->priv->settings, GPM_SETTINGS_SPINDOWN_TIMEOUT_BATT); } if (!enabled) timeout = 0; @@ -1046,15 +1028,15 @@ gpm_manager_client_changed_cb (UpClient *client, GpmManager *manager) /* We do the lid close on battery action if the ac adapter is removed when the laptop is closed and on battery. Fixes #331655 */ - event_when_closed = mateconf_client_get_bool (manager->priv->conf, GPM_CONF_ACTIONS_SLEEP_WHEN_CLOSED, NULL); + event_when_closed = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_SLEEP_WHEN_CLOSED); /* We keep track of the lid state so we can do the lid close on battery action if the ac adapter is removed when the laptop is closed. Fixes #331655 */ if (event_when_closed && on_battery && lid_is_closed) { - gpm_manager_perform_policy (manager, GPM_CONF_BUTTON_LID_BATT, + gpm_manager_perform_policy (manager, GPM_SETTINGS_BUTTON_LID_BATT, "The lid has been closed, and the ac adapter " - "removed (and mateconf is okay)."); + "removed (and GSettings is okay)."); } } @@ -1074,7 +1056,7 @@ manager_critical_action_do (GpmManager *manager) if (manager->priv->critical_alert_timeout_id) gpm_manager_play_loop_stop (manager); - gpm_manager_perform_policy (manager, GPM_CONF_ACTIONS_CRITICAL_BATT, "Battery is critically low."); + gpm_manager_perform_policy (manager, GPM_SETTINGS_ACTION_CRITICAL_BATT, "Battery is critically low."); return FALSE; } @@ -1091,53 +1073,20 @@ gpm_manager_class_init (GpmManagerClass *klass) } /** - * gpm_conf_mateconf_key_changed_cb: + * gpm_manager_settings_changed_cb: * - * We might have to do things when the mateconf keys change; do them here. + * We might have to do things when the keys change; do them here. **/ static void -gpm_conf_mateconf_key_changed_cb (MateConfClient *client, guint cnxn_id, MateConfEntry *entry, GpmManager *manager) +gpm_manager_settings_changed_cb (GSettings *settings, const gchar *key, GpmManager *manager) { - MateConfValue *value; - - value = mateconf_entry_get_value (entry); - if (value == NULL) - return; - - if (g_strcmp0 (entry->key, GPM_CONF_TIMEOUT_SLEEP_COMPUTER_BATT) == 0 || - g_strcmp0 (entry->key, GPM_CONF_TIMEOUT_SLEEP_COMPUTER_AC) == 0 || - g_strcmp0 (entry->key, GPM_CONF_TIMEOUT_SLEEP_DISPLAY_BATT) == 0 || - g_strcmp0 (entry->key, GPM_CONF_TIMEOUT_SLEEP_DISPLAY_AC) == 0) + if (g_strcmp0 (key, GPM_SETTINGS_SLEEP_COMPUTER_BATT) == 0 || + g_strcmp0 (key, GPM_SETTINGS_SLEEP_COMPUTER_AC) == 0 || + g_strcmp0 (key, GPM_SETTINGS_SLEEP_DISPLAY_BATT) == 0 || + g_strcmp0 (key, GPM_SETTINGS_SLEEP_DISPLAY_AC) == 0) gpm_manager_sync_policy_sleep (manager); } -#if 0 -/** - * gpm_manager_screensaver_auth_request_cb: - * @manager: This manager class instance - * @auth: If we are trying to authenticate - * - * Called when the user is trying or has authenticated - **/ -static void -gpm_manager_screensaver_auth_request_cb (GpmScreensaver *screensaver, gboolean auth_begin, GpmManager *manager) -{ - GError *error = NULL; - - if (auth_begin) { - /* We turn on the monitor unconditionally, as we may be using - * a smartcard to authenticate and DPMS might still be on. - * See #350291 for more details */ - gpm_dpms_set_mode (manager->priv->dpms, GPM_DPMS_MODE_ON, &error); - if (error != NULL) { - egg_warning ("Failed to turn on DPMS: %s", error->message); - g_error_free (error); - error = NULL; - } - } -} -#endif - /** * gpm_manager_perhaps_recall_response_cb: */ @@ -1152,7 +1101,7 @@ gpm_manager_perhaps_recall_response_cb (GtkDialog *dialog, gint response_id, Gpm /* don't show this again */ if (response_id == GTK_RESPONSE_CANCEL) { - mateconf_client_set_bool (manager->priv->conf, GPM_CONF_NOTIFY_PERHAPS_RECALL, FALSE, NULL); + g_settings_set_boolean (manager->priv->settings, GPM_SETTINGS_NOTIFY_PERHAPS_RECALL, FALSE); goto out; } @@ -1230,9 +1179,9 @@ gpm_manager_engine_perhaps_recall_cb (GpmEngine *engine, UpDevice *device, gchar } /* already shown, and dismissed */ - ret = mateconf_client_get_bool (manager->priv->conf, GPM_CONF_NOTIFY_PERHAPS_RECALL, NULL); + ret = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_NOTIFY_PERHAPS_RECALL); if (!ret) { - egg_debug ("MateConf prevents notification: %s", GPM_CONF_NOTIFY_PERHAPS_RECALL); + egg_debug ("Gsettings prevents notification: %s", GPM_SETTINGS_NOTIFY_PERHAPS_RECALL); return; } @@ -1310,8 +1259,8 @@ gpm_manager_engine_fully_charged_cb (GpmEngine *engine, UpDevice *device, GpmMan guint plural = 1; const gchar *title; - /* only action this if specified in mateconf */ - ret = mateconf_client_get_bool (manager->priv->conf, GPM_CONF_NOTIFY_FULLY_CHARGED, NULL); + /* only action this if specified in the setings */ + ret = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_NOTIFY_FULLY_CHARGED); if (!ret) { egg_debug ("no notification"); goto out; @@ -1364,8 +1313,8 @@ gpm_manager_engine_discharging_cb (GpmEngine *engine, UpDevice *device, GpmManag gchar *icon = NULL; const gchar *kind_desc; - /* only action this if specified in mateconf */ - ret = mateconf_client_get_bool (manager->priv->conf, GPM_CONF_NOTIFY_DISCHARGING, NULL); + /* only action this if specified in the settings */ + ret = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_NOTIFY_DISCHARGING); if (!ret) { egg_debug ("no notification"); goto out; @@ -1573,7 +1522,6 @@ gpm_manager_engine_charge_critical_cb (GpmEngine *engine, UpDevice *device, GpmM { const gchar *title = NULL; gchar *message = NULL; - gchar *action; gchar *icon = NULL; UpDeviceKind kind; gdouble percentage; @@ -1609,8 +1557,7 @@ gpm_manager_engine_charge_critical_cb (GpmEngine *engine, UpDevice *device, GpmM } /* we have to do different warnings depending on the policy */ - action = mateconf_client_get_string (manager->priv->conf, GPM_CONF_ACTIONS_CRITICAL_BATT, NULL); - policy = gpm_action_policy_from_string (action); + policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_BATT); /* use different text for different actions */ if (policy == GPM_ACTION_POLICY_NOTHING) { @@ -1630,7 +1577,6 @@ gpm_manager_engine_charge_critical_cb (GpmEngine *engine, UpDevice *device, GpmM message = g_strdup_printf (_("Computer will shutdown very soon unless it is plugged in.")); } - g_free (action); } else if (kind == UP_DEVICE_KIND_UPS) { gchar *remaining_text; @@ -1740,7 +1686,6 @@ static void gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmManager *manager) { const gchar *title = NULL; - gchar *action; gchar *message = NULL; gchar *icon = NULL; UpDeviceKind kind; @@ -1765,8 +1710,7 @@ gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmMan title = _("Laptop battery critically low"); /* we have to do different warnings depending on the policy */ - action = mateconf_client_get_string (manager->priv->conf, GPM_CONF_ACTIONS_CRITICAL_BATT, NULL); - policy = gpm_action_policy_from_string (action); + policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_BATT); /* use different text for different actions */ if (policy == GPM_ACTION_POLICY_NOTHING) { @@ -1793,8 +1737,6 @@ gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmMan "this computer is about to shutdown.")); } - g_free (action); - /* wait 20 seconds for user-panic */ g_timeout_add_seconds (20, (GSourceFunc) manager_critical_action_do, manager); @@ -1803,8 +1745,7 @@ gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmMan title = _("UPS critically low"); /* we have to do different warnings depending on the policy */ - action = mateconf_client_get_string (manager->priv->conf, GPM_CONF_ACTIONS_CRITICAL_UPS, NULL); - policy = gpm_action_policy_from_string (action); + policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_UPS); /* use different text for different actions */ if (policy == GPM_ACTION_POLICY_NOTHING) { @@ -1827,7 +1768,6 @@ gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmMan /* wait 20 seconds for user-panic */ g_timeout_add_seconds (20, (GSourceFunc) manager_critical_action_do, manager); - g_free (action); } /* not all types have actions */ @@ -1910,11 +1850,12 @@ gpm_manager_init (GpmManager *manager) gboolean check_type_cpu; gint timeout; DBusGConnection *connection; + GDBusConnection *g_connection; GError *error = NULL; - guint version; manager->priv = GPM_MANAGER_GET_PRIVATE (manager); connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + g_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); /* init to unthrottled */ manager->priv->screensaver_ac_throttle_id = 0; @@ -1930,15 +1871,14 @@ gpm_manager_init (GpmManager *manager) /* don't apply policy when not active, so listen to ConsoleKit */ manager->priv->console = egg_console_kit_new (); - /* this is a singleton, so we keep a master copy open here */ - manager->priv->prefs_server = gpm_prefs_server_new (); - manager->priv->notification_general = NULL; manager->priv->notification_warning_low = NULL; manager->priv->notification_discharging = NULL; manager->priv->notification_fully_charged = NULL; manager->priv->disks = gpm_disks_new (); - manager->priv->conf = mateconf_client_get_default (); + manager->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA); + g_signal_connect (manager->priv->settings, "changed", + G_CALLBACK (gpm_manager_settings_changed_cb), manager); manager->priv->client = up_client_new (); g_signal_connect (manager->priv->client, "changed", G_CALLBACK (gpm_manager_client_changed_cb), manager); @@ -1946,28 +1886,6 @@ gpm_manager_init (GpmManager *manager) /* use libmatenotify */ notify_init (GPM_NAME); - /* watch mate-power-manager keys */ - mateconf_client_add_dir (manager->priv->conf, GPM_CONF_DIR, - MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL); - mateconf_client_notify_add (manager->priv->conf, GPM_CONF_DIR, - (MateConfClientNotifyFunc) gpm_conf_mateconf_key_changed_cb, - manager, NULL, NULL); - - /* check to see if the user has installed the schema properly */ - version = mateconf_client_get_int (manager->priv->conf, GPM_CONF_SCHEMA_VERSION, NULL); - if (version != GPM_CONF_SCHEMA_ID) { - gpm_manager_notify (manager, &manager->priv->notification_general, - /* TRANSLATORS: there was in install problem */ - _("Install problem!"), - /* TRANSLATORS: the MateConf schema was not installed properly */ - _("The configuration defaults for MATE Power Manager have not been installed correctly.\n" - "Please contact your computer administrator."), - GPM_MANAGER_NOTIFY_TIMEOUT_LONG, - GTK_STOCK_DIALOG_WARNING, - NOTIFY_URGENCY_NORMAL); - egg_error ("no mateconf schema installed!"); - } - /* coldplug so we are in the correct state at startup */ g_object_get (manager->priv->client, "on-battery", &manager->priv->on_battery, @@ -1979,10 +1897,6 @@ gpm_manager_init (GpmManager *manager) /* try and start an interactive service */ manager->priv->screensaver = gpm_screensaver_new (); -#if 0 - g_signal_connect (manager->priv->screensaver, "auth-request", - G_CALLBACK (gpm_manager_screensaver_auth_request_cb), manager); -#endif /* try an start an interactive service */ manager->priv->backlight = gpm_backlight_new (); @@ -1994,12 +1908,19 @@ gpm_manager_init (GpmManager *manager) G_OBJECT (manager->priv->backlight)); } + manager->priv->kbd_backlight = gpm_kbd_backlight_new (); + if (manager->priv->kbd_backlight != NULL) { + gpm_kbd_backlight_register_dbus (manager->priv->kbd_backlight, + g_connection, + NULL); + } + manager->priv->idle = gpm_idle_new (); g_signal_connect (manager->priv->idle, "idle-changed", G_CALLBACK (gpm_manager_idle_changed_cb), manager); /* set up the check_type_cpu, so we can disable the CPU load check */ - check_type_cpu = mateconf_client_get_bool (manager->priv->conf, GPM_CONF_IDLE_CHECK_CPU, NULL); + check_type_cpu = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_IDLE_CHECK_CPU); gpm_idle_set_check_cpu (manager->priv->idle, check_type_cpu); manager->priv->dpms = gpm_dpms_new (); @@ -2078,17 +1999,17 @@ gpm_manager_finalize (GObject *object) if (manager->priv->critical_alert_timeout_id != 0) g_source_remove (manager->priv->critical_alert_timeout_id); - g_object_unref (manager->priv->conf); + g_object_unref (manager->priv->settings); g_object_unref (manager->priv->disks); g_object_unref (manager->priv->dpms); g_object_unref (manager->priv->idle); g_object_unref (manager->priv->engine); g_object_unref (manager->priv->tray_icon); g_object_unref (manager->priv->screensaver); - g_object_unref (manager->priv->prefs_server); g_object_unref (manager->priv->control); g_object_unref (manager->priv->button); g_object_unref (manager->priv->backlight); + g_object_unref (manager->priv->kbd_backlight); g_object_unref (manager->priv->console); g_object_unref (manager->priv->client); g_object_unref (manager->priv->status_icon); |