From e58350ab1a00d55e82f7ae97589562e10a77c485 Mon Sep 17 00:00:00 2001 From: Brent Hull Date: Sat, 27 Oct 2012 23:04:21 -0400 Subject: Port to Gsettings based on GNOME patch by Richard Hughes --- configure.ac | 24 +- data/Makefile.am | 27 +- data/mate-power-manager.schemas.in | 741 -------------------------------- data/org.mate.power-manager.gschema.xml | 338 +++++++++++++++ po/POTFILES.in | 2 +- src/gpm-backlight.c | 77 ++-- src/gpm-common.h | 164 ++++--- src/gpm-control.c | 29 +- src/gpm-engine.c | 50 +-- src/gpm-manager.c | 126 +++--- src/gpm-phone.c | 1 - src/gpm-prefs-core.c | 263 +++--------- src/gpm-screensaver.c | 2 +- src/gpm-statistics.c | 54 +-- src/gpm-tray-icon.c | 30 +- 15 files changed, 655 insertions(+), 1273 deletions(-) delete mode 100644 data/mate-power-manager.schemas.in create mode 100644 data/org.mate.power-manager.gschema.xml diff --git a/configure.ac b/configure.ac index bfaed8c..8271e34 100644 --- a/configure.ac +++ b/configure.ac @@ -93,12 +93,14 @@ AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE(GETTEXT_PACKAGE, "AC_PACKAGE_NAME", [foo]) AM_GLIB_GNU_GETTEXT +GLIB_GSETTINGS dnl ---------------------------------------------------------------------------- dnl - Library dependencies dnl ---------------------------------------------------------------------------- GTK_API_VERSION=2.0 GLIB_REQUIRED=2.13.0 +GIO_REQUIRED=2.25.0 GTK_REQUIRED=2.17.7 GDK_REQUIRED=2.11.0 MATECONF_REQUIRED=1.1.0 @@ -139,7 +141,7 @@ esac dnl --------------------------------------------------------------------------- dnl - Check library dependencies dnl --------------------------------------------------------------------------- -PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0) +PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 gio-2.0 >= $GIO_REQUIRED) PKG_CHECK_MODULES(CANBERRA, libcanberra-gtk >= $CANBERRA_REQUIRED) @@ -201,9 +203,6 @@ fi PKG_CHECK_MODULES(UPOWER, upower-glib >= $UPOWER_REQUIRED) -AC_PATH_PROG(MATECONFTOOL, mateconftool-2) -AM_MATECONF_SOURCE_2 - dnl --------------------------------------------------------------------------- dnl - Check XF86XK_Keys dnl --------------------------------------------------------------------------- @@ -253,21 +252,6 @@ else fi AM_CONDITIONAL([HAVE_TESTS], [test $have_tests = yes]) -dnl --------------------------------------------------------------------------- -dnl - Build mateconf default button? -dnl --------------------------------------------------------------------------- -AC_ARG_ENABLE(mateconf-defaults, - AS_HELP_STRING([--disable-mateconf-defaults], - [Allow setting mateconf default settings]), - have_mateconfdefaults=$enableval,have_mateconfdefaults=yes) - -AC_MSG_CHECKING([whether to support mateconf defaults]) -if test x$have_mateconfdefaults = xyes ; then - AC_DEFINE(HAVE_MATECONF_DEFAULTS, 1, [Define if have mateconf defaults]) -fi -AC_MSG_RESULT([$have_mateconfdefaults]) -AM_CONDITIONAL([HAVE_MATECONF_DEFAULTS], [test $have_mateconfdefaults = yes]) - dnl --------------------------------------------------------------------------- dnl - Build applets dnl --------------------------------------------------------------------------- @@ -399,12 +383,10 @@ echo " cflags: ${CFLAGS} Building extra applets: ${enable_applets} Self test support: ${have_tests} - MateConf default support: ${have_mateconfdefaults} Use libunique: ${enable_libunique} Docbook support: ${enable_docbook_docs} documentation dir: $DOCDIR dbus-1 services dir: $DBUS_SERVICES_DIR - mateconf-schema dir: $MATECONF_SCHEMA_FILE_DIR " if [[ "${prefix}" != "/usr" ]] ; then echo ' diff --git a/data/Makefile.am b/data/Makefile.am index 80b8a49..0f0d775 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,9 +1,5 @@ SUBDIRS = icons -@INTLTOOL_SCHEMAS_RULE@ -schemadir = $(sysconfdir)/mateconf/schemas -schema_in_files = mate-power-manager.schemas.in -schema_DATA = $(schema_in_files:.schemas.in=.schemas) @INTLTOOL_DESKTOP_RULE@ desktopdir = $(datadir)/applications @@ -23,6 +19,9 @@ service_DATA = $(service_in_files:.service.in=.service) $(service_DATA): $(service_in_files) Makefile @sed -e "s|\@servicedir\@|$(bindir)|" $< > $@ +@GSETTINGS_RULES@ +gsettings_SCHEMAS = org.mate.power-manager.gschema.xml + pkgdata_DATA = \ gpm-statistics.ui \ gpm-statistics-deprecated.ui \ @@ -32,25 +31,12 @@ pkgdata_DATA = \ acme.ui EXTRA_DIST = \ - mate-power-manager.schemas.in \ - $(schema_in_files) \ - $(desktop_in_files) \ - $(autostart_in_files) \ + $(gsettings_SCHEMAS) \ $(service_in_files) \ + $(autostart_in_files) \ + $(desktop_in_files) \ $(pkgdata_DATA) -if MATECONF_SCHEMAS_INSTALL -install-data-local: - -MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) \ - $(MATECONFTOOL) --makefile-install-rule $(schema_DATA) -endif - -if MATECONF_SCHEMAS_INSTALL -uninstall-local: - -MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) \ - $(MATECONFTOOL) --makefile-uninstall-rule $(schema_DATA) -endif - clean-local : rm -f *~ @@ -58,5 +44,4 @@ DISTCLEANFILES = \ mate-power-manager.desktop \ mate-power-preferences.desktop \ mate-power-statistics.desktop \ - mate-power-manager.schemas \ mate-power-manager.service diff --git a/data/mate-power-manager.schemas.in b/data/mate-power-manager.schemas.in deleted file mode 100644 index 4845738..0000000 --- a/data/mate-power-manager.schemas.in +++ /dev/null @@ -1,741 +0,0 @@ - - - - - /schemas/apps/mate-power-manager/actions/sleep_type_battery - /apps/mate-power-manager/actions/sleep_type_battery - string - hibernate - - Whether to hibernate, suspend or do nothing when inactive - The type of sleeping that should be performed when the computer is inactive. Possible values are "hibernate", "suspend" and "nothing". - - - - - /schemas/apps/mate-power-manager/actions/critical_battery - /apps/mate-power-manager/actions/critical_battery - string - hibernate - - Battery critical low action - The action to take when the battery is critically low. Possible values are "hibernate", "suspend", "shutdown" and "nothing". - - - - - /schemas/apps/mate-power-manager/actions/event_when_closed_battery - /apps/mate-power-manager/actions/event_when_closed_battery - mate-power-manager - bool - true - - If the battery event should occur when the lid is shut and the power disconnected - If the battery lid close event should occur (for example 'Suspend when lid closed on battery') when the lid is previously shut and the AC power disconnected at a later time. - - - - - /schemas/apps/mate-power-manager/actions/sleep_type_ac - /apps/mate-power-manager/actions/sleep_type_ac - string - suspend - - Whether to hibernate, suspend or do nothing when inactive - The type of sleeping that should be performed when the computer is inactive. Possible values are "hibernate", "suspend" and "nothing". - - - - - /schemas/apps/mate-power-manager/actions/critical_ups - /apps/mate-power-manager/actions/critical_ups - string - shutdown - - UPS critical low action - The action to take when the UPS is critically low. Possible values are "hibernate", "suspend", "shutdown" and "nothing". - - - - - /schemas/apps/mate-power-manager/actions/low_ups - /apps/mate-power-manager/actions/low_ups - string - hibernate - - UPS low power action - The action to take when the UPS is low. Possible values are "hibernate", "suspend", "shutdown" and "nothing". - - - - - /schemas/apps/mate-power-manager/backlight/enable - /apps/mate-power-manager/backlight/enable - mate-power-manager - bool - true - - Allow backlight brightness adjustment - If the screen brightness should be changed when switching between AC and battery power. - - - - - /schemas/apps/mate-power-manager/backlight/battery_reduce - /apps/mate-power-manager/backlight/battery_reduce - mate-power-manager - bool - true - - Reduce the backlight brightness when on battery power - If the screen should be reduced in brightness when the computer is on battery power. - - - - - /schemas/apps/mate-power-manager/backlight/idle_brightness - /apps/mate-power-manager/backlight/idle_brightness - mate-power-manager - int - 30 - - The brightness of the screen when idle - This is the laptop panel screen brightness used when the session is idle. Only valid when use_time_for_policy is true. - - - - - /schemas/apps/mate-power-manager/backlight/idle_dim_battery - /apps/mate-power-manager/backlight/idle_dim_battery - mate-power-manager - bool - true - - Dim the screen after a period of inactivity when on battery power - If the screen should be dimmed to save power when the computer is idle when on battery power. - - - - - /schemas/apps/mate-power-manager/backlight/idle_dim_time - /apps/mate-power-manager/backlight/idle_dim_time - mate-power-manager - int - 10 - - The default amount of time to dim the screen after idle - The default amount of time to dim the screen after idle. - - - - - /schemas/apps/mate-power-manager/backlight/brightness_dim_battery - /apps/mate-power-manager/backlight/brightness_dim_battery - int - 50 - - LCD dimming amount when on battery - The amount to dim the brightness of the display when on battery power. Possible values are between 0 and 100. - - - - - /schemas/apps/mate-power-manager/backlight/idle_dim_ac - /apps/mate-power-manager/backlight/idle_dim_ac - mate-power-manager - bool - false - - Dim the screen after a period of inactivity when on AC power - If the screen should be dimmed to save power when the computer is idle when on AC power. - - - - - /schemas/apps/mate-power-manager/backlight/dpms_method_ac - /apps/mate-power-manager/backlight/dpms_method_ac - string - off - - Method used to blank screen on AC - The DPMS method used to blank the screen when on AC power. Possible values are "standby", "suspend" and "off". - - - - - /schemas/apps/mate-power-manager/backlight/dpms_method_battery - /apps/mate-power-manager/backlight/dpms_method_battery - string - off - - Method used to blank screen on battery - The DPMS method used to blank the screen when on battery power. Possible values are "standby", "suspend" and "off". - - - - - /schemas/apps/mate-power-manager/backlight/brightness_ac - /apps/mate-power-manager/backlight/brightness_ac - int - 100 - - LCD brightness when on AC - The brightness of the display when on AC power. Possible values are between 0 and 100. - - - - - /schemas/apps/mate-power-manager/buttons/suspend - /apps/mate-power-manager/buttons/suspend - string - suspend - - Suspend button action - The action to take when the system suspend button is pressed. Possible values are "suspend", "hibernate", "interactive", "shutdown" and "nothing". - - - - - /schemas/apps/mate-power-manager/buttons/hibernate - /apps/mate-power-manager/buttons/hibernate - string - hibernate - - Hibernate button action - The action to take when the system hibernate button is pressed. Possible values are "suspend", "hibernate", "interactive", "shutdown" and "nothing". - - - - - /schemas/apps/mate-power-manager/buttons/power - /apps/mate-power-manager/buttons/power - string - interactive - - Power button action - The action to take when the system power button is pressed. Possible values are "suspend", "hibernate", "interactive", "shutdown" and "nothing". - - - - - /schemas/apps/mate-power-manager/buttons/lid_battery - /apps/mate-power-manager/buttons/lid_battery - string - suspend - - Laptop lid close action on battery - The action to take when the laptop lid is closed and the laptop is on battery power. Possible values are "suspend", "hibernate", "blank", and "nothing". - - - - - /schemas/apps/mate-power-manager/buttons/lid_ac - /apps/mate-power-manager/buttons/lid_ac - string - suspend - - Laptop lid close action when on AC - The action to take when the laptop lid is closed and the laptop is on AC power. Possible values are "suspend", "hibernate", "blank" and "nothing". - - - - - /schemas/apps/mate-power-manager/general/installed_schema - /apps/mate-power-manager/general/installed_schema - mate-power-manager - int - 3 - - The default configuration version - The version of the installed version of the schema. Do not edit this value, it is used so that configure changes between versions can be detected. - - - - - /schemas/apps/mate-power-manager/general/use_profile_time - /apps/mate-power-manager/general/use_profile_time - mate-power-manager - bool - true - - If the learnt profile should be used to calculate the time remaining - If the learnt profile should be used to calculate the time remaining. Only turn this off for debugging. - - - - - /schemas/apps/mate-power-manager/general/use_time_for_policy - /apps/mate-power-manager/general/use_time_for_policy - mate-power-manager - bool - true - - Whether to use time-based notifications - If time based notifications should be used. If set to false, then the percentage change is used instead, which may fix a broken ACPI BIOS. - - - - - /schemas/apps/mate-power-manager/general/check_type_cpu - /apps/mate-power-manager/general/check_type_cpu - mate-power-manager - bool - false - - Check CPU load before sleeping - If the CPU load should be checked before doing the idle action. - - - - - /schemas/apps/mate-power-manager/general/network_sleep - /apps/mate-power-manager/general/network_sleep - mate-power-manager - bool - false - - Whether NetworkManager should be connected and disconnected on sleep - Whether NetworkManager should disconnect before suspending or hibernating and connect on resume. - - - - - /schemas/apps/mate-power-manager/lock/use_screensaver_settings - /apps/mate-power-manager/lock/use_screensaver_settings - mate-power-manager - bool - true - - Use mate-screensaver lock setting - Whether to use the screen lock setting of mate-screensaver to decide if the screen is locked after a hibernate, suspend or blank screen. - - - - - /schemas/apps/mate-power-manager/lock/blank_screen - /apps/mate-power-manager/lock/blank_screen - mate-power-manager - bool - true - - Lock screen when blanked - Whether the screen is locked when the screen is turned off. Only used if lock_use_screensaver_settings is false. - - - - - /schemas/apps/mate-power-manager/lock/suspend - /apps/mate-power-manager/lock/suspend - mate-power-manager - bool - true - - Lock screen on suspend - Whether the screen is locked when the computer wakes up from a suspend. Only used if lock_use_screensaver_settings is false. - - - - - /schemas/apps/mate-power-manager/lock/hibernate - /apps/mate-power-manager/lock/hibernate - mate-power-manager - bool - true - - Lock screen on hibernate - Whether the screen is locked when the computer wakes up from a hibernate. Only used if lock_use_screensaver_settings is false. - - - - - /schemas/apps/mate-power-manager/lock/mate_keyring_suspend - /apps/mate-power-manager/lock/mate_keyring_suspend - mate-power-manager - bool - false - - Lock MATE keyring on sleep - Whether the MATE keyring is locked before the computer enters suspend. This means the keyring will have to be unlocked on resume. - - - - - /schemas/apps/mate-power-manager/lock/mate_keyring_hibernate - /apps/mate-power-manager/lock/mate_keyring_hibernate - mate-power-manager - bool - true - - Lock MATE keyring on sleep - Whether the MATE keyring is locked before the computer enters hibernate. This means the keyring will have to be unlocked on resume. - - - - - /schemas/apps/mate-power-manager/disks/spindown_enable_ac - /apps/mate-power-manager/disks/spindown_enable_ac - mate-power-manager - bool - false - - If the low-power mode should be enabled when on AC - If the system low-power mode should be enabled when on AC power. - - - - - /schemas/apps/mate-power-manager/disks/spindown_enable_battery - /apps/mate-power-manager/disks/spindown_enable_battery - mate-power-manager - bool - true - - If the low-power mode should be enabled when on battery - If the system low-power mode should be enabled when on laptop battery power. - - - - - /schemas/apps/mate-power-manager/disks/spindown_timeout_ac - /apps/mate-power-manager/disks/spindown_timeout_ac - mate-power-manager - int - 600 - - Seconds of inactivity to spin down when on AC - The number of seconds of inactivity to spin down the disks when on AC power. - - - - - /schemas/apps/mate-power-manager/disks/spindown_timeout_battery - /apps/mate-power-manager/disks/spindown_timeout_battery - mate-power-manager - int - 60 - - Seconds of inactivity to spin down when on battery - The number of seconds of inactivity to spin down the disks when on battery power. - - - - - /schemas/apps/mate-power-manager/notify/perhaps_recall - /apps/mate-power-manager/notify/perhaps_recall - mate-power-manager - bool - true - - If we should show the recalled battery warning for a broken battery - If we should show the recalled battery warning for a broken battery. Set this to false only if you know your battery is okay. - - - - - /schemas/apps/mate-power-manager/notify/low_capacity - /apps/mate-power-manager/notify/low_capacity - mate-power-manager - bool - true - - If we should show the low capacity warning for a broken battery - If we should show the low capacity warning for a broken battery. - - - - - /schemas/apps/mate-power-manager/notify/discharging - /apps/mate-power-manager/notify/discharging - mate-power-manager - bool - true - - Notify when AC adapter is disconnected - If the user should be notified when the AC adapter is disconnected. - - - - - /schemas/apps/mate-power-manager/notify/fully_charged - /apps/mate-power-manager/notify/fully_charged - mate-power-manager - bool - false - - Notify when fully charged - If a notification message should be displayed when the battery is fully charged. - - - - - /schemas/apps/mate-power-manager/notify/sleep_failed - /apps/mate-power-manager/notify/sleep_failed - mate-power-manager - bool - true - - Notify on a sleep failure - If a notification message should be displayed after suspend or hibernate failed. - - - - - /schemas/apps/mate-power-manager/notify/sleep_failed_uri - /apps/mate-power-manager/notify/sleep_failed_uri - mate-power-manager - string - - - The URI to show to the user on sleep failure - When sleep fails we can show the user a button to help fix the situation. Leave this blank if the button should not be shown. - - - - - /schemas/apps/mate-power-manager/notify/low_power - /apps/mate-power-manager/notify/low_power - mate-power-manager - bool - true - - Notify on a low power - If a notification message should be displayed when the battery is getting low. - - - - - /schemas/apps/mate-power-manager/statistics/show_axis_labels - /apps/mate-power-manager/statistics/show_axis_labels - mate-power-manager - bool - true - - Whether we should show the axis labels in the statistics window - Whether we should show the axis labels in the statistics window. - - - - - /schemas/apps/mate-power-manager/statistics/show_events - /apps/mate-power-manager/statistics/show_events - mate-power-manager - bool - true - - Whether we should show the events in the statistics window - Whether we should show the events in the statistics window. - - - - - /schemas/apps/mate-power-manager/statistics/smooth_data - /apps/mate-power-manager/statistics/smooth_data - mate-power-manager - bool - true - - Whether we should smooth the data in the graph - Whether we should smooth the data in the graph. - - - - - /schemas/apps/mate-power-manager/statistics/graph_type - /apps/mate-power-manager/statistics/graph_type - mate-power-manager - string - power - - The default graph type to show in the statistics window - The default graph type to show in the statistics window. - - - - - /schemas/apps/mate-power-manager/statistics/data_max_time - /apps/mate-power-manager/statistics/data_max_time - mate-power-manager - int - 21600 - - The maximum time displayed on the graph - The maximum duration of time displayed on the x-axis of the graph. - - - - - /schemas/apps/mate-power-manager/thresholds/percentage_low - /apps/mate-power-manager/thresholds/percentage_low - mate-power-manager - int - 10 - - Percentage considered low - The percentage of the battery when it is considered low. Only valid when use_time_for_policy is false. - - - - - /schemas/apps/mate-power-manager/thresholds/percentage_critical - /apps/mate-power-manager/thresholds/percentage_critical - mate-power-manager - int - 3 - - Percentage considered critical - The percentage of the battery when it is considered critical. Only valid when use_time_for_policy is false. - - - - - /schemas/apps/mate-power-manager/thresholds/percentage_action - /apps/mate-power-manager/thresholds/percentage_action - mate-power-manager - int - 2 - - Percentage action is taken - The percentage of the battery when the critical action is performed. Only valid when use_time_for_policy is false. - - - - - /schemas/apps/mate-power-manager/thresholds/time_low - /apps/mate-power-manager/thresholds/time_low - mate-power-manager - int - 1200 - - The time remaining when low - The time remaining in seconds of the battery when it is considered low. Only valid when use_time_for_policy is true. - - - - - /schemas/apps/mate-power-manager/thresholds/time_critical - /apps/mate-power-manager/thresholds/time_critical - mate-power-manager - int - 300 - - The time remaining when critical - The time remaining in seconds of the battery when it is considered critical. Only valid when use_time_for_policy is true. - - - - - /schemas/apps/mate-power-manager/thresholds/time_action - /apps/mate-power-manager/thresholds/time_action - mate-power-manager - int - 120 - - The time remaining when action is taken - The time remaining in seconds of the battery when critical action is taken. Only valid when use_time_for_policy is true. - - - - - /schemas/apps/mate-power-manager/timeout/sleep_computer_battery - /apps/mate-power-manager/timeout/sleep_computer_battery - int - 0 - - Sleep timeout computer when on battery - The amount of time in seconds the computer on battery power needs to be inactive before it goes to sleep. - - - - - /schemas/apps/mate-power-manager/timeout/sleep_computer_ac - /apps/mate-power-manager/timeout/sleep_computer_ac - int - 0 - - Sleep timeout computer when on AC - The amount of time in seconds the computer on AC power needs to be inactive before it goes to sleep. - - - - - /schemas/apps/mate-power-manager/timeout/sleep_computer_ups - /apps/mate-power-manager/timeout/sleep_computer_ups - int - 0 - - Sleep timeout computer when on UPS - The amount of time in seconds the computer on UPS power needs to be inactive before it goes to sleep. - - - - - /schemas/apps/mate-power-manager/timeout/sleep_display_ac - /apps/mate-power-manager/timeout/sleep_display_ac - int - 1800 - - Sleep timeout display when on AC - The amount of time in seconds before the display goes to sleep when the computer is on AC power. - - - - - /schemas/apps/mate-power-manager/timeout/sleep_display_battery - /apps/mate-power-manager/timeout/sleep_display_battery - int - 600 - - Sleep timeout display when on battery - The amount of time in seconds the computer on battery power needs to be inactive before the display goes to sleep. - - - - - /schemas/apps/mate-power-manager/timeout/sleep_display_ups - /apps/mate-power-manager/timeout/sleep_display_ups - int - 600 - - Sleep timeout display when on UPS - The amount of time in seconds the computer on UPS power needs to be inactive before the display goes to sleep. - - - - - /schemas/apps/mate-power-manager/ui/enable_sound - /apps/mate-power-manager/ui/enable_sound - mate-power-manager - bool - true - - If sounds should be used - If sounds should be used when the power is critically low, or inhibit requests have stopped the policy action. - - - - - /schemas/apps/mate-power-manager/ui/show_actions - /apps/mate-power-manager/ui/show_actions - mate-power-manager - bool - true - - If preferences and statistics items should be shown in the context menu - - - - - - /schemas/apps/mate-power-manager/ui/icon_policy - /apps/mate-power-manager/ui/icon_policy - mate-power-manager - string - present - - When to show the notification icon - Display options for the notification icon. Valid options are "never", "low", "critical", "charge", "present" and "always". - - - - - diff --git a/data/org.mate.power-manager.gschema.xml b/data/org.mate.power-manager.gschema.xml new file mode 100644 index 0000000..0d930e5 --- /dev/null +++ b/data/org.mate.power-manager.gschema.xml @@ -0,0 +1,338 @@ + + + + 'hibernate' + Whether to hibernate, suspend or do nothing when inactive + The type of sleeping that should be performed when the computer is inactive. Possible values are "hibernate", "suspend" and "nothing". + + + 'hibernate' + Battery critical low action + The action to take when the battery is critically low. Possible values are "hibernate", "suspend", "shutdown" and "nothing". + + + true + If the battery event should occur when the lid is shut and the power disconnected + If the battery lid close event should occur (for example 'Suspend when lid closed on battery') when the lid is previously shut and the AC power disconnected at a later time. + + + 'suspend' + Whether to hibernate, suspend or do nothing when inactive + The type of sleeping that should be performed when the computer is inactive. Possible values are "hibernate", "suspend" and "nothing". + + + 'shutdown' + UPS critical low action + The action to take when the UPS is critically low. Possible values are "hibernate", "suspend", "shutdown" and "nothing". + + + 'hibernate' + UPS low power action + The action to take when the UPS is low. Possible values are "hibernate", "suspend", "shutdown" and "nothing". + + + true + Allow backlight brightness adjustment + If the screen brightness should be changed when switching between AC and battery power. + + + true + Reduce the backlight brightness when on battery power + If the screen should be reduced in brightness when the computer is on battery power. + + + 30 + The brightness of the screen when idle + This is the laptop panel screen brightness used when the session is idle. Only valid when use-time-for-policy is true. + + + true + Dim the screen after a period of inactivity when on battery power + If the screen should be dimmed to save power when the computer is idle when on battery power. + + + 10 + The default amount of time to dim the screen after idle + The default amount of time to dim the screen after idle. + + + 50 + LCD dimming amount when on battery + The amount to dim the brightness of the display when on battery power. Possible values are between 0 and 100. + + + false + Dim the screen after a period of inactivity when on AC power + If the screen should be dimmed to save power when the computer is idle when on AC power. + + + 'off' + Method used to blank screen on AC + The DPMS method used to blank the screen when on AC power. Possible values are "standby", "suspend" and "off". + + + 'off' + Method used to blank screen on battery + The DPMS method used to blank the screen when on battery power. Possible values are "standby", "suspend" and "off". + + + 100.0 + LCD brightness when on AC + The brightness of the display when on AC power. Possible values are between 0.0 and 100.0. + + + 'suspend' + Suspend button action + The action to take when the system suspend button is pressed. Possible values are "suspend", "hibernate", "interactive", "shutdown" and "nothing". + + + 'hibernate' + Hibernate button action + The action to take when the system hibernate button is pressed. Possible values are "suspend", "hibernate", "interactive", "shutdown" and "nothing". + + + 'interactive' + Power button action + The action to take when the system power button is pressed. Possible values are "suspend", "hibernate", "interactive", "shutdown" and "nothing". + + + 'suspend' + Laptop lid close action on battery + The action to take when the laptop lid is closed and the laptop is on battery power. Possible values are "suspend", "hibernate", "blank", and "nothing". + + + 'suspend' + Laptop lid close action when on AC + The action to take when the laptop lid is closed and the laptop is on AC power. Possible values are "suspend", "hibernate", "blank" and "nothing". + + + 3 + The default configuration version. + The version of the installed version of the schema. Do not edit this value, it is used so that configure changes between versions can be detected. + + + true + If the learnt profile should be used to calculate the time remaining + If the learnt profile should be used to calculate the time remaining. Only turn this off for debugging. + + + true + Whether to use time-based notifications + If time based notifications should be used. If set to false, then the percentage change is used instead, which may fix a broken ACPI BIOS. + + + false + Check CPU load before sleeping + If the CPU load should be checked before doing the idle action. + + + false + Whether NetworkManager should be connected and disconnected on sleep. + Whether NetworkManager should disconnect before suspending or hibernating and connect on resume. + + + true + Use mate-screensaver lock setting + Whether to use the screen lock setting of mate-screensaver to decide if the screen is locked after a hibernate, suspend or blank screen. + + + true + Lock screen when blanked + Whether the screen is locked when the screen is turned off. Only used if lock-use-screensaver is false. + + + true + Lock screen on suspend + Whether the screen is locked when the computer wakes up from a suspend. Only used if lock-use-screensaver is false. + + + true + Lock screen on hibernate + Whether the screen is locked when the computer wakes up from a hibernate. Only used if lock-use-screensaver is false. + + + false + Lock MATE keyring on sleep + Whether the MATE keyring is locked before the computer enters suspend. This means the keyring will have to be unlocked on resume. + + + true + Lock MATE keyring on sleep + Whether the MATE keyring is locked before the computer enters hibernate. This means the keyring will have to be unlocked on resume. + + + false + If the low-power mode should be enabled when on AC + If the system low-power mode should be enabled when on AC power. + + + true + If the low-power mode should be enabled when on battery + If the system low-power mode should be enabled when on laptop battery power. + + + 600 + Seconds of inactivity to spin down when on AC + The number of seconds of inactivity to spin down the disks when on AC power. + + + 60 + Seconds of inactivity to spin down when on battery + The number of seconds of inactivity to spin down the disks when on battery power. + + + true + If we should show the recalled battery warning for a broken battery + If we should show the recalled battery warning for a broken battery. Set this to false only if you know your battery is okay. + + + true + If we should show the low capacity warning for a broken battery + If we should show the low capacity warning for a broken battery. + + + true + Notify when AC adapter is disconnected + If the user should be notified when the AC adapter is disconnected. + + + false + Notify when fully charged + If a notification message should be displayed when the battery is fully charged. + + + true + Notify on a sleep failure + If a notification message should be displayed after suspend or hibernate failed. + + + '' + The URI to show to the user on sleep failure + When sleep fails we can show the user a button to help fix the situation. Leave this blank if the button should not be shown. + + + true + Notify on a low power + If a notification message should be displayed when the battery is getting low. + + + true + Whether we should show the history data points + Whether we should show the history data points in the statistics window. + + + true + Whether we should smooth the history data + Whether we should smooth the history data in the graph. + + + 'power' + The default graph type to show for history + The default graph type to show in the history window. + + + 21600 + The maximum time displayed for history + The maximum duration of time displayed on the x-axis of the history graph. + + + true + Whether we should show the stats data points + Whether we should show the stats data points in the statistics window. + + + true + Whether we should smooth the stats data + Whether we should smooth the stats data in the graph. + + + 'power' + The default graph type to show for stats + The default graph type to show in the stats window. + + + 0 + The index of the page number to show by default + The index of the page number to show by default which is used to return focus to the correct page. + + + '' + The ID of the last device selected + The identifier of the last device which is used to return focus to the correct device. + + + 10 + Percentage considered low + The percentage of the battery when it is considered low. Only valid when use-time-for-policy is false. + + + 3 + Percentage considered critical + The percentage of the battery when it is considered critical. Only valid when use-time-for-policy is false. + + + 2 + Percentage action is taken + The percentage of the battery when the critical action is performed. Only valid when use-time-for-policy is false. + + + 1200 + The time remaining when low + The time remaining in seconds of the battery when it is considered low. Only valid when use-time-for-policy is true. + + + 300 + The time remaining when critical + The time remaining in seconds of the battery when it is considered critical. Only valid when use-time-for-policy is true. + + + 120 + The time remaining when action is taken + The time remaining in seconds of the battery when critical action is taken. Only valid when use-time-for-policy is true. + + + 0 + Sleep timeout computer when on battery + The amount of time in seconds the computer on battery power needs to be inactive before it goes to sleep. + + + 0 + Sleep timeout computer when on AC + The amount of time in seconds the computer on AC power needs to be inactive before it goes to sleep. + + + 0 + Sleep timeout computer when on UPS + The amount of time in seconds the computer on UPS power needs to be inactive before it goes to sleep. + + + 1800 + Sleep timeout display when on AC + The amount of time in seconds before the display goes to sleep when the computer is on AC power. + + + 600 + Sleep timeout display when on battery + The amount of time in seconds the computer on battery power needs to be inactive before the display goes to sleep. + + + 600 + Sleep timeout display when on UPS + The amount of time in seconds the computer on UPS power needs to be inactive before the display goes to sleep. + + + true + If sounds should be used + If sounds should be used when the power is critically low, or inhibit requests have stopped the policy action. + + + true + If preferences and statistics items should be shown in the context menu + + + 'present' + When to show the notification icon + Display options for the notification icon. Valid options are "never", "low", "critical", "charge", and "present". + + + diff --git a/po/POTFILES.in b/po/POTFILES.in index 6cb335d..8596c96 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -6,7 +6,7 @@ applets/brightness/brightness-applet.c applets/inhibit/inhibit-applet.c [type: gettext/ini]applets/inhibit/org.mate.InhibitApplet.mate-panel-applet.in.in data/mate-power-manager.desktop.in.in -data/mate-power-manager.schemas.in +data/org.mate.power-manager.gschema.xml data/mate-power-preferences.desktop.in.in data/mate-power-statistics.desktop.in.in [type: gettext/glade]data/gpm-feedback-widget.ui diff --git a/src/gpm-backlight.c b/src/gpm-backlight.c index c88e220..9f6b148 100644 --- a/src/gpm-backlight.c +++ b/src/gpm-backlight.c @@ -39,7 +39,6 @@ #include #include -#include #include #include "gpm-button.h" @@ -62,7 +61,7 @@ struct GpmBacklightPrivate UpClient *client; GpmBrightness *brightness; GpmButton *button; - MateConfClient *conf; + GSettings *settings; GtkWidget *popup; GpmControl *control; GpmDpms *dpms; @@ -288,7 +287,7 @@ gpm_backlight_brightness_evaluate_and_set (GpmBacklight *backlight, gboolean int return FALSE; } - do_laptop_lcd = mateconf_client_get_bool (backlight->priv->conf, GPM_CONF_BACKLIGHT_ENABLE, NULL); + do_laptop_lcd = g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_BACKLIGHT_ENABLE); if (do_laptop_lcd == FALSE) { egg_warning ("policy is no dimming"); return FALSE; @@ -304,9 +303,9 @@ gpm_backlight_brightness_evaluate_and_set (GpmBacklight *backlight, gboolean int NULL); /* reduce if on battery power if we should */ - battery_reduce = mateconf_client_get_bool (backlight->priv->conf, GPM_CONF_BACKLIGHT_BATTERY_REDUCE, NULL); + battery_reduce = g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_BACKLIGHT_BATTERY_REDUCE); if (on_battery && battery_reduce) { - value = mateconf_client_get_int (backlight->priv->conf, GPM_CONF_BACKLIGHT_BRIGHTNESS_DIM_BATT, NULL); + value = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_BRIGHTNESS_DIM_BATT); if (value > 100) { egg_warning ("cannot use battery brightness value %i, correcting to 50", value); value = 50; @@ -320,11 +319,11 @@ gpm_backlight_brightness_evaluate_and_set (GpmBacklight *backlight, gboolean int /* reduce if system is momentarily idle */ if (!on_battery) - enable_action = mateconf_client_get_bool (backlight->priv->conf, GPM_CONF_BACKLIGHT_IDLE_DIM_AC, NULL); + enable_action = g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_IDLE_DIM_AC); else - enable_action = mateconf_client_get_bool (backlight->priv->conf, GPM_CONF_BACKLIGHT_IDLE_DIM_BATT, NULL); + enable_action = g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_IDLE_DIM_BATT); if (enable_action && backlight->priv->system_is_idle) { - value = mateconf_client_get_int (backlight->priv->conf, GPM_CONF_BACKLIGHT_IDLE_BRIGHTNESS, NULL); + value = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_IDLE_BRIGHTNESS); if (value > 100) { egg_warning ("cannot use idle brightness value %i, correcting to 50", value); value = 50; @@ -364,44 +363,39 @@ gpm_backlight_brightness_evaluate_and_set (GpmBacklight *backlight, gboolean int } /** - * gpm_conf_mateconf_key_changed_cb: + * gpm_settings_key_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, GpmBacklight *backlight) +gpm_settings_key_changed_cb (GSettings *settings, const gchar *key, GpmBacklight *backlight) { - MateConfValue *value; gboolean on_battery; - value = mateconf_entry_get_value (entry); - if (value == NULL) - return; - /* get battery status */ g_object_get (backlight->priv->client, "on-battery", &on_battery, NULL); - if (!on_battery && strcmp (entry->key, GPM_CONF_BACKLIGHT_BRIGHTNESS_AC) == 0) { - backlight->priv->master_percentage = mateconf_value_get_int (value); + if (!on_battery && g_strcmp0 (key, GPM_SETTINGS_BRIGHTNESS_AC) == 0) { + backlight->priv->master_percentage = g_settings_get_double (settings, key); gpm_backlight_brightness_evaluate_and_set (backlight, FALSE); - } else if (on_battery && strcmp (entry->key, GPM_CONF_BACKLIGHT_BRIGHTNESS_DIM_BATT) == 0) { + } else if (on_battery && g_strcmp0 (key, GPM_SETTINGS_BRIGHTNESS_DIM_BATT) == 0) { gpm_backlight_brightness_evaluate_and_set (backlight, FALSE); - } else if (strcmp (entry->key, GPM_CONF_BACKLIGHT_IDLE_DIM_AC) == 0 || - strcmp (entry->key, GPM_CONF_BACKLIGHT_ENABLE) == 0 || - strcmp (entry->key, GPM_CONF_TIMEOUT_SLEEP_DISPLAY_BATT) == 0 || - strcmp (entry->key, GPM_CONF_BACKLIGHT_BATTERY_REDUCE) == 0 || - strcmp (entry->key, GPM_CONF_BACKLIGHT_IDLE_BRIGHTNESS) == 0) { + } else if (g_strcmp0 (key, GPM_SETTINGS_IDLE_DIM_AC) == 0 || + g_strcmp0 (key, GPM_SETTINGS_BACKLIGHT_ENABLE) == 0 || + g_strcmp0 (key, GPM_SETTINGS_SLEEP_DISPLAY_BATT) == 0 || + g_strcmp0 (key, GPM_SETTINGS_BACKLIGHT_BATTERY_REDUCE) == 0 || + g_strcmp0 (key, GPM_SETTINGS_IDLE_BRIGHTNESS) == 0) { gpm_backlight_brightness_evaluate_and_set (backlight, FALSE); - } else if (strcmp (entry->key, GPM_CONF_BACKLIGHT_IDLE_DIM_TIME) == 0) { - backlight->priv->idle_dim_timeout = mateconf_value_get_int (value); + } else if (g_strcmp0 (key, GPM_SETTINGS_IDLE_DIM_TIME) == 0) { + backlight->priv->idle_dim_timeout = g_settings_get_int (settings, key); gpm_idle_set_timeout_dim (backlight->priv->idle, backlight->priv->idle_dim_timeout); } else { - egg_debug ("unknown key %s", entry->key); + egg_debug ("unknown key %s", key); } } @@ -434,7 +428,7 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli gboolean hw_changed; egg_debug ("Button press event type=%s", type); - if (strcmp (type, GPM_BUTTON_BRIGHT_UP) == 0) { + if (g_strcmp0 (type, GPM_BUTTON_BRIGHT_UP) == 0) { /* go up one step */ ret = gpm_brightness_up (backlight->priv->brightness, &hw_changed); @@ -453,7 +447,7 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli egg_debug ("emitting brightness-changed : %i", percentage); g_signal_emit (backlight, signals [BRIGHTNESS_CHANGED], 0, percentage); } - } else if (strcmp (type, GPM_BUTTON_BRIGHT_DOWN) == 0) { + } else if (g_strcmp0 (type, GPM_BUTTON_BRIGHT_DOWN) == 0) { /* go up down step */ ret = gpm_brightness_down (backlight->priv->brightness, &hw_changed); @@ -472,7 +466,7 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli egg_debug ("emitting brightness-changed : %i", percentage); g_signal_emit (backlight, signals [BRIGHTNESS_CHANGED], 0, percentage); } - } else if (strcmp (type, GPM_BUTTON_LID_OPEN) == 0) { + } else if (g_strcmp0 (type, GPM_BUTTON_LID_OPEN) == 0) { /* make sure we undim when we lift the lid */ gpm_backlight_brightness_evaluate_and_set (backlight, FALSE); @@ -520,8 +514,8 @@ gpm_backlight_notify_system_idle_changed (GpmBacklight *backlight, gboolean is_i if (elapsed > 2*60) { /* reset back to our default dimming */ backlight->priv->idle_dim_timeout = - mateconf_client_get_int (backlight->priv->conf, - GPM_CONF_BACKLIGHT_IDLE_DIM_TIME, NULL); + g_settings_get_int (backlight->priv->settings, + GPM_SETTINGS_IDLE_DIM_TIME); egg_debug ("resetting idle dim time to %is", backlight->priv->idle_dim_timeout); gpm_idle_set_timeout_dim (backlight->priv->idle, backlight->priv->idle_dim_timeout); } @@ -600,9 +594,9 @@ idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight) "on-battery", &on_battery, NULL); if (!on_battery) - dpms_method = mateconf_client_get_string (backlight->priv->conf, GPM_CONF_BACKLIGHT_DPMS_METHOD_AC, NULL); + dpms_method = g_settings_get_string (backlight->priv->settings, GPM_SETTINGS_DPMS_METHOD_AC); else - dpms_method = mateconf_client_get_string (backlight->priv->conf, GPM_CONF_BACKLIGHT_DPMS_METHOD_BATT, NULL); + dpms_method = g_settings_get_string (backlight->priv->settings, GPM_SETTINGS_DPMS_METHOD_BATT); /* convert the string types to standard types */ dpms_mode = gpm_dpms_mode_from_string (dpms_method); @@ -680,7 +674,7 @@ gpm_backlight_finalize (GObject *object) g_object_unref (backlight->priv->dpms); g_object_unref (backlight->priv->control); - g_object_unref (backlight->priv->conf); + g_object_unref (backlight->priv->settings); g_object_unref (backlight->priv->client); g_object_unref (backlight->priv->button); g_object_unref (backlight->priv->idle); @@ -742,17 +736,12 @@ gpm_backlight_init (GpmBacklight *backlight) backlight->priv->can_dim = gpm_brightness_has_hw (backlight->priv->brightness); /* watch for dim value changes */ - backlight->priv->conf = mateconf_client_get_default (); - - /* watch mate-power-manager keys */ - mateconf_client_add_dir (backlight->priv->conf, GPM_CONF_DIR, MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL); - mateconf_client_notify_add (backlight->priv->conf, GPM_CONF_DIR, - (MateConfClientNotifyFunc) gpm_conf_mateconf_key_changed_cb, - backlight, NULL, NULL); + backlight->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA); + g_signal_connect (backlight->priv->settings, "changed", G_CALLBACK (gpm_settings_key_changed_cb), backlight); /* set the main brightness, this is designed to be updated if the user changes the * brightness so we can undim to the 'correct' value */ - backlight->priv->master_percentage = mateconf_client_get_int (backlight->priv->conf, GPM_CONF_BACKLIGHT_BRIGHTNESS_AC, NULL); + backlight->priv->master_percentage = g_settings_get_double (backlight->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC); /* watch for brightness up and down buttons and also check lid state */ backlight->priv->button = gpm_button_new (); @@ -766,7 +755,7 @@ gpm_backlight_init (GpmBacklight *backlight) /* assumption */ backlight->priv->system_is_idle = FALSE; - backlight->priv->idle_dim_timeout = mateconf_client_get_int (backlight->priv->conf, GPM_CONF_BACKLIGHT_IDLE_DIM_TIME, NULL); + backlight->priv->idle_dim_timeout = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_IDLE_DIM_TIME); gpm_idle_set_timeout_dim (backlight->priv->idle, backlight->priv->idle_dim_timeout); /* use a visual widget */ diff --git a/src/gpm-common.h b/src/gpm-common.h index e2733a8..96a06a4 100644 --- a/src/gpm-common.h +++ b/src/gpm-common.h @@ -37,118 +37,106 @@ G_BEGIN_DECLS #define GPM_DESCRIPTION _("Power Manager for the MATE desktop") /* help location */ -#define GPM_HOMEPAGE_URL "http://www.mate.org/projects/mate-power-manager/" -#define GPM_BUGZILLA_URL "http://bugzilla.mate.org/buglist.cgi?product=mate-power-manager" -#define GPM_FAQ_URL "http://live.mate.org/MatePowerManager/Faq" +#define GPM_HOMEPAGE_URL "http://www.gnome.org/projects/mate-power-manager/" +#define GPM_BUGZILLA_URL "http://bugzilla.gnome.org/buglist.cgi?product=mate-power-manager" +#define GPM_FAQ_URL "http://live.gnome.org/MatePowerManager/Faq" /* change general/installed_schema whenever adding or moving keys */ -#define GPM_CONF_SCHEMA_ID 3 - -#define GPM_CONF_DIR "/apps/mate-power-manager" +#define GPM_SETTINGS_SCHEMA_ID 3 +#define GPM_SETTINGS_SCHEMA "org.mate.power-manager" /* actions */ -#define GPM_CONF_ACTIONS_CRITICAL_UPS GPM_CONF_DIR "/actions/critical_ups" -#define GPM_CONF_ACTIONS_CRITICAL_BATT GPM_CONF_DIR "/actions/critical_battery" -#define GPM_CONF_ACTIONS_LOW_UPS GPM_CONF_DIR "/actions/low_ups" -#define GPM_CONF_ACTIONS_SLEEP_TYPE_AC GPM_CONF_DIR "/actions/sleep_type_ac" -#define GPM_CONF_ACTIONS_SLEEP_TYPE_BATT GPM_CONF_DIR "/actions/sleep_type_battery" -#define GPM_CONF_ACTIONS_SLEEP_WHEN_CLOSED GPM_CONF_DIR "/actions/event_when_closed_battery" +#define GPM_SETTINGS_ACTION_CRITICAL_UPS "action-critical-ups" +#define GPM_SETTINGS_ACTION_CRITICAL_BATT "action-critical-battery" +#define GPM_SETTINGS_ACTION_LOW_UPS "action-low-ups" +#define GPM_SETTINGS_ACTION_SLEEP_TYPE_AC "action-sleep-type-ac" +#define GPM_SETTINGS_ACTION_SLEEP_TYPE_BATT "action-sleep-type-battery" +#define GPM_SETTINGS_SLEEP_WHEN_CLOSED "event-when-closed-battery" /* backlight stuff */ -#define GPM_CONF_BACKLIGHT_ENABLE GPM_CONF_DIR "/backlight/enable" -#define GPM_CONF_BACKLIGHT_BATTERY_REDUCE GPM_CONF_DIR "/backlight/battery_reduce" -#define GPM_CONF_BACKLIGHT_DPMS_METHOD_AC GPM_CONF_DIR "/backlight/dpms_method_ac" -#define GPM_CONF_BACKLIGHT_DPMS_METHOD_BATT GPM_CONF_DIR "/backlight/dpms_method_battery" -#define GPM_CONF_BACKLIGHT_IDLE_BRIGHTNESS GPM_CONF_DIR "/backlight/idle_brightness" -#define GPM_CONF_BACKLIGHT_IDLE_DIM_AC GPM_CONF_DIR "/backlight/idle_dim_ac" -#define GPM_CONF_BACKLIGHT_IDLE_DIM_BATT GPM_CONF_DIR "/backlight/idle_dim_battery" -#define GPM_CONF_BACKLIGHT_IDLE_DIM_TIME GPM_CONF_DIR "/backlight/idle_dim_time" -#define GPM_CONF_BACKLIGHT_BRIGHTNESS_AC GPM_CONF_DIR "/backlight/brightness_ac" -#define GPM_CONF_BACKLIGHT_BRIGHTNESS_DIM_BATT GPM_CONF_DIR "/backlight/brightness_dim_battery" +#define GPM_SETTINGS_BACKLIGHT_ENABLE "backlight-enable" +#define GPM_SETTINGS_BACKLIGHT_BATTERY_REDUCE "backlight-battery-reduce" +#define GPM_SETTINGS_DPMS_METHOD_AC "dpms-method-ac" +#define GPM_SETTINGS_DPMS_METHOD_BATT "dpms-method-battery" +#define GPM_SETTINGS_IDLE_BRIGHTNESS "idle-brightness" +#define GPM_SETTINGS_IDLE_DIM_AC "idle-dim-ac" +#define GPM_SETTINGS_IDLE_DIM_BATT "idle-dim-battery" +#define GPM_SETTINGS_IDLE_DIM_TIME "idle-dim-time" +#define GPM_SETTINGS_BRIGHTNESS_AC "brightness-ac" +#define GPM_SETTINGS_BRIGHTNESS_DIM_BATT "brightness-dim-battery" /* buttons */ -#define GPM_CONF_BUTTON_LID_AC GPM_CONF_DIR "/buttons/lid_ac" -#define GPM_CONF_BUTTON_LID_BATT GPM_CONF_DIR "/buttons/lid_battery" -#define GPM_CONF_BUTTON_SUSPEND GPM_CONF_DIR "/buttons/suspend" -#define GPM_CONF_BUTTON_HIBERNATE GPM_CONF_DIR "/buttons/hibernate" -#define GPM_CONF_BUTTON_POWER GPM_CONF_DIR "/buttons/power" +#define GPM_SETTINGS_BUTTON_LID_AC "button-lid-ac" +#define GPM_SETTINGS_BUTTON_LID_BATT "button-lid-battery" +#define GPM_SETTINGS_BUTTON_SUSPEND "button-suspend" +#define GPM_SETTINGS_BUTTON_HIBERNATE "button-hibernate" +#define GPM_SETTINGS_BUTTON_POWER "button-power" /* general */ -#define GPM_CONF_SCHEMA_VERSION GPM_CONF_DIR "/general/installed_schema" -#define GPM_CONF_USE_TIME_POLICY GPM_CONF_DIR "/general/use_time_for_policy" -#define GPM_CONF_USE_PROFILE_TIME GPM_CONF_DIR "/general/use_profile_time" -#define GPM_CONF_NETWORKMANAGER_SLEEP GPM_CONF_DIR "/general/network_sleep" -#define GPM_CONF_IDLE_CHECK_CPU GPM_CONF_DIR "/general/check_type_cpu" -#define GPM_CONF_LAPTOP_USES_EXT_MON GPM_CONF_DIR "/general/using_external_monitor" +#define GPM_SETTINGS_SCHEMA_VERSION "schema-version" +#define GPM_SETTINGS_USE_TIME_POLICY "use-time-for-policy" +#define GPM_SETTINGS_USE_PROFILE_TIME "use-profile-time" +#define GPM_SETTINGS_NETWORKMANAGER_SLEEP "network-sleep" +#define GPM_SETTINGS_IDLE_CHECK_CPU "check-type-cpu" /* lock */ -#define GPM_CONF_LOCK_USE_SCREENSAVER GPM_CONF_DIR "/lock/use_screensaver_settings" -#define GPM_CONF_LOCK_ON_BLANK_SCREEN GPM_CONF_DIR "/lock/blank_screen" -#define GPM_CONF_LOCK_ON_SUSPEND GPM_CONF_DIR "/lock/suspend" -#define GPM_CONF_LOCK_ON_HIBERNATE GPM_CONF_DIR "/lock/hibernate" -#define GPM_CONF_LOCK_MATE_KEYRING_SUSPEND GPM_CONF_DIR "/lock/mate_keyring_suspend" -#define GPM_CONF_LOCK_MATE_KEYRING_HIBERNATE GPM_CONF_DIR "/lock/mate_keyring_hibernate" +#define GPM_SETTINGS_LOCK_USE_SCREENSAVER "lock-use-screensaver" +#define GPM_SETTINGS_LOCK_ON_BLANK_SCREEN "lock-blank-screen" +#define GPM_SETTINGS_LOCK_ON_SUSPEND "lock-suspend" +#define GPM_SETTINGS_LOCK_ON_HIBERNATE "lock-hibernate" +#define GPM_SETTINGS_LOCK_KEYRING_SUSPEND "lock-keyring-suspend" +#define GPM_SETTINGS_LOCK_KEYRING_HIBERNATE "lock-keyring-hibernate" /* disks */ -#define GPM_CONF_DISKS_SPINDOWN_ENABLE_AC GPM_CONF_DIR "/disks/spindown_enable_ac" -#define GPM_CONF_DISKS_SPINDOWN_ENABLE_BATT GPM_CONF_DIR "/disks/spindown_enable_battery" -#define GPM_CONF_DISKS_SPINDOWN_TIMEOUT_AC GPM_CONF_DIR "/disks/spindown_timeout_ac" -#define GPM_CONF_DISKS_SPINDOWN_TIMEOUT_BATT GPM_CONF_DIR "/disks/spindown_timeout_battery" +#define GPM_SETTINGS_SPINDOWN_ENABLE_AC "spindown-enable-ac" +#define GPM_SETTINGS_SPINDOWN_ENABLE_BATT "spindown-enable-battery" +#define GPM_SETTINGS_SPINDOWN_TIMEOUT_AC "spindown-timeout-ac" +#define GPM_SETTINGS_SPINDOWN_TIMEOUT_BATT "spindown-timeout-battery" /* notify */ -#define GPM_CONF_NOTIFY_PERHAPS_RECALL GPM_CONF_DIR "/notify/perhaps_recall" -#define GPM_CONF_NOTIFY_LOW_CAPACITY GPM_CONF_DIR "/notify/low_capacity" -#define GPM_CONF_NOTIFY_DISCHARGING GPM_CONF_DIR "/notify/discharging" -#define GPM_CONF_NOTIFY_FULLY_CHARGED GPM_CONF_DIR "/notify/fully_charged" -#define GPM_CONF_NOTIFY_SLEEP_FAILED GPM_CONF_DIR "/notify/sleep_failed" -#define GPM_CONF_NOTIFY_SLEEP_FAILED_URI GPM_CONF_DIR "/notify/sleep_failed_uri" -#define GPM_CONF_NOTIFY_LOW_POWER GPM_CONF_DIR "/notify/low_power" - -/* statistics */ -#define GPM_CONF_STATS_SHOW_AXIS_LABELS GPM_CONF_DIR "/statistics/show_axis_labels" -#define GPM_CONF_STATS_SHOW_EVENTS GPM_CONF_DIR "/statistics/show_events" -#define GPM_CONF_STATS_SMOOTH_DATA GPM_CONF_DIR "/statistics/smooth_data" -#define GPM_CONF_STATS_GRAPH_TYPE GPM_CONF_DIR "/statistics/graph_type" -#define GPM_CONF_STATS_MAX_TIME GPM_CONF_DIR "/statistics/data_max_time" +#define GPM_SETTINGS_NOTIFY_PERHAPS_RECALL "notify-perhaps-recall" +#define GPM_SETTINGS_NOTIFY_LOW_CAPACITY "notify-low-capacity" +#define GPM_SETTINGS_NOTIFY_DISCHARGING "notify-discharging" +#define GPM_SETTINGS_NOTIFY_FULLY_CHARGED "notify-fully-charged" +#define GPM_SETTINGS_NOTIFY_SLEEP_FAILED "notify-sleep-failed" +#define GPM_SETTINGS_NOTIFY_SLEEP_FAILED_URI "notify-sleep-failed-uri" +#define GPM_SETTINGS_NOTIFY_LOW_POWER "notify-low-power" /* thresholds */ -#define GPM_CONF_THRESH_PERCENTAGE_LOW GPM_CONF_DIR "/thresholds/percentage_low" -#define GPM_CONF_THRESH_PERCENTAGE_CRITICAL GPM_CONF_DIR "/thresholds/percentage_critical" -#define GPM_CONF_THRESH_PERCENTAGE_ACTION GPM_CONF_DIR "/thresholds/percentage_action" -#define GPM_CONF_THRESH_TIME_LOW GPM_CONF_DIR "/thresholds/time_low" -#define GPM_CONF_THRESH_TIME_CRITICAL GPM_CONF_DIR "/thresholds/time_critical" -#define GPM_CONF_THRESH_TIME_ACTION GPM_CONF_DIR "/thresholds/time_action" +#define GPM_SETTINGS_PERCENTAGE_LOW "percentage-low" +#define GPM_SETTINGS_PERCENTAGE_CRITICAL "percentage-critical" +#define GPM_SETTINGS_PERCENTAGE_ACTION "percentage-action" +#define GPM_SETTINGS_TIME_LOW "time-low" +#define GPM_SETTINGS_TIME_CRITICAL "time-critical" +#define GPM_SETTINGS_TIME_ACTION "time-action" /* timeout */ -#define GPM_CONF_TIMEOUT_SLEEP_COMPUTER_AC GPM_CONF_DIR "/timeout/sleep_computer_ac" -#define GPM_CONF_TIMEOUT_SLEEP_COMPUTER_BATT GPM_CONF_DIR "/timeout/sleep_computer_battery" -#define GPM_CONF_TIMEOUT_SLEEP_COMPUTER_UPS GPM_CONF_DIR "/timeout/sleep_computer_ups" -#define GPM_CONF_TIMEOUT_SLEEP_DISPLAY_AC GPM_CONF_DIR "/timeout/sleep_display_ac" -#define GPM_CONF_TIMEOUT_SLEEP_DISPLAY_BATT GPM_CONF_DIR "/timeout/sleep_display_battery" -#define GPM_CONF_TIMEOUT_SLEEP_DISPLAY_UPS GPM_CONF_DIR "/timeout/sleep_display_ups" +#define GPM_SETTINGS_SLEEP_COMPUTER_AC "sleep-computer-ac" +#define GPM_SETTINGS_SLEEP_COMPUTER_BATT "sleep-computer-battery" +#define GPM_SETTINGS_SLEEP_COMPUTER_UPS "sleep-computer-ups" +#define GPM_SETTINGS_SLEEP_DISPLAY_AC "sleep-display-ac" +#define GPM_SETTINGS_SLEEP_DISPLAY_BATT "sleep-display-battery" +#define GPM_SETTINGS_SLEEP_DISPLAY_UPS "sleep-display-ups" /* ui */ -#define GPM_CONF_UI_ICON_POLICY GPM_CONF_DIR "/ui/icon_policy" -#define GPM_CONF_UI_ENABLE_SOUND GPM_CONF_DIR "/ui/enable_sound" -#define GPM_CONF_UI_SHOW_ACTIONS GPM_CONF_DIR "/ui/show_actions" - -/* new info binary */ -#define GPM_CONF_INFO_HISTORY_TIME "/apps/mate-power-manager/info/history_time" -#define GPM_CONF_INFO_HISTORY_TYPE "/apps/mate-power-manager/info/history_type" -#define GPM_CONF_INFO_HISTORY_GRAPH_SMOOTH "/apps/mate-power-manager/info/history_graph_smooth" -#define GPM_CONF_INFO_HISTORY_GRAPH_POINTS "/apps/mate-power-manager/info/history_graph_points" -#define GPM_CONF_INFO_STATS_TYPE "/apps/mate-power-manager/info/stats_type" -#define GPM_CONF_INFO_STATS_GRAPH_SMOOTH "/apps/mate-power-manager/info/stats_graph_smooth" -#define GPM_CONF_INFO_STATS_GRAPH_POINTS "/apps/mate-power-manager/info/stats_graph_points" -#define GPM_CONF_INFO_PAGE_NUMBER "/apps/mate-power-manager/info/page_number" -#define GPM_CONF_INFO_LAST_DEVICE "/apps/mate-power-manager/info/last_device" +#define GPM_SETTINGS_ICON_POLICY "icon-policy" +#define GPM_SETTINGS_ENABLE_SOUND "enable-sound" +#define GPM_SETTINGS_SHOW_ACTIONS "show-actions" -/* mate-screensaver */ -#define GS_CONF_DIR "/apps/mate-screensaver" -#define GS_PREF_LOCK_ENABLED GS_CONF_DIR "/lock_enabled" +/* statistics */ +#define GPM_SETTINGS_INFO_HISTORY_TIME "info-history-time" +#define GPM_SETTINGS_INFO_HISTORY_TYPE "info-history-type" +#define GPM_SETTINGS_INFO_HISTORY_GRAPH_SMOOTH "info-history-graph-smooth" +#define GPM_SETTINGS_INFO_HISTORY_GRAPH_POINTS "info-history-graph-points" +#define GPM_SETTINGS_INFO_STATS_TYPE "info-stats-type" +#define GPM_SETTINGS_INFO_STATS_GRAPH_SMOOTH "info-stats-graph-smooth" +#define GPM_SETTINGS_INFO_STATS_GRAPH_POINTS "info-stats-graph-points" +#define GPM_SETTINGS_INFO_PAGE_NUMBER "info-page-number" +#define GPM_SETTINGS_INFO_LAST_DEVICE "info-last-device" -/* mate-session */ -#define GPM_CONF_IDLE_DELAY "/desktop/mate/session/idle_delay" +/* mate-screensaver */ +#define GS_CONF_DIR "/apps/mate-screensaver" +#define GS_CONF_PREF_LOCK_ENABLED GS_CONF_DIR "/lock_enabled" typedef enum { GPM_ICON_POLICY_ALWAYS, diff --git a/src/gpm-control.c b/src/gpm-control.c index 50212b8..3c945f0 100644 --- a/src/gpm-control.c +++ b/src/gpm-control.c @@ -56,6 +56,7 @@ struct GpmControlPrivate { MateConfClient *conf; + GSettings *settings; UpClient *client; }; @@ -103,7 +104,7 @@ gpm_control_shutdown (GpmControl *control, GError **error) /** * gpm_control_get_lock_policy: * @control: This class instance - * @policy: The policy mateconf string. + * @policy: The policy string. * * This function finds out if we should lock the screen when we do an * action. It is required as we can either use the mate-screensaver policy @@ -116,15 +117,15 @@ gpm_control_get_lock_policy (GpmControl *control, const gchar *policy) { gboolean do_lock; gboolean use_ss_setting; - /* This allows us to over-ride the custom lock settings set in mateconf + /* This allows us to over-ride the custom lock settings set with a system default set in mate-screensaver. See bug #331164 for all the juicy details. :-) */ - use_ss_setting = mateconf_client_get_bool (control->priv->conf, GPM_CONF_LOCK_USE_SCREENSAVER, NULL); + use_ss_setting = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_LOCK_USE_SCREENSAVER); if (use_ss_setting) { - do_lock = mateconf_client_get_bool (control->priv->conf, GS_PREF_LOCK_ENABLED, NULL); + do_lock = mateconf_client_get_bool (control->priv->conf, GS_CONF_PREF_LOCK_ENABLED, NULL); egg_debug ("Using ScreenSaver settings (%i)", do_lock); } else { - do_lock = mateconf_client_get_bool (control->priv->conf, policy, NULL); + do_lock = g_settings_get_boolean (control->priv->settings, policy); egg_debug ("Using custom locking settings (%i)", do_lock); } return do_lock; @@ -157,20 +158,20 @@ gpm_control_suspend (GpmControl *control, GError **error) } /* we should perhaps lock keyrings when sleeping #375681 */ - lock_mate_keyring = mateconf_client_get_bool (control->priv->conf, GPM_CONF_LOCK_MATE_KEYRING_SUSPEND, NULL); + lock_mate_keyring = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_LOCK_KEYRING_SUSPEND); if (lock_mate_keyring) { keyres = mate_keyring_lock_all_sync (); if (keyres != MATE_KEYRING_RESULT_OK) egg_warning ("could not lock keyring"); } - do_lock = gpm_control_get_lock_policy (control, GPM_CONF_LOCK_ON_SUSPEND); + do_lock = gpm_control_get_lock_policy (control, GPM_SETTINGS_LOCK_ON_SUSPEND); if (do_lock) { throttle_cookie = gpm_screensaver_add_throttle (screensaver, "suspend"); gpm_screensaver_lock (screensaver); } - nm_sleep = mateconf_client_get_bool (control->priv->conf, GPM_CONF_NETWORKMANAGER_SLEEP, NULL); + nm_sleep = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_NETWORKMANAGER_SLEEP); if (nm_sleep) gpm_networkmanager_sleep (); @@ -189,7 +190,7 @@ gpm_control_suspend (GpmControl *control, GError **error) gpm_screensaver_remove_throttle (screensaver, throttle_cookie); } - nm_sleep = mateconf_client_get_bool (control->priv->conf, GPM_CONF_NETWORKMANAGER_SLEEP, NULL); + nm_sleep = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_NETWORKMANAGER_SLEEP); if (nm_sleep) gpm_networkmanager_wake (); @@ -225,7 +226,7 @@ gpm_control_hibernate (GpmControl *control, GError **error) } /* we should perhaps lock keyrings when sleeping #375681 */ - lock_mate_keyring = mateconf_client_get_bool (control->priv->conf, GPM_CONF_LOCK_MATE_KEYRING_HIBERNATE, NULL); + lock_mate_keyring = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_LOCK_KEYRING_HIBERNATE); if (lock_mate_keyring) { keyres = mate_keyring_lock_all_sync (); if (keyres != MATE_KEYRING_RESULT_OK) { @@ -233,13 +234,13 @@ gpm_control_hibernate (GpmControl *control, GError **error) } } - do_lock = gpm_control_get_lock_policy (control, GPM_CONF_LOCK_ON_HIBERNATE); + do_lock = gpm_control_get_lock_policy (control, GPM_SETTINGS_LOCK_ON_HIBERNATE); if (do_lock) { throttle_cookie = gpm_screensaver_add_throttle (screensaver, "hibernate"); gpm_screensaver_lock (screensaver); } - nm_sleep = mateconf_client_get_bool (control->priv->conf, GPM_CONF_NETWORKMANAGER_SLEEP, NULL); + nm_sleep = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_NETWORKMANAGER_SLEEP); if (nm_sleep) gpm_networkmanager_sleep (); @@ -257,7 +258,7 @@ gpm_control_hibernate (GpmControl *control, GError **error) gpm_screensaver_remove_throttle (screensaver, throttle_cookie); } - nm_sleep = mateconf_client_get_bool (control->priv->conf, GPM_CONF_NETWORKMANAGER_SLEEP, NULL); + nm_sleep = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_NETWORKMANAGER_SLEEP); if (nm_sleep) gpm_networkmanager_wake (); @@ -279,6 +280,7 @@ gpm_control_finalize (GObject *object) control = GPM_CONTROL (object); g_object_unref (control->priv->conf); + g_object_unref (control->priv->settings); g_object_unref (control->priv->client); g_return_if_fail (control->priv != NULL); @@ -326,6 +328,7 @@ gpm_control_init (GpmControl *control) control->priv = GPM_CONTROL_GET_PRIVATE (control); control->priv->client = up_client_new (); + control->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA); control->priv->conf = mateconf_client_get_default (); } diff --git a/src/gpm-engine.c b/src/gpm-engine.c index 0b1bb62..b006c32 100644 --- a/src/gpm-engine.c +++ b/src/gpm-engine.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include "egg-debug.h" @@ -44,7 +43,7 @@ static void gpm_engine_finalize (GObject *object); struct GpmEnginePrivate { - MateConfClient *conf; + GSettings *settings; UpClient *client; UpDevice *battery_composite; GPtrArray *array; @@ -509,28 +508,20 @@ gpm_engine_recalculate_state (GpmEngine *engine) } /** - * gpm_engine_conf_key_changed_cb: + * gpm_engine_settings_key_changed_cb: **/ static void -gpm_engine_conf_key_changed_cb (MateConfClient *conf, guint cnxn_id, MateConfEntry *entry, GpmEngine *engine) +gpm_engine_settings_key_changed_cb (GSettings *settings, const gchar *key, GpmEngine *engine) { - MateConfValue *value; gchar *icon_policy; - if (entry == NULL) - return; - value = mateconf_entry_get_value (entry); - if (value == NULL) - return; - - if (strcmp (entry->key, GPM_CONF_USE_TIME_POLICY) == 0) { - - engine->priv->use_time_primary = mateconf_value_get_bool (value); + if (g_strcmp0 (key, GPM_SETTINGS_USE_TIME_POLICY) == 0) { + engine->priv->use_time_primary = g_settings_get_boolean (settings, key); - } else if (strcmp (entry->key, GPM_CONF_UI_ICON_POLICY) == 0) { + } else if (g_strcmp0 (key, GPM_SETTINGS_ICON_POLICY) == 0) { /* do we want to display the icon in the tray */ - icon_policy = mateconf_client_get_string (conf, GPM_CONF_UI_ICON_POLICY, NULL); + icon_policy = g_settings_get_string (settings, key); engine->priv->icon_policy = gpm_icon_policy_from_string (icon_policy); g_free (icon_policy); @@ -567,8 +558,8 @@ gpm_engine_device_check_capacity (GpmEngine *engine, UpDevice *device) if (capacity < 1.0f) return FALSE; - /* only emit this if specified in mateconf */ - ret = mateconf_client_get_bool (engine->priv->conf, GPM_CONF_NOTIFY_LOW_CAPACITY, NULL); + /* only emit this if specified in the settings */ + ret = g_settings_get_boolean (engine->priv->settings, GPM_SETTINGS_NOTIFY_LOW_CAPACITY); if (ret) { egg_debug ("** EMIT: low-capacity"); g_signal_emit (engine, signals [LOW_CAPACITY], 0, device); @@ -1067,10 +1058,9 @@ gpm_engine_init (GpmEngine *engine) g_signal_connect (engine->priv->client, "device-changed", G_CALLBACK (gpm_engine_device_changed_cb), engine); - engine->priv->conf = mateconf_client_get_default (); - mateconf_client_notify_add (engine->priv->conf, GPM_CONF_DIR, - (MateConfClientNotifyFunc) gpm_engine_conf_key_changed_cb, - engine, NULL, NULL); + engine->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA); + g_signal_connect (engine->priv->settings, "changed", + G_CALLBACK (gpm_engine_settings_key_changed_cb), engine); engine->priv->phone = gpm_phone_new (); g_signal_connect (engine->priv->phone, "device-added", @@ -1094,22 +1084,22 @@ gpm_engine_init (GpmEngine *engine) engine->priv->previous_summary = NULL; /* do we want to display the icon in the tray */ - icon_policy = mateconf_client_get_string (engine->priv->conf, GPM_CONF_UI_ICON_POLICY, NULL); + icon_policy = g_settings_get_string (engine->priv->settings, GPM_SETTINGS_ICON_POLICY); engine->priv->icon_policy = gpm_icon_policy_from_string (icon_policy); g_free (icon_policy); /* get percentage policy */ - engine->priv->low_percentage = mateconf_client_get_int (engine->priv->conf, GPM_CONF_THRESH_PERCENTAGE_LOW, NULL); - engine->priv->critical_percentage = mateconf_client_get_int (engine->priv->conf, GPM_CONF_THRESH_PERCENTAGE_CRITICAL, NULL); - engine->priv->action_percentage = mateconf_client_get_int (engine->priv->conf, GPM_CONF_THRESH_PERCENTAGE_ACTION, NULL); + engine->priv->low_percentage = g_settings_get_int (engine->priv->settings, GPM_SETTINGS_PERCENTAGE_LOW); + engine->priv->critical_percentage = g_settings_get_int (engine->priv->settings, GPM_SETTINGS_PERCENTAGE_CRITICAL); + engine->priv->action_percentage = g_settings_get_int (engine->priv->settings, GPM_SETTINGS_PERCENTAGE_ACTION); /* get time policy */ - engine->priv->low_time = mateconf_client_get_int (engine->priv->conf, GPM_CONF_THRESH_TIME_LOW, NULL); - engine->priv->critical_time = mateconf_client_get_int (engine->priv->conf, GPM_CONF_THRESH_TIME_CRITICAL, NULL); - engine->priv->action_time = mateconf_client_get_int (engine->priv->conf, GPM_CONF_THRESH_TIME_ACTION, NULL); + engine->priv->low_time = g_settings_get_int (engine->priv->settings, GPM_SETTINGS_TIME_LOW); + engine->priv->critical_time = g_settings_get_int (engine->priv->settings, GPM_SETTINGS_TIME_CRITICAL); + engine->priv->action_time = g_settings_get_int (engine->priv->settings, GPM_SETTINGS_TIME_ACTION); /* we can disable this if the time remaining is inaccurate or just plain wrong */ - engine->priv->use_time_primary = mateconf_client_get_bool (engine->priv->conf, GPM_CONF_USE_TIME_POLICY, NULL); + engine->priv->use_time_primary = g_settings_get_boolean (engine->priv->settings, GPM_SETTINGS_USE_TIME_POLICY); if (engine->priv->use_time_primary) egg_debug ("Using per-time notification policy"); else diff --git a/src/gpm-manager.c b/src/gpm-manager.c index a84f338..6014f84 100644 --- a/src/gpm-manager.c +++ b/src/gpm-manager.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -76,7 +75,7 @@ static void gpm_manager_finalize (GObject *object); struct GpmManagerPrivate { GpmButton *button; - MateConfClient *conf; + GSettings *settings; GpmDisks *disks; GpmDpms *dpms; GpmIdle *idle; @@ -198,7 +197,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; @@ -259,7 +258,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; @@ -354,11 +353,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 */ @@ -385,7 +384,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"); @@ -421,7 +420,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; @@ -532,7 +531,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) { @@ -560,8 +559,8 @@ 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); @@ -597,7 +596,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); @@ -663,7 +662,7 @@ 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) @@ -675,7 +674,7 @@ gpm_manager_perform_policy (GpmManager *manager, const gchar *policy_key, const if (gpm_manager_is_inhibit_valid (manager, FALSE, "policy action") == FALSE) return FALSE; - action = mateconf_client_get_string (manager->priv->conf, policy_key, NULL); + action = g_settings_get_string (manager->priv->settings, policy_key); egg_debug ("action: %s set to %s (%s)", policy_key, action, reason); policy = gpm_action_policy_from_string (action); @@ -713,7 +712,7 @@ gpm_manager_perform_policy (GpmManager *manager, const gchar *policy_key, const * @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) @@ -724,9 +723,9 @@ gpm_manager_idle_do_sleep (GpmManager *manager) GpmActionPolicy policy; if (!manager->priv->on_battery) - action = mateconf_client_get_string (manager->priv->conf, GPM_CONF_ACTIONS_SLEEP_TYPE_AC, NULL); + action = g_settings_get_string (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); + action = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_ACTION_SLEEP_TYPE_BATT); policy = gpm_action_policy_from_string (action); if (policy == GPM_ACTION_POLICY_NOTHING) { @@ -824,13 +823,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."); } @@ -913,13 +912,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) { @@ -958,11 +957,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; @@ -1033,15 +1032,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)."); } } @@ -1061,7 +1060,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; } @@ -1078,23 +1077,17 @@ 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); } @@ -1139,7 +1132,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; } @@ -1217,9 +1210,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; } @@ -1297,8 +1290,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; @@ -1351,8 +1344,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; @@ -1596,7 +1589,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); + action = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_BATT); policy = gpm_action_policy_from_string (action); /* use different text for different actions */ @@ -1752,7 +1745,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); + action = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_BATT); policy = gpm_action_policy_from_string (action); /* use different text for different actions */ @@ -1790,7 +1783,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); + action = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_UPS); policy = gpm_action_policy_from_string (action); /* use different text for different actions */ @@ -1922,7 +1915,9 @@ gpm_manager_init (GpmManager *manager) 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); @@ -1930,16 +1925,9 @@ 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) { + version = g_settings_get_int (manager->priv->settings, GPM_SETTINGS_SCHEMA_VERSION); + if (version != GPM_SETTINGS_SCHEMA_ID) { gpm_manager_notify (manager, &manager->priv->notification_general, /* TRANSLATORS: there was in install problem */ _("Install problem!"), @@ -1949,7 +1937,7 @@ gpm_manager_init (GpmManager *manager) GPM_MANAGER_NOTIFY_TIMEOUT_LONG, GTK_STOCK_DIALOG_WARNING, NOTIFY_URGENCY_NORMAL); - egg_error ("no mateconf schema installed!"); + egg_error ("no GSettings schema installed!"); } /* coldplug so we are in the correct state at startup */ @@ -1983,7 +1971,7 @@ gpm_manager_init (GpmManager *manager) 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 (); @@ -2062,7 +2050,7 @@ 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); diff --git a/src/gpm-phone.c b/src/gpm-phone.c index e5455f7..0732c91 100644 --- a/src/gpm-phone.c +++ b/src/gpm-phone.c @@ -26,7 +26,6 @@ #include #include -#include #include "gpm-phone.h" #include "egg-debug.h" #include "gpm-marshal.h" diff --git a/src/gpm-prefs-core.c b/src/gpm-prefs-core.c index 46cae73..3f23c87 100644 --- a/src/gpm-prefs-core.c +++ b/src/gpm-prefs-core.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include "egg-debug.h" @@ -58,8 +57,7 @@ struct GpmPrefsPrivate gboolean can_shutdown; gboolean can_suspend; gboolean can_hibernate; - guint idle_delay; - MateConfClient *conf; + GSettings *settings; EggConsoleKit *console; }; @@ -142,8 +140,8 @@ gpm_prefs_icon_radio_cb (GtkWidget *widget, GpmPrefs *prefs) policy = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "policy")); str = gpm_icon_policy_to_string (policy); - egg_debug ("Changing %s to %s", GPM_CONF_UI_ICON_POLICY, str); - mateconf_client_set_string (prefs->priv->conf, GPM_CONF_UI_ICON_POLICY, str, NULL); + egg_debug ("Changing %s to %s", GPM_SETTINGS_ICON_POLICY, str); + g_settings_set_string (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY, str); } /** @@ -157,58 +155,6 @@ gpm_prefs_format_percentage_cb (GtkScale *scale, gdouble value) return g_strdup_printf ("%.0f%%", value); } -/** - * gpm_prefs_brightness_slider_changed_cb: - * @range: The GtkRange object - * @gpm_pref_key: The MateConf key for this preference setting. - **/ -static void -gpm_prefs_brightness_slider_changed_cb (GtkRange *range, GpmPrefs *prefs) -{ - gdouble value; - gchar *gpm_pref_key; - - value = gtk_range_get_value (range); - gpm_pref_key = (char *) g_object_get_data (G_OBJECT (range), "conf_key"); - - g_object_set_data (G_OBJECT (range), "conf_key", (gpointer) gpm_pref_key); - egg_debug ("Changing %s to %i", gpm_pref_key, (int) value); - mateconf_client_set_int (prefs->priv->conf, gpm_pref_key, (gint) value, NULL); -} - -/** - * gpm_prefs_setup_brightness_slider: - * @prefs: This prefs class instance - * @widget_name: The GtkWidget name - * @gpm_pref_key: The MateConf key for this preference setting. - **/ -static GtkWidget * -gpm_prefs_setup_brightness_slider (GpmPrefs *prefs, const gchar *widget_name, const gchar *gpm_pref_key) -{ - GtkWidget *widget; - int value; - gboolean is_writable; - - widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, widget_name)); - - g_signal_connect (G_OBJECT (widget), "format-value", - G_CALLBACK (gpm_prefs_format_percentage_cb), NULL); - - value = mateconf_client_get_int (prefs->priv->conf, gpm_pref_key, NULL); - is_writable = mateconf_client_key_is_writable (prefs->priv->conf, gpm_pref_key, NULL); - - gtk_widget_set_sensitive (widget, is_writable); - - gtk_range_set_value (GTK_RANGE (widget), value); - - g_object_set_data (G_OBJECT (widget), "conf_key", (gpointer) gpm_pref_key); - - g_signal_connect (G_OBJECT (widget), "value-changed", - G_CALLBACK (gpm_prefs_brightness_slider_changed_cb), - prefs); - return widget; -} - /** * gpm_prefs_action_combo_changed_cb: **/ @@ -222,13 +168,13 @@ gpm_prefs_action_combo_changed_cb (GtkWidget *widget, GpmPrefs *prefs) guint active; actions = (const GpmActionPolicy *) g_object_get_data (G_OBJECT (widget), "actions"); - gpm_pref_key = (const gchar *) g_object_get_data (G_OBJECT (widget), "conf_key"); + gpm_pref_key = (const gchar *) g_object_get_data (G_OBJECT (widget), "settings_key"); active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)); policy = actions[active]; action = gpm_action_policy_to_string (policy); egg_debug ("Changing %s to %s", gpm_pref_key, action); - mateconf_client_set_string (prefs->priv->conf, gpm_pref_key, action, NULL); + g_settings_set_string (prefs->priv->settings, gpm_pref_key, action); } /** @@ -243,13 +189,13 @@ gpm_prefs_action_time_changed_cb (GtkWidget *widget, GpmPrefs *prefs) guint active; values = (const gint *) g_object_get_data (G_OBJECT (widget), "values"); - gpm_pref_key = (const gchar *) g_object_get_data (G_OBJECT (widget), "conf_key"); + gpm_pref_key = (const gchar *) g_object_get_data (G_OBJECT (widget), "settings_key"); active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)); value = values[active]; egg_debug ("Changing %s to %i", gpm_pref_key, value); - mateconf_client_set_int (prefs->priv->conf, gpm_pref_key, value, NULL); + g_settings_set_int (prefs->priv->settings, gpm_pref_key, value); } /** @@ -289,7 +235,7 @@ gpm_prefs_actions_destroy_cb (GpmActionPolicy *array) * gpm_prefs_setup_action_combo: * @prefs: This prefs class instance * @widget_name: The GtkWidget name - * @gpm_pref_key: The MateConf key for this preference setting. + * @gpm_pref_key: The settings key for this preference setting. * @actions: The actions to associate in an array. **/ static void @@ -308,14 +254,14 @@ gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name, widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, widget_name)); gpm_prefs_set_combo_simple_text (widget); - value_txt = mateconf_client_get_string (prefs->priv->conf, gpm_pref_key, NULL); - is_writable = mateconf_client_key_is_writable (prefs->priv->conf, gpm_pref_key, NULL); + value_txt = g_settings_get_string (prefs->priv->settings, gpm_pref_key); + is_writable = g_settings_is_writable (prefs->priv->settings, gpm_pref_key); value = gpm_action_policy_from_string (value_txt); gtk_widget_set_sensitive (widget, is_writable); array = g_ptr_array_new (); - g_object_set_data (G_OBJECT (widget), "conf_key", (gpointer) gpm_pref_key); + g_object_set_data (G_OBJECT (widget), "settings_key", (gpointer) gpm_pref_key); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (gpm_prefs_action_combo_changed_cb), prefs); @@ -368,7 +314,7 @@ gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name, g_ptr_array_add (array, GINT_TO_POINTER (policy)); #endif } else if (policy == GPM_ACTION_POLICY_NOTHING) { - /* we only add do nothing in the GUI if the user has explicitly specified this in MateConf */ + /* we only add do nothing in the GUI if the user has explicitly specified this in the settings */ if (value == GPM_ACTION_POLICY_NOTHING) { #if GTK_CHECK_VERSION (2, 24, 0) gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT (widget), _("Do nothing")); @@ -379,7 +325,7 @@ gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name, #endif } } else { - egg_warning ("Unknown action read from conf: %i", policy); + egg_warning ("Unknown action read from settings: %i", policy); } } @@ -391,7 +337,7 @@ gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name, g_object_set_data_full (G_OBJECT (widget), "actions", (gpointer) actions_added, (GDestroyNotify) gpm_prefs_actions_destroy_cb); - /* set what we have in MateConf */ + /* set what we have in the settings */ for (i=0; actions_added[i] != -1; i++) { policy = actions_added[i]; egg_debug ("added: %s", gpm_action_policy_to_string (policy)); @@ -407,7 +353,7 @@ gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name, * gpm_prefs_setup_time_combo: * @prefs: This prefs class instance * @widget_name: The GtkWidget name - * @gpm_pref_key: The MateConf key for this preference setting. + * @gpm_pref_key: The settings key for this preference setting. * @actions: The actions to associate in an array. **/ static void @@ -423,11 +369,11 @@ gpm_prefs_setup_time_combo (GpmPrefs *prefs, const gchar *widget_name, widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, widget_name)); gpm_prefs_set_combo_simple_text (widget); - value = mateconf_client_get_int (prefs->priv->conf, gpm_pref_key, NULL); - is_writable = mateconf_client_key_is_writable (prefs->priv->conf, gpm_pref_key, NULL); + value = g_settings_get_int (prefs->priv->settings, gpm_pref_key); + is_writable = g_settings_is_writable (prefs->priv->settings, gpm_pref_key); gtk_widget_set_sensitive (widget, is_writable); - g_object_set_data (G_OBJECT (widget), "conf_key", (gpointer) gpm_pref_key); + g_object_set_data (G_OBJECT (widget), "settings_key", (gpointer) gpm_pref_key); g_object_set_data (G_OBJECT (widget), "values", (gpointer) values); /* add each time */ @@ -460,55 +406,6 @@ gpm_prefs_setup_time_combo (GpmPrefs *prefs, const gchar *widget_name, G_CALLBACK (gpm_prefs_action_time_changed_cb), prefs); } -/** - * gpm_prefs_checkbox_lock_cb: - * @widget: The GtkWidget object - * @gpm_pref_key: The MateConf key for this preference setting. - **/ -static void -gpm_prefs_checkbox_lock_cb (GtkWidget *widget, GpmPrefs *prefs) -{ - gboolean checked; - gchar *gpm_pref_key; - - checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - - gpm_pref_key = (char *) g_object_get_data (G_OBJECT (widget), "conf_key"); - egg_debug ("Changing %s to %i", gpm_pref_key, checked); - mateconf_client_set_bool (prefs->priv->conf, gpm_pref_key, checked, NULL); -} - -/** - * gpm_prefs_setup_checkbox: - * @prefs: This prefs class instance - * @widget_name: The GtkWidget name - * @gpm_pref_key: The MateConf key for this preference setting. - **/ -static GtkWidget * -gpm_prefs_setup_checkbox (GpmPrefs *prefs, const gchar *widget_name, const gchar *gpm_pref_key) -{ - gboolean checked; - GtkWidget *widget; - - egg_debug ("Setting up %s", gpm_pref_key); - - widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, widget_name)); - - checked = mateconf_client_get_bool (prefs->priv->conf, gpm_pref_key, NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), checked); - - g_object_set_data (G_OBJECT (widget), "conf_key", (gpointer) gpm_pref_key); - - /* manually do the callback in case we hide elements in the cb */ - gpm_prefs_checkbox_lock_cb (widget, prefs); - - /* setup after set */ - g_signal_connect (widget, "clicked", - G_CALLBACK (gpm_prefs_checkbox_lock_cb), prefs); - - return widget; -} - /** * gpm_prefs_close_cb: * @widget: The GtkWidget object @@ -534,41 +431,6 @@ gpm_prefs_delete_event_cb (GtkWidget *widget, GdkEvent *event, GpmPrefs *prefs) return FALSE; } -/** - * gpm_conf_mateconf_key_changed_cb: - * - * We might have to do things when the mateconf keys change; do them here. - **/ -static void -gpm_conf_mateconf_key_changed_cb (MateConfClient *client, guint cnxn_id, MateConfEntry *entry, GpmPrefs *prefs) -{ - MateConfValue *value; - gint brightness; - GtkWidget *widget; - gboolean enabled; - - value = mateconf_entry_get_value (entry); - if (value == NULL) - return; - - if (g_strcmp0 (entry->key, GPM_CONF_BACKLIGHT_BRIGHTNESS_AC) == 0) { - widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "hscale_ac_brightness")); - brightness = mateconf_value_get_int (value); - gtk_range_set_value (GTK_RANGE (widget), brightness); - } - - if (g_strcmp0 (entry->key, GPM_CONF_DISKS_SPINDOWN_ENABLE_AC) == 0) { - widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_ac_spindown")); - enabled = mateconf_value_get_bool (value); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), enabled); - - } else if (g_strcmp0 (entry->key, GPM_CONF_DISKS_SPINDOWN_ENABLE_BATT) == 0) { - widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_battery_spindown")); - enabled = mateconf_value_get_bool (value); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), enabled); - } -} - /** setup the notification page */ static void prefs_setup_notification (GpmPrefs *prefs) @@ -582,7 +444,7 @@ prefs_setup_notification (GpmPrefs *prefs) GtkWidget *radiobutton_icon_never; gboolean is_writable; - icon_policy_str = mateconf_client_get_string (prefs->priv->conf, GPM_CONF_UI_ICON_POLICY, NULL); + icon_policy_str = g_settings_get_string (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY); icon_policy = gpm_icon_policy_from_string (icon_policy_str); g_free (icon_policy_str); @@ -597,7 +459,7 @@ prefs_setup_notification (GpmPrefs *prefs) radiobutton_icon_never = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "radiobutton_notification_never")); - is_writable = mateconf_client_key_is_writable (prefs->priv->conf, GPM_CONF_UI_ICON_POLICY, NULL); + is_writable = g_settings_is_writable (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY); gtk_widget_set_sensitive (radiobutton_icon_always, is_writable); gtk_widget_set_sensitive (radiobutton_icon_present, is_writable); gtk_widget_set_sensitive (radiobutton_icon_charge, is_writable); @@ -626,7 +488,7 @@ prefs_setup_notification (GpmPrefs *prefs) g_object_set_data (G_OBJECT (radiobutton_icon_never), "policy", GINT_TO_POINTER (GPM_ICON_POLICY_NEVER)); - /* only connect the callbacks after we set the value, else the conf + /* only connect the callbacks after we set the value, else the settings * keys gets written to (for a split second), and the icon flickers. */ g_signal_connect (radiobutton_icon_always, "clicked", G_CALLBACK (gpm_prefs_icon_radio_cb), prefs); @@ -669,23 +531,33 @@ prefs_setup_ac (GpmPrefs *prefs) -1}; gpm_prefs_setup_time_combo (prefs, "combobox_ac_computer", - GPM_CONF_TIMEOUT_SLEEP_COMPUTER_AC, + GPM_SETTINGS_SLEEP_COMPUTER_AC, computer_times); gpm_prefs_setup_time_combo (prefs, "combobox_ac_display", - GPM_CONF_TIMEOUT_SLEEP_DISPLAY_AC, + GPM_SETTINGS_SLEEP_DISPLAY_AC, display_times); gpm_prefs_setup_action_combo (prefs, "combobox_ac_lid", - GPM_CONF_BUTTON_LID_AC, + GPM_SETTINGS_BUTTON_LID_AC, button_lid_actions); - gpm_prefs_setup_brightness_slider (prefs, "hscale_ac_brightness", - GPM_CONF_BACKLIGHT_BRIGHTNESS_AC); + /* setup brightness slider */ + widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "hscale_ac_brightness")); + g_settings_bind (prefs->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC, + gtk_range_get_adjustment (GTK_RANGE (widget)), "value", + G_SETTINGS_BIND_DEFAULT); + g_signal_connect (G_OBJECT (widget), "format-value", + G_CALLBACK (gpm_prefs_format_percentage_cb), NULL); - gpm_prefs_setup_checkbox (prefs, "checkbutton_ac_display_dim", - GPM_CONF_BACKLIGHT_IDLE_DIM_AC); - gpm_prefs_setup_checkbox (prefs, "checkbutton_ac_spindown", - GPM_CONF_DISKS_SPINDOWN_ENABLE_AC); + /* set up the checkboxes */ + widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_ac_display_dim")); + g_settings_bind (prefs->priv->settings, GPM_SETTINGS_IDLE_DIM_AC, + widget, "active", + G_SETTINGS_BIND_DEFAULT); + widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_ac_spindown")); + g_settings_bind (prefs->priv->settings, GPM_SETTINGS_SPINDOWN_ENABLE_AC, + widget, "active", + G_SETTINGS_BIND_DEFAULT); if (prefs->priv->has_button_lid == FALSE) { widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "hbox_ac_lid")); @@ -752,10 +624,10 @@ prefs_setup_battery (GpmPrefs *prefs) -1}; gpm_prefs_setup_time_combo (prefs, "combobox_battery_computer", - GPM_CONF_TIMEOUT_SLEEP_COMPUTER_BATT, + GPM_SETTINGS_SLEEP_COMPUTER_BATT, computer_times); gpm_prefs_setup_time_combo (prefs, "combobox_battery_display", - GPM_CONF_TIMEOUT_SLEEP_DISPLAY_BATT, + GPM_SETTINGS_SLEEP_DISPLAY_BATT, display_times); if (prefs->priv->has_batteries == FALSE) { @@ -767,19 +639,25 @@ prefs_setup_battery (GpmPrefs *prefs) } gpm_prefs_setup_action_combo (prefs, "combobox_battery_lid", - GPM_CONF_BUTTON_LID_BATT, + GPM_SETTINGS_BUTTON_LID_BATT, button_lid_actions); gpm_prefs_setup_action_combo (prefs, "combobox_battery_critical", - GPM_CONF_ACTIONS_CRITICAL_BATT, + GPM_SETTINGS_ACTION_CRITICAL_BATT, battery_critical_actions); - /* set up the battery reduce checkbox */ - gpm_prefs_setup_checkbox (prefs, "checkbutton_battery_display_reduce", - GPM_CONF_BACKLIGHT_BATTERY_REDUCE); - gpm_prefs_setup_checkbox (prefs, "checkbutton_battery_display_dim", - GPM_CONF_BACKLIGHT_IDLE_DIM_BATT); - gpm_prefs_setup_checkbox (prefs, "checkbutton_battery_spindown", - GPM_CONF_DISKS_SPINDOWN_ENABLE_BATT); + /* set up the checkboxes */ + widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_battery_display_reduce")); + g_settings_bind (prefs->priv->settings, GPM_SETTINGS_BACKLIGHT_BATTERY_REDUCE, + widget, "active", + G_SETTINGS_BIND_DEFAULT); + widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_battery_display_dim")); + g_settings_bind (prefs->priv->settings, GPM_SETTINGS_IDLE_DIM_BATT, + widget, "active", + G_SETTINGS_BIND_DEFAULT); + widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_battery_spindown")); + g_settings_bind (prefs->priv->settings, GPM_SETTINGS_SPINDOWN_ENABLE_BATT, + widget, "active", + G_SETTINGS_BIND_DEFAULT); if (prefs->priv->has_button_lid == FALSE) { widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "hbox_battery_lid")); @@ -830,10 +708,10 @@ prefs_setup_ups (GpmPrefs *prefs) -1}; gpm_prefs_setup_time_combo (prefs, "combobox_ups_computer", - GPM_CONF_TIMEOUT_SLEEP_COMPUTER_UPS, + GPM_SETTINGS_SLEEP_COMPUTER_UPS, computer_times); gpm_prefs_setup_time_combo (prefs, "combobox_ups_display", - GPM_CONF_TIMEOUT_SLEEP_DISPLAY_UPS, + GPM_SETTINGS_SLEEP_DISPLAY_UPS, display_times); if (prefs->priv->has_ups == FALSE) { @@ -845,10 +723,10 @@ prefs_setup_ups (GpmPrefs *prefs) } gpm_prefs_setup_action_combo (prefs, "combobox_ups_low", - GPM_CONF_ACTIONS_LOW_UPS, + GPM_SETTINGS_ACTION_LOW_UPS, ups_low_actions); gpm_prefs_setup_action_combo (prefs, "combobox_ups_critical", - GPM_CONF_ACTIONS_CRITICAL_UPS, + GPM_SETTINGS_ACTION_CRITICAL_UPS, ups_low_actions); } @@ -869,10 +747,10 @@ prefs_setup_general (GpmPrefs *prefs) -1}; gpm_prefs_setup_action_combo (prefs, "combobox_general_power", - GPM_CONF_BUTTON_POWER, + GPM_SETTINGS_BUTTON_POWER, power_button_actions); gpm_prefs_setup_action_combo (prefs, "combobox_general_suspend", - GPM_CONF_BUTTON_SUSPEND, + GPM_SETTINGS_BUTTON_SUSPEND, suspend_button_actions); if (prefs->priv->has_button_suspend == FALSE) { @@ -886,6 +764,7 @@ prefs_setup_general (GpmPrefs *prefs) } } +#ifdef HAVE_MATECONF_DEFAULTS /** * gpm_prefs_set_defaults_cb: **/ @@ -930,6 +809,7 @@ gpm_prefs_set_defaults_cb (GtkWidget *widget, GpmPrefs *prefs) g_object_unref (proxy); } +#endif /** * gpm_prefs_init: @@ -953,16 +833,7 @@ gpm_prefs_init (GpmPrefs *prefs) prefs->priv->client = up_client_new (); prefs->priv->console = egg_console_kit_new (); - prefs->priv->conf = mateconf_client_get_default (); - /* watch mate-power-manager keys */ - mateconf_client_add_dir (prefs->priv->conf, GPM_CONF_DIR, - MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL); - mateconf_client_notify_add (prefs->priv->conf, GPM_CONF_DIR, - (MateConfClientNotifyFunc) gpm_conf_mateconf_key_changed_cb, - prefs, NULL, NULL); - - /* get value of delay in mate-session */ - prefs->priv->idle_delay = mateconf_client_get_int (prefs->priv->conf, GPM_CONF_IDLE_DELAY, NULL); + prefs->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA); /* are we allowed to shutdown? */ prefs->priv->can_shutdown = TRUE; @@ -1070,7 +941,7 @@ gpm_prefs_finalize (GObject *object) prefs = GPM_PREFS (object); prefs->priv = GPM_PREFS_GET_PRIVATE (prefs); - g_object_unref (prefs->priv->conf); + g_object_unref (prefs->priv->settings); g_object_unref (prefs->priv->client); g_object_unref (prefs->priv->console); diff --git a/src/gpm-screensaver.c b/src/gpm-screensaver.c index b4f9ad7..3856b3b 100644 --- a/src/gpm-screensaver.c +++ b/src/gpm-screensaver.c @@ -137,7 +137,7 @@ gpm_screensaver_lock_enabled (GpmScreensaver *screensaver) { gboolean enabled; g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE); - enabled = mateconf_client_get_bool (screensaver->priv->conf, GS_PREF_LOCK_ENABLED, NULL); + enabled = mateconf_client_get_bool (screensaver->priv->conf, GS_CONF_PREF_LOCK_ENABLED, NULL); return enabled; } diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c index 48ce69b..00a7d99 100644 --- a/src/gpm-statistics.c +++ b/src/gpm-statistics.c @@ -49,7 +49,7 @@ gchar *current_device = NULL; static const gchar *history_type; static const gchar *stats_type; static guint history_time; -static MateConfClient *mateconf_client; +static GSettings *settings; static gfloat sigma_smoothing = 0.0f; static UpWakeups *wakeups = NULL; static GtkWidget *graph_history = NULL; @@ -1107,8 +1107,8 @@ gpm_stats_notebook_changed_cb (GtkNotebook *notebook, gpointer page, gint page_n widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_stats")); gpm_stats_set_title (GTK_WINDOW (widget), page_num); - /* save page in mateconf */ - mateconf_client_set_int (mateconf_client, GPM_CONF_INFO_PAGE_NUMBER, page_num, NULL); + /* save page in gsettings */ + g_settings_set_int (settings, GPM_SETTINGS_INFO_PAGE_NUMBER, page_num); if (current_device == NULL) return; @@ -1151,8 +1151,8 @@ gpm_stats_devices_treeview_clicked_cb (GtkTreeSelection *selection, gboolean dat g_free (current_device); gtk_tree_model_get (model, &iter, GPM_DEVICES_COLUMN_ID, ¤t_device, -1); - /* save device in mateconf */ - mateconf_client_set_string (mateconf_client, GPM_CONF_INFO_LAST_DEVICE, current_device, NULL); + /* save device in gsettings */ + g_settings_set_string (settings, GPM_SETTINGS_INFO_LAST_DEVICE, current_device); /* show transaction_id */ egg_debug ("selected row is: %s", current_device); @@ -1326,8 +1326,8 @@ gpm_stats_history_type_combo_changed_cb (GtkWidget *widget, gpointer data) gpm_stats_button_update_ui (); - /* save to mateconf */ - mateconf_client_set_string (mateconf_client, GPM_CONF_INFO_HISTORY_TYPE, history_type, NULL); + /* save to gsettings */ + g_settings_set_string (settings, GPM_SETTINGS_INFO_HISTORY_TYPE, history_type); } /** @@ -1378,8 +1378,8 @@ gpm_stats_type_combo_changed_cb (GtkWidget *widget, gpointer data) gpm_stats_button_update_ui (); - /* save to mateconf */ - mateconf_client_set_string (mateconf_client, GPM_CONF_INFO_STATS_TYPE, stats_type, NULL); + /* save to gsettings */ + g_settings_set_string (settings, GPM_SETTINGS_INFO_STATS_TYPE, stats_type); } /** @@ -1405,8 +1405,8 @@ gpm_stats_range_combo_changed (GtkWidget *widget, gpointer data) else g_assert (FALSE); - /* save to mateconf */ - mateconf_client_set_int (mateconf_client, GPM_CONF_INFO_HISTORY_TIME, history_time, NULL); + /* save to gsettings */ + g_settings_set_int (settings, GPM_SETTINGS_INFO_HISTORY_TIME, history_time); gpm_stats_button_update_ui (); } @@ -1420,7 +1420,7 @@ gpm_stats_smooth_checkbox_history_cb (GtkWidget *widget, gpointer data) { gboolean checked; checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - mateconf_client_set_bool (mateconf_client, GPM_CONF_INFO_HISTORY_GRAPH_SMOOTH, checked, NULL); + g_settings_set_boolean (settings, GPM_SETTINGS_INFO_HISTORY_GRAPH_SMOOTH, checked); gpm_stats_button_update_ui (); } @@ -1433,7 +1433,7 @@ gpm_stats_smooth_checkbox_stats_cb (GtkWidget *widget, gpointer data) { gboolean checked; checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - mateconf_client_set_bool (mateconf_client, GPM_CONF_INFO_STATS_GRAPH_SMOOTH, checked, NULL); + g_settings_set_boolean (settings, GPM_SETTINGS_INFO_STATS_GRAPH_SMOOTH, checked); gpm_stats_button_update_ui (); } @@ -1446,7 +1446,7 @@ gpm_stats_points_checkbox_history_cb (GtkWidget *widget, gpointer data) { gboolean checked; checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - mateconf_client_set_bool (mateconf_client, GPM_CONF_INFO_HISTORY_GRAPH_POINTS, checked, NULL); + g_settings_set_boolean (settings, GPM_SETTINGS_INFO_HISTORY_GRAPH_POINTS, checked); gpm_stats_button_update_ui (); } @@ -1459,7 +1459,7 @@ gpm_stats_points_checkbox_stats_cb (GtkWidget *widget, gpointer data) { gboolean checked; checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - mateconf_client_set_bool (mateconf_client, GPM_CONF_INFO_STATS_GRAPH_POINTS, checked, NULL); + g_settings_set_boolean (settings, GPM_SETTINGS_INFO_STATS_GRAPH_POINTS, checked); gpm_stats_button_update_ui (); } @@ -1592,8 +1592,8 @@ main (int argc, char *argv[]) gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), GPM_DATA G_DIR_SEPARATOR_S "icons"); - /* get data from mateconf */ - mateconf_client = mateconf_client_get_default (); + /* get data from the settings */ + settings = g_settings_new (GPM_SETTINGS_SCHEMA); /* get UI */ builder = gtk_builder_new (); @@ -1639,31 +1639,31 @@ main (int argc, char *argv[]) G_CALLBACK (gpm_stats_button_help_cb), NULL); widget = GTK_WIDGET (gtk_builder_get_object (builder, "checkbutton_smooth_history")); - checked = mateconf_client_get_bool (mateconf_client, GPM_CONF_INFO_HISTORY_GRAPH_SMOOTH, NULL); + checked = g_settings_get_boolean (settings, GPM_SETTINGS_INFO_HISTORY_GRAPH_SMOOTH); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), checked); g_signal_connect (widget, "clicked", G_CALLBACK (gpm_stats_smooth_checkbox_history_cb), NULL); widget = GTK_WIDGET (gtk_builder_get_object (builder, "checkbutton_smooth_stats")); - checked = mateconf_client_get_bool (mateconf_client, GPM_CONF_INFO_STATS_GRAPH_SMOOTH, NULL); + checked = g_settings_get_boolean (settings, GPM_SETTINGS_INFO_STATS_GRAPH_SMOOTH); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), checked); g_signal_connect (widget, "clicked", G_CALLBACK (gpm_stats_smooth_checkbox_stats_cb), NULL); widget = GTK_WIDGET (gtk_builder_get_object (builder, "checkbutton_points_history")); - checked = mateconf_client_get_bool (mateconf_client, GPM_CONF_INFO_HISTORY_GRAPH_POINTS, NULL); + checked = g_settings_get_boolean (settings, GPM_SETTINGS_INFO_HISTORY_GRAPH_POINTS); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), checked); g_signal_connect (widget, "clicked", G_CALLBACK (gpm_stats_points_checkbox_history_cb), NULL); widget = GTK_WIDGET (gtk_builder_get_object (builder, "checkbutton_points_stats")); - checked = mateconf_client_get_bool (mateconf_client, GPM_CONF_INFO_STATS_GRAPH_POINTS, NULL); + checked = g_settings_get_boolean (settings, GPM_SETTINGS_INFO_STATS_GRAPH_POINTS); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), checked); g_signal_connect (widget, "clicked", G_CALLBACK (gpm_stats_points_checkbox_stats_cb), NULL); widget = GTK_WIDGET (gtk_builder_get_object (builder, "notebook1")); - page = mateconf_client_get_int (mateconf_client, GPM_CONF_INFO_PAGE_NUMBER, NULL); + page = g_settings_get_int (settings, GPM_SETTINGS_INFO_PAGE_NUMBER); gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), page); g_signal_connect (widget, "switch-page", G_CALLBACK (gpm_stats_notebook_changed_cb), NULL); @@ -1705,14 +1705,14 @@ main (int argc, char *argv[]) gpm_stats_add_wakeups_columns (GTK_TREE_VIEW (widget)); gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget)); /* show */ - history_type = mateconf_client_get_string (mateconf_client, GPM_CONF_INFO_HISTORY_TYPE, NULL); - history_time = mateconf_client_get_int (mateconf_client, GPM_CONF_INFO_HISTORY_TIME, NULL); + history_type = g_settings_get_string (settings, GPM_SETTINGS_INFO_HISTORY_TYPE); + history_time = g_settings_get_int (settings, GPM_SETTINGS_INFO_HISTORY_TIME); if (history_type == NULL) history_type = GPM_HISTORY_CHARGE_VALUE; if (history_time == 0) history_time = GPM_HISTORY_HOUR_VALUE; - stats_type = mateconf_client_get_string (mateconf_client, GPM_CONF_INFO_STATS_TYPE, NULL); + stats_type = g_settings_get_string (settings, GPM_SETTINGS_INFO_STATS_TYPE); if (stats_type == NULL) stats_type = GPM_STATS_CHARGE_DATA_VALUE; @@ -1821,7 +1821,7 @@ main (int argc, char *argv[]) } if (last_device == NULL) - last_device = mateconf_client_get_string (mateconf_client, GPM_CONF_INFO_LAST_DEVICE, NULL); + last_device = g_settings_get_string (settings, GPM_SETTINGS_INFO_LAST_DEVICE); /* has capability to measure wakeups */ ret = up_wakeups_get_has_capability (wakeups); @@ -1853,7 +1853,7 @@ main (int argc, char *argv[]) gtk_main (); out: - g_object_unref (mateconf_client); + g_object_unref (settings); g_object_unref (client); g_object_unref (wakeups); g_object_unref (builder); diff --git a/src/gpm-tray-icon.c b/src/gpm-tray-icon.c index 8edddce..f2c26f7 100644 --- a/src/gpm-tray-icon.c +++ b/src/gpm-tray-icon.c @@ -38,7 +38,6 @@ #include #include -#include #include #include "egg-debug.h" @@ -55,7 +54,7 @@ static void gpm_tray_icon_finalize (GObject *object); struct GpmTrayIconPrivate { - MateConfClient *conf; + GSettings *settings; GpmEngine *engine; GtkStatusIcon *status_icon; gboolean show_actions; @@ -339,22 +338,17 @@ gpm_tray_icon_activate_cb (GtkStatusIcon *status_icon, GpmTrayIcon *icon) } /** - * gpm_conf_mateconf_key_changed_cb: + * gpm_tray_icon_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 settings change; do them here. **/ static void -gpm_conf_mateconf_key_changed_cb (MateConfClient *client, guint cnxn_id, MateConfEntry *entry, GpmTrayIcon *icon) +gpm_tray_icon_settings_changed_cb (GSettings *settings, const gchar *key, GpmTrayIcon *icon) { - MateConfValue *value; gboolean allowed_in_menu; - value = mateconf_entry_get_value (entry); - if (value == NULL) - return; - - if (strcmp (entry->key, GPM_CONF_UI_SHOW_ACTIONS) == 0) { - allowed_in_menu = mateconf_value_get_bool (value); + if (g_strcmp0 (key, GPM_SETTINGS_SHOW_ACTIONS) == 0) { + allowed_in_menu = g_settings_get_boolean (settings, key); gpm_tray_icon_enable_actions (icon, allowed_in_menu); } } @@ -373,13 +367,9 @@ gpm_tray_icon_init (GpmTrayIcon *icon) icon->priv->engine = gpm_engine_new (); - icon->priv->conf = mateconf_client_get_default (); - /* watch mate-power-manager keys */ - mateconf_client_add_dir (icon->priv->conf, GPM_CONF_DIR, - MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL); - mateconf_client_notify_add (icon->priv->conf, GPM_CONF_DIR, - (MateConfClientNotifyFunc) gpm_conf_mateconf_key_changed_cb, - icon, NULL, NULL); + icon->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA); + g_signal_connect (icon->priv->settings, "changed", + G_CALLBACK (gpm_tray_icon_settings_changed_cb), icon); icon->priv->status_icon = gtk_status_icon_new (); g_signal_connect_object (G_OBJECT (icon->priv->status_icon), @@ -391,7 +381,7 @@ gpm_tray_icon_init (GpmTrayIcon *icon) G_CALLBACK (gpm_tray_icon_activate_cb), icon, 0); - allowed_in_menu = mateconf_client_get_bool (icon->priv->conf, GPM_CONF_UI_SHOW_ACTIONS, NULL); + allowed_in_menu = g_settings_get_boolean (icon->priv->settings, GPM_SETTINGS_SHOW_ACTIONS); gpm_tray_icon_enable_actions (icon, allowed_in_menu); } -- cgit v1.2.1 From 060a4507145425c02c6aa0ef810138c04d38f5a9 Mon Sep 17 00:00:00 2001 From: Brent Hull Date: Tue, 30 Oct 2012 15:55:35 -0400 Subject: Use gsettings enums (partially from GNOME) --- data/org.mate.power-manager.gschema.xml | 73 ++++++++++++++++++---------- src/gpm-backlight.c | 11 ++--- src/gpm-common.c | 84 --------------------------------- src/gpm-common.h | 4 -- src/gpm-dpms.c | 47 ------------------ src/gpm-dpms.h | 2 - src/gpm-engine.c | 10 +--- src/gpm-manager.c | 31 ++++-------- src/gpm-prefs-core.c | 21 ++------- 9 files changed, 64 insertions(+), 219 deletions(-) diff --git a/data/org.mate.power-manager.gschema.xml b/data/org.mate.power-manager.gschema.xml index 0d930e5..daa78f3 100644 --- a/data/org.mate.power-manager.gschema.xml +++ b/data/org.mate.power-manager.gschema.xml @@ -1,34 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + - + 'hibernate' Whether to hibernate, suspend or do nothing when inactive - The type of sleeping that should be performed when the computer is inactive. Possible values are "hibernate", "suspend" and "nothing". + The type of sleeping that should be performed when the computer is inactive. - + 'hibernate' Battery critical low action - The action to take when the battery is critically low. Possible values are "hibernate", "suspend", "shutdown" and "nothing". + The action to take when the battery is critically low. true If the battery event should occur when the lid is shut and the power disconnected If the battery lid close event should occur (for example 'Suspend when lid closed on battery') when the lid is previously shut and the AC power disconnected at a later time. - + 'suspend' Whether to hibernate, suspend or do nothing when inactive - The type of sleeping that should be performed when the computer is inactive. Possible values are "hibernate", "suspend" and "nothing". + The type of sleeping that should be performed when the computer is inactive. - + 'shutdown' UPS critical low action - The action to take when the UPS is critically low. Possible values are "hibernate", "suspend", "shutdown" and "nothing". + The action to take when the UPS is critically low. - + 'hibernate' UPS low power action - The action to take when the UPS is low. Possible values are "hibernate", "suspend", "shutdown" and "nothing". + The action to take when the UPS is low. true @@ -65,45 +86,45 @@ Dim the screen after a period of inactivity when on AC power If the screen should be dimmed to save power when the computer is idle when on AC power. - + 'off' Method used to blank screen on AC - The DPMS method used to blank the screen when on AC power. Possible values are "standby", "suspend" and "off". + The DPMS method used to blank the screen when on AC power. - + 'off' Method used to blank screen on battery - The DPMS method used to blank the screen when on battery power. Possible values are "standby", "suspend" and "off". + The DPMS method used to blank the screen when on battery power. 100.0 LCD brightness when on AC The brightness of the display when on AC power. Possible values are between 0.0 and 100.0. - + 'suspend' Suspend button action - The action to take when the system suspend button is pressed. Possible values are "suspend", "hibernate", "interactive", "shutdown" and "nothing". + The action to take when the system suspend button is pressed. - + 'hibernate' Hibernate button action - The action to take when the system hibernate button is pressed. Possible values are "suspend", "hibernate", "interactive", "shutdown" and "nothing". + The action to take when the system hibernate button is pressed. - + 'interactive' Power button action - The action to take when the system power button is pressed. Possible values are "suspend", "hibernate", "interactive", "shutdown" and "nothing". + The action to take when the system power button is pressed. - + 'suspend' Laptop lid close action on battery - The action to take when the laptop lid is closed and the laptop is on battery power. Possible values are "suspend", "hibernate", "blank", and "nothing". + The action to take when the laptop lid is closed and the laptop is on battery power. - + 'suspend' Laptop lid close action when on AC - The action to take when the laptop lid is closed and the laptop is on AC power. Possible values are "suspend", "hibernate", "blank" and "nothing". + The action to take when the laptop lid is closed and the laptop is on AC power. 3 @@ -329,10 +350,10 @@ true If preferences and statistics items should be shown in the context menu - + 'present' When to show the notification icon - Display options for the notification icon. Valid options are "never", "low", "critical", "charge", and "present". + Display options for the notification icon. diff --git a/src/gpm-backlight.c b/src/gpm-backlight.c index 9f6b148..573778a 100644 --- a/src/gpm-backlight.c +++ b/src/gpm-backlight.c @@ -545,7 +545,6 @@ idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight) gboolean ret; GError *error = NULL; gboolean on_battery; - gchar *dpms_method; GpmDpmsMode dpms_mode; /* don't dim or undim the screen when the lid is closed */ @@ -594,16 +593,13 @@ idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight) "on-battery", &on_battery, NULL); if (!on_battery) - dpms_method = g_settings_get_string (backlight->priv->settings, GPM_SETTINGS_DPMS_METHOD_AC); + dpms_mode = g_settings_get_enum (backlight->priv->settings, GPM_SETTINGS_DPMS_METHOD_AC); else - dpms_method = g_settings_get_string (backlight->priv->settings, GPM_SETTINGS_DPMS_METHOD_BATT); - - /* convert the string types to standard types */ - dpms_mode = gpm_dpms_mode_from_string (dpms_method); + dpms_mode = g_settings_get_enum (backlight->priv->settings, GPM_SETTINGS_DPMS_METHOD_BATT); /* check if method is valid */ if (dpms_mode == GPM_DPMS_MODE_UNKNOWN || dpms_mode == GPM_DPMS_MODE_ON) { - egg_warning ("BACKLIGHT method %s unknown. Using OFF.", dpms_method); + egg_warning ("BACKLIGHT method %i unknown. Using OFF.", dpms_mode); dpms_mode = GPM_DPMS_MODE_OFF; } @@ -614,7 +610,6 @@ idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight) g_error_free (error); } - g_free (dpms_method); } } diff --git a/src/gpm-common.c b/src/gpm-common.c index 0d0e536..861837a 100644 --- a/src/gpm-common.c +++ b/src/gpm-common.c @@ -78,90 +78,6 @@ gpm_get_timestring (guint time_secs) return timestring; } -/** - * gpm_icon_policy_from_string: - **/ -GpmIconPolicy -gpm_icon_policy_from_string (const gchar *policy) -{ - if (policy == NULL) - return GPM_ICON_POLICY_NEVER; - if (g_strcmp0 (policy, "always") == 0) - return GPM_ICON_POLICY_ALWAYS; - if (g_strcmp0 (policy, "present") == 0) - return GPM_ICON_POLICY_PRESENT; - if (g_strcmp0 (policy, "charge") == 0) - return GPM_ICON_POLICY_CHARGE; - if (g_strcmp0 (policy, "low") == 0) - return GPM_ICON_POLICY_LOW; - if (g_strcmp0 (policy, "critical") == 0) - return GPM_ICON_POLICY_CRITICAL; - if (g_strcmp0 (policy, "never") == 0) - return GPM_ICON_POLICY_NEVER; - return GPM_ICON_POLICY_NEVER; -} - -/** - * gpm_icon_policy_to_string: - **/ -const gchar * -gpm_icon_policy_to_string (GpmIconPolicy policy) -{ - if (policy == GPM_ICON_POLICY_ALWAYS) - return "always"; - if (policy == GPM_ICON_POLICY_PRESENT) - return "present"; - if (policy == GPM_ICON_POLICY_CHARGE) - return "charge"; - if (policy == GPM_ICON_POLICY_LOW) - return "low"; - if (policy == GPM_ICON_POLICY_CRITICAL) - return "critical"; - if (policy == GPM_ICON_POLICY_NEVER) - return "never"; - return "never"; -} - -/** - * gpm_action_policy_from_string: - **/ -GpmActionPolicy -gpm_action_policy_from_string (const gchar *policy) -{ - if (policy == NULL) - return GPM_ACTION_POLICY_NOTHING; - if (g_strcmp0 (policy, "blank") == 0) - return GPM_ACTION_POLICY_BLANK; - if (g_strcmp0 (policy, "shutdown") == 0) - return GPM_ACTION_POLICY_SHUTDOWN; - if (g_strcmp0 (policy, "suspend") == 0) - return GPM_ACTION_POLICY_SUSPEND; - if (g_strcmp0 (policy, "hibernate") == 0) - return GPM_ACTION_POLICY_HIBERNATE; - if (g_strcmp0 (policy, "interactive") == 0) - return GPM_ACTION_POLICY_INTERACTIVE; - return GPM_ACTION_POLICY_NOTHING; -} - -/** - * gpm_action_policy_to_string: - **/ -const gchar * -gpm_action_policy_to_string (GpmActionPolicy policy) -{ - if (policy == GPM_ACTION_POLICY_BLANK) - return "blank"; - if (policy == GPM_ACTION_POLICY_SHUTDOWN) - return "shutdown"; - if (policy == GPM_ACTION_POLICY_SUSPEND) - return "suspend"; - if (policy == GPM_ACTION_POLICY_HIBERNATE) - return "hibernate"; - if (policy == GPM_ACTION_POLICY_INTERACTIVE) - return "interactive"; - return "nothing"; -} - /** * gpm_help_display: * @link_id: Subsection of mate-power-manager help section diff --git a/src/gpm-common.h b/src/gpm-common.h index 96a06a4..ee05036 100644 --- a/src/gpm-common.h +++ b/src/gpm-common.h @@ -157,10 +157,6 @@ typedef enum { } GpmActionPolicy; gchar *gpm_get_timestring (guint time); -GpmIconPolicy gpm_icon_policy_from_string (const gchar *policy); -const gchar *gpm_icon_policy_to_string (GpmIconPolicy policy); -GpmActionPolicy gpm_action_policy_from_string (const gchar *policy); -const gchar *gpm_action_policy_to_string (GpmActionPolicy policy); void gpm_help_display (const gchar *link_id); #ifdef EGG_TEST void gpm_common_test (gpointer data); diff --git a/src/gpm-dpms.c b/src/gpm-dpms.c index 13928f9..8eaf704 100644 --- a/src/gpm-dpms.c +++ b/src/gpm-dpms.c @@ -189,53 +189,6 @@ gpm_dpms_x11_set_mode (GpmDpms *dpms, GpmDpmsMode mode, GError **error) return TRUE; } -/** - * gpm_dpms_mode_from_string: - **/ -GpmDpmsMode -gpm_dpms_mode_from_string (const gchar *str) -{ - if (str == NULL) - return GPM_DPMS_MODE_UNKNOWN; - if (strcmp (str, "on") == 0) - return GPM_DPMS_MODE_ON; - if (strcmp (str, "standby") == 0) - return GPM_DPMS_MODE_STANDBY; - if (strcmp (str, "suspend") == 0) - return GPM_DPMS_MODE_SUSPEND; - if (strcmp (str, "off") == 0) - return GPM_DPMS_MODE_OFF; - return GPM_DPMS_MODE_UNKNOWN; -} - -/** - * gpm_dpms_mode_to_string: - **/ -const gchar * -gpm_dpms_mode_to_string (GpmDpmsMode mode) -{ - const gchar *str = NULL; - - switch (mode) { - case GPM_DPMS_MODE_ON: - str = "on"; - break; - case GPM_DPMS_MODE_STANDBY: - str = "standby"; - break; - case GPM_DPMS_MODE_SUSPEND: - str = "suspend"; - break; - case GPM_DPMS_MODE_OFF: - str = "off"; - break; - default: - str = NULL; - break; - } - return str; -} - /** * gpm_dpms_set_mode: **/ diff --git a/src/gpm-dpms.h b/src/gpm-dpms.h index 95cd226..b6218fc 100644 --- a/src/gpm-dpms.h +++ b/src/gpm-dpms.h @@ -71,8 +71,6 @@ gboolean gpm_dpms_get_mode (GpmDpms *dpms, gboolean gpm_dpms_set_mode (GpmDpms *dpms, GpmDpmsMode mode, GError **error); -const gchar *gpm_dpms_mode_to_string (GpmDpmsMode mode); -GpmDpmsMode gpm_dpms_mode_from_string (const gchar *mode); void gpm_dpms_test (gpointer data); G_END_DECLS diff --git a/src/gpm-engine.c b/src/gpm-engine.c index b006c32..0f9d0c1 100644 --- a/src/gpm-engine.c +++ b/src/gpm-engine.c @@ -513,7 +513,6 @@ gpm_engine_recalculate_state (GpmEngine *engine) static void gpm_engine_settings_key_changed_cb (GSettings *settings, const gchar *key, GpmEngine *engine) { - gchar *icon_policy; if (g_strcmp0 (key, GPM_SETTINGS_USE_TIME_POLICY) == 0) { engine->priv->use_time_primary = g_settings_get_boolean (settings, key); @@ -521,9 +520,7 @@ gpm_engine_settings_key_changed_cb (GSettings *settings, const gchar *key, GpmEn } else if (g_strcmp0 (key, GPM_SETTINGS_ICON_POLICY) == 0) { /* do we want to display the icon in the tray */ - icon_policy = g_settings_get_string (settings, key); - engine->priv->icon_policy = gpm_icon_policy_from_string (icon_policy); - g_free (icon_policy); + engine->priv->icon_policy = g_settings_get_enum (settings, key); /* perhaps change icon */ gpm_engine_recalculate_state_icon (engine); @@ -1045,7 +1042,6 @@ phone_device_refresh_cb (GpmPhone *phone, guint idx, GpmEngine *engine) static void gpm_engine_init (GpmEngine *engine) { - gchar *icon_policy; engine->priv = GPM_ENGINE_GET_PRIVATE (engine); @@ -1084,9 +1080,7 @@ gpm_engine_init (GpmEngine *engine) engine->priv->previous_summary = NULL; /* do we want to display the icon in the tray */ - icon_policy = g_settings_get_string (engine->priv->settings, GPM_SETTINGS_ICON_POLICY); - engine->priv->icon_policy = gpm_icon_policy_from_string (icon_policy); - g_free (icon_policy); + engine->priv->icon_policy = g_settings_get_enum (engine->priv->settings, GPM_SETTINGS_ICON_POLICY); /* get percentage policy */ engine->priv->low_percentage = g_settings_get_int (engine->priv->settings, GPM_SETTINGS_PERCENTAGE_LOW); diff --git a/src/gpm-manager.c b/src/gpm-manager.c index 6014f84..b351b6f 100644 --- a/src/gpm-manager.c +++ b/src/gpm-manager.c @@ -667,16 +667,14 @@ gpm_manager_action_hibernate (GpmManager *manager, const gchar *reason) 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 = g_settings_get_string (manager->priv->settings, policy_key); - 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); @@ -700,10 +698,9 @@ 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; } @@ -717,16 +714,14 @@ gpm_manager_perform_policy (GpmManager *manager, const gchar *policy_key, const 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 = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_ACTION_SLEEP_TYPE_AC); + policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_SLEEP_TYPE_AC); else - action = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_ACTION_SLEEP_TYPE_BATT); - 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"); @@ -759,7 +754,6 @@ gpm_manager_idle_do_sleep (GpmManager *manager) } } } - g_free (action); } /** @@ -1553,7 +1547,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; @@ -1589,8 +1582,7 @@ gpm_manager_engine_charge_critical_cb (GpmEngine *engine, UpDevice *device, GpmM } /* we have to do different warnings depending on the policy */ - action = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_BATT); - 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) { @@ -1610,7 +1602,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; @@ -1720,7 +1711,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; @@ -1745,8 +1735,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 = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_BATT); - 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) { @@ -1773,8 +1762,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); @@ -1783,8 +1770,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 = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_UPS); - 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) { @@ -1807,7 +1793,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 */ diff --git a/src/gpm-prefs-core.c b/src/gpm-prefs-core.c index 3f23c87..790427b 100644 --- a/src/gpm-prefs-core.c +++ b/src/gpm-prefs-core.c @@ -135,13 +135,10 @@ gpm_prefs_help_cb (GtkWidget *widget, GpmPrefs *prefs) static void gpm_prefs_icon_radio_cb (GtkWidget *widget, GpmPrefs *prefs) { - const gchar *str; gint policy; policy = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "policy")); - str = gpm_icon_policy_to_string (policy); - egg_debug ("Changing %s to %s", GPM_SETTINGS_ICON_POLICY, str); - g_settings_set_string (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY, str); + g_settings_set_enum (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY, policy); } /** @@ -164,7 +161,6 @@ gpm_prefs_action_combo_changed_cb (GtkWidget *widget, GpmPrefs *prefs) GpmActionPolicy policy; const GpmActionPolicy *actions; const gchar *gpm_pref_key; - const gchar *action; guint active; actions = (const GpmActionPolicy *) g_object_get_data (G_OBJECT (widget), "actions"); @@ -172,9 +168,7 @@ gpm_prefs_action_combo_changed_cb (GtkWidget *widget, GpmPrefs *prefs) active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)); policy = actions[active]; - action = gpm_action_policy_to_string (policy); - egg_debug ("Changing %s to %s", gpm_pref_key, action); - g_settings_set_string (prefs->priv->settings, gpm_pref_key, action); + g_settings_set_enum (prefs->priv->settings, gpm_pref_key, policy); } /** @@ -242,7 +236,6 @@ static void gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name, const gchar *gpm_pref_key, const GpmActionPolicy *actions) { - gchar *value_txt; gint i; gboolean is_writable; GtkWidget *widget; @@ -254,9 +247,8 @@ gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name, widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, widget_name)); gpm_prefs_set_combo_simple_text (widget); - value_txt = g_settings_get_string (prefs->priv->settings, gpm_pref_key); + value = g_settings_get_enum (prefs->priv->settings, gpm_pref_key); is_writable = g_settings_is_writable (prefs->priv->settings, gpm_pref_key); - value = gpm_action_policy_from_string (value_txt); gtk_widget_set_sensitive (widget, is_writable); @@ -340,13 +332,11 @@ gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name, /* set what we have in the settings */ for (i=0; actions_added[i] != -1; i++) { policy = actions_added[i]; - egg_debug ("added: %s", gpm_action_policy_to_string (policy)); if (value == policy) gtk_combo_box_set_active (GTK_COMBO_BOX (widget), i); } g_ptr_array_unref (array); - g_free (value_txt); } /** @@ -435,7 +425,6 @@ gpm_prefs_delete_event_cb (GtkWidget *widget, GdkEvent *event, GpmPrefs *prefs) static void prefs_setup_notification (GpmPrefs *prefs) { - gchar *icon_policy_str; gint icon_policy; GtkWidget *radiobutton_icon_always; GtkWidget *radiobutton_icon_present; @@ -444,9 +433,7 @@ prefs_setup_notification (GpmPrefs *prefs) GtkWidget *radiobutton_icon_never; gboolean is_writable; - icon_policy_str = g_settings_get_string (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY); - icon_policy = gpm_icon_policy_from_string (icon_policy_str); - g_free (icon_policy_str); + icon_policy = g_settings_get_enum (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY); radiobutton_icon_always = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "radiobutton_notification_always")); -- cgit v1.2.1 From 6161e23866e73161dc0943c8ff24039edf8c531e Mon Sep 17 00:00:00 2001 From: Brent Hull Date: Tue, 30 Oct 2012 16:33:38 -0400 Subject: Enable translations for gsettings schema --- data/Makefile.am | 8 +- data/org.mate.power-manager.gschema.xml | 359 ----------------------------- data/org.mate.power-manager.gschema.xml.in | 359 +++++++++++++++++++++++++++++ po/POTFILES.in | 2 +- 4 files changed, 366 insertions(+), 362 deletions(-) delete mode 100644 data/org.mate.power-manager.gschema.xml create mode 100644 data/org.mate.power-manager.gschema.xml.in diff --git a/data/Makefile.am b/data/Makefile.am index 0f0d775..06aab6e 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -20,7 +20,9 @@ $(service_DATA): $(service_in_files) Makefile @sed -e "s|\@servicedir\@|$(bindir)|" $< > $@ @GSETTINGS_RULES@ -gsettings_SCHEMAS = org.mate.power-manager.gschema.xml +@INTLTOOL_XML_NOMERGE_RULE@ +gsettings_schemas_in_files = org.mate.power-manager.gschema.xml.in +gsettings_SCHEMAS = $(gsettings_schemas_in_files:.gschema.xml.in=.gschema.xml) pkgdata_DATA = \ gpm-statistics.ui \ @@ -35,6 +37,7 @@ EXTRA_DIST = \ $(service_in_files) \ $(autostart_in_files) \ $(desktop_in_files) \ + $(gsettings_schemas_in_files) \ $(pkgdata_DATA) clean-local : @@ -44,4 +47,5 @@ DISTCLEANFILES = \ mate-power-manager.desktop \ mate-power-preferences.desktop \ mate-power-statistics.desktop \ - mate-power-manager.service + mate-power-manager.service \ + org.mate.power-manager.gschema.xml diff --git a/data/org.mate.power-manager.gschema.xml b/data/org.mate.power-manager.gschema.xml deleted file mode 100644 index daa78f3..0000000 --- a/data/org.mate.power-manager.gschema.xml +++ /dev/null @@ -1,359 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - 'hibernate' - Whether to hibernate, suspend or do nothing when inactive - The type of sleeping that should be performed when the computer is inactive. - - - 'hibernate' - Battery critical low action - The action to take when the battery is critically low. - - - true - If the battery event should occur when the lid is shut and the power disconnected - If the battery lid close event should occur (for example 'Suspend when lid closed on battery') when the lid is previously shut and the AC power disconnected at a later time. - - - 'suspend' - Whether to hibernate, suspend or do nothing when inactive - The type of sleeping that should be performed when the computer is inactive. - - - 'shutdown' - UPS critical low action - The action to take when the UPS is critically low. - - - 'hibernate' - UPS low power action - The action to take when the UPS is low. - - - true - Allow backlight brightness adjustment - If the screen brightness should be changed when switching between AC and battery power. - - - true - Reduce the backlight brightness when on battery power - If the screen should be reduced in brightness when the computer is on battery power. - - - 30 - The brightness of the screen when idle - This is the laptop panel screen brightness used when the session is idle. Only valid when use-time-for-policy is true. - - - true - Dim the screen after a period of inactivity when on battery power - If the screen should be dimmed to save power when the computer is idle when on battery power. - - - 10 - The default amount of time to dim the screen after idle - The default amount of time to dim the screen after idle. - - - 50 - LCD dimming amount when on battery - The amount to dim the brightness of the display when on battery power. Possible values are between 0 and 100. - - - false - Dim the screen after a period of inactivity when on AC power - If the screen should be dimmed to save power when the computer is idle when on AC power. - - - 'off' - Method used to blank screen on AC - The DPMS method used to blank the screen when on AC power. - - - 'off' - Method used to blank screen on battery - The DPMS method used to blank the screen when on battery power. - - - 100.0 - LCD brightness when on AC - The brightness of the display when on AC power. Possible values are between 0.0 and 100.0. - - - 'suspend' - Suspend button action - The action to take when the system suspend button is pressed. - - - 'hibernate' - Hibernate button action - The action to take when the system hibernate button is pressed. - - - 'interactive' - Power button action - The action to take when the system power button is pressed. - - - 'suspend' - Laptop lid close action on battery - The action to take when the laptop lid is closed and the laptop is on battery power. - - - 'suspend' - Laptop lid close action when on AC - The action to take when the laptop lid is closed and the laptop is on AC power. - - - 3 - The default configuration version. - The version of the installed version of the schema. Do not edit this value, it is used so that configure changes between versions can be detected. - - - true - If the learnt profile should be used to calculate the time remaining - If the learnt profile should be used to calculate the time remaining. Only turn this off for debugging. - - - true - Whether to use time-based notifications - If time based notifications should be used. If set to false, then the percentage change is used instead, which may fix a broken ACPI BIOS. - - - false - Check CPU load before sleeping - If the CPU load should be checked before doing the idle action. - - - false - Whether NetworkManager should be connected and disconnected on sleep. - Whether NetworkManager should disconnect before suspending or hibernating and connect on resume. - - - true - Use mate-screensaver lock setting - Whether to use the screen lock setting of mate-screensaver to decide if the screen is locked after a hibernate, suspend or blank screen. - - - true - Lock screen when blanked - Whether the screen is locked when the screen is turned off. Only used if lock-use-screensaver is false. - - - true - Lock screen on suspend - Whether the screen is locked when the computer wakes up from a suspend. Only used if lock-use-screensaver is false. - - - true - Lock screen on hibernate - Whether the screen is locked when the computer wakes up from a hibernate. Only used if lock-use-screensaver is false. - - - false - Lock MATE keyring on sleep - Whether the MATE keyring is locked before the computer enters suspend. This means the keyring will have to be unlocked on resume. - - - true - Lock MATE keyring on sleep - Whether the MATE keyring is locked before the computer enters hibernate. This means the keyring will have to be unlocked on resume. - - - false - If the low-power mode should be enabled when on AC - If the system low-power mode should be enabled when on AC power. - - - true - If the low-power mode should be enabled when on battery - If the system low-power mode should be enabled when on laptop battery power. - - - 600 - Seconds of inactivity to spin down when on AC - The number of seconds of inactivity to spin down the disks when on AC power. - - - 60 - Seconds of inactivity to spin down when on battery - The number of seconds of inactivity to spin down the disks when on battery power. - - - true - If we should show the recalled battery warning for a broken battery - If we should show the recalled battery warning for a broken battery. Set this to false only if you know your battery is okay. - - - true - If we should show the low capacity warning for a broken battery - If we should show the low capacity warning for a broken battery. - - - true - Notify when AC adapter is disconnected - If the user should be notified when the AC adapter is disconnected. - - - false - Notify when fully charged - If a notification message should be displayed when the battery is fully charged. - - - true - Notify on a sleep failure - If a notification message should be displayed after suspend or hibernate failed. - - - '' - The URI to show to the user on sleep failure - When sleep fails we can show the user a button to help fix the situation. Leave this blank if the button should not be shown. - - - true - Notify on a low power - If a notification message should be displayed when the battery is getting low. - - - true - Whether we should show the history data points - Whether we should show the history data points in the statistics window. - - - true - Whether we should smooth the history data - Whether we should smooth the history data in the graph. - - - 'power' - The default graph type to show for history - The default graph type to show in the history window. - - - 21600 - The maximum time displayed for history - The maximum duration of time displayed on the x-axis of the history graph. - - - true - Whether we should show the stats data points - Whether we should show the stats data points in the statistics window. - - - true - Whether we should smooth the stats data - Whether we should smooth the stats data in the graph. - - - 'power' - The default graph type to show for stats - The default graph type to show in the stats window. - - - 0 - The index of the page number to show by default - The index of the page number to show by default which is used to return focus to the correct page. - - - '' - The ID of the last device selected - The identifier of the last device which is used to return focus to the correct device. - - - 10 - Percentage considered low - The percentage of the battery when it is considered low. Only valid when use-time-for-policy is false. - - - 3 - Percentage considered critical - The percentage of the battery when it is considered critical. Only valid when use-time-for-policy is false. - - - 2 - Percentage action is taken - The percentage of the battery when the critical action is performed. Only valid when use-time-for-policy is false. - - - 1200 - The time remaining when low - The time remaining in seconds of the battery when it is considered low. Only valid when use-time-for-policy is true. - - - 300 - The time remaining when critical - The time remaining in seconds of the battery when it is considered critical. Only valid when use-time-for-policy is true. - - - 120 - The time remaining when action is taken - The time remaining in seconds of the battery when critical action is taken. Only valid when use-time-for-policy is true. - - - 0 - Sleep timeout computer when on battery - The amount of time in seconds the computer on battery power needs to be inactive before it goes to sleep. - - - 0 - Sleep timeout computer when on AC - The amount of time in seconds the computer on AC power needs to be inactive before it goes to sleep. - - - 0 - Sleep timeout computer when on UPS - The amount of time in seconds the computer on UPS power needs to be inactive before it goes to sleep. - - - 1800 - Sleep timeout display when on AC - The amount of time in seconds before the display goes to sleep when the computer is on AC power. - - - 600 - Sleep timeout display when on battery - The amount of time in seconds the computer on battery power needs to be inactive before the display goes to sleep. - - - 600 - Sleep timeout display when on UPS - The amount of time in seconds the computer on UPS power needs to be inactive before the display goes to sleep. - - - true - If sounds should be used - If sounds should be used when the power is critically low, or inhibit requests have stopped the policy action. - - - true - If preferences and statistics items should be shown in the context menu - - - 'present' - When to show the notification icon - Display options for the notification icon. - - - diff --git a/data/org.mate.power-manager.gschema.xml.in b/data/org.mate.power-manager.gschema.xml.in new file mode 100644 index 0000000..a760c37 --- /dev/null +++ b/data/org.mate.power-manager.gschema.xml.in @@ -0,0 +1,359 @@ + + + + + + + + + + + + + + + + + + + + + + + + + 'hibernate' + <_summary>Whether to hibernate, suspend or do nothing when inactive + <_description>The type of sleeping that should be performed when the computer is inactive. + + + 'hibernate' + <_summary>Battery critical low action + <_description>The action to take when the battery is critically low. + + + true + <_summary>If the battery event should occur when the lid is shut and the power disconnected + <_description>If the battery lid close event should occur (for example 'Suspend when lid closed on battery') when the lid is previously shut and the AC power disconnected at a later time. + + + 'suspend' + <_summary>Whether to hibernate, suspend or do nothing when inactive + <_description>The type of sleeping that should be performed when the computer is inactive. + + + 'shutdown' + <_summary>UPS critical low action + <_description>The action to take when the UPS is critically low. + + + 'hibernate' + <_summary>UPS low power action + <_description>The action to take when the UPS is low. + + + true + <_summary>Allow backlight brightness adjustment + <_description>If the screen brightness should be changed when switching between AC and battery power. + + + true + <_summary>Reduce the backlight brightness when on battery power + <_description>If the screen should be reduced in brightness when the computer is on battery power. + + + 30 + <_summary>The brightness of the screen when idle + <_description>This is the laptop panel screen brightness used when the session is idle. Only valid when use-time-for-policy is true. + + + true + <_summary>Dim the screen after a period of inactivity when on battery power + <_description>If the screen should be dimmed to save power when the computer is idle when on battery power. + + + 10 + <_summary>The default amount of time to dim the screen after idle + <_description>The default amount of time to dim the screen after idle. + + + 50 + <_summary>LCD dimming amount when on battery + <_description>The amount to dim the brightness of the display when on battery power. Possible values are between 0 and 100. + + + false + <_summary>Dim the screen after a period of inactivity when on AC power + <_description>If the screen should be dimmed to save power when the computer is idle when on AC power. + + + 'off' + <_summary>Method used to blank screen on AC + <_description>The DPMS method used to blank the screen when on AC power. + + + 'off' + <_summary>Method used to blank screen on battery + <_description>The DPMS method used to blank the screen when on battery power. + + + 100.0 + <_summary>LCD brightness when on AC + <_description>The brightness of the display when on AC power. Possible values are between 0.0 and 100.0. + + + 'suspend' + <_summary>Suspend button action + <_description>The action to take when the system suspend button is pressed. + + + 'hibernate' + <_summary>Hibernate button action + <_description>The action to take when the system hibernate button is pressed. + + + 'interactive' + <_summary>Power button action + <_description>The action to take when the system power button is pressed. + + + 'suspend' + <_summary>Laptop lid close action on battery + <_description>The action to take when the laptop lid is closed and the laptop is on battery power. + + + 'suspend' + <_summary>Laptop lid close action when on AC + <_description>The action to take when the laptop lid is closed and the laptop is on AC power. + + + 3 + <_summary>The default configuration version. + <_description>The version of the installed version of the schema. Do not edit this value, it is used so that configure changes between versions can be detected. + + + true + <_summary>If the learnt profile should be used to calculate the time remaining + <_description>If the learnt profile should be used to calculate the time remaining. Only turn this off for debugging. + + + true + <_summary>Whether to use time-based notifications + <_description>If time based notifications should be used. If set to false, then the percentage change is used instead, which may fix a broken ACPI BIOS. + + + false + <_summary>Check CPU load before sleeping + <_description>If the CPU load should be checked before doing the idle action. + + + false + <_summary>Whether NetworkManager should be connected and disconnected on sleep. + <_description>Whether NetworkManager should disconnect before suspending or hibernating and connect on resume. + + + true + <_summary>Use mate-screensaver lock setting + <_description>Whether to use the screen lock setting of mate-screensaver to decide if the screen is locked after a hibernate, suspend or blank screen. + + + true + <_summary>Lock screen when blanked + <_description>Whether the screen is locked when the screen is turned off. Only used if lock-use-screensaver is false. + + + true + <_summary>Lock screen on suspend + <_description>Whether the screen is locked when the computer wakes up from a suspend. Only used if lock-use-screensaver is false. + + + true + <_summary>Lock screen on hibernate + <_description>Whether the screen is locked when the computer wakes up from a hibernate. Only used if lock-use-screensaver is false. + + + false + <_summary>Lock MATE keyring on sleep + <_description>Whether the MATE keyring is locked before the computer enters suspend. This means the keyring will have to be unlocked on resume. + + + true + <_summary>Lock MATE keyring on sleep + <_description>Whether the MATE keyring is locked before the computer enters hibernate. This means the keyring will have to be unlocked on resume. + + + false + <_summary>If the low-power mode should be enabled when on AC + <_description>If the system low-power mode should be enabled when on AC power. + + + true + <_summary>If the low-power mode should be enabled when on battery + <_description>If the system low-power mode should be enabled when on laptop battery power. + + + 600 + <_summary>Seconds of inactivity to spin down when on AC + <_description>The number of seconds of inactivity to spin down the disks when on AC power. + + + 60 + <_summary>Seconds of inactivity to spin down when on battery + <_description>The number of seconds of inactivity to spin down the disks when on battery power. + + + true + <_summary>If we should show the recalled battery warning for a broken battery + <_description>If we should show the recalled battery warning for a broken battery. Set this to false only if you know your battery is okay. + + + true + <_summary>If we should show the low capacity warning for a broken battery + <_description>If we should show the low capacity warning for a broken battery. + + + true + <_summary>Notify when AC adapter is disconnected + <_description>If the user should be notified when the AC adapter is disconnected. + + + false + <_summary>Notify when fully charged + <_description>If a notification message should be displayed when the battery is fully charged. + + + true + <_summary>Notify on a sleep failure + <_description>If a notification message should be displayed after suspend or hibernate failed. + + + '' + <_summary>The URI to show to the user on sleep failure + <_description>When sleep fails we can show the user a button to help fix the situation. Leave this blank if the button should not be shown. + + + true + <_summary>Notify on a low power + <_description>If a notification message should be displayed when the battery is getting low. + + + true + <_summary>Whether we should show the history data points + <_description>Whether we should show the history data points in the statistics window. + + + true + <_summary>Whether we should smooth the history data + <_description>Whether we should smooth the history data in the graph. + + + 'power' + <_summary>The default graph type to show for history + <_description>The default graph type to show in the history window. + + + 21600 + <_summary>The maximum time displayed for history + <_description>The maximum duration of time displayed on the x-axis of the history graph. + + + true + <_summary>Whether we should show the stats data points + <_description>Whether we should show the stats data points in the statistics window. + + + true + <_summary>Whether we should smooth the stats data + <_description>Whether we should smooth the stats data in the graph. + + + 'power' + <_summary>The default graph type to show for stats + <_description>The default graph type to show in the stats window. + + + 0 + <_summary>The index of the page number to show by default + <_description>The index of the page number to show by default which is used to return focus to the correct page. + + + '' + <_summary>The ID of the last device selected + <_description>The identifier of the last device which is used to return focus to the correct device. + + + 10 + <_summary>Percentage considered low + <_description>The percentage of the battery when it is considered low. Only valid when use-time-for-policy is false. + + + 3 + <_summary>Percentage considered critical + <_description>The percentage of the battery when it is considered critical. Only valid when use-time-for-policy is false. + + + 2 + <_summary>Percentage action is taken + <_description>The percentage of the battery when the critical action is performed. Only valid when use-time-for-policy is false. + + + 1200 + <_summary>The time remaining when low + <_description>The time remaining in seconds of the battery when it is considered low. Only valid when use-time-for-policy is true. + + + 300 + <_summary>The time remaining when critical + <_description>The time remaining in seconds of the battery when it is considered critical. Only valid when use-time-for-policy is true. + + + 120 + <_summary>The time remaining when action is taken + <_description>The time remaining in seconds of the battery when critical action is taken. Only valid when use-time-for-policy is true. + + + 0 + <_summary>Sleep timeout computer when on battery + <_description>The amount of time in seconds the computer on battery power needs to be inactive before it goes to sleep. + + + 0 + <_summary>Sleep timeout computer when on AC + <_description>The amount of time in seconds the computer on AC power needs to be inactive before it goes to sleep. + + + 0 + <_summary>Sleep timeout computer when on UPS + <_description>The amount of time in seconds the computer on UPS power needs to be inactive before it goes to sleep. + + + 1800 + <_summary>Sleep timeout display when on AC + <_description>The amount of time in seconds before the display goes to sleep when the computer is on AC power. + + + 600 + <_summary>Sleep timeout display when on battery + <_description>The amount of time in seconds the computer on battery power needs to be inactive before the display goes to sleep. + + + 600 + <_summary>Sleep timeout display when on UPS + <_description>The amount of time in seconds the computer on UPS power needs to be inactive before the display goes to sleep. + + + true + <_summary>If sounds should be used + <_description>If sounds should be used when the power is critically low, or inhibit requests have stopped the policy action. + + + true + <_summary>If preferences and statistics items should be shown in the context menu + + + 'present' + <_summary>When to show the notification icon + <_description>Display options for the notification icon. + + + diff --git a/po/POTFILES.in b/po/POTFILES.in index 8596c96..deef684 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -6,7 +6,7 @@ applets/brightness/brightness-applet.c applets/inhibit/inhibit-applet.c [type: gettext/ini]applets/inhibit/org.mate.InhibitApplet.mate-panel-applet.in.in data/mate-power-manager.desktop.in.in -data/org.mate.power-manager.gschema.xml +data/org.mate.power-manager.gschema.xml.in data/mate-power-preferences.desktop.in.in data/mate-power-statistics.desktop.in.in [type: gettext/glade]data/gpm-feedback-widget.ui -- cgit v1.2.1 From 1e0bea49d7d1959d063c6ab74c99500067236110 Mon Sep 17 00:00:00 2001 From: Brent Hull Date: Tue, 30 Oct 2012 17:34:02 -0400 Subject: Remove unused key from gsettings schema --- data/org.mate.power-manager.gschema.xml.in | 5 ----- src/gpm-common.h | 1 - 2 files changed, 6 deletions(-) diff --git a/data/org.mate.power-manager.gschema.xml.in b/data/org.mate.power-manager.gschema.xml.in index a760c37..e423182 100644 --- a/data/org.mate.power-manager.gschema.xml.in +++ b/data/org.mate.power-manager.gschema.xml.in @@ -131,11 +131,6 @@ <_summary>The default configuration version. <_description>The version of the installed version of the schema. Do not edit this value, it is used so that configure changes between versions can be detected. - - true - <_summary>If the learnt profile should be used to calculate the time remaining - <_description>If the learnt profile should be used to calculate the time remaining. Only turn this off for debugging. - true <_summary>Whether to use time-based notifications diff --git a/src/gpm-common.h b/src/gpm-common.h index ee05036..7b5822b 100644 --- a/src/gpm-common.h +++ b/src/gpm-common.h @@ -75,7 +75,6 @@ G_BEGIN_DECLS /* general */ #define GPM_SETTINGS_SCHEMA_VERSION "schema-version" #define GPM_SETTINGS_USE_TIME_POLICY "use-time-for-policy" -#define GPM_SETTINGS_USE_PROFILE_TIME "use-profile-time" #define GPM_SETTINGS_NETWORKMANAGER_SLEEP "network-sleep" #define GPM_SETTINGS_IDLE_CHECK_CPU "check-type-cpu" -- cgit v1.2.1 From 972be3627b8b6368a0e8c971ade7963ea7d459de Mon Sep 17 00:00:00 2001 From: Brent Hull Date: Thu, 1 Nov 2012 19:40:46 -0400 Subject: Remove unnecessary schema version check and some unused constants --- data/org.mate.power-manager.gschema.xml.in | 5 ----- src/gpm-common.h | 9 +-------- src/gpm-manager.c | 18 +----------------- 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/data/org.mate.power-manager.gschema.xml.in b/data/org.mate.power-manager.gschema.xml.in index e423182..99ee820 100644 --- a/data/org.mate.power-manager.gschema.xml.in +++ b/data/org.mate.power-manager.gschema.xml.in @@ -126,11 +126,6 @@ <_summary>Laptop lid close action when on AC <_description>The action to take when the laptop lid is closed and the laptop is on AC power. - - 3 - <_summary>The default configuration version. - <_description>The version of the installed version of the schema. Do not edit this value, it is used so that configure changes between versions can be detected. - true <_summary>Whether to use time-based notifications diff --git a/src/gpm-common.h b/src/gpm-common.h index 7b5822b..5cb0696 100644 --- a/src/gpm-common.h +++ b/src/gpm-common.h @@ -36,13 +36,7 @@ G_BEGIN_DECLS #define GPM_NAME _("Power Manager") #define GPM_DESCRIPTION _("Power Manager for the MATE desktop") -/* help location */ -#define GPM_HOMEPAGE_URL "http://www.gnome.org/projects/mate-power-manager/" -#define GPM_BUGZILLA_URL "http://bugzilla.gnome.org/buglist.cgi?product=mate-power-manager" -#define GPM_FAQ_URL "http://live.gnome.org/MatePowerManager/Faq" - -/* change general/installed_schema whenever adding or moving keys */ -#define GPM_SETTINGS_SCHEMA_ID 3 +/* schema location */ #define GPM_SETTINGS_SCHEMA "org.mate.power-manager" /* actions */ @@ -73,7 +67,6 @@ G_BEGIN_DECLS #define GPM_SETTINGS_BUTTON_POWER "button-power" /* general */ -#define GPM_SETTINGS_SCHEMA_VERSION "schema-version" #define GPM_SETTINGS_USE_TIME_POLICY "use-time-for-policy" #define GPM_SETTINGS_NETWORKMANAGER_SLEEP "network-sleep" #define GPM_SETTINGS_IDLE_CHECK_CPU "check-type-cpu" diff --git a/src/gpm-manager.c b/src/gpm-manager.c index b351b6f..6248b97 100644 --- a/src/gpm-manager.c +++ b/src/gpm-manager.c @@ -565,7 +565,7 @@ gpm_manager_sleep_failure (GpmManager *manager, gboolean is_suspend, const gchar 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; @@ -1876,7 +1876,6 @@ gpm_manager_init (GpmManager *manager) gint timeout; DBusGConnection *connection; GError *error = NULL; - guint version; manager->priv = GPM_MANAGER_GET_PRIVATE (manager); connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); @@ -1910,21 +1909,6 @@ gpm_manager_init (GpmManager *manager) /* use libmatenotify */ notify_init (GPM_NAME); - /* check to see if the user has installed the schema properly */ - version = g_settings_get_int (manager->priv->settings, GPM_SETTINGS_SCHEMA_VERSION); - if (version != GPM_SETTINGS_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 GSettings schema installed!"); - } - /* coldplug so we are in the correct state at startup */ g_object_get (manager->priv->client, "on-battery", &manager->priv->on_battery, -- cgit v1.2.1