diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-09-15 10:55:28 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-09-15 13:30:31 +0200 |
commit | a258237a3d25e704b215ef7b4d75e499abe4b20a (patch) | |
tree | 83695d64506cc31d1463d1d1ce7842f3ef027227 /vcl | |
parent | 95a6352da62725d1512c2e93e351684a89859cd4 (diff) |
gtk4: allow combobox text width to shrink smaller than natural request
Change-Id: I9648097ca9f77494ec4ddb2662dbc0372b998cd4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122140
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/gtk3/gtkinst.cxx | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 3899bb35c29f..afcad3c4de7b 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -17438,7 +17438,7 @@ private: // GtkMenuButton* m_pOverlayButton; // button that the StyleDropdown uses on an active row GtkWidget* m_pMenuWindow; GtkTreeModel* m_pTreeModel; -// GtkCellRenderer* m_pButtonTextRenderer; + GtkCellRenderer* m_pButtonTextRenderer; GtkWidget* m_pEntry; GtkEditable* m_pEditable; // GtkCellView* m_pCellView; @@ -18480,7 +18480,7 @@ public: // , m_pOverlayButton(GTK_MENU_BUTTON(gtk_builder_get_object(pComboBuilder, "overlaybutton"))) , m_pMenuWindow(nullptr) , m_pTreeModel(gtk_combo_box_get_model(pComboBox)) -// , m_pButtonTextRenderer(nullptr) + , m_pButtonTextRenderer(nullptr) // , m_pToggleButton(GTK_WIDGET(gtk_builder_get_object(pComboBuilder, "button"))) , m_pEntry(GTK_IS_ENTRY(gtk_combo_box_get_child(pComboBox)) ? gtk_combo_box_get_child(pComboBox) : nullptr) , m_pEditable(GTK_EDITABLE(m_pEntry)) @@ -18518,6 +18518,9 @@ public: } SAL_WARN_IF(!m_pMenuWindow, "vcl.gtk", "GtkInstanceComboBox: couldn't find popup menu"); + bool bHasEntry = gtk_combo_box_get_has_entry(m_pComboBox); + + bool bFindButtonTextRenderer = !bHasEntry; GtkCellLayout* pCellLayout = GTK_CELL_LAYOUT(m_pComboBox); GList* cells = gtk_cell_layout_get_cells(pCellLayout); guint i = g_list_length(cells) - 1;; @@ -18526,9 +18529,14 @@ public: { GtkCellRenderer* pCellRenderer = GTK_CELL_RENDERER(pRenderer->data); gtk_cell_layout_reorder(pCellLayout, pCellRenderer, i--); + if (bFindButtonTextRenderer) + { + m_pButtonTextRenderer = pCellRenderer; + bFindButtonTextRenderer = false; + } } - if (gtk_combo_box_get_has_entry(m_pComboBox)) + if (bHasEntry) { m_bAutoComplete = true; m_nEntryInsertTextSignalId = g_signal_connect(m_pEditable, "insert-text", G_CALLBACK(signalEntryInsertText), this); @@ -18610,7 +18618,6 @@ public: virtual void set_size_request(int nWidth, int nHeight) override { -#if 0 if (m_pButtonTextRenderer) { // tweak the cell render to get a narrower size to stick @@ -18642,7 +18649,6 @@ public: gtk_cell_renderer_set_fixed_size(m_pButtonTextRenderer, -1, -1); } } -#endif gtk_widget_set_size_request(m_pWidget, nWidth, nHeight); } |