[Libreoffice-commits] core.git: sfx2/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue May 21 07:56:05 UTC 2019


 sfx2/source/dialog/tabdlg.cxx |    4 +-
 vcl/unx/gtk3/gtk3gtkinst.cxx  |   58 +++++++++++++++++++++++++-----------------
 2 files changed, 37 insertions(+), 25 deletions(-)

New commits:
commit 0d2472f01375261e354225017b6422ca29899247
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon May 20 20:38:14 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue May 21 09:54:39 2019 +0200

    route delete-event through cancel handler if available
    
    for sync gtk dialogs too
    
    Change-Id: Iad40c539a663504d72f372a0d3b4427a23e717c4
    Reviewed-on: https://gerrit.libreoffice.org/72626
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 32ab60c49776..79e2ad750ada 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -1352,14 +1352,14 @@ IMPL_LINK_NOARG(SfxTabDialogController, UserHdl, weld::Button&, void)
         if (RET_OK == nRet)
             nRet = RET_USER;
         else
-            nRet = RET_USER_CANCEL;
+            nRet = RET_CANCEL;
         m_xDialog->response(nRet);
     }
 }
 
 IMPL_LINK_NOARG(SfxTabDialogController, CancelHdl, weld::Button&, void)
 {
-    m_xDialog->response(RET_USER_CANCEL);
+    m_xDialog->response(RET_CANCEL);
 }
 
 IMPL_LINK_NOARG(SfxTabDialogController, ResetHdl, weld::Button&, void)
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index bfdfb055063d..a39edc1abf07 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -2841,16 +2841,20 @@ namespace
     }
 }
 
+class GtkInstanceDialog;
+
 struct DialogRunner
 {
     GtkDialog *m_pDialog;
+    GtkInstanceDialog *m_pInstance;
     gint m_nResponseId;
     GMainLoop *m_pLoop;
     VclPtr<vcl::Window> m_xFrameWindow;
     int m_nModalDepth;
 
-    DialogRunner(GtkDialog* pDialog)
+    DialogRunner(GtkDialog* pDialog, GtkInstanceDialog* pInstance)
        : m_pDialog(pDialog)
+       , m_pInstance(pInstance)
        , m_nResponseId(GTK_RESPONSE_NONE)
        , m_pLoop(nullptr)
        , m_nModalDepth(0)
@@ -2871,12 +2875,7 @@ struct DialogRunner
             g_main_loop_quit(m_pLoop);
     }
 
-    static void signal_response(GtkDialog*, gint nResponseId, gpointer data)
-    {
-        DialogRunner* pThis = static_cast<DialogRunner*>(data);
-        pThis->m_nResponseId = nResponseId;
-        pThis->loop_quit();
-    }
+    static void signal_response(GtkDialog*, gint nResponseId, gpointer data);
 
     static gboolean signal_delete(GtkDialog*, GdkEventAny*, gpointer data)
     {
@@ -3017,7 +3016,10 @@ private:
     int m_nOldEditWidthReq; // Original width request of the input field
     int m_nOldBorderWidth; // border width for expanded dialog
 
-    void signal_close();
+    void signal_close()
+    {
+        close(true);
+    }
 
     static void signalClose(GtkWidget*, gpointer widget)
     {
@@ -3059,7 +3061,7 @@ public:
     GtkInstanceDialog(GtkDialog* pDialog, GtkInstanceBuilder* pBuilder, bool bTakeOwnership)
         : GtkInstanceWindow(GTK_WINDOW(pDialog), pBuilder, bTakeOwnership)
         , m_pDialog(pDialog)
-        , m_aDialogRun(pDialog)
+        , m_aDialogRun(pDialog, this)
         , m_nCloseSignalId(g_signal_connect(m_pDialog, "close", G_CALLBACK(signalClose), this))
         , m_nResponseSignalId(0)
         , m_nSignalDeleteId(0)
@@ -3255,6 +3257,8 @@ public:
         present();
     }
 
+    void close(bool bCloseSignal);
+
     virtual void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>&) override
     {
         //not implemented for the gtk variant
@@ -3277,6 +3281,21 @@ public:
     }
 };
 
+void DialogRunner::signal_response(GtkDialog*, gint nResponseId, gpointer data)
+{
+    DialogRunner* pThis = static_cast<DialogRunner*>(data);
+
+    // make GTK_RESPONSE_DELETE_EVENT act as if cancel button was pressed
+    if (nResponseId == GTK_RESPONSE_DELETE_EVENT)
+    {
+        pThis->m_pInstance->close(false);
+        return;
+    }
+
+    pThis->m_nResponseId = nResponseId;
+    pThis->loop_quit();
+}
+
 class GtkInstanceMessageDialog : public GtkInstanceDialog, public virtual weld::MessageDialog
 {
 private:
@@ -4602,7 +4621,7 @@ void GtkInstanceDialog::asyncresponse(gint ret)
     {
         // make GTK_RESPONSE_DELETE_EVENT act as if cancel button was pressed
         if (ret == GTK_RESPONSE_DELETE_EVENT)
-            pClickHandler->clicked();
+            close(false);
         return;
     }
 
@@ -4627,16 +4646,8 @@ int GtkInstanceDialog::run()
             help();
             continue;
         }
-
-        GtkInstanceButton* pClickHandler = has_click_handler(ret);
-        if (pClickHandler)
-        {
-            // make GTK_RESPONSE_DELETE_EVENT act as if cancel button was pressed
-            if (ret == GTK_RESPONSE_DELETE_EVENT)
-                pClickHandler->clicked();
+        else if (has_click_handler(ret))
             continue;
-        }
-
         break;
     }
     hide();
@@ -4664,14 +4675,15 @@ void GtkInstanceDialog::response(int nResponse)
     gtk_dialog_response(m_pDialog, VclToGtk(nResponse));
 }
 
-
-void GtkInstanceDialog::signal_close()
+void GtkInstanceDialog::close(bool bCloseSignal)
 {
     GtkInstanceButton* pClickHandler = has_click_handler(GTK_RESPONSE_CANCEL);
     if (pClickHandler)
     {
-        g_signal_stop_emission_by_name(m_pDialog, "close");
-        // make esc act as if cancel button was pressed
+        if (bCloseSignal)
+            g_signal_stop_emission_by_name(m_pDialog, "close");
+        // make esc (bCloseSignal == true) or window-delete (bCloseSignal == false)
+        // act as if cancel button was pressed
         pClickHandler->clicked();
         return;
     }


More information about the Libreoffice-commits mailing list