Changeset cafd66941f4c7a020c73c26bd7383c6bcf522fb9
- Timestamp:
- 07/29/08 11:25:01
(4 months ago)
- Author:
- Dave Foster <daf@minuslab.net>
- git-committer:
- Dave Foster <daf@minuslab.net> 1217355901 -0400
- git-parent:
[90ee6b7c31468b9b240ffdce54f2f6e4345f1608]
- git-author:
- Dave Foster <daf@minuslab.net> 1217355901 -0400
- Message:
Better rounded tree model record, added stub for currently set bg display.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r90ee6b7 |
rcafd669 |
|
| 99 | 99 | Gtk::TreeModel::iterator iter = (view.store)->get_iter(path); |
|---|
| 100 | 100 | Gtk::TreeModel::Row row = *iter; |
|---|
| 101 | | this->set_bg(row[view.filename]); |
|---|
| | 101 | this->set_bg(row[view.record.Filename]); |
|---|
| 102 | 102 | |
|---|
| 103 | 103 | } |
|---|
| … | … | |
| 113 | 113 | Gtk::TreeModel::iterator iter = view.view.get_selection()->get_selected (); |
|---|
| 114 | 114 | Gtk::TreeModel::Row row = *iter; |
|---|
| 115 | | Glib::ustring file = row[view.filename]; |
|---|
| | 115 | Glib::ustring file = row[view.record.Filename]; |
|---|
| 116 | 116 | this->set_bg(file); |
|---|
| 117 | 117 | |
|---|
| … | … | |
| 301 | 301 | for (Gtk::TreeIter iter = view.store->children().begin(); iter != view.store->children().end(); iter++) |
|---|
| 302 | 302 | { |
|---|
| 303 | | if ( (*iter)[view.filename] == default_selection) { |
|---|
| | 303 | if ( (*iter)[view.record.Filename] == default_selection) { |
|---|
| 304 | 304 | view.view.get_selection()->select(iter); |
|---|
| 305 | 305 | view.view.scroll_to_row(Gtk::TreeModel::Path(iter), 0.5); |
|---|
| r014e7ee |
rcafd669 |
|
| 67 | 67 | Glib::RefPtr<Gdk::Pixbuf> thumb = base.get(); |
|---|
| 68 | 68 | |
|---|
| 69 | | if (thumb == thumbview->loading_image && !row[thumbview->loadingthumb]) |
|---|
| | 69 | if (thumb == thumbview->loading_image && !row[thumbview->record.LoadingThumb]) |
|---|
| 70 | 70 | { |
|---|
| 71 | 71 | TreePair* tp = new TreePair(); |
|---|
| 72 | | tp->file = row[thumbview->filename]; |
|---|
| | 72 | tp->file = row[thumbview->record.Filename]; |
|---|
| 73 | 73 | tp->iter = iter; |
|---|
| 74 | 74 | |
|---|
| 75 | | row[thumbview->loadingthumb] = true; |
|---|
| | 75 | row[thumbview->record.LoadingThumb] = true; |
|---|
| 76 | 76 | |
|---|
| 77 | 77 | Util::program_log("Custom model: planning on loading %s\n", tp->file.c_str()); |
|---|
| … | … | |
| 94 | 94 | this->aqueue_createthumbs = g_async_queue_new(); |
|---|
| 95 | 95 | this->aqueue_donethumbs = g_async_queue_new(); |
|---|
| 96 | | |
|---|
| 97 | | // build model record |
|---|
| 98 | | record.add (thumbnail); |
|---|
| 99 | | record.add (description); |
|---|
| 100 | | record.add (filename); |
|---|
| 101 | | record.add (time); |
|---|
| 102 | | record.add (loadingthumb); |
|---|
| 103 | 96 | |
|---|
| 104 | 97 | // create store |
|---|
| … | … | |
| 124 | 117 | this->col_desc = new Gtk::TreeViewColumn("description", this->rend); |
|---|
| 125 | 118 | |
|---|
| 126 | | col_thumb->add_attribute (rend_img, "pixbuf", thumbnail); |
|---|
| | 119 | col_thumb->add_attribute (rend_img, "pixbuf", record.Thumbnail); |
|---|
| 127 | 120 | col_thumb->set_sizing(Gtk::TREE_VIEW_COLUMN_FIXED); |
|---|
| 128 | 121 | col_thumb->set_fixed_width(105); |
|---|
| 129 | | col_desc->add_attribute (rend, "text", description); |
|---|
| 130 | | col_desc->set_sort_column (filename); |
|---|
| | 122 | col_desc->add_attribute (rend, "text", record.Description); |
|---|
| | 123 | col_desc->set_sort_column (record.Filename); |
|---|
| 131 | 124 | col_desc->set_sort_indicator (true); |
|---|
| 132 | 125 | col_desc->set_sort_order (Gtk::SORT_ASCENDING); |
|---|
| … | … | |
| 137 | 130 | |
|---|
| 138 | 131 | // enable search |
|---|
| 139 | | view.set_search_column (description); |
|---|
| | 132 | view.set_search_column (record.Description); |
|---|
| 140 | 133 | view.set_search_equal_func (sigc::mem_fun (this, &Thumbview::search_compare)); |
|---|
| 141 | 134 | |
|---|
| … | … | |
| 176 | 169 | Gtk::TreeModel::Row row = *iter; |
|---|
| 177 | 170 | Glib::RefPtr<Gdk::Pixbuf> thumb = this->loading_image; |
|---|
| 178 | | row[thumbnail] = thumb; |
|---|
| 179 | | row[this->filename] = filename; |
|---|
| 180 | | row[description] = Glib::ustring(filename, filename.rfind ("/")+1); |
|---|
| | 171 | row[record.Thumbnail] = thumb; |
|---|
| | 172 | row[record.Filename] = filename; |
|---|
| | 173 | row[record.Description] = Glib::ustring(filename, filename.rfind ("/")+1); |
|---|
| 181 | 174 | |
|---|
| 182 | 175 | // for modified time |
|---|
| 183 | | row[time] = get_file_mtime(filename); |
|---|
| | 176 | row[record.Time] = get_file_mtime(filename); |
|---|
| 184 | 177 | |
|---|
| 185 | 178 | Util::program_log("add_file(): Adding file %s\n", filename.c_str()); |
|---|
| … | … | |
| 507 | 500 | { |
|---|
| 508 | 501 | Gtk::TreeModel::Row row = *iter; |
|---|
| 509 | | row[thumbnail] = pb; |
|---|
| | 502 | row[record.Thumbnail] = pb; |
|---|
| 510 | 503 | // desc |
|---|
| 511 | | row[description] = Glib::ustring(file, file.rfind("/")+1); |
|---|
| | 504 | row[record.Description] = Glib::ustring(file, file.rfind("/")+1); |
|---|
| 512 | 505 | |
|---|
| 513 | 506 | // emit a changed signal |
|---|
| … | … | |
| 519 | 512 | */ |
|---|
| 520 | 513 | bool Thumbview::search_compare (const Glib::RefPtr<Gtk::TreeModel>& model, int column, const Glib::ustring& key, const Gtk::TreeModel::iterator& iter) { |
|---|
| 521 | | Glib::ustring target = (*iter)[description]; |
|---|
| | 514 | Glib::ustring target = (*iter)[record.Description]; |
|---|
| 522 | 515 | if (target.find (key) != Glib::ustring::npos) { |
|---|
| 523 | 516 | return false; |
|---|
| … | … | |
| 532 | 525 | switch (mode) { |
|---|
| 533 | 526 | case SORT_ALPHA: |
|---|
| 534 | | store->set_sort_column (description, Gtk::SORT_ASCENDING); |
|---|
| | 527 | store->set_sort_column (record.Description, Gtk::SORT_ASCENDING); |
|---|
| 535 | 528 | break; |
|---|
| 536 | 529 | case SORT_RALPHA: |
|---|
| 537 | | store->set_sort_column (description, Gtk::SORT_DESCENDING); |
|---|
| | 530 | store->set_sort_column (record.Description, Gtk::SORT_DESCENDING); |
|---|
| 538 | 531 | break; |
|---|
| 539 | 532 | case SORT_TIME: |
|---|
| 540 | | store->set_sort_column (time, Gtk::SORT_ASCENDING); |
|---|
| | 533 | store->set_sort_column (record.Time, Gtk::SORT_ASCENDING); |
|---|
| 541 | 534 | break; |
|---|
| 542 | 535 | case SORT_RTIME: |
|---|
| 543 | | store->set_sort_column (time, Gtk::SORT_DESCENDING); |
|---|
| | 536 | store->set_sort_column (record.Time, Gtk::SORT_DESCENDING); |
|---|
| 544 | 537 | break; |
|---|
| 545 | 538 | } |
|---|
| … | … | |
| 562 | 555 | Gtk::TreeModel::Children children = store->children(); |
|---|
| 563 | 556 | for (iter = children.begin(); iter != children.end(); iter++) { |
|---|
| 564 | | Glib::ustring this_filename = (*iter)[this->filename]; |
|---|
| | 557 | Glib::ustring this_filename = (*iter)[record.Filename]; |
|---|
| 565 | 558 | if (this_filename == filename) { |
|---|
| 566 | 559 | // remove this iter. |
|---|
| r014e7ee |
rcafd669 |
|
| 62 | 62 | }; |
|---|
| 63 | 63 | |
|---|
| | 64 | ///////////////////////////////////////////////////////////////////////////// |
|---|
| | 65 | |
|---|
| | 66 | /** |
|---|
| | 67 | * Column record for the Thumbview store. |
|---|
| | 68 | */ |
|---|
| | 69 | class ThumbviewRecord : public Gtk::TreeModelColumnRecord |
|---|
| | 70 | { |
|---|
| | 71 | public: |
|---|
| | 72 | ThumbviewRecord() |
|---|
| | 73 | { |
|---|
| | 74 | add(Thumbnail); |
|---|
| | 75 | add(Description); |
|---|
| | 76 | add(Filename); |
|---|
| | 77 | add(Time); |
|---|
| | 78 | add(LoadingThumb); |
|---|
| | 79 | add(CurBGOnDisp); |
|---|
| | 80 | } |
|---|
| | 81 | |
|---|
| | 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; |
|---|
| | 88 | }; |
|---|
| | 89 | |
|---|
| | 90 | |
|---|
| | 91 | ///////////////////////////////////////////////////////////////////////////// |
|---|
| | 92 | |
|---|
| 64 | 93 | class Thumbview : public Gtk::ScrolledWindow { |
|---|
| 65 | 94 | public: |
|---|
| … | … | |
| 76 | 105 | void set_dir(std::string indir) { this->dir = indir; } |
|---|
| 77 | 106 | |
|---|
| 78 | | // TODO: make private? |
|---|
| 79 | | Gtk::TreeModelColumn<Glib::ustring> filename; |
|---|
| 80 | | Gtk::TreeModelColumn<Glib::ustring> description; |
|---|
| 81 | | Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > thumbnail; |
|---|
| 82 | | Gtk::TreeModelColumn<time_t> time; |
|---|
| 83 | | Gtk::TreeModelColumn<bool> loadingthumb; |
|---|
| 84 | | |
|---|
| 85 | 107 | Glib::RefPtr<DelayLoadingStore> store; |
|---|
| 86 | 108 | Gtk::TreeView view; |
|---|
| 87 | | |
|---|
| | 109 | ThumbviewRecord record; |
|---|
| | 110 | |
|---|
| 88 | 111 | // dispatcher |
|---|
| 89 | 112 | Glib::Dispatcher dispatch_thumb; |
|---|
| … | … | |
| 100 | 123 | // loading image |
|---|
| 101 | 124 | Glib::RefPtr<Gdk::Pixbuf> loading_image; |
|---|
| 102 | | |
|---|
| | 125 | |
|---|
| 103 | 126 | protected: |
|---|
| 104 | 127 | |
|---|
| … | … | |
| 112 | 135 | void add_file(std::string filename); |
|---|
| 113 | 136 | void handle_dispatch_thumb(); |
|---|
| 114 | | |
|---|
| 115 | | Gtk::TreeModel::ColumnRecord record; |
|---|
| 116 | 137 | |
|---|
| 117 | 138 | Gtk::TreeViewColumn *col_thumb; |
|---|