paperbox r105 - in trunk: . src
- From: markoa svn gnome org
- To: svn-commits-list gnome org
- Subject: paperbox r105 - in trunk: . src
- Date: Mon, 25 Feb 2008 23:24:42 +0000 (GMT)
Author: markoa
Date: Mon Feb 25 23:24:42 2008
New Revision: 105
URL: http://svn.gnome.org/viewvc/paperbox?rev=105&view=rev
Log:
Implemented category deletion
Modified:
trunk/ChangeLog
trunk/src/category-editor-model.cc
trunk/src/category-editor.cc
Modified: trunk/src/category-editor-model.cc
==============================================================================
--- trunk/src/category-editor-model.cc (original)
+++ trunk/src/category-editor-model.cc Mon Feb 25 23:24:42 2008
@@ -21,6 +21,7 @@
*/
#include <vector>
+#include <glibmm-utils/log-stream-utils.h>
#include <glibmm-utils/ustring.h>
#include "category-editor-model.hh"
@@ -128,6 +129,12 @@
void
CategoryEditorModel::delete_category(const Glib::ustring& name)
{
+ try {
+ CategoryFactory::delete_category(name);
+ model_data_.erase(name);
+ } catch (const CategoryNotFound& ex) {
+ LOG_EXCEPTION(ex.what());
+ }
}
} // namespace paperbox
Modified: trunk/src/category-editor.cc
==============================================================================
--- trunk/src/category-editor.cc (original)
+++ trunk/src/category-editor.cc Mon Feb 25 23:24:42 2008
@@ -172,7 +172,13 @@
shared_ptr<CategoryEditorData> data = model_->new_category(name);
add_new_row(data);
-
+
+ if (category_view_->treemodel->children().size() == 1) {
+ // first category created,
+ // so previously we had some widgets disabled
+ text_view_.set_sensitive();
+ button_save_.set_sensitive();
+ }
} catch (const CategoryExists& ex) {
Gtk::Util::display_dialog_error(ex.what());
}
@@ -181,6 +187,28 @@
void
CategoryEditor::on_button_delete_clicked()
{
+ Gtk::TreeModel::iterator row =
+ category_view_->selection->get_selected();
+
+ if (! row) return;
+
+ // delete from both...
+ category_view_->treemodel->erase(row);
+ model_->delete_category(selected_name_);
+
+ if (category_view_->treemodel->children().begin() !=
+ category_view_->treemodel->children().end()) {
+ // select the first row
+ category_view_->selection->select(
+ category_view_->treemodel->children().begin());
+ } else {
+ // last row deleted, assign a dummy buffer to the textview
+ text_view_.set_buffer(Gtk::TextBuffer::create());
+
+ // disable related widgets
+ text_view_.set_sensitive(false);
+ button_save_.set_sensitive(false);
+ }
}
bool
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]