diff options
| author | Alexander Valavanis <valavanisalex@gmail.com> | 2019-02-02 20:16:00 +0000 |
|---|---|---|
| committer | Alexander Valavanis <valavanisalex@gmail.com> | 2019-02-02 20:16:00 +0000 |
| commit | fa98857205dbaf2c15bb302e3eb28f4738fb6415 (patch) | |
| tree | 5c91217ada74209becdf97006f271b749e51d032 /src/widgets/desktop-widget.cpp | |
| parent | object properties dialog: label placeholder (diff) | |
| download | inkscape-fa98857205dbaf2c15bb302e3eb28f4738fb6415.tar.gz inkscape-fa98857205dbaf2c15bb302e3eb28f4738fb6415.zip | |
TweakToolbar: GtkAction migration
Diffstat (limited to 'src/widgets/desktop-widget.cpp')
| -rw-r--r-- | src/widgets/desktop-widget.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index f629c89f7..489582ca8 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -64,6 +64,7 @@ #include "ui/widget/ink-select-one-action.h" #include "ui/widget/layer-selector.h" #include "ui/widget/selected-style.h" +#include "ui/widget/spin-button-tool-item.h" #include "ui/widget/unit-tracker.h" // TEMP @@ -1535,19 +1536,22 @@ SPDesktopWidget::setToolboxFocusTo (const gchar* label) void SPDesktopWidget::setToolboxAdjustmentValue (gchar const *id, double value) { - GtkAdjustment *a = nullptr; - gpointer hb = sp_search_by_data_recursive (aux_toolbox, (gpointer) id); - if (hb && GTK_IS_WIDGET(hb)) { - if (GTK_IS_SPIN_BUTTON(hb)) - a = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(hb)); - else if (GTK_IS_RANGE(hb)) - a = gtk_range_get_adjustment (GTK_RANGE(hb)); + // First try looking for a named widget + auto hb = sp_search_by_name_recursive(Glib::wrap(aux_toolbox), id); + + // Fallback to looking for a named data member (deprecated) + if (!hb) { + hb = Glib::wrap(GTK_WIDGET(sp_search_by_data_recursive(aux_toolbox, (gpointer)id))); } - if (a) - gtk_adjustment_set_value (a, value); - else - g_warning ("Could not find GtkAdjustment for %s\n", id); + if (hb) { + auto sb = dynamic_cast<Inkscape::UI::Widget::SpinButtonToolItem *>(hb); + auto a = sb->get_adjustment(); + + if(a) a->set_value(value); + } + + else g_warning ("Could not find GtkAdjustment for %s\n", id); } void |
