[Libreoffice-commits] core.git: cui/source cui/uiconfig include/vcl vcl/source vcl/unx
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Sep 19 20:00:54 UTC 2018
cui/source/dialogs/cuigaldlg.cxx | 65 ++++++++--------------------
cui/source/inc/cuigaldlg.hxx | 22 +++------
cui/uiconfig/ui/gallerygeneralpage.ui | 37 ++--------------
include/vcl/weld.hxx | 7 +++
vcl/source/app/salvtables.cxx | 25 +++++++++++
vcl/unx/gtk3/gtk3gtkinst.cxx | 77 +++++++++++++++++++++++-----------
6 files changed, 119 insertions(+), 114 deletions(-)
New commits:
commit af60b15af12bbb0cda2b48b99fde632f1532e1aa
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Sep 18 17:13:33 2018 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Sep 19 22:00:27 2018 +0200
weld TPGalleryThemeGeneral
Change-Id: Id5ec1b1282c039f30c40fc781be0f6d72a8bfb47
Reviewed-on: https://gerrit.libreoffice.org/60718
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx
index 18e39c8ae267..a04340bbc80e 100644
--- a/cui/source/dialogs/cuigaldlg.cxx
+++ b/cui/source/dialogs/cuigaldlg.cxx
@@ -574,7 +574,6 @@ GalleryThemeProperties::GalleryThemeProperties(vcl::Window* pParent,
SetText( aText );
}
-
void GalleryThemeProperties::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
{
if (nId == m_nGeneralPageId)
@@ -583,39 +582,18 @@ void GalleryThemeProperties::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
static_cast<TPGalleryThemeProperties&>( rPage ).SetXChgData( pData );
}
-
-TPGalleryThemeGeneral::TPGalleryThemeGeneral(vcl::Window* pParent, const SfxItemSet& rSet)
- : SfxTabPage(pParent, "GalleryGeneralPage",
- "cui/ui/gallerygeneralpage.ui", &rSet)
+TPGalleryThemeGeneral::TPGalleryThemeGeneral(TabPageParent pParent, const SfxItemSet& rSet)
+ : SfxTabPage(pParent, "cui/ui/gallerygeneralpage.ui", "GalleryGeneralPage", &rSet)
, pData(nullptr)
+ , m_xFiMSImage(m_xBuilder->weld_image("image"))
+ , m_xEdtMSName(m_xBuilder->weld_entry("name"))
+ , m_xFtMSShowType(m_xBuilder->weld_label("type"))
+ , m_xFtMSShowPath(m_xBuilder->weld_label("location"))
+ , m_xFtMSShowContent(m_xBuilder->weld_label("contents"))
+ , m_xFtMSShowChangeDate(m_xBuilder->weld_label("modified"))
{
- get(m_pFiMSImage, "image");
- get(m_pEdtMSName, "name");
- get(m_pFtMSShowType, "type");
- get(m_pFtMSShowPath, "location");
- get(m_pFtMSShowContent, "contents");
- get(m_pFtMSShowChangeDate, "modified");
-}
-
-
-TPGalleryThemeGeneral::~TPGalleryThemeGeneral()
-{
- disposeOnce();
-}
-
-
-void TPGalleryThemeGeneral::dispose()
-{
- m_pFiMSImage.clear();
- m_pEdtMSName.clear();
- m_pFtMSShowType.clear();
- m_pFtMSShowPath.clear();
- m_pFtMSShowContent.clear();
- m_pFtMSShowChangeDate.clear();
- SfxTabPage::dispose();
}
-
void TPGalleryThemeGeneral::SetXChgData( ExchangeData* _pData )
{
pData = _pData;
@@ -627,19 +605,15 @@ void TPGalleryThemeGeneral::SetXChgData( ExchangeData* _pData )
OUString aType( SvxResId( RID_SVXSTR_GALLERYPROPS_GALTHEME ) );
bool bReadOnly = pThm->IsReadOnly();
- m_pEdtMSName->SetText( pThm->GetName() );
- m_pEdtMSName->SetReadOnly( bReadOnly );
-
- if( bReadOnly )
- m_pEdtMSName->Disable();
- else
- m_pEdtMSName->Enable();
+ m_xEdtMSName->set_text(pThm->GetName());
+ m_xEdtMSName->set_editable(!bReadOnly);
+ m_xEdtMSName->set_sensitive(!bReadOnly);
if( pThm->IsReadOnly() )
aType += CuiResId( RID_SVXSTR_GALLERY_READONLY );
- m_pFtMSShowType->SetText( aType );
- m_pFtMSShowPath->SetText( pThm->GetSdgURL().GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ) );
+ m_xFtMSShowType->set_label(aType);
+ m_xFtMSShowPath->set_label(pThm->GetSdgURL().GetMainURL(INetURLObject::DecodeMechanism::Unambiguous));
// singular or plural?
if ( 1 == pThm->GetObjectCount() )
@@ -649,7 +623,7 @@ void TPGalleryThemeGeneral::SetXChgData( ExchangeData* _pData )
aOutStr += " " + aObjStr;
- m_pFtMSShowContent->SetText( aOutStr );
+ m_xFtMSShowContent->set_label(aOutStr);
// get locale wrapper (singleton)
const SvtSysLocale aSysLocale;
@@ -657,7 +631,7 @@ void TPGalleryThemeGeneral::SetXChgData( ExchangeData* _pData )
// ChangeDate/Time
aAccess = aLocaleData.getDate( pData->aThemeChangeDate ) + ", " + aLocaleData.getTime( pData->aThemeChangeTime );
- m_pFtMSShowChangeDate->SetText( aAccess );
+ m_xFtMSShowChangeDate->set_label(aAccess);
// set image
OUString sId;
@@ -669,21 +643,20 @@ void TPGalleryThemeGeneral::SetXChgData( ExchangeData* _pData )
else
sId = RID_SVXBMP_THEME_NORMAL_BIG;
- m_pFiMSImage->SetImage(Image(BitmapEx(sId)));
+ m_xFiMSImage->set_from_icon_name(sId);
}
bool TPGalleryThemeGeneral::FillItemSet( SfxItemSet* /*rSet*/ )
{
- pData->aEditedTitle = m_pEdtMSName->GetText();
+ pData->aEditedTitle = m_xEdtMSName->get_text();
return true;
}
-VclPtr<SfxTabPage> TPGalleryThemeGeneral::Create( TabPageParent pParent, const SfxItemSet* rSet )
+VclPtr<SfxTabPage> TPGalleryThemeGeneral::Create(TabPageParent pParent, const SfxItemSet* rSet)
{
- return VclPtr<TPGalleryThemeGeneral>::Create( pParent.pParent, *rSet );
+ return VclPtr<TPGalleryThemeGeneral>::Create(pParent, *rSet);
}
-
TPGalleryThemeProperties::TPGalleryThemeProperties( vcl::Window* pWindow, const SfxItemSet& rSet )
: SfxTabPage(pWindow, "GalleryFilesPage", "cui/ui/galleryfilespage.ui", &rSet)
, pData(nullptr)
diff --git a/cui/source/inc/cuigaldlg.hxx b/cui/source/inc/cuigaldlg.hxx
index 4487a9bd23c7..fd36e8b314a3 100644
--- a/cui/source/inc/cuigaldlg.hxx
+++ b/cui/source/inc/cuigaldlg.hxx
@@ -206,27 +206,21 @@ public:
class TPGalleryThemeGeneral : public SfxTabPage
{
private:
-
- VclPtr<FixedImage> m_pFiMSImage;
- VclPtr<Edit> m_pEdtMSName;
- VclPtr<FixedText> m_pFtMSShowType;
- VclPtr<FixedText> m_pFtMSShowPath;
- VclPtr<FixedText> m_pFtMSShowContent;
- VclPtr<FixedText> m_pFtMSShowChangeDate;
ExchangeData* pData;
+ std::unique_ptr<weld::Image> m_xFiMSImage;
+ std::unique_ptr<weld::Entry> m_xEdtMSName;
+ std::unique_ptr<weld::Label> m_xFtMSShowType;
+ std::unique_ptr<weld::Label> m_xFtMSShowPath;
+ std::unique_ptr<weld::Label> m_xFtMSShowContent;
+ std::unique_ptr<weld::Label> m_xFtMSShowChangeDate;
+
virtual void Reset( const SfxItemSet* ) override {}
virtual bool FillItemSet( SfxItemSet* rSet ) override;
-
public:
-
- TPGalleryThemeGeneral( vcl::Window* pParent, const SfxItemSet& rSet );
- virtual ~TPGalleryThemeGeneral() override;
- virtual void dispose() override;
-
+ TPGalleryThemeGeneral(TabPageParent pParent, const SfxItemSet& rSet);
void SetXChgData( ExchangeData* pData );
-
static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rSet );
};
diff --git a/cui/uiconfig/ui/gallerygeneralpage.ui b/cui/uiconfig/ui/gallerygeneralpage.ui
index e8ba15e3b625..6749c4d3fd8c 100644
--- a/cui/uiconfig/ui/gallerygeneralpage.ui
+++ b/cui/uiconfig/ui/gallerygeneralpage.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="cui">
<requires lib="gtk+" version="3.18"/>
<object class="GtkGrid" id="GalleryGeneralPage">
@@ -18,14 +18,12 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="gallerygeneralpage|label1">Modified:</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -37,16 +35,12 @@
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -59,14 +53,12 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="gallerygeneralpage|label2">Type:</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -78,36 +70,30 @@
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="gallerygeneralpage|label3">Location:</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="gallerygeneralpage|label4">Contents:</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -119,8 +105,6 @@
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -132,16 +116,12 @@
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -166,8 +146,6 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -175,6 +153,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
+ <property name="activates_default">True</property>
<accessibility>
<relation type="labelled-by" target="image"/>
</accessibility>
@@ -182,16 +161,12 @@
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 1857033f5929..35a9658325e9 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -593,6 +593,12 @@ public:
static unsigned int Power10(unsigned int n);
};
+class VCL_DLLPUBLIC Image : virtual public Widget
+{
+public:
+ virtual void set_from_icon_name(const OUString& rIconName) = 0;
+};
+
// an entry + treeview pair, where the entry autocompletes from the
// treeview list, and selecting something in the list sets the
// entry to that text, i.e. a visually exploded ComboBox
@@ -1078,6 +1084,7 @@ public:
virtual std::unique_ptr<ProgressBar> weld_progress_bar(const OString& id,
bool bTakeOwnership = false)
= 0;
+ virtual std::unique_ptr<Image> weld_image(const OString& id, bool bTakeOwnership = false) = 0;
virtual std::unique_ptr<DrawingArea>
weld_drawing_area(const OString& id, const a11yref& rA11yImpl = nullptr,
FactoryFunction pUITestFactoryFunction = nullptr, void* pUserData = nullptr,
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index cbaf74bb807c..85d6740790d2 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -37,6 +37,7 @@
#include <vcl/combobox.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
#include <vcl/layout.hxx>
#include <vcl/menubtn.hxx>
#include <vcl/prgsbar.hxx>
@@ -1393,6 +1394,24 @@ public:
}
};
+class SalInstanceImage : public SalInstanceWidget, public virtual weld::Image
+{
+private:
+ VclPtr<FixedImage> m_xImage;
+
+public:
+ SalInstanceImage(FixedImage* pImage, bool bTakeOwnership)
+ : SalInstanceWidget(pImage, bTakeOwnership)
+ , m_xImage(pImage)
+ {
+ }
+
+ virtual void set_from_icon_name(const OUString& rIconName) override
+ {
+ m_xImage->SetImage(::Image(BitmapEx(rIconName)));
+ }
+};
+
class SalInstanceEntry : public SalInstanceWidget, public virtual weld::Entry
{
private:
@@ -2628,6 +2647,12 @@ public:
return pProgress ? o3tl::make_unique<SalInstanceProgressBar>(pProgress, bTakeOwnership) : nullptr;
}
+ virtual std::unique_ptr<weld::Image> weld_image(const OString &id, bool bTakeOwnership) override
+ {
+ FixedImage* pImage = m_xBuilder->get<FixedImage>(id);
+ return pImage ? o3tl::make_unique<SalInstanceImage>(pImage, bTakeOwnership) : nullptr;
+ }
+
virtual std::unique_ptr<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 4924abb21e58..4a564e894e37 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -3306,6 +3306,51 @@ public:
}
};
+namespace
+{
+ GdkPixbuf* load_icon_by_name(const OUString& rIconName, const OUString& rIconTheme, const OUString& rUILang)
+ {
+ GdkPixbuf* pixbuf = nullptr;
+ auto xMemStm = ImageTree::get().getImageStream(rIconName, rIconTheme, rUILang);
+ if (xMemStm)
+ {
+ GdkPixbufLoader *pixbuf_loader = gdk_pixbuf_loader_new();
+ gdk_pixbuf_loader_write(pixbuf_loader, static_cast<const guchar*>(xMemStm->GetData()),
+ xMemStm->Seek(STREAM_SEEK_TO_END), nullptr);
+ gdk_pixbuf_loader_close(pixbuf_loader, nullptr);
+ pixbuf = gdk_pixbuf_loader_get_pixbuf(pixbuf_loader);
+ if (pixbuf)
+ g_object_ref(pixbuf);
+ g_object_unref(pixbuf_loader);
+ }
+ return pixbuf;
+ }
+}
+
+class GtkInstanceImage : public GtkInstanceWidget, public virtual weld::Image
+{
+private:
+ GtkImage* m_pImage;
+
+public:
+ GtkInstanceImage(GtkImage* pImage, bool bTakeOwnership)
+ : GtkInstanceWidget(GTK_WIDGET(pImage), bTakeOwnership)
+ , m_pImage(pImage)
+ {
+ }
+
+ virtual void set_from_icon_name(const OUString& rIconName) override
+ {
+ OUString sIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
+ OUString sUILang = Application::GetSettings().GetUILanguageTag().getBcp47();
+ GdkPixbuf* pixbuf = load_icon_by_name(rIconName, sIconTheme, sUILang);
+ if (!pixbuf)
+ return;
+ gtk_image_set_from_pixbuf(m_pImage, pixbuf);
+ g_object_unref(pixbuf);
+ }
+};
+
class GtkInstanceEntry : public GtkInstanceWidget, public virtual weld::Entry
{
private:
@@ -3560,27 +3605,6 @@ namespace
return found;
}
- GdkPixbuf* load_icon_by_name(const OUString& rIconName, const OUString& rIconTheme, const OUString& rUILang)
- {
- GdkPixbuf* pixbuf = nullptr;
- auto xMemStm = ImageTree::get().getImageStream(rIconName, rIconTheme, rUILang);
- if (xMemStm)
- {
- GdkPixbufLoader *pixbuf_loader = gdk_pixbuf_loader_new();
- gdk_pixbuf_loader_write(pixbuf_loader, static_cast<const guchar*>(xMemStm->GetData()),
- xMemStm->Seek(STREAM_SEEK_TO_END), nullptr);
- gdk_pixbuf_loader_close(pixbuf_loader, nullptr);
- pixbuf = gdk_pixbuf_loader_get_pixbuf(pixbuf_loader);
- if (pixbuf)
- g_object_ref(pixbuf);
- g_object_unref(pixbuf_loader);
- }
- return pixbuf;
- }
-}
-
-namespace
-{
void insert_row(GtkListStore* pListStore, int pos, const OUString& rId, const OUString& rText, const OUString* pImage)
{
GtkTreeIter iter;
@@ -5191,8 +5215,6 @@ private:
GtkImage* pImage = GTK_IMAGE(pWidget);
const gchar* icon_name;
gtk_image_get_icon_name(pImage, &icon_name, nullptr);
- GtkIconSize size;
- g_object_get(pImage, "icon-size", &size, nullptr);
if (icon_name)
{
OUString aIconName(icon_name, strlen(icon_name), RTL_TEXTENCODING_UTF8);
@@ -5497,6 +5519,15 @@ public:
return o3tl::make_unique<GtkInstanceProgressBar>(pProgressBar, bTakeOwnership);
}
+ virtual std::unique_ptr<weld::Image> weld_image(const OString &id, bool bTakeOwnership) override
+ {
+ GtkImage* pImage = GTK_IMAGE(gtk_builder_get_object(m_pBuilder, id.getStr()));
+ if (!pImage)
+ return nullptr;
+ auto_add_parentless_widgets_to_container(GTK_WIDGET(pImage));
+ return o3tl::make_unique<GtkInstanceImage>(pImage, bTakeOwnership);
+ }
+
virtual std::unique_ptr<weld::Entry> weld_entry(const OString &id, bool bTakeOwnership) override
{
GtkEntry* pEntry = GTK_ENTRY(gtk_builder_get_object(m_pBuilder, id.getStr()));
More information about the Libreoffice-commits
mailing list