diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-09-14 15:07:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-09-17 15:11:47 +0200 |
commit | 76c7cabc42a239dbaf9e72122d36fb213e5a3555 (patch) | |
tree | 94eac2ae99855b7410168ad4f7be9ea9a8a02d60 /vcl | |
parent | 60a23d5d5f0963cd9bea7711ff4336418e3d6392 (diff) |
rename to weld::ComboBox are they are not text only now
Change-Id: Ice26d1fd2ad97a6959c6916fef428777efea9c2d
Reviewed-on: https://gerrit.libreoffice.org/60500
Tested-by: Jenkins
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 | 116 | ||||
-rw-r--r-- | vcl/unx/generic/print/prtsetup.cxx | 18 | ||||
-rw-r--r-- | vcl/unx/generic/print/prtsetup.hxx | 18 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 112 |
4 files changed, 132 insertions, 132 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index c3286ff365fb..0b6fb19bed87 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -2094,21 +2094,21 @@ IMPL_LINK(SalInstanceDrawingArea, QueryTooltipHdl, tools::Rectangle&, rHelpArea, //ComboBox and ListBox have similar apis, ComboBoxes in LibreOffice have an edit box and ListBoxes //don't. This distinction isn't there in Gtk. Use a template to sort this problem out. template <class vcl_type> -class SalInstanceComboBoxText : public SalInstanceContainer, public virtual weld::ComboBoxText +class SalInstanceComboBox : public SalInstanceContainer, public virtual weld::ComboBox { protected: - VclPtr<vcl_type> m_xComboBoxText; + VclPtr<vcl_type> m_xComboBox; public: - SalInstanceComboBoxText(vcl_type* pComboBoxText, bool bTakeOwnership) - : SalInstanceContainer(pComboBoxText, bTakeOwnership) - , m_xComboBoxText(pComboBoxText) + SalInstanceComboBox(vcl_type* pComboBox, bool bTakeOwnership) + : SalInstanceContainer(pComboBox, bTakeOwnership) + , m_xComboBox(pComboBox) { } virtual int get_active() const override { - const sal_Int32 nRet = m_xComboBoxText->GetSelectedEntryPos(); + const sal_Int32 nRet = m_xComboBox->GetSelectedEntryPos(); if (nRet == LISTBOX_ENTRY_NOTFOUND) return -1; return nRet; @@ -2116,12 +2116,12 @@ public: const OUString* getEntryData(int index) const { - return static_cast<const OUString*>(m_xComboBoxText->GetEntryData(index)); + return static_cast<const OUString*>(m_xComboBox->GetEntryData(index)); } virtual OUString get_active_id() const override { - const OUString* pRet = getEntryData(m_xComboBoxText->GetSelectedEntryPos()); + const OUString* pRet = getEntryData(m_xComboBox->GetSelectedEntryPos()); if (!pRet) return OUString(); return *pRet; @@ -2135,7 +2135,7 @@ public: if (!pId) continue; if (*pId == rStr) - m_xComboBoxText->SelectEntryPos(i); + m_xComboBox->SelectEntryPos(i); } } @@ -2143,15 +2143,15 @@ public: { if (pos == -1) { - m_xComboBoxText->SetNoSelection(); + m_xComboBox->SetNoSelection(); return; } - m_xComboBoxText->SelectEntryPos(pos); + m_xComboBox->SelectEntryPos(pos); } virtual OUString get_text(int pos) const override { - return m_xComboBoxText->GetEntry(pos); + return m_xComboBox->GetEntry(pos); } virtual OUString get_id(int pos) const override @@ -2164,17 +2164,17 @@ public: virtual void insert_text(int pos, const OUString& rStr) override { - m_xComboBoxText->InsertEntry(rStr, pos == -1 ? COMBOBOX_APPEND : pos); + m_xComboBox->InsertEntry(rStr, pos == -1 ? COMBOBOX_APPEND : pos); } virtual int get_count() const override { - return m_xComboBoxText->GetEntryCount(); + return m_xComboBox->GetEntryCount(); } virtual int find_text(const OUString& rStr) const override { - const sal_Int32 nRet = m_xComboBoxText->GetEntryPos(rStr); + const sal_Int32 nRet = m_xComboBox->GetEntryPos(rStr); if (nRet == LISTBOX_ENTRY_NOTFOUND) return -1; return nRet; @@ -2200,40 +2200,40 @@ public: const OUString* pId = getEntryData(i); delete pId; } - return m_xComboBoxText->Clear(); + return m_xComboBox->Clear(); } virtual void make_sorted() override { - m_xComboBoxText->SetStyle(m_xComboBoxText->GetStyle() | WB_SORT); + m_xComboBox->SetStyle(m_xComboBox->GetStyle() | WB_SORT); } - virtual ~SalInstanceComboBoxText() override + virtual ~SalInstanceComboBox() override { clear(); } }; -class SalInstanceComboBoxTextWithoutEdit : public SalInstanceComboBoxText<ListBox> +class SalInstanceComboBoxWithoutEdit : public SalInstanceComboBox<ListBox> { private: DECL_LINK(SelectHdl, ListBox&, void); public: - SalInstanceComboBoxTextWithoutEdit(ListBox* pListBox, bool bTakeOwnership) - : SalInstanceComboBoxText<ListBox>(pListBox, bTakeOwnership) + SalInstanceComboBoxWithoutEdit(ListBox* pListBox, bool bTakeOwnership) + : SalInstanceComboBox<ListBox>(pListBox, bTakeOwnership) { - m_xComboBoxText->SetSelectHdl(LINK(this, SalInstanceComboBoxTextWithoutEdit, SelectHdl)); + m_xComboBox->SetSelectHdl(LINK(this, SalInstanceComboBoxWithoutEdit, SelectHdl)); } virtual OUString get_active_text() const override { - return m_xComboBoxText->GetSelectedEntry(); + return m_xComboBox->GetSelectedEntry(); } virtual void remove(int pos) override { - m_xComboBoxText->RemoveEntry(pos); + m_xComboBox->RemoveEntry(pos); } virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString* pImage) override @@ -2241,10 +2241,10 @@ public: auto nInsertPos = pos == -1 ? COMBOBOX_APPEND : pos; sal_Int32 nInsertedAt; if (!pImage) - nInsertedAt = m_xComboBoxText->InsertEntry(rStr, nInsertPos); + nInsertedAt = m_xComboBox->InsertEntry(rStr, nInsertPos); else - nInsertedAt = m_xComboBoxText->InsertEntry(rStr, createImage(*pImage), nInsertPos); - m_xComboBoxText->SetEntryData(nInsertedAt, new OUString(rId)); + nInsertedAt = m_xComboBox->InsertEntry(rStr, createImage(*pImage), nInsertPos); + m_xComboBox->SetEntryData(nInsertedAt, new OUString(rId)); } virtual bool has_entry() const override @@ -2283,28 +2283,28 @@ public: assert(false); } - virtual ~SalInstanceComboBoxTextWithoutEdit() override + virtual ~SalInstanceComboBoxWithoutEdit() override { - m_xComboBoxText->SetSelectHdl(Link<ListBox&, void>()); + m_xComboBox->SetSelectHdl(Link<ListBox&, void>()); } }; -IMPL_LINK_NOARG(SalInstanceComboBoxTextWithoutEdit, SelectHdl, ListBox&, void) +IMPL_LINK_NOARG(SalInstanceComboBoxWithoutEdit, SelectHdl, ListBox&, void) { return signal_changed(); } -class SalInstanceComboBoxTextWithEdit : public SalInstanceComboBoxText<ComboBox> +class SalInstanceComboBoxWithEdit : public SalInstanceComboBox<ComboBox> { private: DECL_LINK(ChangeHdl, Edit&, void); DECL_LINK(EntryActivateHdl, Edit&, void); public: - SalInstanceComboBoxTextWithEdit(ComboBox* pComboBoxText, bool bTakeOwnership) - : SalInstanceComboBoxText<ComboBox>(pComboBoxText, bTakeOwnership) + SalInstanceComboBoxWithEdit(::ComboBox* pComboBox, bool bTakeOwnership) + : SalInstanceComboBox<::ComboBox>(pComboBox, bTakeOwnership) { - m_xComboBoxText->SetModifyHdl(LINK(this, SalInstanceComboBoxTextWithEdit, ChangeHdl)); - m_xComboBoxText->SetEntryActivateHdl(LINK(this, SalInstanceComboBoxTextWithEdit, EntryActivateHdl)); + m_xComboBox->SetModifyHdl(LINK(this, SalInstanceComboBoxWithEdit, ChangeHdl)); + m_xComboBox->SetEntryActivateHdl(LINK(this, SalInstanceComboBoxWithEdit, EntryActivateHdl)); } virtual bool has_entry() const override @@ -2315,19 +2315,19 @@ public: virtual void set_entry_error(bool bError) override { if (bError) - m_xComboBoxText->SetControlForeground(Color(0xf0, 0, 0)); + m_xComboBox->SetControlForeground(Color(0xf0, 0, 0)); else - m_xComboBoxText->SetControlForeground(); + m_xComboBox->SetControlForeground(); } virtual OUString get_active_text() const override { - return m_xComboBoxText->GetText(); + return m_xComboBox->GetText(); } virtual void remove(int pos) override { - m_xComboBoxText->RemoveEntryAt(pos); + m_xComboBox->RemoveEntryAt(pos); } virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString* pImage) override @@ -2335,53 +2335,53 @@ public: auto nInsertPos = pos == -1 ? COMBOBOX_APPEND : pos; sal_Int32 nInsertedAt; if (!pImage) - nInsertedAt = m_xComboBoxText->InsertEntry(rStr, nInsertPos); + nInsertedAt = m_xComboBox->InsertEntry(rStr, nInsertPos); else - nInsertedAt = m_xComboBoxText->InsertEntryWithImage(rStr, createImage(*pImage), nInsertPos); - m_xComboBoxText->SetEntryData(nInsertedAt, new OUString(rId)); + nInsertedAt = m_xComboBox->InsertEntryWithImage(rStr, createImage(*pImage), nInsertPos); + m_xComboBox->SetEntryData(nInsertedAt, new OUString(rId)); } virtual void set_entry_text(const OUString& rText) override { - m_xComboBoxText->SetText(rText); + m_xComboBox->SetText(rText); } virtual void set_entry_width_chars(int nChars) override { - m_xComboBoxText->SetWidthInChars(nChars); + m_xComboBox->SetWidthInChars(nChars); } virtual void set_entry_completion(bool bEnable) override { - m_xComboBoxText->EnableAutocomplete(bEnable); + m_xComboBox->EnableAutocomplete(bEnable); } virtual void select_entry_region(int nStartPos, int nEndPos) override { - m_xComboBoxText->SetSelection(Selection(nStartPos, nEndPos < 0 ? SELECTION_MAX : nEndPos)); + m_xComboBox->SetSelection(Selection(nStartPos, nEndPos < 0 ? SELECTION_MAX : nEndPos)); } virtual bool get_entry_selection_bounds(int& rStartPos, int& rEndPos) override { - const Selection& rSelection = m_xComboBoxText->GetSelection(); + const Selection& rSelection = m_xComboBox->GetSelection(); rStartPos = rSelection.Min(); rEndPos = rSelection.Max(); return rSelection.Len(); } - virtual ~SalInstanceComboBoxTextWithEdit() override + virtual ~SalInstanceComboBoxWithEdit() override { - m_xComboBoxText->SetEntryActivateHdl(Link<Edit&, void>()); - m_xComboBoxText->SetModifyHdl(Link<Edit&, void>()); + m_xComboBox->SetEntryActivateHdl(Link<Edit&, void>()); + m_xComboBox->SetModifyHdl(Link<Edit&, void>()); } }; -IMPL_LINK_NOARG(SalInstanceComboBoxTextWithEdit, ChangeHdl, Edit&, void) +IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit, ChangeHdl, Edit&, void) { signal_changed(); } -IMPL_LINK_NOARG(SalInstanceComboBoxTextWithEdit, EntryActivateHdl, Edit&, void) +IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit, EntryActivateHdl, Edit&, void) { m_aEntryActivateHdl.Call(*this); } @@ -2617,14 +2617,14 @@ public: return pRet; } - virtual std::unique_ptr<weld::ComboBoxText> weld_combo_box_text(const OString &id, bool bTakeOwnership) override + virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OString &id, bool bTakeOwnership) override { - vcl::Window* pComboBoxText = m_xBuilder->get<vcl::Window>(id); - ComboBox* pComboBox = dynamic_cast<ComboBox*>(pComboBoxText); + vcl::Window* pWidget = m_xBuilder->get<vcl::Window>(id); + ::ComboBox* pComboBox = dynamic_cast<::ComboBox*>(pWidget); if (pComboBox) - return o3tl::make_unique<SalInstanceComboBoxTextWithEdit>(pComboBox, bTakeOwnership); - ListBox* pListBox = dynamic_cast<ListBox*>(pComboBoxText); - return pListBox ? o3tl::make_unique<SalInstanceComboBoxTextWithoutEdit>(pListBox, bTakeOwnership) : nullptr; + return o3tl::make_unique<SalInstanceComboBoxWithEdit>(pComboBox, bTakeOwnership); + ListBox* pListBox = dynamic_cast<ListBox*>(pWidget); + return pListBox ? o3tl::make_unique<SalInstanceComboBoxWithoutEdit>(pListBox, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::EntryTreeView> weld_entry_tree_view(const OString& containerid, const OString& entryid, const OString& treeviewid, bool bTakeOwnership) override diff --git a/vcl/unx/generic/print/prtsetup.cxx b/vcl/unx/generic/print/prtsetup.cxx index 36d397c03fd7..2a75f3051768 100644 --- a/vcl/unx/generic/print/prtsetup.cxx +++ b/vcl/unx/generic/print/prtsetup.cxx @@ -27,7 +27,7 @@ using namespace psp; -void RTSDialog::insertAllPPDValues(weld::ComboBoxText& rBox, const PPDParser* pParser, const PPDKey* pKey ) +void RTSDialog::insertAllPPDValues(weld::ComboBox& rBox, const PPDParser* pParser, const PPDKey* pKey ) { if( ! pKey || ! pParser ) return; @@ -139,13 +139,13 @@ RTSPaperPage::RTSPaperPage(weld::Widget* pPage, RTSDialog* pDialog) , m_xContainer(m_xBuilder->weld_widget("PrinterPaperPage")) , m_xCbFromSetup(m_xBuilder->weld_check_button("papersizefromsetup")) , m_xPaperText(m_xBuilder->weld_label("paperft")) - , m_xPaperBox(m_xBuilder->weld_combo_box_text("paperlb")) + , m_xPaperBox(m_xBuilder->weld_combo_box("paperlb")) , m_xOrientText(m_xBuilder->weld_label("orientft")) - , m_xOrientBox(m_xBuilder->weld_combo_box_text("orientlb")) + , m_xOrientBox(m_xBuilder->weld_combo_box("orientlb")) , m_xDuplexText(m_xBuilder->weld_label("duplexft")) - , m_xDuplexBox(m_xBuilder->weld_combo_box_text("duplexlb")) + , m_xDuplexBox(m_xBuilder->weld_combo_box("duplexlb")) , m_xSlotText(m_xBuilder->weld_label("slotft")) - , m_xSlotBox(m_xBuilder->weld_combo_box_text("slotlb")) + , m_xSlotBox(m_xBuilder->weld_combo_box("slotlb")) { //PrinterPaperPage m_xPaperBox->connect_changed( LINK( this, RTSPaperPage, SelectHdl ) ); @@ -230,7 +230,7 @@ void RTSPaperPage::update() } } -IMPL_LINK( RTSPaperPage, SelectHdl, weld::ComboBoxText&, rBox, void ) +IMPL_LINK( RTSPaperPage, SelectHdl, weld::ComboBox&, rBox, void ) { const PPDKey* pKey = nullptr; if( &rBox == m_xPaperBox.get() ) @@ -284,9 +284,9 @@ RTSDevicePage::RTSDevicePage(weld::Widget* pPage, RTSDialog* pParent) , m_xPPDKeyBox(m_xBuilder->weld_tree_view("options")) , m_xPPDValueBox(m_xBuilder->weld_tree_view("values")) , m_xCustomEdit(m_xBuilder->weld_entry("custom")) - , m_xLevelBox(m_xBuilder->weld_combo_box_text("level")) - , m_xSpaceBox(m_xBuilder->weld_combo_box_text("colorspace")) - , m_xDepthBox(m_xBuilder->weld_combo_box_text("colordepth")) + , m_xLevelBox(m_xBuilder->weld_combo_box("level")) + , m_xSpaceBox(m_xBuilder->weld_combo_box("colorspace")) + , m_xDepthBox(m_xBuilder->weld_combo_box("colordepth")) { m_aReselectCustomIdle.SetInvokeHandler(LINK(this, RTSDevicePage, ImplHandleReselectHdl)); m_aReselectCustomIdle.SetDebugName("RTSDevicePage m_aReselectCustomIdle"); diff --git a/vcl/unx/generic/print/prtsetup.hxx b/vcl/unx/generic/print/prtsetup.hxx index 0685f80aa2b9..67eabe92a6a6 100644 --- a/vcl/unx/generic/print/prtsetup.hxx +++ b/vcl/unx/generic/print/prtsetup.hxx @@ -52,7 +52,7 @@ class RTSDialog : public weld::GenericDialogController DECL_LINK(ClickButton, weld::Button&, void ); // helper functions - void insertAllPPDValues(weld::ComboBoxText&, const psp::PPDParser*, const psp::PPDKey*); + void insertAllPPDValues(weld::ComboBox&, const psp::PPDParser*, const psp::PPDKey*); public: RTSDialog(const ::psp::PrinterInfo& rJobData, weld::Window* pParent); virtual ~RTSDialog() override; @@ -75,18 +75,18 @@ private: std::unique_ptr<weld::CheckButton> m_xCbFromSetup; std::unique_ptr<weld::Label> m_xPaperText; - std::unique_ptr<weld::ComboBoxText> m_xPaperBox; + std::unique_ptr<weld::ComboBox> m_xPaperBox; std::unique_ptr<weld::Label> m_xOrientText; - std::unique_ptr<weld::ComboBoxText> m_xOrientBox; + std::unique_ptr<weld::ComboBox> m_xOrientBox; std::unique_ptr<weld::Label> m_xDuplexText; - std::unique_ptr<weld::ComboBoxText> m_xDuplexBox; + std::unique_ptr<weld::ComboBox> m_xDuplexBox; std::unique_ptr<weld::Label> m_xSlotText; - std::unique_ptr<weld::ComboBoxText> m_xSlotBox; + std::unique_ptr<weld::ComboBox> m_xSlotBox; - DECL_LINK(SelectHdl, weld::ComboBoxText&, void); + DECL_LINK(SelectHdl, weld::ComboBox&, void); DECL_LINK(CheckBoxHdl, weld::ToggleButton&, void); public: RTSPaperPage(weld::Widget* pPage, RTSDialog* pDialog); @@ -110,9 +110,9 @@ private: std::unique_ptr<weld::TreeView> m_xPPDValueBox; std::unique_ptr<weld::Entry> m_xCustomEdit; - std::unique_ptr<weld::ComboBoxText> m_xLevelBox; - std::unique_ptr<weld::ComboBoxText> m_xSpaceBox; - std::unique_ptr<weld::ComboBoxText> m_xDepthBox; + std::unique_ptr<weld::ComboBox> m_xLevelBox; + std::unique_ptr<weld::ComboBox> m_xSpaceBox; + std::unique_ptr<weld::ComboBox> m_xDepthBox; void FillValueBox( const ::psp::PPDKey* ); void ValueBoxChanged( const ::psp::PPDKey* ); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 61c4337e4c0a..93f23b2b0e8e 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -4553,10 +4553,10 @@ namespace } } -class GtkInstanceComboBoxText : public GtkInstanceContainer, public virtual weld::ComboBoxText +class GtkInstanceComboBox : public GtkInstanceContainer, public virtual weld::ComboBox { private: - GtkComboBox* m_pComboBoxText; + GtkComboBox* m_pComboBox; std::unique_ptr<comphelper::string::NaturalStringSorter> m_xSorter; gboolean m_bPopupActive; gulong m_nChangedSignalId; @@ -4565,21 +4565,21 @@ private: static void signalChanged(GtkComboBox*, gpointer widget) { - GtkInstanceComboBoxText* pThis = static_cast<GtkInstanceComboBoxText*>(widget); + GtkInstanceComboBox* pThis = static_cast<GtkInstanceComboBox*>(widget); SolarMutexGuard aGuard; pThis->signal_changed(); } static void signalPopupShown(GtkComboBox*, GParamSpec*, gpointer widget) { - GtkInstanceComboBoxText* pThis = static_cast<GtkInstanceComboBoxText*>(widget); + GtkInstanceComboBox* pThis = static_cast<GtkInstanceComboBox*>(widget); pThis->signal_popup_shown(); } void signal_popup_shown() { gboolean bIsShown(false); - g_object_get(m_pComboBoxText, "popup-shown", &bIsShown, nullptr); + g_object_get(m_pComboBox, "popup-shown", &bIsShown, nullptr); if (m_bPopupActive != bIsShown) { m_bPopupActive = bIsShown; @@ -4591,7 +4591,7 @@ private: static void signalEntryActivate(GtkComboBox*, gpointer widget) { - GtkInstanceComboBoxText* pThis = static_cast<GtkInstanceComboBoxText*>(widget); + GtkInstanceComboBox* pThis = static_cast<GtkInstanceComboBox*>(widget); pThis->signal_entry_activate(); } @@ -4608,7 +4608,7 @@ private: OUString get(int pos, int col) const { OUString sRet; - GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBoxText); + GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBox); GtkTreeIter iter; if (gtk_tree_model_iter_nth_child(pModel, &iter, nullptr, pos)) { @@ -4622,7 +4622,7 @@ private: int find(const OUString& rStr, int col) const { - GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBoxText); + GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBox); GtkTreeIter iter; if (!gtk_tree_model_get_iter_first(pModel, &iter)) return -1; @@ -4645,7 +4645,7 @@ private: GtkEntry* get_entry() { - GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBoxText)); + GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBox)); if (!GTK_IS_ENTRY(pChild)) return nullptr; return GTK_ENTRY(pChild); @@ -4656,7 +4656,7 @@ private: if (gtk_entry_get_completion(pEntry)) return; GtkEntryCompletion* pCompletion = gtk_entry_completion_new(); - gtk_entry_completion_set_model(pCompletion, gtk_combo_box_get_model(m_pComboBoxText)); + gtk_entry_completion_set_model(pCompletion, gtk_combo_box_get_model(m_pComboBox)); gtk_entry_completion_set_text_column(pCompletion, 0); gtk_entry_completion_set_inline_selection(pCompletion, true); gtk_entry_completion_set_inline_completion(pCompletion, true); @@ -4666,26 +4666,26 @@ private: } public: - GtkInstanceComboBoxText(GtkComboBox* pComboBoxText, bool bTakeOwnership) - : GtkInstanceContainer(GTK_CONTAINER(pComboBoxText), bTakeOwnership) - , m_pComboBoxText(pComboBoxText) + GtkInstanceComboBox(GtkComboBox* pComboBox, bool bTakeOwnership) + : GtkInstanceContainer(GTK_CONTAINER(pComboBox), bTakeOwnership) + , m_pComboBox(pComboBox) , m_bPopupActive(false) - , m_nChangedSignalId(g_signal_connect(m_pComboBoxText, "changed", G_CALLBACK(signalChanged), this)) - , m_nPopupShownSignalId(g_signal_connect(m_pComboBoxText, "notify::popup-shown", G_CALLBACK(signalPopupShown), this)) + , m_nChangedSignalId(g_signal_connect(m_pComboBox, "changed", G_CALLBACK(signalChanged), this)) + , m_nPopupShownSignalId(g_signal_connect(m_pComboBox, "notify::popup-shown", G_CALLBACK(signalPopupShown), this)) { if (!has_entry()) { //Always use the same text column renderer layout GtkCellRenderer* text_renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_end(GTK_CELL_LAYOUT(m_pComboBoxText), text_renderer, true); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(m_pComboBoxText), text_renderer, "text", 0, nullptr); + gtk_cell_layout_pack_end(GTK_CELL_LAYOUT(m_pComboBox), text_renderer, true); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(m_pComboBox), text_renderer, "text", 0, nullptr); g_object_set(G_OBJECT(text_renderer), "ellipsize", PANGO_ELLIPSIZE_MIDDLE, nullptr); } else { // this bit isn't great, I really want to be able to ellipse the text in the comboboxtext itself and let // the popup menu render them in full, in the interim allow the text to wrap in both cases - GList* cells = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(m_pComboBoxText)); + GList* cells = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(m_pComboBox)); GtkCellRenderer* cell = static_cast<GtkCellRenderer*>(cells->data); g_object_set(G_OBJECT(cell), "ellipsize", PANGO_ELLIPSIZE_MIDDLE, nullptr); if (g_list_length(cells) == 2) @@ -4693,7 +4693,7 @@ public: //The ComboBox is always going to show the column associated with //the entry when there is one, left to its own devices this image //column will be after it, but we want it before - gtk_cell_layout_reorder(GTK_CELL_LAYOUT(m_pComboBoxText), cell, 1); + gtk_cell_layout_reorder(GTK_CELL_LAYOUT(m_pComboBox), cell, 1); } g_list_free(cells); } @@ -4709,12 +4709,12 @@ public: virtual int get_active() const override { - return gtk_combo_box_get_active(m_pComboBoxText); + return gtk_combo_box_get_active(m_pComboBox); } virtual OUString get_active_id() const override { - const gchar* pText = gtk_combo_box_get_active_id(m_pComboBoxText); + const gchar* pText = gtk_combo_box_get_active_id(m_pComboBox); return OUString(pText, pText ? strlen(pText) : 0, RTL_TEXTENCODING_UTF8); } @@ -4722,14 +4722,14 @@ public: { disable_notify_events(); OString aId(OUStringToOString(rStr, RTL_TEXTENCODING_UTF8)); - gtk_combo_box_set_active_id(m_pComboBoxText, aId.getStr()); + gtk_combo_box_set_active_id(m_pComboBox, aId.getStr()); enable_notify_events(); } virtual void set_size_request(int nWidth, int nHeight) override { // tweak the cell render to get a narrower size to stick - GList* cells = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(m_pComboBoxText)); + GList* cells = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(m_pComboBox)); GtkCellRenderer* cell = static_cast<GtkCellRenderer*>(cells->data); GtkRequisition size; gtk_cell_renderer_get_preferred_size(cell, m_pWidget, &size, nullptr); @@ -4742,25 +4742,25 @@ public: virtual void set_active(int pos) override { disable_notify_events(); - gtk_combo_box_set_active(m_pComboBoxText, pos); + gtk_combo_box_set_active(m_pComboBox, pos); enable_notify_events(); } virtual OUString get_active_text() const override { - if (gtk_combo_box_get_has_entry(m_pComboBoxText)) + if (gtk_combo_box_get_has_entry(m_pComboBox)) { - GtkWidget *pEntry = gtk_bin_get_child(GTK_BIN(m_pComboBoxText)); + GtkWidget *pEntry = gtk_bin_get_child(GTK_BIN(m_pComboBox)); const gchar* pText = gtk_entry_get_text(GTK_ENTRY(pEntry)); return OUString(pText, pText ? strlen(pText) : 0, RTL_TEXTENCODING_UTF8); } GtkTreeIter iter; - if (!gtk_combo_box_get_active_iter(m_pComboBoxText, &iter)) + if (!gtk_combo_box_get_active_iter(m_pComboBox, &iter)) return OUString(); - GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBoxText); - gint col = gtk_combo_box_get_entry_text_column(m_pComboBoxText); + GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBox); + gint col = gtk_combo_box_get_entry_text_column(m_pComboBox); gchar* pStr = nullptr; gtk_tree_model_get(pModel, &iter, col, &pStr, -1); OUString sRet(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8); @@ -4776,7 +4776,7 @@ public: virtual OUString get_id(int pos) const override { - gint id_column = gtk_combo_box_get_id_column(m_pComboBoxText); + gint id_column = gtk_combo_box_get_id_column(m_pComboBox); return get(pos, id_column); } @@ -4784,7 +4784,7 @@ public: { disable_notify_events(); GtkTreeIter iter; - GtkListStore* pListStore = GTK_LIST_STORE(gtk_combo_box_get_model(m_pComboBoxText)); + GtkListStore* pListStore = GTK_LIST_STORE(gtk_combo_box_get_model(m_pComboBox)); gtk_list_store_insert(pListStore, &iter, pos); gtk_list_store_set(pListStore, &iter, 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), -1); enable_notify_events(); @@ -4794,7 +4794,7 @@ public: { disable_notify_events(); GtkTreeIter iter; - GtkListStore* pListStore = GTK_LIST_STORE(gtk_combo_box_get_model(m_pComboBoxText)); + GtkListStore* pListStore = GTK_LIST_STORE(gtk_combo_box_get_model(m_pComboBox)); gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(pListStore), &iter, nullptr, pos); gtk_list_store_remove(pListStore, &iter); enable_notify_events(); @@ -4803,13 +4803,13 @@ public: virtual void insert(int pos, const OUString& rId, const OUString& rText, const OUString* pImage) override { disable_notify_events(); - insert_row(GTK_LIST_STORE(gtk_combo_box_get_model(m_pComboBoxText)), pos, rId, rText, pImage); + insert_row(GTK_LIST_STORE(gtk_combo_box_get_model(m_pComboBox)), pos, rId, rText, pImage); enable_notify_events(); } virtual int get_count() const override { - GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBoxText); + GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBox); return gtk_tree_model_iter_n_children(pModel, nullptr); } @@ -4826,7 +4826,7 @@ public: virtual void clear() override { disable_notify_events(); - GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBoxText); + GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBox); gtk_list_store_clear(GTK_LIST_STORE(pModel)); enable_notify_events(); } @@ -4836,7 +4836,7 @@ public: m_xSorter.reset(new comphelper::string::NaturalStringSorter( ::comphelper::getProcessComponentContext(), Application::GetSettings().GetUILanguageTag().getLocale())); - GtkTreeModel* pModel = gtk_combo_box_get_model(m_pComboBoxText); + GtkTreeModel* pModel = gtk_combo_box_get_model(m_pComboBox); GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(pModel); gtk_tree_sortable_set_sort_func(pSortable, 0, sort_func, m_xSorter.get(), nullptr); gtk_tree_sortable_set_sort_column_id(pSortable, 0, GTK_SORT_ASCENDING); @@ -4844,12 +4844,12 @@ public: virtual bool has_entry() const override { - return gtk_combo_box_get_has_entry(m_pComboBoxText); + return gtk_combo_box_get_has_entry(m_pComboBox); } virtual void set_entry_error(bool bError) override { - GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBoxText)); + GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBox)); assert(GTK_IS_ENTRY(pChild)); GtkEntry* pEntry = GTK_ENTRY(pChild); if (bError) @@ -4860,7 +4860,7 @@ public: virtual void set_entry_text(const OUString& rText) override { - GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBoxText)); + GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBox)); assert(pChild && GTK_IS_ENTRY(pChild)); GtkEntry* pEntry = GTK_ENTRY(pChild); disable_notify_events(); @@ -4870,7 +4870,7 @@ public: virtual void set_entry_width_chars(int nChars) override { - GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBoxText)); + GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBox)); assert(pChild && GTK_IS_ENTRY(pChild)); GtkEntry* pEntry = GTK_ENTRY(pChild); gtk_entry_set_width_chars(pEntry, nChars); @@ -4878,7 +4878,7 @@ public: virtual void select_entry_region(int nStartPos, int nEndPos) override { - GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBoxText)); + GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBox)); assert(pChild && GTK_IS_ENTRY(pChild)); GtkEntry* pEntry = GTK_ENTRY(pChild); disable_notify_events(); @@ -4888,7 +4888,7 @@ public: virtual bool get_entry_selection_bounds(int& rStartPos, int &rEndPos) override { - GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBoxText)); + GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pComboBox)); assert(pChild && GTK_IS_ENTRY(pChild)); GtkEntry* pEntry = GTK_ENTRY(pChild); return gtk_editable_get_selection_bounds(GTK_EDITABLE(pEntry), &rStartPos, &rEndPos); @@ -4908,16 +4908,16 @@ public: { if (GtkEntry* pEntry = get_entry()) g_signal_handler_block(pEntry, m_nEntryActivateSignalId); - g_signal_handler_block(m_pComboBoxText, m_nChangedSignalId); - g_signal_handler_block(m_pComboBoxText, m_nPopupShownSignalId); + g_signal_handler_block(m_pComboBox, m_nChangedSignalId); + g_signal_handler_block(m_pComboBox, m_nPopupShownSignalId); GtkInstanceContainer::disable_notify_events(); } virtual void enable_notify_events() override { GtkInstanceContainer::enable_notify_events(); - g_signal_handler_unblock(m_pComboBoxText, m_nPopupShownSignalId); - g_signal_handler_unblock(m_pComboBoxText, m_nChangedSignalId); + g_signal_handler_unblock(m_pComboBox, m_nPopupShownSignalId); + g_signal_handler_unblock(m_pComboBox, m_nChangedSignalId); if (GtkEntry* pEntry = get_entry()) g_signal_handler_unblock(pEntry, m_nEntryActivateSignalId); } @@ -4927,7 +4927,7 @@ public: GtkInstanceContainer::freeze(); if (m_xSorter) { - GtkTreeModel* pModel = gtk_combo_box_get_model(m_pComboBoxText); + GtkTreeModel* pModel = gtk_combo_box_get_model(m_pComboBox); GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(pModel); gtk_tree_sortable_set_sort_column_id(pSortable, GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, GTK_SORT_ASCENDING); } @@ -4937,19 +4937,19 @@ public: { if (m_xSorter) { - GtkTreeModel* pModel = gtk_combo_box_get_model(m_pComboBoxText); + GtkTreeModel* pModel = gtk_combo_box_get_model(m_pComboBox); GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(pModel); gtk_tree_sortable_set_sort_column_id(pSortable, 0, GTK_SORT_ASCENDING); } GtkInstanceContainer::thaw(); } - virtual ~GtkInstanceComboBoxText() override + virtual ~GtkInstanceComboBox() override { if (GtkEntry* pEntry = get_entry()) g_signal_handler_disconnect(pEntry, m_nEntryActivateSignalId); - g_signal_handler_disconnect(m_pComboBoxText, m_nChangedSignalId); - g_signal_handler_disconnect(m_pComboBoxText, m_nPopupShownSignalId); + g_signal_handler_disconnect(m_pComboBox, m_nChangedSignalId); + g_signal_handler_disconnect(m_pComboBox, m_nPopupShownSignalId); } }; @@ -5494,13 +5494,13 @@ public: return o3tl::make_unique<weld::TimeSpinButton>(weld_spin_button(id, bTakeOwnership), eFormat); } - virtual std::unique_ptr<weld::ComboBoxText> weld_combo_box_text(const OString &id, bool bTakeOwnership) override + virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OString &id, bool bTakeOwnership) override { - GtkComboBox* pComboBoxText = GTK_COMBO_BOX(gtk_builder_get_object(m_pBuilder, id.getStr())); - if (!pComboBoxText) + GtkComboBox* pComboBox = GTK_COMBO_BOX(gtk_builder_get_object(m_pBuilder, id.getStr())); + if (!pComboBox) return nullptr; - auto_add_parentless_widgets_to_container(GTK_WIDGET(pComboBoxText)); - return o3tl::make_unique<GtkInstanceComboBoxText>(pComboBoxText, bTakeOwnership); + auto_add_parentless_widgets_to_container(GTK_WIDGET(pComboBox)); + return o3tl::make_unique<GtkInstanceComboBox>(pComboBox, bTakeOwnership); } virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OString &id, bool bTakeOwnership) override |