diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-02-21 15:57:22 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-02-21 20:48:50 +0100 |
commit | 7bc3ac14a88206ed3cafa123e92877e0a47cfb15 (patch) | |
tree | 35d8b8761b1d879bf48d9fe8bac7e78e22c0b3e6 /vcl | |
parent | e0a8803fa3b053eeccb226fc69d5005e63d00c99 (diff) |
menu of currency combobox in format-cells is too narrow
we want the combobox to be narrower than it wants to be. To make that happen
we have only the option of shrinking the cell renderer of the combobox area.
And that is also used by the menu.
Setting a small value of e.g. 1 works to let the combobox not request more
width than that, and the combobox will correctly render within the wider size
it actually gets. But then the menu is a min width menu, which is undesirable,
we want the menu to be as wide as it can be.
So calculate what part of the combobox belongs to the cell area and set
the widest cell area we can within the overall combobox width, resulting
in the widest menu we can get.
Change-Id: Ie3e9960a320a70471ac21d2a88f32632cafa951f
Reviewed-on: https://gerrit.libreoffice.org/68167
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index cd00ff5a9e8c..b0c0e13b5e7e 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -7531,20 +7531,31 @@ public: // tweak the cell render to get a narrower size to stick GList* cells = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(m_pComboBox)); GtkCellRenderer* cell = static_cast<GtkCellRenderer*>(cells->data); - GtkRequisition size; - gtk_cell_renderer_get_preferred_size(cell, m_pWidget, &size, nullptr); - if (nWidth < size.width) + + if (nWidth != -1) { // this bit isn't great, I really want to be able to ellipse the text in the comboboxtext itself and let - // the popup menu render them in full, in the interim ellipse both + // the popup menu render them in full, in the interim ellipse both of them g_object_set(G_OBJECT(m_pTextRenderer), "ellipsize", PANGO_ELLIPSIZE_MIDDLE, nullptr); - gtk_cell_renderer_set_fixed_size(cell, nWidth, size.height); + + // to find out how much of the width of the combobox belongs to the cell, set + // the cell and widget to the min cell width and see what the difference is + int min; + gtk_cell_renderer_get_preferred_width(cell, m_pWidget, &min, nullptr); + gtk_cell_renderer_set_fixed_size(cell, min, -1); + gtk_widget_set_size_request(m_pWidget, min, -1); + int nNonCellWidth = get_preferred_size().Width() - min; + + // now set the cell to the max width which it can be within the + // requested widget width + gtk_cell_renderer_set_fixed_size(cell, nWidth - nNonCellWidth, -1); } else { g_object_set(G_OBJECT(m_pTextRenderer), "ellipsize", PANGO_ELLIPSIZE_NONE, nullptr); - gtk_cell_renderer_set_fixed_size(cell, -1, size.height); + gtk_cell_renderer_set_fixed_size(cell, -1, -1); } + g_list_free(cells); gtk_widget_set_size_request(m_pWidget, nWidth, nHeight); |