paperbox r204 - in trunk: . src



Author: markoa
Date: Tue Oct 14 16:10:57 2008
New Revision: 204
URL: http://svn.gnome.org/viewvc/paperbox?rev=204&view=rev

Log:
Ellipisize or break long titles

Modified:
   trunk/ChangeLog
   trunk/README
   trunk/src/document-tile.cc
   trunk/src/document-tile.hh

Modified: trunk/README
==============================================================================
--- trunk/README	(original)
+++ trunk/README	Tue Oct 14 16:10:57 2008
@@ -15,7 +15,7 @@
 * boost C++ library
 * libtracker 0.6
 * dbus-glib
-* giomm, part of glibmm 2.16
-* libgthread, gtkmm, libglademm, libgnomeui
-* gtkmm-utils 0.3.1, available at http://download.savannah.nongnu.org/releases/gtkmm-utils/
+* libgthread, glibmm, gtkmm, libglademm, libgnomeui
+* gtkmm-utils 0.3.3, ( not released atm, you have to 'git clone git://git.savannah.nongnu.org/gtkmm-utils.git',
+    the release will be available at http://download.savannah.nongnu.org/releases/gtkmm-utils/ )
 * goocanvas 0.9

Modified: trunk/src/document-tile.cc
==============================================================================
--- trunk/src/document-tile.cc	(original)
+++ trunk/src/document-tile.cc	Tue Oct 14 16:10:57 2008
@@ -36,11 +36,14 @@
     using boost::shared_ptr;
     using Glib::ustring;
 
+    const unsigned int TITLE_BREAK = 50;
+
     DocumentTile::DocumentTile(Thumbnailer& thumbnailer,
                                const shared_ptr<Document>& doc)
         :
         Gtk::Util::Tile(doc->get_subject(), doc->get_author(), false),
         uri_(doc->get_uri()),
+        doc_(doc),
         tag_hbox_(false, 4),
         tag_labels_hbox_(false, 4),
         tag_links_hbox_(false, 4),
@@ -49,8 +52,7 @@
         image_add_(Gtk::Stock::ADD, Gtk::ICON_SIZE_MENU),
         first_boot_(true)
     {
-        get_title_label().set_ellipsize(Pango::ELLIPSIZE_END);
-        get_title_label().set_max_width_chars(50);
+        break_title();
 
         connect_thumbnailer_signals(thumbnailer);
 
@@ -323,6 +325,7 @@
         tag_labels_hbox_.hide();
 
         get_image().set(thumbnail_large_);
+        restore_title();
     }
 
     void
@@ -336,6 +339,7 @@
         tag_links_hbox_.hide();
 
         get_image().set(thumbnail_small_);
+        break_title();
     }
 
     void
@@ -408,4 +412,26 @@
         on_unselected();
     }
 
+    void
+    DocumentTile::break_title()
+    {
+        Gtk::Label& title_label = get_title_label();
+        title_label.set_ellipsize(Pango::ELLIPSIZE_END);
+        title_label.set_max_width_chars(TITLE_BREAK);
+        set_title(doc_->get_subject());
+    }
+
+    void
+    DocumentTile::restore_title()
+    {
+        Gtk::Label& title_label = get_title_label();
+        ustring title = get_title();
+
+        title_label.set_max_width_chars(80); // something large enough
+        if (title.size() > TITLE_BREAK) {
+            title.insert(TITLE_BREAK, "\n");
+            set_title(title);
+        }
+    }
+
 } // namespace paperbox

Modified: trunk/src/document-tile.hh
==============================================================================
--- trunk/src/document-tile.hh	(original)
+++ trunk/src/document-tile.hh	Tue Oct 14 16:10:57 2008
@@ -109,7 +109,11 @@
 
         virtual void on_tag_link_tag_remove_request(const Glib::ustring& tag);
 
+        virtual void break_title();
+        virtual void restore_title();
+
         Glib::ustring uri_;
+        boost::shared_ptr<Document> doc_;
 
         SignalTagClicked signal_tag_clicked_;
 



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