apwal/0000755000175000017500000000000010161562323011517 5ustar pebpeb00000000000000apwal/ABOUT0000644000175000017500000000052110155677470012327 0ustar pebpeb00000000000000Apwal is developped by: ======================= Pascal Eberhard - pascal [dot] ebo [at] laposte [dot] net It you have any request, problem or bug... please tell me! Thanks to: ========== CbWan The first user of Apwal. As paintful it is! Thanks also for his suggestions. Whaly For helping me to find the name of the launcher. apwal/Changelog0000644000175000017500000001762410161533611013341 0ustar pebpeb000000000000000.4.5 - - debian: debian/ files updated from Sam advices. - plenty of good changes have been integrated into gtk2. Use now glib timeouts, gobject closure marshaler, gtk draw_rectangle does not require a padding of 2px in cereimg anymore. Get rid of apwal_file_selection and replace it by gtk file_chooser which allows to select a directory eventually and not only files. - add option --config i to apwal. It's now possible to create an icon calling recusively Apwal with another config file. It provides a simple way to create submenus (Thanks Bill for the idea). - Added busy cursor when loading the icons. - Remove few 'fixme:' in the code. 0.4.4 - 2003.10.25 - splash & filesel: handle delete event on dialog box because metacity shows the menu bar on dialog box which allow the user to kill them. - filesel: fix RH8 compilation problem, gtk_widget_get_display undefined. - property: fix RH8 gtk_widget_modify_text pb, doesn't reset color if NULL. - all: correct gcc log marco format, add a script to avoid this problem again. - editor: remove key bindings until i find a better way to do it. 0.4.3 - 2003.10.25 - all: check tooltips - editor: add 'delete' key binding. - editor: cursor doesn't follow an icon drag anymore. - iconsel: correct the scrollbar bug when started in tab mode. - editor: remove the unknown icon as soon as it is not necessary. - iconsel: apply/close or ok/cancel depending on the window modal mode. - iconsel: apply button near selected icon only showed in tab mode. - property: show exec file/path/icon in red if invalid. - editor: remove tips on arrows and add a bulb to enlight the user. - filesel: use the gtk2 widget and add a dir_only option, merge with dirsel. - sys: simplify file func, now use g_find_program_in_path/g_file_test/... - sys: simplify spawn func. - property: replace the treeview by entries. - app: modifiy properties: del name, add cmdline=prog+args, execpath=path. - splash: add a progress bar when loading icons. - launcher: remove the need of the proc filesystem to launch the editor. - iconsel: correct bug on delete event if iconsel displayed in a 2d window. 0.4.2 - 2003.11.26 - dirsel: create a directory selector. Features: TAB completion, easy navigation with keys. Used for the app launch path and the pixmap paths. - iconsel: fix bug when deselecting the pixmap directory in which the current icon app is in. - iconlist: fix bug when filtering icons on load if the icon failed to be created. (Thanks to Volker) - property: fix assert at launch of the file selector. - all: correct log macro calls. macros need always an argument after fmt. So add "%s","" in case of log msg w/o args. (Thanks to Krp) 0.4.1 - 2003.11.16 - all: size and extension filters are now active at load of the icons from disk. It is a little slower but it consumes less memory - all: Debian package created - syssutff: correct exit of apwal when the program to launch do not exist - launcher: add an option to allow to close apwal at launch of an application - iconsel: it is now possible to change the dimension of the Icon Selection windows when it is in a separate window - iconsel: Icon Selection window is showed automaticly in non modal mode when it is in a separate window - iconsel: It is possible to change dynamicly the mode of the Icon Selection (tab, window, modal window) - iconsel: the Icon Selection could now be launched in a tab in the main window, in a separate window, or in a separate modal window - editor: no icon is showed 'selected' when no app selected (pb at start) - apwal_pref: set/unset correctly tootips at editor start - receimg: replace gdk_draw_pixbuf to gdk_pixbuf_render_to_drawable unless it don't compile on RH8 - iconsel: correct bug at start if someone save a empty path/extension. line 40 (icon_dir_new): assertion failed: (path != NULL) - add a message box if an application failed when it is clicked. - iconlist: explained to this machine that /to/ti or /to//ti or /to/ti/ or whatever are the same directory 0.4.00 - 2003.02.25 - iconsel: deals now correctly with 2 recursive paths which cross together like /usr/share/icons and /usr/shares/icons/hicolor for example - iconsel: correct forget of truncating icons 48x.. or ..x48 - iconsel: show the real width and height of an icon and not the truncated one if truncated. so filters are ok for bigger icons. 0.3.32 - 2003.02.24 - all: a lot of improvement based on Cbwan's suggestion. - iconsel: add buttons add, collapse and expand have now the the same size. - iconsel: check if selection are ok. and it is :) remove !selected button. - editor: remove a bug in vertical size initialisation - xmlrc: if it is the first launch of apwal then create a new xmrc file and launch the editor. - about: done. a little one :) - apwal_pref: new tab apwal_pref. options: timout and activate_tooltips - launcher/editor: remove dependence of X11 call used to get the resolution of the screen (use now gdk_screen_width and height) - all: create LICENSE file and add GPL headers in source files. - all: some cleanup in pixmaps and src directories - all: add install rules on Makefile, update install info in INSTALL file - all: add tooltips on thinks not easy to undertand naturally. - iconsel: truncate icon > 48x48 to save some memory - iconsel: append relief to icon in treeview - property: append relief to icon in treeview - editor: refresh property on start of drag and drop - launcher: editor is now launch from the current apwal binary to avoid path and version problems. - launcher: exit launcher when right click to an icon to launch the editor - selico: add 'apply' button, do the same as dblclick on an icon/selected icon - selico: remove 'file' label - editor: never more that one noname/unknown application/icon at one time. 0.3.31 - 2003.02.10 - fisrt version release since 0.1.22 - a LOT of new features. new icon selection form, new editor... 0.1.22 - 2002.11.20 - add sysstuff.[ch]: sys_exec and sys_can_exec. - deal now with GError on error for gtk function using it. - take now to excess of g_assert rather that if (!ptr) and cie. - create testing directory for testing some stuff (gtktreeview, ...). - add new icon selector. i hope you are going to like it! 0.1.21 - 2002.11.16 - and it will be called... apwal! Tadaaaa.... Thanks to Whale for his proposition! - configuration file is now ~/.apwalrc.xml, update your config! - create src and sample directories, clean some obsolete code. - use define rather than fixed value to cut icon bigger than 48x48. - add gtkstuff.[ch]: add gtk_arrow_button_new(), icon load always use gdk_pixbuf_new_from_apwal(). - icons used are now integrated in the binary file, Makefile generates pixbufinline.inc from PNG files in the directory. - command line arguments are now parsed at the execution. 0.1.20 - 2002.11.12 - app: add have_exec_access and app_exec_is_valid. - launcher and editor: icons with an invalid executable appear in grey. - clean some obsolete files. 0.1.19 - 2002.11.11 - property: remove button directly removes app form the app_list. - app: add app_list_remove, implement app_list_delete. - launcher: prevent starting 2 editors with 2 right clics on an icon. - editor: rewrite button arrow code. - 'no app' is now different than 'app with an unknown icon'. - editor: add the position of the cursor. - launcher and editor: support icons with different size than 48x48. 0.1.18 - 2002.11.09 - editor: the ok button now save the xml file and exit the editor. - editor: the 'cancel' button now exit the editor. 0.1.17 - 2002.11.09 - and it first bug report 10 minutes after :) - launcher: fix freeze on click to an icon with an incorrect executable (no exit on error on execvp). 0.1.16 - 2002.11.09 - Now launcher has is first real user! Thanks Cbwan! apwal/FAQ0000644000175000017500000000253410161562301012051 0ustar pebpeb00000000000000How to launch the editor? ========================= - When Apwal is running, click right on any application icon - apwal --edit How to bind Apwal on the right click with Sawfish? ================================================= Start the Sawfish Configurator: sawfish-ui Go to tab 'Bindings' and set context to 'Root window' Bind 'Button3-Click' to 'Run shell command' and set command to 'apwal' How to bind Apwal on the left click with Enlightenment 0.16? ======================================================= Copy the current key bindings configuration in your E16 local directory: # cp 'EnlightenmentPath'/config/keybindings.cfg ~/.enlightenment/ Where 'EnlightenmentPath' is: for Debian: /usr/share/enlightenment/ for RedHat: /usr/share/enlightenment/ for SuSE: /usr/X11R6/share/enlightenment/ for Mandrake: /usr/X11R6/share/enlightenment/ Edit it and then replace: LTIP_ACTION_TEXT "Display User Menus" __EVENT __MOUSE_PRESS __BUTTON 1 __MODIFIER_KEY __NONE __ACTION __A_SHOW_MENU "named APPS_SUBMENU" by: LTIP_ACTION_TEXT "Apwal Menu" __EVENT __MOUSE_PRESS __BUTTON 1 __MODIFIER_KEY __NONE __ACTION __A_EXEC apwal How to create submenu ? ======================= - in the editor, add an icon with the following command line: apwal --config .apwalrc2.xml apwal/INSTALL0000644000175000017500000000046107756013563012566 0ustar pebpeb00000000000000INSTALL ======= $ tar zxvf apwal-x.y.z.tar.gz $ cd apwal $ make $ su root # make install # exit $ apwal enjoy! NOTE ==== To compile this program you need the developpement library of gtk2 and xml2 In Debian the build package dependencies are: - libgtk2.0-dev - libxml2-dev - binutils (for strip) apwal/LICENSE0000644000175000017500000004311007731413223012526 0ustar pebpeb00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. apwal/Makefile0000644000175000017500000000043010161535427013161 0ustar pebpeb00000000000000 include Makefile.inc all: (cd src && $(MAKE) $@) install: (cd src && $(MAKE) $@) clean: (cd src && $(MAKE) $@) -dh_clean -rm -f build-stamp www: sh ../apwal-www/templates/newupstream.sh sav: clean (cd ..; tar zcvf ~/sav/$(PROG)-$(VERS).tar.gz --exclude CVS $(PROG)) apwal/Makefile.inc0000644000175000017500000000013510161527020013721 0ustar pebpeb00000000000000 PROG=apwal VERS=0.4.5 #To activacte debugging just uncomment the next line #APWAL_DEBUG=1 apwal/README0000644000175000017500000000174510161516422012405 0ustar pebpeb00000000000000 APWAL ===== Allons Par Wangen Acheter des Lilas (advanced and powerful window app launcher) DEVEL INFO ========== edit Makefile.inc to activate debugging BUGS ==== Please tell me WISHLIST/IDEAS - NO PARTICULAR ORDER ==================================== - editor: location of the 'remove' button not really good. - iconselpref: pixmap path in red in invalid - internationalisation/localisation - pool of threads for [re]loading the icons for better usability of the UI. - effects: zooming ala mac, shadow, icon radiance, icon flying to borders, - document the code with documentation system (doxygen?) - SVG support - allow icons from any size. allow to resize them. - position of the icons: free, snap to grid, elipse, spiral, ... - really need to make a nicer 'unknown' icon - rupport of rpm package and... - implement key binding for the editor - comment popup when mouse over icon - gtk2.6: look at GtkIconView, GtkAboutDialog, GtkCellRendererProgress apwal/debian/0000755000175000017500000000000010161562545012747 5ustar pebpeb00000000000000apwal/debian/apwal.10000644000175000017500000000051610004776301014130 0ustar pebpeb00000000000000.TH APWAL 1 .SH NAME apwal \- powerful application launcher .SH SYNOPSIS .B apwal .I "[options]" .SH "DESCRIPTION" .B apwal is a simple and powerful application launcher for X based on the GTK2 toolkit. .SH OPTIONS .TP .B \-\-edit launch the editor .SH AUTHOR This manual page was written by Pascal Eberhard . apwal/debian/changelog0000644000175000017500000000412510161534706014621 0ustar pebpeb00000000000000apwal (0.4.5) unstable; urgency=low * New upstream release: + debian/ files updated from Sam advices. + plenty of good changes have been integrated into gtk2. Use now glib timeouts, gobject closure marshaler, gtk draw_rectangle does not require a padding of 2px in cereimg anymore. Get rid of apwal_file_selection and replace it by gtk file_chooser which allows to select a directory eventually and not only files. + added option --config to apwal. It's now possible to create an icon calling recusively Apwal with another config file. It provides a simple way to create submenus. + Added busy cursor when loading the icons. + Remove few 'fixme:' in the code. -- Pascal Eberhard Mon, 20 Dec 2004 11:21:07 +0000 apwal (0.4.4-1) unstable; urgency=low * New upstream release: + Correct compilation and window manager interaction problems, temporary remove key bindings. -- Pascal Eberhard Wed, 28 Jan 2004 16:50:37 +0000 apwal (0.4.3-1) unstable; urgency=low * New upstream release: + Simplification, homogenization and improvement of the editor interface (Delete key binding, use of entries rather than treeview, highlight wrong values, remove unnecesary fields, buttons more coherent, ...), + Add a progression bar when loading icons, + Rewrite the directory selector, + Remove the dependence on procfs, + Correct the few known bugs. * Remove the 'apwal-editor' symbolic link. -- Pascal Eberhard Sun, 25 Jan 2004 15:45:25 +0000 apwal (0.4.2-1) unstable; urgency=low * New upstream version. * Add a directory selector and correct some bugs. -- Pascal Eberhard Wed, 3 Dec 2003 00:39:37 +0000 apwal (0.4.1-2) unstable; urgency=low * current CVS version (cvs20031126). -- Pascal Eberhard Wed, 26 Nov 2003 23:02:13 +0000 apwal (0.4.1-1) unstable; urgency=low * Initial release. -- Pascal Eberhard Sun, 16 Nov 2003 02:02:46 +0000 apwal/debian/control0000644000175000017500000000163710161562545014361 0ustar pebpeb00000000000000Source: apwal Section: gnome Priority: optional Maintainer: Pascal Eberhard Build-Depends: debhelper (>= 4.0), libgtk2.0-dev, libxml2-dev Standards-Version: 3.6.1.0 Package: apwal Section: gnome Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: icon-based floating application launcher with transparency Apwal is a simple icon-based application launcher. It consists of two components: the application launcher itself, and the configuration editor. . Upon startup, Apwal displays icons at the mouse pointer location. Left clicking on the icons launches applications, and right-clicking opens Apwal Editor. . Apwal Editor is an easy to use graphical interface to configure Apwal. An icon selector displays icons available on your filesystem. Several filters are available to ease the search (by extension, by size, by name, etc.). . Homepage: http://apwal.free.fr/ apwal/debian/copyright0000644000175000017500000000161010155707072014677 0ustar pebpeb00000000000000Copyright (C) 2002-2004 Pascal Eberhard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. On Debian GNU/Linux systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. apwal/debian/dirs0000644000175000017500000000001007755571052013632 0ustar pebpeb00000000000000usr/bin apwal/debian/rules0000755000175000017500000000275110155706352014033 0ustar pebpeb00000000000000#!/usr/bin/make -f # Sample debian/rules that uses debhelper. # This file is public domain software, originally written by Joey Hess. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 build: build-stamp build-stamp: dh_testdir # Add here commands to compile the package. $(MAKE) touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp # Add here commands to clean up after the build process. -$(MAKE) clean dh_clean install: build dh_testdir dh_testroot dh_clean -k dh_installdirs # Add here commands to install the package into debian/ #$(MAKE) prefix=`pwd`/debian/`dh_listpackages`/usr install install -m 755 src/apwal `pwd`/debian/apwal/usr/bin # Build architecture-independent files here. binary-indep: build install # We have nothing to do by default. # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot dh_installchangelogs Changelog dh_installdocs README FAQ ABOUT dh_installexamples example/apwalrc.xml dh_install # dh_installmenu # dh_installdebconf # dh_installlogrotate # dh_installemacsen # dh_installcatalogs # dh_installpam # dh_installmime # dh_installinit # dh_installcron # dh_installinfo # dh_undocumented dh_installman debian/apwal.1 dh_link dh_strip dh_compress dh_fixperms # dh_perl # dh_python # dh_makeshlibs dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install apwal/debian/compat0000644000175000017500000000000210155707154014145 0ustar pebpeb000000000000004 apwal/example/0000755000175000017500000000000010161536532013155 5ustar pebpeb00000000000000apwal/example/apwalrc.xml0000644000175000017500000000345310161536520015332 0ustar pebpeb00000000000000 xterm -fg wheat -bg black -sl 4097 -sb -rightbar -si +sk /usr/share/pixmaps/gnome-terminal.png 0 0 1 0 0 1 /usr/share/WindowMaker/Icons 1 1 /usr/share/icons 1 1 /usr/share/icons/hicolor 1 1 /usr/share/pixmaps 1 1 *.* 0 *.gif 1 *.png 1 *.tif 1 *.xpm 1 3000 1 1 0 0 apwal/example/apwalrc2.xml0000644000175000017500000000770610161536503015422 0ustar pebpeb00000000000000 xterm -fg wheat -bg black -sl 4097 -sb -rightbar -si +sk /usr/share/icons/crystalsvg/48x48/apps/terminal.png 0 -1 xmms /usr/share/icons/crystalsvg/48x48/devices/cdaudio_unmount.png 2 0 mozilla /usr/share/icons/crystalsvg/48x48/apps/mozilla.png 1 -1 sylpheed /usr/share/pixmaps/sylpheed-claws.png 1 1 gthumb /usr/share/pixmaps/gthumb.png 3 -1 /usr/games/frozen-bubble -fs /usr/share/pixmaps/frozen-bubble-icon-48x48.png 4 1 mozilla-firebird /usr/share/pixmaps/mozilla-firebird.png 1 0 aumix /usr/share/icons/crystalsvg/48x48/apps/multimedia.png 2 -1 gimp-1.3 /usr/share/pixmaps/gnome-gimp.png 3 0 gnome-terminal /usr/share/pixmaps/gnome-terminal.png 0 0 grip /usr/share/icons/crystalsvg/48x48/devices/cdwriter_unmount.png 4 -1 sodipodi /usr/share/pixmaps/sodipodi.png 3 1 rhythmbox /usr/share/pixmaps/rhythmbox.png 2 1 grip /usr/share/pixmaps/gripicon.png 4 0 1 0 0 1 /usr/share/WindowMaker/Icons 1 1 /usr/share/icons 1 1 /usr/share/icons/hicolor 1 1 /usr/share/pixmaps 1 1 *.* 0 *.gif 1 *.png 1 *.tif 1 *.xpm 1 3000 0 1 1 1 apwal/pixmaps/0000755000175000017500000000000010155675247013215 5ustar pebpeb00000000000000apwal/pixmaps/cursor.png0000644000175000017500000000035207731413223015226 0ustar pebpeb00000000000000PNG  IHDRabKGD pHYs  ~tIME  %-%wIDATx C*(XhIPR EE-FP6zЋ=H"ML;#)저z96 ,9/0"CZeWllTIENDB`apwal/pixmaps/cursor2.png0000644000175000017500000000027707731413223015316 0ustar pebpeb00000000000000PNG  IHDR 2ϽbKGD pHYs  d_tIME :$7R{LIDATxA 1 )5Ĉhd0.F1%5sM>ΝBdguZ4}D5C`IENDB`apwal/pixmaps/relief.png0000644000175000017500000000025407731413223015160 0ustar pebpeb00000000000000PNG  IHDRabKGDT pHYs  ~tIME7/9IDATx퓱 LC8S{Y P i.m/ ZЂ_/ +0|I5IENDB`apwal/pixmaps/relief.xcf0000644000175000017500000000255307731413223015160 0ustar pebpeb00000000000000gimp xcf fileBB+c Background      .2֣ mꊎfKM@BBC@ $@ @echo -n "#define XMLRC_DEFAULT \"" >> $@ @cat ../example/apwalrc.xml | awk ' \ BEGIN { ORS="\\n"; } \ { gsub("\"","\\\""); \ print; \ }'>> $@ @echo "\"" >> $@ @echo >> $@ pixbufinline.inc: ../pixmaps/*.png @echo "generating $@..." @list2build=$$( \ for f in ../pixmaps/*.png;do echo "`basename $$f .png` $$f ";done); \ if [ -f $@ ]; then rm -f $@; fi; \ gdk-pixbuf-csource --raw --build-list $$list2build > $@; \ echo >> $@ ; echo "pixbufinline_t pixbufinline[] =" >> $@; \ echo "{" >> $@; \ for f in ../pixmaps/*.png;do \ echo " {" >> $@; \ echo " \"`basename $$f .png`\"," >> $@; \ echo " sizeof(`basename $$f .png`)," >> $@; \ echo " (guint8 *) & `basename $$f .png`" >> $@; \ echo " }," >> $@; \ done; \ echo "};" >> $@; \ echo -n "gint pixbufinline_count = (sizeof(pixbufinline) / " >> $@; \ echo "sizeof(pixbufinline_t));" >> $@; \ echo "" >> $@; tags: $(INCS) $(OBJS:.o=.c) ctags -R checktraceformat: @(fmterr=`find . -name "*.c" | xargs grep -nH '\(TRACE\|WARN\|ERR\)[ \t]*([ \t]*"[^%]*"'`; \ if [ ! -z "$$fmterr" ]; then \ echo "*** gcc on OpenBSD does not allow marcos with args... ending by a ','." ; \ echo '*** To avoid this problem with the log macros, TRACE("") has to' ; \ echo '*** be replaced by TRACE("%s", "") for example. Format problem in:' ; \ echo "$$fmterr" ; \ exit 1; fi; ) clean: -rm -f $(OBJS) apwal pixbufinline.inc xmlrcinline.inc tags apwal/src/about.c0000644000175000017500000001014307775104113013571 0ustar pebpeb00000000000000/* about.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" static void about_build_interface(about_t *about); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- about_t * about_new(struct apwalapp_t *apwal) { about_t *about; g_assert(apwal != NULL); g_assert(apwal->about_frame != NULL); about = (about_t*) malloc(sizeof(about_t)); g_assert(about != NULL); about->apwal = apwal; about_build_interface(about); return about; } // ---------------------------------------------------------------------------- static void about_build_interface(about_t *about) { //GtkWidget *about_frame; GtkWidget *vbox; GtkWidget *label; g_assert(about != NULL); g_assert(about->apwal != NULL); g_assert(about->apwal->about_frame != NULL); // vertical box vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); gtk_box_set_spacing(GTK_BOX(vbox), 4); gtk_container_add(GTK_CONTAINER(about->apwal->about_frame), vbox); gtk_widget_show(vbox); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label), "Apwal\nv" APWAL_VERSION); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); gtk_label_set_selectable(GTK_LABEL(label), TRUE); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); gtk_widget_show(label); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label), "http://apwal.free.fr"); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); gtk_label_set_selectable(GTK_LABEL(label), TRUE); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); gtk_widget_show(label); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label), "Copyright (C) 2002-2004 Pascal Eberhard\nemail: pascal.ebo@laposte.net\n"); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); gtk_label_set_selectable(GTK_LABEL(label), TRUE); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); gtk_widget_show(label); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label), "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." \ "\n\n" \ "This program is distributed in the hope that it will be useful, " \ "but WITHOUT ANY WARRANTY; without even the implied warranty of " \ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU " \ "General Public License for more details." \ "\n\n" \ "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."); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); gtk_label_set_selectable(GTK_LABEL(label), TRUE); gtk_box_pack_end(GTK_BOX(vbox), label, TRUE, TRUE, 0); gtk_widget_show(label); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/about.h0000644000175000017500000000256607775104113013610 0ustar pebpeb00000000000000/* about.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #ifndef ABOUT__H #define ABOUT__H #include "common.h" typedef struct about_t { struct apwalapp_t *apwal; } about_t; // ---------------------------------------------------------------------------- about_t * about_new(struct apwalapp_t *apwal); #endif /* ABOUT__H*/ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/app.c0000644000175000017500000003322007776063610013247 0ustar pebpeb00000000000000/* app.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include // used by app_new_noname & app_list_find_noname #define APP_NONAME_CMDLINE "" #define APP_NONAME_PATH "" #define APP_NONAME_ICON "" // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- app_t * app_new(gchar *cmdline, gchar *path, gchar *icon, gint x, gint y) { app_t *app; g_assert(cmdline != NULL && path != NULL && icon != NULL); app = (app_t *) malloc(sizeof(app_t)); g_assert(app != NULL); app->cmdline = cmdline; app->path = path; app->icon = icon; app->x = x; app->y = y; return app; } // ---------------------------------------------------------------------------- app_t * app_new_noname(gint x, gint y) { app_t *app; app = app_new(g_strdup(APP_NONAME_CMDLINE), g_strdup(APP_NONAME_PATH), g_strdup(APP_NONAME_ICON), x, y); return app; } // ---------------------------------------------------------------------------- void app_free(app_t **app) { g_assert(app != NULL && *app != NULL); TRACE("app:%p", *app); if ((*app)->cmdline) g_free((*app)->cmdline); if ((*app)->path) g_free((*app)->path); if ((*app)->icon) g_free((*app)->icon); free((*app)); (*app) = NULL; } // ---------------------------------------------------------------------------- app_t * app_clone(app_t *app) { app_t *newapp; g_assert(app != NULL); newapp = (app_t *) malloc(sizeof(app_t)); g_assert(newapp != NULL); newapp->cmdline = g_strdup(app->cmdline); newapp->path = g_strdup(app->path); newapp->icon = g_strdup(app->icon); newapp->x = app->x; newapp->y = app->y; return newapp; } // ---------------------------------------------------------------------------- gboolean app_exec(app_t *app, gboolean exit_at_app_launch) { gboolean spawned; g_assert(app != NULL); spawned = sys_spawn(app->cmdline, app->path); if (!spawned) { WARN("sys_spawn, cmdline:%s, path:%s", app->cmdline, app->path); return FALSE; } if (exit_at_app_launch) gtk_main_quit(); return TRUE; } // ---------------------------------------------------------------------------- void app_dump(app_t *app) { g_assert(app != NULL); TRACE("icon:%s, cmdline:%s, x:%d, y:%d", app->icon, app->cmdline, app->x, app->y); } // ---------------------------------------------------------------------------- void app_dumpln(app_t *app) { g_assert(app != NULL); TRACE("[app|icon:%s, cmdline:%s, x:%d, y:%d]", app->icon, app->cmdline, app->x, app->y); } // ---------------------------------------------------------------------------- gboolean app_is_executable(app_t *app) { int argcp; char **argvp; gboolean res, is_exec; g_assert(app != NULL && app->cmdline != NULL); res = g_shell_parse_argv(app->cmdline, &argcp, &argvp, NULL/*GError*/); if (res == TRUE) { if (g_path_is_absolute(argvp[0])) is_exec = g_file_test(argvp[0], G_FILE_TEST_IS_EXECUTABLE); else { char *absolute_path; absolute_path = g_find_program_in_path(argvp[0]); is_exec = g_file_test(absolute_path, G_FILE_TEST_IS_EXECUTABLE); g_free(absolute_path); } g_strfreev(argvp); } else return FALSE; return is_exec; } // ---------------------------------------------------------------------------- gboolean app_path_is_valid(app_t *app) { gboolean is_valid; g_assert(app != NULL && app->path != NULL); if (strcmp("", app->path) == 0) return TRUE; is_valid = g_file_test(app->path, G_FILE_TEST_IS_DIR); return is_valid; } // ---------------------------------------------------------------------------- gboolean app_icon_is_valid(app_t *app) { gboolean is_valid; g_assert(app != NULL && app->icon != NULL); is_valid = g_file_test(app->icon, G_FILE_TEST_EXISTS); return is_valid; } // ---------------------------------------------------------------------------- const char *app_get_cmdline(app_t *app) { g_assert(app != NULL); return app->cmdline; } // ---------------------------------------------------------------------------- void app_set_cmdline(app_t *app, const char *value) { g_assert(app != NULL && value != NULL); TRACE("%s", ""); if (app->cmdline) g_free(app->cmdline); app->cmdline = g_strdup(value); g_assert(app->cmdline != NULL); } // ---------------------------------------------------------------------------- const char *app_get_path(app_t *app) { g_assert(app != NULL); return app->path; } // ---------------------------------------------------------------------------- void app_set_path(app_t *app, const char *value) { g_assert(app != NULL && value != NULL); TRACE("%s", ""); if (app->path) g_free(app->path); app->path = g_strdup(value); g_assert(app->path != NULL); } // ---------------------------------------------------------------------------- const char *app_get_icon(app_t *app) { g_assert(app != NULL); return app->icon; } // ---------------------------------------------------------------------------- void app_set_icon(app_t *app, const char *value) { g_assert(app != NULL && value != NULL); TRACE("%s", ""); if (app->icon) g_free(app->icon); app->icon = g_strdup(value); g_assert(app->icon != NULL); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- app_list_t* app_list_new(void) { app_list_t *apps; apps = (app_list_t *) malloc(sizeof(app_list_t)); g_assert(apps != NULL); apps->apps = NULL; apps->hamster = NULL; return apps; } // ---------------------------------------------------------------------------- void app_list_free(app_list_t **apps) { app_t *app; g_assert(apps != NULL && *apps != NULL); TRACE("apps:%p", apps); while ((*apps)->apps) { (*apps)->hamster = g_list_first((*apps)->apps); if ((*apps)->hamster) app = (*apps)->hamster->data; else { WARN("list:%p, (*apps)->hamster:%p", (*apps)->apps, (*apps)->hamster); } (*apps)->apps = g_list_remove((*apps)->apps, app); app_free(&app); } } // ---------------------------------------------------------------------------- int app_list_add(app_list_t *apps, app_t *app) { gboolean empty; gint try_new_pos; g_assert(apps != NULL && app != NULL); try_new_pos = 0; empty = app_list_xy_empty(apps, app->x, app->y); while (!empty) { TRACE("dupplicate icon at x:%d, y:%d, " "change second icon position", app->x, app->y); app->x++; empty = app_list_xy_empty(apps, app->x, app->y); if (try_new_pos > 20) { WARN("whaou, try:%d > 20, it's big! icon:%s, cmdline:%s, x:%d, y:%d", try_new_pos, app->icon, app->cmdline, app->x, app->y); return -1; } try_new_pos++; } apps->apps = g_list_append(apps->apps, app); return 0; } // ---------------------------------------------------------------------------- int app_list_remove(app_list_t *apps, app_t *app) { GList *apps_new; gint len; g_assert(apps != NULL && app != NULL); TRACE("apps:%p, app:%p", apps, app); len = app_list_length(apps); apps_new = g_list_remove(apps->apps, app); if ((!apps_new) && (len !=1)) { WARN("app:%p introuvable dans apps:%p", app, apps); return -1; } apps->apps = apps_new; app_free(&app); return 0; } // ---------------------------------------------------------------------------- app_t *app_list_first(app_list_t *apps) { g_assert(apps != NULL); if (!apps->apps) return NULL; apps->hamster = g_list_first(apps->apps); return apps->hamster->data; } // ---------------------------------------------------------------------------- app_t *app_list_next(app_list_t *apps) { g_assert(apps != NULL); g_assert(apps->apps != NULL && apps->hamster != NULL); apps->hamster = g_list_next(apps->hamster); if (!apps->hamster) return NULL; return apps->hamster->data; } // ---------------------------------------------------------------------------- app_t *app_list_nth(app_list_t *apps, int nth) { g_assert(apps != NULL && apps->apps != NULL); apps->hamster = g_list_nth(apps->apps, nth); if (!apps->hamster) return NULL; return apps->hamster->data; } // ---------------------------------------------------------------------------- int app_list_length(app_list_t *apps) { g_assert(apps != NULL && apps->apps != NULL); return g_list_length(apps->apps); } // ---------------------------------------------------------------------------- void app_list_dump(app_list_t *apps) { app_t *app; g_assert(apps != NULL); app = app_list_first(apps); while(app) { g_print("app["); app_dump(app); g_print("]\n"); app = app_list_next(apps); } } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- gint app_list_delta_x(app_list_t *apps) { app_t *app; gint x_min; gint x_max; g_assert(apps != NULL && apps->apps != NULL); app = app_list_first(apps); x_min = app->x; x_max = app->x; app = app_list_next(apps); while(app) { if (x_max < app->x) x_max = app->x; if (x_min > app->x) x_min = app->x; app = app_list_next(apps); } return (x_max - x_min); } // ---------------------------------------------------------------------------- gint app_list_delta_y(app_list_t *apps) { app_t *app; gint y_min; gint y_max; g_assert(apps != NULL && apps->apps != NULL); app = app_list_first(apps); y_min = app->y; y_max = app->y; app = app_list_next(apps); while(app) { if (y_max < app->y) y_max = app->y; if (y_min > app->y) y_min = app->y; app = app_list_next(apps); } return (y_max - y_min); } // ---------------------------------------------------------------------------- int app_list_min_x(app_list_t *apps) { app_t *app; gint x_min; g_assert(apps != NULL && apps->apps != NULL); app = app_list_first(apps); x_min = app->x; app = app_list_next(apps); while(app) { if (x_min > app->x) x_min = app->x; app = app_list_next(apps); } return x_min; } // ---------------------------------------------------------------------------- int app_list_min_y(app_list_t *apps) { app_t *app; gint y_min; g_assert(apps != NULL && apps->apps != NULL); app = app_list_first(apps); y_min = app->y; app = app_list_next(apps); while(app) { if (y_min > app->y) y_min = app->y; app = app_list_next(apps); } return y_min; } // ---------------------------------------------------------------------------- int app_list_max_x(app_list_t *apps) { app_t *app; gint x_max; g_assert(apps != NULL && apps->apps != NULL); app = app_list_first(apps); x_max = app->x; app = app_list_next(apps); while(app) { if (x_max < app->x) x_max = app->x; app = app_list_next(apps); } return x_max; } // ---------------------------------------------------------------------------- int app_list_max_y(app_list_t *apps) { app_t *app; gint y_max; g_assert(apps != NULL && apps->apps != NULL); app = app_list_first(apps); y_max = app->y; app = app_list_next(apps); while(app) { if (y_max < app->y) y_max = app->y; app = app_list_next(apps); } return y_max; } // ---------------------------------------------------------------------------- app_t * app_list_at_xy(app_list_t *apps, gint x, gint y) { app_t *app; GList *hamster; g_assert(apps != NULL); hamster = g_list_first(apps->apps); while(hamster != NULL) { app = hamster->data; if ((app->x == x) && (app->y == y)) { return app; } hamster = g_list_next(hamster); } return NULL; } // ---------------------------------------------------------------------------- gboolean app_list_xy_empty(app_list_t *apps, gint x, gint y) { app_t *app; g_assert(apps != NULL); if (!apps->apps) return TRUE; app = app_list_at_xy(apps, x, y); if (app) return FALSE; return TRUE; } // ---------------------------------------------------------------------------- app_t * app_list_find_noname(app_list_t *apps) { app_t *app; GList *hamster; g_assert(apps != NULL); hamster = g_list_first(apps->apps); while(hamster != NULL) { app = hamster->data; if (!strcmp(app->cmdline, APP_NONAME_CMDLINE) && !strcmp(app->path, APP_NONAME_PATH) && !strcmp(app->icon, APP_NONAME_ICON)) return app; hamster = g_list_next(hamster); } return NULL; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/app.h0000644000175000017500000000673207776053665013275 0ustar pebpeb00000000000000/* app.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #ifndef APP__H #define APP__H #include "common.h" // ---------------------------------------------------------------------------- typedef struct app_t { gchar *cmdline; gchar *path; gchar *icon; gint x; gint y; } app_t; // ---------------------------------------------------------------------------- typedef struct app_list_t { GList *apps; GList *hamster; } app_list_t; #define TRACE_APP(app, format, args...) { g_assert(app != NULL); TRACE("[APP icon:%s, cmdline:%s, x:%d, y:%d]" format, app->icon, app->cmdline, app->x, app->y, ## args);} // ---------------------------------------------------------------------------- app_t * app_new(gchar *cmdline, gchar *path, gchar *icon, gint x, gint y); app_t * app_new_noname(gint x, gint y); void app_free(app_t **app); app_t * app_clone(app_t *app_orig); gboolean app_exec(app_t *app, gboolean exit_at_app_launch); void app_dump(app_t *app); void app_dumpln(app_t *app); gboolean app_is_executable(app_t *app); gboolean app_path_is_valid(app_t *app); gboolean app_icon_is_valid(app_t *app); const char* app_get_cmdline(app_t *app); void app_set_cmdline(app_t *app, const char *value); const char* app_get_path(app_t *app); void app_set_path(app_t *app, const char *value); const char* app_get_icon(app_t *app); void app_set_icon(app_t *app, const char *value); // ---------------------------------------------------------------------------- app_list_t * app_list_new(void); void app_list_free(app_list_t **apps); int app_list_add(app_list_t *apps, app_t *app); int app_list_remove(app_list_t *apps, app_t *app); app_t * app_list_first(app_list_t *apps); app_t * app_list_next(app_list_t *apps); app_t * app_list_nth(app_list_t *apps, int nth); int app_list_length(app_list_t *apps); void app_list_dump(app_list_t *apps); app_t * app_list_find_noname(app_list_t *apps); gint app_list_delta_x(app_list_t *apps); gint app_list_delta_y(app_list_t *apps); int app_list_min_x(app_list_t *apps); int app_list_min_y(app_list_t *apps); int app_list_max_x(app_list_t *apps); int app_list_max_y(app_list_t *apps); app_t * app_list_at_xy(app_list_t *apps, gint x, gint y); gboolean app_list_xy_empty(app_list_t *apps, gint x, gint y); #endif /*APP__H*/ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/apwalapp.c0000644000175000017500000007243210161363145014270 0ustar pebpeb00000000000000/* apwalapp.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include /* memset */ #include /* define FILENAME_MAX */ #include "common.h" #include static void apwalapp_build_interface(apwalapp_t *apwal); static void apwalapp_clicked_ok(GtkWidget *widget, apwalapp_t *apwal); static void apwalapp_clicked_cancel(GtkWidget *widget, apwalapp_t *apwal); static void apwalapp_w2_close_clicked(GtkWidget *widget, apwalapp_t *apwal); static void apwalapp_w2_apply_clicked(GtkWidget *widget, apwalapp_t *apwal); static void apwalapp_w2_cancel_clicked(GtkWidget *widget, apwalapp_t *apwal); static void apwalapp_w2_ok_clicked(GtkWidget *widget, apwalapp_t *apwal); static gboolean apwalapp_w2_delete(GtkWidget *widget, GdkEvent *event, apwalapp_t *apwal); static void apwalapp_switch_page(GtkWidget *widget, GtkNotebookPage *page, guint page_num, apwalapp_t *apwal); static void apwalapp_switch_page2(GtkWidget *widget, GtkNotebookPage *page, guint page_num, apwalapp_t *apwal); void apwal_load_apps(apwalapp_t *apwal, app_list_t *apps); //static gboolean apwalapp_window_key_release_event(GtkWidget *widget, // GdkEventKey *event, apwalapp_t *apwal); static void apwalapp_window_move_focus_event(GtkWindow *window, GtkDirectionType direction, apwalapp_t *apwal); // ---------------------------------------------------------------------------- apwalapp_t* apwalapp_new(void) { apwalapp_t *apwal; GdkGeometry hints; gint width, height; apwal = (apwalapp_t *)malloc(sizeof(apwalapp_t)); g_assert(apwal != NULL); memset(apwal, '\0', sizeof(apwalapp_t)); xmlrc_load_from_file(&apwal->apps, &apwal->iconsel_pref, &apwal->apwal_pref); apwal->selected_app = NULL; apwalapp_build_interface(apwal); // append objects to this interface apwal->splash = splash_new(apwal); apwal->prop = property_new(apwal); apwal->editor = editor_new(apwal); apwal->iconsel = icon_selection_new(apwal); apwal->filesel = filesel_new(); apwal_pref_build_interface(apwal); apwal->about = about_new(apwal); // window set size and show gtk_window_get_size(GTK_WINDOW(apwal->window), &width, &height); hints.base_width = width; hints.base_height = height; hints.min_width = width; hints.min_height = height; hints.max_width = width; hints.max_height = height; gtk_window_set_geometry_hints(GTK_WINDOW(apwal->window), apwal->window, &hints, GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_RESIZE_INC |GDK_HINT_BASE_SIZE); gtk_widget_show(apwal->window); // window2: set the min size to something useable gtk_window_get_size(GTK_WINDOW(apwal->window), &width, &height); hints.min_width = 400; hints.min_height = height; gtk_window_set_geometry_hints(GTK_WINDOW(apwal->window2), apwal->window2, &hints, GDK_HINT_MIN_SIZE ); if (apwal->apwal_pref->iconsel_in_a_separate_window == TRUE && apwal->apwal_pref->iconsel_modal == FALSE) gtk_widget_show(apwal->window2); icon_selection_load_icons_with_splash(apwal->iconsel); iconsel_refresh(apwal->iconsel); // ./!\.IMPORTANT./!\. // because of a problem with the scrolled window in iconsel.c // gtk_widget_show_all has to be called to show the scrolled window. gtk_widget_show_all(apwal->window); return apwal; } // ---------------------------------------------------------------------------- void apwalapp_selected_app_modified(apwalapp_t *apwal) { gint page; TRACE("%s", ""); g_assert(apwal != NULL); g_assert(apwal->prop != NULL && apwal->editor != NULL); g_assert(apwal->iconsel != NULL && apwal->iconsel_pref); //g_assert((apwal->apwal_pref->iconsel_a_separate_window) // && apwal->window2 == NULL); page = gtk_notebook_get_current_page(GTK_NOTEBOOK(apwal->notebook)); switch(page) { case 0: // editor & property editor_refresh(apwal->editor); property_refresh(apwal->prop); if (apwal->selected_app) iconsel_set_filename(apwal->iconsel, app_get_icon(apwal->selected_app)); else iconsel_set_filename(apwal->iconsel, NULL); iconsel_refresh_selected(apwal->iconsel); break; default: ERR("BUG: should not happend, call from page:%d", page); } /* // if icon selection window is showed and editor has focus // then refresh icon selection if (apwal->apwal_pref->iconsel_in_a_separate_window) { if (GTK_WIDGET_VISIBLE(apwal->window2) && GTK_WIDGET_HAS_FOCUS(gtk_window_get_focus(GTK_WINDOW(apwal->window2)))) { if (apwal->selected_app) iconsel_set_filename(apwal->iconsel, app_get_icon(apwal->selected_app)); else iconsel_set_filename(apwal->iconsel, NULL); iconsel_refresh(apwal->iconsel); } } */ } // ---------------------------------------------------------------------------- void apwalapp_selected_icon_modified(apwalapp_t *apwal) { gboolean refresh_iconsel; gboolean refresh_editor; const char *file; TRACE("%s", ""); g_assert(apwal != NULL); g_assert(apwal->prop != NULL && apwal->editor != NULL); g_assert(apwal->iconsel != NULL && apwal->iconsel_pref); refresh_iconsel = TRUE; refresh_editor = TRUE; /* refresh_iconsel = FALSE; refresh_editor = FALSE; if (apwal->apwal_pref->iconsel_in_a_separate_window == FALSE) { page = gtk_notebook_get_current_page(GTK_NOTEBOOK(apwal->notebook)); if (page == 1) { refresh_iconsel = TRUE; refresh_editor = TRUE; } } else { TRACE("window2 visible:%d, focus:%d", GTK_WIDGET_VISIBLE(apwal->window2), GTK_WIDGET_HAS_FOCUS(gtk_window_get_focus(GTK_WINDOW(apwal->window2)))); if (GTK_WIDGET_VISIBLE(apwal->window2) && GTK_WIDGET_HAS_FOCUS(gtk_window_get_focus(GTK_WINDOW(apwal->window2)))) { TRACE("%s", ""); page = gtk_notebook_get_current_page(GTK_NOTEBOOK(apwal->notebook2)); if (page == 0) { TRACE("%s", ""); refresh_iconsel = TRUE; refresh_editor = TRUE; } else ERR("page:%d is anormal. must be 0", page); } } */ if (refresh_iconsel == TRUE) { //refresh already done by iconsel, not needed: //iconsel_refresh(apwal->iconsel); } if (refresh_editor == TRUE) { if (apwal->selected_app != NULL) { file = iconsel_get_filename(apwal->iconsel); if (file != NULL) app_set_icon(apwal->selected_app, file); else app_set_icon(apwal->selected_app, ""); } editor_refresh(apwal->editor); property_refresh(apwal->prop); } } // ---------------------------------------------------------------------------- void apwalapp_goto_iconsel(apwalapp_t *apwal) { g_assert(apwal != NULL); if (apwal->apwal_pref->iconsel_in_a_separate_window == TRUE) { if (apwal->apwal_pref->iconsel_modal) { gtk_grab_add(apwal->window2); } gtk_widget_show(apwal->window2); gtk_notebook_set_current_page(GTK_NOTEBOOK(apwal->notebook2), 0); } else gtk_notebook_set_current_page(GTK_NOTEBOOK(apwal->notebook), 1); } // ---------------------------------------------------------------------------- void apwalapp_goto_editor(apwalapp_t *apwal) { g_assert(apwal != NULL); if (apwal->apwal_pref->iconsel_in_a_separate_window == TRUE) { if (apwal->apwal_pref->iconsel_modal) { gtk_widget_hide(apwal->window2); gtk_grab_remove(apwal->window2); } } gtk_notebook_set_current_page(GTK_NOTEBOOK(apwal->notebook), 0); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void apwal_load_apps(apwalapp_t *apwal, app_list_t *apps) { g_assert(apwal != NULL); if (apwal->apps != NULL) app_list_free(& apwal->apps); apwal->apps = apps; //if (apwal->apps != NULL) // app_list_dump(apwal->apps); } // ---------------------------------------------------------------------------- static void apwalapp_build_interface(apwalapp_t *apwal) { //GtkWidget *window; GtkWidget *vbox0; GtkWidget *vbox02; //GtkWidget *notebook; GtkWidget *editor_vbox, *editor_label; //GtkWidget *property_frame; //GtkWidget *editor_frame; GtkWidget *iconsel_vbox, *iconsel_label; //GtkWidget *iconsel_frame; GtkWidget *iconsel_pref_vbox, *iconsel_pref_label; //GtkWidget *iconsel_pref_frame; GtkWidget *apwal_pref_vbox, *apwal_pref_label; //GtkWidget *apwal_pref_frame; GtkWidget *about_vbox, *about_label; GtkWidget *btn_bbox; GtkWidget *btn_ok; GtkWidget *btn_cancel; GtkWidget *btn2_bbox; //GtkWidget *btn_help; g_assert(apwal != NULL); // window apwal->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(apwal->window),"Apwal - Editor"); g_signal_connect(G_OBJECT(apwal->window), "delete_event", gtk_main_quit, NULL); //g_signal_connect(G_OBJECT(apwal->window), "key_release_event", // G_CALLBACK(apwalapp_window_key_release_event), apwal); g_signal_connect(G_OBJECT(apwal->window), "move_focus", G_CALLBACK(apwalapp_window_move_focus_event), apwal); apwal->window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(apwal->window2),"Apwal - Icon Selection"); //gtk_widget_hide_on_delete(apwal->window2); g_signal_connect(G_OBJECT(apwal->window2), "delete_event", G_CALLBACK(apwalapp_w2_delete), apwal); apwal->tips = gtk_tooltips_new(); // vbox0 vbox0 = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox0), 4); gtk_container_add(GTK_CONTAINER(apwal->window), vbox0); gtk_widget_show(vbox0); // vbox02 vbox02 = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox02), 4); gtk_container_add(GTK_CONTAINER(apwal->window2), vbox02); gtk_widget_show(vbox02); // notebook apwal->notebook = gtk_notebook_new(); g_signal_connect(G_OBJECT(apwal->notebook), "switch-page", G_CALLBACK(apwalapp_switch_page), apwal); gtk_box_pack_start(GTK_BOX(vbox0), apwal->notebook, FALSE, FALSE, 0); gtk_widget_show(apwal->notebook); // notebook2 apwal->notebook2 = gtk_notebook_new(); g_signal_connect(G_OBJECT(apwal->notebook2), "switch-page", G_CALLBACK(apwalapp_switch_page2), apwal); gtk_box_pack_start(GTK_BOX(vbox02), apwal->notebook2, TRUE, TRUE, 0); gtk_widget_show(apwal->notebook2); // editor_label editor_label = gtk_label_new("Editor"); gtk_widget_show(editor_label); // editor_vbox editor_vbox = gtk_vbox_new(FALSE, 0); gtk_widget_show(editor_vbox); gtk_notebook_append_page(GTK_NOTEBOOK(apwal->notebook), editor_vbox, editor_label); // property_frame apwal->property_frame = gtk_frame_new(" Application Property "); gtk_container_set_border_width(GTK_CONTAINER(apwal->property_frame), 4); gtk_box_pack_start(GTK_BOX(editor_vbox), apwal->property_frame, FALSE, FALSE, 0); gtk_widget_show(apwal->property_frame); // editor_frame apwal->editor_frame = gtk_frame_new(NULL); //" Editor "); gtk_container_set_border_width(GTK_CONTAINER(apwal->editor_frame), 4); gtk_frame_set_shadow_type(GTK_FRAME(apwal->editor_frame), GTK_SHADOW_NONE); gtk_box_pack_start(GTK_BOX(editor_vbox), apwal->editor_frame, FALSE, FALSE, 0); gtk_widget_show(apwal->editor_frame); // iconsel_label iconsel_label = gtk_label_new("Icon Selection"); gtk_widget_show(iconsel_label); // iconsel_vbox iconsel_vbox = gtk_vbox_new(FALSE, 0); gtk_widget_show(iconsel_vbox); if (apwal->apwal_pref->iconsel_in_a_separate_window == FALSE) gtk_notebook_append_page(GTK_NOTEBOOK(apwal->notebook), iconsel_vbox, iconsel_label); else gtk_notebook_append_page(GTK_NOTEBOOK(apwal->notebook2), iconsel_vbox, iconsel_label); // iconsel_frame apwal->iconsel_frame = gtk_frame_new(NULL); gtk_container_set_border_width(GTK_CONTAINER(apwal->iconsel_frame), 4); gtk_frame_set_shadow_type(GTK_FRAME(apwal->iconsel_frame), GTK_SHADOW_NONE); gtk_box_pack_start(GTK_BOX(iconsel_vbox), apwal->iconsel_frame, TRUE, TRUE, 0); gtk_widget_show(apwal->iconsel_frame); // iconsel_pref_label iconsel_pref_label = gtk_label_new("Icon Selection Pref"); gtk_widget_show(iconsel_pref_label); // iconsel_pref_vbox iconsel_pref_vbox = gtk_vbox_new(FALSE, 0); gtk_widget_show(iconsel_pref_vbox); if (apwal->apwal_pref->iconsel_in_a_separate_window == FALSE) gtk_notebook_append_page(GTK_NOTEBOOK(apwal->notebook), iconsel_pref_vbox, iconsel_pref_label); else gtk_notebook_append_page(GTK_NOTEBOOK(apwal->notebook2), iconsel_pref_vbox, iconsel_pref_label); // iconsel_frame apwal->iconsel_pref_frame = gtk_frame_new(NULL); gtk_container_set_border_width(GTK_CONTAINER(apwal->iconsel_pref_frame), 4); gtk_frame_set_shadow_type(GTK_FRAME(apwal->iconsel_pref_frame), GTK_SHADOW_NONE); gtk_box_pack_start(GTK_BOX(iconsel_pref_vbox), apwal->iconsel_pref_frame, TRUE, TRUE, 0); gtk_widget_show(apwal->iconsel_pref_frame); // apwal_pref_label apwal_pref_label = gtk_label_new("Apwal Preference"); gtk_widget_show(apwal_pref_label); // apwal_pref_vbox apwal_pref_vbox = gtk_vbox_new(FALSE, 0); gtk_widget_show(apwal_pref_vbox); gtk_notebook_append_page(GTK_NOTEBOOK(apwal->notebook), apwal_pref_vbox, apwal_pref_label); // apwal_pref_frame apwal->apwal_pref_frame = gtk_frame_new(NULL); gtk_container_set_border_width(GTK_CONTAINER(apwal->apwal_pref_frame), 4); gtk_frame_set_shadow_type(GTK_FRAME(apwal->apwal_pref_frame), GTK_SHADOW_NONE); gtk_box_pack_start(GTK_BOX(apwal_pref_vbox), apwal->apwal_pref_frame, TRUE, TRUE, 0); gtk_widget_show(apwal->apwal_pref_frame); // about_label about_label = gtk_label_new("About"); gtk_widget_show(about_label); // about_vbox about_vbox = gtk_vbox_new(FALSE, 0); gtk_widget_show(about_vbox); gtk_notebook_append_page(GTK_NOTEBOOK(apwal->notebook), about_vbox, about_label); // about_frame apwal->about_frame = gtk_frame_new(NULL); gtk_container_set_border_width(GTK_CONTAINER(apwal->about_frame), 4); gtk_frame_set_shadow_type(GTK_FRAME(apwal->about_frame), GTK_SHADOW_NONE); gtk_box_pack_start(GTK_BOX(about_vbox), apwal->about_frame, TRUE, TRUE, 0); gtk_widget_show(apwal->about_frame); // -------- // horizontal button box 'ok' & 'cancel' & 'help' btn_bbox = gtk_hbutton_box_new(); gtk_button_box_set_layout(GTK_BUTTON_BOX(btn_bbox), GTK_BUTTONBOX_END); gtk_box_set_spacing(GTK_BOX(btn_bbox), 10); gtk_container_set_border_width(GTK_CONTAINER(btn_bbox), 4); gtk_box_pack_end(GTK_BOX(vbox0), btn_bbox, FALSE, FALSE, 0); gtk_widget_show(btn_bbox); // button cancel btn_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); GTK_WIDGET_SET_FLAGS(btn_cancel, GTK_CAN_DEFAULT); g_signal_connect(G_OBJECT(btn_cancel), "clicked", G_CALLBACK(apwalapp_clicked_cancel), apwal); gtk_box_pack_end(GTK_BOX(btn_bbox), btn_cancel, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS(btn_cancel, GTK_CAN_DEFAULT); gtk_widget_grab_default(btn_cancel); gtk_widget_show(btn_cancel); // button ok btn_ok = gtk_button_new_from_stock(GTK_STOCK_OK); GTK_WIDGET_SET_FLAGS(btn_ok, GTK_CAN_DEFAULT); g_signal_connect(G_OBJECT(btn_ok), "clicked", G_CALLBACK(apwalapp_clicked_ok), apwal); gtk_box_pack_end(GTK_BOX(btn_bbox), btn_ok, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS(btn_ok, GTK_CAN_DEFAULT); gtk_widget_grab_default(btn_ok); gtk_widget_show(btn_ok); // window 2 horizontal button box 'apply' 'close' / 'cancel' 'ok' btn2_bbox = gtk_hbutton_box_new(); gtk_button_box_set_layout(GTK_BUTTON_BOX(btn2_bbox), GTK_BUTTONBOX_END); gtk_box_set_spacing(GTK_BOX(btn2_bbox), 10); gtk_container_set_border_width(GTK_CONTAINER(btn2_bbox), 4); gtk_box_pack_end(GTK_BOX(vbox02), btn2_bbox, FALSE, FALSE, 0); gtk_widget_show(btn2_bbox); // button apply apwal->w2_btn_apply = gtk_button_new_from_stock(GTK_STOCK_APPLY); GTK_WIDGET_SET_FLAGS(apwal->w2_btn_apply, GTK_CAN_DEFAULT); g_signal_connect(G_OBJECT(apwal->w2_btn_apply), "clicked", G_CALLBACK(apwalapp_w2_apply_clicked), apwal); gtk_box_pack_end(GTK_BOX(btn2_bbox), apwal->w2_btn_apply, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS(apwal->w2_btn_apply, GTK_CAN_DEFAULT); gtk_widget_grab_default(apwal->w2_btn_apply); if (apwal->apwal_pref->iconsel_modal == FALSE) gtk_widget_show(apwal->w2_btn_apply); gtk_widget_show(apwal->w2_btn_apply); // button close apwal->w2_btn_close = gtk_button_new_from_stock(GTK_STOCK_CLOSE); GTK_WIDGET_SET_FLAGS(apwal->w2_btn_close, GTK_CAN_DEFAULT); g_signal_connect(G_OBJECT(apwal->w2_btn_close), "clicked", G_CALLBACK(apwalapp_w2_close_clicked), apwal); gtk_box_pack_end(GTK_BOX(btn2_bbox), apwal->w2_btn_close, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS(apwal->w2_btn_close, GTK_CAN_DEFAULT); gtk_widget_grab_default(apwal->w2_btn_close); if (apwal->apwal_pref->iconsel_modal == FALSE) gtk_widget_show(apwal->w2_btn_close); gtk_widget_show(apwal->w2_btn_close); // button cancel apwal->w2_btn_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); GTK_WIDGET_SET_FLAGS(apwal->w2_btn_cancel, GTK_CAN_DEFAULT); g_signal_connect(G_OBJECT(apwal->w2_btn_cancel), "clicked", G_CALLBACK(apwalapp_w2_cancel_clicked), apwal); gtk_box_pack_end(GTK_BOX(btn2_bbox), apwal->w2_btn_cancel, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS(apwal->w2_btn_cancel, GTK_CAN_DEFAULT); gtk_widget_grab_default(apwal->w2_btn_cancel); if (apwal->apwal_pref->iconsel_modal == TRUE) gtk_widget_show(apwal->w2_btn_cancel); gtk_widget_show(apwal->w2_btn_cancel); // button OK apwal->w2_btn_ok = gtk_button_new_from_stock(GTK_STOCK_OK); GTK_WIDGET_SET_FLAGS(apwal->w2_btn_ok, GTK_CAN_DEFAULT); g_signal_connect(G_OBJECT(apwal->w2_btn_ok), "clicked", G_CALLBACK(apwalapp_w2_ok_clicked), apwal); gtk_box_pack_end(GTK_BOX(btn2_bbox), apwal->w2_btn_ok, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS(apwal->w2_btn_ok, GTK_CAN_DEFAULT); gtk_widget_grab_default(apwal->w2_btn_ok); if (apwal->apwal_pref->iconsel_modal == TRUE) gtk_widget_show(apwal->w2_btn_ok); gtk_widget_show(apwal->w2_btn_ok); // gtk_widget_show window at the end of apwalapp_new() } // ---------------------------------------------------------------------------- static void apwalapp_switch_page(GtkWidget *widget, GtkNotebookPage *page, guint page_num, apwalapp_t *apwal) { g_assert(apwal != NULL && page != NULL && widget != NULL); TRACE("%s", "notebook apwalapp_switch_page"); } // ---------------------------------------------------------------------------- static void apwalapp_switch_page2(GtkWidget *widget, GtkNotebookPage *page, guint page_num, apwalapp_t *apwal) { g_assert(apwal != NULL && page != NULL && widget != NULL); TRACE("%s", "notebook2 apwalapp_switch_page2"); } // ---------------------------------------------------------------------------- static void apwalapp_clicked_ok(GtkWidget *widget, apwalapp_t *apwal) { g_assert(apwal != NULL); TRACE("%s", "save and exit program..."); xmlrc_save_to_file(apwal->apps, apwal->iconsel_pref, apwal->apwal_pref); gtk_main_quit(); } // ---------------------------------------------------------------------------- static void apwalapp_clicked_cancel(GtkWidget *widget, apwalapp_t *apwal) { g_assert(apwal != NULL); TRACE("%s", "exit program without saving..."); gtk_main_quit(); } // ---------------------------------------------------------------------------- static void apwalapp_w2_close_clicked(GtkWidget *widget, apwalapp_t *apwal) { g_assert(apwal != NULL); TRACE("%s", "w2 close"); gtk_widget_hide(apwal->window2); if (apwal->apwal_pref->iconsel_modal) gtk_grab_remove(apwal->window2); } // ---------------------------------------------------------------------------- static void apwalapp_w2_apply_clicked(GtkWidget *widget, apwalapp_t *apwal) { g_assert(apwal != NULL); TRACE("%s", "w2 apply"); // if no icon selected, nothing to do if (icon_list_get_selected_icon(apwal->iconsel->icons) == NULL) return; // if no application selected selected, nothing to do if (apwal->selected_app == NULL) return; apwalapp_selected_icon_modified(apwal); apwalapp_goto_editor(apwal); } // ---------------------------------------------------------------------------- static void apwalapp_w2_cancel_clicked(GtkWidget *widget, apwalapp_t *apwal) { g_assert(apwal != NULL); TRACE("%s", "w2 cancel"); gtk_widget_hide(apwal->window2); if (apwal->apwal_pref->iconsel_modal) gtk_grab_remove(apwal->window2); } // ---------------------------------------------------------------------------- static void apwalapp_w2_ok_clicked(GtkWidget *widget, apwalapp_t *apwal) { g_assert(apwal != NULL); TRACE("%s", "w2 OK"); // if no icon selected, nothing to do if (icon_list_get_selected_icon(apwal->iconsel->icons) == NULL) return; // if no application selected selected, nothing to do if (apwal->selected_app == NULL) return; apwalapp_selected_icon_modified(apwal); gtk_widget_hide(apwal->window2); if (apwal->apwal_pref->iconsel_modal) gtk_grab_remove(apwal->window2); } // ---------------------------------------------------------------------------- static gboolean apwalapp_w2_delete(GtkWidget *widget, GdkEvent *event, apwalapp_t *apwal) { g_assert(apwal != NULL); TRACE("%s", "delete w2"); gtk_widget_hide(apwal->window2); if (apwal->apwal_pref->iconsel_modal) gtk_grab_remove(apwal->window2); return TRUE; // do NOT propagate the event } // ---------------------------------------------------------------------------- void gtk_notebook_move_page(GtkNotebook *src, gint src_num, GtkNotebook *dst, gint dst_num); // ---------------------------------------------------------------------------- void apwal_iconsel_win2tab(apwalapp_t *apwal) { g_assert(apwal != NULL); TRACE("%s", ""); if (GTK_WIDGET_VISIBLE(apwal->window2)) gtk_widget_hide(apwal->window2); // don't be worried about the modal state because if the window2 is modal // and showed then it is impossible to modify apwal preferences... hop :p gtk_widget_hide(apwal->window2); gtk_widget_show(apwal->iconsel->selected_apply_btn); gtk_notebook_move_page(GTK_NOTEBOOK(apwal->notebook2), 0, GTK_NOTEBOOK(apwal->notebook), 1); gtk_notebook_move_page(GTK_NOTEBOOK(apwal->notebook2), 0, GTK_NOTEBOOK(apwal->notebook), 2); } // ---------------------------------------------------------------------------- void apwal_iconsel_tab2win(apwalapp_t *apwal) { g_assert(apwal != NULL); TRACE("%s", ""); gtk_notebook_move_page(GTK_NOTEBOOK(apwal->notebook), 1, GTK_NOTEBOOK(apwal->notebook2), -1); gtk_notebook_move_page(GTK_NOTEBOOK(apwal->notebook), 1, GTK_NOTEBOOK(apwal->notebook2), -1); gtk_widget_hide(apwal->iconsel->selected_apply_btn); // if non modal mode, then show the w2 if (apwal->apwal_pref->iconsel_modal == FALSE && ! GTK_WIDGET_VISIBLE(apwal->window2)) gtk_widget_show(apwal->window2); } // ---------------------------------------------------------------------------- void apwal_iconsel_set_modal(apwalapp_t *apwal) { g_assert(apwal != NULL); TRACE("%s", ""); // if the iconsel is showed and modal is selected, the when hide the // iconsel window (because it can't be in modal mode and the grab_remove // when the user close this window has not to be called as well). if (GTK_WIDGET_VISIBLE(apwal->window2)) gtk_widget_hide(apwal->window2); gtk_widget_hide(apwal->w2_btn_apply); gtk_widget_hide(apwal->w2_btn_close); gtk_widget_show(apwal->w2_btn_cancel); gtk_widget_show(apwal->w2_btn_ok); } // ---------------------------------------------------------------------------- void apwal_iconsel_set_not_modal(apwalapp_t *apwal) { gtk_widget_show(apwal->w2_btn_apply); gtk_widget_show(apwal->w2_btn_close); gtk_widget_hide(apwal->w2_btn_cancel); gtk_widget_hide(apwal->w2_btn_ok); // if we are asked to switch to non modal mode, then show the w2 if (! GTK_WIDGET_VISIBLE(apwal->window2)) gtk_widget_show(apwal->window2); } // ---------------------------------------------------------------------------- void gtk_notebook_move_page(GtkNotebook *src, gint src_num, GtkNotebook *dst, gint dst_num) { GtkWidget *frame; GtkWidget *label; TRACE("%s", ""); frame = gtk_notebook_get_nth_page(src, src_num); if (frame == NULL) ERR("gtk_notebook_get_nth_page(%p, %d) == NULL", src, src_num); label = gtk_notebook_get_tab_label(src, frame); if (label == NULL) ERR("gtk_notebook_get_tab_label(%p, %p) == NULL", src, frame); g_object_ref(frame); g_object_ref(label); gtk_notebook_remove_page(src, src_num); gtk_notebook_insert_page(dst, frame, label, dst_num); g_object_unref(frame); g_object_unref(label); } // ---------------------------------------------------------------------------- #if 0 static gboolean apwalapp_window_key_release_event(GtkWidget *widget, GdkEventKey *event, apwalapp_t *apwal) { int cc; int page; g_assert(event != NULL && apwal != NULL); g_assert(apwal->editor != NULL); TRACE("key:%d ", event->keyval); // key binding only activated on the editor tab, if not, exit! page = gtk_notebook_get_current_page(GTK_NOTEBOOK(apwal->notebook)); if (page != 0) return FALSE; // FALSE: propagate the event further // see gdk/gdkkeysyms.h for the GDK key codes if ((event->state & gtk_accelerator_get_default_mod_mask ()) == 0) { switch(event->keyval) { case GDK_Delete: case GDK_KP_Delete: if (apwal->selected_app != NULL) { cc = app_list_remove(apwal->apps, apwal->selected_app); if (cc) ERR("%s", "ask to remove the selected app and not possible"); apwal->selected_app = NULL; apwalapp_selected_app_modified(apwal); } break; #if 0 /*do it if find a real interest in doing it*/ case GDK_KP_Space: case GDK_space: case GDK_Return: // NOT catcht because of key binding! case GDK_KP_Enter: // NOT catcht because of key binding! if (apwal->selected_app != NULL) apwalapp_goto_iconsel(apwal); break; case GDK_Left: case GDK_KP_Left: if (apwal->selected_app != NULL) editor_goto(apwal->editor, apwal->selected_app->x-1, apwal->selected_app->y); break; case GDK_Up: case GDK_KP_Up: if (apwal->selected_app != NULL) editor_goto(apwal->editor, apwal->selected_app->x, apwal->selected_app->y-1); break; case GDK_Right: case GDK_KP_Right: if (apwal->selected_app != NULL) editor_goto(apwal->editor, apwal->selected_app->x+1, apwal->selected_app->y); break; case GDK_Down: case GDK_KP_Down: if (apwal->selected_app != NULL) editor_goto(apwal->editor, apwal->selected_app->x, apwal->selected_app->y+1); break; #endif default: return FALSE; // FALSE: propagate the event further } } g_signal_stop_emission_by_name (GTK_OBJECT(widget), "key_release_event"); return TRUE; // TRUE: do not propagate the event further } #endif // ---------------------------------------------------------------------------- static void apwalapp_window_move_focus_event(GtkWindow *window, GtkDirectionType direction, apwalapp_t *apwal) { g_signal_stop_emission_by_name(GTK_OBJECT(window), "move_focus"); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/apwalapp.h0000644000175000017500000000564710003707562014301 0ustar pebpeb00000000000000/* apwalapp.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #ifndef APWALAPP__H #define APWALAPP__H #include "common.h" // ---------------------------------------------------------------------------- typedef struct apwalapp_t { GtkWidget *window; GtkWidget *notebook; // *page 'Editor' GtkWidget *property_frame; GtkWidget *editor_frame; // *page 'Icon selection' GtkWidget *iconsel_frame; // *page 'Icon selection preference' GtkWidget *iconsel_pref_frame; // *page 'About Apwal' GtkWidget *apwal_pref_frame; GtkWidget *about_frame; GtkWidget *window2; GtkWidget *notebook2; // *page 'Icon selection' // *page 'Icon selection preference' GtkWidget *w2_btn_apply; GtkWidget *w2_btn_close; GtkWidget *w2_btn_cancel; GtkWidget *w2_btn_ok; GtkTooltips *tips; struct apwal_pref_t *apwal_pref; struct editor_t *editor; struct property_t *prop; struct icon_selection_t *iconsel; struct iconsel_pref_t *iconsel_pref; struct filesel_t *filesel; struct about_t *about; struct splash_t *splash; struct app_list_t *apps; // list of apps struct app_t *selected_app; // app currently selected } apwalapp_t; // ---------------------------------------------------------------------------- apwalapp_t *apwalapp_new(void); void apwalapp_selected_app_modified(apwalapp_t *apwal); void apwalapp_selected_icon_modified(apwalapp_t *apwal); void apwalapp_goto_iconsel(apwalapp_t *apwal); void apwalapp_goto_editor(apwalapp_t *apwal); void apwal_iconsel_win2tab(apwalapp_t *apwal); void apwal_iconsel_tab2win(apwalapp_t *apwal); void apwal_iconsel_set_modal(apwalapp_t *apwal); void apwal_iconsel_set_not_modal(apwalapp_t *apwal); #endif /*APWALAPP__H*/ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/apwalpref.c0000644000175000017500000003052110004060533014424 0ustar pebpeb00000000000000/* apwalpref.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #include "common.h" static void apwal_pref_timeout_changed(GtkSpinButton *spin, apwalapp_t *apwal); static void apwal_pref_exit_at_app_launch_toggled(GtkToggleButton *chk, apwalapp_t *apwal); static void apwal_pref_tooltips_toggled(GtkToggleButton *chk, apwalapp_t *apwal); static void apwal_pref_iconsel_in_a_sepwin_toggled(GtkToggleButton *chk, apwalapp_t *apwal); static void apwal_pref_iconsel_modal_toggled(GtkToggleButton *chk, apwalapp_t *apwal); // ---------------------------------------------------------------------------- apwal_pref_t * apwal_pref_new(gint timeout, gboolean exit_at_app_launch, gboolean activate_tooltips, gboolean iconsel_in_a_separate_window, gboolean iconsel_modal) { apwal_pref_t *apwal_pref; TRACE("%s", ""); apwal_pref = (apwal_pref_t *) malloc(sizeof(apwal_pref_t)); g_assert(apwal_pref != NULL); apwal_pref->timeout = timeout; apwal_pref->exit_at_app_launch = exit_at_app_launch; apwal_pref->activate_tooltips = activate_tooltips; apwal_pref->iconsel_in_a_separate_window = iconsel_in_a_separate_window; apwal_pref->iconsel_modal = iconsel_modal; apwal_pref->iconsel_modal_chk = NULL; return apwal_pref; } // ---------------------------------------------------------------------------- apwal_pref_t * apwal_pref_new_default(void) { TRACE("%s", ""); return apwal_pref_new(1000, FALSE, TRUE, TRUE, FALSE); } // ---------------------------------------------------------------------------- void apwal_pref_build_interface(apwalapp_t *apwal) { GtkWidget *vbox; GtkWidget *launcher_frame; GtkWidget *launcher_vbox; GtkWidget *timeout_hbox; GtkWidget *timeout_event; GtkWidget *timeout_label; GtkWidget *timeout_spin; GtkWidget *exit_at_app_launch_chk; GtkWidget *editor_frame; GtkWidget *editor_vbox; GtkWidget *tooltips_chk; GtkWidget *iconsel_in_a_sepwin_chk; //GtkWidget *iconsel_modal_chk; gdouble timeout; g_assert(apwal != NULL); g_assert(apwal->apwal_pref != NULL && apwal->apwal_pref_frame != NULL && apwal->tips != NULL); TRACE("%s", ""); vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); gtk_container_add(GTK_CONTAINER(apwal->apwal_pref_frame), vbox); gtk_widget_show(vbox); // launcher frame launcher_frame = gtk_frame_new(" Launcher Preferences "); gtk_container_set_border_width(GTK_CONTAINER(launcher_frame), 4); gtk_box_pack_start(GTK_BOX(vbox), launcher_frame, FALSE, FALSE, 0); gtk_widget_show(launcher_frame); // launcher vbox launcher_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(launcher_vbox), 4); gtk_box_set_spacing(GTK_BOX(launcher_vbox), 4); gtk_container_add(GTK_CONTAINER(launcher_frame), launcher_vbox); gtk_widget_show(launcher_vbox); // timeout hbox timeout_hbox = gtk_hbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(timeout_hbox), 4); gtk_box_set_spacing(GTK_BOX(timeout_hbox), 4); gtk_container_add(GTK_CONTAINER(launcher_vbox), timeout_hbox); gtk_widget_show(timeout_hbox); // timeout event box timeout_event = gtk_event_box_new(); gtk_box_pack_start(GTK_BOX(timeout_hbox), timeout_event, FALSE, FALSE, 0); gtk_widget_show(timeout_event); gtk_tooltips_set_tip(apwal->tips, timeout_event, "Period of time during which the Apwal Launcher will still be displayed if not focused", NULL); // timeout label timeout_label = gtk_label_new("Launcher Timout (in second)"); gtk_container_add(GTK_CONTAINER(timeout_event), timeout_label); gtk_widget_show(timeout_label); // timeout spin button timeout_spin = gtk_spin_button_new_with_range(0.0, 10.0, 0.1); g_signal_connect(G_OBJECT(timeout_spin), "value-changed", G_CALLBACK(apwal_pref_timeout_changed), apwal); gtk_box_pack_start(GTK_BOX(timeout_hbox), timeout_spin, FALSE, FALSE, 0); gtk_widget_show(timeout_spin); timeout = ((double)(apwal->apwal_pref->timeout / 100))/10; TRACE("apwal_pref->timeout:%d, timeout:%f", apwal->apwal_pref->timeout, timeout); gtk_spin_button_set_value(GTK_SPIN_BUTTON(timeout_spin), timeout); // exit_at_app_launch exit_at_app_launch_chk = gtk_check_button_new_with_label( "Exit Apwal when an application is clicked"); gtk_box_pack_start(GTK_BOX(launcher_vbox), exit_at_app_launch_chk, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(exit_at_app_launch_chk), "toggled", G_CALLBACK(apwal_pref_exit_at_app_launch_toggled), apwal); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(exit_at_app_launch_chk), apwal->apwal_pref->exit_at_app_launch); gtk_widget_show(exit_at_app_launch_chk); gtk_tooltips_set_tip(apwal->tips, exit_at_app_launch_chk, "When you launch an application from the Apwal Launcher you can either prefer that Apwal hides itself immediatly or not", NULL); // iconsel_modal // editor frame editor_frame = gtk_frame_new(" Editor Preferences "); gtk_container_set_border_width(GTK_CONTAINER(editor_frame), 4); gtk_box_pack_start(GTK_BOX(vbox), editor_frame, FALSE, FALSE, 0); gtk_widget_show(editor_frame); // editor vbox editor_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(editor_vbox), 4); gtk_box_set_spacing(GTK_BOX(editor_vbox), 4); gtk_container_add(GTK_CONTAINER(editor_frame), editor_vbox); gtk_widget_show(editor_vbox); // tooltips tooltips_chk = gtk_check_button_new_with_label("Activate Tooltips"); gtk_box_pack_start(GTK_BOX(editor_vbox), tooltips_chk, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(tooltips_chk), "toggled", G_CALLBACK(apwal_pref_tooltips_toggled), apwal); gtk_widget_show(tooltips_chk); gtk_tooltips_set_tip(apwal->tips, tooltips_chk, "Activate or not the contextual information boxes like the one you are currently reading", NULL); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tooltips_chk), apwal->apwal_pref->activate_tooltips); if (apwal->apwal_pref->activate_tooltips == TRUE) gtk_tooltips_enable(apwal->tips); else gtk_tooltips_disable(apwal->tips); //iconsel_in_a_separate_window iconsel_in_a_sepwin_chk = gtk_check_button_new_with_label( "Icon Selection in a separate window"); gtk_box_pack_start(GTK_BOX(editor_vbox), iconsel_in_a_sepwin_chk, FALSE, FALSE, 0); // g_connect after iconsel_modal gtk_widget_show(iconsel_in_a_sepwin_chk); gtk_tooltips_set_tip(apwal->tips, iconsel_in_a_sepwin_chk, "The 'Icon Selection' and the 'Icon Selection Preference' tabs could be either showed in tabs in the main window or in a separate window", NULL); // iconsel_modal apwal->apwal_pref->iconsel_modal_chk = gtk_check_button_new_with_label( "Icon Selection Modal"); gtk_box_pack_start(GTK_BOX(editor_vbox), apwal->apwal_pref->iconsel_modal_chk, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(apwal->apwal_pref->iconsel_modal_chk), "toggled", G_CALLBACK(apwal_pref_iconsel_modal_toggled), apwal); gtk_widget_show(apwal->apwal_pref->iconsel_modal_chk); gtk_tooltips_set_tip(apwal->tips, apwal->apwal_pref->iconsel_modal_chk, "If the 'Icon Selection' and the 'Icon Selection Preference' tabs are in a separate window, this separate window could either be modal or not.\nNote: Modal implies that you have to answer and close the Icon Selection Dialog Box in order to access again the main window", NULL); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( apwal->apwal_pref->iconsel_modal_chk), apwal->apwal_pref->iconsel_modal); gtk_widget_set_sensitive(apwal->apwal_pref->iconsel_modal_chk, apwal->apwal_pref->iconsel_in_a_separate_window); // iconsel_in_a_separate_window // have to do that AFTER the creation of iconsel_modal_chk because // apwal_pref_iconsel_in_a_sepwin_toggled motify the enable status of it g_signal_connect(G_OBJECT(iconsel_in_a_sepwin_chk), "toggled", G_CALLBACK(apwal_pref_iconsel_in_a_sepwin_toggled), apwal); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(iconsel_in_a_sepwin_chk), apwal->apwal_pref->iconsel_in_a_separate_window); } // ---------------------------------------------------------------------------- static void apwal_pref_exit_at_app_launch_toggled(GtkToggleButton *chk, apwalapp_t *apwal) { g_assert(chk != NULL && apwal != NULL); g_assert(apwal->apwal_pref != NULL); TRACE("%s", ""); apwal->apwal_pref->exit_at_app_launch = gtk_toggle_button_get_active(chk); } static void apwal_pref_tooltips_toggled(GtkToggleButton *chk, apwalapp_t *apwal) { g_assert(chk != NULL && apwal != NULL); g_assert(apwal->apwal_pref != NULL); TRACE("%s", ""); apwal->apwal_pref->activate_tooltips = gtk_toggle_button_get_active(chk); if (apwal->apwal_pref->activate_tooltips == TRUE) gtk_tooltips_enable(apwal->tips); else gtk_tooltips_disable(apwal->tips); } // ---------------------------------------------------------------------------- static void apwal_pref_iconsel_in_a_sepwin_toggled(GtkToggleButton *chk, apwalapp_t *apwal) { gboolean last_state; g_assert(chk != NULL && apwal != NULL); g_assert(apwal->apwal_pref != NULL); TRACE("%s", ""); last_state = apwal->apwal_pref->iconsel_in_a_separate_window; apwal->apwal_pref->iconsel_in_a_separate_window = gtk_toggle_button_get_active(chk); gtk_widget_set_sensitive(apwal->apwal_pref->iconsel_modal_chk, apwal->apwal_pref->iconsel_in_a_separate_window); // last_state == apwal->apwal_pref->iconsel_in_a_separate_window while // building the graphical interface if (last_state != apwal->apwal_pref->iconsel_in_a_separate_window) { // dynamic set if (apwal->apwal_pref->iconsel_in_a_separate_window) apwal_iconsel_tab2win(apwal); else apwal_iconsel_win2tab(apwal); } } // ---------------------------------------------------------------------------- static void apwal_pref_iconsel_modal_toggled(GtkToggleButton *chk, apwalapp_t *apwal) { g_assert(chk != NULL && apwal != NULL); g_assert(apwal->apwal_pref != NULL); TRACE("%s", ""); apwal->apwal_pref->iconsel_modal = gtk_toggle_button_get_active(chk); if (apwal->apwal_pref->iconsel_modal == TRUE) apwal_iconsel_set_modal(apwal); else apwal_iconsel_set_not_modal(apwal); } // ---------------------------------------------------------------------------- static void apwal_pref_timeout_changed(GtkSpinButton *spin, apwalapp_t *apwal) { g_assert(spin != NULL && apwal != NULL); g_assert(apwal->apwal_pref != NULL); TRACE("%s", ""); apwal->apwal_pref->timeout = (int)(gtk_spin_button_get_value(spin) * 1000.00); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/apwalpref.h0000644000175000017500000000401707775104113014450 0ustar pebpeb00000000000000/* apwalpref.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #ifndef APWALPREF__H #define APWALPREF__H #include "common.h" // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- typedef struct apwal_pref_t { gint timeout; gboolean exit_at_app_launch; gboolean activate_tooltips; gboolean iconsel_in_a_separate_window; gboolean iconsel_modal; GtkWidget *iconsel_modal_chk; } apwal_pref_t; apwal_pref_t * apwal_pref_new(gint timeout, gboolean exit_at_app_launch, gboolean activate_tooltips, gboolean iconsel_in_a_separate_window, gboolean iconsel_modal); apwal_pref_t * apwal_pref_new_default(void); // ---------------------------------------------------------------------------- void apwal_pref_build_interface(struct apwalapp_t *apwal); #endif /*APWALPREF__H*/ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/cereimg.c0000644000175000017500000004727510160137276014110 0ustar pebpeb00000000000000/* cereimg.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* cereimg.c * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include "cereimg.h" //#include "gtkintl.h" //#include "log.h" static void cereimg_get_property (GObject *object, guint param_id, GValue *value, GParamSpec *pspec); static void cereimg_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec); static void cereimg_init (Cereimg *celltext); static void cereimg_class_init (CereimgClass *class); static void cereimg_finalize (GObject *object); static void cereimg_create_stock_pixbuf (Cereimg *cellimg, GtkWidget *widget); static void cereimg_get_size (GtkCellRenderer *cell, GtkWidget *widget, GdkRectangle *rectangle, gint *x_offset, gint *y_offset, gint *width, gint *height); static void cereimg_render (GtkCellRenderer *cell, GdkWindow *window, GtkWidget *widget, GdkRectangle *background_area, GdkRectangle *cell_area, GdkRectangle *expose_area, GtkCellRendererState flags); static gint cereimg_activate (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, GdkRectangle *background_area, GdkRectangle *cell_area, GtkCellRendererState flags); enum { PROP_ZERO, PROP_PIXBUF, PROP_PIXBUF_EXPANDER_OPEN, PROP_PIXBUF_EXPANDER_CLOSED, PROP_STOCK_ID, PROP_STOCK_SIZE, PROP_STOCK_DETAIL, PROP_ACTIVATABLE, PROP_BACKGROUND }; enum { CLICKED, LAST_SIGNAL }; static guint cereimg_cell_signals[LAST_SIGNAL] = { 0 }; static gpointer parent_class; #define CELLTRACE_KEY "gtk-cell-renderer-pixbuf-info" typedef struct _CereimgInfo CereimgInfo; struct _CereimgInfo { gchar *stock_id; GtkIconSize stock_size; gchar *stock_detail; }; GType cereimg_get_type (void) { static GType cell_pixbuf_type = 0; if (!cell_pixbuf_type) { static const GTypeInfo cell_pixbuf_info = { sizeof (CereimgClass), NULL, /* base_init */ NULL, /* base_finalize */ (GClassInitFunc) cereimg_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (Cereimg), 0, /* n_preallocs */ (GInstanceInitFunc) cereimg_init, }; cell_pixbuf_type = g_type_register_static (GTK_TYPE_CELL_RENDERER, "Cereimg", &cell_pixbuf_info, 0); } return cell_pixbuf_type; } static void cereimg_init (Cereimg *cellimg) { CereimgInfo *cellinfo; cellinfo = g_new0 (CereimgInfo, 1); cellinfo->stock_size = GTK_ICON_SIZE_MENU; g_object_set_data (G_OBJECT (cellimg), CELLTRACE_KEY, cellinfo); cellimg->activatable = TRUE; GTK_CELL_RENDERER (cellimg)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE; } static void cereimg_class_init (CereimgClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class); parent_class = g_type_class_peek_parent (class); object_class->finalize = cereimg_finalize; object_class->get_property = cereimg_get_property; object_class->set_property = cereimg_set_property; cell_class->get_size = cereimg_get_size; cell_class->render = cereimg_render; cell_class->activate = cereimg_activate; g_object_class_install_property (object_class, PROP_PIXBUF, g_param_spec_object ("pixbuf", "Pixbuf Object", "The pixbuf to render", GDK_TYPE_PIXBUF, G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property (object_class, PROP_PIXBUF_EXPANDER_OPEN, g_param_spec_object ("pixbuf_expander_open", "Pixbuf Expander Open", "Pixbuf for open expander", GDK_TYPE_PIXBUF, G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property (object_class, PROP_PIXBUF_EXPANDER_CLOSED, g_param_spec_object ("pixbuf_expander_closed", "Pixbuf Expander Closed", "Pixbuf for closed expander", GDK_TYPE_PIXBUF, G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property (object_class, PROP_STOCK_ID, g_param_spec_string ("stock_id", "Stock ID", "The stock ID of the stock icon to render", NULL, G_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_STOCK_SIZE, g_param_spec_enum ("stock_size", "Size", "The size of the rendered icon", GTK_TYPE_ICON_SIZE, GTK_ICON_SIZE_MENU, G_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_STOCK_DETAIL, g_param_spec_string ("stock_detail", "Detail", "Render detail to pass to the theme engine", NULL, G_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_ACTIVATABLE, g_param_spec_boolean ("activatable", "Activatable", "The image can be clicked", TRUE, G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property (object_class, PROP_BACKGROUND, g_param_spec_string ("background", "Background color name", "Background color as a string", NULL, G_PARAM_WRITABLE)); cereimg_cell_signals[CLICKED] = g_signal_new("clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CereimgClass, clicked), NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); } static void cereimg_finalize (GObject *object) { Cereimg *cellimg = GTK_CEREIMG (object); CereimgInfo *cellinfo = g_object_get_data (object, CELLTRACE_KEY); if (cellimg->pixbuf && cellinfo->stock_id) g_object_unref (cellimg->pixbuf); if (cellinfo->stock_id) g_free (cellinfo->stock_id); if (cellinfo->stock_detail) g_free (cellinfo->stock_detail); g_free (cellinfo); g_object_set_data (object, CELLTRACE_KEY, NULL); (* G_OBJECT_CLASS (parent_class)->finalize) (object); } static void cereimg_get_property (GObject *object, guint param_id, GValue *value, GParamSpec *pspec) { Cereimg *cellimg = GTK_CEREIMG (object); CereimgInfo *cellinfo = g_object_get_data (object, CELLTRACE_KEY); switch (param_id) { case PROP_PIXBUF: g_value_set_object (value, cellimg->pixbuf ? G_OBJECT (cellimg->pixbuf) : NULL); break; case PROP_PIXBUF_EXPANDER_OPEN: g_value_set_object (value, cellimg->pixbuf_expander_open ? G_OBJECT (cellimg->pixbuf_expander_open) : NULL); break; case PROP_PIXBUF_EXPANDER_CLOSED: g_value_set_object (value, cellimg->pixbuf_expander_closed ? G_OBJECT (cellimg->pixbuf_expander_closed) : NULL); break; case PROP_STOCK_ID: g_value_set_string (value, cellinfo->stock_id); break; case PROP_STOCK_SIZE: g_value_set_enum (value, cellinfo->stock_size); break; case PROP_STOCK_DETAIL: g_value_set_string (value, cellinfo->stock_detail); break; case PROP_ACTIVATABLE: g_value_set_boolean (value, cellimg->activatable); break; case PROP_BACKGROUND: default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; } } static void cereimg_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec) { GdkPixbuf *pixbuf; Cereimg *cellimg = GTK_CEREIMG (object); CereimgInfo *cellinfo = g_object_get_data (object, CELLTRACE_KEY); switch (param_id) { case PROP_PIXBUF: pixbuf = (GdkPixbuf*) g_value_get_object (value); if (pixbuf) g_object_ref (pixbuf); if (cellimg->pixbuf) g_object_unref (cellimg->pixbuf); cellimg->pixbuf = pixbuf; break; case PROP_PIXBUF_EXPANDER_OPEN: pixbuf = (GdkPixbuf*) g_value_get_object (value); if (pixbuf) g_object_ref (pixbuf); if (cellimg->pixbuf_expander_open) g_object_unref (cellimg->pixbuf_expander_open); cellimg->pixbuf_expander_open = pixbuf; break; case PROP_PIXBUF_EXPANDER_CLOSED: pixbuf = (GdkPixbuf*) g_value_get_object (value); if (pixbuf) g_object_ref (pixbuf); if (cellimg->pixbuf_expander_closed) g_object_unref (cellimg->pixbuf_expander_closed); cellimg->pixbuf_expander_closed = pixbuf; break; case PROP_STOCK_ID: if (cellinfo->stock_id) g_free (cellinfo->stock_id); cellinfo->stock_id = g_strdup (g_value_get_string (value)); g_object_notify (G_OBJECT (object), "stock_id"); break; case PROP_STOCK_SIZE: cellinfo->stock_size = g_value_get_enum (value); g_object_notify (G_OBJECT (object), "stock_size"); break; case PROP_STOCK_DETAIL: if (cellinfo->stock_detail) g_free (cellinfo->stock_detail); cellinfo->stock_detail = g_strdup (g_value_get_string (value)); g_object_notify (G_OBJECT (object), "stock_detail"); break; case PROP_ACTIVATABLE: cellimg->activatable = g_value_get_boolean (value); g_object_notify (G_OBJECT (object), "activatable"); break; case PROP_BACKGROUND: { cellimg->background_set = FALSE; if (!g_value_get_string (value)) g_warning("Don't know color, value is NULL"); else if (gdk_color_parse (g_value_get_string (value), &cellimg->background_color)) cellimg->background_set = TRUE; else g_warning("Don't know color `%s'", g_value_get_string (value)); } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; } if (cellimg->pixbuf && cellinfo->stock_id) { g_object_unref (cellimg->pixbuf); cellimg->pixbuf = NULL; } } /** * cereimg_new: * * Creates a new #Cereimg. Adjust rendering * parameters using object properties. Object properties can be set * globally (with g_object_set()). Also, with #GtkTreeViewColumn, you * can bind a property to a value in a #GtkTreeModel. For example, you * can bind the "pixbuf" property on the cell renderer to a pixbuf value * in the model, thus rendering a different image in each row of the * #GtkTreeView. * * Return value: the new cell renderer **/ GtkCellRenderer * cereimg_new (void) { return g_object_new (GTK_TYPE_CEREIMG, NULL); } static void cereimg_create_stock_pixbuf (Cereimg *cellimg, GtkWidget *widget) { CereimgInfo *cellinfo = g_object_get_data (G_OBJECT (cellimg), CELLTRACE_KEY); if (cellimg->pixbuf) g_object_unref (cellimg->pixbuf); cellimg->pixbuf = gtk_widget_render_icon (widget, cellinfo->stock_id, cellinfo->stock_size, cellinfo->stock_detail); } static void cereimg_get_size (GtkCellRenderer *cell, GtkWidget *widget, GdkRectangle *cell_area, gint *x_offset, gint *y_offset, gint *width, gint *height) { Cereimg *cellimg = (Cereimg *) cell; CereimgInfo *cellinfo = g_object_get_data (G_OBJECT (cell), CELLTRACE_KEY); gint pixbuf_width = 0; gint pixbuf_height = 0; gint calc_width; gint calc_height; if (!cellimg->pixbuf && cellinfo->stock_id) cereimg_create_stock_pixbuf (cellimg, widget); if (cellimg->pixbuf) { pixbuf_width = gdk_pixbuf_get_width (cellimg->pixbuf); pixbuf_height = gdk_pixbuf_get_height (cellimg->pixbuf); } if (cellimg->pixbuf_expander_open) { pixbuf_width = MAX (pixbuf_width, gdk_pixbuf_get_width (cellimg->pixbuf_expander_open)); pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellimg->pixbuf_expander_open)); } if (cellimg->pixbuf_expander_closed) { pixbuf_width = MAX (pixbuf_width, gdk_pixbuf_get_width (cellimg->pixbuf_expander_closed)); pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellimg->pixbuf_expander_closed)); } calc_width = (gint) GTK_CELL_RENDERER (cellimg)->xpad * 2 + pixbuf_width; calc_height = (gint) GTK_CELL_RENDERER (cellimg)->ypad * 2 + pixbuf_height; if (x_offset) *x_offset = 0; if (y_offset) *y_offset = 0; if (cell_area && pixbuf_width > 0 && pixbuf_height > 0) { if (x_offset) { *x_offset = GTK_CELL_RENDERER (cellimg)->xalign * (cell_area->width - calc_width - (2 * GTK_CELL_RENDERER (cellimg)->xpad)); *x_offset = MAX (*x_offset, 0) + GTK_CELL_RENDERER (cellimg)->xpad; } if (y_offset) { *y_offset = GTK_CELL_RENDERER (cellimg)->yalign * (cell_area->height - calc_height - (2 * GTK_CELL_RENDERER (cellimg)->ypad)); *y_offset = MAX (*y_offset, 0) + GTK_CELL_RENDERER (cellimg)->ypad; } } if (width) *width = calc_width; if (height) *height = calc_height; } static void cereimg_render (GtkCellRenderer *cell, GdkWindow *window, GtkWidget *widget, GdkRectangle *background_area, GdkRectangle *cell_area, GdkRectangle *expose_area, GtkCellRendererState flags) { Cereimg *cellimg = (Cereimg *) cell; CereimgInfo *cellinfo = g_object_get_data (G_OBJECT (cell), CELLTRACE_KEY); GdkPixbuf *pixbuf; GdkRectangle pix_rect; GdkRectangle draw_rect; gboolean stock_pixbuf = FALSE; GdkGC *gc; gboolean use_background; use_background = (cellimg->background_set == TRUE) && ((flags & GTK_CELL_RENDERER_SELECTED) != GTK_CELL_RENDERER_SELECTED); if (use_background) { //gdk_color_parse("#ccccff",&cellimg->background_color); gc = gdk_gc_new (window); gdk_gc_set_rgb_fg_color (gc, &cellimg->background_color); gdk_draw_rectangle (window, gc, TRUE, background_area->x, background_area->y, background_area->width, background_area->height); //background_area->width+2 not needed anymore. } else { gc = widget->style->black_gc; } pixbuf = cellimg->pixbuf; if (cell->is_expander) { if (cell->is_expanded && cellimg->pixbuf_expander_open != NULL) pixbuf = cellimg->pixbuf_expander_open; else if (! cell->is_expanded && cellimg->pixbuf_expander_closed != NULL) pixbuf = cellimg->pixbuf_expander_closed; } if (!pixbuf && !cellinfo->stock_id) { if (use_background) g_object_unref(gc); return; } else if (!pixbuf && cellinfo->stock_id) stock_pixbuf = TRUE; cereimg_get_size (cell, widget, cell_area, &pix_rect.x, &pix_rect.y, &pix_rect.width, &pix_rect.height); if (stock_pixbuf) pixbuf = cellimg->pixbuf; pix_rect.x += cell_area->x; pix_rect.y += cell_area->y; pix_rect.width -= cell->xpad * 2; pix_rect.height -= cell->ypad * 2; if (gdk_rectangle_intersect (cell_area, &pix_rect, &draw_rect)) { gdk_pixbuf_render_to_drawable ( pixbuf, window/*drawable*/, gc/*widget->style->black_gc*/, /* pixbuf 0, 0 is at pix_rect.x, pix_rect.y */ draw_rect.x - pix_rect.x/* src_x */, draw_rect.y - pix_rect.y/* src_y */, draw_rect.x/* dst_x */, draw_rect.y/* dst_y */, draw_rect.width/* width */, draw_rect.height/* height */, GDK_RGB_DITHER_NORMAL, 0, 0); #if 0 gdk_draw_pixbuf (window, gc/*widget->style->black_gc*/, pixbuf, /* pixbuf 0, 0 is at pix_rect.x, pix_rect.y */ draw_rect.x - pix_rect.x, draw_rect.y - pix_rect.y, draw_rect.x, draw_rect.y, draw_rect.width, draw_rect.height, GDK_RGB_DITHER_NORMAL, 0, 0); #endif } if (use_background) g_object_unref(gc); } static gint cereimg_activate (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, GdkRectangle *background_area, GdkRectangle *cell_area, GtkCellRendererState flags) { g_signal_emit (cell, cereimg_cell_signals[CLICKED], 0, path); return TRUE; } #if 0 GtkWidget *create_tree(void) { GtkTreeStore *store; GtkWidget *treeview; GtkTreeSelection *select; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkTreeIter iter1; GdkPixbuf *pixbuf_tmp; pixbuf_tmp = gdk_pixbuf_new_from_file("../src/unknown.png", NULL); store = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_POINTER); gtk_tree_store_append(store, &iter1, NULL); gtk_tree_store_set(store, &iter1, 0, "le premier", 1, 0, -1); gtk_tree_store_append(store, &iter1, NULL); gtk_tree_store_set(store, &iter1, 0, "/usr/share/icons", 1, 0, -1); treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); g_object_unref(G_OBJECT(store)); select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes("Name", renderer, "text", 0, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); renderer = gtk_cell_renderer_pixbuf_new(); g_object_set(renderer, "pixbuf", pixbuf_tmp, NULL); column = gtk_tree_view_column_new_with_attributes("Pix", renderer, NULL); return treeview; } int main(int argc, char**argv) { GtkWidget *w; GtkWidget *tree; gtk_init(&argc, &argv); w = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(w), "Treeview cell renderer: cereimg"); tree = create_tree(); gtk_container_add(GTK_CONTAINER(w), tree); gtk_widget_show_all(w); gtk_main(); return 0; } #endif apwal/src/cereimg.h0000644000175000017500000000604007775104113014100 0ustar pebpeb00000000000000/* cereimg.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* cereimg.h * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef __GTK_CEREIMG_H__ #define __GTK_CEREIMG_H__ #include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #define GTK_TYPE_CEREIMG (cereimg_get_type ()) #define GTK_CEREIMG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CEREIMG, Cereimg)) #define GTK_CEREIMG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CEREIMG, CereimgClass)) #define GTK_IS_CEREIMG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CEREIMG)) #define GTK_IS_CEREIMG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CEREIMG)) #define GTK_CEREIMG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CEREIMG, CereimgClass)) typedef struct _Cereimg Cereimg; typedef struct _CereimgClass CereimgClass; struct _Cereimg { GtkCellRenderer parent; /*< private >*/ GdkPixbuf *pixbuf; GdkPixbuf *pixbuf_expander_open; GdkPixbuf *pixbuf_expander_closed; GdkColor background_color; guint activatable : 1; guint background_set : 1; }; struct _CereimgClass { GtkCellRendererClass parent_class; void (* clicked) (Cereimg *cereimg, const gchar *path); /* Padding for future expansion */ void (*_gtk_reserved1) (void); void (*_gtk_reserved2) (void); void (*_gtk_reserved3) (void); void (*_gtk_reserved4) (void); }; GType cereimg_get_type (void); GtkCellRenderer *cereimg_new (void); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __GTK_CEREIMG_H__ */ apwal/src/common.h0000644000175000017500000000317210161363217013753 0ustar pebpeb00000000000000/* common.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef COMMON__H #define COMMON__H // ---------------------------------------------------------------------------- #define ICON_WIDTH 48 #define ICON_HEIGHT 48 #define DBLCLICK 500 // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- //#include // later... #include #include // malloc, free, ... #include "log.h" #include "sysstuff.h" #include "gtkstuff.h" #include "splash.h" #include "app.h" #include "editor.h" #include "property.h" #include "iconlist.h" #include "iconsel.h" #include "filesel.h" #include "apwalpref.h" #include "apwalapp.h" #include "xmlrc.h" #include "about.h" // ---------------------------------------------------------------------------- #endif /*COMMON__H*/ apwal/src/editor.c0000644000175000017500000004324110005771033013741 0ustar pebpeb00000000000000/* editor.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include #include static void editor_draw_icon(editor_t *e, GdkPixbuf *pixbuf_view, char *iconame, gint x, gint y, gboolean is_valid, gboolean is_cursor); static void editor_build_interface(editor_t *e); static gboolean editor_button_press_event(GtkWidget *widget, GdkEventButton *event, editor_t *e); static gboolean editor_motion_notify_event(GtkWidget *widget, GdkEventMotion *event, editor_t *e); static gboolean editor_is_dblclick(editor_t *e, int x, int y); static gboolean editor_button_release_event(GtkWidget *widget, GdkEventButton *event, editor_t *e); static void editor_arrow_up_clicked(GtkWidget *widget, editor_t *e); static void editor_arrow_down_clicked(GtkWidget *widget, editor_t *e); static void editor_arrow_left_clicked(GtkWidget *widget, editor_t *e); static void editor_arrow_right_clicked(GtkWidget *widget, editor_t *e); // ---------------------------------------------------------------------------- editor_t* editor_new(struct apwalapp_t *apwal) { editor_t *editor; g_assert(apwal != NULL); g_assert(apwal->editor_frame != NULL); editor = (editor_t *)malloc(sizeof(editor_t)); g_assert(editor != NULL); editor->apwal = apwal; editor->dblclick_timer = NULL; editor->drag_in_progress = FALSE; editor->xwidth = gdk_screen_width(); editor->xheight = gdk_screen_height(); editor->x = -2; editor->y = -2; editor->width = 10; if (editor->xheight <= 480) editor->height = 3; else editor->height = 6; editor_build_interface(editor); editor_refresh(editor); return editor; } // ---------------------------------------------------------------------------- void editor_draw_icon(editor_t *e, GdkPixbuf *pixbuf_view, char *iconame, gint x, gint y, gboolean is_valid, gboolean is_cursor) { GdkPixbuf *pixbuf_icon; gint width; gint height; g_assert(e != NULL && pixbuf_view != NULL && iconame != NULL); // first check if this icon has to be showed if ((x < e->x) || (x >= (e->x + e->width))) return; if ((y < e->y) || (y >= (e->y + e->height))) return; // icon pixbuf pixbuf_icon = gdk_pixbuf_new_from_apwal(iconame, NULL, NULL); // if the app has something wrong then change is color to N&B. if (!is_valid && !is_cursor) gdk_pixbuf_saturate_and_pixelate(pixbuf_icon, pixbuf_icon, 0.1/*saturation*/, TRUE/*pixelate*/); if ((x == e->drag_start_x) && (y == e->drag_start_y)) { if ((e->drag_in_progress == TRUE) && ( ! ((x == e->drag_current_x) && (y == e->drag_current_y)) ) ) { if (!is_cursor) gdk_pixbuf_saturate_and_pixelate(pixbuf_icon, pixbuf_icon, 0.0/*saturation*/, TRUE/*pixelate*/); if ((e->drag_start_x != e->drag_current_x) || (e->drag_start_y != e->drag_current_y)) { if ((!is_cursor) && (app_list_at_xy(e->apwal->apps, e->drag_current_x, e->drag_current_y) == NULL)) editor_draw_icon(e, pixbuf_view, iconame, e->drag_current_x, e->drag_current_y, TRUE/*valid?*/, FALSE/*cursor?*/); } } } // accept icons with size lower that 48x48 width = gdk_pixbuf_get_width(pixbuf_icon); height = gdk_pixbuf_get_height(pixbuf_icon); width = width < ICON_WIDTH ? width : ICON_WIDTH; height= height< ICON_HEIGHT ? height: ICON_HEIGHT; /* TRACE("x:%d y:%d w:%d h:%d, " "icon x:%d y:%d w:%d h:%d coord:(%d,%d)", e->x, e->y, e->width, e->height, x, y, width, height, (x - e->x) * ICON_WIDTH, (y - e->y) * ICON_HEIGHT); */ // put the icon in the image which has to be displayed gdk_pixbuf_composite(pixbuf_icon/*src*/, pixbuf_view/*dest*/, (x - e->x) * ICON_WIDTH/*dest_x*/, (y - e->y) * ICON_HEIGHT/*dest_y*/, gdk_pixbuf_get_width(pixbuf_icon)/*dest_width*/, gdk_pixbuf_get_height(pixbuf_icon)/*dest_height*/, (x - e->x) * ICON_WIDTH/*offset_x*/, (y - e->y) * ICON_WIDTH/*offset_y*/, 1/*scale_x*/, 1/*scale_y*/, GDK_INTERP_NEAREST/*interp_type*/, 255/*overall_alpha*/); g_object_unref(pixbuf_icon); return; } // ---------------------------------------------------------------------------- void editor_refresh(editor_t *e) { GdkPixbuf *pixbuf_view; app_t *app; gboolean is_valid; g_assert(e != NULL); g_assert(e->apwal != NULL); g_assert(e->apwal->apps != NULL); pixbuf_view = gdk_pixbuf_new(GDK_COLORSPACE_RGB/*colorspace*/, TRUE/*has_alpha*/, 8/*bits_per_sample*/, e->width * ICON_WIDTH, e->height * ICON_HEIGHT); gdk_pixbuf_fill(pixbuf_view, 0x00000000); app = app_list_first(e->apwal->apps); while (app) { is_valid = app_is_executable(app); editor_draw_icon(e, pixbuf_view, app->icon, app->x, app->y, is_valid, FALSE/*cursor?*/); app = app_list_next(e->apwal->apps); } // end while app // draw cursor editor_draw_icon(e, pixbuf_view, "cursor2", 0, 0, TRUE, TRUE/*cursor?*/); // draw selection around the current selected icon if (e->apwal->selected_app != NULL) editor_draw_icon(e, pixbuf_view, "selected", e->apwal->selected_app->x, e->apwal->selected_app->y, TRUE, TRUE/*cursor?*/); //editor_draw_icon(e, pixbuf_view, "selected", e->drag_current_x, // e->drag_current_y, TRUE, TRUE /*cursor?*/); gtk_image_set_from_pixbuf(GTK_IMAGE(e->image), pixbuf_view); g_object_unref(pixbuf_view); } // ---------------------------------------------------------------------------- static void editor_build_interface(editor_t *e) { //GtkWidget *notebook; //GtkWidget *editor_vbox; //GtkWidget *editor_frame; GtkWidget *table; GtkWidget *eventbox; //GtkWidget *image; GtkWidget *button; // left, right, top, button & ? GtkWidget *image; // ? img GtkWidget *eventbox_for_image; // ? img char *tooltips_str; g_assert(e != NULL); g_assert(e->apwal != NULL); g_assert(e->apwal->editor_frame != NULL); // table for the editor view table = gtk_table_new(3/*rows*/,3/*cols*/, FALSE/*homogeous*/); gtk_container_add(GTK_CONTAINER(e->apwal->editor_frame), table); gtk_widget_show(table); // arrows ^ v < > and '?' for the tips button = gtk_arrow_button_new(GTK_ARROW_UP); gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 0, 1); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(editor_arrow_up_clicked), e); gtk_widget_show(button); button = gtk_arrow_button_new(GTK_ARROW_DOWN); gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 2, 3); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(editor_arrow_down_clicked), e); gtk_widget_show(button); button = gtk_arrow_button_new(GTK_ARROW_LEFT); gtk_table_attach_defaults(GTK_TABLE(table), button, 0, 1, 1, 2); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(editor_arrow_left_clicked), e); gtk_widget_show(button); button = gtk_arrow_button_new(GTK_ARROW_RIGHT); gtk_table_attach_defaults(GTK_TABLE(table), button, 2, 3, 1, 2); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(editor_arrow_right_clicked), e); gtk_widget_show(button); eventbox_for_image = gtk_event_box_new(); gtk_table_attach_defaults(GTK_TABLE(table), eventbox_for_image, 0, 1, 0, 1); gtk_widget_show(eventbox_for_image); tooltips_str = "Editor behaviours\n" ". Double click on an icon to select a new one\n" ". Drag and drop an icon to move it on the grid\n" ". Press the remove button to delete an application\n" ". Use the arrow buttons to see all the grid\n" ". The red cross is the positon of the cursor"; gtk_tooltips_set_tip(e->apwal->tips, eventbox_for_image, tooltips_str, NULL); image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_MENU); // GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_container_add(GTK_CONTAINER(eventbox_for_image), image); gtk_widget_show(image); // eventbox eventbox = gtk_event_box_new(); g_signal_connect(G_OBJECT(eventbox), "button_press_event", G_CALLBACK(editor_button_press_event), e); g_signal_connect(G_OBJECT(eventbox), "button_release_event", G_CALLBACK(editor_button_release_event), e); g_signal_connect(G_OBJECT(eventbox), "motion_notify_event", G_CALLBACK(editor_motion_notify_event), e); gtk_table_attach_defaults(GTK_TABLE(table), eventbox, 1, 2, 1, 2); gtk_widget_show(eventbox); // image e->image = gtk_image_new(); gtk_container_add(GTK_CONTAINER(eventbox), e->image); gtk_widget_show(e->image); //gtk_widget_set_extension_events(eventbox, GDK_EXTENSION_EVENTS_ALL); //gtk_widget_add_events(eventbox, GDK_ALL_EVENTS_MASK | GDK_KEY_RELEASE_MASK); //GTK_WIDGET_SET_FLAGS (eventbox, GTK_CAN_FOCUS); //g_signal_connect(G_OBJECT(eventbox), "key_release_event", // G_CALLBACK(editor_key_release_event), e); //gtk_notebook_append_page(GTK_NOTEBOOK(e->apwal->notebook), // editor_vbox, editor_label); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- static gboolean editor_button_press_event(GtkWidget *widget, GdkEventButton *event, editor_t *e) { gint x, y; app_t *app; g_assert(widget != NULL && e != NULL && event != NULL); g_assert(e->apwal != NULL); // have the keyboard focus on the eventbox to be able to catch key bindings gtk_widget_grab_focus(widget); x = (((int)event->x)/ICON_WIDTH) + e->x; y = (((int)event->y)/ICON_WIDTH) + e->y; TRACE("x:%d, y:%d", x, y); app = app_list_at_xy(e->apwal->apps, x, y); if (app != NULL) e->drag_in_progress = TRUE; else e->drag_in_progress = FALSE; e->drag_start_x = x; e->drag_start_y = y; e->drag_current_x = x; e->drag_current_y = y; if (app != NULL) { e->apwal->selected_app = app; apwalapp_selected_app_modified(e->apwal); } editor_refresh(e); return TRUE; } // ---------------------------------------------------------------------------- static gboolean editor_motion_notify_event(GtkWidget *widget, GdkEventMotion *event, editor_t *e) { gint x, y; g_assert(widget != NULL && e != NULL && event != NULL); x = (((int)event->x)/ICON_WIDTH) + e->x; y = (((int)event->y)/ICON_WIDTH) + e->y; if ( ! ((x == e->drag_current_x) && (y == e->drag_current_y)) ) //|| // ((x == e->drag_start_x) && (y == e->drag_start_y)) ) ) { e->drag_current_x = (((int)event->x)/ICON_WIDTH) + e->x; e->drag_current_y = (((int)event->y)/ICON_WIDTH) + e->y; TRACE("x:%d, y:%d", e->drag_current_x, e->drag_current_y); editor_refresh(e); } return TRUE; } // ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------- static gboolean editor_is_dblclick(editor_t *e, int x, int y) { gint elapse; g_assert(e != NULL); if (e->dblclick_timer == NULL) { e->dblclick_timer = g_timer_new(); e->dblclick_last_x = x; e->dblclick_last_y = y; return FALSE; } elapse = (int)(g_timer_elapsed(e->dblclick_timer, NULL) * 1000); g_timer_start(e->dblclick_timer); if ((e->dblclick_last_x != x) || (e->dblclick_last_y != y)) { e->dblclick_last_x = x; e->dblclick_last_y = y; return FALSE; } if (elapse > DBLCLICK) return FALSE; return TRUE; } // ----------------------------------------------------------------------------- static gboolean editor_button_release_event(GtkWidget *widget, GdkEventButton *event, editor_t *e) { int pos_x; int pos_y; app_t *app, *newapp; gboolean drag_in_progress; g_assert(e != NULL); g_assert(e->apwal != NULL); g_assert(e->apwal->apps != NULL); TRACE("type:%x, x:%f, y:%f, button:%d", event->type, event->x, event->y, event->button); pos_x = (((int)event->x)/ICON_WIDTH) + e->x; pos_y = (((int)event->y)/ICON_WIDTH) + e->y; drag_in_progress = e->drag_in_progress; e->drag_in_progress = FALSE; // on double click on a app, go to icon selection tab to select the icon // if no app on the position of the double click, do nothing if (editor_is_dblclick(e, pos_x, pos_y) == TRUE) { if (e->apwal->selected_app != NULL) apwalapp_goto_iconsel(e->apwal); return TRUE; } // if drag in progress and the cursor had moved then do the drop // on the new location of the cursor if ((drag_in_progress == TRUE) && ( ! ((pos_x == e->drag_start_x) && (pos_y == e->drag_start_y)) ) ) { // if there are no app on the drop posistion, move the app // dragged to the new position, else nothing to do app = app_list_at_xy(e->apwal->apps, pos_x, pos_y); if (app == NULL) { newapp = app_list_at_xy(e->apwal->apps, e->drag_start_x, e->drag_start_y); if (newapp == NULL) ERR("app_list_at_xy, e->drag_start_x:%d, e->drag_start_y:%d", e->drag_start_x, e->drag_start_y); newapp->x = pos_x; newapp->y = pos_y; e->drag_start_x = pos_x; // so we see the app 'selected' in the editor e->drag_start_y = pos_y; e->drag_current_x = pos_x; // so we see the app 'selected' in the editor e->drag_current_y = pos_y; } editor_refresh(e); return TRUE; } // if the cursor has moved like and drag and drop but no drag in progress, // then do nothing (case of a drag from an empty position) if ((drag_in_progress == FALSE) && ( ! ((pos_x == e->drag_start_x) && (pos_y == e->drag_start_y)) ) ) return TRUE; // case of the simple clic editor_goto(e, pos_x, pos_y); return TRUE; } // ----------------------------------------------------------------------------- // selected app and show it in property. void editor_goto(editor_t *e, int pos_x, int pos_y) { int cc; app_t *app, *newapp; // if no app on the current position then move the noname app if not // created. if no noname app found create one. // if an app is found check if a noname app exist and remove it. // then select the found app and refresh the properties. app = app_list_at_xy(e->apwal->apps, pos_x, pos_y); if (app == NULL) { newapp = app_list_find_noname(e->apwal->apps); if (newapp != NULL) { newapp->x = pos_x; newapp->y = pos_y; } else { newapp = app_new_noname(pos_x, pos_y); app_list_add(e->apwal->apps, newapp); } app = app_list_at_xy(e->apwal->apps, pos_x, pos_y); if (app != newapp) ERR("app:%p != newapp:%p", app, newapp); } else { newapp = app_list_find_noname(e->apwal->apps); if (newapp != NULL && newapp != app) { cc = app_list_remove(e->apwal->apps, newapp); if (cc) ERR("%s", "impossible to remove the noname app found just before."); } } e->apwal->selected_app = app; editor_refresh(e); apwalapp_selected_app_modified(e->apwal); } // ---------------------------------------------------------------------------- static void editor_arrow_up_clicked(GtkWidget *widget, editor_t *e) { g_assert(e != NULL); //TRACE("%s", ""); e->y--; editor_refresh(e); } // ---------------------------------------------------------------------------- static void editor_arrow_down_clicked(GtkWidget *widget, editor_t *e) { g_assert(e != NULL); //TRACE("%s", ""); e->y++; editor_refresh(e); } // ---------------------------------------------------------------------------- static void editor_arrow_left_clicked(GtkWidget *widget, editor_t *e) { g_assert(e != NULL); //TRACE("%s", ""); e->x--; editor_refresh(e); } // ---------------------------------------------------------------------------- static void editor_arrow_right_clicked(GtkWidget *widget, editor_t *e) { g_assert(e != NULL); //TRACE("%s", ""); e->x++; editor_refresh(e); } // ---------------------------------------------------------------------------- apwal/src/editor.h0000644000175000017500000000432210000352667013746 0ustar pebpeb00000000000000/* editor.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #ifndef EDITOR__H #define EDITOR__H #include "common.h" // ---------------------------------------------------------------------------- typedef struct editor_t { struct apwalapp_t *apwal; GtkWidget *image; gint x; // x coord of the top left icon in the view gint y; // y coord if the top left icon in the view gint width; // number of icons in a row gint height; // number of icons in a column gint xwidth; // resolution of the current X11 display gint xheight; // '' GTimer *dblclick_timer; gint dblclick_last_x; gint dblclick_last_y; gboolean drag_in_progress; gint drag_start_x; gint drag_start_y; gint drag_current_x; gint drag_current_y; gboolean refresh_needed; } editor_t; // ---------------------------------------------------------------------------- editor_t* editor_new(struct apwalapp_t *apwal); void editor_refresh(editor_t *l); void editor_goto(editor_t *e, int pos_x, int pos_y); #endif /*EDITOR__H*/ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/filesel.c0000644000175000017500000001007710160073765014110 0ustar pebpeb00000000000000/* filesel.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include /* define FILENAME_MAX */ #include "common.h" typedef struct filesel_t { GtkWidget *filechooser; char *old_value; void *user_data; void (*compute_result) (const char *old_value, const char *new_value, void *data); } filesel_t; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- struct filesel_t* filesel_new(void) { filesel_t *filesel; filesel = (filesel_t *) malloc(sizeof(filesel_t)); g_assert(filesel != NULL); filesel->filechooser = gtk_file_chooser_dialog_new("Directory chooser", NULL/*parent_window*/, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); gtk_widget_hide(filesel->filechooser); filesel->old_value = NULL; return filesel; } // ---------------------------------------------------------------------------- void filesel_select( struct filesel_t *filesel, const char *old_value, gboolean dir_only, void (*compute_result) (const char *old_value, const char *new_value, void *data), void *data) { char *new_value; char *absolute_path = NULL; g_assert(filesel != NULL); g_assert(compute_result != NULL); g_assert(old_value != NULL); filesel->compute_result = compute_result; filesel->user_data = data; if (!g_file_test(old_value, G_FILE_TEST_IS_EXECUTABLE)) absolute_path = g_find_program_in_path(old_value); if (filesel->old_value != NULL) g_free(filesel->old_value); if (absolute_path == NULL) filesel->old_value = g_strdup(old_value); else filesel->old_value = absolute_path; if (dir_only) { gtk_file_chooser_set_action(GTK_FILE_CHOOSER(filesel->filechooser), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(filesel->filechooser)); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(filesel->filechooser), old_value); } else { gtk_file_chooser_set_action(GTK_FILE_CHOOSER(filesel->filechooser), GTK_FILE_CHOOSER_ACTION_OPEN); gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(filesel->filechooser), old_value); } if (gtk_dialog_run(GTK_DIALOG(filesel->filechooser)) == GTK_RESPONSE_ACCEPT) { new_value = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(filesel->filechooser)); filesel->compute_result(filesel->old_value, new_value, filesel->user_data); if (filesel->old_value != NULL) { g_free(filesel->old_value); filesel->old_value = NULL; } } else // cancel { filesel->compute_result(filesel->old_value, NULL, filesel->user_data); if (filesel->old_value != NULL) { g_free(filesel->old_value); filesel->old_value = NULL; } } gtk_widget_hide(filesel->filechooser); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/filesel.h0000644000175000017500000000345107775572246014133 0ustar pebpeb00000000000000/* filesel.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #ifndef FILESEL__H #define FILESEL__H #include "common.h" // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- struct filesel_t; // ---------------------------------------------------------------------------- struct filesel_t* filesel_new(void); void filesel_select( struct filesel_t *filesel, const char *old_value, gboolean dir_only, void (*compute_result) (const char *old_value, const char *new_value, void *data), void *data); #endif /* FILESEL__H*/ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/gpl.inc0000644000175000017500000000135307775104113013573 0ustar pebpeb00000000000000Copyright (C) 2002-2004 Pascal Eberhard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. apwal/src/gplheader.txt0000644000175000017500000000143507775104113015013 0ustar pebpeb00000000000000 * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ apwal/src/gtkfnmatch.c0000644000175000017500000002056607777642770014641 0ustar pebpeb00000000000000/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS * file for a list of people on the GTK+ Team. See the ChangeLog * files for a list of changes. These files are distributed with * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ /* * Stripped down, converted to UTF-8 and test cases added * * Owen Taylor, 13 December 2002; */ #include #include /* We need to make sure that all constants are defined * to properly compile this file */ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif static gunichar get_char (const char **str) { gunichar c = g_utf8_get_char (*str); *str = g_utf8_next_char (*str); #ifdef G_PLATFORM_WIN32 c = g_unichar_tolower (c); #endif return c; } #if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN) #define DO_ESCAPE 0 #else #define DO_ESCAPE 1 #endif static gunichar get_unescaped_char (const char **str, gboolean *was_escaped) { gunichar c = get_char (str); *was_escaped = DO_ESCAPE && c == '\\'; if (*was_escaped) c = get_char (str); return c; } /* Match STRING against the filename pattern PATTERN, returning zero if it matches, nonzero if not. */ static gboolean gtk_fnmatch_intern (const char *pattern, const char *string, gboolean component_start) { const char *p = pattern, *n = string; while (*p) { const char *last_n = n; gunichar c = get_char (&p); gunichar nc = get_char (&n); switch (c) { case '?': if (nc == '\0') return FALSE; else if (nc == G_DIR_SEPARATOR) return FALSE; else if (nc == '.' && component_start) return FALSE; break; case '\\': if (DO_ESCAPE) c = get_char (&p); if (nc != c) return FALSE; break; case '*': if (nc == '.' && component_start) return FALSE; { const char *last_p = p; for (last_p = p, c = get_char (&p); c == '?' || c == '*'; last_p = p, c = get_char (&p)) { if (c == '?') { if (nc == '\0') return FALSE; else if (nc == G_DIR_SEPARATOR) return FALSE; else { last_n = n; nc = get_char (&n); } } } /* If the pattern ends with wildcards, we have a * guaranteed match unless there is a dir separator * in the remainder of the string. */ if (c == '\0') { if (strchr (last_n, G_DIR_SEPARATOR) != NULL) return FALSE; else return TRUE; } if (DO_ESCAPE && c == '\\') c = get_char (&p); for (p = last_p; nc != '\0';) { if ((c == '[' || nc == c) && gtk_fnmatch_intern (p, last_n, component_start)) return TRUE; component_start = (nc == G_DIR_SEPARATOR); last_n = n; nc = get_char (&n); } return FALSE; } case '[': { /* Nonzero if the sense of the character class is inverted. */ gboolean not; gboolean was_escaped; if (nc == '\0' || nc == G_DIR_SEPARATOR) return FALSE; if (nc == '.' && component_start) return FALSE; not = (*p == '!' || *p == '^'); if (not) ++p; c = get_unescaped_char (&p, &was_escaped); for (;;) { register gunichar cstart = c, cend = c; if (c == '\0') /* [ (unterminated) loses. */ return FALSE; c = get_unescaped_char (&p, &was_escaped); if (!was_escaped && c == '-' && *p != ']') { cend = get_unescaped_char (&p, &was_escaped); if (cend == '\0') return FALSE; c = get_char (&p); } if (nc >= cstart && nc <= cend) goto matched; if (!was_escaped && c == ']') break; } if (!not) return FALSE; break; matched:; /* Skip the rest of the [...] that already matched. */ /* XXX 1003.2d11 is unclear if was_escaped is right. */ while (was_escaped || c != ']') { if (c == '\0') /* [... (unterminated) loses. */ return FALSE; c = get_unescaped_char (&p, &was_escaped); } if (not) return FALSE; } break; default: if (c != nc) return FALSE; } component_start = (nc == G_DIR_SEPARATOR); } if (*n == '\0') return TRUE; return FALSE; } /* Match STRING against the filename pattern PATTERN, returning zero if * it matches, nonzero if not. * * GTK+ used to use a old version of GNU fnmatch() that was buggy * in various ways and didn't handle UTF-8. The following is * converted to UTF-8. To simplify the process of making it * correct, this is special-cased to the combinations of flags * that gtkfilesel.c uses. * * FNM_FILE_NAME - always set * FNM_LEADING_DIR - never set * FNM_PERIOD - always set * FNM_NOESCAPE - set only on windows * FNM_CASEFOLD - set only on windows */ gboolean apwal_fnmatch (const char *pattern, const char *string) { return gtk_fnmatch_intern (pattern, string, TRUE); } #undef FNMATCH_TEST_CASES #ifdef FNMATCH_TEST_CASES #define TEST(pat, str, result) \ g_assert (_apwal_fnmatch ((pat), (str)) == result) int main (int argc, char **argv) { TEST ("[a-]", "-", TRUE); TEST ("a", "a", TRUE); TEST ("a", "b", FALSE); /* Test what ? matches */ TEST ("?", "a", TRUE); TEST ("?", ".", FALSE); TEST ("a?", "a.", TRUE); TEST ("a/?", "a/b", TRUE); TEST ("a/?", "a/.", FALSE); TEST ("?", "/", FALSE); /* Test what * matches */ TEST ("*", "a", TRUE); TEST ("*", ".", FALSE); TEST ("a*", "a.", TRUE); TEST ("a/*", "a/b", TRUE); TEST ("a/*", "a/.", FALSE); TEST ("*", "/", FALSE); /* Range tests */ TEST ("[ab]", "a", TRUE); TEST ("[ab]", "c", FALSE); TEST ("[^ab]", "a", FALSE); TEST ("[!ab]", "a", FALSE); TEST ("[^ab]", "c", TRUE); TEST ("[!ab]", "c", TRUE); TEST ("[a-c]", "b", TRUE); TEST ("[a-c]", "d", FALSE); TEST ("[a-]", "-", TRUE); TEST ("[]]", "]", TRUE); TEST ("[^]]", "a", TRUE); TEST ("[!]]", "a", TRUE); /* Various unclosed ranges */ TEST ("[ab", "a", FALSE); TEST ("[a-", "a", FALSE); TEST ("[ab", "c", FALSE); TEST ("[a-", "c", FALSE); TEST ("[^]", "a", FALSE); /* Ranges and special no-wildcard matches */ TEST ("[.]", ".", FALSE); TEST ("a[.]", "a.", TRUE); TEST ("a/[.]", "a/.", FALSE); TEST ("[/]", "/", FALSE); TEST ("[^/]", "a", TRUE); /* Basic tests of * (and combinations of * and ?) */ TEST ("a*b", "ab", TRUE); TEST ("a*b", "axb", TRUE); TEST ("a*b", "axxb", TRUE); TEST ("a**b", "ab", TRUE); TEST ("a**b", "axb", TRUE); TEST ("a**b", "axxb", TRUE); TEST ("a*?*b", "ab", FALSE); TEST ("a*?*b", "axb", TRUE); TEST ("a*?*b", "axxb", TRUE); /* Test of *[range] */ TEST ("a*[cd]", "ac", TRUE); TEST ("a*[cd]", "axc", TRUE); TEST ("a*[cd]", "axx", FALSE); TEST ("a/[.]", "a/.", FALSE); TEST ("a*[.]", "a/.", FALSE); /* Test of UTF-8 */ TEST ("ä", "ä", TRUE); /* TEST ("ä", "ä", TRUE); */ TEST ("?", "ä", TRUE); /* TEST ("?", "ä", TRUE); */ TEST ("*ö", "äö", TRUE); /* TEST ("*ö", "äö", TRUE); */ TEST ("*ö", "ääö", TRUE); /* TEST ("*ö", "ääö", TRUE); */ TEST ("[ä]", "ä", TRUE); /* TEST ("[ä]", "ä", TRUE); */ TEST ("[ä-ö]", "é", TRUE); /* TEST ("[ä-ö]", "é", TRUE); */ TEST ("[ä-ö]", "a", FALSE); /* TEST ("[ä-ö]", "a", FALSE); */ #ifdef DO_ESCAPE /* Tests of escaping */ TEST ("\\\\", "\\", TRUE); TEST ("\\?", "?", TRUE); TEST ("\\?", "a", FALSE); TEST ("\\*", "*", TRUE); TEST ("\\*", "a", FALSE); TEST ("\\[a-b]", "[a-b]", TRUE); TEST ("[\\\\]", "\\", TRUE); TEST ("[\\^a]", "a", TRUE); TEST ("[a\\-c]", "b", FALSE); TEST ("[a\\-c]", "-", TRUE); TEST ("[a\\]", "a", FALSE); #endif /* DO_ESCAPE */ return 0; } #endif /* FNMATCH_TEST_CASES */ apwal/src/gtkfnmatch.h0000644000175000017500000000216707777642770014643 0ustar pebpeb00000000000000/* gtkfnmatch.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef APWAL_FNMATCH__H #define APWAL_FNMATCH__H #include gboolean apwal_fnmatch (const char *pattern, const char *string); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #endif /*APWAL_FNMATCH__H*/ apwal/src/gtkstuff.c0000644000175000017500000001721210005247213014305 0ustar pebpeb00000000000000/* gtkstuff.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include "common.h" typedef struct pixbufinline_t { gchar name[64]; gint size; guint8 *pixbufinline; } pixbufinline_t; #include "pixbufinline.inc" /* pixbufinline_t pixbufinline[] = { { "unknown", sizeof(unknown), (guint8 *) & unknown }, { NULL } }; */ // ---------------------------------------------------------------------------- GtkWidget *gtk_arrow_button_new(GtkArrowType arrow_type) { GtkWidget *button; GtkWidget *arrow; GtkShadowType shadow_type = GTK_SHADOW_NONE; //GTK_SHADOW_NONE GTK_SHADOW_IN GTK_SHADOW_OUT //GTK_SHADOW_ETCHED_IN GTK_SHADOW_ETCHED_OUT button = gtk_button_new (); arrow = gtk_arrow_new (arrow_type, shadow_type); gtk_container_add (GTK_CONTAINER(button), arrow); // GTK_RELIEF_NORMAL GTK_RELIEF_HALF GTK_RELIEF_NONE //gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_widget_show (button); gtk_widget_show (arrow); return button; } // ---------------------------------------------------------------------------- gint index_of_inline_pixbuf(gchar *name) { gint i; g_assert(name != NULL); for (i=0; imessage != NULL); WARN("gdk_pixbuf_new_from_inline NULL, idx:%d, name:%s, E:%s", idx, name, err->message); g_error_free(err); err = NULL; } } if (g_file_test(name, G_FILE_TEST_EXISTS)) { pixbuf = gdk_pixbuf_new_from_file(name, &err/*GError*/); if (pixbuf) { return pixbuf; } else { g_assert(err != NULL && err->message != NULL); //TRACE("gdk_pixbuf_new_from_file NULL, %s", err->message); g_error_free(err); err = NULL; return NULL; } } idx = index_of_inline_pixbuf("unknown"); if (idx != -1) { pixbuf = gdk_pixbuf_new_from_inline(pixbufinline[idx].size, pixbufinline[idx].pixbufinline, TRUE/*copy_pixels*/, &err/*GError*/); if (pixbuf == NULL) { g_assert(err != NULL && err->message != NULL); ERR("gdk_pixbuf_new_from_inline NULL with unknown ->aoutch, idx:%d, E:%s", idx, err->message); g_error_free(err); err = NULL; } return pixbuf; } else ERR("%s", "inline pixbuf:'unknown' not found"); return NULL; } // ---------------------------------------------------------------------------- GdkPixbuf* gdk_pixbuf_new_from_apwal(gchar *name, gint *rwidth, gint *rheight) { GdkPixbuf *pix1; GdkPixbuf *pix2; gint width, height; g_assert(name != NULL); pix1 = gdk_pixbuf_new_from_apwal_private(name); if (pix1 == NULL) return NULL; // if icon is bigger that 48 x 48 then truncate it to save memory width = gdk_pixbuf_get_width(pix1); height = gdk_pixbuf_get_height(pix1); if (rwidth != NULL) *rwidth = width; if (rheight != NULL) *rheight = height; if (width <= 48 && height <= 48) return pix1; width = (width > 48) ? 48 : width; height = (height > 48) ? 48 : height; pix2 = gdk_pixbuf_new(GDK_COLORSPACE_RGB/*colorspace*/, TRUE/*has_alpha*/, 8/*bits_per_sample*/, width, height); gdk_pixbuf_copy_area(pix1/*src_pixbuf*/, 0 /*src_x*/, 0/*src_y*/, width, height, pix2/*dst_pixbuf*/, 0/*dst_x*/,0/*dst_y*/); g_object_unref(pix1); return pix2; } // ---------------------------------------------------------------------------- void gdk_pixbuf_append(GdkPixbuf *pix1, GdkPixbuf *pix2) { GdkPixbuf *pixtmp; gint width1, height1; gint width2, height2; g_assert(pix1 != NULL && pix2 != NULL); width1 = gdk_pixbuf_get_width(pix1); height1 = gdk_pixbuf_get_height(pix1); width2 = gdk_pixbuf_get_width(pix2); height2 = gdk_pixbuf_get_height(pix2); if ((width1 != width2) || (height1 != height2)) { pixtmp = gdk_pixbuf_scale_simple(pix2, width1, height1, GDK_INTERP_BILINEAR); pix2 = pixtmp; } else pixtmp = NULL; gdk_pixbuf_composite(pix2/*src*/, pix1/*dest*/, 0/*dest_x*/, 0/*dest_y*/, width1/*dest_width*/, height1/*dest_height*/, 0/*offset_x*/, 0/*offset_y*/, 1/*scale_x*/, 1/*scale_y*/, GDK_INTERP_NEAREST/*interp_type*/, 255/*overall_alpha*/); if (pixtmp != NULL) g_object_unref(pixtmp); } // ---------------------------------------------------------------------------- // gtk_widget_modify_text on RH8 doesn't reset the color if the color arg is // NULL. So use this wrapper to avoid the problem. void gtk_widget_set_text_color(GtkWidget *widget, GdkColor *color) { //GtkStyle *wstyle; GtkRcStyle *rcstyle; GtkStateType state = GTK_STATE_NORMAL; GtkRcFlags component = GTK_RC_TEXT; //int i; rcstyle = gtk_widget_get_modifier_style(widget); //for (i=0; i<5; i++) // TRACE("%d %3d.%3d.%3d.%3d", i, rcstyle->fg[i].pixel, rcstyle->fg[i].red, rcstyle->fg[i].green, rcstyle->fg[i].blue); if (color != NULL) { if (component == GTK_RC_TEXT) rcstyle->text[state] = *color; else ERR("component%d != GTK_RC_TEXT", component); rcstyle->color_flags[state] |= component; } else { rcstyle->color_flags[state] &= ~component; } gtk_widget_modify_style(widget, rcstyle); } // ---------------------------------------------------------------------------- void gtk_widget_set_text_color_invalid(GtkWidget *widget) { GdkColor color = { 0, 65535, 0, 0 } /*Red*/; gtk_widget_set_text_color(widget, &color); } // ---------------------------------------------------------------------------- void gtk_widget_set_text_color_default(GtkWidget *widget) { gtk_widget_set_text_color(widget, NULL); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/gtkstuff.h0000644000175000017500000000256210005247213014314 0ustar pebpeb00000000000000/* gtkstuff.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef GTKSTUFF__H #define GTKSTUFF__H #include #include "cereimg.h" GtkWidget *gtk_arrow_button_new(GtkArrowType arrow_type); GdkPixbuf* gdk_pixbuf_new_from_apwal(gchar *name, gint *width, gint *height); void gdk_pixbuf_append(GdkPixbuf *pix1, GdkPixbuf *pix2); void gtk_widget_set_text_color_invalid(GtkWidget *widget); void gtk_widget_set_text_color_default(GtkWidget *widget); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #endif /*GTKSTUFF__H*/ apwal/src/iconlist.c0000644000175000017500000010502510005075216014276 0ustar pebpeb00000000000000/* iconlist.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include #include #include #include #include #define _GNU_SOURCE 1 #include //#ifndef FNM_CASEFOLD // case insensitive but is not defined... ? //#define FNM_CASEFOLD (1 << 4) //#endif typedef struct scandir_context_t { icon_list_t *icons; } scandir_context_t; static scandir_context_t scandir_context = { .icons = NULL }; static int icon_list_scandir_icon(const struct dirent *de); static int icon_list_scandir_path(const struct dirent *de); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- icodir_t* icodir_new_child(gchar *dirname, gboolean sel, gboolean rec, icodir_t *parent) { icodir_t *dir; g_assert(dirname != NULL); dir = (icodir_t*) malloc(sizeof(icodir_t)); g_assert(dir != NULL); dir->path = dirname; dir->count_total = 0; dir->count_selected = 0; dir->recursive = rec; dir->selected = sel; dir->parent = parent; dir->children = NULL; if (parent != NULL) parent->children = g_list_append(parent->children, dir); return dir; } // ---------------------------------------------------------------------------- icodir_t* icodir_new(gchar *dirname, gboolean sel, gboolean rec) { return icodir_new_child(dirname, sel, rec, NULL); } // ---------------------------------------------------------------------------- void icodir_free(icodir_t *icodir) { g_assert(icodir != NULL); g_assert(icodir->children == NULL); if (icodir->count_total != 0) ERR("path:%s, count_total:%d", icodir->path, icodir->count_total); if (icodir->path != NULL) g_free(icodir->path); if (icodir->parent != NULL) icodir->parent->children = g_list_remove(icodir->parent->children, icodir); g_free(icodir); } // ---------------------------------------------------------------------------- gint icodir_compare(icodir_t *a, icodir_t *b) { g_assert(a != NULL && b != NULL); if (strcmp("", a->path) == 0) return 1; if (strcmp("", b->path) == 0) return -1; return strcmp(a->path, b->path); } // ---------------------------------------------------------------------------- gint icodir_count_total_rec(icodir_t *dir) { GList *hamster; icodir_t *childdir; gint count; g_assert(dir != NULL); count = dir->count_total; hamster = g_list_first(dir->children); while(hamster) { childdir = hamster->data; count += icodir_count_total_rec(childdir); hamster = g_list_next(hamster); } return count; } // ---------------------------------------------------------------------------- gint icodir_count_selected_rec(icodir_t *dir) { GList *hamster; icodir_t *childdir; gint count; g_assert(dir != NULL); count = dir->count_selected; hamster = g_list_first(dir->children); while(hamster) { childdir = hamster->data; count += icodir_count_selected_rec(childdir); hamster = g_list_next(hamster); } return count; } // ---------------------------------------------------------------------------- icodir_t * icodir_list_find(GList *dirs, char *dirname) { icodir_t *dir; GList *hamster; g_assert(dirname != NULL); TRACE("dirname:%s", dirname); hamster = g_list_first(dirs); while (hamster != NULL) { dir = hamster->data; if (strcmp(dir->path, dirname) == 0) break; hamster = g_list_next(hamster); } if (hamster == NULL) return NULL; return dir; } // ---------------------------------------------------------------------------- GList * icodir_list_find_with_parent(GList *dirs, icodir_t *parentdir) { icodir_t *dir; GList *hamster; g_assert(parentdir != NULL); TRACE("dir:%p", parentdir); hamster = g_list_first(dirs); while (hamster != NULL) { dir = hamster->data; if (dir == parentdir) break; hamster = g_list_next(hamster); } return hamster; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- ico_t* ico_new(icodir_t *dir, gchar *name) { ico_t *ico; char filename[FILENAME_MAX]; g_assert(dir != NULL && name != NULL); g_assert((strlen(dir->path) + strlen(name)) < FILENAME_MAX); ico = (ico_t *) malloc(sizeof(ico_t)); g_assert(ico != NULL); ico->dir = dir; ico->name = name; strcpy(filename, dir->path); strcat(filename, "/"); strcat(filename, ico->name); ico->pixbuf = gdk_pixbuf_new_from_apwal(filename, &ico->width, &ico->height); if (!ico->pixbuf) { TRACE("failed loading pixbuf, return NULL, %s", filename); g_free(name); g_free(ico); return NULL; } ico->selected = FALSE; ico->dir->count_total++; return ico; } // ---------------------------------------------------------------------------- void ico_free(ico_t *ico) { g_assert(ico != NULL); if (ico->name != NULL) g_free(ico->name); if (ico->pixbuf != NULL) g_object_unref(ico->pixbuf); if (ico->dir != NULL) ico->dir->count_total--; g_free(ico); } // ---------------------------------------------------------------------------- gint ico_compare_by_name(ico_t *a, ico_t *b) { g_assert(a != NULL && b != NULL); return strcmp(a->name, b->name); } // ---------------------------------------------------------------------------- gint ico_compare_by_path(ico_t *a, ico_t *b) { gint res; g_assert(a != NULL && b != NULL); g_assert(a->dir != NULL && b->dir != NULL); res = strcmp(a->dir->path, b->dir->path); if (res == 0) res = strcmp(a->name, b->name); return res; } // ---------------------------------------------------------------------------- char *ico_get_full_filename(ico_t *ico) { static char file[FILENAME_MAX]; g_assert(ico != NULL); g_assert(ico->dir != NULL); strcpy(file, ico->dir->path); strcat(file, "/"); strcat(file, ico->name); return file; } // ---------------------------------------------------------------------------- ico_t *ico_list_find_icon(GList *icos, icodir_t *dir, char *ico_name) { GList *hamster; ico_t ico; //icos could be empty (so icos==NULL). g_assert(dir != NULL && ico_name != NULL); //create a fake icon with only the dir and name set for the search ico.dir = dir; ico.name = ico_name; hamster = g_list_find_custom(icos, &ico, (GCompareFunc)ico_compare_by_path); if (hamster == NULL) return NULL; return ((ico_t *)(hamster->data)); } // ---------------------------------------------------------------------------- ico_t *ico_list_try_select_icon(icodir_t *dir, char *ico_name, icon_list_t *icons) { ico_t *ico; GList *ext_hamster; file_ext_t *ext; int cc; gboolean selected; g_assert(dir != NULL && ico_name != NULL && icons != NULL); // check if the name is matching one of the patterns // if name matches pattern then go out the loop with cc=0 // if name don't match any pattern then cc!=0 at the end of the loop // so after the loop, if cc!=0 then don't select the name ext_hamster = g_list_first(icons->iconsel->apwal->iconsel_pref->file_exts); selected = FALSE; while(ext_hamster != NULL && selected == FALSE) { ext = ext_hamster->data; if (ext->selected == TRUE) { cc = fnmatch(ext->extension, ico_name, FNM_CASEFOLD); //TRACE("ext:%s, name:%s, cc:%d", ext->extension, ico_name, cc); if (cc == 0) // success { selected = TRUE; break; } if ((cc != 0) && (cc != FNM_NOMATCH)) // error during match WARN("fnmatch, ext:%s, name:%s, E:%d", ext->extension, ico_name, cc); } ext_hamster = g_list_next(ext_hamster); } //end while ext if (selected == FALSE) // not match return NULL; // the next tests need the icon to be created. create the icon now ico = ico_new(dir, g_strdup(ico_name)); if (ico == NULL) return NULL; // check if the size of the icon match the selected size selected = FALSE; if ((icons->iconsel->apwal->iconsel_pref->select_48 == TRUE) && (ico->width == 48) && (ico->height == 48)) selected = TRUE; else if ((icons->iconsel->apwal->iconsel_pref->select_gt48 == TRUE) && ((ico->width > 48) || (ico->height > 48))) selected = TRUE; else if ((icons->iconsel->apwal->iconsel_pref->select_lt48 == TRUE) && ((ico->width < 48) || (ico->height < 48))) selected = TRUE; if (selected == FALSE) { ico_free(ico); return NULL; } return ico; } // ---------------------------------------------------------------------------- void ico_list_append(GList **icos, icodir_t *dir, icon_list_t *icons) { struct dirent **namelist; int n; ico_t *ico; ico_t *found; g_assert(icos != NULL && dir != NULL && icons != NULL); n = scandir(dir->path, &namelist, icon_list_scandir_icon, alphasort); if (n < 0) { TRACE("scandir dir:%s, cc:%d, E:%d", dir->path, n, errno); return; } while(n--) { //TRACE("*icos:%p, dir:%p, namelist[n]->d_name:%p", // *icos, dir, namelist[n]->d_name); ico = ico_list_try_select_icon(dir, namelist[n]->d_name, icons); found = ico_list_find_icon(*icos, dir, namelist[n]->d_name); if (ico != NULL && found == NULL) *icos = g_list_append(*icos, ico); else if (ico != NULL && found != NULL) ico_free(ico); else if (ico == NULL && found != NULL) { *icos = g_list_remove(*icos, found); if (found == icon_list_get_selected_icon(icons)) icon_list_set_selected_icon(icons, NULL); ico_free(found); } free(namelist[n]); } free(namelist); TRACE("path:%s, count_total:%d", dir->path, dir->count_total); } // ---------------------------------------------------------------------------- void ico_list_remove(GList **icos, icodir_t *dir, icon_list_t *icons) { GList *hamster; ico_t *ico; gint i, count, dircount, dircount2; g_assert(icos != NULL && dir != NULL && icons != NULL); i = 0; dircount = dir->count_total; dircount2 = 0; hamster = g_list_first(*icos); while(hamster) { ico = hamster->data; if (ico->dir == dir) dircount2++; hamster = g_list_next(hamster); } count = g_list_length(*icos); hamster = g_list_first(*icos); while (hamster != NULL) { ico = hamster->data; if (ico->dir == dir) { if (hamster == g_list_first(*icos)) { *icos = g_list_remove(*icos, ico); if (ico == icon_list_get_selected_icon(icons)) icon_list_set_selected_icon(icons, NULL); hamster = g_list_first(*icos); } else { hamster = g_list_remove(hamster, ico); if (ico == icon_list_get_selected_icon(icons)) icon_list_set_selected_icon(icons, NULL); } i++; ico_free(ico); } else hamster = g_list_next(hamster); } if (dircount != i) ERR("icon list:%d, path:%s, dir->count_total:%d != i:%d", count, dir->path, dircount, i); TRACE("icon list:%d, path:%s, dir->count_total:%d, dircount2:%d, i:%d", count, dir->path, dircount, dircount2, i); } // ---------------------------------------------------------------------------- void ico_list_sort(GList **icos, gint sortmode) { g_assert(icos != NULL); switch(sortmode) { case ICONSEL_SORT_NAME: *icos = g_list_sort(*icos, (GCompareFunc)ico_compare_by_name); break; case ICONSEL_SORT_PATH: *icos = g_list_sort(*icos, (GCompareFunc)ico_compare_by_path); break; default: ERR("sortmode:%d invalid", sortmode); } } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- icon_list_t * icon_list_new(icon_selection_t *iconsel) { icon_list_t *icons; TRACE("%s", ""); g_assert(iconsel != NULL); icons = (icon_list_t *) malloc(sizeof(icon_list_t)); g_assert(icons != NULL); icons->iconsel = iconsel; icons->dirs = NULL; icons->icos = NULL; icons->sortmode = ICONSEL_SORT_NAME; icons->pixbuf = NULL; icons->selected_icon = NULL; icons->icon_per_row = 10; scandir_context.icons = icons; return icons; } // ---------------------------------------------------------------------------- void icon_list_free(icon_list_t *icons) { GList *hamster; icodir_t *dir; ico_t *ico; g_assert(icons != NULL); TRACE("%s", ""); // free icon list hamster = g_list_first(icons->icos); while (hamster != NULL) { ico = hamster->data; ico_free(ico); hamster = g_list_next(hamster); } g_list_free(icons->icos); // free dir list hamster = g_list_first(icons->dirs); while (hamster != NULL) { dir = hamster->data; icodir_free(dir); hamster = g_list_next(hamster); } g_list_free(icons->dirs); if (icons->pixbuf) g_object_unref(icons->pixbuf); g_free(icons); } // ---------------------------------------------------------------------------- void icon_list_set_width(icon_list_t *icons, int icon_per_row) { g_assert((icons != NULL) || (icon_per_row <= 0)); icons->icon_per_row = icon_per_row; } // ---------------------------------------------------------------------------- void icon_list_append_children(icon_list_t *icons, icodir_t *dir) { struct dirent **namelist; char dirname[FILENAME_MAX]; int n; icodir_t *childdir; g_assert(icons != NULL && dir != NULL); g_assert(dir->recursive == TRUE); TRACE("'%s'", dir->path); splash_update(icons->iconsel->apwal->splash); n = scandir(dir->path, &namelist, icon_list_scandir_path, alphasort); if (n < 0) { WARN("scandir:%d, errno:%d", n, errno); return; } while(n--) { // buid the abolute path of the child directory strcpy(dirname, dir->path); strcat(dirname, "/"); strcat(dirname, namelist[n]->d_name); // check if the child directory already exist // if the child do not already exist then create it and follow the child, // if the child already exist then do nothing end of the branch here. childdir = icodir_list_find(icons->dirs, dirname); if (childdir == NULL) { childdir = icodir_new_child(g_strdup(dirname), dir->selected, dir->recursive, dir); icons->dirs = g_list_insert_sorted(icons->dirs, childdir, (GCompareFunc) icodir_compare); ico_list_append(&icons->icos, childdir, icons); icon_list_append_children(icons, childdir); } else { if (childdir->parent == dir) { TRACE("'%s' exist and it is our child, reload it", dirname); ico_list_append(&icons->icos, childdir, icons); icon_list_append_children(icons, childdir); } else TRACE("'%s' exist and we are not his parent, stop this branch here", dirname); } free(namelist[n]); }// end while n-- free(namelist); } // ---------------------------------------------------------------------------- void icon_list_append(icon_list_t *icons, char *dirname, gboolean selected, gboolean recursive) { icodir_t *dir; g_assert(icons != NULL && dirname != NULL); TRACE("'%s' selected:%d recursive:%d", dirname, selected, recursive); splash_update(icons->iconsel->apwal->splash); dir = icodir_list_find(icons->dirs, dirname); if (dir != NULL) { if (dir->parent != NULL) icon_list_fork(icons, dir, selected, recursive); else ERR("dirname:%s already exist", dirname); } else { dir = icodir_new(g_strdup(dirname), selected, recursive); icons->dirs = g_list_insert_sorted(icons->dirs, dir, (GCompareFunc) icodir_compare); ico_list_append(&icons->icos, dir, icons); if (dir->recursive == TRUE) icon_list_append_children(icons, dir); } ico_list_sort(&icons->icos, icons->sortmode); } // ---------------------------------------------------------------------------- void icon_list_reload(icon_list_t *icons, char *dirname) { icodir_t *dir; g_assert(icons != NULL && dirname != NULL); TRACE("reload '%s'", dirname); dir = icodir_list_find(icons->dirs, dirname); if (dir == NULL) ERR("dirname:%s not found", dirname); if (dir->parent != NULL) ERR("dirname:%s is not a root of a dir tree", dirname); ico_list_append(&icons->icos, dir, icons); if (dir->recursive == TRUE) icon_list_append_children(icons, dir); ico_list_sort(&icons->icos, icons->sortmode); } // ---------------------------------------------------------------------------- void icon_list_reload_all_with_splash(icon_list_t *icons) { g_assert(icons != NULL); splash_show(icons->iconsel->apwal->splash); icon_list_reload_all(icons); splash_hide(icons->iconsel->apwal->splash); } // ---------------------------------------------------------------------------- void icon_list_reload_all(icon_list_t *icons) { GList *hamster; icon_dir_t *icon_dir; g_assert(icons != NULL); // use a little trick here. As the dir list is suspectible to change during // the loop, use the list of dirs owned by iconsel for the loop (which will // not change). hamster = g_list_first(icons->iconsel->apwal->iconsel_pref->icon_dirs); while (hamster != NULL) { icon_dir = (icon_dir_t*) hamster->data; icon_list_reload(icons, icon_dir->path); hamster = g_list_next(hamster); } } // ---------------------------------------------------------------------------- void icon_list_remove_children(icon_list_t *icons, icodir_t *dir) { GList *hamster; icodir_t *childdir; g_assert(icons != NULL && dir != NULL); g_assert(dir->recursive == TRUE); if (dir->children == NULL) return; TRACE("%s", dir->path); //hamster = icodir_list_find_with_parent(dir->children, dir); hamster = g_list_first(dir->children); while (hamster != NULL) { childdir = hamster->data; TRACE("parent:%p, childdir:%p", dir, childdir); icon_list_remove_children(icons, childdir); ico_list_remove(&icons->icos, childdir, icons); icons->dirs = g_list_remove(icons->dirs, childdir); hamster = g_list_next(hamster); icodir_free(childdir); //hamster = icodir_list_find_with_parent(dir->children, dir); } g_list_free(dir->children); dir->children = NULL; } // ---------------------------------------------------------------------------- void icon_list_remove(icon_list_t *icons, char *dirname) { icodir_t *dir; g_assert(icons != NULL && dirname != NULL); TRACE("'%s'", dirname); dir = icodir_list_find(icons->dirs, dirname); if (dir == NULL) ERR("dirname:%s not exist", dirname); if (dir->recursive == TRUE) icon_list_remove_children(icons, dir); ico_list_remove(&icons->icos, dir, icons); icons->dirs = g_list_remove(icons->dirs, dir); icodir_free(dir); } // ---------------------------------------------------------------------------- void icon_list_modify_with_splash(icon_list_t *icons, char *dirname, char *newdirname) { g_assert(icons != NULL); splash_show(icons->iconsel->apwal->splash); icon_list_modify(icons, dirname, newdirname); splash_hide(icons->iconsel->apwal->splash); } // ---------------------------------------------------------------------------- void icon_list_modify(icon_list_t *icons, char *dirname, char *newdirname) { icodir_t *dir; gboolean selected, recursive; g_assert(icons != NULL && dirname != NULL && newdirname != NULL); TRACE("old:'%s', new:'%s'", dirname, newdirname); dir = icodir_list_find(icons->dirs, dirname); if (dir == NULL) ERR("dirname:%s not exist, newdirname:%s", dirname, newdirname); recursive = dir->recursive; selected = dir->selected; icon_list_remove(icons, dirname); icon_list_append(icons, newdirname, selected, recursive); } // ---------------------------------------------------------------------------- void icon_list_fork(icon_list_t *icons, icodir_t *dir, gboolean selected, gboolean recursive) { gint len1, len2; g_assert(icons != NULL && dir != NULL); g_assert(dir->parent != NULL); TRACE("'%s'", dir->path); // remove link with parent. you are now a grown up people my child... len1 = g_list_length(dir->parent->children); dir->parent->children = g_list_remove(dir->parent->children, dir); len2 = g_list_length(dir->parent->children); if (len2 != len1 - 1) ERR("remove from dir->parent->children, dir:%s, parent:%s, " "len1:%d len2:%d", dir->path, dir->parent->path, len1, len2); dir->parent = NULL; // set recursive and selected properties if (dir->recursive != recursive) icon_list_set_recursive(icons, dir->path, recursive); if (dir->selected != selected) icon_list_set_selected(icons, dir->path, selected); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void icon_list_set_selected_children(icon_list_t *icons, icodir_t *dir, gboolean selected) { GList *hamster; icodir_t *childdir; g_assert(icons != NULL && dir != NULL); TRACE("dir->selected:%d, selected:%d", dir->selected, selected); hamster = g_list_first(dir->children); while (hamster) { childdir = hamster->data; childdir->selected = selected; icon_list_set_selected_children(icons, childdir, selected); hamster = g_list_next(hamster); } } // ---------------------------------------------------------------------------- void icon_list_set_selected(icon_list_t *icons, char *dirname, gboolean selected) { icodir_t *dir; g_assert(icons != NULL && dirname != NULL); TRACE("%s", ""); dir = icodir_list_find(icons->dirs, dirname); if (dir == NULL) ERR("dirname:%s not exist", dirname); if (dir->selected == selected) ERR("dirname:%s, dir->selected:%d == selected:%d", dirname, dir->selected, selected); dir->selected = selected; if (dir->recursive == TRUE) icon_list_set_selected_children(icons, dir, selected); } // ---------------------------------------------------------------------------- void icon_list_set_recursive_with_splash(icon_list_t *icons, char *dirname, gboolean recursive) { g_assert(icons != NULL); splash_show(icons->iconsel->apwal->splash); icon_list_set_recursive(icons, dirname, recursive); splash_hide(icons->iconsel->apwal->splash); } // ---------------------------------------------------------------------------- void icon_list_set_recursive(icon_list_t *icons, char *dirname, gboolean recursive) { icodir_t *dir; g_assert(icons != NULL && dirname != NULL); dir = icodir_list_find(icons->dirs, dirname); if (dir == NULL) ERR("dirname:%s not exist", dirname); if (dir->recursive == recursive) ERR("dirname:%s, dir->recursive:%d == recursive:%d", dirname, dir->recursive, recursive); if (recursive == TRUE) { dir->recursive = recursive; icon_list_append_children(icons, dir); } else { icon_list_remove_children(icons, dir); dir->recursive = recursive; } } // ---------------------------------------------------------------------------- void icon_list_select (icon_list_t *icons, gboolean (*select_func)(ico_t *ico, void *data), void *data) { GList *hamster; ico_t *ico; icodir_t *dir; g_assert(icons != NULL && select_func != NULL); hamster = g_list_first(icons->dirs); while (hamster != NULL) { dir = hamster->data; dir->count_selected = 0; hamster = g_list_next(hamster); } hamster = g_list_first(icons->icos); while (hamster != NULL) { ico = hamster->data; if (ico->dir->selected == FALSE) ico->selected = FALSE; else ico->selected = select_func(ico, data); if (ico->selected == TRUE) ico->dir->count_selected++; hamster = g_list_next(hamster); } } // ---------------------------------------------------------------------------- ico_t *icon_list_find(icon_list_t *icons, char *path, char *name) { GList *hamster; ico_t *ico; icodir_t *dir; g_assert(icons != NULL && path != NULL && name != NULL); dir = icodir_list_find(icons->dirs, path); if (dir == NULL) return NULL; hamster = g_list_first(icons->icos); while (hamster != NULL) { ico = hamster->data; if (ico->dir == dir) if (strcmp(ico->name, name) == 0) break; hamster = g_list_next(hamster); } if (hamster == NULL) return NULL; return ico; } // ---------------------------------------------------------------------------- icodir_t *icon_list_find_path(icon_list_t *icons, char *path) { g_assert(icons != NULL && path != NULL); return icodir_list_find(icons->dirs, path); } // ---------------------------------------------------------------------------- void icon_list_set_sortmode(icon_list_t *icons, int sortmode) { g_assert(icons != NULL); icons->sortmode = sortmode; ico_list_sort(&icons->icos, icons->sortmode); } // ---------------------------------------------------------------------------- gint icon_list_selected_count(icon_list_t *icons) { ico_t *ico; GList *hamster; int count; g_assert(icons != NULL); count = 0; hamster = g_list_first(icons->icos); while (hamster != NULL) { ico = hamster->data; if (ico->selected) count++; hamster = g_list_next(hamster); } return count; } // ---------------------------------------------------------------------------- ico_t *icon_list_selected_nth(icon_list_t *icons, int nth) { ico_t *ico; GList *hamster; int i; g_assert(icons != NULL); i = 0; hamster = g_list_first(icons->icos); while (hamster != NULL && i != nth) { ico = hamster->data; if (ico->selected == TRUE) i++; hamster = g_list_next(hamster); } if (hamster == NULL) return NULL; return ico; } // ---------------------------------------------------------------------------- GdkPixbuf *icon_list_pixbuf(icon_list_t *icons) { GList *hamster; gint i, count; gint width; gint height; ico_t *ico; gint index_of_selected; g_assert(icons != NULL); count = icon_list_selected_count(icons); width = icons->icon_per_row * 48; height = ((count / icons->icon_per_row) + 1) * 48; if (icons->pixbuf != NULL) { if ( ! (gdk_pixbuf_get_width(icons->pixbuf) == width && gdk_pixbuf_get_height(icons->pixbuf) == height)) { g_object_unref(icons->pixbuf); icons->pixbuf = NULL; } } if (icons->pixbuf == NULL) icons->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB/*colorspace*/, TRUE/*has_alpha*/, 8/*bits_per_sample*/, width, height); gdk_pixbuf_fill(icons->pixbuf, 0x00000000); i = 0; index_of_selected = -1; hamster = g_list_first(icons->icos); while (hamster) { ico = hamster->data; if (ico->selected == TRUE) { // be carful here, width and height are use but for icon pixbuf now width = gdk_pixbuf_get_width(ico->pixbuf); height = gdk_pixbuf_get_height(ico->pixbuf); width = width < 48 ? width : 48; height= height< 48 ? height: 48; gdk_pixbuf_copy_area(ico->pixbuf/*src_pixbuf*/, 0/*src_x*/, 0/*src_y*/, width, height, icons->pixbuf, (i % icons->icon_per_row) * 48/*x*/, (i / icons->icon_per_row) * 48/*y*/); if (icons->selected_icon == ico) index_of_selected = i; i++; } hamster = g_list_next(hamster); } // end while hamster if (i != count) ERR("i:%d, count:%d", i, count); TRACE("i:%d, count:%d", i, count); return icons->pixbuf; } // ---------------------------------------------------------------------------- void icon_list_set_selected_icon_from_xy(icon_list_t *icons, int x, int y) { int nth; g_assert(icons != NULL); nth = (y * icons->icon_per_row) + x + 1/*first nth is 1 and not 0*/; icons->selected_icon = icon_list_selected_nth(icons, nth); if (icons->selected_icon == NULL) TRACE("%s", "no icon selected"); else TRACE("name:%s", icons->selected_icon->name); } // ---------------------------------------------------------------------------- void icon_list_set_selected_icon_from_filename(icon_list_t *icons, const char *file) { char *dirname, *iconame; g_assert(icons != NULL); if (file == NULL) icons->selected_icon = NULL; else { dirname = g_path_get_dirname(file); iconame = g_path_get_basename(file); icons->selected_icon = icon_list_find(icons, dirname, iconame); g_free(dirname); g_free(iconame); } if (icons->selected_icon == NULL) TRACE("NULL selected, filename:%s not found", file); else TRACE("name:%s", icons->selected_icon->name); } // ---------------------------------------------------------------------------- void icon_list_set_selected_icon(icon_list_t *icons, ico_t *ico) { g_assert(icons != NULL); icons->selected_icon = ico; } // ---------------------------------------------------------------------------- ico_t *icon_list_get_selected_icon(icon_list_t *icons) { g_assert(icons != NULL); return icons->selected_icon; } // ---------------------------------------------------------------------------- gchar *icon_list_get_selected_icon_filename(icon_list_t *icons) { gchar *filename; g_assert(icons != NULL); if (icons->selected_icon == NULL) { TRACE("%s", "icon_list_get_selected_icon_filename() no icon selected"); return NULL; } filename = ico_get_full_filename(icons->selected_icon); TRACE("icon_list_get_selected_icon_filename() file:%s", filename); return filename; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // = 0 : not selected // != 0 : selected, sorted and allocated in namelist by scandir // do many check, if the check failed then return 0, else go to the next check. // arrive at the end, return 1 because the file success all the tests. static int icon_list_scandir_icon(const struct dirent *de) { //icon_list_t *icons = scandir_context.icons; g_assert(de != NULL); // do not select . and .. directories if ((!strcmp(".", de->d_name)) || (!strcmp("..", de->d_name))) { //TRACE("ico_select() 1 de->d_name:%s", de->d_name); return 0; } // if file is a directory, then don't select it if (de->d_type == DT_DIR) { //TRACE("ico_select() 2 de->d_name:%s", de->d_name); return 0; } // if not return before here, then the filename is ok. return 1. return 1; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // = 0 : not selected // != 0 : selected, sorted and allocated in namelist by scandir static int icon_list_scandir_path(const struct dirent *de) { g_assert(de != NULL); // not select . & .. if ((!strcmp(".", de->d_name)) || (!strcmp("..", de->d_name))) { return 0; } // select directories only if (de->d_type != DT_DIR) { return 0; } //de->d_type; //de->d_name; return 1; } // ---------------------------------------------------------------------------- void icon_list_print_not_selected(icon_list_t *icons) //debug stuff { GList *hamster; ico_t *ico; hamster = icons->icos; while (hamster != NULL) { ico = hamster->data; if (ico->selected == FALSE) TRACE("!selected: %dx%d, name:%s, dir:%s", ico->width, ico->height, ico->name, ico->dir->path); hamster = g_list_next(hamster); } } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/iconlist.h0000644000175000017500000001423707775572246014340 0ustar pebpeb00000000000000/* iconlist.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #ifndef ICONLIST__H #define ICONLIST__H #include "common.h" // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- typedef struct icodir_t { gchar *path; gint count_total; // number of ico_t linked to this dir gint count_selected; // number of ico_t linked and selected gboolean recursive; // recursive gboolean selected; // struct icodir_t *parent; // GList *children; // icodir_t children (NOT ico_t) } icodir_t; icodir_t* icodir_new (gchar *dirname, gboolean sel, gboolean rec); icodir_t* icodir_new_child(gchar *dirname, gboolean sel, gboolean rec, icodir_t *parent); void icodir_free (icodir_t *icodir); gint icodir_compare (icodir_t *a, icodir_t *b); gint icodir_count_total_rec (icodir_t *dir); gint icodir_count_selected_rec(icodir_t *dir); icodir_t *icodir_list_find(GList *dirs, char *dirname); GList *icodir_list_find_with_parent(GList *dirs, icodir_t *parentdir); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- typedef struct ico_t { gchar *name; icodir_t *dir; GdkPixbuf *pixbuf; gint width; gint height; gboolean selected; } ico_t; ico_t* ico_new(icodir_t *dir, gchar *iconame); void ico_free(ico_t *ico); gint ico_compare_by_name(ico_t *a, ico_t *b); gint ico_compare_by_path(ico_t *a, ico_t *b); char * ico_get_full_filename(ico_t *ico); ico_t* ico_list_find_icon(GList *icos, icodir_t *dir, char *ico_name); struct icon_list_t; ico_t* ico_list_try_select_icon(icodir_t *dir, char *ico_name, struct icon_list_t *icons); void ico_list_append(GList **icos, icodir_t *dir, struct icon_list_t *icons); void ico_list_remove(GList **icos, icodir_t *dir, struct icon_list_t *icons); void ico_list_sort(GList **icos, gint sortmode); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #define ICONSEL_SORT_NAME 1 #define ICONSEL_SORT_PATH 2 #define ICONSEL_SORT_LAST 2 #define ICONSEL_SORT_DEFAULT 1 typedef struct icon_list_t { struct icon_selection_t *iconsel; GList *dirs; GList *icos; gint sortmode; GdkPixbuf *pixbuf; ico_t *selected_icon; gint icon_per_row; } icon_list_t; icon_list_t * icon_list_new (struct icon_selection_t *iconsel); void icon_list_free (icon_list_t *icons); void icon_list_set_width (icon_list_t *icons, int icon_per_row); void icon_list_fork (icon_list_t *icons, icodir_t *dir, gboolean selected, gboolean recursive); void icon_list_append_children (icon_list_t *icons, icodir_t *dir); void icon_list_append (icon_list_t *icons, char *dirname, gboolean selected, gboolean recursive); void icon_list_reload (icon_list_t *icons, char *dirname); void icon_list_reload_all (icon_list_t *icons); void icon_list_reload_all_with_splash(icon_list_t *icons); void icon_list_remove_children (icon_list_t *icons, icodir_t *dir); void icon_list_remove (icon_list_t *icons, char *dirname); void icon_list_modify (icon_list_t *icons, char *dirname, char *newdirname); void icon_list_modify_with_splash(icon_list_t *icons, char *dirname, char *newdirname); void icon_list_set_selected_children(icon_list_t *icons, icodir_t *dir, gboolean selected); void icon_list_set_selected (icon_list_t *icons, char *dirname, gboolean selected); void icon_list_set_selected_icon(icon_list_t *icons, ico_t *ico); void icon_list_set_recursive (icon_list_t *icons, char *dirname, gboolean recursive); void icon_list_set_recursive_with_splash (icon_list_t *icons, char *dirname, gboolean recursive); void icon_list_select (icon_list_t *icons, gboolean (*select_func)(ico_t *dir, void *data), void *data); ico_t * icon_list_find (icon_list_t *icons, char *path, char *name); icodir_t * icon_list_find_path (icon_list_t *icons, char *path); void icon_list_set_sortmode (icon_list_t *icons, int sortmode); gint icon_list_selected_count (icon_list_t *icons); ico_t * icon_list_selected_nth (icon_list_t *icons, int nth); GdkPixbuf * icon_list_pixbuf(icon_list_t *icons); void icon_list_set_selected_icon_from_xy(icon_list_t *icons, int x, int y); void icon_list_set_selected_icon_from_filename(icon_list_t *icons, const char *file); ico_t * icon_list_get_selected_icon(icon_list_t *icons); gchar * icon_list_get_selected_icon_filename(icon_list_t *icons); void icon_list_print_not_selected(icon_list_t *icons); //debug stuff #endif /*ICONLIST__H*/ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/iconpool.c0000644000175000017500000000652110161361701014275 0ustar pebpeb00000000000000/* iconpool.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* NOT USED AT THE MOMENT */ /* NOT USED AT THE MOMENT */ #include "common.h" #include // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #define ICONPOOL_MAXTHREAD 3 #define ICONPOOL_TASK_START 0x1000 #define ICONPOOL_ADD_FOLDER (ICONPOOL_TASK_START+0) #define ICONPOOL_DEL_FOLDER (ICONPOOL_TASK_START+1) #define ICONPOOL_ADD_ICON (ICONPOOL_TASK_START+2) #define ICONPOOL_DEL_ICON (ICONPOOL_TASK_START+3) // ??? #define ICONPOOL_TASK_END (ICONPOOL_TASK_START+3) typedef struct iconpool_t { GThreadPool *threadpool; GError *gerror; } iconpool_t; typedef struct iconpool_task_t { gint type; union { char c; int i; } data; } iconpool_task_t; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void iconpool_do(gpointer data, gpointer userdata) { TRACE("hello %d, %p", GPOINTER_TO_INT(data), g_thread_self()); sleep(1); } // ---------------------------------------------------------------------------- iconpool_t* iconpool_new() { iconpool_t *iconpl; iconpl = (iconpool_t*) malloc(sizeof(iconpool_t)); g_assert(iconpl != NULL); iconpl->gerror = NULL; iconpl->threadpool = g_thread_pool_new(iconpool_do, GINT_TO_POINTER(123456), ICONPOOL_MAXTHREAD/*maxthread*/, TRUE/*excusive*/, &iconpl->gerror); if (iconpl->gerror != NULL) ERR("%s", "g_thread_pool_new failed"); return iconpl; } // ---------------------------------------------------------------------------- void iconpool_free(iconpool_t *iconpl) { g_thread_pool_free(iconpl->threadpool, FALSE/*imediate*/, TRUE/*wait*/); free(iconpl); } // ---------------------------------------------------------------------------- void iconpool_push(iconpool_t *iconpl, iconpool_task_t *task) { g_assert(!task); g_assert(task->type>=ICONPOOL_TASK_START && task->type<=ICONPOOL_TASK_END); } int main(int argc, char **argv) { int i; iconpool_t *iconpl; GError *e = NULL; //gtk_init(&argc, &argv); g_thread_init(NULL); iconpl = iconpool_new(); for(i=123456; i<123466; i++) { g_thread_pool_push(iconpl->threadpool, GINT_TO_POINTER(i), &e); TRACE("%p", e); } iconpool_free(iconpl); return 0; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/iconpool.h0000644000175000017500000000254107775104113014311 0ustar pebpeb00000000000000/* iconpool.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #ifndef ICONPOOL__H #define ICONPOOL__H #include "common.h" // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #endif /*ICONPOOL__H*/ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/iconsel.c0000644000175000017500000003300110003707534014103 0ustar pebpeb00000000000000/* iconsel.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include #include #include #include "iconsel_private.h" #define _GNU_SOURCE 1 #include //#ifndef FNM_CASEFOLD // case insensitive but is not defined... ? //#define FNM_CASEFOLD (1 << 4) //#endif // ---------------------------------------------------------------------------- icon_dir_t *icon_dir_new(gchar *path, gboolean selected, gboolean recursive) { icon_dir_t *icon_dir; g_assert(path != NULL); icon_dir = (icon_dir_t *) malloc(sizeof(icon_dir_t)); g_assert(icon_dir != NULL); icon_dir->path = path; icon_dir->selected = selected; icon_dir->recursive = recursive; return icon_dir; } // ---------------------------------------------------------------------------- void icon_dir_free(icon_dir_t *icon_dir) { g_assert(icon_dir != NULL); if (icon_dir->path) g_free(icon_dir->path); g_free(icon_dir); } // ---------------------------------------------------------------------------- gint icon_dir_compare(icon_dir_t *a, icon_dir_t *b) { g_assert(a != NULL && b != NULL); return strcmp(a->path, b->path); } // ---------------------------------------------------------------------------- void icon_dir_list_append(GList **list, icon_dir_t *dir) { g_assert(list != NULL && dir != NULL); *list = g_list_insert_sorted(*list, dir, (GCompareFunc) icon_dir_compare); } // ---------------------------------------------------------------------------- icon_dir_t * icon_dir_list_find(GList *list, char *olddir) { GList *hamster; icon_dir_t *dir; g_assert(olddir != NULL); hamster = g_list_first(list); while(hamster != NULL) { dir = hamster->data; if (strcmp(dir->path, olddir) == 0) break; hamster = g_list_next(hamster); } if (hamster == NULL) return NULL; else return dir; } // ---------------------------------------------------------------------------- void icon_dir_list_remove(GList **list, char *olddir) { GList *hamster; icon_dir_t *dir; g_assert(list != NULL && olddir != NULL); hamster = g_list_first(*list); while(hamster != NULL) { dir = hamster->data; if (strcmp(dir->path, olddir) == 0) break; hamster = g_list_next(hamster); } if (hamster == NULL) ERR("icon_dir_list_remove() olddir:%s not found", olddir); *list = g_list_remove(*list, dir); icon_dir_free(dir); } // ---------------------------------------------------------------------------- void icon_dir_list_modify(GList **list, char *olddir, char *newdir) { GList *hamster; icon_dir_t *dir; g_assert(list != NULL && olddir != NULL && newdir != NULL); hamster = g_list_first(*list); while(hamster != NULL) { dir = hamster->data; if (strcmp(dir->path, newdir) == 0) break; hamster = g_list_next(hamster); } if (hamster != NULL) { WARN("icon_dir_list_modify() olddir:%s, newdir:%s, " "newdir already exist", olddir, newdir); return; } hamster = g_list_first(*list); while(hamster != NULL) { dir = hamster->data; if (strcmp(dir->path, olddir) == 0) break; hamster = g_list_next(hamster); } if (hamster == NULL) ERR("icon_dir_list_modify() olddir:%s not found", olddir); g_free(dir->path); dir->path = g_strdup(newdir); *list = g_list_sort(*list, (GCompareFunc) icon_dir_compare); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- file_ext_t *file_ext_new(gchar *extension, gboolean selected) { file_ext_t *file_ext; g_assert(extension != NULL); file_ext = (file_ext_t *) malloc(sizeof(file_ext_t)); g_assert(file_ext != NULL); file_ext->extension = extension; file_ext->selected = selected; return file_ext; } // ---------------------------------------------------------------------------- void file_ext_free(file_ext_t *file_ext) { if (file_ext->extension) g_free(file_ext->extension); g_free(file_ext); } // ---------------------------------------------------------------------------- gint file_ext_compare(file_ext_t *a, file_ext_t *b) { g_assert(a != NULL && b != NULL); return strcmp(a->extension, b->extension); } // ---------------------------------------------------------------------------- void file_ext_list_append(GList **list, file_ext_t *ext) { g_assert(list != NULL && ext != NULL); *list = g_list_insert_sorted(*list, ext, (GCompareFunc) file_ext_compare); } // ---------------------------------------------------------------------------- file_ext_t * file_ext_list_find(GList *list, char *oldext) { GList *hamster; file_ext_t *ext; g_assert(oldext != NULL); hamster = g_list_first(list); while(hamster != NULL) { ext = hamster->data; if (strcmp(ext->extension, oldext) == 0) break; hamster = g_list_next(hamster); } if (hamster == NULL) return NULL; else return ext; } // ---------------------------------------------------------------------------- void file_ext_list_remove(GList **list, char *oldext) { GList *hamster; file_ext_t *ext; g_assert(list != NULL && oldext != NULL); hamster = g_list_first(*list); while(hamster != NULL) { ext = hamster->data; if (strcmp(ext->extension, oldext) == 0) break; hamster = g_list_next(hamster); } if (hamster == NULL) ERR("file_ext_list_remove() oldext:%s not found", oldext); *list = g_list_remove(*list, ext); file_ext_free(ext); } // ---------------------------------------------------------------------------- void file_ext_list_modify(GList **list, char *oldext, char *newext) { GList *hamster; file_ext_t *ext; g_assert(list != NULL && oldext != NULL && newext != NULL); hamster = g_list_first(*list); while(hamster != NULL) { ext = hamster->data; if (strcmp(ext->extension, newext) == 0) break; hamster = g_list_next(hamster); } if (hamster != NULL) { WARN("file_ext_list_modify() oldext:%s, newext:%s, " "newext already exist", oldext, newext); return; } hamster = g_list_first(*list); while(hamster != NULL) { ext = hamster->data; if (strcmp(ext->extension, oldext) == 0) break; hamster = g_list_next(hamster); } if (hamster == NULL) ERR("file_ext_list_modify() oldext:%s not found", oldext); g_free(ext->extension); ext->extension = g_strdup(newext); *list = g_list_sort(*list, (GCompareFunc) file_ext_compare); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- iconsel_pref_t * iconsel_pref_new(GList *icon_dirs, GList *file_exts, gboolean eq48, gboolean lt48, gboolean gt48, gint sort) { iconsel_pref_t *ispref; TRACE("%s", ""); ispref = (iconsel_pref_t *) malloc(sizeof(iconsel_pref_t)); g_assert(ispref != NULL); ispref->icon_dirs = icon_dirs; ispref->file_exts = file_exts; ispref->select_48 = eq48; ispref->select_lt48 = lt48; ispref->select_gt48 = gt48; if (sort < 0 || sort > ICONSEL_SORT_LAST) { WARN("sort_mode:%d invalid, set to default:%d", sort, ICONSEL_SORT_DEFAULT); sort = ICONSEL_SORT_DEFAULT; } ispref->sort_mode = sort; return ispref; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- icon_selection_t* icon_selection_new(struct apwalapp_t *apwal) { icon_selection_t *iconsel; g_assert(apwal != NULL); TRACE("%s", ""); iconsel = (icon_selection_t *) malloc(sizeof(icon_selection_t)); g_assert(iconsel != NULL); iconsel->apwal = apwal; iconsel->filter = g_strdup("*"); iconsel->image = NULL; iconsel->dblclick_timer = NULL; iconsel->dblclick_selected_timer = NULL; iconsel->never_refreshed = TRUE; iconsel->icons = icon_list_new(iconsel); iconsel_build_interface(iconsel); return iconsel; } // ---------------------------------------------------------------------------- void icon_selection_load_icons_with_splash(icon_selection_t *iconsel) { GList *hamster; icon_dir_t *icon_dir; g_assert(iconsel != NULL); splash_show(iconsel->apwal->splash); hamster = iconsel->apwal->iconsel_pref->icon_dirs; while(hamster != NULL) { splash_update(iconsel->apwal->splash); icon_dir = hamster->data; icon_list_append(iconsel->icons, icon_dir->path, icon_dir->selected, icon_dir->recursive); hamster = g_list_next(hamster); } splash_hide(iconsel->apwal->splash); iconsel_path_refresh(iconsel); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // usage: icon_list_select(iconsel->icons, iconsel_select_func, iconsel); gboolean iconsel_select_func(ico_t *ico, void *data) { gboolean selected; int cc; icon_selection_t *iconsel = (icon_selection_t *) data; g_assert(ico != NULL && iconsel != NULL); selected = TRUE; while (1) // begin of a 'block' which can be aborted by a break { #if 0 GList *ext_hamster; file_ext_t *ext; // check if the size is selected if ((iconsel->ispref->select_48 == TRUE) && (ico->width == 48) && (ico->height == 48)) selected = TRUE; else if ((iconsel->ispref->select_gt48 == TRUE) && ((ico->width > 48) || (ico->height > 48))) selected = TRUE; else if ((iconsel->ispref->select_lt48 == TRUE) && ((ico->width < 48) || (ico->height < 48))) selected = TRUE; else { selected = FALSE; break; } // check if the name is matching one of the patterns // if name matches pattern then go out the loop with cc=0 // if name don't match any pattern then cc!=0 at the end of the loop // after the loop, if cc!=0 then don't select the name and return 0 ext_hamster = g_list_first(iconsel->ispref->file_exts); while(ext_hamster != NULL) { ext = ext_hamster->data; if (ext->selected == TRUE) { cc = fnmatch(ext->extension, ico->name, FNM_CASEFOLD); //TRACE("ext:%s, name:%s, cc:%d", ext->extension, ico->name, cc); if (cc == 0) // success break; if ((cc != 0) && (cc != FNM_NOMATCH)) // error during match WARN("fnmatch, ext:%s, name:%s, E:%d", ext->extension, ico->name, cc); } ext_hamster = g_list_next(ext_hamster); } //end while ext if (cc != 0 || ext_hamster == NULL) // not match { selected = FALSE; break; } #endif // check if the name match the filter cc = fnmatch(iconsel->filter, ico->name, FNM_CASEFOLD); if (cc != 0) { selected = FALSE; if (cc != FNM_NOMATCH) WARN("fnmatch filter:%s, name:%s, E:%d", iconsel->filter, ico->name, cc); break; } break; // end of the 'block' } // end of the 'block' return selected; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void iconsel_set_filename(icon_selection_t *iconsel, const char *filename) { g_assert(iconsel != NULL); TRACE("%s", ""); icon_list_set_selected_icon_from_filename(iconsel->icons, filename); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- char *iconsel_get_filename(icon_selection_t *iconsel) { g_assert(iconsel != NULL); TRACE("%s", ""); return icon_list_get_selected_icon_filename(iconsel->icons); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/iconsel.h0000644000175000017500000001123710003707535014120 0ustar pebpeb00000000000000/* iconsel.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #ifndef ICONSEL__H #define ICONSEL__H #include "common.h" // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- typedef struct icon_dir_t { gchar *path; gboolean selected; gboolean recursive; } icon_dir_t; icon_dir_t *icon_dir_new(gchar *path, gboolean selected, gboolean recursive); void icon_dir_free(icon_dir_t *icon_dir); gint icon_dir_compare(icon_dir_t *a, icon_dir_t *b); void icon_dir_list_append(GList **list, icon_dir_t *dir); icon_dir_t *icon_dir_list_find(GList *list, char *olddir); void icon_dir_list_remove(GList **list, char *olddir); void icon_dir_list_modify(GList **list, char *olddir, char *newdir); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- typedef struct file_ext_t { gchar *extension; gboolean selected; } file_ext_t; file_ext_t *file_ext_new(gchar *extension, gboolean selected); void file_ext_free(file_ext_t *file_ext); gint file_ext_compare(file_ext_t *a, file_ext_t *b); void file_ext_list_append(GList **list, file_ext_t *ext); file_ext_t *file_ext_list_find(GList *list, char *oldext); void file_ext_list_remove(GList **list, char *oldext); void file_ext_list_modify(GList **list, char *oldext, char *newext); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- typedef struct iconsel_pref_t { GList *icon_dirs; GList *file_exts; gboolean select_48; gboolean select_lt48; gboolean select_gt48; gint sort_mode; } iconsel_pref_t; iconsel_pref_t * iconsel_pref_new(GList *icon_dirs, GList *file_exts, gboolean eq48, gboolean lt48, gboolean gt48, gint sort); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- typedef struct icon_selection_t { struct apwalapp_t *apwal; struct icon_list_t *icons; char *filter; GtkWidget *path_tree; GtkWidget *exts_tree; GtkWidget *image; GtkWidget *filter_entry; GtkWidget *filter_btn; gboolean never_refreshed; GdkPixbuf *transparent_pixbuf; GdkPixbuf *pixbuf_open; GtkWidget *selected_frame; GtkWidget *selected_image; GtkWidget *selected_file_label; GtkWidget *selected_path_label; GtkWidget *selected_res_label; GtkWidget *selected_apply_btn; GTimer *dblclick_selected_timer; GTimer *dblclick_timer; gint dblclick_last_x; gint dblclick_last_y; gint scroll_border_width; } icon_selection_t; // ---------------------------------------------------------------------------- icon_selection_t* icon_selection_new(struct apwalapp_t *apwal); void icon_selection_load_icons_with_splash(icon_selection_t *iconsel); gboolean iconsel_select_func(ico_t *ico, void *data); void iconsel_refresh(icon_selection_t *iconsel); void iconsel_refresh_selected(icon_selection_t *iconsel); void iconsel_path_refresh(icon_selection_t *iconsel); void iconsel_set_filename(icon_selection_t *iconsel, const char *filename); char* iconsel_get_filename(icon_selection_t *iconsel); #endif /*ICONSEL__H*/ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/iconsel_interface.c0000644000175000017500000016167510161364353016151 0ustar pebpeb00000000000000/* iconsel_interface.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include "common.h" #include "iconsel_private.h" //void iconsel_reload(icon_selection_t *iconsel); //void iconsel_build_interface(icon_selection_t *iconsel); static void iconsel_build_iconsel(icon_selection_t *iconsel); static void iconsel_build_iconsel_pref(icon_selection_t *iconsel); static void iconsel_48_toggled(GtkToggleButton *chk, icon_selection_t *iconsel); static void iconsel_lt48_toggled(GtkToggleButton *chk, icon_selection_t *iconsel); static void iconsel_gt48_toggled(GtkToggleButton *chk, icon_selection_t *iconsel); static void iconsel_sort_name_clicked(GtkRadioButton *chk, icon_selection_t *iconsel); static void iconsel_sort_path_clicked(GtkRadioButton *chk, icon_selection_t *iconsel); static void iconsel_path_toggled(GtkCellRendererToggle *cell, gchar *path_str, icon_selection_t *iconsel); static void iconsel_path_toggled_rec(GtkCellRendererToggle *cell, gchar *path_str, icon_selection_t *iconsel); static void iconsel_exts_toggled(GtkCellRendererToggle *cell, gchar *path_str, icon_selection_t *iconsel); static void iconsel_path_edited(GtkCellRendererText *cell, gchar *path_str, gchar *newtext, icon_selection_t *iconsel); static void iconsel_exts_edited(GtkCellRendererText *cell, gchar *path_str, gchar *newtext, icon_selection_t *iconsel); static void iconsel_path_refresh_rec(icon_selection_t *iconsel, GtkTreeModel *model, icodir_t *dir, GtkTreeIter *parent_iter); static void iconsel_exts_refresh(icon_selection_t *iconsel); static GtkWidget *iconsel_tree_path_new(icon_selection_t *iconsel); static GtkWidget *iconsel_tree_exts_new(icon_selection_t *iconsel); static gboolean iconsel_is_dblclick(icon_selection_t *iconsel, gint x, gint y); static gboolean iconsel_release_event(GtkWidget *widget, GdkEventButton *event, icon_selection_t *iconsel); static gboolean iconsel_selected_is_dblclick(icon_selection_t *iconsel); static gboolean iconsel_selected_release_event(GtkWidget *widget, GdkEventButton *event, icon_selection_t *iconsel); void iconsel_selected_apply_btn_clicked(GtkButton *widget, icon_selection_t *iconsel); static void iconsel_filter_entry_changed(GtkWidget *entry, icon_selection_t *iconsel); static void iconsel_path_add_clicked(GtkWidget *button, icon_selection_t *iconsel); static void iconsel_exts_add_clicked(GtkWidget *button, icon_selection_t *iconsel); static void iconsel_path_col_clicked(GtkWidget *button, icon_selection_t *iconsel); static void iconsel_path_exp_clicked(GtkWidget *button, icon_selection_t *iconsel); static void iconsel_path_cereimg_clicked(Cereimg *cell, gchar *path_str, icon_selection_t *iconsel); static void tree_column_set_label_and_tooltips(icon_selection_t *iconsel, GtkTreeViewColumn *colunm, char *title, char *tooltips); void iconsel_filter_reset_clicked(GtkButton *widget, icon_selection_t *iconsel); void iconsel_scroll_size_allocate(GtkWidget *scroll, GtkAllocation *alloc, icon_selection_t *iconsel); void iconsel_filesel_compute(const char *olddir, const char *newdir, void *data); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void iconsel_refresh(icon_selection_t *iconsel) { g_assert(iconsel != NULL); TRACE("%s", ""); iconsel_reload(iconsel); iconsel_refresh_selected(iconsel); iconsel_exts_refresh(iconsel); iconsel_path_refresh(iconsel); } // ---------------------------------------------------------------------------- void iconsel_refresh_selected(icon_selection_t *iconsel) { gchar res[256]; ico_t *ico; g_assert(iconsel != NULL); TRACE("%s", ""); ico = icon_list_get_selected_icon(iconsel->icons); if (ico != NULL) { gtk_widget_set_sensitive(iconsel->selected_frame, TRUE); gtk_image_set_from_pixbuf(GTK_IMAGE(iconsel->selected_image), ico->pixbuf); gtk_label_set_text(GTK_LABEL(iconsel->selected_file_label), ico->name); gtk_label_set_text(GTK_LABEL(iconsel->selected_path_label), ico->dir->path); sprintf(res, "initial size: %d x %d", ico->width, ico->height); gtk_label_set_text(GTK_LABEL(iconsel->selected_res_label), res); } else // no app selected { gtk_widget_set_sensitive(iconsel->selected_frame, FALSE); gtk_image_set_from_pixbuf(GTK_IMAGE(iconsel->selected_image), iconsel->transparent_pixbuf); gtk_label_set_text(GTK_LABEL(iconsel->selected_file_label), ""); gtk_label_set_text(GTK_LABEL(iconsel->selected_path_label), ""); gtk_label_set_text(GTK_LABEL(iconsel->selected_res_label), ""); } } // ---------------------------------------------------------------------------- void iconsel_reload(icon_selection_t *iconsel) { GdkPixbuf *pixbuf; g_assert(iconsel != NULL); TRACE("%s", ""); icon_list_select(iconsel->icons, iconsel_select_func, iconsel); pixbuf = icon_list_pixbuf(iconsel->icons); gtk_image_set_from_pixbuf(GTK_IMAGE(iconsel->image), pixbuf); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void iconsel_build_interface(icon_selection_t *iconsel) { // *notebook; // *iconsel_frame; // *iconsel_pref_frame; GdkPixbuf *pix1; g_assert(iconsel != NULL); TRACE("%s", ""); iconsel->transparent_pixbuf = gdk_pixbuf_new_from_apwal("transparent", NULL, NULL); iconsel->pixbuf_open = gdk_pixbuf_new_from_apwal("relief", NULL, NULL); pix1 = gtk_widget_render_icon(iconsel->apwal->window, "gtk-open", GTK_ICON_SIZE_MENU, NULL); gdk_pixbuf_append(iconsel->pixbuf_open, pix1); iconsel_build_iconsel(iconsel); iconsel_build_iconsel_pref(iconsel); iconsel_exts_refresh(iconsel); //iconsel_refresh(iconsel); //gtk_entry_set_text(GTK_ENTRY(iconsel->filter_entry), ""); } // ---------------------------------------------------------------------------- static void iconsel_build_iconsel(icon_selection_t *iconsel) { GtkWidget *iconsel_vbox; //GtkWidget *iconsel->selected_frame; GtkWidget *info_hbox; GtkWidget *info_event_box; //GtkWidget *iconsel->selected_image; GtkWidget *info_lbl_vbox; //GtkWidget *iconsel->selected_file_label; //GtkWidget *iconsel->selected_path_label; //GtkWidget *iconsel->selected_res_label; GtkWidget *info_apply_vbox; //GtkWidget *iconsel->selected_apply_btn; GtkWidget *filter_frame; GtkWidget *filter_hbox; //GtkWidget *filter_entry; //GtkSizeGroup *size_group; GtkWidget *scroll; GtkWidget *event_box; //GtkWidget *image; GtkSizeGroup *sizegrp; // for 'apply' and 'reset' button GtkRequisition requisition; g_assert(iconsel != NULL); g_assert(iconsel->apwal != NULL); g_assert(iconsel->apwal->iconsel_frame != NULL); TRACE("%s", ""); //sizegrp = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); sizegrp = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); // vertical box iconsel iconsel_vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(iconsel->apwal->iconsel_frame), iconsel_vbox); gtk_container_set_border_width(GTK_CONTAINER(iconsel_vbox), 4); gtk_widget_show(iconsel_vbox); // info frame iconsel->selected_frame = gtk_frame_new(" Selected Icon "); gtk_container_set_border_width(GTK_CONTAINER(iconsel->selected_frame), 4); gtk_box_pack_start(GTK_BOX(iconsel_vbox), iconsel->selected_frame, FALSE, FALSE, 0); gtk_widget_show(iconsel->selected_frame); // info horizontal box info_hbox = gtk_hbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(info_hbox), 4); gtk_box_set_spacing(GTK_BOX(info_hbox), 4); gtk_container_add(GTK_CONTAINER(iconsel->selected_frame), info_hbox); gtk_widget_show(info_hbox); // event box selected image info_event_box = gtk_event_box_new(); g_signal_connect(G_OBJECT(info_event_box), "button-release-event", G_CALLBACK(iconsel_selected_release_event), iconsel); gtk_box_pack_start(GTK_BOX(info_hbox), info_event_box, FALSE, FALSE, 0); gtk_widget_show(info_event_box); // info image iconsel->selected_image = gtk_image_new(); gtk_container_add(GTK_CONTAINER(info_event_box), iconsel->selected_image); gtk_widget_show(iconsel->selected_image); // info label vertical box info_lbl_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(info_lbl_vbox), 4); gtk_box_pack_start(GTK_BOX(info_hbox), info_lbl_vbox, FALSE, FALSE, 0); gtk_widget_show(info_lbl_vbox); // info label filename iconsel->selected_file_label = gtk_label_new(NULL); gtk_misc_set_alignment(GTK_MISC(iconsel->selected_file_label), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(info_lbl_vbox), iconsel->selected_file_label, TRUE, TRUE, 0); gtk_widget_show(iconsel->selected_file_label); // info label path iconsel->selected_path_label = gtk_label_new(NULL); gtk_misc_set_alignment(GTK_MISC(iconsel->selected_path_label), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(info_lbl_vbox), iconsel->selected_path_label, TRUE, TRUE, 0); gtk_widget_show(iconsel->selected_path_label); // info label res iconsel->selected_res_label = gtk_label_new(NULL); gtk_misc_set_alignment(GTK_MISC(iconsel->selected_res_label), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(info_lbl_vbox), iconsel->selected_res_label, TRUE, TRUE, 0); gtk_widget_show(iconsel->selected_res_label); // info label vertical box info_apply_vbox = gtk_vbox_new(FALSE, 0); //gtk_container_set_border_width(GTK_CONTAINER(info_apply_vbox), 4); gtk_box_pack_end(GTK_BOX(info_hbox), info_apply_vbox, FALSE, FALSE, 0); gtk_widget_show(info_apply_vbox); // button apply iconsel->selected_apply_btn = gtk_button_new_from_stock(GTK_STOCK_APPLY); g_signal_connect(G_OBJECT(iconsel->selected_apply_btn), "clicked", G_CALLBACK(iconsel_selected_apply_btn_clicked), iconsel); gtk_size_group_add_widget(sizegrp, iconsel->selected_apply_btn); gtk_box_pack_end(GTK_BOX(info_apply_vbox), iconsel->selected_apply_btn, FALSE, FALSE, 0); gtk_tooltips_set_tip(iconsel->apwal->tips, iconsel->selected_apply_btn, "Set the icon for the current selected application", NULL); if (iconsel->apwal->apwal_pref->iconsel_in_a_separate_window == FALSE) gtk_widget_show(iconsel->selected_apply_btn); // filter frame filter_frame = gtk_frame_new(" Filename Filter "); gtk_container_set_border_width(GTK_CONTAINER(filter_frame), 4); gtk_box_pack_start(GTK_BOX(iconsel_vbox), filter_frame, FALSE, FALSE, 0); gtk_widget_show(filter_frame); // horizontal box 'filter' filter_hbox = gtk_hbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(filter_hbox), 4); gtk_box_set_spacing(GTK_BOX(filter_hbox), 4); gtk_container_add(GTK_CONTAINER(filter_frame), filter_hbox); //gtk_box_pack_start(GTK_BOX(iconsel_vbox), filter_hbox, FALSE, FALSE, 0); gtk_widget_show(filter_hbox); // entry 'filter' iconsel->filter_entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(iconsel->filter_entry), iconsel->filter); g_signal_connect(iconsel->filter_entry, "changed", G_CALLBACK(iconsel_filter_entry_changed), iconsel); gtk_box_pack_start(GTK_BOX(filter_hbox), iconsel->filter_entry, TRUE, TRUE, 0); gtk_tooltips_set_tip(iconsel->apwal->tips, iconsel->filter_entry, "Filter the icons displayed, you can use the wildcard '*'.\nFor example 'gnome*' will display the majority of Gnome icons", NULL); gtk_widget_show(iconsel->filter_entry); // button reset filter iconsel->filter_btn = gtk_button_new_with_label("All Icons"); g_signal_connect(G_OBJECT(iconsel->filter_btn), "clicked", G_CALLBACK(iconsel_filter_reset_clicked), iconsel); gtk_size_group_add_widget(sizegrp, iconsel->filter_btn); gtk_box_pack_end(GTK_BOX(filter_hbox), iconsel->filter_btn, FALSE, FALSE, 0); gtk_tooltips_set_tip(iconsel->apwal->tips, iconsel->filter_btn, "Reset the filter and show all the icons are visible", NULL); gtk_widget_show(iconsel->filter_btn); // scrolled window scroll = gtk_scrolled_window_new(NULL, NULL); //gtk_container_set_border_width(GTK_CONTAINER(scroll), 4); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); g_signal_connect(G_OBJECT(scroll), "size-allocate", G_CALLBACK(iconsel_scroll_size_allocate), iconsel); gtk_box_pack_start(GTK_BOX(iconsel_vbox), scroll, TRUE, TRUE, 0); // ./!\.IMPORTANT./!\. // the scrolled windows is NOT showed before the image loaded // because of a problem with the vertical scrollbar :( // so the scrolled window is actually show with the gtk_widget_show_all // of the main window in apwalapp.c if (iconsel->apwal->apwal_pref->iconsel_in_a_separate_window) gtk_widget_show(scroll); // event box event_box = gtk_event_box_new(); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), event_box); g_signal_connect(G_OBJECT(event_box), "button-release-event", G_CALLBACK(iconsel_release_event), iconsel); gtk_widget_show(event_box); // image iconsel->image = gtk_image_new(); gtk_misc_set_alignment(GTK_MISC(iconsel->image), 0.0, 0.0); gtk_container_add(GTK_CONTAINER(event_box), iconsel->image); gtk_widget_show(iconsel->image); // get the size of the scoll widget. it is the size of it border. gtk_widget_size_request(scroll, &requisition); iconsel->scroll_border_width = requisition.width; TRACE("scroll_border_width: %d", iconsel->scroll_border_width); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- static void iconsel_build_iconsel_pref(icon_selection_t *iconsel) { GtkWidget *selpref_vbox; GtkWidget *path_frame; GtkWidget *path_vbox; GtkWidget *path_scroll; //GtkWidget *path_tree; GtkWidget *path_hbox; GtkSizeGroup *sizegrp; GtkWidget *path_btn_add; GtkWidget *path_btn_col; GtkWidget *path_btn_exp; //GtkWidget *path_btn_notsel; GtkWidget *hbox; GtkWidget *vbox; GtkWidget *option_frame; GtkWidget *option_vbox; GtkWidget *chk0; GtkWidget *chk1; GtkWidget *chk2; GtkWidget *sort_frame; GtkWidget *sort_vbox; GSList *sort_grp; GtkWidget *sort_chk0; GtkWidget *sort_chk1; GtkWidget *vbox2; GtkWidget *exts_frame; GtkWidget *exts_vbox; GtkWidget *exts_scroll; //GtkWidget *exts_tree; GtkWidget *exts_btn_add; g_assert(iconsel != NULL); g_assert(iconsel->apwal != NULL); g_assert(iconsel->apwal->iconsel_pref_frame != NULL); TRACE("%s", ""); // horizontal box selpref_vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(iconsel->apwal->iconsel_pref_frame), selpref_vbox); gtk_widget_show(selpref_vbox); // pixmap path frame path_frame = gtk_frame_new(" Pixmap Path "); gtk_container_set_border_width(GTK_CONTAINER(path_frame), 4); gtk_box_pack_end(GTK_BOX(selpref_vbox), path_frame, TRUE, TRUE, 0); gtk_widget_show(path_frame); // vertical box 'path' path_vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(path_frame), path_vbox); gtk_container_set_border_width(GTK_CONTAINER(path_vbox), 4); gtk_widget_show(path_vbox); // scrolled for path treeview path_scroll = gtk_scrolled_window_new(NULL, NULL); //gtk_container_set_border_width(GTK_CONTAINER(path_scroll), 4); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(path_scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(path_vbox), path_scroll, TRUE, TRUE, 0); gtk_widget_show(path_scroll); // treeview 'pixmap path' iconsel->path_tree = iconsel_tree_path_new(iconsel); //gtk_box_pack_start(GTK_BOX(path_vbox), iconsel->path_tree, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(path_scroll), iconsel->path_tree); gtk_widget_show(iconsel->path_tree); // vertical box 'exts' path_hbox = gtk_hbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(path_hbox), 4); gtk_box_set_spacing(GTK_BOX(path_hbox), 4); gtk_box_pack_start(GTK_BOX(path_vbox), path_hbox, FALSE, FALSE, 0); gtk_widget_show(path_hbox); sizegrp = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); // button add path path_btn_add = gtk_button_new_from_stock(GTK_STOCK_ADD); g_signal_connect(G_OBJECT(path_btn_add), "clicked", G_CALLBACK(iconsel_path_add_clicked), iconsel); gtk_box_pack_start(GTK_BOX(path_hbox), path_btn_add, TRUE, TRUE, 0); gtk_widget_show(path_btn_add); gtk_size_group_add_widget(sizegrp,path_btn_add); // path button collapse path_btn_col = gtk_button_new_with_label("Collapse All"); g_signal_connect(G_OBJECT(path_btn_col), "clicked", G_CALLBACK(iconsel_path_col_clicked), iconsel); gtk_box_pack_start(GTK_BOX(path_hbox), path_btn_col, TRUE, TRUE, 0); gtk_widget_show(path_btn_col); gtk_size_group_add_widget(sizegrp, path_btn_col); // path button expand path_btn_exp = gtk_button_new_with_label("Expand All"); g_signal_connect(G_OBJECT(path_btn_exp), "clicked", G_CALLBACK(iconsel_path_exp_clicked), iconsel); gtk_box_pack_start(GTK_BOX(path_hbox), path_btn_exp, TRUE, TRUE, 0); gtk_widget_show(path_btn_exp); gtk_size_group_add_widget(sizegrp, path_btn_exp); #if 0 /* DEBUG SELECTED */ // path button not selected path_btn_notsel = gtk_button_new_with_label("Print !selected"); g_signal_connect(G_OBJECT(path_btn_notsel), "clicked", G_CALLBACK(iconsel_path_notsel_clicked), iconsel); gtk_box_pack_start(GTK_BOX(path_hbox), path_btn_notsel, TRUE, TRUE, 0); gtk_widget_show(path_btn_notsel); #endif // horizontal box option and sort on the left, extension on the right hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(selpref_vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); // vertical box option and sort vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); gtk_widget_show(vbox); // options frame option_frame = gtk_frame_new(" Icon Resolution "); gtk_container_set_border_width(GTK_CONTAINER(option_frame), 6); gtk_box_pack_start(GTK_BOX(vbox), option_frame, TRUE, TRUE, 0); gtk_widget_show(option_frame); // option vbox option_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(option_vbox), 4); gtk_container_add(GTK_CONTAINER(option_frame), option_vbox); gtk_widget_show(option_vbox); // check button chk0 = gtk_check_button_new_with_label("48x48 icons"); gtk_box_pack_start(GTK_BOX(option_vbox), chk0, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk0), iconsel->apwal->iconsel_pref->select_48); g_signal_connect(G_OBJECT(chk0), "toggled", G_CALLBACK(iconsel_48_toggled), iconsel); gtk_tooltips_set_tip(iconsel->apwal->tips, chk0, "Filter icons when there are loaded from disk.\nSelect 48x48 pixels icons (Strongly recommanded)", NULL); gtk_widget_show(chk0); // check button chk1 = gtk_check_button_new_with_label("Smaller than 48x48 icons"); gtk_box_pack_start(GTK_BOX(option_vbox), chk1, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk1), iconsel->apwal->iconsel_pref->select_lt48); g_signal_connect(G_OBJECT(chk1), "toggled", G_CALLBACK(iconsel_lt48_toggled), iconsel); gtk_tooltips_set_tip(iconsel->apwal->tips, chk1, "Filter icons when there are loaded from disk.\nSelect icons smaller that 48x48 pixels", NULL); gtk_widget_show(chk1); // check button chk2 = gtk_check_button_new_with_label("Bigger than 48x48 icons"); gtk_box_pack_start(GTK_BOX(option_vbox), chk2, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk2), iconsel->apwal->iconsel_pref->select_gt48); g_signal_connect(G_OBJECT(chk2), "toggled", G_CALLBACK(iconsel_gt48_toggled), iconsel); gtk_tooltips_set_tip(iconsel->apwal->tips, chk2, "Filter icons when there are loaded from disk. Select icons bigger that 48x48 pixels", NULL); gtk_widget_show(chk2); // sort frame sort_frame = gtk_frame_new(" Sort Order "); gtk_container_set_border_width(GTK_CONTAINER(sort_frame), 6); gtk_box_pack_start(GTK_BOX(vbox), sort_frame, TRUE, TRUE, 0); gtk_widget_show(sort_frame); // sort vbox sort_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(sort_vbox), 4); gtk_container_add(GTK_CONTAINER(sort_frame), sort_vbox); gtk_widget_show(sort_vbox); // radio button sort_chk0 = gtk_radio_button_new_with_label(NULL, "Sort by Name"); sort_grp = gtk_radio_button_get_group(GTK_RADIO_BUTTON(sort_chk0)); gtk_box_pack_start(GTK_BOX(sort_vbox), sort_chk0, FALSE, FALSE, 0); gtk_tooltips_set_tip(iconsel->apwal->tips, sort_chk0, "Order of the icons displayed in the 'Icon Selection' tab.\nIn this case icons are only sorted by name", NULL); gtk_widget_show(sort_chk0); // radio button sort_chk1 = gtk_radio_button_new_with_label(sort_grp, "Sort by Path, Name"); gtk_box_pack_start(GTK_BOX(sort_vbox), sort_chk1, FALSE, FALSE, 0); gtk_tooltips_set_tip(iconsel->apwal->tips, sort_chk1, "Order of the icons displayed in the 'Icon Selection' tab.\nIcons will be sorted by directory then by name in each directory", NULL); gtk_widget_show(sort_chk1); // set the sort toggle button AND connect the signals. signals are executed // by set_active() and the interface is not currently fully loaded if (iconsel->apwal->iconsel_pref->sort_mode == ICONSEL_SORT_NAME) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sort_chk0), TRUE); else if (iconsel->apwal->iconsel_pref->sort_mode == ICONSEL_SORT_PATH) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sort_chk1), TRUE); g_signal_connect(G_OBJECT(sort_chk0), "toggled", G_CALLBACK(iconsel_sort_name_clicked), iconsel); g_signal_connect(G_OBJECT(sort_chk1), "toggled", G_CALLBACK(iconsel_sort_path_clicked), iconsel); // vertical box extension frame vbox2 = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0); gtk_widget_show(vbox2); // pixmap exts frame exts_frame = gtk_frame_new(" File Extensions "); gtk_container_set_border_width(GTK_CONTAINER(exts_frame), 4); gtk_box_pack_start(GTK_BOX(vbox2), exts_frame, TRUE, TRUE, 0); gtk_widget_show(exts_frame); // vertical box 'exts' exts_vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(exts_frame), exts_vbox); gtk_container_set_border_width(GTK_CONTAINER(exts_vbox), 4); gtk_widget_show(exts_vbox); // scrolled for exts treeview exts_scroll = gtk_scrolled_window_new(NULL, NULL); //gtk_container_set_border_width(GTK_CONTAINER(exts_scroll), 4); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(exts_scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(exts_vbox), exts_scroll, TRUE, TRUE, 0); gtk_widget_show(exts_scroll); // treeview 'extension' iconsel->exts_tree = iconsel_tree_exts_new(iconsel); //gtk_box_pack_start(GTK_BOX(exts_vbox), iconsel->exts_tree, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(exts_scroll), iconsel->exts_tree); gtk_widget_show(iconsel->exts_tree); // extension button add exts_btn_add = gtk_button_new_from_stock(GTK_STOCK_ADD); g_signal_connect(G_OBJECT(exts_btn_add), "clicked", G_CALLBACK(iconsel_exts_add_clicked), iconsel); gtk_box_pack_start(GTK_BOX(exts_vbox), exts_btn_add, FALSE, FALSE, 0); gtk_tooltips_set_tip(iconsel->apwal->tips, exts_btn_add, "Filter icons when there are loaded from disk.\nOnly icons which match one of this extension will be loaded", NULL); gtk_widget_show(exts_btn_add); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- static void iconsel_48_toggled(GtkToggleButton *chk, icon_selection_t *iconsel) { g_assert((chk != NULL) && (iconsel != NULL)); g_assert(iconsel->apwal->iconsel_pref); TRACE("%s", ""); iconsel->apwal->iconsel_pref->select_48 = gtk_toggle_button_get_active(chk); TRACE("bool:%d", iconsel->apwal->iconsel_pref->select_48); icon_list_reload_all_with_splash(iconsel->icons); iconsel_refresh(iconsel); } // ---------------------------------------------------------------------------- static void iconsel_lt48_toggled(GtkToggleButton *chk, icon_selection_t *iconsel) { g_assert((chk != NULL) && (iconsel != NULL)); g_assert(iconsel->apwal->iconsel_pref); TRACE("%s", ""); iconsel->apwal->iconsel_pref->select_lt48 = gtk_toggle_button_get_active(chk); TRACE("bool:%d", iconsel->apwal->iconsel_pref->select_lt48); icon_list_reload_all_with_splash(iconsel->icons); iconsel_refresh(iconsel); } // ---------------------------------------------------------------------------- static void iconsel_gt48_toggled(GtkToggleButton *chk, icon_selection_t *iconsel) { g_assert((chk != NULL) && (iconsel != NULL)); g_assert(iconsel->apwal->iconsel_pref); TRACE("%s", ""); iconsel->apwal->iconsel_pref->select_gt48 = gtk_toggle_button_get_active(chk); TRACE("bool:%d", iconsel->apwal->iconsel_pref->select_gt48); icon_list_reload_all_with_splash(iconsel->icons); iconsel_refresh(iconsel); } // ---------------------------------------------------------------------------- static void iconsel_sort_name_clicked(GtkRadioButton *chk, icon_selection_t *iconsel) { g_assert((chk != NULL) && (iconsel != NULL)); g_assert(iconsel->apwal->iconsel_pref); TRACE("%s", ""); iconsel->apwal->iconsel_pref->sort_mode = ICONSEL_SORT_NAME; TRACE("sort:%d", iconsel->apwal->iconsel_pref->sort_mode); icon_list_set_sortmode(iconsel->icons, iconsel->apwal->iconsel_pref->sort_mode); iconsel_refresh(iconsel); } // ---------------------------------------------------------------------------- static void iconsel_sort_path_clicked(GtkRadioButton *chk, icon_selection_t *iconsel) { g_assert((chk != NULL) && (iconsel != NULL)); g_assert(iconsel->apwal->iconsel_pref); TRACE("%s", ""); iconsel->apwal->iconsel_pref->sort_mode = ICONSEL_SORT_PATH; TRACE("sort:%d", iconsel->apwal->iconsel_pref->sort_mode); icon_list_set_sortmode(iconsel->icons, iconsel->apwal->iconsel_pref->sort_mode); iconsel_refresh(iconsel); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- static void iconsel_path_toggled(GtkCellRendererToggle *cell, gchar *path_str, icon_selection_t *iconsel) { GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; //gboolean cell_active; gboolean selected; char *dirname; GList *hamster; icon_dir_t *dir1; g_assert(cell != NULL && path_str != NULL && iconsel != NULL); TRACE("%s", ""); model = gtk_tree_view_get_model(GTK_TREE_VIEW(iconsel->path_tree)); path = gtk_tree_path_new_from_string(path_str); gtk_tree_model_get_iter(model, &iter, path); gtk_tree_path_free(path); gtk_tree_model_get(model, &iter, 0, &dirname, 1, &selected, -1); TRACE("path:%s, dir:%s, old selected:%d, new selected:%d", path_str, dirname, selected, !selected); selected = ! selected; hamster = g_list_first(iconsel->apwal->iconsel_pref->icon_dirs); while (hamster != NULL) { dir1 = hamster->data; if (strcmp(dir1->path, dirname) == 0) { dir1->selected = selected; break; } hamster = g_list_next(hamster); } if (hamster == NULL) ERR("dir:%s not found in iconsel->apwal->iconsel_pref->icon_dirs", dirname); icon_list_set_selected(iconsel->icons, dirname, selected); iconsel_refresh(iconsel); } // ---------------------------------------------------------------------------- static void iconsel_path_toggled_rec(GtkCellRendererToggle *cell, gchar *path_str, icon_selection_t *iconsel) { GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; //gboolean cell_active; gboolean recursive; char *dirname; GList *hamster; icon_dir_t *dir1; // Deactivate this signal during the processing of this function // It will be reactivated at the end of the function. // The problem is that if someone click too quicly he may be able // to launche twice the function and ask for something wrong // (ask for recusive path a path which is still recusive because // the current processing of the function is making it not recursive // for example). g_signal_handlers_block_by_func(cell, iconsel_path_toggled_rec, iconsel); g_assert(cell != NULL && path_str != NULL && iconsel != NULL); TRACE("%s", ""); model = gtk_tree_view_get_model(GTK_TREE_VIEW(iconsel->path_tree)); path = gtk_tree_path_new_from_string(path_str); gtk_tree_model_get_iter(model, &iter, path); gtk_tree_path_free(path); gtk_tree_model_get(model, &iter, 0, &dirname, 2, &recursive, -1); TRACE("path:%s, dir:%s, old recursive:%d, new recursive:%d", path_str, dirname, recursive, !recursive); recursive = ! recursive; hamster = g_list_first(iconsel->apwal->iconsel_pref->icon_dirs); while (hamster != NULL) { dir1 = hamster->data; if (strcmp(dir1->path, dirname) == 0) { dir1->recursive = recursive; break; } hamster = g_list_next(hamster); } if (hamster == NULL) ERR("dir:%s not found in iconsel->apwal->iconsel_pref->icon_dirs", dirname); if (recursive == FALSE) // it is very quick so no need of splash screen icon_list_set_recursive(iconsel->icons, dirname, recursive); else icon_list_set_recursive_with_splash(iconsel->icons, dirname, recursive); g_free(dirname); iconsel_refresh(iconsel); g_signal_handlers_unblock_by_func(cell, iconsel_path_toggled_rec, iconsel); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- static void iconsel_exts_toggled(GtkCellRendererToggle *cell, gchar *path_str, icon_selection_t *iconsel) { GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; gboolean selected; char *extension; GList *hamster; file_ext_t *ext; g_assert(cell != NULL && path_str != NULL && iconsel != NULL); TRACE("%s", ""); model = gtk_tree_view_get_model(GTK_TREE_VIEW(iconsel->exts_tree)); path = gtk_tree_path_new_from_string(path_str); gtk_tree_model_get_iter(model, &iter, path); gtk_tree_path_free(path); gtk_tree_model_get(model, &iter, 0, &extension, 1, &selected, -1); TRACE("path:%s, extension:%s, old selected:%d, new selected:%d", path_str, extension, selected, !selected); selected = ! selected; hamster = g_list_first(iconsel->apwal->iconsel_pref->file_exts); while (hamster != NULL) { ext = hamster->data; if (strcmp(ext->extension, extension) == 0) { ext->selected = selected; break; } hamster = g_list_next(hamster); } if (hamster == NULL) ERR("extension:%s not found", extension); icon_list_reload_all_with_splash(iconsel->icons); iconsel_refresh(iconsel); } // ---------------------------------------------------------------------------- static void iconsel_path_edited(GtkCellRendererText *cell, gchar *path_str, gchar *newtext, icon_selection_t *iconsel) { GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; gboolean selected; char *dirname, *newdir; icodir_t *icodir; g_assert(cell != NULL && path_str != NULL && newtext != NULL && iconsel != NULL); TRACE("path:%s, newtext:%s", path_str, newtext); model = gtk_tree_view_get_model(GTK_TREE_VIEW(iconsel->path_tree)); path = gtk_tree_path_new_from_string(path_str); gtk_tree_model_get_iter(model, &iter, path); gtk_tree_path_free(path); gtk_tree_model_get(model, &iter, 0, &dirname, 1, &selected, -1); TRACE("path:%s, dirname:%s, new:%s, selected:%d", path_str, dirname, newtext, selected); // if the newtext is empty, remove the line if (strcmp("", newtext) == 0) { icon_dir_list_remove(&iconsel->apwal->iconsel_pref->icon_dirs, dirname); icon_list_remove(iconsel->icons, dirname); } else { newdir = g_strdup(newtext); make_path_uniq(&newdir); icodir = icon_list_find_path(iconsel->icons, newdir); if (icodir != NULL) { if (icodir->parent == NULL) { TRACE("dir:%s already exist and is a parent dir, nothing to do", newdir); g_free(newdir); g_free(dirname); return; } } icon_dir_list_modify(&iconsel->apwal->iconsel_pref->icon_dirs, dirname, newdir); icon_list_modify_with_splash(iconsel->icons, dirname, newdir); g_free(newdir); } g_free(dirname); iconsel_refresh(iconsel); } // ---------------------------------------------------------------------------- static void iconsel_exts_edited(GtkCellRendererText *cell, gchar *path_str, gchar *newtext, icon_selection_t *iconsel) { GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; gboolean selected; char *extension; g_assert(cell != NULL && path_str != NULL && newtext != NULL && iconsel != NULL); TRACE("path:%s, newtext:%s", path_str, newtext); model = gtk_tree_view_get_model(GTK_TREE_VIEW(iconsel->exts_tree)); path = gtk_tree_path_new_from_string(path_str); gtk_tree_model_get_iter(model, &iter, path); gtk_tree_path_free(path); gtk_tree_model_get(model, &iter, 0, &extension, 1, &selected, -1); TRACE("path:%s, extension:%s, new:%s, selected:%d", path_str, extension, newtext, selected); // if the newtext is empty, remove the line if (strcmp("", newtext) == 0) file_ext_list_remove(&iconsel->apwal->iconsel_pref->file_exts, extension); else file_ext_list_modify(&iconsel->apwal->iconsel_pref->file_exts, extension, newtext); icon_list_reload_all_with_splash(iconsel->icons); iconsel_refresh(iconsel); } // ---------------------------------------------------------------------------- static void iconsel_path_refresh_rec(icon_selection_t *iconsel, GtkTreeModel *model, icodir_t *dir, GtkTreeIter *parent_iter) { GList *hamster; GtkTreeIter iter; icodir_t *child; gboolean activatable; gint total_rec, total_sel; GdkPixbuf *pixbuf; g_assert(iconsel != NULL && model != NULL && dir != NULL); //TRACE("%s", ""); activatable = (dir->parent == NULL) ? TRUE : FALSE; total_rec = icodir_count_total_rec(dir); total_sel = icodir_count_selected_rec(dir); pixbuf = (activatable == TRUE) ? iconsel->pixbuf_open : NULL ; gtk_tree_store_append(GTK_TREE_STORE(model), &iter, parent_iter); gtk_tree_store_set(GTK_TREE_STORE(model), &iter, 0, dir->path, 1, dir->selected, 2, dir->recursive, 3, total_rec, 4, total_sel, 5, activatable, 6, pixbuf, -1); if (dir->recursive) { hamster = g_list_first(dir->children); while (hamster) { child = hamster->data; iconsel_path_refresh_rec(iconsel, model, child, &iter); hamster = g_list_next(hamster); } } } // ---------------------------------------------------------------------------- void iconsel_path_refresh(icon_selection_t *iconsel) { GtkTreeModel *model; GList *hamster; icodir_t *icodir; g_assert(iconsel != NULL); TRACE("%s", ""); model = gtk_tree_view_get_model(GTK_TREE_VIEW(iconsel->path_tree)); gtk_tree_store_clear(GTK_TREE_STORE(model)); hamster = iconsel->icons->dirs; while (hamster != NULL) { icodir = hamster->data; if (icodir->parent == NULL) iconsel_path_refresh_rec(iconsel, model, icodir, NULL); hamster = g_list_next(hamster); } } // ---------------------------------------------------------------------------- static void iconsel_exts_refresh(icon_selection_t *iconsel) { GtkTreeModel *model; GtkTreeIter iter1; GList *hamster; file_ext_t *file_ext; g_assert(iconsel != NULL); g_assert(iconsel->apwal->iconsel_pref != NULL); TRACE("%s", ""); model = gtk_tree_view_get_model(GTK_TREE_VIEW(iconsel->exts_tree)); gtk_tree_store_clear(GTK_TREE_STORE(model)); hamster = iconsel->apwal->iconsel_pref->file_exts; while (hamster != NULL) { file_ext = hamster->data; //TRACE("ext:%s", file_ext->extension); gtk_tree_store_append(GTK_TREE_STORE(model), &iter1, NULL); gtk_tree_store_set(GTK_TREE_STORE(model), &iter1, 0, file_ext->extension, 1, file_ext->selected, -1); hamster = g_list_next(hamster); } } // ---------------------------------------------------------------------------- static GtkWidget *iconsel_tree_path_new(icon_selection_t *iconsel) { GtkTreeStore *store; GtkWidget *treeview; GtkTreeSelection *select; GtkCellRenderer *renderer; GtkTreeViewColumn *column; g_assert(iconsel != NULL); g_assert(iconsel->apwal->iconsel_pref != NULL); TRACE("%s", ""); store = gtk_tree_store_new(7, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_INT, G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF); treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); g_object_unref(G_OBJECT(store)); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), TRUE); gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(treeview), TRUE); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE); // cereimg for file selction renderer = cereimg_new(); g_object_set(renderer, "activatable", TRUE, // "pixbuf", pixbuf_open, // "background", "#ccccff", // "active", TRUE, NULL); g_signal_connect(G_OBJECT(renderer), "clicked", G_CALLBACK(iconsel_path_cereimg_clicked), iconsel); column = gtk_tree_view_column_new_with_attributes( NULL, renderer, "pixbuf", 6, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); tree_column_set_label_and_tooltips(iconsel, column, "", "Launch the File Selection Dialog Box to select a new Pixmap Path"); // selected renderer = gtk_cell_renderer_toggle_new(); //g_object_set(renderer, "activatable", TRUE, NULL); g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(iconsel_path_toggled), iconsel); column = gtk_tree_view_column_new_with_attributes( NULL, renderer, "active", 1, "activatable", 5, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); tree_column_set_label_and_tooltips(iconsel, column, "Act", "If toggled, all icons selected in this directory will appear on 'Icon Selection' tab"); // recursive renderer = gtk_cell_renderer_toggle_new(); g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(iconsel_path_toggled_rec), iconsel); column = gtk_tree_view_column_new_with_attributes( NULL, renderer, "active", 2, "activatable", 5, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); tree_column_set_label_and_tooltips(iconsel, column, "Rec", "Starts a recursive scan; be wise...\n" "Don't launch it on '/' unless you have some time to spend.\n" "If 2 paths cross each other the parent will stop its recursive scan at the child directory location." ); // total renderer = gtk_cell_renderer_text_new(); g_object_set(renderer, "editable", FALSE, NULL); column = gtk_tree_view_column_new_with_attributes( NULL, renderer, "text", 3, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); tree_column_set_label_and_tooltips(iconsel, column, "Total", "Icons potentialy selectable"); // selected renderer = gtk_cell_renderer_text_new(); g_object_set(renderer, "editable", FALSE, NULL); column = gtk_tree_view_column_new_with_attributes( NULL, renderer, "text", 4, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); tree_column_set_label_and_tooltips(iconsel, column, "Selected", "Icons which match the filter in the 'Icon Selection' tab (0 if 'Act' is not set)"); // path renderer = gtk_cell_renderer_text_new(); //g_object_set(renderer, "editable", TRUE, NULL); g_signal_connect(G_OBJECT(renderer), "edited", G_CALLBACK(iconsel_path_edited), iconsel); column = gtk_tree_view_column_new_with_attributes( NULL, renderer, "text", 0, "editable", 5, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); gtk_tree_view_set_expander_column(GTK_TREE_VIEW(treeview), column); tree_column_set_label_and_tooltips(iconsel, column, "Pixmap Path", "Directory in which you want to search for icons"); return treeview; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- static GtkWidget *iconsel_tree_exts_new(icon_selection_t *iconsel) { GtkTreeStore *store; GtkWidget *treeview; GtkTreeSelection *select; GtkCellRenderer *renderer; GtkTreeViewColumn *column; g_assert(iconsel != NULL); g_assert(iconsel->apwal->iconsel_pref != NULL); TRACE("%s", ""); store = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN); treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); g_object_unref(G_OBJECT(store)); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE); renderer = gtk_cell_renderer_toggle_new(); g_object_set(renderer, "activatable", TRUE, NULL); g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(iconsel_exts_toggled), iconsel); column = gtk_tree_view_column_new_with_attributes( "selected", renderer, "active", 1, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); renderer = gtk_cell_renderer_text_new(); g_object_set(renderer, "editable", TRUE, NULL); g_signal_connect(G_OBJECT(renderer), "edited", G_CALLBACK(iconsel_exts_edited), iconsel); column = gtk_tree_view_column_new_with_attributes( "extension", renderer, "text", 0, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); return treeview; } // ----------------------------------------------------------------------------- static gboolean iconsel_is_dblclick(icon_selection_t *iconsel, gint x, gint y) { gint elapse; g_assert(iconsel != NULL); TRACE("%s", ""); if (iconsel->dblclick_timer == NULL) { iconsel->dblclick_timer = g_timer_new(); iconsel->dblclick_last_x = x; iconsel->dblclick_last_y = y; return FALSE; } elapse = (int)(g_timer_elapsed(iconsel->dblclick_timer, NULL) * 1000); g_timer_start(iconsel->dblclick_timer); if (iconsel->dblclick_last_x != x || iconsel->dblclick_last_y != y) { iconsel->dblclick_last_x = x; iconsel->dblclick_last_y = y; return FALSE; } if (elapse > DBLCLICK) return FALSE; return TRUE; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- static gboolean iconsel_release_event(GtkWidget *widget, GdkEventButton *event, icon_selection_t *iconsel) { gint x, y; g_assert(widget != NULL && iconsel != NULL && event != NULL); TRACE("%s", ""); x = (int) (event->x / 48); y = (int) (event->y / 48); if (iconsel_is_dblclick(iconsel, x, y)) { TRACE("dblclick x:%d y:%d, app:%p", x, y, iconsel->apwal->selected_app); if (iconsel->apwal->selected_app != NULL) { apwalapp_selected_icon_modified(iconsel->apwal); apwalapp_goto_editor(iconsel->apwal); } } else { TRACE("click x:%d y:%d", x, y); icon_list_set_selected_icon_from_xy(iconsel->icons, x, y); iconsel_refresh_selected(iconsel); } return TRUE; } // ----------------------------------------------------------------------------- static gboolean iconsel_selected_is_dblclick(icon_selection_t *iconsel) { gint elapse; g_assert(iconsel != NULL); TRACE("%s", ""); if (iconsel->dblclick_selected_timer == NULL) { iconsel->dblclick_selected_timer = g_timer_new(); return FALSE; } elapse = (int) (g_timer_elapsed(iconsel->dblclick_selected_timer, NULL) * 1000); g_timer_start(iconsel->dblclick_selected_timer); if (elapse > DBLCLICK) return FALSE; return TRUE; } // ---------------------------------------------------------------------------- static gboolean iconsel_selected_release_event(GtkWidget *widget, GdkEventButton *event, icon_selection_t *iconsel) { g_assert(widget != NULL && iconsel != NULL && event != NULL); TRACE("%s", ""); if (icon_list_get_selected_icon(iconsel->icons) == NULL) { WARN("%s","no icon selected"); return TRUE; } if (iconsel_selected_is_dblclick(iconsel)) { if (iconsel->apwal->selected_app != NULL) { apwalapp_selected_icon_modified(iconsel->apwal); apwalapp_goto_editor(iconsel->apwal); } } return TRUE; } // ---------------------------------------------------------------------------- void iconsel_selected_apply_btn_clicked(GtkButton *widget, icon_selection_t *iconsel) { g_assert(widget != NULL && iconsel != NULL); TRACE("%s", ""); if (icon_list_get_selected_icon(iconsel->icons) == NULL) { TRACE("%s", "no icon selected"); return; } if (iconsel->apwal->selected_app != NULL) { apwalapp_selected_icon_modified(iconsel->apwal); apwalapp_goto_editor(iconsel->apwal); } } // ---------------------------------------------------------------------------- static void iconsel_filter_entry_changed(GtkWidget *entry, icon_selection_t *iconsel) { const gchar *newfilter; g_assert(entry != NULL && iconsel != NULL); TRACE("%s", ""); newfilter = gtk_entry_get_text(GTK_ENTRY(iconsel->filter_entry)); if (newfilter == NULL) ERR("%s", "newfilter NULL, i didn't known that it was possible..."); TRACE("newfilter:%s", newfilter); if (iconsel->filter != NULL) g_free(iconsel->filter); iconsel->filter = g_strdup(newfilter); iconsel_refresh(iconsel); } // ---------------------------------------------------------------------------- static void iconsel_path_add_clicked(GtkWidget *button, icon_selection_t *iconsel) { icon_dir_t *icon_dir; //icodir_t *icodir; g_assert((button != NULL) && (iconsel != NULL)); TRACE("%s", ""); if (icon_list_find_path(iconsel->icons, "") == NULL) { TRACE("%s", "add empty icon_dir"); icon_list_append(iconsel->icons, "", FALSE, FALSE); //icodir = icodir_new("", TRUE/*sel*/, FALSE/*rec*/); //icodir_list_append(&iconsel->dirlist, icodir, &iconsel->icons->icos); icon_dir = icon_dir_new(g_strdup(""), TRUE/*sel*/, FALSE/*rec*/); iconsel->apwal->iconsel_pref->icon_dirs = g_list_append(iconsel->apwal->iconsel_pref->icon_dirs, icon_dir); iconsel_refresh(iconsel); } } // ---------------------------------------------------------------------------- static void iconsel_exts_add_clicked(GtkWidget *button, icon_selection_t *iconsel) { file_ext_t *ext; g_assert((button != NULL) && (iconsel != NULL)); TRACE("%s", ""); if (file_ext_list_find(iconsel->apwal->iconsel_pref->file_exts, "") == NULL) { TRACE("%s", "add empty file_ext"); ext = file_ext_new(g_strdup(""), TRUE); iconsel->apwal->iconsel_pref->file_exts = g_list_append(iconsel->apwal->iconsel_pref->file_exts, ext); icon_list_reload_all_with_splash(iconsel->icons); iconsel_refresh(iconsel); } } // ---------------------------------------------------------------------------- static void iconsel_path_col_clicked(GtkWidget *button, icon_selection_t *iconsel) { g_assert((button != NULL) && (iconsel != NULL)); TRACE("%s", ""); gtk_tree_view_collapse_all(GTK_TREE_VIEW(iconsel->path_tree)); gtk_widget_queue_draw(iconsel->path_tree); } // ---------------------------------------------------------------------------- static void iconsel_path_exp_clicked(GtkWidget *button, icon_selection_t *iconsel) { g_assert((button != NULL) && (iconsel != NULL)); TRACE("%s", ""); gtk_tree_view_expand_all(GTK_TREE_VIEW(iconsel->path_tree)); gtk_widget_queue_draw(iconsel->path_tree); } // ---------------------------------------------------------------------------- #if 0 /* DEBUG SELECTED */ static void iconsel_path_notsel_clicked(GtkWidget *button, icon_selection_t *iconsel); static void iconsel_path_notsel_clicked(GtkWidget *button, icon_selection_t *iconsel) { g_assert((button != NULL) && (iconsel != NULL)); TRACE("%s", ""); icon_list_print_not_selected(iconsel->icons); } #endif // ---------------------------------------------------------------------------- static void iconsel_path_cereimg_clicked(Cereimg *cell, gchar *path_str, icon_selection_t *iconsel) { GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; gboolean selected; icodir_t *icodir; char *olddir; g_assert(cell != NULL && path_str != NULL && iconsel != NULL); TRACE("path:%s", path_str); model = gtk_tree_view_get_model(GTK_TREE_VIEW(iconsel->path_tree)); path = gtk_tree_path_new_from_string(path_str); gtk_tree_model_get_iter(model, &iter, path); gtk_tree_path_free(path); gtk_tree_model_get(model, &iter, 0, &olddir, 1, &selected, -1); TRACE("path:%s, olddir:%s, selected:%d", path_str, olddir, selected); icodir = icon_list_find_path(iconsel->icons, olddir); if (icodir == NULL) ERR("icon_list_find_path return NULL, olddir:%s", olddir); if (icodir->parent == NULL) filesel_select(iconsel->apwal->filesel, olddir, TRUE/*dir_only*/, iconsel_filesel_compute, iconsel); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void iconsel_filesel_compute(const char *oldd, const char *newd, void *data) { icon_selection_t *iconsel = (icon_selection_t *)data; //FIXME: modify icon_dir_list_modify & cie with const char* to avoid cast. char *olddir = (char*) oldd; char *newdir = (char*) newd; icodir_t *icodir; g_assert(iconsel != NULL); TRACE("newdir:%s", newdir); // NULL if user cancel the dir sel box if (newdir == NULL) return; // if the newdir is empty, remove the line if (strcmp("", newdir) == 0) { icon_dir_list_remove(&iconsel->apwal->iconsel_pref->icon_dirs, olddir); icon_list_remove(iconsel->icons, olddir); } else { icodir = icon_list_find_path(iconsel->icons, newdir); if (icodir != NULL) { if (icodir->parent == NULL) { TRACE("dir:%s already exist and is a parent dir, nothing to do", newdir); } else { icon_dir_list_modify(&iconsel->apwal->iconsel_pref->icon_dirs, olddir, newdir); icon_list_modify_with_splash(iconsel->icons, olddir, newdir); } } else { icon_dir_list_modify(&iconsel->apwal->iconsel_pref->icon_dirs, olddir, newdir); icon_list_modify_with_splash(iconsel->icons, olddir, newdir); } } iconsel_refresh(iconsel); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void tree_column_set_label_and_tooltips(icon_selection_t *iconsel, GtkTreeViewColumn *column, char *title, char *tooltips) { GtkWidget *label; GtkWidget *button; g_assert(column); if (!title) { TRACE("%s", "no title, nothing to do"); return; } label = gtk_label_new(title); gtk_widget_show(label); gtk_tree_view_column_set_widget(column, label); //gtk_tree_view_column_set_clickable(column, TRUE); label = gtk_tree_view_column_get_widget(column); if (label == NULL) ERR("gtk_tree_view_column_get_widget, label == %p", label); button = gtk_widget_get_ancestor(label, GTK_TYPE_BUTTON); if (button != NULL) { gtk_tooltips_set_tip(iconsel->apwal->tips, button, tooltips, NULL ); } else { WARN("gtk_widget_get_ancestor, button not found, no tooltips for column:%s", title); } } // ---------------------------------------------------------------------------- void iconsel_filter_reset_clicked(GtkButton *widget, icon_selection_t *iconsel) { g_assert(iconsel != NULL); TRACE("%s", ""); gtk_entry_set_text(GTK_ENTRY(iconsel->filter_entry), "*"); } // ---------------------------------------------------------------------------- void iconsel_scroll_size_allocate(GtkWidget *scroll, GtkAllocation *alloc, icon_selection_t *iconsel) { int new_width; new_width = (alloc->width - iconsel->scroll_border_width) / ICON_WIDTH; if (new_width != iconsel->icons->icon_per_row) { TRACE("new_width:%d", new_width); icon_list_set_width(iconsel->icons, new_width); iconsel_reload(iconsel); } } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/iconsel_private.h0000644000175000017500000000315207775104113015654 0ustar pebpeb00000000000000/* iconsel_private.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #ifndef ICONSEL_PRIVATE__H #define ICONSEL_PRIVATE__H #include /* FILENAME_MAX */ #include "common.h" // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void iconsel_reload(icon_selection_t *iconsel); void iconsel_build_interface(icon_selection_t *iconsel); gboolean iconsel_select_func(ico_t *ico, void *data); #endif /*ICONSEL_PRIVATE__H*/ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/launcher.c0000644000175000017500000002227510160057412014260 0ustar pebpeb00000000000000/* launcher.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include /* execlp */ #include /* fork, execlp */ #include "launcher.h" #include "common.h" // ---------------------------------------------------------------------------- launcher_t* launcher_new(void) { launcher_t *l; app_list_t *apps; l = (launcher_t *)malloc(sizeof(launcher_t)); g_assert(l != NULL); l->window = gtk_window_new(GTK_WINDOW_POPUP); g_signal_connect(G_OBJECT(l->window), "delete_event", gtk_main_quit, NULL); l->event_box = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(l->window), l->event_box); /* And bind an action to it */ gtk_widget_set_events(l->event_box, GDK_BUTTON_PRESS_MASK); g_signal_connect(G_OBJECT(l->event_box), "button_press_event", G_CALLBACK(launcher_button_press_event), l); g_signal_connect(G_OBJECT(l->event_box), "button_release_event", G_CALLBACK(launcher_button_release_event), l); g_signal_connect(G_OBJECT(l->event_box), "enter_notify_event", G_CALLBACK(launcher_enter_notify_event), l); g_signal_connect(G_OBJECT(l->event_box), "leave_notify_event", G_CALLBACK(launcher_leave_notify_event), l); l->image = NULL; l->pixbuf = NULL; l->bitmap_mask = NULL; l->x = 0; l->y = 0; l->width = 0; l->height = 0; l->editor_started = FALSE; l->xwidth = gdk_screen_width(); l->xheight = gdk_screen_height(); l->timeout_activated = 0; l->apps = NULL; xmlrc_load_from_file(&apps, NULL, &l->apwal_pref); launcher_load_apps(l, apps); return l; } // ---------------------------------------------------------------------------- void launcher_load_apps(launcher_t *l, app_list_t *apps) { app_t *app; GdkPixbuf *pixbuf; GdkModifierType state; // mouse state gint x_min, y_min; gint width, height; g_assert(l != NULL); if (l->apps) app_list_free(&(l->apps)); if (l->image) { gtk_container_remove(GTK_CONTAINER(l->event_box), l->image); g_object_unref(l->pixbuf); } l->pixbuf = NULL; l->image = NULL; l->bitmap_mask = NULL; l->apps = apps; if (!apps) return; l->width = ICON_WIDTH * (app_list_delta_x(l->apps) + 1); l->height = ICON_HEIGHT * (app_list_delta_y(l->apps) + 1); x_min = app_list_min_x(l->apps); y_min = app_list_min_y(l->apps); TRACE("Dx:%d, Dy:%d, x_min:%d, y_min:%d", app_list_delta_x(l->apps), app_list_delta_y(l->apps), x_min, y_min); // get the current position of the mouse cursor gdk_window_get_pointer (l->window->window, &l->x, &l->y, &state); // check if the position is correct l->x = l->x + (x_min * ICON_WIDTH); if (l->x < 0) l->x = 0; else if (l->x + l->width > l->xwidth) l->x = l->xwidth - l->width; l->y = l->y + (y_min * ICON_HEIGHT); if (l->y < 0) l->y = 0; else if (l->y + l->height > l->xheight) l->y = l->xheight - l->height; // change position of the window to the mouse cursor position //deprecated gtk_widget_set_uposition(l->window, l->x, l->y); gtk_window_move(GTK_WINDOW(l->window), l->x, l->y); l->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB/*colorspace*/, TRUE/*has_alpha*/, 8/*bits_per_sample*/, l->width, l->height); app = app_list_first(l->apps); while (app) { pixbuf = gdk_pixbuf_new_from_apwal(app->icon, NULL, NULL); if (!app_is_executable(app)) gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, 0.1/*saturation*/, TRUE/*pixelate*/); width = gdk_pixbuf_get_width(pixbuf); height = gdk_pixbuf_get_height(pixbuf); width = width < ICON_WIDTH ? width : ICON_WIDTH; height= height< ICON_HEIGHT ? height: ICON_HEIGHT; gdk_pixbuf_copy_area(pixbuf/*src_pixbuf*/, 0 /*src_x*/, 0/*src_y*/, width, height, l->pixbuf/*dest_pixbuf*/, (app->x - x_min)*ICON_WIDTH/*dest_x*/, (app->y - y_min)*ICON_HEIGHT/*dest_y*/); g_object_unref(pixbuf); app = app_list_next(l->apps); } gdk_pixbuf_render_pixmap_and_mask(l->pixbuf, NULL/*pixmap_return*/, &l->bitmap_mask/*mask_return*/, 128/*alpha_threshold*/); l->image = gtk_image_new_from_pixbuf(l->pixbuf); gtk_container_add(GTK_CONTAINER(l->event_box), l->image); gtk_widget_shape_combine_mask(l->window, l->bitmap_mask, 0/*offset_x*/, 0/*offset_y*/); gtk_widget_show(l->image); gtk_widget_show(l->event_box); gtk_widget_show(l->window); launcher_timeout_start(l); } // ---------------------------------------------------------------------------- void launcher_timeout_start(launcher_t *l) { g_assert(l != NULL); if (!l->timeout_activated) { l->timeout_handler_id = g_timeout_add(l->apwal_pref->timeout, launcher_timeout_function, l); l->timeout_activated = 1 ; } } // ---------------------------------------------------------------------------- void launcher_timeout_stop(launcher_t *l) { g_assert(l != NULL); if (l->timeout_activated) { g_source_remove(l->timeout_handler_id) ; l->timeout_activated = 0 ; } } // ---------------------------------------------------------------------------- gint launcher_timeout_function(gpointer data) { launcher_t *l = (launcher_t*) data; g_assert(l != NULL); if (l->editor_started == TRUE) { TRACE("%s", "editor started, timeout disactivated"); return 0; } gtk_main_quit(); return 0; } // ---------------------------------------------------------------------------- gboolean launcher_button_press_event(GtkWidget *widget, GdkEventButton *event, launcher_t *l) { g_assert(l != NULL); TRACE("type:%x, x:%f, y:%f, button:%d", event->type, event->x, event->y, event->button); return TRUE; } // ---------------------------------------------------------------------------- gboolean launcher_button_release_event(GtkWidget *widget, GdkEventButton *event, launcher_t *l) { guint pos_x; guint pos_y; gboolean launched; app_t *app; GtkWidget *dialog; apwalapp_t *apwal; g_assert(l != NULL); TRACE("type:%x, x:%f, y:%f, button:%d", event->type, event->x, event->y, event->button); if (event->button == 3/*clic avec le bouton droit*/) { if (!l->editor_started) { l->editor_started = TRUE; g_signal_handlers_disconnect_by_func(l->window, launcher_leave_notify_event, l); gtk_widget_hide(l->window); launcher_timeout_stop(l); while (gtk_events_pending()) { gtk_main_iteration(); } apwal = apwalapp_new(); } } else { pos_x = (((int)event->x) / ICON_WIDTH) + app_list_min_x(l->apps); pos_y = (((int)event->y) / ICON_WIDTH) + app_list_min_y(l->apps); TRACE("EXEC x:%d, y:%d, pos_x:%d, pos_y:%d ", (int)event->x, (int)event->y, pos_x, pos_y); app = app_list_at_xy(l->apps, pos_x, pos_y); app_dumpln(app); launched = app_exec(app, l->apwal_pref->exit_at_app_launch); if (!launched) { dialog = gtk_message_dialog_new(GTK_WINDOW(l->window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "An error occured while trying to launch " "the application '%s'.\n(path:'%s')", app->cmdline, app->path); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } } return TRUE; } // ---------------------------------------------------------------------------- gboolean launcher_enter_notify_event(GtkWidget *widget, GdkEventCrossing *event, launcher_t *l) { g_assert(l != NULL); // TRACE("type:%x, x:%f, y:%f", event->type, event->x, event->y); launcher_timeout_stop(l); return TRUE; } // ---------------------------------------------------------------------------- gboolean launcher_leave_notify_event(GtkWidget *widget, GdkEventCrossing *event, launcher_t *l) { g_assert(l != NULL); // TRACE("type:%x, x:%f, y:%f", event->type, event->x, event->y); launcher_timeout_start(l); return TRUE; } // ---------------------------------------------------------------------------- apwal/src/launcher.h0000644000175000017500000000511107775104113014264 0ustar pebpeb00000000000000/* launcher.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef LAUNCHER__H #define LAUNCHER__H #include #include "common.h" // ---------------------------------------------------------------------------- #define ICON_WIDTH 48 #define ICON_HEIGHT 48 // ---------------------------------------------------------------------------- typedef struct launcher_t { GtkWidget *window; GtkWidget *event_box; GtkWidget *image; GdkPixbuf *pixbuf; GdkBitmap *bitmap_mask; gint x; gint y; guint width; guint height; guint xwidth; guint xheight; guint timeout_activated; guint timeout_handler_id; gboolean editor_started; app_list_t *apps; struct apwal_pref_t *apwal_pref; } launcher_t; // ---------------------------------------------------------------------------- launcher_t* launcher_new(void); void launcher_load_apps(launcher_t *l, app_list_t *apps); // ---------------------------------------------------------------------------- void launcher_timeout_start(launcher_t *l); void launcher_timeout_stop(launcher_t *l); gint launcher_timeout_function(gpointer data); gboolean launcher_button_press_event(GtkWidget *widget, GdkEventButton *event, launcher_t *l); gboolean launcher_button_release_event(GtkWidget *widget, GdkEventButton *event, launcher_t *l); gboolean launcher_enter_notify_event(GtkWidget *widget, GdkEventCrossing *event, launcher_t *l); gboolean launcher_leave_notify_event(GtkWidget *widget, GdkEventCrossing *event, launcher_t *l); // ---------------------------------------------------------------------------- #endif /*LAUNCHER__H*/ apwal/src/log.c0000644000175000017500000000173107775104113013243 0ustar pebpeb00000000000000/* log.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- void nop(void) { } // ---------------------------------------------------------------------------- apwal/src/log.h0000644000175000017500000000276607775104113013261 0ustar pebpeb00000000000000/* log.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef LOG__H #define LOG__H #include void nop(void); // ---------------------------------------------------------------------------- #ifdef APWAL_DEBUG #define TRACE(format, args...) g_print("[%s:%d] %s() " format "\n", __FILE__, __LINE__, __FUNCTION__, ## args) #else #define TRACE(format, args...) nop() #endif // ---------------------------------------------------------------------------- #define WARN(format, args...) g_warning("[%s:%d] %s() " format, __FILE__, __LINE__, __FUNCTION__, ## args) #define ERR(format, args...) g_error("[%s:%d] %s() " format, __FILE__, __LINE__, __FUNCTION__, ## args) // ---------------------------------------------------------------------------- #endif /*LOG__H*/ apwal/src/main.c0000644000175000017500000000361710160124375013405 0ustar pebpeb00000000000000/* main.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include "launcher.h" #include #include void usage(char *exec) { fprintf(stderr, "usage: %s [--edit] [--config ]\n", exec); exit(1); } int main(int argc, char **argv) { launcher_t *launcher; apwalapp_t *apwal; gboolean launch_editor = FALSE; char *config_file = NULL; gtk_init(&argc, &argv); if (argc > 1) { int i; for (i = 1; i < argc; i++) { TRACE(); if (strstr(argv[i], "--edit") != NULL) { launch_editor = TRUE; } else if (strstr(argv[i], "--config") != NULL) { i++; if (i < argc) { config_file = argv[i]; } else { usage(argv[0]); } } else { usage(argv[0]); } } } xmlrc_set_resource_file(config_file); // NULL is ok. if (!xmlrc_resource_file_exist()) { xmlrc_resource_file_create(); apwal = apwalapp_new(); } else if (launch_editor) { apwal = apwalapp_new(); } else { launcher = launcher_new(); } gtk_main(); return 0; } apwal/src/property.c0000644000175000017500000004705710005247213014346 0ustar pebpeb00000000000000/* property.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" static void property_refresh_app(property_t *prop); static void property_refresh_no_app(property_t *prop); static void property_build_interface(property_t *prop); static void prop_cmdline_changed(GtkWidget *entry, property_t *prop); static void prop_path_changed(GtkWidget *entry, property_t *prop); static void prop_icon_changed(GtkWidget *entry, property_t *prop); //static void property_refreshed(Cereimg *cell, gchar *path_str, gchar *new_text, // property_t *prop); //static void cereimg_clicked(Cereimg *cell, gchar *path_str, // property_t *prop); static void prop_cmdline_clicked(GtkWidget *entry, property_t *prop); static void prop_path_clicked(GtkWidget *entry, property_t *prop); static void prop_icon_clicked(GtkWidget *entry, property_t *prop); static void prop_cmdline_compute(const char *old_val, const char *new_val, void *data); static void prop_path_compute(const char *old_val, const char *new_val, void *data); static void property_remove_clicked(GtkWidget *button, property_t *prop); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- property_t *property_new(apwalapp_t *apwal) { property_t *prop; g_assert(apwal != NULL); g_assert(apwal->property_frame != NULL); prop = (property_t*) malloc(sizeof(property_t)); g_assert(prop != NULL); prop->apwal = apwal; property_build_interface(prop); property_refresh_no_app(prop); return prop; } // ---------------------------------------------------------------------------- void property_refresh(property_t *prop) { g_assert(prop != NULL); g_assert(prop->apwal != NULL); if (prop->apwal->selected_app != NULL) property_refresh_app(prop); else property_refresh_no_app(prop); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- static void property_refresh_app(property_t *prop) { app_t *app; //GError *err; GdkPixbuf *pix, *pix_scaled; int scale_width, scale_height; g_assert(prop != NULL); g_assert(prop->apwal != NULL); g_assert(prop->apwal->apps != NULL); g_assert(prop->apwal->selected_app != NULL); app = prop->apwal->selected_app; TRACE("app:%p", app); app_dumpln(app); // block the "changed" signal to maintain coherency g_signal_handlers_block_by_func(GTK_OBJECT(prop->entry_cmdline), prop_cmdline_changed, prop); g_signal_handlers_block_by_func(GTK_OBJECT(prop->entry_path), prop_path_changed, prop); g_signal_handlers_block_by_func(GTK_OBJECT(prop->entry_icon), prop_icon_changed, prop); // it is safe now, modifying the data gtk_entry_set_text(GTK_ENTRY(prop->entry_cmdline), app_get_cmdline(app)); //change the color of the cmdline entry if cmdline is not valid if (app_is_executable(app)) gtk_widget_set_text_color_default(GTK_WIDGET(prop->entry_cmdline)); else gtk_widget_set_text_color_invalid(GTK_WIDGET(prop->entry_cmdline)); //change the color of the path entry if path is not valid if (app_path_is_valid(app)) gtk_widget_set_text_color_default(GTK_WIDGET(prop->entry_path)); else gtk_widget_set_text_color_invalid(GTK_WIDGET(prop->entry_path)); //change the color of the icon entry if icon is not valid if (app_icon_is_valid(app)) gtk_widget_set_text_color_default(GTK_WIDGET(prop->entry_icon)); else gtk_widget_set_text_color_invalid(GTK_WIDGET(prop->entry_icon)); gtk_entry_set_text(GTK_ENTRY(prop->entry_path), app_get_path(app)); gtk_entry_set_text(GTK_ENTRY(prop->entry_icon), app_get_icon(app)); // unblock the "changed" signal g_signal_handlers_unblock_by_func(GTK_OBJECT(prop->entry_cmdline), prop_cmdline_changed, prop); g_signal_handlers_unblock_by_func(GTK_OBJECT(prop->entry_path), prop_path_changed, prop); g_signal_handlers_unblock_by_func(GTK_OBJECT(prop->entry_icon), prop_icon_changed, prop); pix = gdk_pixbuf_new_from_apwal((char*)app_get_icon(app), NULL, NULL); //GTK_ICON_SIZE_SMALL_TOOLBAR 18x18 //GTK_ICON_SIZE_LARGE_TOOLBAR 20x20 //GTK_ICON_SIZE_BUTTON 22x22 gtk_icon_size_lookup(GTK_ICON_SIZE_SMALL_TOOLBAR, &scale_width, &scale_height); pix_scaled = gdk_pixbuf_scale_simple(pix, scale_width, scale_height, /*GDK_INTERP_BILINEAR*/ GDK_INTERP_HYPER); gtk_image_set_from_pixbuf(GTK_IMAGE(prop->img_icon), pix_scaled); g_object_unref(pix); g_object_unref(pix_scaled); // set the frame sensitive again so the user will be able to modify the data. gtk_widget_set_sensitive(prop->apwal->property_frame, TRUE); } // ---------------------------------------------------------------------------- static void property_refresh_no_app(property_t *prop) { g_assert(prop != NULL); g_assert(prop->apwal != NULL); g_assert(prop->apwal->selected_app == NULL); TRACE("%s", ""); // set the frame insensitive so the user won't be able to modify the data. gtk_widget_set_sensitive(prop->apwal->property_frame, FALSE); // block the "changed" signal to maintain coherency g_signal_handlers_block_by_func(GTK_OBJECT(prop->entry_cmdline), prop_cmdline_changed, prop); g_signal_handlers_block_by_func(GTK_OBJECT(prop->entry_path), prop_path_changed, prop); g_signal_handlers_block_by_func(GTK_OBJECT(prop->entry_icon), prop_icon_changed, prop); // it is safe now, modifying the data gtk_entry_set_text(GTK_ENTRY(prop->entry_cmdline), ""); gtk_entry_set_text(GTK_ENTRY(prop->entry_path), ""); gtk_entry_set_text(GTK_ENTRY(prop->entry_icon), ""); // unblock the "changed" signal g_signal_handlers_unblock_by_func(GTK_OBJECT(prop->entry_cmdline), prop_cmdline_changed, prop); g_signal_handlers_unblock_by_func(GTK_OBJECT(prop->entry_path), prop_path_changed, prop); g_signal_handlers_unblock_by_func(GTK_OBJECT(prop->entry_icon), prop_icon_changed, prop); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- static void property_build_interface(property_t *prop) { // *apwal->property_frame; GtkWidget *hbox; GtkWidget *vbox_entries; GtkWidget *hbox_cmdline; GtkWidget *label_cmdline; // *prop->entry_cmdline; GtkWidget *btn_cmdline; GtkWidget *img_cmdline; GtkWidget *hbox_path; GtkWidget *label_path; // *prop->entry_path; GtkWidget *btn_path; GtkWidget *img_path; GtkWidget *hbox_icon; GtkWidget *label_icon; // *prop->entry_icon; GtkWidget *btn_icon; // *img_icon; GtkWidget *vbox; // *prop->btn_remove; GtkSizeGroup *group_entries; GtkSizeGroup *group_buttons; g_assert(prop != NULL); g_assert(prop->apwal != NULL); g_assert(prop->apwal->property_frame != NULL); //group entries & buttons group_entries = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); group_buttons = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); // horizontal box hbox = gtk_hbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); gtk_container_add(GTK_CONTAINER(prop->apwal->property_frame), hbox); gtk_widget_show(hbox); //vbox entries vbox_entries = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox_entries), 2); gtk_box_pack_start(GTK_BOX(hbox), vbox_entries, TRUE, TRUE, 0); gtk_widget_show(vbox_entries); //hbox cmdline hbox_cmdline = gtk_hbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(hbox_cmdline), 0); gtk_box_pack_start(GTK_BOX(vbox_entries), hbox_cmdline, TRUE, TRUE, 0); gtk_widget_show(hbox_cmdline); //label cmdline label_cmdline = gtk_label_new("Command Line "); gtk_size_group_add_widget(group_entries, label_cmdline); gtk_box_pack_start(GTK_BOX(hbox_cmdline), label_cmdline, FALSE, FALSE, 0); gtk_widget_show(label_cmdline); //entry cmdline prop->entry_cmdline = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(prop->entry_cmdline), ""); gtk_box_pack_start(GTK_BOX(hbox_cmdline), prop->entry_cmdline, TRUE, TRUE, 0); gtk_widget_show(prop->entry_cmdline); g_signal_connect(G_OBJECT(prop->entry_cmdline), "changed", G_CALLBACK(prop_cmdline_changed), prop); //btn cmdline btn_cmdline = gtk_button_new(); g_signal_connect(G_OBJECT(btn_cmdline), "clicked", G_CALLBACK(prop_cmdline_clicked), prop); gtk_size_group_add_widget(group_buttons, btn_cmdline); gtk_box_pack_start(GTK_BOX(hbox_cmdline), btn_cmdline, FALSE, FALSE, 0); gtk_widget_show(btn_cmdline); //img cmdline img_cmdline = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_tooltips_set_tip(prop->apwal->tips, btn_cmdline, "Cmdline Browse...\nShow the File Selection Dialog Box which allow to select the executable to launch", NULL); gtk_widget_show(img_cmdline); gtk_container_add(GTK_CONTAINER(btn_cmdline), img_cmdline); //hbox path hbox_path = gtk_hbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(hbox_path), 0); gtk_box_pack_start(GTK_BOX(vbox_entries), hbox_path, TRUE, TRUE, 0); gtk_widget_show(hbox_path); //label path label_path = gtk_label_new("Execute Path "); gtk_size_group_add_widget(group_entries, label_path); gtk_misc_set_alignment(GTK_MISC(label_path), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(hbox_path), label_path, FALSE, FALSE, 0); gtk_widget_show(label_path); //entry path prop->entry_path = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(prop->entry_path), ""); gtk_box_pack_start(GTK_BOX(hbox_path), prop->entry_path, TRUE, TRUE, 0); gtk_widget_show(prop->entry_path); g_signal_connect(G_OBJECT(prop->entry_path), "changed", G_CALLBACK(prop_path_changed), prop); //btn path btn_path = gtk_button_new(); g_signal_connect(G_OBJECT(btn_path), "clicked", G_CALLBACK(prop_path_clicked), prop); gtk_size_group_add_widget(group_buttons, btn_path); gtk_box_pack_start(GTK_BOX(hbox_path), btn_path, FALSE, FALSE, 0); gtk_widget_show(btn_path); //img_path img_path = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_widget_show(img_path); gtk_container_add(GTK_CONTAINER(btn_path), img_path); gtk_tooltips_set_tip(prop->apwal->tips, btn_path, "Path Browse...\nShow the Directory Selection Dialog Box which allow to select the execution path of the currently selected application", NULL); //hbox icon hbox_icon = gtk_hbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(hbox_icon), 0); gtk_box_pack_start(GTK_BOX(vbox_entries), hbox_icon, TRUE, TRUE, 0); gtk_widget_show(hbox_icon); //label icon label_icon = gtk_label_new("Icon "); gtk_size_group_add_widget(group_entries, label_icon); gtk_misc_set_alignment(GTK_MISC(label_icon), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(hbox_icon), label_icon, FALSE, FALSE, 0); gtk_widget_show(label_icon); //entry icon prop->entry_icon = gtk_entry_new(); gtk_label_set_justify(GTK_LABEL(label_icon), GTK_JUSTIFY_LEFT); gtk_entry_set_text(GTK_ENTRY(prop->entry_icon), ""); gtk_box_pack_start(GTK_BOX(hbox_icon), prop->entry_icon, TRUE, TRUE, 0); gtk_widget_show(prop->entry_icon); g_signal_connect(G_OBJECT(prop->entry_icon), "changed", G_CALLBACK(prop_icon_changed), prop); //btn icon btn_icon = gtk_button_new(); g_signal_connect(G_OBJECT(btn_icon), "clicked", G_CALLBACK(prop_icon_clicked), prop); gtk_size_group_add_widget(group_buttons, btn_icon); gtk_box_pack_start(GTK_BOX(hbox_icon), btn_icon, FALSE, FALSE, 0); gtk_widget_show(btn_icon); //img_icon prop->img_icon = gtk_image_new(); gtk_widget_show(prop->img_icon); gtk_container_add(GTK_CONTAINER(btn_icon), prop->img_icon); gtk_tooltips_set_tip(prop->apwal->tips, btn_icon, "Icon Browse...\nShow the Icon Selection Window to select a new icon for the currently selected application", NULL); //GdkPixbuf *pix1; //prop->pixbuf_open = gtk_widget_render_icon(prop->apwal->window, "gtk-open", // GTK_ICON_SIZE_MENU, NULL); //prop->pixbuf_open = gdk_pixbuf_new_from_apwal("relief", NULL, NULL); //pix1 = gtk_widget_render_icon(prop->apwal->window, "gtk-open", // GTK_ICON_SIZE_MENU, NULL); //gdk_pixbuf_append(prop->pixbuf_open, pix1); // vbox vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox), 2); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); gtk_widget_show(vbox); // btn_remove prop->btn_remove = gtk_button_new_from_stock(GTK_STOCK_REMOVE); g_signal_connect(G_OBJECT(prop->btn_remove), "clicked", G_CALLBACK(property_remove_clicked), prop); gtk_box_pack_end(GTK_BOX(vbox), prop->btn_remove, FALSE, FALSE, 0); gtk_tooltips_set_tip(prop->apwal->tips, prop->btn_remove, "Remove\nRemove the application currently selected", NULL); gtk_widget_show(prop->btn_remove); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- static void prop_cmdline_clicked(GtkWidget *button, property_t *prop) { app_t *app; g_assert((button != NULL) && (prop != NULL)); g_assert(prop->apwal != NULL); g_assert(prop->apwal->selected_app != NULL); app = prop->apwal->selected_app; TRACE_APP(app, "%s", ""); filesel_select(prop->apwal->filesel, app_get_cmdline(app), FALSE/*dir_only*/, prop_cmdline_compute, prop); } // ---------------------------------------------------------------------------- static void prop_path_clicked(GtkWidget *button, property_t *prop) { app_t *app; g_assert((button != NULL) && (prop != NULL)); g_assert(prop->apwal != NULL); g_assert(prop->apwal->selected_app != NULL); app = prop->apwal->selected_app; TRACE_APP(app, "%s", ""); filesel_select(prop->apwal->filesel, app_get_path(app), TRUE/*dir_only*/, prop_path_compute, prop); } // ---------------------------------------------------------------------------- static void prop_icon_clicked(GtkWidget *button, property_t *prop) { app_t *app; g_assert((button != NULL) && (prop != NULL)); g_assert(prop->apwal != NULL); g_assert(prop->apwal->selected_app != NULL); app = prop->apwal->selected_app; TRACE_APP(app, "%s", ""); apwalapp_goto_iconsel(prop->apwal); } // ---------------------------------------------------------------------------- static void prop_cmdline_compute(const char *old_val, const char *new_val, void *data) { app_t *app; property_t *prop = (property_t *) data; g_assert(prop != NULL); g_assert(prop->apwal != NULL); g_assert(prop->apwal->selected_app != NULL); app = prop->apwal->selected_app; TRACE_APP(app, "old val:%s, new val:%s", old_val, new_val); if (new_val != NULL) { app_set_cmdline(app, new_val); apwalapp_selected_app_modified(prop->apwal); } } // ---------------------------------------------------------------------------- static void prop_path_compute(const char *old_val, const char *new_val, void *data) { app_t *app; property_t *prop = (property_t *) data; g_assert(prop != NULL); g_assert(prop->apwal != NULL); g_assert(prop->apwal->selected_app != NULL); app = prop->apwal->selected_app; TRACE_APP(app, "old val:%s, new val:%s", old_val, new_val); if (new_val != NULL) { app_set_path(app, new_val); apwalapp_selected_app_modified(prop->apwal); } } // ---------------------------------------------------------------------------- static void prop_cmdline_changed(GtkWidget *entry, property_t *prop) { app_t *app; const char *value; g_assert((entry != NULL) && (prop != NULL)); g_assert(prop->apwal != NULL); g_assert(prop->apwal->selected_app != NULL); app = prop->apwal->selected_app; TRACE("app:%p", app); value = gtk_entry_get_text(GTK_ENTRY(entry)); app_set_cmdline(app, value); //change the color of the cmdline entry if cmdline is not valid if (app_is_executable(app)) gtk_widget_set_text_color_default(GTK_WIDGET(prop->entry_cmdline)); else gtk_widget_set_text_color_invalid(GTK_WIDGET(prop->entry_cmdline)); apwalapp_selected_app_modified(prop->apwal); } // ---------------------------------------------------------------------------- static void prop_path_changed(GtkWidget *entry, property_t *prop) { app_t *app; const char *value; g_assert((entry != NULL) && (prop != NULL)); g_assert(prop->apwal != NULL); g_assert(prop->apwal->selected_app != NULL); app = prop->apwal->selected_app; TRACE("app:%p", app); value = gtk_entry_get_text(GTK_ENTRY(entry)); app_set_path(app, value); //change the color of the path entry if path is not valid if (app_path_is_valid(app)) gtk_widget_set_text_color_default(GTK_WIDGET(prop->entry_path)); else gtk_widget_set_text_color_invalid(GTK_WIDGET(prop->entry_path)); apwalapp_selected_app_modified(prop->apwal); } // ---------------------------------------------------------------------------- static void prop_icon_changed(GtkWidget *entry, property_t *prop) { app_t *app; const char *value; g_assert((entry != NULL) && (prop != NULL)); g_assert(prop->apwal != NULL); g_assert(prop->apwal->selected_app != NULL); app = prop->apwal->selected_app; TRACE("app:%p", app); value = gtk_entry_get_text(GTK_ENTRY(entry)); app_set_icon(app, value); //change the color of the icon entry if icon is not valid if (app_icon_is_valid(app)) gtk_widget_set_text_color_default(GTK_WIDGET(prop->entry_icon)); else gtk_widget_set_text_color_invalid(GTK_WIDGET(prop->entry_icon)); apwalapp_selected_app_modified(prop->apwal); } // ---------------------------------------------------------------------------- static void property_remove_clicked(GtkWidget *button, property_t *prop) { app_t *app; g_assert((button != NULL) && (prop != NULL)); g_assert(prop->apwal != NULL); g_assert(prop->apwal->selected_app != NULL); app = prop->apwal->selected_app; TRACE("app:%p", app); app_list_remove(prop->apwal->apps, app); prop->apwal->selected_app = NULL; apwalapp_selected_app_modified(prop->apwal); } // ---------------------------------------------------------------------------- apwal/src/property.h0000644000175000017500000000327007775671440014367 0ustar pebpeb00000000000000/* property.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #ifndef PROPERTY__H #define PROPERTY__H #include "common.h" #define PROPERTY_OK 1 #define PROPERTY_CANCEL 2 #define PROPERTY_DELETE 3 #define PROPERTY_REMOVE 4 typedef struct property_t { struct apwalapp_t *apwal; GtkWidget *entry_cmdline; GtkWidget *entry_path; GtkWidget *entry_icon; GtkWidget *img_icon; GtkWidget *btn_remove; } property_t; // ---------------------------------------------------------------------------- property_t * property_new(struct apwalapp_t *apwal); void property_refresh(property_t *prop); #endif /* PROPERTY__H*/ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/splash.c0000644000175000017500000001255610161361342013753 0ustar pebpeb00000000000000/* splash.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #include "splash.h" #include "common.h" static gboolean splash_window_delete_event(GtkWidget *widget, GdkEvent *event, splash_t *splash); // ---------------------------------------------------------------------------- splash_t* splash_new(struct apwalapp_t *apwal) { splash_t *splash; GtkWidget *frame; GtkWidget *vbox; GtkWidget *label; splash = (splash_t *) malloc (sizeof(splash_t)); g_assert(splash != NULL); splash->apwal = apwal; splash->showed = FALSE; splash->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); //gtk_window_set_type_hint(GTK_WINDOW(splash->window), // GDK_WINDOW_TYPE_HINT_DIALOG); g_signal_connect(G_OBJECT(splash->window), "delete_event", G_CALLBACK(splash_window_delete_event), splash); //gtk_window_set_decorated(GTK_WINDOW(splash->window), FALSE); //is gtk_window_set_auto_startup_notification(FALSE) useful in our situation? frame = gtk_frame_new(NULL); //" Loading icons "); gtk_container_set_border_width(GTK_CONTAINER(frame), 8); //gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); gtk_container_add(GTK_CONTAINER(splash->window), frame); gtk_widget_show(frame); vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox), 0); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_widget_show(vbox); label = gtk_label_new("Load icons, please wait..."); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); gtk_widget_show(label); splash->progressbar = gtk_progress_bar_new(); gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(splash->progressbar), 0.02); gtk_box_pack_start(GTK_BOX(vbox), splash->progressbar, FALSE, FALSE, 0); gtk_widget_show(splash->progressbar); splash->busycursor = gdk_cursor_new(GDK_WATCH); return splash; } // ---------------------------------------------------------------------------- void splash_show(splash_t *splash) { splash->showed = TRUE; // busy cursor on // FIXME: gdk_window_set_cursor on splash window do NOT work gdk_window_set_cursor(splash->window->window, splash->busycursor); gdk_window_set_cursor(splash->apwal->window->window, splash->busycursor); gdk_window_set_cursor(splash->apwal->window2->window, splash->busycursor); //gdk_flush(); // no grab because if iconsel is modal then it is not anymore after // hiding the splash screen. use sensitive to do the job gtk_widget_set_sensitive(splash->apwal->window, FALSE); gtk_widget_set_sensitive(splash->apwal->window2, FALSE); // choose the window on which the user is currently looking at. if ( ! GTK_WIDGET_VISIBLE(splash->apwal->window2)) gtk_window_set_transient_for(GTK_WINDOW(splash->window), GTK_WINDOW(splash->apwal->window)); else gtk_window_set_transient_for(GTK_WINDOW(splash->window), GTK_WINDOW(splash->apwal->window2)); gtk_widget_show(splash->window); while (gtk_events_pending()) gtk_main_iteration(); } // ---------------------------------------------------------------------------- void splash_hide(splash_t *splash) { splash->showed = FALSE; gtk_widget_hide(splash->window); gtk_widget_set_sensitive(splash->apwal->window, TRUE); gtk_widget_set_sensitive(splash->apwal->window2, TRUE); //busy cursor off gdk_window_set_cursor(splash->window->window, NULL); gdk_window_set_cursor(splash->apwal->window->window, NULL); gdk_window_set_cursor(splash->apwal->window2->window, NULL); while (gtk_events_pending()) gtk_main_iteration(); } // ---------------------------------------------------------------------------- void splash_update(splash_t *splash) { if (splash->showed == TRUE) { gtk_progress_bar_pulse(GTK_PROGRESS_BAR(splash->progressbar)); while (gtk_events_pending()) gtk_main_iteration(); } } // ---------------------------------------------------------------------------- static gboolean splash_window_delete_event(GtkWidget *widget, GdkEvent *event, splash_t *splash) { return TRUE;/*TRUE to stop other handlers from being invoked for the event*/ } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/splash.h0000644000175000017500000000270010160262277013754 0ustar pebpeb00000000000000/* splash.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #ifndef PROGRESSWINDOW__H #define PROGRESSWINDOW__H #include "common.h" typedef struct splash_t { struct apwalapp_t *apwal; GtkWidget *window; GtkWidget *progressbar; GdkCursor *busycursor; gboolean showed; } splash_t; splash_t* splash_new(struct apwalapp_t *apwal); void splash_show(splash_t *splash); void splash_hide(splash_t *splash); void splash_update(splash_t *splash); #endif /* PROGRESSWINDOW__H */ // ---------------------------------------------------------------------------- apwal/src/sysstuff.c0000644000175000017500000000634010161364147014347 0ustar pebpeb00000000000000/* sysstuff.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "log.h" #include #include #include #include // FILENAME_MAX #include #include #include #define __USE_GNU 1 #include // group_member, chdir // ---------------------------------------------------------------------------- gboolean sys_spawn(gchar *cmdline, gchar *path) { int cc; gboolean spawned; GError *err = NULL; gchar *oldpwd = NULL; g_assert(cmdline != NULL); // switch to desired PATH if ((path != NULL) && (strcmp(path, "") != 0)) { cc = chdir(path); WARN("chdir:%d, errno:%d, path:%s", cc, errno, path); oldpwd = g_get_current_dir(); } spawned = g_spawn_command_line_async(cmdline, &err/*GError*/); if (oldpwd != NULL) { cc = chdir(oldpwd); if (cc != 0) WARN("chdir:%d, errno:%d, oldpwd:%s", cc, errno, oldpwd); g_free(oldpwd); } if (!spawned) { if (err != NULL && err->message != NULL) { WARN("g_spawn_command_line_async, cmdline:%s, errcode:%d, msg:%s", cmdline, err->code, err->message); g_error_free(err); } else { WARN("g_spawn_command_line_async, cmdline:%s", cmdline); } } return spawned; } // ---------------------------------------------------------------------------- // remove all not necessary '/' in the path void make_path_uniq(char **path) { int i, len, dbl_slash_cnt, dbl_slash_cnt_old; char *new_path; len = strlen(*path); dbl_slash_cnt = 0; for (i=0; i * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef SYSSTUFF__H #define SYSSTUFF__H #include gboolean sys_spawn(gchar *cmdline, gchar *path); void make_path_uniq(char **path); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #endif /*SYSSTUFF__H*/ apwal/src/xmlrc.c0000644000175000017500000005173210161364646013617 0ustar pebpeb00000000000000/* xmlrc.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #include "common.h" #include /* define FILENAME_MAX */ #include #include #include #include #include #include #include #include #include #include "xmlrcinline.inc" // ---------------------------------------------------------------------------- // .apwalrc.xml file: // apwalrc // apps // app // ... // iconsel_pref // icon_dirs // path // ... // file_exts // extension // .. // apwal_pref // // // ---------------------------------------------------------------------------- // only access filerc by xmlrc_set_resource_file/xmlrc_resource_file static char g_xmlrc_filerc[FILENAME_MAX] = { 0 }; static char* xmlrc_resource_file(void); static app_list_t * xmlrc_parse_apps(xmlDocPtr doc, xmlNodePtr cur); static app_t * xmlrc_parse_app(xmlDocPtr doc, xmlNodePtr cur); static apwal_pref_t * xmlrc_parse_apwal_pref(xmlDocPtr doc, xmlNodePtr cur); static iconsel_pref_t * xmlrc_parse_iconsel_pref(xmlDocPtr doc, xmlNodePtr cur); static GList * xmlrc_parse_icon_dirs(xmlDocPtr doc, xmlNodePtr cur); static icon_dir_t * xmlrc_parse_icon_dir(xmlDocPtr doc, xmlNodePtr cur); static GList * xmlrc_parse_file_exts(xmlDocPtr doc, xmlNodePtr cur); static file_ext_t * xmlrc_parse_file_ext(xmlDocPtr doc, xmlNodePtr cur); // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void xmlrc_load_from_file(app_list_t **apps, iconsel_pref_t **iconsel_pref, apwal_pref_t **apwal_pref) { xmlDocPtr doc; xmlNodePtr cur; gboolean apps_is_loaded = FALSE; gboolean iconsel_pref_is_loaded = FALSE; gboolean apwal_pref_is_loaded = FALSE; g_assert(apps != NULL && apwal_pref != NULL); // iconsel_pref NULL in launcher LIBXML_TEST_VERSION xmlKeepBlanksDefault(0); // load tree from file doc = xmlParseFile(xmlrc_resource_file()); if (doc == NULL) ERR("xmlParseFile, file:%s invalid", xmlrc_resource_file()); cur = xmlDocGetRootElement(doc); if (cur == NULL) ERR("xmlDocGetRootElement, empty document, file:%s", xmlrc_resource_file()); if (xmlStrcmp(cur->name, (const xmlChar *) "apwalrc")) ERR("xmlStrcmp, doc root:%s != apwalrc", cur->name); // load app list from tree cur = cur->xmlChildrenNode; while(cur != NULL) { if (xmlIsBlankNode(cur)) { ERR("%s", "I just would like to know what is a xmlIsBlankNode"); } if (!xmlStrcmp(cur->name, (const xmlChar *) "apps")) { if (apps_is_loaded == TRUE) ERR("%s", "there are more that one node"); *apps = xmlrc_parse_apps(doc, cur); apps_is_loaded = TRUE; } else if (!xmlStrcmp(cur->name, (const xmlChar *) "iconsel_pref")) { if (iconsel_pref_is_loaded == TRUE) ERR("%s", "there are more that one node"); if (iconsel_pref != NULL) // the launcher will not ask for it *iconsel_pref = xmlrc_parse_iconsel_pref(doc, cur); iconsel_pref_is_loaded = TRUE; } else if (!xmlStrcmp(cur->name, (const xmlChar *) "apwal_pref")) { if (apwal_pref_is_loaded == TRUE) ERR("%s", "there are more that one node"); if (apwal_pref != NULL) // the launcher will not ask for it *apwal_pref = xmlrc_parse_apwal_pref(doc, cur); apwal_pref_is_loaded = TRUE; } else ERR("cur->name:%s invalid", cur->name); cur = cur->next; } //end while cur if (apps_is_loaded == FALSE) ERR("apps section not found in rc file:%s", xmlrc_resource_file()); if (iconsel_pref_is_loaded == FALSE) ERR("iconsel_pref section not found in rc file:%s", xmlrc_resource_file()); if (apwal_pref_is_loaded == FALSE) ERR("apwal_pref section not found in rc file:%s", xmlrc_resource_file()); // free tree xmlFreeDoc(doc); xmlCleanupParser(); } // ---------------------------------------------------------------------------- static app_list_t * xmlrc_parse_apps(xmlDocPtr doc, xmlNodePtr cur) { app_list_t *apps; app_t *app; apps = app_list_new(); cur = cur->xmlChildrenNode; while (cur) { if (xmlStrcmp(cur->name, (const xmlChar *) "app")) ERR("cur->name:%s unknown", cur->name); app = xmlrc_parse_app(doc, cur); if (app != NULL) app_list_add(apps, app); cur = cur->next; } return apps; } // ---------------------------------------------------------------------------- static app_t * xmlrc_parse_app(xmlDocPtr doc, xmlNodePtr cur) { app_t *app; gchar *cmdline = NULL; gchar *exec = NULL; gchar *args = NULL; gchar *path = NULL; gchar *icon = NULL; gint x = 0; gint y = 0; gchar *buf; cur = cur->xmlChildrenNode; while (cur != NULL) { if (!xmlStrcmp(cur->name, (const xmlChar *)"cmdline")) cmdline = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); else if (!xmlStrcmp(cur->name, (const xmlChar *)"name")) { // name property not used anymore starting from the v0.4.3 } else if (!xmlStrcmp(cur->name, (const xmlChar *)"exec")) exec = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); else if (!xmlStrcmp(cur->name, (const xmlChar *)"args")) args = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); else if (!xmlStrcmp(cur->name, (const xmlChar *)"path")) path = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); else if (!xmlStrcmp(cur->name, (const xmlChar *)"icon")) icon = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); else if (!xmlStrcmp(cur->name, (const xmlChar *)"x")) { buf = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); x = strtol(buf, (char **)NULL, 10); g_free(buf); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"y")) { buf = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); y = strtol(buf, (char **)NULL, 10); g_free(buf); } else ERR("cur->name:%s unknown", cur->name); cur = cur->next; } // starting from the v0.4.3 cmdline replace exec and args if (cmdline == NULL) { if (exec == NULL) { if (args != NULL) cmdline = args; else cmdline = g_strdup(""); } else if (args == NULL) cmdline = exec; else if (strcmp(args, "") == 0) { cmdline = exec; g_free(args); } else { cmdline = g_strconcat(exec, " ", args, NULL); g_free(exec); g_free(args); } } if (path == NULL) path = g_strdup(""); if (icon == NULL) icon = g_strdup(""); app = app_new(cmdline, path, icon, x, y); app_dumpln(app); return app; } // ---------------------------------------------------------------------------- static apwal_pref_t * xmlrc_parse_apwal_pref(xmlDocPtr doc, xmlNodePtr cur) { apwal_pref_t *apwal_pref; gint timeout = 1000; gint exit_at_app_launch = FALSE; gboolean activate_tooltips = TRUE; gboolean iconsel_in_a_separate_window = TRUE; gboolean iconsel_modal = FALSE; char *buf; cur = cur->xmlChildrenNode; while (cur != NULL) { if (!xmlStrcmp(cur->name, (const xmlChar *)"timeout")) { buf = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); timeout = strtol(buf, (char **)NULL, 10); g_free(buf); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"exit_at_app_launch")) { buf = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); exit_at_app_launch = strtol(buf, (char **)NULL, 10); g_free(buf); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"activate_tooltips")) { buf = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); activate_tooltips = strtol(buf, (char **)NULL, 10); g_free(buf); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"iconsel_in_a_separate_window")) { buf = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); iconsel_in_a_separate_window = strtol(buf, (char **)NULL, 10); g_free(buf); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"iconsel_modal")) { buf = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); iconsel_modal = strtol(buf, (char **)NULL, 10); g_free(buf); } else ERR("cur->name:%s unknown", cur->name); cur = cur->next; }//end while cur apwal_pref = apwal_pref_new(timeout, exit_at_app_launch, activate_tooltips, iconsel_in_a_separate_window, iconsel_modal); return apwal_pref; } // ---------------------------------------------------------------------------- static iconsel_pref_t * xmlrc_parse_iconsel_pref(xmlDocPtr doc, xmlNodePtr cur) { iconsel_pref_t *iconsel_pref; GList *icon_dirs = NULL; GList *file_exts = NULL; gboolean select_48 = TRUE; gboolean select_lt48 = TRUE; gboolean select_gt48 = TRUE; gboolean sort_mode = ICONSEL_SORT_DEFAULT; char *buf; gboolean icon_dirs_are_loaded = FALSE; gboolean file_exts_are_loaded = FALSE; cur = cur->xmlChildrenNode; while (cur != NULL) { if (!xmlStrcmp(cur->name, (const xmlChar *) "icon_dirs")) { if (icon_dirs_are_loaded == TRUE) ERR("%s", "there are more that one node"); icon_dirs = xmlrc_parse_icon_dirs(doc, cur); icon_dirs_are_loaded = TRUE; } else if (!xmlStrcmp(cur->name, (const xmlChar *) "file_exts")) { if (file_exts_are_loaded == TRUE) ERR("%s", "there are more that one node"); file_exts = xmlrc_parse_file_exts(doc, cur); file_exts_are_loaded = TRUE; } else if (!xmlStrcmp(cur->name, (const xmlChar *)"select_48")) { buf = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); select_48 = strtol(buf, (char **)NULL, 10); g_free(buf); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"select_lt48")) { buf = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); select_lt48 = strtol(buf, (char **)NULL, 10); g_free(buf); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"select_gt48")) { buf = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); select_gt48 = strtol(buf, (char **)NULL, 10); g_free(buf); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"sort_mode")) { buf = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); sort_mode = strtol(buf, (char **)NULL, 10); g_free(buf); } else ERR("cur->name:%s unknown", cur->name); cur = cur->next; }//end while cur iconsel_pref = iconsel_pref_new(icon_dirs, file_exts, select_48, select_lt48, select_gt48, sort_mode); return iconsel_pref; } // ---------------------------------------------------------------------------- static GList * xmlrc_parse_icon_dirs(xmlDocPtr doc, xmlNodePtr cur) { GList *icon_dirs; icon_dir_t *icon_dir; icon_dirs = NULL; cur = cur->xmlChildrenNode; while (cur) { if (xmlStrcmp(cur->name, (const xmlChar *) "icon_dir")) ERR("cur->name:%s unknown", cur->name); icon_dir = xmlrc_parse_icon_dir(doc, cur); if (icon_dir != NULL) icon_dirs = g_list_append(icon_dirs, icon_dir); cur = cur->next; } return icon_dirs; } // ---------------------------------------------------------------------------- static icon_dir_t * xmlrc_parse_icon_dir(xmlDocPtr doc, xmlNodePtr cur) { icon_dir_t *icon_dir; char *path = NULL; gboolean selected = 1 ; gboolean recursive = FALSE; char *buf; cur = cur->xmlChildrenNode; while (cur != NULL) { if (!xmlStrcmp(cur->name, (const xmlChar *) "path")) path = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); else if (!xmlStrcmp(cur->name, (const xmlChar *)"selected")) { buf = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); selected = strtol(buf, (char **)NULL, 10); g_free(buf); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"recursive")) { buf = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); recursive = strtol(buf, (char **)NULL, 10); g_free(buf); } else ERR("cur->name:%s unknown", cur->name); cur = cur->next; }//end while cur make_path_uniq(&path); icon_dir = icon_dir_new(path, selected, recursive); return icon_dir; } // ---------------------------------------------------------------------------- static GList * xmlrc_parse_file_exts(xmlDocPtr doc, xmlNodePtr cur) { GList *file_exts; file_ext_t *file_ext; file_exts = NULL; cur = cur->xmlChildrenNode; while (cur) { if (xmlStrcmp(cur->name, (const xmlChar *) "file_ext")) ERR("cur->name:%s unknown", cur->name); file_ext = xmlrc_parse_file_ext(doc, cur); if (file_ext != NULL) file_exts = g_list_append(file_exts, file_ext); cur = cur->next; } return file_exts; } // ---------------------------------------------------------------------------- static file_ext_t * xmlrc_parse_file_ext(xmlDocPtr doc, xmlNodePtr cur) { file_ext_t *file_ext; char *extension = NULL; gboolean selected = 1 ; char *buf; cur = cur->xmlChildrenNode; while (cur != NULL) { if (!xmlStrcmp(cur->name, (const xmlChar *) "extension")) extension = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); else if (!xmlStrcmp(cur->name, (const xmlChar *)"selected")) { buf = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); selected = strtol(buf, (char **)NULL, 10); g_free(buf); } else ERR("cur->name:%s unknown", cur->name); cur = cur->next; }//end while cur file_ext = file_ext_new(extension, selected); return file_ext; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void xmlrc_save_to_file(app_list_t *apps, iconsel_pref_t *iconsel_pref, apwal_pref_t *apwal_pref) { xmlDocPtr doc; xmlNodePtr node1; xmlNodePtr node2; xmlNodePtr node3; app_t *app; GList *hamster; icon_dir_t *icon_dir; file_ext_t *file_ext; gint cc; char buf[20]; char flast[FILENAME_MAX]; g_assert(apps != NULL && iconsel_pref != NULL && apwal_pref != NULL); // create new XML document doc = xmlNewDoc("1.0"); doc->xmlRootNode = xmlNewDocNode(doc, NULL, "apwalrc", NULL); node1 = xmlNewChild(doc->xmlRootNode, NULL, "apps", NULL); // save the list of applications for (app=app_list_first(apps); app!=NULL; app=app_list_next(apps)) { node2 = xmlNewChild(node1, NULL, "app", NULL); xmlNewChild(node2, NULL, "cmdline", app->cmdline); xmlNewChild(node2, NULL, "path", app->path); xmlNewChild(node2, NULL, "icon", app->icon); snprintf(buf, sizeof(buf), "%i", app->x); xmlNewChild(node2, NULL, "x", buf); snprintf(buf, sizeof(buf), "%i", app->y); xmlNewChild(node2, NULL, "y", buf); } // save the icon selection prefence node1 = xmlNewChild(doc->xmlRootNode, NULL, "iconsel_pref", NULL); snprintf(buf, sizeof(buf), "%i", iconsel_pref->select_48); xmlNewChild(node1, NULL, "select_48", buf); snprintf(buf, sizeof(buf), "%i", iconsel_pref->select_lt48); xmlNewChild(node1, NULL, "select_lt48", buf); snprintf(buf, sizeof(buf), "%i", iconsel_pref->select_gt48); xmlNewChild(node1, NULL, "select_gt48", buf); snprintf(buf, sizeof(buf), "%i", iconsel_pref->sort_mode); xmlNewChild(node1, NULL, "sort_mode", buf); node2 = xmlNewChild(node1, NULL, "icon_dirs", NULL); hamster = iconsel_pref->icon_dirs; while(hamster != NULL) { icon_dir = hamster->data; // if the icon directory is empty it is not to save if (strcmp(icon_dir->path, "") == 0) { hamster = g_list_next(hamster); continue; } node3 = xmlNewChild(node2, NULL, "icon_dir", NULL); xmlNewChild(node3, NULL, "path", icon_dir->path); snprintf(buf, sizeof(buf), "%i", icon_dir->selected); xmlNewChild(node3, NULL, "selected", buf); snprintf(buf, sizeof(buf), "%i", icon_dir->recursive); xmlNewChild(node3, NULL, "recursive", buf); hamster = g_list_next(hamster); } node2 = xmlNewChild(node1, NULL, "file_exts", NULL); hamster = iconsel_pref->file_exts; while(hamster != NULL) { file_ext = hamster->data; // if the file name extension is empty it is not to save if (strcmp(file_ext->extension, "") == 0) { hamster = g_list_next(hamster); continue; } node3 = xmlNewChild(node2, NULL, "file_ext", NULL); xmlNewChild(node3, NULL, "extension", file_ext->extension); snprintf(buf, sizeof(buf), "%i", file_ext->selected); xmlNewChild(node3, NULL, "selected", buf); hamster = g_list_next(hamster); } // save the apwal preferences node1 = xmlNewChild(doc->xmlRootNode, NULL, "apwal_pref", NULL); snprintf(buf, sizeof(buf), "%i", apwal_pref->timeout); xmlNewChild(node1, NULL, "timeout", buf); snprintf(buf, sizeof(buf), "%i", apwal_pref->exit_at_app_launch); xmlNewChild(node1, NULL, "exit_at_app_launch", buf); snprintf(buf, sizeof(buf), "%i", apwal_pref->activate_tooltips); xmlNewChild(node1, NULL, "activate_tooltips", buf); snprintf(buf, sizeof(buf), "%i", apwal_pref->iconsel_in_a_separate_window); xmlNewChild(node1, NULL, "iconsel_in_a_separate_window", buf); snprintf(buf, sizeof(buf), "%i", apwal_pref->iconsel_modal); xmlNewChild(node1, NULL, "iconsel_modal", buf); // save XML file strcpy(flast, xmlrc_resource_file()); strcat(flast, ".last"); cc = rename(xmlrc_resource_file(), flast); if (cc != 0) ERR("rename %s, %s, cc:%d, errno:%d", xmlrc_resource_file(), flast, cc, errno); cc = xmlSaveFormatFile(xmlrc_resource_file(), doc, 1); if (cc <= 0) ERR("xmlSaveFormatFile, file:%s, cc:%d", xmlrc_resource_file(), cc); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void xmlrc_set_resource_file(char *config_file) { g_assert(g_xmlrc_filerc[0] == '\0'); // set filerc ONE time only if (config_file != NULL) { if (strlen(config_file) >= FILENAME_MAX) ERR("config file name:%d to big", strlen(config_file)); strcat(g_xmlrc_filerc, config_file); } else { char *home; home = getenv("HOME"); if (home == NULL) ERR("%s", "environement variable $HOME not set"); strcpy(g_xmlrc_filerc, home); strcat(g_xmlrc_filerc, "/.apwalrc.xml"); } } // ---------------------------------------------------------------------------- static char* xmlrc_resource_file(void) { g_assert(g_xmlrc_filerc[0] != '\0'); // filerc have to be set return g_xmlrc_filerc; } // ---------------------------------------------------------------------------- gboolean xmlrc_resource_file_exist(void) { char *file; gboolean is_exist; file = xmlrc_resource_file(); is_exist = g_file_test(file, G_FILE_TEST_EXISTS); return is_exist; } // ---------------------------------------------------------------------------- void xmlrc_resource_file_create(void) { int len, fd, cc; fd = creat(xmlrc_resource_file(), 0755); if (fd < 0) ERR("creation of the resource file failed. open cc:%d, errno:%d, file:%s", fd, errno, xmlrc_resource_file()); len = strlen(XMLRC_DEFAULT); cc = write(fd, XMLRC_DEFAULT, len); if (cc != len) ERR("creation of the resource file failed. write cc:%d, errno:%d, file:%s", cc, errno, xmlrc_resource_file()); close(fd); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/xmlrc.h0000644000175000017500000000307710160122275013610 0ustar pebpeb00000000000000/* xmlrc.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- #ifndef XMLRC__H #define XMLRC__H #include "common.h" void xmlrc_load_from_file(app_list_t **apps, iconsel_pref_t **iconsel_pref, apwal_pref_t **apwal_pref); void xmlrc_save_to_file(app_list_t *apps, iconsel_pref_t *iconsel_pref, apwal_pref_t *apwal_pref); gboolean xmlrc_resource_file_exist(void); void xmlrc_resource_file_create(void); void xmlrc_set_resource_file(char *config_file); #endif /*XMLRC__H*/ // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- apwal/src/xstuff.c0000644000175000017500000000262707775104113014006 0ustar pebpeb00000000000000/* xstuff.c * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #if 0 /* DEPRECATED - REPLACE BY gdk_screen_width & height */ #include /* X[Open|Close]Display, XDefaultScreenOfDisplay */ #include // ---------------------------------------------------------------------------- void get_resolution(int *width, int *height) { Display *display; Screen *screen; g_assert(width != NULL && height != NULL); display = XOpenDisplay(""); screen = XDefaultScreenOfDisplay(display); *width = screen->width; *height = screen->height; XCloseDisplay(display); } #endif // ---------------------------------------------------------------------------- apwal/src/xstuff.h0000644000175000017500000000217107775104113014005 0ustar pebpeb00000000000000/* xstuff.h * Copyright (C) 2002-2004 Pascal Eberhard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef XSTUFF__H #define XSTUFF__H // ---------------------------------------------------------------------------- #if 0 /* DEPRECATED - REPLACE BY gdk_screen_width & height */ void get_resolution(int *width, int *height); #endif // ---------------------------------------------------------------------------- #endif /*XSTUFF__H*/