solang-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Solang-devel] [PATCH] Search Basket


From: Debarshi Ray
Subject: [Solang-devel] [PATCH] Search Basket
Date: Thu, 21 May 2009 21:20:35 +0530

http://rishi.fedorapeople.org/0001-Basic-search-basket.patch

>From 958ab816c289cdc576d53b8ab246f523d2b1eb36 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <address@hidden>
Date: Thu, 21 May 2009 21:17:07 +0530
Subject: [PATCH] Basic search basket.

---
 src/application/application.cpp               |    4 +
 src/attribute/Makefile.am                     |    4 +
 src/attribute/search-basket-column-record.cpp |   72 +++++++++++++++
 src/attribute/search-basket-column-record.h   |   62 +++++++++++++
 src/attribute/search-basket.cpp               |  119 +++++++++++++++++++++++++
 src/attribute/search-basket.h                 |   79 ++++++++++++++++
 6 files changed, 340 insertions(+), 0 deletions(-)
 create mode 100644 src/attribute/search-basket-column-record.cpp
 create mode 100644 src/attribute/search-basket-column-record.h
 create mode 100644 src/attribute/search-basket.cpp
 create mode 100644 src/attribute/search-basket.h

diff --git a/src/application/application.cpp b/src/application/application.cpp
index d6f0d41..32939a2 100644
--- a/src/application/application.cpp
+++ b/src/application/application.cpp
@@ -40,6 +40,7 @@
 #include "photo.h"
 #include "progress-observer.h"
 #include "property-manager.h"
+#include "search-basket.h"
 #include "tag-manager.h"
 #include "thumbnail.h"
 #include "thumbnail-store.h"
@@ -211,6 +212,9 @@ Application::init() throw()
     plugins_.insert(std::make_pair("property-manager",
                                    property_manager));

+    IPluginPtr search_basket(new SearchBasket());
+    plugins_.insert(std::make_pair("search-basket", search_basket));
+
     IPluginPtr tag_manager(new TagManager( ));
     plugins_.insert(std::make_pair("tag-manager", tag_manager));

diff --git a/src/attribute/Makefile.am b/src/attribute/Makefile.am
index 3d4fc98..32f2640 100644
--- a/src/attribute/Makefile.am
+++ b/src/attribute/Makefile.am
@@ -15,6 +15,10 @@ libattribute_la_SOURCES = \
        photo-tag.h \
        property-manager.cpp \
        property-manager.h \
+       search-basket.cpp \
+       search-basket.h \
+       search-basket-column-record.cpp \
+       search-basket-column-record.h \
        search-criterion-repo.cpp \
        search-criterion-repo.h \
        search-criterion-source.cpp \
diff --git a/src/attribute/search-basket-column-record.cpp
b/src/attribute/search-basket-column-record.cpp
new file mode 100644
index 0000000..6e7adf9
--- /dev/null
+++ b/src/attribute/search-basket-column-record.cpp
@@ -0,0 +1,72 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * Copyright (C) Debarshi Ray 2009 <address@hidden>
+ *
+ * Solang 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.
+ *
+ * Solang 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif // HAVE_CONFIG_H
+
+#include "search-basket-column-record.h"
+
+namespace Solang
+{
+
+enum
+{
+    COLUMN_PIXBUF = 0,
+    COLUMN_DESCRIPTION,
+    COLUMN_COUNT
+};
+
+SearchBasketColumnRecord::SearchBasketColumnRecord() throw() :
+    Gtk::TreeModelColumnRecord(),
+    columnPixbuf_(),
+    columnDescription_()
+{
+    add(columnPixbuf_);
+    add(columnDescription_);
+}
+
+SearchBasketColumnRecord::~SearchBasketColumnRecord() throw()
+{
+}
+
+const Gtk::TreeModelColumn<PixbufPtr> &
+SearchBasketColumnRecord::get_column_pixbuf() const throw()
+{
+    return columnPixbuf_;
+}
+
+gint
+SearchBasketColumnRecord::get_column_pixbuf_num() const throw()
+{
+    return COLUMN_PIXBUF;
+}
+
+const Gtk::TreeModelColumn<Glib::ustring> &
+SearchBasketColumnRecord::get_column_description() const throw()
+{
+    return columnDescription_;
+}
+
+gint
+SearchBasketColumnRecord::get_column_description_num() const throw()
+{
+    return COLUMN_DESCRIPTION;
+}
+
+} // namespace Solang
diff --git a/src/attribute/search-basket-column-record.h
b/src/attribute/search-basket-column-record.h
new file mode 100644
index 0000000..4315aff
--- /dev/null
+++ b/src/attribute/search-basket-column-record.h
@@ -0,0 +1,62 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * Copyright (C) Debarshi Ray 2009 <address@hidden>
+ *
+ * Solang 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.
+ *
+ * Solang 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 SOLANG_SEARCH_BASKET_COLUMN_RECORD_H
+#define SOLANG_SEARCH_BASKET_COLUMN_RECORD_H
+
+#include <gdkmm.h>
+#include <glibmm.h>
+#include <gtkmm.h>
+
+#include "types.h"
+
+namespace Solang
+{
+
+class SearchBasketColumnRecord :
+    public Gtk::TreeModelColumnRecord
+{
+    public:
+        SearchBasketColumnRecord() throw();
+
+        virtual
+        ~SearchBasketColumnRecord() throw();
+
+        const Gtk::TreeModelColumn<PixbufPtr> &
+        get_column_pixbuf() const throw();
+
+        gint
+        get_column_pixbuf_num() const throw();
+
+        const Gtk::TreeModelColumn<Glib::ustring> &
+        get_column_description() const throw();
+
+        gint
+        get_column_description_num() const throw();
+
+    protected:
+        Gtk::TreeModelColumn<PixbufPtr> columnPixbuf_;
+
+        Gtk::TreeModelColumn<Glib::ustring> columnDescription_;
+
+    private:
+};
+
+} // namespace Solang
+
+#endif // SOLANG_SEARCH_BASKET_COLUMN_RECORD_H
diff --git a/src/attribute/search-basket.cpp b/src/attribute/search-basket.cpp
new file mode 100644
index 0000000..ec96cf5
--- /dev/null
+++ b/src/attribute/search-basket.cpp
@@ -0,0 +1,119 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * Copyright (C) 2009 Debarshi Ray <address@hidden>
+ *
+ * Solang 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.
+ *
+ * Solang 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif // HAVE_CONFIG_H
+
+#include <list>
+
+#include <glibmm/i18n.h>
+
+#include "application.h"
+#include "main-window.h"
+#include "search-basket.h"
+#include "search-basket-column-record.h"
+
+namespace Solang
+{
+
+SearchBasket::SearchBasket() throw() :
+    Plugin(),
+    sigc::trackable(),
+    dockItemName_("search-basket-dock-item"),
+    dockItemTitle_("Search"),
+    dockItemBehaviour_(GDL_DOCK_ITEM_BEH_NORMAL),
+    dockItem_(NULL),
+    scrolledWindow_(),
+    listStore_(Gtk::ListStore::create(SearchBasketColumnRecord())),
+    treeView_(listStore_)
+{
+    scrolledWindow_.set_policy(Gtk::POLICY_AUTOMATIC,
+                               Gtk::POLICY_AUTOMATIC);
+
+    SearchBasketColumnRecord model_column_record;
+    treeView_.append_column("",
+        model_column_record.get_column_pixbuf());
+    treeView_.append_column("",
+        model_column_record.get_column_description());
+
+    treeView_.set_enable_search(true);
+    treeView_.set_grid_lines(Gtk::TREE_VIEW_GRID_LINES_NONE);
+    treeView_.set_headers_clickable(false);
+    treeView_.set_headers_visible(false);
+
+    scrolledWindow_.add(treeView_);
+
+    dockItem_ = gdl_dock_item_new_with_stock(dockItemName_.c_str(),
+                                             dockItemTitle_.c_str(),
+                                             GTK_STOCK_FIND,
+                                             dockItemBehaviour_);
+    gtk_container_add(GTK_CONTAINER(dockItem_),
+                      GTK_WIDGET(scrolledWindow_.gobj()));
+
+    std::list<Gtk::TargetEntry> targets;
+    targets.push_back(Gtk::TargetEntry("STRING",
+                                       Gtk::TARGET_SAME_APP, 0));
+    targets.push_back(Gtk::TargetEntry("UTF8_STRING",
+                                       Gtk::TARGET_SAME_APP, 0));
+    treeView_.enable_model_drag_dest(targets, Gdk::ACTION_COPY);
+
+    treeView_.signal_drag_data_received().connect(sigc::mem_fun(
+        *this, &SearchBasket::on_drag_data_received));
+}
+
+SearchBasket::~SearchBasket() throw()
+{
+    treeView_.unset_model();
+    //g_object_unref(dockItem_);
+}
+
+void
+SearchBasket::init(Application & application) throw()
+{
+    MainWindow & main_window = application.get_main_window();
+    main_window.add_dock_object_left(GDL_DOCK_OBJECT(dockItem_));
+
+    initialized_.emit(*this);
+}
+
+void
+SearchBasket::final(Application & application) throw()
+{
+    finalized_.emit(*this);
+}
+
+void
+SearchBasket::on_drag_data_received(
+                  const DragContextPtr & drag_context,
+                  gint x, gint y,
+                  const Gtk::SelectionData & data,
+                  guint info, guint time) throw()
+{
+    Gtk::TreeModel::iterator model_iter = listStore_->append();
+    Gtk::TreeModel::Row row = *model_iter;
+
+    SearchBasketColumnRecord model_column_record;
+    // row[model_column_record.get_column_pixbuf()] = ;
+    row[model_column_record.get_column_description()]
+        = data.get_text();
+
+    drag_context->drop_finish(true, 0);
+}
+
+} // namespace Solang
diff --git a/src/attribute/search-basket.h b/src/attribute/search-basket.h
new file mode 100644
index 0000000..60d00ce
--- /dev/null
+++ b/src/attribute/search-basket.h
@@ -0,0 +1,79 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * Copyright (C) 2009 Debarshi Ray <address@hidden>
+ *
+ * Solang 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.
+ *
+ * Solang 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 SOLANG_SEARCH_BASKET_H
+#define SOLANG_SEARCH_BASKET_H
+
+#include <string>
+
+#include <gdkmm.h>
+#include <gdl/gdl.h>
+#include <glibmm.h>
+#include <gtkmm.h>
+#include <sigc++/sigc++.h>
+
+#include "plugin.h"
+
+namespace Solang
+{
+
+class Application;
+
+class SearchBasket :
+    public Plugin,
+    public sigc::trackable
+{
+    public:
+        SearchBasket() throw();
+
+        virtual
+        ~SearchBasket() throw();
+
+        virtual void
+        init(Application & application) throw();
+
+        virtual void
+        final(Application & application) throw();
+
+    protected:
+        void
+        on_drag_data_received(const DragContextPtr & drag_context,
+                              gint x, gint y,
+                              const Gtk::SelectionData & data,
+                              guint info, guint time) throw();
+
+        const std::string dockItemName_;
+
+        const Glib::ustring dockItemTitle_;
+
+        GdlDockItemBehavior dockItemBehaviour_;
+
+        GtkWidget * dockItem_;
+
+        Gtk::ScrolledWindow scrolledWindow_;
+
+        ListStorePtr listStore_;
+
+        Gtk::TreeView treeView_;
+
+    private:
+};
+
+} // namespace Solang
+
+#endif // SOLANG_SEARCH_BASKET_H
-- 
1.6.0.6

-- 
One reason that life is complex is that it has a real part and an
imaginary part.
    -- Andrew Koenig




reply via email to

[Prev in Thread] Current Thread [Next in Thread]