d95352c
From 42b3f8f57ad7cdb26fb8acb139c71ae1470a0b94 Mon Sep 17 00:00:00 2001
d95352c
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
d95352c
Date: Wed, 9 Jan 2019 09:48:07 +0000
d95352c
Subject: [PATCH] Resolves: tdf#122467 drop down field name is too narrow
d95352c
d95352c
ellipise only when we have to
d95352c
d95352c
Change-Id: I79820dc84fc9ac0a755700c70bca9edbb14cf371
d95352c
Reviewed-on: https://gerrit.libreoffice.org/66001
d95352c
Tested-by: Jenkins
d95352c
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
d95352c
---
d95352c
 dbaccess/uiconfig/ui/queryfilterdialog.ui | 20 ++++++++--------
d95352c
 vcl/unx/gtk3/gtk3gtkinst.cxx              | 28 +++++++++++++++--------
d95352c
 2 files changed, 29 insertions(+), 19 deletions(-)
d95352c
d95352c
diff --git a/dbaccess/uiconfig/ui/queryfilterdialog.ui b/dbaccess/uiconfig/ui/queryfilterdialog.ui
d95352c
index a52ea3651ba3..46164e2f503d 100644
d95352c
--- a/dbaccess/uiconfig/ui/queryfilterdialog.ui
d95352c
+++ b/dbaccess/uiconfig/ui/queryfilterdialog.ui
d95352c
@@ -99,7 +99,6 @@
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">False</property>
d95352c
                         <property name="label" translatable="yes" context="queryfilterdialog|label2">Operator</property>
d95352c
-                        <property name="ellipsize">end</property>
d95352c
                         <property name="xalign">0</property>
d95352c
                       </object>
d95352c
                       <packing>
d95352c
@@ -112,7 +111,6 @@
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">False</property>
d95352c
                         <property name="label" translatable="yes" context="queryfilterdialog|label5">Field name</property>
d95352c
-                        <property name="ellipsize">end</property>
d95352c
                       </object>
d95352c
                       <packing>
d95352c
                         <property name="left_attach">1</property>
d95352c
@@ -124,7 +122,6 @@
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">False</property>
d95352c
                         <property name="label" translatable="yes" context="queryfilterdialog|label6">Condition</property>
d95352c
-                        <property name="ellipsize">end</property>
d95352c
                       </object>
d95352c
                       <packing>
d95352c
                         <property name="left_attach">2</property>
d95352c
@@ -135,7 +132,7 @@
d95352c
                       <object class="GtkComboBoxText" id="field1">
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">False</property>
d95352c
-                        <property name="hexpand">True</property>
d95352c
+                        <property name="active">0</property>
d95352c
                         <items>
d95352c
                           <item translatable="yes" context="queryfilterdialog|field1">- none -</item>
d95352c
                         </items>
d95352c
@@ -150,6 +147,7 @@
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">False</property>
d95352c
                         <property name="hexpand">True</property>
d95352c
+                        <property name="active">0</property>
d95352c
                         <items>
d95352c
                           <item translatable="yes" context="queryfilterdialog|cond1">=</item>
d95352c
                           <item translatable="yes" context="queryfilterdialog|cond1"><></item>
d95352c
@@ -172,7 +170,7 @@
d95352c
                       <object class="GtkComboBoxText" id="field2">
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">False</property>
d95352c
-                        <property name="hexpand">True</property>
d95352c
+                        <property name="active">0</property>
d95352c
                         <items>
d95352c
                           <item translatable="yes" context="queryfilterdialog|field2">- none -</item>
d95352c
                         </items>
d95352c
@@ -186,7 +184,7 @@
d95352c
                       <object class="GtkComboBoxText" id="field3">
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">False</property>
d95352c
-                        <property name="hexpand">True</property>
d95352c
+                        <property name="active">0</property>
d95352c
                         <items>
d95352c
                           <item translatable="yes" context="queryfilterdialog|field3">- none -</item>
d95352c
                         </items>
d95352c
@@ -201,6 +199,7 @@
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">False</property>
d95352c
                         <property name="hexpand">True</property>
d95352c
+                        <property name="active">0</property>
d95352c
                       </object>
d95352c
                       <packing>
d95352c
                         <property name="left_attach">2</property>
d95352c
@@ -212,6 +211,7 @@
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">False</property>
d95352c
                         <property name="hexpand">True</property>
d95352c
+                        <property name="active">0</property>
d95352c
                       </object>
d95352c
                       <packing>
d95352c
                         <property name="left_attach">2</property>
d95352c
@@ -223,7 +223,6 @@
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">False</property>
d95352c
                         <property name="label" translatable="yes" context="queryfilterdialog|label7">Value</property>
d95352c
-                        <property name="ellipsize">end</property>
d95352c
                       </object>
d95352c
                       <packing>
d95352c
                         <property name="left_attach">3</property>
d95352c
@@ -234,6 +233,7 @@
d95352c
                       <object class="GtkEntry" id="value1">
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">True</property>
d95352c
+                        <property name="hexpand">True</property>
d95352c
                         <property name="activates_default">True</property>
d95352c
                       </object>
d95352c
                       <packing>
d95352c
@@ -245,6 +245,7 @@
d95352c
                       <object class="GtkEntry" id="value2">
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">True</property>
d95352c
+                        <property name="hexpand">True</property>
d95352c
                         <property name="activates_default">True</property>
d95352c
                       </object>
d95352c
                       <packing>
d95352c
@@ -256,6 +257,7 @@
d95352c
                       <object class="GtkEntry" id="value3">
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">True</property>
d95352c
+                        <property name="hexpand">True</property>
d95352c
                         <property name="activates_default">True</property>
d95352c
                       </object>
d95352c
                       <packing>
d95352c
@@ -267,7 +269,7 @@
d95352c
                       <object class="GtkComboBoxText" id="op2">
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">False</property>
d95352c
-                        <property name="hexpand">True</property>
d95352c
+                        <property name="active">0</property>
d95352c
                         <items>
d95352c
                           <item translatable="yes" context="queryfilterdialog|op2">AND</item>
d95352c
                           <item translatable="yes" context="queryfilterdialog|op2">OR</item>
d95352c
@@ -282,7 +284,7 @@
d95352c
                       <object class="GtkComboBoxText" id="op3">
d95352c
                         <property name="visible">True</property>
d95352c
                         <property name="can_focus">False</property>
d95352c
-                        <property name="hexpand">True</property>
d95352c
+                        <property name="active">0</property>
d95352c
                         <items>
d95352c
                           <item translatable="yes" context="queryfilterdialog|op3">AND</item>
d95352c
                           <item translatable="yes" context="queryfilterdialog|op3">OR</item>
d95352c
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
d95352c
index 0165b6888864..c440cd45189e 100644
d95352c
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
d95352c
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
d95352c
@@ -6348,6 +6348,7 @@ class GtkInstanceComboBox : public GtkInstanceContainer, public vcl::ISearchable
d95352c
 private:
d95352c
     GtkComboBox* m_pComboBox;
d95352c
     GtkTreeModel* m_pTreeModel;
d95352c
+    GtkCellRenderer* m_pTextRenderer;
d95352c
     GtkMenu* m_pMenu;
d95352c
     std::unique_ptr<comphelper::string::NaturalStringSorter> m_xSorter;
d95352c
     vcl::QuickSelectionEngine m_aQuickSelectionEngine;
d95352c
@@ -6660,23 +6661,19 @@ public:
d95352c
         if (!g_list_length(cells))
d95352c
         {
d95352c
             //Always use the same text column renderer layout
d95352c
-            GtkCellRenderer* text_renderer = gtk_cell_renderer_text_new();
d95352c
-            gtk_cell_layout_pack_end(GTK_CELL_LAYOUT(m_pComboBox), text_renderer, true);
d95352c
-            gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(m_pComboBox), text_renderer, "text", 0, nullptr);
d95352c
-            g_object_set(G_OBJECT(text_renderer), "ellipsize", PANGO_ELLIPSIZE_MIDDLE, nullptr);
d95352c
+            m_pTextRenderer = gtk_cell_renderer_text_new();
d95352c
+            gtk_cell_layout_pack_end(GTK_CELL_LAYOUT(m_pComboBox), m_pTextRenderer, true);
d95352c
+            gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(m_pComboBox), m_pTextRenderer, "text", 0, nullptr);
d95352c
         }
d95352c
         else
d95352c
         {
d95352c
-            // this bit isn't great, I really want to be able to ellipse the text in the comboboxtext itself and let
d95352c
-            // the popup menu render them in full, in the interim allow the text to wrap in both cases
d95352c
-            GtkCellRenderer* cell = static_cast<GtkCellRenderer*>(cells->data);
d95352c
-            g_object_set(G_OBJECT(cell), "ellipsize", PANGO_ELLIPSIZE_MIDDLE, nullptr);
d95352c
+            m_pTextRenderer = static_cast<GtkCellRenderer*>(cells->data);
d95352c
             if (g_list_length(cells) == 2)
d95352c
             {
d95352c
                 //The ComboBox is always going to show the column associated with
d95352c
                 //the entry when there is one, left to its own devices this image
d95352c
                 //column will be after it, but we want it before
d95352c
-                gtk_cell_layout_reorder(GTK_CELL_LAYOUT(m_pComboBox), cell, 1);
d95352c
+                gtk_cell_layout_reorder(GTK_CELL_LAYOUT(m_pComboBox), m_pTextRenderer, 1);
d95352c
             }
d95352c
         }
d95352c
         g_list_free(cells);
d95352c
@@ -6723,7 +6720,18 @@ public:
d95352c
         GtkCellRenderer* cell = static_cast<GtkCellRenderer*>(cells->data);
d95352c
         GtkRequisition size;
d95352c
         gtk_cell_renderer_get_preferred_size(cell, m_pWidget, &size, nullptr);
d95352c
-        gtk_cell_renderer_set_fixed_size(cell, nWidth, size.height);
d95352c
+        if (nWidth < size.width)
d95352c
+        {
d95352c
+            // this bit isn't great, I really want to be able to ellipse the text in the comboboxtext itself and let
d95352c
+            // the popup menu render them in full, in the interim ellipse both
d95352c
+            g_object_set(G_OBJECT(m_pTextRenderer), "ellipsize", PANGO_ELLIPSIZE_MIDDLE, nullptr);
d95352c
+            gtk_cell_renderer_set_fixed_size(cell, nWidth, size.height);
d95352c
+        }
d95352c
+        else
d95352c
+        {
d95352c
+            g_object_set(G_OBJECT(m_pTextRenderer), "ellipsize", PANGO_ELLIPSIZE_NONE, nullptr);
d95352c
+            gtk_cell_renderer_set_fixed_size(cell, size.width, size.height);
d95352c
+        }
d95352c
         g_list_free(cells);
d95352c
 
d95352c
         gtk_widget_set_size_request(m_pWidget, nWidth, nHeight);
d95352c
-- 
d95352c
2.21.0.rc1
d95352c