summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMilosz Derezynski <mderezynski@gmail.com>2006-05-18 18:58:55 +0000
committermderezynski <mderezynski@users.sourceforge.net>2006-05-18 18:58:55 +0000
commit271df93cb3f417955a3637ca7e170b897ae81c32 (patch)
tree65e2348d78c08302cf74a42ef7039c15efb6bbd2 /src
parent* Use query api for text toolbar (diff)
downloadinkscape-271df93cb3f417955a3637ca7e170b897ae81c32.tar.gz
inkscape-271df93cb3f417955a3637ca7e170b897ae81c32.zip
* Check for a valid font family in the text toolbox's selection_changed callback
* Throw an exception if no TreePath can be found in the map (as in "no such family exists") (bzr r879)
Diffstat (limited to 'src')
-rw-r--r--src/libnrtype/font-lister.h8
-rw-r--r--src/widgets/font-selector.cpp9
-rw-r--r--src/widgets/toolbox.cpp43
3 files changed, 31 insertions, 29 deletions
diff --git a/src/libnrtype/font-lister.h b/src/libnrtype/font-lister.h
index b43395912..fb0810254 100644
--- a/src/libnrtype/font-lister.h
+++ b/src/libnrtype/font-lister.h
@@ -28,6 +28,13 @@ namespace Inkscape
class FontLister
{
public:
+
+ enum Exceptions
+ {
+ FAMILY_NOT_FOUND
+ };
+
+
~FontLister ();
/** GtkTreeModelColumnRecord for the font list Gtk::ListStore
@@ -75,6 +82,7 @@ namespace Inkscape
get_row_for_font (std::string family)
{
IterMapType::iterator iter = font_list_store_iter_map.find (family);
+ if (iter == font_list_store_iter_map.end ()) throw FAMILY_NOT_FOUND;
return (*iter).second;
}
diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp
index ec619c50c..51f706d4b 100644
--- a/src/widgets/font-selector.cpp
+++ b/src/widgets/font-selector.cpp
@@ -383,13 +383,18 @@ GtkWidget *sp_font_selector_new()
void sp_font_selector_set_font (SPFontSelector *fsel, font_instance *font, double size)
{
-
if (font && (fsel->font != font || size != fsel->fontsize))
{
gchar family[256];
font->Family (family, 256);
+
+ Gtk::TreePath path;
- Gtk::TreePath path = Inkscape::FontLister::get_instance()->get_row_for_font (family);
+ try {
+ path = Inkscape::FontLister::get_instance()->get_row_for_font (family);
+ } catch (...) {
+ return;
+ }
fsel->block_emit = TRUE;
gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (fsel->family_treeview)), path.gobj());
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 15dd7f9ae..c306d1690 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -2801,31 +2801,10 @@ sp_text_toolbox_selection_changed (Inkscape::Selection *selection, GObject *tbl)
// If querying returned nothing, read the style from the text tool prefs (default style for new texts)
if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING || result_numbers == QUERY_STYLE_NOTHING)
{
- repr = inkscape_get_repr (INKSCAPE, "tools.text");
- if (repr)
- {
- sp_style_read_from_repr (query, repr);
- }
- else
- {
- return;
- }
- }
-
-#if 0
- // FIXME: process result_family/style == QUERY_STYLE_MULTIPLE_DIFFERENT by showing "Many" in the lists
- font_instance *font = (font_factory::Default())->Face ( query->text->font_family.value, font_style_to_pos(*query) );
- if (font)
- {
- // the font is oversized, so we need to pass the true size separately
- sp_font_selector_set_font (SP_FONT_SELECTOR (fontsel), font, query->font_size.computed);
- sp_font_preview_set_font (SP_FONT_PREVIEW (preview), font, SP_FONT_SELECTOR(fontsel));
- font->Unref();
- font=NULL;
+ return;
}
-#endif
- if (result_numbers > 1)
+ if (result_numbers == QUERY_STYLE_MULTIPLE_DIFFERENT)
{
g_object_set_data (G_OBJECT (cbox), "block", GINT_TO_POINTER(1));
gtk_combo_box_set_active (GTK_COMBO_BOX (cbox), -1);
@@ -2833,8 +2812,18 @@ sp_text_toolbox_selection_changed (Inkscape::Selection *selection, GObject *tbl)
return;
}
- Gtk::TreePath path = Inkscape::FontLister::get_instance()->get_row_for_font (query->text->font_family.value);
- gtk_combo_box_set_active (GTK_COMBO_BOX (cbox), gtk_tree_path_get_indices (path.gobj())[0]);
+ if (query->text && query->text->font_family.value)
+ {
+ Gtk::TreePath path;
+ try {
+ path = Inkscape::FontLister::get_instance()->get_row_for_font (query->text->font_family.value);
+ } catch (...) {
+ return;
+ }
+ g_object_set_data (G_OBJECT (cbox), "block", GINT_TO_POINTER(1));
+ gtk_combo_box_set_active (GTK_COMBO_BOX (cbox), gtk_tree_path_get_indices (path.gobj())[0]);
+ g_object_set_data (G_OBJECT (cbox), "block", GINT_TO_POINTER(0));
+ }
}
static void
@@ -2847,7 +2836,7 @@ sp_text_toolbox_family_changed (GtkComboBox *cbox,
SPCSSAttr *css = sp_repr_css_attr_new ();
sp_repr_css_set_property (css, "font-family", gtk_combo_box_get_active_text (cbox));
- sp_desktop_set_style(desktop, css, true, true);
+ sp_desktop_set_style (desktop, css, true, true);
sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP));
sp_repr_css_attr_unref (css);
}
@@ -2911,7 +2900,7 @@ sp_text_toolbox_new (SPDesktop *desktop)
#endif
sigc::connection *connection =
- new sigc::connection(sp_desktop_selection(desktop)->connectChanged (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_changed), (GObject*)tbl)));
+ new sigc::connection( sp_desktop_selection (desktop)->connectChanged (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_changed), (GObject*)tbl)));
g_signal_connect(G_OBJECT(tbl), "destroy", G_CALLBACK(delete_connection), connection);
#if 0