From 78f66fe7122ea51511f6e43d58c3ea81568a077f Mon Sep 17 00:00:00 2001 From: Nick Schermer <nick@xfce.org> Date: Sat, 3 Mar 2007 19:26:06 +0000 Subject: [PATCH] * Import my 4_5_nick branch into trunk: - Completely rewritten launcher (Bugs 2336, 2365, 1323, 2262 and 1225) - Various improvements in libxfce4panel (memory leaks, G_GNUC_INTERNAL, GSList, canonical strings and fixed pedantic warnings). - Libxfce4panel does no longer depend on libxfcegui4. This might cause some problems with plugins. Plugin developers should add libxfcegui4 to the dependencies of their package (including cflags and libadd in the makefiles). (Old svn revision: 25077) --- AUTHORS | 4 +- COPYING | 10 +- COPYING_LIBS => COPYING.LIB | 3 - ChangeLog | 11 + HACKING | 127 +- Makefile.am | 51 +- NEWS | 87 +- README | 54 +- README.Kiosk | 20 - README.Plugins | 4 - TODO | 46 + autogen.sh | 6 +- config/Makefile.am | 27 +- config/launcher-10.rc.in | 7 +- config/launcher-7.rc.in | 8 +- config/launcher-8.rc.in | 7 +- config/launcher-9.rc.in | 7 +- configure.ac.in | 135 - configure.in.in | 205 ++ icons/16x16/Makefile.am | 15 + icons/{ => 16x16}/xfce-system-exit.png | Bin icons/{ => 16x16}/xfce-system-info.png | Bin icons/{ => 16x16}/xfce-system-lock.png | Bin icons/{ => 16x16}/xfce-system-settings.png | Bin icons/48x48/Makefile.am | 14 + icons/{ => 48x48}/xfce-mouse.png | Bin icons/{ => 48x48}/xfce4-iconbox.png | Bin icons/{ => 48x48}/xfce4-panel.png | Bin icons/{ => 48x48}/xfce4-taskbar.png | Bin icons/Makefile.am | 23 +- icons/xfce-mail.png | Bin 2643 -> 0 bytes libxfce4panel/Makefile.am | 182 +- libxfce4panel/libxfce4panel-1.0.pc.in | 11 +- libxfce4panel/xfce-arrow-button.c | 254 +- libxfce4panel/xfce-arrow-button.h | 67 +- libxfce4panel/xfce-hvbox.c | 96 +- libxfce4panel/xfce-hvbox.h | 39 +- libxfce4panel/xfce-itembar.c | 933 +++--- libxfce4panel/xfce-itembar.h | 157 +- libxfce4panel/xfce-marshal.list | 3 - libxfce4panel/xfce-panel-convenience.c | 55 +- libxfce4panel/xfce-panel-convenience.h | 47 +- libxfce4panel/xfce-panel-enums.h | 43 +- libxfce4panel/xfce-panel-external-item.c | 398 +-- libxfce4panel/xfce-panel-external-item.h | 62 +- libxfce4panel/xfce-panel-external-plugin.c | 433 ++- libxfce4panel/xfce-panel-external-plugin.h | 56 +- libxfce4panel/xfce-panel-internal-plugin.c | 487 +-- libxfce4panel/xfce-panel-internal-plugin.h | 63 +- libxfce4panel/xfce-panel-item-iface.c | 239 +- libxfce4panel/xfce-panel-item-iface.h | 161 +- libxfce4panel/xfce-panel-macros.h | 49 +- .../xfce-panel-plugin-iface-private.h | 129 +- libxfce4panel/xfce-panel-plugin-iface.c | 700 ++-- libxfce4panel/xfce-panel-plugin-iface.h | 139 +- libxfce4panel/xfce-panel-plugin-messages.c | 37 +- libxfce4panel/xfce-panel-plugin-messages.h | 50 +- libxfce4panel/xfce-panel-plugin.h | 151 +- libxfce4panel/xfce-panel-window.c | 654 ++-- libxfce4panel/xfce-panel-window.h | 172 +- mcs-plugin/Makefile.am | 2 +- mcs-plugin/plugin.c | 98 +- panel/Makefile.am | 127 +- panel/main.c | 20 +- plugins/Makefile.am | 24 +- plugins/actions/Makefile.am | 82 +- plugins/actions/actions.c | 126 +- plugins/actions/actions.desktop.in.in | 2 +- plugins/clock/Makefile.am | 82 +- plugins/clock/clock.c | 152 +- plugins/clock/clock.desktop.in.in | 2 +- plugins/iconbox/Makefile.am | 82 +- plugins/iconbox/iconbox.c | 233 +- plugins/iconbox/iconbox.desktop.in.in | 2 +- plugins/launcher/Makefile.am | 91 +- plugins/launcher/launcher-dialog.c | 2819 +++++++---------- plugins/launcher/launcher-dialog.h | 18 +- plugins/launcher/launcher-exec.c | 602 ++++ plugins/launcher/launcher-exec.h | 29 + plugins/launcher/launcher.c | 1855 +++++------ plugins/launcher/launcher.desktop.in.in | 2 +- plugins/launcher/launcher.h | 158 +- plugins/pager/Makefile.am | 82 +- plugins/pager/pager.c | 106 +- plugins/pager/pager.desktop.in.in | 2 +- plugins/separator/Makefile.am | 82 +- plugins/separator/separator.c | 80 +- plugins/separator/separator.desktop.in.in | 2 +- plugins/showdesktop/Makefile.am | 83 +- plugins/showdesktop/showdesktop.c | 1 + plugins/showdesktop/showdesktop.desktop.in.in | 2 +- plugins/systray/Makefile.am | 82 +- plugins/systray/systray.c | 98 +- plugins/systray/systray.desktop.in.in | 2 +- plugins/tasklist/Makefile.am | 87 +- plugins/tasklist/tasklist-dialogs.c | 253 ++ plugins/tasklist/tasklist-dialogs.h | 25 + plugins/tasklist/tasklist.c | 539 +--- plugins/tasklist/tasklist.desktop.in.in | 2 +- plugins/tasklist/tasklist.h | 56 + plugins/windowlist/Makefile.am | 104 +- plugins/windowlist/windowlist-dialog.c | 100 +- plugins/windowlist/windowlist.c | 9 +- plugins/windowlist/windowlist.desktop.in.in | 2 +- plugins/windowlist/windowlist.h | 22 +- xfce4-panel.spec.in | 37 +- 106 files changed, 7971 insertions(+), 7233 deletions(-) rename COPYING_LIBS => COPYING.LIB (99%) delete mode 100644 README.Kiosk delete mode 100644 README.Plugins create mode 100644 TODO delete mode 100644 configure.ac.in create mode 100644 configure.in.in create mode 100644 icons/16x16/Makefile.am rename icons/{ => 16x16}/xfce-system-exit.png (100%) rename icons/{ => 16x16}/xfce-system-info.png (100%) rename icons/{ => 16x16}/xfce-system-lock.png (100%) rename icons/{ => 16x16}/xfce-system-settings.png (100%) create mode 100644 icons/48x48/Makefile.am rename icons/{ => 48x48}/xfce-mouse.png (100%) rename icons/{ => 48x48}/xfce4-iconbox.png (100%) rename icons/{ => 48x48}/xfce4-panel.png (100%) rename icons/{ => 48x48}/xfce4-taskbar.png (100%) delete mode 100644 icons/xfce-mail.png create mode 100644 plugins/launcher/launcher-exec.c create mode 100644 plugins/launcher/launcher-exec.h create mode 100644 plugins/tasklist/tasklist-dialogs.c create mode 100644 plugins/tasklist/tasklist-dialogs.h create mode 100644 plugins/tasklist/tasklist.h diff --git a/AUTHORS b/AUTHORS index 4c33a1377..7c173ad7e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,7 +1,7 @@ Maintainers =========== -Jasper Huijsmans <jasper@xfce.org> -Nick Schermer <nick@xfce.org> +Jasper Huijsmans <jasper@xfce.org> +Nick Schermer <nick@xfce.org> Contributors ============ diff --git a/COPYING b/COPYING index e90dfed1a..d60c31a97 100644 --- a/COPYING +++ b/COPYING @@ -55,7 +55,7 @@ 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 @@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions: 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 @@ -168,7 +168,7 @@ 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 @@ -225,7 +225,7 @@ 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 @@ -278,7 +278,7 @@ 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 diff --git a/COPYING_LIBS b/COPYING.LIB similarity index 99% rename from COPYING_LIBS rename to COPYING.LIB index 4fa521777..191a97fe9 100644 --- a/COPYING_LIBS +++ b/COPYING.LIB @@ -1,6 +1,3 @@ -This license applies to the libraries in this package, but not the -applications. See header comments in specific source files. - GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 diff --git a/ChangeLog b/ChangeLog index afa53e98f..3038640e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-03-03 21:00 nick + + * Import my 4_5_nick branch into trunk: + - Completely rewritten launcher (Bugs 2336, 2365, 1323, 2262 and 1225) + - Various improvements in libxfce4panel (memory leaks, G_GNUC_INTERNAL, + GSList, canonical strings and fixed pedantic warnings). + - Libxfce4panel does no longer depend on libxfcegui4. This might cause + some problems with plugins. Plugin developers should add libxfcegui4 + to the dependencies of their package (including cflags and libadd in + the makefiles). + 2007-01-19 19:59 nick * NEWS: Update NEWS diff --git a/HACKING b/HACKING index 3c55ca91d..f898305d1 100644 --- a/HACKING +++ b/HACKING @@ -1,58 +1,85 @@ -This file describes the coding style I prefer for the panel. If you want to -help out with panel development, please try to conform to these 'rules'. --- Jasper - -* 2006-12-26 - -Nick prefers to align variable declarations, so here is an updated set of rules: - -- Coding style: - o Indentation is 4 spaces. Expand tabs, i.e. only use spaces for indentation. - o Braces are on a new line. For one-line if statements braces may be omitted. - o Return type of function definitions on a separate line. - o Function arguments on separate lines with the same alignment rules as - variable declarations. - o Variable declarations are aligned on the variable name. Short variable - declarations may be combined. Example: - - static gboolean - example_function (GtkWidget *widget, - Panel *panel, - int value) - { - XfceHandleType type; - const char *string; - int important_value; - int i, n, x, y; - /* ... */ - } - - o In header files and for static prototypes, you may align functions names as - well as arguments. No need to limit the line length. Example: - - static gboolean xfce_panel_long_name_for_example_function (GtkWidget *widget, - Panel *panel, - int value); - - static void example_function_2 (Panel *panel, - const char *value); - -- ChangeLog: I use the svn2cl package to create the changelog from the SVN log - messages. - o Website: http://ch.tudelft.nl/~arthur/svn2cl/ . - o Current version: 0.8. - o Command line: svn2cl.sh --linelen=74 --break-before-msg . - Note: I don't care about linelen, but with this parameter the changes with - previous ChangeLog were smallest. - -- Patches: use 'svn diff' to create patches if possible, or 'diff -u'. +Bug tracking system +=================== +To report bugs or file feature requests for xfce4-panel, please +use the Xfce bugzilla at http://bugzilla.xfce.org/. The product +is Xfce, component xfce4-panel. +Before reporting the bug, please search the bug tracker, to make +sure it wasn't reported already before. + + +Patches +======= + +Please submit patches to the Xfce bug tracking system or use the +xfce4-dev mailinglists. + +Please send a patch againts a recent version of xfce4-panel. Patches +against the Subversion trunk branch are most preferable. You can always +access the trunk branch from + + http://svn.xfce.org/svn/xfce/xfce4-panel/trunk + +or using an installed Subversion client + + svn co http://svn.xfce.org/svn/xfce/xfce4-panel/trunk xfce4-panel + + +Coding Style +============ + + - Always expand tabs, so the code is not dependent from a gives tab + setting. + - Braces are on a new line. For one-line if statements braces may be omitted. + - Return type of function definitions on a separate line. + - Function arguments on separate lines with the same alignment rules as + variable declarations. + - Use 3 empty lines between functions. + - Variable declarations are aligned on the variable name. Short variable + declarations may be combined. Example: + + static gboolean + example_function (GtkWidget *widget, + Panel *panel, + gint value) + { + XfceHandleType type; + const gchar *string; + gint important_value; + gint i, n, x, y; + /* ... */ + } + + - In header files and for static prototypes, you may align functions names as + well as arguments. No need to limit the line length. Example: + + static gboolean xfce_panel_long_name_for_example_function (GtkWidget *widget, + Panel *panel, + gint value); + static void example_function_2 (Panel *panel, + const gchar *value); + - Write ChangeLog entries. + + +ChangeLogs +========== + +I use the svn2cl package to create the changelog from the SVN log messages. + + - Website: http://ch.tudelft.nl/~arthur/svn2cl/ . + - Current version: 0.8. + - Command line: svn2cl.sh --linelen=74 --break-before-msg. + +Note: I don't care about linelen, but with this parameter the changes with + previous ChangeLog were smallest. + + +Misc +==== - If you have SVN access it is ok to commit trivial changes directly, but please send a patch to the mailing list for discussion for any non-trivial or non-obvious changes. - - As an exception to the rule above, if you are managing an Xfce release, feel free to do anything you need to achieve that goal. - - Managing the po/ directory, including the ChangeLog found there is left completely in the hands of the Xfce Translation Team. diff --git a/Makefile.am b/Makefile.am index c62626ff9..3ab5d72fe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,30 +1,5 @@ # $Id$ -EXTRA_DIST = \ - intltool-extract.in \ - intltool-merge.in \ - intltool-update.in \ - AUTHORS \ - COPYING \ - COPYING_LIBS \ - ChangeLog \ - HACKING \ - INSTALL \ - NEWS \ - README \ - README.Kiosk \ - README.Plugins \ - .indent.pro \ - xfce4-panel.spec - -DISTCLEANFILES = \ - configure.ac \ - intltool-extract \ - intltool-merge \ - intltool-update - -# docs should be at the end to make sure the library is build before -# scanning it. SUBDIRS = \ config \ icons \ @@ -35,12 +10,8 @@ SUBDIRS = \ po \ docs -AUTOMAKE_OPTIONS = \ - 1.8 \ - dist-bzip2 - distclean-local: - rm -rf *.cache *~ + rm -rf *.spec *.cache *~ rpm: dist rpmbuild -ta $(PACKAGE)-$(VERSION).tar.gz @@ -49,6 +20,24 @@ rpm: dist html: make -C docs html -DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc +EXTRA_DIST = \ + README \ + COPYING \ + COPYING.LIB \ + HACKING \ + INSTALL \ + xfce4-panel.spec.in \ + intltool-extract.in \ + intltool-merge.in \ + intltool-update.in + +DISTCLEANFILES = \ + xfce4-panel.spec \ + intltool-extract \ + intltool-merge \ + intltool-update + +DISTCHECK_CONFIGURE_FLAGS = \ + --enable-gtk-doc # vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/NEWS b/NEWS index 63ecd2012..8184a61b0 100644 --- a/NEWS +++ b/NEWS @@ -1,44 +1,51 @@ -NEWS for xfce4-panel -==================== - -4.4.0 +4.5.x ===== -- Many fixes when using the panel in a multiscreen setup (Jasper, Nick) -- Update or add blinking for urgent windows in taslist, windowlist and iconbox. - (Jasper) -- Move test plugin to Xfce Goodies. (Nick) -- Several fixes for (re)sizing and positioning behavior. (Jasper) -- Lots of small fixes and polish. (Jasper, Nick, Olivier, Benedikt) -- Update manual. (Jasper) -- Many translation updates. (Xfce Translation Team) - - -4.3.99.2 (4.4-RC2) -================== -- Adjust the plugin system to improve support for other platforms - (read: windows). (Jasper, Olivier) -- Many small fixes. (Jasper, Nick, Olivier, Jean-Francois) -- Translation updates. (Xfce Translation Team) - - -4.3.99.1 (4.4-RC1) -================== -- Add helper utility to open windowlist, useful for keyboard shortcuts. - Patch by Darren Salt. (Jasper) -- Create dummy scripts for obsolete xftaskbar4 and xfce4-iconbox. -- Change unix signal handling to use a pipe with an io watch, instead - of a timeout. (Jasper) -- Add search box to new item dialog. Patch by Benedikt. (Jasper) -- Fixes and improvements to memory management, and timeout handling. - (Nick, Jasper) -- Translation updates. (Xfce Translation Team) - - -4.3.x (changes from 4.2.x) -========================== -- Major rewrite of the panel -- New plugin API supporting out-of-process plugins -- Support for multiple panels +- Completely rewritten launcher (Bugs 2336, 2365, 1323, 2262 and 1225) +- Various improvements in libxfce4panel (memory leaks, G_GNUC_INTERNAL, + GSList, canonical strings and fixed pedantic warnings). +- Libxfce4panel does no longer depend on libxfcegui4. This might cause + some problems with plugins. Plugin developers should add libxfcegui4 + to the dependencies of their package (including cflags and libadd in + the makefiles). + + +4.3.99.3 (4.4-RC3) +================== +- Update or add blinking for urgent windows in taslist, windowlist and iconbox. + (Jasper) +- Move test plugin to Xfce Goodies. (Nick) +- Several fixes for (re)sizing and positioning behavior. (Jasper) +- Lots of small fixes and polish. (Jasper, Nick, Olivier, Benedikt) +- Update manual. (Jasper) +- Many translation updates. (Xfce Translation Team) + + +4.3.99.2 (4.4-RC2) +================== +- Adjust the plugin system to improve support for other platforms + (read: windows). (Jasper, Olivier) +- Many small fixes. (Jasper, Nick, Olivier, Jean-Francois) +- Translation updates. (Xfce Translation Team) + + +4.3.99.1 (4.4-RC1) +================== +- Add helper utility to open windowlist, useful for keyboard shortcuts. + Patch by Darren Salt. (Jasper) +- Create dummy scripts for obsolete xftaskbar4 and xfce4-iconbox. +- Change unix signal handling to use a pipe with an io watch, instead + of a timeout. (Jasper) +- Add search box to new item dialog. Patch by Benedikt. (Jasper) +- Fixes and improvements to memory management, and timeout handling. + (Nick, Jasper) +- Translation updates. (Xfce Translation Team) + + +4.3.x (changes from 4.2.x) +========================== +- Major rewrite of the panel +- New plugin API supporting out-of-process plugins +- Support for multiple panels - Xinerama and multi-head support diff --git a/README b/README index b737482f8..a986d8c66 100644 --- a/README +++ b/README @@ -1,11 +1,9 @@ -README for xfce version 4.4.x -============================= +What is it? +=========== -WHAT IS IT ? ------------- 'xfce4-panel' is the panel of the Xfce Desktop Environment. It is no longer modeled after the CDE panel like the first versions of xfce. -This version is based on GTK2 and should have all the advantages that come +This version is based on GTK+ and should have all the advantages that come with this toolkit (see http://www.gtk.org). The panel provides program lauchers with, optionally, non-hierarchical menus @@ -13,3 +11,49 @@ The panel provides program lauchers with, optionally, non-hierarchical menus pager. Additional plugins may be installed separately. +Installation +============ + +The file 'INSTALL' contains generic installation instructions. + + +Plugins +======= + +Starting from version 4.4, the Xfce Panel support two types of plugins: + * Internal plugins. These are loadable modules, using the gmodule interface. + * External plugins. These are separate programs that are embedded into the + panel using the GtkPlug/GtkSocket mechanism. + +For more information about the panel plugins framework, you can read the API +documentation (http://www.xfce.org/documentation/4.4/api/libxfce4panel/) or +the panel plugins how to (http://wiki.xfce.org/panel_plugins_howto). + + +KIOSK mode +========== + +The Xfce Panel supports the KIOSK mode introduced with libxfce4util 4.1.13. +It provides the following KIOSK capabilities: + +CustomizePanel: Only users with this capability will be allowed to customize +their panel (add panel plugins, configure panel plugins, add launchers, etc.). +This is similar to setting the environment va- riable XFCE_DISABLE_USER_CONFIG +with the old panel. + +So a sample xfce4-panel section in your kioskrc might look like this: + +<-- start snip --> +[xfce4-panel] +CustomizePanel=%powerusers,foo +<-- end snip --> + +This allows only users in the group powerusers and the user foo to customize +their panels. + + +How to report bugs? +=================== + +Bugs should be reported to the Xfce bug tracking system: +(http://bugzilla.xfce.org, product Xfce, component xfce4-panel). diff --git a/README.Kiosk b/README.Kiosk deleted file mode 100644 index 6f5c312fd..000000000 --- a/README.Kiosk +++ /dev/null @@ -1,20 +0,0 @@ -The Xfce Panel supports the KIOSK mode introduced with libxfce4util 4.1.13. It -provides the following KIOSK capabilities: - - CustomizePanel Only users with this capability will be allowed - to customize their panel (add panel plugins, - configure panel plugins, add launchers, etc.). - This is similar to setting the environment va- - riable XFCE_DISABLE_USER_CONFIG with the old - panel. - - -So a sample xfce4-panel section in your kioskrc might look like this: - ---- snip --- -[xfce4-panel] -CustomizePanel=%powerusers,foo ---- snip --- - -This allows only users in the group powerusers and the user foo to customize -their panels. diff --git a/README.Plugins b/README.Plugins deleted file mode 100644 index c269f5f08..000000000 --- a/README.Plugins +++ /dev/null @@ -1,4 +0,0 @@ -Information about the plugin system can be found on the Xfce wiki: - -http://wiki.xfce.org/panel_plugins_howto - diff --git a/TODO b/TODO new file mode 100644 index 000000000..7892e585c --- /dev/null +++ b/TODO @@ -0,0 +1,46 @@ +General +======= +* Improve the code layout, so it is consistent and easy to read. We should also + add more comments inside functions. (Nick & Jasper) + +Launcher +======== +* Finish the orientation code. I have no idea what to do here, because we + have no solution for the customizable arrow direction yet. (Nick) +* We also need a good way to popup the launcher menu when we drag over the + button. (Nick) + + +Panel +===== +* Re-evaluate interfaces. Make sure not too much implementation detail is + visible between separate parts of the panel. + + +Libxfce4panel +============= +* In xfce-panel-plugin-iface we use g_object_{get,set} all over the place, + this should be changed to reduce the number of relocations. +* Create some macros for common used code in plugins. This should make writing + consistent plugins easier. + + +Tasklist +======== +* We're going to rewrite the tasklist, see bug #2680 for more information. (Nick) + + +--- End of sane plans --- + +Blue Sky +======== + +* Transparency. The way cairo is integrated into gtk means we will need to + write our own widgets for panel plugins, because every widget with a window + needs to handle this separately :( See + http://www.loculus.nl/xfce/files/panel-cairo-20070125.patch for a quick + hack. + It would be much nicer if transparency were a style property, configurable + by a gtkrc file, but I don't think that will happen any time soon... + + diff --git a/autogen.sh b/autogen.sh index 5f26afa01..5fb36348e 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: autogen.sh 4312 2005-01-27 10:10:04Z jasper $ +# $Id: autogen.sh 25025 2007-02-24 09:54:07Z jasper $ # # Copyright (c) 2002-2005 # The Xfce development team. All rights reserved. @@ -32,13 +32,13 @@ linguas=`sed -e '/^#/d' po/LINGUAS` revision=`LC_ALL=C svn info $0 | awk '/^Revision: / {printf "%05d\n", $2}'` sed -e "s/@LINGUAS@/${linguas}/g" \ -e "s/@REVISION@/${revision}/g" \ - < "configure.ac.in" > "configure.ac" + < "configure.in.in" > "configure.in" xdt-autogen $@ # xdt-autogen clean does not remove all generated files (test x"clean" = x"$1") && { - rm -f configure.ac + rm -f configure.in rm -f INSTALL } || true # vi:set ts=2 sw=2 et ai: diff --git a/config/Makefile.am b/config/Makefile.am index abf7b46ab..7810d52d2 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -1,18 +1,35 @@ +# $Id$ + +confdir = \ + $(sysconfdir)/xdg/xfce4/panel + conf_in_files = \ launcher-7.rc.in \ launcher-8.rc.in \ launcher-9.rc.in \ launcher-10.rc.in -conf_files = $(conf_in_files:.rc.in=.rc) +conf_files = \ + $(conf_in_files:.rc.in=.rc) -confdir = $(sysconfdir)/xdg/xfce4/panel -conf_DATA = panels.xml systray-4.rc xfce4-menu-5.rc clock-14.rc $(conf_files) +conf_DATA = \ + panels.xml \ + systray-4.rc \ + xfce4-menu-5.rc \ + clock-14.rc \ + $(conf_files) # copied from INTLTOOL_DESKTOP_RULE %.rc: %.rc.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@ -EXTRA_DIST = panels.xml systray-4.rc xfce4-menu-5.rc clock-14.rc $(conf_in_files) +EXTRA_DIST = \ + panels.xml \ + systray-4.rc \ + xfce4-menu-5.rc \ + clock-14.rc \ + $(conf_in_files) -distclean-local: +distclean-local: rm -f $(conf_files) + +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/config/launcher-10.rc.in b/config/launcher-10.rc.in index 2769fdc2c..48b5a34e2 100644 --- a/config/launcher-10.rc.in +++ b/config/launcher-10.rc.in @@ -1,8 +1,11 @@ +[Global] +MoveFirst=false + [Entry 0] _Name=Web Browser +_Comment=Surf the internet +Icon=internet-web-browser Exec=exo-open --launch WebBrowser Terminal=false StartupNotify=false -_Comment=Surf the internet -X-XFCE-IconCategory=7 diff --git a/config/launcher-7.rc.in b/config/launcher-7.rc.in index 302384753..2742afec4 100644 --- a/config/launcher-7.rc.in +++ b/config/launcher-7.rc.in @@ -1,8 +1,10 @@ +[Global] +MoveFirst=false + [Entry 0] _Name=Command Prompt +_Comment=X terminal emulator +Icon=utilities-terminal Exec=Terminal Terminal=false StartupNotify=true -_Comment=X terminal emulator -X-XFCE-IconCategory=13 - diff --git a/config/launcher-8.rc.in b/config/launcher-8.rc.in index 7932935d9..35db767d0 100644 --- a/config/launcher-8.rc.in +++ b/config/launcher-8.rc.in @@ -1,8 +1,11 @@ +[Global] +MoveFirst=false + [Entry 0] _Name=Editor +_Comment=Edit text files +Icon=accessories-text-editor Exec=mousepad Terminal=false StartupNotify=true -_Comment=Edit text files -X-XFCE-IconCategory=1 diff --git a/config/launcher-9.rc.in b/config/launcher-9.rc.in index eb7ab575d..9b31dd332 100644 --- a/config/launcher-9.rc.in +++ b/config/launcher-9.rc.in @@ -1,8 +1,11 @@ +[Global] +MoveFirst=false + [Entry 0] _Name=File Manager +_Comment=Manage files and folders +Icon=Thunar Exec=thunar Terminal=false StartupNotify=true -_Comment=Manage files and folders -X-XFCE-IconCategory=2 diff --git a/configure.ac.in b/configure.ac.in deleted file mode 100644 index 491942313..000000000 --- a/configure.ac.in +++ /dev/null @@ -1,135 +0,0 @@ -dnl configure.ac -dnl -dnl xfce4 - panel for the Xfce Desktop environment -dnl -dnl 2005-2007 Jasper Huijsmans <jasper@xfce.org> -dnl - -dnl library version info -m4_define([libxfce4panel_verinfo], [2:2:1]) - -dnl panel version info -m4_define([xfce4_panel_version_major], [4]) -m4_define([xfce4_panel_version_minor], [4]) -m4_define([xfce4_panel_version_micro], [0]) -m4_define([xfce4_panel_version_nano], []) dnl leave this empty to have no nano version -m4_define([xfce4_panel_version_build], [@REVISION@]) -m4_define([xfce4_panel_version_tag], []) - -m4_define([xfce4_panel_version], [xfce4_panel_version_major().xfce4_panel_version_minor().xfce4_panel_version_micro()ifelse(xfce4_panel_version_nano(), [], [], [.xfce4_panel_version_nano()])ifelse(xfce4_panel_version_tag(), [svn], [xfce4_panel_version_tag()-xfce4_panel_version_build()], [xfce4_panel_version_tag()])]) - - - -dnl init autoconf -AC_COPYRIGHT([Copyright (c) 2002-2007 - The Xfce development team. All rights reserved. - -Written for Xfce by Jasper Huijsmans <jasper@xfce.org>.]) -AC_INIT([xfce4-panel], [xfce4_panel_version()], [xfce4-dev@xfce.org]) - -dnl init automake -XFCE4_PANEL_VERSION=xfce4_panel_version() -AM_INIT_AUTOMAKE([xfce4-panel], [$XFCE4_PANEL_VERSION]) -AM_CONFIG_HEADER([config.h]) -AM_MAINTAINER_MODE - -dnl Check for UNIX variants -AC_AIX -AC_ISC_POSIX -AC_MINIX -AM_CONDITIONAL([HAVE_CYGWIN], [test "`uname | grep \"CYGWIN\"`" != ""]) - -dnl disable static libs -AC_DISABLE_STATIC - -dnl Check for basic programs -AC_PROG_CC() -AC_PROG_INSTALL() -AC_PROG_LN_S() -AC_PROG_LIBTOOL() - -AC_PROG_INTLTOOL([0.31], [no-xml]) - -dnl patch intltool-update to support *.rc.in config files -AC_CONFIG_COMMANDS([intltool-update], - [(sed -e 's/^\("desktop.*".*\)/\1\n"rc(?:\\\\.in)+|"\./' intltool-update > intltool-update-tmp && - mv intltool-update-tmp intltool-update && chmod 755 intltool-update)]) - -LIBXFCE4PANEL_VERINFO=libxfce4panel_verinfo() -AC_SUBST([LIBXFCE4PANEL_VERINFO]) - -dnl Check for standard header files -AC_HEADER_STDC -AC_CHECK_HEADERS([signal.h stddef.h sys/wait.h time.h string.h sys/mman.h]) -AC_CHECK_FUNCS([sigaction]) -AC_FUNC_MMAP() - -dnl Check for i18n support -XDT_I18N([@LINGUAS@]) - -dnl Check for X11 installed -XDT_CHECK_LIBX11_REQUIRE -XDT_CHECK_LIBSM - -dnl Check for required packages -XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0]) -XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0]) -XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.4.0]) -XDT_CHECK_PACKAGE(LIBXFCE4MCS_MANAGER, libxfce4mcs-manager-1.0, 4.4.0) -XFCE_MCS_PLUGIN([XFCE_MCS_MANAGER], [4.4.0]) - -dnl Check for optional packages -XDT_CHECK_OPTIONAL_PACKAGE([LIBSTARTUP_NOTIFICATION], - [libstartup-notification-1.0], [0.5], - [startup-notification], - [startup notification library], [yes]) - -dnl install dummy scripts? -AC_ARG_ENABLE([dummy-scripts], - AC_HELP_STRING([--enable-dummy-scripts], - [Install empty scripts for the deprecated xftaskbar4 - and xfce4-iconbox (default=enabled)]), - [ac_cv_enable_dummy_scripts=$enableval], - [ac_cv_enable_dummy_scripts=yes]) -if test "x$ac_cv_enable_dummy_scripts" = "xno"; then - DUMMY_SCRIPTS="" -else - DUMMY_SCRIPTS="xftaskbar4 xfce4-iconbox" -fi -AC_SUBST(DUMMY_SCRIPTS) - -dnl gtk-doc -GTK_DOC_CHECK([1.0]) - -dnl Check for debugging support -XDT_FEATURE_DEBUG() - -AC_OUTPUT([ -xfce4-panel.spec -Makefile -config/Makefile -icons/Makefile -libxfce4panel/Makefile -libxfce4panel/libxfce4panel-1.0.pc -panel/Makefile -plugins/actions/Makefile -plugins/clock/Makefile -plugins/iconbox/Makefile -plugins/launcher/Makefile -plugins/Makefile -plugins/pager/Makefile -plugins/separator/Makefile -plugins/showdesktop/Makefile -plugins/systray/Makefile -plugins/tasklist/Makefile -plugins/windowlist/Makefile -mcs-plugin/Makefile -po/Makefile.in -docs/Makefile -docs/API/Makefile -docs/API/version.xml -docs/manual/Makefile -docs/manual/C/Makefile -docs/manual/C/images/Makefile -]) - diff --git a/configure.in.in b/configure.in.in new file mode 100644 index 000000000..1728d7c73 --- /dev/null +++ b/configure.in.in @@ -0,0 +1,205 @@ +dnl $Id$ +dnl +dnl Copyright (c) 2004-2006 +dnl The Xfce development team. All rights reserved. +dnl +dnl 2005-2007 Jasper Huijsmans <jasper@xfce.org> +dnl 2006-2007 Nick Schermer <nick@xfce.org> +dnl + +dnl *************************** +dnl *** Version information *** +dnl *************************** +m4_define([libxfce4panel_verinfo], [2:2:1]) +m4_define([xfce4_panel_version_major], [4]) +m4_define([xfce4_panel_version_minor], [5]) +m4_define([xfce4_panel_version_micro], [0]) +m4_define([xfce4_panel_version_nano], [2]) dnl leave this empty to have no nano version +m4_define([xfce4_panel_version_build], [r@REVISION@]) +m4_define([xfce4_panel_version_tag], [svn]) +m4_define([xfce4_panel_version], [xfce4_panel_version_major().xfce4_panel_version_minor().xfce4_panel_version_micro()ifelse(xfce4_panel_version_nano(), [], [], [.xfce4_panel_version_nano()])ifelse(xfce4_panel_version_tag(), [svn], [xfce4_panel_version_tag()-xfce4_panel_version_build()], [xfce4_panel_version_tag()])]) + +dnl *************************** +dnl *** Initialize autoconf *** +dnl *************************** +AC_COPYRIGHT([Copyright (c) 2002-2007 + The Xfce development team. All rights reserved. + +Written for Xfce by Jasper Huijsmans <jasper@xfce.org>.]) +AC_INIT([xfce4-panel], [xfce4_panel_version()], [http://bugzilla.xfce.org/], [xfce4-panel]) +AC_PREREQ([2.50]) +AC_REVISION([$Id$]) + +dnl *************************** +dnl *** Initialize automake *** +dnl *************************** +AM_CONFIG_HEADER([config.h]) +AM_INIT_AUTOMAKE([1.8 dist-bzip2 tar-ustar]) +AM_MAINTAINER_MODE() + +dnl ******************************* +dnl *** Check for UNIX variants *** +dnl ******************************* +AC_AIX() +AC_ISC_POSIX() +AC_MINIX() +AM_CONDITIONAL([HAVE_CYGWIN], [test "`uname | grep \"CYGWIN\"`" != ""]) + +dnl ******************************** +dnl *** Check for basic programs *** +dnl ******************************** +AC_PROG_CC() +AC_PROG_INSTALL() +AC_PROG_LN_S() +AC_PROG_INTLTOOL([0.31], [no-xml]) + +dnl ************************** +dnl *** Initialize libtool *** +dnl ************************** +AC_DISABLE_STATIC() +AC_PROG_LIBTOOL() + +dnl **************************** +dnl *** Intltool-update hack *** +dnl **************************** +AC_CONFIG_COMMANDS([intltool-update], + [(sed -e 's/^\("desktop.*".*\)/\1\n"rc(?:\\\\.in)+|"\./' intltool-update > intltool-update-tmp && + mv intltool-update-tmp intltool-update && chmod 755 intltool-update)]) + +dnl ************************************** +dnl *** Substitute version information *** +dnl ************************************** +LIBXFCE4PANEL_VERINFO=libxfce4panel_verinfo() +AC_SUBST([LIBXFCE4PANEL_VERINFO]) + +dnl ********************************** +dnl *** Check for standard headers *** +dnl ********************************** +AC_HEADER_STDC() +AC_CHECK_HEADERS([stdlib.h unistd.h locale.h stdio.h fcntl.h errno.h \ + math.h signal.h stddef.h sys/wait.h sys/stat.h \ + sys/type.h sys/mman.h time.h string.h]) + +dnl ************************************ +dnl *** Check for standard functions *** +dnl ************************************ +AC_FUNC_MMAP() +AC_CHECK_FUNCS([sigaction]) + +dnl ****************************** +dnl *** Check for i18n support *** +dnl ****************************** +XDT_I18N([@LINGUAS@]) + +dnl ******************************* +dnl *** Check for X11 installed *** +dnl ******************************* +XDT_CHECK_LIBX11_REQUIRE() +XDT_CHECK_LIBSM() + +dnl *********************************** +dnl *** Check for required packages *** +dnl *********************************** +XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0]) +XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.4]) +XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.6.4]) +XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.4.0]) +XDT_CHECK_PACKAGE([LIBEXO], [exo-0.3], [0.3.1.11]) + +dnl *********************************** +dnl *** Check for optional packages *** +dnl *********************************** +XDT_CHECK_OPTIONAL_PACKAGE([XFCE_MCS_MANAGER], + [xfce-mcs-manager], + [4.4.0], [mcs-plugin], + [xfce-mcs-manager], [yes]) + +XDT_CHECK_OPTIONAL_PACKAGE([LIBSTARTUP_NOTIFICATION], + [libstartup-notification-1.0], + [0.5], [startup-notification], + [startup notification library], [yes]) + +dnl ******************************* +dnl *** Check for dummy scripts *** +dnl ******************************* +AC_ARG_ENABLE([dummy-scripts], + AC_HELP_STRING([--enable-dummy-scripts], + [Install empty scripts for the deprecated xftaskbar4 and xfce4-iconbox @<:@default=enabled@:>@]), + [enable_dummy_scripts=$enableval], + [enable_dummy_scripts=yes]) +AM_CONDITIONAL([ENABLE_DUMMY_SCRIPTS], [test x"$enable_dummy_scripts" = x"yes"]) + + +dnl ************************* +dnl *** Check for gtk-doc *** +dnl ************************* +GTK_DOC_CHECK([1.0]) + +dnl *********************************** +dnl *** Check for debugging support *** +dnl *********************************** +XDT_FEATURE_DEBUG() + +dnl ********************************* +dnl *** Substitute platform flags *** +dnl ********************************* +AC_MSG_CHECKING([PLATFORM_CPPFLAGS]) +AC_MSG_RESULT([$PLATFORM_CPPFLAGS]) +AC_SUBST([PLATFORM_CPPFLAGS]) +AC_MSG_CHECKING([PLATFORM_CFLAGS]) +AC_MSG_RESULT([$PLATFORM_CFLAGS]) +AC_SUBST([PLATFORM_CFLAGS]) +AC_MSG_CHECKING([PLATFORM_LDFLAGS]) +AC_MSG_RESULT([$PLATFORM_LDFLAGS]) +AC_SUBST([PLATFORM_LDFLAGS]) + +AC_OUTPUT([ +xfce4-panel.spec +Makefile +config/Makefile +icons/Makefile +icons/16x16/Makefile +icons/48x48/Makefile +libxfce4panel/Makefile +libxfce4panel/libxfce4panel-1.0.pc +panel/Makefile +plugins/actions/Makefile +plugins/clock/Makefile +plugins/iconbox/Makefile +plugins/launcher/Makefile +plugins/Makefile +plugins/pager/Makefile +plugins/separator/Makefile +plugins/showdesktop/Makefile +plugins/systray/Makefile +plugins/tasklist/Makefile +plugins/windowlist/Makefile +mcs-plugin/Makefile +po/Makefile.in +docs/Makefile +docs/API/Makefile +docs/API/version.xml +docs/manual/Makefile +docs/manual/C/Makefile +docs/manual/C/images/Makefile +]) + +dnl *************************** +dnl *** Print configuration *** +dnl *************************** +echo +echo "Build Configuration:" +echo +if test x"$LIBSTARTUP_NOTIFICATION_FOUND" = x"yes"; then +echo "* Startup Notification: yes" +else +echo "* Startup Notification: no" +fi +if test x"$XFCE_MCS_MANAGER_FOUND" = x"yes"; then +echo "* Xfce Settings Manager plugin: yes" +else +echo "* Xfce Settings Manager plugin: no" +fi +echo "* Debugging Support: $enable_debug" +echo "* Dummy Scripts: $enable_dummy_scripts" +echo diff --git a/icons/16x16/Makefile.am b/icons/16x16/Makefile.am new file mode 100644 index 000000000..94747bbba --- /dev/null +++ b/icons/16x16/Makefile.am @@ -0,0 +1,15 @@ +# $Id$ + +iconsdir = $(datadir)/icons/hicolor/16x16/apps + +icons_DATA = \ + xfce-system-settings.png \ + xfce-system-lock.png \ + xfce-system-info.png \ + xfce-system-exit.png + + +EXTRA_DIST = \ + $(icons_DATA) + +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/icons/xfce-system-exit.png b/icons/16x16/xfce-system-exit.png similarity index 100% rename from icons/xfce-system-exit.png rename to icons/16x16/xfce-system-exit.png diff --git a/icons/xfce-system-info.png b/icons/16x16/xfce-system-info.png similarity index 100% rename from icons/xfce-system-info.png rename to icons/16x16/xfce-system-info.png diff --git a/icons/xfce-system-lock.png b/icons/16x16/xfce-system-lock.png similarity index 100% rename from icons/xfce-system-lock.png rename to icons/16x16/xfce-system-lock.png diff --git a/icons/xfce-system-settings.png b/icons/16x16/xfce-system-settings.png similarity index 100% rename from icons/xfce-system-settings.png rename to icons/16x16/xfce-system-settings.png diff --git a/icons/48x48/Makefile.am b/icons/48x48/Makefile.am new file mode 100644 index 000000000..4db55338a --- /dev/null +++ b/icons/48x48/Makefile.am @@ -0,0 +1,14 @@ +# $Id$ + +iconsdir = $(datadir)/icons/hicolor/48x48/apps + +icons_DATA = \ + xfce4-panel.png \ + xfce4-iconbox.png \ + xfce4-taskbar.png \ + xfce-mouse.png + +EXTRA_DIST = \ + $(icons_DATA) + +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/icons/xfce-mouse.png b/icons/48x48/xfce-mouse.png similarity index 100% rename from icons/xfce-mouse.png rename to icons/48x48/xfce-mouse.png diff --git a/icons/xfce4-iconbox.png b/icons/48x48/xfce4-iconbox.png similarity index 100% rename from icons/xfce4-iconbox.png rename to icons/48x48/xfce4-iconbox.png diff --git a/icons/xfce4-panel.png b/icons/48x48/xfce4-panel.png similarity index 100% rename from icons/xfce4-panel.png rename to icons/48x48/xfce4-panel.png diff --git a/icons/xfce4-taskbar.png b/icons/48x48/xfce4-taskbar.png similarity index 100% rename from icons/xfce4-taskbar.png rename to icons/48x48/xfce4-taskbar.png diff --git a/icons/Makefile.am b/icons/Makefile.am index d7c5ed4be..438362ceb 100644 --- a/icons/Makefile.am +++ b/icons/Makefile.am @@ -1,23 +1,8 @@ # $Id$ -hicolor48dir = $(datadir)/icons/hicolor/48x48/apps - -hicolor16dir = $(datadir)/icons/hicolor/16x16/apps - -hicolor48_DATA = \ - xfce4-panel.png \ - xfce4-iconbox.png \ - xfce4-taskbar.png \ - xfce-mouse.png \ - xfce-mail.png - -hicolor16_DATA = \ - xfce-system-exit.png \ - xfce-system-info.png \ - xfce-system-lock.png \ - xfce-system-settings.png - -EXTRA_DIST = $(hicolor48_DATA) $(hicolor16_DATA) +SUBDIRS = \ + 16x16 \ + 48x48 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor @@ -32,4 +17,4 @@ install-data-hook: echo "***"; \ fi -# vi:set ts=8 sw=8 noet ai nocindent: +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/icons/xfce-mail.png b/icons/xfce-mail.png deleted file mode 100644 index fd9ead2cb26c2dfad7daed257f25d76b6dcdcc42..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2643 zcmV-Z3as^sP)<h;3K|Lk000e1NJLTq001xm001xu1^@s6R|5Hm00004b3#c}2nYxW zd<bNS0000PbVXQnQ*UN;cVTj60C#tHE@^ISb7Ns}WiD@WXPfRk8UO$Z<w-<ARA_<i znR{>*)g8w_XYbxeZf;0OAb}DE1$ho&M8qec;ER`9p-PLLKE{^%>~!ou9Xn2EoR0mY zo#{+#9c%qZTPsyt<s}moRE8?}=B)(+<V8qGa&zzQ-rYUt*FSCy2?-&jAa=&@%$=Rt zb9VRhJ?DGQ**#Z@2>;Kr&NsmSs;>>4Z+&gxTu3QZpp=RXr0!S7fKsYhDOIJE`ZKT& z7(Sp2MdZBv$T!|_U=gs^w(VA>loS=EjAdB{SU8~je96#JU=;9>Qfhl767g)?mMN1a z>R<fyLD{`&gWSJjxlA8-aR59CsMFokKI>UHNlK|CZ~?F~5{WDkF=Gk}lIn`8OJ&)j z1=g~g=2Mi2S`r4hnGAn@bu~X*a+7_qu6};n^@@SE{_cNH3@D{afGXhrsBO;;!mzA- z_;54tx@)ZEOBQkCtjj@%iZDO|58d7YfzKOnZDH!D5zMNrzzc$lfU&>_=iGo&$^y!O z#Y(B~+qOMJL<+`UG{!8xah~<v+m|rm!b(em91@0@^l=D7B=9j#7I8Yz9cljfw->qX z(n-W5WP0TYe|t^c!gFRoDHQ`o0{7asz04RhHWrITs-{gf-&%O9b@zgsDM=<Q0v`zj zbXzlo0g}sMoD3$L#$-B>Acq*u(bjf8I9SVHzO#r!$6C4JlF<cw8k%lWO8rJea%aVW zQmPP`0z43nMsE(oaQM)Y66Rigm0G@d0Sm6X3d@)-Xw#NO!T|AHOtvEroy~v_5u-ut zuH#GZe#9-4E}{rcLIP%t7^(toW^^`E&7ce@r4&#C%vVbNIBMHhhFTYnzM#@9nm^CF z=eC7RyJRc`J`w~-M;j&x^3ia!CtBHa!DvM5p2tpjjAqpbJ9%vWER5?gL>Y!!P*IpL zhugFBfoBG6pmPPR0Pcy}_6j31(XuRi+LXy=>8&?gD;D3%upvd=TDc_;?|T?0gJja^ zY#M@~8=&b0-5q{UV>2xomup6pAf7|Ygoy7le{^~L`CT;&lv2-%i0RjWQmPzyG#-oH z=?B5cRAC{rubjp5B@5M(IoA?ZVo4Anp`V8i1B~nB2Vf?RIGG+`J>X9|*BxH8=B1DK zamV;dRL;d1O;l@QI$-9oqR1*`UFV}qf#%coz(nA|(Uqfk=84CdIe9{U(1iiwq)$Y{ z$>j5#Nh7}3)v~<+jYhQTyQ~|$(IGGIImmOj%*1$3m+6!V8I!O;F$B0Ac>Qz+K20T) z&9<0f&p!7&6CVBvg;5L1d6;Yl$>v)c9rns{Pw11&diOy0C~d7fMoH9WLSY1Povv$B zI;6?-m|dRY^}6=O12NF<2f2-R&belpLL%3FZzWIu@Ghz<h9buFXtf@IeGSf2!S~S{ zFYP_TH^-FqfX5gTT4Mz{t}c$p-f6OKR7#~pBy&mwA|gtu)vMlo`}X&r`fa3YL@CRE z_cTA6eK`-$xdJ68B5`sI`iAcg+IN&ZKVZX=W*)g=0^&K{27121igb?21s0x`FIMGG z`s)FJO@|vAO<iLHbEiz8`hjn=@`bf**?WLL-Z78i$=F$eZ}D=xS>MKMwXIy7j8RU2 z@jCC@ZIfY$ZP6MSrWVD558HE#`Z93x_rNjRifrHf{zs^2l#vOWS61B0jFDx`e`*z* z_U=bq2l1Tz4AjR_TnFQIp7Y$UbDtkO&YyN1;?6gBbJhBtyn48W8%pE+a$GSl)U@E_ zf*$Yy$%uueU~XBWAQ@2$lv2@tdq6}&rPSJgY}q#JuB&GxR3w7RxcvNz30zfC%tPz8 zvUEZvkIWd4jp=th1YyYg$I@)9Pg8v~O-G=)epr$pRHm3cwTxs$bv<`lQH)oQX1O>S z<<cRs6RoQt6|txq5+@WcBfmb?c4t;6?+YoVCdZ@pC;NZ@D?6TTB{=k-u1vN#E)Q?| zlny`O57$m&RDs<iQfbd;b7MQz4ee}h$}lovGjCV{^U4xTFN$F)`qhpOpM9Bt+bWVo zJ1e&ZhB_}~<&I{j)(amLk!Me5ps*w!+xE=8cTJu<ehl7@Z4icCtEm{x)4OYVYHvNi zuDXE9MR7LPw^7}g=HphE86}BM=s2SiXa26}YT?zRSuQJ%Grlm27TA~dd9gmL|6bSe zFJD+D-Jp9tK}50<r8cbjVAr_0ms}WAmW}q((Af)OH201!W@b@@mD>;F8{zt4Nmh(Z z^7NF_9?=+#3L=WTzmekIR*%;*0gK9$BrS`XC9%lM4Qj5hrN>83uO0wUN?kv+uwcX9 z$L@>jhQkCkpZB?%zEYp&_KL#OMq{vQ3k<899I86U#qtlE{ERk>M5OwQI;Yx|_*Cco zmfbbASjiOPX7e+P>mWH70-w)1JSL{1=LB8=M+>0{vr7}~&IEkY?sIKf91E6ouX`#3 zt)9_uRqxram1U!B8^Qp(y%6s1@R^*7o#OH{mlo&<4M%gDLrzFzE+icqv<R0M#~7cA z62*!YMy-WPsYJg9M8x=pwJ+^D5CB9<D|(dYj1WHyO&=JcEilx3A&1<6W4<P<4Tcl3 zuJbhiY{;5N_Z`n}Xm)&U<TIe?i}L=aiOq+bTTNp+LwQ*_LG6LAg13)*%qc4v6trgq zM+@1|5cDzrw1M5(fGx*ee^aw-Tq8LRTXI@f18aR~5D`5P15LKYwk`XQ%voABNvT*I z@$;Xi+0YDlwlM;(F*rI8uKR%Q2!)T@bG*^wy4%}wb}XXm9c`+$VKuM?XqCQZoBj-l zNKPrW{^h+jS1zrZl!%lLCv2?cfD<sbu-A&-Ls}rK^U$sqgx=4t^EB_Z=1g_7;~sRw zXxw6FCX{u+YdIr(`g-#`BLkgUzqO{}aVH3fmzEPY*79lE=k^hWy(;=f$ZEmShMYN7 zG<>$Sc)_L?SGz`X2DW-y)&lDTL#>GT1A#sh1BVkzKHq+*Ve*`@m4qtNwZsegRnygm zZ0D4BveKd9!*-udozaLZ)sPkQrZ%hr-T_*==Xo&d*MNw$N0h2wyYJArIpZ#jZ6n2H z#W{}VG_IB&v&9!W;%eS&%gM%O$35hR(S)UTrbDv<Se--m0Bxtr^I10lU|`K_du#4{ zV!^dEWj#h9&<#8=ush?k^>|k_eBj@Xmi55vzL8oH$(}9XGd2M1(7xaN_P&E76WLZM zjM5$$K1};;ZgIWsZ8<v;Q4JZ*W^K$m^3gapm^=?geZC9zsGyV`vv_WLY3i;Sg%RFp zcDx!lw3C+F)gGFSz#3o=XCcpn(P<3;D5dT$h^QwOY<IL&liwkz6_I|ozP}6&)IbGL z05pk+bIz&GKm#)HRn}MLPrkwGYXj$7UmG~z`Y)Lbq@H~sO+Nqt002ovPDHLkV1n0v B`^NwP diff --git a/libxfce4panel/Makefile.am b/libxfce4panel/Makefile.am index 0833de456..c580e9c73 100644 --- a/libxfce4panel/Makefile.am +++ b/libxfce4panel/Makefile.am @@ -1,94 +1,106 @@ -lib_LTLIBRARIES = libxfce4panel.la +# $Id: Makefile.am 24484 2007-01-15 17:20:39Z nick $ -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libxfce4panel-1.0.pc +INCLUDES = \ + -I$(top_srcdir) \ + -DG_LOG_DOMAIN=\"libxfce4panel\" \ + -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \ + $(PLATFORM_CPPFLAGS) -generated_files = \ - xfce-panel-enum-types.c \ - xfce-panel-enum-types.h \ - xfce-marshal.c \ - xfce-marshal.h +lib_LTLIBRARIES = \ + libxfce4panel.la -libxfce4panel_la_SOURCES = \ - $(generated_files) \ - xfce-panel-window.c \ - xfce-panel-window.h \ - xfce-arrow-button.c \ - xfce-arrow-button.h \ - xfce-itembar.c \ - xfce-itembar.h \ - xfce-hvbox.c \ - xfce-hvbox.h \ - xfce-panel-enums.h \ - xfce-panel-convenience.c \ - xfce-panel-convenience.h \ - xfce-panel-external-item.c \ - xfce-panel-external-item.h \ - xfce-panel-external-plugin.c \ - xfce-panel-external-plugin.h \ - xfce-panel-internal-plugin.c \ - xfce-panel-internal-plugin.h \ - xfce-panel-item-iface.c \ - xfce-panel-item-iface.h \ - xfce-panel-plugin-iface.c \ - xfce-panel-plugin-iface.h \ - xfce-panel-plugin-iface-private.h \ - xfce-panel-plugin-messages.c \ +libxfce4panel_la_SOURCES = \ + $(generated_files) \ + xfce-panel-window.c \ + xfce-panel-window.h \ + xfce-arrow-button.c \ + xfce-arrow-button.h \ + xfce-itembar.c \ + xfce-itembar.h \ + xfce-hvbox.c \ + xfce-hvbox.h \ + xfce-panel-enums.h \ + xfce-panel-convenience.c \ + xfce-panel-convenience.h \ + xfce-panel-external-item.c \ + xfce-panel-external-item.h \ + xfce-panel-external-plugin.c \ + xfce-panel-external-plugin.h \ + xfce-panel-internal-plugin.c \ + xfce-panel-internal-plugin.h \ + xfce-panel-item-iface.c \ + xfce-panel-item-iface.h \ + xfce-panel-plugin-iface.c \ + xfce-panel-plugin-iface.h \ + xfce-panel-plugin-iface-private.h \ + xfce-panel-plugin-messages.c \ xfce-panel-plugin-messages.h -xfce4_panelincludedir = $(includedir)/xfce4/libxfce4panel - -xfce4_panelinclude_HEADERS = \ - xfce-panel-enum-types.h \ - xfce-panel-window.h \ - xfce-arrow-button.h \ - xfce-itembar.h \ - xfce-hvbox.h \ - xfce-panel-enums.h \ - xfce-panel-convenience.h \ - xfce-panel-plugin-iface.h \ - xfce-panel-internal-plugin.h \ - xfce-panel-external-plugin.h \ - xfce-panel-macros.h \ +xfce4_panelincludedir = \ + $(includedir)/xfce4/libxfce4panel + +xfce4_panelinclude_HEADERS = \ + xfce-panel-enum-types.h \ + xfce-panel-window.h \ + xfce-arrow-button.h \ + xfce-itembar.h \ + xfce-hvbox.h \ + xfce-panel-enums.h \ + xfce-panel-convenience.h \ + xfce-panel-plugin-iface.h \ + xfce-panel-internal-plugin.h \ + xfce-panel-external-plugin.h \ + xfce-panel-macros.h \ xfce-panel-plugin.h - -libxfce4panel_la_CFLAGS = \ - -I$(top_srcdir) \ - -DLOCALEDIR=\"$(localedir)\" \ - @LIBXFCE4UTIL_CFLAGS@ \ - @LIBXFCEGUI4_CFLAGS@ - -libxfce4panel_la_LDFLAGS = \ - -export-dynamic \ - -version-info @LIBXFCE4PANEL_VERINFO@ - -libxfce4panel_la_LIBADD = \ - @LIBXFCEGUI4_LIBS@ \ - @LIBXFCE4UTIL_LIBS@ + +libxfce4panel_la_CFLAGS = \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(GTK_CFLAGS) \ + $(PLATFORM_CFLAGS) + +libxfce4panel_la_LDFLAGS = \ + -export-dynamic \ + -version-info $(LIBXFCE4PANEL_VERINFO) \ + $(PLATFORM_LDFLAGS) if HAVE_CYGWIN - libxfce4panel_la_LDFLAGS += -no-undefined - libxfce4panel_la_LIBADD += @GTK_LIBS@ - libxfce4panel_la_CFLAGS += @GTK_CFLAGS@ +libxfce4panel_la_LDFLAGS += \ + -no-undefined endif -EXTRA_DIST = \ - xfce-marshal.list \ +libxfce4panel_la_LIBADD = \ + $(GTK_LIBS) \ + $(LIBXFCE4UTIL_LIBS) + +pkgconfigdir = \ + $(libdir)/pkgconfig + +pkgconfig_DATA = \ + libxfce4panel-1.0.pc + +generated_files = \ + xfce-panel-enum-types.c \ + xfce-panel-enum-types.h \ + xfce-marshal.c \ + xfce-marshal.h + +EXTRA_DIST = \ + xfce-marshal.list \ $(generated_files) -DISTCLEANFILES = \ +DISTCLEANFILES = \ $(generated_files) -xfce_headers = \ - $(srcdir)/xfce-panel-window.h \ +xfce_headers = \ + $(srcdir)/xfce-panel-window.h \ $(srcdir)/xfce-panel-enums.h xfce-panel-enum-types.h: $(xfce_headers) ( cd $(srcdir) && glib-mkenums \ - --fhead "#ifndef _XFCE_PANEL_ENUM_TYPES_H\n#define _XFCE_PANEL_ENUM_TYPES_H\n#include <libxfce4util/libxfce4util.h>\nG_BEGIN_DECLS\n" \ + --fhead "#ifndef __XFCE_PANEL_ENUM_TYPES_H__\n#define __XFCE_PANEL_ENUM_TYPES_H__\n#include <libxfce4util/libxfce4util.h>\nG_BEGIN_DECLS\n" \ --fprod "/* enumerations from \"@filename@\" */\n#include <libxfce4panel/@filename@>\n" \ - --vhead "GType @enum_name@_get_type (void);\n#define XFCE_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \ - --ftail "G_END_DECLS\n\n#endif /* _XFCE_PANEL_ENUM_TYPES_H__ */" \ + --vhead "GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define XFCE_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \ + --ftail "G_END_DECLS\n\n#endif /* !__XFCE_PANEL_ENUM_TYPES_H__ */" \ $(xfce_headers) ) >> xgen \ && (cmp -s xgen xfce-panel-enum-types.h || cp xgen xfce-panel-enum-types.h ) \ && rm -f xgen xgen~ @@ -97,22 +109,26 @@ xfce-panel-enum-types.c: xfce-panel-enum-types.h ( cd $(srcdir) && glib-mkenums \ --fhead "#include <xfce-panel-enum-types.h>\n" \ --fprod "\n/* enumerations from \"@filename@\" */\n" \ - --vhead "GType\n@enum_name@_get_type (void)\n{\n\tstatic GType type = 0;\n\tif (type == 0) {\n\tstatic const G@Type@Value values[] = {"\ + --vhead "GType\n@enum_name@_get_type (void)\n{\n\tstatic GType type = 0;\n\tif (type == 0) {\n\tstatic const G@Type@Value values[] = {" \ --vprod "\t{ @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \ --vtail "\t{ 0, NULL, NULL }\n\t};\n\ttype = g_@type@_register_static (\"@EnumName@\", values);\n }\n\treturn type;\n}\n" \ $(xfce_headers) ) > xgen \ - && cp xgen xfce-panel-enum-types.c \ + && cp xgen xfce-panel-enum-types.c \ && rm -f xgen xgen~ xfce-marshal.h: $(srcdir)/xfce-marshal.list - glib-genmarshal --header --prefix="_xfce_marshal" \ - $(srcdir)/xfce-marshal.list > tmp-marshal.h && \ - cp tmp-marshal.h $(@F) && \ - rm -f tmp-marshal.h tmp-marshal.h~ - + ( cd $(srcdir) && glib-genmarshal \ + --prefix="_xfce_marshal" \ + --header xfce-marshal.list \ + | sed -e 's/marshal_data);$$/marshal_data) G_GNUC_INTERNAL;/' ) > xgen-xpmh \ + && cp xgen-xpmh $(@F) \ + && rm -f xgen-xpmh xgen-xpmh~ + xfce-marshal.c: xfce-marshal.h - glib-genmarshal --body --prefix="_xfce_marshal" \ - $(srcdir)/xfce-marshal.list > tmp-marshal.c && \ - cp tmp-marshal.c $(@F) && \ - rm -f tmp-marshal.c tmp-marshal.c~ + ( cd $(srcdir) && glib-genmarshal \ + --prefix="_xfce_marshal" \ + --body xfce-marshal.list ) > xgen-xpmc \ + && cp xgen-xpmc xfce-marshal.c \ + && rm -f xgen-xpmc xgen-xpmc~ +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/libxfce4panel/libxfce4panel-1.0.pc.in b/libxfce4panel/libxfce4panel-1.0.pc.in index 6204e3433..3d990a9ea 100644 --- a/libxfce4panel/libxfce4panel-1.0.pc.in +++ b/libxfce4panel/libxfce4panel-1.0.pc.in @@ -1,18 +1,11 @@ prefix=@prefix@ -datadir=@datadir@ exec_prefix=@exec_prefix@ libdir=@libdir@ -libexecdir=@libexecdir@ includedir=@includedir@ -localedir=@localedir@ - -internalplugindir=${libdir}/xfce4/panel-plugins -externalplugindir=${libexecdir}/xfce4/panel-plugins -desktopdatadir=${datadir}/xfce4/panel-plugins Name: libxfce4panel Description: Library for the Xfce Panel -Requires: libxfcegui4-1.0 libxfce4util-1.0 -Version: @VERSION@ +Requires: libxfce4util-1.0 libxfcegui4-1.0 +Version: @PACKAGE_VERSION@ Libs: -L${libdir} -lxfce4panel Cflags: -I${includedir}/xfce4/ diff --git a/libxfce4panel/xfce-arrow-button.c b/libxfce4panel/xfce-arrow-button.c index f7ebb5889..62756f940 100644 --- a/libxfce4panel/xfce-arrow-button.c +++ b/libxfce4panel/xfce-arrow-button.c @@ -1,22 +1,21 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2004-2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2004-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H @@ -29,6 +28,7 @@ #include <gtk/gtk.h> #include "xfce-marshal.h" +#include "xfce-panel-macros.h" #include "xfce-panel-enum-types.h" #include "xfce-arrow-button.h" @@ -53,73 +53,66 @@ enum PROP_ARROW_TYPE }; +static void xfce_arrow_button_class_init (XfceArrowButtonClass *klass); +static void xfce_arrow_button_init (XfceArrowButton *button); +static void xfce_arrow_button_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void xfce_arrow_button_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static gint xfce_arrow_button_expose (GtkWidget *widget, + GdkEventExpose *event); +static void xfce_arrow_button_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void xfce_arrow_button_add (GtkContainer *container, + GtkWidget *child); +static GType xfce_arrow_button_child_type (GtkContainer *container); -static void xfce_arrow_button_class_init (XfceArrowButtonClass * klass); - -static void xfce_arrow_button_init (XfceArrowButton * button); - -static void xfce_arrow_button_set_property (GObject * object, - guint prop_id, - const GValue * value, - GParamSpec * pspec); - -static void xfce_arrow_button_get_property (GObject * object, - guint prop_id, - GValue * value, - GParamSpec * pspec); - -static int xfce_arrow_button_expose (GtkWidget * widget, - GdkEventExpose * event); -static void xfce_arrow_button_size_request (GtkWidget * widget, - GtkRequisition * requisition); -static void xfce_arrow_button_add (GtkContainer * container, - GtkWidget *child); - -static GType xfce_arrow_button_child_type (GtkContainer * container); - - - /* global vars */ static GtkToggleButtonClass *parent_class = NULL; +static guint arrow_button_signals[LAST_SIGNAL] = { 0 }; -static guint arrow_button_signals[LAST_SIGNAL] = { 0 }; GType xfce_arrow_button_get_type (void) { - static GtkType type = 0; + static GtkType type = G_TYPE_INVALID; - if (!type) + if (G_UNLIKELY (type == G_TYPE_INVALID)) { - static const GTypeInfo type_info = { - sizeof (XfceArrowButtonClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) xfce_arrow_button_class_init, - (GClassFinalizeFunc) NULL, - NULL, - sizeof (XfceArrowButton), - 0, /* n_preallocs */ - (GInstanceInitFunc) xfce_arrow_button_init, + static const GTypeInfo type_info = { + sizeof (XfceArrowButtonClass), + NULL, + NULL, + (GClassInitFunc) xfce_arrow_button_class_init, + NULL, + NULL, + sizeof (XfceArrowButton), + 0, + (GInstanceInitFunc) xfce_arrow_button_init, NULL - }; + }; - type = g_type_register_static (GTK_TYPE_TOGGLE_BUTTON, - "XfceArrowButton", &type_info, 0); + type = + g_type_register_static (GTK_TYPE_TOGGLE_BUTTON, I_("XfceArrowButton"), &type_info, 0); } return type; } + static void xfce_arrow_button_class_init (XfceArrowButtonClass * klass) { - GObjectClass *gobject_class; - GtkWidgetClass *widget_class; + GObjectClass *gobject_class; + GtkWidgetClass *widget_class; GtkContainerClass *container_class; parent_class = g_type_class_peek_parent (klass); @@ -130,9 +123,9 @@ xfce_arrow_button_class_init (XfceArrowButtonClass * klass) gobject_class->get_property = xfce_arrow_button_get_property; gobject_class->set_property = xfce_arrow_button_set_property; - widget_class->expose_event = xfce_arrow_button_expose; - widget_class->size_request = xfce_arrow_button_size_request; - + widget_class->expose_event = xfce_arrow_button_expose; + widget_class->size_request = xfce_arrow_button_size_request; + container_class->add = xfce_arrow_button_add; container_class->child_type = xfce_arrow_button_child_type; @@ -147,14 +140,14 @@ xfce_arrow_button_class_init (XfceArrowButtonClass * klass) * This value also determines the direction of the popup menu. **/ arrow_button_signals[ARROW_TYPE_CHANGED] = - g_signal_new ("arrow-type-changed", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (XfceArrowButtonClass, - arrow_type_changed), - NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, GTK_TYPE_ARROW_TYPE); + g_signal_new (I_("arrow-type-changed"), + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (XfceArrowButtonClass, + arrow_type_changed), + NULL, NULL, + g_cclosure_marshal_VOID__ENUM, + G_TYPE_NONE, 1, GTK_TYPE_ARROW_TYPE); /* properties */ @@ -164,16 +157,18 @@ xfce_arrow_button_class_init (XfceArrowButtonClass * klass) * The arrow type of the button. This value also determines the direction * of the popup menu. **/ - g_object_class_install_property (gobject_class, - PROP_ARROW_TYPE, - g_param_spec_enum ("arrow-type", - "Arrow type", - "The arrow type of the menu button", - GTK_TYPE_ARROW_TYPE, - GTK_ARROW_UP, - G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_ARROW_TYPE, + g_param_spec_enum ("arrow-type", + "Arrow type", + "The arrow type of the menu button", + GTK_TYPE_ARROW_TYPE, + GTK_ARROW_UP, + G_PARAM_READWRITE)); } + + static void xfce_arrow_button_init (XfceArrowButton * arrow_button) { @@ -182,58 +177,65 @@ xfce_arrow_button_init (XfceArrowButton * arrow_button) arrow_button->arrow_type = DEFAULT_ARROW_TYPE; } + + static void -xfce_arrow_button_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec) +xfce_arrow_button_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { XfceArrowButton *button = XFCE_ARROW_BUTTON (object); switch (prop_id) { - case PROP_ARROW_TYPE: - xfce_arrow_button_set_arrow_type (button, - g_value_get_enum (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; + case PROP_ARROW_TYPE: + xfce_arrow_button_set_arrow_type (button, g_value_get_enum (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; } } + + static void -xfce_arrow_button_get_property (GObject * object, - guint prop_id, GValue * value, - GParamSpec * pspec) +xfce_arrow_button_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { XfceArrowButton *button = XFCE_ARROW_BUTTON (object); switch (prop_id) { - case PROP_ARROW_TYPE: - g_value_set_enum (value, button->arrow_type); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; + case PROP_ARROW_TYPE: + g_value_set_enum (value, button->arrow_type); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; } } -static int -xfce_arrow_button_expose (GtkWidget * widget, GdkEventExpose *event) + + +static gint +xfce_arrow_button_expose (GtkWidget *widget, + GdkEventExpose *event) { - if (GTK_WIDGET_DRAWABLE (widget)) - { - int x, y, w; + gint x, y, w; - w = MIN (widget->allocation.height - 2 * widget->style->ythickness, + if (G_LIKELY (GTK_WIDGET_DRAWABLE (widget))) + { + w = MIN (widget->allocation.height - 2 * widget->style->ythickness, widget->allocation.width - 2 * widget->style->xthickness); - w = MIN (w, ARROW_WIDTH); - + x = widget->allocation.x + (widget->allocation.width - w) / 2; - y = widget->allocation.y + (widget->allocation.height - w) / 2; - + GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); gtk_paint_arrow (widget->style, widget->window, @@ -246,27 +248,37 @@ xfce_arrow_button_expose (GtkWidget * widget, GdkEventExpose *event) return TRUE; } + + static void -xfce_arrow_button_size_request (GtkWidget * widget, - GtkRequisition * requisition) +xfce_arrow_button_size_request (GtkWidget *widget, + GtkRequisition *requisition) { - int size = ARROW_WIDTH + ARROW_PADDING + - 2 * MAX (widget->style->xthickness, widget->style->ythickness); - + gint size = ARROW_WIDTH + ARROW_PADDING + + 2 * MAX (widget->style->xthickness, widget->style->ythickness); + requisition->width = requisition->height = size; } -static void xfce_arrow_button_add (GtkContainer * container, GtkWidget *child) + + +static void +xfce_arrow_button_add (GtkContainer *container, + GtkWidget *child) { g_warning ("XfceArrowButton cannot contain any children"); } -static GType xfce_arrow_button_child_type (GtkContainer * container) + + +static GType +xfce_arrow_button_child_type (GtkContainer *container) { return GTK_TYPE_NONE; } + /* public interface */ /** @@ -285,6 +297,8 @@ xfce_arrow_button_new (GtkArrowType type) return GTK_WIDGET (button); } + + /** * xfce_arrow_button_set_arrow_type: * @button : an #XfceArrowButton @@ -293,21 +307,22 @@ xfce_arrow_button_new (GtkArrowType type) * Sets the arrow type for @button. **/ void -xfce_arrow_button_set_arrow_type (XfceArrowButton * button, - GtkArrowType type) +xfce_arrow_button_set_arrow_type (XfceArrowButton *button, + GtkArrowType type) { g_return_if_fail (XFCE_IS_ARROW_BUTTON (button)); - + button->arrow_type = type; - g_signal_emit (button, arrow_button_signals[ARROW_TYPE_CHANGED], - 0, type); + g_signal_emit (button, arrow_button_signals[ARROW_TYPE_CHANGED], 0, type); g_object_notify (G_OBJECT (button), "arrow_type"); gtk_widget_queue_draw (GTK_WIDGET (button)); } + + /** * xfce_arrow_button_get_arrow_type: * @button : an #XfceArrowButton @@ -315,10 +330,9 @@ xfce_arrow_button_set_arrow_type (XfceArrowButton * button, * Returns: the #GtkArrowType of @button. **/ GtkArrowType -xfce_arrow_button_get_arrow_type (XfceArrowButton * button) +xfce_arrow_button_get_arrow_type (XfceArrowButton *button) { - g_return_val_if_fail (XFCE_IS_ARROW_BUTTON (button), - DEFAULT_ARROW_TYPE); + g_return_val_if_fail (XFCE_IS_ARROW_BUTTON (button), DEFAULT_ARROW_TYPE); return button->arrow_type; } diff --git a/libxfce4panel/xfce-arrow-button.h b/libxfce4panel/xfce-arrow-button.h index a368e62f5..dd472127c 100644 --- a/libxfce4panel/xfce-arrow-button.h +++ b/libxfce4panel/xfce-arrow-button.h @@ -1,30 +1,34 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2004-2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2004-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_ARROW_BUTTON_H -#define _XFCE_ARROW_BUTTON_H +#ifndef __XFCE_ARROW_BUTTON_H__ +#define __XFCE_ARROW_BUTTON_H__ #include <gtk/gtkenums.h> #include <gtk/gtktogglebutton.h> +G_BEGIN_DECLS + +typedef struct _XfceArrowButton XfceArrowButton; +typedef struct _XfceArrowButtonClass XfceArrowButtonClass; + #define XFCE_TYPE_ARROW_BUTTON (xfce_arrow_button_get_type ()) #define XFCE_ARROW_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_ARROW_BUTTON, XfceArrowButton)) #define XFCE_ARROW_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_ARROW_BUTTON, XfceArrowButtonClass)) @@ -32,17 +36,10 @@ #define XFCE_IS_ARROW_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_ARROW_BUTTON)) #define XFCE_ARROW_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_ARROW_BUTTON, XfceArrowButtonClass)) - -G_BEGIN_DECLS - -typedef struct _XfceArrowButton XfceArrowButton; -typedef struct _XfceArrowButtonClass XfceArrowButtonClass; - struct _XfceArrowButton { GtkToggleButton parent; - - GtkArrowType arrow_type; + GtkArrowType arrow_type; }; struct _XfceArrowButtonClass @@ -50,20 +47,16 @@ struct _XfceArrowButtonClass GtkToggleButtonClass parent_class; /* signals */ - void (*arrow_type_changed) (GtkWidget * widget, - GtkArrowType type); + void (*arrow_type_changed) (GtkWidget *widget, + GtkArrowType type); }; - -GType xfce_arrow_button_get_type (void) G_GNUC_CONST; - -GtkWidget *xfce_arrow_button_new (GtkArrowType type); - -void xfce_arrow_button_set_arrow_type (XfceArrowButton * button, - GtkArrowType type); - -GtkArrowType xfce_arrow_button_get_arrow_type (XfceArrowButton * button); +GType xfce_arrow_button_get_type (void) G_GNUC_CONST; +GtkWidget *xfce_arrow_button_new (GtkArrowType type) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +void xfce_arrow_button_set_arrow_type (XfceArrowButton *button, + GtkArrowType type); +GtkArrowType xfce_arrow_button_get_arrow_type (XfceArrowButton *button); G_END_DECLS -#endif /* _XFCE_ARROW_BUTTON_H */ +#endif /* !__XFCE_ARROW_BUTTON_H__ */ diff --git a/libxfce4panel/xfce-hvbox.c b/libxfce4panel/xfce-hvbox.c index 1f5599da8..7ee13dd49 100644 --- a/libxfce4panel/xfce-hvbox.c +++ b/libxfce4panel/xfce-hvbox.c @@ -1,11 +1,8 @@ -/* vim: set expandtab ts=8 sw=4: */ - /* $Id$ * - * OBox Copyright © 2002 Red Hat Inc. based on GtkHBox - * Copyright © 2006 Jani Monoses (jani@ubuntu.com) - * Copyright © 2006 Jasper Huijsmans <jasper@xfce.org> - * + * OBox Copyright (c) 2002 Red Hat Inc. based on GtkHBox + * Copyright (c) 2006 Jani Monoses <jani@ubuntu.com> + * Copyright (c) 2006-2007 Jasper Huijsmans <jasper@xfce.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -31,66 +28,73 @@ #include <gtk/gtkhbox.h> #include <gtk/gtkvbox.h> +#include "xfce-panel-macros.h" #include "xfce-hvbox.h" -/* Forward declarations */ - -static void xfce_hvbox_class_init (XfceHVBoxClass * class); -static void xfce_hvbox_init (XfceHVBox * hvbox); -static void xfce_hvbox_size_request (GtkWidget * widget, - GtkRequisition * requisition); +/* prototypes */ +static void xfce_hvbox_class_init (XfceHVBoxClass *klass); +static void xfce_hvbox_init (XfceHVBox *hvbox); +static void xfce_hvbox_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void xfce_hvbox_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); -static void xfce_hvbox_size_allocate (GtkWidget * widget, - GtkAllocation * allocation); GtkType xfce_hvbox_get_type (void) { - static GtkType hvbox_type = 0; + static GtkType hvbox_type = G_TYPE_INVALID; - if (!hvbox_type) + if (G_UNLIKELY (hvbox_type == G_TYPE_INVALID)) { static const GTypeInfo hvbox_info = { sizeof (XfceHVBoxClass), - NULL, /* base_init */ - NULL, /* base_finalize */ + NULL, + NULL, (GClassInitFunc) xfce_hvbox_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ + NULL, + NULL, sizeof (XfceHVBox), - 0, /* n_preallocs */ + 0, (GInstanceInitFunc) xfce_hvbox_init, - NULL /* value_table */ + NULL }; - hvbox_type = - g_type_register_static (GTK_TYPE_BOX, "XfceHVBox", &hvbox_info, 0); + hvbox_type = + g_type_register_static (GTK_TYPE_BOX, I_("XfceHVBox"), &hvbox_info, 0); } return hvbox_type; } + + static void -xfce_hvbox_class_init (XfceHVBoxClass * class) +xfce_hvbox_class_init (XfceHVBoxClass *klass) { GtkWidgetClass *widget_class; - widget_class = (GtkWidgetClass *) class; + widget_class = (GtkWidgetClass *) klass; widget_class->size_request = xfce_hvbox_size_request; widget_class->size_allocate = xfce_hvbox_size_allocate; } + + static void -xfce_hvbox_init (XfceHVBox * hvbox) +xfce_hvbox_init (XfceHVBox *hvbox) { + /* empty */ } + + static GtkWidgetClass * -get_class (XfceHVBox * hvbox) +get_class (XfceHVBox *hvbox) { GtkWidgetClass *klass; @@ -111,11 +115,14 @@ get_class (XfceHVBox * hvbox) return klass; } + + static void -xfce_hvbox_size_request (GtkWidget * widget, GtkRequisition * requisition) +xfce_hvbox_size_request (GtkWidget *widget, + GtkRequisition *requisition) { GtkWidgetClass *klass; - XfceHVBox *hvbox; + XfceHVBox *hvbox; hvbox = XFCE_HVBOX (widget); @@ -124,11 +131,14 @@ xfce_hvbox_size_request (GtkWidget * widget, GtkRequisition * requisition) klass->size_request (widget, requisition); } + + static void -xfce_hvbox_size_allocate (GtkWidget * widget, GtkAllocation * allocation) +xfce_hvbox_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) { GtkWidgetClass *klass; - XfceHVBox *hvbox; + XfceHVBox *hvbox; hvbox = XFCE_HVBOX (widget); @@ -137,11 +147,11 @@ xfce_hvbox_size_allocate (GtkWidget * widget, GtkAllocation * allocation) klass->size_allocate (widget, allocation); } -/* public interface */ + /** * xfce_hvbox_new: - * @orientation : Orientation of the #XfceHVBox + * @orienation : Orientation of the #XfceHVBox * @homogeneous : whether all children should be allocated the same size * @spacing : spacing between #XfceHVBox children * @@ -150,7 +160,9 @@ xfce_hvbox_size_allocate (GtkWidget * widget, GtkAllocation * allocation) * Return value: the newly allocated #XfceHVBox container widget. **/ GtkWidget * -xfce_hvbox_new (GtkOrientation orientation, gboolean homogeneous, int spacing) +xfce_hvbox_new (GtkOrientation orientation, + gboolean homogeneous, + gint spacing) { GtkWidget *box = GTK_WIDGET (g_object_new (xfce_hvbox_get_type (), NULL)); @@ -161,12 +173,22 @@ xfce_hvbox_new (GtkOrientation orientation, gboolean homogeneous, int spacing) return box; } + + +/** + * xfce_hvbox_set_orientation: + * @hvbox : #XfceHVBox + * @orientation : the new orientation of the #XfceHVBox + * + * Set the new orientation of the #XfceHVBox container widget. + **/ void -xfce_hvbox_set_orientation (XfceHVBox * hvbox, GtkOrientation orientation) +xfce_hvbox_set_orientation (XfceHVBox *hvbox, + GtkOrientation orientation) { g_return_if_fail (XFCE_IS_HVBOX (hvbox)); - if (hvbox->orientation == orientation) + if (G_UNLIKELY (hvbox->orientation == orientation)) return; hvbox->orientation = orientation; diff --git a/libxfce4panel/xfce-hvbox.h b/libxfce4panel/xfce-hvbox.h index 72a3deda2..ad98e11ab 100644 --- a/libxfce4panel/xfce-hvbox.h +++ b/libxfce4panel/xfce-hvbox.h @@ -1,10 +1,8 @@ -/* vim: set expandtab ts=8 sw=4: */ - /* $Id$ * - * OBox Copyright © 2002 Red Hat Inc. based on GtkHBox - * Copyright © 2006 Jani Monoses (jani@ubuntu.com) - * Copyright © 2006 Jasper Huijsmans <jasper@xfce.org> + * OBox Copyright (c) 2002 Red Hat Inc. based on GtkHBox + * Copyright (c) 2006 Jani Monoses <jani@ubuntu.com> + * Copyright (c) 2006-2007 Jasper Huijsmans <jasper@xfce.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -22,26 +20,26 @@ * Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_HVBOX_H -#define _XFCE_HVBOX_H +#ifndef __XFCE_HVBOX_H__ +#define __XFCE_HVBOX_H__ #include <gtk/gtkbox.h> G_BEGIN_DECLS +typedef struct _XfceHVBox XfceHVBox; +typedef struct _XfceHVBoxClass XfceHVBoxClass; + #define XFCE_TYPE_HVBOX (xfce_hvbox_get_type()) #define XFCE_HVBOX(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, xfce_hvbox_get_type (), XfceHVBox)) -#define XFCE_HVBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, xfce_hvbox_get_type (), XfceHVBoxClass)) +#define XFCE_HVBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, xfce_hvbox_get_type (), XfceHVBoxClass)) #define XFCE_IS_HVBOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, xfce_hvbox_get_type ())) #define XFCE_IS_HVBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_HVBOX)) #define XFCE_HVBOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_HVBOX, TrayOBoxClass)) -typedef struct _XfceHVBox XfceHVBox; -typedef struct _XfceHVBoxClass XfceHVBoxClass; - struct _XfceHVBox { - GtkBox hvbox; + GtkBox hvbox; GtkOrientation orientation; }; @@ -50,15 +48,12 @@ struct _XfceHVBoxClass GtkBoxClass parent_class; }; -GType xfce_hvbox_get_type (void) G_GNUC_CONST; - -GtkWidget *xfce_hvbox_new (GtkOrientation orientation, - gboolean homogeneous, - int spacing); - -void xfce_hvbox_set_orientation (XfceHVBox * hvbox, - GtkOrientation orientation); - +GType xfce_hvbox_get_type (void) G_GNUC_CONST; +GtkWidget *xfce_hvbox_new (GtkOrientation orientation, + gboolean homogeneous, + gint spacing) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +void xfce_hvbox_set_orientation (XfceHVBox *hvbox, + GtkOrientation orientation); G_END_DECLS -#endif /* __XFCE_HVBOX_H__ */ +#endif /* !__XFCE_HVBOX_H__ */ diff --git a/libxfce4panel/xfce-itembar.c b/libxfce4panel/xfce-itembar.c index e8c8f0d27..d5e97714e 100644 --- a/libxfce4panel/xfce-itembar.c +++ b/libxfce4panel/xfce-itembar.c @@ -1,26 +1,24 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2004-2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2004-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/* Partly based on code from GTK+. Copyright © 1997-2000 The GTK+ Team - * licensed under the LGPL. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Partly based on code from GTK+. Copyright (c) 1997-2000 The GTK+ Team + * licensed under the LGPL. */ #ifdef HAVE_CONFIG_H @@ -62,146 +60,125 @@ enum CHILD_PROP_EXPAND }; + + typedef struct _XfceItembarChild XfceItembarChild; typedef struct _XfceItembarPrivate XfceItembarPrivate; -struct _XfceItembarPrivate +struct _XfceItembarPrivate { - GtkOrientation orientation; - GList *children; - - GdkWindow *event_window; - GdkWindow *drag_highlight; - - int drop_index; - guint raised:1; + GtkOrientation orientation; + GSList *children; + + GdkWindow *event_window; + GdkWindow *drag_highlight; + + gint drop_index; + guint raised : 1; }; struct _XfceItembarChild { GtkWidget *widget; - guint expand:1; + guint expand : 1; }; -/* init */ -static void xfce_itembar_class_init (XfceItembarClass * klass); - -static void xfce_itembar_init (XfceItembar * itembar); - -/* GObject */ -static void xfce_itembar_finalize (GObject *object); - -static void xfce_itembar_set_property (GObject * object, - guint prop_id, - const GValue * value, - GParamSpec * pspec); - -static void xfce_itembar_get_property (GObject * object, - guint prop_id, - GValue * value, - GParamSpec * pspec); - -/* widget */ -static int xfce_itembar_expose (GtkWidget * widget, - GdkEventExpose * event); - -static void xfce_itembar_size_request (GtkWidget * widget, - GtkRequisition * requisition); - -static void xfce_itembar_size_allocate (GtkWidget * widget, - GtkAllocation * allocation); - -static void xfce_itembar_realize (GtkWidget * widget); - -static void xfce_itembar_unrealize (GtkWidget * widget); - -static void xfce_itembar_map (GtkWidget * widget); - -static void xfce_itembar_unmap (GtkWidget * widget); - -static void xfce_itembar_drag_leave (GtkWidget * widget, - GdkDragContext * context, - guint time_); - -static gboolean xfce_itembar_drag_motion (GtkWidget * widget, - GdkDragContext * context, - int x, - int y, - guint time_); -/* container */ -static void xfce_itembar_forall (GtkContainer * container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); - -static GType xfce_itembar_child_type (GtkContainer * container); - -static void xfce_itembar_add (GtkContainer * container, - GtkWidget * child); - -static void xfce_itembar_remove (GtkContainer * container, - GtkWidget * child); - -static void xfce_itembar_set_child_property (GtkContainer * container, - GtkWidget * child, - guint prop_id, - const GValue * value, - GParamSpec * pspec); - -static void xfce_itembar_get_child_property (GtkContainer * container, - GtkWidget * child, - guint prop_id, - GValue * value, - GParamSpec * pspec); - -/* internal functions */ -static int _find_drop_index (XfceItembar * itembar, - int x, - int y); +static void xfce_itembar_class_init (XfceItembarClass *klass); +static void xfce_itembar_init (XfceItembar *itembar); +static void xfce_itembar_finalize (GObject *object); +static void xfce_itembar_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void xfce_itembar_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static gint xfce_itembar_expose (GtkWidget *widget, + GdkEventExpose *event); +static void xfce_itembar_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void xfce_itembar_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); +static void xfce_itembar_realize (GtkWidget *widget); +static void xfce_itembar_unrealize (GtkWidget *widget); +static void xfce_itembar_map (GtkWidget *widget); +static void xfce_itembar_unmap (GtkWidget *widget); +static void xfce_itembar_drag_leave (GtkWidget *widget, + GdkDragContext *context, + guint time_); +static gboolean xfce_itembar_drag_motion (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + guint time_); +static void xfce_itembar_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data); +static GType xfce_itembar_child_type (GtkContainer *container); +static void xfce_itembar_add (GtkContainer *container, + GtkWidget *child); +static void xfce_itembar_remove (GtkContainer *container, + GtkWidget *child); +static void xfce_itembar_set_child_property (GtkContainer *container, + GtkWidget *child, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void xfce_itembar_get_child_property (GtkContainer *container, + GtkWidget *child, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static gint _find_drop_index (XfceItembar *itembar, + gint x, + gint y); /* global vars */ static GtkContainerClass *parent_class = NULL; +static guint itembar_signals[LAST_SIGNAL] = { 0 }; -static guint itembar_signals[LAST_SIGNAL] = { 0 }; /* public GType function */ GType xfce_itembar_get_type (void) { - static GtkType type = 0; + static GtkType type = G_TYPE_INVALID; - if (!type) + if (G_UNLIKELY (type == G_TYPE_INVALID)) { - static const GTypeInfo type_info = { - sizeof (XfceItembarClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) xfce_itembar_class_init, - (GClassFinalizeFunc) NULL, - NULL, - sizeof (XfceItembar), - 0, /* n_preallocs */ - (GInstanceInitFunc) xfce_itembar_init, + static const GTypeInfo type_info = { + sizeof (XfceItembarClass), + NULL, + NULL, + (GClassInitFunc) xfce_itembar_class_init, + NULL, + NULL, + sizeof (XfceItembar), + 0, /* n_preallocs */ + (GInstanceInitFunc) xfce_itembar_init, NULL - }; + }; - type = g_type_register_static (GTK_TYPE_CONTAINER, "XfceItembar", - &type_info, 0); + type = + g_type_register_static (GTK_TYPE_CONTAINER, I_("XfceItembar"), &type_info, 0); } return type; } + /* init */ static void -xfce_itembar_class_init (XfceItembarClass * klass) +xfce_itembar_class_init (XfceItembarClass *klass) { - GObjectClass *gobject_class; - GtkWidgetClass *widget_class; + GObjectClass *gobject_class; + GtkWidgetClass *widget_class; GtkContainerClass *container_class; g_type_class_add_private (klass, sizeof (XfceItembarPrivate)); @@ -215,9 +192,9 @@ xfce_itembar_class_init (XfceItembarClass * klass) gobject_class->get_property = xfce_itembar_get_property; gobject_class->set_property = xfce_itembar_set_property; - widget_class->expose_event = xfce_itembar_expose; - widget_class->size_request = xfce_itembar_size_request; - widget_class->size_allocate = xfce_itembar_size_allocate; + widget_class->expose_event = xfce_itembar_expose; + widget_class->size_request = xfce_itembar_size_request; + widget_class->size_allocate = xfce_itembar_size_allocate; widget_class->realize = xfce_itembar_realize; widget_class->unrealize = xfce_itembar_unrealize; widget_class->map = xfce_itembar_map; @@ -242,15 +219,15 @@ xfce_itembar_class_init (XfceItembarClass * klass) * Emitted when the orientation of the itembar changes. **/ itembar_signals[ORIENTATION_CHANGED] = - g_signal_new ("orientation-changed", + g_signal_new (I_("orientation-changed"), G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (XfceItembarClass, + G_STRUCT_OFFSET (XfceItembarClass, orientation_changed), NULL, NULL, g_cclosure_marshal_VOID__ENUM, G_TYPE_NONE, 1, GTK_TYPE_ORIENTATION); - + /** * XfceItembar::contents-changed: * @itembar : the object which emitted the signal @@ -259,15 +236,15 @@ xfce_itembar_class_init (XfceItembarClass * klass) * a child, removing a child, or reordering a child. **/ itembar_signals[CONTENTS_CHANGED] = - g_signal_new ("contents-changed", + g_signal_new (I_("contents-changed"), G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (XfceItembarClass, + G_STRUCT_OFFSET (XfceItembarClass, contents_changed), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - + /* properties */ /** @@ -275,15 +252,15 @@ xfce_itembar_class_init (XfceItembarClass * klass) * * The orientation of the #XfceItembar. **/ - g_object_class_install_property (gobject_class, - PROP_ORIENTATION, - g_param_spec_enum ("orientation", - "Orientation", - "The orientation of the itembar", - GTK_TYPE_ORIENTATION, - DEFAULT_ORIENTATION, - G_PARAM_READWRITE)); - + g_object_class_install_property (gobject_class, + PROP_ORIENTATION, + g_param_spec_enum ("orientation", + "Orientation", + "The orientation of the itembar", + GTK_TYPE_ORIENTATION, + DEFAULT_ORIENTATION, + G_PARAM_READWRITE)); + /* child properties */ /** @@ -292,39 +269,47 @@ xfce_itembar_class_init (XfceItembarClass * klass) * Whether the child of the #XfceItembar should fill available space. **/ gtk_container_class_install_child_property (container_class, - CHILD_PROP_EXPAND, - g_param_spec_boolean ("expand", - "Expand", - "Whether to grow with parent", - DEFAULT_CHILD_EXPAND, - G_PARAM_READWRITE)); + CHILD_PROP_EXPAND, + g_param_spec_boolean ("expand", + "Expand", + "Whether to grow with parent", + DEFAULT_CHILD_EXPAND, + G_PARAM_READWRITE)); } + + static void -xfce_itembar_init (XfceItembar * itembar) +xfce_itembar_init (XfceItembar *itembar) { XfceItembarPrivate *priv = XFCE_ITEMBAR_GET_PRIVATE (itembar); - + GTK_WIDGET_SET_FLAGS (GTK_WIDGET (itembar), GTK_NO_WINDOW); gtk_widget_set_redraw_on_allocate (GTK_WIDGET (itembar), FALSE); - priv->orientation = DEFAULT_ORIENTATION; - priv->children = NULL; - priv->event_window = NULL; - priv->drag_highlight = NULL; - priv->drop_index = -1; + priv->orientation = DEFAULT_ORIENTATION; + priv->children = NULL; + priv->event_window = NULL; + priv->drag_highlight = NULL; + priv->drop_index = -1; } + + /* GObject */ static void -xfce_itembar_finalize (GObject * object) +xfce_itembar_finalize (GObject *object) { G_OBJECT_CLASS (parent_class)->finalize (object); } + + static void -xfce_itembar_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec) +xfce_itembar_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { XfceItembar *itembar = XFCE_ITEMBAR (object); @@ -339,9 +324,13 @@ xfce_itembar_set_property (GObject * object, guint prop_id, } } + + static void -xfce_itembar_get_property (GObject * object, guint prop_id, GValue * value, - GParamSpec * pspec) +xfce_itembar_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { XfceItembar *itembar = XFCE_ITEMBAR (object); @@ -357,12 +346,13 @@ xfce_itembar_get_property (GObject * object, guint prop_id, GValue * value, } + /* GtkWidget */ -static int -xfce_itembar_expose (GtkWidget * widget, GdkEventExpose *event) +static gint +xfce_itembar_expose (GtkWidget *widget, + GdkEventExpose *event) { - XfceItembarPrivate *priv = - XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (widget)); + XfceItembarPrivate *priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (widget)); GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); @@ -372,29 +362,32 @@ xfce_itembar_expose (GtkWidget * widget, GdkEventExpose *event) return TRUE; } + + static void -xfce_itembar_size_request (GtkWidget * widget, GtkRequisition * requisition) +xfce_itembar_size_request (GtkWidget *widget, + GtkRequisition *requisition) { - XfceItembarPrivate *priv = - XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (widget)); - GList *l; - int max, other_size; + XfceItembarPrivate *priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (widget)); + XfceItembarChild *child; + GSList *l; + GtkRequisition req; + gint max, other_size; - requisition->width = requisition->height = + requisition->width = requisition->height = 2 * GTK_CONTAINER (widget)->border_width; - + max = other_size = 0; - + for (l = priv->children; l != NULL; l = l->next) { - XfceItembarChild *child = l->data; - GtkRequisition req; + child = l->data; if (!GTK_WIDGET_VISIBLE (child->widget)) continue; gtk_widget_size_request (child->widget, &req); - + if (GTK_ORIENTATION_HORIZONTAL == priv->orientation) { max = MAX (max, req.height); @@ -421,31 +414,39 @@ xfce_itembar_size_request (GtkWidget * widget, GtkRequisition * requisition) } } + + static void -xfce_itembar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) +xfce_itembar_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) { - XfceItembarPrivate *priv = - XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (widget)); - int n, i, x, y, bar_height, total_size; - int n_expand, expand_width, max_expand, total_expand; - int border_width; - GList *l; - GtkTextDirection direction; - struct ItemProps { + XfceItembarPrivate *priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (widget)); + XfceItembarChild *child; + gint n, i, x, y, bar_height, total_size; + gint n_expand, expand_width, max_expand, total_expand; + gint border_width; + GSList *l; + gint width, height; + gint real_expand_width, size; + GtkRequisition req; + GtkTextDirection direction; + + struct ItemProps + { GtkAllocation allocation; - gboolean expand; + guint expand : 1; } *props; - + widget->allocation = *allocation; border_width = GTK_CONTAINER (widget)->border_width; - + n_expand = expand_width = max_expand = 0; bar_height = total_size = 0; x = allocation->x + border_width; y = allocation->y + border_width; - + if (GTK_ORIENTATION_HORIZONTAL == priv->orientation) { expand_width = allocation->width - 2 * border_width; @@ -453,7 +454,7 @@ xfce_itembar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) if (priv->event_window != NULL) { - gdk_window_move_resize (priv->event_window, + gdk_window_move_resize (priv->event_window, x, y, expand_width, bar_height); } } @@ -464,7 +465,7 @@ xfce_itembar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) if (priv->event_window != NULL) { - gdk_window_move_resize (priv->event_window, + gdk_window_move_resize (priv->event_window, x, y, bar_height, expand_width); } } @@ -472,23 +473,21 @@ xfce_itembar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) total_size = expand_width; direction = gtk_widget_get_direction (widget); - n = g_list_length (priv->children); + n = g_slist_length (priv->children); props = g_new (struct ItemProps, n); - + /* first pass */ for (l = priv->children, i = 0; l != NULL; l = l->next, i++) { - XfceItembarChild *child = l->data; - int width, height; - GtkRequisition req; + child = l->data; if (!GTK_WIDGET_VISIBLE (child->widget)) { props[i].allocation.width = 0; continue; } - + gtk_widget_size_request (child->widget, &req); width = req.width; height = req.height; @@ -496,7 +495,7 @@ xfce_itembar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) if (GTK_ORIENTATION_HORIZONTAL == priv->orientation) { height = bar_height; - + if (child->expand) { n_expand++; @@ -510,7 +509,7 @@ xfce_itembar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) else { width = bar_height; - + if (child->expand) { n_expand++; @@ -528,11 +527,10 @@ xfce_itembar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) } total_expand = expand_width; - + while (n_expand > 0) { - int real_expand_width = - MAX (expand_width / n_expand, 0); + real_expand_width = MAX (expand_width / n_expand, 0); /* if it fits, continue */ if (real_expand_width >= max_expand) @@ -542,15 +540,13 @@ xfce_itembar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) } max_expand = 0; - + /* remove bigger items from expand list */ for (i = 0; i < n; ++i) { - int size; - if (!props[i].expand) continue; - + if (GTK_ORIENTATION_HORIZONTAL == priv->orientation) size = props[i].allocation.width; else @@ -568,14 +564,14 @@ xfce_itembar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) } } } - + x = y = border_width; - + /* second pass */ for (l = priv->children, i = 0; l != NULL; l = l->next, i++) { - XfceItembarChild *child = l->data; - + child = l->data; + if (props[i].allocation.width == 0) continue; @@ -590,7 +586,7 @@ xfce_itembar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { if (n_expand == 1) expand_width = total_expand; - + props[i].allocation.width = expand_width; n_expand--; total_expand -= expand_width; @@ -598,7 +594,7 @@ xfce_itembar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) if (direction == GTK_TEXT_DIR_RTL) { - props[i].allocation.x = allocation->x + total_size - x + props[i].allocation.x = allocation->x + total_size - x - props[i].allocation.width; } @@ -611,9 +607,8 @@ xfce_itembar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) y += props[i].allocation.height; } - - gtk_widget_size_allocate (child->widget, - &(props[i].allocation)); + + gtk_widget_size_allocate (child->widget, &(props[i].allocation)); } g_free (props); @@ -624,12 +619,14 @@ xfce_itembar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) } } + + static void -xfce_itembar_realize (GtkWidget * widget) +xfce_itembar_realize (GtkWidget *widget) { - GdkWindowAttr attributes; - int attributes_mask; - int border_width; + GdkWindowAttr attributes; + gint attributes_mask; + gint border_width; XfceItembarPrivate *priv; GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); @@ -646,9 +643,7 @@ xfce_itembar_realize (GtkWidget * widget) | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - | GDK_EXPOSURE_MASK - | GDK_ENTER_NOTIFY_MASK - | GDK_LEAVE_NOTIFY_MASK; + | GDK_EXPOSURE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK; attributes.wclass = GDK_INPUT_ONLY; attributes_mask = GDK_WA_X | GDK_WA_Y; @@ -665,8 +660,10 @@ xfce_itembar_realize (GtkWidget * widget) widget->style = gtk_style_attach (widget->style, widget->window); } + + static void -xfce_itembar_unrealize (GtkWidget * widget) +xfce_itembar_unrealize (GtkWidget *widget) { XfceItembarPrivate *priv; @@ -683,8 +680,10 @@ xfce_itembar_unrealize (GtkWidget * widget) (*GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); } + + static void -xfce_itembar_map (GtkWidget * widget) +xfce_itembar_map (GtkWidget *widget) { XfceItembarPrivate *priv; @@ -693,13 +692,15 @@ xfce_itembar_map (GtkWidget * widget) gdk_window_show (priv->event_window); (*GTK_WIDGET_CLASS (parent_class)->map) (widget); - + if (priv->raised) gdk_window_raise (priv->event_window); } + + static void -xfce_itembar_unmap (GtkWidget * widget) +xfce_itembar_unmap (GtkWidget *widget) { XfceItembarPrivate *priv; @@ -711,90 +712,94 @@ xfce_itembar_unmap (GtkWidget * widget) (*GTK_WIDGET_CLASS (parent_class)->unmap) (widget); } + + static void -xfce_itembar_drag_leave (GtkWidget * widget, - GdkDragContext * context, guint time_) +xfce_itembar_drag_leave (GtkWidget *widget, + GdkDragContext *context, + guint time_) { - XfceItembar *toolbar = XFCE_ITEMBAR (widget); + XfceItembar *toolbar = XFCE_ITEMBAR (widget); XfceItembarPrivate *priv = XFCE_ITEMBAR_GET_PRIVATE (toolbar); if (priv->drag_highlight) { - gdk_window_set_user_data (priv->drag_highlight, NULL); - gdk_window_destroy (priv->drag_highlight); - priv->drag_highlight = NULL; + gdk_window_set_user_data (priv->drag_highlight, NULL); + gdk_window_destroy (priv->drag_highlight); + priv->drag_highlight = NULL; } priv->drop_index = -1; } + + static gboolean -xfce_itembar_drag_motion (GtkWidget * widget, - GdkDragContext * context, - int x, int y, guint time_) +xfce_itembar_drag_motion (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + guint time_) { - XfceItembar *itembar = XFCE_ITEMBAR (widget); + XfceItembar *itembar = XFCE_ITEMBAR (widget); XfceItembarPrivate *priv = XFCE_ITEMBAR_GET_PRIVATE (itembar); - XfceItembarChild *child; - int new_index, new_pos; + XfceItembarChild *child; + gint new_index, new_pos, border_width; + GdkWindowAttr attributes; + guint attributes_mask; new_index = _find_drop_index (itembar, x, y); if (!priv->drag_highlight) { - GdkWindowAttr attributes; - guint attributes_mask; - - attributes.window_type = GDK_WINDOW_CHILD; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); - attributes.event_mask = - GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK | - GDK_POINTER_MOTION_MASK; - attributes.width = 1; - attributes.height = 1; - attributes_mask = GDK_WA_VISUAL | GDK_WA_COLORMAP; - priv->drag_highlight = - gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (priv->drag_highlight, widget); - gdk_window_set_background (priv->drag_highlight, - &widget->style->fg[widget->state]); + attributes.window_type = GDK_WINDOW_CHILD; + attributes.wclass = GDK_INPUT_OUTPUT; + attributes.visual = gtk_widget_get_visual (widget); + attributes.colormap = gtk_widget_get_colormap (widget); + attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK | + GDK_POINTER_MOTION_MASK; + attributes.width = 1; + attributes.height = 1; + attributes_mask = GDK_WA_VISUAL | GDK_WA_COLORMAP; + priv->drag_highlight = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + + gdk_window_set_user_data (priv->drag_highlight, widget); + gdk_window_set_background (priv->drag_highlight, + &widget->style->fg[widget->state]); } if (priv->drop_index < 0 || priv->drop_index != new_index) { - int border_width = GTK_CONTAINER (itembar)->border_width; - - child = g_list_nth_data (priv->children, new_index); - - priv->drop_index = new_index; - if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) - { - if (child) - new_pos = child->widget->allocation.x; - else - new_pos = widget->allocation.x + widget->allocation.width + border_width = GTK_CONTAINER (itembar)->border_width; + + child = g_slist_nth_data (priv->children, new_index); + + priv->drop_index = new_index; + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) + { + if (child) + new_pos = child->widget->allocation.x; + else + new_pos = widget->allocation.x + widget->allocation.width - border_width; - - gdk_window_move_resize (priv->drag_highlight, new_pos - 1, - widget->allocation.y + border_width, 2, - widget->allocation.height - - border_width * 2); - } - else - { - if (child) - new_pos = child->widget->allocation.y; - else - new_pos = widget->allocation.y + widget->allocation.height; - - gdk_window_move_resize (priv->drag_highlight, - widget->allocation.x + border_width, - new_pos - 1, widget->allocation.width + + gdk_window_move_resize (priv->drag_highlight, new_pos - 1, + widget->allocation.y + border_width, 2, + widget->allocation.height - border_width * 2); + } + else + { + if (child) + new_pos = child->widget->allocation.y; + else + new_pos = widget->allocation.y + widget->allocation.height; + + gdk_window_move_resize (priv->drag_highlight, + widget->allocation.x + border_width, + new_pos - 1, widget->allocation.width - border_width * 2, 2); - } + } } gdk_window_show (priv->drag_highlight); @@ -804,67 +809,80 @@ xfce_itembar_drag_motion (GtkWidget * widget, return TRUE; } + + static void -xfce_itembar_forall (GtkContainer * container, gboolean include_internals, - GtkCallback callback, gpointer callback_data) +xfce_itembar_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data) { - GList *l; - XfceItembarPrivate *priv = - XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (container)); + GSList *l; + XfceItembarChild *child; + XfceItembarPrivate *priv; + + priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (container)); for (l = priv->children; l != NULL; l = l->next) { - XfceItembarChild *child = l->data; - + child = l->data; + if (child && GTK_IS_WIDGET (child->widget)) (*callback) (child->widget, callback_data); } } + + static GType -xfce_itembar_child_type (GtkContainer * container) +xfce_itembar_child_type (GtkContainer *container) { return GTK_TYPE_WIDGET; } + + static void -xfce_itembar_add (GtkContainer * container, GtkWidget * child) +xfce_itembar_add (GtkContainer *container, + GtkWidget *child) { xfce_itembar_insert (XFCE_ITEMBAR (container), child, -1); } + + static void -xfce_itembar_remove (GtkContainer * container, GtkWidget *child) +xfce_itembar_remove (GtkContainer *container, + GtkWidget *child) { XfceItembarPrivate *priv; - GList *l; - + XfceItembarChild *ic; + gboolean was_visible; + GSList *l; + g_return_if_fail (XFCE_IS_ITEMBAR (container)); - g_return_if_fail (child != NULL - && child->parent == GTK_WIDGET (container)); + g_return_if_fail (child != NULL && child->parent == GTK_WIDGET (container)); priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (container)); - + for (l = priv->children; l != NULL; l = l->next) { - XfceItembarChild *ic = l->data; + ic = l->data; if (ic->widget == child) { - gboolean was_visible; - - priv->children = g_list_delete_link (priv->children, l); + priv->children = g_slist_delete_link (priv->children, l); was_visible = GTK_WIDGET_VISIBLE (ic->widget); - + gtk_widget_unparent (ic->widget); panel_slice_free (XfceItembarChild, ic); if (was_visible) gtk_widget_queue_resize (GTK_WIDGET (container)); - - g_signal_emit (G_OBJECT (container), + + g_signal_emit (G_OBJECT (container), itembar_signals [CONTENTS_CHANGED], 0); break; @@ -872,12 +890,18 @@ xfce_itembar_remove (GtkContainer * container, GtkWidget *child) } } + + static void -xfce_itembar_get_child_property (GtkContainer * container, - GtkWidget * child, guint property_id, - GValue * value, GParamSpec * pspec) +xfce_itembar_get_child_property (GtkContainer *container, + GtkWidget *child, + guint property_id, + GValue *value, + GParamSpec *pspec) { - gboolean expand = 0; + gboolean expand; + + expand = FALSE; switch (property_id) { @@ -893,11 +917,14 @@ xfce_itembar_get_child_property (GtkContainer * container, } } + + static void -xfce_itembar_set_child_property (GtkContainer * container, - GtkWidget * child, - guint property_id, - const GValue * value, GParamSpec * pspec) +xfce_itembar_set_child_property (GtkContainer *container, + GtkWidget *child, + guint property_id, + const GValue *value, + GParamSpec *pspec) { switch (property_id) { @@ -912,26 +939,30 @@ xfce_itembar_set_child_property (GtkContainer * container, } } -/* internal functions */ -static int -_find_drop_index (XfceItembar * itembar, int x, int y) + + +/* ginternal functions */ +static gint +_find_drop_index (XfceItembar *itembar, + gint x, + gint y) { - GList *l; - GtkTextDirection direction; - int distance, cursor, pos, i, index; - XfceItembarChild *child; + GSList *l; + GtkTextDirection direction; + gint distance, cursor, pos, i, index; + XfceItembarChild *child; XfceItembarPrivate *priv = XFCE_ITEMBAR_GET_PRIVATE (itembar); - int best_distance = G_MAXINT; - + gint best_distance = G_MAXINT; + if (!priv->children) return 0; - + direction = gtk_widget_get_direction (GTK_WIDGET (itembar)); index = 0; - + child = priv->children->data; - + if (GTK_ORIENTATION_HORIZONTAL == priv->orientation) { cursor = x; @@ -943,7 +974,7 @@ _find_drop_index (XfceItembar * itembar, int x, int y) } else { - pos = child->widget->allocation.x + pos = child->widget->allocation.x + child->widget->allocation.width - x; } } @@ -954,41 +985,42 @@ _find_drop_index (XfceItembar * itembar, int x, int y) pos = child->widget->allocation.y - y; } - + best_distance = ABS (pos - cursor); /* distance to far end of each item */ for (i = 1, l = priv->children; l != NULL; l = l->next, i++) { - child = l->data; + child = l->data; - if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) - { - if (direction == GTK_TEXT_DIR_LTR) - pos = child->widget->allocation.x + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) + { + if (direction == GTK_TEXT_DIR_LTR) + pos = child->widget->allocation.x + child->widget->allocation.width - x; - else - pos = child->widget->allocation.x - x; - } - else - { - pos = y + child->widget->allocation.y + else + pos = child->widget->allocation.x - x; + } + else + { + pos = y + child->widget->allocation.y + child->widget->allocation.height - y; - } + } - distance = ABS (pos - cursor); + distance = ABS (pos - cursor); - if (distance <= best_distance) - { - best_distance = distance; + if (distance <= best_distance) + { + best_distance = distance; index = i; - } + } } return index; } + /* public interface */ /** @@ -1002,23 +1034,25 @@ xfce_itembar_new (GtkOrientation orientation) { XfceItembar *itembar; - itembar = g_object_new (XFCE_TYPE_ITEMBAR, "orientation", orientation, + itembar = g_object_new (XFCE_TYPE_ITEMBAR, "orientation", orientation, NULL); return GTK_WIDGET (itembar); } + + /** * xfce_itembar_get_orientation: * @itembar : an #XfceItembar * * Returns: #GtkOrienation of @itembar. **/ -GtkOrientation -xfce_itembar_get_orientation (XfceItembar * itembar) +GtkOrientation +xfce_itembar_get_orientation (XfceItembar *itembar) { XfceItembarPrivate *priv; - + g_return_val_if_fail (XFCE_IS_ITEMBAR (itembar), DEFAULT_ORIENTATION); priv = XFCE_ITEMBAR_GET_PRIVATE (itembar); @@ -1026,6 +1060,8 @@ xfce_itembar_get_orientation (XfceItembar * itembar) return priv->orientation; } + + /** * xfce_itembar_set_orientation: * @itembar : an #XfceItembar @@ -1033,11 +1069,12 @@ xfce_itembar_get_orientation (XfceItembar * itembar) * * Set the orienation of @itembar. **/ -void -xfce_itembar_set_orientation (XfceItembar * itembar, GtkOrientation orientation) +void +xfce_itembar_set_orientation (XfceItembar *itembar, + GtkOrientation orientation) { XfceItembarPrivate *priv; - + g_return_if_fail (XFCE_IS_ITEMBAR (itembar)); priv = XFCE_ITEMBAR_GET_PRIVATE (itembar); @@ -1047,7 +1084,7 @@ xfce_itembar_set_orientation (XfceItembar * itembar, GtkOrientation orientation) priv->orientation = orientation; - g_signal_emit (itembar, itembar_signals[ORIENTATION_CHANGED], 0, + g_signal_emit (G_OBJECT (itembar), itembar_signals[ORIENTATION_CHANGED], 0, orientation); g_object_notify (G_OBJECT (itembar), "orientation"); @@ -1056,6 +1093,7 @@ xfce_itembar_set_orientation (XfceItembar * itembar, GtkOrientation orientation) } + /** * xfce_itembar_insert: * @itembar : an #XfceItembar @@ -1065,28 +1103,33 @@ xfce_itembar_set_orientation (XfceItembar * itembar, GtkOrientation orientation) * Insert new item at @position on @itembar. **/ void -xfce_itembar_insert (XfceItembar * itembar, GtkWidget * item, int position) +xfce_itembar_insert (XfceItembar *itembar, + GtkWidget *item, + gint position) { XfceItembarPrivate *priv; - XfceItembarChild *child; - + XfceItembarChild *child; + g_return_if_fail (XFCE_IS_ITEMBAR (itembar)); g_return_if_fail (item != NULL && GTK_WIDGET (item)->parent == NULL); priv = XFCE_ITEMBAR_GET_PRIVATE (itembar); - + child = panel_slice_new0 (XfceItembarChild); + child->widget = item; - - priv->children = g_list_insert (priv->children, child, position); + + priv->children = g_slist_insert (priv->children, child, position); gtk_widget_set_parent (GTK_WIDGET (item), GTK_WIDGET (itembar)); gtk_widget_queue_resize (GTK_WIDGET (itembar)); - + g_signal_emit (G_OBJECT (itembar), itembar_signals [CONTENTS_CHANGED], 0); } + + /** * xfce_itembar_append: * @itembar : an #XfceItembar @@ -1095,11 +1138,14 @@ xfce_itembar_insert (XfceItembar * itembar, GtkWidget * item, int position) * Add a new item at the end of @itembar. **/ void -xfce_itembar_append (XfceItembar * itembar, GtkWidget * item) +xfce_itembar_append (XfceItembar *itembar, + GtkWidget *item) { xfce_itembar_insert (itembar, item, -1); } + + /** * xfce_itembar_prepend: * @itembar : an #XfceItembar @@ -1108,11 +1154,14 @@ xfce_itembar_append (XfceItembar * itembar, GtkWidget * item) * Add a new item at the start of @itembar. **/ void -xfce_itembar_prepend (XfceItembar * itembar, GtkWidget * item) +xfce_itembar_prepend (XfceItembar *itembar, + GtkWidget *item) { xfce_itembar_insert (itembar, item, 0); } + + /** * xfce_itembar_reorder_child: * @itembar : an #XfceItembar @@ -1122,31 +1171,33 @@ xfce_itembar_prepend (XfceItembar * itembar, GtkWidget * item) * Move @item to a new position on @itembar. **/ void -xfce_itembar_reorder_child (XfceItembar * itembar, GtkWidget * item, - int position) +xfce_itembar_reorder_child (XfceItembar *itembar, + GtkWidget *item, + gint position) { XfceItembarPrivate *priv; - GList *l; - + XfceItembarChild *child; + GSList *l; + g_return_if_fail (XFCE_IS_ITEMBAR (itembar)); - g_return_if_fail (item != NULL + g_return_if_fail (item != NULL && GTK_WIDGET (item)->parent == GTK_WIDGET (itembar)); priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (itembar)); - + for (l = priv->children; l != NULL; l = l->next) { - XfceItembarChild *child = l->data; + child = l->data; if (item == child->widget) { - priv->children = g_list_delete_link (priv->children, l); + priv->children = g_slist_delete_link (priv->children, l); - priv->children = g_list_insert (priv->children, child, position); + priv->children = g_slist_insert (priv->children, child, position); gtk_widget_queue_resize (GTK_WIDGET (itembar)); - - g_signal_emit (G_OBJECT (itembar), + + g_signal_emit (G_OBJECT (itembar), itembar_signals [CONTENTS_CHANGED], 0); break; @@ -1154,6 +1205,8 @@ xfce_itembar_reorder_child (XfceItembar * itembar, GtkWidget * item, } } + + /** * xfce_itembar_get_child_expand: * @itembar : an #XfceItembar @@ -1162,32 +1215,34 @@ xfce_itembar_reorder_child (XfceItembar * itembar, GtkWidget * item, * Returns: %TRUE if @item will expand when the size of @itembar increases, * otherwise %FALSE. **/ -gboolean -xfce_itembar_get_child_expand (XfceItembar * itembar, GtkWidget * item) +gboolean +xfce_itembar_get_child_expand (XfceItembar *itembar, + GtkWidget *item) { XfceItembarPrivate *priv; - GList *l; - + XfceItembarChild *child; + GSList *l; + g_return_val_if_fail (XFCE_IS_ITEMBAR (itembar), FALSE); - g_return_val_if_fail (item != NULL && + g_return_val_if_fail (item != NULL && GTK_WIDGET (item)->parent == GTK_WIDGET (itembar), FALSE); priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (itembar)); - + for (l = priv->children; l != NULL; l = l->next) { - XfceItembarChild *child = l->data; + child = l->data; if (item == child->widget) - { return child->expand; - } } return FALSE; } + + /** * xfce_itembar_set_child_expand: * @itembar : an #XfceItembar @@ -1196,22 +1251,24 @@ xfce_itembar_get_child_expand (XfceItembar * itembar, GtkWidget * item) * * Sets whether @item should expand when the size of @itembar increases. **/ -void -xfce_itembar_set_child_expand (XfceItembar * itembar, GtkWidget * item, - gboolean expand) +void +xfce_itembar_set_child_expand (XfceItembar *itembar, + GtkWidget *item, + gboolean expand) { XfceItembarPrivate *priv; - GList *l; - + XfceItembarChild *child; + GSList *l; + g_return_if_fail (XFCE_IS_ITEMBAR (itembar)); - g_return_if_fail (item != NULL + g_return_if_fail (item != NULL && GTK_WIDGET (item)->parent == GTK_WIDGET (itembar)); priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (itembar)); - + for (l = priv->children; l != NULL; l = l->next) { - XfceItembarChild *child = l->data; + child = l->data; if (item == child->widget) { @@ -1223,24 +1280,28 @@ xfce_itembar_set_child_expand (XfceItembar * itembar, GtkWidget * item, gtk_widget_queue_resize (GTK_WIDGET (itembar)); } + + /** * xfce_itembar_get_n_items: * @itembar : an #XfceItembar * * Returns: the number of items on @itembar. **/ -int -xfce_itembar_get_n_items (XfceItembar * itembar) +gint +xfce_itembar_get_n_items (XfceItembar *itembar) { XfceItembarPrivate *priv; - + g_return_val_if_fail (XFCE_IS_ITEMBAR (itembar), 0); priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (itembar)); - - return g_list_length (priv->children); + + return g_slist_length (priv->children); } + + /** * xfce_itembar_get_item_index: * @itembar : an #XfceItembar @@ -1248,23 +1309,25 @@ xfce_itembar_get_n_items (XfceItembar * itembar) * * Returns: the index of @item or -1 if @itembar does not contain @item. **/ -int -xfce_itembar_get_item_index (XfceItembar * itembar, GtkWidget * item) +gint +xfce_itembar_get_item_index (XfceItembar *itembar, + GtkWidget *item) { XfceItembarPrivate *priv; - GList *l; - int n; - + XfceItembarChild *child; + GSList *l; + gint n; + g_return_val_if_fail (XFCE_IS_ITEMBAR (itembar), -1); - g_return_val_if_fail (item != NULL - && GTK_WIDGET (item)->parent + g_return_val_if_fail (item != NULL + && GTK_WIDGET (item)->parent == GTK_WIDGET (itembar), -1); priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (itembar)); - + for (n = 0, l = priv->children; l != NULL; l = l->next, ++n) { - XfceItembarChild *child = l->data; + child = l->data; if (item == child->widget) { @@ -1275,6 +1338,8 @@ xfce_itembar_get_item_index (XfceItembar * itembar, GtkWidget * item) return -1; } + + /** * xfce_itembar_get_nth_item: * @itembar : an #XfceItembar @@ -1284,38 +1349,41 @@ xfce_itembar_get_item_index (XfceItembar * itembar, GtkWidget * item) * itembar does not contain an @n<!-- -->'th item. **/ GtkWidget * -xfce_itembar_get_nth_item (XfceItembar * itembar, int n) +xfce_itembar_get_nth_item (XfceItembar *itembar, + gint n) { XfceItembarPrivate *priv; - XfceItembarChild *child; - int n_items; + XfceItembarChild *child; + gint n_items; g_return_val_if_fail (XFCE_IS_ITEMBAR (itembar), NULL); priv = XFCE_ITEMBAR_GET_PRIVATE (itembar); - n_items = g_list_length (priv->children); + n_items = g_slist_length (priv->children); if (n < 0 || n >= n_items) - return NULL; + return NULL; - child = g_list_nth_data (priv->children, n); + child = g_slist_nth_data (priv->children, n); return child->widget; } + + /** * xfce_itembar_raise_event_window: * @itembar : an #XfceItembar * * Raise the event window of @itembar. This causes all events, like - * mouse clicks or key presses to be send to the itembar and not to + * mouse clicks or key presses to be send to the itembar and not to * any item. * * See also: xfce_itembar_lower_event_window() **/ void -xfce_itembar_raise_event_window (XfceItembar * itembar) +xfce_itembar_raise_event_window (XfceItembar *itembar) { XfceItembarPrivate *priv; @@ -1329,6 +1397,8 @@ xfce_itembar_raise_event_window (XfceItembar * itembar) gdk_window_raise (priv->event_window); } + + /** * xfce_itembar_lower_event_window: * @itembar : an #XfceItembar @@ -1340,7 +1410,7 @@ xfce_itembar_raise_event_window (XfceItembar * itembar) * See also: xfce_itembar_raise_event_window() **/ void -xfce_itembar_lower_event_window (XfceItembar * itembar) +xfce_itembar_lower_event_window (XfceItembar *itembar) { XfceItembarPrivate *priv; @@ -1354,6 +1424,8 @@ xfce_itembar_lower_event_window (XfceItembar * itembar) gdk_window_lower (priv->event_window); } + + /** * xfce_itembar_event_window_is_raised: * @itembar : an #XfceItembar @@ -1361,7 +1433,7 @@ xfce_itembar_lower_event_window (XfceItembar * itembar) * Returns: %TRUE if event window is raised. **/ gboolean -xfce_itembar_event_window_is_raised (XfceItembar * itembar) +xfce_itembar_event_window_is_raised (XfceItembar *itembar) { XfceItembarPrivate *priv; @@ -1372,6 +1444,8 @@ xfce_itembar_event_window_is_raised (XfceItembar * itembar) return priv->raised; } + + /** * xfce_itembar_get_item_at_point: * @itembar : an #XfceItembar @@ -1381,25 +1455,30 @@ xfce_itembar_event_window_is_raised (XfceItembar * itembar) * Returns: a #GtkWidget or %NULL. **/ GtkWidget * -xfce_itembar_get_item_at_point (XfceItembar * itembar, int x, int y) +xfce_itembar_get_item_at_point (XfceItembar *itembar, + gint x, + gint y) { XfceItembarPrivate *priv; - GList *l; - + XfceItembarChild *child; + GSList *l; + GtkWidget *w; + GtkAllocation *a; + g_return_val_if_fail (XFCE_IS_ITEMBAR (itembar), NULL); priv = XFCE_ITEMBAR_GET_PRIVATE (itembar); x += GTK_WIDGET (itembar)->allocation.x; y += GTK_WIDGET (itembar)->allocation.y; - + for (l = priv->children; l != NULL; l = l->next) { - XfceItembarChild *child = l->data; - GtkWidget *w = child->widget; - GtkAllocation *a = &(w->allocation); + child = l->data; + w = child->widget; + a = &(w->allocation); - if (x >= a->x && x < a->x + a->width + if (x >= a->x && x < a->x + a->width && y >= a->y && y < a->y + a->height) { return w; @@ -1409,6 +1488,8 @@ xfce_itembar_get_item_at_point (XfceItembar * itembar, int x, int y) return NULL; } + + /** * xfce_itembar_get_drop_index: * @itembar : an #XfceItembar @@ -1421,12 +1502,14 @@ xfce_itembar_get_item_at_point (XfceItembar * itembar, int x, int y) * inserted. * * @x and @y are in @itembar coordinates. - * - * Returns: The position corresponding to the point (@x, @y) on the + * + * Returns: The position corresponding to the point (@x, @y) on the * itembar. **/ -int -xfce_itembar_get_drop_index (XfceItembar * itembar, int x, int y) +gint +xfce_itembar_get_drop_index (XfceItembar *itembar, + gint x, + gint y) { g_return_val_if_fail (XFCE_IS_ITEMBAR (itembar), FALSE); diff --git a/libxfce4panel/xfce-itembar.h b/libxfce4panel/xfce-itembar.h index 7dbc03187..808bdd5ca 100644 --- a/libxfce4panel/xfce-itembar.h +++ b/libxfce4panel/xfce-itembar.h @@ -1,30 +1,34 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2004-2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2004-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_ITEMBAR_H -#define _XFCE_ITEMBAR_H +#ifndef __XFCE_ITEMBAR_H__ +#define __XFCE_ITEMBAR_H__ #include <gtk/gtkenums.h> #include <gtk/gtkcontainer.h> +G_BEGIN_DECLS + +typedef struct _XfceItembar XfceItembar; +typedef struct _XfceItembarClass XfceItembarClass; + #define XFCE_TYPE_ITEMBAR (xfce_itembar_get_type ()) #define XFCE_ITEMBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_ITEMBAR, XfceItembar)) #define XFCE_ITEMBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_ITEMBAR, XfceItembarClass)) @@ -32,12 +36,6 @@ #define XFCE_IS_ITEMBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_ITEMBAR)) #define XFCE_ITEMBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_ITEMBAR, XfceItembarClass)) - -G_BEGIN_DECLS - -typedef struct _XfceItembar XfceItembar; -typedef struct _XfceItembarClass XfceItembarClass; - struct _XfceItembar { GtkContainer parent; @@ -48,77 +46,52 @@ struct _XfceItembarClass GtkContainerClass parent_class; /* signals */ - void (*orientation_changed) (XfceItembar * itembar, - GtkOrientation orientation); - - void (*contents_changed) (XfceItembar * itembar); - - /* Padding for future expansion */ - void (*_xfce_reserved1) (void); - void (*_xfce_reserved2) (void); - void (*_xfce_reserved3) (void); - void (*_xfce_reserved4) (void); + void (*orientation_changed) (XfceItembar *itembar, + GtkOrientation orientation); + void (*contents_changed) (XfceItembar *itembar); + + /* reserved for future expansion */ + void (*reserved1) (void); + void (*reserved2) (void); + void (*reserved3) (void); + void (*reserved4) (void); }; - -GType xfce_itembar_get_type (void) G_GNUC_CONST; - -GtkWidget *xfce_itembar_new (GtkOrientation orientation); - - -void xfce_itembar_set_orientation (XfceItembar * itembar, - GtkOrientation orientation); - -GtkOrientation xfce_itembar_get_orientation (XfceItembar * itembar); - - -void xfce_itembar_insert (XfceItembar * itembar, - GtkWidget * item, - int position); - -void xfce_itembar_append (XfceItembar * itembar, - GtkWidget * item); - -void xfce_itembar_prepend (XfceItembar * itembar, - GtkWidget * item); - -void xfce_itembar_reorder_child (XfceItembar * itembar, - GtkWidget * item, - int position); - - -void xfce_itembar_set_child_expand (XfceItembar * itembar, - GtkWidget * item, - gboolean expand); - -gboolean xfce_itembar_get_child_expand (XfceItembar * itembar, - GtkWidget * item); - - -int xfce_itembar_get_n_items (XfceItembar * itembar); - -int xfce_itembar_get_item_index (XfceItembar * itembar, - GtkWidget * item); - -GtkWidget * xfce_itembar_get_nth_item (XfceItembar * itembar, - int n); - - -void xfce_itembar_raise_event_window (XfceItembar *itembar); - -void xfce_itembar_lower_event_window (XfceItembar *itembar); - -gboolean xfce_itembar_event_window_is_raised (XfceItembar * itembar); - - -GtkWidget * xfce_itembar_get_item_at_point (XfceItembar * itembar, - int x, - int y); - -int xfce_itembar_get_drop_index (XfceItembar * itembar, - int x, - int y); +GType xfce_itembar_get_type (void) G_GNUC_CONST; +GtkWidget *xfce_itembar_new (GtkOrientation orientation) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +void xfce_itembar_set_orientation (XfceItembar *itembar, + GtkOrientation orientation); +GtkOrientation xfce_itembar_get_orientation (XfceItembar *itembar); +void xfce_itembar_insert (XfceItembar *itembar, + GtkWidget *item, + gint position); +void xfce_itembar_append (XfceItembar *itembar, + GtkWidget *item); +void xfce_itembar_prepend (XfceItembar *itembar, + GtkWidget *item); +void xfce_itembar_reorder_child (XfceItembar *itembar, + GtkWidget *item, + gint position); +void xfce_itembar_set_child_expand (XfceItembar *itembar, + GtkWidget *item, + gboolean expand); +gboolean xfce_itembar_get_child_expand (XfceItembar *itembar, + GtkWidget *item); +gint xfce_itembar_get_n_items (XfceItembar *itembar); +gint xfce_itembar_get_item_index (XfceItembar *itembar, + GtkWidget *item); +GtkWidget *xfce_itembar_get_nth_item (XfceItembar *itembar, + gint n) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +void xfce_itembar_raise_event_window (XfceItembar *itembar); +void xfce_itembar_lower_event_window (XfceItembar *itembar); +gboolean xfce_itembar_event_window_is_raised (XfceItembar *itembar); +GtkWidget *xfce_itembar_get_item_at_point (XfceItembar *itembar, + gint x, + gint y) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +gint xfce_itembar_get_drop_index (XfceItembar *itembar, + gint x, + gint y); G_END_DECLS -#endif /* _XFCE_ITEMBAR_H */ +#endif /* !__XFCE_ITEMBAR_H__ */ diff --git a/libxfce4panel/xfce-marshal.list b/libxfce4panel/xfce-marshal.list index 46ed80073..bfaf88c22 100644 --- a/libxfce4panel/xfce-marshal.list +++ b/libxfce4panel/xfce-marshal.list @@ -1,5 +1,2 @@ -BOOLEAN:ENUM -BOOLEAN:BOOLEAN BOOLEAN:INT -BOOLEAN:INT,INT,INT VOID:INT,INT diff --git a/libxfce4panel/xfce-panel-convenience.c b/libxfce4panel/xfce-panel-convenience.c index 461a318ec..840cc534d 100644 --- a/libxfce4panel/xfce-panel-convenience.c +++ b/libxfce4panel/xfce-panel-convenience.c @@ -1,22 +1,21 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2006 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2006-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H @@ -36,10 +35,11 @@ * * Returns: newly created #GtkButton. **/ -GtkWidget *xfce_create_panel_button (void) +GtkWidget * +xfce_create_panel_button (void) { GtkWidget *button = gtk_button_new (); - + GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_DEFAULT|GTK_CAN_FOCUS); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE); @@ -49,18 +49,21 @@ GtkWidget *xfce_create_panel_button (void) return button; } + + /** * xfce_create_panel_button: * - * Create regular #GtkToggleButton with a few properties set to be useful in + * Create regular #GtkToggleButton with a few properties set to be useful in * Xfce panel: Flat (%GTK_RELIEF_NONE), no focus on click and minimal padding. * * Returns: newly created #GtkToggleButton. **/ -GtkWidget *xfce_create_panel_toggle_button (void) +GtkWidget * +xfce_create_panel_toggle_button (void) { GtkWidget *button = gtk_toggle_button_new (); - + GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_DEFAULT|GTK_CAN_FOCUS); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE); @@ -70,6 +73,8 @@ GtkWidget *xfce_create_panel_toggle_button (void) return button; } + + /** * xfce_allow_panel_customization: * @@ -79,16 +84,15 @@ GtkWidget *xfce_create_panel_toggle_button (void) * Returns: %TRUE if the user is allowed to customize the panel, %FALSE * otherwise. **/ -gboolean +gboolean xfce_allow_panel_customization (void ) { - static gboolean allow_customization = FALSE; - static gboolean checked = FALSE; + static gboolean allow_customization = FALSE; + static gboolean checked = FALSE; + XfceKiosk *kiosk; if (G_UNLIKELY (!checked)) { - XfceKiosk *kiosk = NULL; - kiosk = xfce_kiosk_new ("xfce4-panel"); allow_customization = xfce_kiosk_query (kiosk, "CustomizePanel"); xfce_kiosk_free (kiosk); @@ -97,4 +101,3 @@ xfce_allow_panel_customization (void ) return allow_customization; } - diff --git a/libxfce4panel/xfce-panel-convenience.h b/libxfce4panel/xfce-panel-convenience.h index bfa4aaf26..ec9ad2d71 100644 --- a/libxfce4panel/xfce-panel-convenience.h +++ b/libxfce4panel/xfce-panel-convenience.h @@ -1,41 +1,34 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2006 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2006-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_PANEL_CONVENIENCE_H -#define _XFCE_PANEL_CONVENIENCE_H +#ifndef __XFCE_PANEL_CONVENIENCE_H__ +#define __XFCE_PANEL_CONVENIENCE_H__ #include <gtk/gtkwidget.h> G_BEGIN_DECLS -/* widgets */ - -GtkWidget *xfce_create_panel_button (void); - -GtkWidget *xfce_create_panel_toggle_button (void); - -/* configuration */ - -gboolean xfce_allow_panel_customization (void ); +GtkWidget *xfce_create_panel_button (void) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +GtkWidget *xfce_create_panel_toggle_button (void) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +gboolean xfce_allow_panel_customization (void); G_END_DECLS -#endif /* _XFCE_PANEL_CONVENIENCE_H */ +#endif /* !__XFCE_PANEL_CONVENIENCE_H__ */ diff --git a/libxfce4panel/xfce-panel-enums.h b/libxfce4panel/xfce-panel-enums.h index 3febdd6a0..92630ebf4 100644 --- a/libxfce4panel/xfce-panel-enums.h +++ b/libxfce4panel/xfce-panel-enums.h @@ -1,29 +1,27 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_PANEL_ENUMS_H -#define _XFCE_PANEL_ENUMS_H +#ifndef __XFCE_PANEL_ENUMS_H__ +#define __XFCE_PANEL_ENUMS_H__ G_BEGIN_DECLS - /** * XfceScreenPosition * @XFCE_SCREEN_POSITION_NONE : No position has been set. @@ -45,13 +43,13 @@ G_BEGIN_DECLS * There are three screen positions for each side of the screen: * LEFT/TOP, CENTER and RIGHT/BOTTOM. The XfceScreenPosition is expressed * as navigational direction, with possible addition of H or V to denote - * horizontal and vertical orientation. Additionally there are two floating + * horizontal and vertical orientation. Additionally there are two floating * positions, horizontal and vertical. **/ typedef enum /*<enum,prefix=XFCE_SCREEN_POSITION >*/ { XFCE_SCREEN_POSITION_NONE, - + /* top */ XFCE_SCREEN_POSITION_NW_H, /* North West Horizontal */ XFCE_SCREEN_POSITION_N, /* North */ @@ -61,7 +59,7 @@ typedef enum /*<enum,prefix=XFCE_SCREEN_POSITION >*/ XFCE_SCREEN_POSITION_NW_V, /* North West Vertical */ XFCE_SCREEN_POSITION_W, /* West */ XFCE_SCREEN_POSITION_SW_V, /* South West Vertical */ - + /* right */ XFCE_SCREEN_POSITION_NE_V, /* North East Vertical */ XFCE_SCREEN_POSITION_E, /* East */ @@ -150,5 +148,4 @@ XfceScreenPosition; G_END_DECLS -#endif /* _PANEL_ENUMS_H */ - +#endif /* !__PANEL_ENUMS_H__ */ diff --git a/libxfce4panel/xfce-panel-external-item.c b/libxfce4panel/xfce-panel-external-item.c index ba91c7a18..ba7b11ef5 100644 --- a/libxfce4panel/xfce-panel-external-item.c +++ b/libxfce4panel/xfce-panel-external-item.c @@ -1,22 +1,21 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H @@ -25,9 +24,11 @@ #include <string.h> #include <gtk/gtk.h> -#include <libxfcegui4/libxfcegui4.h> #include <errno.h> +#include <sys/types.h> +#include <unistd.h> + #include "xfce-panel-enum-types.h" #include "xfce-panel-item-iface.h" #include "xfce-panel-external-item.h" @@ -38,85 +39,68 @@ XfceExternalPanelItemPrivate)) + typedef struct _XfceExternalPanelItemPrivate XfceExternalPanelItemPrivate; struct _XfceExternalPanelItemPrivate { - char *name; - char *id; - char *display_name; - int size; - XfceScreenPosition screen_position; + gchar *name; + gchar *id; + gchar *display_name; + gint size; + XfceScreenPosition screen_position; + + guint expand : 1; - guint expand:1; /* detect problems */ - guint to_be_removed:1; - guint restart:1; + guint to_be_removed : 1; + guint restart : 1; - char *file; + gchar *file; }; -/* item interface */ -static void xfce_external_panel_item_interface_init (gpointer g_iface, - gpointer data); - -static G_CONST_RETURN char * - xfce_external_panel_item_get_name (XfcePanelItem * item); - -static G_CONST_RETURN char * - xfce_external_panel_item_get_id (XfcePanelItem * item); -static G_CONST_RETURN char * - xfce_external_panel_item_get_display_name (XfcePanelItem * item); - -static gboolean xfce_external_panel_item_get_expand (XfcePanelItem * item); - -static void xfce_external_panel_item_free_data (XfcePanelItem * item); - -static void xfce_external_panel_item_save (XfcePanelItem * item); - -static void xfce_external_panel_item_set_size (XfcePanelItem * item, - int size); - -static void - xfce_external_panel_item_set_screen_position (XfcePanelItem * item, - XfceScreenPosition position); +static void xfce_external_panel_item_interface_init (gpointer g_iface, + gpointer data); +static const gchar *xfce_external_panel_item_get_name (XfcePanelItem *item); +static const gchar *xfce_external_panel_item_get_id (XfcePanelItem *item); +static const gchar *xfce_external_panel_item_get_display_name (XfcePanelItem *item); +static gboolean xfce_external_panel_item_get_expand (XfcePanelItem *item); +static void xfce_external_panel_item_free_data (XfcePanelItem *item); +static void xfce_external_panel_item_save (XfcePanelItem *item); +static void xfce_external_panel_item_set_size (XfcePanelItem *item, + gint size); +static void xfce_external_panel_item_set_screen_position (XfcePanelItem *item, + XfceScreenPosition position); +static void xfce_external_panel_item_set_sensitive (XfcePanelItem *item, + gboolean sensitive); +static void xfce_external_panel_item_remove (XfcePanelItem *item); +static void xfce_external_panel_item_configure (XfcePanelItem *item); +static void xfce_external_panel_item_finalize (GObject *object); +static gboolean xfce_external_panel_item_button_press_event (GtkWidget *widget, + GdkEventButton *ev); +static gboolean _item_event_received (XfceExternalPanelItem *item, + GdkEventClient *ev); +static void _item_construct (XfceExternalPanelItem *item); +static void _item_setup (XfceExternalPanelItem *item, + const gchar *file); +static void _item_screen_changed (XfceExternalPanelItem *item, + GdkScreen *screen); -static void xfce_external_panel_item_set_sensitive (XfcePanelItem *item, - gboolean sensitive); - -static void xfce_external_panel_item_remove (XfcePanelItem * item); - -static void xfce_external_panel_item_configure (XfcePanelItem * item); - - -/* GObject */ -static void xfce_external_panel_item_finalize (GObject * object); - -/* GtkWidget */ -static gboolean xfce_external_panel_item_button_press_event (GtkWidget *widget, - GdkEventButton *ev); - -/* internal functions */ -static gboolean _item_event_received (XfceExternalPanelItem * item, - GdkEventClient * ev); - -static void _item_construct (XfceExternalPanelItem * item); - -static void _item_screen_changed (XfceExternalPanelItem * item, GdkScreen *screen); - -static void _item_setup (XfceExternalPanelItem * item, const char *file); /* type definition and initialization */ G_DEFINE_TYPE_EXTENDED (XfceExternalPanelItem, xfce_external_panel_item, GTK_TYPE_SOCKET, 0, G_IMPLEMENT_INTERFACE (XFCE_TYPE_PANEL_ITEM, - xfce_external_panel_item_interface_init)); + xfce_external_panel_item_interface_init)) + + static void -xfce_external_panel_item_interface_init (gpointer g_iface, gpointer data) +xfce_external_panel_item_interface_init (gpointer g_iface, + gpointer data) { XfcePanelItemInterface *iface = g_iface; @@ -133,10 +117,12 @@ xfce_external_panel_item_interface_init (gpointer g_iface, gpointer data) iface->configure = xfce_external_panel_item_configure; } + + static void -xfce_external_panel_item_class_init (XfceExternalPanelItemClass * klass) +xfce_external_panel_item_class_init (XfceExternalPanelItemClass *klass) { - GObjectClass *object_class; + GObjectClass *object_class; GtkWidgetClass *widget_class; g_type_class_add_private (klass, sizeof (XfceExternalPanelItemPrivate)); @@ -146,12 +132,14 @@ xfce_external_panel_item_class_init (XfceExternalPanelItemClass * klass) object_class->finalize = xfce_external_panel_item_finalize; - widget_class->button_press_event = + widget_class->button_press_event = xfce_external_panel_item_button_press_event; } + + static void -xfce_external_panel_item_init (XfceExternalPanelItem * item) +xfce_external_panel_item_init (XfceExternalPanelItem *item) { XfceExternalPanelItemPrivate *priv; @@ -168,9 +156,10 @@ xfce_external_panel_item_init (XfceExternalPanelItem * item) priv->file = NULL; } -/* GObject */ + + static void -xfce_external_panel_item_finalize (GObject * object) +xfce_external_panel_item_finalize (GObject *object) { XfceExternalPanelItemPrivate *priv; @@ -191,24 +180,26 @@ xfce_external_panel_item_finalize (GObject * object) G_OBJECT_CLASS (xfce_external_panel_item_parent_class)->finalize (object); } -/* Widget */ -static gboolean -xfce_external_panel_item_button_press_event (GtkWidget *widget, + + +static gboolean +xfce_external_panel_item_button_press_event (GtkWidget *widget, GdkEventButton *ev) { guint modifiers; modifiers = gtk_accelerator_get_default_mod_mask (); - if (ev->button == 3 || (ev->button == 1 && + if (ev->button == 3 || (ev->button == 1 && (ev->state & modifiers) == GDK_CONTROL_MASK)) { gdk_pointer_ungrab (ev->time); gdk_keyboard_ungrab (ev->time); xfce_panel_plugin_message_send (widget->window, - GDK_WINDOW_XID (GTK_SOCKET (widget)->plug_window), - XFCE_PANEL_PLUGIN_POPUP_MENU, 0); + GDK_WINDOW_XID (GTK_SOCKET (widget)-> + plug_window), + XFCE_PANEL_PLUGIN_POPUP_MENU, 0); return TRUE; } @@ -216,78 +207,90 @@ xfce_external_panel_item_button_press_event (GtkWidget *widget, return FALSE; } -/* item interface */ -static G_CONST_RETURN char * -xfce_external_panel_item_get_name (XfcePanelItem * item) + + +static const gchar * +xfce_external_panel_item_get_name (XfcePanelItem *item) { XfceExternalPanelItemPrivate *priv; g_return_val_if_fail (XFCE_IS_EXTERNAL_PANEL_ITEM (item), NULL); - priv = XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE ( - XFCE_EXTERNAL_PANEL_ITEM (item)); + priv = + XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE (XFCE_EXTERNAL_PANEL_ITEM (item)); return priv->name; } -static G_CONST_RETURN char * -xfce_external_panel_item_get_id (XfcePanelItem * item) + + +static const gchar * +xfce_external_panel_item_get_id (XfcePanelItem *item) { XfceExternalPanelItemPrivate *priv; g_return_val_if_fail (XFCE_IS_EXTERNAL_PANEL_ITEM (item), NULL); - priv = XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE ( - XFCE_EXTERNAL_PANEL_ITEM (item)); + priv = + XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE (XFCE_EXTERNAL_PANEL_ITEM (item)); return priv->id; } -static G_CONST_RETURN char * -xfce_external_panel_item_get_display_name (XfcePanelItem * item) + + +static const gchar * +xfce_external_panel_item_get_display_name (XfcePanelItem *item) { XfceExternalPanelItemPrivate *priv; g_return_val_if_fail (XFCE_IS_EXTERNAL_PANEL_ITEM (item), NULL); - priv = XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE ( - XFCE_EXTERNAL_PANEL_ITEM (item)); + priv = + XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE (XFCE_EXTERNAL_PANEL_ITEM (item)); return priv->display_name; } + + gboolean -xfce_external_panel_item_get_expand (XfcePanelItem * item) +xfce_external_panel_item_get_expand (XfcePanelItem *item) { XfceExternalPanelItemPrivate *priv; g_return_val_if_fail (XFCE_IS_EXTERNAL_PANEL_ITEM (item), FALSE); - priv = XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE ( - XFCE_EXTERNAL_PANEL_ITEM (item)); + priv = + XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE (XFCE_EXTERNAL_PANEL_ITEM (item)); return priv->expand; } + + static void -xfce_external_panel_item_free_data (XfcePanelItem * item) +xfce_external_panel_item_free_data (XfcePanelItem *item) { XfceExternalPanelItemPrivate *priv; g_return_if_fail (XFCE_IS_EXTERNAL_PANEL_ITEM (item)); - priv = XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE ( - XFCE_EXTERNAL_PANEL_ITEM (item)); + priv = + XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE (XFCE_EXTERNAL_PANEL_ITEM (item)); priv->to_be_removed = TRUE; xfce_panel_plugin_message_send (GTK_WIDGET (item)->window, - GDK_WINDOW_XID (GTK_SOCKET (item)->plug_window), - XFCE_PANEL_PLUGIN_FREE_DATA, 0); + GDK_WINDOW_XID (GTK_SOCKET (item)-> + plug_window), + XFCE_PANEL_PLUGIN_FREE_DATA, 0); } + + static void -xfce_external_panel_item_save (XfcePanelItem * item) +xfce_external_panel_item_save (XfcePanelItem *item) { g_return_if_fail (XFCE_IS_EXTERNAL_PANEL_ITEM (item)); @@ -295,101 +298,120 @@ xfce_external_panel_item_save (XfcePanelItem * item) return; xfce_panel_plugin_message_send (GTK_WIDGET (item)->window, - GDK_WINDOW_XID (GTK_SOCKET (item)->plug_window), - XFCE_PANEL_PLUGIN_SAVE, 0); + GDK_WINDOW_XID (GTK_SOCKET (item)-> + plug_window), + XFCE_PANEL_PLUGIN_SAVE, 0); } + + static void -xfce_external_panel_item_set_size (XfcePanelItem * item, int size) +xfce_external_panel_item_set_size (XfcePanelItem *item, + gint size) { XfceExternalPanelItemPrivate *priv; g_return_if_fail (XFCE_IS_EXTERNAL_PANEL_ITEM (item)); - priv = XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE ( - XFCE_EXTERNAL_PANEL_ITEM (item)); + priv = + XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE (XFCE_EXTERNAL_PANEL_ITEM (item)); if (size != priv->size) { priv->size = size; xfce_panel_plugin_message_send (GTK_WIDGET (item)->window, - GDK_WINDOW_XID (GTK_SOCKET (item)->plug_window), - XFCE_PANEL_PLUGIN_SIZE, size); + GDK_WINDOW_XID (GTK_SOCKET (item)-> + plug_window), + XFCE_PANEL_PLUGIN_SIZE, size); } } + + static void -xfce_external_panel_item_set_screen_position (XfcePanelItem * item, - XfceScreenPosition position) +xfce_external_panel_item_set_screen_position (XfcePanelItem *item, + XfceScreenPosition position) { XfceExternalPanelItemPrivate *priv; g_return_if_fail (XFCE_IS_EXTERNAL_PANEL_ITEM (item)); - priv = XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE ( - XFCE_EXTERNAL_PANEL_ITEM (item)); + priv = + XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE (XFCE_EXTERNAL_PANEL_ITEM (item)); priv->screen_position = position; xfce_panel_plugin_message_send (GTK_WIDGET (item)->window, - GDK_WINDOW_XID (GTK_SOCKET (item)->plug_window), - XFCE_PANEL_PLUGIN_SCREEN_POSITION, position); + GDK_WINDOW_XID (GTK_SOCKET (item)-> + plug_window), + XFCE_PANEL_PLUGIN_SCREEN_POSITION, + position); } + + static void -delayed_set_sensitive(XfcePanelItem * item, gpointer sensitive) +delayed_set_sensitive (XfcePanelItem *item, + gpointer sensitive) { - xfce_external_panel_item_set_sensitive (item, - GPOINTER_TO_INT (sensitive)); - - g_signal_handlers_disconnect_by_func(item, - G_CALLBACK(delayed_set_sensitive), + xfce_external_panel_item_set_sensitive (item, GPOINTER_TO_INT (sensitive)); + + g_signal_handlers_disconnect_by_func(G_OBJECT (item), + G_CALLBACK(delayed_set_sensitive), sensitive); } + + static void -xfce_external_panel_item_set_sensitive (XfcePanelItem * item, - gboolean sensitive) +xfce_external_panel_item_set_sensitive (XfcePanelItem *item, + gboolean sensitive) { g_return_if_fail (XFCE_IS_EXTERNAL_PANEL_ITEM (item)); if (GDK_IS_WINDOW (GTK_SOCKET (item)->plug_window)) { xfce_panel_plugin_message_send (GTK_WIDGET (item)->window, - GDK_WINDOW_XID (GTK_SOCKET (item)->plug_window), - XFCE_PANEL_PLUGIN_SENSITIVE, sensitive ? 1 : 0); + GDK_WINDOW_XID (GTK_SOCKET (item)-> + plug_window), + XFCE_PANEL_PLUGIN_SENSITIVE, + sensitive ? 1 : 0); } else { - g_signal_connect (item, "plug-added", + g_signal_connect (G_OBJECT (item), "plug-added", G_CALLBACK(delayed_set_sensitive), GINT_TO_POINTER (sensitive)); } } -static void -xfce_external_panel_item_remove (XfcePanelItem * item) + +static void +xfce_external_panel_item_remove (XfcePanelItem *item) { g_return_if_fail (XFCE_IS_EXTERNAL_PANEL_ITEM (item)); - + xfce_panel_plugin_message_send (GTK_WIDGET (item)->window, - GDK_WINDOW_XID (GTK_SOCKET (item)->plug_window), - XFCE_PANEL_PLUGIN_REMOVE, 0); + GDK_WINDOW_XID (GTK_SOCKET (item)->plug_window), + XFCE_PANEL_PLUGIN_REMOVE, 0); } + + static void delayed_configure(XfcePanelItem *item) { xfce_external_panel_item_configure (item); - g_signal_handlers_disconnect_by_func (item, - G_CALLBACK (delayed_configure), - NULL); + g_signal_handlers_disconnect_by_func (G_OBJECT (item), + G_CALLBACK (delayed_configure), NULL); } -static void + + +static void xfce_external_panel_item_configure (XfcePanelItem * item) { g_return_if_fail (XFCE_IS_EXTERNAL_PANEL_ITEM (item)); @@ -397,26 +419,30 @@ xfce_external_panel_item_configure (XfcePanelItem * item) if (GDK_IS_WINDOW (GTK_SOCKET (item)->plug_window)) { xfce_panel_plugin_message_send (GTK_WIDGET (item)->window, - GDK_WINDOW_XID (GTK_SOCKET (item)->plug_window), - XFCE_PANEL_PLUGIN_CUSTOMIZE, 0); + GDK_WINDOW_XID (GTK_SOCKET (item)-> + plug_window), + XFCE_PANEL_PLUGIN_CUSTOMIZE, 0); } else { - g_signal_connect (item, "plug-added", + g_signal_connect (G_OBJECT (item), "plug-added", G_CALLBACK(delayed_configure), NULL); } } -/* internal functions */ + + static gboolean -_item_event_received (XfceExternalPanelItem * item, GdkEventClient * ev) +_item_event_received (XfceExternalPanelItem *item, + GdkEventClient *ev) { - GdkAtom atom = gdk_atom_intern (XFCE_PANEL_PLUGIN_ATOM, FALSE); + XfceExternalPanelItemPrivate *priv; + GdkAtom atom; + + atom = gdk_atom_intern (XFCE_PANEL_PLUGIN_ATOM, FALSE); if (ev->message_type == atom) { - XfceExternalPanelItemPrivate *priv; - priv = XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE (item); switch (ev->data.s[0]) @@ -462,8 +488,10 @@ _item_event_received (XfceExternalPanelItem * item, GdkEventClient * ev) return FALSE; } + + static void -_item_construct (XfceExternalPanelItem * item) +_item_construct (XfceExternalPanelItem *item) { GtkSocket *socket = GTK_SOCKET (item); @@ -472,12 +500,14 @@ _item_construct (XfceExternalPanelItem * item) XFCE_PANEL_PLUGIN_CONSTRUCT, 0); } + + static void -_item_screen_changed (XfceExternalPanelItem *item, +_item_screen_changed (XfceExternalPanelItem *item, GdkScreen *screen) { XfceExternalPanelItemPrivate *priv; - + priv = XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE (XFCE_EXTERNAL_PANEL_ITEM (item)); /* quit when we're going to close the plugin */ @@ -503,24 +533,27 @@ _item_screen_changed (XfceExternalPanelItem *item, } } + + static void -_item_setup (XfceExternalPanelItem * item, const char *file) +_item_setup (XfceExternalPanelItem *item, + const gchar *file) { - GdkScreen *gscreen; - gchar *gdkdisplay_name; - char **argv = NULL; - gulong sock; - XfceExternalPanelItemPrivate *priv; + GdkScreen *gscreen; + gchar *gdkdisplay_name; + gchar **argv = NULL; + gulong sock; + XfceExternalPanelItemPrivate *priv; - g_signal_handlers_disconnect_by_func (item, G_CALLBACK (_item_setup), + g_signal_handlers_disconnect_by_func (G_OBJECT (item), G_CALLBACK (_item_setup), (gpointer) file); - priv = XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE ( - XFCE_EXTERNAL_PANEL_ITEM (item)); + priv = + XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE (XFCE_EXTERNAL_PANEL_ITEM (item)); sock = gtk_socket_get_id (GTK_SOCKET (item)); - argv = g_new (char *, 8); + argv = g_new (gchar *, 8); argv[0] = g_strdup (file); argv[1] = g_strdup_printf ("socket_id=%ld", sock); @@ -531,24 +564,24 @@ _item_setup (XfceExternalPanelItem * item, const char *file) argv[6] = g_strdup_printf ("screen_position=%d", priv->screen_position); argv[7] = NULL; - if (!priv->restart) + if (G_LIKELY (priv->restart == FALSE)) { - g_signal_connect (item, "plug-added", G_CALLBACK (_item_construct), NULL); + g_signal_connect (G_OBJECT (item), "plug-added", + G_CALLBACK (_item_construct), NULL); - g_signal_connect (item, "client-event", + g_signal_connect (G_OBJECT (item), "client-event", G_CALLBACK (_item_event_received), NULL); } gscreen = gtk_widget_get_screen (GTK_WIDGET (item)); gdkdisplay_name = gdk_screen_make_display_name (gscreen); - + switch (fork()) { case -1: g_critical ("Could not run plugin: %s", g_strerror (errno)); gtk_widget_destroy (GTK_WIDGET (item)); break; - case 0: xfce_setenv ("DISPLAY", gdkdisplay_name, TRUE); g_free (gdkdisplay_name); @@ -557,23 +590,20 @@ _item_setup (XfceExternalPanelItem * item, const char *file) g_critical ("Could not run plugin: %s", g_strerror (errno)); gtk_widget_destroy (GTK_WIDGET (item)); _exit (1); - break; - default: /* parent: do nothing */; - if (!priv->restart) + if (G_LIKELY (priv->restart == FALSE)) { - g_signal_connect (item, "screen-changed", + g_signal_connect (G_OBJECT (item), "screen-changed", G_CALLBACK (_item_screen_changed), NULL); } - break; } - + g_free (gdkdisplay_name); g_strfreev (argv); } -/* public API */ + /** * xfce_external_panel_item_new @@ -590,13 +620,14 @@ _item_setup (XfceExternalPanelItem * item, const char *file) * Returns: a newly created #GtkWidget **/ GtkWidget * -xfce_external_panel_item_new (const char *name, - const char *id, - const char *display_name, - const char *file, - int size, XfceScreenPosition position) +xfce_external_panel_item_new (const gchar *name, + const gchar *id, + const gchar *display_name, + const gchar *file, + gint size, + XfceScreenPosition position) { - GtkWidget *item; + GtkWidget *item; XfceExternalPanelItemPrivate *priv; item = GTK_WIDGET (g_object_new (XFCE_TYPE_EXTERNAL_PANEL_ITEM, NULL)); @@ -610,9 +641,8 @@ xfce_external_panel_item_new (const char *name, priv->screen_position = position; priv->file = g_strdup (file); - g_signal_connect_after (item, "realize", G_CALLBACK (_item_setup), - (gpointer) file); + g_signal_connect_after (G_OBJECT (item), "realize", G_CALLBACK (_item_setup), + (gpointer) file); return item; } - diff --git a/libxfce4panel/xfce-panel-external-item.h b/libxfce4panel/xfce-panel-external-item.h index 20890cf93..30c153e8d 100644 --- a/libxfce4panel/xfce-panel-external-item.h +++ b/libxfce4panel/xfce-panel-external-item.h @@ -1,30 +1,34 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_EXTERNAL_PANEL_ITEM_H -#define _XFCE_EXTERNAL_PANEL_ITEM_H +#ifndef __XFCE_EXTERNAL_PANEL_ITEM_H__ +#define __XFCE_EXTERNAL_PANEL_ITEM_H__ #include <gtk/gtksocket.h> #include <libxfce4panel/xfce-panel-enums.h> +G_BEGIN_DECLS + +typedef struct _XfceExternalPanelItem XfceExternalPanelItem; +typedef struct _XfceExternalPanelItemClass XfceExternalPanelItemClass; + #define XFCE_TYPE_EXTERNAL_PANEL_ITEM (xfce_external_panel_item_get_type ()) #define XFCE_EXTERNAL_PANEL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_EXTERNAL_PANEL_ITEM, XfceExternalPanelItem)) #define XFCE_EXTERNAL_PANEL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_EXTERNAL_PANEL_ITEM, XfceExternalPanelItemClass)) @@ -32,12 +36,6 @@ #define XFCE_IS_EXTERNAL_PANEL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_EXTERNAL_PANEL_ITEM)) #define XFCE_EXTERNAL_PANEL_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_EXTERNAL_PANEL_ITEM, XfceExternalPanelItemClass)) - -G_BEGIN_DECLS - -typedef struct _XfceExternalPanelItem XfceExternalPanelItem; -typedef struct _XfceExternalPanelItemClass XfceExternalPanelItemClass; - struct _XfceExternalPanelItem { GtkSocket parent; @@ -48,16 +46,14 @@ struct _XfceExternalPanelItemClass GtkSocketClass parent_class; }; - -GType xfce_external_panel_item_get_type (void) G_GNUC_CONST; - -GtkWidget *xfce_external_panel_item_new (const char *name, - const char *id, - const char *display_name, - const char *file, - int size, - XfceScreenPosition position); +GType xfce_external_panel_item_get_type (void) G_GNUC_CONST; +GtkWidget *xfce_external_panel_item_new (const gchar *name, + const gchar *id, + const gchar *display_name, + const gchar *file, + gint size, + XfceScreenPosition position) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; G_END_DECLS -#endif /* _XFCE_EXTERNAL_PANEL_ITEM_H */ +#endif /* !__XFCE_EXTERNAL_PANEL_ITEM_H__ */ diff --git a/libxfce4panel/xfce-panel-external-plugin.c b/libxfce4panel/xfce-panel-external-plugin.c index fa43a2d85..4a46b49b3 100644 --- a/libxfce4panel/xfce-panel-external-plugin.c +++ b/libxfce4panel/xfce-panel-external-plugin.c @@ -1,22 +1,21 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H @@ -30,6 +29,7 @@ #include <gtk/gtk.h> +#include "xfce-panel-macros.h" #include "xfce-panel-enum-types.h" #include "xfce-panel-plugin-iface.h" #include "xfce-panel-plugin-iface-private.h" @@ -39,6 +39,11 @@ #define XFCE_EXTERNAL_PANEL_PLUGIN_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFCE_TYPE_EXTERNAL_PANEL_PLUGIN, \ XfceExternalPanelPluginPrivate)) + +/* Required arguments: socket_id, name, id, display_name, size, screen_position */ +#define REQUIRED_ARGS 6 + + enum { @@ -56,100 +61,60 @@ typedef struct _XfceExternalPanelPluginPrivate XfceExternalPanelPluginPrivate; struct _XfceExternalPanelPluginPrivate { - char *name; - char *id; - char *display_name; - - int size; - XfceScreenPosition screen_position; - - XfcePanelPluginFunc construct; - gulong socket_id; - - guint expand:1; + gchar *name; + gchar *id; + gchar *display_name; + gint size; + XfceScreenPosition screen_position; + XfcePanelPluginFunc construct; + gulong socket_id; + guint expand : 1; }; -/* prototypes */ - -/* initialization */ -static void xfce_external_panel_plugin_interface_init (gpointer g_iface, - gpointer data); - -/* GObject */ -static void xfce_external_panel_plugin_finalize (GObject * object); - -static void xfce_external_panel_plugin_get_property (GObject * object, - guint prop_id, - GValue * value, - GParamSpec * pspec); - -static void xfce_external_panel_plugin_set_property (GObject * object, - guint prop_id, - const GValue * value, - GParamSpec * pspec); - -/* plugin interface */ -static void xfce_external_panel_plugin_remove (XfcePanelPlugin * plugin); -static void xfce_external_panel_plugin_set_expand (XfcePanelPlugin * plugin, - gboolean expand); - -static void -xfce_external_panel_plugin_customize_panel (XfcePanelPlugin * plugin); - -static void -xfce_external_panel_plugin_customize_items (XfcePanelPlugin * plugin); - -static void xfce_external_panel_plugin_move (XfcePanelPlugin * plugin); - -static void -xfce_external_panel_plugin_register_menu (XfcePanelPlugin * plugin, - GtkMenu *menu); - -static void xfce_external_panel_plugin_focus_panel (XfcePanelPlugin * plugin); - -static void -xfce_external_panel_plugin_set_panel_hidden (XfcePanelPlugin * plugin, - gboolean hidden); - - -/* properties */ -static void xfce_external_panel_plugin_set_name (XfceExternalPanelPlugin * - plugin, const char *name); - -static void xfce_external_panel_plugin_set_id (XfceExternalPanelPlugin * - plugin, const char *id); - -static void -xfce_external_panel_plugin_set_display_name (XfceExternalPanelPlugin * plugin, - const char *display_name); - -static void xfce_external_panel_plugin_set_size (XfceExternalPanelPlugin * - plugin, int size); - -static void -xfce_external_panel_plugin_set_screen_position (XfceExternalPanelPlugin * - plugin, - XfceScreenPosition position); - -/* messages */ -static void xfce_external_panel_plugin_construct (XfceExternalPanelPlugin * - plugin); - -static void xfce_external_panel_plugin_save (XfceExternalPanelPlugin * - plugin); - -static void xfce_external_panel_plugin_free_data (XfceExternalPanelPlugin * - plugin); - - -/* internal functions */ -static void _plugin_menu_deactivated (GtkWidget * menu, - XfceExternalPanelPlugin * plugin); +/* prototypes */ +static void xfce_external_panel_plugin_interface_init (gpointer g_iface, + gpointer data); +static void xfce_external_panel_plugin_finalize (GObject *object); +static void xfce_external_panel_plugin_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void xfce_external_panel_plugin_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void xfce_external_panel_plugin_remove (XfcePanelPlugin *plugin); +static void xfce_external_panel_plugin_set_expand (XfcePanelPlugin *plugin, + gboolean expand); +static void xfce_external_panel_plugin_customize_panel (XfcePanelPlugin *plugin); +static void xfce_external_panel_plugin_customize_items (XfcePanelPlugin *plugin); +static void xfce_external_panel_plugin_move (XfcePanelPlugin *plugin); +static void xfce_external_panel_plugin_register_menu (XfcePanelPlugin *plugin, + GtkMenu *menu); +static void xfce_external_panel_plugin_focus_panel (XfcePanelPlugin *plugin); +static void xfce_external_panel_plugin_set_panel_hidden (XfcePanelPlugin *plugin, + gboolean hidden); +static void xfce_external_panel_plugin_set_name (XfceExternalPanelPlugin *plugin, + const gchar *name); +static void xfce_external_panel_plugin_set_id (XfceExternalPanelPlugin *plugin, + const gchar *id); +static void xfce_external_panel_plugin_set_display_name (XfceExternalPanelPlugin *plugin, + const gchar *display_name); +static void xfce_external_panel_plugin_set_size (XfceExternalPanelPlugin *plugin, + gint size); +static void xfce_external_panel_plugin_set_screen_position (XfceExternalPanelPlugin *plugin, + XfceScreenPosition position); +static void xfce_external_panel_plugin_construct (XfceExternalPanelPlugin *plugin); +static void xfce_external_panel_plugin_save (XfceExternalPanelPlugin *plugin); +static void xfce_external_panel_plugin_free_data (XfceExternalPanelPlugin *plugin); +static void _plugin_menu_deactivated (GtkWidget *menu, + XfceExternalPanelPlugin *plugin); +static gboolean _plugin_event_received (GtkWidget *win, + GdkEventClient *ev, + XfceExternalPanelPlugin *plugin); -static gboolean _plugin_event_received (GtkWidget * win, GdkEventClient * ev, - XfceExternalPanelPlugin * plugin); /* type definition and initialization */ @@ -157,10 +122,13 @@ G_DEFINE_TYPE_EXTENDED (XfceExternalPanelPlugin, xfce_external_panel_plugin, GTK_TYPE_PLUG, 0, G_IMPLEMENT_INTERFACE (XFCE_TYPE_PANEL_PLUGIN, - xfce_external_panel_plugin_interface_init)); + xfce_external_panel_plugin_interface_init)) + + static void -xfce_external_panel_plugin_interface_init (gpointer g_iface, gpointer data) +xfce_external_panel_plugin_interface_init (gpointer g_iface, + gpointer data) { XfcePanelPluginInterface *iface = g_iface; @@ -174,8 +142,10 @@ xfce_external_panel_plugin_interface_init (gpointer g_iface, gpointer data) iface->set_panel_hidden = xfce_external_panel_plugin_set_panel_hidden; } + + static void -xfce_external_panel_plugin_class_init (XfceExternalPanelPluginClass * klass) +xfce_external_panel_plugin_class_init (XfceExternalPanelPluginClass *klass) { GObjectClass *object_class; @@ -188,24 +158,29 @@ xfce_external_panel_plugin_class_init (XfceExternalPanelPluginClass * klass) object_class->set_property = xfce_external_panel_plugin_set_property; /* properties */ + g_object_class_override_property (object_class, PROP_NAME, + "name"); - g_object_class_override_property (object_class, PROP_NAME, "name"); - - g_object_class_override_property (object_class, PROP_ID, "id"); + g_object_class_override_property (object_class, PROP_ID, + "id"); g_object_class_override_property (object_class, PROP_DISPLAY_NAME, "display-name"); - g_object_class_override_property (object_class, PROP_SIZE, "size"); + g_object_class_override_property (object_class, PROP_SIZE, + "size"); g_object_class_override_property (object_class, PROP_SCREEN_POSITION, "screen-position"); - g_object_class_override_property (object_class, PROP_EXPAND, "expand"); + g_object_class_override_property (object_class, PROP_EXPAND, + "expand"); } + + static void -xfce_external_panel_plugin_init (XfceExternalPanelPlugin * plugin) +xfce_external_panel_plugin_init (XfceExternalPanelPlugin *plugin) { XfceExternalPanelPluginPrivate *priv; @@ -221,10 +196,10 @@ xfce_external_panel_plugin_init (XfceExternalPanelPlugin * plugin) priv->expand = FALSE; } -/* GObject */ + static void -xfce_external_panel_plugin_finalize (GObject * object) +xfce_external_panel_plugin_finalize (GObject *object) { XfceExternalPanelPluginPrivate *priv; @@ -234,13 +209,16 @@ xfce_external_panel_plugin_finalize (GObject * object) g_free (priv->id); g_free (priv->display_name); - G_OBJECT_CLASS (xfce_external_panel_plugin_parent_class)-> - finalize (object); + G_OBJECT_CLASS (xfce_external_panel_plugin_parent_class)->finalize (object); } + + static void -xfce_external_panel_plugin_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec) +xfce_external_panel_plugin_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { XfceExternalPanelPluginPrivate *priv; @@ -272,41 +250,44 @@ xfce_external_panel_plugin_get_property (GObject * object, guint prop_id, } } + + static void -xfce_external_panel_plugin_set_property (GObject * object, guint prop_id, - const GValue * value, - GParamSpec * pspec) +xfce_external_panel_plugin_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { switch (prop_id) { case PROP_NAME: - xfce_external_panel_plugin_set_name (XFCE_EXTERNAL_PANEL_PLUGIN - (object), - g_value_get_string (value)); + xfce_external_panel_plugin_set_name ( + XFCE_EXTERNAL_PANEL_PLUGIN (object), + g_value_get_string (value)); break; case PROP_ID: - xfce_external_panel_plugin_set_id (XFCE_EXTERNAL_PANEL_PLUGIN - (object), - g_value_get_string (value)); + xfce_external_panel_plugin_set_id ( + XFCE_EXTERNAL_PANEL_PLUGIN (object), + g_value_get_string (value)); break; case PROP_DISPLAY_NAME: - xfce_external_panel_plugin_set_display_name - (XFCE_EXTERNAL_PANEL_PLUGIN (object), - g_value_get_string (value)); + xfce_external_panel_plugin_set_display_name ( + XFCE_EXTERNAL_PANEL_PLUGIN (object), + g_value_get_string (value)); case PROP_SIZE: - xfce_external_panel_plugin_set_size (XFCE_EXTERNAL_PANEL_PLUGIN - (object), - g_value_get_int (value)); + xfce_external_panel_plugin_set_size ( + XFCE_EXTERNAL_PANEL_PLUGIN (object), + g_value_get_int (value)); break; case PROP_SCREEN_POSITION: - xfce_external_panel_plugin_set_screen_position - (XFCE_EXTERNAL_PANEL_PLUGIN (object), - g_value_get_enum (value)); + xfce_external_panel_plugin_set_screen_position ( + XFCE_EXTERNAL_PANEL_PLUGIN (object), + g_value_get_enum (value)); break; case PROP_EXPAND: - xfce_external_panel_plugin_set_expand (XFCE_PANEL_PLUGIN (object), - g_value_get_boolean - (value)); + xfce_external_panel_plugin_set_expand ( + XFCE_PANEL_PLUGIN (object), + g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -314,30 +295,34 @@ xfce_external_panel_plugin_set_property (GObject * object, guint prop_id, } } -/* plugin interface */ + + static void -xfce_external_panel_plugin_remove (XfcePanelPlugin * plugin) +xfce_external_panel_plugin_remove (XfcePanelPlugin *plugin) { XfceExternalPanelPluginPrivate *priv; - char *file; + gchar *file; priv = XFCE_EXTERNAL_PANEL_PLUGIN_GET_PRIVATE (plugin); file = xfce_panel_plugin_save_location (plugin, FALSE); + if (file) { unlink (file); g_free (file); } - + xfce_panel_plugin_message_send (GTK_WIDGET (plugin)->window, priv->socket_id, XFCE_PANEL_PLUGIN_REMOVE, 0); } + + static void -xfce_external_panel_plugin_set_expand (XfcePanelPlugin * plugin, - gboolean expand) +xfce_external_panel_plugin_set_expand (XfcePanelPlugin *plugin, + gboolean expand) { XfceExternalPanelPluginPrivate *priv; @@ -354,8 +339,9 @@ xfce_external_panel_plugin_set_expand (XfcePanelPlugin * plugin, } + static void -xfce_external_panel_plugin_customize_panel (XfcePanelPlugin * plugin) +xfce_external_panel_plugin_customize_panel (XfcePanelPlugin *plugin) { XfceExternalPanelPluginPrivate *priv; @@ -366,8 +352,10 @@ xfce_external_panel_plugin_customize_panel (XfcePanelPlugin * plugin) XFCE_PANEL_PLUGIN_CUSTOMIZE, 0); } + + static void -xfce_external_panel_plugin_customize_items (XfcePanelPlugin * plugin) +xfce_external_panel_plugin_customize_items (XfcePanelPlugin *plugin) { XfceExternalPanelPluginPrivate *priv; @@ -378,42 +366,47 @@ xfce_external_panel_plugin_customize_items (XfcePanelPlugin * plugin) XFCE_PANEL_PLUGIN_CUSTOMIZE_ITEMS, 0); } -static void -xfce_external_panel_plugin_move (XfcePanelPlugin * plugin) + + +static void +xfce_external_panel_plugin_move (XfcePanelPlugin *plugin) { XfceExternalPanelPluginPrivate *priv; priv = XFCE_EXTERNAL_PANEL_PLUGIN_GET_PRIVATE (plugin); xfce_panel_plugin_message_send (GTK_WIDGET (plugin)->window, - priv->socket_id, - XFCE_PANEL_PLUGIN_MOVE, 0); + priv->socket_id, XFCE_PANEL_PLUGIN_MOVE, 0); } -static void -xfce_external_panel_plugin_register_menu (XfcePanelPlugin * plugin, - GtkMenu *menu) + + +static void +xfce_external_panel_plugin_register_menu (XfcePanelPlugin *plugin, + GtkMenu *menu) { XfceExternalPanelPluginPrivate *priv; - int id; + gint id; DBG ("register menu"); - + priv = XFCE_EXTERNAL_PANEL_PLUGIN_GET_PRIVATE (plugin); xfce_panel_plugin_message_send (GTK_WIDGET (plugin)->window, priv->socket_id, XFCE_PANEL_PLUGIN_POPUP_MENU, 0); - id = g_signal_connect (menu, "deactivate", + id = g_signal_connect (G_OBJECT (menu), "deactivate", G_CALLBACK (_plugin_menu_deactivated), plugin); - g_object_set_data (G_OBJECT (plugin), "deactivate_id", + g_object_set_data (G_OBJECT (plugin), I_("deactivate_id"), GINT_TO_POINTER (id)); } -static void -xfce_external_panel_plugin_focus_panel (XfcePanelPlugin * plugin) + + +static void +xfce_external_panel_plugin_focus_panel (XfcePanelPlugin *plugin) { XfceExternalPanelPluginPrivate *priv; @@ -424,9 +417,11 @@ xfce_external_panel_plugin_focus_panel (XfcePanelPlugin * plugin) XFCE_PANEL_PLUGIN_FOCUS, 0); } -static void -xfce_external_panel_plugin_set_panel_hidden (XfcePanelPlugin * plugin, - gboolean hidden) + + +static void +xfce_external_panel_plugin_set_panel_hidden (XfcePanelPlugin *plugin, + gboolean hidden) { XfceExternalPanelPluginPrivate *priv; @@ -437,9 +432,10 @@ xfce_external_panel_plugin_set_panel_hidden (XfcePanelPlugin * plugin, XFCE_PANEL_PLUGIN_SET_HIDDEN, hidden); } -/* item/plugin interaction */ + + static void -xfce_external_panel_plugin_construct (XfceExternalPanelPlugin * plugin) +xfce_external_panel_plugin_construct (XfceExternalPanelPlugin *plugin) { XfceExternalPanelPluginPrivate *priv; @@ -453,24 +449,29 @@ xfce_external_panel_plugin_construct (XfceExternalPanelPlugin * plugin) xfce_panel_plugin_signal_size (XFCE_PANEL_PLUGIN (plugin), priv->size); } + + static void -xfce_external_panel_plugin_save (XfceExternalPanelPlugin * plugin) +xfce_external_panel_plugin_save (XfceExternalPanelPlugin *plugin) { xfce_panel_plugin_signal_save (XFCE_PANEL_PLUGIN (plugin)); } + + static void -xfce_external_panel_plugin_free_data (XfceExternalPanelPlugin * plugin) +xfce_external_panel_plugin_free_data (XfceExternalPanelPlugin *plugin) { xfce_panel_plugin_signal_free_data (XFCE_PANEL_PLUGIN (plugin)); gtk_widget_destroy (GTK_WIDGET (plugin)); } -/* properties */ + + static void -xfce_external_panel_plugin_set_name (XfceExternalPanelPlugin * plugin, - const char *name) +xfce_external_panel_plugin_set_name (XfceExternalPanelPlugin *plugin, + const gchar *name) { XfceExternalPanelPluginPrivate *priv; @@ -480,9 +481,11 @@ xfce_external_panel_plugin_set_name (XfceExternalPanelPlugin * plugin, priv->name = g_strdup (name); } + + static void -xfce_external_panel_plugin_set_id (XfceExternalPanelPlugin * plugin, - const char *id) +xfce_external_panel_plugin_set_id (XfceExternalPanelPlugin *plugin, + const gchar *id) { XfceExternalPanelPluginPrivate *priv; @@ -492,9 +495,11 @@ xfce_external_panel_plugin_set_id (XfceExternalPanelPlugin * plugin, priv->id = g_strdup (id); } + + static void -xfce_external_panel_plugin_set_display_name (XfceExternalPanelPlugin * plugin, - const char *name) +xfce_external_panel_plugin_set_display_name (XfceExternalPanelPlugin *plugin, + const gchar *name) { XfceExternalPanelPluginPrivate *priv; @@ -504,13 +509,14 @@ xfce_external_panel_plugin_set_display_name (XfceExternalPanelPlugin * plugin, priv->display_name = g_strdup (name); } + + static void -xfce_external_panel_plugin_set_screen_position (XfceExternalPanelPlugin * - plugin, - XfceScreenPosition position) +xfce_external_panel_plugin_set_screen_position (XfceExternalPanelPlugin *plugin, + XfceScreenPosition position) { XfceExternalPanelPluginPrivate *priv; - gboolean orientation_changed; + gboolean orientation_changed; priv = XFCE_EXTERNAL_PANEL_PLUGIN_GET_PRIVATE (plugin); @@ -525,14 +531,16 @@ xfce_external_panel_plugin_set_screen_position (XfceExternalPanelPlugin * if (orientation_changed) xfce_panel_plugin_signal_orientation (XFCE_PANEL_PLUGIN (plugin), - xfce_screen_position_get_orientation (position)); + xfce_screen_position_get_orientation (position)); xfce_panel_plugin_signal_size (XFCE_PANEL_PLUGIN (plugin), priv->size); } + + static void -xfce_external_panel_plugin_set_size (XfceExternalPanelPlugin * plugin, - int size) +xfce_external_panel_plugin_set_size (XfceExternalPanelPlugin *plugin, + gint size) { XfceExternalPanelPluginPrivate *priv; @@ -547,12 +555,13 @@ xfce_external_panel_plugin_set_size (XfceExternalPanelPlugin * plugin, } -/* internal functions */ + static void -_plugin_menu_deactivated (GtkWidget * menu, XfceExternalPanelPlugin * plugin) +_plugin_menu_deactivated (GtkWidget *menu, + XfceExternalPanelPlugin *plugin) { XfceExternalPanelPluginPrivate *priv; - int id; + gint id; priv = XFCE_EXTERNAL_PANEL_PLUGIN_GET_PRIVATE (plugin); @@ -560,19 +569,22 @@ _plugin_menu_deactivated (GtkWidget * menu, XfceExternalPanelPlugin * plugin) priv->socket_id, XFCE_PANEL_PLUGIN_MENU_DEACTIVATED, 0); - id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (plugin), - "deactivate_id")); + id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (plugin), + I_("deactivate_id"))); if (id > 0) { - g_signal_handler_disconnect (menu, id); - g_object_set_data (G_OBJECT (plugin), "deactivate_id", NULL); + g_signal_handler_disconnect (G_OBJECT (menu), id); + g_object_set_data (G_OBJECT (plugin), I_("deactivate_id"), NULL); } } + + static gboolean -_plugin_event_received (GtkWidget * win, GdkEventClient * ev, - XfceExternalPanelPlugin * plugin) +_plugin_event_received (GtkWidget *win, + GdkEventClient *ev, + XfceExternalPanelPlugin *plugin) { GdkAtom atom = gdk_atom_intern (XFCE_PANEL_PLUGIN_ATOM, FALSE); @@ -594,23 +606,20 @@ _plugin_event_received (GtkWidget * win, GdkEventClient * ev, break; case XFCE_PANEL_PLUGIN_SCREEN_POSITION: xfce_external_panel_plugin_set_screen_position (plugin, - ev->data. - s[1]); + ev->data.s[1]); break; case XFCE_PANEL_PLUGIN_POPUP_MENU: xfce_panel_plugin_popup_menu (XFCE_PANEL_PLUGIN (plugin)); break; case XFCE_PANEL_PLUGIN_SENSITIVE: - xfce_panel_plugin_set_sensitive (XFCE_PANEL_PLUGIN (plugin), + xfce_panel_plugin_set_sensitive (XFCE_PANEL_PLUGIN (plugin), ev->data.s[1] == 1); break; case XFCE_PANEL_PLUGIN_REMOVE: xfce_panel_plugin_remove_confirm (XFCE_PANEL_PLUGIN (plugin)); break; case XFCE_PANEL_PLUGIN_CUSTOMIZE: - xfce_panel_plugin_signal_configure ( - XFCE_PANEL_PLUGIN (plugin)); - break; + xfce_panel_plugin_signal_configure (XFCE_PANEL_PLUGIN (plugin)); break; default: return FALSE; @@ -622,17 +631,7 @@ _plugin_event_received (GtkWidget * win, GdkEventClient * ev, return FALSE; } -/* public API */ -/* Required arguments: - * - socket_id - * - name - * - id - * - display_name - * - size - * - screen_position - */ -#define REQUIRED_ARGS 6 /** * xfce_external_panel_plugin_new @@ -647,13 +646,14 @@ _plugin_event_received (GtkWidget * win, GdkEventClient * ev, * Returns: newly created panel plugin widget. **/ GtkWidget * -xfce_external_panel_plugin_new (int argc, char **argv, - XfcePanelPluginFunc construct) +xfce_external_panel_plugin_new (gint argc, + gchar **argv, + XfcePanelPluginFunc construct) { - XfcePanelPlugin *plugin; + XfcePanelPlugin *plugin; XfceExternalPanelPluginPrivate *priv; - int i; - char *key, *value, *p; + gint i, size; + gchar *key, *value, *p; if (argc < 1 + REQUIRED_ARGS) return NULL; @@ -692,12 +692,11 @@ xfce_external_panel_plugin_new (int argc, char **argv, } else if (!priv->size && strcmp ("size", key) == 0) { - int size = (int) strtol (value, NULL, 0); - + size = (gint) strtol (value, NULL, 0); + priv->size = size; } - else if (!priv->screen_position && - strcmp ("screen_position", key) == 0) + else if (!priv->screen_position && strcmp ("screen_position", key) == 0) { priv->screen_position = (XfceScreenPosition) strtol (value, NULL, 0); @@ -717,7 +716,7 @@ xfce_external_panel_plugin_new (int argc, char **argv, GTK_WIDGET (plugin)); /* messages */ - g_signal_connect (plugin, "client-event", + g_signal_connect (G_OBJECT (plugin), "client-event", G_CALLBACK (_plugin_event_received), plugin); return GTK_WIDGET (plugin); diff --git a/libxfce4panel/xfce-panel-external-plugin.h b/libxfce4panel/xfce-panel-external-plugin.h index f12297b44..377ba5b71 100644 --- a/libxfce4panel/xfce-panel-external-plugin.h +++ b/libxfce4panel/xfce-panel-external-plugin.h @@ -1,30 +1,34 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_EXTERNAL_PANEL_PLUGIN_H -#define _XFCE_EXTERNAL_PANEL_PLUGIN_H +#ifndef __XFCE_EXTERNAL_PANEL_PLUGIN_H__ +#define __XFCE_EXTERNAL_PANEL_PLUGIN_H__ #include <gtk/gtkplug.h> #include <libxfce4panel/xfce-panel-plugin-iface.h> +G_BEGIN_DECLS + +typedef struct _XfceExternalPanelPlugin XfceExternalPanelPlugin; +typedef struct _XfceExternalPanelPluginClass XfceExternalPanelPluginClass; + #define XFCE_TYPE_EXTERNAL_PANEL_PLUGIN (xfce_external_panel_plugin_get_type ()) #define XFCE_EXTERNAL_PANEL_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_EXTERNAL_PANEL_PLUGIN, XfceExternalPanelPlugin)) #define XFCE_EXTERNAL_PANEL_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_EXTERNAL_PANEL_PLUGIN, XfceExternalPanelPluginClass)) @@ -32,12 +36,6 @@ #define XFCE_IS_EXTERNAL_PANEL_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_EXTERNAL_PANEL_PLUGIN)) #define XFCE_EXTERNAL_PANEL_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_EXTERNAL_PANEL_PLUGIN, XfceExternalPanelPluginClass)) - -G_BEGIN_DECLS - -typedef struct _XfceExternalPanelPlugin XfceExternalPanelPlugin; -typedef struct _XfceExternalPanelPluginClass XfceExternalPanelPluginClass; - struct _XfceExternalPanelPlugin { GtkPlug parent; @@ -48,13 +46,11 @@ struct _XfceExternalPanelPluginClass GtkPlugClass parent_class; }; - -GType xfce_external_panel_plugin_get_type (void) G_GNUC_CONST; - -GtkWidget *xfce_external_panel_plugin_new (int argc, - char **argv, - XfcePanelPluginFunc construct); +GType xfce_external_panel_plugin_get_type (void) G_GNUC_CONST; +GtkWidget *xfce_external_panel_plugin_new (gint argc, + gchar **argv, + XfcePanelPluginFunc construct) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; G_END_DECLS -#endif /* _XFCE_EXTERNAL_PANEL_PLUGIN_H */ +#endif /* !__XFCE_EXTERNAL_PANEL_PLUGIN_H__ */ diff --git a/libxfce4panel/xfce-panel-internal-plugin.c b/libxfce4panel/xfce-panel-internal-plugin.c index 288749632..018e6b65c 100644 --- a/libxfce4panel/xfce-panel-internal-plugin.c +++ b/libxfce4panel/xfce-panel-internal-plugin.c @@ -1,22 +1,21 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H @@ -27,6 +26,7 @@ #include <unistd.h> #include <gtk/gtk.h> +#include "xfce-panel-macros.h" #include "xfce-panel-enum-types.h" #include "xfce-panel-internal-plugin.h" #include "xfce-panel-item-iface.h" @@ -54,107 +54,61 @@ typedef struct _XfceInternalPanelPluginPrivate XfceInternalPanelPluginPrivate; struct _XfceInternalPanelPluginPrivate { - char *name; - char *id; - char *display_name; - int size; - XfceScreenPosition screen_position; - guint expand:1; + gchar *name; + gchar *id; + gchar *display_name; + gint size; + XfceScreenPosition screen_position; + guint expand : 1; }; +static void xfce_internal_panel_plugin_init_item_interface (gpointer g_iface, + gpointer data); +static const gchar *xfce_internal_panel_plugin_get_name (XfcePanelItem *plugin); +static const gchar *xfce_internal_panel_plugin_get_id (XfcePanelItem *plugin); +static const gchar *xfce_internal_panel_plugin_get_display_name (XfcePanelItem *plugin); +static gboolean xfce_internal_panel_plugin_get_expand (XfcePanelItem *item); +static void xfce_internal_panel_plugin_free_data (XfcePanelItem *plugin); +static void xfce_internal_panel_plugin_save (XfcePanelItem *plugin); +static void xfce_internal_panel_plugin_set_size (XfcePanelItem *plugin, + gint size); +static void xfce_internal_panel_plugin_set_screen_position (XfcePanelItem *plugin, + XfceScreenPosition position); +static void xfce_internal_panel_plugin_set_sensitive (XfcePanelItem *plugin, + gboolean sensitive); +static void xfce_internal_panel_plugin_remove_item (XfcePanelItem *plugin); +static void xfce_internal_panel_plugin_configure_item (XfcePanelItem *plugin); +static void xfce_internal_panel_plugin_init_plugin_interface (gpointer g_iface, + gpointer data); +static void xfce_internal_panel_plugin_remove (XfcePanelPlugin *plugin); +static void xfce_internal_panel_plugin_set_expand (XfcePanelPlugin *plugin, + gboolean expand); +static void xfce_internal_panel_plugin_customize_panel (XfcePanelPlugin *plugin); +static void xfce_internal_panel_plugin_customize_items (XfcePanelPlugin *plugin); +static void xfce_internal_panel_plugin_focus_panel (XfcePanelPlugin *plugin); +static void xfce_internal_panel_plugin_register_menu (XfcePanelPlugin *plugin, + GtkMenu *menu); +static void xfce_internal_panel_plugin_move (XfcePanelPlugin *plugin); +static void xfce_internal_panel_plugin_set_panel_hidden (XfcePanelPlugin *plugin, + gboolean hidden); +static void xfce_internal_panel_plugin_set_name (XfcePanelPlugin *plugin, + const gchar *name); +static void xfce_internal_panel_plugin_set_id (XfcePanelPlugin *plugin, + const gchar *id); +static void xfce_internal_panel_plugin_set_display_name (XfcePanelPlugin *plugin, + const gchar *name); +static void xfce_internal_panel_plugin_finalize (GObject *object); +static void xfce_internal_panel_plugin_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void xfce_internal_panel_plugin_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void _plugin_menu_deactivated (GtkWidget *menu, + XfcePanelItem *item); -/* item interface */ -static void xfce_internal_panel_plugin_init_item_interface (gpointer g_iface, - gpointer data); - -static G_CONST_RETURN char * - xfce_internal_panel_plugin_get_name (XfcePanelItem * plugin); - -static G_CONST_RETURN char * - xfce_internal_panel_plugin_get_id (XfcePanelItem * plugin); - -static G_CONST_RETURN char * - xfce_internal_panel_plugin_get_display_name (XfcePanelItem * plugin); - -static gboolean xfce_internal_panel_plugin_get_expand (XfcePanelItem * item); - -static void xfce_internal_panel_plugin_free_data (XfcePanelItem * plugin); - -static void xfce_internal_panel_plugin_save (XfcePanelItem * plugin); - -static void xfce_internal_panel_plugin_set_size (XfcePanelItem * plugin, - int size); - -static void -xfce_internal_panel_plugin_set_screen_position (XfcePanelItem * plugin, - XfceScreenPosition position); - -static void - xfce_internal_panel_plugin_set_sensitive (XfcePanelItem * plugin, - gboolean sensitive); - -static void - xfce_internal_panel_plugin_remove_item (XfcePanelItem * plugin); - -static void - xfce_internal_panel_plugin_configure_item (XfcePanelItem * plugin); - -/* plugin interface */ -static void - xfce_internal_panel_plugin_init_plugin_interface (gpointer g_iface, - gpointer data); - -static void xfce_internal_panel_plugin_remove (XfcePanelPlugin * plugin); - -static void xfce_internal_panel_plugin_set_expand (XfcePanelPlugin * plugin, - gboolean expand); - -static void xfce_internal_panel_plugin_customize_panel (XfcePanelPlugin * - plugin); - -static void xfce_internal_panel_plugin_customize_items (XfcePanelPlugin * - plugin); - -static void xfce_internal_panel_plugin_focus_panel (XfcePanelPlugin * plugin); - -static void -xfce_internal_panel_plugin_register_menu (XfcePanelPlugin * plugin, - GtkMenu *menu); - -static void xfce_internal_panel_plugin_move (XfcePanelPlugin * plugin); - -static void -xfce_internal_panel_plugin_set_panel_hidden (XfcePanelPlugin * plugin, - gboolean hidden); - -/* properties */ -static void xfce_internal_panel_plugin_set_name (XfcePanelPlugin * plugin, - const char *name); - -static void xfce_internal_panel_plugin_set_id (XfcePanelPlugin * plugin, - const char *id); - -static void - xfce_internal_panel_plugin_set_display_name (XfcePanelPlugin * plugin, - const char *name); - - -/* GObject */ -static void xfce_internal_panel_plugin_finalize (GObject * object); - -static void xfce_internal_panel_plugin_get_property (GObject * object, - guint prop_id, - GValue * value, - GParamSpec * pspec); - -static void xfce_internal_panel_plugin_set_property (GObject * object, - guint prop_id, - const GValue * value, - GParamSpec * pspec); - - -/* internal functions */ -static void _plugin_menu_deactivated (GtkWidget * menu, XfcePanelItem * item); /* type definition and initialization */ @@ -163,7 +117,9 @@ G_DEFINE_TYPE_EXTENDED (XfceInternalPanelPlugin, xfce_internal_panel_plugin, G_IMPLEMENT_INTERFACE (XFCE_TYPE_PANEL_ITEM, xfce_internal_panel_plugin_init_item_interface) G_IMPLEMENT_INTERFACE (XFCE_TYPE_PANEL_PLUGIN, - xfce_internal_panel_plugin_init_plugin_interface)); + xfce_internal_panel_plugin_init_plugin_interface)) + + static void xfce_internal_panel_plugin_init_item_interface (gpointer g_iface, @@ -184,6 +140,8 @@ xfce_internal_panel_plugin_init_item_interface (gpointer g_iface, iface->configure = xfce_internal_panel_plugin_configure_item; } + + static void xfce_internal_panel_plugin_init_plugin_interface (gpointer g_iface, gpointer data) @@ -200,8 +158,10 @@ xfce_internal_panel_plugin_init_plugin_interface (gpointer g_iface, iface->focus_panel = xfce_internal_panel_plugin_focus_panel; } + + static void -xfce_internal_panel_plugin_class_init (XfceInternalPanelPluginClass * klass) +xfce_internal_panel_plugin_class_init (XfceInternalPanelPluginClass *klass) { GObjectClass *object_class; @@ -216,22 +176,17 @@ xfce_internal_panel_plugin_class_init (XfceInternalPanelPluginClass * klass) /* properties */ g_object_class_override_property (object_class, PROP_NAME, "name"); - g_object_class_override_property (object_class, PROP_ID, "id"); - - g_object_class_override_property (object_class, PROP_DISPLAY_NAME, - "display-name"); - + g_object_class_override_property (object_class, PROP_DISPLAY_NAME, "display-name"); g_object_class_override_property (object_class, PROP_SIZE, "size"); - - g_object_class_override_property (object_class, PROP_SCREEN_POSITION, - "screen-position"); - + g_object_class_override_property (object_class, PROP_SCREEN_POSITION, "screen-position"); g_object_class_override_property (object_class, PROP_EXPAND, "expand"); } + + static void -xfce_internal_panel_plugin_init (XfceInternalPanelPlugin * plugin) +xfce_internal_panel_plugin_init (XfceInternalPanelPlugin *plugin) { XfceInternalPanelPluginPrivate *priv; @@ -245,9 +200,11 @@ xfce_internal_panel_plugin_init (XfceInternalPanelPlugin * plugin) priv->expand = FALSE; } + + /* GObject */ static void -xfce_internal_panel_plugin_finalize (GObject * object) +xfce_internal_panel_plugin_finalize (GObject *object) { XfceInternalPanelPluginPrivate *priv; @@ -257,13 +214,16 @@ xfce_internal_panel_plugin_finalize (GObject * object) g_free (priv->id); g_free (priv->display_name); - G_OBJECT_CLASS (xfce_internal_panel_plugin_parent_class)-> - finalize (object); + G_OBJECT_CLASS (xfce_internal_panel_plugin_parent_class)->finalize (object); } + + static void -xfce_internal_panel_plugin_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec) +xfce_internal_panel_plugin_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { XfceInternalPanelPluginPrivate *priv; @@ -295,10 +255,13 @@ xfce_internal_panel_plugin_get_property (GObject * object, guint prop_id, } } + + static void -xfce_internal_panel_plugin_set_property (GObject * object, guint prop_id, - const GValue * value, - GParamSpec * pspec) +xfce_internal_panel_plugin_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { XfceInternalPanelPluginPrivate *priv; @@ -308,8 +271,7 @@ xfce_internal_panel_plugin_set_property (GObject * object, guint prop_id, { case PROP_EXPAND: xfce_internal_panel_plugin_set_expand (XFCE_PANEL_PLUGIN (object), - g_value_get_boolean - (value)); + g_value_get_boolean (value)); break; case PROP_NAME: xfce_internal_panel_plugin_set_name (XFCE_PANEL_PLUGIN (object), @@ -320,20 +282,16 @@ xfce_internal_panel_plugin_set_property (GObject * object, guint prop_id, g_value_get_string (value)); break; case PROP_DISPLAY_NAME: - xfce_internal_panel_plugin_set_display_name (XFCE_PANEL_PLUGIN - (object), - g_value_get_string - (value)); + xfce_internal_panel_plugin_set_display_name (XFCE_PANEL_PLUGIN (object), + g_value_get_string (value)); break; case PROP_SIZE: xfce_internal_panel_plugin_set_size (XFCE_PANEL_ITEM (object), g_value_get_int (value)); break; case PROP_SCREEN_POSITION: - xfce_internal_panel_plugin_set_screen_position (XFCE_PANEL_ITEM - (object), - g_value_get_enum - (value)); + xfce_internal_panel_plugin_set_screen_position (XFCE_PANEL_ITEM (object), + g_value_get_enum (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -341,59 +299,69 @@ xfce_internal_panel_plugin_set_property (GObject * object, guint prop_id, } } + + /* item interface */ -static G_CONST_RETURN char * -xfce_internal_panel_plugin_get_name (XfcePanelItem * plugin) +static const gchar * +xfce_internal_panel_plugin_get_name (XfcePanelItem *plugin) { XfceInternalPanelPluginPrivate *priv; g_return_val_if_fail (XFCE_IS_INTERNAL_PANEL_PLUGIN (plugin), NULL); - priv = XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE ( - XFCE_INTERNAL_PANEL_PLUGIN (plugin)); + priv = + XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE (XFCE_INTERNAL_PANEL_PLUGIN (plugin)); return priv->name; } -static G_CONST_RETURN char * -xfce_internal_panel_plugin_get_id (XfcePanelItem * plugin) + + +static const gchar * +xfce_internal_panel_plugin_get_id (XfcePanelItem *plugin) { XfceInternalPanelPluginPrivate *priv; g_return_val_if_fail (XFCE_IS_INTERNAL_PANEL_PLUGIN (plugin), NULL); - priv = XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE ( - XFCE_INTERNAL_PANEL_PLUGIN (plugin)); + priv = + XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE (XFCE_INTERNAL_PANEL_PLUGIN (plugin)); return priv->id; } -static G_CONST_RETURN char * -xfce_internal_panel_plugin_get_display_name (XfcePanelItem * plugin) + + +static const gchar * +xfce_internal_panel_plugin_get_display_name (XfcePanelItem *plugin) { XfceInternalPanelPluginPrivate *priv; g_return_val_if_fail (XFCE_IS_INTERNAL_PANEL_PLUGIN (plugin), NULL); - priv = XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE ( - XFCE_INTERNAL_PANEL_PLUGIN (plugin)); + priv = + XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE (XFCE_INTERNAL_PANEL_PLUGIN (plugin)); return priv->display_name; } + + static gboolean -xfce_internal_panel_plugin_get_expand (XfcePanelItem * plugin) +xfce_internal_panel_plugin_get_expand (XfcePanelItem *plugin) { XfceInternalPanelPluginPrivate *priv; g_return_val_if_fail (XFCE_IS_INTERNAL_PANEL_PLUGIN (plugin), FALSE); - priv = XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE ( - XFCE_INTERNAL_PANEL_PLUGIN (plugin)); + priv = + XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE (XFCE_INTERNAL_PANEL_PLUGIN (plugin)); return priv->expand; } + + static void xfce_internal_panel_plugin_free_data (XfcePanelItem * plugin) { @@ -401,14 +369,16 @@ xfce_internal_panel_plugin_free_data (XfcePanelItem * plugin) g_return_if_fail (XFCE_IS_INTERNAL_PANEL_PLUGIN (plugin)); - priv = XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE ( - XFCE_INTERNAL_PANEL_PLUGIN (plugin)); + priv = + XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE (XFCE_INTERNAL_PANEL_PLUGIN (plugin)); xfce_panel_plugin_signal_free_data (XFCE_PANEL_PLUGIN (plugin)); gtk_widget_destroy (GTK_WIDGET (plugin)); } + + static void xfce_internal_panel_plugin_save (XfcePanelItem * plugin) { @@ -416,23 +386,25 @@ xfce_internal_panel_plugin_save (XfcePanelItem * plugin) g_return_if_fail (XFCE_IS_INTERNAL_PANEL_PLUGIN (plugin)); - priv = XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE ( - XFCE_INTERNAL_PANEL_PLUGIN (plugin)); + priv = + XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE (XFCE_INTERNAL_PANEL_PLUGIN (plugin)); xfce_panel_plugin_signal_save (XFCE_PANEL_PLUGIN (plugin)); } + + static void -xfce_internal_panel_plugin_set_screen_position (XfcePanelItem * plugin, - XfceScreenPosition position) +xfce_internal_panel_plugin_set_screen_position (XfcePanelItem *plugin, + XfceScreenPosition position) { XfceInternalPanelPluginPrivate *priv; - gboolean orientation_changed; + gboolean orientation_changed; g_return_if_fail (XFCE_IS_INTERNAL_PANEL_PLUGIN (plugin)); - priv = XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE ( - XFCE_INTERNAL_PANEL_PLUGIN (plugin)); + priv = + XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE (XFCE_INTERNAL_PANEL_PLUGIN (plugin)); orientation_changed = (xfce_screen_position_is_horizontal (position) != @@ -445,20 +417,24 @@ xfce_internal_panel_plugin_set_screen_position (XfcePanelItem * plugin, if (orientation_changed) xfce_panel_plugin_signal_orientation (XFCE_PANEL_PLUGIN (plugin), - xfce_screen_position_get_orientation (position)); + xfce_screen_position_get_orientation + (position)); xfce_panel_plugin_signal_size (XFCE_PANEL_PLUGIN (plugin), priv->size); } + + static void -xfce_internal_panel_plugin_set_size (XfcePanelItem * plugin, int size) +xfce_internal_panel_plugin_set_size (XfcePanelItem *plugin, + gint size) { XfceInternalPanelPluginPrivate *priv; g_return_if_fail (XFCE_IS_INTERNAL_PANEL_PLUGIN (plugin)); - priv = XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE ( - XFCE_INTERNAL_PANEL_PLUGIN (plugin)); + priv = + XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE (XFCE_INTERNAL_PANEL_PLUGIN (plugin)); if (size != priv->size) { @@ -468,34 +444,43 @@ xfce_internal_panel_plugin_set_size (XfcePanelItem * plugin, int size) } } + + static void -xfce_internal_panel_plugin_set_sensitive (XfcePanelItem * plugin, - gboolean sensitive) +xfce_internal_panel_plugin_set_sensitive (XfcePanelItem *plugin, + gboolean sensitive) { xfce_panel_plugin_set_sensitive (XFCE_PANEL_PLUGIN (plugin), sensitive); } + + static void -xfce_internal_panel_plugin_remove_item (XfcePanelItem * plugin) +xfce_internal_panel_plugin_remove_item (XfcePanelItem *plugin) { xfce_panel_plugin_remove_confirm (XFCE_PANEL_PLUGIN (plugin)); } + + static void -xfce_internal_panel_plugin_configure_item (XfcePanelItem * plugin) +xfce_internal_panel_plugin_configure_item (XfcePanelItem *plugin) { xfce_panel_plugin_signal_configure (XFCE_PANEL_PLUGIN (plugin)); } + + /* plugin interface */ static void -xfce_internal_panel_plugin_remove (XfcePanelPlugin * plugin) +xfce_internal_panel_plugin_remove (XfcePanelPlugin *plugin) { - char *file; + gchar *file; g_return_if_fail (XFCE_IS_INTERNAL_PANEL_PLUGIN (plugin)); file = xfce_panel_plugin_save_location (plugin, FALSE); + if (file) { unlink (file); @@ -505,16 +490,18 @@ xfce_internal_panel_plugin_remove (XfcePanelPlugin * plugin) xfce_internal_panel_plugin_free_data (XFCE_PANEL_ITEM (plugin)); } + + static void -xfce_internal_panel_plugin_set_expand (XfcePanelPlugin * plugin, - gboolean expand) +xfce_internal_panel_plugin_set_expand (XfcePanelPlugin *plugin, + gboolean expand) { XfceInternalPanelPluginPrivate *priv; g_return_if_fail (XFCE_IS_INTERNAL_PANEL_PLUGIN (plugin)); - priv = XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE ( - XFCE_INTERNAL_PANEL_PLUGIN (plugin)); + priv = + XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE (XFCE_INTERNAL_PANEL_PLUGIN (plugin)); if (expand != priv->expand) { @@ -524,124 +511,148 @@ xfce_internal_panel_plugin_set_expand (XfcePanelPlugin * plugin, } } + + static void -xfce_internal_panel_plugin_customize_panel (XfcePanelPlugin * plugin) +xfce_internal_panel_plugin_customize_panel (XfcePanelPlugin *plugin) { xfce_panel_item_customize_panel (XFCE_PANEL_ITEM (plugin)); } + + static void -xfce_internal_panel_plugin_customize_items (XfcePanelPlugin * plugin) +xfce_internal_panel_plugin_customize_items (XfcePanelPlugin *plugin) { xfce_panel_item_customize_items (XFCE_PANEL_ITEM (plugin)); } -static void -xfce_internal_panel_plugin_move (XfcePanelPlugin * plugin) + + +static void +xfce_internal_panel_plugin_move (XfcePanelPlugin *plugin) { xfce_panel_item_move (XFCE_PANEL_ITEM (plugin)); } -static void -xfce_internal_panel_plugin_set_panel_hidden (XfcePanelPlugin * plugin, - gboolean hidden) + + +static void +xfce_internal_panel_plugin_set_panel_hidden (XfcePanelPlugin *plugin, + gboolean hidden) { xfce_panel_item_set_panel_hidden (XFCE_PANEL_ITEM (plugin), hidden); } -static void -xfce_internal_panel_plugin_register_menu (XfcePanelPlugin * plugin, - GtkMenu *menu) + + +static void +xfce_internal_panel_plugin_register_menu (XfcePanelPlugin *plugin, + GtkMenu *menu) { - int id; - + gint id; + DBG ("register menu"); - + xfce_panel_item_menu_opened (XFCE_PANEL_ITEM (plugin)); - id = g_signal_connect (menu, "deactivate", + id = g_signal_connect (G_OBJECT (menu), "deactivate", G_CALLBACK (_plugin_menu_deactivated), plugin); - g_object_set_data (G_OBJECT (plugin), "deactivate_id", + + g_object_set_data (G_OBJECT (plugin), I_("deactivate_id"), GINT_TO_POINTER (id)); } -static void -xfce_internal_panel_plugin_focus_panel (XfcePanelPlugin * plugin) + + +static void +xfce_internal_panel_plugin_focus_panel (XfcePanelPlugin *plugin) { xfce_panel_item_focus_panel (XFCE_PANEL_ITEM (plugin)); } + /* properties */ static void -xfce_internal_panel_plugin_set_name (XfcePanelPlugin * plugin, - const char *name) +xfce_internal_panel_plugin_set_name (XfcePanelPlugin *plugin, + const gchar *name) { XfceInternalPanelPluginPrivate *priv; g_return_if_fail (XFCE_IS_INTERNAL_PANEL_PLUGIN (plugin)); - priv = XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE ( - XFCE_INTERNAL_PANEL_PLUGIN (plugin)); + priv = + XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE (XFCE_INTERNAL_PANEL_PLUGIN (plugin)); g_free (priv->name); priv->name = g_strdup (name); } + + static void -xfce_internal_panel_plugin_set_id (XfcePanelPlugin * plugin, const char *id) +xfce_internal_panel_plugin_set_id (XfcePanelPlugin *plugin, + const gchar *id) { XfceInternalPanelPluginPrivate *priv; g_return_if_fail (XFCE_IS_INTERNAL_PANEL_PLUGIN (plugin)); - priv = XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE ( - XFCE_INTERNAL_PANEL_PLUGIN (plugin)); + priv = + XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE (XFCE_INTERNAL_PANEL_PLUGIN (plugin)); g_free (priv->id); priv->id = g_strdup (id); } + + static void -xfce_internal_panel_plugin_set_display_name (XfcePanelPlugin * plugin, - const char *name) +xfce_internal_panel_plugin_set_display_name (XfcePanelPlugin *plugin, + const gchar *name) { XfceInternalPanelPluginPrivate *priv; g_return_if_fail (XFCE_IS_INTERNAL_PANEL_PLUGIN (plugin)); - priv = XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE ( - XFCE_INTERNAL_PANEL_PLUGIN (plugin)); + priv = + XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE (XFCE_INTERNAL_PANEL_PLUGIN (plugin)); g_free (priv->display_name); priv->display_name = g_strdup (name); } -/* internal functions */ + + +/* ginternal functions */ static void -_plugin_menu_deactivated (GtkWidget * menu, XfcePanelItem * item) +_plugin_menu_deactivated (GtkWidget *menu, + XfcePanelItem *item) { - int id; - + gint id; + xfce_panel_item_menu_deactivated (item); - id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), - "deactivate_id")); + id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "deactivate_id")); if (id > 0) { - g_signal_handler_disconnect (menu, id); - g_object_set_data (G_OBJECT (item), "deactivate_id", NULL); + g_signal_handler_disconnect (G_OBJECT (menu), id); + + g_object_set_data (G_OBJECT (item), I_("deactivate_id"), NULL); } } + + static void -_plugin_setup (XfceInternalPanelPlugin * plugin, - XfcePanelPluginFunc construct) +_plugin_setup (XfceInternalPanelPlugin *plugin, + XfcePanelPluginFunc construct) { XfceInternalPanelPluginPrivate *priv; - g_signal_handlers_disconnect_by_func (plugin, G_CALLBACK (_plugin_setup), + g_signal_handlers_disconnect_by_func (G_OBJECT (plugin), G_CALLBACK (_plugin_setup), (gpointer) construct); priv = XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE (plugin); @@ -652,7 +663,7 @@ _plugin_setup (XfceInternalPanelPlugin * plugin, xfce_panel_plugin_signal_size (XFCE_PANEL_PLUGIN (plugin), priv->size); } -/* public API */ + /** * xfce_internal_panel_plugin_new @@ -664,41 +675,39 @@ _plugin_setup (XfceInternalPanelPlugin * plugin, * @construct : #XfcePanelPluginFunc that will be called to construct the * plugin widgets. * - * Creates a new internal plugin. This function should not be used directly, + * Creates a new ginternal plugin. This function should not be used directly, * but only throught the XFCE_PANEL_PLUGIN_REGISTER_INTERNAL () macro. * * Returns: Newly created panel plugin widget. **/ GtkWidget * -xfce_internal_panel_plugin_new (const char *name, - const char *id, - const char *display_name, - int size, - XfceScreenPosition position, - XfcePanelPluginFunc construct) -{ - GtkWidget *plugin; +xfce_internal_panel_plugin_new (const gchar *name, + const gchar *id, + const gchar *display_name, + gint size, + XfceScreenPosition position, + XfcePanelPluginFunc construct) +{ + GtkWidget *plugin; XfceInternalPanelPluginPrivate *priv; - plugin = - GTK_WIDGET (g_object_new (XFCE_TYPE_INTERNAL_PANEL_PLUGIN, NULL)); + plugin = GTK_WIDGET (g_object_new (XFCE_TYPE_INTERNAL_PANEL_PLUGIN, NULL)); priv = XFCE_INTERNAL_PANEL_PLUGIN_GET_PRIVATE (plugin); - priv->name = g_strdup (name); - priv->id = g_strdup (id); - priv->display_name = g_strdup (display_name); + priv->name = g_strdup (name); + priv->id = g_strdup (id); + priv->display_name = g_strdup (display_name); priv->screen_position = position; - priv->size = size; + priv->size = size; /* add menu */ xfce_panel_plugin_create_menu (XFCE_PANEL_PLUGIN (plugin)); - xfce_panel_plugin_add_action_widget (XFCE_PANEL_PLUGIN (plugin), GTK_WIDGET (plugin)); - g_signal_connect_after (plugin, "realize", G_CALLBACK (_plugin_setup), - construct); + g_signal_connect_after (G_OBJECT (plugin), "realize", + G_CALLBACK (_plugin_setup), construct); return plugin; } diff --git a/libxfce4panel/xfce-panel-internal-plugin.h b/libxfce4panel/xfce-panel-internal-plugin.h index 8f1f604b4..9eee2609a 100644 --- a/libxfce4panel/xfce-panel-internal-plugin.h +++ b/libxfce4panel/xfce-panel-internal-plugin.h @@ -1,30 +1,34 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_INTERNAL_PANEL_PLUGIN_H -#define _XFCE_INTERNAL_PANEL_PLUGIN_H +#ifndef __XFCE_INTERNAL_PANEL_PLUGIN_H__ +#define __XFCE_INTERNAL_PANEL_PLUGIN_H__ #include <gtk/gtkeventbox.h> #include <libxfce4panel/xfce-panel-plugin-iface.h> +G_BEGIN_DECLS + +typedef struct _XfceInternalPanelPlugin XfceInternalPanelPlugin; +typedef struct _XfceInternalPanelPluginClass XfceInternalPanelPluginClass; + #define XFCE_TYPE_INTERNAL_PANEL_PLUGIN (xfce_internal_panel_plugin_get_type ()) #define XFCE_INTERNAL_PANEL_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_INTERNAL_PANEL_PLUGIN, XfceInternalPanelPlugin)) #define XFCE_INTERNAL_PANEL_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_INTERNAL_PANEL_PLUGIN, XfceInternalPanelPluginClass)) @@ -32,12 +36,6 @@ #define XFCE_IS_INTERNAL_PANEL_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_INTERNAL_PANEL_PLUGIN)) #define XFCE_INTERNAL_PANEL_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_INTERNAL_PANEL_PLUGIN, XfceInternalPanelPluginClass)) - -G_BEGIN_DECLS - -typedef struct _XfceInternalPanelPlugin XfceInternalPanelPlugin; -typedef struct _XfceInternalPanelPluginClass XfceInternalPanelPluginClass; - struct _XfceInternalPanelPlugin { GtkEventBox parent; @@ -48,17 +46,14 @@ struct _XfceInternalPanelPluginClass GtkEventBoxClass parent_class; }; - -GType xfce_internal_panel_plugin_get_type (void) G_GNUC_CONST; - -GtkWidget *xfce_internal_panel_plugin_new (const char *name, - const char *id, - const char *display_name, - int size, - XfceScreenPosition position, - XfcePanelPluginFunc construct); - +GType xfce_internal_panel_plugin_get_type (void) G_GNUC_CONST; +GtkWidget *xfce_internal_panel_plugin_new (const gchar *name, + const gchar *id, + const gchar *display_name, + gint size, + XfceScreenPosition position, + XfcePanelPluginFunc construct) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; G_END_DECLS -#endif /* _XFCE_INTERNAL_PANEL_PLUGIN_H */ +#endif /* !__XFCE_INTERNAL_PANEL_PLUGIN_H__ */ diff --git a/libxfce4panel/xfce-panel-item-iface.c b/libxfce4panel/xfce-panel-item-iface.c index 91e98c22f..179ff4fdd 100644 --- a/libxfce4panel/xfce-panel-item-iface.c +++ b/libxfce4panel/xfce-panel-item-iface.c @@ -1,22 +1,21 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H @@ -26,6 +25,8 @@ #include <X11/Xlib.h> #include <gtk/gtk.h> #include <gdk/gdkx.h> + +#include "xfce-panel-macros.h" #include "xfce-panel-item-iface.h" enum @@ -42,20 +43,20 @@ enum static guint xfce_panel_item_signals[LAST_SIGNAL] = { 0 }; -/* interface definition and initialization */ + static void xfce_panel_item_base_init (gpointer g_class) { static gboolean initialized = FALSE; - if (!initialized) + if (initialized == FALSE) { GType ptypes[1]; - + /* signals (note: there are no class closures here) */ ptypes[0] = G_TYPE_BOOLEAN; - + /** * XfcePanelItem::expand-changed * @item : #XfcePanelItem @@ -65,13 +66,13 @@ xfce_panel_item_base_init (gpointer g_class) * expand behaviour. **/ xfce_panel_item_signals [EXPAND_CHANGED] = - g_signal_newv ("expand-changed", + g_signal_newv (I_("expand-changed"), XFCE_TYPE_PANEL_ITEM, - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, ptypes); + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, + 1, ptypes); /** * XfcePanelItem::menu-deactivated @@ -80,13 +81,13 @@ xfce_panel_item_base_init (gpointer g_class) * The signal is emitted when a plugin menu is deactivated. **/ xfce_panel_item_signals [MENU_DEACTIVATED] = - g_signal_newv ("menu-deactivated", + g_signal_newv (I_("menu-deactivated"), XFCE_TYPE_PANEL_ITEM, - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, NULL); + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0, NULL); /** * XfcePanelItem::menu-opened @@ -95,13 +96,13 @@ xfce_panel_item_base_init (gpointer g_class) * The signal is emitted when a plugin menu is opened. **/ xfce_panel_item_signals [MENU_OPENED] = - g_signal_newv ("menu-opened", + g_signal_newv (I_("menu-opened"), XFCE_TYPE_PANEL_ITEM, - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, NULL); + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0, NULL); /** * XfcePanelItem::customize-panel @@ -111,13 +112,13 @@ xfce_panel_item_base_init (gpointer g_class) * be shown. **/ xfce_panel_item_signals [CUSTOMIZE_PANEL] = - g_signal_newv ("customize-panel", + g_signal_newv (I_("customize-panel"), XFCE_TYPE_PANEL_ITEM, - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, NULL); + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0, NULL); /** * XfcePanelItem::customize-items @@ -126,13 +127,13 @@ xfce_panel_item_base_init (gpointer g_class) * The signal is emitted when a plugin requests the 'Add Items' dialog. **/ xfce_panel_item_signals [CUSTOMIZE_ITEMS] = - g_signal_newv ("customize-items", + g_signal_newv (I_("customize-items"), XFCE_TYPE_PANEL_ITEM, - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, NULL); + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0, NULL); /** * XfcePanelItem::move @@ -141,13 +142,13 @@ xfce_panel_item_base_init (gpointer g_class) * The signal is emitted when a plugin requests the item to be moved. **/ xfce_panel_item_signals [MOVE] = - g_signal_newv ("move", + g_signal_newv (I_("move"), XFCE_TYPE_PANEL_ITEM, - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, NULL); + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0, NULL); /** * XfcePanelItem::set-hidden @@ -157,53 +158,56 @@ xfce_panel_item_base_init (gpointer g_class) * The signal is emitted when a plugin requests the panel to unhide. **/ xfce_panel_item_signals [SET_HIDDEN] = - g_signal_newv ("set-hidden", + g_signal_newv (I_("set-hidden"), XFCE_TYPE_PANEL_ITEM, - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, ptypes); + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, + 1, ptypes); initialized = TRUE; } } + + GType xfce_panel_item_get_type (void) { - static GType type = 0; + static GType type = G_TYPE_INVALID; - if (type == 0) + if (G_UNLIKELY (type == G_TYPE_INVALID)) { - static const GTypeInfo info = - { + static const GTypeInfo info = { sizeof (XfcePanelItemInterface), - xfce_panel_item_base_init, /* base_init */ - NULL, /* base_finalize */ - NULL, /* class_init */ - NULL, /* class_finalize */ - NULL, /* class_data */ + xfce_panel_item_base_init, + NULL, + NULL, + NULL, + NULL, 0, - 0, /* n_preallocs */ - NULL, /* instance_init */ + 0, + NULL, NULL }; - type = g_type_register_static (G_TYPE_INTERFACE, "XfcePanelItem", + + type = g_type_register_static (G_TYPE_INTERFACE, I_("XfcePanelItem"), &info, 0); } - + return type; } -/* public API */ + +/* public API */ void xfce_panel_item_focus_panel (XfcePanelItem *item) { - static Atom atom = 0; - XClientMessageEvent xev; - GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET(item)); + static Atom atom = 0; + XClientMessageEvent xev; + GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET(item)); if (G_UNLIKELY (!atom)) atom = XInternAtom (GDK_DISPLAY (), "_NET_ACTIVE_WINDOW", FALSE); @@ -223,7 +227,7 @@ xfce_panel_item_focus_panel (XfcePanelItem *item) gdk_flush(); } -/* signals */ + /** * xfce_panel_item_expand_changed @@ -233,14 +237,18 @@ xfce_panel_item_focus_panel (XfcePanelItem *item) * Emits the "expand-changed" signal on the item. Should only be called by * item implementations. **/ -void -xfce_panel_item_expand_changed (XfcePanelItem *item, gboolean expand) +void +xfce_panel_item_expand_changed (XfcePanelItem *item, + gboolean expand) { g_return_if_fail (XFCE_IS_PANEL_ITEM (item)); - g_signal_emit (item, xfce_panel_item_signals[EXPAND_CHANGED], 0, expand, NULL); + g_signal_emit (G_OBJECT (item), xfce_panel_item_signals[EXPAND_CHANGED], + 0, expand, NULL); } + + /** * xfce_panel_item_menu_deactivated * @item : #XfcePanelItem @@ -248,14 +256,16 @@ xfce_panel_item_expand_changed (XfcePanelItem *item, gboolean expand) * Emits the "menu-deactivated" signal on the item. Should only be called by * item implementations. **/ -void +void xfce_panel_item_menu_deactivated (XfcePanelItem *item) { g_return_if_fail (XFCE_IS_PANEL_ITEM (item)); - g_signal_emit (item, xfce_panel_item_signals[MENU_DEACTIVATED], 0, NULL); + g_signal_emit (G_OBJECT (item), xfce_panel_item_signals[MENU_DEACTIVATED], 0, NULL); } + + /** * xfce_panel_item_menu_opened * @item : #XfcePanelItem @@ -263,14 +273,16 @@ xfce_panel_item_menu_deactivated (XfcePanelItem *item) * Emits the "menu-opened" signal on the item. Should only be called by * item implementations. **/ -void +void xfce_panel_item_menu_opened (XfcePanelItem *item) { g_return_if_fail (XFCE_IS_PANEL_ITEM (item)); - g_signal_emit (item, xfce_panel_item_signals[MENU_OPENED], 0, NULL); + g_signal_emit (G_OBJECT (item), xfce_panel_item_signals[MENU_OPENED], 0, NULL); } + + /** * xfce_panel_item_customize_panel * @item : #XfcePanelItem @@ -283,9 +295,11 @@ xfce_panel_item_customize_panel (XfcePanelItem *item) { g_return_if_fail (XFCE_IS_PANEL_ITEM (item)); - g_signal_emit (item, xfce_panel_item_signals[CUSTOMIZE_PANEL], 0, NULL); + g_signal_emit (G_OBJECT (item), xfce_panel_item_signals[CUSTOMIZE_PANEL], 0, NULL); } + + /** * xfce_panel_item_customize_items * @item : #XfcePanelItem @@ -298,9 +312,11 @@ xfce_panel_item_customize_items (XfcePanelItem *item) { g_return_if_fail (XFCE_IS_PANEL_ITEM (item)); - g_signal_emit (item, xfce_panel_item_signals[CUSTOMIZE_ITEMS], 0, NULL); + g_signal_emit (G_OBJECT (item), xfce_panel_item_signals[CUSTOMIZE_ITEMS], 0, NULL); } + + /** * xfce_panel_item_move * @item : #XfcePanelItem @@ -313,9 +329,11 @@ xfce_panel_item_move (XfcePanelItem *item) { g_return_if_fail (XFCE_IS_PANEL_ITEM (item)); - g_signal_emit (item, xfce_panel_item_signals[MOVE], 0, NULL); + g_signal_emit (G_OBJECT (item), xfce_panel_item_signals[MOVE], 0, NULL); } + + /** * xfce_panel_item_set_panel_hidden * @item : #XfcePanelItem @@ -323,15 +341,17 @@ xfce_panel_item_move (XfcePanelItem *item) * Emits the "set-hidden" signal on the item. Should only be called by * item implementations. **/ -void -xfce_panel_item_set_panel_hidden (XfcePanelItem *item, gboolean hidden) +void +xfce_panel_item_set_panel_hidden (XfcePanelItem *item, + gboolean hidden) { g_return_if_fail (XFCE_IS_PANEL_ITEM (item)); - g_signal_emit (item, xfce_panel_item_signals[SET_HIDDEN], 0, hidden, NULL); + g_signal_emit (G_OBJECT (item), xfce_panel_item_signals[SET_HIDDEN], + 0, hidden, NULL); } -/* properties */ + /** * xfce_panel_item_get_name @@ -339,48 +359,56 @@ xfce_panel_item_set_panel_hidden (XfcePanelItem *item, gboolean hidden) * * Returns: plugin name. **/ -G_CONST_RETURN char * +const gchar * xfce_panel_item_get_name (XfcePanelItem *item) { return XFCE_PANEL_ITEM_GET_INTERFACE (item)->get_name (item); } + + /** * xfce_panel_item_get_id * @item : #XfcePanelItem * * Returns: unique identifier string for the item. **/ -G_CONST_RETURN char * +const gchar * xfce_panel_item_get_id (XfcePanelItem *item) { return XFCE_PANEL_ITEM_GET_INTERFACE (item)->get_id (item); } + + /** * xfce_panel_item_get_display_name * @item : #XfcePanelItem * * Returns: translated plugin name. **/ -G_CONST_RETURN char * +const gchar * xfce_panel_item_get_display_name (XfcePanelItem *item) { return XFCE_PANEL_ITEM_GET_INTERFACE (item)->get_display_name (item); } + + /** * xfce_panel_item_get_expand * @item : #XfcePanelItem * * Returns: whether @item will expand when the panel size increases. **/ -gboolean +gboolean xfce_panel_item_get_expand (XfcePanelItem *item) { return XFCE_PANEL_ITEM_GET_INTERFACE (item)->get_expand (item); } + + /** * xfce_panel_item_save * @item : #XfcePanelItem @@ -388,11 +416,13 @@ xfce_panel_item_get_expand (XfcePanelItem *item) * Ask the item to save its settings. **/ void -xfce_panel_item_save (XfcePanelItem * item) +xfce_panel_item_save (XfcePanelItem *item) { XFCE_PANEL_ITEM_GET_INTERFACE (item)->save (item); } + + /** * xfce_panel_item_free_data * @item : #XfcePanelItem @@ -400,11 +430,13 @@ xfce_panel_item_save (XfcePanelItem * item) * Tell the item it should free allocated data. **/ void -xfce_panel_item_free_data (XfcePanelItem * item) +xfce_panel_item_free_data (XfcePanelItem *item) { XFCE_PANEL_ITEM_GET_INTERFACE (item)->free_data (item); } + + /** * xfce_panel_item_set_size * @item : #XfcePanelItem @@ -413,11 +445,14 @@ xfce_panel_item_free_data (XfcePanelItem * item) * Notifies the item of a change in panel size. **/ void -xfce_panel_item_set_size (XfcePanelItem * item, int size) +xfce_panel_item_set_size (XfcePanelItem *item, + gint size) { XFCE_PANEL_ITEM_GET_INTERFACE (item)->set_size (item, size); } + + /** * xfce_panel_item_set * @item : #XfcePanelItem @@ -426,12 +461,14 @@ xfce_panel_item_set_size (XfcePanelItem * item, int size) * Notifies the item of a change in panel screen position. **/ void -xfce_panel_item_set_screen_position (XfcePanelItem * item, - XfceScreenPosition position) +xfce_panel_item_set_screen_position (XfcePanelItem *item, + XfceScreenPosition position) { XFCE_PANEL_ITEM_GET_INTERFACE (item)->set_screen_position (item, position); } + + /* * xfce_panel_item_set_sensitive * @item : an #XfcePanelItem @@ -440,30 +477,36 @@ xfce_panel_item_set_screen_position (XfcePanelItem * item, * Ask the item to become (in)sensitive. **/ void -xfce_panel_item_set_sensitive (XfcePanelItem * item, gboolean sensitive) +xfce_panel_item_set_sensitive (XfcePanelItem *item, + gboolean sensitive) { XFCE_PANEL_ITEM_GET_INTERFACE (item)->set_sensitive (item, sensitive); } + + /* * xfce_panel_item_remove * @item : an #XfcePanelItem * * Remove @item from the panel. **/ -void +void xfce_panel_item_remove (XfcePanelItem *item) { XFCE_PANEL_ITEM_GET_INTERFACE (item)->remove (item); } + + /* * xfce_panel_item_configure * @item : an #XfcePanelItem * * Ask @item to open a settings dialog. **/ -void xfce_panel_item_configure (XfcePanelItem *item) +void +xfce_panel_item_configure (XfcePanelItem *item) { XFCE_PANEL_ITEM_GET_INTERFACE (item)->configure (item); } diff --git a/libxfce4panel/xfce-panel-item-iface.h b/libxfce4panel/xfce-panel-item-iface.h index 4063d00a2..8a89367c0 100644 --- a/libxfce4panel/xfce-panel-item-iface.h +++ b/libxfce4panel/xfce-panel-item-iface.h @@ -1,22 +1,21 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifndef _XFCE_PANEL_ITEM_H @@ -25,102 +24,68 @@ #include <glib-object.h> #include <libxfce4panel/xfce-panel-enums.h> +G_BEGIN_DECLS + +typedef struct _XfcePanelItem XfcePanelItem; +typedef struct _XfcePanelItemInterface XfcePanelItemInterface; + #define XFCE_TYPE_PANEL_ITEM (xfce_panel_item_get_type ()) #define XFCE_PANEL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_PANEL_ITEM, XfcePanelItem)) #define XFCE_IS_PANEL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_PANEL_ITEM)) #define XFCE_PANEL_ITEM_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), XFCE_TYPE_PANEL_ITEM, XfcePanelItemInterface)) - -G_BEGIN_DECLS - -typedef struct _XfcePanelItem XfcePanelItem; /* dummy object */ -typedef struct _XfcePanelItemInterface XfcePanelItemInterface; - struct _XfcePanelItemInterface { GTypeInterface parent; - /* vtable */ - G_CONST_RETURN char *(*get_name) (XfcePanelItem *item); - - G_CONST_RETURN char *(*get_id) (XfcePanelItem *item); - - G_CONST_RETURN char *(*get_display_name) (XfcePanelItem *item); - - gboolean (*get_expand) (XfcePanelItem *item); - - void (*free_data) (XfcePanelItem *item); - - void (*save) (XfcePanelItem *item); - - void (*set_size) (XfcePanelItem *item, int size); - - void (*set_screen_position) (XfcePanelItem *item, - XfceScreenPosition position); - - void (*set_sensitive) (XfcePanelItem *item, - gboolean sensitive); - - void (*remove) (XfcePanelItem *item); - - void (*configure) (XfcePanelItem *item); + /* signals */ + const gchar *(*get_name) (XfcePanelItem *item); + const gchar *(*get_id) (XfcePanelItem *item); + const gchar *(*get_display_name) (XfcePanelItem *item); + gboolean (*get_expand) (XfcePanelItem *item); + void (*free_data) (XfcePanelItem *item); + void (*save) (XfcePanelItem *item); + void (*set_size) (XfcePanelItem *item, + gint size); + void (*set_screen_position) (XfcePanelItem *item, + XfceScreenPosition position); + void (*set_sensitive) (XfcePanelItem *item, + gboolean sensitive); + void (*remove) (XfcePanelItem *item); + void (*configure) (XfcePanelItem *item); /* reserved for future expansion */ - void (*_panel_reserved1) (void); - void (*_panel_reserved2) (void); - void (*_panel_reserved3) (void); + void (*reserved1) (void); + void (*reserved2) (void); + void (*reserved3) (void); }; -GType xfce_panel_item_get_type (void) G_GNUC_CONST; - -/* focus */ -void xfce_panel_item_focus_panel (XfcePanelItem *item); - -/* emit signals -- to be called from implementors */ - -void xfce_panel_item_expand_changed (XfcePanelItem *item, gboolean expand); - -void xfce_panel_item_menu_deactivated (XfcePanelItem *item); - -void xfce_panel_item_menu_opened (XfcePanelItem *item); - -void xfce_panel_item_customize_panel (XfcePanelItem *item); - -void xfce_panel_item_customize_items (XfcePanelItem *item); - -void xfce_panel_item_move (XfcePanelItem *item); - -void xfce_panel_item_set_panel_hidden (XfcePanelItem *item, gboolean hidden); - - -/* vtable */ - -G_CONST_RETURN char *xfce_panel_item_get_name (XfcePanelItem *item); - -G_CONST_RETURN char *xfce_panel_item_get_id (XfcePanelItem *item); - -G_CONST_RETURN char *xfce_panel_item_get_display_name (XfcePanelItem *item); - -gboolean xfce_panel_item_get_expand (XfcePanelItem *item); - -void xfce_panel_item_save (XfcePanelItem *item); - -void xfce_panel_item_free_data (XfcePanelItem *item); - -void xfce_panel_item_set_size (XfcePanelItem *item, - int size); - -void xfce_panel_item_set_screen_position (XfcePanelItem *item, - XfceScreenPosition position); - -void xfce_panel_item_set_sensitive (XfcePanelItem *item, - gboolean sensitive); - -void xfce_panel_item_remove (XfcePanelItem *item); - -void xfce_panel_item_configure (XfcePanelItem *item); - +GType xfce_panel_item_get_type (void) G_GNUC_CONST; +void xfce_panel_item_focus_panel (XfcePanelItem *item); +void xfce_panel_item_expand_changed (XfcePanelItem *item, + gboolean expand); +void xfce_panel_item_menu_deactivated (XfcePanelItem *item); +void xfce_panel_item_menu_opened (XfcePanelItem *item); +void xfce_panel_item_customize_panel (XfcePanelItem *item); +void xfce_panel_item_customize_items (XfcePanelItem *item); +void xfce_panel_item_move (XfcePanelItem *item); +void xfce_panel_item_set_panel_hidden (XfcePanelItem *item, + gboolean hidden); +const gchar *xfce_panel_item_get_name (XfcePanelItem *item); +const gchar *xfce_panel_item_get_id (XfcePanelItem *item); +const gchar *xfce_panel_item_get_display_name (XfcePanelItem *item); +gboolean xfce_panel_item_get_expand (XfcePanelItem *item); +void xfce_panel_item_save (XfcePanelItem *item); +void xfce_panel_item_free_data (XfcePanelItem *item); +void xfce_panel_item_set_size (XfcePanelItem *item, + gint size); +void xfce_panel_item_set_screen_position (XfcePanelItem *item, + XfceScreenPosition position); +void xfce_panel_item_set_sensitive (XfcePanelItem *item, + gboolean sensitive); +void xfce_panel_item_remove (XfcePanelItem *item); +void xfce_panel_item_configure (XfcePanelItem *item); G_END_DECLS -#endif /* _XFCE_PANEL_ITEM_H */ +#endif /* !__XFCE_PANEL_ITEM_H__ */ diff --git a/libxfce4panel/xfce-panel-macros.h b/libxfce4panel/xfce-panel-macros.h index 5392de4e3..f7fa14505 100644 --- a/libxfce4panel/xfce-panel-macros.h +++ b/libxfce4panel/xfce-panel-macros.h @@ -1,30 +1,29 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2006-2007 Nick Schermer <nick@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_PANEL_MACROS_H -#define _XFCE_PANEL_MACROS_H +#ifndef __XFCE_PANEL_MACROS_H__ +#define __XFCE_PANEL_MACROS_H__ + +G_BEGIN_DECLS -/** - * Support macro's for the slice allocator - **/ +/* Support macro's for the slice allocator */ #if GLIB_CHECK_VERSION(2,10,0) #define panel_slice_alloc(block_size) (g_slice_alloc ((block_size))) #define panel_slice_alloc0(block_size) (g_slice_alloc0 ((block_size))) @@ -41,5 +40,13 @@ #define panel_slice_free(type, ptr) G_STMT_START{ g_free ((ptr)); }G_STMT_END #endif -#endif /* _XFCE_PANEL_MACROS_H */ +/* Canonical Strings */ +#if GLIB_CHECK_VERSION(2,10,0) +#define I_(string) (g_intern_static_string ((string))) +#else +#define I_(string) (g_quark_to_string (g_quark_from_static_string ((string)))) +#endif + +G_END_DECLS +#endif /* !__XFCE_PANEL_MACROS_H__ */ diff --git a/libxfce4panel/xfce-panel-plugin-iface-private.h b/libxfce4panel/xfce-panel-plugin-iface-private.h index 39aa7311a..d44b11971 100644 --- a/libxfce4panel/xfce-panel-plugin-iface-private.h +++ b/libxfce4panel/xfce-panel-plugin-iface-private.h @@ -1,26 +1,25 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_PANEL_PLUGIN_IFACE_PRIVATE_H -#define _XFCE_PANEL_PLUGIN_IFACE_PRIVATE_H +#ifndef __XFCE_PANEL_PLUGIN_IFACE_PRIVATE_H__ +#define __XFCE_PANEL_PLUGIN_IFACE_PRIVATE_H__ #include <libxfce4panel/xfce-panel-plugin-iface.h> @@ -30,69 +29,43 @@ struct _XfcePanelPluginInterface { GTypeInterface parent; - /* vtable */ - void (*remove) (XfcePanelPlugin *plugin); - - void (*set_expand) (XfcePanelPlugin *plugin, - gboolean expand); - - void (*customize_panel) (XfcePanelPlugin *plugin); - - void (*customize_items) (XfcePanelPlugin *plugin); - - void (*move) (XfcePanelPlugin *plugin); - - void (*register_menu) (XfcePanelPlugin *plugin, - GtkMenu *menu); - - void (*focus_panel) (XfcePanelPlugin *plugin); - - void (*set_panel_hidden) (XfcePanelPlugin *plugin, - gboolean hidden); - - void (*_xfce_reserved1) (void); - void (*_xfce_reserved2) (void); + /* signals */ + void (*remove) (XfcePanelPlugin *plugin); + void (*set_expand) (XfcePanelPlugin *plugin, + gboolean expand); + void (*customize_panel) (XfcePanelPlugin *plugin); + void (*customize_items) (XfcePanelPlugin *plugin); + void (*move) (XfcePanelPlugin *plugin); + void (*register_menu) (XfcePanelPlugin *plugin, + GtkMenu *menu); + void (*focus_panel) (XfcePanelPlugin *plugin); + void (*set_panel_hidden) (XfcePanelPlugin *plugin, + gboolean hidden); + + /* reserved for future expansion */ + void (*reserved1) (void); + void (*reserved2) (void); }; -/* menu */ -void xfce_panel_plugin_create_menu (XfcePanelPlugin *plugin); - -void xfce_panel_plugin_popup_menu (XfcePanelPlugin *plugin); - -/* emit signals -- to be called by implementors */ - -void xfce_panel_plugin_signal_screen_position (XfcePanelPlugin *plugin, - XfceScreenPosition position); - -void xfce_panel_plugin_signal_orientation (XfcePanelPlugin * plugin, - GtkOrientation orientation); - -void xfce_panel_plugin_signal_size (XfcePanelPlugin * plugin, - int size); - -void xfce_panel_plugin_signal_free_data (XfcePanelPlugin * plugin); - -void xfce_panel_plugin_signal_save (XfcePanelPlugin * plugin); - -void xfce_panel_plugin_signal_configure (XfcePanelPlugin * plugin); - -/* set (in)sensitive */ -void xfce_panel_plugin_set_sensitive (XfcePanelPlugin *plugin, - gboolean sensitive); - -/* vtable */ - -void xfce_panel_plugin_remove_confirm (XfcePanelPlugin *plugin); - -void xfce_panel_plugin_remove (XfcePanelPlugin *plugin); - -void xfce_panel_plugin_customize_panel (XfcePanelPlugin *plugin); - -void xfce_panel_plugin_customize_items (XfcePanelPlugin *plugin); - -void xfce_panel_plugin_move (XfcePanelPlugin *plugin); - +void xfce_panel_plugin_create_menu (XfcePanelPlugin *plugin) G_GNUC_INTERNAL; +void xfce_panel_plugin_popup_menu (XfcePanelPlugin *plugin) G_GNUC_INTERNAL; +void xfce_panel_plugin_signal_screen_position (XfcePanelPlugin *plugin, + XfceScreenPosition position) G_GNUC_INTERNAL; +void xfce_panel_plugin_signal_orientation (XfcePanelPlugin *plugin, + GtkOrientation orientation) G_GNUC_INTERNAL; +void xfce_panel_plugin_signal_size (XfcePanelPlugin *plugin, + gint size) G_GNUC_INTERNAL; +void xfce_panel_plugin_signal_free_data (XfcePanelPlugin *plugin) G_GNUC_INTERNAL; +void xfce_panel_plugin_signal_save (XfcePanelPlugin *plugin) G_GNUC_INTERNAL; +void xfce_panel_plugin_signal_configure (XfcePanelPlugin *plugin) G_GNUC_INTERNAL; +void xfce_panel_plugin_set_sensitive (XfcePanelPlugin *plugin, + gboolean sensitive) G_GNUC_INTERNAL; +void xfce_panel_plugin_remove_confirm (XfcePanelPlugin *plugin) G_GNUC_INTERNAL; +void xfce_panel_plugin_remove (XfcePanelPlugin *plugin) G_GNUC_INTERNAL; +void xfce_panel_plugin_customize_panel (XfcePanelPlugin *plugin) G_GNUC_INTERNAL; +void xfce_panel_plugin_customize_items (XfcePanelPlugin *plugin) G_GNUC_INTERNAL; +void xfce_panel_plugin_move (XfcePanelPlugin *plugin) G_GNUC_INTERNAL; G_END_DECLS -#endif /* _XFCE_PANEL_PLUGIN_IFACE_PRIVATE_H */ +#endif /* !__XFCE_PANEL_PLUGIN_IFACE_PRIVATE_H__ */ diff --git a/libxfce4panel/xfce-panel-plugin-iface.c b/libxfce4panel/xfce-panel-plugin-iface.c index c016baae1..aa2c1fa1d 100644 --- a/libxfce4panel/xfce-panel-plugin-iface.c +++ b/libxfce4panel/xfce-panel-plugin-iface.c @@ -1,22 +1,21 @@ -/* vim: set expandtab ts=8 sw=4: */ - /* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H @@ -26,6 +25,7 @@ #include <string.h> #include <gtk/gtk.h> +#include "xfce-panel-macros.h" #include "xfce-panel-convenience.h" #include "xfce-panel-plugin-iface.h" #include "xfce-panel-plugin-iface-private.h" @@ -46,7 +46,7 @@ enum static guint xfce_panel_plugin_signals[LAST_SIGNAL] = { 0 }; -/* interface definition and initialization */ + static void xfce_panel_plugin_base_init (gpointer g_class) @@ -56,12 +56,12 @@ xfce_panel_plugin_base_init (gpointer g_class) if (!initialized) { GType ptypes[1]; - + /* signals (note: there are no class closures here) */ /* screen position */ ptypes[0] = XFCE_TYPE_SCREEN_POSITION; - + /** * XfcePanelPlugin::screen-position-changed * @plugin : a #XfcePanelPlugin widget @@ -71,17 +71,17 @@ xfce_panel_plugin_base_init (gpointer g_class) * more interested in the "orientation-changed" signal. **/ xfce_panel_plugin_signals [SCREEN_POSITION_CHANGED] = - g_signal_newv ("screen-position-changed", + g_signal_newv (I_("screen-position-changed"), XFCE_TYPE_PANEL_PLUGIN, - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, ptypes); + g_cclosure_marshal_VOID__ENUM, + G_TYPE_NONE, + 1, ptypes); /* orientation */ ptypes[0] = GTK_TYPE_ORIENTATION; - + /** * XfcePanelPlugin::orientation-changed * @plugin : a #XfcePanelPlugin widget @@ -90,38 +90,36 @@ xfce_panel_plugin_base_init (gpointer g_class) * Emitted when the panel orientation changes. **/ xfce_panel_plugin_signals [ORIENTATION_CHANGED] = - g_signal_newv ("orientation-changed", + g_signal_newv (I_("orientation-changed"), XFCE_TYPE_PANEL_PLUGIN, - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, ptypes); + g_cclosure_marshal_VOID__ENUM, + G_TYPE_NONE, + 1, ptypes); /* size */ ptypes[0] = G_TYPE_INT; - + /** * XfcePanelPlugin::size-changed * @plugin : a #XfcePanelPlugin widget * @size : new panel size * - * Emitted when the panel size changes. By default a plugin will - * get a geometry of @size x @size. This means that a plugin writer - * must handle this signal for any other behavior, even to 'do nothing'. + * Emitted when the panel size changes. * - * Return value: A callback function should return %TRUE when the signal - * is handled and %FALSE otherwise, in which case the - * default handler will run. + * Returns: %TRUE when handled, %FALSE otherwise. **/ xfce_panel_plugin_signals [SIZE_CHANGED] = - g_signal_newv ("size-changed", + g_signal_newv (I_("size-changed"), XFCE_TYPE_PANEL_PLUGIN, - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, - NULL, g_signal_accumulator_true_handled, NULL, - _xfce_marshal_BOOLEAN__INT, - G_TYPE_BOOLEAN, 1, ptypes); + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, + NULL, + g_signal_accumulator_true_handled, + NULL, + _xfce_marshal_BOOLEAN__INT, + G_TYPE_BOOLEAN, + 1, ptypes); /** * XfcePanelPlugin::free-data @@ -133,13 +131,13 @@ xfce_panel_plugin_base_init (gpointer g_class) * See also: #XfcePanelPlugin::save **/ xfce_panel_plugin_signals [FREE_DATA] = - g_signal_newv ("free-data", + g_signal_newv (I_("free-data"), XFCE_TYPE_PANEL_PLUGIN, - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, NULL); + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0, NULL); /** * XfcePanelPlugin::save @@ -147,132 +145,139 @@ xfce_panel_plugin_base_init (gpointer g_class) * * Emitted before the panel is closing. May be called more than once * while the panel is running. Plugin writers should connect to - * this signal to save the plugins configuration. + * this signal to save the plugins configuration. * * See also: xfce_panel_plugin_get_rc_file() **/ xfce_panel_plugin_signals [SAVE] = - g_signal_newv ("save", + g_signal_newv (I_("save"), XFCE_TYPE_PANEL_PLUGIN, - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, NULL); + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0, NULL); /** * XfcePanelPlugin::about * @plugin : a #XfcePanelPlugin widget * - * Emitted when the 'About' menu item is clicked. Plugin writers + * Emitted when the 'About' menu item is clicked. Plugin writers * should connect to this signal to show information about their * plugin (and its authors). * * See also: xfce_panel_plugin_menu_show_about() **/ xfce_panel_plugin_signals [ABOUT] = - g_signal_newv ("about", + g_signal_newv (I_("about"), XFCE_TYPE_PANEL_PLUGIN, - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, NULL); + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0, NULL); /** * XfcePanelPlugin::configure-plugin * @plugin : a #XfcePanelPlugin widget * - * Emitted when the 'Configure' menu item is clicked. Plugin writers + * Emitted when the 'Configure' menu item is clicked. Plugin writers * should connect to this signal to show a settings dialog. * * See also: xfce_panel_plugin_menu_show_configure() **/ xfce_panel_plugin_signals [CONFIGURE] = - g_signal_newv ("configure-plugin", + g_signal_newv (I_("configure-plugin"), XFCE_TYPE_PANEL_PLUGIN, - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, NULL); + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0, NULL); /* properties */ /** * XfcePanelPlugin:name - * - * Untranslated plugin name. This identifies the plugin type and + * + * Untranslated plugin name. This identifies the plugin type and * therefore has to be unique. **/ - g_object_interface_install_property (g_class, - g_param_spec_string ("name", - "xfce_panel_plugin_name", - "Plugin name", - NULL, G_PARAM_READABLE)); + g_object_interface_install_property (g_class, + g_param_spec_string ("name", + "xfce_panel_plugin_name", + "Plugin name", + NULL, + G_PARAM_READABLE)); /** * XfcePanelPlugin:id - * + * * Unique identifier string created for every #XfcePanelPlugin instance. **/ - g_object_interface_install_property (g_class, - g_param_spec_string ("id", - "xfce_panel_plugin_id", - "Plugin id", - NULL, G_PARAM_READABLE)); + g_object_interface_install_property (g_class, + g_param_spec_string ("id", + "xfce_panel_plugin_id", + "Plugin id", + NULL, + G_PARAM_READABLE)); /** * XfcePanelPlugin:display-name - * + * * Translated plugin name. This is the name that can be presented to * the user, e.g. in dialogs or menus. **/ - g_object_interface_install_property (g_class, - g_param_spec_string ("display-name", - "xfce_panel_plugin_display_name", - "Plugin display name", - NULL, G_PARAM_READABLE)); + g_object_interface_install_property (g_class, + g_param_spec_string ("display-name", + "xfce_panel_plugin_display_name", + "Plugin display name", + NULL, + G_PARAM_READABLE)); /** * XfcePanelPlugin:size - * + * * The current panel size. **/ - g_object_interface_install_property (g_class, - g_param_spec_int ("size", - "xfce_panel_plugin_size", - "Panel size", - 10, 128, 32, G_PARAM_READABLE)); + g_object_interface_install_property (g_class, + g_param_spec_int ("size", + "xfce_panel_plugin_size", + "Panel size", + 10, 128, 32, + G_PARAM_READABLE)); /** * XfcePanelPlugin:screen-position - * + * * The current #XfceScreenPosition of the panel. **/ - g_object_interface_install_property (g_class, - g_param_spec_enum ("screen-position", - "xfce_panel_plugin_screen_position", - "Panel screen position", - XFCE_TYPE_SCREEN_POSITION, - XFCE_SCREEN_POSITION_S, - G_PARAM_READABLE)); + g_object_interface_install_property (g_class, + g_param_spec_enum ("screen-position", + "xfce_panel_plugin_screen_position", + "Panel screen position", + XFCE_TYPE_SCREEN_POSITION, + XFCE_SCREEN_POSITION_S, + G_PARAM_READABLE)); /** * XfcePanelPlugin:expand - * + * * Whether to expand the plugin when the panel width increases. **/ - g_object_interface_install_property (g_class, - g_param_spec_boolean ("expand", - "xfce_panel_plugin_expand", - "Whether to expand the plugin", - FALSE, G_PARAM_READWRITE)); + g_object_interface_install_property (g_class, + g_param_spec_boolean ("expand", + "xfce_panel_plugin_expand", + "Whether to expand the plugin", + FALSE, + G_PARAM_READWRITE)); initialized = TRUE; } } + + GType xfce_panel_plugin_get_type (void) { @@ -280,31 +285,29 @@ xfce_panel_plugin_get_type (void) if (type == 0) { - static const GTypeInfo info = - { + static const GTypeInfo info = { sizeof (XfcePanelPluginInterface), - xfce_panel_plugin_base_init, /* base_init */ - NULL, /* base_finalize */ - NULL, /* class_init */ - NULL, /* class_finalize */ - NULL, /* class_data */ + xfce_panel_plugin_base_init, + NULL, + NULL, + NULL, + NULL, 0, - 0, /* n_preallocs */ - NULL, /* instance_init */ + 0, + NULL, NULL }; - type = g_type_register_static (G_TYPE_INTERFACE, "XfcePanelPlugin", + + type = g_type_register_static (G_TYPE_INTERFACE, I_("XfcePanelPlugin"), &info, 0); g_type_interface_add_prerequisite(type, GTK_TYPE_CONTAINER); } - + return type; } -/* public API */ -/* signals */ /** * xfce_panel_plugin_signal_screen_position @@ -314,15 +317,17 @@ xfce_panel_plugin_get_type (void) * Should be called by implementations of the interface. **/ void -xfce_panel_plugin_signal_screen_position (XfcePanelPlugin * plugin, - XfceScreenPosition position) +xfce_panel_plugin_signal_screen_position (XfcePanelPlugin *plugin, + XfceScreenPosition position) { g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin)); - g_signal_emit (plugin, xfce_panel_plugin_signals[SCREEN_POSITION_CHANGED], + g_signal_emit (G_OBJECT (plugin), xfce_panel_plugin_signals[SCREEN_POSITION_CHANGED], 0, position); } + + /** * xfce_panel_plugin_signal_orientation * @plugin : an #XfcePanelPlugin @@ -331,15 +336,17 @@ xfce_panel_plugin_signal_screen_position (XfcePanelPlugin * plugin, * Should be called by implementations of the interface. **/ void -xfce_panel_plugin_signal_orientation (XfcePanelPlugin * plugin, - GtkOrientation orientation) +xfce_panel_plugin_signal_orientation (XfcePanelPlugin *plugin, + GtkOrientation orientation) { g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin)); - g_signal_emit (plugin, xfce_panel_plugin_signals[ORIENTATION_CHANGED], 0, + g_signal_emit (G_OBJECT (plugin), xfce_panel_plugin_signals[ORIENTATION_CHANGED], 0, orientation); } + + /** * xfce_panel_plugin_signal_orientation * @plugin : an #XfcePanelPlugin @@ -347,101 +354,109 @@ xfce_panel_plugin_signal_orientation (XfcePanelPlugin * plugin, * * Should be called by implementations of the interface. **/ -void -xfce_panel_plugin_signal_size (XfcePanelPlugin * plugin, int size) +void +xfce_panel_plugin_signal_size (XfcePanelPlugin *plugin, + gint size) { gboolean handled = FALSE; - + g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin)); - g_signal_emit (plugin, xfce_panel_plugin_signals[SIZE_CHANGED], 0, + g_signal_emit (G_OBJECT (plugin), xfce_panel_plugin_signals[SIZE_CHANGED], 0, size, &handled); if (!handled) - { gtk_widget_set_size_request (GTK_WIDGET (plugin), size, size); - } } + + /** * xfce_panel_plugin_signal_free_data * @plugin : an #XfcePanelPlugin * * Should be called by implementations of the interface. **/ -void -xfce_panel_plugin_signal_free_data (XfcePanelPlugin * plugin) +void +xfce_panel_plugin_signal_free_data (XfcePanelPlugin *plugin) { g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin)); - g_signal_emit (plugin, xfce_panel_plugin_signals[FREE_DATA], 0); + g_signal_emit (G_OBJECT (plugin), xfce_panel_plugin_signals[FREE_DATA], 0); } + + /** * xfce_panel_plugin_signal_save * @plugin : an #XfcePanelPlugin * * Should be called by implementations of the interface. **/ -void -xfce_panel_plugin_signal_save (XfcePanelPlugin * plugin) +void +xfce_panel_plugin_signal_save (XfcePanelPlugin *plugin) { g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin)); - g_signal_emit (plugin, xfce_panel_plugin_signals[SAVE], 0); + g_signal_emit (G_OBJECT (plugin), xfce_panel_plugin_signals[SAVE], 0); } + + /** * xfce_panel_plugin_signal_about * @plugin : an #XfcePanelPlugin * * Should be called by implementations of the interface. **/ -static void -xfce_panel_plugin_signal_about (XfcePanelPlugin * plugin) +static void +xfce_panel_plugin_signal_about (XfcePanelPlugin *plugin) { g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin)); - g_signal_emit (plugin, xfce_panel_plugin_signals[ABOUT], 0); + g_signal_emit (G_OBJECT (plugin), xfce_panel_plugin_signals[ABOUT], 0); } + + /** * xfce_panel_plugin_signal_configure * @plugin : an #XfcePanelPlugin * * Should be called by implementations of the interface. **/ -void -xfce_panel_plugin_signal_configure (XfcePanelPlugin * plugin) +void +xfce_panel_plugin_signal_configure (XfcePanelPlugin *plugin) { g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin)); - g_signal_emit (plugin, xfce_panel_plugin_signals[CONFIGURE], 0); + g_signal_emit (G_OBJECT (plugin), xfce_panel_plugin_signals[CONFIGURE], 0); } -/* properties */ /** * xfce_panel_plugin_get_name * @plugin : an #XfcePanelPlugin * * The plugin name identifies a plugin type and therefore must be unique. - * + * * Returns: the plugin name. **/ gchar * xfce_panel_plugin_get_name (XfcePanelPlugin *plugin) { gchar *name = NULL; - + g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), NULL); - g_object_get (G_OBJECT (plugin), "name", &name, NULL); + g_object_get (G_OBJECT (plugin), I_("name"), &name, NULL); return name; } + + /** * xfce_panel_plugin_get_id * @plugin : an #XfcePanelPlugin @@ -455,14 +470,16 @@ gchar * xfce_panel_plugin_get_id (XfcePanelPlugin *plugin) { gchar *id = NULL; - + g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), NULL); - g_object_get (G_OBJECT (plugin), "id", &id, NULL); + g_object_get (G_OBJECT (plugin), I_("id"), &id, NULL); return id; } + + /** * xfce_panel_plugin_get_display_name * @plugin : an #XfcePanelPlugin @@ -476,71 +493,77 @@ gchar * xfce_panel_plugin_get_display_name (XfcePanelPlugin *plugin) { gchar *name = NULL; - + g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), NULL); - g_object_get (G_OBJECT (plugin), "display-name", &name, NULL); + g_object_get (G_OBJECT (plugin), I_("display-name"), &name, NULL); return name; } + + /** * xfce_panel_plugin_get_size * @plugin : an #XfcePanelPlugin * * Returns: the current panel size. **/ -int +gint xfce_panel_plugin_get_size (XfcePanelPlugin *plugin) { - int size; - + gint size; + g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), 48); - g_object_get (G_OBJECT (plugin), "size", &size, NULL); + g_object_get (G_OBJECT (plugin), I_("size"), &size, NULL); return size; } + + /** * xfce_panel_plugin_get_screen_position * @plugin : an #XfcePanelPlugin * * Returns: the current #XfceScreenPosition of the panel. **/ -XfceScreenPosition +XfceScreenPosition xfce_panel_plugin_get_screen_position (XfcePanelPlugin *plugin) { XfceScreenPosition screen_position; - - g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), + + g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), XFCE_SCREEN_POSITION_S); - g_object_get (G_OBJECT (plugin), "screen-position", &screen_position, + g_object_get (G_OBJECT (plugin), I_("screen-position"), &screen_position, NULL); return screen_position; } + + /** * xfce_panel_plugin_get_expand * @plugin : an #XfcePanelPlugin * * Returns: whether the plugin will expand when the panel width increases. **/ -gboolean +gboolean xfce_panel_plugin_get_expand (XfcePanelPlugin *plugin) { gboolean expand; - + g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), FALSE); - g_object_get (G_OBJECT (plugin), "expand", &expand, NULL); + g_object_get (G_OBJECT (plugin), I_("expand"), &expand, NULL); return expand; } -/* convenience */ + /** * xfce_panel_plugin_get_orientation @@ -552,16 +575,18 @@ GtkOrientation xfce_panel_plugin_get_orientation (XfcePanelPlugin *plugin) { XfceScreenPosition screen_position; - - g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), + + g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), GTK_ORIENTATION_HORIZONTAL); - g_object_get (G_OBJECT (plugin), "screen-position", &screen_position, + g_object_get (G_OBJECT (plugin), I_("screen-position"), &screen_position, NULL); return xfce_screen_position_get_orientation (screen_position); } + + /** * xfce_panel_plugin_remove_confirm * @plugin : an #XfcePanelPlugin @@ -587,7 +612,6 @@ xfce_panel_plugin_remove_confirm (XfcePanelPlugin *plugin) GTK_STOCK_CANCEL, GTK_RESPONSE_NO, GTK_STOCK_REMOVE, GTK_RESPONSE_YES, NULL); - g_free (name); gtk_window_set_screen (GTK_WINDOW (dialog), @@ -607,7 +631,7 @@ xfce_panel_plugin_remove_confirm (XfcePanelPlugin *plugin) xfce_panel_plugin_remove (plugin); } -/* vtable */ + /** * xfce_panel_plugin_remove @@ -615,12 +639,14 @@ xfce_panel_plugin_remove_confirm (XfcePanelPlugin *plugin) * * Remove the plugin from the panel. **/ -void +void xfce_panel_plugin_remove (XfcePanelPlugin *plugin) { XFCE_PANEL_PLUGIN_GET_INTERFACE (plugin)->remove (plugin); } + + /** * xfce_panel_plugin_set_expand * @plugin : an #XfcePanelPlugin @@ -628,36 +654,43 @@ xfce_panel_plugin_remove (XfcePanelPlugin *plugin) * * Sets whether to expand the plugin when the width of the panel increases. **/ -void -xfce_panel_plugin_set_expand (XfcePanelPlugin *plugin, gboolean expand) +void +xfce_panel_plugin_set_expand (XfcePanelPlugin *plugin, + gboolean expand) { XFCE_PANEL_PLUGIN_GET_INTERFACE (plugin)->set_expand (plugin, expand); } + + /** * xfce_panel_plugin_customize_panel * @plugin : an #XfcePanelPlugin * * Ask the panel to show the settings dialog. **/ -void +void xfce_panel_plugin_customize_panel (XfcePanelPlugin *plugin) { XFCE_PANEL_PLUGIN_GET_INTERFACE (plugin)->customize_panel (plugin); } + + /** * xfce_panel_plugin_customize_items * @plugin : an #XfcePanelPlugin * * Ask the panel to show the settings dialog, with the 'Add Items' tab shown. **/ -void +void xfce_panel_plugin_customize_items (XfcePanelPlugin *plugin) { XFCE_PANEL_PLUGIN_GET_INTERFACE (plugin)->customize_items (plugin); } + + /** * xfce_panel_plugin_move * @plugin : an #XfcePanelPlugin @@ -670,6 +703,8 @@ xfce_panel_plugin_move (XfcePanelPlugin *plugin) XFCE_PANEL_PLUGIN_GET_INTERFACE (plugin)->move (plugin); } + + /** * xfce_panel_plugin_register_menu * @plugin : an #XfcePanelPlugin @@ -679,11 +714,14 @@ xfce_panel_plugin_move (XfcePanelPlugin *plugin) * its autohide behaviour. **/ void -xfce_panel_plugin_register_menu (XfcePanelPlugin *plugin, GtkMenu *menu) +xfce_panel_plugin_register_menu (XfcePanelPlugin *plugin, + GtkMenu *menu) { XFCE_PANEL_PLUGIN_GET_INTERFACE (plugin)->register_menu (plugin, menu); } + + /** * xfce_panel_plugin_focus_widget * @plugin : an #XfcePanelPlugin @@ -692,14 +730,17 @@ xfce_panel_plugin_register_menu (XfcePanelPlugin *plugin, GtkMenu *menu) * Grab the focus on @widget. Asks the panel to allow focus on its items and * set the focus to the requested widget. **/ -void -xfce_panel_plugin_focus_widget (XfcePanelPlugin *plugin, GtkWidget *widget) +void +xfce_panel_plugin_focus_widget (XfcePanelPlugin *plugin, + GtkWidget *widget) { XFCE_PANEL_PLUGIN_GET_INTERFACE (plugin)->focus_panel (plugin); - + gtk_widget_grab_focus (widget); } + + /** * xfce_panel_plugin_set_panel_hidden * @plugin : an #XfcePanelPlugin @@ -708,45 +749,54 @@ xfce_panel_plugin_focus_widget (XfcePanelPlugin *plugin, GtkWidget *widget) * Ask the panel to hide or unhide. This only has effect when autohide is * enabled. **/ -void xfce_panel_plugin_set_panel_hidden (XfcePanelPlugin *plugin, gboolean hidden) +void +xfce_panel_plugin_set_panel_hidden (XfcePanelPlugin *plugin, + gboolean hidden) { XFCE_PANEL_PLUGIN_GET_INTERFACE (plugin)->set_panel_hidden (plugin, hidden); } -/* menu */ + static void _plugin_menu_deactivate (GtkWidget *menu) { - int id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu), - "xfce-panel-plugin-button-release-callback")); + gint id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu), + I_("xfce-panel-plugin-button-release-callback"))); if (id) { - g_signal_handler_disconnect (menu, id); - g_object_set_data (G_OBJECT (menu), - "xfce-panel-plugin-button-release-callback", NULL); + g_signal_handler_disconnect (G_OBJECT (menu), id); + g_object_set_data (G_OBJECT (menu), + I_("xfce-panel-plugin-button-release-callback"), + NULL); } } + + static gboolean -_plugin_menu_button_released (GtkWidget *menu, GdkEventButton *ev, +_plugin_menu_button_released (GtkWidget *menu, + GdkEventButton *ev, XfcePanelPlugin *plugin) { - int id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu), - "xfce-panel-plugin-button-release-callback")); + gint id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu), + I_("xfce-panel-plugin-button-release-callback"))); if (id) { - g_signal_handler_disconnect (menu, id); - g_object_set_data (G_OBJECT (menu), - "xfce-panel-plugin-button-release-callback", NULL); + g_signal_handler_disconnect (G_OBJECT (menu), id); + g_object_set_data (G_OBJECT (menu), + I_("xfce-panel-plugin-button-release-callback"), + NULL); return TRUE; } return FALSE; } + + /** * xfce_panel_plugin_create_menu * @plugin : an #XfcePanelPlugin @@ -757,17 +807,16 @@ void xfce_panel_plugin_create_menu (XfcePanelPlugin *plugin) { GtkWidget *menu, *mi, *img; - int insert_position; - int configure_position; - gboolean allow_customization; - gchar *name; - - + gint insert_position; + gint configure_position; + gchar *name; + gboolean allow_customization; + g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin)); - allow_customization = xfce_allow_panel_customization (); + xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); - xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); + allow_customization = xfce_allow_panel_customization (); menu = gtk_menu_new (); @@ -778,13 +827,13 @@ xfce_panel_plugin_create_menu (XfcePanelPlugin *plugin) gtk_widget_set_sensitive (mi, FALSE); gtk_widget_show (mi); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + mi = gtk_separator_menu_item_new (); gtk_widget_show (mi); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + /* configure, hide by default */ - + mi = gtk_image_menu_item_new_with_label (_("Properties")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); @@ -792,15 +841,15 @@ xfce_panel_plugin_create_menu (XfcePanelPlugin *plugin) gtk_widget_show (img); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img); - g_signal_connect_swapped (mi, "activate", - G_CALLBACK (xfce_panel_plugin_signal_configure), + g_signal_connect_swapped (G_OBJECT (mi), "activate", + G_CALLBACK (xfce_panel_plugin_signal_configure), plugin); configure_position = 2; - g_object_set_data (G_OBJECT (plugin), - "xfce-panel-plugin-configure-position", + g_object_set_data (G_OBJECT (plugin), + I_("xfce-panel-plugin-configure-position"), GINT_TO_POINTER (configure_position)); - + /* about item, hide by default */ mi = gtk_image_menu_item_new_with_label (_("About")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); @@ -809,28 +858,27 @@ xfce_panel_plugin_create_menu (XfcePanelPlugin *plugin) gtk_widget_show (img); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img); - g_signal_connect_swapped (mi, "activate", - G_CALLBACK (xfce_panel_plugin_signal_about), + g_signal_connect_swapped (G_OBJECT (mi), "activate", + G_CALLBACK (xfce_panel_plugin_signal_about), plugin); /* move */ - if (allow_customization) + if (G_LIKELY (allow_customization)) { mi = gtk_image_menu_item_new_with_label (_("Move")); gtk_widget_show (mi); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + img = gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_MENU); gtk_widget_show (img); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img); - g_signal_connect_swapped (mi, "activate", - G_CALLBACK (xfce_panel_plugin_move), - plugin); + g_signal_connect_swapped (G_OBJECT (mi), "activate", + G_CALLBACK (xfce_panel_plugin_move), plugin); /* insert custom items after move */ insert_position = 5; - + /* remove */ mi = gtk_separator_menu_item_new(); gtk_widget_show (mi); @@ -839,13 +887,13 @@ xfce_panel_plugin_create_menu (XfcePanelPlugin *plugin) mi = gtk_image_menu_item_new_with_label (_("Remove")); gtk_widget_show (mi); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + img = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU); gtk_widget_show (img); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img); - g_signal_connect_swapped (mi, "activate", - G_CALLBACK (xfce_panel_plugin_remove_confirm), + g_signal_connect_swapped (G_OBJECT (mi), "activate", + G_CALLBACK (xfce_panel_plugin_remove_confirm), plugin); /* panel section */ @@ -856,26 +904,24 @@ xfce_panel_plugin_create_menu (XfcePanelPlugin *plugin) mi = gtk_image_menu_item_new_with_label (_("Add New Item")); gtk_widget_show (mi); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + img = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU); gtk_widget_show (img); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img); - g_signal_connect_swapped (mi, "activate", - G_CALLBACK (xfce_panel_plugin_customize_items), - plugin); + g_signal_connect_swapped (G_OBJECT (mi), "activate", + G_CALLBACK (xfce_panel_plugin_customize_items), plugin); mi = gtk_image_menu_item_new_with_label (_("Customize Panel")); gtk_widget_show (mi); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + img = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU); gtk_widget_show (img); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img); - g_signal_connect_swapped (mi, "activate", - G_CALLBACK (xfce_panel_plugin_customize_panel), - plugin); + g_signal_connect_swapped (G_OBJECT (mi), "activate", + G_CALLBACK (xfce_panel_plugin_customize_panel), plugin); } else { @@ -883,17 +929,20 @@ xfce_panel_plugin_create_menu (XfcePanelPlugin *plugin) insert_position = 4; } - g_object_set_data (G_OBJECT (plugin), "xfce-panel-plugin-insert-position", + g_object_set_data (G_OBJECT (plugin), + I_("xfce-panel-plugin-insert-position"), GINT_TO_POINTER (insert_position)); - + /* deactivation */ - g_signal_connect (menu, "deactivate", + g_signal_connect (G_OBJECT (menu), "deactivate", G_CALLBACK (_plugin_menu_deactivate), NULL); - - g_object_set_data_full (G_OBJECT (plugin), "xfce-panel-plugin-menu", menu, - (GDestroyNotify)gtk_widget_destroy); + + g_object_set_data_full (G_OBJECT (plugin), I_("xfce-panel-plugin-menu"), + menu, (GDestroyNotify) gtk_widget_destroy); } + + /** * xfce_panel_plugin_popup_menu * @plugin : an #XfcePanelPlugin @@ -904,66 +953,72 @@ void xfce_panel_plugin_popup_menu (XfcePanelPlugin *plugin) { GtkMenu *menu; - int block; + gint block, id; - block = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (plugin), - "xfce-panel-plugin-block")); + block = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (plugin), + I_("xfce-panel-plugin-block"))); if (block > 0) return; - - menu = g_object_get_data (G_OBJECT (plugin), "xfce-panel-plugin-menu"); + + menu = g_object_get_data (G_OBJECT (plugin), I_("xfce-panel-plugin-menu")); if (menu) { - int id = g_signal_connect (menu, "button-release-event", - G_CALLBACK (_plugin_menu_button_released), plugin); - - g_object_set_data (G_OBJECT (menu), - "xfce-panel-plugin-button-release-callback", - GINT_TO_POINTER (id)); + id = g_signal_connect (G_OBJECT (menu), "button-release-event", + G_CALLBACK (_plugin_menu_button_released), + plugin); + + g_object_set_data (G_OBJECT (menu), + I_("xfce-panel-plugin-button-release-callback"), + GINT_TO_POINTER (id)); xfce_panel_plugin_register_menu (plugin, menu); - gtk_menu_set_screen (menu, - gtk_widget_get_screen (GTK_WIDGET (plugin))); - + gtk_menu_set_screen (menu, gtk_widget_get_screen (GTK_WIDGET (plugin))); + gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME); } } + + static gboolean -_plugin_popup_menu (GtkWidget *widget, GdkEventButton *ev, +_plugin_popup_menu (GtkWidget *widget, + GdkEventButton *ev, XfcePanelPlugin *plugin) { GtkMenu *menu; - guint modifiers; - int block; + guint modifiers; + gint block; - block = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (plugin), - "xfce-panel-plugin-block")); + block = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (plugin), + I_("xfce-panel-plugin-block"))); if (block > 0) return FALSE; - menu = g_object_get_data (G_OBJECT (plugin), "xfce-panel-plugin-menu"); + menu = g_object_get_data (G_OBJECT (plugin), I_("xfce-panel-plugin-menu")); modifiers = gtk_accelerator_get_default_mod_mask (); - if (ev->button == 3 || (ev->button == 1 && + if (ev->button == 3 || (ev->button == 1 && (ev->state & modifiers) == GDK_CONTROL_MASK)) { gtk_menu_set_screen (menu, gtk_widget_get_screen (widget)); - + xfce_panel_plugin_register_menu (plugin, menu); gtk_menu_popup (menu, NULL, NULL, NULL, NULL, ev->button, ev->time); + return TRUE; } return FALSE; } + + /** * xfce_panel_plugin_add_action_widget * @plugin : an #XfcePanelPlugin @@ -972,22 +1027,24 @@ _plugin_popup_menu (GtkWidget *widget, GdkEventButton *ev, * Attach the plugin menu to this widget. Plugin writers should call this * for every widget that can receive mouse events. If you forget to call this * the plugin will not have a right-click menu and the user won't be able to - * remove it. + * remove it. **/ -void -xfce_panel_plugin_add_action_widget (XfcePanelPlugin *plugin, - GtkWidget *widget) +void +xfce_panel_plugin_add_action_widget (XfcePanelPlugin *plugin, + GtkWidget *widget) { - GtkWidget *menu = - g_object_get_data (G_OBJECT (plugin), "xfce-panel-plugin-menu"); + GtkWidget *menu = + g_object_get_data (G_OBJECT (plugin), I_("xfce-panel-plugin-menu")); if (menu) { - g_signal_connect (widget, "button-press-event", + g_signal_connect (G_OBJECT (widget), "button-press-event", G_CALLBACK (_plugin_popup_menu), plugin); } } + + /** * xfce_panel_plugin_menu_insert_item * @plugin : an #XfcePanelPlugin @@ -995,29 +1052,31 @@ xfce_panel_plugin_add_action_widget (XfcePanelPlugin *plugin, * * Insert custom menu item. **/ -void -xfce_panel_plugin_menu_insert_item (XfcePanelPlugin *plugin, - GtkMenuItem *item) +void +xfce_panel_plugin_menu_insert_item (XfcePanelPlugin *plugin, + GtkMenuItem *item) { - GtkWidget *menu = - g_object_get_data (G_OBJECT (plugin), "xfce-panel-plugin-menu"); + gint position; + GtkWidget *menu = + g_object_get_data (G_OBJECT (plugin), I_("xfce-panel-plugin-menu")); if (menu) { - int position; + position = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (plugin), + I_("xfce-panel-plugin-insert-position"))); - position = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (plugin), - "xfce-panel-plugin-insert-position")); - - gtk_menu_shell_insert (GTK_MENU_SHELL (menu), GTK_WIDGET (item), + gtk_menu_shell_insert (GTK_MENU_SHELL (menu), GTK_WIDGET (item), position); position++; - g_object_set_data (G_OBJECT (plugin), - "xfce-panel-plugin-insert-position", + + g_object_set_data (G_OBJECT (plugin), + I_("xfce-panel-plugin-insert-position"), GINT_TO_POINTER (position)); } -} +} + + /** * xfce_panel_plugin_menu_show_about @@ -1026,19 +1085,18 @@ xfce_panel_plugin_menu_insert_item (XfcePanelPlugin *plugin, * Show the 'About' item in the menu. Clicking on the menu item will emit * the "about" signal. **/ -void +void xfce_panel_plugin_menu_show_about (XfcePanelPlugin *plugin) { - GtkWidget *menu = - g_object_get_data (G_OBJECT (plugin), "xfce-panel-plugin-menu"); + gint position; + GList *l; + GtkWidget *menu = + g_object_get_data (G_OBJECT (plugin), I_("xfce-panel-plugin-menu")); if (menu) { - int position; - GList *l; - - position = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (plugin), - "xfce-panel-plugin-configure-position")); + position = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (plugin), + I_("xfce-panel-plugin-configure-position"))); l = g_list_nth (GTK_MENU_SHELL (menu)->children, position+1); @@ -1047,6 +1105,8 @@ xfce_panel_plugin_menu_show_about (XfcePanelPlugin *plugin) } } + + /** * xfce_panel_plugin_menu_show_configure * @plugin : an #XfcePanelPlugin @@ -1054,23 +1114,22 @@ xfce_panel_plugin_menu_show_about (XfcePanelPlugin *plugin) * Show the 'Configure' item in the menu. Clicking on the menu item will emit * the "configure-plugin" signal. **/ -void +void xfce_panel_plugin_menu_show_configure (XfcePanelPlugin *plugin) { GtkWidget *menu; - + gint position; + GList *l; + if (!xfce_allow_panel_customization()) return; - menu = g_object_get_data (G_OBJECT (plugin), "xfce-panel-plugin-menu"); + menu = g_object_get_data (G_OBJECT (plugin), I_("xfce-panel-plugin-menu")); if (menu) { - int position; - GList *l; - - position = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (plugin), - "xfce-panel-plugin-configure-position")); + position = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (plugin), + I_("xfce-panel-plugin-configure-position"))); l = g_list_nth (GTK_MENU_SHELL (menu)->children, position); @@ -1079,6 +1138,8 @@ xfce_panel_plugin_menu_show_configure (XfcePanelPlugin *plugin) } } + + /** * xfce_panel_plugin_block_menu * @plugin : an #XfcePanelPlugin @@ -1088,15 +1149,17 @@ xfce_panel_plugin_menu_show_configure (XfcePanelPlugin *plugin) * * See also: xfce_panel_plugin_unblock_menu() **/ -void +void xfce_panel_plugin_block_menu (XfcePanelPlugin *plugin) { - int n = 1; + gint n = 1; - g_object_set_data (G_OBJECT (plugin), "xfce-panel-plugin-block", + g_object_set_data (G_OBJECT (plugin), I_("xfce-panel-plugin-block"), GINT_TO_POINTER (n)); } + + /** * xfce_panel_plugin_unblock_menu * @plugin : an #XfcePanelPlugin @@ -1105,82 +1168,82 @@ xfce_panel_plugin_block_menu (XfcePanelPlugin *plugin) * * See also: xfce_panel_plugin_block_menu() **/ -void +void xfce_panel_plugin_unblock_menu (XfcePanelPlugin *plugin) { - g_object_set_data (G_OBJECT (plugin), "xfce-panel-plugin-block", - NULL); + g_object_set_data (G_OBJECT (plugin), I_("xfce-panel-plugin-block"), NULL); } -/* config */ + /** * xfce_panel_plugin_lookup_rc_file * @plugin : an #XfcePanelPlugin * * Looks up unique filename associated with @plugin in standard configuration - * locations. Uses xfce_resource_lookup() internally. + * locations. Uses xfce_resource_lookup() ginternally. * - * Returns: path to configuration file or %NULL if none was found. The + * Returns: path to configuration file or %NULL if none was found. The * returned string must be freed using g_free(). * * See also: xfce_panel_plugin_save_location() **/ -char * +gchar * xfce_panel_plugin_lookup_rc_file (XfcePanelPlugin *plugin) { - char path[255]; - gchar *name, *id; - + gchar path[255]; + gchar *id, *name; + name = xfce_panel_plugin_get_name (plugin); id = xfce_panel_plugin_get_id (plugin); - g_snprintf (path, 255, + g_snprintf (path, sizeof (path), "xfce4" G_DIR_SEPARATOR_S - "panel" G_DIR_SEPARATOR_S - "%s-%s.rc", - name, id); - + "panel" G_DIR_SEPARATOR_S "%s-%s.rc", name, id); + g_free (name); g_free (id); return xfce_resource_lookup (XFCE_RESOURCE_CONFIG, path); } + + /** * xfce_panel_plugin_save_location * @plugin : an #XfcePanelPlugin * @create : whether the file should be created * * Unique file location that can be used to store configuration information. - * Uses xfce_resource_save_location() internally. + * Uses xfce_resource_save_location() ginternally. * * Returns: path to configuration file or %NULL is the file could not be * created. The returned string must be freed using g_free(). * - * See also: xfce_panel_plugin_lookup_rc_file() + * See also: xfce_panel_plugin_lookup_rc_file() **/ -char * -xfce_panel_plugin_save_location (XfcePanelPlugin *plugin, gboolean create) +gchar * +xfce_panel_plugin_save_location (XfcePanelPlugin *plugin, + gboolean create) { - char path[255]; + gchar path[255]; gchar *name, *id; - + name = xfce_panel_plugin_get_name (plugin); id = xfce_panel_plugin_get_id (plugin); - g_snprintf (path, 255, + g_snprintf (path, sizeof (path), "xfce4" G_DIR_SEPARATOR_S - "panel" G_DIR_SEPARATOR_S - "%s-%s.rc", - name, id); - + "panel" G_DIR_SEPARATOR_S "%s-%s.rc", name, id); + g_free (name); g_free (id); return xfce_resource_save_location (XFCE_RESOURCE_CONFIG, path, create); } + + /** * xfce_panel_plugin_set_sensitive * @plugin : an #XfcePanelPlugin @@ -1188,13 +1251,14 @@ xfce_panel_plugin_save_location (XfcePanelPlugin *plugin, gboolean create) * * This should only be called by plugin implementations. **/ -void -xfce_panel_plugin_set_sensitive (XfcePanelPlugin *plugin, gboolean sensitive) +void +xfce_panel_plugin_set_sensitive (XfcePanelPlugin *plugin, + gboolean sensitive) { if (GTK_BIN (plugin)->child) gtk_widget_set_sensitive (GTK_BIN (plugin)->child, sensitive); else - g_signal_connect_after (plugin, "realize", + g_signal_connect_after (G_OBJECT (plugin), "realize", G_CALLBACK (xfce_panel_plugin_set_sensitive), GINT_TO_POINTER (sensitive)); } diff --git a/libxfce4panel/xfce-panel-plugin-iface.h b/libxfce4panel/xfce-panel-plugin-iface.h index 08be99b02..72ff40f63 100644 --- a/libxfce4panel/xfce-panel-plugin-iface.h +++ b/libxfce4panel/xfce-panel-plugin-iface.h @@ -1,49 +1,46 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_PANEL_PLUGIN_IFACE_H -#define _XFCE_PANEL_PLUGIN_IFACE_H +#ifndef __XFCE_PANEL_PLUGIN_IFACE_H__ +#define __XFCE_PANEL_PLUGIN_IFACE_H__ #include <gtk/gtkwidget.h> #include <gtk/gtkmenuitem.h> #include <gtk/gtkmenu.h> -#include <libxfce4util/libxfce4util.h> #include <libxfce4panel/xfce-panel-enums.h> +G_BEGIN_DECLS + +typedef struct _XfcePanelPlugin XfcePanelPlugin; +typedef struct _XfcePanelPluginInterface XfcePanelPluginInterface; + #define XFCE_TYPE_PANEL_PLUGIN (xfce_panel_plugin_get_type ()) #define XFCE_PANEL_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_PANEL_PLUGIN, XfcePanelPlugin)) #define XFCE_IS_PANEL_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_PANEL_PLUGIN)) #define XFCE_PANEL_PLUGIN_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), XFCE_TYPE_PANEL_PLUGIN, XfcePanelPluginInterface)) - -G_BEGIN_DECLS - -typedef struct _XfcePanelPlugin XfcePanelPlugin; /* dummy object */ -typedef struct _XfcePanelPluginInterface XfcePanelPluginInterface; - /** * XfcePanelPluginFunc: * @plugin : The #XfcePanelPlugin * - * Callback function to create the plugin contents. It should be given as + * Callback function to create the plugin contents. It should be given as * the argument to the registration macros. * * See also: XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL() and @@ -53,78 +50,44 @@ typedef void (*XfcePanelPluginFunc) (XfcePanelPlugin *plugin); /** * XfcePanelPluginCheck: - * @screen : The #GdkScreen that the plugin should be run on. * * Callback function that is run before creating a plugin. It should return - * if the plugin is not available for whatever reason. It should be given as + * if the plugin is not available for whatever reason. It should be given as * the argument to the registration macros. * - * Returns: %TRUE if the plugin can be started, %FALSE other wise. - * * See also: XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_WITH_CHECK() and * XFCE_PANEL_PLUGIN_REGISTER_INTERNAL_WITH_CHECK() **/ typedef gboolean (*XfcePanelPluginCheck) (GdkScreen *screen); - -GType xfce_panel_plugin_get_type (void) G_GNUC_CONST; - - -/* properties */ - -gchar *xfce_panel_plugin_get_name (XfcePanelPlugin *plugin); - -gchar *xfce_panel_plugin_get_id (XfcePanelPlugin *plugin); - -gchar * xfce_panel_plugin_get_display_name (XfcePanelPlugin *plugin); - -int xfce_panel_plugin_get_size (XfcePanelPlugin *plugin); - -XfceScreenPosition xfce_panel_plugin_get_screen_position (XfcePanelPlugin *plugin); - -void xfce_panel_plugin_set_expand (XfcePanelPlugin *plugin, - gboolean expand); - -gboolean xfce_panel_plugin_get_expand (XfcePanelPlugin *plugin); - - -/* convenience */ -GtkOrientation xfce_panel_plugin_get_orientation (XfcePanelPlugin *plugin); - - -/* menu */ -void xfce_panel_plugin_add_action_widget (XfcePanelPlugin *plugin, - GtkWidget *widget); - -void xfce_panel_plugin_menu_insert_item (XfcePanelPlugin *plugin, - GtkMenuItem *item); - -void xfce_panel_plugin_menu_show_about (XfcePanelPlugin *plugin); - -void xfce_panel_plugin_menu_show_configure (XfcePanelPlugin *plugin); - -void xfce_panel_plugin_block_menu (XfcePanelPlugin *plugin); - -void xfce_panel_plugin_unblock_menu (XfcePanelPlugin *plugin); - -void xfce_panel_plugin_register_menu (XfcePanelPlugin *plugin, - GtkMenu *menu); - - -/* config */ -char *xfce_panel_plugin_lookup_rc_file (XfcePanelPlugin *plugin); - -char *xfce_panel_plugin_save_location (XfcePanelPlugin *plugin, - gboolean create); - -/* focus */ -void xfce_panel_plugin_focus_widget (XfcePanelPlugin *plugin, - GtkWidget *widget); - -/* unhide panel */ -void xfce_panel_plugin_set_panel_hidden (XfcePanelPlugin *plugin, - gboolean hidden); +GType xfce_panel_plugin_get_type (void) G_GNUC_CONST; +gchar *xfce_panel_plugin_get_name (XfcePanelPlugin *plugin) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +gchar *xfce_panel_plugin_get_id (XfcePanelPlugin *plugin) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +gchar *xfce_panel_plugin_get_display_name (XfcePanelPlugin *plugin) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +gint xfce_panel_plugin_get_size (XfcePanelPlugin *plugin); +XfceScreenPosition xfce_panel_plugin_get_screen_position (XfcePanelPlugin *plugin); +void xfce_panel_plugin_set_expand (XfcePanelPlugin *plugin, + gboolean expand); +gboolean xfce_panel_plugin_get_expand (XfcePanelPlugin *plugin); +GtkOrientation xfce_panel_plugin_get_orientation (XfcePanelPlugin *plugin); +void xfce_panel_plugin_add_action_widget (XfcePanelPlugin *plugin, + GtkWidget *widget); +void xfce_panel_plugin_menu_insert_item (XfcePanelPlugin *plugin, + GtkMenuItem *item); +void xfce_panel_plugin_menu_show_about (XfcePanelPlugin *plugin); +void xfce_panel_plugin_menu_show_configure (XfcePanelPlugin *plugin); +void xfce_panel_plugin_block_menu (XfcePanelPlugin *plugin); +void xfce_panel_plugin_unblock_menu (XfcePanelPlugin *plugin); +void xfce_panel_plugin_register_menu (XfcePanelPlugin *plugin, + GtkMenu *menu); +gchar *xfce_panel_plugin_lookup_rc_file (XfcePanelPlugin *plugin) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +gchar *xfce_panel_plugin_save_location (XfcePanelPlugin *plugin, + gboolean create) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +void xfce_panel_plugin_focus_widget (XfcePanelPlugin *plugin, + GtkWidget *widget); +void xfce_panel_plugin_set_panel_hidden (XfcePanelPlugin *plugin, + gboolean hidden); G_END_DECLS -#endif /* _XFCE_PANEL_PLUGIN_IFACE_H */ +#endif /* !__XFCE_PANEL_PLUGIN_IFACE_H__ */ diff --git a/libxfce4panel/xfce-panel-plugin-messages.c b/libxfce4panel/xfce-panel-plugin-messages.c index b14226a63..273590a39 100644 --- a/libxfce4panel/xfce-panel-plugin-messages.c +++ b/libxfce4panel/xfce-panel-plugin-messages.c @@ -1,22 +1,21 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H @@ -26,7 +25,7 @@ #include <gdk/gdk.h> #include "xfce-panel-plugin-messages.h" -/* public API */ + /** * xfce_panel_plugin_message_send @@ -37,8 +36,10 @@ * Send a message to or from a panel plugin. **/ void -xfce_panel_plugin_message_send (GdkWindow *from, GdkNativeWindow xid, - XfcePanelPluginMessage message, int value) +xfce_panel_plugin_message_send (GdkWindow *from, + GdkNativeWindow xid, + XfcePanelPluginMessage message, + gint value) { GdkEventClient gev; diff --git a/libxfce4panel/xfce-panel-plugin-messages.h b/libxfce4panel/xfce-panel-plugin-messages.h index 357bd3f05..a1c2466aa 100644 --- a/libxfce4panel/xfce-panel-plugin-messages.h +++ b/libxfce4panel/xfce-panel-plugin-messages.h @@ -1,33 +1,32 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_PANEL_PLUGIN_MESSAGES_H -#define _XFCE_PANEL_PLUGIN_MESSAGES_H +#ifndef __XFCE_PANEL_PLUGIN_MESSAGES_H__ +#define __XFCE_PANEL_PLUGIN_MESSAGES_H__ #include <gdk/gdkx.h> -#define XFCE_PANEL_PLUGIN_ATOM "XFCE4_XFCE_PANEL_PLUGIN" - G_BEGIN_DECLS +#define XFCE_PANEL_PLUGIN_ATOM "XFCE4_XFCE_PANEL_PLUGIN" + typedef enum { XFCE_PANEL_PLUGIN_CONSTRUCT, @@ -44,16 +43,15 @@ typedef enum XFCE_PANEL_PLUGIN_SENSITIVE, XFCE_PANEL_PLUGIN_MOVE, XFCE_PANEL_PLUGIN_FOCUS, - XFCE_PANEL_PLUGIN_SET_HIDDEN, + XFCE_PANEL_PLUGIN_SET_HIDDEN } XfcePanelPluginMessage; -void xfce_panel_plugin_message_send (GdkWindow *from, - GdkNativeWindow xid, - XfcePanelPluginMessage message, - int value); +void xfce_panel_plugin_message_send (GdkWindow *from, + GdkNativeWindow xid, + XfcePanelPluginMessage message, + gint value); G_END_DECLS -#endif /* _XFCE_PANEL_PLUGIN_MESSAGES_H */ - +#endif /* !__XFCE_PANEL_PLUGIN_MESSAGES_H__ */ diff --git a/libxfce4panel/xfce-panel-plugin.h b/libxfce4panel/xfce-panel-plugin.h index e2a5ddc90..37bbd8b31 100644 --- a/libxfce4panel/xfce-panel-plugin.h +++ b/libxfce4panel/xfce-panel-plugin.h @@ -1,67 +1,74 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_PANEL_PLUGIN_H -#define _XFCE_PANEL_PLUGIN_H +#ifndef __XFCE_PANEL_PLUGIN_H__ +#define __XFCE_PANEL_PLUGIN_H__ -#include <stdlib.h> +#include <gtk/gtk.h> #include <libxfce4panel/xfce-panel-enums.h> #include <libxfce4panel/xfce-panel-macros.h> #include <libxfce4panel/xfce-panel-plugin-iface.h> -#include <libxfce4panel/xfce-panel-internal-plugin.h> +#include <libxfce4panel/xfce-panel-internal-plugin.h> #include <libxfce4panel/xfce-panel-external-plugin.h> +G_BEGIN_DECLS + /** * XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL * @construct : name of a function that can be cast to an #XfcePanelPluginFunc * - * Registers and initializes the plugin. This is the only thing that is + * Registers and initializes the plugin. This is the only thing that is * required to create a panel plugin. * * See also: <link linkend="XfcePanelPlugin">Panel Plugin interface</link> **/ -#define XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL(construct) \ - int \ - main (int argc, char **argv) \ - { \ - GtkWidget *plugin; \ - gtk_init (&argc, &argv); \ - plugin = xfce_external_panel_plugin_new (argc, argv, \ - (XfcePanelPluginFunc)construct); \ - if (!plugin) return 1; \ - g_signal_connect_after (plugin, "destroy", \ - G_CALLBACK (exit), NULL); \ - gtk_widget_show (plugin); \ - gtk_main (); \ - return 0; \ +#define XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL(construct) \ + gint \ + main (gint argc, gchar **argv) \ + { \ + GtkWidget *plugin; \ + \ + gtk_init (&argc, &argv); \ + \ + plugin = xfce_external_panel_plugin_new (argc, argv, \ + (XfcePanelPluginFunc)construct); \ + \ + if (G_UNLIKELY (plugin == NULL)) \ + return 1; \ + \ + g_signal_connect_after (G_OBJECT (plugin), "destroy", \ + G_CALLBACK (gtk_main_quit), NULL); \ + gtk_widget_show (plugin); \ + \ + gtk_main (); \ + return 0; \ } /** * XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_WITH_CHECK - * @construct : name of a function that can be cast to an + * @construct : name of a function that can be cast to an * #XfcePanelPluginFunc * @check : name of a function that can be cast to an * #XfcePanelPluginCheck * - * Registers and initializes the plugin. This is the only thing that is + * Registers and initializes the plugin. This is the only thing that is * required to create a panel plugin. The @check functions is run before * creating the plugin, and should return FALSE if plugin creation is not * possible. @@ -69,28 +76,36 @@ * See also: <link linkend="XfcePanelPlugin">Panel Plugin interface</link> **/ #define XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_WITH_CHECK(construct,check) \ - int \ - main (int argc, char **argv) \ - { \ - GtkWidget *plugin; \ - XfcePanelPluginCheck test = (XfcePanelPluginCheck)check; \ - gtk_init (&argc, &argv); \ - if (!test(gdk_screen_get_default())) return 2; \ - plugin = xfce_external_panel_plugin_new (argc, argv, \ - (XfcePanelPluginFunc)construct); \ - if (!plugin) return 1; \ - g_signal_connect_after (plugin, "destroy", \ - G_CALLBACK (exit), NULL); \ - gtk_widget_show (plugin); \ - gtk_main (); \ - return 0; \ + gint \ + main (gint argc, gchar **argv) \ + { \ + GtkWidget *plugin; \ + XfcePanelPluginCheck test = (XfcePanelPluginCheck)check; \ + \ + gtk_init (&argc, &argv); \ + \ + if (G_UNLIKELY (test(gdk_screen_get_default()) == FALSE)) \ + return 2; \ + \ + plugin = xfce_external_panel_plugin_new (argc, argv, \ + (XfcePanelPluginFunc)construct); \ + \ + if (G_UNLIKELY (plugin == NULL)) \ + return 1; \ + \ + g_signal_connect_after (G_OBJECT (plugin), "destroy", \ + G_CALLBACK (gtk_main_quit), NULL); \ + gtk_widget_show (plugin); \ + \ + gtk_main (); \ + return 0; \ } /** * XFCE_PANEL_PLUGIN_REGISTER_INTERNAL * @construct : name of a function that can be cast to an #XfcePanelPluginFunc * - * Registers and initializes the plugin. This is the only thing that is + * Registers and initializes the plugin. This is the only thing that is * required to create a panel plugin. * * This macro is for plugins implemented as a loadable module. Generally it is @@ -100,10 +115,10 @@ * See also: <link linkend="XfcePanelPlugin">Panel Plugin interface</link> **/ #define XFCE_PANEL_PLUGIN_REGISTER_INTERNAL(construct) \ - XfcePanelPluginFunc \ - xfce_panel_plugin_get_construct (void) \ - { \ - return (XfcePanelPluginFunc)construct; \ + XfcePanelPluginFunc \ + xfce_panel_plugin_get_construct (void) \ + { \ + return (XfcePanelPluginFunc)construct; \ } /** @@ -112,7 +127,7 @@ * @check : name of a function that can be cast to an * #XfcePanelPluginCheck * - * Registers and initializes the plugin. This is the only thing that is + * Registers and initializes the plugin. This is the only thing that is * required to create a panel plugin. The @check function is run before * creating the plugin, and should return FALSE if plugin creation is not * possible. @@ -124,15 +139,17 @@ * See also: <link linkend="XfcePanelPlugin">Panel Plugin interface</link> **/ #define XFCE_PANEL_PLUGIN_REGISTER_INTERNAL_WITH_CHECK(construct,check) \ - XfcePanelPluginFunc \ - xfce_panel_plugin_get_construct (void) \ - { \ - return (XfcePanelPluginFunc)construct; \ - } \ - XfcePanelPluginCheck \ - xfce_panel_plugin_get_check (void) \ - { \ - return (XfcePanelPluginCheck)check; \ + XfcePanelPluginFunc \ + xfce_panel_plugin_get_construct (void) \ + { \ + return (XfcePanelPluginFunc)construct; \ + } \ + XfcePanelPluginCheck \ + xfce_panel_plugin_get_check (void) \ + { \ + return (XfcePanelPluginCheck)check; \ } -#endif /* _XFCE_PANEL_PLUGIN_H */ +G_END_DECLS + +#endif /* !__XFCE_PANEL_PLUGIN_H__ */ diff --git a/libxfce4panel/xfce-panel-window.c b/libxfce4panel/xfce-panel-window.c index e5914ad6c..b3bb58a1c 100644 --- a/libxfce4panel/xfce-panel-window.c +++ b/libxfce4panel/xfce-panel-window.c @@ -1,22 +1,21 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2004-2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2004-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H @@ -28,6 +27,7 @@ #include <gtk/gtk.h> +#include "xfce-panel-macros.h" #include "xfce-marshal.h" #include "xfce-panel-enum-types.h" #include "xfce-panel-window.h" @@ -38,7 +38,7 @@ #define DEFAULT_ORIENTATION GTK_ORIENTATION_HORIZONTAL #define DEFAULT_HANDLE_STYLE XFCE_HANDLE_STYLE_BOTH -#define HANDLE_WIDTH 8 +#define HANDLE_WIDTH 8 enum { @@ -57,137 +57,114 @@ enum }; -typedef struct _XfcePanelWindowPrivate XfcePanelWindowPrivate; +typedef struct _XfcePanelWindowPrivate XfcePanelWindowPrivate; struct _XfcePanelWindowPrivate { - GtkOrientation orientation; - XfceHandleStyle handle_style; + GtkOrientation orientation; + XfceHandleStyle handle_style; - GtkAllocation allocation; + GtkAllocation allocation; - int x_offset; - int y_offset; - int x_root; - int y_root; + gint x_offset; + gint y_offset; + gint x_root; + gint y_root; - XfcePanelWindowMoveFunc move_func; - gpointer move_data; + XfcePanelWindowMoveFunc move_func; + gpointer move_data; XfcePanelWindowResizeFunc resize_func; - gpointer resize_data; - - guint shown:1; - guint in_move:1; - guint top_border:1; - guint bottom_border:1; - guint left_border:1; - guint right_border:1; - guint movable:1; + gpointer resize_data; + + guint shown : 1; + guint in_move : 1; + guint top_border : 1; + guint bottom_border : 1; + guint left_border : 1; + guint right_border : 1; + guint movable : 1; }; -/* init */ -static void xfce_panel_window_class_init (XfcePanelWindowClass * klass); - -static void xfce_panel_window_init (XfcePanelWindow * window); - - -/* GObject */ -static void xfce_panel_window_get_property (GObject * object, - guint prop_id, - GValue * value, - GParamSpec * pspec); - -static void xfce_panel_window_set_property (GObject * object, - guint prop_id, - const GValue * value, - GParamSpec * pspec); - - -/* GtkWidget */ -static void xfce_panel_window_realize (GtkWidget * widget); - -static void xfce_panel_window_unrealize (GtkWidget * widget); - -static void xfce_panel_window_map (GtkWidget * widget); - -static void xfce_panel_window_unmap (GtkWidget * widget); - -static void xfce_panel_window_show (GtkWidget * widget); - -static void xfce_panel_window_hide (GtkWidget * widget); -/* drawing, size and style */ -static gint xfce_panel_window_expose (GtkWidget * widget, - GdkEventExpose * event); - -static void xfce_panel_window_size_request (GtkWidget * widget, - GtkRequisition * requisition); - -static void xfce_panel_window_size_allocate (GtkWidget * widget, - GtkAllocation * allocation); +static void xfce_panel_window_class_init (XfcePanelWindowClass *klass); +static void xfce_panel_window_init (XfcePanelWindow *window); +static void xfce_panel_window_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void xfce_panel_window_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void xfce_panel_window_realize (GtkWidget *widget); +static void xfce_panel_window_unrealize (GtkWidget *widget); +static void xfce_panel_window_map (GtkWidget *widget); +static void xfce_panel_window_unmap (GtkWidget *widget); +static void xfce_panel_window_show (GtkWidget *widget); +static void xfce_panel_window_hide (GtkWidget *widget); +static gint xfce_panel_window_expose (GtkWidget *widget, + GdkEventExpose *event); +static void xfce_panel_window_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void xfce_panel_window_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); +static gboolean xfce_panel_window_button_press (GtkWidget *widget, + GdkEventButton *event); +static gboolean xfce_panel_window_button_release (GtkWidget *widget, + GdkEventButton *event); +static gboolean xfce_panel_window_motion_notify (GtkWidget *widget, + GdkEventMotion *event); +static void _paint_handle (XfcePanelWindow *panel_window, + gboolean start, + GdkRectangle *area); -/* keyboard and mouse events */ -static gboolean xfce_panel_window_button_press (GtkWidget * widget, - GdkEventButton * event); - -static gboolean xfce_panel_window_button_release (GtkWidget * widget, - GdkEventButton * event); - -static gboolean xfce_panel_window_motion_notify (GtkWidget * widget, - GdkEventMotion * event); - - -/* internal functions */ -static void _paint_handle (XfcePanelWindow * panel_window, - gboolean start, - GdkRectangle * area); - /* global vars */ static GtkWindowClass *parent_class = NULL; +static guint panel_window_signals[LAST_SIGNAL] = { 0 }; -static guint panel_window_signals[LAST_SIGNAL] = { 0 }; /* public GType function */ GType xfce_panel_window_get_type (void) { - static GtkType type = 0; + static GtkType type = G_TYPE_INVALID; - if (!type) + if (G_UNLIKELY (type == G_TYPE_INVALID)) { static const GTypeInfo type_info = { sizeof (XfcePanelWindowClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, + NULL, + NULL, (GClassInitFunc) xfce_panel_window_class_init, - (GClassFinalizeFunc) NULL, + NULL, NULL, sizeof (XfcePanelWindow), - 0, /* n_preallocs */ + 0, (GInstanceInitFunc) xfce_panel_window_init, NULL }; type = g_type_register_static (GTK_TYPE_WINDOW, - "XfcePanelWindow", &type_info, 0); + I_("XfcePanelWindow"), &type_info, 0); } return type; } + /* init */ static void -xfce_panel_window_class_init (XfcePanelWindowClass * klass) +xfce_panel_window_class_init (XfcePanelWindowClass *klass) { - GObjectClass *gobject_class; - GtkWidgetClass *widget_class; + GObjectClass *gobject_class; + GtkWidgetClass *widget_class; GtkContainerClass *container_class; g_type_class_add_private (klass, sizeof (XfcePanelWindowPrivate)); @@ -225,15 +202,17 @@ xfce_panel_window_class_init (XfcePanelWindowClass * klass) * Emitted when the orientation of the #XfcePanelWindow changes. **/ panel_window_signals[ORIENTATION_CHANGED] = - g_signal_new ("orientation-changed", + g_signal_new (I_("orientation-changed"), G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (XfcePanelWindowClass, orientation_changed), NULL, NULL, g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, GTK_TYPE_ORIENTATION); - + G_TYPE_NONE, + 1, + GTK_TYPE_ORIENTATION); + /** * XfcePanelWindow::move-start * @window: the #XfcePanelWindow which emitted the signal @@ -241,11 +220,15 @@ xfce_panel_window_class_init (XfcePanelWindowClass * klass) * Emitted when the user starts to drag the #XfcePanelWindow. **/ panel_window_signals[MOVE_START] = - g_signal_new ("move-start", G_OBJECT_CLASS_TYPE (widget_class), + g_signal_new (I_("move-start"), + G_OBJECT_CLASS_TYPE (widget_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (XfcePanelWindowClass, move_start), + G_STRUCT_OFFSET (XfcePanelWindowClass, + move_start), NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); /** * XfcePanelWindow::move @@ -254,15 +237,20 @@ xfce_panel_window_class_init (XfcePanelWindowClass * klass) * @y: y coordinate of the new position * * Emitted when the user moves the #XfcePanelWindow to a new position with - * coordinates (@x, @y). + * coordinates (@x, @y). **/ panel_window_signals[MOVE] = - g_signal_new ("move", G_OBJECT_CLASS_TYPE (widget_class), + g_signal_new (I_("move"), + G_OBJECT_CLASS_TYPE (widget_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (XfcePanelWindowClass, move), + G_STRUCT_OFFSET (XfcePanelWindowClass, + move), NULL, NULL, _xfce_marshal_VOID__INT_INT, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); + G_TYPE_NONE, + 2, + G_TYPE_INT, + G_TYPE_INT); /** * XfcePanelWindow::move-end @@ -274,12 +262,17 @@ xfce_panel_window_class_init (XfcePanelWindowClass * klass) * position has coordinates (@x, @y). **/ panel_window_signals[MOVE_END] = - g_signal_new ("move-end", G_OBJECT_CLASS_TYPE (widget_class), + g_signal_new (I_("move-end"), + G_OBJECT_CLASS_TYPE (widget_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (XfcePanelWindowClass, move_end), + G_STRUCT_OFFSET (XfcePanelWindowClass, + move_end), NULL, NULL, _xfce_marshal_VOID__INT_INT, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); + G_TYPE_NONE, + 2, + G_TYPE_INT, + G_TYPE_INT); /* properties */ @@ -289,13 +282,14 @@ xfce_panel_window_class_init (XfcePanelWindowClass * klass) * The orientation of the window. This the determines the way the handles * are drawn. **/ - g_object_class_install_property (gobject_class, - PROP_ORIENTATION, - g_param_spec_enum ("orientation", - "Orientation", - "The orientation of the itembar", - GTK_TYPE_ORIENTATION, - GTK_ORIENTATION_HORIZONTAL, G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_ORIENTATION, + g_param_spec_enum ("orientation", + "Orientation", + "The orientation of the itembar", + GTK_TYPE_ORIENTATION, + GTK_ORIENTATION_HORIZONTAL, + G_PARAM_READWRITE)); /** @@ -303,18 +297,20 @@ xfce_panel_window_class_init (XfcePanelWindowClass * klass) * * The #XfceHandleStyle to use when drawing handles. **/ - g_object_class_install_property (gobject_class, - PROP_HANDLE_STYLE, - g_param_spec_enum ("handle-style", - "Handle style", - "Type of handles to draw", - XFCE_TYPE_HANDLE_STYLE, - DEFAULT_HANDLE_STYLE, G_PARAM_READWRITE)); - + g_object_class_install_property (gobject_class, + PROP_HANDLE_STYLE, + g_param_spec_enum ("handle-style", + "Handle style", + "Type of handles to draw", + XFCE_TYPE_HANDLE_STYLE, + DEFAULT_HANDLE_STYLE, + G_PARAM_READWRITE)); } + + static void -xfce_panel_window_init (XfcePanelWindow * panel_window) +xfce_panel_window_init (XfcePanelWindow *panel_window) { XfcePanelWindowPrivate *priv; @@ -328,7 +324,7 @@ xfce_panel_window_init (XfcePanelWindow * panel_window) NULL); gtk_window_stick (GTK_WINDOW (panel_window)); - + priv = XFCE_PANEL_WINDOW_GET_PRIVATE (panel_window); priv->handle_style = DEFAULT_HANDLE_STYLE; @@ -351,23 +347,26 @@ xfce_panel_window_init (XfcePanelWindow * panel_window) priv->bottom_border = TRUE; priv->left_border = TRUE; priv->right_border = TRUE; - priv->movable = TRUE; + priv->movable = TRUE; gtk_widget_set_events (GTK_WIDGET (panel_window), gtk_widget_get_events (GTK_WIDGET (panel_window)) | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - | GDK_EXPOSURE_MASK - | GDK_ENTER_NOTIFY_MASK + | GDK_EXPOSURE_MASK + | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); } + + /* GObject */ static void -xfce_panel_window_get_property (GObject * object, - guint prop_id, GValue * value, - GParamSpec * pspec) +xfce_panel_window_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { XfcePanelWindowPrivate *priv = XFCE_PANEL_WINDOW_GET_PRIVATE (object); @@ -385,21 +384,23 @@ xfce_panel_window_get_property (GObject * object, } } + + static void -xfce_panel_window_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec) +xfce_panel_window_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { XfcePanelWindow *window = XFCE_PANEL_WINDOW (object); switch (prop_id) { case PROP_ORIENTATION: - xfce_panel_window_set_orientation (window, - g_value_get_enum (value)); + xfce_panel_window_set_orientation (window, g_value_get_enum (value)); break; case PROP_HANDLE_STYLE: - xfce_panel_window_set_handle_style (window, - g_value_get_enum (value)); + xfce_panel_window_set_handle_style (window, g_value_get_enum (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -407,35 +408,45 @@ xfce_panel_window_set_property (GObject * object, guint prop_id, } } + + /* GtkWidget */ static void -xfce_panel_window_realize (GtkWidget * widget) +xfce_panel_window_realize (GtkWidget *widget) { gtk_window_stick (GTK_WINDOW (widget)); GTK_WIDGET_CLASS (parent_class)->realize (widget); } + + static void -xfce_panel_window_unrealize (GtkWidget * widget) +xfce_panel_window_unrealize (GtkWidget *widget) { GTK_WIDGET_CLASS (parent_class)->unrealize (widget); } + + static void -xfce_panel_window_map (GtkWidget * widget) +xfce_panel_window_map (GtkWidget *widget) { GTK_WIDGET_CLASS (parent_class)->map (widget); } + + static void -xfce_panel_window_unmap (GtkWidget * widget) +xfce_panel_window_unmap (GtkWidget *widget) { GTK_WIDGET_CLASS (parent_class)->unmap (widget); } + + static void -xfce_panel_window_show (GtkWidget * widget) +xfce_panel_window_show (GtkWidget *widget) { XfcePanelWindowPrivate *priv = XFCE_PANEL_WINDOW_GET_PRIVATE (widget); @@ -450,8 +461,10 @@ xfce_panel_window_show (GtkWidget * widget) } } + + static void -xfce_panel_window_hide (GtkWidget * widget) +xfce_panel_window_hide (GtkWidget *widget) { XfcePanelWindowPrivate *priv = XFCE_PANEL_WINDOW_GET_PRIVATE (widget); @@ -460,26 +473,29 @@ xfce_panel_window_hide (GtkWidget * widget) priv->shown = FALSE; } + + /* drawing, size and style */ static void -_panel_window_paint_border (XfcePanelWindow * panel) +_panel_window_paint_border (XfcePanelWindow *panel) { - XfcePanelWindowPrivate *priv = XFCE_PANEL_WINDOW_GET_PRIVATE (panel); - GdkWindow *window = GTK_WIDGET (panel)->window; - GtkAllocation *a = &(GTK_WIDGET (panel)->allocation); - GtkStyle *style = GTK_WIDGET (panel)->style; - GtkStateType state_type = GTK_WIDGET_STATE (GTK_WIDGET (panel)); - int top, bottom, left, right; + XfcePanelWindowPrivate *priv = XFCE_PANEL_WINDOW_GET_PRIVATE (panel); + GdkWindow *window = GTK_WIDGET (panel)->window; + GtkAllocation *a = &(GTK_WIDGET (panel)->allocation); + GtkStyle *style = GTK_WIDGET (panel)->style; + GtkStateType state_type = GTK_WIDGET_STATE (GTK_WIDGET (panel)); + gint top, bottom, left, right; + gint x1, x2, y1, y2; top = priv->top_border ? style->ythickness : 0; bottom = priv->bottom_border ? style->ythickness : 0; left = priv->left_border ? style->xthickness : 0; right = priv->right_border ? style->xthickness : 0; - + /* Code based on gtk-xfce-engine-2 */ /* Attempt to explain the code below with some ASCII 'art' - * + * * joining lines: - = horizontal, + = vertical * * single double @@ -489,140 +505,134 @@ _panel_window_paint_border (XfcePanelWindow * panel) * + + ++ ++ * + + ++--------+ * +---------- +---------- - * + * */ - + if (top > 0) { - int x1, y1, x2; - x1 = a->x; y1 = a->y; x2 = x1 + a->width - 1; - if (right > 0) x2--; - + if (right > 0) + x2--; + if (top > 1) { - gdk_draw_line (window, style->dark_gc[state_type], - x1, y1, x2, y1); - - if (left > 0) x1++; + gdk_draw_line (window, style->dark_gc[state_type], x1, y1, x2, y1); - if (right > 1) x2--; + if (left > 0) + x1++; + + if (right > 1) + x2--; y1++; - - gdk_draw_line (window, style->light_gc[state_type], - x1, y1, x2, y1); + + gdk_draw_line (window, style->light_gc[state_type], x1, y1, x2, y1); } else { - gdk_draw_line (window, style->light_gc[state_type], - x1, y1, x2, y1); + gdk_draw_line (window, style->light_gc[state_type], x1, y1, x2, y1); } } - + if (bottom > 0) { - int x1, y1, x2; - - x1 = a->x; + x1 = a->x; y1 = a->y + a->height - 1; x2 = x1 + a->width - 1; - - if (left > 0) x1++; - + + if (left > 0) + x1++; + if (bottom > 1) - { - gdk_draw_line (window, style->dark_gc[state_type], - x1, y1, x2, y1); + { + gdk_draw_line (window, style->dark_gc[state_type], x1, y1, x2, y1); - if (left > 1) x1++; + if (left > 1) + x1++; - if (right > 0) x2--; + if (right > 0) + x2--; y1--; - - gdk_draw_line (window, style->mid_gc[state_type], - x1, y1, x2, y1); + + gdk_draw_line (window, style->mid_gc[state_type], x1, y1, x2, y1); } else { - gdk_draw_line (window, style->dark_gc[state_type], - x1, y1, x2, y1); + gdk_draw_line (window, style->dark_gc[state_type], x1, y1, x2, y1); } } if (left > 0) { - int x1, y1, y2; - x1 = a->x; y1 = a->y; y2 = a->y + a->height - 1; - - if (top > 0) y1++; - + + if (top > 0) + y1++; + if (left > 1) { - gdk_draw_line (window, style->dark_gc[state_type], - x1, y1, x1, y2); + gdk_draw_line (window, style->dark_gc[state_type], x1, y1, x1, y2); - if (top > 1) y1++; + if (top > 1) + y1++; - if (bottom > 0) y2--; + if (bottom > 0) + y2--; x1++; - - gdk_draw_line (window, style->light_gc[state_type], - x1, y1, x1, y2); + + gdk_draw_line (window, style->light_gc[state_type], x1, y1, x1, y2); } - else + else { - gdk_draw_line (window, style->light_gc[state_type], - x1, y1, x1, y2); + gdk_draw_line (window, style->light_gc[state_type], x1, y1, x1, y2); } } if (right > 0) { - int x1, y1, y2; - x1 = a->x + a->width - 1; y1 = a->y; y2 = a->y + a->height - 1; - - if (bottom > 0) y2--; - + + if (bottom > 0) + y2--; + if (right > 1) { - gdk_draw_line (window, style->dark_gc[state_type], - x1, y1, x1, y2); - - if (top > 0) y1++; + gdk_draw_line (window, style->dark_gc[state_type], x1, y1, x1, y2); + + if (top > 0) + y1++; - if (bottom > 1) y2--; + if (bottom > 1) + y2--; x1--; - - gdk_draw_line (window, style->mid_gc[state_type], - x1, y1, x1, y2); + + gdk_draw_line (window, style->mid_gc[state_type], x1, y1, x1, y2); } else { - gdk_draw_line (window, style->dark_gc[state_type], - x1, y1, x1, y2); + gdk_draw_line (window, style->dark_gc[state_type], x1, y1, x1, y2); } } } + + static gint -xfce_panel_window_expose (GtkWidget * widget, GdkEventExpose * event) +xfce_panel_window_expose (GtkWidget *widget, + GdkEventExpose *event) { - XfcePanelWindow *panel_window = XFCE_PANEL_WINDOW (widget); - XfcePanelWindowPrivate *priv = - XFCE_PANEL_WINDOW_GET_PRIVATE (panel_window); + XfcePanelWindow *panel_window = XFCE_PANEL_WINDOW (widget); + XfcePanelWindowPrivate *priv = XFCE_PANEL_WINDOW_GET_PRIVATE (panel_window); if (GTK_WIDGET_DRAWABLE (widget)) { @@ -647,21 +657,22 @@ xfce_panel_window_expose (GtkWidget * widget, GdkEventExpose * event) default: break; } - + _panel_window_paint_border (panel_window); } return FALSE; } + + static void -xfce_panel_window_size_request (GtkWidget * widget, - GtkRequisition * requisition) +xfce_panel_window_size_request (GtkWidget *widget, + GtkRequisition *requisition) { - XfcePanelWindow *panel_window = XFCE_PANEL_WINDOW (widget); - XfcePanelWindowPrivate *priv = - XFCE_PANEL_WINDOW_GET_PRIVATE (panel_window); - int handle_size, thick; + XfcePanelWindow *panel_window = XFCE_PANEL_WINDOW (widget); + XfcePanelWindowPrivate *priv = XFCE_PANEL_WINDOW_GET_PRIVATE (panel_window); + gint handle_size, thick; requisition->width = requisition->height = 0; @@ -669,7 +680,7 @@ xfce_panel_window_size_request (GtkWidget * widget, { gtk_widget_size_request (GTK_BIN (widget)->child, requisition); } - + if (priv->top_border) requisition->height += widget->style->ythickness; if (priv->bottom_border) @@ -680,23 +691,21 @@ xfce_panel_window_size_request (GtkWidget * widget, requisition->width += widget->style->xthickness; if (GTK_ORIENTATION_HORIZONTAL == priv->orientation) - { thick = 2 * widget->style->xthickness; - } else - { thick = 2 * widget->style->ythickness; - } switch (priv->handle_style) { case XFCE_HANDLE_STYLE_BOTH: handle_size = 2 * (HANDLE_WIDTH + thick); break; + case XFCE_HANDLE_STYLE_START: case XFCE_HANDLE_STYLE_END: handle_size = HANDLE_WIDTH + thick; break; + default: handle_size = 0; } @@ -707,11 +716,15 @@ xfce_panel_window_size_request (GtkWidget * widget, requisition->height += handle_size; } + + static void -xfce_panel_window_size_allocate (GtkWidget * widget, - GtkAllocation * allocation) +xfce_panel_window_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) { XfcePanelWindowPrivate *priv = XFCE_PANEL_WINDOW_GET_PRIVATE (widget); + GtkAllocation old, new, childalloc; + gint start_handle_size, end_handle_size, thick; widget->allocation = *allocation; @@ -727,8 +740,6 @@ xfce_panel_window_size_allocate (GtkWidget * widget, if (priv->resize_func && priv->shown) { - GtkAllocation old, new; - old = priv->allocation; new = *allocation; @@ -745,9 +756,6 @@ xfce_panel_window_size_allocate (GtkWidget * widget, if (GTK_BIN (widget)->child) { - GtkAllocation childalloc; - int start_handle_size, end_handle_size, thick; - if (GTK_ORIENTATION_HORIZONTAL == priv->orientation) thick = 2 * widget->style->xthickness; else @@ -777,19 +785,19 @@ xfce_panel_window_size_allocate (GtkWidget * widget, childalloc.y += widget->style->ythickness; childalloc.height -= widget->style->ythickness; } - + if (priv->bottom_border) childalloc.height -= widget->style->ythickness; - + if (priv->left_border) { childalloc.x += widget->style->xthickness; childalloc.width -= widget->style->xthickness; } - + if (priv->right_border) childalloc.width -= widget->style->xthickness; - + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { childalloc.x += start_handle_size; @@ -807,23 +815,25 @@ xfce_panel_window_size_allocate (GtkWidget * widget, priv->allocation = *allocation; } + + /* keyboard and mouse events */ static gboolean -xfce_panel_window_button_press (GtkWidget * widget, GdkEventButton * event) +xfce_panel_window_button_press (GtkWidget *widget, + GdkEventButton *event) { - XfcePanelWindow *panel_window; + XfcePanelWindow *panel_window; XfcePanelWindowPrivate *priv; + GdkCursor *fleur; g_return_val_if_fail (XFCE_IS_PANEL_WINDOW (widget), FALSE); panel_window = XFCE_PANEL_WINDOW (widget); priv = XFCE_PANEL_WINDOW_GET_PRIVATE (panel_window); - if (priv->movable && + if (priv->movable && event->button == 1 && (event->window == widget->window)) { - GdkCursor *fleur; - gdk_window_get_root_origin (widget->window, &(priv->x_root), &(priv->y_root)); @@ -843,17 +853,20 @@ xfce_panel_window_button_press (GtkWidget * widget, GdkEventButton * event) } gdk_cursor_unref (fleur); - g_signal_emit (widget, panel_window_signals[MOVE_START], 0); + g_signal_emit (G_OBJECT (widget), panel_window_signals[MOVE_START], 0); return TRUE; } return FALSE; } + + static gboolean -xfce_panel_window_button_release (GtkWidget * widget, GdkEventButton * event) +xfce_panel_window_button_release (GtkWidget *widget, + GdkEventButton *event) { - XfcePanelWindow *panel_window; + XfcePanelWindow *panel_window; XfcePanelWindowPrivate *priv; g_return_val_if_fail (XFCE_IS_PANEL_WINDOW (widget), FALSE); @@ -868,18 +881,21 @@ xfce_panel_window_button_release (GtkWidget * widget, GdkEventButton * event) priv->in_move = FALSE; gdk_window_get_origin (widget->window, &(priv->x_root), &(priv->y_root)); - g_signal_emit (widget, panel_window_signals[MOVE_END], 0, + g_signal_emit (G_OBJECT (widget), panel_window_signals[MOVE_END], 0, priv->x_root, priv->y_root); return TRUE; } + + static gboolean -xfce_panel_window_motion_notify (GtkWidget * widget, GdkEventMotion * event) +xfce_panel_window_motion_notify (GtkWidget *widget, + GdkEventMotion *event) { - XfcePanelWindow *panel_window; + XfcePanelWindow *panel_window; XfcePanelWindowPrivate *priv; - int new_x, new_y; + gint new_x, new_y; g_return_val_if_fail (XFCE_IS_PANEL_WINDOW (widget), FALSE); @@ -887,40 +903,38 @@ xfce_panel_window_motion_notify (GtkWidget * widget, GdkEventMotion * event) priv = XFCE_PANEL_WINDOW_GET_PRIVATE (panel_window); if (!priv->in_move) - { return FALSE; - } gdk_window_get_pointer (NULL, &new_x, &new_y, NULL); new_x += priv->x_offset; new_y += priv->y_offset; if (priv->move_func) - { priv->move_func (widget, priv->move_data, &new_x, &new_y); - } priv->x_root = new_x; priv->y_root = new_y; gdk_window_move (widget->window, new_x, new_y); - g_signal_emit (widget, panel_window_signals[MOVE], 0, new_x, new_y); + g_signal_emit (G_OBJECT (widget), panel_window_signals[MOVE], 0, new_x, new_y); return TRUE; } -/* internal functions */ + + +/* ginternal functions */ static void -_paint_handle (XfcePanelWindow * panel_window, gboolean start, - GdkRectangle * area) +_paint_handle (XfcePanelWindow *panel_window, + gboolean start, + GdkRectangle *area) { - XfcePanelWindowPrivate *priv = - XFCE_PANEL_WINDOW_GET_PRIVATE (panel_window); - GtkWidget *widget = GTK_WIDGET (panel_window); - GtkAllocation *alloc = &(widget->allocation); - int x, y, w, h, xthick, ythick; - gboolean horizontal = priv->orientation == GTK_ORIENTATION_HORIZONTAL; + XfcePanelWindowPrivate *priv = XFCE_PANEL_WINDOW_GET_PRIVATE (panel_window); + GtkWidget *widget = GTK_WIDGET (panel_window); + GtkAllocation *alloc = &(widget->allocation); + gint x, y, w, h, xthick, ythick; + gboolean horizontal = priv->orientation == GTK_ORIENTATION_HORIZONTAL; xthick = widget->style->xthickness; ythick = widget->style->ythickness; @@ -987,14 +1001,14 @@ _paint_handle (XfcePanelWindow * panel_window, gboolean start, } gtk_paint_handle (widget->style, widget->window, - GTK_WIDGET_STATE (widget), GTK_SHADOW_NONE, + GTK_WIDGET_STATE (widget), GTK_SHADOW_NONE, area, widget, "handlebox", x, y, w, h, horizontal ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL); } -/* public interface */ + /** * xfce_panel_window_new @@ -1009,16 +1023,18 @@ xfce_panel_window_new (void) return GTK_WIDGET (g_object_new (XFCE_TYPE_PANEL_WINDOW, NULL)); } + + /** * xfce_panel_window_get_orientation * @window: #XfcePanelWindow - * + * * Get orientation of panel window. * * Returns: #GtkOrientation of @window **/ GtkOrientation -xfce_panel_window_get_orientation (XfcePanelWindow * window) +xfce_panel_window_get_orientation (XfcePanelWindow *window) { XfcePanelWindowPrivate *priv; @@ -1029,16 +1045,18 @@ xfce_panel_window_get_orientation (XfcePanelWindow * window) return priv->orientation; } + + /** * xfce_panel_window_set_orientation * @window : #XfcePanelWindow * @orientation: new #GtkOrientation - * + * * Set orientation for panel window. **/ void -xfce_panel_window_set_orientation (XfcePanelWindow * window, - GtkOrientation orientation) +xfce_panel_window_set_orientation (XfcePanelWindow *window, + GtkOrientation orientation) { XfcePanelWindowPrivate *priv; @@ -1054,37 +1072,40 @@ xfce_panel_window_set_orientation (XfcePanelWindow * window, g_object_notify (G_OBJECT (window), "orientation"); } + + /** * xfce_panel_window_get_handle_style * @window: #XfcePanelWindow - * + * * Get handle style of panel window. * * Returns: #XfceHandleStyle of @window **/ XfceHandleStyle -xfce_panel_window_get_handle_style (XfcePanelWindow * window) +xfce_panel_window_get_handle_style (XfcePanelWindow *window) { XfcePanelWindowPrivate *priv; - g_return_val_if_fail (XFCE_IS_PANEL_WINDOW (window), - DEFAULT_HANDLE_STYLE); + g_return_val_if_fail (XFCE_IS_PANEL_WINDOW (window), DEFAULT_HANDLE_STYLE); priv = XFCE_PANEL_WINDOW_GET_PRIVATE (window); return priv->handle_style; } + + /** * xfce_panel_window_set_handle_style * @window : #XfcePanelWindow * @handle_style: new #XfceHandleStyle - * + * * Set handle style for panel window. **/ void -xfce_panel_window_set_handle_style (XfcePanelWindow * window, - XfceHandleStyle handle_style) +xfce_panel_window_set_handle_style (XfcePanelWindow *window, + XfceHandleStyle handle_style) { XfcePanelWindowPrivate *priv; @@ -1102,6 +1123,8 @@ xfce_panel_window_set_handle_style (XfcePanelWindow * window, gtk_widget_queue_resize (GTK_WIDGET (window)); } + + /** * xfce_panel_window_get_show_border * @window : #XfcePanelWindow @@ -1109,15 +1132,15 @@ xfce_panel_window_set_handle_style (XfcePanelWindow * window, * @bottom_border: location for bottom border or %NULL * @left_border : location for left border or %NULL * @right_border : location for right border or %NULL - * + * * Get visibility of panel window borders. **/ void -xfce_panel_window_get_show_border (XfcePanelWindow * window, - gboolean *top_border, - gboolean *bottom_border, - gboolean *left_border, - gboolean *right_border) +xfce_panel_window_get_show_border (XfcePanelWindow *window, + gboolean *top_border, + gboolean *bottom_border, + gboolean *left_border, + gboolean *right_border) { XfcePanelWindowPrivate *priv; @@ -1135,6 +1158,8 @@ xfce_panel_window_get_show_border (XfcePanelWindow * window, *right_border = priv->right_border; } + + /** * xfce_panel_window_set_show_border * @window : #XfcePanelWindow @@ -1142,15 +1167,15 @@ xfce_panel_window_get_show_border (XfcePanelWindow * window, * @bottom_border: show bottom border * @left_border : show left border * @right_border : show right border - * + * * Set border visibility for the panel window. **/ void -xfce_panel_window_set_show_border (XfcePanelWindow * window, - gboolean top_border, - gboolean bottom_border, - gboolean left_border, - gboolean right_border) +xfce_panel_window_set_show_border (XfcePanelWindow *window, + gboolean top_border, + gboolean bottom_border, + gboolean left_border, + gboolean right_border) { XfcePanelWindowPrivate *priv; @@ -1172,18 +1197,20 @@ xfce_panel_window_set_show_border (XfcePanelWindow * window, } } + + /** * xfce_panel_window_set_move_function * @window : #XfcePanelWindow * @function: #XfcePanelWindowMoveFunc * @data : user data - * + * * Set a function to modify move behaviour of the panel window. **/ void -xfce_panel_window_set_move_function (XfcePanelWindow * window, - XfcePanelWindowMoveFunc function, - gpointer data) +xfce_panel_window_set_move_function (XfcePanelWindow *window, + XfcePanelWindowMoveFunc function, + gpointer data) { XfcePanelWindowPrivate *priv; @@ -1195,18 +1222,20 @@ xfce_panel_window_set_move_function (XfcePanelWindow * window, priv->move_data = data; } + + /** * xfce_panel_window_set_resize_function * @window : #XfcePanelWindow * @function: #XfcePanelWindowResizeFunc * @data : user data - * + * * Set a function to modify resize behaviour of the panel window. **/ void -xfce_panel_window_set_resize_function (XfcePanelWindow * window, - XfcePanelWindowResizeFunc function, - gpointer data) +xfce_panel_window_set_resize_function (XfcePanelWindow *window, + XfcePanelWindowResizeFunc function, + gpointer data) { XfcePanelWindowPrivate *priv; @@ -1218,6 +1247,8 @@ xfce_panel_window_set_resize_function (XfcePanelWindow * window, priv->resize_data = data; } + + /** * xfce_panel_window_get_movable * @window : #XfcePanelWindow @@ -1228,7 +1259,7 @@ xfce_panel_window_set_resize_function (XfcePanelWindow * window, * Returns: %TRUE if the user is allowed to move @window, %FALSE if not. **/ gboolean -xfce_panel_window_get_movable (XfcePanelWindow * window) +xfce_panel_window_get_movable (XfcePanelWindow *window) { XfcePanelWindowPrivate *priv; @@ -1239,6 +1270,8 @@ xfce_panel_window_get_movable (XfcePanelWindow * window) return priv->movable; } + + /** * xfce_panel_window_set_movable * @window : #XfcePanelWindow @@ -1247,7 +1280,8 @@ xfce_panel_window_get_movable (XfcePanelWindow * window) * Set if the panel window can be moved by the user. **/ void -xfce_panel_window_set_movable (XfcePanelWindow * window, gboolean movable) +xfce_panel_window_set_movable (XfcePanelWindow *window, + gboolean movable) { XfcePanelWindowPrivate *priv; diff --git a/libxfce4panel/xfce-panel-window.h b/libxfce4panel/xfce-panel-window.h index b6615456a..4156b50ef 100644 --- a/libxfce4panel/xfce-panel-window.h +++ b/libxfce4panel/xfce-panel-window.h @@ -1,30 +1,34 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2004-2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2004-2007 Jasper Huijsmans <jasper@xfce.org> * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_PANEL_WINDOW_H -#define _XFCE_PANEL_WINDOW_H +#ifndef __XFCE_PANEL_WINDOW_H__ +#define __XFCE_PANEL_WINDOW_H__ #include <gtk/gtkenums.h> #include <gtk/gtkwindow.h> +G_BEGIN_DECLS + +typedef struct _XfcePanelWindow XfcePanelWindow; +typedef struct _XfcePanelWindowClass XfcePanelWindowClass; + #define XFCE_TYPE_PANEL_WINDOW (xfce_panel_window_get_type ()) #define XFCE_PANEL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_PANEL_WINDOW, XfcePanelWindow)) #define XFCE_PANEL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_PANEL_WINDOW, XfcePanelWindowClass)) @@ -32,9 +36,6 @@ #define XFCE_IS_PANEL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_PANEL_WINDOW)) #define XFCE_PANEL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_PANEL_WINDOW, XfcePanelWindowClass)) - -G_BEGIN_DECLS - /** * XfceHandleStyle * @XFCE_HANDLE_STYLE_NONE : No handles. @@ -53,11 +54,6 @@ typedef enum /*<enum,prefix=XFCE_HANDLE_STYLE >*/ } XfceHandleStyle; - -typedef struct _XfcePanelWindow XfcePanelWindow; -typedef struct _XfcePanelWindowClass XfcePanelWindowClass; - - /** * XfcePanelWindowMoveFunc * @widget : The #XfcePanelWindow widget @@ -69,10 +65,10 @@ typedef struct _XfcePanelWindowClass XfcePanelWindowClass; * #XfcePanelWindow. The function should modify @x and @y to set the new * position. **/ -typedef void (*XfcePanelWindowMoveFunc) (GtkWidget * widget, - gpointer data, - int *x, - int *y); +typedef void (*XfcePanelWindowMoveFunc) (GtkWidget *widget, + gpointer data, + gint *x, + gint *y); /** * XfcePanelWindowResizeFunc @@ -84,15 +80,15 @@ typedef void (*XfcePanelWindowMoveFunc) (GtkWidget * widget, * @y : location of the new y coordinate * * Callback function that can be used to adjust the position of the - * #XfcePanelWindow when its size changes. The function should modify @x + * #XfcePanelWindow when its size changes. The function should modify @x * and @y to set the new position. **/ -typedef void (*XfcePanelWindowResizeFunc) (GtkWidget * widget, - gpointer data, - GtkAllocation * previous, - GtkAllocation * allocation, - int *x, - int *y); +typedef void (*XfcePanelWindowResizeFunc) (GtkWidget *widget, + gpointer data, + GtkAllocation *previous, + GtkAllocation *allocation, + gint *x, + gint *y); struct _XfcePanelWindow { @@ -104,70 +100,50 @@ struct _XfcePanelWindowClass GtkWindowClass parent_class; /* signals */ - void (*orientation_changed) (GtkWidget * widget, - GtkOrientation orientation); - - void (*move_start) (GtkWidget * widget); - - void (*move) (GtkWidget * widget, - gint new_x, - gint new_y); - - void (*move_end) (GtkWidget * widget, - gint new_x, - gint new_y); - - /* Padding for future expansion */ - void (*_xfce_reserved1) (void); - void (*_xfce_reserved2) (void); - void (*_xfce_reserved3) (void); + void (*orientation_changed) (GtkWidget *widget, + GtkOrientation orientation); + void (*move_start) (GtkWidget *widget); + void (*move) (GtkWidget *widget, + gint new_x, + gint new_y); + void (*move_end) (GtkWidget *widget, + gint new_x, + gint new_y); + + /* reserved for future expansion */ + void (*reserved1) (void); + void (*reserved2) (void); + void (*reserved3) (void); }; - -GType xfce_panel_window_get_type (void) G_GNUC_CONST; - -GtkWidget *xfce_panel_window_new (void); - - -void xfce_panel_window_set_orientation (XfcePanelWindow * window, - GtkOrientation orientation); - -GtkOrientation xfce_panel_window_get_orientation (XfcePanelWindow * window); - - -void xfce_panel_window_set_handle_style (XfcePanelWindow * window, - XfceHandleStyle handle_style); - -XfceHandleStyle xfce_panel_window_get_handle_style (XfcePanelWindow * window); - - -void xfce_panel_window_set_show_border (XfcePanelWindow * window, - gboolean top_border, - gboolean bottom_border, - gboolean left_border, - gboolean right_border); - -void xfce_panel_window_get_show_border (XfcePanelWindow * window, - gboolean * top_border, - gboolean * bottom_border, - gboolean * left_border, - gboolean * right_border); - - -void xfce_panel_window_set_resize_function (XfcePanelWindow * window, - XfcePanelWindowResizeFunc function, - gpointer data); - -void xfce_panel_window_set_move_function (XfcePanelWindow * window, - XfcePanelWindowMoveFunc function, - gpointer data); - - -void xfce_panel_window_set_movable (XfcePanelWindow * window, - gboolean movable); - -gboolean xfce_panel_window_get_movable (XfcePanelWindow * window); +GType xfce_panel_window_get_type (void) G_GNUC_CONST; +GtkWidget *xfce_panel_window_new (void) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +void xfce_panel_window_set_orientation (XfcePanelWindow *window, + GtkOrientation orientation); +GtkOrientation xfce_panel_window_get_orientation (XfcePanelWindow *window); +void xfce_panel_window_set_handle_style (XfcePanelWindow *window, + XfceHandleStyle handle_style); +XfceHandleStyle xfce_panel_window_get_handle_style (XfcePanelWindow *window); +void xfce_panel_window_set_show_border (XfcePanelWindow *window, + gboolean top_border, + gboolean bottom_border, + gboolean left_border, + gboolean right_border); +void xfce_panel_window_get_show_border (XfcePanelWindow *window, + gboolean *top_border, + gboolean *bottom_border, + gboolean *left_border, + gboolean *right_border); +void xfce_panel_window_set_resize_function (XfcePanelWindow *window, + XfcePanelWindowResizeFunc function, + gpointer data); +void xfce_panel_window_set_move_function (XfcePanelWindow *window, + XfcePanelWindowMoveFunc function, + gpointer data); +void xfce_panel_window_set_movable (XfcePanelWindow *window, + gboolean movable); +gboolean xfce_panel_window_get_movable (XfcePanelWindow *window); G_END_DECLS -#endif /* _XFCE_PANEL_WINDOW_H */ +#endif /* !__XFCE_PANEL_WINDOW_H__ */ diff --git a/mcs-plugin/Makefile.am b/mcs-plugin/Makefile.am index 9003e0eb9..e0348e5f9 100644 --- a/mcs-plugin/Makefile.am +++ b/mcs-plugin/Makefile.am @@ -19,7 +19,7 @@ plugin_LTLIBRARIES = \ libxfce4settings.la libxfce4settings_la_SOURCES = \ - mcs_plugin.c + plugin.c libxfce4settings_la_CFLAGS = \ $(LIBXFCEGUI4_CFLAGS) \ diff --git a/mcs-plugin/plugin.c b/mcs-plugin/plugin.c index 043099238..daf7d6464 100644 --- a/mcs-plugin/plugin.c +++ b/mcs-plugin/plugin.c @@ -1,59 +1,75 @@ -/* vim: set expandtab ts=8 sw=4: */ - -/* $Id$ +/* $Id$ * - * Copyright © 2006 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2006 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2006 Nick Schermer <nick@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 library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This 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. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. * - * You should have received a copy of the GNU 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. + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include <config.h> #endif -#include <glib.h> -#include <xfce-mcs-manager/manager-plugin.h> #include <libxfcegui4/libxfcegui4.h> -#include <libxfce4mcs/mcs-common.h> -#include <libxfce4mcs/mcs-manager.h> - -static void run_dialog (McsPlugin * mcs_plugin); +#include <xfce-mcs-manager/manager-plugin.h> -/* plugin init */ -McsPluginInitResult -mcs_plugin_init (McsPlugin * mcs_plugin) +static void +run_dialog (McsPlugin *plugin) { - /* - This is required for UTF-8 at least - Please don't remove it - And it needs to be done here for the label to be properly - localized.... - */ - xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); - - mcs_plugin->plugin_name = g_strdup ("xfce4panel"); - mcs_plugin->caption = g_strdup (_("Panel")); - mcs_plugin->run_dialog = run_dialog; - mcs_plugin->icon = xfce_themed_icon_load ("xfce4-panel", 48); - - return (MCS_PLUGIN_INIT_OK); + GtkWidget *message; + GError *error = NULL; + gchar *argv[] = { BINDIR G_DIR_SEPARATOR_S "xfce4-panel", "-c", NULL }; + + if (!g_spawn_async (NULL, argv, NULL, 0, NULL, NULL, NULL, &error)) + { + message = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, + "%s.", _("Failed to launch 'xfce4-panel -c'")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message), "%s.", error->message); + gtk_dialog_run (GTK_DIALOG (message)); + gtk_widget_destroy (message); + g_error_free (error); + } } -/* settings dialog */ -static void -run_dialog (McsPlugin * mcs_plugin) +McsPluginInitResult +mcs_plugin_init (McsPlugin *plugin) { - g_spawn_command_line_async("xfce4-panel -c", NULL); + GtkIconTheme *icon_theme; + + /* setup i18n support */ + xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); + + /* initialize plugin structure */ + plugin->plugin_name = g_strdup ("xfce4panel"); + plugin->caption = g_strdup (_("Panel")); + plugin->run_dialog = run_dialog; + + /* lookup the icon (on the default icon theme, *sigh*) */ + icon_theme = gtk_icon_theme_get_default (); + plugin->icon = gtk_icon_theme_load_icon (icon_theme, "xfce4-panel", 48, 0, NULL); + + /* if that didn't work, we know where we installed the icon, so load it directly */ + if (G_UNLIKELY (plugin->icon == NULL)) + plugin->icon = gdk_pixbuf_new_from_file (DATADIR "/icons/hicolor/48x48/apps/xfce4-panel.png", NULL); + + /* attach icon name to the plugin icon (if any) */ + if (G_LIKELY (plugin->icon != NULL)) + g_object_set_data_full (G_OBJECT (plugin->icon), "mcs-plugin-icon-name", g_strdup ("xfce4-panel"), g_free); + + return MCS_PLUGIN_INIT_OK; } +MCS_PLUGIN_CHECK_INIT; diff --git a/panel/Makefile.am b/panel/Makefile.am index 04f85dbfd..1e946ae07 100644 --- a/panel/Makefile.am +++ b/panel/Makefile.am @@ -1,60 +1,73 @@ -# dummy scripts to replace 4.2 versions -bin_SCRIPTS = @DUMMY_SCRIPTS@ - -EXTRA_SCRIPTS = xftaskbar4 xfce4-iconbox -EXTRA_DIST = $(EXTRA_SCRIPTS) - -bin_PROGRAMS = xfce4-panel - -xfce4_panel_SOURCES = \ - frap-icon-entry.c \ - frap-icon-entry.h \ - main.c \ - panel-app.c \ - panel-app.h \ - panel-app-messages.c \ - panel-app-messages.h \ - panel-config.c \ - panel-config.h \ - panel-dnd.c \ - panel-dnd.h \ - panel-item-manager.c \ - panel-item-manager.h \ - panel-properties.c \ - panel-properties.h \ - panel-dialogs.c \ - panel-dialogs.h \ - panel.c \ - panel-private.h \ - panel.h - - -xfce4_panel_CFLAGS = \ - -I$(top_srcdir) \ - @LIBSTARTUP_NOTIFICATION_CFLAGS@ \ - @LIBX11_CFLAGS@ \ - @LIBXFCE4UTIL_CFLAGS@ \ - @LIBXFCEGUI4_CFLAGS@ \ - -DDATADIR=\"$(datadir)\" \ - -DLIBDIR=\"$(libdir)/xfce4\" \ - -DLIBEXECDIR=\"$(libexecdir)/xfce4\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DLOCALEDIR=\"$(localedir)\" - -xfce4_panel_LDFLAGS = \ - -export-dynamic - -if HAVE_CYGWIN -xfce4_panel_LDFLAGS += -no-undefined -endif +# $Id$ + +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + -DG_LOG_DOMAIN=\"xfce4-panel\" \ + -DDATADIR=\"$(datadir)\" \ + -DLIBDIR=\"$(libdir)/xfce4\" \ + -DLIBEXECDIR=\"$(libexecdir)/xfce4\" \ + -DSYSCONFDIR=\"$(sysconfdir)\" \ + -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \ + $(PLATFORM_CPPFLAGS) + +bin_PROGRAMS = \ + xfce4-panel + +xfce4_panel_SOURCES = \ + main.c \ + panel.c \ + panel.h \ + panel-app.c \ + panel-app.h \ + panel-app-messages.c \ + panel-app-messages.h \ + panel-config.c \ + panel-config.h \ + panel-dnd.c \ + panel-dnd.h \ + panel-item-manager.c \ + panel-item-manager.h \ + panel-private.h \ + panel-properties.c \ + panel-properties.h \ + panel-dialogs.c \ + panel-dialogs.h \ + frap-icon-entry.c \ + frap-icon-entry.h + +xfce4_panel_CFLAGS = \ + $(LIBX11_CFLAGS) \ + $(LIBSTARTUP_NOTIFICATION_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCEGUI4_CFLAGS) \ + $(PLATFORM_CFLAGS) -xfce4_panel_LDADD = \ - ../libxfce4panel/libxfce4panel.la \ - @LIBSTARTUP_NOTIFICATION_LIBS@ \ - @LIBX11_LIBS@ \ - @LIBXFCE4UTIL_LIBS@ \ - @LIBXFCEGUI4_LIBS@ +xfce4_panel_LDFLAGS = \ + -no-undefined \ + $(PLATFORM_LDFLAGS) -xfce4_panel_DEPENDENCIES = \ - ../libxfce4panel/libxfce4panel.la +xfce4_panel_LDADD = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la \ + $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCEGUI4_LIBS) \ + $(LIBSTARTUP_NOTIFICATION_LIBS) \ + $(LIBX11_LIBS) + +xfce4_panel_DEPENDENCIES = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la + +# +# Dummy Scripts +# +if ENABLE_DUMMY_SCRIPTS +bin_SCRIPTS = \ + xftaskbar4 \ + xfce4-iconbox + +EXTRA_DIST = \ + xftaskbar4 \ + xfce4-iconbox +endif +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/panel/main.c b/panel/main.c index 614b7916c..1431e143b 100644 --- a/panel/main.c +++ b/panel/main.c @@ -5,7 +5,7 @@ * Copyright © 2005 Jasper Huijsmans <jasper@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 + * 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. * @@ -74,7 +74,7 @@ handle_options (int argc, char **argv, int *success) if (argc > 1 && argv[1][0] == '-') { /* help / version */ - if (!strcmp (argv[1], "-h") || + if (!strcmp (argv[1], "-h") || !strcmp (argv[1], "-v") || !strcmp (argv[1], "--help") || !strcmp (argv[1], "--version")) @@ -86,7 +86,7 @@ handle_options (int argc, char **argv, int *success) else { int msg = -1; - + if (!strcmp (argv[1], "-c") || !strcmp (argv[1], "--customize")) { @@ -131,7 +131,7 @@ handle_options (int argc, char **argv, int *success) } } } - + return handled; } @@ -141,18 +141,18 @@ int main (int argc, char **argv) { int success = 0; - - xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); - + + xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); + if (handle_options (argc, argv, &success)) exit (success); TIMER_ELAPSED("start gtk_init()"); gtk_init (&argc, &argv); - + TIMER_ELAPSED("start panel_init()"); success = panel_app_init (); - + if (success == -1) { return 1; @@ -165,7 +165,7 @@ main (int argc, char **argv) TIMER_ELAPSED("start panel_app_run()"); success = panel_app_run (argc, argv); - + if (success == 1) { /* restart */ diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 0a295669e..c5fe4a9f0 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -1,11 +1,15 @@ -SUBDIRS = \ - actions \ - clock \ - iconbox \ - launcher \ - pager \ - separator \ - showdesktop \ - systray \ - tasklist \ +# $Id$ + +SUBDIRS = \ + actions \ + clock \ + iconbox \ + launcher \ + pager \ + separator \ + showdesktop \ + systray \ + tasklist \ windowlist + +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/plugins/actions/Makefile.am b/plugins/actions/Makefile.am index c648dbe1a..c7fdcf3ef 100644 --- a/plugins/actions/Makefile.am +++ b/plugins/actions/Makefile.am @@ -1,45 +1,60 @@ -plugindir = $(libdir)/xfce4/panel-plugins +# $Id$ -plugin_LTLIBRARIES = libactions.la +INCLUDES = \ + -I$(top_srcdir) \ + -DG_LOG_DOMAIN=\"libactions\" \ + -DLOCALEDIR=\"$(localedir)\" \ + $(PLATFORM_CPPFLAGS) -libactions_la_LDFLAGS = \ - -avoid-version \ - -module +plugindir = \ + $(libdir)/xfce4/panel-plugins + +plugin_LTLIBRARIES = \ + libactions.la libactions_la_SOURCES = \ actions.c libactions_la_CFLAGS = \ - -I$(top_srcdir) \ - @LIBXFCEGUI4_CFLAGS@ \ - -DLOCALEDIR=\"$(localedir)\" + $(GTK_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCEGUI4_CFLAGS) \ + $(PLATFORM_CFLAGS) -libactions_la_LIBADD = \ - ../../libxfce4panel/libxfce4panel.la \ - @LIBS@ +libactions_la_LDFLAGS = \ + -avoid-version \ + -module \ + $(PLATFORM_LDFLAGS) -libactions_la_DEPENDENCIES = \ - ../../libxfce4panel/libxfce4panel.la - if HAVE_CYGWIN -libactions_la_LDFLAGS += \ - -no-undefined \ - @LIBX11_LDFLAGS@ \ - @LIBXFCEGUI4_LIBS@ \ - @LIBX11_LIBS@ +libactions_la_LDFLAGS += \ + -no-undefined endif +libactions_la_LIBADD = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la \ + $(GTK_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCEGUI4_LIBS) + +libactions_la_DEPENDENCIES = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la + +# # .desktop file # -# Some automake trickery here. Because we cannot use $(libexecdir) in the -# automake stage, we'll use sed to get the full path into the .desktop file. -# We also need to let intltool merge the translated fields, so we add an -# additional level of indirection: a <name>.desktop.in.in file. -# -desktop_in_in_files = actions.desktop.in.in -desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in) - -desktopdir = $(datadir)/xfce4/panel-plugins +desktopdir = \ + $(datadir)/xfce4/panel-plugins + +desktop_in_in_files = \ + actions.desktop.in.in + +desktop_in_files = \ + $(desktop_in_in_files:.desktop.in.in=.desktop.in) + +%.desktop.in: %.desktop.in.in + sed -e "s,\@libdir\@,$(libdir),g" < $< > $@ + desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) @INTLTOOL_DESKTOP_RULE@ @@ -47,12 +62,7 @@ EXTRA_DIST = \ $(desktop_in_in_files) DISTCLEANFILES = \ - $(desktop_DATA) $(desktop_in_files) - -# get full path into .desktop file -%.desktop.in: %.desktop.in.in $(plugin_LTLIBRARIES) - plugin_name=`grep dlname= $(plugin_LTLIBRARIES) | sed "s/dlname='\(.*\)'/\1/"`; \ - sed -e "s^@INTERNAL_PLUGIN_PATH@^$(libdir)/xfce4/panel-plugins^" \ - -e "s^@PLUGIN_NAME@^$$plugin_name^" \ - $< > $@ + $(desktop_DATA) \ + $(desktop_in_files) +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/plugins/actions/actions.c b/plugins/actions/actions.c index 7ac3f65c4..313db1530 100644 --- a/plugins/actions/actions.c +++ b/plugins/actions/actions.c @@ -5,7 +5,7 @@ * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published + * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * @@ -45,7 +45,7 @@ typedef struct { XfcePanelPlugin *plugin; GtkTooltips *tips; - + ActionType type; GtkWidget *button1; GtkWidget *image1; @@ -73,13 +73,13 @@ XFCE_PANEL_PLUGIN_REGISTER_INTERNAL (actions_construct); /* Interface Implementation */ static void -actions_orientation_changed (XfcePanelPlugin *plugin, +actions_orientation_changed (XfcePanelPlugin *plugin, GtkOrientation orientation, Action *action) { if (action->type == ACTION_QUIT_LOCK) { - xfce_hvbox_set_orientation (XFCE_HVBOX (GTK_BIN (plugin)->child), + xfce_hvbox_set_orientation (XFCE_HVBOX (GTK_BIN (plugin)->child), (orientation == GTK_ORIENTATION_HORIZONTAL) ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL); } @@ -94,10 +94,10 @@ static GdkPixbuf * actions_load_icon (ActionType type, int size) { GdkPixbuf *pb = NULL; - + /* first try name from icon nameing spec... */ pb = xfce_themed_icon_load (action_icon_names[type][1], size); - + /* ...then try xfce name, if necessary */ if (!pb) { @@ -107,13 +107,13 @@ actions_load_icon (ActionType type, int size) return pb; } -static gboolean +static gboolean actions_set_size (XfcePanelPlugin *plugin, int size, Action *action) { int width; GdkPixbuf *pb = NULL; int border; - + if (xfce_panel_plugin_get_orientation (plugin) == GTK_ORIENTATION_HORIZONTAL) { @@ -123,7 +123,7 @@ actions_set_size (XfcePanelPlugin *plugin, int size, Action *action) { border = 2 + 2 * GTK_WIDGET(plugin)->style->xthickness; } - + switch (action->type) { case ACTION_QUIT_LOCK: @@ -131,11 +131,11 @@ actions_set_size (XfcePanelPlugin *plugin, int size, Action *action) pb = actions_load_icon (ACTION_LOCK, width); gtk_image_set_from_pixbuf (GTK_IMAGE (action->image1), pb); g_object_unref (G_OBJECT (pb)); - + pb = actions_load_icon (ACTION_QUIT, width); gtk_image_set_from_pixbuf (GTK_IMAGE (action->image2), pb); g_object_unref (G_OBJECT (pb)); - + break; case ACTION_QUIT: case ACTION_LOCK: @@ -143,10 +143,10 @@ actions_set_size (XfcePanelPlugin *plugin, int size, Action *action) pb = actions_load_icon (action->type, width); gtk_image_set_from_pixbuf (GTK_IMAGE (action->image1), pb); g_object_unref (G_OBJECT (pb)); - + break; } - + return TRUE; } @@ -156,7 +156,7 @@ actions_read_rc_file (XfcePanelPlugin *plugin, Action *action) char *file; XfceRc *rc; int type = ACTION_QUIT; - + if ((file = xfce_panel_plugin_lookup_rc_file (plugin)) != NULL) { rc = xfce_rc_simple_open (file, TRUE); @@ -165,7 +165,7 @@ actions_read_rc_file (XfcePanelPlugin *plugin, Action *action) if (rc != NULL) { type = xfce_rc_read_int_entry (rc, "type", ACTION_QUIT); - + xfce_rc_close (rc); } } @@ -178,7 +178,7 @@ actions_write_rc_file (XfcePanelPlugin *plugin, Action *action) { char *file; XfceRc *rc; - + if (!(file = xfce_panel_plugin_save_location (plugin, TRUE))) return; @@ -187,7 +187,7 @@ actions_write_rc_file (XfcePanelPlugin *plugin, Action *action) if (!rc) return; - + xfce_rc_write_int_entry (rc, "type", action->type); xfce_rc_close (rc); @@ -200,10 +200,10 @@ actions_free_data (XfcePanelPlugin *plugin, Action *action) if (action->screen_id) g_signal_handler_disconnect (plugin, action->screen_id); - + if (action->style_id) g_signal_handler_disconnect (plugin, action->style_id); - + action->screen_id = action->style_id = 0; dlg = g_object_get_data (G_OBJECT (plugin), "dialog"); @@ -234,15 +234,15 @@ actions_create_widgets (XfcePanelPlugin *plugin, Action *action) { GtkWidget *widget, *box, *button, *img; GtkOrientation orientation; - + widget = GTK_WIDGET (plugin); switch (action->type) { case ACTION_QUIT_LOCK: - orientation = (xfce_panel_plugin_get_orientation (plugin) == + orientation = (xfce_panel_plugin_get_orientation (plugin) == GTK_ORIENTATION_HORIZONTAL) ? - GTK_ORIENTATION_VERTICAL : + GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL; box = xfce_hvbox_new (orientation, TRUE, 0); @@ -254,29 +254,29 @@ actions_create_widgets (XfcePanelPlugin *plugin, Action *action) gtk_box_pack_start (GTK_BOX (box), button, TRUE, TRUE, 0); xfce_panel_plugin_add_action_widget (plugin, button); - - g_signal_connect (button, "clicked", + + g_signal_connect (button, "clicked", G_CALLBACK (actions_do_lock), plugin); - + gtk_tooltips_set_tip (action->tips, action->button1, _("Lock screen"), NULL); img = action->image1 = gtk_image_new (); gtk_widget_show (img); gtk_container_add (GTK_CONTAINER (button), img); - + action->button2 = button = xfce_create_panel_button (); gtk_widget_show (button); gtk_box_pack_start (GTK_BOX (box), button, TRUE, TRUE, 0); xfce_panel_plugin_add_action_widget (plugin, button); - g_signal_connect (button, "clicked", + g_signal_connect (button, "clicked", G_CALLBACK (actions_do_quit), plugin); - + img = action->image2 = gtk_image_new (); gtk_widget_show (img); gtk_container_add (GTK_CONTAINER (button), img); - + gtk_tooltips_set_tip (action->tips, action->button2, _("Quit"), NULL); break; @@ -284,16 +284,16 @@ actions_create_widgets (XfcePanelPlugin *plugin, Action *action) action->button1 = button = xfce_create_panel_button (); gtk_widget_show (button); gtk_container_add (GTK_CONTAINER (plugin), button); - + xfce_panel_plugin_add_action_widget (plugin, button); - - g_signal_connect (button, "clicked", + + g_signal_connect (button, "clicked", G_CALLBACK (actions_do_lock), plugin); - + img = action->image1 = gtk_image_new (); gtk_widget_show (img); gtk_container_add (GTK_CONTAINER (button), img); - + gtk_tooltips_set_tip (action->tips, action->button1, _("Lock screen"), NULL); break; @@ -301,12 +301,12 @@ actions_create_widgets (XfcePanelPlugin *plugin, Action *action) action->button1 = button = xfce_create_panel_button (); gtk_widget_show (button); gtk_container_add (GTK_CONTAINER (plugin), button); - + xfce_panel_plugin_add_action_widget (plugin, button); - - g_signal_connect (button, "clicked", + + g_signal_connect (button, "clicked", G_CALLBACK (actions_do_quit), plugin); - + img = action->image1 = gtk_image_new (); gtk_widget_show (img); gtk_container_add (GTK_CONTAINER (button), img); @@ -322,7 +322,7 @@ actions_icontheme_changed (XfcePanelPlugin *plugin, gpointer ignored, actions_set_size (plugin, xfce_panel_plugin_get_size (plugin), action); } -static void +static void actions_construct (XfcePanelPlugin *plugin) { Action *action = panel_slice_new0 (Action); @@ -330,33 +330,33 @@ actions_construct (XfcePanelPlugin *plugin) action->plugin = plugin; action->tips = gtk_tooltips_new(); - - g_signal_connect (plugin, "orientation-changed", + + g_signal_connect (plugin, "orientation-changed", G_CALLBACK (actions_orientation_changed), action); - - g_signal_connect (plugin, "size-changed", + + g_signal_connect (plugin, "size-changed", G_CALLBACK (actions_set_size), action); - - g_signal_connect (plugin, "save", + + g_signal_connect (plugin, "save", G_CALLBACK (actions_write_rc_file), action); - - g_signal_connect (plugin, "free-data", + + g_signal_connect (plugin, "free-data", G_CALLBACK (actions_free_data), action); - + xfce_panel_plugin_menu_show_configure (plugin); - g_signal_connect (plugin, "configure-plugin", + g_signal_connect (plugin, "configure-plugin", G_CALLBACK (actions_properties_dialog), action); actions_read_rc_file (plugin, action); actions_create_widgets (plugin, action); - + action->style_id = - g_signal_connect (plugin, "style-set", + g_signal_connect (plugin, "style-set", G_CALLBACK (actions_icontheme_changed), action); - + action->screen_id = - g_signal_connect (plugin, "screen-changed", + g_signal_connect (plugin, "screen-changed", G_CALLBACK (actions_icontheme_changed), action); } @@ -372,7 +372,7 @@ action_type_changed (GtkComboBox *box, Action *action) gtk_widget_destroy (GTK_BIN (action->plugin)->child); actions_create_widgets (action->plugin, action); - actions_set_size (action->plugin, + actions_set_size (action->plugin, xfce_panel_plugin_get_size (action->plugin), action); } @@ -392,25 +392,25 @@ actions_properties_dialog (XfcePanelPlugin *plugin, Action *action) GtkWidget *dlg, *vbox, *hbox, *label, *box; xfce_panel_plugin_block_menu (plugin); - + dlg = xfce_titled_dialog_new_with_buttons (_("Panel Actions"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); - gtk_window_set_screen (GTK_WINDOW (dlg), + gtk_window_set_screen (GTK_WINDOW (dlg), gtk_widget_get_screen (GTK_WIDGET (plugin))); g_object_set_data (G_OBJECT (plugin), "dialog", dlg); gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER); gtk_window_set_icon_name (GTK_WINDOW (dlg), "xfce4-settings"); - + g_signal_connect (dlg, "response", G_CALLBACK (actions_dialog_response), action); gtk_container_set_border_width (GTK_CONTAINER (dlg), 2); - + vbox = gtk_vbox_new (FALSE, 8); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); gtk_widget_show (vbox); @@ -428,16 +428,16 @@ actions_properties_dialog (XfcePanelPlugin *plugin, Action *action) box = gtk_combo_box_new_text (); gtk_widget_show (box); gtk_box_pack_start (GTK_BOX (hbox), box, TRUE, TRUE, 0); - + gtk_combo_box_append_text (GTK_COMBO_BOX (box), _("Quit")); gtk_combo_box_append_text (GTK_COMBO_BOX (box), _("Lock screen")); gtk_combo_box_append_text (GTK_COMBO_BOX (box), _("Quit + Lock screen")); - + gtk_combo_box_set_active (GTK_COMBO_BOX (box), action->type); - - g_signal_connect (box, "changed", G_CALLBACK (action_type_changed), + + g_signal_connect (box, "changed", G_CALLBACK (action_type_changed), action); - + gtk_widget_show (dlg); } diff --git a/plugins/actions/actions.desktop.in.in b/plugins/actions/actions.desktop.in.in index b2490ba58..83e16dacb 100644 --- a/plugins/actions/actions.desktop.in.in +++ b/plugins/actions/actions.desktop.in.in @@ -5,5 +5,5 @@ _Name=Action Buttons _Comment=Log out or lock the screen Icon=xfce-system-exit X-XFCE-Module=actions -X-XFCE-Module-Path=@INTERNAL_PLUGIN_PATH@ +X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins diff --git a/plugins/clock/Makefile.am b/plugins/clock/Makefile.am index 2e9b85561..a2a084176 100644 --- a/plugins/clock/Makefile.am +++ b/plugins/clock/Makefile.am @@ -1,45 +1,60 @@ -plugindir = $(libdir)/xfce4/panel-plugins +# $Id$ -plugin_LTLIBRARIES = libclock.la +INCLUDES = \ + -I$(top_srcdir) \ + -DG_LOG_DOMAIN=\"libclock\" \ + -DLOCALEDIR=\"$(localedir)\" \ + $(PLATFORM_CPPFLAGS) -libclock_la_LDFLAGS = \ - -avoid-version \ - -module +plugindir = \ + $(libdir)/xfce4/panel-plugins + +plugin_LTLIBRARIES = \ + libclock.la libclock_la_SOURCES = \ clock.c libclock_la_CFLAGS = \ - -I$(top_srcdir) \ - @LIBXFCEGUI4_CFLAGS@ \ - -DLOCALEDIR=\"$(localedir)\" + $(GTK_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCEGUI4_CFLAGS) \ + $(PLATFORM_CFLAGS) -libclock_la_LIBADD = \ - ../../libxfce4panel/libxfce4panel.la \ - @LIBS@ +libclock_la_LDFLAGS = \ + -avoid-version \ + -module \ + $(PLATFORM_LDFLAGS) -libclock_la_DEPENDENCIES = \ - ../../libxfce4panel/libxfce4panel.la - if HAVE_CYGWIN -libclock_la_LDFLAGS += \ - -no-undefined \ - @LIBX11_LDFLAGS@ \ - @LIBXFCEGUI4_LIBS@ \ - @LIBX11_LIBS@ +libclock_la_LDFLAGS += \ + -no-undefined endif +libclock_la_LIBADD = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la \ + $(GTK_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCEGUI4_LIBS) + +libclock_la_DEPENDENCIES = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la + +# # .desktop file # -# Some automake trickery here. Because we cannot use $(libexecdir) in the -# automake stage, we'll use sed to get the full path into the .desktop file. -# We also need to let intltool merge the translated fields, so we add an -# additional level of indirection: a <name>.desktop.in.in file. -# -desktop_in_in_files = clock.desktop.in.in -desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in) - -desktopdir = $(datadir)/xfce4/panel-plugins +desktopdir = \ + $(datadir)/xfce4/panel-plugins + +desktop_in_in_files = \ + clock.desktop.in.in + +desktop_in_files = \ + $(desktop_in_in_files:.desktop.in.in=.desktop.in) + +%.desktop.in: %.desktop.in.in + sed -e "s,\@libdir\@,$(libdir),g" < $< > $@ + desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) @INTLTOOL_DESKTOP_RULE@ @@ -47,12 +62,7 @@ EXTRA_DIST = \ $(desktop_in_in_files) DISTCLEANFILES = \ - $(desktop_DATA) $(desktop_in_files) - -# get full path into .desktop file -%.desktop.in: %.desktop.in.in $(plugin_LTLIBRARIES) - plugin_name=`grep dlname= $(plugin_LTLIBRARIES) | sed "s/dlname='\(.*\)'/\1/"`; \ - sed -e "s^@INTERNAL_PLUGIN_PATH@^$(libdir)/xfce4/panel-plugins^" \ - -e "s^@PLUGIN_NAME@^$$plugin_name^" \ - $< > $@ + $(desktop_DATA) \ + $(desktop_in_files) +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/plugins/clock/clock.c b/plugins/clock/clock.c index fe1c83d9a..7896b94ef 100644 --- a/plugins/clock/clock.c +++ b/plugins/clock/clock.c @@ -5,7 +5,7 @@ * Copyright © 2005 The Xfce Development Team * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published + * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * @@ -76,7 +76,7 @@ Clock; typedef struct { Clock *clock; - + GtkWidget *cb_mode; GtkWidget *cb_frame; GtkWidget *cb_military; @@ -85,7 +85,7 @@ typedef struct } ClockDialog; -static void clock_properties_dialog (XfcePanelPlugin *plugin, +static void clock_properties_dialog (XfcePanelPlugin *plugin, Clock *clock); static void clock_construct (XfcePanelPlugin *plugin); @@ -95,7 +95,7 @@ static void clock_construct (XfcePanelPlugin *plugin); * Clock * * -------------------------------------------------------------------- */ -static gboolean +static gboolean clock_date_tooltip (Clock *clock) { time_t ticks; @@ -124,23 +124,23 @@ clock_date_tooltip (Clock *clock) /* Conversion to utf8 * Patch by Oliver M. Bolzer <oliver@fakeroot.net> */ - if (!g_utf8_validate(date_s, -1, NULL)) + if (!g_utf8_validate(date_s, -1, NULL)) { utf8date = g_locale_to_utf8(date_s, -1, NULL, NULL, NULL); } if (utf8date) { - gtk_tooltips_set_tip (clock->tips, GTK_WIDGET (clock->plugin), + gtk_tooltips_set_tip (clock->tips, GTK_WIDGET (clock->plugin), utf8date, NULL); g_free (utf8date); } else { - gtk_tooltips_set_tip (clock->tips, GTK_WIDGET (clock->plugin), + gtk_tooltips_set_tip (clock->tips, GTK_WIDGET (clock->plugin), date_s, NULL); } - } + } return TRUE; } @@ -164,28 +164,28 @@ clock_update_size (Clock *clock, int size) gtk_container_set_border_width (GTK_CONTAINER (clock->frame), 0); size -= 1; } - - /* Replaced old 4-stage switch; Perhaps DIGIT_*_HEIGHT + + /* Replaced old 4-stage switch; Perhaps DIGIT_*_HEIGHT * should be moved from xfce_clock.c to xfce_clock.h so we * can use them here (e.g. 10*2 => DIGIT_SMALL_HEIGHT*2) * */ - if (xfce_panel_plugin_get_orientation (clock->plugin) + if (xfce_panel_plugin_get_orientation (clock->plugin) == GTK_ORIENTATION_HORIZONTAL) { if (size <= 10*2) { xfce_clock_set_led_size (clk, DIGIT_SMALL); } - else if (size <= 14*2) + else if (size <= 14*2) { xfce_clock_set_led_size (clk, DIGIT_MEDIUM); - } - else if (size <= 20*2) + } + else if (size <= 20*2) { xfce_clock_set_led_size (clk, DIGIT_LARGE); } - else + else { xfce_clock_set_led_size (clk, DIGIT_HUGE); } @@ -221,7 +221,7 @@ XFCE_PANEL_PLUGIN_REGISTER_INTERNAL (clock_construct); /* Interface Implementation */ -static gboolean +static gboolean clock_set_size (XfcePanelPlugin *plugin, int size, Clock *clock) { clock_update_size(clock, size); @@ -238,7 +238,7 @@ clock_free_data (XfcePanelPlugin *plugin, Clock *clock) gtk_widget_destroy (dlg); g_signal_handler_disconnect (plugin, clock->screen_changed_id); - + g_source_remove (clock->timeout_id); g_object_unref (G_OBJECT (clock->tips)); panel_slice_free (Clock, clock); @@ -257,7 +257,7 @@ clock_read_rc_file (XfcePanelPlugin *plugin, Clock* clock) ampm = FALSE; secs = FALSE; show_frame = FALSE; - + if ((file = xfce_panel_plugin_lookup_rc_file (plugin)) != NULL) { rc = xfce_rc_simple_open (file, TRUE); @@ -283,32 +283,13 @@ clock_read_rc_file (XfcePanelPlugin *plugin, Clock* clock) xfce_clock_show_military (XFCE_CLOCK (clock->clock), military); xfce_clock_show_ampm (XFCE_CLOCK (clock->clock), ampm); xfce_clock_show_secs (XFCE_CLOCK (clock->clock), secs); - + clock->show_frame = show_frame; - gtk_frame_set_shadow_type (GTK_FRAME (clock->frame), + gtk_frame_set_shadow_type (GTK_FRAME (clock->frame), show_frame ? GTK_SHADOW_IN : GTK_SHADOW_NONE); - - clock_update_size (clock, - xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (plugin))); -} - -static void -clock_screen_changed (GtkWidget *plugin, GdkScreen *screen, - Clock *clock) -{ - /* return when the widget is not visible (when moving the plugin) */ - if (GTK_IS_INVISIBLE (clock->clock) == FALSE) - return; - - gtk_widget_destroy (clock->clock); - - clock->clock = xfce_clock_new (); - gtk_widget_show (clock->clock); - gtk_container_add (GTK_CONTAINER (clock->frame), clock->clock); - xfce_clock_set_interval (XFCE_CLOCK (clock->clock), 1000); - - clock_read_rc_file (clock->plugin, clock); + clock_update_size (clock, + xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (plugin))); } static void @@ -316,7 +297,7 @@ clock_write_rc_file (XfcePanelPlugin *plugin, Clock *clock) { char *file; XfceRc *rc; - + if (!(file = xfce_panel_plugin_save_location (plugin, TRUE))) return; @@ -331,34 +312,53 @@ clock_write_rc_file (XfcePanelPlugin *plugin, Clock *clock) xfce_rc_write_bool_entry (rc, "ampm", clock->ampm); xfce_rc_write_bool_entry (rc, "secs", clock->secs); xfce_rc_write_bool_entry (rc, "show_frame", clock->show_frame); - + xfce_rc_close (rc); } +static void +clock_screen_changed (GtkWidget *plugin, GdkScreen *screen, + Clock *clock) +{ + /* return when the widget is not visible (when moving the plugin) */ + if (GTK_IS_INVISIBLE (clock->clock) == FALSE) + return; + + gtk_widget_destroy (clock->clock); + + clock->clock = xfce_clock_new (); + gtk_widget_show (clock->clock); + gtk_container_add (GTK_CONTAINER (clock->frame), clock->clock); + + xfce_clock_set_interval (XFCE_CLOCK (clock->clock), 1000); + + clock_read_rc_file (clock->plugin, clock); +} + /* Create widgets and connect to signals */ -static void +static void clock_construct (XfcePanelPlugin *plugin) { Clock *clock = panel_slice_new0 (Clock); clock->plugin = plugin; - g_signal_connect (plugin, "size-changed", + g_signal_connect (plugin, "size-changed", G_CALLBACK (clock_set_size), clock); - - g_signal_connect (plugin, "free-data", + + g_signal_connect (plugin, "free-data", G_CALLBACK (clock_free_data), clock); - - g_signal_connect (plugin, "save", + + g_signal_connect (plugin, "save", G_CALLBACK (clock_write_rc_file), clock); - + xfce_panel_plugin_menu_show_configure (plugin); - g_signal_connect (plugin, "configure-plugin", + g_signal_connect (plugin, "configure-plugin", G_CALLBACK (clock_properties_dialog), clock); - clock->screen_changed_id = - g_signal_connect (plugin, "screen-changed", + clock->screen_changed_id = + g_signal_connect (plugin, "screen-changed", G_CALLBACK (clock_screen_changed), clock); clock->frame = gtk_frame_new (NULL); @@ -372,14 +372,14 @@ clock_construct (XfcePanelPlugin *plugin) xfce_clock_set_interval (XFCE_CLOCK (clock->clock), 1000); clock_read_rc_file (plugin, clock); - + clock->tips = gtk_tooltips_new (); g_object_ref (G_OBJECT (clock->tips)); gtk_object_sink (GTK_OBJECT (clock->tips)); - + clock_date_tooltip (clock); - clock->timeout_id = + clock->timeout_id = g_timeout_add (60000, (GSourceFunc) clock_date_tooltip, clock); } @@ -398,7 +398,7 @@ clock_set_sensative (ClockDialog *cd) else { gtk_widget_set_sensitive (cd->cb_military, TRUE); - + if (cd->clock->military) gtk_widget_set_sensitive (cd->cb_ampm, FALSE); else @@ -410,7 +410,7 @@ static void clock_button_toggled (GtkWidget *cb, ClockDialog *cd) { gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cb)); - + if (cb == cd->cb_frame) { cd->clock->show_frame = active; @@ -422,7 +422,7 @@ clock_button_toggled (GtkWidget *cb, ClockDialog *cd) cd->clock->military = active; xfce_clock_show_military (XFCE_CLOCK (cd->clock->clock), active); - + clock_set_sensative (cd); } else if (cb == cd->cb_ampm) @@ -437,8 +437,8 @@ clock_button_toggled (GtkWidget *cb, ClockDialog *cd) xfce_clock_show_secs (XFCE_CLOCK (cd->clock->clock), active); } - - clock_update_size (cd->clock, + + clock_update_size (cd->clock, xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (cd->clock->plugin))); } @@ -447,15 +447,15 @@ clock_mode_changed (GtkComboBox *cb, ClockDialog *cd) { cd->clock->mode = gtk_combo_box_get_active(cb); xfce_clock_set_mode (XFCE_CLOCK (cd->clock->clock), cd->clock->mode); - + clock_set_sensative (cd); - - clock_update_size (cd->clock, + + clock_update_size (cd->clock, xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (cd->clock->plugin))); } static void -clock_dialog_response (GtkWidget *dlg, int reponse, +clock_dialog_response (GtkWidget *dlg, int reponse, ClockDialog *cd) { g_object_set_data (G_OBJECT (cd->clock->plugin), "dialog", NULL); @@ -463,7 +463,7 @@ clock_dialog_response (GtkWidget *dlg, int reponse, gtk_widget_destroy (dlg); xfce_panel_plugin_unblock_menu (cd->clock->plugin); clock_write_rc_file (cd->clock->plugin, cd->clock); - + g_free (cd); } @@ -474,30 +474,30 @@ clock_properties_dialog (XfcePanelPlugin *plugin, Clock *clock) ClockDialog *cd; xfce_panel_plugin_block_menu (plugin); - + cd = g_new0 (ClockDialog, 1); cd->clock = clock; - + dlg = xfce_titled_dialog_new_with_buttons (_("Clock"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); - gtk_window_set_screen (GTK_WINDOW (dlg), + gtk_window_set_screen (GTK_WINDOW (dlg), gtk_widget_get_screen (GTK_WIDGET (plugin))); g_object_set_data (G_OBJECT (plugin), "dialog", dlg); gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER); gtk_window_set_icon_name (GTK_WINDOW (dlg), "xfce4-settings"); - + gtk_container_set_border_width (GTK_CONTAINER (dlg), 2); - + frame = xfce_create_framebox (_("Appearance"), &bin); gtk_container_set_border_width (GTK_CONTAINER (frame), 6); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, FALSE, FALSE, 0); - + vbox = gtk_vbox_new (FALSE, 8); gtk_container_add (GTK_CONTAINER (bin), vbox); @@ -509,7 +509,7 @@ clock_properties_dialog (XfcePanelPlugin *plugin, Clock *clock) gtk_combo_box_append_text (GTK_COMBO_BOX (cb), _("Digital")); gtk_combo_box_append_text (GTK_COMBO_BOX (cb), _("LED")); gtk_combo_box_set_active (GTK_COMBO_BOX (cb), clock->mode); - g_signal_connect (cb, "changed", + g_signal_connect (cb, "changed", G_CALLBACK (clock_mode_changed), cd); cd->cb_frame = cb = gtk_check_button_new_with_mnemonic (_("Show _frame")); @@ -518,12 +518,12 @@ clock_properties_dialog (XfcePanelPlugin *plugin, Clock *clock) clock->show_frame); g_signal_connect (cb, "toggled", G_CALLBACK (clock_button_toggled), cd); - + frame = xfce_create_framebox (_("Clock Options"), &bin); gtk_container_set_border_width (GTK_CONTAINER (frame), 6); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, FALSE, FALSE, 0); - + vbox = gtk_vbox_new (FALSE, 8); gtk_container_add (GTK_CONTAINER (bin), vbox); @@ -533,7 +533,7 @@ clock_properties_dialog (XfcePanelPlugin *plugin, Clock *clock) clock->military); g_signal_connect (cb, "toggled", G_CALLBACK (clock_button_toggled), cd); - + cd->cb_ampm = cb = gtk_check_button_new_with_mnemonic (_("Show AM/PM")); gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), diff --git a/plugins/clock/clock.desktop.in.in b/plugins/clock/clock.desktop.in.in index 974dfe6cc..526ec96b9 100644 --- a/plugins/clock/clock.desktop.in.in +++ b/plugins/clock/clock.desktop.in.in @@ -5,5 +5,5 @@ _Name=Clock _Comment=What time is it? Icon=xfce-schedule X-XFCE-Module=clock -X-XFCE-Module-Path=@INTERNAL_PLUGIN_PATH@ +X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins diff --git a/plugins/iconbox/Makefile.am b/plugins/iconbox/Makefile.am index 5b1fdb5b5..8e3f82b58 100644 --- a/plugins/iconbox/Makefile.am +++ b/plugins/iconbox/Makefile.am @@ -1,45 +1,60 @@ -plugindir = $(libdir)/xfce4/panel-plugins +# $Id$ -plugin_LTLIBRARIES = libiconbox.la +INCLUDES = \ + -I$(top_srcdir) \ + -DG_LOG_DOMAIN=\"libiconbox\" \ + -DLOCALEDIR=\"$(localedir)\" \ + $(PLATFORM_CPPFLAGS) -libiconbox_la_LDFLAGS = \ - -avoid-version \ - -module +plugindir = \ + $(libdir)/xfce4/panel-plugins + +plugin_LTLIBRARIES = \ + libiconbox.la libiconbox_la_SOURCES = \ iconbox.c libiconbox_la_CFLAGS = \ - -I$(top_srcdir) \ - @LIBXFCEGUI4_CFLAGS@ \ - -DLOCALEDIR=\"$(localedir)\" + $(GTK_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCEGUI4_CFLAGS) \ + $(PLATFORM_CFLAGS) -libiconbox_la_LIBADD = \ - ../../libxfce4panel/libxfce4panel.la \ - @LIBS@ +libiconbox_la_LDFLAGS = \ + -avoid-version \ + -module \ + $(PLATFORM_LDFLAGS) -libiconbox_la_DEPENDENCIES = \ - ../../libxfce4panel/libxfce4panel.la - if HAVE_CYGWIN -libiconbox_la_LDFLAGS += \ - -no-undefined \ - @LIBX11_LDFLAGS@ \ - @LIBXFCEGUI4_LIBS@ \ - @LIBX11_LIBS@ +libiconbox_la_LDFLAGS += \ + -no-undefined endif +libiconbox_la_LIBADD = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la \ + $(GTK_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCEGUI4_LIBS) + +libiconbox_la_DEPENDENCIES = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la + +# # .desktop file # -# Some automake trickery here. Because we cannot use $(libexecdir) in the -# automake stage, we'll use sed to get the full path into the .desktop file. -# We also need to let intltool merge the translated fields, so we add an -# additional level of indirection: a <name>.desktop.in.in file. -# -desktop_in_in_files = iconbox.desktop.in.in -desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in) - -desktopdir = $(datadir)/xfce4/panel-plugins +desktopdir = \ + $(datadir)/xfce4/panel-plugins + +desktop_in_in_files = \ + iconbox.desktop.in.in + +desktop_in_files = \ + $(desktop_in_in_files:.desktop.in.in=.desktop.in) + +%.desktop.in: %.desktop.in.in + sed -e "s,\@libdir\@,$(libdir),g" < $< > $@ + desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) @INTLTOOL_DESKTOP_RULE@ @@ -47,12 +62,7 @@ EXTRA_DIST = \ $(desktop_in_in_files) DISTCLEANFILES = \ - $(desktop_DATA) $(desktop_in_files) - -# get full path into .desktop file -%.desktop.in: %.desktop.in.in $(plugin_LTLIBRARIES) - plugin_name=`grep dlname= $(plugin_LTLIBRARIES) | sed "s/dlname='\(.*\)'/\1/"`; \ - sed -e "s^@INTERNAL_PLUGIN_PATH@^$(libdir)/xfce4/panel-plugins^" \ - -e "s^@PLUGIN_NAME@^$$plugin_name^" \ - $< > $@ + $(desktop_DATA) \ + $(desktop_in_files) +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/plugins/iconbox/iconbox.c b/plugins/iconbox/iconbox.c index feeb32c79..de04a3819 100644 --- a/plugins/iconbox/iconbox.c +++ b/plugins/iconbox/iconbox.c @@ -1,11 +1,9 @@ -/* vim: set expandtab ts=8 sw=4: */ - /* $Id$ * * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published + * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * @@ -61,12 +59,12 @@ Iconbox; typedef struct { Iconbox *ib; - + NetkWindow *window; int connections[N_ICON_CONNECTIONS]; GdkPixbuf *pb; - + GtkWidget *button; GtkWidget *image; gboolean was_minimized; @@ -75,7 +73,7 @@ typedef struct Icon; -static void iconbox_properties_dialog (XfcePanelPlugin *plugin, +static void iconbox_properties_dialog (XfcePanelPlugin *plugin, Iconbox *iconbox); static void iconbox_construct (XfcePanelPlugin *plugin); @@ -86,7 +84,7 @@ static void iconbox_construct (XfcePanelPlugin *plugin); * -------------------------------------------------------------------- */ /* icons */ -static void +static void update_visibility (Icon *icon, NetkWorkspace *optional_active_ws) { NetkWorkspace *ws; @@ -98,26 +96,26 @@ update_visibility (Icon *icon, NetkWorkspace *optional_active_ws) gtk_widget_hide (icon->button); return; } - + if (icon->ib->only_hidden && !netk_window_is_minimized (icon->window)) { gtk_widget_hide (icon->button); return; } - + if (optional_active_ws) { ws = optional_active_ws; } else { - ws = netk_screen_get_active_workspace + ws = netk_screen_get_active_workspace (netk_window_get_screen (icon->window)); } - - if (icon->ib->all_workspaces - || netk_window_is_sticky (icon->window) - || ws == netk_window_get_workspace (icon->window) + + if (icon->ib->all_workspaces + || netk_window_is_sticky (icon->window) + || ws == netk_window_get_workspace (icon->window) || netk_window_or_transient_demands_attention (icon->window)) { gtk_widget_show (icon->button); @@ -134,7 +132,7 @@ icon_update_image (Icon *icon) GdkPixbuf *scaled; g_return_if_fail (GDK_IS_PIXBUF (icon->pb)); - + if (netk_window_is_minimized (icon->window)) { if (!icon->was_minimized) @@ -147,7 +145,7 @@ icon_update_image (Icon *icon) scaled = gdk_pixbuf_copy (icon->pb); else scaled = gdk_pixbuf_add_alpha (icon->pb, FALSE, 0, 0, 0); - + w = gdk_pixbuf_get_width (scaled); h = gdk_pixbuf_get_height (scaled); @@ -170,7 +168,7 @@ icon_update_image (Icon *icon) row += row_stride; } - xfce_scaled_image_set_from_pixbuf (XFCE_SCALED_IMAGE (icon->image), + xfce_scaled_image_set_from_pixbuf (XFCE_SCALED_IMAGE (icon->image), scaled); g_object_unref (G_OBJECT (scaled)); @@ -180,7 +178,7 @@ icon_update_image (Icon *icon) } else if (icon->was_minimized) { - xfce_scaled_image_set_from_pixbuf (XFCE_SCALED_IMAGE (icon->image), + xfce_scaled_image_set_from_pixbuf (XFCE_SCALED_IMAGE (icon->image), icon->pb); icon->was_minimized = FALSE; @@ -204,7 +202,7 @@ update_blink (Icon *icon, gboolean blink) if (blink) { gtk_button_set_relief (GTK_BUTTON (icon->button), GTK_RELIEF_NORMAL); - + if(mod->color_flags[GTK_STATE_NORMAL] & GTK_RC_BG) { mod->color_flags[GTK_STATE_NORMAL] &= ~(GTK_RC_BG); @@ -238,7 +236,7 @@ queue_urgent_timeout (Icon *icon) { if (icon->urgent_id == 0) { - icon->urgent_id = + icon->urgent_id = g_timeout_add (URGENT_TIMEOUT, (GSourceFunc)urgent_timeout, icon); } } @@ -291,13 +289,13 @@ icon_button_pressed (GtkWidget *button, GdkEventButton *ev, gpointer data) else if (ev->button == 3) { GtkWidget *action_menu; - + action_menu = netk_create_window_action_menu(icon->window); - - g_signal_connect(G_OBJECT(action_menu), "selection-done", + + g_signal_connect(G_OBJECT(action_menu), "selection-done", G_CALLBACK(gtk_widget_destroy), NULL); - - gtk_menu_popup(GTK_MENU(action_menu), NULL, NULL, NULL, NULL, + + gtk_menu_popup(GTK_MENU(action_menu), NULL, NULL, NULL, NULL, ev->button, ev->time); return TRUE; @@ -311,7 +309,7 @@ icon_name_changed (NetkWindow *window, gpointer data) { Icon *icon = (Icon *)data; - gtk_tooltips_set_tip (icon->ib->icon_tooltips, icon->button, + gtk_tooltips_set_tip (icon->ib->icon_tooltips, icon->button, netk_window_get_name (window), NULL); } @@ -355,7 +353,7 @@ static void icon_icon_changed (NetkWindow *window, gpointer data) { Icon *icon = (Icon *)data; - + if (icon->pb) g_object_unref (G_OBJECT (icon->pb)); @@ -363,7 +361,7 @@ icon_icon_changed (NetkWindow *window, gpointer data) if (icon->pb) g_object_ref (G_OBJECT (icon->pb)); - + /* make sure the icon is actually updated */ icon->was_minimized = !netk_window_is_minimized (icon->window); icon_update_image (icon); @@ -375,18 +373,18 @@ icon_destroy (Icon *icon) int i; unqueue_urgent_timeout (icon); - + for (i = 0; i < N_ICON_CONNECTIONS; i++) { if (icon->connections[i]) g_signal_handler_disconnect (icon->window, icon->connections[i]); - + icon->connections[i] = 0; } - + if (icon->pb) g_object_unref (G_OBJECT (icon->pb)); - + panel_slice_free (Icon, icon); } @@ -397,44 +395,44 @@ icon_new (NetkWindow *window, Iconbox *ib) int i = 0; icon->ib = ib; - - icon->window = window; + + icon->window = window; icon->button = xfce_create_panel_toggle_button (); - + g_signal_connect (icon->button, "button-press-event", G_CALLBACK (icon_button_pressed), icon); - + icon->image = xfce_scaled_image_new (); gtk_widget_show (icon->image); gtk_container_add (GTK_CONTAINER (icon->button), icon->image); - + icon->pb = netk_window_get_icon (window); if (icon->pb) { - xfce_scaled_image_set_from_pixbuf (XFCE_SCALED_IMAGE (icon->image), + xfce_scaled_image_set_from_pixbuf (XFCE_SCALED_IMAGE (icon->image), icon->pb); g_object_ref (G_OBJECT (icon->pb)); } - - icon->connections[i++] = - g_signal_connect (window, "name-changed", + + icon->connections[i++] = + g_signal_connect (window, "name-changed", G_CALLBACK (icon_name_changed), icon); - - icon->connections[i++] = - g_signal_connect (window, "state-changed", + + icon->connections[i++] = + g_signal_connect (window, "state-changed", G_CALLBACK (icon_state_changed), icon); - - icon->connections[i++] = - g_signal_connect (window, "workspace-changed", + + icon->connections[i++] = + g_signal_connect (window, "workspace-changed", G_CALLBACK (icon_workspace_changed), icon); - - icon->connections[i++] = - g_signal_connect (window, "icon-changed", + + icon->connections[i++] = + g_signal_connect (window, "icon-changed", G_CALLBACK (icon_icon_changed), icon); - + g_assert (i == N_ICON_CONNECTIONS); - + if (netk_window_is_skip_tasklist (window)) { return icon; @@ -442,7 +440,7 @@ icon_new (NetkWindow *window, Iconbox *ib) icon_update_image (icon); - gtk_tooltips_set_tip (ib->icon_tooltips, icon->button, + gtk_tooltips_set_tip (ib->icon_tooltips, icon->button, netk_window_get_name (window), NULL); update_visibility (icon, NULL); @@ -457,12 +455,12 @@ iconbox_active_window_changed (NetkScreen *screen, gpointer data) Iconbox *ib = (Iconbox *)data; GSList *l; NetkWindow *window = netk_screen_get_active_window (screen); - + for (l = ib->iconlist; l != NULL; l = l->next) { Icon *icon = l->data; - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (icon->button), + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (icon->button), (window == icon->window)); } } @@ -473,11 +471,11 @@ iconbox_active_workspace_changed (NetkScreen *screen, gpointer data) Iconbox *ib = (Iconbox *)data; GSList *l; NetkWorkspace *ws = netk_screen_get_active_workspace (screen); - + for (l = ib->iconlist; l != NULL; l = l->next) { Icon *icon = l->data; - + update_visibility (icon, ws); } } @@ -505,11 +503,11 @@ iconbox_window_closed (NetkScreen *screen, NetkWindow *window, gpointer data) { Iconbox *ib = (Iconbox *)data; GSList *l; - + for (l = ib->iconlist; l != NULL; l = l->next) { Icon *icon = l->data; - + if (window == icon->window) { gtk_widget_destroy (icon->button); @@ -528,27 +526,27 @@ iconbox_init_icons (Iconbox * ib) { int i = 0; GList *windows, *l; - + netk_screen_force_update (ib->netk_screen); ib->connections[i++] = g_signal_connect (ib->netk_screen, "active_window_changed", - G_CALLBACK (iconbox_active_window_changed), + G_CALLBACK (iconbox_active_window_changed), ib); ib->connections[i++] = g_signal_connect (ib->netk_screen, "active_workspace_changed", - G_CALLBACK (iconbox_active_workspace_changed), + G_CALLBACK (iconbox_active_workspace_changed), ib); ib->connections[i++] = g_signal_connect (ib->netk_screen, "window_opened", - G_CALLBACK (iconbox_window_opened), + G_CALLBACK (iconbox_window_opened), ib); ib->connections[i++] = g_signal_connect (ib->netk_screen, "window_closed", - G_CALLBACK (iconbox_window_closed), + G_CALLBACK (iconbox_window_closed), ib); g_assert (i == N_ICONBOX_CONNECTIONS); @@ -595,7 +593,7 @@ cleanup_iconbox (Iconbox *ib) cleanup_icons (ib); g_object_unref (G_OBJECT (ib->icon_tooltips)); - + panel_slice_free (Iconbox, ib); } @@ -612,8 +610,8 @@ XFCE_PANEL_PLUGIN_REGISTER_INTERNAL (iconbox_construct); /* Interface Implementation */ static void -iconbox_orientation_changed (XfcePanelPlugin *plugin, - GtkOrientation orientation, +iconbox_orientation_changed (XfcePanelPlugin *plugin, + GtkOrientation orientation, Iconbox *iconbox) { xfce_hvbox_set_orientation (XFCE_HVBOX(iconbox->box), orientation); @@ -622,24 +620,24 @@ iconbox_orientation_changed (XfcePanelPlugin *plugin, gtk_widget_queue_draw (iconbox->handle); } -static gboolean +static gboolean iconbox_set_size (XfcePanelPlugin *plugin, int size, Iconbox *ib) { GSList *l; Icon *icon = ib->iconlist ? ib->iconlist->data : NULL; GtkWidget *widget = icon ? icon->button : ib->iconbox; - + if (xfce_panel_plugin_get_orientation (plugin) == GTK_ORIENTATION_HORIZONTAL) { ib->icon_size = size - 2 * widget->style->xthickness - 2; - gtk_widget_set_size_request (GTK_WIDGET (plugin), + gtk_widget_set_size_request (GTK_WIDGET (plugin), -1, size); } else { ib->icon_size = size - 2 * widget->style->ythickness - 2; - gtk_widget_set_size_request (GTK_WIDGET (plugin), + gtk_widget_set_size_request (GTK_WIDGET (plugin), size, -1); } @@ -649,7 +647,7 @@ iconbox_set_size (XfcePanelPlugin *plugin, int size, Iconbox *ib) icon_update_image (icon); } - + return TRUE; } @@ -660,7 +658,7 @@ iconbox_free_data (XfcePanelPlugin *plugin, Iconbox *iconbox) if (dlg) gtk_widget_destroy (dlg); - + g_signal_handler_disconnect (plugin, iconbox->screen_changed_id); cleanup_iconbox (iconbox); @@ -674,7 +672,7 @@ iconbox_read_rc_file (XfcePanelPlugin *plugin, Iconbox *iconbox) int only_hidden = 0; int all_workspaces = 0; int expand = 1; - + if ((file = xfce_panel_plugin_lookup_rc_file (plugin)) != NULL) { rc = xfce_rc_simple_open (file, TRUE); @@ -699,7 +697,7 @@ iconbox_write_rc_file (XfcePanelPlugin *plugin, Iconbox *iconbox) { char *file; XfceRc *rc; - + if (!(file = xfce_panel_plugin_save_location (plugin, TRUE))) return; @@ -708,7 +706,7 @@ iconbox_write_rc_file (XfcePanelPlugin *plugin, Iconbox *iconbox) if (!rc) return; - + xfce_rc_write_int_entry (rc, "only_hidden", iconbox->only_hidden); xfce_rc_write_int_entry (rc, "all_workspaces", iconbox->all_workspaces); xfce_rc_write_int_entry (rc, "expand", iconbox->expand); @@ -726,14 +724,14 @@ handle_expose (GtkWidget *widget, GdkEventExpose *ev, Iconbox *iconbox) int x, y, w, h; gboolean horizontal; - horizontal = (xfce_panel_plugin_get_orientation (iconbox->plugin) + horizontal = (xfce_panel_plugin_get_orientation (iconbox->plugin) == GTK_ORIENTATION_HORIZONTAL); x = allocation->x; y = allocation->y; w = allocation->width; h = allocation->height; - + if (horizontal) { y += widget->style->ythickness; @@ -746,7 +744,7 @@ handle_expose (GtkWidget *widget, GdkEventExpose *ev, Iconbox *iconbox) } gtk_paint_handle (widget->style, widget->window, - GTK_WIDGET_STATE (widget), GTK_SHADOW_NONE, + GTK_WIDGET_STATE (widget), GTK_SHADOW_NONE, &(ev->area), widget, "handlebox", x, y, w, h, horizontal ? GTK_ORIENTATION_VERTICAL : @@ -761,17 +759,15 @@ handle_expose (GtkWidget *widget, GdkEventExpose *ev, Iconbox *iconbox) static void iconbox_screen_changed (GtkWidget *plugin, GdkScreen *screen, Iconbox *ib) { - screen = gtk_widget_get_screen (plugin); - if (!screen) return; - gtk_container_foreach (GTK_CONTAINER (ib->iconbox), + gtk_container_foreach (GTK_CONTAINER (ib->iconbox), (GtkCallback) gtk_widget_destroy, NULL); cleanup_icons (ib); - + ib->netk_screen = netk_screen_get (gdk_screen_get_number (screen)); - + iconbox_init_icons (ib); } @@ -781,12 +777,12 @@ iconbox_construct (XfcePanelPlugin *plugin) Iconbox *iconbox = panel_slice_new0 (Iconbox); iconbox->plugin = plugin; - + iconbox_read_rc_file (plugin, iconbox); xfce_panel_plugin_set_expand (plugin, iconbox->expand); - - iconbox->box = xfce_hvbox_new (xfce_panel_plugin_get_orientation (plugin), + + iconbox->box = xfce_hvbox_new (xfce_panel_plugin_get_orientation (plugin), FALSE, 0); gtk_container_set_reallocate_redraws (GTK_CONTAINER (iconbox->box), TRUE); gtk_widget_show (iconbox->box); @@ -795,46 +791,46 @@ iconbox_construct (XfcePanelPlugin *plugin) iconbox->handle = gtk_alignment_new (0, 0, 0, 0); gtk_widget_set_size_request (iconbox->handle, 8, 8); gtk_widget_show (iconbox->handle); - gtk_box_pack_start (GTK_BOX (iconbox->box), iconbox->handle, + gtk_box_pack_start (GTK_BOX (iconbox->box), iconbox->handle, FALSE, FALSE, 0); xfce_panel_plugin_add_action_widget (plugin, iconbox->handle); - g_signal_connect (iconbox->handle, "expose-event", + g_signal_connect (iconbox->handle, "expose-event", G_CALLBACK (handle_expose), iconbox); - - iconbox->iconbox = + + iconbox->iconbox = xfce_hvbox_new (xfce_panel_plugin_get_orientation (plugin), FALSE, 0); gtk_widget_show (iconbox->iconbox); - gtk_box_pack_start (GTK_BOX (iconbox->box), iconbox->iconbox, + gtk_box_pack_start (GTK_BOX (iconbox->box), iconbox->iconbox, FALSE, FALSE, 0); - + iconbox->icon_tooltips = gtk_tooltips_new (); g_object_ref (G_OBJECT (iconbox->icon_tooltips)); gtk_object_sink (GTK_OBJECT (iconbox->icon_tooltips)); - g_signal_connect (plugin, "orientation-changed", + g_signal_connect (plugin, "orientation-changed", G_CALLBACK (iconbox_orientation_changed), iconbox); - - g_signal_connect (plugin, "size-changed", + + g_signal_connect (plugin, "size-changed", G_CALLBACK (iconbox_set_size), iconbox); - - g_signal_connect (plugin, "free-data", + + g_signal_connect (plugin, "free-data", G_CALLBACK (iconbox_free_data), iconbox); - - g_signal_connect (plugin, "save", + + g_signal_connect (plugin, "save", G_CALLBACK (iconbox_write_rc_file), iconbox); - + xfce_panel_plugin_menu_show_configure (plugin); - g_signal_connect (plugin, "configure-plugin", + g_signal_connect (plugin, "configure-plugin", G_CALLBACK (iconbox_properties_dialog), iconbox); - iconbox->screen_changed_id = - g_signal_connect (plugin, "screen-changed", + iconbox->screen_changed_id = + g_signal_connect (plugin, "screen-changed", G_CALLBACK (iconbox_screen_changed), iconbox); - + iconbox_screen_changed (GTK_WIDGET (plugin), - gtk_widget_get_screen (GTK_WIDGET (plugin)), + gtk_widget_get_screen (GTK_WIDGET (plugin)), iconbox); } @@ -846,12 +842,12 @@ static void only_hidden_toggled (GtkToggleButton *tb, Iconbox *ib) { GSList *l; - + ib->only_hidden = gtk_toggle_button_get_active (tb); for (l = ib->iconlist; l != NULL; l = l->next) { - Icon *icon = l->data; + Icon *icon = l->data; update_visibility (icon, NULL); } @@ -861,12 +857,12 @@ static void all_workspaces_toggled (GtkToggleButton *tb, Iconbox *ib) { GSList *l; - + ib->all_workspaces = gtk_toggle_button_get_active (tb); for (l = ib->iconlist; l != NULL; l = l->next) { - Icon *icon = l->data; + Icon *icon = l->data; update_visibility (icon, NULL); } @@ -881,7 +877,7 @@ expand_toggled (GtkToggleButton *tb, Iconbox *ib) } static void -iconbox_dialog_response (GtkWidget *dlg, int reponse, +iconbox_dialog_response (GtkWidget *dlg, int reponse, Iconbox *ib) { g_object_set_data (G_OBJECT (ib->plugin), "dialog", NULL); @@ -897,25 +893,25 @@ iconbox_properties_dialog (XfcePanelPlugin *plugin, Iconbox *iconbox) GtkWidget *dlg, *vbox, *cb; xfce_panel_plugin_block_menu (plugin); - + dlg = xfce_titled_dialog_new_with_buttons (_("Icon Box"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); - gtk_window_set_screen (GTK_WINDOW (dlg), + gtk_window_set_screen (GTK_WINDOW (dlg), gtk_widget_get_screen (GTK_WIDGET (plugin))); g_object_set_data (G_OBJECT (plugin), "dialog", dlg); gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER); gtk_window_set_icon_name (GTK_WINDOW (dlg), "xfce4-settings"); - + g_signal_connect (dlg, "response", G_CALLBACK (iconbox_dialog_response), iconbox); gtk_container_set_border_width (GTK_CONTAINER (dlg), 2); - + vbox = gtk_vbox_new (FALSE, 8); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); gtk_widget_show (vbox); @@ -930,7 +926,7 @@ iconbox_properties_dialog (XfcePanelPlugin *plugin, Iconbox *iconbox) iconbox->only_hidden); g_signal_connect (cb, "toggled", G_CALLBACK (only_hidden_toggled), iconbox); - + cb = gtk_check_button_new_with_mnemonic ( _("Show applications of all workspaces")); gtk_widget_show (cb); @@ -939,7 +935,7 @@ iconbox_properties_dialog (XfcePanelPlugin *plugin, Iconbox *iconbox) iconbox->all_workspaces); g_signal_connect (cb, "toggled", G_CALLBACK (all_workspaces_toggled), iconbox); - + cb = gtk_check_button_new_with_mnemonic (_("Use all available space")); gtk_widget_show (cb); gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0); @@ -950,4 +946,3 @@ iconbox_properties_dialog (XfcePanelPlugin *plugin, Iconbox *iconbox) gtk_widget_show (dlg); } - diff --git a/plugins/iconbox/iconbox.desktop.in.in b/plugins/iconbox/iconbox.desktop.in.in index 560b7201b..4e334f390 100644 --- a/plugins/iconbox/iconbox.desktop.in.in +++ b/plugins/iconbox/iconbox.desktop.in.in @@ -5,5 +5,5 @@ _Name=Icon Box _Comment=Show icons of all running applications Icon=xfce4-iconbox X-XFCE-Module=iconbox -X-XFCE-Module-Path=@INTERNAL_PLUGIN_PATH@ +X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins diff --git a/plugins/launcher/Makefile.am b/plugins/launcher/Makefile.am index 8a8eab410..1d6fc62ef 100644 --- a/plugins/launcher/Makefile.am +++ b/plugins/launcher/Makefile.am @@ -1,48 +1,72 @@ -liblauncherdir = $(libdir)/xfce4/panel-plugins +# $Id$ -liblauncher_LTLIBRARIES = liblauncher.la +INCLUDES = \ + -I$(top_srcdir) \ + -DBINDIR=\"$(bindir)\" \ + -DG_LOG_DOMAIN=\"liblauncher\" \ + -DSN_API_NOT_YET_FROZEN \ + -DEXO_API_SUBJECT_TO_CHANGE \ + -DLOCALEDIR=\"$(localedir)\" \ + $(PLATFORM_CPPFLAGS) -liblauncher_la_LDFLAGS = \ - -avoid-version \ - -module +plugindir = \ + $(libdir)/xfce4/panel-plugins + +plugin_LTLIBRARIES = \ + liblauncher.la liblauncher_la_SOURCES = \ launcher.h \ launcher.c \ + launcher-exec.h \ + launcher-exec.c \ launcher-dialog.h \ launcher-dialog.c liblauncher_la_CFLAGS = \ - -I$(top_srcdir) \ - @LIBXFCEGUI4_CFLAGS@ \ - -DLOCALEDIR=\"$(localedir)\" + $(GTK_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCEGUI4_CFLAGS) \ + $(LIBEXO_CFLAGS) \ + $(LIBSTARTUP_NOTIFICATION_CFLAGS) \ + $(PLATFORM_CFLAGS) -liblauncher_la_LIBADD = \ - ../../libxfce4panel/libxfce4panel.la \ - @LIBS@ +liblauncher_la_LDFLAGS = \ + -avoid-version \ + -module \ + $(PLATFORM_LDFLAGS) -liblauncher_la_DEPENDENCIES = \ - ../../libxfce4panel/libxfce4panel.la - if HAVE_CYGWIN -liblauncher_la_LDFLAGS += \ - -no-undefined \ - @LIBX11_LDFLAGS@ \ - @LIBXFCEGUI4_LIBS@ \ - @LIBX11_LIBS@ +liblauncher_la_LDFLAGS += \ + -no-undefined endif +liblauncher_la_LIBADD = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la \ + $(GTK_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCEGUI4_LIBS) \ + $(LIBEXO_LIBS) \ + $(LIBSTARTUP_NOTIFICATION_LIBS) + +liblauncher_la_DEPENDENCIES = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la + +# # .desktop file # -# Some automake trickery here. Because we cannot use $(libexecdir) in the -# automake stage, we'll use sed to get the full path into the .desktop file. -# We also need to let intltool merge the translated fields, so we add an -# additional level of indirection: a <name>.desktop.in.in file. -# -desktop_in_in_files = launcher.desktop.in.in -desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in) - -desktopdir = $(datadir)/xfce4/panel-plugins +desktopdir = \ + $(datadir)/xfce4/panel-plugins + +desktop_in_in_files = \ + launcher.desktop.in.in + +desktop_in_files = \ + $(desktop_in_in_files:.desktop.in.in=.desktop.in) + +%.desktop.in: %.desktop.in.in + sed -e "s,\@libdir\@,$(libdir),g" < $< > $@ + desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) @INTLTOOL_DESKTOP_RULE@ @@ -50,12 +74,7 @@ EXTRA_DIST = \ $(desktop_in_in_files) DISTCLEANFILES = \ - $(desktop_DATA) $(desktop_in_files) - -# get full path into .desktop file -%.desktop.in: %.desktop.in.in $(plugin_LTLIBRARIES) - plugin_name=`grep dlname= liblauncher.la | sed "s/dlname='\(.*\)'/\1/"`; \ - sed -e "s^@INTERNAL_PLUGIN_PATH@^$(libdir)/xfce4/panel-plugins^" \ - -e "s^@PLUGIN_NAME@^$$plugin_name^" \ - $< > $@ + $(desktop_DATA) \ + $(desktop_in_files) +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/plugins/launcher/launcher-dialog.c b/plugins/launcher/launcher-dialog.c index 900376f3f..aff90b1c0 100644 --- a/plugins/launcher/launcher-dialog.c +++ b/plugins/launcher/launcher-dialog.c @@ -1,8 +1,8 @@ -/* vim: set expandtab ts=8 sw=4: */ - /* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2006-2007 Nick Schermer <nick@xfce.org> + * Copyright (c) 2005-2006 Benedikt Meurer <benny@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 @@ -19,1938 +19,1541 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H #include <config.h> - -#include <stdio.h> +#endif +#ifdef HAVE_MEMORY_H +#include <memory.h> +#endif +#ifdef HAVE_STRING_H #include <string.h> -#include <math.h> -#include <gtk/gtk.h> +#endif -#include <libxfce4util/libxfce4util.h> -#include <libxfcegui4/libxfcegui4.h> -#include <libxfce4panel/xfce-arrow-button.h> +#include <libxfcegui4/xfce-titled-dialog.h> #include <libxfce4panel/xfce-panel-plugin.h> +#include "launcher.h" #include "launcher-dialog.h" - -typedef struct +enum { - XfcePanelPlugin *plugin; - LauncherPlugin *launcher; + COL_ICON = 0, + COL_TEXT +}; - GtkWidget *dlg; - - /* launchers */ - GtkWidget *tree; - GtkWidget *scroll; - - GtkWidget *up; - GtkWidget *down; - GtkWidget *add; - GtkWidget *remove; - - /* edit current entry */ - gboolean updating; - - LauncherEntry *entry; - - GtkWidget *exec_name; - GtkWidget *exec_comment; - - GtkWidget *icon_button; - GtkWidget *icon_img; - GtkWidget *icon_category; - GtkWidget *icon_file_align; - GtkWidget *icon_file; - GtkWidget *icon_browse; - GtkWidget *icon_label; - - GtkWidget *exec; - GtkWidget *exec_browse; - GtkWidget *exec_terminal; - GtkWidget *exec_startup; -} -LauncherDialog; +typedef struct _LauncherDialog LauncherDialog; -/* Adding a new Zero Install interface requires using the - * network, so we do it asynchronously. This structure records - * the details for the callback handler. - */ -typedef struct +struct _LauncherDialog { - /* LauncherDialog objects are not ref-counted, so we ref-count - * the plugin object instead and use that to check that the - * LauncherDialog is still available. - */ - GObject *plugin; - - /* The package we are checking. */ - char *interface_uri; - - /* The entry to update, or NULL to add a new one. - * Need to check that this is still valid when the callback is - * invoked. - */ - LauncherEntry *entry; -} -ZeroInstallProcess; - -/* Keep in sync with XfceIconTheme */ -static const char *category_icons [] = { - N_("Default"), - N_("Editor"), - N_("File management"), - N_("Utilities"), - N_("Games"), - N_("Help browser"), - N_("Multimedia"), - N_("Network"), - N_("Graphics"), - N_("Printer"), - N_("Productivity"), - N_("Office"), - N_("Sound"), - N_("Terminal"), - N_("Development") + LauncherPlugin *launcher; + + /* entries list */ + GtkWidget *treeview; + GtkListStore *store; + + /* tree buttons */ + GtkWidget *up; + GtkWidget *down; + GtkWidget *add; + GtkWidget *remove; + + /* lock */ + guint updating : 1; + + /* active entry */ + LauncherEntry *entry; + + /* entry widgets */ + GtkWidget *entry_name; + GtkWidget *entry_comment; + GtkWidget *entry_icon; + GtkWidget *entry_exec; + GtkWidget *entry_path; + GtkWidget *entry_terminal; +#ifdef HAVE_LIBSTARTUP_NOTIFICATION + GtkWidget *entry_startup; +#endif }; -#define NUM_CATEGORIES G_N_ELEMENTS(category_icons) - -/* DND */ -static void entry_dialog_data_received (GtkWidget *w, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - LauncherDialog *ld); - -static void launcher_dialog_data_received (GtkWidget *w, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - LauncherDialog *ld); - -static void icon_entry_data_received (GtkWidget *w, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - LauncherDialog *ld); - -/* File dialog with preview */ -static char *select_file_with_preview (const char *title, - const char *path, - GtkWidget * parent, - gboolean with_preview); - - -/* LauncherEntry Properties * - * ------------------------ */ - -/* update entry from dialog */ -static void -update_entry_info (LauncherDialog *ld) + + +/** + * Prototypes + **/ +static gchar *launcher_dialog_parse_exec (const gchar *exec) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +static gboolean launcher_dialog_read_desktop_file (const gchar *file, + LauncherEntry *entry); +static void launcher_dialog_tree_drag_data_received (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint time, + LauncherDialog *ld); +static void launcher_dialog_frame_drag_data_received (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint time, + LauncherDialog *ld); +static void launcher_dialog_update_panel (LauncherDialog *ld); +static void launcher_dialog_save_entry (GtkWidget *entry, + LauncherDialog *ld); +static void launcher_dialog_save_button (GtkWidget *button, + LauncherDialog *ld); +static void launcher_dialog_update_entries (LauncherDialog *ld); +static void launcher_dialog_update_icon (LauncherDialog *ld); +static void launcher_dialog_folder_chooser (LauncherDialog *ld); +static void launcher_dialog_command_chooser (LauncherDialog *ld); +static void launcher_dialog_icon_chooser (LauncherDialog *ld); +static void launcher_dialog_tree_free_store (LauncherDialog *ld); +static void launcher_dialog_tree_update_row (LauncherDialog *ld, + gint column); +static void launcher_dialog_tree_selection_changed (LauncherDialog *ld, + GtkTreeSelection *selection); +static void launcher_dialog_tree_button_clicked (GtkWidget *button, + LauncherDialog *ld); +static GtkWidget *launcher_dialog_add_properties (LauncherDialog *ld) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +static GtkWidget *launcher_dialog_add_tree (LauncherDialog *ld) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +static GtkWidget *launcher_dialog_add_tree_buttons (LauncherDialog *ld) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +static void launcher_dialog_response (GtkWidget *dialog, + gint response, + LauncherDialog *ld); + + + +/** + * .Desktop entry + **/ +static gchar * +launcher_dialog_parse_exec (const gchar *exec) { - const char *text; - - text = gtk_entry_get_text (GTK_ENTRY (ld->exec_name)); + gchar *expanded, *command = NULL; - if (!text || !strlen (text)) - { - if (ld->entry->name) - { - g_free (ld->entry->name); - ld->entry->name = NULL; - } - } - else if (!ld->entry->name || strcmp (text, ld->entry->name) != 0) - { - g_free (ld->entry->name); - ld->entry->name = g_strdup (text); - } + /* quit if nothing is set */ + if (exec == NULL) + return NULL; - text = gtk_entry_get_text (GTK_ENTRY (ld->exec_comment)); + /* expand enviorement variables like ~/ and ~user/ */ + expanded = xfce_expand_variables (exec, NULL); - if (!text || !strlen (text)) + /* use %f if an application hasn't set anything else */ + if (expanded != NULL && + strstr (exec, "%f") == NULL && strstr (exec, "%F") == NULL && + strstr (exec, "%u") == NULL && strstr (exec, "%U") == NULL) { - if (ld->entry->comment) - { - g_free (ld->entry->comment); - ld->entry->comment = NULL; - } + command = g_strconcat (expanded, " %f", NULL); + g_free (expanded); } - else if (!ld->entry->comment || strcmp (text, ld->entry->comment) != 0) + else { - g_free (ld->entry->comment); - ld->entry->comment = g_strdup (text); + command = expanded; } - gtk_widget_queue_draw (ld->tree); + return command; } -static void -update_entry_icon (LauncherDialog *ld) -{ - const char *text; - GdkPixbuf *pb; - text = gtk_entry_get_text (GTK_ENTRY (ld->icon_file)); - - if (!text || !strlen (text)) - { - if (ld->entry->icon.type == LAUNCHER_ICON_TYPE_NAME) - { - g_free (ld->entry->icon.icon.name); - ld->entry->icon.icon.name = NULL; - } - ld->entry->icon.type = LAUNCHER_ICON_TYPE_NONE; +static gboolean +launcher_dialog_read_desktop_file (const gchar *path, + LauncherEntry *entry) +{ + XfceRc *rc = NULL; + const gchar *value = NULL; + const gchar *p; - pb = launcher_icon_load_pixbuf (ld->icon_img, &ld->entry->icon, - DLG_ICON_SIZE); - gtk_image_set_from_pixbuf (GTK_IMAGE (ld->icon_img), pb); - g_object_unref (G_OBJECT (pb)); - } - else if (ld->entry->icon.type != LAUNCHER_ICON_TYPE_NAME || - strcmp (text, ld->entry->icon.icon.name) != 0) - { - if (ld->entry->icon.type == LAUNCHER_ICON_TYPE_NAME) - g_free (ld->entry->icon.icon.name); - - ld->entry->icon.type = LAUNCHER_ICON_TYPE_NAME; - ld->entry->icon.icon.name = g_strdup (text); - - pb = launcher_icon_load_pixbuf (ld->icon_img, &ld->entry->icon, - DLG_ICON_SIZE); - gtk_image_set_from_pixbuf (GTK_IMAGE (ld->icon_img), pb); - g_object_unref (G_OBJECT (pb)); - } + /* we only support .desktop files */ + if (G_UNLIKELY (g_str_has_suffix (path, ".desktop") == FALSE || + g_path_is_absolute (path) == FALSE)) + return FALSE; - gtk_widget_queue_draw (ld->tree); -} + /* open de .desktop file */ + rc = xfce_rc_simple_open (path, TRUE); + if (G_UNLIKELY (rc == NULL)) + return FALSE; -static void -update_entry_exec (LauncherDialog *ld) -{ - const char *text; - - text = gtk_entry_get_text (GTK_ENTRY (ld->exec)); + /* set the desktop entry group */ + xfce_rc_set_group (rc, "Desktop Entry"); - if (!text || !strlen (text)) + /* name */ + value = xfce_rc_read_entry (rc, "Name", NULL); + if (G_LIKELY (value != NULL)) { - if (ld->entry->exec) - { - g_free (ld->entry->exec); - ld->entry->exec = NULL; - g_free (ld->entry->real_exec); - ld->entry->real_exec = NULL; - } + g_free (entry->name); + entry->name = g_strdup (value); } - else if (!ld->entry->exec || strcmp (text, ld->entry->exec) != 0) + + /* comment */ + value = xfce_rc_read_entry (rc, "Comment", NULL); + if (G_LIKELY (value != NULL)) { - g_free (ld->entry->exec); - ld->entry->exec = g_strdup (text); - g_free (ld->entry->real_exec); - if (!(ld->entry->real_exec = - xfce_expand_variables (ld->entry->exec, NULL))) - { - ld->entry->real_exec = g_strdup (ld->entry->exec); - } + g_free (entry->comment); + entry->comment = g_strdup (value); } -} -/* text entries */ -static gboolean -entry_lost_focus (GtkWidget *gentry, GdkEventFocus *ev, LauncherDialog *ld) -{ - if (ld->updating) - return FALSE; - - if (gentry == ld->exec_name || gentry == ld->exec_comment) + /* icon */ + value = xfce_rc_read_entry_untranslated (rc, "Icon", NULL); + if (G_LIKELY (value != NULL)) { - update_entry_info (ld); + g_free (entry->icon); + + /* get rid of extensions in non-absolute names */ + if (G_UNLIKELY (g_path_is_absolute (value) == FALSE) && + ((p = g_strrstr (value, ".")) && strlen (p) < 6)) + entry->icon = g_strndup (value, p-value); + else + entry->icon = g_strdup (value); } - else if (gentry == ld->icon_file) + + /* exec */ + value = xfce_rc_read_entry_untranslated (rc, "Exec", NULL); + if (G_LIKELY (value != NULL)) { - update_entry_icon (ld); + g_free (entry->exec); + + /* expand variables and store */ + entry->exec = launcher_dialog_parse_exec (value); } - else if (gentry == ld->exec) + + /* working directory */ + value = xfce_rc_read_entry_untranslated (rc, "Path", NULL); + if (G_UNLIKELY (value != NULL)) { - update_entry_exec (ld); + g_free (entry->path); + + /* expand variables and store */ + entry->path = value ? xfce_expand_variables (value, NULL) : NULL; } - return FALSE; -} + /* terminal */ + entry->terminal = xfce_rc_read_bool_entry (rc, "Terminal", FALSE); -/* toggle buttons */ -static void -check_button_toggled (GtkWidget *tb, LauncherDialog *ld) -{ - if (ld->updating) - return; - - if (tb == ld->exec_terminal) - ld->entry->terminal = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tb)); - else if (tb == ld->exec_startup) - ld->entry->startup = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tb)); -} +#ifdef HAVE_LIBSTARTUP_NOTIFICATION + /* startup notification */ + entry->startup = xfce_rc_read_bool_entry (rc, "StartupNotify", FALSE); +#endif -/* icon callbacks */ -static void -set_panel_icon (LauncherDialog *ld) -{ - launcher_update_panel_entry(ld->launcher); -} + /* release rc file */ + xfce_rc_close (rc); -static void -icon_menu_deactivated (GtkWidget *menu, LauncherDialog *ld) -{ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ld->icon_button), FALSE); + return TRUE; } -static void -position_icon_menu (GtkMenu * menu, int *x, int *y, gboolean * push_in, - GtkWidget *b) -{ - GtkRequisition req; - GdkScreen *screen; - GdkRectangle geom; - int num; - - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (menu))) - gtk_widget_realize (GTK_WIDGET (menu)); - gtk_widget_size_request (GTK_WIDGET (menu), &req); - gdk_window_get_origin (b->window, x, y); +static void +launcher_dialog_tree_drag_data_received (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint time, + LauncherDialog *ld) +{ + GtkTreePath *path = NULL; + GtkTreeViewDropPosition position; + GtkTreeModel *model; + GtkTreeIter iter_a; + GtkTreeIter iter_b; + GSList *file_list = NULL; + GSList *li; + gchar *file; + gboolean insert_before = FALSE; + gint i = 0; + LauncherEntry *entry; + GdkPixbuf *icon = NULL; + + /* get drop position in the tree */ + if (gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (ld->treeview), + x, y, &path, &position) == FALSE) + { + /* probably droped in empty tree space, drop after last item */ + path = gtk_tree_path_new_from_indices (g_list_length (ld->launcher->entries) -1 , -1); + position = GTK_TREE_VIEW_DROP_AFTER; + } - *x += b->allocation.x; - *y += b->allocation.y - req.height; + if (G_LIKELY (path != NULL)) + { + /* get the iter we're going to drop after */ + model = gtk_tree_view_get_model (GTK_TREE_VIEW (ld->treeview)); + gtk_tree_model_get_iter (model, &iter_a, path); - screen = gtk_widget_get_screen (b); + /* array position or current item */ + i = gtk_tree_path_get_indices (path)[0]; - num = gdk_screen_get_monitor_at_window (screen, b->window); + /* insert position, array correction and the path we select afterwards */ + switch (position) + { + case GTK_TREE_VIEW_DROP_BEFORE: + case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: + insert_before = TRUE; + break; - gdk_screen_get_monitor_geometry (screen, num, &geom); + case GTK_TREE_VIEW_DROP_AFTER: + case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: + gtk_tree_path_next (path); + ++i; + insert_before = FALSE; + break; + } - if (*x > geom.x + geom.width - req.width) - *x = geom.x + geom.width - req.width; - if (*x < geom.x) - *x = geom.x; + /* we need to update the button icon if something was dropped on the first position */ + if (i == 0) + ld->launcher->icon_update_required = TRUE; - if (*y > geom.y + geom.height - req.height) - *y = geom.y + geom.height - req.height; - if (*y < geom.y) - *y = geom.y; -} + /* create list from selection data */ + file_list = launcher_file_list_from_selection (selection_data); + } -static void -popup_icon_menu (GtkWidget *tb, LauncherDialog *ld) -{ - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tb))) + if (G_LIKELY (file_list != NULL)) { - gtk_menu_popup (GTK_MENU (ld->icon_category), NULL, NULL, - (GtkMenuPositionFunc) position_icon_menu, tb, - 0, gtk_get_current_event_time ()); - } -} + for (li = file_list; li != NULL; li = li->next) + { + file = (gchar *) li->data; -static void -icon_menu_activated (GtkWidget *mi, LauncherDialog *ld) -{ - int n = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (mi), "category")); + /* create new entry */ + entry = launcher_new_entry (); - n = CLAMP (n, 0, NUM_CATEGORIES); + /* try to parse desktop file */ + if (G_LIKELY (launcher_dialog_read_desktop_file (file, entry) == TRUE)) + { + /* try to load the pixbuf */ + icon = launcher_load_pixbuf (ld->treeview, entry->icon, TREE_ICON_SIZE, TRUE); + + /* insert new row in store */ + if (insert_before) + gtk_list_store_insert_before (ld->store, &iter_b, &iter_a); + else + gtk_list_store_insert_after (ld->store, &iter_b, &iter_a); + + /* set tree data */ + gtk_list_store_set (ld->store, &iter_b, + COL_ICON, icon, + COL_TEXT, entry->name, + -1); + + /* release pixbuf */ + if (G_LIKELY (icon != NULL)) + g_object_unref (G_OBJECT (icon)); + + /* insert in list */ + ld->launcher->entries = g_list_insert (ld->launcher->entries, + entry, i); + + /* copy iter, so we add after last item */ + iter_a = iter_b; + + /* raise position counter */ + ++i; + + /* 1st item is inserted before existing item, after + * that we insert after the 1st item */ + insert_before = FALSE; + } + else + { + /* desktop file pasring failed, free new entry */ + launcher_free_entry (entry, NULL); + } + } - if (ld->entry->icon.type != LAUNCHER_ICON_TYPE_CATEGORY - || ld->entry->icon.icon.category != n) - { - GdkPixbuf *pb; - - gtk_label_set_text (GTK_LABEL (ld->icon_label), _(category_icons[n])); - gtk_widget_hide (ld->icon_file_align); - gtk_widget_show (ld->icon_label); - - if (ld->entry->icon.type == LAUNCHER_ICON_TYPE_NAME) - g_free (ld->entry->icon.icon.name); - ld->entry->icon.icon.name = NULL; - - ld->entry->icon.type = LAUNCHER_ICON_TYPE_CATEGORY; - ld->entry->icon.icon.category = (XfceIconThemeCategory) n; - - pb = launcher_icon_load_pixbuf (ld->icon_img, &ld->entry->icon, - DLG_ICON_SIZE); - gtk_image_set_from_pixbuf (GTK_IMAGE (ld->icon_img), pb); - g_object_unref (G_OBJECT (pb)); - - if (ld->entry == g_ptr_array_index (ld->launcher->entries, 0)) - set_panel_icon (ld); - } + /* select the new item (also updates treeview buttons) */ + gtk_tree_view_set_cursor (GTK_TREE_VIEW (ld->treeview), path, NULL, FALSE); - gtk_widget_queue_draw (ld->tree); -} + /* update the panel */ + launcher_dialog_update_panel (ld); -static void -icon_browse (GtkWidget *b, LauncherDialog *ld) -{ - char *file, *path; - - path = - (ld->entry->icon.type == LAUNCHER_ICON_TYPE_NAME - && g_path_is_absolute (ld->entry->icon.icon.name)) ? - ld->entry->icon.icon.name : NULL; - - file = select_file_with_preview (_("Select image file"), path, ld->dlg, - TRUE); - - if (file && g_file_test (file, G_FILE_TEST_IS_REGULAR)) - { - GdkPixbuf *pb; - - gtk_entry_set_text (GTK_ENTRY (ld->icon_file), file); - gtk_editable_set_position (GTK_EDITABLE (ld->icon_file), -1); - update_entry_icon (ld); - - pb = launcher_icon_load_pixbuf (ld->icon_img, &ld->entry->icon, - DLG_ICON_SIZE); - gtk_image_set_from_pixbuf (GTK_IMAGE (ld->icon_img), pb); - g_object_unref (G_OBJECT (pb)); - - if (ld->entry == g_ptr_array_index (ld->launcher->entries, 0)) - set_panel_icon (ld); + /* cleanup */ + g_slist_free_all (file_list); } - g_free (file); + /* free path */ + if (G_LIKELY (path != NULL)) + gtk_tree_path_free (path); - gtk_widget_queue_draw (ld->tree); + /* finish drag */ + gtk_drag_finish (context, TRUE, FALSE, time); } -static void -icon_menu_browse (GtkWidget *mi, LauncherDialog *ld) -{ - gtk_widget_hide (ld->icon_label); - gtk_widget_show (ld->icon_file_align); - - update_entry_icon (ld); - if (ld->entry->icon.type != LAUNCHER_ICON_TYPE_NAME || - !ld->entry->icon.icon.name) - { - icon_browse (NULL, ld); - } -} -/* exec callback */ static void -exec_browse (GtkWidget *b, LauncherDialog *ld) +launcher_dialog_frame_drag_data_received (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint time, + LauncherDialog *ld) { - char *file; - - file = select_file_with_preview (_("Select command"), ld->entry->exec, - ld->dlg, FALSE); - - if (file) - { - gtk_entry_set_text (GTK_ENTRY (ld->exec), file); - gtk_editable_set_position (GTK_EDITABLE (ld->exec), -1); - update_entry_exec (ld); - } - - g_free (file); -} + GSList *file_list = NULL; + GSList *li; + gchar *file; -/* info widgets */ -static void -add_entry_info_options(LauncherDialog *ld, GtkBox *box, GtkSizeGroup *sg) -{ - GtkWidget *hbox, *label; - - hbox = gtk_hbox_new (FALSE, BORDER); - gtk_widget_show (hbox); - gtk_box_pack_start (box, hbox, FALSE, FALSE, 0); + /* create list from all the uri list */ + file_list = launcher_file_list_from_selection (selection_data); - label = gtk_label_new (_("Name")); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + if (G_LIKELY (file_list != NULL)) + { + for (li = file_list; li != NULL; li = li->next) + { + file = (gchar *) li->data; - gtk_size_group_add_widget (sg, label); + /* try to update the current entry settings */ + if (G_LIKELY (launcher_dialog_read_desktop_file (file, ld->entry) == TRUE)) + { + /* update the widgets */ + launcher_dialog_update_entries (ld); - ld->exec_name = gtk_entry_new (); - gtk_widget_show (ld->exec_name); - gtk_box_pack_start (GTK_BOX (hbox), ld->exec_name, TRUE, TRUE, 0); + /* update the tree */ + launcher_dialog_tree_update_row (ld, COL_TEXT); + launcher_dialog_tree_update_row (ld, COL_ICON); - g_signal_connect (ld->exec_name, "focus-out-event", - G_CALLBACK (entry_lost_focus), ld); - - hbox = gtk_hbox_new (FALSE, BORDER); - gtk_widget_show (hbox); - gtk_box_pack_start (box, hbox, FALSE, FALSE, 0); + /* update the panel */ + launcher_dialog_update_panel (ld); - label = gtk_label_new (_("Description")); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + /* stop trying */ + break; + } + } - gtk_size_group_add_widget (sg, label); + /* cleanup */ + g_slist_free_all (file_list); + } - ld->exec_comment = gtk_entry_new (); - gtk_widget_show (ld->exec_comment); - gtk_box_pack_start (GTK_BOX (hbox), ld->exec_comment, TRUE, TRUE, 0); - gtk_widget_set_size_request (ld->exec_comment, 300, -1); - - g_signal_connect (ld->exec_comment, "focus-out-event", - G_CALLBACK (entry_lost_focus), ld); + /* finish drag */ + gtk_drag_finish (context, TRUE, FALSE, time); } -/* icon widgets */ -static GtkWidget * -create_icon_category_menu (LauncherDialog *ld) -{ - GtkWidget *menu, *mi, *img; - GdkPixbuf *pb; - int i; - LauncherIcon icon; - - menu = gtk_menu_new (); - - g_signal_connect (menu, "deactivate", - G_CALLBACK (icon_menu_deactivated), ld); - - icon.type = LAUNCHER_ICON_TYPE_CATEGORY; - - for (i = 1; i < NUM_CATEGORIES; ++i) - { - mi = gtk_image_menu_item_new_with_label (_(category_icons[i])); - gtk_widget_show (mi); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - g_object_set_data (G_OBJECT (mi), "category", GINT_TO_POINTER (i)); - g_signal_connect (mi, "activate", - G_CALLBACK (icon_menu_activated), ld); +/** + * Properties update and save functions + **/ +static void +launcher_dialog_update_panel (LauncherDialog *ld) +{ + g_idle_add ((GSourceFunc) launcher_button_update, ld->launcher); + g_idle_add ((GSourceFunc) launcher_menu_prepare, ld->launcher); +} - icon.icon.category = i; - pb = launcher_icon_load_pixbuf (mi, &icon, MENU_ICON_SIZE); - img = gtk_image_new_from_pixbuf (pb); - gtk_widget_show (img); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img); - g_object_unref (G_OBJECT (pb)); - } - mi = gtk_separator_menu_item_new (); - gtk_widget_show (mi); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - - mi = gtk_menu_item_new_with_label (_("Other...")); - gtk_widget_show (mi); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - - g_signal_connect (mi, "activate", - G_CALLBACK (icon_menu_browse), ld); - - gtk_menu_set_screen (GTK_MENU (menu), - gtk_widget_get_screen (ld->launcher->iconbutton)); - - return menu; -} static void -add_entry_icon_options (LauncherDialog *ld, GtkBox *box, GtkSizeGroup *sg) +launcher_dialog_save_entry (GtkWidget *entry, + LauncherDialog *ld) { - GtkWidget *hbox, *hbox2, *arrow, *align, *img; - - hbox = gtk_hbox_new (FALSE, BORDER); - gtk_widget_show (hbox); - gtk_box_pack_start (box, hbox, FALSE, FALSE, 0); + const gchar *text; - ld->icon_button = gtk_toggle_button_new (); - gtk_widget_show (ld->icon_button); - gtk_box_pack_start (GTK_BOX (hbox), ld->icon_button, FALSE, FALSE, 0); + /* quit if locked or no active entry set */ + if (G_UNLIKELY (ld->updating == TRUE || ld->entry == NULL)) + return; - gtk_size_group_add_widget (sg, ld->icon_button); + /* get entry text */ + text = gtk_entry_get_text (GTK_ENTRY (entry)); - ld->icon_category = create_icon_category_menu (ld); + /* set text to null, if there is no valid text */ + if (G_UNLIKELY (text == NULL || *text == '\0')) + text = NULL; - g_signal_connect (ld->icon_button, "toggled", - G_CALLBACK (popup_icon_menu), ld); - - hbox2 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox2); - gtk_container_add (GTK_CONTAINER (ld->icon_button), hbox2); + /* save new value */ + if (entry == ld->entry_name) + { + g_free (ld->entry->name); + ld->entry->name = g_strdup (text); - ld->icon_img = gtk_image_new (); - gtk_widget_show (ld->icon_img); - gtk_box_pack_start (GTK_BOX (hbox2), ld->icon_img, TRUE, TRUE, 0); + /* update tree, when triggered by widget */ + launcher_dialog_tree_update_row (ld, COL_TEXT); + } + else if (entry == ld->entry_comment) + { + g_free (ld->entry->comment); + ld->entry->comment = g_strdup (text); + } + else if (entry == ld->entry_exec) + { + g_free (ld->entry->exec); + ld->entry->exec = launcher_dialog_parse_exec (text); + } + else if (entry == ld->entry_path) + { + g_free (ld->entry->path); + ld->entry->path = text ? xfce_expand_variables (text, NULL) : NULL; + } - arrow = gtk_arrow_new (GTK_ARROW_UP, GTK_SHADOW_IN); - gtk_widget_show (arrow); - gtk_box_pack_start (GTK_BOX (hbox2), arrow, TRUE, TRUE, 0); - - align = ld->icon_file_align = gtk_alignment_new (0, 0.5, 1, 0); - gtk_box_pack_start (GTK_BOX (hbox), align, TRUE, TRUE, 0); - - hbox2 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox2); - gtk_container_add (GTK_CONTAINER (align), hbox2); - - ld->icon_file = gtk_entry_new (); - gtk_widget_show (ld->icon_file); - gtk_box_pack_start (GTK_BOX (hbox2), ld->icon_file, TRUE, TRUE, 0); - - g_signal_connect (ld->icon_file, "focus-out-event", - G_CALLBACK (entry_lost_focus), ld); - - ld->icon_browse = gtk_button_new (); - gtk_widget_show (ld->icon_browse); - gtk_box_pack_start (GTK_BOX (hbox2), ld->icon_browse, FALSE, FALSE, 0); - - g_signal_connect (ld->icon_browse, "clicked", G_CALLBACK (icon_browse), - ld); - - img = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON); - gtk_widget_show (img); - gtk_container_add (GTK_CONTAINER (ld->icon_browse), img); - - ld->icon_label = gtk_label_new (NULL); - gtk_misc_set_alignment (GTK_MISC (ld->icon_label), 0, 0.5); - - gtk_box_pack_start (GTK_BOX (hbox), ld->icon_label, TRUE, TRUE, 0); - - launcher_set_drag_dest (ld->icon_button); - g_signal_connect (ld->icon_button, "drag-data-received", - G_CALLBACK (icon_entry_data_received), ld); - - launcher_set_drag_dest (ld->icon_file); - g_signal_connect (ld->icon_file, "drag-data-received", - G_CALLBACK (icon_entry_data_received), ld); - - launcher_set_drag_dest (ld->icon_browse); - g_signal_connect (ld->icon_browse, "drag-data-received", - G_CALLBACK (icon_entry_data_received), ld); + /* update panel */ + launcher_dialog_update_panel (ld); } -/* exec widgets */ + + static void -add_entry_exec_options (LauncherDialog *ld, GtkBox *box, GtkSizeGroup *sg) +launcher_dialog_save_button (GtkWidget *button, + LauncherDialog *ld) { - GtkWidget *hbox, *label, *button, *img; + gboolean active; - hbox = gtk_hbox_new (FALSE, BORDER); - gtk_widget_show (hbox); - gtk_box_pack_start (box, hbox, FALSE, FALSE, 0); + /* quit if locked or no active entry set */ + if (G_UNLIKELY (ld->updating == TRUE || ld->entry == NULL)) + return; - label = gtk_label_new (_("Command")); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + /* get toggle button state */ + active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - gtk_size_group_add_widget (sg, label); + /* update entry or global setting */ + if (button == ld->entry_terminal) + { + ld->entry->terminal = active; +#ifdef HAVE_LIBSTARTUP_NOTIFICATION + gtk_widget_set_sensitive (ld->entry_startup, !active); +#endif + } +#ifdef HAVE_LIBSTARTUP_NOTIFICATION + else if (button == ld->entry_startup) + ld->entry->startup = active; +#endif +} - ld->exec = gtk_entry_new (); - gtk_widget_show (ld->exec); - gtk_box_pack_start (GTK_BOX (hbox), ld->exec, TRUE, TRUE, 0); - - g_signal_connect (ld->exec, "focus-out-event", - G_CALLBACK (entry_lost_focus), ld); - ld->exec_browse = button = gtk_button_new (); - gtk_widget_show (button); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - g_signal_connect (ld->exec_browse, "clicked", G_CALLBACK (exec_browse), - ld); +static void +launcher_dialog_update_entries (LauncherDialog *ld) +{ + /* quit if locked or no active entry set */ + if (G_UNLIKELY (ld->updating == TRUE || ld->entry == NULL)) + return; - img = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON); - gtk_widget_show (img); - gtk_container_add (GTK_CONTAINER (button), img); + /* lock the save functions */ + ld->updating = TRUE; - hbox = gtk_hbox_new (FALSE, BORDER); - gtk_widget_show (hbox); - gtk_box_pack_start (box, hbox, FALSE, FALSE, 0); + /* set new entry values */ + gtk_entry_set_text (GTK_ENTRY (ld->entry_name), + (ld->entry->name != NULL) ? ld->entry->name : ""); - label = gtk_alignment_new (0, 0, 0, 0); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_entry_set_text (GTK_ENTRY (ld->entry_comment), + (ld->entry->comment != NULL) ? ld->entry->comment : ""); - gtk_size_group_add_widget (sg, label); + gtk_entry_set_text (GTK_ENTRY (ld->entry_exec), + (ld->entry->exec != NULL) ? ld->entry->exec : ""); - ld->exec_terminal = - gtk_check_button_new_with_mnemonic (_("Run in _terminal")); - gtk_widget_show (ld->exec_terminal); - gtk_box_pack_start (GTK_BOX (hbox), ld->exec_terminal, TRUE, TRUE, 0); + gtk_entry_set_text (GTK_ENTRY (ld->entry_path), + (ld->entry->path != NULL) ? ld->entry->path : ""); - g_signal_connect (ld->exec_terminal, "toggled", - G_CALLBACK (check_button_toggled), ld); + /* set toggle buttons */ + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ld->entry_terminal), + ld->entry->terminal); +#ifdef HAVE_LIBSTARTUP_NOTIFICATION + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ld->entry_startup), + ld->entry->startup); - hbox = gtk_hbox_new (FALSE, BORDER); - gtk_widget_show (hbox); - gtk_box_pack_start (box, hbox, FALSE, FALSE, 0); + gtk_widget_set_sensitive (ld->entry_startup, !ld->entry->terminal); +#endif - label = gtk_alignment_new (0, 0, 0, 0); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + /* update icon button */ + launcher_dialog_update_icon (ld); - gtk_size_group_add_widget (sg, label); + /* unlock */ + ld->updating = FALSE; +} - ld->exec_startup = - gtk_check_button_new_with_mnemonic (_("Use _startup notification")); - gtk_widget_show (ld->exec_startup); - gtk_box_pack_start (GTK_BOX (hbox), ld->exec_startup, TRUE, TRUE, 0); - g_signal_connect (ld->exec_startup, "toggled", - G_CALLBACK (check_button_toggled), ld); -} -/* entry properties */ static void -launcher_dialog_update_entry_properties (LauncherDialog *ld) +launcher_dialog_update_icon (LauncherDialog *ld) { - char *value; - GdkPixbuf *pb; - - ld->updating = TRUE; + GdkPixbuf *icon = NULL; + GtkWidget *child; - value = ld->entry->name ? ld->entry->name : ""; - gtk_entry_set_text (GTK_ENTRY (ld->exec_name), value); - - value = ld->entry->comment ? ld->entry->comment : ""; - gtk_entry_set_text (GTK_ENTRY (ld->exec_comment), value); - - value = ld->entry->exec ? ld->entry->exec : ""; - gtk_entry_set_text (GTK_ENTRY (ld->exec), value); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ld->exec_terminal), - ld->entry->terminal); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ld->exec_startup), - ld->entry->startup); + /* drop the previous button child */ + if (GTK_BIN (ld->entry_icon)->child != NULL) + gtk_widget_destroy (GTK_BIN (ld->entry_icon)->child); - pb = launcher_icon_load_pixbuf (ld->icon_img, &ld->entry->icon, - DLG_ICON_SIZE); - gtk_image_set_from_pixbuf (GTK_IMAGE (ld->icon_img), pb); - g_object_unref (G_OBJECT (pb)); + if (G_LIKELY (ld->entry->icon)) + icon = launcher_load_pixbuf (ld->entry_icon, ld->entry->icon, CHOOSER_ICON_SIZE, FALSE); - if (ld->entry->icon.type != LAUNCHER_ICON_TYPE_CATEGORY) - gtk_widget_show (ld->icon_file_align); - else - gtk_widget_hide (ld->icon_file_align); - - if (ld->entry->icon.type == LAUNCHER_ICON_TYPE_NAME && - ld->entry->icon.icon.name) - { - gtk_entry_set_text (GTK_ENTRY (ld->icon_file), - ld->entry->icon.icon.name); - } - else + /* create icon button */ + if (G_LIKELY (icon != NULL)) { - gtk_entry_set_text (GTK_ENTRY (ld->icon_file), ""); - } + child = gtk_image_new_from_pixbuf (icon); - if (ld->entry->icon.type == LAUNCHER_ICON_TYPE_CATEGORY) - { - gtk_label_set_text (GTK_LABEL (ld->icon_label), - _(category_icons [ld->entry->icon.icon.category])); - gtk_widget_show (ld->icon_label); + /* release icon */ + g_object_unref (G_OBJECT (icon)); } else { - gtk_widget_hide (ld->icon_label); + child = gtk_label_new (_("No icon")); + + gtk_widget_set_size_request (child, -1, CHOOSER_ICON_SIZE); } - - ld->updating = FALSE; + + gtk_container_add (GTK_CONTAINER (ld->entry_icon), child); + gtk_widget_show (child); } + + +/** + * Icon and command search dialogs + **/ static void -launcher_dialog_add_entry_properties (LauncherDialog *ld, GtkBox *box) +launcher_dialog_folder_chooser (LauncherDialog *ld) { - GtkWidget *frame, *vbox, *align; - GtkSizeGroup *sg; - - frame = gtk_frame_new (NULL); - gtk_widget_show (frame); - gtk_box_pack_start (GTK_BOX (box), frame, TRUE, TRUE, 0); - - vbox = gtk_vbox_new (FALSE, BORDER); - gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER); - gtk_widget_show (vbox); - gtk_container_add (GTK_CONTAINER (frame), vbox); + GtkWidget *chooser; + gchar *path; - sg = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + chooser = gtk_file_chooser_dialog_new (_("Select a Directory"), + NULL, + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); - add_entry_info_options (ld, GTK_BOX (vbox), sg); + /* only here */ + gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), TRUE); - align = gtk_alignment_new (0, 0, 0, 0); - gtk_widget_show (align); - gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0); - gtk_widget_set_size_request (align, BORDER, BORDER); - - add_entry_icon_options (ld, GTK_BOX (vbox), sg); + /* use the bindir as default folder */ + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), BINDIR); - align = gtk_alignment_new (0, 0, 0, 0); - gtk_widget_show (align); - gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0); - gtk_widget_set_size_request (align, BORDER, BORDER); - - add_entry_exec_options (ld, GTK_BOX (vbox), sg); - - g_object_unref (G_OBJECT (sg)); - - launcher_dialog_update_entry_properties (ld); - - launcher_set_drag_dest (frame); - g_signal_connect (frame, "drag-data-received", - G_CALLBACK (entry_dialog_data_received), ld); -} + /* select folder from field */ + if (G_LIKELY (ld->entry->path != NULL)) + { + if (G_LIKELY (g_path_is_absolute (ld->entry->path))) + gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (chooser), ld->entry->path); + } + /* run the chooser dialog */ + if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT) + { + path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); -/* LauncherPlugin Dialog * - * --------------------- */ + /* set the new entry text */ + gtk_entry_set_text (GTK_ENTRY (ld->entry_path), path); -/* treeview */ -static void -treeview_destroyed (GtkWidget * tv) -{ - GtkTreeModel *store; + /* cleanup */ + g_free (path); + } - store = gtk_tree_view_get_model (GTK_TREE_VIEW (tv)); - gtk_list_store_clear (GTK_LIST_STORE (store)); + /* destroy dialog */ + gtk_widget_destroy (chooser); } static void -cursor_changed (GtkTreeView * tv, LauncherDialog *ld) +launcher_dialog_command_chooser (LauncherDialog *ld) { - GtkTreeSelection *sel; - GtkTreeModel *model; - GtkTreeIter iter; - LauncherEntry *e; - - /* update current item */ - update_entry_info (ld); - update_entry_exec (ld); - if (ld->entry->icon.type != LAUNCHER_ICON_TYPE_CATEGORY) - update_entry_icon (ld); - - sel = gtk_tree_view_get_selection (tv); - gtk_tree_selection_get_selected (sel, &model, &iter); - - gtk_tree_model_get (model, &iter, 0, &e, -1); - - if (e) + GtkFileFilter *filter; + GtkWidget *chooser; + gchar *filename; + gchar *s; + + chooser = gtk_file_chooser_dialog_new (_("Select an Application"), + NULL, + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), TRUE); + + /* add file chooser filters */ + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("All Files")); + gtk_file_filter_add_pattern (filter, "*"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter); + + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("Executable Files")); + gtk_file_filter_add_mime_type (filter, "application/x-csh"); + gtk_file_filter_add_mime_type (filter, "application/x-executable"); + gtk_file_filter_add_mime_type (filter, "application/x-perl"); + gtk_file_filter_add_mime_type (filter, "application/x-python"); + gtk_file_filter_add_mime_type (filter, "application/x-ruby"); + gtk_file_filter_add_mime_type (filter, "application/x-shellscript"); + gtk_file_filter_add_pattern (filter, "*.pl"); + gtk_file_filter_add_pattern (filter, "*.py"); + gtk_file_filter_add_pattern (filter, "*.rb"); + gtk_file_filter_add_pattern (filter, "*.sh"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter); + gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), filter); + + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("Perl Scripts")); + gtk_file_filter_add_mime_type (filter, "application/x-perl"); + gtk_file_filter_add_pattern (filter, "*.pl"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter); + + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("Python Scripts")); + gtk_file_filter_add_mime_type (filter, "application/x-python"); + gtk_file_filter_add_pattern (filter, "*.py"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter); + + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("Ruby Scripts")); + gtk_file_filter_add_mime_type (filter, "application/x-ruby"); + gtk_file_filter_add_pattern (filter, "*.rb"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter); + + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("Shell Scripts")); + gtk_file_filter_add_mime_type (filter, "application/x-csh"); + gtk_file_filter_add_mime_type (filter, "application/x-shellscript"); + gtk_file_filter_add_pattern (filter, "*.sh"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter); + + /* use the bindir as default folder */ + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), BINDIR); + + /* get the current command */ + filename = gtk_editable_get_chars (GTK_EDITABLE (ld->entry_exec), 0, -1); + if (G_LIKELY (filename != NULL)) { - int i; - - ld->entry = e; + /* use only the first argument */ + s = strchr (filename, ' '); + if (G_UNLIKELY (s != NULL)) + *s = '\0'; - gtk_widget_set_sensitive (ld->up, TRUE); - gtk_widget_set_sensitive (ld->down, TRUE); - gtk_widget_set_sensitive (ld->remove, - (ld->launcher->entries->len > 1)); - - for (i = 0; i < ld->launcher->entries->len; ++i) + /* check if we have a file name */ + if (G_LIKELY (*filename != '\0')) { - LauncherEntry *tmp = g_ptr_array_index (ld->launcher->entries, i); - - if (tmp != e) - continue; - - if (i == 0) + /* check if the filename is not an absolute path */ + if (G_LIKELY (!g_path_is_absolute (filename))) { - gtk_widget_set_sensitive (ld->up, FALSE); + /* try to lookup the filename in $PATH */ + s = g_find_program_in_path (filename); + if (G_LIKELY (s != NULL)) + { + /* use the absolute path instead */ + g_free (filename); + filename = s; + } } - - if (i == ld->launcher->entries->len - 1) - gtk_widget_set_sensitive (ld->down, FALSE); - break; + /* check if we have an absolute path now */ + if (G_LIKELY (g_path_is_absolute (filename))) + gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (chooser), filename); } + + /* release the filename */ + g_free (filename); } - else + + /* run the chooser dialog */ + if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT) { - gtk_widget_set_sensitive (ld->up, FALSE); - gtk_widget_set_sensitive (ld->down, FALSE); - gtk_widget_set_sensitive (ld->remove, FALSE); + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); + s = g_strconcat (filename, " %f", NULL); + + /* set the new entry text */ + gtk_entry_set_text (GTK_ENTRY (ld->entry_exec), s); + + /* cleanup */ + g_free (filename); + g_free (s); } - launcher_dialog_update_entry_properties (ld); + /* destroy dialog */ + gtk_widget_destroy (chooser); } + + static void -render_icon (GtkTreeViewColumn * col, GtkCellRenderer * cell, - GtkTreeModel * model, GtkTreeIter * iter, GtkWidget *tree) +launcher_dialog_icon_chooser (LauncherDialog *ld) { - LauncherEntry *entry; - GdkPixbuf *pb; + const gchar *name; + GtkWidget *chooser; + gchar *title; + + /* determine the name of the entry being edited */ + name = gtk_entry_get_text (GTK_ENTRY (ld->entry_name)); + if (G_UNLIKELY (name == NULL || *name == '\0')) + name = _("Unknown"); + + /* allocate the chooser dialog */ + title = g_strdup_printf (_("Select an Icon for \"%s\""), name); + chooser = exo_icon_chooser_dialog_new (title, NULL, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + NULL); + gtk_dialog_set_alternative_button_order (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT, GTK_RESPONSE_CANCEL, -1); + gtk_dialog_set_default_response (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT); + g_free (title); + + /* set the current icon, if there is any */ + if (G_LIKELY (ld->entry->icon)) + exo_icon_chooser_dialog_set_icon (EXO_ICON_CHOOSER_DIALOG (chooser), ld->entry->icon); + + /* run the icon chooser dialog */ + if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT) + { + /* free the old icon name */ + if (G_LIKELY (ld->entry->icon)) + g_free (ld->entry->icon); - gtk_tree_model_get (model, iter, 0, &entry, -1); + /* set new icon */ + ld->entry->icon = exo_icon_chooser_dialog_get_icon (EXO_ICON_CHOOSER_DIALOG (chooser)); - if (entry) - { - pb = launcher_icon_load_pixbuf (tree, &entry->icon, DLG_ICON_SIZE); - g_object_set (cell, "pixbuf", pb, NULL); - g_object_unref (G_OBJECT (pb)); - } - else - { - g_object_set (cell, "pixbuf", NULL, NULL); + /* update the icon button */ + launcher_dialog_update_icon (ld); + + /* update the icon column in the tree */ + launcher_dialog_tree_update_row (ld, COL_ICON); + + /* check if we need to update the icon button image */ + if (g_list_index (ld->launcher->entries, ld->entry) == 0) + ld->launcher->icon_update_required = TRUE; + + /* update the panel widgets */ + launcher_dialog_update_panel (ld); } + + /* destroy the chooser */ + gtk_widget_destroy (chooser); } + + +/** + * Tree functions + **/ static void -render_text (GtkTreeViewColumn * col, GtkCellRenderer * cell, - GtkTreeModel * model, GtkTreeIter * iter, GtkWidget * treeview) +launcher_dialog_tree_free_store (LauncherDialog *ld) { - LauncherEntry *entry; + /* clear the store */ + gtk_list_store_clear (ld->store); - gtk_tree_model_get (model, iter, 0, &entry, -1); - - if (entry) - g_object_set (cell, "markup", entry->name, NULL); - else - g_object_set (cell, "markup", "", NULL); + /* release the store */ + g_object_unref (G_OBJECT (ld->store)); } + + static void -launcher_dialog_add_item_tree (LauncherDialog *ld, GtkBox *box) +launcher_dialog_tree_update_row (LauncherDialog *ld, + gint column) { - GtkWidget *tv; - GtkCellRenderer *cell; - GtkTreeViewColumn *col; - GtkListStore *store; - GtkTreeModel *model; - GtkTreePath *path; - GtkTreeIter iter; - LauncherEntry *e; - int i; - - ld->scroll = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (ld->scroll); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ld->scroll), - GTK_POLICY_NEVER, - GTK_POLICY_NEVER); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (ld->scroll), - GTK_SHADOW_IN); - gtk_box_pack_start (box, ld->scroll, TRUE, TRUE, 0); - - store = gtk_list_store_new (1, G_TYPE_POINTER); - model = GTK_TREE_MODEL (store); - - ld->tree = tv = gtk_tree_view_new_with_model (model); - gtk_widget_show (tv); - gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tv), FALSE); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tv), FALSE); - gtk_container_add (GTK_CONTAINER (ld->scroll), tv); - - g_signal_connect (tv, "destroy", G_CALLBACK (treeview_destroyed), NULL); - - g_object_unref (G_OBJECT (store)); - - launcher_set_drag_dest (tv); - g_signal_connect (tv, "drag-data-received", - G_CALLBACK (launcher_dialog_data_received), ld); - - /* create the view */ - col = gtk_tree_view_column_new (); - gtk_tree_view_column_set_spacing (col, BORDER); - gtk_tree_view_append_column (GTK_TREE_VIEW (tv), col); - - cell = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (col, cell, FALSE); - gtk_tree_view_column_set_cell_data_func (col, cell, - (GtkTreeCellDataFunc) - render_icon, tv, NULL); - - cell = gtk_cell_renderer_text_new (); - gtk_tree_view_column_pack_start (col, cell, TRUE); - gtk_tree_view_column_set_cell_data_func (col, cell, - (GtkTreeCellDataFunc) - render_text, tv, NULL); - - /* fill model */ - for (i = 0; i < ld->launcher->entries->len; ++i) + GtkTreeSelection *selection; + GtkTreeIter iter; + GdkPixbuf *icon = NULL; + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ld->treeview)); + + if (G_LIKELY (gtk_tree_selection_get_selected (selection, NULL, &iter))) { - if (i == 7) + switch (column) { - GtkRequisition req; + case COL_ICON: + /* load entry icon */ + icon = launcher_load_pixbuf (ld->treeview, ld->entry->icon, TREE_ICON_SIZE, TRUE); - gtk_widget_size_request (tv, &req); + /* set new icon */ + gtk_list_store_set (ld->store, &iter, + COL_ICON, icon, + -1); - gtk_widget_set_size_request (tv, -1, req.height); + /* release icon */ + if (G_LIKELY (icon != NULL)) + g_object_unref (G_OBJECT (icon)); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ld->scroll), - GTK_POLICY_NEVER, - GTK_POLICY_ALWAYS); - } + break; + + case COL_TEXT: + /* set new name */ + gtk_list_store_set (ld->store, &iter, + COL_TEXT, ld->entry->name, + -1); - e = g_ptr_array_index (ld->launcher->entries, i); - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, e, -1); + break; + } } +} - path = gtk_tree_path_new_from_string ("0"); - gtk_tree_view_set_cursor (GTK_TREE_VIEW (tv), path, NULL, FALSE); - gtk_tree_path_free (path); - g_signal_connect (tv, "cursor_changed", G_CALLBACK (cursor_changed), ld); -} -/* treeview buttons */ static void -launcher_dialog_add_entry_after (LauncherDialog *ld, GtkTreeIter *prev_iter, - LauncherEntry *new_e) +launcher_dialog_tree_selection_changed (LauncherDialog *ld, + GtkTreeSelection *selection) { - LauncherEntry *e = NULL; - GtkTreeIter iter; GtkTreeModel *model; - GtkTreePath *path; - - g_return_if_fail (new_e != NULL); + GtkTreePath *path; + GtkTreeIter iter; + gboolean selected; + gint position = 0; + gint items; - if (ld->launcher->entries->len == 6) - { - GtkRequisition req; + if (G_UNLIKELY (ld->updating == TRUE)) + return; - gtk_widget_size_request (ld->tree, &req); + g_return_if_fail (GTK_IS_TREE_SELECTION (selection)); - gtk_widget_set_size_request (ld->tree, -1, req.height); + /* check if we have currently selected an item */ + selected = gtk_tree_selection_get_selected (selection, &model, &iter); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ld->scroll), - GTK_POLICY_NEVER, - GTK_POLICY_ALWAYS); - } - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (ld->tree)); - - if (prev_iter) - gtk_tree_model_get (model, prev_iter, 0, &e, -1); - - if (!e) + if (G_LIKELY (selected)) { - g_ptr_array_add (ld->launcher->entries, new_e); - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, new_e, -1); - } - else - { - int i; + /* determine the path for the selected iter */ + path = gtk_tree_model_get_path (model, &iter); - g_ptr_array_add (ld->launcher->entries, NULL); - - for (i = ld->launcher->entries->len; i > 0; --i) - { - LauncherEntry *tmp = - g_ptr_array_index (ld->launcher->entries, i - 1); + /* get position */ + position = gtk_tree_path_get_indices (path)[0]; - if (tmp == e) - { - ld->launcher->entries->pdata[i] = new_e; - break; - } - - ld->launcher->entries->pdata[i] = tmp; - } + /* set new active entry */ + ld->entry = (LauncherEntry *) g_list_nth (ld->launcher->entries, position)->data; - gtk_list_store_insert_after (GTK_LIST_STORE (model), &iter, - prev_iter); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, new_e, -1); + /* update fields */ + launcher_dialog_update_entries (ld); + + /* scroll new item to center of window */ + gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (ld->treeview), path, NULL, + TRUE, 0.5, 0.0); + + /* release path */ + gtk_tree_path_free (path); } - path = gtk_tree_model_get_path (model, &iter); - gtk_tree_view_set_cursor (GTK_TREE_VIEW (ld->tree), path, NULL, FALSE); - gtk_tree_path_free (path); + /* items in the list */ + items = gtk_tree_model_iter_n_children (model, NULL); - gtk_widget_show (ld->launcher->arrowbutton); + /* change sensitivity of buttons */ + gtk_widget_set_sensitive (ld->up, selected && (position > 0)); + gtk_widget_set_sensitive (ld->down, selected && (position < items - 1)); + gtk_widget_set_sensitive (ld->remove, selected && (items > 1)); } -static void -tree_button_clicked (GtkWidget *b, LauncherDialog *ld) -{ - GtkTreeSelection *sel; - GtkTreeModel *model; - GtkTreeIter iter, iter2; - GtkTreePath *path; - LauncherEntry *e; - int i; - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (ld->tree)); - gtk_tree_selection_get_selected (sel, &model, &iter); - gtk_tree_model_get (model, &iter, 0, &e, -1); +static void +launcher_dialog_tree_button_clicked (GtkWidget *button, + LauncherDialog *ld) +{ + GtkTreeSelection *selection; + GtkTreeModel *model; + GtkTreePath *path; + GtkTreeIter iter_a; + GtkTreeIter iter_b; + guint position; + GList *li; + GdkPixbuf *icon = NULL; + LauncherEntry *entry; + + /* get the selected items in the treeview */ + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ld->treeview)); + + /* get selected iter, quit if no iter found */ + if (G_UNLIKELY (gtk_tree_selection_get_selected (selection, &model, &iter_a) == FALSE)) + return; - if (b == ld->up) + /* run the requested button action */ + if (button == ld->up) { - if (!e) - return; + /* get path */ + path = gtk_tree_model_get_path (model, &iter_a); - path = gtk_tree_model_get_path (model, &iter); + /* position of the item in the list */ + position = gtk_tree_path_get_indices (path)[0]; - if (gtk_tree_path_prev (path) && - gtk_tree_model_get_iter (model, &iter2, path)) - { - gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &iter2); + /* check if we need to update the icon button image*/ + if (position == 1) + ld->launcher->icon_update_required = TRUE; - gtk_tree_view_set_cursor (GTK_TREE_VIEW (ld->tree), path, NULL, - FALSE); - - for (i = 1; i < ld->launcher->entries->len; ++i) - { - LauncherEntry *tmp = - g_ptr_array_index (ld->launcher->entries, i); - - if (tmp == e) - { - ld->launcher->entries->pdata[i] = - ld->launcher->entries->pdata[i-1]; - ld->launcher->entries->pdata[i-1] = tmp; + /* get previous path */ + if (G_LIKELY (gtk_tree_path_prev (path))) + { + /* get iter for previous item */ + gtk_tree_model_get_iter (model, &iter_b, path); - if (i == 1) - set_panel_icon (ld); + /* swap the entries */ + gtk_list_store_swap (ld->store, &iter_a, &iter_b); - break; - } - } + /* swap items in the list */ + li = g_list_nth (ld->launcher->entries, position); + launcher_g_list_swap (li, li->prev); } - + + /* release the path */ gtk_tree_path_free (path); + + /* update tree view */ + launcher_dialog_tree_selection_changed (ld, selection); } - else if (b == ld->down) + else if (button == ld->down) { - if (!e) - return; + /* get path of selected item */ + path = gtk_tree_model_get_path (model, &iter_a); - path = gtk_tree_model_get_path (model, &iter); - gtk_tree_path_next (path); - - if (gtk_tree_model_get_iter (model, &iter2, path)) - { - gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &iter2); + /* get position of item we're going to move */ + position = gtk_tree_path_get_indices (path)[0]; - gtk_tree_view_set_cursor (GTK_TREE_VIEW (ld->tree), path, NULL, - FALSE); + /* check if we need to update the icon button image*/ + if (position == 0) + ld->launcher->icon_update_required = TRUE; - for (i = 0; i < ld->launcher->entries->len - 1; ++i) - { - LauncherEntry *tmp = - g_ptr_array_index (ld->launcher->entries, i); - - if (tmp == e) - { - ld->launcher->entries->pdata[i] = - ld->launcher->entries->pdata[i+1]; - ld->launcher->entries->pdata[i+1] = tmp; + /* get next item in the list */ + gtk_tree_path_next (path); - if (i == 0) - set_panel_icon (ld); + /* get next iter */ + if (G_LIKELY (gtk_tree_model_get_iter (model, &iter_b, path))) + { + /* swap the entries */ + gtk_list_store_swap (ld->store, &iter_a, &iter_b); - break; - } - } + /* swap items in the list */ + li = g_list_nth (ld->launcher->entries, position); + launcher_g_list_swap (li, li->next); } + /* release the path */ gtk_tree_path_free (path); + + /* update tree view */ + launcher_dialog_tree_selection_changed (ld, selection); } - else if (b == ld->add) + else if (button == ld->add) { - LauncherEntry *e2; - - e2 = launcher_entry_new (); - e2->name = g_strdup (_("New Item")); - - launcher_dialog_add_entry_after (ld, &iter, e2); + /* create new entry */ + entry = launcher_new_entry (); + + /* load new launcher icon */ + icon = launcher_load_pixbuf (ld->treeview, entry->icon, TREE_ICON_SIZE, TRUE); + + /* append new entry */ + gtk_list_store_insert_after (ld->store, &iter_b, &iter_a); + gtk_list_store_set (ld->store, &iter_b, + COL_ICON, icon, + COL_TEXT, entry->name, + -1); + + /* release the pixbuf */ + if (G_LIKELY (icon != NULL)) + g_object_unref (G_OBJECT (icon)); + + /* get path of new item */ + path = gtk_tree_model_get_path (model, &iter_b); + + /* position in the list */ + position = gtk_tree_path_get_indices (path)[0]; + + /* insert in list */ + ld->launcher->entries = g_list_insert (ld->launcher->entries, + entry, position); + + /* select the new item (also updates treeview buttons) */ + gtk_tree_view_set_cursor (GTK_TREE_VIEW (ld->treeview), path, NULL, FALSE); + + /* cleanup */ + gtk_tree_path_free (path); + } - else if (b == ld->remove) + else if (button == ld->remove) { - gboolean is_first; - - if (!e) - return; + /* path from row to remove */ + path = gtk_tree_model_get_path (model, &iter_a); - if (gtk_list_store_remove (GTK_LIST_STORE (model), &iter)) - { - path = gtk_tree_model_get_path (model, &iter); - } - else - { - char last[3]; + /* get position of the item to remove */ + position = gtk_tree_path_get_indices (path)[0]; - g_snprintf (last, 3, "%d", ld->launcher->entries->len - 2); - path = gtk_tree_path_new_from_string (last); - } - - gtk_tree_view_set_cursor (GTK_TREE_VIEW (ld->tree), path, NULL, FALSE); - - gtk_tree_path_free (path); - - is_first = (e == g_ptr_array_index (ld->launcher->entries, 0)); + /* check if we need to update the icon button image*/ + if (position == 0) + ld->launcher->icon_update_required = TRUE; - g_ptr_array_remove (ld->launcher->entries, e); - launcher_entry_free (e); - - if (ld->launcher->entries->len == 1) - { - gtk_widget_hide (ld->launcher->arrowbutton); - gtk_widget_set_sensitive (ld->remove, FALSE); - } + /* lock */ + ld->updating = TRUE; + + /* remove active entry */ + launcher_free_entry (ld->entry, ld->launcher); + ld->entry = NULL; + + /* remove row from store */ + gtk_list_store_remove (ld->store, &iter_a); + + /* unlock */ + ld->updating = FALSE; - if (is_first) - set_panel_icon (ld); + /* select previous item, if last item was removed */ + if (position >= g_list_length (ld->launcher->entries)) + gtk_tree_path_prev (path); + + /* select the new item (also updates treeview buttons) */ + gtk_tree_view_set_cursor (GTK_TREE_VIEW (ld->treeview), path, NULL, FALSE); + + /* cleanup */ + gtk_tree_path_free (path); } - cursor_changed (GTK_TREE_VIEW (ld->tree), ld); + /* update panel */ + launcher_dialog_update_panel (ld); } -static void -launcher_dialog_add_buttons (LauncherDialog *ld, GtkBox *box) + + +/** + * Launcher dialog widgets + **/ +static GtkWidget * +launcher_dialog_add_properties (LauncherDialog *ld) { - GtkWidget *hbox, *b, *align, *img; + GtkWidget *frame, *vbox, *hbox; + GtkWidget *label, *button, *image; + GtkSizeGroup *sg; - hbox = gtk_hbox_new (FALSE, BORDER); - gtk_widget_show (hbox); - gtk_box_pack_start (box, hbox, FALSE, FALSE, 0); - - ld->up = b = gtk_button_new (); - gtk_button_set_focus_on_click (GTK_BUTTON (b), FALSE); - gtk_widget_show (b); - gtk_box_pack_start (GTK_BOX (hbox), b, FALSE, FALSE, 0); - img = gtk_image_new_from_stock (GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON); - gtk_widget_show (img); - gtk_container_add (GTK_CONTAINER (b), img); - - g_signal_connect (b, "clicked", G_CALLBACK (tree_button_clicked), ld); - - gtk_widget_set_sensitive (b, FALSE); - - ld->down = b = gtk_button_new (); - gtk_button_set_focus_on_click (GTK_BUTTON (b), FALSE); - gtk_widget_show (b); - gtk_box_pack_start (GTK_BOX (hbox), b, FALSE, FALSE, 0); - img = gtk_image_new_from_stock (GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON); - gtk_widget_show (img); - gtk_container_add (GTK_CONTAINER (b), img); - - g_signal_connect (b, "clicked", G_CALLBACK (tree_button_clicked), ld); + frame = gtk_frame_new (NULL); - align = gtk_alignment_new (0, 0, 0, 0); - gtk_widget_show (align); - gtk_widget_set_size_request (align, 1, 1); - gtk_box_pack_start (GTK_BOX (hbox), align, FALSE, FALSE, 0); - - ld->add = b = gtk_button_new (); - gtk_button_set_focus_on_click (GTK_BUTTON (b), FALSE); - gtk_widget_show (b); - gtk_box_pack_start (GTK_BOX (hbox), b, FALSE, FALSE, 0); - img = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON); - gtk_widget_show (img); - gtk_container_add (GTK_CONTAINER (b), img); - - g_signal_connect (b, "clicked", G_CALLBACK (tree_button_clicked), ld); - - ld->remove = b = gtk_button_new (); - gtk_button_set_focus_on_click (GTK_BUTTON (b), FALSE); - gtk_widget_show (b); - gtk_box_pack_start (GTK_BOX (hbox), b, FALSE, FALSE, 0); - img = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_BUTTON); - gtk_widget_show (img); - gtk_container_add (GTK_CONTAINER (b), img); - - g_signal_connect (b, "clicked", G_CALLBACK (tree_button_clicked), ld); - - gtk_widget_set_sensitive (b, FALSE); -} + vbox = gtk_vbox_new (FALSE, BORDER); + gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER); + gtk_container_add (GTK_CONTAINER (frame), vbox); -/* explanation */ -static void -launcher_dialog_add_explanation (GtkBox *box) -{ - GtkWidget *hbox, *img, *label; + sg = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + /* entry name field */ hbox = gtk_hbox_new (FALSE, BORDER); - gtk_container_set_border_width (GTK_CONTAINER (hbox), BORDER - 2); - gtk_widget_show (hbox); - gtk_box_pack_start (box, hbox, FALSE, FALSE, 0); - - img = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, - GTK_ICON_SIZE_LARGE_TOOLBAR); - gtk_misc_set_alignment (GTK_MISC (img), 0, 0); - gtk_widget_show (img); - gtk_box_pack_start (GTK_BOX (hbox), img, FALSE, FALSE, 0); - - label = - gtk_label_new (_("The first item in the list is shown on the panel. " - "Additional items will appear in a menu.")); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); -} + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); -/* launcher plugin dialog */ -static void -launcher_dialog_response (GtkWidget *dlg, int response, LauncherDialog *ld) -{ - g_object_set_data (G_OBJECT (ld->plugin), "dialog", NULL); - g_object_set_data (G_OBJECT (ld->plugin), "launcher-dialog", NULL); + label = gtk_label_new_with_mnemonic (_("_Name")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_widget_hide (dlg); - - launcher_update_panel_entry (ld->launcher); - launcher_recreate_menu (ld->launcher); - - gtk_widget_destroy (ld->icon_category); - gtk_widget_destroy (dlg); + gtk_size_group_add_widget (sg, label); - xfce_panel_plugin_unblock_menu (ld->plugin); + ld->entry_name = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (hbox), ld->entry_name, TRUE, TRUE, 0); - launcher_save (ld->plugin, ld->launcher); - - panel_slice_free (LauncherDialog, ld); -} + gtk_label_set_mnemonic_widget (GTK_LABEL (label), ld->entry_name); -void -launcher_properties_dialog (XfcePanelPlugin *plugin, LauncherPlugin * launcher) -{ - LauncherDialog *ld; - GtkWidget *vbox, *hbox; + g_signal_connect (G_OBJECT (ld->entry_name), "changed", + G_CALLBACK (launcher_dialog_save_entry), ld); - ld = panel_slice_new0 (LauncherDialog); - - ld->plugin = plugin; - ld->launcher = launcher; - ld->entry = g_ptr_array_index (launcher->entries, 0); - - xfce_panel_plugin_block_menu (ld->plugin); - - ld->dlg = xfce_titled_dialog_new_with_buttons (_("Program Launcher"), NULL, - GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, - GTK_STOCK_CLOSE, GTK_RESPONSE_OK, - NULL); - - g_object_set_data (G_OBJECT (plugin), "dialog", ld->dlg); - g_object_set_data (G_OBJECT (plugin), "launcher-dialog", ld); - - gtk_window_set_position (GTK_WINDOW (ld->dlg), GTK_WIN_POS_CENTER); - gtk_window_set_icon_name (GTK_WINDOW (ld->dlg), "xfce4-settings"); - - gtk_container_set_border_width (GTK_CONTAINER (ld->dlg), 2); - - launcher_dialog_add_explanation (GTK_BOX (GTK_DIALOG (ld->dlg)->vbox)); - + /* entry comment field */ hbox = gtk_hbox_new (FALSE, BORDER); - gtk_container_set_border_width (GTK_CONTAINER (hbox), BORDER - 2); - gtk_widget_show (hbox); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (ld->dlg)->vbox), hbox, - TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - vbox = gtk_vbox_new (FALSE, BORDER); - gtk_widget_show (vbox); - gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); - - launcher_dialog_add_item_tree (ld, GTK_BOX (vbox)); + label = gtk_label_new_with_mnemonic (_("_Description")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - launcher_dialog_add_buttons (ld, GTK_BOX (vbox)); + gtk_size_group_add_widget (sg, label); - launcher_dialog_add_entry_properties (ld, GTK_BOX (hbox)); - - cursor_changed (GTK_TREE_VIEW (ld->tree), ld); + ld->entry_comment = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (hbox), ld->entry_comment, TRUE, TRUE, 0); + gtk_widget_set_size_request (ld->entry_comment, 300, -1); - g_signal_connect (ld->dlg, "response", - G_CALLBACK (launcher_dialog_response), ld); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), ld->entry_comment); - gtk_widget_show (ld->dlg); -} + g_signal_connect (G_OBJECT (ld->entry_comment), "changed", + G_CALLBACK (launcher_dialog_save_entry), ld); + /* entry icon chooser button */ + hbox = gtk_hbox_new (FALSE, BORDER); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); -/* DND * - * --- */ + label = gtk_label_new_with_mnemonic (_("_Icon")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); -static const char *dentry_keys [] = { - "Name", - "GenericName", - "Comment", - "Exec", - "Icon", - "Terminal", - "StartupNotify", - "OnlyShowIn" -}; + gtk_size_group_add_widget (sg, label); -static LauncherEntry * -launcher_entry_update_from_interface (LauncherEntry *e, const char *iface) -{ - const gchar *argv[] = {"python", "-c", - "import sys;" - "from zeroinstall.injector.iface_cache import iface_cache;" - "iface = iface_cache.get_interface(sys.argv[1]);" - "print iface.name;" - "print iface.summary.replace('\\n', ' ');" - "hasattr(iface_cache, 'get_icon_path') and " - " sys.stdout.write(iface_cache.get_icon_path(iface));", - NULL, NULL}; - GError *error = NULL; - char *child_stdout = NULL; - - /* Set the command to "0launch iface" */ - g_free (e->exec); - g_free (e->real_exec); - - e->exec = g_strconcat ("0launch ", iface, NULL); - e->real_exec = g_strdup (e->exec); - - /* Get the name and summary from the interface file. Since 0launch - * worked, the user should have Python... - */ - argv[3] = iface; - g_spawn_sync (NULL, (gchar **) argv, NULL, - G_SPAWN_SEARCH_PATH, - NULL, NULL, - &child_stdout, NULL, - NULL, &error); - - if (error) - { - xfce_warn (_("Failed to run 0launch:\n%s\n\n" - "For help using Zero Install, " - "see http://0install.net"), error->message); - g_error_free (error); - } - else if (child_stdout) - { - gchar **lines; - - lines = g_strsplit(child_stdout, "\n", 3); + ld->entry_icon = gtk_button_new (); + gtk_box_pack_start (GTK_BOX (hbox), ld->entry_icon, FALSE, FALSE, 0); - if (lines[0]) - { - g_free(e->name); - e->name = lines[0]; + gtk_label_set_mnemonic_widget (GTK_LABEL (label), ld->entry_icon); - if (lines[1]) - { - g_free(e->comment); - e->comment = lines[1]; + g_signal_connect_swapped (G_OBJECT (ld->entry_icon), "clicked", + G_CALLBACK (launcher_dialog_icon_chooser), ld); - if (lines[2]) { - g_free(e->icon.icon.name); - e->icon.type = LAUNCHER_ICON_TYPE_NAME; - e->icon.icon.name = lines[2]; - } - } - } + /* entry command field and button */ + hbox = gtk_hbox_new (FALSE, BORDER); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - g_free (lines); /* Not strvfree(); we used all the lines */ - } + label = gtk_label_new_with_mnemonic (_("Co_mmand")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - g_free (child_stdout); + gtk_size_group_add_widget (sg, label); - return e; -} + ld->entry_exec = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (hbox), ld->entry_exec, TRUE, TRUE, 0); -static void -zero_install_launch_done (GPid pid, gint status, ZeroInstallProcess *info) -{ - g_spawn_close_pid (pid); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), ld->entry_exec); - if (status == 0) - { - /* Success! Let's add the application's details... */ - LauncherDialog *ld; - ld = g_object_get_data (G_OBJECT (info->plugin), "launcher-dialog"); - if (ld) - { - LauncherEntry *e = NULL; + g_signal_connect (G_OBJECT (ld->entry_exec), "changed", + G_CALLBACK (launcher_dialog_save_entry), ld); - if (info->entry && ld->entry == info->entry) - { - e = info->entry; - launcher_entry_update_from_interface (e, info->interface_uri); - launcher_dialog_update_entry_properties (ld); - } - else - { - e = launcher_entry_new (); - launcher_entry_update_from_interface (e, info->interface_uri); - launcher_dialog_add_entry_after (ld, NULL, e); - } - } - else - { - xfce_warn(_("The Zero Install GUI has finished, but the launcher dialog " - "has disappeared in the meantime. Not adding launcher " - "(but any files downloaded have not been lost).")); - } - } - - g_object_unref(G_OBJECT (info->plugin)); - g_free(info->interface_uri); - panel_slice_free(ZeroInstallProcess, info); -} + button = gtk_button_new (); + gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); -/** The user wants to add a launcher for 'interface'. Confirm that it - * is a valid Zero Install interface, download archives needed to run - * the program, and then add it as a launcher. - * Note: This function will return immediately without adding or updating - * the entry. The update happens later in a callback. - */ -static void -start_entry_from_interface_file (LauncherDialog *ld, - const char *interface, - LauncherEntry *entry) -{ - GPid pid; - GError *error = NULL; - const gchar *argv[] = {"0launch", "-dg", "--", NULL, NULL}; + g_signal_connect_swapped (G_OBJECT (button), "clicked", + G_CALLBACK (launcher_dialog_command_chooser), ld); - argv[3] = interface; + image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU); + gtk_container_add (GTK_CONTAINER (button), image); - g_spawn_async(NULL, (gchar **) argv, NULL, - G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, - NULL, NULL, - &pid, &error); + /* working directory field */ + hbox = gtk_hbox_new (FALSE, BORDER); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - if (error) - { - xfce_warn (_("Failed to run 0launch:\n%s\n\n" - "For help using Zero Install, " - "see http://0install.net"), error->message); - g_error_free (error); - } - else - { - ZeroInstallProcess *info; - info = panel_slice_new0 (ZeroInstallProcess); + label = gtk_label_new_with_mnemonic (_("_Working Directory")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - info->interface_uri = g_strdup(interface); - info->plugin = G_OBJECT(ld->plugin); - info->entry = entry; + gtk_size_group_add_widget (sg, label); - g_object_ref (G_OBJECT (info->plugin)); - g_child_watch_add (pid, - (GChildWatchFunc) zero_install_launch_done, - info); - } -} + ld->entry_path = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (hbox), ld->entry_path, TRUE, TRUE, 0); -static LauncherEntry * -update_entry_from_desktop_file (LauncherEntry *e, const char *path) -{ - XfceDesktopEntry *dentry; + gtk_label_set_mnemonic_widget (GTK_LABEL (label), ld->entry_path); - if ((dentry = xfce_desktop_entry_new (path, dentry_keys, - G_N_ELEMENTS (dentry_keys)))) - { - char *value = NULL, *p; - - g_free (e->name); - g_free (e->comment); - g_free (e->exec); - g_free (e->real_exec); - if (e->icon.type == LAUNCHER_ICON_TYPE_NAME) - g_free (e->icon.icon.name); - - e->name = e->comment = e->exec = NULL; - e->terminal = e->startup = FALSE; - e->icon.icon.name = NULL; - e->icon.type = LAUNCHER_ICON_TYPE_NONE; - - xfce_desktop_entry_get_string (dentry, "OnlyShowIn", FALSE, - &value); - - if (value && !strcmp ("XFCE", value)) - { - xfce_desktop_entry_get_string (dentry, "GenericName", FALSE, - &(e->name)); - } + g_signal_connect (G_OBJECT (ld->entry_path), "changed", + G_CALLBACK (launcher_dialog_save_entry), ld); - g_free (value); + button = gtk_button_new (); + gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - if (!e->name) - { - xfce_desktop_entry_get_string (dentry, "Name", FALSE, - &(e->name)); - } - - xfce_desktop_entry_get_string (dentry, "Comment", FALSE, - &(e->comment)); - - value = NULL; - xfce_desktop_entry_get_string (dentry, "Icon", FALSE, - &value); - - if (value) - { - e->icon.type = LAUNCHER_ICON_TYPE_NAME; - e->icon.icon.name = value; - } + g_signal_connect_swapped (G_OBJECT (button), "clicked", + G_CALLBACK (launcher_dialog_folder_chooser), ld); - xfce_desktop_entry_get_string (dentry, "Exec", FALSE, - &(e->exec)); + image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU); + gtk_container_add (GTK_CONTAINER (button), image); - if (e->exec) - { - /* if command contains % variables, like %U or %f, discard all - * arguments. This is not very good solution, but it is simple - * and fast. - */ - if (strchr (e->exec, '%') && (p = strchr (e->exec, ' '))) - *p = '\0'; - - /* expand variables */ - if (!(e->real_exec = xfce_expand_variables (e->exec, NULL))) - e->real_exec = g_strdup (e->exec); - } - + /* entry terminal toggle button with spacer */ + hbox = gtk_hbox_new (FALSE, BORDER); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + label = gtk_alignment_new (0, 0, 0, 0); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - value = NULL; - xfce_desktop_entry_get_string (dentry, "Terminal", FALSE, - &value); + gtk_size_group_add_widget (sg, label); - if (value && (!strcmp ("1", value) || !strcmp ("true", value))) - { - e->terminal = TRUE; + ld->entry_terminal = gtk_check_button_new_with_mnemonic (_("Run in _terminal")); + gtk_box_pack_start (GTK_BOX (hbox), ld->entry_terminal, TRUE, TRUE, 0); - g_free (value); - } - - value = NULL; - xfce_desktop_entry_get_string (dentry, "StartupNotify", FALSE, - &value); + g_signal_connect (G_OBJECT (ld->entry_terminal), "toggled", + G_CALLBACK (launcher_dialog_save_button), ld); - if (value && (!strcmp ("1", value) || !strcmp ("true", value))) - { - e->startup = TRUE; +#ifdef HAVE_LIBSTARTUP_NOTIFICATION + /* startup notification */ + hbox = gtk_hbox_new (FALSE, BORDER); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - g_free (value); - } - - g_object_unref (G_OBJECT (dentry)); + label = gtk_alignment_new (0, 0, 0, 0); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - return e; - } + gtk_size_group_add_widget (sg, label); - return NULL; -} + ld->entry_startup = gtk_check_button_new_with_mnemonic (_("Use _startup notification")); + gtk_box_pack_start (GTK_BOX (hbox), ld->entry_startup, TRUE, TRUE, 0); -static LauncherEntry * -create_entry_from_file (const char *path) -{ - LauncherEntry *e = launcher_entry_new (); + g_signal_connect (G_OBJECT (ld->entry_startup), "toggled", + G_CALLBACK (launcher_dialog_save_button), ld); +#endif - if (g_str_has_suffix (path, ".desktop")) - { - update_entry_from_desktop_file (e, path); - } - else - { - const char *start, *end; - char *utf8; - - if (!g_utf8_validate (path, -1, NULL)) - utf8 = g_locale_to_utf8 (path, -1, NULL, NULL, NULL); - else - utf8 = g_strdup (path); - - e->exec = g_strdup (path); - if (!(e->real_exec = xfce_expand_variables (e->exec, NULL))) - e->real_exec = g_strdup (e->exec); - - if (!(start = strrchr (utf8, G_DIR_SEPARATOR))) - start = utf8; - else - start++; - end = strrchr (start, '.'); - e->name = g_strndup (start, end ? end - start : strlen (start)); - e->icon.type = LAUNCHER_ICON_TYPE_NAME; - e->icon.icon.name = g_strdup (e->name); + /* release size group */ + g_object_unref (G_OBJECT (sg)); - g_free (utf8); - } + /* setup dnd in frame */ + gtk_drag_dest_set (frame, GTK_DEST_DEFAULT_ALL, + drop_targets, G_N_ELEMENTS (drop_targets), + GDK_ACTION_COPY); + + g_signal_connect (frame, "drag-data-received", + G_CALLBACK (launcher_dialog_frame_drag_data_received), ld); - return e; + return frame; } -static void -entry_dialog_data_received (GtkWidget *w, GdkDragContext *context, - gint x, gint y, GtkSelectionData *data, - guint info, guint time, LauncherDialog *ld) -{ - LauncherEntry *e = NULL; - GPtrArray *files; - int i; - - if (!data || data->length < 1) - return; - if (!(files = launcher_get_file_list_from_selection_data (data, info))) - return; - - if (files->len > 0) - { - char *file = g_ptr_array_index (files, 0); - if (g_str_has_suffix (file, ".xml") || - g_str_has_prefix (file, "http://")) - { - start_entry_from_interface_file (ld, file, ld->entry); - } - else if (g_str_has_suffix (file, ".desktop")) - { - e = update_entry_from_desktop_file (ld->entry, file); - } - else - { - /* do stuff based on the widget the file was dropped on */ - } - if (e) +static GtkWidget * +launcher_dialog_add_tree (LauncherDialog *ld) +{ + GtkWidget *scroll; + GtkTreeViewColumn *column; + GtkTreeSelection *selection; + GtkCellRenderer *renderer; + GtkTreeIter iter; + GList *li; + LauncherEntry *entry; + GdkPixbuf *icon; + + /* scrolled window */ + scroll = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), + GTK_POLICY_NEVER, + GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), + GTK_SHADOW_IN); + + /* create new list store */ + ld->store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING); + + /* create tree view */ + ld->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (ld->store)); + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (ld->treeview), FALSE); + gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (ld->treeview), TRUE); + gtk_container_add (GTK_CONTAINER (scroll), ld->treeview); + + g_signal_connect_swapped (G_OBJECT (ld->treeview), "destroy", + G_CALLBACK (launcher_dialog_tree_free_store), ld); + + /* create columns and cell renders */ + column = gtk_tree_view_column_new (); + gtk_tree_view_column_set_expand (column, TRUE); + gtk_tree_view_column_set_resizable (column, FALSE); + gtk_tree_view_append_column (GTK_TREE_VIEW (ld->treeview), column); + + renderer = gtk_cell_renderer_pixbuf_new(); + gtk_tree_view_column_pack_start (column, renderer, FALSE); + gtk_tree_view_column_set_attributes (column, renderer, "pixbuf", COL_ICON, NULL); + + renderer = gtk_cell_renderer_text_new (); + gtk_tree_view_column_pack_start (column, renderer, TRUE); + gtk_tree_view_column_set_attributes (column, renderer, "text", COL_TEXT, NULL); + g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); + + /* set selection change signal */ + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ld->treeview)); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); + g_signal_connect_swapped (G_OBJECT (selection), "changed", + G_CALLBACK (launcher_dialog_tree_selection_changed), ld); + + /* append current items */ + for (li = ld->launcher->entries; li != NULL; li = li->next) + { + entry = li->data; + + if (G_LIKELY (entry && entry->name)) { - GdkPixbuf *pb; - - gtk_entry_set_text (GTK_ENTRY (ld->exec_name), e->name); - gtk_entry_set_text (GTK_ENTRY (ld->exec_comment), e->comment); - if (e->icon.type == LAUNCHER_ICON_TYPE_NAME) - gtk_entry_set_text (GTK_ENTRY (ld->icon_file), - e->icon.icon.name); - gtk_entry_set_text (GTK_ENTRY (ld->exec), e->exec); - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (ld->exec_terminal), e->terminal); - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (ld->exec_startup), e->startup); - - pb = launcher_icon_load_pixbuf (ld->icon_img, &e->icon, - DLG_ICON_SIZE); - gtk_image_set_from_pixbuf (GTK_IMAGE (ld->icon_img), pb); - g_object_unref (G_OBJECT (pb)); + /* load icon */ + icon = launcher_load_pixbuf (ld->treeview, entry->icon, TREE_ICON_SIZE, TRUE); + + /* create new row and add the data */ + gtk_list_store_append (ld->store, &iter); + gtk_list_store_set (ld->store, &iter, + COL_ICON, icon, + COL_TEXT, entry->name, + -1); + + /* release the pixbuf */ + if (G_LIKELY (icon)) + g_object_unref (G_OBJECT (icon)); } } - for (i = 0; i < files->len; ++i) - g_free (g_ptr_array_index (files, i)); + /* dnd support */ + gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (ld->treeview), + drop_targets, G_N_ELEMENTS (drop_targets), + GDK_ACTION_COPY); - g_ptr_array_free (files, TRUE); - - gtk_drag_finish (context, TRUE, FALSE, time); + g_signal_connect (G_OBJECT (ld->treeview), "drag-data-received", + G_CALLBACK (launcher_dialog_tree_drag_data_received), ld); + + return scroll; } - -static void -launcher_dialog_data_received (GtkWidget *w, GdkDragContext *context, - gint x, gint y, GtkSelectionData *data, - guint info, guint time, LauncherDialog *ld) + + + +static GtkWidget * +launcher_dialog_add_tree_buttons (LauncherDialog *ld) { - GPtrArray *files; - int i; - - if (!data || data->length < 1) - return; - - if (!(files = launcher_get_file_list_from_selection_data (data, info))) - return; - - for (i = 0; i < files->len; ++i) - { - char *file = g_ptr_array_index (files, i); + GtkWidget *hbox, *button, *align, *image; - if (g_str_has_suffix (file, ".xml") || - g_str_has_prefix (file, "http://")) - { - start_entry_from_interface_file (ld, file, NULL); - } - else - { - LauncherEntry *e = create_entry_from_file (file); + hbox = gtk_hbox_new (FALSE, BORDER); - if (e) - launcher_dialog_add_entry_after (ld, NULL, e); - } + /* up button */ + ld->up = button = gtk_button_new (); + gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE); + gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - g_free (file); - } + image = gtk_image_new_from_stock (GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON); + gtk_container_add (GTK_CONTAINER (button), image); - g_ptr_array_free (files, TRUE); - - gtk_drag_finish (context, TRUE, FALSE, time); -} - -static void -icon_entry_data_received (GtkWidget *w, GdkDragContext *context, - gint x, gint y, GtkSelectionData *data, - guint info, guint time, LauncherDialog *ld) -{ - GPtrArray *files; - int i; - - if (!data || data->length < 1) - return; - - if (!(files = launcher_get_file_list_from_selection_data (data, info))) - return; + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (launcher_dialog_tree_button_clicked), ld); - for (i = 0; i < files->len; ++i) - { - char *file = g_ptr_array_index (files, i); + gtk_widget_set_sensitive (button, FALSE); - if (file && g_file_test (file, G_FILE_TEST_IS_REGULAR)) - { - GdkPixbuf *pb = gdk_pixbuf_new_from_file (file, NULL); - - if (pb) - { - g_object_unref (G_OBJECT (pb)); + /* down button */ + ld->down = button = gtk_button_new (); + gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE); + gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - gtk_widget_hide (ld->icon_label); - gtk_widget_show (ld->icon_file_align); + image = gtk_image_new_from_stock (GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON); + gtk_container_add (GTK_CONTAINER (button), image); - gtk_entry_set_text (GTK_ENTRY (ld->icon_file), file); - gtk_editable_set_position (GTK_EDITABLE (ld->icon_file), -1); - update_entry_icon (ld); + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (launcher_dialog_tree_button_clicked), ld); - pb = launcher_icon_load_pixbuf (ld->icon_img, &ld->entry->icon, - DLG_ICON_SIZE); - gtk_image_set_from_pixbuf (GTK_IMAGE (ld->icon_img), pb); - g_object_unref (G_OBJECT (pb)); + gtk_widget_set_sensitive (button, FALSE); - if (ld->entry == g_ptr_array_index (ld->launcher->entries, 0)) - set_panel_icon (ld); - } - } + /* free space between buttons */ + align = gtk_alignment_new (0, 0, 0, 0); + gtk_widget_set_size_request (align, 1, 1); + gtk_box_pack_start (GTK_BOX (hbox), align, TRUE, TRUE, 0); - g_free (file); - } + /* add button */ + ld->add = button = gtk_button_new (); + gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE); + gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - g_ptr_array_free (files, TRUE); - - gtk_drag_finish (context, TRUE, FALSE, time); -} - -/* File open dialog - * ---------------- - */ -static void -update_preview_cb (GtkFileChooser *chooser, gpointer data) -{ - GtkImage *preview; - char *filename; - GdkPixbuf *pb = NULL; - - preview = GTK_IMAGE(data); - filename = gtk_file_chooser_get_filename(chooser); - - if(filename && g_file_test(filename, G_FILE_TEST_EXISTS) - && (pb = gdk_pixbuf_new_from_file (filename, NULL))) - { - int w, h; - - w = gdk_pixbuf_get_width (pb); - h = gdk_pixbuf_get_height (pb); + image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON); + gtk_container_add (GTK_CONTAINER (button), image); - if (h > 120 || w > 120) - { - double wratio, hratio; - GdkPixbuf *tmp; - - wratio = (double)120 / w; - hratio = (double)120 / h; + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (launcher_dialog_tree_button_clicked), ld); - if (hratio < wratio) - { - w = rint (hratio * w); - h = 120; - } - else - { - w = 120; - h = rint (wratio * h); - } + /* remove button */ + ld->remove = button = gtk_button_new (); + gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE); + gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - tmp = gdk_pixbuf_scale_simple (pb, w, h, GDK_INTERP_BILINEAR); - g_object_unref (G_OBJECT (pb)); - pb = tmp; - } - } - - g_free(filename); - - gtk_image_set_from_pixbuf(preview, pb); + image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_BUTTON); + gtk_container_add (GTK_CONTAINER (button), image); + + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (launcher_dialog_tree_button_clicked), ld); - if (pb) - g_object_unref(G_OBJECT (pb)); + gtk_widget_set_sensitive (button, FALSE); + + return hbox; } -/* Any of the arguments may be NULL */ -static char * -select_file_with_preview (const char *title, const char *path, - GtkWidget * parent, gboolean with_preview) -{ - const char *t; - GtkWidget *fs, *frame, *preview; - char *name = NULL; - xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); - t = (title) ? title : _("Select file"); - - fs = gtk_file_chooser_dialog_new (t, GTK_WINDOW(parent), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - NULL); +/** + * Dialog functions + **/ +static void +launcher_dialog_response (GtkWidget *dialog, + gint response, + LauncherDialog *ld) +{ + /* hide the dialog */ + gtk_widget_hide (dialog); - if (path && *path && g_file_test (path, G_FILE_TEST_EXISTS)) - { - if (!g_path_is_absolute (path)) - { - char *current, *full; + /* lock for further updates */ + ld->updating = TRUE; + ld->entry = NULL; - current = g_get_current_dir (); - full = g_build_filename (current, path, NULL); + /* remove link */ + g_object_set_data (G_OBJECT (ld->launcher->plugin), "dialog", NULL); - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fs), full); + /* destroy the dialog */ + gtk_widget_destroy (dialog); - g_free (current); - g_free (full); - } - else - { - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fs), path); - } - } + /* unlock plugin menu (do this before writing -> see hack in write function) */ + xfce_panel_plugin_unblock_menu (ld->launcher->plugin); - if (with_preview) + /* revert settings made */ + if (response == GTK_RESPONSE_CANCEL) { - frame = gtk_frame_new (NULL); - gtk_widget_set_size_request (frame, 130, 130); - gtk_widget_show (frame); - - preview = gtk_image_new(); - gtk_widget_show(preview); - gtk_container_add (GTK_CONTAINER (frame), preview); - - gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(fs), frame); - - g_signal_connect (G_OBJECT(fs), "update-preview", G_CALLBACK (update_preview_cb), preview); - gtk_file_chooser_set_use_preview_label (GTK_FILE_CHOOSER(fs), FALSE); - - if (path) - update_preview_cb (GTK_FILE_CHOOSER(fs), preview); + /* remove all entries from the list */ + g_list_foreach (ld->launcher->entries, + (GFunc) launcher_free_entry, ld->launcher); + + /* read last saved settings */ + launcher_read (ld->launcher); + + /* update the panel again */ + launcher_dialog_update_panel (ld); } - - if (gtk_dialog_run (GTK_DIALOG (fs)) == GTK_RESPONSE_ACCEPT) + else /* save changes */ { - name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs)); + /* write new settings */ + launcher_write (ld->launcher); } - gtk_widget_destroy (fs); + /* enable/disable auto sort again */ + launcher_set_move_first (ld->launcher->move_first); - return name; + /* free the panel structure */ + panel_slice_free (LauncherDialog, ld); } + +void +launcher_dialog_show (LauncherPlugin *launcher) +{ + LauncherDialog *ld; + GtkWidget *dialog; + GtkWidget *dialog_vbox; + GtkWidget *paned, *vbox; + GtkWidget *widget; + GtkTreePath *path; + + /* create new structure */ + ld = panel_slice_new0 (LauncherDialog); + + ld->launcher = launcher; + + /* get first entry */ + ld->entry = g_list_first (launcher->entries)->data; + + /* lock right-click plugin menu */ + xfce_panel_plugin_block_menu (launcher->plugin); + + /* disable the auto sort of the list, while working in properties */ + launcher_set_move_first (FALSE); + + /* create new dialog */ + dialog = xfce_titled_dialog_new_with_buttons (_("Program Launcher"), + NULL, + GTK_DIALOG_NO_SEPARATOR, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_OK, + NULL); + + gtk_window_set_screen (GTK_WINDOW (dialog), + gtk_widget_get_screen (GTK_WIDGET (launcher->plugin))); + + gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); + gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-settings"); + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); + + /* connect dialog to plugin, so we can destroy it when plugin is closed */ + g_object_set_data (G_OBJECT (ld->launcher->plugin), "dialog", dialog); + + dialog_vbox = GTK_DIALOG (dialog)->vbox; + + /* added the horizontal panes */ + paned = gtk_hpaned_new (); + gtk_box_pack_start (GTK_BOX (dialog_vbox), paned, TRUE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (paned), BORDER - 2); + + vbox = gtk_vbox_new (FALSE, BORDER); + gtk_paned_pack1 (GTK_PANED (paned), vbox, FALSE, FALSE); + + /* add the entries list */ + widget = launcher_dialog_add_tree (ld); + gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0); + + /* add the tree navigation buttons */ + widget = launcher_dialog_add_tree_buttons (ld); + gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); + + /* add the entry widgets */ + widget = launcher_dialog_add_properties (ld); + gtk_paned_pack2 (GTK_PANED (paned), widget, TRUE, FALSE); + + /* show all widgets inside dialog */ + gtk_widget_show_all (dialog_vbox); + + /* focus the title entry */ + gtk_widget_grab_focus (ld->entry_name); + + /* select first item in the tree (this also updates the fields) */ + path = gtk_tree_path_new_first (); + gtk_tree_view_set_cursor (GTK_TREE_VIEW (ld->treeview), path, NULL, FALSE); + gtk_tree_path_free (path); + + /* connect response signal */ + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (launcher_dialog_response), ld); + + /* show the dialog */ + gtk_widget_show (dialog); +} diff --git a/plugins/launcher/launcher-dialog.h b/plugins/launcher/launcher-dialog.h index 8b65d2f54..29fab33e3 100644 --- a/plugins/launcher/launcher-dialog.h +++ b/plugins/launcher/launcher-dialog.h @@ -1,8 +1,7 @@ -/* vim: set expandtab ts=8 sw=4: */ - /* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright © 2005-2007 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2006-2007 Nick Schermer <nick@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 @@ -19,14 +18,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_PANEL_LAUNCHER_DIALOG_H -#define _XFCE_PANEL_LAUNCHER_DIALOG_H - -#include "launcher.h" - -void launcher_properties_dialog (XfcePanelPlugin *plugin, - LauncherPlugin *launcher); - +#ifndef __XFCE_PANEL_LAUNCHER_DIALOG_H__ +#define __XFCE_PANEL_LAUNCHER_DIALOG_H__ -#endif /* _XFCE_PANEL_LAUNCHER_DIALOG_H */ +void launcher_dialog_show (LauncherPlugin *launcher) G_GNUC_INTERNAL; +#endif /* !__XFCE_PANEL_LAUNCHER_DIALOG_H__ */ diff --git a/plugins/launcher/launcher-exec.c b/plugins/launcher/launcher-exec.c new file mode 100644 index 000000000..88d9bea98 --- /dev/null +++ b/plugins/launcher/launcher-exec.c @@ -0,0 +1,602 @@ +/* $Id$ + * + * Copyright (c) 2006-2007 Nick Schermer <nick@xfce.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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 Library 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_MEMORY_H +#include <memory.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif + +#include "launcher.h" +#include "launcher-exec.h" + +#ifdef HAVE_LIBSTARTUP_NOTIFICATION +#ifdef GDK_WINDOWING_X11 +#include <X11/Xatom.h> +#include <gdk/gdkx.h> +#endif +#include <libsn/sn.h> +#endif + + + +typedef struct +{ + SnLauncherContext *sn_launcher; + guint timeout_id; + guint watch_id; + GPid pid; +} LauncherStartupData; + + + +/* Prototypes */ +#ifdef HAVE_LIBSTARTUP_NOTIFICATION +static gint launcher_exec_get_active_workspace_number (GdkScreen *screen); +static gboolean launcher_exec_startup_timeout (gpointer data); +static void launcher_exec_startup_timeout_destroy (gpointer data); +static void launcher_exec_startup_watch (GPid pid, + gint status, + gpointer data); +#endif +static void launcher_exec_string_append_quoted (GString *string, + const gchar *unquoted); +static gchar **launcher_exec_parse_argv (LauncherEntry *entry, + GSList *list, + GError **error) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;; +static gboolean launcher_exec_on_screen (GdkScreen *screen, + LauncherEntry *entry, + GSList *list); + + + +#ifdef HAVE_LIBSTARTUP_NOTIFICATION +static gint +launcher_exec_get_active_workspace_number (GdkScreen *screen) +{ + GdkWindow *root; + gulong bytes_after_ret = 0; + gulong nitems_ret = 0; + guint *prop_ret = NULL; + Atom _NET_CURRENT_DESKTOP; + Atom _WIN_WORKSPACE; + Atom type_ret = None; + gint format_ret; + gint ws_num = 0; + + gdk_error_trap_push (); + + root = gdk_screen_get_root_window (screen); + + /* determine the X atom values */ + _NET_CURRENT_DESKTOP = XInternAtom (GDK_WINDOW_XDISPLAY (root), "_NET_CURRENT_DESKTOP", False); + _WIN_WORKSPACE = XInternAtom (GDK_WINDOW_XDISPLAY (root), "_WIN_WORKSPACE", False); + + if (XGetWindowProperty (GDK_WINDOW_XDISPLAY (root), GDK_WINDOW_XWINDOW (root), + _NET_CURRENT_DESKTOP, 0, 32, False, XA_CARDINAL, + &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, + (gpointer) &prop_ret) != Success) + { + if (XGetWindowProperty (GDK_WINDOW_XDISPLAY (root), GDK_WINDOW_XWINDOW (root), + _WIN_WORKSPACE, 0, 32, False, XA_CARDINAL, + &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, + (gpointer) &prop_ret) != Success) + { + if (G_UNLIKELY (prop_ret != NULL)) + { + XFree (prop_ret); + prop_ret = NULL; + } + } + } + + if (G_LIKELY (prop_ret != NULL)) + { + if (G_LIKELY (type_ret != None && format_ret != 0)) + ws_num = *prop_ret; + XFree (prop_ret); + } + + gdk_error_trap_pop (); + + return ws_num; +} + + + +static gboolean +launcher_exec_startup_timeout (gpointer data) +{ + LauncherStartupData *startup_data = data; + GTimeVal now; + gdouble elapsed; + glong tv_sec; + glong tv_usec; + + /* determine the amount of elapsed time */ + g_get_current_time (&now); + sn_launcher_context_get_last_active_time (startup_data->sn_launcher, &tv_sec, &tv_usec); + elapsed = (((gdouble) now.tv_sec - tv_sec) * G_USEC_PER_SEC + (now.tv_usec - tv_usec)) / 1000.0; + + /* check if the timeout was reached */ + if (elapsed >= STARTUP_TIMEOUT) + { + /* abort the startup notification */ + sn_launcher_context_complete (startup_data->sn_launcher); + sn_launcher_context_unref (startup_data->sn_launcher); + startup_data->sn_launcher = NULL; + } + + /* keep the startup timeout if not elapsed */ + return (elapsed < STARTUP_TIMEOUT); +} + + + +static void +launcher_exec_startup_timeout_destroy (gpointer data) +{ + LauncherStartupData *startup_data = data; + + g_return_if_fail (startup_data->sn_launcher == NULL); + + /* cancel the watch (if any) */ + if (startup_data->watch_id != 0) + g_source_remove (startup_data->watch_id); + + /* close the PID */ + g_spawn_close_pid (startup_data->pid); + + /* release the startup data */ + panel_slice_free (LauncherStartupData, startup_data); +} + + + +static void +launcher_exec_startup_watch (GPid pid, + gint status, + gpointer data) +{ + LauncherStartupData *startup_data = data; + + g_return_if_fail (startup_data->sn_launcher != NULL); + g_return_if_fail (startup_data->watch_id != 0); + g_return_if_fail (startup_data->pid == pid); + + /* abort the startup notification (application exited) */ + sn_launcher_context_complete (startup_data->sn_launcher); + sn_launcher_context_unref (startup_data->sn_launcher); + startup_data->sn_launcher = NULL; + + /* cancel the startup notification timeout */ + g_source_remove (startup_data->timeout_id); +} +#endif + + + +static void +launcher_exec_string_append_quoted (GString *string, + const gchar *unquoted) +{ + gchar *quoted; + + quoted = g_shell_quote (unquoted); + g_string_append (string, quoted); + g_free (quoted); +} + + + +static gchar ** +launcher_exec_parse_argv (LauncherEntry *entry, + GSList *list, + GError **error) +{ + GString *command_line = g_string_new (NULL); + const gchar *p; + gchar *t; + GSList *li; + gchar **argv = NULL; + + /* build the full command */ + for (p = entry->exec; *p != '\0'; ++p) + { + if (p[0] == '%' && p[1] != '\0') + { + switch (*++p) + { + case 'u': + case 'f': + /* a single filename or url */ + if (list != NULL) + launcher_exec_string_append_quoted (command_line, (gchar *) list->data); + break; + + case 'U': + case 'F': + /* a list of filenames or urls */ + for (li = list; li != NULL; li = li->next) + { + if (G_LIKELY (li != list)) + g_string_append_c (command_line, ' '); + + launcher_exec_string_append_quoted (command_line, (gchar *) li->data); + } + break; + + case 'd': + /* directory containing the file that would be passed in a %f field */ + if (list != NULL) + { + t = g_path_get_dirname ((gchar *) list->data); + if (t != NULL) + { + launcher_exec_string_append_quoted (command_line, t); + g_free (t); + } + } + break; + + case 'D': + /* list of directories containing the files that would be passed in to a %F field */ + for (li = list; li != NULL; li = li->next) + { + t = g_path_get_dirname (li->data); + if (t != NULL) + { + if (G_LIKELY (li != list)) + g_string_append_c (command_line, ' '); + + launcher_exec_string_append_quoted (command_line, t); + g_free (t); + } + } + break; + + case 'n': + /* a single filename (without path). */ + if (list != NULL) + { + t = g_path_get_basename ((gchar *) list->data); + if (t != NULL) + { + launcher_exec_string_append_quoted (command_line, t); + g_free (t); + } + } + break; + + case 'N': + /* a list of filenames (without paths) */ + for (li = list; li != NULL; li = li->next) + { + t = g_path_get_basename (li->data); + if (t != NULL) + { + if (G_LIKELY (li != list)) + g_string_append_c (command_line, ' '); + + launcher_exec_string_append_quoted (command_line, t); + g_free (t); + } + } + break; + + case 'i': + /* the icon key of the desktop entry */ + if (G_LIKELY (entry->icon != NULL)) + { + g_string_append (command_line, "--icon "); + launcher_exec_string_append_quoted (command_line, entry->icon); + } + break; + + case 'c': + /* the translated name of the application */ + if (G_LIKELY (entry->name != NULL)) + launcher_exec_string_append_quoted (command_line, entry->name); + break; + + case '%': + /* percentage character */ + g_string_append_c (command_line, '%'); + break; + } + } + else + { + g_string_append_c (command_line, *p); + } + } + + DBG ("Execute: %s", command_line->str); + + /* create the argv */ + if (G_LIKELY (command_line->str != NULL)) + { + if (entry->terminal == FALSE) + { + /* use glib to parge the argv */ + g_shell_parse_argv (command_line->str, NULL, &argv, error); + } + else + { + /* we parse our own argv here so exo-open will handle all attributes without problems */ + argv = g_new (gchar *, 5); + argv[0] = g_strdup ("exo-open"); + argv[1] = g_strdup ("--launch"); + argv[2] = g_strdup ("TerminalEmulator"); + argv[3] = g_strdup (command_line->str); + argv[4] = NULL; + } + } + + /* cleanup */ + g_string_free (command_line, TRUE); + + return argv; +} + + +static gboolean +launcher_exec_on_screen (GdkScreen *screen, + LauncherEntry *entry, + GSList *list) +{ +#ifdef HAVE_LIBSTARTUP_NOTIFICATION + SnLauncherContext *sn_launcher = NULL; + SnDisplay *sn_display = NULL; + LauncherStartupData *startup_data; + gint sn_workspace; + extern gchar **environ; + gint n, m; +#endif + gboolean succeed = FALSE; + GError *error = NULL; + gchar **argv; + gchar **envp = NULL; + GtkWidget *dialog; + GSpawnFlags flags = G_SPAWN_SEARCH_PATH; + GPid pid; + + /* parse the full command */ + if ((argv = launcher_exec_parse_argv (entry, list, &error)) == NULL) + goto error; + +#ifdef HAVE_LIBSTARTUP_NOTIFICATION + /* setup startup notification, only when not running in terminal */ + if (entry->startup && !entry->terminal) + { + sn_display = sn_display_new (GDK_SCREEN_XDISPLAY (screen), + (SnDisplayErrorTrapPush) gdk_error_trap_push, + (SnDisplayErrorTrapPop) gdk_error_trap_pop); + + if (G_LIKELY (sn_display != NULL)) + { + /* create new startup context */ + sn_launcher = sn_launcher_context_new (sn_display, GDK_SCREEN_XNUMBER (screen)); + + if (G_LIKELY (sn_launcher != NULL && !sn_launcher_context_get_initiated (sn_launcher))) + { + /* setup the startup notification context */ + sn_workspace = launcher_exec_get_active_workspace_number (screen); + sn_launcher_context_set_binary_name (sn_launcher, argv[0]); + sn_launcher_context_set_workspace (sn_launcher, sn_workspace); + sn_launcher_context_initiate (sn_launcher, g_get_prgname (), argv[0], CurrentTime); + + /* count environ items */ + for (n = 0; environ[n] != NULL; ++n) + ; + + /* alloc new envp string */ + envp = g_new (gchar *, n + 2); + + /* copy the environ vars into the envp */ + for (n = m = 0; environ[n] != NULL; ++n) + if (G_LIKELY (strncmp (environ[n], "DESKTOP_STARTUP_ID", 18) != 0)) + envp[m++] = g_strdup (environ[n]); + + /* append the startup notification id */ + envp[m++] = g_strconcat ("DESKTOP_STARTUP_ID=", sn_launcher_context_get_startup_id (sn_launcher), NULL); + envp[m] = NULL; + + /* we want to watch the child process */ + flags |= G_SPAWN_DO_NOT_REAP_CHILD; + } + } + } +#endif + + /* spawn the application */ + succeed = gdk_spawn_on_screen (screen, + entry->path, + argv, + envp, + flags, + NULL, NULL, + &pid, + &error); + + /* cleanup the argv */ + g_strfreev (argv); + +#ifdef HAVE_LIBSTARTUP_NOTIFICATION + /* handle the sn launcher context */ + if (sn_launcher != NULL) + { + if (G_UNLIKELY (!succeed)) + { + /* abort the sn sequence */ + sn_launcher_context_complete (sn_launcher); + sn_launcher_context_unref (sn_launcher); + } + else + { + /* schedule a startup notification timeout */ + startup_data = panel_slice_new (LauncherStartupData); + startup_data->sn_launcher = sn_launcher; + startup_data->timeout_id = g_timeout_add_full (G_PRIORITY_LOW, STARTUP_TIMEOUT, + launcher_exec_startup_timeout, + startup_data, launcher_exec_startup_timeout_destroy); + startup_data->watch_id = g_child_watch_add_full (G_PRIORITY_LOW, pid, launcher_exec_startup_watch, + startup_data, NULL); + startup_data->pid = pid; + } + } + + /* release the sn display */ + if (sn_display != NULL) + sn_display_unref (sn_display); + + if (envp != NULL) + g_strfreev (envp); +#endif + +error: + if (G_UNLIKELY (error != NULL)) + { + /* create new warning dialog */ + dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + _("Failed to launch \"%s\""), + entry->name); + + /* show g's error message, if there is any */ + if (G_LIKELY (error->message)) + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + "%s.", error->message); + + /* popup the dialog */ + gtk_dialog_run (GTK_DIALOG (dialog)); + + /* cleanup */ + gtk_widget_destroy (dialog); + g_error_free (error); + } + + return succeed; +} + + + +void +launcher_execute (GdkScreen *screen, + LauncherEntry *entry, + GSList *file_list) +{ + GSList *li; + GSList fake; + gboolean proceed = TRUE; + + /* be secure */ + if (G_UNLIKELY (screen == NULL)) + screen = gdk_screen_get_default (); + + /* maybe no command have been filed yet */ + if (G_UNLIKELY (entry->exec == NULL)) + return; + + /* check if the launcher supports (and needs) multiple instances */ + if (file_list != NULL && + strstr (entry->exec, "%F") == NULL && + strstr (entry->exec, "%U") == NULL) + { + /* fake an empty list */ + fake.next = NULL; + + /* run new instance for each file in the list */ + for (li = file_list; li != NULL && proceed; li = li->next) + { + /* point to data */ + fake.data = li->data; + + /* spawn */ + proceed = launcher_exec_on_screen (screen, entry, &fake); + } + } + else + { + /* spawn */ + launcher_exec_on_screen (screen, entry, file_list); + } +} + + + +void +launcher_execute_from_clipboard (GdkScreen *screen, + LauncherEntry *entry) +{ + GtkClipboard *clipboard; + gchar *text = NULL; + GSList *file_list = NULL; + GtkSelectionData selection_data; + + /* maybe no command have been filed yet */ + if (G_UNLIKELY (entry->exec == NULL)) + return; + + /* get the clipboard */ + clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY); + + /* get clipboard text */ + if (G_LIKELY (clipboard)) + text = gtk_clipboard_wait_for_text (clipboard); + + /* try other clipboard if this one was empty */ + if (text == NULL) + { + /* get the clipboard */ + clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); + + /* get clipboard text */ + if (G_LIKELY (clipboard)) + text = gtk_clipboard_wait_for_text (clipboard); + } + + if (G_LIKELY (text != NULL)) + { + /* create some fake selection data */ + selection_data.data = (guchar *) text; + selection_data.length = strlen (text); + + /* parse the filelist, this way we can handle 'copied' file from thunar */ + file_list = launcher_file_list_from_selection (&selection_data); + + if (G_LIKELY (file_list != NULL)) + { + /* run the command with argument from clipboard */ + launcher_exec_on_screen (screen, entry, file_list); + + /* cleanup */ + g_slist_free_all (file_list); + } + + /* cleanup */ + g_free (text); + } +} diff --git a/plugins/launcher/launcher-exec.h b/plugins/launcher/launcher-exec.h new file mode 100644 index 000000000..04ec5ab05 --- /dev/null +++ b/plugins/launcher/launcher-exec.h @@ -0,0 +1,29 @@ +/* $Id$ + * + * Copyright (c) 2006-2007 Nick Schermer <nick@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 __XFCE_PANEL_EXEC_H__ +#define __XFCE_PANEL_EXEC_H__ + +void launcher_execute (GdkScreen *screen, + LauncherEntry *entry, + GSList *file_list) G_GNUC_INTERNAL; +void launcher_execute_from_clipboard (GdkScreen *screen, + LauncherEntry *entry) G_GNUC_INTERNAL; + +#endif /* !__XFCE_PANEL_EXEC_H__ */ diff --git a/plugins/launcher/launcher.c b/plugins/launcher/launcher.c index 87bc06c3e..ef6472c32 100644 --- a/plugins/launcher/launcher.c +++ b/plugins/launcher/launcher.c @@ -1,11 +1,10 @@ -/* vim: set expandtab ts=8 sw=4: */ - /* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2006-2007 Nick Schermer <nick@xfce.org> * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published + * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * @@ -22,760 +21,556 @@ #ifdef HAVE_CONFIG_H #include <config.h> #endif - -#include <stdio.h> -#include <ctype.h> +#ifdef HAVE_MEMORY_H +#include <memory.h> +#endif +#ifdef HAVE_STRING_H #include <string.h> -#include <gtk/gtk.h> +#endif #include <libxfce4util/libxfce4util.h> -#include <libxfcegui4/libxfcegui4.h> #include <libxfce4panel/xfce-arrow-button.h> -#include <libxfce4panel/xfce-panel-plugin.h> #include <libxfce4panel/xfce-panel-convenience.h> #include <libxfce4panel/xfce-hvbox.h> #include "launcher.h" +#include "launcher-exec.h" #include "launcher-dialog.h" +/** + * Prototypes + **/ +static void launcher_g_list_move_first (GList *li); +static gboolean launcher_theme_changed (GSignalInvocationHint *ihint, + guint n_param_values, + const GValue *param_values, + LauncherPlugin *launcher); +static void launcher_button_drag_data_received (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint time, + LauncherPlugin *launcher); +static void launcher_menu_drag_data_received (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint time, + LauncherEntry *entry); +static void launcher_button_clicked (GtkWidget *button, + LauncherPlugin *launcher); +static void launcher_button_pointer (GtkWidget *button_a, + GtkWidget *button_b); +static gboolean launcher_button_pressed (LauncherPlugin *launcher, + GdkEventButton *ev); +static gboolean launcher_button_released (GtkWidget *button, + GdkEventButton *ev, + LauncherPlugin *launcher); +static gboolean launcher_arrow_pressed (LauncherPlugin *launcher, + GdkEventButton *ev); +static void launcher_menu_item_activate (GtkWidget *mi, + GList *li); +static gboolean launcher_menu_item_released (GtkWidget *mi, + GdkEventButton *ev, + GList *li); +static void launcher_menu_position (GtkMenu *menu, + gint *x, + gint *y, + gboolean *push_in, + GtkWidget *button); +static gboolean launcher_menu_popup (LauncherPlugin *launcher); +static void launcher_menu_deactivated (LauncherPlugin *launcher); +static gboolean launcher_menu_update (LauncherPlugin *launcher); +static LauncherPlugin *launcher_new (XfcePanelPlugin *plugin) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +static GtkArrowType launcher_calculate_floating_arrow (LauncherPlugin *launcher, + XfceScreenPosition position); +static void launcher_screen_position_changed (LauncherPlugin *launcher, + XfceScreenPosition position); +static void launcher_orientation_changed (LauncherPlugin *launcher, + GtkOrientation orientation); +static gboolean launcher_set_size (LauncherPlugin *launcher, + guint size); +static void launcher_free (LauncherPlugin *launcher); +static void launcher_construct (XfcePanelPlugin *plugin); + + + +/* global setting */ +static gboolean move_first = FALSE; + + + +/* register the plugin */ +XFCE_PANEL_PLUGIN_REGISTER_INTERNAL (launcher_construct); -static LauncherPlugin * launcher_new (XfcePanelPlugin *plugin); - -static void launcher_free (LauncherPlugin *launcher); - -static void launcher_set_orientation (XfcePanelPlugin *plugin, - LauncherPlugin *launcher, - GtkOrientation orientation); - -static void launcher_set_screen_position (LauncherPlugin *launcher, - XfceScreenPosition position); - -static void launcher_write_rc_file (XfcePanelPlugin *plugin, - LauncherPlugin *launcher); - -static void launcher_construct (XfcePanelPlugin *plugin); -/* -------------------------------------------------------------------- * - * Panel Plugin Interface * - * -------------------------------------------------------------------- */ -/* Register with the panel */ +/** + * Utility functions + **/ +void +launcher_g_list_swap (GList *li_a, + GList *li_b) +{ + gpointer data; -XFCE_PANEL_PLUGIN_REGISTER_INTERNAL (launcher_construct); + /* swap data between the items */ + data = li_a->data; + li_a->data = li_b->data; + li_b->data = data; +} -/* Interface Implementation */ static void -launcher_screen_position_changed (XfcePanelPlugin *plugin, - XfceScreenPosition position, - LauncherPlugin *launcher) +launcher_g_list_move_first (GList *li) { - launcher_set_screen_position (launcher, position); -} + /* quit if we're not going to sort */ + if (move_first == FALSE) + return; -static void -launcher_orientation_changed (XfcePanelPlugin *plugin, - GtkOrientation orientation, - LauncherPlugin *launcher) + /* swap items till we reached the beginning of the list */ + while (li->prev != NULL) { - launcher_set_orientation (plugin, launcher, orientation); + launcher_g_list_swap (li, li->prev); + li = li->prev; + } } -static gboolean -launcher_set_size (XfcePanelPlugin *plugin, int size, LauncherPlugin *launcher) -{ - gtk_widget_set_size_request (launcher->iconbutton, size, size); - launcher_update_panel_entry (launcher); - return TRUE; -} -static void -launcher_free_data (XfcePanelPlugin *plugin, LauncherPlugin *launcher) +/** + * Miscelanious function + **/ +static gboolean +launcher_theme_changed (GSignalInvocationHint *ihint, + guint n_param_values, + const GValue *param_values, + LauncherPlugin *launcher) { - GtkWidget *dlg; - - if (launcher->screen_id) - g_signal_handler_disconnect (launcher->image, launcher->screen_id); - - if (launcher->style_id) - g_signal_handler_disconnect (launcher->image, launcher->style_id); - - launcher->screen_id = launcher->style_id = 0; - - dlg = g_object_get_data (G_OBJECT (plugin), "dialog"); - - if (dlg) - gtk_widget_destroy (dlg); - - launcher_free (launcher); -} + /* only update if we already have an image, this fails when the signal is connected */ + if (G_LIKELY (gtk_image_get_storage_type (GTK_IMAGE (launcher->image)) == GTK_IMAGE_EMPTY)) + return TRUE; -void -launcher_save (XfcePanelPlugin *plugin, LauncherPlugin *launcher) -{ - launcher_write_rc_file (plugin, launcher); -} + /* update the icon button */ + launcher->icon_update_required = TRUE; + launcher_button_update (launcher); -static void -launcher_configure (XfcePanelPlugin *plugin, LauncherPlugin *launcher) -{ - launcher_properties_dialog (plugin, launcher); + /* destroy the menu */ + launcher_menu_prepare (launcher); + + /* keep hook alive */ + return TRUE; } -/* create widgets and connect to signals */ -static void -launcher_construct (XfcePanelPlugin *plugin) -{ - LauncherPlugin *launcher = launcher_new (plugin); - gtk_container_add (GTK_CONTAINER (plugin), launcher->box); - xfce_panel_plugin_add_action_widget (plugin, launcher->iconbutton); - xfce_panel_plugin_add_action_widget (plugin, launcher->arrowbutton); +GdkPixbuf * +launcher_load_pixbuf (GtkWidget *widget, + const gchar *icon_name, + guint size, + gboolean fallback) +{ + GdkPixbuf *icon = NULL; + GdkPixbuf *icon_scaled; + GtkIconTheme *icon_theme; - g_signal_connect (plugin, "screen-position-changed", - G_CALLBACK (launcher_screen_position_changed), launcher); - - g_signal_connect (plugin, "orientation-changed", - G_CALLBACK (launcher_orientation_changed), launcher); - - g_signal_connect (plugin, "size-changed", - G_CALLBACK (launcher_set_size), launcher); - - g_signal_connect (plugin, "free-data", - G_CALLBACK (launcher_free_data), launcher); - - g_signal_connect (plugin, "save", - G_CALLBACK (launcher_save), launcher); - - xfce_panel_plugin_menu_show_configure (plugin); - g_signal_connect (plugin, "configure-plugin", - G_CALLBACK (launcher_configure), launcher); + if (G_LIKELY (icon_name != NULL) && + G_UNLIKELY (g_path_is_absolute (icon_name))) + { + /* load the icon from the file */ + icon = exo_gdk_pixbuf_new_from_file_at_max_size (icon_name, size, size, TRUE, NULL); + } + else if (G_LIKELY (icon_name != NULL)) + { + /* determine the appropriate icon theme */ + if (G_LIKELY (gtk_widget_has_screen (widget))) + icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget)); + else + icon_theme = gtk_icon_theme_get_default (); - launcher_set_screen_position (launcher, - xfce_panel_plugin_get_screen_position (plugin)); -} + /* try to load the named icon */ + icon = gtk_icon_theme_load_icon (icon_theme, icon_name, size, 0, NULL); + } -/* -------------------------------------------------------------------- * - * Launcher Plugin Interface * - * -------------------------------------------------------------------- */ + /* scale down the icon (function above is a convenience function) */ + if (G_LIKELY (icon != NULL)) + { + /* scale down the icon if required */ + icon_scaled = exo_gdk_pixbuf_scale_down (icon, TRUE, size, size); + g_object_unref (G_OBJECT (icon)); + icon = icon_scaled; + } + else if (fallback) /* create empty pixbuf */ + { + /* this is a transparent pixbuf, used for tree convenience */ + icon = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, size, size); + gdk_pixbuf_fill (icon, 0x00000000); + } -static LauncherPlugin *open_launcher = NULL; + return icon; +} -/* DND * - * --- */ -static const GtkTargetEntry target_list [] = +void +launcher_set_move_first (gboolean activate) { - { "text/uri-list", 0, TARGET_URI_LIST }, - { "text/x-moz-url", 0, TARGET_MOZ_URL }, - { "STRING", 0, TARGET_URI_LIST } -}; + /* set the value of the move first boolean */ + move_first = activate; +} + -static const guint n_targets = G_N_ELEMENTS (target_list); -/* Mozilla uses its own weird format. */ +/** + * Drag and Drop + **/ static void -add_mozilla_files (GPtrArray *files, GtkSelectionData *data) +launcher_button_drag_data_received (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint time, + LauncherPlugin *launcher) { - gchar *utf8, *eol; + /* run the 'entry' dnd with first item from the list */ + launcher_menu_drag_data_received (widget, context, x, y, + selection_data, info, time, + g_list_first (launcher->entries)->data); +} - utf8 = g_utf16_to_utf8((gunichar2 *) data->data, - (glong) data->length, - NULL, NULL, NULL); - eol = utf8 ? strchr(utf8, '\n') : NULL; - if (eol) { - gchar *s1 = utf8; - if (!strncmp (s1, "file:", 5)) - { - s1 += 5; - while (*(s1 + 1) == '/') - ++s1; - } - g_ptr_array_add (files, g_strndup(s1, eol - s1)); - } - else - { - g_warning ("Invalid UTF16 from text/x-moz-url target"); - } - g_free(utf8); -} -GPtrArray * -launcher_get_file_list_from_selection_data (GtkSelectionData *data, guint info) +static void +launcher_menu_drag_data_received (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint time, + LauncherEntry *entry) { - GPtrArray *files; - const char *s1, *s2; + GSList *file_list = NULL; - if (data->length < 1) - return NULL; + /* create list from all the uri list */ + file_list = launcher_file_list_from_selection (selection_data); - files = g_ptr_array_new (); - - if (info == TARGET_MOZ_URL) + if (G_LIKELY (file_list != NULL)) { - add_mozilla_files(files, data); - return files; - } + launcher_execute (gtk_widget_get_screen (widget), entry, file_list); - /* Assume text/uri-list (RFC2483): - * - Commented lines are allowed; they start with #. - * - Lines are separated by CRLF (\r\n) - * - We also allow LF (\n) as separator - * - We strip "file:" and multiple slashes ("/") at the start - */ - for (s1 = (const char *)data->data; s1 != NULL && strlen(s1); ++s1) - { - if (*s1 != '#') - { - while (isspace ((int)*s1)) - ++s1; - - if (!strncmp (s1, "file:", 5)) - { - s1 += 5; - while (*(s1 + 1) == '/') - ++s1; - } - - for (s2 = s1; *s2 != '\0' && *s2 != '\r' && *s2 != '\n'; ++s2) - /* */; - - if (s2 > s1) - { - while (isspace ((int)*(s2-1))) - --s2; - - if (s2 > s1) - { - int len, i; - char *file; - - len = s2 - s1; - file = g_new (char, len + 1); - - /* decode % escaped characters */ - for (i = 0, s2 = s1; s2 - s1 <= len; ++i, ++s2) - { - if (*s2 != '%' || s2 + 3 -s1 > len) - { - file[i] = *s2; - } - else - { - guint c; - - if (sscanf (s2+1, "%2x", &c) == 1) - file[i] = (char)c; - - s2 += 2; - } - } - - file[i-1] = '\0'; - g_ptr_array_add (files, file); - } - } - } - - if (!(s1 = strchr (s1, '\n'))) - break; - } - - if (files->len > 0) - { - return files; + /* cleanup */ + g_slist_free_all (file_list); } - g_ptr_array_free (files, TRUE); - - return NULL; -} - -void launcher_set_drag_dest (GtkWidget *widget) -{ - gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_ALL, - target_list, n_targets, GDK_ACTION_COPY); + /* finish drag */ + gtk_drag_finish (context, TRUE, FALSE, time); } -/* utility functions * - * ----------------- */ -GdkPixbuf * -launcher_icon_load_pixbuf (GtkWidget *w, LauncherIcon * icon, int size) +GSList * +launcher_file_list_from_selection (GtkSelectionData *selection_data) { - GdkPixbuf *pb = NULL; + gchar **uri_list; + GSList *file_list = NULL; + gchar *filename; + guint i; - if (icon->type == LAUNCHER_ICON_TYPE_NAME) + /* check whether the retrieval worked */ + if (G_LIKELY (selection_data->length > 0)) { - if (g_path_is_absolute (icon->icon.name)) - { - pb = gdk_pixbuf_new_from_file_at_size (icon->icon.name, - size, size, NULL); - } - else + /* split the received uri list */ + uri_list = g_uri_list_extract_uris ((gchar *) selection_data->data); + + /* walk though the list */ + for (i = 0; uri_list[i] != NULL; i++) { - pb = xfce_themed_icon_load (icon->icon.name, size); + /* escape the ascii-encoded uri */ + filename = g_filename_from_uri (uri_list[i], NULL, NULL); + + /* append the uri, if uri -> filename conversion failed */ + if (G_UNLIKELY (filename == NULL)) + filename = g_strdup (uri_list[i]); + + /* append the filename */ + file_list = g_slist_append (file_list, filename); } - } - else if (icon->type == LAUNCHER_ICON_TYPE_CATEGORY) - { - pb = xfce_themed_icon_load_category (icon->icon.category, size); - } - if (!pb) - { - pb = xfce_themed_icon_load_category (XFCE_ICON_CATEGORY_UNKNOWN, size); + /* cleanup */ + g_strfreev (uri_list); } - return pb; + return file_list; } -LauncherEntry * -launcher_entry_new (void) -{ - return panel_slice_new0 (LauncherEntry); -} -void -launcher_entry_free (LauncherEntry *e) -{ - g_free (e->name); - g_free (e->comment); - if (e->icon.type == LAUNCHER_ICON_TYPE_NAME) - g_free (e->icon.icon.name); - g_free (e->exec); - g_free (e->real_exec); - - panel_slice_free (LauncherEntry, e); -} -static void -launcher_entry_exec (GdkScreen *screen, LauncherEntry *entry) +/** + * (Icon) Button Functions + **/ +gboolean +launcher_button_update (LauncherPlugin *launcher) { - GError *error = NULL; - - if (!entry->exec || !strlen (entry->exec)) - return; - - xfce_exec_on_screen (screen, entry->real_exec, entry->terminal, - entry->startup, &error); - - if (error) - { - char first[256]; + GdkPixbuf *icon; + LauncherEntry *entry; + guint size; + gchar *tooltip = NULL; - g_snprintf (first, 256, _("Could not run \"%s\""), entry->name); - - xfce_message_dialog (NULL, _("Xfce Panel"), - GTK_STOCK_DIALOG_ERROR, first, error->message, - GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); + /* safety check */ + if (G_UNLIKELY (g_list_length (launcher->entries) == 0)) + return FALSE; - g_error_free (error); - } -} + /* get first entry */ + entry = g_list_first (launcher->entries)->data; -static void -launcher_entry_drop_cb (GdkScreen *screen, LauncherEntry *entry, - GPtrArray *files) -{ - char **argv, **execv; - int i, n; - GError *error = NULL; + /* check if we really need to update the button icon */ + if (launcher->icon_update_required == FALSE) + goto updatetooltip; - if (G_UNLIKELY (!entry->exec)) - return; + /* reset button update */ + launcher->icon_update_required = FALSE; - if (!g_shell_parse_argv (entry->real_exec, &n, &execv, &error)) - { - char first[256]; - - g_snprintf (first, 256, _("Error in command \"%s\""), - entry->real_exec); - - xfce_message_dialog (NULL, _("Xfce Panel"), - GTK_STOCK_DIALOG_ERROR, first, error->message, - GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); - - g_error_free (error); - return; - } - - if (entry->terminal) + /* calculate icon size */ + size = xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (launcher->plugin)) + - 2 - 2 * MAX (launcher->iconbutton->style->xthickness, + launcher->iconbutton->style->ythickness); + + /* load the pixbuf, we use the fallback image here because else + * the theme signal fails when xfce-mcs-manager restarts */ + icon = launcher_load_pixbuf (launcher->iconbutton, entry->icon, size, TRUE); + + /* set the new button icon */ + if (G_LIKELY (icon != NULL)) { - argv = g_new (char *, n + files->len + 3); - argv[0] = "xfterm4"; - argv[1] = "-e"; - for (i = 0; i < n; ++i) - argv[i+2] = execv[i]; - n += 2; + gtk_image_set_from_pixbuf (GTK_IMAGE (launcher->image), icon); + + /* release the icon */ + g_object_unref (G_OBJECT (icon)); } else { - argv = g_new (char *, n + files->len + 1); - for (i = 0; i < n; ++i) - argv[i] = execv[i]; + /* clear image if no (valid) icon is set */ + gtk_image_clear (GTK_IMAGE (launcher->image)); } - for (i = 0; i < files->len; ++i) - argv[n+i] = g_ptr_array_index (files, i); +updatetooltip: - argv[n+i] = NULL; - - if (!xfce_exec_argv_on_screen (screen, argv, entry->terminal, - entry->startup, &error)) + /* create tooltip text */ + if (G_LIKELY (entry->name)) { - char first[256]; - - g_snprintf (first, 256, _("Could not run \"%s\""), entry->name); - - xfce_message_dialog (NULL, _("Xfce Panel"), - GTK_STOCK_DIALOG_ERROR, first, error->message, - GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); - - g_error_free (error); + if (entry->comment) + tooltip = g_strdup_printf ("%s\n%s", entry->name, entry->comment); + else + tooltip = g_strdup_printf ("%s", entry->name); } - g_strfreev (execv); - g_free (argv); -} + /* set the tooltip */ + gtk_tooltips_set_tip (launcher->tips, launcher->iconbutton, + tooltip, NULL); -static void -launcher_entry_clipboard_cb (GdkScreen *screen, LauncherEntry *entry) -{ - char *paste = NULL; - GtkClipboard *clip; + /* free string */ + if (G_LIKELY (tooltip)) + g_free (tooltip); - clip = gtk_clipboard_get (GDK_SELECTION_PRIMARY); - if (clip) - paste = gtk_clipboard_wait_for_text (clip); + return FALSE; +} - if (paste != NULL) - { - GPtrArray *files; - char *tmp; - tmp = g_strescape (paste, NULL); - g_free (paste); - paste = tmp; - files = g_ptr_array_sized_new (1); - g_ptr_array_add (files, paste); +static void +launcher_button_pointer (GtkWidget *button_a, + GtkWidget *button_b) +{ + /* sync the button states */ + gtk_widget_set_state (button_b, GTK_WIDGET_STATE (button_a)); +} - launcher_entry_drop_cb (screen, entry, files); - g_free (paste); - g_ptr_array_free (files, TRUE); - } -} static void -launcher_entry_data_received (GtkWidget *widget, GdkDragContext *context, - gint x, gint y, GtkSelectionData *data, - guint info, guint time, LauncherEntry *entry) +launcher_button_clicked (GtkWidget *button, + LauncherPlugin *launcher) { - GPtrArray *files; - - if (!data || data->length < 1) - return; - - files = launcher_get_file_list_from_selection_data (data, info); + LauncherEntry *entry; - if (files) + /* remove popup timeout */ + if (launcher->popup_timeout_id) { - launcher_entry_drop_cb (gtk_widget_get_screen (widget), entry, files); - g_ptr_array_free (files, TRUE); + g_source_remove (launcher->popup_timeout_id); + launcher->popup_timeout_id = 0; } - if (open_launcher) - { - gtk_widget_hide (GTK_MENU (open_launcher->menu)->toplevel); - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (open_launcher->arrowbutton), FALSE); - open_launcher = NULL; - } - - gtk_drag_finish (context, TRUE, FALSE, time); + /* get first entry */ + entry = g_list_first (launcher->entries)->data; + + /* execute command */ + launcher_execute (gtk_widget_get_screen (button), entry, NULL); } -static void -launcher_drag_data_received (GtkWidget *widget, GdkDragContext *context, - gint x, gint y, GtkSelectionData *data, - guint info, guint time, LauncherPlugin *launcher) + + +static gboolean +launcher_button_pressed (LauncherPlugin *launcher, + GdkEventButton *ev) { - GPtrArray *files; - - if (!data || data->length < 1) - return; - - files = launcher_get_file_list_from_selection_data (data, info); + guint modifiers; - if (files) - { - launcher_entry_drop_cb (gtk_widget_get_screen (widget), - g_ptr_array_index (launcher->entries, 0), - files); + modifiers = gtk_accelerator_get_default_mod_mask (); - g_ptr_array_free (files, TRUE); + /* exit if control is pressed, or pressed != button 1 */ + if (G_LIKELY (ev->button != 1) || + (ev->button == 1 && (ev->state & modifiers) == GDK_CONTROL_MASK)) + { + return FALSE; } - if (open_launcher) + /* start new popup timeout */ + if (launcher->popup_timeout_id == 0) { - gtk_widget_hide (GTK_MENU (open_launcher->menu)->toplevel); - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (open_launcher->arrowbutton), FALSE); - open_launcher = NULL; + launcher->popup_timeout_id = + g_timeout_add (MENU_POPUP_DELAY, + (GSourceFunc) launcher_menu_popup, + launcher); } -} -static void -launcher_menu_deactivated (GtkWidget *menu, LauncherPlugin *launcher) -{ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (launcher->arrowbutton), - FALSE); - launcher->from_timeout = FALSE; + return FALSE; } + + static gboolean -launcher_button_released (GtkWidget *mi, GdkEventButton *ev, - LauncherPlugin *launcher) +launcher_button_released (GtkWidget *button, + GdkEventButton *ev, + LauncherPlugin *launcher) { - if (launcher->from_timeout) + LauncherEntry *entry; + + /* stop the timeout (from button press) if it's still running */ + if (launcher->popup_timeout_id > 0) { - launcher->from_timeout = FALSE; - /* don't activate on button release */ - return TRUE; + g_source_remove (launcher->popup_timeout_id); + launcher->popup_timeout_id = 0; } - + + /* if button is 2, start command with arg from clipboard */ if (ev->button == 2) { - LauncherEntry *entry = - g_object_get_data (G_OBJECT (mi), "launcher_entry"); - - if (entry != NULL) - { - launcher_entry_clipboard_cb (gtk_widget_get_screen (mi), entry); + entry = g_list_first (launcher->entries)->data; - gtk_menu_popdown (GTK_MENU (launcher->menu)); - launcher_menu_deactivated(launcher->menu, launcher); - } - return TRUE; + launcher_execute_from_clipboard (gtk_widget_get_screen (button), entry); } - /* don't activate on right-click */ - if (ev->button == 3) - return TRUE; - return FALSE; } -static void -launcher_menu_item_activate (GtkWidget *mi, LauncherEntry *entry) -{ - launcher_entry_exec (gtk_widget_get_screen (mi), entry); -} + +/** + * Arrow button functions + **/ static gboolean -launcher_menu_drag_leave_timeout (LauncherPlugin *launcher) +launcher_arrow_pressed (LauncherPlugin *launcher, + GdkEventButton *ev) { - GdkScreen *screen = gtk_widget_get_screen (launcher->arrowbutton); - GdkDisplay *dpy = gdk_screen_get_display (screen); - int x, y, wx, wy, ww, wh; - - gdk_display_get_pointer (dpy, NULL, &x, &y, NULL); - - gdk_window_get_root_origin (launcher->menu->window, &wx, &wy); - gdk_drawable_get_size (GDK_DRAWABLE (launcher->menu->window), &ww, &wh); - - if (x < wx || x > wx + ww || y < wy || y > wy +wh) - { - gtk_widget_hide (GTK_MENU (launcher->menu)->toplevel); - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (launcher->arrowbutton), FALSE); - } - - return FALSE; -} + /* only popup on 1st button */ + if (G_UNLIKELY (ev->button != 1)) + return FALSE; -static void -launcher_menu_drag_leave (GtkWidget *w, GdkDragContext *drag_context, - guint time, LauncherPlugin *launcher) -{ - g_timeout_add (100, (GSourceFunc)launcher_menu_drag_leave_timeout, - launcher); + /* popup menu */ + launcher_menu_popup (launcher); + + return FALSE; } -static void -launcher_destroy_menu (LauncherPlugin *launcher) -{ - gtk_widget_destroy (launcher->menu); - launcher->menu = NULL; -} static gboolean -load_menu_icons (LauncherPlugin *launcher) +launcher_arrow_drag_motion (GtkToggleButton *button, + GdkDragContext *drag_context, + gint x, + gint y, + guint time, + LauncherPlugin *launcher) { - GtkWidget *img, *mi; - GdkPixbuf *pb; - LauncherEntry *entry; - int i; - GList *children, *li; - - if (!launcher->menu) - return FALSE; + /* we need to popup the menu to allow a drop in a menu item, but + * since there is no good way to do this (because the pointer is grabbed) + * we do nothing... */ + return TRUE; +} - children = gtk_container_get_children (GTK_CONTAINER (launcher->menu)); - for (li = children, i = 1; li != 0; li = li->next, ++i) - { - entry = g_ptr_array_index (launcher->entries, i); - mi = li->data; - - pb = launcher_icon_load_pixbuf (GTK_WIDGET (mi), &entry->icon, - MENU_ICON_SIZE); - img = gtk_image_new_from_pixbuf (pb); - gtk_widget_show (img); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img); - g_object_unref (G_OBJECT (pb)); - } - g_list_free (children); +/** + * Menu functions + **/ +static void +launcher_menu_item_activate (GtkWidget *mi, + GList *li) +{ + /* execute command */ + launcher_execute (gtk_widget_get_screen (mi), li->data, NULL); - return FALSE; + /* reorder list, if needed */ + launcher_g_list_move_first (li); } -void -launcher_recreate_menu (LauncherPlugin *launcher) -{ - int i; - - if (launcher->menu) - launcher_destroy_menu (launcher); - if (launcher->entries->len <= 1) - { - gtk_widget_hide (launcher->arrowbutton); - return; - } - - launcher->menu = gtk_menu_new (); - for (i = launcher->entries->len - 1; i > 0; --i) +static gboolean +launcher_menu_item_released (GtkWidget *mi, + GdkEventButton *ev, + GList *li) +{ + if (ev->button == 2) { - GtkWidget *mi; - LauncherEntry *entry = g_ptr_array_index (launcher->entries, i); - - mi = gtk_image_menu_item_new_with_label (entry->name ? - entry->name : _("New Item")); - gtk_widget_show (mi); - gtk_menu_shell_prepend (GTK_MENU_SHELL (launcher->menu), mi); + /* execute command with arg from clipboard */ + launcher_execute_from_clipboard (gtk_widget_get_screen (mi), li->data); - /* delayed loading of icons */ - g_object_set_data (G_OBJECT (mi), "launcher_entry", entry); - - g_signal_connect (mi, "button-release-event", - G_CALLBACK (launcher_button_released), - launcher); - - g_signal_connect (mi, "activate", - G_CALLBACK (launcher_menu_item_activate), entry); - - gtk_tooltips_set_tip (launcher->tips, mi, entry->comment, NULL); - - launcher_set_drag_dest (mi); - - g_signal_connect (mi, "drag-data-received", - G_CALLBACK (launcher_entry_data_received), entry); - - g_signal_connect (mi, "drag-leave", - G_CALLBACK (launcher_menu_drag_leave), launcher); - } + /* reorder list, if needed */ + launcher_g_list_move_first (li); - g_signal_connect (launcher->menu, "button-release-event", - G_CALLBACK (launcher_button_released), - launcher); - - g_signal_connect (launcher->menu, "deactivate", - G_CALLBACK (launcher_menu_deactivated), launcher); - - launcher_set_drag_dest (launcher->menu); - - g_signal_connect (launcher->menu, "drag-leave", - G_CALLBACK (launcher_menu_drag_leave), launcher); - - if (launcher->entries->len > 1) - { - g_idle_add ((GSourceFunc) load_menu_icons, launcher); + return TRUE; } -} - -void -launcher_update_panel_entry (LauncherPlugin *launcher) -{ - char tip[512]; - GdkPixbuf *pb; - int size; - LauncherEntry *entry; - if (launcher->entries->len == 0) - return; - - entry = g_ptr_array_index (launcher->entries, 0); + return FALSE; +} - size = xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (launcher->plugin)) - - 2 - 2 * MAX (launcher->iconbutton->style->xthickness, - launcher->iconbutton->style->ythickness); - - pb = launcher_icon_load_pixbuf (launcher->image, &(entry->icon), size); - gtk_image_set_from_pixbuf (GTK_IMAGE (launcher->image), pb); - g_object_unref (G_OBJECT (pb)); - - if (entry->name || entry->comment) - { - if (entry->name && entry->comment) - g_snprintf (tip, 521, "%s\n%s", entry->name, entry->comment); - else if (entry->name) - g_strlcpy (tip, entry->name, 521); - else - g_strlcpy (tip, entry->comment, 521); - gtk_tooltips_set_tip (launcher->tips, launcher->iconbutton, tip, NULL); - } - else - { - gtk_tooltips_set_tip (launcher->tips, launcher->iconbutton, NULL, NULL); - } -} static void -launcher_position_menu (GtkMenu * menu, int *x, int *y, gboolean * push_in, - GtkWidget *b) +launcher_menu_position (GtkMenu *menu, + gint *x, + gint *y, + gboolean *push_in, + GtkWidget *button) { - GtkWidget *widget; - GtkRequisition req; - GdkScreen *screen; - GdkRectangle geom; - int num; - - widget = b->parent->parent; - + GtkWidget *widget; + GtkRequisition req; + GdkScreen *screen; + GdkRectangle geom; + gint num; + if (!GTK_WIDGET_REALIZED (GTK_WIDGET (menu))) gtk_widget_realize (GTK_WIDGET (menu)); gtk_widget_size_request (GTK_WIDGET (menu), &req); + widget = button->parent->parent; gdk_window_get_origin (widget->window, x, y); - widget = b->parent; - - switch (xfce_arrow_button_get_arrow_type (XFCE_ARROW_BUTTON (b))) + widget = button->parent; + + switch (xfce_arrow_button_get_arrow_type (XFCE_ARROW_BUTTON (button))) { + case GTK_ARROW_NONE: case GTK_ARROW_UP: *x += widget->allocation.x; *y += widget->allocation.y - req.height; @@ -787,21 +582,19 @@ launcher_position_menu (GtkMenu * menu, int *x, int *y, gboolean * push_in, case GTK_ARROW_LEFT: *x += widget->allocation.x - req.width; *y += widget->allocation.y - req.height - + widget->allocation.height; + + widget->allocation.height; break; case GTK_ARROW_RIGHT: *x += widget->allocation.x + widget->allocation.width; *y += widget->allocation.y - req.height - + widget->allocation.height; - break; - default: + + widget->allocation.height; break; } screen = gtk_widget_get_screen (widget); + num = gdk_screen_get_monitor_at_window (screen, widget->window); - gtk_menu_set_screen (menu, screen); gdk_screen_get_monitor_geometry (screen, num, &geom); if (*x > geom.x + geom.width - req.width) @@ -815,309 +608,474 @@ launcher_position_menu (GtkMenu * menu, int *x, int *y, gboolean * push_in, *y = geom.y; } + + static gboolean -real_toggle_menu (LauncherPlugin *launcher) +launcher_menu_popup (LauncherPlugin *launcher) { - if (launcher->menu) + /* stop timeout if needed */ + if (launcher->popup_timeout_id > 0) { - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (launcher->arrowbutton), TRUE); - - xfce_panel_plugin_register_menu (XFCE_PANEL_PLUGIN (launcher->plugin), - GTK_MENU (launcher->menu)); - - gtk_menu_popup (GTK_MENU (launcher->menu), NULL, NULL, - (GtkMenuPositionFunc) launcher_position_menu, - launcher->arrowbutton, 0, - gtk_get_current_event_time ()); + g_source_remove (launcher->popup_timeout_id); + launcher->popup_timeout_id = 0; } - launcher->popup_timeout = 0; - return FALSE; + /* check if menu is needed, or it needs an update */ + if (g_list_length (launcher->entries) <= 1) + return FALSE; + else if (launcher->menu == NULL) + launcher_menu_update (launcher); + + /* toggle the arrow button */ + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (launcher->arrowbutton), TRUE); + + /* popup menu */ + gtk_menu_popup (GTK_MENU (launcher->menu), NULL, NULL, + (GtkMenuPositionFunc) launcher_menu_position, + launcher->arrowbutton, 0, + gtk_get_current_event_time ()); + + return TRUE; } -static gboolean -launcher_toggle_menu_timeout (GtkToggleButton *b, GdkEventButton *ev, - LauncherPlugin *launcher) -{ - guint modifiers; - modifiers = gtk_accelerator_get_default_mod_mask (); - if (ev->button != 1 || (ev->button == 1 && - (ev->state & modifiers) == GDK_CONTROL_MASK)) - { - return FALSE; - } +static void +launcher_menu_deactivated (LauncherPlugin *launcher) +{ + /* deactivate arrow button */ + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (launcher->arrowbutton), FALSE); - if (launcher->popup_timeout < 1) + /* rebuild menu and button */ + if (move_first) { - launcher->from_timeout = TRUE; - - launcher->popup_timeout = - g_timeout_add (MENU_TIMEOUT, (GSourceFunc)real_toggle_menu, - launcher); - } + launcher->icon_update_required = TRUE; + g_idle_add ((GSourceFunc) launcher_button_update, launcher); - return FALSE; + g_idle_add ((GSourceFunc) launcher_menu_prepare, launcher); + } } -static gboolean -launcher_toggle_menu (GtkToggleButton *b, GdkEventButton *ev, - LauncherPlugin *launcher) -{ - guint modifiers; - modifiers = gtk_accelerator_get_default_mod_mask (); - if (ev->button != 1 || (ev->button == 1 && - (ev->state & modifiers) == GDK_CONTROL_MASK)) +gboolean +launcher_menu_prepare (LauncherPlugin *launcher) +{ + if (launcher->menu != NULL) { - return FALSE; + g_signal_emit_by_name (G_OBJECT (launcher->menu), "deactivate"); + gtk_widget_destroy (launcher->menu); + launcher->menu = NULL; } - real_toggle_menu (launcher); + /* show or hide the arrow button */ + if (g_list_length (launcher->entries) <= 1) + gtk_widget_hide (launcher->arrowbutton); + else + gtk_widget_show (launcher->arrowbutton); - return TRUE; + return FALSE; } + + static gboolean -launcher_arrow_drag (GtkToggleButton * tb, GdkDragContext *drag_context, - gint x, gint y, guint time, LauncherPlugin * launcher) +launcher_menu_update (LauncherPlugin *launcher) { - int push_in; + GList *li; + GtkWidget *mi, *image; + GdkPixbuf *icon; + LauncherEntry *entry; - if (open_launcher && open_launcher != launcher) - { - gtk_widget_hide (open_launcher->menu); - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (open_launcher->arrowbutton), FALSE); - open_launcher = NULL; - } - - gtk_toggle_button_set_active (tb, TRUE); + /* destroy the old menu, if needed */ + if (G_UNLIKELY (launcher->menu != NULL)) + launcher_menu_prepare (launcher); + + /* create new menu */ + launcher->menu = gtk_menu_new (); - gtk_widget_show (launcher->menu); + /* make sure the menu popups up in right screen */ + gtk_menu_set_screen (GTK_MENU (launcher->menu), + gtk_widget_get_screen (GTK_WIDGET (launcher->plugin))); + /* append all entries, except first one */ + for (li = g_list_nth (launcher->entries, 1); li != NULL; li = li->next) { - GtkRequisition tmp_request; - GtkAllocation tmp_allocation = { 0, }; + entry = li->data; - gtk_widget_size_request (GTK_MENU (launcher->menu)->toplevel, - &tmp_request); + /* create new menu item */ + mi = gtk_image_menu_item_new_with_label (entry->name ? entry->name : _("New Item")); + gtk_widget_show (mi); + gtk_menu_shell_prepend (GTK_MENU_SHELL (launcher->menu), mi); - tmp_allocation.width = tmp_request.width; - tmp_allocation.height = tmp_request.height; + /* load and set menu icon */ + icon = launcher_load_pixbuf (launcher->iconbutton, entry->icon, MENU_ICON_SIZE, FALSE); - gtk_widget_size_allocate (GTK_MENU (launcher->menu)->toplevel, - &tmp_allocation); + if (G_LIKELY (icon != NULL)) + { + image = gtk_image_new_from_pixbuf (icon); + gtk_widget_show (image); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), image); - gtk_widget_realize (launcher->menu); - } + /* release pixbuf */ + g_object_unref (G_OBJECT (icon)); + } - launcher_position_menu (GTK_MENU (launcher->menu), &x, &y, &push_in, - GTK_WIDGET (tb)); + /* connect signals */ + g_signal_connect (G_OBJECT (mi), "activate", + G_CALLBACK (launcher_menu_item_activate), li); - gtk_window_move (GTK_WINDOW (GTK_MENU (launcher->menu)->toplevel), - x, y); + g_signal_connect (G_OBJECT (mi), "button-release-event", + G_CALLBACK (launcher_menu_item_released), li); - gtk_widget_show (GTK_MENU (launcher->menu)->toplevel); + /* dnd support */ + gtk_drag_dest_set (mi, GTK_DEST_DEFAULT_ALL, + drop_targets, G_N_ELEMENTS (drop_targets), + GDK_ACTION_COPY); - open_launcher = launcher; + g_signal_connect (G_OBJECT (mi), "drag-data-received", + G_CALLBACK (launcher_menu_drag_data_received), entry); - return TRUE; -} - -static void -launcher_state_changed (GtkWidget *b1, GtkStateType state, GtkWidget *b2) -{ - if (GTK_WIDGET_STATE (b2) != GTK_WIDGET_STATE (b1) - && GTK_WIDGET_STATE (b1) != GTK_STATE_INSENSITIVE) - { - gtk_widget_set_state (b2, GTK_WIDGET_STATE (b1)); + /* set tooltip */ + if (G_LIKELY (entry->comment)) + gtk_tooltips_set_tip (launcher->tips, mi, entry->comment, NULL); } + + /* connect deactivate signal */ + g_signal_connect_swapped (G_OBJECT (launcher->menu), "deactivate", + G_CALLBACK (launcher_menu_deactivated), launcher); + + return FALSE; } -static void -launcher_clicked (GtkWidget *w, LauncherPlugin *launcher) + + +/** + * Save and load settings + **/ +static gchar * +launcher_read_entry (XfceRc *rc, + const gchar *name) { - if (launcher->popup_timeout > 0) - { - g_source_remove (launcher->popup_timeout); - launcher->popup_timeout = 0; - launcher->from_timeout = FALSE; - } + const gchar *temp; + gchar *value = NULL; - launcher_entry_exec (gtk_widget_get_screen (w), - g_ptr_array_index (launcher->entries, 0)); + temp = xfce_rc_read_entry (rc, name, NULL); + if (G_LIKELY (temp != NULL && *temp != '\0')) + value = g_strdup (temp); + + return value; } -static gboolean -launcher_released (GtkWidget *b, GdkEventButton *ev, LauncherPlugin *launcher) + + +void +launcher_read (LauncherPlugin *launcher) { - if (ev->button == 2) - { - LauncherEntry *entry = g_ptr_array_index (launcher->entries, 0); + gchar *file; + gchar group[10]; + XfceRc *rc; + guint i; + LauncherEntry *entry; - launcher_entry_clipboard_cb (gtk_widget_get_screen (b), entry); + /* get rc file name, create it if needed */ + file = xfce_panel_plugin_save_location (launcher->plugin, TRUE); - return TRUE; - } + if (G_UNLIKELY (file == NULL)) + return; - return FALSE; -} + /* open rc, read-only */ + rc = xfce_rc_simple_open (file, TRUE); + g_free (file); -/* Read Configuration Data */ + if (G_UNLIKELY (rc == NULL)) + return; -static LauncherEntry* -launcher_entry_from_rc_file (XfceRc *rc) -{ - LauncherEntry *entry = launcher_entry_new (); - const char *s; + /* read global settings */ + xfce_rc_set_group (rc, "Global"); - if ((s = xfce_rc_read_entry (rc, "Name", NULL)) != NULL) - entry->name = g_strdup (s); + launcher->move_first = xfce_rc_read_bool_entry (rc, "MoveFirst", FALSE); - if ((s = xfce_rc_read_entry (rc, "Exec", NULL)) != NULL) + for (i = 0; i < 100 /* arbitrary */; ++i) { - entry->exec = g_strdup (s); - - if (!(entry->real_exec = xfce_expand_variables (entry->exec, NULL))) - entry->real_exec = g_strdup (entry->exec); - } + /* create group name */ + g_snprintf (group, sizeof (group), "Entry %d", i); - entry->terminal = xfce_rc_read_bool_entry (rc, "Terminal", FALSE); - - entry->startup = xfce_rc_read_bool_entry (rc, "StartupNotify", FALSE); + /* break if no more entries found */ + if (xfce_rc_has_group (rc, group) == FALSE) + break; - if ((s = xfce_rc_read_entry (rc, "Comment", NULL)) != NULL) - entry->comment = g_strdup (s); + /* set the group */ + xfce_rc_set_group (rc, group); - if ((s = xfce_rc_read_entry (rc, "Icon", NULL)) != NULL) - { - entry->icon.type = LAUNCHER_ICON_TYPE_NAME; - entry->icon.icon.name = g_strdup (s); - } - else - { - entry->icon.type = LAUNCHER_ICON_TYPE_CATEGORY; - entry->icon.icon.category = - xfce_rc_read_int_entry (rc, "X-XFCE-IconCategory", 0); + /* create new entry structure */ + entry = panel_slice_new0 (LauncherEntry); + + /* read all the entry settings */ + entry->name = launcher_read_entry (rc, "Name"); + entry->comment = launcher_read_entry (rc, "Comment"); + entry->icon = launcher_read_entry (rc, "Icon"); + entry->exec = launcher_read_entry (rc, "Exec"); + entry->path = launcher_read_entry (rc, "Path"); + + entry->terminal = xfce_rc_read_bool_entry (rc, "Terminal", FALSE); +#ifdef HAVE_LIBSTARTUP_NOTIFICATION + entry->startup = xfce_rc_read_bool_entry (rc, "StartupNotify", FALSE); +#endif + /* append the entry */ + launcher->entries = g_list_append (launcher->entries, entry); } - return entry; + /* close the rc file */ + xfce_rc_close (rc); } -static void -launcher_read_rc_file (XfcePanelPlugin *plugin, LauncherPlugin *launcher) + + +void +launcher_write (LauncherPlugin *launcher) { - XfceRc *rc; - char *file; - int i; - - if (!(file = xfce_panel_plugin_lookup_rc_file (plugin))) + gchar *file; + gchar **groups; + gchar group[10]; + XfceRc *rc; + GList *li; + guint i = 0, n; + guint block; + LauncherEntry *entry; + + /* HACK: + * sometimes the panel emits a save signal, this is cool, unless we're working + * in the properties dialog. This because the cancel button won't work then. */ + block = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (launcher->plugin), + "xfce-panel-plugin-block")); + if (G_UNLIKELY (block > 0)) return; - rc = xfce_rc_simple_open (file, TRUE); + /* get rc file name, create it if needed */ + file = xfce_panel_plugin_save_location (launcher->plugin, TRUE); + + if (G_UNLIKELY (file == NULL)) + return; + + /* open rc, read/write */ + rc = xfce_rc_simple_open (file, FALSE); g_free (file); - if (!rc) + if (G_UNLIKELY (rc == NULL)) return; - - for (i = 0; i < 100 /* arbitrary */; ++i) + + /* retreive all the groups in the config file */ + groups = xfce_rc_get_groups (rc); + + /* remove all the groups + * note: you can use g_unlink to remove the file, but first you need some + * stdio library and some benchmarking showed this is almost 2x faster for + * 'normal' situations */ + for (n = 0; groups[n] != NULL; ++n) + xfce_rc_delete_group (rc, groups[n], TRUE); + + /* cleanup */ + g_strfreev (groups); + + /* save global launcher settings */ + xfce_rc_set_group (rc, "Global"); + + xfce_rc_write_bool_entry (rc, "MoveFirst", launcher->move_first); + + /* save all the entries */ + for (li = launcher->entries; li != NULL; li = li->next, ++i) { - LauncherEntry *entry; - char group[10]; - - g_snprintf (group, 10, "Entry %d", i); - - if (!xfce_rc_has_group (rc, group)) - break; - + entry = li->data; + + /* set entry group */ + g_snprintf (group, sizeof (group), "Entry %d", i); xfce_rc_set_group (rc, group); - if ((entry = launcher_entry_from_rc_file (rc)) != NULL) - g_ptr_array_add (launcher->entries, entry); + /* write entry settings */ + if (G_LIKELY (entry->name)) + xfce_rc_write_entry (rc, "Name", entry->name); + + if (G_LIKELY (entry->comment)) + xfce_rc_write_entry (rc, "Comment", entry->comment); + + if (G_LIKELY (entry->icon)) + xfce_rc_write_entry (rc, "Icon", entry->icon); + + if (G_LIKELY (entry->exec)) + xfce_rc_write_entry (rc, "Exec", entry->exec); + + if (G_LIKELY (entry->path)) + xfce_rc_write_entry (rc, "Path", entry->path); + + xfce_rc_write_bool_entry (rc, "Terminal", entry->terminal); +#ifdef HAVE_LIBSTARTUP_NOTIFICATION + xfce_rc_write_bool_entry (rc, "StartupNotify", entry->startup); +#endif } - + + /* close the rc file */ xfce_rc_close (rc); - - launcher_update_panel_entry (launcher); - launcher_recreate_menu (launcher); } -/* Write Configuration Data */ -static void -launcher_entry_write_rc_file (LauncherEntry *entry, XfceRc *rc) + +LauncherEntry * +launcher_new_entry (void) { - if (entry->name) - xfce_rc_write_entry (rc, "Name", entry->name); + LauncherEntry *entry; - if (entry->exec) - xfce_rc_write_entry (rc, "Exec", entry->exec); + /* create new entry slice */ + entry = panel_slice_new0 (LauncherEntry); - xfce_rc_write_bool_entry (rc, "Terminal", entry->terminal); - - xfce_rc_write_bool_entry (rc, "StartupNotify", entry->startup); - - if (entry->comment) - xfce_rc_write_entry (rc, "Comment", entry->comment); + /* set some default values */ + entry->name = g_strdup (_("New Item")); + entry->comment = NULL; /* _("This item has not yet been configured")); */ + entry->icon = g_strdup ("applications-other"); - if (entry->icon.type == LAUNCHER_ICON_TYPE_CATEGORY) - { - xfce_rc_write_int_entry (rc, "X-XFCE-IconCategory", - entry->icon.icon.category); - } - else if (entry->icon.type == LAUNCHER_ICON_TYPE_NAME) - { - xfce_rc_write_entry (rc, "Icon", entry->icon.icon.name); - } + /* fill others */ + entry->exec = NULL; + entry->path = NULL; + entry->terminal = FALSE; +#ifdef HAVE_LIBSTARTUP_NOTIFICATION + entry->startup = FALSE; +#endif + + return entry; } -static void -launcher_write_rc_file (XfcePanelPlugin *plugin, LauncherPlugin *launcher) + + +/** + * Plugin create function and signal handling + **/ +static LauncherPlugin* +launcher_new (XfcePanelPlugin *plugin) { - char *file; - XfceRc *rc; - char group[10]; - int i; + LauncherPlugin *launcher; + LauncherEntry *entry; + GtkWidget *box; + XfceScreenPosition position; + gpointer klass; - if (!(file = xfce_panel_plugin_save_location (plugin, TRUE))) - return; + /* get panel information */ + position = xfce_panel_plugin_get_screen_position (plugin); - unlink (file); - - rc = xfce_rc_simple_open (file, FALSE); - g_free (file); + launcher = panel_slice_new0 (LauncherPlugin); - if (!rc) - return; - - for (i = 0; i < launcher->entries->len; ++i) - { - LauncherEntry *entry = g_ptr_array_index (launcher->entries, i); + /* link plugin */ + launcher->plugin = plugin; - g_snprintf (group, 10, "Entry %d", i); + /* defaults */ + launcher->menu = NULL; - xfce_rc_set_group (rc, group); + /* create tooltips */ + launcher->tips = gtk_tooltips_new (); + exo_gtk_object_ref_sink (GTK_OBJECT (launcher->tips)); + + /* create widgets */ + box = xfce_hvbox_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); + gtk_container_add (GTK_CONTAINER (plugin), box); + gtk_widget_show (box); + + launcher->iconbutton = xfce_create_panel_button (); + gtk_widget_show (launcher->iconbutton); + gtk_box_pack_start (GTK_BOX (box), launcher->iconbutton, TRUE, TRUE, 0); + + gtk_drag_dest_set (launcher->iconbutton, GTK_DEST_DEFAULT_ALL, + drop_targets, G_N_ELEMENTS (drop_targets), + GDK_ACTION_COPY); + + launcher->image = gtk_image_new (); + gtk_widget_show (launcher->image); + gtk_container_add (GTK_CONTAINER (launcher->iconbutton), launcher->image); + + launcher->arrowbutton = xfce_arrow_button_new (GTK_ARROW_UP); + GTK_WIDGET_UNSET_FLAGS (launcher->arrowbutton, GTK_CAN_DEFAULT|GTK_CAN_FOCUS); + gtk_box_pack_start (GTK_BOX (box), launcher->arrowbutton, FALSE, FALSE, 0); + gtk_widget_set_size_request (launcher->arrowbutton, ARROW_WIDTH, ARROW_WIDTH); + gtk_button_set_relief (GTK_BUTTON (launcher->arrowbutton), GTK_RELIEF_NONE); + gtk_button_set_focus_on_click (GTK_BUTTON (launcher->arrowbutton), FALSE); + + gtk_drag_dest_set (launcher->arrowbutton, GTK_DEST_DEFAULT_ALL, + drop_targets, G_N_ELEMENTS (drop_targets), + GDK_ACTION_COPY); + + /* signals for button state sync */ + g_signal_connect (G_OBJECT (launcher->iconbutton), "enter", + G_CALLBACK (launcher_button_pointer), launcher->arrowbutton); + g_signal_connect (G_OBJECT (launcher->iconbutton), "leave", + G_CALLBACK (launcher_button_pointer), launcher->arrowbutton); + g_signal_connect (G_OBJECT (launcher->arrowbutton), "enter", + G_CALLBACK (launcher_button_pointer), launcher->iconbutton); + g_signal_connect (G_OBJECT (launcher->arrowbutton), "leave", + G_CALLBACK (launcher_button_pointer), launcher->iconbutton); + + /* hook for icon themes changes */ + klass = g_type_class_ref (GTK_TYPE_ICON_THEME); + launcher->theme_timeout_id = g_signal_add_emission_hook (g_signal_lookup ("changed", GTK_TYPE_ICON_THEME), + 0, (GSignalEmissionHook) launcher_theme_changed, + launcher, NULL); + g_type_class_unref (klass); + + /* icon button signals */ + g_signal_connect (G_OBJECT (launcher->iconbutton), "clicked", + G_CALLBACK (launcher_button_clicked), launcher); + + g_signal_connect_swapped (G_OBJECT (launcher->iconbutton), "button-press-event", + G_CALLBACK (launcher_button_pressed), launcher); + + g_signal_connect (G_OBJECT (launcher->iconbutton), "button-release-event", + G_CALLBACK (launcher_button_released), launcher); + + g_signal_connect (G_OBJECT (launcher->iconbutton), "drag-data-received", + G_CALLBACK (launcher_button_drag_data_received), launcher); + + /* this signal with update the button (show icon) when the button is realizde */ + launcher->icon_update_required = TRUE; + g_signal_connect_swapped (G_OBJECT (launcher->iconbutton), "realize", + G_CALLBACK (launcher_button_update), launcher); + + /* arrow button signals */ + g_signal_connect_swapped (G_OBJECT (launcher->arrowbutton), "button-press-event", + G_CALLBACK (launcher_arrow_pressed), launcher); + + g_signal_connect (G_OBJECT (launcher->arrowbutton), "drag-motion", + G_CALLBACK (launcher_arrow_drag_motion), launcher); + + /* read the user settings */ + launcher_read (launcher); + + /* set move_first boolean */ + launcher_set_move_first (launcher->move_first); + + /* append new entry if no entries loaded */ + if (G_UNLIKELY (g_list_length (launcher->entries) == 0)) + { + entry = launcher_new_entry (); - launcher_entry_write_rc_file (entry, rc); + launcher->entries = g_list_append (launcher->entries, entry); } - xfce_rc_close (rc); + /* set arrow position */ + launcher_screen_position_changed (launcher, position); + + /* prepare the menu */ + launcher_menu_prepare (launcher); + + return launcher; } -/* position and orientation */ + + static GtkArrowType -calculate_floating_arrow_type (LauncherPlugin *launcher, - XfceScreenPosition position) +launcher_calculate_floating_arrow (LauncherPlugin *launcher, + XfceScreenPosition position) { - GtkArrowType type = GTK_ARROW_UP; - int mon, x, y; - GdkScreen *screen; - GdkRectangle geom; - + gint mon, x, y; + GdkScreen *screen; + GdkRectangle geom; + if (!GTK_WIDGET_REALIZED (launcher->iconbutton)) { if (xfce_screen_position_is_horizontal (position)) @@ -1125,220 +1083,165 @@ calculate_floating_arrow_type (LauncherPlugin *launcher, else return GTK_ARROW_LEFT; } - + screen = gtk_widget_get_screen (launcher->iconbutton); - mon = gdk_screen_get_monitor_at_window (screen, + mon = gdk_screen_get_monitor_at_window (screen, launcher->iconbutton->window); gdk_screen_get_monitor_geometry (screen, mon, &geom); - + gdk_window_get_root_origin (launcher->iconbutton->window, &x, &y); - + if (xfce_screen_position_is_horizontal (position)) { if (y > geom.y + geom.height / 2) - type = GTK_ARROW_UP; + return GTK_ARROW_UP; else - type = GTK_ARROW_DOWN; + return GTK_ARROW_DOWN; } else { if (x > geom.x + geom.width / 2) - type = GTK_ARROW_LEFT; + return GTK_ARROW_LEFT; else - type = GTK_ARROW_RIGHT; + return GTK_ARROW_RIGHT; } - - return type; } + + static void -launcher_set_screen_position (LauncherPlugin *launcher, - XfceScreenPosition position) +launcher_screen_position_changed (LauncherPlugin *launcher, + XfceScreenPosition position) { - GtkArrowType type = GTK_ARROW_UP; - - if (xfce_screen_position_is_floating (position)) - { - type = calculate_floating_arrow_type (launcher, position); - } + GtkArrowType type; + + if (xfce_screen_position_is_bottom (position)) + type = GTK_ARROW_UP; else if (xfce_screen_position_is_top (position)) - { type = GTK_ARROW_DOWN; - } else if (xfce_screen_position_is_left (position)) - { type = GTK_ARROW_RIGHT; - } else if (xfce_screen_position_is_right (position)) - { type = GTK_ARROW_LEFT; - } - else if (xfce_screen_position_is_bottom (position)) - { - type = GTK_ARROW_UP; - } - - xfce_arrow_button_set_arrow_type ( - XFCE_ARROW_BUTTON (launcher->arrowbutton), type); -} + else /* floating */ + type = launcher_calculate_floating_arrow (launcher, position); -static void -launcher_set_orientation (XfcePanelPlugin *plugin, - LauncherPlugin *launcher, - GtkOrientation orientation) -{ - xfce_hvbox_set_orientation (XFCE_HVBOX (launcher->box), orientation); + /* set the arrow direction */ + xfce_arrow_button_set_arrow_type (XFCE_ARROW_BUTTON (launcher->arrowbutton), type); } -static void -plugin_icon_theme_changed (GtkWidget *w, gpointer ignored, - LauncherPlugin *launcher) -{ - if (!launcher->plugin) - return; - launcher_update_panel_entry (launcher); - launcher_recreate_menu (launcher); +static void +launcher_orientation_changed (LauncherPlugin *launcher, + GtkOrientation orientation) +{ + /* noting yet */ } -/* Create Launcher Plugin Contents */ -static LauncherPlugin * -launcher_new (XfcePanelPlugin *plugin) -{ - LauncherPlugin *launcher; - int size; - XfceScreenPosition screen_position; - - size = xfce_panel_plugin_get_size (plugin); - screen_position = xfce_panel_plugin_get_screen_position (plugin); - - launcher = panel_slice_new0 (LauncherPlugin); - - launcher->plugin = GTK_WIDGET (plugin); - - launcher->tips = gtk_tooltips_new (); - g_object_ref (G_OBJECT (launcher->tips)); - gtk_object_sink (GTK_OBJECT (launcher->tips)); - - launcher->entries = g_ptr_array_new (); - - if (xfce_screen_position_is_horizontal (screen_position)) - launcher->box = xfce_hvbox_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); - else - launcher->box = xfce_hvbox_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_widget_show (launcher->box); - launcher->iconbutton = xfce_create_panel_button (); - gtk_widget_show (launcher->iconbutton); - gtk_box_pack_start (GTK_BOX (launcher->box), launcher->iconbutton, - TRUE, TRUE, 0); +static gboolean +launcher_set_size (LauncherPlugin *launcher, + guint size) +{ + /* set fixed button size */ gtk_widget_set_size_request (launcher->iconbutton, size, size); - launcher->image = gtk_image_new (); - gtk_widget_show (launcher->image); - gtk_container_add (GTK_CONTAINER (launcher->iconbutton), launcher->image); - - launcher->arrowbutton = xfce_arrow_button_new (GTK_ARROW_UP); - GTK_WIDGET_UNSET_FLAGS (launcher->arrowbutton, - GTK_CAN_DEFAULT|GTK_CAN_FOCUS); - gtk_box_pack_start (GTK_BOX (launcher->box), launcher->arrowbutton, - FALSE, FALSE, 0); - gtk_widget_set_size_request (launcher->arrowbutton, W_ARROW, W_ARROW); - gtk_button_set_relief (GTK_BUTTON (launcher->arrowbutton), - GTK_RELIEF_NONE); - gtk_button_set_focus_on_click (GTK_BUTTON (launcher->arrowbutton), FALSE); - launcher_set_screen_position (launcher, screen_position); - - /* signals */ - launcher->style_id = - g_signal_connect (launcher->image, "style-set", - G_CALLBACK (plugin_icon_theme_changed), launcher); - - launcher->screen_id = - g_signal_connect (launcher->image, "screen-changed", - G_CALLBACK (plugin_icon_theme_changed), launcher); - - g_signal_connect (launcher->iconbutton, "button-press-event", - G_CALLBACK (launcher_toggle_menu_timeout), launcher); - - g_signal_connect (launcher->iconbutton, "clicked", - G_CALLBACK (launcher_clicked), launcher); - - g_signal_connect (launcher->iconbutton, "button-release-event", - G_CALLBACK (launcher_released), launcher); - - g_signal_connect (launcher->arrowbutton, "button-press-event", - G_CALLBACK (launcher_toggle_menu), launcher); - - g_signal_connect (launcher->iconbutton, "state-changed", - G_CALLBACK (launcher_state_changed), - launcher->arrowbutton); - - g_signal_connect (launcher->arrowbutton, "state-changed", - G_CALLBACK (launcher_state_changed), - launcher->iconbutton); - - g_signal_connect (launcher->iconbutton, "destroy", - G_CALLBACK (gtk_widget_destroyed), - &(launcher->iconbutton)); - - g_signal_connect (launcher->iconbutton, "drag-data-received", - G_CALLBACK (launcher_drag_data_received), launcher); - - g_signal_connect (launcher->arrowbutton, "drag-motion", - G_CALLBACK (launcher_arrow_drag), launcher); - - g_signal_connect (launcher->arrowbutton, "drag-leave", - G_CALLBACK (launcher_menu_drag_leave), launcher); - - /* configuration */ - launcher_read_rc_file (plugin, launcher); - - if (launcher->entries->len == 0) + /* reload the icon button */ + if (GTK_WIDGET_REALIZED (launcher->iconbutton)) { - LauncherEntry *entry = entry = panel_slice_new0 (LauncherEntry); + launcher->icon_update_required = TRUE; + launcher_button_update (launcher); + } - entry->name = g_strdup (_("New Item")); - entry->comment = g_strdup (_("This item has not yet been configured")); + return TRUE; +} - g_ptr_array_add (launcher->entries, entry); - launcher_update_panel_entry (launcher); - } - else if (launcher->entries->len > 1) - { - gtk_widget_show (launcher->arrowbutton); - } - launcher_set_drag_dest (launcher->iconbutton); - launcher_set_drag_dest (launcher->arrowbutton); - - return launcher; +void +launcher_free_entry (LauncherEntry *entry, + LauncherPlugin *launcher) +{ + /* remove from the list */ + if (G_LIKELY (launcher != NULL)) + launcher->entries = g_list_remove (launcher->entries, entry); + + /* free variables */ + g_free (entry->name); + g_free (entry->comment); + g_free (entry->path); + g_free (entry->icon); + g_free (entry->exec); + + /* free structure */ + panel_slice_free (LauncherEntry, entry); } -/* Free Launcher Data */ + static void launcher_free (LauncherPlugin *launcher) { - int i; + GtkWidget *dialog; - g_object_unref (G_OBJECT (launcher->tips)); - - for (i = 0; i < launcher->entries->len; ++i) - { - LauncherEntry *e = g_ptr_array_index (launcher->entries, i); + /* check if we still need to destroy the dialog */ + dialog = g_object_get_data (G_OBJECT (launcher->plugin), "dialog"); + if (G_UNLIKELY (dialog != NULL)) + gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); - launcher_entry_free (e); - } + /* stop timeout */ + if (G_UNLIKELY (launcher->popup_timeout_id)) + g_source_remove (launcher->popup_timeout_id); - g_ptr_array_free (launcher->entries, TRUE); + /* remove icon theme change */ + g_signal_remove_emission_hook (g_signal_lookup ("changed", GTK_TYPE_ICON_THEME), + launcher->theme_timeout_id); + /* destroy the popup menu */ if (launcher->menu) gtk_widget_destroy (launcher->menu); - - launcher->plugin = NULL; + + /* remove the entries */ + g_list_foreach (launcher->entries, + (GFunc) launcher_free_entry, launcher); + g_list_free (launcher->entries); + + /* release the tooltips */ + g_object_unref (G_OBJECT (launcher->tips)); + + /* free launcher structure */ panel_slice_free (LauncherPlugin, launcher); } + + + +static void +launcher_construct (XfcePanelPlugin *plugin) +{ + LauncherPlugin *launcher = launcher_new (plugin); + + xfce_panel_plugin_add_action_widget (plugin, launcher->iconbutton); + xfce_panel_plugin_add_action_widget (plugin, launcher->arrowbutton); + xfce_panel_plugin_menu_show_configure (plugin); + + /* connect signals */ + g_signal_connect_swapped (G_OBJECT (plugin), "screen-position-changed", + G_CALLBACK (launcher_screen_position_changed), launcher); + + g_signal_connect_swapped (G_OBJECT (plugin), "orientation-changed", + G_CALLBACK (launcher_orientation_changed), launcher); + + g_signal_connect_swapped (G_OBJECT (plugin), "size-changed", + G_CALLBACK (launcher_set_size), launcher); + + g_signal_connect_swapped (G_OBJECT (plugin), "free-data", + G_CALLBACK (launcher_free), launcher); + + g_signal_connect_swapped (G_OBJECT (plugin), "save", + G_CALLBACK (launcher_write), launcher); + + g_signal_connect_swapped (G_OBJECT (plugin), "configure-plugin", + G_CALLBACK (launcher_dialog_show), launcher); +} diff --git a/plugins/launcher/launcher.desktop.in.in b/plugins/launcher/launcher.desktop.in.in index aad54904f..c31bade6f 100644 --- a/plugins/launcher/launcher.desktop.in.in +++ b/plugins/launcher/launcher.desktop.in.in @@ -5,5 +5,5 @@ _Name=Launcher _Comment=Program launcher with optional menu Icon=gnome-fs-executable X-XFCE-Module=launcher -X-XFCE-Module-Path=@INTERNAL_PLUGIN_PATH@ +X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins diff --git a/plugins/launcher/launcher.h b/plugins/launcher/launcher.h index 2cb351799..8d97a358d 100644 --- a/plugins/launcher/launcher.h +++ b/plugins/launcher/launcher.h @@ -1,8 +1,7 @@ -/* vim: set expandtab ts=8 sw=4: */ - /* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2006-2007 Nick Schermer <nick@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 @@ -19,102 +18,85 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _XFCE_PANEL_LAUNCHER_H -#define _XFCE_PANEL_LAUNCHER_H +#ifndef __XFCE_PANEL_LAUNCHER_H__ +#define __XFCE_PANEL_LAUNCHER_H__ -#define MENU_TIMEOUT 250 -#define BORDER 8 -#define W_ARROW 12 -#define MENU_ICON_SIZE 24 -#define DLG_ICON_SIZE 32 -#define PANEL_ICON_SIZE 48 -#define MIN_ICON_SIZE 12 +#include <gtk/gtk.h> +#include <exo/exo.h> +#include <libxfce4panel/xfce-panel-plugin.h> -typedef enum _LauncherIconType LauncherIconType; -typedef struct _LauncherIcon LauncherIcon; -typedef struct _LauncherEntry LauncherEntry; -typedef struct _LauncherPlugin LauncherPlugin; +#define STARTUP_TIMEOUT (30 * 1000) +#define ARROW_WIDTH 16 +#define MENU_ICON_SIZE 24 +#define MENU_POPUP_DELAY 225 +#define BORDER 8 +#define TREE_ICON_SIZE 24 +#define CHOOSER_ICON_SIZE 48 -/* Drag-and-drop data formats (for the 'info' parameter). */ -enum { - TARGET_URI_LIST, /* text/uri-list */ - TARGET_MOZ_URL /* text/x-moz-url */ -}; +#define g_free_null(mem) g_free (mem); mem = NULL +#define g_slist_free_all(list) g_slist_foreach (list, (GFunc) g_free, NULL); g_slist_free (list) -enum _LauncherIconType -{ - LAUNCHER_ICON_TYPE_NONE, - LAUNCHER_ICON_TYPE_NAME, - LAUNCHER_ICON_TYPE_CATEGORY -}; - -struct _LauncherIcon -{ - LauncherIconType type; - union { - XfceIconThemeCategory category; - char *name; - } icon; -}; +typedef struct _LauncherEntry LauncherEntry; +typedef struct _LauncherPlugin LauncherPlugin; struct _LauncherEntry { - char *name; - char *comment; - char *exec; - char *real_exec; - - LauncherIcon icon; - - guint terminal:1; - guint startup:1; + gchar *name; + gchar *comment; + gchar *exec; + gchar *path; + gchar *icon; + + guint terminal : 1; +#ifdef HAVE_LIBSTARTUP_NOTIFICATION + guint startup : 1; +#endif }; struct _LauncherPlugin { - GPtrArray *entries; - - GtkWidget *plugin; - GtkTooltips *tips; - - /* button + menu */ - GtkWidget *box; - GtkWidget *arrowbutton; - GtkWidget *iconbutton; - GtkWidget *image; - GtkWidget *menu; - - int screen_id; - int style_id; - int popup_timeout; - guint from_timeout:1; + /* globals */ + XfcePanelPlugin *plugin; + GtkTooltips *tips; + GList *entries; + + /* cpu saver */ + guint icon_update_required : 1; + + /* panel widgets */ + GtkWidget *arrowbutton; + GtkWidget *iconbutton; + GtkWidget *image; + GtkWidget *menu; + + /* global settings */ + guint move_first : 1; + + /* timeouts */ + guint popup_timeout_id; + guint theme_timeout_id; }; +/* target types for dropping in the launcher plugin */ +static const GtkTargetEntry drop_targets[] = +{ + { "text/uri-list", 0, 0, }, +}; -/* launcher */ -void launcher_update_panel_entry (LauncherPlugin *launcher); - -void launcher_recreate_menu (LauncherPlugin *launcher); - -void launcher_save (XfcePanelPlugin *plugin, LauncherPlugin *launcher); - - -/* entry */ -LauncherEntry *launcher_entry_new (void); - -void launcher_entry_free (LauncherEntry *entry); - - -/* icon */ -GdkPixbuf * launcher_icon_load_pixbuf (GtkWidget *w, - LauncherIcon *icon, - int size); - - -/* DND */ -void launcher_set_drag_dest (GtkWidget *widget); - -GPtrArray *launcher_get_file_list_from_selection_data (GtkSelectionData *data, - guint info); - -#endif /* _XFCE_PANEL_LAUNCHER_H */ +void launcher_g_list_swap (GList *li_a, + GList *li_b) G_GNUC_INTERNAL; +GdkPixbuf *launcher_load_pixbuf (GtkWidget *widget, + const gchar *icon_name, + guint size, + gboolean fallback) G_GNUC_INTERNAL G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +void launcher_set_move_first (gboolean activate) G_GNUC_INTERNAL; +GSList *launcher_file_list_from_selection (GtkSelectionData *selection_data) G_GNUC_INTERNAL G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; +gboolean launcher_button_update (LauncherPlugin *launcher) G_GNUC_INTERNAL; +gboolean launcher_menu_prepare (LauncherPlugin *launcher) G_GNUC_INTERNAL; +void launcher_read (LauncherPlugin *launcher) G_GNUC_INTERNAL; +void launcher_write (LauncherPlugin *launcher) G_GNUC_INTERNAL; +void launcher_free_entry (LauncherEntry *entry, + LauncherPlugin *launcher) G_GNUC_INTERNAL; +LauncherEntry *launcher_new_entry (void) G_GNUC_INTERNAL G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; + +#endif /* !__XFCE_PANEL_LAUNCHER_H__ */ diff --git a/plugins/pager/Makefile.am b/plugins/pager/Makefile.am index dfc739df6..86fccb17d 100644 --- a/plugins/pager/Makefile.am +++ b/plugins/pager/Makefile.am @@ -1,45 +1,60 @@ -plugindir = $(libdir)/xfce4/panel-plugins +# $Id$ -plugin_LTLIBRARIES = libpager.la +INCLUDES = \ + -I$(top_srcdir) \ + -DG_LOG_DOMAIN=\"libpager\" \ + -DLOCALEDIR=\"$(localedir)\" \ + $(PLATFORM_CPPFLAGS) -libpager_la_LDFLAGS = \ - -avoid-version \ - -module +plugindir = \ + $(libdir)/xfce4/panel-plugins + +plugin_LTLIBRARIES = \ + libpager.la libpager_la_SOURCES = \ pager.c libpager_la_CFLAGS = \ - -I$(top_srcdir) \ - @LIBXFCEGUI4_CFLAGS@ \ - -DLOCALEDIR=\"$(localedir)\" + $(GTK_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCEGUI4_CFLAGS) \ + $(PLATFORM_CFLAGS) -libpager_la_LIBADD = \ - ../../libxfce4panel/libxfce4panel.la \ - @LIBS@ +libpager_la_LDFLAGS = \ + -avoid-version \ + -module \ + $(PLATFORM_LDFLAGS) -libpager_la_DEPENDENCIES = \ - ../../libxfce4panel/libxfce4panel.la - if HAVE_CYGWIN -libpager_la_LDFLAGS += \ - -no-undefined \ - @LIBX11_LDFLAGS@ \ - @LIBXFCEGUI4_LIBS@ \ - @LIBX11_LIBS@ +libpager_la_LDFLAGS += \ + -no-undefined endif +libpager_la_LIBADD = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la \ + $(GTK_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCEGUI4_LIBS) + +libpager_la_DEPENDENCIES = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la + +# # .desktop file # -# Some automake trickery here. Because we cannot use $(libexecdir) in the -# automake stage, we'll use sed to get the full path into the .desktop file. -# We also need to let intltool merge the translated fields, so we add an -# additional level of indirection: a <name>.desktop.in.in file. -# -desktop_in_in_files = pager.desktop.in.in -desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in) - -desktopdir = $(datadir)/xfce4/panel-plugins +desktopdir = \ + $(datadir)/xfce4/panel-plugins + +desktop_in_in_files = \ + pager.desktop.in.in + +desktop_in_files = \ + $(desktop_in_in_files:.desktop.in.in=.desktop.in) + +%.desktop.in: %.desktop.in.in + sed -e "s,\@libdir\@,$(libdir),g" < $< > $@ + desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) @INTLTOOL_DESKTOP_RULE@ @@ -47,12 +62,7 @@ EXTRA_DIST = \ $(desktop_in_in_files) DISTCLEANFILES = \ - $(desktop_DATA) $(desktop_in_files) - -# get full path into .desktop file -%.desktop.in: %.desktop.in.in $(plugin_LTLIBRARIES) - plugin_name=`grep dlname= $(plugin_LTLIBRARIES) | sed "s/dlname='\(.*\)'/\1/"`; \ - sed -e "s^@INTERNAL_PLUGIN_PATH@^$(libdir)/xfce4/panel-plugins^" \ - -e "s^@PLUGIN_NAME@^$$plugin_name^" \ - $< > $@ + $(desktop_DATA) \ + $(desktop_in_files) +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c index 339745b79..4f4aada86 100644 --- a/plugins/pager/pager.c +++ b/plugins/pager/pager.c @@ -5,7 +5,7 @@ * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published + * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * @@ -37,7 +37,7 @@ typedef struct GdkScreen *gdk_screen; GtkWidget *pager; - + int ws_created_id; int ws_destroyed_id; int screen_changed_id; @@ -48,7 +48,7 @@ typedef struct } Pager; -static void pager_properties_dialog (XfcePanelPlugin *plugin, +static void pager_properties_dialog (XfcePanelPlugin *plugin, Pager *pager); static void pager_construct (XfcePanelPlugin *plugin); @@ -65,25 +65,25 @@ XFCE_PANEL_PLUGIN_REGISTER_INTERNAL (pager_construct); /* Interface Implementation */ static void -pager_orientation_changed (XfcePanelPlugin *plugin, - GtkOrientation orientation, +pager_orientation_changed (XfcePanelPlugin *plugin, + GtkOrientation orientation, Pager *pager) { netk_pager_set_orientation (NETK_PAGER (pager->pager), orientation); } -static gboolean +static gboolean pager_set_size (XfcePanelPlugin *plugin, int size) { if (xfce_panel_plugin_get_orientation (plugin) == GTK_ORIENTATION_HORIZONTAL) { - gtk_widget_set_size_request (GTK_WIDGET (plugin), + gtk_widget_set_size_request (GTK_WIDGET (plugin), -1, size); } else { - gtk_widget_set_size_request (GTK_WIDGET (plugin), + gtk_widget_set_size_request (GTK_WIDGET (plugin), size, -1); } @@ -97,7 +97,7 @@ pager_free_data (XfcePanelPlugin *plugin, Pager *pager) if (dlg) gtk_widget_destroy (dlg); - + g_signal_handler_disconnect (plugin, pager->screen_changed_id); if (pager->ws_created_id) @@ -105,7 +105,7 @@ pager_free_data (XfcePanelPlugin *plugin, Pager *pager) g_signal_handler_disconnect (pager->screen, pager->ws_created_id); pager->ws_created_id = 0; } - + if (pager->ws_destroyed_id) { g_signal_handler_disconnect (pager->screen, pager->ws_destroyed_id); @@ -128,7 +128,7 @@ pager_read_rc_file (XfcePanelPlugin *plugin, Pager *pager) XfceRc *rc; int rows = 1; gboolean scrolling = TRUE; - + if ((file = xfce_panel_plugin_lookup_rc_file (plugin)) != NULL) { rc = xfce_rc_simple_open (file, TRUE); @@ -150,7 +150,7 @@ pager_write_rc_file (XfcePanelPlugin *plugin, Pager *pager) { char *file; XfceRc *rc; - + if (!(file = xfce_panel_plugin_save_location (plugin, TRUE))) return; @@ -159,9 +159,9 @@ pager_write_rc_file (XfcePanelPlugin *plugin, Pager *pager) if (!rc) return; - + xfce_rc_write_int_entry (rc, "rows", pager->rows); - + xfce_rc_write_bool_entry (rc, "scrolling", pager->scrolling); xfce_rc_close (rc); @@ -169,10 +169,10 @@ pager_write_rc_file (XfcePanelPlugin *plugin, Pager *pager) /* create widgets and connect to signals */ static void -pager_n_workspaces_changed (NetkScreen * screen, NetkWorkspace * ws, +pager_n_workspaces_changed (NetkScreen * screen, NetkWorkspace * ws, Pager * pager) { - pager_set_size (pager->plugin, + pager_set_size (pager->plugin, xfce_panel_plugin_get_size (pager->plugin)); } @@ -181,8 +181,6 @@ static void pager_screen_size_changed (GdkScreen *screen, Pager *pager); static void pager_screen_changed (GtkWidget *plugin, GdkScreen *screen, Pager *pager) { - screen = gtk_widget_get_screen (plugin); - if (!screen) return; @@ -191,7 +189,7 @@ pager_screen_changed (GtkWidget *plugin, GdkScreen *screen, Pager *pager) g_signal_handler_disconnect (pager->screen, pager->ws_created_id); pager->ws_created_id = 0; } - + if (pager->ws_destroyed_id) { g_signal_handler_disconnect (pager->screen, pager->ws_destroyed_id); @@ -208,17 +206,17 @@ pager_screen_changed (GtkWidget *plugin, GdkScreen *screen, Pager *pager) pager->screen = netk_screen_get (gdk_screen_get_number (screen)); netk_pager_set_screen (NETK_PAGER (pager->pager), pager->screen); - + pager->ws_created_id = g_signal_connect (pager->screen, "workspace-created", G_CALLBACK (pager_n_workspaces_changed), pager); - + pager->ws_destroyed_id = g_signal_connect (pager->screen, "workspace-destroyed", G_CALLBACK (pager_n_workspaces_changed), pager); - pager->screen_size_changed_id = - g_signal_connect (screen, "size-changed", + pager->screen_size_changed_id = + g_signal_connect (screen, "size-changed", G_CALLBACK (pager_screen_size_changed), pager); } @@ -229,27 +227,27 @@ pager_screen_size_changed (GdkScreen *screen, Pager *pager) gtk_widget_queue_resize (GTK_WIDGET (pager->plugin)); } -static void +static void pager_construct (XfcePanelPlugin *plugin) { GdkScreen *screen; int screen_idx; Pager *pager = panel_slice_new0 (Pager); - g_signal_connect (plugin, "orientation-changed", + g_signal_connect (plugin, "orientation-changed", G_CALLBACK (pager_orientation_changed), pager); - - g_signal_connect (plugin, "size-changed", + + g_signal_connect (plugin, "size-changed", G_CALLBACK (pager_set_size), NULL); - - g_signal_connect (plugin, "free-data", + + g_signal_connect (plugin, "free-data", G_CALLBACK (pager_free_data), pager); - - g_signal_connect (plugin, "save", + + g_signal_connect (plugin, "save", G_CALLBACK (pager_write_rc_file), pager); xfce_panel_plugin_menu_show_configure (plugin); - g_signal_connect (plugin, "configure-plugin", + g_signal_connect (plugin, "configure-plugin", G_CALLBACK (pager_properties_dialog), pager); pager->plugin = plugin; @@ -257,33 +255,33 @@ pager_construct (XfcePanelPlugin *plugin) pager->gdk_screen = screen = gtk_widget_get_screen (GTK_WIDGET (plugin)); screen_idx = gdk_screen_get_number (screen); pager->screen = netk_screen_get (screen_idx); - + pager_read_rc_file (plugin, pager); pager->pager = netk_pager_new (pager->screen); - netk_pager_set_orientation (NETK_PAGER (pager->pager), + netk_pager_set_orientation (NETK_PAGER (pager->pager), xfce_panel_plugin_get_orientation (plugin)); netk_pager_set_n_rows (NETK_PAGER (pager->pager), pager->rows); netk_pager_set_workspace_scrolling (NETK_PAGER (pager->pager), pager->scrolling); gtk_widget_show (pager->pager); gtk_container_add (GTK_CONTAINER (plugin), pager->pager); - + pager->ws_created_id = g_signal_connect (pager->screen, "workspace-created", G_CALLBACK (pager_n_workspaces_changed), pager); - + pager->ws_destroyed_id = g_signal_connect (pager->screen, "workspace-destroyed", G_CALLBACK (pager_n_workspaces_changed), pager); - + xfce_panel_plugin_add_action_widget (plugin, pager->pager); - - pager->screen_changed_id = - g_signal_connect (plugin, "screen-changed", + + pager->screen_changed_id = + g_signal_connect (plugin, "screen-changed", G_CALLBACK (pager_screen_changed), pager); - pager->screen_size_changed_id = - g_signal_connect (screen, "size-changed", + pager->screen_size_changed_id = + g_signal_connect (screen, "size-changed", G_CALLBACK (pager_screen_size_changed), pager); } @@ -308,11 +306,11 @@ static void workspace_scrolling_toggled (GtkWidget *button, Pager *pager) { gboolean scrolling = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - + if (pager->scrolling != scrolling) { pager->scrolling = scrolling; - + netk_pager_set_workspace_scrolling (NETK_PAGER (pager->pager), scrolling); } } @@ -334,25 +332,25 @@ pager_properties_dialog (XfcePanelPlugin *plugin, Pager *pager) int max; xfce_panel_plugin_block_menu (plugin); - + dlg = xfce_titled_dialog_new_with_buttons (_("Pager"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); + gtk_window_set_screen (GTK_WINDOW (dlg), + gtk_widget_get_screen (GTK_WIDGET (plugin))); + g_object_set_data (G_OBJECT (plugin), "dialog", dlg); gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER); gtk_window_set_icon_name (GTK_WINDOW (dlg), "xfce4-settings"); - - gtk_window_set_screen (GTK_WINDOW (dlg), - gtk_widget_get_screen (GTK_WIDGET (plugin))); g_signal_connect (dlg, "response", G_CALLBACK (pager_dialog_response), pager); gtk_container_set_border_width (GTK_CONTAINER (dlg), 2); - + vbox = gtk_vbox_new (FALSE, 8); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); gtk_widget_show (vbox); @@ -363,7 +361,7 @@ pager_properties_dialog (XfcePanelPlugin *plugin, Pager *pager) gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - if (xfce_panel_plugin_get_orientation (plugin) == + if (xfce_panel_plugin_get_orientation (plugin) == GTK_ORIENTATION_HORIZONTAL) { label = gtk_label_new (_("Number of rows:")); @@ -371,7 +369,7 @@ pager_properties_dialog (XfcePanelPlugin *plugin, Pager *pager) else { label = gtk_label_new (_("Number of columns:")); - } + } gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); @@ -395,15 +393,15 @@ pager_properties_dialog (XfcePanelPlugin *plugin, Pager *pager) gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); } - + scrolling = gtk_check_button_new_with_mnemonic (_("Switch workspaces using the mouse wheel")); gtk_widget_show (scrolling); gtk_box_pack_start (GTK_BOX (vbox), scrolling, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scrolling), pager->scrolling); - + g_signal_connect (scrolling, "toggled", G_CALLBACK (workspace_scrolling_toggled), pager); - + gtk_widget_show (dlg); } diff --git a/plugins/pager/pager.desktop.in.in b/plugins/pager/pager.desktop.in.in index 32abe5a85..814287d7f 100644 --- a/plugins/pager/pager.desktop.in.in +++ b/plugins/pager/pager.desktop.in.in @@ -5,5 +5,5 @@ _Name=Pager _Comment=Miniature view of all virtual desktops Icon=wksp X-XFCE-Module=pager -X-XFCE-Module-Path=@INTERNAL_PLUGIN_PATH@ +X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins diff --git a/plugins/separator/Makefile.am b/plugins/separator/Makefile.am index 89793f674..77be4e136 100644 --- a/plugins/separator/Makefile.am +++ b/plugins/separator/Makefile.am @@ -1,45 +1,60 @@ -plugindir = $(libdir)/xfce4/panel-plugins +# $Id$ -plugin_LTLIBRARIES = libseparator.la +INCLUDES = \ + -I$(top_srcdir) \ + -DG_LOG_DOMAIN=\"libseparator\" \ + -DLOCALEDIR=\"$(localedir)\" \ + $(PLATFORM_CPPFLAGS) -libseparator_la_LDFLAGS = \ - -avoid-version \ - -module +plugindir = \ + $(libdir)/xfce4/panel-plugins + +plugin_LTLIBRARIES = \ + libseparator.la libseparator_la_SOURCES = \ separator.c libseparator_la_CFLAGS = \ - -I$(top_srcdir) \ - @LIBXFCEGUI4_CFLAGS@ \ - -DLOCALEDIR=\"$(localedir)\" + $(GTK_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCEGUI4_CFLAGS) \ + $(PLATFORM_CFLAGS) -libseparator_la_LIBADD = \ - ../../libxfce4panel/libxfce4panel.la \ - @LIBS@ +libseparator_la_LDFLAGS = \ + -avoid-version \ + -module \ + $(PLATFORM_LDFLAGS) -libseparator_la_DEPENDENCIES = \ - ../../libxfce4panel/libxfce4panel.la - if HAVE_CYGWIN -libseparator_la_LDFLAGS += \ - -no-undefined \ - @LIBX11_LDFLAGS@ \ - @LIBXFCEGUI4_LIBS@ \ - @LIBX11_LIBS@ +libseparator_la_LDFLAGS += \ + -no-undefined endif +libseparator_la_LIBADD = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la \ + $(GTK_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCEGUI4_LIBS) + +libseparator_la_DEPENDENCIES = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la + +# # .desktop file # -# Some automake trickery here. Because we cannot use $(libexecdir) in the -# automake stage, we'll use sed to get the full path into the .desktop file. -# We also need to let intltool merge the translated fields, so we add an -# additional level of indirection: a <name>.desktop.in.in file. -# -desktop_in_in_files = separator.desktop.in.in -desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in) - -desktopdir = $(datadir)/xfce4/panel-plugins +desktopdir = \ + $(datadir)/xfce4/panel-plugins + +desktop_in_in_files = \ + separator.desktop.in.in + +desktop_in_files = \ + $(desktop_in_in_files:.desktop.in.in=.desktop.in) + +%.desktop.in: %.desktop.in.in + sed -e "s,\@libdir\@,$(libdir),g" < $< > $@ + desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) @INTLTOOL_DESKTOP_RULE@ @@ -47,12 +62,7 @@ EXTRA_DIST = \ $(desktop_in_in_files) DISTCLEANFILES = \ - $(desktop_DATA) $(desktop_in_files) - -# get full path into .desktop file -%.desktop.in: %.desktop.in.in $(plugin_LTLIBRARIES) - plugin_name=`grep dlname= $(plugin_LTLIBRARIES) | sed "s/dlname='\(.*\)'/\1/"`; \ - sed -e "s^@INTERNAL_PLUGIN_PATH@^$(libdir)/xfce4/panel-plugins^" \ - -e "s^@PLUGIN_NAME@^$$plugin_name^" \ - $< > $@ + $(desktop_DATA) \ + $(desktop_in_files) +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/plugins/separator/separator.c b/plugins/separator/separator.c index b250646dc..818a8f99a 100644 --- a/plugins/separator/separator.c +++ b/plugins/separator/separator.c @@ -5,7 +5,7 @@ * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published + * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * @@ -50,7 +50,7 @@ XFCE_PANEL_PLUGIN_REGISTER_INTERNAL (separator_construct); /* Interface Implementation */ static gboolean -separator_expose (GtkWidget *widget, GdkEventExpose *event, +separator_expose (GtkWidget *widget, GdkEventExpose *event, XfcePanelPlugin *plugin) { if (GTK_WIDGET_DRAWABLE (widget)) @@ -64,7 +64,7 @@ separator_expose (GtkWidget *widget, GdkEventExpose *event, start = allocation->y + SEP_START * allocation->height; end = allocation->y + SEP_END * allocation->height; position = allocation->x + allocation->width / 2; - + gtk_paint_vline (widget->style, widget->window, GTK_STATE_NORMAL, &(event->area), widget, "separator", @@ -75,8 +75,8 @@ separator_expose (GtkWidget *widget, GdkEventExpose *event, start = allocation->x + SEP_START * allocation->width; end = allocation->x + SEP_END * allocation->width; position = allocation->y + allocation->height / 2; - - gtk_paint_hline (widget->style, widget->window, + + gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL, &(event->area), widget, "separator", start, end, position); @@ -92,35 +92,35 @@ static void separator_add_widget (XfcePanelPlugin *plugin) { GtkWidget *widget; - + widget = gtk_drawing_area_new (); gtk_widget_show (widget); gtk_container_add (GTK_CONTAINER (plugin), widget); - - g_signal_connect (widget, "expose-event", + + g_signal_connect (widget, "expose-event", G_CALLBACK (separator_expose), plugin); } static void -separator_orientation_changed (XfcePanelPlugin *plugin, +separator_orientation_changed (XfcePanelPlugin *plugin, GtkOrientation orientation) { if (GTK_BIN (plugin)->child) gtk_widget_queue_draw (GTK_BIN (plugin)->child); } -static gboolean +static gboolean separator_set_size (XfcePanelPlugin *plugin, int size) { if (xfce_panel_plugin_get_orientation (plugin) == GTK_ORIENTATION_HORIZONTAL) { - gtk_widget_set_size_request (GTK_WIDGET (plugin), + gtk_widget_set_size_request (GTK_WIDGET (plugin), SEPARATOR_WIDTH, size); } else { - gtk_widget_set_size_request (GTK_WIDGET (plugin), + gtk_widget_set_size_request (GTK_WIDGET (plugin), size, SEPARATOR_WIDTH); } @@ -133,10 +133,10 @@ separator_read_rc_file (XfcePanelPlugin *plugin) char *file; XfceRc *rc; int line, expand; - + line = 1; expand = 0; - + if ((file = xfce_panel_plugin_lookup_rc_file (plugin)) != NULL) { rc = xfce_rc_simple_open (file, TRUE); @@ -145,16 +145,16 @@ separator_read_rc_file (XfcePanelPlugin *plugin) if (rc != NULL) { line = xfce_rc_read_int_entry (rc, "draw-separator", 1); - + expand = xfce_rc_read_int_entry (rc, "expand", 0); - + xfce_rc_close (rc); } } if (line) separator_add_widget (plugin); - + if (expand) xfce_panel_plugin_set_expand (plugin, TRUE); } @@ -164,7 +164,7 @@ separator_write_rc_file (XfcePanelPlugin *plugin) { char *file; XfceRc *rc; - + if (!(file = xfce_panel_plugin_save_location (plugin, TRUE))) return; @@ -173,13 +173,13 @@ separator_write_rc_file (XfcePanelPlugin *plugin) if (!rc) return; - - xfce_rc_write_int_entry (rc, "draw-separator", + + xfce_rc_write_int_entry (rc, "draw-separator", GTK_BIN (plugin)->child ? 1 : 0); - xfce_rc_write_int_entry (rc, "expand", - xfce_panel_plugin_get_expand (plugin) ? 1 : 0); - + xfce_rc_write_int_entry (rc, "expand", + xfce_panel_plugin_get_expand (plugin) ? 1 : 0); + xfce_rc_close (rc); } @@ -193,23 +193,23 @@ separator_free_data (XfcePanelPlugin *plugin) } /* create widgets and connect to signals */ -static void +static void separator_construct (XfcePanelPlugin *plugin) { - g_signal_connect (plugin, "orientation-changed", + g_signal_connect (plugin, "orientation-changed", G_CALLBACK (separator_orientation_changed), NULL); - - g_signal_connect (plugin, "size-changed", + + g_signal_connect (plugin, "size-changed", G_CALLBACK (separator_set_size), NULL); - - g_signal_connect (plugin, "save", + + g_signal_connect (plugin, "save", G_CALLBACK (separator_write_rc_file), NULL); - - g_signal_connect (plugin, "free-data", + + g_signal_connect (plugin, "free-data", G_CALLBACK (separator_free_data), NULL); - + xfce_panel_plugin_menu_show_configure (plugin); - g_signal_connect (plugin, "configure-plugin", + g_signal_connect (plugin, "configure-plugin", G_CALLBACK (separator_properties_dialog), NULL); separator_read_rc_file (plugin); @@ -235,7 +235,7 @@ expand_toggled (GtkToggleButton *tb, XfcePanelPlugin *plugin) } static void -separator_dialog_response (GtkWidget *dlg, int reponse, +separator_dialog_response (GtkWidget *dlg, int reponse, XfcePanelPlugin *plugin) { g_object_set_data (G_OBJECT (plugin), "dialog", NULL); @@ -251,25 +251,25 @@ separator_properties_dialog (XfcePanelPlugin *plugin) GtkWidget *dlg, *vbox, *tb; xfce_panel_plugin_block_menu (plugin); - + dlg = xfce_titled_dialog_new_with_buttons (_("Separator or Spacing"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); - gtk_window_set_screen (GTK_WINDOW (dlg), + gtk_window_set_screen (GTK_WINDOW (dlg), gtk_widget_get_screen (GTK_WIDGET (plugin))); g_object_set_data (G_OBJECT (plugin), "dialog", dlg); gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER); gtk_window_set_icon_name (GTK_WINDOW (dlg), "xfce4-settings"); - + g_signal_connect (dlg, "response", G_CALLBACK (separator_dialog_response), plugin); gtk_container_set_border_width (GTK_CONTAINER (dlg), 2); - + vbox = gtk_vbox_new (FALSE, 8); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); gtk_widget_show (vbox); @@ -284,7 +284,7 @@ separator_properties_dialog (XfcePanelPlugin *plugin) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tb), TRUE); g_signal_connect (tb, "toggled", G_CALLBACK (separator_toggled), plugin); - + tb = gtk_check_button_new_with_mnemonic (_("_Expand")); gtk_widget_show (tb); gtk_box_pack_start (GTK_BOX (vbox), tb, FALSE, FALSE, 0); @@ -293,7 +293,7 @@ separator_properties_dialog (XfcePanelPlugin *plugin) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tb), TRUE); g_signal_connect (tb, "toggled", G_CALLBACK (expand_toggled), plugin); - + gtk_widget_show (dlg); } diff --git a/plugins/separator/separator.desktop.in.in b/plugins/separator/separator.desktop.in.in index 01eb1e62c..37d047e0f 100644 --- a/plugins/separator/separator.desktop.in.in +++ b/plugins/separator/separator.desktop.in.in @@ -4,5 +4,5 @@ Encoding=UTF-8 _Name=Separator or Spacing _Comment=Adds a space or a line between panel items X-XFCE-Module=separator -X-XFCE-Module-Path=@INTERNAL_PLUGIN_PATH@ +X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins diff --git a/plugins/showdesktop/Makefile.am b/plugins/showdesktop/Makefile.am index 16044233d..68da23ded 100644 --- a/plugins/showdesktop/Makefile.am +++ b/plugins/showdesktop/Makefile.am @@ -1,45 +1,60 @@ -plugindir = $(libdir)/xfce4/panel-plugins +# $Id$ -plugin_LTLIBRARIES = libshowdesktop.la +INCLUDES = \ + -I$(top_srcdir) \ + -DG_LOG_DOMAIN=\"libshowdesktop\" \ + -DLOCALEDIR=\"$(localedir)\" \ + $(PLATFORM_CPPFLAGS) -libshowdesktop_la_LDFLAGS = \ - -avoid-version \ - -module +plugindir = \ + $(libdir)/xfce4/panel-plugins + +plugin_LTLIBRARIES = \ + libshowdesktop.la libshowdesktop_la_SOURCES = \ showdesktop.c libshowdesktop_la_CFLAGS = \ - -I$(top_srcdir) \ - @LIBXFCEGUI4_CFLAGS@ \ - -DLOCALEDIR=\"$(localedir)\" + $(GTK_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCEGUI4_CFLAGS) \ + $(PLATFORM_CFLAGS) -libshowdesktop_la_LIBADD = \ - ../../libxfce4panel/libxfce4panel.la \ - @LIBS@ +libshowdesktop_la_LDFLAGS = \ + -avoid-version \ + -module \ + $(PLATFORM_LDFLAGS) -libshowdesktop_la_DEPENDENCIES = \ - ../../libxfce4panel/libxfce4panel.la - if HAVE_CYGWIN -libshowdesktop_la_LDFLAGS += \ - -no-undefined \ - @LIBX11_LDFLAGS@ \ - @LIBXFCEGUI4_LIBS@ \ - @LIBX11_LIBS@ +libshowdesktop_la_LDFLAGS += \ + -no-undefined endif +libshowdesktop_la_LIBADD = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la \ + $(GTK_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCEGUI4_LIBS) + +libshowdesktop_la_DEPENDENCIES = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la + +# # .desktop file # -# Some automake trickery here. Because we cannot use $(libexecdir) in the -# automake stage, we'll use sed to get the full path into the .desktop file. -# We also need to let intltool merge the translated fields, so we add an -# additional level of indirection: a <name>.desktop.in.in file. -# -desktop_in_in_files = showdesktop.desktop.in.in -desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in) - -desktopdir = $(datadir)/xfce4/panel-plugins +desktopdir = \ + $(datadir)/xfce4/panel-plugins + +desktop_in_in_files = \ + showdesktop.desktop.in.in + +desktop_in_files = \ + $(desktop_in_in_files:.desktop.in.in=.desktop.in) + +%.desktop.in: %.desktop.in.in + sed -e "s,\@libdir\@,$(libdir),g" < $< > $@ + desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) @INTLTOOL_DESKTOP_RULE@ @@ -47,13 +62,7 @@ EXTRA_DIST = \ $(desktop_in_in_files) DISTCLEANFILES = \ - $(desktop_DATA) $(desktop_in_files) - -# get full path into .desktop file -%.desktop.in: %.desktop.in.in $(plugin_LTLIBRARIES) - plugin_name=`grep dlname= $(plugin_LTLIBRARIES) | sed "s/dlname='\(.*\)'/\1/"`; \ - sed -e "s^@INTERNAL_PLUGIN_PATH@^$(libdir)/xfce4/panel-plugins^" \ - -e "s^@PLUGIN_NAME@^$$plugin_name^" \ - $< > $@ - + $(desktop_DATA) \ + $(desktop_in_files) +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/plugins/showdesktop/showdesktop.c b/plugins/showdesktop/showdesktop.c index f70fc825d..53911ab1a 100644 --- a/plugins/showdesktop/showdesktop.c +++ b/plugins/showdesktop/showdesktop.c @@ -151,6 +151,7 @@ showdesktop_screen_changed (XfcePanelPlugin *plugin, GdkScreen *screen, } screen = gtk_widget_get_screen (GTK_WIDGET (plugin)); + if (screen) { sdd->screen = netk_screen_get (gdk_screen_get_number (screen)); diff --git a/plugins/showdesktop/showdesktop.desktop.in.in b/plugins/showdesktop/showdesktop.desktop.in.in index dd9645c37..a60d23020 100644 --- a/plugins/showdesktop/showdesktop.desktop.in.in +++ b/plugins/showdesktop/showdesktop.desktop.in.in @@ -5,5 +5,5 @@ _Name=Show Desktop _Comment=Toggle desktop show/hide Icon=gnome-fs-desktop X-XFCE-Module=showdesktop -X-XFCE-Module-Path=@INTERNAL_PLUGIN_PATH@ +X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins diff --git a/plugins/systray/Makefile.am b/plugins/systray/Makefile.am index 078873b98..3895f4182 100644 --- a/plugins/systray/Makefile.am +++ b/plugins/systray/Makefile.am @@ -1,45 +1,60 @@ -plugindir = $(libdir)/xfce4/panel-plugins +# $Id$ -plugin_LTLIBRARIES = libsystray.la +INCLUDES = \ + -I$(top_srcdir) \ + -DG_LOG_DOMAIN=\"libsystray\" \ + -DLOCALEDIR=\"$(localedir)\" \ + $(PLATFORM_CPPFLAGS) -libsystray_la_LDFLAGS = \ - -avoid-version \ - -module +plugindir = \ + $(libdir)/xfce4/panel-plugins + +plugin_LTLIBRARIES = \ + libsystray.la libsystray_la_SOURCES = \ systray.c libsystray_la_CFLAGS = \ - -I$(top_srcdir) \ - @LIBXFCEGUI4_CFLAGS@ \ - -DLOCALEDIR=\"$(localedir)\" + $(GTK_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCEGUI4_CFLAGS) \ + $(PLATFORM_CFLAGS) -libsystray_la_LIBADD = \ - ../../libxfce4panel/libxfce4panel.la \ - @LIBS@ +libsystray_la_LDFLAGS = \ + -avoid-version \ + -module \ + $(PLATFORM_LDFLAGS) -libsystray_la_DEPENDENCIES = \ - ../../libxfce4panel/libxfce4panel.la - if HAVE_CYGWIN -libsystray_la_LDFLAGS += \ - -no-undefined \ - @LIBX11_LDFLAGS@ \ - @LIBXFCEGUI4_LIBS@ \ - @LIBX11_LIBS@ +libsystray_la_LDFLAGS += \ + -no-undefined endif +libsystray_la_LIBADD = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la \ + $(GTK_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCEGUI4_LIBS) + +libsystray_la_DEPENDENCIES = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la + +# # .desktop file # -# Some automake trickery here. Because we cannot use $(libexecdir) in the -# automake stage, we'll use sed to get the full path into the .desktop file. -# We also need to let intltool merge the translated fields, so we add an -# additional level of indirection: a <name>.desktop.in.in file. -# -desktop_in_in_files = systray.desktop.in.in -desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in) - -desktopdir = $(datadir)/xfce4/panel-plugins +desktopdir = \ + $(datadir)/xfce4/panel-plugins + +desktop_in_in_files = \ + systray.desktop.in.in + +desktop_in_files = \ + $(desktop_in_in_files:.desktop.in.in=.desktop.in) + +%.desktop.in: %.desktop.in.in + sed -e "s,\@libdir\@,$(libdir),g" < $< > $@ + desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) @INTLTOOL_DESKTOP_RULE@ @@ -47,12 +62,7 @@ EXTRA_DIST = \ $(desktop_in_in_files) DISTCLEANFILES = \ - $(desktop_DATA) $(desktop_in_files) - -# get full path into .desktop file -%.desktop.in: %.desktop.in.in $(plugin_LTLIBRARIES) - plugin_name=`grep dlname= $(plugin_LTLIBRARIES) | sed "s/dlname='\(.*\)'/\1/"`; \ - sed -e "s^@INTERNAL_PLUGIN_PATH@^$(libdir)/xfce4/panel-plugins^" \ - -e "s^@PLUGIN_NAME@^$$plugin_name^" \ - $< > $@ + $(desktop_DATA) \ + $(desktop_in_files) +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/plugins/systray/systray.c b/plugins/systray/systray.c index 9b372ac29..a37c28246 100644 --- a/plugins/systray/systray.c +++ b/plugins/systray/systray.c @@ -5,7 +5,7 @@ * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published + * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * @@ -35,17 +35,17 @@ typedef struct XfcePanelPlugin *plugin; XfceSystemTray *tray; - gboolean tray_registered; + guint tray_registered : 1; GtkWidget *frame; GtkWidget *align; GtkWidget *iconbox; - guint show_frame:1; + guint show_frame : 1; } Systray; -static void systray_properties_dialog (XfcePanelPlugin *plugin, +static void systray_properties_dialog (XfcePanelPlugin *plugin, Systray *systray); static void systray_free_data (XfcePanelPlugin *plugin, Systray *systray); @@ -59,7 +59,7 @@ static gboolean systray_check (GdkScreen *screen); * Systray * * -------------------------------------------------------------------- */ -static gboolean +static gboolean systray_check (GdkScreen *screen) { Screen *scr = GDK_SCREEN_XSCREEN (screen); @@ -102,7 +102,7 @@ icon_docked (XfceSystemTray * tray, GtkWidget * icon, Systray * systray) if (systray->tray_registered) { gtk_widget_show (icon); - gtk_box_pack_start (GTK_BOX (systray->iconbox), icon, + gtk_box_pack_start (GTK_BOX (systray->iconbox), icon, FALSE, FALSE, 0); } } @@ -143,7 +143,7 @@ systray_start (Systray *systray) if (!systray->tray_registered) { systray->tray_registered = register_tray (systray); - + if (!systray->tray_registered) { g_idle_add ((GSourceFunc)systray_remove, systray); @@ -167,42 +167,42 @@ systray_stop (Systray *systray) /* Register with the panel */ -XFCE_PANEL_PLUGIN_REGISTER_INTERNAL_WITH_CHECK (systray_construct, +XFCE_PANEL_PLUGIN_REGISTER_INTERNAL_WITH_CHECK (systray_construct, systray_check); /* Interface Implementation */ static void -systray_orientation_changed (XfcePanelPlugin *plugin, - GtkOrientation orientation, +systray_orientation_changed (XfcePanelPlugin *plugin, + GtkOrientation orientation, Systray *systray) { xfce_hvbox_set_orientation (XFCE_HVBOX (systray->iconbox), orientation); if (orientation == GTK_ORIENTATION_HORIZONTAL) { - gtk_alignment_set_padding (GTK_ALIGNMENT (systray->align), + gtk_alignment_set_padding (GTK_ALIGNMENT (systray->align), 0, 0, 3, 3); } else { - gtk_alignment_set_padding (GTK_ALIGNMENT (systray->align), + gtk_alignment_set_padding (GTK_ALIGNMENT (systray->align), 3, 3, 0, 0); } } -static gboolean +static gboolean systray_set_size (XfcePanelPlugin *plugin, int size, Systray *systray) { int border = size > 26 ? 1 : 0; gtk_container_set_border_width (GTK_CONTAINER (systray->frame), border); - + size = size - (2*border) - 2 - MAX (systray->frame->style->xthickness, systray->frame->style->ythickness); - - if (xfce_panel_plugin_get_orientation (plugin) + + if (xfce_panel_plugin_get_orientation (plugin) == GTK_ORIENTATION_HORIZONTAL) { gtk_widget_set_size_request (systray->iconbox, -1, size); @@ -211,7 +211,7 @@ systray_set_size (XfcePanelPlugin *plugin, int size, Systray *systray) { gtk_widget_set_size_request (systray->iconbox, size, -1); } - + return TRUE; } @@ -222,7 +222,7 @@ systray_free_data (XfcePanelPlugin *plugin, Systray *systray) if (dlg) gtk_widget_destroy (dlg); - + systray_stop (systray); panel_slice_free (Systray, systray); } @@ -233,7 +233,7 @@ systray_read_rc_file (XfcePanelPlugin *plugin, Systray *systray) char *file; XfceRc *rc; int show_frame = 1; - + if ((file = xfce_panel_plugin_lookup_rc_file (plugin)) != NULL) { rc = xfce_rc_simple_open (file, TRUE); @@ -242,7 +242,7 @@ systray_read_rc_file (XfcePanelPlugin *plugin, Systray *systray) if (rc != NULL) { show_frame = xfce_rc_read_int_entry (rc, "show_frame", 1); - + xfce_rc_close (rc); } } @@ -255,7 +255,7 @@ systray_write_rc_file (XfcePanelPlugin *plugin, Systray *systray) { char *file; XfceRc *rc; - + if (!(file = xfce_panel_plugin_save_location (plugin, TRUE))) return; @@ -264,32 +264,32 @@ systray_write_rc_file (XfcePanelPlugin *plugin, Systray *systray) if (!rc) return; - + xfce_rc_write_int_entry (rc, "show_frame", systray->show_frame); xfce_rc_close (rc); } /* create widgets and connect to signals */ -static void +static void systray_construct (XfcePanelPlugin *plugin) { Systray *systray = panel_slice_new0 (Systray); - g_signal_connect (plugin, "orientation-changed", + g_signal_connect (plugin, "orientation-changed", G_CALLBACK (systray_orientation_changed), systray); - - g_signal_connect (plugin, "size-changed", + + g_signal_connect (plugin, "size-changed", G_CALLBACK (systray_set_size), systray); - - g_signal_connect (plugin, "free-data", + + g_signal_connect (plugin, "free-data", G_CALLBACK (systray_free_data), systray); - - g_signal_connect (plugin, "save", + + g_signal_connect (plugin, "save", G_CALLBACK (systray_write_rc_file), systray); - + xfce_panel_plugin_menu_show_configure (plugin); - g_signal_connect (plugin, "configure-plugin", + g_signal_connect (plugin, "configure-plugin", G_CALLBACK (systray_properties_dialog), systray); systray->plugin = plugin; @@ -297,7 +297,7 @@ systray_construct (XfcePanelPlugin *plugin) systray_read_rc_file (plugin, systray); systray->frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (systray->frame), + gtk_frame_set_shadow_type (GTK_FRAME (systray->frame), systray->show_frame ? GTK_SHADOW_IN : GTK_SHADOW_NONE); gtk_widget_show (systray->frame); @@ -306,25 +306,25 @@ systray_construct (XfcePanelPlugin *plugin) systray->align = gtk_alignment_new (0, 0, 1, 1); gtk_widget_show (systray->align); gtk_container_add (GTK_CONTAINER (systray->frame), systray->align); - - if (xfce_panel_plugin_get_orientation (plugin) == + + if (xfce_panel_plugin_get_orientation (plugin) == GTK_ORIENTATION_HORIZONTAL) { - systray->iconbox = + systray->iconbox = xfce_hvbox_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 3); - - gtk_alignment_set_padding (GTK_ALIGNMENT (systray->align), + + gtk_alignment_set_padding (GTK_ALIGNMENT (systray->align), 0, 0, 3, 3); } else { - systray->iconbox = + systray->iconbox = xfce_hvbox_new (GTK_ORIENTATION_VERTICAL, FALSE, 3); - - gtk_alignment_set_padding (GTK_ALIGNMENT (systray->align), + + gtk_alignment_set_padding (GTK_ALIGNMENT (systray->align), 3, 3, 0, 0); } - + gtk_widget_show (systray->iconbox); gtk_container_add (GTK_CONTAINER (systray->align), systray->iconbox); @@ -334,10 +334,10 @@ systray_construct (XfcePanelPlugin *plugin) g_signal_connect (systray->tray, "icon_docked", G_CALLBACK (icon_docked), systray); - + g_signal_connect (systray->tray, "icon_undocked", G_CALLBACK (icon_undocked), systray); - + g_signal_connect (systray->tray, "message_new", G_CALLBACK (message_new), systray); @@ -358,7 +358,7 @@ show_frame_toggled (GtkToggleButton *tb, Systray *systray) } static void -systray_dialog_response (GtkWidget *dlg, int reponse, +systray_dialog_response (GtkWidget *dlg, int reponse, Systray *systray) { g_object_set_data (G_OBJECT (systray->plugin), "dialog", NULL); @@ -374,25 +374,25 @@ systray_properties_dialog (XfcePanelPlugin *plugin, Systray *systray) GtkWidget *dlg, *vbox, *cb; xfce_panel_plugin_block_menu (plugin); - + dlg = xfce_titled_dialog_new_with_buttons (_("System Tray"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); - gtk_window_set_screen (GTK_WINDOW (dlg), + gtk_window_set_screen (GTK_WINDOW (dlg), gtk_widget_get_screen (GTK_WIDGET (plugin))); g_object_set_data (G_OBJECT (plugin), "dialog", dlg); gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER); gtk_window_set_icon_name (GTK_WINDOW (dlg), "xfce4-settings"); - + g_signal_connect (dlg, "response", G_CALLBACK (systray_dialog_response), systray); gtk_container_set_border_width (GTK_CONTAINER (dlg), 2); - + vbox = gtk_vbox_new (FALSE, 8); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); gtk_widget_show (vbox); diff --git a/plugins/systray/systray.desktop.in.in b/plugins/systray/systray.desktop.in.in index 9b1fa939e..6109d250d 100644 --- a/plugins/systray/systray.desktop.in.in +++ b/plugins/systray/systray.desktop.in.in @@ -5,5 +5,5 @@ _Name=System Tray _Comment=Show notification icons Icon=xfce-system-info X-XFCE-Module=systray -X-XFCE-Module-Path=@INTERNAL_PLUGIN_PATH@ +X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins diff --git a/plugins/tasklist/Makefile.am b/plugins/tasklist/Makefile.am index c9b84d049..f0f63e3f6 100644 --- a/plugins/tasklist/Makefile.am +++ b/plugins/tasklist/Makefile.am @@ -1,45 +1,63 @@ -plugindir = $(libdir)/xfce4/panel-plugins +# $Id$ -plugin_LTLIBRARIES = libtasklist.la +INCLUDES = \ + -I$(top_srcdir) \ + -DG_LOG_DOMAIN=\"libtasklist\" \ + -DLOCALEDIR=\"$(localedir)\" \ + $(PLATFORM_CPPFLAGS) -libtasklist_la_LDFLAGS = \ - -avoid-version \ - -module +plugindir = \ + $(libdir)/xfce4/panel-plugins + +plugin_LTLIBRARIES = \ + libtasklist.la libtasklist_la_SOURCES = \ - tasklist.c + tasklist.c \ + tasklist.h \ + tasklist-dialogs.c \ + tasklist-dialogs.h libtasklist_la_CFLAGS = \ - -I$(top_srcdir) \ - @LIBXFCEGUI4_CFLAGS@ \ - -DLOCALEDIR=\"$(localedir)\" + $(GTK_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCEGUI4_CFLAGS) \ + $(PLATFORM_CFLAGS) -libtasklist_la_LIBADD = \ - ../../libxfce4panel/libxfce4panel.la \ - @LIBS@ +libtasklist_la_LDFLAGS = \ + -avoid-version \ + -module \ + $(PLATFORM_LDFLAGS) -libtasklist_la_DEPENDENCIES = \ - ../../libxfce4panel/libxfce4panel.la - if HAVE_CYGWIN -libtasklist_la_LDFLAGS += \ - -no-undefined \ - @LIBX11_LDFLAGS@ \ - @LIBXFCEGUI4_LIBS@ \ - @LIBX11_LIBS@ +libtasklist_la_LDFLAGS += \ + -no-undefined endif +libtasklist_la_LIBADD = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la \ + $(GTK_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCEGUI4_LIBS) + +libtasklist_la_DEPENDENCIES = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la + +# # .desktop file # -# Some automake trickery here. Because we cannot use $(libexecdir) in the -# automake stage, we'll use sed to get the full path into the .desktop file. -# We also need to let intltool merge the translated fields, so we add an -# additional level of indirection: a <name>.desktop.in.in file. -# -desktop_in_in_files = tasklist.desktop.in.in -desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in) - -desktopdir = $(datadir)/xfce4/panel-plugins +desktopdir = \ + $(datadir)/xfce4/panel-plugins + +desktop_in_in_files = \ + tasklist.desktop.in.in + +desktop_in_files = \ + $(desktop_in_in_files:.desktop.in.in=.desktop.in) + +%.desktop.in: %.desktop.in.in + sed -e "s,\@libdir\@,$(libdir),g" < $< > $@ + desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) @INTLTOOL_DESKTOP_RULE@ @@ -47,12 +65,7 @@ EXTRA_DIST = \ $(desktop_in_in_files) DISTCLEANFILES = \ - $(desktop_DATA) $(desktop_in_files) - -# get full path into .desktop file -%.desktop.in: %.desktop.in.in $(plugin_LTLIBRARIES) - plugin_name=`grep dlname= $(plugin_LTLIBRARIES) | sed "s/dlname='\(.*\)'/\1/"`; \ - sed -e "s^@INTERNAL_PLUGIN_PATH@^$(libdir)/xfce4/panel-plugins^" \ - -e "s^@PLUGIN_NAME@^$$plugin_name^" \ - $< > $@ + $(desktop_DATA) \ + $(desktop_in_files) +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/plugins/tasklist/tasklist-dialogs.c b/plugins/tasklist/tasklist-dialogs.c new file mode 100644 index 000000000..2bc616877 --- /dev/null +++ b/plugins/tasklist/tasklist-dialogs.c @@ -0,0 +1,253 @@ +/* $Id$ + * + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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 Library 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 + +#include "tasklist.h" +#include "tasklist-dialogs.h" + + + +/* prototypes */ +static void tasklist_all_workspaces_toggled (GtkToggleButton *tb, + Tasklist *tasklist); +static void tasklist_grouping_changed (GtkComboBox *cb, + Tasklist *tasklist); +static void tasklist_show_label_toggled (GtkToggleButton *tb, + Tasklist *tasklist); +static void tasklist_expand_toggled (GtkToggleButton *tb, + Tasklist *tasklist); +static void tasklist_flat_buttons_toggled (GtkToggleButton *tb, + Tasklist *tasklist); +static void tasklist_show_handle_toggled (GtkToggleButton *tb, + Tasklist *tasklist); +static void tasklist_width_changed (GtkSpinButton *sb, + Tasklist *tasklist); +static void tasklist_dialog_response (GtkWidget *dlg, + gint reponse, + Tasklist *tasklist); + + + +static void +tasklist_all_workspaces_toggled (GtkToggleButton *tb, + Tasklist *tasklist) +{ + tasklist->all_workspaces = gtk_toggle_button_get_active (tb); + + netk_tasklist_set_include_all_workspaces (NETK_TASKLIST (tasklist->list), + tasklist->all_workspaces); +} + + + +static void +tasklist_grouping_changed (GtkComboBox *cb, + Tasklist *tasklist) +{ + tasklist->grouping = gtk_combo_box_get_active (cb); + + netk_tasklist_set_grouping (NETK_TASKLIST (tasklist->list), + tasklist->grouping); +} + + + +static void +tasklist_show_label_toggled (GtkToggleButton *tb, + Tasklist *tasklist) +{ + tasklist->show_label = gtk_toggle_button_get_active (tb); + + netk_tasklist_set_show_label (NETK_TASKLIST (tasklist->list), + tasklist->show_label); +} + + + +static void +tasklist_expand_toggled (GtkToggleButton *tb, + Tasklist *tasklist) +{ + tasklist->expand = gtk_toggle_button_get_active (tb); + + xfce_panel_plugin_set_expand (tasklist->plugin, tasklist->expand); +} + + + +static void +tasklist_flat_buttons_toggled (GtkToggleButton *tb, + Tasklist *tasklist) +{ + tasklist->flat_buttons = gtk_toggle_button_get_active (tb); + + netk_tasklist_set_button_relief (NETK_TASKLIST (tasklist->list), + tasklist->flat_buttons ? + GTK_RELIEF_NONE : GTK_RELIEF_NORMAL); +} + + + +static void +tasklist_show_handle_toggled (GtkToggleButton *tb, + Tasklist *tasklist) +{ + tasklist->show_handles = gtk_toggle_button_get_active (tb); + + if (tasklist->show_handles) + gtk_widget_show (tasklist->handle); + else + gtk_widget_hide (tasklist->handle); +} + + + +static void +tasklist_width_changed (GtkSpinButton *sb, + Tasklist *tasklist) +{ + tasklist->width = gtk_spin_button_get_value_as_int (sb); + + tasklist_set_size (tasklist, xfce_panel_plugin_get_size (tasklist->plugin)); +} + + + +static void +tasklist_dialog_response (GtkWidget *dlg, + gint reponse, + Tasklist *tasklist) +{ + g_object_set_data (G_OBJECT (tasklist->plugin), "dialog", NULL); + + gtk_widget_destroy (dlg); + xfce_panel_plugin_unblock_menu (tasklist->plugin); + tasklist_write_rc_file (tasklist); +} + + + +void +tasklist_properties_dialog (Tasklist *tasklist) +{ + GtkWidget *dlg, *mainvbox, *vbox, *frame, *cb, + *hbox, *label, *spin; + + xfce_panel_plugin_block_menu (tasklist->plugin); + + dlg = xfce_titled_dialog_new_with_buttons (_("Task List"), NULL, + GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, + GTK_STOCK_CLOSE, GTK_RESPONSE_OK, + NULL); + + gtk_window_set_screen (GTK_WINDOW (dlg), + gtk_widget_get_screen (GTK_WIDGET (tasklist->plugin))); + + g_object_set_data (G_OBJECT (tasklist->plugin), "dialog", dlg); + + gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER); + gtk_window_set_icon_name (GTK_WINDOW (dlg), "xfce4-settings"); + + g_signal_connect (G_OBJECT (dlg), "response", + G_CALLBACK (tasklist_dialog_response), tasklist); + + gtk_container_set_border_width (GTK_CONTAINER (dlg), 2); + + mainvbox = gtk_vbox_new (FALSE, 8); + gtk_container_set_border_width (GTK_CONTAINER (mainvbox), 5); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), mainvbox, + TRUE, TRUE, 0); + + /* Size */ + vbox = gtk_vbox_new (FALSE, 8); + + frame = xfce_create_framebox_with_content (_("Appearance"), vbox); + gtk_box_pack_start (GTK_BOX (mainvbox), frame, FALSE, FALSE, 0); + + hbox = gtk_hbox_new (FALSE, 8); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new (_("Minimum Width:")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + + /* an arbitrary max of 4000 should be future proof, right? */ + spin = gtk_spin_button_new_with_range (100, 4000, 10); + gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 0); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), tasklist->width); + g_signal_connect (G_OBJECT (spin), "value-changed", + G_CALLBACK (tasklist_width_changed), tasklist); + + if (tasklist_using_xinerama (tasklist->plugin)) + { + cb = gtk_check_button_new_with_mnemonic (_("Use all available space")); + gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), tasklist->expand); + g_signal_connect (G_OBJECT (cb), "toggled", + G_CALLBACK (tasklist_expand_toggled), tasklist); + } + + cb = gtk_check_button_new_with_mnemonic (_("Use flat buttons")); + gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), tasklist->flat_buttons); + g_signal_connect (G_OBJECT (cb), "toggled", + G_CALLBACK (tasklist_flat_buttons_toggled), tasklist); + + cb = gtk_check_button_new_with_mnemonic (_("Show handle")); + gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), tasklist->show_handles); + g_signal_connect (G_OBJECT (cb), "toggled", + G_CALLBACK (tasklist_show_handle_toggled), tasklist); + + /* Tasks */ + vbox = gtk_vbox_new (FALSE, 8); + + frame = xfce_create_framebox_with_content (_("Task List"), vbox); + gtk_box_pack_start (GTK_BOX (mainvbox), frame, FALSE, FALSE, 0); + + cb = gtk_check_button_new_with_mnemonic (_("Show tasks from _all workspaces")); + gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), tasklist->all_workspaces); + g_signal_connect (G_OBJECT (cb), "toggled", + G_CALLBACK (tasklist_all_workspaces_toggled), tasklist); + + cb = gtk_check_button_new_with_mnemonic (_("Show application _names")); + gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), tasklist->show_label); + g_signal_connect (G_OBJECT (cb), "toggled", + G_CALLBACK (tasklist_show_label_toggled), tasklist); + + cb = gtk_combo_box_new_text (); + gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0); + + /* keep order in sync with NetkTasklistGroupingType */ + gtk_combo_box_append_text (GTK_COMBO_BOX (cb), _("Never group tasks")); + gtk_combo_box_append_text (GTK_COMBO_BOX (cb), _("Automatically group tasks")); + gtk_combo_box_append_text (GTK_COMBO_BOX (cb), _("Always group tasks")); + + gtk_combo_box_set_active (GTK_COMBO_BOX (cb), tasklist->grouping); + + g_signal_connect (G_OBJECT (cb), "changed", + G_CALLBACK (tasklist_grouping_changed), tasklist); + + gtk_widget_show_all (dlg); +} diff --git a/plugins/tasklist/tasklist-dialogs.h b/plugins/tasklist/tasklist-dialogs.h new file mode 100644 index 000000000..6c0e20925 --- /dev/null +++ b/plugins/tasklist/tasklist-dialogs.h @@ -0,0 +1,25 @@ +/* $Id$ + * + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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 Library 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 __TASKLIST_DIALOGS_H__ +#define __TASKLIST_DIALOGS_H__ + +void tasklist_properties_dialog (Tasklist *tasklist) G_GNUC_INTERNAL; + +#endif /* !__TASKLIST_DIALOGS_H__ */ diff --git a/plugins/tasklist/tasklist.c b/plugins/tasklist/tasklist.c index 5c06ba465..8c962dd8f 100644 --- a/plugins/tasklist/tasklist.c +++ b/plugins/tasklist/tasklist.c @@ -1,11 +1,9 @@ -/* vim: set expandtab ts=8 sw=4: */ - /* $Id$ * - * Copyright © 2005 Jasper Huijsmans <jasper@xfce.org> + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published + * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * @@ -23,188 +21,175 @@ #include <config.h> #endif -#include <gtk/gtk.h> - #include <libxfce4util/libxfce4util.h> -#include <libxfcegui4/libxfcegui4.h> -#include <libxfce4panel/xfce-panel-plugin.h> #include <libxfce4panel/xfce-hvbox.h> -typedef struct -{ - XfcePanelPlugin *plugin; - - GtkWidget *box; - GtkWidget *handle; - GtkWidget *list; - - int width; - int screen_changed_id; - - NetkTasklistGroupingType grouping; - guint all_workspaces:1; - guint show_label:1; - guint expand:1; - guint flat_buttons:1; -} -Tasklist; +#include "tasklist.h" +#include "tasklist-dialogs.h" -static void tasklist_properties_dialog (XfcePanelPlugin *plugin, - Tasklist *tasklist); -static void tasklist_construct (XfcePanelPlugin *plugin); +/* prototypes */ +static void tasklist_orientation_changed (Tasklist *tasklist, + GtkOrientation orientation); +static void tasklist_free_data (Tasklist *tasklist); +static void tasklist_read_rc_file (Tasklist *tasklist); +static gboolean tasklist_handle_exposed (GtkWidget *widget, + GdkEventExpose *ev, + Tasklist *tasklist); +static void tasklist_screen_changed (Tasklist *tasklist, + GdkScreen *screen); +static void tasklist_construct (XfcePanelPlugin *plugin); -static gboolean using_xinerama (XfcePanelPlugin *plugin); -/* -------------------------------------------------------------------- * - * Panel Plugin Interface * - * -------------------------------------------------------------------- */ - -/* Register with the panel */ +/* register with the panel */ XFCE_PANEL_PLUGIN_REGISTER_INTERNAL (tasklist_construct); -/* Interface Implementation */ static void -tasklist_orientation_changed (XfcePanelPlugin *plugin, - GtkOrientation orientation, - Tasklist *tasklist) +tasklist_orientation_changed (Tasklist *tasklist, + GtkOrientation orientation) { + xfce_hvbox_set_orientation (XFCE_HVBOX (tasklist->box), orientation); gtk_widget_queue_draw (tasklist->handle); } -static gboolean -tasklist_set_size (XfcePanelPlugin *plugin, int size, Tasklist *tasklist) + + +gboolean +tasklist_set_size (Tasklist *tasklist, + gint size) { - if (xfce_panel_plugin_get_orientation (plugin) == - GTK_ORIENTATION_HORIZONTAL) + GtkOrientation orientation; + + orientation = xfce_panel_plugin_get_orientation (tasklist->plugin); + + if (orientation == GTK_ORIENTATION_HORIZONTAL) { - gtk_widget_set_size_request (GTK_WIDGET (plugin), + gtk_widget_set_size_request (GTK_WIDGET (tasklist->plugin), tasklist->width, size); } else { - gtk_widget_set_size_request (GTK_WIDGET (plugin), + gtk_widget_set_size_request (GTK_WIDGET (tasklist->plugin), size, tasklist->width); } return TRUE; } + + static void -tasklist_free_data (XfcePanelPlugin *plugin, Tasklist *tasklist) +tasklist_free_data (Tasklist *tasklist) { - GtkWidget *dlg = g_object_get_data (G_OBJECT (plugin), "dialog"); + GtkWidget *dlg = g_object_get_data (G_OBJECT (tasklist->plugin), "dialog"); - if (dlg) + if (G_UNLIKELY (dlg)) gtk_widget_destroy (dlg); - - g_signal_handler_disconnect (plugin, tasklist->screen_changed_id); + + /* disconnect the screen changed signal */ + g_signal_handler_disconnect (G_OBJECT (tasklist->plugin), + tasklist->screen_changed_id); + panel_slice_free (Tasklist, tasklist); } + + static void -tasklist_read_rc_file (XfcePanelPlugin *plugin, Tasklist *tasklist) +tasklist_read_rc_file (Tasklist *tasklist) { - char *file; + gchar *file; XfceRc *rc; - int grouping, all_workspaces, labels, expand, flat_buttons, width; - - grouping = NETK_TASKLIST_AUTO_GROUP; - all_workspaces = 0; - labels = 1; - expand = 1; - flat_buttons = 1; - width = 300; - - if ((file = xfce_panel_plugin_lookup_rc_file (plugin)) != NULL) + + /* defaults */ + tasklist->grouping = NETK_TASKLIST_AUTO_GROUP; + tasklist->all_workspaces = FALSE; + tasklist->show_label = TRUE; + tasklist->expand = TRUE; + tasklist->flat_buttons = TRUE; + tasklist->show_handles = TRUE; + tasklist->width = 300; + + if ((file = xfce_panel_plugin_lookup_rc_file (tasklist->plugin)) != NULL) { rc = xfce_rc_simple_open (file, TRUE); g_free (file); - if (rc != NULL) + if (G_UNLIKELY (rc != NULL)) { - grouping = xfce_rc_read_int_entry (rc, "grouping", grouping); - - all_workspaces = xfce_rc_read_int_entry (rc, "all_workspaces", - all_workspaces); - - labels = xfce_rc_read_int_entry (rc, "show_label", labels); - - if (using_xinerama (plugin)) - { - expand = xfce_rc_read_int_entry (rc, "expand", expand); - } - - flat_buttons = xfce_rc_read_int_entry (rc, "flat_buttons", flat_buttons); - - width = xfce_rc_read_int_entry (rc, "width", width); - + /* read user settings */ + tasklist->grouping = xfce_rc_read_int_entry (rc, "grouping", tasklist->grouping); + tasklist->all_workspaces = xfce_rc_read_bool_entry (rc, "all_workspaces", tasklist->all_workspaces); + tasklist->show_label = xfce_rc_read_bool_entry (rc, "show_label", tasklist->show_label); + tasklist->flat_buttons = xfce_rc_read_bool_entry (rc, "flat_buttons", tasklist->flat_buttons); + tasklist->show_handles = xfce_rc_read_bool_entry (rc, "show_handles", tasklist->show_handles); + tasklist->width = xfce_rc_read_int_entry (rc, "width",tasklist->width); + + if (tasklist_using_xinerama (tasklist->plugin)) + tasklist->expand = xfce_rc_read_int_entry (rc, "expand", tasklist->expand); + xfce_rc_close (rc); } } - - tasklist->grouping = grouping; - tasklist->all_workspaces = (all_workspaces == 1); - tasklist->show_label = (labels != 0); - tasklist->expand = (expand != 0); - tasklist->flat_buttons = (flat_buttons != 0); - tasklist->width = MAX (100, width); } -static void -tasklist_write_rc_file (XfcePanelPlugin *plugin, Tasklist *tasklist) + + +void +tasklist_write_rc_file (Tasklist *tasklist) { - char *file; - XfceRc *rc; - - if (!(file = xfce_panel_plugin_save_location (plugin, TRUE))) - return; + gchar *file; + XfceRc *rc = NULL; - rc = xfce_rc_simple_open (file, FALSE); - g_free (file); + file = xfce_panel_plugin_save_location (tasklist->plugin, TRUE); - if (!rc) + if (G_UNLIKELY (file == NULL)) return; - - xfce_rc_write_int_entry (rc, "grouping", tasklist->grouping); - xfce_rc_write_int_entry (rc, "all_workspaces", tasklist->all_workspaces); + rc = xfce_rc_simple_open (file, FALSE); + g_free (file); - xfce_rc_write_int_entry (rc, "show_label", tasklist->show_label); + if (G_LIKELY (rc != NULL)) + { + xfce_rc_write_int_entry (rc, "grouping", tasklist->grouping); + xfce_rc_write_int_entry (rc, "width", tasklist->width); - xfce_rc_write_int_entry (rc, "expand", tasklist->expand); + xfce_rc_write_bool_entry (rc, "all_workspaces", tasklist->all_workspaces); + xfce_rc_write_bool_entry (rc, "show_label", tasklist->show_label); + xfce_rc_write_bool_entry (rc, "expand", tasklist->expand); + xfce_rc_write_bool_entry (rc, "flat_buttons", tasklist->flat_buttons); + xfce_rc_write_bool_entry (rc, "show_handles", tasklist->show_handles); - xfce_rc_write_int_entry (rc, "flat_buttons", tasklist->flat_buttons); + xfce_rc_close (rc); + } +} - xfce_rc_write_int_entry (rc, "width", tasklist->width); - xfce_rc_close (rc); -} -/* create widgets and connect to signals */ static gboolean -handle_expose (GtkWidget *widget, GdkEventExpose *ev, Tasklist *tasklist) +tasklist_handle_exposed (GtkWidget *widget, + GdkEventExpose *ev, + Tasklist *tasklist) { + GtkAllocation *allocation = &(widget->allocation); + gint x, y, w, h; + GtkOrientation orientation; + if (GTK_WIDGET_DRAWABLE (widget)) { - GtkAllocation *allocation = &(widget->allocation); - int x, y, w, h; - gboolean horizontal; - - horizontal = (xfce_panel_plugin_get_orientation (tasklist->plugin) - == GTK_ORIENTATION_HORIZONTAL); + orientation = xfce_panel_plugin_get_orientation (tasklist->plugin); x = allocation->x; y = allocation->y; w = allocation->width; h = allocation->height; - - if (horizontal) + + if (orientation == GTK_ORIENTATION_HORIZONTAL) { y += widget->style->ythickness; h -= 2 * widget->style->ythickness; @@ -216,11 +201,10 @@ handle_expose (GtkWidget *widget, GdkEventExpose *ev, Tasklist *tasklist) } gtk_paint_handle (widget->style, widget->window, - GTK_WIDGET_STATE (widget), GTK_SHADOW_NONE, + GTK_WIDGET_STATE (widget), GTK_SHADOW_NONE, &(ev->area), widget, "handlebox", x, y, w, h, - horizontal ? GTK_ORIENTATION_VERTICAL : - GTK_ORIENTATION_HORIZONTAL); + orientation); return TRUE; } @@ -228,293 +212,102 @@ handle_expose (GtkWidget *widget, GdkEventExpose *ev, Tasklist *tasklist) return FALSE; } -static void -tasklist_screen_changed (GtkWidget *plugin, GdkScreen *screen, - Tasklist *tasklist) + + +gboolean +tasklist_using_xinerama (XfcePanelPlugin *plugin) { - NetkScreen *ns; + return (gdk_screen_get_n_monitors (gtk_widget_get_screen (GTK_WIDGET (plugin))) > 1); +} + - screen = gtk_widget_get_screen (plugin); +static void +tasklist_screen_changed (Tasklist *tasklist, + GdkScreen *screen) +{ + NetkScreen *ns; + + /* get the new screen */ + screen = gtk_widget_get_screen (GTK_WIDGET (tasklist->plugin)); + + /* be secure */ if (G_UNLIKELY (screen == NULL)) screen = gdk_screen_get_default (); - + ns = netk_screen_get (gdk_screen_get_number (screen)); netk_tasklist_set_screen (NETK_TASKLIST (tasklist->list), ns); } -static void + + +static void tasklist_construct (XfcePanelPlugin *plugin) { GdkScreen *screen; - int screen_idx; - Tasklist *tasklist = panel_slice_new0 (Tasklist); + gint screen_idx; + Tasklist *tasklist = panel_slice_new0 (Tasklist); tasklist->plugin = plugin; - - g_signal_connect (plugin, "orientation-changed", - G_CALLBACK (tasklist_orientation_changed), tasklist); - - g_signal_connect (plugin, "size-changed", - G_CALLBACK (tasklist_set_size), tasklist); - - g_signal_connect (plugin, "free-data", - G_CALLBACK (tasklist_free_data), tasklist); - - g_signal_connect (plugin, "save", - G_CALLBACK (tasklist_write_rc_file), tasklist); + /* show the properties menu item in the right-click menu */ xfce_panel_plugin_menu_show_configure (plugin); - g_signal_connect (plugin, "configure-plugin", - G_CALLBACK (tasklist_properties_dialog), tasklist); - - tasklist_read_rc_file (plugin, tasklist); + /* connect panel signals */ + g_signal_connect_swapped (G_OBJECT (plugin), "orientation-changed", + G_CALLBACK (tasklist_orientation_changed), tasklist); + g_signal_connect_swapped (G_OBJECT (plugin), "size-changed", + G_CALLBACK (tasklist_set_size), tasklist); + g_signal_connect_swapped (G_OBJECT (plugin), "free-data", + G_CALLBACK (tasklist_free_data), tasklist); + g_signal_connect_swapped (G_OBJECT (plugin), "save", + G_CALLBACK (tasklist_write_rc_file), tasklist); + g_signal_connect_swapped (G_OBJECT (plugin), "configure-plugin", + G_CALLBACK (tasklist_properties_dialog), tasklist); + + /* read user settings / defaults */ + tasklist_read_rc_file (tasklist); + + /* whether to expand the plugin */ xfce_panel_plugin_set_expand (plugin, tasklist->expand); - - tasklist->box = xfce_hvbox_new (xfce_panel_plugin_get_orientation (plugin), - FALSE, 0); - gtk_container_set_reallocate_redraws (GTK_CONTAINER (tasklist->box), TRUE); + + /* create the main box */ + tasklist->box = xfce_hvbox_new (xfce_panel_plugin_get_orientation (plugin), FALSE, 0); gtk_widget_show (tasklist->box); gtk_container_add (GTK_CONTAINER (plugin), tasklist->box); + /* create left handle */ tasklist->handle = gtk_alignment_new (0, 0, 0, 0); gtk_widget_set_size_request (tasklist->handle, 8, 8); - gtk_widget_show (tasklist->handle); - gtk_box_pack_start (GTK_BOX (tasklist->box), tasklist->handle, - FALSE, FALSE, 0); - + gtk_box_pack_start (GTK_BOX (tasklist->box), tasklist->handle, FALSE, FALSE, 0); xfce_panel_plugin_add_action_widget (plugin, tasklist->handle); + g_signal_connect (tasklist->handle, "expose-event", + G_CALLBACK (tasklist_handle_exposed), tasklist); - g_signal_connect (tasklist->handle, "expose-event", - G_CALLBACK (handle_expose), tasklist); - + /* create netk tasklist */ screen = gtk_widget_get_screen (GTK_WIDGET (plugin)); screen_idx = gdk_screen_get_number (screen); tasklist->list = netk_tasklist_new (netk_screen_get (screen_idx)); gtk_widget_show (tasklist->list); - gtk_box_pack_start (GTK_BOX (tasklist->box), tasklist->list, - TRUE, TRUE, 0); - - netk_tasklist_set_include_all_workspaces (NETK_TASKLIST (tasklist->list), - tasklist->all_workspaces); - - netk_tasklist_set_grouping (NETK_TASKLIST (tasklist->list), - tasklist->grouping); - - netk_tasklist_set_show_label (NETK_TASKLIST (tasklist->list), - tasklist->show_label); - - netk_tasklist_set_button_relief (NETK_TASKLIST (tasklist->list), - tasklist->flat_buttons ? - GTK_RELIEF_NONE : GTK_RELIEF_NORMAL); - - tasklist->screen_changed_id = - g_signal_connect (plugin, "screen-changed", - G_CALLBACK (tasklist_screen_changed), tasklist); -} + gtk_box_pack_start (GTK_BOX (tasklist->box), tasklist->list, TRUE, TRUE, 0); -/* -------------------------------------------------------------------- * - * Configuration Dialog * - * -------------------------------------------------------------------- */ - -static void -all_workspaces_toggled (GtkToggleButton *tb, Tasklist *tasklist) -{ - tasklist->all_workspaces = gtk_toggle_button_get_active (tb); + /* show the handles */ + if (tasklist->show_handles) + gtk_widget_show (tasklist->handle); + /* set netk tasklist settings */ netk_tasklist_set_include_all_workspaces (NETK_TASKLIST (tasklist->list), tasklist->all_workspaces); + netk_tasklist_set_grouping (NETK_TASKLIST (tasklist->list), + tasklist->grouping); + netk_tasklist_set_show_label (NETK_TASKLIST (tasklist->list), + tasklist->show_label); + netk_tasklist_set_button_relief (NETK_TASKLIST (tasklist->list), + tasklist->flat_buttons ? GTK_RELIEF_NONE : GTK_RELIEF_NORMAL); + + /* connect screen changed signal */ + tasklist->screen_changed_id = + g_signal_connect_swapped (G_OBJECT (plugin), "screen-changed", + G_CALLBACK (tasklist_screen_changed), tasklist); } - -static void -grouping_changed (GtkComboBox *cb, Tasklist *tasklist) -{ - tasklist->grouping = gtk_combo_box_get_active (cb); - - netk_tasklist_set_grouping (NETK_TASKLIST (tasklist->list), - tasklist->grouping); -} - -static void -show_label_toggled (GtkToggleButton *tb, Tasklist *tasklist) -{ - tasklist->show_label = gtk_toggle_button_get_active (tb); - - netk_tasklist_set_show_label (NETK_TASKLIST (tasklist->list), - tasklist->show_label); -} - -static void -expand_toggled (GtkToggleButton *tb, Tasklist *tasklist) -{ - tasklist->expand = gtk_toggle_button_get_active (tb); - - xfce_panel_plugin_set_expand (tasklist->plugin, tasklist->expand); -} - -static void -flat_buttons_toggled (GtkToggleButton *tb, Tasklist *tasklist) -{ - tasklist->flat_buttons = gtk_toggle_button_get_active (tb); - - netk_tasklist_set_button_relief (NETK_TASKLIST (tasklist->list), - tasklist->flat_buttons ? - GTK_RELIEF_NONE : GTK_RELIEF_NORMAL); -} - -static void -width_changed (GtkSpinButton *sb, Tasklist *tasklist) -{ - tasklist->width = gtk_spin_button_get_value_as_int (sb); - - tasklist_set_size (tasklist->plugin, - xfce_panel_plugin_get_size (tasklist->plugin), - tasklist); -} - -static void -tasklist_dialog_response (GtkWidget *dlg, int reponse, - Tasklist *tasklist) -{ - g_object_set_data (G_OBJECT (tasklist->plugin), "dialog", NULL); - - gtk_widget_destroy (dlg); - xfce_panel_plugin_unblock_menu (tasklist->plugin); - tasklist_write_rc_file (tasklist->plugin, tasklist); -} - -static void -tasklist_properties_dialog (XfcePanelPlugin *plugin, Tasklist *tasklist) -{ - GtkWidget *dlg, *mainvbox, *vbox, *frame, *cb, - *hbox, *label, *spin; - - xfce_panel_plugin_block_menu (plugin); - - dlg = xfce_titled_dialog_new_with_buttons (_("Task List"), NULL, - GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, - GTK_STOCK_CLOSE, GTK_RESPONSE_OK, - NULL); - - gtk_window_set_screen (GTK_WINDOW (dlg), - gtk_widget_get_screen (GTK_WIDGET (plugin))); - - g_object_set_data (G_OBJECT (plugin), "dialog", dlg); - - gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER); - gtk_window_set_icon_name (GTK_WINDOW (dlg), "xfce4-settings"); - - g_signal_connect (dlg, "response", G_CALLBACK (tasklist_dialog_response), - tasklist); - - gtk_container_set_border_width (GTK_CONTAINER (dlg), 2); - - mainvbox = gtk_vbox_new (FALSE, 8); - gtk_container_set_border_width (GTK_CONTAINER (mainvbox), 5); - gtk_widget_show (mainvbox); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), mainvbox, - TRUE, TRUE, 0); - - /* Size */ - vbox = gtk_vbox_new (FALSE, 8); - gtk_widget_show (vbox); - - frame = xfce_create_framebox_with_content (_("Appearance"), vbox); - gtk_widget_show (frame); - gtk_box_pack_start (GTK_BOX (mainvbox), frame, FALSE, FALSE, 0); - - hbox = gtk_hbox_new (FALSE, 8); - gtk_widget_show (hbox); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new (_("Minimum Width:")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - /* an arbitrary max of 4000 should be future proof, right? */ - spin = gtk_spin_button_new_with_range (100, 4000, 10); - gtk_widget_show (spin); - gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 0); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), tasklist->width); - g_signal_connect (spin, "value-changed", G_CALLBACK (width_changed), - tasklist); - - if (using_xinerama (plugin)) - { - cb = gtk_check_button_new_with_mnemonic (_("Use all available space")); - gtk_widget_show (cb); - gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), - tasklist->expand); - g_signal_connect (cb, "toggled", G_CALLBACK (expand_toggled), - tasklist); - } - - cb = gtk_check_button_new_with_mnemonic (_("Use flat buttons")); - gtk_widget_show (cb); - gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), - tasklist->flat_buttons); - - g_signal_connect (cb, "toggled", G_CALLBACK (flat_buttons_toggled), - tasklist); - - /* Tasks */ - vbox = gtk_vbox_new (FALSE, 8); - gtk_widget_show (vbox); - - frame = xfce_create_framebox_with_content (_("Task List"), vbox); - gtk_widget_show (frame); - gtk_box_pack_start (GTK_BOX (mainvbox), frame, FALSE, FALSE, 0); - - cb = gtk_check_button_new_with_mnemonic (_("Show tasks " - "from _all workspaces")); - gtk_widget_show (cb); - gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), - tasklist->all_workspaces); - - g_signal_connect (cb, "toggled", G_CALLBACK (all_workspaces_toggled), - tasklist); - - cb = gtk_check_button_new_with_mnemonic (_("Show application _names")); - gtk_widget_show (cb); - gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), - tasklist->show_label); - g_signal_connect (cb, "toggled", G_CALLBACK (show_label_toggled), - tasklist); - - cb = gtk_combo_box_new_text (); - gtk_widget_show (cb); - gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0); - - /* keep order in sync with NetkTasklistGroupingType */ - gtk_combo_box_append_text (GTK_COMBO_BOX (cb), - _("Never group tasks")); - - gtk_combo_box_append_text (GTK_COMBO_BOX (cb), - _("Automatically group tasks")); - - gtk_combo_box_append_text (GTK_COMBO_BOX (cb), - _("Always group tasks")); - - gtk_combo_box_set_active (GTK_COMBO_BOX (cb), tasklist->grouping); - - g_signal_connect (cb, "changed", G_CALLBACK (grouping_changed), - tasklist); - - gtk_widget_show (dlg); -} - -static gboolean -using_xinerama (XfcePanelPlugin *plugin) -{ - return ( gdk_screen_get_n_monitors ( - gtk_widget_get_screen (GTK_WIDGET (plugin))) > 1 ); -} - - diff --git a/plugins/tasklist/tasklist.desktop.in.in b/plugins/tasklist/tasklist.desktop.in.in index 029a96b62..dcb6ca47a 100644 --- a/plugins/tasklist/tasklist.desktop.in.in +++ b/plugins/tasklist/tasklist.desktop.in.in @@ -5,5 +5,5 @@ _Name=Task List _Comment=Show all running applications Icon=xfce4-taskbar X-XFCE-Module=tasklist -X-XFCE-Module-Path=@INTERNAL_PLUGIN_PATH@ +X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins diff --git a/plugins/tasklist/tasklist.h b/plugins/tasklist/tasklist.h new file mode 100644 index 000000000..dab79bd0e --- /dev/null +++ b/plugins/tasklist/tasklist.h @@ -0,0 +1,56 @@ +/* $Id$ + * + * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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 Library 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 __TASKLIST_H__ +#define __TASKLIST_H__ + +#include <gtk/gtk.h> +#include <libxfcegui4/libxfcegui4.h> +#include <libxfce4panel/xfce-panel-plugin.h> + +typedef struct _Tasklist Tasklist; + +struct _Tasklist +{ + XfcePanelPlugin *plugin; + + /* widgets */ + GtkWidget *box; + GtkWidget *handle; + GtkWidget *list; + + /* signals */ + gint screen_changed_id; + + /* settings */ + gint width; + NetkTasklistGroupingType grouping; + guint all_workspaces : 1; + guint show_label : 1; + guint expand : 1; + guint flat_buttons : 1; + guint show_handles : 1; +}; + +void tasklist_write_rc_file (Tasklist *tasklist) G_GNUC_INTERNAL; +gboolean tasklist_set_size (Tasklist *tasklist, + gint size) G_GNUC_INTERNAL; +gboolean tasklist_using_xinerama (XfcePanelPlugin *plugin) G_GNUC_INTERNAL; + +#endif /* !__TASKLIST_H__ */ diff --git a/plugins/windowlist/Makefile.am b/plugins/windowlist/Makefile.am index 6753d6f2a..e520cbc1d 100644 --- a/plugins/windowlist/Makefile.am +++ b/plugins/windowlist/Makefile.am @@ -1,25 +1,33 @@ -bin_PROGRAMS = xfce4-popup-windowlist +# $Id$ -xfce4_popup_windowlist_SOURCES = \ - xfce4-popup-windowlist.c \ +INCLUDES = \ + -I$(top_srcdir) \ + -DG_LOG_DOMAIN=\"libwindowlist\" \ + -DLOCALEDIR=\"$(localedir)\" \ + $(PLATFORM_CPPFLAGS) + +bin_PROGRAMS = \ + xfce4-popup-windowlist + +xfce4_popup_windowlist_SOURCES = \ + xfce4-popup-windowlist.c \ xfce4-popup-windowlist.h -xfce4_popup_windowlist_CFLAGS = \ - $(LIBX11_CFLAGS) \ - $(GTK_CFLAGS) +xfce4_popup_windowlist_CFLAGS = \ + $(LIBX11_CFLAGS) \ + $(GTK_CFLAGS) \ + $(PLATFORM_CFLAGS) -xfce4_popup_windowlist_LDADD = \ - $(LIBX11_LDFLAGS) \ - $(LIBX11_LIBS) \ +xfce4_popup_windowlist_LDADD = \ + $(LIBX11_LDFLAGS) \ + $(LIBX11_LIBS) \ $(GTK_LIBS) -plugindir = $(libdir)/xfce4/panel-plugins +plugindir = \ + $(libdir)/xfce4/panel-plugins -plugin_LTLIBRARIES = libwindowlist.la - -libwindowlist_la_LDFLAGS = \ - -avoid-version \ - -module +plugin_LTLIBRARIES = \ + libwindowlist.la libwindowlist_la_SOURCES = \ windowlist.h \ @@ -29,36 +37,45 @@ libwindowlist_la_SOURCES = \ xfce4-popup-windowlist.h libwindowlist_la_CFLAGS = \ - -I$(top_srcdir) \ - @LIBXFCEGUI4_CFLAGS@ \ - -DLOCALEDIR=\"$(localedir)\" + $(GTK_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCEGUI4_CFLAGS) \ + $(PLATFORM_CFLAGS) -libwindowlist_la_LIBADD = \ - ../../libxfce4panel/libxfce4panel.la \ - @LIBS@ +libwindowlist_la_LDFLAGS = \ + -avoid-version \ + -module \ + $(PLATFORM_LDFLAGS) -libwindowlist_la_DEPENDENCIES = \ - ../../libxfce4panel/libxfce4panel.la - if HAVE_CYGWIN -libwindowlist_la_LDFLAGS += \ - -no-undefined \ - @LIBX11_LDFLAGS@ \ - @LIBXFCEGUI4_LIBS@ \ - @LIBX11_LIBS@ +libwindowlist_la_LDFLAGS += \ + -no-undefined endif +libwindowlist_la_LIBADD = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la \ + $(GTK_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCEGUI4_LIBS) + +libwindowlist_la_DEPENDENCIES = \ + $(top_builddir)/libxfce4panel/libxfce4panel.la + +# # .desktop file # -# Some automake trickery here. Because we cannot use $(libexecdir) in the -# automake stage, we'll use sed to get the full path into the .desktop file. -# We also need to let intltool merge the translated fields, so we add an -# additional level of indirection: a <name>.desktop.in.in file. -# -desktop_in_in_files = windowlist.desktop.in.in -desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in) - -desktopdir = $(datadir)/xfce4/panel-plugins +desktopdir = \ + $(datadir)/xfce4/panel-plugins + +desktop_in_in_files = \ + windowlist.desktop.in.in + +desktop_in_files = \ + $(desktop_in_in_files:.desktop.in.in=.desktop.in) + +%.desktop.in: %.desktop.in.in + sed -e "s,\@libdir\@,$(libdir),g" < $< > $@ + desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) @INTLTOOL_DESKTOP_RULE@ @@ -66,12 +83,7 @@ EXTRA_DIST = \ $(desktop_in_in_files) DISTCLEANFILES = \ - $(desktop_DATA) $(desktop_in_files) - -# get full path into .desktop file -%.desktop.in: %.desktop.in.in $(plugin_LTLIBRARIES) - plugin_name=`grep dlname= $(plugin_LTLIBRARIES) | sed "s/dlname='\(.*\)'/\1/"`; \ - sed -e "s^@INTERNAL_PLUGIN_PATH@^$(libdir)/xfce4/panel-plugins^" \ - -e "s^@PLUGIN_NAME@^$$plugin_name^" \ - $< > $@ + $(desktop_DATA) \ + $(desktop_in_files) +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/plugins/windowlist/windowlist-dialog.c b/plugins/windowlist/windowlist-dialog.c index 3f0e34008..57f35e5e9 100644 --- a/plugins/windowlist/windowlist-dialog.c +++ b/plugins/windowlist/windowlist-dialog.c @@ -4,12 +4,12 @@ * * Copyright (c) 2003 Andre Lerche <a.lerche@gmx.net> * Copyright (c) 2003 Benedikt Meurer <benedikt.meurer@unix-ag.uni-siegen.de> - * Copyright (c) 2006 Jani Monoses <jani@ubuntu.com> + * Copyright (c) 2006 Jani Monoses <jani@ubuntu.com> * Copyright (c) 2006 Jasper Huijsmans <jasper@xfce.org> * Copyright (c) 2006 Nick Schermer <nick@xfce.org> * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published + * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * @@ -22,7 +22,7 @@ * 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 @@ -33,13 +33,13 @@ typedef struct { Windowlist *wl; - + GtkWidget *button_layout; - + GtkWidget *show_all_workspaces; GtkWidget *show_window_icons; GtkWidget *show_workspace_actions; - + GtkWidget *notify_disabled; GtkWidget *notify_other; GtkWidget *notify_all; @@ -52,16 +52,16 @@ windowlist_notify_toggled (GtkWidget *button, { if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) return; - + if (button == wd->notify_disabled) wd->wl->notify = DISABLED; - + else if (button == wd->notify_other) wd->wl->notify = OTHER_WORKSPACES; - + else if (button == wd->notify_all) wd->wl->notify = ALL_WORKSPACES; - + windowlist_start_blink (wd->wl); } @@ -75,31 +75,31 @@ windowlist_button_toggled (GtkWidget *button, wd->wl->layout = ARROW_BUTTON; else wd->wl->layout = ICON_BUTTON; - + windowlist_create_button (wd->wl); } else if (button == wd->show_all_workspaces) - wd->wl->show_all_workspaces = + wd->wl->show_all_workspaces = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - + else if (button == wd->show_window_icons) - wd->wl->show_window_icons = + wd->wl->show_window_icons = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - + else if (button == wd->show_workspace_actions) - wd->wl->show_workspace_actions = + wd->wl->show_workspace_actions = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); } static void -windowlist_properties_response (GtkWidget *dlg, +windowlist_properties_response (GtkWidget *dlg, int response, WindowlistDialog *wd) { gtk_widget_destroy (dlg); - + xfce_panel_plugin_unblock_menu (wd->wl->plugin); - + panel_slice_free (WindowlistDialog, wd); } @@ -108,29 +108,29 @@ windowlist_properties (XfcePanelPlugin *plugin, Windowlist * wl) { WindowlistDialog *wd; - + GtkWidget *dlg, *vbox, *vbox2, *frame, *hbox, *alignment, *label, *button, *image; - + wd = panel_slice_new0 (WindowlistDialog); - + wd->wl = wl; - + xfce_panel_plugin_block_menu (wd->wl->plugin); - + dlg = xfce_titled_dialog_new_with_buttons (_("Window List"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); - gtk_window_set_screen (GTK_WINDOW (dlg), + gtk_window_set_screen (GTK_WINDOW (dlg), gtk_widget_get_screen (GTK_WIDGET (plugin))); gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER); gtk_window_set_icon_name (GTK_WINDOW (dlg), "xfce4-settings"); - + gtk_container_set_border_width (GTK_CONTAINER (dlg), 2); - + vbox = gtk_vbox_new (FALSE, BORDER); gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER - 2); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), vbox, @@ -140,7 +140,7 @@ windowlist_properties (XfcePanelPlugin *plugin, hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); - image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, + image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DND); gtk_misc_set_alignment (GTK_MISC (image), 0, 0); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); @@ -159,55 +159,55 @@ windowlist_properties (XfcePanelPlugin *plugin, vbox2 = gtk_vbox_new (FALSE, 6); gtk_container_add (GTK_CONTAINER (alignment), vbox2); - - button = wd->notify_disabled = + + button = wd->notify_disabled = gtk_radio_button_new_with_mnemonic (NULL, _("_Disabled")); gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), (wd->wl->notify == DISABLED)); g_signal_connect (button, "toggled", G_CALLBACK (windowlist_notify_toggled), wd); - button = wd->notify_other = + button = wd->notify_other = gtk_radio_button_new_with_mnemonic_from_widget ( GTK_RADIO_BUTTON (button), _("For _other workspaces")); gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), (wd->wl->notify == OTHER_WORKSPACES)); g_signal_connect (button, "toggled", G_CALLBACK (windowlist_notify_toggled), wd); - - button = wd->notify_all = + + button = wd->notify_all = gtk_radio_button_new_with_mnemonic_from_widget ( GTK_RADIO_BUTTON (button), _("For _all workspaces")); gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), (wd->wl->notify == ALL_WORKSPACES)); g_signal_connect (button, "toggled", G_CALLBACK (windowlist_notify_toggled), wd); - + /* Button Layout */ frame = xfce_create_framebox (_("Appearance"), &alignment); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0); vbox2 = gtk_vbox_new (FALSE, 6); gtk_container_add (GTK_CONTAINER (alignment), vbox2); - + button = gtk_radio_button_new_with_mnemonic (NULL, _("_Icon button")); gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), (wd->wl->layout == ICON_BUTTON)); button = wd->button_layout = gtk_radio_button_new_with_mnemonic_from_widget ( GTK_RADIO_BUTTON (button), _("A_rrow button")); gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), (wd->wl->layout == ARROW_BUTTON)); g_signal_connect (button, "toggled", G_CALLBACK (windowlist_button_toggled), wd); - + /* Windowlist Settings */ frame = xfce_create_framebox (_("Window List"), &alignment); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0); @@ -220,8 +220,8 @@ windowlist_properties (XfcePanelPlugin *plugin, gtk_check_button_new_with_mnemonic ( _("Show _windows from all workspaces")); gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), wd->wl->show_all_workspaces); g_signal_connect (button, "toggled", G_CALLBACK (windowlist_button_toggled), wd); @@ -229,8 +229,8 @@ windowlist_properties (XfcePanelPlugin *plugin, button = wd->show_window_icons = gtk_check_button_new_with_mnemonic (_("Show a_pplication icons")); gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), wd->wl->show_window_icons); g_signal_connect (button, "toggled", G_CALLBACK (windowlist_button_toggled), wd); @@ -238,15 +238,15 @@ windowlist_properties (XfcePanelPlugin *plugin, button = wd->show_workspace_actions = gtk_check_button_new_with_mnemonic (_("Show wor_kspace actions")); gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), wd->wl->show_workspace_actions); g_signal_connect (button, "toggled", G_CALLBACK (windowlist_button_toggled), wd); /* Show Dialog */ - g_signal_connect (dlg, "response", + g_signal_connect (dlg, "response", G_CALLBACK (windowlist_properties_response), wd); - + gtk_widget_show_all (dlg); } diff --git a/plugins/windowlist/windowlist.c b/plugins/windowlist/windowlist.c index ef1cd13ed..3057877e7 100644 --- a/plugins/windowlist/windowlist.c +++ b/plugins/windowlist/windowlist.c @@ -559,11 +559,11 @@ menulist_popup_menu (Windowlist * wl, /* Apply some styles for windows on !current workspace and * if they are urgent */ - if (netk_window_or_transient_demands_attention (window)) + if (netk_window_or_transient_demands_attention (window)) { if (netk_workspace == active_workspace) { - gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (mi)), + gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (mi)), bold); } else @@ -571,7 +571,7 @@ menulist_popup_menu (Windowlist * wl, gtk_widget_modify_fg (gtk_bin_get_child (GTK_BIN (mi)), GTK_STATE_NORMAL, &(menu->style->fg[GTK_STATE_INSENSITIVE])); - gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (mi)), + gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (mi)), bold); } } @@ -734,7 +734,8 @@ windowlist_search_urgent (gpointer data) netk_window_is_skip_tasklist (window)) continue; - if (netk_window_or_transient_demands_attention (window)) + /* Check if window is urgent */ + if (netk_window_or_transient_demands_attention (window)) blink = TRUE; } diff --git a/plugins/windowlist/windowlist.desktop.in.in b/plugins/windowlist/windowlist.desktop.in.in index 9b2a15f0f..56dee136f 100644 --- a/plugins/windowlist/windowlist.desktop.in.in +++ b/plugins/windowlist/windowlist.desktop.in.in @@ -5,5 +5,5 @@ _Name=Window List _Comment=Show list of available windows Icon=xfce-windowlist X-XFCE-Module=windowlist -X-XFCE-Module-Path=@INTERNAL_PLUGIN_PATH@ +X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins diff --git a/plugins/windowlist/windowlist.h b/plugins/windowlist/windowlist.h index 58275cbd8..2be501376 100644 --- a/plugins/windowlist/windowlist.h +++ b/plugins/windowlist/windowlist.h @@ -4,12 +4,12 @@ * * Copyright (c) 2003 Andre Lerche <a.lerche@gmx.net> * Copyright (c) 2003 Benedikt Meurer <benedikt.meurer@unix-ag.uni-siegen.de> - * Copyright (c) 2006 Jani Monoses <jani@ubuntu.com> + * Copyright (c) 2006 Jani Monoses <jani@ubuntu.com> * Copyright (c) 2006 Jasper Huijsmans <jasper@xfce.org> * Copyright (c) 2006 Nick Schermer <nick@xfce.org> * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published + * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * @@ -59,21 +59,21 @@ typedef struct NetkScreen *screen; guint screen_callback_id; - + /* Settings */ ButtonLayout layout; - - gboolean show_all_workspaces; - gboolean show_window_icons; - gboolean show_workspace_actions; - + + guint show_all_workspaces : 1; + guint show_window_icons : 1; + guint show_workspace_actions : 1; + UrgencyNotify notify; - + /* Blink button stuff */ guint search_timeout_id; guint blink_timeout_id; - gboolean blink; - gboolean block_blink; + guint blink : 1; + guint block_blink : 1; } Windowlist; diff --git a/xfce4-panel.spec.in b/xfce4-panel.spec.in index ff5e52bc8..06719dd7a 100644 --- a/xfce4-panel.spec.in +++ b/xfce4-panel.spec.in @@ -1,18 +1,21 @@ -Summary: Xfce Panel -Name: @PACKAGE_TARNAME@ -Version: @PACKAGE_VERSION@ -Release: 1 -License: GPL, LGPL -URL: http://www.xfce.org/ -Source0: %{name}-%{version}.tar.gz -Group: User Interface/Desktops -BuildRoot: %{_tmppath}/%{name}-root -Requires: libxfce4util >= @LIBXFCEGUI4_REQUIRED_VERSION@ -Requires: libxfcegui4 >= @LIBXFCEGUI4_REQUIRED_VERSION@ -BuildRequires: libxfce4util-devel >= @LIBXFCEGUI4_REQUIRED_VERSION@ -BuildRequires: libxfcegui4-devel >= @LIBXFCEGUI4_REQUIRED_VERSION@ -Requires: gtk2 >= @GTK_REQUIRED_VERSION@ -BuildRequires: gtk2-devel >= @GTK_REQUIRED_VERSION@ +Summary: Xfce Panel +Name: @PACKAGE_TARNAME@ +Version: @PACKAGE_VERSION@ +Release: 1 +License: GPL, LGPL +URL: http://www.xfce.org/ +Source0: %{name}-%{version}.tar.gz +Group: User Interface/Desktops +BuildRoot: %{_tmppath}/%{name}-root +Requires: libxfce4util >= @LIBXFCEGUI4_REQUIRED_VERSION@ +Requires: libxfcegui4 >= @LIBXFCEGUI4_REQUIRED_VERSION@ +Requires: exo0.3 >= @EXO_REQUIRED_VERSION@ +Requires: gtk2 >= @GTK_REQUIRED_VERSION@ +Requires: startup-notification >= @LIBSTARTUP_NOTIFICATION_REQUIRED_VERSION@ +BuildRequires: libxfce4util-devel >= @LIBXFCEGUI4_REQUIRED_VERSION@ +BuildRequires: libxfcegui4-devel >= @LIBXFCEGUI4_REQUIRED_VERSION@ +BuildRequires: exo0.3-devel >= @EXO_REQUIRED_VERSION@ +BuildRequires: gtk2-devel >= @GTK_REQUIRED_VERSION@ %description xfce4-panel is the panel for the Xfce desktop environment @@ -55,7 +58,7 @@ fi %files %defattr(-,root,root) -%doc README README.Kiosk ChangeLog NEWS INSTALL COPYING COPYING_LIBS AUTHORS HACKING +%doc README COPYING COPYING.LIB HACKING INSTALL %config(noreplace) %{_sysconfdir}/xdg/xfce4/ %{_datadir}/icons/ %{_datadir}/locale/ @@ -66,7 +69,7 @@ fi %{_libexecdir}/xfce4/panel-plugins/ %files devel -%defattr(-, root, root) +%defattr(-,root,root) %{_libdir}/lib*.so %{_libdir}/*a %{_libdir}/pkgconfig/*.pc -- GitLab