From 4bbd16182dab69da9ca7ad13309962af40529469 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Tue, 12 Jun 2012 17:49:56 +0200 Subject: add timer-applet --- timer-applet/AUTHORS | 2 + timer-applet/Makefile.am | 1 + timer-applet/data/Makefile.am | 37 + timer-applet/data/TimerApplet.server.in.in | 22 + timer-applet/data/TimerApplet.xml | 19 + timer-applet/data/timer-applet.glade | 1302 ++++++++++++++++++++ timer-applet/data/timer-applet.schemas.in | 87 ++ timer-applet/images/Makefile.am | 5 + timer-applet/images/timer-applet.png | Bin 0 -> 2820 bytes timer-applet/images/timer-applet.svg | 725 +++++++++++ timer-applet/src/Makefile.am | 6 + timer-applet/src/timer-applet | 136 ++ timer-applet/src/timerapplet/Makefile.am | 27 + timer-applet/src/timerapplet/__init__.py | 1 + timer-applet/src/timerapplet/config.py | 39 + .../timerapplet/controllers/GlobalController.py | 91 ++ .../src/timerapplet/controllers/Makefile.am | 8 + .../src/timerapplet/controllers/TimerApplet.py | 635 ++++++++++ .../timerapplet/controllers/TimerManagerService.py | 42 + .../src/timerapplet/controllers/TimerService.py | 49 + .../src/timerapplet/controllers/__init__.py | 20 + .../src/timerapplet/core/AppletMateConfWrapper.py | 89 ++ timer-applet/src/timerapplet/core/Makefile.am | 6 + timer-applet/src/timerapplet/core/PresetsStore.py | 160 +++ timer-applet/src/timerapplet/core/Timer.py | 175 +++ timer-applet/src/timerapplet/core/__init__.py | 19 + timer-applet/src/timerapplet/defs.py.in | 7 + timer-applet/src/timerapplet/logger.py | 23 + .../src/timerapplet/ui/AddEditPresetDialog.py | 75 ++ .../src/timerapplet/ui/ContinueTimerDialog.py | 63 + timer-applet/src/timerapplet/ui/DurationChooser.py | 166 +++ timer-applet/src/timerapplet/ui/Makefile.am | 15 + .../src/timerapplet/ui/ManagePresetsDialog.py | 86 ++ timer-applet/src/timerapplet/ui/Notifier.py | 73 ++ timer-applet/src/timerapplet/ui/PieMeter.py | 77 ++ .../src/timerapplet/ui/PreferencesDialog.py | 192 +++ timer-applet/src/timerapplet/ui/PulseButton.py | 69 ++ .../src/timerapplet/ui/ScrollableButtonList.py | 65 + .../src/timerapplet/ui/StartNextTimerDialog.py | 66 + .../src/timerapplet/ui/StartTimerDialog.py | 267 ++++ timer-applet/src/timerapplet/ui/StatusButton.py | 101 ++ timer-applet/src/timerapplet/ui/__init__.py | 28 + timer-applet/src/timerapplet/utils.py | 79 ++ 43 files changed, 5155 insertions(+) create mode 100644 timer-applet/AUTHORS create mode 100644 timer-applet/Makefile.am create mode 100644 timer-applet/data/Makefile.am create mode 100644 timer-applet/data/TimerApplet.server.in.in create mode 100644 timer-applet/data/TimerApplet.xml create mode 100644 timer-applet/data/timer-applet.glade create mode 100644 timer-applet/data/timer-applet.schemas.in create mode 100644 timer-applet/images/Makefile.am create mode 100644 timer-applet/images/timer-applet.png create mode 100644 timer-applet/images/timer-applet.svg create mode 100644 timer-applet/src/Makefile.am create mode 100755 timer-applet/src/timer-applet create mode 100644 timer-applet/src/timerapplet/Makefile.am create mode 100644 timer-applet/src/timerapplet/__init__.py create mode 100644 timer-applet/src/timerapplet/config.py create mode 100644 timer-applet/src/timerapplet/controllers/GlobalController.py create mode 100644 timer-applet/src/timerapplet/controllers/Makefile.am create mode 100644 timer-applet/src/timerapplet/controllers/TimerApplet.py create mode 100644 timer-applet/src/timerapplet/controllers/TimerManagerService.py create mode 100644 timer-applet/src/timerapplet/controllers/TimerService.py create mode 100644 timer-applet/src/timerapplet/controllers/__init__.py create mode 100644 timer-applet/src/timerapplet/core/AppletMateConfWrapper.py create mode 100644 timer-applet/src/timerapplet/core/Makefile.am create mode 100644 timer-applet/src/timerapplet/core/PresetsStore.py create mode 100644 timer-applet/src/timerapplet/core/Timer.py create mode 100644 timer-applet/src/timerapplet/core/__init__.py create mode 100644 timer-applet/src/timerapplet/defs.py.in create mode 100644 timer-applet/src/timerapplet/logger.py create mode 100644 timer-applet/src/timerapplet/ui/AddEditPresetDialog.py create mode 100644 timer-applet/src/timerapplet/ui/ContinueTimerDialog.py create mode 100644 timer-applet/src/timerapplet/ui/DurationChooser.py create mode 100644 timer-applet/src/timerapplet/ui/Makefile.am create mode 100644 timer-applet/src/timerapplet/ui/ManagePresetsDialog.py create mode 100644 timer-applet/src/timerapplet/ui/Notifier.py create mode 100644 timer-applet/src/timerapplet/ui/PieMeter.py create mode 100644 timer-applet/src/timerapplet/ui/PreferencesDialog.py create mode 100644 timer-applet/src/timerapplet/ui/PulseButton.py create mode 100644 timer-applet/src/timerapplet/ui/ScrollableButtonList.py create mode 100644 timer-applet/src/timerapplet/ui/StartNextTimerDialog.py create mode 100644 timer-applet/src/timerapplet/ui/StartTimerDialog.py create mode 100644 timer-applet/src/timerapplet/ui/StatusButton.py create mode 100644 timer-applet/src/timerapplet/ui/__init__.py create mode 100644 timer-applet/src/timerapplet/utils.py (limited to 'timer-applet') diff --git a/timer-applet/AUTHORS b/timer-applet/AUTHORS new file mode 100644 index 00000000..a12bc88c --- /dev/null +++ b/timer-applet/AUTHORS @@ -0,0 +1,2 @@ +Jimmy Do +Stefano Karapetsas diff --git a/timer-applet/Makefile.am b/timer-applet/Makefile.am new file mode 100644 index 00000000..106cc3f9 --- /dev/null +++ b/timer-applet/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = data images src diff --git a/timer-applet/data/Makefile.am b/timer-applet/data/Makefile.am new file mode 100644 index 00000000..043616ad --- /dev/null +++ b/timer-applet/data/Makefile.am @@ -0,0 +1,37 @@ +serverdir = $(libdir)/matecomponent/servers +server_in_files = TimerApplet.server.in +server_DATA = $(server_in_files:.server.in=.server) + +$(server_in_files): $(server_in_files:.server.in=.server.in.in) Makefile + sed -e "s|\@LIBEXECDIR\@|$(pkglibdir)|" $< > $@ + +schemasdir = $(MATECONF_SCHEMA_FILE_DIR) +schemas_in_files = timer-applet.schemas.in +schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) + +pkgdata_DATA = \ + TimerApplet.xml \ + timer-applet.glade + +EXTRA_DIST = \ + TimerApplet.server.in.in \ + $(pkgdata_DATA) \ + $(schemas_in_files) + +CLEANFILES = \ + $(server_DATA) \ + $(server_in_files) \ + $(schemas_DATA) + +@INTLTOOL_SERVER_RULE@ +@INTLTOOL_SCHEMAS_RULE@ + +if MATECONF_SCHEMAS_INSTALL +install-data-local: + MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) \ + $(MATECONFTOOL) --makefile-install-rule $(schemas_DATA) + +uninstall-local: + MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) \ + $(MATECONFTOOL) --makefile-uninstall-rule $(schemas_DATA) +endif diff --git a/timer-applet/data/TimerApplet.server.in.in b/timer-applet/data/TimerApplet.server.in.in new file mode 100644 index 00000000..5c7a826d --- /dev/null +++ b/timer-applet/data/TimerApplet.server.in.in @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/timer-applet/data/TimerApplet.xml b/timer-applet/data/TimerApplet.xml new file mode 100644 index 00000000..67df361c --- /dev/null +++ b/timer-applet/data/TimerApplet.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/timer-applet/data/timer-applet.glade b/timer-applet/data/timer-applet.glade new file mode 100644 index 00000000..2ac443e6 --- /dev/null +++ b/timer-applet/data/timer-applet.glade @@ -0,0 +1,1302 @@ + + + + + + Start Timer + dialog + False + + + True + + + True + 12 + + + True + 6 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + + + + False + False + 0 + + + + + True + 6 + + + True + 0 + _Name: + True + name_entry + + + False + False + 0 + + + + + True + True + True + + + 1 + + + + + False + False + 1 + + + + + True + True + + + True + + + True + 0 + none + + + True + 12 + + + True + + + True + 2 + + + True + + + 3 + + + + + Start automatically + True + False + True + False + True + + + 1 + 2 + 3 + + + + + 0 + + + + + + + + + True + <b>Define next timer</b> + True + + + label_item + + + + + 0 + + + + + True + 0 + none + + + True + 12 + + + True + 3 + + + 50 + True + True + 5 + Execute: + + + 0 + + + + + True + True + + + + 5 + 1 + + + + + + + + + True + <b>Run custom command</b> + True + + + label_item + + + + + 1 + + + + + True + True + True + + + 2 + + + + + + + True + Run executable after timer finished. + Advanced + + + label_item + + + + + 2 + + + + + True + end + + + S_ave as Preset + True + True + True + False + True + + + False + False + 0 + + + + + False + False + 3 + + + + + False + False + 0 + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + none + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 6 + + + True + + + + + + 0 + + + + + Mana_ge Presets + True + True + False + True + + + False + False + 1 + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + <b>_Presets</b> + True + True + + + label_item + + + + + 2 + + + + + 1 + + + + + True + end + + + gtk-cancel + -6 + True + True + True + False + True + + + False + False + 0 + + + + + S_tart Timer + -5 + True + True + True + False + True + + + False + False + 1 + + + + + False + False + end + 0 + + + + + + + Manage Presets + dialog + False + + + True + + + True + 12 + 0 + none + + + True + 12 + + + True + 6 + + + True + True + never + automatic + in + + + True + True + False + + + + + 0 + + + + + True + 6 + + + _Delete + True + True + False + True + + + 0 + + + + + _Edit... + True + True + False + True + + + 1 + + + + + _Add... + True + True + False + True + + + 2 + + + + + False + False + 1 + + + + + + + + + True + <b>_Presets</b> + True + True + + + label_item + + + + + 1 + + + + + True + end + + + gtk-close + -7 + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + + Timer Preferences + 189 + dialog + False + + + True + + + True + 12 + + + _Show remaining time while timer is running + True + True + False + True + True + + + False + False + 0 + + + + + True + + + _Play notification sound + True + True + False + True + True + + + False + False + 0 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + + + True + + + Use d_efault sound + True + True + False + True + True + + + False + False + 0 + + + + + True + + + Use c_ustom sound + True + True + False + True + True + use_default_sound_radio + + + False + False + 0 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Choose A Sound File + + + + + False + False + 1 + + + + + False + False + 1 + + + + + + + 0 + + + + + False + False + 1 + + + + + False + False + 1 + + + + + _Show popup notification + True + True + False + _Show popup notification after timer has ended. + True + True + + + False + False + 2 + + + + + S_how pulsing panel icon + True + True + False + Show pulsing panel icon after timer has ended. + True + True + + + False + False + 3 + + + + + 1 + + + + + True + end + + + gtk-close + -7 + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + + Add Preset + dialog + False + + + True + + + True + 12 + + + True + 0 + none + + + True + 12 + 12 + + + True + True + True + + + + + + + True + <b>_Name</b> + True + True + + + label_item + + + + + False + False + 0 + + + + + True + 0 + none + + + True + 12 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + + + + + + + + True + <b>_Duration</b> + True + True + + + label_item + + + + + 1 + + + + + True + 0 + none + + + True + 12 + 12 + + + True + True + + + + + + + True + Run custom command after timer has ended. + <b>Custom command</b> + True + + + label_item + + + + + 2 + + + + + True + 0 + none + + + True + 12 + 12 + + + True + + + True + True + + + 0 + + + + + Initiate automatically + True + True + False + True + + + 1 + + + + + + + + + True + <b>Interval timer</b> + True + + + label_item + + + + + 3 + + + + + 1 + + + + + True + end + + + gtk-cancel + -6 + True + True + True + False + True + + + False + False + 0 + + + + + gtk-save + -5 + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + + center + normal + Copyright (c) 2010 by Kenny Meyer. +Copyright (c) 2007 by Jimmy Do + A timer applet for the perfect egg and beyond! + https://launchpad.net/timer-applet + Timer Applet + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 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. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, 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 software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, 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 redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +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 give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) 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; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, 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 executable. 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. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. 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 Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program 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. + + 7. 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 Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geomraphical 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. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 Program +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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + Jimmy Do <jimmydo@users.sourceforge.net> + + + True + + + + + + True + + + False + end + 0 + + + + + + diff --git a/timer-applet/data/timer-applet.schemas.in b/timer-applet/data/timer-applet.schemas.in new file mode 100644 index 00000000..eadc902a --- /dev/null +++ b/timer-applet/data/timer-applet.schemas.in @@ -0,0 +1,87 @@ + + + + /schemas/apps/timer-applet/prefs/play_notification_sound + /apps/timer-applet/prefs/play_notification_sound + timer-applet + bool + false + + Play notification sound + Play a notification sound when the timer finishes a countdown + + + + + /schemas/apps/timer-applet/prefs/use_custom_notification_sound + /apps/timer-applet/prefs/use_custom_notification_sound + timer-applet + bool + false + + Use a custom notification sound + Use the custom notification sound specified in custom_notification_sound_path + + + + + /schemas/apps/timer-applet/prefs/custom_notification_sound_path + /apps/timer-applet/prefs/custom_notification_sound_path + timer-applet + string + + + Path to a custom notification sound + Path to a sound file that will be played when the timer finishes a countdown + + + + + /schemas/apps/timer-applet/prefs/show_pulsing_icon + /apps/timer-applet/prefs/show_pulsing_icon + timer-applet + bool + true + + Show Pulsing icon + Show pulsing tray icon when timer finished + + + + + /schemas/apps/timer-applet/prefs/show_popup_notification + /apps/timer-applet/prefs/show_popup_notification + timer-applet + bool + true + + Show Popup notification + Show Popup notification in the notification area + + + + + /schemas/apps/timer-applet/prefs/show_remaining_time + /apps/timer-applet/prefs/show_remaining_time + timer-applet + bool + true + + Show remaining time + Show the remaining time while the timer is running or paused + + + + + /schemas/apps/timer-applet/prefs/play_beep + /apps/timer-applet/prefs/play_beep + timer-applet + bool + false + + Play a beep sound + Play a beep sound on a computer's internal speaker when the timer finishes. This may not have an effect on all computers. + + + + diff --git a/timer-applet/images/Makefile.am b/timer-applet/images/Makefile.am new file mode 100644 index 00000000..fd039a73 --- /dev/null +++ b/timer-applet/images/Makefile.am @@ -0,0 +1,5 @@ +icondir = $(datadir)/pixmaps +icon_DATA = timer-applet.png + +EXTRA_DIST = $(icon_DATA) + diff --git a/timer-applet/images/timer-applet.png b/timer-applet/images/timer-applet.png new file mode 100644 index 00000000..cb54c3c6 Binary files /dev/null and b/timer-applet/images/timer-applet.png differ diff --git a/timer-applet/images/timer-applet.svg b/timer-applet/images/timer-applet.svg new file mode 100644 index 00000000..8378578e --- /dev/null +++ b/timer-applet/images/timer-applet.svg @@ -0,0 +1,725 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/timer-applet/src/Makefile.am b/timer-applet/src/Makefile.am new file mode 100644 index 00000000..d266f640 --- /dev/null +++ b/timer-applet/src/Makefile.am @@ -0,0 +1,6 @@ +SUBDIRS = timerapplet + +libexec_SCRIPTS = timer-applet + +EXTRA_DIST = \ + timer-applet diff --git a/timer-applet/src/timer-applet b/timer-applet/src/timer-applet new file mode 100755 index 00000000..cd550fbb --- /dev/null +++ b/timer-applet/src/timer-applet @@ -0,0 +1,136 @@ +#!/usr/bin/env python +# Copyright (C) 2010 Kenny Meyer +# Copyright (C) 2008 Jimmy Do +# +# 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 + +from os import path +import gettext +import locale +import sys +import gtk +import mateapplet +from timerapplet import config +from timerapplet.controllers import GlobalController, TimerApplet, TimerService, TimerManagerService +from timerapplet.core import AppletMateConfWrapper, Timer + +from dbus.mainloop.glib import DBusGMainLoop +DBusGMainLoop(set_as_default=True) + +DBUS_BUS_NAME = 'net.launchpad.timerapplet.TimerApplet' +DBUS_OBJ_NAMESPACE = '/net/launchpad/timerapplet/TimerApplet' + +gettext.bindtextdomain(config.GETTEXT_PACKAGE, config.LOCALE_DIR) +gettext.bind_textdomain_codeset(config.GETTEXT_PACKAGE, 'UTF-8') +gettext.textdomain(config.GETTEXT_PACKAGE) +locale.bindtextdomain(config.GETTEXT_PACKAGE, config.LOCALE_DIR) +locale.bind_textdomain_codeset(config.GETTEXT_PACKAGE, 'UTF-8') +locale.textdomain(config.GETTEXT_PACKAGE) + +global_controller = GlobalController() +timer_manager_obj_path = path.join(DBUS_OBJ_NAMESPACE, 'TimerManager') +print 'Timer Manager D-Bus object path: %s' % timer_manager_obj_path + +timer_manager = None +try: + timer_manager = TimerManagerService(DBUS_BUS_NAME, timer_manager_obj_path) +except Exception, err: + print 'ERROR: Could not start TimerManagerService. D-Bus support will not be available. Error message: %s' % err + +def check_dependencies(): + # Check for optional dependencies + try: + import dbus # >= 0.80 + except ImportError, err: + print 'Missing optional dependency: %s' % err + + # Check for required dependencies + try: + import gobject # >= 2.12 + import gtk # >= 2.10, includes pango + import gtk.glade # >= 2.10 + import mateconf # >= 2.18 + import mate # >= 2.18, includes matecomponent.ui + import mateapplet # >= 2.18, included in python-mate2-desktop + import pynotify # >= 0.1.1 + except ImportError, err: + dialog = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, + buttons=gtk.BUTTONS_CLOSE, + message_format='%s\n\nPlease install required dependencies.' % err) + dialog.run() + dialog.destroy() + sys.exit(1) + +def get_timer_id(mateconf_wrapper): + path_components = mateconf_wrapper.get_base_path().split('/') + + # Use the second component from the end, which should usually be 'applet_*', + # where '*' is some integer assigned by the system. + # It could also be 'timer-applet' if we're running in standalone mode. + # D-Bus doesn't like hyphens in object paths, so we have to replace them + # with underscores. + return path_components[-2].replace('-', '_') + +def applet_factory(applet, iid): + check_dependencies() + + timer = Timer() + mateconf_wrapper = AppletMateConfWrapper(applet, + '/schemas/apps/timer-applet/prefs', + '/apps/timer-applet/prefs') + timer_id = get_timer_id(mateconf_wrapper) + print 'Timer ID: %s' % timer_id + + if timer_manager is not None: + timer_manager.register_timer_id(timer_id) + applet.connect('destroy', lambda sender: timer_manager.unregister_timer_id(timer_id)) + + TimerApplet(global_controller.get_presets_store(), + global_controller.get_manage_presets_dialog(), + applet, + timer, + mateconf_wrapper) + + timer_obj_path = path.join(DBUS_OBJ_NAMESPACE, 'Timers', timer_id) + print 'Timer D-Bus object path: %s' % timer_obj_path + + try: + TimerService(DBUS_BUS_NAME, timer_obj_path, timer) + except Exception, err: + print 'ERROR: Could not start TimerService. D-Bus support will not be available. Error message: %s' % err + + return True + +if __name__ == '__main__': + windowed_mode = (len(sys.argv) > 1 and sys.argv[1] == '-w') + + if windowed_mode: + win = gtk.Window() + win.set_title('Timer Applet') + applet = mateapplet.Applet() + applet_factory(applet, None) + applet.reparent(win) + + applet.connect('destroy', gtk.main_quit) + win.show() + + gtk.main() + else: + mateapplet.matecomponent_factory( + 'OAFIID:TimerApplet_Factory', + mateapplet.Applet.__gtype__, + config.PACKAGE, + config.VERSION, + applet_factory) diff --git a/timer-applet/src/timerapplet/Makefile.am b/timer-applet/src/timerapplet/Makefile.am new file mode 100644 index 00000000..08f474c0 --- /dev/null +++ b/timer-applet/src/timerapplet/Makefile.am @@ -0,0 +1,27 @@ +SUBDIRS = controllers core ui + +defs.py: defs.py.in Makefile + sed -e "s|\@PACKAGE\@|$(PACKAGE)|" \ + -e "s|\@VERSION\@|$(VERSION)|" \ + -e "s|\@RESOURCESDIR\@|$(pkgdatadir)|" \ + -e "s|\@IMAGESDIR\@|$(datadir)/pixmaps|" \ + -e "s|\@LOCALEDIR\@|$(localedir)|" \ + -e "s|\@GETTEXT_PACKAGE\@|$(GETTEXT_PACKAGE)|" $< > $@ + +EXTRA_DIST = \ + defs.py.in + +CLEANFILES = \ + defs.py + +# Need this so that defs.py is actually created after cleaning. +BUILT_SOURCES = defs.py + +moduledir = $(pythondir)/timerapplet +module_PYTHON = \ + __init__.py \ + config.py \ + defs.py \ + utils.py \ + logger.py + diff --git a/timer-applet/src/timerapplet/__init__.py b/timer-applet/src/timerapplet/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/timer-applet/src/timerapplet/__init__.py @@ -0,0 +1 @@ + diff --git a/timer-applet/src/timerapplet/config.py b/timer-applet/src/timerapplet/config.py new file mode 100644 index 00000000..ca8a4f9d --- /dev/null +++ b/timer-applet/src/timerapplet/config.py @@ -0,0 +1,39 @@ +# Copyright (C) 2008 Jimmy Do +# +# 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 + +import os.path as path + +try: + from defs import * +except ImportError: + PACKAGE = 'timer-applet' + VERSION = '0' + GETTEXT_PACKAGE = '' + LOCALE_DIR = '' + RESOURCES_DIR = path.join(path.dirname(__file__), '../../data') + IMAGES_DIR = path.join(path.dirname(__file__), '../../images') + +print 'Using these definitions:' +print 'GETTEXT_PACKAGE: %s' % GETTEXT_PACKAGE +print 'LOCALE_DIR: %s' % LOCALE_DIR +print 'RESOURCES_DIR: %s' % RESOURCES_DIR +print 'IMAGES_DIR: %s' % IMAGES_DIR + +GLADE_PATH = path.join(RESOURCES_DIR, 'timer-applet.glade') +POPUP_MENU_FILE_PATH = path.join(RESOURCES_DIR, 'TimerApplet.xml') +ICON_PATH = path.join(IMAGES_DIR, 'timer-applet.png') +PRESETS_PATH = path.expanduser('~/.config/mate/timer-applet/presets.xml') +DEFAULT_SOUND_PATH = '/usr/share/sounds/gtk-events/clicked.wav' diff --git a/timer-applet/src/timerapplet/controllers/GlobalController.py b/timer-applet/src/timerapplet/controllers/GlobalController.py new file mode 100644 index 00000000..860573a6 --- /dev/null +++ b/timer-applet/src/timerapplet/controllers/GlobalController.py @@ -0,0 +1,91 @@ +# Copyright (C) 2008 Jimmy Do +# +# 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 + +from gettext import gettext as _ +import gtk +from timerapplet import core +from timerapplet import ui +from timerapplet import utils +from timerapplet import config + +class GlobalController(object): + def __init__(self): + self._presets_store = core.PresetsStore(config.PRESETS_PATH) + self._manage_presets_dialog = ui.ManagePresetsDialog(config.GLADE_PATH, + self._presets_store.get_model(), + lambda row_iter: utils.get_preset_display_text(self._presets_store, + row_iter)) + + self._manage_presets_dialog.connect('clicked-add', self._on_mgr_clicked_add) + self._manage_presets_dialog.connect('clicked-edit', self._on_mgr_clicked_edit) + self._manage_presets_dialog.connect('clicked-remove', self._on_mgr_clicked_remove) + + gtk.window_set_default_icon_from_file(config.ICON_PATH) + + def get_presets_store(self): + return self._presets_store + + def get_manage_presets_dialog(self): + return self._manage_presets_dialog + + def _on_mgr_clicked_add(self, sender, data=None): + add_dialog = ui.AddEditPresetDialog( + config.GLADE_PATH, + _('Add Preset'), + lambda name: utils.is_valid_preset_name(name, self._presets_store)) + + result = add_dialog.get_preset() + if result is not None: + (name, hours, minutes, seconds, command, next_timer, auto_start) = result + self._presets_store.add_preset(name, hours, minutes, seconds, + command, next_timer, auto_start) + + def _on_mgr_clicked_edit(self, sender, row_path, data=None): + row_iter = self._presets_store.get_model().get_iter(row_path) + (name, hours, minutes, seconds, command, next_timer, auto_start) = \ + self._presets_store.get_preset(row_iter) + + edit_dialog = ui.AddEditPresetDialog(config.GLADE_PATH, + _('Edit Preset'), + lambda name: utils.is_valid_preset_name(name, + self._presets_store, + (name,)), + name, + hours, + minutes, + seconds, + command, + next_timer, + auto_start + ) + + result = edit_dialog.get_preset() + if result is not None: + (name, hours, minutes, seconds, command, next_timer, auto_start) = result + self._presets_store.modify_preset(row_iter, name, hours, minutes, + seconds, command, next_timer, + auto_start) + + def _on_mgr_clicked_remove(self, sender, row_path, data=None): + row_iter = self._presets_store.get_model().get_iter(row_path) + self._presets_store.remove_preset(row_iter) + + # TODO + def _on_mgr_next_timer_is_being_edited(self, sender, row_path, data=None): + """Show a dropdown widget to help completing the next timer.""" + raise NotImplementedError("Not implemented, yet") + + diff --git a/timer-applet/src/timerapplet/controllers/Makefile.am b/timer-applet/src/timerapplet/controllers/Makefile.am new file mode 100644 index 00000000..bb5018d6 --- /dev/null +++ b/timer-applet/src/timerapplet/controllers/Makefile.am @@ -0,0 +1,8 @@ +moduledir = $(pythondir)/timerapplet/controllers +module_PYTHON = \ + __init__.py \ + GlobalController.py \ + TimerApplet.py \ + TimerManagerService.py \ + TimerService.py + diff --git a/timer-applet/src/timerapplet/controllers/TimerApplet.py b/timer-applet/src/timerapplet/controllers/TimerApplet.py new file mode 100644 index 00000000..3c53754a --- /dev/null +++ b/timer-applet/src/timerapplet/controllers/TimerApplet.py @@ -0,0 +1,635 @@ +# Copyright (C) 2008 Jimmy Do +# Copyright (C) 2010 Kenny Meyer +# +# 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 + +from gettext import gettext as _ +from gettext import ngettext +from datetime import datetime, timedelta +import mateapplet +import gst +import gtk +import gtk.glade as glade +import gtk.gdk as gdk +import subprocess +import shlex +import threading +from timerapplet import config +from timerapplet import core +from timerapplet import ui +from timerapplet import utils + +def on_widget_button_press_event(sender, event, data=None): + if event.button != 1: + sender.emit_stop_by_name('button-press-event') + return False + +def force_no_focus_padding(widget): + gtk.rc_parse_string('\n' + ' style "timer-applet-button-style"\n' + ' {\n' + ' GtkWidget::focus-line-width=0\n' + ' GtkWidget::focus-padding=0\n' + ' }\n' + '\n' + ' widget "*.timer-applet-button" style "timer-applet-button-style"\n' + '\n') + widget.set_name('timer-applet-button') + +class TimerApplet(object): + # MateConf key identifiers + ## You can find Timer Applet's schemas file in data/timer-applet.schemas.in + _SHOW_REMAINING_TIME_KEY = 'show_remaining_time' + _PLAY_SOUND_KEY = 'play_notification_sound' + _USE_CUSTOM_SOUND_KEY = 'use_custom_notification_sound' + _SHOW_POPUP_NOTIFICATION_KEY = 'show_popup_notification' + _SHOW_PULSING_ICON_KEY = 'show_pulsing_icon' + _CUSTOM_SOUND_PATH_KEY = 'custom_notification_sound_path' + + _PRESETS_PLACEHOLDER_NAME = 'Placeholder' + _PRESETS_PLACEHOLDER_PATH = '/popups/popup/Presets/' + _PRESETS_PLACEHOLDER_NAME + _PRESETS_PATH = '/popups/popup/Presets' + + def __init__(self, presets_store, manage_presets_dialog, applet, timer, mateconf_wrapper): + self._presets_store = presets_store + self._manage_presets_dialog = manage_presets_dialog + self._applet = applet + self._timer = timer + + self._gst_playbin = gst.element_factory_make('playbin', 'player') + def bus_event(bus, message): + t = message.type + if t == gst.MESSAGE_EOS: + self._gst_playbin.set_state(gst.STATE_NULL) + elif t == gst.MESSAGE_ERROR: + self._gst_playbin.set_state(gst.STATE_NULL) + err, debug = message.parse_error() + print 'Error playing sound: %s' % err, debug + return True + self._gst_playbin.get_bus().add_watch(bus_event) + + self._status_button = ui.StatusButton() + self._notifier = ui.Notifier('TimerApplet', gtk.STOCK_DIALOG_INFO, self._status_button) + self._start_next_timer_dialog = ui.StartNextTimerDialog( + config.GLADE_PATH, + "Start next timer", + "Would you like to start the next timer?") + self._start_timer_dialog = ui.StartTimerDialog(config.GLADE_PATH, + lambda name: utils.is_valid_preset_name(name, + self._presets_store), + self._presets_store.get_model(), + lambda row_iter: utils.get_preset_display_text(self._presets_store, + row_iter)) + self._continue_dialog = ui.ContinueTimerDialog(config.GLADE_PATH, + _('Continue timer countdown?'), + _('The timer is currently paused. Would you like to continue countdown?')) + self._preferences_dialog = ui.PreferencesDialog(config.GLADE_PATH) + self._mateconf = mateconf_wrapper + + self._about_dialog = glade.XML(config.GLADE_PATH, 'about_dialog').get_widget('about_dialog') + self._about_dialog.set_version(config.VERSION) + + self._applet.set_applet_flags(mateapplet.EXPAND_MINOR) + self._applet.setup_menu_from_file( + None, + config.POPUP_MENU_FILE_PATH, + None, + [('PauseTimer', lambda component, verb: self._timer.stop()), + ('ContinueTimer', lambda component, verb: self._timer.start()), + ('StopTimer', lambda component, verb: self._timer.reset()), + ('RestartTimer', lambda component, verb: self._restart_timer()), + ('StartNextTimer', lambda component, verb: self._start_next_timer()), + ('ManagePresets', lambda component, verb: self._manage_presets_dialog.show()), + ('Preferences', lambda component, + verb: self._preferences_dialog.show()), + ('About', lambda component, verb: self._about_dialog.show())] + ) + self._applet.add(self._status_button) + + # Remove padding around button contents. + force_no_focus_padding(self._status_button) + + # TODO: + # Fix bug in which button would not propogate middle-clicks + # and right-clicks to the applet. + self._status_button.connect('button-press-event', on_widget_button_press_event) + + self._status_button.set_relief(gtk.RELIEF_NONE) + self._status_button.set_icon(config.ICON_PATH); + + self._connect_signals() + self._update_status_button() + self._update_popup_menu() + self._update_preferences_dialog() + self._status_button.show() + self._applet.show() + + def _connect_signals(self): + self._applet.connect('change-orient', lambda applet, orientation: self._update_status_button()) + self._applet.connect('change-size', lambda applet, size: self._update_status_button()) + self._applet.connect('change-background', self._on_applet_change_background) + self._applet.connect('destroy', self._on_applet_destroy) + + self._presets_store.get_model().connect('row-deleted', + lambda model, + row_path: self._update_popup_menu()) + self._presets_store.get_model().connect('row-changed', + lambda model, + row_path, + row_iter: self._update_popup_menu()) + + self._timer.connect('time-changed', self._on_timer_time_changed) + self._timer.connect('state-changed', self._on_timer_state_changed) + self._status_button.connect('clicked', self._on_status_button_clicked) + self._start_timer_dialog.connect('clicked-start', + self._on_start_dialog_clicked_start) + self._start_timer_dialog.connect('clicked-manage-presets', + self._on_start_dialog_clicked_manage_presets) + self._start_timer_dialog.connect('clicked-save', + self._on_start_dialog_clicked_save) + self._start_timer_dialog.connect('clicked-preset', + self._on_start_dialog_clicked_preset) + self._start_timer_dialog.connect('double-clicked-preset', + self._on_start_dialog_double_clicked_preset) + + self._preferences_dialog.connect('show-remaining-time-changed', self._on_prefs_show_time_changed) + self._preferences_dialog.connect('play-sound-changed', self._on_prefs_play_sound_changed) + self._preferences_dialog.connect('use-custom-sound-changed', self._on_prefs_use_custom_sound_changed) + self._preferences_dialog.connect('show-popup-notification-changed', self._on_prefs_show_popup_notification_changed) + self._preferences_dialog.connect('show-pulsing-icon-changed', self._on_prefs_show_pulsing_icon_changed) + self._preferences_dialog.connect('custom-sound-path-changed', self._on_prefs_custom_sound_path_changed) + + self._about_dialog.connect('delete-event', gtk.Widget.hide_on_delete) + self._about_dialog.connect('response', lambda dialog, response_id: self._about_dialog.hide()) + + self._mateconf.add_notification(TimerApplet._SHOW_REMAINING_TIME_KEY, self._on_mateconf_changed) + self._mateconf.add_notification(TimerApplet._PLAY_SOUND_KEY, self._on_mateconf_changed) + self._mateconf.add_notification(TimerApplet._USE_CUSTOM_SOUND_KEY, self._on_mateconf_changed) + self._mateconf.add_notification(TimerApplet._SHOW_PULSING_ICON_KEY, self._on_mateconf_changed) + self._mateconf.add_notification(TimerApplet._SHOW_POPUP_NOTIFICATION_KEY, self._on_mateconf_changed) + self._mateconf.add_notification(TimerApplet._CUSTOM_SOUND_PATH_KEY, self._on_mateconf_changed) + + ## Private methods for updating UI ## + + def _update_status_button(self): + current_state = self._timer.get_state() + if current_state == core.Timer.STATE_IDLE: + print 'Idle' + # This label text should not be visible because the label + # is hidden when the timer is idle. + self._status_button.set_label('--:--:--') + self._status_button.set_tooltip(_('Click to start a new timer countdown.')) + elif current_state == core.Timer.STATE_RUNNING: + print 'Running' + elif current_state == core.Timer.STATE_PAUSED: + print 'Paused' + self._status_button.set_tooltip(_('Paused. Click to continue timer countdown.')) + elif current_state == core.Timer.STATE_FINISHED: + print 'Finished' + self._status_button.set_label(_('Finished')) + name_str = self._timer.get_name() + time_str = utils.get_display_text_from_datetime(self._timer.get_end_time()) + if len(name_str) > 0: + # "" finished at