summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorAlexander Valavanis <valavanisalex@gmail.com>2019-05-29 11:57:25 +0000
committerAlexander Valavanis <valavanisalex@gmail.com>2019-05-29 11:57:25 +0000
commit7d6574fe783697fe236e29fcf1d1b437d14e3b2c (patch)
treed82cf241cc14d74c29dbd41deb7d664aeee8371c /src/ui
parentHackfest2019: Add an entry to ComboBoxToolItem (diff)
downloadinkscape-7d6574fe783697fe236e29fcf1d1b437d14e3b2c.tar.gz
inkscape-7d6574fe783697fe236e29fcf1d1b437d14e3b2c.zip
Hackfest 2019: C++ify ComboBoxEntryAction
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/toolbar/text-toolbar.cpp35
-rw-r--r--src/ui/toolbar/text-toolbar.h20
2 files changed, 29 insertions, 26 deletions
diff --git a/src/ui/toolbar/text-toolbar.cpp b/src/ui/toolbar/text-toolbar.cpp
index 4b9b0f160..929c709f7 100644
--- a/src/ui/toolbar/text-toolbar.cpp
+++ b/src/ui/toolbar/text-toolbar.cpp
@@ -753,7 +753,7 @@ TextToolbar::TextToolbar(SPDesktop *desktop)
}
void
-TextToolbar::fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, gpointer data )
+TextToolbar::fontfamily_value_changed( UI::Widget::ComboBoxEntryAction *act, gpointer data )
{
auto toolbar = reinterpret_cast<TextToolbar *>(data);
@@ -773,7 +773,7 @@ TextToolbar::fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, gpointer d
}
toolbar->_freeze = true;
- Glib::ustring new_family = ink_comboboxentry_action_get_active_text( act );
+ Glib::ustring new_family = act->get_active_text();
css_font_family_unquote( new_family ); // Remove quotes around font family names.
// TODO: Think about how to handle handle multiple selections. While
@@ -789,13 +789,16 @@ TextToolbar::fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, gpointer d
if( new_family.compare( fontlister->get_font_family() ) != 0 ) {
// Changed font-family
- if( act->active == -1 ) {
+ if( act->get_active() == -1 ) {
// New font-family, not in document, not on system (could be fallback list)
fontlister->insert_font_family( new_family );
- act->active = 0; // New family is always at top of list.
+
+ // This just sets a variable in the ComboBoxEntryAction object...
+ // shouldn't we also set the actual active row in the combobox?
+ act->set_active(0); // New family is always at top of list.
}
- fontlister->set_font_family( act->active );
+ fontlister->set_font_family( act->get_active() );
// active text set in sp_text_toolbox_selection_changed()
SPCSSAttr *css = sp_repr_css_attr_new ();
@@ -833,7 +836,7 @@ TextToolbar::create(SPDesktop *desktop)
}
void
-TextToolbar::fontsize_value_changed( Ink_ComboBoxEntry_Action *act, gpointer data)
+TextToolbar::fontsize_value_changed( UI::Widget::ComboBoxEntryAction *act, gpointer data)
{
auto toolbar = reinterpret_cast<TextToolbar *>(data);
@@ -843,7 +846,7 @@ TextToolbar::fontsize_value_changed( Ink_ComboBoxEntry_Action *act, gpointer dat
}
toolbar->_freeze = true;
- gchar *text = ink_comboboxentry_action_get_active_text( act );
+ gchar *text = act->get_active_text();
gchar *endptr;
gdouble size = g_strtod( text, &endptr );
if (endptr == text) { // Conversion failed, non-numeric input.
@@ -922,7 +925,7 @@ TextToolbar::fontsize_value_changed( Ink_ComboBoxEntry_Action *act, gpointer dat
}
void
-TextToolbar::fontstyle_value_changed( Ink_ComboBoxEntry_Action *act, gpointer data)
+TextToolbar::fontstyle_value_changed( UI::Widget::ComboBoxEntryAction *act, gpointer data)
{
auto toolbar = reinterpret_cast<TextToolbar *>(data);
@@ -932,7 +935,7 @@ TextToolbar::fontstyle_value_changed( Ink_ComboBoxEntry_Action *act, gpointer da
}
toolbar->_freeze = true;
- Glib::ustring new_style = ink_comboboxentry_action_get_active_text( act );
+ Glib::ustring new_style = act->get_active_text();
Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance();
@@ -2015,9 +2018,9 @@ TextToolbar::selection_changed(Inkscape::Selection * /*selection*/, bool subsele
fontlister->selection_update();
// Update font list, but only if widget already created.
- if( _font_family_action->combobox != nullptr ) {
- ink_comboboxentry_action_set_active_text( _font_family_action, fontlister->get_font_family().c_str(), fontlister->get_font_family_row() );
- ink_comboboxentry_action_set_active_text( _font_style_action, fontlister->get_font_style().c_str() );
+ if( _font_family_action->get_combobox() != nullptr ) {
+ _font_family_action->set_active_text( fontlister->get_font_family().c_str(), fontlister->get_font_family_row() );
+ _font_style_action->set_active_text( fontlister->get_font_style().c_str() );
}
// Only flowed text can be justified, only normal text can be kerned...
@@ -2092,7 +2095,7 @@ TextToolbar::selection_changed(Inkscape::Selection * /*selection*/, bool subsele
// To ensure the value of the combobox is properly set on start-up, only mark
// the prefs set if the combobox has already been constructed.
- if( _font_family_action->combobox != nullptr ) {
+ if( _font_family_action->get_combobox() != nullptr ) {
_text_style_from_prefs = true;
}
} else {
@@ -2114,13 +2117,13 @@ TextToolbar::selection_changed(Inkscape::Selection * /*selection*/, bool subsele
// Freeze to ignore callbacks.
//g_object_freeze_notify( G_OBJECT( fontSizeAction->combobox ) );
- sp_text_set_sizes(GTK_LIST_STORE(ink_comboboxentry_action_get_model(_font_size_action)), unit);
+ sp_text_set_sizes(GTK_LIST_STORE(_font_size_action->get_model()), unit);
//g_object_thaw_notify( G_OBJECT( fontSizeAction->combobox ) );
- ink_comboboxentry_action_set_active_text( _font_size_action, os.str().c_str() );
+ _font_size_action->set_active_text( os.str().c_str() );
Glib::ustring tooltip = Glib::ustring::format(_("Font size"), " (", sp_style_get_css_unit_string(unit), ")");
- ink_comboboxentry_action_set_tooltip ( _font_size_action, tooltip.c_str());
+ _font_size_action->set_tooltip (tooltip.c_str());
// Superscript
gboolean superscriptSet =
diff --git a/src/ui/toolbar/text-toolbar.h b/src/ui/toolbar/text-toolbar.h
index aec51fd49..0c47b33b5 100644
--- a/src/ui/toolbar/text-toolbar.h
+++ b/src/ui/toolbar/text-toolbar.h
@@ -34,10 +34,8 @@
class SPDesktop;
-typedef struct _GtkActionGroup GtkActionGroup;
-typedef struct _Ink_ComboBoxEntry_Action Ink_ComboBoxEntry_Action;
-
namespace Gtk {
+class ComboBoxText;
class ToggleToolButton;
}
@@ -50,6 +48,7 @@ class ToolBase;
}
namespace Widget {
+class ComboBoxEntryAction;
class ComboToolItem;
class SpinButtonToolItem;
class UnitTracker;
@@ -63,9 +62,9 @@ private:
UI::Widget::UnitTracker *_tracker;
- Ink_ComboBoxEntry_Action *_font_family_action;
- Ink_ComboBoxEntry_Action *_font_size_action;
- Ink_ComboBoxEntry_Action *_font_style_action;
+ UI::Widget::ComboBoxEntryAction *_font_family_action;
+ UI::Widget::ComboBoxEntryAction *_font_size_action;
+ UI::Widget::ComboBoxEntryAction *_font_style_action;
Gtk::ToggleToolButton *_superscript_item;
Gtk::ToggleToolButton *_subscript_item;
Gtk::ToggleToolButton *_outer_style_item;
@@ -97,12 +96,12 @@ private:
sigc::connection c_selection_modified;
sigc::connection c_subselection_changed;
- static void fontfamily_value_changed(Ink_ComboBoxEntry_Action *act,
- gpointer data);
- static void fontsize_value_changed (Ink_ComboBoxEntry_Action *act,
+ static void fontfamily_value_changed(UI::Widget::ComboBoxEntryAction *act,
gpointer data);
- static void fontstyle_value_changed (Ink_ComboBoxEntry_Action *act,
+ static void fontsize_value_changed (UI::Widget::ComboBoxEntryAction *act,
gpointer data);
+ static void fontstyle_value_changed (UI::Widget::ComboBoxEntryAction *act,
+ gpointer data);
void script_changed(Gtk::ToggleToolButton *btn);
void lineheight_unset_changed();
void outer_style_changed();
@@ -123,6 +122,7 @@ private:
void selection_modified(Inkscape::Selection *selection, guint flags);
void subselection_changed(gpointer tc);
void watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec);
+ void set_sizes(int unit);
protected:
TextToolbar(SPDesktop *desktop);