summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d83c856)
raw | patch | inline | side by side (parent: d83c856)
author | mderezynski <mderezynski@users.sourceforge.net> | |
Thu, 18 May 2006 18:58:55 +0000 (18:58 +0000) | ||
committer | mderezynski <mderezynski@users.sourceforge.net> | |
Thu, 18 May 2006 18:58:55 +0000 (18:58 +0000) |
* Throw an exception if no TreePath can be found in the map (as in "no such family exists")
src/libnrtype/font-lister.h | patch | blob | history | |
src/widgets/font-selector.cpp | patch | blob | history | |
src/widgets/toolbox.cpp | patch | blob | history |
index b43395912141a34297eb2b3307a6b4e9749b62eb..fb0810254e4617cd08bc5c25ebd297971620257a 100644 (file)
class FontLister
{
public:
+
+ enum Exceptions
+ {
+ FAMILY_NOT_FOUND
+ };
+
+
~FontLister ();
/** GtkTreeModelColumnRecord for the font list Gtk::ListStore
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;
}
index ec619c50c202bf1d6f367d028de83ed1f13e5aca..51f706d4b03e8ca750d3b33589ffaa1b6353daa3 100644 (file)
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());
index 15dd7f9aeb0daf2c5e2c859ffb0c8ab8522d6e97..c306d16902805dd47cece36c066dc01bfd5a9b5d 100644 (file)
--- 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
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);
}
#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