[niepce] Rework the FilmStrip to have a C++ control and less glitches.
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [niepce] Rework the FilmStrip to have a C++ control and less glitches.
- Date: Fri, 17 Jul 2009 03:56:47 +0000 (UTC)
commit ac97f234bc41062928e4c8cac80662ada55ee4c0
Author: Hubert Figuiere <hub figuiere net>
Date: Tue Jul 14 14:23:34 2009 -0400
Rework the FilmStrip to have a C++ control and less glitches.
ChangeLog | 4 +
src/niepce/ui/Makefile.am | 2 +-
src/niepce/ui/filmstripcontroller.cpp | 94 +---
src/niepce/ui/filmstripcontroller.hpp | 6 +-
src/niepce/ui/niepcewindow.cpp | 4 +-
src/niepce/ui/thumb-view/eog-thumb-nav.cpp | 52 +-
src/niepce/ui/thumb-view/eog-thumb-nav.hpp | 4 +-
src/niepce/ui/thumb-view/eog-thumb-view.cpp | 785 ---------------------------
src/niepce/ui/thumb-view/eog-thumb-view.hpp | 91 ---
src/niepce/ui/thumbstripview.cpp | 277 ++++++++++
src/niepce/ui/thumbstripview.hpp | 68 +++
11 files changed, 404 insertions(+), 983 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c8dcd3f..3235996 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-07-14 Hubert Figuiere <hub figuiere net>
+
+ * Rework the FilmStrip to have a C++ control and less glitches.
+
2009-07-13 Hubert Figuiere <hub figuiere net>
* Really merge menus properly.
diff --git a/src/niepce/ui/Makefile.am b/src/niepce/ui/Makefile.am
index 9492812..93547ba 100644
--- a/src/niepce/ui/Makefile.am
+++ b/src/niepce/ui/Makefile.am
@@ -43,6 +43,6 @@ libniepceui_a_SOURCES = \
filmstripcontroller.hpp filmstripcontroller.cpp \
dialogs/importdialog.hpp dialogs/importdialog.cpp \
thumb-view/eog-thumb-nav.cpp thumb-view/eog-thumb-nav.hpp \
- thumb-view/eog-thumb-view.cpp thumb-view/eog-thumb-view.hpp \
+ thumbstripview.cpp thumbstripview.hpp \
$(PUBLICHEADERS) \
$(NULL)
diff --git a/src/niepce/ui/filmstripcontroller.cpp b/src/niepce/ui/filmstripcontroller.cpp
index fb9677f..d0bfa7e 100644
--- a/src/niepce/ui/filmstripcontroller.cpp
+++ b/src/niepce/ui/filmstripcontroller.cpp
@@ -1,7 +1,7 @@
/*
- * niepce - ui/filmstripcontroller.cpp
+ * niepce - niepce/ui/filmstripcontroller.cpp
*
- * Copyright (C) 2008 Hubert Figuiere
+ * Copyright (C) 2008-2009 Hubert Figuiere
*
* 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
@@ -26,7 +26,7 @@
#include "fwk/base/debug.hpp"
#include "eog-thumb-nav.hpp"
-#include "eog-thumb-view.hpp"
+#include "thumbstripview.hpp"
#include "filmstripcontroller.hpp"
namespace ui {
@@ -42,94 +42,48 @@ Gtk::Widget * FilmStripController::buildWidget(const Glib::RefPtr<Gtk::UIManager
return m_widget;
}
DBG_ASSERT(m_store, "m_store NULL");
- m_thumbview = Glib::wrap(GTK_ICON_VIEW(eog_thumb_view_new(m_store)));
- GtkWidget *thn = eog_thumb_nav_new(GTK_WIDGET(m_thumbview->gobj()),
- EOG_THUMB_NAV_MODE_ONE_ROW, true);
- gtk_icon_view_set_selection_mode(GTK_ICON_VIEW(m_thumbview->gobj()),
- GTK_SELECTION_SINGLE);
- m_widget = Glib::wrap(thn);
- return m_widget;
+ m_thumbview = manage(new ThumbStripView(m_store));
+ GtkWidget *thn = eog_thumb_nav_new(m_thumbview,
+ EOG_THUMB_NAV_MODE_ONE_ROW, true);
+ m_thumbview->set_selection_mode(Gtk::SELECTION_SINGLE);
+ m_widget = Glib::wrap(thn);
+ m_widget->set_size_request(-1, 145);
+ return m_widget;
}
Gtk::IconView * FilmStripController::image_list()
{
- return m_thumbview;
+ return m_thumbview;
}
int FilmStripController::get_selected()
{
- int id = 0;
- Gtk::IconView::ArrayHandle_TreePaths paths = m_thumbview->get_selected_items();
- if(!paths.empty()) {
- Gtk::TreePath path(*(paths.begin()));
- DBG_OUT("found path %s", path.to_string().c_str());
- Gtk::TreeRow row = *(m_store->get_iter(path));
- if(row) {
- DBG_OUT("found row");
+ int id = 0;
+ DBG_OUT("get selected in filmstrip");
+ Gtk::IconView::ArrayHandle_TreePaths paths = m_thumbview->get_selected_items();
+ if(!paths.empty()) {
+ Gtk::TreePath path(*(paths.begin()));
+ DBG_OUT("found path %s", path.to_string().c_str());
+ Gtk::TreeRow row = *(m_store->get_iter(path));
+ if(row) {
+ DBG_OUT("found row");
eng::LibFile::Ptr libfile = row[m_store->columns().m_libfile];
if(libfile) {
id = libfile->id();
}
- }
- }
- return id;
+ }
+ }
+ return id;
}
void FilmStripController::select_image(int id)
{
- DBG_OUT("filmstrip select %d", id);
+ DBG_OUT("filmstrip select %d", id);
Gtk::TreePath path = m_store->get_path_from_id(id);
m_thumbview->select_path(path);
}
-#if 0
-void FilmStripController::on_lib_notification(const framework::Notification::Ptr &n)
-{
- DBG_ASSERT(n->type() == niepce::NOTIFICATION_LIB, "wrong notification type");
- if(n->type() == niepce::NOTIFICATION_LIB) {
- eng::LibNotification ln = boost::any_cast<eng::LibNotification>(n->data());
- switch(ln.type) {
- case eng::Library::NOTIFY_FOLDER_CONTENT_QUERIED:
- case eng::Library::NOTIFY_KEYWORD_CONTENT_QUERIED:
- {
- eng::LibFile::ListPtr l
- = boost::any_cast<eng::LibFile::ListPtr>(ln.param);
- DBG_OUT("received folder content file # %d", l->size());
-
- Glib::RefPtr<EogListStore> store(new EogListStore( *l ));
- eog_thumb_view_set_model((EogThumbView*)(m_thumbview->gobj()),
- store);
- break;
- }
- default:
- break;
- }
- }
-}
-
-
-void FilmStripController::on_tnail_notification(const framework::Notification::Ptr &n)
-{
- DBG_ASSERT(n->type() == niepce::NOTIFICATION_THUMBNAIL, "wrong notification type");
- if(n->type() == niepce::NOTIFICATION_THUMBNAIL) {
- Glib::RefPtr<EogListStore> store
- = eog_thumb_view_get_model((EogThumbView*)(m_thumbview->gobj()));
- library::ThumbnailNotification tn
- = boost::any_cast<library::ThumbnailNotification>(n->data());
- Gtk::TreeRow row;
- bool found = store->find_by_id(tn.id, row);
- if(found) {
- // FIXME parametrize
- row[store->m_columns.m_thumbnail] = framework::gdkpixbuf_scale_to_fit(tn.pixmap, 100);
- }
- else {
- DBG_OUT("row %d not found", tn.id);
- }
- }
-}
-#endif
-
}
/*
diff --git a/src/niepce/ui/filmstripcontroller.hpp b/src/niepce/ui/filmstripcontroller.hpp
index 4b3701d..374aee3 100644
--- a/src/niepce/ui/filmstripcontroller.hpp
+++ b/src/niepce/ui/filmstripcontroller.hpp
@@ -1,7 +1,7 @@
/*
- * niepce - ui/filmstripcontroller.h
+ * niepce - niepce/ui/filmstripcontroller.h
*
- * Copyright (C) 2008 Hubert Figuiere
+ * Copyright (C) 2008-2009 Hubert Figuiere
*
* 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
@@ -47,8 +47,6 @@ public:
virtual int get_selected();
virtual void select_image(int id);
-// void on_tnail_notification(const framework::Notification::Ptr &);
-// void on_lib_notification(const framework::Notification::Ptr &);
virtual Gtk::Widget * buildWidget(const Glib::RefPtr<Gtk::UIManager> &);
private:
diff --git a/src/niepce/ui/niepcewindow.cpp b/src/niepce/ui/niepcewindow.cpp
index 565a48e..e24a025 100644
--- a/src/niepce/ui/niepcewindow.cpp
+++ b/src/niepce/ui/niepcewindow.cpp
@@ -34,14 +34,14 @@
#include "fwk/base/debug.hpp"
#include "fwk/base/moniker.hpp"
#include "fwk/utils/boost.hpp"
-#include "engine/db/library.hpp"
#include "fwk/toolkit/application.hpp"
#include "fwk/toolkit/configuration.hpp"
#include "fwk/toolkit/notificationcenter.hpp"
#include "fwk/toolkit/configdatabinder.hpp"
#include "fwk/toolkit/undo.hpp"
+#include "engine/db/library.hpp"
-#include "eog-thumb-view.hpp"
+#include "thumbstripview.hpp"
#include "niepcewindow.hpp"
#include "dialogs/importdialog.hpp"
#include "dialogs/preferencesdialog.hpp"
diff --git a/src/niepce/ui/thumb-view/eog-thumb-nav.cpp b/src/niepce/ui/thumb-view/eog-thumb-nav.cpp
index df2d68d..c384ff9 100644
--- a/src/niepce/ui/thumb-view/eog-thumb-nav.cpp
+++ b/src/niepce/ui/thumb-view/eog-thumb-nav.cpp
@@ -1,8 +1,9 @@
/* Eye Of Gnome - Thumbnail Navigator
*
* Copyright (C) 2006 The Free Software Foundation
+ * Copyright (C) 2009 Hubert Figuiere
*
- * Author: Lucas Rocha <lucasr gnome org>
+ * Original author: Lucas Rocha <lucasr gnome 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
@@ -23,8 +24,6 @@
#include "config.h"
#endif
-#include "eog-thumb-nav.hpp"
-#include "eog-thumb-view.hpp"
#include <glib.h>
#include <glib/gi18n.h>
@@ -32,6 +31,9 @@
#include <gtk/gtk.h>
#include <string.h>
+#include "eog-thumb-nav.hpp"
+#include "thumbstripview.hpp"
+
#define EOG_THUMB_NAV_GET_PRIVATE(object) \
(G_TYPE_INSTANCE_GET_PRIVATE ((object), EOG_TYPE_THUMB_NAV, EogThumbNavPrivate))
@@ -57,7 +59,7 @@ struct _EogThumbNavPrivate {
GtkWidget *button_right;
GtkWidget *sw;
GtkWidget *scale;
- GtkWidget *thumbview;
+ ui::ThumbStripView *thumbview;
};
static void
@@ -194,7 +196,7 @@ eog_thumb_nav_get_property (GObject *object,
break;
case PROP_THUMB_VIEW:
- g_value_set_object (value, nav->priv->thumbview);
+ g_value_set_pointer (value, nav->priv->thumbview);
break;
case PROP_MODE:
@@ -220,8 +222,7 @@ eog_thumb_nav_set_property (GObject *object,
break;
case PROP_THUMB_VIEW:
- nav->priv->thumbview =
- GTK_WIDGET (g_value_get_object (value));
+ nav->priv->thumbview = (ui::ThumbStripView *)(g_value_get_pointer (value));
break;
case PROP_MODE:
@@ -245,7 +246,8 @@ eog_thumb_nav_constructor (GType type,
priv = EOG_THUMB_NAV (object)->priv;
if (priv->thumbview != NULL) {
- gtk_container_add (GTK_CONTAINER (priv->sw), priv->thumbview);
+ gtk_container_add (GTK_CONTAINER (priv->sw),
+ (GtkWidget*)priv->thumbview->gobj());
gtk_widget_show_all (priv->sw);
}
@@ -271,10 +273,9 @@ eog_thumb_nav_class_init (EogThumbNavClass *klass)
g_object_class_install_property (g_object_class,
PROP_THUMB_VIEW,
- g_param_spec_object ("thumbview",
+ g_param_spec_pointer ("thumbview",
"Thumbnail View",
"The internal thumbnail viewer widget",
- EOG_TYPE_THUMB_VIEW,
(GParamFlags)(G_PARAM_CONSTRUCT_ONLY |
G_PARAM_READABLE |
G_PARAM_WRITABLE)));
@@ -364,7 +365,7 @@ eog_thumb_nav_init (EogThumbNav *nav)
}
GtkWidget *
-eog_thumb_nav_new (GtkWidget *thumbview,
+eog_thumb_nav_new (Gtk::Widget *thumbview,
EogThumbNavMode mode,
gboolean show_buttons)
{
@@ -430,12 +431,10 @@ eog_thumb_nav_set_mode (EogThumbNav *nav, EogThumbNavMode mode)
switch (mode)
{
case EOG_THUMB_NAV_MODE_ONE_ROW:
- gtk_icon_view_set_columns (GTK_ICON_VIEW (priv->thumbview),
- G_MAXINT);
+ priv->thumbview->set_columns (G_MAXINT);
- gtk_widget_set_size_request (priv->thumbview, -1, 108);
- eog_thumb_view_set_item_height (EOG_THUMB_VIEW (priv->thumbview),
- 100);
+ priv->thumbview->set_size_request (-1, -1);
+ priv->thumbview->set_item_height (100);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->sw),
GTK_POLICY_ALWAYS,
@@ -446,11 +445,10 @@ eog_thumb_nav_set_mode (EogThumbNav *nav, EogThumbNavMode mode)
break;
case EOG_THUMB_NAV_MODE_ONE_COLUMN:
- gtk_icon_view_set_columns (GTK_ICON_VIEW (priv->thumbview), 1);
+ priv->thumbview->set_columns (1);
- gtk_widget_set_size_request (priv->thumbview, 113, -1);
- eog_thumb_view_set_item_height (EOG_THUMB_VIEW (priv->thumbview),
- -1);
+ priv->thumbview->set_size_request (-1, -1);
+ priv->thumbview->set_item_height (-1);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->sw),
GTK_POLICY_NEVER,
@@ -462,11 +460,10 @@ eog_thumb_nav_set_mode (EogThumbNav *nav, EogThumbNavMode mode)
break;
case EOG_THUMB_NAV_MODE_MULTIPLE_ROWS:
- gtk_icon_view_set_columns (GTK_ICON_VIEW (priv->thumbview), -1);
+ priv->thumbview->set_columns (-1);
- gtk_widget_set_size_request (priv->thumbview, -1, 220);
- eog_thumb_view_set_item_height (EOG_THUMB_VIEW (priv->thumbview),
- -1);
+ priv->thumbview->set_size_request (-1, -1);
+ priv->thumbview->set_item_height (-1);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->sw),
GTK_POLICY_NEVER,
@@ -478,11 +475,10 @@ eog_thumb_nav_set_mode (EogThumbNav *nav, EogThumbNavMode mode)
break;
case EOG_THUMB_NAV_MODE_MULTIPLE_COLUMNS:
- gtk_icon_view_set_columns (GTK_ICON_VIEW (priv->thumbview), -1);
+ priv->thumbview->set_columns (-1);
- gtk_widget_set_size_request (priv->thumbview, 230, -1);
- eog_thumb_view_set_item_height (EOG_THUMB_VIEW (priv->thumbview),
- -1);
+ priv->thumbview->set_size_request (-1, -1);
+ priv->thumbview->set_item_height (-1);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->sw),
GTK_POLICY_NEVER,
diff --git a/src/niepce/ui/thumb-view/eog-thumb-nav.hpp b/src/niepce/ui/thumb-view/eog-thumb-nav.hpp
index 3ee2184..8981d38 100644
--- a/src/niepce/ui/thumb-view/eog-thumb-nav.hpp
+++ b/src/niepce/ui/thumb-view/eog-thumb-nav.hpp
@@ -22,7 +22,7 @@
#ifndef __EOG_THUMB_NAV_H__
#define __EOG_THUMB_NAV_H__
-#include "eog-thumb-view.hpp"
+#include "thumbstripview.hpp"
#include <gtk/gtk.h>
#include <glib.h>
@@ -60,7 +60,7 @@ struct _EogThumbNavClass {
GType eog_thumb_nav_get_type (void) G_GNUC_CONST;
-GtkWidget *eog_thumb_nav_new (GtkWidget *thumbview,
+GtkWidget *eog_thumb_nav_new (Gtk::Widget *thumbview,
EogThumbNavMode mode,
gboolean show_buttons);
diff --git a/src/niepce/ui/thumbstripview.cpp b/src/niepce/ui/thumbstripview.cpp
new file mode 100644
index 0000000..ad0da72
--- /dev/null
+++ b/src/niepce/ui/thumbstripview.cpp
@@ -0,0 +1,277 @@
+/* Eye Of Gnome - Thumbnail View
+ *
+ * Copyright (C) 2006 The Free Software Foundation
+ * Copyright (C) 2007-2009 Hubert Figuiere
+ *
+ * C++-ization: Hubert Figuiere <hub figuiere net>
+ * Original Author: Claudio Saavedra <csaavedra alumnos utalca cl>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <string>
+
+#include <glibmm/i18n.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/scrolledwindow.h>
+
+#include "fwk/base/debug.hpp"
+#include "fwk/utils/boost.hpp"
+#include "engine/db/libfile.hpp"
+#include "thumbstripview.hpp"
+
+struct EogThumbView;
+
+namespace ui {
+
+#define THUMB_STRIP_VIEW_SPACING 0
+
+/* Drag 'n Drop */
+enum {
+ TARGET_PLAIN,
+ TARGET_PLAIN_UTF8,
+ TARGET_URILIST
+};
+
+#if 0
+static GtkTargetEntry target_table[] = {
+ { const_cast<gchar*>("text/uri-list"), 0, TARGET_URILIST },
+};
+#endif
+
+ThumbStripView::ThumbStripView(const Glib::RefPtr<ui::ImageListStore> & store)
+ : m_start_thumb(0)
+ , m_end_thumb(0)
+ , m_store(store)
+{
+ IconView::set_model(store);
+
+ m_renderer = new Gtk::CellRendererPixbuf();
+
+ GtkCellLayout *cl = GTK_CELL_LAYOUT(gobj());
+ DBG_ASSERT(cl, "No cell layout");
+ gtk_cell_layout_pack_start(cl, GTK_CELL_RENDERER(m_renderer->gobj()),
+ FALSE);
+ m_renderer->property_follow_state() = true;
+ m_renderer->property_height() = 100;
+ m_renderer->property_yalign() = 0.5;
+ m_renderer->property_xalign() = 0.5;
+
+ gtk_cell_layout_set_attributes (cl, GTK_CELL_RENDERER(m_renderer->gobj()),
+ "pixbuf",
+ ui::ImageListStore::Columns::STRIP_THUMB_INDEX,
+ NULL);
+ set_selection_mode(Gtk::SELECTION_MULTIPLE);
+ set_column_spacing(THUMB_STRIP_VIEW_SPACING);
+
+ set_row_spacing (THUMB_STRIP_VIEW_SPACING);
+
+ signal_parent_changed().connect(
+ sigc::mem_fun(*this, &ThumbStripView::on_parent_set));
+
+// enable_model_drag_source (target_table, Gdk::MODIFIER_MASK, Gdk::ACTION_COPY);
+
+// signal_drag_data_get().connect(
+// sigc::mem_fun(*this, &ThumbStripView::on_drag_data_get));
+}
+
+void ThumbStripView::set_model(const Glib::RefPtr<ui::ImageListStore> & store)
+{
+ m_store = store;
+ IconView::set_model(store);
+}
+
+const Glib::RefPtr<ui::ImageListStore> & ThumbStripView::get_model() const
+{
+ return m_store;
+}
+
+void
+ThumbStripView::clear_range (int start_thumb, int end_thumb)
+{
+// Gtk::TreeIter iter;
+// int thumb = start_thumb;
+
+ g_assert (start_thumb <= end_thumb);
+
+// for (iter = m_store->children().begin() + start_thumb;
+// iter && thumb <= end_thumb;
+// ++iter, thumb++) {
+// eog_list_store_thumbnail_unset (get_pointer(store), &iter);
+// }
+}
+
+void
+ThumbStripView::add_range (int start_thumb, int end_thumb)
+{
+// Gtk::TreeIter iter;
+// gint thumb = start_thumb;
+
+ g_assert (start_thumb <= end_thumb);
+
+// for (iter = m_store->children().begin() + start_thumb;
+// iter && thumb <= end_thumb;
+// ++iter, thumb++) {
+// eog_list_store_thumbnail_set (get_pointer(store), &iter);
+// }
+}
+
+void
+ThumbStripView::update_visible_range (int start_thumb, int end_thumb)
+{
+ int old_start_thumb, old_end_thumb;
+
+ old_start_thumb = m_start_thumb;
+ old_end_thumb = m_end_thumb;
+
+ if (start_thumb == old_start_thumb &&
+ end_thumb == old_end_thumb) {
+ return;
+ }
+
+ if (old_start_thumb < start_thumb)
+ clear_range (old_start_thumb, MIN (start_thumb - 1, old_end_thumb));
+
+ if (old_end_thumb > end_thumb)
+ clear_range (MAX (end_thumb + 1, old_start_thumb), old_end_thumb);
+
+ add_range (start_thumb, end_thumb);
+
+ m_start_thumb = start_thumb;
+ m_end_thumb = end_thumb;
+}
+
+void
+ThumbStripView::on_visible_range_changed()
+{
+ Gtk::TreePath path1, path2;
+
+ if (!get_visible_range (path1, path2)) {
+ return;
+ }
+
+ update_visible_range (path1[0], path2[0]);
+}
+
+void
+ThumbStripView::on_adjustment_changed ()
+{
+ Gtk::TreePath path1, path2;
+ int start_thumb, end_thumb;
+
+ if (!get_visible_range (path1, path2)) {
+ return;
+ }
+
+ start_thumb = path1 [0];
+ end_thumb = path2 [0];
+
+ add_range (start_thumb, end_thumb);
+
+ /* case we added an image, we need to make sure that the shifted thumbnail is cleared */
+ clear_range (end_thumb + 1, end_thumb + 1);
+
+ m_start_thumb = start_thumb;
+ m_end_thumb = end_thumb;
+}
+
+void
+ThumbStripView::on_parent_set (Gtk::Widget */*old_parent*/)
+{
+ Gtk::ScrolledWindow *sw;
+ Gtk::Adjustment *hadjustment;
+ Gtk::Adjustment *vadjustment;
+
+ Gtk::Widget *parent = get_parent ();
+ sw = dynamic_cast<Gtk::ScrolledWindow*>(parent);
+ if (!sw) {
+ return;
+ }
+
+ /* if we have been set to a ScrolledWindow, we connect to the callback
+ to set and unset thumbnails. */
+ hadjustment = sw->get_hadjustment ();
+ vadjustment = sw->get_vadjustment ();
+
+ /* when scrolling */
+ hadjustment->signal_value_changed().connect(
+ sigc::mem_fun(*this, &ThumbStripView::on_visible_range_changed));
+ vadjustment->signal_value_changed().connect(
+ sigc::mem_fun(*this, &ThumbStripView::on_visible_range_changed));
+
+ /* when the adjustment is changed, ie. probably we have new images added. */
+ hadjustment->signal_changed().connect(
+ sigc::mem_fun(*this, &ThumbStripView::on_adjustment_changed));
+ vadjustment->signal_changed().connect(
+ sigc::mem_fun(*this, &ThumbStripView::on_adjustment_changed));
+
+ /* when resizing the scrolled window */
+ sw->signal_size_allocate().connect(
+ sigc::hide<0>(sigc::mem_fun(*this,
+ &ThumbStripView::on_visible_range_changed)));
+}
+
+
+void ThumbStripView::on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
+ Gtk::SelectionData& /*data*/,guint,guint)
+{
+#if 0
+ GList *list;
+ GList *node;
+ eng::LibFile *image;
+ const char *str;
+ gchar *uris = NULL;
+ gchar *tmp_str;
+
+ list = eog_thumb_view_get_selected_images (EOG_THUMB_VIEW (widget));
+
+ for (node = list; node != NULL; node = node->next) {
+ image = static_cast<eng::LibFile*>(node->data);
+ str = image->uri().c_str();
+
+ /* build the "text/uri-list" string */
+ if (uris) {
+ tmp_str = g_strconcat (uris, str, "\r\n", NULL);
+ g_free (uris);
+ } else {
+ tmp_str = g_strconcat (str, "\r\n", NULL);
+ }
+ uris = tmp_str;
+ }
+ gtk_selection_data_set (data, data->target, 8,
+ (guchar*) uris, strlen (uris));
+ g_free (uris);
+ g_list_free (list);
+#endif
+}
+
+
+void
+ThumbStripView::set_item_height (int height)
+{
+ m_renderer->property_height() = height;
+}
+
+
+}
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
diff --git a/src/niepce/ui/thumbstripview.hpp b/src/niepce/ui/thumbstripview.hpp
new file mode 100644
index 0000000..e6ae618
--- /dev/null
+++ b/src/niepce/ui/thumbstripview.hpp
@@ -0,0 +1,68 @@
+/*
+ * niepce - niepce/ui/thumbstripview.hpp
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _THUMB_STRIP_VIEW_HPP_
+#define _THUMB_STRIP_VIEW_HPP_
+
+#include <gtkmm/iconview.h>
+#include <gtkmm/cellrendererpixbuf.h>
+
+#include "niepce/ui/imageliststore.hpp"
+
+namespace ui {
+
+class ThumbStripView
+ : public Gtk::IconView
+{
+public:
+ ThumbStripView(const Glib::RefPtr<ui::ImageListStore> & store);
+
+ void set_model(const Glib::RefPtr<ui::ImageListStore> & store);
+ const Glib::RefPtr<ui::ImageListStore> & get_model() const;
+ void set_item_height(int height);
+
+private:
+ void on_parent_set(Gtk::Widget* previous_parent);
+ void on_visible_range_changed();
+ void on_adjustment_changed();
+ void on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
+ Gtk::SelectionData&,guint,guint);
+ void update_visible_range(int, int);
+ void add_range(int, int);
+ void clear_range (int start_thumb, int end_thumb);
+
+ gint m_start_thumb; /* the first visible thumbnail */
+ gint m_end_thumb; /* the last visible thumbnail */
+ Glib::RefPtr<ui::ImageListStore> m_store;
+ Gtk::CellRendererPixbuf *m_renderer;
+};
+
+
+}
+
+#endif
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]