diff options
| author | John Smith <john.smith7545@yahoo.com> | 2012-05-20 04:23:31 +0000 |
|---|---|---|
| committer | John Smith <removethis.john.q.public@bigmail.com> | 2012-05-20 04:23:31 +0000 |
| commit | 3f67967cd8a4852de65eefb4d1d142f807642be2 (patch) | |
| tree | 9cdca878b43ef19ec052b33a273f2215ae33caf0 /src/widgets | |
| parent | C++ification of SPWidget. (diff) | |
| download | inkscape-3f67967cd8a4852de65eefb4d1d142f807642be2.tar.gz inkscape-3f67967cd8a4852de65eefb4d1d142f807642be2.zip | |
Fix for 973195 : Limit width of color profile labels
(bzr r11388)
Diffstat (limited to 'src/widgets')
| -rw-r--r-- | src/widgets/gradient-vector.cpp | 8 | ||||
| -rw-r--r-- | src/widgets/sp-color-icc-selector.cpp | 71 |
2 files changed, 40 insertions, 39 deletions
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 64b2d3a5e..e396c9768 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -270,15 +270,15 @@ Glib::ustring gr_prepare_label (SPObject *obj) } /* - * Ellipse text if longer than maxlen, "30% start text + ... + ~70% end text" + * Ellipse text if longer than maxlen, "50% start text + ... + ~50% end text" * Text should be > length 8 or just return the original text */ Glib::ustring gr_ellipsize_text(Glib::ustring const &src, size_t maxlen) { if (src.length() > maxlen && maxlen > 8) { - size_t p1 = (size_t) maxlen / 3; - size_t p2 = (size_t) src.length() - (maxlen-p1-3); // 3 ellipses - return src.substr(0, p1) + "..." + src.substr(p2); + size_t p1 = (size_t) maxlen / 2; + size_t p2 = (size_t) src.length() - (maxlen - p1 - 1); + return src.substr(0, p1) + "…" + src.substr(p2); } return src; } diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 8d71fc410..0f85d4d98 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -11,6 +11,7 @@ #include "document.h" #include "inkscape.h" #include "profile-manager.h" +#include "gradient-vector.h" #define noDEBUG_LCMS @@ -300,14 +301,18 @@ void ColorICCSelector::init() gtk_widget_show( _fixupBtn ); gtk_table_attach( GTK_TABLE (t), _fixupBtn, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); + // Combobox and store with 2 columns : label (0) and full name (1) + GtkListStore *store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); + _profileSel = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); + + GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (_profileSel), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (_profileSel), renderer, "text", 0, NULL); + + GtkTreeIter iter; + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, 0, _("<none>"), 1, _("<none>"), -1); -#if GTK_CHECK_VERSION(2,24,0) - _profileSel = gtk_combo_box_text_new(); - gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT(_profileSel), _("<none>") ); -#else - _profileSel = gtk_combo_box_new_text(); - gtk_combo_box_append_text( GTK_COMBO_BOX(_profileSel), _("<none>") ); -#endif gtk_widget_show( _profileSel ); gtk_combo_box_set_active( GTK_COMBO_BOX(_profileSel), 0 ); gtk_table_attach( GTK_TABLE(t), _profileSel, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); @@ -460,16 +465,21 @@ void ColorICCSelector::_fixupHit( GtkWidget* /*src*/, gpointer data ) void ColorICCSelector::_profileSelected( GtkWidget* /*src*/, gpointer data ) { ColorICCSelector* self = reinterpret_cast<ColorICCSelector*>(data); - gint activeIndex = gtk_combo_box_get_active( GTK_COMBO_BOX(self->_profileSel) ); -#if GTK_CHECK_VERSION(2,24,0) - gchar* name = (activeIndex != 0) ? gtk_combo_box_text_get_active_text( GTK_COMBO_BOX_TEXT(self->_profileSel) ) : 0; -#else - gchar* name = (activeIndex != 0) ? gtk_combo_box_get_active_text( GTK_COMBO_BOX(self->_profileSel) ) : 0; -#endif //GTK_CHECK_VERSION - self->_switchToProfile( name ); - if ( name ) { - g_free( name ); + + GtkTreeIter iter; + if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX(self->_profileSel), &iter)) { + GtkTreeModel *store = gtk_combo_box_get_model (GTK_COMBO_BOX(self->_profileSel)); + gchar* name = 0; + + gtk_tree_model_get (store, &iter, 1, &name, -1); + self->_switchToProfile( name ); + gtk_widget_set_tooltip_text(self->_profileSel, name ); + + if ( name ) { + g_free( name ); + } } + } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -580,21 +590,12 @@ void ColorICCSelector::_profilesChanged( std::string const & name ) g_signal_handler_block( G_OBJECT(_profileSel), _profChangedID ); - GtkTreeModel* model = gtk_combo_box_get_model( combo ); - GtkTreeIter iter; - while ( gtk_tree_model_get_iter_first( model, &iter ) ) { -#if GTK_CHECK_VERSION(2,24,0) - gtk_combo_box_text_remove( GTK_COMBO_BOX_TEXT(combo), 0 ); -#else - gtk_combo_box_remove_text( combo, 0 ); -#endif - } + GtkListStore *store = (GtkListStore *)gtk_combo_box_get_model (combo); + gtk_list_store_clear(store); -#if GTK_CHECK_VERSION(2,24,0) - gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT(combo), _("<none>")); -#else - gtk_combo_box_append_text( combo, _("<none>")); -#endif + GtkTreeIter iter; + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, 0, _("<none>"), 1, _("<none>"), -1); gtk_combo_box_set_active( combo, 0 ); @@ -603,13 +604,13 @@ void ColorICCSelector::_profilesChanged( std::string const & name ) while ( current ) { SPObject* obj = SP_OBJECT(current->data); Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj); -#if GTK_CHECK_VERSION(2,24,0) - gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT(combo), prof->name ); -#else - gtk_combo_box_append_text( combo, prof->name ); -#endif + + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, 0, gr_ellipsize_text(prof->name, 25).c_str(), 1, prof->name, -1); + if ( name == prof->name ) { gtk_combo_box_set_active( combo, index ); + gtk_widget_set_tooltip_text(_profileSel, prof->name ); } index++; |
