3 This file is from Nitrogen, an X11 background setter.
4 Copyright (C) 2006 Dave Foster & Javeed Shaikh
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 //#include "Inotify.h"
32 Gtk::TreeModel::iterator iter
;
33 Glib::RefPtr
<Gdk::Pixbuf
> thumb
;
38 class DelayLoadingStore
: public Gtk::ListStore
41 static Glib::RefPtr
<DelayLoadingStore
> create(const Gtk::TreeModelColumnRecord
& columns
)
43 return Glib::RefPtr
<DelayLoadingStore
>(new DelayLoadingStore(columns
));
47 DelayLoadingStore() : Gtk::ListStore() {}
48 DelayLoadingStore(const Gtk::TreeModelColumnRecord
& columns
) : Gtk::ListStore(columns
) {}
51 virtual void get_value_vfunc (const iterator
& iter
, int column
, Glib::ValueBase
& value
) const;
54 void set_queue(GAsyncQueue
*queue
) { aqueue_loadthumbs
= queue
; }
55 void set_thumbview(Thumbview
*view
) { thumbview
= view
; }
58 GAsyncQueue
*aqueue_loadthumbs
;
64 /////////////////////////////////////////////////////////////////////////////
67 * Column record for the Thumbview store.
69 class ThumbviewRecord
: public Gtk::TreeModelColumnRecord
82 Gtk::TreeModelColumn
<Glib::ustring
> Filename
;
83 Gtk::TreeModelColumn
<Glib::ustring
> Description
;
84 Gtk::TreeModelColumn
< Glib::RefPtr
<Gdk::Pixbuf
> > Thumbnail
;
85 Gtk::TreeModelColumn
<time_t> Time
;
86 Gtk::TreeModelColumn
<bool> LoadingThumb
;
87 Gtk::TreeModelColumn
<Glib::ustring
> CurBGOnDisp
;
91 /////////////////////////////////////////////////////////////////////////////
93 class Thumbview
: public Gtk::ScrolledWindow
{
105 void set_dir(std::string indir
) { this->dir
= indir
; }
107 Glib::RefPtr
<DelayLoadingStore
> store
;
109 ThumbviewRecord record
;
112 Glib::Dispatcher dispatch_thumb
;
115 void load_cache_images();
116 void create_cache_images();
117 void load_dir(std::string dir
= "");
119 void set_sort_mode (SortMode mode
);
120 // search compare function
121 bool search_compare (const Glib::RefPtr
<Gtk::TreeModel
>& model
, int column
, const Glib::ustring
& key
, const Gtk::TreeModel::iterator
& iter
);
124 Glib::RefPtr
<Gdk::Pixbuf
> loading_image
;
126 // "cache" of config - maps displays to full filenames
127 std::map
<Glib::ustring
, Glib::ustring
> map_setbgs
;
128 void load_map_setbgs();
133 void file_deleted_callback(std::string filename
);
134 void file_changed_callback(std::string filename
);
135 void file_created_callback(std::string filename
);
136 std::map
<std::string
, Inotify::Watch
*> watches
;
139 void add_file(std::string filename
);
140 void handle_dispatch_thumb();
142 Gtk::TreeViewColumn
*col_thumb
;
143 Gtk::TreeViewColumn
*col_desc
;
145 Gtk::CellRendererPixbuf rend_img
;
146 Gtk::CellRendererText rend
;
149 bool is_image(std::string file
);
150 Glib::ustring
cache_file(Glib::ustring file
);
151 void update_thumbnail(Glib::ustring file
, Gtk::TreeModel::iterator iter
, Glib::RefPtr
<Gdk::Pixbuf
> pb
);
154 // TODO: remove when we get a proper db
157 // load thumbnail queue
158 GAsyncQueue
* aqueue_loadthumbs
;
159 GAsyncQueue
* aqueue_createthumbs
;
160 GAsyncQueue
* aqueue_donethumbs
;