summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-01-08 09:28:38 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2021-01-14 10:20:27 +0100
commit25f33c3393895edced99cb69c7a450b9e2bb5343 (patch)
tree4a255d899fb6bfba6c391cad6a7b4c35aef8c04a /vcl
parentce324c96132066a614d302ba07723026e5c6b83e (diff)
Fontwork dialog: use iconview
Change-Id: I5bb35407ca83c9b0cda6f6355e6e25c21fecb459 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108960 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109181 Tested-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/app/salvtables.cxx41
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx28
2 files changed, 69 insertions, 0 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index e8755eb5b1d5..0aa3db724e91 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -5115,6 +5115,47 @@ public:
enable_notify_events();
}
+ virtual void insert(int pos, const OUString* pStr, const OUString* pId,
+ const VirtualDevice* pIcon, weld::TreeIter* pRet) override
+ {
+ disable_notify_events();
+ auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos;
+ void* pUserData;
+ if (pId)
+ {
+ m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
+ pUserData = m_aUserData.back().get();
+ }
+ else
+ pUserData = nullptr;
+
+ SvTreeListEntry* pEntry = new SvTreeListEntry;
+ if (pIcon)
+ {
+ const Point aNull(0, 0);
+ const Size aSize = pIcon->GetOutputSizePixel();
+ Image aImage(pIcon->GetBitmapEx(aNull, aSize));
+ pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage, false));
+ }
+ else
+ {
+ Image aDummy;
+ pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false));
+ }
+ if (pStr)
+ pEntry->AddItem(std::make_unique<SvLBoxString>(*pStr));
+ pEntry->SetUserData(pUserData);
+ m_xIconView->Insert(pEntry, nullptr, nInsertPos);
+
+ if (pRet)
+ {
+ SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet);
+ pVclRetIter->iter = pEntry;
+ }
+
+ enable_notify_events();
+ }
+
virtual OUString get_selected_id() const override
{
assert(m_xIconView->IsUpdateMode() && "don't request selection when frozen");
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 39c826823d01..0ef2b33239cf 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -12467,6 +12467,21 @@ private:
}
}
+ void insert_item(GtkTreeIter& iter, int pos, const OUString* pId, const OUString* pText, const VirtualDevice* pIcon)
+ {
+ gtk_tree_store_insert_with_values(m_pTreeStore, &iter, nullptr, pos,
+ m_nTextCol, !pText ? nullptr : OUStringToOString(*pText, RTL_TEXTENCODING_UTF8).getStr(),
+ m_nIdCol, !pId ? nullptr : OUStringToOString(*pId, RTL_TEXTENCODING_UTF8).getStr(),
+ -1);
+ if (pIcon)
+ {
+ GdkPixbuf* pixbuf = getPixbuf(*pIcon);
+ gtk_tree_store_set(m_pTreeStore, &iter, m_nImageCol, pixbuf, -1);
+ if (pixbuf)
+ g_object_unref(pixbuf);
+ }
+ }
+
OUString get(const GtkTreeIter& iter, int col) const
{
GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore);
@@ -12527,6 +12542,19 @@ public:
enable_notify_events();
}
+ virtual void insert(int pos, const OUString* pText, const OUString* pId, const VirtualDevice* pIcon, weld::TreeIter* pRet) override
+ {
+ disable_notify_events();
+ GtkTreeIter iter;
+ insert_item(iter, pos, pId, pText, pIcon);
+ if (pRet)
+ {
+ GtkInstanceTreeIter* pGtkRetIter = static_cast<GtkInstanceTreeIter*>(pRet);
+ pGtkRetIter->iter = iter;
+ }
+ enable_notify_events();
+ }
+
virtual OUString get_selected_id() const override
{
assert(gtk_icon_view_get_model(m_pIconView) && "don't request selection when frozen");