[Xfce4-commits] <ristretto:ristretto-0.0> Merge branch 'master' of stephan/ristretto
Stephan Arts
noreply at xfce.org
Sun Oct 23 19:16:59 CEST 2011
Updating branch refs/heads/ristretto-0.0
to 73c621338fce0b7a508d2ec81e8d8ec5acae3fd9 (commit)
from 924eb9c8b4c87fd09a7c9e34d469b534d4eaf0c1 (commit)
commit 73c621338fce0b7a508d2ec81e8d8ec5acae3fd9
Merge: 924eb9c 9b75414
Author: Stephan Arts <stephan at stephan-laptop.(none)>
Date: Wed Aug 12 18:00:04 2009 +0200
Merge branch 'master' of stephan/ristretto
Conflicts:
ChangeLog
Makefile.am
NEWS
configure.in.in
po/ChangeLog
po/LINGUAS
po/POTFILES.in
po/ar.po
po/bg.po
po/ca.po
po/cs.po
po/da.po
po/de.po
po/el.po
po/en_GB.po
po/es.po
po/eu.po
po/fi.po
po/fr.po
po/gl.po
po/hu.po
po/id.po
po/it.po
po/ja.po
po/lv.po
po/nl.po
po/pl.po
po/pt_BR.po
po/ru.po
po/sk.po
po/tr.po
po/uk.po
po/ur.po
po/zh_CN.po
ristretto.desktop.in
src/Makefile.am
src/main.c
src/main_window.c
src/main_window.h
src/picture_viewer.c
src/picture_viewer.h
src/thumbnail.c
src/thumbnail.h
src/thumbnail_bar.c
src/thumbnail_bar.h
commit 9b75414e8bb4500c58635dd45ecb8f2f45266902
Author: Stephan Arts <stephan at xfce.org>
Date: Sun Jun 21 10:56:27 2009 +0200
Do not open non-image files when opening folder-contents from the recently-used menu.
commit a07d682816dffb989b62eac47f2fbd6f02770201
Author: Stephan Arts <stephan at xfce.org>
Date: Sun Jun 21 10:27:16 2009 +0200
Don't generate the missing-image thumbnail on every expose event.
commit abedf056b8badfb414c41efe142d7ba2bae81172
Author: Stephan Arts <stephan at xfce.org>
Date: Tue Jun 16 22:29:55 2009 +0200
Add workaround for the cache-size calculation
commit 09f2c67e9f24784ba528af9631e60cc38166fba9
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Jun 15 22:07:52 2009 +0200
Improve cancellation of image_load
commit c13156f68cd93ccc2bcbf21af394b65ebf873601
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Jun 15 20:48:02 2009 +0200
Fix quality-combobox of preferences-dialog
commit d67206b1dc62557daf8e26033102a928f3957622
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Jun 15 20:41:50 2009 +0200
Free EXIF data
Improve cache-size calculation
commit cb5053d9d63db53016fd7d0b7873c4231a8280b2
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Jun 13 13:29:09 2009 +0200
Improve thumbnail rendering (can be done with less instructions... but at least it works now)
commit fd7996a3822de483c74595c7c9aa48ace04dddad
Author: Stephan Arts <stephan at xfce.org>
Date: Wed Jun 10 18:54:21 2009 +0200
Fix segfault with animated gifs (Bug #5422)
commit dd00ffe411a25a8655cb4ee92d60b99edbd96445
Author: Stephan Arts <stephan at xfce.org>
Date: Sun Jun 7 10:49:11 2009 +0200
Improve positioning of the thumbnails
commit 8bb5f1ca12914363b49a947867ef905d45045640
Author: Stephan Arts <stephan at xfce.org>
Date: Sun Jun 7 09:48:50 2009 +0200
Improve thumbnail behaviour
commit 609d230ce3dad3b9d51d67858ea88dce0e79d5ee
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Jun 6 18:06:03 2009 +0200
honor thumbnail dimensions in the thumbnail-bar
commit 08a57e5f3c7c487d909059e85f46129bfa91c6a2
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Jun 6 11:35:54 2009 +0200
remove assertion
commit cbce31e3ee0179b8f1dd033d4876e17c65730a1e
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Jun 6 11:18:53 2009 +0200
Show 'image-missing' icon in the thumbnail when there is no thumbnail.
Fix warning in the main_window
commit f11cf02f6589eb413490a32d4230fb5de62c2c24
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Jun 6 11:00:42 2009 +0200
Fix compile-warnings
commit 6b6940b9ce336f83d00fc9b50a7beef94c439583
Author: Stephan Arts <stephan at xfce.org>
Date: Thu Jun 4 23:44:53 2009 +0200
Fix compiler warnings
commit 50b2fe9210cdab8e3db9bb444c751fe4fc312ac4
Author: Stephan Arts <stephan at xfce.org>
Date: Wed Jun 3 22:34:54 2009 +0200
Fixed segfault
commit ead286a0c0dc1ea2820196a8248444b75514125c
Author: Stephan Arts <stephan at xfce.org>
Date: Wed Jun 3 22:23:03 2009 +0200
Fix default image-quality
commit 1eea711f30a5357c81e626e6615237bd0ee5d1ac
Author: Stephan Arts <stephan at xfce.org>
Date: Wed Jun 3 21:58:07 2009 +0200
Add functionality to the message-bar
commit 137a15aa37549cfb88a9a3e80af6621d1e9be5a4
Author: Stephan Arts <stephan at xfce.org>
Date: Wed Jun 3 19:06:53 2009 +0200
Add open-folder question-bar
commit 5cc4ebc2809050737072f9add17a1b2359c3049c
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Jun 1 23:44:14 2009 +0200
Improve positioning code and file-open behaviour
commit 61b9578d193049de5af0e74779e3d63d39d7da2c
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Jun 1 22:29:19 2009 +0200
Remove save-dialog code, not going to support that anyways
commit 33705411c4aea2d081e723dad34116a1e701e5a1
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Jun 1 10:52:22 2009 +0200
Sort items in recently-used menu
commit 7e5c0cc2954ae3939f129354bfac5815f782a296
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Jun 1 10:47:34 2009 +0200
Thumbnail in thumbnailbar has filename as tooltip
commit a4263e79c9584f93191391403f075f4c93d05f0d
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Jun 1 10:42:27 2009 +0200
Update .po files
Make ImageListIter used throughout the app
Guard sanity of ImageListIter
commit 385afa8b8407183b319c26c416cf7b329d5b0f06
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Jun 1 00:19:29 2009 +0200
Expose the image_compare func and use it for the thumbnailbar
commit c6b2411bd4c96a227b8b46b80012e98639a417a1
Author: Stephan Arts <stephan at xfce.org>
Date: Sun May 31 23:52:38 2009 +0200
Rename Navigator to ImageList, makes more sense
commit 61955d3c7a4e42a5de0e19ef738a9db9faa52b82
Author: Stephan Arts <stephan at xfce.org>
Date: Thu May 28 16:04:18 2009 +0200
Add basic thumbnail-bar with test-items
commit 23bec501b47a85cc805b93ee63c8afe5bbb36d7b
Author: Stephan Arts <stephan at xfce.org>
Date: Tue May 26 17:15:16 2009 +0200
Fix upside-down rendering
commit cc9a0da88e61039a1680ba22076e39a0a9d7cca3
Author: Stephan Arts <stephan at xfce.org>
Date: Tue May 26 14:44:19 2009 +0200
Fix typo
commit 94dc596fe5c10eb41f75816663c4ec0f658e69c5
Author: Stephan Arts <stephan at xfce.org>
Date: Tue May 26 13:05:56 2009 +0200
Show an inactive image when there is no image loaded
commit d144f6ee499591485ba8976d0aa2b1c17d756e46
Author: Stephan Arts <stephan at xfce.org>
Date: Tue May 26 09:31:05 2009 +0200
Modify toolbar stuff
commit 6172880e2f774831f5a8ffd111808cae965a9f62
Author: Stephan Arts <stephan at xfce.org>
Date: Mon May 25 16:09:37 2009 +0200
Modified the settings-dialog
commit 5219745d28ce2e720c4119aad585b048a7d59a05
Author: Stephan Arts <stephan at xfce.org>
Date: Mon May 25 13:34:22 2009 +0200
Change .desktop file details
commit 26dad8468682bf62e8cfd8a5f3e0f99b5d687a3b
Author: Stephan Arts <stephan at xfce.org>
Date: Mon May 25 11:49:43 2009 +0200
Fix save-copy sensitivity
commit 33d935289ebb30f921f25dd2ecf472dffaa8c755
Author: Stephan Arts <stephan at xfce.org>
Date: Mon May 25 11:20:40 2009 +0200
Rename save-as to save-copy
commit 2182434ce9cc1ec909e0eafdd141ad8921b21981
Author: Stephan Arts <stephan at xfce.org>
Date: Mon May 25 11:18:18 2009 +0200
Improve cache-size and image-quality calculations
commit 95ea5978a9d91f3cb1bef5300d097d97674d38d8
Author: Stephan Arts <stephan at xfce.org>
Date: Mon May 25 09:38:42 2009 +0200
Add preferences for the open toolbar item
commit d846e6417fd049b2f2668127915fefdef477981e
Author: Stephan Arts <stephan at xfce.org>
Date: Sat May 23 00:23:32 2009 +0200
Make toolbar-open button configurable
commit 61bb958bff96be10e5a194831e73c58a18c5b079
Author: Stephan Arts <stephan at xfce.org>
Date: Fri May 22 23:33:16 2009 +0200
Fix behaviour when switching to the last image
commit 4608a75c0edfe4e17b0b6ad2fe9be671ce576c4b
Author: Stephan Arts <stephan at xfce.org>
Date: Fri May 22 23:27:28 2009 +0200
Sanitize navigator-iter design
commit 73304079584fdced4a7f58b86daacdb58cb68e7d
Author: Stephan Arts <stephan at xfce.org>
Date: Thu May 21 09:52:49 2009 +0200
If a file in the recent-menu does not exist, show an error-dialog
commit 47d300a0eac8bdfb734781b4534a078eebc20d5d
Author: Stephan Arts <stephan at xfce.org>
Date: Thu May 21 09:37:35 2009 +0200
Add Delete menu-item
Add accelerators for leaving fullscreen-mode and navigating the images
commit bac224cb1b66e10412b716087efc58bf3e95eb41
Author: Stephan Arts <stephan at xfce.org>
Date: Wed May 20 00:06:28 2009 +0200
Scale image down to page-size
commit c392e68978eb22be783cc51fb4dc5af083e21019
Author: Stephan Arts <stephan at xfce.org>
Date: Mon May 18 00:41:55 2009 +0200
Fix compiler warning and toggle print-button sensitivity
commit 77ca2890d1c29041719b07704c05dc064d88bf46
Author: Stephan Arts <stephan at xfce.org>
Date: Mon May 18 00:38:39 2009 +0200
Implement first rudimentary printing support
commit feebe0cf4c3df003121cb97768ef2d7e7e3f36c3
Author: Stephan Arts <stephan at thor.(none)>
Date: Sun May 17 11:40:47 2009 +0200
Add printing button
commit 89880a545af123dac21c238051def0054a06f76e
Author: Stephan Arts <stephan at thor.(none)>
Date: Sat May 16 12:31:24 2009 +0200
Clear the cache when the image-quality is changed, and reload the active image
commit 8622ee7260c4f7c3546d0d4518514655f522bbed
Author: Stephan Arts <stephan at thor.(none)>
Date: Sat May 16 11:12:05 2009 +0200
Remove profiling flag
commit 3fdca51f9afb8dc0b8c6d01a6359531ef5545afc
Author: Stephan Arts <stephan at thor.(none)>
Date: Sat May 16 11:08:01 2009 +0200
Fix reference-count on settings-object
Set default accelerator on rotation buttons
commit 10e6f204a2c38fcd091ca023e10078810719adf0
Author: Stephan Arts <stephan at thor.(none)>
Date: Sat May 16 10:55:18 2009 +0200
When the image is rotated upside-down, use the horizontal slider for horizontal scrolling in stead of vertical scrolling. And use the
vertical slider for vertical scrolling instead of horizontal scrolling
commit 1f40e6b21f7fcad72dd19442570ccdf12cc8a6a0
Author: Stephan Arts <stephan at thor.(none)>
Date: Sat May 16 10:49:05 2009 +0200
Re-implement image rotation to work with the new rendering method
commit 35499a94d25bde24f109593fe41b8f04b358202a
Author: Stephan Arts <stephan at thor.(none)>
Date: Fri May 15 19:32:50 2009 +0200
Improve image-size calculation (required for cache-size calc)
commit 9a3eeb38527886d402c868969bf102e1a761c0ff
Author: Stephan Arts <stephan at thor.(none)>
Date: Fri May 15 21:46:15 2009 +0200
Set current-uri to open-folder dialog
commit 66cae1e72422b4912d5cc852c4989a9225322ea3
Author: Stephan Arts <stephan at thor.(none)>
Date: Fri May 15 18:33:06 2009 +0200
Revert "Implement state-machine in image class"
This reverts commit 96ee95c3848f91e9693d4519e1c7d52f35ab4340.
commit 99f0917fc1d220dd6a2ef61a5f5f53fe2e839065
Author: Stephan Arts <stephan at thor.(none)>
Date: Fri May 15 18:00:45 2009 +0200
Fix memory leak in image class (unref animation-iter)
commit 96ee95c3848f91e9693d4519e1c7d52f35ab4340
Author: Stephan Arts <stephan at thor.(none)>
Date: Fri May 15 01:03:53 2009 +0200
Implement state-machine in image class
commit e47e53b62d95d969276956fb50a659b99cb6738a
Author: Stephan Arts <stephan at xfce.org>
Date: Sat May 2 16:19:18 2009 +0200
Improve cache behaviour
commit b53ef99302afe9424dc1f8424e0c896034f3069c
Author: Stephan Arts <stephan at xfce.org>
Date: Sat May 2 01:27:36 2009 +0200
Added save-as function
* src/main_window.c
src/main_window_ui.xml: Implement save-as function (Bug #4647)
* src/navigator.c: Fix iter_find_image function
* src/image_cache.h
src/image_cache.c: Return TRUE when the cache had to drop images to
fit the new one.
* src/main.c: Fix error when trying to open nonexistent file from the
CLI
commit 4b1c367e21a57eaf0f1785838268f379f22bde89
Author: Stephan Arts <stephan at xfce.org>
Date: Sat May 2 00:32:50 2009 +0200
Implement image-cache size calculation
commit e81a905eac295ffb23214cac5f239e8c0370379d
Author: Stephan Arts <stephan at xfce.org>
Date: Sat May 2 00:31:31 2009 +0200
Add jpeg filter to open files dialog
commit 90a0d52283c57eafc4c49e2065883a4828580e65
Author: Stephan Arts <stephan at xfce.org>
Date: Fri May 1 10:37:26 2009 +0200
Make sure sticky does not break the visibility of the fs-toolbar
commit 20f7ffbc978263b6dff3a6ac5040909a38f9b402
Author: Stephan Arts <stephan at xfce.org>
Date: Thu Apr 30 23:30:32 2009 +0200
Implement hack to check if the image has been rotated
commit 41f49ce624d31417b35e1f8b171148fda8ca5269
Author: Stephan Arts <stephan at xfce.org>
Date: Thu Apr 30 09:52:59 2009 +0200
Add sticky button to fullscreen-toolbar
commit 1e586ea0c33bed9d55245b85a508bc277da099ee
Author: Stephan Arts <stephan at xfce.org>
Date: Thu Apr 30 09:35:17 2009 +0200
Set important hint on leave-fullscreen toolbar item
commit c75595516827f2c6fc5552e81335088a3af7da48
Author: Stephan Arts <stephan at xfce.org>
Date: Thu Apr 30 09:26:43 2009 +0200
Improve behaviour when in fullscreen mode
commit 81c13825b177d82b6f72cb06b8e28cbae9fa8163
Author: Stephan Arts <stephan at xfce.org>
Date: Thu Apr 30 08:29:53 2009 +0200
Let the pictureviewer figure out the fullscreen mode by itself
commit 79b7af6a3c4556054e689bff631b0b53379bb350
Author: Stephan Arts <stephan at xfce.org>
Date: Tue Apr 28 18:59:51 2009 +0200
* src/image.c
src/pictureviewer.c: Emit 'prepared' signal when the size-prepared signal
is emitted, instead of waiting for the area-prepared signal. When the
image is rendered at a different scale then 'maximum', the
'area-prepared', 'area-updated' and 'closed' signals are all emitted at
once. Then the thumbnail is not displayed when the image is not ready yet.
* src/pictureviewer.c: Do not repaint the image when the image is
'prepared' but there is no thumbnail available. This will prevent the
image from flickering.
* src/image_cache.c: Implement 'enable'/'disable' of image-cache
* src/main_window_ui.xml
src/main_window.c: Remove properties dialog menu item
* src/pictureviewer.c: Add a 'fullscreen' state, setting a different
background-color if it is in fullscreen.
commit 980a4b09195f393b76bfa1985726f7eab2364651
Author: Stephan Arts <stephan at xfce.org>
Date: Tue Apr 28 07:41:48 2009 +0200
Set ratio-trigger to 1, '0' will never do anything
commit 415eea3428c67d8bc2ae097c451a3d2ea001d307
Author: Stephan Arts <stephan at xfce.org>
Date: Tue Apr 28 00:26:34 2009 +0200
Do not scale the image UP, only DOWN
Fix warning if thumbnail does not exist
commit 97ee4a1faf585e0386bcf05cc64c092fb3ebb5d3
Author: Stephan Arts <stephan at xfce.org>
Date: Tue Apr 28 00:01:29 2009 +0200
Implement preferences option for the image-quality
commit 8ad85cec725c16125ca2ca1ee38d3262a44b6421
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Apr 27 23:30:18 2009 +0200
Add image_quality as a property that can be configured (default to 2MP)
commit cc07db14e094aead5cd174d641f44ef5ac2a911e
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Apr 27 21:30:09 2009 +0200
Add 'enable-cache' option
Add maximum-render-quality of 1MP (can be configured with later commits)
Destroy open_folder dialog after use
Update TODO
commit 42db1caddceb8fbb5516b1e7e6790a9e92da2107
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Apr 27 00:39:59 2009 +0200
disable slideshow tab too
commit e148dbd2f8ee70b39cef9f6a2a723ea4edfa7848
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Apr 27 00:38:38 2009 +0200
Disable unimplemented tabs
commit d5dc066d91eb2ea4c31a50ee8ab23b9a02900eb5
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Apr 27 00:34:36 2009 +0200
Implement 'display' tab the right way :)
commit c0eae3ec6f54a57bfde0666bbeddd55a41c8a049
Author: Stephan Arts <stephan at xfce.org>
Date: Thu Apr 23 00:11:54 2009 +0200
Mak sure bgcolor is not initialised with random color
commit be4b10beab50a7a9e3ceb6e84fbfd65cd223395f
Author: Stephan Arts <stephan at xfce.org>
Date: Wed Apr 22 00:40:08 2009 +0200
Implement bgcolor settings
commit c2a9945bcada416a23698705f6402560405c756c
Author: Stephan Arts <stephan at xfce.org>
Date: Fri Apr 3 12:02:38 2009 +0200
Clean up looks of preferences dialog
Update TODO
commit 83656e1f3afa123a0cd5a645c089adaffbe13ac5
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Mar 23 21:59:36 2009 +0100
Add missing options to the preferences dialog
commit 8f3bd6691ddf5e23883d31307bef55bbee5e9e28
Author: Stephan Arts <stephan at xfce.org>
Date: Sun Mar 22 09:46:57 2009 +0100
Implement bgcolor related settings in Settingsmanager
Add a few options to the preferences dialog (still not doing anything)
commit 94adc418fdc9869d468f34b004ae8038aa49bc35
Author: Stephan Arts <stephan at xfce.org>
Date: Fri Mar 13 23:18:18 2009 +0100
- Fix picture viewer refresh when no image is present
- Add notebook to preferences dialog
- Rename icon in preferences dialog
commit 64c12a35e6f7465c3b5e4a31c18d8526019c81a7
Author: Stephan Arts <stephan at xfce.org>
Date: Fri Mar 13 21:19:31 2009 +0100
cleanup some code
commit 148698070231eb6527c8e08cec68e0de5b432eea
Author: Stephan Arts <stephan at xfce.org>
Date: Fri Mar 13 20:06:01 2009 +0100
Improve moving of the image
commit 7566a5a251dd6a37bc30889dab19aa8615361b5a
Author: Stephan Arts <stephan at xfce.org>
Date: Wed Mar 11 16:36:13 2009 +0100
Improved behaviour when zooming inside a previewed image
commit 3c9fbba878bb2518b4e9915f43be88dcb0b501a8
Author: Stephan Arts <stephan at xfce.org>
Date: Tue Mar 10 13:02:15 2009 +0100
Fix 'zoom-fit' when resizing
commit 656f9b4bb9f4b7d51cc012a384e08fa4f0175879
Author: Stephan Arts <stephan at xfce.org>
Date: Tue Mar 10 09:28:26 2009 +0100
Fix moving of zoomed-in image
commit f6b085b3e0b356796a592414249485c7a8e8ae20
Merge: 7c3c0b8 0c1e906
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Mar 9 22:01:38 2009 +0100
Merge branch 'breakup_refresh'
Conflicts:
src/picture_viewer.c
commit 7c3c0b8d56ed639352d7e11d1bdf3058052a2d5c
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Mar 9 22:00:05 2009 +0100
Revert "add new entry in news"
This reverts commit 5932e7f473d373ae87c8532a29c9ee7fc5017a9f.
commit 8ecfb6a2e3e91f6857266a9d17d8475a8d97420e
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Mar 9 21:59:38 2009 +0100
Revert "That was a bug... reverting last change, I need to implement some better"
This reverts commit 580177dc2ef4a2b3eaeade76bd83a94a1b6b9534.
commit 0c1e906c2931655b6f075bb7105895748b50946a
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Mar 9 21:51:09 2009 +0100
Emit 'updated' signal when 'rstto_image_load' is called and the image is already there.
commit 68f99e86e52a3bbd80337b2e8516133eab1aaa23
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Mar 9 21:44:47 2009 +0100
Fix zoom-in and zoom-out (accidently passed a boolean instead of a double)
commit 2b5990b32b22c130f54395eb0f61f9c7ad107e27
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Mar 9 00:28:49 2009 +0100
Move DnD code to the bottom of the file
commit edf1b2a317f77e5b162a50c0ac5e8d11e0703a9b
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Mar 9 00:23:48 2009 +0100
Fix segfault
commit 1da739e89571c1775602a511ad86b5c0ed97a8e1
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Mar 9 00:03:41 2009 +0100
Made all the scale related functions internal
commit 7da92c8d582e14d50adfee29144751e7b89b93cb
Author: Stephan Arts <stephan at xfce.org>
Date: Sun Mar 8 14:22:37 2009 +0100
Split 'view' state from 'motion' state
commit 5932e7f473d373ae87c8532a29c9ee7fc5017a9f
Author: Stephan Arts <stephan at xfce.org>
Date: Fri Mar 6 15:29:13 2009 +0100
add new entry in news
commit 691a6a7c89eb2902984ac6ccfe02e219168b82f4
Author: Stephan Arts <stephan at xfce.org>
Date: Fri Mar 6 15:28:33 2009 +0100
commit changes
commit ad1c2baadb12b28c47cbeb97b622af39d614ba5a
Author: Stephan Arts <stephan at xfce.org>
Date: Sun Feb 22 10:40:29 2009 +0100
Add refresh mask, needs some tweaking, but it solves the drag performance-loss.
Eventually, this should reduce the times ristretto scales the image.
commit 580177dc2ef4a2b3eaeade76bd83a94a1b6b9534
Author: Stephan Arts <stephan at xfce.org>
Date: Sun Feb 22 09:36:36 2009 +0100
That was a bug... reverting last change, I need to implement some better
way of doing this.
commit fa5894a0df7f1bc7052c17fd2085e81b906497ba
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Feb 21 18:00:43 2009 +0100
Improved performance when drawing the zoom-box, don't do a refresh when performing a queued_repaint, just paint the darn thing.
commit 67ce593c1d98dc141cfa28df268c5d5ff4338e02
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Feb 21 17:48:50 2009 +0100
Enable mouse-move on picture viewer
commit 79b6826f644c87e459531d01f1f50458a3925678
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Feb 21 17:31:54 2009 +0100
Add string.h header to prevent a compiler warning
commit f28d501a4b94c752e2ad1e6ab4c8d06086a57907
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Feb 21 16:38:56 2009 +0100
Fix the adjustment settings
commit 58bee9be96336fe2448bae3f8f9906eaa2055169
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Feb 21 16:08:42 2009 +0100
Add some rudimentary preview support
commit 9a99870c75f66aa963e22434ff4f1c5fc2a521f4
Merge: c2e9b6b ce3185b
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Feb 21 11:06:54 2009 +0100
Merge branch 'master' into new_picture_viewer
commit ce3185bf18ad773e073ab83e87354f7c4da9507c
Merge: 3f8ba01 1d06647
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Feb 21 10:59:21 2009 +0100
Merge branch 'recent_menu'
commit 1d06647dac89feb4e0eb82ac437b7710b7753b8c
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Feb 21 10:56:52 2009 +0100
Implemented 'open folder'.
commit 73a8d7229f688d4b796117843b97b0101c1f5fdc
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Feb 21 10:09:19 2009 +0100
Add some more comments
Add a recent-filter to the recent-chooser (only filter the files opened by ristretto)
Actually open files from the recent-chooser
commit c2e9b6b2e7c036f6e144318f9856ed44c28e69ae
Merge: d4e2a5d 3f8ba01
Author: Stephan Arts <stephan at thor.(none)>
Date: Sat Feb 21 09:26:25 2009 +0100
Merge branch 'master' into new_picture_viewer
commit 3f8ba01f6df517764a03802d145dfcf18bf14fbc
Author: Stephan Arts <stephan at thor.(none)>
Date: Sat Feb 21 09:22:56 2009 +0100
Remove autogenerated header file from git
commit f4223148a6df935fa94da97a94ec04e89c0f29db
Author: Stephan Arts <stephan at thor.(none)>
Date: Sat Feb 21 09:18:33 2009 +0100
Removed autogenerated header from git
Added the recently used menu to the file-menu
commit d4e2a5d7d9d203d5477a3dad227c1d7849b80df4
Author: Stephan Arts <stephan at thor.(none)>
Date: Sat Feb 21 01:08:31 2009 +0100
Add a preload state to the pictureviewer, where it will render the thumbnail instead of the original image.
commit 7d29665d25fe6356853220c6a2e3506fe02d9635
Author: Stephan Arts <stephan at thor.(none)>
Date: Sat Feb 21 00:15:57 2009 +0100
Add missing main_window_ui.xml file from svn
commit 64cb5958270db4126e75a42cdf99838485501c14
Author: Stephan Arts <stephan at thor.(none)>
Date: Sat Feb 21 00:06:18 2009 +0100
Initial Commit
ChangeLog | 245 +++-
Makefile.am | 4 +-
NEWS | 9 +
TODO | 21 +
configure.in.in | 60 +-
docs/Makefile.am | 1 +
docs/manual/C/Makefile.am | 66 +
docs/manual/C/images/Makefile.am | 7 +
docs/manual/C/ristretto.xml.in | 66 +
docs/manual/Makefile.am | 6 +
docs/manual/ristretto.css | 101 ++
docs/manual/ristretto.xsl | 255 +++
po/POTFILES.in | 8 +-
ristretto.desktop.in | 4 +-
src/Makefile.am | 41 +-
src/image.c | 736 +++++++++
src/image.h | 93 ++
src/image_cache.c | 208 +++
src/image_cache.h | 57 +
src/image_list.c | 489 ++++++
src/image_list.h | 121 ++
src/main.c | 444 +-----
src/main_window.c | 3281 +++++++++++++++++--------------------
src/main_window.h | 69 +-
src/main_window_ui.xml | 101 ++
src/picture_viewer.c | 1587 +++++++++++--------
src/picture_viewer.h | 27 +-
src/preferences_dialog.c | 523 ++++++
src/preferences_dialog.h | 68 +
src/settings.c | 488 ++++++
src/{save_dialog.h => settings.h} | 52 +-
src/thumbnail.c | 226 ++-
src/thumbnail.h | 5 +-
src/thumbnail_bar.c | 402 ++---
src/thumbnail_bar.h | 3 +
35 files changed, 6575 insertions(+), 3299 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0ae2355..6c94d6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,247 @@
+2009-08-12 Stephan Arts <stephan at xfce.org>
+
+ * ChangeLog: Merge with private branch
+
+2009-06-01 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c
+ src/image_list.c: Improve positioning code and file-open behaviour
+
+2009-06-01 Stephan Arts <stephan at xfce.org>
+
+ * src/save_dialog.c
+ src/save_dialog.h: Remove save-dialog code not going to support that
+ anyways
+
+2009-06-01 Stephan Arts <stephan at xfce.org>
+
+ * src/image_list.h
+ src/image_list.c
+ src/thumbnail_bar.c: Expose compare_func, and use it in the thumbnailbar
+
+2009-06-01 Stephan Arts <stephan at xfce.org>
+
+ * src/*: Rename Navigator to ImageList, makes more sense
+
+2009-05-26 Stephan Arts <stephan at xfce.org>
+
+ * src/picture_viewer.c: Show an 'inactive' image when there is no
+ image loaded.
+
+2009-05-25 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c: change open-folder icon to 'folder-open' instead of
+ 'document-open'
+ * src/settings.c
+ src/preferences_dialog.c: Make preload-images an number value (as-in,
+ how many should be preloaded)
+ * src/preferences_dialog.c: Change the values in the quality-combo to
+ something human-readable.
+ * src/preferences_dialog.c: Move image-quality frame to the behaviour tab.
+
+2009-05-25 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c: Fix sensitivity of the save-copy button
+
+2009-05-25 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c
+ src/main_window_ui.xml: Rename save-as to save-copy (suggested by cody
+ somerville)
+
+2009-05-25 Stephan Arts <stephan at xfce.org>
+
+ * src/image_cache.c
+ src/preferences_dialog.c
+ src/settings.c
+ src/image.c: Improve cache-size and image-quality calculations
+
+2009-05-25 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c
+ src/preferences_dialog.c: Implement preferences for the 'open' toolbar
+ item.
+ * TODO: Update TODO
+
+2009-05-23 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c
+ src/main_window_ui.xml
+ src/settings.c: Add ability to configure the toolbar-open button, it can
+ now do the following:
+ - Open image
+ - Open folder
+ - None (disappear)
+
+2009-05-22 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c: Fix behaviour when switching to the last image
+
+2009-05-22 Stephan Arts <stephan at xfce.org>
+
+ * src/navigating.c,
+ src/main_window.c: Sanitize navigator-iter design
+
+2009-05-21 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c: if a file in the recent_menu does not exist, because
+ it has been deleted, show an error-dialog
+
+2009-05-21 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c
+ src/main_window_ui.xml: Add 'delete' button to remove an image from disk
+ (Bug #4135)
+ * src/main_window.c: Add accelerators for leaving fullscreen-mode,
+ navigating to the next image and to the previous image using Escape,
+ Page_Up and Page_Down respectively
+
+2009-05-20 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c: Scale the image down to page-size
+
+2009-05-17 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c: Toggle printing-button sensitivity
+ * src/main_window.c: Fix compiler warning
+
+2009-05-17 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c: Implement first rudimentary printing.
+
+2009-05-16 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c
+ src/image_cache.c
+ src/image_cache.h: Clear the cache when the image-quality is changed
+
+2009-05-16 Stephan Arts <stephan at xfce.org>
+
+ * src/Makefile.am: Remove profiling flag
+
+2009-05-16 Stephan Arts <stephan at xfce.org>
+
+ * src/image_cache.c
+ src/picture_viewer.c
+ src/main_window.c: Fix reference-count on settings-object
+ * src/main_window.c: Set default accelerators on rotation buttons
+
+2009-05-16 Stephan Arts <stephan at xfce.org>
+
+ * src/picture_viewer.c: When an image is rotated upside down, make sure
+ the horizontal slider works horizontally and the vertical slider works
+ vertically. These were switched :-p
+
+2009-05-16 Stephan Arts <stephan at xfce.org>
+
+ * src/image.c
+ src/image.h
+ src/main_window.c
+ src/picture_viewer.c
+ src/image_transformation.h
+ src/image_transformation.c
+ src/image_transform_orientation.h
+ src/image_transform_orientation.c
+ src/Makefile.am: Re-implement image-rotation, now it finally works with
+ the new rendering method.
+
+
+2009-05-15 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c: Set current_uri on open_folder dialog
+ * src/image.c
+ src/image.h
+ src/picture_viewer.c: Remove state-machine, breaks things
+
+2009-05-15 Stephan Arts <stephan at xfce.org>
+
+ * src/image.c
+ src/image.h
+ src/picture_viewer.c: Implement state-machine, do not expose weird
+ signals
+ * src/image.c: Unref animation_iter, fix memleak
+
+2009-05-02 Stephan Arts <stephan at xfce.org>
+
+ * src/image_cache.c: Remove images which return size=0 from the cache,
+ it might still be loading, in which case it should stop immediately and
+ be dropped from the cache
+ * src/image.c
+ src/image.h
+ src/image_cache.c: calculate cache-size in uint instead of uint64
+
+2009-05-02 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c
+ src/main_window_ui.xml: Implement save-as function (Bug #4647)
+ * src/navigator.c: Fix iter_find_image function
+ * src/image_cache.h
+ src/image_cache.c: Return TRUE when the cache had to drop images to
+ fit the new one.
+ * src/main.c: Fix error when trying to open nonexistent file from the
+ CLI
+
+2009-05-02 Stephan Arts <stephan at xfce.org>
+
+ * src/image,c
+ src/image.h
+ src/image_cache.c: Implement image-cache size calculation (Bug #4064)
+
+2009-05-02 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c: Add jpeg filter to the open-files dialog
+
+2009-05-01 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c: Make sure the fullscreen-toolbar gets shown in
+ fullscreen mode when ristretto left fullscreen with sticky set.
+
+2009-04-30 Stephan Arts <stephan at xfce.org>
+
+ * src/picture_viewer.c: Implement a hack to check if the pixbuf has
+ been rotated.
+
+2009-04-30 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c
+ src/main_window_ui.xml: Add Sticky button to the fullscreen-toolbar.
+
+2009-04-30 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c
+ src/main_window_ui.xml: Set is_important hint on 'leave-fullscreen'
+ toolitem.
+
+2009-04-30 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c
+ src/main_window_ui.xml: Add 'fullscreen-toolbar' with controls when in
+ fullscreen-mode.
+
+2009-04-30 Stephan Arts <stephan at xfce.org>
+
+ * src/main_window.c
+ src/picture_viewer.c
+ src/picture_viewer.h: Let the pictureviewer figure out the fullscreen-
+ state of it's parent-window by itself
+
+2009-04-28 Stephan Arts <stephan at xfce.org>
+
+ * src/image.c
+ src/picture_viewer.c: Emit 'prepared' signal when the size-prepared signal
+ is emitted, instead of waiting for the area-prepared signal. When the
+ image is rendered at a different scale then 'maximum', the
+ 'area-prepared', 'area-updated' and 'closed' signals are all emitted at
+ once. Then the thumbnail is not displayed when the image is not ready yet.
+ * src/picture_viewer.c: Do not repaint the image when the image is
+ 'prepared' but there is no thumbnail available. This will prevent the
+ image from flickering.
+ * src/image_cache.c: Implement 'enable'/'disable' of image-cache
+ * src/main_window_ui.xml
+ src/main_window.c: Remove properties dialog menu item
+ * src/picture_viewer.c: Add a 'fullscreen' state, setting a different
+ background-color if it is in fullscreen.
+
2009-05-15 16:51 stephan
* src/navigator.c:
@@ -3150,4 +3394,3 @@
* .:
Adding ristretto/{tags,branches,trunk}
-
diff --git a/Makefile.am b/Makefile.am
index b1b8ce6..d358382 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
-SUBDIRS = src po icons
+SUBDIRS = src po icons docs
desktopdir = $(datadir)/applications
desktop_in_files = ristretto.desktop.in
@@ -21,3 +21,5 @@ DISTCLEANFILES = \
intltool-merge \
intltool-update \
$(desktop_DATA)
+
+DISTCHECK_CONFIGURE_FLAGS=--enable-xsltproc
diff --git a/NEWS b/NEWS
index d40d629..ad584bf 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,12 @@
+0.x.x
+=====
+- Remove dependency on thunar
+- Port to GIO instead of thunarvfs
+- Add option to select maximum render quality (can improve performance at the
+ cost of image-quality)
+- Store the settings in xfconf
+- Add option to completely disable the image-cache
+
0.0.22
======
diff --git a/TODO b/TODO
index e69de29..fb53141 100644
--- a/TODO
+++ b/TODO
@@ -0,0 +1,21 @@
+- Implement preferences dialog
+- Generate and save thumbnails (contact thumbler)
+
+- Support setting wallpapers
+ - xfdesktop
+ - nautilus
+ - rox
+
+- Implement box-zoom
+
+- Add preloading
+- Improve cache calculation
+
+- Write comments
+
+- Implement thumbnailbar
+
+- Support image collections
+ - Export to tarball/zip
+
+- Configure printing-settings
diff --git a/configure.in.in b/configure.in.in
index 3a3c365..123a1f1 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -1,5 +1,5 @@
dnl
-dnl Copyright (c) 2006
+dnl Copyright (c) 2006-2009
dnl The Xfce development team. All rights reserved.
dnl
dnl Originally written for Xfce by Benedikt Meurer <benny at xfce.org>
@@ -13,7 +13,7 @@ m4_define([ristretto_version_major], [0])
m4_define([ristretto_version_minor], [0])
m4_define([ristretto_version_micro], [22])
m4_define([ristretto_version_build], [r at REVISION@])
-m4_define([ristretto_version_tag], []) # Leave empty for releases
+m4_define([ristretto_version_tag], [gio]) # Leave empty for releases
m4_define([ristretto_version], [ristretto_version_major().ristretto_version_minor().ristretto_version_micro()ifelse(ristretto_version_tag(),[],[], [-ifelse(ristretto_version_tag(), [svn], [ristretto_version_tag()-ristretto_version_build()], [ristretto_version_tag()])])])
dnl *******************************************
@@ -21,7 +21,7 @@ dnl *** Debugging support for SVN snapshots ***
dnl *******************************************
m4_define([ristretto_debug_default], [ifelse(ristretto_version_tag(), [svn], [full], [minimum])])
-AC_COPYRIGHT([Copyright (c) 2006-2008
+AC_COPYRIGHT([Copyright (c) 2006-2009
The Xfce development team. All rights reserved.
Written for Xfce by Stephan Arts <stephan at xfce.org>.])
@@ -45,35 +45,38 @@ dnl check for standard header files
AC_PROG_CC
AC_PROG_INTLTOOL([0.31], [no-xml])
+
AC_HEADER_STDC
dnl Check for i18n support
XDT_I18N([@LINGUAS@])
XDT_CHECK_PACKAGE([LIBEXIF], [libexif], [0.6.0])
-XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.10.0])
-XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.12.0])
-XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [2.12.0])
-XDT_CHECK_PACKAGE([THUNAR_VFS], [thunar-vfs-1], [0.4.0])
+XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.12.0])
+XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.16.0])
+XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.16.0])
+XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [2.16.0])
+XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.16.0])
XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.34])
-XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0])
-XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.4.0])
-
-AC_ARG_ENABLE([xfce-desktop],
- [AC_HELP_STRING([--enable-xfce-desktop],
- [Build with xfdesktop support (xfce >= 4.5)])],
- [build_xfce_desktop=$enableval],
- [build_xfce_desktop=yes])
-if test "x$build_xfce_desktop" = "xyes"; then
- AC_CHECK_PROG([xfconf_query_found], [xfconf-query], [yes], [no])
- if test x"$xfconf_query_found" = x"no"; then
- echo "***"
- echo "*** xfconf-query was not found on your system."
- echo "*** The wallpaper won't work without it installed."
- echo "***"
- fi
- AC_DEFINE([WITH_DESKTOP_WALLPAPER], [1], [Define With Desktop wallpaper])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.6.0])
+XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.6.0])
+
+XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.6.0])
+
+XDT_CHECK_PACKAGE([CAIRO], [cairo], [1.8.0])
+
+dnl **************************
+dnl *** Check for xsltproc ***
+dnl **************************
+AC_ARG_ENABLE([xsltproc], [AC_HELP_STRING([--enable-xsltproc], [Use xsltproc to build documentation @<:@default=no@:>@])],, [enable_xsltproc=no])
+if test x"$enable_xsltproc" = x"yes"; then
+ AC_PATH_PROG([XSLTPROC], [xsltproc], [no])
+ if test x"$XSLTPROC" = x"no"; then
+ enable_xsltproc=no
+ fi
fi
+AM_CONDITIONAL([ENABLE_XSLTPROC], [test x"$enable_xsltproc" = x"yes"])
+
dnl check for debugging support
@@ -83,6 +86,11 @@ AC_OUTPUT([
Makefile
po/Makefile.in
src/Makefile
+docs/Makefile
+docs/manual/Makefile
+docs/manual/C/Makefile
+docs/manual/C/ristretto.xml
+docs/manual/C/images/Makefile
icons/Makefile
icons/16x16/Makefile
icons/22x22/Makefile
@@ -98,7 +106,3 @@ echo "$PACKAGE $VERSION"
echo ""
echo "The binary will be installed in $prefix/bin"
echo "----------------------------------------"
-echo "Xfce 4.6 wallpaper support: $build_xfce_desktop"
-echo ""
-echo ""
-echo "Configure finished, type 'make' to build."
diff --git a/docs/Makefile.am b/docs/Makefile.am
new file mode 100644
index 0000000..e76efaf
--- /dev/null
+++ b/docs/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = manual
diff --git a/docs/manual/C/Makefile.am b/docs/manual/C/Makefile.am
new file mode 100644
index 0000000..b15d68e
--- /dev/null
+++ b/docs/manual/C/Makefile.am
@@ -0,0 +1,66 @@
+# Copied from Thunar, original author: Benedict Meurer
+
+SUBDIRS = \
+ images
+
+TARGET_DIR = $(datadir)/doc/ristretto/html/C
+STYLESHEET = ../ristretto.xsl
+DOCUMENT = ristretto.xml
+
+# We set GPATH here; this gives us semantics for GNU make
+# which are more like other make's VPATH, when it comes to
+# whether a source that is a target of one rule is then
+# searched for in VPATH/GPATH.
+GPATH = $(srcdir)
+
+DOC_STAMPS = html-build.stamp
+
+EXTRA_DIST = $(DOCUMENT)
+CLEANFILES = $(DOC_STAMPS)
+
+if ENABLE_XSLTPROC
+all-local: html-build.stamp
+
+html-build.stamp: $(srcdir)/$(DOCUMENT) $(srcdir)/$(STYLESHEET)
+ @echo "*** Building HTML ***"
+ @-chmod -R u+w $(srcdir)
+ rm -rf $(srcdir)/html
+ mkdir $(srcdir)/html
+ $(XSLTPROC) --nonet -o $(srcdir)/html/ $(srcdir)/$(STYLESHEET) \
+ $(srcdir)/$(DOCUMENT)
+ touch html-build.stamp
+else
+all-local:
+endif
+
+maintainer-clean-local: clean
+ (cd $(srcdir) && rm -rf html)
+
+install-data-local:
+ installfiles=`echo $(srcdir)/html/*`; \
+ if test "$$installfiles" = '$(srcdir)/html/*'; then \
+ echo "--- Nothing to install"; \
+ else \
+ $(mkinstalldirs) $(DESTDIR)$(TARGET_DIR); \
+ for file in $$installfiles; do \
+ echo "--- Installing "$$file; \
+ $(INSTALL_DATA) $$file $(DESTDIR)$(TARGET_DIR); \
+ done; \
+ fi
+
+uninstall-local:
+ rm -rf $(DESTDIR)$(TARGET_DIR)/*
+
+if ENABLE_XSLTPROC
+dist-check-xsltproc: all
+else
+dist-check-xsltproc:
+ @echo "*** xsltproc must be installed and enabled in order to make dist"
+ @false
+endif
+
+dist-hook: dist-check-xsltproc dist-hook-local
+ mkdir $(distdir)/html
+ -cp $(srcdir)/html/* $(distdir)/html
+
+.PHONY: dist-hook-local
diff --git a/docs/manual/C/images/Makefile.am b/docs/manual/C/images/Makefile.am
new file mode 100644
index 0000000..7b02fc9
--- /dev/null
+++ b/docs/manual/C/images/Makefile.am
@@ -0,0 +1,7 @@
+
+imagesdir = $(datadir)/doc/ristretto/html/C/images
+images_DATA =
+
+EXTRA_DIST = \
+ $(images_DATA)
+
diff --git a/docs/manual/C/ristretto.xml.in b/docs/manual/C/ristretto.xml.in
new file mode 100644
index 0000000..e2e704b
--- /dev/null
+++ b/docs/manual/C/ristretto.xml.in
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+ <!ENTITY date "Januari 2009">
+ <!ENTITY version "@PACKAGE_VERSION@">
+ <!ENTITY application "@PACKAGE_NAME@">
+]>
+<article id="index" lang="en">
+
+ <!-- Header -->
+ <articleinfo>
+ <title>Ristretto Image Viewer</title>
+
+ <pubdate>&date;</pubdate>
+
+ <copyright>
+ <year>2006</year>
+ <year>2007</year>
+ <year>2008</year>
+ <year>2008</year>
+ <holder>Stephan Arts</holder>
+ </copyright>
+
+ <legalnotice id="legalnotice">
+ <para>
+ Permission is granted to copy, distribute and/or modify this document
+ under the terms of the GNU Free Documentation License, Version 1.1 or
+ any later version published by the Free Software Foundation; with no
+ Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
+ Texts. The complete license text is available from the <ulink
+ type="http" url="http://www.gnu.org/">Free Software Foundation</ulink>.
+ </para>
+ </legalnotice>
+
+ <authorgroup>
+ <author>
+ <firstname>Stephan</firstname>
+ <surname>Arts</surname>
+ <affiliation>
+ <address><email>stephan at xfce.org</email></address>
+ <!--
+ <orgname>os-cillation</orgname>
+ <orgdiv>System development</orgdiv>
+ <jobtitle>Software developer</jobtitle>
+ -->
+ </affiliation>
+ </author>
+ </authorgroup>
+
+ <releaseinfo>
+ This manual describes version &version; of &application;.
+ </releaseinfo>
+ </articleinfo>
+
+ <sect1 id="intro">
+ <title>Introduction to &application;</title>
+
+ <para>
+ </para>
+
+ </sect1>
+
+</article>
+<!--
+ vim:set ts=2 sw=2 et ai encoding=UTF-8:
+-->
diff --git a/docs/manual/Makefile.am b/docs/manual/Makefile.am
new file mode 100644
index 0000000..5416fbf
--- /dev/null
+++ b/docs/manual/Makefile.am
@@ -0,0 +1,6 @@
+SUBDIRS = \
+ C
+
+EXTRA_DIST = \
+ ristretto.css \
+ ristretto.xsl
diff --git a/docs/manual/ristretto.css b/docs/manual/ristretto.css
new file mode 100644
index 0000000..6a99dba
--- /dev/null
+++ b/docs/manual/ristretto.css
@@ -0,0 +1,101 @@
+/* Copied from Thunar written by Benedict Meurer */
+
+body address
+{
+ line-height: 1.3;
+ margin: .6em 0;
+}
+
+body blockquote
+{
+ margin-top: .75em;
+ line-height: 1.5;
+ margin-bottom: .75em;
+}
+
+html body
+{
+ margin: 1em 8% 1em 10%;
+ line-height: 1.2;
+ background-color: #ffffff;
+}
+
+body pre
+{
+ margin: .75em 0;
+ line-height: 1.3;
+ color: #4f3f3f;
+ font-weight: bold;
+}
+
+body div
+{
+ margin: 0;
+}
+
+dl
+{
+ margin: .8em 0;
+ line-height: 1.2;
+}
+
+.legalnotice
+{
+ font-size: small;
+ font-variant: small-caps;
+}
+
+h1,h2,h3,h4,h5,h6,
+div.example p b,
+.question,
+div.table p b,
+div.procedure p b
+{
+ color: #990000;
+}
+
+.option
+{
+ color: #0000ca;
+ font-weight: bold;
+}
+
+.parameter
+{
+ color: #007a00;
+ font-weight: bold;
+}
+
+a
+{
+ color: #000000;
+}
+
+a:hover
+{
+ color: #3c3c3c;
+ border-bottom: 1px dotted #dc0000;
+}
+
+hr
+{
+ background-color: #9c9c9c;
+ border-style: none;
+ height: 1px;
+}
+
+ul li
+{
+ list-style-type: square;
+}
+
+.programlisting, .screen
+{
+ background-color: #F8F9FD;
+ border-color: #907777;
+ border-width: 1px;
+ border-style: solid;
+ padding: 0.5em;
+}
+
+/* vim:set ts=2 sw=2 et ai: */
diff --git a/docs/manual/ristretto.xsl b/docs/manual/ristretto.xsl
new file mode 100644
index 0000000..337e68a
--- /dev/null
+++ b/docs/manual/ristretto.xsl
@@ -0,0 +1,255 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version='1.0'
+ xmlns="http://www.w3.org/TR/xhtml1/transitional"
+ exclude-result-prefixes="#default">
+
+<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"/>
+
+<!-- XSL copied from Thunar written by Bennedict Meurer-->
+<!-- Use stylesheet -->
+<xsl:param name="html.stylesheet" select="'../ristretto.css'"/>
+
+<!-- labels and numbering -->
+<xsl:param name="autotoc.label.separator" select="'. '"/>
+<xsl:param name="chapter.autolabel" select="1"/>
+
+<!-- Don't force the use of index.html as root filename -->
+<xsl:param name="root.filename" select="''"/>
+
+<!-- Use element id (if present) as file name -->
+<xsl:variable name="use.id.as.filename">1</xsl:variable>
+
+<xsl:template match="releaseinfo" mode="titlepage.mode">
+ <span class="{name(.)}">
+ <br/>
+ <xsl:apply-templates mode="titlepage.mode"/>
+ <br/>
+ </span>
+</xsl:template>
+
+<!-- Use graphics in admonitions (note, warning, etc) -->
+<xsl:variable name="admon.graphics">0</xsl:variable>
+
+<xsl:param name="admon.style">
+ <xsl:text>text-align: left;</xsl:text></xsl:param>
+
+<xsl:variable name="admon.graphics.path">stylesheet-images/</xsl:variable>
+
+<xsl:variable name="admon.graphics.extension">.gif</xsl:variable>
+
+<xsl:param name="table.border.thickness" select="'0.2pt'"/>
+
+<xsl:param name="graphic.default.extension" select="png"/>
+
+<!-- This requires an adapted template for tgroup (see end of stylesheet) -->
+<xsl:attribute-set name="table.style">
+ <xsl:attribute name="bgcolor">#fdf9f8</xsl:attribute>
+ <xsl:attribute name="cellspacing">0</xsl:attribute>
+ <xsl:attribute name="cellpadding">4</xsl:attribute>
+</xsl:attribute-set>
+
+
+<xsl:param name="generate.legalnotice.link" select="0"/>
+
+<!-- set font styles for various tags -->
+<xsl:template match="guibutton">
+<xsl:call-template name="inline.boldseq"/>
+</xsl:template>
+
+<xsl:template match="guiicon">
+<xsl:call-template name="inline.boldseq"/>
+</xsl:template>
+
+<xsl:template match="guilabel">
+<xsl:call-template name="inline.boldseq"/>
+</xsl:template>
+
+<xsl:template match="guimenu">
+<xsl:call-template name="inline.boldseq"/>
+</xsl:template>
+
+<xsl:template match="guimenuitem">
+<xsl:call-template name="inline.boldseq"/>
+</xsl:template>
+
+<xsl:template match="guisubmenu">
+<xsl:call-template name="inline.boldseq"/>
+</xsl:template>
+
+<xsl:template match="application">
+<xsl:call-template name="inline.boldmonoseq"/>
+</xsl:template>
+
+<xsl:template match="caption">
+<xsl:call-template name="inline.boldseq"/>
+</xsl:template>
+
+<!-- Adapted template for tgroup. The only change is the addition of -->
+<!-- table.style attributes -->
+<xsl:template match="tgroup">
+ <table xsl:use-attribute-sets="table.style">
+ <xsl:choose>
+ <!-- If there's a <?dbhtml table-summary="foo"?> PI, use it for
+ the HTML table summary attribute -->
+ <xsl:when test="processing-instruction('dbhtml')">
+ <xsl:variable name="summary">
+ <xsl:call-template name="dbhtml-attribute">
+ <xsl:with-param name="pis"
+ select="processing-instruction('dbhtml')[1]"/>
+ <xsl:with-param name="attribute" select="'table-summary'"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:if test="$summary != ''">
+ <xsl:attribute name="summary">
+ <xsl:value-of select="$summary"/>
+ </xsl:attribute>
+ </xsl:if>
+ </xsl:when>
+ <!-- Otherwise, if there's a title, use that -->
+ <xsl:when test="../title">
+ <xsl:attribute name="summary">
+ <xsl:value-of select="string(../title)"/>
+ </xsl:attribute>
+ </xsl:when>
+ <!-- Otherwise, forget the whole idea -->
+ <xsl:otherwise><!-- nevermind --></xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:if test="../@pgwide=1">
+ <xsl:attribute name="width">100%</xsl:attribute>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="../@frame='none'">
+ <xsl:attribute name="border">0</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="$table.borders.with.css != 0">
+ <xsl:attribute name="border">0</xsl:attribute>
+ <xsl:choose>
+ <xsl:when test="../@frame='topbot' or ../@frame='top'">
+ <xsl:attribute name="style">
+ <xsl:call-template name="border">
+ <xsl:with-param name="side" select="'top'"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="../@frame='sides'">
+ <xsl:attribute name="style">
+ <xsl:call-template name="border">
+ <xsl:with-param name="side" select="'left'"/>
+ </xsl:call-template>
+ <xsl:call-template name="border">
+ <xsl:with-param name="side" select="'right'"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="border">1</xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:variable name="colgroup">
+ <colgroup>
+ <xsl:call-template name="generate.colgroup">
+ <xsl:with-param name="cols" select="@cols"/>
+ </xsl:call-template>
+ </colgroup>
+ </xsl:variable>
+
+ <xsl:variable name="explicit.table.width">
+ <xsl:call-template name="dbhtml-attribute">
+ <xsl:with-param name="pis"
+ select="../processing-instruction('dbhtml')[1]"/>
+ <xsl:with-param name="attribute" select="'table-width'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="table.width">
+ <xsl:choose>
+ <xsl:when test="$explicit.table.width != ''">
+ <xsl:value-of select="$explicit.table.width"/>
+ </xsl:when>
+ <xsl:when test="$default.table.width = ''">
+ <xsl:text>100%</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$default.table.width"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:if test="$default.table.width != ''
+ or $explicit.table.width != ''">
+ <xsl:attribute name="width">
+ <xsl:choose>
+ <xsl:when test="contains($table.width, '%')">
+ <xsl:value-of select="$table.width"/>
+ </xsl:when>
+ <xsl:when test="$use.extensions != 0
+ and $tablecolumns.extension != 0">
+ <xsl:choose>
+ <xsl:when test="function-available('stbl:convertLength')">
+ <xsl:value-of select="stbl:convertLength($table.width)"/>
+ </xsl:when>
+ <xsl:when test="function-available('xtbl:convertLength')">
+ <xsl:value-of select="xtbl:convertLength($table.width)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message terminate="yes">
+ <xsl:text>No convertLength function available.</xsl:text>
+ </xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$table.width"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="$use.extensions != 0
+ and $tablecolumns.extension != 0">
+ <xsl:choose>
+ <xsl:when test="function-available('stbl:adjustColumnWidths')">
+ <xsl:copy-of select="stbl:adjustColumnWidths($colgroup)"/>
+ </xsl:when>
+ <xsl:when test="function-available('xtbl:adjustColumnWidths')">
+ <xsl:copy-of select="xtbl:adjustColumnWidths($colgroup)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message terminate="yes">
+ <xsl:text>No adjustColumnWidths function available.</xsl:text>
+ </xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$colgroup"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:apply-templates select="thead"/>
+ <xsl:apply-templates select="tbody"/>
+ <xsl:apply-templates select="tfoot"/>
+
+ <xsl:if test=".//footnote">
+ <tbody class="footnotes">
+ <tr>
+ <td colspan="{@cols}">
+ <xsl:apply-templates select=".//footnote"
+ mode="table.footnote.mode"/>
+ </td>
+ </tr>
+ </tbody>
+ </xsl:if>
+ </table>
+</xsl:template>
+
+
+</xsl:stylesheet>
+
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c953d83..976352a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,8 +1,8 @@
src/main.c
src/main_window.c
-src/navigator.c
src/picture_viewer.c
-src/save_dialog.c
-src/thumbnail.c
-src/thumbnail_bar.c
+src/preferences_dialog.c
+src/image.c
+src/image_list.c
+src/image_cache.c
ristretto.desktop.in
diff --git a/ristretto.desktop.in b/ristretto.desktop.in
index f0302b0..5c8375f 100644
--- a/ristretto.desktop.in
+++ b/ristretto.desktop.in
@@ -1,7 +1,7 @@
[Desktop Entry]
Version=1.0
-_Name=Ristretto
-_Comment=Xfce Image viewer
+_Name=Ristretto Photo Viewer
+_Comment=Look at your photo's easily
_GenericName=Image Viewer
Exec=ristretto %F
Icon=ristretto
diff --git a/src/Makefile.am b/src/Makefile.am
index 141038d..c201e0f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,22 +1,28 @@
bin_PROGRAMS = ristretto
ristretto_SOURCES = \
- main.c \
- main_window.c main_window.h \
- navigator.c navigator.h \
+ image_list.c image_list.h \
+ image.c image.h \
+ image_cache.c image_cache.h \
picture_viewer.c picture_viewer.h \
- save_dialog.h save_dialog.c \
+ settings.c settings.h \
+ preferences_dialog.h preferences_dialog.c \
+ main_window_ui.h \
+ main_window.c main_window.h \
+ thumbnail_bar.c thumbnail_bar.h \
thumbnail.c thumbnail.h \
- thumbnail_bar.c thumbnail_bar.h
+ main.c
ristretto_CFLAGS = \
$(GTK_CFLAGS) \
$(GLIB_CFLAGS) \
- $(DBUS_GLIB_CFLAGS) \
+ $(GTHREAD_CFLAGS) \
+ $(GIO_CFLAGS) \
$(LIBEXIF_CFLAGS) \
+ $(XFCONF_CFLAGS) \
+ $(CAIRO_CFLAGS) \
$(LIBXFCE4UTIL_CFLAGS) \
$(LIBXFCEGUI4_CFLAGS) \
- $(THUNAR_VFS_CFLAGS) \
-DDATADIR=\"$(datadir)\" \
-DSRCDIR=\"$(top_srcdir)\" \
-DLOCALEDIR=\"$(localedir)\"
@@ -24,11 +30,26 @@ ristretto_CFLAGS = \
ristretto_LDADD = \
$(GTK_LIBS) \
$(GLIB_LIBS) \
- $(DBUS_GLIB_LIBS) \
+ $(GTHREAD_LIBS) \
+ $(GIO_LIBS) \
$(LIBEXIF_LIBS) \
+ $(CAIRO_LIBS) \
+ $(XFCONF_LIBS) \
$(LIBXFCE4UTIL_LIBS) \
- $(LIBXFCEGUI4_LIBS) \
- $(THUNAR_VFS_LIBS)
+ $(LIBXFCEGUI4_LIBS)
INCLUDES = \
-I${top_srcdir}
+
+if MAINTAINER_MODE
+
+BUILT_SOURCES = \
+ main_window_ui.h
+
+main_window_ui.h: main_window_ui.xml
+ exo-csource --strip-comments --strip-content --static --name=main_window_ui $< > $@
+
+endif
+
+EXTRA_DIST = \
+ main_window_ui.xml
diff --git a/src/image.c b/src/image.c
new file mode 100644
index 0000000..a6a9bb5
--- /dev/null
+++ b/src/image.c
@@ -0,0 +1,736 @@
+/*
+ * Copyright (c) 2009 Stephan Arts <stephan at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <gdk/gdk.h>
+
+#include <libexif/exif-data.h>
+
+#include <string.h>
+
+#include "image.h"
+#include "image_cache.h"
+
+#ifndef RSTTO_IMAGE_BUFFER_SIZE
+/* #define RSTTO_IMAGE_BUFFER_SIZE 1024 */
+#define RSTTO_IMAGE_BUFFER_SIZE 131072
+#endif
+
+enum
+{
+ RSTTO_IMAGE_SIGNAL_UPDATED= 0,
+ RSTTO_IMAGE_SIGNAL_PREPARED,
+ RSTTO_IMAGE_SIGNAL_COUNT
+};
+
+static void
+rstto_image_init (GObject *);
+static void
+rstto_image_class_init (GObjectClass *);
+
+static void
+rstto_image_dispose (GObject *object);
+
+static void
+cb_rstto_image_area_prepared (GdkPixbufLoader *loader, RsttoImage *image);
+static void
+cb_rstto_image_size_prepared (GdkPixbufLoader *loader, gint width, gint height, RsttoImage *image);
+static void
+cb_rstto_image_closed (GdkPixbufLoader *loader, RsttoImage *image);
+static gboolean
+cb_rstto_image_update(RsttoImage *image);
+
+static void
+cb_rstto_image_read_file_ready (GObject *source_object, GAsyncResult *result, gpointer user_data);
+static void
+cb_rstto_image_read_input_stream_ready (GObject *source_object, GAsyncResult *result, gpointer user_data);
+
+static GObjectClass *parent_class = NULL;
+
+static gint rstto_image_signals[RSTTO_IMAGE_SIGNAL_COUNT];
+
+GType
+rstto_image_get_type (void)
+{
+ static GType rstto_image_type = 0;
+
+ if (!rstto_image_type)
+ {
+ static const GTypeInfo rstto_image_info =
+ {
+ sizeof (RsttoImageClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) rstto_image_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (RsttoImage),
+ 0,
+ (GInstanceInitFunc) rstto_image_init,
+ NULL
+ };
+
+ rstto_image_type = g_type_register_static (G_TYPE_OBJECT, "RsttoImage", &rstto_image_info, 0);
+ }
+ return rstto_image_type;
+}
+
+struct _RsttoImagePriv
+{
+ /* File data */
+ /*************/
+ GFile *file;
+ GFileMonitor *monitor;
+ GCancellable *cancellable;
+
+ /* File I/O data */
+ /*****************/
+ guchar *buffer;
+
+ /* Image data */
+ /**************/
+ RsttoImageOrientation orientation;
+ GdkPixbufLoader *loader;
+ ExifData *exif_data;
+ GdkPixbuf *thumbnail;
+ GdkPixbuf *pixbuf;
+ gint width;
+ gint height;
+ guint max_size;
+
+ GdkPixbufAnimation *animation;
+ GdkPixbufAnimationIter *iter;
+ gint animation_timeout_id;
+};
+
+
+static void
+rstto_image_init (GObject *object)
+{
+ RsttoImage *image = RSTTO_IMAGE (object);
+
+ image->priv = g_new0 (RsttoImagePriv, 1);
+
+ image->priv->buffer = g_new0 (guchar, RSTTO_IMAGE_BUFFER_SIZE);
+ image->priv->cancellable = g_cancellable_new();
+
+}
+
+
+static void
+rstto_image_class_init (GObjectClass *object_class)
+{
+ RsttoImageClass *image_class = RSTTO_IMAGE_CLASS (object_class);
+
+ parent_class = g_type_class_peek_parent (image_class);
+
+ object_class->dispose = rstto_image_dispose;
+
+ rstto_image_signals[RSTTO_IMAGE_SIGNAL_UPDATED] = g_signal_new("updated",
+ G_TYPE_FROM_CLASS (image_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0,
+ NULL);
+
+ rstto_image_signals[RSTTO_IMAGE_SIGNAL_PREPARED] = g_signal_new("prepared",
+ G_TYPE_FROM_CLASS (image_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0,
+ NULL);
+
+}
+
+/**
+ * rstto_image_dispose:
+ * @object:
+ *
+ */
+static void
+rstto_image_dispose (GObject *object)
+{
+ RsttoImage *image = RSTTO_IMAGE (object);
+
+ if(image->priv->cancellable)
+ {
+ g_cancellable_cancel (image->priv->cancellable);
+ g_object_unref (image->priv->cancellable);
+ image->priv->cancellable = NULL;
+ }
+
+ if(image->priv->thumbnail)
+ {
+ g_object_unref (image->priv->thumbnail);
+ image->priv->thumbnail = NULL;
+ }
+
+ if (image->priv->animation_timeout_id)
+ {
+ g_source_remove (image->priv->animation_timeout_id);
+ image->priv->animation_timeout_id = 0;
+ }
+
+ if (image->priv->loader)
+ {
+ g_signal_handlers_disconnect_by_func (image->priv->loader , cb_rstto_image_area_prepared, image);
+ gdk_pixbuf_loader_close (image->priv->loader, NULL);
+ image->priv->loader = NULL;
+ }
+
+ if (image->priv->animation)
+ {
+ g_object_unref (image->priv->animation);
+ image->priv->animation = NULL;
+ }
+
+ if (image->priv->pixbuf)
+ {
+ g_object_unref (image->priv->pixbuf);
+ image->priv->pixbuf = NULL;
+ }
+
+ if (image->priv->buffer)
+ {
+ g_free (image->priv->buffer);
+ image->priv->buffer = NULL;
+ }
+
+ if (image->priv->exif_data)
+ {
+ exif_data_free (image->priv->exif_data);
+ image->priv->exif_data = NULL;
+ }
+}
+
+
+
+
+/**
+ * rstto_image_new:
+ * @file : The file which contains the image.
+ *
+ */
+RsttoImage *
+rstto_image_new (GFile *file)
+{
+ RsttoImage *image = g_object_new (RSTTO_TYPE_IMAGE, NULL);
+ gchar *file_path = g_file_get_path (file);
+ ExifEntry *exif_entry = NULL;
+
+ g_object_ref (file);
+
+ image->priv->file = file;
+ image->priv->exif_data = exif_data_new_from_file (file_path);
+ image->priv->thumbnail = NULL;
+ image->priv->pixbuf = NULL;
+
+ if (image->priv->exif_data) {
+ exif_entry = exif_data_get_entry (image->priv->exif_data, EXIF_TAG_ORIENTATION);
+ }
+ if (exif_entry && exif_entry->data != NULL)
+ {
+ image->priv->orientation = exif_get_short (exif_entry->data, exif_data_get_byte_order (exif_entry->parent->parent));
+ if (image->priv->orientation == 0)
+ image->priv->orientation = RSTTO_IMAGE_ORIENT_NONE;
+ }
+ else
+ {
+ image->priv->orientation = RSTTO_IMAGE_ORIENT_NONE;
+ }
+
+ return image;
+}
+
+
+static void
+cb_rstto_image_read_file_ready (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ GFile *file = G_FILE (source_object);
+ RsttoImage *image = RSTTO_IMAGE (user_data);
+ GFileInputStream *file_input_stream = g_file_read_finish (file, result, NULL);
+
+ if (g_cancellable_is_cancelled (image->priv->cancellable))
+ {
+ g_object_unref (image);
+ return;
+ }
+
+
+ g_input_stream_read_async (G_INPUT_STREAM (file_input_stream),
+ image->priv->buffer,
+ RSTTO_IMAGE_BUFFER_SIZE,
+ G_PRIORITY_DEFAULT,
+ NULL,
+ (GAsyncReadyCallback) cb_rstto_image_read_input_stream_ready,
+ image);
+}
+
+static void
+cb_rstto_image_read_input_stream_ready (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ RsttoImage *image = RSTTO_IMAGE (user_data);
+ gssize read_bytes = g_input_stream_read_finish (G_INPUT_STREAM (source_object), result, NULL);
+ GError *error = NULL;
+
+ if (g_cancellable_is_cancelled (image->priv->cancellable))
+ {
+ g_object_unref (image);
+ return;
+ }
+
+ if (image->priv->loader == NULL)
+ return;
+
+
+ if (read_bytes > 0)
+ {
+ if(gdk_pixbuf_loader_write (image->priv->loader, (const guchar *)image->priv->buffer, read_bytes, &error) == FALSE)
+ {
+ g_input_stream_close (G_INPUT_STREAM (source_object), NULL, NULL);
+ g_object_unref (image);
+ }
+ else
+ {
+ g_input_stream_read_async (G_INPUT_STREAM (source_object),
+ image->priv->buffer,
+ RSTTO_IMAGE_BUFFER_SIZE,
+ G_PRIORITY_DEFAULT,
+ NULL,
+ (GAsyncReadyCallback) cb_rstto_image_read_input_stream_ready,
+ image);
+ }
+ }
+ else
+ if (read_bytes == 0)
+ {
+ if (read_bytes == 0)
+ {
+ /* OK */
+ g_input_stream_close (G_INPUT_STREAM (source_object), NULL, NULL);
+ gdk_pixbuf_loader_close (image->priv->loader, NULL);
+ g_object_unref (image);
+ }
+ else
+ {
+ /* I/O ERROR */
+ g_input_stream_close (G_INPUT_STREAM (source_object), NULL, NULL);
+ gdk_pixbuf_loader_close (image->priv->loader, NULL);
+ g_object_unref (image);
+ }
+ }
+}
+
+/**
+ * rstto_image_load:
+ * @image : The image to load from disk.
+ * @empty_cache : if it should empty the cache (eg, perform a reload)
+ * @error : return location for errors or %NULL.
+ *
+ * If the image is not yet loaded in memory, load the image.
+ * A reload can be forced with @empty_cache set to %TRUE.
+ * On failure, returns %FALSE. And @error will be set to
+ * point to a #GError describing the cause of the failure.
+ * Warning: this function initializes a load, it is an a-sync call and
+ * does not guarantee that the image will be loaded afterwards.
+ * the 'image-loaded' signal will indicate that this operation
+ * has finished.
+ *
+ * Return value: TRUE on success.
+ */
+gboolean
+rstto_image_load (RsttoImage *image, gboolean empty_cache, guint max_size, gboolean preload, GError **error)
+{
+ RsttoImageCache *cache;
+
+ g_return_val_if_fail (image != NULL, FALSE);
+
+ cache = rstto_image_cache_new ();
+
+ g_cancellable_reset (image->priv->cancellable);
+
+ /* NEW */
+ image->priv->max_size = max_size;
+
+ /* Check if a GIOChannel is present, if so... the load is already in progress */
+ /* The image needs to be loaded if:
+ * a) The image is already loaded but there is
+ * a reload required because the cache needs
+ * to be cleared.
+ * b) The image is not yet loaded.
+ */
+ if ((image->priv->loader == NULL) && ((empty_cache == TRUE ) || image->priv->pixbuf == NULL))
+ {
+ /* If the image has been loaded, free it */
+ if (image->priv->pixbuf)
+ {
+ g_object_unref (image->priv->pixbuf);
+ image->priv->pixbuf = NULL;
+ }
+
+ /* FIXME: should we check if the loader already exists? */
+ image->priv->loader = gdk_pixbuf_loader_new();
+
+ /* connect the signal-handlers */
+ g_signal_connect(image->priv->loader, "area-prepared", G_CALLBACK(cb_rstto_image_area_prepared), image);
+ g_signal_connect(image->priv->loader, "size-prepared", G_CALLBACK(cb_rstto_image_size_prepared), image);
+ /*g_signal_connect(image->priv->loader, "area-updated", G_CALLBACK(cb_rstto_image_area_updated), image);*/
+ g_signal_connect(image->priv->loader, "closed", G_CALLBACK(cb_rstto_image_closed), image);
+
+ g_object_ref (image);
+ g_file_read_async (image->priv->file, 0, NULL, (GAsyncReadyCallback)cb_rstto_image_read_file_ready, image);
+ }
+ else
+ {
+ g_signal_emit(G_OBJECT(image), rstto_image_signals[RSTTO_IMAGE_SIGNAL_UPDATED], 0, image, NULL);
+ }
+ rstto_image_cache_push_image (cache, image, preload);
+ return TRUE;
+}
+
+
+/**
+ * rstto_image_unload:
+ * @image : The image to unload from memory.
+ *
+ * This function will unload the image-pixbuf from memory.
+ */
+void
+rstto_image_unload (RsttoImage *image)
+{
+ g_return_if_fail (image != NULL);
+
+ g_cancellable_cancel (image->priv->cancellable);
+
+ if (image->priv->loader)
+ {
+ gdk_pixbuf_loader_close (image->priv->loader, NULL);
+ image->priv->loader = NULL;
+ }
+
+ if (image->priv->pixbuf)
+ {
+ g_object_unref (image->priv->pixbuf);
+ image->priv->pixbuf = NULL;
+ }
+
+ if (image->priv->thumbnail)
+ {
+ g_object_unref (image->priv->thumbnail);
+ image->priv->thumbnail = NULL;
+ }
+
+ if (image->priv->animation_timeout_id)
+ {
+ g_source_remove (image->priv->animation_timeout_id);
+ image->priv->animation_timeout_id = 0;
+ }
+
+ if (image->priv->animation)
+ {
+ g_object_unref (image->priv->animation);
+ image->priv->animation = NULL;
+ }
+
+ if (image->priv->iter)
+ {
+ g_object_unref (image->priv->iter);
+ image->priv->iter = NULL;
+ }
+
+}
+
+
+/**
+ * rstto_image_get_file:
+ * @image : The image to get the GFile object from.
+ *
+ * Return value: A GFile object representing the image file.
+ */
+GFile *
+rstto_image_get_file (RsttoImage *image)
+{
+ g_return_val_if_fail (image != NULL, NULL);
+ g_return_val_if_fail (image->priv != NULL, NULL);
+ g_return_val_if_fail (image->priv->file != NULL, NULL);
+
+ return image->priv->file;
+}
+
+/**
+ * rstto_image_get_width:
+ * @image:
+ *
+ * Return value: width of the image
+ */
+gint
+rstto_image_get_width (RsttoImage *image)
+{
+ g_return_val_if_fail (image != NULL, 0);
+ g_return_val_if_fail (image->priv != NULL, 0);
+
+ return image->priv->width;
+}
+
+/**
+ * rstto_image_get_height:
+ * @image:
+ *
+ * Return value: height of the image
+ */
+gint
+rstto_image_get_height (RsttoImage *image)
+{
+ g_return_val_if_fail (image != NULL, 0);
+ g_return_val_if_fail (image->priv != NULL, 0);
+
+ return image->priv->height;
+}
+
+
+/**
+ * rstto_image_get_thumbnail:
+ * @image :
+ *
+ * return value: a gdkpixbuf * referencing a pixbuf pointing to the thumbnail.
+ */
+GdkPixbuf *
+rstto_image_get_thumbnail (RsttoImage *image)
+{
+ gchar *file_uri;
+ gchar *file_uri_checksum;
+ gchar *thumbnail_filename;
+ gchar *thumbnail_path;
+
+ g_return_val_if_fail (image != NULL, NULL);
+ g_return_val_if_fail (image->priv != NULL, NULL);
+
+ file_uri = g_file_get_uri (image->priv->file);
+ file_uri_checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, file_uri, strlen (file_uri));
+ thumbnail_filename = g_strconcat (file_uri_checksum, ".png", NULL);
+ thumbnail_path = g_build_path ("/", g_get_home_dir(), ".thumbnails", "normal", thumbnail_filename, NULL);
+
+ if (image->priv->thumbnail == NULL)
+ {
+ image->priv->thumbnail = gdk_pixbuf_new_from_file_at_scale (thumbnail_path, 128, 128, TRUE, NULL);
+ }
+ else
+ {
+
+ }
+
+ g_free (file_uri);
+ g_free (file_uri_checksum);
+ g_free (thumbnail_filename);
+ g_free (thumbnail_path);
+
+
+ return image->priv->thumbnail;
+}
+
+
+/**
+ * rstto_image_get_pixbuf:
+ * @image :
+ *
+ * return value: a gdkpixbuf * referencing a pixbuf pointing to the image.
+ */
+GdkPixbuf *
+rstto_image_get_pixbuf (RsttoImage *image)
+{
+ g_return_val_if_fail (image != NULL, NULL);
+ g_return_val_if_fail (image->priv != NULL, NULL);
+
+
+ return image->priv->pixbuf;
+}
+
+/**
+ * PRIVATE CALLBACKS
+ */
+
+/**
+ * cb_rstto_image_size_prepared:
+ * @loader:
+ * @width;
+ * @height;
+ * @image:
+ *
+ */
+static void
+cb_rstto_image_size_prepared (GdkPixbufLoader *loader, gint width, gint height, RsttoImage *image)
+{
+ image->priv->width = width;
+ image->priv->height = height;
+
+ if (image->priv->max_size > 0)
+ {
+ gdouble ratio = (gdouble)(image->priv->max_size)/(gdouble)(width * height);
+ if (ratio < 1)
+ gdk_pixbuf_loader_set_size (loader, width*ratio, height*ratio);
+ }
+
+ g_signal_emit(G_OBJECT(image), rstto_image_signals[RSTTO_IMAGE_SIGNAL_PREPARED], 0, image, NULL);
+}
+
+/**
+ * cb_rstto_image_area_prepared:
+ * @loader:
+ * @image:
+ *
+ */
+static void
+cb_rstto_image_area_prepared (GdkPixbufLoader *loader, RsttoImage *image)
+{
+ gint timeout = 0;
+ image->priv->animation = gdk_pixbuf_loader_get_animation (loader);
+ image->priv->iter = gdk_pixbuf_animation_get_iter (image->priv->animation, NULL);
+ if (image->priv->pixbuf)
+ {
+ g_object_unref(image->priv->pixbuf);
+ image->priv->pixbuf = NULL;
+ }
+
+ g_object_ref (image->priv->animation);
+
+ timeout = gdk_pixbuf_animation_iter_get_delay_time (image->priv->iter);
+
+ if (timeout != -1)
+ {
+ /* fix borked stuff */
+ if (timeout == 0)
+ {
+ g_warning("timeout == 0: defaulting to 40ms");
+ timeout = 40;
+ }
+
+ image->priv->animation_timeout_id = g_timeout_add(timeout, (GSourceFunc)cb_rstto_image_update, image);
+ }
+ else
+ {
+ image->priv->pixbuf = gdk_pixbuf_animation_iter_get_pixbuf (image->priv->iter);
+ g_object_ref (image->priv->pixbuf);
+ }
+}
+
+/**
+ * cb_rstto_image_closed:
+ * @loader:
+ * @image:
+ *
+ */
+static void
+cb_rstto_image_closed (GdkPixbufLoader *loader, RsttoImage *image)
+{
+ g_return_if_fail (image != NULL);
+ g_return_if_fail (RSTTO_IS_IMAGE (image));
+ g_return_if_fail (loader == image->priv->loader);
+
+ g_object_unref (image->priv->loader);
+ image->priv->loader = NULL;
+
+
+ if (image->priv->pixbuf != NULL)
+ {
+ g_signal_emit(G_OBJECT(image), rstto_image_signals[RSTTO_IMAGE_SIGNAL_UPDATED], 0, image, NULL);
+ }
+}
+
+/**
+ * cb_rstto_image_update:
+ * @image:
+ *
+ * Return value:
+ */
+static gboolean
+cb_rstto_image_update(RsttoImage *image)
+{
+ gint timeout = 0;
+
+ if (image->priv->iter)
+ {
+ if(gdk_pixbuf_animation_iter_advance (image->priv->iter, NULL))
+ {
+ /* Cleanup old image */
+ if (image->priv->pixbuf)
+ {
+ g_object_unref (image->priv->pixbuf);
+ image->priv->pixbuf = NULL;
+ }
+
+ image->priv->pixbuf = gdk_pixbuf_copy (gdk_pixbuf_animation_iter_get_pixbuf (image->priv->iter));
+ }
+
+ timeout = gdk_pixbuf_animation_iter_get_delay_time (image->priv->iter);
+
+ if (timeout != -1)
+ {
+ if (timeout == 0)
+ {
+ g_warning("timeout == 0: defaulting to 40ms");
+ timeout = 40;
+ }
+ image->priv->animation_timeout_id = g_timeout_add(timeout, (GSourceFunc)cb_rstto_image_update, image);
+ }
+ g_signal_emit (G_OBJECT(image), rstto_image_signals[RSTTO_IMAGE_SIGNAL_UPDATED], 0, image, NULL);
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+guint
+rstto_image_get_size (RsttoImage *image)
+{
+ GdkPixbuf *pixbuf = rstto_image_get_pixbuf (image);
+ if (pixbuf)
+ {
+ gint rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ gint height = gdk_pixbuf_get_height (pixbuf);
+ /* HACK HACK HACK HACK */
+ /* multiplied by 2 since it is unclear why the nr of bytes
+ * in memory is twice what is calculated here, based on the dimensions
+ */
+ return rowstride * height * 2;
+ }
+ return 0;
+}
+
+RsttoImageOrientation
+rstto_image_get_orientation (RsttoImage *image)
+{
+ return image->priv->orientation;
+}
+
+void
+rstto_image_set_orientation (RsttoImage *image, RsttoImageOrientation orientation)
+{
+ image->priv->orientation = orientation;
+ g_signal_emit (G_OBJECT(image), rstto_image_signals[RSTTO_IMAGE_SIGNAL_UPDATED], 0, image, NULL);
+}
diff --git a/src/image.h b/src/image.h
new file mode 100644
index 0000000..8b483b5
--- /dev/null
+++ b/src/image.h
@@ -0,0 +1,93 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __RISTRETTO_IMAGE_H__
+#define __RISTRETTO_IMAGE_H__
+
+G_BEGIN_DECLS
+
+typedef enum
+{
+ RSTTO_IMAGE_ORIENT_NONE = 1,
+ RSTTO_IMAGE_ORIENT_FLIP_HORIZONTAL,
+ RSTTO_IMAGE_ORIENT_180,
+ RSTTO_IMAGE_ORIENT_FLIP_VERTICAL,
+ RSTTO_IMAGE_ORIENT_TRANSPOSE,
+ RSTTO_IMAGE_ORIENT_90,
+ RSTTO_IMAGE_ORIENT_TRANSVERSE,
+ RSTTO_IMAGE_ORIENT_270,
+} RsttoImageOrientation;
+
+#define RSTTO_TYPE_IMAGE rstto_image_get_type()
+
+#define RSTTO_IMAGE(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ RSTTO_TYPE_IMAGE, \
+ RsttoImage))
+
+#define RSTTO_IS_IMAGE(obj)( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ RSTTO_TYPE_IMAGE))
+
+#define RSTTO_IMAGE_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ RSTTO_TYPE_IMAGE, \
+ RsttoImageClass))
+
+#define RSTTO_IS_IMAGE_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ RSTTO_TYPE_IMAGE()))
+
+
+typedef struct _RsttoImage RsttoImage;
+typedef struct _RsttoImagePriv RsttoImagePriv;
+
+struct _RsttoImage
+{
+ GObject parent;
+
+ RsttoImagePriv *priv;
+};
+
+typedef struct _RsttoImageClass RsttoImageClass;
+
+struct _RsttoImageClass
+{
+ GObjectClass parent_class;
+};
+
+RsttoImage *rstto_image_new (GFile *file);
+GType rstto_image_get_type ();
+
+GdkPixbuf *rstto_image_get_thumbnail (RsttoImage *image);
+GdkPixbuf *rstto_image_get_pixbuf (RsttoImage *image);
+gint rstto_image_get_width (RsttoImage *image);
+gint rstto_image_get_height (RsttoImage *image);
+
+GFile *rstto_image_get_file (RsttoImage *image);
+void rstto_image_unload (RsttoImage *image);
+gboolean rstto_image_load (RsttoImage *image, gboolean empty_cache, guint max_size, gboolean preload, GError **error);
+
+guint rstto_image_get_size (RsttoImage *image);
+
+void
+rstto_image_set_orientation (RsttoImage *image, RsttoImageOrientation orientation);
+RsttoImageOrientation
+rstto_image_get_orientation (RsttoImage *image);
+
+G_END_DECLS
+
+#endif /* __RISTRETTO_IMAGE_H__ */
diff --git a/src/image_cache.c b/src/image_cache.c
new file mode 100644
index 0000000..a37cda0
--- /dev/null
+++ b/src/image_cache.c
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2009 Stephan Arts <stephan at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <gdk/gdk.h>
+
+#include <libexif/exif-data.h>
+
+#include "image.h"
+#include "image_cache.h"
+#include "settings.h"
+
+static void
+rstto_image_cache_init (GObject *);
+static void
+rstto_image_cache_class_init (GObjectClass *);
+
+static RsttoImageCache *rstto_global_image_cache = NULL;
+
+struct _RsttoImageCache
+{
+ GObject parent;
+ GList *cache_list;
+};
+
+struct _RsttoImageCacheClass
+{
+ GObjectClass parent_class;
+};
+
+
+GType
+rstto_image_cache_get_type (void)
+{
+ static GType rstto_image_cache_type = 0;
+
+ if (!rstto_image_cache_type)
+ {
+ static const GTypeInfo rstto_image_cache_info =
+ {
+ sizeof (RsttoImageCacheClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) rstto_image_cache_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (RsttoImageCache),
+ 0,
+ (GInstanceInitFunc) rstto_image_cache_init,
+ NULL
+ };
+
+ rstto_image_cache_type = g_type_register_static (G_TYPE_OBJECT, "RsttoImageCache", &rstto_image_cache_info, 0);
+ }
+ return rstto_image_cache_type;
+}
+
+
+static void
+rstto_image_cache_init (GObject *object)
+{
+
+}
+
+static void
+rstto_image_cache_class_init (GObjectClass *object_class)
+{
+
+}
+
+gboolean
+rstto_image_cache_push_image (RsttoImageCache *cache, RsttoImage *image, gboolean last)
+{
+ gboolean retval = FALSE;
+ RsttoSettings *settings = rstto_settings_new();
+ gboolean cache_enabled;
+ guint size = 0;
+ guint cache_size = 0;
+ RsttoImage *c_image;
+ GList *iter = NULL;
+
+ g_object_get (G_OBJECT (settings),
+ "enable-cache", &cache_enabled,
+ "cache-size", &cache_size,
+ NULL);
+
+ if (cache->cache_list)
+ {
+ cache->cache_list = g_list_remove_all (cache->cache_list, image);
+ }
+
+ g_object_ref (image);
+
+ if (last)
+ {
+ cache->cache_list = g_list_append (cache->cache_list, image);
+ }
+ else
+ {
+ cache->cache_list = g_list_prepend (cache->cache_list, image);
+ }
+
+ /**
+ * Check if we are keeping a cache
+ */
+ if (cache_enabled == FALSE)
+ {
+ while (g_list_length (cache->cache_list) > 1)
+ {
+ c_image = g_list_last (cache->cache_list)->data;
+ rstto_image_unload (c_image);
+ cache->cache_list = g_list_remove (cache->cache_list, c_image);
+ g_object_unref (c_image);
+ retval = TRUE;
+ }
+ }
+ else
+ {
+ /* Calculate the cache-size, if it exceeds the defined maximum,
+ * unload the the images that exceed that.
+ */
+ for (iter = cache->cache_list->next; iter != NULL; iter = g_list_next (iter))
+ {
+ c_image = iter->data;
+ size += rstto_image_get_size (c_image);
+ if (size > (cache_size*1000000))
+ {
+ rstto_image_unload (c_image);
+ cache->cache_list = g_list_remove (cache->cache_list, c_image);
+ g_object_unref (c_image);
+ iter = g_list_previous(iter);
+ retval = TRUE;
+ }
+ else
+ {
+ if (rstto_image_get_size (c_image) == 0)
+ {
+ rstto_image_unload (c_image);
+ cache->cache_list = g_list_remove (cache->cache_list, c_image);
+ g_object_unref (c_image);
+ iter = g_list_previous(iter);
+ }
+ }
+ }
+ }
+ g_object_unref (settings);
+ return retval;
+}
+
+/**
+ * rstto_image_cache_new:
+ *
+ * Singleton
+ *
+ * Return value:
+ */
+RsttoImageCache *
+rstto_image_cache_new (void)
+{
+ if (rstto_global_image_cache == NULL)
+ {
+ rstto_global_image_cache = g_object_new (RSTTO_TYPE_IMAGE_CACHE, NULL);
+ }
+
+ return rstto_global_image_cache;
+}
+
+void
+rstto_image_cache_clear (RsttoImageCache *cache)
+{
+ RsttoImage *c_image;
+ RsttoSettings *settings_manager = rstto_settings_new();
+ GValue max_size = {0,};
+
+ g_value_init (&max_size, G_TYPE_UINT);
+ g_object_get_property (G_OBJECT(settings_manager), "image-quality", &max_size);
+
+
+ while (g_list_length (cache->cache_list) > 1)
+ {
+ c_image = g_list_last (cache->cache_list)->data;
+ rstto_image_unload (c_image);
+ cache->cache_list = g_list_remove (cache->cache_list, c_image);
+ }
+ if (cache->cache_list)
+ {
+ rstto_image_load (cache->cache_list->data, TRUE, g_value_get_uint (&max_size), FALSE, NULL);
+ }
+ g_object_unref (settings_manager);
+}
diff --git a/src/image_cache.h b/src/image_cache.h
new file mode 100644
index 0000000..01e1adc
--- /dev/null
+++ b/src/image_cache.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) Stephan Arts 2009 <stephan at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __RISTRETTO_IMAGE_CACHE_H__
+#define __RISTRETTO_IMAGE_CACHE_H__
+
+G_BEGIN_DECLS
+
+#define RSTTO_TYPE_IMAGE_CACHE rstto_image_cache_get_type()
+
+#define RSTTO_IMAGE_CACHE(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ RSTTO_TYPE_IMAGE_CACHE, \
+ RsttoImageCache))
+
+#define RSTTO_IS_IMAGE_CACHE(obj)( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ RSTTO_TYPE_IMAGE_CACHE))
+
+#define RSTTO_IMAGE_CACHE_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ RSTTO_TYPE_IMAGE_CACHE, \
+ RsttoImageCacheClass))
+
+#define RSTTO_IS_IMAGE_CACHE_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ RSTTO_TYPE_IMAGE_CACHE()))
+
+typedef struct _RsttoImageCache RsttoImageCache;
+
+typedef struct _RsttoImageCacheClass RsttoImageCacheClass;
+
+GType rstto_image_cache_get_type (void);
+RsttoImageCache *rstto_image_cache_new ();
+
+gboolean rstto_image_cache_push_image (RsttoImageCache *cache, RsttoImage *image, gboolean last);
+
+void rstto_image_cache_clear (RsttoImageCache *cache);
+
+G_END_DECLS
+
+#endif /* __RISTRETTO_IMAGE_CACHE_H__ */
diff --git a/src/image_list.c b/src/image_list.c
new file mode 100644
index 0000000..f1c1110
--- /dev/null
+++ b/src/image_list.c
@@ -0,0 +1,489 @@
+/*
+ * Copyright (c) 2009 Stephan Arts <stephan at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <gtk/gtk.h>
+#include <gtk/gtkmarshal.h>
+
+#include <string.h>
+
+#include <libexif/exif-data.h>
+
+#include "image.h"
+#include "image_list.h"
+
+static void
+rstto_image_list_init(RsttoImageList *);
+static void
+rstto_image_list_class_init(RsttoImageListClass *);
+static void
+rstto_image_list_dispose(GObject *object);
+
+static void
+rstto_image_list_iter_init(RsttoImageListIter *);
+static void
+rstto_image_list_iter_class_init(RsttoImageListIterClass *);
+static void
+rstto_image_list_iter_dispose(GObject *object);
+
+static RsttoImageListIter * rstto_image_list_iter_new ();
+
+static gint
+cb_rstto_image_list_image_name_compare_func (RsttoImage *a, RsttoImage *b);
+
+static GObjectClass *parent_class = NULL;
+static GObjectClass *iter_parent_class = NULL;
+
+enum
+{
+ RSTTO_IMAGE_LIST_SIGNAL_NEW_IMAGE = 0,
+ RSTTO_IMAGE_LIST_SIGNAL_REMOVE_IMAGE,
+ RSTTO_IMAGE_LIST_SIGNAL_REMOVE_ALL,
+ RSTTO_IMAGE_LIST_SIGNAL_COUNT
+};
+
+enum
+{
+ RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED = 0,
+ RSTTO_IMAGE_LIST_ITER_SIGNAL_COUNT
+};
+
+struct _RsttoImageListIterPriv
+{
+ RsttoImageList *image_list;
+ RsttoImage *image;
+};
+
+struct _RsttoImageListPriv
+{
+ GList *images;
+ gint n_images;
+
+ GSList *iterators;
+};
+
+static gint rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_COUNT];
+static gint rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_COUNT];
+
+GType
+rstto_image_list_get_type (void)
+{
+ static GType rstto_image_list_type = 0;
+
+ if (!rstto_image_list_type)
+ {
+ static const GTypeInfo rstto_image_list_info =
+ {
+ sizeof (RsttoImageListClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) rstto_image_list_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (RsttoImageList),
+ 0,
+ (GInstanceInitFunc) rstto_image_list_init,
+ NULL
+ };
+
+ rstto_image_list_type = g_type_register_static (G_TYPE_OBJECT, "RsttoImageList", &rstto_image_list_info, 0);
+ }
+ return rstto_image_list_type;
+}
+
+static void
+rstto_image_list_init(RsttoImageList *image_list)
+{
+ image_list->priv = g_new0 (RsttoImageListPriv, 1);
+}
+
+static void
+rstto_image_list_class_init(RsttoImageListClass *nav_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(nav_class);
+
+ parent_class = g_type_class_peek_parent(nav_class);
+
+ object_class->dispose = rstto_image_list_dispose;
+
+ rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_NEW_IMAGE] = g_signal_new("new-image",
+ G_TYPE_FROM_CLASS(nav_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_OBJECT,
+ NULL);
+
+ rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_REMOVE_IMAGE] = g_signal_new("remove-image",
+ G_TYPE_FROM_CLASS(nav_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_OBJECT,
+ NULL);
+
+ rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_REMOVE_ALL] = g_signal_new("remove-all",
+ G_TYPE_FROM_CLASS(nav_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0,
+ NULL);
+}
+
+static void
+rstto_image_list_dispose(GObject *object)
+{
+ /*RsttoImageList *image_list = RSTTO_IMAGE_LIST(object);*/
+}
+
+RsttoImageList *
+rstto_image_list_new (void)
+{
+ RsttoImageList *image_list;
+
+ image_list = g_object_new(RSTTO_TYPE_IMAGE_LIST, NULL);
+
+ return image_list;
+}
+
+gboolean
+rstto_image_list_add_file (RsttoImageList *image_list, GFile *file, GError **error)
+{
+ RsttoImage *image = rstto_image_new (file);
+ if (image)
+ {
+ image_list->priv->images = g_list_insert_sorted (image_list->priv->images, image, (GCompareFunc)cb_rstto_image_list_image_name_compare_func);
+ image_list->priv->n_images++;
+
+ g_signal_emit (G_OBJECT (image_list), rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_NEW_IMAGE], 0, image, NULL);
+ if (image_list->priv->n_images == 1)
+ {
+ /** TODO: update all iterators */
+ GSList *iter = image_list->priv->iterators;
+ while (iter)
+ {
+ g_signal_emit (G_OBJECT (iter->data), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED], 0, NULL);
+ iter = g_slist_next (iter);
+ }
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+gint
+rstto_image_list_get_n_images (RsttoImageList *image_list)
+{
+ return g_list_length (image_list->priv->images);
+}
+
+/**
+ * rstto_image_list_get_iter:
+ * @image_list:
+ *
+ * TODO: track iterators
+ *
+ * return iter;
+ */
+RsttoImageListIter *
+rstto_image_list_get_iter (RsttoImageList *image_list)
+{
+ RsttoImage *image = NULL;
+ RsttoImageListIter *iter = NULL;
+ if (image_list->priv->images)
+ image = image_list->priv->images->data;
+
+ iter = rstto_image_list_iter_new (image_list, image);
+
+ image_list->priv->iterators = g_slist_prepend (image_list->priv->iterators, iter);
+
+ return iter;
+}
+
+
+void
+rstto_image_list_remove_image (RsttoImageList *image_list, RsttoImage *image)
+{
+ GSList *iter = NULL;
+
+ if (g_list_find (image_list->priv->images, image))
+ {
+ image_list->priv->images = g_list_remove (image_list->priv->images, image);
+
+ iter = image_list->priv->iterators;
+ while (iter)
+ {
+ if (rstto_image_list_iter_get_image (iter->data) == image)
+ {
+ rstto_image_list_iter_previous (iter->data);
+ }
+ iter = g_slist_next (iter);
+ }
+ g_signal_emit (G_OBJECT (image_list), rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_REMOVE_IMAGE], 0, image, NULL);
+ g_object_unref (image);
+ }
+}
+
+void
+rstto_image_list_remove_all (RsttoImageList *image_list)
+{
+ GSList *iter = NULL;
+ g_list_foreach (image_list->priv->images, (GFunc)g_object_unref, NULL);
+ g_list_free (image_list->priv->images);
+ image_list->priv->images = NULL;
+
+ iter = image_list->priv->iterators;
+ while (iter)
+ {
+ rstto_image_list_iter_set_position (iter->data, 0);
+ iter = g_slist_next (iter);
+ }
+ g_signal_emit (G_OBJECT (image_list), rstto_image_list_signals[RSTTO_IMAGE_LIST_SIGNAL_REMOVE_ALL], 0, NULL);
+}
+
+
+/**
+ * cb_rstto_image_list_image_name_compare_func:
+ * @a:
+ * @b:
+ *
+ *
+ * Return value: (see strcmp)
+ */
+static gint
+cb_rstto_image_list_image_name_compare_func (RsttoImage *a, RsttoImage *b)
+{
+ gchar *a_base = g_file_get_basename (rstto_image_get_file (a));
+ gchar *b_base = g_file_get_basename (rstto_image_get_file (b));
+ gint result = 0;
+
+ result = g_strcasecmp (a_base, b_base);
+
+ g_free (a_base);
+ g_free (b_base);
+ return result;
+}
+
+GType
+rstto_image_list_iter_get_type (void)
+{
+ static GType rstto_image_list_iter_type = 0;
+
+ if (!rstto_image_list_iter_type)
+ {
+ static const GTypeInfo rstto_image_list_iter_info =
+ {
+ sizeof (RsttoImageListIterClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) rstto_image_list_iter_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (RsttoImageListIter),
+ 0,
+ (GInstanceInitFunc) rstto_image_list_iter_init,
+ NULL
+ };
+
+ rstto_image_list_iter_type = g_type_register_static (G_TYPE_OBJECT, "RsttoImageListIter", &rstto_image_list_iter_info, 0);
+ }
+ return rstto_image_list_iter_type;
+}
+
+static void
+rstto_image_list_iter_init (RsttoImageListIter *iter)
+{
+ iter->priv = g_new0 (RsttoImageListIterPriv, 1);
+}
+
+static void
+rstto_image_list_iter_class_init(RsttoImageListIterClass *iter_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(iter_class);
+
+ iter_parent_class = g_type_class_peek_parent(iter_class);
+
+ object_class->dispose = rstto_image_list_iter_dispose;
+
+ rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED] = g_signal_new("changed",
+ G_TYPE_FROM_CLASS(iter_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0,
+ NULL);
+
+}
+
+static void
+rstto_image_list_iter_dispose (GObject *object)
+{
+ RsttoImageListIter *iter = RSTTO_IMAGE_LIST_ITER(object);
+ if (iter->priv->image)
+ {
+ g_object_unref (iter->priv->image);
+ iter->priv->image = NULL;
+ }
+
+ if (iter->priv->image_list)
+ {
+ iter->priv->image_list->priv->iterators = g_slist_remove (iter->priv->image_list->priv->iterators, iter);
+ iter->priv->image_list= NULL;
+ }
+}
+
+static RsttoImageListIter *
+rstto_image_list_iter_new (RsttoImageList *nav, RsttoImage *image)
+{
+ RsttoImageListIter *iter;
+
+ iter = g_object_new(RSTTO_TYPE_IMAGE_LIST_ITER, NULL);
+ iter->priv->image = image;
+ iter->priv->image_list = nav;
+
+ return iter;
+}
+
+gboolean
+rstto_image_list_iter_find_image (RsttoImageListIter *iter, RsttoImage *image)
+{
+ gint pos = g_list_index (iter->priv->image_list->priv->images, image);
+ if (pos > -1)
+ {
+ if (iter->priv->image)
+ {
+ iter->priv->image = NULL;
+ }
+ iter->priv->image = image;
+
+ g_signal_emit (G_OBJECT (iter), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED], 0, NULL);
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+gint
+rstto_image_list_iter_get_position (RsttoImageListIter *iter)
+{
+ if (iter->priv->image == NULL)
+ {
+ return -1;
+ }
+ return g_list_index (iter->priv->image_list->priv->images, iter->priv->image);
+}
+
+RsttoImage *
+rstto_image_list_iter_get_image (RsttoImageListIter *iter)
+{
+ return RSTTO_IMAGE (iter->priv->image);
+}
+
+
+void
+rstto_image_list_iter_set_position (RsttoImageListIter *iter, gint pos)
+{
+ if (iter->priv->image)
+ {
+ iter->priv->image = NULL;
+ }
+
+ iter->priv->image = g_list_nth_data (iter->priv->image_list->priv->images, pos);
+
+ g_signal_emit (G_OBJECT (iter), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED], 0, NULL);
+}
+
+void
+rstto_image_list_iter_next (RsttoImageListIter *iter)
+{
+ GList *position = NULL;
+ if (iter->priv->image)
+ {
+ position = g_list_find (iter->priv->image_list->priv->images, iter->priv->image);
+ iter->priv->image = NULL;
+ }
+
+ position = g_list_next (position);
+ if (position)
+ iter->priv->image = position->data;
+ else
+ {
+ position = g_list_first (iter->priv->image_list->priv->images);
+ if (position)
+ iter->priv->image = position->data;
+ else
+ iter->priv->image = NULL;
+ }
+
+ g_signal_emit (G_OBJECT (iter), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED], 0, NULL);
+}
+
+void
+rstto_image_list_iter_previous (RsttoImageListIter *iter)
+{
+ GList *position = NULL;
+ if (iter->priv->image)
+ {
+ position = g_list_find (iter->priv->image_list->priv->images, iter->priv->image);
+ iter->priv->image = NULL;
+ }
+
+ position = g_list_previous (position);
+ if (position)
+ iter->priv->image = position->data;
+ else
+ {
+ position = g_list_last (iter->priv->image_list->priv->images);
+ if (position)
+ iter->priv->image = position->data;
+ else
+ iter->priv->image = NULL;
+ }
+
+ g_signal_emit (G_OBJECT (iter), rstto_image_list_iter_signals[RSTTO_IMAGE_LIST_ITER_SIGNAL_CHANGED], 0, NULL);
+}
+
+RsttoImageListIter *
+rstto_image_list_iter_clone (RsttoImageListIter *iter)
+{
+ RsttoImageListIter *new_iter = rstto_image_list_iter_new (iter->priv->image_list, iter->priv->image);
+
+ return new_iter;
+}
+
+GCompareFunc
+rstto_image_list_get_compare_func (RsttoImageList *image_list)
+{
+ return (GCompareFunc)cb_rstto_image_list_image_name_compare_func;
+}
diff --git a/src/image_list.h b/src/image_list.h
new file mode 100644
index 0000000..49ec8a2
--- /dev/null
+++ b/src/image_list.h
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2009 Stephan Arts <stephan at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __RISTRETTO_IMAGE_LIST_H__
+#define __RISTRETTO_IMAGE_LIST_H__
+
+G_BEGIN_DECLS
+
+#define RSTTO_TYPE_IMAGE_LIST rstto_image_list_get_type()
+
+#define RSTTO_IMAGE_LIST(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ RSTTO_TYPE_IMAGE_LIST, \
+ RsttoImageList))
+
+#define RSTTO_IS_IMAGE_LIST(obj)( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ RSTTO_TYPE_IMAGE_LIST))
+
+#define RSTTO_IMAGE_LIST_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ RSTTO_TYPE_IMAGE_LIST, \
+ RsttoImageListClass))
+
+#define RSTTO_IS_IMAGE_LIST_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ RSTTO_TYPE_IMAGE_LIST()))
+
+typedef struct _RsttoImageListPriv RsttoImageListPriv;
+typedef struct _RsttoImageList RsttoImageList;
+
+struct _RsttoImageList
+{
+ GObject parent;
+ RsttoImageListPriv *priv;
+};
+
+typedef struct _RsttoImageListClass RsttoImageListClass;
+struct _RsttoImageListClass
+{
+ GObjectClass parent_class;
+};
+
+
+#define RSTTO_TYPE_IMAGE_LIST_ITER rstto_image_list_iter_get_type()
+
+#define RSTTO_IMAGE_LIST_ITER(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ RSTTO_TYPE_IMAGE_LIST_ITER, \
+ RsttoImageListIter))
+
+#define RSTTO_IS_IMAGE_LIST_ITER(obj)( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ RSTTO_TYPE_IMAGE_LIST_ITER))
+
+#define RSTTO_IMAGE_LIST_ITER_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ RSTTO_TYPE_IMAGE_LIST_ITER, \
+ RsttoImageListIterClass))
+
+#define RSTTO_IS_IMAGE_LIST_ITER_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ RSTTO_TYPE_IMAGE_LIST_ITER()))
+
+typedef struct _RsttoImageListIter RsttoImageListIter;
+typedef struct _RsttoImageListIterPriv RsttoImageListIterPriv;
+struct _RsttoImageListIter
+{
+ GObject parent;
+ RsttoImageListIterPriv *priv;
+};
+
+typedef struct _RsttoImageListIterClass RsttoImageListIterClass;
+struct _RsttoImageListIterClass
+{
+ GObjectClass parent_class;
+};
+
+
+GType rstto_image_list_get_type ();
+RsttoImageList *rstto_image_list_new ();
+
+gint rstto_image_list_get_n_images (RsttoImageList *image_list);
+gboolean rstto_image_list_add_file (RsttoImageList *image_list, GFile *file, GError **);
+
+RsttoImageListIter *rstto_image_list_get_iter (RsttoImageList *image_list);
+
+/** Iter functions */
+GType rstto_image_list_iter_get_type ();
+RsttoImage *rstto_image_list_iter_get_image (RsttoImageListIter *iter);
+void rstto_image_list_iter_previous (RsttoImageListIter *iter);
+void rstto_image_list_iter_next (RsttoImageListIter *iter);
+gint rstto_image_list_iter_get_position (RsttoImageListIter *iter);
+void rstto_image_list_iter_set_position (RsttoImageListIter *iter, gint pos);
+
+void rstto_image_list_remove_all (RsttoImageList *image_list);
+void rstto_image_list_remove_image (RsttoImageList *image_list, RsttoImage *image);
+gboolean rstto_image_list_iter_find_image (RsttoImageListIter *iter, RsttoImage *image);
+RsttoImageListIter *rstto_image_list_iter_clone (RsttoImageListIter *iter);
+
+GCompareFunc rstto_image_list_get_compare_func (RsttoImageList *image_list);
+
+
+G_END_DECLS
+
+#endif /* __RISTRETTO_IMAGE_LIST_H__ */
diff --git a/src/main.c b/src/main.c
index 5da3746..fa411ff 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,4 +1,6 @@
/*
+ * Copyright (c) 2006-2009 Stephan Arts <stephan at xfce.org>
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -15,42 +17,40 @@
*/
#include <config.h>
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <xfconf/xfconf.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <string.h>
-#include <thunar-vfs/thunar-vfs.h>
+#include <libxfce4util/libxfce4util.h>
#include <libexif/exif-data.h>
-#include "navigator.h"
+#include "image.h"
+#include "image_list.h"
+#include "settings.h"
#include "picture_viewer.h"
#include "main_window.h"
-typedef struct {
- RsttoNavigator *navigator;
- RsttoMainWindow *main_window;
- GSList *files;
-} RsttoOpenFiles;
-
-static ThunarVfsMimeDatabase *mime_dbase = NULL;
-static XfceRc *xfce_rc;
-static gint window_save_geometry_timer_id = 0;
+gboolean version = FALSE;
+gboolean start_fullscreen = FALSE;
+gboolean start_slideshow = FALSE;
-static gboolean
-rstto_window_save_geometry_timer (gpointer user_data);
-static void
-rstto_window_save_geometry_timer_destroy(gpointer user_data);
-static gboolean
-cb_rstto_main_window_configure_event (GtkWidget *widget, GdkEventConfigure *event);
+typedef struct {
+ RsttoImageList *image_list;
+ gint argc;
+ gchar **argv;
+ gint iter;
+} RsttoOpenFiles;
static gboolean
cb_rstto_open_files (RsttoOpenFiles *rof);
-gboolean version = FALSE;
-gboolean start_fullscreen = FALSE;
-gboolean start_slideshow = FALSE;
-
static GOptionEntry entries[] =
{
{ "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &version,
@@ -68,156 +68,13 @@ static GOptionEntry entries[] =
{ NULL, ' ', 0, 0, NULL, NULL, NULL }
};
-
-#if GTK_CHECK_VERSION(2,12,0)
-#define RSTTO_COLOR_PARSE gdk_color_parse
-#define RSTTO_COLOR_TO_STRING gdk_color_to_string
-#else
-gboolean
-rstto_color_parse(const gchar *string, GdkColor *color)
+int
+main(int argc, char **argv)
{
- gint i;
- guint16 red = 0;
- guint16 green = 0;
- guint16 blue = 0;
- g_return_val_if_fail(string != NULL, FALSE);
- /* Check is the string is long enough tp contain #rrrrggggbbbb
- */
- if(strlen(string) != 13)
- return FALSE;
- if(string[0] != '#')
- return FALSE;
-
- /* red */
- for(i = 1; i < 5; ++i)
- {
- if(string[i] >= '0' && string[i] <= '9')
- {
- red |= (string[i] ^ 0x30);
- }
- else
- {
- if(string[i] >= 'a' && string[i] <= 'f')
- {
- red |= ((string[i] ^ 0x60)+9);
- }
- else
- {
- return FALSE;
- }
- }
- if (i < 4)
- red = red << 4;
- }
-
- /* green */
- for(i = 5; i < 9; ++i)
- {
- if(string[i] >= '0' && string[i] <= '9')
- {
- green |= (string[i] ^ 0x30);
- }
- else
- {
- if(string[i] >= 'a' && string[i] <= 'f')
- {
- green |= ((string[i] ^ 0x60)+9);
- }
- else
- {
- return FALSE;
- }
- }
-
- if (i < 8)
- green = green << 4;
-
- }
-
- /* blue */
- for(i = 9; i < 13; ++i)
- {
- if(string[i] >= '0' && string[i] <= '9')
- {
- blue |= (string[i] ^ 0x30);
- }
- else
- {
- if(string[i] >= 'a' && string[i] <= 'f')
- {
- blue |= ((string[i] ^ 0x60)+9);
- }
- else
- {
- return FALSE;
- }
- }
- if (i < 12)
- blue = blue << 4;
- }
-
- color->red = red;
- color->green = green;
- color->blue = blue;
- return TRUE;
-}
-
-gchar *
-rstto_color_to_string(const GdkColor *color)
-{
- gint i;
- gchar *color_string = g_new0(gchar, 14);
-
- color_string[0] = '#';
-
- for(i = 0; i < 4; ++i)
- {
- if(((color->red >> (4*i))&0x000f) < 0xA)
- {
- color_string[1+3-i] = (((color->red >> (4*i))&0x000f)|0x0030);
- }
- else
- {
- color_string[1+3-i] = ((((color->red >> (4*i))&0x000f)|0x0060)-9);
- }
- }
-
- for(i = 0; i < 4; ++i)
- {
- if(((color->green >> (4*i))&0x000f) < 0xA)
- {
- color_string[5+3-i] = (((color->green >> (4*i))&0x000f)|0x0030);
- }
- else
- {
- color_string[5+3-i] = ((((color->green >> (4*i))&0x000f)|0x0060)-9);
- }
- }
-
- for(i = 0; i < 4; ++i)
- {
- if(((color->blue >> (4*i))&0x000f) < 0xA)
- {
- color_string[9+3-i] = (((color->blue >> (4*i))&0x000f)|0x0030);
- }
- else
- {
- color_string[9+3-i] = ((((color->blue >> (4*i))&0x000f)|0x0060)-9);
- }
- }
-
- return color_string;
-}
-#define RSTTO_COLOR_PARSE(string, color) rstto_color_parse(string, color)
-#define RSTTO_COLOR_TO_STRING(color) rstto_color_to_string(color)
-#endif
-
-int main(int argc, char **argv)
-{
- GdkColor *bg_color = NULL;
GError *cli_error = NULL;
- gint n;
- gchar *program = NULL;
+ RsttoSettings *settings;
+ RsttoImageList *image_list;
+ GtkWidget *window;
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
@@ -241,260 +98,63 @@ int main(int argc, char **argv)
return 0;
}
-
- thunar_vfs_init();
-
- mime_dbase = thunar_vfs_mime_database_get_default();
-
- program = g_find_program_in_path ("xfconf-query");
- if (G_LIKELY (program != NULL))
- {
- rstto_has_xfconf_query = TRUE;
- g_free (program);
- }
+ xfconf_init(NULL);
gtk_window_set_default_icon_name("ristretto");
- xfce_rc = xfce_rc_config_open(XFCE_RESOURCE_CONFIG, "ristretto/ristrettorc", FALSE);
-
- const gchar *thumbnail_viewer_orientation = xfce_rc_read_entry(xfce_rc, "ThumbnailViewerOrientation", "horizontal");
- gboolean show_thumbnail_viewer = xfce_rc_read_bool_entry(xfce_rc, "ShowThumbnailViewer", TRUE);
- gboolean show_toolbar = xfce_rc_read_bool_entry(xfce_rc, "ShowToolBar", TRUE);
- gint window_width = xfce_rc_read_int_entry(xfce_rc, "LastWindowWidth", 400);
- gint window_height = xfce_rc_read_int_entry(xfce_rc, "LastWindowHeight", 300);
- gint slideshow_timeout = xfce_rc_read_int_entry(xfce_rc, "SlideShowTimeout", 5000);
- gboolean slideshow_hide_thumbnail = xfce_rc_read_bool_entry(xfce_rc, "SlideShowHideThumbnail", TRUE);
- gint max_cache = xfce_rc_read_int_entry(xfce_rc, "MaxImagesCacheSize", 64);
- gboolean preload_imgs = xfce_rc_read_bool_entry (xfce_rc, "PreloadImgs", FALSE);
- gboolean override_bg_color = xfce_rc_read_bool_entry (xfce_rc, "OverrideBgColor", FALSE);
- gboolean scale_to_100 = xfce_rc_read_bool_entry (xfce_rc, "ScaleTo100", FALSE);
+ settings = rstto_settings_new();
- if (override_bg_color)
- {
- const gchar *color = xfce_rc_read_entry(xfce_rc, "BgColor", "#000000000000");
- bg_color = g_new0(GdkColor, 1);
- if(!RSTTO_COLOR_PARSE(color, bg_color))
- {
- g_debug("parse failed");
- }
- }
-
- GtkWidget *window = rstto_main_window_new();
- gtk_widget_ref(window);
-
- RsttoNavigator *navigator = rstto_main_window_get_navigator(RSTTO_MAIN_WINDOW(window));
+ image_list = rstto_image_list_new ();
+ window = rstto_main_window_new (image_list, FALSE);
- navigator->preload = preload_imgs;
-
- rstto_main_window_set_max_cache_size(RSTTO_MAIN_WINDOW(window), max_cache);
- rstto_main_window_set_slideshow_timeout(RSTTO_MAIN_WINDOW(window), (gdouble)slideshow_timeout);
- rstto_main_window_set_hide_thumbnail(RSTTO_MAIN_WINDOW(window), slideshow_hide_thumbnail);
- rstto_main_window_set_scale_to_100(RSTTO_MAIN_WINDOW(window), scale_to_100);
- rstto_navigator_set_timeout(navigator, slideshow_timeout);
- rstto_main_window_set_start_fullscreen(RSTTO_MAIN_WINDOW(window), start_fullscreen);
- rstto_main_window_set_start_slideshow(RSTTO_MAIN_WINDOW(window), start_slideshow);
-
- /* When more then one file is provided over the CLI,
- * just open those files and don't index the folder
- */
if (argc > 1)
{
RsttoOpenFiles rof;
- rof.files = NULL;
- rof.navigator = navigator;
- rof.main_window = RSTTO_MAIN_WINDOW(window);
- for (n = 1; n < argc; ++n)
- {
- rof.files = g_slist_prepend(rof.files, argv[n]);
- }
+ rof.image_list = image_list;
+ rof.argc = argc;
+ rof.argv = argv;
+ rof.iter = 1;
- gtk_init_add((GtkFunction)cb_rstto_open_files, &rof);
- }
+ g_idle_add ((GSourceFunc )cb_rstto_open_files, &rof);
- g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
- g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(cb_rstto_main_window_configure_event), NULL);
-
- if (!strcmp(thumbnail_viewer_orientation, "vertical"))
- {
- rstto_main_window_set_thumbnail_viewer_orientation(RSTTO_MAIN_WINDOW(window), GTK_ORIENTATION_VERTICAL);
- }
- else
- {
- rstto_main_window_set_thumbnail_viewer_orientation(RSTTO_MAIN_WINDOW(window), GTK_ORIENTATION_HORIZONTAL);
}
- if (bg_color)
- {
- rstto_main_window_set_pv_bg_color(RSTTO_MAIN_WINDOW(window), bg_color);
- g_free(bg_color);
- }
-
-
- gtk_window_set_default_size(GTK_WINDOW(window), window_width, window_height);
- gtk_widget_show_all(window);
+ g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
+ gtk_widget_show_all (window);
- rstto_main_window_set_show_thumbnail_viewer(RSTTO_MAIN_WINDOW(window), show_thumbnail_viewer);
- rstto_main_window_set_show_toolbar(RSTTO_MAIN_WINDOW(window), show_toolbar);
- if (start_fullscreen)
- rstto_main_window_force_fullscreen(RSTTO_MAIN_WINDOW(window));
- if (start_slideshow)
- rstto_main_window_force_slideshow (RSTTO_MAIN_WINDOW(window));
gtk_main();
- bg_color = (GdkColor *)rstto_main_window_get_pv_bg_color(RSTTO_MAIN_WINDOW(window));
+ g_object_unref (settings);
- xfce_rc_write_bool_entry(xfce_rc, "ShowToolBar", rstto_main_window_get_show_toolbar(RSTTO_MAIN_WINDOW(window)));
- xfce_rc_write_bool_entry(xfce_rc, "ScaleTo100", rstto_main_window_get_scale_to_100(RSTTO_MAIN_WINDOW(window)));
- xfce_rc_write_bool_entry(xfce_rc, "PreloadImgs", navigator->preload);
- xfce_rc_write_bool_entry(xfce_rc, "ShowThumbnailViewer", rstto_main_window_get_show_thumbnail_viewer(RSTTO_MAIN_WINDOW(window)));
- if (bg_color)
- {
- xfce_rc_write_bool_entry(xfce_rc, "OverrideBgColor", TRUE);
- xfce_rc_write_entry(xfce_rc, "BgColor", RSTTO_COLOR_TO_STRING(bg_color));
- }
- else
- {
- xfce_rc_write_bool_entry(xfce_rc, "OverrideBgColor", FALSE);
- }
- switch (rstto_main_window_get_thumbnail_viewer_orientation(RSTTO_MAIN_WINDOW(window)))
- {
- case GTK_ORIENTATION_VERTICAL:
- xfce_rc_write_entry(xfce_rc, "ThumbnailViewerOrientation", "vertical");
- break;
- case GTK_ORIENTATION_HORIZONTAL:
- xfce_rc_write_entry(xfce_rc, "ThumbnailViewerOrientation", "horizontal");
- break;
- }
- xfce_rc_write_int_entry(xfce_rc, "MaxImagesCacheSize", rstto_main_window_get_max_cache_size(RSTTO_MAIN_WINDOW(window)));
- xfce_rc_write_int_entry(xfce_rc, "SlideShowTimeout", (gint)rstto_main_window_get_slideshow_timeout(RSTTO_MAIN_WINDOW(window)));
- xfce_rc_write_bool_entry(xfce_rc, "SlideShowHideThumbnail", rstto_main_window_get_hide_thumbnail(RSTTO_MAIN_WINDOW(window)));
- xfce_rc_flush(xfce_rc);
- xfce_rc_close(xfce_rc);
- gtk_widget_unref(window);
+ xfconf_shutdown();
return 0;
}
static gboolean
-rstto_window_save_geometry_timer (gpointer user_data)
-{
- GtkWindow *window = GTK_WINDOW(user_data);
- gint width = 0;
- gint height = 0;
- /* check if the window is still visible */
- if (GTK_WIDGET_VISIBLE (window))
- {
- /* determine the current state of the window */
- gint state = gdk_window_get_state (GTK_WIDGET (window)->window);
-
- /* don't save geometry for maximized or fullscreen windows */
- if ((state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) == 0)
- {
- /* determine the current width/height of the window... */
- gtk_window_get_size (GTK_WINDOW (window), &width, &height);
-
- /* ...and remember them as default for new windows */
- xfce_rc_write_int_entry (xfce_rc, "LastWindowWidth", width);
- xfce_rc_write_int_entry (xfce_rc, "LastWindowHeight", height);
- }
- }
- return FALSE;
-}
-
-static void
-rstto_window_save_geometry_timer_destroy(gpointer user_data)
-{
- window_save_geometry_timer_id = 0;
-}
-
-static gboolean
-cb_rstto_main_window_configure_event (GtkWidget *widget, GdkEventConfigure *event)
-{
- /* shamelessly copied from thunar, written by benny */
- /* check if we have a new dimension here */
- if (widget->allocation.width != event->width || widget->allocation.height != event->height)
- {
- /* drop any previous timer source */
- if (window_save_geometry_timer_id > 0)
- g_source_remove (window_save_geometry_timer_id);
-
- /* check if we should schedule another save timer */
- if (GTK_WIDGET_VISIBLE (widget))
- {
- /* save the geometry one second after the last configure event */
- window_save_geometry_timer_id = g_timeout_add_full (G_PRIORITY_LOW, 1000, rstto_window_save_geometry_timer,
- widget, rstto_window_save_geometry_timer_destroy);
- }
- }
-
- /* let Gtk+ handle the configure event */
- return FALSE;
-}
-
-static gboolean
cb_rstto_open_files (RsttoOpenFiles *rof)
{
- GError *error = NULL;
- gchar *path_dir = NULL;
- RsttoNavigator *navigator = rof->navigator;
- RsttoMainWindow *window = rof->main_window;
-
- GtkStatusbar *bar = rstto_main_window_get_statusbar(window);
-
- guint context_id = gtk_statusbar_get_context_id(bar, "StatusMessages");
- guint message_id = gtk_statusbar_push(bar, context_id, N_("Opening file(s)..."));
-
- if (g_slist_length(rof->files) >= 1)
+ GFile *file;
+ GFileInfo *file_info;
+ const gchar *content_type;
+ if (rof->iter < rof->argc)
{
- GSList *_iter = rof->files;
- while(_iter)
+ file = g_file_new_for_commandline_arg (rof->argv[rof->iter]);
+ if (file)
{
- if (g_path_is_absolute(_iter->data))
+ file_info = g_file_query_info (file, "standard::content-type", 0, NULL, NULL);
+ if (file_info)
{
- path_dir = g_strdup(_iter->data);
- }
- else
- {
- gchar *base_dir = g_get_current_dir();
-
- path_dir = g_build_path("/", base_dir, _iter->data, NULL);
+ content_type = g_file_info_get_attribute_string (file_info, "standard::content-type");
- g_free(base_dir);
- }
- if(g_file_test(path_dir, G_FILE_TEST_EXISTS))
- {
-
- if(g_file_test(path_dir, G_FILE_TEST_IS_DIR))
+ if (strncmp (content_type, "image/", 6) == 0)
{
- if(rstto_navigator_open_folder (navigator, path_dir, TRUE, &error) == TRUE)
- {
- rstto_navigator_jump_first(navigator);
- gtk_statusbar_remove(bar, context_id, message_id);
- }
- else
- {
-
- }
- }
- else
- {
- if (g_slist_length(rof->files) == 1)
- rstto_navigator_open_file (navigator, path_dir, TRUE, NULL);
- else
- rstto_navigator_open_file (navigator, path_dir, FALSE, NULL);
-
- gtk_statusbar_remove(bar, context_id, message_id);
+ rstto_image_list_add_file (rof->image_list, file, NULL);
}
}
-
- g_free(path_dir);
-
- _iter = g_slist_next(_iter);
}
-
- if (g_slist_length(rof->files) > 1)
- rstto_navigator_jump_first(navigator);
+ rof->iter++;
+ return TRUE;
}
-
return FALSE;
}
diff --git a/src/main_window.c b/src/main_window.c
index 6740be6..8cadffd 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) Stephan Arts 2006-2008 <stephan at xfce.org>
+ * Copyright (C) Stephan Arts 2006-2009 <stephan at xfce.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,265 +19,289 @@
#include <config.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
-#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <string.h>
-#include <thunar-vfs/thunar-vfs.h>
+
+#include <gio/gio.h>
+
#include <libxfcegui4/libxfcegui4.h>
#include <libexif/exif-data.h>
-#include <dbus/dbus-glib.h>
-#include "navigator.h"
-#include "thumbnail_bar.h"
+#include <cairo/cairo.h>
+
+#include "image.h"
+
+#include "settings.h"
+#include "image_list.h"
+#include "image_cache.h"
#include "picture_viewer.h"
#include "main_window.h"
-#include "save_dialog.h"
+#include "main_window_ui.h"
+#include "thumbnail_bar.h"
+
+#include "preferences_dialog.h"
#define XFDESKTOP_SELECTION_FMT "XFDESKTOP_SELECTION_%d"
+#ifndef RISTRETTO_APP_TITLE
+#define RISTRETTO_APP_TITLE "Image viewer"
+#endif
+
+
+#ifndef ZOOM_FACTOR
+#define ZOOM_FACTOR 1.2
+#endif
struct _RsttoMainWindowPriv
{
- RsttoNavigator *navigator;
- GtkWidget *thumbnail_viewer;
- GtkWidget *picture_viewer;
- GtkWidget *statusbar;
- GtkRecentManager *manager;
- GtkIconTheme *icon_theme;
- ThunarVfsMimeDatabase *mime_dbase;
- GList *menu_apps_list;
- gdouble zoom_factor;
+ struct {
+ RsttoImageList *image_list;
+ gboolean toolbar_visible;
+ } props;
- DBusGConnection *connection;
- DBusGProxy *filemanager_proxy;
+ guint show_fs_toolbar_timeout_id;
+ gint window_save_geometry_timer_id;
+
+ gboolean fs_toolbar_sticky;
- struct {
- GtkWidget *main_vbox;
- GtkWidget *s_window;
- GtkWidget *paned;
- } containers;
+ RsttoImageListIter *iter;
- struct {
- GtkOrientation thumbnail_viewer_orientation;
- gboolean thumbnail_viewer_visibility;
- gboolean toolbar_visibility;
- gint max_cache_size;
- gdouble slideshow_timeout;
- gboolean slideshow_hide_thumbnail;
- const GdkColor *bg_color;
- gboolean scale_to_100;
- RsttoDesktop desktop;
- gboolean start_fullscreen;
- gboolean start_slideshow;
- } settings;
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
+ GtkRecentManager *recent_manager;
+ RsttoSettings *settings_manager;
- struct {
- GtkWidget *menu;
- GtkWidget *menu_item_file;
- struct {
- GtkWidget *menu;
- GtkWidget *menu_item_open_file;
- GtkWidget *menu_item_open_folder;
- GtkWidget *menu_item_open_recently;
- struct {
- GtkWidget *menu;
- GtkWidget *menu_item_separator_1;
- GtkWidget *menu_item_clear;
- } recently;
- GtkWidget *menu_item_separator_1;
- GtkWidget *menu_item_file_properties;
- GtkWidget *menu_item_separator_2;
- GtkWidget *menu_item_close;
- GtkWidget *menu_item_close_all;
- GtkWidget *menu_item_quit;
- } file;
-
- GtkWidget *menu_item_edit;
- struct {
- GtkWidget *menu;
- GtkWidget *menu_item_open_with;
- struct {
- GtkWidget *menu;
- GtkWidget *menu_item_empty;
- } open_with;
- GtkWidget *menu_item_preferences;
- } edit;
-
- GtkWidget *menu_item_view;
- struct {
- GtkWidget *menu;
- GtkWidget *menu_item_show_toolbar;
- GtkWidget *menu_item_show_thumbnail_viewer;
- struct {
- GtkWidget *menu;
- GtkWidget *menu_item_thumbnail_viewer_horizontal;
- GtkWidget *menu_item_thumbnail_viewer_vertical;
- GtkWidget *menu_item_thumbnail_viewer_hide;
- } show_thumbnail_viewer;
- GtkWidget *menu_item_separator_1;
-
- GtkWidget *menu_item_zooming;
- struct {
- GtkWidget *menu;
- GtkWidget *menu_item_zoom_in;
- GtkWidget *menu_item_zoom_out;
- GtkWidget *menu_item_zoom_100;
- GtkWidget *menu_item_zoom_fit;
- GtkWidget *menu_item_zoom_box;
- } zooming;
-
- GtkWidget *menu_item_rotate;
- struct {
- GtkWidget *menu;
- GtkWidget *menu_item_rotate_cw;
- GtkWidget *menu_item_rotate_ccw;
- } rotate;
-
- GtkWidget *menu_item_separator_2;
- GtkWidget *menu_item_fullscreen;
- GtkWidget *menu_item_set_wallpaper;
- } view;
-
- GtkWidget *menu_item_go;
- struct {
- GtkWidget *menu;
- GtkWidget *menu_item_next;
- GtkWidget *menu_item_previous;
- GtkWidget *menu_item_first;
- GtkWidget *menu_item_last;
- GtkWidget *menu_item_separator_1;
- GtkWidget *menu_item_play;
- GtkWidget *menu_item_pause;
- } go;
-
- GtkWidget *menu_item_help;
- struct {
- GtkWidget *menu;
- GtkWidget *menu_item_about;
- } help;
-
- struct {
- GtkWidget *menu;
- GtkWidget *menu_item_open_file;
- GtkWidget *menu_item_close;
- GtkWidget *menu_item_separator_1;
- GtkWidget *menu_item_open_with;
- struct {
- GtkWidget *menu;
- GtkWidget *menu_item_empty;
- } open_with;
- GtkWidget *menu_item_separator_2;
- GtkWidget *menu_item_zoom_in;
- GtkWidget *menu_item_zoom_out;
- GtkWidget *menu_item_zoom_fit;
- GtkWidget *menu_item_zoom_100;
- } _picture_viewer;
- } menus;
+ GtkWidget *menubar;
+ GtkWidget *toolbar;
+ GtkWidget *image_list_toolbar;
+ GtkWidget *image_list_toolbar_menu;
+ GtkWidget *picture_viewer;
+ GtkWidget *p_viewer_s_window;
+ GtkWidget *hpaned;
+ GtkWidget *thumbnail_bar;
+ GtkWidget *statusbar;
- struct {
- GtkWidget *bar;
-
- GtkToolItem *tool_item_open;
- GtkToolItem *tool_item_separator_1;
- GtkToolItem *tool_item_next;
- GtkToolItem *tool_item_previous;
- GtkToolItem *tool_item_spacer_1;
-
- GtkToolItem *tool_item_zoom_fit;
- GtkToolItem *tool_item_zoom_100;
- GtkToolItem *tool_item_zoom_out;
- GtkToolItem *tool_item_zoom_in;
- } toolbar;
+ GtkWidget *message_bar;
+ GtkWidget *message_bar_label;
+ GtkWidget *message_bar_button_cancel;
+ GtkWidget *message_bar_button_open;
+ GFile *message_bar_file;
+
+ guint t_open_merge_id;
+ guint t_open_folder_merge_id;
+ guint recent_merge_id;
+ guint play_merge_id;
+ guint pause_merge_id;
+ guint toolbar_play_merge_id;
+ guint toolbar_pause_merge_id;
+ guint toolbar_fullscreen_merge_id;
+ guint toolbar_unfullscreen_merge_id;
+
+ GtkAction *play_action;
+ GtkAction *pause_action;
+ GtkAction *recent_action;
+
+ gboolean playing;
+ gint play_timeout_id;
+};
+
+enum
+{
+ PROP_0,
+ PROP_IMAGE_LIST,
};
static void
-cb_rstto_main_window_thumbnail_viewer_horizontal(GtkWidget *widget, RsttoMainWindow *window);
-static void
-cb_rstto_main_window_thumbnail_viewer_vertical(GtkWidget *widget, RsttoMainWindow *window);
+rstto_main_window_init (RsttoMainWindow *);
static void
-cb_rstto_main_window_thumbnail_viewer_hide(GtkWidget *widget, RsttoMainWindow *window);
+rstto_main_window_class_init(RsttoMainWindowClass *);
static void
-cb_rstto_main_window_toggle_toolbar(GtkWidget *widget, RsttoMainWindow *window);
+rstto_main_window_dispose(GObject *object);
+
static void
-cb_rstto_main_window_toggle_fullscreen(GtkWidget *widget, RsttoMainWindow *window);
-#ifdef WITH_DESKTOP_WALLPAPER
+rstto_main_window_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
static void
-cb_rstto_main_window_set_wallpaper(GtkWidget *widget, RsttoMainWindow *window);
-#endif
+rstto_main_window_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
static gboolean
-cb_rstto_main_window_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data);
+rstto_window_save_geometry_timer (gpointer user_data);
+static gboolean
+cb_rstto_main_window_configure_event (GtkWidget *widget, GdkEventConfigure *event);
static void
cb_rstto_main_window_state_event(GtkWidget *widget, GdkEventWindowState *event, gpointer user_data);
+static gboolean
+cb_rstto_main_window_show_fs_toolbar_timeout (RsttoMainWindow *window);
static void
-cb_rstto_main_window_play(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_image_list_iter_changed (RsttoImageListIter *iter, RsttoMainWindow *window);
static void
-cb_rstto_main_window_pause(GtkWidget *widget, RsttoMainWindow *window);
+rstto_main_window_image_list_iter_changed (RsttoMainWindow *window);
+
static void
-cb_rstto_main_window_spawn_app(GtkWidget *widget, ThunarVfsMimeApplication *app);
+cb_rstto_main_window_image_list_new_image (RsttoImageList *image_list, RsttoImage *image, RsttoMainWindow *window);
static void
-cb_rstto_main_window_next(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_zoom_100 (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_previous(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_zoom_fit (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_last(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_zoom_in (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_first(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_zoom_out (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_zoom_in(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_rotate_cw (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_zoom_out(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_rotate_ccw (GtkWidget *widget, RsttoMainWindow *window);
+
static void
-cb_rstto_main_window_zoom_100(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_next_image (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_zoom_fit(GtkWidget *widget, RsttoMainWindow *window);
-
+cb_rstto_main_window_previous_image (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_rotate_cw(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_first_image (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_rotate_ccw(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_last_image (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_open_file(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_open_image (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_open_folder(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_open_folder (GtkWidget *widget, RsttoMainWindow *window);
static void
cb_rstto_main_window_open_recent(GtkRecentChooser *chooser, RsttoMainWindow *window);
static void
-cb_rstto_main_window_clear_recent(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_close (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_close(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_close_all (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_close_all(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_save_copy (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_file_properties(GtkWidget *widget, RsttoMainWindow *window);
-static void
-cb_rstto_main_window_quit(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_delete (GtkWidget *widget, RsttoMainWindow *window);
+
static void
-cb_rstto_main_window_about(GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_print (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_preferences(GtkWidget *widget, RsttoMainWindow *window);
+rstto_main_window_print_draw_page (GtkPrintOperation *operation,
+ GtkPrintContext *print_context,
+ gint page_nr,
+ RsttoMainWindow *window);
static void
-cb_rstto_bg_color_override_check_toggled(GtkToggleButton *button, GtkWidget *);
+cb_rstto_main_window_play (GtkWidget *widget, RsttoMainWindow *window);
+static void
+cb_rstto_main_window_pause(GtkWidget *widget, RsttoMainWindow *window);
+static gboolean
+cb_rstto_main_window_play_slideshow (RsttoMainWindow *window);
static void
-cb_rstto_main_window_nav_iter_changed(RsttoNavigator *navigator, gint nr, RsttoNavigatorEntry *entry, RsttoMainWindow *window);
+cb_rstto_main_window_message_bar_open (GtkWidget *widget, RsttoMainWindow *window);
static void
-cb_rstto_main_window_nav_new_entry(RsttoNavigator *navigator, gint nr, RsttoNavigatorEntry *entry, RsttoMainWindow *window);
+cb_rstto_main_window_message_bar_cancel (GtkWidget *widget, RsttoMainWindow *window);
+
static void
-rstto_main_window_init(RsttoMainWindow *);
+cb_rstto_main_window_toggle_show_toolbar (GtkWidget *widget, RsttoMainWindow *window);
static void
-rstto_main_window_class_init(RsttoMainWindowClass *);
+cb_rstto_main_window_fullscreen (GtkWidget *widget, RsttoMainWindow *window);
static void
-rstto_main_window_dispose(GObject *object);
+cb_rstto_main_window_preferences (GtkWidget *widget, RsttoMainWindow *window);
+static void
+cb_rstto_main_window_about (GtkWidget *widget, RsttoMainWindow *window);
+static void
+cb_rstto_main_window_contents (GtkWidget *widget, RsttoMainWindow *window);
+static void
+cb_rstto_main_window_quit (GtkWidget *widget, RsttoMainWindow *window);
+
+static void
+cb_rstto_main_window_settings_notify (GObject *settings, GParamSpec *spec, RsttoMainWindow *window);
+
+static gboolean
+cb_rstto_main_window_picture_viewer_motion_notify_event (RsttoPictureViewer *viewer,
+ GdkEventMotion *event,
+ gpointer user_data);
+
+static void
+rstto_main_window_set_sensitive (RsttoMainWindow *window, gboolean sensitive);
static GtkWidgetClass *parent_class = NULL;
+static GtkActionEntry action_entries[] =
+{
+/* File Menu */
+ { "file-menu", NULL, N_ ("_File"), NULL, },
+ { "open", "document-open", N_ ("_Open"), "<control>O", N_ ("Open an image"), G_CALLBACK (cb_rstto_main_window_open_image), },
+ { "open-folder", "folder-open", N_ ("Open _Folder"), NULL, N_ ("Open a folder"), G_CALLBACK (cb_rstto_main_window_open_folder), },
+ { "save-copy", GTK_STOCK_SAVE_AS, N_ ("_Save copy"), "<control>s", N_ ("Save a copy of the image"), G_CALLBACK (cb_rstto_main_window_save_copy), },
+ { "print", GTK_STOCK_PRINT, N_ ("_Print"), "<control>p", N_ ("Print the image"), G_CALLBACK (cb_rstto_main_window_print), },
+ { "close", GTK_STOCK_CLOSE, N_ ("_Close"), "<control>W", N_ ("Close this image"), G_CALLBACK (cb_rstto_main_window_close), },
+ { "close-all", NULL, N_ ("_Close All"), NULL, N_ ("Close all images"), G_CALLBACK (cb_rstto_main_window_close_all), },
+ { "quit", GTK_STOCK_QUIT, N_ ("_Quit"), "<control>Q", N_ ("Quit Ristretto"), G_CALLBACK (cb_rstto_main_window_quit), },
+/* Edit Menu */
+ { "edit-menu", NULL, N_ ("_Edit"), NULL, },
+ { "open-with-menu", NULL, N_ ("_Open with..."), NULL, },
+ { "sorting-menu", NULL, N_ ("_Sorting"), NULL, },
+ { "delete", GTK_STOCK_DELETE, N_ ("_Delete"), "Delete", NULL, G_CALLBACK (cb_rstto_main_window_delete), },
+ { "preferences", GTK_STOCK_PREFERENCES, N_ ("_Preferences"), NULL, NULL, G_CALLBACK (cb_rstto_main_window_preferences), },
+/* View Menu */
+ { "view-menu", NULL, N_ ("_View"), NULL, },
+ { "fullscreen", GTK_STOCK_FULLSCREEN, N_ ("_Fullscreen"), "F11", NULL, G_CALLBACK (cb_rstto_main_window_fullscreen), },
+ { "unfullscreen", GTK_STOCK_LEAVE_FULLSCREEN, N_ ("_Leave Fullscreen"), NULL, NULL, G_CALLBACK (cb_rstto_main_window_fullscreen), },
+ { "set-as-wallpaper", NULL, N_ ("_Set as Wallpaper"), NULL, NULL, NULL, },
+/* Thumbnailbar submenu */
+ { "thumbnailbar-menu", NULL, N_ ("_Thumbnail Bar"), NULL, },
+/* Zoom submenu */
+ { "zoom-menu", NULL, N_ ("_Zooming"), NULL, },
+ { "zoom-in", GTK_STOCK_ZOOM_IN, N_ ("Zoom _In"), "<control>plus", NULL, G_CALLBACK (cb_rstto_main_window_zoom_in),},
+ { "zoom-out", GTK_STOCK_ZOOM_OUT, N_ ("Zoom _Out"), "<control>minus", NULL, G_CALLBACK (cb_rstto_main_window_zoom_out), },
+ { "zoom-fit", GTK_STOCK_ZOOM_FIT, N_ ("Zoom _Fit"), "<control>equal", NULL, G_CALLBACK (cb_rstto_main_window_zoom_fit), },
+ { "zoom-100", GTK_STOCK_ZOOM_100, N_ ("_Normal Size"), "<control>0", NULL, G_CALLBACK (cb_rstto_main_window_zoom_100), },
+/* Rotation submenu */
+ { "rotation-menu", NULL, N_ ("_Rotation"), NULL, },
+ { "rotate-cw", "object-rotate-right", N_ ("Rotate _Right"), "<control>bracketright", NULL, G_CALLBACK (cb_rstto_main_window_rotate_cw), },
+ { "rotate-ccw", "object-rotate-left", N_ ("Rotate _Left"), "<contron>bracketleft", NULL, G_CALLBACK (cb_rstto_main_window_rotate_ccw), },
+/* Go Menu */
+ { "go-menu", NULL, N_ ("_Go"), NULL, },
+ { "forward", GTK_STOCK_GO_FORWARD, N_ ("_Forward"), "space", NULL, G_CALLBACK (cb_rstto_main_window_next_image), },
+ { "back", GTK_STOCK_GO_BACK, N_ ("_Back"), "BackSpace", NULL, G_CALLBACK (cb_rstto_main_window_previous_image), },
+ { "first", GTK_STOCK_GOTO_FIRST, N_ ("_First"), "Home", NULL, G_CALLBACK (cb_rstto_main_window_first_image), },
+ { "last", GTK_STOCK_GOTO_LAST, N_ ("_Last"), "End", NULL, G_CALLBACK (cb_rstto_main_window_last_image), },
+/* Help Menu */
+ { "help-menu", NULL, N_ ("_Help"), NULL, },
+ { "contents", GTK_STOCK_HELP,
+ N_ ("_Contents"),
+ "F1",
+ N_ ("Display ristretto user manual"),
+ G_CALLBACK (cb_rstto_main_window_contents), },
+ { "about", GTK_STOCK_ABOUT,
+ N_ ("_About"),
+ NULL,
+ N_ ("Display information about ristretto"),
+ G_CALLBACK (cb_rstto_main_window_about), },
+/* Misc */
+ { "leave-fullscreen", GTK_STOCK_LEAVE_FULLSCREEN, N_ ("Leave _Fullscreen"), NULL, NULL, G_CALLBACK (cb_rstto_main_window_fullscreen), },
+ { "tb-menu", NULL, NULL, NULL, }
+};
+
+static const GtkToggleActionEntry toggle_action_entries[] =
+{
+ { "show-toolbar", NULL, N_ ("Show _Toolbar"), NULL, NULL, G_CALLBACK (cb_rstto_main_window_toggle_show_toolbar), TRUE, },
+ { "show-thumbnailbar", NULL, N_ ("Show Thumb_nailbar"), NULL, NULL, NULL, FALSE},
+};
+
+static const GtkRadioActionEntry radio_action_sort_entries[] =
+{
+ {"sort-filename", NULL, N_("sort by filename"), NULL, NULL, 0},
+ {"sort-date", NULL, N_("sort by date"), NULL, NULL, 1},
+};
+
+
GType
-rstto_main_window_get_type ()
+rstto_main_window_get_type (void)
{
static GType rstto_main_window_type = 0;
@@ -303,1259 +327,1212 @@ rstto_main_window_get_type ()
}
static void
-rstto_main_window_init(RsttoMainWindow *window)
+rstto_main_window_init (RsttoMainWindow *window)
{
- window->priv = g_new0(RsttoMainWindowPriv, 1);
- window->priv->zoom_factor = 1.2;
-
- window->priv->mime_dbase = thunar_vfs_mime_database_get_default();
- window->priv->icon_theme = gtk_icon_theme_get_default();
-
- window->priv->settings.scale_to_100 = TRUE;
-
-
- GtkAccelGroup *accel_group = gtk_accel_group_new();
+ GtkAccelGroup *accel_group;
+ GValue show_toolbar_val = {0,}, window_width = {0, }, window_height = {0, };
+ GtkWidget *separator, *back, *forward;
+ GtkWidget *main_vbox = gtk_vbox_new (FALSE, 0);
+ GtkRecentFilter *recent_filter;
- gtk_window_set_title(GTK_WINDOW(window), PACKAGE_STRING);
- gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
+ GClosure *leave_fullscreen_closure = g_cclosure_new_swap ((GCallback)gtk_window_unfullscreen, window, NULL);
+ GClosure *next_image_closure = g_cclosure_new ((GCallback)cb_rstto_main_window_next_image, window, NULL);
+ GClosure *previous_image_closure = g_cclosure_new ((GCallback)cb_rstto_main_window_previous_image, window, NULL);
- window->priv->manager = gtk_recent_manager_get_default();
- window->priv->navigator = rstto_navigator_new(window->priv->manager);
- window->priv->thumbnail_viewer = rstto_thumbnail_bar_new(window->priv->navigator);
- window->priv->picture_viewer = rstto_picture_viewer_new(window->priv->navigator);
+ gtk_window_set_title (GTK_WINDOW (window), RISTRETTO_APP_TITLE);
+ window->priv = g_new0(RsttoMainWindowPriv, 1);
-/* Set up default settings */
- window->priv->settings.thumbnail_viewer_orientation = GTK_ORIENTATION_HORIZONTAL;
- window->priv->settings.thumbnail_viewer_visibility = TRUE;
+ window->priv->iter = NULL;
+
+ window->priv->ui_manager = gtk_ui_manager_new ();
+ window->priv->recent_manager = gtk_recent_manager_get_default();
+ window->priv->settings_manager = rstto_settings_new();
+
+ accel_group = gtk_ui_manager_get_accel_group (window->priv->ui_manager);
+ gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
+
+ gtk_accel_group_connect_by_path (accel_group, "<Window>/unfullscreen", leave_fullscreen_closure);
+ gtk_accel_group_connect_by_path (accel_group, "<Window>/next-image", next_image_closure);
+ gtk_accel_group_connect_by_path (accel_group, "<Window>/previous-image", previous_image_closure);
+ /* Set default accelerators */
+ gtk_accel_map_change_entry ("<Window>/unfullscreen", GDK_Escape, 0, FALSE);
+ gtk_accel_map_change_entry ("<Window>/next-image", GDK_Page_Down, 0, FALSE);
+ gtk_accel_map_change_entry ("<Window>/previous-image", GDK_Page_Up, 0, FALSE);
+
+ /* Create mergeid's for adding ui-components */
+ window->priv->recent_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
+ window->priv->play_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
+ window->priv->pause_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
+ window->priv->toolbar_play_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
+ window->priv->toolbar_pause_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
+ window->priv->toolbar_fullscreen_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
+ window->priv->toolbar_unfullscreen_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
+
+
+ window->priv->play_action = gtk_action_new ("play", "_Play", "Play slideshow", GTK_STOCK_MEDIA_PLAY);
+ window->priv->pause_action = gtk_action_new ("pause", "_Pause", "Pause slideshow", GTK_STOCK_MEDIA_PAUSE);
+ window->priv->recent_action = gtk_recent_action_new_for_manager ("document-open-recent", "_Recently used", "Recently used", 0, GTK_RECENT_MANAGER(window->priv->recent_manager));
+
+ gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (window->priv->recent_action), GTK_RECENT_SORT_MRU);
+
+ /**
+ * Add a filter to the recent-chooser
+ */
+ recent_filter = gtk_recent_filter_new();
+ gtk_recent_filter_add_application (recent_filter, "ristretto");
+ gtk_recent_chooser_add_filter(GTK_RECENT_CHOOSER(window->priv->recent_action), recent_filter);
+
+ /* Add the same accelerator path to play and pause, so the same kb-shortcut will be used for starting and stopping the slideshow */
+ gtk_action_set_accel_path (window->priv->pause_action, "<Actions>/RsttoWindow/play");
+ gtk_action_set_accel_path (window->priv->play_action, "<Actions>/RsttoWindow/play");
+
+ /* Add the play and pause actions to the actiongroup */
+ window->priv->action_group = gtk_action_group_new ("RsttoWindow");
+ gtk_action_group_add_action (window->priv->action_group,
+ window->priv->play_action);
+ gtk_action_group_add_action (window->priv->action_group,
+ window->priv->pause_action);
+ gtk_action_group_add_action (window->priv->action_group,
+ window->priv->recent_action);
+ /* Connect signal-handlers */
+ g_signal_connect(G_OBJECT(window->priv->play_action), "activate", G_CALLBACK(cb_rstto_main_window_play), window);
+ g_signal_connect(G_OBJECT(window->priv->pause_action), "activate", G_CALLBACK(cb_rstto_main_window_pause), window);
+ g_signal_connect(G_OBJECT(window->priv->recent_action), "item-activated", G_CALLBACK(cb_rstto_main_window_open_recent), window);
+
+ gtk_ui_manager_insert_action_group (window->priv->ui_manager, window->priv->action_group, 0);
+
+ gtk_action_group_set_translation_domain (window->priv->action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (window->priv->action_group, action_entries, G_N_ELEMENTS (action_entries), GTK_WIDGET (window));
+ gtk_action_group_add_toggle_actions (window->priv->action_group, toggle_action_entries, G_N_ELEMENTS (toggle_action_entries), GTK_WIDGET (window));
+ gtk_action_group_add_radio_actions (window->priv->action_group, radio_action_sort_entries , G_N_ELEMENTS (radio_action_sort_entries), 0, NULL, GTK_WIDGET (window));
+
+ gtk_ui_manager_add_ui_from_string (window->priv->ui_manager,main_window_ui, main_window_ui_length, NULL);
+ window->priv->menubar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu");
+ window->priv->toolbar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-toolbar");
+ window->priv->image_list_toolbar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/navigation-toolbar");
+ window->priv->image_list_toolbar_menu = gtk_ui_manager_get_widget (window->priv->ui_manager, "/tb-menu");
-/* Create menu bar */
- window->priv->menus.menu = gtk_menu_bar_new();
-/* Create 'File' menu */
- window->priv->menus.menu_item_file = gtk_menu_item_new_with_mnemonic(_("_File"));
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.menu), window->priv->menus.menu_item_file);
-
- window->priv->menus.file.menu = gtk_menu_new();
- gtk_menu_set_accel_group(GTK_MENU(window->priv->menus.file.menu), accel_group);
-
- window->priv->menus.file.menu_item_open_file = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, accel_group);
- window->priv->menus.file.menu_item_open_folder = gtk_menu_item_new_with_mnemonic(_("O_pen Folder"));
- window->priv->menus.file.menu_item_open_recently = gtk_menu_item_new_with_mnemonic(_("_Recently used"));
- window->priv->menus.file.menu_item_separator_1 = gtk_separator_menu_item_new();
- window->priv->menus.file.menu_item_file_properties = gtk_image_menu_item_new_from_stock(GTK_STOCK_PROPERTIES, accel_group);
- window->priv->menus.file.menu_item_separator_2 = gtk_separator_menu_item_new();
- window->priv->menus.file.menu_item_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_group);
- window->priv->menus.file.menu_item_close_all = gtk_menu_item_new_with_mnemonic(_("Close _all"));
- window->priv->menus.file.menu_item_quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, accel_group);
-
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(window->priv->menus.menu_item_file), window->priv->menus.file.menu);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.file.menu), window->priv->menus.file.menu_item_open_file);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.file.menu), window->priv->menus.file.menu_item_open_folder);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.file.menu), window->priv->menus.file.menu_item_open_recently);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.file.menu), window->priv->menus.file.menu_item_separator_1);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.file.menu), window->priv->menus.file.menu_item_file_properties);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.file.menu), window->priv->menus.file.menu_item_separator_2);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.file.menu), window->priv->menus.file.menu_item_close);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.file.menu), window->priv->menus.file.menu_item_close_all);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.file.menu), window->priv->menus.file.menu_item_quit);
-
- gtk_widget_set_sensitive(window->priv->menus.file.menu_item_close, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.file.menu_item_close_all, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.file.menu_item_file_properties, FALSE);
-
- window->priv->menus.file.recently.menu = gtk_recent_chooser_menu_new_for_manager(GTK_RECENT_MANAGER(window->priv->manager));
- window->priv->menus.file.recently.menu_item_clear = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLEAR, accel_group);
- window->priv->menus.file.recently.menu_item_separator_1 = gtk_separator_menu_item_new();
-
- GtkRecentFilter *filter = gtk_recent_filter_new();
- gtk_recent_filter_add_application(filter, "ristretto");
- gtk_recent_chooser_add_filter(GTK_RECENT_CHOOSER(window->priv->menus.file.recently.menu), filter);
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(window->priv->menus.file.menu_item_open_recently), window->priv->menus.file.recently.menu);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.file.recently.menu), window->priv->menus.file.recently.menu_item_separator_1);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.file.recently.menu), window->priv->menus.file.recently.menu_item_clear);
-
-/* Create 'Edit' menu */
- window->priv->menus.menu_item_edit = gtk_menu_item_new_with_mnemonic(_("_Edit"));
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.menu), window->priv->menus.menu_item_edit);
-
- window->priv->menus.edit.menu = gtk_menu_new();
- gtk_menu_set_accel_group(GTK_MENU(window->priv->menus.edit.menu), accel_group);
- window->priv->menus.edit.menu_item_open_with = gtk_menu_item_new_with_mnemonic(_("Open with..."));
- window->priv->menus.edit.menu_item_preferences = gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES, NULL);
-
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(window->priv->menus.menu_item_edit), window->priv->menus.edit.menu);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.edit.menu), window->priv->menus.edit.menu_item_open_with);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.edit.menu), window->priv->menus.edit.menu_item_preferences);
- window->priv->menus.edit.open_with.menu = gtk_menu_new();
- window->priv->menus.edit.open_with.menu_item_empty = gtk_menu_item_new_with_label(_("No applications available"));
-
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.edit.open_with.menu), window->priv->menus.edit.open_with.menu_item_empty);
- gtk_widget_set_sensitive(window->priv->menus.edit.open_with.menu_item_empty, FALSE);
- gtk_widget_ref(window->priv->menus.edit.open_with.menu_item_empty);
-
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(window->priv->menus.edit.menu_item_open_with), window->priv->menus.edit.open_with.menu);
-
-/* Create 'View' menu */
- window->priv->menus.menu_item_view = gtk_menu_item_new_with_mnemonic(_("_View"));
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.menu), window->priv->menus.menu_item_view);
-
- window->priv->menus.view.menu = gtk_menu_new();
- gtk_menu_set_accel_group(GTK_MENU(window->priv->menus.view.menu), accel_group);
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(window->priv->menus.menu_item_view), window->priv->menus.view.menu);
-
- window->priv->menus.view.menu_item_show_toolbar = gtk_check_menu_item_new_with_mnemonic(_("Show _Toolbar"));
- window->priv->menus.view.menu_item_show_thumbnail_viewer = gtk_menu_item_new_with_mnemonic(_("Thumbnail _Viewer"));
-
- window->priv->menus.view.menu_item_separator_1 = gtk_separator_menu_item_new();
-
- window->priv->menus.view.menu_item_zooming = gtk_menu_item_new_with_mnemonic(_("_Zooming"));
- window->priv->menus.view.menu_item_rotate = gtk_menu_item_new_with_mnemonic(_("_Rotate"));
-
- window->priv->menus.view.menu_item_separator_2 = gtk_separator_menu_item_new();
-
- window->priv->menus.view.menu_item_fullscreen = gtk_image_menu_item_new_from_stock(GTK_STOCK_FULLSCREEN, NULL);
+ /**
+ * Get the separator toolitem and tell it to expand
+ */
+ separator = gtk_ui_manager_get_widget (window->priv->ui_manager, "/navigation-toolbar/separator-1");
+ gtk_tool_item_set_expand (GTK_TOOL_ITEM (separator), TRUE);
+ gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (separator), FALSE);
+
+ /**
+ * Make the back and forward toolitems important,
+ * when they are, the labels are shown when the toolbar style is 'both-horizontal'
+ */
+ back = gtk_ui_manager_get_widget (window->priv->ui_manager, "/navigation-toolbar/back");
+ gtk_tool_item_set_is_important (GTK_TOOL_ITEM (back), TRUE);
+ forward = gtk_ui_manager_get_widget (window->priv->ui_manager, "/navigation-toolbar/forward");
+ gtk_tool_item_set_is_important (GTK_TOOL_ITEM (forward), TRUE);
+
+ window->priv->picture_viewer = rstto_picture_viewer_new ();
+ window->priv->p_viewer_s_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (window->priv->p_viewer_s_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_container_add (GTK_CONTAINER (window->priv->p_viewer_s_window), window->priv->picture_viewer);
+ window->priv->thumbnail_bar = rstto_thumbnail_bar_new (NULL);
+ window->priv->hpaned = gtk_hpaned_new();
+ gtk_paned_pack1 (GTK_PANED (window->priv->hpaned), window->priv->p_viewer_s_window, TRUE, FALSE);
+ gtk_paned_pack2 (GTK_PANED (window->priv->hpaned), window->priv->thumbnail_bar, FALSE, FALSE);
- GtkWidget *wallpaper_image = gtk_image_new_from_icon_name("preferences-desktop-wallpaper", GTK_ICON_SIZE_MENU);
- window->priv->menus.view.menu_item_set_wallpaper = gtk_image_menu_item_new_with_mnemonic(_("_Set as wallpaper"));
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(window->priv->menus.view.menu_item_set_wallpaper), wallpaper_image);
+ window->priv->statusbar = gtk_statusbar_new();
-#ifdef WITH_DESKTOP_WALLPAPER
- /** Set xfce-desktop as default when support has been compiled in */
- /* Check if xfdesktop is running */
+ window->priv->message_bar = gtk_hbox_new (FALSE,0);
+ window->priv->message_bar_label = gtk_label_new (N_("Do you want to open all the images in the folder?"));
+ window->priv->message_bar_button_cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+ window->priv->message_bar_button_open = gtk_button_new_from_stock (GTK_STOCK_OPEN);
+
+ g_signal_connect(G_OBJECT(window->priv->message_bar_button_cancel), "clicked", G_CALLBACK(cb_rstto_main_window_message_bar_cancel), window);
+ g_signal_connect(G_OBJECT(window->priv->message_bar_button_open), "clicked", G_CALLBACK(cb_rstto_main_window_message_bar_open), window);
+
+ gtk_container_set_border_width (GTK_CONTAINER (window->priv->message_bar), 2);
+ gtk_box_pack_start (GTK_BOX (window->priv->message_bar), window->priv->message_bar_label, FALSE,FALSE, 5);
+ gtk_box_pack_end (GTK_BOX (window->priv->message_bar), window->priv->message_bar_button_cancel, FALSE,FALSE, 5);
+ gtk_box_pack_end (GTK_BOX (window->priv->message_bar), window->priv->message_bar_button_open, FALSE,FALSE, 5);
+
+ gtk_container_add (GTK_CONTAINER (window), main_vbox);
+ gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->menubar, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->toolbar, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->message_bar, FALSE,FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->hpaned, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->image_list_toolbar, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->statusbar, FALSE, FALSE, 0);
+
+ rstto_main_window_set_sensitive (window, FALSE);
+ gtk_widget_set_no_show_all (window->priv->toolbar, TRUE);
+ gtk_widget_set_no_show_all (window->priv->message_bar, TRUE);
+
+ /**
+ * Add missing pieces to the UI
+ */
+ gtk_ui_manager_add_ui (window->priv->ui_manager,
+ window->priv->play_merge_id,
+ "/main-menu/go-menu/placeholder-slideshow",
+ "play",
+ "play",
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
+ gtk_ui_manager_add_ui (window->priv->ui_manager,
+ window->priv->recent_merge_id,
+ "/main-menu/file-menu/placeholder-open-recent",
+ "document-open-recent",
+ "document-open-recent",
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
+ gtk_ui_manager_add_ui (window->priv->ui_manager,
+ window->priv->toolbar_play_merge_id,
+ "/navigation-toolbar/placeholder-slideshow",
+ "play",
+ "play",
+ GTK_UI_MANAGER_TOOLITEM,
+ FALSE);
+ gtk_ui_manager_add_ui (window->priv->ui_manager,
+ window->priv->toolbar_fullscreen_merge_id,
+ "/navigation-toolbar/placeholder-fullscreen",
+ "fullscreen",
+ "fullscreen",
+ GTK_UI_MANAGER_TOOLITEM,
+ FALSE);
+
+ /**
+ * Retrieve the last window-size from the settings-manager
+ * and make it the default for this window
+ */
+ g_value_init (&window_width, G_TYPE_UINT);
+ g_value_init (&window_height, G_TYPE_UINT);
+ g_object_get_property (G_OBJECT(window->priv->settings_manager), "window-width", &window_width);
+ g_object_get_property (G_OBJECT(window->priv->settings_manager), "window-height", &window_height);
+ gtk_window_set_default_size(GTK_WINDOW(window), g_value_get_uint (&window_width), g_value_get_uint (&window_height));
+
+ /**
+ * Retrieve the toolbar state from the settings-manager
+ */
+ g_value_init (&show_toolbar_val, G_TYPE_BOOLEAN);
+ g_object_get_property (G_OBJECT(window->priv->settings_manager), "show-toolbar", &show_toolbar_val);
+ if (g_value_get_boolean (&show_toolbar_val))
{
- gchar selection_name[100];
-
- GdkScreen *gdk_screen = gdk_screen_get_default();
- gint xscreen = gdk_screen_get_number(gdk_screen);
-
- g_snprintf(selection_name, 100, XFDESKTOP_SELECTION_FMT, xscreen);
-
- Atom xfce_selection_atom = XInternAtom (gdk_display, selection_name, False);
- if((XGetSelectionOwner(GDK_DISPLAY(), xfce_selection_atom)))
- {
- if (rstto_has_xfconf_query)
- window->priv->settings.desktop = RSTTO_DESKTOP_XFCE;
- }
- else
- {
- g_debug("xfdesktop is not running");
- }
+ gtk_check_menu_item_set_active (
+ GTK_CHECK_MENU_ITEM (
+ gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/view-menu/show-toolbar")),
+ TRUE);
+ gtk_widget_show (window->priv->toolbar);
+ }
+ else
+ {
+ gtk_check_menu_item_set_active (
+ GTK_CHECK_MENU_ITEM (
+ gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/view-menu/show-toolbar")),
+ FALSE);
+ gtk_widget_hide (window->priv->toolbar);
}
-#endif
-
- gtk_widget_add_accelerator(window->priv->menus.view.menu_item_fullscreen, "activate", accel_group, GDK_F11, 0,GTK_ACCEL_VISIBLE);
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(window->priv->menus.view.menu_item_show_toolbar), TRUE);
-
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.menu), window->priv->menus.view.menu_item_show_toolbar);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.menu), window->priv->menus.view.menu_item_show_thumbnail_viewer);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.menu), window->priv->menus.view.menu_item_separator_1);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.menu), window->priv->menus.view.menu_item_zooming);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.menu), window->priv->menus.view.menu_item_rotate);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.menu), window->priv->menus.view.menu_item_separator_2);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.menu), window->priv->menus.view.menu_item_fullscreen);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.menu), window->priv->menus.view.menu_item_set_wallpaper);
-
-/* Create 'View/Show thumbnail-bar' menu */
- window->priv->menus.view.show_thumbnail_viewer.menu = gtk_menu_new();
- gtk_menu_set_accel_group(GTK_MENU(window->priv->menus.view.show_thumbnail_viewer.menu), accel_group);
-
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(window->priv->menus.view.menu_item_show_thumbnail_viewer),
- window->priv->menus.view.show_thumbnail_viewer.menu);
- window->priv->menus.view.show_thumbnail_viewer.
- menu_item_thumbnail_viewer_horizontal = gtk_radio_menu_item_new_with_mnemonic(
- NULL,
- _("Show _Horizontally"));
- window->priv->menus.view.show_thumbnail_viewer.
- menu_item_thumbnail_viewer_vertical = gtk_radio_menu_item_new_with_mnemonic_from_widget(
- GTK_RADIO_MENU_ITEM(window->priv->menus.view.show_thumbnail_viewer.menu_item_thumbnail_viewer_horizontal),
- _("Show _Vertically"));
- window->priv->menus.view.show_thumbnail_viewer.
- menu_item_thumbnail_viewer_hide = gtk_radio_menu_item_new_with_mnemonic_from_widget(
- GTK_RADIO_MENU_ITEM(window->priv->menus.view.show_thumbnail_viewer.menu_item_thumbnail_viewer_horizontal),
- _("H_ide"));
-
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.show_thumbnail_viewer.menu),
- window->priv->menus.view.show_thumbnail_viewer.menu_item_thumbnail_viewer_horizontal);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.show_thumbnail_viewer.menu),
- window->priv->menus.view.show_thumbnail_viewer.menu_item_thumbnail_viewer_vertical);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.show_thumbnail_viewer.menu),
- window->priv->menus.view.show_thumbnail_viewer.menu_item_thumbnail_viewer_hide);
-
-/* Create 'view/zooming' menu */
- window->priv->menus.view.zooming.menu = gtk_menu_new();
- gtk_menu_set_accel_group(GTK_MENU(window->priv->menus.view.zooming.menu), accel_group);
-
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(window->priv->menus.view.menu_item_zooming),
- window->priv->menus.view.zooming.menu);
-
- window->priv->menus.view.zooming.menu_item_zoom_in = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, accel_group);
- window->priv->menus.view.zooming.menu_item_zoom_out = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, accel_group);
- window->priv->menus.view.zooming.menu_item_zoom_100 = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, accel_group);
- window->priv->menus.view.zooming.menu_item_zoom_fit = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_FIT, accel_group);
-
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.zooming.menu),
- window->priv->menus.view.zooming.menu_item_zoom_in);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.zooming.menu),
- window->priv->menus.view.zooming.menu_item_zoom_out);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.zooming.menu),
- window->priv->menus.view.zooming.menu_item_zoom_100);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.zooming.menu),
- window->priv->menus.view.zooming.menu_item_zoom_fit);
-
-/* Create 'view/rotate' menu */
- window->priv->menus.view.rotate.menu = gtk_menu_new();
- gtk_menu_set_accel_group(GTK_MENU(window->priv->menus.view.rotate.menu), accel_group);
-
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(window->priv->menus.view.menu_item_rotate),
- window->priv->menus.view.rotate.menu);
-
- window->priv->menus.view.rotate.menu_item_rotate_cw = gtk_image_menu_item_new_with_mnemonic(_("Rotate _Right"));
- window->priv->menus.view.rotate.menu_item_rotate_ccw = gtk_image_menu_item_new_with_mnemonic(_("Rotate _Left"));
-
- gtk_widget_add_accelerator(window->priv->menus.view.rotate.menu_item_rotate_cw,
- "activate",
- accel_group,
- GDK_bracketright,
- GDK_CONTROL_MASK,
- GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator(window->priv->menus.view.rotate.menu_item_rotate_ccw,
- "activate",
- accel_group,
- GDK_bracketleft,
- GDK_CONTROL_MASK,
- GTK_ACCEL_VISIBLE);
-
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.rotate.menu),
- window->priv->menus.view.rotate.menu_item_rotate_cw);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.view.rotate.menu),
- window->priv->menus.view.rotate.menu_item_rotate_ccw);
-
-/* Create 'Go' menu */
- window->priv->menus.menu_item_go= gtk_menu_item_new_with_mnemonic(_("_Go"));
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.menu), window->priv->menus.menu_item_go);
-
- window->priv->menus.go.menu = gtk_menu_new();
- gtk_menu_set_accel_group(GTK_MENU(window->priv->menus.go.menu), accel_group);
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(window->priv->menus.menu_item_go), window->priv->menus.go.menu);
-
- window->priv->menus.go.menu_item_first = gtk_image_menu_item_new_from_stock(GTK_STOCK_GOTO_FIRST, NULL);
- window->priv->menus.go.menu_item_last = gtk_image_menu_item_new_from_stock(GTK_STOCK_GOTO_LAST, NULL);
- window->priv->menus.go.menu_item_next = gtk_image_menu_item_new_from_stock(GTK_STOCK_GO_FORWARD, NULL);
- window->priv->menus.go.menu_item_previous = gtk_image_menu_item_new_from_stock(GTK_STOCK_GO_BACK, NULL);
- window->priv->menus.go.menu_item_separator_1 = gtk_separator_menu_item_new();
- window->priv->menus.go.menu_item_play = gtk_image_menu_item_new_from_stock(GTK_STOCK_MEDIA_PLAY, accel_group);
- window->priv->menus.go.menu_item_pause = gtk_image_menu_item_new_from_stock(GTK_STOCK_MEDIA_PAUSE, accel_group);
-
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.go.menu), window->priv->menus.go.menu_item_next);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.go.menu), window->priv->menus.go.menu_item_previous);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.go.menu), window->priv->menus.go.menu_item_first);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.go.menu), window->priv->menus.go.menu_item_last);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.go.menu), window->priv->menus.go.menu_item_separator_1);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.go.menu), window->priv->menus.go.menu_item_play);
-
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_first, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_last, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_next, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_previous, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_play, FALSE);
-
- gtk_widget_set_sensitive(window->priv->menus.view.menu_item_set_wallpaper, FALSE);
-
-/* Create 'Help' menu */
- window->priv->menus.menu_item_help = gtk_menu_item_new_with_mnemonic(_("_Help"));
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.menu), window->priv->menus.menu_item_help);
-
- window->priv->menus.help.menu = gtk_menu_new();
- gtk_menu_set_accel_group(GTK_MENU(window->priv->menus.help.menu), accel_group);
-
- window->priv->menus.help.menu_item_about = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, accel_group);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.help.menu), window->priv->menus.help.menu_item_about);
-
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(window->priv->menus.menu_item_help), window->priv->menus.help.menu);
-
-/* Create toolbar */
- window->priv->toolbar.bar = gtk_toolbar_new();
- window->priv->toolbar.tool_item_open = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
- window->priv->toolbar.tool_item_separator_1 = gtk_separator_tool_item_new();
- window->priv->toolbar.tool_item_next = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD);
- window->priv->toolbar.tool_item_previous = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
- window->priv->toolbar.tool_item_spacer_1= gtk_tool_item_new();
-
- gtk_tool_item_set_is_important(window->priv->toolbar.tool_item_previous, TRUE);
- gtk_tool_item_set_is_important(window->priv->toolbar.tool_item_next, TRUE);
-
- gtk_tool_item_set_expand(window->priv->toolbar.tool_item_spacer_1, TRUE);
- gtk_tool_item_set_homogeneous(window->priv->toolbar.tool_item_spacer_1, FALSE);
-
- window->priv->toolbar.tool_item_zoom_fit = gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_FIT);
- window->priv->toolbar.tool_item_zoom_100 = gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_100);
- window->priv->toolbar.tool_item_zoom_in = gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_IN);
- window->priv->toolbar.tool_item_zoom_out = gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_OUT);
-
- gtk_toolbar_insert(GTK_TOOLBAR(window->priv->toolbar.bar), window->priv->toolbar.tool_item_open, 0);
- gtk_toolbar_insert(GTK_TOOLBAR(window->priv->toolbar.bar), window->priv->toolbar.tool_item_separator_1, 1);
- gtk_toolbar_insert(GTK_TOOLBAR(window->priv->toolbar.bar), window->priv->toolbar.tool_item_previous, 2);
- gtk_toolbar_insert(GTK_TOOLBAR(window->priv->toolbar.bar), window->priv->toolbar.tool_item_next, 3);
- gtk_toolbar_insert(GTK_TOOLBAR(window->priv->toolbar.bar), window->priv->toolbar.tool_item_spacer_1, 4);
- gtk_toolbar_insert(GTK_TOOLBAR(window->priv->toolbar.bar), window->priv->toolbar.tool_item_zoom_in, 5);
- gtk_toolbar_insert(GTK_TOOLBAR(window->priv->toolbar.bar), window->priv->toolbar.tool_item_zoom_out, 6);
- gtk_toolbar_insert(GTK_TOOLBAR(window->priv->toolbar.bar), window->priv->toolbar.tool_item_zoom_fit, 7);
- gtk_toolbar_insert(GTK_TOOLBAR(window->priv->toolbar.bar), window->priv->toolbar.tool_item_zoom_100, 8);
-
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_previous), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_next), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_zoom_in), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_zoom_out), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_zoom_100), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_zoom_fit), FALSE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.zooming.menu_item_zoom_in), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.zooming.menu_item_zoom_out), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.zooming.menu_item_zoom_100), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.zooming.menu_item_zoom_fit), FALSE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.rotate.menu_item_rotate_cw), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.rotate.menu_item_rotate_ccw), FALSE);
-
-/* Create statusbar */
- window->priv->statusbar = gtk_statusbar_new();
-/* Create containers */
- window->priv->containers.main_vbox = gtk_vbox_new(FALSE, 0);
- window->priv->containers.s_window = gtk_scrolled_window_new(NULL, NULL);
- window->priv->containers.paned = gtk_vbox_new(FALSE, 0);
+ g_signal_connect(G_OBJECT(window->priv->picture_viewer), "motion-notify-event", G_CALLBACK(cb_rstto_main_window_picture_viewer_motion_notify_event), window);
+ g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(cb_rstto_main_window_configure_event), NULL);
+ g_signal_connect(G_OBJECT(window), "window-state-event", G_CALLBACK(cb_rstto_main_window_state_event), NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window->priv->containers.s_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ g_signal_connect(G_OBJECT(window->priv->settings_manager), "notify", G_CALLBACK(cb_rstto_main_window_settings_notify), window);
+}
- gtk_container_add(GTK_CONTAINER(window), window->priv->containers.main_vbox);
- gtk_box_pack_start(GTK_BOX(window->priv->containers.main_vbox), window->priv->menus.menu, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(window->priv->containers.main_vbox), window->priv->toolbar.bar, FALSE, FALSE, 0);
+static void
+rstto_main_window_class_init(RsttoMainWindowClass *window_class)
+{
+ GParamSpec *pspec;
- gtk_container_add(GTK_CONTAINER(window->priv->containers.s_window), window->priv->picture_viewer);
+ GObjectClass *object_class = (GObjectClass*)window_class;
+ parent_class = g_type_class_peek_parent(window_class);
- gtk_box_pack_start(GTK_BOX(window->priv->containers.paned), window->priv->containers.s_window, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(window->priv->containers.paned), window->priv->thumbnail_viewer, FALSE, FALSE, 0);
+ object_class->dispose = rstto_main_window_dispose;
- gtk_box_pack_start(GTK_BOX(window->priv->containers.main_vbox), window->priv->containers.paned, TRUE, TRUE, 0);
+ object_class->set_property = rstto_main_window_set_property;
+ object_class->get_property = rstto_main_window_get_property;
- gtk_box_pack_end(GTK_BOX(window->priv->containers.main_vbox), window->priv->statusbar, FALSE, FALSE, 0);
+ pspec = g_param_spec_object ("image_list",
+ "",
+ "",
+ RSTTO_TYPE_IMAGE_LIST,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
-/* Create picture viewer menu */
- window->priv->menus._picture_viewer.menu = gtk_menu_new();
- window->priv->menus._picture_viewer.menu_item_open_file = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, NULL);
- window->priv->menus._picture_viewer.menu_item_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, NULL);
+ g_object_class_install_property (object_class,
+ PROP_IMAGE_LIST,
+ pspec);
+}
- window->priv->menus._picture_viewer.menu_item_separator_1 = gtk_separator_menu_item_new();
+static void
+rstto_main_window_dispose(GObject *object)
+{
+ RsttoMainWindow *window = RSTTO_MAIN_WINDOW(object);
+ G_OBJECT_CLASS (parent_class)->dispose(object);
- window->priv->menus._picture_viewer.menu_item_open_with = gtk_menu_item_new_with_mnemonic(_("Open with..."));
+ if (window->priv->ui_manager)
+ {
+ g_object_unref (window->priv->ui_manager);
+ window->priv->ui_manager = NULL;
+ }
- window->priv->menus._picture_viewer.menu_item_separator_2 = gtk_separator_menu_item_new();
+ if (window->priv->settings_manager)
+ {
+ g_object_unref (window->priv->settings_manager);
+ window->priv->settings_manager = NULL;
+ }
+}
+/**
+ * rstto_main_window_new:
+ * @image_list:
+ *
+ * Return value:
+ */
+GtkWidget *
+rstto_main_window_new (RsttoImageList *image_list, gboolean fullscreen)
+{
+ GtkWidget *widget;
- window->priv->menus._picture_viewer.menu_item_zoom_in = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL);
- window->priv->menus._picture_viewer.menu_item_zoom_out = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);
- window->priv->menus._picture_viewer.menu_item_zoom_fit = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_FIT, NULL);
- window->priv->menus._picture_viewer.menu_item_zoom_100 = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, NULL);
+ widget = g_object_new (RSTTO_TYPE_MAIN_WINDOW, "image_list", image_list, NULL);
- window->priv->menus._picture_viewer.open_with.menu = gtk_menu_new();
- window->priv->menus._picture_viewer.open_with.menu_item_empty = gtk_menu_item_new_with_label(_("No applications available"));
+ if (fullscreen == TRUE)
+ {
+ gtk_window_fullscreen (GTK_WINDOW (widget));
+ }
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus._picture_viewer.open_with.menu),
- window->priv->menus._picture_viewer.open_with.menu_item_empty);
- gtk_widget_set_sensitive(window->priv->menus._picture_viewer.open_with.menu_item_empty, FALSE);
- gtk_widget_ref(window->priv->menus._picture_viewer.open_with.menu_item_empty);
+ return widget;
+}
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(window->priv->menus._picture_viewer.menu_item_open_with),
- window->priv->menus._picture_viewer.open_with.menu);
+static void
+cb_rstto_main_window_image_list_iter_changed (RsttoImageListIter *iter, RsttoMainWindow *window)
+{
+ rstto_main_window_image_list_iter_changed (window);
+}
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus._picture_viewer.menu), window->priv->menus._picture_viewer.menu_item_open_file);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus._picture_viewer.menu), window->priv->menus._picture_viewer.menu_item_close);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus._picture_viewer.menu), window->priv->menus._picture_viewer.menu_item_separator_1);
+/**
+ * rstto_main_window_image_list_iter_changed:
+ * @window:
+ *
+ */
+static void
+rstto_main_window_image_list_iter_changed (RsttoMainWindow *window)
+{
+ gchar *path, *basename, *title;
+ GFile *file = NULL;
+ RsttoImage *cur_image;
+ gint position, count;
+ RsttoImageList *image_list = window->priv->props.image_list;
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus._picture_viewer.menu), window->priv->menus._picture_viewer.menu_item_open_with);
+ if (window->priv->props.image_list)
+ {
+ position = rstto_image_list_iter_get_position (window->priv->iter);
+ count = rstto_image_list_get_n_images (image_list);
+ cur_image = rstto_image_list_iter_get_image (window->priv->iter);
+ if (cur_image)
+ {
+ file = rstto_image_get_file (cur_image);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus._picture_viewer.menu), window->priv->menus._picture_viewer.menu_item_separator_2);
+ path = g_file_get_path (file);
+ basename = g_path_get_basename (path);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus._picture_viewer.menu), window->priv->menus._picture_viewer.menu_item_zoom_in);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus._picture_viewer.menu), window->priv->menus._picture_viewer.menu_item_zoom_out);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus._picture_viewer.menu), window->priv->menus._picture_viewer.menu_item_zoom_fit);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus._picture_viewer.menu), window->priv->menus._picture_viewer.menu_item_zoom_100);
+ title = g_strdup_printf ("%s - %s [%d/%d]", RISTRETTO_APP_TITLE, basename, position+1, count);
+ rstto_main_window_set_sensitive (window, TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_close), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_zoom_in), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_zoom_out), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_zoom_100), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_zoom_fit), FALSE);
+ g_free (basename);
+ g_free (path);
+ }
+ else
+ {
+ title = g_strdup (RISTRETTO_APP_TITLE);
+ rstto_main_window_set_sensitive (window, FALSE);
+ }
- rstto_picture_viewer_set_menu(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer),
- GTK_MENU(window->priv->menus._picture_viewer.menu));
-/* D-Bus stuff */
+ gtk_window_set_title (GTK_WINDOW (window), title);
- window->priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
- if (window->priv->connection)
- {
- window->priv->filemanager_proxy = dbus_g_proxy_new_for_name(window->priv->connection,
- "org.xfce.FileManager",
- "/org/xfce/FileManager",
- "org.xfce.FileManager");
+ g_free (title);
}
-/* Connect signals */
-
- /* Thumbnail-viewer */
- g_signal_connect(window->priv->menus.view.show_thumbnail_viewer.menu_item_thumbnail_viewer_horizontal,
- "activate",
- G_CALLBACK(cb_rstto_main_window_thumbnail_viewer_horizontal), window);
- g_signal_connect(window->priv->menus.view.show_thumbnail_viewer.menu_item_thumbnail_viewer_vertical,
- "activate",
- G_CALLBACK(cb_rstto_main_window_thumbnail_viewer_vertical), window);
- g_signal_connect(window->priv->menus.view.show_thumbnail_viewer.menu_item_thumbnail_viewer_hide,
- "activate",
- G_CALLBACK(cb_rstto_main_window_thumbnail_viewer_hide), window);
-
- /* Toolbar show/hide */
- g_signal_connect(window->priv->menus.view.menu_item_show_toolbar,
- "activate",
- G_CALLBACK(cb_rstto_main_window_toggle_toolbar), window);
-
- /* Fullscreen */
- g_signal_connect(window->priv->menus.view.menu_item_fullscreen,
- "activate",
- G_CALLBACK(cb_rstto_main_window_toggle_fullscreen), window);
-
- /* Set Wallpaper */
-#ifdef WITH_DESKTOP_WALLPAPER
- g_signal_connect(window->priv->menus.view.menu_item_set_wallpaper,
- "activate",
- G_CALLBACK(cb_rstto_main_window_set_wallpaper), window);
-#endif
-
- /* Play / Pause */
- g_signal_connect(window->priv->menus.go.menu_item_play,
- "activate",
- G_CALLBACK(cb_rstto_main_window_play), window);
- g_signal_connect(window->priv->menus.go.menu_item_pause,
- "activate",
- G_CALLBACK(cb_rstto_main_window_pause), window);
-
- /* Window events */
- g_signal_connect(G_OBJECT(window),
- "window-state-event",
- G_CALLBACK(cb_rstto_main_window_state_event), NULL);
- g_signal_connect(G_OBJECT(window),
- "key-press-event",
- G_CALLBACK(cb_rstto_main_window_key_press_event), NULL);
-
- /* Generic menu signals */
- g_signal_connect(window->priv->menus.file.menu_item_open_file,
- "activate",
- G_CALLBACK(cb_rstto_main_window_open_file), window);
- g_signal_connect(window->priv->menus.file.menu_item_open_folder,
- "activate",
- G_CALLBACK(cb_rstto_main_window_open_folder), window);
- g_signal_connect(window->priv->menus.file.menu_item_close,
- "activate",
- G_CALLBACK(cb_rstto_main_window_close), window);
- g_signal_connect(window->priv->menus.file.menu_item_close_all,
- "activate",
- G_CALLBACK(cb_rstto_main_window_close_all), window);
- g_signal_connect(G_OBJECT(window->priv->menus.file.recently.menu),
- "item-activated",
- G_CALLBACK(cb_rstto_main_window_open_recent), window);
- g_signal_connect(window->priv->menus.file.menu_item_file_properties,
- "activate",
- G_CALLBACK(cb_rstto_main_window_file_properties), window);
- g_signal_connect(window->priv->menus.file.menu_item_quit,
- "activate",
- G_CALLBACK(cb_rstto_main_window_quit), window);
- g_signal_connect(window->priv->menus.file.recently.menu_item_clear,
- "activate",
- G_CALLBACK(cb_rstto_main_window_clear_recent), window);
- g_signal_connect(window->priv->menus.help.menu_item_about,
- "activate",
- G_CALLBACK(cb_rstto_main_window_about), window);
-
- g_signal_connect(window->priv->menus.edit.menu_item_preferences,
- "activate",
- G_CALLBACK(cb_rstto_main_window_preferences), window);
-
-/* zoom menu items */
- g_signal_connect(window->priv->menus.view.zooming.menu_item_zoom_in,
- "activate",
- G_CALLBACK(cb_rstto_main_window_zoom_in), window);
- g_signal_connect(window->priv->menus.view.zooming.menu_item_zoom_out,
- "activate",
- G_CALLBACK(cb_rstto_main_window_zoom_out), window);
- g_signal_connect(window->priv->menus.view.zooming.menu_item_zoom_100,
- "activate",
- G_CALLBACK(cb_rstto_main_window_zoom_100), window);
- g_signal_connect(window->priv->menus.view.zooming.menu_item_zoom_fit,
- "activate",
- G_CALLBACK(cb_rstto_main_window_zoom_fit), window);
-/* rotate menu items */
- g_signal_connect(window->priv->menus.view.rotate.menu_item_rotate_cw,
- "activate",
- G_CALLBACK(cb_rstto_main_window_rotate_cw), window);
- g_signal_connect(window->priv->menus.view.rotate.menu_item_rotate_ccw,
- "activate",
- G_CALLBACK(cb_rstto_main_window_rotate_ccw), window);
-
-/* go menu items */
- g_signal_connect(window->priv->menus.go.menu_item_next,
- "activate",
- G_CALLBACK(cb_rstto_main_window_next), window);
- g_signal_connect(window->priv->menus.go.menu_item_previous,
- "activate",
- G_CALLBACK(cb_rstto_main_window_previous), window);
- g_signal_connect(window->priv->menus.go.menu_item_first,
- "activate",
- G_CALLBACK(cb_rstto_main_window_first), window);
- g_signal_connect(window->priv->menus.go.menu_item_last,
- "activate",
- G_CALLBACK(cb_rstto_main_window_last), window);
-
- /* Toolbar signals */
- g_signal_connect(window->priv->toolbar.tool_item_open,
- "clicked",
- G_CALLBACK(cb_rstto_main_window_open_folder), window);
- g_signal_connect(window->priv->toolbar.tool_item_next,
- "clicked",
- G_CALLBACK(cb_rstto_main_window_next), window);
- g_signal_connect(window->priv->toolbar.tool_item_previous,
- "clicked",
- G_CALLBACK(cb_rstto_main_window_previous), window);
-
- g_signal_connect(window->priv->toolbar.tool_item_zoom_in,
- "clicked",
- G_CALLBACK(cb_rstto_main_window_zoom_in), window);
- g_signal_connect(window->priv->toolbar.tool_item_zoom_out,
- "clicked",
- G_CALLBACK(cb_rstto_main_window_zoom_out), window);
- g_signal_connect(window->priv->toolbar.tool_item_zoom_100,
- "clicked",
- G_CALLBACK(cb_rstto_main_window_zoom_100), window);
- g_signal_connect(window->priv->toolbar.tool_item_zoom_fit,
- "clicked",
- G_CALLBACK(cb_rstto_main_window_zoom_fit), window);
-
- /* Picture viewer menu */
- g_signal_connect(window->priv->menus._picture_viewer.menu_item_open_file,
- "activate",
- G_CALLBACK(cb_rstto_main_window_open_file), window);
- g_signal_connect(window->priv->menus._picture_viewer.menu_item_close,
- "activate",
- G_CALLBACK(cb_rstto_main_window_close), window);
-
- g_signal_connect(window->priv->menus._picture_viewer.menu_item_zoom_in,
- "activate",
- G_CALLBACK(cb_rstto_main_window_zoom_in), window);
- g_signal_connect(window->priv->menus._picture_viewer.menu_item_zoom_out,
- "activate",
- G_CALLBACK(cb_rstto_main_window_zoom_out), window);
- g_signal_connect(window->priv->menus._picture_viewer.menu_item_zoom_100,
- "activate",
- G_CALLBACK(cb_rstto_main_window_zoom_100), window);
- g_signal_connect(window->priv->menus._picture_viewer.menu_item_zoom_fit,
- "activate",
- G_CALLBACK(cb_rstto_main_window_zoom_fit), window);
- /* Misc */
- g_signal_connect(G_OBJECT(window->priv->navigator),
- "iter-changed",
- G_CALLBACK(cb_rstto_main_window_nav_iter_changed), window);
- g_signal_connect(G_OBJECT(window->priv->navigator),
- "new-entry",
- G_CALLBACK(cb_rstto_main_window_nav_new_entry), window);
}
-static void
-rstto_main_window_class_init(RsttoMainWindowClass *window_class)
-{
- GObjectClass *object_class = (GObjectClass*)window_class;
- parent_class = g_type_class_peek_parent(window_class);
- object_class->dispose = rstto_main_window_dispose;
-}
+/**
+ * rstto_main_window_set_sensitive:
+ * @window:
+ * @sensitive:
+ *
+ */
+static void
+rstto_main_window_set_sensitive (RsttoMainWindow *window, gboolean sensitive)
+{
+
+ gtk_widget_set_sensitive (
+ gtk_ui_manager_get_widget (
+ window->priv->ui_manager,
+ "/main-menu/file-menu/save-copy"),
+ sensitive);
+ gtk_widget_set_sensitive (
+ gtk_ui_manager_get_widget (
+ window->priv->ui_manager,
+ "/main-menu/file-menu/print"),
+ sensitive);
+ gtk_widget_set_sensitive (
+ gtk_ui_manager_get_widget (
+ window->priv->ui_manager,
+ "/main-menu/file-menu/close"),
+ sensitive);
+ gtk_widget_set_sensitive (
+ gtk_ui_manager_get_widget (
+ window->priv->ui_manager,
+ "/main-menu/file-menu/close-all"),
+ sensitive);
+
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/edit-menu/delete"), sensitive);
+
+ /* Go Menu */
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/go-menu/forward"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/go-menu/back"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/go-menu/first"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/go-menu/last"), sensitive);
+
+ gtk_action_set_sensitive (window->priv->play_action, sensitive);
+ gtk_action_set_sensitive (window->priv->pause_action, sensitive);
+
+ /* View Menu */
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager,
+ "/main-menu/view-menu/set-as-wallpaper"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager,
+ "/main-menu/view-menu/zoom-menu"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager,
+ "/main-menu/view-menu/rotation-menu"), sensitive);
+ /*
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager,
+ "/main-menu/view-menu/zoom-menu/zoom-in"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager,
+ "/main-menu/view-menu/zoom-menu/zoom-out"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager,
+ "/main-menu/view-menu/zoom-menu/zoom-fit"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager,
+ "/main-menu/view-menu/zoom-menu/zoom-100"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager,
+ "/main-menu/view-menu/rotation-menu/rotate-cw"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager,
+ "/main-menu/view-menu/rotation-menu/rotate-ccw"), sensitive);
+ */
+
+ /* Toolbar */
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-toolbar/save-copy"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-toolbar/close"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-toolbar/delete"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/navigation-toolbar/forward"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/navigation-toolbar/back"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/navigation-toolbar/zoom-in"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/navigation-toolbar/zoom-out"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/navigation-toolbar/zoom-fit"), sensitive);
+ gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/navigation-toolbar/zoom-100"), sensitive);
+
+}
+
+/**
+ * rstto_main_window_set_property:
+ * @object:
+ * @property_id:
+ * @value:
+ * @pspec:
+ *
+ */
static void
-rstto_main_window_dispose(GObject *object)
+rstto_main_window_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- RsttoMainWindow *window = RSTTO_MAIN_WINDOW(object);
- RsttoNavigator *navigator = window->priv->navigator;
- if (navigator)
+ RsttoMainWindow *window = RSTTO_MAIN_WINDOW (object);
+
+ switch (property_id)
{
-#if 0
- GList *iter, *modified_files = NULL;
-
- for (iter = navigator->file_list; iter != NULL; iter = iter->next)
- {
- if (rstto_navigator_entry_get_orientation_changed ((RsttoNavigatorEntry *)iter->data))
+ case PROP_IMAGE_LIST:
+ if (window->priv->props.image_list)
{
- modified_files = g_list_append (modified_files, iter->data);
+ g_signal_handlers_disconnect_by_func (window->priv->props.image_list, cb_rstto_main_window_image_list_new_image, window);
+ g_object_unref (window->priv->props.image_list);
+
+ g_signal_handlers_disconnect_by_func (window->priv->iter, cb_rstto_main_window_image_list_iter_changed, window);
+ g_object_unref (window->priv->iter);
+ window->priv->iter = NULL;
}
- }
- if (modified_files)
- {
- GtkWidget *dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, _("The orientation of one or more images has been modified, do you want to save the changes?"));
- if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
+ window->priv->props.image_list = g_value_get_object (value);
+
+ if (window->priv->props.image_list)
{
- gtk_widget_hide(dialog);
- GtkWidget *save_dialog = rstto_save_dialog_new (GTK_WINDOW(window), modified_files);
- if (gtk_dialog_run (GTK_DIALOG(save_dialog)) == GTK_RESPONSE_OK)
- {
-
- }
+ g_object_ref (window->priv->props.image_list);
+ g_signal_connect (G_OBJECT (window->priv->props.image_list), "new-image", G_CALLBACK (cb_rstto_main_window_image_list_new_image), window);
+
+ window->priv->iter = rstto_image_list_get_iter (window->priv->props.image_list);
+ g_signal_connect (G_OBJECT (window->priv->iter), "changed", G_CALLBACK (cb_rstto_main_window_image_list_iter_changed), window);
+ rstto_thumbnail_bar_set_image_list (RSTTO_THUMBNAIL_BAR (window->priv->thumbnail_bar), window->priv->props.image_list);
+ rstto_thumbnail_bar_set_iter (RSTTO_THUMBNAIL_BAR (window->priv->thumbnail_bar), window->priv->iter);
+ rstto_picture_viewer_set_iter (RSTTO_PICTURE_VIEWER (window->priv->picture_viewer), window->priv->iter);
}
- }
-#endif
- g_object_unref(window->priv->navigator);
- window->priv->navigator = NULL;
+ break;
+ default:
+ break;
}
- G_OBJECT_CLASS (parent_class)->dispose(object);
}
-static gboolean
-rstto_main_window_clear_recent(RsttoMainWindow *window)
+/**
+ * rstto_main_window_get_property:
+ * @object:
+ * @property_id:
+ * @value:
+ * @pspec:
+ *
+ */
+static void
+rstto_main_window_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GList *items = gtk_recent_manager_get_items(window->priv->manager);
- GList *iter = items;
- while(iter)
+ RsttoMainWindow *window = RSTTO_MAIN_WINDOW (object);
+
+ switch (property_id)
{
- if(gtk_recent_info_has_application(iter->data, "ristretto"))
- {
- gtk_recent_manager_remove_item(window->priv->manager, gtk_recent_info_get_uri(iter->data), NULL);
- }
- iter = g_list_next(iter);
+ case PROP_IMAGE_LIST:
+ g_value_set_object (value, window->priv->props.image_list);
+ break;
+ default:
+ break;
}
- return FALSE;
}
-
-GtkWidget *
-rstto_main_window_new()
+/**
+ * cb_rstto_main_window_zoom_fit:
+ * @widget:
+ * @window:
+ *
+ *
+ */
+static void
+cb_rstto_main_window_zoom_fit (GtkWidget *widget, RsttoMainWindow *window)
{
- GtkWidget *widget;
+ rstto_picture_viewer_zoom_fit (RSTTO_PICTURE_VIEWER (window->priv->picture_viewer));
+}
- widget = g_object_new(RSTTO_TYPE_MAIN_WINDOW, NULL);
+/**
+ * cb_rstto_main_window_zoom_100:
+ * @widget:
+ * @window:
+ *
+ *
+ */
+static void
+cb_rstto_main_window_zoom_100 (GtkWidget *widget, RsttoMainWindow *window)
+{
+ rstto_picture_viewer_zoom_100 (RSTTO_PICTURE_VIEWER (window->priv->picture_viewer));
+}
- return widget;
+/**
+ * cb_rstto_main_window_zoom_in:
+ * @widget:
+ * @window:
+ *
+ *
+ */
+static void
+cb_rstto_main_window_zoom_in (GtkWidget *widget, RsttoMainWindow *window)
+{
+ rstto_picture_viewer_zoom_in (RSTTO_PICTURE_VIEWER (window->priv->picture_viewer), ZOOM_FACTOR);
}
-void
-rstto_main_window_set_thumbnail_viewer_orientation(RsttoMainWindow *window, GtkOrientation orientation)
+/**
+ * cb_rstto_main_window_zoom_out:
+ * @widget:
+ * @window:
+ *
+ *
+ */
+static void
+cb_rstto_main_window_zoom_out (GtkWidget *widget, RsttoMainWindow *window)
{
- window->priv->settings.thumbnail_viewer_orientation = orientation;
+ rstto_picture_viewer_zoom_out (RSTTO_PICTURE_VIEWER (window->priv->picture_viewer), ZOOM_FACTOR);
+}
+
+/**********************/
+/* ROTATION CALLBACKS */
+/**********************/
- gtk_widget_ref(window->priv->thumbnail_viewer);
- gtk_widget_ref(window->priv->containers.s_window);
- gtk_container_remove(GTK_CONTAINER(window->priv->containers.paned), window->priv->thumbnail_viewer);
- gtk_container_remove(GTK_CONTAINER(window->priv->containers.paned), window->priv->containers.s_window);
- gtk_widget_destroy(window->priv->containers.paned);
+/**
+ * cb_rstto_main_window_rotate_cw:
+ * @widget:
+ * @window:
+ *
+ *
+ */
+static void
+cb_rstto_main_window_rotate_cw (GtkWidget *widget, RsttoMainWindow *window)
+{
+ RsttoImage *image = NULL;
- rstto_thumbnail_bar_set_orientation(RSTTO_THUMBNAIL_BAR(window->priv->thumbnail_viewer), orientation);
+ if (window->priv->iter)
+ image = rstto_image_list_iter_get_image (window->priv->iter);
- switch (orientation)
+ if (image)
{
- case GTK_ORIENTATION_HORIZONTAL:
- window->priv->containers.paned = gtk_vbox_new(FALSE, 0);
- break;
- case GTK_ORIENTATION_VERTICAL:
- window->priv->containers.paned = gtk_hbox_new(FALSE, 0);
- break;
+ switch (rstto_image_get_orientation (image))
+ {
+ default:
+ case RSTTO_IMAGE_ORIENT_NONE:
+ rstto_image_set_orientation (image, RSTTO_IMAGE_ORIENT_90);
+ break;
+ case RSTTO_IMAGE_ORIENT_90:
+ rstto_image_set_orientation (image, RSTTO_IMAGE_ORIENT_180);
+ break;
+ case RSTTO_IMAGE_ORIENT_180:
+ rstto_image_set_orientation (image, RSTTO_IMAGE_ORIENT_270);
+ break;
+ case RSTTO_IMAGE_ORIENT_270:
+ rstto_image_set_orientation (image, RSTTO_IMAGE_ORIENT_NONE);
+ break;
+ }
}
-
- gtk_box_pack_start(GTK_BOX(window->priv->containers.paned), window->priv->containers.s_window, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(window->priv->containers.paned), window->priv->thumbnail_viewer, FALSE, FALSE, 0);
-
- gtk_box_pack_start(GTK_BOX(window->priv->containers.main_vbox), window->priv->containers.paned, TRUE, TRUE, 0);
- gtk_box_reorder_child(GTK_BOX(window->priv->containers.main_vbox), window->priv->containers.paned, -2);
- gtk_widget_show(window->priv->containers.paned);
-
}
-void
-rstto_main_window_set_show_thumbnail_viewer(RsttoMainWindow *window, gboolean visibility)
+/**
+ * cb_rstto_main_window_rotate_ccw:
+ * @widget:
+ * @window:
+ *
+ *
+ */
+static void
+cb_rstto_main_window_rotate_ccw (GtkWidget *widget, RsttoMainWindow *window)
{
- window->priv->settings.thumbnail_viewer_visibility = visibility;
- if (visibility == TRUE)
+ RsttoImage *image = NULL;
+
+ if (window->priv->iter)
+ image = rstto_image_list_iter_get_image (window->priv->iter);
+
+ if (image)
{
- switch(rstto_thumbnail_bar_get_orientation(RSTTO_THUMBNAIL_BAR(window->priv->thumbnail_viewer)))
+ switch (rstto_image_get_orientation (image))
{
- case GTK_ORIENTATION_HORIZONTAL:
- gtk_check_menu_item_set_active(
- GTK_CHECK_MENU_ITEM(window->priv->menus.view.show_thumbnail_viewer.menu_item_thumbnail_viewer_horizontal),
- TRUE);
+ default:
+ case RSTTO_IMAGE_ORIENT_NONE:
+ rstto_image_set_orientation (image, RSTTO_IMAGE_ORIENT_270);
+ break;
+ case RSTTO_IMAGE_ORIENT_90:
+ rstto_image_set_orientation (image, RSTTO_IMAGE_ORIENT_NONE);
+ break;
+ case RSTTO_IMAGE_ORIENT_180:
+ rstto_image_set_orientation (image, RSTTO_IMAGE_ORIENT_90);
break;
- case GTK_ORIENTATION_VERTICAL:
- gtk_check_menu_item_set_active(
- GTK_CHECK_MENU_ITEM(window->priv->menus.view.show_thumbnail_viewer.menu_item_thumbnail_viewer_vertical),
- TRUE);
+ case RSTTO_IMAGE_ORIENT_270:
+ rstto_image_set_orientation (image, RSTTO_IMAGE_ORIENT_180);
break;
}
-
}
- else
- {
- gtk_check_menu_item_set_active(
- GTK_CHECK_MENU_ITEM(window->priv->menus.view.show_thumbnail_viewer.menu_item_thumbnail_viewer_hide),
- TRUE);
- }
-}
-
-void
-rstto_main_window_set_show_toolbar (RsttoMainWindow *window, gboolean visibility)
-{
- window->priv->settings.toolbar_visibility = visibility;
- gtk_check_menu_item_set_active(
- GTK_CHECK_MENU_ITEM(window->priv->menus.view.menu_item_show_toolbar),
- visibility);
}
-gboolean
-rstto_main_window_get_show_toolbar (RsttoMainWindow *window)
-{
- return window->priv->settings.toolbar_visibility;
-}
-gboolean
-rstto_main_window_get_show_thumbnail_viewer (RsttoMainWindow *window)
-{
- return window->priv->settings.thumbnail_viewer_visibility;
-}
+/************************/
+/* NAVIGATION CALLBACKS */
+/************************/
-GtkOrientation
-rstto_main_window_get_thumbnail_viewer_orientation (RsttoMainWindow *window)
+/**
+ * cb_rstto_main_window_first_image:
+ * @widget:
+ * @window:
+ *
+ * Move the iter to the first image;
+ *
+ */
+static void
+cb_rstto_main_window_first_image (GtkWidget *widget, RsttoMainWindow *window)
{
- return window->priv->settings.thumbnail_viewer_orientation;
+ rstto_image_list_iter_set_position (window->priv->iter, 0);
}
-RsttoNavigator *
-rstto_main_window_get_navigator (RsttoMainWindow *window)
-{
- return window->priv->navigator;
-}
-GtkRecentManager *
-rstto_main_window_get_recent_manager (RsttoMainWindow *window)
+/**
+ * cb_rstto_main_window_last_image:
+ * @widget:
+ * @window:
+ *
+ * Move the iter to the last image;
+ *
+ */
+static void
+cb_rstto_main_window_last_image (GtkWidget *widget, RsttoMainWindow *window)
{
- return window->priv->manager;
+ guint n_images = rstto_image_list_get_n_images (window->priv->props.image_list);
+ rstto_image_list_iter_set_position (window->priv->iter, n_images-1);
}
-gdouble
-rstto_main_window_get_slideshow_timeout (RsttoMainWindow *window)
+/**
+ * cb_rstto_main_window_next_image:
+ * @widget:
+ * @window:
+ *
+ * Move the iter to the next image;
+ *
+ */
+static void
+cb_rstto_main_window_next_image (GtkWidget *widget, RsttoMainWindow *window)
{
- return window->priv->settings.slideshow_timeout;
+ rstto_image_list_iter_next (window->priv->iter);
}
-gboolean
-rstto_main_window_get_hide_thumbnail (RsttoMainWindow *window)
+/**
+ * cb_rstto_main_window_previous_image:
+ * @widget:
+ * @window:
+ *
+ * Move the iter to the previous image;
+ *
+ */
+static void
+cb_rstto_main_window_previous_image (GtkWidget *widget, RsttoMainWindow *window)
{
- return window->priv->settings.slideshow_hide_thumbnail;
+ rstto_image_list_iter_previous (window->priv->iter);
}
-gint
-rstto_main_window_get_max_cache_size (RsttoMainWindow *window)
+/**
+ * cb_rstto_main_window_open_image:
+ * @widget:
+ * @window:
+ *
+ *
+ */
+static void
+cb_rstto_main_window_open_image (GtkWidget *widget, RsttoMainWindow *window)
{
- return window->priv->settings.max_cache_size;
-}
+ GtkWidget *dialog, *err_dialog;
+ gint response;
+ GFile *file;
+ GSList *files = NULL, *_files_iter;
+ GValue current_uri_val = {0, };
+ gchar *uri = NULL;
+ gint pos = 0;
+ GtkFileFilter *filter;
-void
-rstto_main_window_set_slideshow_timeout (RsttoMainWindow *window, gdouble timeout)
-{
- window->priv->settings.slideshow_timeout = timeout;
- rstto_navigator_set_timeout(window->priv->navigator, timeout);
-}
+ g_value_init (¤t_uri_val, G_TYPE_STRING);
+ g_object_get_property (G_OBJECT(window->priv->settings_manager), "current-uri", ¤t_uri_val);
-void
-rstto_main_window_set_hide_thumbnail (RsttoMainWindow *window, gboolean hide)
-{
- window->priv->settings.slideshow_hide_thumbnail = hide;
-}
+ filter = gtk_file_filter_new();
-void
-rstto_main_window_set_start_fullscreen (RsttoMainWindow *window, gboolean fullscreen)
-{
- window->priv->settings.start_fullscreen = fullscreen;
-}
+ dialog = gtk_file_chooser_dialog_new(_("Open image"),
+ GTK_WINDOW(window),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL);
-void
-rstto_main_window_set_start_slideshow (RsttoMainWindow *window, gboolean slideshow)
-{
- window->priv->settings.start_slideshow = slideshow;
-}
+ gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
+ if (g_value_get_string (¤t_uri_val))
+ gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog), g_value_get_string (¤t_uri_val));
-void
-rstto_main_window_force_fullscreen (RsttoMainWindow *window)
-{
- if(gdk_window_get_state(GTK_WIDGET(window)->window) | GDK_WINDOW_STATE_FULLSCREEN)
- gtk_window_fullscreen(GTK_WINDOW(window));
-}
+ gtk_file_filter_add_pixbuf_formats (filter);
+ gtk_file_filter_set_name (filter, _("Images"));
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
-void
-rstto_main_window_force_slideshow (RsttoMainWindow *window)
-{
- gtk_widget_activate(window->priv->menus.go.menu_item_play);
-}
+ filter = gtk_file_filter_new();
+ gtk_file_filter_add_mime_type (filter, "image/jpeg");
+ gtk_file_filter_set_name (filter, _(".jp(e)g"));
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
-void
-rstto_main_window_set_max_cache_size (RsttoMainWindow *window, gint max_cache_size)
-{
- window->priv->settings.max_cache_size = max_cache_size;
- rstto_navigator_set_max_history_size(window->priv->navigator, (guint64)max_cache_size * 1000000);
-}
-void
-rstto_main_window_set_scale_to_100 (RsttoMainWindow *window, gboolean scale_to_100)
-{
- window->priv->settings.scale_to_100 = scale_to_100;
-}
+ response = gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_hide (dialog);
+ if(response == GTK_RESPONSE_OK)
+ {
+ files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (dialog));
+ _files_iter = files;
+ pos = rstto_image_list_iter_get_position (window->priv->iter);
+ if (g_slist_length (files) > 1)
+ {
+ while (_files_iter)
+ {
+ file = _files_iter->data;
+ if (rstto_image_list_add_file (window->priv->props.image_list, file, NULL) == FALSE)
+ {
+ err_dialog = gtk_message_dialog_new(GTK_WINDOW(window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Could not open file"));
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ }
+ else
+ {
+ uri = g_file_get_uri (_files_iter->data);
+ gtk_recent_manager_add_item (window->priv->recent_manager, uri);
+ g_free (uri);
+ uri = NULL;
+ }
+ _files_iter = g_slist_next (_files_iter);
+ }
+ }
+ else
+ {
-gboolean
-rstto_main_window_get_scale_to_100 (RsttoMainWindow *window)
-{
- return window->priv->settings.scale_to_100;
-}
+ if (rstto_image_list_add_file (window->priv->props.image_list, files->data, NULL) == FALSE)
+ {
+ err_dialog = gtk_message_dialog_new(GTK_WINDOW(window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Could not open file"));
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ }
+ else
+ {
+ gtk_widget_show (window->priv->message_bar);
+ gtk_widget_show (window->priv->message_bar_label);
+ gtk_widget_show (window->priv->message_bar_button_cancel);
+ gtk_widget_show (window->priv->message_bar_button_open);
-/* CALLBACK FUNCTIONS */
+ if (window->priv->message_bar_file)
+ {
+ g_object_unref (window->priv->message_bar_file);
+ window->priv->message_bar_file = NULL;
+ }
+ window->priv->message_bar_file = g_file_get_parent (files->data);
+ }
+ }
-static void
-cb_rstto_main_window_thumbnail_viewer_horizontal(GtkWidget *widget, RsttoMainWindow *window)
-{
- window->priv->settings.thumbnail_viewer_visibility = TRUE;
- gtk_widget_show(window->priv->thumbnail_viewer);
- rstto_main_window_set_thumbnail_viewer_orientation(window, GTK_ORIENTATION_HORIZONTAL);
-}
+ if (pos == -1)
+ rstto_image_list_iter_set_position (window->priv->iter, 0);
+ g_value_set_string (¤t_uri_val, gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (dialog)));
+ g_object_set_property (G_OBJECT(window->priv->settings_manager), "current-uri", ¤t_uri_val);
-static void
-cb_rstto_main_window_thumbnail_viewer_vertical(GtkWidget *widget, RsttoMainWindow *window)
-{
- window->priv->settings.thumbnail_viewer_visibility = TRUE;
- gtk_widget_show(window->priv->thumbnail_viewer);
- rstto_main_window_set_thumbnail_viewer_orientation(window, GTK_ORIENTATION_VERTICAL);
-}
+ }
-static void
-cb_rstto_main_window_thumbnail_viewer_hide(GtkWidget *widget, RsttoMainWindow *window)
-{
- window->priv->settings.thumbnail_viewer_visibility = FALSE;
- gtk_widget_hide(window->priv->thumbnail_viewer);
-}
+ gtk_widget_destroy(dialog);
-static void
-cb_rstto_main_window_toggle_fullscreen(GtkWidget *widget, RsttoMainWindow *window)
-{
- if(gdk_window_get_state(GTK_WIDGET(window)->window) & GDK_WINDOW_STATE_FULLSCREEN)
+ if (files)
{
- gtk_window_unfullscreen(GTK_WINDOW(window));
- }
- else
- {
- gtk_window_fullscreen(GTK_WINDOW(window));
+ g_slist_foreach (files, (GFunc)g_object_unref, NULL);
+ g_slist_free (files);
}
}
+/**
+ * cb_rstto_main_window_open_folder:
+ * @widget:
+ * @window:
+ *
+ *
+ */
static void
-cb_rstto_main_window_toggle_toolbar(GtkWidget *widget, RsttoMainWindow *window)
+cb_rstto_main_window_open_folder (GtkWidget *widget, RsttoMainWindow *window)
{
- gboolean active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM(widget));
+ gint response;
+ GFile *file = NULL, *child_file = NULL;
+ GFileEnumerator *file_enumarator = NULL;
+ GFileInfo *file_info = NULL;
+ const gchar *filename = NULL;
+ const gchar *content_type = NULL;
+ gchar *uri = NULL;
+ GValue current_uri_val = {0, };
+ gint pos = 0;
+ GtkWidget *dialog;
- window->priv->settings.toolbar_visibility = active;
+ g_value_init (¤t_uri_val, G_TYPE_STRING);
+ g_object_get_property (G_OBJECT(window->priv->settings_manager), "current-uri", ¤t_uri_val);
- if (active == TRUE)
- {
- gtk_widget_show(window->priv->toolbar.bar);
- }
- else
- {
- gtk_widget_hide(window->priv->toolbar.bar);
- }
-}
+ dialog = gtk_file_chooser_dialog_new(_("Open folder"),
+ GTK_WINDOW(window),
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL);
-#ifdef WITH_DESKTOP_WALLPAPER
-static void
-cb_rstto_main_window_set_wallpaper(GtkWidget *widget, RsttoMainWindow *window)
-{
- RsttoNavigatorEntry *entry = rstto_navigator_get_file(window->priv->navigator);
- ThunarVfsInfo *info = rstto_navigator_entry_get_info(entry);
- gchar *path = thunar_vfs_path_dup_string(info->path);
+ if (g_value_get_string (¤t_uri_val))
+ gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog), g_value_get_string (¤t_uri_val));
- GdkScreen *gdk_screen = gdk_screen_get_default();
- gint screen = gdk_screen_get_number(gdk_screen);
- gint monitor = gdk_screen_get_monitor_at_window(gdk_screen, GTK_WIDGET(window)->window);
+ response = gtk_dialog_run(GTK_DIALOG(dialog));
+ if(response == GTK_RESPONSE_OK)
+ {
+ gtk_widget_hide(dialog);
+ file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
- gchar *image_path_prop = NULL;
- gchar *image_show_prop = NULL;
- gchar *image_style_prop = NULL;
- gchar *command = NULL;
+ file_enumarator = g_file_enumerate_children (file, "standard::*", 0, NULL, NULL);
+ pos = rstto_image_list_iter_get_position (window->priv->iter);
+ for(file_info = g_file_enumerator_next_file (file_enumarator, NULL, NULL); file_info != NULL; file_info = g_file_enumerator_next_file (file_enumarator, NULL, NULL))
+ {
+ filename = g_file_info_get_name (file_info);
+ content_type = g_file_info_get_content_type (file_info);
+ child_file = g_file_get_child (file, filename);
- switch (window->priv->settings.desktop)
- {
- case RSTTO_DESKTOP_XFCE:
+ if (strncmp (content_type, "image/", 6) == 0)
{
+ rstto_image_list_add_file (window->priv->props.image_list, child_file, NULL);
+ }
- /*
- * Retrieve the screen and monitor number where the main ristretto window is running,
- * set the wallpaper there.
- */
- image_path_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-path", screen, monitor);
- image_show_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-show", screen, monitor);
- image_style_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-style", screen, monitor);
-
- command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t string -s %s", image_path_prop, path);
- g_spawn_command_line_async (command, NULL);
- g_free (command);
+ g_object_unref (child_file);
+ g_object_unref (file_info);
+ }
- command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t bool -s true", image_show_prop);
- g_spawn_command_line_async (command, NULL);
- g_free (command);
+ if (pos == -1)
+ rstto_image_list_iter_set_position (window->priv->iter, 0);
- command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t int -s 4", image_style_prop);
- g_spawn_command_line_async (command, NULL);
- g_free (command);
+ uri = g_file_get_uri (file);
+ gtk_recent_manager_add_item (window->priv->recent_manager, uri);
+ g_free (uri);
+ uri = NULL;
- }
- break;
- default:
- g_debug("not supported");
- break;
+ g_value_set_string (¤t_uri_val, gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (dialog)));
+ g_object_set_property (G_OBJECT(window->priv->settings_manager), "current-uri", ¤t_uri_val);
}
- if (image_path_prop)
- g_free(image_path_prop);
- if (image_show_prop)
- g_free(image_show_prop);
- if (image_style_prop)
- g_free(image_style_prop);
- if (path)
- g_free(path);
-}
-#endif
-static gboolean
-cb_rstto_main_window_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
-{
- GtkWindow *window = GTK_WINDOW(widget);
- RsttoMainWindow *rstto_window = RSTTO_MAIN_WINDOW(widget);
- if(gtk_window_activate_key(window, event) == FALSE)
+ gtk_widget_destroy(dialog);
+
+ if (file)
{
- switch(event->keyval)
- {
- case GDK_F5:
- if (rstto_navigator_is_running(RSTTO_NAVIGATOR(rstto_window->priv->navigator)))
- {
- cb_rstto_main_window_pause(rstto_window->priv->menus.go.menu_item_pause, rstto_window);
- }
- else
- {
- cb_rstto_main_window_play(rstto_window->priv->menus.go.menu_item_play, rstto_window);
- }
- break;
- case GDK_F11:
- if(gdk_window_get_state(widget->window) & GDK_WINDOW_STATE_FULLSCREEN)
- {
- gtk_window_unfullscreen(window);
- }
- else
- {
- gtk_window_fullscreen(window);
- }
- break;
- case GDK_Escape:
- if(gdk_window_get_state(widget->window) & GDK_WINDOW_STATE_FULLSCREEN)
- {
- gtk_window_unfullscreen(window);
- }
- break;
- case GDK_Home:
- rstto_navigator_jump_first(rstto_window->priv->navigator);
- break;
- case GDK_End:
- rstto_navigator_jump_last(rstto_window->priv->navigator);
- break;
- case GDK_Page_Down:
- case GDK_space:
- rstto_navigator_jump_forward(rstto_window->priv->navigator);
- break;
- case GDK_Page_Up:
- case GDK_BackSpace:
- rstto_navigator_jump_back(rstto_window->priv->navigator);
- break;
- case GDK_t:
- rstto_main_window_set_show_thumbnail_viewer(RSTTO_MAIN_WINDOW(window),
- !(RSTTO_MAIN_WINDOW(window)->priv->settings.thumbnail_viewer_visibility));
- break;
- case GDK_bracketleft:
- cb_rstto_main_window_rotate_ccw(NULL, RSTTO_MAIN_WINDOW(window));
- break;
- case GDK_bracketright:
- cb_rstto_main_window_rotate_cw(NULL, RSTTO_MAIN_WINDOW(window));
- break;
- }
+ g_object_unref (file);
}
- return TRUE;
}
+/**
+ * cb_rstto_main_window_open_recent:
+ * @chooser:
+ * @window:
+ *
+ */
static void
-cb_rstto_main_window_state_event(GtkWidget *widget, GdkEventWindowState *event, gpointer user_data)
+cb_rstto_main_window_open_recent(GtkRecentChooser *chooser, RsttoMainWindow *window)
{
- RsttoMainWindow *window = RSTTO_MAIN_WINDOW(widget);
- if(event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
+ GtkWidget *err_dialog;
+ gchar *uri = gtk_recent_chooser_get_current_uri (chooser);
+ const gchar *filename;
+ const gchar *content_type = NULL;
+ GError *error = NULL;
+ GFile *file = g_file_new_for_uri (uri);
+ GFile *child_file;
+ GFileEnumerator *file_enumarator = NULL;
+ GFileInfo *child_file_info = NULL;
+ GFileInfo *file_info = g_file_query_info (file, "standard::type", 0, NULL, &error);
+
+ if (error == NULL)
{
- if(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
+ if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY)
{
- gtk_widget_hide(window->priv->menus.menu);
- gtk_widget_hide(window->priv->toolbar.bar);
- gtk_widget_hide(window->priv->statusbar);
- GdkColor *color = g_new0(GdkColor, 1);
+ file_enumarator = g_file_enumerate_children (file, "standard::*", 0, NULL, NULL);
+ for(child_file_info = g_file_enumerator_next_file (file_enumarator, NULL, NULL); child_file_info != NULL; child_file_info = g_file_enumerator_next_file (file_enumarator, NULL, NULL))
+ {
+ filename = g_file_info_get_name (child_file_info);
+ content_type = g_file_info_get_content_type (child_file_info);
+ child_file = g_file_get_child (file, filename);
- rstto_picture_viewer_set_bg_color(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), color);
+ if (strncmp (content_type, "image/", 6) == 0)
+ {
+ rstto_image_list_add_file (window->priv->props.image_list, child_file, NULL);
+ }
+
+ g_object_unref (child_file);
+ g_object_unref (child_file_info);
+ }
- g_free(color);
}
else
{
- gtk_widget_show(window->priv->menus.menu);
- gtk_widget_show(window->priv->statusbar);
- rstto_picture_viewer_set_bg_color(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), window->priv->settings.bg_color);
-
- if (window->priv->settings.toolbar_visibility == TRUE)
+ if (rstto_image_list_add_file (window->priv->props.image_list, file, NULL) == FALSE)
+ {
+ err_dialog = gtk_message_dialog_new(GTK_WINDOW(window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Could not open file"));
+ gtk_dialog_run( GTK_DIALOG(err_dialog));
+ gtk_widget_destroy(err_dialog);
+ }
+ else
{
- gtk_widget_show(window->priv->toolbar.bar);
+ gtk_widget_show (window->priv->message_bar);
+ gtk_widget_show (window->priv->message_bar_label);
+ gtk_widget_show (window->priv->message_bar_button_cancel);
+ gtk_widget_show (window->priv->message_bar_button_open);
+
+ if (window->priv->message_bar_file)
+ {
+ g_object_unref (window->priv->message_bar_file);
+ window->priv->message_bar_file = NULL;
+ }
+ window->priv->message_bar_file = g_file_get_parent (file);
}
}
}
- if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED)
+ else
{
- RsttoNavigatorEntry *entry = rstto_navigator_get_file(window->priv->navigator);
-
- if (window->priv->settings.scale_to_100 == TRUE)
- {
- rstto_picture_viewer_set_zoom_mode(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), RSTTO_ZOOM_MODE_CUSTOM);
- rstto_navigator_entry_set_scale(entry, 0);
- }
-
+ err_dialog = gtk_message_dialog_new(GTK_WINDOW(window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Could not open file"));
+ gtk_dialog_run (GTK_DIALOG (err_dialog));
+ gtk_widget_destroy (err_dialog);
}
-}
-static void
-cb_rstto_main_window_play(GtkWidget *widget, RsttoMainWindow *window)
-{
- gtk_widget_ref(widget);
- gtk_container_remove(GTK_CONTAINER(window->priv->menus.go.menu), widget);
- gtk_menu_shell_insert(GTK_MENU_SHELL(window->priv->menus.go.menu), window->priv->menus.go.menu_item_pause, 5);
- gtk_widget_show_all(window->priv->menus.go.menu_item_pause);
- rstto_navigator_set_running(RSTTO_NAVIGATOR(window->priv->navigator), TRUE);
- if (window->priv->settings.thumbnail_viewer_visibility &&
- window->priv->settings.slideshow_hide_thumbnail)
- gtk_widget_hide (window->priv->thumbnail_viewer);
+ g_object_unref (file);
+ g_free (uri);
}
static void
-cb_rstto_main_window_pause(GtkWidget *widget, RsttoMainWindow *window)
+cb_rstto_main_window_save_copy (GtkWidget *widget, RsttoMainWindow *window)
{
- gtk_widget_ref(widget);
- gtk_container_remove(GTK_CONTAINER(window->priv->menus.go.menu), widget);
- gtk_menu_shell_insert(GTK_MENU_SHELL(window->priv->menus.go.menu), window->priv->menus.go.menu_item_play, 5);
- gtk_widget_show_all(window->priv->menus.go.menu_item_play);
- rstto_navigator_set_running(RSTTO_NAVIGATOR(window->priv->navigator), FALSE);
- if (window->priv->settings.thumbnail_viewer_visibility)
- gtk_widget_show (window->priv->thumbnail_viewer);
-}
+ GtkWidget *dialog;
+ gint response;
+ GFile *file, *s_file;
-static void
-cb_rstto_main_window_preferences(GtkWidget *widget, RsttoMainWindow *window)
-{
- GdkColor *color = NULL;
- if (rstto_picture_viewer_get_bg_color(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer)))
+ dialog = gtk_file_chooser_dialog_new(_("Save copy"),
+ GTK_WINDOW(window),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_OK,
+ NULL);
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
+
+ response = gtk_dialog_run(GTK_DIALOG(dialog));
+ if(response == GTK_RESPONSE_OK)
{
- color = gdk_color_copy(rstto_main_window_get_pv_bg_color(window));
+ file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
+ s_file = rstto_image_get_file (rstto_image_list_iter_get_image (window->priv->iter));
+ if (g_file_copy (s_file, file, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL))
+ {
+ rstto_image_list_add_file (window->priv->props.image_list, file, NULL);
+ }
}
- GtkWidget *slideshow_main_vbox;
- GtkWidget *slideshow_main_lbl;
- GtkWidget *display_main_vbox;
- GtkWidget *display_main_lbl;
- GtkWidget *behaviour_main_vbox;
- GtkWidget *behaviour_main_lbl;
-
- GtkWidget *resize_to_content_vbox, *resize_to_content_frame;
- GtkWidget *resize_on_maximize_check;
-
- GtkWidget *bg_color_vbox;
- GtkWidget *bg_color_hbox;
- GtkWidget *bg_color_frame;
- GtkWidget *bg_color_button;
- GtkWidget *bg_color_override_check;
- GtkWidget *cache_vbox;
- GtkWidget *cache_frame;
- GtkWidget *cache_hbox;
- GtkObject *cache_adjustment;
- GtkWidget *cache_spin_button;
- GtkWidget *cache_label;
- GtkWidget *cache_mb_label;
-
- cache_adjustment = gtk_adjustment_new(rstto_main_window_get_max_cache_size(window), 0, 9999, 1, 100, 0);
-
- GtkWidget *dialog = xfce_titled_dialog_new_with_buttons(_("Image viewer Preferences"),
- GTK_WINDOW(window),
- GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK,
- GTK_RESPONSE_OK,
- NULL);
- gtk_window_set_icon_name(GTK_WINDOW(dialog), "ristretto");
- gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
-
- GtkWidget *notebook = gtk_notebook_new();
- gtk_container_set_border_width(GTK_CONTAINER(notebook), 6);
- gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook, TRUE, TRUE, 0);
-
-/** Add notebook pages */
- display_main_vbox = gtk_vbox_new(FALSE, 0);
- display_main_lbl = gtk_label_new(_("Display"));
- gtk_notebook_append_page(GTK_NOTEBOOK(notebook), display_main_vbox, display_main_lbl);
+ gtk_widget_destroy(dialog);
- slideshow_main_vbox = gtk_vbox_new(FALSE, 0);
- slideshow_main_lbl = gtk_label_new(_("Slideshow"));
- gtk_notebook_append_page(GTK_NOTEBOOK(notebook), slideshow_main_vbox, slideshow_main_lbl);
+}
- behaviour_main_vbox = gtk_vbox_new(FALSE, 0);
- behaviour_main_lbl = gtk_label_new(_("Behaviour"));
- gtk_notebook_append_page(GTK_NOTEBOOK(notebook), behaviour_main_vbox, behaviour_main_lbl);
+/**
+ * cb_rstto_main_window_print:
+ * @widget:
+ * @window:
+ *
+ *
+ */
+static void
+cb_rstto_main_window_print (GtkWidget *widget, RsttoMainWindow *window)
+{
-/** Add content for behaviour page */
- resize_to_content_vbox = gtk_vbox_new(FALSE, 0);
- resize_to_content_frame = xfce_create_framebox_with_content(_("Scaling"), resize_to_content_vbox);
+ GtkPrintSettings *print_settings = gtk_print_settings_new ();
+ GtkPrintOperation *print_operation = gtk_print_operation_new ();
+ GtkPageSetup *page_setup = gtk_page_setup_new ();
- resize_on_maximize_check = gtk_check_button_new_with_mnemonic(_("Don't scale over 100% when maximizing the window."));
- gtk_box_pack_start(GTK_BOX(resize_to_content_vbox), resize_on_maximize_check, FALSE, TRUE, 0);
+ gtk_print_settings_set_resolution (print_settings, 300);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resize_on_maximize_check), window->priv->settings.scale_to_100);
+ gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE);
- gtk_container_set_border_width (GTK_CONTAINER (resize_to_content_frame), 8);
- gtk_box_pack_start(GTK_BOX(behaviour_main_vbox), resize_to_content_frame, FALSE, TRUE, 0);
+ gtk_print_operation_set_default_page_setup (print_operation, page_setup);
+ gtk_print_operation_set_print_settings (print_operation, print_settings);
-/** Add content for display page */
- bg_color_vbox = gtk_vbox_new(FALSE, 0);
- bg_color_frame = xfce_create_framebox_with_content (_("Background Color"), bg_color_vbox);
+ g_object_set (print_operation,
+ "n-pages", 1,
+ NULL);
+
+ g_signal_connect (print_operation, "draw-page", G_CALLBACK (rstto_main_window_print_draw_page), window);
- bg_color_override_check = gtk_check_button_new_with_mnemonic(_("_Override Background Color:"));
- bg_color_hbox = gtk_hbox_new(FALSE, 4);
- bg_color_button = gtk_color_button_new();
+ gtk_print_operation_run (print_operation, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, GTK_WINDOW(window), NULL);
+
+}
- gtk_box_pack_start(GTK_BOX(bg_color_hbox), bg_color_override_check, FALSE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(bg_color_hbox), bg_color_button, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(bg_color_vbox), bg_color_hbox, FALSE, FALSE, 0);
+static void
+rstto_main_window_print_draw_page (GtkPrintOperation *operation,
+ GtkPrintContext *print_context,
+ gint page_nr,
+ RsttoMainWindow *window)
+{
+ RsttoImage *image = rstto_image_list_iter_get_image (window->priv->iter);
+ GdkPixbuf *pixbuf = rstto_image_get_pixbuf (image);
+ gdouble w = gdk_pixbuf_get_width (pixbuf);
+ gdouble w1 = gtk_print_context_get_width (print_context);
+ gdouble h = gdk_pixbuf_get_height (pixbuf);
+ gdouble h1 = gtk_print_context_get_height (print_context);
- g_signal_connect(G_OBJECT(bg_color_override_check), "toggled", (GCallback)cb_rstto_bg_color_override_check_toggled, bg_color_button);
+ cairo_t *context = gtk_print_context_get_cairo_context (print_context);
- if (color)
+ cairo_translate (context, 0, 0);
+ /* Scale to page-width */
+ if ((w1/w) < (h1/h))
{
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bg_color_override_check), TRUE);
- gtk_color_button_set_color(GTK_COLOR_BUTTON(bg_color_button), color);
- gdk_color_free(color);
- color = NULL;
+ cairo_scale (context, w1/w, w1/w);
}
else
{
- gtk_widget_set_sensitive(bg_color_button, FALSE);
+ cairo_scale (context, h1/h, h1/h);
}
+ //cairo_rotate (context, 90 * 3.141592/180);
+ gdk_cairo_set_source_pixbuf (context, pixbuf, 0, 0);
- cache_vbox = gtk_vbox_new(FALSE, 0);
- cache_frame = xfce_create_framebox_with_content (_("Image Cache"), cache_vbox);
- cache_hbox = gtk_hbox_new(FALSE, 4);
- cache_spin_button = gtk_spin_button_new(GTK_ADJUSTMENT(cache_adjustment), 1.0, 0);
- cache_label = gtk_label_new(_("Cache size:"));
- cache_mb_label = gtk_label_new(_("MB"));
-
- GtkWidget *preload_check = gtk_check_button_new_with_mnemonic(_("_Preload images (GUI more responsive but more CPU-intensive)"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(preload_check), window->priv->navigator->preload);
-
- gtk_box_pack_start(GTK_BOX(cache_hbox), cache_label, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(cache_hbox), cache_spin_button, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(cache_hbox), cache_mb_label, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(cache_vbox), cache_hbox, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(cache_vbox), preload_check, FALSE, FALSE, 0);
+ //cairo_rectangle (context, 0, 0, 200, 200);
- gtk_container_set_border_width (GTK_CONTAINER (bg_color_frame), 8);
- gtk_container_set_border_width (GTK_CONTAINER (cache_frame), 8);
+ cairo_paint (context);
+}
- gtk_box_pack_start(GTK_BOX(display_main_vbox), bg_color_frame, FALSE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(display_main_vbox), cache_frame, FALSE, TRUE, 0);
+/**
+ * cb_rstto_main_window_play:
+ * @widget:
+ * @window:
+ *
+ * Remove the play button from the menu, and add the pause button.
+ *
+ */
+static void
+cb_rstto_main_window_play (GtkWidget *widget, RsttoMainWindow *window)
+{
+ GValue timeout = {0, };
-/** Add content for slideshow page */
- GtkWidget *slideshow_vbox = gtk_vbox_new(FALSE, 0);
- GtkWidget *slideshow_frame = xfce_create_framebox_with_content (_("Timeout"), slideshow_vbox);
+ gtk_ui_manager_add_ui (window->priv->ui_manager,
+ window->priv->pause_merge_id,
+ "/main-menu/go-menu/placeholder-slideshow",
+ "pause",
+ "pause",
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
+ gtk_ui_manager_remove_ui (window->priv->ui_manager,
+ window->priv->play_merge_id);
- GtkWidget *thumbnails_vbox = gtk_vbox_new(FALSE, 0);
- GtkWidget *thumbnails_frame = xfce_create_framebox_with_content (_("Thumbnails"), thumbnails_vbox);
+ gtk_ui_manager_add_ui (window->priv->ui_manager,
+ window->priv->toolbar_pause_merge_id,
+ "/navigation-toolbar/placeholder-slideshow",
+ "pause",
+ "pause",
+ GTK_UI_MANAGER_TOOLITEM,
+ FALSE);
+ gtk_ui_manager_remove_ui (window->priv->ui_manager,
+ window->priv->toolbar_play_merge_id);
- gtk_container_set_border_width (GTK_CONTAINER (slideshow_frame), 8);
- gtk_container_set_border_width (GTK_CONTAINER (thumbnails_frame), 8);
- GtkWidget *slideshow_lbl = gtk_label_new(_("The time period an individual image is displayed during a slideshow\n(in seconds)"));
- GtkWidget *slideshow_hscale = gtk_hscale_new_with_range(1, 60, 1);
+ g_value_init (&timeout, G_TYPE_UINT);
+ g_object_get_property (G_OBJECT(window->priv->settings_manager), "slideshow-timeout", &timeout);
- GtkWidget *thumbnails_lbl = gtk_label_new(_("Hide the thumbnails bar during slideshow"));
- GtkWidget *thumbnails_check = gtk_check_button_new_with_mnemonic(_("_Hide thumbnails"));
+ window->priv->playing = TRUE;
+ window->priv->play_timeout_id = g_timeout_add (g_value_get_uint (&timeout), (GSourceFunc)cb_rstto_main_window_play_slideshow, window);
+}
- gtk_misc_set_alignment(GTK_MISC(slideshow_lbl), 0, 0.5);
- gtk_misc_set_alignment(GTK_MISC(thumbnails_lbl), 0, 0.5);
+/**
+ * cb_rstto_main_window_pause:
+ * @widget:
+ * @window:
+ *
+ * Remove the pause button from the menu, and add the play button.
+ *
+ */
+static void
+cb_rstto_main_window_pause (GtkWidget *widget, RsttoMainWindow *window)
+{
+ gtk_ui_manager_add_ui (window->priv->ui_manager,
+ window->priv->play_merge_id,
+ "/main-menu/go-menu/placeholder-slideshow",
+ "play",
+ "play",
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
+ gtk_ui_manager_remove_ui (window->priv->ui_manager,
+ window->priv->pause_merge_id);
+
+ gtk_ui_manager_add_ui (window->priv->ui_manager,
+ window->priv->toolbar_play_merge_id,
+ "/navigation-toolbar/placeholder-slideshow",
+ "play",
+ "play",
+ GTK_UI_MANAGER_TOOLITEM,
+ FALSE);
+ gtk_ui_manager_remove_ui (window->priv->ui_manager,
+ window->priv->toolbar_pause_merge_id);
+
+ window->priv->playing = FALSE;
+}
+
+/**
+ * cb_rstto_main_window_play_slideshow:
+ * @window:
+ *
+ */
+static gboolean
+cb_rstto_main_window_play_slideshow (RsttoMainWindow *window)
+{
+ if (window->priv->playing)
+ {
+ rstto_image_list_iter_next (window->priv->iter);
+ rstto_main_window_image_list_iter_changed (window);
+ }
+ else
+ {
+ window->priv->play_timeout_id = 0;
+ }
+ return window->priv->playing;
+}
- gtk_misc_set_padding(GTK_MISC(slideshow_lbl), 2, 2);
- gtk_misc_set_padding(GTK_MISC(thumbnails_lbl), 2, 2);
-
- gtk_range_set_value(GTK_RANGE(slideshow_hscale), window->priv->settings.slideshow_timeout / 1000);
+/**
+ * cb_rstto_main_window_fullscreen:
+ * @widget:
+ * @window:
+ *
+ * Toggle the fullscreen mode of this window.
+ *
+ */
+static void
+cb_rstto_main_window_fullscreen (GtkWidget *widget, RsttoMainWindow *window)
+{
+ if(gdk_window_get_state(GTK_WIDGET(window)->window) & GDK_WINDOW_STATE_FULLSCREEN)
+ {
+ gtk_window_unfullscreen(GTK_WINDOW(window));
+ }
+ else
+ {
+ gtk_window_fullscreen(GTK_WINDOW(window));
+ }
+}
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thumbnails_check), window->priv->settings.slideshow_hide_thumbnail);
+/**
+ * cb_rstto_main_window_preferences:
+ * @widget:
+ * @window:
+ *
+ *
+ */
+static void
+cb_rstto_main_window_preferences (GtkWidget *widget, RsttoMainWindow *window)
+{
+ GValue val1 = {0,};
+ GValue val2 = {0,};
+ GtkWidget *dialog = rstto_preferences_dialog_new (GTK_WINDOW (window));
- gtk_box_pack_start(GTK_BOX(slideshow_vbox), slideshow_lbl, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(slideshow_vbox), slideshow_hscale, FALSE, TRUE, 0);
+ g_value_init (&val1, G_TYPE_UINT);
+ g_value_init (&val2, G_TYPE_UINT);
- gtk_box_pack_start(GTK_BOX(thumbnails_vbox), thumbnails_lbl, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(thumbnails_vbox), thumbnails_check, FALSE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(slideshow_main_vbox), slideshow_frame, FALSE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(slideshow_main_vbox), thumbnails_frame, FALSE, TRUE, 0);
+ g_object_get_property (G_OBJECT (window->priv->settings_manager), "image-quality", &val1);
- gtk_widget_show_all(notebook);
+ gtk_dialog_run (GTK_DIALOG (dialog));
- gint result = gtk_dialog_run(GTK_DIALOG(dialog));
+ g_object_get_property (G_OBJECT (window->priv->settings_manager), "image-quality", &val2);
- switch (result)
+ if (g_value_get_uint (&val1) != g_value_get_uint (&val2))
{
- case GTK_RESPONSE_OK:
- rstto_main_window_set_slideshow_timeout(window, gtk_range_get_value(GTK_RANGE(slideshow_hscale)) * 1000);
- window->priv->navigator->preload = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(preload_check));
- window->priv->settings.slideshow_hide_thumbnail = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(thumbnails_check));
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(bg_color_override_check)) == TRUE)
- {
- GdkColor *new_color = g_new0(GdkColor, 1);
- gtk_color_button_get_color(GTK_COLOR_BUTTON(bg_color_button), new_color);
- rstto_main_window_set_pv_bg_color(window, new_color);
- g_free(new_color);
- }
- else
- {
- rstto_main_window_set_pv_bg_color(window, NULL);
- }
- rstto_picture_viewer_redraw(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer));
- rstto_main_window_set_max_cache_size(window, (guint)GTK_ADJUSTMENT(cache_adjustment)->value);
-
- window->priv->settings.scale_to_100 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resize_on_maximize_check));
-
- default:
- break;
+ rstto_image_cache_clear (rstto_image_cache_new());
}
- gtk_widget_destroy(dialog);
+ gtk_widget_destroy (dialog);
}
+/**
+ * cb_rstto_main_window_about:
+ * @widget:
+ * @window:
+ *
+ *
+ */
static void
-cb_rstto_main_window_about(GtkWidget *widget, RsttoMainWindow *window)
+cb_rstto_main_window_about (GtkWidget *widget, RsttoMainWindow *window)
{
const gchar *authors[] = {
_("Developer:"),
@@ -1568,7 +1545,7 @@ cb_rstto_main_window_about(GtkWidget *widget, RsttoMainWindow *window)
gtk_about_dialog_set_version((GtkAboutDialog *)about_dialog, PACKAGE_VERSION);
gtk_about_dialog_set_comments((GtkAboutDialog *)about_dialog,
- _("Ristretto is a fast and lightweight picture-viewer for the Xfce desktop environment."));
+ _("Ristretto is an imageviewer for the Xfce desktop environment."));
gtk_about_dialog_set_website((GtkAboutDialog *)about_dialog,
"http://goodies.xfce.org/projects/applications/ristretto");
gtk_about_dialog_set_logo_icon_name((GtkAboutDialog *)about_dialog,
@@ -1580,630 +1557,400 @@ cb_rstto_main_window_about(GtkWidget *widget, RsttoMainWindow *window)
gtk_about_dialog_set_license((GtkAboutDialog *)about_dialog,
xfce_get_license_text(XFCE_LICENSE_TEXT_GPL));
gtk_about_dialog_set_copyright((GtkAboutDialog *)about_dialog,
- "Copyright \302\251 2006-2008 Stephan Arts");
+ "Copyright \302\251 2006-2009 Stephan Arts");
gtk_dialog_run(GTK_DIALOG(about_dialog));
gtk_widget_destroy(about_dialog);
}
+/**
+ * cb_rstto_main_window_contents:
+ * @widget:
+ * @window:
+ *
+ *
+ */
static void
-cb_rstto_main_window_quit(GtkWidget *widget, RsttoMainWindow *window)
+cb_rstto_main_window_contents (GtkWidget *widget, RsttoMainWindow *window)
{
- gtk_widget_destroy(GTK_WIDGET(window));
+ g_debug ("%s", __FUNCTION__);
}
+
+/**
+ * cb_rstto_main_window_quit:
+ * @widget:
+ * @window:
+ *
+ *
+ */
static void
-cb_rstto_main_window_open_file(GtkWidget *widget, RsttoMainWindow *window)
+cb_rstto_main_window_quit (GtkWidget *widget, RsttoMainWindow *window)
{
- GtkStatusbar *statusbar = GTK_STATUSBAR(window->priv->statusbar);
- g_object_add_weak_pointer(G_OBJECT(window), (gpointer)statusbar);
-
- gint context_id = gtk_statusbar_get_context_id(statusbar, "StatusMessages");
- gint message_id = gtk_statusbar_push(statusbar, context_id, N_("Opening file(s)..."));
-
- GtkWidget *dialog = gtk_file_chooser_dialog_new(_("Open image"),
- GTK_WINDOW(window),
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_OK,
- NULL);
-
- gint response = gtk_dialog_run(GTK_DIALOG(dialog));
- if(response == GTK_RESPONSE_OK)
- {
- const gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
- if (!rstto_navigator_open_file(window->priv->navigator, filename, FALSE, NULL))
- {
- gtk_widget_destroy(dialog);
- dialog = gtk_message_dialog_new(GTK_WINDOW(window),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Could not open file"));
- gtk_dialog_run(GTK_DIALOG(dialog));
- }
- }
- gtk_widget_destroy(dialog);
-
- if (statusbar)
- {
- gtk_statusbar_remove(statusbar, context_id, message_id);
- g_object_remove_weak_pointer(G_OBJECT(window), (gpointer)statusbar);
- }
+ gtk_widget_destroy (GTK_WIDGET (window));
}
+/**
+ * cb_rstto_main_window_close:
+ * @widget:
+ * @window:
+ *
+ *
+ */
static void
-cb_rstto_main_window_open_folder(GtkWidget *widget, RsttoMainWindow *window)
+cb_rstto_main_window_close (GtkWidget *widget, RsttoMainWindow *window)
{
- GtkStatusbar *statusbar = GTK_STATUSBAR(window->priv->statusbar);
- g_object_add_weak_pointer(G_OBJECT(window), (gpointer)statusbar);
-
- gint context_id = gtk_statusbar_get_context_id(statusbar, "StatusMessages");
- gint message_id = gtk_statusbar_push(statusbar, context_id, N_("Opening file(s)..."));
-
- GtkWidget *dialog = gtk_file_chooser_dialog_new(_("Open folder"),
- GTK_WINDOW(window),
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_OK,
- NULL);
-
- gint response = gtk_dialog_run(GTK_DIALOG(dialog));
- if(response == GTK_RESPONSE_OK)
- {
- gtk_widget_hide(dialog);
- const gchar *dir_name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
-
- RsttoNavigator *navigator = window->priv->navigator;
- if(rstto_navigator_open_folder(navigator, dir_name, TRUE, NULL) == TRUE)
- {
- rstto_navigator_jump_first(navigator);
- }
- }
- gtk_widget_destroy(dialog);
-
- if (statusbar)
- {
- gtk_statusbar_remove(statusbar, context_id, message_id);
- g_object_remove_weak_pointer(G_OBJECT(window), (gpointer)statusbar);
- }
+ RsttoImage *image = rstto_image_list_iter_get_image (window->priv->iter);
+ rstto_image_list_remove_image (window->priv->props.image_list, image);
}
+/**
+ * cb_rstto_main_window_close_all:
+ * @widget:
+ * @window:
+ *
+ *
+ */
static void
-cb_rstto_main_window_open_recent(GtkRecentChooser *chooser, RsttoMainWindow *window)
+cb_rstto_main_window_close_all (GtkWidget *widget, RsttoMainWindow *window)
{
- GtkStatusbar *statusbar = GTK_STATUSBAR(window->priv->statusbar);
- g_object_add_weak_pointer(G_OBJECT(window), (gpointer)statusbar);
-
- gint context_id = gtk_statusbar_get_context_id(statusbar, "StatusMessages");
- gint message_id = gtk_statusbar_push(statusbar, context_id, N_("Opening file(s)..."));
+ rstto_image_list_remove_all (window->priv->props.image_list);
+ rstto_main_window_image_list_iter_changed (window);
+}
- gchar *uri = gtk_recent_chooser_get_current_uri(chooser);
- ThunarVfsPath *vfs_path = thunar_vfs_path_new(uri, NULL);
- if (vfs_path)
+/**
+ * cb_rstto_main_window_delete:
+ * @widget:
+ * @window:
+ *
+ *
+ */
+static void
+cb_rstto_main_window_delete (GtkWidget *widget, RsttoMainWindow *window)
+{
+ RsttoImage *image = rstto_image_list_iter_get_image (window->priv->iter);
+ GFile *file = rstto_image_get_file (image);
+ gchar *path = g_file_get_path (file);
+ gchar *basename = g_path_get_basename (path);
+ GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK_CANCEL,
+ N_("Are you sure you want to delete image '%s' from disk?"),
+ basename);
+ g_object_ref (image);
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
{
- gchar *path = thunar_vfs_path_dup_string(vfs_path);
- if(g_file_test(path, G_FILE_TEST_EXISTS))
+ if (g_file_trash (file, NULL, NULL) == TRUE)
{
- if(g_file_test(path, G_FILE_TEST_IS_DIR))
- {
- RsttoNavigator *navigator = window->priv->navigator;
- if(rstto_navigator_open_folder(navigator, path, TRUE, NULL) == TRUE)
- {
- rstto_navigator_jump_first(navigator);
- }
- }
- else
- {
- rstto_navigator_open_file(window->priv->navigator, path, FALSE, NULL);
- }
+ rstto_image_list_remove_image (window->priv->props.image_list, image);
+ }
+ else
+ {
+
}
- thunar_vfs_path_unref(vfs_path);
- g_free(path);
- }
-
- if (statusbar)
- {
- gtk_statusbar_remove(statusbar, context_id, message_id);
- g_object_remove_weak_pointer(G_OBJECT(window), (gpointer)statusbar);
}
+ gtk_widget_destroy (dialog);
+ g_free (basename);
+ g_free (path);
+ g_object_unref (image);
}
+/**
+ * cb_rstto_main_window_toggle_show_toolbar:
+ * @widget:
+ * @window:
+ *
+ *
+ */
static void
-cb_rstto_main_window_clear_recent(GtkWidget *widget, RsttoMainWindow *window)
+cb_rstto_main_window_toggle_show_toolbar (GtkWidget *widget, RsttoMainWindow *window)
{
- GtkWidget *dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK_CANCEL,
- _("Are you sure you want to clear ristretto's list of recently opened documents?"));
- gint result = gtk_dialog_run(GTK_DIALOG(dialog));
- if (result == GTK_RESPONSE_OK)
- {
- g_timeout_add(150, (GSourceFunc)rstto_main_window_clear_recent, window);
- }
- gtk_widget_destroy(dialog);
-
-}
+ GValue val = {0,};
+ g_value_init (&val, G_TYPE_BOOLEAN);
-static void
-cb_rstto_main_window_close(GtkWidget *widget, RsttoMainWindow *window)
-{
- RsttoNavigatorEntry *entry = rstto_navigator_get_file(window->priv->navigator);
- if (entry)
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (widget)))
{
- rstto_navigator_remove(window->priv->navigator, entry);
- rstto_navigator_entry_free(entry);
- if (rstto_navigator_get_n_files(window->priv->navigator) == 0)
- {
- gtk_widget_set_sensitive(widget, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.file.menu_item_close_all, FALSE);
- }
+ gtk_widget_show (window->priv->toolbar);
+ g_value_set_boolean (&val, TRUE);
}
else
{
- gtk_widget_set_sensitive(widget, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.file.menu_item_close_all, FALSE);
+ gtk_widget_hide (window->priv->toolbar);
+ g_value_set_boolean (&val, FALSE);
}
+ g_object_set_property (G_OBJECT (window->priv->settings_manager), "show-toolbar", &val);
}
+/**
+ * cb_rstto_main_window_image_list_new_image:
+ * @image_list:
+ * @image:
+ * @window:
+ *
+ */
static void
-cb_rstto_main_window_close_all(GtkWidget *widget, RsttoMainWindow *window)
+cb_rstto_main_window_image_list_new_image (RsttoImageList *image_list, RsttoImage *image, RsttoMainWindow *window)
{
-#if 0
- RsttoNavigator *navigator = window->priv->navigator;
+ if (rstto_image_list_iter_get_position (window->priv->iter) == -1)
+ rstto_image_list_iter_set_position (window->priv->iter, 0);
+ rstto_main_window_image_list_iter_changed (window);
+}
- if (navigator)
+static gboolean
+cb_rstto_main_window_configure_event (GtkWidget *widget, GdkEventConfigure *event)
+{
+ RsttoMainWindow *window = RSTTO_MAIN_WINDOW(widget);
+ /* shamelessly copied from thunar, written by benny */
+ /* check if we have a new dimension here */
+ if (widget->allocation.width != event->width || widget->allocation.height != event->height)
{
- GList *iter, *modified_files = NULL;
-
- for (iter = navigator->file_list; iter != NULL; iter = iter->next)
+ /* drop any previous timer source */
+ if (window->priv->window_save_geometry_timer_id > 0)
{
- if (rstto_navigator_entry_get_orientation_changed ((RsttoNavigatorEntry *)iter->data))
- {
- modified_files = g_list_append (modified_files, iter->data);
- }
+ g_source_remove (window->priv->window_save_geometry_timer_id);
}
+ window->priv->window_save_geometry_timer_id = 0;
- if (modified_files)
+ /* check if we should schedule another save timer */
+ if (GTK_WIDGET_VISIBLE (widget))
{
- GtkWidget *dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, _("The orientation of one or more images has been modified, do you want to save the changes?"));
- if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
- {
- gtk_widget_hide(dialog);
- GtkWidget *save_dialog = rstto_save_dialog_new (GTK_WINDOW(window), modified_files);
- if (gtk_dialog_run (GTK_DIALOG(save_dialog)) == GTK_RESPONSE_OK)
- {
-
- }
- }
+ /* save the geometry one second after the last configure event */
+ window->priv->window_save_geometry_timer_id = g_timeout_add (
+ 1000, rstto_window_save_geometry_timer,
+ widget);
}
}
-#endif
- rstto_navigator_clear (window->priv->navigator);
- gtk_widget_set_sensitive(widget, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.file.menu_item_close, FALSE);
+ /* let Gtk+ handle the configure event */
+ return FALSE;
}
-static void
-cb_rstto_main_window_file_properties(GtkWidget *widget, RsttoMainWindow *window)
+static gboolean
+rstto_window_save_geometry_timer (gpointer user_data)
{
- GError *error = NULL;
- RsttoNavigatorEntry *entry = rstto_navigator_get_file(window->priv->navigator);
- if (entry)
+ GtkWindow *window = GTK_WINDOW(user_data);
+ gint width = 0;
+ gint height = 0;
+ /* check if the window is still visible */
+ if (GTK_WIDGET_VISIBLE (window))
{
- ThunarVfsInfo *info = rstto_navigator_entry_get_info(entry);
- if(info)
+ /* determine the current state of the window */
+ gint state = gdk_window_get_state (GTK_WIDGET (window)->window);
+
+ /* don't save geometry for maximized or fullscreen windows */
+ if ((state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) == 0)
{
- gchar *uri = thunar_vfs_path_dup_uri(info->path);
- if(dbus_g_proxy_call(window->priv->filemanager_proxy,
- "DisplayFileProperties",
- &error,
- G_TYPE_STRING, uri,
- G_TYPE_STRING, "",
- G_TYPE_INVALID,
- G_TYPE_INVALID) == FALSE)
- {
- g_warning("%s", error->message);
- }
- g_free(uri);
+ /* determine the current width/height of the window... */
+ gtk_window_get_size (GTK_WINDOW (window), &width, &height);
+
+ /* ...and remember them as default for new windows */
+ g_object_set (G_OBJECT (RSTTO_MAIN_WINDOW(window)->priv->settings_manager),
+ "window-width", width,
+ "window-height", height,
+ NULL);
}
}
+ return FALSE;
}
static void
-cb_rstto_main_window_nav_iter_changed(RsttoNavigator *navigator, gint nr, RsttoNavigatorEntry *entry, RsttoMainWindow *window)
+cb_rstto_main_window_state_event(GtkWidget *widget, GdkEventWindowState *event, gpointer user_data)
{
- ThunarVfsInfo *info = NULL;
- const gchar *filename = NULL;
- gchar *title = NULL;
+ RsttoMainWindow *window = RSTTO_MAIN_WINDOW(widget);
+ GValue show_toolbar_val = {0,};
- if(entry)
+ if(event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
{
- info = rstto_navigator_entry_get_info(entry);
- filename = info->display_name;
- gtk_widget_set_sensitive(window->priv->menus.file.menu_item_close, TRUE);
- gtk_widget_set_sensitive(window->priv->menus.file.menu_item_close_all, TRUE);
- gtk_widget_set_sensitive(window->priv->menus.file.menu_item_file_properties, TRUE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_first, TRUE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_last, TRUE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_previous, TRUE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_next, TRUE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_play, TRUE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_pause, TRUE);
-
-#ifdef WITH_DESKTOP_WALLPAPER
- if (window->priv->settings.desktop > 0)
- {
- gtk_widget_set_sensitive(window->priv->menus.view.menu_item_set_wallpaper, TRUE);
- }
- else
- {
- gtk_widget_set_sensitive(window->priv->menus.view.menu_item_set_wallpaper, FALSE);
- }
-#endif
-
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_next), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_previous), TRUE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_zoom_in), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_zoom_out), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_zoom_fit), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_zoom_100), TRUE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_close), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_zoom_in), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_zoom_out), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_zoom_100), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_zoom_fit), TRUE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.zooming.menu_item_zoom_in), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.zooming.menu_item_zoom_out), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.zooming.menu_item_zoom_100), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.zooming.menu_item_zoom_fit), TRUE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.rotate.menu_item_rotate_cw), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.rotate.menu_item_rotate_ccw), TRUE);
-
-
- /* Update window title */
- if (rstto_navigator_get_n_files(navigator) > 1)
- {
- title = g_strdup_printf("%s - %s [%d/%d]", PACKAGE_NAME, filename, nr+1, rstto_navigator_get_n_files(navigator));
- }
- else
- {
- title = g_strconcat(PACKAGE_NAME, " - ", filename, NULL);
- }
- gtk_window_set_title(GTK_WINDOW(window), title);
- g_free(title);
- title = NULL;
-
- /* Update 'open with...' submenu */
- if(gtk_widget_get_parent(window->priv->menus.edit.open_with.menu_item_empty))
- {
- gtk_container_remove(GTK_CONTAINER(window->priv->menus.edit.open_with.menu),
- window->priv->menus.edit.open_with.menu_item_empty);
- }
- if(gtk_widget_get_parent(window->priv->menus._picture_viewer.open_with.menu_item_empty))
- {
- gtk_container_remove(GTK_CONTAINER(window->priv->menus._picture_viewer.open_with.menu),
- window->priv->menus._picture_viewer.open_with.menu_item_empty);
- }
-
- gtk_container_foreach(GTK_CONTAINER(window->priv->menus.edit.open_with.menu), (GtkCallback)gtk_widget_destroy, NULL);
- gtk_container_foreach(GTK_CONTAINER(window->priv->menus._picture_viewer.open_with.menu), (GtkCallback)gtk_widget_destroy, NULL);
-
- if (info)
+ if(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
{
- window->priv->menu_apps_list = thunar_vfs_mime_database_get_applications(window->priv->mime_dbase, info->mime_info);
- GList *iter = window->priv->menu_apps_list;
- if (iter == NULL)
+ gtk_widget_hide (window->priv->menubar);
+ gtk_widget_hide (window->priv->toolbar);
+ gtk_widget_hide (window->priv->statusbar);
+ if (window->priv->fs_toolbar_sticky)
{
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.edit.open_with.menu), window->priv->menus.edit.open_with.menu_item_empty);
- gtk_widget_show(window->priv->menus.edit.open_with.menu_item_empty);
-
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus._picture_viewer.open_with.menu),
- window->priv->menus._picture_viewer.open_with.menu_item_empty);
- gtk_widget_show(window->priv->menus._picture_viewer.open_with.menu_item_empty);
+ if (window->priv->show_fs_toolbar_timeout_id > 0)
+ {
+ g_source_remove (window->priv->show_fs_toolbar_timeout_id);
+ window->priv->show_fs_toolbar_timeout_id = 0;
+ }
+ window->priv->show_fs_toolbar_timeout_id = g_timeout_add (3000, (GSourceFunc)cb_rstto_main_window_show_fs_toolbar_timeout, window);
}
- while (iter != NULL)
+ else
{
- GtkWidget *menu_item = gtk_image_menu_item_new_with_label(thunar_vfs_mime_application_get_name(iter->data));
- GtkWidget *image = gtk_image_new_from_icon_name(thunar_vfs_mime_handler_lookup_icon_name(iter->data, window->priv->icon_theme), GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), image);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.edit.open_with.menu), menu_item);
- g_object_set_data(iter->data, "entry", entry);
- g_signal_connect(menu_item, "activate", G_CALLBACK(cb_rstto_main_window_spawn_app), iter->data);
- gtk_widget_show(menu_item);
-
- menu_item = gtk_image_menu_item_new_with_label(thunar_vfs_mime_application_get_name(iter->data));
- image = gtk_image_new_from_icon_name(thunar_vfs_mime_handler_lookup_icon_name(iter->data, window->priv->icon_theme), GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), image);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus._picture_viewer.open_with.menu), menu_item);
- g_object_set_data(iter->data, "entry", entry);
- g_signal_connect(menu_item, "activate", G_CALLBACK(cb_rstto_main_window_spawn_app), iter->data);
- gtk_widget_show(menu_item);
-
- iter = g_list_next(iter);
+ gtk_widget_hide (window->priv->image_list_toolbar);
}
- }
- else
- {
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.edit.open_with.menu), window->priv->menus.edit.open_with.menu_item_empty);
- gtk_widget_show(window->priv->menus.edit.open_with.menu_item_empty);
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus._picture_viewer.open_with.menu),
- window->priv->menus._picture_viewer.open_with.menu_item_empty);
- gtk_widget_show(window->priv->menus._picture_viewer.open_with.menu_item_empty);
+ rstto_picture_viewer_zoom_fit (RSTTO_PICTURE_VIEWER (window->priv->picture_viewer));
+
+ gtk_ui_manager_add_ui (window->priv->ui_manager,
+ window->priv->toolbar_unfullscreen_merge_id,
+ "/navigation-toolbar/placeholder-fullscreen",
+ "unfullscreen",
+ "unfullscreen",
+ GTK_UI_MANAGER_TOOLITEM,
+ FALSE);
+ gtk_ui_manager_remove_ui (window->priv->ui_manager,
+ window->priv->toolbar_fullscreen_merge_id);
}
- }
- else
- {
- gtk_widget_set_sensitive(window->priv->menus.file.menu_item_close, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.file.menu_item_close_all, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.view.menu_item_set_wallpaper, FALSE);
- gtk_window_set_title(GTK_WINDOW(window), PACKAGE_STRING);
- if (rstto_navigator_get_n_files(window->priv->navigator) == 0)
+ else
{
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_first, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_last, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_previous, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_next, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_play, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.go.menu_item_pause, FALSE);
- gtk_widget_set_sensitive(window->priv->menus.file.menu_item_file_properties, FALSE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_next), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_previous), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_zoom_in), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_zoom_out), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_zoom_fit), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->toolbar.tool_item_zoom_100), FALSE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_close), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_zoom_in), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_zoom_out), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_zoom_100), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus._picture_viewer.menu_item_zoom_fit), FALSE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.zooming.menu_item_zoom_in), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.zooming.menu_item_zoom_out), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.zooming.menu_item_zoom_100), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.zooming.menu_item_zoom_fit), FALSE);
-
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.rotate.menu_item_rotate_cw), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(window->priv->menus.view.rotate.menu_item_rotate_ccw), FALSE);
- }
+ gtk_ui_manager_add_ui (window->priv->ui_manager,
+ window->priv->toolbar_fullscreen_merge_id,
+ "/navigation-toolbar/placeholder-fullscreen",
+ "fullscreen",
+ "fullscreen",
+ GTK_UI_MANAGER_TOOLITEM,
+ FALSE);
+ gtk_ui_manager_remove_ui (window->priv->ui_manager,
+ window->priv->toolbar_unfullscreen_merge_id);
+ if (window->priv->show_fs_toolbar_timeout_id > 0)
+ {
+ g_source_remove (window->priv->show_fs_toolbar_timeout_id);
+ window->priv->show_fs_toolbar_timeout_id = 0;
+ }
+ gtk_widget_show (window->priv->image_list_toolbar);
- gtk_container_foreach(GTK_CONTAINER(window->priv->menus.edit.open_with.menu), (GtkCallback)gtk_widget_destroy, NULL);
- gtk_container_foreach(GTK_CONTAINER(window->priv->menus._picture_viewer.open_with.menu), (GtkCallback)gtk_widget_destroy, NULL);
- if(!gtk_widget_get_parent(window->priv->menus.edit.open_with.menu_item_empty))
- {
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus.edit.open_with.menu), window->priv->menus.edit.open_with.menu_item_empty);
- gtk_widget_show(window->priv->menus.edit.open_with.menu_item_empty);
- }
+ g_value_init (&show_toolbar_val, G_TYPE_BOOLEAN);
+ g_object_get_property (G_OBJECT(window->priv->settings_manager), "show-toolbar", &show_toolbar_val);
- if(!gtk_widget_get_parent(window->priv->menus._picture_viewer.open_with.menu_item_empty))
- {
- gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->menus._picture_viewer.open_with.menu),
- window->priv->menus._picture_viewer.open_with.menu_item_empty);
- gtk_widget_show(window->priv->menus._picture_viewer.open_with.menu_item_empty);
+ gtk_widget_show (window->priv->menubar);
+ gtk_widget_show (window->priv->statusbar);
+
+ if (g_value_get_boolean (&show_toolbar_val))
+ gtk_widget_show (window->priv->toolbar);
+
+ g_value_reset (&show_toolbar_val);
}
}
-
+ if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED)
+ {
+ }
}
-static void
-cb_rstto_main_window_nav_new_entry(RsttoNavigator *navigator, gint nr, RsttoNavigatorEntry *entry, RsttoMainWindow *window)
+static gboolean
+cb_rstto_main_window_picture_viewer_motion_notify_event (RsttoPictureViewer *viewer,
+ GdkEventMotion *event,
+ gpointer user_data)
{
- RsttoNavigatorEntry *current_entry = rstto_navigator_get_file(navigator);
- ThunarVfsInfo *info = rstto_navigator_entry_get_info(entry);
- gchar *filename = info->display_name;
-
- gint current_nr = rstto_navigator_get_position(navigator);
-
- if (current_entry)
+ RsttoMainWindow *window = RSTTO_MAIN_WINDOW (user_data);
+ if(gdk_window_get_state(GTK_WIDGET(window)->window) & GDK_WINDOW_STATE_FULLSCREEN)
{
- gchar *title;
- /* Update window title */
- if (rstto_navigator_get_n_files(navigator) > 1)
- {
- title = g_strdup_printf("%s - %s [%d/%d]", PACKAGE_NAME, filename, current_nr+1, rstto_navigator_get_n_files(navigator));
- }
- else
+ if (event->state == 0)
{
- title = g_strconcat(PACKAGE_NAME, " - ", filename, NULL);
+ gtk_widget_show (window->priv->image_list_toolbar);
+
+ if (window->priv->fs_toolbar_sticky == FALSE)
+ {
+ if (window->priv->show_fs_toolbar_timeout_id > 0)
+ {
+ g_source_remove (window->priv->show_fs_toolbar_timeout_id);
+ window->priv->show_fs_toolbar_timeout_id = 0;
+ }
+ window->priv->show_fs_toolbar_timeout_id = g_timeout_add (3000, (GSourceFunc)cb_rstto_main_window_show_fs_toolbar_timeout, window);
+ }
}
- gtk_window_set_title(GTK_WINDOW(window), title);
- g_free(title);
- title = NULL;
}
-
+ return TRUE;
}
-static void
-cb_rstto_main_window_next(GtkWidget *widget, RsttoMainWindow *window)
+static gboolean
+cb_rstto_main_window_show_fs_toolbar_timeout (RsttoMainWindow *window)
{
- rstto_navigator_jump_forward(window->priv->navigator);
+ gtk_widget_hide (window->priv->image_list_toolbar);
+ return FALSE;
}
static void
-cb_rstto_main_window_previous(GtkWidget *widget, RsttoMainWindow *window)
+cb_rstto_main_window_settings_notify (GObject *settings, GParamSpec *spec, RsttoMainWindow *window)
{
- rstto_navigator_jump_back(window->priv->navigator);
-}
+ GValue val = {0,};
+ g_return_if_fail (RSTTO_IS_SETTINGS (settings));
+ g_return_if_fail (RSTTO_IS_MAIN_WINDOW (window));
-static void
-cb_rstto_main_window_first(GtkWidget *widget, RsttoMainWindow *window)
-{
- rstto_navigator_jump_first(window->priv->navigator);
-}
+ g_value_init (&val, spec->value_type);
+ g_object_get_property (settings, spec->name, &val);
-static void
-cb_rstto_main_window_last(GtkWidget *widget, RsttoMainWindow *window)
-{
- rstto_navigator_jump_last(window->priv->navigator);
-}
-static void
-cb_rstto_main_window_zoom_in(GtkWidget *widget, RsttoMainWindow *window)
-{
- rstto_picture_viewer_set_zoom_mode(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), RSTTO_ZOOM_MODE_CUSTOM);
- gdouble scale = rstto_picture_viewer_get_scale(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer));
- rstto_picture_viewer_set_scale(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), scale * window->priv->zoom_factor);
+ g_value_unset (&val);
}
+/**
+ * cb_rstto_main_window_message_bar_cancel:
+ * @widget:
+ * @window:
+ *
+ */
static void
-cb_rstto_main_window_zoom_out(GtkWidget *widget, RsttoMainWindow *window)
+cb_rstto_main_window_message_bar_cancel (GtkWidget *widget, RsttoMainWindow *window)
{
- rstto_picture_viewer_set_zoom_mode(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), RSTTO_ZOOM_MODE_CUSTOM);
- gdouble scale = rstto_picture_viewer_get_scale(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer));
- rstto_picture_viewer_set_scale(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), scale / window->priv->zoom_factor);
+ gtk_widget_hide (window->priv->message_bar);
+ if (window->priv->message_bar_file)
+ {
+ g_object_unref (window->priv->message_bar_file);
+ window->priv->message_bar_file = NULL;
+ }
}
+/**
+ * cb_rstto_main_window_message_bar_open:
+ * @widget:
+ * @window:
+ *
+ */
static void
-cb_rstto_main_window_zoom_100(GtkWidget *widget, RsttoMainWindow *window)
+cb_rstto_main_window_message_bar_open (GtkWidget *widget, RsttoMainWindow *window)
{
- rstto_picture_viewer_set_zoom_mode(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), RSTTO_ZOOM_MODE_100);
- rstto_picture_viewer_set_scale(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), 1);
-}
+ GFile *child_file = NULL;
+ GFileEnumerator *file_enumarator = NULL;
+ GFileInfo *file_info = NULL;
+ const gchar *filename = NULL;
+ const gchar *content_type = NULL;
-static void
-cb_rstto_main_window_zoom_fit(GtkWidget *widget, RsttoMainWindow *window)
-{
- rstto_picture_viewer_set_zoom_mode(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), RSTTO_ZOOM_MODE_FIT);
- rstto_picture_viewer_fit_scale(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer));
-}
+ gtk_widget_hide (window->priv->message_bar);
-static void
-cb_rstto_main_window_rotate_cw(GtkWidget *widget, RsttoMainWindow *window)
-{
- RsttoNavigatorEntry *entry = rstto_navigator_get_file(window->priv->navigator);
- if (entry)
- {
- GdkPixbufRotation rotation = rstto_navigator_entry_get_rotation(entry);
- switch (rotation)
- {
- case GDK_PIXBUF_ROTATE_NONE:
- rotation = GDK_PIXBUF_ROTATE_CLOCKWISE;
- break;
- case GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE:
- rotation = GDK_PIXBUF_ROTATE_NONE;
- break;
- case GDK_PIXBUF_ROTATE_UPSIDEDOWN:
- rotation = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
- break;
- case GDK_PIXBUF_ROTATE_CLOCKWISE:
- rotation = GDK_PIXBUF_ROTATE_UPSIDEDOWN;
- break;
- default:
- g_warning("Unable to rotate, rotation unknown");
- break;
- }
- rstto_navigator_entry_set_rotation(entry, rotation);
- }
-}
-static void
-cb_rstto_main_window_rotate_ccw(GtkWidget *widget, RsttoMainWindow *window)
-{
- RsttoNavigatorEntry *entry = rstto_navigator_get_file(window->priv->navigator);
- if (entry)
+ file_enumarator = g_file_enumerate_children (window->priv->message_bar_file, "standard::*", 0, NULL, NULL);
+ for(file_info = g_file_enumerator_next_file (file_enumarator, NULL, NULL); file_info != NULL; file_info = g_file_enumerator_next_file (file_enumarator, NULL, NULL))
{
- GdkPixbufRotation rotation = rstto_navigator_entry_get_rotation(entry);
- switch (rotation)
+ filename = g_file_info_get_name (file_info);
+ content_type = g_file_info_get_content_type (file_info);
+ child_file = g_file_get_child (window->priv->message_bar_file, filename);
+
+ if (strncmp (content_type, "image/", 6) == 0)
{
- case GDK_PIXBUF_ROTATE_NONE:
- rotation = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
- break;
- case GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE:
- rotation = GDK_PIXBUF_ROTATE_UPSIDEDOWN;
- break;
- case GDK_PIXBUF_ROTATE_UPSIDEDOWN:
- rotation = GDK_PIXBUF_ROTATE_CLOCKWISE;
- break;
- case GDK_PIXBUF_ROTATE_CLOCKWISE:
- rotation = GDK_PIXBUF_ROTATE_NONE;
- break;
- default:
- g_warning("Unable to rotate, rotation unknown");
- break;
+ rstto_image_list_add_file (window->priv->props.image_list, child_file, NULL);
}
- rstto_navigator_entry_set_rotation(entry, rotation);
- }
-}
-static void
-cb_rstto_main_window_spawn_app(GtkWidget *widget, ThunarVfsMimeApplication *app)
-{
- ThunarVfsInfo *info = rstto_navigator_entry_get_info(g_object_get_data(G_OBJECT(app), "entry"));
- GList *list = g_list_prepend(NULL, info->path);
- thunar_vfs_mime_handler_exec(THUNAR_VFS_MIME_HANDLER(app), NULL, list, NULL);
-}
-
-void
-rstto_main_window_set_pv_bg_color (RsttoMainWindow *window, const GdkColor *color)
-{
- rstto_picture_viewer_set_bg_color(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), color);
- if (color)
- {
- window->priv->settings.bg_color = gdk_color_copy(color);
+ g_object_unref (child_file);
+ g_object_unref (file_info);
}
- else
- {
- window->priv->settings.bg_color = NULL;
- }
-}
-const GdkColor *
-rstto_main_window_get_pv_bg_color (RsttoMainWindow *window)
-{
- return window->priv->settings.bg_color;
-}
-
-static void
-cb_rstto_bg_color_override_check_toggled(GtkToggleButton *button, GtkWidget *widget)
-{
- if (gtk_toggle_button_get_active(button) == TRUE)
- {
- gtk_widget_set_sensitive(widget, TRUE);
- }
- else
+
+ if (window->priv->message_bar_file)
{
- gtk_widget_set_sensitive(widget, FALSE);
+ g_object_unref (window->priv->message_bar_file);
+ window->priv->message_bar_file = NULL;
}
}
-GtkStatusbar *
-rstto_main_window_get_statusbar(RsttoMainWindow *window)
-{
- return GTK_STATUSBAR(window->priv->statusbar);
-}
-
-gint
-rstto_main_window_get_desktop(RsttoMainWindow *window)
-{
- return window->priv->settings.desktop;
-}
-
-gint
-rstto_main_window_set_desktop(RsttoMainWindow *window, RsttoDesktop desktop)
-{
- switch(desktop)
- {
-#ifdef WITH_DESKTOP_WALLPAPER
-#ifdef HAVE_XFCONF
- case RSTTO_DESKTOP_XFCE:
- window->priv->settings.desktop = desktop;
- break;
-#endif
-#endif
- default:
- window->priv->settings.desktop = RSTTO_DESKTOP_NONE;
- break;
- }
- return 0;
-}
+/*
+static gboolean
+cb_rstto_main_window_image_list_toolbar_popup_context_menu (GtkToolbar *toolbar,
+ gint x,
+ gint y,
+ gint button,
+ gpointer user_data)
+{
+ RsttoMainWindow *window = RSTTO_MAIN_WINDOW (user_data);
+
+ gtk_menu_popup (window->priv->image_list_toolbar_menu,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 3,
+ gtk_get_current_event_time ());
+}
+*/
diff --git a/src/main_window.h b/src/main_window.h
index f1793eb..e70768f 100644
--- a/src/main_window.h
+++ b/src/main_window.h
@@ -60,77 +60,14 @@ struct _RsttoMainWindowClass
typedef enum {
RSTTO_DESKTOP_NONE,
- RSTTO_DESKTOP_XFCE
+ RSTTO_DESKTOP_XFCE,
+ RSTTO_DESKTOP_GNOME
} RsttoDesktop;
-static gboolean rstto_has_xfconf_query = FALSE;
-
GType rstto_main_window_get_type();
-GtkWidget *rstto_main_window_new();
-
-void
-rstto_main_window_set_thumbnail_viewer_orientation(RsttoMainWindow *window, GtkOrientation orientation);
-void
-rstto_main_window_set_show_thumbnail_viewer (RsttoMainWindow *window, gboolean visibility);
-void
-rstto_main_window_set_show_toolbar (RsttoMainWindow *window, gboolean visibility);
-gboolean
-rstto_main_window_get_show_toolbar (RsttoMainWindow *window);
-gboolean
-rstto_main_window_get_show_thumbnail_viewer (RsttoMainWindow *window);
-GtkOrientation
-rstto_main_window_get_thumbnail_viewer_orientation (RsttoMainWindow *window);
-RsttoNavigator *
-rstto_main_window_get_navigator (RsttoMainWindow *window);
-GtkRecentManager *
-rstto_main_window_get_recent_manager (RsttoMainWindow *window);
-
-
-gdouble
-rstto_main_window_get_slideshow_timeout (RsttoMainWindow *window);
-gboolean
-rstto_main_window_get_hide_thumbnails (RsttoMainWindow *window);
-gint
-rstto_main_window_get_max_cache_size (RsttoMainWindow *window);
-void
-rstto_main_window_set_slideshow_timeout (RsttoMainWindow *window, gdouble timeout);
-void
-rstto_main_window_set_hide_thumbnails (RsttoMainWindow *window, gboolean hide);
-void
-rstto_main_window_set_max_cache_size (RsttoMainWindow *window, gint max_cache_size);
-void
-rstto_main_window_set_pv_bg_color (RsttoMainWindow *window, const GdkColor *color);
-const GdkColor *
-rstto_main_window_get_pv_bg_color (RsttoMainWindow *window);
-
-void
-rstto_main_window_set_start_fullscreen (RsttoMainWindow *window, gboolean fullscreen);
-void
-rstto_main_window_set_start_slideshow (RsttoMainWindow *window, gboolean slideshow);
-void
-rstto_main_window_force_fullscreen (RsttoMainWindow *window);
-void
-rstto_main_window_force_slideshow (RsttoMainWindow *window);
-
-void
-rstto_main_window_set_scale_to_100 (RsttoMainWindow *window, gboolean scale_to_100);
-gboolean
-rstto_main_window_get_scale_to_100 (RsttoMainWindow *window);
-
-GtkStatusbar *
-rstto_main_window_get_statusbar(RsttoMainWindow *window);
-gint
-rstto_main_window_get_desktop(RsttoMainWindow *window);
-gint
-rstto_main_window_set_desktop(RsttoMainWindow *window, RsttoDesktop desktop);
-gboolean
-rstto_main_window_get_hide_thumbnail (RsttoMainWindow *window);
-void
-rstto_main_window_set_hide_thumbnail (RsttoMainWindow *window, gboolean hide);
-void
-rstto_main_window_set_start_fullscreen (RsttoMainWindow *window, gboolean fullscreen);
+GtkWidget *rstto_main_window_new (RsttoImageList *, gboolean);
G_END_DECLS
diff --git a/src/main_window_ui.xml b/src/main_window_ui.xml
new file mode 100644
index 0000000..6b5760b
--- /dev/null
+++ b/src/main_window_ui.xml
@@ -0,0 +1,101 @@
+<ui>
+ <!--
+
+
+ -->
+ <menubar name="main-menu">
+ <menu action="file-menu">
+ <menuitem action="open"/>
+ <menuitem action="open-folder"/>
+ <placeholder name="placeholder-open-recent"/>
+ <separator/>
+ <menuitem action="save-copy"/>
+ <separator/>
+ <menuitem action="print"/>
+ <separator/>
+ <menuitem action="close"/>
+ <menuitem action="close-all"/>
+ <menuitem action="quit"/>
+ </menu>
+ <menu action="edit-menu">
+ <menu action="open-with-menu">
+ <placeholder name="open-with-apps" />
+ </menu>
+ <separator/>
+ <menu action="sorting-menu">
+ <menuitem action="sort-filename"/>
+ <menuitem action="sort-date"/>
+ </menu>
+ <menuitem action="delete"/>
+ <separator/>
+ <menuitem action="preferences"/>
+ </menu>
+ <menu action="view-menu">
+ <menuitem action="show-toolbar"/>
+ <menuitem action="show-thumbnailbar"/>
+ <separator/>
+ <menu action="zoom-menu">
+ <menuitem action="zoom-in"/>
+ <menuitem action="zoom-out"/>
+ <menuitem action="zoom-fit"/>
+ <menuitem action="zoom-100"/>
+ </menu>
+ <menu action="rotation-menu">
+ <menuitem action="rotate-cw"/>
+ <menuitem action="rotate-ccw"/>
+ </menu>
+ <separator/>
+ <menuitem action="fullscreen"/>
+ <menuitem action="set-as-wallpaper"/>
+ </menu>
+ <menu action="go-menu">
+ <menuitem action="back"/>
+ <menuitem action="forward"/>
+ <menuitem action="first"/>
+ <menuitem action="last"/>
+ <separator/>
+ <placeholder name="placeholder-slideshow" />
+ </menu>
+ <menu action="help-menu">
+ <menuitem action="contents"/>
+ <menuitem action="about"/>
+ </menu>
+ </menubar>
+
+ <popup name="tb-menu">
+ <menuitem action="open"/>
+ </popup>
+
+ <!--
+
+ -->
+ <toolbar name="main-toolbar">
+ <toolitem action="open"/>
+ <toolitem action="open-folder"/>
+ <separator />
+ <toolitem action="save-copy"/>
+ <toolitem action="close"/>
+ <toolitem action="delete"/>
+ <separator />
+ </toolbar>
+
+ <!--
+
+ -->
+ <toolbar name="navigation-toolbar">
+ <toolitem action="back"/>
+ <placeholder name="placeholder-slideshow" />
+ <toolitem action="forward"/>
+ <separator name="separator-1"/>
+ <toolitem action="rotate-ccw"/>
+ <toolitem action="rotate-cw"/>
+ <separator />
+ <toolitem action="zoom-in"/>
+ <toolitem action="zoom-out"/>
+ <toolitem action="zoom-100"/>
+ <toolitem action="zoom-fit"/>
+ <separator />
+ <placeholder name="placeholder-fullscreen" />
+ </toolbar>
+
+</ui>
diff --git a/src/picture_viewer.c b/src/picture_viewer.c
index fcbf63f..9fc6201 100644
--- a/src/picture_viewer.c
+++ b/src/picture_viewer.c
@@ -1,4 +1,9 @@
/*
+<<<<<<< HEAD:src/picture_viewer.c
+=======
+ * Copyright (C) Stephan Arts 2006-2009 <stephan at xfce.org>
+ *
+>>>>>>> 9b75414e8bb4500c58635dd45ecb8f2f45266902:src/picture_viewer.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
@@ -20,19 +25,34 @@
#include <gtk/gtk.h>
#include <gtk/gtkmarshal.h>
#include <string.h>
-#include <thunar-vfs/thunar-vfs.h>
+#include <gio/gio.h>
#include <libexif/exif-data.h>
-#include "navigator.h"
+#include "image.h"
+#include "image_list.h"
#include "picture_viewer.h"
+#include "settings.h"
typedef enum
{
- RSTTO_PICTURE_VIEWER_STATE_NONE,
- RSTTO_PICTURE_VIEWER_STATE_MOVE,
- RSTTO_PICTURE_VIEWER_STATE_BOX_ZOOM
+ RSTTO_PICTURE_VIEWER_STATE_NORMAL = 0,
+ RSTTO_PICTURE_VIEWER_STATE_PREVIEW
} RsttoPictureViewerState;
+typedef enum
+{
+ RSTTO_PICTURE_VIEWER_MOTION_STATE_NORMAL = 0,
+ RSTTO_PICTURE_VIEWER_MOTION_STATE_BOX_ZOOM,
+ RSTTO_PICTURE_VIEWER_MOTION_STATE_MOVE
+} RsttoPictureViewerMotionState;
+
+typedef enum
+{
+ RSTTO_ZOOM_MODE_CUSTOM,
+ RSTTO_ZOOM_MODE_100,
+ RSTTO_ZOOM_MODE_FIT
+} RsttoZoomMode;
+
enum
{
TARGET_TEXT_URI_LIST,
@@ -45,15 +65,17 @@ static const GtkTargetEntry drop_targets[] = {
struct _RsttoPictureViewerPriv
{
- RsttoNavigator *navigator;
- RsttoNavigatorEntry *entry;
- RsttoZoomMode zoom_mode;
+ RsttoImage *image;
+ RsttoImageListIter *iter;
+ GtkMenu *menu;
+ RsttoPictureViewerState state;
+ RsttoZoomMode zoom_mode;
+
- GdkPixbuf *src_pixbuf;
GdkPixbuf *dst_pixbuf; /* The pixbuf which ends up on screen */
void (*cb_value_changed)(GtkAdjustment *, RsttoPictureViewer *);
- gboolean show_border;
GdkColor *bg_color;
+
struct
{
gdouble x;
@@ -62,13 +84,14 @@ struct _RsttoPictureViewerPriv
gdouble current_y;
gint h_val;
gint v_val;
- RsttoPictureViewerState state;
+ RsttoPictureViewerMotionState state;
} motion;
+
struct
{
gint idle_id;
- } refresh;
- GtkMenu *menu;
+ gboolean refresh;
+ } repaint;
};
static void
@@ -78,8 +101,17 @@ rstto_picture_viewer_class_init(RsttoPictureViewerClass *);
static void
rstto_picture_viewer_destroy(GtkObject *object);
-static gboolean
-cb_rstto_picture_viewer_queued_repaint(RsttoPictureViewer *viewer);
+static void
+rstto_picture_viewer_set_state (RsttoPictureViewer *viewer, RsttoPictureViewerState state);
+static RsttoPictureViewerState
+rstto_picture_viewer_get_state (RsttoPictureViewer *viewer);
+static void
+rstto_picture_viewer_set_motion_state (RsttoPictureViewer *viewer, RsttoPictureViewerMotionState state);
+static RsttoPictureViewerMotionState
+rstto_picture_viewer_get_motion_state (RsttoPictureViewer *viewer);
+
+static void
+rstto_picture_viewer_set_zoom_mode (RsttoPictureViewer *viewer, RsttoZoomMode mode);
static void
rstto_picture_viewer_size_request(GtkWidget *, GtkRequisition *);
@@ -89,54 +121,52 @@ static void
rstto_picture_viewer_realize(GtkWidget *);
static gboolean
rstto_picture_viewer_expose(GtkWidget *, GdkEventExpose *);
-
static void
-rstto_picture_viewer_paint(GtkWidget *widget);
-static gboolean
-rstto_picture_viewer_refresh(RsttoPictureViewer *viewer);
+rstto_picture_viewer_paint (GtkWidget *widget);
+static void
+rstto_picture_viewer_queued_repaint (RsttoPictureViewer *viewer, gboolean refresh);
static gboolean
rstto_picture_viewer_set_scroll_adjustments(RsttoPictureViewer *, GtkAdjustment *, GtkAdjustment *);
static void
-cb_rstto_picture_viewer_nav_iter_changed(RsttoNavigator *, gint , RsttoNavigatorEntry *, RsttoPictureViewer *);
-static void
-cb_rstto_picture_viewer_nav_entry_modified(RsttoNavigator *, RsttoNavigatorEntry *, RsttoPictureViewer *);
+rstto_marshal_VOID__OBJECT_OBJECT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
static void
cb_rstto_picture_viewer_value_changed(GtkAdjustment *, RsttoPictureViewer *);
static void
-cb_rstto_picture_viewer_scroll_event (RsttoPictureViewer *, GdkEventScroll *);
+cb_rstto_picture_viewer_nav_iter_changed (RsttoImageListIter *iter, gpointer user_data);
+
+static void
+cb_rstto_picture_viewer_image_updated (RsttoImage *image, RsttoPictureViewer *viewer);
+static void
+cb_rstto_picture_viewer_image_prepared (RsttoImage *image, RsttoPictureViewer *viewer);
+
static gboolean
-cb_rstto_picture_viewer_motion_notify_event (RsttoPictureViewer *viewer,
- GdkEventMotion *event,
- gpointer user_data);
+cb_rstto_picture_viewer_queued_repaint (RsttoPictureViewer *viewer);
+
+static void
+cb_rstto_picture_viewer_scroll_event (RsttoPictureViewer *viewer, GdkEventScroll *event);
static void
cb_rstto_picture_viewer_button_press_event (RsttoPictureViewer *viewer, GdkEventButton *event);
static void
cb_rstto_picture_viewer_button_release_event (RsttoPictureViewer *viewer, GdkEventButton *event);
+static gboolean
+cb_rstto_picture_viewer_motion_notify_event (RsttoPictureViewer *viewer,
+ GdkEventMotion *event,
+ gpointer user_data);
static void
cb_rstto_picture_viewer_popup_menu (RsttoPictureViewer *viewer, gboolean user_data);
-static gboolean
-rstto_picture_viewer_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time);
-static gboolean
-rstto_picture_viewer_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time);
-static void
-rstto_picture_viewer_drag_data_received();
-
static GtkWidgetClass *parent_class = NULL;
GType
-rstto_picture_viewer_get_type ()
+rstto_picture_viewer_get_type (void)
{
static GType rstto_picture_viewer_type = 0;
@@ -167,16 +197,14 @@ rstto_picture_viewer_init(RsttoPictureViewer *viewer)
viewer->priv = g_new0(RsttoPictureViewerPriv, 1);
viewer->priv->cb_value_changed = cb_rstto_picture_viewer_value_changed;
- viewer->priv->src_pixbuf = NULL;
viewer->priv->dst_pixbuf = NULL;
viewer->priv->zoom_mode = RSTTO_ZOOM_MODE_CUSTOM;
gtk_widget_set_redraw_on_allocate(GTK_WIDGET(viewer), TRUE);
gtk_widget_set_events (GTK_WIDGET(viewer),
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
- GDK_BUTTON1_MOTION_MASK);
-
- viewer->priv->show_border = FALSE;
+ GDK_BUTTON1_MOTION_MASK |
+ GDK_POINTER_MOTION_MASK);
g_signal_connect(G_OBJECT(viewer), "scroll_event", G_CALLBACK(cb_rstto_picture_viewer_scroll_event), NULL);
g_signal_connect(G_OBJECT(viewer), "button_press_event", G_CALLBACK(cb_rstto_picture_viewer_button_press_event), NULL);
@@ -188,7 +216,18 @@ rstto_picture_viewer_init(RsttoPictureViewer *viewer)
GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE | GDK_ACTION_PRIVATE);
}
-void
+/**
+ * rstto_marshal_VOID__OBJECT_OBJECT:
+ * @closure:
+ * @return_value:
+ * @n_param_values:
+ * @param_values:
+ * @invocation_hint:
+ * @marshal_data:
+ *
+ * A marshaller for the set_scroll_adjustments signal.
+ */
+static void
rstto_marshal_VOID__OBJECT_OBJECT (GClosure *closure,
GValue *return_value,
guint n_param_values,
@@ -196,35 +235,41 @@ rstto_marshal_VOID__OBJECT_OBJECT (GClosure *closure,
gpointer invocation_hint,
gpointer marshal_data)
{
- typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT) (gpointer data1,
- gpointer arg_1,
- gpointer arg_2,
- gpointer data2);
- register GMarshalFunc_VOID__OBJECT_OBJECT callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
+ typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__OBJECT_OBJECT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
- g_return_if_fail (n_param_values == 3);
+ g_return_if_fail (n_param_values == 3);
- if (G_CCLOSURE_SWAP_DATA (closure))
+ if (G_CCLOSURE_SWAP_DATA (closure))
{
- data1 = closure->data;
- data2 = g_value_get_object (param_values + 0);
+ data1 = closure->data;
+ data2 = g_value_get_object (param_values + 0);
}
- else
+ else
{
- data1 = g_value_get_object (param_values + 0);
- data2 = closure->data;
+ data1 = g_value_get_object (param_values + 0);
+ data2 = closure->data;
}
- callback = (GMarshalFunc_VOID__OBJECT_OBJECT) (marshal_data ?
- marshal_data : cc->callback);
+ callback = (GMarshalFunc_VOID__OBJECT_OBJECT) (marshal_data ?
+ marshal_data : cc->callback);
- callback (data1,
- g_value_get_object (param_values + 1),
- g_value_get_object (param_values + 2),
- data2);
+ callback (data1,
+ g_value_get_object (param_values + 1),
+ g_value_get_object (param_values + 2),
+ data2);
}
+/**
+ * rstto_picture_viewer_class_init:
+ * @viewer_class:
+ *
+ * Initialize pictureviewer class
+ */
static void
rstto_picture_viewer_class_init(RsttoPictureViewerClass *viewer_class)
{
@@ -242,13 +287,9 @@ rstto_picture_viewer_class_init(RsttoPictureViewerClass *viewer_class)
widget_class->expose_event = rstto_picture_viewer_expose;
widget_class->size_request = rstto_picture_viewer_size_request;
widget_class->size_allocate = rstto_picture_viewer_size_allocate;
- widget_class->drag_drop = rstto_picture_viewer_drag_drop;
- widget_class->drag_motion = rstto_picture_viewer_drag_motion;
- widget_class->drag_data_received = rstto_picture_viewer_drag_data_received;
object_class->destroy = rstto_picture_viewer_destroy;
-
widget_class->set_scroll_adjustments_signal =
g_signal_new ("set_scroll_adjustments",
G_TYPE_FROM_CLASS (object_class),
@@ -261,42 +302,20 @@ rstto_picture_viewer_class_init(RsttoPictureViewerClass *viewer_class)
GTK_TYPE_ADJUSTMENT);
}
-static void
-rstto_picture_viewer_size_request(GtkWidget *widget, GtkRequisition *requisition)
-{
- requisition->width = 100;
- requisition->height= 500;
-}
-
-static void
-rstto_picture_viewer_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
-{
- RsttoPictureViewer *viewer = RSTTO_PICTURE_VIEWER(widget);
- gint border_width = 0;
- widget->allocation = *allocation;
-
- if (GTK_WIDGET_REALIZED (widget))
- {
- gdk_window_move_resize (widget->window,
- allocation->x + border_width,
- allocation->y + border_width,
- allocation->width - border_width * 2,
- allocation->height - border_width * 2);
- }
-
- rstto_picture_viewer_refresh(viewer);
- rstto_picture_viewer_paint(GTK_WIDGET(viewer));
-}
-
+/**
+ * rstto_picture_viewer_realize:
+ * @widget:
+ *
+ */
static void
rstto_picture_viewer_realize(GtkWidget *widget)
{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (RSTTO_IS_PICTURE_VIEWER(widget));
-
GdkWindowAttr attributes;
gint attributes_mask;
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (RSTTO_IS_PICTURE_VIEWER(widget));
+
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
attributes.x = widget->allocation.x;
@@ -319,48 +338,133 @@ rstto_picture_viewer_realize(GtkWidget *widget)
gtk_style_set_background (widget->style, widget->window, GTK_STATE_ACTIVE);
}
+/**
+ * rstto_picture_viewer_size_request:
+ * @widget:
+ * @requisition:
+ *
+ * Request a default size of 300 by 400 pixels
+ */
+static void
+rstto_picture_viewer_size_request(GtkWidget *widget, GtkRequisition *requisition)
+{
+ requisition->width = 400;
+ requisition->height= 300;
+}
+
+
+/**
+ * rstto_picture_viewer_size_allocate:
+ * @widget:
+ * @allocation:
+ *
+ *
+ */
+static void
+rstto_picture_viewer_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
+{
+ RsttoPictureViewer *viewer = RSTTO_PICTURE_VIEWER(widget);
+ gint border_width = 0;
+ widget->allocation = *allocation;
+
+ if (GTK_WIDGET_REALIZED (widget))
+ {
+ gdk_window_move_resize (widget->window,
+ allocation->x + border_width,
+ allocation->y + border_width,
+ allocation->width - border_width * 2,
+ allocation->height - border_width * 2);
+ }
+
+ /**
+ * TODO: Check if we really nead a refresh
+ */
+ rstto_picture_viewer_queued_repaint (viewer, TRUE);
+}
+
+/**
+ * rstto_picture_viewer_expose:
+ * @widget:
+ * @event:
+ *
+ */
static gboolean
rstto_picture_viewer_expose(GtkWidget *widget, GdkEventExpose *event)
{
- rstto_picture_viewer_refresh(RSTTO_PICTURE_VIEWER(widget));
- rstto_picture_viewer_paint(widget);
+ RsttoPictureViewer *viewer = RSTTO_PICTURE_VIEWER (widget);
+
+ /**
+ * TODO: Check if we really nead a refresh
+ */
+ rstto_picture_viewer_queued_repaint (viewer, TRUE);
return FALSE;
}
+/**
+ * rstto_picture_viewer_paint:
+ * @widget:
+ *
+ * Paint the picture_viewer widget contents
+ */
static void
-rstto_picture_viewer_paint(GtkWidget *widget)
+rstto_picture_viewer_paint (GtkWidget *widget)
{
+ RsttoSettings *settings_manager = rstto_settings_new();
RsttoPictureViewer *viewer = RSTTO_PICTURE_VIEWER(widget);
GdkPixbuf *pixbuf = viewer->priv->dst_pixbuf;
GdkColor color;
GdkColor line_color;
+ gint i, a, height, width;
+ GdkColor *bg_color = NULL;
+ gdouble m_x1, m_x2, m_y1, m_y2;
+ gint x1, x2, y1, y2;
+ GValue val_bg_color = {0, }, val_bg_color_override = {0, }, val_bg_color_fs = {0, };
+ g_value_init (&val_bg_color, GDK_TYPE_COLOR);
+ g_value_init (&val_bg_color_fs, GDK_TYPE_COLOR);
+ g_value_init (&val_bg_color_override, G_TYPE_BOOLEAN);
+
+ g_object_get_property (G_OBJECT(settings_manager), "bgcolor", &val_bg_color);
+ g_object_get_property (G_OBJECT(settings_manager), "bgcolor-override", &val_bg_color_override);
+
+ g_object_get_property (G_OBJECT(settings_manager), "bgcolor-fullscreen", &val_bg_color_fs);
+
color.pixel = 0x0;
line_color.pixel = 0x0;
- gint i, a, height, width;
-
/* required for transparent pixbufs... add double buffering to fix flickering*/
if(GTK_WIDGET_REALIZED(widget))
{
GdkPixmap *buffer = gdk_pixmap_new(NULL, widget->allocation.width, widget->allocation.height, gdk_drawable_get_depth(widget->window));
GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(buffer));
- if (viewer->priv->bg_color)
+ if(gdk_window_get_state(gdk_window_get_toplevel(GTK_WIDGET(viewer)->window)) & GDK_WINDOW_STATE_FULLSCREEN)
{
- gdk_gc_set_foreground(gc, viewer->priv->bg_color);
+ bg_color = g_value_get_boxed (&val_bg_color_fs);
}
else
{
- gdk_gc_set_foreground(gc, &(widget->style->bg[GTK_STATE_NORMAL]));
+ if (g_value_get_boxed (&val_bg_color) && g_value_get_boolean (&val_bg_color_override))
+ {
+ bg_color = g_value_get_boxed (&val_bg_color);
+ }
+ else
+ {
+ bg_color = &(widget->style->bg[GTK_STATE_NORMAL]);
+ }
}
+ gdk_colormap_alloc_color (gdk_gc_get_colormap (gc), bg_color, FALSE, TRUE);
+ gdk_gc_set_rgb_fg_color (gc, bg_color);
+
gdk_draw_rectangle(GDK_DRAWABLE(buffer), gc, TRUE, 0, 0, widget->allocation.width, widget->allocation.height);
+
+ /* Check if there is a destination pixbuf */
if(pixbuf)
{
- gint x1 = (widget->allocation.width-gdk_pixbuf_get_width(pixbuf))<0?0:(widget->allocation.width-gdk_pixbuf_get_width(pixbuf))/2;
- gint y1 = (widget->allocation.height-gdk_pixbuf_get_height(pixbuf))<0?0:(widget->allocation.height-gdk_pixbuf_get_height(pixbuf))/2;
- gint x2 = gdk_pixbuf_get_width(pixbuf);
- gint y2 = gdk_pixbuf_get_height(pixbuf);
+ x1 = (widget->allocation.width-gdk_pixbuf_get_width(pixbuf))<0?0:(widget->allocation.width-gdk_pixbuf_get_width(pixbuf))/2;
+ y1 = (widget->allocation.height-gdk_pixbuf_get_height(pixbuf))<0?0:(widget->allocation.height-gdk_pixbuf_get_height(pixbuf))/2;
+ x2 = gdk_pixbuf_get_width(pixbuf);
+ y2 = gdk_pixbuf_get_height(pixbuf);
/* We only need to paint a checkered background if the image is transparent */
if(gdk_pixbuf_get_has_alpha(pixbuf))
@@ -412,11 +516,10 @@ rstto_picture_viewer_paint(GtkWidget *widget)
y2,
GDK_RGB_DITHER_NONE,
0,0);
- if(viewer->priv->motion.state == RSTTO_PICTURE_VIEWER_STATE_BOX_ZOOM)
+ if(viewer->priv->motion.state == RSTTO_PICTURE_VIEWER_MOTION_STATE_BOX_ZOOM)
{
gdk_gc_set_foreground(gc,
&(widget->style->fg[GTK_STATE_SELECTED]));
- gdouble m_x1, m_x2, m_y1, m_y2;
if (viewer->priv->motion.x < viewer->priv->motion.current_x)
{
@@ -490,15 +593,43 @@ rstto_picture_viewer_paint(GtkWidget *widget)
m_y2 - m_y1);
}
- if(viewer->priv->show_border)
+ }
+ else
+ {
+
+ /* HACK HACK HACK HACK */
+ guint size = 0;
+ if ((GTK_WIDGET (viewer)->allocation.width) < (GTK_WIDGET (viewer)->allocation.height))
+ {
+ size = GTK_WIDGET (viewer)->allocation.width;
+ }
+ else
{
- gdk_gc_set_foreground(gc, &line_color);
- gdk_draw_line(GDK_DRAWABLE(buffer), gc, x1, y1, x1, y1+y2);
- gdk_draw_line(GDK_DRAWABLE(buffer), gc, x1, y1+y2, x1+x2, y1+y2);
- gdk_draw_line(GDK_DRAWABLE(buffer), gc, x1, y1, x1+x2, y1);
- gdk_draw_line(GDK_DRAWABLE(buffer), gc, x1+x2, y1, x1+x2, y1+y2);
+ size = GTK_WIDGET (viewer)->allocation.height;
}
+ pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(),
+ "ristretto",
+ (size*0.8),
+ GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
+ gdk_pixbuf_saturate_and_pixelate (pixbuf, pixbuf, 0, TRUE);
+ pixbuf = gdk_pixbuf_composite_color_simple (pixbuf, (size*0.8), (size*0.8), GDK_INTERP_BILINEAR, 40, 40, bg_color->pixel, bg_color->pixel);
+
+ x1 = (widget->allocation.width-gdk_pixbuf_get_width(pixbuf))<0?0:(widget->allocation.width-gdk_pixbuf_get_width(pixbuf))/2;
+ y1 = (widget->allocation.height-gdk_pixbuf_get_height(pixbuf))<0?0:(widget->allocation.height-gdk_pixbuf_get_height(pixbuf))/2;
+ x2 = gdk_pixbuf_get_width(pixbuf);
+ y2 = gdk_pixbuf_get_height(pixbuf);
+ gdk_draw_pixbuf(GDK_DRAWABLE(buffer),
+ NULL,
+ pixbuf,
+ 0,
+ 0,
+ x1,
+ y1,
+ x2,
+ y2,
+ GDK_RGB_DITHER_NONE,
+ 0,0);
}
gdk_draw_drawable(GDK_DRAWABLE(widget->window),
gdk_gc_new(widget->window),
@@ -511,6 +642,7 @@ rstto_picture_viewer_paint(GtkWidget *widget)
widget->allocation.height);
g_object_unref(buffer);
}
+ g_object_unref (settings_manager);
}
static void
@@ -552,362 +684,177 @@ rstto_picture_viewer_set_scroll_adjustments(RsttoPictureViewer *viewer, GtkAdjus
static void
cb_rstto_picture_viewer_value_changed(GtkAdjustment *adjustment, RsttoPictureViewer *viewer)
{
- if (viewer->priv->refresh.idle_id > 0)
- {
- g_source_remove(viewer->priv->refresh.idle_id);
- }
- viewer->priv->refresh.idle_id = g_idle_add((GSourceFunc)cb_rstto_picture_viewer_queued_repaint, viewer);
+ /**
+ * A new subpixbuf needs to be blown up
+ */
+ rstto_picture_viewer_queued_repaint (viewer, TRUE);
}
GtkWidget *
-rstto_picture_viewer_new(RsttoNavigator *navigator)
+rstto_picture_viewer_new (void)
{
GtkWidget *widget;
widget = g_object_new(RSTTO_TYPE_PICTURE_VIEWER, NULL);
- RSTTO_PICTURE_VIEWER(widget)->priv->navigator = navigator;
- g_signal_connect(G_OBJECT(navigator), "iter-changed", G_CALLBACK(cb_rstto_picture_viewer_nav_iter_changed), widget);
- g_signal_connect(G_OBJECT(navigator), "entry-modified", G_CALLBACK(cb_rstto_picture_viewer_nav_entry_modified), widget);
return widget;
}
void
-rstto_picture_viewer_set_scale(RsttoPictureViewer *viewer, gdouble scale)
+rstto_picture_viewer_set_scale (RsttoPictureViewer *viewer, gdouble scale)
{
- RsttoNavigatorEntry *entry = rstto_navigator_get_file(viewer->priv->navigator);
- if (entry)
- {
- gdouble old_scale = rstto_navigator_entry_get_scale(entry);
+ gdouble *img_scale;
+ GdkPixbuf *src_pixbuf = NULL;
- gdouble width = (gdouble)gdk_pixbuf_get_width(viewer->priv->src_pixbuf);
- gdouble height = (gdouble)gdk_pixbuf_get_height(viewer->priv->src_pixbuf);
-
- rstto_navigator_entry_set_fit_to_screen (entry, FALSE);
- rstto_navigator_entry_set_scale(entry, scale);
+ if (viewer->priv->image)
+ {
+ src_pixbuf = rstto_image_get_pixbuf (viewer->priv->image);
+ img_scale = g_object_get_data (G_OBJECT (viewer->priv->image), "viewer-scale");
- viewer->hadjustment->upper = width * scale;
- gtk_adjustment_changed(viewer->hadjustment);
+ if (src_pixbuf)
+ {
+ gdouble image_width = (gdouble)rstto_image_get_width (viewer->priv->image);
+ gdouble image_height = (gdouble)rstto_image_get_height (viewer->priv->image);
- viewer->vadjustment->upper = height * scale;
- gtk_adjustment_changed(viewer->vadjustment);
+ viewer->hadjustment->upper = image_width *scale;
+ gtk_adjustment_changed(viewer->hadjustment);
- viewer->hadjustment->value = (((viewer->hadjustment->value +
- (viewer->hadjustment->page_size / 2)) *
- scale) / old_scale) - (viewer->hadjustment->page_size / 2);
- viewer->vadjustment->value = (((viewer->vadjustment->value +
- (viewer->vadjustment->page_size / 2)) *
- scale) / old_scale) - (viewer->vadjustment->page_size / 2);
+ viewer->vadjustment->upper = image_height * scale;
+ gtk_adjustment_changed(viewer->vadjustment);
- if((viewer->hadjustment->value + viewer->hadjustment->page_size) > viewer->hadjustment->upper)
- {
- viewer->hadjustment->value = viewer->hadjustment->upper - viewer->hadjustment->page_size;
- }
- if(viewer->hadjustment->value < viewer->hadjustment->lower)
- {
- viewer->hadjustment->value = viewer->hadjustment->lower;
- }
- if((viewer->vadjustment->value + viewer->vadjustment->page_size) > viewer->vadjustment->upper)
- {
- viewer->vadjustment->value = viewer->vadjustment->upper - viewer->vadjustment->page_size;
- }
- if(viewer->vadjustment->value < viewer->vadjustment->lower)
- {
- viewer->vadjustment->value = viewer->vadjustment->lower;
- }
+ viewer->hadjustment->value = (((viewer->hadjustment->value +
+ (viewer->hadjustment->page_size / 2)) *
+ (scale)) / (*img_scale)) - (viewer->hadjustment->page_size / 2);
+ viewer->vadjustment->value = (((viewer->vadjustment->value +
+ (viewer->vadjustment->page_size / 2)) *
+ (scale)) / (*img_scale)) - (viewer->vadjustment->page_size / 2);
- gtk_adjustment_value_changed(viewer->hadjustment);
- gtk_adjustment_value_changed(viewer->vadjustment);
+ if((viewer->hadjustment->value + viewer->hadjustment->page_size) > viewer->hadjustment->upper)
+ {
+ viewer->hadjustment->value = viewer->hadjustment->upper - viewer->hadjustment->page_size;
+ }
+ if(viewer->hadjustment->value < viewer->hadjustment->lower)
+ {
+ viewer->hadjustment->value = viewer->hadjustment->lower;
+ }
+ if((viewer->vadjustment->value + viewer->vadjustment->page_size) > viewer->vadjustment->upper)
+ {
+ viewer->vadjustment->value = viewer->vadjustment->upper - viewer->vadjustment->page_size;
+ }
+ if(viewer->vadjustment->value < viewer->vadjustment->lower)
+ {
+ viewer->vadjustment->value = viewer->vadjustment->lower;
+ }
- }
-}
+ gtk_adjustment_value_changed(viewer->hadjustment);
+ gtk_adjustment_value_changed(viewer->vadjustment);
-gdouble
-rstto_picture_viewer_fit_scale(RsttoPictureViewer *viewer)
-{
- RsttoNavigatorEntry *entry = rstto_navigator_get_file(viewer->priv->navigator);
- if (entry)
- {
- rstto_navigator_entry_set_fit_to_screen (entry, TRUE);
+ /**
+ * Set these settings at the end of the function,
+ * since the old and new values are required in the above code
+ */
+ *img_scale = scale;
- if(rstto_picture_viewer_refresh(viewer))
- {
- rstto_picture_viewer_paint(GTK_WIDGET(viewer));
+ rstto_picture_viewer_queued_repaint (viewer, TRUE);
}
- return rstto_navigator_entry_get_scale(entry);
}
- return 0;
}
gdouble
rstto_picture_viewer_get_scale(RsttoPictureViewer *viewer)
{
- RsttoNavigatorEntry *entry = rstto_navigator_get_file(viewer->priv->navigator);
- if (entry)
+ gdouble *scale;
+ if (viewer->priv->image)
{
- return rstto_navigator_entry_get_scale(entry);
+ scale = g_object_get_data (G_OBJECT (viewer->priv->image), "viewer-scale");
+ return *scale;
}
return 0;
}
-static gboolean
-rstto_picture_viewer_refresh(RsttoPictureViewer *viewer)
+/**
+ * rstto_picture_viewer_calculate_scale:
+ * @viewer:
+ *
+ */
+static gdouble
+rstto_picture_viewer_calculate_scale (RsttoPictureViewer *viewer)
{
- GtkWidget *widget = GTK_WIDGET(viewer);
- gboolean fit_to_screen = FALSE;
- gdouble scale = 0;
- RsttoNavigatorEntry *entry = rstto_navigator_get_file(viewer->priv->navigator);
- gboolean changed = TRUE;
- if (entry)
+ gint width = 0, height = 0;
+
+ if (viewer->priv->image != NULL)
+ {
+ switch(rstto_image_get_orientation (viewer->priv->image))
+ {
+ default:
+ width = rstto_image_get_width (viewer->priv->image);
+ height = rstto_image_get_height (viewer->priv->image);
+ break;
+ case RSTTO_IMAGE_ORIENT_270:
+ case RSTTO_IMAGE_ORIENT_90:
+ height = rstto_image_get_width (viewer->priv->image);
+ width = rstto_image_get_height (viewer->priv->image);
+ break;
+ }
+ }
+
+ if (width > 0 && height > 0)
{
- fit_to_screen = rstto_navigator_entry_get_fit_to_screen(entry);
- scale = rstto_navigator_entry_get_scale(entry);
+ if ((gdouble)(GTK_WIDGET (viewer)->allocation.width / (gdouble)width) <
+ ((gdouble)GTK_WIDGET (viewer)->allocation.height / (gdouble)height))
+ {
+ return (gdouble)GTK_WIDGET (viewer)->allocation.width / (gdouble)width;
+ }
+ else
+ {
+ return (gdouble)GTK_WIDGET (viewer)->allocation.height / (gdouble)height;
+ }
}
-
+ return -1;
+}
- gboolean vadjustment_changed = FALSE;
- gboolean hadjustment_changed = FALSE;
+static void
+cb_rstto_picture_viewer_scroll_event (RsttoPictureViewer *viewer, GdkEventScroll *event)
+{
+ /*
+ RsttoImageListEntry *entry = rstto_image_list_get_file(viewer->priv->image_list);
- if (viewer->priv->src_pixbuf != NULL && entry == NULL)
+ if (entry == NULL)
{
- gdk_pixbuf_unref(viewer->priv->src_pixbuf);
- viewer->priv->src_pixbuf = NULL;
+ return;
}
- if(viewer->priv->src_pixbuf)
+ gdouble scale = rstto_image_list_entry_get_scale(entry);
+ viewer->priv->zoom_mode = RSTTO_ZOOM_MODE_CUSTOM;
+ switch(event->direction)
{
- gdouble width = (gdouble)gdk_pixbuf_get_width(viewer->priv->src_pixbuf);
- gdouble height = (gdouble)gdk_pixbuf_get_height(viewer->priv->src_pixbuf);
- if (scale == 0)
- {
- if ((widget->allocation.width > width) && (widget->allocation.height > height))
- {
- scale = 1.0;
- rstto_navigator_entry_set_scale(entry, scale);
- rstto_navigator_entry_set_fit_to_screen(entry, FALSE);
- fit_to_screen = FALSE;
- }
- else
+ case GDK_SCROLL_UP:
+ case GDK_SCROLL_LEFT:
+ if (scale= 0.05)
+ return;
+ if (viewer->priv->refresh.idle_id > 0)
{
- fit_to_screen = TRUE;
- rstto_navigator_entry_set_fit_to_screen(entry, TRUE);
+ g_source_remove(viewer->priv->refresh.idle_id);
}
- }
+ rstto_image_list_entry_set_scale(entry, scale / 1.1);
+ rstto_image_list_entry_set_fit_to_screen (entry, FALSE);
- switch (viewer->priv->zoom_mode)
- {
- case RSTTO_ZOOM_MODE_FIT:
- fit_to_screen = TRUE;
- rstto_navigator_entry_set_fit_to_screen(entry, TRUE);
- break;
- case RSTTO_ZOOM_MODE_100:
- fit_to_screen = FALSE;
- scale = 1.0;
- rstto_navigator_entry_set_scale(entry, scale);
- break;
- case RSTTO_ZOOM_MODE_CUSTOM:
- break;
- }
+ viewer->vadjustment->value = ((viewer->vadjustment->value + event->y) / 1.1) - event->y;
+ viewer->hadjustment->value = ((viewer->hadjustment->value + event->x) / 1.1) - event->x;
- if(fit_to_screen)
- {
- gdouble h_scale = GTK_WIDGET(viewer)->allocation.width / width;
- gdouble v_scale = GTK_WIDGET(viewer)->allocation.height / height;
- if(h_scale < v_scale)
- {
- if(scale != h_scale)
- {
- scale = h_scale;
- changed = TRUE;
- }
- rstto_navigator_entry_set_scale(entry, h_scale);
- }
- else
- {
- if(scale != v_scale)
- {
- scale = v_scale;
- changed = TRUE;
- }
- rstto_navigator_entry_set_scale(entry, v_scale);
- }
- }
- if(GTK_WIDGET_REALIZED(widget))
- {
- gdouble width = (gdouble)gdk_pixbuf_get_width(viewer->priv->src_pixbuf);
- gdouble height = (gdouble)gdk_pixbuf_get_height(viewer->priv->src_pixbuf);
-
- if(viewer->hadjustment)
- {
- viewer->hadjustment->page_size = widget->allocation.width;
- viewer->hadjustment->upper = width * scale;
- viewer->hadjustment->lower = 0;
- viewer->hadjustment->step_increment = 1;
- viewer->hadjustment->page_increment = 100;
- if((viewer->hadjustment->value + viewer->hadjustment->page_size) > viewer->hadjustment->upper)
- {
- viewer->hadjustment->value = viewer->hadjustment->upper - viewer->hadjustment->page_size;
- hadjustment_changed = TRUE;
- }
- if(viewer->hadjustment->value < viewer->hadjustment->lower)
- {
- viewer->hadjustment->value = viewer->hadjustment->lower;
- hadjustment_changed = TRUE;
- }
- }
- if(viewer->vadjustment)
+ viewer->priv->refresh.idle_id = g_idle_add((GSourceFunc)cb_rstto_picture_viewer_queued_repaint, viewer);
+ break;
+ case GDK_SCROLL_DOWN:
+ case GDK_SCROLL_RIGHT:
+ if (scale >= 16)
+ return;
+ if (viewer->priv->refresh.idle_id > 0)
{
- viewer->vadjustment->page_size = widget->allocation.height;
- viewer->vadjustment->upper = height * scale;
- viewer->vadjustment->lower = 0;
- viewer->vadjustment->step_increment = 1;
- viewer->vadjustment->page_increment = 100;
- if((viewer->vadjustment->value + viewer->vadjustment->page_size) > viewer->vadjustment->upper)
- {
- viewer->vadjustment->value = viewer->vadjustment->upper - viewer->vadjustment->page_size;
- vadjustment_changed = TRUE;
- }
- if(viewer->vadjustment->value < viewer->vadjustment->lower)
- {
- viewer->vadjustment->value = viewer->vadjustment->lower;
- vadjustment_changed = TRUE;
- }
+ g_source_remove(viewer->priv->refresh.idle_id);
}
-
-
- GdkPixbuf *tmp_pixbuf = NULL;
- if (viewer->vadjustment && viewer->hadjustment)
- {
- if (1.0)
- {
- tmp_pixbuf = gdk_pixbuf_new_subpixbuf(viewer->priv->src_pixbuf,
- (gint)(viewer->hadjustment->value / scale),
- viewer->vadjustment->value / scale,
- ((widget->allocation.width/scale)) < width?
- widget->allocation.width/scale:width,
- ((widget->allocation.height/scale))< height?
- widget->allocation.height/scale:height);
- }
- else
- {
- tmp_pixbuf = viewer->priv->src_pixbuf;
- g_object_ref(tmp_pixbuf);
- }
- }
-
- if(viewer->priv->dst_pixbuf)
- {
- g_object_unref(viewer->priv->dst_pixbuf);
- viewer->priv->dst_pixbuf = NULL;
- }
-
- if(tmp_pixbuf)
- {
- gint dst_width = gdk_pixbuf_get_width(tmp_pixbuf)*scale;
- gint dst_height = gdk_pixbuf_get_height(tmp_pixbuf)*scale;
- viewer->priv->dst_pixbuf = gdk_pixbuf_scale_simple(tmp_pixbuf,
- dst_width>0?dst_width:1,
- dst_height>0?dst_height:1,
- GDK_INTERP_BILINEAR);
- g_object_unref(tmp_pixbuf);
- tmp_pixbuf = NULL;
- }
- if (viewer->vadjustment && viewer->hadjustment)
- {
- gtk_adjustment_changed(viewer->hadjustment);
- gtk_adjustment_changed(viewer->vadjustment);
- }
- if (hadjustment_changed == TRUE)
- gtk_adjustment_value_changed(viewer->hadjustment);
- if (vadjustment_changed == TRUE)
- gtk_adjustment_value_changed(viewer->vadjustment);
- }
- }
- else
- {
- if(viewer->priv->dst_pixbuf)
- {
- g_object_unref(viewer->priv->dst_pixbuf);
- viewer->priv->dst_pixbuf = NULL;
- }
- }
- return changed;
-}
-
-static void
-cb_rstto_picture_viewer_nav_iter_changed(RsttoNavigator *nav, gint nr, RsttoNavigatorEntry *entry, RsttoPictureViewer *viewer)
-{
- viewer->priv->entry = entry;
- if(entry)
- {
- rstto_navigator_entry_load_image(entry, FALSE);
- }
- else
- {
- rstto_picture_viewer_refresh(viewer);
- rstto_picture_viewer_paint(GTK_WIDGET(viewer));
- }
-}
-
-static void
-cb_rstto_picture_viewer_nav_entry_modified(RsttoNavigator *nav, RsttoNavigatorEntry *entry, RsttoPictureViewer *viewer)
-{
- if (entry == viewer->priv->entry)
- {
- if(viewer->priv->src_pixbuf)
- {
- gdk_pixbuf_unref(viewer->priv->src_pixbuf);
- }
- viewer->priv->src_pixbuf = rstto_navigator_entry_get_pixbuf(entry);
- if (viewer->priv->src_pixbuf)
- {
- gdk_pixbuf_ref(viewer->priv->src_pixbuf);
- }
- rstto_picture_viewer_refresh(viewer);
- rstto_picture_viewer_paint(GTK_WIDGET(viewer));
- }
-}
-
-static void
-cb_rstto_picture_viewer_scroll_event (RsttoPictureViewer *viewer, GdkEventScroll *event)
-{
- RsttoNavigatorEntry *entry = rstto_navigator_get_file(viewer->priv->navigator);
-
- if (entry == NULL)
- {
- return;
- }
-
- gdouble scale = rstto_navigator_entry_get_scale(entry);
- viewer->priv->zoom_mode = RSTTO_ZOOM_MODE_CUSTOM;
- switch(event->direction)
- {
- case GDK_SCROLL_UP:
- case GDK_SCROLL_LEFT:
- if (scale <= 0.05)
- return;
- if (viewer->priv->refresh.idle_id > 0)
- {
- g_source_remove(viewer->priv->refresh.idle_id);
- }
- rstto_navigator_entry_set_scale(entry, scale / 1.1);
- rstto_navigator_entry_set_fit_to_screen (entry, FALSE);
-
- viewer->vadjustment->value = ((viewer->vadjustment->value + event->y) / 1.1) - event->y;
- viewer->hadjustment->value = ((viewer->hadjustment->value + event->x) / 1.1) - event->x;
-
- viewer->priv->refresh.idle_id = g_idle_add((GSourceFunc)cb_rstto_picture_viewer_queued_repaint, viewer);
- break;
- case GDK_SCROLL_DOWN:
- case GDK_SCROLL_RIGHT:
- if (scale >= 16)
- return;
- if (viewer->priv->refresh.idle_id > 0)
- {
- g_source_remove(viewer->priv->refresh.idle_id);
- }
- rstto_navigator_entry_set_scale(entry, scale * 1.1);
- rstto_navigator_entry_set_fit_to_screen (entry, FALSE);
+ rstto_image_list_entry_set_scale(entry, scale * 1.1);
+ rstto_image_list_entry_set_fit_to_screen (entry, FALSE);
+>>>>>>> 9b75414e8bb4500c58635dd45ecb8f2f45266902:src/picture_viewer.c
viewer->vadjustment->value = ((viewer->vadjustment->value + event->y) * 1.1) - event->y;
@@ -919,6 +866,9 @@ cb_rstto_picture_viewer_scroll_event (RsttoPictureViewer *viewer, GdkEventScroll
viewer->priv->refresh.idle_id = g_idle_add((GSourceFunc)cb_rstto_picture_viewer_queued_repaint, viewer);
break;
}
+<<<<<<< HEAD:src/picture_viewer.c
+=======
+ */
}
static gboolean
@@ -931,15 +881,9 @@ cb_rstto_picture_viewer_motion_notify_event (RsttoPictureViewer *viewer,
viewer->priv->motion.current_x = event->x;
viewer->priv->motion.current_y = event->y;
- if (viewer->priv->refresh.idle_id > 0)
- {
- g_source_remove(viewer->priv->refresh.idle_id);
- viewer->priv->refresh.idle_id = 0;
- }
-
switch (viewer->priv->motion.state)
{
- case RSTTO_PICTURE_VIEWER_STATE_MOVE:
+ case RSTTO_PICTURE_VIEWER_MOTION_STATE_MOVE:
if (viewer->priv->motion.x != viewer->priv->motion.current_x)
{
gint val = viewer->hadjustment->value;
@@ -972,8 +916,8 @@ cb_rstto_picture_viewer_motion_notify_event (RsttoPictureViewer *viewer,
gtk_adjustment_value_changed(viewer->vadjustment);
}
break;
- case RSTTO_PICTURE_VIEWER_STATE_BOX_ZOOM:
- viewer->priv->refresh.idle_id = g_idle_add((GSourceFunc)cb_rstto_picture_viewer_queued_repaint, viewer);
+ case RSTTO_PICTURE_VIEWER_MOTION_STATE_BOX_ZOOM:
+ rstto_picture_viewer_queued_repaint (viewer, FALSE);
break;
default:
break;
@@ -982,16 +926,352 @@ cb_rstto_picture_viewer_motion_notify_event (RsttoPictureViewer *viewer,
return FALSE;
}
+static void
+rstto_picture_viewer_calculate_adjustments (RsttoPictureViewer *viewer, gdouble scale)
+{
+ GdkPixbuf *p_src_pixbuf;
+ GtkWidget *widget = GTK_WIDGET (viewer);
+ gdouble image_width, image_height;
+ gdouble pixbuf_width, pixbuf_height;
+ gdouble image_scale;
+ gboolean vadjustment_changed = FALSE;
+ gboolean hadjustment_changed = FALSE;
+
+ if (viewer->priv->image != NULL)
+ {
+ p_src_pixbuf = rstto_image_get_pixbuf (viewer->priv->image);
+ if (p_src_pixbuf != NULL)
+ {
+ image_width = (gdouble)rstto_image_get_width (viewer->priv->image);
+ image_height = (gdouble)rstto_image_get_height (viewer->priv->image);
+
+ pixbuf_width = (gdouble)gdk_pixbuf_get_width (p_src_pixbuf);
+ pixbuf_height = (gdouble)gdk_pixbuf_get_height (p_src_pixbuf);
+
+ image_scale = pixbuf_width / image_width;
+
+ switch (rstto_image_get_orientation (viewer->priv->image))
+ {
+ default:
+ if(viewer->hadjustment)
+ {
+ viewer->hadjustment->page_size = widget->allocation.width / image_scale;
+ viewer->hadjustment->upper = image_width * (scale / image_scale);
+ viewer->hadjustment->lower = 0;
+ viewer->hadjustment->step_increment = 1;
+ viewer->hadjustment->page_increment = 100;
+ if((viewer->hadjustment->value + viewer->hadjustment->page_size) > viewer->hadjustment->upper)
+ {
+ viewer->hadjustment->value = viewer->hadjustment->upper - viewer->hadjustment->page_size;
+ hadjustment_changed = TRUE;
+ }
+ if(viewer->hadjustment->value < viewer->hadjustment->lower)
+ {
+ viewer->hadjustment->value = viewer->hadjustment->lower;
+ hadjustment_changed = TRUE;
+ }
+ }
+ if(viewer->vadjustment)
+ {
+ viewer->vadjustment->page_size = widget->allocation.height / image_scale;
+ viewer->vadjustment->upper = image_height * (scale / image_scale);
+ viewer->vadjustment->lower = 0;
+ viewer->vadjustment->step_increment = 1;
+ viewer->vadjustment->page_increment = 100;
+ if((viewer->vadjustment->value + viewer->vadjustment->page_size) > viewer->vadjustment->upper)
+ {
+ viewer->vadjustment->value = viewer->vadjustment->upper - viewer->vadjustment->page_size;
+ vadjustment_changed = TRUE;
+ }
+ if(viewer->vadjustment->value < viewer->vadjustment->lower)
+ {
+ viewer->vadjustment->value = viewer->vadjustment->lower;
+ vadjustment_changed = TRUE;
+ }
+ }
+ break;
+ case RSTTO_IMAGE_ORIENT_270:
+ case RSTTO_IMAGE_ORIENT_90:
+ if(viewer->hadjustment)
+ {
+ viewer->hadjustment->page_size = widget->allocation.width / image_scale;
+ viewer->hadjustment->upper = image_height * (scale / image_scale);
+ viewer->hadjustment->lower = 0;
+ viewer->hadjustment->step_increment = 1;
+ viewer->hadjustment->page_increment = 100;
+ if((viewer->hadjustment->value + viewer->hadjustment->page_size) > viewer->hadjustment->upper)
+ {
+ viewer->hadjustment->value = viewer->hadjustment->upper - viewer->hadjustment->page_size;
+ hadjustment_changed = TRUE;
+ }
+ if(viewer->hadjustment->value < viewer->hadjustment->lower)
+ {
+ viewer->hadjustment->value = viewer->hadjustment->lower;
+ hadjustment_changed = TRUE;
+ }
+ }
+ if(viewer->vadjustment)
+ {
+ viewer->vadjustment->page_size = widget->allocation.height / image_scale;
+ viewer->vadjustment->upper = image_width * (scale / image_scale);
+ viewer->vadjustment->lower = 0;
+ viewer->vadjustment->step_increment = 1;
+ viewer->vadjustment->page_increment = 100;
+ if((viewer->vadjustment->value + viewer->vadjustment->page_size) > viewer->vadjustment->upper)
+ {
+ viewer->vadjustment->value = viewer->vadjustment->upper - viewer->vadjustment->page_size;
+ vadjustment_changed = TRUE;
+ }
+ if(viewer->vadjustment->value < viewer->vadjustment->lower)
+ {
+ viewer->vadjustment->value = viewer->vadjustment->lower;
+ vadjustment_changed = TRUE;
+ }
+ }
+ break;
+ }
+
+ if (viewer->vadjustment && viewer->hadjustment)
+ {
+ gtk_adjustment_changed(viewer->hadjustment);
+ gtk_adjustment_changed(viewer->vadjustment);
+ }
+ if (hadjustment_changed == TRUE)
+ gtk_adjustment_value_changed(viewer->hadjustment);
+ if (vadjustment_changed == TRUE)
+ gtk_adjustment_value_changed(viewer->vadjustment);
+ }
+ }
+
+}
+
+static void
+rstto_picture_viewer_queued_repaint (RsttoPictureViewer *viewer, gboolean refresh)
+{
+ if (viewer->priv->repaint.idle_id > 0)
+ {
+ g_source_remove(viewer->priv->repaint.idle_id);
+ }
+ if (refresh)
+ {
+ viewer->priv->repaint.refresh = TRUE;
+ }
+ viewer->priv->repaint.idle_id = g_idle_add((GSourceFunc)cb_rstto_picture_viewer_queued_repaint, viewer);
+}
+
static gboolean
-cb_rstto_picture_viewer_queued_repaint(RsttoPictureViewer *viewer)
+cb_rstto_picture_viewer_queued_repaint (RsttoPictureViewer *viewer)
{
- rstto_picture_viewer_refresh(viewer);
- rstto_picture_viewer_paint(GTK_WIDGET(viewer));
- g_source_remove(viewer->priv->refresh.idle_id);
- viewer->priv->refresh.idle_id = -1;
+ GdkPixbuf *p_src_pixbuf = NULL;
+ GdkPixbuf *p_tmp_pixbuf = NULL;
+ GdkPixbuf *p_tmp_pixbuf2 = NULL;
+ gdouble *p_scale = NULL;
+ gboolean *p_fit_to_screen= NULL;
+ gdouble scale = 1;
+ gdouble image_scale = 1;
+ gdouble thumb_scale = 1;
+ gdouble thumb_width = 0;
+ gboolean fit_to_screen = FALSE;
+ gdouble image_width = 0, image_height = 0;
+ gdouble pixbuf_width, pixbuf_height;
+ GtkWidget *widget = GTK_WIDGET (viewer);
+
+ if (viewer->priv->image != NULL)
+ {
+ image_width = (gdouble)rstto_image_get_width (viewer->priv->image);
+ image_height = (gdouble)rstto_image_get_height (viewer->priv->image);
+
+ switch (viewer->priv->state)
+ {
+ case RSTTO_PICTURE_VIEWER_STATE_NORMAL:
+ p_src_pixbuf = rstto_image_get_pixbuf (viewer->priv->image);
+ if (p_src_pixbuf)
+ {
+ pixbuf_width = (gdouble)gdk_pixbuf_get_width (p_src_pixbuf);
+ pixbuf_height = (gdouble)gdk_pixbuf_get_height (p_src_pixbuf);
+
+ image_scale = pixbuf_width / image_width;
+ }
+ break;
+ case RSTTO_PICTURE_VIEWER_STATE_PREVIEW:
+ p_src_pixbuf = rstto_image_get_thumbnail (viewer->priv->image);
+ if (p_src_pixbuf)
+ {
+ thumb_width = (gdouble)gdk_pixbuf_get_width (p_src_pixbuf);
+ thumb_scale = (thumb_width / image_width);
+ }
+ else
+ return FALSE;
+ break;
+ default:
+ break;
+ }
+
+ p_scale = g_object_get_data (G_OBJECT (viewer->priv->image), "viewer-scale");
+ p_fit_to_screen = g_object_get_data (G_OBJECT (viewer->priv->image), "viewer-fit-to-screen");
+ scale = *p_scale;
+ fit_to_screen = *p_fit_to_screen;
+
+ if ((scale <= 0) || (fit_to_screen == TRUE))
+ {
+ scale = rstto_picture_viewer_calculate_scale (viewer);
+ *p_fit_to_screen = TRUE;
+ *p_scale = scale;
+ }
+ }
+
+
+ rstto_picture_viewer_calculate_adjustments (viewer, scale);
+
+
+ if (viewer->priv->repaint.refresh)
+ {
+ if(viewer->priv->dst_pixbuf)
+ {
+ g_object_unref(viewer->priv->dst_pixbuf);
+ viewer->priv->dst_pixbuf = NULL;
+ }
+ if (p_src_pixbuf)
+ {
+ gdouble x, y;
+
+ switch (rstto_image_get_orientation (viewer->priv->image))
+ {
+ default:
+ case RSTTO_IMAGE_ORIENT_NONE:
+ x = viewer->hadjustment->value * image_scale;
+ y = viewer->vadjustment->value * image_scale;
+ p_tmp_pixbuf = gdk_pixbuf_new_subpixbuf (p_src_pixbuf,
+ (gint)(x/scale * thumb_scale * image_scale),
+ (gint)(y/scale * thumb_scale * image_scale),
+ (gint)((widget->allocation.width / scale) < image_width?
+ (widget->allocation.width / scale)*thumb_scale*image_scale:image_width*thumb_scale*image_scale),
+ (gint)((widget->allocation.height / scale) < image_height?
+ (widget->allocation.height / scale)*image_scale*thumb_scale:image_height*thumb_scale*image_scale));
+ break;
+ case RSTTO_IMAGE_ORIENT_90:
+ x = viewer->vadjustment->value * image_scale;
+ y = (viewer->hadjustment->upper - (viewer->hadjustment->value + viewer->hadjustment->page_size)) * image_scale;
+ if (y < 0) y = 0;
+ //y = viewer->hadjustment->value * image_scale;
+ p_tmp_pixbuf = gdk_pixbuf_new_subpixbuf (p_src_pixbuf,
+ (gint)(x/scale * thumb_scale * image_scale),
+ (gint)(y/scale * thumb_scale * image_scale),
+ (gint)((widget->allocation.height/ scale) < image_width?
+ (widget->allocation.height/ scale)*thumb_scale*image_scale:image_width*thumb_scale*image_scale),
+ (gint)((widget->allocation.width/ scale) < image_height?
+ (widget->allocation.width/ scale)*image_scale*thumb_scale:image_height*thumb_scale*image_scale));
+ if (p_tmp_pixbuf)
+ {
+ p_tmp_pixbuf2 = gdk_pixbuf_rotate_simple (p_tmp_pixbuf, GDK_PIXBUF_ROTATE_CLOCKWISE);
+ g_object_unref (p_tmp_pixbuf);
+ p_tmp_pixbuf = p_tmp_pixbuf2;
+ }
+ break;
+ case RSTTO_IMAGE_ORIENT_180:
+ x = (viewer->hadjustment->upper - (viewer->hadjustment->value + viewer->hadjustment->page_size)) * image_scale;
+ if (x < 0) x = 0;
+ y = (viewer->vadjustment->upper - (viewer->vadjustment->value + viewer->vadjustment->page_size)) * image_scale;
+ if (y < 0) y = 0;
+ //y = viewer->hadjustment->value * image_scale;
+ p_tmp_pixbuf = gdk_pixbuf_new_subpixbuf (p_src_pixbuf,
+ (gint)(x/scale * thumb_scale * image_scale),
+ (gint)(y/scale * thumb_scale * image_scale),
+ (gint)((widget->allocation.width / scale) < image_width?
+ (widget->allocation.width / scale)*thumb_scale*image_scale:image_width*thumb_scale*image_scale),
+ (gint)((widget->allocation.height/ scale) < image_width?
+ (widget->allocation.height/ scale)*image_scale*thumb_scale:image_height*thumb_scale*image_scale));
+ if (p_tmp_pixbuf)
+ {
+ p_tmp_pixbuf2 = gdk_pixbuf_rotate_simple (p_tmp_pixbuf, GDK_PIXBUF_ROTATE_UPSIDEDOWN);
+ g_object_unref (p_tmp_pixbuf);
+ p_tmp_pixbuf = p_tmp_pixbuf2;
+ }
+ break;
+ case RSTTO_IMAGE_ORIENT_270:
+ x = (viewer->vadjustment->upper - (viewer->vadjustment->value + viewer->vadjustment->page_size)) * image_scale;
+ if (x < 0) x = 0;
+ y = viewer->hadjustment->value * image_scale;
+ p_tmp_pixbuf = gdk_pixbuf_new_subpixbuf (p_src_pixbuf,
+ (gint)(x/scale * thumb_scale * image_scale),
+ (gint)(y/scale * thumb_scale * image_scale),
+ (gint)((widget->allocation.height/ scale) < image_width?
+ (widget->allocation.height/ scale)*thumb_scale*image_scale:image_width*thumb_scale*image_scale),
+ (gint)((widget->allocation.width/ scale) < image_height?
+ (widget->allocation.width/ scale)*image_scale*thumb_scale:image_height*thumb_scale*image_scale));
+ if (p_tmp_pixbuf)
+ {
+ p_tmp_pixbuf2 = gdk_pixbuf_rotate_simple (p_tmp_pixbuf, GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE);
+ g_object_unref (p_tmp_pixbuf);
+ p_tmp_pixbuf = p_tmp_pixbuf2;
+ }
+ break;
+ }
+ /**
+ * tmp_scale is the factor between the original image and the thumbnail,
+ * when looking at the actual image, tmp_scale == 1.0
+ */
+ /*
+ gdouble x = viewer->hadjustment->value * image_scale;
+ gdouble y = viewer->vadjustment->value * image_scale;
+
+ p_tmp_pixbuf = gdk_pixbuf_new_subpixbuf (p_src_pixbuf,
+ (gint)(x/scale * thumb_scale * image_scale),
+ (gint)(y/scale * thumb_scale * image_scale),
+ (gint)((widget->allocation.width / scale) < image_width?
+ (widget->allocation.width / scale)*thumb_scale*image_scale:image_width*thumb_scale*image_scale),
+ (gint)((widget->allocation.height / scale) < image_height?
+ (widget->allocation.height / scale)*image_scale*thumb_scale:image_height*thumb_scale*image_scale));
+ */
+
+ if(p_tmp_pixbuf)
+ {
+ gint dst_width = gdk_pixbuf_get_width (p_tmp_pixbuf)*(scale/thumb_scale/image_scale);
+ gint dst_height = gdk_pixbuf_get_height (p_tmp_pixbuf)*(scale/thumb_scale/image_scale);
+ viewer->priv->dst_pixbuf = gdk_pixbuf_scale_simple (p_tmp_pixbuf,
+ dst_width>0?dst_width:1,
+ dst_height>0?dst_height:1,
+ GDK_INTERP_BILINEAR);
+ g_object_unref (p_tmp_pixbuf);
+ p_tmp_pixbuf = NULL;
+ }
+ }
+ }
+
+
+ rstto_picture_viewer_paint (GTK_WIDGET (viewer));
+
+ g_source_remove (viewer->priv->repaint.idle_id);
+ viewer->priv->repaint.idle_id = -1;
+ viewer->priv->repaint.refresh = FALSE;
return FALSE;
}
+static RsttoPictureViewerState
+rstto_picture_viewer_get_state (RsttoPictureViewer *viewer)
+{
+ return viewer->priv->state;
+}
+
+
+static void
+rstto_picture_viewer_set_state (RsttoPictureViewer *viewer, RsttoPictureViewerState state)
+{
+ viewer->priv->state = state;
+}
+
+static void
+rstto_picture_viewer_set_motion_state (RsttoPictureViewer *viewer, RsttoPictureViewerMotionState state)
+{
+ viewer->priv->motion.state = state;
+}
+
+static RsttoPictureViewerMotionState
+rstto_picture_viewer_get_motion_state (RsttoPictureViewer *viewer)
+{
+ return viewer->priv->motion.state;
+}
+
static void
cb_rstto_picture_viewer_button_press_event (RsttoPictureViewer *viewer, GdkEventButton *event)
{
@@ -1004,7 +1284,7 @@ cb_rstto_picture_viewer_button_press_event (RsttoPictureViewer *viewer, GdkEvent
viewer->priv->motion.h_val = viewer->hadjustment->value;
viewer->priv->motion.v_val = viewer->vadjustment->value;
- if (rstto_navigator_get_file(viewer->priv->navigator) != NULL)
+ if (viewer->priv->image != NULL && rstto_picture_viewer_get_state (viewer) == RSTTO_PICTURE_VIEWER_STATE_NORMAL)
{
if (!(event->state & (GDK_CONTROL_MASK)))
@@ -1014,7 +1294,7 @@ cb_rstto_picture_viewer_button_press_event (RsttoPictureViewer *viewer, GdkEvent
gdk_window_set_cursor(widget->window, cursor);
gdk_cursor_unref(cursor);
- viewer->priv->motion.state = RSTTO_PICTURE_VIEWER_STATE_MOVE;
+ rstto_picture_viewer_set_motion_state (viewer, RSTTO_PICTURE_VIEWER_MOTION_STATE_MOVE);
}
if (event->state & GDK_CONTROL_MASK)
@@ -1024,7 +1304,7 @@ cb_rstto_picture_viewer_button_press_event (RsttoPictureViewer *viewer, GdkEvent
gdk_window_set_cursor(widget->window, cursor);
gdk_cursor_unref(cursor);
- viewer->priv->motion.state = RSTTO_PICTURE_VIEWER_STATE_BOX_ZOOM;
+ rstto_picture_viewer_set_motion_state (viewer, RSTTO_PICTURE_VIEWER_MOTION_STATE_BOX_ZOOM);
}
}
@@ -1049,136 +1329,28 @@ cb_rstto_picture_viewer_button_press_event (RsttoPictureViewer *viewer, GdkEvent
static void
cb_rstto_picture_viewer_button_release_event (RsttoPictureViewer *viewer, GdkEventButton *event)
{
- if(event->button == 1)
+ GtkWidget *widget = GTK_WIDGET(viewer);
+ switch (event->button)
{
- GtkWidget *widget = GTK_WIDGET(viewer);
- gdk_window_set_cursor(widget->window, NULL);
- switch (viewer->priv->motion.state)
- {
- case RSTTO_PICTURE_VIEWER_STATE_NONE:
- break;
- case RSTTO_PICTURE_VIEWER_STATE_MOVE:
- break;
- case RSTTO_PICTURE_VIEWER_STATE_BOX_ZOOM:
- viewer->priv->zoom_mode = RSTTO_ZOOM_MODE_CUSTOM;
- if(GTK_WIDGET_REALIZED(widget))
- {
- RsttoNavigatorEntry *entry = rstto_navigator_get_file(viewer->priv->navigator);
- gdouble scale = rstto_navigator_entry_get_scale(entry);
- gdouble old_scale = scale;
- gdouble width = (gdouble)gdk_pixbuf_get_width(viewer->priv->src_pixbuf);
- gdouble height = (gdouble)gdk_pixbuf_get_height(viewer->priv->src_pixbuf);
-
- gdouble d_width = (gdouble)gdk_pixbuf_get_width(viewer->priv->dst_pixbuf);
- gdouble d_height = (gdouble)gdk_pixbuf_get_height(viewer->priv->dst_pixbuf);
-
- gdouble box_width, box_height;
- gdouble top_left_x, top_left_y;
-
- if (viewer->priv->motion.x < viewer->priv->motion.current_x)
- {
- gint x_offset = (widget->allocation.width - d_width)<=0?0:((widget->allocation.width - d_width)/2);
- top_left_x = viewer->priv->motion.x + viewer->hadjustment->value - x_offset;
- box_width = viewer->priv->motion.current_x - viewer->priv->motion.x;
- }
- else
- {
- gint x_offset = (widget->allocation.width - d_width)<=0?0:((widget->allocation.width - d_width)/2);
- top_left_x = viewer->priv->motion.current_x + viewer->hadjustment->value - x_offset;
- box_width = viewer->priv->motion.x - viewer->priv->motion.current_x;
- }
- if (viewer->priv->motion.y < viewer->priv->motion.current_y)
- {
- gint y_offset = (widget->allocation.height - d_height)<=0?0:((widget->allocation.height - d_height)/2);
- top_left_y = viewer->priv->motion.y + viewer->vadjustment->value - y_offset;
- box_height = viewer->priv->motion.current_y - viewer->priv->motion.y;
- }
- else
+ case 1:
+ gdk_window_set_cursor(widget->window, NULL);
+ switch (rstto_picture_viewer_get_motion_state (viewer))
+ {
+ case RSTTO_PICTURE_VIEWER_MOTION_STATE_BOX_ZOOM:
+ rstto_picture_viewer_set_zoom_mode (viewer, RSTTO_ZOOM_MODE_CUSTOM);
+ if(GTK_WIDGET_REALIZED(widget))
{
- gint y_offset = (widget->allocation.height - d_height) <=0?0:((widget->allocation.height - d_height)/2);
- top_left_y = viewer->priv->motion.current_y + viewer->vadjustment->value - y_offset;
- box_height = viewer->priv->motion.y - viewer->priv->motion.current_y;
}
-
- gdouble h_scale = widget->allocation.width / box_width * scale;
- gdouble v_scale = widget->allocation.height / box_height * scale;
-
- /**
- * Check if the mouse has been moved (and there exists a box
- */
- if (box_height > 1 && box_width > 1)
- {
- if (h_scale < v_scale)
- {
- rstto_navigator_entry_set_scale(entry, h_scale);
- gdouble d_box_height = box_height * v_scale / h_scale;
- top_left_y -= (d_box_height - box_height) / 2;
- box_height = d_box_height;
- }
- else
- {
- rstto_navigator_entry_set_scale(entry, v_scale);
- gdouble d_box_width = box_width * h_scale / v_scale;
- top_left_x -= (d_box_width - box_width) / 2;
- box_width = d_box_width;
- }
-
- rstto_navigator_entry_set_fit_to_screen(entry, FALSE);
- scale = rstto_navigator_entry_get_scale(entry);
-
- if(viewer->hadjustment)
- {
- viewer->hadjustment->page_size = box_width / old_scale * scale;
- viewer->hadjustment->upper = width * scale;
- viewer->hadjustment->lower = 0;
- viewer->hadjustment->step_increment = 1;
- viewer->hadjustment->page_increment = 100;
- viewer->hadjustment->value = top_left_x / old_scale * scale;
- if((viewer->hadjustment->value + viewer->hadjustment->page_size) > viewer->hadjustment->upper)
- {
- viewer->hadjustment->value = viewer->hadjustment->upper - viewer->hadjustment->page_size;
- }
- if(viewer->hadjustment->value < viewer->hadjustment->lower)
- {
- viewer->hadjustment->value = viewer->hadjustment->lower;
- }
- gtk_adjustment_changed(viewer->hadjustment);
- gtk_adjustment_value_changed(viewer->hadjustment);
- }
- if(viewer->vadjustment)
- {
- viewer->vadjustment->page_size = box_height /old_scale* scale;
- viewer->vadjustment->upper = height * scale;
- viewer->vadjustment->lower = 0;
- viewer->vadjustment->step_increment = 1;
- viewer->vadjustment->page_increment = 100;
- viewer->vadjustment->value = top_left_y / old_scale * scale;
- if((viewer->vadjustment->value + viewer->vadjustment->page_size) > viewer->vadjustment->upper)
- {
- viewer->vadjustment->value = viewer->vadjustment->upper - viewer->vadjustment->page_size;
- }
- if(viewer->vadjustment->value < viewer->vadjustment->lower)
- {
- viewer->vadjustment->value = viewer->vadjustment->lower;
- }
- gtk_adjustment_changed(viewer->vadjustment);
- gtk_adjustment_value_changed(viewer->vadjustment);
- }
- }
- }
- if (viewer->priv->refresh.idle_id > 0)
- {
- g_source_remove(viewer->priv->refresh.idle_id);
- }
- viewer->priv->refresh.idle_id = g_idle_add((GSourceFunc)cb_rstto_picture_viewer_queued_repaint, viewer);
- break;
- }
-
+ break;
+ default:
+ break;
+ }
+ rstto_picture_viewer_set_motion_state (viewer, RSTTO_PICTURE_VIEWER_MOTION_STATE_NORMAL);
+ rstto_picture_viewer_queued_repaint (viewer, FALSE);
+ break;
}
- viewer->priv->motion.state = RSTTO_PICTURE_VIEWER_STATE_NONE;
-
}
static void
@@ -1202,142 +1374,227 @@ rstto_picture_viewer_set_menu (RsttoPictureViewer *viewer, GtkMenu *menu)
{
if (viewer->priv->menu)
{
- gtk_menu_detach(viewer->priv->menu);
- gtk_widget_destroy(GTK_WIDGET(viewer->priv->menu));
+ gtk_menu_detach (viewer->priv->menu);
+ gtk_widget_destroy (GTK_WIDGET(viewer->priv->menu));
}
viewer->priv->menu = menu;
if (viewer->priv->menu)
{
- gtk_menu_attach_to_widget(viewer->priv->menu, GTK_WIDGET(viewer), NULL);
+ gtk_menu_attach_to_widget (viewer->priv->menu, GTK_WIDGET(viewer), NULL);
}
}
-void
-rstto_picture_viewer_set_bg_color (RsttoPictureViewer *viewer, const GdkColor *color)
+static void
+rstto_picture_viewer_set_zoom_mode(RsttoPictureViewer *viewer, RsttoZoomMode mode)
+{
+ gdouble scale;
+ gboolean *p_fit_to_screen;
+ viewer->priv->zoom_mode = mode;
+
+ switch (viewer->priv->zoom_mode)
+ {
+ case RSTTO_ZOOM_MODE_CUSTOM:
+ if (viewer->priv->image)
+ {
+ p_fit_to_screen = g_object_get_data (G_OBJECT (viewer->priv->image), "viewer-fit-to-screen");
+ *p_fit_to_screen = FALSE;
+ g_object_set_data (G_OBJECT (viewer->priv->image), "viewer-fit-to-screen", p_fit_to_screen);
+ }
+ break;
+ case RSTTO_ZOOM_MODE_FIT:
+ if (viewer->priv->image)
+ {
+ p_fit_to_screen = g_object_get_data (G_OBJECT (viewer->priv->image), "viewer-fit-to-screen");
+ *p_fit_to_screen = TRUE;
+ g_object_set_data (G_OBJECT (viewer->priv->image), "viewer-fit-to-screen", p_fit_to_screen);
+ }
+ scale = rstto_picture_viewer_calculate_scale (viewer);
+ if (scale != -1.0)
+ rstto_picture_viewer_set_scale (viewer, scale);
+ break;
+ case RSTTO_ZOOM_MODE_100:
+ if (viewer->priv->image)
+ {
+ p_fit_to_screen = g_object_get_data (G_OBJECT (viewer->priv->image), "viewer-fit-to-screen");
+ *p_fit_to_screen = FALSE;
+ g_object_set_data (G_OBJECT (viewer->priv->image), "viewer-fit-to-screen", p_fit_to_screen);
+ }
+ rstto_picture_viewer_set_scale (viewer, 1);
+ break;
+ }
+}
+
+/**
+ * rstto_picture_viewer_set_image:
+ * @viewer :
+ * @image :
+ *
+ *
+ */
+static void
+rstto_picture_viewer_set_image (RsttoPictureViewer *viewer, RsttoImage *image)
{
- if (viewer->priv->bg_color)
+ gdouble *scale = NULL;
+ gboolean *fit_to_screen = NULL;
+
+ RsttoSettings *settings_manager = rstto_settings_new();
+ GValue max_size = {0,};
+
+ g_value_init (&max_size, G_TYPE_UINT);
+ g_object_get_property (G_OBJECT(settings_manager), "image-quality", &max_size);
+
+ if (viewer->priv->image)
+ {
+ g_signal_handlers_disconnect_by_func (viewer->priv->image, cb_rstto_picture_viewer_image_updated, viewer);
+ g_signal_handlers_disconnect_by_func (viewer->priv->image, cb_rstto_picture_viewer_image_prepared, viewer);
+ g_object_remove_weak_pointer (G_OBJECT (viewer->priv->image), (gpointer *)&viewer->priv->image);
+ }
+
+ viewer->priv->image = image;
+
+ if (viewer->priv->image)
{
- gdk_color_free(viewer->priv->bg_color);
- viewer->priv->bg_color = NULL;
+ g_object_add_weak_pointer (G_OBJECT (viewer->priv->image), (gpointer *)&viewer->priv->image);
+
+ g_signal_connect (G_OBJECT (viewer->priv->image), "updated", G_CALLBACK (cb_rstto_picture_viewer_image_updated), viewer);
+ g_signal_connect (G_OBJECT (viewer->priv->image), "prepared", G_CALLBACK (cb_rstto_picture_viewer_image_prepared), viewer);
+
+ scale = g_object_get_data (G_OBJECT (viewer->priv->image), "viewer-scale");
+ fit_to_screen = g_object_get_data (G_OBJECT (viewer->priv->image), "viewer-fit-to-screen");
+
+ if (scale == NULL)
+ {
+ scale = g_new0 (gdouble, 1);
+ *scale = -1.0;
+ g_object_set_data (G_OBJECT (viewer->priv->image), "viewer-scale", scale);
+ }
+ if (fit_to_screen == NULL)
+ {
+ fit_to_screen = g_new0 (gboolean, 1);
+ g_object_set_data (G_OBJECT (viewer->priv->image), "viewer-fit-to-screen", fit_to_screen);
+ }
+
+ rstto_image_load (viewer->priv->image, FALSE, g_value_get_uint (&max_size), FALSE, NULL);
}
- if (color)
+ else
{
- viewer->priv->bg_color = gdk_color_copy(color);
- GdkColormap *colormap = gtk_widget_get_colormap(GTK_WIDGET(viewer));
- gdk_colormap_alloc_color(colormap, viewer->priv->bg_color, TRUE, TRUE);
+ rstto_picture_viewer_queued_repaint (viewer, TRUE);
}
+ g_object_unref (settings_manager);
}
-const GdkColor *
-rstto_picture_viewer_get_bg_color (RsttoPictureViewer *viewer)
+/**
+ * cb_rstto_picture_viewer_image_updated:
+ * @image:
+ * @viewer:
+ *
+ */
+static void
+cb_rstto_picture_viewer_image_updated (RsttoImage *image, RsttoPictureViewer *viewer)
{
- return viewer->priv->bg_color;
+ rstto_picture_viewer_set_state (viewer, RSTTO_PICTURE_VIEWER_STATE_NORMAL);
+
+ rstto_picture_viewer_queued_repaint (viewer, TRUE);
}
+/**
+ * cb_rstto_picture_viewer_image_prepared:
+ * @image:
+ * @viewer:
+ *
+ */
+static void
+cb_rstto_picture_viewer_image_prepared (RsttoImage *image, RsttoPictureViewer *viewer)
+{
+ rstto_picture_viewer_set_state (viewer, RSTTO_PICTURE_VIEWER_STATE_PREVIEW);
+
+ rstto_picture_viewer_queued_repaint (viewer, TRUE);
+}
+
+/**
+ * rstto_picture_viewer_zoom_fit:
+ * @window:
+ *
+ * Adjust the scale to make the image fit the window
+ */
void
-rstto_picture_viewer_redraw(RsttoPictureViewer *viewer)
+rstto_picture_viewer_zoom_fit (RsttoPictureViewer *viewer)
{
- rstto_picture_viewer_refresh(viewer);
- rstto_picture_viewer_paint(GTK_WIDGET(viewer));
+ rstto_picture_viewer_set_zoom_mode (viewer, RSTTO_ZOOM_MODE_FIT);
}
+/**
+ * rstto_picture_viewer_zoom_100:
+ * @viewer:
+ *
+ * Set the scale to 1, meaning a zoom-factor of 100%
+ */
void
-rstto_picture_viewer_set_zoom_mode(RsttoPictureViewer *viewer, RsttoZoomMode mode)
+rstto_picture_viewer_zoom_100 (RsttoPictureViewer *viewer)
{
- viewer->priv->zoom_mode = mode;
+ rstto_picture_viewer_set_zoom_mode (viewer, RSTTO_ZOOM_MODE_100);
}
-static void
-rstto_picture_viewer_drag_data_received(GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time)
+/**
+ * rstto_picture_viewer_zoom_in:
+ * @viewer:
+ * @factor:
+ *
+ * Zoom in the scale with a certain factor
+ */
+void
+rstto_picture_viewer_zoom_in (RsttoPictureViewer *viewer, gdouble factor)
{
- RsttoPictureViewer *picture_viewer = RSTTO_PICTURE_VIEWER(widget);
- gchar **array = gtk_selection_data_get_uris (selection_data);
+ gdouble scale;
- context->action = GDK_ACTION_PRIVATE;
+ rstto_picture_viewer_set_zoom_mode (viewer, RSTTO_ZOOM_MODE_CUSTOM);
+ scale = rstto_picture_viewer_get_scale (viewer);
+ rstto_picture_viewer_set_scale (viewer, scale * factor);
+}
- if (array == NULL)
- {
- gtk_drag_finish (context, FALSE, FALSE, time);
- }
+/**
+ * rstto_picture_viewer_zoom_out:
+ * @viewer:
+ * @factor:
+ *
+ * Zoom out the scale with a certain factor
+ */
+void
+rstto_picture_viewer_zoom_out (RsttoPictureViewer *viewer, gdouble factor)
+{
+ gdouble scale;
- gchar **_array = array;
+ rstto_picture_viewer_set_zoom_mode (viewer, RSTTO_ZOOM_MODE_CUSTOM);
+ scale = rstto_picture_viewer_get_scale (viewer);
+ rstto_picture_viewer_set_scale (viewer, scale / factor);
+}
- while(*_array)
- {
- ThunarVfsPath *vfs_path = thunar_vfs_path_new(*_array, NULL);
- gchar *path = thunar_vfs_path_dup_string(vfs_path);
- if (g_file_test(path, G_FILE_TEST_EXISTS))
- {
- if (g_file_test(path, G_FILE_TEST_IS_DIR))
- {
- if(rstto_navigator_open_folder(picture_viewer->priv->navigator, path, FALSE, NULL) == TRUE)
- {
- rstto_navigator_jump_first(picture_viewer->priv->navigator);
- }
- }
- else
- {
- rstto_navigator_open_file(picture_viewer->priv->navigator, path, FALSE, NULL);
- }
- }
- g_free(path);
- thunar_vfs_path_unref(vfs_path);
- _array++;
- }
-
- gtk_drag_finish (context, TRUE, FALSE, time);
-}
+/******************************************************************************************/
-static gboolean
-rstto_picture_viewer_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
-{
- GdkAtom target;
- /* determine the drop target */
- target = gtk_drag_dest_find_target (widget, context, NULL);
- if (G_LIKELY (target == gdk_atom_intern ("text/uri-list", FALSE)))
+void
+rstto_picture_viewer_set_iter (RsttoPictureViewer *viewer, RsttoImageListIter *iter)
+{
+ if (viewer->priv->iter)
{
- /* set state so the drag-data-received handler
- * knows that this is really a drop this time.
- */
-
- /* request the drag data from the source. */
- gtk_drag_get_data (widget, context, target, time);
+ g_signal_handlers_disconnect_by_func (viewer->priv->iter, cb_rstto_picture_viewer_nav_iter_changed, viewer);
+ g_object_unref (viewer->priv->iter);
+ viewer->priv->iter = NULL;
}
- else
+ if (iter)
{
- return FALSE;
+ viewer->priv->iter = iter;
+ g_object_ref (viewer->priv->iter);
+ g_signal_connect (G_OBJECT (viewer->priv->iter), "changed", G_CALLBACK (cb_rstto_picture_viewer_nav_iter_changed), viewer);
}
- return TRUE;
}
-static gboolean
-rstto_picture_viewer_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+static void
+cb_rstto_picture_viewer_nav_iter_changed (RsttoImageListIter *iter, gpointer user_data)
{
- GdkAtom target;
- target = gtk_drag_dest_find_target (widget, context, NULL);
- if (G_UNLIKELY (target != gdk_atom_intern ("text/uri-list", FALSE)))
- {
- /* we cannot handle the drop */
- g_debug("FAAAAAAAAAAAAAALSE");
- return FALSE;
- }
- return TRUE;
+ RsttoPictureViewer *viewer = RSTTO_PICTURE_VIEWER (user_data);
+ rstto_picture_viewer_set_image (viewer, rstto_image_list_iter_get_image (iter));
}
diff --git a/src/picture_viewer.h b/src/picture_viewer.h
index 12863b3..655a012 100644
--- a/src/picture_viewer.h
+++ b/src/picture_viewer.h
@@ -1,4 +1,6 @@
/*
+ * Copyright (C) Stephan Arts 2006-2009 <stephan at xfce.org>
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -39,13 +41,6 @@ G_BEGIN_DECLS
G_TYPE_CHECK_CLASS_TYPE ((klass), \
RSTTO_TYPE_PICTURE_VIEWER()))
-typedef enum
-{
- RSTTO_ZOOM_MODE_100,
- RSTTO_ZOOM_MODE_FIT,
- RSTTO_ZOOM_MODE_CUSTOM
-} RsttoZoomMode;
-
typedef struct _RsttoPictureViewerPriv RsttoPictureViewerPriv;
typedef struct _RsttoPictureViewer RsttoPictureViewer;
@@ -72,11 +67,20 @@ struct _RsttoPictureViewerClass
GType rstto_picture_viewer_get_type();
-GtkWidget *rstto_picture_viewer_new(RsttoNavigator *navigator);
-void rstto_picture_viewer_set_scale(RsttoPictureViewer *viewer, gdouble scale);
+GtkWidget *rstto_picture_viewer_new ();
+void rstto_picture_viewer_set_iter (RsttoPictureViewer *, RsttoImageListIter *);
gdouble rstto_picture_viewer_get_scale(RsttoPictureViewer *viewer);
+void rstto_picture_viewer_set_scale (RsttoPictureViewer *,gdouble);
+
+void rstto_picture_viewer_zoom_fit (RsttoPictureViewer *viewer);
+void rstto_picture_viewer_zoom_100 (RsttoPictureViewer *viewer);
+void rstto_picture_viewer_zoom_in (RsttoPictureViewer *viewer, gdouble factor);
+void rstto_picture_viewer_zoom_out (RsttoPictureViewer *viewer, gdouble factor);
+
+void rstto_picture_viewer_set_menu (RsttoPictureViewer *viewer, GtkMenu *menu);
+
+/**
gdouble rstto_picture_viewer_fit_scale(RsttoPictureViewer *viewer);
-void rstto_picture_viewer_set_timeout(RsttoPictureViewer *viewer, gboolean timeout);
void rstto_picture_viewer_set_menu (RsttoPictureViewer *viewer, GtkMenu *menu);
void rstto_picture_viewer_set_bg_color (RsttoPictureViewer *viewer, const GdkColor *color);
@@ -84,8 +88,7 @@ const GdkColor *
rstto_picture_viewer_get_bg_color (RsttoPictureViewer *viewer);
void rstto_picture_viewer_redraw (RsttoPictureViewer *viewer);
-void
-rstto_picture_viewer_set_zoom_mode(RsttoPictureViewer *viewer, RsttoZoomMode mode);
+*/
G_END_DECLS
diff --git a/src/preferences_dialog.c b/src/preferences_dialog.c
new file mode 100644
index 0000000..4b34610
--- /dev/null
+++ b/src/preferences_dialog.c
@@ -0,0 +1,523 @@
+/*
+ * Copyright (C) Stephan Arts 2009 <stephan at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <gtk/gtk.h>
+#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4util/libxfce4util.h>
+
+#include "settings.h"
+#include "preferences_dialog.h"
+
+#ifndef RSTTO_MIN_CACHE_SIZE
+#define RSTTO_MIN_CACHE_SIZE 16
+#endif
+
+#ifndef RSTTO_DEFAULT_CACHE_SIZE
+#define RSTTO_DEFAULT_CACHE_SIZE 256
+#endif
+
+static void
+rstto_preferences_dialog_init(RsttoPreferencesDialog *);
+static void
+rstto_preferences_dialog_class_init(RsttoPreferencesDialogClass *);
+
+
+static void
+cb_rstto_preferences_dialog_bgcolor_override_toggled (GtkToggleButton *, gpointer);
+static void
+cb_rstto_preferences_dialog_bgcolor_color_set (GtkColorButton *, gpointer);
+static void
+cb_rstto_preferences_dialog_cache_check_button_toggled (GtkToggleButton *, gpointer);
+static void
+cb_rstto_preferences_dialog_cache_preload_hscale_value_changed (GtkRange *range,
+ gpointer user_data);
+static void
+cb_rstto_preferences_dialog_cache_spin_button_value_changed (GtkSpinButton *, gpointer);
+static void
+cb_rstto_preferences_dialog_image_quality_combo_box_changed (GtkComboBox *, gpointer);
+
+static GtkWidgetClass *parent_class = NULL;
+
+struct _RsttoPreferencesDialogPriv
+{
+ RsttoSettings *settings;
+
+ struct
+ {
+ GtkWidget *bgcolor_frame;
+ GtkWidget *bgcolor_vbox;
+ GtkWidget *bgcolor_hbox;
+ GtkWidget *bgcolor_color_button;
+ GtkWidget *bgcolor_override_check_button;
+
+
+ GtkWidget *image_quality_frame;
+ GtkWidget *image_quality_vbox;
+ GtkWidget *image_quality_hbox;
+ GtkWidget *image_quality_label;
+ GtkWidget *image_quality_combo;
+ } display_tab;
+
+ struct
+ {
+ } control_tab;
+
+ struct
+ {
+ GtkWidget *cache_frame;
+ GtkWidget *cache_vbox;
+ GtkWidget *cache_sub_vbox;
+ GtkWidget *cache_hbox;
+ GtkWidget *cache_size_label;
+ GtkWidget *cache_size_unit;
+ GtkWidget *cache_check_button;
+ GtkWidget *cache_alignment;
+ GtkWidget *cache_spin_button;
+ GtkWidget *cache_preload_label;
+ GtkWidget *cache_preload_hscale;
+ } behaviour_tab;
+};
+
+GType
+rstto_preferences_dialog_get_type (void)
+{
+ static GType rstto_preferences_dialog_type = 0;
+
+ if (!rstto_preferences_dialog_type)
+ {
+ static const GTypeInfo rstto_preferences_dialog_info =
+ {
+ sizeof (RsttoPreferencesDialogClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) rstto_preferences_dialog_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (RsttoPreferencesDialog),
+ 0,
+ (GInstanceInitFunc) rstto_preferences_dialog_init,
+ NULL
+ };
+
+ rstto_preferences_dialog_type = g_type_register_static (XFCE_TYPE_TITLED_DIALOG, "RsttoPreferencesDialog", &rstto_preferences_dialog_info, 0);
+ }
+ return rstto_preferences_dialog_type;
+}
+
+static void
+rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
+{
+ guint uint_image_quality;
+ guint uint_cache_size;
+ guint uint_preload_images;
+ gboolean bool_enable_cache;
+ gboolean bool_bgcolor_override;
+ GdkColor *bgcolor;
+ GtkWidget *scroll_frame, *scroll_vbox;
+ GtkWidget *timeout_frame, *timeout_vbox, *timeout_lbl, *timeout_hscale;
+ GtkWidget *scaling_frame, *scaling_vbox;
+ GtkWidget *widget;
+ GtkObject *cache_adjustment;
+ GtkWidget *display_main_vbox;
+ GtkWidget *display_main_lbl;
+ GtkWidget *slideshow_main_vbox;
+ GtkWidget *slideshow_main_lbl;
+ GtkWidget *control_main_vbox;
+ GtkWidget *control_main_lbl;
+ GtkWidget *behaviour_main_vbox;
+ GtkWidget *behaviour_main_lbl;
+ GtkWidget *notebook = gtk_notebook_new ();
+
+
+ dialog->priv = g_new0 (RsttoPreferencesDialogPriv, 1);
+
+ dialog->priv->settings = rstto_settings_new ();
+ g_object_get (G_OBJECT (dialog->priv->settings),
+ "image-quality", &uint_image_quality,
+ "cache-size", &uint_cache_size,
+ "preload-images", &uint_preload_images,
+ "enable-cache", &bool_enable_cache,
+ "bgcolor-override", &bool_bgcolor_override,
+ "bgcolor", &bgcolor,
+ NULL);
+
+/*****************/
+/** DISPLAY TAB **/
+/*****************/
+ display_main_vbox = gtk_vbox_new(FALSE, 0);
+ display_main_lbl = gtk_label_new(_("Display"));
+ gtk_notebook_append_page(GTK_NOTEBOOK(notebook), display_main_vbox, display_main_lbl);
+
+/** Bg-color frame */
+ dialog->priv->display_tab.bgcolor_vbox = gtk_vbox_new (FALSE, 0);
+ dialog->priv->display_tab.bgcolor_frame = xfce_create_framebox_with_content (_("Background color"),
+ dialog->priv->display_tab.bgcolor_vbox);
+ gtk_box_pack_start (GTK_BOX (display_main_vbox), dialog->priv->display_tab.bgcolor_frame, FALSE, FALSE, 0);
+
+ dialog->priv->display_tab.bgcolor_override_check_button = gtk_check_button_new_with_label (_("Override background color:"));
+ dialog->priv->display_tab.bgcolor_hbox = gtk_hbox_new (FALSE, 4);
+ dialog->priv->display_tab.bgcolor_color_button = gtk_color_button_new();
+
+ gtk_box_pack_start (GTK_BOX (dialog->priv->display_tab.bgcolor_hbox),
+ dialog->priv->display_tab.bgcolor_override_check_button, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (dialog->priv->display_tab.bgcolor_hbox),
+ dialog->priv->display_tab.bgcolor_color_button, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (dialog->priv->display_tab.bgcolor_vbox),
+ dialog->priv->display_tab.bgcolor_hbox, FALSE, FALSE, 0);
+
+ /* set current value */
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (dialog->priv->display_tab.bgcolor_color_button),
+ bgcolor);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->display_tab.bgcolor_override_check_button),
+ bool_bgcolor_override);
+ gtk_widget_set_sensitive (GTK_WIDGET (dialog->priv->display_tab.bgcolor_color_button),
+ bool_bgcolor_override);
+
+ /* connect signals */
+ g_signal_connect (G_OBJECT (dialog->priv->display_tab.bgcolor_override_check_button),
+ "toggled", (GCallback)cb_rstto_preferences_dialog_bgcolor_override_toggled, dialog);
+ g_signal_connect (G_OBJECT (dialog->priv->display_tab.bgcolor_color_button),
+ "color-set", G_CALLBACK (cb_rstto_preferences_dialog_bgcolor_color_set), dialog);
+
+/** Image-quality frame */
+ dialog->priv->display_tab.image_quality_vbox = gtk_vbox_new(FALSE, 0);
+ dialog->priv->display_tab.image_quality_frame = xfce_create_framebox_with_content (_("Quality"),
+ dialog->priv->display_tab.image_quality_vbox);
+ gtk_box_pack_start (GTK_BOX (display_main_vbox), dialog->priv->display_tab.image_quality_frame, FALSE, FALSE, 0);
+
+ dialog->priv->display_tab.image_quality_label = gtk_label_new (_("Maximum render quality:"));
+ dialog->priv->display_tab.image_quality_hbox= gtk_hbox_new (FALSE, 4);
+ dialog->priv->display_tab.image_quality_combo= gtk_combo_box_new_text ();
+
+ gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), _("Really High"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), _("High"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), _("Medium"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), _("Low"));
+
+ gtk_box_pack_start (GTK_BOX (dialog->priv->display_tab.image_quality_vbox),
+ dialog->priv->display_tab.image_quality_hbox, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (dialog->priv->display_tab.image_quality_hbox),
+ dialog->priv->display_tab.image_quality_label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (dialog->priv->display_tab.image_quality_hbox),
+ dialog->priv->display_tab.image_quality_combo, FALSE, FALSE, 0);
+ /* set current value */
+ switch (uint_image_quality-(uint_image_quality%1000000))
+ {
+ case 0:
+ gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 0);
+ break;
+ case 8000000:
+ gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 1);
+ break;
+ case 4000000:
+ gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 2);
+ break;
+ case 2000000:
+ gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 3);
+ break;
+ default:
+ gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 2);
+ break;
+ }
+
+ /* connect signals */
+ g_signal_connect (G_OBJECT (dialog->priv->display_tab.image_quality_combo),
+ "changed", (GCallback)cb_rstto_preferences_dialog_image_quality_combo_box_changed, dialog);
+
+
+/*******************/
+/** Slideshow tab **/
+/*******************/
+ slideshow_main_vbox = gtk_vbox_new(FALSE, 0);
+ slideshow_main_lbl = gtk_label_new(_("Slideshow"));
+ gtk_notebook_append_page(GTK_NOTEBOOK(notebook), slideshow_main_vbox, slideshow_main_lbl);
+ /* not used */
+ gtk_widget_set_sensitive (slideshow_main_vbox, FALSE);
+
+ timeout_vbox = gtk_vbox_new(FALSE, 0);
+ timeout_frame = xfce_create_framebox_with_content (_("Timeout"), timeout_vbox);
+ gtk_box_pack_start (GTK_BOX (slideshow_main_vbox), timeout_frame, FALSE, FALSE, 0);
+
+
+ timeout_lbl = gtk_label_new(_("The time period an individual image is displayed during a slideshow\n(in seconds)"));
+ timeout_hscale = gtk_hscale_new_with_range(1, 60, 1);
+ gtk_misc_set_alignment(GTK_MISC(timeout_lbl), 0, 0.5);
+ gtk_misc_set_padding(GTK_MISC(timeout_lbl), 2, 2);
+
+ gtk_box_pack_start(GTK_BOX(timeout_vbox), timeout_lbl, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(timeout_vbox), timeout_hscale, FALSE, TRUE, 0);
+
+
+/********************************************/
+ control_main_vbox = gtk_vbox_new(FALSE, 0);
+ control_main_lbl = gtk_label_new(_("Control"));
+ gtk_notebook_append_page(GTK_NOTEBOOK(notebook), control_main_vbox, control_main_lbl);
+
+ scroll_vbox = gtk_vbox_new(FALSE, 0);
+ scroll_frame = xfce_create_framebox_with_content (_("Scrollwheel"), scroll_vbox);
+ gtk_box_pack_start (GTK_BOX (control_main_vbox), scroll_frame, FALSE, FALSE, 0);
+ gtk_widget_set_sensitive (scroll_vbox, FALSE);
+
+ widget = gtk_radio_button_new_with_label (NULL, _("No action"));
+ gtk_container_add (GTK_CONTAINER (scroll_vbox), widget);
+ widget = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (widget), _("Zoom in and out"));
+ gtk_container_add (GTK_CONTAINER (scroll_vbox), widget);
+ widget = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (widget), _("Switch images"));
+ gtk_container_add (GTK_CONTAINER (scroll_vbox), widget);
+
+/*******************/
+/** Behaviour tab **/
+/*******************/
+ behaviour_main_vbox = gtk_vbox_new(FALSE, 0);
+ behaviour_main_lbl = gtk_label_new(_("Behaviour"));
+ gtk_notebook_append_page(GTK_NOTEBOOK(notebook), behaviour_main_vbox, behaviour_main_lbl);
+
+
+/** Image-cache frame */
+ dialog->priv->behaviour_tab.cache_vbox = gtk_vbox_new(FALSE, 0);
+ dialog->priv->behaviour_tab.cache_frame = xfce_create_framebox_with_content (_("Image cache"),
+ dialog->priv->behaviour_tab.cache_vbox);
+ gtk_box_pack_start (GTK_BOX (behaviour_main_vbox), dialog->priv->behaviour_tab.cache_frame, FALSE, FALSE, 0);
+
+ cache_adjustment = gtk_adjustment_new (RSTTO_DEFAULT_CACHE_SIZE, RSTTO_MIN_CACHE_SIZE, 4096, 1, 0, 0);
+
+ dialog->priv->behaviour_tab.cache_size_label = gtk_label_new (_("Cache size"));
+ dialog->priv->behaviour_tab.cache_size_unit = gtk_label_new (_("MB"));
+ dialog->priv->behaviour_tab.cache_hbox = gtk_hbox_new (FALSE, 4);
+ dialog->priv->behaviour_tab.cache_sub_vbox = gtk_vbox_new (FALSE, 4);
+ dialog->priv->behaviour_tab.cache_check_button = gtk_check_button_new_with_label (_("Enable cache"));
+ dialog->priv->behaviour_tab.cache_alignment = gtk_alignment_new (0, 0, 1, 1);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (dialog->priv->behaviour_tab.cache_alignment), 0, 0, 20, 0);
+ dialog->priv->behaviour_tab.cache_spin_button = gtk_spin_button_new(GTK_ADJUSTMENT(cache_adjustment), 1.0, 0);
+
+ dialog->priv->behaviour_tab.cache_preload_label = gtk_label_new (_("Preload images"));
+ gtk_misc_set_alignment(GTK_MISC(dialog->priv->behaviour_tab.cache_preload_label), 0, 0.5);
+ gtk_misc_set_padding(GTK_MISC(dialog->priv->behaviour_tab.cache_preload_label), 2, 2);
+ dialog->priv->behaviour_tab.cache_preload_hscale = gtk_hscale_new_with_range(0, 50, 1);
+ gtk_scale_set_value_pos (GTK_SCALE (dialog->priv->behaviour_tab.cache_preload_hscale), GTK_POS_LEFT);
+
+ gtk_box_pack_start (GTK_BOX (dialog->priv->behaviour_tab.cache_hbox),
+ dialog->priv->behaviour_tab.cache_size_label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (dialog->priv->behaviour_tab.cache_hbox),
+ dialog->priv->behaviour_tab.cache_spin_button, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (dialog->priv->behaviour_tab.cache_hbox),
+ dialog->priv->behaviour_tab.cache_size_unit, FALSE, FALSE, 0);
+
+ gtk_box_pack_start (GTK_BOX (dialog->priv->behaviour_tab.cache_vbox),
+ dialog->priv->behaviour_tab.cache_check_button, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (dialog->priv->behaviour_tab.cache_vbox),
+ dialog->priv->behaviour_tab.cache_alignment, FALSE, FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (dialog->priv->behaviour_tab.cache_alignment),
+ dialog->priv->behaviour_tab.cache_sub_vbox);
+
+ gtk_box_pack_start (GTK_BOX (dialog->priv->behaviour_tab.cache_sub_vbox),
+ dialog->priv->behaviour_tab.cache_hbox, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (dialog->priv->behaviour_tab.cache_sub_vbox),
+ dialog->priv->behaviour_tab.cache_preload_label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (dialog->priv->behaviour_tab.cache_sub_vbox),
+ dialog->priv->behaviour_tab.cache_preload_hscale, FALSE, FALSE, 0);
+
+ /* set current value */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->behaviour_tab.cache_check_button),
+ bool_enable_cache);
+ gtk_widget_set_sensitive (GTK_WIDGET (dialog->priv->behaviour_tab.cache_sub_vbox),
+ bool_enable_cache);
+
+ gtk_range_set_value ( GTK_RANGE(dialog->priv->behaviour_tab.cache_preload_hscale),
+ uint_preload_images);
+
+ if (uint_cache_size < RSTTO_MIN_CACHE_SIZE)
+ {
+ gtk_adjustment_set_value (GTK_ADJUSTMENT (cache_adjustment), RSTTO_DEFAULT_CACHE_SIZE);
+ }
+ else
+ {
+ gtk_adjustment_set_value (GTK_ADJUSTMENT (cache_adjustment), uint_cache_size);
+ }
+
+ /* connect signals */
+ g_signal_connect (G_OBJECT (dialog->priv->behaviour_tab.cache_check_button),
+ "toggled", (GCallback)cb_rstto_preferences_dialog_cache_check_button_toggled, dialog);
+ g_signal_connect (G_OBJECT (dialog->priv->behaviour_tab.cache_preload_hscale),
+ "value-changed", (GCallback)cb_rstto_preferences_dialog_cache_preload_hscale_value_changed, dialog);
+ g_signal_connect (G_OBJECT (dialog->priv->behaviour_tab.cache_spin_button),
+ "value-changed", (GCallback)cb_rstto_preferences_dialog_cache_spin_button_value_changed, dialog);
+
+ /********************************************/
+ scaling_vbox = gtk_vbox_new(FALSE, 0);
+ scaling_frame = xfce_create_framebox_with_content (_("Scaling"), scaling_vbox);
+ gtk_box_pack_start (GTK_BOX (behaviour_main_vbox), scaling_frame, FALSE, FALSE, 0);
+ /* not used */
+ gtk_widget_set_sensitive (scaling_vbox, FALSE);
+
+ widget = gtk_check_button_new_with_label (_("Don't scale over 100% when maximizing the window."));
+ gtk_container_add (GTK_CONTAINER (scaling_vbox), widget);
+
+
+/********************************************/
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), notebook);
+ gtk_widget_show_all (notebook);
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_OK);
+}
+
+static void
+rstto_preferences_dialog_class_init(RsttoPreferencesDialogClass *dialog_class)
+{
+ parent_class = g_type_class_peek_parent (dialog_class);
+}
+
+GtkWidget *
+rstto_preferences_dialog_new (GtkWindow *parent)
+{
+ GtkWidget *dialog = g_object_new (RSTTO_TYPE_PREFERENCES_DIALOG,
+ "title", _("Preferences"),
+ "icon-name", GTK_STOCK_PREFERENCES,
+ NULL);
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
+
+ return dialog;
+}
+
+
+static void
+cb_rstto_preferences_dialog_bgcolor_override_toggled (GtkToggleButton *button,
+ gpointer user_data)
+{
+ RsttoPreferencesDialog *dialog = RSTTO_PREFERENCES_DIALOG (user_data);
+
+ GValue bgcolor_override_val = {0, };
+ g_value_init (&bgcolor_override_val, G_TYPE_BOOLEAN);
+
+ if (gtk_toggle_button_get_active (button))
+ {
+ g_value_set_boolean (&bgcolor_override_val, TRUE);
+ gtk_widget_set_sensitive (dialog->priv->display_tab.bgcolor_color_button, TRUE);
+ }
+ else
+ {
+ g_value_set_boolean (&bgcolor_override_val, FALSE);
+ gtk_widget_set_sensitive (dialog->priv->display_tab.bgcolor_color_button, FALSE);
+ }
+
+ g_object_set_property (G_OBJECT (dialog->priv->settings), "bgcolor-override", &bgcolor_override_val);
+
+}
+
+static void
+cb_rstto_preferences_dialog_bgcolor_color_set (GtkColorButton *button, gpointer user_data)
+{
+ RsttoPreferencesDialog *dialog = RSTTO_PREFERENCES_DIALOG (user_data);
+ GValue bgcolor_val = {0, };
+ g_value_init (&bgcolor_val, GDK_TYPE_COLOR);
+
+ g_object_get_property (G_OBJECT(button), "color", &bgcolor_val);
+ g_object_set_property (G_OBJECT(dialog->priv->settings), "bgcolor", &bgcolor_val);
+
+}
+
+static void
+cb_rstto_preferences_dialog_cache_check_button_toggled (GtkToggleButton *button,
+ gpointer user_data)
+{
+ RsttoPreferencesDialog *dialog = RSTTO_PREFERENCES_DIALOG (user_data);
+
+ GValue value = {0, };
+ g_value_init (&value, G_TYPE_BOOLEAN);
+
+ if (gtk_toggle_button_get_active (button))
+ {
+ g_value_set_boolean (&value, TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (dialog->priv->behaviour_tab.cache_sub_vbox), TRUE);
+ }
+ else
+ {
+ g_value_set_boolean (&value, FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (dialog->priv->behaviour_tab.cache_sub_vbox), FALSE);
+ }
+
+ g_object_set_property (G_OBJECT (dialog->priv->settings), "enable-cache", &value);
+
+ g_value_unset (&value);
+
+}
+
+static void
+cb_rstto_preferences_dialog_cache_preload_hscale_value_changed (GtkRange *range,
+ gpointer user_data)
+{
+ RsttoPreferencesDialog *dialog = RSTTO_PREFERENCES_DIALOG (user_data);
+
+ GValue value = {0, };
+ g_value_init (&value, G_TYPE_UINT);
+
+ g_value_set_uint (&value, gtk_range_get_value (range));
+
+ g_object_set_property (G_OBJECT (dialog->priv->settings), "preload-images", &value);
+ g_value_unset (&value);
+}
+
+static void
+cb_rstto_preferences_dialog_cache_spin_button_value_changed (GtkSpinButton *button,
+ gpointer user_data)
+{
+ RsttoPreferencesDialog *dialog = RSTTO_PREFERENCES_DIALOG (user_data);
+
+ GValue value = {0, };
+ g_value_init (&value, G_TYPE_UINT);
+
+ g_value_set_uint (&value, (guint)gtk_spin_button_get_value (button));
+
+ g_object_set_property (G_OBJECT (dialog->priv->settings), "cache-size", &value);
+
+ g_value_unset (&value);
+}
+
+static void
+cb_rstto_preferences_dialog_image_quality_combo_box_changed (GtkComboBox *combo_box,
+ gpointer user_data)
+
+{
+ /* FIXME */
+ RsttoPreferencesDialog *dialog = RSTTO_PREFERENCES_DIALOG (user_data);
+ switch (gtk_combo_box_get_active (combo_box))
+ {
+ case 0: /* unlimited */
+ g_object_set (G_OBJECT (dialog->priv->settings),
+ "image-quality", 0,
+ NULL);
+ break;
+ case 1: /* 1 MegaPixel */
+ g_object_set (G_OBJECT (dialog->priv->settings),
+ "image-quality", 8000000,
+ NULL);
+ break;
+ case 2: /* 2 MegaPixel */
+ g_object_set (G_OBJECT (dialog->priv->settings),
+ "image-quality", 4000000,
+ NULL);
+ break;
+ case 3: /* 4 MegaPixel */
+ g_object_set (G_OBJECT (dialog->priv->settings),
+ "image-quality", 2000000,
+ NULL);
+ break;
+ }
+}
diff --git a/src/preferences_dialog.h b/src/preferences_dialog.h
new file mode 100644
index 0000000..1ba2506
--- /dev/null
+++ b/src/preferences_dialog.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) Stephan Arts 2009 <stephan at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __RISTRETTO_PREFERENCES_DIALOG_H__
+#define __RISTRETTO_PREFERENCES_DIALOG_H__
+
+G_BEGIN_DECLS
+
+#define RSTTO_TYPE_PREFERENCES_DIALOG rstto_preferences_dialog_get_type()
+
+#define RSTTO_PREFERENCES_DIALOG(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ RSTTO_TYPE_PREFERENCES_DIALOG, \
+ RsttoPreferencesDialog))
+
+#define RSTTO_IS_PREFERENCES_DIALOG(obj)( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ RSTTO_TYPE_PREFERENCES_DIALOG))
+
+#define RSTTO_PREFERENCES_DIALOG_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ RSTTO_TYPE_PREFERENCES_DIALOG, \
+ RsttoPreferencesDialogClass))
+
+#define RSTTO_IS_PREFERENCES_DIALOG_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ RSTTO_TYPE_PREFERENCES_DIALOG()))
+
+typedef struct _RsttoPreferencesDialog RsttoPreferencesDialog;
+
+typedef struct _RsttoPreferencesDialogPriv RsttoPreferencesDialogPriv;
+
+struct _RsttoPreferencesDialog
+{
+ XfceTitledDialog parent;
+ RsttoPreferencesDialogPriv *priv;
+};
+
+typedef struct _RsttoPreferencesDialogClass RsttoPreferencesDialogClass;
+
+struct _RsttoPreferencesDialogClass
+{
+ XfceTitledDialogClass parent_class;
+};
+
+GType rstto_preferences_dialog_get_type();
+
+GtkWidget *
+rstto_preferences_dialog_new (GtkWindow *parent);
+
+G_END_DECLS
+
+#endif /* __RISTRETTO_PREFERENCES_DIALOG_H__ */
diff --git a/src/settings.c b/src/settings.c
new file mode 100644
index 0000000..1bf543d
--- /dev/null
+++ b/src/settings.c
@@ -0,0 +1,488 @@
+/*
+ * Copyright (c) 2009 Stephan Arts <stephan at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <xfconf/xfconf.h>
+#include <libxfce4util/libxfce4util.h>
+
+#include "settings.h"
+
+static void
+rstto_settings_init (GObject *);
+static void
+rstto_settings_class_init (GObjectClass *);
+
+static void
+rstto_settings_dispose (GObject *object);
+static void
+rstto_settings_finalize (GObject *object);
+
+static void
+rstto_settings_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void
+rstto_settings_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static GObjectClass *parent_class = NULL;
+
+static RsttoSettings *settings_object;
+
+enum
+{
+ PROP_0,
+ PROP_SHOW_TOOLBAR,
+ PROP_TOOLBAR_OPEN,
+ PROP_ENABLE_CACHE,
+ PROP_PRELOAD_IMAGES,
+ PROP_CACHE_SIZE,
+ PROP_IMAGE_QUALITY,
+ PROP_WINDOW_WIDTH,
+ PROP_WINDOW_HEIGHT,
+ PROP_BGCOLOR,
+ PROP_BGCOLOR_OVERRIDE,
+ PROP_BGCOLOR_FULLSCREEN,
+ PROP_CURRENT_URI,
+ PROP_SLIDESHOW_TIMEOUT,
+ PROP_SCROLLWHEEL_ACTION,
+};
+
+GType
+rstto_settings_get_type (void)
+{
+ static GType rstto_settings_type = 0;
+
+ if (!rstto_settings_type)
+ {
+ static const GTypeInfo rstto_settings_info =
+ {
+ sizeof (RsttoSettingsClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) rstto_settings_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (RsttoSettings),
+ 0,
+ (GInstanceInitFunc) rstto_settings_init,
+ NULL
+ };
+
+ rstto_settings_type = g_type_register_static (G_TYPE_OBJECT, "RsttoSettings", &rstto_settings_info, 0);
+ }
+ return rstto_settings_type;
+}
+
+struct _RsttoSettingsPriv
+{
+ XfconfChannel *channel;
+
+ gboolean show_toolbar;
+ guint preload_images;
+ gboolean enable_cache;
+ guint cache_size;
+ guint image_quality;
+ guint window_width;
+ guint window_height;
+ gchar *last_file_path;
+ guint slideshow_timeout;
+ GdkColor *bgcolor;
+ gboolean bgcolor_override;
+ GdkColor *bgcolor_fullscreen;
+ gchar *scrollwheel_action;
+};
+
+
+static void
+rstto_settings_init (GObject *object)
+{
+ gchar *accelmap_path = NULL;
+
+ RsttoSettings *settings = RSTTO_SETTINGS (object);
+
+ settings->priv = g_new0 (RsttoSettingsPriv, 1);
+ settings->priv->channel = xfconf_channel_new ("ristretto");
+
+ accelmap_path = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, "ristretto/accels.scm");
+ if (accelmap_path)
+ {
+ gtk_accel_map_load (accelmap_path);
+ g_free (accelmap_path);
+ accelmap_path = NULL;
+ }
+
+ settings->priv->slideshow_timeout = 5000;
+ settings->priv->bgcolor = g_new0 (GdkColor, 1);
+ settings->priv->bgcolor_fullscreen = g_new0 (GdkColor, 1);
+ settings->priv->image_quality = 2000000;
+
+ xfconf_g_property_bind (settings->priv->channel, "/window/width", G_TYPE_UINT, settings, "window-width");
+ xfconf_g_property_bind (settings->priv->channel, "/window/height", G_TYPE_UINT, settings, "window-height");
+
+ xfconf_g_property_bind (settings->priv->channel, "/file/current-uri", G_TYPE_STRING, settings, "current-uri");
+
+ xfconf_g_property_bind (settings->priv->channel, "/window/show-toolbar", G_TYPE_BOOLEAN, settings, "show-toolbar");
+ xfconf_g_property_bind (settings->priv->channel, "/window/scrollwheel-action", G_TYPE_STRING, settings, "scrollwheel-action");
+
+ xfconf_g_property_bind (settings->priv->channel, "/slideshow/timeout", G_TYPE_UINT, settings, "slideshow-timeout");
+
+ xfconf_g_property_bind_gdkcolor (settings->priv->channel, "/window/bgcolor", settings, "bgcolor");
+ xfconf_g_property_bind (settings->priv->channel, "/window/bgcolor-override", G_TYPE_BOOLEAN, settings, "bgcolor-override");
+
+ xfconf_g_property_bind_gdkcolor (settings->priv->channel, "/window/bgcolor-fullscreen", settings, "bgcolor-fullscreen");
+ xfconf_g_property_bind (settings->priv->channel, "/image/preload", G_TYPE_UINT, settings, "preload-images");
+ xfconf_g_property_bind (settings->priv->channel, "/image/cache", G_TYPE_BOOLEAN, settings, "enable-cache");
+ xfconf_g_property_bind (settings->priv->channel, "/image/cache-size", G_TYPE_UINT, settings, "cache-size");
+ xfconf_g_property_bind (settings->priv->channel, "/image/quality", G_TYPE_UINT, settings, "image-quality");
+}
+
+
+static void
+rstto_settings_class_init (GObjectClass *object_class)
+{
+ GParamSpec *pspec;
+
+ RsttoSettingsClass *settings_class = RSTTO_SETTINGS_CLASS (object_class);
+
+ parent_class = g_type_class_peek_parent (settings_class);
+
+ object_class->dispose = rstto_settings_dispose;
+ object_class->finalize = rstto_settings_finalize;
+
+ object_class->set_property = rstto_settings_set_property;
+ object_class->get_property = rstto_settings_get_property;
+
+ pspec = g_param_spec_uint ("window-width",
+ "",
+ "",
+ 0,
+ G_MAXUINT,
+ 600,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ PROP_WINDOW_WIDTH,
+ pspec);
+
+ pspec = g_param_spec_uint ("window-height",
+ "",
+ "",
+ 0,
+ G_MAXUINT,
+ 400,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ PROP_WINDOW_HEIGHT,
+ pspec);
+
+ pspec = g_param_spec_boolean ("show-toolbar",
+ "",
+ "",
+ TRUE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ PROP_SHOW_TOOLBAR,
+ pspec);
+
+ pspec = g_param_spec_uint ("preload-images",
+ "",
+ "",
+ 0,
+ 50,
+ 0,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ PROP_PRELOAD_IMAGES,
+ pspec);
+
+ pspec = g_param_spec_boolean ("enable-cache",
+ "",
+ "",
+ TRUE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ PROP_ENABLE_CACHE,
+ pspec);
+
+ pspec = g_param_spec_uint ("cache-size",
+ "",
+ "",
+ 0,
+ G_MAXUINT,
+ 256,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ PROP_CACHE_SIZE,
+ pspec);
+
+ pspec = g_param_spec_uint ("image-quality",
+ "",
+ "",
+ 0,
+ 50000000,
+ 2000000,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ PROP_IMAGE_QUALITY,
+ pspec);
+
+ pspec = g_param_spec_string ("current-uri",
+ "",
+ "",
+ "file://~/",
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ PROP_CURRENT_URI,
+ pspec);
+
+ pspec = g_param_spec_string ("scrollwheel-action",
+ "",
+ "",
+ "zoom",
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ PROP_CURRENT_URI,
+ pspec);
+
+ pspec = g_param_spec_uint ("slideshow-timeout",
+ "",
+ "",
+ 1000,
+ G_MAXUINT,
+ 5000,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ PROP_SLIDESHOW_TIMEOUT,
+ pspec);
+
+ pspec = g_param_spec_boxed ("bgcolor",
+ "",
+ "",
+ GDK_TYPE_COLOR,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ PROP_BGCOLOR,
+ pspec);
+
+ pspec = g_param_spec_boolean ("bgcolor-override",
+ "",
+ "",
+ TRUE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ PROP_BGCOLOR_OVERRIDE,
+ pspec);
+
+ pspec = g_param_spec_boxed ("bgcolor-fullscreen",
+ "",
+ "",
+ GDK_TYPE_COLOR,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ PROP_BGCOLOR_FULLSCREEN,
+ pspec);
+}
+
+/**
+ * rstto_settings_dispose:
+ * @object:
+ *
+ */
+static void
+rstto_settings_dispose (GObject *object)
+{
+ RsttoSettings *settings = RSTTO_SETTINGS (object);
+
+ if (settings->priv)
+ {
+ g_free (settings->priv);
+ settings->priv = NULL;
+ }
+}
+
+/**
+ * rstto_settings_finalize:
+ * @object:
+ *
+ */
+static void
+rstto_settings_finalize (GObject *object)
+{
+ gchar *accelmap_path = NULL;
+ /*RsttoSettings *settings = RSTTO_SETTINGS (object);*/
+
+ accelmap_path = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "ristretto/accels.scm", TRUE);
+ if (accelmap_path)
+ {
+ gtk_accel_map_save (accelmap_path);
+ g_free (accelmap_path);
+ accelmap_path = NULL;
+ }
+
+}
+
+
+
+/**
+ * rstto_settings_new:
+ *
+ *
+ * Singleton
+ */
+RsttoSettings *
+rstto_settings_new (void)
+{
+ if (settings_object == NULL)
+ {
+ settings_object = g_object_new (RSTTO_TYPE_SETTINGS, NULL);
+ }
+ else
+ {
+ g_object_ref (settings_object);
+ }
+
+ return settings_object;
+}
+
+
+static void
+rstto_settings_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GdkColor *color;
+ RsttoSettings *settings = RSTTO_SETTINGS (object);
+
+ switch (property_id)
+ {
+ case PROP_SHOW_TOOLBAR:
+ settings->priv->show_toolbar = g_value_get_boolean (value);
+ break;
+ case PROP_PRELOAD_IMAGES:
+ settings->priv->preload_images = g_value_get_uint (value);
+ break;
+ case PROP_ENABLE_CACHE:
+ settings->priv->enable_cache = g_value_get_boolean (value);
+ break;
+ case PROP_IMAGE_QUALITY:
+ settings->priv->image_quality = g_value_get_uint (value);
+ break;
+ case PROP_CACHE_SIZE:
+ settings->priv->cache_size = g_value_get_uint (value);
+ break;
+ case PROP_WINDOW_WIDTH:
+ settings->priv->window_width = g_value_get_uint (value);
+ break;
+ case PROP_WINDOW_HEIGHT:
+ settings->priv->window_height = g_value_get_uint (value);
+ break;
+ case PROP_BGCOLOR:
+ color = g_value_get_boxed (value);
+ settings->priv->bgcolor->red = color->red;
+ settings->priv->bgcolor->green = color->green;
+ settings->priv->bgcolor->blue = color->blue;
+ break;
+ case PROP_BGCOLOR_OVERRIDE:
+ settings->priv->bgcolor_override = g_value_get_boolean (value);
+ break;
+ case PROP_CURRENT_URI:
+ if (settings->priv->last_file_path)
+ g_free (settings->priv->last_file_path);
+ settings->priv->last_file_path = g_value_dup_string (value);
+ break;
+ case PROP_SLIDESHOW_TIMEOUT:
+ settings->priv->slideshow_timeout = g_value_get_uint (value);
+ break;
+ case PROP_BGCOLOR_FULLSCREEN:
+ color = g_value_get_boxed (value);
+ settings->priv->bgcolor_fullscreen->red = color->red;
+ settings->priv->bgcolor_fullscreen->green = color->green;
+ settings->priv->bgcolor_fullscreen->blue = color->blue;
+ break;
+ case PROP_SCROLLWHEEL_ACTION:
+ if (settings->priv->scrollwheel_action)
+ g_free (settings->priv->scrollwheel_action);
+ settings->priv->scrollwheel_action = g_value_dup_string (value);
+ break;
+ default:
+ break;
+ }
+
+}
+
+static void
+rstto_settings_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ RsttoSettings *settings = RSTTO_SETTINGS (object);
+
+ switch (property_id)
+ {
+ case PROP_SHOW_TOOLBAR:
+ g_value_set_boolean (value, settings->priv->show_toolbar);
+ break;
+ case PROP_PRELOAD_IMAGES:
+ g_value_set_uint (value, settings->priv->preload_images);
+ break;
+ case PROP_ENABLE_CACHE:
+ g_value_set_boolean (value, settings->priv->enable_cache);
+ break;
+ case PROP_IMAGE_QUALITY:
+ g_value_set_uint (value, settings->priv->image_quality);
+ break;
+ case PROP_CACHE_SIZE:
+ g_value_set_uint (value, settings->priv->cache_size);
+ break;
+ case PROP_WINDOW_WIDTH:
+ g_value_set_uint (value, settings->priv->window_width);
+ break;
+ case PROP_WINDOW_HEIGHT:
+ g_value_set_uint (value, settings->priv->window_height);
+ break;
+ case PROP_CURRENT_URI:
+ g_value_set_string (value, settings->priv->last_file_path);
+ break;
+ case PROP_SLIDESHOW_TIMEOUT:
+ g_value_set_uint (value, settings->priv->slideshow_timeout);
+ break;
+ case PROP_BGCOLOR_FULLSCREEN:
+ g_value_set_boxed (value, settings->priv->bgcolor_fullscreen);
+ break;
+ case PROP_BGCOLOR:
+ g_value_set_boxed (value, settings->priv->bgcolor);
+ break;
+ case PROP_BGCOLOR_OVERRIDE:
+ g_value_set_boolean (value, settings->priv->bgcolor_override);
+ break;
+ case PROP_SCROLLWHEEL_ACTION:
+ g_value_set_string (value, settings->priv->scrollwheel_action);
+ break;
+ default:
+ break;
+
+ }
+}
diff --git a/src/save_dialog.h b/src/settings.h
similarity index 50%
copy from src/save_dialog.h
copy to src/settings.h
index 44d4a5f..4b526c2 100644
--- a/src/save_dialog.h
+++ b/src/settings.h
@@ -1,6 +1,4 @@
/*
- * Copyright (C) Stephan Arts 2008 <stephan at xfce.org>
- *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,50 +14,52 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef __RISTRETTO_SAVE_DIALOG_H__
-#define __RISTRETTO_SAVE_DIALOG_H__
+#ifndef __RISTRETTO_SETTINGS_H__
+#define __RISTRETTO_SETTINGS_H__
G_BEGIN_DECLS
-#define RSTTO_TYPE_SAVE_DIALOG rstto_save_dialog_get_type()
+#define RSTTO_TYPE_SETTINGS rstto_settings_get_type()
-#define RSTTO_SAVE_DIALOG(obj)( \
+#define RSTTO_SETTINGS(obj)( \
G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- RSTTO_TYPE_SAVE_DIALOG, \
- RsttoSaveDialog))
+ RSTTO_TYPE_SETTINGS, \
+ RsttoSettings))
-#define RSTTO_IS_SAVE_DIALOG(obj)( \
+#define RSTTO_IS_SETTINGS(obj)( \
G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- RSTTO_TYPE_SAVE_DIALOG))
+ RSTTO_TYPE_SETTINGS))
-#define RSTTO_SAVE_DIALOG_CLASS(klass)( \
+#define RSTTO_SETTINGS_CLASS(klass)( \
G_TYPE_CHECK_CLASS_CAST ((klass), \
- RSTTO_TYPE_SAVE_DIALOG, \
- RsttoSaveDialogClass))
+ RSTTO_TYPE_SETTINGS, \
+ RsttoSettingsClass))
-#define RSTTO_IS_SAVE_DIALOG_CLASS(klass)( \
+#define RSTTO_IS_SETTINGS_CLASS(klass)( \
G_TYPE_CHECK_CLASS_TYPE ((klass), \
- RSTTO_TYPE_SAVE_DIALOG()))
+ RSTTO_TYPE_SETTINGS()))
+
-typedef struct _RsttoSaveDialog RsttoSaveDialog;
+typedef struct _RsttoSettings RsttoSettings;
+typedef struct _RsttoSettingsPriv RsttoSettingsPriv;
-struct _RsttoSaveDialog
+struct _RsttoSettings
{
- GtkDialog parent;
+ GObject parent;
+
+ RsttoSettingsPriv *priv;
};
-typedef struct _RsttoSaveDialogClass RsttoSaveDialogClass;
+typedef struct _RsttoSettingsClass RsttoSettingsClass;
-struct _RsttoSaveDialogClass
+struct _RsttoSettingsClass
{
- GtkDialogClass parent_class;
+ GObjectClass parent_class;
};
-GType rstto_save_dialog_get_type();
-
-GtkWidget *
-rstto_save_dialog_new (GtkWindow *parent, GList *entries);
+RsttoSettings *rstto_settings_new (void);
+GType rstto_settings_get_type (void);
G_END_DECLS
-#endif /* __RISTRETTO_SAVE_DIALOG_H__ */
+#endif /* __RISTRETTO_SETTINGS_H__ */
diff --git a/src/thumbnail.c b/src/thumbnail.c
index 6ba7c4f..94f7abc 100644
--- a/src/thumbnail.c
+++ b/src/thumbnail.c
@@ -19,20 +19,20 @@
#include <gtk/gtkmarshal.h>
#include <string.h>
-#include <thunar-vfs/thunar-vfs.h>
#include <libexif/exif-data.h>
-#include "navigator.h"
+#include "image.h"
+#include "image_list.h"
#include "thumbnail.h"
struct _RsttoThumbnailPriv
{
- RsttoNavigatorEntry *entry;
- gboolean selected;
- GSList *group;
+ RsttoImage *image;
+ GdkPixbuf *pixbuf;
};
static GtkWidgetClass *parent_class = NULL;
+static GdkPixbuf *thumbnail_missing_icon = NULL;
static void
rstto_thumbnail_init(RsttoThumbnail *);
@@ -52,10 +52,14 @@ static void
rstto_thumbnail_paint(RsttoThumbnail *thumb);
static void
-rstto_thumbnail_clicked(GtkButton *);
+rstto_thumbnail_clicked (GtkButton *);
+static void
+rstto_thumbnail_enter (GtkButton *);
+static void
+rstto_thumbnail_leave (GtkButton *);
GType
-rstto_thumbnail_get_type ()
+rstto_thumbnail_get_type (void)
{
static GType rstto_thumbnail_type = 0;
@@ -85,6 +89,16 @@ rstto_thumbnail_init(RsttoThumbnail *thumb)
{
thumb->priv = g_new0(RsttoThumbnailPriv, 1);
+ if (thumbnail_missing_icon == NULL)
+ {
+ thumbnail_missing_icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(),
+ "image-missing",
+ 128,
+ 0,
+ NULL);
+ }
+
+
gtk_widget_set_redraw_on_allocate(GTK_WIDGET(thumb), TRUE);
gtk_widget_set_events (GTK_WIDGET(thumb),
GDK_POINTER_MOTION_MASK);
@@ -109,11 +123,26 @@ rstto_thumbnail_class_init(RsttoThumbnailClass *thumb_class)
widget_class->size_allocate = rstto_thumbnail_size_allocate;
button_class->clicked = rstto_thumbnail_clicked;
+ button_class->enter = rstto_thumbnail_enter;
+ button_class->leave = rstto_thumbnail_leave;
object_class->finalize = rstto_thumbnail_finalize;
}
static void
+rstto_thumbnail_finalize(GObject *object)
+{
+ RsttoThumbnail *thumb = RSTTO_THUMBNAIL(object);
+ if (thumb->priv->image)
+ {
+ g_object_unref (thumb->priv->image);
+ thumb->priv->image = NULL;
+ }
+
+}
+
+
+static void
rstto_thumbnail_size_request(GtkWidget *widget, GtkRequisition *requisition)
{
requisition->height = 70;
@@ -123,46 +152,84 @@ rstto_thumbnail_size_request(GtkWidget *widget, GtkRequisition *requisition)
static void
rstto_thumbnail_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
+ RsttoThumbnail *thumb = RSTTO_THUMBNAIL(widget);
widget->allocation = *allocation;
-
parent_class->size_allocate(widget, allocation);
+
+ if (thumb->priv->pixbuf)
+ {
+ g_object_unref (thumb->priv->pixbuf);
+ thumb->priv->pixbuf = NULL;
+ }
+
+ thumb->priv->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ TRUE,
+ 8,
+ allocation->width,
+ allocation->height);
}
static gboolean
rstto_thumbnail_expose(GtkWidget *widget, GdkEventExpose *event)
{
RsttoThumbnail *thumb = RSTTO_THUMBNAIL(widget);
+ GdkPixbuf *thumb_pixbuf = NULL;
if (GTK_WIDGET_REALIZED (widget))
{
- GdkRegion *region = event->region;
+ if (thumb->priv->image)
+ {
+ thumb_pixbuf = rstto_image_get_thumbnail (thumb->priv->image);
+ }
- gdk_window_begin_paint_region(widget->window, region);
- rstto_thumbnail_paint(thumb);
- gdk_window_end_paint(widget->window);
- }
+ if (thumb_pixbuf == NULL)
+ {
+ thumb_pixbuf = thumbnail_missing_icon;
+ }
- return FALSE;
-}
+ g_object_ref (thumb_pixbuf);
-static void
-rstto_thumbnail_finalize(GObject *object)
-{
- RsttoThumbnail *thumb = RSTTO_THUMBNAIL(object);
+ if (thumb_pixbuf)
+ {
+ gint height = gdk_pixbuf_get_height (thumb->priv->pixbuf) - 10;
+ gint width = gdk_pixbuf_get_width (thumb->priv->pixbuf) - 10;
+ gdouble scale = 1.0;
+ GdkPixbuf *dst_thumb_pixbuf = NULL;
- if (thumb->priv->entry)
- {
- GSList *group = g_slist_remove(thumb->priv->group, thumb);
- GSList *iter = group;
+ if (gdk_pixbuf_get_width (thumb_pixbuf) > gdk_pixbuf_get_height (thumb_pixbuf))
+ {
+ height = (gint)(((gdouble)gdk_pixbuf_get_height (thumb_pixbuf) / (gdouble)gdk_pixbuf_get_width (thumb_pixbuf)) * width);
+ scale = ((gdouble)width / (gdouble)gdk_pixbuf_get_width (thumb_pixbuf));
+ }
+ else
+ {
+ width = (gint)(((gdouble)gdk_pixbuf_get_width (thumb_pixbuf) / (gdouble)gdk_pixbuf_get_height (thumb_pixbuf)) * height);
+ scale = ((gdouble)height / (gdouble)gdk_pixbuf_get_height (thumb_pixbuf));
+ }
- while(iter)
- {
- RsttoThumbnail *thumb_iter = iter->data;
- thumb_iter->priv->group = group;
- iter = g_slist_next(iter);
+ gdk_pixbuf_fill (thumb->priv->pixbuf, 0x00000000);
+
+ dst_thumb_pixbuf = gdk_pixbuf_scale_simple (thumb_pixbuf, width, height, GDK_INTERP_BILINEAR);
+
+ gdk_pixbuf_copy_area (dst_thumb_pixbuf,
+ 0, 0,
+ width, height,
+ thumb->priv->pixbuf,
+ (gint)((gdouble)(gdk_pixbuf_get_width (thumb->priv->pixbuf) - width))/2,
+ (gint)((gdouble)(gdk_pixbuf_get_height (thumb->priv->pixbuf) - height))/2
+ );
+
+ g_object_unref (dst_thumb_pixbuf);
+ g_object_unref (thumb_pixbuf);
}
- thumb->priv->entry = NULL;
+
+
+ gdk_window_begin_paint_region(widget->window, event->region);
+ rstto_thumbnail_paint(thumb);
+ gdk_window_end_paint(widget->window);
}
+
+ return FALSE;
}
static void
@@ -172,25 +239,13 @@ rstto_thumbnail_paint(RsttoThumbnail *thumb)
GtkStateType state = GTK_WIDGET_STATE(widget);
- if(thumb->priv->entry)
+ if(thumb->priv->image)
{
if (GTK_WIDGET_STATE(widget) != GTK_STATE_PRELIGHT)
{
- if (rstto_navigator_entry_is_selected(thumb->priv->entry))
- {
- gtk_widget_set_state(widget, GTK_STATE_SELECTED);
- }
- else
- {
- gtk_widget_set_state(widget, GTK_STATE_NORMAL);
- }
}
- GdkPixbuf *pixbuf = rstto_navigator_entry_get_thumb(
- thumb->priv->entry,
- widget->allocation.height - 4);
-
gtk_paint_box(widget->style,
widget->window,
state,
@@ -201,75 +256,84 @@ rstto_thumbnail_paint(RsttoThumbnail *thumb)
widget->allocation.x, widget->allocation.y,
widget->allocation.width, widget->allocation.height);
- if(pixbuf)
+ if (thumb->priv->pixbuf)
{
gdk_draw_pixbuf(GDK_DRAWABLE(widget->window),
NULL,
- pixbuf,
+ thumb->priv->pixbuf,
0, 0,
- (0.5 * (widget->allocation.width - gdk_pixbuf_get_width(pixbuf))) + widget->allocation.x,
- (0.5 * (widget->allocation.height - gdk_pixbuf_get_height(pixbuf))) + widget->allocation.y,
+ (0.5 * (widget->allocation.width - gdk_pixbuf_get_width(thumb->priv->pixbuf))) + widget->allocation.x,
+ (0.5 * (widget->allocation.height - gdk_pixbuf_get_height(thumb->priv->pixbuf))) + widget->allocation.y,
-1, -1,
GDK_RGB_DITHER_NORMAL,
0, 0);
}
+
+ /*
+ gtk_paint_focus (widget->style,
+ widget->window,
+ state,
+ NULL,
+ widget,
+ NULL,
+ widget->allocation.x+3, widget->allocation.y+3,
+ widget->allocation.width-6, widget->allocation.height-6);
+ */
+
}
}
GtkWidget *
-rstto_thumbnail_new(RsttoNavigatorEntry *entry, GSList *thumb_list)
+rstto_thumbnail_new (RsttoImage *image)
{
- g_return_val_if_fail(entry != NULL, NULL);
+ gchar *path, *basename;
+ GFile *file = NULL;
+ RsttoThumbnail *thumb;
- RsttoThumbnail *thumb = g_object_new(RSTTO_TYPE_THUMBNAIL, NULL);
+ g_return_val_if_fail (image != NULL, NULL);
- thumb->priv->entry = entry;
+ thumb = g_object_new(RSTTO_TYPE_THUMBNAIL, NULL);
-#if GTK_CHECK_VERSION(2,12,0)
- ThunarVfsInfo *info = rstto_navigator_entry_get_info(thumb->priv->entry);
-
- gtk_widget_set_tooltip_text(GTK_WIDGET(thumb), thunar_vfs_path_dup_string(info->path));
-#else
- /* TODO: gtktooltip stuff */
-#endif
+ thumb->priv->image = image;
+ g_object_ref (image);
- {
- thumb->priv->group = g_slist_prepend(thumb_list, thumb);
- GSList *iter = thumb->priv->group;
- while(iter)
- {
- RsttoThumbnail *iter_thumb = iter->data;
- iter_thumb->priv->group = thumb->priv->group;
- iter = iter->next;
- }
- }
+ file = rstto_image_get_file (image);
- return GTK_WIDGET(thumb);
-}
+ path = g_file_get_path (file);
+ basename = g_path_get_basename (path);
-GtkWidget *
-rstto_thumbnail_new_from_widget(RsttoNavigatorEntry *entry, RsttoThumbnail *sibling)
-{
- return rstto_thumbnail_new(entry, sibling->priv->group);
+ gtk_widget_set_tooltip_text(GTK_WIDGET(thumb), basename);
+
+ g_free (basename);
+ g_free (path);
+ return GTK_WIDGET(thumb);
}
-RsttoNavigatorEntry *
-rstto_thumbnail_get_entry (RsttoThumbnail *thumb)
+RsttoImage *
+rstto_thumbnail_get_image (RsttoThumbnail *thumb)
{
- return thumb->priv->entry;
+ return thumb->priv->image;
}
/* CALLBACKS */
/*************/
static void
-rstto_thumbnail_clicked(GtkButton *button)
+rstto_thumbnail_clicked (GtkButton *button)
{
- RsttoThumbnail *thumb = RSTTO_THUMBNAIL(button);
- RsttoNavigatorEntry *entry = rstto_thumbnail_get_entry(thumb);
+ gtk_widget_queue_draw (GTK_WIDGET (button));
+}
- thumb->selected = TRUE;
- rstto_navigator_entry_select(entry);
+static void
+rstto_thumbnail_enter (GtkButton *button)
+{
+ gtk_widget_set_state (GTK_WIDGET (button), GTK_STATE_PRELIGHT);
+ gtk_widget_queue_draw (GTK_WIDGET (button));
+}
+static void
+rstto_thumbnail_leave (GtkButton *button)
+{
+ gtk_widget_set_state (GTK_WIDGET (button), GTK_STATE_NORMAL);
gtk_widget_queue_draw (GTK_WIDGET (button));
}
diff --git a/src/thumbnail.h b/src/thumbnail.h
index 4e71b30..1ca3014 100644
--- a/src/thumbnail.h
+++ b/src/thumbnail.h
@@ -59,9 +59,8 @@ struct _RsttoThumbnailClass
GType rstto_thumbnail_get_type();
-GtkWidget *rstto_thumbnail_new(RsttoNavigatorEntry *entry, GSList *thumb_list);
-GtkWidget *rstto_thumbnail_new_from_widget(RsttoNavigatorEntry *entry, RsttoThumbnail *sibling);
-RsttoNavigatorEntry *rstto_thumbnail_get_entry (RsttoThumbnail *thumb);
+GtkWidget *rstto_thumbnail_new (RsttoImage *image);
+RsttoImage *rstto_thumbnail_get_image (RsttoThumbnail *thumb);
G_END_DECLS
diff --git a/src/thumbnail_bar.c b/src/thumbnail_bar.c
index 2ef0514..4901919 100644
--- a/src/thumbnail_bar.c
+++ b/src/thumbnail_bar.c
@@ -19,23 +19,28 @@
#include <gtk/gtkmarshal.h>
#include <string.h>
-#include <thunar-vfs/thunar-vfs.h>
+#include <gio/gio.h>
+
+#include <libxfcegui4/libxfcegui4.h>
#include <libexif/exif-data.h>
-#include "navigator.h"
+#include "image.h"
+#include "image_list.h"
#include "thumbnail.h"
#include "thumbnail_bar.h"
struct _RsttoThumbnailBarPriv
{
GtkOrientation orientation;
- RsttoNavigator *navigator;
gint dimension;
gint offset;
gboolean auto_center;
gint begin;
gint end;
- GSList *thumbs;
+ RsttoImageList *image_list;
+ RsttoImageListIter *iter;
+ RsttoImageListIter *internal_iter;
+ GList *thumbs;
gint scroll_speed;
struct
{
@@ -62,12 +67,21 @@ rstto_thumbnail_bar_realize(GtkWidget *widget);
static void
rstto_thumbnail_bar_unrealize(GtkWidget *widget);
+static void
+cb_rstto_thumbnail_bar_image_list_new_image (RsttoImageList *image_list, RsttoImage *image, gpointer user_data);
+static void
+cb_rstto_thumbnail_bar_image_list_remove_image (RsttoImageList *image_list, RsttoImage *image, gpointer user_data);
+static void
+cb_rstto_thumbnail_bar_image_list_remove_all (RsttoImageList *image_list, gpointer user_data);
+void
+cb_rstto_thumbnail_bar_image_list_iter_changed (RsttoImageListIter *iter, gpointer user_data);
+
static gboolean
-cb_rstto_thumbnail_bar_thumbnail_button_press_event (RsttoThumbnail *thumb, GdkEventButton *event);
+cb_rstto_thumbnail_bar_thumbnail_button_press_event (GtkWidget *thumb, GdkEventButton *event);
static gboolean
-cb_rstto_thumbnail_bar_thumbnail_button_release_event (RsttoThumbnail *thumb, GdkEventButton *event);
+cb_rstto_thumbnail_bar_thumbnail_button_release_event (GtkWidget *thumb, GdkEventButton *event);
static gboolean
-cb_rstto_thumbnail_bar_thumbnail_motion_notify_event (RsttoThumbnail *thumb,
+cb_rstto_thumbnail_bar_thumbnail_motion_notify_event (GtkWidget *thumb,
GdkEventMotion *event,
gpointer user_data);
@@ -88,31 +102,13 @@ rstto_thumbnail_bar_child_type(GtkContainer *container);
static GtkWidgetClass *parent_class = NULL;
static void
-cb_rstto_thumbnail_bar_nav_new_entry (RsttoNavigator *nav,
- gint nr,
- RsttoNavigatorEntry *entry,
- RsttoThumbnailBar *bar);
-static void
-cb_rstto_thumbnail_bar_nav_iter_changed (RsttoNavigator *nav,
- gint nr,
- RsttoNavigatorEntry *entry,
- RsttoThumbnailBar *bar);
-static void
-cb_rstto_thumbnail_bar_nav_reordered (RsttoNavigator *nav,
- RsttoThumbnailBar *bar);
-static void
-cb_rstto_thumbnail_bar_nav_entry_removed(RsttoNavigator *nav,
- RsttoNavigatorEntry *entry,
- RsttoThumbnailBar *bar);
-
-static void
-cb_rstto_thumbnail_bar_thumbnail_clicked (RsttoThumbnail *thumb, RsttoThumbnailBar *bar);
+cb_rstto_thumbnail_bar_thumbnail_clicked (GtkWidget *thumb, RsttoThumbnailBar *bar);
static gint
-cb_rstto_thumbnail_bar_compare (RsttoThumbnail *a, RsttoThumbnail *b);
+cb_rstto_thumbnail_bar_compare (GtkWidget *a, GtkWidget *b, gpointer);
GType
-rstto_thumbnail_bar_get_type ()
+rstto_thumbnail_bar_get_type (void)
{
static GType rstto_thumbnail_bar_type = 0;
@@ -150,7 +146,7 @@ rstto_thumbnail_bar_init(RsttoThumbnailBar *bar)
gtk_widget_set_events (GTK_WIDGET(bar),
GDK_SCROLL_MASK);
- bar->priv->orientation = GTK_ORIENTATION_HORIZONTAL;
+ bar->priv->orientation = GTK_ORIENTATION_VERTICAL;
bar->priv->offset = 0;
bar->priv->scroll_speed = 20;
@@ -200,17 +196,15 @@ rstto_thumbnail_bar_size_request(GtkWidget *widget, GtkRequisition *requisition)
{
RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(widget);
gint border_width = GTK_CONTAINER(bar)->border_width;
+ GList *iter;
+ GtkRequisition child_requisition;
gtk_widget_style_get(widget, "border-width", &border_width, NULL);
- GSList *iter;
-
- GtkRequisition child_requisition;
-
requisition->height = 70;
requisition->width = 70;
- for(iter = bar->priv->thumbs; iter; iter = g_slist_next(iter))
+ for(iter = bar->priv->thumbs; iter; iter = g_list_next(iter))
{
gtk_widget_size_request(GTK_WIDGET(iter->data), &child_requisition);
requisition->width = MAX(child_requisition.width, requisition->width);
@@ -230,17 +224,18 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(widget);
gint border_width = GTK_CONTAINER(bar)->border_width;
gint spacing = 0;
- gtk_widget_style_get(widget, "spacing", &spacing, NULL);
- widget->allocation = *allocation;
GtkAllocation child_allocation;
GtkRequisition child_requisition;
+ GList *iter = bar->priv->thumbs;
+
+ gtk_widget_style_get(widget, "spacing", &spacing, NULL);
+ widget->allocation = *allocation;
child_allocation.x = border_width;
child_allocation.y = border_width;
child_allocation.height = border_width * 2;
child_allocation.width = border_width * 2;
- GSList *iter = bar->priv->thumbs;
if (GTK_WIDGET_REALIZED(widget))
{
@@ -266,17 +261,9 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
if (bar->priv->auto_center == TRUE)
{
- if (g_slist_position(bar->priv->thumbs, iter) < rstto_navigator_get_position(bar->priv->navigator))
- {
- bar->priv->offset += child_requisition.width + spacing;
- }
- if (g_slist_position(bar->priv->thumbs, iter) == rstto_navigator_get_position(bar->priv->navigator))
- {
- bar->priv->offset += (0.5 * child_requisition.width);
- }
}
- iter = g_slist_next(iter);
+ iter = g_list_next(iter);
}
child_allocation.x -= bar->priv->offset;
@@ -287,7 +274,7 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
child_allocation.height = allocation->height - (border_width * 2);
- child_allocation.width = child_requisition.width;
+ child_allocation.width = child_allocation.height;
if ((child_allocation.x < (allocation->x + allocation->width)) &&
((child_allocation.x + child_allocation.width) > allocation->x + border_width))
@@ -298,8 +285,8 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
else
gtk_widget_set_child_visible(GTK_WIDGET(iter->data), FALSE);
- child_allocation.x += child_requisition.width + spacing;
- iter = g_slist_next(iter);
+ child_allocation.x += child_allocation.width + spacing;
+ iter = g_list_next(iter);
}
break;
case GTK_ORIENTATION_VERTICAL:
@@ -314,17 +301,9 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
if (bar->priv->auto_center == TRUE)
{
- if (g_slist_position(bar->priv->thumbs, iter) < rstto_navigator_get_position(bar->priv->navigator))
- {
- bar->priv->offset += child_requisition.height + spacing;
- }
- if (g_slist_position(bar->priv->thumbs, iter) == rstto_navigator_get_position(bar->priv->navigator))
- {
- bar->priv->offset += (0.5 * child_requisition.height);
- }
}
- iter = g_slist_next(iter);
+ iter = g_list_next(iter);
}
child_allocation.y -= bar->priv->offset;
@@ -336,7 +315,7 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
child_allocation.width = allocation->width - (border_width * 2);
- child_allocation.height = child_requisition.height;
+ child_allocation.height = child_allocation.width;
if (child_allocation.y < (allocation->y + allocation->height))
gtk_widget_set_child_visible(GTK_WIDGET(iter->data), TRUE);
@@ -344,8 +323,8 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
gtk_widget_set_child_visible(GTK_WIDGET(iter->data), FALSE);
gtk_widget_size_allocate(GTK_WIDGET(iter->data), &child_allocation);
- child_allocation.y += child_requisition.height + spacing;
- iter = g_slist_next(iter);
+ child_allocation.y += child_allocation.height + spacing;
+ iter = g_list_next(iter);
}
break;
}
@@ -356,7 +335,7 @@ rstto_thumbnail_bar_expose(GtkWidget *widget, GdkEventExpose *ex)
{
RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(widget);
- GSList *iter = bar->priv->thumbs;
+ GList *iter = bar->priv->thumbs;
GdkEventExpose *n_ex = g_new0(GdkEventExpose, 1);
@@ -450,7 +429,7 @@ rstto_thumbnail_bar_expose(GtkWidget *widget, GdkEventExpose *ex)
break;
}
}
- iter = g_slist_next(iter);
+ iter = g_list_next(iter);
}
return FALSE;
@@ -500,22 +479,36 @@ rstto_thumbnail_bar_unrealize(GtkWidget *widget)
}
GtkWidget *
-rstto_thumbnail_bar_new(RsttoNavigator *navigator)
+rstto_thumbnail_bar_new (RsttoImageList *nav)
{
RsttoThumbnailBar *bar;
bar = g_object_new(RSTTO_TYPE_THUMBNAIL_BAR, NULL);
- bar->priv->navigator = navigator;
-
- g_signal_connect(G_OBJECT(navigator), "new-entry", G_CALLBACK(cb_rstto_thumbnail_bar_nav_new_entry), bar);
- g_signal_connect(G_OBJECT(navigator), "iter-changed", G_CALLBACK(cb_rstto_thumbnail_bar_nav_iter_changed), bar);
- g_signal_connect(G_OBJECT(navigator), "reordered", G_CALLBACK(cb_rstto_thumbnail_bar_nav_reordered), bar);
- g_signal_connect(G_OBJECT(navigator), "entry-removed", G_CALLBACK(cb_rstto_thumbnail_bar_nav_entry_removed), bar);
+ rstto_thumbnail_bar_set_image_list (bar, nav);
return (GtkWidget *)bar;
}
+void
+rstto_thumbnail_bar_set_image_list (RsttoThumbnailBar *bar, RsttoImageList *nav)
+{
+ if (bar->priv->image_list)
+ {
+ g_object_unref (bar->priv->image_list);
+ bar->priv->image_list = NULL;
+ }
+
+ bar->priv->image_list = nav;
+
+ if (bar->priv->image_list)
+ {
+ g_signal_connect (G_OBJECT (bar->priv->image_list), "new-image", G_CALLBACK (cb_rstto_thumbnail_bar_image_list_new_image), bar);
+ g_signal_connect (G_OBJECT (bar->priv->image_list), "remove-image", G_CALLBACK (cb_rstto_thumbnail_bar_image_list_remove_image), bar);
+ g_signal_connect (G_OBJECT (bar->priv->image_list), "remove-all", G_CALLBACK (cb_rstto_thumbnail_bar_image_list_remove_all), bar);
+ g_object_ref (nav);
+ }
+}
/*
* rstto_thumbnail_bar_set_orientation:
*
@@ -546,25 +539,26 @@ rstto_thumbnail_bar_get_orientation (RsttoThumbnailBar *bar)
static void
rstto_thumbnail_bar_add(GtkContainer *container, GtkWidget *child)
{
- g_return_if_fail(GTK_IS_WIDGET(child));
RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(container);
+ g_return_if_fail(GTK_IS_WIDGET(child));
gtk_widget_set_parent(child, GTK_WIDGET(container));
- bar->priv->thumbs = g_slist_insert_sorted(bar->priv->thumbs, child, (GCompareFunc)cb_rstto_thumbnail_bar_compare);
+ bar->priv->thumbs = g_list_insert_sorted_with_data (bar->priv->thumbs, child, (GCompareDataFunc)cb_rstto_thumbnail_bar_compare, bar);
}
static void
rstto_thumbnail_bar_remove(GtkContainer *container, GtkWidget *child)
{
- g_return_if_fail(GTK_IS_WIDGET(child));
-
RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(container);
gboolean widget_was_visible;
+ g_return_if_fail(GTK_IS_WIDGET(child));
+
+
widget_was_visible = GTK_WIDGET_VISIBLE(child);
- bar->priv->thumbs = g_slist_remove(bar->priv->thumbs, child);
+ bar->priv->thumbs = g_list_remove(bar->priv->thumbs, child);
gtk_widget_unparent(child);
@@ -580,7 +574,7 @@ rstto_thumbnail_bar_forall(GtkContainer *container, gboolean include_internals,
g_return_if_fail(callback != NULL);
- g_slist_foreach(bar->priv->thumbs, (GFunc)callback, callback_data);
+ g_list_foreach(bar->priv->thumbs, (GFunc)callback, callback_data);
}
@@ -590,163 +584,18 @@ rstto_thumbnail_bar_child_type(GtkContainer *container)
return GTK_TYPE_WIDGET;
}
-/*
- * cb_rstto_thumbnail_bar_nav_new_entry :
- *
- * @nav : RsttoNavigator
- * @nr : nr
- * @entry :
- * @bar :
- *
- */
-static void
-cb_rstto_thumbnail_bar_nav_new_entry(RsttoNavigator *nav, gint nr, RsttoNavigatorEntry *entry, RsttoThumbnailBar *bar)
-{
- GtkWidget *thumb;
- if (g_slist_length(bar->priv->thumbs) > 0)
- {
- thumb = rstto_thumbnail_new_from_widget(entry, bar->priv->thumbs->data);
- }
- else
- {
- thumb = rstto_thumbnail_new(entry, NULL);
- }
- g_signal_connect(G_OBJECT(thumb), "clicked", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_clicked), bar);
- g_signal_connect(G_OBJECT(thumb), "button_press_event", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_button_press_event), NULL);
- g_signal_connect(G_OBJECT(thumb), "button_release_event", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_button_release_event), NULL);
- g_signal_connect(G_OBJECT(thumb), "motion_notify_event", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_motion_notify_event), NULL);
- gtk_container_add(GTK_CONTAINER(bar), thumb);
- gtk_widget_show(thumb);
-}
-
-/*
- * cb_rstto_thumbnail_bar_nav_iter_changed :
- *
- * @nav : RsttoNavigator
- * @nr : nr
- * @entry :
- * @bar :
- *
- */
-static void
-cb_rstto_thumbnail_bar_nav_iter_changed(RsttoNavigator *nav, gint nr, RsttoNavigatorEntry *entry, RsttoThumbnailBar *bar)
-{
- if (nr == -1)
- {
- gtk_container_foreach(GTK_CONTAINER(bar), (GtkCallback)gtk_widget_destroy, NULL);
- }
- GSList *iter = bar->priv->thumbs;
-
-
- int i = 0;
-
- while (iter != NULL)
- {
- if (entry == rstto_thumbnail_get_entry(RSTTO_THUMBNAIL(iter->data)))
- {
- //gtk_button_clicked(GTK_BUTTON(iter->data));
- break;
- }
- i++;
- iter = g_slist_next(iter);
- }
-
- /* If the children should be autocentered... resize */
- /*
- * if (bar->priv->auto_center == TRUE)
- * gtk_widget_queue_resize(GTK_WIDGET(bar));
- */
-
- gtk_widget_queue_resize(GTK_WIDGET(bar));
-}
-
-/*
- * cb_rstto_thumbnail_bar_nav_reordered :
- *
- * @nav : RsttoNavigator
- * @bar :
- *
- */
-static void
-cb_rstto_thumbnail_bar_nav_reordered (RsttoNavigator *nav, RsttoThumbnailBar *bar)
-{
- gtk_container_foreach(GTK_CONTAINER(bar), (GtkCallback)gtk_widget_destroy, NULL);
- if (bar->priv->thumbs)
- {
- g_slist_free(bar->priv->thumbs);
- bar->priv->thumbs = NULL;
- }
-
- GtkWidget *thumb;
- gint i;
- gint n_files = rstto_navigator_get_n_files(bar->priv->navigator);
-
- for (i = 0; i < n_files; ++i)
- {
- RsttoNavigatorEntry *entry = rstto_navigator_get_nth_file(bar->priv->navigator, i);
- if (g_slist_length(bar->priv->thumbs) > 0)
- {
- thumb = rstto_thumbnail_new_from_widget(entry, bar->priv->thumbs->data);
- }
- else
- {
- thumb = rstto_thumbnail_new(entry, NULL);
- }
-
-
- g_signal_connect(G_OBJECT(thumb), "clicked", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_clicked), bar);
- g_signal_connect(G_OBJECT(thumb), "button_press_event", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_button_press_event), NULL);
- g_signal_connect(G_OBJECT(thumb), "button_release_event", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_button_release_event), NULL);
- g_signal_connect(G_OBJECT(thumb), "motion_notify_event", G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_motion_notify_event), NULL);
- gtk_container_add(GTK_CONTAINER(bar), thumb);
-
- if (rstto_navigator_entry_is_selected(entry))
- {
- RSTTO_THUMBNAIL(thumb)->selected = TRUE;
- }
- }
-
- gtk_container_foreach(GTK_CONTAINER(bar), (GtkCallback)gtk_widget_show, NULL);
-
-
-
- /* If the children should be autocentered... resize */
- /*
- * if (bar->priv->auto_center == TRUE)
- * gtk_widget_queue_resize(GTK_WIDGET(bar));
- */
-
- gtk_widget_queue_resize(GTK_WIDGET(bar));
-}
-
-static void
-cb_rstto_thumbnail_bar_thumbnail_clicked (RsttoThumbnail *thumb, RsttoThumbnailBar *bar)
-{
- if (thumb->selected == TRUE)
- {
- bar->priv->auto_center = TRUE;
- rstto_navigator_entry_select (rstto_thumbnail_get_entry(thumb));
- }
-}
-
static gint
-cb_rstto_thumbnail_bar_compare (RsttoThumbnail *a, RsttoThumbnail *b)
+cb_rstto_thumbnail_bar_compare (GtkWidget *a, GtkWidget *b, gpointer user_data)
{
- RsttoNavigatorEntry *_a = rstto_thumbnail_get_entry(a);
- RsttoNavigatorEntry *_b = rstto_thumbnail_get_entry(b);
+ RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
+ RsttoImage *a_i = rstto_thumbnail_get_image (RSTTO_THUMBNAIL (a));
+ RsttoImage *b_i = rstto_thumbnail_get_image (RSTTO_THUMBNAIL (b));
- if (rstto_navigator_entry_get_position(_a) < rstto_navigator_entry_get_position(_b))
- {
- return -1;
- }
- else
- {
- return 1;
- }
+ return rstto_image_list_get_compare_func (bar->priv->image_list) (a_i, b_i);
}
static gboolean
-cb_rstto_thumbnail_bar_thumbnail_button_press_event (RsttoThumbnail *thumb, GdkEventButton *event)
+cb_rstto_thumbnail_bar_thumbnail_button_press_event (GtkWidget *thumb, GdkEventButton *event)
{
if(event->button == 1)
{
@@ -769,7 +618,7 @@ cb_rstto_thumbnail_bar_thumbnail_button_press_event (RsttoThumbnail *thumb, GdkE
}
static gboolean
-cb_rstto_thumbnail_bar_thumbnail_button_release_event (RsttoThumbnail *thumb, GdkEventButton *event)
+cb_rstto_thumbnail_bar_thumbnail_button_release_event (GtkWidget *thumb, GdkEventButton *event)
{
RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(gtk_widget_get_parent(GTK_WIDGET(thumb)));
if(event->button == 1)
@@ -786,7 +635,7 @@ cb_rstto_thumbnail_bar_thumbnail_button_release_event (RsttoThumbnail *thumb, Gd
}
static gboolean
-cb_rstto_thumbnail_bar_thumbnail_motion_notify_event (RsttoThumbnail *thumb,
+cb_rstto_thumbnail_bar_thumbnail_motion_notify_event (GtkWidget *thumb,
GdkEventMotion *event,
gpointer user_data)
{
@@ -822,7 +671,7 @@ cb_rstto_thumbnail_bar_scroll_event (RsttoThumbnailBar *bar,
gpointer *user_data)
{
gint thumb_size;
- GSList *thumb;
+ GList *thumb;
gint border_width = GTK_CONTAINER(bar)->border_width;
switch(event->direction)
@@ -859,10 +708,10 @@ cb_rstto_thumbnail_bar_scroll_event (RsttoThumbnailBar *bar,
{
case GTK_ORIENTATION_HORIZONTAL:
thumb_size = GTK_WIDGET(bar->priv->thumbs->data)->allocation.width;
- for (thumb = bar->priv->thumbs; thumb != NULL; thumb = g_slist_next(thumb))
+ for (thumb = bar->priv->thumbs; thumb != NULL; thumb = g_list_next(thumb))
{
size += GTK_WIDGET(thumb->data)->allocation.width;
- if (g_slist_next(thumb))
+ if (g_list_next(thumb))
size += border_width;
}
if ((size - thumb_size) <= bar->priv->offset)
@@ -870,10 +719,10 @@ cb_rstto_thumbnail_bar_scroll_event (RsttoThumbnailBar *bar,
break;
case GTK_ORIENTATION_VERTICAL:
thumb_size = GTK_WIDGET(bar->priv->thumbs->data)->allocation.height;
- for (thumb = bar->priv->thumbs; thumb != NULL; thumb = g_slist_next(thumb))
+ for (thumb = bar->priv->thumbs; thumb != NULL; thumb = g_list_next(thumb))
{
size += GTK_WIDGET(thumb->data)->allocation.height;
- if (g_slist_next(thumb))
+ if (g_list_next(thumb))
size += border_width;
}
if ((size - thumb_size) <= bar->priv->offset)
@@ -888,19 +737,90 @@ cb_rstto_thumbnail_bar_scroll_event (RsttoThumbnailBar *bar,
}
+void
+rstto_thumbnail_bar_set_iter (RsttoThumbnailBar *bar, RsttoImageListIter *iter)
+{
+ if (bar->priv->iter)
+ {
+ g_signal_handlers_disconnect_by_func (bar->priv->iter, cb_rstto_thumbnail_bar_image_list_iter_changed, bar);
+
+ g_object_unref (bar->priv->iter);
+ g_object_unref (bar->priv->internal_iter);
+ bar->priv->internal_iter = NULL;
+ }
+
+ bar->priv->iter = iter;
+
+ if (bar->priv->iter)
+ {
+ g_object_ref (bar->priv->iter);
+ bar->priv->internal_iter = rstto_image_list_iter_clone (bar->priv->iter);
+ g_signal_connect (bar->priv->iter, "changed", G_CALLBACK (cb_rstto_thumbnail_bar_image_list_iter_changed), bar);
+ }
+}
+
+void
+cb_rstto_thumbnail_bar_image_list_iter_changed (RsttoImageListIter *iter, gpointer user_data)
+{
+ RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
+ /* useless, but keepsthe compiler silent */
+ bar->priv->begin=0;
+}
+
static void
-cb_rstto_thumbnail_bar_nav_entry_removed(RsttoNavigator *nav, RsttoNavigatorEntry *entry, RsttoThumbnailBar *bar)
+cb_rstto_thumbnail_bar_image_list_new_image (RsttoImageList *image_list, RsttoImage *image, gpointer user_data)
{
- GSList *iter = bar->priv->thumbs;
+ RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
+ GtkWidget *thumb;
+
+ g_return_if_fail (rstto_image_list_iter_find_image (bar->priv->internal_iter, image));
+
+ thumb = rstto_thumbnail_new (image);
+
+ gtk_container_add (GTK_CONTAINER (bar), thumb);
+ gtk_widget_show_all (thumb);
- while (iter != NULL)
+ g_signal_connect (thumb, "clicked", G_CALLBACK (cb_rstto_thumbnail_bar_thumbnail_clicked), bar);
+ g_signal_connect (thumb, "button_press_event", G_CALLBACK (cb_rstto_thumbnail_bar_thumbnail_button_press_event), bar);
+ g_signal_connect (thumb, "button_release_event", G_CALLBACK (cb_rstto_thumbnail_bar_thumbnail_button_release_event), bar);
+ g_signal_connect (thumb, "motion_notify_event", G_CALLBACK (cb_rstto_thumbnail_bar_thumbnail_motion_notify_event), bar);
+}
+
+static void
+cb_rstto_thumbnail_bar_image_list_remove_image (RsttoImageList *image_list, RsttoImage *image, gpointer user_data)
+{
+ RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
+ GList *iter = bar->priv->thumbs;
+
+ while (iter)
{
- if (entry == rstto_thumbnail_get_entry(RSTTO_THUMBNAIL(iter->data)))
+ if (rstto_thumbnail_get_image (iter->data) == image)
{
- g_signal_handlers_disconnect_by_func(G_OBJECT(iter->data), G_CALLBACK(cb_rstto_thumbnail_bar_thumbnail_clicked), bar);
- gtk_widget_destroy(GTK_WIDGET(iter->data));
+ GtkWidget *widget = iter->data;
+ gtk_container_remove (GTK_CONTAINER (bar), widget);
break;
}
- iter = g_slist_next(iter);
+ iter = g_list_next (iter);
}
}
+
+static void
+cb_rstto_thumbnail_bar_image_list_remove_all (RsttoImageList *image_list, gpointer user_data)
+{
+ RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
+ if (bar->priv->thumbs)
+ {
+ g_list_foreach (bar->priv->thumbs, (GFunc)(gtk_widget_destroy), NULL);
+ g_list_free (bar->priv->thumbs);
+ bar->priv->thumbs = NULL;
+ }
+}
+
+
+
+static void
+cb_rstto_thumbnail_bar_thumbnail_clicked (GtkWidget *thumb, RsttoThumbnailBar *bar)
+{
+ g_return_if_fail (bar->priv->iter);
+ rstto_image_list_iter_set_position (bar->priv->iter, g_list_index(bar->priv->thumbs, thumb));
+}
diff --git a/src/thumbnail_bar.h b/src/thumbnail_bar.h
index bb4c687..e5cb3cb 100644
--- a/src/thumbnail_bar.h
+++ b/src/thumbnail_bar.h
@@ -63,6 +63,9 @@ GtkWidget *rstto_thumbnail_bar_new();
void rstto_thumbnail_bar_set_orientation (RsttoThumbnailBar *, GtkOrientation);
GtkOrientation rstto_thumbnail_bar_get_orientation (RsttoThumbnailBar *);
+void rstto_thumbnail_bar_set_image_list (RsttoThumbnailBar *bar, RsttoImageList *nav);
+void rstto_thumbnail_bar_set_iter (RsttoThumbnailBar *bar, RsttoImageListIter *iter);
+
G_END_DECLS
#endif /* __RISTRETTO_THUMBNAIL_BAR_H__ */
More information about the Xfce4-commits
mailing list