diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-18 21:06:08 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-19 09:53:55 +0200 |
commit | cc7cb945846e5b476de917bb90976a4fca175ad1 (patch) | |
tree | d50e5a6bb05f1f4dfa0c4b85360ea21e13cd8452 /vcl | |
parent | 8c9c1b852ce0ebc6bd19437e9e583ef4226cf685 (diff) |
weld CompressGraphicsDialog
Change-Id: I593e6f0fe2e002c75ecd367a38dda96e7e6552f9
Reviewed-on: https://gerrit.libreoffice.org/53125
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 42 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 58 |
2 files changed, 100 insertions, 0 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 159fd97a4d2e..fcfcdd90618c 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -36,6 +36,7 @@ #include <vcl/dialog.hxx> #include <vcl/layout.hxx> #include <vcl/menubtn.hxx> +#include <vcl/slider.hxx> #include <vcl/tabctrl.hxx> #include <vcl/tabpage.hxx> #include <vcl/unowrap.hxx> @@ -994,6 +995,41 @@ IMPL_LINK_NOARG(SalInstanceCheckButton, ToggleHdl, CheckBox&, void) signal_toggled(); } +class SalInstanceScale : public SalInstanceWidget, public virtual weld::Scale +{ +private: + VclPtr<Slider> m_xScale; + + DECL_LINK(SlideHdl, Slider*, void); +public: + SalInstanceScale(Slider* pScale, bool bTakeOwnership) + : SalInstanceWidget(pScale, bTakeOwnership) + , m_xScale(pScale) + { + m_xScale->SetSlideHdl(LINK(this, SalInstanceScale, SlideHdl)); + } + + virtual void set_value(int value) override + { + m_xScale->SetThumbPos(value); + } + + virtual int get_value() const override + { + return m_xScale->GetThumbPos(); + } + + virtual ~SalInstanceScale() override + { + m_xScale->SetSlideHdl(Link<Slider*, void>()); + } +}; + +IMPL_LINK_NOARG(SalInstanceScale, SlideHdl, Slider*, void) +{ + signal_value_changed(); +} + class SalInstanceEntry : public SalInstanceWidget, public virtual weld::Entry { private: @@ -1926,6 +1962,12 @@ public: return pCheckButton ? new SalInstanceCheckButton(pCheckButton, bTakeOwnership) : nullptr; } + virtual weld::Scale* weld_scale(const OString &id, bool bTakeOwnership) override + { + Slider* pSlider = m_xBuilder->get<Slider>(id); + return pSlider ? new SalInstanceScale(pSlider, bTakeOwnership) : nullptr; + } + virtual weld::Entry* weld_entry(const OString &id, bool bTakeOwnership) override { Edit* pEntry = m_xBuilder->get<Edit>(id); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 14e8af024d01..20f94158612e 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -2629,6 +2629,55 @@ public: } }; +class GtkInstanceScale : public GtkInstanceWidget, public virtual weld::Scale +{ +private: + GtkScale* m_pScale; + gulong m_nValueChangedSignalId; + + static void signalValueChanged(GtkScale*, gpointer widget) + { + GtkInstanceScale* pThis = static_cast<GtkInstanceScale*>(widget); + SolarMutexGuard aGuard; + pThis->signal_value_changed(); + } + +public: + GtkInstanceScale(GtkScale* pScale, bool bTakeOwnership) + : GtkInstanceWidget(GTK_WIDGET(pScale), bTakeOwnership) + , m_pScale(pScale) + , m_nValueChangedSignalId(g_signal_connect(m_pScale, "value-changed", G_CALLBACK(signalValueChanged), this)) + { + } + + virtual void disable_notify_events() override + { + g_signal_handler_block(m_pScale, m_nValueChangedSignalId); + GtkInstanceWidget::disable_notify_events(); + } + + virtual void enable_notify_events() override + { + GtkInstanceWidget::enable_notify_events(); + g_signal_handler_unblock(m_pScale, m_nValueChangedSignalId); + } + + virtual void set_value(int value) override + { + gtk_range_set_value(GTK_RANGE(m_pScale), value); + } + + virtual int get_value() const override + { + return gtk_range_get_value(GTK_RANGE(m_pScale)); + } + + virtual ~GtkInstanceScale() override + { + g_signal_handler_disconnect(m_pScale, m_nValueChangedSignalId); + } +}; + class GtkInstanceEntry : public GtkInstanceWidget, public virtual weld::Entry { private: @@ -4365,6 +4414,15 @@ public: return new GtkInstanceCheckButton(pCheckButton, bTakeOwnership); } + virtual weld::Scale* weld_scale(const OString &id, bool bTakeOwnership) override + { + GtkScale* pScale = GTK_SCALE(gtk_builder_get_object(m_pBuilder, id.getStr())); + if (!pScale) + return nullptr; + auto_add_parentless_widgets_to_container(GTK_WIDGET(pScale)); + return new GtkInstanceScale(pScale, bTakeOwnership); + } + virtual weld::Entry* weld_entry(const OString &id, bool bTakeOwnership) override { GtkEntry* pEntry = GTK_ENTRY(gtk_builder_get_object(m_pBuilder, id.getStr())); |