[Libreoffice-commits] core.git: dbaccess/inc dbaccess/source dbaccess/uiconfig vcl/inc vcl/source vcl/unx

Caolán McNamara caolanm at redhat.com
Tue Mar 20 23:23:24 UTC 2018


 dbaccess/inc/bitmaps.hlst             |    3 -
 dbaccess/source/ui/dlg/sqlmessage.cxx |   97 ++++++++++++----------------------
 dbaccess/uiconfig/ui/sqlexception.ui  |   70 ++++++++++++++++++++----
 vcl/inc/bitmaps.hlst                  |    5 +
 vcl/source/app/salvtables.cxx         |    6 +-
 vcl/unx/gtk3/gtk3gtkinst.cxx          |   33 ++++++++---
 6 files changed, 126 insertions(+), 88 deletions(-)

New commits:
commit dd4f1b1bd31daf080dc0420524712dc244e539b5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Mar 20 21:39:00 2018 +0000

    weld OExceptionChainDialog
    
    Change-Id: I0092d2741055ab89ed4a97db9b8fad56144024c2
    Reviewed-on: https://gerrit.libreoffice.org/51678
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/dbaccess/inc/bitmaps.hlst b/dbaccess/inc/bitmaps.hlst
index 17303e2c7151..b12d7c681a9f 100644
--- a/dbaccess/inc/bitmaps.hlst
+++ b/dbaccess/inc/bitmaps.hlst
@@ -26,9 +26,6 @@
 #define REPORTFOLDER_TREE_ICON          "dbaccess/res/reports_16.png"
 #define BMP_NAVIGATION_BTN_UP_SC        "res/fp010.png"
 #define BMP_NAVIGATION_CREATEFOLDER_SC  "res/fp015.png"
-#define BMP_EXCEPTION_ERROR             "dbaccess/res/exerror.png"
-#define BMP_EXCEPTION_WARNING           "dbaccess/res/exwarning.png"
-#define BMP_EXCEPTION_INFO              "dbaccess/res/exinfo.png"
 #define BMP_PRIMARY_KEY                 "dbaccess/res/jo01.png"
 #define BMP_PKEYICON                    "dbaccess/res/pkey.png"
 #define BMP_UP                          "dbaccess/res/sortup.png"
diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx
index 8b9c834220e8..9dfc3c1f84f2 100644
--- a/dbaccess/source/ui/dlg/sqlmessage.cxx
+++ b/dbaccess/source/ui/dlg/sqlmessage.cxx
@@ -25,6 +25,7 @@
 #include <com/sun/star/sdbc/SQLException.hpp>
 #include <com/sun/star/sdb/SQLContext.hpp>
 #include <vcl/fixed.hxx>
+#include <vcl/weld.hxx>
 #include <osl/diagnose.h>
 #include <svtools/treelistbox.hxx>
 #include <svtools/treelistentry.hxx>
@@ -60,19 +61,15 @@ namespace
     private:
         OUString m_defaultImageID;
 
-        mutable Image   m_defaultImage;
-
     public:
-        explicit ImageProvider(const OUString& _defaultImageID)
-            :m_defaultImageID( _defaultImageID )
+        explicit ImageProvider(const OUString& defaultImageID)
+            : m_defaultImageID(defaultImageID)
         {
         }
 
-        Image const & getImage() const
+        const OUString& getImage() const
         {
-            if ( !m_defaultImage )
-                m_defaultImage = Image(BitmapEx(m_defaultImageID));
-            return m_defaultImage;
+            return m_defaultImageID;
         }
     };
 
@@ -86,7 +83,7 @@ namespace
         {
         }
 
-        const OUString&  getLabel() const
+        const OUString& getLabel() const
         {
             return m_label;
         }
@@ -110,18 +107,18 @@ namespace
         std::shared_ptr< ImageProvider > const & getImageProvider( SQLExceptionInfo::TYPE _eType ) const
         {
             std::shared_ptr< ImageProvider >* ppProvider( &m_pErrorImage );
-            OUString sNormalImageID(BMP_EXCEPTION_ERROR);
+            OUString sNormalImageID("dialog-error");
 
             switch ( _eType )
             {
             case SQLExceptionInfo::TYPE::SQLWarning:
                 ppProvider = &m_pWarningsImage;
-                sNormalImageID = BMP_EXCEPTION_WARNING;
+                sNormalImageID = "dialog-warning";
                 break;
 
             case SQLExceptionInfo::TYPE::SQLContext:
                 ppProvider = &m_pInfoImage;
-                sNormalImageID = BMP_EXCEPTION_INFO;
+                sNormalImageID = "dialog-information";
                 break;
 
             default:
@@ -265,19 +262,16 @@ namespace
         }
     }
 
-    void lcl_insertExceptionEntry( SvTreeListBox& _rList, size_t _nElementPos, const ExceptionDisplayInfo& _rEntry )
+    void lcl_insertExceptionEntry(weld::TreeView& rList, size_t nElementPos, const ExceptionDisplayInfo& rEntry)
     {
-        Image aEntryImage( _rEntry.pImageProvider->getImage() );
-        SvTreeListEntry* pListEntry =
-            _rList.InsertEntry( _rEntry.pLabelProvider->getLabel(), aEntryImage, aEntryImage );
-        pListEntry->SetUserData( reinterpret_cast< void* >( _nElementPos ) );
+        rList.append(OUString::number(nElementPos), rEntry.pLabelProvider->getLabel(), rEntry.pImageProvider->getImage());
     }
 }
 
-class OExceptionChainDialog : public ModalDialog
+class OExceptionChainDialog : public weld::GenericDialogController
 {
-    VclPtr<SvTreeListBox>    m_pExceptionList;
-    VclPtr<VclMultiLineEdit> m_pExceptionText;
+    std::unique_ptr<weld::TreeView> m_xExceptionList;
+    std::unique_ptr<weld::TextView> m_xExceptionText;
 
     OUString        m_sStatusLabel;
     OUString        m_sErrorCodeLabel;
@@ -285,49 +279,35 @@ class OExceptionChainDialog : public ModalDialog
     ExceptionDisplayChain   m_aExceptions;
 
 public:
-    OExceptionChainDialog( vcl::Window* pParent, const ExceptionDisplayChain& _rExceptions );
-    virtual ~OExceptionChainDialog() override { disposeOnce(); }
-    virtual void dispose() override
-    {
-        m_pExceptionList.clear();
-        m_pExceptionText.clear();
-        ModalDialog::dispose();
-    }
+    OExceptionChainDialog(weld::Window* pParent, const ExceptionDisplayChain& rExceptions);
 
 protected:
-    DECL_LINK(OnExceptionSelected, SvTreeListBox*, void);
+    DECL_LINK(OnExceptionSelected, weld::TreeView&, void);
 };
 
-OExceptionChainDialog::OExceptionChainDialog(vcl::Window* pParent, const ExceptionDisplayChain& _rExceptions)
-    : ModalDialog(pParent, "SQLExceptionDialog", "dbaccess/ui/sqlexception.ui")
-    , m_aExceptions(_rExceptions)
+OExceptionChainDialog::OExceptionChainDialog(weld::Window* pParent, const ExceptionDisplayChain& rExceptions)
+    : GenericDialogController(pParent, "dbaccess/ui/sqlexception.ui", "SQLExceptionDialog")
+    , m_xExceptionList(m_xBuilder->weld_tree_view("list"))
+    , m_xExceptionText(m_xBuilder->weld_text_view("description"))
+    , m_aExceptions(rExceptions)
 {
-    get(m_pExceptionList, "list");
-    Size aListSize(LogicToPixel(Size(85, 93), MapMode(MapUnit::MapAppFont)));
-    m_pExceptionList->set_width_request(aListSize.Width());
-    m_pExceptionList->set_height_request(aListSize.Height());
-    get(m_pExceptionText, "description");
-    Size aTextSize(LogicToPixel(Size(125, 93), MapMode(MapUnit::MapAppFont)));
-    m_pExceptionText->set_width_request(aTextSize.Width());
-    m_pExceptionText->set_height_request(aTextSize.Height());
+    int nListWidth = m_xExceptionText->get_approximate_digit_width() * 28;
+    int nTextWidth = m_xExceptionText->get_approximate_digit_width() * 42;
+    int nHeight = m_xExceptionList->get_height_rows(6);
+    m_xExceptionList->set_size_request(nListWidth, nHeight);
+    m_xExceptionText->set_size_request(nTextWidth, nHeight);
 
     m_sStatusLabel = DBA_RES( STR_EXCEPTION_STATUS );
     m_sErrorCodeLabel = DBA_RES( STR_EXCEPTION_ERRORCODE );
 
-    m_pExceptionList->SetSelectionMode(SelectionMode::Single);
-    m_pExceptionList->SetDragDropMode(DragDropMode::NONE);
-    m_pExceptionList->EnableInplaceEditing(false);
-    m_pExceptionList->SetStyle(m_pExceptionList->GetStyle() | WB_HASLINES | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HSCROLL);
-
-    m_pExceptionList->SetSelectHdl(LINK(this, OExceptionChainDialog, OnExceptionSelected));
-    m_pExceptionList->SetNodeDefaultImages( );
+    m_xExceptionList->connect_changed(LINK(this, OExceptionChainDialog, OnExceptionSelected));
 
     bool bHave22018 = false;
     size_t elementPos = 0;
 
     for (auto const& elem : m_aExceptions)
     {
-        lcl_insertExceptionEntry(*m_pExceptionList, elementPos, elem);
+        lcl_insertExceptionEntry(*m_xExceptionList, elementPos, elem);
         bHave22018 = elem.sSQLState == "22018";
         ++elementPos;
     }
@@ -344,21 +324,18 @@ OExceptionChainDialog::OExceptionChainDialog(vcl::Window* pParent, const Excepti
         aInfo22018.pImageProvider = aProviderFactory.getImageProvider( SQLExceptionInfo::TYPE::SQLContext );
         m_aExceptions.push_back( aInfo22018 );
 
-        lcl_insertExceptionEntry( *m_pExceptionList, m_aExceptions.size() - 1, aInfo22018 );
+        lcl_insertExceptionEntry(*m_xExceptionList, m_aExceptions.size() - 1, aInfo22018);
     }
 }
 
-IMPL_LINK_NOARG(OExceptionChainDialog, OnExceptionSelected, SvTreeListBox*, void)
+IMPL_LINK_NOARG(OExceptionChainDialog, OnExceptionSelected, weld::TreeView&, void)
 {
-    SvTreeListEntry* pSelected = m_pExceptionList->FirstSelected();
-    OSL_ENSURE(!pSelected || !m_pExceptionList->NextSelected(pSelected), "OExceptionChainDialog::OnExceptionSelected : multi selection ?");
-
     OUString sText;
 
-    if ( pSelected )
+    OUString sId(m_xExceptionList->get_selected_id());
+    if (!sId.isEmpty())
     {
-        size_t pos = reinterpret_cast< size_t >( pSelected->GetUserData() );
-        const ExceptionDisplayInfo& aExceptionInfo( m_aExceptions[ pos ] );
+        const ExceptionDisplayInfo& aExceptionInfo(m_aExceptions[sId.toUInt32()]);
 
         if ( !aExceptionInfo.sSQLState.isEmpty() )
         {
@@ -376,7 +353,7 @@ IMPL_LINK_NOARG(OExceptionChainDialog, OnExceptionSelected, SvTreeListBox*, void
         sText += aExceptionInfo.sMessage;
     }
 
-    m_pExceptionText->SetText(sText);
+    m_xExceptionText->set_text(sText);
 }
 
 // SQLMessageBox_Impl
@@ -582,7 +559,7 @@ void OSQLMessageBox::impl_addDetailsButton()
         }
     }
 
-    if ( bMoreDetailsAvailable )
+    if ( bMoreDetailsAvailable || true )
     {
         AddButton( StandardButtonType::More, RET_MORE);
         PushButton* pButton = GetPushButton( RET_MORE );
@@ -677,8 +654,8 @@ void OSQLMessageBox::dispose()
 
 IMPL_LINK_NOARG( OSQLMessageBox, ButtonClickHdl, Button *, void )
 {
-    ScopedVclPtrInstance< OExceptionChainDialog > aDlg( this, m_pImpl->aDisplayInfo );
-    aDlg->Execute();
+    OExceptionChainDialog aDlg(GetFrameWeld(), m_pImpl->aDisplayInfo);
+    aDlg.run();
 }
 
 // OSQLWarningBox
diff --git a/dbaccess/uiconfig/ui/sqlexception.ui b/dbaccess/uiconfig/ui/sqlexception.ui
index 6a2894814506..4d2d6117774c 100644
--- a/dbaccess/uiconfig/ui/sqlexception.ui
+++ b/dbaccess/uiconfig/ui/sqlexception.ui
@@ -1,13 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.2 -->
 <interface domain="dba">
   <requires lib="gtk+" version="3.18"/>
-  <requires lib="LibreOffice" version="1.0"/>
+  <object class="GtkListStore" id="liststore1">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+      <!-- column-name image -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="SQLExceptionDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="sqlexception|SQLExceptionDialog">Error Details</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">
@@ -54,10 +65,10 @@
               <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="sqlexception|label2">Error _list:</property>
                 <property name="use_underline">True</property>
-                <property name="mnemonic_widget">list:border</property>
+                <property name="mnemonic_widget">list</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
@@ -68,10 +79,10 @@
               <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="sqlexception|label3">_Description:</property>
                 <property name="use_underline">True</property>
-                <property name="mnemonic_widget">description:border</property>
+                <property name="mnemonic_widget">description</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">1</property>
@@ -86,7 +97,7 @@
                 <property name="vexpand">True</property>
                 <property name="shadow_type">in</property>
                 <child>
-                  <object class="GtkTextView" id="description:border">
+                  <object class="GtkTextView" id="description">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="hexpand">True</property>
@@ -101,13 +112,47 @@
               </packing>
             </child>
             <child>
-              <object class="svtlo-SvTreeListBox" id="list:border">
+              <object class="GtkScrolledWindow" id="scrolledwindow2">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
-                <child internal-child="selection">
-                  <object class="GtkTreeSelection" id="Tree List-selection1"/>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkTreeView" id="list">
+                    <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-selection1"/>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                        <child>
+                          <object class="GtkCellRendererPixbuf" id="cellrenderertext1"/>
+                          <attributes>
+                            <attribute name="icon-name">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>
               </object>
               <packing>
@@ -127,5 +172,8 @@
     <action-widgets>
       <action-widget response="-5">ok</action-widget>
     </action-widgets>
+    <child>
+      <placeholder/>
+    </child>
   </object>
 </interface>
diff --git a/vcl/inc/bitmaps.hlst b/vcl/inc/bitmaps.hlst
index f3cf68890eb2..788a5c965235 100644
--- a/vcl/inc/bitmaps.hlst
+++ b/vcl/inc/bitmaps.hlst
@@ -138,8 +138,9 @@
 #define SPINNER_64_12                                "vcl/res/spinner-64-12.png"
 //end, Throbber::getDefaultImageURLs
 
-#define IMG_WARN "res/ballgreen_7.png"
-#define IMG_ERR  "res/ballred_7.png"
+#define IMG_WARN    "dbaccess/res/exwarning.png"
+#define IMG_ERROR   "dbaccess/res/exerror.png"
+#define IMG_INFO    "dbaccess/res/exinfo.png"
 
 #endif
 
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 62b923f98cb8..63db48d4a1de 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -870,12 +870,14 @@ public:
             nInsertedAt = m_xTreeView->InsertEntry(rStr, pos == -1 ? COMBOBOX_APPEND : pos);
         else
         {
-            assert((rImage == "dialog-warning" || rImage == "dialog-error") && "unknown stock image");
+            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_ERR));
+                aImage = Image(BitmapEx(IMG_ERROR));
+            else if (rImage == "dialog-information")
+                aImage = Image(BitmapEx(IMG_INFO));
             nInsertedAt = m_xTreeView->InsertEntry(rStr, aImage, pos == -1 ? COMBOBOX_APPEND : pos);
         }
         m_xTreeView->SetEntryData(nInsertedAt, new OUString(rId));
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index dbb4320f7024..3c825d167061 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -2130,7 +2130,7 @@ public:
         }
         else
         {
-            assert((rImage == "dialog-warning" || rImage == "dialog-error") && "unknown stock image");
+            assert((rImage == "dialog-warning" || rImage == "dialog-error" || rImage == "dialog-information") && "unknown stock image");
 
             gtk_list_store_set(m_pListStore, &iter,
                     0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(),
@@ -2268,24 +2268,34 @@ public:
 
     virtual int get_height_rows(int nRows) const override
     {
-        GtkTreeViewColumn* pColumn = gtk_tree_view_get_column(m_pTreeView, 0);
-        GList *pRenderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(pColumn));
-        GtkCellRenderer* pRenderer = GTK_CELL_RENDERER(g_list_nth_data(pRenderers, 0));
-        gint nRowHeight;
-        gtk_cell_renderer_get_preferred_height(pRenderer, GTK_WIDGET(m_pTreeView), nullptr, &nRowHeight);
-        g_list_free(pRenderers);
+        gint nMaxRowHeight = 0;
+        GList *pColumns = gtk_tree_view_get_columns(m_pTreeView);
+        for (GList* pEntry = g_list_first(pColumns); pEntry; pEntry = g_list_next(pEntry))
+        {
+            GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(pEntry->data);
+            GList *pRenderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(pColumn));
+            GtkCellRenderer* pRenderer = GTK_CELL_RENDERER(g_list_nth_data(pRenderers, 0));
+            gint nRowHeight;
+            gtk_cell_renderer_get_preferred_height(pRenderer, GTK_WIDGET(m_pTreeView), nullptr, &nRowHeight);
+            nMaxRowHeight = std::max(nMaxRowHeight, nRowHeight);
+            g_list_free(pRenderers);
+        }
+        g_list_free(pColumns);
 
         gint nVerticalSeparator;
         gtk_widget_style_get(GTK_WIDGET(m_pTreeView), "vertical-separator", &nVerticalSeparator, nullptr);
 
-        return (nRowHeight * nRows) + (nVerticalSeparator * (nRows + 1));
+        return (nMaxRowHeight * nRows) + (nVerticalSeparator * (nRows + 1));
     }
 
     virtual void set_size_request(int nWidth, int nHeight) override
     {
         GtkWidget* pParent = gtk_widget_get_parent(m_pWidget);
         if (GTK_IS_SCROLLED_WINDOW(pParent))
-            gtk_widget_set_size_request(pParent, nWidth, nHeight);
+        {
+            gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(pParent), nWidth);
+            gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(pParent), nHeight);
+        }
         else
             gtk_widget_set_size_request(m_pWidget, nWidth, nHeight);
     }
@@ -2461,7 +2471,10 @@ public:
     {
         GtkWidget* pParent = gtk_widget_get_parent(m_pWidget);
         if (GTK_IS_SCROLLED_WINDOW(pParent))
-            gtk_widget_set_size_request(pParent, nWidth, nHeight);
+        {
+            gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(pParent), nWidth);
+            gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(pParent), nHeight);
+        }
         else
             gtk_widget_set_size_request(m_pWidget, nWidth, nHeight);
     }


More information about the Libreoffice-commits mailing list