paperbox r95 - in trunk: . src ui
- From: markoa svn gnome org
- To: svn-commits-list gnome org
- Subject: paperbox r95 - in trunk: . src ui
- Date: Wed, 6 Feb 2008 21:32:07 +0000 (GMT)
Author: markoa
Date: Wed Feb 6 21:32:06 2008
New Revision: 95
URL: http://svn.gnome.org/viewvc/paperbox?rev=95&view=rev
Log:
Put common category treeview code into separate class
Added:
trunk/src/category-view.cc
trunk/src/category-view.hh
Modified:
trunk/ChangeLog
trunk/src/Makefile.am
trunk/src/main-window.cc
trunk/src/main-window.hh
trunk/ui/Makefile.am
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Wed Feb 6 21:32:06 2008
@@ -13,6 +13,8 @@
category.hh \
category-factory.cc \
category-factory.hh \
+ category-view.cc \
+ category-view.hh \
dialog-categories.cc \
dialog-categories.hh \
dialog-tag-entry.cc \
Added: trunk/src/category-view.cc
==============================================================================
--- (empty file)
+++ trunk/src/category-view.cc Wed Feb 6 21:32:06 2008
@@ -0,0 +1,50 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+
+/*
+ * PaperBox - category-view.cc
+ *
+ * Copyright (C) 2008 Marko Anastasov
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <glib/gi18n.h>
+#include "category-view.hh"
+
+namespace paperbox {
+
+ CategoryView::CategoryView(Gtk::Box* _parent)
+ :
+ parent(_parent)
+ {
+ // pack the widgets
+ label_title.set_markup(_("<b>Categories</b>"));
+
+ parent->pack_start(label_title, false, false);
+ parent->pack_start(treeview, true, true);
+
+ // create the tree model
+ treemodel = Gtk::ListStore::create(columns);
+ treeview.set_model(treemodel);
+
+ // set up the treeview selection object
+ selection = treeview.get_selection();
+ selection->set_mode(Gtk::SELECTION_SINGLE);
+
+ // add a category column
+ treeview.append_column(_("Name"), columns.col_name);
+ }
+
+} // namespace paperbox
Added: trunk/src/category-view.hh
==============================================================================
--- (empty file)
+++ trunk/src/category-view.hh Wed Feb 6 21:32:06 2008
@@ -0,0 +1,61 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+
+/*
+ * PaperBox - category-view.hh
+ *
+ * Copyright (C) 2008 Marko Anastasov
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __PAPER_BOX_CATEGORY_VIEW__
+#define __PAPER_BOX_CATEGORY_VIEW__
+
+#include <boost/noncopyable.hpp>
+#include <gtkmm/box.h>
+#include <gtkmm/label.h>
+#include <gtkmm/liststore.h>
+#include <gtkmm/treeview.h>
+
+namespace paperbox {
+
+ // treemodel
+ class CategoryModelColumns : public Gtk::TreeModel::ColumnRecord
+ {
+ public:
+ CategoryModelColumns() { add(col_id); add(col_name); }
+
+ Gtk::TreeModelColumn<int> col_id; // not displayed
+ Gtk::TreeModelColumn<Glib::ustring> col_name;
+ };
+
+ /// common treeview setup for categories
+ class CategoryView : private boost::noncopyable
+ {
+ public:
+ explicit CategoryView(Gtk::Box* parent);
+ virtual ~CategoryView() {}
+
+ Gtk::Box* parent;
+ Gtk::Label label_title;
+ Gtk::TreeView treeview;
+ CategoryModelColumns columns;
+ Glib::RefPtr<Gtk::ListStore> treemodel;
+ Glib::RefPtr<Gtk::TreeSelection> selection;
+ };
+
+} // namespace paperbox
+
+#endif // __PAPER_BOX_CATEGORY_VIEW__
Modified: trunk/src/main-window.cc
==============================================================================
--- trunk/src/main-window.cc (original)
+++ trunk/src/main-window.cc Wed Feb 6 21:32:06 2008
@@ -150,27 +150,12 @@
void
MainWindow::setup_categories()
{
- // pack the widgets
- label_categories_.set_markup(_("<b>Categories</b>"));
-
- category_vbox_->pack_start(label_categories_, false, false);
- category_vbox_->pack_start(category_view_, true, true);
+ category_view_.reset(new CategoryView(category_vbox_));
category_vbox_->pack_start(button_edit_category_, false, false);
- // create the tree model
- category_treemodel_ = Gtk::ListStore::create(category_columns_);
- category_view_.set_model(category_treemodel_);
-
- // set up the treeview selection object
- category_selection_ = category_view_.get_selection();
- category_selection_->set_mode(Gtk::SELECTION_SINGLE);
-
- // add a category column
- category_view_.append_column(_("Name"), category_columns_.col_name);
-
add_default_category();
- category_selection_->set_select_function(
+ category_view_->selection->set_select_function(
sigc::mem_fun(*this, &MainWindow::on_category_selected));
}
@@ -180,18 +165,17 @@
bool /*path_currently_selected*/)
{
//TODO
- g_debug ("cat sel");
return true;
}
void
MainWindow::add_default_category()
{
- Gtk::TreeModel::Row row = *(category_treemodel_->append());
+ Gtk::TreeModel::Row row = *(category_view_->treemodel->append());
- row[category_columns_.col_id] = 1;
+ row[category_view_->columns.col_id] = 1;
//TRANSLATORS: 'all' means 'all categories'
- row[category_columns_.col_name] = _("All");
+ row[category_view_->columns.col_name] = _("All");
}
void
Modified: trunk/src/main-window.hh
==============================================================================
--- trunk/src/main-window.hh (original)
+++ trunk/src/main-window.hh Wed Feb 6 21:32:06 2008
@@ -30,6 +30,7 @@
#include <gtk/gtkwindow.h>
#include <libglademm.h>
#include <gtkmm-utils/tile.h>
+#include "category-view.hh"
#include "document-tile-view.hh"
#include "tag-cloud-model.hh"
#include "tag-cloud.hh"
@@ -98,29 +99,15 @@
// categories
- // treemodel
- class CategoryModelColumns : public Gtk::TreeModel::ColumnRecord
- {
- public:
- CategoryModelColumns() { add(col_id); add(col_name); }
-
- Gtk::TreeModelColumn<int> col_id; // not displayed
- Gtk::TreeModelColumn<Glib::ustring> col_name;
- };
-
- Gtk::VBox* category_vbox_;
- Gtk::Label label_categories_;
- Gtk::TreeView category_view_;
- CategoryModelColumns category_columns_;
- Glib::RefPtr<Gtk::ListStore> category_treemodel_;
- Glib::RefPtr<Gtk::TreeSelection> category_selection_;
+ Gtk::VBox* category_vbox_;
+ boost::shared_ptr<CategoryView> category_view_;
Gtk::HBox* category_buttons_hbox_;
Gtk::Button button_edit_category_;
// tag cloud
- Gtk::VBox* tag_cloud_vbox_;
- Gtk::Label label_tags_;
+ Gtk::VBox* tag_cloud_vbox_;
+ Gtk::Label label_tags_;
boost::shared_ptr<TagCloudModel> model_;
TagCloud tag_cloud_;
Modified: trunk/ui/Makefile.am
==============================================================================
--- trunk/ui/Makefile.am (original)
+++ trunk/ui/Makefile.am Wed Feb 6 21:32:06 2008
@@ -4,7 +4,7 @@
#menusfiles = actions.xml
-gladefiles = dialog-tag-entry.glade window-main.glade
+gladefiles = dialog-categories.glade dialog-tag-entry.glade window-main.glade
ui_DATA = $(gladefiles)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]