Commit eed14fb8 authored by Alex Valavanis's avatar Alex Valavanis

Finish TextToolbar migration

parent 5c2e77fe
<ui>
<!--
<toolbar name='TextToolbar'>
<toolitem action='TextFontFamilyAction' />
<toolitem action='TextFontStyleAction' />
<separator />
<toolitem action='TextOuterStyleAction' />
<toolitem action='TextFontSizeAction' />
<toolitem action='TextLineHeightAction' />
<toolitem action='TextLineHeightUnitsAction' />
<toolitem action='TextLineHeightUnsetAction' />
<toolitem action='TextLineSpacingAction' />
<separator />
<toolitem action='TextAlignAction' />
<separator />
<toolitem action='TextSuperscriptAction' />
<toolitem action='TextSubscriptAction' />
<separator />
<toolitem action='TextLetterSpacingAction' />
<toolitem action='TextWordSpacingAction' />
<toolitem action='TextDxAction' />
<toolitem action='TextDyAction' />
<toolitem action='TextRotationAction' />
<separator />
<toolitem action='TextWritingModeAction' />
<toolitem action='TextOrientationAction' />
<toolitem action='TextDirectionAction' />
</toolbar>
-->
</ui>
......@@ -162,6 +162,7 @@ set(ui_SRC
widget/color-scales.cpp
widget/color-slider.cpp
widget/color-wheel-selector.cpp
widget/combo-box-entry-tool-item.cpp
widget/combo-tool-item.cpp
widget/dash-selector.cpp
widget/dock-item.cpp
......@@ -395,6 +396,7 @@ set(ui_SRC
widget/color-slider.h
widget/color-wheel-selector.h
widget/combo-enums.h
widget/combo-box-entry-tool-item.h
widget/combo-tool-item.h
widget/dash-selector.h
widget/dock-item.h
......
......@@ -53,11 +53,11 @@
#include "ui/icon-names.h"
#include "ui/tools/text-tool.h"
#include "ui/widget/combo-box-entry-tool-item.h"
#include "ui/widget/combo-tool-item.h"
#include "ui/widget/spin-button-tool-item.h"
#include "ui/widget/unit-tracker.h"
#include "widgets/ink-comboboxentry-action.h"
#include "widgets/style-utils.h"
using Inkscape::DocumentUndo;
......@@ -270,7 +270,6 @@ TextToolbar::TextToolbar(SPDesktop *desktop)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
#if 0
/* Font family */
{
// Font list
......@@ -279,8 +278,8 @@ TextToolbar::TextToolbar(SPDesktop *desktop)
Glib::RefPtr<Gtk::ListStore> store = fontlister->get_font_list();
GtkListStore* model = store->gobj();
toolbar->_font_family_action =
ink_comboboxentry_action_new( "TextFontFamilyAction",
_font_family_item =
Gtk::manage(new UI::Widget::ComboBoxEntryToolItem( "TextFontFamilyAction",
_("Font Family"),
_("Select Font Family (Alt-X to access)"),
GTK_TREE_MODEL(model),
......@@ -288,21 +287,21 @@ TextToolbar::TextToolbar(SPDesktop *desktop)
50, // Extra list width
(gpointer)font_lister_cell_data_func2, // Cell layout
(gpointer)font_lister_separator_func2,
GTK_WIDGET(desktop->canvas)); // Focus widget
ink_comboboxentry_action_popup_enable( toolbar->_font_family_action ); // Enable entry completion
GTK_WIDGET(desktop->canvas))); // Focus widget
_font_family_item->popup_enable(); // Enable entry completion
gchar *const info = _("Select all text with this font-family");
ink_comboboxentry_action_set_info( toolbar->_font_family_action, info ); // Show selection icon
ink_comboboxentry_action_set_info_cb( toolbar->_font_family_action, (gpointer)sp_text_toolbox_select_cb );
_font_family_item->set_info( info ); // Show selection icon
_font_family_item->set_info_cb( (gpointer)sp_text_toolbox_select_cb );
gchar *const warning = _("Font not found on system");
ink_comboboxentry_action_set_warning( toolbar->_font_family_action, warning ); // Show icon w/ tooltip if font missing
ink_comboboxentry_action_set_warning_cb( toolbar->_font_family_action, (gpointer)sp_text_toolbox_select_cb );
_font_family_item->set_warning( warning ); // Show icon w/ tooltip if font missing
_font_family_item->set_warning_cb( (gpointer)sp_text_toolbox_select_cb );
//ink_comboboxentry_action_set_warning_callback( act, sp_text_fontfamily_select_all );
ink_comboboxentry_action_set_altx_name( toolbar->_font_family_action, "altx-text" ); // Set Alt-X keyboard shortcut
g_signal_connect( G_OBJECT(toolbar->_font_family_action), "changed", G_CALLBACK(fontfamily_value_changed), (gpointer)toolbar );
gtk_action_group_add_action( mainActions, GTK_ACTION(toolbar->_font_family_action) );
_font_family_item->set_altx_name( "altx-text" ); // Set Alt-X keyboard shortcut
_font_family_item->signal_changed().connect( sigc::mem_fun(*this, &TextToolbar::fontfamily_value_changed) );
add(*_font_family_item);
// Change style of drop-down from menu to list
auto css_provider = gtk_css_provider_new();
......@@ -317,7 +316,6 @@ TextToolbar::TextToolbar(SPDesktop *desktop)
GTK_STYLE_PROVIDER(css_provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
}
#endif
/* Font styles */
{
......@@ -339,7 +337,6 @@ TextToolbar::TextToolbar(SPDesktop *desktop)
add(*_font_style_item);
}
add_separator();
/* Text outer style */
......@@ -748,10 +745,8 @@ TextToolbar::TextToolbar(SPDesktop *desktop)
}
void
TextToolbar::fontfamily_value_changed( UI::Widget::ComboBoxEntryToolItem *act, gpointer data )
TextToolbar::fontfamily_value_changed()
{
auto toolbar = reinterpret_cast<TextToolbar *>(data);
#ifdef DEBUG_TEXT
std::cout << std::endl;
std::cout << "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM" << std::endl;
......@@ -759,16 +754,16 @@ TextToolbar::fontfamily_value_changed( UI::Widget::ComboBoxEntryToolItem *act, g
#endif
// quit if run by the _changed callbacks
if (toolbar->_freeze) {
if (_freeze) {
#ifdef DEBUG_TEXT
std::cout << "sp_text_fontfamily_value_changed: frozen... return" << std::endl;
std::cout << "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n" << std::endl;
#endif
return;
}
toolbar->_freeze = true;
_freeze = true;
Glib::ustring new_family = act->get_active_text();
Glib::ustring new_family = _font_family_item->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
......@@ -784,16 +779,16 @@ TextToolbar::fontfamily_value_changed( UI::Widget::ComboBoxEntryToolItem *act, g
if( new_family.compare( fontlister->get_font_family() ) != 0 ) {
// Changed font-family
if( act->get_active() == -1 ) {
if( _font_family_item->get_active() == -1 ) {
// New font-family, not in document, not on system (could be fallback list)
fontlister->insert_font_family( new_family );
// 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.
_font_family_item->set_active(0); // New family is always at top of list.
}
fontlister->set_font_family( act->get_active() );
fontlister->set_font_family( _font_family_item->get_active() );
// active text set in sp_text_toolbox_selection_changed()
SPCSSAttr *css = sp_repr_css_attr_new ();
......@@ -814,7 +809,7 @@ TextToolbar::fontfamily_value_changed( UI::Widget::ComboBoxEntryToolItem *act, g
}
// unfreeze
toolbar->_freeze = false;
_freeze = false;
#ifdef DEBUG_TEXT
std::cout << "sp_text_toolbox_fontfamily_changes: exit" << std::endl;
......@@ -2009,12 +2004,10 @@ TextToolbar::selection_changed(Inkscape::Selection * /*selection*/, bool subsele
fontlister->selection_update();
// Update font list, but only if widget already created.
#ifdef FINISHEDHACKING
if( _font_family_action->get_combobox() != nullptr ) {
_font_family_action->set_active_text( fontlister->get_font_family().c_str(), fontlister->get_font_family_row() );
if( _font_family_item->get_combobox() != nullptr ) {
_font_family_item->set_active_text( fontlister->get_font_family().c_str(), fontlister->get_font_family_row() );
_font_style_item->set_active_text( fontlister->get_font_style().c_str() );
}
#endif
// Only flowed text can be justified, only normal text can be kerned...
// Find out if we have flowed text now so we can use it several places
......@@ -2086,13 +2079,11 @@ TextToolbar::selection_changed(Inkscape::Selection * /*selection*/, bool subsele
return;
}
#ifdef FINISHEDHACKING
// 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->get_combobox() != nullptr ) {
if( _font_family_item->get_combobox() != nullptr ) {
_text_style_from_prefs = true;
}
#endif
} else {
_text_style_from_prefs = false;
}
......
......@@ -62,7 +62,7 @@ private:
UI::Widget::UnitTracker *_tracker;
UI::Widget::ComboBoxEntryToolItem *_font_family_action;
UI::Widget::ComboBoxEntryToolItem *_font_family_item;
UI::Widget::ComboBoxEntryToolItem *_font_size_item;
UI::Widget::ComboBoxEntryToolItem *_font_style_item;
Gtk::ToggleToolButton *_superscript_item;
......@@ -96,8 +96,7 @@ private:
sigc::connection c_selection_modified;
sigc::connection c_subselection_changed;
static void fontfamily_value_changed(UI::Widget::ComboBoxEntryToolItem *act,
gpointer data);
void fontfamily_value_changed();
void fontsize_value_changed();
void fontstyle_value_changed();
void script_changed(Gtk::ToggleToolButton *btn);
......
......@@ -24,6 +24,8 @@
* we must keep track of things like active entry ourselves.
*/
#include "combo-box-entry-tool-item.h"
#include <iostream>
#include <cstring>
#include <glibmm/ustring.h>
......@@ -32,7 +34,6 @@
#include <gdk/gdkkeysyms.h>
#include <gdkmm/display.h>
#include "widgets/ink-comboboxentry-action.h"
#include "ui/icon-names.h"
static GQuark gDataName = 0;
......
......@@ -9,7 +9,6 @@ set(widgets_SRC
gradient-selector.cpp
gradient-vector.cpp
ink-action.cpp
ink-comboboxentry-action.cpp
ink-toggle-action.cpp
paint-selector.cpp
sp-attribute-widget.cpp
......@@ -32,7 +31,6 @@ set(widgets_SRC
gradient-selector.h
gradient-vector.h
ink-action.h
ink-comboboxentry-action.h
ink-toggle-action.h
paint-selector.h
sp-attribute-widget.h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment