diff --git a/share/ui/color-palette.glade b/share/ui/color-palette.glade
index 4b9e31ae5cbc198e1e61d5e429ac20a68d3b323d..b388d131aa56e91514719586397ad8fe71283b6c 100644
--- a/share/ui/color-palette.glade
+++ b/share/ui/color-palette.glade
@@ -27,6 +27,7 @@
2
-
diff --git a/share/ui/page-properties.glade b/share/ui/page-properties.glade
index e09544740e61033d9dcea6f4ed7b262450b0ae72..fa4f60b399a1e48a9f7d0ef9e92c9e3e77403efd 100644
--- a/share/ui/page-properties.glade
+++ b/share/ui/page-properties.glade
@@ -148,12 +148,12 @@
5
True
page-portrait
-
+
20
page-landscape-symbolic
-
+
@@ -161,12 +161,12 @@
True
5
True
-
+
20
page-portrait-symbolic
-
+
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index ad12fdbdd07d94bfe55a212567e539326ef2f8ca..8ef41a286aa5b3375fa58784fa949b473e2da008 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -11,7 +11,6 @@ set(ui_SRC
drag-and-drop.cpp
icon-loader.cpp
interface.cpp
- menuize.cpp
monitor.cpp
pack.cpp
popup-menu.cpp
@@ -137,10 +136,9 @@ set(ui_SRC
dialog/filter-effects-dialog.cpp
dialog/find.cpp
dialog/font-collections-manager.cpp
- widget/font-collection-selector.cpp
dialog/font-substitution.cpp
dialog/global-palettes.cpp
- dialog/glyphs.cpp
+ dialog/glyphs.cpp
dialog/grid-arrange-tab.cpp
dialog/guides.cpp
dialog/icon-preview.cpp
@@ -200,7 +198,6 @@ set(ui_SRC
widget/color-palette-preview.cpp
widget/color-picker.cpp
widget/color-preview.cpp
- icon-loader.cpp
widget/color-scales.cpp
widget/color-slider.cpp
widget/combo-box-entry-tool-item.cpp
@@ -208,7 +205,7 @@ set(ui_SRC
widget/css-name-class-init.cpp
widget/custom-tooltip.cpp
widget/dash-selector.cpp
- widget/desktop-widget.cpp
+ widget/desktop-widget.cpp
widget/entity-entry.cpp
widget/entry.cpp
widget/export-lists.cpp
@@ -216,6 +213,7 @@ set(ui_SRC
widget/filter-effect-chooser.cpp
widget/fill-style.cpp
widget/font-button.cpp
+ widget/font-collection-selector.cpp
widget/font-selector.cpp
widget/font-selector-toolbar.cpp
widget/font-variants.cpp
@@ -248,6 +246,7 @@ set(ui_SRC
widget/paint-selector.cpp
widget/pattern-editor.cpp
widget/point.cpp
+ widget/popover-bin.cpp
widget/popover-menu.cpp
widget/popover-menu-item.cpp
widget/preferences-widget.cpp
@@ -263,7 +262,7 @@ set(ui_SRC
widget/shapeicon.cpp
widget/spin-scale.cpp
widget/spinbutton.cpp
- widget/status-bar.cpp
+ widget/status-bar.cpp
widget/stroke-style.cpp
widget/style-subject.cpp
widget/style-swatch.cpp
@@ -274,7 +273,7 @@ set(ui_SRC
widget/unit-menu.cpp
widget/unit-tracker.cpp
widget/widget-vfuncs-class-init.cpp
- widget/xml-treeview.cpp
+ widget/xml-treeview.cpp
view/svg-view-widget.cpp
@@ -284,6 +283,7 @@ set(ui_SRC
builder-utils.h
clipboard.h
contextmenu.h
+ containerize.h
controller.h
cursor-utils.h
control-types.h
@@ -295,7 +295,6 @@ set(ui_SRC
icon-names.h
icon-loader.h
interface.h
- menuize.h
monitor.h
pack.h
popup-menu.h
@@ -481,7 +480,7 @@ set(ui_SRC
widget/canvas/glgraphics.h
widget/canvas/cairographics.h
widget/canvas-grid.h
- widget/canvas-notice.h
+ widget/canvas-notice.h
widget/completion-popup.h
widget/color-entry.h
widget/color-icc-selector.h
@@ -498,7 +497,7 @@ set(ui_SRC
widget/css-name-class-init.h
widget/custom-tooltip.h
widget/dash-selector.h
- widget/desktop-widget.h
+ widget/desktop-widget.h
widget/entity-entry.h
widget/entry.h
widget/events/canvas-event.h
@@ -541,6 +540,7 @@ set(ui_SRC
widget/palette_t.h
widget/pattern-editor.h
widget/point.h
+ widget/popover-bin.h
widget/popover-menu.h
widget/popover-menu-item.h
widget/preferences-widget.h
@@ -557,7 +557,7 @@ set(ui_SRC
widget/shapeicon.h
widget/spin-scale.h
widget/spinbutton.h
- widget/status-bar.h
+ widget/status-bar.h
widget/stroke-style.h
widget/style-subject.h
widget/style-swatch.h
@@ -567,7 +567,7 @@ set(ui_SRC
widget/unit-menu.h
widget/unit-tracker.h
widget/widget-vfuncs-class-init.h
- widget/xml-treeview.h
+ widget/xml-treeview.h
view/svg-view-widget.h
)
diff --git a/src/ui/containerize.h b/src/ui/containerize.h
new file mode 100644
index 0000000000000000000000000000000000000000..0a3b4d0210ff4f75b5d45b66e5aa76f7e3c6975e
--- /dev/null
+++ b/src/ui/containerize.h
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#ifndef INKSCAPE_UI_CONTAINERIZE_H
+#define INKSCAPE_UI_CONTAINERIZE_H
+
+#include
+
+namespace Inkscape::UI {
+
+/**
+ * Make a custom widget implement sensible memory management for its children.
+ *
+ * This frees the implementer of a custom widget from having to manually unparent()
+ * children added with set_parent() both in the destructor and on signal_destroy(),
+ * a memory management detail from C that has no business leaking into C++.
+ *
+ * Upon destruction, or for managed widgets just before, all children are unparented.
+ * Managed children are also deleted if they have no other references.
+ *
+ * This function is typically called in the constructor of a custom widget that derives
+ * from an intrinsically childless Gtk widget, e.g. Gtk::Widget, Gtk::DrawingArea.
+
+ * It must not be used with any intrinsically child-containing Gtk widget, e.g.
+ * Gtk::Box, Gtk::SpinButton.
+ */
+inline void containerize(Gtk::Widget &widget)
+{
+ g_signal_connect(widget.gobj(), "destroy", G_CALLBACK(+[] (GtkWidget *gobj, void *) {
+ for (auto c = gtk_widget_get_first_child(gobj); c; ) {
+ auto cnext = gtk_widget_get_next_sibling(c);
+ gtk_widget_unparent(c);
+ c = cnext;
+ }
+ }), nullptr);
+}
+
+} // namespace Inkscape::UI
+
+#endif // INKSCAPE_UI_CONTAINERIZE_H
diff --git a/src/ui/contextmenu.cpp b/src/ui/contextmenu.cpp
index 92afb607e8af43ffaa61d7dd100ac0a73200ef94..55d8816b0fcc2ed03e59980bc56b1c85a29d8551 100644
--- a/src/ui/contextmenu.cpp
+++ b/src/ui/contextmenu.cpp
@@ -47,7 +47,6 @@
#include "object/sp-text.h"
#include "object/sp-use.h"
#include "ui/desktop/menu-set-tooltips-shift-icons.h"
-#include "ui/menuize.h"
#include "ui/util.h"
#include "ui/widget/desktop-widget.h"
@@ -347,14 +346,11 @@ ContextMenu::ContextMenu(SPDesktop *desktop, SPObject *object, bool hide_layers_
}
// clang-format on
- auto const widget = desktop->getDesktopWidget();
- g_assert(widget);
- set_parent(*widget);
set_menu_model(gmenu);
set_position(Gtk::PositionType::BOTTOM);
set_has_arrow(false);
show_all_images(*this);
- Inkscape::UI::menuize_popover(*this);
+ set_flags(Gtk::PopoverMenu::Flags::NESTED);
// Do not install this CSS provider; it messes up menus with icons (like popup menu with all dialogs).
// It doesn't work well with context menu either, introducing disturbing visual glitch
diff --git a/src/ui/contextmenu.h b/src/ui/contextmenu.h
index a66f8c824436a6c785848d2ddca751236064766c..bdd23861f4624116534acb1bfed73a34cc444cae 100644
--- a/src/ui/contextmenu.h
+++ b/src/ui/contextmenu.h
@@ -40,6 +40,7 @@ private:
std::vector items_under_cursor;
void unhide_or_unlock(SPDocument* document, bool unhide);
};
+
#endif // SEEN_CONTEXT_MENU_H
/*
diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp
index dd157f71f38cb0a2b2909c986326a409f4476fe1..987e636abf848e5e62dde3083fc1030f03b409fc 100644
--- a/src/ui/dialog/attrdialog.cpp
+++ b/src/ui/dialog/attrdialog.cpp
@@ -57,7 +57,6 @@
#include "ui/dialog/inkscape-preferences.h"
#include "ui/icon-loader.h"
#include "ui/icon-names.h"
-#include "ui/menuize.h"
#include "ui/pack.h"
#include "ui/popup-menu.h"
#include "ui/syntax.h"
@@ -235,7 +234,6 @@ AttrDialog::AttrDialog()
action->property_state().signal_changed().connect([=, this]{ int n; action->get_state(n);
setPrecision(n); });
insert_action_group("attrdialog", std::move(group));
- UI::menuize_popover(*get_widget(_builder, "btn-menu").get_popover());
attr_reset_context(0);
UI::pack_start(*this, get_widget(_builder, "main-box"), UI::PackOptions::expand_widget);
@@ -281,13 +279,6 @@ void AttrDialog::adjust_popup_edit_size()
}
}
-void AttrDialog::size_allocate_vfunc(int const width, int const height, int const baseline)
-{
- DialogBase::size_allocate_vfunc(width, height, baseline);
-
- _popover->present();
-}
-
bool AttrDialog::onPopoverKeyPressed(GtkEventControllerKey const * /*controller*/,
unsigned keyval, unsigned /*keycode*/,
GdkModifierType state)
diff --git a/src/ui/dialog/attrdialog.h b/src/ui/dialog/attrdialog.h
index f586070b8e9fd8fc289bd526127c5f4b2a15bc22..d16c2d934460a51eb60d41745309331e228b7ecd 100644
--- a/src/ui/dialog/attrdialog.h
+++ b/src/ui/dialog/attrdialog.h
@@ -154,7 +154,6 @@ private:
auto_connection _close_popup;
int _rounding_precision = 0;
- void size_allocate_vfunc(int width, int height, int baseline) final;
bool onPopoverKeyPressed(GtkEventControllerKey const *controller,
unsigned keyval, unsigned keycode, GdkModifierType state);
diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp
index a2fcbe7e5a6c8d825348ee2a12ebd0b62262ae40..42de70f29c5e00f04378a736fafece6a5241aed5 100644
--- a/src/ui/dialog/color-item.cpp
+++ b/src/ui/dialog/color-item.cpp
@@ -28,16 +28,17 @@
#include
#include
#include
+#include
#include
#include
#include
+#include
#include
#include "desktop-style.h"
#include "document.h"
#include "document-undo.h"
#include "hsluv.h"
-#include "inkscape-preferences.h"
#include "message-context.h"
#include "preferences.h"
#include "selection.h"
@@ -45,34 +46,41 @@
#include "display/cairo-utils.h"
#include "helper/sigc-track-obj.h"
#include "io/resource.h"
-#include "io/sys.h"
#include "object/sp-gradient.h"
#include "object/tags.h"
#include "svg/svg-color.h"
+#include "ui/containerize.h"
#include "ui/controller.h"
#include "ui/dialog/dialog-base.h"
#include "ui/dialog/dialog-container.h"
#include "ui/icon-names.h"
-#include "ui/menuize.h"
#include "ui/util.h"
-[[nodiscard]] static auto const &get_removecolor()
+namespace Inkscape::UI::Dialog {
+namespace {
+
+// Return the result of executing a lambda, and cache the result for future calls.
+template
+auto &staticify(F &&f)
{
- // The "remove-color" image.
- static Glib::RefPtr pixbuf;
- if (pixbuf) return pixbuf;
-
- auto path_utf8 = (Glib::ustring)Inkscape::IO::Resource::get_path(Inkscape::IO::Resource::SYSTEM,
- Inkscape::IO::Resource::UIS, "resources", "remove-color.png");
- auto path = Glib::filename_from_utf8(path_utf8);
- pixbuf = Gdk::Pixbuf::create_from_file(path);
- if (!pixbuf) {
- g_warning("Null pixbuf for %p [%s]", path.c_str(), path.c_str());
- }
- return pixbuf;
+ static auto result = std::forward(f)();
+ return result;
}
-namespace Inkscape::UI::Dialog {
+// Get the "remove-color" image.
+Glib::RefPtr get_removecolor()
+{
+ return staticify([] {
+ auto path = IO::Resource::get_path(IO::Resource::SYSTEM, IO::Resource::UIS, "resources", "remove-color.png");
+ auto pixbuf = Gdk::Pixbuf::create_from_file(path.pointer());
+ if (!pixbuf) {
+ std::cerr << "Null pixbuf for " << Glib::filename_to_utf8(path.pointer()) << std::endl;
+ }
+ return pixbuf;
+ });
+}
+
+} // namespace
ColorItem::ColorItem(PaintDef const &paintdef, DialogBase *dialog)
: dialog(dialog)
@@ -120,7 +128,9 @@ ColorItem::ColorItem(SPGradient *gradient, DialogBase *dialog)
common_setup();
}
-ColorItem::ColorItem(Glib::ustring name) : description(std::move(name)) {
+ColorItem::ColorItem(Glib::ustring name)
+ : description(std::move(name))
+{
bool group = !description.empty();
set_name("ColorItem");
set_tooltip_text(description);
@@ -140,8 +150,11 @@ bool ColorItem::is_filler() const {
void ColorItem::common_setup()
{
+ containerize(*this);
+ set_layout_manager(Gtk::BinLayout::create());
set_name("ColorItem");
set_tooltip_text(description + (tooltip.empty() ? tooltip : "\n" + tooltip));
+
set_draw_func(sigc::mem_fun(*this, &ColorItem::draw_func));
Controller::add_drag_source(*this, {
@@ -267,7 +280,7 @@ void ColorItem::draw_func(Cairo::RefPtr const &cr, int const w,
}
}
-void ColorItem::size_allocate_vfunc(int const width, int const height, int const baseline)
+void ColorItem::size_allocate_vfunc(int width, int height, int baseline)
{
Gtk::DrawingArea::size_allocate_vfunc(width, height, baseline);
@@ -413,10 +426,15 @@ void ColorItem::on_rightclick()
menu->append_section(section);
}
- // static to only create/show 1 menu over all items & avoid lifetime hassles
- static std::unique_ptr popover;
- popover = UI::make_menuized_popover(std::move(menu), *this);
- popover->popup();
+
+ if (_popover) {
+ _popover->unparent();
+ }
+
+ _popover = std::make_unique(menu, Gtk::PopoverMenu::Flags::NESTED);
+ _popover->set_parent(*this);
+
+ _popover->popup();
}
void ColorItem::action_set_fill()
diff --git a/src/ui/dialog/color-item.h b/src/ui/dialog/color-item.h
index b06de94badf708e1cbcd05d07d6421d39e2d7153..61d1078c544d414cef6b4ee932167c08d11c8b6e 100644
--- a/src/ui/dialog/color-item.h
+++ b/src/ui/dialog/color-item.h
@@ -34,6 +34,7 @@ class Drag;
namespace Gtk {
class DragSource;
class GestureClick;
+class Popover;
} // namespace Gtk
class SPGradient;
@@ -47,18 +48,18 @@ class DialogBase;
*
* Note: This widget must be outlived by its parent dialog, passed in the constructor.
*/
-class ColorItem final : public Gtk::DrawingArea
+class ColorItem : public Gtk::DrawingArea
{
public:
/// Create a static color from a paintdef.
ColorItem(PaintDef const&, DialogBase*);
/// Add new group or filler element.
ColorItem(Glib::ustring name);
- ~ColorItem() final;
+ ~ColorItem() override;
// Returns true if this is group heading rather than a color
bool is_group() const;
- // Returns true if this is alignmet filler item, not a color
+ // Returns true if this is alignment filler item, not a color
bool is_filler() const;
// Is paint "None"?
bool is_paint_none() const;
@@ -86,23 +87,19 @@ public:
private:
void draw_func(Cairo::RefPtr const&, int width, int height);
- void size_allocate_vfunc(int width, int height, int baseline) final;
+ void size_allocate_vfunc(int width, int height, int baseline) override;
- Glib::RefPtr on_drag_prepare(Gtk::DragSource const &source,
- double x, double y);
+ Glib::RefPtr on_drag_prepare(Gtk::DragSource const &source, double x, double y);
void on_drag_begin(Gtk::DragSource &source, Glib::RefPtr const &drag);
// Common post-construction setup.
void common_setup();
- void on_motion_enter(GtkEventControllerMotion const *motion,
- double x, double y);
+ void on_motion_enter(GtkEventControllerMotion const *motion, double x, double y);
void on_motion_leave(GtkEventControllerMotion const *motion);
- Gtk::EventSequenceState on_click_pressed (Gtk::GestureClick const &click,
- int n_press, double x, double y);
- Gtk::EventSequenceState on_click_released(Gtk::GestureClick const &click,
- int n_press, double x, double y);
+ Gtk::EventSequenceState on_click_pressed (Gtk::GestureClick const &click, int n_press, double x, double y);
+ Gtk::EventSequenceState on_click_released(Gtk::GestureClick const &click, int n_press, double x, double y);
// Perform the on-click action of setting the fill or stroke.
void on_click(bool stroke);
@@ -137,10 +134,10 @@ private:
bool pinned_default = false;
// The color.
+ struct Undefined {};
+ struct PaintNone {};
struct RGBData { std::array rgb; };
struct GradientData { SPGradient *gradient; };
- enum Undefined {};
- enum PaintNone {};
std::variant data;
// The dialog this widget belongs to. Used for determining what desktop to take action on.
@@ -153,6 +150,7 @@ private:
// A cache of the widget contents, if necessary.
Cairo::RefPtr cache;
bool cache_dirty = true;
+
bool was_grad_pinned = false;
// For ensuring that clicks that release outside the widget don't count.
@@ -160,6 +158,8 @@ private:
sigc::signal _signal_modified;
sigc::signal _signal_pinned;
+
+ std::unique_ptr _popover;
};
} // namespace Inkscape::UI::Dialog
diff --git a/src/ui/dialog/dialog-multipaned.cpp b/src/ui/dialog/dialog-multipaned.cpp
index 22379cd1c00912b648360b87c956add6e9d50e95..f9061af73af9156f6882d4b1df1da0d7cb284ef7 100644
--- a/src/ui/dialog/dialog-multipaned.cpp
+++ b/src/ui/dialog/dialog-multipaned.cpp
@@ -490,16 +490,9 @@ DialogMultipaned::DialogMultipaned(Gtk::Orientation orientation)
// add empty widget to initiate the container
add_empty_widget();
-
- signal_destroy().connect([this]{ unparent_children(); });
}
DialogMultipaned::~DialogMultipaned()
-{
- unparent_children();
-}
-
-void DialogMultipaned::unparent_children()
{
// Remove widgets that require special logic to remove.
// TODO: Understand why this is necessary.
diff --git a/src/ui/dialog/dialog-multipaned.h b/src/ui/dialog/dialog-multipaned.h
index 9bc59f26b234a20703ee3450a58dde337103d206..618800cf7556f3dcc4a056c37e0bce18a8a6e29a 100644
--- a/src/ui/dialog/dialog-multipaned.h
+++ b/src/ui/dialog/dialog-multipaned.h
@@ -118,7 +118,6 @@ private:
// Others
Gtk::Widget *_empty_widget; // placeholder in an empty container
- void unparent_children();
void insert(int pos, std::unique_ptr child);
void add_empty_widget();
void remove_empty_widget();
diff --git a/src/ui/dialog/dialog-notebook.cpp b/src/ui/dialog/dialog-notebook.cpp
index f704bf9722161ada01f080b8c99921dc5f335f41..4bd3da2290e673f4988c23ca8d4b9808a1f11b4a 100644
--- a/src/ui/dialog/dialog-notebook.cpp
+++ b/src/ui/dialog/dialog-notebook.cpp
@@ -54,8 +54,8 @@ std::list DialogNotebook::_instances;
DialogNotebook::DialogNotebook(DialogContainer *container)
: Gtk::ScrolledWindow()
, _container(container)
- , _menu {nullptr, Gtk::PositionType::BOTTOM}
- , _menutabs{*this , Gtk::PositionType::BOTTOM}
+ , _menu{Gtk::PositionType::BOTTOM}
+ , _menutabs{Gtk::PositionType::BOTTOM}
, _labels_auto(true)
, _detaching_duplicate(false)
, _selected_page(nullptr)
@@ -145,8 +145,7 @@ DialogNotebook::DialogNotebook(DialogContainer *container)
return a.order < b.order;
});
- auto builder = ColumnMenuBuilder{_menu, 2, Gtk::IconSize::NORMAL,
- row};
+ auto builder = ColumnMenuBuilder{_menu, 2, Gtk::IconSize::NORMAL, row};
for (auto const &data : all_dialogs) {
auto callback = [key = data.key]{
// get desktop's container, it may be different than current '_container'!
@@ -156,8 +155,7 @@ DialogNotebook::DialogNotebook(DialogContainer *container)
}
}
};
- builder.add_item(data.label, data.category, {}, data.icon_name, true, false,
- std::move(callback));
+ builder.add_item(data.label, data.category, {}, data.icon_name, true, false, std::move(callback));
if (builder.new_section()) {
builder.set_section(gettext(dialog_categories[data.category]));
}
@@ -188,8 +186,9 @@ DialogNotebook::DialogNotebook(DialogContainer *container)
// ============= Finish setup ===============
_reload_context = true;
- set_child(_notebook);
- set_visible(true);
+ _popoverbin.setChild(&_notebook);
+ _popoverbin.setPopover(&_menutabs);
+ set_child(_popoverbin);
_instances.push_back(this);
}
@@ -209,8 +208,6 @@ DialogNotebook::~DialogNotebook()
}
_instances.remove(this);
-
- _menutabs.unparent();
}
void DialogNotebook::add_highlight_header()
@@ -589,7 +586,7 @@ void DialogNotebook::on_size_allocate_scroll(int const width)
// magic number
static constexpr int MIN_HEIGHT = 60;
// set or unset scrollbars to completely hide a notebook
- // because we have a "blocking" scroll per tab we need to loop to aboid
+ // because we have a "blocking" scroll per tab we need to loop to avoid
// other page stop out scroll
for_each_page(_notebook, [this](Gtk::Widget &page){
if (!provide_scroll(page)) {
@@ -772,7 +769,7 @@ void DialogNotebook::reload_tab_menu()
_connmenu.clear();
- _menutabs.delete_all();
+ _menutabs.remove_all();
auto prefs = Inkscape::Preferences::get();
bool symbolic = false;
diff --git a/src/ui/dialog/dialog-notebook.h b/src/ui/dialog/dialog-notebook.h
index 8ab3d0a8aa64ca8c91dec1a08367beec446f02d0..54881b73bf851e9c4591386a68d3737cae24fad4 100644
--- a/src/ui/dialog/dialog-notebook.h
+++ b/src/ui/dialog/dialog-notebook.h
@@ -25,6 +25,7 @@
#include "helper/auto-connection.h"
#include "ui/widget/popover-menu.h"
+#include "ui/widget/popover-bin.h"
namespace Glib {
class ValueBase;
@@ -85,6 +86,7 @@ private:
UI::Widget::PopoverMenu _menu;
UI::Widget::PopoverMenu _menutabs;
Gtk::Notebook _notebook;
+ UI::Widget::PopoverBin _popoverbin;
// State variables
bool _label_visible;
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index c4a4a770803fa95f2325024cd44562942b36c69b..44cb877a0b96137857b28486d8ebd31f5858ab60 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -34,7 +34,7 @@
#include
#include
#include
-#include
+
#include
#include
#include
@@ -143,7 +143,7 @@ static void docprops_style_button(Gtk::Button& btn, char const* iconName)
}
static bool do_remove_popup_menu(PopupMenuOptionalClick const click,
- Gtk::TreeView &tree_view, sigc::slot const &slot)
+ Gtk::TreeView &tree_view, UI::Widget::PopoverBin &pb, sigc::slot const &slot)
{
auto const selection = tree_view.get_selection();
if (!selection) return false;
@@ -153,9 +153,10 @@ static bool do_remove_popup_menu(PopupMenuOptionalClick const click,
auto const mi = Gtk::make_managed(_("_Remove"), true);
mi->signal_activate().connect(slot);
- auto const menu = std::make_shared(tree_view, Gtk::PositionType::BOTTOM);
+ auto const menu = Gtk::make_managed(Gtk::PositionType::BOTTOM);
menu->append(*mi);
- UI::on_hide_reset(menu);
+
+ pb.setPopover(menu);
if (click) {
menu->popup_at(tree_view, click->x, click->y);
@@ -171,10 +172,9 @@ static bool do_remove_popup_menu(PopupMenuOptionalClick const click,
return true;
}
-static void connect_remove_popup_menu(Gtk::TreeView &tree_view, sigc::slot slot)
+static void connect_remove_popup_menu(Gtk::TreeView &tree_view, UI::Widget::PopoverBin &pb, sigc::slot slot)
{
- UI::on_popup_menu(tree_view, sigc::bind(&do_remove_popup_menu,
- std::ref(tree_view), std::move(slot)));
+ UI::on_popup_menu(tree_view, sigc::bind(&do_remove_popup_menu, std::ref(tree_view), std::ref(pb), std::move(slot)));
}
DocumentProperties::DocumentProperties()
@@ -206,7 +206,8 @@ DocumentProperties::DocumentProperties()
, _namedview_connection(this)
, _root_connection(this)
{
- UI::pack_start(*this, _notebook, true, true);
+ append(_popoverbin);
+ _popoverbin.setChild(&_notebook);
_notebook.append_page(*_page_page, _("Display"));
_notebook.append_page(*_page_guides, _("Guides"));
@@ -878,7 +879,7 @@ void DocumentProperties::build_cms()
_LinkedProfilesList.get_selection()->signal_changed().connect( sigc::mem_fun(*this, &DocumentProperties::onColorProfileSelectRow) );
- connect_remove_popup_menu(_LinkedProfilesList, sigc::mem_fun(*this, &DocumentProperties::removeSelectedProfile));
+ connect_remove_popup_menu(_LinkedProfilesList, _popoverbin, sigc::mem_fun(*this, &DocumentProperties::removeSelectedProfile));
if (auto document = getDocument()) {
std::vector current = document->getResourceList( "defs" );
@@ -1049,8 +1050,8 @@ void DocumentProperties::build_scripting()
_external_remove_btn.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::removeExternalScript));
_embed_remove_btn.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::removeEmbeddedScript));
- connect_remove_popup_menu(_ExternalScriptsList, sigc::mem_fun(*this, &DocumentProperties::removeExternalScript));
- connect_remove_popup_menu(_EmbeddedScriptsList, sigc::mem_fun(*this, &DocumentProperties::removeEmbeddedScript));
+ connect_remove_popup_menu(_ExternalScriptsList, _popoverbin, sigc::mem_fun(*this, &DocumentProperties::removeExternalScript));
+ connect_remove_popup_menu(_EmbeddedScriptsList, _popoverbin, sigc::mem_fun(*this, &DocumentProperties::removeEmbeddedScript));
//TODO: review this observers code:
if (auto document = getDocument()) {
diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h
index cccecb382a3fd6027ccf214b43217f012a26077a..e947572ed186265244ecfe4880a051fd104943de 100644
--- a/src/ui/dialog/document-properties.h
+++ b/src/ui/dialog/document-properties.h
@@ -42,6 +42,7 @@
#include "object/sp-grid.h"
#include "ui/dialog/dialog-base.h"
+#include "ui/widget/popover-bin.h"
#include "ui/widget/licensor.h"
#include "ui/widget/registered-widget.h"
#include "ui/widget/registry.h"
@@ -129,7 +130,8 @@ protected:
void set_viewbox_size(SPDesktop* desktop, double width, double height);
Inkscape::XML::SignalObserver _emb_profiles_observer, _scripts_observer;
- Gtk::Notebook _notebook;
+ UI::Widget::PopoverBin _popoverbin;
+ Gtk::Notebook _notebook;
UI::Widget::NotebookPage *_page_page;
UI::Widget::NotebookPage *_page_guides;
diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp
index 021a37cb770f4d47e6524081b4dcd7857e41ebbb..0129b5c5f5250a2b7948828bdd7417d3e3912978 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -17,7 +17,6 @@
#include "filter-effects-dialog.h"
-#include
#include