aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS2
-rw-r--r--COPYING674
-rw-r--r--ChangeLog2
-rw-r--r--Makefile.am37
-rw-r--r--NEWS0
-rw-r--r--README0
-rwxr-xr-xautogen.sh11
-rw-r--r--configure.ac260
-rw-r--r--data/Makefile.am26
-rw-r--r--data/com.canonical.indicator.datetime.gschema.xml111
-rw-r--r--data/datetime-dialog.ui774
-rw-r--r--data/indicator-datetime-preferences.desktop.in14
-rw-r--r--data/indicator-datetime.service.in3
-rw-r--r--libmap/Makefile.am77
-rw-r--r--libmap/README5
-rw-r--r--libmap/backward118
-rw-r--r--libmap/cc-timezone-map.c1195
-rw-r--r--libmap/cc-timezone-map.h85
-rw-r--r--libmap/data/bg.pngbin0 -> 213448 bytes
-rw-r--r--libmap/data/cc.pngbin0 -> 53948 bytes
-rw-r--r--libmap/data/olsen_map.pngbin0 -> 54969 bytes
-rw-r--r--libmap/data/pin.pngbin0 -> 561 bytes
-rw-r--r--libmap/data/timezone_-1.pngbin0 -> 8012 bytes
-rw-r--r--libmap/data/timezone_-10.pngbin0 -> 7783 bytes
-rw-r--r--libmap/data/timezone_-11.pngbin0 -> 7406 bytes
-rw-r--r--libmap/data/timezone_-2.pngbin0 -> 4333 bytes
-rw-r--r--libmap/data/timezone_-3.5.pngbin0 -> 740 bytes
-rw-r--r--libmap/data/timezone_-3.pngbin0 -> 13615 bytes
-rw-r--r--libmap/data/timezone_-4.5.pngbin0 -> 1900 bytes
-rw-r--r--libmap/data/timezone_-4.pngbin0 -> 15084 bytes
-rw-r--r--libmap/data/timezone_-5.5.pngbin0 -> 437 bytes
-rw-r--r--libmap/data/timezone_-5.pngbin0 -> 19166 bytes
-rw-r--r--libmap/data/timezone_-6.pngbin0 -> 13764 bytes
-rw-r--r--libmap/data/timezone_-7.pngbin0 -> 11977 bytes
-rw-r--r--libmap/data/timezone_-8.pngbin0 -> 6801 bytes
-rw-r--r--libmap/data/timezone_-9.5.pngbin0 -> 437 bytes
-rw-r--r--libmap/data/timezone_-9.pngbin0 -> 7908 bytes
-rw-r--r--libmap/data/timezone_0.pngbin0 -> 11074 bytes
-rw-r--r--libmap/data/timezone_1.pngbin0 -> 15458 bytes
-rw-r--r--libmap/data/timezone_10.5.pngbin0 -> 421 bytes
-rw-r--r--libmap/data/timezone_10.pngbin0 -> 12829 bytes
-rw-r--r--libmap/data/timezone_11.5.pngbin0 -> 446 bytes
-rw-r--r--libmap/data/timezone_11.pngbin0 -> 12113 bytes
-rw-r--r--libmap/data/timezone_12.75.pngbin0 -> 409 bytes
-rw-r--r--libmap/data/timezone_12.pngbin0 -> 7130 bytes
-rw-r--r--libmap/data/timezone_13.pngbin0 -> 621 bytes
-rw-r--r--libmap/data/timezone_2.pngbin0 -> 12854 bytes
-rw-r--r--libmap/data/timezone_3.5.pngbin0 -> 2142 bytes
-rw-r--r--libmap/data/timezone_3.pngbin0 -> 17475 bytes
-rw-r--r--libmap/data/timezone_4.5.pngbin0 -> 1773 bytes
-rw-r--r--libmap/data/timezone_4.pngbin0 -> 4954 bytes
-rw-r--r--libmap/data/timezone_5.5.pngbin0 -> 6099 bytes
-rw-r--r--libmap/data/timezone_5.75.pngbin0 -> 2885 bytes
-rw-r--r--libmap/data/timezone_5.pngbin0 -> 14539 bytes
-rw-r--r--libmap/data/timezone_6.5.pngbin0 -> 1609 bytes
-rw-r--r--libmap/data/timezone_6.pngbin0 -> 8441 bytes
-rw-r--r--libmap/data/timezone_7.pngbin0 -> 14412 bytes
-rw-r--r--libmap/data/timezone_8.pngbin0 -> 16725 bytes
-rw-r--r--libmap/data/timezone_9.5.pngbin0 -> 1959 bytes
-rw-r--r--libmap/data/timezone_9.pngbin0 -> 12608 bytes
-rw-r--r--libmap/test-timezone.c56
-rw-r--r--libmap/tz.c399
-rw-r--r--libmap/tz.h86
-rw-r--r--po/LINGUAS31
-rw-r--r--po/Makevars7
-rw-r--r--po/POTFILES.in8
-rw-r--r--po/ar.po44
-rw-r--r--po/bg.po44
-rw-r--r--po/cs.po45
-rw-r--r--po/da.po45
-rw-r--r--po/de.po45
-rw-r--r--po/el.po45
-rw-r--r--po/es.po45
-rw-r--r--po/fi.po45
-rw-r--r--po/fr.po45
-rw-r--r--po/he.po45
-rw-r--r--po/hi.po44
-rw-r--r--po/hr.po46
-rw-r--r--po/hu.po45
-rw-r--r--po/it.po45
-rw-r--r--po/ja.po45
-rw-r--r--po/ko.po45
-rw-r--r--po/nb.po45
-rw-r--r--po/nl.po45
-rw-r--r--po/pl.po46
-rw-r--r--po/pt.po45
-rw-r--r--po/pt_BR.po45
-rw-r--r--po/ro.po46
-rw-r--r--po/ru.po46
-rw-r--r--po/sk.po45
-rw-r--r--po/sl.po46
-rw-r--r--po/sr.po46
-rw-r--r--po/sv.po45
-rw-r--r--po/th.po44
-rw-r--r--po/tr.po45
-rw-r--r--po/zh_CN.po44
-rw-r--r--po/zh_TW.po44
-rw-r--r--src/Makefile.am82
-rw-r--r--src/calendar-menu-item.c100
-rw-r--r--src/calendar-menu-item.h59
-rw-r--r--src/datetime-interface.c207
-rw-r--r--src/datetime-interface.h57
-rw-r--r--src/datetime-prefs-locations.c500
-rw-r--r--src/datetime-prefs-locations.h35
-rw-r--r--src/datetime-prefs.c769
-rw-r--r--src/datetime-service.c1493
-rw-r--r--src/datetime-service.xml11
-rw-r--r--src/dbus-shared.h42
-rw-r--r--src/indicator-datetime.c1535
-rw-r--r--src/settings-shared.h68
-rw-r--r--src/timezone-completion.c688
-rw-r--r--src/timezone-completion.h63
-rw-r--r--src/utils.c276
-rw-r--r--src/utils.h38
-rw-r--r--tests/Makefile.am0
115 files changed, 11399 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..a741f25
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+# Generated by Makefile
+
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. 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
+them 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 prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. 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.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey 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;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If 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 convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU 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 that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ 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.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+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.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ 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
+state 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 3 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, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program 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, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU 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. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..a741f25
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,2 @@
+# Generated by Makefile
+
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..4de650a
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,37 @@
+
+SUBDIRS = \
+ libmap \
+ src \
+ data \
+ tests \
+ po
+
+DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall
+
+EXTRA_DIST = autogen.sh
+
+dist-hook:
+ @if test -d "$(top_srcdir)/.bzr"; \
+ then \
+ echo Creating ChangeLog && \
+ ( cd "$(top_srcdir)" && \
+ echo '# Generated by Makefile. Do not edit.'; echo; \
+ $(top_srcdir)/missing --run bzr log --gnu-changelog ) > ChangeLog.tmp \
+ && mv -f ChangeLog.tmp $(top_distdir)/ChangeLog \
+ || (rm -f ChangeLog.tmp; \
+ echo Failed to generate ChangeLog >&2 ); \
+ else \
+ echo Failed to generate ChangeLog: not a branch >&2; \
+ fi
+ @if test -d "$(top_srcdir)/.bzr"; \
+ then \
+ echo Creating AUTHORS && \
+ ( cd "$(top_srcdir)" && \
+ echo '# Generated by Makefile. Do not edit.'; echo; \
+ $(top_srcdir)/missing --run bzr log --long --levels=0 | grep -e "^\s*author:" -e "^\s*committer:" | cut -d ":" -f 2 | cut -d "<" -f 1 | sort -u) > AUTHORS.tmp \
+ && mv -f AUTHORS.tmp $(top_distdir)/AUTHORS \
+ || (rm -f AUTHORS.tmp; \
+ echo Failed to generate AUTHORS >&2 ); \
+ else \
+ echo Failed to generate AUTHORS: not a branch >&2; \
+ fi
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NEWS
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..3d255d3
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+PKG_NAME="indicator-datetime"
+
+which gnome-autogen.sh || {
+ echo "You need gnome-common from GNOME Git"
+ exit 1
+}
+
+USE_GNOME2_MACROS=1 \
+. gnome-autogen.sh $@
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..1504c6a
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,260 @@
+
+AC_INIT(indicator-datetime, 0.2.3, ted@canonical.com)
+AC_COPYRIGHT([Copyright 2009,2010 Canonical])
+
+AC_PREREQ(2.53)
+
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE(indicator-datetime, 0.2.3)
+
+AM_MAINTAINER_MODE
+
+IT_PROG_INTLTOOL([0.35.0])
+
+AC_ISC_POSIX
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_STDC_HEADERS
+AC_DISABLE_STATIC
+AC_PROG_LIBTOOL
+
+AC_SUBST(VERSION)
+AC_CONFIG_MACRO_DIR([m4])
+
+m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
+
+AC_ARG_ENABLE([deprecations],
+ [AS_HELP_STRING([--enable-deprecations],
+ [allow deprecated API usage @<:@default=yes@:>@])],
+ [],
+ [enable_deprecations=yes])
+AS_IF([test "x$enable_deprecations" = xno],
+ [CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGSEAL_ENABLE -DGTK_DISABLE_SINGLE_INCLUDES"]
+)
+
+AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums])
+AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
+
+PKG_PROG_PKG_CONFIG
+
+###########################
+# GTK+ version option
+###########################
+
+AC_ARG_WITH([gtk],
+ [AS_HELP_STRING([--with-gtk],
+ [Which version of gtk to use @<:@default=2@:>@])],
+ [],
+ [with_gtk=2])
+
+###########################
+# Dependencies
+###########################
+
+INDICATOR_REQUIRED_VERSION=0.3.19
+DBUSMENUGLIB_REQUIRED_VERSION=0.1.1
+DBUSMENUGTK_REQUIRED_VERSION=0.3.94
+GIO_REQUIRED_VERSION=2.25.11
+# Note: the GIO check below also ensures the proper glib with gsettings support is present
+INDICATOR_DISPLAY_OBJECTS=0.2.2
+GEOCLUE_REQUIRED_VERSION=0.12.0
+ECAL_REQUIRED_VERSION=2.30
+EDS_REQUIRED_VERSION=2.30
+ICAL_REQUIRED_VERSION=0.44
+CAIRO_REQUIRED_VERSION=1.10
+GDK_REQUIRED_VERSION=2.22
+GLIB_REQUIRED_VERSION=2.26
+GTK_REQUIRED_VERSION=2.12
+GTK3_REQUIRED_VERSION=3.0
+GCONF_REQUIRED_VERSION=2.31
+
+AS_IF([test "x$with_gtk" = x3],
+ [PKG_CHECK_MODULES(INDICATOR, indicator3 >= $INDICATOR_REQUIRED_VERSION
+ glib-2.0 >= $GLIB_REQUIRED_VERSION
+ dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION
+ dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION
+ libido3-0.1 >= $INDICATOR_DISPLAY_OBJECTS)
+ ],
+ [test "x$with_gtk" = x2],
+ [PKG_CHECK_MODULES(INDICATOR, indicator >= $INDICATOR_REQUIRED_VERSION
+ glib-2.0 >= $GLIB_REQUIRED_VERSION
+ dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION
+ dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION
+ libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS)
+ ],
+ [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])]
+)
+
+AS_IF([test "x$with_gtk" = x3],
+ [PKG_CHECK_MODULES(SERVICE, indicator >= $INDICATOR_REQUIRED_VERSION
+ glib-2.0 >= $GLIB_REQUIRED_VERSION
+ dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION
+ dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION
+ libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS
+ gio-2.0 >= $GIO_REQUIRED_VERSION
+ geoclue >= $GEOCLUE_REQUIRED_VERSION
+ libecal-1.2 >= $ECAL_REQUIRED_VERSION
+ libical >= $ICAL_REQUIRED_VERSION
+ libedataserver-1.2 >= EDS_REQUIRED_VERSION
+ libedataserverui-1.2 >= EDS_REQUIRED_VERSION
+ cairo >= CAIRO_REQUIRED_VERSION
+ gdk-2.0 >= GDK_REQUIRED_VERSION
+ gconf-2.0 >= GCONF_REQUIRED_VERSION)
+ ],
+ [test "x$with_gtk" = x2],
+ [PKG_CHECK_MODULES(SERVICE, indicator >= $INDICATOR_REQUIRED_VERSION
+ glib-2.0 >= $GLIB_REQUIRED_VERSION
+ dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION
+ dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION
+ libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS
+ gio-2.0 >= $GIO_REQUIRED_VERSION
+ geoclue >= $GEOCLUE_REQUIRED_VERSION
+ libecal-1.2 >= $ECAL_REQUIRED_VERSION
+ libical >= $ICAL_REQUIRED_VERSION
+ libedataserver-1.2 >= EDS_REQUIRED_VERSION
+ libedataserverui-1.2 >= EDS_REQUIRED_VERSION
+ cairo >= CAIRO_REQUIRED_VERSION
+ gdk-2.0 >= GDK_REQUIRED_VERSION
+ gconf-2.0 >= GCONF_REQUIRED_VERSION)
+ ],
+ [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])]
+)
+
+# FIXME: polkit-gtk-1 isn't gtk3-compatible
+AS_IF([test "x$with_gtk" = x3],
+ [PKG_CHECK_MODULES(PREF, gio-2.0 >= $GIO_REQUIRED_VERSION
+ gtk+-3.0 >= $GTK3_REQUIRED_VERSION
+ unique-3.0
+ json-glib-1.0
+ polkit-gtk-1)
+ ],
+ [test "x$with_gtk" = x2],
+ [PKG_CHECK_MODULES(PREF, gio-2.0 >= $GIO_REQUIRED_VERSION
+ gtk+-2.0 >= $GTK_REQUIRED_VERSION
+ unique-1.0
+ json-glib-1.0
+ polkit-gtk-1)
+ ],
+ [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])]
+)
+
+AS_IF([test "x$with_gtk" = x3],
+ [PKG_CHECK_MODULES(LIBMAP, gio-2.0 >= $GIO_REQUIRED_VERSION
+ gtk+-3.0 >= $GTK3_REQUIRED_VERSION)
+ ],
+ [test "x$with_gtk" = x2],
+ [PKG_CHECK_MODULES(LIBMAP, gio-2.0 >= $GIO_REQUIRED_VERSION
+ gtk+-2.0 >= $GTK_REQUIRED_VERSION)
+ ],
+ [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])]
+)
+AC_SUBST(INDICATOR_CFLAGS)
+AC_SUBST(INDICATOR_LIBS)
+
+AC_SUBST(SERVICE_CFLAGS)
+AC_SUBST(SERVICE_LIBS)
+
+AC_SUBST(PREF_CFLAGS)
+AC_SUBST(PREF_LIBS)
+
+AC_SUBST(LIBMAP_CFLAGS)
+AC_SUBST(LIBMAP_LIBS)
+AC_SUBST(LIBMAP_LDFLAGS)
+
+###########################
+# Grab the GSettings Macros
+###########################
+
+GLIB_GSETTINGS
+
+###########################
+# Check to see if we're local
+###########################
+
+with_localinstall="no"
+AC_ARG_ENABLE(localinstall, AS_HELP_STRING([--enable-localinstall], [install all of the files localy instead of system directories (for distcheck)]), with_localinstall=$enableval, with_localinstall=no)
+
+###########################
+# Indicator Info
+###########################
+
+AS_IF([test "x$with_localinstall" = "xyes"],
+ [
+ INDICATORDIR="${libdir}/indicators/2/"
+ INDICATORICONSDIR="${datadir}/libindicate/icons/"
+ ],
+ [AS_IF([test "x$with_gtk" = "x2"],
+ [
+ INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator`
+ INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator`
+ ],
+ [
+ INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator3`
+ INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator3`
+ ])])
+
+AC_SUBST(INDICATORDIR)
+AC_SUBST(INDICATORICONSDIR)
+
+###########################
+# DBus Service Info
+###########################
+
+if test "x$with_localinstall" = "xyes"; then
+ DBUSSERVICEDIR="${datadir}/dbus-1/services/"
+else
+ DBUSSERVICEDIR=`$PKG_CONFIG --variable=session_bus_services_dir dbus-1`
+fi
+AC_SUBST(DBUSSERVICEDIR)
+
+##############################
+# Custom Junk
+##############################
+
+AC_DEFUN([AC_DEFINE_PATH], [
+ test "x$prefix" = xNONE && prefix="$ac_default_prefix"
+ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+ ac_define_path=`eval echo [$]$2`
+ ac_define_path=`eval echo [$]ac_define_path`
+ $1="$ac_define_path"
+ AC_SUBST($1)
+ ifelse($3, ,
+ AC_DEFINE_UNQUOTED($1, "$ac_define_path"),
+ AC_DEFINE_UNQUOTED($1, "$ac_define_path", $3))
+])
+
+###########################
+# Internationalization
+###########################
+
+GETTEXT_PACKAGE=indicator-datetime
+AC_SUBST(GETTEXT_PACKAGE)
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Name of the default get text domain])
+AC_DEFINE_PATH(GNOMELOCALEDIR, "${datadir}/locale", [locale directory])
+
+AM_GLIB_GNU_GETTEXT
+
+###########################
+# Files
+###########################
+
+AC_OUTPUT([
+Makefile
+libmap/Makefile
+src/Makefile
+data/Makefile
+tests/Makefile
+po/Makefile.in
+])
+
+###########################
+# Results
+###########################
+
+AC_MSG_NOTICE([
+
+Date and Time Indicator Configuration:
+
+ Prefix: $prefix
+ Indicator Dir: $INDICATORDIR
+])
diff --git a/data/Makefile.am b/data/Makefile.am
new file mode 100644
index 0000000..b9a9532
--- /dev/null
+++ b/data/Makefile.am
@@ -0,0 +1,26 @@
+#SUBDIRS = icons
+
+gsettings_SCHEMAS = \
+ com.canonical.indicator.datetime.gschema.xml
+@GSETTINGS_RULES@
+
+dbus_servicesdir = $(DBUSSERVICEDIR)
+dbus_services_DATA = indicator-datetime.service
+
+%.service: %.service.in
+ sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
+
+pkgdata_DATA = datetime-dialog.ui
+
+@INTLTOOL_DESKTOP_RULE@
+desktopdir = $(datadir)/applications
+desktop_DATA = indicator-datetime-preferences.desktop
+
+EXTRA_DIST = \
+ $(gsettings_SCHEMAS) \
+ datetime-dialog.ui \
+ indicator-datetime-preferences.desktop \
+ indicator-datetime-preferences.desktop.in \
+ indicator-datetime.service.in
+
+CLEANFILES = indicator-datetime-preferences.desktop indicator-datetime.service
diff --git a/data/com.canonical.indicator.datetime.gschema.xml b/data/com.canonical.indicator.datetime.gschema.xml
new file mode 100644
index 0000000..8ce75e6
--- /dev/null
+++ b/data/com.canonical.indicator.datetime.gschema.xml
@@ -0,0 +1,111 @@
+<schemalist>
+ <enum id="time-enum">
+ <value nick="locale-default" value="0" />
+ <value nick="12-hour" value="1" />
+ <value nick="24-hour" value="2" />
+ <value nick="custom" value="3" />
+ </enum>
+ <schema id="com.canonical.indicator.datetime" path="/com/canonical/indicator/datetime/" gettext-domain="indicator-datetime">
+ <key name="show-clock" type="b">
+ <default>true</default>
+ <summary>Show the clock in the panel</summary>
+ <description>
+ Controls whether the clock indicator appears in the panel or not.
+ </description>
+ </key>
+ <key name="time-format" enum="time-enum">
+ <default>'locale-default'</default>
+ <summary>What the time format should be</summary>
+ <description>
+ Controls the time format that is displayed in the indicator. For almost
+ all users this should be the default for their locale. If you think the
+ setting is wrong for your locale please join or talk to the translation
+ team for your language. If you just want something different you can
+ adjust this to be either 12 or 24 time. Or, you can use a custom format
+ string and set the custom-time-format setting.
+ </description>
+ </key>
+ <key name="custom-time-format" type="s">
+ <default>"%l:%M %p"</default>
+ <summary>The format string passed to strftime</summary>
+ <description>
+ The format of the time and/or date that is visible on the panel when using
+ the indicator. For most users this will be a set of predefined values as
+ determined by the configuration utility, but advanced users can change it
+ to anything strftime can accept. Look at the man page on strftime for
+ more information.
+ </description>
+ </key>
+ <key name="show-seconds" type="b">
+ <default>false</default>
+ <summary>Show the number of seconds in the indicator</summary>
+ <description>
+ Makes the datetime indicator show the number of seconds in the indicator.
+ It's important to note that this will cause additional battery drain as
+ the time will update 60 times as often, so it is not recommended. Also,
+ this setting will be ignored if the time-format value is set to custom.
+ </description>
+ </key>
+ <key name="show-day" type="b">
+ <default>false</default>
+ <summary>Show the day of the week in the indicator</summary>
+ <description>
+ Puts the day of the week on the panel along with the time and/or date
+ depending on settings. This setting will be ignored if the time-format
+ value is set to custom.
+ </description>
+ </key>
+ <key name="show-date" type="b">
+ <default>false</default>
+ <summary>Show the month and date in the indicator</summary>
+ <description>
+ Puts the month and the date in the panel along with the time and/or day
+ of the week depending on settings. This setting will be ignored if the
+ time-format value is set to custom.
+ </description>
+ </key>
+ <key name="show-calendar" type="b">
+ <default>true</default>
+ <summary>Show the monthly calendar in the indicator</summary>
+ <description>
+ Puts the monthly calendar in indicator-datetime's menu.
+ </description>
+ </key>
+ <key name="show-week-numbers" type="b">
+ <default>false</default>
+ <summary>Show week numbers in calendar</summary>
+ <description>
+ Shows the week numbers in the monthly calendar in indicator-datetime's menu.
+ </description>
+ </key>
+ <key name="show-events" type="b">
+ <default>true</default>
+ <summary>Show events in the indicator</summary>
+ <description>
+ Shows events from Evolution in indicator-datetime's menu.
+ </description>
+ </key>
+ <key name="show-locations" type="b">
+ <default>false</default>
+ <summary>Show locations in the indicator</summary>
+ <description>
+ Shows custom defined locations in indicator-datetime's menu.
+ </description>
+ </key>
+ <key name="locations" type="as">
+ <default>['UTC']</default>
+ <summary>A List of locations</summary>
+ <description>
+ Adds the list of locations the user has configured to display in the
+ indicator-datetime menu.
+ </description>
+ </key>
+ <key name="timezone-name" type="s">
+ <default>''</default>
+ <summary>The name of the current timezone</summary>
+ <description>
+ Some timezones can be known by many different cities or names. This setting describes how the current zone prefers to be named. Format is "TIMEZONE NAME" (e.g. "America/New_York Boston" to name the New_York zone Boston).
+ </description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/data/datetime-dialog.ui b/data/datetime-dialog.ui
new file mode 100644
index 0000000..8479482
--- /dev/null
+++ b/data/datetime-dialog.ui
@@ -0,0 +1,774 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.24"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkAdjustment" id="dateAdjustment">
+ <property name="upper">1.8446744073709552e+19</property>
+ <property name="step_increment">86400</property>
+ <property name="page_increment">864000</property>
+ </object>
+ <object class="GtkWindow" id="locationsDialog">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Locations</property>
+ <property name="default_width">300</property>
+ <property name="default_height">200</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="icon_name">time-admin</property>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkTreeView" id="locationsView">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">locationsStore</property>
+ <property name="reorderable">True</property>
+ <property name="search_column">0</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHSeparator" id="hseparator1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkButton" id="addButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="addButton-atkobject">
+ <property name="AtkObject::accessible-description" translatable="yes">Add a Location…</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage" id="addImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-add</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="removeButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="removeButton-atkobject">
+ <property name="AtkObject::accessible-description" translatable="yes">Remove This Location</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage" id="removeImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-remove</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkListStore" id="locationsStore">
+ <columns>
+ <!-- column-name Location -->
+ <column type="gchararray"/>
+ <!-- column-name Time -->
+ <column type="gchararray"/>
+ <!-- column-name Zone -->
+ <column type="gchararray"/>
+ <!-- column-name Visible Name -->
+ <column type="gchararray"/>
+ <!-- column-name Icon -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkAdjustment" id="timeAdjustment">
+ <property name="upper">1.8446744073709552e+19</property>
+ <property name="step_increment">60</property>
+ <property name="page_increment">3600</property>
+ </object>
+ <object class="GtkWindow" id="timeDateDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Time &amp; Date</property>
+ <property name="resizable">False</property>
+ <property name="icon_name">time-admin</property>
+ <property name="type_hint">dialog</property>
+ <child>
+ <object class="GtkNotebook" id="notebook1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkVBox" id="timeDateBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">12</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkVBox" id="timeDateOptions">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkVBox" id="vbox6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkAspectFrame" id="mapBox">
+ <property name="height_request">265</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">_Location:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">timezoneEntry</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="timezoneEntry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="invisible_char_set">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkRadioButton" id="manualTimeRadio">
+ <property name="label" translatable="yes">_Manually</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="automaticTimeRadio">
+ <property name="label" translatable="yes">_Automatically from the Internet</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">manualTimeRadio</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Set the time:</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="manualOptions">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkHBox" id="hbox8">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkSpinButton" id="timeSpinner">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="width_chars">11</property>
+ <property name="xalign">1</property>
+ <property name="invisible_char_set">True</property>
+ <property name="adjustment">timeAdjustment</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox9">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Date:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">dateSpinner</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="dateSpinner">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="width_chars">11</property>
+ <property name="xalign">1</property>
+ <property name="invisible_char_set">True</property>
+ <property name="adjustment">dateAdjustment</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Tim_e:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">timeSpinner</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xpad">1</property>
+ <property name="label" translatable="yes">_Time &amp; Date</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="yalign">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <object class="GtkVBox" id="clockBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">12</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkCheckButton" id="showClockCheck">
+ <property name="label" translatable="yes">_Show a clock in the menu bar</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="clockOptions">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">In the clock, show:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="showWeekdayCheck">
+ <property name="label" translatable="yes">_Weekday</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="showDateTimeCheck">
+ <property name="label" translatable="yes">_Date and month</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkRadioButton" id="show12HourRadio">
+ <property name="label" translatable="yes">_12-hour time</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="show24HourRadio">
+ <property name="label" translatable="yes">_24-hour time</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">show12HourRadio</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="showSecondsCheck">
+ <property name="label" translatable="yes">Seco_nds</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">In the clock’s menu, show:</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="showCalendarCheck">
+ <property name="label" translatable="yes">_Monthly calendar</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="calendarOptions">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="yscale">0</property>
+ <property name="left_padding">24</property>
+ <child>
+ <object class="GtkVBox" id="vbox4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="includeWeekNumbersCheck">
+ <property name="label" translatable="yes">Include week num_bers</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="showEventsCheck">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ <child>
+ <object class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Coming _events from Evolution Calendar</property>
+ <property name="use_underline">True</property>
+ <property name="wrap">True</property>
+ <property name="mnemonic_widget">showEventsCheck</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="showLocationsCheck">
+ <property name="label" translatable="yes">Time in _other locations</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="left_padding">24</property>
+ <child>
+ <object class="GtkButton" id="locationsButton">
+ <property name="label" translatable="yes">Choose _Locations…</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Clock</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkSizeGroup" id="timeSizeGroup">
+ <widgets>
+ <widget name="label5"/>
+ <widget name="label9"/>
+ <widget name="label11"/>
+ </widgets>
+ </object>
+</interface>
diff --git a/data/indicator-datetime-preferences.desktop.in b/data/indicator-datetime-preferences.desktop.in
new file mode 100644
index 0000000..f37765b
--- /dev/null
+++ b/data/indicator-datetime-preferences.desktop.in
@@ -0,0 +1,14 @@
+[Desktop Entry]
+Version=1.0
+
+_Name=Time & Date
+_Comment=Change your clock and date settings
+
+Icon=time-admin
+TryExec=indicator-datetime-preferences
+Exec=indicator-datetime-preferences
+
+StartupNotify=true
+
+Type=Application
+Categories=GNOME;GTK;Utility;DesktopSettings;Settings;
diff --git a/data/indicator-datetime.service.in b/data/indicator-datetime.service.in
new file mode 100644
index 0000000..e7735ce
--- /dev/null
+++ b/data/indicator-datetime.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=com.canonical.indicator.datetime
+Exec=@libexecdir@/indicator-datetime-service
diff --git a/libmap/Makefile.am b/libmap/Makefile.am
new file mode 100644
index 0000000..a10b835
--- /dev/null
+++ b/libmap/Makefile.am
@@ -0,0 +1,77 @@
+uidir = $(pkgdatadir)/libmap/ui
+dist_ui_DATA = \
+ data/bg.png \
+ data/cc.png \
+ data/olsen_map.png \
+ data/pin.png \
+ data/timezone_0.png \
+ data/timezone_-10.png \
+ data/timezone_10.png \
+ data/timezone_10.5.png \
+ data/timezone_-1.png \
+ data/timezone_1.png \
+ data/timezone_-11.png \
+ data/timezone_11.png \
+ data/timezone_11.5.png \
+ data/timezone_12.png \
+ data/timezone_12.75.png \
+ data/timezone_13.png \
+ data/timezone_-2.png \
+ data/timezone_2.png \
+ data/timezone_-3.png \
+ data/timezone_3.png \
+ data/timezone_-3.5.png \
+ data/timezone_3.5.png \
+ data/timezone_-4.png \
+ data/timezone_4.png \
+ data/timezone_-4.5.png \
+ data/timezone_4.5.png \
+ data/timezone_-5.png \
+ data/timezone_5.png \
+ data/timezone_-5.5.png \
+ data/timezone_5.5.png \
+ data/timezone_5.75.png \
+ data/timezone_-6.png \
+ data/timezone_6.png \
+ data/timezone_6.5.png \
+ data/timezone_-7.png \
+ data/timezone_7.png \
+ data/timezone_-8.png \
+ data/timezone_8.png \
+ data/timezone_-9.png \
+ data/timezone_9.png \
+ data/timezone_-9.5.png \
+ data/timezone_9.5.png
+
+tzdatadir = $(pkgdatadir)/libmap/datetime
+dist_tzdata_DATA = backward
+
+AM_CPPFLAGS = \
+ $(LIBMAP_CFLAGS) \
+ -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
+ -DGNOMECC_DATA_DIR="\"$(pkgdatadir)/libmap\"" \
+ -DDATADIR="\"$(uidir)\"" \
+ $(NULL)
+
+noinst_PROGRAMS = test-timezone
+
+test_timezone_SOURCES = test-timezone.c tz.c tz.h
+test_timezone_LDADD = $(LIBMAP_LIBS)
+test_timezone_CFLAGS = $(LIBMAP_CFLAGS)
+
+all-local: check-local
+
+# FIXME remove "|| :" when we have all the necessary pixmaps
+check-local: test-timezone
+ $(builddir)/test-timezone $(srcdir)/data || :
+
+noinst_LTLIBRARIES = libmap.la
+
+libmap_la_SOURCES = \
+ cc-timezone-map.c \
+ cc-timezone-map.h \
+ tz.c tz.h
+
+libmap_la_LIBADD = $(LIBMAP_LIBS)
+libmap_la_LDFLAGS = $(LIBMAP_LDFLAGS)
+
diff --git a/libmap/README b/libmap/README
new file mode 100644
index 0000000..6766b42
--- /dev/null
+++ b/libmap/README
@@ -0,0 +1,5 @@
+This static library is a copied version of the code in GNOME 3.0's control center panel 'datetime', which itself is a version of Ubiquity's map ported to C.
+
+Ideally in the future, we can have all three packages using the same code. But for now, for time reasons (hah), it's just a copy.
+
+To update this copy, put newer versions of the code and data files in place; then fix up any GTK3-isms and add cc_timezone_map_set_coords and friends. And the watermark.
diff --git a/libmap/backward b/libmap/backward
new file mode 100644
index 0000000..f1f95a8
--- /dev/null
+++ b/libmap/backward
@@ -0,0 +1,118 @@
+# <pre>
+# @(#)backward 8.9
+# This file is in the public domain, so clarified as of
+# 2009-05-17 by Arthur David Olson.
+
+# This file provides links between current names for time zones
+# and their old names. Many names changed in late 1993.
+
+Link Africa/Asmara Africa/Asmera
+Link Africa/Bamako Africa/Timbuktu
+Link America/Argentina/Catamarca America/Argentina/ComodRivadavia
+Link America/Adak America/Atka
+Link America/Argentina/Buenos_Aires America/Buenos_Aires
+Link America/Argentina/Catamarca America/Catamarca
+Link America/Atikokan America/Coral_Harbour
+Link America/Argentina/Cordoba America/Cordoba
+Link America/Tijuana America/Ensenada
+Link America/Indiana/Indianapolis America/Fort_Wayne
+Link America/Indiana/Indianapolis America/Indianapolis
+Link America/Argentina/Jujuy America/Jujuy
+Link America/Indiana/Knox America/Knox_IN
+Link America/Kentucky/Louisville America/Louisville
+Link America/Argentina/Mendoza America/Mendoza
+Link America/Rio_Branco America/Porto_Acre
+Link America/Argentina/Cordoba America/Rosario
+Link America/St_Thomas America/Virgin
+Link Asia/Ashgabat Asia/Ashkhabad
+Link Asia/Chongqing Asia/Chungking
+Link Asia/Dhaka Asia/Dacca
+Link Asia/Kathmandu Asia/Katmandu
+Link Asia/Kolkata Asia/Calcutta
+Link Asia/Macau Asia/Macao
+Link Asia/Jerusalem Asia/Tel_Aviv
+Link Asia/Ho_Chi_Minh Asia/Saigon
+Link Asia/Thimphu Asia/Thimbu
+Link Asia/Makassar Asia/Ujung_Pandang
+Link Asia/Ulaanbaatar Asia/Ulan_Bator
+Link Atlantic/Faroe Atlantic/Faeroe
+Link Europe/Oslo Atlantic/Jan_Mayen
+Link Australia/Sydney Australia/ACT
+Link Australia/Sydney Australia/Canberra
+Link Australia/Lord_Howe Australia/LHI
+Link Australia/Sydney Australia/NSW
+Link Australia/Darwin Australia/North
+Link Australia/Brisbane Australia/Queensland
+Link Australia/Adelaide Australia/South
+Link Australia/Hobart Australia/Tasmania
+Link Australia/Melbourne Australia/Victoria
+Link Australia/Perth Australia/West
+Link Australia/Broken_Hill Australia/Yancowinna
+Link America/Rio_Branco Brazil/Acre
+Link America/Noronha Brazil/DeNoronha
+Link America/Sao_Paulo Brazil/East
+Link America/Manaus Brazil/West
+Link America/Halifax Canada/Atlantic
+Link America/Winnipeg Canada/Central
+Link America/Regina Canada/East-Saskatchewan
+Link America/Toronto Canada/Eastern
+Link America/Edmonton Canada/Mountain
+Link America/St_Johns Canada/Newfoundland
+Link America/Vancouver Canada/Pacific
+Link America/Regina Canada/Saskatchewan
+Link America/Whitehorse Canada/Yukon
+Link America/Santiago Chile/Continental
+Link Pacific/Easter Chile/EasterIsland
+Link America/Havana Cuba
+Link Africa/Cairo Egypt
+Link Europe/Dublin Eire
+Link Europe/London Europe/Belfast
+Link Europe/Chisinau Europe/Tiraspol
+Link Europe/London GB
+Link Europe/London GB-Eire
+Link Etc/GMT GMT+0
+Link Etc/GMT GMT-0
+Link Etc/GMT GMT0
+Link Etc/GMT Greenwich
+Link Asia/Hong_Kong Hongkong
+Link Atlantic/Reykjavik Iceland
+Link Asia/Tehran Iran
+Link Asia/Jerusalem Israel
+Link America/Jamaica Jamaica
+Link Asia/Tokyo Japan
+Link Pacific/Kwajalein Kwajalein
+Link Africa/Tripoli Libya
+Link America/Tijuana Mexico/BajaNorte
+Link America/Mazatlan Mexico/BajaSur
+Link America/Mexico_City Mexico/General
+Link Pacific/Auckland NZ
+Link Pacific/Chatham NZ-CHAT
+Link America/Denver Navajo
+Link Asia/Shanghai PRC
+Link Pacific/Pago_Pago Pacific/Samoa
+Link Pacific/Chuuk Pacific/Yap
+Link Pacific/Chuuk Pacific/Truk
+Link Pacific/Pohnpei Pacific/Ponape
+Link Europe/Warsaw Poland
+Link Europe/Lisbon Portugal
+Link Asia/Taipei ROC
+Link Asia/Seoul ROK
+Link Asia/Singapore Singapore
+Link Europe/Istanbul Turkey
+Link Etc/UCT UCT
+Link America/Anchorage US/Alaska
+Link America/Adak US/Aleutian
+Link America/Phoenix US/Arizona
+Link America/Chicago US/Central
+Link America/Indiana/Indianapolis US/East-Indiana
+Link America/New_York US/Eastern
+Link Pacific/Honolulu US/Hawaii
+Link America/Indiana/Knox US/Indiana-Starke
+Link America/Detroit US/Michigan
+Link America/Denver US/Mountain
+Link America/Los_Angeles US/Pacific
+Link Pacific/Pago_Pago US/Samoa
+Link Etc/UTC UTC
+Link Etc/UTC Universal
+Link Europe/Moscow W-SU
+Link Etc/UTC Zulu
diff --git a/libmap/cc-timezone-map.c b/libmap/cc-timezone-map.c
new file mode 100644
index 0000000..7b7d704
--- /dev/null
+++ b/libmap/cc-timezone-map.c
@@ -0,0 +1,1195 @@
+/*
+ * Copyright (C) 2010 Intel, Inc
+ * Copyright (C) 2011 Canonical Ltd.
+ *
+ * Portions from Ubiquity, Copyright (C) 2009 Canonical Ltd.
+ * Written by Evan Dandrea <evand@ubuntu.com>
+ *
+ * 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.
+ *
+ * Author: Thomas Wood <thomas.wood@intel.com>
+ *
+ */
+
+#include "cc-timezone-map.h"
+#include <math.h>
+#include "tz.h"
+
+G_DEFINE_TYPE (CcTimezoneMap, cc_timezone_map, GTK_TYPE_WIDGET)
+
+#define TIMEZONE_MAP_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_TIMEZONE_MAP, CcTimezoneMapPrivate))
+
+
+typedef struct
+{
+ gdouble offset;
+ guchar red;
+ guchar green;
+ guchar blue;
+ guchar alpha;
+} CcTimezoneMapOffset;
+
+struct _CcTimezoneMapPrivate
+{
+ GdkPixbuf *orig_background;
+ GdkPixbuf *orig_color_map;
+
+ GdkPixbuf *background;
+ GdkPixbuf *color_map;
+ GdkPixbuf *olsen_map;
+
+ guchar *visible_map_pixels;
+ gint visible_map_rowstride;
+
+ gint olsen_map_channels;
+ guchar *olsen_map_pixels;
+ gint olsen_map_rowstride;
+
+ gdouble selected_offset;
+
+ gchar *watermark;
+
+ TzDB *tzdb;
+ TzLocation *location;
+ GHashTable *alias_db;
+};
+
+enum
+{
+ LOCATION_CHANGED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
+
+static CcTimezoneMapOffset color_codes[] =
+{
+ {-11.0, 43, 0, 0, 255 },
+ {-10.0, 85, 0, 0, 255 },
+ {-9.5, 102, 255, 0, 255 },
+ {-9.0, 128, 0, 0, 255 },
+ {-8.0, 170, 0, 0, 255 },
+ {-7.0, 212, 0, 0, 255 },
+ {-6.0, 255, 0, 1, 255 }, // north
+ {-6.0, 255, 0, 0, 255 }, // south
+ {-5.0, 255, 42, 42, 255 },
+ {-4.5, 192, 255, 0, 255 },
+ {-4.0, 255, 85, 85, 255 },
+ {-3.5, 0, 255, 0, 255 },
+ {-3.0, 255, 128, 128, 255 },
+ {-2.0, 255, 170, 170, 255 },
+ {-1.0, 255, 213, 213, 255 },
+ {0.0, 43, 17, 0, 255 },
+ {1.0, 85, 34, 0, 255 },
+ {2.0, 128, 51, 0, 255 },
+ {3.0, 170, 68, 0, 255 },
+ {3.5, 0, 255, 102, 255 },
+ {4.0, 212, 85, 0, 255 },
+ {4.5, 0, 204, 255, 255 },
+ {5.0, 255, 102, 0, 255 },
+ {5.5, 0, 102, 255, 255 },
+ {5.75, 0, 238, 207, 247 },
+ {6.0, 255, 127, 42, 255 },
+ {6.5, 204, 0, 254, 254 },
+ {7.0, 255, 153, 85, 255 },
+ {8.0, 255, 179, 128, 255 },
+ {9.0, 255, 204, 170, 255 },
+ {9.5, 170, 0, 68, 250 },
+ {10.0, 255, 230, 213, 255 },
+ {10.5, 212, 124, 21, 250 },
+ {11.0, 212, 170, 0, 255 },
+ {11.5, 249, 25, 87, 253 },
+ {12.0, 255, 204, 0, 255 },
+ {12.75, 254, 74, 100, 248 },
+ {13.0, 255, 85, 153, 250 },
+ {-100, 0, 0, 0, 0 }
+};
+
+static const gchar * olsen_map_timezones[] = {
+ "Africa/Abidjan",
+ "Africa/Accra",
+ "Africa/Addis_Ababa",
+ "Africa/Algiers",
+ "Africa/Asmara",
+ "Africa/Bamako",
+ "Africa/Bangui",
+ "Africa/Banjul",
+ "Africa/Bissau",
+ "Africa/Blantyre",
+ "Africa/Brazzaville",
+ "Africa/Bujumbura",
+ "Africa/Cairo",
+ "Africa/Casablanca",
+ "Africa/Conakry",
+ "Africa/Dakar",
+ "Africa/Dar_es_Salaam",
+ "Africa/Djibouti",
+ "Africa/Douala",
+ "Africa/El_Aaiun",
+ "Africa/Freetown",
+ "Africa/Gaborone",
+ "Africa/Harare",
+ "Africa/Johannesburg",
+ "Africa/Kampala",
+ "Africa/Khartoum",
+ "Africa/Kigali",
+ "Africa/Kinshasa",
+ "Africa/Lagos",
+ "Africa/Libreville",
+ "Africa/Lome",
+ "Africa/Luanda",
+ "Africa/Lubumbashi",
+ "Africa/Lusaka",
+ "Africa/Malabo",
+ "Africa/Maputo",
+ "Africa/Maseru",
+ "Africa/Mbabane",
+ "Africa/Mogadishu",
+ "Africa/Monrovia",
+ "Africa/Nairobi",
+ "Africa/Ndjamena",
+ "Africa/Niamey",
+ "Africa/Nouakchott",
+ "Africa/Ouagadougou",
+ "Africa/Porto-Novo",
+ "Africa/Sao_Tome",
+ "Africa/Tripoli",
+ "Africa/Tunis",
+ "Africa/Windhoek",
+ "America/Adak",
+ "America/Anguilla",
+ "America/Antigua",
+ "America/Araguaina",
+ "America/Argentina/Buenos_Aires",
+ "America/Argentina/Catamarca",
+ "America/Argentina/Cordoba",
+ "America/Argentina/Jujuy",
+ "America/Argentina/La_Rioja",
+ "America/Argentina/Mendoza",
+ "America/Argentina/Rio_Gallegos",
+ "America/Argentina/San_Juan",
+ "America/Argentina/San_Luis",
+ "America/Argentina/Tucuman",
+ "America/Argentina/Ushuaia",
+ "America/Aruba",
+ "America/Asuncion",
+ "America/Atikokan",
+ "America/Bahia",
+ "America/Barbados",
+ "America/Belem",
+ "America/Belize",
+ "America/Blanc-Sablon",
+ "America/Boa_Vista",
+ "America/Bogota",
+ "America/Boise",
+ "America/Cambridge_Bay",
+ "America/Campo_Grande",
+ "America/Cancun",
+ "America/Caracas",
+ "America/Cayenne",
+ "America/Cayman",
+ "America/Chicago",
+ "America/Chihuahua",
+ "America/Coral_Harbour",
+ "America/Costa_Rica",
+ "America/Cuiaba",
+ "America/Curacao",
+ "America/Dawson",
+ "America/Dawson_Creek",
+ "America/Denver",
+ "America/Dominica",
+ "America/Edmonton",
+ "America/Eirunepe",
+ "America/El_Salvador",
+ "America/Fortaleza",
+ "America/Glace_Bay",
+ "America/Goose_Bay",
+ "America/Grand_Turk",
+ "America/Grenada",
+ "America/Guadeloupe",
+ "America/Guatemala",
+ "America/Guayaquil",
+ "America/Guyana",
+ "America/Halifax",
+ "America/Havana",
+ "America/Hermosillo",
+ "America/Indiana/Indianapolis",
+ "America/Indiana/Knox",
+ "America/Indiana/Marengo",
+ "America/Indiana/Petersburg",
+ "America/Indiana/Vevay",
+ "America/Indiana/Vincennes",
+ "America/Indiana/Winamac",
+ "America/Inuvik",
+ "America/Iqaluit",
+ "America/Jamaica",
+ "America/Juneau",
+ "America/Kentucky/Louisville",
+ "America/Kentucky/Monticello",
+ "America/La_Paz",
+ "America/Lima",
+ "America/Los_Angeles",
+ "America/Maceio",
+ "America/Managua",
+ "America/Manaus",
+ "America/Marigot",
+ "America/Martinique",
+ "America/Mazatlan",
+ "America/Menominee",
+ "America/Merida",
+ "America/Mexico_City",
+ "America/Miquelon",
+ "America/Moncton",
+ "America/Monterrey",
+ "America/Montevideo",
+ "America/Montreal",
+ "America/Montserrat",
+ "America/Nassau",
+ "America/New_York",
+ "America/Nipigon",
+ "America/Noronha",
+ "America/North_Dakota/Center",
+ "America/North_Dakota/Salem",
+ "America/Panama",
+ "America/Pangnirtung",
+ "America/Paramaribo",
+ "America/Phoenix",
+ "America/Port-au-Prince",
+ "America/Port_of_Spain",
+ "America/Porto_Velho",
+ "America/Puerto_Rico",
+ "America/Rainy_River",
+ "America/Rankin_Inlet",
+ "America/Recife",
+ "America/Regina",
+ "America/Resolute",
+ "America/Rio_Branco",
+ "America/Santarem",
+ "America/Santiago",
+ "America/Santo_Domingo",
+ "America/Sao_Paulo",
+ "America/St_Barthelemy",
+ "America/St_Johns",
+ "America/St_Kitts",
+ "America/St_Lucia",
+ "America/St_Thomas",
+ "America/St_Vincent",
+ "America/Tegucigalpa",
+ "America/Thunder_Bay",
+ "America/Tijuana",
+ "America/Toronto",
+ "America/Tortola",
+ "America/Vancouver",
+ "America/Whitehorse",
+ "America/Winnipeg",
+ "America/Yellowknife",
+ "Ameriica/Swift_Current",
+ "Arctic/Longyearbyen",
+ "Asia/Aden",
+ "Asia/Almaty",
+ "Asia/Amman",
+ "Asia/Anadyr",
+ "Asia/Aqtau",
+ "Asia/Aqtobe",
+ "Asia/Ashgabat",
+ "Asia/Baghdad",
+ "Asia/Bahrain",
+ "Asia/Baku",
+ "Asia/Bangkok",
+ "Asia/Beirut",
+ "Asia/Bishkek",
+ "Asia/Brunei",
+ "Asia/Choibalsan",
+ "Asia/Chongqing",
+ "Asia/Colombo",
+ "Asia/Damascus",
+ "Asia/Dhaka",
+ "Asia/Dili",
+ "Asia/Dubai",
+ "Asia/Dushanbe",
+ "Asia/Gaza",
+ "Asia/Harbin",
+ "Asia/Ho_Chi_Minh",
+ "Asia/Hong_Kong",
+ "Asia/Hovd",
+ "Asia/Irkutsk",
+ "Asia/Jakarta",
+ "Asia/Jayapura",
+ "Asia/Jerusalem",
+ "Asia/Kabul",
+ "Asia/Kamchatka",
+ "Asia/Karachi",
+ "Asia/Kashgar",
+ "Asia/Katmandu",
+ "Asia/Kolkata",
+ "Asia/Krasnoyarsk",
+ "Asia/Kuala_Lumpur",
+ "Asia/Kuching",
+ "Asia/Kuwait",
+ "Asia/Macau",
+ "Asia/Magadan",
+ "Asia/Makassar",
+ "Asia/Manila",
+ "Asia/Muscat",
+ "Asia/Nicosia",
+ "Asia/Novosibirsk",
+ "Asia/Omsk",
+ "Asia/Oral",
+ "Asia/Phnom_Penh",
+ "Asia/Pontianak",
+ "Asia/Pyongyang",
+ "Asia/Qatar",
+ "Asia/Qyzylorda",
+ "Asia/Rangoon",
+ "Asia/Riyadh",
+ "Asia/Sakhalin",
+ "Asia/Samarkand",
+ "Asia/Seoul",
+ "Asia/Shanghai",
+ "Asia/Singapore",
+ "Asia/Taipei",
+ "Asia/Tashkent",
+ "Asia/Tbilisi",
+ "Asia/Tehran",
+ "Asia/Thimphu",
+ "Asia/Tokyo",
+ "Asia/Ulaanbaatar",
+ "Asia/Urumqi",
+ "Asia/Vientiane",
+ "Asia/Vladivostok",
+ "Asia/Yakutsk",
+ "Asia/Yekaterinburg",
+ "Asia/Yerevan",
+ "Atlantic/Azores",
+ "Atlantic/Bermuda",
+ "Atlantic/Canary",
+ "Atlantic/Cape_Verde",
+ "Atlantic/Faroe",
+ "Atlantic/Madeira",
+ "Atlantic/Reykjavik",
+ "Atlantic/South_Georgia",
+ "Atlantic/St_Helena",
+ "Atlantic/Stanley",
+ "Australia/Adelaide",
+ "Australia/Brisbane",
+ "Australia/Broken_Hill",
+ "Australia/Currie",
+ "Australia/Darwin",
+ "Australia/Eucla",
+ "Australia/Hobart",
+ "Australia/Lindeman",
+ "Australia/Lord_Howe",
+ "Australia/Melbourne",
+ "Australia/Perth",
+ "Australia/Sydney",
+ "Europe/Amsterdam",
+ "Europe/Andorra",
+ "Europe/Athens",
+ "Europe/Belgrade",
+ "Europe/Berlin",
+ "Europe/Bratislava",
+ "Europe/Brussels",
+ "Europe/Bucharest",
+ "Europe/Budapest",
+ "Europe/Chisinau",
+ "Europe/Copenhagen",
+ "Europe/Dublin",
+ "Europe/Gibraltar",
+ "Europe/Guernsey",
+ "Europe/Helsinki",
+ "Europe/Isle_of_Man",
+ "Europe/Istanbul",
+ "Europe/Jersey",
+ "Europe/Kaliningrad",
+ "Europe/Kiev",
+ "Europe/Lisbon",
+ "Europe/Ljubljana",
+ "Europe/London",
+ "Europe/Luxembourg",
+ "Europe/Madrid",
+ "Europe/Malta",
+ "Europe/Marienhamn",
+ "Europe/Minsk",
+ "Europe/Monaco",
+ "Europe/Moscow",
+ "Europe/Oslo",
+ "Europe/Paris",
+ "Europe/Podgorica",
+ "Europe/Prague",
+ "Europe/Riga",
+ "Europe/Rome",
+ "Europe/Samara",
+ "Europe/San_Marino",
+ "Europe/Sarajevo",
+ "Europe/Simferopol",
+ "Europe/Skopje",
+ "Europe/Sofia",
+ "Europe/Stockholm",
+ "Europe/Tallinn",
+ "Europe/Tirane",
+ "Europe/Uzhgorod",
+ "Europe/Vaduz",
+ "Europe/Vatican",
+ "Europe/Vienna",
+ "Europe/Vilnius",
+ "Europe/Volgograd",
+ "Europe/Warsaw",
+ "Europe/Zagreb",
+ "Europe/Zaporozhye",
+ "Europe/Zurich",
+ "Indian/Antananarivo",
+ "Indian/Chagos",
+ "Indian/Christmas",
+ "Indian/Cocos",
+ "Indian/Comoro",
+ "Indian/Kerguelen",
+ "Indian/Mahe",
+ "Indian/Maldives",
+ "Indian/Mauritius",
+ "Indian/Mayotte",
+ "Indian/Reunion",
+ "Pacific/Apia",
+ "Pacific/Auckland",
+ "Pacific/Chatham",
+ "Pacific/Easter",
+ "Pacific/Efate",
+ "Pacific/Enderbury",
+ "Pacific/Fakaofo",
+ "Pacific/Fiji",
+ "Pacific/Funafuti",
+ "Pacific/Galapagos",
+ "Pacific/Gambier",
+ "Pacific/Guadalcanal",
+ "Pacific/Guam",
+ "Pacific/Honolulu",
+ "Pacific/Johnston",
+ "Pacific/Kiritimati",
+ "Pacific/Kosrae",
+ "Pacific/Kwajalein",
+ "Pacific/Majuro",
+ "Pacific/Marquesas",
+ "Pacific/Midway",
+ "Pacific/Nauru",
+ "Pacific/Niue",
+ "Pacific/Norfolk",
+ "Pacific/Noumea",
+ "Pacific/Pago_Pago",
+ "Pacific/Palau",
+ "Pacific/Pitcairn",
+ "Pacific/Ponape",
+ "Pacific/Port_Moresby",
+ "Pacific/Rarotonga",
+ "Pacific/Saipan",
+ "Pacific/Tahiti",
+ "Pacific/Tarawa",
+ "Pacific/Tongatapu",
+ "Pacific/Truk",
+ "Pacific/Wake",
+ "Pacific/Wallis"
+};
+
+static void
+cc_timezone_map_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+cc_timezone_map_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+cc_timezone_map_dispose (GObject *object)
+{
+ CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (object)->priv;
+
+ if (priv->orig_background)
+ {
+ g_object_unref (priv->orig_background);
+ priv->orig_background = NULL;
+ }
+
+ if (priv->orig_color_map)
+ {
+ g_object_unref (priv->orig_color_map);
+ priv->orig_color_map = NULL;
+ }
+
+ if (priv->olsen_map)
+ {
+ g_object_unref (priv->olsen_map);
+ priv->olsen_map = NULL;
+
+ priv->olsen_map_channels = 0;
+ priv->olsen_map_pixels = NULL;
+ priv->olsen_map_rowstride = 0;
+ }
+
+ if (priv->background)
+ {
+ g_object_unref (priv->background);
+ priv->background = NULL;
+ }
+
+ if (priv->color_map)
+ {
+ g_object_unref (priv->color_map);
+ priv->color_map = NULL;
+
+ priv->visible_map_pixels = NULL;
+ priv->visible_map_rowstride = 0;
+ }
+
+ if (priv->alias_db)
+ {
+ g_hash_table_destroy (priv->alias_db);
+ priv->alias_db = NULL;
+ }
+
+ if (priv->watermark)
+ {
+ g_free (priv->watermark);
+ priv->watermark = NULL;
+ }
+
+ G_OBJECT_CLASS (cc_timezone_map_parent_class)->dispose (object);
+}
+
+static void
+cc_timezone_map_finalize (GObject *object)
+{
+ CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (object)->priv;
+
+ if (priv->tzdb)
+ {
+ tz_db_free (priv->tzdb);
+ priv->tzdb = NULL;
+ }
+
+
+ G_OBJECT_CLASS (cc_timezone_map_parent_class)->finalize (object);
+}
+
+/* GtkWidget functions */
+#ifdef CCGTK3
+static void
+cc_timezone_map_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ /* choose a minimum size small enough to prevent the window
+ * from growing horizontally
+ */
+ if (minimum != NULL)
+ *minimum = 300;
+ if (natural != NULL)
+ *natural = 300;
+}
+
+static void
+cc_timezone_map_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
+ gint size;
+
+ /* The + 20 here is a slight tweak to make the map fill the
+ * panel better without causing horizontal growing
+ */
+ size = 300 * gdk_pixbuf_get_height (priv->orig_background) / gdk_pixbuf_get_width (priv->orig_background) + 20;
+ if (minimum != NULL)
+ *minimum = size;
+ if (natural != NULL)
+ *natural = size;
+}
+
+#else
+
+static void
+cc_timezone_map_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
+
+ if (!requisition)
+ return;
+
+ /* The + 20 here is a slight tweak to make the map fill the
+ * panel better without causing horizontal growing
+ */
+ requisition->height = 300 * gdk_pixbuf_get_height (priv->orig_background) / gdk_pixbuf_get_width (priv->orig_background) + 20;
+ requisition->width = 300;
+}
+#endif
+
+static void
+cc_timezone_map_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
+
+ if (priv->background)
+ g_object_unref (priv->background);
+
+ priv->background = gdk_pixbuf_scale_simple (priv->orig_background,
+ allocation->width,
+ allocation->height,
+ GDK_INTERP_BILINEAR);
+
+ if (priv->color_map)
+ g_object_unref (priv->color_map);
+
+ priv->color_map = gdk_pixbuf_scale_simple (priv->orig_color_map,
+ allocation->width,
+ allocation->height,
+ GDK_INTERP_BILINEAR);
+
+ priv->visible_map_pixels = gdk_pixbuf_get_pixels (priv->color_map);
+ priv->visible_map_rowstride = gdk_pixbuf_get_rowstride (priv->color_map);
+
+ GTK_WIDGET_CLASS (cc_timezone_map_parent_class)->size_allocate (widget,
+ allocation);
+}
+
+static void
+cc_timezone_map_realize (GtkWidget *widget)
+{
+ GdkWindowAttr attr = { 0, };
+ GtkAllocation allocation;
+ GdkCursor *cursor;
+ GdkWindow *window;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ gtk_widget_set_realized (widget, TRUE);
+
+ attr.window_type = GDK_WINDOW_CHILD;
+ attr.wclass = GDK_INPUT_OUTPUT;
+ attr.width = allocation.width;
+ attr.height = allocation.height;
+ attr.x = allocation.x;
+ attr.y = allocation.y;
+ attr.event_mask = gtk_widget_get_events (widget)
+ | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK;
+
+ window = gdk_window_new (gtk_widget_get_parent_window (widget), &attr,
+ GDK_WA_X | GDK_WA_Y);
+
+ gtk_widget_set_style (widget,
+ gtk_style_attach (gtk_widget_get_style (widget),
+ window));
+
+ gdk_window_set_user_data (window, widget);
+
+ cursor = gdk_cursor_new (GDK_HAND2);
+ gdk_window_set_cursor (window, cursor);
+
+ gtk_widget_set_window (widget, window);
+}
+
+
+static gdouble
+convert_longtitude_to_x (gdouble longitude, gint map_width)
+{
+ const gdouble xdeg_offset = -6;
+ gdouble x;
+
+ x = (map_width * (180.0 + longitude) / 360.0)
+ + (map_width * xdeg_offset / 180.0);
+
+ return x;
+}
+
+static gdouble
+radians (gdouble degrees)
+{
+ return (degrees / 360.0) * G_PI * 2;
+}
+
+static gdouble
+convert_latitude_to_y (gdouble latitude, gdouble map_height)
+{
+ gdouble bottom_lat = -59;
+ gdouble top_lat = 81;
+ gdouble top_per, y, full_range, top_offset, map_range;
+
+ top_per = top_lat / 180.0;
+ y = 1.25 * log (tan (G_PI_4 + 0.4 * radians (latitude)));
+ full_range = 4.6068250867599998;
+ top_offset = full_range * top_per;
+ map_range = fabs (1.25 * log (tan (G_PI_4 + 0.4 * radians (bottom_lat))) - top_offset);
+ y = fabs (y - top_offset);
+ y = y / map_range;
+ y = y * map_height;
+ return y;
+}
+
+
+static gboolean
+cc_timezone_map_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
+ GdkPixbuf *hilight, *orig_hilight, *pin;
+ GtkAllocation alloc;
+ gchar *file;
+ GError *err = NULL;
+ gdouble pointx, pointy;
+ gdouble alpha = 1.0;
+ GtkStyle *style;
+ char buf[16];
+
+ gtk_widget_get_allocation (widget, &alloc);
+
+ style = gtk_widget_get_style (widget);
+
+ /* Check if insensitive */
+ if (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE)
+ alpha = 0.5;
+
+ /* paint background */
+ gdk_cairo_set_source_color (cr, &style->bg[gtk_widget_get_state (widget)]);
+ cairo_paint (cr);
+ gdk_cairo_set_source_pixbuf (cr, priv->background, 0, 0);
+ cairo_paint_with_alpha (cr, alpha);
+
+ /* paint watermark */
+ if (priv->watermark) {
+ cairo_text_extents_t extent;
+ cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+ cairo_set_font_size(cr, 12.0);
+ cairo_set_source_rgba(cr, 1, 1, 1, 0.5);
+ cairo_text_extents(cr, priv->watermark, &extent);
+ cairo_move_to(cr, alloc.width - extent.x_advance + extent.x_bearing - 5,
+ alloc.height - extent.height - extent.y_bearing - 5);
+ cairo_show_text(cr, priv->watermark);
+ cairo_stroke(cr);
+ }
+
+ if (!priv->location) {
+ return TRUE;
+ }
+
+ /* paint hilight */
+ file = g_strdup_printf (DATADIR "/timezone_%s.png",
+ g_ascii_formatd (buf, sizeof (buf),
+ "%g", priv->selected_offset));
+ orig_hilight = gdk_pixbuf_new_from_file (file, &err);
+ g_free (file);
+ file = NULL;
+
+ if (!orig_hilight)
+ {
+ g_warning ("Could not load hilight: %s",
+ (err) ? err->message : "Unknown Error");
+ if (err)
+ g_clear_error (&err);
+ }
+ else
+ {
+
+ hilight = gdk_pixbuf_scale_simple (orig_hilight, alloc.width,
+ alloc.height, GDK_INTERP_BILINEAR);
+ gdk_cairo_set_source_pixbuf (cr, hilight, 0, 0);
+
+ cairo_paint_with_alpha (cr, alpha);
+ g_object_unref (hilight);
+ g_object_unref (orig_hilight);
+ }
+
+ /* load pin icon */
+ pin = gdk_pixbuf_new_from_file (DATADIR "/pin.png", &err);
+
+ if (err)
+ {
+ g_warning ("Could not load pin icon: %s", err->message);
+ g_clear_error (&err);
+ }
+
+ pointx = convert_longtitude_to_x (priv->location->longitude, alloc.width);
+ pointy = convert_latitude_to_y (priv->location->latitude, alloc.height);
+
+ if (pointy > alloc.height)
+ pointy = alloc.height;
+
+ if (pin)
+ {
+ gdk_cairo_set_source_pixbuf (cr, pin, pointx - 8, pointy - 14);
+ cairo_paint_with_alpha (cr, alpha);
+ g_object_unref (pin);
+ }
+
+ return TRUE;
+}
+
+#ifndef CCGTK3
+static gboolean
+cc_timezone_map_expose_event (GtkWidget *widget,
+ GdkEventExpose *event)
+{
+ gboolean rv;
+ cairo_t *cr;
+ cr = gdk_cairo_create (widget->window);
+ rv = cc_timezone_map_draw (widget, cr);
+ cairo_destroy (cr);
+ return rv;
+}
+#endif
+
+
+static void
+cc_timezone_map_class_init (CcTimezoneMapClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (CcTimezoneMapPrivate));
+
+ object_class->get_property = cc_timezone_map_get_property;
+ object_class->set_property = cc_timezone_map_set_property;
+ object_class->dispose = cc_timezone_map_dispose;
+ object_class->finalize = cc_timezone_map_finalize;
+
+#ifdef CCGTK3
+ widget_class->get_preferred_width = cc_timezone_map_get_preferred_width;
+ widget_class->get_preferred_height = cc_timezone_map_get_preferred_height;
+#else
+ widget_class->size_request = cc_timezone_map_size_request;
+#endif
+ widget_class->size_allocate = cc_timezone_map_size_allocate;
+ widget_class->realize = cc_timezone_map_realize;
+#ifdef CCGTK3
+ widget_class->draw = cc_timezone_map_draw;
+#else
+ widget_class->expose_event = cc_timezone_map_expose_event;
+#endif
+
+ signals[LOCATION_CHANGED] = g_signal_new ("location-changed",
+ CC_TYPE_TIMEZONE_MAP,
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
+}
+
+
+static gint
+sort_locations (TzLocation *a,
+ TzLocation *b)
+{
+ if (a->dist > b->dist)
+ return 1;
+
+ if (a->dist < b->dist)
+ return -1;
+
+ return 0;
+}
+
+static void
+set_location (CcTimezoneMap *map,
+ TzLocation *location)
+{
+ CcTimezoneMapPrivate *priv = map->priv;
+ TzInfo *info;
+
+ priv->location = location;
+
+ info = tz_info_from_location (priv->location);
+
+ priv->selected_offset = tz_location_get_utc_offset (priv->location)
+ / (60.0*60.0) + ((info->daylight) ? -1.0 : 0.0);
+
+ g_signal_emit (map, signals[LOCATION_CHANGED], 0, priv->location);
+
+ tz_info_free (info);
+}
+
+static TzLocation *
+get_loc_for_xy (GtkWidget * widget, gint x, gint y)
+{
+ CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
+ guchar r, g, b, a;
+ guchar *pixels;
+ gint rowstride;
+ gint i;
+
+ const GPtrArray *array;
+ gint width, height;
+ GList *distances = NULL;
+ GtkAllocation alloc;
+
+ rowstride = priv->visible_map_rowstride;
+ pixels = priv->visible_map_pixels;
+
+ r = pixels[(rowstride * y + x * 4)];
+ g = pixels[(rowstride * y + x * 4) + 1];
+ b = pixels[(rowstride * y + x * 4) + 2];
+ a = pixels[(rowstride * y + x * 4) + 3];
+
+
+ for (i = 0; color_codes[i].offset != -100; i++)
+ {
+ if (color_codes[i].red == r && color_codes[i].green == g
+ && color_codes[i].blue == b && color_codes[i].alpha == a)
+ {
+ priv->selected_offset = color_codes[i].offset;
+ }
+ }
+
+ gtk_widget_queue_draw (widget);
+
+ /* work out the co-ordinates */
+
+ array = tz_get_locations (priv->tzdb);
+
+ gtk_widget_get_allocation (widget, &alloc);
+ width = alloc.width;
+ height = alloc.height;
+
+ for (i = 0; i < array->len; i++)
+ {
+ gdouble pointx, pointy, dx, dy;
+ TzLocation *loc = array->pdata[i];
+
+ pointx = convert_longtitude_to_x (loc->longitude, width);
+ pointy = convert_latitude_to_y (loc->latitude, height);
+
+ dx = pointx - x;
+ dy = pointy - y;
+
+ loc->dist = dx * dx + dy * dy;
+ distances = g_list_prepend (distances, loc);
+
+ }
+ distances = g_list_sort (distances, (GCompareFunc) sort_locations);
+
+ TzLocation * loc = (TzLocation*) distances->data;
+
+ g_list_free (distances);
+
+ return loc;
+}
+
+static gboolean
+button_press_event (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ TzLocation * loc = get_loc_for_xy (widget, event->x, event->y);
+ set_location (CC_TIMEZONE_MAP (widget), loc);
+ return TRUE;
+}
+
+static void
+load_backward_tz (CcTimezoneMap *self)
+{
+ GError *error = NULL;
+ char **lines, *contents;
+ guint i;
+
+ self->priv->alias_db = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+ if (g_file_get_contents (GNOMECC_DATA_DIR "/datetime/backward", &contents, NULL, &error) == FALSE)
+ {
+ g_warning ("Failed to load 'backward' file: %s", error->message);
+ return;
+ }
+ lines = g_strsplit (contents, "\n", -1);
+ g_free (contents);
+ for (i = 0; lines[i] != NULL; i++)
+ {
+ char **items;
+ guint j;
+ char *real, *alias;
+
+ if (g_ascii_strncasecmp (lines[i], "Link\t", 5) != 0)
+ continue;
+
+ items = g_strsplit (lines[i], "\t", -1);
+ real = NULL;
+ alias = NULL;
+ /* Skip the "Link<tab>" part */
+ for (j = 1; items[j] != NULL; j++)
+ {
+ if (items[j][0] == '\0')
+ continue;
+ if (real == NULL)
+ {
+ real = items[j];
+ continue;
+ }
+ alias = items[j];
+ break;
+ }
+
+ if (real == NULL || alias == NULL)
+ g_warning ("Could not parse line: %s", lines[i]);
+
+ g_hash_table_insert (self->priv->alias_db, g_strdup (alias), g_strdup (real));
+ g_strfreev (items);
+ }
+ g_strfreev (lines);
+}
+
+static void
+cc_timezone_map_init (CcTimezoneMap *self)
+{
+ CcTimezoneMapPrivate *priv;
+ GError *err = NULL;
+
+ priv = self->priv = TIMEZONE_MAP_PRIVATE (self);
+
+ priv->orig_background = gdk_pixbuf_new_from_file (DATADIR "/bg.png",
+ &err);
+
+ if (!priv->orig_background)
+ {
+ g_warning ("Could not load background image: %s",
+ (err) ? err->message : "Unknown error");
+ g_clear_error (&err);
+ }
+
+ priv->orig_color_map = gdk_pixbuf_new_from_file (DATADIR "/cc.png",
+ &err);
+ if (!priv->orig_color_map)
+ {
+ g_warning ("Could not load background image: %s",
+ (err) ? err->message : "Unknown error");
+ g_clear_error (&err);
+ }
+
+ priv->olsen_map = gdk_pixbuf_new_from_file (DATADIR "/olsen_map.png",
+ &err);
+ if (!priv->olsen_map)
+ {
+ g_warning ("Could not load olsen map: %s",
+ (err) ? err->message : "Unknown error");
+ g_clear_error (&err);
+ }
+ priv->olsen_map_channels = gdk_pixbuf_get_n_channels (priv->olsen_map);
+ priv->olsen_map_pixels = gdk_pixbuf_get_pixels (priv->olsen_map);
+ priv->olsen_map_rowstride = gdk_pixbuf_get_rowstride (priv->olsen_map);
+
+ priv->tzdb = tz_load_db ();
+
+ g_signal_connect (self, "button-press-event", G_CALLBACK (button_press_event),
+ NULL);
+
+ load_backward_tz (self);
+}
+
+CcTimezoneMap *
+cc_timezone_map_new (void)
+{
+ return g_object_new (CC_TYPE_TIMEZONE_MAP, NULL);
+}
+
+void
+cc_timezone_map_set_timezone (CcTimezoneMap *map,
+ const gchar *timezone)
+{
+ GPtrArray *locations;
+ guint i;
+ char *real_tz;
+
+ real_tz = g_hash_table_lookup (map->priv->alias_db, timezone);
+
+ locations = tz_get_locations (map->priv->tzdb);
+
+ for (i = 0; i < locations->len; i++)
+ {
+ TzLocation *loc = locations->pdata[i];
+
+ if (!g_strcmp0 (loc->zone, real_tz ? real_tz : timezone))
+ {
+ set_location (map, loc);
+ break;
+ }
+ }
+
+ gtk_widget_queue_draw (GTK_WIDGET (map));
+}
+
+void
+cc_timezone_map_set_coords (CcTimezoneMap *map, gdouble lon, gdouble lat)
+{
+ const gchar * zone = cc_timezone_map_get_timezone_at_coords (map, lon, lat);
+ cc_timezone_map_set_timezone (map, zone);
+}
+
+const gchar *
+cc_timezone_map_get_timezone_at_coords (CcTimezoneMap *map, gdouble lon, gdouble lat)
+{
+ gint x = (int)(2048.0 / 360.0 * (180.0 + lon));
+ gint y = (int)(1024.0 / 180.0 * (90.0 - lat));
+ gint offset = map->priv->olsen_map_rowstride * y + x * map->priv->olsen_map_channels;
+ guchar color0 = map->priv->olsen_map_pixels[offset];
+ guchar color1 = map->priv->olsen_map_pixels[offset + 1];
+ gint zone = ((color0 & 248) << 1) + ((color1 >>4) & 15);
+
+ const gchar * city = NULL;
+ if (zone < G_N_ELEMENTS(olsen_map_timezones))
+ city = olsen_map_timezones[zone];
+
+ if (city != NULL) {
+ return city;
+ }
+ else {
+ GtkAllocation alloc;
+ gtk_widget_get_allocation (GTK_WIDGET (map), &alloc);
+ x = convert_longtitude_to_x(lon, alloc.width);
+ y = convert_latitude_to_y(lat, alloc.height);
+ TzLocation * loc = get_loc_for_xy(GTK_WIDGET (map), x, y);
+ return loc->zone;
+ }
+}
+
+void
+cc_timezone_map_set_watermark (CcTimezoneMap *map, const gchar * watermark)
+{
+ if (map->priv->watermark)
+ g_free (map->priv->watermark);
+
+ map->priv->watermark = g_strdup (watermark);
+ gtk_widget_queue_draw (GTK_WIDGET (map));
+}
+
+TzLocation *
+cc_timezone_map_get_location (CcTimezoneMap *map)
+{
+ return map->priv->location;
+}
diff --git a/libmap/cc-timezone-map.h b/libmap/cc-timezone-map.h
new file mode 100644
index 0000000..ace1107
--- /dev/null
+++ b/libmap/cc-timezone-map.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2010 Intel, Inc
+ *
+ * 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.
+ *
+ * Author: Thomas Wood <thomas.wood@intel.com>
+ *
+ */
+
+
+#ifndef _CC_TIMEZONE_MAP_H
+#define _CC_TIMEZONE_MAP_H
+
+#include <gtk/gtk.h>
+#include "tz.h"
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_TIMEZONE_MAP cc_timezone_map_get_type()
+
+#define CC_TIMEZONE_MAP(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ CC_TYPE_TIMEZONE_MAP, CcTimezoneMap))
+
+#define CC_TIMEZONE_MAP_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ CC_TYPE_TIMEZONE_MAP, CcTimezoneMapClass))
+
+#define CC_IS_TIMEZONE_MAP(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ CC_TYPE_TIMEZONE_MAP))
+
+#define CC_IS_TIMEZONE_MAP_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ CC_TYPE_TIMEZONE_MAP))
+
+#define CC_TIMEZONE_MAP_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ CC_TYPE_TIMEZONE_MAP, CcTimezoneMapClass))
+
+typedef struct _CcTimezoneMap CcTimezoneMap;
+typedef struct _CcTimezoneMapClass CcTimezoneMapClass;
+typedef struct _CcTimezoneMapPrivate CcTimezoneMapPrivate;
+
+struct _CcTimezoneMap
+{
+ GtkWidget parent;
+
+ CcTimezoneMapPrivate *priv;
+};
+
+struct _CcTimezoneMapClass
+{
+ GtkWidgetClass parent_class;
+};
+
+GType cc_timezone_map_get_type (void) G_GNUC_CONST;
+
+CcTimezoneMap *cc_timezone_map_new (void);
+
+void cc_timezone_map_set_watermark (CcTimezoneMap * map,
+ const gchar * watermark);
+void cc_timezone_map_set_timezone (CcTimezoneMap *map,
+ const gchar *timezone);
+void cc_timezone_map_set_coords (CcTimezoneMap *map,
+ gdouble lon, gdouble lat);
+const gchar * cc_timezone_map_get_timezone_at_coords (CcTimezoneMap *map,
+ gdouble lon, gdouble lat);
+TzLocation * cc_timezone_map_get_location (CcTimezoneMap *map);
+
+G_END_DECLS
+
+#endif /* _CC_TIMEZONE_MAP_H */
diff --git a/libmap/data/bg.png b/libmap/data/bg.png
new file mode 100644
index 0000000..4180ee8
--- /dev/null
+++ b/libmap/data/bg.png
Binary files differ
diff --git a/libmap/data/cc.png b/libmap/data/cc.png
new file mode 100644
index 0000000..54fb668
--- /dev/null
+++ b/libmap/data/cc.png
Binary files differ
diff --git a/libmap/data/olsen_map.png b/libmap/data/olsen_map.png
new file mode 100644
index 0000000..f9bb75c
--- /dev/null
+++ b/libmap/data/olsen_map.png
Binary files differ
diff --git a/libmap/data/pin.png b/libmap/data/pin.png
new file mode 100644
index 0000000..599a751
--- /dev/null
+++ b/libmap/data/pin.png
Binary files differ
diff --git a/libmap/data/timezone_-1.png b/libmap/data/timezone_-1.png
new file mode 100644
index 0000000..fb00d83
--- /dev/null
+++ b/libmap/data/timezone_-1.png
Binary files differ
diff --git a/libmap/data/timezone_-10.png b/libmap/data/timezone_-10.png
new file mode 100644
index 0000000..472eb88
--- /dev/null
+++ b/libmap/data/timezone_-10.png
Binary files differ
diff --git a/libmap/data/timezone_-11.png b/libmap/data/timezone_-11.png
new file mode 100644
index 0000000..5f8c5d6
--- /dev/null
+++ b/libmap/data/timezone_-11.png
Binary files differ
diff --git a/libmap/data/timezone_-2.png b/libmap/data/timezone_-2.png
new file mode 100644
index 0000000..30a1ec7
--- /dev/null
+++ b/libmap/data/timezone_-2.png
Binary files differ
diff --git a/libmap/data/timezone_-3.5.png b/libmap/data/timezone_-3.5.png
new file mode 100644
index 0000000..c1df00b
--- /dev/null
+++ b/libmap/data/timezone_-3.5.png
Binary files differ
diff --git a/libmap/data/timezone_-3.png b/libmap/data/timezone_-3.png
new file mode 100644
index 0000000..c22dbb6
--- /dev/null
+++ b/libmap/data/timezone_-3.png
Binary files differ
diff --git a/libmap/data/timezone_-4.5.png b/libmap/data/timezone_-4.5.png
new file mode 100644
index 0000000..9e3c134
--- /dev/null
+++ b/libmap/data/timezone_-4.5.png
Binary files differ
diff --git a/libmap/data/timezone_-4.png b/libmap/data/timezone_-4.png
new file mode 100644
index 0000000..4b5a431
--- /dev/null
+++ b/libmap/data/timezone_-4.png
Binary files differ
diff --git a/libmap/data/timezone_-5.5.png b/libmap/data/timezone_-5.5.png
new file mode 100644
index 0000000..b1c788d
--- /dev/null
+++ b/libmap/data/timezone_-5.5.png
Binary files differ
diff --git a/libmap/data/timezone_-5.png b/libmap/data/timezone_-5.png
new file mode 100644
index 0000000..06c15e6
--- /dev/null
+++ b/libmap/data/timezone_-5.png
Binary files differ
diff --git a/libmap/data/timezone_-6.png b/libmap/data/timezone_-6.png
new file mode 100644
index 0000000..8505fb1
--- /dev/null
+++ b/libmap/data/timezone_-6.png
Binary files differ
diff --git a/libmap/data/timezone_-7.png b/libmap/data/timezone_-7.png
new file mode 100644
index 0000000..fec235d
--- /dev/null
+++ b/libmap/data/timezone_-7.png
Binary files differ
diff --git a/libmap/data/timezone_-8.png b/libmap/data/timezone_-8.png
new file mode 100644
index 0000000..bdad7bf
--- /dev/null
+++ b/libmap/data/timezone_-8.png
Binary files differ
diff --git a/libmap/data/timezone_-9.5.png b/libmap/data/timezone_-9.5.png
new file mode 100644
index 0000000..b1c788d
--- /dev/null
+++ b/libmap/data/timezone_-9.5.png
Binary files differ
diff --git a/libmap/data/timezone_-9.png b/libmap/data/timezone_-9.png
new file mode 100644
index 0000000..04cb3cb
--- /dev/null
+++ b/libmap/data/timezone_-9.png
Binary files differ
diff --git a/libmap/data/timezone_0.png b/libmap/data/timezone_0.png
new file mode 100644
index 0000000..e59b773
--- /dev/null
+++ b/libmap/data/timezone_0.png
Binary files differ
diff --git a/libmap/data/timezone_1.png b/libmap/data/timezone_1.png
new file mode 100644
index 0000000..2053b7e
--- /dev/null
+++ b/libmap/data/timezone_1.png
Binary files differ
diff --git a/libmap/data/timezone_10.5.png b/libmap/data/timezone_10.5.png
new file mode 100644
index 0000000..6ec7f9f
--- /dev/null
+++ b/libmap/data/timezone_10.5.png
Binary files differ
diff --git a/libmap/data/timezone_10.png b/libmap/data/timezone_10.png
new file mode 100644
index 0000000..475dcf4
--- /dev/null
+++ b/libmap/data/timezone_10.png
Binary files differ
diff --git a/libmap/data/timezone_11.5.png b/libmap/data/timezone_11.5.png
new file mode 100644
index 0000000..afdedd7
--- /dev/null
+++ b/libmap/data/timezone_11.5.png
Binary files differ
diff --git a/libmap/data/timezone_11.png b/libmap/data/timezone_11.png
new file mode 100644
index 0000000..6168aa2
--- /dev/null
+++ b/libmap/data/timezone_11.png
Binary files differ
diff --git a/libmap/data/timezone_12.75.png b/libmap/data/timezone_12.75.png
new file mode 100644
index 0000000..4f74a85
--- /dev/null
+++ b/libmap/data/timezone_12.75.png
Binary files differ
diff --git a/libmap/data/timezone_12.png b/libmap/data/timezone_12.png
new file mode 100644
index 0000000..d0b3531
--- /dev/null
+++ b/libmap/data/timezone_12.png
Binary files differ
diff --git a/libmap/data/timezone_13.png b/libmap/data/timezone_13.png
new file mode 100644
index 0000000..fe2f134
--- /dev/null
+++ b/libmap/data/timezone_13.png
Binary files differ
diff --git a/libmap/data/timezone_2.png b/libmap/data/timezone_2.png
new file mode 100644
index 0000000..ec1e874
--- /dev/null
+++ b/libmap/data/timezone_2.png
Binary files differ
diff --git a/libmap/data/timezone_3.5.png b/libmap/data/timezone_3.5.png
new file mode 100644
index 0000000..2dc7399
--- /dev/null
+++ b/libmap/data/timezone_3.5.png
Binary files differ
diff --git a/libmap/data/timezone_3.png b/libmap/data/timezone_3.png
new file mode 100644
index 0000000..eda59dc
--- /dev/null
+++ b/libmap/data/timezone_3.png
Binary files differ
diff --git a/libmap/data/timezone_4.5.png b/libmap/data/timezone_4.5.png
new file mode 100644
index 0000000..e09ed90
--- /dev/null
+++ b/libmap/data/timezone_4.5.png
Binary files differ
diff --git a/libmap/data/timezone_4.png b/libmap/data/timezone_4.png
new file mode 100644
index 0000000..483dc53
--- /dev/null
+++ b/libmap/data/timezone_4.png
Binary files differ
diff --git a/libmap/data/timezone_5.5.png b/libmap/data/timezone_5.5.png
new file mode 100644
index 0000000..f904cc2
--- /dev/null
+++ b/libmap/data/timezone_5.5.png
Binary files differ
diff --git a/libmap/data/timezone_5.75.png b/libmap/data/timezone_5.75.png
new file mode 100644
index 0000000..827ce1a
--- /dev/null
+++ b/libmap/data/timezone_5.75.png
Binary files differ
diff --git a/libmap/data/timezone_5.png b/libmap/data/timezone_5.png
new file mode 100644
index 0000000..1bb6d20
--- /dev/null
+++ b/libmap/data/timezone_5.png
Binary files differ
diff --git a/libmap/data/timezone_6.5.png b/libmap/data/timezone_6.5.png
new file mode 100644
index 0000000..d307bf3
--- /dev/null
+++ b/libmap/data/timezone_6.5.png
Binary files differ
diff --git a/libmap/data/timezone_6.png b/libmap/data/timezone_6.png
new file mode 100644
index 0000000..460f9cf
--- /dev/null
+++ b/libmap/data/timezone_6.png
Binary files differ
diff --git a/libmap/data/timezone_7.png b/libmap/data/timezone_7.png
new file mode 100644
index 0000000..239115a
--- /dev/null
+++ b/libmap/data/timezone_7.png
Binary files differ
diff --git a/libmap/data/timezone_8.png b/libmap/data/timezone_8.png
new file mode 100644
index 0000000..3627686
--- /dev/null
+++ b/libmap/data/timezone_8.png
Binary files differ
diff --git a/libmap/data/timezone_9.5.png b/libmap/data/timezone_9.5.png
new file mode 100644
index 0000000..1c3290c
--- /dev/null
+++ b/libmap/data/timezone_9.5.png
Binary files differ
diff --git a/libmap/data/timezone_9.png b/libmap/data/timezone_9.png
new file mode 100644
index 0000000..65d2e46
--- /dev/null
+++ b/libmap/data/timezone_9.png
Binary files differ
diff --git a/libmap/test-timezone.c b/libmap/test-timezone.c
new file mode 100644
index 0000000..c1935fd
--- /dev/null
+++ b/libmap/test-timezone.c
@@ -0,0 +1,56 @@
+#include <config.h>
+#include <locale.h>
+
+#include "tz.h"
+
+int main (int argc, char **argv)
+{
+ TzDB *db;
+ GPtrArray *locs;
+ guint i;
+ char *pixmap_dir;
+ int retval = 0;
+
+ setlocale (LC_ALL, "");
+
+ if (argc == 2) {
+ pixmap_dir = g_strdup (argv[1]);
+ } else if (argc == 1) {
+ pixmap_dir = g_strdup ("data/");
+ } else {
+ g_message ("Usage: %s [PIXMAP DIRECTORY]", argv[0]);
+ return 1;
+ }
+
+ db = tz_load_db ();
+ locs = tz_get_locations (db);
+ for (i = 0; i < locs->len ; i++) {
+ TzLocation *loc = locs->pdata[i];
+ TzInfo *info;
+ char *filename, *path;
+ gdouble selected_offset;
+ char buf[16];
+
+ info = tz_info_from_location (loc);
+ selected_offset = tz_location_get_utc_offset (loc)
+ / (60.0*60.0) + ((info->daylight) ? -1.0 : 0.0);
+
+ filename = g_strdup_printf ("timezone_%s.png",
+ g_ascii_formatd (buf, sizeof (buf),
+ "%g", selected_offset));
+ path = g_build_filename (pixmap_dir, filename, NULL);
+
+ if (g_file_test (path, G_FILE_TEST_IS_REGULAR) == FALSE) {
+ g_message ("File '%s' missing for zone '%s'", filename, loc->zone);
+ retval = 1;
+ }
+
+ g_free (filename);
+ g_free (path);
+ tz_info_free (info);
+ }
+ tz_db_free (db);
+ g_free (pixmap_dir);
+
+ return retval;
+}
diff --git a/libmap/tz.c b/libmap/tz.c
new file mode 100644
index 0000000..b77a8ef
--- /dev/null
+++ b/libmap/tz.c
@@ -0,0 +1,399 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* Generic timezone utilities.
+ *
+ * Copyright (C) 2000-2001 Ximian, Inc.
+ *
+ * Authors: Hans Petter Jansson <hpj@ximian.com>
+ *
+ * Largely based on Michael Fulbright's work on Anaconda.
+ *
+ * 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.
+ */
+
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+#include <math.h>
+#include <string.h>
+#include "tz.h"
+
+
+/* Forward declarations for private functions */
+
+static float convert_pos (gchar *pos, int digits);
+static int compare_country_names (const void *a, const void *b);
+static void sort_locations_by_country (GPtrArray *locations);
+static gchar * tz_data_file_get (void);
+
+
+/* ---------------- *
+ * Public interface *
+ * ---------------- */
+TzDB *
+tz_load_db (void)
+{
+ gchar *tz_data_file;
+ TzDB *tz_db;
+ FILE *tzfile;
+ char buf[4096];
+
+ tz_data_file = tz_data_file_get ();
+ if (!tz_data_file) {
+ g_warning ("Could not get the TimeZone data file name");
+ return NULL;
+ }
+ tzfile = fopen (tz_data_file, "r");
+ if (!tzfile) {
+ g_warning ("Could not open *%s*\n", tz_data_file);
+ g_free (tz_data_file);
+ return NULL;
+ }
+
+ tz_db = g_new0 (TzDB, 1);
+ tz_db->locations = g_ptr_array_new ();
+
+ while (fgets (buf, sizeof(buf), tzfile))
+ {
+ gchar **tmpstrarr;
+ gchar *latstr, *lngstr, *p;
+ TzLocation *loc;
+
+ if (*buf == '#') continue;
+
+ g_strchomp(buf);
+ tmpstrarr = g_strsplit(buf,"\t", 6);
+
+ latstr = g_strdup (tmpstrarr[1]);
+ p = latstr + 1;
+ while (*p != '-' && *p != '+') p++;
+ lngstr = g_strdup (p);
+ *p = '\0';
+
+ loc = g_new0 (TzLocation, 1);
+ loc->country = g_strdup (tmpstrarr[0]);
+ loc->zone = g_strdup (tmpstrarr[2]);
+ loc->latitude = convert_pos (latstr, 2);
+ loc->longitude = convert_pos (lngstr, 3);
+
+#ifdef __sun
+ if (tmpstrarr[3] && *tmpstrarr[3] == '-' && tmpstrarr[4])
+ loc->comment = g_strdup (tmpstrarr[4]);
+
+ if (tmpstrarr[3] && *tmpstrarr[3] != '-' && !islower(loc->zone)) {
+ TzLocation *locgrp;
+
+ /* duplicate entry */
+ locgrp = g_new0 (TzLocation, 1);
+ locgrp->country = g_strdup (tmpstrarr[0]);
+ locgrp->zone = g_strdup (tmpstrarr[3]);
+ locgrp->latitude = convert_pos (latstr, 2);
+ locgrp->longitude = convert_pos (lngstr, 3);
+ locgrp->comment = (tmpstrarr[4]) ? g_strdup (tmpstrarr[4]) : NULL;
+
+ g_ptr_array_add (tz_db->locations, (gpointer) locgrp);
+ }
+#else
+ loc->comment = (tmpstrarr[3]) ? g_strdup(tmpstrarr[3]) : NULL;
+#endif
+
+ g_ptr_array_add (tz_db->locations, (gpointer) loc);
+
+ g_free (latstr);
+ g_free (lngstr);
+ g_strfreev (tmpstrarr);
+ }
+
+ fclose (tzfile);
+
+ /* now sort by country */
+ sort_locations_by_country (tz_db->locations);
+
+ g_free (tz_data_file);
+
+ return tz_db;
+}
+
+static void
+tz_location_free (TzLocation *loc)
+{
+ g_free (loc->country);
+ g_free (loc->zone);
+ g_free (loc->comment);
+
+ g_free (loc);
+}
+
+void
+tz_db_free (TzDB *db)
+{
+ g_ptr_array_foreach (db->locations, (GFunc) tz_location_free, NULL);
+ g_ptr_array_free (db->locations, TRUE);
+ g_free (db);
+}
+
+static gint
+sort_locations (TzLocation *a,
+ TzLocation *b)
+{
+ if (a->dist > b->dist)
+ return 1;
+
+ if (a->dist < b->dist)
+ return -1;
+
+ return 0;
+}
+
+static gdouble
+convert_longtitude_to_x (gdouble longitude, gint map_width)
+{
+ const gdouble xdeg_offset = -6;
+ gdouble x;
+
+ x = (map_width * (180.0 + longitude) / 360.0)
+ + (map_width * xdeg_offset / 180.0);
+
+ return x;
+}
+
+static gdouble
+radians (gdouble degrees)
+{
+ return (degrees / 360.0) * G_PI * 2;
+}
+
+static gdouble
+convert_latitude_to_y (gdouble latitude, gdouble map_height)
+{
+ gdouble bottom_lat = -59;
+ gdouble top_lat = 81;
+ gdouble top_per, y, full_range, top_offset, map_range;
+
+ top_per = top_lat / 180.0;
+ y = 1.25 * log (tan (G_PI_4 + 0.4 * radians (latitude)));
+ full_range = 4.6068250867599998;
+ top_offset = full_range * top_per;
+ map_range = fabs (1.25 * log (tan (G_PI_4 + 0.4 * radians (bottom_lat))) - top_offset);
+ y = fabs (y - top_offset);
+ y = y / map_range;
+ y = y * map_height;
+ return y;
+}
+
+GPtrArray *
+tz_get_locations (TzDB *db)
+{
+ return db->locations;
+}
+
+
+gchar *
+tz_location_get_country (TzLocation *loc)
+{
+ return loc->country;
+}
+
+
+gchar *
+tz_location_get_zone (TzLocation *loc)
+{
+ return loc->zone;
+}
+
+
+gchar *
+tz_location_get_comment (TzLocation *loc)
+{
+ return loc->comment;
+}
+
+
+void
+tz_location_get_position (TzLocation *loc, double *longitude, double *latitude)
+{
+ *longitude = loc->longitude;
+ *latitude = loc->latitude;
+}
+
+glong
+tz_location_get_utc_offset (TzLocation *loc)
+{
+ TzInfo *tz_info;
+ glong offset;
+
+ tz_info = tz_info_from_location (loc);
+ offset = tz_info->utc_offset;
+ tz_info_free (tz_info);
+ return offset;
+}
+
+gint
+tz_location_set_locally (TzLocation *loc)
+{
+ time_t curtime;
+ struct tm *curzone;
+ gboolean is_dst = FALSE;
+ gint correction = 0;
+
+ g_return_val_if_fail (loc != NULL, 0);
+ g_return_val_if_fail (loc->zone != NULL, 0);
+
+ curtime = time (NULL);
+ curzone = localtime (&curtime);
+ is_dst = curzone->tm_isdst;
+
+ setenv ("TZ", loc->zone, 1);
+#if 0
+ curtime = time (NULL);
+ curzone = localtime (&curtime);
+
+ if (!is_dst && curzone->tm_isdst) {
+ correction = (60 * 60);
+ }
+ else if (is_dst && !curzone->tm_isdst) {
+ correction = 0;
+ }
+#endif
+
+ return correction;
+}
+
+TzInfo *
+tz_info_from_location (TzLocation *loc)
+{
+ TzInfo *tzinfo;
+ time_t curtime;
+ struct tm *curzone;
+
+ g_return_val_if_fail (loc != NULL, NULL);
+ g_return_val_if_fail (loc->zone != NULL, NULL);
+
+ setenv ("TZ", loc->zone, 1);
+
+#if 0
+ tzset ();
+#endif
+ tzinfo = g_new0 (TzInfo, 1);
+
+ curtime = time (NULL);
+ curzone = localtime (&curtime);
+
+#ifndef __sun
+ /* Currently this solution doesnt seem to work - I get that */
+ /* America/Phoenix uses daylight savings, which is wrong */
+ tzinfo->tzname_normal = g_strdup (curzone->tm_zone);
+ if (curzone->tm_isdst)
+ tzinfo->tzname_daylight =
+ g_strdup (&curzone->tm_zone[curzone->tm_isdst]);
+ else
+ tzinfo->tzname_daylight = NULL;
+
+ tzinfo->utc_offset = curzone->tm_gmtoff;
+#else
+ tzinfo->tzname_normal = NULL;
+ tzinfo->tzname_daylight = NULL;
+ tzinfo->utc_offset = 0;
+#endif
+
+ tzinfo->daylight = curzone->tm_isdst;
+
+ return tzinfo;
+}
+
+
+void
+tz_info_free (TzInfo *tzinfo)
+{
+ g_return_if_fail (tzinfo != NULL);
+
+ if (tzinfo->tzname_normal) g_free (tzinfo->tzname_normal);
+ if (tzinfo->tzname_daylight) g_free (tzinfo->tzname_daylight);
+ g_free (tzinfo);
+}
+
+/* ----------------- *
+ * Private functions *
+ * ----------------- */
+
+static gchar *
+tz_data_file_get (void)
+{
+ gchar *file;
+
+ file = g_strdup (TZ_DATA_FILE);
+
+ return file;
+}
+
+static float
+convert_pos (gchar *pos, int digits)
+{
+ gchar whole[10];
+ gchar *fraction;
+ gint i;
+ float t1, t2;
+
+ if (!pos || strlen(pos) < 4 || digits > 9) return 0.0;
+
+ for (i = 0; i < digits + 1; i++) whole[i] = pos[i];
+ whole[i] = '\0';
+ fraction = pos + digits + 1;
+
+ t1 = g_strtod (whole, NULL);
+ t2 = g_strtod (fraction, NULL);
+
+ if (t1 >= 0.0) return t1 + t2/pow (10.0, strlen(fraction));
+ else return t1 - t2/pow (10.0, strlen(fraction));
+}
+
+
+#if 0
+
+/* Currently not working */
+static void
+free_tzdata (TzLocation *tz)
+{
+
+ if (tz->country)
+ g_free(tz->country);
+ if (tz->zone)
+ g_free(tz->zone);
+ if (tz->comment)
+ g_free(tz->comment);
+
+ g_free(tz);
+}
+#endif
+
+
+static int
+compare_country_names (const void *a, const void *b)
+{
+ const TzLocation *tza = * (TzLocation **) a;
+ const TzLocation *tzb = * (TzLocation **) b;
+
+ return strcmp (tza->zone, tzb->zone);
+}
+
+
+static void
+sort_locations_by_country (GPtrArray *locations)
+{
+ qsort (locations->pdata, locations->len, sizeof (gpointer),
+ compare_country_names);
+}
diff --git a/libmap/tz.h b/libmap/tz.h
new file mode 100644
index 0000000..91281a5
--- /dev/null
+++ b/libmap/tz.h
@@ -0,0 +1,86 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* Generic timezone utilities.
+ *
+ * Copyright (C) 2000-2001 Ximian, Inc.
+ *
+ * Authors: Hans Petter Jansson <hpj@ximian.com>
+ *
+ * Largely based on Michael Fulbright's work on Anaconda.
+ *
+ * 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.
+ */
+
+
+#ifndef _E_TZ_H
+#define _E_TZ_H
+
+#include <glib.h>
+
+#ifndef __sun
+# define TZ_DATA_FILE "/usr/share/zoneinfo/zone.tab"
+#else
+# define TZ_DATA_FILE "/usr/share/lib/zoneinfo/tab/zone_sun.tab"
+#endif
+
+typedef struct _TzDB TzDB;
+typedef struct _TzLocation TzLocation;
+typedef struct _TzInfo TzInfo;
+
+
+struct _TzDB
+{
+ GPtrArray *locations;
+};
+
+struct _TzLocation
+{
+ gchar *country;
+ gdouble latitude;
+ gdouble longitude;
+ gchar *zone;
+ gchar *comment;
+
+ gdouble dist; /* distance to clicked point for comparison */
+};
+
+/* see the glibc info page information on time zone information */
+/* tzname_normal is the default name for the timezone */
+/* tzname_daylight is the name of the zone when in daylight savings */
+/* utc_offset is offset in seconds from utc */
+/* daylight if non-zero then location obeys daylight savings */
+
+struct _TzInfo
+{
+ gchar *tzname_normal;
+ gchar *tzname_daylight;
+ glong utc_offset;
+ gint daylight;
+};
+
+
+TzDB *tz_load_db (void);
+void tz_db_free (TzDB *db);
+GPtrArray *tz_get_locations (TzDB *db);
+void tz_location_get_position (TzLocation *loc,
+ double *longitude, double *latitude);
+char *tz_location_get_country (TzLocation *loc);
+gchar *tz_location_get_zone (TzLocation *loc);
+gchar *tz_location_get_comment (TzLocation *loc);
+glong tz_location_get_utc_offset (TzLocation *loc);
+gint tz_location_set_locally (TzLocation *loc);
+TzInfo *tz_info_from_location (TzLocation *loc);
+void tz_info_free (TzInfo *tz_info);
+
+#endif
diff --git a/po/LINGUAS b/po/LINGUAS
new file mode 100644
index 0000000..dd5940e
--- /dev/null
+++ b/po/LINGUAS
@@ -0,0 +1,31 @@
+ar
+bg
+cs
+da
+de
+el
+es
+fi
+fr
+he
+hi
+hr
+hu
+it
+ja
+ko
+nb
+nl
+pl
+pt
+pt_BR
+ro
+ru
+sk
+sl
+sr
+sv
+th
+tr
+zh_CN
+zh_TW
diff --git a/po/Makevars b/po/Makevars
new file mode 100644
index 0000000..e877468
--- /dev/null
+++ b/po/Makevars
@@ -0,0 +1,7 @@
+DOMAIN = $(PACKAGE)
+subdir = po
+top_builddir = ..
+XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=T_ --from-code=UTF-8
+COPYRIGHT_HOLDER = Canonical Ltd.
+MSGID_BUGS_ADDRESS = ted@canonical.com
+EXTRA_LOCALE_CATEGORIES =
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644
index 0000000..d22e5f9
--- /dev/null
+++ b/po/POTFILES.in
@@ -0,0 +1,8 @@
+src/indicator-datetime.c
+src/datetime-service.c
+src/datetime-prefs.c
+src/datetime-prefs-locations.c
+src/utils.c
+src/settings-shared.h
+[type: gettext/glade]data/datetime-dialog.ui
+data/indicator-datetime-preferences.desktop.in
diff --git a/po/ar.po b/po/ar.po
new file mode 100644
index 0000000..96ad24b
--- /dev/null
+++ b/po/ar.po
@@ -0,0 +1,44 @@
+# Arabic translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:05-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Arabic\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "خطأ في الحصول على الوقت"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d صباحا"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d مساء"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "التقويم المفتوح (Open Calendar)"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "ضبط الوقت والتاريخ..."
diff --git a/po/bg.po b/po/bg.po
new file mode 100644
index 0000000..0eaac8a
--- /dev/null
+++ b/po/bg.po
@@ -0,0 +1,44 @@
+# Bulgarian translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:05-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Bulgarian\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Грешка при проверка на време"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d преди обяд"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d следобед"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Отвори календар"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Свери час и дата..."
diff --git a/po/cs.po b/po/cs.po
new file mode 100644
index 0000000..6cfd9bb
--- /dev/null
+++ b/po/cs.po
@@ -0,0 +1,45 @@
+# Czech translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Czech\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Chyba získání času"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d dop."
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d odp."
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Otevřít kalendář"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Nastavit čas a datum..."
diff --git a/po/da.po b/po/da.po
new file mode 100644
index 0000000..684f89e
--- /dev/null
+++ b/po/da.po
@@ -0,0 +1,45 @@
+# Danish translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Danish\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Fejl ved hentning af klokkeslæt"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d.%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d.%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Åbn Kalender"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Indstil klokkeslæt og dato..."
diff --git a/po/de.po b/po/de.po
new file mode 100644
index 0000000..93f2748
--- /dev/null
+++ b/po/de.po
@@ -0,0 +1,45 @@
+# German translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: German\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Fehler beim Abrufen der Zeit"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Kalender öffnen"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Datum und Uhrzeit einstellen."
diff --git a/po/el.po b/po/el.po
new file mode 100644
index 0000000..9355a53
--- /dev/null
+++ b/po/el.po
@@ -0,0 +1,45 @@
+# Greek translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Greek\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Σφάλμα κατά τη λήψη του χρόνου"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d π.μ."
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d μ.μ."
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Άνοιγμα ημερολογίου"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Ορισμός ώρας και ημερομηνίας..."
diff --git a/po/es.po b/po/es.po
new file mode 100644
index 0000000..4dcafd3
--- /dev/null
+++ b/po/es.po
@@ -0,0 +1,45 @@
+# Spanish translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Spanish\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Error al obtener la hora"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Abrir calendario"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Ajustar fecha y hora..."
diff --git a/po/fi.po b/po/fi.po
new file mode 100644
index 0000000..ed15e58
--- /dev/null
+++ b/po/fi.po
@@ -0,0 +1,45 @@
+# Finnish translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Finnish\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Virheen noudettaessa aikaa"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AP"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d IP"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Avaa kalenteri"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Aseta kellonaika ja päivämäärä..."
diff --git a/po/fr.po b/po/fr.po
new file mode 100644
index 0000000..930ef4d
--- /dev/null
+++ b/po/fr.po
@@ -0,0 +1,45 @@
+# French translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: French\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Erreur lors de l'obtention de l'heure"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Ouvrir le calendrier"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Régler la date et l'heure..."
diff --git a/po/he.po b/po/he.po
new file mode 100644
index 0000000..20b41bb
--- /dev/null
+++ b/po/he.po
@@ -0,0 +1,45 @@
+# Hebrew translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Hebrew\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "שגיאה בקבלת השעה"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "פתח לוח שנה"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "הגדרת שעה ותאריך..."
diff --git a/po/hi.po b/po/hi.po
new file mode 100644
index 0000000..3f453c0
--- /dev/null
+++ b/po/hi.po
@@ -0,0 +1,44 @@
+# Hindi translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Hindi\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "समय प्राप्त करने में त्रुटि"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "प्रातः %d%d:%d%d बजे"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "सायं %d%d:%d%d बजे"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "कैलेंडर खोलें"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "समय और तिथि सेट करें..."
diff --git a/po/hr.po b/po/hr.po
new file mode 100644
index 0000000..66c28d4
--- /dev/null
+++ b/po/hr.po
@@ -0,0 +1,46 @@
+# Croatian translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Croatian\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%"
+"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Greška pri dohvaćanju vremena"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Otvori kalendar"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Postavi vrijeme i datum..."
diff --git a/po/hu.po b/po/hu.po
new file mode 100644
index 0000000..de2bcee
--- /dev/null
+++ b/po/hu.po
@@ -0,0 +1,45 @@
+# Hungarian translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Hungarian\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Hiba az idő lekérésekor"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d de."
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d du."
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Naptár megnyitása"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Idő és dátum beállítása..."
diff --git a/po/it.po b/po/it.po
new file mode 100644
index 0000000..839ab2e
--- /dev/null
+++ b/po/it.po
@@ -0,0 +1,45 @@
+# Italian translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Italian\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Errore nell'acquisizione dell'orario"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Apri calendario"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Imposta data e ora..."
diff --git a/po/ja.po b/po/ja.po
new file mode 100644
index 0000000..02c90b7
--- /dev/null
+++ b/po/ja.po
@@ -0,0 +1,45 @@
+# Japanese translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Japanese\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "時刻を取得できません"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "午前 %d%d:%d%d"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "午後 %d%d:%d%d"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "カレンダーを開く"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "時刻と日付の設定..."
diff --git a/po/ko.po b/po/ko.po
new file mode 100644
index 0000000..0406690
--- /dev/null
+++ b/po/ko.po
@@ -0,0 +1,45 @@
+# Korean translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Korean\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "시간 가져오기 오류"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "오전 %d%d:%d%d"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "오후 %d%d:%d%d"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "일정 열기"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "시간 및 날짜 설정..."
diff --git a/po/nb.po b/po/nb.po
new file mode 100644
index 0000000..deb0de8
--- /dev/null
+++ b/po/nb.po
@@ -0,0 +1,45 @@
+# Norwegian Bokmal translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Norwegian Bokmal\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Feil under henting av klokkeslett"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Åpne kalender"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Angi dato og klokkeslett..."
diff --git a/po/nl.po b/po/nl.po
new file mode 100644
index 0000000..96df725
--- /dev/null
+++ b/po/nl.po
@@ -0,0 +1,45 @@
+# Dutch translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Dutch\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Fout bij lezen van tijd"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d%d%d VM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d%d%d NM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Kalender openen"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Datum en tijd instellen..."
diff --git a/po/pl.po b/po/pl.po
new file mode 100644
index 0000000..6be96db
--- /dev/null
+++ b/po/pl.po
@@ -0,0 +1,46 @@
+# Polish translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Polish\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
+"|| n%100>=20) ? 1 : 2);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Wystąpił błąd pobierania godziny"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Otwórz kalendarz"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Ustaw godzinę i datę..."
diff --git a/po/pt.po b/po/pt.po
new file mode 100644
index 0000000..fb6a0f0
--- /dev/null
+++ b/po/pt.po
@@ -0,0 +1,45 @@
+# Portuguese translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Portuguese\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Erro na obtenção das horas"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Abrir Calendário"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Acertar Hora e Data..."
diff --git a/po/pt_BR.po b/po/pt_BR.po
new file mode 100644
index 0000000..1795ceb
--- /dev/null
+++ b/po/pt_BR.po
@@ -0,0 +1,45 @@
+# Portuguese translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Brazilian Portuguese\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Erro ao obter hora"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Abrir o calendário"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Ajustar data e hora..."
diff --git a/po/ro.po b/po/ro.po
new file mode 100644
index 0000000..3eb1bf9
--- /dev/null
+++ b/po/ro.po
@@ -0,0 +1,46 @@
+# Romanian translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Romanian\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < "
+"20)) ? 1 : 2;\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Eroare la obținerea orei"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Deschide calendarul"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Setare oră și dată..."
diff --git a/po/ru.po b/po/ru.po
new file mode 100644
index 0000000..b4e54e2
--- /dev/null
+++ b/po/ru.po
@@ -0,0 +1,46 @@
+# Russian translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Russian\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%"
+"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Ошибка получения времени"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Открыть календарь"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Установить время и дату..."
diff --git a/po/sk.po b/po/sk.po
new file mode 100644
index 0000000..9c47050
--- /dev/null
+++ b/po/sk.po
@@ -0,0 +1,45 @@
+# Slovak translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Slovak\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Čas zistenia chyby"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Otvoriť kalendár"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Nastaviť čas a dátum..."
diff --git a/po/sl.po b/po/sl.po
new file mode 100644
index 0000000..012ff00
--- /dev/null
+++ b/po/sl.po
@@ -0,0 +1,46 @@
+# Slovenian translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Slovenian\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n"
+"%100==4 ? 2 : 3);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Napaka pri pridobivanju podatka o času"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Odpri koledar"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Nastavi čas in datum ..."
diff --git a/po/sr.po b/po/sr.po
new file mode 100644
index 0000000..df6149a
--- /dev/null
+++ b/po/sr.po
@@ -0,0 +1,46 @@
+# Serbian translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Serbian\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%"
+"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Greška u prikazu vremena"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d%d%d pre podne"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d%d%d popodne"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Otvori kalendar"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Podesi vreme i datum"
diff --git a/po/sv.po b/po/sv.po
new file mode 100644
index 0000000..585daeb
--- /dev/null
+++ b/po/sv.po
@@ -0,0 +1,45 @@
+# Swedish translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Swedish\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Ett fel uppstod då tid hämtades"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d FM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d EM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Öppna kalender"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Ange tid och datum..."
diff --git a/po/th.po b/po/th.po
new file mode 100644
index 0000000..fd7e2ac
--- /dev/null
+++ b/po/th.po
@@ -0,0 +1,44 @@
+# Thai translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Thai\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "ข้อผิดพลาดการขอข้อมูลเวลา"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d AM"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d PM"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "เปิดปฏิทิน"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "ตั้งเวลาและวันที่..."
diff --git a/po/tr.po b/po/tr.po
new file mode 100644
index 0000000..8ad85a6
--- /dev/null
+++ b/po/tr.po
@@ -0,0 +1,45 @@
+# Turkish translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Turkish\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "Saati alma hatâsı"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "Öğleden Önce %d%d:%d%d"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "Öğleden Sonra %d%d:%d%d"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "Takvimi Aç"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "Saati ve Târihi Ayarla..."
diff --git a/po/zh_CN.po b/po/zh_CN.po
new file mode 100644
index 0000000..fb74d02
--- /dev/null
+++ b/po/zh_CN.po
@@ -0,0 +1,44 @@
+# Chinese translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Chinese (simplified)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "获取时间出错"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d 上午"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d 下午"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "打开日历"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "设置时间和日期..."
diff --git a/po/zh_TW.po b/po/zh_TW.po
new file mode 100644
index 0000000..ec58031
--- /dev/null
+++ b/po/zh_TW.po
@@ -0,0 +1,44 @@
+# Chinese translations for PACKAGE package.
+# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Canonical OEM, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: indicator-datetime\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 15:20-0500\n"
+"PO-Revision-Date: 2010-03-03 10:06-0500\n"
+"Last-Translator: Canonical OEM\n"
+"Language-Team: Chinese (traditional)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../src/indicator-datetime.c:177
+msgid "Error getting time"
+msgstr "獲得時間發生錯誤"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:259
+#, c-format
+msgid "%d%d:%d%d AM"
+msgstr "%d%d:%d%d 上午"
+
+#. TRANSLATORS: This string is used for measuring the size of
+#. the font used for showing the time and is not shown to the
+#. user anywhere.
+#: ../src/indicator-datetime.c:266
+#, c-format
+msgid "%d%d:%d%d PM"
+msgstr "%d%d:%d%d 下午"
+
+#: ../src/indicator-datetime.c:351
+msgid "Open Calendar"
+msgstr "開啟行事曆"
+
+#: ../src/indicator-datetime.c:361
+msgid "Set Time and Date..."
+msgstr "設定時間和日期..."
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..6d388c7
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,82 @@
+
+bin_PROGRAMS = indicator-datetime-preferences
+libexec_PROGRAMS = indicator-datetime-service
+
+indicator_datetime_service_SOURCES = \
+ datetime-interface.c \
+ datetime-interface.h \
+ gen-datetime-service.xml.c \
+ calendar-menu-item.c \
+ calendar-menu-item.h \
+ datetime-service.c \
+ utils.c \
+ utils.h \
+ dbus-shared.h \
+ settings-shared.h
+indicator_datetime_service_CFLAGS = \
+ -Wall \
+ -Werror \
+ $(SERVICE_CFLAGS) \
+ -DTIMEZONE_FILE="\"/etc/timezone\"" \
+ -DG_LOG_DOMAIN=\"Indicator-Datetime\"
+indicator_datetime_service_LDADD = \
+ $(SERVICE_LIBS)
+
+datetimelibdir = $(INDICATORDIR)
+datetimelib_LTLIBRARIES = libdatetime.la
+libdatetime_la_SOURCES = \
+ gen-datetime-service.xml.h \
+ dbus-shared.h \
+ settings-shared.h \
+ utils.c \
+ utils.h \
+ indicator-datetime.c
+libdatetime_la_CFLAGS = \
+ $(INDICATOR_CFLAGS) \
+ -Wall -Werror \
+ -DG_LOG_DOMAIN=\"Indicator-Datetime\"
+libdatetime_la_LIBADD = \
+ $(INDICATOR_LIBS)
+libdatetime_la_LDFLAGS = \
+ -module \
+ -avoid-version
+
+indicator_datetime_preferences_SOURCES =\
+ datetime-prefs.c \
+ datetime-prefs-locations.c \
+ datetime-prefs-locations.h \
+ timezone-completion.c \
+ timezone-completion.h \
+ utils.c \
+ utils.h \
+ settings-shared.h
+indicator_datetime_preferences_CFLAGS = \
+ -Wall \
+ -Werror \
+ -I$(top_srcdir)/libmap \
+ $(PREF_CFLAGS) \
+ -DPKGDATADIR="\"$(pkgdatadir)\""
+indicator_datetime_preferences_LDADD = \
+ $(top_builddir)/libmap/libmap.la \
+ $(PREF_LIBS)
+
+gen-%.xml.c: %.xml
+ @echo "Building $@ from $<"
+ @echo "const char * _$(subst -,_,$(subst .,_,$(basename $<))) = " > $@
+ @sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@
+ @echo ";" >> $@
+
+gen-%.xml.h: %.xml
+ @echo "Building $@ from $<"
+ @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $<)));" > $@
+
+BUILT_SOURCES = \
+ gen-datetime-service.xml.c \
+ gen-datetime-service.xml.h
+
+
+CLEANFILES = \
+ $(BUILT_SOURCES)
+
+EXTRA_DIST = \
+ datetime-service.xml
diff --git a/src/calendar-menu-item.c b/src/calendar-menu-item.c
new file mode 100644
index 0000000..c2ceec3
--- /dev/null
+++ b/src/calendar-menu-item.c
@@ -0,0 +1,100 @@
+/*
+Calendar menu item dbusmenu "transport" for the corresponding IDO widget.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ David Barth <david.barth@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gdk/gdk.h>
+#include <glib/gi18n.h>
+#include "calendar-menu-item.h"
+
+#include "dbus-shared.h"
+
+#include <libdbusmenu-glib/client.h>
+#include <libdbusmenu-glib/server.h>
+#include <libdbusmenu-glib/menuitem.h>
+
+enum {
+ LAST_SIGNAL
+};
+
+/* static guint signals[LAST_SIGNAL] = { }; */
+
+typedef struct _CalendarMenuItemPrivate CalendarMenuItemPrivate;
+struct _CalendarMenuItemPrivate
+{
+ void * placeholder;
+};
+
+#define CALENDAR_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CALENDAR_MENU_ITEM_TYPE, CalendarMenuItemPrivate))
+
+/* Prototypes */
+static void calendar_menu_item_class_init (CalendarMenuItemClass *klass);
+static void calendar_menu_item_init (CalendarMenuItem *self);
+static void calendar_menu_item_dispose (GObject *object);
+static void calendar_menu_item_finalize (GObject *object);
+
+G_DEFINE_TYPE (CalendarMenuItem, calendar_menu_item, DBUSMENU_TYPE_MENUITEM);
+
+static void
+calendar_menu_item_class_init (CalendarMenuItemClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (CalendarMenuItemPrivate));
+
+ object_class->dispose = calendar_menu_item_dispose;
+ object_class->finalize = calendar_menu_item_finalize;
+
+ return;
+}
+
+static void
+calendar_menu_item_init (CalendarMenuItem *self)
+{
+ return;
+}
+
+static void
+calendar_menu_item_dispose (GObject *object)
+{
+ G_OBJECT_CLASS (calendar_menu_item_parent_class)->dispose (object);
+}
+
+static void
+calendar_menu_item_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (calendar_menu_item_parent_class)->finalize (object);
+
+ return;
+}
+
+CalendarMenuItem *
+calendar_menu_item_new ()
+{
+ CalendarMenuItem * self = g_object_new(CALENDAR_MENU_ITEM_TYPE, NULL);
+
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CALENDAR_MENUITEM_TYPE);
+
+ return self;
+}
+
diff --git a/src/calendar-menu-item.h b/src/calendar-menu-item.h
new file mode 100644
index 0000000..7a56f96
--- /dev/null
+++ b/src/calendar-menu-item.h
@@ -0,0 +1,59 @@
+/*
+Calendar menu item dbusmenu "transport" for the corresponding IDO widget.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ David Barth <david.barth@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __CALENDAR_MENU_ITEM_H__
+#define __CALENDAR_MENU_ITEM_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libdbusmenu-glib/menuitem.h>
+
+G_BEGIN_DECLS
+
+#define CALENDAR_MENU_ITEM_TYPE (calendar_menu_item_get_type ())
+#define CALENDAR_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALENDAR_MENU_ITEM_TYPE, CalendarMenuItem))
+#define CALENDAR_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALENDAR_MENU_ITEM_TYPE, CalendarMenuItemClass))
+#define IS_CALENDAR_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALENDAR_MENU_ITEM_TYPE))
+#define IS_CALENDAR_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALENDAR_MENU_ITEM_TYPE))
+#define CALENDAR_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALENDAR_MENU_ITEM_TYPE, CalendarMenuItemClass))
+
+#define CALENDAR_MENU_ITEM_SIGNAL_ACTIVATE "activate"
+#define CALENDAR_MENUITEM_PROP_TEXT "text"
+
+typedef struct _CalendarMenuItem CalendarMenuItem;
+typedef struct _CalendarMenuItemClass CalendarMenuItemClass;
+
+struct _CalendarMenuItemClass {
+ DbusmenuMenuitemClass parent_class;
+};
+
+struct _CalendarMenuItem {
+ DbusmenuMenuitem parent;
+};
+
+GType calendar_menu_item_get_type (void);
+CalendarMenuItem * calendar_menu_item_new ();
+
+G_END_DECLS
+
+#endif /* __CALENDAR_MENU_ITEM_H__ */
+
diff --git a/src/datetime-interface.c b/src/datetime-interface.c
new file mode 100644
index 0000000..5939061
--- /dev/null
+++ b/src/datetime-interface.c
@@ -0,0 +1,207 @@
+/*
+An indicator to time and date related information in the menubar.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gio/gio.h>
+
+#include "datetime-interface.h"
+#include "gen-datetime-service.xml.h"
+#include "dbus-shared.h"
+
+/**
+ DatetimeInterfacePrivate:
+ @dbus_registration: The handle for this object being registered
+ on dbus.
+
+ Structure to define the memory for the private area
+ of the datetime interface instance.
+*/
+struct _DatetimeInterfacePrivate {
+ GDBusConnection * bus;
+ GCancellable * bus_cancel;
+ guint dbus_registration;
+};
+
+#define DATETIME_INTERFACE_GET_PRIVATE(o) (DATETIME_INTERFACE(o)->priv)
+
+/* GDBus Stuff */
+static GDBusNodeInfo * node_info = NULL;
+static GDBusInterfaceInfo * interface_info = NULL;
+
+static void datetime_interface_class_init (DatetimeInterfaceClass *klass);
+static void datetime_interface_init (DatetimeInterface *self);
+static void datetime_interface_dispose (GObject *object);
+static void datetime_interface_finalize (GObject *object);
+static void bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data);
+
+G_DEFINE_TYPE (DatetimeInterface, datetime_interface, G_TYPE_OBJECT);
+
+static void
+datetime_interface_class_init (DatetimeInterfaceClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (DatetimeInterfacePrivate));
+
+ object_class->dispose = datetime_interface_dispose;
+ object_class->finalize = datetime_interface_finalize;
+
+ /* Setting up the DBus interfaces */
+ if (node_info == NULL) {
+ GError * error = NULL;
+
+ node_info = g_dbus_node_info_new_for_xml(_datetime_service, &error);
+ if (error != NULL) {
+ g_error("Unable to parse Datetime Service Interface description: %s", error->message);
+ g_error_free(error);
+ }
+ }
+
+ if (interface_info == NULL) {
+ interface_info = g_dbus_node_info_lookup_interface(node_info, SERVICE_IFACE);
+
+ if (interface_info == NULL) {
+ g_error("Unable to find interface '" SERVICE_IFACE "'");
+ }
+ }
+
+ return;
+}
+
+static void
+datetime_interface_init (DatetimeInterface *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, DATETIME_INTERFACE_TYPE, DatetimeInterfacePrivate);
+
+ self->priv->bus = NULL;
+ self->priv->bus_cancel = NULL;
+ self->priv->dbus_registration = 0;
+
+ self->priv->bus_cancel = g_cancellable_new();
+ g_bus_get(G_BUS_TYPE_SESSION,
+ self->priv->bus_cancel,
+ bus_get_cb,
+ self);
+
+ return;
+}
+
+static void
+bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data)
+{
+ GError * error = NULL;
+ GDBusConnection * connection = g_bus_get_finish(res, &error);
+
+ if (error != NULL) {
+ g_error("OMG! Unable to get a connection to DBus: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ DatetimeInterfacePrivate * priv = DATETIME_INTERFACE_GET_PRIVATE(user_data);
+
+ g_warn_if_fail(priv->bus == NULL);
+ priv->bus = connection;
+
+ if (priv->bus_cancel != NULL) {
+ g_object_unref(priv->bus_cancel);
+ priv->bus_cancel = NULL;
+ }
+
+ /* Now register our object on our new connection */
+ priv->dbus_registration = g_dbus_connection_register_object(priv->bus,
+ SERVICE_OBJ,
+ interface_info,
+ NULL,
+ user_data,
+ NULL,
+ &error);
+
+ if (error != NULL) {
+ g_error("Unable to register the object to DBus: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ return;
+}
+
+static void
+datetime_interface_dispose (GObject *object)
+{
+ DatetimeInterfacePrivate * priv = DATETIME_INTERFACE_GET_PRIVATE(object);
+
+ if (priv->dbus_registration != 0) {
+ g_dbus_connection_unregister_object(priv->bus, priv->dbus_registration);
+ /* Don't care if it fails, there's nothing we can do */
+ priv->dbus_registration = 0;
+ }
+
+ if (priv->bus != NULL) {
+ g_object_unref(priv->bus);
+ priv->bus = NULL;
+ }
+
+ if (priv->bus_cancel != NULL) {
+ g_cancellable_cancel(priv->bus_cancel);
+ g_object_unref(priv->bus_cancel);
+ priv->bus_cancel = NULL;
+ }
+
+ G_OBJECT_CLASS (datetime_interface_parent_class)->dispose (object);
+ return;
+}
+
+static void
+datetime_interface_finalize (GObject *object)
+{
+
+ G_OBJECT_CLASS (datetime_interface_parent_class)->finalize (object);
+ return;
+}
+
+void
+datetime_interface_update (DatetimeInterface *self)
+{
+ g_return_if_fail(IS_DATETIME_INTERFACE(self));
+
+ DatetimeInterfacePrivate * priv = DATETIME_INTERFACE_GET_PRIVATE(self);
+ GError * error = NULL;
+
+ g_dbus_connection_emit_signal (priv->bus,
+ NULL,
+ SERVICE_OBJ,
+ SERVICE_IFACE,
+ "UpdateTime",
+ NULL,
+ &error);
+
+ if (error != NULL) {
+ g_error("Unable to send UpdateTime signal: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ return;
+}
diff --git a/src/datetime-interface.h b/src/datetime-interface.h
new file mode 100644
index 0000000..ae85605
--- /dev/null
+++ b/src/datetime-interface.h
@@ -0,0 +1,57 @@
+/*
+An indicator to time and date related information in the menubar.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __DATETIME_INTERFACE_H__
+#define __DATETIME_INTERFACE_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define DATETIME_INTERFACE_TYPE (datetime_interface_get_type ())
+#define DATETIME_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DATETIME_INTERFACE_TYPE, DatetimeInterface))
+#define DATETIME_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DATETIME_INTERFACE_TYPE, DatetimeInterfaceClass))
+#define IS_DATETIME_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DATETIME_INTERFACE_TYPE))
+#define IS_DATETIME_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DATETIME_INTERFACE_TYPE))
+#define DATETIME_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DATETIME_INTERFACE_TYPE, DatetimeInterfaceClass))
+
+typedef struct _DatetimeInterface DatetimeInterface;
+typedef struct _DatetimeInterfacePrivate DatetimeInterfacePrivate;
+typedef struct _DatetimeInterfaceClass DatetimeInterfaceClass;
+
+struct _DatetimeInterfaceClass {
+ GObjectClass parent_class;
+
+ void (*update_time) (void);
+};
+
+struct _DatetimeInterface {
+ GObject parent;
+ DatetimeInterfacePrivate * priv;
+};
+
+GType datetime_interface_get_type (void);
+void datetime_interface_update (DatetimeInterface *self);
+
+G_END_DECLS
+
+#endif
diff --git a/src/datetime-prefs-locations.c b/src/datetime-prefs-locations.c
new file mode 100644
index 0000000..af0e10d
--- /dev/null
+++ b/src/datetime-prefs-locations.c
@@ -0,0 +1,500 @@
+/* -*- Mode: C; coding: utf-8; indent-tabs-mode: nil; tab-width: 2 -*-
+
+A dialog for setting time and date preferences.
+
+Copyright 2011 Canonical Ltd.
+
+Authors:
+ Michael Terry <michael.terry@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+
+#include "datetime-prefs-locations.h"
+#include "settings-shared.h"
+#include "utils.h"
+#include "timezone-completion.h"
+
+#define DATETIME_DIALOG_UI_FILE PKGDATADIR "/datetime-dialog.ui"
+
+#define COL_NAME 0
+#define COL_TIME 1
+#define COL_ZONE 2
+#define COL_VISIBLE_NAME 3
+#define COL_ICON 4
+
+static gboolean update_times (GtkWidget * dlg);
+static void save_when_idle (GtkWidget * dlg);
+
+static void
+handle_add (GtkWidget * button, GtkTreeView * tree)
+{
+ GtkListStore * store = GTK_LIST_STORE (gtk_tree_view_get_model (tree));
+
+ GtkTreeIter iter;
+ gtk_list_store_append (store, &iter);
+
+ GtkTreePath * path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter);
+ gtk_tree_view_set_cursor (tree, path, gtk_tree_view_get_column (tree, 0), TRUE);
+ gtk_tree_path_free (path);
+}
+
+static void
+handle_remove (GtkWidget * button, GtkTreeView * tree)
+{
+ GtkListStore * store = GTK_LIST_STORE (gtk_tree_view_get_model (tree));
+ GtkTreeSelection * selection = gtk_tree_view_get_selection (tree);
+
+ GList * paths = gtk_tree_selection_get_selected_rows (selection, NULL);
+
+ /* Convert all paths to iters so we can safely delete multiple paths. For a
+ GtkListStore, iters persist past model changes. */
+ GList * tree_iters = NULL;
+ GList * iter;
+ for (iter = paths; iter; iter = iter->next) {
+ GtkTreeIter * tree_iter = g_new(GtkTreeIter, 1);
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), tree_iter, (GtkTreePath *)iter->data)) {
+ tree_iters = g_list_prepend (tree_iters, tree_iter);
+ }
+ gtk_tree_path_free (iter->data);
+ }
+ g_list_free (paths);
+
+ // Find the next item to select
+ GtkTreeIter *last_selected = g_list_nth_data(tree_iters, 0);
+ GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL (store), last_selected);
+ GtkTreeIter titer;
+ if (!gtk_tree_model_get_iter(GTK_TREE_MODEL (store), &titer, path)) {
+ g_debug("Failed to get last selected iter from path");
+ last_selected = NULL;
+ } else {
+ if (!gtk_tree_model_iter_next(GTK_TREE_MODEL (store), &titer)) {
+ if (gtk_tree_path_prev(path)) {
+ if (!gtk_tree_model_get_iter(GTK_TREE_MODEL (store), &titer, path)) {
+ g_debug("Failed to get iter from path");
+ last_selected = NULL;
+ } else {
+ last_selected = &titer;
+ }
+ } else {
+ g_debug("handle_remove: Failed to find another location to select (assume single selected)");
+ last_selected = NULL;
+ }
+ } else {
+ g_debug("Got next item in model");
+ last_selected = &titer;
+ }
+ }
+
+ if (last_selected) {
+ gboolean clear = TRUE;
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL (store), last_selected);
+
+ // Step over the path to find an item which isn't in the delete list
+ if (g_list_length(tree_iters) > 1) {
+ for (iter = tree_iters; iter; iter = iter->next) {
+ GtkTreePath *ipath = gtk_tree_model_get_path(GTK_TREE_MODEL (store), (GtkTreeIter *)iter->data);
+ if (gtk_tree_path_compare(path, ipath) == 0) {
+ clear = FALSE;
+ break;
+ }
+ }
+ while (clear == FALSE) {
+ if (gtk_tree_path_prev(path)) {
+ clear = TRUE;
+ for (iter = tree_iters; iter; iter = iter->next) {
+ GtkTreePath *ipath = gtk_tree_model_get_path(GTK_TREE_MODEL (store), (GtkTreeIter *)iter->data);
+ if (gtk_tree_path_compare(path, ipath) == 0) {
+ clear = FALSE;
+ break;
+ }
+ }
+ if (clear) {
+ if (!gtk_tree_model_get_iter(GTK_TREE_MODEL (store), &titer, path)) {
+ g_debug("Failed to get iter from path");
+ last_selected = NULL;
+ } else {
+ last_selected = &titer;
+ }
+ }
+ } else {
+ last_selected = NULL;
+ break;
+ }
+ }
+ }
+ }
+
+ /* Now delete each iterator */
+ for (iter = tree_iters; iter; iter = iter->next) {
+ gtk_list_store_remove (store, (GtkTreeIter *)iter->data);
+ g_free (iter->data);
+ }
+ g_list_free (tree_iters);
+
+ if (last_selected)
+ gtk_tree_selection_select_iter(selection, last_selected);
+}
+
+static void
+handle_edit (GtkCellRendererText * renderer, gchar * path, gchar * new_text,
+ GtkListStore * store)
+{
+ GtkTreeIter iter;
+
+ // Manual user edits are always wrong (unless they are undoing a previous
+ // edit), so we set the error icon here if needed. Common way to get to
+ // this code path is to lose entry focus.
+ if (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &iter, path)) {
+ const gchar * name;
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, COL_NAME, &name, -1);
+ gboolean correct = g_strcmp0 (name, new_text) == 0;
+
+ gtk_list_store_set (store, &iter,
+ COL_VISIBLE_NAME, new_text,
+ COL_ICON, correct ? NULL : GTK_STOCK_DIALOG_ERROR,
+ -1);
+ }
+}
+
+static gboolean
+timezone_selected (GtkEntryCompletion * widget, GtkTreeModel * model,
+ GtkTreeIter * iter, GtkWidget * dlg)
+{
+ const gchar * zone, * name;
+
+ gtk_tree_model_get (model, iter,
+ TIMEZONE_COMPLETION_ZONE, &zone,
+ TIMEZONE_COMPLETION_NAME, &name,
+ -1);
+
+ if (zone == NULL || zone[0] == 0) {
+ const gchar * strlon, * strlat;
+ gdouble lon = 0.0, lat = 0.0;
+
+ gtk_tree_model_get (model, iter,
+ TIMEZONE_COMPLETION_LONGITUDE, &strlon,
+ TIMEZONE_COMPLETION_LATITUDE, &strlat,
+ -1);
+
+ if (strlon != NULL && strlon[0] != 0) {
+ lon = strtod(strlon, NULL);
+ }
+
+ if (strlat != NULL && strlat[0] != 0) {
+ lat = strtod(strlat, NULL);
+ }
+
+ CcTimezoneMap * tzmap = CC_TIMEZONE_MAP (g_object_get_data (G_OBJECT (widget), "tzmap"));
+ zone = cc_timezone_map_get_timezone_at_coords (tzmap, lon, lat);
+ }
+
+ GtkListStore * store = GTK_LIST_STORE (g_object_get_data (G_OBJECT (widget), "store"));
+ GtkTreeIter * store_iter = (GtkTreeIter *)g_object_get_data (G_OBJECT (widget), "store_iter");
+ if (store != NULL && store_iter != NULL) {
+ gtk_list_store_set (store, store_iter,
+ COL_VISIBLE_NAME, name,
+ COL_ICON, NULL,
+ COL_NAME, name,
+ COL_ZONE, zone, -1);
+ }
+
+ update_times (dlg);
+
+ return FALSE; // Do normal action too
+}
+
+static gboolean
+query_tooltip (GtkTreeView * tree, gint x, gint y, gboolean keyboard_mode,
+ GtkTooltip * tooltip, GtkCellRenderer * cell)
+{
+ GtkTreeModel * model;
+ GtkTreeIter iter;
+ if (!gtk_tree_view_get_tooltip_context (tree, &x, &y, keyboard_mode,
+ &model, NULL, &iter))
+ return FALSE;
+
+ const gchar * icon;
+ gtk_tree_model_get (model, &iter, COL_ICON, &icon, -1);
+ if (icon == NULL)
+ return FALSE;
+
+ GtkTreeViewColumn * col = gtk_tree_view_get_column (tree, 0);
+ gtk_tree_view_set_tooltip_cell (tree, tooltip, NULL, col, cell);
+ gtk_tooltip_set_text (tooltip, _("You need to complete this location for it to appear in the menu."));
+ return TRUE;
+}
+
+static void
+handle_edit_started (GtkCellRendererText * renderer, GtkCellEditable * editable,
+ gchar * path, TimezoneCompletion * completion)
+{
+ if (GTK_IS_ENTRY (editable)) {
+ GtkEntry *entry = GTK_ENTRY (editable);
+ timezone_completion_watch_entry (completion, entry);
+
+ GtkListStore * store = GTK_LIST_STORE (g_object_get_data (G_OBJECT (completion), "store"));
+ GtkTreeIter * store_iter = g_new(GtkTreeIter, 1);
+ if (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), store_iter, path)) {
+ g_object_set_data_full (G_OBJECT (completion), "store_iter", store_iter, g_free);
+ }
+ }
+}
+
+static gboolean
+update_times (GtkWidget * dlg)
+{
+ /* For each entry, check zone in column 2 and set column 1 to it's time */
+ TimezoneCompletion * completion = TIMEZONE_COMPLETION (g_object_get_data (G_OBJECT (dlg), "completion"));
+ GtkListStore * store = GTK_LIST_STORE (g_object_get_data (G_OBJECT (completion), "store"));
+ GObject * cell = G_OBJECT (g_object_get_data (G_OBJECT (completion), "name-cell"));
+
+ gboolean editing;
+ g_object_get (cell, "editing", &editing, NULL);
+ if (editing) { /* No updates while editing, it cancels the edit */
+ return TRUE;
+ }
+
+ g_signal_handlers_block_by_func (store, save_when_idle, dlg);
+
+ GDateTime * now = g_date_time_new_now_local ();
+
+ GtkTreeIter iter;
+ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) {
+ do {
+ const gchar * strzone;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, COL_ZONE, &strzone, -1);
+
+ if (strzone != NULL && strzone[0] != 0) {
+ GTimeZone * tz = g_time_zone_new (strzone);
+ GDateTime * now_tz = g_date_time_to_timezone (now, tz);
+ gchar * format = generate_format_string_at_time (now_tz);
+ gchar * time_str = g_date_time_format (now_tz, format);
+
+ gtk_list_store_set (store, &iter, COL_TIME, time_str, -1);
+
+ g_free (time_str);
+ g_free (format);
+ g_date_time_unref (now_tz);
+ g_time_zone_unref (tz);
+ }
+ } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter));
+ }
+
+ g_date_time_unref (now);
+
+ g_signal_handlers_unblock_by_func (store, save_when_idle, dlg);
+
+ return TRUE;
+}
+
+static void
+fill_from_settings (GObject * store, GSettings * conf)
+{
+ gchar ** locations = g_settings_get_strv (conf, SETTINGS_LOCATIONS_S);
+
+ gtk_list_store_clear (GTK_LIST_STORE (store));
+
+ gchar ** striter;
+ GtkTreeIter iter;
+ for (striter = locations; *striter; ++striter) {
+ gchar * zone, * name;
+ split_settings_location (*striter, &zone, &name);
+
+ gtk_list_store_append (GTK_LIST_STORE (store), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (store), &iter,
+ COL_VISIBLE_NAME, name,
+ COL_ICON, NULL,
+ COL_NAME, name,
+ COL_ZONE, zone, -1);
+
+ g_free (zone);
+ g_free (name);
+ }
+
+ g_strfreev (locations);
+}
+
+static void
+save_to_settings (GObject * store, GSettings * conf)
+{
+ gboolean empty = TRUE;
+ GVariantBuilder builder;
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
+
+ GtkTreeIter iter;
+ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) {
+ do {
+ const gchar * strzone, * strname;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
+ COL_NAME, &strname,
+ COL_ZONE, &strzone,
+ -1);
+
+ if (strzone != NULL && strzone[0] != 0 && strname != NULL && strname[0] != 0) {
+ gchar * settings_string = g_strdup_printf("%s %s", strzone, strname);
+ g_variant_builder_add (&builder, "s", settings_string);
+ g_free (settings_string);
+ empty = FALSE;
+ }
+ } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter));
+ }
+
+ if (empty) {
+ /* Empty list */
+ g_variant_builder_clear (&builder);
+ g_settings_set_strv (conf, SETTINGS_LOCATIONS_S, NULL);
+ }
+ else {
+ GVariant * locations = g_variant_builder_end (&builder);
+ g_settings_set_strv (conf, SETTINGS_LOCATIONS_S, g_variant_get_strv (locations, NULL));
+ g_variant_unref (locations);
+ }
+}
+
+static gboolean
+save_now (GtkWidget *dlg)
+{
+ GSettings * conf = G_SETTINGS (g_object_get_data (G_OBJECT (dlg), "conf"));
+ GObject * completion = G_OBJECT (g_object_get_data (G_OBJECT (dlg), "completion"));
+ GObject * store = G_OBJECT (g_object_get_data (completion, "store"));
+
+ save_to_settings (store, conf);
+
+ g_object_set_data (G_OBJECT (dlg), "save-id", GINT_TO_POINTER(0));
+
+ return FALSE;
+}
+
+static void
+save_when_idle (GtkWidget *dlg)
+{
+ guint save_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dlg), "save-id"));
+
+ if (save_id == 0) {
+ save_id = g_idle_add ((GSourceFunc)save_now, dlg);
+ g_object_set_data (G_OBJECT (dlg), "save-id", GINT_TO_POINTER(save_id));
+ }
+}
+
+static void
+dialog_closed (GtkWidget * dlg, GObject * store)
+{
+ /* Cleanup a tad */
+ guint time_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dlg), "time-id"));
+ g_source_remove (time_id);
+
+ guint save_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dlg), "save-id"));
+ if (save_id > 0)
+ g_source_remove (save_id);
+}
+
+static void
+selection_changed (GtkTreeSelection * selection, GtkWidget * remove_button)
+{
+ gint count = gtk_tree_selection_count_selected_rows (selection);
+ gtk_widget_set_sensitive (remove_button, count > 0);
+}
+
+GtkWidget *
+datetime_setup_locations_dialog (CcTimezoneMap * map)
+{
+ GError * error = NULL;
+ GtkBuilder * builder = gtk_builder_new ();
+ gtk_builder_add_from_file (builder, DATETIME_DIALOG_UI_FILE, &error);
+ if (error != NULL) {
+ /* We have to abort, we can't continue without the ui file */
+ g_error ("Could not load ui file %s: %s", DATETIME_DIALOG_UI_FILE, error->message);
+ g_error_free (error);
+ return NULL;
+ }
+
+ gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
+
+ GSettings * conf = g_settings_new (SETTINGS_INTERFACE);
+
+#define WIG(name) GTK_WIDGET (gtk_builder_get_object (builder, name))
+
+ GtkWidget * dlg = WIG ("locationsDialog");
+ GtkWidget * tree = WIG ("locationsView");
+ GObject * store = gtk_builder_get_object (builder, "locationsStore");
+
+ /* Configure tree */
+ TimezoneCompletion * completion = timezone_completion_new ();
+ g_object_set_data (G_OBJECT (completion), "tzmap", map);
+ g_object_set_data (G_OBJECT (completion), "store", store);
+ g_signal_connect (completion, "match-selected", G_CALLBACK (timezone_selected), dlg);
+
+ GtkCellRenderer * cell = gtk_cell_renderer_text_new ();
+ g_object_set (cell, "editable", TRUE, NULL);
+ g_signal_connect (cell, "editing-started", G_CALLBACK (handle_edit_started), completion);
+ g_signal_connect (cell, "edited", G_CALLBACK (handle_edit), store);
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1,
+ _("Location"), cell,
+ "text", COL_VISIBLE_NAME, NULL);
+ GtkTreeViewColumn * loc_col = gtk_tree_view_get_column (GTK_TREE_VIEW (tree), 0);
+ gtk_tree_view_column_set_expand (loc_col, TRUE);
+ g_object_set_data (G_OBJECT (completion), "name-cell", cell);
+
+ cell = gtk_cell_renderer_pixbuf_new ();
+ gtk_tree_view_column_pack_start (loc_col, cell, FALSE);
+ gtk_tree_view_column_add_attribute (loc_col, cell, "icon-name", COL_ICON);
+
+ gtk_widget_set_has_tooltip (tree, TRUE);
+ g_signal_connect (tree, "query-tooltip", G_CALLBACK (query_tooltip), cell);
+
+ cell = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1,
+ _("Time"), cell,
+ "text", COL_TIME, NULL);
+
+ GtkTreeSelection * selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+ g_signal_connect (selection, "changed", G_CALLBACK (selection_changed), WIG ("removeButton"));
+ selection_changed (selection, WIG ("removeButton"));
+
+ g_signal_connect (WIG ("addButton"), "clicked", G_CALLBACK (handle_add), tree);
+ g_signal_connect (WIG ("removeButton"), "clicked", G_CALLBACK (handle_remove), tree);
+
+ fill_from_settings (store, conf);
+ g_signal_connect_swapped (store, "row-deleted", G_CALLBACK (save_when_idle), dlg);
+ g_signal_connect_swapped (store, "row-inserted", G_CALLBACK (save_when_idle), dlg);
+ g_signal_connect_swapped (store, "row-changed", G_CALLBACK (save_when_idle), dlg);
+ g_signal_connect_swapped (store, "rows-reordered", G_CALLBACK (save_when_idle), dlg);
+
+ g_object_set_data_full (G_OBJECT (dlg), "conf", g_object_ref (conf), g_object_unref);
+ g_object_set_data_full (G_OBJECT (dlg), "completion", completion, g_object_unref);
+ g_signal_connect (dlg, "destroy", G_CALLBACK (dialog_closed), store);
+
+ guint time_id = g_timeout_add_seconds (2, (GSourceFunc)update_times, dlg);
+ g_object_set_data (G_OBJECT (dlg), "time-id", GINT_TO_POINTER(time_id));
+ update_times (dlg);
+
+#undef WIG
+
+ g_object_unref (conf);
+ g_object_unref (builder);
+
+ return dlg;
+}
+
diff --git a/src/datetime-prefs-locations.h b/src/datetime-prefs-locations.h
new file mode 100644
index 0000000..e312894
--- /dev/null
+++ b/src/datetime-prefs-locations.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C; coding: utf-8; indent-tabs-mode: nil; tab-width: 2 -*-
+
+A dialog for setting time and date preferences.
+
+Copyright 2011 Canonical Ltd.
+
+Authors:
+ Michael Terry <michael.terry@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __DATETIME_PREFS_LOCATIONS_H__
+#define __DATETIME_PREFS_LOCATIONS_H__
+
+#include <gtk/gtk.h>
+#include "cc-timezone-map.h"
+
+G_BEGIN_DECLS
+
+GtkWidget * datetime_setup_locations_dialog (CcTimezoneMap * map);
+
+G_END_DECLS
+
+#endif
diff --git a/src/datetime-prefs.c b/src/datetime-prefs.c
new file mode 100644
index 0000000..9b00e60
--- /dev/null
+++ b/src/datetime-prefs.c
@@ -0,0 +1,769 @@
+/* -*- Mode: C; coding: utf-8; indent-tabs-mode: nil; tab-width: 2 -*-
+
+A dialog for setting time and date preferences.
+
+Copyright 2011 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+ Michael Terry <michael.terry@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <libintl.h>
+#include <locale.h>
+#include <langinfo.h>
+#include <glib/gi18n-lib.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+#include <unique/unique.h>
+#include <polkitgtk/polkitgtk.h>
+
+#include "dbus-shared.h"
+#include "settings-shared.h"
+#include "utils.h"
+#include "datetime-prefs-locations.h"
+#include "timezone-completion.h"
+#include "cc-timezone-map.h"
+
+#define DATETIME_DIALOG_UI_FILE PKGDATADIR "/datetime-dialog.ui"
+
+GDBusProxy * proxy = NULL;
+GtkWidget * auto_radio = NULL;
+GtkWidget * tz_entry = NULL;
+CcTimezoneMap * tzmap = NULL;
+GtkWidget * time_spin = NULL;
+GtkWidget * date_spin = NULL;
+guint save_time_id = 0;
+gboolean user_edited_time = FALSE;
+gboolean changing_time = FALSE;
+GtkWidget * loc_dlg = NULL;
+
+/* Turns the boolean property into a string gsettings */
+static GVariant *
+bind_hours_set (const GValue * value, const GVariantType * type, gpointer user_data)
+{
+ const gchar * output = NULL;
+ gboolean is_12hour_button = (gboolean)GPOINTER_TO_INT(user_data);
+
+ if (g_value_get_boolean(value)) {
+ /* Only do anything if we're setting active = true */
+ output = is_12hour_button ? "12-hour" : "24-hour";
+ } else {
+ return NULL;
+ }
+
+ return g_variant_new_string (output);
+}
+
+/* Turns a string gsettings into a boolean property */
+static gboolean
+bind_hours_get (GValue * value, GVariant * variant, gpointer user_data)
+{
+ const gchar * str = g_variant_get_string(variant, NULL);
+ gboolean output = FALSE;
+ gboolean is_12hour_button = (gboolean)GPOINTER_TO_INT(user_data);
+
+ if (g_strcmp0(str, "locale-default") == 0) {
+ output = (is_12hour_button == is_locale_12h ());
+ } else if (g_strcmp0(str, "12-hour") == 0) {
+ output = is_12hour_button;
+ } else if (g_strcmp0(str, "24-hour") == 0) {
+ output = !is_12hour_button;
+ } else {
+ return FALSE;
+ }
+
+ g_value_set_boolean (value, output);
+ return TRUE;
+}
+
+static void
+widget_dependency_cb (GtkWidget * parent, GParamSpec *pspec, GtkWidget * dependent)
+{
+ gboolean active, sensitive;
+ g_object_get (G_OBJECT (parent),
+ "active", &active,
+ "sensitive", &sensitive, NULL);
+ gtk_widget_set_sensitive (dependent, active && sensitive);
+}
+
+static void
+add_widget_dependency (GtkWidget * parent, GtkWidget * dependent)
+{
+ g_signal_connect (parent, "notify::active", G_CALLBACK(widget_dependency_cb),
+ dependent);
+ g_signal_connect (parent, "notify::sensitive", G_CALLBACK(widget_dependency_cb),
+ dependent);
+ widget_dependency_cb (parent, NULL, dependent);
+}
+
+static void
+polkit_dependency_cb (GtkWidget * parent, GParamSpec *pspec, GtkWidget * dependent)
+{
+ gboolean authorized, sensitive;
+ g_object_get (G_OBJECT (parent),
+ "is-authorized", &authorized,
+ "sensitive", &sensitive, NULL);
+ gtk_widget_set_sensitive (dependent, authorized && sensitive);
+}
+
+static void
+add_polkit_dependency (GtkWidget * parent, GtkWidget * dependent)
+{
+ g_signal_connect (parent, "notify::is-authorized", G_CALLBACK(polkit_dependency_cb),
+ dependent);
+ g_signal_connect (parent, "notify::sensitive", G_CALLBACK(polkit_dependency_cb),
+ dependent);
+ polkit_dependency_cb (parent, NULL, dependent);
+}
+
+static void
+dbus_set_answered (GObject *object, GAsyncResult *res, gpointer command)
+{
+ GError * error = NULL;
+ GVariant * answers = g_dbus_proxy_call_finish (proxy, res, &error);
+
+ if (error != NULL) {
+ g_warning("Could not set '%s' for SettingsDaemon: %s", (gchar *)command, error->message);
+ g_error_free(error);
+ return;
+ }
+
+ g_variant_unref (answers);
+}
+
+static void
+toggle_ntp (GtkWidget * radio, GParamSpec * pspec, gpointer user_data)
+{
+ gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio));
+
+ g_dbus_proxy_call (proxy, "SetUsingNtp", g_variant_new ("(b)", active),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, dbus_set_answered, "using_ntp");
+}
+
+static void
+ntp_query_answered (GObject *object, GAsyncResult *res, gpointer user_data)
+{
+ GError * error = NULL;
+ GVariant * answers = g_dbus_proxy_call_finish (proxy, res, &error);
+
+ if (error != NULL) {
+ g_warning("Could not query DBus proxy for SettingsDaemon: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ gboolean can_use_ntp, is_using_ntp;
+ g_variant_get (answers, "(bb)", &can_use_ntp, &is_using_ntp);
+
+ gtk_widget_set_sensitive (GTK_WIDGET (auto_radio), can_use_ntp);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (auto_radio), is_using_ntp);
+
+ g_signal_connect (auto_radio, "notify::active", G_CALLBACK (toggle_ntp), NULL);
+
+ g_variant_unref (answers);
+}
+
+static void
+sync_entry (const gchar * location)
+{
+ gchar * name = get_current_zone_name (location);
+ gtk_entry_set_text (GTK_ENTRY (tz_entry), name);
+ g_free (name);
+
+ gtk_entry_set_icon_from_stock (GTK_ENTRY (tz_entry), GTK_ENTRY_ICON_SECONDARY, NULL);
+}
+
+static void
+tz_changed (CcTimezoneMap * map, TzLocation * location)
+{
+ if (location == NULL)
+ return;
+
+ gchar * file = g_build_filename ("/usr/share/zoneinfo", location->zone, NULL);
+ g_dbus_proxy_call (proxy, "SetTimezone", g_variant_new ("(s)", file),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, dbus_set_answered, "timezone");
+ g_free (file);
+
+ sync_entry (location->zone);
+}
+
+static void
+tz_query_answered (GObject *object, GAsyncResult *res, gpointer user_data)
+{
+ GError * error = NULL;
+ GVariant * answers = g_dbus_proxy_call_finish (proxy, res, &error);
+
+ if (error != NULL) {
+ g_warning("Could not query DBus proxy for SettingsDaemon: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ const gchar * timezone;
+ g_variant_get (answers, "(&s)", &timezone);
+
+ cc_timezone_map_set_timezone (tzmap, timezone);
+
+ sync_entry (timezone);
+ g_signal_connect (tzmap, "location-changed", G_CALLBACK (tz_changed), NULL);
+
+ g_variant_unref (answers);
+}
+
+static void
+proxy_ready (GObject *object, GAsyncResult *res, gpointer user_data)
+{
+ GError * error = NULL;
+
+ proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+
+ if (error != NULL) {
+ g_critical("Could not grab DBus proxy for SettingsDaemon: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ /* And now, do initial proxy configuration */
+ g_dbus_proxy_call (proxy, "GetUsingNtp", NULL, G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL, ntp_query_answered, auto_radio);
+ g_dbus_proxy_call (proxy, "GetTimezone", NULL, G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL, tz_query_answered, NULL);
+}
+
+static void
+service_name_owner_changed (GDBusProxy * proxy, GParamSpec *pspec, gpointer user_data)
+{
+ GtkWidget * widget = GTK_WIDGET (user_data);
+ gchar * owner = g_dbus_proxy_get_name_owner (proxy);
+
+ gtk_widget_set_sensitive (widget, (owner != NULL));
+
+ g_free (owner);
+}
+
+static void
+service_proxy_ready (GObject *object, GAsyncResult *res, gpointer user_data)
+{
+ GError * error = NULL;
+
+ proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+
+ if (error != NULL) {
+ g_critical("Could not grab DBus proxy for indicator-datetime-service: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ /* And now, do initial proxy configuration */
+ g_signal_connect (proxy, "notify::g-name-owner", G_CALLBACK (service_name_owner_changed), user_data);
+ service_name_owner_changed (proxy, NULL, user_data);
+}
+
+static gboolean
+are_spinners_focused (void)
+{
+ // save_time_id means that we were in focus and haven't finished our save
+ // yet, so act like we are still focused.
+ return save_time_id || gtk_widget_has_focus (time_spin) || gtk_widget_has_focus (date_spin);
+}
+
+static gboolean
+save_time (gpointer user_data)
+{
+ if (user_edited_time) {
+ gdouble current_value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (date_spin));
+ g_dbus_proxy_call (proxy, "SetTime", g_variant_new ("(x)", (guint64)current_value),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, dbus_set_answered, "time");
+ }
+ user_edited_time = FALSE;
+ save_time_id = 0;
+ return FALSE;
+}
+
+static gboolean
+spin_focus_in (void)
+{
+ if (save_time_id > 0) {
+ g_source_remove (save_time_id);
+ save_time_id = 0;
+ }
+ return FALSE;
+}
+
+static gboolean
+spin_focus_out (void)
+{
+ /* We want to only save when both spinners are unfocused. But it's difficult
+ to tell who is about to get focus during a focus-out. So we set an idle
+ callback to save the time if we don't focus in to another spinner by that
+ time. */
+ if (save_time_id == 0) {
+ save_time_id = g_idle_add ((GSourceFunc)save_time, NULL);
+ }
+ return FALSE;
+}
+
+static int
+input_time_text (GtkWidget * spinner, gdouble * value, gpointer user_data)
+{
+ gboolean is_time = (gboolean)GPOINTER_TO_INT (g_object_get_data (G_OBJECT (spinner), "is-time"));
+ const gchar * text = gtk_entry_get_text (GTK_ENTRY (spinner));
+
+ gdouble current_value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinner));
+ *value = current_value;
+
+ GDateTime * now = g_date_time_new_from_unix_local (current_value);
+ gint year, month, day, hour, minute, second;
+ year = g_date_time_get_year (now);
+ month = g_date_time_get_month (now);
+ day = g_date_time_get_day_of_month (now);
+ hour = g_date_time_get_hour (now);
+ minute = g_date_time_get_minute (now);
+ second = g_date_time_get_second (now);
+ g_date_time_unref (now);
+
+ /* Parse this string as if it were in the output format */
+ gint scanned = 0;
+ gboolean passed = TRUE, skip = FALSE;
+ if (is_time) {
+ gint hour_in, minute_in, second_in;
+
+ if (is_locale_12h ()) { // TODO: make this look-at/watch gsettings?
+ char ampm[51];
+
+ scanned = sscanf (text, "%u:%u:%u %50s", &hour_in, &minute_in, &second_in, ampm);
+ passed = (scanned == 4);
+
+ if (passed) {
+ const char *pm_str = nl_langinfo (PM_STR);
+ if (g_ascii_strcasecmp (pm_str, ampm) == 0) {
+ hour_in += 12;
+ }
+ }
+ } else {
+ scanned = sscanf (text, "%u:%u:%u", &hour_in, &minute_in, &second_in);
+ passed = (scanned == 3);
+ }
+
+ if (passed && (hour_in > 23 || minute_in > 59 || second_in > 59)) {
+ passed = FALSE;
+ }
+ if (passed && hour == hour_in && minute == minute_in && second == second_in) {
+ skip = TRUE; // no change
+ } else {
+ hour = hour_in;
+ minute = minute_in;
+ second = second_in;
+ }
+ }
+ else {
+ gint year_in, month_in, day_in;
+
+ scanned = sscanf (text, "%u-%u-%u", &year_in, &month_in, &day_in);
+
+ if (scanned != 3 || year_in < 1 || year_in > 9999 ||
+ month_in < 1 || month_in > 12 || day_in < 1 || day_in > 31) {
+ passed = FALSE;
+ }
+ if (passed && year == year_in && month == month_in && day == day_in) {
+ skip = TRUE; // no change
+ } else {
+ year = year_in;
+ month = month_in;
+ day = day_in;
+ }
+ }
+
+ if (!passed) {
+ g_warning ("Could not understand %s", text);
+ return TRUE;
+ }
+
+ if (skip) {
+ return TRUE;
+ }
+
+ gboolean prev_changing = changing_time;
+ changing_time = TRUE;
+ GDateTime * new_time = g_date_time_new_local (year, month, day, hour, minute, second);
+ *value = g_date_time_to_unix (new_time);
+ user_edited_time = TRUE;
+ g_date_time_unref (new_time);
+ changing_time = prev_changing;
+
+ return TRUE;
+}
+
+static gboolean
+format_time_text (GtkWidget * spinner, gpointer user_data)
+{
+ gboolean is_time = (gboolean)GPOINTER_TO_INT (g_object_get_data (G_OBJECT (spinner), "is-time"));
+
+ const gchar * format;
+ if (is_time) {
+ if (is_locale_12h ()) { // TODO: make this look-at/watch gsettings?
+ format = "%I:%M:%S %p";
+ } else {
+ format = "%H:%M:%S";
+ }
+ }
+ else {
+ format = "%Y-%m-%d";
+ }
+
+ GDateTime * datetime = g_date_time_new_from_unix_local (gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinner)));
+ gchar * formatted = g_date_time_format (datetime, format);
+ gtk_entry_set_text (GTK_ENTRY (spinner), formatted);
+ g_date_time_unref (datetime);
+
+ return TRUE;
+}
+
+static void
+spin_copy_value (GtkSpinButton * spinner, GtkSpinButton * other)
+{
+ if (gtk_spin_button_get_value (spinner) != gtk_spin_button_get_value (other)) {
+ gtk_spin_button_set_value (other, gtk_spin_button_get_value (spinner));
+ }
+ if (!changing_time) { /* Means user pressed spin buttons */
+ user_edited_time = TRUE;
+ }
+}
+
+static gboolean
+update_spinners (void)
+{
+ /* Add datetime object to spinner, which will hold the real time value, rather
+ then using the value of the spinner itself. And don't update while user is
+ editing. */
+ if (!are_spinners_focused ()) {
+ gboolean prev_changing = changing_time;
+ changing_time = TRUE;
+ GDateTime * now = g_date_time_new_now_local ();
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (time_spin), (gdouble)g_date_time_to_unix (now));
+ /* will be copied to other spin button */
+ g_date_time_unref (now);
+ changing_time = prev_changing;
+ }
+ return TRUE;
+}
+
+static void
+setup_time_spinners (GtkWidget * time, GtkWidget * date)
+{
+ g_signal_connect (time, "input", G_CALLBACK (input_time_text), date);
+ g_signal_connect (date, "input", G_CALLBACK (input_time_text), time);
+
+ g_signal_connect (time, "output", G_CALLBACK (format_time_text), date);
+ g_signal_connect (date, "output", G_CALLBACK (format_time_text), time);
+
+ g_signal_connect (time, "focus-in-event", G_CALLBACK (spin_focus_in), date);
+ g_signal_connect (date, "focus-in-event", G_CALLBACK (spin_focus_in), time);
+
+ g_signal_connect (time, "focus-out-event", G_CALLBACK (spin_focus_out), date);
+ g_signal_connect (date, "focus-out-event", G_CALLBACK (spin_focus_out), time);
+
+ g_signal_connect (time, "value-changed", G_CALLBACK (spin_copy_value), date);
+ g_signal_connect (date, "value-changed", G_CALLBACK (spin_copy_value), time);
+
+ g_object_set_data (G_OBJECT (time), "is-time", GINT_TO_POINTER (TRUE));
+ g_object_set_data (G_OBJECT (date), "is-time", GINT_TO_POINTER (FALSE));
+
+ time_spin = time;
+ date_spin = date;
+
+ /* 2 seconds is what the indicator itself uses */
+ guint time_id = g_timeout_add_seconds (2, (GSourceFunc)update_spinners, NULL);
+ g_signal_connect_swapped (time_spin, "destroy", G_CALLBACK (g_source_remove), GINT_TO_POINTER (time_id));
+ update_spinners ();
+}
+
+static void
+hide_locations ()
+{
+ if (loc_dlg != NULL)
+ gtk_widget_destroy (loc_dlg);
+}
+
+static void
+show_locations (GtkWidget * button, GtkWidget * dlg)
+{
+ if (loc_dlg == NULL) {
+ loc_dlg = datetime_setup_locations_dialog (tzmap);
+ gtk_window_set_transient_for (GTK_WINDOW (loc_dlg), GTK_WINDOW (dlg));
+ g_signal_connect (loc_dlg, "destroy", G_CALLBACK (gtk_widget_destroyed), &loc_dlg);
+ g_signal_connect (dlg, "focus-in-event", G_CALLBACK (hide_locations), NULL);
+ gtk_widget_show_all (loc_dlg);
+ }
+ else {
+ gtk_window_present_with_time (GTK_WINDOW (loc_dlg), gtk_get_current_event_time ());
+ }
+}
+
+static gboolean
+timezone_selected (GtkEntryCompletion * widget, GtkTreeModel * model,
+ GtkTreeIter * iter, gpointer user_data)
+{
+ const gchar * name, * zone;
+
+ gtk_tree_model_get (model, iter,
+ TIMEZONE_COMPLETION_NAME, &name,
+ TIMEZONE_COMPLETION_ZONE, &zone,
+ -1);
+
+ if (zone == NULL || zone[0] == 0) {
+ const gchar * strlon, * strlat;
+ gdouble lon = 0.0, lat = 0.0;
+
+ gtk_tree_model_get (model, iter,
+ TIMEZONE_COMPLETION_LONGITUDE, &strlon,
+ TIMEZONE_COMPLETION_LATITUDE, &strlat,
+ -1);
+
+ if (strlon != NULL && strlon[0] != 0) {
+ lon = strtod(strlon, NULL);
+ }
+
+ if (strlat != NULL && strlat[0] != 0) {
+ lat = strtod(strlat, NULL);
+ }
+
+ zone = cc_timezone_map_get_timezone_at_coords (tzmap, lon, lat);
+ }
+
+ GSettings * conf = g_settings_new (SETTINGS_INTERFACE);
+ gchar * tz_name = g_strdup_printf ("%s %s", zone, name);
+ g_settings_set_string (conf, SETTINGS_TIMEZONE_NAME_S, tz_name);
+ g_free (tz_name);
+ g_object_unref (conf);
+
+ cc_timezone_map_set_timezone (tzmap, zone);
+
+ return FALSE; // Do normal action too
+}
+
+static gboolean
+entry_focus_out (GtkEntry * entry, GdkEventFocus * event)
+{
+ // If the name left in the entry doesn't match the current timezone name,
+ // show an error icon. It's always an error for the user to manually type in
+ // a timezone.
+ TzLocation * location = cc_timezone_map_get_location (tzmap);
+ if (location == NULL)
+ return FALSE;
+
+ gchar * name = get_current_zone_name (location->zone);
+ gboolean correct = (g_strcmp0 (gtk_entry_get_text (entry), name) == 0);
+ g_free (name);
+
+ gtk_entry_set_icon_from_stock (entry, GTK_ENTRY_ICON_SECONDARY,
+ correct ? NULL : GTK_STOCK_DIALOG_ERROR);
+ gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY,
+ _("You need to choose a location to change the time zone."));
+ gtk_entry_set_icon_activatable (entry, GTK_ENTRY_ICON_SECONDARY, FALSE);
+ return FALSE;
+}
+
+static gboolean
+key_pressed (GtkWidget * widget, GdkEventKey * event, gpointer user_data)
+{
+ switch (event->keyval) {
+ case GDK_KEY_Escape:
+ gtk_widget_destroy (widget);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static GtkWidget *
+get_child_of_type (GtkContainer * parent, GType type)
+{
+ GList * children, * iter;
+
+ children = gtk_container_get_children (parent);
+ for (iter = children; iter; iter = iter->next) {
+ if (G_TYPE_CHECK_INSTANCE_TYPE (iter->data, type)) {
+ return GTK_WIDGET (iter->data);
+ }
+ }
+
+ return NULL;
+}
+
+static GtkWidget *
+create_dialog (void)
+{
+ GError * error = NULL;
+
+ GtkBuilder * builder = gtk_builder_new ();
+ gtk_builder_add_from_file (builder, DATETIME_DIALOG_UI_FILE, &error);
+ if (error != NULL) {
+ /* We have to abort, we can't continue without the ui file */
+ g_error ("Could not load ui file %s: %s", DATETIME_DIALOG_UI_FILE, error->message);
+ g_error_free (error);
+ return NULL;
+ }
+
+ gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
+
+ GSettings * conf = g_settings_new (SETTINGS_INTERFACE);
+
+#define WIG(name) GTK_WIDGET (gtk_builder_get_object (builder, name))
+
+ /* Add policykit button */
+ GtkWidget * polkit_button = polkit_lock_button_new ("org.gnome.settingsdaemon.datetimemechanism.configure");
+ polkit_lock_button_set_unlock_text (POLKIT_LOCK_BUTTON (polkit_button), _("Unlock to change these settings"));
+ polkit_lock_button_set_lock_text (POLKIT_LOCK_BUTTON (polkit_button), _("Lock to prevent further changes"));
+ gtk_box_pack_start (GTK_BOX (WIG ("timeDateBox")), polkit_button, FALSE, TRUE, 0);
+ /* Make sure border around button is visible */
+ GtkWidget * polkit_button_button = get_child_of_type (GTK_CONTAINER (polkit_button), GTK_TYPE_BUTTON);
+ if (polkit_button_button != NULL) {
+ gtk_button_set_relief (GTK_BUTTON (polkit_button_button), GTK_RELIEF_NORMAL);
+ }
+
+ /* Add map */
+ tzmap = cc_timezone_map_new ();
+ gtk_container_add (GTK_CONTAINER (WIG ("mapBox")), GTK_WIDGET (tzmap));
+ /* Fufill the CC by Attribution license requirements for the Geonames lookup */
+ cc_timezone_map_set_watermark (tzmap, "Geonames.org");
+
+ /* And completion entry */
+ TimezoneCompletion * completion = timezone_completion_new ();
+ timezone_completion_watch_entry (completion, GTK_ENTRY (WIG ("timezoneEntry")));
+ g_signal_connect (completion, "match-selected", G_CALLBACK (timezone_selected), NULL);
+ g_signal_connect (WIG ("timezoneEntry"), "focus-out-event", G_CALLBACK (entry_focus_out), NULL);
+
+ /* Set up settings bindings */
+ g_settings_bind (conf, SETTINGS_SHOW_CLOCK_S, WIG ("showClockCheck"),
+ "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (conf, SETTINGS_SHOW_DAY_S, WIG ("showWeekdayCheck"),
+ "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (conf, SETTINGS_SHOW_DATE_S, WIG ("showDateTimeCheck"),
+ "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (conf, SETTINGS_SHOW_SECONDS_S, WIG ("showSecondsCheck"),
+ "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind_with_mapping (conf, SETTINGS_TIME_FORMAT_S,
+ WIG ("show12HourRadio"), "active",
+ G_SETTINGS_BIND_DEFAULT,
+ bind_hours_get, bind_hours_set,
+ GINT_TO_POINTER(TRUE), NULL);
+ g_settings_bind_with_mapping (conf, SETTINGS_TIME_FORMAT_S,
+ WIG ("show24HourRadio"), "active",
+ G_SETTINGS_BIND_DEFAULT,
+ bind_hours_get, bind_hours_set,
+ GINT_TO_POINTER(FALSE), NULL);
+ g_settings_bind (conf, SETTINGS_SHOW_CALENDAR_S, WIG ("showCalendarCheck"),
+ "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (conf, SETTINGS_SHOW_WEEK_NUMBERS_S, WIG ("includeWeekNumbersCheck"),
+ "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (conf, SETTINGS_SHOW_EVENTS_S, WIG ("showEventsCheck"),
+ "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (conf, SETTINGS_SHOW_LOCATIONS_S, WIG ("showLocationsCheck"),
+ "active", G_SETTINGS_BIND_DEFAULT);
+
+ /* Set up sensitivities */
+ add_widget_dependency (WIG ("showCalendarCheck"), WIG ("calendarOptions"));
+ add_widget_dependency (WIG ("showClockCheck"), WIG ("clockOptions"));
+ add_widget_dependency (WIG ("showLocationsCheck"), WIG ("locationsButton"));
+ add_widget_dependency (WIG ("manualTimeRadio"), WIG ("manualOptions"));
+ add_polkit_dependency (polkit_button, WIG ("timeDateOptions"));
+
+ /* Hacky proxy test for whether evolution-data-server is installed */
+ gchar * evo_path = g_find_program_in_path ("evolution");
+ gtk_widget_set_sensitive (WIG ("showEventsCheck"), (evo_path != NULL));
+ g_free (evo_path);
+
+ setup_time_spinners (WIG ("timeSpinner"), WIG ("dateSpinner"));
+
+ GtkWidget * dlg = WIG ("timeDateDialog");
+ auto_radio = WIG ("automaticTimeRadio");
+ tz_entry = WIG ("timezoneEntry");
+
+ g_signal_connect (WIG ("locationsButton"), "clicked", G_CALLBACK (show_locations), dlg);
+ g_signal_connect (dlg, "key-press-event", G_CALLBACK (key_pressed), NULL);
+
+ /* Grab proxy for settings daemon */
+ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL,
+ "org.gnome.SettingsDaemon.DateTimeMechanism",
+ "/",
+ "org.gnome.SettingsDaemon.DateTimeMechanism",
+ NULL, proxy_ready, NULL);
+
+ /* Grab proxy for datetime service, to see if it's running. It would
+ actually be more ideal to see if the indicator module itself is running,
+ but that doesn't yet claim a name on the bus. Presumably the service
+ would have been started by any such indicator, so this will at least tell
+ us if there *was* a datetime module run this session. */
+ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, NULL,
+ SERVICE_NAME, SERVICE_OBJ, SERVICE_IFACE,
+ NULL, service_proxy_ready, WIG ("showClockCheck"));
+
+#undef WIG
+
+ g_object_unref (conf);
+ g_object_unref (builder);
+
+ return dlg;
+}
+
+static UniqueResponse
+message_received (UniqueApp * app, gint command, UniqueMessageData *message_data,
+ guint time, gpointer user_data)
+{
+ if (command == UNIQUE_ACTIVATE) {
+ gtk_window_present_with_time (GTK_WINDOW (user_data), time);
+ return UNIQUE_RESPONSE_OK;
+ }
+ return UNIQUE_RESPONSE_PASSTHROUGH;
+}
+
+int
+main (int argc, char ** argv)
+{
+ g_type_init ();
+
+ /* Setting up i18n and gettext. Apparently, we need
+ all of these. */
+ setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ textdomain (GETTEXT_PACKAGE);
+
+ gtk_init (&argc, &argv);
+
+ UniqueApp * app = unique_app_new ("com.canonical.indicator.datetime.preferences", NULL);
+
+ if (unique_app_is_running (app)) {
+ unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);
+ } else {
+ // We're first instance. Yay!
+ GtkWidget * dlg = create_dialog ();
+
+ g_signal_connect (app, "message-received", G_CALLBACK(message_received), dlg);
+ unique_app_watch_window (app, GTK_WINDOW (dlg));
+
+ gtk_widget_show_all (dlg);
+ g_signal_connect (dlg, "destroy", G_CALLBACK(gtk_main_quit), NULL);
+ gtk_main ();
+ }
+
+ return 0;
+}
+
diff --git a/src/datetime-service.c b/src/datetime-service.c
new file mode 100644
index 0000000..08ff9ad
--- /dev/null
+++ b/src/datetime-service.c
@@ -0,0 +1,1493 @@
+/*
+An indicator to time and date related information in the menubar.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <config.h>
+#include <libindicator/indicator-service.h>
+#include <locale.h>
+
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+#include <math.h>
+#include <gconf/gconf-client.h>
+
+#include <libdbusmenu-gtk/menuitem.h>
+#include <libdbusmenu-glib/server.h>
+#include <libdbusmenu-glib/client.h>
+#include <libdbusmenu-glib/menuitem.h>
+
+#include <geoclue/geoclue-master.h>
+#include <geoclue/geoclue-master-client.h>
+
+#include <time.h>
+#include <libecal/e-cal.h>
+#include <libical/ical.h>
+#include <libecal/e-cal-time-util.h>
+#include <libedataserver/e-source.h>
+#include <libedataserverui/e-passwords.h>
+// Other users of ecal seem to also include these, not sure why they should be included by the above
+#include <libical/icaltime.h>
+#include <cairo/cairo.h>
+
+#include "datetime-interface.h"
+#include "dbus-shared.h"
+#include "settings-shared.h"
+#include "utils.h"
+
+
+static void geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * path, GError * error, gpointer user_data);
+static gboolean update_appointment_menu_items (gpointer user_data);
+static gboolean update_timezone_menu_items(gpointer user_data);
+static void setup_timer (void);
+static void geo_client_invalid (GeoclueMasterClient * client, gpointer user_data);
+static void geo_address_change (GeoclueMasterClient * client, gchar * a, gchar * b, gchar * c, gchar * d, gpointer user_data);
+
+static IndicatorService * service = NULL;
+static GMainLoop * mainloop = NULL;
+static DbusmenuServer * server = NULL;
+static DbusmenuMenuitem * root = NULL;
+static DatetimeInterface * dbus = NULL;
+
+/* Global Items */
+static DbusmenuMenuitem * date = NULL;
+static DbusmenuMenuitem * calendar = NULL;
+static DbusmenuMenuitem * settings = NULL;
+static DbusmenuMenuitem * events_separator = NULL;
+static DbusmenuMenuitem * locations_separator = NULL;
+static DbusmenuMenuitem * geo_location = NULL;
+static DbusmenuMenuitem * current_location = NULL;
+//static DbusmenuMenuitem * ecal_location = NULL;
+static DbusmenuMenuitem * add_appointment = NULL;
+static GList * appointments = NULL;
+static GList * dconflocations = NULL;
+static GList * comp_instances = NULL;
+static gboolean updating_appointments = FALSE;
+static time_t start_time_appointments = (time_t) 0;
+GSettings *conf;
+GConfClient* gconf;
+
+
+/* Geoclue trackers */
+static GeoclueMasterClient * geo_master = NULL;
+static GeoclueAddress * geo_address = NULL;
+
+/* Our 2 important timezones */
+static gchar * current_timezone = NULL;
+static gchar * geo_timezone = NULL;
+
+struct comp_instance {
+ ECalComponent *comp;
+ time_t start;
+ time_t end;
+ ESource *source;
+};
+
+static void
+set_timezone_label (DbusmenuMenuitem * mi, const gchar * location)
+{
+ gchar * zone, * name;
+ split_settings_location (location, &zone, &name);
+
+ dbusmenu_menuitem_property_set (mi, TIMEZONE_MENUITEM_PROP_NAME, name);
+ dbusmenu_menuitem_property_set (mi, TIMEZONE_MENUITEM_PROP_ZONE, zone);
+
+ g_free (zone);
+ g_free (name);
+}
+
+static void
+set_current_timezone_label (DbusmenuMenuitem * mi, const gchar * location)
+{
+ gchar * name = get_current_zone_name (location);
+
+ dbusmenu_menuitem_property_set (mi, TIMEZONE_MENUITEM_PROP_NAME, name);
+ dbusmenu_menuitem_property_set (mi, TIMEZONE_MENUITEM_PROP_ZONE, location);
+
+ g_free (name);
+}
+
+/* Check to see if our timezones are the same */
+static void
+check_timezone_sync (void) {
+ gchar * label;
+ gboolean in_sync = FALSE;
+
+ if (geo_timezone == NULL) {
+ in_sync = TRUE;
+ }
+
+ if (current_timezone == NULL) {
+ in_sync = TRUE;
+ }
+
+ if (!in_sync && g_strcmp0(geo_timezone, current_timezone) == 0) {
+ in_sync = TRUE;
+ }
+
+ if (in_sync) {
+ g_debug("Timezones in sync");
+ } else {
+ g_debug("Timezones are different");
+ }
+
+ gboolean show = g_settings_get_boolean (conf, SETTINGS_SHOW_LOCATIONS_S);
+
+ if (geo_location != NULL && current_location != NULL) {
+ g_debug("Got timezone %s", current_timezone);
+ g_debug("Got timezone %s", geo_timezone);
+ // Show neither current location nor geo location if both are the same
+ // however, we want to set their time and label accordingly
+ if (in_sync) {
+ if (current_timezone == NULL && geo_timezone == NULL) {
+ dbusmenu_menuitem_property_set_bool(locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ update_timezone_menu_items(NULL); // Update the timezone menu items
+ return;
+ }
+
+ dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
+ dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
+
+ if (current_timezone != NULL) {
+ label = current_timezone;
+ } else {
+ label = geo_timezone;
+ }
+
+ if (label != NULL) {
+ // TODO work out the current location name in a nice way
+ set_current_timezone_label (current_location, label);
+ // TODO work out the current time at that location
+ dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show);
+ dbusmenu_menuitem_property_set_bool(current_location, TIMEZONE_MENUITEM_PROP_RADIO, TRUE);
+ } else {
+ g_debug("Label for current location is null, this shouldn't happen");
+ }
+ if (geo_timezone != NULL) {
+ // TODO work out the geo location name in a nice way
+ set_current_timezone_label (geo_location, geo_timezone);
+ // TODO work out the current time at that location
+ dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show);
+ }
+ } else {
+ // TODO work out the geo location name in a nice way
+ set_current_timezone_label (geo_location, geo_timezone);
+ // TODO work out the current time at that location
+ dbusmenu_menuitem_property_set_bool(geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show);
+
+ // TODO work out the current location name in a nice way
+ set_current_timezone_label (current_location, current_timezone);
+ // TODO work out the current time at that location
+ dbusmenu_menuitem_property_set_bool(current_location, TIMEZONE_MENUITEM_PROP_RADIO, TRUE);
+ dbusmenu_menuitem_property_set_bool(current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show);
+ dbusmenu_menuitem_property_set_bool(locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, show);
+ }
+ }
+ g_debug("Finished checking timezone sync");
+ update_timezone_menu_items(NULL); // Update the timezone menu items
+
+ return;
+}
+
+/* Update the current timezone */
+static void
+update_current_timezone (void) {
+ /* Clear old data */
+ if (current_timezone != NULL) {
+ g_free(current_timezone);
+ current_timezone = NULL;
+ }
+
+ GError * error = NULL;
+ gchar * tempzone = NULL;
+ if (!g_file_get_contents(TIMEZONE_FILE, &tempzone, NULL, &error)) {
+ g_warning("Unable to read timezone file '" TIMEZONE_FILE "': %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ /* This shouldn't happen, so let's make it a big boom! */
+ g_return_if_fail(tempzone != NULL);
+
+ /* Note: this really makes sense as strstrip works in place
+ so we end up with something a little odd without the dup
+ so we have the dup to make sure everything is as expected
+ for everyone else. */
+ current_timezone = g_strdup(g_strstrip(tempzone));
+ g_free(tempzone);
+
+ g_debug("System timezone is: %s", current_timezone);
+
+ check_timezone_sync();
+
+ if (error != NULL) g_error_free(error);
+ return;
+}
+
+static void
+quick_set_tz_cb (GObject *object, GAsyncResult *res, gpointer data)
+{
+ GError * error = NULL;
+ GVariant * answers = g_dbus_proxy_call_finish (G_DBUS_PROXY (object), res, &error);
+
+ if (error != NULL) {
+ g_warning("Could not set timezone for SettingsDaemon: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ g_variant_unref (answers);
+}
+
+static void
+quick_set_tz_proxy_cb (GObject *object, GAsyncResult *res, gpointer zone)
+{
+ GError * error = NULL;
+
+ GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+
+ if (error != NULL) {
+ g_warning("Could not grab DBus proxy for SettingsDaemon: %s", error->message);
+ g_error_free(error);
+ g_free (zone);
+ return;
+ }
+
+ gchar * file = g_build_filename ("/usr/share/zoneinfo", (char *)zone, NULL);
+ g_dbus_proxy_call (proxy, "SetTimezone", g_variant_new ("(s)", file),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, quick_set_tz_cb, NULL);
+ g_free (file);
+ g_free (zone);
+ g_object_unref (proxy);
+}
+
+static void
+quick_set_tz (DbusmenuMenuitem * menuitem, guint timestamp, gpointer user_data)
+{
+ const gchar * tz = dbusmenu_menuitem_property_get(menuitem, TIMEZONE_MENUITEM_PROP_ZONE);
+ g_debug("Quick setting timezone to: %s", tz);
+
+ g_return_if_fail(tz != NULL);
+
+ const gchar * name = dbusmenu_menuitem_property_get(menuitem, TIMEZONE_MENUITEM_PROP_NAME);
+
+ /* Set it in gsettings so we don't lose user's preferred name */
+ GSettings * conf = g_settings_new (SETTINGS_INTERFACE);
+ gchar * tz_full = g_strdup_printf ("%s %s", tz, name);
+ g_settings_set_string (conf, SETTINGS_TIMEZONE_NAME_S, tz_full);
+ g_free (tz_full);
+ g_object_unref (conf);
+
+ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL,
+ "org.gnome.SettingsDaemon.DateTimeMechanism",
+ "/",
+ "org.gnome.SettingsDaemon.DateTimeMechanism",
+ NULL, quick_set_tz_proxy_cb, g_strdup (tz));
+
+ return;
+}
+
+/* Updates the label in the date menuitem */
+static gboolean
+update_datetime (gpointer user_data)
+{
+ g_debug("Updating Date/Time");
+
+ gchar longstr[128];
+ time_t t;
+ struct tm *ltime;
+
+ t = time(NULL);
+ ltime = localtime(&t);
+ if (ltime == NULL) {
+ g_warning("Error getting local time");
+ dbusmenu_menuitem_property_set(date, DBUSMENU_MENUITEM_PROP_LABEL, _("Error getting time"));
+ return FALSE;
+ }
+
+ /* Translators: strftime(3) style date format on top of the menu when you click on the clock */
+ strftime(longstr, 128, _("%A, %e %B %Y"), ltime);
+
+ gchar * utf8 = g_locale_to_utf8(longstr, -1, NULL, NULL, NULL);
+ dbusmenu_menuitem_property_set(date, DBUSMENU_MENUITEM_PROP_LABEL, utf8);
+ g_free(utf8);
+
+ return FALSE;
+}
+
+/* Run a particular program based on an activation */
+static void
+activate_cb (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command)
+{
+ GError * error = NULL;
+
+ g_debug("Issuing command '%s'", command);
+ if (!g_spawn_command_line_async(command, &error)) {
+ g_warning("Unable to start %s: %s", (char *)command, error->message);
+ g_error_free(error);
+ }
+}
+
+static gboolean
+update_appointment_menu_items_idle (gpointer user_data)
+{
+ update_appointment_menu_items(user_data);
+ return FALSE;
+}
+
+static gboolean
+month_changed_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, guint timestamp)
+{
+ start_time_appointments = (time_t)g_variant_get_uint32(variant);
+
+ g_debug("Received month changed with timestamp: %d -> %s",(int)start_time_appointments, ctime(&start_time_appointments));
+ /* By default one of the first things we do is
+ clear the marks as we don't know the correct
+ ones yet and we don't want to confuse the
+ user. */
+ dbusmenu_menuitem_property_remove(menuitem, CALENDAR_MENUITEM_PROP_MARKS);
+
+ GList * appointment;
+ for (appointment = appointments; appointment != NULL; appointment = g_list_next(appointment)) {
+ DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(appointment->data);
+ dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
+ }
+
+ g_idle_add(update_appointment_menu_items_idle, NULL);
+ return TRUE;
+}
+
+static gboolean
+day_selected_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, guint timestamp)
+{
+ time_t new_time = (time_t)g_variant_get_uint32(variant);
+ g_warn_if_fail(new_time != 0);
+
+ if (start_time_appointments == 0 || new_time == 0) {
+ /* If we've got nothing, assume everyhting is going to
+ get repopulated, let's start with a clean slate */
+ dbusmenu_menuitem_property_remove(menuitem, CALENDAR_MENUITEM_PROP_MARKS);
+ } else {
+ /* No check to see if we changed months. If we did we'll
+ want to clear the marks. Otherwise we're cool keeping
+ them around. */
+ struct tm start_tm;
+ struct tm new_tm;
+
+ localtime_r(&start_time_appointments, &start_tm);
+ localtime_r(&new_time, &new_tm);
+
+ if (start_tm.tm_mon != new_tm.tm_mon) {
+ dbusmenu_menuitem_property_remove(menuitem, CALENDAR_MENUITEM_PROP_MARKS);
+ }
+ }
+
+ GList * appointment;
+ for (appointment = appointments; appointment != NULL; appointment = g_list_next(appointment)) {
+ DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(appointment->data);
+ dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
+ }
+
+ start_time_appointments = new_time;
+
+ g_debug("Received day-selected with timestamp: %d -> %s",(int)start_time_appointments, ctime(&start_time_appointments));
+ g_idle_add(update_appointment_menu_items_idle, NULL);
+
+ return TRUE;
+}
+
+static gboolean
+day_selected_double_click_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, guint timestamp)
+{
+ time_t evotime = (time_t)g_variant_get_uint32(variant);
+
+ g_debug("Received day-selected-double-click with timestamp: %d -> %s",(int)evotime, ctime(&evotime));
+
+ gchar *ad = isodate_from_time_t(evotime);
+ gchar *cmd = g_strconcat("evolution calendar:///?startdate=", ad, NULL);
+
+ GError * error = NULL;
+
+ g_debug("Issuing command '%s'", cmd);
+ if (!g_spawn_command_line_async(cmd, &error)) {
+ g_warning("Unable to start %s: %s", (char *)cmd, error->message);
+ g_error_free(error);
+ }
+
+ return TRUE;
+}
+
+static guint ecaltimer = 0;
+
+static void
+start_ecal_timer(void)
+{
+ if (ecaltimer != 0) g_source_remove(ecaltimer);
+ if (update_appointment_menu_items(NULL))
+ ecaltimer = g_timeout_add_seconds(60*5, update_appointment_menu_items, NULL);
+}
+
+static void
+stop_ecal_timer(void)
+{
+ if (ecaltimer != 0) g_source_remove(ecaltimer);
+}
+static gboolean
+idle_start_ecal_timer (gpointer data)
+{
+ start_ecal_timer();
+ return FALSE;
+}
+
+static void
+show_events_changed (void)
+{
+ if (g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) {
+ dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ start_ecal_timer();
+ } else {
+ dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ /* Remove all of the previous appointments */
+ if (appointments != NULL) {
+ g_debug("Hiding old appointments");
+ GList * appointment;
+ for (appointment = appointments; appointment != NULL; appointment = g_list_next(appointment)) {
+ DbusmenuMenuitem * litem = DBUSMENU_MENUITEM(appointment->data);
+ g_debug("Hiding old appointment: %p", litem);
+ // Remove all the existing menu items which are in appointments.
+ dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(litem), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ }
+ }
+ stop_ecal_timer();
+ }
+}
+
+/* Looks for the calendar application and enables the item if
+ we have one, starts ecal timer if events are turned on */
+static gboolean
+check_for_calendar (gpointer user_data)
+{
+ g_return_val_if_fail (calendar != NULL, FALSE);
+
+ dbusmenu_menuitem_property_set_bool(date, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
+
+ gchar *evo = g_find_program_in_path("evolution");
+ if (evo != NULL) {
+ g_debug("Found the calendar application: %s", evo);
+
+ g_signal_connect (G_OBJECT(date), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
+ G_CALLBACK (activate_cb), "evolution -c calendar");
+
+ events_separator = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(events_separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
+ dbusmenu_menuitem_child_add_position(root, events_separator, 2);
+ add_appointment = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set (add_appointment, DBUSMENU_MENUITEM_PROP_LABEL, _("Add Event..."));
+ dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
+ g_signal_connect(G_OBJECT(add_appointment), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), "evolution -c calendar");
+ dbusmenu_menuitem_child_add_position (root, add_appointment, 3);
+
+
+ if (g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) {
+ dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ g_idle_add((GSourceFunc)idle_start_ecal_timer, NULL);
+ } else {
+ dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ stop_ecal_timer();
+ }
+
+ // Connect to calendar events
+ g_signal_connect(calendar, "event::month-changed", G_CALLBACK(month_changed_cb), NULL);
+ g_signal_connect(calendar, "event::day-selected", G_CALLBACK(day_selected_cb), NULL);
+ g_signal_connect(calendar, "event::day-selected-double-click", G_CALLBACK(day_selected_double_click_cb), NULL);
+ g_free(evo);
+ } else {
+ g_debug("Unable to find calendar app.");
+ dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ }
+
+ if (g_settings_get_boolean(conf, SETTINGS_SHOW_CALENDAR_S)) {
+ dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
+ dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ } else {
+ dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
+ dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ }
+
+ return FALSE;
+}
+
+
+static gboolean
+update_timezone_menu_items(gpointer user_data) {
+ g_debug("Updating timezone menu items");
+
+ gchar ** locations = g_settings_get_strv(conf, SETTINGS_LOCATIONS_S);
+
+ if (locations == NULL) {
+ g_debug("No locations configured (NULL)");
+ return FALSE;
+ }
+ guint len = g_strv_length(locations);
+ DbusmenuMenuitem *item;
+ gint i, offset;
+
+ /* Remove all of the previous locations */
+ if (dconflocations != NULL) {
+ while (dconflocations != NULL) {
+ DbusmenuMenuitem * litem = DBUSMENU_MENUITEM(dconflocations->data);
+ // Remove all the existing menu items which are in dconflocations.
+ dconflocations = g_list_remove(dconflocations, litem);
+ dbusmenu_menuitem_child_delete(root, DBUSMENU_MENUITEM(litem));
+ g_object_unref(G_OBJECT(litem));
+ }
+ }
+
+ gboolean show = g_settings_get_boolean (conf, SETTINGS_SHOW_LOCATIONS_S);
+
+ dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, show);
+ dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show);
+ dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
+
+ if (len == 0) {
+ g_debug("No locations configured (Empty List)");
+ return FALSE;
+ }
+
+ offset = dbusmenu_menuitem_get_position (current_location, root)+1;
+ for (i = 0; i < len; i++) {
+ // Iterate over configured places and add any which aren't already listed
+ if (g_strcmp0(locations[i], current_timezone) != 0 &&
+ g_strcmp0(locations[i], geo_timezone) != 0) {
+ g_debug("Adding timezone in update_timezones %s", locations[i]);
+ item = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set (item, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE);
+ set_timezone_label (item, locations[i]);
+ dbusmenu_menuitem_property_set_bool (item, TIMEZONE_MENUITEM_PROP_RADIO, FALSE);
+ dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
+ dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_VISIBLE, show);
+ dbusmenu_menuitem_child_add_position (root, item, offset++);
+ g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL);
+ dconflocations = g_list_append(dconflocations, item);
+ }
+ }
+ g_strfreev (locations);
+ return FALSE;
+}
+
+// Authentication function
+static gchar *
+auth_func (ECal *ecal,
+ const gchar *prompt,
+ const gchar *key,
+ gpointer user_data)
+{
+ ESource *source = e_cal_get_source (ecal);
+ gchar *auth_domain = e_source_get_duped_property (source, "auth-domain");
+
+ const gchar *component_name;
+ if (auth_domain) component_name = auth_domain;
+ else component_name = "Calendar";
+
+ gchar *password = e_passwords_get_password (component_name, key);
+
+ g_free (auth_domain);
+
+ return password;
+}
+
+static gint
+compare_comp_instances (gconstpointer a,
+ gconstpointer b)
+{
+ const struct comp_instance *ci_a = a;
+ const struct comp_instance *ci_b = b;
+ time_t d = ci_a->start - ci_b->start;
+ if (d < 0) return -1;
+ else if (d > 0) return 1;
+ return 0;
+}
+
+static gboolean
+populate_appointment_instances (ECalComponent *comp,
+ time_t instance_start,
+ time_t instance_end,
+ gpointer data)
+{
+ g_debug("Appending item %p", comp);
+
+ ECalComponentVType vtype = e_cal_component_get_vtype (comp);
+ if (vtype != E_CAL_COMPONENT_EVENT && vtype != E_CAL_COMPONENT_TODO) return FALSE;
+
+ icalproperty_status status;
+ e_cal_component_get_status (comp, &status);
+ if (status == ICAL_STATUS_COMPLETED || status == ICAL_STATUS_CANCELLED) return FALSE;
+
+ g_object_ref(comp);
+
+ ECalComponentDateTime datetime;
+ icaltimezone *appointment_zone = NULL;
+ icaltimezone *current_zone = NULL;
+
+ if (vtype == E_CAL_COMPONENT_EVENT)
+ e_cal_component_get_dtstart (comp, &datetime);
+ else
+ e_cal_component_get_due (comp, &datetime);
+
+ appointment_zone = icaltimezone_get_builtin_timezone_from_tzid(datetime.tzid);
+ current_zone = icaltimezone_get_builtin_timezone_from_tzid(current_timezone);
+ if (!appointment_zone || datetime.value->is_date) { // If it's today put in the current timezone?
+ appointment_zone = current_zone;
+ }
+
+ // TODO: Convert the timezone into a 3 letter abbreviation if it's different to current_timezone
+ // TODO: Add the appointment timezone to the list if it's not already there.
+
+ struct comp_instance *ci;
+ ci = g_new (struct comp_instance, 1);
+
+ g_debug("Using times start %s, end %s", ctime(&instance_start), ctime(&instance_end));
+
+ ci->comp = comp;
+ ci->source = E_SOURCE(data);
+ ci->start = instance_start;
+ ci->end = instance_end;
+
+ comp_instances = g_list_append(comp_instances, ci);
+ return TRUE;
+}
+
+/* Populate the menu with todays, next 5 appointments.
+ * we should hook into the ABOUT TO SHOW signal and use that to update the appointments.
+ * Experience has shown that caldav's and webcals can be slow to load from eds
+ * this is a problem mainly on the EDS side of things, not ours.
+ */
+static gboolean
+update_appointment_menu_items (gpointer user_data)
+{
+ // FFR: we should take into account short term timers, for instance
+ // tea timers, pomodoro timers etc... that people may add, this is hinted to in the spec.
+ g_debug("Update appointments called");
+ if (calendar == NULL) return FALSE;
+ if (!g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) return FALSE;
+ if (updating_appointments) return TRUE;
+ updating_appointments = TRUE;
+
+ time_t curtime = 0, t1 = 0, t2 = 0;
+ gchar *ad;
+ GList *l;
+ GSList *g;
+ GError *gerror = NULL;
+ gint i;
+ gint width = 0, height = 0;
+ ESourceList * sources = NULL;
+
+ // Get today & work out query times
+ time(&curtime);
+ struct tm *today = localtime(&curtime);
+ const int mday = today->tm_mday;
+ const int mon = today->tm_mon;
+ const int year = today->tm_year;
+
+ int start_month_saved = mon;
+
+ struct tm *start_tm = NULL;
+ int this_year = today->tm_year + 1900;
+ int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
+ if ((this_year % 400 == 0) || (this_year % 100 > 0 && this_year % 4 == 0)) days[1] = 29;
+
+ int highlightdays = days[mon] - mday + 1;
+ t1 = curtime; // By default the current time is the appointment start time.
+
+ if (start_time_appointments > 0) {
+ start_tm = localtime(&start_time_appointments);
+ int start_month = start_tm->tm_mon;
+ start_month_saved = start_month;
+ int start_year = start_tm->tm_year + 1900;
+ if ((start_month != mon) || (start_year != this_year)) {
+ // Set t1 to the start of that month.
+ struct tm month_start = {0};
+ month_start.tm_year = start_tm->tm_year;
+ month_start.tm_mon = start_tm->tm_mon;
+ month_start.tm_mday = 1;
+ t1 = mktime(&month_start);
+ highlightdays = days[start_month];
+ }
+ }
+
+ g_debug("Will highlight %d days from %s", highlightdays, ctime(&t1));
+
+ highlightdays = highlightdays + 7; // Minimum of 7 days ahead
+ t2 = t1 + (time_t) (highlightdays * 24 * 60 * 60);
+
+ if (!e_cal_get_sources(&sources, E_CAL_SOURCE_TYPE_EVENT, &gerror)) {
+ g_debug("Failed to get ecal sources\n");
+ return FALSE;
+ }
+
+ // Free comp_instances if not NULL
+ if (comp_instances != NULL) {
+ g_debug("Freeing comp_instances: may be an overlap\n");
+ for (l = comp_instances; l; l = l->next) {
+ const struct comp_instance *ci = l->data;
+ g_object_unref(ci->comp);
+ g_list_free(comp_instances);
+ comp_instances = NULL;
+ }
+ }
+ GSList *cal_list = gconf_client_get_list(gconf, "/apps/evolution/calendar/display/selected_calendars", GCONF_VALUE_STRING, &gerror);
+ if (gerror) {
+ g_debug("Failed to get evolution preference for enabled calendars");
+ g_error_free(gerror);
+ gerror = NULL;
+ cal_list = NULL;
+ }
+ // Generate instances for all sources
+ for (g = e_source_list_peek_groups (sources); g; g = g->next) {
+ ESourceGroup *group = E_SOURCE_GROUP (g->data);
+ GSList *s;
+
+ for (s = e_source_group_peek_sources (group); s; s = s->next) {
+ ESource *source = E_SOURCE (s->data);
+ g_signal_connect (G_OBJECT(source), "changed", G_CALLBACK (update_appointment_menu_items), NULL);
+ ECal *ecal = e_cal_new(source, E_CAL_SOURCE_TYPE_EVENT);
+ e_cal_set_auth_func (ecal, (ECalAuthFunc) auth_func, NULL);
+
+ if (!e_cal_open(ecal, FALSE, &gerror)) {
+ g_debug("Failed to get ecal sources %s", gerror->message);
+ g_error_free(gerror);
+ gerror = NULL;
+ continue;
+ }
+ const gchar *ecal_uid = e_source_peek_uid(source);
+ gboolean match = FALSE;
+ g_debug("Checking ecal_uid is enabled: %s", ecal_uid);
+ for (i = 0; i<g_slist_length(cal_list);i++) {
+ char *cuid = (char *)g_slist_nth_data(cal_list, i);
+ if (g_strcmp0(cuid, ecal_uid) == 0) {
+ match = TRUE;
+ break;
+ }
+ }
+ if (!match) continue;
+ g_debug("ecal_uid is enabled, generating instances");
+
+ e_cal_generate_instances (ecal, t1, t2, (ECalRecurInstanceFn) populate_appointment_instances, (gpointer) source);
+ }
+ }
+ g_debug("Number of ECalComponents returned: %d", g_list_length(comp_instances));
+ GList *sorted_comp_instances = g_list_sort(comp_instances, compare_comp_instances);
+ comp_instances = NULL;
+ g_debug("Components sorted");
+
+ /* Hiding all of the previous appointments */
+ if (appointments != NULL) {
+ g_debug("Hiding old appointments");
+ GList * appointment;
+ for (appointment = appointments; appointment != NULL; appointment = g_list_next(appointment)) {
+ DbusmenuMenuitem * litem = DBUSMENU_MENUITEM(appointment->data);
+ g_debug("Hiding old appointment: %p", litem);
+ // Remove all the existing menu items which are in appointments.
+ dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(litem), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ }
+ }
+
+ gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
+ if (width <= 0) width = 12;
+ if (height <= 0) height = 12;
+ if (width > 30) width = 12;
+ if (height > 30) height = 12;
+
+ gchar *time_format_str = g_settings_get_string(conf, SETTINGS_TIME_FORMAT_S);
+ gint apt_output;
+ if (g_strcmp0(time_format_str, "12-hour") == 0) {
+ apt_output = SETTINGS_TIME_12_HOUR;
+ } else if (g_strcmp0(time_format_str, "24-hour") == 0) {
+ apt_output = SETTINGS_TIME_24_HOUR;
+ } else {
+ if (is_locale_12h()) {
+ apt_output = SETTINGS_TIME_12_HOUR;
+ } else {
+ apt_output = SETTINGS_TIME_24_HOUR;
+ }
+ }
+
+ GVariantBuilder markeddays;
+ g_variant_builder_init (&markeddays, G_VARIANT_TYPE_ARRAY);
+
+ i = 0;
+ GList * cached_appointment = appointments;
+ for (l = sorted_comp_instances; l; l = l->next) {
+ struct comp_instance *ci = l->data;
+ ECalComponent *ecalcomp = ci->comp;
+ ECalComponentText valuetext;
+ gchar *summary, *cmd;
+ char right[20];
+ //const gchar *uri;
+ DbusmenuMenuitem * item;
+
+ ECalComponentVType vtype = e_cal_component_get_vtype (ecalcomp);
+ struct tm due_data = {0};
+ struct tm *due = NULL;
+ if (vtype == E_CAL_COMPONENT_EVENT) due = localtime_r(&ci->start, &due_data);
+ else if (vtype == E_CAL_COMPONENT_TODO) due = localtime_r(&ci->end, &due_data);
+ else continue;
+
+ const int dmday = due->tm_mday;
+ const int dmon = due->tm_mon;
+ const int dyear = due->tm_year;
+
+ if (start_month_saved == dmon) {
+ // Mark day if our query hasn't hit the next month.
+ g_debug("Adding marked date %s, %d", ctime(&ci->start), dmday);
+ g_variant_builder_add (&markeddays, "i", dmday);
+ }
+
+ // If the appointment time is less than the selected date,
+ // don't create an appointment item for it.
+ if (vtype == E_CAL_COMPONENT_EVENT) {
+ if (ci->start < start_time_appointments) continue;
+ } else if (vtype == E_CAL_COMPONENT_TODO) {
+ if (ci->end < start_time_appointments) continue;
+ }
+
+ if (i >= 5) continue;
+ i++;
+
+ if (cached_appointment == NULL) {
+ g_debug("Create menu item");
+
+ item = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set (item, DBUSMENU_MENUITEM_PROP_TYPE, APPOINTMENT_MENUITEM_TYPE);
+
+ dbusmenu_menuitem_child_add_position (root, item, 2+i);
+ appointments = g_list_append (appointments, item); // Keep track of the items here to make them easy to remove
+ } else {
+ item = DBUSMENU_MENUITEM(cached_appointment->data);
+ cached_appointment = g_list_next(cached_appointment);
+
+ /* Remove the icon as we might not replace it on error */
+ dbusmenu_menuitem_property_remove(item, APPOINTMENT_MENUITEM_PROP_ICON);
+
+ /* Remove the activate handler */
+ g_signal_handlers_disconnect_matched(G_OBJECT(item), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, G_CALLBACK(activate_cb), NULL);
+ }
+
+ dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
+ dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+
+
+ // Label text
+ e_cal_component_get_summary (ecalcomp, &valuetext);
+ summary = g_strdup (valuetext.value);
+
+ dbusmenu_menuitem_property_set (item, APPOINTMENT_MENUITEM_PROP_LABEL, summary);
+ g_debug("Summary: %s", summary);
+ g_free (summary);
+
+ gboolean full_day = FALSE;
+ if (vtype == E_CAL_COMPONENT_EVENT) {
+ time_t start = ci->start;
+ if (time_add_day(start, 1) == ci->end) {
+ full_day = TRUE;
+ }
+ }
+
+ // Due text
+ if (full_day) {
+ struct tm fulldaytime = {0};
+ gmtime_r(&ci->start, &fulldaytime);
+
+ /* TRANSLATORS: This is a strftime string for the day for full day events
+ in the menu. It should most likely be either '%A' for a full text day
+ (Wednesday) or '%a' for a shortened one (Wed). You should only need to
+ change for '%a' in the case of langauges with very long day names. */
+ strftime(right, 20, _("%A"), &fulldaytime);
+ } else {
+ if (apt_output == SETTINGS_TIME_12_HOUR) {
+ if ((mday == dmday) && (mon == dmon) && (year == dyear))
+ strftime(right, 20, _(DEFAULT_TIME_12_FORMAT), due);
+ else
+ strftime(right, 20, _(DEFAULT_TIME_12_FORMAT_WITH_DAY), due);
+ } else if (apt_output == SETTINGS_TIME_24_HOUR) {
+ if ((mday == dmday) && (mon == dmon) && (year == dyear))
+ strftime(right, 20, _(DEFAULT_TIME_24_FORMAT), due);
+ else
+ strftime(right, 20, _(DEFAULT_TIME_24_FORMAT_WITH_DAY), due);
+ }
+ }
+ g_debug("Appointment time: %s, for date %s", right, asctime(due));
+ dbusmenu_menuitem_property_set (item, APPOINTMENT_MENUITEM_PROP_RIGHT, right);
+
+ // Now we pull out the URI for the calendar event and try to create a URI that'll work when we execute evolution
+ // FIXME Because the URI stuff is really broken, we're going to open the calendar at todays date instead
+ //e_cal_component_get_uid(ecalcomp, &uri);
+ ad = isodate_from_time_t(mktime(due));
+ cmd = g_strconcat("evolution calendar:///?startdate=", ad, NULL);
+ g_signal_connect (G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
+ G_CALLBACK (activate_cb), cmd);
+
+ g_debug("Command to Execute: %s", cmd);
+
+ const gchar *color_spec = e_source_peek_color_spec(ci->source);
+ g_debug("Colour to use: %s", color_spec);
+
+ // Draw the correct icon for the appointment type and then tint it using mask fill.
+ // For now we'll create a circle
+ if (color_spec != NULL) {
+ GdkColor color;
+ gdk_color_parse (color_spec, &color);
+ g_debug("Creating a cairo surface: size, %d by %d", width, height);
+ cairo_surface_t *surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, width, height );
+
+ cairo_t *cr = cairo_create(surface);
+ gdk_cairo_set_source_color(cr, &color);
+ cairo_paint(cr);
+ cairo_set_source_rgba(cr, 0,0,0,0.5);
+ cairo_set_line_width(cr, 1);
+ cairo_rectangle (cr, 0.5, 0.5, width-1, height-1);
+ cairo_stroke(cr);
+ // Convert to pixbuf, in gtk3 this is done with gdk_pixbuf_get_from_surface
+ cairo_content_t content = cairo_surface_get_content (surface) | CAIRO_CONTENT_COLOR;
+ GdkPixbuf *pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ !!(content & CAIRO_CONTENT_ALPHA),
+ 8, width, height);
+ if (pixbuf != NULL) {
+ gint sstride = cairo_image_surface_get_stride( surface );
+ gint dstride = gdk_pixbuf_get_rowstride (pixbuf);
+ guchar *spixels = cairo_image_surface_get_data( surface );
+ guchar *dpixels = gdk_pixbuf_get_pixels (pixbuf);
+
+ int x, y;
+ for (y = 0; y < height; y++) {
+ guint32 *src = (guint32 *) spixels;
+
+ for (x = 0; x < width; x++) {
+ guint alpha = src[x] >> 24;
+
+ if (alpha == 0) {
+ dpixels[x * 4 + 0] = 0;
+ dpixels[x * 4 + 1] = 0;
+ dpixels[x * 4 + 2] = 0;
+ } else {
+ dpixels[x * 4 + 0] = (((src[x] & 0xff0000) >> 16) * 255 + alpha / 2) / alpha;
+ dpixels[x * 4 + 1] = (((src[x] & 0x00ff00) >> 8) * 255 + alpha / 2) / alpha;
+ dpixels[x * 4 + 2] = (((src[x] & 0x0000ff) >> 0) * 255 + alpha / 2) / alpha;
+ }
+ dpixels[x * 4 + 3] = alpha;
+ }
+ spixels += sstride;
+ dpixels += dstride;
+ }
+
+ dbusmenu_menuitem_property_set_image (item, APPOINTMENT_MENUITEM_PROP_ICON, pixbuf);
+ } else {
+ g_debug("Creating pixbuf from surface failed");
+ }
+ cairo_surface_destroy (surface);
+ cairo_destroy(cr);
+ }
+ g_debug("Adding appointment: %p", item);
+ }
+
+ if (gerror != NULL) g_error_free(gerror);
+ for (l = sorted_comp_instances; l; l = l->next) {
+ const struct comp_instance *ci = l->data;
+ g_object_unref(ci->comp);
+ }
+ g_list_free(sorted_comp_instances);
+
+ GVariant * marks = g_variant_builder_end (&markeddays);
+ dbusmenu_menuitem_property_set_variant (calendar, CALENDAR_MENUITEM_PROP_MARKS, marks);
+
+ updating_appointments = FALSE;
+ g_debug("End of objects");
+ return TRUE;
+}
+
+/* Looks for the time and date admin application and enables the
+ item we have one */
+static gboolean
+check_for_timeadmin (gpointer user_data)
+{
+ g_return_val_if_fail (settings != NULL, FALSE);
+
+ gchar * timeadmin = g_find_program_in_path("indicator-datetime-preferences");
+ if (timeadmin != NULL) {
+ g_debug("Found the indicator-datetime-preferences application: %s", timeadmin);
+ dbusmenu_menuitem_property_set_bool(settings, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
+ g_free(timeadmin);
+ } else {
+ g_debug("Unable to find indicator-datetime-preferences app.");
+ dbusmenu_menuitem_property_set_bool(settings, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
+ }
+
+ return FALSE;
+}
+
+static void
+show_locations_changed (void)
+{
+ /* Re-calculate */
+ check_timezone_sync();
+}
+
+static void
+time_format_changed (void)
+{
+ update_appointment_menu_items(NULL);
+}
+
+/* Does the work to build the default menu, really calls out
+ to other functions but this is the core to clean up the
+ main function. */
+static void
+build_menus (DbusmenuMenuitem * root)
+{
+ g_debug("Building Menus.");
+ if (date == NULL) {
+ date = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set (date, DBUSMENU_MENUITEM_PROP_LABEL, _("No date yet..."));
+ dbusmenu_menuitem_property_set_bool(date, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
+ dbusmenu_menuitem_child_append(root, date);
+
+ g_idle_add(update_datetime, NULL);
+ }
+
+ if (calendar == NULL) {
+ calendar = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set (calendar, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CALENDAR_MENUITEM_TYPE);
+ /* insensitive until we check for available apps */
+ dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
+ g_signal_connect (G_OBJECT(calendar), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
+ G_CALLBACK (activate_cb), "evolution -c calendar");
+ dbusmenu_menuitem_child_append(root, calendar);
+
+ g_idle_add(check_for_calendar, NULL);
+ }
+
+ locations_separator = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(locations_separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
+ dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ dbusmenu_menuitem_child_append(root, locations_separator);
+
+ geo_location = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set (geo_location, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE);
+ set_current_timezone_label (geo_location, "");
+ dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
+ dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ g_signal_connect(G_OBJECT(geo_location), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL);
+ dbusmenu_menuitem_child_append(root, geo_location);
+
+ current_location = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set (current_location, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE);
+ set_current_timezone_label (current_location, "");
+ dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
+ dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ dbusmenu_menuitem_child_append(root, current_location);
+
+ check_timezone_sync();
+
+ g_signal_connect (conf, "changed::" SETTINGS_SHOW_LOCATIONS_S, G_CALLBACK (show_locations_changed), NULL);
+ g_signal_connect (conf, "changed::" SETTINGS_LOCATIONS_S, G_CALLBACK (show_locations_changed), NULL);
+ g_signal_connect (conf, "changed::" SETTINGS_SHOW_EVENTS_S, G_CALLBACK (show_events_changed), NULL);
+ g_signal_connect (conf, "changed::" SETTINGS_TIME_FORMAT_S, G_CALLBACK (time_format_changed), NULL);
+
+ DbusmenuMenuitem * separator = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
+ dbusmenu_menuitem_child_append(root, separator);
+
+ settings = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set (settings, DBUSMENU_MENUITEM_PROP_LABEL, _("Time & Date Settings..."));
+ /* insensitive until we check for available apps */
+ dbusmenu_menuitem_property_set_bool(settings, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
+ g_signal_connect(G_OBJECT(settings), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), "indicator-datetime-preferences");
+ dbusmenu_menuitem_child_append(root, settings);
+ g_idle_add(check_for_timeadmin, NULL);
+
+ return;
+}
+
+/* Run when the timezone file changes */
+static void
+timezone_changed (GFileMonitor * monitor, GFile * file, GFile * otherfile, GFileMonitorEvent event, gpointer user_data)
+{
+ update_current_timezone();
+ datetime_interface_update(DATETIME_INTERFACE(user_data));
+ update_datetime(NULL);
+ setup_timer();
+ return;
+}
+
+/* Set up monitoring the timezone file */
+static void
+build_timezone (DatetimeInterface * dbus)
+{
+ GFile * timezonefile = g_file_new_for_path(TIMEZONE_FILE);
+ GFileMonitor * monitor = g_file_monitor_file(timezonefile, G_FILE_MONITOR_NONE, NULL, NULL);
+ if (monitor != NULL) {
+ g_signal_connect(G_OBJECT(monitor), "changed", G_CALLBACK(timezone_changed), dbus);
+ g_debug("Monitoring timezone file: '" TIMEZONE_FILE "'");
+ } else {
+ g_warning("Unable to monitor timezone file: '" TIMEZONE_FILE "'");
+ }
+ return;
+}
+
+/* Source ID for the timer */
+static guint timer = 0;
+
+/* Execute at a given time, update and setup a new
+ timer to go again. */
+static gboolean
+timer_func (gpointer user_data)
+{
+ timer = 0;
+ /* Reset up each time to reduce error */
+ setup_timer();
+ update_datetime(NULL);
+ return FALSE;
+}
+
+/* Sets up the time to launch the timer to update the
+ date in the datetime entry */
+static void
+setup_timer (void)
+{
+ if (timer != 0) {
+ g_source_remove(timer);
+ timer = 0;
+ }
+
+ time_t t;
+ t = time(NULL);
+ struct tm * ltime = localtime(&t);
+
+ timer = g_timeout_add_seconds(((23 - ltime->tm_hour) * 60 * 60) +
+ ((59 - ltime->tm_min) * 60) +
+ ((60 - ltime->tm_sec)) + 60 /* one minute past */,
+ timer_func, NULL);
+
+ return;
+}
+
+static void
+session_active_change_cb (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name,
+ GVariant * parameters, gpointer user_data)
+{
+ // Just returned from suspend
+ if (g_strcmp0(signal_name, "SystemIdleHintChanged") == 0) {
+ gboolean idle = FALSE;
+ g_variant_get(parameters, "(b)", &idle);
+ if (!idle) {
+ datetime_interface_update(DATETIME_INTERFACE(user_data));
+ update_datetime(NULL);
+ setup_timer();
+ }
+ }
+ return;
+}
+
+/* for hooking into console kit signal on wake from suspend */
+static void
+system_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
+{
+ GError * error = NULL;
+
+ GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
+
+ if (error != NULL) {
+ g_warning("Could not grab DBus proxy for ConsoleKit: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ g_signal_connect(proxy, "g-signal", G_CALLBACK(session_active_change_cb), user_data);
+}
+
+/* Callback from getting the address */
+static void
+geo_address_cb (GeoclueAddress * address, int timestamp, GHashTable * addy_data, GeoclueAccuracy * accuracy, GError * error, gpointer user_data)
+{
+ if (error != NULL) {
+ g_warning("Unable to get Geoclue address: %s", error->message);
+ return;
+ }
+
+ g_debug("Geoclue timezone is: %s", (gchar *)g_hash_table_lookup(addy_data, "timezone"));
+
+ if (geo_timezone != NULL) {
+ g_free(geo_timezone);
+ geo_timezone = NULL;
+ }
+
+ gpointer tz_hash = g_hash_table_lookup(addy_data, "timezone");
+ if (tz_hash != NULL) {
+ geo_timezone = g_strdup((gchar *)tz_hash);
+ }
+
+ check_timezone_sync();
+
+ return;
+}
+
+/* Clean up the reference we kept to the address and make sure to
+ drop the signals incase someone else has one. */
+static void
+geo_address_clean (void)
+{
+ if (geo_address == NULL) {
+ return;
+ }
+
+ g_signal_handlers_disconnect_by_func(G_OBJECT(geo_address), geo_address_cb, NULL);
+ g_object_unref(G_OBJECT(geo_address));
+
+ geo_address = NULL;
+
+ return;
+}
+
+/* Clean up and remove all signal handlers from the client as we
+ unreference it as well. */
+static void
+geo_client_clean (void)
+{
+ if (geo_master == NULL) {
+ return;
+ }
+
+ g_signal_handlers_disconnect_by_func(G_OBJECT(geo_master), geo_client_invalid, NULL);
+ g_signal_handlers_disconnect_by_func(G_OBJECT(geo_master), geo_address_change, NULL);
+ g_object_unref(G_OBJECT(geo_master));
+
+ geo_master = NULL;
+
+ return;
+}
+
+/* Callback from creating the address */
+static void
+geo_create_address (GeoclueMasterClient * master, GeoclueAddress * address, GError * error, gpointer user_data)
+{
+ if (error != NULL) {
+ g_warning("Unable to create GeoClue address: %s", error->message);
+ return;
+ }
+
+ /* We shouldn't have created a new address if we already had one
+ so this is a warning. But, it really is only a mem-leak so we
+ don't need to error out. */
+ g_warn_if_fail(geo_address == NULL);
+ geo_address_clean();
+
+ g_debug("Created Geoclue Address");
+ geo_address = address;
+ g_object_ref(G_OBJECT(geo_address));
+
+ geoclue_address_get_address_async(geo_address, geo_address_cb, NULL);
+
+ g_signal_connect(G_OBJECT(address), "address-changed", G_CALLBACK(geo_address_cb), NULL);
+
+ return;
+}
+
+/* Callback from setting requirements */
+static void
+geo_req_set (GeoclueMasterClient * master, GError * error, gpointer user_data)
+{
+ if (error != NULL) {
+ g_warning("Unable to set Geoclue requirements: %s", error->message);
+ }
+ return;
+}
+
+/* Client is killing itself rather oddly */
+static void
+geo_client_invalid (GeoclueMasterClient * client, gpointer user_data)
+{
+ g_warning("Master client invalid, rebuilding.");
+
+ /* Client changes we can assume the address is now invalid so we
+ need to unreference the one we had. */
+ geo_address_clean();
+
+ /* And our master client is invalid */
+ geo_client_clean();
+
+ GeoclueMaster * master = geoclue_master_get_default();
+ geoclue_master_create_client_async(master, geo_create_client, NULL);
+
+ if (geo_timezone != NULL) {
+ g_free(geo_timezone);
+ geo_timezone = NULL;
+ }
+
+ check_timezone_sync();
+
+ return;
+}
+
+/* Address provider changed, we need to get that one */
+static void
+geo_address_change (GeoclueMasterClient * client, gchar * a, gchar * b, gchar * c, gchar * d, gpointer user_data)
+{
+ g_warning("Address provider changed. Let's change");
+
+ /* If the address is supposed to have changed we need to drop the old
+ address before starting to get the new one. */
+ geo_address_clean();
+
+ geoclue_master_client_create_address_async(geo_master, geo_create_address, NULL);
+
+ if (geo_timezone != NULL) {
+ g_free(geo_timezone);
+ geo_timezone = NULL;
+ }
+
+ check_timezone_sync();
+
+ return;
+}
+
+/* Callback from creating the client */
+static void
+geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * path, GError * error, gpointer user_data)
+{
+ g_debug("Created Geoclue client at: %s", path);
+
+ geo_master = client;
+
+ if (geo_master != NULL) {
+ g_warning(_("Unable to get a GeoClue client! Geolocation based timezone support will not be available."));
+ return;
+ }
+
+ g_object_ref(G_OBJECT(geo_master));
+
+ /* New client, make sure we don't have an address hanging on */
+ geo_address_clean();
+
+ geoclue_master_client_set_requirements_async(geo_master,
+ GEOCLUE_ACCURACY_LEVEL_REGION,
+ 0,
+ FALSE,
+ GEOCLUE_RESOURCE_ALL,
+ geo_req_set,
+ NULL);
+
+ geoclue_master_client_create_address_async(geo_master, geo_create_address, NULL);
+
+ g_signal_connect(G_OBJECT(client), "invalidated", G_CALLBACK(geo_client_invalid), NULL);
+ g_signal_connect(G_OBJECT(client), "address-provider-changed", G_CALLBACK(geo_address_change), NULL);
+
+ return;
+}
+
+/* Repsonds to the service object saying it's time to shutdown.
+ It stops the mainloop. */
+static void
+service_shutdown (IndicatorService * service, gpointer user_data)
+{
+ g_warning("Shutting down service!");
+ g_main_loop_quit(mainloop);
+ return;
+}
+
+/* Function to build everything up. Entry point from asm. */
+int
+main (int argc, char ** argv)
+{
+ g_type_init();
+
+ /* Acknowledging the service init and setting up the interface */
+ service = indicator_service_new_version(SERVICE_NAME, SERVICE_VERSION);
+ g_signal_connect(service, INDICATOR_SERVICE_SIGNAL_SHUTDOWN, G_CALLBACK(service_shutdown), NULL);
+
+ /* Setting up i18n and gettext. Apparently, we need
+ all of these. */
+ setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ textdomain (GETTEXT_PACKAGE);
+
+ /* Set up GSettings */
+ conf = g_settings_new(SETTINGS_INTERFACE);
+ /* Set up gconf for getting evolution enabled calendars */
+ gconf = gconf_client_get_default();
+ // TODO Add a signal handler to catch gsettings changes and respond to them
+
+ /* Building the base menu */
+ server = dbusmenu_server_new(MENU_OBJ);
+ root = dbusmenu_menuitem_new();
+ dbusmenu_server_set_root(server, root);
+
+ build_menus(root);
+
+ /* Cache the timezone */
+ update_current_timezone();
+
+ /* Setup geoclue */
+ GeoclueMaster * master = geoclue_master_get_default();
+ geoclue_master_create_client_async(master, geo_create_client, NULL);
+
+ /* Setup dbus interface */
+ dbus = g_object_new(DATETIME_INTERFACE_TYPE, NULL);
+
+ /* Setup timezone watch */
+ build_timezone(dbus);
+
+ /* Setup the timer */
+ setup_timer();
+
+ /* And watch for system resumes */
+ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ "org.freedesktop.ConsoleKit",
+ "/org/freedesktop/ConsoleKit/Manager",
+ "org.freedesktop.ConsoleKit.Manager",
+ NULL, system_proxy_cb, dbus);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ g_object_unref(G_OBJECT(conf));
+ g_object_unref(G_OBJECT(master));
+ g_object_unref(G_OBJECT(dbus));
+ g_object_unref(G_OBJECT(service));
+ g_object_unref(G_OBJECT(server));
+ g_object_unref(G_OBJECT(root));
+
+ geo_address_clean();
+ geo_client_clean();
+
+ return 0;
+}
diff --git a/src/datetime-service.xml b/src/datetime-service.xml
new file mode 100644
index 0000000..eda064f
--- /dev/null
+++ b/src/datetime-service.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<node name="/">
+ <interface name="com.canonical.indicator.datetime.service">
+
+<!-- Methods -->
+
+<!-- Signals -->
+ <signal name="UpdateTime" />
+
+ </interface>
+</node>
diff --git a/src/dbus-shared.h b/src/dbus-shared.h
new file mode 100644
index 0000000..9e3a781
--- /dev/null
+++ b/src/dbus-shared.h
@@ -0,0 +1,42 @@
+/*
+An indicator to show date and time information.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+
+#define SERVICE_NAME "com.canonical.indicator.datetime"
+#define SERVICE_IFACE "com.canonical.indicator.datetime.service"
+#define SERVICE_OBJ "/com/canonical/indicator/datetime/service"
+#define SERVICE_VERSION 1
+
+#define MENU_OBJ "/com/canonical/indicator/datetime/menu"
+
+#define DBUSMENU_CALENDAR_MENUITEM_TYPE "x-canonical-calendar-item"
+
+#define CALENDAR_MENUITEM_PROP_MARKS "calendar-marks"
+
+#define APPOINTMENT_MENUITEM_TYPE "appointment-item"
+#define APPOINTMENT_MENUITEM_PROP_LABEL "appointment-label"
+#define APPOINTMENT_MENUITEM_PROP_ICON "appointment-icon"
+#define APPOINTMENT_MENUITEM_PROP_RIGHT "appointment-time"
+
+#define TIMEZONE_MENUITEM_TYPE "timezone-item"
+#define TIMEZONE_MENUITEM_PROP_ZONE "timezone-zone"
+#define TIMEZONE_MENUITEM_PROP_NAME "timezone-name"
+#define TIMEZONE_MENUITEM_PROP_RADIO "timezone-radio"
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c
new file mode 100644
index 0000000..eb4b695
--- /dev/null
+++ b/src/indicator-datetime.c
@@ -0,0 +1,1535 @@
+/*
+An indicator to time and date related information in the menubar.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <locale.h>
+#include <langinfo.h>
+#include <string.h>
+#include <time.h>
+
+/* GStuff */
+#include <glib.h>
+#include <glib/gprintf.h>
+#include <glib-object.h>
+#include <glib/gi18n-lib.h>
+#include <gio/gio.h>
+
+/* Indicator Stuff */
+#include <libindicator/indicator.h>
+#include <libindicator/indicator-object.h>
+#include <libindicator/indicator-service-manager.h>
+
+/* DBusMenu */
+#include <libdbusmenu-gtk/menu.h>
+#include <libido/libido.h>
+#include <libdbusmenu-gtk/menuitem.h>
+
+#include "utils.h"
+#include "dbus-shared.h"
+#include "settings-shared.h"
+
+
+#define INDICATOR_DATETIME_TYPE (indicator_datetime_get_type ())
+#define INDICATOR_DATETIME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_DATETIME_TYPE, IndicatorDatetime))
+#define INDICATOR_DATETIME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATOR_DATETIME_TYPE, IndicatorDatetimeClass))
+#define IS_INDICATOR_DATETIME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_DATETIME_TYPE))
+#define IS_INDICATOR_DATETIME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_DATETIME_TYPE))
+#define INDICATOR_DATETIME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_DATETIME_TYPE, IndicatorDatetimeClass))
+
+typedef struct _IndicatorDatetime IndicatorDatetime;
+typedef struct _IndicatorDatetimeClass IndicatorDatetimeClass;
+typedef struct _IndicatorDatetimePrivate IndicatorDatetimePrivate;
+
+struct _IndicatorDatetimeClass {
+ IndicatorObjectClass parent_class;
+};
+
+struct _IndicatorDatetime {
+ IndicatorObject parent;
+ IndicatorDatetimePrivate * priv;
+};
+
+struct _IndicatorDatetimePrivate {
+ GtkLabel * label;
+ guint timer;
+
+ gchar * time_string;
+
+ gboolean show_clock;
+ gint time_mode;
+ gboolean show_seconds;
+ gboolean show_date;
+ gboolean show_day;
+ gchar * custom_string;
+ gboolean custom_show_seconds;
+
+ gboolean show_week_numbers;
+ gboolean show_calendar;
+ gint week_start;
+
+ guint idle_measure;
+ gint max_width;
+
+ IndicatorServiceManager * sm;
+ DbusmenuGtkMenu * menu;
+
+ GCancellable * service_proxy_cancel;
+ GDBusProxy * service_proxy;
+ IdoCalendarMenuItem *ido_calendar;
+
+ GList * timezone_items;
+
+ GSettings * settings;
+
+ GtkSizeGroup * indicator_right_group;
+};
+
+/* Enum for the properties so that they can be quickly
+ found and looked up. */
+enum {
+ PROP_0,
+ PROP_SHOW_CLOCK,
+ PROP_TIME_FORMAT,
+ PROP_SHOW_SECONDS,
+ PROP_SHOW_DAY,
+ PROP_SHOW_DATE,
+ PROP_CUSTOM_TIME_FORMAT,
+ PROP_SHOW_WEEK_NUMBERS,
+ PROP_SHOW_CALENDAR
+};
+
+typedef struct _indicator_item_t indicator_item_t;
+struct _indicator_item_t {
+ IndicatorDatetime * self;
+ DbusmenuMenuitem * mi;
+ GtkWidget * gmi;
+ GtkWidget * icon;
+ GtkWidget * label;
+ GtkWidget * right;
+};
+
+#define PROP_SHOW_CLOCK_S "show-clock"
+#define PROP_TIME_FORMAT_S "time-format"
+#define PROP_SHOW_SECONDS_S "show-seconds"
+#define PROP_SHOW_DAY_S "show-day"
+#define PROP_SHOW_DATE_S "show-date"
+#define PROP_CUSTOM_TIME_FORMAT_S "custom-time-format"
+#define PROP_SHOW_WEEK_NUMBERS_S "show-week-numbers"
+#define PROP_SHOW_CALENDAR_S "show-calendar"
+
+#define INDICATOR_DATETIME_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_DATETIME_TYPE, IndicatorDatetimePrivate))
+
+enum {
+ STRFTIME_MASK_NONE = 0, /* Hours or minutes as we always test those */
+ STRFTIME_MASK_SECONDS = 1 << 0, /* Seconds count */
+ STRFTIME_MASK_AMPM = 1 << 1, /* AM/PM counts */
+ STRFTIME_MASK_WEEK = 1 << 2, /* Day of the week maters (Sat, Sun, etc.) */
+ STRFTIME_MASK_DAY = 1 << 3, /* Day of the month counts (Feb 1st) */
+ STRFTIME_MASK_MONTH = 1 << 4, /* Which month matters */
+ STRFTIME_MASK_YEAR = 1 << 5, /* Which year matters */
+ /* Last entry, combines all previous */
+ STRFTIME_MASK_ALL = (STRFTIME_MASK_SECONDS | STRFTIME_MASK_AMPM | STRFTIME_MASK_WEEK | STRFTIME_MASK_DAY | STRFTIME_MASK_MONTH | STRFTIME_MASK_YEAR)
+};
+
+GType indicator_datetime_get_type (void);
+
+static void indicator_datetime_class_init (IndicatorDatetimeClass *klass);
+static void indicator_datetime_init (IndicatorDatetime *self);
+static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec);
+static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec);
+static void indicator_datetime_dispose (GObject *object);
+static void indicator_datetime_finalize (GObject *object);
+static GtkLabel * get_label (IndicatorObject * io);
+static GtkMenu * get_menu (IndicatorObject * io);
+static const gchar * get_accessible_desc (IndicatorObject * io);
+static GVariant * bind_enum_set (const GValue * value, const GVariantType * type, gpointer user_data);
+static gboolean bind_enum_get (GValue * value, GVariant * variant, gpointer user_data);
+static gchar * generate_format_string_now (IndicatorDatetime * self);
+static void update_label (IndicatorDatetime * io, GDateTime ** datetime);
+static void guess_label_size (IndicatorDatetime * self);
+static void setup_timer (IndicatorDatetime * self, GDateTime * datetime);
+static void update_time (IndicatorDatetime * self);
+static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data);
+static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data);
+static gint generate_strftime_bitmask (const char *time_str);
+static void timezone_update_labels (indicator_item_t * mi_data);
+static gboolean new_calendar_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data);
+static gboolean new_appointment_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data);
+static gboolean new_timezone_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data);
+
+/* Indicator Module Config */
+INDICATOR_SET_VERSION
+INDICATOR_SET_TYPE(INDICATOR_DATETIME_TYPE)
+
+G_DEFINE_TYPE (IndicatorDatetime, indicator_datetime, INDICATOR_OBJECT_TYPE);
+
+static void
+indicator_datetime_class_init (IndicatorDatetimeClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (IndicatorDatetimePrivate));
+
+ object_class->dispose = indicator_datetime_dispose;
+ object_class->finalize = indicator_datetime_finalize;
+
+ object_class->set_property = set_property;
+ object_class->get_property = get_property;
+
+ IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass);
+
+ io_class->get_label = get_label;
+ io_class->get_menu = get_menu;
+ io_class->get_accessible_desc = get_accessible_desc;
+
+ g_object_class_install_property (object_class,
+ PROP_SHOW_CLOCK,
+ g_param_spec_boolean(PROP_SHOW_CLOCK_S,
+ "Whether to show the clock in the menu bar.",
+ "Shows indicator-datetime in the shell's menu bar.",
+ TRUE, /* default */
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class,
+ PROP_TIME_FORMAT,
+ g_param_spec_int(PROP_TIME_FORMAT_S,
+ "A choice of which format should be used on the panel",
+ "Chooses between letting the locale choose the time, 12-hour time, 24-time or using the custom string passed to strftime().",
+ SETTINGS_TIME_LOCALE, /* min */
+ SETTINGS_TIME_CUSTOM, /* max */
+ SETTINGS_TIME_LOCALE, /* default */
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class,
+ PROP_SHOW_SECONDS,
+ g_param_spec_boolean(PROP_SHOW_SECONDS_S,
+ "Whether to show seconds in the indicator.",
+ "Shows seconds along with the time in the indicator. Also effects refresh interval.",
+ FALSE, /* default */
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class,
+ PROP_SHOW_DAY,
+ g_param_spec_boolean(PROP_SHOW_DAY_S,
+ "Whether to show the day of the week in the indicator.",
+ "Shows the day of the week along with the time in the indicator.",
+ FALSE, /* default */
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class,
+ PROP_SHOW_DATE,
+ g_param_spec_boolean(PROP_SHOW_DATE_S,
+ "Whether to show the day and month in the indicator.",
+ "Shows the day and month along with the time in the indicator.",
+ FALSE, /* default */
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class,
+ PROP_CUSTOM_TIME_FORMAT,
+ g_param_spec_string(PROP_CUSTOM_TIME_FORMAT_S,
+ "The format that is used to show the time on the panel.",
+ "A format string in the form used to pass to strftime to make a string for displaying on the panel.",
+ DEFAULT_TIME_FORMAT,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_SHOW_WEEK_NUMBERS,
+ g_param_spec_boolean(PROP_SHOW_WEEK_NUMBERS_S,
+ "Whether to show the week numbers in the calendar.",
+ "Shows the week numbers in the monthly calendar in indicator-datetime's menu.",
+ FALSE, /* default */
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class,
+ PROP_SHOW_CALENDAR,
+ g_param_spec_boolean(PROP_SHOW_CALENDAR_S,
+ "Whether to show the calendar.",
+ "Shows the monthly calendar in indicator-datetime's menu.",
+ TRUE, /* default */
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ return;
+}
+
+static void
+menu_visible_notfy_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpointer user_data)
+{
+ IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
+ g_debug("notify visible signal recieved");
+
+ // we should only react if we're currently visible
+ gboolean visible;
+ g_object_get(G_OBJECT(menu), "visible", &visible, NULL);
+ if (visible) return;
+ g_debug("notify visible menu hidden, resetting date");
+
+ time_t curtime;
+
+ time(&curtime);
+ struct tm *today = localtime(&curtime);
+ int y = today->tm_year;
+ int m = today->tm_mon;
+ int d = today->tm_mday;
+
+ // Set the calendar to todays date
+ ido_calendar_menu_item_set_date (self->priv->ido_calendar, y+1900, m, d);
+
+ // Make sure the day-selected signal is sent so the menu updates - may duplicate
+ /*GVariant *variant = g_variant_new_uint32((guint)curtime);
+ guint timestamp = (guint)time(NULL);
+ dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(self->priv->ido_calendar), "day-selected", variant, timestamp);*/
+}
+
+static void
+indicator_datetime_init (IndicatorDatetime *self)
+{
+ self->priv = INDICATOR_DATETIME_GET_PRIVATE(self);
+
+ self->priv->label = NULL;
+ self->priv->timer = 0;
+
+ self->priv->idle_measure = 0;
+ self->priv->max_width = 0;
+
+ self->priv->show_clock = TRUE;
+ self->priv->time_mode = SETTINGS_TIME_LOCALE;
+ self->priv->show_seconds = FALSE;
+ self->priv->show_date = FALSE;
+ self->priv->show_day = FALSE;
+ self->priv->custom_string = g_strdup(DEFAULT_TIME_FORMAT);
+ self->priv->custom_show_seconds = FALSE;
+
+ self->priv->time_string = generate_format_string_now(self);
+
+ self->priv->service_proxy = NULL;
+
+ self->priv->sm = NULL;
+ self->priv->menu = NULL;
+
+ self->priv->settings = g_settings_new(SETTINGS_INTERFACE);
+ if (self->priv->settings != NULL) {
+ g_settings_bind(self->priv->settings,
+ SETTINGS_SHOW_CLOCK_S,
+ self,
+ PROP_SHOW_CLOCK_S,
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind_with_mapping(self->priv->settings,
+ SETTINGS_TIME_FORMAT_S,
+ self,
+ PROP_TIME_FORMAT_S,
+ G_SETTINGS_BIND_DEFAULT,
+ bind_enum_get,
+ bind_enum_set,
+ NULL, NULL); /* Userdata and destroy func */
+ g_settings_bind(self->priv->settings,
+ SETTINGS_SHOW_SECONDS_S,
+ self,
+ PROP_SHOW_SECONDS_S,
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind(self->priv->settings,
+ SETTINGS_SHOW_DAY_S,
+ self,
+ PROP_SHOW_DAY_S,
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind(self->priv->settings,
+ SETTINGS_SHOW_DATE_S,
+ self,
+ PROP_SHOW_DATE_S,
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind(self->priv->settings,
+ SETTINGS_CUSTOM_TIME_FORMAT_S,
+ self,
+ PROP_CUSTOM_TIME_FORMAT_S,
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind(self->priv->settings,
+ SETTINGS_SHOW_WEEK_NUMBERS_S,
+ self,
+ PROP_SHOW_WEEK_NUMBERS_S,
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind(self->priv->settings,
+ SETTINGS_SHOW_CALENDAR_S,
+ self,
+ PROP_SHOW_CALENDAR_S,
+ G_SETTINGS_BIND_DEFAULT);
+ } else {
+ g_warning("Unable to get settings for '" SETTINGS_INTERFACE "'");
+ }
+
+ self->priv->sm = indicator_service_manager_new_version(SERVICE_NAME, SERVICE_VERSION);
+ self->priv->indicator_right_group = GTK_SIZE_GROUP(gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL));
+
+ self->priv->menu = dbusmenu_gtkmenu_new(SERVICE_NAME, MENU_OBJ);
+
+ g_signal_connect(self->priv->menu, "notify::visible", G_CALLBACK(menu_visible_notfy_cb), self);
+
+ DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(self->priv->menu);
+ dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), DBUSMENU_CALENDAR_MENUITEM_TYPE, new_calendar_item, self, NULL);
+ dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), APPOINTMENT_MENUITEM_TYPE, new_appointment_item, self, NULL);
+ dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), TIMEZONE_MENUITEM_TYPE, new_timezone_item, self, NULL);
+
+ self->priv->service_proxy_cancel = g_cancellable_new();
+
+ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ SERVICE_NAME,
+ SERVICE_OBJ,
+ SERVICE_IFACE,
+ self->priv->service_proxy_cancel,
+ service_proxy_cb,
+ self);
+
+ return;
+}
+
+/* Callback from trying to create the proxy for the serivce, this
+ could include starting the service. Sometime it'll fail and
+ we'll try to start that dang service again! */
+static void
+service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
+{
+ GError * error = NULL;
+
+ IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
+ g_return_if_fail(self != NULL);
+
+ GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
+
+ IndicatorDatetimePrivate * priv = INDICATOR_DATETIME_GET_PRIVATE(self);
+
+ if (priv->service_proxy_cancel != NULL) {
+ g_object_unref(priv->service_proxy_cancel);
+ priv->service_proxy_cancel = NULL;
+ }
+
+ if (error != NULL) {
+ g_warning("Could not grab DBus proxy for %s: %s", SERVICE_NAME, error->message);
+ g_error_free(error);
+ return;
+ }
+
+ /* Okay, we're good to grab the proxy at this point, we're
+ sure that it's ours. */
+ priv->service_proxy = proxy;
+
+ g_signal_connect(proxy, "g-signal", G_CALLBACK(receive_signal), self);
+
+ return;
+}
+
+static void
+indicator_datetime_dispose (GObject *object)
+{
+ IndicatorDatetime * self = INDICATOR_DATETIME(object);
+
+ if (self->priv->label != NULL) {
+ g_object_unref(self->priv->label);
+ self->priv->label = NULL;
+ }
+
+ if (self->priv->timer != 0) {
+ g_source_remove(self->priv->timer);
+ self->priv->timer = 0;
+ }
+
+ if (self->priv->idle_measure != 0) {
+ g_source_remove(self->priv->idle_measure);
+ self->priv->idle_measure = 0;
+ }
+
+ if (self->priv->menu != NULL) {
+ g_object_unref(G_OBJECT(self->priv->menu));
+ self->priv->menu = NULL;
+ }
+
+ if (self->priv->sm != NULL) {
+ g_object_unref(G_OBJECT(self->priv->sm));
+ self->priv->sm = NULL;
+ }
+
+ if (self->priv->settings != NULL) {
+ g_object_unref(G_OBJECT(self->priv->settings));
+ self->priv->settings = NULL;
+ }
+
+ if (self->priv->service_proxy != NULL) {
+ g_object_unref(self->priv->service_proxy);
+ self->priv->service_proxy = NULL;
+ }
+
+ if (self->priv->indicator_right_group != NULL) {
+ g_object_unref(G_OBJECT(self->priv->indicator_right_group));
+ self->priv->indicator_right_group = NULL;
+ }
+
+ G_OBJECT_CLASS (indicator_datetime_parent_class)->dispose (object);
+ return;
+}
+
+static void
+indicator_datetime_finalize (GObject *object)
+{
+ IndicatorDatetime * self = INDICATOR_DATETIME(object);
+
+ if (self->priv->time_string != NULL) {
+ g_free(self->priv->time_string);
+ self->priv->time_string = NULL;
+ }
+
+ if (self->priv->custom_string != NULL) {
+ g_free(self->priv->custom_string);
+ self->priv->custom_string = NULL;
+ }
+
+ G_OBJECT_CLASS (indicator_datetime_parent_class)->finalize (object);
+ return;
+}
+
+/* Turns the int value into a string GVariant */
+static GVariant *
+bind_enum_set (const GValue * value, const GVariantType * type, gpointer user_data)
+{
+ switch (g_value_get_int(value)) {
+ case SETTINGS_TIME_LOCALE:
+ return g_variant_new_string("locale-default");
+ case SETTINGS_TIME_12_HOUR:
+ return g_variant_new_string("12-hour");
+ case SETTINGS_TIME_24_HOUR:
+ return g_variant_new_string("24-hour");
+ case SETTINGS_TIME_CUSTOM:
+ return g_variant_new_string("custom");
+ default:
+ return NULL;
+ }
+}
+
+/* Turns a string GVariant into an int value */
+static gboolean
+bind_enum_get (GValue * value, GVariant * variant, gpointer user_data)
+{
+ const gchar * str = g_variant_get_string(variant, NULL);
+ gint output = 0;
+
+ if (g_strcmp0(str, "locale-default") == 0) {
+ output = SETTINGS_TIME_LOCALE;
+ } else if (g_strcmp0(str, "12-hour") == 0) {
+ output = SETTINGS_TIME_12_HOUR;
+ } else if (g_strcmp0(str, "24-hour") == 0) {
+ output = SETTINGS_TIME_24_HOUR;
+ } else if (g_strcmp0(str, "custom") == 0) {
+ output = SETTINGS_TIME_CUSTOM;
+ } else {
+ return FALSE;
+ }
+
+ g_value_set_int(value, output);
+ return TRUE;
+}
+
+static void
+timezone_update_all_labels (IndicatorDatetime * self)
+{
+ IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(self);
+ g_list_foreach(priv->timezone_items, (GFunc)timezone_update_labels, NULL);
+}
+
+/* Sets a property on the object */
+static void
+set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
+{
+ IndicatorDatetime * self = INDICATOR_DATETIME(object);
+ gboolean update = FALSE;
+
+ switch(prop_id) {
+ case PROP_SHOW_CLOCK: {
+ if (g_value_get_boolean(value) != self->priv->show_clock) {
+ self->priv->show_clock = g_value_get_boolean(value);
+ if (self->priv->label != NULL) {
+ gtk_widget_set_visible (GTK_WIDGET (self->priv->label), self->priv->show_clock);
+ }
+ }
+ break;
+ }
+ case PROP_TIME_FORMAT: {
+ gint newval = g_value_get_int(value);
+ if (newval != self->priv->time_mode) {
+ update = TRUE;
+ self->priv->time_mode = newval;
+ setup_timer(self, NULL);
+ }
+ break;
+ }
+ case PROP_SHOW_SECONDS: {
+ if (g_value_get_boolean(value) != self->priv->show_seconds) {
+ self->priv->show_seconds = !self->priv->show_seconds;
+ if (self->priv->time_mode != SETTINGS_TIME_CUSTOM) {
+ update = TRUE;
+ setup_timer(self, NULL);
+ }
+ }
+ break;
+ }
+ case PROP_SHOW_DAY: {
+ if (g_value_get_boolean(value) != self->priv->show_day) {
+ self->priv->show_day = !self->priv->show_day;
+ if (self->priv->time_mode != SETTINGS_TIME_CUSTOM) {
+ update = TRUE;
+ }
+ }
+ break;
+ }
+ case PROP_SHOW_DATE: {
+ if (g_value_get_boolean(value) != self->priv->show_date) {
+ self->priv->show_date = !self->priv->show_date;
+ if (self->priv->time_mode != SETTINGS_TIME_CUSTOM) {
+ update = TRUE;
+ }
+ }
+ break;
+ }
+ case PROP_CUSTOM_TIME_FORMAT: {
+ const gchar * newstr = g_value_get_string(value);
+ if (g_strcmp0(newstr, self->priv->custom_string) != 0) {
+ if (self->priv->custom_string != NULL) {
+ g_free(self->priv->custom_string);
+ self->priv->custom_string = NULL;
+ }
+ self->priv->custom_string = g_strdup(newstr);
+ gint time_mask = generate_strftime_bitmask(newstr);
+ self->priv->custom_show_seconds = (time_mask & STRFTIME_MASK_SECONDS);
+ if (self->priv->time_mode == SETTINGS_TIME_CUSTOM) {
+ update = TRUE;
+ setup_timer(self, NULL);
+ }
+ }
+ break;
+ }
+ case PROP_SHOW_WEEK_NUMBERS: {
+ if (g_value_get_boolean(value) != self->priv->show_week_numbers) {
+ GtkCalendarDisplayOptions flags = ido_calendar_menu_item_get_display_options (self->priv->ido_calendar);
+ if (g_value_get_boolean(value) == TRUE)
+ flags |= GTK_CALENDAR_SHOW_WEEK_NUMBERS;
+ else
+ flags &= ~GTK_CALENDAR_SHOW_WEEK_NUMBERS;
+ ido_calendar_menu_item_set_display_options (self->priv->ido_calendar, flags);
+ self->priv->show_week_numbers = g_value_get_boolean(value);
+ }
+ break;
+ }
+ case PROP_SHOW_CALENDAR: {
+ if (g_value_get_boolean(value) != self->priv->show_calendar) {
+ self->priv->show_calendar = g_value_get_boolean(value);
+ if (self->priv->ido_calendar != NULL) {
+ gtk_widget_set_visible (GTK_WIDGET (self->priv->ido_calendar), self->priv->show_calendar);
+ }
+ }
+ break;
+ }
+ default: {
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ return;
+ }
+ }
+
+ if (!update) {
+ return;
+ }
+
+ /* Get the new format string */
+ gchar * newformat = generate_format_string_now(self);
+
+ /* check to ensure the format really changed */
+ if (g_strcmp0(self->priv->time_string, newformat) == 0) {
+ g_free(newformat);
+ return;
+ }
+
+ /* Okay now process the change */
+ if (self->priv->time_string != NULL) {
+ g_free(self->priv->time_string);
+ self->priv->time_string = NULL;
+ }
+ self->priv->time_string = newformat;
+
+ /* And update everything */
+ update_label(self, NULL);
+ timezone_update_all_labels(self);
+ guess_label_size(self);
+
+ return;
+}
+
+/* Gets a property from the object */
+static void
+get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
+{
+ IndicatorDatetime * self = INDICATOR_DATETIME(object);
+
+ switch(prop_id) {
+ case PROP_SHOW_CLOCK:
+ g_value_set_boolean(value, self->priv->show_clock);
+ break;
+ case PROP_TIME_FORMAT:
+ g_value_set_int(value, self->priv->time_mode);
+ break;
+ case PROP_SHOW_SECONDS:
+ g_value_set_boolean(value, self->priv->show_seconds);
+ break;
+ case PROP_SHOW_DAY:
+ g_value_set_boolean(value, self->priv->show_day);
+ break;
+ case PROP_SHOW_DATE:
+ g_value_set_boolean(value, self->priv->show_date);
+ break;
+ case PROP_CUSTOM_TIME_FORMAT:
+ g_value_set_string(value, self->priv->custom_string);
+ break;
+ case PROP_SHOW_WEEK_NUMBERS:
+ g_value_set_boolean(value, self->priv->show_week_numbers);
+ break;
+ case PROP_SHOW_CALENDAR:
+ g_value_set_boolean(value, self->priv->show_calendar);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ return;
+ }
+
+ return;
+}
+
+/* Looks at the size of the label, if it grew beyond what we
+ thought was the max, make sure it doesn't shrink again. */
+static gboolean
+idle_measure (gpointer data)
+{
+ IndicatorDatetime * self = INDICATOR_DATETIME(data);
+ self->priv->idle_measure = 0;
+
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(GTK_WIDGET(self->priv->label), &allocation);
+
+ if (allocation.width > self->priv->max_width) {
+ if (self->priv->max_width != 0) {
+ g_warning("Guessed wrong. We thought the max would be %d but we're now at %d", self->priv->max_width, allocation.width);
+ }
+ self->priv->max_width = allocation.width;
+ gtk_widget_set_size_request(GTK_WIDGET(self->priv->label), self->priv->max_width, -1);
+ }
+
+ return FALSE;
+}
+
+/* Updates the accessible description */
+static void
+update_accessible_description (IndicatorDatetime * io)
+{
+ GList * entries = indicator_object_get_entries(INDICATOR_OBJECT(io));
+ IndicatorObjectEntry * entry = (IndicatorObjectEntry *)entries->data;
+
+ entry->accessible_desc = get_accessible_desc(INDICATOR_OBJECT(io));
+
+ g_signal_emit(G_OBJECT(io),
+ INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID,
+ 0,
+ entry,
+ TRUE);
+
+ g_list_free(entries);
+
+ return;
+}
+
+/* Updates the label to be the current time. */
+static void
+set_label_to_time_in_zone (IndicatorDatetime * self, GtkLabel * label,
+ GTimeZone * tz, const gchar * format,
+ GDateTime ** datetime)
+{
+ GDateTime * datetime_now;
+ if (tz == NULL)
+ datetime_now = g_date_time_new_now_local();
+ else
+ datetime_now = g_date_time_new_now(tz);
+
+ gchar * timestr;
+ if (format == NULL) {
+ gchar * format_for_time = generate_format_string_at_time(datetime_now);
+ timestr = g_date_time_format(datetime_now, format_for_time);
+ g_free(format_for_time);
+ }
+ else {
+ timestr = g_date_time_format(datetime_now, format);
+ }
+
+ gboolean use_markup = FALSE;
+ if (pango_parse_markup(timestr, -1, 0, NULL, NULL, NULL, NULL))
+ use_markup = TRUE;
+
+ if (use_markup)
+ gtk_label_set_markup(label, timestr);
+ else
+ gtk_label_set_text(label, timestr);
+
+ g_free(timestr);
+
+ if (datetime)
+ *datetime = datetime_now;
+ else
+ g_date_time_unref(datetime_now);
+
+ return;
+}
+
+/* Updates the label to be the current time. */
+static void
+update_label (IndicatorDatetime * io, GDateTime ** datetime)
+{
+ IndicatorDatetime * self = INDICATOR_DATETIME(io);
+
+ if (self->priv->label == NULL) return;
+
+ set_label_to_time_in_zone(self, self->priv->label, NULL, self->priv->time_string, datetime);
+
+ if (self->priv->idle_measure == 0) {
+ self->priv->idle_measure = g_idle_add(idle_measure, io);
+ }
+
+ update_accessible_description(io);
+
+ return;
+}
+
+/* Update the time right now. Usually the result of a timezone switch. */
+static void
+update_time (IndicatorDatetime * self)
+{
+ GDateTime * dt;
+ update_label(self, &dt);
+ timezone_update_all_labels(self);
+ setup_timer(self, dt);
+ g_date_time_unref(dt);
+ return;
+}
+
+/* Receives all signals from the service, routed to the appropriate functions */
+static void
+receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name,
+ GVariant * parameters, gpointer user_data)
+{
+ IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
+
+ if (g_strcmp0(signal_name, "UpdateTime") == 0) {
+ update_time(self);
+ }
+
+ return;
+}
+
+/* Runs every minute and updates the time */
+gboolean
+timer_func (gpointer user_data)
+{
+ IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
+ self->priv->timer = 0;
+ GDateTime * dt;
+ update_label(self, &dt);
+ timezone_update_all_labels(self);
+ setup_timer(self, dt);
+ g_date_time_unref(dt);
+ return FALSE;
+}
+
+/* Configure the timer to run the next time through */
+static void
+setup_timer (IndicatorDatetime * self, GDateTime * datetime)
+{
+ gboolean unref = FALSE;
+
+ if (self->priv->timer != 0) {
+ g_source_remove(self->priv->timer);
+ self->priv->timer = 0;
+ }
+
+ if (self->priv->show_seconds ||
+ (self->priv->time_mode == SETTINGS_TIME_CUSTOM && self->priv->custom_show_seconds)) {
+ self->priv->timer = g_timeout_add_full(G_PRIORITY_HIGH, 999, timer_func, self, NULL);
+ } else {
+ if (datetime == NULL) {
+ datetime = g_date_time_new_now_local();
+ unref = TRUE;
+ }
+
+ /* Plus 2 so we're just after the minute, don't want to be early. */
+ gint seconds = (gint)g_date_time_get_seconds(datetime);
+ self->priv->timer = g_timeout_add_seconds(60 - seconds + 2, timer_func, self);
+
+ if (unref) {
+ g_date_time_unref(datetime);
+ }
+ }
+
+ return;
+}
+
+/* Does a quick meausre of how big the string is in
+ pixels with a Pango layout */
+static gint
+measure_string (GtkStyle * style, PangoContext * context, const gchar * string)
+{
+ PangoLayout * layout = pango_layout_new(context);
+
+ if (pango_parse_markup(string, -1, 0, NULL, NULL, NULL, NULL))
+ pango_layout_set_markup(layout, string, -1);
+ else
+ pango_layout_set_text(layout, string, -1);
+
+ pango_layout_set_font_description(layout, style->font_desc);
+
+ gint width;
+ pango_layout_get_pixel_size(layout, &width, NULL);
+ g_object_unref(layout);
+ return width;
+}
+
+/* Format for the table of strftime() modifiers to what
+ we need to check when determining the length */
+typedef struct _strftime_type_t strftime_type_t;
+struct _strftime_type_t {
+ char character;
+ gint mask;
+};
+
+/* A table taken from the man page of strftime to what the different
+ characters can effect. These are worst case in that we need to
+ test the length based on all these things to ensure that we have
+ a reasonable string lenght measurement. */
+const static strftime_type_t strftime_type[] = {
+ {'a', STRFTIME_MASK_WEEK},
+ {'A', STRFTIME_MASK_WEEK},
+ {'b', STRFTIME_MASK_MONTH},
+ {'B', STRFTIME_MASK_MONTH},
+ {'c', STRFTIME_MASK_ALL}, /* We don't know, so we have to assume all */
+ {'C', STRFTIME_MASK_YEAR},
+ {'d', STRFTIME_MASK_MONTH},
+ {'D', STRFTIME_MASK_MONTH | STRFTIME_MASK_YEAR | STRFTIME_MASK_DAY},
+ {'e', STRFTIME_MASK_DAY},
+ {'F', STRFTIME_MASK_MONTH | STRFTIME_MASK_YEAR | STRFTIME_MASK_DAY},
+ {'G', STRFTIME_MASK_YEAR},
+ {'g', STRFTIME_MASK_YEAR},
+ {'h', STRFTIME_MASK_MONTH},
+ {'j', STRFTIME_MASK_DAY},
+ {'m', STRFTIME_MASK_MONTH},
+ {'p', STRFTIME_MASK_AMPM},
+ {'P', STRFTIME_MASK_AMPM},
+ {'r', STRFTIME_MASK_AMPM},
+ {'s', STRFTIME_MASK_SECONDS},
+ {'S', STRFTIME_MASK_SECONDS},
+ {'T', STRFTIME_MASK_SECONDS},
+ {'u', STRFTIME_MASK_WEEK},
+ {'U', STRFTIME_MASK_DAY | STRFTIME_MASK_MONTH},
+ {'V', STRFTIME_MASK_DAY | STRFTIME_MASK_MONTH},
+ {'w', STRFTIME_MASK_DAY},
+ {'W', STRFTIME_MASK_DAY | STRFTIME_MASK_MONTH},
+ {'x', STRFTIME_MASK_YEAR | STRFTIME_MASK_MONTH | STRFTIME_MASK_DAY | STRFTIME_MASK_WEEK},
+ {'X', STRFTIME_MASK_SECONDS},
+ {'y', STRFTIME_MASK_YEAR},
+ {'Y', STRFTIME_MASK_YEAR},
+ /* Last one */
+ {0, 0}
+};
+
+#define FAT_NUMBER 8
+
+/* Looks through the characters in the format string to
+ ensure that we can figure out which of the things we
+ need to check in determining the length. */
+static gint
+generate_strftime_bitmask (const char *time_str)
+{
+ gint retval = 0;
+ glong strlength = g_utf8_strlen(time_str, -1);
+ gint i;
+ g_debug("Evaluating bitmask for '%s'", time_str);
+
+ for (i = 0; i < strlength; i++) {
+ if (time_str[i] == '%' && i + 1 < strlength) {
+ gchar evalchar = time_str[i + 1];
+
+ /* If we're using alternate formats we need to skip those characters */
+ if (evalchar == 'E' || evalchar == 'O') {
+ if (i + 2 < strlength) {
+ evalchar = time_str[i + 2];
+ } else {
+ continue;
+ }
+ }
+
+ /* Let's look at that character in the table */
+ int j;
+ for (j = 0; strftime_type[j].character != 0; j++) {
+ if (strftime_type[j].character == evalchar) {
+ retval |= strftime_type[j].mask;
+ break;
+ }
+ }
+ }
+ }
+
+ return retval;
+}
+
+/* Build an array up of all the time values that we want to check
+ for length to ensure we're in a good place */
+static void
+build_timeval_array (GArray * timevals, gint mask)
+{
+ struct tm mytm = {0};
+
+ /* Sun 12/28/8888 00:00 */
+ mytm.tm_hour = 0;
+ mytm.tm_mday = 28;
+ mytm.tm_mon = 11;
+ mytm.tm_year = 8888 - 1900;
+ mytm.tm_wday = 0;
+ mytm.tm_yday = 363;
+ g_array_append_val(timevals, mytm);
+
+ if (mask & STRFTIME_MASK_AMPM) {
+ /* Sun 12/28/8888 12:00 */
+ mytm.tm_hour = 12;
+ g_array_append_val(timevals, mytm);
+ }
+
+ /* NOTE: Ignoring year 8888 should handle it */
+
+ if (mask & STRFTIME_MASK_MONTH) {
+ gint oldlen = timevals->len;
+ gint i, j;
+ for (i = 0; i < oldlen; i++) {
+ for (j = 0; j < 11; j++) {
+ struct tm localval = g_array_index(timevals, struct tm, i);
+ localval.tm_mon = j;
+ /* Not sure if I need to adjust yday & wday, hope not */
+ g_array_append_val(timevals, localval);
+ }
+ }
+ }
+
+ /* Doing these together as it seems like just slightly more
+ coverage on the numerical days, but worth it. */
+ if (mask & (STRFTIME_MASK_WEEK | STRFTIME_MASK_DAY)) {
+ gint oldlen = timevals->len;
+ gint i, j;
+ for (i = 0; i < oldlen; i++) {
+ for (j = 22; j < 28; j++) {
+ struct tm localval = g_array_index(timevals, struct tm, i);
+
+ gint diff = 28 - j;
+
+ localval.tm_mday = j;
+ localval.tm_wday = localval.tm_wday - diff;
+ if (localval.tm_wday < 0) {
+ localval.tm_wday += 7;
+ }
+ localval.tm_yday = localval.tm_yday - diff;
+
+ g_array_append_val(timevals, localval);
+ }
+ }
+ }
+
+ return;
+}
+
+/* Try to get a good guess at what a maximum width of the entire
+ string would be. */
+static void
+guess_label_size (IndicatorDatetime * self)
+{
+ /* This is during startup. */
+ if (self->priv->label == NULL) return;
+
+ GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(self->priv->label));
+ PangoContext * context = gtk_widget_get_pango_context(GTK_WIDGET(self->priv->label));
+ gint * max_width = &(self->priv->max_width);
+ gint posibilitymask = generate_strftime_bitmask(self->priv->time_string);
+
+ /* Reset max width */
+ *max_width = 0;
+
+ /* Build the array of possibilities that we want to test */
+ GArray * timevals = g_array_new(FALSE, TRUE, sizeof(struct tm));
+ build_timeval_array(timevals, posibilitymask);
+
+ g_debug("Checking against %d posible times", timevals->len);
+ gint check_time;
+ for (check_time = 0; check_time < timevals->len; check_time++) {
+ gchar longstr[256];
+ strftime(longstr, 256, self->priv->time_string, &(g_array_index(timevals, struct tm, check_time)));
+
+ gchar * utf8 = g_locale_to_utf8(longstr, -1, NULL, NULL, NULL);
+ gint length = measure_string(style, context, utf8);
+ g_free(utf8);
+
+ if (length > *max_width) {
+ *max_width = length;
+ }
+ }
+
+ g_array_free(timevals, TRUE);
+
+ gtk_widget_set_size_request(GTK_WIDGET(self->priv->label), self->priv->max_width, -1);
+ g_debug("Guessing max time width: %d", self->priv->max_width);
+
+ return;
+}
+
+/* React to the style changing, which could mean an font
+ update. */
+static void
+style_changed (GtkWidget * widget, GtkStyle * oldstyle, gpointer data)
+{
+ g_debug("New style for time label");
+ IndicatorDatetime * self = INDICATOR_DATETIME(data);
+ guess_label_size(self);
+ update_label(self, NULL);
+ timezone_update_all_labels(self);
+ return;
+}
+
+/* Respond to changes in the screen to update the text gravity */
+static void
+update_text_gravity (GtkWidget *widget, GdkScreen *previous_screen, gpointer data)
+{
+ IndicatorDatetime * self = INDICATOR_DATETIME(data);
+ if (self->priv->label == NULL) return;
+
+ PangoLayout *layout;
+ PangoContext *context;
+
+ layout = gtk_label_get_layout (GTK_LABEL(self->priv->label));
+ context = pango_layout_get_context(layout);
+ pango_context_set_base_gravity(context, PANGO_GRAVITY_AUTO);
+}
+
+static gchar *
+generate_format_string_now (IndicatorDatetime * self)
+{
+ if (self->priv->time_mode == SETTINGS_TIME_CUSTOM) {
+ return g_strdup(self->priv->custom_string);
+ }
+ else {
+ return generate_format_string_full(self->priv->show_day,
+ self->priv->show_date);
+ }
+}
+
+static void
+timezone_update_labels (indicator_item_t * mi_data)
+{
+ const gchar * zone = dbusmenu_menuitem_property_get(mi_data->mi, TIMEZONE_MENUITEM_PROP_ZONE);
+ const gchar * name = dbusmenu_menuitem_property_get(mi_data->mi, TIMEZONE_MENUITEM_PROP_NAME);
+
+ gtk_label_set_text(GTK_LABEL(mi_data->label), name);
+
+ /* Show current time in that zone on the right */
+ GTimeZone * tz = g_time_zone_new(zone);
+ set_label_to_time_in_zone(mi_data->self, GTK_LABEL(mi_data->right), tz, NULL, NULL);
+ g_time_zone_unref(tz);
+}
+
+/* Whenever we have a property change on a DbusmenuMenuitem
+ we need to be responsive to that. */
+static void
+indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant *value, indicator_item_t * mi_data)
+{
+ if (!g_strcmp0(prop, APPOINTMENT_MENUITEM_PROP_LABEL)) {
+ /* Set the main label */
+ gtk_label_set_text(GTK_LABEL(mi_data->label), g_variant_get_string(value, NULL));
+ } else if (!g_strcmp0(prop, APPOINTMENT_MENUITEM_PROP_RIGHT)) {
+ /* Set the right label */
+ gtk_label_set_text(GTK_LABEL(mi_data->right), g_variant_get_string(value, NULL));
+ } else if (!g_strcmp0(prop, APPOINTMENT_MENUITEM_PROP_ICON)) {
+ /* We don't use the value here, which is probably less efficient,
+ but it's easier to use the easy function. And since th value
+ is already cached, shouldn't be a big deal really. */
+ GdkPixbuf * pixbuf = dbusmenu_menuitem_property_get_image(mi, APPOINTMENT_MENUITEM_PROP_ICON);
+ if (pixbuf != NULL) {
+ /* If we've got a pixbuf we need to make sure it's of a reasonable
+ size to fit in the menu. If not, rescale it. */
+ GdkPixbuf * resized_pixbuf;
+ gint width, height;
+ gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
+ if (gdk_pixbuf_get_width(pixbuf) > width ||
+ gdk_pixbuf_get_height(pixbuf) > height) {
+ g_debug("Resizing icon from %dx%d to %dx%d", gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), width, height);
+ resized_pixbuf = gdk_pixbuf_scale_simple(pixbuf,
+ width,
+ height,
+ GDK_INTERP_BILINEAR);
+ } else {
+ g_debug("Happy with icon sized %dx%d", gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf));
+ resized_pixbuf = pixbuf;
+ }
+ gtk_image_set_from_pixbuf(GTK_IMAGE(mi_data->icon), resized_pixbuf);
+ /* The other pixbuf should be free'd by the dbusmenu. */
+ if (resized_pixbuf != pixbuf) {
+ g_object_unref(resized_pixbuf);
+ }
+ }
+ } else if (!g_strcmp0(prop, TIMEZONE_MENUITEM_PROP_ZONE)) {
+ timezone_update_labels(mi_data);
+ } else if (!g_strcmp0(prop, TIMEZONE_MENUITEM_PROP_NAME)) {
+ timezone_update_labels(mi_data);
+ } else if (!g_strcmp0(prop, TIMEZONE_MENUITEM_PROP_RADIO)) {
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi_data->gmi), g_variant_get_boolean(value));
+ }
+ return;
+}
+// Properties for marking and unmarking the calendar
+static void
+calendar_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant *value, IdoCalendarMenuItem * mi_data)
+{
+ g_debug("Changing calendar property: %s", prop);
+ if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_MARKS)) {
+ ido_calendar_menu_item_clear_marks (IDO_CALENDAR_MENU_ITEM (mi_data));
+
+ if (value != NULL) {
+ GVariantIter *iter;
+ gint day;
+
+ g_debug("\tMarks: %s", g_variant_print(value, FALSE));
+
+ g_variant_get (value, "ai", &iter);
+ while (g_variant_iter_loop (iter, "i", &day)) {
+ ido_calendar_menu_item_mark_day (IDO_CALENDAR_MENU_ITEM (mi_data), day);
+ }
+ g_variant_iter_free (iter);
+ } else {
+ g_debug("\tMarks: <cleared>");
+ }
+ }
+ return;
+}
+
+/* We have a small little menuitem type that handles all
+ of the fun stuff for indicators. Mostly this is the
+ shifting over and putting the icon in with some right
+ side text that'll be determined by the service.
+ Copied verbatim from an old revision (including comments) of indicator-messages
+*/
+static gboolean
+new_appointment_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data)
+{
+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
+ g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
+ g_return_val_if_fail(IS_INDICATOR_DATETIME(user_data), FALSE);
+ /* Note: not checking parent, it's reasonable for it to be NULL */
+ IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
+
+ indicator_item_t * mi_data = g_new0(indicator_item_t, 1);
+
+ mi_data->gmi = gtk_menu_item_new();
+
+ GtkWidget * hbox = gtk_hbox_new(FALSE, 4);
+
+ /* Icon, probably someone's face or avatar on an IM */
+ mi_data->icon = gtk_image_new();
+ GdkPixbuf * pixbuf = dbusmenu_menuitem_property_get_image(newitem, APPOINTMENT_MENUITEM_PROP_ICON);
+
+ if (pixbuf != NULL) {
+ /* If we've got a pixbuf we need to make sure it's of a reasonable
+ size to fit in the menu. If not, rescale it. */
+ GdkPixbuf * resized_pixbuf;
+ gint width, height;
+ gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
+ if (gdk_pixbuf_get_width(pixbuf) > width ||
+ gdk_pixbuf_get_height(pixbuf) > height) {
+ g_debug("Resizing icon from %dx%d to %dx%d", gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), width, height);
+ resized_pixbuf = gdk_pixbuf_scale_simple(pixbuf,
+ width,
+ height,
+ GDK_INTERP_BILINEAR);
+ } else {
+ g_debug("Happy with icon sized %dx%d", gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf));
+ resized_pixbuf = pixbuf;
+ }
+
+ gtk_image_set_from_pixbuf(GTK_IMAGE(mi_data->icon), resized_pixbuf);
+
+ /* The other pixbuf should be free'd by the dbusmenu. */
+ if (resized_pixbuf != pixbuf) {
+ g_object_unref(resized_pixbuf);
+ }
+ }
+ gtk_misc_set_alignment(GTK_MISC(mi_data->icon), 0.0, 0.5);
+ gtk_box_pack_start(GTK_BOX(hbox), mi_data->icon, FALSE, FALSE, 0);
+ gtk_widget_show(mi_data->icon);
+
+ /* Label, probably a username, chat room or mailbox name */
+ mi_data->label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, APPOINTMENT_MENUITEM_PROP_LABEL));
+ gtk_misc_set_alignment(GTK_MISC(mi_data->label), 0.0, 0.5);
+
+ GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(mi_data->label));
+ PangoContext * context = gtk_widget_get_pango_context(GTK_WIDGET(mi_data->label));
+ gint length = measure_string(style, context, "MMMMMMMMMMMMMMM"); // 15 char wide string max
+ gtk_widget_set_size_request(GTK_WIDGET(mi_data->label), length, -1); // Set the min size in pixels
+
+ gtk_label_set_ellipsize(GTK_LABEL(mi_data->label), PANGO_ELLIPSIZE_END);
+ gtk_box_pack_start(GTK_BOX(hbox), mi_data->label, TRUE, TRUE, 0);
+ gtk_widget_show(mi_data->label);
+
+ /* Usually either the time or the count on the individual
+ item. */
+ mi_data->right = gtk_label_new(dbusmenu_menuitem_property_get(newitem, APPOINTMENT_MENUITEM_PROP_RIGHT));
+ gtk_size_group_add_widget(self->priv->indicator_right_group, mi_data->right);
+ gtk_misc_set_alignment(GTK_MISC(mi_data->right), 1.0, 0.5);
+ gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, 0);
+ gtk_widget_show(mi_data->right);
+
+ gtk_container_add(GTK_CONTAINER(mi_data->gmi), hbox);
+ gtk_widget_show(hbox);
+
+ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(mi_data->gmi), parent);
+
+ g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(indicator_prop_change_cb), mi_data);
+ return TRUE;
+}
+
+static void
+month_changed_cb (IdoCalendarMenuItem *ido,
+ gpointer user_data)
+{
+ guint d,m,y;
+ DbusmenuMenuitem * item = DBUSMENU_MENUITEM (user_data);
+ ido_calendar_menu_item_get_date(ido, &y, &m, &d);
+ struct tm date = {0};
+ date.tm_mday = d;
+ date.tm_mon = m;
+ date.tm_year = y - 1900;
+ guint selecteddate = (guint)mktime(&date);
+ g_debug("Got month changed signal: %s", asctime(&date));
+ GVariant *variant = g_variant_new_uint32(selecteddate);
+ guint timestamp = (guint)time(NULL);
+ dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), "month-changed", variant, timestamp);
+}
+
+static void
+day_selected_cb (IdoCalendarMenuItem *ido,
+ gpointer user_data)
+{
+ guint d,m,y;
+ DbusmenuMenuitem * item = DBUSMENU_MENUITEM (user_data);
+ ido_calendar_menu_item_get_date(ido, &y, &m, &d);
+ struct tm date = {0};
+ date.tm_mday = d;
+ date.tm_mon = m;
+ date.tm_year = y - 1900;
+ guint selecteddate = (guint)mktime(&date);
+ g_debug("Got day selected signal: %s", asctime(&date));
+ GVariant *variant = g_variant_new_uint32(selecteddate);
+ guint timestamp = (guint)time(NULL);
+ dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), "day-selected", variant, timestamp);
+}
+
+static void
+day_selected_double_click_cb (IdoCalendarMenuItem *ido,
+ gpointer user_data)
+{
+ guint d,m,y;
+ DbusmenuMenuitem * item = DBUSMENU_MENUITEM (user_data);
+ ido_calendar_menu_item_get_date(ido, &y, &m, &d);
+ struct tm date = {0};
+ date.tm_mday = d;
+ date.tm_mon = m;
+ date.tm_year = y - 1900;
+ guint selecteddate = (guint)mktime(&date);
+ g_debug("Got day selected double click signal: %s", asctime(&date));
+ GVariant *variant = g_variant_new_uint32(selecteddate);
+ guint timestamp = (guint)time(NULL);
+ dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), "day-selected-double-click", variant, timestamp);
+}
+
+static gboolean
+new_calendar_item (DbusmenuMenuitem * newitem,
+ DbusmenuMenuitem * parent,
+ DbusmenuClient * client,
+ gpointer user_data)
+{
+ g_debug("New calendar item");
+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
+ g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
+ g_return_val_if_fail(IS_INDICATOR_DATETIME(user_data), FALSE);
+ /* Note: not checking parent, it's reasonable for it to be NULL */
+
+ IndicatorDatetime *self = INDICATOR_DATETIME(user_data);
+ self->priv = INDICATOR_DATETIME_GET_PRIVATE(self);
+
+ IdoCalendarMenuItem *ido = IDO_CALENDAR_MENU_ITEM (ido_calendar_menu_item_new ());
+ self->priv->ido_calendar = ido;
+
+ GtkCalendarDisplayOptions flags = ido_calendar_menu_item_get_display_options (self->priv->ido_calendar);
+ if (self->priv->show_week_numbers == TRUE)
+ flags |= GTK_CALENDAR_SHOW_WEEK_NUMBERS;
+ else
+ flags &= ~GTK_CALENDAR_SHOW_WEEK_NUMBERS;
+ ido_calendar_menu_item_set_display_options (self->priv->ido_calendar, flags);
+
+ gtk_widget_set_visible (GTK_WIDGET (self->priv->ido_calendar), self->priv->show_calendar);
+
+ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent);
+
+ g_signal_connect_after(ido, "month-changed", G_CALLBACK(month_changed_cb), (gpointer)newitem);
+ g_signal_connect_after(ido, "day-selected", G_CALLBACK(day_selected_cb), (gpointer)newitem);
+ g_signal_connect_after(ido, "day-selected-double-click", G_CALLBACK(day_selected_double_click_cb), (gpointer)newitem);
+
+ g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(calendar_prop_change_cb), ido);
+
+ /* Run the current values through prop changed */
+ GVariant * propval = NULL;
+
+ propval = dbusmenu_menuitem_property_get_variant(newitem, CALENDAR_MENUITEM_PROP_MARKS);
+ if (propval != NULL) {
+ calendar_prop_change_cb(newitem, CALENDAR_MENUITEM_PROP_MARKS, propval, ido);
+ }
+
+ return TRUE;
+}
+
+static void
+timezone_toggled_cb (GtkCheckMenuItem *checkmenuitem, DbusmenuMenuitem * dbusitem)
+{
+ /* Make sure that the displayed radio-active setting is always
+ consistent with the dbus menuitem */
+ gtk_check_menu_item_set_active(checkmenuitem,
+ dbusmenu_menuitem_property_get_bool(dbusitem, TIMEZONE_MENUITEM_PROP_RADIO));
+}
+
+static void
+timezone_destroyed_cb (indicator_item_t * mi_data, DbusmenuMenuitem * dbusitem)
+{
+ IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(mi_data->self);
+ priv->timezone_items = g_list_remove(priv->timezone_items, mi_data);
+ g_signal_handlers_disconnect_by_func(G_OBJECT(mi_data->gmi), G_CALLBACK(timezone_toggled_cb), dbusitem);
+ g_free(mi_data);
+}
+
+static gboolean
+new_timezone_item(DbusmenuMenuitem * newitem,
+ DbusmenuMenuitem * parent,
+ DbusmenuClient * client,
+ gpointer user_data)
+{
+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
+ g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
+ g_return_val_if_fail(IS_INDICATOR_DATETIME(user_data), FALSE);
+ /* Note: not checking parent, it's reasonable for it to be NULL */
+
+ IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
+ IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(self);
+
+ // Menu item with a radio button and a right aligned time
+ indicator_item_t * mi_data = g_new0(indicator_item_t, 1);
+
+ priv->timezone_items = g_list_prepend(priv->timezone_items, mi_data);
+
+ mi_data->self = self;
+ mi_data->mi = newitem;
+ mi_data->gmi = gtk_check_menu_item_new();
+
+ gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(mi_data->gmi), TRUE);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi_data->gmi),
+ dbusmenu_menuitem_property_get_bool(newitem, TIMEZONE_MENUITEM_PROP_RADIO));
+
+ GtkWidget * hbox = gtk_hbox_new(FALSE, 4);
+
+ /* Label, probably a username, chat room or mailbox name */
+ mi_data->label = gtk_label_new("");
+ gtk_misc_set_alignment(GTK_MISC(mi_data->label), 0.0, 0.5);
+ gtk_box_pack_start(GTK_BOX(hbox), mi_data->label, TRUE, TRUE, 0);
+ gtk_widget_show(mi_data->label);
+
+ /* Usually either the time or the count on the individual
+ item. */
+ mi_data->right = gtk_label_new("");
+ gtk_size_group_add_widget(self->priv->indicator_right_group, mi_data->right);
+ gtk_misc_set_alignment(GTK_MISC(mi_data->right), 1.0, 0.5);
+ gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, 0);
+ gtk_widget_show(mi_data->right);
+
+ timezone_update_labels(mi_data);
+
+ gtk_container_add(GTK_CONTAINER(mi_data->gmi), hbox);
+ gtk_widget_show(hbox);
+
+ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(mi_data->gmi), parent);
+
+ g_signal_connect(G_OBJECT(mi_data->gmi), "toggled", G_CALLBACK(timezone_toggled_cb), newitem);
+ g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(indicator_prop_change_cb), mi_data);
+ g_object_weak_ref(G_OBJECT(newitem), (GWeakNotify)timezone_destroyed_cb, mi_data);
+
+ return TRUE;
+}
+
+/* Grabs the label. Creates it if it doesn't
+ exist already */
+static GtkLabel *
+get_label (IndicatorObject * io)
+{
+ IndicatorDatetime * self = INDICATOR_DATETIME(io);
+
+ /* If there's not a label, we'll build ourselves one */
+ if (self->priv->label == NULL) {
+ self->priv->label = GTK_LABEL(gtk_label_new("Time"));
+ gtk_label_set_justify (GTK_LABEL(self->priv->label), GTK_JUSTIFY_CENTER);
+ g_object_ref(G_OBJECT(self->priv->label));
+ g_signal_connect(G_OBJECT(self->priv->label), "style-set", G_CALLBACK(style_changed), self);
+ g_signal_connect(G_OBJECT(self->priv->label), "screen-changed", G_CALLBACK(update_text_gravity), self);
+ guess_label_size(self);
+ update_label(self, NULL);
+ gtk_widget_set_visible(GTK_WIDGET (self->priv->label), self->priv->show_clock);
+ }
+
+ if (self->priv->timer == 0) {
+ setup_timer(self, NULL);
+ }
+
+ return self->priv->label;
+}
+
+static GtkMenu *
+get_menu (IndicatorObject * io)
+{
+ IndicatorDatetime * self = INDICATOR_DATETIME(io);
+
+ return GTK_MENU(self->priv->menu);
+}
+
+static const gchar *
+get_accessible_desc (IndicatorObject * io)
+{
+ IndicatorDatetime * self = INDICATOR_DATETIME(io);
+ const gchar * name;
+
+ if (self->priv->label != NULL) {
+ name = gtk_label_get_text(self->priv->label);
+ return name;
+ }
+ return NULL;
+}
diff --git a/src/settings-shared.h b/src/settings-shared.h
new file mode 100644
index 0000000..da66205
--- /dev/null
+++ b/src/settings-shared.h
@@ -0,0 +1,68 @@
+/*
+An indicator to show date and time information.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __DATETIME_SETTINGS_SHARED_H__
+#define __DATETIME_SETTINGS_SHARED_H__
+
+#define SETTINGS_INTERFACE "com.canonical.indicator.datetime"
+#define SETTINGS_SHOW_CLOCK_S "show-clock"
+#define SETTINGS_TIME_FORMAT_S "time-format"
+#define SETTINGS_SHOW_SECONDS_S "show-seconds"
+#define SETTINGS_SHOW_DAY_S "show-day"
+#define SETTINGS_SHOW_DATE_S "show-date"
+#define SETTINGS_CUSTOM_TIME_FORMAT_S "custom-time-format"
+#define SETTINGS_SHOW_CALENDAR_S "show-calendar"
+#define SETTINGS_SHOW_WEEK_NUMBERS_S "show-week-numbers"
+#define SETTINGS_SHOW_EVENTS_S "show-events"
+#define SETTINGS_SHOW_LOCATIONS_S "show-locations"
+#define SETTINGS_LOCATIONS_S "locations"
+#define SETTINGS_TIMEZONE_NAME_S "timezone-name"
+
+enum {
+ SETTINGS_TIME_LOCALE = 0,
+ SETTINGS_TIME_12_HOUR = 1,
+ SETTINGS_TIME_24_HOUR = 2,
+ SETTINGS_TIME_CUSTOM = 3
+};
+
+/* TRANSLATORS: A format string for the strftime function for
+ a clock showing 12-hour time without seconds. */
+#define DEFAULT_TIME_12_FORMAT N_("%l:%M %p")
+
+/* TRANSLATORS: A format string for the strftime function for
+ a clock showing 24-hour time without seconds. */
+#define DEFAULT_TIME_24_FORMAT N_("%H:%M")
+
+#define DEFAULT_TIME_FORMAT DEFAULT_TIME_12_FORMAT
+#define DEFAULT_TIME_FORMAT_WITH_DAY DEFAULT_TIME_12_FORMAT_WITH_DAY
+
+/* TRANSLATORS: A format string for the strftime function for
+ a clock showing the day of the week and the time in 12-hour format without
+ seconds. */
+#define DEFAULT_TIME_12_FORMAT_WITH_DAY N_("%a %l:%M %p")
+
+/* TRANSLATORS: A format string for the strftime function for
+ a clock showing the day of the week and the time in 24-hour format without
+ seconds. Information is available in this Launchpad answer:
+ https://answers.launchpad.net/ubuntu/+source/indicator-datetime/+question/149752 */
+#define DEFAULT_TIME_24_FORMAT_WITH_DAY N_("%a %H:%M")
+
+#endif
diff --git a/src/timezone-completion.c b/src/timezone-completion.c
new file mode 100644
index 0000000..7dcc28e
--- /dev/null
+++ b/src/timezone-completion.c
@@ -0,0 +1,688 @@
+/* -*- Mode: C; coding: utf-8; indent-tabs-mode: nil; tab-width: 2 -*-
+
+Copyright 2011 Canonical Ltd.
+
+Authors:
+ Michael Terry <michael.terry@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <json-glib/json-glib.h>
+#include <gdk/gdk.h>
+#include <gdk/gdkkeysyms.h>
+#include <glib/gi18n.h>
+#include "timezone-completion.h"
+#include "tz.h"
+
+enum {
+ LAST_SIGNAL
+};
+
+/* static guint signals[LAST_SIGNAL] = { }; */
+
+typedef struct _TimezoneCompletionPrivate TimezoneCompletionPrivate;
+struct _TimezoneCompletionPrivate
+{
+ GtkTreeModel * initial_model;
+ GtkEntry * entry;
+ guint queued_request;
+ guint changed_id;
+ guint keypress_id;
+ GCancellable * cancel;
+ gchar * request_text;
+ GHashTable * request_table;
+};
+
+#define TIMEZONE_COMPLETION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), TIMEZONE_COMPLETION_TYPE, TimezoneCompletionPrivate))
+
+#define GEONAME_URL "http://geoname-lookup.ubuntu.com/?query=%s&release=%s&lang=%s"
+
+/* Prototypes */
+static void timezone_completion_class_init (TimezoneCompletionClass *klass);
+static void timezone_completion_init (TimezoneCompletion *self);
+static void timezone_completion_dispose (GObject *object);
+static void timezone_completion_finalize (GObject *object);
+
+G_DEFINE_TYPE (TimezoneCompletion, timezone_completion, GTK_TYPE_ENTRY_COMPLETION);
+
+static gboolean
+match_func (GtkEntryCompletion *completion, const gchar *key,
+ GtkTreeIter *iter, gpointer user_data)
+{
+ // geonames does the work for us
+ return TRUE;
+}
+
+static void
+save_and_use_model (TimezoneCompletion * completion, GtkTreeModel * model)
+{
+ TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE(completion);
+
+ g_hash_table_insert (priv->request_table, g_strdup (priv->request_text), g_object_ref_sink (model));
+
+ if (model == priv->initial_model)
+ gtk_entry_completion_set_match_func (GTK_ENTRY_COMPLETION (completion), NULL, NULL, NULL);
+ else
+ gtk_entry_completion_set_match_func (GTK_ENTRY_COMPLETION (completion), match_func, NULL, NULL);
+
+ gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion), model);
+
+ if (priv->entry != NULL) {
+ gtk_entry_completion_complete (GTK_ENTRY_COMPLETION (completion));
+
+ /* By this time, the changed signal has come and gone. We didn't give a
+ model to use, so no popup appeared for user. Poke the entry again to show
+ popup in 300ms. */
+ g_signal_emit_by_name (priv->entry, "changed");
+ }
+}
+
+static gint
+sort_zone (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b,
+ gpointer user_data)
+{
+ /* Anything that has text as a prefix goes first, in mostly sorted order.
+ Then everything else goes after, in mostly sorted order. */
+ const gchar *casefolded_text = (const gchar *)user_data;
+
+ const gchar *namea = NULL, *nameb = NULL;
+ gtk_tree_model_get (model, a, TIMEZONE_COMPLETION_NAME, &namea, -1);
+ gtk_tree_model_get (model, b, TIMEZONE_COMPLETION_NAME, &nameb, -1);
+
+ gchar *casefolded_namea = NULL, *casefolded_nameb = NULL;
+ casefolded_namea = g_utf8_casefold (namea, -1);
+ casefolded_nameb = g_utf8_casefold (nameb, -1);
+
+ gboolean amatches = FALSE, bmatches = FALSE;
+ amatches = strncmp (casefolded_text, casefolded_namea, strlen(casefolded_text)) == 0;
+ bmatches = strncmp (casefolded_text, casefolded_nameb, strlen(casefolded_text)) == 0;
+
+ gint rv;
+ if (amatches && !bmatches)
+ rv = -1;
+ else if (bmatches && !amatches)
+ rv = 1;
+ else
+ rv = g_utf8_collate (casefolded_namea, casefolded_nameb);
+
+ g_free (casefolded_namea);
+ g_free (casefolded_nameb);
+ return rv;
+}
+
+static void
+json_parse_ready (GObject *object, GAsyncResult *res, gpointer user_data)
+{
+ TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data);
+ TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE(completion);
+ GError * error = NULL;
+ const gchar * prev_name = NULL;
+ const gchar * prev_admin1 = NULL;
+ const gchar * prev_country = NULL;
+
+ json_parser_load_from_stream_finish (JSON_PARSER (object), res, &error);
+
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) && priv->cancel) {
+ g_cancellable_reset (priv->cancel);
+ }
+
+ if (error != NULL) {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ save_and_use_model (completion, priv->initial_model);
+ g_warning ("Could not parse geoname JSON data: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ GtkListStore * store = gtk_list_store_new (TIMEZONE_COMPLETION_LAST,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+
+ JsonReader * reader = json_reader_new (json_parser_get_root (JSON_PARSER (object)));
+
+ if (!json_reader_is_array (reader)) {
+ g_warning ("Could not parse geoname JSON data");
+ save_and_use_model (completion, priv->initial_model);
+ g_object_unref (G_OBJECT (reader));
+ return;
+ }
+
+ gint i, count = json_reader_count_elements (reader);
+ for (i = 0; i < count; ++i) {
+ if (!json_reader_read_element (reader, i))
+ continue;
+
+ if (json_reader_is_object (reader)) {
+ const gchar * name = NULL;
+ const gchar * admin1 = NULL;
+ const gchar * country = NULL;
+ const gchar * longitude = NULL;
+ const gchar * latitude = NULL;
+ gboolean skip = FALSE;
+ if (json_reader_read_member (reader, "name")) {
+ name = json_reader_get_string_value (reader);
+ json_reader_end_member (reader);
+ }
+ if (json_reader_read_member (reader, "admin1")) {
+ admin1 = json_reader_get_string_value (reader);
+ json_reader_end_member (reader);
+ }
+ if (json_reader_read_member (reader, "country")) {
+ country = json_reader_get_string_value (reader);
+ json_reader_end_member (reader);
+ }
+ if (json_reader_read_member (reader, "longitude")) {
+ longitude = json_reader_get_string_value (reader);
+ json_reader_end_member (reader);
+ }
+ if (json_reader_read_member (reader, "latitude")) {
+ latitude = json_reader_get_string_value (reader);
+ json_reader_end_member (reader);
+ }
+
+ if (g_strcmp0(name, prev_name) == 0 &&
+ g_strcmp0(admin1, prev_admin1) == 0 &&
+ g_strcmp0(country, prev_country) == 0) {
+ // Sometimes the data will have duplicate entries that only differ
+ // in longitude and latitude. e.g. "rio de janeiro", "wellington"
+ skip = TRUE;
+ }
+
+ if (!skip) {
+ GtkTreeIter iter;
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ TIMEZONE_COMPLETION_ZONE, NULL,
+ TIMEZONE_COMPLETION_NAME, name,
+ TIMEZONE_COMPLETION_ADMIN1, admin1,
+ TIMEZONE_COMPLETION_COUNTRY, country,
+ TIMEZONE_COMPLETION_LONGITUDE, longitude,
+ TIMEZONE_COMPLETION_LATITUDE, latitude,
+ -1);
+ gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store),
+ TIMEZONE_COMPLETION_NAME, sort_zone,
+ g_utf8_casefold(priv->request_text, -1),
+ g_free);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ TIMEZONE_COMPLETION_NAME,
+ GTK_SORT_ASCENDING);
+ }
+
+ prev_name = name;
+ prev_admin1 = admin1;
+ prev_country = country;
+ }
+
+ json_reader_end_element (reader);
+ }
+
+ if (strlen (priv->request_text) < 4) {
+ gchar * lower_text = g_ascii_strdown (priv->request_text, -1);
+ if (g_strcmp0 (lower_text, "ut") == 0 ||
+ g_strcmp0 (lower_text, "utc") == 0) {
+ GtkTreeIter iter;
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ TIMEZONE_COMPLETION_ZONE, "UTC",
+ TIMEZONE_COMPLETION_NAME, "UTC",
+ -1);
+ }
+ g_free (lower_text);
+ }
+
+ save_and_use_model (completion, GTK_TREE_MODEL (store));
+ g_object_unref (G_OBJECT (reader));
+}
+
+static void
+geonames_data_ready (GObject *object, GAsyncResult *res, gpointer user_data)
+{
+ TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data);
+ TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
+ GError * error = NULL;
+ GFileInputStream * stream;
+
+ stream = g_file_read_finish (G_FILE (object), res, &error);
+
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) && priv->cancel) {
+ g_cancellable_reset (priv->cancel);
+ }
+
+ if (error != NULL) {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ save_and_use_model (completion, priv->initial_model);
+ g_warning ("Could not connect to geoname lookup server: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ JsonParser * parser = json_parser_new ();
+ json_parser_load_from_stream_async (parser, G_INPUT_STREAM (stream), priv->cancel,
+ json_parse_ready, user_data);
+}
+
+/* Returns message locale, with possible country info too like en_US */
+static gchar *
+get_locale (void)
+{
+ /* Check LANGUAGE, LC_ALL, LC_MESSAGES, and LANG, treat as colon-separated */
+ const gchar *env_names[] = {"LANGUAGE", "LC_ALL", "LC_MESSAGES", "LANG", NULL};
+ const gchar *env = NULL;
+ gint i;
+
+ for (i = 0; env_names[i]; i++) {
+ env = g_getenv (env_names[i]);
+ if (env != NULL && env[0] != 0)
+ break;
+ }
+
+ if (env == NULL)
+ return NULL;
+
+ /* Now, we split on colons as expected, but also on . and @ to filter out
+ extra pieces of locale we don't care about as we only use first chunk. */
+ gchar **split = g_strsplit_set (env, ":.@", 2);
+ if (split == NULL)
+ return NULL;
+
+ if (split[0] == NULL) {
+ g_strfreev (split);
+ return NULL;
+ }
+
+ gchar *locale = g_strdup (split[0]);
+ g_strfreev (split);
+ return locale;
+}
+
+static gchar *
+get_version (void)
+{
+ static gchar *version = NULL;
+
+ if (version == NULL) {
+ gchar *stdout = NULL;
+ g_spawn_command_line_sync ("lsb_release -rs", &stdout, NULL, NULL, NULL);
+
+ if (stdout != NULL)
+ version = g_strstrip (stdout);
+ else
+ version = g_strdup("");
+ }
+
+ return version;
+}
+
+static gboolean
+request_zones (TimezoneCompletion * completion)
+{
+ TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
+
+ priv->queued_request = 0;
+
+ if (priv->entry == NULL) {
+ return FALSE;
+ }
+
+ /* Cancel any ongoing request */
+ if (priv->cancel) {
+ g_cancellable_cancel (priv->cancel);
+ g_cancellable_reset (priv->cancel);
+ }
+ g_free (priv->request_text);
+
+ const gchar * text = gtk_entry_get_text (priv->entry);
+ priv->request_text = g_strdup (text);
+
+ gchar * escaped = g_uri_escape_string (text, NULL, FALSE);
+ gchar * version = get_version ();
+ gchar * locale = get_locale ();
+ gchar * url = g_strdup_printf (GEONAME_URL, escaped, version, locale);
+ g_free (locale);
+ g_free (version);
+ g_free (escaped);
+
+ GFile * file = g_file_new_for_uri (url);
+ g_free (url);
+
+ g_file_read_async (file, G_PRIORITY_DEFAULT, priv->cancel,
+ geonames_data_ready, completion);
+
+ return FALSE;
+}
+
+static void
+entry_changed (GtkEntry * entry, TimezoneCompletion * completion)
+{
+ TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
+
+ if (priv->queued_request) {
+ g_source_remove (priv->queued_request);
+ priv->queued_request = 0;
+ }
+
+ /* See if we've already got this one */
+ const gchar * text = gtk_entry_get_text (priv->entry);
+ gpointer data;
+ if (g_hash_table_lookup_extended (priv->request_table, text, NULL, &data)) {
+ gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion), GTK_TREE_MODEL (data));
+ }
+ else {
+ priv->queued_request = g_timeout_add (300, (GSourceFunc)request_zones, completion);
+ gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion), NULL);
+ }
+ gtk_entry_completion_complete (GTK_ENTRY_COMPLETION (completion));
+}
+
+static GtkWidget *
+get_descendent (GtkWidget * parent, GType type)
+{
+ if (g_type_is_a (G_OBJECT_TYPE (parent), type))
+ return parent;
+
+ if (GTK_IS_CONTAINER (parent)) {
+ GList * children = gtk_container_get_children (GTK_CONTAINER (parent));
+ GList * iter;
+ for (iter = children; iter; iter = iter->next) {
+ GtkWidget * found = get_descendent (GTK_WIDGET (iter->data), type);
+ if (found) {
+ g_list_free (children);
+ return found;
+ }
+ }
+ g_list_free (children);
+ }
+
+ return NULL;
+}
+
+/**
+ * The popup window and its GtkTreeView are private to our parent completion
+ * object. We can't get access to discover if there is a highlighted item or
+ * even if the window is showing right now. So this is a super hack to find
+ * it by looking through our toplevel's window group and finding a window with
+ * a GtkTreeView that points at our model. There should be only one ever, so
+ * we'll use the first one we find.
+ */
+static GtkTreeView *
+find_popup_treeview (GtkWidget * widget, GtkTreeModel * model)
+{
+ GtkWidget * toplevel = gtk_widget_get_toplevel (widget);
+ if (!GTK_IS_WINDOW (toplevel))
+ return NULL;
+
+ GtkWindowGroup * group = gtk_window_get_group (GTK_WINDOW (toplevel));
+ GList * windows = gtk_window_group_list_windows (group);
+ GList * iter;
+ for (iter = windows; iter; iter = iter->next) {
+ if (iter->data == toplevel)
+ continue; // Skip our own window, we don't have it
+ GtkWidget * view = get_descendent (GTK_WIDGET (iter->data), GTK_TYPE_TREE_VIEW);
+ if (view != NULL) {
+ GtkTreeModel * tree_model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+ if (GTK_IS_TREE_MODEL_FILTER (tree_model))
+ tree_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (tree_model));
+ if (tree_model == model) {
+ g_list_free (windows);
+ return GTK_TREE_VIEW (view);
+ }
+ }
+ }
+ g_list_free (windows);
+
+ return NULL;
+}
+
+static gboolean
+entry_keypress (GtkEntry * entry, GdkEventKey *event, TimezoneCompletion * completion)
+{
+ if (event->keyval == GDK_ISO_Enter ||
+ event->keyval == GDK_KP_Enter ||
+ event->keyval == GDK_Return) {
+ /* Make sure that user has a selection to choose, otherwise ignore */
+ GtkTreeModel * model = gtk_entry_completion_get_model (GTK_ENTRY_COMPLETION (completion));
+ GtkTreeView * view = find_popup_treeview (GTK_WIDGET (entry), model);
+ if (view == NULL) {
+ // Just beep if popup hasn't appeared yet.
+ gtk_widget_error_bell (GTK_WIDGET (entry));
+ return TRUE;
+ }
+
+ GtkTreeSelection * sel = gtk_tree_view_get_selection (view);
+ GtkTreeModel * sel_model = NULL;
+ if (!gtk_tree_selection_get_selected (sel, &sel_model, NULL)) {
+ // No selection, we should help them out and select first item in list
+ GtkTreeIter iter;
+ if (gtk_tree_model_get_iter_first (sel_model, &iter))
+ gtk_tree_selection_select_iter (sel, &iter);
+ // And fall through to normal handler code
+ }
+ }
+
+ return FALSE;
+}
+
+void
+timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry)
+{
+ TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
+
+ if (priv->queued_request) {
+ g_source_remove (priv->queued_request);
+ priv->queued_request = 0;
+ }
+ if (priv->entry) {
+ g_signal_handler_disconnect (priv->entry, priv->changed_id);
+ g_signal_handler_disconnect (priv->entry, priv->keypress_id);
+ g_object_remove_weak_pointer (G_OBJECT (priv->entry), (gpointer *)&priv->entry);
+ gtk_entry_set_completion (priv->entry, NULL);
+ }
+
+ guint id = g_signal_connect (entry, "changed", G_CALLBACK (entry_changed), completion);
+ priv->changed_id = id;
+
+ id = g_signal_connect (entry, "key-press-event", G_CALLBACK (entry_keypress), completion);
+ priv->keypress_id = id;
+
+ priv->entry = entry;
+ g_object_add_weak_pointer (G_OBJECT (entry), (gpointer *)&priv->entry);
+
+ gtk_entry_set_completion (entry, GTK_ENTRY_COMPLETION (completion));
+}
+
+static GtkListStore *
+get_initial_model (void)
+{
+ TzDB * db = tz_load_db ();
+ GPtrArray * locations = tz_get_locations (db);
+
+ GtkListStore * store = gtk_list_store_new (TIMEZONE_COMPLETION_LAST,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+
+ gint i;
+ for (i = 0; i < locations->len; ++i) {
+ TzLocation * loc = g_ptr_array_index (locations, i);
+ GtkTreeIter iter;
+ gtk_list_store_append (store, &iter);
+
+ /* FIXME: need something better than below for non-English locales */
+ const gchar * last_bit = ((const gchar *)strrchr (loc->zone, '/')) + 1;
+ if (last_bit == NULL)
+ last_bit = loc->zone;
+ gchar * name = g_strdup (last_bit);
+ gchar * underscore;
+ while ((underscore = strchr (name, '_'))) {
+ *underscore = ' ';
+ }
+
+ gtk_list_store_set (store, &iter,
+ TIMEZONE_COMPLETION_ZONE, loc->zone,
+ TIMEZONE_COMPLETION_NAME, name,
+ TIMEZONE_COMPLETION_COUNTRY, loc->country,
+ -1);
+
+ g_free (name);
+ }
+
+ GtkTreeIter iter;
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ TIMEZONE_COMPLETION_ZONE, "UTC",
+ TIMEZONE_COMPLETION_NAME, "UTC",
+ -1);
+
+ tz_db_free (db);
+ return store;
+}
+
+static void
+data_func (GtkCellLayout *cell_layout, GtkCellRenderer *cell,
+ GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer user_data)
+{
+ const gchar * name, * admin1, * country;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (tree_model), iter,
+ TIMEZONE_COMPLETION_NAME, &name,
+ TIMEZONE_COMPLETION_ADMIN1, &admin1,
+ TIMEZONE_COMPLETION_COUNTRY, &country,
+ -1);
+
+ gchar * user_name;
+ if (country == NULL || country[0] == 0) {
+ user_name = g_strdup (name);
+ } else if (admin1 == NULL || admin1[0] == 0) {
+ user_name = g_strdup_printf ("%s <small>(%s)</small>", name, country);
+ } else {
+ user_name = g_strdup_printf ("%s <small>(%s, %s)</small>", name, admin1, country);
+ }
+
+ g_object_set (G_OBJECT (cell), "markup", user_name, NULL);
+}
+
+static void
+timezone_completion_class_init (TimezoneCompletionClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (TimezoneCompletionPrivate));
+
+ object_class->dispose = timezone_completion_dispose;
+ object_class->finalize = timezone_completion_finalize;
+
+ return;
+}
+
+static void
+timezone_completion_init (TimezoneCompletion * self)
+{
+ TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (self);
+
+ priv->initial_model = GTK_TREE_MODEL (get_initial_model ());
+
+ g_object_set (G_OBJECT (self),
+ "text-column", TIMEZONE_COMPLETION_NAME,
+ "popup-set-width", FALSE,
+ NULL);
+
+ priv->cancel = g_cancellable_new ();
+
+ priv->request_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
+
+ GtkCellRenderer * cell = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self), cell, TRUE);
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (self), cell, data_func, NULL, NULL);
+
+ return;
+}
+
+static void
+timezone_completion_dispose (GObject * object)
+{
+ G_OBJECT_CLASS (timezone_completion_parent_class)->dispose (object);
+
+ TimezoneCompletion * completion = TIMEZONE_COMPLETION (object);
+ TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
+
+ if (priv->changed_id) {
+ if (priv->entry)
+ g_signal_handler_disconnect (priv->entry, priv->changed_id);
+ priv->changed_id = 0;
+ }
+
+ if (priv->keypress_id) {
+ if (priv->entry)
+ g_signal_handler_disconnect (priv->entry, priv->keypress_id);
+ priv->keypress_id = 0;
+ }
+
+ if (priv->entry != NULL) {
+ g_object_remove_weak_pointer (G_OBJECT (priv->entry), (gpointer *)&priv->entry);
+ }
+
+ if (priv->initial_model != NULL) {
+ g_object_unref (G_OBJECT (priv->initial_model));
+ priv->initial_model = NULL;
+ }
+
+ if (priv->queued_request) {
+ g_source_remove (priv->queued_request);
+ priv->queued_request = 0;
+ }
+
+ if (priv->cancel != NULL) {
+ g_cancellable_cancel (priv->cancel);
+ g_object_unref (priv->cancel);
+ priv->cancel = NULL;
+ }
+
+ if (priv->request_text != NULL) {
+ g_free (priv->request_text);
+ priv->request_text = NULL;
+ }
+
+ if (priv->request_table != NULL) {
+ g_hash_table_destroy (priv->request_table);
+ priv->request_table = NULL;
+ }
+
+ return;
+}
+
+static void
+timezone_completion_finalize (GObject * object)
+{
+ G_OBJECT_CLASS (timezone_completion_parent_class)->finalize (object);
+ return;
+}
+
+TimezoneCompletion *
+timezone_completion_new ()
+{
+ TimezoneCompletion * self = g_object_new (TIMEZONE_COMPLETION_TYPE, NULL);
+ return self;
+}
+
diff --git a/src/timezone-completion.h b/src/timezone-completion.h
new file mode 100644
index 0000000..fdfb234
--- /dev/null
+++ b/src/timezone-completion.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C; coding: utf-8; indent-tabs-mode: nil; tab-width: 2 -*-
+
+Copyright 2011 Canonical Ltd.
+
+Authors:
+ Michael Terry <michael.terry@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __TIMEZONE_COMPLETION_H__
+#define __TIMEZONE_COMPLETION_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define TIMEZONE_COMPLETION_TYPE (timezone_completion_get_type ())
+#define TIMEZONE_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TIMEZONE_COMPLETION_TYPE, TimezoneCompletion))
+#define TIMEZONE_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TIMEZONE_COMPLETION_TYPE, TimezoneCompletionClass))
+#define IS_TIMEZONE_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TIMEZONE_COMPLETION_TYPE))
+#define IS_TIMEZONE_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TIMEZONE_COMPLETION_TYPE))
+#define TIMEZONE_COMPLETION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TIMEZONE_COMPLETION_TYPE, TimezoneCompletionClass))
+
+typedef struct _TimezoneCompletion TimezoneCompletion;
+typedef struct _TimezoneCompletionClass TimezoneCompletionClass;
+
+struct _TimezoneCompletionClass {
+ GtkEntryCompletionClass parent_class;
+};
+
+struct _TimezoneCompletion {
+ GtkEntryCompletion parent;
+};
+
+#define TIMEZONE_COMPLETION_ZONE 0
+#define TIMEZONE_COMPLETION_NAME 1
+#define TIMEZONE_COMPLETION_ADMIN1 2
+#define TIMEZONE_COMPLETION_COUNTRY 3
+#define TIMEZONE_COMPLETION_LONGITUDE 4
+#define TIMEZONE_COMPLETION_LATITUDE 5
+#define TIMEZONE_COMPLETION_LAST 6
+
+GType timezone_completion_get_type (void);
+TimezoneCompletion * timezone_completion_new ();
+void timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry);
+
+G_END_DECLS
+
+#endif /* __TIMEZONE_COMPLETION_H__ */
+
diff --git a/src/utils.c b/src/utils.c
new file mode 100644
index 0000000..ab93ecf
--- /dev/null
+++ b/src/utils.c
@@ -0,0 +1,276 @@
+/* -*- Mode: C; coding: utf-8; indent-tabs-mode: nil; tab-width: 2 -*-
+
+A dialog for setting time and date preferences.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Michael Terry <michael.terry@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib/gi18n-lib.h>
+#include <gio/gio.h>
+#include <locale.h>
+#include <langinfo.h>
+#include <string.h>
+#include "utils.h"
+#include "settings-shared.h"
+
+/* Check the system locale setting to see if the format is 24-hour
+ time or 12-hour time */
+gboolean
+is_locale_12h (void)
+{
+ static const char *formats_24h[] = {"%H", "%R", "%T", "%OH", "%k", NULL};
+ const char *t_fmt = nl_langinfo (T_FMT);
+ int i;
+
+ for (i = 0; formats_24h[i]; ++i) {
+ if (strstr (t_fmt, formats_24h[i])) {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+void
+split_settings_location (const gchar * location, gchar ** zone, gchar ** name)
+{
+ gchar * location_dup = g_strdup (location);
+ gchar * first = strchr (location_dup, ' ');
+
+ if (first) {
+ first[0] = 0;
+ }
+
+ if (zone) {
+ *zone = location_dup;
+ }
+
+ if (name) {
+ gchar * after = first ? g_strstrip (first + 1) : NULL;
+ if (after == NULL || after[0] == 0) {
+ /* Make up name from zone */
+ gchar * chr = strrchr (location_dup, '/');
+ after = g_strdup (chr ? chr + 1 : location_dup);
+ while ((chr = strchr (after, '_')) != NULL) { /* and turn underscores to spaces */
+ *chr = ' ';
+ }
+ *name = after;
+ }
+ else {
+ *name = g_strdup (after);
+ }
+ }
+}
+
+gchar *
+get_current_zone_name (const gchar * location)
+{
+ gchar * new_zone, * new_name;
+ gchar * old_zone, * old_name;
+ gchar * rv;
+
+ split_settings_location (location, &new_zone, &new_name);
+
+ GSettings * conf = g_settings_new (SETTINGS_INTERFACE);
+ gchar * tz_name = g_settings_get_string (conf, SETTINGS_TIMEZONE_NAME_S);
+ split_settings_location (tz_name, &old_zone, &old_name);
+ g_free (tz_name);
+ g_object_unref (conf);
+
+ // new_name is always just a sanitized version of a timezone.
+ // old_name is potentially a saved "pretty" version of a timezone name from
+ // geonames. So we prefer to use it if available and the zones match.
+
+ if (g_strcmp0 (old_zone, new_zone) == 0) {
+ rv = old_name;
+ old_name = NULL;
+ }
+ else {
+ rv = new_name;
+ new_name = NULL;
+ }
+
+ g_free (new_zone);
+ g_free (old_zone);
+ g_free (new_name);
+ g_free (old_name);
+
+ return rv;
+}
+
+/* Translate msg according to the locale specified by LC_TIME */
+static char *
+T_(const char *msg)
+{
+ /* General strategy here is to make sure LANGUAGE is empty (since that
+ trumps all LC_* vars) and then to temporarily swap LC_TIME and
+ LC_MESSAGES. Then have gettext translate msg.
+
+ We strdup the strings because the setlocale & *env functions do not
+ guarantee anything about the storage used for the string, and thus
+ the string may not be portably safe after multiple calls.
+
+ Note that while you might think g_dcgettext would do the trick here,
+ that actually looks in /usr/share/locale/XX/LC_TIME, not the
+ LC_MESSAGES directory, so we won't find any translation there.
+ */
+ char *message_locale = g_strdup(setlocale(LC_MESSAGES, NULL));
+ char *time_locale = g_strdup(setlocale(LC_TIME, NULL));
+ char *language = g_strdup(g_getenv("LANGUAGE"));
+ char *rv;
+ g_unsetenv("LANGUAGE");
+ setlocale(LC_MESSAGES, time_locale);
+
+ /* Get the LC_TIME version */
+ rv = _(msg);
+
+ /* Put everything back the way it was */
+ setlocale(LC_MESSAGES, message_locale);
+ g_setenv("LANGUAGE", language, TRUE);
+ g_free(message_locale);
+ g_free(time_locale);
+ g_free(language);
+ return rv;
+}
+
+/* Tries to figure out what our format string should be. Lots
+ of translator comments in here. */
+gchar *
+generate_format_string_full (gboolean show_day, gboolean show_date)
+{
+ gboolean twelvehour = TRUE;
+
+ GSettings * settings = g_settings_new (SETTINGS_INTERFACE);
+ gint time_mode = g_settings_get_enum (settings, SETTINGS_TIME_FORMAT_S);
+ gboolean show_seconds = g_settings_get_boolean (settings, SETTINGS_SHOW_SECONDS_S);
+ g_object_unref (settings);
+
+ if (time_mode == SETTINGS_TIME_LOCALE) {
+ twelvehour = is_locale_12h();
+ } else if (time_mode == SETTINGS_TIME_24_HOUR) {
+ twelvehour = FALSE;
+ }
+
+ const gchar * time_string = NULL;
+ if (twelvehour) {
+ if (show_seconds) {
+ /* TRANSLATORS: A format string for the strftime function for
+ a clock showing 12-hour time with seconds. */
+ time_string = T_("%l:%M:%S %p");
+ } else {
+ time_string = T_(DEFAULT_TIME_12_FORMAT);
+ }
+ } else {
+ if (show_seconds) {
+ /* TRANSLATORS: A format string for the strftime function for
+ a clock showing 24-hour time with seconds. */
+ time_string = T_("%H:%M:%S");
+ } else {
+ time_string = T_(DEFAULT_TIME_24_FORMAT);
+ }
+ }
+
+ /* Checkpoint, let's not fail */
+ g_return_val_if_fail(time_string != NULL, g_strdup(DEFAULT_TIME_FORMAT));
+
+ /* If there's no date or day let's just leave now and
+ not worry about the rest of this code */
+ if (!show_date && !show_day) {
+ return g_strdup(time_string);
+ }
+
+ const gchar * date_string = NULL;
+ if (show_date && show_day) {
+ /* TRANSLATORS: This is a format string passed to strftime to represent
+ the day of the week, the month and the day of the month. */
+ date_string = T_("%a %b %e");
+ } else if (show_date) {
+ /* TRANSLATORS: This is a format string passed to strftime to represent
+ the month and the day of the month. */
+ date_string = T_("%b %e");
+ } else if (show_day) {
+ /* TRANSLATORS: This is a format string passed to strftime to represent
+ the day of the week. */
+ date_string = T_("%a");
+ }
+
+ /* Check point, we should have a date string */
+ g_return_val_if_fail(date_string != NULL, g_strdup(time_string));
+
+ /* TRANSLATORS: This is a format string passed to strftime to combine the
+ date and the time. The value of "%s %s" would result in a string like
+ this in US English 12-hour time: 'Fri Jul 16 11:50 AM' */
+ return g_strdup_printf(T_("%s %s"), date_string, time_string);
+}
+
+gchar *
+generate_format_string_at_time (GDateTime * time)
+{
+ /* This is a bit less free-form than for the main "now" time label. */
+ /* If it is today, just the time should be shown (e.g. “3:55 PM”)
+ If it is a different day this week, the day and time should be shown (e.g. “Wed 3:55 PM”)
+ If it is after this week, the day, date, and time should be shown (e.g. “Wed 21 Apr 3:55 PM”).
+ In addition, when presenting the times of upcoming events, the time should be followed by the timezone if it is different from the one the computer is currently set to. For example, “Wed 3:55 PM UTC−5”. */
+ gboolean show_day = FALSE;
+ gboolean show_date = FALSE;
+
+ GDateTime * now = g_date_time_new_now_local();
+
+ /* First, are we same day? */
+ gint time_year, time_month, time_day;
+ gint now_year, now_month, now_day;
+ g_date_time_get_ymd(time, &time_year, &time_month, &time_day);
+ g_date_time_get_ymd(now, &now_year, &now_month, &now_day);
+
+ if (time_year != now_year ||
+ time_month != now_month ||
+ time_day != now_day) {
+ /* OK, different days so we must at least show the day. */
+ show_day = TRUE;
+
+ /* Is it this week? */
+ /* Here, we define "is this week" as yesterday, today, or the next five days */
+ GDateTime * past = g_date_time_add_days(now, -1);
+ GDateTime * future = g_date_time_add_days(now, 5);
+ GDateTime * past_bound = g_date_time_new_local(g_date_time_get_year(past),
+ g_date_time_get_month(past),
+ g_date_time_get_day_of_month(past),
+ 0, 0, 0.0);
+ GDateTime * future_bound = g_date_time_new_local(g_date_time_get_year(future),
+ g_date_time_get_month(future),
+ g_date_time_get_day_of_month(future),
+ 23, 59, 59.9);
+ if (g_date_time_compare(time, past_bound) < 0 ||
+ g_date_time_compare(time, future_bound) > 0) {
+ show_date = TRUE;
+ }
+ g_date_time_unref(past);
+ g_date_time_unref(future);
+ g_date_time_unref(past_bound);
+ g_date_time_unref(future_bound);
+ }
+
+ g_date_time_unref (now);
+
+ return generate_format_string_full(show_day, show_date);
+}
+
diff --git a/src/utils.h b/src/utils.h
new file mode 100644
index 0000000..c2bc0c5
--- /dev/null
+++ b/src/utils.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C; coding: utf-8; indent-tabs-mode: nil; tab-width: 2 -*-
+
+A dialog for setting time and date preferences.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Michael Terry <michael.terry@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __DATETIME_UTILS_H__
+#define __DATETIME_UTILS_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gboolean is_locale_12h (void);
+void split_settings_location (const gchar * location, gchar ** zone, gchar ** name);
+gchar * get_current_zone_name (const gchar * location);
+gchar * generate_format_string_full (gboolean show_day, gboolean show_date);
+gchar * generate_format_string_at_time (GDateTime * time);
+
+G_END_DECLS
+
+#endif
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/Makefile.am