paperbox r113 - in trunk: . src



Author: markoa
Date: Wed Mar 12 19:49:00 2008
New Revision: 113
URL: http://svn.gnome.org/viewvc/paperbox?rev=113&view=rev

Log:
Insert selected tag in category buffer, property for tag marking in the cloud.

Modified:
   trunk/ChangeLog
   trunk/src/category-editor.cc
   trunk/src/category-editor.hh
   trunk/src/tag-cloud.cc
   trunk/src/tag-cloud.hh

Modified: trunk/src/category-editor.cc
==============================================================================
--- trunk/src/category-editor.cc	(original)
+++ trunk/src/category-editor.cc	Wed Mar 12 19:49:00 2008
@@ -113,6 +113,7 @@
             new DocumentTagCloudModel(TAG_FONT_SIZE, TAG_FONT_SIZE));
         tag_cloud_.set_model(tag_cloud_model_);
         tag_box_.pack_start(tag_cloud_, true, true);
+        tag_cloud_.set_mark_selected_tags(false);
 
         set_default_size(DEFAULT_WIDTH, DEFAULT_HEIGHT);
 
@@ -143,6 +144,9 @@
         // TODO: what about signals for tags added/removed?
         Browser::instance()->signal_new_document().connect(
             sigc::mem_fun(*this, &CategoryEditor::on_new_document));
+
+        tag_cloud_.signal_tag_clicked().connect(
+            sigc::mem_fun(*this, &CategoryEditor::on_tag_clicked));
     }
 
     int
@@ -322,4 +326,19 @@
         return false;
     }
 
+    void
+    CategoryEditor::on_tag_clicked(const Glib::ustring& tag)
+    {
+        using Glib::ustring;
+
+        Glib::RefPtr<Gtk::TextBuffer> buf = text_view_.get_buffer();
+        ustring::size_type pos = buf->get_text().find(tag);
+
+        if (pos == ustring::size_type(-1)) {
+            ustring text = buf->get_text();
+            text.insert(text.size(), " " + tag);
+            buf->set_text(text);
+        }
+    }
+
 } // namespace paperbox

Modified: trunk/src/category-editor.hh
==============================================================================
--- trunk/src/category-editor.hh	(original)
+++ trunk/src/category-editor.hh	Wed Mar 12 19:49:00 2008
@@ -68,6 +68,7 @@
                                   bool path_selected);
         bool on_key_release_event(GdkEventKey* key);
         void on_new_document(const boost::shared_ptr<Document>& doc);
+        void on_tag_clicked(const Glib::ustring& tag);
 
         virtual bool on_expose_event(GdkEventExpose* event);
 

Modified: trunk/src/tag-cloud.cc
==============================================================================
--- trunk/src/tag-cloud.cc	(original)
+++ trunk/src/tag-cloud.cc	Wed Mar 12 19:49:00 2008
@@ -84,6 +84,7 @@
     randomize_borders_(true),
     underline_tags_(false),
     lighten_rare_tags_(true),
+    mark_selected_(true),
     alloc_width_(0),
     alloc_height_(0)
 {
@@ -312,11 +313,11 @@
 void
 TagCloud::update_marker(TagItem* new_selection)
 {
-    if (selection_) {
-        selection_->marker_off();
+    if (mark_selected_) {
+        if (selection_) selection_->marker_off();
+        new_selection->marker_on();
     }
 
-    new_selection->marker_on();
     selection_ = new_selection;
 }
 

Modified: trunk/src/tag-cloud.hh
==============================================================================
--- trunk/src/tag-cloud.hh	(original)
+++ trunk/src/tag-cloud.hh	Wed Mar 12 19:49:00 2008
@@ -58,6 +58,10 @@
         { lighten_rare_tags_ = lighten; }
     bool get_lighten_rare_tags() const { return lighten_rare_tags_; }
 
+    void set_mark_selected_tags(bool mark = true)
+        { mark_selected_ = mark; }
+    bool get_mark_selected_tags() const { return mark_selected_; }
+
     SignalTagClicked& signal_tag_clicked() { return signal_tag_clicked_; }
 
     void update_marker(TagItem* new_selection);
@@ -87,6 +91,7 @@
 
     bool   underline_tags_;
     bool   lighten_rare_tags_;
+    bool   mark_selected_;
 
     int alloc_width_;
     int alloc_height_;



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