[Xfce4-commits] [panel-plugins/xfce4-statusnotifier-plugin] 01/08: Initial commit
noreply at xfce.org
noreply at xfce.org
Sun Jul 16 23:24:41 CEST 2017
This is an automated email from the git hooks/post-receive script.
n i n e t l s p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository panel-plugins/xfce4-statusnotifier-plugin.
commit 2fc70066fd765f9739750531900fde74f4386723
Author: Viktor Odintsev <ninetls at xfce.org>
Date: Wed Jul 12 18:41:28 2017 +0300
Initial commit
---
AUTHORS | 2 +
COPYING | 339 ++++++++
COPYING.LIB | 502 +++++++++++
ChangeLog | 0
Makefile.am | 26 +
NEWS | 0
README | 15 +
THANKS | 13 +
autogen.sh | 19 +
configure.ac.in | 106 +++
icons/48x48/Makefile.am | 9 +
icons/48x48/xfce4-statusnotifier-plugin.png | Bin 0 -> 2497 bytes
icons/Makefile.am | 19 +
icons/scalable/Makefile.am | 9 +
icons/scalable/xfce4-statusnotifier-plugin.svg | 137 +++
panel-plugin/Makefile.am | 99 +++
panel-plugin/sn-backend.c | 434 ++++++++++
panel-plugin/sn-backend.h | 44 +
panel-plugin/sn-box.c | 535 ++++++++++++
panel-plugin/sn-box.h | 49 ++
panel-plugin/sn-button.c | 394 +++++++++
panel-plugin/sn-button.h | 53 ++
panel-plugin/sn-config.c | 758 +++++++++++++++++
panel-plugin/sn-config.h | 83 ++
panel-plugin/sn-dialog.c | 528 ++++++++++++
panel-plugin/sn-dialog.glade | 414 +++++++++
panel-plugin/sn-dialog.h | 46 +
panel-plugin/sn-icon-box.c | 370 ++++++++
panel-plugin/sn-icon-box.h | 46 +
panel-plugin/sn-item.c | 1084 ++++++++++++++++++++++++
panel-plugin/sn-item.h | 72 ++
panel-plugin/sn-plugin.c | 254 ++++++
panel-plugin/sn-plugin.h | 43 +
panel-plugin/sn-watcher.xml | 29 +
panel-plugin/statusnotifier.desktop.in | 10 +
po/POTFILES.in | 7 +
36 files changed, 6548 insertions(+)
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..d29dbd6
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Viktor Odintsev <ninetls at xfce.org>
+Andrzej Radecki <andrzejr at xfce.org>
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..674d65a
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/COPYING.LIB b/COPYING.LIB
new file mode 100644
index 0000000..72fc682
--- /dev/null
+++ b/COPYING.LIB
@@ -0,0 +1,502 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e69de29
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..4452fc0
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,26 @@
+SUBDIRS = \
+ icons \
+ panel-plugin \
+ po
+
+distclean-local:
+ rm -rf *.cache *~
+
+distuninstallcheck_listfiles = \
+ find . -type f -print | grep -v ./share/icons/hicolor/icon-theme.cache
+
+rpm: dist
+ rpmbuild -ta $(PACKAGE)-$(VERSION).tar.gz
+ @rm -f $(PACKAGE)-$(VERSION).tar.gz
+
+EXTRA_DIST = \
+ intltool-extract.in \
+ intltool-merge.in \
+ intltool-update.in
+
+DISTCLEANFILES = \
+ intltool-extract \
+ intltool-merge \
+ intltool-update
+
+# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
diff --git a/README b/README
new file mode 100644
index 0000000..1af1775
--- /dev/null
+++ b/README
@@ -0,0 +1,15 @@
+What is it?
+===========
+
+A panel plugin which provides an area for status notifier items
+(application indicators).
+
+Installation
+============
+
+The file 'INSTALL' contains generic installation instructions.
+
+How to report bugs?
+===================
+
+Report bugs to the author directly, until a bugtracker is available.
diff --git a/THANKS b/THANKS
new file mode 100644
index 0000000..2cc0375
--- /dev/null
+++ b/THANKS
@@ -0,0 +1,13 @@
+This project is partially based on xfce4-indicator-plugin.
+
+This file contains a complete list of contributors who
+took part in its creation.
+
+-----------------------------------------------------------
+
+Mark Trompell <mark at foresightlinux.org>
+Lionel Le Folgoc <lionel at lefolgoc.net>
+Alistair Buxton <a.j.buxton at gmail.com>
+Jason Conti <jconti at launchpad.net>
+Nick Schermer <nick at xfce.org>
+Evgeni Golov <evgeni at debian.org>
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..04afe68
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# $Id: autogen.sh 2398 2007-01-17 17:47:38Z nick $
+#
+# Copyright (c) 2002-2007
+# The Xfce development team. All rights reserved.
+#
+
+(type xdt-autogen) >/dev/null 2>&1 || {
+ cat >&2 <<EOF
+autogen.sh: You don't seem to have the Xfce development tools installed on
+ your system, which are required to build this software.
+ Please install the xfce4-dev-tools package first, it is available
+ from http://www.xfce.org/.
+EOF
+ exit 1
+}
+
+XDT_AUTOGEN_REQUIRED_VERSION="4.7.3" exec xdt-autogen $@
diff --git a/configure.ac.in b/configure.ac.in
new file mode 100644
index 0000000..74333b5
--- /dev/null
+++ b/configure.ac.in
@@ -0,0 +1,106 @@
+dnl xfce4-statusnotifier-plugin - A Status Notifier plugin for the Xfce panel
+dnl
+dnl 2017 Viktor Odintsev <ninetls at xfce.org>
+dnl
+
+dnl ***************************
+dnl *** Version information ***
+dnl ***************************
+m4_define([sn_version_major], [0])
+m4_define([sn_version_minor], [0])
+m4_define([sn_version_micro], [9])
+m4_define([sn_version_nano], [])
+m4_define([sn_version_build], [@REVISION@])
+m4_define([sn_version_tag], [git])
+m4_define([sn_version], [sn_version_major().sn_version_minor().sn_version_micro()ifelse(sn_version_nano(), [], [], [.sn_version_nano()])ifelse(sn_version_tag(), [git], [sn_version_tag()-sn_version_build()], [sn_version_tag()])])
+
+dnl ***************************
+dnl *** Initialize autoconf ***
+dnl ***************************
+AC_COPYRIGHT([Copyright (c) 2017
+ The Xfce development team. All rights reserved.])
+AC_INIT([xfce4-statusnotifier-plugin], [sn_version], [https://bugzilla.xfce.org/], [xfce4-statusnotifier-plugin])
+AC_PREREQ([2.50])
+AC_CONFIG_MACRO_DIRS([m4])
+AC_CONFIG_HEADERS([config.h])
+AC_CANONICAL_TARGET()
+AC_REVISION([@REVISION@])
+
+dnl ***************************
+dnl *** Initialize automake ***
+dnl ***************************
+AM_INIT_AUTOMAKE([1.8 dist-bzip2 tar-ustar])
+AM_MAINTAINER_MODE()
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+dnl ********************************
+dnl *** Check for basic programs ***
+dnl ********************************
+AC_PROG_CC()
+AC_PROG_LD()
+AC_PROG_INSTALL()
+IT_PROG_INTLTOOL([0.35.0])
+LT_PREREQ([2.2.6])
+LT_INIT([disable-static])
+
+dnl ************************************
+dnl *** Check for standard functions ***
+dnl ************************************
+AC_HEADER_STDC
+AC_CHECK_FUNCS([])
+
+dnl ******************************
+dnl *** Check for i18n support ***
+dnl ******************************
+XDT_I18N([@LINGUAS@])
+
+dnl *******************************
+dnl *** Check for X11 installed ***
+dnl *******************************
+XDT_CHECK_LIBX11_REQUIRE()
+
+dnl *******************************
+dnl *** Check for gdbus-codegen ***
+dnl *******************************
+AC_ARG_VAR([GDBUS_CODEGEN], [D-Bus code and documentation generator from XML D-Bus interface definitions])
+AC_PATH_PROG([GDBUS_CODEGEN], [gdbus-codegen], [no])
+if test x"$GDBUS_CODEGEN" = x"no"; then
+ AC_MSG_ERROR([could not find gdbus-codegen in \$PATH. You can run
+ ./configure GDBUS_CODEGEN=/path/to/gdbus-codegen to define
+ a custom location for it.])
+fi
+
+dnl ***********************************
+dnl *** Check for required packages ***
+dnl ***********************************
+XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [3.20.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.12.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.12.0])
+XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-2.0], [4.12.0])
+XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.12.0])
+XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.24.0])
+PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.24.0])
+XDT_CHECK_PACKAGE([DBUSMENU], [dbusmenu-gtk3-0.4], [16.04.0])
+
+dnl ***********************************
+dnl *** Check for debugging support ***
+dnl ***********************************
+XDT_FEATURE_DEBUG()
+
+AC_OUTPUT([
+Makefile
+icons/Makefile
+icons/48x48/Makefile
+icons/scalable/Makefile
+panel-plugin/Makefile
+po/Makefile.in
+])
+
+dnl ***************************
+dnl *** Print configuration ***
+dnl ***************************
+echo
+echo "Build Configuration:"
+echo
+echo "* Debug Support: $enable_debug"
+echo
diff --git a/icons/48x48/Makefile.am b/icons/48x48/Makefile.am
new file mode 100644
index 0000000..0de6844
--- /dev/null
+++ b/icons/48x48/Makefile.am
@@ -0,0 +1,9 @@
+iconsdir = $(datadir)/icons/hicolor/48x48/apps
+
+icons_DATA = \
+ xfce4-statusnotifier-plugin.png
+
+EXTRA_DIST = \
+ $(icons_DATA)
+
+# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/icons/48x48/xfce4-statusnotifier-plugin.png b/icons/48x48/xfce4-statusnotifier-plugin.png
new file mode 100644
index 0000000..79625aa
Binary files /dev/null and b/icons/48x48/xfce4-statusnotifier-plugin.png differ
diff --git a/icons/Makefile.am b/icons/Makefile.am
new file mode 100644
index 0000000..4c7dfb1
--- /dev/null
+++ b/icons/Makefile.am
@@ -0,0 +1,19 @@
+SUBDIRS = \
+ 48x48 \
+ scalable
+
+gtk_update_icon_cache = \
+ gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
+
+install-data-hook:
+ @-if test -z "$(DESTDIR)"; then \
+ echo "Updating Gtk icon cache."; \
+ $(gtk_update_icon_cache); \
+ else \
+ echo "*** Icon cache not updated. Remember to run:"; \
+ echo "***"; \
+ echo "*** $(gtk_update_icon_cache)"; \
+ echo "***"; \
+ fi
+
+# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/icons/scalable/Makefile.am b/icons/scalable/Makefile.am
new file mode 100644
index 0000000..754fd5e
--- /dev/null
+++ b/icons/scalable/Makefile.am
@@ -0,0 +1,9 @@
+iconsdir = $(datadir)/icons/hicolor/scalable/apps
+
+icons_DATA = \
+ xfce4-statusnotifier-plugin.svg
+
+EXTRA_DIST = \
+ $(icons_DATA)
+
+# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/icons/scalable/xfce4-statusnotifier-plugin.svg b/icons/scalable/xfce4-statusnotifier-plugin.svg
new file mode 100644
index 0000000..93e06fb
--- /dev/null
+++ b/icons/scalable/xfce4-statusnotifier-plugin.svg
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="32"
+ height="32"
+ id="svg3499"
+ sodipodi:version="0.32"
+ inkscape:version="0.92.1 r"
+ sodipodi:docname="xfce4-statusnotifier-plugin.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ version="1.1">
+ <defs
+ id="defs3501">
+ <linearGradient
+ id="linearGradient3547">
+ <stop
+ style="stop-color:#cfcfcf;stop-opacity:1;"
+ offset="0"
+ id="stop3549" />
+ <stop
+ id="stop3553"
+ offset="0"
+ style="stop-color:#7355dd;stop-opacity:1" />
+ <stop
+ style="stop-color:#df3baa;stop-opacity:1"
+ offset="1"
+ id="stop3557" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3547"
+ id="linearGradient3565"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.53333333,0,0,0.53333334,138.13333,5.3333362)"
+ x1="-255.35397"
+ y1="-2.3250461"
+ x2="-198.67494"
+ y2="54.022526" />
+ <filter
+ inkscape:collect="always"
+ style="color-interpolation-filters:sRGB"
+ id="filter889"
+ x="-0.035999998"
+ width="1.072"
+ y="-0.035999998"
+ height="1.072">
+ <feGaussianBlur
+ inkscape:collect="always"
+ stdDeviation="0.42"
+ id="feGaussianBlur891" />
+ </filter>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="10.46875"
+ inkscape:cx="-4.6292316"
+ inkscape:cy="20.476807"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:grid-bbox="true"
+ inkscape:document-units="px"
+ showborder="false"
+ inkscape:window-width="1920"
+ inkscape:window-height="1020"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3605"
+ visible="true"
+ enabled="true"
+ originx="0"
+ originy="0"
+ spacingx="1.0666667"
+ spacingy="1.0666667" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata3504">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ transform="translate(0,-2.1333351)">
+ <path
+ style="display:inline;overflow:visible;visibility:visible;opacity:0.25;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:4.00243473;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;filter:url(#filter889);enable-background:accumulate"
+ d="M 16.000005,2 C 8.2720052,2 2.0000052,8.271999 2.0000052,16 c 0,7.728 6.272001,14 13.9999998,14 7.728,0 14.000001,-6.272001 14,-14 0,-7.728 -6.271999,-13.999999 -14,-14 z m 0,1 c 7.175998,2e-6 13,5.824 13,13 0,7.175999 -5.824002,13 -13,13 C 8.8240062,29 3.0000052,23.176 3.0000052,16 c 0,-7.176 5.824002,-13 12.9999998,-13 z"
+ id="path4138"
+ inkscape:connector-curvature="0"
+ transform="matrix(1.066101,0,0,1.066101,-1.057622,1.0757186)" />
+ <circle
+ style="display:inline;overflow:visible;visibility:visible;opacity:1;fill:url(#linearGradient3565);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.13333344;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;enable-background:accumulate"
+ id="path3539"
+ cx="15.999994"
+ cy="18.133335"
+ r="14.925414" />
+ <path
+ style="display:inline;overflow:visible;visibility:visible;opacity:0.3;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;enable-background:accumulate"
+ d="m 16,3.2079207 c -8.238829,0 -14.9254145,6.6865843 -14.9254145,14.9254143 0,8.238828 6.6865866,14.925414 14.9254145,14.925414 8.238828,0 14.925415,-6.686587 14.925414,-14.925414 C 30.925414,9.8945061 24.238829,3.2079218 16,3.2079207 Z m 0,1.066101 c 7.650339,2.1e-6 13.859313,6.2089723 13.859313,13.8593133 0,7.65034 -6.208974,13.859313 -13.859313,13.859313 -7.6503402,0 -13.8593136,-6.208972 -13.8593136,-13.859313 C 2.1406864,10.482994 8.3496608,4.2740217 16,4.2740217 Z"
+ id="path3541"
+ inkscape:connector-curvature="0" />
+ <path
+ style="display:inline;overflow:visible;visibility:visible;opacity:0.5;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.42222226;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;enable-background:accumulate"
+ d="m 12.295179,15.761 v 1.492581 h 1.492583 v 6.716616 h -1.492583 v 1.492581 h 7.462907 V 23.970197 H 18.265505 V 17.253581 15.761 Z"
+ id="path3555"
+ inkscape:connector-curvature="0" />
+ <path
+ style="display:inline;overflow:visible;visibility:visible;opacity:0.5;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.42222226;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;enable-background:accumulate"
+ d="m 16.026633,9.790675 c -1.235858,0 -2.238871,1.003014 -2.238871,2.238872 0,1.235858 1.003013,2.238871 2.238871,2.238871 1.235858,0 2.238872,-1.003013 2.238872,-2.238871 0,-1.235858 -1.003014,-2.238872 -2.238872,-2.238872 z"
+ id="path3561"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
new file mode 100644
index 0000000..163fac8
--- /dev/null
+++ b/panel-plugin/Makefile.am
@@ -0,0 +1,99 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -DG_LOG_DOMAIN=\"libstatusnotifier\" \
+ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
+ $(PLATFORM_CPPFLAGS)
+
+plugindir = \
+ $(libdir)/xfce4/panel/plugins
+
+plugin_LTLIBRARIES = \
+ libstatusnotifier.la
+
+libstatusnotifier_built_sources = \
+ sn-watcher.h \
+ sn-watcher.c \
+ sn-dialog-ui.h
+
+libstatusnotifier_la_SOURCES = \
+ $(libstatusnotifier_built_sources) \
+ sn-config.c \
+ sn-config.h \
+ sn-backend.c \
+ sn-backend.h \
+ sn-button.c \
+ sn-button.h \
+ sn-box.c \
+ sn-box.h \
+ sn-dialog.c \
+ sn-dialog.h \
+ sn-icon-box.c \
+ sn-icon-box.h \
+ sn-item.c \
+ sn-item.h \
+ sn-plugin.c \
+ sn-plugin.h
+
+libstatusnotifier_la_CFLAGS = \
+ $(GTK_CFLAGS) \
+ $(LIBXFCE4UTIL_CFLAGS) \
+ $(LIBXFCE4UI_CFLAGS) \
+ $(LIBXFCE4PANEL_CFLAGS) \
+ $(XFCONF_CFLAGS) \
+ $(DBUSMENU_CFLAGS) \
+ $(PLATFORM_CFLAGS) \
+ -DDATADIR=\""$(datadir)"\"
+
+libstatusnotifier_la_LDFLAGS = \
+ -avoid-version \
+ -module \
+ -no-undefined \
+ -export-symbols-regex '^xfce_panel_module_(preinit|init|construct)' \
+ $(PLATFORM_LDFLAGS)
+
+libstatusnotifier_la_LIBADD = \
+ $(GTK_LIBS) \
+ $(LIBXFCE4UTIL_LIBS) \
+ $(LIBXFCE4UI_LIBS) \
+ $(LIBXFCE4PANEL_LIBS) \
+ $(XFCONF_LIBS) \
+ $(DBUSMENU_LIBS)
+
+desktopdir = \
+ $(datadir)/xfce4/panel/plugins
+
+desktop_in_files = \
+ statusnotifier.desktop.in
+
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+
+ at INTLTOOL_DESKTOP_RULE@
+
+EXTRA_DIST = \
+ sn-dialog.glade \
+ $(desktop_in_files)
+
+DISTCLEANFILES = \
+ $(desktop_DATA)
+
+if MAINTAINER_MODE
+
+sn-watcher.h:
+sn-watcher.c: sn-watcher.xml Makefile
+ $(AM_V_GEN) $(GDBUS_CODEGEN) \
+ --interface-prefix org.kde.StatusNotifierWatcher \
+ --generate-c-code sn-watcher \
+ $(srcdir)/sn-watcher.xml
+
+sn-dialog-ui.h: sn-dialog.glade
+ $(AM_V_GEN) xdt-csource --static --strip-comments --strip-content --name=sn_dialog_ui $< >$@
+
+BUILT_SOURCES = \
+ $(libstatusnotifier_built_sources)
+
+DISTCLEANFILES += \
+ $(libstatusnotifier_built_sources)
+
+endif
+
+# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/panel-plugin/sn-backend.c b/panel-plugin/sn-backend.c
new file mode 100644
index 0000000..4148804
--- /dev/null
+++ b/panel-plugin/sn-backend.c
@@ -0,0 +1,434 @@
+/*
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <gio/gio.h>
+
+#include "sn-backend.h"
+#include "sn-item.h"
+#include "sn-watcher.h"
+
+
+
+static void sn_backend_finalize (GObject *object);
+
+static void sn_backend_clear_items (SnBackend *backend);
+
+static gboolean sn_backend_register_item (SnWatcher *watcher,
+ GDBusMethodInvocation *invocation,
+ const gchar *service,
+ SnBackend *backend);
+
+static void sn_backend_unregister_item (SnBackend *backend,
+ SnItem *item,
+ gboolean remove_and_notify);
+
+static gboolean sn_backend_register_host (SnWatcher *watcher,
+ GDBusMethodInvocation *invocation,
+ const gchar *service);
+
+static void sn_backend_update_registered_items (SnBackend *backend);
+
+
+
+struct _SnBackendClass
+{
+ GObjectClass __parent__;
+};
+
+struct _SnBackend
+{
+ GObject __parent__;
+
+ guint bus_owner_id;
+
+ SnWatcher *watcher;
+ GHashTable *items;
+};
+
+G_DEFINE_TYPE (SnBackend, sn_backend, G_TYPE_OBJECT)
+
+
+
+enum
+{
+ PROP_0,
+ PROP_IO_ENTRY,
+};
+
+enum
+{
+ ITEM_ADDED,
+ ITEM_REMOVED,
+ LAST_SIGNAL
+};
+
+static guint sn_backend_signals[LAST_SIGNAL] = { 0, };
+
+
+
+typedef struct
+{
+ gint index;
+ gchar **out;
+}
+CollectItemKeysContext;
+
+
+
+static void
+sn_backend_class_init (SnBackendClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = sn_backend_finalize;
+
+ sn_backend_signals[ITEM_ADDED] =
+ g_signal_new (g_intern_static_string ("item-added"),
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, XFCE_TYPE_SN_ITEM);
+
+ sn_backend_signals[ITEM_REMOVED] =
+ g_signal_new (g_intern_static_string ("item-removed"),
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, XFCE_TYPE_SN_ITEM);
+}
+
+
+
+static void
+sn_backend_init (SnBackend *backend)
+{
+ backend->bus_owner_id = 0;
+ backend->watcher = NULL;
+ backend->items = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+}
+
+
+
+static void
+sn_backend_finalize (GObject *object)
+{
+ SnBackend *backend = XFCE_SN_BACKEND (object);
+
+ sn_backend_clear_items (backend);
+ g_hash_table_destroy (backend->items);
+
+ if (backend->watcher != NULL)
+ g_object_unref (backend->watcher);
+
+ if (backend->bus_owner_id != 0)
+ g_bus_unown_name (backend->bus_owner_id);
+
+ G_OBJECT_CLASS (sn_backend_parent_class)->finalize (object);
+}
+
+
+
+static gboolean
+sn_backend_clear_item (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ SnBackend *backend = user_data;
+ SnItem *item = value;
+
+ sn_backend_unregister_item (backend, item, FALSE);
+
+ return TRUE;
+}
+
+
+
+static void
+sn_backend_clear_items (SnBackend *backend)
+{
+ g_hash_table_foreach_remove (backend->items, sn_backend_clear_item, backend);
+}
+
+
+
+static void
+sn_backend_bus_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ SnBackend *backend = user_data;
+ GError *error = NULL;
+
+ if (backend->watcher != NULL)
+ g_object_unref (backend->watcher);
+
+ backend->watcher = sn_watcher_skeleton_new ();
+
+ sn_watcher_set_is_status_notifier_host_registered (backend->watcher, TRUE);
+ sn_watcher_set_registered_status_notifier_items (backend->watcher, NULL);
+ sn_watcher_set_protocol_version (backend->watcher, 0);
+
+ g_signal_connect (backend->watcher, "handle-register-status-notifier-item",
+ G_CALLBACK (sn_backend_register_item), backend);
+ g_signal_connect (backend->watcher, "handle-register-status-notifier-host",
+ G_CALLBACK (sn_backend_register_host), backend);
+
+ g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (backend->watcher),
+ connection, "/StatusNotifierWatcher", &error);
+
+ if (error != NULL)
+ {
+ g_error_free (error);
+
+ g_object_unref (backend->watcher);
+ backend->watcher = NULL;
+ }
+}
+
+
+
+static void
+sn_backend_name_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ SnBackend *backend = user_data;
+
+ if (backend->watcher != NULL)
+ sn_watcher_emit_status_notifier_host_registered (backend->watcher);
+}
+
+
+
+static void
+sn_backend_name_lost (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ SnBackend *backend = user_data;
+
+ sn_backend_clear_items (backend);
+}
+
+
+
+SnBackend *
+sn_backend_new (void)
+{
+ return g_object_new (XFCE_TYPE_SN_BACKEND, NULL);
+}
+
+
+
+void
+sn_backend_start (SnBackend *backend)
+{
+ g_return_if_fail (XFCE_IS_SN_BACKEND (backend));
+ g_return_if_fail (backend->bus_owner_id == 0);
+
+ backend->bus_owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ "org.kde.StatusNotifierWatcher",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ sn_backend_bus_acquired,
+ sn_backend_name_acquired,
+ sn_backend_name_lost,
+ backend, NULL);
+}
+
+
+
+static void
+sn_backend_item_expose (SnItem *item,
+ SnBackend *backend)
+{
+ g_signal_emit (G_OBJECT (backend), sn_backend_signals[ITEM_ADDED], 0, item);
+}
+
+
+
+static void
+sn_backend_item_seal (SnItem *item,
+ SnBackend *backend)
+{
+ g_signal_emit (G_OBJECT (backend), sn_backend_signals[ITEM_REMOVED], 0, item);
+}
+
+
+
+static void
+sn_backend_item_finish (SnItem *item,
+ SnBackend *backend)
+{
+ sn_backend_unregister_item (backend, item, TRUE);
+}
+
+
+
+static gboolean
+sn_backend_register_item (SnWatcher *watcher,
+ GDBusMethodInvocation *invocation,
+ const gchar *service,
+ SnBackend *backend)
+{
+ const gchar *bus_name;
+ const gchar *object_path;
+ const gchar *sender;
+ gchar *key;
+ SnItem *item;
+
+ sender = g_dbus_method_invocation_get_sender (invocation);
+
+ if (service[0] == '/')
+ {
+ /* /org/ayatana/NotificationItem */
+ bus_name = sender;
+ object_path = service;
+ }
+ else
+ {
+ /* org.kde.StatusNotifierItem */
+ bus_name = service;
+ object_path = "/StatusNotifierItem";
+ }
+
+ key = g_strdup_printf ("%s%s", bus_name, object_path);
+ item = g_hash_table_lookup (backend->items, key);
+ if (item != NULL)
+ {
+ g_free (key);
+ sn_item_invalidate (item);
+ }
+ else
+ {
+ item = g_object_new (XFCE_TYPE_SN_ITEM,
+ "bus-name", bus_name,
+ "object-path", object_path,
+ "service", service,
+ "key", key,
+ NULL);
+ g_signal_connect (item, "expose",
+ G_CALLBACK (sn_backend_item_expose), backend);
+ g_signal_connect (item, "seal",
+ G_CALLBACK (sn_backend_item_seal), backend);
+ g_signal_connect (item, "finish",
+ G_CALLBACK (sn_backend_item_finish), backend);
+ sn_item_start (item);
+ g_hash_table_insert (backend->items, key, item);
+ }
+
+ sn_backend_update_registered_items (backend);
+
+ sn_watcher_complete_register_status_notifier_item (watcher, invocation);
+
+ sn_watcher_emit_status_notifier_item_registered (watcher, service);
+
+ return TRUE;
+}
+
+
+
+static void
+sn_backend_unregister_item (SnBackend *backend,
+ SnItem *item,
+ gboolean remove_and_notify)
+{
+ gchar *service;
+ gchar *key;
+ gboolean exposed;
+
+ g_object_get (item,
+ "service", &service,
+ "key", &key,
+ "exposed", &exposed,
+ NULL);
+
+ if (exposed)
+ g_signal_emit (G_OBJECT (backend), sn_backend_signals[ITEM_REMOVED], 0, item);
+
+ if (remove_and_notify)
+ g_hash_table_remove (backend->items, key);
+
+ g_object_unref (item);
+
+ if (backend->watcher != NULL)
+ sn_watcher_emit_status_notifier_item_unregistered (backend->watcher, service);
+
+ g_free (service);
+ g_free (key);
+
+ if (remove_and_notify)
+ sn_backend_update_registered_items (backend);
+}
+
+
+
+static gboolean
+sn_backend_register_host (SnWatcher *watcher,
+ GDBusMethodInvocation *invocation,
+ const gchar *service)
+{
+ g_dbus_method_invocation_return_error_literal (invocation,
+ G_IO_ERROR,
+ G_IO_ERROR_EXISTS,
+ "Multiple hosts are not supported");
+
+ return FALSE;
+}
+
+
+
+static void
+sn_backend_collect_item_keys (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ CollectItemKeysContext *context = user_data;
+ context->out[context->index++] = key;
+}
+
+
+
+static void
+sn_backend_update_registered_items (SnBackend *backend)
+{
+ CollectItemKeysContext context;
+
+ if (backend->watcher != NULL)
+ {
+ context.index = 0;
+ context.out = g_new0 (gchar *, g_hash_table_size (backend->items) + 1);
+ g_hash_table_foreach (backend->items,
+ sn_backend_collect_item_keys,
+ &context);
+ sn_watcher_set_registered_status_notifier_items (backend->watcher,
+ (gpointer)context.out);
+ g_free (context.out);
+ }
+}
diff --git a/panel-plugin/sn-backend.h b/panel-plugin/sn-backend.h
new file mode 100644
index 0000000..9e98cc3
--- /dev/null
+++ b/panel-plugin/sn-backend.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __SN_BACKEND_H__
+#define __SN_BACKEND_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SnBackendClass SnBackendClass;
+typedef struct _SnBackend SnBackend;
+
+#define XFCE_TYPE_SN_BACKEND (sn_backend_get_type ())
+#define XFCE_SN_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_SN_BACKEND, SnBackend))
+#define XFCE_SN_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_SN_BACKEND, SnBackendClass))
+#define XFCE_IS_SN_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_SN_BACKEND))
+#define XFCE_IS_SN_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_SN_BACKEND))
+#define XFCE_SN_BACKEND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_SN_BACKEND, SnBackendClass))
+
+GType sn_backend_get_type (void) G_GNUC_CONST;
+
+SnBackend *sn_backend_new (void);
+
+void sn_backend_start (SnBackend *backend);
+
+G_END_DECLS
+
+#endif /* !__SN_BACKEND_H__ */
diff --git a/panel-plugin/sn-box.c b/panel-plugin/sn-box.c
new file mode 100644
index 0000000..e9d1067
--- /dev/null
+++ b/panel-plugin/sn-box.c
@@ -0,0 +1,535 @@
+/*
+ * Copyright (c) 2012-2013 Andrzej Radecki <andrzejr at xfce.org>
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <libxfce4panel/libxfce4panel.h>
+
+#include "sn-box.h"
+#include "sn-button.h"
+
+
+
+static void sn_box_finalize (GObject *object);
+
+static void sn_box_collect_known_items (SnBox *box,
+ GHashTable *result);
+
+static void sn_box_list_changed (SnBox *box,
+ SnConfig *config);
+
+static void sn_box_add (GtkContainer *container,
+ GtkWidget *child);
+
+static void sn_box_remove (GtkContainer *container,
+ GtkWidget *child);
+
+static void sn_box_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data);
+
+static GType sn_box_child_type (GtkContainer *container);
+
+static void sn_box_get_preferred_length (GtkWidget *widget,
+ gint *minimal_length,
+ gint *natural_length);
+
+static void sn_box_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width);
+
+static void sn_box_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height);
+
+static void sn_box_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
+
+
+
+struct _SnBoxClass
+{
+ GtkContainerClass __parent__;
+};
+
+struct _SnBox
+{
+ GtkContainer __parent__;
+
+ SnConfig *config;
+
+ /* in theory it's possible to have multiple items with same name */
+ GHashTable *children;
+
+ gulong config_collect_known_items_handler;
+ gulong config_items_list_changed_handler;
+};
+
+G_DEFINE_TYPE (SnBox, sn_box, GTK_TYPE_CONTAINER)
+
+
+
+static void
+sn_box_class_init (SnBoxClass *klass)
+{
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ GtkContainerClass *container_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = sn_box_finalize;
+
+ widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->get_preferred_width = sn_box_get_preferred_width;
+ widget_class->get_preferred_height = sn_box_get_preferred_height;
+ widget_class->size_allocate = sn_box_size_allocate;
+
+ container_class = GTK_CONTAINER_CLASS (klass);
+ container_class->add = sn_box_add;
+ container_class->remove = sn_box_remove;
+ container_class->forall = sn_box_forall;
+ container_class->child_type = sn_box_child_type;
+}
+
+
+
+static void
+sn_box_init (SnBox *box)
+{
+ gtk_widget_set_has_window (GTK_WIDGET (box), FALSE);
+ gtk_widget_set_can_focus (GTK_WIDGET (box), TRUE);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 0);
+
+ box->children = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+}
+
+
+
+static void
+sn_box_finalize (GObject *object)
+{
+ SnBox *box = XFCE_SN_BOX (object);
+
+ if (box->config_collect_known_items_handler != 0)
+ {
+ g_signal_handler_disconnect (box->config, box->config_collect_known_items_handler);
+ box->config_collect_known_items_handler = 0;
+ }
+
+ if (box->config_items_list_changed_handler != 0)
+ {
+ g_signal_handler_disconnect (box->config, box->config_items_list_changed_handler);
+ box->config_items_list_changed_handler = 0;
+ }
+
+ g_hash_table_destroy (box->children);
+
+ G_OBJECT_CLASS (sn_box_parent_class)->finalize (object);
+}
+
+
+
+GtkWidget *
+sn_box_new (SnConfig *config)
+{
+ SnBox *box = g_object_new (XFCE_TYPE_SN_BOX, NULL);
+
+ box->config = config;
+
+ box->config_collect_known_items_handler =
+ g_signal_connect_swapped (G_OBJECT (box->config), "collect-known-items",
+ G_CALLBACK (sn_box_collect_known_items), box);
+ box->config_items_list_changed_handler =
+ g_signal_connect_swapped (G_OBJECT (box->config), "items-list-changed",
+ G_CALLBACK (sn_box_list_changed), box);
+
+ return GTK_WIDGET (box);
+}
+
+
+
+static void
+sn_box_collect_known_items_callback (GtkWidget *widget,
+ gpointer user_data)
+{
+ SnButton *button = XFCE_SN_BUTTON (widget);
+ GHashTable *table = user_data;
+ gchar *name;
+
+ name = g_strdup (sn_button_get_name (button));
+ g_hash_table_replace (table, name, name);
+}
+
+
+
+static void
+sn_box_collect_known_items (SnBox *box,
+ GHashTable *result)
+{
+ gtk_container_foreach (GTK_CONTAINER (box),
+ sn_box_collect_known_items_callback, result);
+}
+
+
+
+static void
+sn_box_list_changed (SnBox *box,
+ SnConfig *config)
+{
+ SnButton *button;
+ GList *known_items, *li, *li_int, *li_tmp;
+
+ g_return_if_fail (XFCE_IS_SN_BOX (box));
+ g_return_if_fail (XFCE_IS_SN_CONFIG (config));
+
+ gtk_container_foreach (GTK_CONTAINER (box), (GtkCallback)gtk_widget_unmap, NULL);
+
+ known_items = sn_config_get_known_items (box->config);
+ for (li = known_items; li != NULL; li = li->next)
+ {
+ li_int = g_hash_table_lookup (box->children, li->data);
+ for (li_tmp = li_int; li_tmp != NULL; li_tmp = li_tmp->next)
+ {
+ button = li_tmp->data;
+ if (!sn_config_is_hidden (box->config,
+ sn_button_get_name (button)))
+ {
+ gtk_widget_map (GTK_WIDGET (button));
+ }
+ }
+ }
+
+ gtk_widget_queue_resize (GTK_WIDGET (box));
+}
+
+
+
+static void
+sn_box_add (GtkContainer *container,
+ GtkWidget *child)
+{
+ SnBox *box = XFCE_SN_BOX (container);
+ SnButton *button = XFCE_SN_BUTTON (child);
+ GList *li;
+ const gchar *name;
+
+ g_return_if_fail (XFCE_IS_SN_BOX (box));
+ g_return_if_fail (XFCE_IS_SN_BUTTON (button));
+ g_return_if_fail (gtk_widget_get_parent (GTK_WIDGET (child)) == NULL);
+
+ name = sn_button_get_name (button);
+ li = g_hash_table_lookup (box->children, name);
+ li = g_list_prepend (li, button);
+ g_hash_table_replace (box->children, g_strdup (name), li);
+
+ gtk_widget_set_parent (child, GTK_WIDGET (box));
+
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+}
+
+
+
+static void
+sn_box_remove (GtkContainer *container,
+ GtkWidget *child)
+{
+ SnBox *box = XFCE_SN_BOX (container);
+ SnButton *button = XFCE_SN_BUTTON (child);
+ GList *li, *li_tmp;
+ const gchar *name;
+
+ /* search the child */
+ name = sn_button_get_name (button);
+ li = g_hash_table_lookup (box->children, name);
+ li_tmp = g_list_find (li, button);
+ if (G_LIKELY (li_tmp != NULL))
+ {
+ /* unparent widget */
+ li = g_list_remove_link (li, li_tmp);
+ g_hash_table_replace (box->children, g_strdup (name), li);
+ gtk_widget_unparent (child);
+
+ /* resize, so we update has-hidden */
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+ }
+}
+
+
+
+static void
+sn_box_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data)
+{
+ SnBox *box = XFCE_SN_BOX (container);
+ SnButton *button;
+ GList *known_items, *li, *li_int, *li_tmp;
+
+ /* run callback for all children */
+ known_items = sn_config_get_known_items (box->config);
+ for (li = known_items; li != NULL; li = li->next)
+ {
+ li_int = g_hash_table_lookup (box->children, li->data);
+ for (li_tmp = li_int; li_tmp != NULL; li_tmp = li_tmp->next)
+ {
+ button = li_tmp->data;
+ callback (GTK_WIDGET (button), callback_data);
+ }
+ }
+}
+
+
+
+static GType
+sn_box_child_type (GtkContainer *container)
+{
+ return XFCE_TYPE_SN_BUTTON;
+}
+
+
+
+static void
+sn_box_get_preferred_length (GtkWidget *widget,
+ gint *minimum_length,
+ gint *natural_length)
+{
+ SnBox *box = XFCE_SN_BOX (widget);
+ SnButton *button;
+ GList *known_items, *li, *li_int, *li_tmp;
+ gint panel_size, icon_size, size, nrows;
+ gboolean single_row, square_icons;
+ gint x, index;
+ GtkRequisition child_req;
+
+ panel_size = sn_config_get_panel_size (box->config);
+ icon_size = sn_config_get_icon_size (box->config);
+ single_row = sn_config_get_single_row (box->config);
+ square_icons = sn_config_get_square_icons (box->config);
+ icon_size += 2; /* additional padding */
+ if (square_icons)
+ {
+ nrows = MAX (1, sn_config_get_nrows (box->config));
+ size = panel_size / (single_row ? 1 : nrows);
+ }
+ else
+ {
+ size = MIN (icon_size, panel_size);
+ nrows = single_row ? 1 : MAX (1, panel_size / size);
+ }
+
+ x = 0;
+ index = 0;
+
+ known_items = sn_config_get_known_items (box->config);
+ for (li = known_items; li != NULL; li = li->next)
+ {
+ li_int = g_hash_table_lookup (box->children, li->data);
+ for (li_tmp = li_int; li_tmp != NULL; li_tmp = li_tmp->next)
+ {
+ button = li_tmp->data;
+ if (sn_config_is_hidden (box->config,
+ sn_button_get_name (button)))
+ {
+ continue;
+ }
+
+ gtk_widget_get_preferred_size (GTK_WIDGET (button), NULL, &child_req);
+
+ /* for each first item in row */
+ if (index % nrows == 0)
+ x += size;
+ index += 1;
+ }
+ }
+
+ if (minimum_length != NULL)
+ *minimum_length = x;
+
+ if (natural_length != NULL)
+ *natural_length = x;
+}
+
+
+
+static void
+sn_box_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ SnBox *box = XFCE_SN_BOX (widget);
+ gint panel_size;
+
+ if (sn_config_get_panel_orientation (box->config) == GTK_ORIENTATION_HORIZONTAL)
+ {
+ sn_box_get_preferred_length (widget, minimum_width, natural_width);
+ }
+ else
+ {
+ panel_size = sn_config_get_panel_size (box->config);
+ if (minimum_width != NULL)
+ *minimum_width = panel_size;
+ if (natural_width != NULL)
+ *natural_width = panel_size;
+ }
+}
+
+
+
+static void
+sn_box_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ SnBox *box = XFCE_SN_BOX (widget);
+ gint panel_size;
+
+ if (sn_config_get_panel_orientation (box->config) == GTK_ORIENTATION_VERTICAL)
+ {
+ sn_box_get_preferred_length (widget, minimum_height, natural_height);
+ }
+ else
+ {
+ panel_size = sn_config_get_panel_size (box->config);
+ if (minimum_height != NULL)
+ *minimum_height = panel_size;
+ if (natural_height != NULL)
+ *natural_height = panel_size;
+ }
+}
+
+
+
+static void
+sn_box_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ SnBox *box = XFCE_SN_BOX (widget);
+ SnButton *button;
+ GtkAllocation child_alloc;
+ gint panel_size, icon_size, xsize, ysize, nrows;
+ gboolean single_row, square_icons;
+ gint x, y, row;
+ GList *known_items, *li, *li_int, *li_tmp;
+ GtkOrientation panel_orientation;
+
+ row = 0;
+ x = 0;
+ y = 0;
+
+ gtk_widget_set_allocation (widget, allocation);
+
+ panel_size = sn_config_get_panel_size (box->config);
+ icon_size = sn_config_get_icon_size (box->config);
+ single_row = sn_config_get_single_row (box->config);
+ square_icons = sn_config_get_square_icons (box->config);
+ icon_size += 2; /* additional padding */
+ if (square_icons)
+ {
+ nrows = MAX (1, sn_config_get_nrows (box->config));
+ xsize = ysize = panel_size / (single_row ? 1 : nrows);
+ }
+ else
+ {
+ xsize = MIN (icon_size, panel_size);
+ nrows = single_row ? 1 : MAX (1, panel_size / xsize);
+ ysize = panel_size / nrows;
+ }
+
+ panel_orientation = sn_config_get_panel_orientation (box->config);
+
+ known_items = sn_config_get_known_items (box->config);
+ for (li = known_items; li != NULL; li = li->next)
+ {
+ li_int = g_hash_table_lookup (box->children, li->data);
+ for (li_tmp = li_int; li_tmp != NULL; li_tmp = li_tmp->next)
+ {
+ button = li_int->data;
+ if (sn_config_is_hidden (box->config,
+ sn_button_get_name (button)))
+ {
+ continue;
+ }
+
+ if (nrows == 1)
+ y = (panel_size - ysize + 1) / 2;
+ else
+ y = (2 * row * (panel_size - ysize) + nrows - 1) / (2 * nrows - 2);
+
+ if (panel_orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ child_alloc.x = allocation->x + x;
+ child_alloc.y = allocation->y + y;
+ child_alloc.width = xsize;
+ child_alloc.height = ysize;
+ }
+ else
+ {
+ child_alloc.x = allocation->x + y;
+ child_alloc.y = allocation->y + x;
+ child_alloc.width = ysize;
+ child_alloc.height = xsize;
+ }
+
+ gtk_widget_size_allocate (GTK_WIDGET (button), &child_alloc);
+
+ row += 1;
+ if (row >= nrows)
+ {
+ x += xsize;
+ row = 0;
+ }
+ }
+ }
+}
+
+
+
+void
+sn_box_remove_item (SnBox *box,
+ SnItem *item)
+{
+ SnButton *button;
+ GList *known_items, *li, *li_int, *li_tmp;
+
+ g_return_if_fail (XFCE_IS_SN_BOX (box));
+
+ known_items = sn_config_get_known_items (box->config);
+ for (li = known_items; li != NULL; li = li->next)
+ {
+ li_int = g_hash_table_lookup (box->children, li->data);
+ for (li_tmp = li_int; li_tmp != NULL; li_tmp = li_tmp->next)
+ {
+ button = li_tmp->data;
+ if (sn_button_get_item (button) == item)
+ {
+ gtk_container_remove (GTK_CONTAINER (box), GTK_WIDGET (button));
+ return;
+ }
+ }
+ }
+}
diff --git a/panel-plugin/sn-box.h b/panel-plugin/sn-box.h
new file mode 100644
index 0000000..58d6f9d
--- /dev/null
+++ b/panel-plugin/sn-box.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2012-2013 Andrzej Radecki <andrzejr at xfce.org>
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __SN_BOX_H__
+#define __SN_BOX_H__
+
+#include <gtk/gtk.h>
+
+#include "sn-config.h"
+#include "sn-item.h"
+
+G_BEGIN_DECLS
+
+typedef struct _SnBoxClass SnBoxClass;
+typedef struct _SnBox SnBox;
+
+#define XFCE_TYPE_SN_BOX (sn_box_get_type ())
+#define XFCE_SN_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_SN_BOX, SnBox))
+#define XFCE_SN_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_SN_BOX, SnBoxClass))
+#define XFCE_IS_SN_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_SN_BOX))
+#define XFCE_IS_SN_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_SN_BOX))
+#define XFCE_SN_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_SN_BOX, SnBoxClass))
+
+GType sn_box_get_type (void) G_GNUC_CONST;
+
+void sn_box_remove_item (SnBox *box,
+ SnItem *item);
+
+GtkWidget *sn_box_new (SnConfig *config);
+
+G_END_DECLS
+
+#endif /* !__SN_BOX_H__ */
diff --git a/panel-plugin/sn-button.c b/panel-plugin/sn-button.c
new file mode 100644
index 0000000..513bdfb
--- /dev/null
+++ b/panel-plugin/sn-button.c
@@ -0,0 +1,394 @@
+/*
+ * Copyright (c) 2012-2013 Andrzej Radecki <andrzejr at xfce.org>
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include "sn-button.h"
+#include "sn-icon-box.h"
+
+
+
+static void sn_button_finalize (GObject *object);
+
+static gboolean sn_button_button_press (GtkWidget *widget,
+ GdkEventButton *event);
+
+static gboolean sn_button_button_release (GtkWidget *widget,
+ GdkEventButton *event);
+
+static gboolean sn_button_scroll_event (GtkWidget *widget,
+ GdkEventScroll *event);
+
+static void sn_button_menu_changed (GtkWidget *widget,
+ SnItem *item);
+
+static gboolean sn_button_query_tooltip (GtkWidget *widget,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip *tooltip,
+ gpointer user_data);
+
+
+
+struct _SnButtonClass
+{
+ GtkButtonClass __parent__;
+};
+
+struct _SnButton
+{
+ GtkButton __parent__;
+
+ SnItem *item;
+ GtkMenuPositionFunc pos_func;
+ gpointer pos_func_data;
+
+ GtkWidget *menu;
+ gboolean menu_only;
+
+ GtkWidget *box;
+
+ guint item_tooltip_changed_handler;
+ guint item_menu_changed_handler;
+ guint menu_deactivate_handler;
+};
+
+G_DEFINE_TYPE (SnButton, sn_button, GTK_TYPE_BUTTON)
+
+
+
+static void
+sn_button_class_init (SnButtonClass *klass)
+{
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = sn_button_finalize;
+
+ widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->button_press_event = sn_button_button_press;
+ widget_class->button_release_event = sn_button_button_release;
+ widget_class->scroll_event = sn_button_scroll_event;
+}
+
+
+
+static void
+sn_button_init (SnButton *button)
+{
+ GtkCssProvider *css_provider;
+
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+
+ gtk_widget_set_name (GTK_WIDGET (button), "sn-button");
+ css_provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (css_provider,
+ "#sn-button {"
+ "padding: 0px;"
+ "border-width: 1px;"
+ "}", -1, NULL);
+ gtk_style_context_add_provider (GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (button))),
+ GTK_STYLE_PROVIDER (css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (css_provider);
+
+ gtk_widget_add_events (GTK_WIDGET (button), GDK_SCROLL_MASK | GDK_SMOOTH_SCROLL_MASK);
+
+ button->item = NULL;
+ button->pos_func = NULL;
+ button->pos_func_data = NULL;
+
+ button->menu = NULL;
+ button->menu_only = FALSE;
+
+ button->box = NULL;
+
+ button->item_tooltip_changed_handler = 0;
+ button->item_menu_changed_handler = 0;
+ button->menu_deactivate_handler = 0;
+
+ gtk_widget_set_halign (GTK_WIDGET (button), GTK_ALIGN_FILL);
+ gtk_widget_set_valign (GTK_WIDGET (button), GTK_ALIGN_FILL);
+}
+
+
+
+SnItem *
+sn_button_get_item (SnButton *button)
+{
+ g_return_val_if_fail (XFCE_IS_SN_BUTTON (button), NULL);
+
+ return button->item;
+}
+
+
+
+const gchar *
+sn_button_get_name (SnButton *button)
+{
+ g_return_val_if_fail (XFCE_IS_SN_BUTTON (button), NULL);
+
+ return sn_item_get_name (button->item);
+}
+
+
+
+GtkWidget *
+sn_button_new (SnItem *item,
+ GtkMenuPositionFunc pos_func,
+ gpointer pos_func_data,
+ SnConfig *config)
+{
+ SnButton *button = g_object_new (XFCE_TYPE_SN_BUTTON, NULL);
+ GtkWidget *image, *menu;
+
+ g_return_val_if_fail (XFCE_IS_SN_ITEM (item), NULL);
+ g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), NULL);
+
+ button->item = item;
+ button->pos_func = pos_func;
+ button->pos_func_data = pos_func_data;
+
+ button->box = sn_icon_box_new (item, config);
+ gtk_container_add (GTK_CONTAINER (button), button->box);
+ gtk_widget_show (button->box);
+
+ g_object_set (G_OBJECT (button), "has-tooltip", TRUE, NULL);
+ g_signal_connect (button, "query-tooltip",
+ G_CALLBACK (sn_button_query_tooltip), NULL);
+ button->item_tooltip_changed_handler =
+ g_signal_connect_swapped (item, "tooltip-changed",
+ G_CALLBACK (gtk_widget_trigger_tooltip_query), button);
+ button->item_menu_changed_handler =
+ g_signal_connect_swapped (item, "menu-changed",
+ G_CALLBACK (sn_button_menu_changed), button);
+ sn_button_menu_changed (GTK_WIDGET (button), item);
+
+ return GTK_WIDGET (button);
+}
+
+
+
+static void
+sn_button_finalize (GObject *object)
+{
+ SnButton *button = XFCE_SN_BUTTON (object);
+
+ if (button->item_tooltip_changed_handler != 0)
+ g_signal_handler_disconnect (button->item, button->item_tooltip_changed_handler);
+
+ if (button->item_menu_changed_handler != 0)
+ g_signal_handler_disconnect (button->item, button->item_menu_changed_handler);
+
+ if (button->menu_deactivate_handler != 0)
+ g_signal_handler_disconnect (button->menu, button->menu_deactivate_handler);
+
+ G_OBJECT_CLASS (sn_button_parent_class)->finalize (object);
+}
+
+
+
+static void
+sn_button_menu_deactivate (GtkWidget *widget,
+ GtkMenu *menu)
+{
+ SnButton *button = XFCE_SN_BUTTON (widget);
+
+ if (button->menu_deactivate_handler != 0)
+ {
+ g_signal_handler_disconnect (menu, button->menu_deactivate_handler);
+ button->menu_deactivate_handler = 0;
+ }
+
+ gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_ACTIVE);
+}
+
+
+
+static gboolean
+sn_button_button_press (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ SnButton *button = XFCE_SN_BUTTON (widget);
+
+ if (event->button == 3 && button->menu_only)
+ {
+ /* menu is available by left click, so show the panel menu instead */
+ return FALSE;
+ }
+
+ if ((event->button == 1 && button->menu_only) || event->button == 3)
+ {
+ if (button->menu != NULL)
+ {
+ button->menu_deactivate_handler =
+ g_signal_connect_swapped (G_OBJECT (button->menu), "deactivate",
+ G_CALLBACK (sn_button_menu_deactivate), button);
+ gtk_menu_reposition (GTK_MENU (button->menu));
+#if GTK_CHECK_VERSION(3, 22, 0)
+ gtk_menu_popup_at_widget (GTK_MENU (button->menu), widget,
+ GDK_GRAVITY_NORTH_WEST, GDK_GRAVITY_NORTH_WEST,
+ (GdkEvent *)event);
+#else
+ gtk_menu_popup (GTK_MENU (button->menu), NULL, NULL,
+ button->pos_func, button->pos_func_data,
+ event->button, event->time);
+#endif
+
+ gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_ACTIVE, FALSE);
+ return TRUE;
+ }
+ else if (event->button == 3)
+ {
+ /* dispay panel menu */
+ return FALSE;
+ }
+ }
+
+ /* process animations */
+ GTK_WIDGET_CLASS (sn_button_parent_class)->button_press_event (widget, event);
+
+ return TRUE;
+}
+
+
+
+static gboolean
+sn_button_button_release (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ SnButton *button = XFCE_SN_BUTTON (widget);
+
+ if (event->button == 1)
+ {
+ /* menu could be handled in button-press-event, check this */
+ if (button->menu == NULL || !button->menu_only)
+ sn_item_activate (button->item, (gint) event->x_root, (gint) event->y_root);
+ }
+ else if (event->button == 2)
+ {
+ sn_item_secondary_activate (button->item, (gint) event->x_root, (gint) event->y_root);
+ }
+
+ /* process animations */
+ GTK_WIDGET_CLASS (sn_button_parent_class)->button_release_event (widget, event);
+
+ return TRUE;
+}
+
+
+
+static gboolean
+sn_button_scroll_event (GtkWidget *widget,
+ GdkEventScroll *event)
+{
+ SnButton *button = XFCE_SN_BUTTON (widget);
+ gdouble delta_x, delta_y;
+
+ if (!gdk_event_get_scroll_deltas ((GdkEvent *)event, &delta_x, &delta_y))
+ {
+ delta_x = event->delta_x;
+ delta_y = event->delta_y;
+ }
+
+ if (delta_x != 0 || delta_y != 0)
+ {
+ delta_x = (delta_x == 0 ? 0 : delta_x > 0 ? 1 : -1) *
+ MAX (ABS (delta_x) + 0.5, 1);
+ delta_y = (delta_y == 0 ? 0 : delta_y > 0 ? 1 : -1) *
+ MAX (ABS (delta_y) + 0.5, 1);
+ sn_item_scroll (button->item, (gint) delta_x, (gint) delta_y);
+ }
+
+ return TRUE;
+}
+
+
+
+static void
+sn_button_menu_changed (GtkWidget *widget,
+ SnItem *item)
+{
+ SnButton *button = XFCE_SN_BUTTON (widget);
+
+ if (button->menu != NULL)
+ {
+ if (button->menu_deactivate_handler != 0)
+ {
+ g_signal_handler_disconnect (button->menu, button->menu_deactivate_handler);
+ button->menu_deactivate_handler = 0;
+
+ gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_ACTIVE);
+ gtk_menu_popdown (GTK_MENU (button->menu));
+ }
+
+ gtk_menu_detach (GTK_MENU (button->menu));
+ }
+
+ button->menu_only = sn_item_is_menu_only (item);
+ button->menu = sn_item_get_menu (item);
+
+ if (button->menu != NULL)
+ gtk_menu_attach_to_widget (GTK_MENU (button->menu), GTK_WIDGET (button), NULL);
+}
+
+
+
+static gboolean
+sn_button_query_tooltip (GtkWidget *widget,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip *tooltip,
+ gpointer user_data)
+{
+ SnButton *button = XFCE_SN_BUTTON (widget);
+ const gchar *tooltip_title;
+ const gchar *tooltip_subtitle;
+ gchar *full;
+
+ sn_item_get_tooltip (button->item, &tooltip_title, &tooltip_subtitle);
+
+ if (tooltip_title != NULL)
+ {
+ if (tooltip_subtitle != NULL)
+ {
+ full = g_strdup_printf ("<b>%s</b>\n%s", tooltip_title, tooltip_subtitle);
+ gtk_tooltip_set_markup (tooltip, full);
+ g_free (full);
+ }
+ else
+ {
+ gtk_tooltip_set_markup (tooltip, tooltip_title);
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/panel-plugin/sn-button.h b/panel-plugin/sn-button.h
new file mode 100644
index 0000000..bd08836
--- /dev/null
+++ b/panel-plugin/sn-button.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2012-2013 Andrzej Radecki <andrzejr at xfce.org>
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __SN_BUTTON_H__
+#define __SN_BUTTON_H__
+
+#include <gtk/gtk.h>
+
+#include "sn-config.h"
+#include "sn-item.h"
+
+G_BEGIN_DECLS
+
+typedef struct _SnButtonClass SnButtonClass;
+typedef struct _SnButton SnButton;
+
+#define XFCE_TYPE_SN_BUTTON (sn_button_get_type ())
+#define XFCE_SN_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_SN_BUTTON, SnButton))
+#define XFCE_SN_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_SN_BUTTON, SnButtonClass))
+#define XFCE_IS_SN_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_SN_BUTTON))
+#define XFCE_IS_SN_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_SN_BUTTON))
+#define XFCE_SN_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_SN_BUTTON, SnButtonClass))
+
+GType sn_button_get_type (void) G_GNUC_CONST;
+
+SnItem *sn_button_get_item (SnButton *button);
+
+const gchar *sn_button_get_name (SnButton *button);
+
+GtkWidget *sn_button_new (SnItem *item,
+ GtkMenuPositionFunc pos_func,
+ gpointer pos_func_data,
+ SnConfig *config);
+
+G_END_DECLS
+
+#endif /* !__SN_BUTTON_H__ */
diff --git a/panel-plugin/sn-config.c b/panel-plugin/sn-config.c
new file mode 100644
index 0000000..d45b3ae
--- /dev/null
+++ b/panel-plugin/sn-config.c
@@ -0,0 +1,758 @@
+/*
+ * Copyright (c) 2013 Andrzej Radecki <andrzejr at xfce.org>
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <libxfce4ui/libxfce4ui.h>
+#include <libxfce4util/libxfce4util.h>
+#include <libxfce4panel/xfce-panel-plugin.h>
+#include <xfconf/xfconf.h>
+#include <dbus/dbus-glib.h>
+
+#include "sn-plugin.h"
+#include "sn-config.h"
+
+
+
+#define DEFAULT_ICON_SIZE 22
+#define DEFAULT_SINGLE_ROW FALSE
+#define DEFAULT_SQUARE_ICONS FALSE
+#define DEFAULT_ORIENTATION GTK_ORIENTATION_HORIZONTAL
+#define DEFAULT_PANEL_ORIENTATION GTK_ORIENTATION_HORIZONTAL
+#define DEFAULT_PANEL_SIZE 28
+#define DEFAULT_MODE_WHITELIST FALSE
+
+
+
+static void sn_config_finalize (GObject *object);
+
+static void sn_config_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void sn_config_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+
+
+struct _SnConfigClass
+{
+ GObjectClass __parent__;
+};
+
+struct _SnConfig
+{
+ GObject __parent__;
+
+ gint icon_size;
+ gboolean single_row;
+ gboolean square_icons;
+ gboolean mode_whitelist;
+ GList *known_items;
+ GHashTable *hidden_items;
+
+ /* not xfconf properties but it is still convenient to have them here */
+ GtkOrientation orientation;
+ GtkOrientation panel_orientation;
+ gint nrows;
+ gint panel_size;
+};
+
+G_DEFINE_TYPE (SnConfig, sn_config, G_TYPE_OBJECT)
+
+
+
+enum
+{
+ PROP_0,
+ PROP_ICON_SIZE,
+ PROP_SINGLE_ROW,
+ PROP_SQUARE_ICONS,
+ PROP_MODE_WHITELIST,
+ PROP_KNOWN_ITEMS,
+ PROP_HIDDEN_ITEMS
+};
+
+enum
+{
+ CONFIGURATION_CHANGED,
+ ITEM_LIST_CHANGED,
+ COLLECT_KNOWN_ITEMS,
+ LAST_SIGNAL
+};
+
+static guint sn_config_signals[LAST_SIGNAL] = { 0, };
+
+
+
+#define XFCE_TYPE_SN_CONFIG_VALUE_ARRAY (sn_config_value_array_get_type ())
+
+
+
+static GType
+sn_config_value_array_get_type (void)
+{
+ static volatile gsize type__volatile = 0;
+ GType type;
+
+ if (g_once_init_enter (&type__volatile))
+ {
+ type = dbus_g_type_get_collection ("GPtrArray", G_TYPE_VALUE);
+ g_once_init_leave (&type__volatile, type);
+ }
+
+ return type__volatile;
+}
+
+
+
+static void
+sn_config_class_init (SnConfigClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = sn_config_finalize;
+ object_class->get_property = sn_config_get_property;
+ object_class->set_property = sn_config_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_ICON_SIZE,
+ g_param_spec_int ("icon-size", NULL, NULL,
+ 12, 64, DEFAULT_ICON_SIZE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_SINGLE_ROW,
+ g_param_spec_boolean ("single-row", NULL, NULL,
+ DEFAULT_SINGLE_ROW,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_SQUARE_ICONS,
+ g_param_spec_boolean ("square-icons", NULL, NULL,
+ DEFAULT_SQUARE_ICONS,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_MODE_WHITELIST,
+ g_param_spec_boolean ("mode-whitelist", NULL, NULL,
+ DEFAULT_MODE_WHITELIST,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_KNOWN_ITEMS,
+ g_param_spec_boxed ("known-items",
+ NULL, NULL,
+ XFCE_TYPE_SN_CONFIG_VALUE_ARRAY,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_HIDDEN_ITEMS,
+ g_param_spec_boxed ("hidden-items",
+ NULL, NULL,
+ XFCE_TYPE_SN_CONFIG_VALUE_ARRAY,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ sn_config_signals[CONFIGURATION_CHANGED] =
+ g_signal_new (g_intern_static_string ("configuration-changed"),
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ sn_config_signals[ITEM_LIST_CHANGED] =
+ g_signal_new (g_intern_static_string ("items-list-changed"),
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ sn_config_signals[COLLECT_KNOWN_ITEMS] =
+ g_signal_new (g_intern_static_string ("collect-known-items"),
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+}
+
+
+
+static void
+sn_config_init (SnConfig *config)
+{
+ config->icon_size = DEFAULT_ICON_SIZE;
+ config->single_row = DEFAULT_SINGLE_ROW;
+ config->square_icons = DEFAULT_SQUARE_ICONS;
+ config->mode_whitelist = DEFAULT_MODE_WHITELIST;
+ config->known_items = NULL;
+ config->hidden_items = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ config->orientation = DEFAULT_ORIENTATION;
+ config->panel_orientation = DEFAULT_PANEL_ORIENTATION;
+ config->nrows = 1;
+ config->panel_size = DEFAULT_PANEL_SIZE;
+}
+
+
+
+static void
+sn_config_finalize (GObject *object)
+{
+ SnConfig *config = XFCE_SN_CONFIG (object);
+
+ xfconf_shutdown ();
+
+ g_list_free_full (config->known_items, g_free);
+ g_hash_table_destroy (config->hidden_items);
+
+ G_OBJECT_CLASS (sn_config_parent_class)->finalize (object);
+}
+
+
+
+static void
+sn_config_free_array_element (gpointer data)
+{
+ GValue *value = (GValue *)data;
+
+ g_value_unset (value);
+ g_free (value);
+}
+
+
+
+static void
+sn_config_collect_keys (gpointer key,
+ gpointer value,
+ gpointer array)
+{
+ GValue *tmp;
+
+ tmp = g_new0 (GValue, 1);
+ g_value_init (tmp, G_TYPE_STRING);
+ g_value_set_string (tmp, key);
+ g_ptr_array_add (array, tmp);
+}
+
+
+
+static void
+sn_config_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ SnConfig *config = XFCE_SN_CONFIG (object);
+ GPtrArray *array;
+ GList *li;
+ GValue *tmp;
+
+ switch (prop_id)
+ {
+ case PROP_ICON_SIZE:
+ g_value_set_int (value, config->icon_size);
+ break;
+
+ case PROP_SINGLE_ROW:
+ g_value_set_boolean (value, config->single_row);
+ break;
+
+ case PROP_SQUARE_ICONS:
+ g_value_set_boolean (value, config->square_icons);
+ break;
+
+ case PROP_MODE_WHITELIST:
+ g_value_set_boolean (value, config->mode_whitelist);
+ break;
+
+ case PROP_KNOWN_ITEMS:
+ array = g_ptr_array_new_full (1, sn_config_free_array_element);
+ for (li = config->known_items; li != NULL; li = li->next)
+ {
+ tmp = g_new0 (GValue, 1);
+ g_value_init (tmp, G_TYPE_STRING);
+ g_value_set_string (tmp, li->data);
+ g_ptr_array_add (array, tmp);
+ }
+ g_value_set_boxed (value, array);
+ g_ptr_array_unref (array);
+ break;
+
+ case PROP_HIDDEN_ITEMS:
+ array = g_ptr_array_new_full (1, sn_config_free_array_element);
+ g_hash_table_foreach (config->hidden_items, sn_config_collect_keys, array);
+ g_value_set_boxed (value, array);
+ g_ptr_array_unref (array);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+
+static void
+sn_config_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ SnConfig *config = XFCE_SN_CONFIG (object);
+ gint val;
+ GPtrArray *array;
+ const GValue *tmp;
+ gchar *name;
+ guint i;
+
+ switch (prop_id)
+ {
+ case PROP_ICON_SIZE:
+ val = g_value_get_int (value);
+ if (config->icon_size != val)
+ {
+ config->icon_size = val;
+ g_signal_emit (G_OBJECT (config), sn_config_signals[CONFIGURATION_CHANGED], 0);
+ }
+ break;
+
+ case PROP_SINGLE_ROW:
+ val = g_value_get_boolean (value);
+ if (config->single_row != val)
+ {
+ config->single_row = val;
+ g_signal_emit (G_OBJECT (config), sn_config_signals[CONFIGURATION_CHANGED], 0);
+ }
+ break;
+
+ case PROP_SQUARE_ICONS:
+ val = g_value_get_boolean (value);
+ if (config->square_icons != val)
+ {
+ config->square_icons = val;
+ g_signal_emit (G_OBJECT (config), sn_config_signals[CONFIGURATION_CHANGED], 0);
+ }
+ break;
+
+ case PROP_MODE_WHITELIST:
+ val = g_value_get_boolean (value);
+ if (config->mode_whitelist != val)
+ {
+ config->mode_whitelist = val;
+ g_signal_emit (G_OBJECT (config), sn_config_signals[ITEM_LIST_CHANGED], 0);
+ }
+ break;
+
+ case PROP_KNOWN_ITEMS:
+ g_list_free_full (config->known_items, g_free);
+ config->known_items = NULL;
+ array = g_value_get_boxed (value);
+ if (G_LIKELY (array != NULL))
+ {
+ for (i = 0; i < array->len; i++)
+ {
+ tmp = g_ptr_array_index (array, i);
+ g_assert (G_VALUE_HOLDS_STRING (tmp));
+ name = g_value_dup_string (tmp);
+ config->known_items = g_list_append (config->known_items, name);
+ }
+ }
+ g_signal_emit (G_OBJECT (config), sn_config_signals[ITEM_LIST_CHANGED], 0);
+ break;
+
+ case PROP_HIDDEN_ITEMS:
+ g_hash_table_remove_all (config->hidden_items);
+ array = g_value_get_boxed (value);
+ if (G_LIKELY (array != NULL))
+ {
+ for (i = 0; i < array->len; i++)
+ {
+ tmp = g_ptr_array_index (array, i);
+ g_assert (G_VALUE_HOLDS_STRING (tmp));
+ name = g_value_dup_string (tmp);
+ g_hash_table_replace (config->hidden_items, name, name);
+ }
+ }
+ g_signal_emit (G_OBJECT (config), sn_config_signals[ITEM_LIST_CHANGED], 0);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+
+gint
+sn_config_get_icon_size (SnConfig *config)
+{
+ g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), DEFAULT_ICON_SIZE);
+
+ return config->icon_size;
+}
+
+
+
+gboolean
+sn_config_get_single_row (SnConfig *config)
+{
+ g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), DEFAULT_SINGLE_ROW);
+
+ return config->single_row;
+}
+
+
+
+gboolean
+sn_config_get_square_icons (SnConfig *config)
+{
+ g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), DEFAULT_SQUARE_ICONS);
+
+ return config->square_icons;
+}
+
+
+
+void
+sn_config_set_orientation (SnConfig *config,
+ GtkOrientation panel_orientation,
+ GtkOrientation orientation)
+{
+ gboolean needs_update = FALSE;
+
+ g_return_if_fail (XFCE_IS_SN_CONFIG (config));
+
+ if (config->orientation != orientation)
+ {
+ config->orientation = orientation;
+ needs_update = TRUE;
+ }
+
+ if (config->panel_orientation != panel_orientation)
+ {
+ config->panel_orientation = panel_orientation;
+ needs_update = TRUE;
+ }
+
+ if (needs_update)
+ g_signal_emit (G_OBJECT (config), sn_config_signals[CONFIGURATION_CHANGED], 0);
+}
+
+
+
+GtkOrientation
+sn_config_get_orientation (SnConfig *config)
+{
+ g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), DEFAULT_ORIENTATION);
+
+ return config->orientation;
+}
+
+
+
+GtkOrientation
+sn_config_get_panel_orientation (SnConfig *config)
+{
+ g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), DEFAULT_PANEL_ORIENTATION);
+
+ return config->panel_orientation;
+}
+
+
+
+void
+sn_config_set_size (SnConfig *config,
+ gint panel_size,
+ gint nrows)
+{
+ gboolean needs_update = FALSE;
+
+ g_return_if_fail (XFCE_IS_SN_CONFIG (config));
+
+ if (config->nrows != nrows)
+ {
+ config->nrows = nrows;
+ needs_update = TRUE;
+ }
+
+ if (config->panel_size != panel_size)
+ {
+ config->panel_size = panel_size;
+ needs_update = TRUE;
+ }
+
+ if (needs_update)
+ g_signal_emit (G_OBJECT (config), sn_config_signals[CONFIGURATION_CHANGED], 0);
+}
+
+
+
+gint
+sn_config_get_nrows (SnConfig *config)
+{
+ g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), 1);
+
+ return config->nrows;
+}
+
+
+
+gint
+sn_config_get_panel_size (SnConfig *config)
+{
+ g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), DEFAULT_PANEL_SIZE);
+
+ return config->panel_size;
+}
+
+
+
+gboolean
+sn_config_is_hidden (SnConfig *config,
+ const gchar *name)
+{
+ g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), FALSE);
+
+ return g_hash_table_lookup_extended (config->hidden_items, name, NULL, NULL);
+}
+
+
+
+void
+sn_config_set_hidden (SnConfig *config,
+ const gchar *name,
+ gboolean hidden)
+{
+ gchar *name_copy;
+
+ g_return_if_fail (XFCE_IS_SN_CONFIG (config));
+
+ if (hidden)
+ {
+ name_copy = g_strdup (name);
+ g_hash_table_replace (config->hidden_items, name_copy, name_copy);
+ }
+ else
+ {
+ g_hash_table_remove (config->hidden_items, name);
+ }
+ g_object_notify (G_OBJECT (config), "hidden-items");
+ g_signal_emit (G_OBJECT (config), sn_config_signals[ITEM_LIST_CHANGED], 0);
+}
+
+
+
+GList*
+sn_config_get_known_items (SnConfig *config)
+{
+ g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), NULL);
+
+ return config->known_items;
+}
+
+
+
+void
+sn_config_add_known_item (SnConfig *config,
+ const gchar *name)
+{
+ GList *li;
+ gchar *name_copy;
+
+ g_return_if_fail (XFCE_IS_SN_CONFIG (config));
+
+ /* check if item is already known */
+ for(li = config->known_items; li != NULL; li = li->next)
+ if (g_strcmp0 (li->data, name) == 0)
+ return;
+
+ config->known_items = g_list_prepend (config->known_items, g_strdup (name));
+
+ if (config->mode_whitelist)
+ {
+ name_copy = g_strdup (name);
+ g_hash_table_replace (config->hidden_items, name_copy, name_copy);
+ g_object_notify (G_OBJECT (config), "hidden-items");
+ }
+
+ g_object_notify (G_OBJECT (config), "known-items");
+ g_signal_emit (G_OBJECT (config), sn_config_signals[ITEM_LIST_CHANGED], 0);
+}
+
+
+
+void
+sn_config_swap_known_items (SnConfig *config,
+ const gchar *name1,
+ const gchar *name2)
+{
+ GList *li, *li_tmp;
+
+ g_return_if_fail (XFCE_IS_SN_CONFIG (config));
+
+ for(li = config->known_items; li != NULL; li = li->next)
+ if (g_strcmp0 (li->data, name1) == 0)
+ break;
+
+ /* make sure that the list contains name1 followed by name2 */
+ if (li == NULL || li->next == NULL || g_strcmp0 (li->next->data, name2) != 0)
+ {
+ g_debug("Couldn't swap items: %s and %s", name1, name2);
+ return;
+ }
+
+ /* li_tmp will contain only the removed element (name2) */
+ li_tmp = li->next;
+ config->known_items = g_list_remove_link (config->known_items, li_tmp);
+
+ /* not strictly necessary (in testing the list contents was preserved)
+ * but searching for the index again should be safer */
+ for(li = config->known_items; li != NULL; li = li->next)
+ if (g_strcmp0 (li->data, name1) == 0)
+ break;
+
+ config->known_items = g_list_insert_before (config->known_items, li, li_tmp->data);
+ g_list_free (li_tmp);
+
+ g_object_notify (G_OBJECT (config), "known-items");
+ g_signal_emit (G_OBJECT (config), sn_config_signals[ITEM_LIST_CHANGED], 0);
+}
+
+
+
+static gboolean
+sn_config_items_clear_callback (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ GHashTable *collected_known_items = user_data;
+ return !g_hash_table_contains (collected_known_items, key);
+}
+
+
+
+gboolean
+sn_config_items_clear (SnConfig *config)
+{
+ GHashTable *collected_known_items;
+ gint initial_size;
+ GList *new_list, *li;
+
+ collected_known_items = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ g_signal_emit (G_OBJECT (config), sn_config_signals[COLLECT_KNOWN_ITEMS],
+ 0, collected_known_items);
+
+ initial_size = g_list_length (config->known_items);
+ new_list = NULL;
+ for (li = config->known_items; li != NULL; li = li->next)
+ {
+ if (g_hash_table_contains (collected_known_items, li->data))
+ {
+ new_list = g_list_append (new_list, g_strdup (li->data));
+ }
+ }
+ g_list_free_full (config->known_items, g_free);
+ config->known_items = new_list;
+
+ g_hash_table_foreach_remove (config->hidden_items,
+ sn_config_items_clear_callback,
+ collected_known_items);
+ g_hash_table_destroy (collected_known_items);
+
+ if (initial_size != g_list_length (config->known_items))
+ {
+ g_object_notify (G_OBJECT (config), "known-items");
+ g_object_notify (G_OBJECT (config), "hidden-items");
+ g_signal_emit (G_OBJECT (config), sn_config_signals[ITEM_LIST_CHANGED], 0);
+
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+
+
+SnConfig *
+sn_config_new (const gchar *property_base)
+{
+ SnConfig *config;
+ XfconfChannel *channel;
+ gchar *property;
+
+ config = g_object_new (XFCE_TYPE_SN_CONFIG, NULL);
+
+ if (xfconf_init (NULL))
+ {
+ channel = xfconf_channel_get ("xfce4-panel");
+
+ property = g_strconcat (property_base, "/icon-size", NULL);
+ xfconf_g_property_bind (channel, property, G_TYPE_INT, config, "icon-size");
+ g_free (property);
+
+ property = g_strconcat (property_base, "/single-row", NULL);
+ xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, config, "single-row");
+ g_free (property);
+
+ property = g_strconcat (property_base, "/square-icons", NULL);
+ xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, config, "square-icons");
+ g_free (property);
+
+ property = g_strconcat (property_base, "/mode-whitelist", NULL);
+ xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, config, "mode-whitelist");
+ g_free (property);
+
+ property = g_strconcat (property_base, "/known-items", NULL);
+ xfconf_g_property_bind (channel, property, XFCE_TYPE_SN_CONFIG_VALUE_ARRAY, config, "known-items");
+ g_free (property);
+
+ property = g_strconcat (property_base, "/hidden-items", NULL);
+ xfconf_g_property_bind (channel, property, XFCE_TYPE_SN_CONFIG_VALUE_ARRAY, config, "hidden-items");
+ g_free (property);
+
+ g_signal_emit (G_OBJECT (config), sn_config_signals[CONFIGURATION_CHANGED], 0);
+ }
+
+ return config;
+}
diff --git a/panel-plugin/sn-config.h b/panel-plugin/sn-config.h
new file mode 100644
index 0000000..30576b0
--- /dev/null
+++ b/panel-plugin/sn-config.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013 Andrzej Radecki <andrzejr at xfce.org>
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __SN_CONFIG_H__
+#define __SN_CONFIG_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SnConfigClass SnConfigClass;
+typedef struct _SnConfig SnConfig;
+
+#define XFCE_TYPE_SN_CONFIG (sn_config_get_type ())
+#define XFCE_SN_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_SN_CONFIG, SnConfig))
+#define XFCE_SN_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_SN_CONFIG, SnConfigClass))
+#define XFCE_IS_SN_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_SN_CONFIG))
+#define XFCE_IS_SN_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_SN_CONFIG))
+#define XFCE_SN_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_SN_CONFIG, SnConfigClass))
+
+GType sn_config_get_type (void) G_GNUC_CONST;
+
+SnConfig *sn_config_new (const gchar *property_base);
+
+void sn_config_set_orientation (SnConfig *config,
+ GtkOrientation panel_orientation,
+ GtkOrientation orientation);
+
+GtkOrientation sn_config_get_orientation (SnConfig *config);
+
+GtkOrientation sn_config_get_panel_orientation (SnConfig *config);
+
+void sn_config_set_size (SnConfig *config,
+ gint panel_size,
+ gint nrows);
+
+gint sn_config_get_nrows (SnConfig *config);
+
+gint sn_config_get_panel_size (SnConfig *config);
+
+gboolean sn_config_get_single_row (SnConfig *config);
+
+gboolean sn_config_get_square_icons (SnConfig *config);
+
+gint sn_config_get_icon_size (SnConfig *config);
+
+gboolean sn_config_is_hidden (SnConfig *config,
+ const gchar *name);
+
+void sn_config_set_hidden (SnConfig *config,
+ const gchar *name,
+ gboolean filtered);
+
+GList *sn_config_get_known_items (SnConfig *config);
+
+void sn_config_add_known_item (SnConfig *config,
+ const gchar *name);
+
+void sn_config_swap_known_items (SnConfig *config,
+ const gchar *name1,
+ const gchar *name2);
+
+gboolean sn_config_items_clear (SnConfig *config);
+
+G_END_DECLS
+
+#endif /* !__SN_CONFIG_H__ */
diff --git a/panel-plugin/sn-dialog.c b/panel-plugin/sn-dialog.c
new file mode 100644
index 0000000..20dad32
--- /dev/null
+++ b/panel-plugin/sn-dialog.c
@@ -0,0 +1,528 @@
+/*
+ * Copyright (c) 2012-2013 Andrzej Radecki <andrzejr at xfce.org>
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <libxfce4ui/libxfce4ui.h>
+#include <libxfce4util/libxfce4util.h>
+#include <libxfce4panel/xfce-panel-plugin.h>
+
+#include "sn-dialog.h"
+#include "sn-dialog-ui.h"
+
+
+
+static gboolean sn_dialog_build (SnDialog *dialog);
+
+static void sn_dialog_finalize (GObject *object);
+
+
+
+struct _SnDialogClass
+{
+ GObjectClass __parent__;
+};
+
+struct _SnDialog
+{
+ GObject __parent__;
+
+ GtkBuilder *builder;
+ GtkWidget *dialog;
+ GObject *store;
+ SnConfig *config;
+};
+
+G_DEFINE_TYPE (SnDialog, sn_dialog, G_TYPE_OBJECT)
+
+
+
+enum
+{
+ COLUMN_PIXBUF,
+ COLUMN_TITLE,
+ COLUMN_HIDDEN,
+ COLUMN_TIP
+};
+
+
+
+/* known applications to improve the icon and name */
+static const gchar *known_applications[][3] =
+{
+ /* application name, icon-name, understandable name */
+ { "nm-applet", "network-workgroup", "Network Manager Applet" },
+ { "blueman", "blueman", "Blueman Applet" },
+};
+
+
+
+static void
+sn_dialog_class_init (SnDialogClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = sn_dialog_finalize;
+}
+
+
+
+static void
+sn_dialog_init (SnDialog *dialog)
+{
+ dialog->builder = NULL;
+ dialog->dialog = NULL;
+ dialog->store = NULL;
+ dialog->config = NULL;
+}
+
+
+
+static void
+sn_dialog_add_item (SnDialog *dialog,
+ GdkPixbuf *pixbuf,
+ const gchar *name,
+ const gchar *title,
+ gboolean hidden)
+{
+ GtkTreeIter iter;
+
+ g_return_if_fail (XFCE_IS_SN_DIALOG (dialog));
+ g_return_if_fail (GTK_IS_LIST_STORE (dialog->store));
+ g_return_if_fail (name == NULL || g_utf8_validate (name, -1, NULL));
+
+ /* insert in the store */
+ gtk_list_store_append (GTK_LIST_STORE (dialog->store), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (dialog->store), &iter,
+ COLUMN_PIXBUF, pixbuf,
+ COLUMN_TITLE, title,
+ COLUMN_HIDDEN, hidden,
+ COLUMN_TIP, name,
+ -1);
+}
+
+
+
+static void
+sn_dialog_update_names (SnDialog *dialog)
+{
+ GList *li;
+ const gchar *name;
+ const gchar *title;
+ const gchar *icon_name;
+ GdkPixbuf *pixbuf;
+ guint i;
+
+ g_return_if_fail (XFCE_IS_SN_DIALOG (dialog));
+ g_return_if_fail (XFCE_IS_SN_CONFIG (dialog->config));
+ g_return_if_fail (GTK_IS_LIST_STORE (dialog->store));
+
+ for (li = sn_config_get_known_items (dialog->config); li != NULL; li = li->next)
+ {
+ name = li->data;
+ title = name;
+ icon_name = name;
+
+ /* check if we have a better name for the application */
+ for (i = 0; i < G_N_ELEMENTS (known_applications); i++)
+ {
+ if (strcmp (name, known_applications[i][0]) == 0)
+ {
+ icon_name = known_applications[i][1];
+ title = known_applications[i][2];
+ break;
+ }
+ }
+
+ pixbuf = xfce_panel_pixbuf_from_source (icon_name, NULL, 22);
+
+ /* insert item in the store */
+ sn_dialog_add_item (dialog, pixbuf, name, title,
+ sn_config_is_hidden (dialog->config, name));
+
+ if (pixbuf != NULL)
+ g_object_unref (G_OBJECT (pixbuf));
+ }
+}
+
+
+
+static void
+sn_dialog_selection_changed (GtkTreeSelection *selection,
+ SnDialog *dialog)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ gint *indices;
+ gint count = 0, position = -1, depth;
+ gboolean item_up_sensitive, item_down_sensitive;
+ GObject *object;
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ path = gtk_tree_model_get_path (model, &iter);
+ indices = gtk_tree_path_get_indices_with_depth (path, &depth);
+
+ if (indices != NULL && depth > 0)
+ position = indices[0];
+
+ count = gtk_tree_model_iter_n_children (model, NULL);
+
+ gtk_tree_path_free (path);
+ }
+
+ item_up_sensitive = position > 0;
+ item_down_sensitive = position + 1 < count;
+
+ object = gtk_builder_get_object (dialog->builder, "item-up");
+ if (GTK_IS_BUTTON (object))
+ gtk_widget_set_sensitive (GTK_WIDGET (object), item_up_sensitive);
+
+ object = gtk_builder_get_object (dialog->builder, "item-down");
+ if (GTK_IS_BUTTON (object))
+ gtk_widget_set_sensitive (GTK_WIDGET (object), item_down_sensitive);
+}
+
+
+
+static void
+sn_dialog_hidden_toggled (GtkCellRendererToggle *renderer,
+ const gchar *path_string,
+ SnDialog *dialog)
+{
+ GtkTreeIter iter;
+ gboolean hidden;
+ gchar *name;
+
+ g_return_if_fail (XFCE_IS_SN_DIALOG (dialog));
+ g_return_if_fail (XFCE_IS_SN_CONFIG (dialog->config));
+ g_return_if_fail (GTK_IS_LIST_STORE (dialog->store));
+
+ if (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (dialog->store), &iter, path_string))
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (dialog->store), &iter,
+ COLUMN_HIDDEN, &hidden,
+ COLUMN_TIP, &name, -1);
+
+ /* insert value (we need to update it) */
+ hidden = !hidden;
+
+ /* update box and store with new state */
+ sn_config_set_hidden (dialog->config, name, hidden);
+ gtk_list_store_set (GTK_LIST_STORE (dialog->store), &iter, COLUMN_HIDDEN, hidden, -1);
+
+ g_free (name);
+ }
+}
+
+
+
+static void
+sn_dialog_swap_rows (SnDialog *dialog,
+ GtkTreeIter *iter_prev,
+ GtkTreeIter *iter)
+{
+ GdkPixbuf *pixbuf1, *pixbuf2;
+ gchar *title1, *title2;
+ gboolean hidden1, hidden2;
+ gchar *tip1, *tip2;
+
+ g_return_if_fail (XFCE_IS_SN_DIALOG (dialog));
+ g_return_if_fail (XFCE_IS_SN_CONFIG (dialog->config));
+ g_return_if_fail (GTK_IS_LIST_STORE (dialog->store));
+
+ gtk_tree_model_get (GTK_TREE_MODEL (dialog->store), iter_prev,
+ COLUMN_PIXBUF, &pixbuf1,
+ COLUMN_TITLE, &title1,
+ COLUMN_HIDDEN, &hidden1,
+ COLUMN_TIP, &tip1, -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (dialog->store), iter,
+ COLUMN_PIXBUF, &pixbuf2,
+ COLUMN_TITLE, &title2,
+ COLUMN_HIDDEN, &hidden2,
+ COLUMN_TIP, &tip2, -1);
+ gtk_list_store_set (GTK_LIST_STORE (dialog->store), iter_prev,
+ COLUMN_PIXBUF, pixbuf2,
+ COLUMN_TITLE, title2,
+ COLUMN_HIDDEN, hidden2,
+ COLUMN_TIP, tip2, -1);
+ gtk_list_store_set (GTK_LIST_STORE (dialog->store), iter,
+ COLUMN_PIXBUF, pixbuf1,
+ COLUMN_TITLE, title1,
+ COLUMN_HIDDEN, hidden1,
+ COLUMN_TIP, tip1, -1);
+
+ /* do a matching operation on SnConfig */
+ sn_config_swap_known_items (dialog->config, tip1, tip2);
+}
+
+
+
+static gboolean
+sn_dialog_iter_equal (GtkTreeIter *iter1,
+ GtkTreeIter *iter2)
+{
+ return (iter1->user_data == iter2->user_data &&
+ iter1->user_data2 == iter2->user_data2 &&
+ iter1->user_data3 == iter2->user_data3);
+}
+
+
+
+static void
+sn_dialog_item_up_clicked (GtkWidget *button,
+ SnDialog *dialog)
+{
+ GObject *treeview;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter, iter_prev, iter_tmp;
+
+ g_return_if_fail (XFCE_IS_SN_DIALOG (dialog));
+ g_return_if_fail (GTK_IS_LIST_STORE (dialog->store));
+
+ treeview = gtk_builder_get_object (dialog->builder, "items-treeview");
+ g_return_if_fail (GTK_IS_TREE_VIEW (treeview));
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+ if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
+ return;
+
+ /* gtk_tree_model_iter_previous available from Gtk3 */
+ /* so we have to search for it starting from the first iter */
+ if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->store), &iter_prev))
+ return;
+
+ iter_tmp = iter_prev;
+ while (!sn_dialog_iter_equal (&iter_tmp, &iter))
+ {
+ iter_prev = iter_tmp;
+ if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (dialog->store), &iter_tmp))
+ return;
+ }
+
+ sn_dialog_swap_rows (dialog, &iter_prev, &iter);
+ gtk_tree_selection_select_iter (selection, &iter_prev);
+}
+
+
+
+static void
+sn_dialog_item_down_clicked (GtkWidget *button,
+ SnDialog *dialog)
+{
+ GObject *treeview;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter, iter_next;
+
+ g_return_if_fail (XFCE_IS_SN_DIALOG (dialog));
+
+ treeview = gtk_builder_get_object (dialog->builder, "items-treeview");
+ g_return_if_fail (GTK_IS_TREE_VIEW (treeview));
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+ if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
+ return;
+
+ iter_next = iter;
+ if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (dialog->store), &iter_next))
+ return;
+
+ sn_dialog_swap_rows (dialog, &iter, &iter_next);
+ gtk_tree_selection_select_iter (selection, &iter_next);
+}
+
+
+
+static void
+sn_dialog_clear_clicked (GtkWidget *button,
+ SnDialog *dialog)
+{
+ g_return_if_fail (XFCE_IS_SN_DIALOG (dialog));
+
+ if (xfce_dialog_confirm (GTK_WINDOW (gtk_widget_get_toplevel (button)),
+ "edit-clear", _("Clear"), NULL,
+ _("Are you sure you want to clear the list of "
+ "known items?")))
+ {
+ if (sn_config_items_clear (dialog->config))
+ {
+ gtk_list_store_clear (GTK_LIST_STORE (dialog->store));
+ sn_dialog_update_names (dialog);
+ }
+ }
+}
+
+
+
+static void
+sn_dialog_dialog_unref (SnDialog *dialog)
+{
+ dialog->dialog = NULL;
+ g_object_unref (dialog);
+}
+
+
+
+static gboolean
+sn_dialog_build (SnDialog *dialog)
+{
+ GObject *object;
+ GError *error = NULL;
+ GtkTreeSelection *selection;
+
+ if (xfce_titled_dialog_get_type () == 0)
+ return FALSE;
+
+ dialog->builder = gtk_builder_new ();
+
+ /* load the builder data into the object */
+ if (gtk_builder_add_from_string (dialog->builder, sn_dialog_ui,
+ sn_dialog_ui_length, &error))
+ {
+ object = gtk_builder_get_object (dialog->builder, "dialog");
+ g_return_val_if_fail (XFCE_IS_TITLED_DIALOG (object), FALSE);
+ dialog->dialog = GTK_WIDGET (object);
+
+ object = gtk_builder_get_object (dialog->builder, "close-button");
+ g_return_val_if_fail (GTK_IS_BUTTON (object), FALSE);
+ g_signal_connect_swapped (G_OBJECT (object), "clicked",
+ G_CALLBACK (gtk_widget_destroy),
+ dialog->dialog);
+
+ object = gtk_builder_get_object (dialog->builder, "spinbutton-icon-size");
+ g_return_val_if_fail (GTK_IS_WIDGET (object), FALSE);
+ g_object_bind_property (G_OBJECT (dialog->config), "icon-size",
+ G_OBJECT (gtk_spin_button_get_adjustment
+ (GTK_SPIN_BUTTON (object))), "value",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ object = gtk_builder_get_object (dialog->builder, "checkbutton-single-row");
+ g_return_val_if_fail (GTK_IS_WIDGET (object), FALSE);
+ g_object_bind_property (G_OBJECT (dialog->config), "single-row",
+ G_OBJECT (object), "active",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ object = gtk_builder_get_object (dialog->builder, "checkbutton-square-icons");
+ g_return_val_if_fail (GTK_IS_WIDGET (object), FALSE);
+ g_object_bind_property (G_OBJECT (dialog->config), "square-icons",
+ G_OBJECT (object), "active",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ object = gtk_builder_get_object (dialog->builder, "checkbutton-whitelist");
+ g_return_val_if_fail (GTK_IS_WIDGET (object), FALSE);
+ g_object_bind_property (G_OBJECT (dialog->config), "mode-whitelist",
+ G_OBJECT (object), "active",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ dialog->store = gtk_builder_get_object (dialog->builder, "items-store");
+ g_return_val_if_fail (GTK_IS_LIST_STORE (dialog->store), FALSE);
+ sn_dialog_update_names (dialog);
+
+ object = gtk_builder_get_object (dialog->builder, "items-treeview");
+ g_return_val_if_fail (GTK_IS_TREE_VIEW (object), FALSE);
+ gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (object), COLUMN_TIP);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (object));
+ g_signal_connect (G_OBJECT (selection), "changed",
+ G_CALLBACK (sn_dialog_selection_changed), dialog);
+ sn_dialog_selection_changed (selection, dialog);
+
+ object = gtk_builder_get_object (dialog->builder, "hidden-toggle");
+ g_return_val_if_fail (GTK_IS_CELL_RENDERER_TOGGLE (object), FALSE);
+ g_signal_connect (G_OBJECT (object), "toggled",
+ G_CALLBACK (sn_dialog_hidden_toggled), dialog);
+
+ object = gtk_builder_get_object (dialog->builder, "item-up");
+ g_return_val_if_fail (GTK_IS_BUTTON (object), FALSE);
+ g_signal_connect (G_OBJECT (object), "clicked",
+ G_CALLBACK (sn_dialog_item_up_clicked), dialog);
+
+ object = gtk_builder_get_object (dialog->builder, "item-down");
+ g_return_val_if_fail (GTK_IS_BUTTON (object), FALSE);
+ g_signal_connect (G_OBJECT (object), "clicked",
+ G_CALLBACK (sn_dialog_item_down_clicked), dialog);
+
+ object = gtk_builder_get_object (dialog->builder, "items-clear");
+ g_return_val_if_fail (GTK_IS_BUTTON (object), FALSE);
+ g_signal_connect (G_OBJECT (object), "clicked",
+ G_CALLBACK (sn_dialog_clear_clicked), dialog);
+
+ g_object_weak_ref (G_OBJECT (dialog->dialog),
+ (GWeakNotify)sn_dialog_dialog_unref, dialog);
+ return TRUE;
+ }
+ else
+ {
+ g_critical ("Failed to construct the builder: %s.",
+ error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+}
+
+
+
+SnDialog *
+sn_dialog_new (SnConfig *config,
+ GdkScreen *screen)
+{
+ SnDialog *dialog;
+
+ g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), NULL);
+
+ dialog = g_object_new (XFCE_TYPE_SN_DIALOG, NULL);
+ dialog->config = config;
+
+ if (sn_dialog_build (dialog))
+ {
+ gtk_widget_show (dialog->dialog);
+ gtk_window_set_screen (GTK_WINDOW (dialog->dialog), screen);
+ return dialog;
+ }
+ else
+ {
+ g_object_unref (dialog);
+ return NULL;
+ }
+}
+
+
+
+static void
+sn_dialog_finalize (GObject *object)
+{
+ SnDialog *dialog = XFCE_SN_DIALOG (object);
+
+ if (dialog->dialog != NULL)
+ gtk_widget_destroy (dialog->dialog);
+
+ if (dialog->builder != NULL)
+ g_object_unref (dialog->builder);
+
+ G_OBJECT_CLASS (sn_dialog_parent_class)->finalize (object);
+}
diff --git a/panel-plugin/sn-dialog.glade b/panel-plugin/sn-dialog.glade
new file mode 100644
index 0000000..d9cc5db
--- /dev/null
+++ b/panel-plugin/sn-dialog.glade
@@ -0,0 +1,414 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <!-- interface-requires libxfce4ui-2 -->
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="XfceTitledDialog" id="dialog">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Status Notifier Items</property>
+ <property name="default_width">425</property>
+ <property name="default_height">525</property>
+ <property name="icon_name">gtk-properties</property>
+ <property name="type_hint">normal</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">horizontal</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="close-button">
+ <property name="label">gtk-close</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_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkFrame" id="frame3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Maximum icon size (px):</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">spinbutton-icon-size</property>
+ <property name="xalign">0</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="spinbutton-icon-size">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">size-adjustment</property>
+ <property name="numeric">True</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">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton-single-row">
+ <property name="label" translatable="yes">Arrange items in a single row</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">If enabled, ensure that the items are laid out in a single row or column.</property>
+ <property name="use_action_appearance">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton-square-icons">
+ <property name="label" translatable="yes">Square icons</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Item buttons will take a square when it's possible.</property>
+ <property name="use_action_appearance">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Appearance</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton-whitelist">
+ <property name="label" translatable="yes">Hide items by default</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">When enabled, all new items will be marked as "Hidden".</property>
+ <property name="use_action_appearance">False</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="GtkBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">horizontal</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="items-treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">items-store</property>
+ <property name="headers_clickable">False</property>
+ <property name="rules_hint">True</property>
+ <property name="enable_search">False</property>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn-icon">
+ <property name="min_width">24</property>
+ <child>
+ <object class="GtkCellRendererPixbuf" id="cellrendererpixbuf1"/>
+ <attributes>
+ <attribute name="pixbuf">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn-name">
+ <property name="title" translatable="yes">Item</property>
+ <property name="expand">True</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn-hidden">
+ <property name="title" translatable="yes">Hidden</property>
+ <child>
+ <object class="GtkCellRendererToggle" id="hidden-toggle"/>
+ <attributes>
+ <attribute name="active">2</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="vbox4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkButton" id="item-up">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Move the selected item one row up.</property>
+ <property name="use_action_appearance">False</property>
+ <child>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-go-up</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="item-down">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Move the selected item one row down.</property>
+ <property name="use_action_appearance">False</property>
+ <child>
+ <object class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-go-down</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">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">horizontal</property>
+ <property name="layout_style">start</property>
+ <child>
+ <object class="GtkButton" id="items-clear">
+ <property name="label" translatable="yes">C_lear Known Items</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Resets the list of items and their visibility settings.</property>
+ <property name="use_action_appearance">False</property>
+ <property name="image">image1</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Known Items</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </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>
+ <action-widgets>
+ <action-widget response="0">close-button</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-clear</property>
+ </object>
+ <object class="GtkListStore" id="items-store">
+ <columns>
+ <!-- column-name icon -->
+ <column type="GdkPixbuf"/>
+ <!-- column-name title -->
+ <column type="gchararray"/>
+ <!-- column-name hidden -->
+ <column type="gboolean"/>
+ <!-- column-name tooltip -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkAdjustment" id="size-adjustment">
+ <property name="lower">12</property>
+ <property name="upper">64</property>
+ <property name="value">22</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">2</property>
+ </object>
+</interface>
diff --git a/panel-plugin/sn-dialog.h b/panel-plugin/sn-dialog.h
new file mode 100644
index 0000000..9416a35
--- /dev/null
+++ b/panel-plugin/sn-dialog.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012-2013 Andrzej Radecki <andrzejr at xfce.org>
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __SN_DIALOG_H__
+#define __SN_DIALOG_H__
+
+#include <gtk/gtk.h>
+
+#include "sn-config.h"
+
+G_BEGIN_DECLS
+
+typedef struct _SnDialogClass SnDialogClass;
+typedef struct _SnDialog SnDialog;
+
+#define XFCE_TYPE_SN_DIALOG (sn_dialog_get_type ())
+#define XFCE_SN_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_SN_DIALOG, SnDialog))
+#define XFCE_SN_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_SN_DIALOG, SnDialogClass))
+#define XFCE_IS_SN_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_SN_DIALOG))
+#define XFCE_IS_SN_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_SN_DIALOG))
+#define XFCE_SN_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_SN_DIALOG, SnDialogClass))
+
+GType sn_dialog_get_type (void) G_GNUC_CONST;
+
+SnDialog *sn_dialog_new (SnConfig *config,
+ GdkScreen *screen);
+
+G_END_DECLS
+
+#endif /* !__SN_DIALOG_H__ */
diff --git a/panel-plugin/sn-icon-box.c b/panel-plugin/sn-icon-box.c
new file mode 100644
index 0000000..1db9a67
--- /dev/null
+++ b/panel-plugin/sn-icon-box.c
@@ -0,0 +1,370 @@
+/*
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <libxfce4panel/libxfce4panel.h>
+
+#include "sn-icon-box.h"
+
+
+
+static void sn_icon_box_finalize (GObject *object);
+
+static void sn_icon_box_icon_changed (GtkWidget *widget);
+
+static void sn_icon_box_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width);
+
+static void sn_icon_box_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height);
+
+static void sn_icon_box_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
+
+static void sn_icon_box_remove (GtkContainer *container,
+ GtkWidget *child);
+
+static GType sn_icon_box_child_type (GtkContainer *container);
+
+static void sn_icon_box_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data);
+
+
+struct _SnIconBoxClass
+{
+ GtkContainerClass __parent__;
+};
+
+struct _SnIconBox
+{
+ GtkContainer __parent__;
+
+ SnItem *item;
+ SnConfig *config;
+
+ GtkWidget *icon;
+ GtkWidget *overlay;
+
+ guint item_icon_changed_handler;
+ guint config_notify_icon_size_handler;
+};
+
+G_DEFINE_TYPE (SnIconBox, sn_icon_box, GTK_TYPE_CONTAINER)
+
+
+
+static void
+sn_icon_box_class_init (SnIconBoxClass *klass)
+{
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ GtkContainerClass *container_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = sn_icon_box_finalize;
+
+ widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->get_preferred_width = sn_icon_box_get_preferred_width;
+ widget_class->get_preferred_height = sn_icon_box_get_preferred_height;
+ widget_class->size_allocate = sn_icon_box_size_allocate;
+
+ container_class = GTK_CONTAINER_CLASS (klass);
+ container_class->remove = sn_icon_box_remove;
+ container_class->child_type = sn_icon_box_child_type;
+ container_class->forall = sn_icon_box_forall;
+}
+
+
+
+static void
+sn_icon_box_init (SnIconBox *box)
+{
+ gtk_widget_set_has_window (GTK_WIDGET (box), FALSE);
+ gtk_widget_set_can_focus (GTK_WIDGET (box), FALSE);
+ gtk_widget_set_can_default (GTK_WIDGET (box), FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 0);
+ gtk_widget_set_name (GTK_WIDGET (box), "sn-button-box");
+
+ box->item = NULL;
+ box->config = NULL;
+
+ box->icon = NULL;
+ box->overlay = NULL;
+
+ box->item_icon_changed_handler = 0;
+ box->config_notify_icon_size_handler = 0;
+}
+
+
+
+static GType
+sn_icon_box_child_type (GtkContainer *container)
+{
+ return GTK_TYPE_WIDGET;
+}
+
+
+
+static void
+sn_icon_box_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data)
+{
+ SnIconBox *box = XFCE_SN_ICON_BOX (container);
+
+ /* z-order depends on forall order */
+
+ if (box->overlay != NULL)
+ (*callback) (box->overlay, callback_data);
+
+ if (box->icon != NULL)
+ (*callback) (box->icon, callback_data);
+}
+
+
+
+static void
+sn_icon_box_remove (GtkContainer *container,
+ GtkWidget *child)
+{
+ SnIconBox *box;
+
+ g_return_if_fail (XFCE_IS_SN_ICON_BOX (container));
+
+ box = XFCE_SN_ICON_BOX (container);
+
+ if (child == box->icon)
+ {
+ gtk_widget_unparent (child);
+ box->icon = NULL;
+ }
+ else if (child == box->overlay)
+ {
+ gtk_widget_unparent (child);
+ box->overlay = NULL;
+ }
+
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+}
+
+
+
+GtkWidget *
+sn_icon_box_new (SnItem *item,
+ SnConfig *config)
+{
+ SnIconBox *box = g_object_new (XFCE_TYPE_SN_ICON_BOX, NULL);
+
+ g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), NULL);
+
+ box->item = item;
+ box->config = config;
+
+ box->icon = gtk_image_new ();
+ gtk_widget_set_parent (box->icon, GTK_WIDGET (box));
+ gtk_widget_show (box->icon);
+
+ box->overlay = gtk_image_new ();
+ gtk_widget_set_parent (box->overlay, GTK_WIDGET (box));
+ gtk_widget_show (box->overlay);
+
+ box->config_notify_icon_size_handler =
+ g_signal_connect_swapped (config, "notify::icon-size",
+ G_CALLBACK (sn_icon_box_icon_changed), box);
+ box->item_icon_changed_handler =
+ g_signal_connect_swapped (item, "icon-changed",
+ G_CALLBACK (sn_icon_box_icon_changed), box);
+ sn_icon_box_icon_changed (GTK_WIDGET (box));
+
+ return GTK_WIDGET (box);
+}
+
+
+
+static void
+sn_icon_box_finalize (GObject *object)
+{
+ SnIconBox *box = XFCE_SN_ICON_BOX (object);
+
+ if (box->item_icon_changed_handler != 0)
+ g_signal_handler_disconnect (box->item, box->item_icon_changed_handler);
+ if (box->config_notify_icon_size_handler != 0)
+ g_signal_handler_disconnect (box->config, box->config_notify_icon_size_handler);
+
+ G_OBJECT_CLASS (sn_icon_box_parent_class)->finalize (object);
+}
+
+
+
+static void
+sn_icon_box_apply_icon (GtkWidget *image,
+ GtkIconTheme *icon_theme,
+ const gchar *icon_name,
+ GdkPixbuf *icon_pixbuf,
+ gint icon_size)
+{
+ GtkIconInfo *icon_info;
+ gboolean use_pixbuf = TRUE;
+ gint width, height;
+
+ gtk_image_clear (GTK_IMAGE (image));
+
+ if (icon_name != NULL)
+ {
+ icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, 16, 0);
+ if (icon_info != NULL)
+ {
+ gtk_image_set_from_icon_name (GTK_IMAGE (image), icon_name, GTK_ICON_SIZE_BUTTON);
+ g_object_unref (icon_info);
+ use_pixbuf = FALSE;
+ }
+ }
+
+ if (use_pixbuf && icon_pixbuf != NULL)
+ {
+ width = gdk_pixbuf_get_width (icon_pixbuf);
+ height = gdk_pixbuf_get_height (icon_pixbuf);
+ if (width > icon_size || height > icon_size)
+ {
+ /* scale pixbuf */
+ if (width > height)
+ {
+ height = icon_size * height / width;
+ width = icon_size;
+ }
+ else
+ {
+ width = icon_size * width / height;
+ height = icon_size;
+ }
+ icon_pixbuf = gdk_pixbuf_scale_simple (icon_pixbuf,
+ width, height, GDK_INTERP_BILINEAR);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (image), icon_pixbuf);
+ g_object_unref (icon_pixbuf);
+ }
+ else
+ {
+ gtk_image_set_from_pixbuf (GTK_IMAGE (image), icon_pixbuf);
+ }
+ }
+
+ gtk_image_set_pixel_size (GTK_IMAGE (image), icon_size);
+}
+
+
+
+static void
+sn_icon_box_icon_changed (GtkWidget *widget)
+{
+ SnIconBox *box;
+ const gchar *icon_name;
+ GdkPixbuf *icon_pixbuf;
+ const gchar *overlay_icon_name;
+ GdkPixbuf *overlay_icon_pixbuf;
+ GtkIconTheme *icon_theme;
+ gint icon_size;
+
+ box = XFCE_SN_ICON_BOX (widget);
+ icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (widget)));
+ icon_size = sn_config_get_icon_size (box->config);
+
+ sn_item_get_icon (box->item,
+ &icon_name, &icon_pixbuf,
+ &overlay_icon_name, &overlay_icon_pixbuf);
+
+ sn_icon_box_apply_icon (box->icon, icon_theme,
+ icon_name, icon_pixbuf, icon_size);
+ sn_icon_box_apply_icon (box->overlay, icon_theme,
+ overlay_icon_name, overlay_icon_pixbuf, icon_size);
+}
+
+
+
+static void
+sn_icon_box_get_preferred_size (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ SnIconBox *box = XFCE_SN_ICON_BOX (widget);
+ gint icon_size;
+ GtkRequisition child_req;
+
+ icon_size = sn_config_get_icon_size (box->config);
+
+ if (box->icon != NULL)
+ gtk_widget_get_preferred_size (box->icon, NULL, &child_req);
+
+ if (box->overlay != NULL)
+ gtk_widget_get_preferred_size (box->overlay, NULL, &child_req);
+
+ if (minimum_size != NULL)
+ *minimum_size = icon_size;
+
+ if (natural_size != NULL)
+ *natural_size = icon_size;
+}
+
+
+
+static void
+sn_icon_box_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ sn_icon_box_get_preferred_size (widget, minimum_width, natural_width);
+}
+
+
+
+static void
+sn_icon_box_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ sn_icon_box_get_preferred_size (widget, minimum_height, natural_height);
+}
+
+
+
+static void
+sn_icon_box_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ SnIconBox *box = XFCE_SN_ICON_BOX (widget);
+
+ gtk_widget_set_allocation (widget, allocation);
+
+ if (box->icon != NULL)
+ gtk_widget_size_allocate (box->icon, allocation);
+
+ if (box->overlay != NULL)
+ gtk_widget_size_allocate (box->overlay, allocation);
+}
diff --git a/panel-plugin/sn-icon-box.h b/panel-plugin/sn-icon-box.h
new file mode 100644
index 0000000..cb42a05
--- /dev/null
+++ b/panel-plugin/sn-icon-box.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __SN_ICON_BOX_H__
+#define __SN_ICON_BOX_H__
+
+#include <gtk/gtk.h>
+
+#include "sn-config.h"
+#include "sn-item.h"
+
+G_BEGIN_DECLS
+
+typedef struct _SnIconBoxClass SnIconBoxClass;
+typedef struct _SnIconBox SnIconBox;
+
+#define XFCE_TYPE_SN_ICON_BOX (sn_icon_box_get_type ())
+#define XFCE_SN_ICON_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_SN_ICON_BOX, SnIconBox))
+#define XFCE_SN_ICON_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_SN_ICON_BOX, SnIconBoxClass))
+#define XFCE_IS_SN_ICON_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_SN_ICON_BOX))
+#define XFCE_IS_SN_ICON_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_SN_ICON_BOX))
+#define XFCE_SN_ICON_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_SN_ICON_BOX, SnIconBoxClass))
+
+GType sn_icon_box_get_type (void) G_GNUC_CONST;
+
+GtkWidget *sn_icon_box_new (SnItem *item,
+ SnConfig *config);
+
+G_END_DECLS
+
+#endif /* !__SN_ICON_BOX_H__ */
diff --git a/panel-plugin/sn-item.c b/panel-plugin/sn-item.c
new file mode 100644
index 0000000..7aae308
--- /dev/null
+++ b/panel-plugin/sn-item.c
@@ -0,0 +1,1084 @@
+/*
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <gio/gio.h>
+#include <libdbusmenu-gtk/dbusmenu-gtk.h>
+
+#include "sn-item.h"
+
+
+
+static void sn_item_finalize (GObject *object);
+
+static void sn_item_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void sn_item_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+static void sn_item_signal_received (GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data);
+
+static void sn_item_get_all_properties_result (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data);
+
+
+
+struct _SnItemClass
+{
+ GObjectClass __parent__;
+};
+
+struct _SnItem
+{
+ GObject __parent__;
+
+ gboolean started;
+ gboolean initialized;
+ gboolean exposed;
+
+ GCancellable *cancellable;
+ GDBusProxy *item_proxy;
+ GDBusProxy *properties_proxy;
+
+ gchar *bus_name;
+ gchar *object_path;
+ gchar *service;
+ gchar *key;
+
+ gchar *id;
+ gchar *title;
+ gchar *tooltip_title;
+ gchar *tooltip_subtitle;
+ gchar *icon_desc;
+ gchar *attention_desc;
+
+ gchar *icon_name;
+ gchar *attention_icon_name;
+ gchar *overlay_icon_name;
+ GdkPixbuf *icon_pixbuf;
+ GdkPixbuf *attention_icon_pixbuf;
+ GdkPixbuf *overlay_icon_pixbuf;
+ gchar *icon_theme_path;
+
+ gboolean item_is_menu;
+ gchar *menu_object_path;
+ GtkWidget *cached_menu;
+};
+
+G_DEFINE_TYPE (SnItem, sn_item, G_TYPE_OBJECT)
+
+
+
+enum
+{
+ PROP_0,
+ PROP_BUS_NAME,
+ PROP_OBJECT_PATH,
+ PROP_SERVICE,
+ PROP_KEY,
+ PROP_EXPOSED
+};
+
+enum
+{
+ EXPOSE,
+ SEAL,
+ FINISH,
+ TOOLTIP_CHANGED,
+ ICON_CHANGED,
+ MENU_CHANGED,
+ LAST_SIGNAL
+};
+
+static guint sn_item_signals[LAST_SIGNAL] = { 0, };
+
+
+
+typedef struct
+{
+ GDBusConnection *connection;
+ guint handler;
+}
+SubscriptionContext;
+
+
+
+#define free_error_and_return_if_cancelled(error) \
+if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) \
+ { \
+ g_error_free (error); \
+ return; \
+ } \
+if (error != NULL) \
+ g_error_free (error);
+
+
+
+#define return_and_finish_if_true(condition) \
+if (condition) \
+ { \
+ g_signal_emit (G_OBJECT (item), sn_item_signals[FINISH], 0); \
+ return; \
+ }
+
+
+
+static void
+sn_item_class_init (SnItemClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = sn_item_finalize;
+ object_class->get_property = sn_item_get_property;
+ object_class->set_property = sn_item_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_BUS_NAME,
+ g_param_spec_string ("bus-name", NULL, NULL, NULL,
+ G_PARAM_WRITABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_OBJECT_PATH,
+ g_param_spec_string ("object-path", NULL, NULL, NULL,
+ G_PARAM_WRITABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_SERVICE,
+ g_param_spec_string ("service", NULL, NULL, NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_KEY,
+ g_param_spec_string ("key", NULL, NULL, NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_EXPOSED,
+ g_param_spec_boolean ("exposed", NULL, NULL, FALSE,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ sn_item_signals[EXPOSE] =
+ g_signal_new (g_intern_static_string ("expose"),
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ sn_item_signals[SEAL] =
+ g_signal_new (g_intern_static_string ("seal"),
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ sn_item_signals[FINISH] =
+ g_signal_new (g_intern_static_string ("finish"),
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ sn_item_signals[TOOLTIP_CHANGED] =
+ g_signal_new (g_intern_static_string ("tooltip-changed"),
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ sn_item_signals[ICON_CHANGED] =
+ g_signal_new (g_intern_static_string ("icon-changed"),
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ sn_item_signals[MENU_CHANGED] =
+ g_signal_new (g_intern_static_string ("menu-changed"),
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
+
+
+
+static void
+sn_item_init (SnItem *item)
+{
+ item->started = FALSE;
+ item->initialized = FALSE;
+ item->exposed = TRUE;
+
+ item->cancellable = g_cancellable_new ();
+ item->item_proxy = NULL;
+ item->properties_proxy = NULL;
+
+ item->bus_name = NULL;
+ item->object_path = NULL;
+ item->service = NULL;
+ item->key = NULL;
+
+ item->id = NULL;
+ item->title = NULL;
+ item->tooltip_title = NULL;
+ item->tooltip_subtitle = NULL;
+ item->icon_desc = NULL;
+ item->attention_desc = NULL;
+
+ item->icon_name = NULL;
+ item->attention_icon_name = NULL;
+ item->overlay_icon_name = NULL;
+ item->icon_pixbuf = NULL;
+ item->attention_icon_pixbuf = NULL;
+ item->overlay_icon_pixbuf = NULL;
+ item->icon_theme_path = NULL;
+
+ /* Ubuntu indicators don't support activate action and
+ don't provide this option so it's enabled by default. */
+ item->item_is_menu = TRUE;
+ item->menu_object_path = NULL;
+ item->cached_menu = NULL;
+}
+
+
+
+static void
+sn_item_finalize (GObject *object)
+{
+ SnItem *item = XFCE_SN_ITEM (object);
+
+ g_object_unref (item->cancellable);
+
+ if (item->properties_proxy != NULL)
+ g_object_unref (item->properties_proxy);
+
+ if (item->item_proxy != NULL)
+ g_object_unref (item->item_proxy);
+
+ g_free (item->bus_name);
+ g_free (item->object_path);
+ g_free (item->service);
+ g_free (item->key);
+
+ g_free (item->id);
+ g_free (item->title);
+ g_free (item->tooltip_title);
+ g_free (item->tooltip_subtitle);
+ g_free (item->icon_desc);
+ g_free (item->attention_desc);
+
+ g_free (item->icon_name);
+ g_free (item->attention_icon_name);
+ g_free (item->overlay_icon_name);
+ g_free (item->icon_theme_path);
+
+ if (item->icon_pixbuf != NULL)
+ g_object_unref (item->icon_pixbuf);
+ if (item->attention_icon_pixbuf != NULL)
+ g_object_unref (item->attention_icon_pixbuf);
+ if (item->overlay_icon_pixbuf != NULL)
+ g_object_unref (item->overlay_icon_pixbuf);
+
+ g_free (item->menu_object_path);
+ if (item->cached_menu != NULL)
+ gtk_widget_destroy (item->cached_menu);
+
+ G_OBJECT_CLASS (sn_item_parent_class)->finalize (object);
+}
+
+
+
+static void
+sn_item_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ SnItem *item = XFCE_SN_ITEM (object);
+
+ switch (prop_id)
+ {
+ case PROP_SERVICE:
+ g_value_set_string (value, item->service);
+ break;
+
+ case PROP_KEY:
+ g_value_set_string (value, item->key);
+ break;
+
+ case PROP_EXPOSED:
+ g_value_set_boolean (value, item->exposed);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+
+static void
+sn_item_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ SnItem *item = XFCE_SN_ITEM (object);
+
+ switch (prop_id)
+ {
+ case PROP_BUS_NAME:
+ g_free (item->bus_name);
+ item->bus_name = g_value_dup_string (value);
+ break;
+
+ case PROP_OBJECT_PATH:
+ g_free (item->object_path);
+ item->object_path = g_value_dup_string (value);
+ break;
+
+ case PROP_SERVICE:
+ g_free (item->service);
+ item->service = g_value_dup_string (value);
+ break;
+
+ case PROP_KEY:
+ g_free (item->key);
+ item->key = g_value_dup_string (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+
+static void
+sn_item_subscription_context_ubsubscribe (gpointer data,
+ GObject *where_the_object_was)
+{
+ SubscriptionContext *context = data;
+
+ g_dbus_connection_signal_unsubscribe (context->connection, context->handler);
+ g_free (context);
+}
+
+
+
+static void
+sn_item_name_owner_changed (GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ SnItem *item = user_data;
+ gchar *new_owner;
+
+ g_variant_get (parameters, "(sss)", NULL, NULL, &new_owner);
+ return_and_finish_if_true (new_owner == NULL || strlen (new_owner) == 0);
+}
+
+
+
+static void
+sn_item_properties_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ SnItem *item = user_data;
+ GError *error = NULL;
+
+ item->properties_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+ free_error_and_return_if_cancelled (error);
+ return_and_finish_if_true (item->properties_proxy == NULL);
+
+ sn_item_invalidate (item);
+}
+
+
+
+static void
+sn_item_item_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ SnItem *item = user_data;
+ GError *error = NULL;
+ SubscriptionContext *context;
+
+ item->item_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+ free_error_and_return_if_cancelled (error);
+ return_and_finish_if_true (item->item_proxy == NULL);
+
+ context = g_new0 (SubscriptionContext, 1);
+ context->connection = g_dbus_proxy_get_connection (item->item_proxy);
+ context->handler =
+ g_dbus_connection_signal_subscribe (g_dbus_proxy_get_connection (item->item_proxy),
+ "org.freedesktop.DBus",
+ "org.freedesktop.DBus",
+ "NameOwnerChanged",
+ "/org/freedesktop/DBus",
+ g_dbus_proxy_get_name (item->item_proxy),
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ sn_item_name_owner_changed,
+ item, NULL);
+ g_object_weak_ref (G_OBJECT (item->item_proxy),
+ sn_item_subscription_context_ubsubscribe, context);
+
+ g_signal_connect (item->item_proxy, "g-signal",
+ G_CALLBACK (sn_item_signal_received), item);
+
+ g_dbus_proxy_new (g_dbus_proxy_get_connection (item->item_proxy),
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ item->bus_name,
+ item->object_path,
+ "org.freedesktop.DBus.Properties",
+ item->cancellable,
+ sn_item_properties_callback,
+ item);
+}
+
+
+
+static gboolean
+sn_item_start_failed (gpointer user_data)
+{
+ SnItem *item = user_data;
+
+ /* start is failed, emit the signel in next loop iteration */
+ g_signal_emit (G_OBJECT (item), sn_item_signals[FINISH], 0);
+
+ return G_SOURCE_REMOVE;
+}
+
+
+
+void
+sn_item_start (SnItem *item)
+{
+ g_return_if_fail (XFCE_IS_SN_ITEM (item));
+ g_return_if_fail (!item->started);
+
+ if (!g_dbus_is_name (item->bus_name))
+ {
+ g_idle_add (sn_item_start_failed, item);
+ return;
+ }
+
+ item->started = TRUE;
+ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ item->bus_name,
+ item->object_path,
+ "org.kde.StatusNotifierItem",
+ item->cancellable,
+ sn_item_item_callback,
+ item);
+}
+
+
+
+void
+sn_item_invalidate (SnItem *item)
+{
+ g_return_if_fail (XFCE_IS_SN_ITEM (item));
+ g_return_if_fail (item->properties_proxy != NULL);
+
+ g_dbus_proxy_call (item->properties_proxy,
+ "GetAll",
+ g_variant_new ("(s)", "org.kde.StatusNotifierItem"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ item->cancellable,
+ sn_item_get_all_properties_result,
+ item);
+}
+
+
+
+static gboolean
+sn_item_status_is_exposed (const gchar *status)
+{
+ return !!g_strcmp0 (status, "Passive");
+}
+
+
+
+static void
+sn_item_signal_received (GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ SnItem *item = user_data;
+ gchar *status;
+ gboolean exposed;
+
+ if (!g_strcmp0 (signal_name, "NewTitle") ||
+ !g_strcmp0 (signal_name, "NewIcon") ||
+ !g_strcmp0 (signal_name, "NewAttentionIcon") ||
+ !g_strcmp0 (signal_name, "NewOverlayIcon") ||
+ !g_strcmp0 (signal_name, "NewToolTip"))
+ {
+ sn_item_invalidate (item);
+ }
+ else if (!g_strcmp0 (signal_name, "NewStatus"))
+ {
+ g_variant_get (parameters, "(s)", &status);
+ exposed = sn_item_status_is_exposed (status);
+ if (exposed != item->exposed)
+ {
+ item->exposed = exposed;
+ if (item->initialized)
+ g_signal_emit (G_OBJECT (item), sn_item_signals[exposed ? EXPOSE : SEAL], 0);
+ }
+ }
+}
+
+
+
+static gboolean
+sn_item_pixbuf_equals (GdkPixbuf *p1,
+ GdkPixbuf *p2)
+{
+ guchar *p1p, *p2p;
+ guint p1l, p2l;
+ gint i;
+
+ if (p1 == p2 || p1 == NULL && p2 == NULL)
+ return TRUE;
+
+ if ((p1 == NULL) != (p2 == NULL))
+ return FALSE;
+
+ p1p = gdk_pixbuf_get_pixels_with_length (p1, &p1l);
+ p2p = gdk_pixbuf_get_pixels_with_length (p2, &p2l);
+
+ if (p1l != p2l)
+ return FALSE;
+
+ for (gint i = 0; i < p1l; i++)
+ if (p1p[i] != p2p[i])
+ return FALSE;
+
+ return TRUE;
+}
+
+
+
+static GdkPixbuf *
+sn_item_extract_pixbuf (GVariant *variant)
+{
+ GVariantIter *iter;
+ gint width, height;
+ gint lwidth = 0, lheight = 0;
+ GVariant *array_value;
+ gconstpointer data;
+ guchar *array = NULL;
+ gsize size;
+ guchar alpha;
+ gint i;
+
+ if (variant == NULL)
+ return NULL;
+
+ g_variant_get (variant, "a(iiay)", &iter);
+
+ if (iter == NULL)
+ return NULL;
+
+ while (g_variant_iter_loop (iter, "(ii at ay)", &width, &height, &array_value))
+ {
+ if (width > 0 && height > 0 && array_value != NULL &&
+ width * height > lwidth * lheight)
+ {
+ size = g_variant_get_size (array_value);
+ /* sanity check */
+ if (size == 4 * width * height)
+ {
+ /* find the largest image */
+ data = g_variant_get_data (array_value);
+ if (data != NULL)
+ {
+ if (array != NULL)
+ g_free (array);
+ array = g_memdup (data, size);
+ lwidth = width;
+ lheight = height;
+ }
+ }
+ }
+ }
+
+ if (array != NULL)
+ {
+ /* argb to rgba */
+ for (i = 0; i < 4 * lwidth * lheight; i += 4)
+ {
+ alpha = array[i];
+ array[i] = array[i + 1];
+ array[i + 1] = array[i + 2];
+ array[i + 2] = array[i + 3];
+ array[i + 3] = alpha;
+ }
+
+ return gdk_pixbuf_new_from_data (array, GDK_COLORSPACE_RGB,
+ TRUE, 8, lwidth, lheight, 4 * lwidth,
+ (GdkPixbufDestroyNotify)g_free, NULL);
+ }
+
+ return NULL;
+}
+
+
+
+static void
+sn_item_get_all_properties_result (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ SnItem *item = user_data;
+ GError *error = NULL;
+ GVariant *properties;
+ GVariantIter *iter = NULL;
+ const gchar *name;
+ GVariant *value;
+
+ const gchar *str_val1;
+ const gchar *str_val2;
+ gboolean bool_val1;
+ GdkPixbuf *pb_val1;
+
+ gboolean update_exposed = FALSE;
+ gboolean update_tooltip = FALSE;
+ gboolean update_icon = FALSE;
+ gboolean update_menu = FALSE;
+
+ properties = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, &error);
+ free_error_and_return_if_cancelled (error);
+ return_and_finish_if_true (properties == NULL);
+
+ #define string_empty_null(s) ((s) != NULL ? (s) : "")
+
+ #define update_new_string(val, entry, update_what) \
+ if (g_strcmp0 (string_empty_null (val), string_empty_null (item->entry))) \
+ { \
+ g_free (item->entry); \
+ item->entry = (val) != NULL && strlen (val) > 0 \
+ ? g_strdup (val) : NULL; \
+ update_what = TRUE; \
+ }
+
+ #define update_new_pixbuf(val, entry, update_what) \
+ if (!sn_item_pixbuf_equals (val, item->entry)) \
+ { \
+ if (item->entry != NULL) \
+ g_object_unref (item->entry); \
+ item->entry = val; \
+ update_what = TRUE; \
+ } \
+ else if (val != NULL) \
+ { \
+ g_object_unref (val); \
+ }
+
+ g_variant_get (properties, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop (iter, "{&sv}", &name, &value)) {
+ if (!g_strcmp0 (name, "Id"))
+ {
+ if (item->id == NULL)
+ item->id = g_variant_dup_string (value, NULL);
+ }
+ else if (!g_strcmp0 (name, "Status"))
+ {
+ str_val1 = g_variant_get_string (value, NULL);
+ bool_val1 = sn_item_status_is_exposed (str_val1);
+ if (bool_val1 != item->exposed)
+ {
+ item->exposed = bool_val1;
+ update_exposed = TRUE;
+ }
+ }
+ else if (!g_strcmp0 (name, "Title"))
+ {
+ str_val1 = g_variant_get_string (value, NULL);
+ update_new_string (str_val1, title, update_tooltip);
+ }
+ else if (!g_strcmp0 (name, "ToolTip"))
+ {
+ g_variant_get (value, "(sa(iiay)ss)", NULL, NULL, &str_val1, &str_val2);
+ update_new_string (str_val1, tooltip_title, update_tooltip);
+ update_new_string (str_val2, tooltip_subtitle, update_tooltip);
+ }
+ else if (!g_strcmp0 (name, "ItemIsMenu"))
+ {
+ bool_val1 = g_variant_get_boolean (value);
+ if (bool_val1 != item->item_is_menu)
+ {
+ item->item_is_menu = bool_val1;
+ update_menu = TRUE;
+ }
+ }
+ else if (!g_strcmp0 (name, "Menu"))
+ {
+ str_val1 = g_variant_get_string (value, NULL);
+ update_new_string (str_val1, menu_object_path, update_menu);
+ }
+ else if (!g_strcmp0 (name, "IconThemePath"))
+ {
+ str_val1 = g_variant_get_string (value, NULL);
+ update_new_string (str_val1, icon_theme_path, update_icon);
+ }
+ else if (!g_strcmp0 (name, "IconName"))
+ {
+ str_val1 = g_variant_get_string (value, NULL);
+ update_new_string (str_val1, icon_name, update_icon);
+ }
+ else if (!g_strcmp0 (name, "IconPixmap"))
+ {
+ pb_val1 = sn_item_extract_pixbuf (value);
+ update_new_pixbuf (pb_val1, icon_pixbuf, update_icon);
+ }
+ else if (!g_strcmp0 (name, "IconAccessibleDesc"))
+ {
+ str_val1 = g_variant_get_string (value, NULL);
+ update_new_string (str_val1, icon_desc, update_icon);
+ }
+ else if (!g_strcmp0 (name, "AttentionIconName"))
+ {
+ str_val1 = g_variant_get_string (value, NULL);
+ update_new_string (str_val1, attention_icon_name, update_icon);
+ }
+ else if (!g_strcmp0 (name, "AttentionIconPixmap"))
+ {
+ pb_val1 = sn_item_extract_pixbuf (value);
+ update_new_pixbuf (pb_val1, attention_icon_pixbuf, update_icon);
+ }
+ else if (!g_strcmp0 (name, "AttentionAccessibleDesc"))
+ {
+ str_val1 = g_variant_get_string (value, NULL);
+ update_new_string (str_val1, attention_desc, update_icon);
+ }
+ else if (!g_strcmp0 (name, "OverlayIconName"))
+ {
+ str_val1 = g_variant_get_string (value, NULL);
+ update_new_string (str_val1, overlay_icon_name, update_icon);
+ }
+ else if (!g_strcmp0 (name, "OverlayIconPixmap"))
+ {
+ pb_val1 = sn_item_extract_pixbuf (value);
+ update_new_pixbuf (pb_val1, overlay_icon_pixbuf, update_icon);
+ }
+ }
+
+ g_variant_iter_free (iter);
+ g_variant_unref (properties);
+
+ #undef update_new_pixbuf
+ #undef update_new_string
+ #undef string_empty_null
+
+ if (!item->initialized)
+ {
+ if (item->id != NULL)
+ {
+ item->initialized = TRUE;
+ if (item->exposed)
+ g_signal_emit (G_OBJECT (item), sn_item_signals[EXPOSE], 0);
+ }
+ }
+ else
+ {
+ if (update_exposed)
+ g_signal_emit (G_OBJECT (item), sn_item_signals[item->exposed ? EXPOSE : SEAL], 0);
+
+ if (item->exposed)
+ {
+ if (update_tooltip)
+ g_signal_emit (G_OBJECT (item), sn_item_signals[TOOLTIP_CHANGED], 0);
+ if (update_icon)
+ g_signal_emit (G_OBJECT (item), sn_item_signals[ICON_CHANGED], 0);
+ if (update_menu)
+ {
+ if (item != NULL)
+ g_object_unref (item->cached_menu);
+ item->cached_menu = NULL;
+ g_signal_emit (G_OBJECT (item), sn_item_signals[MENU_CHANGED], 0);
+ }
+ }
+ }
+}
+
+
+
+const gchar *
+sn_item_get_name (SnItem *item)
+{
+ g_return_val_if_fail (XFCE_IS_SN_ITEM (item), NULL);
+ g_return_val_if_fail (item->initialized, NULL);
+
+ return item->id;
+}
+
+
+
+void
+sn_item_get_icon (SnItem *item,
+ const gchar **icon_name,
+ GdkPixbuf **icon_pixbuf,
+ const gchar **overlay_icon_name,
+ GdkPixbuf **overlay_icon_pixbuf)
+{
+ g_return_if_fail (XFCE_IS_SN_ITEM (item));
+ g_return_if_fail (item->initialized);
+
+ if (icon_name != NULL)
+ {
+ *icon_name = item->attention_icon_name != NULL
+ ? item->attention_icon_name
+ : item->icon_name;
+ }
+
+ if (icon_pixbuf != NULL)
+ {
+ *icon_pixbuf = item->attention_icon_pixbuf != NULL
+ ? item->attention_icon_pixbuf
+ : item->icon_pixbuf;
+ }
+
+ if (overlay_icon_name != NULL)
+ *overlay_icon_name = item->overlay_icon_name;
+
+ if (overlay_icon_pixbuf != NULL)
+ *overlay_icon_pixbuf = item->overlay_icon_pixbuf;
+}
+
+
+
+void
+sn_item_get_tooltip (SnItem *item,
+ const gchar **title,
+ const gchar **subtitle)
+{
+ gchar *stub;
+
+ g_return_if_fail (XFCE_IS_SN_ITEM (item));
+ g_return_if_fail (item->initialized);
+
+ if (title == NULL)
+ title = (gpointer)&stub;
+ if (subtitle == NULL)
+ subtitle = (gpointer)&stub;
+
+ if (item->tooltip_title != NULL && item->tooltip_subtitle != NULL)
+ {
+ *title = item->tooltip_title;
+ *subtitle = item->tooltip_subtitle;
+ }
+ else if (item->attention_desc != NULL)
+ {
+ /* try to use attention_desc as subtitle */
+ if (item->tooltip_title != NULL)
+ {
+ *title = item->tooltip_title;
+ *subtitle = item->attention_desc;
+ }
+ else if (item->title != NULL)
+ {
+ *title = item->title;
+ *subtitle = item->attention_desc;
+ }
+ else
+ {
+ *title = item->attention_desc;
+ *subtitle = NULL;
+ }
+ }
+ else if (item->icon_desc != NULL)
+ {
+ /* try to use icon_desc as subtitle */
+ if (item->tooltip_title != NULL)
+ {
+ *title = item->tooltip_title;
+ *subtitle = item->icon_desc;
+ }
+ else if (item->title != NULL)
+ {
+ *title = item->title;
+ *subtitle = item->icon_desc;
+ }
+ else
+ {
+ *title = item->icon_desc;
+ *subtitle = NULL;
+ }
+ }
+ else if (item->tooltip_title != NULL )
+ {
+ *title = item->tooltip_title;
+ *subtitle = NULL;
+ }
+ else if (item->title != NULL )
+ {
+ *title = item->title;
+ *subtitle = NULL;
+ }
+ else
+ {
+ *title = NULL;
+ *subtitle = NULL;
+ }
+
+ #undef sn_non_empty
+}
+
+
+
+gboolean
+sn_item_is_menu_only (SnItem *item)
+{
+ g_return_val_if_fail (XFCE_IS_SN_ITEM (item), FALSE);
+ g_return_val_if_fail (item->initialized, FALSE);
+
+ return item->item_is_menu;
+}
+
+
+
+GtkWidget *
+sn_item_get_menu (SnItem *item)
+{
+ DbusmenuGtkMenu *menu;
+
+ g_return_val_if_fail (XFCE_IS_SN_ITEM (item), NULL);
+ g_return_val_if_fail (item->initialized, NULL);
+
+ if (item->cached_menu == NULL && item->menu_object_path != NULL)
+ {
+ menu = dbusmenu_gtkmenu_new (item->bus_name, item->menu_object_path);
+ if (menu != NULL)
+ {
+ g_object_ref_sink (menu);
+ item->cached_menu = GTK_WIDGET (menu);
+ }
+ }
+
+ return item->cached_menu;
+}
+
+
+
+void
+sn_item_activate (SnItem *item,
+ gint x_root,
+ gint y_root)
+{
+ g_return_if_fail (XFCE_IS_SN_ITEM (item));
+ g_return_if_fail (item->initialized);
+ g_return_if_fail (item->item_proxy != NULL);
+
+ g_dbus_proxy_call (item->item_proxy, "Activate",
+ g_variant_new ("(ii)", x_root, y_root),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, NULL, NULL);
+}
+
+
+
+void
+sn_item_secondary_activate (SnItem *item,
+ gint x_root,
+ gint y_root)
+{
+ g_return_if_fail (XFCE_IS_SN_ITEM (item));
+ g_return_if_fail (item->initialized);
+ g_return_if_fail (item->item_proxy != NULL);
+
+ g_dbus_proxy_call (item->item_proxy, "SecondaryActivate",
+ g_variant_new ("(ii)", x_root, y_root),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, NULL, NULL);
+}
+
+
+
+void
+sn_item_scroll (SnItem *item,
+ gint delta_x,
+ gint delta_y)
+{
+ g_return_if_fail (XFCE_IS_SN_ITEM (item));
+ g_return_if_fail (item->initialized);
+ g_return_if_fail (item->item_proxy != NULL);
+
+ if (delta_x != 0)
+ {
+ g_dbus_proxy_call (item->item_proxy, "Scroll",
+ g_variant_new ("(is)", delta_x, "horizontal"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, NULL, NULL);
+ }
+
+ if (delta_y != 0)
+ {
+ g_dbus_proxy_call (item->item_proxy, "Scroll",
+ g_variant_new ("(is)", delta_y, "vertical"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, NULL, NULL);
+ }
+}
diff --git a/panel-plugin/sn-item.h b/panel-plugin/sn-item.h
new file mode 100644
index 0000000..76ee3dd
--- /dev/null
+++ b/panel-plugin/sn-item.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __SN_ITEM_H__
+#define __SN_ITEM_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SnItemClass SnItemClass;
+typedef struct _SnItem SnItem;
+
+#define XFCE_TYPE_SN_ITEM (sn_item_get_type ())
+#define XFCE_SN_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_SN_ITEM, SnItem))
+#define XFCE_SN_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_SN_ITEM, SnItemClass))
+#define XFCE_IS_SN_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_SN_ITEM))
+#define XFCE_IS_SN_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_SN_ITEM))
+#define XFCE_SN_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_SN_ITEM, SnItemClass))
+
+GType sn_item_get_type (void) G_GNUC_CONST;
+
+void sn_item_start (SnItem *item);
+
+void sn_item_invalidate (SnItem *item);
+
+const gchar *sn_item_get_name (SnItem *item);
+
+void sn_item_get_icon (SnItem *item,
+ const gchar **icon_name,
+ GdkPixbuf **icon_pixbuf,
+ const gchar **overlay_icon_name,
+ GdkPixbuf **overlay_icon_pixbuf);
+
+void sn_item_get_tooltip (SnItem *item,
+ const gchar **title,
+ const gchar **subtitle);
+
+gboolean sn_item_is_menu_only (SnItem *item);
+
+GtkWidget *sn_item_get_menu (SnItem *item);
+
+void sn_item_activate (SnItem *item,
+ gint x_root,
+ gint y_root);
+
+void sn_item_secondary_activate (SnItem *item,
+ gint x_root,
+ gint y_root);
+
+void sn_item_scroll (SnItem *item,
+ gint delta_x,
+ gint delta_y);
+
+G_END_DECLS
+
+#endif /* !__SN_ITEM_H__ */
diff --git a/panel-plugin/sn-plugin.c b/panel-plugin/sn-plugin.c
new file mode 100644
index 0000000..ee59208
--- /dev/null
+++ b/panel-plugin/sn-plugin.c
@@ -0,0 +1,254 @@
+/*
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <libxfce4util/libxfce4util.h>
+
+#include "sn-backend.h"
+#include "sn-box.h"
+#include "sn-button.h"
+#include "sn-dialog.h"
+#include "sn-item.h"
+#include "sn-plugin.h"
+
+
+
+static void sn_plugin_construct (XfcePanelPlugin *panel_plugin);
+
+static void sn_plugin_free (XfcePanelPlugin *panel_plugin);
+
+static gboolean sn_plugin_size_changed (XfcePanelPlugin *panel_plugin,
+ gint size);
+
+static void sn_plugin_mode_changed (XfcePanelPlugin *panel_plugin,
+ XfcePanelPluginMode mode);
+
+static void sn_plugin_configure_plugin (XfcePanelPlugin *panel_plugin);
+
+static void sn_plugin_show_about (XfcePanelPlugin *panel_plugin);
+
+
+
+struct _SnPluginClass
+{
+ XfcePanelPluginClass __parent__;
+};
+
+struct _SnPlugin
+{
+ XfcePanelPlugin __parent__;
+
+ GtkWidget *item;
+ GtkWidget *box;
+
+ SnBackend *backend;
+ SnConfig *config;
+};
+
+XFCE_PANEL_DEFINE_PLUGIN (SnPlugin, sn_plugin)
+
+
+
+static void
+sn_plugin_class_init (SnPluginClass *klass)
+{
+ XfcePanelPluginClass *panel_plugin_class;
+
+ panel_plugin_class = XFCE_PANEL_PLUGIN_CLASS (klass);
+ panel_plugin_class->construct = sn_plugin_construct;
+ panel_plugin_class->free_data = sn_plugin_free;
+ panel_plugin_class->size_changed = sn_plugin_size_changed;
+ panel_plugin_class->mode_changed = sn_plugin_mode_changed;
+ panel_plugin_class->configure_plugin = sn_plugin_configure_plugin;
+ panel_plugin_class->about = sn_plugin_show_about;
+}
+
+
+
+static void
+sn_plugin_init (SnPlugin *plugin)
+{
+ plugin->item = NULL;
+ plugin->box = NULL;
+
+ plugin->backend = NULL;
+ plugin->config = NULL;
+}
+
+
+
+static void
+sn_plugin_free (XfcePanelPlugin *panel_plugin)
+{
+ SnPlugin *plugin = XFCE_SN_PLUGIN (panel_plugin);
+ GList *children, *li;
+
+ /* remove children so they won't use unrefed SnItems and SnConfig */
+ children = gtk_container_get_children (GTK_CONTAINER (plugin->box));
+ for (li = children; li != NULL; li = li->next)
+ {
+ gtk_container_remove (GTK_CONTAINER (plugin->box), li->data);
+ }
+ g_list_free (children);
+
+ g_object_unref (plugin->backend);
+ g_object_unref (plugin->config);
+}
+
+
+
+static gboolean
+sn_plugin_size_changed (XfcePanelPlugin *panel_plugin,
+ gint size)
+{
+ SnPlugin *plugin = XFCE_SN_PLUGIN (panel_plugin);
+
+ sn_config_set_size (plugin->config, size, xfce_panel_plugin_get_nrows (panel_plugin));
+
+ return TRUE;
+}
+
+
+
+static void
+sn_plugin_mode_changed (XfcePanelPlugin *panel_plugin,
+ XfcePanelPluginMode mode)
+{
+ SnPlugin *plugin = XFCE_SN_PLUGIN (panel_plugin);
+ GtkOrientation orientation;
+ GtkOrientation panel_orientation;
+
+ panel_orientation = xfce_panel_plugin_get_orientation (panel_plugin);
+ orientation = mode == XFCE_PANEL_PLUGIN_MODE_VERTICAL
+ ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL;
+
+ sn_config_set_orientation (plugin->config, panel_orientation, orientation);
+
+ sn_plugin_size_changed (panel_plugin, xfce_panel_plugin_get_size (panel_plugin));
+}
+
+
+
+static void
+sn_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
+{
+ SnPlugin *plugin = XFCE_SN_PLUGIN (panel_plugin);
+ SnDialog *dialog;
+
+ dialog = sn_dialog_new (plugin->config, gtk_widget_get_screen (GTK_WIDGET (plugin)));
+ if (dialog != NULL)
+ {
+ xfce_panel_plugin_block_menu (panel_plugin);
+ g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify)xfce_panel_plugin_unblock_menu, panel_plugin);
+ }
+}
+
+
+
+static void
+sn_plugin_show_about (XfcePanelPlugin *panel_plugin)
+{
+ GdkPixbuf *icon;
+
+ const gchar *auth[] =
+ {
+ "Viktor Odintsev <ninetls at xfce.org>",
+ "Andrzej Radecki <andrzejr at xfce.org>",
+ NULL
+ };
+
+ icon = xfce_panel_pixbuf_from_source ("xfce4-statusnotifier-plugin", NULL, 32);
+
+ gtk_show_about_dialog (NULL,
+ "logo", icon,
+ "license", xfce_get_license_text (XFCE_LICENSE_TEXT_GPL),
+ "version", PACKAGE_VERSION,
+ "program-name", PACKAGE_NAME,
+ "comments", _("Provides a panel area for status notifier items (application indicators)."),
+ "website", "https://goodies.xfce.org/projects/panel-plugins/xfce4-statusnotifier-plugin",
+ "authors", auth,
+ NULL);
+
+ if (icon)
+ g_object_unref (icon);
+}
+
+
+
+static void
+sn_plugin_item_added (SnPlugin *plugin,
+ SnItem *item)
+{
+ GtkWidget *button;
+
+ button = sn_button_new (item,
+ xfce_panel_plugin_position_menu, plugin,
+ plugin->config);
+
+ sn_config_add_known_item (plugin->config, sn_item_get_name (item));
+
+ gtk_container_add (GTK_CONTAINER (plugin->box), button);
+ gtk_widget_show (button);
+}
+
+
+
+static void
+sn_plugin_item_removed (SnPlugin *plugin,
+ SnItem *item)
+{
+ sn_box_remove_item (XFCE_SN_BOX (plugin->box), item);
+}
+
+
+
+static void
+sn_plugin_construct (XfcePanelPlugin *panel_plugin)
+{
+ SnPlugin *plugin = XFCE_SN_PLUGIN (panel_plugin);
+ GtkWidget *label;
+
+ xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
+
+ xfce_panel_plugin_menu_show_configure (panel_plugin);
+ xfce_panel_plugin_menu_show_about (panel_plugin);
+
+ plugin->config = sn_config_new (xfce_panel_plugin_get_property_base (panel_plugin));
+
+ plugin->box = sn_box_new (plugin->config);
+ gtk_container_add (GTK_CONTAINER (plugin), GTK_WIDGET (plugin->box));
+ gtk_widget_show (GTK_WIDGET (plugin->box));
+
+ g_signal_connect_swapped (plugin->config, "configuration-changed",
+ G_CALLBACK (gtk_widget_queue_resize), plugin->box);
+
+ plugin->backend = sn_backend_new ();
+ g_signal_connect_swapped (plugin->backend, "item-added",
+ G_CALLBACK (sn_plugin_item_added), plugin);
+ g_signal_connect_swapped (plugin->backend, "item-removed",
+ G_CALLBACK (sn_plugin_item_removed), plugin);
+ sn_backend_start (plugin->backend);
+}
diff --git a/panel-plugin/sn-plugin.h b/panel-plugin/sn-plugin.h
new file mode 100644
index 0000000..a7c4999
--- /dev/null
+++ b/panel-plugin/sn-plugin.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017 Viktor Odintsev <ninetls at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __SN_PLUGIN_H__
+#define __SN_PLUGIN_H__
+
+#include <gtk/gtk.h>
+#include <libxfce4panel/libxfce4panel.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SnPluginClass SnPluginClass;
+typedef struct _SnPlugin SnPlugin;
+
+#define XFCE_TYPE_SN_PLUGIN (sn_plugin_get_type ())
+#define XFCE_SN_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_SN_PLUGIN, SnPlugin))
+#define XFCE_SN_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_SN_PLUGIN, SnPluginClass))
+#define XFCE_IS_SN_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_SN_PLUGIN))
+#define XFCE_IS_SN_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_SN_PLUGIN))
+#define XFCE_SN_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_SN_PLUGIN, SnPluginClass))
+
+GType sn_plugin_get_type (void) G_GNUC_CONST;
+
+void sn_plugin_register_type (XfcePanelTypeModule *panel_type_module);
+
+G_END_DECLS
+
+#endif /* !__SN_PLUGIN_H__ */
diff --git a/panel-plugin/sn-watcher.xml b/panel-plugin/sn-watcher.xml
new file mode 100644
index 0000000..efa101d
--- /dev/null
+++ b/panel-plugin/sn-watcher.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<node name="/StatusNotifierWatcher">
+ <interface name="org.kde.StatusNotifierWatcher">
+ <annotation name="org.gtk.GDBus.C.Name" value="SnWatcher" />
+
+ <method name="RegisterStatusNotifierItem">
+ <arg name="service" type="s" direction="in" />
+ </method>
+
+ <method name="RegisterStatusNotifierHost">
+ <arg name="service" type="s" direction="in" />
+ </method>
+
+ <property name="RegisteredStatusNotifierItems" type="as" access="read" />
+ <property name="IsStatusNotifierHostRegistered" type="b" access="read" />
+ <property name="ProtocolVersion" type="i" access="read" />
+
+ <signal name="StatusNotifierItemRegistered">
+ <arg type="s" name="service" direction="out" />
+ </signal>
+
+ <signal name="StatusNotifierItemUnregistered">
+ <arg type="s" name="service" direction="out" />
+ </signal>
+
+ <signal name="StatusNotifierHostRegistered" />
+ </interface>
+</node>
diff --git a/panel-plugin/statusnotifier.desktop.in b/panel-plugin/statusnotifier.desktop.in
new file mode 100644
index 0000000..4d7e924
--- /dev/null
+++ b/panel-plugin/statusnotifier.desktop.in
@@ -0,0 +1,10 @@
+[Xfce Panel]
+Type=X-XFCE-PanelPlugin
+Encoding=UTF-8
+_Name=Status Notifier Plugin
+_Comment=Provides a panel area for status notifier items (application indicators)
+Icon=xfce4-statusnotifier-plugin
+X-XFCE-Module=statusnotifier
+X-XFCE-Unique=TRUE
+X-XFCE-Internal=FALSE
+X-XFCE-API=2.0
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644
index 0000000..77034f5
--- /dev/null
+++ b/po/POTFILES.in
@@ -0,0 +1,7 @@
+panel-plugin/sn.desktop.in
+panel-plugin/sn-box.c
+panel-plugin/sn-button.c
+panel-plugin/sn-config.c
+panel-plugin/sn-dialog.c
+panel-plugin/sn-dialog.glade
+panel-plugin/sn-plugin.c
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list