summaryrefslogtreecommitdiff
path: root/applets/brightness
diff options
context:
space:
mode:
Diffstat (limited to 'applets/brightness')
-rw-r--r--applets/brightness/MATE_BrightnessApplet.server.in.in36
-rw-r--r--applets/brightness/MATE_BrightnessApplet.xml8
-rw-r--r--applets/brightness/Makefile.am55
-rw-r--r--applets/brightness/Makefile.in717
-rw-r--r--applets/brightness/brightness-applet.c1038
-rw-r--r--applets/brightness/egg-dbus-monitor.c251
-rw-r--r--applets/brightness/egg-dbus-monitor.h65
-rw-r--r--applets/brightness/egg-debug.c308
-rw-r--r--applets/brightness/egg-debug.h83
-rw-r--r--applets/brightness/gpm-common.c210
-rw-r--r--applets/brightness/gpm-common.h183
11 files changed, 2954 insertions, 0 deletions
diff --git a/applets/brightness/MATE_BrightnessApplet.server.in.in b/applets/brightness/MATE_BrightnessApplet.server.in.in
new file mode 100644
index 0000000..fcb60b7
--- /dev/null
+++ b/applets/brightness/MATE_BrightnessApplet.server.in.in
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+
+<oaf_info>
+ <oaf_server iid="OAFIID:MATE_BrightnessApplet_Factory" type="exe" location="@LIBEXECDIR@/mate-brightness-applet">
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:MateComponent/GenericFactory:1.0"/>
+ <item value="IDL:MateComponent/Unknown:1.0"/>
+ </oaf_attribute>
+ <oaf_attribute name="name" type="string" _value="Brightness Applet Factory"/>
+ <oaf_attribute name="description" type="string" _value="Factory for Brightness Applet"/>
+ <oaf_attribute name="bugzilla:bugzilla" type="string" value="MATE"/>
+ <oaf_attribute name="bugzilla:product" type="string" value="mate-power-manager"/>
+ <oaf_attribute name="bugzilla:component" type="string" value="applets"/>
+ <oaf_attribute name="bugzilla:version" type="string" value="@VERSION@"/>
+ <oaf_attribute name="bugzilla:other_binaries" type="string" value="mate-brightness-applet"/>
+ </oaf_server>
+ <oaf_server iid="OAFIID:MATE_BrightnessApplet" type="factory" location="OAFIID:MATE_BrightnessApplet_Factory">
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:MATE/Vertigo/MatePanelAppletShell:1.0"/>
+ <item value="IDL:MateComponent/Control:1.0"/>
+ <item value="IDL:MateComponent/Unknown:1.0"/>
+ </oaf_attribute>
+ <oaf_attribute name="panel:category" type="string" value="System &amp; Hardware"/>
+ <oaf_attribute name="panel:icon" type="string" value="mate-brightness-applet"/>
+ <oaf_attribute name="name" type="string" _value="Brightness Applet"/>
+ <oaf_attribute name="description" type="string" _value="Adjusts Laptop panel brightness"/>
+ <oaf_attribute name="bugzilla:bugzilla" type="string" value="MATE"/>
+ <oaf_attribute name="bugzilla:product" type="string" value="mate-power-manager"/>
+ <oaf_attribute name="bugzilla:component" type="string" value="applets"/>
+ <oaf_attribute name="bugzilla:version" type="string" value="@VERSION@"/>
+ <oaf_attribute name="bugzilla:other_binaries" type="string" value="mate-brightness-applet"/>
+ <oaf_attribute name="matecomponent:environment" type="stringv">
+ <item value="DBUS_SESSION_BUS_ADDRESS"/>
+ </oaf_attribute>
+ </oaf_server>
+</oaf_info>
diff --git a/applets/brightness/MATE_BrightnessApplet.xml b/applets/brightness/MATE_BrightnessApplet.xml
new file mode 100644
index 0000000..83b176f
--- /dev/null
+++ b/applets/brightness/MATE_BrightnessApplet.xml
@@ -0,0 +1,8 @@
+<Root>
+ <popups>
+ <popup name="button3">
+ <menuitem name="Help" verb="Help" _label="_Help" pixtype="stock" pixname="gtk-help"/>
+ <menuitem name="About" verb="About" _label="_About" pixtype="stock" pixname="gtk-about" />
+ </popup>
+ </popups>
+</Root>
diff --git a/applets/brightness/Makefile.am b/applets/brightness/Makefile.am
new file mode 100644
index 0000000..c0a6cb6
--- /dev/null
+++ b/applets/brightness/Makefile.am
@@ -0,0 +1,55 @@
+INCLUDES = \
+ -I. -I$(srcdir) \
+ $(GLIB_CFLAGS) \
+ $(DBUS_CFLAGS) \
+ $(MATE_CFLAGS) \
+ $(PANEL_CFLAGS) \
+ $(LIBMATENOTIFY_CFLAGS) \
+ $(GTKUNIQUE_CFLAGS) \
+ -DBINDIR=\"$(bindir)\" \
+ -DMATELOCALEDIR=\""$(datadir)/locale"\" \
+ -DDATADIR=\"$(datadir)\" \
+ -DPREFIX=\""$(prefix)"\" \
+ -DSYSCONFDIR=\""$(sysconfdir)"\" \
+ -DLIBDIR=\""$(libdir)"\" \
+ -DVERSION="\"$(VERSION)\"" \
+ -DGPM_DATA=\"$(pkgdatadir)\" \
+ -DEGG_LOG_FILE=\""~/mate-power-manager.log"\" \
+ -DEGG_VERBOSE="\"GPM_VERBOSE\"" \
+ -DEGG_LOGGING="\"GPM_LOGGING\"" \
+ -DEGG_CONSOLE="\"GPM_CONSOLE\"" \
+ -I$(top_srcdir)/libdbus-glib \
+ $(NULL)
+
+libexec_PROGRAMS=mate-brightness-applet
+
+mate_brightness_applet_SOURCES = \
+ brightness-applet.c \
+ egg-dbus-monitor.c \
+ egg-dbus-monitor.h \
+ egg-debug.c \
+ egg-debug.h \
+ gpm-common.c \
+ gpm-common.h
+
+mate_brightness_applet_LDADD = \
+ $(DBUS_LIBS) \
+ $(MATE_LIBS) \
+ $(PANEL_LIBS)
+
+serverdir = $(libdir)/matecomponent/servers
+server_in_files = MATE_BrightnessApplet.server.in
+server_DATA = $(server_in_files:.server.in=.server)
+
+$(server_in_files): $(server_in_files:.server.in=.server.in.in)
+ sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" -e "s|\@VERSION\@|$(VERSION)|" $< > $@
+
+@INTLTOOL_SERVER_RULE@
+
+uidir = $(datadir)/mate-2.0/ui
+ui_DATA = MATE_BrightnessApplet.xml
+
+EXTRA_DIST = MATE_BrightnessApplet.server.in.in $(ui_DATA)
+
+DISTCLEANFILES = \
+ $(server_DATA) $(server_DATA).in
diff --git a/applets/brightness/Makefile.in b/applets/brightness/Makefile.in
new file mode 100644
index 0000000..281ba50
--- /dev/null
+++ b/applets/brightness/Makefile.in
@@ -0,0 +1,717 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+libexec_PROGRAMS = mate-brightness-applet$(EXEEXT)
+subdir = applets/brightness
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/mate-doc-utils.m4 \
+ $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(serverdir)" \
+ "$(DESTDIR)$(uidir)"
+PROGRAMS = $(libexec_PROGRAMS)
+am_mate_brightness_applet_OBJECTS = brightness-applet.$(OBJEXT) \
+ egg-dbus-monitor.$(OBJEXT) egg-debug.$(OBJEXT) \
+ gpm-common.$(OBJEXT)
+mate_brightness_applet_OBJECTS = $(am_mate_brightness_applet_OBJECTS)
+am__DEPENDENCIES_1 =
+mate_brightness_applet_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(mate_brightness_applet_SOURCES)
+DIST_SOURCES = $(mate_brightness_applet_SOURCES)
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+DATA = $(server_DATA) $(ui_DATA)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALL_LINGUAS = @ALL_LINGUAS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINDIR = @BINDIR@
+CANBERRA_CFLAGS = @CANBERRA_CFLAGS@
+CANBERRA_LIBS = @CANBERRA_LIBS@
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATADIR = @DATADIR@
+DATADIRNAME = @DATADIRNAME@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DBUS_SERVICES_DIR = @DBUS_SERVICES_DIR@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@
+DOCBOOK2MAN = @DOCBOOK2MAN@
+DOCDIR = @DOCDIR@
+DOC_USER_FORMATS = @DOC_USER_FORMATS@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
+GLIB_LIBS = @GLIB_LIBS@
+GMOFILES = @GMOFILES@
+GMSGFMT = @GMSGFMT@
+GPM_EXTRA_LIBS = @GPM_EXTRA_LIBS@
+GREP = @GREP@
+HELP_DIR = @HELP_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INSTOBJEXT = @INSTOBJEXT@
+INTLLIBS = @INTLLIBS@
+INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
+INTLTOOL_MERGE = @INTLTOOL_MERGE@
+INTLTOOL_PERL = @INTLTOOL_PERL@
+INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBMATENOTIFY_CFLAGS = @LIBMATENOTIFY_CFLAGS@
+LIBMATENOTIFY_LIBS = @LIBMATENOTIFY_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MATECONFTOOL = @MATECONFTOOL@
+MATECONF_SCHEMA_CONFIG_SOURCE = @MATECONF_SCHEMA_CONFIG_SOURCE@
+MATECONF_SCHEMA_FILE_DIR = @MATECONF_SCHEMA_FILE_DIR@
+MATE_CFLAGS = @MATE_CFLAGS@
+MATE_LIBS = @MATE_LIBS@
+MKDIR_P = @MKDIR_P@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+MSGFMT = @MSGFMT@
+MSGFMT_OPTS = @MSGFMT_OPTS@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OMF_DIR = @OMF_DIR@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANEL_CFLAGS = @PANEL_CFLAGS@
+PANEL_LIBS = @PANEL_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+POFILES = @POFILES@
+POSUB = @POSUB@
+PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@
+PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@
+RANLIB = @RANLIB@
+SBINDIR = @SBINDIR@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+SYSCONFDIR = @SYSCONFDIR@
+UNIQUE_CFLAGS = @UNIQUE_CFLAGS@
+UNIQUE_LIBS = @UNIQUE_LIBS@
+UPOWER_CFLAGS = @UPOWER_CFLAGS@
+UPOWER_LIBS = @UPOWER_LIBS@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+WARNINGFLAGS = @WARNINGFLAGS@
+WARN_CFLAGS = @WARN_CFLAGS@
+X11_CFLAGS = @X11_CFLAGS@
+X11_LIBS = @X11_LIBS@
+XGETTEXT = @XGETTEXT@
+XMLTO = @XMLTO@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = \
+ -I. -I$(srcdir) \
+ $(GLIB_CFLAGS) \
+ $(DBUS_CFLAGS) \
+ $(MATE_CFLAGS) \
+ $(PANEL_CFLAGS) \
+ $(LIBMATENOTIFY_CFLAGS) \
+ $(GTKUNIQUE_CFLAGS) \
+ -DBINDIR=\"$(bindir)\" \
+ -DMATELOCALEDIR=\""$(datadir)/locale"\" \
+ -DDATADIR=\"$(datadir)\" \
+ -DPREFIX=\""$(prefix)"\" \
+ -DSYSCONFDIR=\""$(sysconfdir)"\" \
+ -DLIBDIR=\""$(libdir)"\" \
+ -DVERSION="\"$(VERSION)\"" \
+ -DGPM_DATA=\"$(pkgdatadir)\" \
+ -DEGG_LOG_FILE=\""~/mate-power-manager.log"\" \
+ -DEGG_VERBOSE="\"GPM_VERBOSE\"" \
+ -DEGG_LOGGING="\"GPM_LOGGING\"" \
+ -DEGG_CONSOLE="\"GPM_CONSOLE\"" \
+ -I$(top_srcdir)/libdbus-glib \
+ $(NULL)
+
+mate_brightness_applet_SOURCES = \
+ brightness-applet.c \
+ egg-dbus-monitor.c \
+ egg-dbus-monitor.h \
+ egg-debug.c \
+ egg-debug.h \
+ gpm-common.c \
+ gpm-common.h
+
+mate_brightness_applet_LDADD = \
+ $(DBUS_LIBS) \
+ $(MATE_LIBS) \
+ $(PANEL_LIBS)
+
+serverdir = $(libdir)/matecomponent/servers
+server_in_files = MATE_BrightnessApplet.server.in
+server_DATA = $(server_in_files:.server.in=.server)
+uidir = $(datadir)/mate-2.0/ui
+ui_DATA = MATE_BrightnessApplet.xml
+EXTRA_DIST = MATE_BrightnessApplet.server.in.in $(ui_DATA)
+DISTCLEANFILES = \
+ $(server_DATA) $(server_DATA).in
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign applets/brightness/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign applets/brightness/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-libexecPROGRAMS: $(libexec_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(libexecdir)" || $(MKDIR_P) "$(DESTDIR)$(libexecdir)"
+ @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed 's/$(EXEEXT)$$//' | \
+ while read p p1; do if test -f $$p || test -f $$p1; \
+ then echo "$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+ sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) files[d] = files[d] " " $$1; \
+ else { print "f", $$3 "/" $$4, $$1; } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-libexecPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+ -e 's/$$/$(EXEEXT)/' `; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(libexecdir)" && rm -f $$files
+
+clean-libexecPROGRAMS:
+ @list='$(libexec_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+mate-brightness-applet$(EXEEXT): $(mate_brightness_applet_OBJECTS) $(mate_brightness_applet_DEPENDENCIES)
+ @rm -f mate-brightness-applet$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(mate_brightness_applet_OBJECTS) $(mate_brightness_applet_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/brightness-applet.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/egg-dbus-monitor.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/egg-debug.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gpm-common.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-serverDATA: $(server_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(serverdir)" || $(MKDIR_P) "$(DESTDIR)$(serverdir)"
+ @list='$(server_DATA)'; test -n "$(serverdir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(serverdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(serverdir)" || exit $$?; \
+ done
+
+uninstall-serverDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(server_DATA)'; test -n "$(serverdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(serverdir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(serverdir)" && rm -f $$files
+install-uiDATA: $(ui_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(uidir)" || $(MKDIR_P) "$(DESTDIR)$(uidir)"
+ @list='$(ui_DATA)'; test -n "$(uidir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(uidir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(uidir)" || exit $$?; \
+ done
+
+uninstall-uiDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(ui_DATA)'; test -n "$(uidir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(uidir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(uidir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS) $(DATA)
+installdirs:
+ for dir in "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(serverdir)" "$(DESTDIR)$(uidir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libexecPROGRAMS clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-serverDATA install-uiDATA
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-libexecPROGRAMS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-libexecPROGRAMS uninstall-serverDATA \
+ uninstall-uiDATA
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libexecPROGRAMS clean-libtool ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am \
+ install-libexecPROGRAMS install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-serverDATA install-strip \
+ install-uiDATA installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-libexecPROGRAMS uninstall-serverDATA \
+ uninstall-uiDATA
+
+
+$(server_in_files): $(server_in_files:.server.in=.server.in.in)
+ sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" -e "s|\@VERSION\@|$(VERSION)|" $< > $@
+
+@INTLTOOL_SERVER_RULE@
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/applets/brightness/brightness-applet.c b/applets/brightness/brightness-applet.c
new file mode 100644
index 0000000..125af49
--- /dev/null
+++ b/applets/brightness/brightness-applet.c
@@ -0,0 +1,1038 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * MATE Power Manager Brightness Applet
+ * Copyright (C) 2006 Benjamin Canou <[email protected]>
+ * Copyright (C) 2007 Richard Hughes <[email protected]>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* FIXME: gdk_gc_* needs porting to cairo */
+#undef GDK_DISABLE_DEPRECATED
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mate-panel-applet.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+
+#include "egg-debug.h"
+#include "egg-dbus-monitor.h"
+#include "gpm-common.h"
+
+#define GPM_TYPE_BRIGHTNESS_APPLET (gpm_brightness_applet_get_type ())
+#define GPM_BRIGHTNESS_APPLET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_BRIGHTNESS_APPLET, GpmBrightnessApplet))
+#define GPM_BRIGHTNESS_APPLET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_BRIGHTNESS_APPLET, GpmBrightnessAppletClass))
+#define GPM_IS_BRIGHTNESS_APPLET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_BRIGHTNESS_APPLET))
+#define GPM_IS_BRIGHTNESS_APPLET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_BRIGHTNESS_APPLET))
+#define GPM_BRIGHTNESS_APPLET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_BRIGHTNESS_APPLET, GpmBrightnessAppletClass))
+
+typedef struct{
+ MatePanelApplet parent;
+ /* applet state */
+ gboolean call_worked; /* g-p-m refusing action */
+ gboolean popped; /* the popup is shown */
+ /* the popup and its widgets */
+ GtkWidget *popup, *slider, *btn_plus, *btn_minus;
+ /* the icon and a cache for size*/
+ GdkPixbuf *icon;
+ gint icon_width, icon_height;
+ /* connection to g-p-m */
+ DBusGProxy *proxy;
+ DBusGConnection *connection;
+ EggDbusMonitor *monitor;
+ guint level;
+ /* a cache for panel size */
+ gint size;
+} GpmBrightnessApplet;
+
+typedef struct{
+ MatePanelAppletClass parent_class;
+} GpmBrightnessAppletClass;
+
+GType gpm_brightness_applet_get_type (void);
+
+
+static void gpm_brightness_applet_class_init (GpmBrightnessAppletClass *klass);
+static void gpm_brightness_applet_init (GpmBrightnessApplet *applet);
+
+G_DEFINE_TYPE (GpmBrightnessApplet, gpm_brightness_applet, PANEL_TYPE_APPLET)
+
+static void gpm_applet_get_icon (GpmBrightnessApplet *applet);
+static void gpm_applet_check_size (GpmBrightnessApplet *applet);
+static gboolean gpm_applet_draw_cb (GpmBrightnessApplet *applet);
+static void gpm_applet_change_background_cb (GpmBrightnessApplet *applet,
+ MatePanelAppletBackgroundType arg1,
+ GdkColor *arg2, GdkPixmap *arg3, gpointer data);
+static void gpm_applet_theme_change_cb (GtkIconTheme *icon_theme, gpointer data);
+static void gpm_applet_stop_scroll_events_cb (GtkWidget *widget, GdkEvent *event);
+static gboolean gpm_applet_destroy_popup_cb (GpmBrightnessApplet *applet);
+static void gpm_applet_update_tooltip (GpmBrightnessApplet *applet);
+static void gpm_applet_update_popup_level (GpmBrightnessApplet *applet);
+static gboolean gpm_applet_plus_cb (GtkWidget *w, GpmBrightnessApplet *applet);
+static gboolean gpm_applet_minus_cb (GtkWidget *w, GpmBrightnessApplet *applet);
+static gboolean gpm_applet_key_press_cb (GpmBrightnessApplet *applet, GdkEventKey *event);
+static gboolean gpm_applet_scroll_cb (GpmBrightnessApplet *applet, GdkEventScroll *event);
+static gboolean gpm_applet_slide_cb (GtkWidget *w, GpmBrightnessApplet *applet);
+static void gpm_applet_create_popup (GpmBrightnessApplet *applet);
+static gboolean gpm_applet_popup_cb (GpmBrightnessApplet *applet, GdkEventButton *event);
+static void gpm_applet_dialog_about_cb (MateComponentUIComponent *uic, gpointer data, const gchar *verbname);
+static gboolean gpm_applet_matecomponent_cb (MatePanelApplet *_applet, const gchar *iid, gpointer data);
+static void gpm_applet_destroy_cb (GtkObject *object);
+
+#define GPM_BRIGHTNESS_APPLET_OAFID "OAFIID:MATE_BrightnessApplet"
+#define GPM_BRIGHTNESS_APPLET_FACTORY_OAFID "OAFIID:MATE_BrightnessApplet_Factory"
+#define GPM_BRIGHTNESS_APPLET_ICON "mate-brightness-applet"
+#define GPM_BRIGHTNESS_APPLET_ICON_DISABLED "gpm-brightness-lcd-disabled"
+#define GPM_BRIGHTNESS_APPLET_ICON_INVALID "gpm-brightness-lcd-invalid"
+#define GPM_BRIGHTNESS_APPLET_NAME _("Power Manager Brightness Applet")
+#define GPM_BRIGHTNESS_APPLET_DESC _("Adjusts laptop panel brightness.")
+#define MATE_PANEL_APPLET_VERTICAL(p) \
+ (((p) == MATE_PANEL_APPLET_ORIENT_LEFT) || ((p) == MATE_PANEL_APPLET_ORIENT_RIGHT))
+
+/**
+ * gpm_applet_get_brightness:
+ * Return value: Success value, or zero for failure
+ **/
+static gboolean
+gpm_applet_get_brightness (GpmBrightnessApplet *applet)
+{
+ GError *error = NULL;
+ gboolean ret;
+ guint policy_brightness;
+
+ if (applet->proxy == NULL) {
+ egg_warning ("not connected\n");
+ return FALSE;
+ }
+
+ ret = dbus_g_proxy_call (applet->proxy, "GetBrightness", &error,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, &policy_brightness,
+ G_TYPE_INVALID);
+ if (error) {
+ egg_debug ("ERROR: %s\n", error->message);
+ g_error_free (error);
+ }
+ if (ret) {
+ applet->level = policy_brightness;
+ } else {
+ /* abort as the DBUS method failed */
+ egg_warning ("GetBrightness failed!\n");
+ }
+
+ return ret;
+}
+
+/**
+ * gpm_applet_set_brightness:
+ * Return value: Success value, or zero for failure
+ **/
+static gboolean
+gpm_applet_set_brightness (GpmBrightnessApplet *applet)
+{
+ GError *error = NULL;
+ gboolean ret;
+
+ if (applet->proxy == NULL) {
+ egg_warning ("not connected");
+ return FALSE;
+ }
+
+ ret = dbus_g_proxy_call (applet->proxy, "SetBrightness", &error,
+ G_TYPE_UINT, applet->level,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (error) {
+ egg_debug ("ERROR: %s", error->message);
+ g_error_free (error);
+ }
+ if (!ret) {
+ /* abort as the DBUS method failed */
+ egg_warning ("SetBrightness failed!");
+ }
+
+ return ret;
+}
+
+/**
+ * gpm_applet_get_icon:
+ * @applet: Brightness applet instance
+ *
+ * retrieve an icon from stock with a size adapted to panel
+ **/
+static void
+gpm_applet_get_icon (GpmBrightnessApplet *applet)
+{
+ const gchar *icon;
+
+ /* free */
+ if (applet->icon != NULL) {
+ g_object_unref (applet->icon);
+ applet->icon = NULL;
+ }
+
+ if (applet->size <= 2) {
+ return;
+ }
+
+ /* get icon */
+ if (applet->proxy == NULL) {
+ icon = GPM_BRIGHTNESS_APPLET_ICON_INVALID;
+ } else if (applet->call_worked == FALSE) {
+ icon = GPM_BRIGHTNESS_APPLET_ICON_DISABLED;
+ } else {
+ icon = GPM_BRIGHTNESS_APPLET_ICON;
+ }
+
+ applet->icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ icon, applet->size - 2, 0, NULL);
+
+ if (applet->icon == NULL) {
+ egg_warning ("Cannot find %s!\n", icon);
+ } else {
+ egg_debug ("got icon %s!\n", icon);
+ /* update size cache */
+ applet->icon_height = gdk_pixbuf_get_height (applet->icon);
+ applet->icon_width = gdk_pixbuf_get_width (applet->icon);
+ }
+}
+
+/**
+ * gpm_applet_check_size:
+ * @applet: Brightness applet instance
+ *
+ * check if panel size has changed and applet adapt size
+ **/
+static void
+gpm_applet_check_size (GpmBrightnessApplet *applet)
+{
+ GtkAllocation allocation;
+
+ /* we don't use the size function here, but the yet allocated size because the
+ size value is false (kind of rounded) */
+ gtk_widget_get_allocation (GTK_WIDGET (applet), &allocation);
+ if (MATE_PANEL_APPLET_VERTICAL(mate_panel_applet_get_orient (MATE_PANEL_APPLET (applet)))) {
+ if (applet->size != allocation.width) {
+ applet->size = allocation.width;
+ gpm_applet_get_icon (applet);
+ gtk_widget_set_size_request (GTK_WIDGET(applet), applet->size, applet->icon_height + 2);
+ }
+ } else {
+ if (applet->size != allocation.height) {
+ applet->size = allocation.height;
+ gpm_applet_get_icon (applet);
+ gtk_widget_set_size_request (GTK_WIDGET(applet), applet->icon_width + 2, applet->size);
+ }
+ }
+}
+
+/**
+ * gpm_applet_draw_cb:
+ * @applet: Brightness applet instance
+ *
+ * draws applet content (background + icon)
+ **/
+static gboolean
+gpm_applet_draw_cb (GpmBrightnessApplet *applet)
+{
+ gint w, h, bg_type;
+ GdkColor color;
+ GdkGC *gc;
+ GdkPixmap *background;
+ GtkAllocation allocation;
+
+ if (gtk_widget_get_window (GTK_WIDGET(applet)) == NULL) {
+ return FALSE;
+ }
+
+ /* retrieve applet size */
+ gpm_applet_get_icon (applet);
+ gpm_applet_check_size (applet);
+ if (applet->size <= 2) {
+ return FALSE;
+ }
+
+ /* if no icon, then don't try to display */
+ if (applet->icon == NULL) {
+ return FALSE;
+ }
+
+ gtk_widget_get_allocation (GTK_WIDGET (applet), &allocation);
+ w = allocation.width;
+ h = allocation.height;
+
+ gc = gdk_gc_new (gtk_widget_get_window (GTK_WIDGET(applet)));
+
+ /* draw pixmap background */
+ bg_type = mate_panel_applet_get_background (MATE_PANEL_APPLET (applet), &color, &background);
+ if (bg_type == PANEL_PIXMAP_BACKGROUND && !applet->popped) {
+ /* fill with given background pixmap */
+ gdk_draw_drawable (gtk_widget_get_window (GTK_WIDGET(applet)), gc, background, 0, 0, 0, 0, w, h);
+ }
+
+ /* draw color background */
+ if (bg_type == PANEL_COLOR_BACKGROUND && !applet->popped) {
+ gdk_gc_set_rgb_fg_color (gc,&color);
+ gdk_gc_set_fill (gc,GDK_SOLID);
+ gdk_draw_rectangle (gtk_widget_get_window (GTK_WIDGET(applet)), gc, TRUE, 0, 0, w, h);
+ }
+
+ /* fill with selected color if popped */
+ if (applet->popped) {
+ color = gtk_rc_get_style (GTK_WIDGET(applet))->bg[GTK_STATE_SELECTED];
+ gdk_gc_set_rgb_fg_color (gc,&color);
+ gdk_gc_set_fill (gc,GDK_SOLID);
+ gdk_draw_rectangle (gtk_widget_get_window (GTK_WIDGET(applet)), gc, TRUE, 0, 0, w, h);
+ }
+
+ /* draw icon at center */
+ gdk_draw_pixbuf (gtk_widget_get_window (GTK_WIDGET(applet)), gc, applet->icon,
+ 0, 0, (w - applet->icon_width)/2, (h - applet->icon_height)/2,
+ applet->icon_width, applet->icon_height,
+ GDK_RGB_DITHER_NONE, 0, 0);
+
+ g_object_unref (gc);
+
+ return TRUE;
+}
+
+/**
+ * gpm_applet_change_background_cb:
+ *
+ * Enqueues an expose event (don't know why it's not the default behaviour)
+ **/
+static void
+gpm_applet_change_background_cb (GpmBrightnessApplet *applet,
+ MatePanelAppletBackgroundType arg1,
+ GdkColor *arg2, GdkPixmap *arg3, gpointer data)
+{
+ gtk_widget_queue_draw (GTK_WIDGET (applet));
+}
+
+/**
+ * gpm_applet_destroy_popup_cb:
+ * @applet: Brightness applet instance
+ *
+ * destroys the popup (called if orientation has changed)
+ **/
+static gboolean
+gpm_applet_destroy_popup_cb (GpmBrightnessApplet *applet)
+{
+ if (applet->popup != NULL) {
+ gtk_widget_set_parent (applet->popup, NULL);
+ gtk_widget_destroy (applet->popup);
+ applet->popup = NULL;
+ }
+ return TRUE;
+}
+
+/**
+ * gpm_applet_update_tooltip:
+ * @applet: Brightness applet instance
+ *
+ * sets tooltip's content (percentage or disabled)
+ **/
+static void
+gpm_applet_update_tooltip (GpmBrightnessApplet *applet)
+{
+ gchar *buf = NULL;
+ if (applet->popped == FALSE) {
+ if (applet->proxy == NULL) {
+ buf = g_strdup (_("Cannot connect to mate-power-manager"));
+ } else if (applet->call_worked == FALSE) {
+ buf = g_strdup (_("Cannot get laptop panel brightness"));
+ } else {
+ buf = g_strdup_printf (_("LCD brightness : %d%%"), applet->level);
+ }
+ gtk_widget_set_tooltip_text (GTK_WIDGET(applet), buf);
+ } else {
+ gtk_widget_set_tooltip_text (GTK_WIDGET(applet), NULL);
+ }
+ g_free (buf);
+}
+
+/**
+ * gpm_applet_update_popup_level:
+ * @applet: Brightness applet instance
+ * @get_hw: set UI value from HW value
+ * @set_hw: set HW value from UI value
+ *
+ * updates popup and hardware level of brightness
+ * FALSE FAlSE -> set UI from cached value
+ * TRUE FAlSE -> set UI from HW value
+ * TRUE FALSE -> set HW from UI value, then set UI from HW value
+ * FALSE TRUE -> set HW from UI value
+ **/
+static void
+gpm_applet_update_popup_level (GpmBrightnessApplet *applet)
+{
+ if (applet->popup != NULL) {
+ gtk_widget_set_sensitive (applet->btn_plus, applet->level < 100);
+ gtk_widget_set_sensitive (applet->btn_minus, applet->level > 0);
+ gtk_range_set_value (GTK_RANGE(applet->slider), (guint) applet->level);
+ }
+ gpm_applet_update_tooltip (applet);
+}
+
+/**
+ * gpm_applet_plus_cb:
+ * @widget: The sending widget (plus button)
+ * @applet: Brightness applet instance
+ *
+ * callback for the plus button
+ **/
+static gboolean
+gpm_applet_plus_cb (GtkWidget *w, GpmBrightnessApplet *applet)
+{
+ if (applet->level < 100) {
+ applet->level++;
+ }
+ applet->call_worked = gpm_applet_set_brightness (applet);
+ gpm_applet_update_popup_level (applet);
+ return TRUE;
+}
+
+/**
+ * gpm_applet_minus_cb:
+ * @widget: The sending widget (minus button)
+ * @applet: Brightness applet instance
+ *
+ * callback for the minus button
+ **/
+static gboolean
+gpm_applet_minus_cb (GtkWidget *w, GpmBrightnessApplet *applet)
+{
+ if (applet->level > 0) {
+ applet->level--;
+ }
+ applet->call_worked = gpm_applet_set_brightness (applet);
+ gpm_applet_update_popup_level (applet);
+ return TRUE;
+}
+
+/**
+ * gpm_applet_slide_cb:
+ * @widget: The sending widget (slider)
+ * @applet: Brightness applet instance
+ *
+ * callback for the slider
+ **/
+static gboolean
+gpm_applet_slide_cb (GtkWidget *w, GpmBrightnessApplet *applet)
+{
+ applet->level = gtk_range_get_value (GTK_RANGE(applet->slider));
+ applet->call_worked = gpm_applet_set_brightness (applet);
+ gpm_applet_update_popup_level (applet);
+ return TRUE;
+}
+
+/**
+ * gpm_applet_slide_cb:
+ * @applet: Brightness applet instance
+ * @event: The key press event
+ *
+ * callback handling keyboard
+ * mainly escape to unpop and arrows to change brightness
+ **/
+static gboolean
+gpm_applet_key_press_cb (GpmBrightnessApplet *applet, GdkEventKey *event)
+{
+ int i;
+
+ switch (event->keyval) {
+ case GDK_KP_Enter:
+ case GDK_ISO_Enter:
+ case GDK_3270_Enter:
+ case GDK_Return:
+ case GDK_space:
+ case GDK_KP_Space:
+ case GDK_Escape:
+ /* if yet popped, release focus and hide then redraw applet unselected */
+ if (applet->popped) {
+ gdk_keyboard_ungrab (GDK_CURRENT_TIME);
+ gdk_pointer_ungrab (GDK_CURRENT_TIME);
+ gtk_grab_remove (GTK_WIDGET(applet));
+ gtk_widget_set_state (GTK_WIDGET(applet), GTK_STATE_NORMAL);
+ gtk_widget_hide (applet->popup);
+ applet->popped = FALSE;
+ gpm_applet_draw_cb (applet);
+ gpm_applet_update_tooltip (applet);
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ break;
+ case GDK_Page_Up:
+ for (i = 0;i < 10;i++) {
+ gpm_applet_plus_cb (NULL, applet);
+ }
+ return TRUE;
+ break;
+ case GDK_Left:
+ case GDK_Up:
+ gpm_applet_plus_cb (NULL, applet);
+ return TRUE;
+ break;
+ case GDK_Page_Down:
+ for (i = 0;i < 10;i++) {
+ gpm_applet_minus_cb (NULL, applet);
+ }
+ return TRUE;
+ break;
+ case GDK_Right:
+ case GDK_Down:
+ gpm_applet_minus_cb (NULL, applet);
+ return TRUE;
+ break;
+ default:
+ return FALSE;
+ break;
+ }
+
+ return FALSE;
+}
+
+/**
+ * gpm_applet_scroll_cb:
+ * @applet: Brightness applet instance
+ * @event: The scroll event
+ *
+ * callback handling mouse scrolls, either when the applet
+ * is not popped and the mouse is over the applet, or when
+ * the applet is popped and no matter where the mouse is.
+ **/
+static gboolean
+gpm_applet_scroll_cb (GpmBrightnessApplet *applet, GdkEventScroll *event)
+{
+ int i;
+
+ if (event->type == GDK_SCROLL) {
+ if (event->direction == GDK_SCROLL_UP) {
+ for (i = 0;i < 5;i++) {
+ gpm_applet_plus_cb (NULL, applet);
+ }
+
+ } else {
+ for (i = 0;i < 5;i++) {
+ gpm_applet_minus_cb (NULL, applet);
+ }
+ }
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ * gpm_applet_create_popup:
+ * @applet: Brightness applet instance
+ *
+ * cretes a new popup according to orientation of panel
+ **/
+static void
+gpm_applet_create_popup (GpmBrightnessApplet *applet)
+{
+ static GtkWidget *box, *frame;
+ gint orientation = mate_panel_applet_get_orient (MATE_PANEL_APPLET (MATE_PANEL_APPLET (applet)));
+
+ gpm_applet_destroy_popup_cb (applet);
+
+ /* slider */
+ if (MATE_PANEL_APPLET_VERTICAL(orientation)) {
+ applet->slider = gtk_hscale_new_with_range (0, 100, 1);
+ gtk_widget_set_size_request (applet->slider, 100, -1);
+ } else {
+ applet->slider = gtk_vscale_new_with_range (0, 100, 1);
+ gtk_widget_set_size_request (applet->slider, -1, 100);
+ }
+ gtk_range_set_inverted (GTK_RANGE(applet->slider), TRUE);
+ gtk_scale_set_draw_value (GTK_SCALE(applet->slider), FALSE);
+ gtk_range_set_value (GTK_RANGE(applet->slider), applet->level);
+ g_signal_connect (G_OBJECT(applet->slider), "value-changed", G_CALLBACK(gpm_applet_slide_cb), applet);
+
+ /* minus button */
+ applet->btn_minus = gtk_button_new_with_label ("\342\210\222"); /* U+2212 MINUS SIGN */
+ gtk_button_set_relief (GTK_BUTTON(applet->btn_minus), GTK_RELIEF_NONE);
+ g_signal_connect (G_OBJECT(applet->btn_minus), "pressed", G_CALLBACK(gpm_applet_minus_cb), applet);
+
+ /* plus button */
+ applet->btn_plus = gtk_button_new_with_label ("+");
+ gtk_button_set_relief (GTK_BUTTON(applet->btn_plus), GTK_RELIEF_NONE);
+ g_signal_connect (G_OBJECT(applet->btn_plus), "pressed", G_CALLBACK(gpm_applet_plus_cb), applet);
+
+ /* box */
+ if (MATE_PANEL_APPLET_VERTICAL(orientation)) {
+ box = gtk_hbox_new (FALSE, 1);
+ } else {
+ box = gtk_vbox_new (FALSE, 1);
+ }
+ gtk_box_pack_start (GTK_BOX(box), applet->btn_plus, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(box), applet->slider, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX(box), applet->btn_minus, FALSE, FALSE, 0);
+
+ /* frame */
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_OUT);
+ gtk_container_add (GTK_CONTAINER(frame), box);
+
+ /* window */
+ applet->popup = gtk_window_new (GTK_WINDOW_POPUP);
+ gtk_window_set_type_hint (GTK_WINDOW(applet->popup), GDK_WINDOW_TYPE_HINT_UTILITY);
+ gtk_widget_set_parent (applet->popup, GTK_WIDGET(applet));
+ gtk_container_add (GTK_CONTAINER(applet->popup), frame);
+}
+
+/**
+ * gpm_applet_popup_cb:
+ * @applet: Brightness applet instance
+ *
+ * pops and unpops
+ **/
+static gboolean
+gpm_applet_popup_cb (GpmBrightnessApplet *applet, GdkEventButton *event)
+{
+ GtkAllocation allocation, popup_allocation;
+ gint orientation, x, y;
+
+ /* react only to left mouse button */
+ if (event->button != 1) {
+ return FALSE;
+ }
+
+ /* if yet popped, release focus and hide then redraw applet unselected */
+ if (applet->popped) {
+ gdk_keyboard_ungrab (GDK_CURRENT_TIME);
+ gdk_pointer_ungrab (GDK_CURRENT_TIME);
+ gtk_grab_remove (GTK_WIDGET(applet));
+ gtk_widget_set_state (GTK_WIDGET(applet), GTK_STATE_NORMAL);
+ gtk_widget_hide (applet->popup);
+ applet->popped = FALSE;
+ gpm_applet_draw_cb (applet);
+ gpm_applet_update_tooltip (applet);
+ return TRUE;
+ }
+
+ /* update UI for current brightness */
+ gpm_applet_update_popup_level (applet);
+
+ /* otherwise pop */
+ applet->popped = TRUE;
+ gpm_applet_draw_cb (applet);
+
+ /* create a new popup (initial or if panel parameters changed) */
+ if (applet->popup == NULL) {
+ gpm_applet_create_popup (applet);
+ }
+
+ /* update UI for current brightness */
+ gpm_applet_update_popup_level (applet);
+
+ gtk_widget_show_all (applet->popup);
+
+ /* retrieve geometry parameters and move window appropriately */
+ orientation = mate_panel_applet_get_orient (MATE_PANEL_APPLET (MATE_PANEL_APPLET (applet)));
+ gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET(applet)), &x, &y);
+
+ gtk_widget_get_allocation (GTK_WIDGET (applet), &allocation);
+ gtk_widget_get_allocation (GTK_WIDGET (applet->popup), &popup_allocation);
+ switch (orientation) {
+ case MATE_PANEL_APPLET_ORIENT_DOWN:
+ x += allocation.x + allocation.width/2;
+ y += allocation.y + allocation.height;
+ x -= popup_allocation.width/2;
+ break;
+ case MATE_PANEL_APPLET_ORIENT_UP:
+ x += allocation.x + allocation.width/2;
+ y += allocation.y;
+ x -= popup_allocation.width/2;
+ y -= popup_allocation.height;
+ break;
+ case MATE_PANEL_APPLET_ORIENT_RIGHT:
+ y += allocation.y + allocation.height/2;
+ x += allocation.x + allocation.width;
+ y -= popup_allocation.height/2;
+ break;
+ case MATE_PANEL_APPLET_ORIENT_LEFT:
+ y += allocation.y + allocation.height/2;
+ x += allocation.x;
+ x -= popup_allocation.width;
+ y -= popup_allocation.height/2;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ gtk_window_move (GTK_WINDOW (applet->popup), x, y);
+
+ /* grab input */
+ gtk_widget_grab_focus (GTK_WIDGET(applet));
+ gtk_grab_add (GTK_WIDGET(applet));
+ gdk_pointer_grab (gtk_widget_get_window (GTK_WIDGET(applet)), TRUE,
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK,
+ NULL, NULL, GDK_CURRENT_TIME);
+ gdk_keyboard_grab (gtk_widget_get_window (GTK_WIDGET(applet)),
+ TRUE, GDK_CURRENT_TIME);
+ gtk_widget_set_state (GTK_WIDGET(applet), GTK_STATE_SELECTED);
+
+ return TRUE;
+}
+
+/**
+ * gpm_applet_theme_change_cb:
+ *
+ * Updtes icon when theme changes
+ **/
+static void
+gpm_applet_theme_change_cb (GtkIconTheme *icon_theme, gpointer data)
+{
+ GpmBrightnessApplet *applet = GPM_BRIGHTNESS_APPLET (data);
+ gpm_applet_get_icon (applet);
+}
+
+/**
+ * gpm_applet_stop_scroll_events_cb:
+ *
+ * Prevents scroll events from reaching the tooltip
+ **/
+static void
+gpm_applet_stop_scroll_events_cb (GtkWidget *widget, GdkEvent *event)
+{
+ if (event->type == GDK_SCROLL)
+ g_signal_stop_emission_by_name (widget, "event-after");
+}
+
+/**
+ * gpm_applet_dialog_about_cb:
+ *
+ * displays about dialog
+ **/
+static void
+gpm_applet_dialog_about_cb (MateComponentUIComponent *uic, gpointer data, const gchar *verbname)
+{
+ GtkAboutDialog *about;
+
+ GdkPixbuf *logo =
+ gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ GPM_BRIGHTNESS_APPLET_ICON,
+ 128, 0, NULL);
+
+ static const gchar *authors[] = {
+ "Benjamin Canou <[email protected]>",
+ "Richard Hughes <[email protected]>",
+ NULL
+ };
+ const char *documenters [] = {
+ NULL
+ };
+ const char *license[] = {
+ N_("Licensed under the GNU General Public License Version 2"),
+ N_("Power Manager is free software; you can redistribute it and/or\n"
+ "modify it under the terms of the GNU General Public License\n"
+ "as published by the Free Software Foundation; either version 2\n"
+ "of the License, or (at your option) any later version."),
+ N_("Power Manager is distributed in the hope that it will be useful,\n"
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
+ "GNU General Public License for more details."),
+ N_("You should have received a copy of the GNU General Public License\n"
+ "along with this program; if not, write to the Free Software\n"
+ "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\n"
+ "02110-1301, USA.")
+ };
+ const char *translator_credits = NULL;
+ char *license_trans;
+
+ license_trans = g_strconcat (_(license[0]), "\n\n", _(license[1]), "\n\n",
+ _(license[2]), "\n\n", _(license[3]), "\n", NULL);
+
+ about = (GtkAboutDialog*) gtk_about_dialog_new ();
+ gtk_about_dialog_set_program_name (about, GPM_BRIGHTNESS_APPLET_NAME);
+ gtk_about_dialog_set_version (about, VERSION);
+ gtk_about_dialog_set_copyright (about, _("Copyright \xc2\xa9 2006 Benjamin Canou"));
+ gtk_about_dialog_set_comments (about, GPM_BRIGHTNESS_APPLET_DESC);
+ gtk_about_dialog_set_authors (about, authors);
+ gtk_about_dialog_set_documenters (about, documenters);
+ gtk_about_dialog_set_translator_credits (about, translator_credits);
+ gtk_about_dialog_set_logo (about, logo);
+ gtk_about_dialog_set_license (about, license_trans);
+ gtk_about_dialog_set_website (about, GPM_HOMEPAGE_URL);
+
+ g_signal_connect (G_OBJECT(about), "response",
+ G_CALLBACK(gtk_widget_destroy), NULL);
+
+ gtk_widget_show (GTK_WIDGET(about));
+
+ g_free (license_trans);
+ g_object_unref (logo);
+}
+
+/**
+ * gpm_applet_help_cb:
+ *
+ * open gpm help
+ **/
+static void
+gpm_applet_help_cb (MateComponentUIComponent *uic, gpointer data, const gchar *verbname)
+{
+ gpm_help_display ("applets-brightness");
+}
+
+/**
+ * gpm_applet_destroy_cb:
+ * @object: Class instance to destroy
+ **/
+static void
+gpm_applet_destroy_cb (GtkObject *object)
+{
+ GpmBrightnessApplet *applet = GPM_BRIGHTNESS_APPLET(object);
+
+ if (applet->monitor != NULL) {
+ g_object_unref (applet->monitor);
+ }
+ if (applet->icon != NULL) {
+ g_object_unref (applet->icon);
+ }
+}
+
+/**
+ * gpm_brightness_applet_class_init:
+ * @klass: Class instance
+ **/
+static void
+gpm_brightness_applet_class_init (GpmBrightnessAppletClass *class)
+{
+ /* nothing to do here */
+}
+
+static void
+brightness_changed_cb (DBusGProxy *proxy,
+ guint brightness,
+ GpmBrightnessApplet *applet)
+{
+ egg_debug ("BrightnessChanged detected: %i\n", brightness);
+ applet->level = brightness;
+}
+
+/**
+ * gpm_brightness_applet_dbus_connect:
+ **/
+gboolean
+gpm_brightness_applet_dbus_connect (GpmBrightnessApplet *applet)
+{
+ GError *error = NULL;
+
+ if (applet->connection == NULL) {
+ egg_debug ("get connection\n");
+ g_clear_error (&error);
+ applet->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (error != NULL) {
+ egg_warning ("Could not connect to DBUS daemon: %s", error->message);
+ g_error_free (error);
+ applet->connection = NULL;
+ return FALSE;
+ }
+ }
+ if (applet->proxy == NULL) {
+ egg_debug ("get proxy\n");
+ g_clear_error (&error);
+ applet->proxy = dbus_g_proxy_new_for_name_owner (applet->connection,
+ GPM_DBUS_SERVICE,
+ GPM_DBUS_PATH_BACKLIGHT,
+ GPM_DBUS_INTERFACE_BACKLIGHT,
+ &error);
+ if (error != NULL) {
+ egg_warning ("Cannot connect, maybe the daemon is not running: %s\n", error->message);
+ g_error_free (error);
+ applet->proxy = NULL;
+ return FALSE;
+ }
+ dbus_g_proxy_add_signal (applet->proxy, "BrightnessChanged",
+ G_TYPE_UINT, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (applet->proxy, "BrightnessChanged",
+ G_CALLBACK (brightness_changed_cb),
+ applet, NULL);
+ /* reset, we might be starting race */
+ applet->call_worked = gpm_applet_get_brightness (applet);
+ }
+ return TRUE;
+}
+
+/**
+ * gpm_brightness_applet_dbus_disconnect:
+ **/
+gboolean
+gpm_brightness_applet_dbus_disconnect (GpmBrightnessApplet *applet)
+{
+ if (applet->proxy != NULL) {
+ egg_debug ("removing proxy\n");
+ g_object_unref (applet->proxy);
+ applet->proxy = NULL;
+ }
+ return TRUE;
+}
+
+/**
+ * monitor_connection_cb:
+ * @proxy: The dbus raw proxy
+ * @status: The status of the service, where TRUE is connected
+ * @screensaver: This class instance
+ **/
+static void
+monitor_connection_cb (EggDbusMonitor *monitor,
+ gboolean status,
+ GpmBrightnessApplet *applet)
+{
+ if (status) {
+ gpm_brightness_applet_dbus_connect (applet);
+ gpm_applet_update_tooltip (applet);
+ gpm_applet_draw_cb (applet);
+ } else {
+ gpm_brightness_applet_dbus_disconnect (applet);
+ gpm_applet_update_tooltip (applet);
+ gpm_applet_draw_cb (applet);
+ }
+}
+
+/**
+ * gpm_brightness_applet_init:
+ * @applet: Brightness applet instance
+ **/
+static void
+gpm_brightness_applet_init (GpmBrightnessApplet *applet)
+{
+ DBusGConnection *connection;
+
+ /* initialize fields */
+ applet->size = 0;
+ applet->call_worked = TRUE;
+ applet->popped = FALSE;
+ applet->popup = NULL;
+ applet->icon = NULL;
+ applet->connection = NULL;
+ applet->proxy = NULL;
+
+ /* Add application specific icons to search path */
+ gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+ GPM_DATA G_DIR_SEPARATOR_S "icons");
+
+
+ applet->monitor = egg_dbus_monitor_new ();
+ g_signal_connect (applet->monitor, "connection-changed",
+ G_CALLBACK (monitor_connection_cb), applet);
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+ egg_dbus_monitor_assign (applet->monitor, connection, GPM_DBUS_SERVICE);
+ gpm_brightness_applet_dbus_connect (applet);
+
+ /* coldplug */
+ applet->call_worked = gpm_applet_get_brightness (applet);
+ gpm_applet_update_popup_level (applet);
+
+ /* prepare */
+ mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet), MATE_PANEL_APPLET_EXPAND_MINOR);
+
+ /* show */
+ gtk_widget_show_all (GTK_WIDGET(applet));
+
+ /* set appropriate size and load icon accordingly */
+ gpm_applet_draw_cb (applet);
+
+ /* connect */
+ g_signal_connect (G_OBJECT(applet), "button-press-event",
+ G_CALLBACK(gpm_applet_popup_cb), NULL);
+
+ g_signal_connect (G_OBJECT(applet), "scroll-event",
+ G_CALLBACK(gpm_applet_scroll_cb), NULL);
+
+ g_signal_connect (G_OBJECT(applet), "key-press-event",
+ G_CALLBACK(gpm_applet_key_press_cb), NULL);
+
+ /* We use g_signal_connect_after because letting the panel draw
+ * the background is the only way to have the correct
+ * background when a theme defines a background picture. */
+ g_signal_connect_after (G_OBJECT(applet), "expose-event",
+ G_CALLBACK(gpm_applet_draw_cb), NULL);
+
+ g_signal_connect (G_OBJECT(applet), "change-background",
+ G_CALLBACK(gpm_applet_change_background_cb), NULL);
+
+ g_signal_connect (G_OBJECT(applet), "change-orient",
+ G_CALLBACK(gpm_applet_draw_cb), NULL);
+
+ g_signal_connect (G_OBJECT(applet), "change-orient",
+ G_CALLBACK(gpm_applet_destroy_popup_cb), NULL);
+
+ g_signal_connect (G_OBJECT(applet), "destroy",
+ G_CALLBACK(gpm_applet_destroy_cb), NULL);
+
+ /* prevent scroll events from reaching the tooltip */
+ g_signal_connect (G_OBJECT (applet), "event-after", G_CALLBACK (gpm_applet_stop_scroll_events_cb), NULL);
+
+ g_signal_connect (gtk_icon_theme_get_default (), "changed", G_CALLBACK (gpm_applet_theme_change_cb), applet);
+}
+
+/**
+ * gpm_applet_matecomponent_cb:
+ * @_applet: GpmBrightnessApplet instance created by the matecomponent factory
+ * @iid: MateComponent id
+ *
+ * the function called by matecomponent factory after creation
+ **/
+static gboolean
+gpm_applet_matecomponent_cb (MatePanelApplet *_applet, const gchar *iid, gpointer data)
+{
+ GpmBrightnessApplet *applet = GPM_BRIGHTNESS_APPLET(_applet);
+
+ static MateComponentUIVerb verbs [] = {
+ MATECOMPONENT_UI_VERB ("About", gpm_applet_dialog_about_cb),
+ MATECOMPONENT_UI_VERB ("Help", gpm_applet_help_cb),
+ MATECOMPONENT_UI_VERB_END
+ };
+
+ if (strcmp (iid, GPM_BRIGHTNESS_APPLET_OAFID) != 0) {
+ return FALSE;
+ }
+
+ mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (applet),
+ DATADIR,
+ "MATE_BrightnessApplet.xml",
+ NULL, verbs, applet);
+ gpm_applet_draw_cb (applet);
+ return TRUE;
+}
+
+/**
+ * this generates a main with a matecomponent factory
+ **/
+MATE_PANEL_APPLET_MATECOMPONENT_FACTORY
+ (/* the factory iid */
+ GPM_BRIGHTNESS_APPLET_FACTORY_OAFID,
+ /* generates brighness applets instead of regular mate applets */
+ GPM_TYPE_BRIGHTNESS_APPLET,
+ /* the applet name and version */
+ "BrightnessApplet", VERSION,
+ /* our callback (with no user data) */
+ gpm_applet_matecomponent_cb, NULL);
diff --git a/applets/brightness/egg-dbus-monitor.c b/applets/brightness/egg-dbus-monitor.c
new file mode 100644
index 0000000..b8238d1
--- /dev/null
+++ b/applets/brightness/egg-dbus-monitor.c
@@ -0,0 +1,251 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2008 Richard Hughes <[email protected]>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <dbus/dbus.h>
+
+#include "egg-debug.h"
+#include "egg-dbus-monitor.h"
+
+static void egg_dbus_monitor_finalize (GObject *object);
+
+#define EGG_DBUS_MONITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorPrivate))
+
+struct EggDbusMonitorPrivate
+{
+ gchar *service;
+ DBusGProxy *proxy;
+ DBusGConnection *connection;
+ const gchar *unique_name;
+};
+
+enum {
+ EGG_DBUS_MONITOR_CONNECTION_CHANGED,
+ EGG_DBUS_MONITOR_CONNECTION_REPLACED,
+ EGG_DBUS_MONITOR_LAST_SIGNAL
+};
+
+static guint signals [EGG_DBUS_MONITOR_LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (EggDbusMonitor, egg_dbus_monitor, G_TYPE_OBJECT)
+
+/**
+ * egg_dbus_monitor_name_owner_changed_cb:
+ **/
+static void
+egg_dbus_monitor_name_owner_changed_cb (DBusGProxy *proxy, const gchar *name,
+ const gchar *prev, const gchar *new,
+ EggDbusMonitor *monitor)
+{
+ guint new_len;
+ guint prev_len;
+
+ g_return_if_fail (EGG_IS_DBUS_MONITOR (monitor));
+ if (monitor->priv->proxy == NULL)
+ return;
+
+ /* not us */
+ if (strcmp (name, monitor->priv->service) != 0)
+ return;
+
+ /* ITS4: ignore, not used for allocation */
+ new_len = strlen (new);
+ /* ITS4: ignore, not used for allocation */
+ prev_len = strlen (prev);
+
+ /* something --> nothing */
+ if (prev_len != 0 && new_len == 0) {
+ g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, FALSE);
+ return;
+ }
+
+ /* nothing --> something */
+ if (prev_len == 0 && new_len != 0) {
+ g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, TRUE);
+ return;
+ }
+
+ /* something --> something (we've replaced the old process) */
+ if (prev_len != 0 && new_len != 0) {
+ /* only send this to the prev client */
+ if (strcmp (monitor->priv->unique_name, prev) == 0)
+ g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_REPLACED], 0);
+ return;
+ }
+}
+
+/**
+ * egg_dbus_monitor_assign:
+ * @monitor: This class instance
+ * @connection: The bus connection
+ * @service: The EGG_DBUS_MONITOR service name
+ * Return value: success
+ *
+ * Emits connection-changed(TRUE) if connection is alive - this means you
+ * have to connect up the callback before this function is called.
+ **/
+gboolean
+egg_dbus_monitor_assign (EggDbusMonitor *monitor, DBusGConnection *connection, const gchar *service)
+{
+ GError *error = NULL;
+ gboolean connected;
+ DBusConnection *conn;
+
+ g_return_val_if_fail (EGG_IS_DBUS_MONITOR (monitor), FALSE);
+ g_return_val_if_fail (service != NULL, FALSE);
+ g_return_val_if_fail (connection != NULL, FALSE);
+
+ if (monitor->priv->proxy != NULL) {
+ egg_warning ("already assigned!");
+ return FALSE;
+ }
+
+ monitor->priv->service = g_strdup (service);
+ monitor->priv->connection = connection;
+ monitor->priv->proxy = dbus_g_proxy_new_for_name_owner (monitor->priv->connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ &error);
+ if (error != NULL) {
+ egg_warning ("Cannot connect to DBUS: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+ dbus_g_proxy_add_signal (monitor->priv->proxy, "NameOwnerChanged",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (monitor->priv->proxy, "NameOwnerChanged",
+ G_CALLBACK (egg_dbus_monitor_name_owner_changed_cb),
+ monitor, NULL);
+
+ /* coldplug */
+ connected = egg_dbus_monitor_is_connected (monitor);
+ if (connected)
+ g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, TRUE);
+
+ /* save this for the replaced check */
+ conn = dbus_g_connection_get_connection (monitor->priv->connection);
+ monitor->priv->unique_name = dbus_bus_get_unique_name (conn);
+ return TRUE;
+}
+
+/**
+ * egg_dbus_monitor_is_connected:
+ * @monitor: This class instance
+ * Return value: if we are connected to a valid watch
+ **/
+gboolean
+egg_dbus_monitor_is_connected (EggDbusMonitor *monitor)
+{
+ DBusError error;
+ DBusConnection *conn;
+ gboolean ret;
+ g_return_val_if_fail (EGG_IS_DBUS_MONITOR (monitor), FALSE);
+
+ /* get raw connection */
+ conn = dbus_g_connection_get_connection (monitor->priv->connection);
+ dbus_error_init (&error);
+ ret = dbus_bus_name_has_owner (conn, monitor->priv->service, &error);
+ if (dbus_error_is_set (&error)) {
+ egg_debug ("error: %s", error.message);
+ dbus_error_free (&error);
+ }
+
+ return ret;
+}
+
+/**
+ * egg_dbus_monitor_class_init:
+ * @klass: The EggDbusMonitorClass
+ **/
+static void
+egg_dbus_monitor_class_init (EggDbusMonitorClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = egg_dbus_monitor_finalize;
+ g_type_class_add_private (klass, sizeof (EggDbusMonitorPrivate));
+ signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED] =
+ g_signal_new ("connection-changed",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggDbusMonitorClass, connection_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ signals [EGG_DBUS_MONITOR_CONNECTION_REPLACED] =
+ g_signal_new ("connection-replaced",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggDbusMonitorClass, connection_replaced),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
+
+/**
+ * egg_dbus_monitor_init:
+ * @monitor: This class instance
+ **/
+static void
+egg_dbus_monitor_init (EggDbusMonitor *monitor)
+{
+ monitor->priv = EGG_DBUS_MONITOR_GET_PRIVATE (monitor);
+ monitor->priv->service = NULL;
+ monitor->priv->connection = NULL;
+ monitor->priv->proxy = NULL;
+}
+
+/**
+ * egg_dbus_monitor_finalize:
+ * @object: The object to finalize
+ **/
+static void
+egg_dbus_monitor_finalize (GObject *object)
+{
+ EggDbusMonitor *monitor;
+
+ g_return_if_fail (EGG_IS_DBUS_MONITOR (object));
+
+ monitor = EGG_DBUS_MONITOR (object);
+
+ g_return_if_fail (monitor->priv != NULL);
+ if (monitor->priv->proxy != NULL)
+ g_object_unref (monitor->priv->proxy);
+
+ G_OBJECT_CLASS (egg_dbus_monitor_parent_class)->finalize (object);
+}
+
+/**
+ * egg_dbus_monitor_new:
+ *
+ * Return value: a new EggDbusMonitor object.
+ **/
+EggDbusMonitor *
+egg_dbus_monitor_new (void)
+{
+ EggDbusMonitor *monitor;
+ monitor = g_object_new (EGG_TYPE_DBUS_MONITOR, NULL);
+ return EGG_DBUS_MONITOR (monitor);
+}
+
diff --git a/applets/brightness/egg-dbus-monitor.h b/applets/brightness/egg-dbus-monitor.h
new file mode 100644
index 0000000..9efa8b9
--- /dev/null
+++ b/applets/brightness/egg-dbus-monitor.h
@@ -0,0 +1,65 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <[email protected]>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __EGG_DBUS_MONITOR_H
+#define __EGG_DBUS_MONITOR_H
+
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#define EGG_TYPE_DBUS_MONITOR (egg_dbus_monitor_get_type ())
+#define EGG_DBUS_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitor))
+#define EGG_DBUS_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorClass))
+#define EGG_IS_DBUS_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGG_TYPE_DBUS_MONITOR))
+#define EGG_IS_DBUS_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGG_TYPE_DBUS_MONITOR))
+#define EGG_DBUS_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorClass))
+#define EGG_DBUS_MONITOR_ERROR (egg_dbus_monitor_error_quark ())
+#define EGG_DBUS_MONITOR_TYPE_ERROR (egg_dbus_monitor_error_get_type ())
+
+typedef struct EggDbusMonitorPrivate EggDbusMonitorPrivate;
+
+typedef struct
+{
+ GObject parent;
+ EggDbusMonitorPrivate *priv;
+} EggDbusMonitor;
+
+typedef struct
+{
+ GObjectClass parent_class;
+ void (* connection_changed) (EggDbusMonitor *watch,
+ gboolean connected);
+ void (* connection_replaced) (EggDbusMonitor *watch);
+} EggDbusMonitorClass;
+
+GType egg_dbus_monitor_get_type (void);
+EggDbusMonitor *egg_dbus_monitor_new (void);
+gboolean egg_dbus_monitor_assign (EggDbusMonitor *monitor,
+ DBusGConnection *connection,
+ const gchar *service);
+gboolean egg_dbus_monitor_is_connected (EggDbusMonitor *monitor);
+
+G_END_DECLS
+
+#endif /* __EGG_DBUS_MONITOR_H */
+
diff --git a/applets/brightness/egg-debug.c b/applets/brightness/egg-debug.c
new file mode 100644
index 0000000..2f140f2
--- /dev/null
+++ b/applets/brightness/egg-debug.c
@@ -0,0 +1,308 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <[email protected]>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/**
+ * SECTION:egg-debug
+ * @short_description: Debugging functions
+ *
+ * This file contains functions that can be used for debugging.
+ */
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib/gprintf.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <time.h>
+#include <execinfo.h>
+
+#include "egg-debug.h"
+
+#define CONSOLE_RESET 0
+#define CONSOLE_BLACK 30
+#define CONSOLE_RED 31
+#define CONSOLE_GREEN 32
+#define CONSOLE_YELLOW 33
+#define CONSOLE_BLUE 34
+#define CONSOLE_MAGENTA 35
+#define CONSOLE_CYAN 36
+#define CONSOLE_WHITE 37
+
+static gint fd = -1;
+
+/**
+ * pk_set_console_mode:
+ **/
+static void
+pk_set_console_mode (guint console_code)
+{
+ gchar command[13];
+
+ /* don't put extra commands into logs */
+ if (!egg_debug_is_console ())
+ return;
+
+ /* Command is the control command to the terminal */
+ g_snprintf (command, 13, "%c[%dm", 0x1B, console_code);
+ printf ("%s", command);
+}
+
+/**
+ * egg_debug_backtrace:
+ **/
+void
+egg_debug_backtrace (void)
+{
+ void *call_stack[512];
+ int call_stack_size;
+ char **symbols;
+ int i = 1;
+
+ call_stack_size = backtrace (call_stack, G_N_ELEMENTS (call_stack));
+ symbols = backtrace_symbols (call_stack, call_stack_size);
+ if (symbols != NULL) {
+ pk_set_console_mode (CONSOLE_RED);
+ g_print ("Traceback:\n");
+ while (i < call_stack_size) {
+ g_print ("\t%s\n", symbols[i]);
+ i++;
+ }
+ pk_set_console_mode (CONSOLE_RESET);
+ free (symbols);
+ }
+}
+
+/**
+ * pk_log_line:
+ **/
+static void
+pk_log_line (const gchar *buffer)
+{
+ ssize_t count;
+ /* open a file */
+ if (fd == -1) {
+ /* ITS4: ignore, /var/log/foo is owned by root, and this is just debug text */
+ fd = open (EGG_LOG_FILE, O_WRONLY|O_APPEND|O_CREAT, 0777);
+ if (fd == -1)
+ g_error ("could not open log: '%s'", EGG_LOG_FILE);
+ }
+
+ /* ITS4: ignore, debug text always NULL terminated */
+ count = write (fd, buffer, strlen (buffer));
+ if (count == -1)
+ g_warning ("could not write %s", buffer);
+ /* newline */
+ count = write (fd, "\n", 1);
+ if (count == -1)
+ g_warning ("could not write newline");
+}
+
+/**
+ * pk_print_line:
+ **/
+static void
+pk_print_line (const gchar *func, const gchar *file, const int line, const gchar *buffer, guint color)
+{
+ gchar *str_time;
+ gchar *header;
+ time_t the_time;
+ GThread *thread;
+
+ time (&the_time);
+ str_time = g_new0 (gchar, 255);
+ strftime (str_time, 254, "%H:%M:%S", localtime (&the_time));
+ thread = g_thread_self ();
+
+ /* generate header text */
+ header = g_strdup_printf ("TI:%s\tTH:%p\tFI:%s\tFN:%s,%d", str_time, thread, file, func, line);
+ g_free (str_time);
+
+ /* always in light green */
+ pk_set_console_mode (CONSOLE_GREEN);
+ printf ("%s\n", header);
+
+ /* different colors according to the severity */
+ pk_set_console_mode (color);
+ printf (" - %s\n", buffer);
+ pk_set_console_mode (CONSOLE_RESET);
+
+ /* log to a file */
+ if (egg_debug_is_logging ()) {
+ pk_log_line (header);
+ pk_log_line (buffer);
+ }
+
+ /* flush this output, as we need to debug */
+ fflush (stdout);
+
+ g_free (header);
+}
+
+/**
+ * egg_debug_real:
+ **/
+void
+egg_debug_real (const gchar *func, const gchar *file, const int line, const gchar *format, ...)
+{
+ va_list args;
+ gchar *buffer = NULL;
+
+ if (!egg_debug_enabled ())
+ return;
+
+ va_start (args, format);
+ g_vasprintf (&buffer, format, args);
+ va_end (args);
+
+ pk_print_line (func, file, line, buffer, CONSOLE_BLUE);
+
+ g_free(buffer);
+}
+
+/**
+ * egg_warning_real:
+ **/
+void
+egg_warning_real (const gchar *func, const gchar *file, const int line, const gchar *format, ...)
+{
+ va_list args;
+ gchar *buffer = NULL;
+
+ if (!egg_debug_enabled ())
+ return;
+
+ va_start (args, format);
+ g_vasprintf (&buffer, format, args);
+ va_end (args);
+
+ /* do extra stuff for a warning */
+ if (!egg_debug_is_console ())
+ printf ("*** WARNING ***\n");
+ pk_print_line (func, file, line, buffer, CONSOLE_RED);
+
+ g_free(buffer);
+}
+
+/**
+ * egg_error_real:
+ **/
+void
+egg_error_real (const gchar *func, const gchar *file, const int line, const gchar *format, ...)
+{
+ va_list args;
+ gchar *buffer = NULL;
+
+ va_start (args, format);
+ g_vasprintf (&buffer, format, args);
+ va_end (args);
+
+ /* do extra stuff for a warning */
+ if (!egg_debug_is_console ())
+ printf ("*** ERROR ***\n");
+ pk_print_line (func, file, line, buffer, CONSOLE_RED);
+ g_free(buffer);
+
+ /* we want to fix this! */
+ egg_debug_backtrace ();
+
+ exit (1);
+}
+
+/**
+ * egg_debug_enabled:
+ *
+ * Returns: TRUE if we have debugging enabled
+ **/
+gboolean
+egg_debug_enabled (void)
+{
+ const gchar *env;
+ env = g_getenv (EGG_VERBOSE);
+ return (g_strcmp0 (env, "1") == 0);
+}
+
+/**
+ * egg_debug_is_logging:
+ *
+ * Returns: TRUE if we have logging enabled
+ **/
+gboolean
+egg_debug_is_logging (void)
+{
+ const gchar *env;
+ env = g_getenv (EGG_LOGGING);
+ return (g_strcmp0 (env, "1") == 0);
+}
+
+/**
+ * egg_debug_is_console:
+ *
+ * Returns: TRUE if we have debugging enabled
+ **/
+gboolean
+egg_debug_is_console (void)
+{
+ const gchar *env;
+ env = g_getenv (EGG_CONSOLE);
+ return (g_strcmp0 (env, "1") == 0);
+}
+
+/**
+ * egg_debug_set_logging:
+ **/
+void
+egg_debug_set_logging (gboolean enabled)
+{
+ if (enabled)
+ g_setenv (EGG_LOGGING, "1", TRUE);
+ else
+ g_setenv (EGG_LOGGING, "0", TRUE);
+
+ if (egg_debug_is_logging ())
+ egg_debug ("logging to %s", EGG_LOG_FILE);
+}
+
+/**
+ * egg_debug_init:
+ * @debug: If we should print out verbose logging
+ **/
+void
+egg_debug_init (gboolean debug)
+{
+ /* check if we are on console */
+ if (isatty (fileno (stdout)) == 1)
+ g_setenv (EGG_CONSOLE, "1", FALSE);
+ else
+ g_setenv (EGG_CONSOLE, "0", FALSE);
+ if (debug)
+ g_setenv (EGG_VERBOSE, "1", FALSE);
+ else
+ g_setenv (EGG_VERBOSE, "0", FALSE);
+ egg_debug ("Verbose debugging %i (on console %i)%s", egg_debug_enabled (), egg_debug_is_console (), EGG_VERBOSE);
+}
+
diff --git a/applets/brightness/egg-debug.h b/applets/brightness/egg-debug.h
new file mode 100644
index 0000000..fdfb02b
--- /dev/null
+++ b/applets/brightness/egg-debug.h
@@ -0,0 +1,83 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <[email protected]>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __EGG_DEBUG_H
+#define __EGG_DEBUG_H
+
+#include <stdarg.h>
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+/**
+ * egg_debug:
+ *
+ * Non critical debugging
+ */
+#define egg_debug(...) egg_debug_real (__func__, __FILE__, __LINE__, __VA_ARGS__)
+
+/**
+ * egg_warning:
+ *
+ * Important debugging
+ */
+#define egg_warning(...) egg_warning_real (__func__, __FILE__, __LINE__, __VA_ARGS__)
+
+/**
+ * egg_error:
+ *
+ * Critical debugging, with exit
+ */
+#define egg_error(...) egg_error_real (__func__, __FILE__, __LINE__, __VA_ARGS__)
+
+#elif defined(__GNUC__) && __GNUC__ >= 3
+#define egg_debug(...) egg_debug_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
+#define egg_warning(...) egg_warning_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
+#define egg_error(...) egg_error_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
+#else
+#define egg_debug(...)
+#define egg_warning(...)
+#define egg_error(...)
+#endif
+
+void egg_debug_init (gboolean debug);
+void egg_debug_set_logging (gboolean enabled);
+gboolean egg_debug_enabled (void);
+gboolean egg_debug_is_logging (void);
+gboolean egg_debug_is_console (void);
+void egg_debug_backtrace (void);
+void egg_debug_real (const gchar *func,
+ const gchar *file,
+ int line,
+ const gchar *format, ...) __attribute__((format (printf,4,5)));
+void egg_warning_real (const gchar *func,
+ const gchar *file,
+ int line,
+ const gchar *format, ...) __attribute__((format (printf,4,5)));
+void egg_error_real (const gchar *func,
+ const gchar *file,
+ int line,
+ const gchar *format, ...) G_GNUC_NORETURN __attribute__((format (printf,4,5)));
+
+G_END_DECLS
+
+#endif /* __EGG_DEBUG_H */
diff --git a/applets/brightness/gpm-common.c b/applets/brightness/gpm-common.c
new file mode 100644
index 0000000..0d0e536
--- /dev/null
+++ b/applets/brightness/gpm-common.c
@@ -0,0 +1,210 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2007 Richard Hughes <[email protected]>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <string.h>
+#include <glib/gi18n.h>
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
+
+#include "egg-debug.h"
+#include "gpm-common.h"
+
+/**
+ * gpm_get_timestring:
+ * @time_secs: The time value to convert in seconds
+ * @cookie: The cookie we are looking for
+ *
+ * Returns a localised timestring
+ *
+ * Return value: The time string, e.g. "2 hours 3 minutes"
+ **/
+gchar *
+gpm_get_timestring (guint time_secs)
+{
+ char* timestring = NULL;
+ gint hours;
+ gint minutes;
+
+ /* Add 0.5 to do rounding */
+ minutes = (int) ( ( time_secs / 60.0 ) + 0.5 );
+
+ if (minutes == 0) {
+ timestring = g_strdup (_("Unknown time"));
+ return timestring;
+ }
+
+ if (minutes < 60) {
+ timestring = g_strdup_printf (ngettext ("%i minute",
+ "%i minutes",
+ minutes), minutes);
+ return timestring;
+ }
+
+ hours = minutes / 60;
+ minutes = minutes % 60;
+
+ if (minutes == 0)
+ timestring = g_strdup_printf (ngettext (
+ "%i hour",
+ "%i hours",
+ hours), hours);
+ else
+ /* TRANSLATOR: "%i %s %i %s" are "%i hours %i minutes"
+ * Swap order with "%2$s %2$i %1$s %1$i if needed */
+ timestring = g_strdup_printf (_("%i %s %i %s"),
+ hours, ngettext ("hour", "hours", hours),
+ minutes, ngettext ("minute", "minutes", minutes));
+ 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
+ **/
+void
+gpm_help_display (const gchar *link_id)
+{
+ GError *error = NULL;
+ gchar *uri;
+
+ if (link_id != NULL)
+ uri = g_strconcat ("ghelp:mate-power-manager?", link_id, NULL);
+ else
+ uri = g_strdup ("ghelp:mate-power-manager");
+
+ gtk_show_uri (NULL, uri, GDK_CURRENT_TIME, &error);
+
+ if (error != NULL) {
+ GtkWidget *d;
+ d = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", error->message);
+ gtk_dialog_run (GTK_DIALOG(d));
+ gtk_widget_destroy (d);
+ g_error_free (error);
+ }
+ g_free (uri);
+}
+
+/***************************************************************************
+ *** MAKE CHECK TESTS ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"
+
+void
+gpm_common_test (gpointer data)
+{
+ EggTest *test = (EggTest *) data;
+ if (egg_test_start (test, "GpmCommon") == FALSE)
+ return;
+
+ egg_test_end (test);
+}
+
+#endif
+
diff --git a/applets/brightness/gpm-common.h b/applets/brightness/gpm-common.h
new file mode 100644
index 0000000..e2733a8
--- /dev/null
+++ b/applets/brightness/gpm-common.h
@@ -0,0 +1,183 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2007 Richard Hughes <[email protected]>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPMCOMMON_H
+#define __GPMCOMMON_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define GPM_DBUS_SERVICE "org.mate.PowerManager"
+#define GPM_DBUS_INTERFACE "org.mate.PowerManager"
+#define GPM_DBUS_INTERFACE_BACKLIGHT "org.mate.PowerManager.Backlight"
+#define GPM_DBUS_PATH "/org/mate/PowerManager"
+#define GPM_DBUS_PATH_BACKLIGHT "/org/mate/PowerManager/Backlight"
+
+/* common descriptions of this program */
+#define GPM_NAME _("Power Manager")
+#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"
+
+/* change general/installed_schema whenever adding or moving keys */
+#define GPM_CONF_SCHEMA_ID 3
+
+#define GPM_CONF_DIR "/apps/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"
+
+/* 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"
+
+/* 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"
+
+/* 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"
+
+/* 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"
+
+/* 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"
+
+/* 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"
+
+/* 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"
+
+/* 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"
+
+/* 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"
+
+/* mate-screensaver */
+#define GS_CONF_DIR "/apps/mate-screensaver"
+#define GS_PREF_LOCK_ENABLED GS_CONF_DIR "/lock_enabled"
+
+/* mate-session */
+#define GPM_CONF_IDLE_DELAY "/desktop/mate/session/idle_delay"
+
+typedef enum {
+ GPM_ICON_POLICY_ALWAYS,
+ GPM_ICON_POLICY_PRESENT,
+ GPM_ICON_POLICY_CHARGE,
+ GPM_ICON_POLICY_LOW,
+ GPM_ICON_POLICY_CRITICAL,
+ GPM_ICON_POLICY_NEVER
+} GpmIconPolicy;
+
+typedef enum {
+ GPM_ACTION_POLICY_BLANK,
+ GPM_ACTION_POLICY_SUSPEND,
+ GPM_ACTION_POLICY_SHUTDOWN,
+ GPM_ACTION_POLICY_HIBERNATE,
+ GPM_ACTION_POLICY_INTERACTIVE,
+ GPM_ACTION_POLICY_NOTHING
+} 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);
+#endif
+
+G_END_DECLS
+
+#endif /* __GPMCOMMON_H */