diff options
| author | Eduard Braun <eduard.braun2@gmx.de> | 2017-07-09 12:42:10 +0000 |
|---|---|---|
| committer | Eduard Braun <eduard.braun2@gmx.de> | 2017-07-09 12:42:10 +0000 |
| commit | 241554b7ad311b5868ba284c7a4e6a410432b9bd (patch) | |
| tree | 8bf6fed572d27e9b97ca60b90ae1684ba4856eeb /src/ui | |
| parent | Use .xml when exporting shortcuts by default (diff) | |
| parent | Shortcuts: Fix for 7d248fbba5b0c24d9a24cda8c3f2e79f96395553 (is_user_set was ... (diff) | |
| download | inkscape-241554b7ad311b5868ba284c7a4e6a410432b9bd.tar.gz inkscape-241554b7ad311b5868ba284c7a4e6a410432b9bd.zip | |
Merge branch 'master' into shortcuts
Diffstat (limited to 'src/ui')
123 files changed, 2685 insertions, 2107 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 389e8902a..789378e0c 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -1,5 +1,6 @@ set(ui_SRC clipboard.cpp + contextmenu.cpp control-manager.cpp dialog-events.cpp draw-anchor.cpp @@ -71,6 +72,7 @@ set(ui_SRC dialog/filedialog.cpp dialog/filedialogimpl-gtkmm.cpp dialog/fill-and-stroke.cpp + dialog/filter-editor.cpp dialog/filter-effects-dialog.cpp dialog/find.cpp dialog/floating-behavior.cpp @@ -113,6 +115,7 @@ set(ui_SRC dialog/transformation.cpp dialog/undo-history.cpp dialog/xml-tree.cpp + dialog/save-template-dialog.cpp widget/addtoicon.cpp widget/anchor-selector.cpp @@ -173,6 +176,7 @@ set(ui_SRC # ------- # Headers clipboard.h + contextmenu.h control-manager.h control-types.h dialog-events.h @@ -214,6 +218,7 @@ set(ui_SRC dialog/filedialogimpl-gtkmm.h dialog/filedialogimpl-win32.h dialog/fill-and-stroke.h + dialog/filter-editor.h dialog/filter-effects-dialog.h dialog/find.h dialog/floating-behavior.h @@ -258,6 +263,7 @@ set(ui_SRC dialog/transformation.h dialog/undo-history.h dialog/xml-tree.h + dialog/save-template-dialog.h tool/commit-events.h tool/control-point-selection.h diff --git a/src/ui/contextmenu.cpp b/src/ui/contextmenu.cpp new file mode 100644 index 000000000..1bc87574e --- /dev/null +++ b/src/ui/contextmenu.cpp @@ -0,0 +1,914 @@ +/** + * @file + * Context menu + */ +/* Authors: + * Lauris Kaplinski <lauris@kaplinski.com> + * Frank Felfe <innerspace@iname.com> + * bulia byak <buliabyak@users.sf.net> + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma + * Kris De Gussem <Kris.DeGussem@gmail.com> + * + * Copyright (C) 2012 Kris De Gussem + * Copyright (C) 2010 authors + * Copyright (C) 1999-2005 authors + * Copyright (C) 2004 David Turner + * Copyright (C) 2001-2002 Ximian, Inc. + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "contextmenu.h" + +#include <glibmm/i18n.h> +#include <glibmm/miscutils.h> + +#include <gtkmm/box.h> +#include <gtkmm/image.h> +#include <gtkmm/separatormenuitem.h> + +#include "desktop.h" +#include "document.h" +#include "document-undo.h" +#include "helper/action.h" +#include "helper/action-context.h" +#include "inkscape.h" +#include "message-context.h" +#include "message-stack.h" +#include "selection.h" +#include "selection-chemistry.h" +#include "shortcuts.h" +#include "sp-anchor.h" +#include "sp-clippath.h" +#include "sp-image.h" +#include "sp-item.h" +#include "sp-mask.h" +#include "sp-shape.h" +#include "sp-text.h" +#include "ui/dialog/dialog-manager.h" +#include "ui/dialog/layer-properties.h" +#include "verbs.h" + +static bool temporarily_block_actions = false; + +ContextMenu::ContextMenu(SPDesktop *desktop, SPItem *item) : + _item(item), + MIGroup(), + MIParent(_("Go to parent")) +{ +// g_message("ContextMenu"); + _object = static_cast<SPObject *>(item); + _desktop = desktop; + + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_UNDO)); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_REDO)); + AddSeparator(); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_CUT)); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_COPY)); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_PASTE)); + AddSeparator(); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DUPLICATE)); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DELETE)); + + positionOfLastDialog = 10; // 9 in front + 1 for the separator in the next if; used to position the dialog menu entries below each other + /* Item menu */ + if (item!=NULL) { + AddSeparator(); + MakeObjectMenu(); + } + AddSeparator(); + /* Lock/Unock Hide/Unhide*/ + Geom::Rect b(_desktop->point(),_desktop->point() + Geom::Point(1,1)); + std::vector< SPItem * > down_items = _desktop->getDocument()->getItemsPartiallyInBox( _desktop->dkey, b, true, true); + bool has_down_hidden = false; + bool has_down_locked = false; + for(std::vector< SPItem * >::iterator down = down_items.begin(); down != down_items.end(); ++down){ + if((*down)->isHidden()) { + has_down_hidden = true; + } + if((*down)->isLocked()) { + has_down_locked = true; + } + } + Gtk::MenuItem* mi; + + mi = Gtk::manage(new Gtk::MenuItem(_("Hide selected objects"),1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::HideSelected)); + if (_desktop->selection->isEmpty()) { + mi->set_sensitive(false); + } + mi->show(); + append(*mi);//insert(*mi,positionOfLastDialog++); + + mi = Gtk::manage(new Gtk::MenuItem(_("Unhide objects below"),1)); + mi->signal_activate().connect(sigc::bind<std::vector< SPItem * > >(sigc::mem_fun(*this, &ContextMenu::UnHideBelow), down_items)); + if (!has_down_hidden) { + mi->set_sensitive(false); + } + mi->show(); + append(*mi);//insert(*mi,positionOfLastDialog++); + + mi = Gtk::manage(new Gtk::MenuItem(_("Lock selected objects"),1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::LockSelected)); + if (_desktop->selection->isEmpty()) { + mi->set_sensitive(false); + } + mi->show(); + append(*mi);//insert(*mi,positionOfLastDialog++); + + mi = Gtk::manage(new Gtk::MenuItem(_("Unlock objects below"),1)); + mi->signal_activate().connect(sigc::bind<std::vector< SPItem * > >(sigc::mem_fun(*this, &ContextMenu::UnLockBelow), down_items)); + if (!has_down_locked) { + mi->set_sensitive(false); + } + mi->show(); + append(*mi);//insert(*mi,positionOfLastDialog++); + /* layer menu */ + SPGroup *group=NULL; + if (item) { + if (SP_IS_GROUP(item)) { + group = SP_GROUP(item); + } else if ( item != _desktop->currentRoot() && SP_IS_GROUP(item->parent) ) { + group = SP_GROUP(item->parent); + } + } + + if (( group && group != _desktop->currentLayer() ) || + ( _desktop->currentLayer() != _desktop->currentRoot() && _desktop->currentLayer()->parent != _desktop->currentRoot() ) ) { + AddSeparator(); + } + + if ( group && group != _desktop->currentLayer() ) { + /* TRANSLATORS: #%1 is the id of the group e.g. <g id="#g7">, not a number. */ + MIGroup.set_label (Glib::ustring::compose(_("Enter group #%1"), group->getId())); + MIGroup.set_data("group", group); + MIGroup.signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &ContextMenu::EnterGroup),&MIGroup)); + MIGroup.show(); + append(MIGroup); + } + + if ( _desktop->currentLayer() != _desktop->currentRoot() ) { + if ( _desktop->currentLayer()->parent != _desktop->currentRoot() ) { + MIParent.signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::LeaveGroup)); + MIParent.show(); + append(MIParent); + + /* Pop selection out of group */ + Gtk::MenuItem* miu = Gtk::manage(new Gtk::MenuItem(_("_Pop selection out of group"), 1)); + miu->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroupPopSelection)); + miu->show(); + append(*miu); + } + } +} + +ContextMenu::~ContextMenu(void) +{ +} + +Gtk::SeparatorMenuItem* ContextMenu::AddSeparator(void) +{ + Gtk::SeparatorMenuItem* sep = Gtk::manage(new Gtk::SeparatorMenuItem()); + sep->show(); + append(*sep); + return sep; +} + +void ContextMenu::EnterGroup(Gtk::MenuItem* mi) +{ + _desktop->setCurrentLayer(reinterpret_cast<SPObject *>(mi->get_data("group"))); + _desktop->selection->clear(); +} + +void ContextMenu::LeaveGroup(void) +{ + _desktop->setCurrentLayer(_desktop->currentLayer()->parent); +} + +void ContextMenu::LockSelected(void) +{ + auto itemlist = _desktop->selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i) { + (*i)->setLocked(true); + } +} + +void ContextMenu::HideSelected(void) +{ + auto itemlist =_desktop->selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i) { + (*i)->setHidden(true); + } +} + +void ContextMenu::UnLockBelow(std::vector<SPItem *> items) +{ + _desktop->selection->clear(); + for(auto i=items.begin();i!=items.end(); ++i) { + if ((*i)->isLocked()) { + (*i)->setLocked(false); + _desktop->selection->add(*i); + } + } +} + +void ContextMenu::UnHideBelow(std::vector<SPItem *> items) +{ + _desktop->selection->clear(); + for(auto i=items.begin();i!=items.end(); ++i) { + if ((*i)->isHidden()) { + (*i)->setHidden(false); + _desktop->selection->add(*i); + } + } +} + +/* + * Some day when the right-click menus are ready to start working + * smarter with the verbs, we'll need to change this NULL being + * sent to sp_action_perform to something useful, or set some kind + * of global "right-clicked position" variable for actions to + * investigate when they're called. + */ +static void +context_menu_item_on_my_activate(void */*object*/, SPAction *action) +{ + if (!temporarily_block_actions) { + sp_action_perform(action, NULL); + } +} + +static void +context_menu_item_on_my_select(void */*object*/, SPAction *action) +{ + sp_action_get_view(action)->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, action->tip); +} + +static void +context_menu_item_on_my_deselect(void */*object*/, SPAction *action) +{ + sp_action_get_view(action)->tipsMessageContext()->clear(); +} + + +// TODO: Update this to allow radio items to be used +void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb)//, SPDesktop *view)//, bool radio, GSList *group) +{ + SPAction *action; + SPDesktop *view = _desktop; + + if (verb->get_code() == SP_VERB_NONE) { + Gtk::MenuItem *item = AddSeparator(); + item->show(); + append(*item); + } else { + action = verb->get_action(Inkscape::ActionContext(view)); + if (!action) { + return; + } + + auto const item = Gtk::manage(new Gtk::MenuItem(action->name, true)); + + sp_shortcut_add_accelerator(GTK_WIDGET(item->gobj()), sp_shortcut_get_primary(verb)); + + action->signal_set_sensitive.connect(sigc::mem_fun(*this, &ContextMenu::set_sensitive)); + action->signal_set_name.connect(sigc::mem_fun(*item, &ContextMenu::set_name)); + + if (!action->sensitive) { + item->set_sensitive(FALSE); + } + + item->set_events(Gdk::KEY_PRESS_MASK); + item->signal_activate().connect(sigc::bind(sigc::ptr_fun(context_menu_item_on_my_activate),item,action)); + item->signal_select().connect(sigc::bind(sigc::ptr_fun(context_menu_item_on_my_select),item,action)); + item->signal_deselect().connect(sigc::bind(sigc::ptr_fun(context_menu_item_on_my_deselect),item,action)); + item->show_all(); + append(*item); + } +} + +void ContextMenu::MakeObjectMenu(void) +{ + if (SP_IS_ITEM(_object)) { + MakeItemMenu(); + } + + if (SP_IS_GROUP(_object)) { + MakeGroupMenu(); + } + + if (SP_IS_ANCHOR(_object)) { + MakeAnchorMenu(); + } + + if (SP_IS_IMAGE(_object)) { + MakeImageMenu(); + } + + if (SP_IS_SHAPE(_object)) { + MakeShapeMenu(); + } + + if (SP_IS_TEXT(_object)) { + MakeTextMenu(); + } +} + +void ContextMenu::MakeItemMenu (void) +{ + Gtk::MenuItem* mi; + + /* Item dialog */ + mi = Gtk::manage(new Gtk::MenuItem(_("_Object Properties..."),1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemProperties)); + mi->show(); + append(*mi);//insert(*mi,positionOfLastDialog++); + + AddSeparator(); + + /* Select item */ + if (Inkscape::Verb::getbyid( "org.inkscape.followlink" )) { + mi = Gtk::manage(new Gtk::MenuItem(_("_Select This"), 1)); + if (_desktop->selection->includes(_item)) { + mi->set_sensitive(FALSE); + } else { + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemSelectThis)); + } + mi->show(); + append(*mi); + } + + + mi = Gtk::manage(new Gtk::MenuItem(_("Select Same"))); + mi->show(); + Gtk::Menu *select_same_submenu = Gtk::manage(new Gtk::Menu()); + if (_desktop->selection->isEmpty()) { + mi->set_sensitive(FALSE); + } + mi->set_submenu(*select_same_submenu); + append(*mi); + + /* Select same fill and stroke */ + mi = Gtk::manage(new Gtk::MenuItem(_("Fill and Stroke"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameFillStroke)); + mi->set_sensitive(!SP_IS_ANCHOR(_item)); + mi->show(); + select_same_submenu->append(*mi); + + /* Select same fill color */ + mi = Gtk::manage(new Gtk::MenuItem(_("Fill Color"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameFillColor)); + mi->set_sensitive(!SP_IS_ANCHOR(_item)); + mi->show(); + select_same_submenu->append(*mi); + + /* Select same stroke color */ + mi = Gtk::manage(new Gtk::MenuItem(_("Stroke Color"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameStrokeColor)); + mi->set_sensitive(!SP_IS_ANCHOR(_item)); + mi->show(); + select_same_submenu->append(*mi); + + /* Select same stroke style */ + mi = Gtk::manage(new Gtk::MenuItem(_("Stroke Style"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameStrokeStyle)); + mi->set_sensitive(!SP_IS_ANCHOR(_item)); + mi->show(); + select_same_submenu->append(*mi); + + /* Select same stroke style */ + mi = Gtk::manage(new Gtk::MenuItem(_("Object type"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameObjectType)); + mi->set_sensitive(!SP_IS_ANCHOR(_item)); + mi->show(); + select_same_submenu->append(*mi); + + /* Move to layer */ + mi = Gtk::manage(new Gtk::MenuItem(_("_Move to layer ..."), 1)); + if (_desktop->selection->isEmpty()) { + mi->set_sensitive(FALSE); + } else { + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemMoveTo)); + } + mi->show(); + append(*mi); + + /* Create link */ + mi = Gtk::manage(new Gtk::MenuItem(_("Create _Link"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemCreateLink)); + mi->set_sensitive(!SP_IS_ANCHOR(_item)); + mi->show(); + append(*mi); + + bool ClipRefOK=false; + bool MaskRefOK=false; + if (_item){ + if (_item->clip_ref){ + if (_item->clip_ref->getObject()){ + ClipRefOK=true; + } + } + } + if (_item){ + if (_item->mask_ref){ + if (_item->mask_ref->getObject()){ + MaskRefOK=true; + } + } + } + /* Set mask */ + mi = Gtk::manage(new Gtk::MenuItem(_("Set Mask"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetMask)); + if (ClipRefOK || MaskRefOK) { + mi->set_sensitive(FALSE); + } else { + mi->set_sensitive(TRUE); + } + mi->show(); + append(*mi); + + /* Release mask */ + mi = Gtk::manage(new Gtk::MenuItem(_("Release Mask"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseMask)); + if (MaskRefOK) { + mi->set_sensitive(TRUE); + } else { + mi->set_sensitive(FALSE); + } + mi->show(); + append(*mi); + + /*SSet Clip Group */ + mi = Gtk::manage(new Gtk::MenuItem(_("Create Clip G_roup"),1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::CreateGroupClip)); + mi->set_sensitive(TRUE); + mi->show(); + append(*mi); + + /* Set Clip */ + mi = Gtk::manage(new Gtk::MenuItem(_("Set Cl_ip"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetClip)); + if (ClipRefOK || MaskRefOK) { + mi->set_sensitive(FALSE); + } else { + mi->set_sensitive(TRUE); + } + mi->show(); + append(*mi); + + /* Release Clip */ + mi = Gtk::manage(new Gtk::MenuItem(_("Release C_lip"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseClip)); + if (ClipRefOK) { + mi->set_sensitive(TRUE); + } else { + mi->set_sensitive(FALSE); + } + mi->show(); + append(*mi); + + /* Group */ + mi = Gtk::manage(new Gtk::MenuItem(_("_Group"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateGroup)); + if (_desktop->selection->isEmpty()) { + mi->set_sensitive(FALSE); + } else { + mi->set_sensitive(TRUE); + } + mi->show(); + append(*mi); +} + +void ContextMenu::SelectSameFillStroke(void) +{ + sp_select_same_fill_stroke_style(_desktop, true, true, true); +} + +void ContextMenu::SelectSameFillColor(void) +{ + sp_select_same_fill_stroke_style(_desktop, true, false, false); +} + +void ContextMenu::SelectSameStrokeColor(void) +{ + sp_select_same_fill_stroke_style(_desktop, false, true, false); +} + +void ContextMenu::SelectSameStrokeStyle(void) +{ + sp_select_same_fill_stroke_style(_desktop, false, false, true); +} + +void ContextMenu::SelectSameObjectType(void) +{ + sp_select_same_object_type(_desktop); +} + +void ContextMenu::ItemProperties(void) +{ + _desktop->selection->set(_item); + _desktop->_dlg_mgr->showDialog("ObjectProperties"); +} + +void ContextMenu::ItemSelectThis(void) +{ + _desktop->selection->set(_item); +} + +void ContextMenu::ItemMoveTo(void) +{ + Inkscape::UI::Dialogs::LayerPropertiesDialog::showMove(_desktop, _desktop->currentLayer()); +} + + + +void ContextMenu::ItemCreateLink(void) +{ + Inkscape::XML::Document *xml_doc = _desktop->doc()->getReprDoc(); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:a"); + _item->parent->getRepr()->addChild(repr, _item->getRepr()); + SPObject *object = _item->document->getObjectByRepr(repr); + g_return_if_fail(SP_IS_ANCHOR(object)); + + const char *id = _item->getRepr()->attribute("id"); + Inkscape::XML::Node *child = _item->getRepr()->duplicate(xml_doc); + _item->deleteObject(false); + repr->addChild(child, NULL); + child->setAttribute("id", id); + + Inkscape::GC::release(repr); + Inkscape::GC::release(child); + + Inkscape::DocumentUndo::done(object->document, SP_VERB_NONE, _("Create link")); + + _desktop->selection->set(SP_ITEM(object)); + _desktop->_dlg_mgr->showDialog("ObjectAttributes"); +} + +void ContextMenu::SetMask(void) +{ + _desktop->selection->setMask(false, false); +} + +void ContextMenu::ReleaseMask(void) +{ + _desktop->selection->unsetMask(false); +} + +void ContextMenu::CreateGroupClip(void) +{ + _desktop->selection->setClipGroup(); +} + +void ContextMenu::SetClip(void) +{ + _desktop->selection->setMask(true, false); +} + + +void ContextMenu::ReleaseClip(void) +{ + _desktop->selection->unsetMask(true); +} + +void ContextMenu::MakeGroupMenu(void) +{ + /* Ungroup */ + Gtk::MenuItem* mi = Gtk::manage(new Gtk::MenuItem(_("_Ungroup"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroup)); + mi->show(); + append(*mi); +} + +void ContextMenu::ActivateGroup(void) +{ + _desktop->selection->group(); +} + +void ContextMenu::ActivateUngroup(void) +{ + std::vector<SPItem*> children; + + sp_item_group_ungroup(static_cast<SPGroup*>(_item), children); + _desktop->selection->setList(children); +} + +void ContextMenu::ActivateUngroupPopSelection(void) +{ + _desktop->selection->popFromGroup(); +} + + +void ContextMenu::MakeAnchorMenu(void) +{ + Gtk::MenuItem* mi; + + /* Link dialog */ + mi = Gtk::manage(new Gtk::MenuItem(_("Link _Properties..."), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkProperties)); + mi->show(); + insert(*mi,positionOfLastDialog++); + + /* Select item */ + mi = Gtk::manage(new Gtk::MenuItem(_("_Follow Link"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkFollow)); + mi->show(); + append(*mi); + + /* Reset transformations */ + mi = Gtk::manage(new Gtk::MenuItem(_("_Remove Link"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkRemove)); + mi->show(); + append(*mi); +} + +void ContextMenu::AnchorLinkProperties(void) +{ + _desktop->_dlg_mgr->showDialog("ObjectAttributes"); +} + +void ContextMenu::AnchorLinkFollow(void) +{ + + if (_desktop->selection->isEmpty()) { + _desktop->selection->set(_item); + } + // Opening the selected links with a python extension + Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.inkscape.followlink" ); + if (verb) { + SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop)); + if (action) { + sp_action_perform(action, NULL); + } + } +} + +void ContextMenu::AnchorLinkRemove(void) +{ + std::vector<SPItem*> children; + sp_item_group_ungroup(static_cast<SPAnchor*>(_item), children, false); + Inkscape::DocumentUndo::done(_desktop->doc(), SP_VERB_NONE, _("Remove link")); +} + +void ContextMenu::MakeImageMenu (void) +{ + Gtk::MenuItem* mi; + Inkscape::XML::Node *ir = _object->getRepr(); + const gchar *href = ir->attribute("xlink:href"); + + /* Image properties */ + mi = Gtk::manage(new Gtk::MenuItem(_("Image _Properties..."), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageProperties)); + mi->show(); + insert(*mi,positionOfLastDialog++); + + /* Edit externally */ + mi = Gtk::manage(new Gtk::MenuItem(_("Edit Externally..."), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEdit)); + mi->show(); + insert(*mi,positionOfLastDialog++); + if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { + mi->set_sensitive( FALSE ); + } + + /* Trace Bitmap */ + mi = Gtk::manage(new Gtk::MenuItem(_("_Trace Bitmap..."), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageTraceBitmap)); + mi->show(); + insert(*mi,positionOfLastDialog++); + if (_desktop->selection->isEmpty()) { + mi->set_sensitive(FALSE); + } + + /* Trace Pixel Art */ + mi = Gtk::manage(new Gtk::MenuItem(_("Trace Pixel Art"), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageTracePixelArt)); + mi->show(); + insert(*mi,positionOfLastDialog++); + if (_desktop->selection->isEmpty()) { + mi->set_sensitive(FALSE); + } + + /* Embed image */ + if (Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" )) { + mi = Gtk::manage(new Gtk::MenuItem(C_("Context menu", "Embed Image"))); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEmbed)); + mi->show(); + insert(*mi,positionOfLastDialog++); + if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { + mi->set_sensitive( FALSE ); + } + } + + /* Extract image */ + if (Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" )) { + mi = Gtk::manage(new Gtk::MenuItem(C_("Context menu", "Extract Image..."))); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageExtract)); + mi->show(); + insert(*mi,positionOfLastDialog++); + if ( (!href) || ((strncmp(href, "data:", 5) != 0)) ) { + mi->set_sensitive( FALSE ); + } + } +} + +void ContextMenu::ImageProperties(void) +{ + _desktop->_dlg_mgr->showDialog("ObjectAttributes"); +} + +Glib::ustring ContextMenu::getImageEditorName() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring value; + Glib::ustring choices = prefs->getString("/options/bitmapeditor/value"); + if (!choices.empty()) { + value = choices; + } + else { + value = "gimp"; + } + return value; +} + +void ContextMenu::ImageEdit(void) +{ + if (_desktop->selection->isEmpty()) { + _desktop->selection->set(_item); + } + + GError* errThing = 0; + Glib::ustring cmdline = getImageEditorName(); + Glib::ustring name; + Glib::ustring fullname; + +#ifdef WIN32 + // g_spawn_command_line_sync parsing is done according to Unix shell rules, + // not Windows command interpreter rules. Thus we need to enclose the + // executable path with single quotes. + int index = cmdline.find(".exe"); + if ( index < 0 ) index = cmdline.find(".bat"); + if ( index < 0 ) index = cmdline.find(".com"); + if ( index >= 0 ) { + Glib::ustring editorBin = cmdline.substr(0, index + 4).c_str(); + Glib::ustring args = cmdline.substr(index + 4, cmdline.length()).c_str(); + editorBin.insert(0, "'"); + editorBin.append("'"); + cmdline = editorBin; + cmdline.append(args); + } else { + // Enclose the whole command line if no executable path can be extracted. + cmdline.insert(0, "'"); + cmdline.append("'"); + } +#endif + + auto itemlist= _desktop->selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ + Inkscape::XML::Node *ir = (*i)->getRepr(); + const gchar *href = ir->attribute("xlink:href"); + + if (strncmp (href,"file:",5) == 0) { + // URI to filename conversion + name = g_filename_from_uri(href, NULL, NULL); + } else { + name.append(href); + } + + if (Glib::path_is_absolute(name)) { + fullname = name; + } else if (SP_ACTIVE_DOCUMENT->getBase()) { + fullname = Glib::build_filename(SP_ACTIVE_DOCUMENT->getBase(), name); + } else { + fullname = Glib::build_filename(Glib::get_current_dir(), name); + } + + cmdline.append(" '"); + cmdline.append(fullname.c_str()); + cmdline.append("'"); + } + + //g_warning("##Command line: %s\n", cmdline.c_str()); + + g_spawn_command_line_async(cmdline.c_str(), &errThing); + + if ( errThing ) { + g_warning("Problem launching editor (%d). %s", errThing->code, errThing->message); + (_desktop->messageStack())->flash(Inkscape::ERROR_MESSAGE, errThing->message); + g_error_free(errThing); + errThing = 0; + } +} + +void ContextMenu::ImageTraceBitmap(void) +{ + INKSCAPE.dialogs_unhide(); + _desktop->_dlg_mgr->showDialog("Trace"); +} + +void ContextMenu::ImageTracePixelArt(void) +{ + INKSCAPE.dialogs_unhide(); + _desktop->_dlg_mgr->showDialog("PixelArt"); +} + +void ContextMenu::ImageEmbed(void) +{ + if (_desktop->selection->isEmpty()) { + _desktop->selection->set(_item); + } + + Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" ); + if (verb) { + SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop)); + if (action) { + sp_action_perform(action, NULL); + } + } +} + +void ContextMenu::ImageExtract(void) +{ + if (_desktop->selection->isEmpty()) { + _desktop->selection->set(_item); + } + + Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" ); + if (verb) { + SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop)); + if (action) { + sp_action_perform(action, NULL); + } + } +} + +void ContextMenu::MakeShapeMenu (void) +{ + Gtk::MenuItem* mi; + + /* Item dialog */ + mi = Gtk::manage(new Gtk::MenuItem(_("_Fill and Stroke..."), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings)); + mi->show(); + insert(*mi,positionOfLastDialog++); +} + +void ContextMenu::FillSettings(void) +{ + if (_desktop->selection->isEmpty()) { + _desktop->selection->set(_item); + } + + _desktop->_dlg_mgr->showDialog("FillAndStroke"); +} + +void ContextMenu::MakeTextMenu (void) +{ + Gtk::MenuItem* mi; + + /* Fill and Stroke dialog */ + mi = Gtk::manage(new Gtk::MenuItem(_("_Fill and Stroke..."), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings)); + mi->show(); + insert(*mi,positionOfLastDialog++); + + /* Edit Text dialog */ + mi = Gtk::manage(new Gtk::MenuItem(_("_Text and Font..."), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::TextSettings)); + mi->show(); + insert(*mi,positionOfLastDialog++); + + /* Spellcheck dialog */ + mi = Gtk::manage(new Gtk::MenuItem(_("Check Spellin_g..."), 1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SpellcheckSettings)); + mi->show(); + insert(*mi,positionOfLastDialog++); +} + +void ContextMenu::TextSettings (void) +{ + if (_desktop->selection->isEmpty()) { + _desktop->selection->set(_item); + } + + _desktop->_dlg_mgr->showDialog("TextFont"); +} + +void ContextMenu::SpellcheckSettings (void) +{ + if (_desktop->selection->isEmpty()) { + _desktop->selection->set(_item); + } + + _desktop->_dlg_mgr->showDialog("SpellCheck"); +} +/* + 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/contextmenu.h b/src/ui/contextmenu.h new file mode 100644 index 000000000..faae6358f --- /dev/null +++ b/src/ui/contextmenu.h @@ -0,0 +1,218 @@ +#ifndef SEEN_CONTEXTMENU_H +#define SEEN_CONTEXTMENU_H + +/* + * Context menu + * + * Authors: + * Lauris Kaplinski <lauris@kaplinski.com> + * Frank Felfe <innerspace@iname.com> + * Abhishek Sharma + * Kris De Gussem <Kris.DeGussem@gmail.com> + * + * Copyright (C) 2012 Kris De Gussem + * Copyright (C) 1999-2002 authors + * Copyright (C) 2001-2002 Ximian, Inc. + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include <gtkmm/menu.h> + +class SPDesktop; +class SPItem; +class SPObject; + +namespace Gtk { +class SeparatorMenuItem; +} + +namespace Inkscape { +class Verb; +} + +/** + * Implements the Inkscape context menu. + * + * For the context menu implementation, the ContextMenu class stores the object + * that was selected in a private data member. This should be farely safe to do + * and a pointer to the SPItem as well as SPObject class are kept. + * All callbacks of the context menu entries are implemented as private + * functions. + * + * @todo add callbacks to destroy the context menu when it is closed (=key or mouse button pressed out of the scope of the context menu) + */ +class ContextMenu : public Gtk::Menu +{ + public: + /** + * The ContextMenu constructor contains all code to create and show the + * menu entries (aka child widgets). + * + * @param desktop pointer to the desktop the user is currently working on. + * @param item SPItem pointer to the object selected at the time the ContextMenu is created. + */ + ContextMenu(SPDesktop *desktop, SPItem *item); + ~ContextMenu(void); + + private: + SPItem *_item; // pointer to the object selected at the time the ContextMenu is created + SPObject *_object; // pointer to the object selected at the time the ContextMenu is created + SPDesktop *_desktop; //pointer to the desktop the user was currently working on at the time the ContextMenu is created + + int positionOfLastDialog; + + Gtk::MenuItem MIGroup; //menu entry to enter a group + Gtk::MenuItem MIParent; //menu entry to leave a group + + /** + * auxiliary function that adds a separator line in the context menu + */ + Gtk::SeparatorMenuItem* AddSeparator(void); + + /** + * c++ified version of sp_ui_menu_append_item. + * + * @see sp_ui_menu_append_item_from_verb and synchronize/drop that function when c++ifying other code in interface.cpp + */ + void AppendItemFromVerb(Inkscape::Verb *verb); + + /** + * main function which is responsible for creating the context sensitive menu items, + * calls subfunctions below to create the menu entry widgets. + */ + void MakeObjectMenu (void); + /** + * creates menu entries for an SP_TYPE_ITEM object + */ + void MakeItemMenu (void); + /** + * creates menu entries for a grouped object + */ + void MakeGroupMenu (void); + /** + * creates menu entries for an anchor object + */ + void MakeAnchorMenu (void); + /** + * creates menu entries for a bitmap image object + */ + void MakeImageMenu (void); + /** + * creates menu entries for a shape object + */ + void MakeShapeMenu (void); + /** + * creates menu entries for a text object + */ + void MakeTextMenu (void); + + void EnterGroup(Gtk::MenuItem* mi); + void LeaveGroup(void); + void LockSelected(void); + void HideSelected(void); + void UnLockBelow(std::vector<SPItem *> items); + void UnHideBelow(std::vector<SPItem *> items); + ////////////////////////////////////////// + //callbacks for the context menu entries of an SP_TYPE_ITEM object + void ItemProperties(void); + void ItemSelectThis(void); + void ItemMoveTo(void); + void SelectSameFillStroke(void); + void SelectSameFillColor(void); + void SelectSameStrokeColor(void); + void SelectSameStrokeStyle(void); + void SelectSameObjectType(void); + void ItemCreateLink(void); + void CreateGroupClip(void); + void SetMask(void); + void ReleaseMask(void); + void SetClip(void); + void ReleaseClip(void); + ////////////////////////////////////////// + + + /** + * callback, is executed on clicking the anchor "Group" and "Ungroup" menu entry + */ + void ActivateUngroupPopSelection(void); + void ActivateUngroup(void); + void ActivateGroup(void); + + void AnchorLinkProperties(void); + /** + * placeholder for callback to be executed on clicking the anchor "Follow link" context menu entry + * @todo add code to follow link externally + */ + void AnchorLinkFollow(void); + + /** + * callback, is executed on clicking the anchor "Link remove" menu entry + */ + void AnchorLinkRemove(void); + + + /** + * callback, opens the image properties dialog and is executed on clicking the context menu entry with similar name + */ + void ImageProperties(void); + + /** + * callback, is executed on clicking the image "Edit Externally" menu entry + */ + void ImageEdit(void); + + /** + * auxiliary function that loads the external image editor name from the settings. + */ + Glib::ustring getImageEditorName(); + + /** + * callback, is executed on clicking the "Embed Image" menu entry + */ + void ImageEmbed(void); + + /** + * callback, is executed on clicking the "Trace Bitmap" menu entry + */ + void ImageTraceBitmap(void); + + /** + * callback, is executed on clicking the "Trace Pixel Art" menu entry + */ + void ImageTracePixelArt(void); + + /** + * callback, is executed on clicking the "Extract Image" menu entry + */ + void ImageExtract(void); + + + /** + * callback, is executed on clicking the "Fill and Stroke" menu entry + */ + void FillSettings(void); + + + /** + * callback, is executed on clicking the "Text and Font" menu entry + */ + void TextSettings(void); + + /** + * callback, is executed on clicking the "Check spelling" menu entry + */ + void SpellcheckSettings(void); +}; +#endif // SEEN_CONTEXT_MENU_H + +/* + 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/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index 805bfb562..9b99dde6b 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -107,8 +107,21 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) { g_strdup_printf("<small>Inkscape %s</small>", Inkscape::version_string); label->set_markup(label_text); + +#if WITH_GTKMM_3_10 + label->set_halign(Gtk::ALIGN_END); + label->set_valign(Gtk::ALIGN_CENTER); +#else label->set_alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER); +#endif + +#if WITH_GTKMM_3_12 + label->set_margin_start(5); + label->set_margin_end(5); +#else label->set_padding(5,0); +#endif + g_free(label_text); label->set_selectable(true); label->show(); @@ -118,8 +131,22 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) { "<a href=\"https://www.inkscape.org\">https://www.inkscape.org</a>"; link->set_markup(website_link); + +#if WITH_GTKMM_3_10 + link->set_halign(Gtk::ALIGN_END); +#else link->set_alignment(Gtk::ALIGN_END); +#endif + +#if WITH_GTKMM_3_12 + label->set_margin_start(5); + label->set_margin_end(5); + label->set_margin_top(5); + label->set_margin_bottom(5); +#else link->set_padding(5,5); +#endif + link->set_selectable(true); link->show(); diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 1c88fc849..27bfa681f 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -41,7 +41,6 @@ #include "ui/tool/multi-path-manipulator.h" #include "ui/tool/control-point-selection.h" #include "verbs.h" -#include "widgets/icon.h" #include "sp-root.h" #include "document-undo.h" #include "desktop.h" @@ -64,7 +63,8 @@ Action::Action(const Glib::ustring &id, _id(id), _parent(parent) { - Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( _id, Inkscape::ICON_SIZE_LARGE_TOOLBAR) ); + Gtk::Image* pIcon = Gtk::manage(new Gtk::Image()); + pIcon->set_from_icon_name( _id, Gtk::ICON_SIZE_LARGE_TOOLBAR); Gtk::Button * pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); diff --git a/src/ui/dialog/calligraphic-profile-rename.cpp b/src/ui/dialog/calligraphic-profile-rename.cpp index 36570e769..321df04b0 100644 --- a/src/ui/dialog/calligraphic-profile-rename.cpp +++ b/src/ui/dialog/calligraphic-profile-rename.cpp @@ -36,7 +36,8 @@ CalligraphicProfileRename::CalligraphicProfileRename() : _profile_name_entry.set_activates_default(true); _profile_name_label.set_label(_("Profile name:")); - _profile_name_label.set_alignment(1.0, 0.5); + _profile_name_label.set_halign(Gtk::ALIGN_END); + _profile_name_label.set_valign(Gtk::ALIGN_CENTER); _layout_table->attach(_profile_name_label, 0, 0, 1, 1); diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 3cdcf594a..cef3c0c71 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -49,7 +49,6 @@ #include "ui/widget/spinbutton.h" #include "unclump.h" #include "verbs.h" -#include "widgets/icon.h" using Inkscape::DocumentUndo; using Inkscape::Util::unit_table; @@ -2678,7 +2677,7 @@ GtkWidget * CloneTiler::table_x_y_rand(int values) auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-rows")); + GtkWidget *i = gtk_image_new_from_icon_name (INKSCAPE_ICON("object-rows"), GTK_ICON_SIZE_MENU); gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2); GtkWidget *l = gtk_label_new (""); @@ -2692,7 +2691,7 @@ GtkWidget * CloneTiler::table_x_y_rand(int values) auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); - GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-columns")); + GtkWidget *i = gtk_image_new_from_icon_name (INKSCAPE_ICON("object-columns"), GTK_ICON_SIZE_MENU); gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2); GtkWidget *l = gtk_label_new (""); diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index df4ab6485..8eda9ae08 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -559,7 +559,8 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewS Gtk::Widget* widget = 0; if ( style == PREVIEW_STYLE_BLURB) { Gtk::Label *lbl = new Gtk::Label(def.descr); - lbl->set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + lbl->set_halign(Gtk::ALIGN_START); + lbl->set_valign(Gtk::ALIGN_CENTER); widget = lbl; } else { GtkWidget* eekWidget = eek_preview_new(); diff --git a/src/ui/dialog/cssdialog.cpp b/src/ui/dialog/cssdialog.cpp index 85c804b75..0443d7c44 100644 --- a/src/ui/dialog/cssdialog.cpp +++ b/src/ui/dialog/cssdialog.cpp @@ -13,7 +13,6 @@ #include "cssdialog.h" #include "ui/widget/addtoicon.h" -#include "widgets/icon.h" #include "verbs.h" #include "sp-object.h" #include "selection.h" @@ -122,7 +121,7 @@ void CssDialog::setDesktop(SPDesktop* desktop) void CssDialog::_styleButton(Gtk::Button& btn, char const* iconName, char const* tooltip) { - GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName); + GtkWidget *child = gtk_image_new_from_icon_name(iconName, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_widget_show(child); btn.add(*manage(Glib::wrap(child))); btn.set_relief(Gtk::RELIEF_NONE); diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index 01cd9dd0f..c5392864d 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -26,6 +26,7 @@ #include "ui/dialog/extension-editor.h" #include "ui/dialog/fill-and-stroke.h" #include "ui/dialog/filter-effects-dialog.h" +#include "ui/dialog/filter-editor.h" #include "ui/dialog/find.h" #include "ui/dialog/glyphs.h" #include "ui/dialog/inkscape-preferences.h" @@ -113,6 +114,7 @@ DialogManager::DialogManager() { registerFactory("ExtensionEditor", &create<ExtensionEditor, FloatingBehavior>); registerFactory("FillAndStroke", &create<FillAndStroke, FloatingBehavior>); registerFactory("FilterEffectsDialog", &create<FilterEffectsDialog, FloatingBehavior>); + registerFactory("FilterEditorDialog", &create<FilterEditorDialog, FloatingBehavior>); registerFactory("Find", &create<Find, FloatingBehavior>); registerFactory("Glyphs", &create<GlyphsPanel, FloatingBehavior>); registerFactory("IconPreviewPanel", &create<IconPreviewPanel, FloatingBehavior>); @@ -155,6 +157,7 @@ DialogManager::DialogManager() { registerFactory("ExtensionEditor", &create<ExtensionEditor, DockBehavior>); registerFactory("FillAndStroke", &create<FillAndStroke, DockBehavior>); registerFactory("FilterEffectsDialog", &create<FilterEffectsDialog, DockBehavior>); + registerFactory("FilterEditorDialog", &create<FilterEditorDialog, DockBehavior>); registerFactory("Find", &create<Find, DockBehavior>); registerFactory("Glyphs", &create<GlyphsPanel, DockBehavior>); registerFactory("IconPreviewPanel", &create<IconPreviewPanel, DockBehavior>); diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index f36b13d9b..9037e8377 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -19,6 +19,11 @@ #include "dialog-manager.h" #include <gtkmm/dialog.h> + +#if WITH_GTKMM_3_22 +# include <gdkmm/monitor.h> +#endif + #include <gdk/gdkkeysyms.h> #include "inkscape.h" @@ -161,10 +166,26 @@ void Dialog::read_geometry() resize(w, h); } +#if WITH_GTKMM_3_22 + auto const display = Gdk::Display::get_default(); + auto const monitor = display->get_primary_monitor(); + + // If user hasn't configured a primary monitor, nullptr is returned. + Gdk::Rectangle screen_geometry; + if (monitor) { + monitor->get_geometry(screen_geometry); + } + auto const screen_width = screen_geometry.get_width(); + auto const screen_height = screen_geometry.get_height(); +#else + auto const screen_width = gdk_screen_width(); + auto const screen_height = gdk_screen_width(); +#endif + // If there are stored values for where the dialog should be // located, then restore the dialog to that position. // also check if (x,y) is actually onscreen with the current screen dimensions - if ( (x >= 0) && (y >= 0) && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE)) ) { + if ( (x >= 0) && (y >= 0) && (x < (screen_width-MIN_ONSCREEN_DISTANCE)) && (y < (screen_height-MIN_ONSCREEN_DISTANCE)) ) { move(x, y); } else { // ...otherwise just put it in the middle of the screen diff --git a/src/ui/dialog/dock-behavior.cpp b/src/ui/dialog/dock-behavior.cpp index 02955b9a8..0c8bb3194 100644 --- a/src/ui/dialog/dock-behavior.cpp +++ b/src/ui/dialog/dock-behavior.cpp @@ -19,7 +19,6 @@ #include "inkscape.h" #include "desktop.h" #include "ui/interface.h" -#include "widgets/icon.h" #include "ui/widget/dock.h" #include "verbs.h" #include "dialog.h" @@ -40,9 +39,9 @@ DockBehavior::DockBehavior(Dialog &dialog) : static_cast<Widget::DockItem::State>( Inkscape::Preferences::get()->getInt(_dialog._prefs_path + "/state", UI::Widget::DockItem::DOCKED_STATE)), - static_cast<Widget::DockItem::Placement>( + static_cast<GdlDockPlacement>( Inkscape::Preferences::get()->getInt(_dialog._prefs_path + "/placement", - UI::Widget::DockItem::TOP))) + GDL_DOCK_TOP))) { // Connect signals diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp index dc1958434..74cf9ef0d 100644 --- a/src/ui/dialog/document-metadata.cpp +++ b/src/ui/dialog/document-metadata.cpp @@ -113,9 +113,9 @@ DocumentMetadata::build_metadata() Gtk::Label *label = Gtk::manage (new Gtk::Label); label->set_markup (_("<b>Dublin Core Entities</b>")); - label->set_alignment (0.0); - + label->set_halign(Gtk::ALIGN_START); label->set_valign(Gtk::ALIGN_CENTER); + _page_metadata1.attach(*label, 0, 0, 3, 1); /* add generic metadata entry areas */ @@ -145,7 +145,7 @@ DocumentMetadata::build_metadata() row = 0; Gtk::Label *llabel = Gtk::manage (new Gtk::Label); llabel->set_markup (_("<b>License</b>")); - llabel->set_alignment (0.0); + llabel->set_halign(Gtk::ALIGN_START); llabel->set_valign(Gtk::ALIGN_CENTER); _page_metadata2.attach(*llabel, 0, row, 3, 1); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 8593223c1..7d51653db 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -34,7 +34,6 @@ #include "ui/tools-switch.h" #include "ui/dialog/filedialog.h" #include "verbs.h" -#include "widgets/icon.h" #include "xml/node-event-vector.h" #include "rdf.h" @@ -74,7 +73,7 @@ static Inkscape::XML::NodeEventVector const _repr_events = { static void docprops_style_button(Gtk::Button& btn, char const* iconName) { - GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName); + GtkWidget *child = gtk_image_new_from_icon_name(iconName, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_widget_show( child ); btn.add(*Gtk::manage(Glib::wrap(child))); btn.set_relief(Gtk::RELIEF_NONE); @@ -229,8 +228,13 @@ inline void attach_all(Gtk::Grid &table, Gtk::Widget *const arr[], unsigned cons // this sets the padding for subordinate widgets on the "Page" page if( i==(n-8) || i==(n-10) ) { arr[i+1]->set_hexpand(); +#if WITH_GTKMM_3_12 + arr[i+1]->set_margin_start(20); + arr[i+1]->set_margin_end(20); +#else arr[i+1]->set_margin_left(20); arr[i+1]->set_margin_right(20); +#endif if (yoptions & Gtk::EXPAND) arr[i+1]->set_vexpand(); @@ -260,13 +264,13 @@ inline void attach_all(Gtk::Grid &table, Gtk::Widget *const arr[], unsigned cons } } else if (arr[i]) { Gtk::Label& label = reinterpret_cast<Gtk::Label&>(*arr[i]); - label.set_alignment (0.0); label.set_hexpand(); + label.set_halign(Gtk::ALIGN_START); label.set_valign(Gtk::ALIGN_CENTER); table.attach(label, 0, r, 3, 1); } else { - Gtk::HBox *space = Gtk::manage (new Gtk::HBox); + auto space = Gtk::manage (new Gtk::Box); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); space->set_halign(Gtk::ALIGN_CENTER); @@ -387,26 +391,25 @@ void DocumentProperties::populate_available_profiles(){ _AvailableProfilesListStore->clear(); // Clear any existing items in the combo box // Iterate through the list of profiles and add the name to the combo box. - std::vector<std::pair<std::pair<Glib::ustring, bool>, Glib::ustring> > pairs = ColorProfile::getProfileFilesWithNames(); bool home = true; // initial value doesn't matter, it's just to avoid a compiler warning - for ( std::vector<std::pair<std::pair<Glib::ustring, bool>, Glib::ustring> >::const_iterator it = pairs.begin(); it != pairs.end(); ++it ) { + bool first = true; + for (auto &profile: ColorProfile::getProfileFilesWithNames()) { Gtk::TreeModel::Row row; - Glib::ustring file = it->first.first; - Glib::ustring name = it->second; // add a separator between profiles from the user's home directory and system profiles - if (it != pairs.begin() && it->first.second != home) + if (!first && profile.isInHome != home) { row = *(_AvailableProfilesListStore->append()); row[_AvailableProfilesListColumns.fileColumn] = "<separator>"; row[_AvailableProfilesListColumns.nameColumn] = "<separator>"; row[_AvailableProfilesListColumns.separatorColumn] = true; } - home = it->first.second; + home = profile.isInHome; + first = false; row = *(_AvailableProfilesListStore->append()); - row[_AvailableProfilesListColumns.fileColumn] = file; - row[_AvailableProfilesListColumns.nameColumn] = name; + row[_AvailableProfilesListColumns.fileColumn] = profile.filename; + row[_AvailableProfilesListColumns.nameColumn] = profile.name; row[_AvailableProfilesListColumns.separatorColumn] = false; } } @@ -460,10 +463,11 @@ void DocumentProperties::linkSelectedProfile() g_warning("No color profile available."); return; } - + // Read the filename and description from the list of available profiles Glib::ustring file = (*iter)[_AvailableProfilesListColumns.fileColumn]; Glib::ustring name = (*iter)[_AvailableProfilesListColumns.nameColumn]; + std::vector<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); for (std::vector<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { SPObject* obj = *it; @@ -515,6 +519,9 @@ struct _cmp { } }; +template <typename From, typename To> +struct static_caster { To * operator () (From * value) const { return static_cast<To *>(value); } }; + void DocumentProperties::populate_linked_profiles_box() { _LinkedProfilesListStore->clear(); @@ -522,12 +529,16 @@ void DocumentProperties::populate_linked_profiles_box() if (! current.empty()) { _emb_profiles_observer.set((*(current.begin()))->parent); } - std::set<SPObject *, _cmp> _current (current.begin(), current.end()); - for (std::set<SPObject *, _cmp>::const_iterator it = _current.begin(); it != _current.end(); ++it) { - SPObject* obj = *it; - Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj); + + std::set<Inkscape::ColorProfile *, Inkscape::ColorProfile::pointerComparator> _current; + std::transform(current.begin(), + current.end(), + std::inserter(_current, _current.begin()), + static_caster<SPObject, Inkscape::ColorProfile>()); + + for (auto &profile: _current) { Gtk::TreeModel::Row row = *(_LinkedProfilesListStore->append()); - row[_LinkedProfilesListColumns.nameColumn] = prof->name; + row[_LinkedProfilesListColumns.nameColumn] = profile->name; // row[_LinkedProfilesListColumns.previewColumn] = "Color Preview"; } } @@ -639,9 +650,8 @@ void DocumentProperties::build_cms() _page_cms->set_spacing(4); gint row = 0; - label_link->set_alignment(0.0); - label_link->set_hexpand(); + label_link->set_halign(Gtk::ALIGN_START); label_link->set_valign(Gtk::ALIGN_CENTER); _page_cms->table().attach(*label_link, 0, row, 3, 1); @@ -662,9 +672,8 @@ void DocumentProperties::build_cms() row++; - label_avail->set_alignment(0.0); - label_avail->set_hexpand(); + label_avail->set_halign(Gtk::ALIGN_START); label_avail->set_valign(Gtk::ALIGN_CENTER); _page_cms->table().attach(*label_avail, 0, row, 3, 1); @@ -676,8 +685,13 @@ void DocumentProperties::build_cms() _link_btn.set_halign(Gtk::ALIGN_CENTER); _link_btn.set_valign(Gtk::ALIGN_CENTER); +#if WITH_GTKMM_3_12 + _link_btn.set_margin_start(2); + _link_btn.set_margin_end(2); +#else _link_btn.set_margin_left(2); _link_btn.set_margin_right(2); +#endif _page_cms->table().attach(_link_btn, 1, row, 1, 1); _unlink_btn.set_halign(Gtk::ALIGN_CENTER); @@ -748,8 +762,8 @@ void DocumentProperties::build_scripting() _page_external_scripts->set_spacing(4); gint row = 0; - label_external->set_alignment(0.0); label_external->set_hexpand(); + label_external->set_halign(Gtk::ALIGN_START); label_external->set_valign(Gtk::ALIGN_CENTER); _page_external_scripts->table().attach(*label_external, 0, row, 3, 1); @@ -776,8 +790,15 @@ void DocumentProperties::build_scripting() _external_add_btn.set_halign(Gtk::ALIGN_CENTER); _external_add_btn.set_valign(Gtk::ALIGN_CENTER); + +#if WITH_GTKMM_3_12 + _external_add_btn.set_margin_start(2); + _external_add_btn.set_margin_end(2); +#else _external_add_btn.set_margin_left(2); _external_add_btn.set_margin_right(2); +#endif + _page_external_scripts->table().attach(_external_add_btn, 1, row, 1, 1); _external_remove_btn.set_halign(Gtk::ALIGN_CENTER); @@ -810,8 +831,8 @@ void DocumentProperties::build_scripting() _page_embedded_scripts->set_spacing(4); row = 0; - label_embedded->set_alignment(0.0); label_embedded->set_hexpand(); + label_embedded->set_halign(Gtk::ALIGN_START); label_embedded->set_valign(Gtk::ALIGN_CENTER); _page_embedded_scripts->table().attach(*label_embedded, 0, row, 3, 1); @@ -848,8 +869,8 @@ void DocumentProperties::build_scripting() Gtk::Label *label_embedded_content= Gtk::manage (new Gtk::Label("", Gtk::ALIGN_START)); label_embedded_content->set_markup (_("<b>Content:</b>")); - label_embedded_content->set_alignment(0.0); label_embedded_content->set_hexpand(); + label_embedded_content->set_halign(Gtk::ALIGN_START); label_embedded_content->set_valign(Gtk::ALIGN_CENTER); _page_embedded_scripts->table().attach(*label_embedded_content, 0, row, 3, 1); @@ -917,8 +938,7 @@ void DocumentProperties::build_metadata() Gtk::Label *label = Gtk::manage (new Gtk::Label); label->set_markup (_("<b>Dublin Core Entities</b>")); - label->set_alignment (0.0); - + label->set_halign(Gtk::ALIGN_START); label->set_valign(Gtk::ALIGN_CENTER); _page_metadata1->table().attach (*label, 0,0,3,1); @@ -964,8 +984,7 @@ void DocumentProperties::build_metadata() row = 0; Gtk::Label *llabel = Gtk::manage (new Gtk::Label); llabel->set_markup (_("<b>License</b>")); - llabel->set_alignment (0.0); - + llabel->set_halign(Gtk::ALIGN_START); llabel->set_valign(Gtk::ALIGN_CENTER); _page_metadata2->table().attach(*llabel, 0, row, 3, 1); @@ -1429,8 +1448,10 @@ DocumentProperties::_createPageTabLabel(const Glib::ustring& label, const char * { Gtk::HBox *_tab_label_box = Gtk::manage(new Gtk::HBox(false, 0)); _tab_label_box->set_spacing(4); - _tab_label_box->pack_start(*Glib::wrap(sp_icon_new(Inkscape::ICON_SIZE_DECORATION, - label_image))); + + auto img = Gtk::manage(new Gtk::Image()); + img->set_from_icon_name(label_image, Gtk::ICON_SIZE_MENU); + _tab_label_box->pack_start(*img); Gtk::Label *_tab_label = Gtk::manage(new Gtk::Label(label, true)); _tab_label_box->pack_start(*_tab_label); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 1bb952de4..56f3a29c0 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -54,6 +54,7 @@ #include "extension/db.h" #include "io/sys.h" +#include "io/resource.h" #include "helper/png-write.h" @@ -502,7 +503,8 @@ Glib::RefPtr<Gtk::Adjustment> Export::createSpinbutton( gchar const * /*key*/, f if (!ll.empty()) { l = new Gtk::Label(ll,true); - l->set_alignment (1.0, 0.5); + l->set_halign(Gtk::ALIGN_END); + l->set_valign(Gtk::ALIGN_CENTER); l->set_hexpand(); l->set_vexpand(); t->attach(*l, x + pos, y, 1, 1); @@ -525,7 +527,8 @@ Glib::RefPtr<Gtk::Adjustment> Export::createSpinbutton( gchar const * /*key*/, f if (!lr.empty()) { l = new Gtk::Label(lr,true); - l->set_alignment (0.0, 0.5); + l->set_halign(Gtk::ALIGN_START); + l->set_valign(Gtk::ALIGN_CENTER); l->set_hexpand(); l->set_vexpand(); t->attach(*l, x + pos, y, 1, 1); @@ -564,7 +567,7 @@ Glib::ustring Export::create_filepath_from_id (Glib::ustring id, const Glib::ust } if (directory.empty()) { - directory = INKSCAPE.homedir_path(NULL); + directory = Inkscape::IO::Resource::homedir_path(NULL); } Glib::ustring filename = Glib::build_filename(directory, id+".png"); diff --git a/src/ui/dialog/extension-editor.cpp b/src/ui/dialog/extension-editor.cpp index 84840f22d..248f4f67f 100644 --- a/src/ui/dialog/extension-editor.cpp +++ b/src/ui/dialog/extension-editor.cpp @@ -19,7 +19,6 @@ #include <glibmm/i18n.h> #include <gtkmm/frame.h> -#include <gtkmm/alignment.h> #include <gtkmm/notebook.h> #include "verbs.h" diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 92e9ce834..b69e9ce97 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -27,6 +27,7 @@ #include "ui/dialog-events.h" #include "ui/interface.h" #include "io/sys.h" +#include "io/resource.h" #include "path-prefix.h" #include "preferences.h" @@ -1038,13 +1039,12 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk(Gtk::Window &parentWindow, const Gl } // allow easy access to the user's own templates folder - gchar *templates = Inkscape::Application::profile_path("templates"); + using namespace Inkscape::IO::Resource; + char const *templates = Inkscape::IO::Resource::get_path(USER, TEMPLATES); if (Inkscape::IO::file_test(templates, G_FILE_TEST_EXISTS) && Inkscape::IO::file_test(templates, G_FILE_TEST_IS_DIR) && g_path_is_absolute(templates)) { add_shortcut_folder(templates); } - g_free(templates); - // if (extension == NULL) // checkbox.set_sensitive(FALSE); diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp index 0b3b468e9..b271c951b 100644 --- a/src/ui/dialog/fill-and-stroke.cpp +++ b/src/ui/dialog/fill-and-stroke.cpp @@ -28,7 +28,6 @@ #include "ui/icon-names.h" #include "verbs.h" #include "widgets/fill-style.h" -#include "widgets/icon.h" #include "widgets/paint-selector.h" #include "widgets/stroke-style.h" @@ -173,8 +172,10 @@ Gtk::HBox& FillAndStroke::_createPageTabLabel(const Glib::ustring& label, const char *label_image) { Gtk::HBox *_tab_label_box = Gtk::manage(new Gtk::HBox(false, 4)); - _tab_label_box->pack_start(*Glib::wrap(sp_icon_new(Inkscape::ICON_SIZE_DECORATION, - label_image))); + + auto img = Gtk::manage(new Gtk::Image()); + img->set_from_icon_name(label_image, Gtk::ICON_SIZE_MENU); + _tab_label_box->pack_start(*img); Gtk::Label *_tab_label = Gtk::manage(new Gtk::Label(label, true)); _tab_label_box->pack_start(*_tab_label); diff --git a/src/ui/dialog/filter-editor.cpp b/src/ui/dialog/filter-editor.cpp new file mode 100644 index 000000000..1b532578d --- /dev/null +++ b/src/ui/dialog/filter-editor.cpp @@ -0,0 +1,128 @@ +/** + * @file + * Filter Effects dialog. + */ +/* Authors: + * Marc Jeanmougin + * + * Copyright (C) 2017 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "dialog-manager.h" + +#include <gdkmm/display.h> +#if GTK_CHECK_VERSION(3, 20, 0) +# include <gdkmm/seat.h> +#else +# include <gdkmm/devicemanager.h> +#endif + +#include "ui/widget/spinbutton.h" + +#include <glibmm/i18n.h> +#include <glibmm/stringutils.h> +#include <glibmm/main.h> +#include <glibmm/convert.h> +#include <glibmm/error.h> + +#include "desktop.h" + +#include "document.h" +#include "document-undo.h" +#include "filter-chemistry.h" +#include "filter-editor.h" +#include "filter-enums.h" +#include "inkscape.h" +#include "filters/blend.h" +#include "filters/colormatrix.h" +#include "filters/componenttransfer.h" +#include "filters/componenttransfer-funcnode.h" +#include "filters/convolvematrix.h" +#include "filters/distantlight.h" +#include "filters/merge.h" +#include "filters/mergenode.h" +#include "filters/pointlight.h" +#include "filters/spotlight.h" + +#include "style.h" +#include "svg/svg-color.h" +#include "ui/dialog/filedialog.h" +#include "verbs.h" + +#include "io/sys.h" +#include "io/resource.h" +#include "selection-chemistry.h" + +#include <string> + +#include <gtkmm.h> + +using namespace Inkscape::Filters; +using namespace Inkscape::IO::Resource; +namespace Inkscape { +namespace UI { +namespace Dialog { + +FilterEditorDialog::FilterEditorDialog() : UI::Widget::Panel("", "/dialogs/filtereffects", SP_VERB_DIALOG_FILTER_EFFECTS) +{ + + const std::string req_widgets[] = {"FilterEditor", "FilterList", "FilterFERX", "FilterFERY", "FilterFERH", "FilterFERW", "FilterPreview", "FilterPrimitiveDescImage", "FilterPrimitiveList", "FilterPrimitiveDescText", "FilterPrimitiveAdd"}; + Glib::ustring gladefile = get_filename(UIS, "filter-editor.glade"); + try { + builder = Gtk::Builder::create_from_file(gladefile); + } catch(const Glib::Error& ex) { + g_warning("Glade file loading failed for filter effect dialog"); + return; + } + + Gtk::Object* test; + for(std::string w:req_widgets) { + builder->get_widget(w,test); + if(!test){ + g_warning("Required widget %s does not exist", w.c_str()); + return; + } + } + + builder->get_widget("FilterEditor", FilterEditor); + _getContents()->add(*FilterEditor); + +//test + Gtk::ComboBox *OptionList; + builder->get_widget("OptionList",OptionList); + FilterStore = builder->get_object("FilterStore"); + Glib::RefPtr<Gtk::ListStore> fs = Glib::RefPtr<Gtk::ListStore>::cast_static(FilterStore); + Gtk::TreeModel::Row row = *(fs->append()); + + + + + +} +FilterEditorDialog::~FilterEditorDialog(){} + + + + + + +} // Never put these namespaces together unless you are using gcc 6+ +} +} // P.S. This is for Inkscape::UI::Dialog + +/* + 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/dialog/filter-editor.h b/src/ui/dialog/filter-editor.h new file mode 100644 index 000000000..6acb83f02 --- /dev/null +++ b/src/ui/dialog/filter-editor.h @@ -0,0 +1,53 @@ +/** @file + * @brief Filter Editor dialog + */ +/* Authors: + * Marc Jeanmougin + * + * Copyright (C) 2017 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_DIALOG_FILTER_EDITOR_H +#define INKSCAPE_UI_DIALOG_FILTER_EDITOR_H + +#include "attributes.h" +#include "ui/widget/panel.h" +#include "sp-filter.h" + +#include <gtkmm/notebook.h> +#include <gtkmm/sizegroup.h> +#include <gtkmm/builder.h> +#include <gtkmm/comboboxtext.h> +#include <gtkmm/combobox.h> +#include <gtkmm/drawingarea.h> +#include <gtkmm/liststore.h> + +#include <gtkmm/paned.h> +#include <gtkmm/scrolledwindow.h> +#include <gtkmm/treeview.h> + +namespace Inkscape { +namespace UI { +namespace Dialog { + +class FilterEditorDialog : public UI::Widget::Panel { +public: + + FilterEditorDialog(); + ~FilterEditorDialog(); + + static FilterEditorDialog &getInstance() + { return *new FilterEditorDialog(); } + +// void set_attrs_locked(const bool); +private: + Glib::RefPtr<Gtk::Builder> builder; + Glib::RefPtr<Glib::Object> FilterStore; + Gtk::Box *FilterEditor; +}; +} +} +} +#endif diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 80dc08ccf..01d66d588 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1921,7 +1921,7 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair auto sc = gtk_widget_get_style_context(GTK_WIDGET(gobj())); GdkRGBA bg_color, fg_color; - gtk_style_context_get_background_color(sc, GTK_STATE_FLAG_NORMAL, &bg_color); + gdk_rgba_parse(&bg_color, "f0f0f0"); // Fix bg as a light gray gtk_style_context_get_color(sc, GTK_STATE_FLAG_NORMAL, &fg_color); GdkRGBA mid_color = {(bg_color.red + fg_color.red)/2.0, @@ -1930,7 +1930,7 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair (bg_color.alpha + fg_color.alpha)/2.0}; GdkRGBA bg_color_active, fg_color_active; - gtk_style_context_get_background_color(sc, GTK_STATE_FLAG_ACTIVE, &bg_color_active); + gdk_rgba_parse(&bg_color, "f0f0f0"); // Fix bg as a light gray gtk_style_context_get_color(sc, GTK_STATE_FLAG_ACTIVE, &fg_color_active); GdkRGBA mid_color_active = {(bg_color_active.red + fg_color_active.red)/2.0, @@ -2114,7 +2114,7 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai auto sc = gtk_widget_get_style_context(GTK_WIDGET(gobj())); GdkRGBA bg_color, fg_color; - gtk_style_context_get_background_color(sc, GTK_STATE_FLAG_NORMAL, &bg_color); + gdk_rgba_parse(&bg_color, "f0f0f0"); // Fix bg as a light gray gtk_style_context_get_color(sc, GTK_STATE_FLAG_NORMAL, &fg_color); GdkRGBA mid_color = {(bg_color.red + fg_color.red)/2.0, @@ -2649,8 +2649,10 @@ FilterEffectsDialog::FilterEffectsDialog() hpaned->pack2(*_primitive_box); _getContents()->add(*hpaned); - _infobox_icon.set_alignment(0, 0); - _infobox_desc.set_alignment(0, 0); + _infobox_icon.set_halign(Gtk::ALIGN_START); + _infobox_icon.set_valign(Gtk::ALIGN_START); + _infobox_desc.set_halign(Gtk::ALIGN_START); + _infobox_desc.set_valign(Gtk::ALIGN_START); _infobox_desc.set_justify(Gtk::JUSTIFY_LEFT); _infobox_desc.set_line_wrap(true); _infobox_desc.set_size_request(200, -1); diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index 32fabb741..e410a88f9 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -132,11 +132,7 @@ private: Gtk::Button _add; Glib::RefPtr<Gtk::Menu> _menu; sigc::signal<void> _signal_filter_changed; -#if __cplusplus <= 199711L - std::auto_ptr<Inkscape::XML::SignalObserver> _observer; -#else std::unique_ptr<Inkscape::XML::SignalObserver> _observer; -#endif }; class PrimitiveColumns : public Gtk::TreeModel::ColumnRecord @@ -244,11 +240,7 @@ private: sigc::connection _scroll_connection; int _autoscroll_y; int _autoscroll_x; -#if __cplusplus <= 199711L - std::auto_ptr<Inkscape::XML::SignalObserver> _observer; -#else std::unique_ptr<Inkscape::XML::SignalObserver> _observer; -#endif int _input_type_width; int _input_type_height; }; diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 9c1236ca9..f858a4d55 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -12,7 +12,6 @@ #include "glyphs.h" #include <glibmm/i18n.h> -#include <gtkmm/alignment.h> #include <gtkmm/comboboxtext.h> #include <gtkmm/grid.h> #include <gtkmm/iconview.h> @@ -356,7 +355,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : table->attach( *Gtk::manage(label), 0, row, 1, 1); - scriptCombo = new Gtk::ComboBoxText(); + scriptCombo = Gtk::manage(new Gtk::ComboBoxText()); for (std::map<GUnicodeScript, Glib::ustring>::iterator it = getScriptToName().begin(); it != getScriptToName().end(); ++it) { scriptCombo->append(it->second); @@ -365,11 +364,11 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : scriptCombo->set_active_text(getScriptToName()[G_UNICODE_SCRIPT_INVALID_CODE]); sigc::connection conn = scriptCombo->signal_changed().connect(sigc::mem_fun(*this, &GlyphsPanel::rebuild)); instanceConns.push_back(conn); - Gtk::Alignment *align = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_START, Gtk::ALIGN_START, 0.0, 0.0)); - align->add(*Gtk::manage(scriptCombo)); - align->set_hexpand(); - table->attach( *align, 1, row, 1, 1); + scriptCombo->set_halign(Gtk::ALIGN_START); + scriptCombo->set_valign(Gtk::ALIGN_START); + scriptCombo->set_hexpand(); + table->attach(*scriptCombo, 1, row, 1, 1); } row++; @@ -380,7 +379,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : auto label = new Gtk::Label(_("Range: ")); table->attach( *Gtk::manage(label), 0, row, 1, 1); - rangeCombo = new Gtk::ComboBoxText(); + rangeCombo = Gtk::manage(new Gtk::ComboBoxText()); for ( std::vector<NamedRange>::iterator it = getRanges().begin(); it != getRanges().end(); ++it ) { rangeCombo->append(it->second); } @@ -388,10 +387,11 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : rangeCombo->set_active_text(getRanges()[1].second); sigc::connection conn = rangeCombo->signal_changed().connect(sigc::mem_fun(*this, &GlyphsPanel::rebuild)); instanceConns.push_back(conn); - Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_START, Gtk::ALIGN_START, 0.0, 0.0); - align->add(*Gtk::manage(rangeCombo)); - align->set_hexpand(); - table->attach( *Gtk::manage(align), 1, row, 1, 1); + + rangeCombo->set_halign(Gtk::ALIGN_START); + rangeCombo->set_valign(Gtk::ALIGN_START); + rangeCombo->set_hexpand(); + table->attach(*rangeCombo, 1, row, 1, 1); } row++; diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 9ec8d3148..3cbc1b6e9 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -28,7 +28,6 @@ #include "document.h" #include "document-undo.h" -#include "widgets/icon.h" #include "desktop.h" //#include "sp-item-transform.h" FIXME #include "ui/dialog/tile.h" // for Inkscape::UI::Dialog::ArrangeDialog @@ -611,6 +610,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) NoOfRowsLabel.set_text_with_mnemonic(_("_Rows:")); NoOfRowsLabel.set_mnemonic_widget(NoOfRowsSpinner); + NoOfRowsBox.set_orientation(Gtk::ORIENTATION_VERTICAL); NoOfRowsBox.pack_start(NoOfRowsLabel, false, false, MARGIN); NoOfRowsSpinner.set_digits(0); @@ -641,6 +641,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) /*#### Label for X ####*/ padXByYLabel.set_label(" "); + XByYLabelVBox.set_orientation(Gtk::ORIENTATION_VERTICAL); XByYLabelVBox.pack_start(padXByYLabel, false, false, MARGIN); XByYLabel.set_markup(" × "); XByYLabelVBox.pack_start(XByYLabel, false, false, MARGIN); @@ -651,6 +652,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) NoOfColsLabel.set_text_with_mnemonic(_("_Columns:")); NoOfColsLabel.set_mnemonic_widget(NoOfColsSpinner); + NoOfColsBox.set_orientation(Gtk::ORIENTATION_VERTICAL); NoOfColsBox.pack_start(NoOfColsLabel, false, false, MARGIN); NoOfColsSpinner.set_digits(0); @@ -677,6 +679,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) SpinsHBox.pack_start(NoOfColsBox, false, false, MARGIN); + TileBox.set_orientation(Gtk::ORIENTATION_VERTICAL); TileBox.pack_start(SpinsHBox, false, false, MARGIN); VertAlign = prefs->getInt("/dialogs/gridtiler/VertAlign", 1); @@ -684,7 +687,8 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) // Anchor selection widget AlignLabel.set_label(_("Alignment:")); - AlignLabel.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + AlignLabel.set_halign(Gtk::ALIGN_START); + AlignLabel.set_valign(Gtk::ALIGN_CENTER); AlignmentSelector.setAlignment(HorizAlign, VertAlign); AlignmentSelector.on_selectionChanged().connect(sigc::mem_fun(*this, &GridArrangeTab::Align_changed)); TileBox.pack_start(AlignLabel, false, false, MARGIN); diff --git a/src/ui/dialog/grid-arrange-tab.h b/src/ui/dialog/grid-arrange-tab.h index 891849f1a..93bc38218 100644 --- a/src/ui/dialog/grid-arrange-tab.h +++ b/src/ui/dialog/grid-arrange-tab.h @@ -73,7 +73,7 @@ private: bool userHidden; bool updating; - Gtk::VBox TileBox; + Gtk::Box TileBox; Gtk::Button *TileOkButton; Gtk::Button *TileCancelButton; @@ -81,22 +81,22 @@ private: Gtk::Label SelectionContentsLabel; - Gtk::HBox AlignHBox; - Gtk::HBox SpinsHBox; + Gtk::Box AlignHBox; + Gtk::Box SpinsHBox; // Number per Row - Gtk::VBox NoOfColsBox; + Gtk::Box NoOfColsBox; Gtk::Label NoOfColsLabel; Inkscape::UI::Widget::SpinButton NoOfColsSpinner; bool AutoRowSize; Gtk::CheckButton RowHeightButton; - Gtk::VBox XByYLabelVBox; + Gtk::Box XByYLabelVBox; Gtk::Label padXByYLabel; Gtk::Label XByYLabel; // Number per Column - Gtk::VBox NoOfRowsBox; + Gtk::Box NoOfRowsBox; Gtk::Label NoOfRowsLabel; Inkscape::UI::Widget::SpinButton NoOfRowsSpinner; bool AutoColSize; @@ -121,15 +121,11 @@ private: bool ManualSpacing; // Row height - Gtk::VBox RowHeightVBox; - Gtk::HBox RowHeightBox; - Gtk::Label RowHeightLabel; + Gtk::Box RowHeightBox; Inkscape::UI::Widget::SpinButton RowHeightSpinner; // Column width - Gtk::VBox ColumnWidthVBox; - Gtk::HBox ColumnWidthBox; - Gtk::Label ColumnWidthLabel; + Gtk::Box ColumnWidthBox; Inkscape::UI::Widget::SpinButton ColumnWidthSpinner; }; diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 9c8b14953..f0de5ad0d 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -167,10 +167,12 @@ void GuidelinePropertiesDialog::_setup() { mainVBox->pack_start(_layout_table, false, false, 0); _label_name.set_label("foo0"); - _label_name.set_alignment(0, 0.5); + _label_name.set_halign(Gtk::ALIGN_START); + _label_name.set_valign(Gtk::ALIGN_CENTER); _label_descr.set_label("foo1"); - _label_descr.set_alignment(0, 0.5); + _label_descr.set_halign(Gtk::ALIGN_START); + _label_descr.set_valign(Gtk::ALIGN_CENTER); _label_name.set_halign(Gtk::ALIGN_FILL); _label_name.set_valign(Gtk::ALIGN_FILL); diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 19050fb1d..991139aa8 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -24,16 +24,18 @@ #include <glibmm/timer.h> #include <glibmm/main.h> -#include <gtkmm/alignment.h> #include <gtkmm/checkbutton.h> #include <gtkmm/frame.h> #include "ui/widget/frame.h" #include "desktop.h" +#include "display/cairo-utils.h" #include "display/drawing.h" +#include "display/drawing-context.h" #include "document.h" #include "inkscape.h" +#include "sp-namedview.h" #include "sp-root.h" #include "verbs.h" @@ -41,7 +43,6 @@ extern "C" { // takes doc, drawing, icon, and icon name to produce pixels -// this is defined in widgets/icon.cpp guchar * sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing, const gchar *name, unsigned int psize, unsigned &stride); @@ -195,12 +196,11 @@ IconPreviewPanel::IconPreviewPanel() : buttons[i]->signal_clicked().connect( sigc::bind<int>( sigc::mem_fun(*this, &IconPreviewPanel::on_button_clicked), i) ); - - Gtk::Alignment *align = Gtk::manage(new Gtk::Alignment(0.5, 0.5, 0, 0)); - align->add(*buttons[i]); + buttons[i]->set_halign(Gtk::ALIGN_CENTER); + buttons[i]->set_valign(Gtk::ALIGN_CENTER); if ( !pack || ( (avail == 0) && (previous == 0) ) ) { - verts->pack_end(*align, Gtk::PACK_SHRINK); + verts->pack_end(*(buttons[i]), Gtk::PACK_SHRINK); previous = sizes[i]; avail = sizes[i]; } else { @@ -217,12 +217,12 @@ IconPreviewPanel::IconPreviewPanel() : avail = previous; verts->pack_end(*horiz, Gtk::PACK_SHRINK); } - horiz->pack_start(*align, Gtk::PACK_EXPAND_WIDGET); + horiz->pack_start(*(buttons[i]), Gtk::PACK_EXPAND_WIDGET); avail -= sizes[i]; avail -= pad; // a little extra for padding } else { horiz = 0; - verts->pack_end(*align, Gtk::PACK_SHRINK); + verts->pack_end(*(buttons[i]), Gtk::PACK_SHRINK); } } } @@ -428,6 +428,190 @@ void IconPreviewPanel::modeToggled() refreshPreview(); } +void overlayPixels(guchar *px, int width, int height, int stride, + unsigned r, unsigned g, unsigned b) +{ + int bytesPerPixel = 4; + int spacing = 4; + for ( int y = 0; y < height; y += spacing ) { + guchar *ptr = px + y * stride; + for ( int x = 0; x < width; x += spacing ) { + *(ptr++) = r; + *(ptr++) = g; + *(ptr++) = b; + *(ptr++) = 0xff; + + ptr += bytesPerPixel * (spacing - 1); + } + } + + if ( width > 1 && height > 1 ) { + // point at the last pixel + guchar *ptr = px + ((height-1) * stride) + ((width - 1) * bytesPerPixel); + + if ( width > 2 ) { + px[4] = r; + px[5] = g; + px[6] = b; + px[7] = 0xff; + + ptr[-12] = r; + ptr[-11] = g; + ptr[-10] = b; + ptr[-9] = 0xff; + } + + ptr[-4] = r; + ptr[-3] = g; + ptr[-2] = b; + ptr[-1] = 0xff; + + px[0 + stride] = r; + px[1 + stride] = g; + px[2 + stride] = b; + px[3 + stride] = 0xff; + + ptr[0 - stride] = r; + ptr[1 - stride] = g; + ptr[2 - stride] = b; + ptr[3 - stride] = 0xff; + + if ( height > 2 ) { + ptr[0 - stride * 3] = r; + ptr[1 - stride * 3] = g; + ptr[2 - stride * 3] = b; + ptr[3 - stride * 3] = 0xff; + } + } +} + +// takes doc, drawing, icon, and icon name to produce pixels +extern "C" guchar * +sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing, + gchar const *name, unsigned psize, + unsigned &stride) +{ + bool const dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpSvg"); + guchar *px = NULL; + + if (doc) { + SPObject *object = doc->getObjectById(name); + if (object && SP_IS_ITEM(object)) { + SPItem *item = SP_ITEM(object); + // Find bbox in document + Geom::OptRect dbox = item->documentVisualBounds(); + + if ( object->parent == NULL ) + { + dbox = Geom::Rect(Geom::Point(0, 0), + Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px"))); + } + + /* This is in document coordinates, i.e. pixels */ + if ( dbox ) { + /* Update to renderable state */ + double sf = 1.0; + drawing.root()->setTransform(Geom::Scale(sf)); + drawing.update(); + /* Item integer bbox in points */ + // NOTE: previously, each rect coordinate was rounded using floor(c + 0.5) + Geom::IntRect ibox = dbox->roundOutwards(); + + if ( dump ) { + g_message( " box --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.left(), (double)ibox.top(), (double)ibox.right(), (double)ibox.bottom() ); + } + + /* Find button visible area */ + int width = ibox.width(); + int height = ibox.height(); + + if ( dump ) { + g_message( " vis --'%s' (%d,%d)", name, width, height ); + } + + { + int block = std::max(width, height); + if (block != static_cast<int>(psize) ) { + if ( dump ) { + g_message(" resizing" ); + } + sf = (double)psize / (double)block; + + drawing.root()->setTransform(Geom::Scale(sf)); + drawing.update(); + + auto scaled_box = *dbox * Geom::Scale(sf); + ibox = scaled_box.roundOutwards(); + if ( dump ) { + g_message( " box2 --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.left(), (double)ibox.top(), (double)ibox.right(), (double)ibox.bottom() ); + } + + /* Find button visible area */ + width = ibox.width(); + height = ibox.height(); + if ( dump ) { + g_message( " vis2 --'%s' (%d,%d)", name, width, height ); + } + } + } + + Geom::IntPoint pdim(psize, psize); + int dx, dy; + //dx = (psize - width) / 2; + //dy = (psize - height) / 2; + dx=dy=psize; + dx=(dx-width)/2; // watch out for psize, since 'unsigned'-'signed' can cause problems if the result is negative + dy=(dy-height)/2; + Geom::IntRect area = Geom::IntRect::from_xywh(ibox.min() - Geom::IntPoint(dx,dy), pdim); + /* Actual renderable area */ + Geom::IntRect ua = *Geom::intersect(ibox, area); + + if ( dump ) { + g_message( " area --'%s' (%f,%f)-(%f,%f)", name, (double)area.left(), (double)area.top(), (double)area.right(), (double)area.bottom() ); + g_message( " ua --'%s' (%f,%f)-(%f,%f)", name, (double)ua.left(), (double)ua.top(), (double)ua.right(), (double)ua.bottom() ); + } + + stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, psize); + + /* Set up pixblock */ + px = g_new(guchar, stride * psize); + memset(px, 0x00, stride * psize); + + /* Render */ + cairo_surface_t *s = cairo_image_surface_create_for_data(px, + CAIRO_FORMAT_ARGB32, psize, psize, stride); + Inkscape::DrawingContext dc(s, ua.min()); + + SPNamedView *nv = sp_document_namedview(doc, NULL); + float bg_r = SP_RGBA32_R_F(nv->pagecolor); + float bg_g = SP_RGBA32_G_F(nv->pagecolor); + float bg_b = SP_RGBA32_B_F(nv->pagecolor); + float bg_a = SP_RGBA32_A_F(nv->pagecolor); + + cairo_t *cr = cairo_create(s); + cairo_set_source_rgba(cr, bg_r, bg_g, bg_b, bg_a); + cairo_rectangle(cr, 0, 0, psize, psize); + cairo_fill(cr); + cairo_save(cr); + cairo_destroy(cr); + + drawing.render(dc, ua); + cairo_surface_destroy(s); + + // convert to GdkPixbuf format + convert_pixels_argb32_to_pixbuf(px, psize, psize, stride); + + if ( Inkscape::Preferences::get()->getBool("/debug/icons/overlaySvg") ) { + overlayPixels( px, psize, psize, stride, 0x00, 0x00, 0xff ); + } + } + } + } + + return px; +} // end of sp_icon_doc_icon() + + void IconPreviewPanel::renderPreview( SPObject* obj ) { SPDocument * doc = obj->document; diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index feff40fe5..b9f1f40b2 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -22,7 +22,6 @@ #include <glibmm/miscutils.h> #include <glibmm/markup.h> #include <gtkmm/main.h> -#include <gtkmm/alignment.h> #include "preferences.h" #include "verbs.h" @@ -85,7 +84,7 @@ InkscapePreferences::InkscapePreferences() delete sb; //Main HBox - Gtk::HBox* hbox_list_page = Gtk::manage(new Gtk::HBox()); + auto hbox_list_page = Gtk::manage(new Gtk::Box()); hbox_list_page->set_border_width(12); hbox_list_page->set_spacing(12); _getContents()->add(*hbox_list_page); @@ -107,7 +106,7 @@ InkscapePreferences::InkscapePreferences() page_list_selection->set_mode(Gtk::SELECTION_BROWSE); //Pages - Gtk::VBox* vbox_page = Gtk::manage(new Gtk::VBox()); + auto vbox_page = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); Gtk::Frame* title_frame = Gtk::manage(new Gtk::Frame()); Gtk::ScrolledWindow* pageScroller = Gtk::manage(new Gtk::ScrolledWindow()); @@ -266,12 +265,11 @@ void InkscapePreferences::AddNewObjectsStyle(DialogPage &p, Glib::ustring const _("Apply the style you last set on an object")); PrefRadioButton* own = Gtk::manage( new PrefRadioButton); - Gtk::HBox* hb = Gtk::manage( new Gtk::HBox); - Gtk::Alignment* align = Gtk::manage( new Gtk::Alignment); + auto hb = Gtk::manage( new Gtk::Box); own->init ( _("This tool's own style:"), prefs_path + "/usecurrent", 0, false, current); - align->set(0,0,0,0); - align->add(*own); - hb->add(*align); + own->set_halign(Gtk::ALIGN_START); + own->set_valign(Gtk::ALIGN_START); + hb->add(*own); p.set_tip( *own, _("Each tool may store its own style to apply to the newly created objects. Use the button below to set it.")); p.add_line( true, "", *hb, "", ""); @@ -986,9 +984,8 @@ void InkscapePreferences::initPageIO() _page_cms.add_group_header( _("Display adjustment")); Glib::ustring tmpStr; - std::vector<std::pair<Glib::ustring, bool> > sources = ColorProfile::getBaseProfileDirs(); - for ( std::vector<std::pair<Glib::ustring, bool> >::const_iterator it = sources.begin(); it != sources.end(); ++it ) { - gchar* part = g_strdup_printf( "\n%s", it->first.c_str() ); + for (auto &profile: ColorProfile::getBaseProfileDirs()) { + gchar* part = g_strdup_printf( "\n%s", profile.filename.c_str() ); tmpStr += part; g_free(part); } @@ -1947,7 +1944,7 @@ void InkscapePreferences::initPageSystem() _page_system.add_group_header( _("System info")); - _sys_user_config.set_text((char const *)Inkscape::Application::profile_path("")); + _sys_user_config.set_text((char const *)Inkscape::IO::Resource::profile_path("")); _sys_user_config.set_editable(false); _page_system.add_line(true, _("User config: "), _sys_user_config, "", _("Location of users configuration"), true); diff --git a/src/ui/dialog/knot-properties.cpp b/src/ui/dialog/knot-properties.cpp index 954fe2a66..e69fee52e 100644 --- a/src/ui/dialog/knot-properties.cpp +++ b/src/ui/dialog/knot-properties.cpp @@ -45,31 +45,33 @@ KnotPropertiesDialog::KnotPropertiesDialog() { Gtk::Box *mainVBox = get_vbox(); - _layout_table.set_spacings(4); - _layout_table.resize (2, 2); + _layout_table.set_row_spacing(4); + _layout_table.set_column_spacing(4); _unit_name = ""; // Layer name widgets _knot_x_entry.set_activates_default(true); _knot_x_entry.set_digits(4); _knot_x_entry.set_increments(1,1); _knot_x_entry.set_range(-G_MAXDOUBLE, G_MAXDOUBLE); + _knot_x_entry.set_hexpand(); _knot_x_label.set_label(_("Position X:")); - _knot_x_label.set_alignment(1.0, 0.5); + _knot_x_label.set_halign(Gtk::ALIGN_END); + _knot_x_label.set_valign(Gtk::ALIGN_CENTER); _knot_y_entry.set_activates_default(true); _knot_y_entry.set_digits(4); _knot_y_entry.set_increments(1,1); _knot_y_entry.set_range(-G_MAXDOUBLE, G_MAXDOUBLE); - _knot_y_label.set_label(_("Position Y:")); - _knot_y_label.set_alignment(1.0, 0.5); + _knot_y_entry.set_hexpand(); + _knot_y_label.set_label(_("Position Y:")); + _knot_y_label.set_halign(Gtk::ALIGN_END); + _knot_y_label.set_valign(Gtk::ALIGN_CENTER); - _layout_table.attach(_knot_x_label, - 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); - _layout_table.attach(_knot_x_entry, - 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); + _layout_table.attach(_knot_x_label, 0, 0, 1, 1); + _layout_table.attach(_knot_x_entry, 1, 0, 1, 1); - _layout_table.attach(_knot_y_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL); - _layout_table.attach(_knot_y_entry, 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); + _layout_table.attach(_knot_y_label, 0, 1, 1, 1); + _layout_table.attach(_knot_y_entry, 1, 1, 1, 1); mainVBox->pack_start(_layout_table, true, true, 4); diff --git a/src/ui/dialog/knot-properties.h b/src/ui/dialog/knot-properties.h index f6157168f..1297eae1f 100644 --- a/src/ui/dialog/knot-properties.h +++ b/src/ui/dialog/knot-properties.h @@ -13,9 +13,9 @@ #define INKSCAPE_DIALOG_KNOT_PROPERTIES_H #include <gtkmm/dialog.h> +#include <gtkmm/grid.h> #include <gtkmm/label.h> #include <gtkmm/spinbutton.h> -#include <gtkmm/table.h> #include <2geom/point.h> #include "knot.h" #include "ui/tools/measure-tool.h" @@ -45,7 +45,7 @@ protected: Gtk::SpinButton _knot_x_entry; Gtk::Label _knot_y_label; Gtk::SpinButton _knot_y_entry; - Gtk::Table _layout_table; + Gtk::Grid _layout_table; bool _position_visible; Gtk::Button _close_button; diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index c8c42ef90..562484022 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -48,7 +48,8 @@ LayerPropertiesDialog::LayerPropertiesDialog() // Layer name widgets _layer_name_entry.set_activates_default(true); _layer_name_label.set_label(_("Layer name:")); - _layer_name_label.set_alignment(1.0, 0.5); + _layer_name_label.set_halign(Gtk::ALIGN_END); + _layer_name_label.set_valign(Gtk::ALIGN_CENTER); _layer_name_label.set_halign(Gtk::ALIGN_FILL); _layer_name_label.set_valign(Gtk::ALIGN_FILL); @@ -165,7 +166,8 @@ LayerPropertiesDialog::_setup_position_controls() { row->set_value(_dropdown_columns.name, Glib::ustring(_("As sublayer of current"))); _layer_position_label.set_label(_("Position:")); - _layer_position_label.set_alignment(1.0, 0.5); + _layer_position_label.set_halign(Gtk::ALIGN_END); + _layer_position_label.set_valign(Gtk::ALIGN_CENTER); _layer_position_combo.set_halign(Gtk::ALIGN_FILL); _layer_position_combo.set_valign(Gtk::ALIGN_FILL); diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index dd9d7ec25..7a650b034 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -15,7 +15,6 @@ #include "layers.h" #include <gtkmm/icontheme.h> -#include <gtkmm/imagemenuitem.h> #include <gtkmm/separatormenuitem.h> #include <glibmm/main.h> @@ -31,7 +30,6 @@ #include "ui/icon-names.h" #include "ui/widget/imagetoggler.h" #include "verbs.h" -#include "widgets/icon.h" #include "sp-root.h" #include "ui/tools/tool-base.h" #include "selection-chemistry.h" @@ -82,7 +80,7 @@ void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned i bool set = false; if ( iconName ) { - GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName ); + GtkWidget *child = gtk_image_new_from_icon_name( iconName, GTK_ICON_SIZE_SMALL_TOOLBAR ); gtk_widget_show( child ); btn.add( *Gtk::manage(Glib::wrap(child)) ); btn.set_relief(Gtk::RELIEF_NONE); @@ -94,7 +92,7 @@ void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned i if ( verb ) { SPAction *action = verb->get_action(Inkscape::ActionContext(desktop)); if ( !set && action && action->image ) { - GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, action->image ); + GtkWidget *child = gtk_image_new_from_icon_name( action->image, GTK_ICON_SIZE_SMALL_TOOLBAR ); gtk_widget_show( child ); btn.add( *Gtk::manage(Glib::wrap(child)) ); set = true; @@ -114,11 +112,12 @@ void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned i Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id ) { - GtkWidget* iconWidget = 0; + Gtk::Image *iconWidget = nullptr; const char* label = 0; if ( iconName ) { - iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, iconName ); + iconWidget = Gtk::manage(new Gtk::Image()); + iconWidget->set_from_icon_name( iconName, Gtk::ICON_SIZE_MENU ); } if ( desktop ) { @@ -126,7 +125,8 @@ Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code if ( verb ) { SPAction *action = verb->get_action(Inkscape::ActionContext(desktop)); if ( !iconWidget && action && action->image ) { - iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, action->image ); + iconWidget = Gtk::manage(new Gtk::Image()); + iconWidget->set_from_icon_name( action->image, Gtk::ICON_SIZE_MENU ); } if ( action ) { @@ -139,21 +139,23 @@ Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code label = fallback; } - Gtk::Widget* wrapped = 0; - if ( iconWidget ) { - wrapped = Gtk::manage(Glib::wrap(iconWidget)); - wrapped->show(); - } - - - Gtk::MenuItem* item = 0; + auto box = Gtk::manage(new Gtk::Box()); + Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem()); - if (wrapped) { - item = Gtk::manage(new Gtk::ImageMenuItem(*wrapped, label, true)); - } else { - item = Gtk::manage(new Gtk::MenuItem(label, true)); + if (iconWidget) { + box->pack_start(*iconWidget, false, true, 0); + } + else { + Gtk::Label *fake_icon = Gtk::manage(new Gtk::Label("")); + box->pack_start(*fake_icon, false, true, 0); } + Gtk::Label *menu_label = Gtk::manage(new Gtk::Label(label, true)); + menu_label->set_xalign(0.0); + box->pack_start(*menu_label, true, true, 0); + item->add(*box); + item->show_all(); + item->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &LayersPanel::_takeAction), id)); _popupMenu.append(*item); diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index bb9b61504..98789f7b2 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -36,7 +36,6 @@ #include "ui/icon-names.h" #include "ui/widget/imagetoggler.h" #include "verbs.h" -#include "widgets/icon.h" #include "livepatheffect-add.h" namespace Inkscape { @@ -67,7 +66,7 @@ void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flag static void lpe_style_button(Gtk::Button& btn, char const* iconName) { - GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName); + GtkWidget *child = gtk_image_new_from_icon_name(iconName, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_widget_show( child ); btn.add(*Gtk::manage(Glib::wrap(child))); btn.set_relief(Gtk::RELIEF_NONE); diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp index 82c6035d4..13264c979 100644 --- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp +++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp @@ -44,7 +44,8 @@ FilletChamferPropertiesDialog::FilletChamferPropertiesDialog() _fillet_chamfer_position_numeric.set_range(0., SCALARPARAM_G_MAXDOUBLE); _fillet_chamfer_position_numeric.set_hexpand(); _fillet_chamfer_position_label.set_label(_("Radius (pixels):")); - _fillet_chamfer_position_label.set_alignment(1.0, 0.5); + _fillet_chamfer_position_label.set_halign(Gtk::ALIGN_END); + _fillet_chamfer_position_label.set_valign(Gtk::ALIGN_CENTER); _layout_table.attach(_fillet_chamfer_position_label, 0, 0, 1, 1); _layout_table.attach(_fillet_chamfer_position_numeric, 1, 0, 1, 1); @@ -54,7 +55,8 @@ FilletChamferPropertiesDialog::FilletChamferPropertiesDialog() _fillet_chamfer_chamfer_subdivisions.set_range(0, SCALARPARAM_G_MAXDOUBLE); _fillet_chamfer_chamfer_subdivisions.set_hexpand(); _fillet_chamfer_chamfer_subdivisions_label.set_label(_("Chamfer subdivisions:")); - _fillet_chamfer_chamfer_subdivisions_label.set_alignment(1.0, 0.5); + _fillet_chamfer_chamfer_subdivisions_label.set_halign(Gtk::ALIGN_END); + _fillet_chamfer_chamfer_subdivisions_label.set_valign(Gtk::ALIGN_CENTER); _layout_table.attach(_fillet_chamfer_chamfer_subdivisions_label, 0, 1, 1, 1); _layout_table.attach(_fillet_chamfer_chamfer_subdivisions, 1, 1, 1, 1); diff --git a/src/ui/dialog/lpe-powerstroke-properties.cpp b/src/ui/dialog/lpe-powerstroke-properties.cpp index 0757aa1c3..bc3fbd828 100644 --- a/src/ui/dialog/lpe-powerstroke-properties.cpp +++ b/src/ui/dialog/lpe-powerstroke-properties.cpp @@ -50,7 +50,8 @@ PowerstrokePropertiesDialog::PowerstrokePropertiesDialog() _powerstroke_position_entry.set_range(-SCALARPARAM_G_MAXDOUBLE, SCALARPARAM_G_MAXDOUBLE); _powerstroke_position_entry.set_hexpand(); _powerstroke_position_label.set_label(_("Position:")); - _powerstroke_position_label.set_alignment(1.0, 0.5); + _powerstroke_position_label.set_halign(Gtk::ALIGN_END); + _powerstroke_position_label.set_valign(Gtk::ALIGN_CENTER); _powerstroke_width_entry.set_activates_default(true); _powerstroke_width_entry.set_digits(4); @@ -58,7 +59,8 @@ PowerstrokePropertiesDialog::PowerstrokePropertiesDialog() _powerstroke_width_entry.set_range(-SCALARPARAM_G_MAXDOUBLE, SCALARPARAM_G_MAXDOUBLE); _powerstroke_width_entry.set_hexpand(); _powerstroke_width_label.set_label(_("Width:")); - _powerstroke_width_label.set_alignment(1.0, 0.5); + _powerstroke_width_label.set_halign(Gtk::ALIGN_END); + _powerstroke_width_label.set_valign(Gtk::ALIGN_CENTER); _layout_table.attach(_powerstroke_position_label,0,0,1,1); _layout_table.attach(_powerstroke_position_entry,1,0,1,1); diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index 2b33fd54d..ab46a55da 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -15,9 +15,6 @@ #include "new-from-template.h" #include "file.h" -#include <gtkmm/alignment.h> - - namespace Inkscape { namespace UI { @@ -32,13 +29,16 @@ NewFromTemplate::NewFromTemplate() get_content_area()->pack_start(*_main_widget); - Gtk::Alignment *align; - align = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + _create_template_button.set_halign(Gtk::ALIGN_END); + _create_template_button.set_valign(Gtk::ALIGN_END); - get_content_area()->pack_end(*align, Gtk::PACK_SHRINK); +#if WITH_GTKMM_3_12 + _create_template_button.set_margin_end(15); +#else + _create_template_button.set_margin_right(15); +#endif - align->set_padding(0, 0, 0, 15); - align->add(_create_template_button); + get_content_area()->pack_end(_create_template_button, Gtk::PACK_SHRINK); _create_template_button.signal_clicked().connect( sigc::mem_fun(*this, &NewFromTemplate::_createFromTemplate)); diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp index 191216eea..4c8bd4176 100644 --- a/src/ui/dialog/object-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -108,7 +108,7 @@ void ObjectProperties::_init() /* Create the label for the object id */ _label_id.set_label(_label_id.get_label() + " "); - _label_id.set_alignment(1, 0.5); + _label_id.set_halign(Gtk::ALIGN_END); _label_id.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_label_id, 0, 0, 1, 1); @@ -128,8 +128,7 @@ void ObjectProperties::_init() /* Create the label for the object label */ _label_label.set_label(_label_label.get_label() + " "); - _label_label.set_alignment(1, 0.5); - + _label_label.set_halign(Gtk::ALIGN_END); _label_label.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_label_label, 0, 1, 1, 1); @@ -149,8 +148,7 @@ void ObjectProperties::_init() /* Create the label for the object title */ _label_title.set_label(_label_title.get_label() + " "); - _label_title.set_alignment (1, 0.5); - + _label_title.set_halign(Gtk::ALIGN_END); _label_title.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_label_title, 0, 2, 1, 1); @@ -187,8 +185,7 @@ void ObjectProperties::_init() /* Image rendering */ /* Create the label for the object ImageRendering */ _label_image_rendering.set_label(_label_image_rendering.get_label() + " "); - _label_image_rendering.set_alignment(1, 0.5); - + _label_image_rendering.set_halign(Gtk::ALIGN_END); _label_image_rendering.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_label_image_rendering, 0, 3, 1, 1); diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 92557b1a3..2930f9ba5 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -47,7 +47,6 @@ #include "ui/tools/node-tool.h" #include "verbs.h" #include "ui/widget/color-notebook.h" -#include "widgets/icon.h" #include "xml/node-observer.h" //#define DUMP_LAYERS 1 @@ -224,7 +223,7 @@ public: */ void ObjectsPanel::_styleButton(Gtk::Button& btn, char const* iconName, char const* tooltip) { - GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName ); + GtkWidget *child = gtk_image_new_from_icon_name( iconName, GTK_ICON_SIZE_SMALL_TOOLBAR ); gtk_widget_show( child ); btn.add( *Gtk::manage(Glib::wrap(child)) ); btn.set_relief(Gtk::RELIEF_NONE); @@ -242,23 +241,25 @@ void ObjectsPanel::_styleButton(Gtk::Button& btn, char const* iconName, char con */ Gtk::MenuItem& ObjectsPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id ) { - GtkWidget* iconWidget = 0; + Gtk::Image *iconWidget = nullptr; const char* label = 0; if ( iconName ) { - iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, iconName ); + iconWidget = Gtk::manage(new Gtk::Image()); + iconWidget->set_from_icon_name( iconName, Gtk::ICON_SIZE_MENU ); } if ( desktop ) { Verb *verb = Verb::get( code ); if ( verb ) { - SPAction *action = verb->get_action(desktop); + SPAction *action = verb->get_action(Inkscape::ActionContext(desktop)); if ( !iconWidget && action && action->image ) { - iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, action->image ); + iconWidget = Gtk::manage(new Gtk::Image()); + iconWidget->set_from_icon_name( action->image, Gtk::ICON_SIZE_MENU ); } if ( action ) { - // label = action->name; + label = action->name; } } } @@ -267,20 +268,22 @@ Gtk::MenuItem& ObjectsPanel::_addPopupItem( SPDesktop *desktop, unsigned int cod label = fallback; } - Gtk::Widget* wrapped = 0; - if ( iconWidget ) { - wrapped = Gtk::manage(Glib::wrap(iconWidget)); - wrapped->show(); - } - + auto box = Gtk::manage(new Gtk::Box()); + Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem()); - Gtk::MenuItem* item = 0; - - if (wrapped) { - item = Gtk::manage(new Gtk::ImageMenuItem(*wrapped, label, true)); - } else { - item = Gtk::manage(new Gtk::MenuItem(label, true)); + if (iconWidget) { + box->pack_start(*iconWidget, false, true, 0); } + else { + Gtk::Label *fake_icon = Gtk::manage(new Gtk::Label("")); + box->pack_start(*fake_icon, false, true, 0); + } + + Gtk::Label *menu_label = Gtk::manage(new Gtk::Label(label, true)); + menu_label->set_xalign(0.0); + box->pack_start(*menu_label, true, true, 0); + item->add(*box); + item->show_all(); item->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &ObjectsPanel::_takeAction), id)); _popupMenu.append(*item); @@ -1642,19 +1645,17 @@ ObjectsPanel::ObjectsPanel() : _clipmaskHeader(C_("Clip and mask", "CM")), _highlightHeader(C_("Highlight", "HL")), _nameHeader(_("Label")), - _composite_vbox(false, 0), - _opacity_vbox(false, 0), + _composite_vbox(Gtk::ORIENTATION_VERTICAL), + _opacity_vbox(Gtk::ORIENTATION_VERTICAL), _opacity_label(_("Opacity:")), _opacity_label_unit(_("%")), _opacity_adjustment(Gtk::Adjustment::create(100.0, 0.0, 100.0, 1.0, 1.0, 0.0)), _opacity_hscale(_opacity_adjustment), _opacity_spin_button(_opacity_adjustment, 0.01, 1), _fe_cb(UI::Widget::SimpleFilterModifier::BLEND), - _fe_vbox(false, 0), - _fe_alignment(1, 1, 1, 1), + _fe_vbox(Gtk::ORIENTATION_VERTICAL), _fe_blur(UI::Widget::SimpleFilterModifier::BLUR), - _blur_vbox(false, 0), - _blur_alignment(1, 1, 1, 1), + _blur_vbox(Gtk::ORIENTATION_VERTICAL), _colorSelectorDialog("dialogs.colorpickerwindow") { //Create the tree model and store @@ -1791,21 +1792,39 @@ ObjectsPanel::ObjectsPanel() : //Set up the compositing items //Blend mode filter effect _composite_vbox.pack_start(_fe_vbox, false, false, 2); - _fe_alignment.set_padding(0, 0, 4, 0); - _fe_alignment.add(_fe_cb); - _fe_vbox.pack_start(_fe_alignment, false, false, 0); + + _fe_cb.set_halign(Gtk::ALIGN_FILL); + _fe_cb.set_valign(Gtk::ALIGN_END); + +#if WITH_GTKMM_3_12 + _fe_cb.set_margin_start(4); +#else + _fe_cb.set_margin_left(4); +#endif + + _fe_vbox.pack_start(_fe_cb, false, false, 0); _blendConnection = _fe_cb.signal_blend_blur_changed().connect(sigc::mem_fun(*this, &ObjectsPanel::_blendValueChanged)); //Blur filter effect _composite_vbox.pack_start(_blur_vbox, false, false, 2); - _blur_alignment.set_padding(0, 0, 4, 0); - _blur_alignment.add(_fe_blur); - _blur_vbox.pack_start(_blur_alignment, false, false, 0); + + _fe_blur.set_hexpand(); + _fe_blur.set_halign(Gtk::ALIGN_FILL); + _fe_blur.set_valign(Gtk::ALIGN_END); + +#if WITH_GTKMM_3_12 + _fe_blur.set_margin_start(4); +#else + _fe_blur.set_margin_left(4); +#endif + + _blur_vbox.pack_start(_fe_blur, false, false, 0); _blurConnection = _fe_blur.signal_blend_blur_changed().connect(sigc::mem_fun(*this, &ObjectsPanel::_blurValueChanged)); //Opacity _composite_vbox.pack_start(_opacity_vbox, false, false, 2); - _opacity_label.set_alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER); + _opacity_label.set_halign(Gtk::ALIGN_END); + _opacity_label.set_valign(Gtk::ALIGN_CENTER); _opacity_hbox.pack_start(_opacity_label, false, false, 3); _opacity_vbox.pack_start(_opacity_hbox, false, false, 0); _opacity_hbox.pack_start(_opacity_hscale, true, true, 0); diff --git a/src/ui/dialog/objects.h b/src/ui/dialog/objects.h index 21305669e..b7fd1b4f8 100644 --- a/src/ui/dialog/objects.h +++ b/src/ui/dialog/objects.h @@ -153,21 +153,19 @@ private: Gtk::Label _nameHeader; /* Composite Settings */ - Gtk::VBox _composite_vbox; - Gtk::VBox _opacity_vbox; - Gtk::HBox _opacity_hbox; + Gtk::Box _composite_vbox; + Gtk::Box _opacity_vbox; + Gtk::Box _opacity_hbox; Gtk::Label _opacity_label; Gtk::Label _opacity_label_unit; Glib::RefPtr<Gtk::Adjustment> _opacity_adjustment; - Gtk::HScale _opacity_hscale; + Gtk::Scale _opacity_hscale; Inkscape::UI::Widget::SpinButton _opacity_spin_button; Inkscape::UI::Widget::SimpleFilterModifier _fe_cb; - Gtk::VBox _fe_vbox; - Gtk::Alignment _fe_alignment; + Gtk::Box _fe_vbox; Inkscape::UI::Widget::SimpleFilterModifier _fe_blur; - Gtk::VBox _blur_vbox; - Gtk::Alignment _blur_alignment; + Gtk::Box _blur_vbox; Gtk::Dialog _colorSelectorDialog; boost::scoped_ptr<Inkscape::UI::SelectedColor> _selectedColor; diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index 9485b6ba3..2b4550d20 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -19,7 +19,6 @@ #include "document.h" #include "document-undo.h" -#include "widgets/icon.h" #include "desktop.h" #include "sp-ellipse.h" #include "sp-item-transform.h" @@ -40,7 +39,7 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) angleX("", C_("Polar arrange tab", "End angle"), angleY) { anchorPointLabel.set_text(C_("Polar arrange tab", "Anchor point:")); - anchorPointLabel.set_alignment(Gtk::ALIGN_START); + anchorPointLabel.set_halign(Gtk::ALIGN_START); pack_start(anchorPointLabel, false, false); anchorBoundingBoxRadio.set_label(C_("Polar arrange tab", "Objects' bounding boxes:")); @@ -56,7 +55,7 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) pack_start(anchorObjectPivotRadio, false, false); arrangeOnLabel.set_text(C_("Polar arrange tab", "Arrange on:")); - arrangeOnLabel.set_alignment(Gtk::ALIGN_START); + arrangeOnLabel.set_halign(Gtk::ALIGN_START); pack_start(arrangeOnLabel, false, false); arrangeOnFirstCircleRadio.set_label(C_("Polar arrange tab", "First selected circle/ellipse/arc")); diff --git a/src/ui/dialog/save-template-dialog.cpp b/src/ui/dialog/save-template-dialog.cpp new file mode 100644 index 000000000..5b7540039 --- /dev/null +++ b/src/ui/dialog/save-template-dialog.cpp @@ -0,0 +1,91 @@ +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include "save-template-dialog.h" +#include "file.h" + +#include <glibmm/i18n.h> + +#include <iostream> + +namespace Inkscape { +namespace UI { +namespace Dialog { + +SaveTemplate::SaveTemplate() : + Gtk::Dialog(_("Save Document as Template")), + name_label(_("Name: "), Gtk::ALIGN_START), + author_label(_("Author: "), Gtk::ALIGN_START), + description_label(_("Description: "), Gtk::ALIGN_START), + keywords_label(_("Keywords: "), Gtk::ALIGN_START), + is_default_template("Set as default template") +{ + resize(400, 200); + + name_text.set_hexpand(true); + + grid.attach(name_label, 0, 0, 1, 1); + grid.attach(name_text, 1, 0, 1, 1); + + grid.attach(author_label, 0, 1, 1, 1); + grid.attach(author_text, 1, 1, 1, 1); + + grid.attach(description_label, 0, 2, 1, 1); + grid.attach(description_text, 1, 2, 1, 1); + + grid.attach(keywords_label, 0, 3, 1, 1); + grid.attach(keywords_text, 1, 3, 1, 1); + + auto content_area = get_content_area(); + + content_area->set_spacing(5); + + content_area->add(grid); + content_area->add(is_default_template); + + name_text.signal_changed().connect( sigc::mem_fun(*this, + &SaveTemplate::on_name_changed) ); + + add_button("Cancel", Gtk::RESPONSE_CANCEL); + add_button("Save", Gtk::RESPONSE_OK); + + set_response_sensitive(Gtk::RESPONSE_OK, false); + set_default_response(Gtk::RESPONSE_CANCEL); + + show_all(); +} + +void SaveTemplate::on_name_changed() { + + if (name_text.get_text_length() == 0) { + + set_response_sensitive(Gtk::RESPONSE_OK, false); + } else { + + set_response_sensitive(Gtk::RESPONSE_OK, true); + } +} + +void SaveTemplate::save_template(Gtk::Window &parentWindow) { + + sp_file_save_template(parentWindow, name_text.get_text(), + author_text.get_text(), description_text.get_text(), + keywords_text.get_text(), is_default_template.get_active()); +} + +void SaveTemplate::save_document_as_template(Gtk::Window &parentWindow) { + + SaveTemplate dialog; + + auto result = dialog.run(); + + if (result == Gtk::RESPONSE_OK){ + + dialog.save_template(parentWindow); + } +} + +} +} +} diff --git a/src/ui/dialog/save-template-dialog.h b/src/ui/dialog/save-template-dialog.h new file mode 100644 index 000000000..9f38c499d --- /dev/null +++ b/src/ui/dialog/save-template-dialog.h @@ -0,0 +1,51 @@ +#ifndef INKSCAPE_SEEN_UI_DIALOG_SAVE_TEMPLATE_H +#define INKSCAPE_SEEN_UI_DIALOG_SAVE_TEMPLATE_H + +#include <gtkmm/dialog.h> +#include <gtkmm/entry.h> +#include <gtkmm/box.h> +#include <gtkmm/grid.h> +#include <gtkmm/label.h> +#include <gtkmm/checkbutton.h> + +namespace Inkscape { +namespace UI { +namespace Dialog { + +class SaveTemplate : public Gtk::Dialog +{ + +public: + + static void save_document_as_template(Gtk::Window &parentWindow); + +protected: + + void on_name_changed(); + +private: + + Gtk::Grid grid; + + Gtk::Label name_label; + Gtk::Entry name_text; + + Gtk::Label author_label; + Gtk::Entry author_text; + + Gtk::Label description_label; + Gtk::Entry description_text; + + Gtk::Label keywords_label; + Gtk::Entry keywords_text; + + Gtk::CheckButton is_default_template; + + SaveTemplate(); + void save_template(Gtk::Window &parentWindow); + +}; +} +} +} +#endif diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index 045ce3459..4f7657f4f 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -13,7 +13,6 @@ */ #include "spellcheck.h" -#include "widgets/icon.h" #include "message-stack.h" #include "helper/window.h" diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index 8679659ce..3642c0168 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -13,7 +13,6 @@ #include "styledialog.h" #include "ui/widget/addtoicon.h" -#include "widgets/icon.h" #include "verbs.h" #include "sp-object.h" #include "selection.h" @@ -265,7 +264,9 @@ StyleDialog::StyleDialog() : _treeView.set_expander_column(*(_treeView.get_column(1))); // Pack widgets + _paned.set_orientation(Gtk::ORIENTATION_VERTICAL); _paned.pack1(_mainBox, Gtk::SHRINK); + _mainBox.set_orientation(Gtk::ORIENTATION_VERTICAL); _mainBox.pack_start(_scrolledWindow, Gtk::PACK_EXPAND_WIDGET); _scrolledWindow.add(_treeView); _scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); @@ -1515,7 +1516,7 @@ bool StyleDialog::_delProperty(GdkEventButton *event) void StyleDialog::_styleButton(Gtk::Button& btn, char const* iconName, char const* tooltip) { - GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName); + GtkWidget *child = gtk_image_new_from_icon_name(iconName, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_widget_show(child); btn.add(*manage(Glib::wrap(child))); btn.set_relief(Gtk::RELIEF_NONE); diff --git a/src/ui/dialog/styledialog.h b/src/ui/dialog/styledialog.h index dbbc1e480..03932e3cc 100644 --- a/src/ui/dialog/styledialog.h +++ b/src/ui/dialog/styledialog.h @@ -108,9 +108,9 @@ private: Glib::RefPtr<TreeStore> _store; // Widgets - Gtk::VPaned _paned; - Gtk::VBox _mainBox; - Gtk::HBox _buttonBox; + Gtk::Paned _paned; + Gtk::Box _mainBox; + Gtk::Box _buttonBox; Gtk::ScrolledWindow _scrolledWindow; Gtk::Button* del; Gtk::Button* create; diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 87bfa9252..28269c81b 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -24,6 +24,8 @@ #include <glibmm/i18n.h> #include <glibmm/main.h> #include <glibmm/timer.h> +#include <glibmm/fileutils.h> +#include <glibmm/miscutils.h> #include "color-item.h" #include "desktop.h" @@ -384,10 +386,11 @@ static bool parseNum( char*& str, int& val ) { } -void _loadPaletteFile( gchar const *filename, gchar const *path, gboolean user/*=FALSE*/ ) +void _loadPaletteFile(Glib::ustring path, gboolean user/*=FALSE*/) { + Glib::ustring filename = Glib::path_get_basename(path); char block[1024]; - FILE *f = Inkscape::IO::fopen_utf8name(path, "r" ); + FILE *f = Inkscape::IO::fopen_utf8name(path.c_str(), "r"); if ( f ) { char* result = fgets( block, sizeof(block), f ); if ( result ) { @@ -396,7 +399,7 @@ void _loadPaletteFile( gchar const *filename, gchar const *path, gboolean user/* bool hasErr = false; SwatchPage *onceMore = new SwatchPage(); - onceMore->_name = filename; + onceMore->_name = filename.c_str(); do { result = fgets( block, sizeof(block), f ); @@ -512,61 +515,24 @@ compare_swatch_names(SwatchPage const *a, SwatchPage const *b) { static void loadEmUp() { + using namespace Inkscape::IO::Resource; static bool beenHere = false; gboolean userPalette = true; if ( !beenHere ) { beenHere = true; - std::list<gchar *> sources; - sources.push_back( Inkscape::Application::profile_path("palettes") ); - sources.push_back( g_strdup(INKSCAPE_PALETTESDIR) ); - sources.push_back( g_strdup(CREATE_PALETTESDIR) ); - - // Use this loop to iterate through a list of possible document locations. - while (!sources.empty()) { - gchar *dirname = sources.front(); - if ( Inkscape::IO::file_test( dirname, G_FILE_TEST_EXISTS ) - && Inkscape::IO::file_test( dirname, G_FILE_TEST_IS_DIR )) { - GError *err = 0; - GDir *directory = g_dir_open(dirname, 0, &err); - if (!directory) { - gchar *safeDir = Inkscape::IO::sanitizeString(dirname); - g_warning(_("Palettes directory (%s) is unavailable."), safeDir); - g_free(safeDir); - } else { - gchar *filename = 0; - while ((filename = (gchar *)g_dir_read_name(directory)) != NULL) { - gchar* lower = g_ascii_strdown( filename, -1 ); -// if ( g_str_has_suffix(lower, ".gpl") ) { - if ( !g_str_has_suffix(lower, "~") ) { - gchar* full = g_build_filename(dirname, filename, NULL); - if ( !Inkscape::IO::file_test( full, G_FILE_TEST_IS_DIR ) ) { - _loadPaletteFile(filename, full, userPalette); - } - g_free(full); - } -// } - g_free(lower); - } - g_dir_close(directory); - } - } - - // toss the dirname - g_free(dirname); - sources.pop_front(); - userPalette = false; + for(auto &filename: get_filenames(PALETTES, {".gpl"})) { + bool userPalette = Inkscape::IO::file_is_writable(filename.c_str()); + _loadPaletteFile(filename, userPalette); } } - // Sort the list of swatches by name, grouped by user/system - userSwatchPages.sort(compare_swatch_names); - systemSwatchPages.sort(compare_swatch_names); - + // Sort the list of swatches by name, grouped by user/system + userSwatchPages.sort(compare_swatch_names); + systemSwatchPages.sort(compare_swatch_names); } - SwatchesPanel& SwatchesPanel::getInstance() { return *new SwatchesPanel(); diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index e9a13620b..b876fa98c 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -31,6 +31,7 @@ #include <glibmm/i18n.h> #include "path-prefix.h" #include "io/sys.h" +#include "io/resource.h" #include "ui/cache/svg_preview_cache.h" #include "ui/clipboard.h" @@ -47,7 +48,6 @@ #include "sp-use.h" #include "sp-defs.h" #include "sp-symbol.h" -#include "widgets/icon.h" #ifdef WITH_LIBVISIO #include <libvisio/libvisio.h> @@ -174,18 +174,22 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : scroller->set_hexpand(); table->attach(*Gtk::manage(tools),0,row,2,1); + auto addSymbolImage = Gtk::manage(new Gtk::Image()); + addSymbolImage->set_from_icon_name("symbol-add", Gtk::ICON_SIZE_SMALL_TOOLBAR); + addSymbol = Gtk::manage(new Gtk::Button()); - addSymbol->add(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-add")))) ); + addSymbol->add(*addSymbolImage); addSymbol->set_tooltip_text(_("Add Symbol from the current document.")); addSymbol->set_relief( Gtk::RELIEF_NONE ); addSymbol->set_focus_on_click( false ); addSymbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::insertSymbol)); tools->pack_start(* addSymbol, Gtk::PACK_SHRINK); + auto removeSymbolImage = Gtk::manage(new Gtk::Image()); + removeSymbolImage->set_from_icon_name("symbol-remove", Gtk::ICON_SIZE_SMALL_TOOLBAR); + removeSymbol = Gtk::manage(new Gtk::Button()); - removeSymbol->add(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-remove")))) ); + removeSymbol->add(*removeSymbolImage); removeSymbol->set_tooltip_text(_("Remove Symbol from the current document.")); removeSymbol->set_relief( Gtk::RELIEF_NONE ); removeSymbol->set_focus_on_click( false ); @@ -197,18 +201,23 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : // Pack size (controls display area) pack_size = 2; // Default 32px + + auto packMoreImage = Gtk::manage(new Gtk::Image()); + packMoreImage->set_from_icon_name("pack-more", Gtk::ICON_SIZE_SMALL_TOOLBAR); + button = Gtk::manage(new Gtk::Button()); - button->add(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("pack-more")))) ); + button->add(*packMoreImage); button->set_tooltip_text(_("Display more icons in row.")); button->set_relief( Gtk::RELIEF_NONE ); button->set_focus_on_click( false ); button->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::packmore)); tools->pack_start(* button, Gtk::PACK_SHRINK); + auto packLessImage = Gtk::manage(new Gtk::Image()); + packLessImage->set_from_icon_name("pack-less", Gtk::ICON_SIZE_SMALL_TOOLBAR); + button = Gtk::manage(new Gtk::Button()); - button->add(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("pack-less")))) ); + button->add(*packLessImage); button->set_tooltip_text(_("Display fewer icons in row.")); button->set_relief( Gtk::RELIEF_NONE ); button->set_focus_on_click( false ); @@ -216,9 +225,11 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : tools->pack_start(* button, Gtk::PACK_SHRINK); // Toggle scale to fit on/off + auto fitSymbolImage = Gtk::manage(new Gtk::Image()); + fitSymbolImage->set_from_icon_name("symbol-fit", Gtk::ICON_SIZE_SMALL_TOOLBAR); + fitSymbol = Gtk::manage(new Gtk::ToggleButton()); - fitSymbol->add(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-fit")))) ); + fitSymbol->add(*fitSymbolImage); fitSymbol->set_tooltip_text(_("Toggle 'fit' symbols in icon space.")); fitSymbol->set_relief( Gtk::RELIEF_NONE ); fitSymbol->set_focus_on_click( false ); @@ -228,9 +239,11 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : // Render size (scales symbols within display area) scale_factor = 0; // Default 1:1 * pack_size/pack_size default + auto zoomOutImage = Gtk::manage(new Gtk::Image()); + zoomOutImage->set_from_icon_name("symbol-smaller", Gtk::ICON_SIZE_SMALL_TOOLBAR); + zoomOut = Gtk::manage(new Gtk::Button()); - zoomOut->add(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-smaller")))) ); + zoomOut->add(*zoomOutImage); zoomOut->set_tooltip_text(_("Make symbols smaller by zooming out.")); zoomOut->set_relief( Gtk::RELIEF_NONE ); zoomOut->set_focus_on_click( false ); @@ -238,9 +251,11 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : zoomOut->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::zoomout)); tools->pack_start(* zoomOut, Gtk::PACK_SHRINK); + auto zoomInImage = Gtk::manage(new Gtk::Image()); + zoomInImage->set_from_icon_name("symbol-bigger", Gtk::ICON_SIZE_SMALL_TOOLBAR); + zoomIn = Gtk::manage(new Gtk::Button()); - zoomIn->add(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-bigger")))) ); + zoomIn->add(*zoomInImage); zoomIn->set_tooltip_text(_("Make symbols bigger by zooming in.")); zoomIn->set_relief( Gtk::RELIEF_NONE ); zoomIn->set_focus_on_click( false ); @@ -480,20 +495,19 @@ class REVENGE_API RVNGSVGDrawingGenerator_WithTitle : public RVNGSVGDrawingGener #endif // Read Visio stencil files -SPDocument* read_vss( gchar* fullname, Glib::ustring name ) { - +SPDocument* read_vss(Glib::ustring filename, Glib::ustring name ) { + gchar *fullname; #ifdef WIN32 // RVNGFileStream uses fopen() internally which unfortunately only uses ANSI encoding on Windows // therefore attempt to convert uri to the system codepage // even if this is not possible the alternate short (8.3) file name will be used if available - fullname = g_win32_locale_filename_from_utf8(fullname); + fullname = g_win32_locale_filename_from_utf8(filename.c_str()); + #else + filename.copy(fullname, filename.length()); #endif RVNGFileStream input(fullname); - - #ifdef WIN32 - g_free(fullname); - #endif + g_free(fullname); if (!libvisio::VisioDocument::isSupported(&input)) { return NULL; @@ -575,78 +589,32 @@ SPDocument* read_vss( gchar* fullname, Glib::ustring name ) { /* Hunts preference directories for symbol files */ void SymbolsDialog::get_symbols() { - std::list<Glib::ustring> directories; - -// \TODO optimize this - - if( Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_EXISTS ) && - Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_IS_DIR ) ) { - directories.push_back( INKSCAPE_SYMBOLSDIR ); - } - if( Inkscape::IO::file_test( Inkscape::Application::profile_path("symbols"), G_FILE_TEST_EXISTS ) && - Inkscape::IO::file_test( Inkscape::Application::profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) { - directories.push_back( Inkscape::Application::profile_path("symbols") ); - } - - std::list<Glib::ustring>::iterator it; - for( it = directories.begin(); it != directories.end(); ++it ) { - - GError *err = 0; - GDir *dir = g_dir_open( (*it).c_str(), 0, &err ); - if( dir ) { - - gchar *filename = 0; - while( (filename = (gchar *)g_dir_read_name( dir ) ) != NULL) { - - gchar *fullname = g_build_filename((*it).c_str(), filename, NULL); - - if ( !Inkscape::IO::file_test( fullname, G_FILE_TEST_IS_DIR ) - && ( Glib::str_has_suffix(fullname, ".svg") || Glib::str_has_suffix(fullname, ".vss") ) ) { - - Glib::ustring fn( filename ); - Glib::ustring tag = fn.substr( fn.find_last_of(".") + 1 ); - - SPDocument* symbol_doc = NULL; + using namespace Inkscape::IO::Resource; + SPDocument* symbol_doc = NULL; + Glib::ustring title; + + for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { + if(Glib::str_has_suffix(filename, ".svg")) { + symbol_doc = SPDocument::createNewDoc(filename.c_str(), FALSE); + if(symbol_doc) { + title = symbol_doc->getRoot()->title(); + if(title.empty()) { + title = _("Unnamed Symbols"); + } + } + } #ifdef WITH_LIBVISIO - if( tag.compare( "vss" ) == 0 ) { - // strip extension from filename and use it as name for the symbol set - Glib::ustring name = Glib::ustring(filename); - name = name.erase(name.rfind('.')); - - symbol_doc = read_vss( fullname, name ); - if( symbol_doc ) { - symbolSets[name]= symbol_doc; - symbolSet->append(name); - } - } + if(Glib::str_has_suffix(filename, ".vss")) { + Glib::ustring title = filename.erase(filename.rfind('.')); + symbol_doc = read_vss(filename, title); + } #endif - // Try to read all remaining files as SVG - if( !symbol_doc ) { - - symbol_doc = SPDocument::createNewDoc( fullname, FALSE ); - if( symbol_doc ) { - - const gchar *title = symbol_doc->getRoot()->title(); - - // A user provided file may not have a title - if( title != NULL ) { - title = g_dpgettext2(NULL, "Symbol", title); // Translate - } else { - title = _("Unnamed Symbols"); - } - - symbolSets[Glib::ustring(title)] = symbol_doc; - symbolSet->append(title); - } - } - + if(symbol_doc) { + symbolSets[title]= symbol_doc; + symbolSet->append(title); } - g_free( fullname ); - } - g_dir_close( dir ); } - } } GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l) diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index dfe71bddb..176719995 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -31,7 +31,6 @@ #include "ui/widget/layertypeicon.h" #include "ui/widget/addtoicon.h" #include "verbs.h" -#include "widgets/icon.h" #include "xml/node-observer.h" #include "sp-root.h" #include "ui/tools/tool-base.h" //"event-context.h" @@ -130,7 +129,7 @@ public: void TagsPanel::_styleButton(Gtk::Button& btn, char const* iconName, char const* tooltip) { - GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName); + GtkWidget *child = gtk_image_new_from_icon_name(iconName, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_widget_show(child); btn.add(*manage(Glib::wrap(child))); btn.set_relief(Gtk::RELIEF_NONE); @@ -144,7 +143,7 @@ Gtk::MenuItem& TagsPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, const char* label = 0; if ( iconName ) { - iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, iconName ); + iconWidget = gtk_image_new_from_icon_name( iconName, GTK_ICON_SIZE_MENU ); } if ( desktop ) { @@ -152,11 +151,11 @@ Gtk::MenuItem& TagsPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, if ( verb ) { SPAction *action = verb->get_action(desktop); if ( !iconWidget && action && action->image ) { - iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, action->image ); + iconWidget = gtk_image_new_from_icon_name( action->image, GTK_ICON_SIZE_MENU ); } if ( action ) { - label = action->name; + // label = action->name; } } } @@ -167,7 +166,7 @@ Gtk::MenuItem& TagsPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, Gtk::Widget* wrapped = 0; if ( iconWidget ) { - wrapped = manage(Glib::wrap(iconWidget)); + wrapped = Gtk::manage(Glib::wrap(iconWidget)); wrapped->show(); } diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 7b96c2b97..7dd889b2f 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -2,7 +2,7 @@ * @brief New From Template abstract tab implementation */ /* Authors: - * Jan Darowski <jan.darowski@gmail.com>, supervised by Krzysztof KosiÅ„ski + * Jan Darowski <jan.darowski@gmail.com>, supervised by Krzysztof KosiÅ„ski * * Copyright (C) 2013 Authors * Released under GNU GPL, read the file 'COPYING' for more information @@ -24,6 +24,8 @@ #include "file.h" #include "path-prefix.h" +using namespace Inkscape::IO::Resource; + namespace Inkscape { namespace UI { @@ -36,28 +38,27 @@ TemplateLoadTab::TemplateLoadTab(NewFromTemplate* parent) set_border_width(10); _info_widget = Gtk::manage(new TemplateWidget()); - + Gtk::Label *title; title = Gtk::manage(new Gtk::Label(_("Search:"))); _search_box.pack_start(*title, Gtk::PACK_SHRINK); _search_box.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 5); - + _tlist_box.pack_start(_search_box, Gtk::PACK_SHRINK, 10); - + pack_start(_tlist_box, Gtk::PACK_SHRINK); pack_start(*_info_widget, Gtk::PACK_EXPAND_WIDGET, 5); - + Gtk::ScrolledWindow *scrolled; scrolled = Gtk::manage(new Gtk::ScrolledWindow()); scrolled->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); scrolled->add(_tlist_view); _tlist_box.pack_start(*scrolled, Gtk::PACK_EXPAND_WIDGET, 5); - + _keywords_combo.signal_changed().connect( sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected)); this->show_all(); - - _loading_path = ""; + _loadTemplates(); _initLists(); } @@ -90,14 +91,14 @@ void TemplateLoadTab::_displayTemplateInfo() _info_widget->display(_tdata[_current_template]); _parent_widget->setCreateButtonSensitive(true); } - + } void TemplateLoadTab::_initKeywordsList() { _keywords_combo.append(_("All")); - + for (std::set<Glib::ustring>::iterator it = _keywords.begin() ; it != _keywords.end() ; ++it){ _keywords_combo.append(*it); } @@ -110,15 +111,15 @@ void TemplateLoadTab::_initLists() _tlist_view.set_model(_tlist_store); _tlist_view.append_column("", _columns.textValue); _tlist_view.set_headers_visible(false); - + _initKeywordsList(); _refreshTemplatesList(); - + Glib::RefPtr<Gtk::TreeSelection> templateSelectionRef = - _tlist_view.get_selection(); + _tlist_view.get_selection(); templateSelectionRef->signal_changed().connect( sigc::mem_fun(*this, &TemplateLoadTab::_displayTemplateInfo)); - + _tlist_view.signal_row_activated().connect( sigc::mem_fun(*this, &TemplateLoadTab::_onRowActivated)); } @@ -132,10 +133,10 @@ void TemplateLoadTab::_keywordSelected() } else _current_search_type = LIST_KEYWORD; - + if (_current_keyword == "" || _current_keyword == _("All")) _current_search_type = ALL; - + _refreshTemplatesList(); } @@ -202,17 +203,17 @@ void TemplateLoadTab::_refreshTemplatesList() _info_widget->clear(); _parent_widget->setCreateButtonSensitive(false); } -} +} void TemplateLoadTab::_loadTemplates() { - // user's local dir - _getTemplatesFromDir(Inkscape::Application::profile_path("templates") + _loading_path); + for(auto &filename: get_filenames(TEMPLATES, {".svg"}, {"default.", "default_"})) { + TemplateData tmp = _processTemplateFile(filename); + if (tmp.display_name != "") + _tdata[tmp.display_name] = tmp; - // system templates dir - _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); - + } // procedural templates _getProceduralTemplates(); } @@ -224,72 +225,51 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const std::s result.path = path; result.is_procedural = false; result.preview_name = ""; - + // convert path into valid template name result.display_name = Glib::path_get_basename(path); gsize n = 0; while ((n = result.display_name.find_first_of("_", 0)) < Glib::ustring::npos){ result.display_name.replace(n, 1, 1, ' '); - } + } n = result.display_name.rfind(".svg"); result.display_name.replace(n, 4, 1, ' '); - + Inkscape::XML::Document *rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); if (rdoc){ Inkscape::XML::Node *myRoot = rdoc->root(); if (strcmp(myRoot->name(), "svg:svg") != 0){ // Wrong file format return result; } - + myRoot = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); - + if (myRoot == NULL) // No template info return result; _getDataFromNode(myRoot, result); } - - return result; -} - -void TemplateLoadTab::_getTemplatesFromDir(const std::string &path) -{ - if ( !Glib::file_test(path, Glib::FILE_TEST_EXISTS) || - !Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) - return; - - Glib::Dir dir(path); - - std::string file = Glib::build_filename(path, dir.read_name()); - while (file != path){ - if (Glib::str_has_suffix(file, ".svg") && !Glib::str_has_prefix(Glib::path_get_basename(file), "default.")){ - TemplateData tmp = _processTemplateFile(file); - if (tmp.display_name != "") - _tdata[tmp.display_name] = tmp; - } - file = Glib::build_filename(path, dir.read_name()); - } + return result; } - void TemplateLoadTab::_getProceduralTemplates() { std::list<Inkscape::Extension::Effect *> effects; Inkscape::Extension::db.get_effect_list(effects); - + std::list<Inkscape::Extension::Effect *>::iterator it = effects.begin(); while (it != effects.end()){ Inkscape::XML::Node *myRoot; myRoot = (*it)->get_repr(); myRoot = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); - + if (myRoot){ TemplateData result; result.display_name = (*it)->get_name(); result.is_procedural = true; result.path = ""; result.tpl_effect = *it; - + _getDataFromNode(myRoot, result); _tdata[result.display_name] = result; } @@ -313,18 +293,18 @@ void TemplateLoadTab::_getDataFromNode(Inkscape::XML::Node *dataNode, TemplateDa data.preview_name = currentData->firstChild()->content(); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:date")) != NULL) data.creation_date = currentData->firstChild()->content(); - + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_keywords")) != NULL){ Glib::ustring tplKeywords = _(currentData->firstChild()->content()); while (!tplKeywords.empty()){ std::size_t pos = tplKeywords.find_first_of(" "); if (pos == Glib::ustring::npos) pos = tplKeywords.size(); - + Glib::ustring keyword = tplKeywords.substr(0, pos).data(); data.keywords.insert(keyword.lowercase()); _keywords.insert(keyword.lowercase()); - + if (pos == tplKeywords.size()) break; tplKeywords.erase(0, pos+1); diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index d11c4c77f..0a5521d93 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -21,6 +21,7 @@ #include <string> #include "xml/node.h" +#include "io/resource.h" #include "extension/effect.h" @@ -66,7 +67,6 @@ protected: Glib::ustring _current_keyword; Glib::ustring _current_template; - std::string _loading_path; std::map<Glib::ustring, TemplateData> _tdata; std::set<Glib::ustring> _keywords; @@ -100,7 +100,7 @@ private: void _getDataFromNode(Inkscape::XML::Node *, TemplateData &); void _getProceduralTemplates(); - void _getTemplatesFromDir(const std::string &); + void _getTemplatesFromDomain(Inkscape::IO::Resource::Domain domain); void _keywordSelected(); TemplateData _processTemplateFile(const std::string &); diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 3b7fbe88c..8aeaa4046 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -11,7 +11,6 @@ #include "template-widget.h" #include <glibmm/miscutils.h> -#include <gtkmm/alignment.h> #include <gtkmm/messagedialog.h> #include "desktop.h" @@ -42,10 +41,9 @@ TemplateWidget::TemplateWidget() _short_description_label.set_line_wrap(true); - Gtk::Alignment *align; - align = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); - pack_end(*align, Gtk::PACK_SHRINK); - align->add(_more_info_button); + _more_info_button.set_halign(Gtk::ALIGN_END); + _more_info_button.set_valign(Gtk::ALIGN_CENTER); + pack_end(_more_info_button, Gtk::PACK_SHRINK); pack_end(_short_description_label, Gtk::PACK_SHRINK, 5); diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 94f307828..f6b2305b1 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -45,7 +45,6 @@ extern "C" { #include "verbs.h" #include "ui/interface.h" #include "svg/css-ostringstream.h" -#include "widgets/icon.h" #include "widgets/font-selector.h" #include <glibmm/i18n.h> #include <glibmm/markup.h> @@ -59,7 +58,6 @@ namespace Dialog { TextEdit::TextEdit() : UI::Widget::Panel("", "/dialogs/textandfont", SP_VERB_DIALOG_TEXT), font_label(_("_Font"), true), - layout_frame(), text_label(_("_Text"), true), vari_label(_("_Variants"), true), setasdefault_button(_("Set as _default")), @@ -103,26 +101,6 @@ TextEdit::TextEdit() layout_hbox.pack_start(text_sep, false, false, 10); - /* Line Spacing */ - /* Commented out as this does not handle non-percentage values - GtkWidget *px = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("text_line_spacing") ); - layout_hbox.pack_start(*Gtk::manage(Glib::wrap(px)), false, false); - - spacing_combo = gtk_combo_box_text_new_with_entry (); - gtk_widget_set_size_request (spacing_combo, 90, -1); - - const gchar *spacings[] = {"50%", "80%", "90%", "100%", "110%", "120%", "130%", "140%", "150%", "200%", "300%", NULL}; - for (int i = 0; spacings[i]; i++) { - gtk_combo_box_text_append_text((GtkComboBoxText *) spacing_combo, spacings[i]); - } - - gtk_widget_set_tooltip_text (px, _("Spacing between baselines (percent of font size)")); - gtk_widget_set_tooltip_text (spacing_combo, _("Spacing between baselines (percent of font size)")); - layout_hbox.pack_start(*Gtk::manage(Glib::wrap(spacing_combo)), false, false); - layout_frame.set_padding(4,4,4,4); - layout_frame.add(layout_hbox); - */ - // Text start Offset { startOffset = gtk_combo_box_text_new_with_entry (); @@ -149,7 +127,6 @@ TextEdit::TextEdit() preview_label.set_line_wrap(FALSE); font_vbox.pack_start(fontsel_hbox, true, true); - font_vbox.pack_start(layout_frame, false, false, VB_MARGIN); font_vbox.pack_start(preview_label, true, true, VB_MARGIN); /* Text tab */ @@ -223,10 +200,7 @@ TextEdit::~TextEdit() void TextEdit::styleButton(Gtk::RadioButton *button, gchar const *tooltip, gchar const *icon_name, Gtk::RadioButton *group_button ) { - GtkWidget *icon = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, icon_name ); - if (!GTK_IS_IMAGE(icon)) { - icon = gtk_image_new_from_icon_name ( icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR ); - } + GtkWidget *icon = gtk_image_new_from_icon_name( icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR ); if (group_button) { Gtk::RadioButton::Group group = group_button->get_group(); diff --git a/src/ui/dialog/text-edit.h b/src/ui/dialog/text-edit.h index 1fc0099fb..35b051b6f 100644 --- a/src/ui/dialog/text-edit.h +++ b/src/ui/dialog/text-edit.h @@ -22,7 +22,6 @@ # include <config.h> #endif -#include <gtkmm/alignment.h> #include <gtkmm/box.h> #include <gtkmm/notebook.h> #include <gtkmm/button.h> @@ -190,11 +189,10 @@ private: Gtk::VBox font_vbox; Gtk::Label font_label; - Gtk::HBox fontsel_hbox; + Gtk::Box fontsel_hbox; SPFontSelector *fsel; - Gtk::Alignment layout_frame; - Gtk::HBox layout_hbox; + Gtk::Box layout_hbox; Gtk::RadioButton align_left; Gtk::RadioButton align_center; Gtk::RadioButton align_right; diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index d209a450c..5ad1b9ec5 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -31,7 +31,6 @@ #include "sp-namedview.h" #include "sp-item-transform.h" #include "ui/icon-names.h" -#include "widgets/icon.h" namespace Inkscape { @@ -278,14 +277,18 @@ void Transformation::layoutPageRotate() _scalar_rotate.setDigits(3); _scalar_rotate.setIncrements(0.1, 1.0); - _counterclockwise_rotate.add(*manage( Glib::wrap( - sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("object-rotate-left"))))); + auto object_rotate_left_icon = Gtk::manage(new Gtk::Image()); + object_rotate_left_icon->set_from_icon_name("object-rotate-left", Gtk::ICON_SIZE_SMALL_TOOLBAR); + + _counterclockwise_rotate.add(*object_rotate_left_icon); _counterclockwise_rotate.set_mode(false); _counterclockwise_rotate.set_relief(Gtk::RELIEF_NONE); _counterclockwise_rotate.set_tooltip_text(_("Rotate in a counterclockwise direction")); - _clockwise_rotate.add(*manage( Glib::wrap( - sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("object-rotate-right"))))); + auto object_rotate_right_icon = Gtk::manage(new Gtk::Image()); + object_rotate_right_icon->set_from_icon_name("object-rotate-right", Gtk::ICON_SIZE_SMALL_TOOLBAR); + + _clockwise_rotate.add(*object_rotate_right_icon); _clockwise_rotate.set_mode(false); _clockwise_rotate.set_relief(Gtk::RELIEF_NONE); _clockwise_rotate.set_tooltip_text(_("Rotate in a clockwise direction")); diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp index bf5bdc76d..3d6d71e9a 100644 --- a/src/ui/dialog/undo-history.cpp +++ b/src/ui/dialog/undo-history.cpp @@ -44,16 +44,13 @@ void CellRendererSPIcon::render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr, if ( !_icon_cache[_property_event_type] ) { Glib::ustring image_name = Inkscape::Verb::get(_property_event_type)->get_image(); - Gtk::Widget* icon = sp_icon_get_icon(image_name, Inkscape::ICON_SIZE_MENU); + Gtk::Image* icon = Gtk::manage(new Gtk::Image()); + icon->set_from_icon_name(image_name, Gtk::ICON_SIZE_MENU); if (icon) { // check icon type (inkscape, gtk, none) - if ( SP_IS_ICON(icon->gobj()) ) { - SPIcon* sp_icon = SP_ICON(icon->gobj()); - sp_icon_fetch_pixbuf(sp_icon); - _property_icon = Glib::wrap(sp_icon->pb, true); - } else if ( GTK_IS_IMAGE(icon->gobj()) ) { + if ( GTK_IS_IMAGE(icon->gobj()) ) { auto icon_theme = Gtk::IconTheme::get_default(); _property_icon = icon_theme->load_icon(image_name, 16); } else { diff --git a/src/ui/dialog/undo-history.h b/src/ui/dialog/undo-history.h index 48929a0d0..3efc25f15 100644 --- a/src/ui/dialog/undo-history.h +++ b/src/ui/dialog/undo-history.h @@ -24,7 +24,6 @@ #include "event-log.h" -#include "widgets/icon.h" #include "ui/dialog/desktop-tracker.h" class SPDesktop; diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 72aaadb9f..83c0de45b 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -17,7 +17,6 @@ */ #include "xml-tree.h" -#include "widgets/icon.h" #include <glibmm/i18n.h> #include "desktop.h" @@ -87,7 +86,8 @@ XmlTree::XmlTree (void) : contents->set_spacing(0); contents->set_size_request(320, 260); - status.set_alignment( 0.0, 0.5); + status.set_halign(Gtk::ALIGN_START); + status.set_valign(Gtk::ALIGN_CENTER); status.set_size_request(1, -1); status.set_markup(""); status.set_line_wrap(true); @@ -109,57 +109,74 @@ XmlTree::XmlTree (void) : gtk_widget_set_tooltip_text( GTK_WIDGET(tree), _("Drag to reorder nodes") ); tree_toolbar.set_toolbar_style(Gtk::TOOLBAR_ICONS); - xml_element_new_button.set_icon_widget(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("xml-element-new")))) ); + + auto xml_element_new_icon = Gtk::manage(new Gtk::Image()); + xml_element_new_icon->set_from_icon_name("xml-element-new", Gtk::ICON_SIZE_LARGE_TOOLBAR); + + xml_element_new_button.set_icon_widget(*xml_element_new_icon); xml_element_new_button.set_tooltip_text(_("New element node")); xml_element_new_button.set_sensitive(false); tree_toolbar.add(xml_element_new_button); - xml_text_new_button.set_icon_widget(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("xml-text-new"))))); + auto xml_text_new_icon = Gtk::manage(new Gtk::Image()); + xml_text_new_icon->set_from_icon_name("xml-text-new", Gtk::ICON_SIZE_LARGE_TOOLBAR); + + xml_text_new_button.set_icon_widget(*xml_text_new_icon); xml_text_new_button.set_tooltip_text(_("New text node")); xml_text_new_button.set_sensitive(false); tree_toolbar.add(xml_text_new_button); - xml_node_duplicate_button.set_icon_widget(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("xml-node-duplicate"))))); + auto xml_node_duplicate_icon = Gtk::manage(new Gtk::Image()); + xml_node_duplicate_icon->set_from_icon_name("xml-node-duplicate", Gtk::ICON_SIZE_LARGE_TOOLBAR); + + xml_node_duplicate_button.set_icon_widget(*xml_node_duplicate_icon); xml_node_duplicate_button.set_tooltip_text(_("Duplicate node")); xml_node_duplicate_button.set_sensitive(false); tree_toolbar.add(xml_node_duplicate_button); tree_toolbar.add(separator); - xml_node_delete_button.set_icon_widget(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("xml-node-delete"))))); + auto xml_node_delete_icon = Gtk::manage(new Gtk::Image()); + xml_node_delete_icon->set_from_icon_name("xml-node-delete", Gtk::ICON_SIZE_LARGE_TOOLBAR); + + xml_node_delete_button.set_icon_widget(*xml_node_delete_icon); xml_node_delete_button.set_tooltip_text(Q_("nodeAsInXMLdialogTooltip|Delete node")); xml_node_delete_button.set_sensitive(false); tree_toolbar.add(xml_node_delete_button); tree_toolbar.add(separator2); - unindent_node_button.set_icon_widget(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("format-indent-less"))))); + auto format_indent_less_icon = Gtk::manage(new Gtk::Image()); + format_indent_less_icon->set_from_icon_name("format-indent-less", Gtk::ICON_SIZE_LARGE_TOOLBAR); + + unindent_node_button.set_icon_widget(*format_indent_less_icon); unindent_node_button.set_label(_("Unindent node")); unindent_node_button.set_tooltip_text(_("Unindent node")); unindent_node_button.set_sensitive(false); tree_toolbar.add(unindent_node_button); - indent_node_button.set_icon_widget(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("format-indent-more"))))); + auto format_indent_more_icon = Gtk::manage(new Gtk::Image()); + format_indent_more_icon->set_from_icon_name("format-indent-more", Gtk::ICON_SIZE_LARGE_TOOLBAR); + + indent_node_button.set_icon_widget(*format_indent_more_icon); indent_node_button.set_label(_("Indent node")); indent_node_button.set_tooltip_text(_("Indent node")); indent_node_button.set_sensitive(false); tree_toolbar.add(indent_node_button); - raise_node_button.set_icon_widget(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("go-up"))))); + auto go_up_icon = Gtk::manage(new Gtk::Image()); + go_up_icon->set_from_icon_name("go-up", Gtk::ICON_SIZE_LARGE_TOOLBAR); + + raise_node_button.set_icon_widget(*go_up_icon); raise_node_button.set_label(_("Raise node")); raise_node_button.set_tooltip_text(_("Raise node")); raise_node_button.set_sensitive(false); tree_toolbar.add(raise_node_button); - lower_node_button.set_icon_widget(*Gtk::manage(Glib::wrap( - sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("go-down"))))); + auto go_down_icon = Gtk::manage(new Gtk::Image()); + go_down_icon->set_from_icon_name("go-down", Gtk::ICON_SIZE_LARGE_TOOLBAR); + + lower_node_button.set_icon_widget(*go_down_icon); lower_node_button.set_label(_("Lower node")); lower_node_button.set_tooltip_text(_("Lower node")); lower_node_button.set_sensitive(false); @@ -183,7 +200,10 @@ XmlTree::XmlTree (void) : attributes = SP_XMLVIEW_ATTR_LIST(sp_xmlview_attr_list_new(NULL)); attr_toolbar.set_toolbar_style(Gtk::TOOLBAR_ICONS); - xml_attribute_delete_button.set_icon_widget(*Gtk::manage(Glib::wrap(sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("xml-attribute-delete"))))); + + auto xml_attribute_delete_icon = Gtk::manage(new Gtk::Image()); + xml_attribute_delete_icon->set_from_icon_name("xml-attribute-delete", Gtk::ICON_SIZE_LARGE_TOOLBAR); + xml_attribute_delete_button.set_icon_widget(*xml_attribute_delete_icon); xml_attribute_delete_button.set_tooltip_text(_("Delete attribute")); xml_attribute_delete_button.set_sensitive(false); attr_toolbar.add(xml_attribute_delete_button); diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 7e80c1a2f..a0ee5c72b 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -27,14 +27,15 @@ #include <gtkmm/icontheme.h> #include "file.h" #include <glibmm/miscutils.h> -#include <gtkmm/imagemenuitem.h> -#include <gtkmm/separatormenuitem.h> + +#if WITH_GTKMM_3_22 +# include <gdkmm/monitor.h> +#endif #include "inkscape.h" #include "extension/db.h" #include "extension/effect.h" #include "extension/input.h" -#include "widgets/icon.h" #include "preferences.h" #include "shortcuts.h" #include "document.h" @@ -135,8 +136,6 @@ static void sp_ui_menu_item_set_name(GtkWidget *data, Glib::ustring const &name); static void sp_recent_open(GtkRecentChooser *, gpointer); -static void injectRenamedIcons(); - static const int MIN_ONSCREEN_DISTANCE = 50; void @@ -176,13 +175,26 @@ sp_create_window(SPViewWidget *vw, bool editable) gint full = prefs->getBool("/desktop/geometry/fullscreen"); gint maxed = prefs->getBool("/desktop/geometry/maximized"); if (pw>0 && ph>0) { - gint w = MIN(gdk_screen_width(), pw); - gint h = MIN(gdk_screen_height(), ph); - gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, px); - gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, py); +#if WITH_GTKMM_3_22 + auto const display = Gdk::Display::get_default(); + auto const monitor = display->get_primary_monitor(); + + // A Gdk::Rectangle in "application pixel" units + Gdk::Rectangle screen_geometry; + monitor->get_geometry(screen_geometry); + auto const screen_width = screen_geometry.get_width(); + auto const screen_height = screen_geometry.get_height(); +#else + auto const screen_width = gdk_screen_width(); + auto const screen_height = gdk_screen_height(); +#endif + gint w = MIN(screen_width, pw); + gint h = MIN(screen_height, ph); + gint x = MIN(screen_width - MIN_ONSCREEN_DISTANCE, px); + gint y = MIN(screen_height - MIN_ONSCREEN_DISTANCE, py); if (w>0 && h>0) { - x = MIN(gdk_screen_width() - w, x); - y = MIN(gdk_screen_height() - h, y); + x = MIN(screen_width - w, x); + y = MIN(screen_height - h, y); desktop->setWindowSize(w, h); } @@ -389,23 +401,6 @@ sp_ui_menu_deselect(gpointer object) view->tipsMessageContext()->clear(); } -/** - * Creates and attaches a scaled icon to the given menu item. - */ -static void -sp_ui_menuitem_add_icon( GtkWidget *item, gchar *icon_name ) -{ - static bool iconsInjected = false; - if ( !iconsInjected ) { - iconsInjected = true; - injectRenamedIcons(); - } - GtkWidget *icon; - - icon = sp_icon_new( Inkscape::ICON_SIZE_MENU, icon_name ); - gtk_widget_show(icon); - gtk_image_menu_item_set_image((GtkImageMenuItem *) item, icon); -} // end of sp_ui_menu_add_icon void sp_ui_dialog_title_string(Inkscape::Verb *verb, gchar *c) @@ -435,38 +430,82 @@ sp_ui_dialog_title_string(Inkscape::Verb *verb, gchar *c) } } - /** * Appends a custom menu UI from a verb. * * @see ContextMenu::AppendItemFromVerb for a c++ified alternative. Consider dropping sp_ui_menu_append_item_from_verb when c++ifying interface.cpp. + * + * @param menu The menu to which the item will be appended + * @param verb The verb from which the item's label, action and icon (optionally) will be read + * @param view + * @param show_icon True if an icon should be displayed before the menu item's label + * @param radio True if a radio button should be displayed next to the menu item + * @param group The radio button group that the item should belong to + * + * @details The show_icon flag should be used very sparingly because menu icons are not recommended + * any longer under the GNOME HIG. Also, note that the text appears after the icon, and + * so will be indented relative to "normal" menu items. As such, menus will look best if + * all the items with icons are grouped together between a pair of separators. */ -static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape::UI::View::View *view, bool radio = false, GSList *group = NULL) +static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, + Inkscape::Verb *verb, + Inkscape::UI::View::View *view, + bool show_icon = false, + bool radio = false, + GSList *group = NULL) { - SPAction *action; GtkWidget *item; + // Just create a menu separator if this isn't a real action. + // Otherwise, create a real menu item if (verb->get_code() == SP_VERB_NONE) { - item = gtk_separator_menu_item_new(); - } else { + SPAction *action = verb->get_action(Inkscape::ActionContext(view)); - action = verb->get_action(Inkscape::ActionContext(view)); if (!action) return NULL; + // Create the menu item itself, either as a radio menu item, or just + // a regular menu item depending on whether the "radio" flag is set if (radio) { - item = gtk_radio_menu_item_new_with_mnemonic(group, action->name); + item = gtk_radio_menu_item_new(group); } else { - item = gtk_image_menu_item_new_with_mnemonic(action->name); + item = gtk_menu_item_new(); } - gtk_label_set_markup_with_mnemonic( GTK_LABEL(gtk_bin_get_child(GTK_BIN (item))), action->name); + // Create a box to contain all the widgets (icon, label, accelerator) + // that will go inside the menu item + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); - GtkAccelGroup *accel_group = sp_shortcut_get_accel_group(); + // Now create the label and add it to the menu item + 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); + gtk_label_set_xalign(GTK_LABEL(label), 0.0); + + GtkAccelGroup *accel_group = sp_shortcut_get_accel_group(); gtk_menu_set_accel_group(menu, accel_group); sp_shortcut_add_accelerator(item, sp_shortcut_get_primary(verb)); + gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), item); + + GtkWidget *icon; + + // If there is an image associated with the action, then we can add it as an + // icon for the menu item. If not, give the label a bit more space + if(show_icon && action->image) { + icon = gtk_image_new_from_icon_name(action->image, GTK_ICON_SIZE_MENU); + } + else { + icon = gtk_label_new(NULL); // A fake icon just to act as a placeholder + } + + gtk_box_pack_start(GTK_BOX(box), icon, FALSE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0); + + // Finally, pack all the widgets into the menu item + gtk_container_add(GTK_CONTAINER(item), box); + action->signal_set_sensitive.connect( sigc::bind<0>( @@ -481,9 +520,6 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb gtk_widget_set_sensitive(item, FALSE); } - if (action->image) { - sp_ui_menuitem_add_icon(item, action->image); - } gtk_widget_set_events(item, GDK_KEY_PRESS_MASK); g_object_set_data(G_OBJECT(item), "view", (gpointer) view); g_signal_connect( G_OBJECT(item), "activate", G_CALLBACK(sp_ui_menu_activate), action ); @@ -491,7 +527,7 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb g_signal_connect( G_OBJECT(item), "deselect", G_CALLBACK(sp_ui_menu_deselect_action), action ); } - gtk_widget_show(item); + gtk_widget_show_all(item); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); return item; @@ -806,11 +842,19 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I } if (!strcmp(menu_pntr->name(), "verb")) { gchar const *verb_name = menu_pntr->attribute("verb-id"); + + // Check if the "show-icon" attribute is set, and set the flag here accordingly + bool show_icon = false; + + if(menu_pntr->attribute("show-icon") != NULL) { + show_icon = true; + } + Inkscape::Verb *verb = Inkscape::Verb::getbyid(verb_name); if (verb != NULL) { if (menu_pntr->attribute("radio") != NULL) { - GtkWidget *item = sp_ui_menu_append_item_from_verb (GTK_MENU(menu), verb, view, true, group); + GtkWidget *item = sp_ui_menu_append_item_from_verb (GTK_MENU(menu), verb, view, show_icon, true, group); group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(item)); if (menu_pntr->attribute("default") != NULL) { gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); @@ -826,7 +870,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I checkitem_toggled, checkitem_update, verb); } } else { - sp_ui_menu_append_item_from_verb(GTK_MENU(menu), verb, view); + sp_ui_menu_append_item_from_verb(GTK_MENU(menu), verb, view, show_icon); group = NULL; } } else { @@ -1382,894 +1426,19 @@ sp_ui_menu_item_set_name(GtkWidget *data, Glib::ustring const &name) if (GTK_IS_LABEL(child)) { gtk_label_set_markup_with_mnemonic(GTK_LABEL (child), name.c_str()); } else if (GTK_IS_BOX(child)) { + GList *children = gtk_container_get_children(GTK_CONTAINER(child)); + + // Label is second child in list + GtkWidget *label = GTK_WIDGET(children->next->data); + gtk_label_set_markup_with_mnemonic( - GTK_LABEL (gtk_container_get_children(GTK_CONTAINER (child))->data), + GTK_LABEL (label), name.c_str()); }//else sp_ui_menu_append_item_from_verb has been modified and can set //a menu item in yet another way... } } } - -void injectRenamedIcons() -{ - Glib::RefPtr<Gtk::IconTheme> iconTheme = Gtk::IconTheme::get_default(); - - std::vector< std::pair<Glib::ustring, Glib::ustring> > renamed; - renamed.push_back(std::make_pair("gtk-file", "document-x-generic")); - renamed.push_back(std::make_pair("gtk-directory", "folder")); - - for ( std::vector< std::pair<Glib::ustring, Glib::ustring> >::iterator it = renamed.begin(); it < renamed.end(); ++it ) { - bool hasIcon = iconTheme->has_icon(it->first); - bool hasSecondIcon = iconTheme->has_icon(it->second); - - if ( !hasIcon && hasSecondIcon ) { - Glib::ArrayHandle<int> sizes = iconTheme->get_icon_sizes(it->second); - for ( Glib::ArrayHandle<int>::iterator it2 = sizes.begin(); it2 < sizes.end(); ++it2 ) { - Glib::RefPtr<Gdk::Pixbuf> pb = iconTheme->load_icon( it->second, *it2 ); - if ( pb ) { - // install a private copy of the pixbuf to avoid pinning a theme - Glib::RefPtr<Gdk::Pixbuf> pbCopy = pb->copy(); - Gtk::IconTheme::add_builtin_icon( it->first, *it2, pbCopy ); - } - } - } - } -} - - -ContextMenu::ContextMenu(SPDesktop *desktop, SPItem *item) : - _item(item), - MIGroup(), - MIParent(_("Go to parent")) -{ -// g_message("ContextMenu"); - _object = static_cast<SPObject *>(item); - _desktop = desktop; - - AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_UNDO)); - AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_REDO)); - AddSeparator(); - AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_CUT)); - AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_COPY)); - AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_PASTE)); - AddSeparator(); - AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DUPLICATE)); - AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DELETE)); - - positionOfLastDialog = 10; // 9 in front + 1 for the separator in the next if; used to position the dialog menu entries below each other - /* Item menu */ - if (item!=NULL) { - AddSeparator(); - MakeObjectMenu(); - } - AddSeparator(); - /* Lock/Unock Hide/Unhide*/ - Geom::Rect b(_desktop->point(),_desktop->point() + Geom::Point(1,1)); - std::vector< SPItem * > down_items = _desktop->getDocument()->getItemsPartiallyInBox( _desktop->dkey, b, true, true); - bool has_down_hidden = false; - bool has_down_locked = false; - for(std::vector< SPItem * >::iterator down = down_items.begin(); down != down_items.end(); ++down){ - if((*down)->isHidden()) { - has_down_hidden = true; - } - if((*down)->isLocked()) { - has_down_locked = true; - } - } - Gtk::MenuItem* mi; - - mi = Gtk::manage(new Gtk::MenuItem(_("Hide selected objects"),1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::HideSelected)); - if (_desktop->selection->isEmpty()) { - mi->set_sensitive(false); - } - mi->show(); - append(*mi);//insert(*mi,positionOfLastDialog++); - - mi = Gtk::manage(new Gtk::MenuItem(_("Unhide objects below"),1)); - mi->signal_activate().connect(sigc::bind<std::vector< SPItem * > >(sigc::mem_fun(*this, &ContextMenu::UnHideBelow), down_items)); - if (!has_down_hidden) { - mi->set_sensitive(false); - } - mi->show(); - append(*mi);//insert(*mi,positionOfLastDialog++); - - mi = Gtk::manage(new Gtk::MenuItem(_("Lock selected objects"),1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::LockSelected)); - if (_desktop->selection->isEmpty()) { - mi->set_sensitive(false); - } - mi->show(); - append(*mi);//insert(*mi,positionOfLastDialog++); - - mi = Gtk::manage(new Gtk::MenuItem(_("Unlock objects below"),1)); - mi->signal_activate().connect(sigc::bind<std::vector< SPItem * > >(sigc::mem_fun(*this, &ContextMenu::UnLockBelow), down_items)); - if (!has_down_locked) { - mi->set_sensitive(false); - } - mi->show(); - append(*mi);//insert(*mi,positionOfLastDialog++); - /* layer menu */ - SPGroup *group=NULL; - if (item) { - if (SP_IS_GROUP(item)) { - group = SP_GROUP(item); - } else if ( item != _desktop->currentRoot() && SP_IS_GROUP(item->parent) ) { - group = SP_GROUP(item->parent); - } - } - - if (( group && group != _desktop->currentLayer() ) || - ( _desktop->currentLayer() != _desktop->currentRoot() && _desktop->currentLayer()->parent != _desktop->currentRoot() ) ) { - AddSeparator(); - } - - if ( group && group != _desktop->currentLayer() ) { - /* TRANSLATORS: #%1 is the id of the group e.g. <g id="#g7">, not a number. */ - MIGroup.set_label (Glib::ustring::compose(_("Enter group #%1"), group->getId())); - MIGroup.set_data("group", group); - MIGroup.signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &ContextMenu::EnterGroup),&MIGroup)); - MIGroup.show(); - append(MIGroup); - } - - if ( _desktop->currentLayer() != _desktop->currentRoot() ) { - if ( _desktop->currentLayer()->parent != _desktop->currentRoot() ) { - MIParent.signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::LeaveGroup)); - MIParent.show(); - append(MIParent); - - /* Pop selection out of group */ - Gtk::MenuItem* miu = Gtk::manage(new Gtk::MenuItem(_("_Pop selection out of group"), 1)); - miu->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroupPopSelection)); - miu->show(); - append(*miu); - } - } -} - -ContextMenu::~ContextMenu(void) -{ -} - -Gtk::SeparatorMenuItem* ContextMenu::AddSeparator(void) -{ - Gtk::SeparatorMenuItem* sep = Gtk::manage(new Gtk::SeparatorMenuItem()); - sep->show(); - append(*sep); - return sep; -} - -void ContextMenu::EnterGroup(Gtk::MenuItem* mi) -{ - _desktop->setCurrentLayer(reinterpret_cast<SPObject *>(mi->get_data("group"))); - _desktop->selection->clear(); -} - -void ContextMenu::LeaveGroup(void) -{ - _desktop->setCurrentLayer(_desktop->currentLayer()->parent); -} - -void ContextMenu::LockSelected(void) -{ - auto itemlist = _desktop->selection->items(); - for(auto i=itemlist.begin();i!=itemlist.end(); ++i) { - (*i)->setLocked(true); - } -} - -void ContextMenu::HideSelected(void) -{ - auto itemlist =_desktop->selection->items(); - for(auto i=itemlist.begin();i!=itemlist.end(); ++i) { - (*i)->setHidden(true); - } -} - -void ContextMenu::UnLockBelow(std::vector<SPItem *> items) -{ - _desktop->selection->clear(); - for(auto i=items.begin();i!=items.end(); ++i) { - if ((*i)->isLocked()) { - (*i)->setLocked(false); - _desktop->selection->add(*i); - } - } -} - -void ContextMenu::UnHideBelow(std::vector<SPItem *> items) -{ - _desktop->selection->clear(); - for(auto i=items.begin();i!=items.end(); ++i) { - if ((*i)->isHidden()) { - (*i)->setHidden(false); - _desktop->selection->add(*i); - } - } -} - -void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb)//, SPDesktop *view)//, bool radio, GSList *group) -{ - SPAction *action; - SPDesktop *view = _desktop; - - if (verb->get_code() == SP_VERB_NONE) { - Gtk::MenuItem *item = AddSeparator(); - item->show(); - append(*item); - } else { - action = verb->get_action(Inkscape::ActionContext(view)); - if (!action) { - return; - } - - Gtk::ImageMenuItem *item = Gtk::manage(new Gtk::ImageMenuItem(action->name, true)); - - sp_shortcut_add_accelerator(GTK_WIDGET(item->gobj()), sp_shortcut_get_primary(verb)); - - action->signal_set_sensitive.connect(sigc::mem_fun(*this, &ContextMenu::set_sensitive)); - action->signal_set_name.connect(sigc::mem_fun(*item, &ContextMenu::set_name)); - - if (!action->sensitive) { - item->set_sensitive(FALSE); - } - - if (action->image) { - sp_ui_menuitem_add_icon((GtkWidget*)item->gobj(), action->image); - } - item->set_events(Gdk::KEY_PRESS_MASK); - item->signal_activate().connect(sigc::bind(sigc::ptr_fun(sp_ui_menu_activate),item,action)); - item->signal_select().connect(sigc::bind(sigc::ptr_fun(sp_ui_menu_select_action),item,action)); - item->signal_deselect().connect(sigc::bind(sigc::ptr_fun(sp_ui_menu_deselect_action),item,action)); - item->show(); - append(*item); - } -} - -void ContextMenu::MakeObjectMenu(void) -{ -// GObjectClass *klass = G_OBJECT_GET_CLASS(_object); //to deduce the object's type from its class -// -// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_ITEM)) -// { -// MakeItemMenu (); -// } -// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_GROUP)) -// { -// MakeGroupMenu(); -// } -// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_ANCHOR)) -// { -// MakeAnchorMenu(); -// } -// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_IMAGE)) -// { -// MakeImageMenu(); -// } -// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_SHAPE)) -// { -// MakeShapeMenu(); -// } -// if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_TEXT)) -// { -// MakeTextMenu(); -// } - - if (SP_IS_ITEM(_object)) { - MakeItemMenu(); - } - - if (SP_IS_GROUP(_object)) { - MakeGroupMenu(); - } - - if (SP_IS_ANCHOR(_object)) { - MakeAnchorMenu(); - } - - if (SP_IS_IMAGE(_object)) { - MakeImageMenu(); - } - - if (SP_IS_SHAPE(_object)) { - MakeShapeMenu(); - } - - if (SP_IS_TEXT(_object)) { - MakeTextMenu(); - } -} - -void ContextMenu::MakeItemMenu (void) -{ - Gtk::MenuItem* mi; - - /* Item dialog */ - mi = Gtk::manage(new Gtk::MenuItem(_("_Object Properties..."),1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemProperties)); - mi->show(); - append(*mi);//insert(*mi,positionOfLastDialog++); - - AddSeparator(); - - /* Select item */ - if (Inkscape::Verb::getbyid( "org.inkscape.followlink" )) { - mi = Gtk::manage(new Gtk::MenuItem(_("_Select This"), 1)); - if (_desktop->selection->includes(_item)) { - mi->set_sensitive(FALSE); - } else { - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemSelectThis)); - } - mi->show(); - append(*mi); - } - - - mi = Gtk::manage(new Gtk::MenuItem(_("Select Same"))); - mi->show(); - Gtk::Menu *select_same_submenu = Gtk::manage(new Gtk::Menu()); - if (_desktop->selection->isEmpty()) { - mi->set_sensitive(FALSE); - } - mi->set_submenu(*select_same_submenu); - append(*mi); - - /* Select same fill and stroke */ - mi = Gtk::manage(new Gtk::MenuItem(_("Fill and Stroke"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameFillStroke)); - mi->set_sensitive(!SP_IS_ANCHOR(_item)); - mi->show(); - select_same_submenu->append(*mi); - - /* Select same fill color */ - mi = Gtk::manage(new Gtk::MenuItem(_("Fill Color"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameFillColor)); - mi->set_sensitive(!SP_IS_ANCHOR(_item)); - mi->show(); - select_same_submenu->append(*mi); - - /* Select same stroke color */ - mi = Gtk::manage(new Gtk::MenuItem(_("Stroke Color"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameStrokeColor)); - mi->set_sensitive(!SP_IS_ANCHOR(_item)); - mi->show(); - select_same_submenu->append(*mi); - - /* Select same stroke style */ - mi = Gtk::manage(new Gtk::MenuItem(_("Stroke Style"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameStrokeStyle)); - mi->set_sensitive(!SP_IS_ANCHOR(_item)); - mi->show(); - select_same_submenu->append(*mi); - - /* Select same stroke style */ - mi = Gtk::manage(new Gtk::MenuItem(_("Object type"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameObjectType)); - mi->set_sensitive(!SP_IS_ANCHOR(_item)); - mi->show(); - select_same_submenu->append(*mi); - - /* Move to layer */ - mi = Gtk::manage(new Gtk::MenuItem(_("_Move to layer ..."), 1)); - if (_desktop->selection->isEmpty()) { - mi->set_sensitive(FALSE); - } else { - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemMoveTo)); - } - mi->show(); - append(*mi); - - /* Create link */ - mi = Gtk::manage(new Gtk::MenuItem(_("Create _Link"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemCreateLink)); - mi->set_sensitive(!SP_IS_ANCHOR(_item)); - mi->show(); - append(*mi); - - bool ClipRefOK=false; - bool MaskRefOK=false; - if (_item){ - if (_item->clip_ref){ - if (_item->clip_ref->getObject()){ - ClipRefOK=true; - } - } - } - if (_item){ - if (_item->mask_ref){ - if (_item->mask_ref->getObject()){ - MaskRefOK=true; - } - } - } - /* Set mask */ - mi = Gtk::manage(new Gtk::MenuItem(_("Set Mask"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetMask)); - if (ClipRefOK || MaskRefOK) { - mi->set_sensitive(FALSE); - } else { - mi->set_sensitive(TRUE); - } - mi->show(); - append(*mi); - - /* Release mask */ - mi = Gtk::manage(new Gtk::MenuItem(_("Release Mask"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseMask)); - if (MaskRefOK) { - mi->set_sensitive(TRUE); - } else { - mi->set_sensitive(FALSE); - } - mi->show(); - append(*mi); - - /*SSet Clip Group */ - mi = Gtk::manage(new Gtk::MenuItem(_("Create Clip G_roup"),1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::CreateGroupClip)); - mi->set_sensitive(TRUE); - mi->show(); - append(*mi); - - /* Set Clip */ - mi = Gtk::manage(new Gtk::MenuItem(_("Set Cl_ip"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetClip)); - if (ClipRefOK || MaskRefOK) { - mi->set_sensitive(FALSE); - } else { - mi->set_sensitive(TRUE); - } - mi->show(); - append(*mi); - - /* Release Clip */ - mi = Gtk::manage(new Gtk::MenuItem(_("Release C_lip"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseClip)); - if (ClipRefOK) { - mi->set_sensitive(TRUE); - } else { - mi->set_sensitive(FALSE); - } - mi->show(); - append(*mi); - - /* Group */ - mi = Gtk::manage(new Gtk::MenuItem(_("_Group"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateGroup)); - if (_desktop->selection->isEmpty()) { - mi->set_sensitive(FALSE); - } else { - mi->set_sensitive(TRUE); - } - mi->show(); - append(*mi); -} - -void ContextMenu::SelectSameFillStroke(void) -{ - sp_select_same_fill_stroke_style(_desktop, true, true, true); -} - -void ContextMenu::SelectSameFillColor(void) -{ - sp_select_same_fill_stroke_style(_desktop, true, false, false); -} - -void ContextMenu::SelectSameStrokeColor(void) -{ - sp_select_same_fill_stroke_style(_desktop, false, true, false); -} - -void ContextMenu::SelectSameStrokeStyle(void) -{ - sp_select_same_fill_stroke_style(_desktop, false, false, true); -} - -void ContextMenu::SelectSameObjectType(void) -{ - sp_select_same_object_type(_desktop); -} - -void ContextMenu::ItemProperties(void) -{ - _desktop->selection->set(_item); - _desktop->_dlg_mgr->showDialog("ObjectProperties"); -} - -void ContextMenu::ItemSelectThis(void) -{ - _desktop->selection->set(_item); -} - -void ContextMenu::ItemMoveTo(void) -{ - Inkscape::UI::Dialogs::LayerPropertiesDialog::showMove(_desktop, _desktop->currentLayer()); -} - - - -void ContextMenu::ItemCreateLink(void) -{ - Inkscape::XML::Document *xml_doc = _desktop->doc()->getReprDoc(); - Inkscape::XML::Node *repr = xml_doc->createElement("svg:a"); - _item->parent->getRepr()->addChild(repr, _item->getRepr()); - SPObject *object = _item->document->getObjectByRepr(repr); - g_return_if_fail(SP_IS_ANCHOR(object)); - - const char *id = _item->getRepr()->attribute("id"); - Inkscape::XML::Node *child = _item->getRepr()->duplicate(xml_doc); - _item->deleteObject(false); - repr->addChild(child, NULL); - child->setAttribute("id", id); - - Inkscape::GC::release(repr); - Inkscape::GC::release(child); - - DocumentUndo::done(object->document, SP_VERB_NONE, _("Create link")); - - _desktop->selection->set(SP_ITEM(object)); - _desktop->_dlg_mgr->showDialog("ObjectAttributes"); -} - -void ContextMenu::SetMask(void) -{ - _desktop->selection->setMask(false, false); -} - -void ContextMenu::ReleaseMask(void) -{ - _desktop->selection->unsetMask(false); -} - -void ContextMenu::CreateGroupClip(void) -{ - _desktop->selection->setClipGroup(); -} - -void ContextMenu::SetClip(void) -{ - _desktop->selection->setMask(true, false); -} - - -void ContextMenu::ReleaseClip(void) -{ - _desktop->selection->unsetMask(true); -} - -void ContextMenu::MakeGroupMenu(void) -{ - /* Ungroup */ - Gtk::MenuItem* mi = Gtk::manage(new Gtk::MenuItem(_("_Ungroup"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroup)); - mi->show(); - append(*mi); -} - -void ContextMenu::ActivateGroup(void) -{ - _desktop->selection->group(); -} - -void ContextMenu::ActivateUngroup(void) -{ - std::vector<SPItem*> children; - - sp_item_group_ungroup(static_cast<SPGroup*>(_item), children); - _desktop->selection->setList(children); -} - -void ContextMenu::ActivateUngroupPopSelection(void) -{ - _desktop->selection->popFromGroup(); -} - - -void ContextMenu::MakeAnchorMenu(void) -{ - Gtk::MenuItem* mi; - - /* Link dialog */ - mi = Gtk::manage(new Gtk::MenuItem(_("Link _Properties..."), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkProperties)); - mi->show(); - insert(*mi,positionOfLastDialog++); - - /* Select item */ - mi = Gtk::manage(new Gtk::MenuItem(_("_Follow Link"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkFollow)); - mi->show(); - append(*mi); - - /* Reset transformations */ - mi = Gtk::manage(new Gtk::MenuItem(_("_Remove Link"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkRemove)); - mi->show(); - append(*mi); -} - -void ContextMenu::AnchorLinkProperties(void) -{ - _desktop->_dlg_mgr->showDialog("ObjectAttributes"); -} - -void ContextMenu::AnchorLinkFollow(void) -{ - - if (_desktop->selection->isEmpty()) { - _desktop->selection->set(_item); - } - // Opening the selected links with a python extension - Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.inkscape.followlink" ); - if (verb) { - SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop)); - if (action) { - sp_action_perform(action, NULL); - } - } -} - -void ContextMenu::AnchorLinkRemove(void) -{ - std::vector<SPItem*> children; - sp_item_group_ungroup(static_cast<SPAnchor*>(_item), children, false); - DocumentUndo::done(_desktop->doc(), SP_VERB_NONE, _("Remove link")); -} - -void ContextMenu::MakeImageMenu (void) -{ - Gtk::MenuItem* mi; - Inkscape::XML::Node *ir = _object->getRepr(); - const gchar *href = ir->attribute("xlink:href"); - - /* Image properties */ - mi = Gtk::manage(new Gtk::MenuItem(_("Image _Properties..."), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageProperties)); - mi->show(); - insert(*mi,positionOfLastDialog++); - - /* Edit externally */ - mi = Gtk::manage(new Gtk::MenuItem(_("Edit Externally..."), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEdit)); - mi->show(); - insert(*mi,positionOfLastDialog++); - if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { - mi->set_sensitive( FALSE ); - } - - /* Trace Bitmap */ - mi = Gtk::manage(new Gtk::MenuItem(_("_Trace Bitmap..."), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageTraceBitmap)); - mi->show(); - insert(*mi,positionOfLastDialog++); - if (_desktop->selection->isEmpty()) { - mi->set_sensitive(FALSE); - } - - /* Trace Pixel Art */ - mi = Gtk::manage(new Gtk::MenuItem(_("Trace Pixel Art"), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageTracePixelArt)); - mi->show(); - insert(*mi,positionOfLastDialog++); - if (_desktop->selection->isEmpty()) { - mi->set_sensitive(FALSE); - } - - /* Embed image */ - if (Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" )) { - mi = Gtk::manage(new Gtk::MenuItem(C_("Context menu", "Embed Image"))); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEmbed)); - mi->show(); - insert(*mi,positionOfLastDialog++); - if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { - mi->set_sensitive( FALSE ); - } - } - - /* Extract image */ - if (Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" )) { - mi = Gtk::manage(new Gtk::MenuItem(C_("Context menu", "Extract Image..."))); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageExtract)); - mi->show(); - insert(*mi,positionOfLastDialog++); - if ( (!href) || ((strncmp(href, "data:", 5) != 0)) ) { - mi->set_sensitive( FALSE ); - } - } -} - -void ContextMenu::ImageProperties(void) -{ - _desktop->_dlg_mgr->showDialog("ObjectAttributes"); -} - -Glib::ustring ContextMenu::getImageEditorName() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring value; - Glib::ustring choices = prefs->getString("/options/bitmapeditor/value"); - if (!choices.empty()) { - value = choices; - } - else { - value = "gimp"; - } - return value; -} - -void ContextMenu::ImageEdit(void) -{ - if (_desktop->selection->isEmpty()) { - _desktop->selection->set(_item); - } - - GError* errThing = 0; - Glib::ustring cmdline = getImageEditorName(); - Glib::ustring name; - Glib::ustring fullname; - -#ifdef WIN32 - // g_spawn_command_line_sync parsing is done according to Unix shell rules, - // not Windows command interpreter rules. Thus we need to enclose the - // executable path with single quotes. - int index = cmdline.find(".exe"); - if ( index < 0 ) index = cmdline.find(".bat"); - if ( index < 0 ) index = cmdline.find(".com"); - if ( index >= 0 ) { - Glib::ustring editorBin = cmdline.substr(0, index + 4).c_str(); - Glib::ustring args = cmdline.substr(index + 4, cmdline.length()).c_str(); - editorBin.insert(0, "'"); - editorBin.append("'"); - cmdline = editorBin; - cmdline.append(args); - } else { - // Enclose the whole command line if no executable path can be extracted. - cmdline.insert(0, "'"); - cmdline.append("'"); - } -#endif - - auto itemlist= _desktop->selection->items(); - for(auto i=itemlist.begin();i!=itemlist.end();++i){ - Inkscape::XML::Node *ir = (*i)->getRepr(); - const gchar *href = ir->attribute("xlink:href"); - - if (strncmp (href,"file:",5) == 0) { - // URI to filename conversion - name = g_filename_from_uri(href, NULL, NULL); - } else { - name.append(href); - } - - if (Glib::path_is_absolute(name)) { - fullname = name; - } else if (SP_ACTIVE_DOCUMENT->getBase()) { - fullname = Glib::build_filename(SP_ACTIVE_DOCUMENT->getBase(), name); - } else { - fullname = Glib::build_filename(Glib::get_current_dir(), name); - } - - cmdline.append(" '"); - cmdline.append(fullname.c_str()); - cmdline.append("'"); - } - - //g_warning("##Command line: %s\n", cmdline.c_str()); - - g_spawn_command_line_async(cmdline.c_str(), &errThing); - - if ( errThing ) { - g_warning("Problem launching editor (%d). %s", errThing->code, errThing->message); - (_desktop->messageStack())->flash(Inkscape::ERROR_MESSAGE, errThing->message); - g_error_free(errThing); - errThing = 0; - } -} - -void ContextMenu::ImageTraceBitmap(void) -{ - INKSCAPE.dialogs_unhide(); - _desktop->_dlg_mgr->showDialog("Trace"); -} - -void ContextMenu::ImageTracePixelArt(void) -{ - INKSCAPE.dialogs_unhide(); - _desktop->_dlg_mgr->showDialog("PixelArt"); -} - -void ContextMenu::ImageEmbed(void) -{ - if (_desktop->selection->isEmpty()) { - _desktop->selection->set(_item); - } - - Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" ); - if (verb) { - SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop)); - if (action) { - sp_action_perform(action, NULL); - } - } -} - -void ContextMenu::ImageExtract(void) -{ - if (_desktop->selection->isEmpty()) { - _desktop->selection->set(_item); - } - - Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" ); - if (verb) { - SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop)); - if (action) { - sp_action_perform(action, NULL); - } - } -} - -void ContextMenu::MakeShapeMenu (void) -{ - Gtk::MenuItem* mi; - - /* Item dialog */ - mi = Gtk::manage(new Gtk::MenuItem(_("_Fill and Stroke..."), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings)); - mi->show(); - insert(*mi,positionOfLastDialog++); -} - -void ContextMenu::FillSettings(void) -{ - if (_desktop->selection->isEmpty()) { - _desktop->selection->set(_item); - } - - _desktop->_dlg_mgr->showDialog("FillAndStroke"); -} - -void ContextMenu::MakeTextMenu (void) -{ - Gtk::MenuItem* mi; - - /* Fill and Stroke dialog */ - mi = Gtk::manage(new Gtk::MenuItem(_("_Fill and Stroke..."), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings)); - mi->show(); - insert(*mi,positionOfLastDialog++); - - /* Edit Text dialog */ - mi = Gtk::manage(new Gtk::MenuItem(_("_Text and Font..."), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::TextSettings)); - mi->show(); - insert(*mi,positionOfLastDialog++); - - /* Spellcheck dialog */ - mi = Gtk::manage(new Gtk::MenuItem(_("Check Spellin_g..."), 1)); - mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SpellcheckSettings)); - mi->show(); - insert(*mi,positionOfLastDialog++); -} - -void ContextMenu::TextSettings (void) -{ - if (_desktop->selection->isEmpty()) { - _desktop->selection->set(_item); - } - - _desktop->_dlg_mgr->showDialog("TextFont"); -} - -void ContextMenu::SpellcheckSettings (void) -{ - if (_desktop->selection->isEmpty()) { - _desktop->selection->set(_item); - } - - _desktop->_dlg_mgr->showDialog("SpellCheck"); -} - /* Local Variables: mode:c++ diff --git a/src/ui/interface.h b/src/ui/interface.h index a41c36cc3..6e95c161c 100644 --- a/src/ui/interface.h +++ b/src/ui/interface.h @@ -17,23 +17,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -//#ifdef HAVE_CONFIG_H -//# include <config.h> -//#endif +#include <glibmm/ustring.h> -#include <gtkmm/menu.h> - -class SPItem; -class SPObject; -class SPDesktop; class SPViewWidget; -namespace Gtk { -class SeparatorMenuItem; -} +typedef struct _GtkWidget GtkWidget; namespace Inkscape { - class Verb; namespace UI { @@ -93,181 +83,6 @@ Glib::ustring getLayoutPrefPath( Inkscape::UI::View::View *view ); void sp_ui_error_dialog (char const* message); bool sp_ui_overwrite_file (char const* filename); - -/** - * Implements the Inkscape context menu. - * - * For the context menu implementation, the ContextMenu class stores the object - * that was selected in a private data member. This should be farely safe to do - * and a pointer to the SPItem as well as SPObject class are kept. - * All callbacks of the context menu entries are implemented as private - * functions. - * - * @todo add callbacks to destroy the context menu when it is closed (=key or mouse button pressed out of the scope of the context menu) - */ -class ContextMenu : public Gtk::Menu -{ - public: - /** - * The ContextMenu constructor contains all code to create and show the - * menu entries (aka child widgets). - * - * @param desktop pointer to the desktop the user is currently working on. - * @param item SPItem pointer to the object selected at the time the ContextMenu is created. - */ - ContextMenu(SPDesktop *desktop, SPItem *item); - ~ContextMenu(void); - - private: - SPItem *_item; // pointer to the object selected at the time the ContextMenu is created - SPObject *_object; // pointer to the object selected at the time the ContextMenu is created - SPDesktop *_desktop; //pointer to the desktop the user was currently working on at the time the ContextMenu is created - - int positionOfLastDialog; - - Gtk::MenuItem MIGroup; //menu entry to enter a group - Gtk::MenuItem MIParent; //menu entry to leave a group - - /** - * auxiliary function that adds a separator line in the context menu - */ - Gtk::SeparatorMenuItem* AddSeparator(void); - - /** - * c++ified version of sp_ui_menu_append_item. - * - * @see sp_ui_menu_append_item_from_verb and synchronize/drop that function when c++ifying other code in interface.cpp - */ - void AppendItemFromVerb(Inkscape::Verb *verb); - - /** - * main function which is responsible for creating the context sensitive menu items, - * calls subfunctions below to create the menu entry widgets. - */ - void MakeObjectMenu (void); - /** - * creates menu entries for an SP_TYPE_ITEM object - */ - void MakeItemMenu (void); - /** - * creates menu entries for a grouped object - */ - void MakeGroupMenu (void); - /** - * creates menu entries for an anchor object - */ - void MakeAnchorMenu (void); - /** - * creates menu entries for a bitmap image object - */ - void MakeImageMenu (void); - /** - * creates menu entries for a shape object - */ - void MakeShapeMenu (void); - /** - * creates menu entries for a text object - */ - void MakeTextMenu (void); - - void EnterGroup(Gtk::MenuItem* mi); - void LeaveGroup(void); - void LockSelected(void); - void HideSelected(void); - void UnLockBelow(std::vector<SPItem *> items); - void UnHideBelow(std::vector<SPItem *> items); - ////////////////////////////////////////// - //callbacks for the context menu entries of an SP_TYPE_ITEM object - void ItemProperties(void); - void ItemSelectThis(void); - void ItemMoveTo(void); - void SelectSameFillStroke(void); - void SelectSameFillColor(void); - void SelectSameStrokeColor(void); - void SelectSameStrokeStyle(void); - void SelectSameObjectType(void); - void ItemCreateLink(void); - void CreateGroupClip(void); - void SetMask(void); - void ReleaseMask(void); - void SetClip(void); - void ReleaseClip(void); - ////////////////////////////////////////// - - - /** - * callback, is executed on clicking the anchor "Group" and "Ungroup" menu entry - */ - void ActivateUngroupPopSelection(void); - void ActivateUngroup(void); - void ActivateGroup(void); - - void AnchorLinkProperties(void); - /** - * placeholder for callback to be executed on clicking the anchor "Follow link" context menu entry - * @todo add code to follow link externally - */ - void AnchorLinkFollow(void); - - /** - * callback, is executed on clicking the anchor "Link remove" menu entry - */ - void AnchorLinkRemove(void); - - - /** - * callback, opens the image properties dialog and is executed on clicking the context menu entry with similar name - */ - void ImageProperties(void); - - /** - * callback, is executed on clicking the image "Edit Externally" menu entry - */ - void ImageEdit(void); - - /** - * auxiliary function that loads the external image editor name from the settings. - */ - Glib::ustring getImageEditorName(); - - /** - * callback, is executed on clicking the "Embed Image" menu entry - */ - void ImageEmbed(void); - - /** - * callback, is executed on clicking the "Trace Bitmap" menu entry - */ - void ImageTraceBitmap(void); - - /** - * callback, is executed on clicking the "Trace Pixel Art" menu entry - */ - void ImageTracePixelArt(void); - - /** - * callback, is executed on clicking the "Extract Image" menu entry - */ - void ImageExtract(void); - - - /** - * callback, is executed on clicking the "Fill and Stroke" menu entry - */ - void FillSettings(void); - - - /** - * callback, is executed on clicking the "Text and Font" menu entry - */ - void TextSettings(void); - - /** - * callback, is executed on clicking the "Check spelling" menu entry - */ - void SpellcheckSettings(void); -}; - #endif // SEEN_SP_INTERFACE_H /* diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp index 6fec65124..e294bd408 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -149,7 +149,6 @@ void PreviewHolder::addPreview( Previewable* preview ) auto target = kids[childCount - (j + 1)]; int col2 = j % width; int row2 = j / width; - Glib::RefPtr<Gtk::Widget> handle(target); _insides->remove( *target ); target->set_hexpand(); diff --git a/src/ui/shape-editor.cpp b/src/ui/shape-editor.cpp index 98320ed8c..6a8f5e931 100644 --- a/src/ui/shape-editor.cpp +++ b/src/ui/shape-editor.cpp @@ -17,6 +17,9 @@ #include "desktop.h" #include "document.h" #include "knotholder.h" +#include "sp-shape.h" +#include "sp-path.h" +#include "inkscape.h" #include "ui/object-edit.h" #include "ui/shape-editor.h" #include "xml/node-event-vector.h" @@ -81,7 +84,7 @@ const SPItem *ShapeEditor::get_item() { return item; } -void ShapeEditor::event_attr_changed(Inkscape::XML::Node *, gchar const *name, gchar const *, gchar const *, bool, void *data) +void ShapeEditor::event_attr_changed(Inkscape::XML::Node * node, gchar const *name, gchar const *, gchar const *, bool, void *data) { g_assert(data); ShapeEditor *sh = static_cast<ShapeEditor *>(data); @@ -94,7 +97,9 @@ void ShapeEditor::event_attr_changed(Inkscape::XML::Node *, gchar const *name, g if (changed_kh) { // this can happen if an LPEItem's knotholder handle was dragged, in which case we want // to keep the knotholder; in all other cases (e.g., if the LPE itself changes) we delete it - sh->reset_item(!strcmp(name, "d")); + SPObject * obj = SP_ACTIVE_DOCUMENT->getObjectById(node->attribute("id")); + bool is_shape = SP_IS_SHAPE(obj) && !SP_IS_PATH(obj); + sh->reset_item(!strcmp(name, "d") || is_shape); } } } @@ -112,7 +117,6 @@ void ShapeEditor::set_item(SPItem *item, bool keep_knotholder) { if (_blockSetItem) { return; } - // this happens (and should only happen) when for an LPEItem having both knotholder and // nodepath the knotholder is adapted; in this case we don't want to delete the knotholder // since this freezes the handles @@ -155,6 +159,7 @@ bool ShapeEditor::knot_mouseover() const { if (this->knotholder) { return knotholder->knot_mouseover(); } + return false; } diff --git a/src/ui/shape-editor.h b/src/ui/shape-editor.h index 142a2493b..7f435efca 100644 --- a/src/ui/shape-editor.h +++ b/src/ui/shape-editor.h @@ -35,20 +35,17 @@ public: void decrement_local_change(); bool knot_mouseover() const; - + KnotHolder *knotholder; + bool has_knotholder(); static void blockSetItem(bool b) { _blockSetItem = b; } // kludge - static void event_attr_changed(Inkscape::XML::Node * /*repr*/, char const *name, char const * /*old_value*/, char const * /*new_value*/, bool /*is_interactive*/, void *data); private: - bool has_knotholder(); void reset_item (bool keep_knotholder = true); const SPItem *get_item(); - static bool _blockSetItem; SPDesktop *desktop; - KnotHolder *knotholder; Inkscape::XML::Node *knotholder_listener_attached_for; }; diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp index 6652f7ab5..b501962fb 100644 --- a/src/ui/tools/arc-tool.cpp +++ b/src/ui/tools/arc-tool.cpp @@ -59,7 +59,7 @@ const std::string ArcTool::prefsPath = "/tools/shapes/arc"; ArcTool::ArcTool() - : ToolBase(cursor_ellipse_xpm, 4, 4) + : ToolBase(cursor_ellipse_xpm) , arc(NULL) { } @@ -244,15 +244,6 @@ bool ArcTool::root_handler(GdkEvent* event) { } break; - case GDK_KEY_Up: - case GDK_KEY_Down: - case GDK_KEY_KP_Up: - case GDK_KEY_KP_Down: - // prevent the zoom field from activation - if (!MOD__CTRL_ONLY(event)) - handled = true; - break; - case GDK_KEY_x: case GDK_KEY_X: if (MOD__ALT_ONLY(event)) { diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 425695a2c..276385335 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -54,7 +54,7 @@ const std::string& Box3dTool::getPrefsPath() { const std::string Box3dTool::prefsPath = "/tools/shapes/3dbox"; Box3dTool::Box3dTool() - : ToolBase(cursor_3dbox_xpm, 4, 4) + : ToolBase(cursor_3dbox_xpm) , _vpdrag(NULL) , box3d(NULL) , ctrl_dragged(false) diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 7228a52bc..266375caa 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -88,7 +88,7 @@ const std::string& CalligraphicTool::getPrefsPath() { const std::string CalligraphicTool::prefsPath = "/tools/calligraphic"; CalligraphicTool::CalligraphicTool() - : DynamicBase(cursor_calligraphy_xpm, 4, 4) + : DynamicBase(cursor_calligraphy_xpm) , keep_selected(true) , hatch_spacing(0) , hatch_spacing_step(0) diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 7e6fb4b72..6d2682089 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -145,7 +145,7 @@ const std::string& ConnectorTool::getPrefsPath() { const std::string ConnectorTool::prefsPath = "/tools/connector"; ConnectorTool::ConnectorTool() - : ToolBase(cursor_connector_xpm, 1, 1) + : ToolBase(cursor_connector_xpm) , selection(NULL) , npoints(0) , state(SP_CONNECTOR_CONTEXT_IDLE) @@ -348,7 +348,7 @@ cc_select_handle(SPKnot* knot) knot->setShape(SP_KNOT_SHAPE_SQUARE); knot->setSize(10); knot->setAnchor(SP_ANCHOR_CENTER); - knot->setFill(0x0000ffff, 0x0000ffff, 0x0000ffff); + knot->setFill(0x0000ffff, 0x0000ffff, 0x0000ffff, 0x0000ffff); knot->updateCtrl(); } @@ -358,7 +358,7 @@ cc_deselect_handle(SPKnot* knot) knot->setShape(SP_KNOT_SHAPE_SQUARE); knot->setSize(8); knot->setAnchor(SP_ANCHOR_CENTER); - knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff); + knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff, 0xff0000ff); knot->updateCtrl(); } @@ -941,8 +941,7 @@ void ConnectorTool::_finish() { this->npoints = 0; if (this->newConnRef) { - this->newConnRef->removeFromGraph(); - delete this->newConnRef; + this->newConnRef->router()->deleteConnector(this->newConnRef); this->newConnRef = NULL; } } @@ -1058,7 +1057,7 @@ void ConnectorTool::_activeShapeAddKnot(SPItem* item) { knot->setShape(SP_KNOT_SHAPE_SQUARE); knot->setSize(8); knot->setAnchor(SP_ANCHOR_CENTER); - knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff); + knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff, 0xff0000ff); knot->updateCtrl(); // We don't want to use the standard knot handler. @@ -1176,8 +1175,8 @@ void ConnectorTool::cc_set_active_conn(SPItem *item) { knot->setShape(SP_KNOT_SHAPE_SQUARE); knot->setSize(7); knot->setAnchor(SP_ANCHOR_CENTER); - knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff); - knot->setStroke(0x000000ff, 0x000000ff, 0x000000ff); + knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff, 0xff0000ff); + knot->setStroke(0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff); knot->updateCtrl(); // We don't want to use the standard knot handler, diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index 99177dc75..53a99e481 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -39,6 +39,8 @@ #include "pixmaps/cursor-dropper-f.xpm" #include "pixmaps/cursor-dropper-s.xpm" +#include "pixmaps/cursor-dropping-f.xpm" +#include "pixmaps/cursor-dropping-s.xpm" #include "ui/tools/dropper-tool.h" #include "message-context.h" @@ -46,9 +48,6 @@ using Inkscape::DocumentUndo; -static GdkCursor *cursor_dropper_fill = NULL; -static GdkCursor *cursor_dropper_stroke = NULL; - namespace Inkscape { namespace UI { namespace Tools { @@ -60,18 +59,20 @@ const std::string& DropperTool::getPrefsPath() { const std::string DropperTool::prefsPath = "/tools/dropper"; DropperTool::DropperTool() - : ToolBase(cursor_dropper_f_xpm, 5, 5) + : ToolBase(cursor_dropper_f_xpm) , R(0) , G(0) , B(0) , alpha(0) + , radius(0) + , invert(false) + , stroke(false) + , dropping(false) , dragging(false) , grabbed(NULL) , area(NULL) , centre(0, 0) { - cursor_dropper_fill = sp_cursor_new_from_xpm(cursor_dropper_f_xpm , 5, 5); - cursor_dropper_stroke = sp_cursor_new_from_xpm(cursor_dropper_s_xpm , 5, 5); } DropperTool::~DropperTool() { @@ -117,41 +118,84 @@ void DropperTool::finish() { this->area = NULL; } - if (cursor_dropper_fill) { - g_object_unref(cursor_dropper_fill); - cursor_dropper_fill = NULL; - } - - if (cursor_dropper_stroke) { - g_object_unref(cursor_dropper_stroke); - cursor_dropper_fill = NULL; - } - ToolBase::finish(); } /** * Returns the current dropper context color. */ -guint32 DropperTool::get_color() { +guint32 DropperTool::get_color(bool invert) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int pick = prefs->getInt("/tools/dropper/pick", SP_DROPPER_PICK_VISIBLE); bool setalpha = prefs->getBool("/tools/dropper/setalpha", true); - return SP_RGBA32_F_COMPOSE(this->R, - this->G, - this->B, - (pick == SP_DROPPER_PICK_ACTUAL && setalpha) ? this->alpha : 1.0); + return SP_RGBA32_F_COMPOSE( + fabs(invert - this->R), + fabs(invert - this->G), + fabs(invert - this->B), + (pick == SP_DROPPER_PICK_ACTUAL && setalpha) ? this->alpha : 1.0); } bool DropperTool::root_handler(GdkEvent* event) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int ret = FALSE; - int pick = prefs->getInt("/tools/dropper/pick", SP_DROPPER_PICK_VISIBLE); - bool setalpha = prefs->getBool("/tools/dropper/setalpha", true); + + // Decide first what kind of 'mode' we're in. + if (event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE) { + switch (event->key.keyval) { + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + this->stroke = event->type == GDK_KEY_PRESS; + break; + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: + this->dropping = event->type == GDK_KEY_PRESS; + break; + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: + this->invert = event->type == GDK_KEY_PRESS; + break; + } + } + + // Get color from selected object instead. + if(this->dropping) { + Inkscape::Selection *selection = desktop->getSelection(); + g_assert(selection); + guint32 apply_color; + bool apply_set = false; + for (auto& obj: selection->objects()) { + if(obj->style) { + double opacity = 1.0; + if(!this->stroke && obj->style->fill.set) { + if(obj->style->fill_opacity.set) { + opacity = obj->style->fill_opacity.value; + } + apply_color = obj->style->fill.value.color.toRGBA32(opacity); + apply_set = true; + } else if(this->stroke && obj->style->stroke.set) { + if(obj->style->stroke_opacity.set) { + opacity = obj->style->stroke_opacity.value; + } + apply_color = obj->style->stroke.value.color.toRGBA32(opacity); + apply_set = true; + } + } + } + if(apply_set) { + this->R = SP_RGBA32_R_F(apply_color); + this->G = SP_RGBA32_G_F(apply_color); + this->B = SP_RGBA32_B_F(apply_color); + this->alpha = SP_RGBA32_A_F(apply_color); + } else { + // This means that having no selection or some other error + // we will default back to normal dropper mode. + this->dropping = false; + } + } switch (event->type) { case GDK_BUTTON_PRESS: @@ -160,11 +204,12 @@ bool DropperTool::root_handler(GdkEvent* event) { this->dragging = true; ret = TRUE; } - - sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), - GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK, - NULL, event->button.time); - this->grabbed = SP_CANVAS_ITEM(desktop->acetate); + + sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), + GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK, + NULL, event->button.time); + this->grabbed = SP_CANVAS_ITEM(desktop->acetate); break; case GDK_MOTION_NOTIFY: @@ -174,14 +219,6 @@ bool DropperTool::root_handler(GdkEvent* event) { break; } else if (!this->space_panning) { // otherwise, constantly calculate color no matter is any button pressed or not - - // If one time pick with stroke set the pixmap - if (prefs->getBool("/tools/dropper/onetimepick", false) && prefs->getInt("/dialogs/fillstroke/page", 0) == 1) { - //TODO Only set when not set already - GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas())); - gdk_window_set_cursor(window, cursor_dropper_stroke); - } - double rw = 0.0; double R(0), G(0), B(0), A(0); @@ -190,10 +227,10 @@ bool DropperTool::root_handler(GdkEvent* event) { // radius rw = std::min(Geom::L2(Geom::Point(event->button.x, event->button.y) - this->centre), 400.0); - if (rw == 0) { // happens sometimes, little idea why... break; } + this->radius = rw; Geom::Point const cd = desktop->w2d(this->centre); Geom::Affine const w2dt = desktop->w2d(); @@ -242,74 +279,57 @@ bool DropperTool::root_handler(GdkEvent* event) { } // remember color - this->R = R; - this->G = G; - this->B = B; - this->alpha = A; - - // status message - double alpha_to_set = setalpha? this->alpha : 1.0; - guint32 c32 = SP_RGBA32_F_COMPOSE(R, G, B, alpha_to_set); - - gchar c[64]; - sp_svg_write_color(c, sizeof(c), c32); - - // alpha of color under cursor, to show in the statusbar - // locale-sensitive printf is OK, since this goes to the UI, not into SVG - gchar *alpha = g_strdup_printf(_(" alpha %.3g"), alpha_to_set); - // where the color is picked, to show in the statusbar - gchar *where = this->dragging ? g_strdup_printf(_(", averaged with radius %d"), (int) rw) : g_strdup_printf("%s", _(" under cursor")); - // message, to show in the statusbar - const gchar *message = this->dragging ? _("<b>Release mouse</b> to set color.") : _("<b>Click</b> to set fill, <b>Shift+click</b> to set stroke; <b>drag</b> to average color in area; with <b>Alt</b> to pick inverse color; <b>Ctrl+C</b> to copy the color under mouse to clipboard"); - - this->defaultMessageContext()->setF( - Inkscape::NORMAL_MESSAGE, - "<b>%s%s</b>%s. %s", c, - (pick == SP_DROPPER_PICK_VISIBLE) ? "" : alpha, where, message); - - g_free(where); - g_free(alpha); - + if(!this->dropping && (R != this->R || G != this->G || B != this->B || A != this->alpha)) { + this->R = R; + this->G = G; + this->B = B; + this->alpha = A; + } ret = TRUE; } break; case GDK_BUTTON_RELEASE: if (event->button.button == 1 && !this->space_panning) { - sp_canvas_item_hide(this->area); - this->dragging = false; - - if (this->grabbed) { - sp_canvas_item_ungrab(this->grabbed, event->button.time); - this->grabbed = NULL; - } - - double alpha_to_set = setalpha? this->alpha : 1.0; - - bool fill = !(event->button.state & GDK_SHIFT_MASK); // Stroke if Shift key held - - if (prefs->getBool("/tools/dropper/onetimepick", false)) { - // "One time" pick from Fill/Stroke dialog stroke page, always apply fill or stroke (ignore <Shift> key) - fill = (prefs->getInt("/dialogs/fillstroke/page", 0) == 0) ? true : false; + sp_canvas_item_hide(this->area); + this->dragging = false; + + if (this->grabbed) { + sp_canvas_item_ungrab(this->grabbed, event->button.time); + this->grabbed = NULL; + } + + Inkscape::Selection *selection = desktop->getSelection(); + g_assert(selection); + std::vector<SPItem *> old_selection(selection->items().begin(), selection->items().end()); + if(this->dropping) { + Geom::Point const button_w(event->button.x, event->button.y); + // remember clicked item, disregarding groups, honoring Alt + this->item_to_select = sp_event_context_find_item (desktop, button_w, event->button.state & GDK_MOD1_MASK, TRUE); + + // Change selected object to object under cursor + if (this->item_to_select) { + std::vector<SPItem *> vec(selection->items().begin(), selection->items().end()); + selection->set(this->item_to_select); + } + } else { + if (prefs->getBool("/tools/dropper/onetimepick", false)) { + // "One time" pick from Fill/Stroke dialog stroke page, always apply fill or stroke (ignore <Shift> key) + //fill = (prefs->getInt("/dialogs/fillstroke/page", 0) == 0) ? true : false; + } } // do the actual color setting - sp_desktop_set_color(desktop, - (event->button.state & GDK_MOD1_MASK)? - ColorRGBA(1 - this->R, 1 - this->G, 1 - this->B, alpha_to_set) : ColorRGBA(this->R, this->G, this->B, alpha_to_set), - false, fill); + sp_desktop_set_color(desktop, ColorRGBA(this->get_color(this->invert)), false, !this->stroke); // REJON: set aux. toolbar input to hex color! - - if (event->button.state & GDK_SHIFT_MASK) { - GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas())); - gdk_window_set_cursor(window, cursor_dropper_stroke); - } - if (!(desktop->getSelection()->isEmpty())) { DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_DROPPER, _("Set picked color")); } + if(this->dropping) { + selection->setList(old_selection); + } if (prefs->getBool("/tools/dropper/onetimepick", false)) { prefs->setBool("/tools/dropper/onetimepick", false); @@ -326,50 +346,49 @@ bool DropperTool::root_handler(GdkEvent* event) { case GDK_KEY_PRESS: switch (get_group0_keyval(&event->key)) { - case GDK_KEY_Up: - case GDK_KEY_Down: - case GDK_KEY_KP_Up: - case GDK_KEY_KP_Down: + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: // prevent the zoom field from activation if (!MOD__CTRL_ONLY(event)) { ret = TRUE; } break; - - case GDK_KEY_Escape: + case GDK_KEY_Escape: desktop->getSelection()->clear(); - case GDK_KEY_Shift_L: - case GDK_KEY_Shift_R: - if (!desktop->isWaitingCursor() && !prefs->getBool("/tools/dropper/onetimepick", false)) { - GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas())); - gdk_window_set_cursor(window, cursor_dropper_stroke); - } - - break; - default: break; } break; - - case GDK_KEY_RELEASE: - switch (get_group0_keyval(&event->key)) { - case GDK_KEY_Shift_L: - case GDK_KEY_Shift_R: - if (!desktop->isWaitingCursor() && !prefs->getBool("/tools/dropper/onetimepick", false)) { - GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas())); - gdk_window_set_cursor(window, cursor_dropper_fill); - } - break; - - default: - break; - } - break; - - default: - break; } + // set the status message to the right text. + gchar c[64]; + sp_svg_write_color(c, sizeof(c), this->get_color(this->invert)); + + // alpha of color under cursor, to show in the statusbar + // locale-sensitive printf is OK, since this goes to the UI, not into SVG + gchar *alpha = g_strdup_printf(_(" alpha %.3g"), this->alpha); + // where the color is picked, to show in the statusbar + gchar *where = this->dragging ? g_strdup_printf(_(", averaged with radius %d"), (int) this->radius) : g_strdup_printf("%s", _(" under cursor")); + // message, to show in the statusbar + const gchar *message = this->dragging ? _("<b>Release mouse</b> to set color.") : _("<b>Click</b> to set fill, <b>Shift+click</b> to set stroke; <b>drag</b> to average color in area; with <b>Alt</b> to pick inverse color; <b>Ctrl+C</b> to copy the color under mouse to clipboard"); + + this->defaultMessageContext()->setF( + Inkscape::NORMAL_MESSAGE, + "<b>%s%s</b>%s. %s", c, + (pick == SP_DROPPER_PICK_VISIBLE) ? "" : alpha, where, message); + + g_free(where); + g_free(alpha); + + // Set the right cursor for the mode and apply the special Fill color + auto xpm = (this->dropping ? (this->stroke ? cursor_dropping_s_xpm : cursor_dropping_f_xpm) : + (this->stroke ? cursor_dropper_s_xpm : cursor_dropper_f_xpm)); + GdkCursor *cursor = sp_cursor_from_xpm(xpm, this->get_color(this->invert)); + GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas())); + gdk_window_set_cursor(window, cursor); + if (!ret) { ret = ToolBase::root_handler(event); } diff --git a/src/ui/tools/dropper-tool.h b/src/ui/tools/dropper-tool.h index cfeb91dab..813f68296 100644 --- a/src/ui/tools/dropper-tool.h +++ b/src/ui/tools/dropper-tool.h @@ -25,6 +25,11 @@ enum { SP_DROPPER_PICK_VISIBLE, SP_DROPPER_PICK_ACTUAL }; +enum { + DONT_REDRAW_CURSOR, + DRAW_FILL_CURSOR, + DRAW_STROKE_CURSOR +}; namespace Inkscape { namespace UI { @@ -39,7 +44,7 @@ public: virtual const std::string& getPrefsPath(); - guint32 get_color(); + guint32 get_color(bool invert=false); protected: virtual void setup(); @@ -52,6 +57,10 @@ private: double B; double alpha; + double radius; + bool invert; + bool stroke; + bool dropping; bool dragging; SPCanvasItem* grabbed; diff --git a/src/ui/tools/dynamic-base.cpp b/src/ui/tools/dynamic-base.cpp index 6627a470e..bb4989333 100644 --- a/src/ui/tools/dynamic-base.cpp +++ b/src/ui/tools/dynamic-base.cpp @@ -18,8 +18,8 @@ namespace Inkscape { namespace UI { namespace Tools { -DynamicBase::DynamicBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y) - : ToolBase(cursor_shape, hot_x, hot_y) +DynamicBase::DynamicBase(gchar const *const *cursor_shape) + : ToolBase(cursor_shape) , accumulated(NULL) , segments(NULL) , currentshape(NULL) diff --git a/src/ui/tools/dynamic-base.h b/src/ui/tools/dynamic-base.h index 095af8f88..e270052f3 100644 --- a/src/ui/tools/dynamic-base.h +++ b/src/ui/tools/dynamic-base.h @@ -38,7 +38,7 @@ namespace Tools { class DynamicBase : public ToolBase { public: - DynamicBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y); + DynamicBase(gchar const *const *cursor_shape); virtual ~DynamicBase(); virtual void set(const Inkscape::Preferences::Entry& val); diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index ae312e054..b4246b9cc 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -93,7 +93,7 @@ const std::string& EraserTool::getPrefsPath() { const std::string EraserTool::prefsPath = "/tools/eraser"; EraserTool::EraserTool() - : DynamicBase(cursor_eraser_xpm, 4, 4) + : DynamicBase(cursor_eraser_xpm) , nowidth(false) { } diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 6e1d085aa..f6f9b4355 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -98,7 +98,7 @@ Glib::ustring gap_init[4] = { const std::vector<Glib::ustring> FloodTool::gap_list( gap_init, gap_init+4 ); FloodTool::FloodTool() - : ToolBase(cursor_paintbucket_xpm, 11, 30) + : ToolBase(cursor_paintbucket_xpm) , item(NULL) { // TODO: Why does the flood tool use a hardcoded tolerance instead of a pref? diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 4af70a816..8a5ef0aad 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -63,8 +63,8 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc); static void spdc_reset_white(FreehandBase *dc); static void spdc_free_colors(FreehandBase *dc); -FreehandBase::FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y) - : ToolBase(cursor_shape, hot_x, hot_y) +FreehandBase::FreehandBase(gchar const *const *cursor_shape) + : ToolBase(cursor_shape) , selection(NULL) , grab(NULL) , attach(false) diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h index 3ee4cd7d0..a3069aa09 100644 --- a/src/ui/tools/freehand-base.h +++ b/src/ui/tools/freehand-base.h @@ -44,7 +44,7 @@ namespace Tools { class FreehandBase : public ToolBase { public: - FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y); + FreehandBase(gchar const *const *cursor_shape); virtual ~FreehandBase(); Inkscape::Selection *selection; diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 750596808..95d940bd6 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -58,7 +58,7 @@ const std::string GradientTool::prefsPath = "/tools/gradient"; GradientTool::GradientTool() - : ToolBase(cursor_gradient_xpm, 4, 4) + : ToolBase(cursor_gradient_xpm) , cursor_addnode(false) , node_added(false) // TODO: Why are these connections stored as pointers? diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index 29e4c9e74..35e6d14a0 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -68,7 +68,7 @@ const std::string& LpeTool::getPrefsPath() { const std::string LpeTool::prefsPath = "/tools/lpetool"; LpeTool::LpeTool() - : PenTool(cursor_crosshairs_xpm, 7, 7) + : PenTool(cursor_crosshairs_xpm) , shape_editor(NULL) , canvas_bbox(NULL) , mode(Inkscape::LivePathEffect::BEND_PATH) diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 98b2c7d03..0da883891 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -322,7 +322,7 @@ void createAngleDisplayCurve(SPDesktop *desktop, Geom::Point const ¢er, Geom boost::optional<Geom::Point> explicit_base_tmp = boost::none; MeasureTool::MeasureTool() - : ToolBase(cursor_measure_xpm, 4, 4) + : ToolBase(cursor_measure_xpm) , grabbed(NULL) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; @@ -332,14 +332,14 @@ MeasureTool::MeasureTool() // create the knots this->knot_start = new SPKnot(desktop, _("Measure start, <b>Shift+Click</b> for position dialog")); this->knot_start->setMode(SP_KNOT_MODE_XOR); - this->knot_start->setFill(MT_KNOT_COLOR_NORMAL, MT_KNOT_COLOR_MOUSEOVER, MT_KNOT_COLOR_MOUSEOVER); - this->knot_start->setStroke(0x0000007f, 0x0000007f, 0x0000007f); + this->knot_start->setFill(MT_KNOT_COLOR_NORMAL, MT_KNOT_COLOR_MOUSEOVER, MT_KNOT_COLOR_MOUSEOVER, MT_KNOT_COLOR_MOUSEOVER); + this->knot_start->setStroke(0x0000007f, 0x0000007f, 0x0000007f, 0x0000007f); this->knot_start->setShape(SP_KNOT_SHAPE_CIRCLE); this->knot_start->updateCtrl(); this->knot_end = new SPKnot(desktop, _("Measure end, <b>Shift+Click</b> for position dialog")); this->knot_end->setMode(SP_KNOT_MODE_XOR); - this->knot_end->setFill(MT_KNOT_COLOR_NORMAL, MT_KNOT_COLOR_MOUSEOVER, MT_KNOT_COLOR_MOUSEOVER); - this->knot_end->setStroke(0x0000007f, 0x0000007f, 0x0000007f); + this->knot_end->setFill(MT_KNOT_COLOR_NORMAL, MT_KNOT_COLOR_MOUSEOVER, MT_KNOT_COLOR_MOUSEOVER, MT_KNOT_COLOR_MOUSEOVER); + this->knot_end->setStroke(0x0000007f, 0x0000007f, 0x0000007f, 0x0000007f); this->knot_end->setShape(SP_KNOT_SHAPE_CIRCLE); this->knot_end->updateCtrl(); Geom::Rect display_area = desktop->get_display_area(); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index ac43b6c9d..d79741270 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -72,7 +72,7 @@ const std::string MeshTool::prefsPath = "/tools/mesh"; // TODO: The gradient tool class looks like a 1:1 copy. MeshTool::MeshTool() - : ToolBase(cursor_gradient_xpm, 4, 4) + : ToolBase(cursor_gradient_xpm) , cursor_addnode(false) , node_added(false) , show_handles(true) diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 0c948c91c..08aacf805 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -118,7 +118,7 @@ const std::string NodeTool::prefsPath = "/tools/nodes"; SPCanvasGroup *create_control_group(SPDesktop *d); NodeTool::NodeTool() - : ToolBase(cursor_node_xpm, 1, 1) + : ToolBase(cursor_node_xpm) , _selected_nodes(NULL) , _multipath(NULL) , edit_clipping_paths(false) @@ -773,14 +773,10 @@ void NodeTool::mouseover_changed(Inkscape::UI::ControlPoint *p) { if (cdp && !this->cursor_drag) { this->cursor_shape = cursor_node_d_xpm; - this->hot_x = 1; - this->hot_y = 1; this->sp_event_context_update_cursor(); this->cursor_drag = true; } else if (!cdp && this->cursor_drag) { this->cursor_shape = cursor_node_xpm; - this->hot_x = 1; - this->hot_y = 1; this->sp_event_context_update_cursor(); this->cursor_drag = false; } diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h index 983ba6cee..dded2d9bd 100644 --- a/src/ui/tools/node-tool.h +++ b/src/ui/tools/node-tool.h @@ -61,6 +61,7 @@ public: virtual bool root_handler(GdkEvent* event); virtual const std::string& getPrefsPath(); + boost::ptr_map<SPItem*, ShapeEditor> _shape_editors; private: sigc::connection _selection_changed_connection; @@ -74,7 +75,6 @@ private: Inkscape::UI::PathSharedData* _path_data; SPCanvasGroup *_transform_handle_group; SPItem *_last_over; - boost::ptr_map<SPItem*, ShapeEditor> _shape_editors; bool cursor_drag; bool show_handles; diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 0422dc9cd..4f19b25c6 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -81,7 +81,7 @@ const std::string& PenTool::getPrefsPath() { const std::string PenTool::prefsPath = "/tools/freehand/pen"; PenTool::PenTool() - : FreehandBase(cursor_pen_xpm, 4, 4) + : FreehandBase(cursor_pen_xpm) , p() , npoints(0) , mode(MODE_CLICK) @@ -100,8 +100,8 @@ PenTool::PenTool() { } -PenTool::PenTool(gchar const *const *cursor_shape, gint hot_x, gint hot_y) - : FreehandBase(cursor_shape, hot_x, hot_y) +PenTool::PenTool(gchar const *const *cursor_shape) + : FreehandBase(cursor_shape) , p() , npoints(0) , mode(MODE_CLICK) diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h index 5a21e3bac..7e5483358 100644 --- a/src/ui/tools/pen-tool.h +++ b/src/ui/tools/pen-tool.h @@ -23,7 +23,7 @@ namespace Tools { class PenTool : public FreehandBase { public: PenTool(); - PenTool(gchar const *const *cursor_shape, gint hot_x, gint hot_y); + PenTool(gchar const *const *cursor_shape); virtual ~PenTool(); enum Mode { diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index ec2874823..99b8103c3 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -57,7 +57,7 @@ const std::string& PencilTool::getPrefsPath() { const std::string PencilTool::prefsPath = "/tools/freehand/pencil"; PencilTool::PencilTool() - : FreehandBase(cursor_pencil_xpm, 4, 4) + : FreehandBase(cursor_pencil_xpm) , p() , npoints(0) , state(SP_PENCIL_CONTEXT_IDLE) diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 272531945..9ebf51e76 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -52,7 +52,7 @@ const std::string& RectTool::getPrefsPath() { const std::string RectTool::prefsPath = "/tools/shapes/rect"; RectTool::RectTool() - : ToolBase(cursor_rect_xpm, 4, 4) + : ToolBase(cursor_rect_xpm) , rect(NULL) , rx(0) , ry(0) @@ -274,15 +274,6 @@ bool RectTool::root_handler(GdkEvent* event) { NULL); } break; - case GDK_KEY_Up: - case GDK_KEY_Down: - case GDK_KEY_KP_Up: - case GDK_KEY_KP_Down: - // prevent the zoom field from activation - if (!MOD__CTRL_ONLY(event)) - ret = TRUE; - break; - case GDK_KEY_x: case GDK_KEY_X: if (MOD__ALT_ONLY(event)) { diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index bae1793ed..fca2173ca 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -81,7 +81,7 @@ sp_load_handles(int start, int count, char const **xpm) { SelectTool::SelectTool() // Don't load a default cursor - : ToolBase(NULL, 0, 0) + : ToolBase(NULL) , dragging(false) , moved(false) , button_press_shift(false) @@ -94,8 +94,8 @@ SelectTool::SelectTool() , _describer(NULL) { // cursors in select context - CursorSelectMouseover = sp_cursor_new_from_xpm(cursor_select_m_xpm , 1, 1); - CursorSelectDragging = sp_cursor_new_from_xpm(cursor_select_d_xpm , 1, 1); + CursorSelectMouseover = sp_cursor_from_xpm(cursor_select_m_xpm); + CursorSelectDragging = sp_cursor_from_xpm(cursor_select_d_xpm); // selection handles sp_load_handles(0, 2, handle_scale_xpm); @@ -566,7 +566,9 @@ bool SelectTool::root_handler(GdkEvent* event) { /* User has dragged fast, so we get events on root (lauris)*/ // not only that; we will end up here when ctrl-dragging as well // and also when we started within tolerance, but trespassed tolerance outside of item - Inkscape::Rubberband::get(desktop)->stop(); + if (Inkscape::Rubberband::get(desktop)->is_started()) { + Inkscape::Rubberband::get(desktop)->stop(); + } this->defaultMessageContext()->clear(); item_at_point = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), FALSE); diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp index 0ba08853e..b681aec38 100644 --- a/src/ui/tools/spiral-tool.cpp +++ b/src/ui/tools/spiral-tool.cpp @@ -51,7 +51,7 @@ const std::string& SpiralTool::getPrefsPath() { const std::string SpiralTool::prefsPath = "/tools/shapes/spiral"; SpiralTool::SpiralTool() - : ToolBase(cursor_spiral_xpm, 4, 4) + : ToolBase(cursor_spiral_xpm) , spiral(NULL) , revo(3) , exp(1) @@ -245,14 +245,6 @@ bool SpiralTool::root_handler(GdkEvent* event) { NULL, _("<b>Alt</b>: lock spiral radius")); break; - case GDK_KEY_Up: - case GDK_KEY_Down: - case GDK_KEY_KP_Up: - case GDK_KEY_KP_Down: - // prevent the zoom field from activation - if (!MOD__CTRL_ONLY(event)) - ret = TRUE; - break; case GDK_KEY_x: case GDK_KEY_X: diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index ad006627c..f3e7e6d3c 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -137,7 +137,7 @@ static void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *it } SprayTool::SprayTool() - : ToolBase(cursor_spray_xpm, 4, 4, false) + : ToolBase(cursor_spray_xpm, false) , pressure(TC_DEFAULT_PRESSURE) , dragging(false) , usepressurewidth(false) diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp index ddee08189..32f0e6d92 100644 --- a/src/ui/tools/star-tool.cpp +++ b/src/ui/tools/star-tool.cpp @@ -57,7 +57,7 @@ const std::string& StarTool::getPrefsPath() { const std::string StarTool::prefsPath = "/tools/shapes/star"; StarTool::StarTool() - : ToolBase(cursor_star_xpm, 4, 4) + : ToolBase(cursor_star_xpm) , star(NULL) , magnitude(5) , proportion(0.5) @@ -260,15 +260,6 @@ bool StarTool::root_handler(GdkEvent* event) { NULL); break; - case GDK_KEY_Up: - case GDK_KEY_Down: - case GDK_KEY_KP_Up: - case GDK_KEY_KP_Down: - // prevent the zoom field from activation - if (!MOD__CTRL_ONLY(event)) - ret = TRUE; - break; - case GDK_KEY_x: case GDK_KEY_X: if (MOD__ALT_ONLY(event)) { diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 649bbb045..9091b455e 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -76,7 +76,7 @@ const std::string TextTool::prefsPath = "/tools/text"; TextTool::TextTool() - : ToolBase(cursor_text_xpm, 7, 7) + : ToolBase(cursor_text_xpm) , imc(NULL) , text(NULL) , pdoc(0, 0) @@ -359,8 +359,6 @@ bool TextTool::item_handler(SPItem* item, GdkEvent* event) { sp_canvas_item_show(this->indicator); this->cursor_shape = cursor_text_insert_xpm; - this->hot_x = 7; - this->hot_y = 10; this->sp_event_context_update_cursor(); sp_text_context_update_text_selection(this); @@ -548,8 +546,6 @@ bool TextTool::root_handler(GdkEvent* event) { this->over_text = 0; // update cursor and statusbar: we are not over a text object now this->cursor_shape = cursor_text_xpm; - this->hot_x = 7; - this->hot_y = 7; this->sp_event_context_update_cursor(); desktop->event_context->defaultMessageContext()->clear(); } diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 490d0fb26..12c3a3675 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -23,6 +23,7 @@ #include "shortcuts.h" #include "file.h" +#include "ui/contextmenu.h" #include "ui/interface.h" #include "ui/event-debug.h" #include "ui/tool/control-point.h" @@ -30,6 +31,10 @@ #include "ui/tools/tool-base.h" #include "ui/tools-switch.h" #include "ui/tools/lpe-tool.h" +#include "ui/tool/commit-events.h" +#include "ui/tool/event-utils.h" +#include "ui/tools/node-tool.h" +#include "ui/tool/shape-record.h" #include <gdk/gdkkeysyms.h> #include <glibmm/i18n.h> @@ -85,7 +90,7 @@ SPDesktop const& ToolBase::getDesktop() const { return *desktop; } -ToolBase::ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y, bool uses_snap) +ToolBase::ToolBase(gchar const *const *cursor_shape, bool uses_snap) : pref_observer(NULL) , cursor(NULL) , xp(0) @@ -103,8 +108,6 @@ ToolBase::ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y, boo , desktop(NULL) , _uses_snap(uses_snap) , cursor_shape(cursor_shape) - , hot_x(hot_x) - , hot_y(hot_y) { } @@ -153,44 +156,22 @@ void ToolBase::sp_event_context_set_cursor(GdkCursorType cursor_type) { void ToolBase::sp_event_context_update_cursor() { GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas()); if (gtk_widget_get_window (w)) { - - GtkStyle *style = gtk_widget_get_style(w); - - /* fixme: */ if (this->cursor_shape) { - GdkDisplay *display = gdk_display_get_default(); - if (gdk_display_supports_cursor_alpha(display) && gdk_display_supports_cursor_color(display)) { - bool fillHasColor=false, strokeHasColor=false; - guint32 fillColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), true, &fillHasColor); - guint32 strokeColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), false, &strokeHasColor); - double fillOpacity = fillHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), true) : 0; - double strokeOpacity = strokeHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), false) : 0; - - GdkPixbuf *pixbuf = sp_cursor_pixbuf_from_xpm( - this->cursor_shape, - style->black, style->white, - SP_RGBA32_U_COMPOSE(SP_RGBA32_R_U(fillColor),SP_RGBA32_G_U(fillColor),SP_RGBA32_B_U(fillColor),SP_COLOR_F_TO_U(fillOpacity)), - SP_RGBA32_U_COMPOSE(SP_RGBA32_R_U(strokeColor),SP_RGBA32_G_U(strokeColor),SP_RGBA32_B_U(strokeColor),SP_COLOR_F_TO_U(strokeOpacity)) - ); - if (pixbuf != NULL) { - if (this->cursor) { - g_object_unref(this->cursor); - } - this->cursor = gdk_cursor_new_from_pixbuf(display, pixbuf, this->hot_x, this->hot_y); - g_object_unref(pixbuf); - } - } else { - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)this->cursor_shape); - - if (pixbuf) { - if (this->cursor) { - g_object_unref(this->cursor); - } - this->cursor = gdk_cursor_new_from_pixbuf(display, - pixbuf, this->hot_x, this->hot_y); - g_object_unref(pixbuf); - } + if(this->cursor) { + g_object_unref(this->cursor); } + + bool fillHasColor=false, strokeHasColor=false; + guint32 fillColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), true, &fillHasColor); + guint32 strokeColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), false, &strokeHasColor); + double fillOpacity = fillHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), true) : 0; + double strokeOpacity = strokeHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), false) : 0; + + this->cursor = sp_cursor_from_xpm( + this->cursor_shape, + SP_RGBA32_C_COMPOSE(fillColor, fillOpacity), + SP_RGBA32_C_COMPOSE(strokeColor, strokeOpacity) + ); } gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); gdk_flush(); @@ -207,8 +188,7 @@ void ToolBase::sp_event_context_update_cursor() { void ToolBase::setup() { this->pref_observer = new ToolPrefObserver(this->getPrefsPath(), this); Inkscape::Preferences::get()->addObserver(*(this->pref_observer)); - - this->sp_event_context_update_cursor(); + this->sp_event_context_update_cursor(); } /** @@ -326,6 +306,43 @@ static gdouble accelerate_scroll(GdkEvent *event, gdouble acceleration, return scroll_multiply; } +/** Moves the selected points along the supplied unit vector according to + * the modifier state of the supplied event. */ +bool ToolBase::_keyboardMove(GdkEventKey const &event, Geom::Point const &dir) +{ + if (held_control(event)) return false; + unsigned num = 1 + combine_key_events(shortcut_key(event), 0); + Geom::Point delta = dir * num; + if (held_shift(event)) delta *= 10; + if (held_alt(event)) { + delta /= desktop->current_zoom(); + } else { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000, "px"); + delta *= nudge; + } + if (shape_editor && shape_editor->has_knotholder()) { + KnotHolder * knotholder = shape_editor->knotholder; + if (knotholder) { + knotholder->transform_selected(Geom::Translate(delta)); + } + } else if (tools_isactive(desktop, TOOLS_NODES)) { + Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(desktop->event_context); + if (nt) { + for(auto i=nt->_shape_editors.begin();i!=nt->_shape_editors.end();++i){ + ShapeEditor * shape_editor = i->second; + if (shape_editor && shape_editor->has_knotholder()) { + KnotHolder * knotholder = shape_editor->knotholder; + if (knotholder) { + knotholder->transform_selected(Geom::Translate(delta)); + } + } + } + } + } + return true; +} + bool ToolBase::root_handler(GdkEvent* event) { // ui_dump_event (event, "ToolBase::root_handler"); @@ -624,6 +641,8 @@ bool ToolBase::root_handler(GdkEvent* event) { gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); this->desktop->scroll_relative(Geom::Point(i, 0)); ret = TRUE; + } else { + ret = _keyboardMove(event->key, Geom::Point(-1, 0)); } break; @@ -637,6 +656,8 @@ bool ToolBase::root_handler(GdkEvent* event) { gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); this->desktop->scroll_relative(Geom::Point(0, i)); ret = TRUE; + } else { + ret = _keyboardMove(event->key, Geom::Point(0, 1)); } break; @@ -650,6 +671,8 @@ bool ToolBase::root_handler(GdkEvent* event) { gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); this->desktop->scroll_relative(Geom::Point(-i, 0)); ret = TRUE; + } else { + ret = _keyboardMove(event->key, Geom::Point(1, 0)); } break; @@ -663,6 +686,8 @@ bool ToolBase::root_handler(GdkEvent* event) { gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); this->desktop->scroll_relative(Geom::Point(0, -i)); ret = TRUE; + } else { + ret = _keyboardMove(event->key, Geom::Point(0, -1)); } break; diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h index 69533e417..09a9db660 100644 --- a/src/ui/tools/tool-base.h +++ b/src/ui/tools/tool-base.h @@ -14,12 +14,12 @@ #include <stddef.h> #include <string> - +#include "knot.h" +#include "knotholder.h" #include <2geom/point.h> #include <gdk/gdk.h> #include <glib-object.h> #include <sigc++/trackable.h> -#include "knot.h" #include "preferences.h" @@ -30,7 +30,7 @@ namespace Glib { class GrDrag; class SPDesktop; class SPItem; - +class KnotHolder; namespace Inkscape { class MessageContext; class SelCue; @@ -42,6 +42,7 @@ namespace Inkscape { namespace Inkscape { namespace UI { + class ShapeEditor; namespace Tools { @@ -144,7 +145,7 @@ public: void enableGrDrag (bool enable=true); bool deleteSelectedDrag(bool just_one); - ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y, bool uses_snap = true); + ToolBase(gchar const *const *cursor_shape, bool uses_snap=true); virtual ~ToolBase(); @@ -219,20 +220,18 @@ public: SPDesktop *desktop; bool _uses_snap; // TODO: make protected or private - protected: /// An xpm containing the shape of the tool's cursor. gchar const *const *cursor_shape; - /// The cursor's hot spot - gint hot_x, hot_y; - bool sp_event_context_knot_mouseover() const; private: ToolBase(const ToolBase&); ToolBase& operator=(const ToolBase&); + bool _keyboardMove(GdkEventKey const &event, Geom::Point const &dir); + void sp_event_context_set_cursor(GdkCursorType cursor_type); }; diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index ff5d623c2..dcd9413fb 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -38,13 +38,13 @@ #include "pixmaps/cursor-tweak-rotate-counterclockwise.xpm" #include "pixmaps/cursor-tweak-more.xpm" #include "pixmaps/cursor-tweak-less.xpm" -#include "pixmaps/cursor-thin.xpm" -#include "pixmaps/cursor-thicken.xpm" -#include "pixmaps/cursor-attract.xpm" -#include "pixmaps/cursor-repel.xpm" -#include "pixmaps/cursor-push.xpm" -#include "pixmaps/cursor-roughen.xpm" -#include "pixmaps/cursor-color.xpm" +#include "pixmaps/cursor-tweak-thin.xpm" +#include "pixmaps/cursor-tweak-thicken.xpm" +#include "pixmaps/cursor-tweak-attract.xpm" +#include "pixmaps/cursor-tweak-repel.xpm" +#include "pixmaps/cursor-tweak-push.xpm" +#include "pixmaps/cursor-tweak-roughen.xpm" +#include "pixmaps/cursor-tweak-color.xpm" #include "context-fns.h" #include "inkscape.h" #include "splivarot.h" @@ -92,7 +92,7 @@ const std::string& TweakTool::getPrefsPath() { const std::string TweakTool::prefsPath = "/tools/tweak"; TweakTool::TweakTool() - : ToolBase(cursor_push_xpm, 4, 4) + : ToolBase(cursor_push_xpm) , pressure(TC_DEFAULT_PRESSURE) , dragging(false) , usepressure(false) diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp index d40d2e969..8ba0c17b3 100644 --- a/src/ui/tools/zoom-tool.cpp +++ b/src/ui/tools/zoom-tool.cpp @@ -36,7 +36,7 @@ const std::string& ZoomTool::getPrefsPath() { const std::string ZoomTool::prefsPath = "/tools/zoom"; ZoomTool::ZoomTool() - : ToolBase(cursor_zoom_xpm, 6, 6) + : ToolBase(cursor_zoom_xpm) , grabbed(NULL) , escaped(false) { diff --git a/src/ui/widget/addtoicon.cpp b/src/ui/widget/addtoicon.cpp index 70516ed00..e5119fc60 100644 --- a/src/ui/widget/addtoicon.cpp +++ b/src/ui/widget/addtoicon.cpp @@ -16,7 +16,6 @@ #include <gtkmm/icontheme.h> -#include "widgets/icon.h" #include "widgets/toolbox.h" #include "ui/icon-names.h" #include "layertypeicon.h" @@ -33,7 +32,10 @@ AddToIcon::AddToIcon() : // _property_pixbuf_add(*this, "pixbuf_on", Glib::RefPtr<Gdk::Pixbuf>(0)) { property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE; - phys = sp_icon_get_phys_size((int)Inkscape::ICON_SIZE_BUTTON); + + gint width, height; + gtk_icon_size_lookup(GTK_ICON_SIZE_BUTTON, &width, &height); + phys = width; // Assumes that we have a square icon? // Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default(); // @@ -43,8 +45,6 @@ AddToIcon::AddToIcon() : // if (icon_theme->has_icon(_pixAddName)) { // _property_pixbuf_add = icon_theme->load_icon(_pixAddName, phys, (Gtk::IconLookupFlags)0); // } -// -// _property_pixbuf_add = Gtk::Widget:: set_pixbuf(); } @@ -104,8 +104,10 @@ void AddToIcon::set_pixbuf() { bool active = property_active().get_value(); - GdkPixbuf *pixbuf = sp_pixbuf_new(Inkscape::ICON_SIZE_BUTTON, active ? INKSCAPE_ICON("list-add") : INKSCAPE_ICON("edit-delete")); - property_pixbuf() = Glib::wrap(pixbuf); + auto icon_theme = Gtk::IconTheme::get_default(); + + property_pixbuf() = icon_theme->load_icon(active ? "list-add" : "edit-delete", + phys); } diff --git a/src/ui/widget/addtoicon.h b/src/ui/widget/addtoicon.h index 3b2228754..93d66c8d5 100644 --- a/src/ui/widget/addtoicon.h +++ b/src/ui/widget/addtoicon.h @@ -54,7 +54,7 @@ protected: private: - int phys; + int phys; ///< Physical size of the icon (px) // Glib::ustring _pixAddName; diff --git a/src/ui/widget/anchor-selector.cpp b/src/ui/widget/anchor-selector.cpp index 087e7375e..52768b7f1 100644 --- a/src/ui/widget/anchor-selector.cpp +++ b/src/ui/widget/anchor-selector.cpp @@ -8,15 +8,17 @@ */ #include "ui/widget/anchor-selector.h" -#include "widgets/icon.h" #include "ui/icon-names.h" +#include <gtkmm/image.h> + namespace Inkscape { namespace UI { namespace Widget { void AnchorSelector::setupButton(const Glib::ustring& icon, Gtk::ToggleButton& button) { - Gtk::Widget* buttonIcon = Gtk::manage(sp_icon_get_icon(icon, Inkscape::ICON_SIZE_SMALL_TOOLBAR)); + Gtk::Image* buttonIcon = Gtk::manage(new Gtk::Image()); + buttonIcon->set_from_icon_name(icon, Gtk::ICON_SIZE_SMALL_TOOLBAR); buttonIcon->show(); button.set_relief(Gtk::RELIEF_NONE); @@ -26,9 +28,9 @@ void AnchorSelector::setupButton(const Glib::ustring& icon, Gtk::ToggleButton& b } AnchorSelector::AnchorSelector() - : Gtk::Alignment(0.5, 0, 0, 0), - _container() + : _container() { + set_halign(Gtk::ALIGN_CENTER); setupButton(INKSCAPE_ICON("boundingbox_top_left"), _buttons[0]); setupButton(INKSCAPE_ICON("boundingbox_top"), _buttons[1]); setupButton(INKSCAPE_ICON("boundingbox_top_right"), _buttons[2]); diff --git a/src/ui/widget/anchor-selector.h b/src/ui/widget/anchor-selector.h index 96331fae3..e756e9aa0 100644 --- a/src/ui/widget/anchor-selector.h +++ b/src/ui/widget/anchor-selector.h @@ -14,7 +14,7 @@ #include "config.h" #endif -#include <gtkmm/alignment.h> +#include <gtkmm/bin.h> #include <gtkmm/togglebutton.h> #include <gtkmm/grid.h> @@ -22,7 +22,7 @@ namespace Inkscape { namespace UI { namespace Widget { -class AnchorSelector : public Gtk::Alignment +class AnchorSelector : public Gtk::Bin { private: Gtk::ToggleButton _buttons[9]; diff --git a/src/ui/widget/clipmaskicon.cpp b/src/ui/widget/clipmaskicon.cpp index a1e3eaf82..eceff13ca 100644 --- a/src/ui/widget/clipmaskicon.cpp +++ b/src/ui/widget/clipmaskicon.cpp @@ -15,7 +15,6 @@ #include <gtkmm/icontheme.h> -#include "widgets/icon.h" #include "widgets/toolbox.h" #include "ui/icon-names.h" #include "layertypeicon.h" @@ -37,28 +36,15 @@ ClipMaskIcon::ClipMaskIcon() : { property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE; - phys = sp_icon_get_phys_size((int)Inkscape::ICON_SIZE_DECORATION); - Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default(); - if (!icon_theme->has_icon(_pixClipName)) { - Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixClipName.data()), Inkscape::ICON_SIZE_DECORATION ); - } - if (!icon_theme->has_icon(_pixMaskName)) { - Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixMaskName.data()), Inkscape::ICON_SIZE_DECORATION ); - } - if (!icon_theme->has_icon(_pixBothName)) { - Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixBothName.data()), Inkscape::ICON_SIZE_DECORATION ); - } + gint width, height; + gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); + phys = width; - if (icon_theme->has_icon(_pixClipName)) { - _property_pixbuf_clip = icon_theme->load_icon(_pixClipName, phys, (Gtk::IconLookupFlags)0); - } - if (icon_theme->has_icon(_pixMaskName)) { - _property_pixbuf_mask = icon_theme->load_icon(_pixMaskName, phys, (Gtk::IconLookupFlags)0); - } - if (icon_theme->has_icon(_pixBothName)) { - _property_pixbuf_both = icon_theme->load_icon(_pixBothName, phys, (Gtk::IconLookupFlags)0); - } + Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default(); + _property_pixbuf_clip = icon_theme->load_icon(_pixClipName, phys, (Gtk::IconLookupFlags)0); + _property_pixbuf_mask = icon_theme->load_icon(_pixMaskName, phys, (Gtk::IconLookupFlags)0); + _property_pixbuf_both = icon_theme->load_icon(_pixBothName, phys, (Gtk::IconLookupFlags)0); property_pixbuf() = Glib::RefPtr<Gdk::Pixbuf>(0); } diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp index 616e9afa8..f1dd92746 100644 --- a/src/ui/widget/color-icc-selector.cpp +++ b/src/ui/widget/color-icc-selector.cpp @@ -663,6 +663,9 @@ struct _cmp { } }; +template <typename From, typename To> +struct static_caster { To * operator () (From * value) const { return static_cast<To *>(value); } }; + void ColorICCSelectorImpl::_profilesChanged(std::string const &name) { GtkComboBox *combo = GTK_COMBO_BOX(_profileSel); @@ -680,10 +683,15 @@ void ColorICCSelectorImpl::_profilesChanged(std::string const &name) int index = 1; std::vector<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList("iccprofile"); - std::set<SPObject *, _cmp> _current(current.begin(), current.end()); - for (std::set<SPObject *, _cmp>::const_iterator it = _current.begin(); it != _current.end(); ++it) { - SPObject *obj = *it; - Inkscape::ColorProfile *prof = reinterpret_cast<Inkscape::ColorProfile *>(obj); + + std::set<Inkscape::ColorProfile *, Inkscape::ColorProfile::pointerComparator> _current; + std::transform(current.begin(), + current.end(), + std::inserter(_current, _current.begin()), + static_caster<SPObject, Inkscape::ColorProfile>()); + + for (auto &it: _current) { + Inkscape::ColorProfile *prof = it; gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, gr_ellipsize_text(prof->name, 25).c_str(), 1, prof->name, -1); diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp index 33e22b59d..0c9402c99 100644 --- a/src/ui/widget/color-notebook.cpp +++ b/src/ui/widget/color-notebook.cpp @@ -19,7 +19,6 @@ #include "config.h" #endif -#include "widgets/icon.h" #include <glibmm/i18n.h> #include <gtkmm/label.h> #include <gtkmm/notebook.h> diff --git a/src/ui/widget/color-wheel-selector.cpp b/src/ui/widget/color-wheel-selector.cpp index 4f011c6c3..6bbb8e21d 100644 --- a/src/ui/widget/color-wheel-selector.cpp +++ b/src/ui/widget/color-wheel-selector.cpp @@ -62,7 +62,8 @@ void ColorWheelSelector::_initUI() /* Label */ Gtk::Label *label = Gtk::manage(new Gtk::Label(_("_A:"), true)); - label->set_alignment(1.0, 0.5); + label->set_halign(Gtk::ALIGN_END); + label->set_valign(Gtk::ALIGN_CENTER); label->show(); #if GTK_CHECK_VERSION(3, 12, 0) diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp index d124854ae..18ab70eb4 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -12,7 +12,6 @@ #include "desktop.h" #include "inkscape.h" #include "ui/icon-names.h" -#include "widgets/icon.h" #include <gtkmm/icontheme.h> #include <glibmm/exceptionhandler.h> @@ -22,7 +21,7 @@ namespace UI { namespace Widget { DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& long_name, - const Glib::ustring& icon_name, State state, Placement placement) : + const Glib::ustring& icon_name, State state, GdlDockPlacement placement) : _dock(dock), _prev_state(state), _prev_position(0), @@ -43,15 +42,10 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l if (!icon_name.empty()) { Glib::RefPtr<Gtk::IconTheme> iconTheme = Gtk::IconTheme::get_default(); - if (!iconTheme->has_icon(icon_name)) { - Inkscape::queueIconPrerender( INKSCAPE_ICON(icon_name.data()), Inkscape::ICON_SIZE_MENU ); - } - if ( iconTheme->has_icon(icon_name) ) { - int width = 0; - int height = 0; - Gtk::IconSize::lookup(Gtk::ICON_SIZE_MENU, width, height); - _icon_pixbuf = iconTheme->load_icon(icon_name, width); - } + int width = 0; + int height = 0; + Gtk::IconSize::lookup(Gtk::ICON_SIZE_MENU, width, height); + _icon_pixbuf = iconTheme->load_icon(icon_name, width); } if ( _icon_pixbuf ) { @@ -74,7 +68,7 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l signal_delete_event().connect(sigc::mem_fun(*this, &Inkscape::UI::Widget::DockItem::_onDeleteEvent)); signal_realize().connect(sigc::mem_fun(*this, &Inkscape::UI::Widget::DockItem::_onRealize)); - _dock.addItem(*this, ( _prev_state == FLOATING_STATE || _prev_state == ICONIFIED_FLOATING_STATE ) ? FLOATING : placement); + _dock.addItem(*this, ( _prev_state == FLOATING_STATE || _prev_state == ICONIFIED_FLOATING_STATE ) ? GDL_DOCK_FLOATING : placement); if (_prev_state == ICONIFIED_FLOATING_STATE || _prev_state == ICONIFIED_DOCKED_STATE) { iconify(); @@ -218,16 +212,16 @@ DockItem::getPrevState() const return _prev_state; } -DockItem::Placement +GdlDockPlacement DockItem::getPlacement() const { - GdlDockPlacement placement = (GdlDockPlacement)TOP; + GdlDockPlacement placement = GDL_DOCK_TOP; GdlDockObject *parent = gdl_dock_object_get_parent_object (GDL_DOCK_OBJECT(_gdl_dock_item)); if (parent) { gdl_dock_object_child_placement(parent, GDL_DOCK_OBJECT(_gdl_dock_item), &placement); } - return (Placement)placement; + return placement; } void @@ -262,7 +256,7 @@ DockItem::present() show(); } // tabbed - else if (getPlacement() == CENTER) { + else if (getPlacement() == GDL_DOCK_CENTER) { int i = gtk_notebook_page_num(GTK_NOTEBOOK(gtk_widget_get_parent(_gdl_dock_item)), GTK_WIDGET (_gdl_dock_item)); if (i >= 0) diff --git a/src/ui/widget/dock-item.h b/src/ui/widget/dock-item.h index 2df45b207..b5f6c13af 100644 --- a/src/ui/widget/dock-item.h +++ b/src/ui/widget/dock-item.h @@ -45,18 +45,8 @@ public: ICONIFIED_DOCKED_STATE, // item iconified in its assigned dock from dock ICONIFIED_FLOATING_STATE}; // item iconified in its assigned dock from float - enum Placement { - NONE = GDL_DOCK_NONE, - TOP = GDL_DOCK_TOP, - BOTTOM = GDL_DOCK_BOTTOM, - RIGHT = GDL_DOCK_RIGHT, - LEFT = GDL_DOCK_LEFT, - CENTER = GDL_DOCK_CENTER, - FLOATING = GDL_DOCK_FLOATING - }; - DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& long_name, - const Glib::ustring& icon_name, State state, Placement placement); + const Glib::ustring& icon_name, State state, GdlDockPlacement placement); ~DockItem(); @@ -80,7 +70,7 @@ public: bool isIconified() const; State getState() const; State getPrevState() const; - Placement getPlacement() const; + GdlDockPlacement getPlacement() const; Gtk::Window *getWindow(); //< gives the parent window, if the dock item has one (i.e. it's floating) diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index b2dec401f..7dfad9582 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -124,12 +124,13 @@ Dock::~Dock() g_free(_gdl_dock_bar); } -void Dock::addItem(DockItem& item, DockItem::Placement placement) +void Dock::addItem(DockItem& item, GdlDockPlacement placement) { _dock_items.push_back(&item); + gdl_dock_add_item(GDL_DOCK(_gdl_dock), GDL_DOCK_ITEM(item.gobj()), - (GdlDockPlacement)placement); + placement); // FIXME: This is a hack to prevent the dock from expanding the main window, this can't be done // initially as the paned doesn't exist. diff --git a/src/ui/widget/dock.h b/src/ui/widget/dock.h index 74b072d22..6258a06e3 100644 --- a/src/ui/widget/dock.h +++ b/src/ui/widget/dock.h @@ -37,7 +37,7 @@ public: Dock(Gtk::Orientation orientation=Gtk::ORIENTATION_VERTICAL); ~Dock(); - void addItem(DockItem& item, DockItem::Placement placement); + void addItem(DockItem& item, GdlDockPlacement placement); Gtk::Widget& getWidget(); //< return the top widget Gtk::Paned *getParentPaned(); diff --git a/src/ui/widget/highlight-picker.cpp b/src/ui/widget/highlight-picker.cpp index 561c1332a..3d8ab50ea 100644 --- a/src/ui/widget/highlight-picker.cpp +++ b/src/ui/widget/highlight-picker.cpp @@ -13,7 +13,6 @@ #include "display/cairo-utils.h" #include "highlight-picker.h" -#include "widgets/icon.h" namespace Inkscape { namespace UI { diff --git a/src/ui/widget/imagetoggler.cpp b/src/ui/widget/imagetoggler.cpp index 987cc67bb..a2783ecb1 100644 --- a/src/ui/widget/imagetoggler.cpp +++ b/src/ui/widget/imagetoggler.cpp @@ -13,7 +13,6 @@ #include <gtkmm/icontheme.h> -#include "widgets/icon.h" #include "widgets/toolbox.h" #include "ui/icon-names.h" @@ -32,23 +31,14 @@ ImageToggler::ImageToggler( char const* on, char const* off) : _property_pixbuf_off(*this, "pixbuf_off", Glib::RefPtr<Gdk::Pixbuf>(0)) { property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE; - int phys = sp_icon_get_phys_size((int)Inkscape::ICON_SIZE_DECORATION); - Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default(); - - if (!icon_theme->has_icon(_pixOnName)) { - Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixOnName.data()), Inkscape::ICON_SIZE_DECORATION ); - } - if (!icon_theme->has_icon(_pixOffName)) { - Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixOffName.data()), Inkscape::ICON_SIZE_DECORATION ); - } + gint width, height; + gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); + int phys = width; - if (icon_theme->has_icon(_pixOnName)) { - _property_pixbuf_on = icon_theme->load_icon(_pixOnName, phys, (Gtk::IconLookupFlags)0); - } - if (icon_theme->has_icon(_pixOffName)) { - _property_pixbuf_off = icon_theme->load_icon(_pixOffName, phys, (Gtk::IconLookupFlags)0); - } + Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default(); + _property_pixbuf_on = icon_theme->load_icon(_pixOnName, phys, (Gtk::IconLookupFlags)0); + _property_pixbuf_off = icon_theme->load_icon(_pixOffName, phys, (Gtk::IconLookupFlags)0); property_pixbuf() = _property_pixbuf_off.get_value(); } diff --git a/src/ui/widget/insertordericon.cpp b/src/ui/widget/insertordericon.cpp index 7ed1ed2e2..5d1f64a54 100644 --- a/src/ui/widget/insertordericon.cpp +++ b/src/ui/widget/insertordericon.cpp @@ -11,7 +11,6 @@ #include <gtkmm/icontheme.h> -#include "widgets/icon.h" #include "widgets/toolbox.h" #include "ui/icon-names.h" #include "layertypeicon.h" @@ -31,22 +30,14 @@ InsertOrderIcon::InsertOrderIcon() : { property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE; - phys = sp_icon_get_phys_size((int)Inkscape::ICON_SIZE_DECORATION); - Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default(); - if (!icon_theme->has_icon(_pixTopName)) { - Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixTopName.data()), Inkscape::ICON_SIZE_DECORATION ); - } - if (!icon_theme->has_icon(_pixBottomName)) { - Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixBottomName.data()), Inkscape::ICON_SIZE_DECORATION ); - } + gint width, height; + gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); + phys=width; - if (icon_theme->has_icon(_pixTopName)) { - _property_pixbuf_top = icon_theme->load_icon(_pixTopName, phys, (Gtk::IconLookupFlags)0); - } - if (icon_theme->has_icon(_pixBottomName)) { - _property_pixbuf_bottom = icon_theme->load_icon(_pixBottomName, phys, (Gtk::IconLookupFlags)0); - } + Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default(); + _property_pixbuf_top = icon_theme->load_icon(_pixTopName, phys, (Gtk::IconLookupFlags)0); + _property_pixbuf_bottom = icon_theme->load_icon(_pixBottomName, phys, (Gtk::IconLookupFlags)0); property_pixbuf() = Glib::RefPtr<Gdk::Pixbuf>(0); } diff --git a/src/ui/widget/labelled.cpp b/src/ui/widget/labelled.cpp index 6e3652830..d3dc6210f 100644 --- a/src/ui/widget/labelled.cpp +++ b/src/ui/widget/labelled.cpp @@ -14,8 +14,7 @@ #include "labelled.h" -/* For getting the Gtkmmified Icon manager */ -#include "widgets/icon.h" +#include <gtkmm/image.h> #include <gtkmm/label.h> namespace Inkscape { @@ -33,8 +32,9 @@ Labelled::Labelled(Glib::ustring const &label, Glib::ustring const &tooltip, { g_assert(g_utf8_validate(icon.c_str(), -1, NULL)); if (icon != "") { - _icon = sp_icon_get_icon(icon.c_str(), Inkscape::ICON_SIZE_LARGE_TOOLBAR); - pack_start(*Gtk::manage(_icon), Gtk::PACK_SHRINK); + _icon = Gtk::manage(new Gtk::Image()); + _icon->set_from_icon_name(icon, Gtk::ICON_SIZE_LARGE_TOOLBAR); + pack_start(*_icon, Gtk::PACK_SHRINK); } pack_start(*Gtk::manage(_label), Gtk::PACK_EXPAND_WIDGET, 6); pack_start(*Gtk::manage(_widget), Gtk::PACK_SHRINK, 6); diff --git a/src/ui/widget/labelled.h b/src/ui/widget/labelled.h index 88eb3ce19..824abf305 100644 --- a/src/ui/widget/labelled.h +++ b/src/ui/widget/labelled.h @@ -14,6 +14,7 @@ #include <gtkmm/box.h> namespace Gtk { +class Image; class Label; } @@ -64,7 +65,7 @@ protected: Gtk::Widget *_widget; Gtk::Label *_label; Gtk::Label *_suffix; - Gtk::Widget *_icon; + Gtk::Image *_icon; }; } // namespace Widget diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index 4432a6e09..0332143b5 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -31,7 +31,6 @@ #include "util/filter-list.h" #include "util/reverse-list.h" #include "verbs.h" -#include "widgets/icon.h" #include "xml/node-event-vector.h" #include "widgets/gradient-vector.h" @@ -42,17 +41,19 @@ namespace { class AlternateIcons : public Gtk::HBox { public: - AlternateIcons(Inkscape::IconSize size, gchar const *a, gchar const *b) + AlternateIcons(Gtk::IconSize size, Glib::ustring const &a, Glib::ustring const &b) : _a(NULL), _b(NULL) { set_name("AlternateIcons"); - if (a) { - _a = Gtk::manage(sp_icon_get_icon(a, size)); + if (!a.empty()) { + _a = Gtk::manage(new Gtk::Image()); + _a->set_from_icon_name(a, size); _a->set_no_show_all(true); add(*_a); } - if (b) { - _b = Gtk::manage(sp_icon_get_icon(b, size)); + if (!b.empty()) { + _b = Gtk::manage(new Gtk::Image()); + _b->set_from_icon_name(b, size); _b->set_no_show_all(true); add(*_b); } @@ -80,8 +81,8 @@ public: } private: - Gtk::Widget *_a; - Gtk::Widget *_b; + Gtk::Image *_a; + Gtk::Image *_b; bool _state; }; @@ -98,7 +99,7 @@ LayerSelector::LayerSelector(SPDesktop *desktop) set_name("LayerSelector"); AlternateIcons *label; - label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_DECORATION, + label = Gtk::manage(new AlternateIcons(Gtk::ICON_SIZE_MENU, INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-hidden"))); _visibility_toggle.add(*label); _visibility_toggle.signal_toggled().connect( @@ -118,7 +119,7 @@ LayerSelector::LayerSelector(SPDesktop *desktop) _visibility_toggle.set_tooltip_text(_("Toggle current layer visibility")); pack_start(_visibility_toggle, Gtk::PACK_EXPAND_PADDING); - label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_DECORATION, + label = Gtk::manage(new AlternateIcons(Gtk::ICON_SIZE_MENU, INKSCAPE_ICON("object-unlocked"), INKSCAPE_ICON("object-locked"))); _lock_toggle.add(*label); _lock_toggle.signal_toggled().connect( diff --git a/src/ui/widget/layertypeicon.cpp b/src/ui/widget/layertypeicon.cpp index df85f271a..3a8ffab44 100644 --- a/src/ui/widget/layertypeicon.cpp +++ b/src/ui/widget/layertypeicon.cpp @@ -15,7 +15,6 @@ #include <gtkmm/icontheme.h> -#include "widgets/icon.h" #include "widgets/toolbox.h" #include "ui/icon-names.h" @@ -37,28 +36,14 @@ LayerTypeIcon::LayerTypeIcon() : { property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE; - int phys = sp_icon_get_phys_size((int)Inkscape::ICON_SIZE_DECORATION); - Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default(); - - if (!icon_theme->has_icon(_pixLayerName)) { - Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixLayerName.data()), Inkscape::ICON_SIZE_DECORATION ); - } - if (!icon_theme->has_icon(_pixGroupName)) { - Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixGroupName.data()), Inkscape::ICON_SIZE_DECORATION ); - } - if (!icon_theme->has_icon(_pixPathName)) { - Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixPathName.data()), Inkscape::ICON_SIZE_DECORATION ); - } + gint width, height; + gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); + int phys = width; - if (icon_theme->has_icon(_pixLayerName)) { - _property_pixbuf_layer = icon_theme->load_icon(_pixLayerName, phys, (Gtk::IconLookupFlags)0); - } - if (icon_theme->has_icon(_pixGroupName)) { - _property_pixbuf_group = icon_theme->load_icon(_pixGroupName, phys, (Gtk::IconLookupFlags)0); - } - if (icon_theme->has_icon(_pixPathName)) { - _property_pixbuf_path = icon_theme->load_icon(_pixPathName, phys, (Gtk::IconLookupFlags)0); - } + Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default(); + _property_pixbuf_layer = icon_theme->load_icon(_pixLayerName, phys, (Gtk::IconLookupFlags)0); + _property_pixbuf_group = icon_theme->load_icon(_pixGroupName, phys, (Gtk::IconLookupFlags)0); + _property_pixbuf_path = icon_theme->load_icon(_pixPathName, phys, (Gtk::IconLookupFlags)0); property_pixbuf() = _property_pixbuf_path.get_value(); } diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index 1727660c8..ca33a845c 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -24,7 +24,6 @@ #include "style.h" #include "svg/css-ostringstream.h" #include "verbs.h" -#include "widgets/icon.h" #include "display/sp-canvas.h" #include "ui/widget/style-subject.h" diff --git a/src/ui/widget/object-composite-settings.h b/src/ui/widget/object-composite-settings.h index ae16564e1..d7525093f 100644 --- a/src/ui/widget/object-composite-settings.h +++ b/src/ui/widget/object-composite-settings.h @@ -12,7 +12,6 @@ */ #include <gtkmm/box.h> -#include <gtkmm/alignment.h> #include <gtkmm/adjustment.h> #include <gtkmm/label.h> #include <gtkmm/scale.h> diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 081300b9e..bb88536d5 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -374,37 +374,31 @@ PageSizer::PageSizer(Registry & _wr) _marginTable.set_row_spacing(4); _marginTable.set_column_spacing(4); - _marginTopAlign.set_hexpand(); - _marginTopAlign.set_vexpand(); - _marginTable.attach(_marginTopAlign, 0, 0, 2, 1); - - _marginLeftAlign.set_hexpand(); - _marginLeftAlign.set_vexpand(); - _marginTable.attach(_marginLeftAlign, 0, 1, 1, 1); - - _marginRightAlign.set_hexpand(); - _marginRightAlign.set_vexpand(); - _marginTable.attach(_marginRightAlign, 1, 1, 1, 1); - - _marginBottomAlign.set_hexpand(); - _marginBottomAlign.set_vexpand(); - _marginTable.attach(_marginBottomAlign, 0, 2, 2, 1); - - _fitPageButtonAlign.set_hexpand(); - _fitPageButtonAlign.set_vexpand(); - _marginTable.attach(_fitPageButtonAlign, 0, 3, 2, 1); - - _marginTopAlign.set(0.5, 0.5, 0.0, 1.0); - _marginTopAlign.add(_marginTop); - _marginLeftAlign.set(0.0, 0.5, 0.0, 1.0); - _marginLeftAlign.add(_marginLeft); - _marginRightAlign.set(1.0, 0.5, 0.0, 1.0); - _marginRightAlign.add(_marginRight); - _marginBottomAlign.set(0.5, 0.5, 0.0, 1.0); - _marginBottomAlign.add(_marginBottom); + _marginTop.set_halign(Gtk::ALIGN_CENTER); + _marginTop.set_hexpand(); + _marginTop.set_vexpand(); + _marginTable.attach(_marginTop, 0, 0, 2, 1); + + _marginLeft.set_halign(Gtk::ALIGN_START); + _marginLeft.set_hexpand(); + _marginLeft.set_vexpand(); + _marginTable.attach(_marginLeft, 0, 1, 1, 1); + + _marginRight.set_halign(Gtk::ALIGN_END); + _marginRight.set_hexpand(); + _marginRight.set_vexpand(); + _marginTable.attach(_marginRight, 1, 1, 1, 1); + + _marginBottom.set_halign(Gtk::ALIGN_CENTER); + _marginBottom.set_hexpand(); + _marginBottom.set_vexpand(); + _marginTable.attach(_marginBottom, 0, 2, 2, 1); + + _fitPageButton.set_halign(Gtk::ALIGN_CENTER); + _fitPageButton.set_hexpand(); + _fitPageButton.set_vexpand(); + _marginTable.attach(_fitPageButton, 0, 3, 2, 1); - _fitPageButtonAlign.set(0.5, 0.5, 0.0, 1.0); - _fitPageButtonAlign.add(_fitPageButton); _fitPageButton.set_use_underline(); _fitPageButton.set_label(_("_Resize page to drawing or selection (Ctrl+Shift+R)")); _fitPageButton.set_tooltip_text(_("Resize the page to fit the current selection, or the entire drawing if there is no selection")); diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index f1966f848..d0655fb0e 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -20,7 +20,6 @@ #include "util/units.h" -#include <gtkmm/alignment.h> #include <gtkmm/expander.h> #include <gtkmm/frame.h> #include <gtkmm/grid.h> @@ -227,15 +226,10 @@ protected: Gtk::Expander _fitPageMarginExpander; Gtk::Grid _marginTable; - Gtk::Alignment _marginTopAlign; - Gtk::Alignment _marginLeftAlign; - Gtk::Alignment _marginRightAlign; - Gtk::Alignment _marginBottomAlign; RegisteredScalar _marginTop; RegisteredScalar _marginLeft; RegisteredScalar _marginRight; RegisteredScalar _marginBottom; - Gtk::Alignment _fitPageButtonAlign; Gtk::Button _fitPageButton; bool _lockMarginUpdate; diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index dff92594b..9332fe0f9 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -46,7 +46,7 @@ static const int PANEL_SETTING_NEXTFREE = 5; void Panel::prep() { GtkIconSize sizes[] = { - Inkscape::getRegisteredIconSize(Inkscape::ICON_SIZE_DECORATION), + GTK_ICON_SIZE_MENU, GTK_ICON_SIZE_MENU, GTK_ICON_SIZE_SMALL_TOOLBAR, GTK_ICON_SIZE_BUTTON, @@ -270,7 +270,7 @@ void Panel::_init() gint height = 0; gtk_image_set_from_icon_name(_temp_arrow.gobj(), "pan-start-symbolic", - Inkscape::getRegisteredIconSize(Inkscape::ICON_SIZE_SMALL_TOOLBAR)); + GTK_ICON_SIZE_SMALL_TOOLBAR); _menu_popper.add(_temp_arrow); _menu_popper.signal_button_press_event().connect_notify(sigc::mem_fun(*this, &Panel::_popper)); } diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index b2cebcaa6..2981316c0 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -16,7 +16,6 @@ #include <gtkmm/box.h> #include <gtkmm/frame.h> -#include <gtkmm/alignment.h> #include <gtkmm/scale.h> #include <gtkmm/table.h> @@ -77,9 +76,7 @@ void DialogPage::add_line(bool indent, if (tip != "") widget.set_tooltip_text (tip); - Gtk::Alignment* label_alignment = Gtk::manage(new Gtk::Alignment()); - - Gtk::HBox* hb = Gtk::manage(new Gtk::HBox()); + auto hb = Gtk::manage(new Gtk::Box()); hb->set_spacing(12); hb->pack_start(widget, expand_widget, expand_widget); @@ -87,11 +84,7 @@ void DialogPage::add_line(bool indent, if (other_widget) hb->pack_start(*other_widget, expand_widget, expand_widget); - // Pack the widget into an alignment container so that it can - // be indented if desired - Gtk::Alignment* w_alignment = Gtk::manage(new Gtk::Alignment()); - w_alignment->add(*hb); - w_alignment->set_valign(Gtk::ALIGN_CENTER); + hb->set_valign(Gtk::ALIGN_CENTER); // Add a label in the first column if provided if (label != "") @@ -100,30 +93,36 @@ void DialogPage::add_line(bool indent, Gtk::ALIGN_CENTER, true)); label_widget->set_mnemonic_widget(widget); - // Pack the label into an alignment container so that we can indent it - // if necessary - label_alignment->add(*label_widget); - - if (indent) - label_alignment->set_padding(0, 0, 12, 0); + if (indent) { +#if WITH_GTKMM_3_12 + label_widget->set_margin_start(12); +#else + label_widget->set_margin_left(12); +#endif + } - label_alignment->set_valign(Gtk::ALIGN_CENTER); - add(*label_alignment); - attach_next_to(*w_alignment, *label_alignment, Gtk::POS_RIGHT, 1, 1); + label_widget->set_valign(Gtk::ALIGN_CENTER); + add(*label_widget); + attach_next_to(*hb, *label_widget, Gtk::POS_RIGHT, 1, 1); } // Now add the widget to the bottom of the dialog if (label == "") { - if (indent) - w_alignment->set_padding(0, 0, 12, 0); + if (indent) { +#if WITH_GTKMM_3_12 + hb->set_margin_start(12); +#else + hb->set_margin_left(12); +#endif + } - add(*w_alignment); + add(*hb); GValue width = G_VALUE_INIT; g_value_init(&width, G_TYPE_INT); g_value_set_int(&width, 2); - gtk_container_child_set_property(GTK_CONTAINER(gobj()), GTK_WIDGET(w_alignment->gobj()), "width", &width); + gtk_container_child_set_property(GTK_CONTAINER(gobj()), GTK_WIDGET(hb->gobj()), "width", &width); } // Add a label on the right of the widget if desired @@ -505,24 +504,21 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl _sb.set_increments (step_increment, 0); _sb.set_value (value); _sb.set_digits(2); + _sb.set_halign(Gtk::ALIGN_CENTER); + _sb.set_valign(Gtk::ALIGN_END); _unit.set_data("sensitive", GINT_TO_POINTER(0)); _unit.setUnitType(UNIT_TYPE_LINEAR); _unit.set_data("sensitive", GINT_TO_POINTER(1)); _unit.setUnit(prefs->getString("/options/zoomcorrection/unit")); - - Gtk::Alignment *alignment1 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0)); - Gtk::Alignment *alignment2 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0)); - alignment1->add(_sb); - alignment2->add(_unit); + _unit.set_halign(Gtk::ALIGN_CENTER); + _unit.set_valign(Gtk::ALIGN_END); auto table = Gtk::manage(new Gtk::Grid()); - table->attach(*_slider, 0, 0, 1, 1); - alignment1->set_halign(Gtk::ALIGN_CENTER); - table->attach(*alignment1, 1, 0, 1, 1); - table->attach(_ruler, 0, 1, 1, 1); - alignment2->set_halign(Gtk::ALIGN_CENTER); - table->attach(*alignment2, 1, 1, 1, 1); + table->attach(*_slider, 0, 0, 1, 1); + table->attach(_sb, 1, 0, 1, 1); + table->attach(_ruler, 0, 1, 1, 1); + table->attach(_unit, 1, 1, 1, 1); pack_start(*table, Gtk::PACK_SHRINK); } @@ -582,15 +578,13 @@ PrefSlider::init(Glib::ustring const &prefs_path, _sb.set_increments (step_increment, 0); _sb.set_value (value); _sb.set_digits(digits); - - Gtk::Alignment *alignment1 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0)); - alignment1->add(_sb); + _sb.set_halign(Gtk::ALIGN_CENTER); + _sb.set_valign(Gtk::ALIGN_END); auto table = Gtk::manage(new Gtk::Grid()); _slider->set_hexpand(); - table->attach(*_slider, 0, 0, 1, 1); - alignment1->set_halign(Gtk::ALIGN_CENTER); - table->attach(*alignment1, 1, 0, 1, 1); + table->attach(*_slider, 0, 0, 1, 1); + table->attach(_sb, 1, 0, 1, 1); this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET); } diff --git a/src/ui/widget/random.cpp b/src/ui/widget/random.cpp index ba3b025ba..237144c7c 100644 --- a/src/ui/widget/random.cpp +++ b/src/ui/widget/random.cpp @@ -15,11 +15,11 @@ #include "random.h" -#include "widgets/icon.h" #include <glibmm/i18n.h> #include <gtkmm/button.h> +#include <gtkmm/image.h> namespace Inkscape { namespace UI { @@ -70,7 +70,8 @@ void Random::setStartSeed(long newseed) void Random::addReseedButton() { - Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "randomize", Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Image* pIcon = Gtk::manage(new Gtk::Image()); + pIcon->set_from_icon_name( "randomize", Gtk::ICON_SIZE_BUTTON); Gtk::Button * pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index be677a434..0af5bdba0 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -55,7 +55,11 @@ RegisteredCheckButton::RegisteredCheckButton (const Glib::ustring& label, const Gtk::Label *l = new Gtk::Label (label); l->set_use_underline (true); add (*manage (l)); - set_alignment (right? 1.0 : 0.0, 0.5); + + if(right) set_halign(Gtk::ALIGN_END); + else set_halign(Gtk::ALIGN_START); + + set_valign(Gtk::ALIGN_CENTER); _toggled_connection = signal_toggled().connect (sigc::mem_fun (*this, &RegisteredCheckButton::on_toggled)); } @@ -107,7 +111,11 @@ RegisteredToggleButton::RegisteredToggleButton (const Glib::ustring& /*label*/, init_parent(key, wr, repr_in, doc_in); setProgrammatically = false; set_tooltip_text (tip); - set_alignment (right? 1.0 : 0.0, 0.5); + + if(right) set_halign(Gtk::ALIGN_END); + else set_halign(Gtk::ALIGN_START); + + set_valign(Gtk::ALIGN_CENTER); _toggled_connection = signal_toggled().connect (sigc::mem_fun (*this, &RegisteredToggleButton::on_toggled)); } diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 65d68195c..8ea1e530f 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -146,11 +146,14 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _drop[0] = _drop[1] = 0; _dropEnabled[0] = _dropEnabled[1] = false; - _fill_label.set_alignment(0.0, 0.5); + _fill_label.set_halign(Gtk::ALIGN_START); + _fill_label.set_valign(Gtk::ALIGN_CENTER); _fill_label.set_padding(0, 0); - _stroke_label.set_alignment(0.0, 0.5); + _stroke_label.set_halign(Gtk::ALIGN_START); + _stroke_label.set_valign(Gtk::ALIGN_CENTER); _stroke_label.set_padding(0, 0); - _opacity_label.set_alignment(0.0, 0.5); + _opacity_label.set_halign(Gtk::ALIGN_START); + _opacity_label.set_valign(Gtk::ALIGN_CENTER); _opacity_label.set_padding(0, 0); _table.set_column_spacing(2); diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index f8eac1c78..4beb0b323 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -116,13 +116,15 @@ StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip) _label[SS_STROKE].set_markup(_("Stroke:")); for (int i = SS_FILL; i <= SS_STROKE; i++) { - _label[i].set_alignment(0.0, 0.5); + _label[i].set_halign(Gtk::ALIGN_START); + _label[i].set_valign(Gtk::ALIGN_CENTER); _label[i].set_padding(0, 0); _color_preview[i] = new Inkscape::UI::Widget::ColorPreview (0); } - _opacity_value.set_alignment(0.0, 0.5); + _opacity_value.set_halign(Gtk::ALIGN_START); + _opacity_value.set_valign(Gtk::ALIGN_CENTER); _opacity_value.set_padding(0, 0); _table->set_column_spacing(2); diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp index dea14585d..47e646c34 100644 --- a/src/ui/widget/tolerance-slider.cpp +++ b/src/ui/widget/tolerance-slider.cpp @@ -72,7 +72,8 @@ void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& la Gtk::Label *theLabel1 = Gtk::manage(new Gtk::Label(label1)); theLabel1->set_use_underline(); - theLabel1->set_alignment(0, 0.5); + theLabel1->set_halign(Gtk::ALIGN_START); + theLabel1->set_valign(Gtk::ALIGN_CENTER); // align the label with the checkbox text above by indenting 22 px. _hbox->pack_start(*theLabel1, Gtk::PACK_EXPAND_WIDGET, 22); @@ -100,9 +101,11 @@ void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& la _button1->set_tooltip_text (tip2); _button2->set_tooltip_text (tip3); _button1->add (*theLabel3); - _button1->set_alignment (0.0, 0.5); + _button1->set_halign(Gtk::ALIGN_START); + _button1->set_valign(Gtk::ALIGN_CENTER); _button2->add (*theLabel2); - _button2->set_alignment (0.0, 0.5); + _button2->set_halign(Gtk::ALIGN_START); + _button2->set_valign(Gtk::ALIGN_CENTER); _vbox->add (*_button1); _vbox->add (*_button2); |
