summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2013-02-02 08:54:40 +0000
committertavmjong-free <tavmjong@free.fr>2013-02-02 08:54:40 +0000
commitfe9078f74cb1dbf160b712408f9c3f2e1ca53f5e (patch)
tree6dc220b949ecbd04ebadb4ed726167a44bba488a /src
parentFix for 1002757 : Regressions with new default font 'sans-serif' (diff)
downloadinkscape-fe9078f74cb1dbf160b712408f9c3f2e1ca53f5e.tar.gz
inkscape-fe9078f74cb1dbf160b712408f9c3f2e1ca53f5e.zip
Text-Toolbar font-family entry-box warning-icon tooltip now includes list of missing fonts.
(bzr r12090)
Diffstat (limited to 'src')
-rw-r--r--src/ink-comboboxentry-action.cpp67
1 files changed, 38 insertions, 29 deletions
diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp
index 8df16ec9a..a28ec4f53 100644
--- a/src/ink-comboboxentry-action.cpp
+++ b/src/ink-comboboxentry-action.cpp
@@ -25,6 +25,7 @@
#include <iostream>
#include <string.h>
+#include <glibmm/ustring.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
@@ -37,7 +38,7 @@ static GtkWidget* create_menu_item( GtkAction* action );
// Internal
static gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* target_text );
-static gint check_comma_separated_text( Ink_ComboBoxEntry_Action* action );
+static Glib::ustring check_comma_separated_text( Ink_ComboBoxEntry_Action* action );
// Callbacks
static void combo_box_changed_cb( GtkComboBox* widget, gpointer data );
@@ -469,10 +470,12 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink
gtk_entry_set_text( ink_comboboxentry_action->entry, text );
// Show or hide warning
+ bool clear = true;
if( ink_comboboxentry_action->active == -1 &&
- ink_comboboxentry_action->warning != NULL &&
- check_comma_separated_text( ink_comboboxentry_action ) ) {
- {
+ ink_comboboxentry_action->warning != NULL ) {
+ Glib::ustring missing = check_comma_separated_text( ink_comboboxentry_action );
+ if( !missing.empty() ) {
+
GtkStockItem item;
gboolean isStock = gtk_stock_lookup( GTK_STOCK_DIALOG_WARNING, &item );
if (isStock) {
@@ -484,15 +487,21 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink
GTK_ENTRY_ICON_SECONDARY,
GTK_STOCK_DIALOG_WARNING );
}
+ // Can't add tooltip until icon set
+ Glib::ustring warning = ink_comboboxentry_action->warning;
+ warning += ": ";
+ warning += missing;
+ gtk_entry_set_icon_tooltip_text( ink_comboboxentry_action->entry,
+ GTK_ENTRY_ICON_SECONDARY,
+ warning.c_str() );
+ clear = false;
}
- // Can't add tooltip until icon set
- gtk_entry_set_icon_tooltip_text( ink_comboboxentry_action->entry,
- GTK_ENTRY_ICON_SECONDARY,
- ink_comboboxentry_action->warning );
- } else {
+ }
+
+ if( clear ) {
gtk_entry_set_icon_from_icon_name( GTK_ENTRY(ink_comboboxentry_action->entry),
- GTK_ENTRY_ICON_SECONDARY,
- NULL );
+ GTK_ENTRY_ICON_SECONDARY,
+ NULL );
gtk_entry_set_icon_from_stock( GTK_ENTRY(ink_comboboxentry_action->entry),
GTK_ENTRY_ICON_SECONDARY,
NULL );
@@ -631,18 +640,21 @@ gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* ta
}
-// Checks if all comma separated text fragments are in the list.
+// Checks if all comma separated text fragments are in the list and
+// returns a ustring with a list of missing fragments.
// This is useful for checking if all fonts in a font-family fallback
// list are available on the system.
-// The return value is set to the number of missing text fragments.
+//
// This routine could also create a Pango Markup string to show which
-// fragments are invalid.
-// It is envisioned that one can construct a Pango Markup String here
-// so that individual text fragments can be flagged as not being in the
-// list.
-static gint check_comma_separated_text( Ink_ComboBoxEntry_Action* action ) {
+// fragments are invalid in the entry box itself. See:
+// http://developer.gnome.org/pango/stable/PangoMarkupFormat.html
+// However... it appears that while one can retrieve the PangoLayout
+// for a GtkEntry box, it is only a copy and changing it has no effect.
+// PangoLayout * pl = gtk_entry_get_layout( entry );
+// pango_layout_set_markup( pl, "NEW STRING", -1 ); // DOESN'T WORK
+static Glib::ustring check_comma_separated_text( Ink_ComboBoxEntry_Action* action ) {
- gint ret_val = 0;
+ Glib::ustring missing;
// Parse fallback_list using a comma as deliminator
gchar** tokens = g_strsplit( action->text, ",", 0 );
@@ -654,21 +666,18 @@ static gint check_comma_separated_text( Ink_ComboBoxEntry_Action* action ) {
g_strstrip( tokens[i] );
if( get_active_row_from_text( action, tokens[i] ) == -1 ) {
- ret_val += 1;
+ missing += tokens[i];
+ missing += ", ";
}
++i;
}
g_strfreev( tokens );
- // Pango Markup notes:
- // GString* Pango_Markup = g_string_new("");
- // if not present:
- // g_string_sprintfa( Pango_Markup, "<span strikethrough=\"true\" strikethrough_color=\"#880000\">%s</span>", tokens[i] );
- // PangoLayout * pl = gtk_entry_get_layout( entry );
- // pango_layout_set_markup( pl, Pango_Markup->str, -1 );
- // g_string_free( Pango_Markup, TRUE );
-
- return ret_val;
+ // Remove extra comma and space from end.
+ if( missing.size() >= 2 ) {
+ missing.resize( missing.size()-2 );
+ }
+ return missing;
}
// Callbacks ---------------------------------------------------