From 78cebbf91af8d91681d4ff18b7c1a8b25f2c431a Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 21 Jul 2017 03:05:09 -0400 Subject: Use menus.xml for menus, load a basic File>Quit menu as backup. --- src/inkscape.cpp | 15 +-- src/menus-skeleton.h | 300 --------------------------------------------------- 2 files changed, 3 insertions(+), 312 deletions(-) (limited to 'src') diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 24a744bbd..8dfff3c63 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -746,24 +746,15 @@ Application::crash_handler (int /*signum*/) */ bool Application::load_menus() { - gchar *fn = Inkscape::IO::Resource::profile_path(MENUS_FILE); + using namespace Inkscape::IO::Resource; + Glib::ustring filename = get_filename(UIS, MENUS_FILE); gchar *menus_xml = 0; gsize len = 0; - if ( g_file_get_contents(fn, &menus_xml, &len, NULL) ) { - // load the menus_xml file - _menus = sp_repr_read_mem(menus_xml, len, NULL); - - g_free(menus_xml); - menus_xml = 0; - } - g_free(fn); - fn = 0; - + _menus = sp_repr_read_file(filename.c_str(), NULL); if ( !_menus ) { _menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL); } - return (_menus != 0); } diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index ca337e6a7..4cafe85ac 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -16,308 +16,8 @@ static char const menus_skeleton[] = " xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\">\n" "\n" " \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -//" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -//" \n" -" \n" -" \n" " \n" " \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -// Better location in menu needs to be found -//" \n" -//" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -// Better location in menu needs to be found -//" \n" -//" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -// Not quite ready to be in the menus. -// " \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" - -#if HAVE_POTRACE -" \n" -#endif - -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -#ifdef HAVE_ASPELL -" \n" -" \n" -#endif -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -#if HAVE_POTRACE -" \n" -#endif -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -//" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -//" \n" -" \n" "\n"; #define MENUS_SKELETON_SIZE (sizeof(menus_skeleton) - 1) -- cgit v1.2.3 From 20b9bb08c9cf6c5023df3fb52c6bb65885057f22 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 24 Jul 2017 17:52:10 +0200 Subject: Add C++ based Gtk::Action for choosing one item out of many. Options: Show icons and/or labels. Use combbox or radio buttons. Replacement for C based ege-select-one-action. Update text toolbar to use this class, allowing bar to be narrower. --- src/ui/CMakeLists.txt | 2 + src/ui/widget/ink-select-one-action.cpp | 239 +++++++++++++++++++ src/ui/widget/ink-select-one-action.h | 131 +++++++++++ src/widgets/text-toolbar.cpp | 399 ++++++++++++++------------------ 4 files changed, 540 insertions(+), 231 deletions(-) create mode 100644 src/ui/widget/ink-select-one-action.cpp create mode 100644 src/ui/widget/ink-select-one-action.h (limited to 'src') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 789378e0c..efdb279b4 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -147,6 +147,7 @@ set(ui_SRC widget/licensor.cpp widget/notebook-page.cpp widget/object-composite-settings.cpp + widget/ink-select-one-action.cpp widget/page-sizer.cpp widget/panel.cpp widget/point.cpp @@ -339,6 +340,7 @@ set(ui_SRC widget/licensor.h widget/notebook-page.h widget/object-composite-settings.h + widget/ink-select-one-action.h widget/page-sizer.h widget/panel.h widget/point.h diff --git a/src/ui/widget/ink-select-one-action.cpp b/src/ui/widget/ink-select-one-action.cpp new file mode 100644 index 000000000..40bafecc2 --- /dev/null +++ b/src/ui/widget/ink-select-one-action.cpp @@ -0,0 +1,239 @@ +/* + * Authors: + * Tavmjong Bah + * + * Copyright (C) 2017 Tavmjong Bah + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + + +/** \file + An action (menu/toolbar item) that allows selecting one choice out of many. + + The choices may be displayed as: + + 1. A group of items in a toolbar with labels and/or icons. + 2. As a drop-down menu with a labels and/or icons. +*/ + +#include "ink-select-one-action.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +InkSelectOneAction* InkSelectOneAction::create(const Glib::ustring &name, + const Glib::ustring &label, + const Glib::ustring &tooltip, + const Glib::ustring &stock_id, + Glib::RefPtr store ) { + + return new InkSelectOneAction(name, label, tooltip, stock_id, store); +} + +InkSelectOneAction::InkSelectOneAction (const Glib::ustring &name, + const Glib::ustring &label, + const Glib::ustring &tooltip, + const Glib::ustring &stock_id, + Glib::RefPtr store ) : + Gtk::Action(name, stock_id, label, tooltip), + _name( name ), + _label( label ), + _tooltip( tooltip ), + _stock_id( stock_id ), + _store (store), + _use_radio (true), + _use_label (true), + _use_icon (true), + _icon_size ( Gtk::ICON_SIZE_LARGE_TOOLBAR ), + _combobox (nullptr), + _radioaction (nullptr), + _menuitem (nullptr) +{ +} + +void InkSelectOneAction::set_active (gint active) { + + if (_active != active) { + + _active = active; + + if (_combobox) { + _combobox->set_active (active); + } + + if (_radioaction) { + _radioaction->set_current_value (active); + } + + if (active < _radiomenuitems.size()) { + _radiomenuitems[ active ]->set_active(); + } + } +} + +Gtk::Widget* InkSelectOneAction::create_menu_item_vfunc() { + + if (_menuitem == nullptr) { + + _menuitem = Gtk::manage (new Gtk::MenuItem); + Gtk::Menu *menu = Gtk::manage (new Gtk::Menu); + + Gtk::RadioButton::Group group; + int index = 0; + auto children = _store->children(); + for (auto iter = children.begin(); iter != children.end(); ++iter) { + Gtk::TreeModel::Row row = *iter; + + InkSelectOneActionColumns columns; + Glib::ustring label = row[columns.col_label ]; + Glib::ustring icon = row[columns.col_icon ]; + Glib::ustring tooltip = row[columns.col_tooltip ]; + bool sensitive = row[columns.col_sensitive ]; + + Gtk::RadioMenuItem* button = Gtk::manage(new Gtk::RadioMenuItem(group)); + button->set_label (label); + button->set_tooltip_text( tooltip ); + button->set_sensitive( sensitive ); + + button->signal_toggled().connect( sigc::bind<0>( + sigc::mem_fun(*this, &InkSelectOneAction::on_toggled_radiomenu), index++) + ); + + menu->add (*button); + + _radiomenuitems.push_back( button ); + } + + if ( _active < _radiomenuitems.size()) { + _radiomenuitems[ _active ]->set_active(); + } + + _menuitem->set_submenu (*menu); + _menuitem->show_all(); + } + + return _menuitem; +} + + +Gtk::Widget* InkSelectOneAction::create_tool_item_vfunc() { + // Either a group of radio actions or a combobox with labels and/or icons. + + Gtk::ToolItem *tool_item = new Gtk::ToolItem; + + if (_use_radio) { + // Create radio actions (note: these are not radio buttons). + + Gtk::Box* box = Gtk::manage(new Gtk::Box()); + tool_item->add (*box); + + Gtk::RadioAction::Group group; + int index = 0; + auto children = _store->children(); + for (auto iter = children.begin(); iter != children.end(); ++iter) { + Gtk::TreeModel::Row row = *iter; + + InkSelectOneActionColumns columns; + Glib::ustring label = row[columns.col_label ]; + Glib::ustring icon = row[columns.col_icon ]; + Glib::ustring tooltip = row[columns.col_tooltip ]; + bool sensitive = row[columns.col_sensitive]; + Glib::RefPtr action; + if (_use_icon) { + action = + Gtk::RadioAction::create_with_icon_name (group, "Anonymous", icon, label, tooltip); + } else { + action = + Gtk::RadioAction::create (group, "Anonymous", label, tooltip); + } + action->set_property( "value", index++ ); // To identify uniquely each radioaction. + action->set_sensitive( sensitive ); + + // Save first action for use in setting/getting active value. + if (!_radioaction) { + _radioaction = action; + } + + Gtk::ToolItem* item = action->create_tool_item(); + box->add (*item); + } + + _radioaction->signal_changed().connect( sigc::mem_fun(*this, &InkSelectOneAction::on_changed_radioaction)); + + } else { + // Create combobox + + _combobox = Gtk::manage (new Gtk::ComboBox()); + _combobox->set_model(_store); + + InkSelectOneActionColumns columns; + if (_use_icon ) { + Gtk::CellRendererPixbuf *renderer = new Gtk::CellRendererPixbuf; + renderer->set_property ("stock_size", Gtk::ICON_SIZE_LARGE_TOOLBAR); + _combobox->pack_start (*renderer, false); + _combobox->add_attribute (*renderer, "icon_name", columns.col_icon ); + } + + if (_use_label) { + _combobox->pack_start(columns.col_label); + } + + std::vector cells = _combobox->get_cells(); + for (auto iter = cells.begin(); iter!= cells.end(); ++iter) { + _combobox->add_attribute (**iter, "sensitive", columns.col_sensitive); + } + + _combobox->set_active (_active); + + _combobox->signal_changed().connect( + sigc::mem_fun(*this, &InkSelectOneAction::on_changed_combobox)); + + tool_item->add (*_combobox); + } + + tool_item->show_all(); + + return tool_item; +} + +void InkSelectOneAction::on_changed_combobox() { + + set_active( _combobox->get_active_row_number() ); + _changed.emit (_active); +} + +void InkSelectOneAction::on_changed_radioaction(const Glib::RefPtr& current) { + + set_active( current->get_current_value() ); + _changed.emit (_active); +} + +void InkSelectOneAction::on_toggled_radiomenu(int n) { + + // toggled emitted twice, first for button toggled off, second for button toggled on. + // We want to react only to the button turned on. + if ( n < _radiomenuitems.size() &&_radiomenuitems[ n ]->get_active()) { + set_active ( n ); + _changed.emit (_active); + } +} + +/* + 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 : diff --git a/src/ui/widget/ink-select-one-action.h b/src/ui/widget/ink-select-one-action.h new file mode 100644 index 000000000..194ca8027 --- /dev/null +++ b/src/ui/widget/ink-select-one-action.h @@ -0,0 +1,131 @@ +#ifndef SEEN_INK_SELECT_ONE_ACTION +#define SEEN_INK_SELECT_ONE_ACTION + +/* + * Authors: + * Tavmjong Bah + * + * Copyright (C) 2017 Tavmjong Bah + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +/** + An action (menu/toolbar item) that allows selecting one choice out of many. + + The choices may be displayed as: + + 1. A group of items in a toolbar with labels and/or icons. + 2. As a drop-down menu with a labels and/or icons. +*/ + +#include +#include +#include +#include + +namespace Gtk { +class ComboBox; +class RadioAction; +class MenuItem; +class RadioMenuItem; +} + +class InkSelectOneActionColumns : public Gtk::TreeModel::ColumnRecord { + +public: + InkSelectOneActionColumns() { + add (col_label); + add (col_icon); + add (col_tooltip); + add (col_sensitive); + } + Gtk::TreeModelColumn col_label; + Gtk::TreeModelColumn col_icon; + Gtk::TreeModelColumn col_tooltip; + Gtk::TreeModelColumn col_sensitive; +}; + + +class InkSelectOneAction : public Gtk::Action { + +public: + + static InkSelectOneAction* create(const Glib::ustring &name, + const Glib::ustring &label, + const Glib::ustring &tooltip, + const Glib::ustring &stock_id, + Glib::RefPtr store ); + + /* Style of action */ + void use_radio( bool use_radio ) { _use_radio = use_radio; } + void use_label( bool use_label ) { _use_label = use_label; } + void use_icon( bool use_icon ) { _use_icon = use_icon; } + + gint get_active() { return _active; } + void set_active( gint active ); + void set_icon_size( Gtk::BuiltinIconSize size ) { _icon_size = size; } + + Glib::RefPtr get_store() { return _store; } + + sigc::signal signal_changed() { return _changed; } + +protected: + + virtual Gtk::Widget* create_menu_item_vfunc(); + virtual Gtk::Widget* create_tool_item_vfunc(); + + /* Signals */ + sigc::signal _changed; + +private: + + Glib::ustring _name; + Glib::ustring _label; + Glib::ustring _tooltip; + Glib::ustring _stock_id; + Glib::RefPtr _store; + + gint _active; /* Active menu item/button */ + + /* Style */ + bool _use_radio; // Applies to tool item only + bool _use_label; + bool _use_icon; // Applies to menu item only + Gtk::BuiltinIconSize _icon_size; + + /* Combobox in tool */ + Gtk::ComboBox* _combobox; + + /* Need to track one action to get active action. */ + Glib::RefPtr _radioaction; + + Gtk::MenuItem* _menuitem; + std::vector _radiomenuitems; + + /* Internal Callbacks */ + void on_changed_combobox(); + void on_changed_radioaction(const Glib::RefPtr& current); + void on_toggled_radiomenu(int n); + + InkSelectOneAction (const Glib::ustring &name, + const Glib::ustring &label, + const Glib::ustring &tooltip, + const Glib::ustring &stock_id, + Glib::RefPtr store ); + +}; + + +#endif /* SEEN_INK_SELECT_ONE_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 : diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 272125631..0c0e75ad0 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -37,7 +37,6 @@ #include "document-undo.h" #include "document.h" #include "widgets/ege-adjustment-action.h" -#include "widgets/ege-select-one-action.h" #include "ink-radio-action.h" #include "ink-toggle-action.h" #include "widgets/ink-comboboxentry-action.h" @@ -54,6 +53,7 @@ #include "ui/icon-names.h" #include "ui/tools/text-tool.h" #include "ui/widget/unit-tracker.h" +#include "ui/widget/ink-select-one-action.h" #include "verbs.h" using Inkscape::DocumentUndo; @@ -435,7 +435,7 @@ static void sp_text_script_changed( InkToggleAction* act, GObject *tbl ) g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } -static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) +static void sp_text_align_mode_changed( GObject *tbl, int mode ) { // quit if run by the _changed callbacks if (g_object_get_data(G_OBJECT(tbl), "freeze")) { @@ -443,8 +443,6 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) ); - int mode = ege_select_one_action_get_active( act ); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setInt("/tools/text/align_mode", mode); @@ -1033,7 +1031,7 @@ static void sp_text_rotation_value_changed( GtkAdjustment *adj, GObject *tbl ) g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } -static void sp_writing_mode_changed( EgeSelectOneAction *act, GObject *tbl ) +static void sp_writing_mode_changed( GObject* tbl, int mode ) { // quit if run by the _changed callbacks if (g_object_get_data(G_OBJECT(tbl), "freeze")) { @@ -1041,8 +1039,6 @@ static void sp_writing_mode_changed( EgeSelectOneAction *act, GObject *tbl ) } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) ); - int mode = ege_select_one_action_get_active( act ); - SPCSSAttr *css = sp_repr_css_attr_new (); switch (mode) { @@ -1058,7 +1054,7 @@ static void sp_writing_mode_changed( EgeSelectOneAction *act, GObject *tbl ) break; } - case 2: + case 2: { sp_repr_css_set_property (css, "writing-mode", "vertical-lr"); break; @@ -1087,7 +1083,7 @@ static void sp_writing_mode_changed( EgeSelectOneAction *act, GObject *tbl ) g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } -static void sp_text_orientation_changed( EgeSelectOneAction *act, GObject *tbl ) +static void sp_text_orientation_changed( GObject* tbl, int mode ) { // quit if run by the _changed callbacks if (g_object_get_data(G_OBJECT(tbl), "freeze")) { @@ -1095,8 +1091,6 @@ static void sp_text_orientation_changed( EgeSelectOneAction *act, GObject *tbl ) } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) ); - int mode = ege_select_one_action_get_active( act ); - SPCSSAttr *css = sp_repr_css_attr_new (); switch (mode) { @@ -1141,7 +1135,7 @@ static void sp_text_orientation_changed( EgeSelectOneAction *act, GObject *tbl ) g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } -static void sp_text_direction_changed( EgeSelectOneAction *act, GObject *tbl ) +static void sp_text_direction_changed( GObject *tbl, int mode ) { // quit if run by the _changed callbacks if (g_object_get_data(G_OBJECT(tbl), "freeze")) { @@ -1149,7 +1143,6 @@ static void sp_text_direction_changed( EgeSelectOneAction *act, GObject *tbl ) } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) ); - int mode = ege_select_one_action_get_active( act ); SPCSSAttr *css = sp_repr_css_attr_new (); switch (mode) { @@ -1396,24 +1389,18 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ // Alignment - EgeSelectOneAction* textAlignAction = EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextAlignAction" ) ); + InkSelectOneAction* textAlignAction = + static_cast( g_object_get_data( tbl, "TextAlignAction" ) ); // Note: SVG 1.1 doesn't include text-align, SVG 1.2 Tiny doesn't include text-align="justify" // text-align="justify" was a draft SVG 1.2 item (along with flowed text). // Only flowed text can be left and right justified at the same time. // Disable button if we don't have flowed text. - // The GtkTreeModel class doesn't have a set function so we can't - // simply add an ege_select_one_action_set_sensitive method! - // We must set values directly with the GtkListStore and then - // ask that the GtkAction update the sensitive parameters. - GtkListStore * model = GTK_LIST_STORE( ege_select_one_action_get_model( textAlignAction ) ); - GtkTreePath * path = gtk_tree_path_new_from_string("3"); // Justify entry - GtkTreeIter iter; - gtk_tree_model_get_iter( GTK_TREE_MODEL (model), &iter, path ); - gtk_list_store_set( model, &iter, /* column */ 3, isFlow, -1 ); - ege_select_one_action_update_sensitive( textAlignAction ); - // ege_select_one_action_set_sensitive( textAlignAction, 3, isFlow ); + Glib::RefPtr store = textAlignAction->get_store(); + Gtk::TreeModel::Row row = *(store->get_iter("3")); // Justify entry + InkSelectOneActionColumns columns; + row[columns.col_sensitive] = isFlow; int activeButton = 0; if (query.text_align.computed == SP_CSS_TEXT_ALIGN_JUSTIFY) @@ -1425,8 +1412,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ if (query.text_anchor.computed == SP_CSS_TEXT_ANCHOR_MIDDLE) activeButton = 1; if (query.text_anchor.computed == SP_CSS_TEXT_ANCHOR_END) activeButton = 2; } - ege_select_one_action_set_active( textAlignAction, activeButton ); - + textAlignAction->set_active( activeButton ); // Line height (spacing) and line height unit double height; @@ -1520,9 +1506,9 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ if (query.writing_mode.computed == SP_CSS_WRITING_MODE_TB_RL) activeButton2 = 1; if (query.writing_mode.computed == SP_CSS_WRITING_MODE_TB_LR) activeButton2 = 2; - EgeSelectOneAction* writingModeAction = - EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextWritingModeAction" ) ); - ege_select_one_action_set_active( writingModeAction, activeButton2 ); + InkSelectOneAction* writingModeAction = + static_cast( g_object_get_data( tbl, "TextWritingModeAction" ) ); + writingModeAction->set_active( activeButton2 ); // Orientation int activeButton3 = 0; @@ -1530,35 +1516,20 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ if (query.text_orientation.computed == SP_CSS_TEXT_ORIENTATION_UPRIGHT ) activeButton3 = 1; if (query.text_orientation.computed == SP_CSS_TEXT_ORIENTATION_SIDEWAYS) activeButton3 = 2; - EgeSelectOneAction* textOrientationAction = - EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextOrientationAction" ) ); - ege_select_one_action_set_active( textOrientationAction, activeButton3 ); - - // Disable text orientation for horizontal text.. See above for why this nonsense - model = GTK_LIST_STORE( ege_select_one_action_get_model( textOrientationAction ) ); - - path = gtk_tree_path_new_from_string("0"); - gtk_tree_model_get_iter( GTK_TREE_MODEL (model), &iter, path ); - gtk_list_store_set( model, &iter, /* column */ 3, activeButton2 != 0, -1 ); - - path = gtk_tree_path_new_from_string("1"); - gtk_tree_model_get_iter( GTK_TREE_MODEL (model), &iter, path ); - gtk_list_store_set( model, &iter, /* column */ 3, activeButton2 != 0, -1 ); + InkSelectOneAction* textOrientationAction = + static_cast( g_object_get_data( tbl, "TextOrientationAction" ) ); + textOrientationAction->set_active( activeButton3 ); - path = gtk_tree_path_new_from_string("2"); - gtk_tree_model_get_iter( GTK_TREE_MODEL (model), &iter, path ); - gtk_list_store_set( model, &iter, /* column */ 3, activeButton2 != 0, -1 ); - - ege_select_one_action_update_sensitive( textOrientationAction ); + // Disable text orientation for horizontal text... + textOrientationAction->set_sensitive( activeButton2 != 0 ); // Direction int activeButton4 = 0; if (query.direction.computed == SP_CSS_DIRECTION_LTR ) activeButton4 = 0; if (query.direction.computed == SP_CSS_DIRECTION_RTL ) activeButton4 = 1; - EgeSelectOneAction* textDirectionAction = - EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextDirectionAction" ) ); - ege_select_one_action_set_active( textDirectionAction, activeButton4 ); - + InkSelectOneAction* textDirectionAction = + static_cast( g_object_get_data( tbl, "TextDirectionAction" ) ); + textDirectionAction->set_active( activeButton4 ); } #ifdef DEBUG_TEXT @@ -1832,209 +1803,175 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje /* Alignment */ { - GtkListStore* model = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN ); - - GtkTreeIter iter; + InkSelectOneActionColumns columns; + + Glib::RefPtr store = Gtk::ListStore::create(columns); + + Gtk::TreeModel::Row row; + + row = *(store->append()); + row[columns.col_label ] = _("Align left"); + row[columns.col_tooltip ] = _("Align left"); + row[columns.col_icon ] = INKSCAPE_ICON("format-justify-left"); + row[columns.col_sensitive] = true; + + row = *(store->append()); + row[columns.col_label ] = _("Align center"); + row[columns.col_tooltip ] = _("Align center"); + row[columns.col_icon ] = INKSCAPE_ICON("format-justify-center"); + row[columns.col_sensitive] = true; + + row = *(store->append()); + row[columns.col_label ] = _("Align right"); + row[columns.col_tooltip ] = _("Align right"); + row[columns.col_icon ] = INKSCAPE_ICON("format-justify-right"); + row[columns.col_sensitive] = true; + + row = *(store->append()); + row[columns.col_label ] = _("Justify"); + row[columns.col_tooltip ] = _("Justify (only flowed text)"); + row[columns.col_icon ] = INKSCAPE_ICON("format-justify-fill"); + row[columns.col_sensitive] = false; + + InkSelectOneAction* act = + InkSelectOneAction::create( "TextAlignAction", // Name + _("Alignment"), // Label + _("Text alignment"), // Tooltip + "Not Used", // Icon + store ); // Tree store + act->use_radio( false ); + act->use_label( false ); + gint mode = prefs->getInt("/tools/text/align_mode", 0); + act->set_active( mode ); - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("Align left"), - 1, _("Align left"), - 2, INKSCAPE_ICON("format-justify-left"), - 3, true, - -1 ); - - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("Align center"), - 1, _("Align center"), - 2, INKSCAPE_ICON("format-justify-center"), - 3, true, - -1 ); - - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("Align right"), - 1, _("Align right"), - 2, INKSCAPE_ICON("format-justify-right"), - 3, true, - -1 ); - - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("Justify"), - 1, _("Justify (only flowed text)"), - 2, INKSCAPE_ICON("format-justify-fill"), - 3, false, - -1 ); - - EgeSelectOneAction* act = ege_select_one_action_new( "TextAlignAction", // Name - _("Alignment"), // Label - _("Text alignment"), // Tooltip - NULL, // Icon name - GTK_TREE_MODEL(model) ); // Model - g_object_set( act, "short_label", "NotUsed", NULL ); - gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + gtk_action_group_add_action( mainActions, GTK_ACTION( act->gobj() )); g_object_set_data( holder, "TextAlignAction", act ); - ege_select_one_action_set_appearance( act, "full" ); - ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE ); - g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL ); - ege_select_one_action_set_icon_column( act, 2 ); - ege_select_one_action_set_icon_size( act, secondarySize ); - ege_select_one_action_set_tooltip_column( act, 1 ); - ege_select_one_action_set_sensitive_column( act, 3 ); - gint mode = prefs->getInt("/tools/text/align_mode", 0); - ege_select_one_action_set_active( act, mode ); - g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_align_mode_changed), holder ); + act->signal_changed().connect(sigc::bind<0>(sigc::ptr_fun(&sp_text_align_mode_changed), holder)); } /* Writing mode (Horizontal, Vertical-LR, Vertical-RL) */ { - GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING ); - - GtkTreeIter iter; + InkSelectOneActionColumns columns; + + Glib::RefPtr store = Gtk::ListStore::create(columns); + + Gtk::TreeModel::Row row; + + row = *(store->append()); + row[columns.col_label ] = _("Horizontal"); + row[columns.col_tooltip ] = _("Horizontal text"); + row[columns.col_icon ] = INKSCAPE_ICON("format-text-direction-horizontal"); + row[columns.col_sensitive] = true; + + row = *(store->append()); + row[columns.col_label ] = _("Vertical — RL"); + row[columns.col_tooltip ] = _("Vertical text — lines: right to left"); + row[columns.col_icon ] = INKSCAPE_ICON("format-text-direction-vertical"); + row[columns.col_sensitive] = true; + + row = *(store->append()); + row[columns.col_label ] = _("Vertical — LR"); + row[columns.col_tooltip ] = _("Vertical text — lines: left to right"); + row[columns.col_icon ] = INKSCAPE_ICON("format-text-direction-vertical-lr"); + row[columns.col_sensitive] = true; + + InkSelectOneAction* act = + InkSelectOneAction::create( "TextWritingModeAction", // Name + _("Writing mode"), // Label + _("Block progression"), // Tooltip + "Not Used", // Icon + store ); // Tree store + act->use_radio( false ); + act->use_label( false ); + gint mode = prefs->getInt("/tools/text/writing_mode", 0); + act->set_active( mode ); - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("Horizontal"), - 1, _("Horizontal text"), - 2, INKSCAPE_ICON("format-text-direction-horizontal"), - -1 ); - - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("Vertical — RL"), - 1, _("Vertical text — lines: right to left"), - 2, INKSCAPE_ICON("format-text-direction-vertical"), - -1 ); - - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("Vertical — LR"), - 1, _("Vertical text — lines: left to right"), // Mongolian! - 2, INKSCAPE_ICON("format-text-direction-vertical-lr"), - -1 ); - - EgeSelectOneAction* act = ege_select_one_action_new( "TextWritingModeAction", // Name - _("Writing mode"), // Label - _("Block progression"), // Tooltip - NULL, // Icon name - GTK_TREE_MODEL(model) ); // Model - - g_object_set( act, "short_label", "NotUsed", NULL ); - gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + gtk_action_group_add_action( mainActions, GTK_ACTION( act->gobj() )); g_object_set_data( holder, "TextWritingModeAction", act ); - ege_select_one_action_set_appearance( act, "full" ); - ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE ); - g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL ); - ege_select_one_action_set_icon_column( act, 2 ); - ege_select_one_action_set_icon_size( act, secondarySize ); - ege_select_one_action_set_tooltip_column( act, 1 ); - - gint mode = prefs->getInt("/tools/text/writing_mode", 0); - ege_select_one_action_set_active( act, mode ); - g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_writing_mode_changed), holder ); + act->signal_changed().connect(sigc::bind<0>(sigc::ptr_fun(&sp_writing_mode_changed), holder)); } /* Text (glyph) orientation (Auto (mixed), Upright, Sideways) */ { - GtkListStore* model = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN ); - - GtkTreeIter iter; + InkSelectOneActionColumns columns; + + Glib::RefPtr store = Gtk::ListStore::create(columns); + + Gtk::TreeModel::Row row; + + row = *(store->append()); + row[columns.col_label ] = _("Auto"); + row[columns.col_tooltip ] = _("Auto glyph orientation"); + row[columns.col_icon ] = INKSCAPE_ICON("text-orientation-auto"); + row[columns.col_sensitive] = true; + + row = *(store->append()); + row[columns.col_label ] = _("Upright"); + row[columns.col_tooltip ] = _("Upright glyph orientation"); + row[columns.col_icon ] = INKSCAPE_ICON("text-orientation-upright"); + row[columns.col_sensitive] = true; + + row = *(store->append()); + row[columns.col_label ] = _("Sideways"); + row[columns.col_tooltip ] = _("Sideways glyph orientation"); + row[columns.col_icon ] = INKSCAPE_ICON("text-orientation-sideways"); + row[columns.col_sensitive] = true; + + InkSelectOneAction* act = + InkSelectOneAction::create( "TextOrientationAction", // Name + _("Text orientation"), // Label + _("Text (glyph) orientation in vertical text."), // Tooltip + "Not Used", // Icon + store ); // List store + act->use_radio( false ); + act->use_label( false ); + gint mode = prefs->getInt("/tools/text/text_orientation", 0); + act->set_active( mode ); - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("Auto"), - 1, _("Auto glyph orientation"), - 2, INKSCAPE_ICON("text-orientation-auto"), - 3, true, - -1 ); - - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("Upright"), - 1, _("Upright glyph orientation"), - 2, INKSCAPE_ICON("text-orientation-upright"), - 3, true, - -1 ); - - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("Sideways"), - 1, _("Sideways glyph orientation"), - 2, INKSCAPE_ICON("text-orientation-sideways"), - 3, true, - -1 ); - - EgeSelectOneAction* act = ege_select_one_action_new( "TextOrientationAction", // Name - _("Text orientation"), // Label - _("Text (glyph) orientation in vertical text."), // Tooltip - NULL, // Icon name - GTK_TREE_MODEL(model) ); // Model - - g_object_set( act, "short_label", "NotUsed", NULL ); - gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + gtk_action_group_add_action( mainActions, GTK_ACTION( act->gobj() )); g_object_set_data( holder, "TextOrientationAction", act ); - ege_select_one_action_set_appearance( act, "full" ); - ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE ); - g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL ); - ege_select_one_action_set_icon_column( act, 2 ); - ege_select_one_action_set_icon_size( act, secondarySize ); - ege_select_one_action_set_tooltip_column( act, 1 ); - ege_select_one_action_set_sensitive_column( act, 3 ); - - gint mode = prefs->getInt("/tools/text/text_orientation", 0); - ege_select_one_action_set_active( act, mode ); - g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_orientation_changed), holder ); + act->signal_changed().connect(sigc::bind<0>(sigc::ptr_fun(&sp_text_orientation_changed), holder)); } // Text direction (predominant direction of horizontal text). { - GtkListStore* model = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN ); - - GtkTreeIter iter; + InkSelectOneActionColumns columns; + + Glib::RefPtr store = Gtk::ListStore::create(columns); + + Gtk::TreeModel::Row row; + + row = *(store->append()); + row[columns.col_label ] = _("LTR"); + row[columns.col_tooltip ] = _("Left to right text"); + row[columns.col_icon ] = INKSCAPE_ICON("format-text-direction-horizontal"); + row[columns.col_sensitive] = true; + + row = *(store->append()); + row[columns.col_label ] = _("RTL"); + row[columns.col_tooltip ] = _("Right to left text"); + row[columns.col_icon ] = INKSCAPE_ICON("format-text-direction-r2l"); + row[columns.col_sensitive] = true; + + InkSelectOneAction* act = + InkSelectOneAction::create( "TextDirectionAction", // Name + _("Text direction"), // Label + _("Text direction for normally horizontal text."), // Tooltip + "Not Used", // Icon + store ); // List store + act->use_radio( false ); + act->use_label( false ); + gint mode = prefs->getInt("/tools/text/text_direction", 0); + act->set_active( mode ); - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("LTR"), - 1, _("Left to right text"), - 2, INKSCAPE_ICON("format-text-direction-horizontal"), - 3, true, - -1 ); - - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("RTL"), - 1, _("Right to left text"), - 2, INKSCAPE_ICON("format-text-direction-r2l"), - 3, true, - -1 ); - - EgeSelectOneAction* act = ege_select_one_action_new( "TextDirectionAction", // Name - _("Text direction"), // Label - _("Text direction for normally horizontal text."), // Tooltip - NULL, // Icon name - GTK_TREE_MODEL(model) ); // Model - - g_object_set( act, "short_label", "NotUsed", NULL ); - gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + gtk_action_group_add_action( mainActions, GTK_ACTION( act->gobj() )); g_object_set_data( holder, "TextDirectionAction", act ); - ege_select_one_action_set_appearance( act, "full" ); - ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE ); - g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL ); - ege_select_one_action_set_icon_column( act, 2 ); - ege_select_one_action_set_icon_size( act, secondarySize ); - ege_select_one_action_set_tooltip_column( act, 1 ); - ege_select_one_action_set_sensitive_column( act, 3 ); - - gint mode = prefs->getInt("/tools/text/text_direction", 0); - ege_select_one_action_set_active( act, mode ); - g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_direction_changed), holder ); + act->signal_changed().connect(sigc::bind<0>(sigc::ptr_fun(&sp_text_direction_changed), holder)); } /* Line height unit tracker */ -- cgit v1.2.3 From b82b890314bfc64364f38e69696f7c6596ec3536 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 25 Jul 2017 13:17:19 +0100 Subject: libcola: C++11 fixes for Trusty --- src/libcola/cola.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libcola/cola.cpp b/src/libcola/cola.cpp index d553110b9..0009ef894 100644 --- a/src/libcola/cola.cpp +++ b/src/libcola/cola.cpp @@ -126,7 +126,7 @@ ConstrainedMajorizationLayout Dij[i*n + j] = d; if(i==j) continue; double lij=0; - if(d!=0 && !isinf(d)) { + if(d!=0 && !std::isinf(d)) { lij=1./(d*d); } degree += lap2[i*n + j] = lij; @@ -284,7 +284,7 @@ inline double ConstrainedMajorizationLayout for (unsigned i = 1; i < n; i++) { for (unsigned j = 0; j < i; j++) { d = Dij[i*n+j]; - if(!isinf(d)&&d!=numeric_limits::max()) { + if(!std::isinf(d)&&d!=numeric_limits::max()) { diff = d - euclidean_distance(i,j); if(d>80&&diff<0) continue; sum += diff*diff / (d*d); -- cgit v1.2.3 From 4670a2817c984493424e7fea3d73d614dbdb5089 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 25 Jul 2017 14:24:50 +0100 Subject: Fix Harfbuzz version check for Trusty --- src/libnrtype/FontFactory.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index fe0da45dc..5c6a96694 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -747,7 +747,10 @@ font_instance *font_factory::Face(PangoFontDescription *descr, bool canFail) } } -#if HB_VERSION_ATLEAST(1,2,3) +// TODO: Ideally, we should use the HB_VERSION_ATLEAST macro here, +// but this was only released in harfbuzz >= 0.9.30 +// #if HB_VERSION_ATLEAST(1,2,3) +#if HB_VERSION_MAJOR*10000 + HB_VERSION_MINOR*100 + HB_VERSION_MICRO >= 10203 // Find glyphs in OpenType substitution tables ('gsub'). // Note that pango's functions are just dummies. Must use harfbuzz. -- cgit v1.2.3 From 4546dc857e6e09fdcc0bea306a77f658dba765ea Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 25 Jul 2017 15:42:28 +0100 Subject: interface: add support for old Gtk+ --- src/ui/interface.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index a0ee5c72b..bbbd71ab8 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -481,7 +481,12 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *men GtkWidget *label = gtk_accel_label_new(action->name); gtk_label_set_markup_with_mnemonic( GTK_LABEL(label), action->name); gtk_label_set_use_underline(GTK_LABEL(label), true); + +#if GTK_CHECK_VERSION(3,16,0) gtk_label_set_xalign(GTK_LABEL(label), 0.0); +#else + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +#endif GtkAccelGroup *accel_group = sp_shortcut_get_accel_group(); gtk_menu_set_accel_group(menu, accel_group); -- cgit v1.2.3 From 3de5a80d68f64774646fd3dd6524897ee0dc3bad Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Wed, 26 Jul 2017 19:36:34 +0200 Subject: change "FileDescription" in inkscape.rc to include product name The name "description" seems to be misleading - it's (mis?)used by Microsoft to include the name of the program --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d10e4ec25..7437f12ae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -487,14 +487,14 @@ if(WIN32) set(FILE_NAME inkscape) set(PROGRAM_NAME Inkscape) - set(PROGRAM_DESCRIPTION "Vector graphics editor") + set(PROGRAM_DESCRIPTION "Inkscape vector graphics editor") configure_file(inkscape.rc ${CMAKE_BINARY_DIR}/src/inkscape.rc) configure_file(inkscape-manifest.xml ${CMAKE_BINARY_DIR}/src/inkscape-manifest.xml) list(APPEND main_SRC ${CMAKE_BINARY_DIR}/src/inkscape.rc) set(FILE_NAME inkview) set(PROGRAM_NAME Inkview) - set(PROGRAM_DESCRIPTION "Vector graphics viewer") + set(PROGRAM_DESCRIPTION "Inkview vector graphics viewer") configure_file(inkscape.rc ${CMAKE_BINARY_DIR}/src/inkview.rc) configure_file(inkscape-manifest.xml ${CMAKE_BINARY_DIR}/src/inkview-manifest.xml) list(APPEND view_SRC ${CMAKE_BINARY_DIR}/src/inkview.rc) -- cgit v1.2.3 From c1b8f8c0e669d426caaaa08cfc5c9d9545a3d0f1 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Thu, 27 Jul 2017 00:03:02 +0200 Subject: UX compres document dialog from Ronaldo idea with target to backport to 0.92.2 --- src/ui/dialog/document-properties.cpp | 58 +++++++++++++++++++++++------------ src/ui/dialog/document-properties.h | 4 +++ src/ui/widget/page-sizer.cpp | 6 +--- src/ui/widget/page-sizer.h | 1 - 4 files changed, 43 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 7d51653db..2765e63f4 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -207,7 +207,7 @@ DocumentProperties::~DocumentProperties() * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and * (non-0, non-0) means two widgets in columns 2 and 3. */ -inline void attach_all(Gtk::Grid &table, Gtk::Widget *const arr[], unsigned const n, int start = 0, int docum_prop_flag = 0) +inline void attach_all(Gtk::Grid &table, Gtk::Widget *const arr[], unsigned const n, int start = 0, int docum_prop_flag = 0, bool indent = false) { for (unsigned i = 0, r = start; i < n; i += 2) { if (arr[i] && arr[i+1]) { @@ -226,7 +226,7 @@ inline void attach_all(Gtk::Grid &table, Gtk::Widget *const arr[], unsigned cons } if (docum_prop_flag) { // this sets the padding for subordinate widgets on the "Page" page - if( i==(n-8) || i==(n-10) ) { + if( indent && (i==(n-6) || i==(n-4) || i==(n-2)) ) { arr[i+1]->set_hexpand(); #if WITH_GTKMM_3_12 arr[i+1]->set_margin_start(20); @@ -305,29 +305,47 @@ void DocumentProperties::build_page() Gtk::Widget *const widget_array[] = { - label_gen, 0, - 0, &_rum_deflt, - //label_col, 0, - //_rcp_bg._label, &_rcp_bg, - 0, 0, - label_for, 0, - 0, &_page_sizer, - 0, 0, - label_bkg, 0, - 0, &_rcb_checkerboard, - _rcp_bg._label, &_rcp_bg, - label_bdr, 0, - 0, &_rcb_canb, - 0, &_rcb_bord, - 0, &_rcb_shad, - _rcp_bord._label, &_rcp_bord, - label_dsp, 0, - 0, &_rcb_antialias, + label_gen, 0, + 0, &_rum_deflt, + //label_col, 0, + //_rcp_bg._label, &_rcp_bg, + 0, 0, + label_for, 0, + 0, &_page_sizer, + 0, 0, + &_rcb_doc_props_left, &_rcb_doc_props_right, }; + attach_all(_page_page->table(), widget_array, G_N_ELEMENTS(widget_array),0,1); + _rcp_bg_col.pack_start(*_rcp_bg._label, false, false, 2); + _rcp_bg_col.pack_start(_rcp_bg, false, false, 2); + Gtk::Widget *const widget_array_left[] = + { + label_bkg, 0, + 0, &_rcb_checkerboard, + 0, &_rcp_bg_col, + label_dsp, 0, + 0, &_rcb_antialias, + }; + + attach_all(_rcb_doc_props_left, widget_array_left, G_N_ELEMENTS(widget_array_left),0,1); + _rcp_bord_col.pack_start(*_rcp_bord._label, false, false, 2); + _rcp_bord_col.pack_start(_rcp_bord, false, false, 2); + Gtk::Widget *const widget_array_right[] = + { + label_bdr, 0, + 0, &_rcb_canb, + 0, &_rcb_bord, + 0, &_rcb_shad, + 0, &_rcp_bord_col, + }; + + attach_all(_rcb_doc_props_right, widget_array_right, G_N_ELEMENTS(widget_array_right),0,1, true); + std::list _slaveList; _slaveList.push_back(&_rcb_bord); _slaveList.push_back(&_rcb_shad); + _slaveList.push_back(&_rcp_bord_col); _rcb_canb.setSlaveWidgets(_slaveList); attach_all(_page_page->table(), widget_array, G_N_ELEMENTS(widget_array),0,1); diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 8d1c6b38a..fe0e1864e 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -117,6 +117,10 @@ protected: UI::Widget::Registry _wr; //--------------------------------------------------------------- + Gtk::Grid _rcb_doc_props_left; + Gtk::Grid _rcb_doc_props_right; + Gtk::Box _rcp_bg_col; + Gtk::Box _rcp_bord_col; UI::Widget::RegisteredCheckButton _rcb_antialias; UI::Widget::RegisteredCheckButton _rcb_checkerboard; UI::Widget::RegisteredCheckButton _rcb_canb; diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index bb88536d5..3ec6a2b9f 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -225,7 +225,7 @@ PageSizer::PageSizer(Registry & _wr) _marginBottom( _("Botto_m:"), _("Bottom margin"), "fit-margin-bottom", _wr), _lockMarginUpdate(false), _scaleX(_("Scale _x:"), _("Scale X"), "scale-x", _wr), - _scaleY(_("Scale _y:"), _("Scale Y"), "scale-y", _wr), + _scaleY(_("Scale _y:"), _("While SVG allows non-uniform scaling it is recommended to use only uniform scaling in Inkscape. To set a non-uniform scaling, set the 'viewBox' directly."), "scale-y", _wr), _lockScaleUpdate(false), _viewboxX(_("X:"), _("X"), "viewbox-x", _wr), _viewboxY(_("Y:"), _("Y"), "viewbox-y", _wr), @@ -416,13 +416,9 @@ PageSizer::PageSizer(Registry & _wr) _scaleTable.attach(_scaleY, 1, 0, 1, 1); _scaleTable.attach(_scaleLabel, 2, 0, 1, 1); - _scaleTable.attach(_scaleWarning, 0, 1, 2, 1); _viewboxExpander.set_hexpand(); _viewboxExpander.set_vexpand(); _scaleTable.attach(_viewboxExpander, 0, 2, 2, 1); - - _scaleWarning.set_label(_("While SVG allows non-uniform scaling it is recommended to use only uniform scaling in Inkscape. To set a non-uniform scaling, set the 'viewBox' directly.")); - _scaleWarning.set_line_wrap( true ); _viewboxExpander.set_use_underline(); _viewboxExpander.set_label(_("_Viewbox...")); diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index d0655fb0e..f84f96782 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -238,7 +238,6 @@ protected: Gtk::Grid _scaleTable; Gtk::Label _scaleLabel; - Gtk::Label _scaleWarning; RegisteredScalar _scaleX; RegisteredScalar _scaleY; bool _lockScaleUpdate; -- cgit v1.2.3 From f96dc7e33910f1e16175959147f5173cce8c230f Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 28 Jul 2017 19:21:37 +0200 Subject: Show a control point for the center of a spiral Spirals in Inkscape define a center point but the user cannot easily control the position of the center. Show a control point for the center so it's easier to move the shape around and snap it by its center. --- src/ui/object-edit.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src') diff --git a/src/ui/object-edit.cpp b/src/ui/object-edit.cpp index 81f0b92c0..a2b6a2de0 100644 --- a/src/ui/object-edit.cpp +++ b/src/ui/object-edit.cpp @@ -1293,6 +1293,12 @@ public: virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; +class SpiralKnotHolderEntityCenter : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + /* * set attributes via inner (t=t0) knot point: @@ -1425,6 +1431,20 @@ SpiralKnotHolderEntityOuter::knot_set(Geom::Point const &p, Geom::Point const &/ spiral->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } +void +SpiralKnotHolderEntityCenter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPSpiral *spiral = dynamic_cast(item); + g_assert(spiral != NULL); + + Geom::Point const s = snap_knot_position(p, state); + + spiral->cx = s[Geom::X]; + spiral->cy = s[Geom::Y]; + + spiral->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + Geom::Point SpiralKnotHolderEntityInner::knot_get() const { @@ -1443,6 +1463,15 @@ SpiralKnotHolderEntityOuter::knot_get() const return spiral->getXY(1.0); } +Geom::Point +SpiralKnotHolderEntityCenter::knot_get() const +{ + SPSpiral const *spiral = dynamic_cast(item); + g_assert(spiral != NULL); + + return Geom::Point(spiral->cx, spiral->cy); +} + void SpiralKnotHolderEntityInner::knot_click(unsigned int state) { @@ -1461,9 +1490,26 @@ SpiralKnotHolderEntityInner::knot_click(unsigned int state) SpiralKnotHolder::SpiralKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : KnotHolder(desktop, item, relhandler) { + SpiralKnotHolderEntityCenter *entity_center = new SpiralKnotHolderEntityCenter(); SpiralKnotHolderEntityInner *entity_inner = new SpiralKnotHolderEntityInner(); SpiralKnotHolderEntityOuter *entity_outer = new SpiralKnotHolderEntityOuter(); + // NOTE: entity_central and entity_inner can overlap. + // + // In that case it would be a problem if the center control point was ON + // TOP because it would steal the mouse focus and the user would loose the + // ability to access the inner control point using only the mouse. + // + // However if the inner control point is ON TOP, taking focus, the + // situation is a lot better: the user can still move the inner control + // point with the mouse to regain access to the center control point. + // + // So, create entity_inner AFTER entity_center; this ensures that + // entity_inner gets rendered ON TOP. + entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, + _("Drag to move the spiral"), + SP_KNOT_SHAPE_CROSS); + entity_inner->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Roll/unroll the spiral from inside; with Ctrl to snap angle; " "with Alt to converge/diverge")); @@ -1472,6 +1518,7 @@ SpiralKnotHolder::SpiralKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolde _("Roll/unroll the spiral from outside; with Ctrl to snap angle; " "with Shift to scale/rotate; with Alt to lock radius")); + entity.push_back(entity_center); entity.push_back(entity_inner); entity.push_back(entity_outer); -- cgit v1.2.3