Kaydet (Commit) 61964fc1 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SvxJavaClassPathDlg

Change-Id: I3938a05d96cb1fc171611e54fa34f780ba569268
üst 1c90deaa
This diff is collapsed.
......@@ -29,6 +29,7 @@
#include <vcl/lstbox.hxx>
#include <vcl/timer.hxx>
#include <vcl/idle.hxx>
#include <vcl/weld.hxx>
#include <sfx2/tabdlg.hxx>
#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
#include <svtools/dialogclosedlistener.hxx>
......@@ -64,7 +65,7 @@ private:
VclPtr<PushButton> m_pExpertConfigBtn;
std::unique_ptr<SvxJavaParameterDlg> m_xParamDlg;
VclPtr<SvxJavaClassPathDlg> m_pPathDlg;
std::unique_ptr<SvxJavaClassPathDlg> m_xPathDlg;
VclPtr<OfaTreeOptionsDialog> m_pParentDlg;
#if HAVE_FEATURE_JAVA
......@@ -176,34 +177,33 @@ public:
// class SvxJavaClassPathDlg ---------------------------------------------
class SvxJavaClassPathDlg : public ModalDialog
class SvxJavaClassPathDlg : public weld::GenericDialogController
{
private:
VclPtr<ListBox> m_pPathList;
VclPtr<PushButton> m_pAddArchiveBtn;
VclPtr<PushButton> m_pAddPathBtn;
VclPtr<PushButton> m_pRemoveBtn;
std::unique_ptr<weld::TreeView> m_xPathList;
std::unique_ptr<weld::Button> m_xAddArchiveBtn;
std::unique_ptr<weld::Button> m_xAddPathBtn;
std::unique_ptr<weld::Button> m_xRemoveBtn;
OUString m_sOldPath;
DECL_LINK(AddArchiveHdl_Impl, Button*, void);
DECL_LINK(AddPathHdl_Impl, Button*, void);
DECL_LINK(RemoveHdl_Impl, Button*, void);
DECL_LINK(SelectHdl_Impl, ListBox&, void);
bool IsPathDuplicate( const OUString& _rPath );
void EnableRemoveButton()
{ m_pRemoveBtn->Enable(
m_pPathList->GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND ); }
DECL_LINK(AddArchiveHdl_Impl, weld::Button&, void);
DECL_LINK(AddPathHdl_Impl, weld::Button&, void);
DECL_LINK(RemoveHdl_Impl, weld::Button&, void);
DECL_LINK(SelectHdl_Impl, weld::TreeView&, void);
bool IsPathDuplicate(const OUString& _rPath);
void EnableRemoveButton()
{
m_xRemoveBtn->set_sensitive(m_xPathList->get_selected_index() != -1);
}
public:
explicit SvxJavaClassPathDlg( vcl::Window* pParent );
explicit SvxJavaClassPathDlg(weld::Window* pParent);
virtual ~SvxJavaClassPathDlg() override;
virtual void dispose() override;
const OUString& GetOldPath() const { return m_sOldPath; }
void SetFocus() { m_pPathList->GrabFocus(); }
void SetFocus() { m_xPathList->grab_focus(); }
OUString GetClassPath() const;
void SetClassPath( const OUString& _rPath );
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.20.4 -->
<interface domain="cui">
<requires lib="gtk+" version="3.18"/>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
<!-- column-name image -->
<column type="GdkPixbuf"/>
</columns>
</object>
<object class="GtkDialog" id="JavaClassPath">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="javaclasspathdialog|JavaClassPath">Class Path</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
......@@ -89,10 +102,10 @@
<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="javaclasspathdialog|label1">A_ssigned folders and archives</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">paths:border</property>
<property name="mnemonic_widget">paths</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -101,21 +114,44 @@
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="width_request">1</property>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="paths:border">
<object class="GtkTreeView" id="paths">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore1</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection4"/>
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<child>
<object class="GtkCellRendererPixbuf" id="cellrenderertext1"/>
<attributes>
<attribute name="pixbuf">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
......@@ -202,5 +238,8 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
<child>
<placeholder/>
</child>
</object>
</interface>
......@@ -9,7 +9,7 @@
<!-- column-name id -->
<column type="gchararray"/>
<!-- column-name image -->
<column type="gchararray"/>
<column type="GdkPixbuf"/>
</columns>
</object>
<object class="GtkDialog" id="SQLExceptionDialog">
......@@ -137,7 +137,7 @@
<child>
<object class="GtkCellRendererPixbuf" id="cellrenderertext1"/>
<attributes>
<attribute name="icon-name">2</attribute>
<attribute name="pixbuf">2</attribute>
</attributes>
</child>
</object>
......
......@@ -9,7 +9,7 @@
<!-- column-name id -->
<column type="gchararray"/>
<!-- column-name image -->
<column type="gchararray"/>
<column type="GdkPixbuf"/>
</columns>
</object>
<object class="GtkMessageDialog" id="WarnPDFDialog">
......@@ -92,7 +92,7 @@
<child>
<object class="GtkCellRendererPixbuf" id="cellrenderertext1"/>
<attributes>
<attribute name="icon-name">2</attribute>
<attribute name="pixbuf">2</attribute>
</attributes>
</child>
</object>
......
......@@ -20,8 +20,9 @@
#ifndef INCLUDED_SVTOOLS_IMAGEMGR_HXX
#define INCLUDED_SVTOOLS_IMAGEMGR_HXX
#include <svtools/svtdllapi.h>
#include <rtl/ustring.hxx>
#include <sal/types.h>
#include <svtools/svtdllapi.h>
enum class SvImageId {
NONE = 0,
......@@ -79,9 +80,6 @@ enum class SvImageId {
class Image;
namespace rtl {
class OUString;
};
class INetURLObject;
namespace svtools {
......@@ -121,6 +119,7 @@ private:
static rtl::OUString GetDescription_Impl( const INetURLObject& rObject, bool bDetectFolder );
public:
SVT_DLLPUBLIC static OUString GetImageId( const INetURLObject& rURL, bool bBig = false );
SVT_DLLPUBLIC static Image GetImage( const INetURLObject& rURL, bool bBig = false );
SVT_DLLPUBLIC static Image GetFileImage( const INetURLObject& rURL );
SVT_DLLPUBLIC static Image GetImageNoDefault( const INetURLObject& rURL, bool bBig = false );
......
......@@ -1313,14 +1313,19 @@ public:
nInsertedAt = m_xTreeView->InsertEntry(rStr, pos == -1 ? COMBOBOX_APPEND : pos);
else
{
assert((rImage == "dialog-warning" || rImage == "dialog-error" || rImage == "dialog-information") && "unknown stock image");
Image aImage;
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));
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);
}
m_xTreeView->SetEntryData(nInsertedAt, new OUString(rId));
......
......@@ -3000,6 +3000,24 @@ namespace
g_free(pStr);
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;
}
}
class GtkInstanceTreeView : public GtkInstanceContainer, public virtual weld::TreeView
......@@ -3073,13 +3091,33 @@ public:
}
else
{
assert((rImage == "dialog-warning" || rImage == "dialog-error" || rImage == "dialog-information") && "unknown stock image");
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, OUStringToOString(rImage, RTL_TEXTENCODING_UTF8).getStr(),
2, pixbuf,
-1);
if (pixbuf)
g_object_unref(pixbuf);
}
enable_notify_events();
}
......@@ -4349,17 +4387,11 @@ private:
if (icon_name)
{
OUString aIconName(icon_name, strlen(icon_name), RTL_TEXTENCODING_UTF8);
auto xMemStm = ImageTree::get().getImageStream(aIconName, m_aIconTheme, m_aUILang);
if (xMemStm)
GdkPixbuf* pixbuf = load_icon_by_name(aIconName, m_aIconTheme, m_aUILang);
if (pixbuf)
{
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);
GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(pixbuf_loader);
gtk_image_set_from_pixbuf(pImage, pixbuf);
g_object_unref(pixbuf_loader);
g_object_unref(pixbuf);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment