=== modified file 'src/ui/dialog/inkscape-preferences.cpp'
--- src/ui/dialog/inkscape-preferences.cpp 2015-11-01 12:50:42 +0000
+++ src/ui/dialog/inkscape-preferences.cpp 2015-11-06 17:29:44 +0000
@@ -2068,6 +2068,9 @@
_page_list.expand_row(_path_behavior, false);
if (desired_page >= PREFS_PAGE_IO && desired_page <= PREFS_PAGE_IO_OPENCLIPART)
_page_list.expand_row(_path_io, false);
+ if (desired_page == PREFS_PAGE_TOOLS_TEXT)
+ _font_unit_type.set_active(prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT) -1);
+
_page_list.get_selection()->select(iter);
return true;
}
@@ -2112,6 +2115,9 @@
_page_title.set_markup("" + col_name_escaped + "");
_page_frame.add(*_current_page);
_current_page->show();
+ if (row[_page_list_columns._col_id] == PREFS_PAGE_TOOLS_TEXT){
+ _font_unit_type.set_active(prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT) -1);
+ }
while (Gtk::Main::events_pending())
{
Gtk::Main::iteration();
=== modified file 'src/widgets/font-selector.cpp'
--- src/widgets/font-selector.cpp 2014-10-17 20:03:14 +0000
+++ src/widgets/font-selector.cpp 2015-11-06 16:25:50 +0000
@@ -25,9 +25,9 @@
#include <2geom/transforms.h>
#include
-
+#include "inkscape.h"
#include
-
+#include "util/units.h"
#include "desktop.h"
#include "widgets/font-selector.h"
#include "preferences.h"
@@ -47,6 +47,7 @@
GtkWidget *family;
GtkWidget *style;
GtkWidget *size;
+ GtkWidget *fontunit;
GtkWidget *family_treeview;
GtkWidget *style_treeview;
@@ -86,6 +87,9 @@
static void sp_font_selector_size_changed (GtkComboBox *combobox,
SPFontSelector *fsel);
+static void sp_font_selector_unit_changed (GtkComboBox *combobox,
+ SPFontSelector *fsel);
+
static void sp_font_selector_emit_set (SPFontSelector *fsel);
static void sp_font_selector_set_sizes( SPFontSelector *fsel );
@@ -121,6 +125,14 @@
gtk_widget_set_tooltip_text (fsel->size, _(tooltip.c_str()));
}
+static void sp_font_selector_set_unit_tooltip(SPFontSelector *fsel)
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT);
+ Glib::ustring tooltip = Glib::ustring::format(_("Units"), " (", sp_style_get_css_unit_string(unit), ")");
+ gtk_widget_set_tooltip_text (fsel->size, _(tooltip.c_str()));
+}
+
/*
* Create a widget with children for selecting font-family, font-style, and font-size.
@@ -229,6 +241,32 @@
gtk_widget_show(hb);
gtk_box_pack_start(GTK_BOX(vb), hb, FALSE, FALSE, 0);
+ //Font-units
+ // List of font sizes for drop-down menu
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT);
+ // List of font sizes for drop-down menu
+ int units[] = {SP_CSS_UNIT_PX, SP_CSS_UNIT_PT, SP_CSS_UNIT_PC, SP_CSS_UNIT_MM, SP_CSS_UNIT_CM, SP_CSS_UNIT_IN, SP_CSS_UNIT_EM/*, SP_CSS_UNIT_EX, SP_CSS_UNIT_PERCENT*/};
+
+ GtkTreeIter iter;
+ GtkListStore *storeunits = gtk_list_store_new(1,G_TYPE_STRING);
+ for( unsigned int i = 0; i < G_N_ELEMENTS(units); ++i ) {
+ gtk_list_store_append(storeunits,&iter);
+ gtk_list_store_set(storeunits,&iter,0,sp_style_get_css_unit_string(units[i]),-1);
+ }
+ fsel->fontunit = gtk_combo_box_new_with_model(GTK_TREE_MODEL(storeunits));
+ sp_font_selector_set_unit_tooltip(fsel);
+ g_object_unref(storeunits);
+ GtkCellRenderer *combocell = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(fsel->fontunit), combocell, TRUE );
+ gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT(fsel->fontunit), combocell, "text", 0, NULL );
+ g_signal_connect (G_OBJECT(fsel->fontunit), "changed", G_CALLBACK (sp_font_selector_unit_changed), fsel);
+ gtk_box_pack_end (GTK_BOX(hb), fsel->fontunit, FALSE, FALSE, 0);
+
+ gtk_combo_box_set_active(GTK_COMBO_BOX(fsel->fontunit), (gint)unit - 1);
+
+ gtk_widget_show_all (fsel->fontunit);
+
// Font-size
fsel->size = gtk_combo_box_text_new_with_entry ();
@@ -251,6 +289,7 @@
fsel->fontsize_dirty = false;
fsel->fontspec = new Glib::ustring;
+
}
static void sp_font_selector_dispose(GObject *object)
@@ -403,8 +442,26 @@
{
fsel->fontsize_dirty = true;
}
+ //todo: select the active fammily on apply button to use sp_font_selector_emit_set to activate the apply button
+ g_signal_emit(fsel, fs_signals[FONT_SET], 0, "");
+}
- sp_font_selector_emit_set (fsel);
+// Callback when unit changed
+static void sp_font_selector_unit_changed( GtkComboBox */*cbox*/, SPFontSelector *fsel )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ SPCSSUnit unit = (SPCSSUnit)gtk_combo_box_get_active(GTK_COMBO_BOX (fsel->fontunit));
+ int units[] = {SP_CSS_UNIT_PX, SP_CSS_UNIT_PT, SP_CSS_UNIT_PC, SP_CSS_UNIT_MM, SP_CSS_UNIT_CM, SP_CSS_UNIT_IN, SP_CSS_UNIT_EM/*, SP_CSS_UNIT_EX, SP_CSS_UNIT_PERCENT*/};
+ prefs->setInt("/options/font/unitType", units[unit]);
+ SPStyle query(SP_ACTIVE_DOCUMENT);
+ double size = sp_style_css_size_px_to_units(query.font_size.computed, units[unit]);
+ std::stringstream new_font_num;
+ new_font_num.imbue(std::locale::classic());
+ new_font_num << size;
+ gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child (GTK_BIN (fsel->size))), new_font_num.str().c_str());
+ sp_font_selector_set_sizes( fsel );
+ sp_font_selector_set_size_tooltip( fsel);
+ sp_font_selector_set_unit_tooltip(fsel);
}
@@ -436,7 +493,6 @@
if (!gtk_tree_selection_get_selected (selection_family, NULL, &iter_family)) return;
if (!gtk_tree_selection_get_selected (selection_style, NULL, &iter_style )) return;
-
gtk_tree_model_get (model_family, &iter_family, 0, &family, -1);
gtk_tree_model_get (model_style, &iter_style, 0, &style, -1);
@@ -504,7 +560,11 @@
gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (fsel->style_treeview)), path_c.gobj());
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (fsel->style_treeview), path_c.gobj(), NULL, TRUE, 0.5, 0.5);
-
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(fsel->fontunit), (gint)unit - 1);
+
if (size != fsel->fontsize)
{
gchar s[8];
@@ -512,6 +572,7 @@
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(fsel->size))), s);
fsel->fontsize = size;
sp_font_selector_set_size_tooltip(fsel);
+ sp_font_selector_set_unit_tooltip(fsel);
sp_font_selector_set_sizes(fsel);
}
}
=== modified file 'src/widgets/text-toolbar.cpp'
--- src/widgets/text-toolbar.cpp 2015-04-29 20:51:23 +0000
+++ src/widgets/text-toolbar.cpp 2015-11-06 16:16:27 +0000
@@ -51,6 +51,7 @@
#include "svg/css-ostringstream.h"
#include "text-editing.h"
#include "toolbox.h"
+#include "util/units.h"
#include "ui/icon-names.h"
#include "ui/tools/text-tool.h"
#include "ui/tools/tool-base.h"
@@ -69,7 +70,6 @@
// Functions for debugging:
#ifdef DEBUG_TEXT
-
static void sp_print_font( SPStyle *query ) {
bool family_set = query->font_family.set;
@@ -113,7 +113,7 @@
}
#endif
-
+static void sp_text_set_sizes(GtkListStore* model_size, int unit);
// Font family
static void sp_text_fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, GObject *tbl )
{
@@ -193,7 +193,6 @@
return;
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
-
gchar *text = ink_comboboxentry_action_get_active_text( act );
gchar *endptr;
gdouble size = g_strtod( text, &endptr );
@@ -243,6 +242,28 @@
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
+static void sp_text_fontunit_value_changed( EgeSelectOneAction *eact, GObject *tbl ){
+ // quit if run by the _changed callbacks
+ if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
+ return;
+ }
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ SPCSSUnit unit = (SPCSSUnit)ege_select_one_action_get_active(eact);
+ int units[] = {SP_CSS_UNIT_PX, SP_CSS_UNIT_PT, SP_CSS_UNIT_PC, SP_CSS_UNIT_MM, SP_CSS_UNIT_CM, SP_CSS_UNIT_IN, SP_CSS_UNIT_EM/*, SP_CSS_UNIT_EX, SP_CSS_UNIT_PERCENT*/};
+ prefs->setInt("/options/font/unitType", units[unit]);
+ SPStyle query(SP_ACTIVE_DOCUMENT);
+ double size = sp_style_css_size_px_to_units(query.font_size.computed, units[unit]);
+ std::stringstream new_font_num;
+ new_font_num.imbue(std::locale::classic());
+ new_font_num << size;
+ Ink_ComboBoxEntry_Action* fontsize = INK_COMBOBOXENTRY_ACTION( g_object_get_data(tbl, "TextFontSizeAction") );
+ ink_comboboxentry_action_set_active_text( fontsize , new_font_num.str().c_str());
+ Glib::ustring tooltip = Glib::ustring::format(_("Font size"), " (", sp_style_get_css_unit_string(units[unit]), ")");
+ ink_comboboxentry_action_set_tooltip ( fontsize, tooltip.c_str());
+ sp_text_set_sizes(GTK_LIST_STORE(ink_comboboxentry_action_get_model(fontsize)), unit);
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+}
/*
* Font style
@@ -809,7 +830,6 @@
}
}
-
/*
* This function sets up the text-tool tool-controls, setting the entry boxes
* etc. to the values from the current selection or the default if no selection.
@@ -854,7 +874,11 @@
INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontFamilyAction" ) );
Ink_ComboBoxEntry_Action* fontStyleAction =
INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontStyleAction" ) );
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT);
+ EgeSelectOneAction* fontUnits =
+ EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextFontUnitAction" ) );
+ ege_select_one_action_set_active(fontUnits,(gint)unit - 1);
Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance();
if (!subselection) {
fontlister->update_font_list( SP_ACTIVE_DESKTOP->getDocument());
@@ -1262,8 +1286,7 @@
sp_text_set_sizes(model_size, unit);
- Glib::ustring tooltip = Glib::ustring::format(_("Font size"), " (", sp_style_get_css_unit_string(unit), ")");
-
+ Glib::ustring tooltip = Glib::ustring(_("Font size"));
Ink_ComboBoxEntry_Action* act = ink_comboboxentry_action_new( "TextFontSizeAction",
_("Font Size"),
_(tooltip.c_str()),
@@ -1280,6 +1303,33 @@
g_object_set_data( holder, "TextFontSizeAction", act );
}
+ /* Font unit */
+ {
+ // List of font sizes for drop-down menu
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT);
+ // List of font sizes for drop-down menu
+ int units[] = {SP_CSS_UNIT_PX, SP_CSS_UNIT_PT, SP_CSS_UNIT_PC, SP_CSS_UNIT_MM, SP_CSS_UNIT_CM, SP_CSS_UNIT_IN, SP_CSS_UNIT_EM/*, SP_CSS_UNIT_EX, SP_CSS_UNIT_PERCENT*/};
+
+ GtkTreeIter iter;
+ GtkListStore *store = gtk_list_store_new(1,G_TYPE_STRING);
+ for( unsigned int i = 0; i < G_N_ELEMENTS(units); ++i ) {
+ gtk_list_store_append(store,&iter);
+ gtk_list_store_set(store,&iter,0,sp_style_get_css_unit_string(units[i]),-1);
+ }
+ Glib::ustring tooltip = Glib::ustring(_("Font Unit"));
+ EgeSelectOneAction* eact = ege_select_one_action_new( "TextFontUnitAction",
+ _("Font unit"),
+ _(tooltip.c_str()),
+ NULL,
+ GTK_TREE_MODEL(store));
+ //-1 to handle SP_CSS_UNIT_NONE
+ ege_select_one_action_set_active(eact,(gint)unit - 1);
+ g_signal_connect( G_OBJECT(eact), "changed", G_CALLBACK(sp_text_fontunit_value_changed), holder );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact));
+ g_object_set_data( holder, "TextFontUnitAction", eact );
+ }
+
/* Font styles */
{
Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance();
=== modified file 'src/widgets/toolbox.cpp'
--- src/widgets/toolbox.cpp 2015-10-22 17:29:20 +0000
+++ src/widgets/toolbox.cpp 2015-11-06 16:16:27 +0000
@@ -476,6 +476,7 @@
" "
" "
" "
+ " "
" "
// " "
// " "