diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-07-01 12:47:58 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-07-01 12:55:03 +0100 |
commit | 3af5cc2797277082dc82f531d08bfbf90df31306 (patch) | |
tree | 5c95cb4e6ef5041254081ae77c0078b9243a7f5c | |
parent | 2e874cb1079d552147362058a3fb837e8706def6 (diff) |
prototype native gtk3 .ui loading message dialogfeature/gtk3nativedialogs
native gtkbuilder loading our .ui files
Change-Id: Iff07d8d0d92e0c0f67fb10605f7329d46235aeff
-rw-r--r-- | include/vcl/outdev.hxx | 2 | ||||
-rw-r--r-- | sfx2/uiconfig/ui/querysavedialog.ui | 8 | ||||
-rw-r--r-- | vcl/inc/salinst.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkinst.hxx | 1 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 7 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 14 | ||||
-rw-r--r-- | vcl/source/window/syswin.cxx | 3 | ||||
-rw-r--r-- | vcl/unx/gtk3/app/gtk3gtkinst.cxx | 78 |
8 files changed, 108 insertions, 9 deletions
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 9af2f62a63cf..e4be6113692c 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -350,7 +350,7 @@ public: virtual ~VclPtrRefCountBase(); }; -class VCL_DLLPUBLIC OutputDevice : public VclPtrRefCountBase +class VCL_DLLPUBLIC OutputDevice : public virtual VclPtrRefCountBase { friend class PaintHelper; friend class Printer; diff --git a/sfx2/uiconfig/ui/querysavedialog.ui b/sfx2/uiconfig/ui/querysavedialog.ui index b9f1e1be873e..129f1e3fc87d 100644 --- a/sfx2/uiconfig/ui/querysavedialog.ui +++ b/sfx2/uiconfig/ui/querysavedialog.ui @@ -4,7 +4,6 @@ <requires lib="gtk+" version="3.0"/> <object class="GtkMessageDialog" id="QuerySaveDialog"> <property name="can_focus">False</property> - <property name="border_width">6</property> <property name="title" translatable="yes">Save Document?</property> <property name="resizable">False</property> <property name="type_hint">dialog</property> @@ -15,12 +14,15 @@ <child internal-child="vbox"> <object class="GtkBox" id="messagedialog-vbox"> <property name="can_focus">False</property> + <property name="margin_top">6</property> <property name="orientation">vertical</property> <property name="spacing">12</property> <child internal-child="action_area"> <object class="GtkButtonBox" id="messagedialog-action_area"> <property name="can_focus">False</property> - <property name="layout_style">end</property> + <property name="margin_top">6</property> + <property name="hexpand">True</property> + <property name="layout_style">expand</property> <child> <object class="GtkButton" id="discard"> <property name="label" translatable="yes">_Don’t Save</property> @@ -68,7 +70,7 @@ </child> </object> <packing> - <property name="expand">False</property> + <property name="expand">True</property> <property name="fill">True</property> <property name="pack_type">end</property> <property name="position">0</property> diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx index 4ad66af11a7f..f6268da24d3d 100644 --- a/vcl/inc/salinst.hxx +++ b/vcl/inc/salinst.hxx @@ -28,6 +28,7 @@ #include "tools/solar.h" #include "displayconnectiondispatch.hxx" #include "vcl/dllapi.h" +#include "vcl/window.hxx" #include <sal/types.h> #include "rtl/ref.hxx" @@ -55,6 +56,7 @@ struct SalItemParams; class SalSession; struct SystemGraphicsData; struct SystemWindowData; +class MessageDialogImpl; class Menu; enum class VclInputFlags; @@ -80,6 +82,8 @@ public: virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow = true ) = 0; virtual void DestroyObject( SalObject* pObject ) = 0; + virtual VclPtr<MessageDialogImpl> CreateSalDialog(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription); + // VirtualDevice // nDX and nDY in pixels // nBitCount: 0 == default(=as window) / 1 == mono diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx index 9a11df1093d9..4f779ecc802b 100644 --- a/vcl/inc/unx/gtk/gtkinst.hxx +++ b/vcl/inc/unx/gtk/gtkinst.hxx @@ -96,6 +96,7 @@ public: #if GTK_CHECK_VERSION(3,0,0) virtual css::uno::Reference< css::uno::XInterface > CreateClipboard( const css::uno::Sequence< css::uno::Any >& i_rArguments ) SAL_OVERRIDE; + virtual VclPtr<MessageDialogImpl> CreateSalDialog(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription) SAL_OVERRIDE; #endif void RemoveTimer (SalTimer *pTimer); diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 4c5636372a48..ffa6f084dc25 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -27,7 +27,7 @@ #include <salbmp.hxx> #include <salobj.hxx> #include <salmenu.hxx> - +#include <vcl/layout.hxx> SalFrame::SalFrame() : m_bPaintsBlocked(false) @@ -93,6 +93,11 @@ void SalInstance::DestroyMenuItem( SalMenuItem* pItem ) OSL_ENSURE( pItem == 0, "DestroyMenu called with non-native menus" ); } +VclPtr<MessageDialogImpl> SalInstance::CreateSalDialog(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription) +{ + return VclPtr<VclMessageDialog>::Create(pParent, rID, rUIXMLDescription); +} + SalTimer::~SalTimer() { } diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index cf44b0930f0d..d8aab933664e 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -14,6 +14,8 @@ #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include "window.h" +#include "svdata.hxx" +#include "salinst.hxx" VclContainer::VclContainer(vcl::Window *pParent, WinBits nStyle) : Window(WINDOW_CONTAINER) @@ -1978,9 +1980,8 @@ MessageDialogImpl::~MessageDialogImpl() MessageDialog::MessageDialog(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription) { -// SalFrame* pParentFrame = pParent ? pParent->mpWindowImpl->mpFrame : NULL; -// m_pImpl = pSVData->mpDefInst->CreateChildFrame( pSystemParentData, nFrameStyle | SAL_FRAME_STYLE_PLUG ); - m_pImpl = new VclMessageDialog(pParent, rID, rUIXMLDescription); + ImplSVData* pSVData = ImplGetSVData(); + m_xImpl = pSVData->mpDefInst->CreateSalDialog(pParent, rID, rUIXMLDescription); } MessageDialog::MessageDialog(vcl::Window* pParent, const OUString &rMessage, VclMessageType eMessageType, @@ -1988,7 +1989,12 @@ MessageDialog::MessageDialog(vcl::Window* pParent, const OUString &rMessage, Vcl { // SalFrame* pParentFrame = pParent ? pParent->mpWindowImpl->mpFrame : NULL; // m_pImpl = pSVData->mpDefInst->CreateChildFrame( pSystemParentData, nFrameStyle | SAL_FRAME_STYLE_PLUG ); - m_pImpl = new VclMessageDialog(pParent, rMessage, eMessageType, eButtonsType); + m_xImpl = VclPtr<VclMessageDialog>::Create(pParent, rMessage, eMessageType, eButtonsType); +} + +MessageDialog::~MessageDialog() +{ + disposeOnce(); } void VclMessageDialog::create_owned_areas() diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index c08a60168a93..0bc02e5e0614 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -93,6 +93,7 @@ SystemWindow::SystemWindow(WindowType nType) : Window(nType) , mbIsDefferedInit(false) { + fprintf(stderr, "SystemWindow ctor %p\n", this); Init(); } @@ -106,11 +107,13 @@ void SystemWindow::loadUI(vcl::Window* pParent, const OString& rID, const OUStri SystemWindow::~SystemWindow() { + fprintf(stderr, "SystemWindow dtor %p\n", this); disposeOnce(); } void SystemWindow::dispose() { + fprintf(stderr, "SystemWindow dispose %p\n", this); maLayoutIdle.Stop(); delete mpImplData; mpImplData = NULL; diff --git a/vcl/unx/gtk3/app/gtk3gtkinst.cxx b/vcl/unx/gtk3/app/gtk3gtkinst.cxx index 2dedd2de8bb7..e076d690285d 100644 --- a/vcl/unx/gtk3/app/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/app/gtk3gtkinst.cxx @@ -28,6 +28,7 @@ #include "cppuhelper/compbase.hxx" #include "cppuhelper/implbase1.hxx" #include <cppuhelper/supportsservice.hxx> +#include <vcl/layout.hxx> using namespace com::sun::star; using namespace com::sun::star::uno; @@ -628,4 +629,81 @@ Reference< XInterface > GtkInstance::CreateClipboard(const Sequence< Any >& argu return Reference< XInterface >( static_cast<cppu::OWeakObject *>(new VclGtkClipboard()) ); } +class SalMessageDialog : public MessageDialogImpl +{ +private: + GtkBuilder *m_pBuilder; + GtkWidget *m_pDialog; +public: + SalMessageDialog(vcl::Window* /*pParent*/, const OString& rID, const OUString& rUIXMLDescription) + { + OUString sURL = VclBuilderContainer::getUIRootDir() + rUIXMLDescription; + OUString sFileName; + osl::FileBase::getSystemPathFromFileURL(sURL, sFileName); + + m_pBuilder = gtk_builder_new_from_file(OUStringToOString(sFileName, RTL_TEXTENCODING_UTF8).getStr()); + + m_pDialog = GTK_WIDGET(gtk_builder_get_object(m_pBuilder, rID.getStr())); + + gtk_window_set_title(GTK_WINDOW(m_pDialog), ""); + } + + virtual void set_title(const OUString &rTitle) SAL_OVERRIDE + { + gtk_window_set_title(GTK_WINDOW(m_pDialog), OUStringToOString(rTitle, RTL_TEXTENCODING_UTF8).getStr()); + } + + virtual short Execute() SAL_OVERRIDE + { + gint nStatus = gtk_dialog_run(GTK_DIALOG(m_pDialog)); + gtk_widget_hide(m_pDialog); + return nStatus; + } + + ///Emitted when an action widget is clicked + virtual void response(short /*nResponseId*/) SAL_OVERRIDE + { + } + + OUString get_primary_text() const SAL_OVERRIDE + { + gchar *text; + g_object_get(m_pDialog, "text", &text, NULL); + return OUString(text, rtl_str_getLength(text), RTL_TEXTENCODING_UTF8); + } + + OUString get_secondary_text() const SAL_OVERRIDE + { + gchar *text; + g_object_get(m_pDialog, "secondary-text", &text, NULL); + return OUString(text, rtl_str_getLength(text), RTL_TEXTENCODING_UTF8); + } + + void set_primary_text(const OUString &rPrimaryString) SAL_OVERRIDE + { + g_object_set(m_pDialog, "text", OUStringToOString(rPrimaryString, RTL_TEXTENCODING_UTF8).getStr(), NULL); + } + + void set_secondary_text(const OUString &rSecondaryString) SAL_OVERRIDE + { + g_object_set(m_pDialog, "secondary-text", OUStringToOString(rSecondaryString, RTL_TEXTENCODING_UTF8).getStr(), NULL); + } + + virtual void dispose() SAL_OVERRIDE + { + g_object_unref(G_OBJECT(m_pBuilder)); + } + + virtual ~SalMessageDialog() + { + disposeOnce(); + } +}; + +VclPtr<MessageDialogImpl> GtkInstance::CreateSalDialog(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription) +{ + return VclPtr<SalMessageDialog>::Create(pParent, rID, rUIXMLDescription); +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |