Commit 346e7643 authored by Alex Valavanis's avatar Alex Valavanis

Merge branch 'text-toolbar-migration'

parents 2e40143d eed14fb8
<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>
......@@ -1524,10 +1524,10 @@ SPDesktop::setToolboxAdjustmentValue (gchar const* id, double val)
_widget->setToolboxAdjustmentValue (id, val);
}
void
SPDesktop::setToolboxSelectOneValue (gchar const* id, gint val)
Gtk::Toolbar*
SPDesktop::get_toolbar_by_name(const Glib::ustring& name)
{
_widget->setToolboxSelectOneValue (id, val);
return _widget->get_toolbar_by_name(name);
}
bool
......
......@@ -65,7 +65,8 @@ class InkscapeWindow;
namespace Gtk
{
class Window;
class Toolbar;
class Window;
}
typedef int sp_verb_t;
......@@ -388,8 +389,8 @@ public:
void layoutWidget();
void destroyWidget();
void setToolboxFocusTo (gchar const* label);
Gtk::Toolbar* get_toolbar_by_name(const Glib::ustring& name);
void setToolboxAdjustmentValue (gchar const* id, double val);
void setToolboxSelectOneValue (gchar const* id, gint val);
bool isToolboxButtonActive (gchar const *id);
void updateNow();
void updateCanvasNow();
......
......@@ -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
......@@ -179,7 +180,6 @@ set(ui_SRC
widget/imagetoggler.cpp
widget/ink-color-wheel.cpp
widget/ink-flow-box.cpp
widget/ink-select-one-action.cpp
widget/ink-spinscale.cpp
widget/insertordericon.cpp
widget/label-tool-item.cpp
......@@ -396,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
......@@ -414,7 +415,6 @@ set(ui_SRC
widget/imagetoggler.h
widget/ink-color-wheel.h
widget/ink-flow-box.h
widget/ink-select-one-action.h
widget/ink-spinscale.h
widget/label-tool-item.h
widget/labelled.h
......
......@@ -32,7 +32,6 @@
#include <gtkmm/adjustment.h>
class InkSelectOneAction;
class SPDesktop;
class SPItem;
......
......@@ -37,10 +37,6 @@
class Persp3D;
class SPDesktop;
typedef struct _EgeAdjustmentAction EgeAdjustmentAction;
typedef struct _GtkActionGroup GtkActionGroup;
typedef struct _InkToggleAction InkToggleAction;
namespace Inkscape {
class Selection;
......
......@@ -173,6 +173,12 @@ LPEToolbar::LPEToolbar(SPDesktop *desktop)
show_all();
}
void
LPEToolbar::set_mode(int mode)
{
_mode_buttons[mode]->set_active();
}
GtkWidget *
LPEToolbar::create(SPDesktop *desktop)
{
......
......@@ -92,6 +92,7 @@ protected:
public:
static GtkWidget * create(SPDesktop *desktop);
void set_mode(int mode);
};
}
......
......@@ -36,10 +36,6 @@ class SPDesktop;
class SPItem;
class SPRect;
typedef struct _EgeAdjustmentAction EgeAdjustmentAction;
typedef struct _EgeOutputAction EgeOutputAction;
typedef struct _InkAction InkAction;
namespace Gtk {
class Toolbutton;
}
......
......@@ -37,7 +37,6 @@
#include "ui/icon-names.h"
#include "ui/widget/combo-tool-item.h"
#include "ui/widget/ink-select-one-action.h"
#include "ui/widget/spin-button-tool-item.h"
#include "ui/widget/unit-tracker.h"
......
......@@ -528,6 +528,12 @@ SprayToolbar::on_pref_toggled(Gtk::ToggleToolButton *btn,
prefs->setBool(path, active);
}
void
SprayToolbar::set_mode(int mode)
{
_mode_buttons[mode]->set_active();
}
}
}
}
......
......@@ -97,6 +97,8 @@ protected:
public:
static GtkWidget * create(SPDesktop *desktop);
void set_mode(int mode);
};
}
}
......
This diff is collapsed.
......@@ -32,13 +32,12 @@
#include <gtkmm/adjustment.h>
class InkSelectOneAction;
class SPDesktop;
typedef struct _EgeAdjustmentAction EgeAdjustmentAction;
typedef struct _GtkActionGroup GtkActionGroup;
typedef struct _Ink_ComboBoxEntry_Action Ink_ComboBoxEntry_Action;
typedef struct _InkToggleAction InkToggleAction;
namespace Gtk {
class ComboBoxText;
class ToggleToolButton;
}
namespace Inkscape {
class Selection;
......@@ -49,6 +48,9 @@ class ToolBase;
}
namespace Widget {
class ComboBoxEntryToolItem;
class ComboToolItem;
class SpinButtonToolItem;
class UnitTracker;
}
......@@ -60,26 +62,26 @@ private:
UI::Widget::UnitTracker *_tracker;
Ink_ComboBoxEntry_Action *_font_family_action;
Ink_ComboBoxEntry_Action *_font_size_action;
Ink_ComboBoxEntry_Action *_font_style_action;
InkToggleAction *_superscript_action;
InkToggleAction *_subscript_action;
InkToggleAction *_outer_style_action;
InkToggleAction *_line_height_unset_action;
InkSelectOneAction *_align_action;
InkSelectOneAction *_writing_mode_action;
InkSelectOneAction *_orientation_action;
InkSelectOneAction *_direction_action;
InkSelectOneAction *_line_height_units_action;
InkSelectOneAction *_line_spacing_action;
EgeAdjustmentAction *_line_height_action;
EgeAdjustmentAction *_word_spacing_action;
EgeAdjustmentAction *_letter_spacing_action;
EgeAdjustmentAction *_dx_action;
EgeAdjustmentAction *_dy_action;
EgeAdjustmentAction *_rotation_action;
UI::Widget::ComboBoxEntryToolItem *_font_family_item;
UI::Widget::ComboBoxEntryToolItem *_font_size_item;
UI::Widget::ComboBoxEntryToolItem *_font_style_item;
Gtk::ToggleToolButton *_superscript_item;
Gtk::ToggleToolButton *_subscript_item;
Gtk::ToggleToolButton *_outer_style_item;
Gtk::ToggleToolButton *_line_height_unset_item;
UI::Widget::ComboToolItem *_align_item;
UI::Widget::ComboToolItem *_writing_mode_item;
UI::Widget::ComboToolItem *_orientation_item;
UI::Widget::ComboToolItem *_direction_item;
UI::Widget::ComboToolItem *_line_height_units_item;
UI::Widget::ComboToolItem *_line_spacing_item;
UI::Widget::SpinButtonToolItem *_line_height_item;
UI::Widget::SpinButtonToolItem *_word_spacing_item;
UI::Widget::SpinButtonToolItem *_letter_spacing_item;
UI::Widget::SpinButtonToolItem *_dx_item;
UI::Widget::SpinButtonToolItem *_dy_item;
UI::Widget::SpinButtonToolItem *_rotation_item;
Glib::RefPtr<Gtk::Adjustment> _line_height_adj;
Glib::RefPtr<Gtk::Adjustment> _word_spacing_adj;
......@@ -94,19 +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,
gpointer data);
static void fontstyle_value_changed (Ink_ComboBoxEntry_Action *act,
gpointer data);
static void script_changed (InkToggleAction *act,
gpointer data);
static void lineheight_unset_changed(InkToggleAction *act,
gpointer data);
static void outer_style_changed (InkToggleAction *act,
gpointer data);
void fontfamily_value_changed();
void fontsize_value_changed();
void fontstyle_value_changed();
void script_changed(Gtk::ToggleToolButton *btn);
void lineheight_unset_changed();
void outer_style_changed();
void align_mode_changed(int mode);
void writing_mode_changed(int mode);
void orientation_changed(int mode);
......@@ -124,12 +119,13 @@ 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);
public:
static GtkWidget * prep(SPDesktop *desktop, GtkActionGroup* mainActions);
static GtkWidget * create(SPDesktop *desktop);
};
}
......
......@@ -243,6 +243,12 @@ TweakToolbar::TweakToolbar(SPDesktop *desktop)
}
}
void
TweakToolbar::set_mode(int mode)
{
_mode_buttons[mode]->set_active();
}
GtkWidget *
TweakToolbar::create(SPDesktop *desktop)
{
......
......@@ -79,6 +79,8 @@ protected:
public:
static GtkWidget * create(SPDesktop *desktop);
void set_mode(int mode);
};
}
}
......
......@@ -36,6 +36,7 @@
#include "util/units.h"
#include "ui/toolbar/lpe-toolbar.h"
#include "ui/tools/lpe-tool.h"
#include "ui/shape-editor.h"
......@@ -309,7 +310,13 @@ lpetool_context_switch_mode(LpeTool *lc, Inkscape::LivePathEffect::EffectType co
int index = lpetool_mode_to_index(type);
if (index != -1) {
lc->mode = type;
lc->desktop->setToolboxSelectOneValue ("lpetool_mode_action", index);
auto tb = dynamic_cast<UI::Toolbar::LPEToolbar*>(lc->desktop->get_toolbar_by_name("LPEToolToolbar"));
if(tb) {
tb->set_mode(index);
} else {
std::cerr << "Could not access LPE toolbar" << std::endl;
}
} else {
g_warning ("Invalid mode selected: %d", type);
return;
......
......@@ -62,6 +62,7 @@
#include "svg/svg.h"
#include "svg/svg-color.h"
#include "ui/toolbar/spray-toolbar.h"
#include "ui/tools/spray-tool.h"
#include "ui/dialog/dialog-manager.h"
......@@ -1210,7 +1211,14 @@ static void sp_spray_update_area(SprayTool *tc)
static void sp_spray_switch_mode(SprayTool *tc, gint mode, bool with_shift)
{
// Select the button mode
SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue("spray_tool_mode", mode);
auto tb = dynamic_cast<UI::Toolbar::SprayToolbar*>(SP_EVENT_CONTEXT(tc)->desktop->get_toolbar_by_name("SprayToolbar"));
if(tb) {
tb->set_mode(mode);
} else {
std::cerr << "Could not access Spray toolbar" << std::endl;
}
// Need to set explicitly, because the prefs may not have changed by the previous
tc->mode = mode;
tc->update_cursor(with_shift);
......
......@@ -74,6 +74,8 @@
#include "svg/svg.h"
#include "ui/toolbar/tweak-toolbar.h"
#include "ui/tools/tweak-tool.h"
using Inkscape::DocumentUndo;
......@@ -1121,7 +1123,14 @@ sp_tweak_update_area (TweakTool *tc)
static void
sp_tweak_switch_mode (TweakTool *tc, gint mode, bool with_shift)
{
SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("tweak_tool_mode", mode);
auto tb = dynamic_cast<UI::Toolbar::TweakToolbar*>(SP_EVENT_CONTEXT(tc)->desktop->get_toolbar_by_name("TweakToolbar"));
if(tb) {
tb->set_mode(mode);
} else {
std::cerr << "Could not access Tweak toolbar" << std::endl;
}
// need to set explicitly, because the prefs may not have changed by the previous
tc->mode = mode;
tc->update_cursor(with_shift);
......@@ -1133,7 +1142,15 @@ sp_tweak_switch_mode_temporarily (TweakTool *tc, gint mode, bool with_shift)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// Juggling about so that prefs have the old value but tc->mode and the button show new mode:
gint now_mode = prefs->getInt("/tools/tweak/mode", 0);
SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("tweak_tool_mode", mode);
auto tb = dynamic_cast<UI::Toolbar::TweakToolbar*>(SP_EVENT_CONTEXT(tc)->desktop->get_toolbar_by_name("TweakToolbar"));
if(tb) {
tb->set_mode(mode);
} else {
std::cerr << "Could not access Tweak toolbar" << std::endl;
}
// button has changed prefs, restore
prefs->setInt("/tools/tweak/mode", now_mode);
// changing prefs changed tc->mode, restore back :)
......
......@@ -17,7 +17,8 @@
#include <2geom/point.h>
namespace Gtk {
class Window;
class Toolbar;
class Window;
}
namespace Glib {
......@@ -132,15 +133,14 @@ struct EditWidgetInterface
/// Temporarily block signals and update rotation display
virtual void updateRotation() = 0;
virtual Gtk::Toolbar* get_toolbar_by_name(const Glib::ustring&) = 0;
/// In auxiliary toolbox, set focus to widget having specific id
virtual void setToolboxFocusTo (const gchar *) = 0;
/// In auxiliary toolbox, set value of adjustment with specific id
virtual void setToolboxAdjustmentValue (const gchar *, double) = 0;
/// In auxiliary toolbox, select one of the "select one" options (usually radio toggles)
virtual void setToolboxSelectOneValue (const gchar *, gint) = 0;
/// In auxiliary toolbox, return true if specific togglebutton is active
virtual bool isToolboxButtonActive (gchar const*) = 0;
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* A subclass of GtkAction that wraps a GtkComboBoxEntry.
* Features:
* Setting GtkEntryBox width in characters.
* Passing a function for formatting cells.
* Displaying a warning if text isn't in list.
* Setting names for GtkComboBoxEntry and GtkEntry (actionName_combobox, actionName_entry)
* to allow setting resources.
*
* Author(s):
* Tavmjong Bah
* Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2010 Authors
*
* Released under GNU GPL v2+, read the file 'COPYING' for more information.
*/
#ifndef SEEN_INK_COMBOBOXENTRY_ACTION
#define SEEN_INK_COMBOBOXENTRY_ACTION
#include <gtkmm/toolitem.h>
namespace Inkscape {
namespace UI {
namespace Widget {
/**
* Creates a Gtk::ToolItem subclass that wraps a Gtk::ComboBox object.
*/
class ComboBoxEntryToolItem : public Gtk::ToolItem {
private:
Glib::ustring _tooltip;
Glib::ustring _label;
GtkTreeModel *_model; ///< Tree Model
GtkComboBox *_combobox;
GtkEntry *_entry;
gint _entry_width;// Width of GtkEntry in characters.
gint _extra_width;// Extra Width of GtkComboBox.. to widen drop-down list in list mode.
gpointer _cell_data_func; // drop-down menu format
gpointer _separator_func;
gboolean _popup; // Do we pop-up an entry-completion dialog?
GtkEntryCompletion *_entry_completion;
GtkWidget *_focusWidget; ///< The widget to return focus to
GtkWidget *_indicator;
gint _active; // Index of active menu item (-1 if not in list).
gchar *_text; // Text of active menu item or entry box.
gchar *_info; // Text for tooltip info about entry.
gpointer _info_cb; // Callback for clicking info icon.
gint _info_cb_id;
gboolean _info_cb_blocked;
gchar *_warning; // Text for tooltip warning that entry isn't in list.
gpointer _warning_cb; // Callback for clicking warning icon.
gint _warning_cb_id;
gboolean _warning_cb_blocked;
gchar *_altx_name; // Target for Alt-X keyboard shortcut.
// Signals
sigc::signal<void> _signal_changed;
void (*changed) (ComboBoxEntryToolItem* action);
void (*activated) (ComboBoxEntryToolItem* action);
static gint get_active_row_from_text(ComboBoxEntryToolItem *action,
const gchar *target_text,
gboolean exclude = false,
gboolean ignore_case = false);
void defocus();
static void combo_box_changed_cb( GtkComboBox* widget, gpointer data );
static void entry_activate_cb( GtkEntry *widget,
gpointer data );
static gboolean match_selected_cb( GtkEntryCompletion *widget,
GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data);
static gboolean keypress_cb( GtkWidget *widget,
GdkEventKey *event,
gpointer data );
Glib::ustring check_comma_separated_text();
public:
ComboBoxEntryToolItem(const Glib::ustring name,
const Glib::ustring label,
const Glib::ustring tooltip,
GtkTreeModel *model,
gint entry_width = -1,
gint extra_width = -1,
gpointer cell_data_func = nullptr,
gpointer separator_func = nullptr,
GtkWidget* focusWidget = nullptr);
gchar* get_active_text();
gboolean set_active_text(const gchar* text, int row=-1);
void set_entry_width(gint entry_width);
void set_extra_width(gint extra_width);
void popup_enable();
void popup_disable();
void set_info( const gchar* info );
void set_info_cb( gpointer info_cb );
void set_warning( const gchar* warning_cb );
void set_warning_cb(gpointer warning );
void set_tooltip( const gchar* tooltip );
void set_altx_name( const gchar* altx_name );
// Accessor methods
decltype(_model) get_model() const {return _model;}
decltype(_combobox) get_combobox() const {return _combobox;}
decltype(_entry) get_entry() const {return _entry;}
decltype(_entry_width) get_entry_width() const {return _entry_width;}
decltype(_extra_width) get_extra_width() const {return _extra_width;}
decltype(_cell_data_func) get_cell_data_func() const {return _cell_data_func;}
decltype(_separator_func) get_separator_func() const {return _separator_func;}
decltype(_popup) get_popup() const {return _popup;}
decltype(_focusWidget) get_focus_widget() const {return _focusWidget;}
decltype(_active) get_active() const {return _active;}
decltype(_signal_changed) signal_changed() {return _signal_changed;}
// Mutator methods
void set_model (decltype(_model) model) {_model = model;}
void set_combobox (decltype(_combobox) combobox) {_combobox = combobox;}
void set_entry (decltype(_entry) entry) {_entry = entry;}
void set_cell_data_func(decltype(_cell_data_func) cell_data_func) {_cell_data_func = cell_data_func;}
void set_separator_func(decltype(_separator_func) separator_func) {_separator_func = separator_func;}
void set_popup (decltype(_popup) popup) {_popup = popup;}
void set_focus_widget (decltype(_focusWidget) focus_widget) {_focusWidget = focus_widget;}
// This doesn't seem right... surely we should set the active row in the Combobox too?
void set_active (decltype(_active) active) {_active = active;}
};
}
}
}
#endif /* SEEN_INK_COMBOBOXENTRY_ACTION */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
......@@ -34,15 +34,17 @@ ComboToolItem*
ComboToolItem::create(const Glib::ustring &group_label,
const Glib::ustring &tooltip,
const Glib::ustring &stock_id,
Glib::RefPtr<Gtk::ListStore> store )
Glib::RefPtr<Gtk::ListStore> store,
bool has_entry)
{
return new ComboToolItem(group_label, tooltip, stock_id, store);
return new ComboToolItem(group_label, tooltip, stock_id, store, has_entry);
}
ComboToolItem::ComboToolItem(Glib::ustring group_label,
Glib::ustring tooltip,
Glib::ustring stock_id,
Glib::RefPtr<Gtk::ListStore> store ) :
Glib::RefPtr<Gtk::ListStore> store,
bool has_entry) :
_group_label(std::move( group_label )),
_tooltip(std::move( tooltip )),
_stock_id(std::move( stock_id )),
......@@ -63,9 +65,45 @@ ComboToolItem::ComboToolItem(Glib::ustring group_label,
}
// Create combobox
_combobox = Gtk::manage (new Gtk::ComboBox());
_combobox = Gtk::manage (new Gtk::ComboBox(has_entry));
_combobox->set_model(_store);
populate_combobox();
_combobox->signal_changed().connect(
sigc::mem_fun(*this, &ComboToolItem::on_changed_combobox));
box->add (*_combobox);
show_all();
}
void
ComboToolItem::use_label(bool use_label)
{
_use_label = use_label;
populate_combobox();
}
void
ComboToolItem::use_icon(bool use_icon)
{
_use_icon = use_icon;
populate_combobox();
}
void
ComboToolItem::use_pixbuf(bool use_pixbuf)
{
_use_pixbuf = use_pixbuf;
populate_combobox();
}
void
ComboToolItem::populate_combobox()
{
_combobox->clear();
ComboToolItemColumns columns;
if (_use_icon) {
Gtk::CellRendererPixbuf *renderer = new Gtk::CellRendererPixbuf;
......@@ -89,13 +127,6 @@ ComboToolItem::ComboToolItem(Glib::ustring group_label,
}
_combobox->set_active (_active);
_combobox->signal_changed().connect(
sigc::mem_fun(*this, &ComboToolItem::on_changed_combobox));
box->add (*_combobox);
show_all();
}
void
......
<
......@@ -54,12 +54,13 @@ public:
static ComboToolItem* create(const Glib::ustring &label,
const Glib::ustring &tooltip,
const Glib::ustring &stock_id,
Glib::RefPtr<Gtk::ListStore> store );
Glib::RefPtr<Gtk::ListStore> store,
bool has_entry = false);
/* Style of action */
void use_label( bool use_label ) { _use_label = use_label; }
void use_icon( bool use_icon ) { _use_icon = use_icon; }
void use_pixbuf( bool use_pixbuf ) { _use_pixbuf = use_pixbuf; }
/* Style of combobox */
void use_label( bool use_label );
void use_icon( bool use_icon );
void use_pixbuf( bool use_pixbuf );
void use_group_label( bool use_group_label ) { _use_group_label = use_group_label; }
gint get_active() { return _active; }
......@@ -74,6 +75,7 @@ public:
protected:
bool on_create_menu_proxy() override;
void populate_combobox();
/* Signals */
sigc::signal<void, int> _changed;
......@@ -108,7 +110,8 @@ private:
ComboToolItem(Glib::ustring group_label,
Glib::ustring tooltip,
Glib::ustring stock_id,
Glib::RefPtr<Gtk::ListStore> store );
Glib::RefPtr<Gtk::ListStore> store,
bool has_entry = false);
};