summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bd8075a)
raw | patch | inline | side by side (parent: bd8075a)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 30 Jan 2008 08:51:08 +0000 (08:51 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 30 Jan 2008 08:51:08 +0000 (08:51 +0000) |
src/widgets/font-selector.cpp | patch | blob | history |
index 9da48d0e63ede4fd7d45c4a8138227674104ff3c..6745fcc59c996e9402ecf19230835b0c14ac2678 100644 (file)
static void sp_font_selector_size_changed( GtkComboBox */*cbox*/, SPFontSelector *fsel )
{
- char *sstr = gtk_combo_box_get_active_text (GTK_COMBO_BOX (fsel->size));
+ char *text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (fsel->size));
gfloat old_size = fsel->fontsize;
- fsel->fontsize = MAX(atof(sstr), 0.1);
+
+ gchar *endptr;
+ gdouble value = -1;
+ if (text) {
+ value = g_strtod (text, &endptr);
+ if (endptr == text) // conversion failed, non-numeric input
+ value = -1;
+ free (text);
+ }
+ if (value <= 0) {
+ return; // could not parse value
+ }
+ if (value > 10000)
+ value = 10000; // somewhat arbitrary, but text&font preview freezes with too huge fontsizes
+
+ fsel->fontsize = value;
if ( fabs(fsel->fontsize-old_size) > 0.001)
{
fsel->fontsize_dirty = true;
}
sp_font_selector_emit_set (fsel);
-
- free (sstr);
}
static void sp_font_selector_emit_set (SPFontSelector *fsel)