[Goodies-commits] r1458 - in xfce4-battery-plugin/branches/XERVERIUS: . icons/16x16 icons/22x22 icons/scalable panel-plugin po
Nick Schermer
nick at xfce.org
Wed Jun 21 21:27:14 CEST 2006
Author: nick
Date: 2006-06-21 19:26:53 +0000 (Wed, 21 Jun 2006)
New Revision: 1458
Added:
xfce4-battery-plugin/branches/XERVERIUS/configure.in.in
xfce4-battery-plugin/branches/XERVERIUS/icons/16x16/battery.png
xfce4-battery-plugin/branches/XERVERIUS/icons/22x22/battery.png
xfce4-battery-plugin/branches/XERVERIUS/icons/scalable/battery.svg
xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.c
xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.h
xfce4-battery-plugin/branches/XERVERIUS/po/ChangeLog
xfce4-battery-plugin/branches/XERVERIUS/po/LINGUAS
Removed:
xfce4-battery-plugin/branches/XERVERIUS/configure.ac
xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-warning.c
xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-warning.h
Modified:
xfce4-battery-plugin/branches/XERVERIUS/NEWS
xfce4-battery-plugin/branches/XERVERIUS/TODO
xfce4-battery-plugin/branches/XERVERIUS/autogen.sh
xfce4-battery-plugin/branches/XERVERIUS/icons/16x16/Makefile.am
xfce4-battery-plugin/branches/XERVERIUS/icons/22x22/Makefile.am
xfce4-battery-plugin/branches/XERVERIUS/icons/scalable/Makefile.am
xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/Makefile.am
xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-dialogs.c
xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-hal.c
xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-hal.h
xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-overview.c
xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.c
xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.desktop.in.in
xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.h
xfce4-battery-plugin/branches/XERVERIUS/po/POTFILES.in
Log:
* Frame border for panel plugin
* Smaller fonts for users with a panel size < 30
* Support for the notification daemon (libnotify), you can enable
this option with --enable-notifications
* Improved HAL backend
* New warning dialog, with (multiple) battery(-ies) status
* Plug some leaks
* Support for LINGUAS and string improvements for translators
* Include battery icon
* Various tweaks all over the place and stuff i've probably forgotten.
Modified: xfce4-battery-plugin/branches/XERVERIUS/NEWS
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/NEWS 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/NEWS 2006-06-21 19:26:53 UTC (rev 1458)
@@ -1,3 +1,8 @@
-Releases:
-
-Version 0.0.1: 2006-05-04 22:11
+* Battery status from HAL
+* Fully multiple battery compatable
+* Overview of the battery(-ies)
+* Different types of actions:
+ * Message dialog
+ * Command (in terminal is enabled)
+ * Support for the Notifications Daemon
+* Various layouts for the panel
\ No newline at end of file
Modified: xfce4-battery-plugin/branches/XERVERIUS/TODO
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/TODO 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/TODO 2006-06-21 19:26:53 UTC (rev 1458)
@@ -1,7 +1,3 @@
-- Improve the warning dialog
- - After close, popup a couple of minutes later
- - "Don't show this warning again" option
-
- Create our own "remaining time" calculate function,
using some kind of argoritm
@@ -10,5 +6,5 @@
- Add support for power usage (Watts) to give the user
an idea of the power usage of his/her laptop
-- Add dialog (on widget click) to give a detailed list of
- the battery(-ies) and they status
+- Add a 'averange' battery for multiple battery users, to
+ show a global status of all batteries in the system.
Modified: xfce4-battery-plugin/branches/XERVERIUS/autogen.sh
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/autogen.sh 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/autogen.sh 2006-06-21 19:26:53 UTC (rev 1458)
@@ -1,11 +1,11 @@
#!/bin/sh
#
-# $Id: autogen.sh 13265 2005-03-12 04:15:08Z brian $
+# $Id: autogen.sh 20256 2006-03-06 15:43:06Z benny $
#
-# Copyright (c) 2002-2005
-# The Xfce development team. All rights reserved.
+# Copyright (c) 2002-2006
+# The Thunar development team. All rights reserved.
#
-# Written for Xfce by Benedikt Meurer <benny at xfce.org>.
+# Written for Thunar by Benedikt Meurer <benny at xfce.org>.
#
(type xdt-autogen) >/dev/null 2>&1 || {
@@ -18,6 +18,22 @@
exit 1
}
+# verify that po/LINGUAS is present
+(test -f po/LINGUAS) >/dev/null 2>&1 || {
+ cat >&2 <<EOF
+autogen.sh: The file po/LINGUAS could not be found. Please check your snapshot
+ or try to checkout again.
+EOF
+ exit 1
+}
+
+# substitute revision and linguas
+linguas=`sed -e '/^#/d' po/LINGUAS`
+revision=`LC_ALL=C svn info $0 | awk '/^Revision: / {printf "%05d\n", $2}'`
+sed -e "s/@LINGUAS@/${linguas}/g" \
+ -e "s/@REVISION@/${revision}/g" \
+ < "configure.in.in" > "configure.in"
+
exec xdt-autogen $@
-# vi:set ts=2 sw=2 et ai:
\ No newline at end of file
+# vi:set ts=2 sw=2 et ai:
Deleted: xfce4-battery-plugin/branches/XERVERIUS/configure.ac
Added: xfce4-battery-plugin/branches/XERVERIUS/configure.in.in
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/configure.in.in (rev 0)
+++ xfce4-battery-plugin/branches/XERVERIUS/configure.in.in 2006-06-21 19:26:53 UTC (rev 1458)
@@ -0,0 +1,95 @@
+dnl configure.ac
+dnl
+dnl xfce4-battery-plugin - Battery Monitor for the Xfce Panel
+dnl
+dnl 2005 Nick Schermer <nick at xfce.org>
+dnl
+
+dnl version info
+m4_define([battery_version], [0.6.0])
+
+dnl init autoconf
+AC_INIT([xfce4-battery-plugin], [battery_version], [nick at xfce.org])
+AC_PREREQ([2.50])
+
+dnl init automake
+BATTERY_VERSION=battery_version
+AM_INIT_AUTOMAKE([xfce4-battery-plugin], [$BATTERY_VERSION])
+AM_CONFIG_HEADER([config.h])
+AM_MAINTAINER_MODE
+
+dnl check for basic programs
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_LIBTOOL
+AC_PROG_INTLTOOL()
+
+dnl add configure options
+AC_ARG_ENABLE([dummies],
+ [AC_HELP_STRING([--enable-dummies],
+ [This option will add 4 (static) dummy batteries for better testing @<:@default=no@:>@])]
+ ,,
+ [enable_dummies])
+
+AC_ARG_ENABLE([notifications],
+ [AC_HELP_STRING([--enable-notifications],
+ [Enable the use of libnotify to show the battery status @<:@default=no@:>@])]
+ ,,
+ [enable_notifications])
+
+dnl enable dummies is requested
+if test x"$enable_dummies" = x"yes" ; then
+ AC_DEFINE([DUMMIES], [1], [Use Dummies])
+fi
+
+dnl check for standard header files
+AC_HEADER_STDC
+
+dnl check for required packages
+XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.6.0])
+XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.3.90])
+XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.3.90.2])
+XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.90])
+XDT_CHECK_PACKAGE([HAL], [hal], [0.5.6])
+XDT_CHECK_PACKAGE([DBUS], [dbus-glib-1], [0.34])
+
+dnl Check for libnotify package, if enabled
+if test x"$enable_notifications" = x"yes" ; then
+ XDT_CHECK_OPTIONAL_PACKAGE([LIBNOTIFY], [libnotify], [0.4.0],
+ [libnotify], [Notifications support])
+fi
+AM_CONDITIONAL([HAVE_LIBNOTIFY], [test x"$LIBNOTIFY_FOUND" = x"yes"])
+
+dnl Check for i18n support
+XDT_I18N([@LINGUAS@])
+
+dnl check for debugging support
+XDT_FEATURE_DEBUG()
+
+AC_OUTPUT([
+Makefile
+panel-plugin/Makefile
+icons/Makefile
+icons/16x16/Makefile
+icons/22x22/Makefile
+icons/scalable/Makefile
+po/Makefile.in
+])
+
+dnl Print configuration
+echo
+echo "Build Configuration:"
+echo
+if test x"$enable_dummies" = x"yes" ; then
+echo "* Dummy Batteries: yes"
+else
+echo "* Dummy Batteries: no"
+fi
+
+if test x"$LIBNOTIFY_FOUND" = x"yes" ; then
+echo "* Notifications: yes"
+else
+echo "* Notifications: no"
+fi
+echo
Property changes on: xfce4-battery-plugin/branches/XERVERIUS/configure.in.in
___________________________________________________________________
Name: svn:executable
+ *
Modified: xfce4-battery-plugin/branches/XERVERIUS/icons/16x16/Makefile.am
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/icons/16x16/Makefile.am 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/icons/16x16/Makefile.am 2006-06-21 19:26:53 UTC (rev 1458)
@@ -14,7 +14,8 @@
battery-charging-080.png \
battery-charging-100.png \
battery-charged.png \
- battery-missing.png
+ battery-missing.png \
+ battery.png
EXTRA_DIST = \
$(icons_DATA)
Added: xfce4-battery-plugin/branches/XERVERIUS/icons/16x16/battery.png
===================================================================
(Binary files differ)
Property changes on: xfce4-battery-plugin/branches/XERVERIUS/icons/16x16/battery.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Modified: xfce4-battery-plugin/branches/XERVERIUS/icons/22x22/Makefile.am
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/icons/22x22/Makefile.am 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/icons/22x22/Makefile.am 2006-06-21 19:26:53 UTC (rev 1458)
@@ -14,7 +14,8 @@
battery-charging-080.png \
battery-charging-100.png \
battery-charged.png \
- battery-missing.png
+ battery-missing.png \
+ battery.png
EXTRA_DIST = \
$(icons_DATA)
Added: xfce4-battery-plugin/branches/XERVERIUS/icons/22x22/battery.png
===================================================================
(Binary files differ)
Property changes on: xfce4-battery-plugin/branches/XERVERIUS/icons/22x22/battery.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Modified: xfce4-battery-plugin/branches/XERVERIUS/icons/scalable/Makefile.am
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/icons/scalable/Makefile.am 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/icons/scalable/Makefile.am 2006-06-21 19:26:53 UTC (rev 1458)
@@ -14,7 +14,8 @@
battery-charging-080.svg \
battery-charging-100.svg \
battery-charged.svg \
- battery-missing.svg
+ battery-missing.svg \
+ battery.svg
EXTRA_DIST = \
$(icons_DATA)
Added: xfce4-battery-plugin/branches/XERVERIUS/icons/scalable/battery.svg
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/icons/scalable/battery.svg (rev 0)
+++ xfce4-battery-plugin/branches/XERVERIUS/icons/scalable/battery.svg 2006-06-21 19:26:53 UTC (rev 1458)
@@ -0,0 +1,347 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ sodipodi:docname="battery.svg"
+ sodipodi:docbase="/home/tigert/cvs/freedesktop.org/tango-icon-theme/scalable/devices"
+ inkscape:version="0.43+devel"
+ sodipodi:version="0.32"
+ id="svg1328"
+ height="48px"
+ width="48px"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs3">
+ <linearGradient
+ id="linearGradient6932">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1.0000000;"
+ offset="0.0000000"
+ id="stop6934" />
+ <stop
+ style="stop-color:#e7e6ae;stop-opacity:1.0000000;"
+ offset="1.0000000"
+ id="stop6936" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient6924"
+ inkscape:collect="always">
+ <stop
+ id="stop6926"
+ offset="0"
+ style="stop-color:#ffffff;stop-opacity:1;" />
+ <stop
+ id="stop6928"
+ offset="1"
+ style="stop-color:#ffffff;stop-opacity:0;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient4206">
+ <stop
+ id="stop4208"
+ offset="0.0000000"
+ style="stop-color:#7d4b01;stop-opacity:1.0000000;" />
+ <stop
+ id="stop4210"
+ offset="1.0000000"
+ style="stop-color:#535353;stop-opacity:1.0000000;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient4176"
+ inkscape:collect="always">
+ <stop
+ id="stop4178"
+ offset="0"
+ style="stop-color:#ffffff;stop-opacity:1;" />
+ <stop
+ id="stop4180"
+ offset="1"
+ style="stop-color:#ffffff;stop-opacity:0;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient4162">
+ <stop
+ id="stop4164"
+ offset="0.0000000"
+ style="stop-color:#f79403;stop-opacity:1.0000000;" />
+ <stop
+ style="stop-color:#fdb343;stop-opacity:1.0000000;"
+ offset="0.18691589"
+ id="stop4170" />
+ <stop
+ id="stop4172"
+ offset="0.43008122"
+ style="stop-color:#fdb74f;stop-opacity:1.0000000;" />
+ <stop
+ id="stop4166"
+ offset="1.0000000"
+ style="stop-color:#8f5601;stop-opacity:1.0000000;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient4134">
+ <stop
+ id="stop4136"
+ offset="0.0000000"
+ style="stop-color:#7e807a;stop-opacity:1.0000000;" />
+ <stop
+ style="stop-color:#babbb8;stop-opacity:1.0000000;"
+ offset="0.25000000"
+ id="stop4148" />
+ <stop
+ style="stop-color:#a5a6a3;stop-opacity:1.0000000;"
+ offset="0.50000000"
+ id="stop4142" />
+ <stop
+ id="stop4138"
+ offset="1.0000000"
+ style="stop-color:#333432;stop-opacity:1.0000000;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient4126"
+ inkscape:collect="always">
+ <stop
+ id="stop4128"
+ offset="0"
+ style="stop-color:#000000;stop-opacity:1;" />
+ <stop
+ id="stop4130"
+ offset="1"
+ style="stop-color:#000000;stop-opacity:0;" />
+ </linearGradient>
+ <radialGradient
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.000000,0.000000,0.000000,0.500000,-7.259031e-15,20.00000)"
+ r="17.142857"
+ fy="40.000000"
+ fx="23.857143"
+ cy="40.000000"
+ cx="23.857143"
+ id="radialGradient4132"
+ xlink:href="#linearGradient4126"
+ inkscape:collect="always" />
+ <linearGradient
+ gradientTransform="translate(-1.142857e-6,-1.714284)"
+ gradientUnits="userSpaceOnUse"
+ y2="26.718750"
+ x2="38.826412"
+ y1="26.718750"
+ x1="9.3030529"
+ id="linearGradient4140"
+ xlink:href="#linearGradient4134"
+ inkscape:collect="always" />
+ <linearGradient
+ gradientUnits="userSpaceOnUse"
+ y2="13.284962"
+ x2="24.000000"
+ y1="16.525082"
+ x1="24.000000"
+ id="linearGradient4160"
+ xlink:href="#linearGradient6932"
+ inkscape:collect="always" />
+ <linearGradient
+ gradientTransform="translate(-1.142857e-6,-1.714284)"
+ gradientUnits="userSpaceOnUse"
+ y2="17.511776"
+ x2="38.013393"
+ y1="17.511776"
+ x1="10.116071"
+ id="linearGradient4168"
+ xlink:href="#linearGradient4162"
+ inkscape:collect="always" />
+ <linearGradient
+ gradientTransform="translate(-1.142857e-6,-1.714284)"
+ gradientUnits="userSpaceOnUse"
+ y2="56.575912"
+ x2="37.969398"
+ y1="14.004482"
+ x1="17.160095"
+ id="linearGradient4182"
+ xlink:href="#linearGradient4176"
+ inkscape:collect="always" />
+ <linearGradient
+ gradientTransform="translate(-1.142857e-6,-1.714284)"
+ gradientUnits="userSpaceOnUse"
+ y2="25.428572"
+ x2="25.207588"
+ y1="21.857143"
+ x1="25.064732"
+ id="linearGradient4198"
+ xlink:href="#linearGradient4206"
+ inkscape:collect="always" />
+ <linearGradient
+ gradientTransform="translate(-0.142857,0.928571)"
+ gradientUnits="userSpaceOnUse"
+ y2="30.000000"
+ x2="15.785715"
+ y1="19.500000"
+ x1="16.071430"
+ id="linearGradient6930"
+ xlink:href="#linearGradient6924"
+ inkscape:collect="always" />
+ <linearGradient
+ y2="13.284962"
+ x2="24.000000"
+ y1="16.525082"
+ x1="24.000000"
+ gradientUnits="userSpaceOnUse"
+ id="linearGradient6942"
+ xlink:href="#linearGradient6932"
+ inkscape:collect="always" />
+ <radialGradient
+ r="17.142857"
+ fy="40.000000"
+ fx="23.857143"
+ cy="40.000000"
+ cx="23.857143"
+ gradientTransform="matrix(1.000000,0.000000,0.000000,0.500000,-4.403648e-15,20.00000)"
+ gradientUnits="userSpaceOnUse"
+ id="radialGradient6946"
+ xlink:href="#linearGradient4126"
+ inkscape:collect="always" />
+ </defs>
+ <sodipodi:namedview
+ stroke="#a40000"
+ inkscape:window-y="229"
+ inkscape:window-x="201"
+ inkscape:window-height="644"
+ inkscape:window-width="882"
+ fill="#cc0000"
+ inkscape:showpageshadow="false"
+ inkscape:document-units="px"
+ inkscape:grid-bbox="true"
+ showgrid="false"
+ inkscape:current-layer="layer1"
+ inkscape:cy="23.637033"
+ inkscape:cx="28.540224"
+ inkscape:zoom="9.8994949"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ borderopacity="0.25490196"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base" />
+ <metadata
+ id="metadata4">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title>Battery</dc:title>
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>Jakub Steiner</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ <dc:source>http://jimmac.musichall.cz</dc:source>
+ <dc:subject>
+ <rdf:Bag>
+ <rdf:li>battery</rdf:li>
+ <rdf:li>apm</rdf:li>
+ <rdf:li>acpi</rdf:li>
+ <rdf:li>power management</rdf:li>
+ </rdf:Bag>
+ </dc:subject>
+ <cc:license
+ rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/" />
+ </cc:Work>
+ <cc:License
+ rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/Reproduction" />
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/Distribution" />
+ <cc:requires
+ rdf:resource="http://web.resource.org/cc/Notice" />
+ <cc:requires
+ rdf:resource="http://web.resource.org/cc/Attribution" />
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
+ <cc:requires
+ rdf:resource="http://web.resource.org/cc/ShareAlike" />
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:groupmode="layer"
+ inkscape:label="Battery"
+ id="layer1">
+ <path
+ transform="matrix(1.058752,0.000000,0.000000,1.151259,-1.115944,-10.27691)"
+ d="M 41.000000 40.000000 A 17.142857 8.5714283 0 1 1 6.7142868,40.000000 A 17.142857 8.5714283 0 1 1 41.000000 40.000000 z"
+ sodipodi:ry="8.5714283"
+ sodipodi:rx="17.142857"
+ sodipodi:cy="40.000000"
+ sodipodi:cx="23.857143"
+ id="path3366"
+ style="opacity:1.0000000;color:#000000;fill:url(#radialGradient4132);fill-opacity:1.0000000;fill-rule:nonzero;stroke:none;stroke-width:1.0000000;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10.000000;stroke-dasharray:none;stroke-dashoffset:0.0000000;stroke-opacity:1.0000000;visibility:visible;display:block;overflow:visible"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:nodetypes="csszssz"
+ id="path3068"
+ d="M 23.937499,7.1919650 C 16.078072,7.1919650 9.6874997,9.9944659 9.6874987,13.441966 C 9.6874987,13.689351 9.6874987,36.309326 9.6874987,36.566966 C 9.6874987,40.014467 16.078071,42.816966 23.937499,42.816966 C 31.796927,42.816966 38.441965,40.014466 38.441963,36.566966 C 38.441963,36.362905 38.441963,13.646027 38.441963,13.441966 C 38.441963,9.9944649 31.796926,7.1919650 23.937499,7.1919650 z "
+ style="opacity:1.0000000;color:#000000;fill:url(#linearGradient4140);fill-opacity:1.0000000;fill-rule:nonzero;stroke:url(#linearGradient4198);stroke-width:1.0000000;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10.000000;stroke-dasharray:none;stroke-dashoffset:0.0000000;stroke-opacity:1.0000000;visibility:visible;display:block;overflow:visible" />
+ <path
+ style="opacity:1.0000000;color:#000000;fill:url(#linearGradient4168);fill-opacity:1.0000000;fill-rule:nonzero;stroke:none;stroke-width:0.76899999;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10.000000;stroke-dasharray:none;stroke-dashoffset:0.0000000;stroke-opacity:1.0000000;visibility:visible;display:block;overflow:visible"
+ d="M 23.941292,7.4484874 C 16.316147,7.4484874 10.116071,10.167450 10.116070,13.512182 C 10.116070,13.752193 10.116070,19.820066 10.116070,20.070026 C 10.116070,23.414760 16.316146,25.717924 23.941292,25.717924 C 31.566438,25.717924 38.013394,23.414760 38.013392,20.070026 C 38.013392,19.872048 38.013392,13.710160 38.013392,13.512182 C 38.013392,10.167449 31.566437,7.4484874 23.941292,7.4484874 z "
+ id="path4152"
+ sodipodi:nodetypes="csszssz" />
+ <path
+ style="opacity:0.54430377;color:#000000;fill:none;fill-opacity:1.0000000;fill-rule:nonzero;stroke:url(#linearGradient4182);stroke-width:1.0000000;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10.000000;stroke-dasharray:none;stroke-dashoffset:0.0000000;stroke-opacity:1.0000000;visibility:visible;display:block;overflow:visible"
+ d="M 23.946122,7.9712859 C 16.618364,7.9712859 10.660096,10.584206 10.660095,13.798491 C 10.660095,14.029142 10.660095,35.684551 10.660095,35.924762 C 10.660095,39.139049 16.618363,41.751967 23.946122,41.751967 C 31.273880,41.751967 37.469399,39.139048 37.469397,35.924762 C 37.469397,35.734506 37.469397,13.988749 37.469397,13.798491 C 37.469397,10.584205 31.273879,7.9712859 23.946122,7.9712859 z "
+ id="path4174"
+ sodipodi:nodetypes="csszssz" />
+ <path
+ transform="matrix(1.037291,0.000000,0.000000,0.954619,-0.894979,-7.572056e-2)"
+ d="M 36.857142 14.071428 A 12.857142 5.5000000 0 1 1 11.142858,14.071428 A 12.857142 5.5000000 0 1 1 36.857142 14.071428 z"
+ sodipodi:ry="5.5000000"
+ sodipodi:rx="12.857142"
+ sodipodi:cy="14.071428"
+ sodipodi:cx="24.000000"
+ id="path3364"
+ style="opacity:1.0000000;color:#000000;fill:#fed496;fill-opacity:1.0000000;fill-rule:nonzero;stroke:url(#linearGradient4160);stroke-width:1.0049270;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10.000000;stroke-dasharray:none;stroke-dashoffset:0.0000000;stroke-opacity:1.0000000;visibility:visible;display:block;overflow:visible"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:type="arc"
+ style="overflow:visible;display:block;visibility:visible;stroke-opacity:1.0000000;stroke-dashoffset:0.0000000;stroke-dasharray:none;stroke-miterlimit:10.000000;marker-end:none;marker-mid:none;marker-start:none;marker:none;stroke-linejoin:miter;stroke-linecap:butt;stroke-width:1.0000000;stroke:none;fill-rule:nonzero;fill-opacity:1.0000000;fill:url(#radialGradient6946);color:#000000;opacity:0.65822785"
+ id="path6944"
+ sodipodi:cx="23.857143"
+ sodipodi:cy="40.000000"
+ sodipodi:rx="17.142857"
+ sodipodi:ry="8.5714283"
+ d="M 41.000000 40.000000 A 17.142857 8.5714283 0 1 1 6.7142868,40.000000 A 17.142857 8.5714283 0 1 1 41.000000 40.000000 z"
+ transform="matrix(0.363430,0.000000,0.000000,0.363430,15.47247,-4.118577)" />
+ <path
+ style="opacity:1.0000000;color:#000000;fill:#fcaf3e;fill-opacity:1.0000000;fill-rule:nonzero;stroke:#b46c02;stroke-width:1.0000000;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10.000000;stroke-dasharray:none;stroke-dashoffset:0.0000000;stroke-opacity:1.0000000;visibility:visible;display:block;overflow:visible"
+ d="M 23.889443,6.4653480 C 21.886649,6.4653480 19.258159,7.1795010 19.258159,8.0580170 C 19.258159,8.1210570 19.258159,10.622022 19.258159,10.687676 C 19.258159,11.566192 21.886649,12.280345 23.889443,12.280345 C 25.892238,12.280345 28.299859,11.566192 28.299858,10.687676 C 28.299858,10.635676 28.299858,8.1100170 28.299858,8.0580170 C 28.299858,7.1795000 25.892238,6.4653480 23.889443,6.4653480 z "
+ id="path3362"
+ sodipodi:nodetypes="csszssz" />
+ <path
+ sodipodi:nodetypes="ccccccc"
+ id="path6922"
+ d="M 13.642858,17.999999 L 14.000000,34.785714 L 18.571429,36.071428 L 18.428572,19.357142 C 18.428572,19.357142 20.500000,19.357142 23.857143,19.142856 C 18.641400,18.909783 12.673770,16.668176 10.642858,15.214285 C 12.059757,17.306461 13.642858,17.999999 13.642858,17.999999 z "
+ style="opacity:0.49367085;color:#000000;fill:url(#linearGradient6930);fill-opacity:1.0000000;fill-rule:nonzero;stroke:none;stroke-width:1.0000000;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4.0000000;stroke-dasharray:none;stroke-dashoffset:0.0000000;stroke-opacity:1.0000000;visibility:visible;display:block;overflow:visible" />
+ <path
+ sodipodi:type="arc"
+ style="opacity:1.0000000;color:#000000;fill:#fed496;fill-opacity:1.0000000;fill-rule:nonzero;stroke:url(#linearGradient6942);stroke-width:4.1198664;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10.000000;stroke-dasharray:none;stroke-dashoffset:0.0000000;stroke-opacity:1.0000000;visibility:visible;display:block;overflow:visible"
+ id="path6940"
+ sodipodi:cx="24.000000"
+ sodipodi:cy="14.071428"
+ sodipodi:rx="12.857142"
+ sodipodi:ry="5.5000000"
+ d="M 36.857142 14.071428 A 12.857142 5.5000000 0 1 1 11.142858,14.071428 A 12.857142 5.5000000 0 1 1 36.857142 14.071428 z"
+ transform="matrix(0.271979,0.000000,0.000000,0.216619,17.27048,5.409742)" />
+ </g>
+ <g
+ inkscape:label="Emblem"
+ id="layer2"
+ inkscape:groupmode="layer" />
+</svg>
Property changes on: xfce4-battery-plugin/branches/XERVERIUS/icons/scalable/battery.svg
___________________________________________________________________
Name: svn:executable
+ *
Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/Makefile.am
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/Makefile.am 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/Makefile.am 2006-06-21 19:26:53 UTC (rev 1458)
@@ -8,8 +8,8 @@
battery-hal.c \
battery-dialogs.h \
battery-dialogs.c \
- battery-warning.h \
- battery-warning.c \
+ battery-actions.h \
+ battery-actions.c \
battery-overview.h \
battery-overview.c
@@ -19,6 +19,7 @@
@LIBXFCE4PANEL_CFLAGS@ \
@HAL_CFLAGS@ \
@DBUS_CFLAGS@ \
+ -DBINDIR=\"$(bindir)\" \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\"
xfce4_battery_plugin_LDFLAGS = \
@@ -26,7 +27,15 @@
@LIBXFCE4UTIL_LIBS@ \
@HAL_LIBS@ \
@DBUS_LIBS@
+
+#ifdef HAVE_LIBNOTIFY
+xfce4_battery_plugin_CFLAGS += \
+ @LIBNOTIFY_CFLAGS@
+xfce4_battery_plugin_LDFLAGS += \
+ @LIBNOTIFY_LIBS@
+#endif
+
desktop_in_in_files = battery.desktop.in.in
desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
Added: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.c
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.c (rev 0)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.c 2006-06-21 19:26:53 UTC (rev 1458)
@@ -0,0 +1,416 @@
+/* vim: set expandtab ts=8 sw=4: */
+
+/* $Id$
+ *
+ * Copyright (c) 2006 Nick Schermer <nick at xfce.org>
+ *
+ * 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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#define BORDER 6
+#define DIALOG_TIMEOUT 60000 /* 1 minute */
+#define MAX_CRITICAL 1 /* 1 minute */
+#define MAX_LOW 5 /* 5 minutes */
+
+#define CRITICAL_TIMEOUT 10000 /* 10 seconds */
+#define NORMAL_TIMEOUT 5000 /* 5 seconds */
+
+#define MSG_CHARGED _("is fully charged.")
+#define TIP_CHARGED _("You should consider plugging out your AC cable, to not overcharge your battery.")
+#define MSG_LOW _("is running low.")
+#define TIP_LOW _("You should consider plugging in or shutting down your computer soon, to avoid possible data loss.")
+#define MSG_CRITICAL _("has reached critical status.")
+#define TIP_CRITICAL _("You should plug in or shutdown your computer now, to avoid possible data loss.")
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <libxfce4panel/xfce-panel-plugin.h>
+#include <libxfcegui4/libxfcegui4.h>
+
+#ifdef HAVE_LIBNOTIFY
+#include <libnotify/notify.h>
+#endif
+
+#include "battery.h"
+#include "battery-actions.h"
+
+/* Global counters */
+static gint battery_number = 0;
+static gint warning_timeout = 0;
+static gint critical_counter = 0;
+static gint low_counter = 0;
+
+/* Timeout functions */
+static gboolean
+battery_actions_run_timeout (gpointer data)
+{
+ gint i, actions = 0;
+ BatteryStatus *bat;
+ BatteryPlugin *battery;
+ GtkWidget *messages;
+
+ DBG ("Run timeout function");
+
+ battery = (BatteryPlugin *) data;
+
+ critical_counter++;
+ low_counter++;
+
+ messages = battery_actions_dialog_init ();
+
+ for (i = 0; i < battery->batteries->len; ++i)
+ {
+ bat = g_ptr_array_index (battery->batteries, i);
+
+ switch (bat->status)
+ {
+ case CRITICAL:
+ if (critical_counter == MAX_CRITICAL && (
+#ifdef HAVE_LIBNOTIFY
+ battery->action_critical == NOTIFICATION ||
+#endif
+ battery->action_critical == MESSAGE ))
+ {
+ actions++;
+ battery_actions_check (bat,
+ i,
+ messages,
+ battery->action_critical,
+ battery->command_critical);
+ }
+ break;
+
+ case LOW:
+ if (low_counter == MAX_LOW && (
+#ifdef HAVE_LIBNOTIFY
+ battery->action_critical == NOTIFICATION ||
+#endif
+ battery->action_critical == MESSAGE ))
+ {
+ actions++;
+ battery_actions_check (bat,
+ i,
+ messages,
+ battery->action_low,
+ battery->command_low);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ /* Reset counters if needed */
+ if (critical_counter == MAX_CRITICAL)
+ critical_counter = 0;
+
+ if (low_counter == MAX_LOW)
+ low_counter = 0;
+
+ /* Create the message dialog, if there are any items */
+ battery_actions_dialog_create (battery, messages);
+
+ /* If no actions were triggered, stop timeout */
+ return (actions ? TRUE : FALSE);
+}
+
+void
+battery_actions_stop_timeout (void)
+{
+ /* Stop timeout */
+ if (warning_timeout)
+ {
+ DBG ("Removed timeout %d", warning_timeout);
+ g_source_remove (warning_timeout);
+ }
+
+ /* Reset counters and the id */
+ warning_timeout = 0;
+ critical_counter = 0;
+ low_counter = 0;
+}
+
+static void
+battery_actions_start_timeout (BatteryPlugin *battery)
+{
+ if (!warning_timeout)
+ warning_timeout =
+ g_timeout_add (DIALOG_TIMEOUT, battery_actions_run_timeout, battery);
+}
+
+void
+battery_actions_restart_timeout (BatteryPlugin *battery)
+{
+ battery_actions_stop_timeout ();
+ battery_actions_start_timeout (battery);
+}
+
+/* Message return functions */
+static const gchar *
+battery_actions_message_title (Status status,
+ guint id)
+{
+ const gchar *intro;
+
+ /* Create the title intro */
+ if (battery_number == 1)
+ intro = g_strdup (_("Your battery"));
+ else
+ intro = g_strdup_printf ("%s %d", _("Battery"), (id + 1));
+
+ switch (status)
+ {
+ case CHARGED:
+ return g_strdup_printf ("%s %s", intro, MSG_CHARGED);
+ case CRITICAL:
+ return g_strdup_printf ("%s %s", intro, MSG_CRITICAL);
+ case LOW:
+ return g_strdup_printf ("%s %s", intro, MSG_LOW);
+ default:
+ return g_strdup ("");
+ }
+}
+
+static const gchar *
+battery_actions_message_tip (Status status)
+{
+ switch (status)
+ {
+ case CHARGED:
+ return TIP_CHARGED;
+ case CRITICAL:
+ return TIP_CRITICAL;
+ case LOW:
+ return TIP_LOW;
+ default:
+ return "";
+ }
+}
+
+/* Message dialog functions */
+void
+battery_actions_dialog_destroy (BatteryPlugin *battery)
+{
+ GtkWidget *dialog;
+
+ /* Destroy the old dialog */
+ dialog = g_object_get_data (G_OBJECT (battery->plugin), "messages");
+
+ if (dialog)
+ {
+ gtk_widget_destroy (dialog);
+ g_object_set_data (G_OBJECT (battery->plugin), "messages", NULL);
+ }
+}
+
+GtkWidget *
+battery_actions_dialog_init (void)
+{
+ GtkWidget *box;
+
+ box = gtk_vbox_new (FALSE, BORDER);
+ g_object_set_data (G_OBJECT (box), "counter", GUINT_TO_POINTER (0));
+
+ return box;
+}
+
+static void
+battery_actions_dialog_response (GtkWidget *dialog,
+ int response,
+ BatteryPlugin *battery)
+{
+ g_object_set_data (G_OBJECT (battery->plugin), "messages", NULL);
+
+ /* "Don't show again" button clicked */
+ if (response == GTK_RESPONSE_OK)
+ battery_actions_stop_timeout ();
+
+ gtk_widget_destroy (dialog);
+}
+
+void
+battery_actions_dialog_create (BatteryPlugin *battery,
+ GtkWidget *messages)
+{
+ GtkWidget *dialog, *dialog_vbox;
+ gpointer data;
+
+ /* Check if there is anything to show */
+ data = g_object_get_data (G_OBJECT (messages), "counter");
+ g_object_set_data (G_OBJECT (messages), "counter", NULL);
+
+ if (GPOINTER_TO_UINT (data) == 0)
+ {
+ gtk_widget_destroy (messages);
+ return;
+ }
+
+ /* Destroy the old dialog */
+ battery_actions_dialog_destroy (battery);
+
+ /* Create the new dialog */
+ dialog = gtk_dialog_new_with_buttons (_("Battery Warning"),
+ NULL,
+ GTK_DIALOG_NO_SEPARATOR,
+ _("Remind me later"), GTK_RESPONSE_DELETE_EVENT,
+ _("Don't show again"), GTK_RESPONSE_OK,
+ NULL);
+
+ g_object_set_data (G_OBJECT (battery->plugin), "messages", dialog);
+
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "gtk-dialog-warning");
+ gtk_window_set_keep_above(GTK_WINDOW (dialog), TRUE);
+ gtk_window_stick (GTK_WINDOW (dialog));
+
+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
+
+ dialog_vbox = GTK_DIALOG (dialog)->vbox;
+
+ gtk_box_pack_start (GTK_BOX (dialog_vbox), messages, FALSE, TRUE, 0);
+
+ g_signal_connect(dialog, "response",
+ G_CALLBACK (battery_actions_dialog_response), battery);
+
+ DBG ("Show the messages dialog");
+ gtk_widget_show_all (dialog);
+}
+
+static void
+battery_action_append_message (BatteryStatus *bat,
+ guint id,
+ GtkWidget *messages)
+{
+ GtkWidget *hbox, *image, *label;
+ gchar *message, *icon;
+ gpointer data;
+ guint counter;
+
+ DBG ("Start adding new message");
+
+ /* Raise the counter */
+ data = g_object_get_data (G_OBJECT (messages), "counter");
+ counter = GPOINTER_TO_UINT (data) + 1;
+ g_object_set_data (G_OBJECT (messages), "counter", GUINT_TO_POINTER (counter));
+
+ hbox = gtk_hbox_new (FALSE, BORDER);
+ gtk_box_pack_start (GTK_BOX (messages), hbox, FALSE, FALSE, 0);
+
+ /* Add the icon */
+ icon = battery_icon_name (bat);
+
+ image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_DIALOG);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
+ gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0);
+ gtk_misc_set_padding (GTK_MISC (image), 10, 10);
+
+ g_free (icon);
+
+ /* Add the label */
+ message = g_strdup_printf ("<b>%s</b>\n%s",
+ battery_actions_message_title (bat->status, id),
+ battery_actions_message_tip (bat->status));
+
+ label = gtk_label_new (message);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ g_free (message);
+
+ DBG ("Added (%d) new battery to message dialog", counter);
+}
+
+#ifdef HAVE_LIBNOTIFY
+/* Show Notification */
+static void
+battery_action_show_notification (BatteryStatus *bat,
+ guint id)
+{
+ NotifyNotification *notify;
+
+ if (!notify_init("notify-send"))
+ {
+ g_warning ("Unable to init the notification library");
+ return;
+ }
+
+ notify = notify_notification_new (battery_actions_message_title (bat->status, id),
+ battery_actions_message_tip (bat->status),
+ battery_icon_name (bat),
+ NULL);
+ notify_notification_set_category (notify, "battery-status");
+ notify_notification_set_urgency (notify,
+ bat->status == CRITICAL ?
+ NOTIFY_URGENCY_CRITICAL : NOTIFY_URGENCY_NORMAL);
+ notify_notification_set_timeout (notify,
+ bat->status == CRITICAL ?
+ CRITICAL_TIMEOUT : NORMAL_TIMEOUT);
+ notify_notification_show (notify, NULL);
+ g_object_unref (G_OBJECT(notify));
+ notify_uninit ();
+}
+#endif
+
+/* Global function */
+void
+battery_actions_set_len (gint len)
+{
+ battery_number = len;
+}
+
+void
+battery_actions_check (BatteryStatus *bat,
+ guint id,
+ GtkWidget *messages,
+ ActiveAction action,
+ gchar *command)
+{
+ switch (action)
+ {
+ case MESSAGE:
+ battery_action_append_message (bat, id, messages);
+ break;
+
+#ifdef HAVE_LIBNOTIFY
+ case NOTIFICATION:
+ battery_action_show_notification (bat, id);
+ break;
+#endif
+
+ case COMMAND:
+ if (!xfce_exec (command, FALSE, FALSE, NULL))
+ goto failed;
+ break;
+
+ case TERMINAL:
+ if (!xfce_exec (command, TRUE, FALSE, NULL))
+ goto failed;
+ break;
+
+ default:
+ break;
+ }
+
+ return;
+
+ failed:
+ g_warning (_("The battery monitor was unable to execute following command: %s"), command);
+}
Property changes on: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.c
___________________________________________________________________
Name: svn:executable
+ *
Added: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.h
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.h (rev 0)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.h 2006-06-21 19:26:53 UTC (rev 1458)
@@ -0,0 +1,53 @@
+/* vim: set expandtab ts=8 sw=4: */
+
+/* $Id$
+ *
+ * Copyright (c) 2006 Nick Schermer <nick at xfce.org>
+ *
+ * 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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BATTERY_ACTIONS_H
+#define _BATTERY_ACTIONS_H
+
+G_BEGIN_DECLS
+
+void
+battery_actions_stop_timeout (void);
+
+void
+battery_actions_restart_timeout (BatteryPlugin *battery);
+
+void
+battery_actions_dialog_destroy (BatteryPlugin *battery);
+
+GtkWidget *
+battery_actions_dialog_init (void);
+
+void
+battery_actions_dialog_create (BatteryPlugin *battery, GtkWidget *messages);
+
+void
+battery_actions_dialog_create (BatteryPlugin *battery, GtkWidget *messages);
+
+void
+battery_actions_set_len (gint len);
+
+void
+battery_actions_check (BatteryStatus *bat, guint id, GtkWidget *messages, ActiveAction action, gchar *command);
+
+G_END_DECLS
+
+#endif /* _BATTERY_ACTIONS_H */
Property changes on: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.h
___________________________________________________________________
Name: svn:executable
+ *
Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-dialogs.c
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-dialogs.c 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-dialogs.c 2006-06-21 19:26:53 UTC (rev 1458)
@@ -39,7 +39,7 @@
{
BatteryPlugin *battery;
- GtkWidget *panel_icon, *panel_progressbar, *panel_percentage, *panel_time;
+ GtkWidget *panel_frame, *panel_icon, *panel_progressbar, *panel_percentage, *panel_time;
GtkWidget *tooltip_time;
GtkWidget *main_battery;
@@ -55,7 +55,11 @@
check_button_toggled (GtkWidget *button,
BatteryOptions *options)
{
- if (button == options->panel_icon)
+ if (button == options->panel_frame)
+ options->battery->show_frame =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+
+ else if (button == options->panel_icon)
options->battery->show_icon =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
@@ -78,64 +82,18 @@
battery_widgets (options->battery);
battery_update_plugin (options->battery);
}
-/*
-static gboolean
-return_valid_command (gchar *command)
-{
- // Script from Thunar UCA Editor *
- gchar *filename = g_strdup (command);
- gchar *s;
- if (G_LIKELY (filename != NULL))
- {
- // use only the first argument *
- s = strchr (filename, ' ');
- if (G_UNLIKELY (s != NULL))
- *s = '\0';
-
- // check if we have a file name *
- if (G_LIKELY (*filename != '\0'))
- {
- // check if the filename is not an absolute path *
- if (G_LIKELY (!g_path_is_absolute (filename)))
- {
- // try to lookup the filename in $PATH *
- s = g_find_program_in_path (filename);
- if (G_LIKELY (s != NULL))
- {
- // use the absolute path instead *
- g_free (filename);
- filename = s;
- }
- }
-
- // check if we have an absolute path now *
- if (G_LIKELY (g_path_is_absolute (filename)))
- {
- DBG ("Valid command: %s", filename);
- g_free (filename);
- return TRUE;
- }
- }
- }
-
- DBG ("Not A valid command");
- g_free (filename);
- return FALSE;
-}
-*/
static gboolean
command_focus_out (GtkWidget *entry,
GdkEventFocus *event,
BatteryOptions *options)
{
- gchar *command = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
+ gchar *command;
- //if (!command || /*!return_valid_command (command)*/)
- if (!command)
- {
- DBG ("WARNING, NOT A VALID COMMAND");
- }
+ command = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
+
+ if (command == NULL)
+ return FALSE;
if (entry == options->entry_critical)
options->battery->command_critical = g_strdup (command);
@@ -145,7 +103,7 @@
else if (entry == options->entry_full)
options->battery->command_charged = g_strdup (command);
-
+
g_free (command);
return FALSE;
@@ -156,7 +114,11 @@
GtkWidget *entry,
GtkWidget *button)
{
+#ifdef HAVE_LIBNOTIFY
+ if (active >= 3)
+#else
if (active >= 2)
+#endif
{
gtk_widget_set_sensitive (entry, TRUE);
gtk_widget_set_sensitive (button, TRUE);
@@ -189,7 +151,7 @@
combobox_changed_sensative (active, options->entry_full, options->button_full);
options->battery->action_charged = active;
}
- else if (GTK_WIDGET (combobox) == options->main_battery )
+ else if (GTK_WIDGET (combobox) == options->main_battery)
{
options->battery->show_battery = active;
@@ -202,12 +164,29 @@
spin_button_changed (GtkWidget *button,
BatteryOptions *options)
{
- guint value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(button));
+ guint critical, low;
+
+ /* Get values from the widgets */
+ critical = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(options->spin_critical));
+ low = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(options->spin_low));
- if (button == options->spin_critical)
- options->battery->perc_critical = value;
- else if (button == options->spin_low)
- options->battery->perc_low = value;
+ /* Compare values and correct if needed */
+ if (button == options->spin_critical &&
+ critical >= low)
+ {
+ low = critical + 1;
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(options->spin_low), low);
+ }
+ else if (button == options->spin_low &&
+ low <= critical)
+ {
+ critical = low - 1;
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(options->spin_critical), critical);
+ }
+
+ /* Save values */
+ options->battery->perc_critical = critical;
+ options->battery->perc_low = low;
}
static void
@@ -229,6 +208,18 @@
}
static void
+battery_append_values (GtkComboBox *box)
+{
+ gtk_combo_box_append_text (box, _("Do nothing"));
+ gtk_combo_box_append_text (box, _("Display warning message"));
+#ifdef HAVE_LIBNOTIFY
+ gtk_combo_box_append_text (box, _("Notification"));
+#endif
+ gtk_combo_box_append_text (box, _("Run Command"));
+ gtk_combo_box_append_text (box, _("Run command in terminal"));
+}
+
+static void
battery_command_clicked (GtkWidget *button,
GdkEventButton *ev,
GtkWidget *entry)
@@ -246,7 +237,7 @@
NULL);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), TRUE);
- // add file chooser filters *
+ /* add file chooser filters */
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("All Files"));
gtk_file_filter_add_pattern (filter, "*");
@@ -292,51 +283,49 @@
gtk_file_filter_add_pattern (filter, "*.sh");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
- // use the bindir as default folder *
- // gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), BINDIR); *
+ /* use the bindir as default folder */
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), BINDIR);
- // setup the currently selected file *
+ /* setup the currently selected file */
filename = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
if (G_LIKELY (filename != NULL))
{
- // use only the first argument *
+ /* use only the first argument */
s = strchr (filename, ' ');
if (G_UNLIKELY (s != NULL))
*s = '\0';
- // check if we have a file name *
+ /* check if we have a file name */
if (G_LIKELY (*filename != '\0'))
{
- // check if the filename is not an absolute path *
+ /* check if the filename is not an absolute path */
if (G_LIKELY (!g_path_is_absolute (filename)))
{
- // try to lookup the filename in $PATH *
+ /* try to lookup the filename in $PATH */
s = g_find_program_in_path (filename);
if (G_LIKELY (s != NULL))
{
- // use the absolute path instead *
+ /* use the absolute path instead */
g_free (filename);
filename = s;
}
}
- // check if we have an absolute path now *
+ /* check if we have an absolute path now */
if (G_LIKELY (g_path_is_absolute (filename)))
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (chooser), filename);
}
- // release the filename *
+ /* release the filename */
g_free (filename);
}
- // run the chooser dialog *
+ /* run the chooser dialog */
if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT)
{
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
- s = g_strconcat (filename, " %f", NULL);
gtk_entry_set_text (GTK_ENTRY (entry), filename);
g_free (filename);
- g_free (s);
}
gtk_widget_destroy (chooser);
@@ -350,10 +339,6 @@
GtkWidget *frame, *button, *icon, *label, *alignment, *hbox, *vbox;
GtkWidget *combobox, *entry;
-#ifndef USE_NEW_DIALOG
- GtkWidget *header;
-#endif
-
GtkSizeGroup *sg_buttons, *sg_labels;
guint i;
gchar *name;
@@ -370,39 +355,19 @@
xfce_panel_plugin_block_menu (battery->plugin);
-#ifdef USE_NEW_DIALOG
dialog = xfce_titled_dialog_new_with_buttons (_("Battery Monitor"),
- NULL,
- GTK_DIALOG_NO_SEPARATOR,
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
+ GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
NULL);
- xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dialog),
- _("Configure the battery monitor plugin"));
-#else
- dialog = gtk_dialog_new_with_buttons (_("Configure Battery Monitor"),
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
- GTK_DIALOG_DESTROY_WITH_PARENT |
- GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
- NULL);
-#endif
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
- gtk_window_set_icon_name (GTK_WINDOW (dialog), "gtk-properties");
- gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE);
- gtk_window_stick (GTK_WINDOW (dialog));
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-settings");
g_object_set_data (G_OBJECT (battery->plugin), "configure", dialog);
dialog_vbox = GTK_DIALOG (dialog)->vbox;
-#ifndef USE_NEW_DIALOG
- header = xfce_create_header (NULL, _("Battery Monitor"));
- gtk_widget_set_size_request (GTK_BIN (header)->child, -1, 32);
- gtk_container_set_border_width (GTK_CONTAINER (header), BORDER);
- gtk_box_pack_start (GTK_BOX (dialog_vbox), header, FALSE, TRUE, 0);
-#endif
-
notebook = gtk_notebook_new ();
gtk_box_pack_start (GTK_BOX (dialog_vbox), notebook, FALSE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (notebook), BORDER);
@@ -454,6 +419,14 @@
G_CALLBACK(combobox_changed), options);
}
+
+ button = options->panel_frame = gtk_check_button_new_with_mnemonic (_("Show frame"));
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), battery->show_frame);
+
+ g_signal_connect (button, "toggled",
+ G_CALLBACK (check_button_toggled), options);
+
button = options->panel_icon = gtk_check_button_new_with_mnemonic (_("Show battery status icon"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), battery->show_icon);
@@ -541,7 +514,7 @@
gtk_size_group_add_widget (sg_labels, label);
- button = options->spin_critical = gtk_spin_button_new_with_range(0, 99, 1);
+ button = options->spin_critical = gtk_spin_button_new_with_range(1, 98, 1);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(button), battery->perc_critical);
@@ -559,10 +532,7 @@
combobox = options->combo_critical = gtk_combo_box_new_text ();
gtk_box_pack_start (GTK_BOX (hbox), combobox, TRUE, TRUE, 0);
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Do nothing"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Display warning message"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Run Command"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Run command in terminal"));
+ battery_append_values (GTK_COMBO_BOX (combobox));
g_signal_connect(G_OBJECT(combobox), "changed",
G_CALLBACK(combobox_changed), options);
@@ -622,7 +592,7 @@
gtk_size_group_add_widget (sg_labels, label);
- button = options->spin_low = gtk_spin_button_new_with_range(0, 99, 1);
+ button = options->spin_low = gtk_spin_button_new_with_range(2, 99, 1);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(button), battery->perc_low);
@@ -640,10 +610,7 @@
combobox = options->combo_low = gtk_combo_box_new_text ();
gtk_box_pack_start (GTK_BOX (hbox), combobox, TRUE, TRUE, 0);
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Do nothing"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Display warning message"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Run Command"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Run command in terminal"));
+ battery_append_values (GTK_COMBO_BOX (combobox));
g_signal_connect(G_OBJECT(combobox), "changed",
G_CALLBACK(combobox_changed), options);
@@ -705,10 +672,7 @@
combobox = options->combo_full = gtk_combo_box_new_text ();
gtk_box_pack_start (GTK_BOX (hbox), combobox, TRUE, TRUE, 0);
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Do nothing"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Display warning message"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Run Command"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Run command in terminal"));
+ battery_append_values (GTK_COMBO_BOX (combobox));
g_signal_connect(G_OBJECT(combobox), "changed",
G_CALLBACK(combobox_changed), options);
Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-hal.c
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-hal.c 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-hal.c 2006-06-21 19:26:53 UTC (rev 1458)
@@ -35,97 +35,124 @@
#include "battery.h"
#include "battery-hal.h"
+/* Minimum time in seconds beween HAL events */
+#define MAX_UPDATE_INTERVAL 0.1
+
+static GTimer *update_timer;
static LibHalContext *context;
static DBusConnection *dbus_connection;
+gchar *
+battery_hal_get_string (const gchar *udi,
+ const gchar *key)
+{
+ /* Get a char value, if it exists */
+ if (G_LIKELY (libhal_device_property_exists (context, udi, key, NULL)))
+ return g_strdup (libhal_device_get_property_string (context, udi, key, NULL));
+ else
+ return NULL;
+}
+
+gint
+battery_hal_get_int (const gchar *udi,
+ const gchar *key)
+{
+ /* Get a int value, if it exists */
+ if (G_LIKELY (libhal_device_property_exists (context, udi, key, NULL)))
+ return libhal_device_get_property_int (context, udi, key, NULL);
+ else
+ return 0;
+}
+
+static gboolean
+battery_hal_get_bool (const gchar *udi,
+ const gchar *key)
+{
+ /* Get a boolean value, if it exists */
+ if (G_LIKELY (libhal_device_property_exists (context, udi, key, NULL)))
+ return libhal_device_get_property_bool (context, udi, key, NULL);
+ else
+ return FALSE;
+}
+
+gboolean
+battery_hal_device_exists (const gchar *udi)
+{
+ return libhal_device_exists (context, udi, NULL);
+}
+
static void
-battery_store_propery (LibHalContext *ctx,
- const char *udi,
- const char *key,
- BatteryStatus *bat,
- DBusError error)
+battery_store_properties (BatteryStatus *bat,
+ const gchar *udi)
{
- if (bat->percentage != libhal_device_get_property_int (ctx, udi, "battery.charge_level.percentage", &error))
- {
- bat->percentage = libhal_device_get_property_int (ctx, udi, "battery.charge_level.percentage", &error);
- return;
- }
-
- if (G_LIKELY (libhal_device_property_exists (ctx, udi, "battery.remaining_time", &error) &&
- libhal_device_get_property_int (ctx, udi, "battery.remaining_time", &error) > 0 ) &&
- libhal_device_get_property_int (ctx, udi, "battery.remaining_time", &error) != bat->time)
- {
- bat->time = libhal_device_get_property_int (ctx, udi, "battery.remaining_time", &error);
- return;
- }
+ /* Check if the device exists */
+ if (G_UNLIKELY (battery_hal_device_exists (udi) == FALSE))
+ return;
- if (G_UNLIKELY (strcmp (key, "battery.rechargeable.is_discharging") == 0))
- {
- bat->charging = !libhal_device_get_property_bool (ctx, udi, "battery.rechargeable.is_discharging", &error);
- return;
- }
+ /* Get current status */
+ bat->charging = !battery_hal_get_bool (udi, "battery.rechargeable.is_discharging");
+ bat->present = battery_hal_get_bool (udi, "battery.present");
+
+ bat->time = battery_hal_get_int (udi, "battery.remaining_time");
+ bat->percentage = battery_hal_get_int (udi, "battery.charge_level.percentage");
- if (G_UNLIKELY (strcmp (key, "battery.present") == 0))
- {
- bat->present = libhal_device_get_property_bool (ctx, udi, "battery.present", &error);
- return;
- }
+ /* People have this problem, sometimes... */
+ if (G_UNLIKELY (bat->percentage > 100))
+ bat->percentage = 100;
}
static void
hal_property_modified (LibHalContext *ctx,
- const char *udi,
- const char *key,
+ const gchar *udi,
+ const gchar *key,
dbus_bool_t is_removed,
dbus_bool_t is_added)
{
- unsigned int i;
- DBusError error;
+ guint i;
BatteryPlugin *battery;
BatteryStatus *bat;
+
+ g_return_if_fail (ctx == context);
/* Only allow battery* keys */
if (strncmp (key, "battery", 7) != 0)
return;
+ /* Sometimes HAL Sends > 3 Signals when something changed. We're using just the
+ first time to get all info so the widgets are updated once to save cpu time */
+ if (g_timer_elapsed (update_timer, NULL) > MAX_UPDATE_INTERVAL)
+ {
+ DBG ("Update new properties, last run %.1f seconds ago", g_timer_elapsed (update_timer, NULL));
+ g_timer_reset (update_timer);
+ }
+ else
+ return;
+
+ /* Get the plugin structure */
battery = libhal_ctx_get_user_data (ctx);
-
- g_return_if_fail (ctx == context);
-
- dbus_error_init (&error);
-
+
+ /* Search the battery from the list */
for (i = battery->batteries->len; i--; )
{
bat = g_ptr_array_index (battery->batteries, i);
-
- if (G_LIKELY (strcmp (bat->udi, udi) == 0))
- {
- battery_store_propery (ctx, udi, key, bat, error);
- battery_update_plugin (battery);
-
- break;
- }
+
+#ifdef DUMMIES
+ /* Skip dummy batteries */
+ if (strcmp (bat->udi, "dummy") == 0)
+ continue;
+#endif
+ /* Store the new battery values */
+ battery_store_properties (bat, bat->udi);
}
- if (G_UNLIKELY (dbus_error_is_set (&error)))
- {
- DBG ("DBus Error: %s: %s", error.name, error.message);
- dbus_error_free (&error);
- }
+ /* Update the plugin */
+ battery_update_plugin (battery);
}
void
battery_remove (BatteryStatus *bat)
{
- DBusError error;
- dbus_error_init (&error);
-
- if (dbus_error_is_set (&error))
- {
- DBG ("DBus Error: %s: %s", error.name, error.message);
- dbus_error_free (&error);
- }
-
+ /* Free all the battery information */
g_free (bat->udi);
g_free (bat);
}
@@ -138,86 +165,75 @@
DBG ("Interting dummy batteries");
- /* Dummy 1 */
+ /* Dummy 1: Discharging battery */
bat = g_new0 (BatteryStatus, 1);
- bat->udi = g_strdup ("/org/freedesktop/Hal/devices/acpi_BAT97");
- bat->charging = FALSE;
- bat->present = TRUE;
- bat->percentage = 81;
- bat->time = 2000;
- bat->active_action = NONE;
+ bat->udi = g_strdup ("dummy");
+ bat->charging = FALSE;
+ bat->present = TRUE;
+ bat->percentage = 81;
+ bat->time = 2000;
+ bat->status = NONE;
g_ptr_array_add (battery->batteries, bat);
- /* Dummy 2 */
+ /* Dummy 2: A charing battery */
bat = g_new0 (BatteryStatus, 1);
- bat->udi = g_strdup ("/org/freedesktop/Hal/devices/acpi_BAT98");
- bat->charging = TRUE;
- bat->present = TRUE;
- bat->percentage = 44;
- bat->time = 3800;
- bat->active_action = NONE;
+ bat->udi = g_strdup ("dummy");
+ bat->charging = TRUE;
+ bat->present = TRUE;
+ bat->percentage = 44;
+ bat->time = 3800;
+ bat->status = NONE;
g_ptr_array_add (battery->batteries, bat);
- /* Dummy 3 */
+ /* Dummy 3: This battery is not connected to the system, but with some weird values */
bat = g_new0 (BatteryStatus, 1);
- bat->udi = g_strdup ("/org/freedesktop/Hal/devices/acpi_BAT99");
- bat->charging = FALSE;
- bat->present = FALSE;
- bat->percentage = 0;
- bat->time = 0;
- bat->active_action = NONE;
+ bat->udi = g_strdup ("dummy");
+ bat->charging = TRUE;
+ bat->present = FALSE;
+ bat->percentage = 10;
+ bat->time = 450;
+ bat->status = NONE;
g_ptr_array_add (battery->batteries, bat);
-}
-#endif
+ /* Dummy 4: Discharging battery */
+ bat = g_new0 (BatteryStatus, 1);
-static void
-battery_refresh_settings (BatteryStatus *bat,
- const gchar *udi,
- DBusError error)
-{
- bat->charging = !libhal_device_get_property_bool(context, udi, "battery.rechargeable.is_discharging", &error);
- bat->present = libhal_device_get_property_bool (context, udi, "battery.present", &error);
+ bat->udi = g_strdup ("dummy");
+ bat->charging = FALSE;
+ bat->present = TRUE;
+ bat->percentage = 15;
+ bat->time = 3600;
+ bat->status = NONE;
- bat->percentage = libhal_device_get_property_int (context, udi, "battery.charge_level.percentage", &error);
+ g_ptr_array_add (battery->batteries, bat);
- if (G_LIKELY (libhal_device_property_exists (context, udi, "battery.remaining_time", &error) &&
- libhal_device_get_property_int (context, udi, "battery.remaining_time", &error) > 0))
- bat->time = libhal_device_get_property_int (context, udi, "battery.remaining_time", &error);
- else
- bat->time = 0;
}
+#endif
static void
battery_add (BatteryPlugin *battery,
const gchar *udi)
{
- DBusError error;
BatteryStatus *bat;
-
- dbus_error_init (&error);
bat = g_new0 (BatteryStatus, 1);
- bat->udi = g_strdup (udi);
- bat->active_action = NONE;
+ /* Set battery information */
+ bat->udi = g_strdup (udi);
+ bat->status = NONE;
- battery_refresh_settings (bat, udi, error);
+ /* Load all the current battery settings */
+ battery_store_properties (bat, udi);
+ /* Add new battery to the batteries list */
g_ptr_array_add (battery->batteries, bat);
- if (G_UNLIKELY (dbus_error_is_set (&error)))
- {
- DBG ("DBus Error: %s: %s", error.name, error.message);
- dbus_error_free (&error);
- }
-
DBG ("Added battery: %s", udi);
}
@@ -231,8 +247,14 @@
if (G_UNLIKELY (device_names == NULL || num_devices == 0))
{
- DBG ("Unable to get device list or no batteries found");
+#ifdef DUMMIES
+ DBG ("Unable to get device list or no batteries found, but you're compiling with dummies, so you can still preview");
+ battery_add_dummies (battery);
+ return TRUE;
+#else
+ DBG ("Unable to get device list or no batteries found");
return FALSE;
+#endif
}
DBG ("%d batter%s found", num_devices, num_devices > 1 ? "ies" : "y");
@@ -263,13 +285,17 @@
{
bat = g_ptr_array_index (battery->batteries, i);
+ /* If the device exists, force it to rescan and then update the values */
if (G_LIKELY (libhal_device_exists (context, bat->udi, &error)))
+ {
if (G_LIKELY (libhal_device_rescan (context, bat->udi, &error)))
- battery_refresh_settings (bat, bat->udi, error);
+ battery_store_properties (bat, bat->udi);
+ }
}
if (G_UNLIKELY (dbus_error_is_set (&error)))
{
+ g_warning (_("Unable to rescan the batterie(s), you probably don't have permission to do this"));
DBG ("DBus Error: %s: %s", error.name, error.message);
dbus_error_free (&error);
}
@@ -281,12 +307,17 @@
DBusError error;
dbus_error_init (&error);
+ /* Free the timer */
+ g_timer_destroy (update_timer);
+
+ /* Free the contect */
if (G_LIKELY (context))
{
libhal_ctx_shutdown (context, &error);
libhal_ctx_free (context);
}
+ /* Free the dbus connection */
if (G_LIKELY (dbus_connection))
{
if (G_LIKELY (dbus_connection_get_is_connected (dbus_connection)))
@@ -311,6 +342,9 @@
DBusError error;
dbus_error_init (&error);
+
+ update_timer = g_timer_new ();
+ g_timer_start (update_timer);
dbus_connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
if (G_UNLIKELY (dbus_connection == NULL))
Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-hal.h
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-hal.h 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-hal.h 2006-06-21 19:26:53 UTC (rev 1458)
@@ -24,17 +24,26 @@
G_BEGIN_DECLS
+gchar *
+battery_hal_get_string (const gchar *udi, const gchar *key);
+
+gint
+battery_hal_get_int (const gchar *udi, const gchar *key);
+
+gboolean
+battery_hal_device_exists (const gchar *udi);
+
void
-battery_remove (BatteryStatus *bat);
+battery_remove (BatteryStatus *bat);
void
-battery_rescan_batteries (BatteryPlugin *battery);
+battery_rescan_batteries (BatteryPlugin *battery);
gboolean
-battery_start_monitor (BatteryPlugin *battery);
+battery_start_monitor (BatteryPlugin *battery);
void
-battery_stop_monitor (BatteryPlugin *battery);
+battery_stop_monitor (BatteryPlugin *battery);
G_END_DECLS
Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-overview.c
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-overview.c 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-overview.c 2006-06-21 19:26:53 UTC (rev 1458)
@@ -32,112 +32,126 @@
#include <libxfce4panel/xfce-panel-plugin.h>
#include "battery.h"
+#include "battery-hal.h"
-static gchar *
+static const gchar *
battery_get_status (BatteryStatus *bat)
{
- gchar *status;
-
if (G_UNLIKELY (!bat->present))
- status = g_strdup (_("Battery Not Present"));
+ return _("Battery Not Present");
- else if (G_UNLIKELY (((bat->percentage == 100) && bat->charging)))
- status = g_strdup (_("Battery Fully Charged"));
+ else if (bat->percentage == 100 && bat->charging)
+ return _("Battery Fully Charged");
else if (bat->charging)
- status = g_strdup (_("Battery Charging"));
+ return _("Battery Charging");
else
- status = g_strdup (_("Battery Discharging"));
+ return _("Battery Discharging");
+}
- return status;
+static void
+battery_add_overview_item (GtkWidget *vbox,
+ GtkSizeGroup *sg,
+ const gchar *title,
+ gchar *value)
+
+{
+ if (G_LIKELY (value))
+ {
+ GtkWidget *hbox, *label;
+ gchar *text;
+
+ hbox = gtk_hbox_new (FALSE, BORDER*2);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+
+ text = g_strdup_printf ("<b>%s:</b>", title);
+ label = gtk_label_new (text);
+ g_free (text);
+
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ gtk_size_group_add_widget (sg, label);
+
+ label = gtk_label_new (value);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ g_free (value);
+ }
}
static void
battery_add_overview (GtkWidget *box,
- BatteryStatus *bat)
+ BatteryStatus *bat,
+ GtkSizeGroup *sg)
{
- GtkWidget *hbox, *vbox, *label, *icon, *ibox, *expander;
- gchar *name, *status, *percentage, *time;
+ GtkWidget *hbox, *vbox, *label, *image, *expander;
+ gchar *value;
hbox = gtk_hbox_new (FALSE, BORDER);
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (hbox), BORDER);
/* Battery Icon */
- name = battery_icon_name (bat);
+ value = battery_icon_name (bat);
- icon = gtk_image_new_from_icon_name (name, GTK_ICON_SIZE_DIALOG);
- gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, TRUE, 0);
- gtk_misc_set_alignment (GTK_MISC (icon), 0.5, 0);
- gtk_misc_set_padding (GTK_MISC (icon), 10, 10);
+ image = gtk_image_new_from_icon_name (value, GTK_ICON_SIZE_DIALOG);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
+ gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0);
+ gtk_misc_set_padding (GTK_MISC (image), 10, 0);
+ g_free (value);
- g_free (name);
-
vbox = gtk_vbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
/* Status box */
- ibox = gtk_hbox_new (FALSE, BORDER*2);
- gtk_box_pack_start (GTK_BOX (vbox), ibox, TRUE, TRUE, 0);
-
- label = gtk_label_new (_("<b>Status:</b>"));
- gtk_box_pack_start (GTK_BOX (ibox), label, FALSE, FALSE, 0);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-
- status = battery_get_status (bat);
-
- label = gtk_label_new (status);
- gtk_box_pack_start (GTK_BOX (ibox), label, FALSE, FALSE, 0);
+ value = g_strdup (battery_get_status (bat));
+ battery_add_overview_item (vbox, sg, _("Status"), value);
- g_free (status);
-
/* Percentage */
- ibox = gtk_hbox_new (FALSE, BORDER*2);
- gtk_box_pack_start (GTK_BOX (vbox), ibox, TRUE, TRUE, 0);
-
- label = gtk_label_new (_("<b>Percentage:</b>"));
- gtk_box_pack_start (GTK_BOX (ibox), label, FALSE, FALSE, 0);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ value = g_strdup_printf ("%d%%", bat->percentage > 100 ? 100 : bat->percentage);
+ battery_add_overview_item (vbox, sg, _("Percentage"), value);
- percentage = g_strdup_printf ("%d%%", bat->percentage);
-
- label = gtk_label_new (percentage);
- gtk_box_pack_start (GTK_BOX (ibox), label, FALSE, FALSE, 0);
-
- g_free (percentage);
-
/* Time remaining */
- if (bat->time > 3600)
- time = g_strdup_printf (_("%d hr %d min"), bat->time / 3600, bat->time / 60 % 60);
- else if (bat->time > 0)
- time = g_strdup_printf (_("%d min"), bat->time / 60);
- else
- time = NULL;
+ value = battery_get_time_string (bat->time);
+ battery_add_overview_item (vbox, sg, _("Time"), value);
- if (time)
- {
- ibox = gtk_hbox_new (FALSE, BORDER*2);
- gtk_box_pack_start (GTK_BOX (vbox), ibox, TRUE, TRUE, 0);
-
- label = gtk_label_new (_("<b>Remaining Time:</b>"));
- gtk_box_pack_start (GTK_BOX (ibox), label, FALSE, FALSE, 0);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ /* Check if the device exists, just for safety and to exclude the dummies */
+ if (G_UNLIKELY (battery_hal_device_exists (bat->udi) == FALSE))
+ return;
- label = gtk_label_new (time);
- gtk_box_pack_start (GTK_BOX (ibox), label, FALSE, FALSE, 0);
-
- g_free (time);
- }
-
+ /* Expander */
expander = gtk_expander_new (NULL);
gtk_box_pack_start (GTK_BOX (vbox), expander, TRUE, TRUE, 0);
label = gtk_label_new (_("More..."));
gtk_expander_set_label_widget (GTK_EXPANDER (expander), label);
+
+ vbox = gtk_vbox_new (FALSE, 2);
+ gtk_container_add (GTK_CONTAINER (expander), vbox);
+
+ /* Vendor */
+ value = battery_hal_get_string (bat->udi, "battery.vendor");
+ battery_add_overview_item (vbox, sg, _("Vendor"), value);
+
+ /* Technology */
+ value = battery_hal_get_string (bat->udi, "battery.technology");
+ battery_add_overview_item (vbox, sg, _("Technology:"), value);
+
+ /* Capacity */
+ if (battery_hal_get_int (bat->udi, "battery.reporting.design") &&
+ battery_hal_get_string (bat->udi, "battery.reporting.unit"))
+ {
+ value = g_strdup_printf ("%d %s",
+ battery_hal_get_int (bat->udi, "battery.reporting.design"),
+ battery_hal_get_string (bat->udi, "battery.reporting.unit"));
+ battery_add_overview_item (vbox, sg, _("Design Capacity:"), value);
+ }
+
+ value = battery_hal_get_string (bat->udi, "linux.acpi_path");
+ battery_add_overview_item (vbox, sg, _("ACPI Path:"), value);
}
static void
@@ -156,13 +170,10 @@
BatteryPlugin *battery)
{
GtkWidget *dialog, *window, *dialog_vbox;
+ GtkSizeGroup *sg;
guint i;
BatteryStatus *bat;
-#ifndef USE_NEW_DIALOG
- GtkWidget *header;
-#endif
-
if (ev->button != 1)
return FALSE;
@@ -173,7 +184,6 @@
DBG ("Show Overview");
-#ifdef USE_NEW_DIALOG
dialog = xfce_titled_dialog_new_with_buttons (_("Battery Information"),
NULL,
GTK_DIALOG_NO_SEPARATOR,
@@ -181,34 +191,21 @@
NULL);
xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dialog),
_("An overview of all the batteries in the system"));
-#else
- dialog = gtk_dialog_new_with_buttons (_("Battery Information"),
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (battery->plugin))),
- GTK_DIALOG_DESTROY_WITH_PARENT |
- GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
- NULL);
-#endif
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
gtk_window_set_icon_name (GTK_WINDOW (dialog), "battery");
g_object_set_data (G_OBJECT (battery->plugin), "overview", dialog);
+ sg = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
dialog_vbox = GTK_DIALOG (dialog)->vbox;
-#ifndef USE_NEW_DIALOG
- header = xfce_create_header (NULL, _("Battery Information"));
- gtk_widget_set_size_request (GTK_BIN (header)->child, -1, 32);
- gtk_container_set_border_width (GTK_CONTAINER (header), BORDER);
- gtk_box_pack_start (GTK_BOX (dialog_vbox), header, FALSE, TRUE, 0);
-#endif
-
for (i = 0; i < battery->batteries->len; ++i)
{
bat = g_ptr_array_index (battery->batteries, i);
- battery_add_overview (dialog_vbox, bat);
+ battery_add_overview (dialog_vbox, bat, sg);
}
g_signal_connect(dialog, "response",
Deleted: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-warning.c
Deleted: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-warning.h
Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.c
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.c 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.c 2006-06-21 19:26:53 UTC (rev 1458)
@@ -17,10 +17,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#define SPACING 2
-#define BORDER 4
-#define PROGRESSBAR_WIDTH 8
-#define SMALL_PANEL_SIZE 34
+#define SPACING 2 /* Space between the widgets */
+#define FRAME_BORDER 2 /* Space between the frame and the panel */
+#define BORDER 1 /* Space between the frame and the widgets */
+#define PROGRESSBAR_WIDTH 8 /* Width of the progressbar */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -36,7 +36,7 @@
#include "battery.h"
#include "battery-hal.h"
#include "battery-dialogs.h"
-#include "battery-warning.h"
+#include "battery-actions.h"
#include "battery-overview.h"
static void
@@ -49,40 +49,67 @@
XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (battery_construct);
/* Battery Panel Widgets */
+gchar *
+battery_get_time_string (guint time)
+{
+ gchar *string;
+
+ if (time > 3600)
+ string = g_strdup_printf ("%d %s %d %s", time / 3600, _("hr"),
+ time / 60 % 60, _("min"));
+
+ else if (time > 0)
+ string = g_strdup_printf ("%d %s", time / 60, _("min"));
+
+ else
+ string = NULL;
+
+ return string;
+}
+
static void
battery_tooltip (BatteryPlugin *battery,
GString *tooltip,
BatteryStatus *bat)
{
- if (bat->charging && bat->present) /* Charging */
+ const gchar *charging, *completed, *remaining;
+ gchar *time;
+
+ /* Get time */
+ time = battery_get_time_string (bat->time);
+
+ /* Be nice for translators */
+ charging = _("Charging");
+ completed = _("completed");
+ remaining = _("remaining");
+
+ if (bat->charging && G_LIKELY (bat->present)) /* Charging */
{
- if (bat->percentage == 100)
- tooltip = g_string_append (tooltip, _("Fully Charged (100%)"));
-
- else if (battery->tip_time && G_LIKELY (bat->time > 3600))
- g_string_append_printf (tooltip, _("Charging (%d%% completed)\n%d hr %d min remaining"), bat->percentage, bat->time / 3600, bat->time / 60 % 60);
-
- else if (battery->tip_time && G_LIKELY (bat->time > 0))
- g_string_append_printf (tooltip, _("Charging (%d%% completed)\n%d min remaining"), bat->percentage, bat->time / 60);
-
+ if (bat->percentage >= 100)
+ g_string_append_printf (tooltip, "%s (100%%)",
+ _("Fully Charged"));
+ else if (battery->tip_time && time)
+ g_string_append_printf (tooltip, "%s (%d%% %s)\n%s %s",
+ charging, bat->percentage, completed, time, remaining);
else
- g_string_append_printf (tooltip, _("Charging (%d%% completed)"), bat->percentage);
+ g_string_append_printf (tooltip, "%s (%d%% %s)",
+ charging, bat->percentage, completed);
}
- else if (bat->present)/* Discharging */
+ else if (G_LIKELY (bat->present))/* Discharging */
{
- if (battery->tip_time && bat->time > 3600)
- g_string_append_printf (tooltip, _("%d hr %d min (%d%%) remaining"), bat->time / 3600, bat->time / 60 % 60, bat->percentage);
-
- else if (battery->tip_time && bat->time > 0)
- g_string_append_printf (tooltip, _("%d min (%d%%) remaining"), bat->time / 60, bat->percentage);
-
+ if (battery->tip_time && time)
+ g_string_append_printf (tooltip, "%s (%d%%) %s",
+ time, bat->percentage, remaining);
else
- g_string_append_printf (tooltip, _("%d%% remaining"), bat->percentage);
+ g_string_append_printf (tooltip, "%d%% %s",
+ bat->percentage, remaining);
}
else /* Battery not present in system */
{
tooltip = g_string_append (tooltip, _("Battery not present"));
- }
+ }
+
+ g_free (time);
}
static const gchar *
@@ -90,19 +117,19 @@
{
if (percentage <= 10)
return "000";
-
+
else if (percentage <= 30)
return "020";
-
+
else if (percentage <= 50)
return "040";
-
+
else if (percentage <= 70)
return "060";
-
+
else if (percentage <= 90)
return "080";
-
+
else /* (percentage <= 100) */
return "100";
}
@@ -114,20 +141,20 @@
if (G_UNLIKELY (!bat->present))
name = g_strdup ("battery-missing");
-
- else if (G_UNLIKELY (((bat->percentage == 100) && bat->charging)))
+
+ else if ((bat->percentage >= 100) && bat->charging)
name = g_strdup ("battery-charged");
-
+
else if (bat->charging)
name = g_strconcat ("battery-charging-",
battery_icon_group (bat->percentage),
NULL);
-
+
else
name = g_strconcat ("battery-discharging-",
battery_icon_group (bat->percentage),
NULL);
-
+
return name;
}
@@ -136,35 +163,44 @@
BatteryStatus *bat)
{
gchar *name;
- guint psize;
+ guint psize, isize;
GdkPixbuf *pixbuf = NULL;
if (G_UNLIKELY (!battery->show_icon ||
!GTK_IS_WIDGET (battery->icon)))
return;
-
- name = battery_icon_name (bat);
-
+
+ /* Get the new icon name */
+ name = battery_icon_name (bat);
+
/* Only update icon if it's different from new one */
if (G_UNLIKELY (strcmp (battery->iconname, name) != 0))
{
DBG ("Set (%s) to icon: %s", battery->iconname, name);
-
- /* Get plugin size - the table spacing */
- psize = xfce_panel_plugin_get_size (battery->plugin) - 2 * BORDER;
-
- pixbuf = xfce_themed_icon_load (name, psize);
-
- gtk_image_set_from_pixbuf (GTK_IMAGE (battery->icon),
- pixbuf);
-
- g_object_unref (pixbuf);
-
+
+ /* Get plugin size and calculate the new icon size */
+ psize = xfce_panel_plugin_get_size (battery->plugin);
+ isize = psize - (2 * BORDER) - (2 * (psize > 26 ? 2 : 0)) - (2 * MAX (battery->frame->style->xthickness,
+ battery->frame->style->ythickness));
+
+ /* Load the new icon */
+ pixbuf = xfce_themed_icon_load (name, isize);
+
+ if (pixbuf)
+ {
+ gtk_image_set_from_pixbuf (GTK_IMAGE (battery->icon),
+ pixbuf);
+
+ g_object_unref (G_OBJECT (pixbuf));
+ }
+ else
+ g_warning ("%s \"%s\"", _("Unable to find the icon"), name);
+
/* Set new icon name */
g_free (battery->iconname);
battery->iconname = g_strdup (name);
}
-
+
g_free (name);
}
@@ -172,38 +208,64 @@
battery_widget_label (BatteryPlugin *battery,
BatteryStatus *bat)
{
- gchar *label;
- gchar *strtime;
- gchar *strperc;
- gboolean small;
+ gchar *label;
+ gchar *time;
+ gchar *percentage;
+ guint psize;
+ gboolean both;
+ const gchar *textsize;
if (!(battery->show_percentage | battery->show_time))
return;
-
- if (G_LIKELY (!GTK_IS_WIDGET (battery->label)))
+
+ if (!GTK_IS_WIDGET (battery->label))
return;
+
+ /* Get the plugin size */
+ psize = xfce_panel_plugin_get_size (battery->plugin);
+
+ /* Create percentage string */
+ if (battery->show_percentage)
+ percentage = g_strdup_printf ("%d%%", bat->percentage);
+ else
+ percentage = NULL;
+
+ /* Create time string */
+ if (battery->show_time && bat->time > 0)
+ time = g_strdup_printf ("%d:%02d", bat->time / 3600, bat->time / 60 % 60);
+ else if (battery->show_time)
+ time = g_strdup ("0:00");
+ else
+ time = NULL;
- small = xfce_panel_plugin_get_size (battery->plugin) <= SMALL_PANEL_SIZE;
+ /* Are both values visible? */
+ both = battery->show_time && battery->show_percentage;
- strperc = g_strdup_printf ("%d%%", bat->percentage);
+ /* Get textsize (arbitrary) */
+ if ((both && psize <= 25))
+ textsize = "xx-small";
+ else if ((both && psize <= 30) || (!both && psize <= 20))
+ textsize = "x-small";
+ else if ((both && psize <= 40) || (!both && psize <= 40))
+ textsize = "small";
+ else if (psize <= 50)
+ textsize = "medium";
+ else /* For (almost) blind people ^_^ */
+ textsize = "large";
- if (G_LIKELY (bat->time > 0))
- strtime = g_strdup_printf ("%d:%02d", bat->time / 3600, bat->time / 60 % 60);
- else
- strtime = g_strdup ("0:00");
-
- label = g_strconcat (small ? "<small>" : "",
- battery->show_percentage ? strperc : "",
- battery->show_percentage && battery->show_time ? "\n" : "",
- battery->show_time ? strtime : "",
- small ? "</small>" : "",
- NULL);
+ /* Build the label */
+ label = g_strdup_printf ("<span size=\"%s\">%s%s%s</span>",
+ textsize,
+ percentage ? percentage : "",
+ both ? "\n" : "",
+ time ? time : "");
+ /* Free */
+ g_free (time);
+ g_free (percentage);
/* Set the label, no checking here because it's almost different any time */
gtk_label_set_label (GTK_LABEL(battery->label), label);
-
- g_free (strtime);
- g_free (strperc);
+
g_free (label);
}
@@ -214,8 +276,8 @@
if (G_UNLIKELY (!battery->show_progressbar ||
!GTK_IS_WIDGET (battery->progressbar)))
return;
-
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (battery->progressbar),
+
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (battery->progressbar),
bat->percentage / 100.0);
}
@@ -224,25 +286,35 @@
{
GtkOrientation orientation;
GtkWidget *box;
+ guint size;
g_return_if_fail (battery->running);
orientation = xfce_panel_plugin_get_orientation (battery->plugin);
-
+ size = xfce_panel_plugin_get_size (battery->plugin);
+
/* Destroy all widgets */
if (battery->ebox)
- gtk_widget_destroy (battery->ebox);
+ gtk_widget_destroy (battery->ebox);
/* Rebuild the plugin */
battery->ebox = gtk_event_box_new ();
+
+ /* Create frame */
+ battery->frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (battery->frame),
+ battery->show_frame ? GTK_SHADOW_IN : GTK_SHADOW_NONE);
+ gtk_container_add (GTK_CONTAINER (battery->ebox), battery->frame);
+ gtk_container_set_border_width (GTK_CONTAINER (battery->frame),
+ size > 26 ? FRAME_BORDER : 0);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
box = gtk_hbox_new (FALSE, SPACING);
- else
+ else
box = gtk_vbox_new (FALSE, SPACING);
gtk_container_set_border_width (GTK_CONTAINER (box), BORDER);
- gtk_container_add (GTK_CONTAINER (battery->ebox), box);
+ gtk_container_add (GTK_CONTAINER (battery->frame), box);
if (battery->show_icon)
{
@@ -267,14 +339,14 @@
gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (battery->progressbar), GTK_PROGRESS_LEFT_TO_RIGHT);
}
}
-
+
if (battery->show_percentage || battery->show_time)
{
battery->label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (box), battery->label, FALSE, FALSE, 0);
gtk_label_set_use_markup (GTK_LABEL (battery->label), TRUE);
}
-
+
/* Display Widgets and (re)connect signals */
gtk_widget_show_all (battery->ebox);
@@ -299,7 +371,7 @@
psize = xfce_panel_plugin_get_size (battery->plugin) - SPACING*2;
pixbuf = xfce_themed_icon_load("battery-missing", psize);
battery->icon = gtk_image_new_from_pixbuf (pixbuf);
- g_object_unref (pixbuf);
+ g_object_unref (G_OBJECT (pixbuf));
gtk_container_add (GTK_CONTAINER (battery->ebox), battery->icon);
gtk_widget_show_all (battery->ebox);
@@ -308,57 +380,30 @@
xfce_panel_plugin_add_action_widget (battery->plugin, battery->ebox);
}
-/* Battery Actions */
-
-static void
-battery_run_action (ActionType type,
- BatteryPlugin *battery,
- Action action,
- gchar *command)
-{
- switch (action)
- {
- case MESSAGE:
- battery_warning (battery, type);
- break;
-
- case COMMAND:
- if (!xfce_exec (command, FALSE, FALSE, NULL))
- goto failed;
- break;
-
- case TERMINAL:
- if (!xfce_exec (command, TRUE, FALSE, NULL))
- goto failed;
- break;
-
- default:
- break;
- }
-
- return;
-
- failed:
- g_warning (_("The battery monitor was unable to execute following command: %s"), command);
-}
-
/* Update the plugin */
void
battery_update_plugin (BatteryPlugin *battery)
{
- guint i;
+ guint i, actions = 0;
GString *tooltip;
BatteryStatus *bat;
-
+ GtkWidget *messages;
+
g_return_if_fail (battery->running);
tooltip = g_string_new ("");
+ /* Destroy the old dialog and reset the counter */
+ battery_actions_dialog_destroy (battery);
+
+ /* Init new message dialog */
+ messages = battery_actions_dialog_init ();
+
/* Loop for each battery that was found */
for (i = 0; i < battery->batteries->len; ++i)
{
bat = g_ptr_array_index (battery->batteries, i);
-
+
/* If this battery is the battery that is shown in the panel, update it */
if (G_LIKELY (i == battery->show_battery))
{
@@ -366,7 +411,7 @@
battery_widget_label (battery, bat);
battery_widget_icon (battery, bat);
}
-
+
/* Build the tooltip */
if (G_LIKELY (battery->batteries->len == 1))
{
@@ -375,110 +420,91 @@
else
{
g_string_append_printf (tooltip, _("Battery %d:\n"), i+1);
-
+
battery_tooltip (battery, tooltip, bat);
-
+
if (G_LIKELY (i < (battery->batteries->len-1)))
tooltip = g_string_append (tooltip, "\n\n");
}
-
- /* Check for actions. The battery_run_action is triggered only
- once to prevent useless behaviours */
+
+ /* Store new actions */
if (bat->charging && G_LIKELY (bat->present))
{
- if (G_UNLIKELY (bat->percentage == 100))
+ if (G_UNLIKELY (bat->percentage >= 100))
{
- if (bat->active_action != CHARGED)
+ if (bat->status != CHARGED)
{
- DBG ("Battery is fully charged -> run action");
- bat->active_action = CHARGED;
-
- battery_run_action (CHARGED,
- battery,
- battery->action_charged,
- battery->command_charged);
+ /* Battery is fully charged */
+ bat->status = CHARGED;
+ battery_actions_check (bat,
+ i,
+ messages,
+ battery->action_charged,
+ battery->command_charged);
}
}
- else
+ else if (bat->status != NONE)
{
- if (bat->active_action != NONE)
- {
- /* Stop the warning timout */
- battery_warning_stop ();
-
- /* Reset the current battery action */
- bat->active_action = NONE;
-
- /* Check if the warning message is shown, if so, destroy it */
- GtkWidget *warning = g_object_get_data (G_OBJECT (battery->plugin), "warning");
-
- if (G_UNLIKELY (warning))
- {
- DBG ("Destroy dialog");
- g_object_set_data (G_OBJECT (battery->plugin), "warning", NULL);
- gtk_widget_destroy (warning);
- }
- }
+ /* Reset the status */
+ bat->status = NONE;
}
}
- else if (G_LIKELY (bat->present)) /* Not charging, but present in system */
+ else if (G_LIKELY (bat->present)) /* Discharging */
{
if (bat->percentage <= battery->perc_critical)
{
- if (bat->active_action != CRITICAL)
+ if (bat->status != CRITICAL)
{
- DBG ("Battery status is critical -> run action");
- bat->active_action = CRITICAL;
-
- battery_run_action (CRITICAL,
- battery,
- battery->action_critical,
- battery->command_critical);
+ /* Status is critical */
+ bat->status = CRITICAL;
+ actions++;
+ battery_actions_check (bat,
+ i,
+ messages,
+ battery->action_critical,
+ battery->command_critical);
}
}
else if (bat->percentage <= battery->perc_low)
{
- if (bat->active_action != LOW)
+ if (bat->status != LOW)
{
- DBG ("Battery status is low -> run action");
- bat->active_action = LOW;
-
- battery_run_action (LOW,
- battery,
- battery->action_low,
- battery->command_low);
+ /* Status is low */
+ bat->status = LOW;
+ actions++;
+ battery_actions_check (bat,
+ i,
+ messages,
+ battery->action_low,
+ battery->command_low);
}
}
- else
+ else if (bat->status != NONE)
{
- if (bat->active_action != NONE)
- {
- /* Stop the warning timout */
- battery_warning_stop ();
-
- /* Reset the current battery action */
- bat->active_action = NONE;
-
- /* Check if the warning message is shown, if so, destroy it */
- GtkWidget *warning = g_object_get_data (G_OBJECT (battery->plugin), "warning");
-
- if (G_UNLIKELY (warning))
- {
- DBG ("Destroy dialog");
- g_object_set_data (G_OBJECT (battery->plugin), "warning", NULL);
- gtk_widget_destroy (warning);
- }
- }
+ /* Reset the status */
+ bat->status = NONE;
}
}
- }
-
+ else if (bat->status != NONE)
+ {
+ /* No battery, clear the status */
+ bat->status = NONE;
+ }
+ } /* for batteries */
+
+ /* Set and free the tooltip */
gtk_tooltips_set_tip (battery->tooltip,
battery->ebox,
tooltip->str,
NULL);
-
g_string_free (tooltip, TRUE);
+
+ /* Create the message dialog, if there are any items */
+ battery_actions_dialog_create (battery, messages);
+
+ /* Check if we need to reset the timeouts */
+ if (actions)
+ battery_actions_restart_timeout (battery);
}
static void
@@ -492,39 +518,40 @@
if (G_UNLIKELY (!file))
return;
-
+
DBG("Read from file: %s", file);
-
+
rc = xfce_rc_simple_open (file, FALSE);
g_free (file);
-
+
xfce_rc_set_group (rc, "Properties");
-
+
battery->show_battery = xfce_rc_read_int_entry (rc, "show_battery", 0);
-
+
+ battery->show_frame = xfce_rc_read_bool_entry (rc, "show_frame", TRUE);
battery->show_icon = xfce_rc_read_bool_entry (rc, "show_icon", TRUE);
- battery->show_progressbar = xfce_rc_read_bool_entry (rc, "show_progressbar", TRUE);
+ battery->show_progressbar = xfce_rc_read_bool_entry (rc, "show_progressbar", FALSE);
battery->show_percentage = xfce_rc_read_bool_entry (rc, "show_percentage", TRUE);
- battery->show_time = xfce_rc_read_bool_entry (rc, "show_time", TRUE);
-
+ battery->show_time = xfce_rc_read_bool_entry (rc, "show_time", FALSE);
+
battery->tip_time = xfce_rc_read_bool_entry (rc, "tip_time", TRUE);
-
+
battery->action_critical = xfce_rc_read_int_entry (rc, "action_critical", 1);
battery->action_low = xfce_rc_read_int_entry (rc, "action_low", 1);
battery->action_charged = xfce_rc_read_int_entry (rc, "action_charged", 0);
-
+
battery->perc_critical = xfce_rc_read_int_entry (rc, "perc_critical", 10);
battery->perc_low = xfce_rc_read_int_entry (rc, "perc_low", 20);
-
+
if((s = xfce_rc_read_entry (rc, "command_critical", "")) != NULL);
battery->command_critical = g_strdup (s);
-
+
if ((s = xfce_rc_read_entry (rc, "command_low", NULL)) != NULL)
battery->command_low = g_strdup (s);
-
+
if ((s = xfce_rc_read_entry (rc, "command_charged", NULL)) != NULL)
battery->command_charged = g_strdup (s);
-
+
xfce_rc_close (rc);
}
@@ -539,27 +566,28 @@
if (G_UNLIKELY (!file))
return;
-
+
DBG("Save to file: %s", file);
-
+
rc = xfce_rc_simple_open (file, FALSE);
g_free (file);
-
+
xfce_rc_set_group (rc, "Properties");
-
+
xfce_rc_write_int_entry (rc, "show_battery", battery->show_battery);
-
+
+ xfce_rc_write_bool_entry (rc, "show_frame", battery->show_frame);
xfce_rc_write_bool_entry (rc, "show_icon", battery->show_icon);
xfce_rc_write_bool_entry (rc, "show_progressbar", battery->show_progressbar);
xfce_rc_write_bool_entry (rc, "show_percentage", battery->show_percentage);
xfce_rc_write_bool_entry (rc, "show_time", battery->show_time);
xfce_rc_write_bool_entry (rc, "tip_time", battery->tip_time);
-
+
xfce_rc_write_int_entry (rc, "action_critical", battery->action_critical);
xfce_rc_write_int_entry (rc, "action_low", battery->action_low);
xfce_rc_write_int_entry (rc, "action_charged", battery->action_charged);
-
+
xfce_rc_write_int_entry (rc, "perc_critical", battery->perc_critical);
xfce_rc_write_int_entry (rc, "perc_low", battery->perc_low);
@@ -576,7 +604,7 @@
{
guint i;
BatteryStatus *bat;
- GtkWidget *configure, *warning, *overview;
+ GtkWidget *configure, *messages, *overview;
/* Remove the batteries array */
for (i = battery->batteries->len; i--;)
@@ -586,81 +614,77 @@
battery_remove (bat);
}
g_ptr_array_free (battery->batteries, TRUE);
-
+
/* Remove tooltip */
gtk_tooltips_set_tip (battery->tooltip, battery->ebox, NULL, NULL);
- g_object_unref (battery->tooltip);
+ g_object_unref (G_OBJECT (battery->tooltip));
/* Stop HAL Monitor */
battery_stop_monitor (battery);
-
- /* Stop battery warning timout */
- battery_warning_stop ();
+ /* Stop battery actions timout */
+ battery_actions_stop_timeout ();
+
/* Destroy windows (properties, warnings, errors */
configure = g_object_get_data (G_OBJECT (plugin), "configure");
- warning = g_object_get_data (G_OBJECT (plugin), "warning");
+ messages = g_object_get_data (G_OBJECT (plugin), "messages");
overview = g_object_get_data (G_OBJECT (plugin), "overview");
-
+
if (configure)
gtk_widget_destroy (configure);
- if (warning)
- gtk_widget_destroy (warning);
+ if (messages)
+ gtk_widget_destroy (messages);
if (overview)
gtk_widget_destroy (overview);
-
+
/* Destroy Panel Widgets */
- if (battery->icon)
- gtk_widget_destroy (battery->icon);
- if (battery->progressbar)
- gtk_widget_destroy (battery->progressbar);
- if (battery->label)
- gtk_widget_destroy (battery->label);
if (battery->ebox)
- gtk_widget_destroy (battery->ebox);
-
+ gtk_widget_destroy (battery->ebox);
+
g_free (battery->iconname);
-
+
g_free (battery->command_critical);
g_free (battery->command_low);
g_free (battery->command_charged);
battery->plugin = NULL;
-
+
g_free (battery);
-
+
DBG ("Plugin Freed");
}
static gboolean
-battery_set_size (XfcePanelPlugin *plugin,
+battery_set_size (XfcePanelPlugin *plugin,
gint wsize,
BatteryPlugin *battery)
{
- DBG ("Set plugin size");
-
/* Update size of the plugin */
if (xfce_panel_plugin_get_orientation (plugin) == GTK_ORIENTATION_HORIZONTAL)
gtk_widget_set_size_request (GTK_WIDGET (plugin), -1, wsize);
else
gtk_widget_set_size_request (GTK_WIDGET (plugin), wsize, -1);
+
+ /* Set the border width of the frame */
+ gtk_container_set_border_width (GTK_CONTAINER (battery->frame),
+ wsize > 26 ? FRAME_BORDER : 0);
/* Reset icon name so it will be updated */
g_free (battery->iconname);
battery->iconname = g_strdup ("");
battery_update_plugin (battery);
-
+
return TRUE;
}
static void
-battery_orientation_changed (XfcePanelPlugin *plugin,
+battery_orientation_changed (XfcePanelPlugin *plugin,
GtkOrientation orientation,
BatteryPlugin *battery)
{
DBG ("Change orientation");
-
+
battery_widgets (battery);
}
@@ -696,49 +720,52 @@
battery_error_widget (battery);
return battery;
}
-
+
+ /* Set battery count for actions */
+ battery_actions_set_len (battery->batteries->len);
+
/* Check if the default battery exists */
if (battery->show_battery + 1 > battery->batteries->len)
battery->show_battery = 0;
-
+
/* Tell everyone hal is running and batteries are all fine */
battery->running = TRUE;
-
+
/* Add refresh options to right click menu */
mi = gtk_image_menu_item_new_from_stock ("gtk-refresh", NULL);
gtk_widget_show (mi);
- g_signal_connect(mi, "activate",
+ g_signal_connect(mi, "activate",
G_CALLBACK(battery_manual_update), battery);
xfce_panel_plugin_menu_insert_item (plugin, GTK_MENU_ITEM (mi));
-
+
battery_widgets (battery);
-
+
return battery;
}
-static void
+static void
battery_construct (XfcePanelPlugin *plugin)
{
BatteryPlugin *battery;
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
-
+
battery = battery_plugin_new (plugin);
/* Connect Plugin Signals */
- g_signal_connect (plugin, "free-data",
+ g_signal_connect (plugin, "free-data",
G_CALLBACK (battery_free), battery);
- g_signal_connect (plugin, "save",
+ g_signal_connect (plugin, "save",
G_CALLBACK (battery_save), battery);
g_signal_connect (plugin, "size-changed",
G_CALLBACK (battery_set_size), battery);
- g_signal_connect (plugin, "orientation-changed",
+ g_signal_connect (plugin, "orientation-changed",
G_CALLBACK (battery_orientation_changed), battery);
-
+
xfce_panel_plugin_menu_show_configure (plugin);
- g_signal_connect (plugin, "configure-plugin",
+ g_signal_connect (plugin, "configure-plugin",
G_CALLBACK (battery_configure), battery);
}
Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.desktop.in.in
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.desktop.in.in 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.desktop.in.in 2006-06-21 19:26:53 UTC (rev 1458)
@@ -4,5 +4,4 @@
_Name=Battery Monitor
_Comment=Show and monitor the battery status
Icon=battery
-X-XFCE-Exec=@EXTERNAL_PLUGIN_PATH@/xfce4-battery-plugin
-#X-XFCE-Unique=true
\ No newline at end of file
+X-XFCE-Exec=@EXTERNAL_PLUGIN_PATH@/xfce4-battery-plugin
\ No newline at end of file
Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.h
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.h 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.h 2006-06-21 19:26:53 UTC (rev 1458)
@@ -28,10 +28,12 @@
{
NOTHING = 0,
MESSAGE,
+#ifdef HAVE_LIBNOTIFY
+ NOTIFICATION,
+#endif
COMMAND,
TERMINAL,
-}
-Action;
+} ActiveAction;
typedef enum
{
@@ -40,19 +42,19 @@
LOW,
CRITICAL,
}
-ActionType;
+ActiveStatus;
typedef struct
{
- gchar *udi; /* /org/freedesktop/Hal/devices/acpi_BAT0 */
+ gchar *udi; /* /org/freedesktop/Hal/devices/acpi_BAT0 */
- gboolean charging;
- gboolean present;
+ gboolean charging;
+ gboolean present;
+
+ ActiveStatus status;
- ActionType active_action;
-
- gint time;
- guint percentage;
+ gint time;
+ guint percentage;
}
BatteryStatus;
@@ -65,7 +67,7 @@
GPtrArray *batteries;
/* Widgets */
- GtkWidget *ebox, *icon, *progressbar, *label;
+ GtkWidget *ebox, *frame, *icon, *progressbar, *label;
GtkTooltips *tooltip;
/* Widget Settings */
@@ -73,27 +75,30 @@
guint show_battery;
/* Settings: Appearance */
- gboolean show_icon, show_progressbar, show_percentage, show_time;
+ gboolean show_frame, show_icon, show_progressbar, show_percentage, show_time;
gboolean tip_time;
/* Settings: Actions */
guint perc_critical, perc_low;
- Action action_critical, action_low, action_charged;
+ ActiveAction action_critical, action_low, action_charged;
gchar *command_critical, *command_low, *command_charged;
}
BatteryPlugin;
gchar *
-battery_icon_name (BatteryStatus *bat);
+battery_get_time_string (guint time);
+gchar *
+battery_icon_name (BatteryStatus *bat);
+
void
-battery_widgets (BatteryPlugin *battery);
+battery_widgets (BatteryPlugin *battery);
void
-battery_update_plugin (BatteryPlugin *battery);
+battery_update_plugin (BatteryPlugin *battery);
void
-battery_save (XfcePanelPlugin *plugin, BatteryPlugin *battery);
+battery_save (XfcePanelPlugin *plugin, BatteryPlugin *battery);
G_END_DECLS
Added: xfce4-battery-plugin/branches/XERVERIUS/po/ChangeLog
===================================================================
Added: xfce4-battery-plugin/branches/XERVERIUS/po/LINGUAS
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/po/LINGUAS (rev 0)
+++ xfce4-battery-plugin/branches/XERVERIUS/po/LINGUAS 2006-06-21 19:26:53 UTC (rev 1458)
@@ -0,0 +1,2 @@
+# set of available languages (in alphabetic order)
+
Modified: xfce4-battery-plugin/branches/XERVERIUS/po/POTFILES.in
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/po/POTFILES.in 2006-06-21 19:06:57 UTC (rev 1457)
+++ xfce4-battery-plugin/branches/XERVERIUS/po/POTFILES.in 2006-06-21 19:26:53 UTC (rev 1458)
@@ -1,9 +1,6 @@
-# List of source files containing translatable strings.
-
+panel-plugin/battery.c
+panel-plugin/battery-actions.c
panel-plugin/battery-hal.c
+panel-plugin/battery.desktop.in.in
panel-plugin/battery-dialogs.c
-panel-plugin/battery-warning.c
-panel-plugin/battery.c
-
-# Files added by intltool-prepare.
-panel-plugin/battery.desktop.in.in
\ No newline at end of file
+panel-plugin/battery-overview.c
More information about the Goodies-commits
mailing list