[Xfce4-commits] <xfce4-battery-plugin:upower> New branch of the battery plugin, based on devkit-power, which seems that it is decided that going to be renamed to upower, for now we use devkit as there is no upower release yet.

Ali Abdallah noreply at xfce.org
Thu Dec 10 21:06:01 CET 2009


Updating branch refs/heads/upower
         to 36e29fccfdfe545dbbc5ea1c8de661af92837857 (commit)
       from fd374c61b33193e42d34af87edf782e714499e98 (commit)

commit 36e29fccfdfe545dbbc5ea1c8de661af92837857
Author: Ali Abdallah <aliov at xfce.org>
Date:   Thu Dec 10 20:58:31 2009 +0100

    New branch of the battery plugin, based on devkit-power, which seems that it is decided that
    going to be renamed to upower, for now we use devkit as there is no upower release yet.
    
    The plugin can be compiled with libxfce4ui or libxfcegui4 and it supports multiple
    batteries, no release will be made from this branch until upower reaches a reasonable
    API stability.

 AUTHORS                                            |    8 +-
 COPYING                                            |    4 +-
 COPYING.LIB                                        |  437 ------
 ChangeLog                                          |  124 --
 INSTALL                                            |  302 +++++
 Makefile.am                                        |   42 +-
 NEWS                                               |    1 +
 README                                             |    3 -
 TODO                                               |    1 +
 autogen.sh                                         |   28 +-
 configure.ac.in                                    |   83 ++
 configure.in.in                                    |   93 --
 module.xml                                         |   19 +
 panel-plugin/Makefile.am                           |   45 +-
 panel-plugin/batt-plugin.c                         |  776 +++++++++++
 panel-plugin/battery.c                             | 1418 --------------------
 panel-plugin/libacpi.c                             |  755 -----------
 panel-plugin/libacpi.h                             |   91 --
 panel-plugin/libapm.c                              |  473 -------
 panel-plugin/libapm.h                              |   74 -
 panel-plugin/settings.ui                           |   66 +
 ...op.in.in => xfce4-battery-plugin.desktop.in.in} |    0
 22 files changed, 1317 insertions(+), 3526 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index fa80a17..70526e9 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,7 +1 @@
-Eduard Roccatello <eduard at xfce.org
-Nick Penwarden <toth64 at yahoo.com>
-Benedikt Meurer <benny at xfce.org>
-Edscott Wilson Garcia <edscott at users.sourceforge.net>
-Rickard E. Faith <faith at acm.org>
-Noberasco Michele <2001s098 at educ.disi.unige.it>
-Nick Schermer <nick at xfce.org>
+Ali Abdallah aliov at xfce.org
\ No newline at end of file
diff --git a/COPYING b/COPYING
index d60c31a..623b625 100644
--- a/COPYING
+++ b/COPYING
@@ -2,7 +2,7 @@
 		       Version 2, June 1991
 
  Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
@@ -305,7 +305,7 @@ the "copyright" line and a pointer to where the full notice is found.
 
     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
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 
 Also add information on how to contact you by electronic and paper mail.
diff --git a/COPYING.LIB b/COPYING.LIB
deleted file mode 100644
index 191a97f..0000000
--- a/COPYING.LIB
+++ /dev/null
@@ -1,437 +0,0 @@
-		  GNU LIBRARY GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
-
- Copyright (C) 1991 Free Software Foundation, Inc.
-    		    59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the library GPL.  It is
- numbered 2 because it goes with version 2 of the ordinary GPL.]
-
-			    Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Library General Public License, applies to some
-specially designated Free Software Foundation software, and to any
-other libraries whose authors decide to use it.  You can use it for
-your libraries, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if
-you distribute copies of the library, or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link a program with the library, you must provide
-complete object files to the recipients so that they can relink them
-with the library, after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  Our method of protecting your rights has two steps: (1) copyright
-the library, and (2) offer you this license which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  Also, for each distributor's protection, we want to make certain
-that everyone understands that there is no warranty for this free
-library.  If the library is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original
-version, so that any problems introduced by others will not reflect on
-the original authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that companies distributing free
-software will individually obtain patent licenses, thus in effect
-transforming the program into proprietary software.  To prevent this,
-we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
-
-  Most GNU software, including some libraries, is covered by the ordinary
-GNU General Public License, which was designed for utility programs.  This
-license, the GNU Library General Public License, applies to certain
-designated libraries.  This license is quite different from the ordinary
-one; be sure to read it in full, and don't assume that anything in it is
-the same as in the ordinary license.
-
-  The reason we have a separate public license for some libraries is that
-they blur the distinction we usually make between modifying or adding to a
-program and simply using it.  Linking a program with a library, without
-changing the library, is in some sense simply using the library, and is
-analogous to running a utility program or application program.  However, in
-a textual and legal sense, the linked executable is a combined work, a
-derivative of the original library, and the ordinary General Public License
-treats it as such.
-
-  Because of this blurred distinction, using the ordinary General
-Public License for libraries did not effectively promote software
-sharing, because most developers did not use the libraries.  We
-concluded that weaker conditions might promote sharing better.
-
-  However, unrestricted linking of non-free programs would deprive the
-users of those programs of all benefit from the free status of the
-libraries themselves.  This Library General Public License is intended to
-permit developers of non-free programs to use free libraries, while
-preserving your freedom as a user of such programs to change the free
-libraries that are incorporated in them.  (We have not seen how to achieve
-this as regards changes in header files, but we have achieved it as regards
-changes in the actual functions of the Library.)  The hope is that this
-will lead to faster development of free libraries.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, while the latter only
-works together with the library.
-
-  Note that it is possible for a library to be covered by the ordinary
-General Public License rather than by this special one.
-
-		  GNU LIBRARY GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library which
-contains a notice placed by the copyright holder or other authorized
-party saying it may be distributed under the terms of this Library
-General Public License (also called "this License").  Each licensee is
-addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-  
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
-  6. As an exception to the Sections above, you may also compile or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Accompany the work with a written offer, valid for at
-    least three years, to give the same user the materials
-    specified in Subsection 6a, above, for a charge no more
-    than the cost of performing this distribution.
-
-    c) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    d) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the source code distributed need not include anything that is normally
-distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded.  In such case, this License incorporates the limitation as if
-written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Library General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-			    NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
diff --git a/ChangeLog b/ChangeLog
index fdc3f8b..8b13789 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,125 +1 @@
-2008-09-21	Mike Massonnet <mmassonnet at xfce.org>
-	* Fix build for libtool 2.2 (or at least for ArchLinux)
-
-2008-09-04	Auke Kok <sofar at xfce.org>
-	* Reduce polling interval for ACPI reads to reduce ACPI interrupts.
-
-2007-08-17	Nick Schermer <nick at xfce.org>
-
-	* Apply patch to fix compilation with kfreebsd (Bug #3040).
-	* Apply patch to make the plugin work with newer kernels (Bug #3190).
-
-2007-01-17	Nick Schermer <nick at xfce.org>
-
-	* Remove the inline icon and add Tango icons.
-	* Improve Makefile.am and configure files.
-	* Use the battery icon in the desktop file.
-	* Fix LDADD to prevent linker problems.
-	* Bump version to 0.5.0 for release with Xfce 4.4.0
-
-2006-12-20	Nick Schermer <nick at xfce.org>
-
-	* panel-plugin/battery.c: Add help button with exo-open
-	  to battery wiki page.
-	* po/*.po: Merge new string
-
-2006-10-22	Nick Schermer <nick at xfce.org>
-
-	* Regenerated po files
-	* Applied atch from Tim Baga <tim.baga at gmail dot com>
-	  * Fixed update_apm_status() to allow plugin display correct
-	    information on systems with multiple batteries.
-	  * Maid few fixes to avoid overlapping remaining time/percentage
-	    labels on small panel height.
-	  * Due to different ACPI data update time on different systems made
-	    approx. 10 seconds averaging of calculations of remaining time/percentage.
-	  * Now plugin shows remaining discharge time when ac adaptor is off,
-	    otherwise remaining charge time.
-	  * Added option "hide time/percentage when full". Actually it hides
-	    appropriate labels when battery is charging, and it's charge >= 99%.
-	  * Changed default low/critical battery action to "Display a warning message".
-
-2006-09-06	Nick Schermer <nick at xfce.org>
-
-	* Added $Id$ using svn:keywords
-	* Added COPYING.LIB for libacpi and libapm
-	* Updated the copyright text in all *.c and *.h files
-	* Regenerated po files
-	* Some improvements in build files
-
-2006-09-02	Nick Schermer <nick at xfce.org>
-
-	* configure.in.in, Makefile.am, panel-plugin/Makefile.am: Improvements
-	in build files. This also makes building with as-needed possible.
-	* libapm.c, libapm.h, battery.c: Rename files
-
-2006-09-01	Nick Schermer <nick at xfce.org>
-
-	* Bumped version to 0.4.90.2 for release.
-
-2006-09-01	Nick Schermer <nick at xfce.org>
-
-	* panel-plugin/battmon.c, panel-plugin/libacpi.c: Applied patches (or
-	parts of it) from Bug #1261, Bug #1475
-	* panel-plugin/battmon.c, panel-plugin/libacpi.c: NetBSD patch from
-	Stefan Sperling <stsp at stsp.in-berlin.de>
-
-2006-09-01	Nick Schermer <nick at xfce.org>
-
-	* configure.ac, autogen.sh, po/LINGUAS: Switch to linguas support,
-	rename configure.in to configure.in.in
-	* po/xfce4-battery-plugin.pot: Addded file
-	* po/*.po: Regenerated po files
-
-2006-09-01	Nick Schermer <nick at xfce.org>
-
-	* panel-plugin/libacpi.c: Apply patch from Giuseppe Ciotta to
-	remove hardcoded battery paths.
-	* panel-plugin/battmon.c: Fix crash when adding the plugin.
-	* panel-plugin/battmon.c: Fix plugin resize problem (bug #1791)
-	* panel-plugin/battmon.c: Improved icon loading and try to load the
-	battery icon from your current theme (fallback on buildin icon).
-	* panel-plugin/battmon.c: Initially hide the icon when building the
-	plugin (this stops the icon from flashing if disabled).
-	* panel-plugin/battmon.c: Remove the time label from "display percentage"
-	and add a new option "Display time".
-	* panel-plugin/battmon.c: Fix label alignment if only 1 "option" is shown
-	in a vbox.
-	* panel-plugin/battmon.c, configure.ac: Use new titled dialog and depend on
-	beta 2.
-	* panel-plugin/battmon.c: Couple of small fixes, improvement, memleaks etc.
-
-2003-07-18	Jasper Huijsmans <jasper at xfce.org>
-
-	* panel-plugin/battmon.c: Change panel API again to prevent old
-	plugins to crash the panel
-
-2003-07-17	Benedikt Meurer <benny at xfce.org>
-
-	* ChangeLog: Updated ChangeLog.
-
-2003-07-17	Benedikt Meurer <benny at xfce.org>
-
-	* compile, depcomp, README, aclocal.m4, ltmain.sh, configure,
-	configure.ac, config.guess, install-sh, AUTHORS, COPYING,
-	ChangeLog, INSTALL, Makefile.am, Makefile.in, autogen.sh,
-	config.h.in, config.sub, missing, mkinstalldirs, m4/debug.m4,
-	m4/depends.m4, m4/i18n.m4, panel-plugin/Makefile.am,
-	panel-plugin/Makefile.in, panel-plugin/acpi-linux.c,
-	panel-plugin/acpi-linux.h, panel-plugin/apm.h,
-	panel-plugin/apmlib.c, panel-plugin/battmon.c,
-	panel-plugin/libbattmon_la-apmlib.loT: Initial revision
-
-2003-07-17	Benedikt Meurer <benny at xfce.org>
-
-	* compile, depcomp, README, aclocal.m4, ltmain.sh, configure,
-	configure.ac, config.guess, install-sh, AUTHORS, COPYING,
-	ChangeLog, INSTALL, Makefile.am, Makefile.in, autogen.sh,
-	config.h.in, config.sub, missing, mkinstalldirs, m4/debug.m4,
-	m4/depends.m4, m4/i18n.m4, panel-plugin/Makefile.am,
-	panel-plugin/Makefile.in, panel-plugin/acpi-linux.c,
-	panel-plugin/acpi-linux.h, panel-plugin/apm.h,
-	panel-plugin/apmlib.c, panel-plugin/battmon.c,
-	panel-plugin/libbattmon_la-apmlib.loT: Initial import of the
-	battery monitor panel plugin.
 
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..2550dab
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,302 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+
+   This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+   Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+  6. Often, you can also type `make uninstall' to remove the installed
+     files again.
+
+Compilers and Options
+=====================
+
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+   You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+   On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor.  Like
+this:
+
+     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CPP="gcc -E" CXXCPP="g++ -E"
+
+   This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
+Installation Names
+==================
+
+   By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+   Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Particular systems
+==================
+
+   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+     ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+   On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
+a workaround.  If GNU CC is not installed, it is therefore recommended
+to try
+
+     ./configure CC="cc"
+
+and if that doesn't work, try
+
+     ./configure CC="cc -nodtk"
+
+   On Solaris, don't put `/usr/ucb' early in your `PATH'.  This
+directory contains several dysfunctional programs; working variants of
+these programs are available in `/usr/bin'.  So, if you need `/usr/ucb'
+in your `PATH', put it _after_ `/usr/bin'.
+
+   On Haiku, software installed for all users goes in `/boot/common',
+not `/usr/local'.  It is recommended to use the following options:
+
+     ./configure --prefix=/boot/common
+
+Specifying the System Type
+==========================
+
+   There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on.  Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS
+     KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+   Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+   `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+     Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+     Print a summary of the options unique to this package's
+     `configure', and exit.  The `short' variant lists options used
+     only in the top level, while the `recursive' variant lists options
+     also present in any nested packages.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`--prefix=DIR'
+     Use DIR as the installation prefix.  *Note Installation Names::
+     for more details, including other options available for fine-tuning
+     the installation locations.
+
+`--no-create'
+`-n'
+     Run the configure checks, but stop before creating any output
+     files.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
+
diff --git a/Makefile.am b/Makefile.am
index fc01f02..048a537 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,27 +1,37 @@
-# $Id$
+SUBDIRS = panel-plugin po icons
 
-SUBDIRS =								\
-	panel-plugin							\
-	icons								\
-	po
+EXTRA_DIST = \
+	intltool-extract.in \
+	intltool-merge.in \
+	intltool-update.in
+
+DISTCLEANFILES = \
+	intltool-extract \
+	intltool-merge \
+	intltool-update
 
 distclean-local:
-	rm -rf *.cache *~
+	rm -rf *.cache
 
 rpm: dist
 	rpmbuild -ta $(PACKAGE)-$(VERSION).tar.gz
 	@rm -f $(PACKAGE)-$(VERSION).tar.gz
 
-EXTRA_DIST = 								\
-	README								\
-	intltool-extract.in						\
-	intltool-merge.in						\
-	intltool-update.in
+html: Makefile
+	make -C doc html
 
-DISTCLEANFILES =							\
-	intltool-extract						\
-	intltool-merge							\
-	intltool-update
+dist-bz2: dist
+	zcat $(PACKAGE)-$(VERSION).tar.gz | \
+	bzip2 --best -c > $(PACKAGE)-$(VERSION).tar.bz2
 
-# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
+distcheck-bz2: distcheck
+	zcat $(PACKAGE)-$(VERSION).tar.gz | \
+	bzip2 --best -c > $(PACKAGE)-$(VERSION).tar.bz2
+         
+snapshot: dist
+	mv $(PACKAGE)-$(VERSION).tar.gz \
+	$(PACKAGE)-$(VERSION)-r at REVISION@.tar.gz
 
+snapshot-bz2: dist-bz2
+	mv $(PACKAGE)-$(VERSION).tar.bz2 \
+	$(PACKAGE)-$(VERSION)-r at REVISION@.tar.bz2         
diff --git a/NEWS b/NEWS
index e69de29..8b13789 100644
--- a/NEWS
+++ b/NEWS
@@ -0,0 +1 @@
+
diff --git a/README b/README
index b0ba834..e69de29 100644
--- a/README
+++ b/README
@@ -1,3 +0,0 @@
-Battery monitor panel plugin for XFce4.
-
-Battery Icon borrowed from KDE :-)
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/TODO
@@ -0,0 +1 @@
+
diff --git a/autogen.sh b/autogen.sh
index 3308482..6bc0c8a 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,32 +1,20 @@
 #!/bin/sh
 #
-# $Id$
+# Copyright (c) 2002-2009
+#         The Xfce development team. All rights reserved.
 #
+# Written for Xfce by Benedikt Meurer <benny at xfce.org>.
+
+export XDT_AUTOGEN_REQUIRED_VERSION="4.7.0"
 
 (type xdt-autogen) >/dev/null 2>&1 || {
   cat >&2 <<EOF
 autogen.sh: You don't seem to have the Xfce development tools installed on
             your system, which are required to build this software.
-            Please install the xfce4-dev-tools package first, it is available
-            from http://www.xfce.org/.
+            Please install the xfce4-dev-tools package first, available from
+            http://xfce.org/~benny/projects/xfce4-dev-tools/.
 EOF
   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 "%04d\n", $2}'`
-sed -e "s/@LINGUAS@/${linguas}/g" \
-    -e "s/@REVISION@/${revision}/g" \
-    < "configure.in.in" > "configure.in"
-
-exec xdt-autogen $@
+xdt-autogen $@
diff --git a/configure.ac.in b/configure.ac.in
new file mode 100644
index 0000000..2eb95ff
--- /dev/null
+++ b/configure.ac.in
@@ -0,0 +1,83 @@
+# ===================================================== #
+#               Version Information                     #
+# ===================================================== #
+m4_define([battery_version_major],  [0])
+m4_define([battery_version_minor],  [6])
+m4_define([battery_version_micro],  [0])
+m4_define([battery_version_build],  [r at REVISION@])
+m4_define([battery_version_tag], [git])
+m4_define([battery_version], [battery_version_major().battery_version_minor().battery_version_micro()ifelse(battery_version_tag(), [git], [battery_version_tag().battery_version_build()], [battery_version_tag()])])
+
+AC_INIT([xfce4-battery-plugin], [battery_version], [aliov at xfce.org])
+AC_PREREQ(2.50)
+
+AM_INIT_AUTOMAKE([1.8 dist-bzip2 tar-ustar])
+AM_CONFIG_HEADER([config.h])
+AM_MAINTAINER_MODE()
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+AC_USE_SYSTEM_EXTENSIONS()
+
+# ===================================================== #
+#               Basic compiler settings                 #
+# ===================================================== #
+AC_PROG_CC()
+AC_PROG_LD()
+AC_PROG_INSTALL()
+AC_PROG_LIBTOOL()
+AC_PROG_INTLTOOL()
+
+# ==================================================== #
+#   Check for headers needed for standard interfaces   #
+# ==================================================== #
+AC_HEADER_STDC()
+AC_CHECK_HEADERS([errno.h signal.h stddef.h sys/ioctl.h fcntl.h\
+                  string.h sys/stat.h sys/types.h sys/wait.h time.h \
+                  unistd.h])
+
+# ===================================================== #
+# 		Check for i18n support 			#
+# ===================================================== #
+
+XDT_I18N([@LINGUAS@])
+
+#==================================================== #
+#          Check for required packages 		      #
+#=====================================================#
+m4_define([gtk_minimum_version], [2.10.0])
+m4_define([glib_minimum_version], [2.14.0])
+m4_define([libxfce4panel_minimum_version],[4.4.1])
+m4_define([libxfce4util_minimum_version],[4.4.1])
+m4_define([dkp_minimum_version], [010])
+
+XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [gtk_minimum_version])
+XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [glib_minimum_version])
+XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [glib_minimum_version])
+XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0],[libxfce4panel_minimum_version])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [libxfce4util_minimum_version])
+XDT_CHECK_PACKAGE([DKP], [devkit-power-gobject], [dkp_minimum_version])
+
+LIBXFCE4UI_FOUND="no"
+XDT_CHECK_OPTIONAL_PACKAGE([LIBXFCE4UI],
+                           [libxfce4ui-1], [4.7.0],
+                           [libxfce4ui-1], 
+                           [libxfce4ui], [yes])
+			   
+if test x"$LIBXFCE4UI_FOUND" = x"no"; then
+XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [libxfce4util_minimum_version])
+fi
+
+XDT_FEATURE_DEBUG()
+
+AC_OUTPUT([
+Makefile
+panel-plugin/Makefile
+icons/Makefile
+icons/16x16/Makefile
+icons/22x22/Makefile
+icons/24x24/Makefile
+icons/32x32/Makefile
+icons/scalable/Makefile
+po/Makefile.in
+])
+
+echo "Configuration finished, type make to compile"
diff --git a/configure.in.in b/configure.in.in
deleted file mode 100644
index 5f3ece2..0000000
--- a/configure.in.in
+++ /dev/null
@@ -1,93 +0,0 @@
-dnl $Id$
-dnl
-dnl xfce4-battery-plugin - Battery monitor for the Xfce4 panel
-dnl
-dnl 2003      Benedikt Meurer <benny at xfce.org>
-dnl 2006-2007 Nick Schermer <nick at xfce.org>
-dnl
-
-dnl ***************************
-dnl *** Version information ***
-dnl ***************************
-m4_define([battery_version_major], [0])
-m4_define([battery_version_minor], [5])
-m4_define([battery_version_micro], [2])
-m4_define([battery_version_build], [r at REVISION@])
-m4_define([battery_version_tag], [svn])
-m4_define([battery_version], [battery_version_major().battery_version_minor().battery_version_micro()ifelse(battery_version_tag(), [svn], [battery_version_tag()-battery_version_build()], [battery_version_tag()])])
-
-dnl ***************************
-dnl *** Initialize autoconf ***
-dnl ***************************
-AC_COPYRIGHT([Copyright (c) 2006-2007
-        The Xfce development team. All rights reserved.])
-AC_INIT([xfce4-battery-plugin], [battery_version], [http://bugzilla.xfce.org/], [xfce4-battery-plugin])
-AC_PREREQ([2.50])
-AC_CANONICAL_TARGET()
-AC_REVISION([$Id$])
-
-dnl ***************************
-dnl *** Initialize automake ***
-dnl ***************************
-AM_INIT_AUTOMAKE([1.8 dist-bzip2 tar-ustar])
-AM_CONFIG_HEADER([config.h])
-AM_MAINTAINER_MODE()
-
-dnl ********************************
-dnl *** Check for basic programs ***
-dnl ********************************
-AC_PROG_CC()
-AC_PROG_LD()
-AC_PROG_INSTALL()
-AC_PROG_LIBTOOL()
-AC_PROG_INTLTOOL()
-
-dnl **********************************
-dnl *** Check for standard headers ***
-dnl **********************************
-AC_CHECK_HEADERS([dirent.h stdio.h stdlib.h unistd.h string.h fcntl.h \
-                  ctype.h sys/stat.h sys/time.h sys/ioctl.h sys/types.h])
-
-dnl ************************************
-dnl *** Check for standard functions ***
-dnl ************************************
-AC_CHECK_FUNCS([sysctl])
-
-dnl ******************************
-dnl *** Check for i18n support ***
-dnl ******************************
-XDT_I18N([@LINGUAS@])
-
-dnl ***********************************
-dnl *** Check for required packages ***
-dnl ***********************************
-XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
-XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.6.0])
-XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.3.90.2])
-XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.3.90.2])
-XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.90.2])
-
-dnl ***********************************
-dnl *** Check for debugging support ***
-dnl ***********************************
-XDT_FEATURE_DEBUG()
-
-AC_OUTPUT([
-Makefile
-panel-plugin/Makefile
-icons/Makefile
-icons/16x16/Makefile
-icons/22x22/Makefile
-icons/24x24/Makefile
-icons/32x32/Makefile
-icons/scalable/Makefile
-po/Makefile.in
-])
-dnl ***************************
-dnl *** Print configuration ***
-dnl ***************************
-echo
-echo "Build Configuration:"
-echo
-echo "* Debug Support:    $enable_debug"
-echo
diff --git a/module.xml b/module.xml
new file mode 100644
index 0000000..fdc446c
--- /dev/null
+++ b/module.xml
@@ -0,0 +1,19 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<Project xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+         xmlns:foaf="http://xmlns.com/foaf/0.1/"
+         xmlns:gnome="http://api.gnome.org/doap-extensions#"
+         xmlns="http://usefulinc.com/ns/doap#">
+
+  <name xml:lang="en">xfce4-battery-plugin</name>
+  <shortdesc xml:lang="en">Battery monitor plugin for the Xfce panel</shortdesc>
+  <homepage rdf:resource="http://goodies.xfce.org/projects/panel-plugins/xfce4-battery-plugin"/>
+
+  <maintainer>
+    <foaf:Person>
+      <foaf:name>Ali Abdallah</foaf:name>
+      <foaf:mbox>mailto:aliov at xfce.org</foaf:mbox>
+      <gnome:userid>aliov</gnome:userid>
+    </foaf:Person>
+  </maintainer>
+</Project>
diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
index 511f499..46efd53 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -4,6 +4,7 @@ INCLUDES =								\
 	-I$(top_srcdir)							\
 	-DG_LOG_DOMAIN=\"xfce4-battery-plugin\"				\
 	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"				\
+	-DI_KNOW_THE_DEVICEKIT_POWER_API_IS_SUBJECT_TO_CHANGE		\
 	$(PLATFORM_CPPFLAGS)
 
 #
@@ -16,41 +17,59 @@ plugin_PROGRAMS =							\
 	xfce4-battery-plugin
 
 xfce4_battery_plugin_SOURCES =						\
-	battery.c							\
-	libacpi.h							\
-	libacpi.c							\
-	libapm.h							\
-	libapm.c
+	batt-plugin.c							\
+	interface_ui.h
 
 xfce4_battery_plugin_CFLAGS =						\
 	$(LIBXFCE4PANEL_CFLAGS)						\
-	$(LIBXFCEGUI4_CFLAGS)						\
 	$(LIBXFCE4UTIL_CFLAGS)						\
-	$(GTK_CFLAGS)							\
+	$(LIBXFCE4UI_CFLAGS)						\
+	$(LIBXFCEGUI4_CFLAGS)						\
+	$(GMODULE_CFLAGS)						\
+	$(DKP_CFLAGS)							\
 	$(PLATFORM_CFLAGS)
 
 xfce4_battery_plugin_LDADD =						\
 	$(LIBXFCE4PANEL_LIBS)						\
-	$(LIBXFCEGUI4_LIBS)						\
 	$(LIBXFCE4UTIL_LIBS)						\
-	$(GTK_LIBS)
+	$(LIBXFCE4UI_LIBS)						\
+	$(LIBXFCEGUI4_LIBS)						\
+	$(GMODULE_LIBS)							\
+	$(DKP_LIBS)
+
+interface = 								\
+	settings.ui
+
+interface_h =								\
+	$(interface:.ui=_ui.h)
+
+if MAINTAINER_MODE
+BUILT_SOURCES = $(interface_h)
+
+settings_ui.h: settings.ui
+	exo-csource --static --strip-comments --strip-content --name=settings_ui $< > $@
+
+endif
 
 #
 # Desktop file
 #
 desktopdir = $(datadir)/xfce4/panel-plugins
-desktop_in_in_files = battmon.desktop.in.in
+desktop_in_in_files = xfce4-battery-plugin.desktop.in.in
 desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
 %.desktop.in: %.desktop.in.in
 	sed -e "s,\@libexecdir\@,$(libexecdir),g" < $< > $@
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 @INTLTOOL_DESKTOP_RULE@
 
-EXTRA_DIST =								\
+EXTRA_DIST =                                    \
+	$(interface)                           	\
+	$(interface_h)				\
 	$(desktop_in_in_files)
 
-CLEANFILES =								\
-	$(desktop_in_files)						\
+CLEANFILES =					\
+	$(interface_h)				\
+	$(desktop_in_files)			\
 	$(desktop_DATA)
 
 # vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/panel-plugin/batt-plugin.c b/panel-plugin/batt-plugin.c
new file mode 100644
index 0000000..42cddd0
--- /dev/null
+++ b/panel-plugin/batt-plugin.c
@@ -0,0 +1,776 @@
+/*
+ * * Copyright (C) 2008-2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <unistd.h>
+
+#include <gtk/gtk.h>
+#include <glib.h>
+
+#include <libxfce4util/libxfce4util.h>
+#include <libxfce4panel/libxfce4panel.h>
+
+#ifdef HAVE_LIBXFCE4UI
+#include <libxfce4ui/libxfce4ui.h>
+#else
+#include <libxfcegui4/libxfcegui4.h>
+#endif
+
+#include <devkit-power-gobject/devicekit-power.h>
+
+#include "settings_ui.h"
+
+#define BORDER 8
+#define PLUGIN_WEBSITE  "http://goodies.xfce.org/projects/panel-plugins/xfce4-battery-plugin"
+
+typedef struct
+{
+    /* Options */
+    gboolean show_percentage;
+    gboolean show_icon;
+    gboolean show_time;
+    gboolean hide_percentage_time_when_full;
+    
+} BattOptions;
+
+typedef struct
+{
+    DkpClient       *client;
+    GPtrArray       *array;
+    
+    XfcePanelPlugin *panel_plugin;
+    
+    GtkWidget	    *ebox;
+    GtkWidget       *hvbox;
+    
+    BattOptions     *options;
+    
+} BattPlugin;
+
+typedef struct
+{
+    const DkpDevice *device;
+    
+    GtkWidget	    *ebox;
+    GtkWidget       *hvbox;
+    GtkWidget 	    *progress;
+    GtkWidget       *label_percentage;
+    GtkWidget       *label_time;
+    GtkWidget       *image;
+    
+    BattOptions     *options;
+    
+} BattDevice;
+
+void		show_percentage_toggled_cb		  (GtkToggleButton *bt, gpointer data);
+
+void		show_icon_toggled_cb			  (GtkToggleButton *bt, gpointer data);
+
+void		show_time_toggled_cb			  (GtkToggleButton *bt, gpointer data);
+
+void		hide_percentage_time_when_full_toggled_cb (GtkToggleButton *bt, gpointer data);
+
+static void	battery_plugin_rescan_battery 		  (const DkpDevice *device, 
+							   gpointer *obj, 
+							   BattDevice *batt);
+
+/**
+ *
+ * 
+ **/
+static void
+battery_plugin_refresh_displayed_info (BattPlugin *plugin)
+{
+    guint i;
+    
+    for ( i = 0; i < plugin->array->len; i++)
+    {
+	BattDevice *batt = g_ptr_array_index (plugin->array, i);
+	battery_plugin_rescan_battery (batt->device, NULL, batt);
+    }
+}
+
+/**
+ *
+ * 
+ **/
+void show_percentage_toggled_cb	(GtkToggleButton *bt, gpointer data)
+{
+    BattPlugin *plugin = (BattPlugin *)data;
+    
+    plugin->options->show_percentage = gtk_toggle_button_get_active (bt);
+    battery_plugin_refresh_displayed_info (plugin);
+}
+
+/**
+ *
+ * 
+ **/
+void show_icon_toggled_cb (GtkToggleButton *bt, gpointer data)
+{
+    guint i;
+    BattPlugin *plugin = (BattPlugin *)data;
+    
+    plugin->options->show_icon = gtk_toggle_button_get_active (bt);
+    
+    for ( i = 0; i < plugin->array->len; i++)
+    {
+	BattDevice *batt = g_ptr_array_index (plugin->array, i);
+	g_object_set (G_OBJECT (batt->image),
+		      "visible", plugin->options->show_icon,
+		      NULL);
+	
+    }
+}
+
+/**
+ *
+ * 
+ **/
+void show_time_toggled_cb (GtkToggleButton *bt, gpointer data)
+{
+    BattPlugin *plugin = (BattPlugin *)data;
+    plugin->options->show_time = gtk_toggle_button_get_active (bt);
+    battery_plugin_refresh_displayed_info (plugin);
+}
+
+/**
+ *
+ * 
+ **/
+void hide_percentage_time_when_full_toggled_cb (GtkToggleButton *bt, gpointer data)
+{
+    BattPlugin *plugin = (BattPlugin *)data;
+    plugin->options->hide_percentage_time_when_full = gtk_toggle_button_get_active (bt);
+    battery_plugin_refresh_displayed_info (plugin);
+}
+
+/**
+ * load_pixbug_icon:
+ * 
+ **/
+static GdkPixbuf *
+load_pixbuf_icon (const gchar *icon_name, gint size)
+{
+    GdkPixbuf *pix = NULL;
+    GError *error = NULL;
+    
+    pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), 
+                                    icon_name, 
+                                    size,
+                                    GTK_ICON_LOOKUP_USE_BUILTIN,
+                                    &error);
+                                    
+    if ( error )
+    {
+        g_warning ("Unable to load icon : %s : %s", icon_name, error->message);
+        g_error_free (error);
+    }
+    
+    return pix;
+}
+
+/**
+ *
+ **/
+static gchar *
+battery_get_time_string_label (guint seconds)
+{
+    gint  hours;
+    gint  minutes;
+
+    /* Add 0.5 to do rounding */
+    minutes = (int) ( ( seconds / 60.0 ) + 0.5 );
+    
+    hours = minutes / 60;
+    minutes = minutes % 60;
+    
+    return g_strdup_printf ("%02i:%02i", hours, minutes);
+}
+
+/**
+ *
+ **/
+static gchar *
+battery_get_time_string (guint seconds)
+{
+    char* timestring = NULL;
+    gint  hours;
+    gint  minutes;
+
+    /* Add 0.5 to do rounding */
+    minutes = (int) ( ( seconds / 60.0 ) + 0.5 );
+
+    if (minutes == 0) 
+    {
+	timestring = g_strdup (_("Unknown time"));
+	return timestring;
+    }
+
+    if (minutes < 60) 
+    {
+	timestring = g_strdup_printf (ngettext ("%i minute",
+			              "%i minutes",
+				      minutes), minutes);
+	return timestring;
+    }
+
+    hours = minutes / 60;
+    minutes = minutes % 60;
+
+    if (minutes == 0)
+	timestring = g_strdup_printf (ngettext (
+			    "%i hour",
+			    "%i hours",
+			    hours), hours);
+    else
+	/* TRANSLATOR: "%i %s %i %s" are "%i hours %i minutes"
+	 * Swap order with "%2$s %2$i %1$s %1$i if needed */
+	timestring = g_strdup_printf (_("%i %s %i %s"),
+			    hours, ngettext ("hour", "hours", hours),
+			    minutes, ngettext ("minute", "minutes", minutes));
+    return timestring;
+}
+
+/**
+ * 
+ **/
+static void
+battery_plugin_set_tooltip (BattDevice *batt, GtkTooltip *tooltip)
+{
+    gchar *tip = NULL;
+    gchar *est_time_str = NULL;
+    DkpDeviceState state;
+    gint64 time_to_empty, time_to_full;
+    gdouble percentage_double;
+    guint percentage;
+    
+    g_object_get (G_OBJECT (batt->device),
+		  "state", &state,
+		  "time-to-empty", &time_to_empty,
+		  "time-to-full", &time_to_full,
+		  "percentage", &percentage_double,
+		  NULL);
+    
+    percentage = (guint) percentage_double;
+    
+    if ( state == DKP_DEVICE_STATE_FULLY_CHARGED )
+    {
+	if ( time_to_empty > 0 )
+	{
+	    est_time_str = battery_get_time_string (time_to_empty);
+	    tip = g_strdup_printf (_("Your battery is fully charged (%i%%).\nProvides %s runtime"), 
+				   percentage,
+				   est_time_str);
+	    g_free (est_time_str);
+	}
+	else
+	{
+	    tip = g_strdup_printf (_("Your battery is fully charged (%i%%)."), 
+				   percentage);
+	}
+    }
+    else if ( state == DKP_DEVICE_STATE_CHARGING )
+    {
+	if ( time_to_full != 0 )
+	{
+	    est_time_str = battery_get_time_string (time_to_full);
+	    tip = g_strdup_printf (_("Your battery is charging (%i%%)\n%s until is fully charged."), 
+				   percentage, 
+				   est_time_str);
+	    g_free (est_time_str);
+	}
+	else
+	{
+	    tip = g_strdup_printf (_("Your battery is charging (%i%%)."),
+				   percentage);
+	}
+    }
+    else if ( state == DKP_DEVICE_STATE_DISCHARGING )
+    {
+	if ( time_to_empty != 0 )
+	{
+	    est_time_str = battery_get_time_string (time_to_empty);
+	    tip = g_strdup_printf (_("Your battery is discharging (%i%%)\nestimated time left is %s."), 
+				   percentage, 
+				   est_time_str);
+	    g_free (est_time_str);
+	}
+	else
+	{
+	    tip = g_strdup_printf (_("Your is discharging (%i%%)."),
+				   percentage);
+	}
+    }
+    else if ( state == DKP_DEVICE_STATE_PENDING_CHARGE )
+    {
+	tip = g_strdup_printf (_("Waiting to discharge (%i%%)."), percentage);
+    }
+    else if ( state == DKP_DEVICE_STATE_PENDING_DISCHARGE )
+    {
+	tip = g_strdup_printf (_("Waiting to charge (%i%%)."), percentage);
+    }
+    else if ( state == DKP_DEVICE_STATE_EMPTY )
+    {
+	tip = g_strdup (_("Your battery is empty"));
+    }
+    
+    gtk_tooltip_set_text (tooltip, tip);
+}
+
+/**
+ * 
+ **/
+static gboolean
+battery_plugin_query_device_tooltip (GtkStatusIcon *icon, 
+				     gint x,
+				     gint y,
+				     gboolean keyboard_mode,
+				     GtkTooltip *tooltip,
+				     BattDevice *batt)
+{
+    battery_plugin_set_tooltip (batt, tooltip);
+    return TRUE;
+}
+
+/**
+ * 
+ * 
+ **/
+static gboolean
+battery_plugin_device_size_changed_cb (XfcePanelPlugin *panel_plugin, gint size, BattDevice *batt)
+{
+    GdkPixbuf *icon;
+
+    if (xfce_panel_plugin_get_orientation (panel_plugin) == GTK_ORIENTATION_HORIZONTAL)
+    {
+        gtk_widget_set_size_request (GTK_WIDGET(batt->progress),
+				     BORDER, size - BORDER);
+				     
+	gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (batt->progress), GTK_PROGRESS_BOTTOM_TO_TOP);
+    }
+    else
+    {
+        gtk_widget_set_size_request (GTK_WIDGET (batt->progress),
+				     size - BORDER, BORDER);
+	gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (batt->progress), GTK_PROGRESS_LEFT_TO_RIGHT);
+    }
+    
+    icon = load_pixbuf_icon ("battery", size - BORDER) ;
+    
+    gtk_image_set_from_pixbuf (GTK_IMAGE (batt->image), icon);
+    
+    g_object_unref (icon);
+    
+    return TRUE;
+}
+
+/**
+ * 
+ * 
+ **/
+static void
+battery_plugin_rescan_battery (const DkpDevice *device, gpointer *obj, BattDevice *batt)
+{
+    GtkAdjustment *adj;
+    gdouble percentage;
+    DkpDeviceState state;
+    gchar percentage_str[32];
+    
+    g_object_get (G_OBJECT (device),
+		  "percentage", &percentage,
+		  "state", &state,
+		  NULL);
+    
+    g_snprintf (percentage_str, 32, "%i%%", (gint) percentage);
+    gtk_label_set_text (GTK_LABEL (batt->label_percentage), NULL);
+    gtk_label_set_text (GTK_LABEL (batt->label_time), NULL);
+    
+    if ( batt->options->show_percentage && ( state != DKP_DEVICE_STATE_FULLY_CHARGED || !batt->options->hide_percentage_time_when_full ))
+    {
+	gtk_label_set_text (GTK_LABEL (batt->label_percentage), percentage_str);
+	gtk_widget_show (batt->label_percentage);
+    }
+    else
+	gtk_widget_show (batt->label_percentage);
+    
+    if ( batt->options->show_time )
+    {
+	gint64 time_to_full, time_to_empty;
+	gchar *time_str = NULL;
+	
+	g_object_get (G_OBJECT (batt->device),
+		      "time-to-empty", &time_to_empty,
+		      "time-to-full", &time_to_full,
+		      NULL);
+	
+	gtk_widget_hide (batt->label_time);
+	
+	if ( state == DKP_DEVICE_STATE_FULLY_CHARGED )
+	{
+	    if (!batt->options->hide_percentage_time_when_full)
+	    {
+		time_str = battery_get_time_string_label (time_to_empty);
+		gtk_label_set_text (GTK_LABEL (batt->label_time), time_str);
+		g_free (time_str);
+		gtk_widget_show (batt->label_time);
+	    }
+	}
+	else if ( state == DKP_DEVICE_STATE_DISCHARGING )
+	{
+	    time_str = battery_get_time_string_label (time_to_empty);
+	    gtk_label_set_text (GTK_LABEL (batt->label_time), time_str);
+	    g_free (time_str);
+	    gtk_widget_show (batt->label_time);
+	}
+	else if ( state == DKP_DEVICE_STATE_CHARGING )
+	{
+	    time_str = battery_get_time_string_label (time_to_full);
+	    gtk_label_set_text (GTK_LABEL (batt->label_time), time_str);
+	    g_free (time_str);
+	    gtk_widget_show (batt->label_time);
+	}
+    }
+    else
+	gtk_widget_hide (batt->label_time);
+	
+    g_object_get (G_OBJECT (batt->progress),
+		  "adjustment", &adj,
+		  NULL);
+		  
+    gtk_adjustment_set_value (adj, percentage);
+}
+
+/**
+ * 
+ * 
+ **/
+static void
+battery_plugin_add_battery (BattPlugin *plugin, const DkpDevice *device)
+{
+    BattDevice *batt;
+    GtkWidget *vbox;
+    GdkPixbuf *pix;
+    GtkObject *adj;
+    gint size;
+    
+    batt = g_new0 (BattDevice, 1);
+    
+    batt->device = device;
+    batt->options = plugin->options;
+    
+    batt->ebox = gtk_event_box_new ();
+    gtk_event_box_set_above_child (GTK_EVENT_BOX (batt->ebox), TRUE);
+    gtk_widget_set_has_tooltip (batt->ebox, TRUE);
+    
+    batt->hvbox = xfce_hvbox_new (xfce_panel_plugin_get_orientation (plugin->panel_plugin),
+				  FALSE, 2);
+    gtk_container_set_border_width (GTK_CONTAINER (batt->hvbox), BORDER / 2);
+    size = xfce_panel_plugin_get_size (plugin->panel_plugin);
+    pix = load_pixbuf_icon ("battery", size - BORDER) ;
+    
+    batt->image = gtk_image_new_from_pixbuf (pix);
+    
+    g_object_unref (pix);
+    
+    batt->label_percentage = gtk_label_new (NULL);
+    batt->label_time = gtk_label_new (NULL);
+    
+    adj = gtk_adjustment_new (0., 0., 100., 1., 0., 0.);
+
+    batt->progress = gtk_progress_bar_new_with_adjustment (GTK_ADJUSTMENT (adj));
+
+    gtk_box_pack_start (GTK_BOX (batt->hvbox), batt->image, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (batt->hvbox), batt->progress, FALSE, FALSE, 0);
+    
+    vbox = gtk_vbox_new (TRUE, 0);
+    
+    gtk_box_pack_start (GTK_BOX (vbox), batt->label_percentage, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (vbox), batt->label_time, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (batt->hvbox), vbox, FALSE, FALSE, 0);
+    
+    gtk_container_add (GTK_CONTAINER (batt->ebox), batt->hvbox);
+    gtk_box_pack_start (GTK_BOX (plugin->hvbox), batt->ebox, FALSE, FALSE, 0);
+    
+    g_signal_connect (plugin->panel_plugin, "size-changed", 
+		      G_CALLBACK (battery_plugin_device_size_changed_cb), batt);
+	
+    g_signal_connect (batt->ebox, "query-tooltip",
+		      G_CALLBACK (battery_plugin_query_device_tooltip), batt);
+    
+    battery_plugin_device_size_changed_cb (plugin->panel_plugin, size, batt);
+    gtk_widget_show_all (batt->ebox);
+    
+    battery_plugin_rescan_battery (device, NULL, batt);
+    g_ptr_array_add (plugin->array, batt);
+    g_signal_connect (G_OBJECT (batt->device), "changed",
+		      G_CALLBACK (battery_plugin_rescan_battery), batt);
+}
+
+/**
+ * 
+ * 
+ **/
+static void
+battery_plugin_get_batteries (BattPlugin *plugin)
+{
+    GError *error = NULL;
+    GPtrArray *array;
+    guint i;
+    
+    array = dkp_client_enumerate_devices (plugin->client, &error);
+    
+    if ( error )
+    {
+        g_critical ("Couldn't enumerate power devices : %s", error->message);
+        g_error_free (error);
+        return; //FIXME: Display error image.
+    }
+    
+    for ( i = 0; i < array->len; i++)
+    {
+        DkpDevice *device;
+        DkpDeviceType type;
+        
+        device = g_ptr_array_index (array, i);
+        
+        g_object_get (G_OBJECT (device), 
+                      "type", &type,
+                      NULL);
+	/*
+	 * Support for other battery device could be added later.
+	 */
+        if ( type == DKP_DEVICE_TYPE_BATTERY )
+        {
+            battery_plugin_add_battery (plugin, device);
+        }
+    }
+}
+
+/**
+ * 
+ * 
+ **/
+static gboolean
+battery_plugin_orientation_changed_cb (XfcePanelPlugin *panel_plugin, GtkOrientation orientation, BattPlugin *plugin)
+{
+    guint i;
+    
+    for ( i = 0; i < plugin->array->len; i++)
+    {
+	BattDevice *batt;
+	
+	batt = g_ptr_array_index (plugin->array, i);
+	
+	xfce_hvbox_set_orientation (XFCE_HVBOX (batt->hvbox), orientation);
+	battery_plugin_device_size_changed_cb (panel_plugin, 
+					       xfce_panel_plugin_get_size (panel_plugin),
+					       batt);
+    }
+    
+    xfce_hvbox_set_orientation (XFCE_HVBOX (plugin->hvbox), orientation);
+    
+    return TRUE;
+}
+
+/**
+ * 
+ * 
+ **/
+static gboolean
+battery_plugin_size_changed_cb (XfcePanelPlugin *panel_plugin, gint size, BattPlugin *plugin)
+{
+    return TRUE;
+}
+
+/**
+ * 
+ * 
+ **/
+static void
+battery_plugin_dialog_response_cb (GtkWidget *dlg, int response, BattPlugin *plugin)
+{
+    gboolean result;
+
+    if (response == GTK_RESPONSE_HELP)
+    {
+        result = g_spawn_command_line_async ("exo-open --launch WebBrowser " PLUGIN_WEBSITE, NULL);
+
+        if (G_UNLIKELY (result == FALSE))
+            g_warning (_("Unable to open the following url: %s"), PLUGIN_WEBSITE);
+    }
+    else
+    {
+        gtk_widget_destroy (dlg);
+        xfce_panel_plugin_unblock_menu (plugin->panel_plugin);
+    }
+}
+
+/**
+ * 
+ **/
+static void
+battery_plugin_init_options (BattPlugin *plugin)
+{
+    plugin->options = g_new0 (BattOptions, 1);
+    
+    plugin->options->show_percentage   = TRUE;
+    plugin->options->show_time         = FALSE;
+    plugin->options->show_icon         = TRUE;
+    plugin->options->hide_percentage_time_when_full = FALSE;
+}
+
+/**
+ * 
+ **/
+static void
+battery_plugin_configure_cb (BattPlugin *plugin)
+{
+    GtkBuilder *builder;
+    GError *error = NULL;
+    GtkWidget *dialog;
+    GtkWidget *vbox;
+    
+    dialog = xfce_titled_dialog_new_with_buttons (_("Battery Monitor"),
+                                                  GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin->panel_plugin))),
+                                                  GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
+                                                  GTK_STOCK_HELP, GTK_RESPONSE_HELP,
+                                                  GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
+                                                  NULL);
+    
+    gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
+    gtk_window_set_icon_name  (GTK_WINDOW (dialog), "battery");
+    
+    builder = gtk_builder_new ();
+    gtk_builder_add_from_string (builder, settings_ui, settings_ui_length, &error);
+    
+    if ( G_UNLIKELY (error) )
+    {
+	g_critical ("Unable to open dialog :%s", error->message);
+	g_error_free (error);
+	g_object_unref (builder);
+	return;
+    }
+    
+    vbox = GTK_WIDGET (gtk_builder_get_object (builder, "vbox"));
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER - 2);
+    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox,
+                        TRUE, TRUE, 0);
+
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "show-icon")),
+				  plugin->options->show_icon);
+
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "show-time")),
+				  plugin->options->show_time);
+				  
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "show-percentage")),
+				  plugin->options->show_percentage);
+    
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "hide-percentage-time-when-full")),
+				  plugin->options->hide_percentage_time_when_full);
+
+    gtk_builder_connect_signals (builder, plugin);
+    g_signal_connect (dialog, "response", 
+		      G_CALLBACK (battery_plugin_dialog_response_cb), plugin);
+    gtk_widget_show (dialog);
+    g_object_unref (builder);
+}
+
+/**
+ * 
+ * 
+ **/
+static void
+battery_plugin_destroy_batt_data (BattDevice *batt)
+{
+    gtk_widget_destroy (batt->ebox);
+    g_free (batt);
+}
+
+/**
+ * 
+ * 
+ **/
+static void
+battery_plugin_free_data_cb (BattPlugin *plugin)
+{
+    g_ptr_array_foreach (plugin->array, (GFunc)battery_plugin_destroy_batt_data, NULL);
+    g_ptr_array_free (plugin->array, TRUE);
+    g_object_unref (plugin->client);
+    
+    g_free (plugin->options);
+    g_free (plugin);
+}
+
+/**
+ * 
+ * 
+ **/
+static void
+battery_plugin_construct (XfcePanelPlugin *panel_plugin)
+{
+    BattPlugin *plugin;
+    
+    plugin = g_new0 (BattPlugin, 1);
+    
+    battery_plugin_init_options (plugin);
+    
+    plugin->client  = dkp_client_new ();
+    plugin->array   = g_ptr_array_new ();
+    
+    plugin->panel_plugin = panel_plugin;
+    plugin->ebox = gtk_event_box_new ();
+    
+    gtk_container_add (GTK_CONTAINER (panel_plugin), GTK_WIDGET (plugin->ebox));
+		     
+    plugin->hvbox = xfce_hvbox_new (xfce_panel_plugin_get_orientation (plugin->panel_plugin),
+				    FALSE, 0);
+				    
+    gtk_container_add (GTK_CONTAINER (plugin->ebox), plugin->hvbox);
+    
+    xfce_panel_plugin_add_action_widget (panel_plugin, GTK_WIDGET (plugin->ebox));
+    
+    g_signal_connect_swapped (panel_plugin, "free-data",
+			      G_CALLBACK (battery_plugin_free_data_cb), plugin);
+			      
+    g_signal_connect (panel_plugin, "size-changed", 
+		      G_CALLBACK (battery_plugin_size_changed_cb), plugin);
+    
+    g_signal_connect (panel_plugin, "orientation-changed", 
+		      G_CALLBACK (battery_plugin_orientation_changed_cb), plugin);
+		      
+    xfce_panel_plugin_menu_show_configure (panel_plugin);
+    g_signal_connect_swapped (panel_plugin, "configure-plugin", 
+			      G_CALLBACK (battery_plugin_configure_cb), plugin);
+    
+    gtk_widget_show_all (GTK_WIDGET (panel_plugin));
+    
+    battery_plugin_get_batteries (plugin);
+    gtk_widget_set_size_request(plugin->ebox, -1, -1);
+}
+
+XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (battery_plugin_construct);
diff --git a/panel-plugin/battery.c b/panel-plugin/battery.c
deleted file mode 100644
index 0b875af..0000000
--- a/panel-plugin/battery.c
+++ /dev/null
@@ -1,1418 +0,0 @@
-/* $Id$
- *
- * Copyright (c) 2003 Nicholas Penwarden <toth64 at yahoo.com>
- * Copyright (c) 2003 Benedikt Meurer <benedikt.meurer at unix-ag.uni-siegen.de>
- * Copyright (c) 2003 Edscott Wilson Garcia <edscott at users.sourceforge.net>
- * Copyright (c) 2005 Eduard Roccatello <eduard at xfce.org>
- * 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 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
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-#include <machine/apm_bios.h>
-#elif __OpenBSD__
-#include <sys/param.h>
-#include <machine/apmvar.h>
-#elif __NetBSD__
-#include <sys/param.h>
-#include <sys/ioctl.h>
-#include <machine/apmvar.h>
-#define APMDEVICE "/dev/apm"
-#elif __linux__
-#include <libapm.h>
-#endif
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <libxfce4util/libxfce4util.h>
-#include <libxfcegui4/libxfcegui4.h>
-
-#include <gtk/gtk.h>
-#include <libxfce4panel/xfce-panel-plugin.h>
-
-#include "libacpi.h"
-
-#include <sys/time.h>
-#include <time.h>
-
-#define BORDER          8
-#define HIGH_COLOR      "#00ff00"
-#define LOW_COLOR       "#ffff00"
-#define CRITICAL_COLOR  "#ff0000"
-#define AVERAGING_CYCLE 5
-#define PLUGIN_WEBSITE  "http://goodies.xfce.org/projects/panel-plugins/xfce4-battery-plugin"
-
-typedef struct
-{
-    gboolean    display_label;    /* Options */
-    gboolean    display_icon;    /* Options */
-    gboolean    display_power;    /* Options */
-    gboolean    display_percentage;    /* Options */
-    gboolean    display_time;
-        gboolean        hide_when_full;
-    gboolean    tooltip_display_percentage;
-    gboolean    tooltip_display_time;
-    int        low_percentage;
-    int        critical_percentage;
-    int        action_on_low;
-    int        action_on_critical;
-    char        *command_on_low;    char        *command_on_critical;
-    float        hsize;
-    float        vsize;
-} t_battmon_options;
-
-typedef struct
-{
-    XfcePanelPlugin *plugin;
-
-    GtkTooltips        *tips;
-    GtkWidget        *vbox;        /* Widgets */
-    GtkWidget        *ebox;
-    GtkWidget        *battstatus;
-    int            timeoutid;    /* To update apm status */
-    int            method;
-    gboolean        flag;
-    gboolean        low;
-    gboolean        critical;
-    t_battmon_options    options;
-    GdkColor        colorH;
-    GdkColor        colorL;
-    GdkColor        colorC;
-    GtkLabel        *label;
-    GtkLabel        *charge;
-    GtkLabel        *rtime;
-    GtkLabel        *alt_rtime;
-    GtkLabel        *acfan;
-    GtkLabel        *temp;
-    GtkWidget        *image;
-} t_battmon;
-
-typedef struct
-{
-    GtkWidget        *cb_disp_power;
-    GtkWidget        *cb_disp_label;
-    GtkWidget        *cb_disp_percentage;
-    GtkWidget        *cb_disp_time;
-        GtkWidget               *cb_hide_when_full;
-    GtkWidget        *cb_disp_tooltip_percentage;
-    GtkWidget        *cb_disp_tooltip_time;
-    GtkWidget        *cb_disp_icon;
-    GtkWidget        *sb_low_percentage;
-    GtkWidget        *sb_critical_percentage;
-    GtkWidget        *om_action_low;
-    GtkWidget        *om_action_critical;
-    GtkWidget        *en_command_low;
-    GtkWidget        *en_command_critical;
-    t_battmon        *battmon;
-} t_battmon_dialog;
-
-enum {BM_DO_NOTHING, BM_MESSAGE, BM_COMMAND, BM_COMMAND_TERM};
-enum {BM_BROKEN, BM_USE_ACPI, BM_USE_APM};
-
-
-static void
-init_options(t_battmon_options *options)
-{
-    options->display_icon = FALSE;
-    options->display_label = FALSE;
-    options->display_power = FALSE;
-    options->display_percentage = TRUE;
-    options->display_time = FALSE;
-    options->tooltip_display_percentage = FALSE;
-    options->tooltip_display_time = FALSE;
-    options->low_percentage = 10;
-    options->critical_percentage = 5;
-    options->action_on_low = 1;
-    options->action_on_critical = 1;
-    options->command_on_low = NULL;
-    options->command_on_critical = NULL;
-    options->hsize = 1.75;
-    options->vsize = 0.5;
-}
-
-gboolean
-detect_battery_info(t_battmon *battmon)
-{
-#ifdef __FreeBSD__
-  /* This is how I read the information from the APM subsystem under
-     FreeBSD.  Each time this functions is called (once every second)
-     the APM device is opened, read from and then closed.
-
-     except that is does not work on FreeBSD
-
-  */
-    struct apm_info apm;
-      int fd;
-
-    /* First check to see if ACPI is available */
-    if (check_acpi() == 0) {
-        int i;
-        /* ACPI detected */
-        battmon->method = BM_USE_ACPI;
-        /* consider battery 0 first... */
-        for (i=0;i<batt_count;i++) {
-            if (read_acpi_info(i)) break;
-        }
-        for (i=0;i<batt_count;i++) {
-            if (read_acpi_state(i)) break;
-        }
-        /*read_acpi_state(0);*/ /* only consider first battery... */
-
-    DBG ("using ACPI");
-
-        return TRUE;
-    }
-
-    battmon->method = BM_BROKEN;
-#ifdef APMDEVICE
-      fd = open(APMDEVICE, O_RDONLY);
-      if (fd == -1) return FALSE;
-
-      if (ioctl(fd, APMIO_GETINFO, &apm) == -1) {
-        close(fd);
-              return FALSE;
-      }
-      close(fd);
-      battmon->method = BM_USE_APM;
-#endif
-      return TRUE;
-#elif defined(__OpenBSD__) || defined(__NetBSD__)
-  /* Code for OpenBSD by Joe Ammond <jra at twinight.org>. Using the same
-     procedure as for FreeBSD.
-     Made to work on NetBSD by Stefan Sperling <stsp at stsp.in-berlin.de>
-  */
-      struct apm_power_info apm;
-      int fd;
-
-      battmon->method = BM_BROKEN;
-      fd = open(APMDEVICE, O_RDONLY);
-      if (fd == -1) return FALSE;
-      +      if (ioctl(fd, APM_IOC_GETPOWER, &apm) == -1) {
-        close(fd);
-             return FALSE;
-    }
-      close(fd);
-      battmon->method = BM_USE_APM;
-
-      return TRUE;
-#elif __linux__
-    struct apm_info apm;
-
-    /* First check to see if ACPI is available */
-    if(check_acpi()==0) {
-        /* ACPI detected */
-        int i;
-        battmon->method = BM_USE_ACPI;
-        for (i=0;i<batt_count;i++) {
-            if (read_acpi_info(i)) break;
-        }
-        /*read_acpi_info(0);*/ /* only consider first battery... */
-        for (i=0;i<batt_count;i++) {
-            if (read_acpi_state(i)) break;
-        }
-        if (batt_count){
-           apm.battery_percentage=acpistate->percentage;
-           apm.battery_time=acpistate->rtime;
-        }
-    return TRUE;
-    }
-    if(apm_read(&apm) == 0) {
-        /* ACPI not detected, but APM works */
-        battmon->method = BM_USE_APM;
-        return TRUE;
-    }
-
-    /* Neither ACPI or APM detected/working */
-    battmon->method = BM_BROKEN;
-
-    return FALSE;
-#endif
-}
-
-static gboolean
-battmon_time_labels_fits(t_battmon *battmon)
-{
-  int plugin_size, labels_size;
-
-    GtkRequisition widget_size;
-    gtk_widget_size_request( GTK_WIDGET(battmon->plugin), &widget_size );
-    plugin_size = widget_size.height;
-
-    labels_size = 0;
-    gtk_widget_size_request( GTK_WIDGET(battmon->charge), &widget_size );
-    labels_size += widget_size.height;
-    gtk_widget_size_request( GTK_WIDGET(battmon->rtime), &widget_size );
-    labels_size += widget_size.height;
-
-    return labels_size <= plugin_size;
-}
-
-static gboolean
-update_apm_status(t_battmon *battmon)
-{
-    int charge=0, rate;
-
-    int lcapacity, ccapacity;
-    gboolean fan=FALSE;
-    const char *temp;
-    int time_remaining=0;
-    gboolean acline;
-    gchar buffer[128];
-
-    static int update_time = AVERAGING_CYCLE;
-    static int sum_lcapacity = 0;
-    static int sum_ccapacity = 0;
-    static int sum_rate = 0;
-
-    static int last_ccapacity = 0;
-    static int last_lcapacity = 0;
-    static int last_rate = 0;
-    static int last_acline = 0;
-
-#if defined(__OpenBSD__) || defined(__NetBSD__)
-  /* Code for OpenBSD by Joe Ammond <jra at twinight.org>. Using the same
-     procedure as for FreeBSD.
-     Made to work on NetBSD by Stefan Sperling <stsp at stsp.in-berlin.de>
-  */
-      struct apm_power_info apm;
-      int fd;
-
-      battmon->method = BM_BROKEN;
-      fd = open(APMDEVICE, O_RDONLY);
-      if (fd == -1) return TRUE;
-      if (ioctl(fd, APM_IOC_GETPOWER, &apminfo) == -1)
-            return TRUE;
-      close(fd);
-      charge = apm.battery_life;
-      time_remaining = apm.minutes_left;
-      acline = apm.ac_state ? TRUE : FALSE;
-
-#else
-    struct apm_info apm;
-    DBG ("Updating battery status...");
-
-    if(battmon->method == BM_BROKEN) {
-      /* See if ACPI or APM support has been enabled yet */
-        if(!detect_battery_info(battmon)) return TRUE;
-        if(battmon->timeoutid != 0) g_source_remove(battmon->timeoutid);
-        /* Poll only once per minute if using ACPI due to a bug */
-#ifdef TUTTLE_UPDATES
-        /* what bug? I don't see any bug here. */
-        if(battmon->method == BM_USE_ACPI) {
-            battmon->timeoutid = g_timeout_add(60 * 1024,
-                    (GSourceFunc) update_apm_status, battmon);
-        }
-            else
-#endif
-            battmon->timeoutid = g_timeout_add(2 * 1024,
-                    (GSourceFunc) update_apm_status, battmon);
-    }
-
-    /* Show initial state if using ACPI rather than waiting a minute */
-    if(battmon->flag) {
-        g_source_remove(battmon->timeoutid);
-        /* we hit ACPI 4-5 times per poll, so polling every 2 seconds
-	 * generates ~10 interrupts per second. updating every 30 seconds
-	 * should be more than enough, and comes down to only 0.16
-	 * interrupts per second, adding significant sleep time */
-        battmon->timeoutid = g_timeout_add(30 * 1024,
-                (GSourceFunc) update_apm_status, battmon);
-    }
-
-    if(battmon->method == BM_USE_ACPI) {
-        int i;
-        acline = read_acad_state();
-        lcapacity = rate = ccapacity = 0;
-        for (i=0;i<batt_count;i++) {
-          if ( !read_acpi_info(i) || !read_acpi_state(i) )
-            continue;
-          lcapacity += acpiinfo->last_full_capacity;
-          ccapacity += acpistate->rcapacity;
-          rate += acpistate->prate;
-        }
-
-        if ( battmon->flag ) {
-          last_ccapacity = ccapacity;
-          last_lcapacity = lcapacity;
-          last_rate = rate;
-        }
-
-        sum_lcapacity += lcapacity;
-        sum_ccapacity += ccapacity;
-        sum_rate += rate;
-
-        update_time++;
-        if ( update_time >= AVERAGING_CYCLE || last_acline != acline ) {
-          if ( last_acline != acline ) {
-            last_ccapacity = ccapacity;
-            last_lcapacity = lcapacity;
-            last_rate = rate;
-          } else {
-            last_ccapacity = ccapacity = (float)(sum_ccapacity)/(float)(update_time);
-            last_lcapacity = lcapacity = (float)(sum_lcapacity)/(float)(update_time);
-            last_rate = rate = (float)(sum_rate)/(float)(update_time);
-          }
-          update_time = 0;
-          sum_ccapacity = sum_lcapacity = sum_rate = 0;
-        } else {
-          ccapacity = last_ccapacity;
-          lcapacity = last_lcapacity;
-          rate = last_rate;
-        }
-
-        charge = (((float)ccapacity)/((float)lcapacity))*100;
-
-        if ( last_acline )
-            time_remaining = ((float)(lcapacity-ccapacity)/(float)(rate))*60;
-        else
-            time_remaining = ((float)(ccapacity)/(float)(rate))*60;
-
-        if ( time_remaining < 0 )
-            time_remaining = 0;
-
-        last_acline = acline;
-
-    }
-#ifdef __linux__
-    else {
-        DBG ("Trying apm_read()...");
-        apm_read(&apm);    /* not broken and not using ACPI, assume APM */
-        charge = apm.battery_percentage;
-        time_remaining = apm.battery_time;
-        acline = apm.ac_line_status ? TRUE : FALSE;
-
-    }
-#elif __FreeBSD__
-    else {
- /* This is how I read the information from the APM subsystem under
-     FreeBSD.  Each time this functions is called (once every second)
-     the APM device is opened, read from and then closed.
-
-     except it don't work with 5.x:
-battmon.c: In function `update_apm_status':
-battmon.c:241: `APMDEVICE' undeclared (first use in this function)
-battmon.c:241: (Each undeclared identifier is reported only once
-battmon.c:241: for each function it appears in.)
-*** Error code 1
-
-  */
-#ifdef APMDEVICE
-       int fd;
-
-       battmon->method = BM_BROKEN;
-       fd = open(APMDEVICE, O_RDONLY);
-       if (fd == -1) return TRUE;
-
-       if (ioctl(fd, APMIO_GETINFO, &apm) == -1) {
-        close(fd);
-        return TRUE;
-     }
-
-       close(fd);
-
-       acline = apm.ai_acline ? TRUE : FALSE;
-       time_remaining = apm.ai_batt_time;
-     time_remaining = time_remaining / 60; /* convert from seconds to minutes */
-       charge = apm.ai_batt_life;
-#else
-     /* FIXME: apm stuff needs fix for 5.x kernels */
-     acline=0;
-     time_remaining=0;
-     charge=0;
-#endif
-    }
-#endif
-#endif
-    battmon->flag = FALSE;
-
-    charge = CLAMP (charge, 0, 100);
-    gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(battmon->battstatus), charge / 100.0);
-
-    if(battmon->options.display_label){
-        gtk_widget_show((GtkWidget *)battmon->label);
-    } else {
-        gtk_widget_hide((GtkWidget *)battmon->label);
-    }
-
-    if(battmon->options.display_icon){
-        gtk_widget_show(battmon->image);
-    } else {
-        gtk_widget_hide(battmon->image);
-    }
-
-    if(battmon->options.display_percentage && !(battmon->options.hide_when_full && acline && charge >= 99)){
-        gtk_widget_show((GtkWidget *)battmon->charge);
-        g_snprintf(buffer, sizeof(buffer),"%d%% ", charge);
-        gtk_label_set_text(battmon->charge,buffer);
-    } else {
-        gtk_widget_hide((GtkWidget *)battmon->charge);
-    }
-
-    if (battmon->options.display_time && !(battmon->options.hide_when_full && acline && charge >= 99 )){
-        GtkLabel *active_label;
-        if ( battmon_time_labels_fits( battmon ) ) {
-            active_label = battmon->rtime;
-            gtk_widget_hide( (GtkWidget*)battmon->alt_rtime );
-        } else {
-            active_label = battmon->alt_rtime;
-            gtk_widget_hide( (GtkWidget*)battmon->rtime );
-        }
-
-        gtk_widget_show((GtkWidget *)active_label);
-        g_snprintf(buffer, sizeof(buffer),"%02d:%02d ",time_remaining/60,time_remaining%60);
-        gtk_label_set_text(active_label,buffer);
-
-    } else {
-        gtk_widget_hide((GtkWidget *)battmon->rtime);
-        gtk_widget_hide((GtkWidget *)battmon->alt_rtime);
-    }
-
-
-    if(acline) {
-        char *t=(charge<99.9)?_("(Charging from AC)"):_("(AC on-line)");
-        if(battmon->options.tooltip_display_percentage) {
-            g_snprintf(buffer, sizeof(buffer), "%d%% %s", charge,t);
-        }
-        else
-            g_snprintf(buffer, sizeof(buffer), "%s",t);
-    }
-    else {
-        if(battmon->options.tooltip_display_percentage && battmon->options.tooltip_display_time)
-             g_snprintf(buffer, sizeof(buffer), _("%d%% (%02d:%02d) remaining"), charge, time_remaining / 60, time_remaining % 60);
-        else if(battmon->options.tooltip_display_time)
-             g_snprintf(buffer, sizeof(buffer), _("%02d:%02d remaining"),time_remaining / 60, time_remaining % 60);
-        else if(battmon->options.tooltip_display_percentage)
-             g_snprintf(buffer, sizeof(buffer), _("%d%% remaining"), charge);
-           else
-             g_snprintf(buffer, sizeof(buffer), _("AC off-line"));
-    }
-
-    gtk_tooltips_set_tip (battmon->tips, battmon->ebox, buffer, NULL);
-
-    if(battmon->options.display_power){
-      gtk_widget_show((GtkWidget *)battmon->acfan);
-      gtk_widget_show((GtkWidget *)battmon->temp);
-
-      fan=get_fan_status();
-      if(acline && fan)
-        gtk_label_set_text(battmon->acfan,"AC FAN");
-      else if(acline && !fan)
-        gtk_label_set_text(battmon->acfan,"AC");
-      else if(!acline && fan)
-        gtk_label_set_text(battmon->acfan,"FAN");
-      else {
-          gtk_label_set_text(battmon->acfan,"");
-          gtk_widget_hide((GtkWidget *)battmon->acfan);
-      }
-
-      temp=get_temperature();
-      DBG ("Temp: %s", temp);
-      if(temp)
-        gtk_label_set_text(battmon->temp,temp);
-      else {
-          gtk_label_set_text(battmon->temp,"");
-          gtk_widget_hide((GtkWidget *)battmon->temp);
-      }
-    } else {
-      gtk_widget_hide((GtkWidget *)battmon->acfan);
-      gtk_widget_hide((GtkWidget *)battmon->temp);
-    }
-
-    gtk_progress_bar_set_text(GTK_PROGRESS_BAR(battmon->battstatus), NULL);
-
-    /* bar colors and state flags */
-    if (acline) {
-      battmon->low = battmon->critical = FALSE;
-      gtk_widget_modify_bg(battmon->battstatus, GTK_STATE_PRELIGHT, NULL);
-    }
-    else {
-      if(charge <= battmon->options.critical_percentage) {
-        gtk_widget_modify_bg(battmon->battstatus, GTK_STATE_PRELIGHT, &(battmon->colorC));
-      }
-      else if(charge <= battmon->options.low_percentage) {
-        gtk_widget_modify_bg(battmon->battstatus, GTK_STATE_PRELIGHT, &(battmon->colorL));
-        battmon->critical = FALSE;
-      }
-      else {
-            battmon->low = battmon->critical = FALSE;
-        gtk_widget_modify_bg(battmon->battstatus, GTK_STATE_PRELIGHT, &(battmon->colorH));
-      }
-    }
-
-    /* alarms */
-    /* FIXME: should put in a timeout to terminate the alarm boxes after one
-     * minute because if they are left open, they block the event loop for
-     * the panel, and that means the critical action will not be performed! */
-    if (!acline && charge <= battmon->options.low_percentage){
-        if(!battmon->critical && charge <= battmon->options.critical_percentage) {
-               battmon->critical = TRUE;
-            if(battmon->options.action_on_critical == BM_MESSAGE){
-do_critical_warn:
-                xfce_warn(_("WARNING: Your battery has reached critical status. You should plug in or shutdown your computer now to avoid possible data loss."));
-                return TRUE;
-            }
-            if(battmon->options.action_on_critical == BM_COMMAND ||
-               battmon->options.action_on_critical == BM_COMMAND_TERM){
-                int interm=(battmon->options.action_on_critical == BM_COMMAND_TERM)?1:0;
-                if (!battmon->options.command_on_critical ||
-                    !strlen(battmon->options.command_on_critical)) goto do_critical_warn;
-                xfce_exec (battmon->options.command_on_critical, interm, 0, NULL);
-            }
-        } else if (!battmon->low){
-                battmon->low = TRUE;
-            if(battmon->options.action_on_low == BM_MESSAGE){
-do_low_warn:
-                xfce_warn(_("WARNING: Your battery is running low. You should consider plugging in or shutting down your computer soon to avoid possible data loss."));
-                return TRUE;
-            }
-            if(battmon->options.action_on_low == BM_COMMAND ||
-               battmon->options.action_on_low == BM_COMMAND_TERM){
-                int interm=(battmon->options.action_on_low == BM_COMMAND_TERM)?1:0;
-                if (!battmon->options.command_on_low ||
-                    !strlen(battmon->options.command_on_low)) goto do_low_warn;
-                xfce_exec(battmon->options.command_on_low, interm, 0, NULL);
-            }
-        }
-    }
-
-    return TRUE;
-}
-
-static GdkPixbuf *
-battmon_icon (t_battmon *battmon)
-{
-    GdkPixbuf      *icon;
-    GtkOrientation  orientation;
-    gint            width, height, size;
-
-    /* panel info */
-    orientation = xfce_panel_plugin_get_orientation (battmon->plugin);
-    size = xfce_panel_plugin_get_size (battmon->plugin) - 6;
-
-        /* icon size is 41x64px */
-    if (orientation == GTK_ORIENTATION_HORIZONTAL)
-    {
-        height = size;
-        width = height * 0.625;
-    }
-    else /* vertical */
-    {
-        width = size;
-        height = width * 1.6;
-    }
-
-    /* try to load battery icon from your current icon theme */
-    icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
-                                     "battery", size , 0, NULL);
-
-    return icon;
-}
-
-
-static void setup_battmon(t_battmon *battmon, GtkOrientation orientation)
-{
-    GtkWidget *box,*vbox;
-    GdkPixbuf *icon;
-
-    battmon->battstatus = gtk_progress_bar_new();
-    if (orientation == GTK_ORIENTATION_HORIZONTAL)
-    {
-       gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(battmon->battstatus),
-               GTK_PROGRESS_BOTTOM_TO_TOP);
-       box=gtk_hbox_new(FALSE, 0);
-       battmon->vbox = gtk_hbox_new(FALSE, 0);
-    } else {
-       gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(battmon->battstatus),
-               GTK_PROGRESS_LEFT_TO_RIGHT);
-       box=gtk_vbox_new(FALSE, 0);
-       battmon->vbox = gtk_vbox_new(FALSE, 0);
-    }
-
-    gtk_container_set_border_width(GTK_CONTAINER(battmon->vbox), BORDER / 2);
-
-    gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(battmon->battstatus), 0.0);
-
-    icon  = battmon_icon (battmon);
-    if (icon)
-    {
-        battmon->image = gtk_image_new_from_pixbuf (icon);
-        g_object_unref (G_OBJECT (icon));
-    }
-    else
-    {
-        battmon->image = gtk_image_new_from_icon_name ("battery", GTK_ICON_SIZE_BUTTON);
-    }
-
-    gtk_box_pack_start(GTK_BOX(box),GTK_WIDGET(battmon->image), FALSE, FALSE, 2);
-    /* init hide the widget */
-    gtk_widget_hide(battmon->image);
-
-      battmon->label = (GtkLabel *)gtk_label_new(_("Battery"));
-        gtk_box_pack_start(GTK_BOX(box),GTK_WIDGET(battmon->label),FALSE, FALSE, 0);
-
-    gtk_box_pack_start(GTK_BOX(box),  GTK_WIDGET(battmon->battstatus), FALSE, FALSE, 2);
-
-    vbox = gtk_vbox_new(FALSE, 0);
-
-    /* percent + rtime */
-    gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(vbox), FALSE, FALSE, 0);
-
-      battmon->charge = (GtkLabel *)gtk_label_new("50%%");
-        gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(battmon->charge),TRUE, TRUE, 0);
-
-      battmon->rtime = (GtkLabel *)gtk_label_new("01:00");
-    gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(battmon->rtime),TRUE, TRUE, 0);
-
-    vbox=gtk_vbox_new(FALSE, 0);
-    gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(vbox), FALSE, FALSE, 0);
-
-    battmon->alt_rtime = (GtkLabel *)gtk_label_new("01:00");
-    gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(battmon->alt_rtime),TRUE, TRUE, 0);
-
-    vbox=gtk_vbox_new(FALSE, 0);
-
-    /* ac-fan-temp */
-    gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(vbox), FALSE, FALSE, 0);
-
-    battmon->acfan = (GtkLabel *)gtk_label_new("AC FAN");
-        gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(battmon->acfan),TRUE, TRUE, 0);
-
-      battmon->temp = (GtkLabel *)gtk_label_new("40°C");
-        gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(battmon->temp),TRUE, TRUE, 0);
-
-
-    gtk_box_pack_start(GTK_BOX(battmon->vbox), box, FALSE, FALSE, 0);
-    gtk_widget_show_all(battmon->vbox);
-    if(!battmon->options.display_label)
-        gtk_widget_hide((GtkWidget *)battmon->label);
-    if(!battmon->options.display_power){
-        gtk_widget_hide((GtkWidget *)battmon->acfan);
-        gtk_widget_hide((GtkWidget *)battmon->temp);
-    }
-    if(!battmon->options.display_percentage){
-        gtk_widget_hide((GtkWidget *)battmon->charge);
-    }
-    if (!battmon->options.display_time){
-        gtk_widget_hide((GtkWidget *)battmon->rtime);
-        gtk_widget_hide((GtkWidget *)battmon->alt_rtime);
-    } else {
-        if ( battmon_time_labels_fits(battmon) ) {
-        gtk_widget_hide((GtkWidget*)battmon->alt_rtime);
-        } else {
-        gtk_widget_hide((GtkWidget*)battmon->rtime);
-        }
-    }
-
-    gtk_container_add(GTK_CONTAINER(battmon->ebox),GTK_WIDGET(battmon->vbox));
-    gtk_widget_show(battmon->ebox);
-
-
-    gdk_color_parse(HIGH_COLOR, &(battmon->colorH));
-    gdk_color_parse(LOW_COLOR, &(battmon->colorL));
-    gdk_color_parse(CRITICAL_COLOR, &(battmon->colorC));
-    gtk_widget_set_size_request(battmon->ebox, -1, -1);
-}
-
-static gboolean
-battmon_set_orientation (XfcePanelPlugin *plugin, GtkOrientation orientation,
-                         t_battmon *battmon)
-{
-    if (battmon->timeoutid) g_source_remove(battmon->timeoutid);
-    gtk_container_remove(GTK_CONTAINER(battmon->ebox), GTK_WIDGET(battmon->vbox));
-    setup_battmon(battmon,orientation);
-    update_apm_status( battmon );
-    battmon->timeoutid = g_timeout_add(1 * 1024, (GSourceFunc) update_apm_status, battmon);
-
-    return TRUE;
-}
-
-static t_battmon*
-battmon_create(XfcePanelPlugin *plugin)
-{
-    t_battmon *battmon;
-
-    battmon = g_new(t_battmon, 1);
-    init_options(&(battmon->options));
-
-        battmon->plugin = plugin;
-
-    battmon->low = FALSE;
-    battmon->critical = FALSE;
-    battmon->ebox = gtk_event_box_new();
-    setup_battmon(battmon, xfce_panel_plugin_get_orientation (plugin));
-    battmon->timeoutid = 0;
-    battmon->flag = FALSE;
-    battmon->tips = gtk_tooltips_new ();
-    g_object_ref (G_OBJECT (battmon->tips));
-    gtk_object_sink (GTK_OBJECT (battmon->tips));
-
-    return battmon;
-}
-
-static void
-battmon_free(XfcePanelPlugin *plugin, t_battmon *battmon)
-{
-    if(battmon->timeoutid != 0) {
-        g_source_remove(battmon->timeoutid);
-        battmon->timeoutid = 0;
-    }
-
-    /* cleanup options */
-    g_free (battmon->options.command_on_low);
-    g_free (battmon->options.command_on_critical);
-
-    /* free tooltip */
-    gtk_tooltips_set_tip (battmon->tips, battmon->ebox, NULL, NULL);
-    g_object_unref (G_OBJECT (battmon->tips));
-
-    g_free(battmon);
-}
-
-static void
-battmon_read_config(XfcePanelPlugin *plugin, t_battmon *battmon)
-{
-    const char *value;
-    char *file;
-    XfceRc *rc;
-
-    if (!(file = xfce_panel_plugin_lookup_rc_file (plugin)))
-        return;
-
-    rc = xfce_rc_simple_open (file, TRUE);
-    g_free (file);
-
-    if (!rc)
-        return;
-
-    battmon->options.display_label = xfce_rc_read_bool_entry (rc, "display_label", FALSE);
-
-    battmon->options.display_icon = xfce_rc_read_bool_entry (rc, "display_icon", FALSE);
-
-    battmon->options.display_power = xfce_rc_read_bool_entry (rc, "display_power", FALSE);
-
-    battmon->options.display_percentage = xfce_rc_read_bool_entry (rc, "display_percentage", FALSE);
-
-    battmon->options.display_time = xfce_rc_read_bool_entry (rc, "display_time", FALSE);
-
-    battmon->options.tooltip_display_percentage = xfce_rc_read_bool_entry (rc, "tooltip_display_percentage", FALSE);
-
-    battmon->options.tooltip_display_time = xfce_rc_read_bool_entry (rc, "tooltip_display_time", FALSE);
-
-    battmon->options.low_percentage = xfce_rc_read_int_entry (rc, "low_percentage", 10);
-
-    battmon->options.critical_percentage = xfce_rc_read_int_entry (rc, "critical_percentage", 5);
-
-    battmon->options.action_on_low = xfce_rc_read_int_entry (rc, "action_on_low", 0);
-
-    battmon->options.action_on_critical = xfce_rc_read_int_entry (rc, "action_on_critical", 0);
-
-    battmon->options.hide_when_full = xfce_rc_read_int_entry (rc, "hide_when_full", 0);
-
-    if ((value =  xfce_rc_read_entry (rc, "command_on_low", NULL)) && *value)
-        battmon->options.command_on_low = g_strdup (value);
-
-    if((value =  xfce_rc_read_entry (rc, "command_on_critical", NULL)) && *value)
-        battmon->options.command_on_critical = g_strdup (value);
-
-    xfce_rc_close (rc);
-}
-
-static void
-battmon_write_config(XfcePanelPlugin *plugin, t_battmon *battmon)
-{
-    XfceRc *rc;
-    gchar *file;
-
-    if (!(file = xfce_panel_plugin_save_location (plugin, TRUE)))
-        return;
-
-    rc = xfce_rc_simple_open (file, FALSE);
-    g_free (file);
-
-    if (!rc)
-        return;
-
-    xfce_rc_write_bool_entry (rc, "display_label", battmon->options.display_label);
-
-    xfce_rc_write_bool_entry (rc, "display_icon", battmon->options.display_icon);
-
-    xfce_rc_write_bool_entry (rc, "display_power", battmon->options.display_power);
-
-    xfce_rc_write_bool_entry (rc, "display_percentage", battmon->options.display_percentage);
-
-    xfce_rc_write_bool_entry (rc, "display_time", battmon->options.display_time);
-
-    xfce_rc_write_bool_entry (rc, "tooltip_display_percentage", battmon->options.tooltip_display_percentage);
-
-    xfce_rc_write_bool_entry (rc, "tooltip_display_time", battmon->options.tooltip_display_time);
-
-    xfce_rc_write_int_entry (rc, "low_percentage", battmon->options.low_percentage);
-
-    xfce_rc_write_int_entry (rc, "critical_percentage", battmon->options.critical_percentage);
-
-    xfce_rc_write_int_entry (rc, "action_on_low", battmon->options.action_on_low);
-
-    xfce_rc_write_int_entry (rc, "action_on_critical", battmon->options.action_on_critical);
-
-    xfce_rc_write_int_entry (rc, "hide_when_full", battmon->options.hide_when_full );
-
-    xfce_rc_write_entry (rc, "command_on_low", battmon->options.command_on_low ? battmon->options.command_on_low : "");
-
-    xfce_rc_write_entry (rc, "command_on_critical", battmon->options.command_on_critical ? battmon->options.command_on_critical : "");
-
-    xfce_rc_close (rc);
-}
-
-static gboolean
-battmon_set_size(XfcePanelPlugin *plugin, int size, t_battmon *battmon)
-{
-    GdkPixbuf *icon;
-
-    if (xfce_panel_plugin_get_orientation (plugin) ==
-            GTK_ORIENTATION_HORIZONTAL)
-    {
-        /* force size of the panel plugin */
-        gtk_widget_set_size_request(GTK_WIDGET(battmon->plugin),
-                                -1, size);
-        /* size of the progressbar */
-        gtk_widget_set_size_request(GTK_WIDGET(battmon->battstatus),
-                BORDER, size);
-    }
-    else
-    {
-        /* size of the plugin */
-        gtk_widget_set_size_request(GTK_WIDGET(battmon->plugin),
-                size, -1);
-        /* size of the progressbar */
-        gtk_widget_set_size_request(GTK_WIDGET(battmon->battstatus),
-                size, BORDER);
-    }
-
-    /* update the icon */
-    icon  = battmon_icon (battmon);
-    if (icon)
-    {
-        gtk_image_set_from_pixbuf (GTK_IMAGE (battmon->image), icon);
-        g_object_unref (G_OBJECT (icon));
-    }
-
-    return TRUE;
-}
-
-
-static void refresh_dialog(t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-
-    gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->sb_low_percentage), battmon->options.low_percentage);
-    gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->sb_critical_percentage), battmon->options.critical_percentage);
-    gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->om_action_low), battmon->options.action_on_low);
-    if(battmon->options.command_on_low)
-        gtk_entry_set_text(GTK_ENTRY(dialog->en_command_low), battmon->options.command_on_low);
-    else
-        gtk_entry_set_text(GTK_ENTRY(dialog->en_command_low), "");
-    gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->om_action_critical), battmon->options.action_on_critical);
-    if(battmon->options.command_on_critical)
-        gtk_entry_set_text(GTK_ENTRY(dialog->en_command_critical), battmon->options.command_on_critical);
-    else
-        gtk_entry_set_text(GTK_ENTRY(dialog->en_command_critical), "");
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->cb_disp_label), battmon->options.display_label);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->cb_disp_icon), battmon->options.display_icon);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->cb_disp_power), battmon->options.display_power);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->cb_disp_percentage), battmon->options.display_percentage);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->cb_disp_time), battmon->options.display_time);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->cb_disp_tooltip_percentage), battmon->options.tooltip_display_percentage);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->cb_disp_tooltip_time), battmon->options.tooltip_display_time);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->cb_hide_when_full), battmon->options.hide_when_full);
-    gtk_widget_set_sensitive(dialog->en_command_low, (battmon->options.action_on_low > 1) ? 1 : 0);
-    gtk_widget_set_sensitive(dialog->en_command_critical, (battmon->options.action_on_critical > 1) ? 1 : 0);
-}
-
-static void
-set_disp_percentage(GtkToggleButton *tb, t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-
-    battmon->options.display_percentage = gtk_toggle_button_get_active(tb);
-    update_apm_status(dialog->battmon);
-}
-
-static void
-set_disp_time(GtkToggleButton *tb, t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-
-    battmon->options.display_time = gtk_toggle_button_get_active(tb);
-    update_apm_status(dialog->battmon);
-}
-
-static void
-set_hide_when_full(GtkToggleButton *tb, t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-
-    battmon->options.hide_when_full = gtk_toggle_button_get_active(tb);
-    update_apm_status(dialog->battmon);
-}
-
-static void
-set_tooltip_disp_percentage(GtkToggleButton *tb, t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-
-    battmon->options.tooltip_display_percentage = gtk_toggle_button_get_active(tb);
-}
-static void
-set_disp_power(GtkToggleButton *tb, t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-
-    battmon->options.display_power = gtk_toggle_button_get_active(tb);
-    update_apm_status(dialog->battmon);
-}
-static void
-set_disp_label(GtkToggleButton *tb, t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-
-    battmon->options.display_label = gtk_toggle_button_get_active(tb);
-    update_apm_status(dialog->battmon);
-}
-
-static void
-set_disp_icon(GtkToggleButton *tb, t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-
-    battmon->options.display_icon = gtk_toggle_button_get_active(tb);
-    update_apm_status(dialog->battmon);
-}
-
-static void
-set_tooltip_time(GtkToggleButton *tb, t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-
-    battmon->options.tooltip_display_time = gtk_toggle_button_get_active(tb);
-}
-
-static void
-set_low_percentage(GtkSpinButton *sb, t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-
-    battmon->options.low_percentage = gtk_spin_button_get_value_as_int(sb);
-    update_apm_status(dialog->battmon);
-}
-
-static void
-set_critical_percentage(GtkSpinButton *sb, t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-
-    battmon->options.critical_percentage = gtk_spin_button_get_value_as_int(sb);
-    update_apm_status(dialog->battmon);
-}
-
-static void
-set_action_low(GtkOptionMenu *om, t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-
-    battmon->options.action_on_low = gtk_option_menu_get_history(om);
-
-    gtk_widget_set_sensitive(dialog->en_command_low, (gtk_option_menu_get_history(om) > 1) ? 1 : 0);
-    update_apm_status(dialog->battmon);
-}
-
-static void
-set_action_critical(GtkOptionMenu *om, t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-
-    battmon->options.action_on_critical = gtk_option_menu_get_history(om);
-
-    gtk_widget_set_sensitive(dialog->en_command_critical, (gtk_option_menu_get_history(om) > 1) ? 1 : 0);
-    update_apm_status(dialog->battmon);
-}
-
-static gboolean
-set_command_low(GtkEntry *en, GdkEventFocus *event, t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-    const char *temp;
-
-    g_free(battmon->options.command_on_low);
-    temp = gtk_entry_get_text(en);
-    battmon->options.command_on_low = g_strdup(temp);
-    update_apm_status(dialog->battmon);
-
-    /* Prevents a GTK crash */
-    return FALSE;
-}
-
-static gboolean
-set_command_critical(GtkEntry *en, GdkEventFocus *event, t_battmon_dialog *dialog)
-{
-    t_battmon *battmon = dialog->battmon;
-    const char *temp;
-
-    g_free(battmon->options.command_on_critical);
-    temp = gtk_entry_get_text(en);
-    battmon->options.command_on_critical = g_strdup(temp);
-    update_apm_status(dialog->battmon);
-
-    /* Prevents a GTK crash */
-    return FALSE;
-}
-
-static char *
-select_file_name (const char *title, const char *path, GtkWidget * parent)
-{
-    const char *t;
-    GtkWidget *fs;
-    char *name = NULL;
-
-    t = (title) ? title : _("Select file");
-
-    fs = gtk_file_chooser_dialog_new (t, GTK_WINDOW(parent),
-                               GTK_FILE_CHOOSER_ACTION_OPEN,
-                               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                               GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
-                               NULL);
-
-    if (path && *path && g_file_test (path, G_FILE_TEST_EXISTS))
-    {
-        if (!g_path_is_absolute (path))
-        {
-            char *current, *full;
-
-            current = g_get_current_dir ();
-            full = g_build_filename (current, path, NULL);
-
-            gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fs), full);
-
-            g_free (current);
-            g_free (full);
-        }
-        else
-        {
-            gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fs), path);
-        }
-    }
-
-    if (gtk_dialog_run (GTK_DIALOG (fs)) == GTK_RESPONSE_ACCEPT)
-    {
-        name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs));
-    }
-
-    gtk_widget_destroy (fs);
-
-    return name;
-}
-
-static void
-command_browse_cb (GtkWidget *b, GtkEntry *entry)
-{
-    char *file = select_file_name(_("Select command"), gtk_entry_get_text(entry), gtk_widget_get_toplevel (b));
-
-    if (file) {
-        gtk_entry_set_text (entry, file);
-        g_free (file);
-    }
-}
-
-static void
-battmon_dialog_response (GtkWidget *dlg, int response, t_battmon *battmon)
-{
-    gboolean result;
-
-    if (response == GTK_RESPONSE_HELP)
-    {
-        /* show help */
-        result = g_spawn_command_line_async ("exo-open --launch WebBrowser " PLUGIN_WEBSITE, NULL);
-
-        if (G_UNLIKELY (result == FALSE))
-            g_warning (_("Unable to open the following url: %s"), PLUGIN_WEBSITE);
-    }
-    else
-    {
-        gtk_widget_destroy (dlg);
-        xfce_panel_plugin_unblock_menu (battmon->plugin);
-        battmon_write_config (battmon->plugin, battmon);
-    }
-}
-
-static void
-battmon_create_options(XfcePanelPlugin *plugin, t_battmon *battmon)
-{
-    GtkWidget *dlg;
-    GtkWidget *vbox, *vbox2, *hbox, *label, *menu, *mi, *button, *button2;
-    GtkSizeGroup *sg;
-    t_battmon_dialog *dialog;
-
-    dialog = g_new0(t_battmon_dialog, 1);
-
-    dialog->battmon = battmon;
-
-    xfce_panel_plugin_block_menu (plugin);
-
-    dlg = xfce_titled_dialog_new_with_buttons (_("Battery Monitor"),
-                                                  GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
-                                                  GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
-                                                  GTK_STOCK_HELP, GTK_RESPONSE_HELP,
-                                                  GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
-                                                  NULL);
-
-    gtk_window_set_position   (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER);
-    gtk_window_set_icon_name  (GTK_WINDOW (dlg), "xfce4-settings");
-
-    g_signal_connect (dlg, "response", G_CALLBACK (battmon_dialog_response),
-                      battmon);
-
-    gtk_container_set_border_width (GTK_CONTAINER (dlg), 2);
-
-    vbox = gtk_vbox_new(FALSE, BORDER);
-    gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER - 2);
-    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), vbox,
-                        TRUE, TRUE, 0);
-
-    /* Create size group to keep widgets aligned */
-
-    sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
-
-    /* Low and Critical percentage settings */
-
-    hbox = gtk_hbox_new(FALSE, BORDER);
-    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
-
-    label = gtk_label_new(_("Low percentage:"));
-    gtk_size_group_add_widget(sg, label);
-    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-
-    dialog->sb_low_percentage = gtk_spin_button_new_with_range(1, 100, 1);
-    gtk_box_pack_start(GTK_BOX(hbox), dialog->sb_low_percentage, FALSE, FALSE, 0);
-
-    hbox = gtk_hbox_new(FALSE, BORDER);
-    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
-
-    label = gtk_label_new(_("Critical percentage:"));
-    gtk_size_group_add_widget(sg, label);
-    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-
-    dialog->sb_critical_percentage = gtk_spin_button_new_with_range(1, 100, 1);
-    gtk_box_pack_start(GTK_BOX(hbox), dialog->sb_critical_percentage, FALSE, FALSE, 0);
-
-    /* Low battery action settings */
-
-    hbox = gtk_hbox_new(FALSE, BORDER);
-    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
-
-    label = gtk_label_new(_("Low battery action:"));
-    gtk_size_group_add_widget(sg, label);
-    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-
-    menu = gtk_menu_new();
-        mi = gtk_menu_item_new_with_label(_("Do nothing"));
-    gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
-     mi = gtk_menu_item_new_with_label(_("Display a warning message"));
-        gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
-    mi = gtk_menu_item_new_with_label(_("Run command"));
-        gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
-     mi = gtk_menu_item_new_with_label(_("Run command in terminal"));
-        gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
-
-
-    dialog->om_action_low = gtk_option_menu_new();
-    gtk_option_menu_set_menu(GTK_OPTION_MENU(dialog->om_action_low), menu);
-    gtk_box_pack_start(GTK_BOX(hbox), dialog->om_action_low, FALSE, FALSE, 0);
-
-    /* Low battery command */
-
-    hbox = gtk_hbox_new(FALSE, BORDER);
-      gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
-
-        label = gtk_label_new(_("Command:"));
-        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-        gtk_size_group_add_widget(sg, label);
-    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-
-        dialog->en_command_low = gtk_entry_new();
-        gtk_box_pack_start(GTK_BOX(hbox), dialog->en_command_low, FALSE, FALSE, 0);
-
-        button = gtk_button_new_with_label("...");
-        gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
-
-    /* Critical battery action settings */
-
-    hbox = gtk_hbox_new(FALSE, BORDER);
-    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
-
-    label = gtk_label_new(_("Critical battery action:"));
-    gtk_size_group_add_widget(sg, label);
-    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-
-    menu = gtk_menu_new();
-        mi = gtk_menu_item_new_with_label(_("Do nothing"));
-        gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
-     mi = gtk_menu_item_new_with_label(_("Display a warning message"));
-        gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
-    mi = gtk_menu_item_new_with_label(_("Run command"));
-        gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
-     mi = gtk_menu_item_new_with_label(_("Run command in terminal"));
-        gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
-
-    dialog->om_action_critical = gtk_option_menu_new();
-    gtk_option_menu_set_menu(GTK_OPTION_MENU(dialog->om_action_critical), menu);
-    gtk_box_pack_start(GTK_BOX(hbox), dialog->om_action_critical, FALSE, FALSE, 0);
-
-    /* Critical battery command */
-
-    hbox = gtk_hbox_new(FALSE, BORDER);
-      gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
-
-        label = gtk_label_new(_("Command:"));
-        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-        gtk_size_group_add_widget(sg, label);
-    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-
-        dialog->en_command_critical = gtk_entry_new();
-    gtk_box_pack_start(GTK_BOX(hbox), dialog->en_command_critical, FALSE, FALSE, 0);
-
-        button2 = gtk_button_new_with_label("...");
-        gtk_box_pack_start(GTK_BOX(hbox), button2, FALSE, FALSE, 0);
-
-    /* Create checkbox options */
-
-    hbox = gtk_hbox_new(FALSE, BORDER);
-    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
-
-    label = gtk_label_new(NULL);
-    gtk_size_group_add_widget(sg, label);
-    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-
-    vbox2 = gtk_vbox_new(FALSE, 4);
-    gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, 0);
-
-    dialog->cb_disp_label = gtk_check_button_new_with_mnemonic(_("Display label"));
-    gtk_box_pack_start(GTK_BOX(vbox2), dialog->cb_disp_label, FALSE, FALSE, 0);
-
-    dialog->cb_disp_percentage = gtk_check_button_new_with_mnemonic(_("Display percentage"));
-    gtk_box_pack_start(GTK_BOX(vbox2), dialog->cb_disp_percentage, FALSE, FALSE, 0);
-
-    dialog->cb_disp_time = gtk_check_button_new_with_mnemonic(_("Display time"));
-    gtk_box_pack_start(GTK_BOX(vbox2), dialog->cb_disp_time, FALSE, FALSE, 0);
-
-    dialog->cb_hide_when_full = gtk_check_button_new_with_mnemonic(_("Hide time/percentage when full"));
-    gtk_box_pack_start(GTK_BOX(vbox2), dialog->cb_hide_when_full, FALSE, FALSE, 0);
-
-    dialog->cb_disp_tooltip_percentage = gtk_check_button_new_with_mnemonic(_("Display percentage in tooltip"));
-    gtk_box_pack_start(GTK_BOX(vbox2), dialog->cb_disp_tooltip_percentage, FALSE, FALSE, 0);
-
-    dialog->cb_disp_tooltip_time = gtk_check_button_new_with_mnemonic(_("Display time remaining in tooltip"));
-    gtk_box_pack_start(GTK_BOX(vbox2), dialog->cb_disp_tooltip_time, FALSE, FALSE, 0);
-
-    dialog->cb_disp_power = gtk_check_button_new_with_mnemonic(_("Display power"));
-    gtk_box_pack_start(GTK_BOX(vbox2), dialog->cb_disp_power, FALSE, FALSE, 0);
-
-    dialog->cb_disp_icon = gtk_check_button_new_with_mnemonic(_("Display icon"));
-    gtk_box_pack_start(GTK_BOX(vbox2), dialog->cb_disp_icon, FALSE, FALSE, 0);
-
-    /* Signal connections should be set after setting tate of toggle buttons...*/
-    refresh_dialog(dialog);
-
-    g_signal_connect(button, "clicked", G_CALLBACK(command_browse_cb), dialog->en_command_low);
-    g_signal_connect(button2, "clicked", G_CALLBACK(command_browse_cb), dialog->en_command_critical);
-    g_signal_connect(dialog->cb_disp_percentage, "toggled", G_CALLBACK(set_disp_percentage), dialog);
-    g_signal_connect(dialog->cb_disp_time, "toggled", G_CALLBACK(set_disp_time), dialog);
-    g_signal_connect(dialog->cb_hide_when_full, "toggled", G_CALLBACK(set_hide_when_full), dialog);
-    g_signal_connect(dialog->cb_disp_tooltip_percentage, "toggled", G_CALLBACK(set_tooltip_disp_percentage), dialog);
-    g_signal_connect(dialog->cb_disp_power, "toggled", G_CALLBACK(set_disp_power), dialog);
-    g_signal_connect(dialog->cb_disp_tooltip_time, "toggled", G_CALLBACK(set_tooltip_time), dialog);
-    g_signal_connect(dialog->cb_disp_label, "toggled", G_CALLBACK(set_disp_label), dialog);
-    g_signal_connect(dialog->cb_disp_icon, "toggled", G_CALLBACK(set_disp_icon), dialog);
-
-    g_signal_connect(dialog->sb_low_percentage, "value-changed", G_CALLBACK(set_low_percentage), dialog);
-    g_signal_connect(dialog->sb_critical_percentage, "value-changed", G_CALLBACK(set_critical_percentage), dialog);
-    g_signal_connect(dialog->om_action_low, "changed", G_CALLBACK(set_action_low), dialog);
-    g_signal_connect(dialog->om_action_critical, "changed", G_CALLBACK(set_action_critical), dialog);
-    g_signal_connect(dialog->en_command_low, "focus-out-event", G_CALLBACK(set_command_low), dialog);
-    g_signal_connect(dialog->en_command_critical, "focus-out-event", G_CALLBACK(set_command_critical), dialog);
-
-    gtk_widget_show_all (dlg);
-}
-
-/* create the plugin */
-static void
-battmon_construct (XfcePanelPlugin *plugin)
-{
-    t_battmon *battmon;
-
-    xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
-
-    battmon = battmon_create (plugin);
-
-    battmon_read_config (plugin, battmon);
-
-    g_signal_connect (plugin, "free-data", G_CALLBACK (battmon_free), battmon);
-
-    g_signal_connect (plugin, "save", G_CALLBACK (battmon_write_config), battmon);
-
-    xfce_panel_plugin_menu_show_configure (plugin);
-    g_signal_connect (plugin, "configure-plugin", G_CALLBACK (battmon_create_options), battmon);
-
-    g_signal_connect (plugin, "size-changed", G_CALLBACK (battmon_set_size), battmon);
-
-    g_signal_connect (plugin, "orientation-changed", G_CALLBACK (battmon_set_orientation), battmon);
-
-    gtk_container_add(GTK_CONTAINER(plugin), battmon->ebox);
-
-    xfce_panel_plugin_add_action_widget (plugin, battmon->ebox);
-
-    xfce_panel_plugin_add_action_widget (plugin, battmon->battstatus);
-
-    /* Determine what facility to use and initialize reading */
-    battmon->method = BM_BROKEN;
-    update_apm_status(battmon);
-
-    /* If neither ACPI nor APM are enabled, check for either every 60 seconds */
-    if(battmon->timeoutid == 0)
-        battmon->timeoutid = g_timeout_add(60 * 1024, (GSourceFunc) update_apm_status, battmon);
-
-    /* Required for the percentage and tooltip to be initially displayed due to the long timeout for ACPI */
-    if(battmon->method == BM_USE_ACPI) {
-        battmon->flag = TRUE;
-        g_source_remove(battmon->timeoutid);
-        battmon->timeoutid = g_timeout_add(1000, (GSourceFunc) update_apm_status, battmon);
-    }
-}
-
-/* register the plugin */
-XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (battmon_construct);
-
diff --git a/panel-plugin/libacpi.c b/panel-plugin/libacpi.c
deleted file mode 100644
index 31bdeaf..0000000
--- a/panel-plugin/libacpi.c
+++ /dev/null
@@ -1,755 +0,0 @@
-/* $Id$
- *
- * Copyright (c) 2002 Costantino Pistagna <valvoline at vrlteam.org>
- * Copyright (c) 2003 Noberasco Michele <2001s098 at educ.disi.unige.it>
- * Copyright (c) 2003 Edscott Wilson Garcia <edscott at imp.mx>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Library General Public License as published
- * by the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This library 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 Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#ifndef __libacpi_c__
-#define __libacpi_c__
-#endif
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <dirent.h>
-
-#if HAVE_SYSCTL
-
-#ifdef __NetBSD__
-#include <sys/param.h>
-/* CTLTYPE does not exist in NetBSD headers.
- * Defining it to 0x0f here won't do any harm though. */
-#define CTLTYPE 0x0f
-#endif
-
-#include <sys/sysctl.h>
-#include <err.h>
-#include <errno.h>
-#include <unistd.h>
-
-#endif
-
-#include "libacpi.h"
-
-#define ACBASE "/proc/acpi/ac_adapter"
-
-
-static char batteries[MAXBATT][128];
-static char battinfo[MAXBATT][128];
-#ifndef __linux__
-#if HAVE_SYSCTL
- static int
-name2oid(char *name, int *oidp)
-{
-	int oid[2];
-	int i;
-	size_t j;
-
-	oid[0] = 0;
-	oid[1] = 3;
-
-	j = CTL_MAXNAME * sizeof(int);
-	i = sysctl(oid, 2, oidp, &j, name, strlen(name));
-	if (i < 0)
-		return i;
-	j /= sizeof(int);
-	return (j);
-}
-static int
-oidfmt(int *oid, int len, char *fmt, u_int *kind)
-{
-	int qoid[CTL_MAXNAME+2];
-	u_char buf[BUFSIZ];
-	int i;
-	size_t j;
-
-	qoid[0] = 0;
-	qoid[1] = 4;
-	memcpy(qoid + 2, oid, len * sizeof(int));
-
-	j = sizeof(buf);
-	i = sysctl(qoid, len + 2, buf, &j, 0, 0);
-	if (i)
-		err(1, "sysctl fmt %d %d %d", i, j, errno);
-
-	if (kind)
-		*kind = *(u_int *)buf;
-
-	if (fmt)
-		strcpy(fmt, (char *)(buf + sizeof(u_int)));
-	return 0;
-}
-
-
-
-static int
-get_var(int *oid, int nlen)
-{
-		int retval=0;
-	u_char buf[BUFSIZ], *val, *p;
-	char name[BUFSIZ], *fmt, *sep;
-	int qoid[CTL_MAXNAME+2];
-	int i;
-	size_t j, len;
-	u_int kind;
-/*	int (*func)(int, void *);*/
-
-	qoid[0] = 0;
-	memcpy(qoid + 2, oid, nlen * sizeof(int));
-
-	qoid[1] = 1;
-	j = sizeof(name);
-	i = sysctl(qoid, nlen + 2, name, &j, 0, 0);
-	if (i || !j)
-		err(1, "sysctl name %d %d %d", i, j, errno);
-
-	sep = "=";
-
-
-	/* find an estimate of how much we need for this var */
-	j = 0;
-	i = sysctl(oid, nlen, 0, &j, 0, 0);
-	j += j; /* we want to be sure :-) */
-
-	val = alloca(j + 1);
-	len = j;
-	i = sysctl(oid, nlen, val, &len, 0, 0);
-	if (i || !len)
-		return (1);
-
-	val[len] = '\0';
-	fmt = buf;
-	oidfmt(oid, nlen, fmt, &kind);
-	p = val;
-	switch (*fmt) {
-	case 'I':
-#ifdef DEBUG
-		printf("I:%s%s", name, sep);
-#endif
-		fmt++;
-		val = "";
-		while (len >= sizeof(int)) {
-			if(*fmt == 'U'){
-				retval=*((unsigned int *)p);
-#ifdef DEBUG
-				printf("x%s%u", val, *(unsigned int *)p);
-#endif
-			}
-			else {
-				retval=*((int *)p);
-#ifdef DEBUG
-				printf("x%s%d", val, *(int *)p);
-#endif
-			}
-			val = " ";
-			len -= sizeof(int);
-			p += sizeof(int);
-		}
-
-		return (retval);
-	default:
-			printf("%s%s", name, sep);
-		printf("Format:%s Length:%d Dump:0x", fmt, len);
-		while (len-- && (p < val + 16))
-			printf("%02x", *p++);
-		if (len > 16)
-			printf("...");
-		return (0);
-	}
-	return (0);
-}
-
-
-#endif
-#endif
-
-/* see if we have ACPI support */
-int check_acpi(void)
-{
-  DIR *battdir;
-  struct dirent *batt;
-  char *name;
-#ifdef __linux__
-  FILE *acpi;
-
-  if (!(acpi = fopen ("/proc/acpi/info", "r"))
-      && !(acpi = fopen ("/sys/module/acpi/parameters/acpica_version", "r")))
-  {
-#ifdef DEBUG
-	  printf("DBG:no acpi: /proc/acpi/info or "
-             "/sys/module/acpi/parameters/acpica_version not found!\n");
-#endif
-    return 1;
-  }
-
-  /* yep, all good */
-  fclose (acpi);
-
-  /* now enumerate batteries */
-  batt_count = 0;
-  battdir = opendir ("/proc/acpi/battery");
-  if (battdir == 0)
-  {
-#ifdef DEBUG
-	  printf("DBG:No battery. /proc/acpi/battery not found!\n");
-#endif
-    return 2;
-  }
-  while ((batt = readdir (battdir)))
-  {
-    name = batt->d_name;
-
-    /* skip . and .. */
-    if (!strncmp (".", name, 1) || !strncmp ("..", name, 2)) continue;
-
-    sprintf (batteries[batt_count], "/proc/acpi/battery/%s/state", name);
-    if (!(acpi = fopen (batteries[batt_count], "r"))) {
-       sprintf (batteries[batt_count], "/proc/acpi/battery/%s/status", name);
-    }
-    else fclose (acpi);
-
-    sprintf (battinfo[batt_count], "/proc/acpi/battery/%s/info", name);
-#ifdef DEBUG
-	  printf("DBG:battery number %d at:\n",batt_count);
-	  printf("DBG:info->%s\n",battinfo[batt_count]);
-	  printf("DBG:state->%s\n",batteries[batt_count]);
-	  printf("DBG:------------------------\n");
-#endif
-
-    batt_count++;
-  }
-  closedir (battdir);
-  return 0;
-#else
-#ifdef HAVE_SYSCTL
-  {
-    static char buf[BUFSIZ];
-    char *bufp=buf;
-    char fmt[BUFSIZ];
-    void *oldp=(void *)buf;
-    size_t oldlenp=BUFSIZ;
-    int len,mib[CTL_MAXNAME];
-    u_int kind;
-/*  snprintf(buf, BUFSIZ, "%s", "hw.acpi.battery.time");*/
-    snprintf(buf, BUFSIZ, "%s", "hw.acpi.battery.units");
-    len = name2oid(bufp, mib);
-    if (len <=0) return 1;
-    if (oidfmt(mib, len, fmt, &kind)) return 1;
-    if ((kind & CTLTYPE) == CTLTYPE_NODE) return 1;
-    batt_count=get_var(mib, len);
-
-  }
-  return 0;
-#else
-  return 1;
-#endif
-#endif
-}
-
-int read_acad_state(void)
-{
-#ifdef __linux__
-  FILE *acpi;
-  char *ptr;
-  char stat;
-
-  char acpath[64];
-  char *name;
-  DIR  *acdir;
-  struct dirent *ac;
-
-  if (!(acdir=opendir(ACBASE))){
-    return -1;
-  }
-  while ((ac = readdir (acdir))){
-    name = ac->d_name;
-
-    /* skip . and .. */
-    if (name[0] == '.')
-      continue;
-
-    sprintf (acpath, "%s/%s/state", ACBASE, name);
-    if (access(acpath,R_OK)){
-      sprintf (acpath, "%s/%s/status", ACBASE, name);
-      if (access(acpath,R_OK)){
-	return -1;
-      }
-    }
-    break; //only one ac adapter supported
-  }
-  closedir(acdir);
-  acpi = fopen (acpath, "r");
-
-  fread (buf, 512, 1, acpi);
-  fclose (acpi);
-  if (!acadstate) acadstate=(ACADstate *)malloc(sizeof(ACADstate));
-
-  if ( (ptr = strstr(buf, "state:")) )
-  {
-    stat = *(ptr + 26);
-    if (stat == 'n') acadstate->state = 1;
-    if (stat == 'f')
-  	{
-	    acadstate->state = 0;
-	    return 0;
-  	}
-  }
-
-  if ( (ptr = strstr (buf, "Status:")) )
-  {
-    stat = *(ptr + 26);
-    if (stat == 'n') acadstate->state = 1;
-    if (stat == 'f')
-  	{
-	    acadstate->state = 0;
-	    return 0;
-	  }
-  }
-
-  return 1;
-#else
-#ifdef HAVE_SYSCTL
-  static char buf[BUFSIZ];
-  char fmt[BUFSIZ];
-  void *oldp=(void *)buf;
-  char *bufp=buf;
-  size_t oldlenp=BUFSIZ;
-  int len,mib[CTL_MAXNAME];
-  u_int kind;
-  int retval;
-  snprintf(buf, BUFSIZ, "%s", "hw.acpi.acline");
-  len = name2oid(bufp, mib);
-  if (len <= 0) return(-1);
-  if (oidfmt(mib, len, fmt, &kind))
-	err(1, "couldn't find format of oid '%s'", bufp);
-  if (len < 0) errx(1, "unknown oid '%s'", bufp);
-  if ((kind & CTLTYPE) == CTLTYPE_NODE) {
-	printf("oh-oh...\n");
-  } else {
-	retval=get_var(mib, len);
-#ifdef DEBUG
-	printf("retval=%d\n",retval);
-#endif
-  }
-  return retval;
-#else
-  return 0;
-#endif
-#endif
-}
-
-int read_acpi_info(int battery)
-{
-#ifdef __linux__
-  FILE *acpi;
-  char *ptr;
-  char stat;
-  int temp;
-
-  if (battery > MAXBATT) {
-#ifdef DEBUG
-	  printf("DBG: error, battery > MAXBATT (%d)\n",MAXBATT);
-#endif
-	  return 0;
-  }
-  if (!(acpi = fopen (battinfo[battery], "r"))) {
-#ifdef DEBUG
-	  printf("DBG:cannot open %s for read!\n",battinfo[battery]);
-#endif
-	  return 0;
-  }
-
-#ifdef DEBUG
-  {
-	  int jj= fread (buf, 1,512, acpi);
-	  printf("DBG:%d characters read from %s\n",jj,battinfo[battery]);
-  }
-#else
-  fread (buf, 1,512, acpi);
-#endif
-  fclose (acpi);
-
-  if (!acpiinfo) acpiinfo=(ACPIinfo *)malloc(sizeof(ACPIinfo));
-
-  if ((ptr = strstr (buf, "present:")) || (ptr = strstr (buf, "Present:")))
-  {
-#ifdef DEBUG
-	  printf("DBG:Battery present... and its called %s\n",battinfo[battery]);
-#endif
-    stat = *(ptr + 25);
-    if (stat == 'y')
-  	{
-	    acpiinfo->present = 1;
-  	  if ((ptr = strstr (buf, "design capacity:")) || (ptr = strstr (buf, "Design Capacity:")))
-	    {
-	      ptr += 25;
-	      sscanf (ptr, "%d", &temp);
-	      acpiinfo->design_capacity = temp;
-#ifdef DEBUG
-	  printf("DBG:design capacity:%d\n",temp);
-#endif
-	    }
-	    if ((ptr = strstr (buf, "last full capacity:")) || (ptr = strstr (buf, "Last Full Capacity:")))
-	    {
-	      ptr += 25;
-	      sscanf (ptr, "%d", &temp);
-	      acpiinfo->last_full_capacity = temp;
-#ifdef DEBUG
-	  printf("DBG:last full capacity:%d\n",temp);
-#endif
-	    }
-	    if ((ptr = strstr (buf, "battery technology:")) || (ptr = strstr (buf, "Battery Technology:")))
-	    {
-	      stat = *(ptr + 25);
-	      switch (stat)
-		    {
-		      case 'n':
-		        acpiinfo->battery_technology = 1;
-		        break;
-		      case 'r':
-		        acpiinfo->battery_technology = 0;
-		        break;
-		    }
-	    }
-	    if ((ptr = strstr (buf, "design voltage:")) || (ptr = strstr (buf, "Design Voltage:")))
-	    {
-	      ptr += 25;
-	      sscanf (ptr, "%d", &temp);
-	      acpiinfo->design_voltage = temp;
-#ifdef DEBUG
-	  printf("DBG:design voltage:%d\n",temp);
-#endif
-	    }
-	    if ((ptr = strstr (buf, "design capacity warning:")) || (ptr = strstr (buf, "Design Capacity Warning:")))
-	    {
-	      ptr += 25;
-	      sscanf (ptr, "%d", &temp);
-	      acpiinfo->design_capacity_warning = temp;
-#ifdef DEBUG
-	  printf("DBG:design capacity warning:%d\n",temp);
-#endif
-	    }
-  	  if ((ptr = strstr (buf, "design capacity low:")) || (ptr = strstr (buf, "Design Capacity Low:")))
-	    {
-	      ptr += 25;
-	      sscanf (ptr, "%d", &temp);
-	      acpiinfo->design_capacity_low = temp;
-#ifdef DEBUG
-	  printf("DBG:design capacity low:%d\n",temp);
-#endif
-	    }
-#ifdef DEBUG
-	  printf("DBG:ALL Battery information read...\n");
-#endif
-	  }
-    else /* Battery not present */
-	  {
-#ifdef DEBUG
-	  printf("DBG:Battery not present!... and its called %s\n",battinfo[battery]);
-#endif
-	    acpiinfo->present = 0;
-	    acpiinfo->design_capacity = 0;
-	    acpiinfo->last_full_capacity = 0;
-	    acpiinfo->battery_technology = 0;
-	    acpiinfo->design_voltage = 0;
-	    acpiinfo->design_capacity_warning = 0;
-	    acpiinfo->design_capacity_low = 0;
-	    return 0;
-	  }
-  }
-
-  return 1;
-#else
-#ifdef HAVE_SYSCTL
-  static char buf[BUFSIZ];
-  char *bufp=buf;
-  int len,mib[CTL_MAXNAME];
-  char fmt[BUFSIZ];
-  u_int kind;
-  int retval;
-  if (!acpiinfo) acpiinfo=(ACPIinfo *)malloc(sizeof(ACPIinfo));
-	    acpiinfo->present = 0;
-	    acpiinfo->design_capacity = 0;
-	    acpiinfo->last_full_capacity = 0;
-	    acpiinfo->battery_technology = 0;
-	    acpiinfo->design_voltage = 0;
-	    acpiinfo->design_capacity_warning = 0;
-	    acpiinfo->design_capacity_low = 0;
-  snprintf(buf, BUFSIZ, "%s", "hw.acpi.battery.units");
-  len = name2oid(bufp, mib);
-  if (len <= 0) return(-1);
-  if (oidfmt(mib, len, fmt, &kind))
-	err(1, "couldn't find format of oid '%s'", bufp);
-  if (len < 0) errx(1, "unknown oid '%s'", bufp);
-  if ((kind & CTLTYPE) == CTLTYPE_NODE) {
-	printf("oh-oh...\n");
-  } else {
-	retval=get_var(mib, len);
-#ifdef DEBUG
-	printf("retval=%d\n",retval);
-#endif
-  }
-  acpiinfo->present = retval;
-  return 1;
-#else
-  return 0;
-#endif
-#endif
-
-}
-
-int read_acpi_state(int battery)
-{
-#ifdef __linux__
-  FILE *acpi;
-  char *ptr;
-  char stat;
-
-  int percent = 100;		/* battery percentage */
-  int ptemp, rate, rtime = 0;
-
-  if (!(acpi = fopen (batteries[battery], "r"))) {
-#ifdef DEBUG
-	  printf("DBG:Could not open %s (%d)\n",batteries[battery],battery);
-#endif
-	  return 0;
-  }
-
-  fread (buf, 512, 1, acpi);
-  fclose (acpi);
-  if (!acpistate) acpistate=(ACPIstate *)malloc(sizeof(ACPIstate));
-
-  if ((ptr = strstr (buf, "present:")) || (ptr = strstr (buf, "Present:")))
-  {
-#ifdef DEBUG
-	  printf("DBG:Battery state present...\n");
-#endif
-    stat = *(ptr + 25);
-    if (stat == 'y')
-  	{
-	    acpistate->present = 1;
-	    if ((ptr = strstr (buf, "charging state:")) || (ptr = strstr (buf, "State:")))
-	    {
-	      stat = *(ptr + 25);
-	      switch (stat)
-		    {
-		      case 'd':
-		        acpistate->state = 1;
-		        break;
-		      case 'c':
-		        if (*(ptr + 33) == '/')
-		          acpistate->state = 0;
-		        else
-		          acpistate->state = 2;
-		        break;
-		      case 'u':
-		        acpistate->state = 3;
-		        break;
-		    }
-	    }
-	    /* This section of the code will calculate "percentage remaining"
-	     * using battery capacity, and the following formula
-	     * (acpi spec 3.9.2):
-	     *
-	     * percentage = (current_capacity / last_full_capacity) * 100;
-	     *
-	     */
-	    if ((ptr = strstr (buf, "remaining capacity:")) || (ptr = strstr (buf, "Remaining Capacity:")))
-	    {
-	      ptr += 25;
-	      sscanf (ptr, "%d", &ptemp);
-	      acpistate->rcapacity = ptemp;
-	      percent =	(float) ((float) ptemp / (float) acpiinfo->last_full_capacity) * 100;
-	      acpistate->percentage = percent;
-#ifdef DEBUG
-	  printf("DBG:remaining capacity:100 * %d/%d = %d\n",
-			  ptemp,acpiinfo->last_full_capacity,acpistate->percentage);
-#endif
-	    }
-	    if ((ptr = strstr (buf, "present rate:")) || (ptr = strstr (buf, "Present Rate:")))
-	    {
-	      ptr += 25;
-	      sscanf (ptr, "%d", &rate);
-
-	      /* if something wrong */
-	      if (rate <= 0) rate = 0;
-
-	      acpistate->prate = rate;
-
-	      /* time remaining in minutes */
-	      rtime = ((float) ((float) acpistate->rcapacity /
-				(float) acpistate->prate)) * 60;
-	      if (rtime <= 0) rtime = 0;
-
-				acpistate->rtime = rtime;
-	    }
-	    if ((ptr = strstr (buf, "present voltage:")) || (ptr = strstr (buf, "Battery Voltage:")))
-	    {
-	      ptr += 25;
-	      sscanf (ptr, "%d", &ptemp);
-	      acpistate->pvoltage = ptemp;
-	    }
-	  }
-    else /* Battery not present */
-	  {
-	    acpistate->present = 0;
-	    acpistate->state = UNKNOW;
-	    acpistate->prate = 0;
-	    acpistate->rcapacity = 0;
-	    acpistate->pvoltage = 0;
-	    acpistate->rtime = 0;
-	    acpistate->percentage = 0;
-	    return 0;
-	  }
-  }
-
-  return 1;
-#else
-#ifdef HAVE_SYSCTL
-  char *string;
-  static char buf[BUFSIZ];
-  char fmt[BUFSIZ];
-  char *bufp=buf;
-  void *oldp=(void *)buf;
-  size_t oldlenp=BUFSIZ;
-  int len,mib[CTL_MAXNAME];
-  int retval;
-  u_int kind;
-  if (!acpistate) acpistate=(ACPIstate *)malloc(sizeof(ACPIstate));
-  acpistate->present = 0;
-  acpistate->state = UNKNOW;
-  acpistate->prate = 0;
-  acpistate->rcapacity = 0;
-  acpistate->pvoltage = 0;
-  acpistate->rtime = 0;
-  acpistate->percentage = 0;
-
-  snprintf(buf, BUFSIZ, "%s", "hw.acpi.battery.time");
-  len = name2oid(bufp, mib);
-  if (len <= 0) return(-1);
-  if (oidfmt(mib, len, fmt, &kind))
-	err(1, "couldn't find format of oid '%s'", bufp);
-  if (len < 0) errx(1, "unknown oid '%s'", bufp);
-  if ((kind & CTLTYPE) == CTLTYPE_NODE) {
-	printf("oh-oh...\n");
-  } else {
-	retval=get_var(mib, len);
-#ifdef DEBUG
-	printf("retval=%d\n",retval);
-#endif
-  }
-  acpistate->rtime =(retval<0)?0:retval;
-
-  snprintf(buf, BUFSIZ, "%s", "hw.acpi.battery.life");
-  len = name2oid(bufp, mib);
-  if (len <= 0) return(-1);
-  if (oidfmt(mib, len, fmt, &kind))
-	err(1, "couldn't find format of oid '%s'", bufp);
-  if (len < 0) errx(1, "unknown oid '%s'", bufp);
-  if ((kind & CTLTYPE) == CTLTYPE_NODE) {
-	printf("oh-oh...\n");
-  } else {
-	retval=get_var(mib, len);
-#ifdef DEBUG
-	printf("retval=%d\n",retval);
-#endif
-  }
-  acpistate->percentage =retval;
-  return 1;
-#else
-  return 0;
-#endif
-#endif
-}
-
-int get_fan_status(void)
-{
-  FILE *fp;
-  char * proc_fan_status="/proc/acpi/toshiba/fan";
-  char line[256];
-  /*int result;*/
-
-   /* Check for fan status in PROC filesystem */
-    if ( (fp=fopen(proc_fan_status, "r")) != NULL ) {
- 	  fgets(line,255,fp);
-  	  fclose(fp);
-  	  if (strlen(line) && strstr(line,"1")) return 1;
-    	  else return 0;
-    }
-    proc_fan_status="/proc/acpi/fan/*/state";
-    if ( (fp=fopen(proc_fan_status, "r")) == NULL ) return 0;
-
-    fgets(line,255,fp);
-    fclose(fp);
-
-    if (strlen(line) && strstr(line,"off")) return 0;
-    else return 1;
-}
-
-const char *get_temperature(void)
-{
-#ifdef __linux__
-  FILE *fp;
-  char *proc_temperature="/proc/acpi/thermal_zone/*0/temperature";
-  static char *p,line[256];
-
-  if ( (fp=fopen(proc_temperature, "r")) == NULL) return NULL;
-  fgets(line,255,fp);
-  fclose(fp);
-  p=strtok(line," ");
-  if (!p) return NULL;
-  p=p+strlen(p)+1;
-  while (p && *p ==' ') p++;
-  if (*p==0) return NULL;
-  if (strchr(p,'\n')) p=strtok(p,"\n");
-  return (const char *)p;
-#else
-#ifdef HAVE_SYSCTL
-  static char buf[BUFSIZ];
-  char fmt[BUFSIZ];
-  char *bufp=buf;
-  void *oldp=(void *)buf;
-  size_t oldlenp=BUFSIZ;
-  int len,mib[CTL_MAXNAME];
-  int retval;
-  u_int kind;
-  snprintf(buf, BUFSIZ, "%s", "hw.acpi.thermal.tz0.temperature");
-  len = name2oid(bufp, mib);
-  if (len <= 0) return(NULL);
-  if (oidfmt(mib, len, fmt, &kind))
-	err(1, "couldn't find format of oid '%s'", bufp);
-  if (len < 0) errx(1, "unknown oid '%s'", bufp);
-  if ((kind & CTLTYPE) == CTLTYPE_NODE) {
-	printf("oh-oh...\n");
-  } else {
-	retval=get_var(mib, len);
-#ifdef DEBUG
-	printf("retval=%d\n",retval);
-#endif
-  }
-  snprintf(buf, BUFSIZ, "%d C",(retval-2735)/10);
-  return (const char *)buf;
-#else
-  return "";
-#endif
-#endif
-}
-
diff --git a/panel-plugin/libacpi.h b/panel-plugin/libacpi.h
deleted file mode 100644
index cc4fb6e..0000000
--- a/panel-plugin/libacpi.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* $Id$
- *
- * Copyright (c) 2002 Costantino Pistagna <valvoline at vrlteam.org>
- * Copyright (c) 2003 Noberasco Michele <2001s098 at educ.disi.unige.it>
- * Copyright (c) 2003 Edscott Wilson Garcia <edscott at imp.mx>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Library General Public License as published
- * by the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This library 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 Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#define MAXBATT 8
-
-typedef enum
-{
-  POWER,			/* on AC, Battery charged  */
-  DISCHARGING,			/* on Battery, Discharging */
-  CHARGING,			/* on AC, Charging         */
-  UNKNOW			/* unknow                  */
-}
-Charging;
-
-typedef struct
-{
-  int present;			/* 1 if present, 0 if no battery         */
-  Charging state;		/* charging state enum                   */
-  int prate;			/* present rate                          */
-  int rcapacity;		/* rameining capacity                    */
-  int pvoltage;			/* present voltage                       */
-
-  /* not present in /proc */
-  int rtime;			/* remaining time                        */
-  int percentage;		/* battery percentage (-1 if no battery) */
-}
-ACPIstate;
-
-typedef struct
-{
-  int present;			/* 1 if present, 0 if no battery        */
-  int design_capacity;		/* design capacity                      */
-  int last_full_capacity;	/* last_full_capacity                   */
-  int battery_technology;	/* 1 non-rechargeable, 0 rechargeable   */
-  int design_voltage;		/* design voltage                       */
-  int design_capacity_warning;	/* design capacity warning (critical)   */
-  int design_capacity_low;	/* design capacity low (low level)      */
-}
-ACPIinfo;
-
-
-typedef struct
-{
-  int state;			/* 1 if online, 0 if offline            */
-}
-ACADstate;
-
-int check_acpi (void);
-int read_acad_state (void);
-int read_acpi_info (int battery);
-int read_acpi_state (int battery);
-int get_fan_status(void);
-const char *get_temperature(void);
-
-#ifdef __libacpi_c__
-/* global */
-char battery_type;
-ACPIstate *acpistate=NULL;
-ACPIinfo *acpiinfo=NULL;
-ACADstate *acadstate=NULL;
-/* batteries detected */
-int batt_count;
-/* temp buffer */
-char buf[512];
-#else
-extern int batt_count;
-extern ACPIstate *acpistate;
-extern ACPIinfo *acpiinfo;
-extern ACADstate *acadstate;
-#endif
-
-
-
diff --git a/panel-plugin/libapm.c b/panel-plugin/libapm.c
deleted file mode 100644
index cde93ea..0000000
--- a/panel-plugin/libapm.c
+++ /dev/null
@@ -1,473 +0,0 @@
-/* $Id$
- *
- * Copyright (c) 1996, 1997 Rickard E. Faith <faith at acm.org>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Library General Public License as published
- * by the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This library 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 Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-
-#ifndef __linux__
-/* FIXME: enable BSD apm calls here */
-int apm_exists(void)
-{
-     return 0;
-}
-#else
-#include <sys/sysmacros.h>
-#include "libapm.h"
-
-#define BACKWARD_COMPAT 1
-
-/* If APM support of the right version exists in kernel, return zero.
- * Otherwise, return 1 if no support exists, or 2 if it is the wrong
- * version.  *NOTE* The sense of the return value is not intuitive.
- */
-int apm_exists(void)
-{
-    apm_info i;
-
-    if (access(APM_PROC, R_OK))
-	return 1;
-    return apm_read(&i);
-}
-
-
-/* Read information from /proc/apm.  Return 0 on success, 1 if APM not
- * installed, 2 if APM installed, but old version.
- */
-int apm_read(apm_info * i)
-{
-    FILE *str;
-    char units[10];
-    char buffer[100];
-    int retcode = 0;
-
-    if (!(str = fopen(APM_PROC, "r")))
-	return 1;
-    fgets(buffer, sizeof(buffer) - 1, str);
-    buffer[sizeof(buffer) - 1] = '\0';
-
-    /* Should check for other driver versions; driver 1.9 (and some
-     * others) uses this format, which doesn't expose # batteries.
-     */
-    sscanf(buffer, "%s %d.%d %x %x %x %x %d%% %d %s\n",
-	   (char *) i->driver_version,
-	   &i->apm_version_major,
-	   &i->apm_version_minor,
-	   &i->apm_flags,
-	   &i->ac_line_status,
-	   &i->battery_status,
-	   &i->battery_flags,
-	   &i->battery_percentage,
-	   &i->battery_time,
-	   units);
-    i->using_minutes = !strncmp(units, "min", 3) ? 1 : 0;
-    if (i->driver_version[0] == 'B')
-    {				/* old style.  argh. */
-#if !BACKWARD_COMPAT
-	retcode = 2;
-#else
-	strcpy((char *) i->driver_version, "pre-0.7");
-	i->apm_version_major = 0;
-	i->apm_version_minor = 0;
-	i->apm_flags = 0;
-	i->ac_line_status = 0xff;
-	i->battery_status = 0xff;
-	i->battery_flags = 0xff;
-	i->battery_percentage = -1;
-	i->battery_time = -1;
-	i->using_minutes = 1;
-
-	sscanf(buffer, "BIOS version: %d.%d",
-	       &i->apm_version_major, &i->apm_version_minor);
-	fgets(buffer, sizeof(buffer) - 1, str);
-	sscanf(buffer, "Flags: 0x%02x", &i->apm_flags);
-	if (i->apm_flags & APM_32_BIT_SUPPORT)
-	{
-	    fgets(buffer, sizeof(buffer) - 1, str);
-	    fgets(buffer, sizeof(buffer) - 1, str);
-	    if (buffer[0] != 'P')
-	    {
-		if (!strncmp(buffer + 4, "off line", 8))
-		    i->ac_line_status = 0;
-		else if (!strncmp(buffer + 4, "on line", 7))
-		    i->ac_line_status = 1;
-		else if (!strncmp(buffer + 4, "on back", 7))
-		    i->ac_line_status = 2;
-
-		fgets(buffer, sizeof(buffer) - 1, str);
-		if (!strncmp(buffer + 16, "high", 4))
-		    i->battery_status = 0;
-		else if (!strncmp(buffer + 16, "low", 3))
-		    i->battery_status = 1;
-		else if (!strncmp(buffer + 16, "crit", 4))
-		    i->battery_status = 2;
-		else if (!strncmp(buffer + 16, "charg", 5))
-		    i->battery_status = 3;
-
-		fgets(buffer, sizeof(buffer) - 1, str);
-		if (strncmp(buffer + 14, "unknown", 7))
-		    i->battery_percentage = atoi(buffer + 14);
-		if (i->apm_version_major >= 1 && i->apm_version_minor >= 1)
-		{
-		    fgets(buffer, sizeof(buffer) - 1, str);
-		    sscanf(buffer, "Battery flag: 0x%02x", &i->battery_flags);
-
-		    fgets(buffer, sizeof(buffer) - 1, str);
-		    if (strncmp(buffer + 14, "unknown", 7))
-			i->battery_time = atoi(buffer + 14);
-		}
-	    }
-	}
-#endif
-    }
-
-    /* Fix possible kernel bug -- percentage
-     * set to 0xff (==255) instead of -1.
-     */
-    if (i->battery_percentage > 100)
-	i->battery_percentage = -1;
-
-    fclose(str);
-    return retcode;
-}
-
-
-/* Lookup the device number for the apm_bios device. */
-dev_t apm_dev(void)
-{
-    FILE *str;
-    static int cached = -1;
-    char buf[80];
-    char *pt;
-    apm_info i;
-
-    if (cached >= 0)
-	return cached;
-
-    if (access(APM_PROC, R_OK) || apm_read(&i) == 1)
-	return cached = -1;
-    if (i.driver_version[0] == '1')
-	return cached = makedev(10, 134);
-
-    if (!(str = fopen(APM_DEV, "r")))
-	return -1;
-    while (fgets(buf, sizeof(buf) - 1, str))
-    {
-	buf[sizeof(buf) - 1] = '\0';
-	for (pt = buf; *pt && isspace(*pt); ++pt);	/* skip leading spaces */
-	for (; *pt && !isspace(*pt); ++pt);	/* find next space */
-	if (isspace(*pt))
-	{
-	    *pt++ = '\0';
-	    pt[strlen(pt) - 1] = '\0';	/* get rid of newline */
-	    if (!strcmp(pt, APM_NAME))
-	    {
-		fclose(str);
-		return cached = makedev(atoi(buf), 0);
-	    }
-	}
-    }
-    fclose(str);
-    return cached = -1;
-}
-
-
-/* Return a file descriptor for the apm_bios device, or -1 if there is an
- * error.  Is this method secure?  Should we make the device in /dev
- * instead of /tmp?
- *
- * apenwarr 2001/05/11: just throw out the weird temporary device file stuff.
- *	It was only for ancient kernel versions anyway.
- */
-int apm_open(void)
-{
-    int fd;
-    apm_info i;
-
-    if (access(APM_PROC, R_OK) || apm_read(&i) == 1)
-	return -1;
-    if (i.driver_version[0] >= '1')
-    {
-	if ((fd = open(APM_DEVICE, O_RDWR)) < 0)
-	{
-	    /* Try to create it.  This is reasonable
-	     * for backward compatibility.
-	     */
-	    if (mknod(APM_DEVICE, S_IFCHR | S_IRUSR | S_IWUSR, apm_dev()))
-	    {
-		unlink(APM_DEVICE);
-		return -1;
-	    }
-	    fd = open(APM_DEVICE, O_RDWR);
-	}
-
-	return fd;
-    }
-
-    return -1;
-}
-
-
-/* Given a file descriptor for the apm_bios device, close it. */
-int apm_close(int fd)
-{
-    return close(fd);
-}
-
-/* Given a file descriptor for the apm_bios device, this routine will wait
- * timeout seconds for APM events.  Up to n events will be placed in the
- * events queue.  The return code will indicate the number of events
- * stored.  Since this routine uses select(2), it will return if an
- * unblocked signal is caught.  A timeout < 0 means to block indefinately.
- *
- * Note that if you read a request to standby or to suspend, the kernel
- * will be waiting for you to respond to it with a call to apm_suspend()
- * or to apm_standby() !
- */
-int apm_get_events(int fd, int timeout, apm_event_t * events, int n)
-{
-    int retcode;
-    fd_set fds;
-    struct timeval t;
-
-    t.tv_sec = timeout;
-    t.tv_usec = 0;
-
-    FD_ZERO(&fds);
-    FD_SET(fd, &fds);
-    retcode = select(fd + 1, &fds, NULL, NULL, timeout < 0 ? NULL : &t);
-    if (retcode <= 0)
-	return 0;
-    return read(fd, events, n * sizeof(apm_event_t)) / sizeof(apm_event_t);
-}
-
-
-/* Try to set the Power State to Suspend. */
-int apm_suspend(int fd)
-{
-    sync();
-    return ioctl(fd, APM_IOC_SUSPEND, NULL);
-}
-
-
-/* Try to set the Power State to Standby. */
-int apm_standby(int fd)
-{
-    sync();
-    return ioctl(fd, APM_IOC_STANDBY, NULL);
-}
-
-/* Return the last error code generated by the kernel APM driver */
-unsigned int apm_last_error( int fd )
-{
-    int err = 0;
-
-#ifdef APM_IOC_LAST_ERROR
-    int ierr = 0;
-    if ( (ierr = ioctl( fd, APM_IOC_LAST_ERROR, &err)) )
-	return ierr;
-#endif
-    return err;
-}
-
-/* Define lookup table for error messages */
-typedef struct lookup_t {
-	int	key;
-	char *	msg;
-} lookup_t;
-
-/* APM error messages, arranged by error code */
-static const lookup_t error_table[] = {
-/* N/A	{ APM_SUCCESS,		"Operation succeeded" }, */
-	{ APM_DISABLED,		"Power management disabled" },
-	{ APM_CONNECTED,	"Real mode interface already connected" },
-	{ APM_NOT_CONNECTED,	"Interface not connected" },
-	{ APM_16_CONNECTED,	"16 bit interface already connected" },
-/* N/A	{ APM_16_UNSUPPORTED,	"16 bit interface not supported" }, */
-	{ APM_32_CONNECTED,	"32 bit interface already connected" },
-	{ APM_32_UNSUPPORTED,	"32 bit interface not supported" },
-	{ APM_BAD_DEVICE,	"Unrecognized device ID" },
-	{ APM_BAD_PARAM,	"Parameter out of range" },
-	{ APM_NOT_ENGAGED,	"Interface not engaged" },
-#ifdef APM_BAD_FUNCTION
-	{ APM_BAD_FUNCTION,     "Function not supported" },
-#endif
-#ifdef APM_RESUME_DISABLED
-	{ APM_RESUME_DISABLED,	"Resume timer disabled" },
-#endif
-	{ APM_BAD_STATE,	"Unable to enter requested state" },
-/* N/A	{ APM_NO_EVENTS,	"No events pending" }, */
-	{ APM_NOT_PRESENT,	"No APM present" }
-};
-#define ERROR_COUNT	(sizeof(error_table)/sizeof(lookup_t))
-
-/* Return character string describing error messages from APM kernel */
-const char *apm_error_name( unsigned int err )
-{
-  int i;
-
-  for(i=0; i<ERROR_COUNT; i++)
-    if(err == error_table[i].key) return(error_table[i].msg);
-
-  return "Unknown error";
-}
-
-int apm_reject( int fd )
-{
-#ifdef APM_IOC_REJECT
-    if ( ioctl( fd, APM_IOC_REJECT, NULL ) )
-	return apm_last_error( fd );
-    else
-#endif
-	return 0;
-}
-
-#ifdef APM_IOC_IGNORE		/* detect kernel support of IGNORE/NOIGNORE functions */
-int apm_set_ignore(int fd, int mode)
-/* Ignore Standby. */
-{
-    if (mode == IGNORE)
-    {
-	printf("Telling kernel to ignore system standby/suspend mode\n");
-	return ioctl(fd, APM_IOC_IGNORE, NULL);
-    }
-    else
-    {
-	printf("Telling kernel not to ignore system standby/suspend mode\n");
-	return ioctl(fd, APM_IOC_NOIGNORE, NULL);
-    }
-    printf("NOTE: User-generated suspend/standby requests are not ignored\n");
-}
-#endif
-
-/* Return a string describing the event. From p. 16 of the Intel/Microsoft
- * Advanded Power Management (APM) BIOS Interface Specification, Revision
- * 1.1 (September 1993). Intel Order Number: 241704-001.  Microsoft Part
- * Number: 781-110-X01.
- *
- * Updated to APM BIOS 1.2 spec (February 1996).  Available on-line.
- */
-const char *apm_event_name(apm_event_t event)
-{
-    switch (event)
-    {
-    case APM_SYS_STANDBY:
-	return "System Standby Request";
-    case APM_SYS_SUSPEND:
-	return "System Suspend Request";
-    case APM_NORMAL_RESUME:
-	return "Normal Resume System";
-    case APM_CRITICAL_RESUME:
-	return "Critical Resume System";
-    case APM_LOW_BATTERY:
-	return "Battery Low";
-    case APM_POWER_STATUS_CHANGE:
-	return "Power Status Change";
-    case APM_UPDATE_TIME:
-	return "Update Time";
-    case APM_CRITICAL_SUSPEND:
-	return "Critical Suspend";
-    case APM_USER_STANDBY:
-	return "User System Standby Request";
-    case APM_USER_SUSPEND:
-	return "User System Suspend Request";
-    case APM_STANDBY_RESUME:
-	return "System Standby Resume";
-#ifdef APM_CAPABILITY_CHANGE
-    case APM_CAPABILITY_CHANGE:
-	return "Capability Change";
-#endif
-    }
-    return "Unknown";
-}
-
-
-/* This is a convenience function that has nothing to do with APM.  It just
- * formats a time nicely.  If you don't like this format, then write your
- * own.
- */
-#define SEC_PER_DAY  (60*60*24)
-#define SEC_PER_HOUR (60*60)
-#define SEC_PER_MIN  (60)
-
-const char *apm_delta_time(time_t then, time_t now)
-{
-    return apm_time(now - then);
-}
-
-const char *apm_time(time_t t)
-{
-    static char buffer[128];
-    unsigned long s, m, h, d;
-
-    d = t / SEC_PER_DAY;
-    t -= d * SEC_PER_DAY;
-    h = t / SEC_PER_HOUR;
-    t -= h * SEC_PER_HOUR;
-    m = t / SEC_PER_MIN;
-    t -= m * SEC_PER_MIN;
-    s = t;
-
-    if (d)
-	sprintf(buffer, "%lu day%s, %02lu:%02lu:%02lu",
-		d, d > 1 ? "s" : "", h, m, s);
-    else
-	sprintf(buffer, "%02lu:%02lu:%02lu", h, m, s);
-
-    if (t == -1)
-	sprintf(buffer, "unknown");
-
-    return buffer;
-}
-
-const char *apm_time_nosec(time_t t)
-{
-    static char buffer[128];
-    unsigned long s, m, h, d;
-
-    d = t / SEC_PER_DAY;
-    t -= d * SEC_PER_DAY;
-    h = t / SEC_PER_HOUR;
-    t -= h * SEC_PER_HOUR;
-    m = t / SEC_PER_MIN;
-    t -= m * SEC_PER_MIN;
-    s = t;
-
-    if (s > 30)
-	++m;
-
-    if (d)
-	sprintf(buffer, "%lu day%s, %lu:%02lu",
-		d, d > 1 ? "s" : "", h, m);
-    else
-	sprintf(buffer, "%lu:%02lu", h, m);
-
-    if (t == -1)
-	sprintf(buffer, "unknown");
-
-    return buffer;
-}
-#endif
diff --git a/panel-plugin/libapm.h b/panel-plugin/libapm.h
deleted file mode 100644
index 9788bc4..0000000
--- a/panel-plugin/libapm.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* $Id$
- *
- * Copyright (c) 1996, 1997 Rickard E. Faith <faith at acm.org>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Library General Public License as published
- * by the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This library 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 Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/apm_bios.h>
-#include <sys/types.h>
-
-#define APM_PROC   "/proc/apm"
-#define APM_DEVICE "/dev/apm_bios"
-
-#define APM_DEV  "/proc/devices"
-#define APM_NAME "apm_bios"
-
-#ifndef APM_32_BIT_SUPPORT
-#define APM_32_BIT_SUPPORT      0x0002
-#endif
-
-typedef struct apm_info
-{
-    const char driver_version[10];
-    int apm_version_major;
-    int apm_version_minor;
-    int apm_flags;
-    int ac_line_status;
-    int battery_status;
-    int battery_flags;
-    int battery_percentage;
-    int battery_time;
-    int using_minutes;
-}
-apm_info;
-
-extern int apm_exists(void);
-extern int apm_read(apm_info * i);
-extern dev_t apm_dev(void);
-extern int apm_open(void);
-extern int apm_close(int fd);
-extern int apm_get_events(int fd, int timeout, apm_event_t * events, int n);
-extern int apm_suspend(int fd);
-extern int apm_standby(int fd);
-extern int apm_set_ignore(int fd, int mode);
-extern unsigned int apm_last_error(int fd);
-extern const char *apm_error_name( unsigned int err );
-extern int apm_reject(int fd);
-extern const char *apm_event_name(apm_event_t event);
-extern const char *apm_time(time_t t);
-extern const char *apm_delta_time(time_t then, time_t now);
-extern const char *apm_time_nosec(time_t t);
-
-#define SUSPEND 0
-#define STANDBY 1
-#define IGNORE 2
-#define NOIGNORE 3
-
-/* Linux Kernel APM drivers version 1.10 and higher permit suspend
-   rejections. */
-#ifdef APM_IOC_REJECT
-#define APM_REJECT_ENABLED
-#endif
diff --git a/panel-plugin/settings.ui b/panel-plugin/settings.ui
new file mode 100644
index 0000000..4bd8ae8
--- /dev/null
+++ b/panel-plugin/settings.ui
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 2.10 -->
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkVBox" id="vbox">
+    <property name="visible">True</property>
+    <property name="orientation">vertical</property>
+    <property name="spacing">4</property>
+    <child>
+      <object class="GtkCheckButton" id="show-icon">
+        <property name="label" translatable="yes">Display image</property>
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">False</property>
+        <property name="draw_indicator">True</property>
+        <signal name="toggled" handler="show_icon_toggled_cb"/>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkCheckButton" id="show-time">
+        <property name="label" translatable="yes">Display time</property>
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">False</property>
+        <property name="draw_indicator">True</property>
+        <signal name="toggled" handler="show_time_toggled_cb"/>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkCheckButton" id="show-percentage">
+        <property name="label" translatable="yes">Display percentage</property>
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">False</property>
+        <property name="draw_indicator">True</property>
+        <signal name="toggled" handler="show_percentage_toggled_cb"/>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="position">2</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkCheckButton" id="hide-percentage-time-when-full">
+        <property name="label" translatable="yes">Hide time/percentage when full</property>
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">False</property>
+        <property name="draw_indicator">True</property>
+        <signal name="toggled" handler="hide_percentage_time_when_full_toggled_cb"/>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="position">3</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/panel-plugin/battmon.desktop.in.in b/panel-plugin/xfce4-battery-plugin.desktop.in.in
similarity index 100%
rename from panel-plugin/battmon.desktop.in.in
rename to panel-plugin/xfce4-battery-plugin.desktop.in.in



More information about the Xfce4-commits mailing list