cui/source/customize/cfg.cxx | 4 cui/source/dialogs/multipat.cxx | 4 cui/source/dialogs/pastedlg.cxx | 2 cui/uiconfig/ui/charnamepage.ui | 85 ++++++++++- include/svx/langbox.hxx | 1 include/vcl/weld.hxx | 23 +-- sc/source/ui/miscdlgs/mvtabdlg.cxx | 2 sd/source/ui/dlg/PhotoAlbumDialog.cxx | 8 - sd/source/ui/dlg/custsdlg.cxx | 2 sfx2/source/dialog/mgetempl.cxx | 2 svtools/source/control/ctrlbox.cxx | 4 svx/source/dialog/langbox.cxx | 17 ++ sw/source/ui/frmdlg/column.cxx | 2 sw/source/uibase/misc/numberingtypelistbox.cxx | 4 sw/source/uibase/utlui/uitool.cxx | 2 vcl/source/app/salvtables.cxx | 70 +++++---- vcl/unx/generic/print/prtsetup.cxx | 8 - vcl/unx/gtk3/gtk3gtkinst.cxx | 191 +++++++++++++++---------- 18 files changed, 298 insertions(+), 133 deletions(-)
New commits: commit 2419fa71d8b2223a50f596d5db7721f6213d4f87 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Sep 14 14:43:07 2018 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Sep 17 10:02:23 2018 +0200 add image support to weld::ComboBoxText Change-Id: Ie7f00ed4aef5318a525a526d0377bb7952bdd5a0 Reviewed-on: https://gerrit.libreoffice.org/60499 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index d9d2f8dc9468..facdf5e59e3c 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -1967,7 +1967,7 @@ IMPL_LINK_NOARG(SvxMainMenuOrganizerDialog, ModifyHdl, weld::Entry&, void) const int nNewMenuPos = m_xMenuListBox->find_id(m_sNewMenuEntryId); const int nOldSelection = m_xMenuListBox->get_selected_index(); m_xMenuListBox->remove(nNewMenuPos); - m_xMenuListBox->insert(nNewMenuPos, m_sNewMenuEntryId, pNewEntryData->GetName(), ""); + m_xMenuListBox->insert(nNewMenuPos, m_sNewMenuEntryId, pNewEntryData->GetName(), nullptr); m_xMenuListBox->select(nOldSelection); } @@ -2005,7 +2005,7 @@ IMPL_LINK( SvxMainMenuOrganizerDialog, MoveHdl, weld::Button&, rButton, void ) OUString sId = m_xMenuListBox->get_id(nSourceEntry); OUString sEntry = m_xMenuListBox->get_text(nSourceEntry); m_xMenuListBox->remove(nSourceEntry); - m_xMenuListBox->insert(nTargetEntry, sId, sEntry, ""); + m_xMenuListBox->insert(nTargetEntry, sId, sEntry, nullptr); m_xMenuListBox->select(nTargetEntry); UpdateButtonStates(); diff --git a/cui/source/dialogs/multipat.cxx b/cui/source/dialogs/multipat.cxx index a5f0734b85f2..a006d606ed6b 100644 --- a/cui/source/dialogs/multipat.cxx +++ b/cui/source/dialogs/multipat.cxx @@ -125,7 +125,7 @@ IMPL_LINK_NOARG(SvxPathSelectDialog, AddHdl_Impl, weld::Button&, void) } else { - m_xPathLB->append(aURL, sInsPath, ""); + m_xPathLB->append(aURL, sInsPath); } SelectHdl_Impl(*m_xPathLB); @@ -328,7 +328,7 @@ void SvxPathSelectDialog::SetPath(const OUString& rPath) bool bIsSystemPath = osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None; - m_xPathLB->append(sPath, bIsSystemPath ? sSystemPath : sPath, ""); + m_xPathLB->append(sPath, bIsSystemPath ? sSystemPath : sPath); } while (nIndex >= 0); } diff --git a/cui/source/dialogs/pastedlg.cxx b/cui/source/dialogs/pastedlg.cxx index d48235c5a3ac..7b70ed34fa0a 100644 --- a/cui/source/dialogs/pastedlg.cxx +++ b/cui/source/dialogs/pastedlg.cxx @@ -154,7 +154,7 @@ SotClipboardFormatId SvPasteObjectDialog::GetFormat( const TransferableDataHelpe if (ObjectLB().find_text(aName) == -1) { - ObjectLB().append(OUString::number(static_cast<sal_uInt32>(nFormat)), aName, ""); + ObjectLB().append(OUString::number(static_cast<sal_uInt32>(nFormat)), aName); } } } diff --git a/cui/uiconfig/ui/charnamepage.ui b/cui/uiconfig/ui/charnamepage.ui index fa44eab6f724..55ac94e0f44a 100644 --- a/cui/uiconfig/ui/charnamepage.ui +++ b/cui/uiconfig/ui/charnamepage.ui @@ -50,6 +50,46 @@ <property name="popup_set_width">False</property> <property name="popup_single_match">False</property> </object> + <object class="GtkListStore" id="liststore4"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + <!-- column-name image --> + <column type="GdkPixbuf"/> + </columns> + </object> + <object class="GtkListStore" id="liststore5"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + <!-- column-name image --> + <column type="GdkPixbuf"/> + </columns> + </object> + <object class="GtkListStore" id="liststore6"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + <!-- column-name image --> + <column type="GdkPixbuf"/> + </columns> + </object> + <object class="GtkListStore" id="liststore7"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + <!-- column-name image --> + <column type="GdkPixbuf"/> + </columns> + </object> <object class="GtkBox" id="CharNamePage"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -370,12 +410,21 @@ </packing> </child> <child> - <object class="GtkComboBoxText" id="westlanglb-nocjk"> + <object class="GtkComboBox" id="westlanglb-nocjk"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">start</property> <property name="hexpand">True</property> + <property name="model">liststore4</property> <property name="has_entry">True</property> + <property name="entry_text_column">0</property> + <property name="id_column">1</property> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext4"/> + <attributes> + <attribute name="pixbuf">2</attribute> + </attributes> + </child> <child internal-child="entry"> <object class="GtkEntry"> <property name="can_focus">True</property> @@ -550,10 +599,19 @@ </packing> </child> <child> - <object class="GtkComboBoxText" id="westlanglb-cjk"> + <object class="GtkComboBox" id="westlanglb-cjk"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="model">liststore5</property> <property name="has_entry">True</property> + <property name="entry_text_column">0</property> + <property name="id_column">1</property> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext5"/> + <attributes> + <attribute name="pixbuf">2</attribute> + </attributes> + </child> <child internal-child="entry"> <object class="GtkEntry"> <property name="can_focus">True</property> @@ -749,9 +807,19 @@ </packing> </child> <child> - <object class="GtkComboBoxText" id="eastlanglb"> + <object class="GtkComboBox" id="eastlanglb"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="model">liststore6</property> + <property name="has_entry">False</property> + <property name="entry_text_column">0</property> + <property name="id_column">1</property> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext6"/> + <attributes> + <attribute name="pixbuf">2</attribute> + </attributes> + </child> </object> <packing> <property name="left_attach">3</property> @@ -941,9 +1009,18 @@ </packing> </child> <child> - <object class="GtkComboBoxText" id="ctllanglb"> + <object class="GtkComboBox" id="ctllanglb"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="model">liststore7</property> + <property name="entry_text_column">0</property> + <property name="id_column">1</property> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext7"/> + <attributes> + <attribute name="pixbuf">2</attribute> + </attributes> + </child> </object> <packing> <property name="left_attach">3</property> diff --git a/include/svx/langbox.hxx b/include/svx/langbox.hxx index 723957c54e35..3ce7a3e43554 100644 --- a/include/svx/langbox.hxx +++ b/include/svx/langbox.hxx @@ -161,6 +161,7 @@ private: std::unique_ptr<weld::ComboBoxText> m_xControl; Link<weld::ComboBoxText&, void> m_aChangeHdl; OUString m_aAllString; + std::unique_ptr<css::uno::Sequence<sal_Int16>> m_xSpellUsedLang; LanguageType m_eSavedLanguage; EditedAndValid m_eEditedAndValid; bool m_bHasLangNone; diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index b74df5232c4f..b5fac32ca461 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -257,8 +257,13 @@ protected: public: virtual void insert_text(int pos, const OUString& rStr) = 0; void append_text(const OUString& rStr) { insert_text(-1, rStr); } - virtual void insert(int pos, const OUString& rId, const OUString& rStr) = 0; - void append(const OUString& rId, const OUString& rStr) { insert(-1, rId, rStr); } + virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString* pImage) + = 0; + void append(const OUString& rId, const OUString& rStr) { insert(-1, rId, rStr, nullptr); } + void append(const OUString& rId, const OUString& rStr, const OUString& rImage) + { + insert(-1, rId, rStr, &rImage); + } virtual int get_count() const = 0; virtual void make_sorted() = 0; @@ -315,12 +320,13 @@ protected: public: virtual void insert_text(const OUString& rText, int pos) = 0; - virtual void append_text(const OUString& rText) { insert_text(rText, -1); } - virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString& rImage) + virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString* pImage) = 0; - virtual void append(const OUString& rId, const OUString& rStr, const OUString& rImage) + void append_text(const OUString& rText) { insert_text(rText, -1); } + void append(const OUString& rId, const OUString& rStr) { insert(-1, rId, rStr, nullptr); } + void append(const OUString& rId, const OUString& rStr, const OUString& rImage) { - insert(-1, rId, rStr, rImage); + insert(-1, rId, rStr, &rImage); } virtual int n_children() const = 0; @@ -611,9 +617,10 @@ public: { m_xTreeView->insert_text(rStr, pos); } - virtual void insert(int pos, const OUString& rId, const OUString& rStr) override + virtual void insert(int pos, const OUString& rId, const OUString& rStr, + const OUString* pImage) override { - m_xTreeView->insert(pos, rId, rStr, OUString()); + m_xTreeView->insert(pos, rId, rStr, pImage); } virtual int get_count() const override { return m_xTreeView->n_children(); } diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx index 3c7b46ead276..8515f07121de 100644 --- a/sc/source/ui/miscdlgs/mvtabdlg.cxx +++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx @@ -220,7 +220,7 @@ void ScMoveTableDlg::InitDocListBox() aEntryName += msCurrentDoc; } - m_xLbDoc->insert(i, OUString::number(reinterpret_cast<sal_uInt64>(&pScSh->GetDocument())), aEntryName); + m_xLbDoc->insert(i, OUString::number(reinterpret_cast<sal_uInt64>(&pScSh->GetDocument())), aEntryName, nullptr); i++; } diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx index d43a54006a2f..4987c1a11bce 100644 --- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx +++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx @@ -550,8 +550,8 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, UpHdl, weld::Button&, void) m_xImagesLst->remove_text(sActEntry); m_xImagesLst->remove_text(sUpperEntry); - m_xImagesLst->insert(nActPos - 1, sAct, sActEntry, ""); - m_xImagesLst->insert(nActPos, sUpper, sUpperEntry, ""); + m_xImagesLst->insert(nActPos - 1, sAct, sActEntry, nullptr); + m_xImagesLst->insert(nActPos, sUpper, sUpperEntry, nullptr); m_xImagesLst->select(nActPos - 1); } @@ -573,8 +573,8 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, DownHdl, weld::Button&, void) m_xImagesLst->remove_text(sActEntry); m_xImagesLst->remove_text(sDownEntry); - m_xImagesLst->insert(nActPos, sDown, sDownEntry, ""); - m_xImagesLst->insert(nActPos + 1, sAct, sActEntry, ""); + m_xImagesLst->insert(nActPos, sDown, sDownEntry, nullptr); + m_xImagesLst->insert(nActPos + 1, sAct, sActEntry, nullptr); m_xImagesLst->select(nActPos + 1); } diff --git a/sd/source/ui/dlg/custsdlg.cxx b/sd/source/ui/dlg/custsdlg.cxx index 060f314c74a6..3dfc611bbbb2 100644 --- a/sd/source/ui/dlg/custsdlg.cxx +++ b/sd/source/ui/dlg/custsdlg.cxx @@ -378,7 +378,7 @@ void SdDefineCustomShowDlg::ClickButtonHdl2(void const * p) { OUString aStr = m_xLbPages->get_text(i); SdPage* pPage = rDoc.GetSdPage(i, PageKind::Standard); - m_xLbCustomPages->insert(nPosCP, OUString::number(reinterpret_cast<sal_uInt64>(pPage)), aStr, ""); + m_xLbCustomPages->insert(nPosCP, OUString::number(reinterpret_cast<sal_uInt64>(pPage)), aStr, nullptr); m_xLbCustomPages->select(nPosCP != -1 ? nPosCP : m_xLbCustomPages->n_children() - 1); if (nPosCP != -1) diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx index b878329bcf63..980f7dda4abc 100644 --- a/sfx2/source/dialog/mgetempl.cxx +++ b/sfx2/source/dialog/mgetempl.cxx @@ -200,7 +200,7 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(TabPageParent pParent, const Sf rTupel.nFlags != SfxStyleSearchBits::AllVisible && rTupel.nFlags != SfxStyleSearchBits::All ) { - m_xFilterLb->insert(nIdx, OUString::number(i), rTupel.aName); + m_xFilterLb->insert(nIdx, OUString::number(i), rTupel.aName, nullptr); if ( ( rTupel.nFlags & nMask ) == nMask ) nStyleFilterIdx = nIdx; ++nIdx; diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx index 530a9a6b95f4..75ac23aed95f 100644 --- a/svtools/source/control/ctrlbox.cxx +++ b/svtools/source/control/ctrlbox.cxx @@ -1840,7 +1840,7 @@ void SvtFontSizeBox::Fill( const FontMetric* pFontMetric, const FontList* pList OUString aSizeName = aFontSizeNames.GetIndexName( i ); sal_IntPtr nSize = aFontSizeNames.GetIndexSize( i ); OUString sId(OUString::number(-nSize)); // mark as special - m_xComboBox->insert(nPos, sId, aSizeName); + m_xComboBox->insert(nPos, sId, aSizeName, nullptr); nPos++; } } @@ -1854,7 +1854,7 @@ void SvtFontSizeBox::Fill( const FontMetric* pFontMetric, const FontList* pList if ( !aSizeName.isEmpty() ) { OUString sId(OUString::number(-(*pTempAry))); // mark as special - m_xComboBox->insert(nPos, sId, aSizeName); + m_xComboBox->insert(nPos, sId, aSizeName, nullptr); nPos++; } pTempAry++; diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx index bb4768c1292e..4c737d080569 100644 --- a/svx/source/dialog/langbox.cxx +++ b/svx/source/dialog/langbox.cxx @@ -735,7 +735,22 @@ void LanguageBox::InsertLanguage(const LanguageType nLangType) aStrEntry += SvtLanguageTable::GetLanguageString( nRealLang ); } - m_xControl->append(OUString::number(static_cast<sal_uInt16>(nLangType)), aStrEntry); + if (m_bWithCheckmark) + { + if (!m_xSpellUsedLang) + { + Reference<XSpellChecker1> xSpell(LinguMgr::GetSpellChecker(), UNO_QUERY); + if (xSpell.is()) + m_xSpellUsedLang.reset(new Sequence<sal_Int16>(xSpell->getLanguages())); + } + + bool bFound = m_xSpellUsedLang && lcl_SeqHasLang(*m_xSpellUsedLang, static_cast<sal_uInt16>(nRealLang)); + + m_xControl->append(OUString::number(static_cast<sal_uInt16>(nLangType)), aStrEntry, + bFound ? OUString(RID_SVXBMP_CHECKED) : OUString(RID_SVXBMP_NOTCHECKED)); + } + else + m_xControl->append(OUString::number(static_cast<sal_uInt16>(nLangType)), aStrEntry); } IMPL_LINK(LanguageBox, ChangeHdl, weld::ComboBoxText&, rControl, void) diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx index cc3adc0c97f5..1332b6040ae4 100644 --- a/sw/source/ui/frmdlg/column.cxx +++ b/sw/source/ui/frmdlg/column.cxx @@ -189,7 +189,7 @@ SwColumnDlg::SwColumnDlg(weld::Window* pParent, SwWrtShell& rSh) { const OUString sPageStr = pApplyToLB->get_text(nPagePos) + pPageDesc->GetName(); pApplyToLB->remove(nPagePos); - pApplyToLB->insert(nPagePos, OUString::number(LISTBOX_PAGE), sPageStr); + pApplyToLB->insert(nPagePos, OUString::number(LISTBOX_PAGE), sPageStr, nullptr); } else pApplyToLB->remove( nPagePos ); diff --git a/sw/source/uibase/misc/numberingtypelistbox.cxx b/sw/source/uibase/misc/numberingtypelistbox.cxx index 5f824d95a044..71f186d948b6 100644 --- a/sw/source/uibase/misc/numberingtypelistbox.cxx +++ b/sw/source/uibase/misc/numberingtypelistbox.cxx @@ -113,7 +113,7 @@ void SwNumberingTypeListBox::Reload(SwInsertNumTypes nTypeFlags) } if (bInsert) { - m_xWidget->insert(nPos, OUString::number(nValue), SvxNumberingTypeTable::GetString(i)); + m_xWidget->insert(nPos, OUString::number(nValue), SvxNumberingTypeTable::GetString(i), nullptr); } } if (nTypeFlags & SwInsertNumTypes::Extended) @@ -127,7 +127,7 @@ void SwNumberingTypeListBox::Reload(SwInsertNumTypes nTypeFlags) { if (m_xWidget->find_id(OUString::number(nCurrent)) == -1) { - m_xWidget->insert(-1, OUString::number(nCurrent), m_xImpl->xInfo->getNumberingIdentifier(nCurrent)); + m_xWidget->append(OUString::number(nCurrent), m_xImpl->xInfo->getNumberingIdentifier(nCurrent)); } } } diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx index e2a3276464f1..09bb27b81c9a 100644 --- a/sw/source/uibase/utlui/uitool.cxx +++ b/sw/source/uibase/utlui/uitool.cxx @@ -687,7 +687,7 @@ void InsertStringSorted(const OUString& rId, const OUString& rEntry, weld::Combo break; ++nOffset; } - rToFill.insert(nOffset, rId, rEntry); + rToFill.insert(nOffset, rId, rEntry, nullptr); } void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, bool bSorted, bool bWithDefault) diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 65eeaf83a182..c3286ff365fb 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1521,6 +1521,24 @@ IMPL_LINK(SalInstanceEntry, CursorListener, VclWindowEvent&, rEvent, void) signal_cursor_position(); } +namespace +{ + Image createImage(const OUString& rImage) + { + if (rImage.lastIndexOf('.') != rImage.getLength() - 4) + { + assert((rImage == "dialog-warning" || rImage == "dialog-error" || rImage == "dialog-information") && "unknown stock image"); + if (rImage == "dialog-warning") + return Image(BitmapEx(IMG_WARN)); + else if (rImage == "dialog-error") + return Image(BitmapEx(IMG_ERROR)); + else if (rImage == "dialog-information") + return Image(BitmapEx(IMG_INFO)); + } + return Image(BitmapEx(rImage)); + } +} + class SalInstanceTreeView : public SalInstanceContainer, public virtual weld::TreeView { private: @@ -1543,28 +1561,14 @@ public: m_xTreeView->InsertEntry(rText, pos == -1 ? LISTBOX_APPEND : pos); } - virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString& rImage) override + virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString* pImage) override { + auto nInsertPos = pos == -1 ? COMBOBOX_APPEND : pos; sal_Int32 nInsertedAt; - if (rImage.isEmpty()) - nInsertedAt = m_xTreeView->InsertEntry(rStr, pos == -1 ? COMBOBOX_APPEND : pos); + if (!pImage) + nInsertedAt = m_xTreeView->InsertEntry(rStr, nInsertPos); else - { - Image aImage; - if (rImage.lastIndexOf('.') != rImage.getLength() - 4) - { - assert((rImage == "dialog-warning" || rImage == "dialog-error" || rImage == "dialog-information") && "unknown stock image"); - if (rImage == "dialog-warning") - aImage = Image(BitmapEx(IMG_WARN)); - else if (rImage == "dialog-error") - aImage = Image(BitmapEx(IMG_ERROR)); - else if (rImage == "dialog-information") - aImage = Image(BitmapEx(IMG_INFO)); - } - else - aImage = Image(BitmapEx(rImage)); - nInsertedAt = m_xTreeView->InsertEntry(rStr, aImage, pos == -1 ? COMBOBOX_APPEND : pos); - } + nInsertedAt = m_xTreeView->InsertEntry(rStr, createImage(*pImage), nInsertPos); m_xTreeView->SetEntryData(nInsertedAt, new OUString(rId)); } @@ -2163,12 +2167,6 @@ public: m_xComboBoxText->InsertEntry(rStr, pos == -1 ? COMBOBOX_APPEND : pos); } - virtual void insert(int pos, const OUString& rId, const OUString& rStr) override - { - m_xComboBoxText->SetEntryData(m_xComboBoxText->InsertEntry(rStr, pos == -1 ? COMBOBOX_APPEND : pos), - new OUString(rId)); - } - virtual int get_count() const override { return m_xComboBoxText->GetEntryCount(); @@ -2238,6 +2236,17 @@ public: m_xComboBoxText->RemoveEntry(pos); } + virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString* pImage) override + { + auto nInsertPos = pos == -1 ? COMBOBOX_APPEND : pos; + sal_Int32 nInsertedAt; + if (!pImage) + nInsertedAt = m_xComboBoxText->InsertEntry(rStr, nInsertPos); + else + nInsertedAt = m_xComboBoxText->InsertEntry(rStr, createImage(*pImage), nInsertPos); + m_xComboBoxText->SetEntryData(nInsertedAt, new OUString(rId)); + } + virtual bool has_entry() const override { return false; @@ -2321,6 +2330,17 @@ public: m_xComboBoxText->RemoveEntryAt(pos); } + virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString* pImage) override + { + auto nInsertPos = pos == -1 ? COMBOBOX_APPEND : pos; + sal_Int32 nInsertedAt; + if (!pImage) + nInsertedAt = m_xComboBoxText->InsertEntry(rStr, nInsertPos); + else + nInsertedAt = m_xComboBoxText->InsertEntryWithImage(rStr, createImage(*pImage), nInsertPos); + m_xComboBoxText->SetEntryData(nInsertedAt, new OUString(rId)); + } + virtual void set_entry_text(const OUString& rText) override { m_xComboBoxText->SetText(rText); diff --git a/vcl/unx/generic/print/prtsetup.cxx b/vcl/unx/generic/print/prtsetup.cxx index 31d9b74d12ca..36d397c03fd7 100644 --- a/vcl/unx/generic/print/prtsetup.cxx +++ b/vcl/unx/generic/print/prtsetup.cxx @@ -47,7 +47,7 @@ void RTSDialog::insertAllPPDValues(weld::ComboBoxText& rBox, const PPDParser* pP if( m_aJobData.m_aContext.checkConstraints( pKey, pValue ) ) { if (nCurrentPos == -1) - rBox.insert(-1, sId, aOptionText); + rBox.append(sId, aOptionText); } else { @@ -329,7 +329,7 @@ RTSDevicePage::RTSDevicePage(weld::Widget* pPage, RTSDialog* pParent) || int(bAutoIsPDF) == m_pParent->m_aJobData.m_nPDFDevice); OUString sStr = m_xLevelBox->get_text(0); - m_xLevelBox->insert(0, m_xLevelBox->get_id(0), sStr.replaceAll("%s", bAutoIsPDF ? m_xLevelBox->get_text(5) : m_xLevelBox->get_text(1))); + m_xLevelBox->insert(0, m_xLevelBox->get_id(0), sStr.replaceAll("%s", bAutoIsPDF ? m_xLevelBox->get_text(5) : m_xLevelBox->get_text(1)), nullptr); m_xLevelBox->remove(1); for (int i = 0; i < m_xLevelBox->get_count(); ++i) @@ -367,7 +367,7 @@ RTSDevicePage::RTSDevicePage(weld::Widget* pPage, RTSDialog* pParent) pKey->getGroup() != "InstallableOptions") { OUString aEntry( m_pParent->m_aJobData.m_pParser->translateKey( pKey->getKey() ) ); - m_xPPDKeyBox->append(OUString::number(reinterpret_cast<sal_Int64>(pKey)), aEntry, ""); + m_xPPDKeyBox->append(OUString::number(reinterpret_cast<sal_Int64>(pKey)), aEntry); } } } @@ -467,7 +467,7 @@ void RTSDevicePage::FillValueBox( const PPDKey* pKey ) aEntry = VclResId(SV_PRINT_CUSTOM_TXT); else aEntry = m_pParent->m_aJobData.m_pParser->translateOption( pKey->getKey(), pValue->m_aOption); - m_xPPDValueBox->append(OUString::number(reinterpret_cast<sal_Int64>(pValue)), aEntry, ""); + m_xPPDValueBox->append(OUString::number(reinterpret_cast<sal_Int64>(pValue)), aEntry); } } pValue = m_pParent->m_aJobData.m_aContext.getValue( pKey ); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index d99fa04f09fb..61c4337e4c0a 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -3579,6 +3579,52 @@ namespace } } +namespace +{ + void insert_row(GtkListStore* pListStore, int pos, const OUString& rId, const OUString& rText, const OUString* pImage) + { + GtkTreeIter iter; + gtk_list_store_insert(pListStore, &iter, pos); + if (!pImage) + { + gtk_list_store_set(pListStore, &iter, + 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), + 1, OUStringToOString(rId, RTL_TEXTENCODING_UTF8).getStr(), + -1); + } + else + { + GdkPixbuf* pixbuf = nullptr; + + if (pImage->lastIndexOf('.') != pImage->getLength() - 4) + { + assert((*pImage == "dialog-warning" || *pImage == "dialog-error" || *pImage == "dialog-information") && "unknown stock image"); + + GError *error = nullptr; + GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); + pixbuf = gtk_icon_theme_load_icon(icon_theme, OUStringToOString(*pImage, RTL_TEXTENCODING_UTF8).getStr(), + 16, GTK_ICON_LOOKUP_USE_BUILTIN, &error); + } + else + { + const AllSettings& rSettings = Application::GetSettings(); + pixbuf = load_icon_by_name(*pImage, + rSettings.GetStyleSettings().DetermineIconTheme(), + rSettings.GetUILanguageTag().getBcp47()); + } + + gtk_list_store_set(pListStore, &iter, + 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), + 1, OUStringToOString(rId, RTL_TEXTENCODING_UTF8).getStr(), + 2, pixbuf, + -1); + + if (pixbuf) + g_object_unref(pixbuf); + } + } +} + class GtkInstanceTreeView : public GtkInstanceContainer, public virtual weld::TreeView { private: @@ -3643,48 +3689,10 @@ public: enable_notify_events(); } - virtual void insert(int pos, const OUString& rId, const OUString& rText, const OUString& rImage) override + virtual void insert(int pos, const OUString& rId, const OUString& rText, const OUString* pImage) override { disable_notify_events(); - GtkTreeIter iter; - gtk_list_store_insert(m_pListStore, &iter, pos); - if (rImage.isEmpty()) - { - gtk_list_store_set(m_pListStore, &iter, - 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), - 1, OUStringToOString(rId, RTL_TEXTENCODING_UTF8).getStr(), - -1); - } - else - { - GdkPixbuf* pixbuf = nullptr; - - if (rImage.lastIndexOf('.') != rImage.getLength() - 4) - { - assert((rImage == "dialog-warning" || rImage == "dialog-error" || rImage == "dialog-information") && "unknown stock image"); - - GError *error = nullptr; - GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); - pixbuf = gtk_icon_theme_load_icon(icon_theme, OUStringToOString(rImage, RTL_TEXTENCODING_UTF8).getStr(), - 16, GTK_ICON_LOOKUP_USE_BUILTIN, &error); - } - else - { - const AllSettings& rSettings = Application::GetSettings(); - pixbuf = load_icon_by_name(rImage, - rSettings.GetStyleSettings().DetermineIconTheme(), - rSettings.GetUILanguageTag().getBcp47()); - } - - gtk_list_store_set(m_pListStore, &iter, - 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), - 1, OUStringToOString(rId, RTL_TEXTENCODING_UTF8).getStr(), - 2, pixbuf, - -1); - - if (pixbuf) - g_object_unref(pixbuf); - } + insert_row(m_pListStore, pos, rId, rText, pImage); enable_notify_events(); } @@ -4548,7 +4556,7 @@ namespace class GtkInstanceComboBoxText : public GtkInstanceContainer, public virtual weld::ComboBoxText { private: - GtkComboBoxText* m_pComboBoxText; + GtkComboBox* m_pComboBoxText; std::unique_ptr<comphelper::string::NaturalStringSorter> m_xSorter; gboolean m_bPopupActive; gulong m_nChangedSignalId; @@ -4600,7 +4608,7 @@ private: OUString get(int pos, int col) const { OUString sRet; - GtkTreeModel *pModel = gtk_combo_box_get_model(GTK_COMBO_BOX(m_pComboBoxText)); + GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBoxText); GtkTreeIter iter; if (gtk_tree_model_iter_nth_child(pModel, &iter, nullptr, pos)) { @@ -4614,7 +4622,7 @@ private: int find(const OUString& rStr, int col) const { - GtkTreeModel *pModel = gtk_combo_box_get_model(GTK_COMBO_BOX(m_pComboBoxText)); + GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBoxText); GtkTreeIter iter; if (!gtk_tree_model_get_iter_first(pModel, &iter)) return -1; @@ -4648,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(GTK_COMBO_BOX(m_pComboBoxText))); + gtk_entry_completion_set_model(pCompletion, gtk_combo_box_get_model(m_pComboBoxText)); gtk_entry_completion_set_text_column(pCompletion, 0); gtk_entry_completion_set_inline_selection(pCompletion, true); gtk_entry_completion_set_inline_completion(pCompletion, true); @@ -4658,19 +4666,37 @@ private: } public: - GtkInstanceComboBoxText(GtkComboBoxText* pComboBoxText, bool bTakeOwnership) + GtkInstanceComboBoxText(GtkComboBox* pComboBoxText, bool bTakeOwnership) : GtkInstanceContainer(GTK_CONTAINER(pComboBoxText), bTakeOwnership) , m_pComboBoxText(pComboBoxText) , 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)) { - // 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)); - GtkCellRenderer* cell = static_cast<GtkCellRenderer*>(cells->data); - g_object_set(G_OBJECT(cell), "ellipsize", PANGO_ELLIPSIZE_MIDDLE, nullptr); - g_list_free(cells); + 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); + 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)); + GtkCellRenderer* cell = static_cast<GtkCellRenderer*>(cells->data); + g_object_set(G_OBJECT(cell), "ellipsize", PANGO_ELLIPSIZE_MIDDLE, nullptr); + if (g_list_length(cells) == 2) + { + //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); + } + g_list_free(cells); + } if (GtkEntry* pEntry = get_entry()) { @@ -4683,12 +4709,12 @@ public: virtual int get_active() const override { - return gtk_combo_box_get_active(GTK_COMBO_BOX(m_pComboBoxText)); + return gtk_combo_box_get_active(m_pComboBoxText); } virtual OUString get_active_id() const override { - const gchar* pText = gtk_combo_box_get_active_id(GTK_COMBO_BOX(m_pComboBoxText)); + const gchar* pText = gtk_combo_box_get_active_id(m_pComboBoxText); return OUString(pText, pText ? strlen(pText) : 0, RTL_TEXTENCODING_UTF8); } @@ -4696,7 +4722,7 @@ public: { disable_notify_events(); OString aId(OUStringToOString(rStr, RTL_TEXTENCODING_UTF8)); - gtk_combo_box_set_active_id(GTK_COMBO_BOX(m_pComboBoxText), aId.getStr()); + gtk_combo_box_set_active_id(m_pComboBoxText, aId.getStr()); enable_notify_events(); } @@ -4716,15 +4742,30 @@ public: virtual void set_active(int pos) override { disable_notify_events(); - gtk_combo_box_set_active(GTK_COMBO_BOX(m_pComboBoxText), pos); + gtk_combo_box_set_active(m_pComboBoxText, pos); enable_notify_events(); } virtual OUString get_active_text() const override { - gchar* pText = gtk_combo_box_text_get_active_text(m_pComboBoxText); - OUString sRet(pText, pText ? strlen(pText) : 0, RTL_TEXTENCODING_UTF8); - g_free(pText); + if (gtk_combo_box_get_has_entry(m_pComboBoxText)) + { + GtkWidget *pEntry = gtk_bin_get_child(GTK_BIN(m_pComboBoxText)); + 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)) + return OUString(); + + GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBoxText); + gint col = gtk_combo_box_get_entry_text_column(m_pComboBoxText); + gchar* pStr = nullptr; + gtk_tree_model_get(pModel, &iter, col, &pStr, -1); + OUString sRet(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8); + g_free(pStr); + return sRet; } @@ -4735,36 +4776,40 @@ public: virtual OUString get_id(int pos) const override { - gint id_column = gtk_combo_box_get_id_column(GTK_COMBO_BOX(m_pComboBoxText)); + gint id_column = gtk_combo_box_get_id_column(m_pComboBoxText); return get(pos, id_column); } - virtual void insert_text(int pos, const OUString& rStr) override + virtual void insert_text(int pos, const OUString& rText) override { disable_notify_events(); - gtk_combo_box_text_insert_text(m_pComboBoxText, pos, OUStringToOString(rStr, RTL_TEXTENCODING_UTF8).getStr()); + GtkTreeIter iter; + GtkListStore* pListStore = GTK_LIST_STORE(gtk_combo_box_get_model(m_pComboBoxText)); + gtk_list_store_insert(pListStore, &iter, pos); + gtk_list_store_set(pListStore, &iter, 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), -1); enable_notify_events(); } virtual void remove(int pos) override { disable_notify_events(); - gtk_combo_box_text_remove(m_pComboBoxText, pos); + GtkTreeIter iter; + GtkListStore* pListStore = GTK_LIST_STORE(gtk_combo_box_get_model(m_pComboBoxText)); + gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(pListStore), &iter, nullptr, pos); + gtk_list_store_remove(pListStore, &iter); enable_notify_events(); } - virtual void insert(int pos, const OUString& rId, const OUString& rStr) override + virtual void insert(int pos, const OUString& rId, const OUString& rText, const OUString* pImage) override { disable_notify_events(); - gtk_combo_box_text_insert(m_pComboBoxText, pos, - OUStringToOString(rId, RTL_TEXTENCODING_UTF8).getStr(), - OUStringToOString(rStr, RTL_TEXTENCODING_UTF8).getStr()); + insert_row(GTK_LIST_STORE(gtk_combo_box_get_model(m_pComboBoxText)), pos, rId, rText, pImage); enable_notify_events(); } virtual int get_count() const override { - GtkTreeModel *pModel = gtk_combo_box_get_model(GTK_COMBO_BOX(m_pComboBoxText)); + GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBoxText); return gtk_tree_model_iter_n_children(pModel, nullptr); } @@ -4781,7 +4826,7 @@ public: virtual void clear() override { disable_notify_events(); - GtkTreeModel *pModel = gtk_combo_box_get_model(GTK_COMBO_BOX(m_pComboBoxText)); + GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBoxText); gtk_list_store_clear(GTK_LIST_STORE(pModel)); enable_notify_events(); } @@ -4791,7 +4836,7 @@ public: m_xSorter.reset(new comphelper::string::NaturalStringSorter( ::comphelper::getProcessComponentContext(), Application::GetSettings().GetUILanguageTag().getLocale())); - GtkTreeModel* pModel = gtk_combo_box_get_model(GTK_COMBO_BOX(m_pComboBoxText)); + GtkTreeModel* pModel = gtk_combo_box_get_model(m_pComboBoxText); 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); @@ -4799,7 +4844,7 @@ public: virtual bool has_entry() const override { - return gtk_combo_box_get_has_entry(GTK_COMBO_BOX(m_pComboBoxText)); + return gtk_combo_box_get_has_entry(m_pComboBoxText); } virtual void set_entry_error(bool bError) override @@ -4882,7 +4927,7 @@ public: GtkInstanceContainer::freeze(); if (m_xSorter) { - GtkTreeModel* pModel = gtk_combo_box_get_model(GTK_COMBO_BOX(m_pComboBoxText)); + GtkTreeModel* pModel = gtk_combo_box_get_model(m_pComboBoxText); GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(pModel); gtk_tree_sortable_set_sort_column_id(pSortable, GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, GTK_SORT_ASCENDING); } @@ -4892,7 +4937,7 @@ public: { if (m_xSorter) { - GtkTreeModel* pModel = gtk_combo_box_get_model(GTK_COMBO_BOX(m_pComboBoxText)); + GtkTreeModel* pModel = gtk_combo_box_get_model(m_pComboBoxText); GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(pModel); gtk_tree_sortable_set_sort_column_id(pSortable, 0, GTK_SORT_ASCENDING); } @@ -5451,7 +5496,7 @@ public: virtual std::unique_ptr<weld::ComboBoxText> weld_combo_box_text(const OString &id, bool bTakeOwnership) override { - GtkComboBoxText* pComboBoxText = GTK_COMBO_BOX_TEXT(gtk_builder_get_object(m_pBuilder, id.getStr())); + GtkComboBox* pComboBoxText = GTK_COMBO_BOX(gtk_builder_get_object(m_pBuilder, id.getStr())); if (!pComboBoxText) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pComboBoxText)); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits