Merge lp:~bellini666/gtk/fix_1427352 into lp:~ubuntu-desktop/gtk/ubuntugtk3trusty

Proposed by Thiago Bellini
Status: Merged
Merged at revision: 344
Proposed branch: lp:~bellini666/gtk/fix_1427352
Merge into: lp:~ubuntu-desktop/gtk/ubuntugtk3trusty
Diff against target: 523 lines (+498/-0)
4 files modified
debian/changelog (+9/-0)
debian/patches/revert-better-resize-of-expandable-columns.patch (+123/-0)
debian/patches/revert-use-minumum-natural-size-semantics.patch (+364/-0)
debian/patches/series (+2/-0)
To merge this branch: bzr merge lp:~bellini666/gtk/fix_1427352
Reviewer Review Type Date Requested Status
Ubuntu Desktop Pending
Review via email: mp+251508@code.launchpad.net

Description of the change

Fix for LP:#1427352

Upstream bug: https://bugzilla.gnome.org/show_bug.cgi?id=731054

To post a comment you must log in.
Revision history for this message
Thiago Bellini (bellini666) wrote :

I tested this locally and it solves the issue and is working great!

But if anyone wants to test, it is building atm on this ppa: https://launchpad.net/~hackedbellini/+archive/ubuntu/misc

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2015-01-15 15:01:30 +0000
+++ debian/changelog 2015-03-02 19:52:16 +0000
@@ -1,3 +1,12 @@
1gtk+3.0 (3.10.8-0ubuntu1.5) trusty; urgency=low
2
3 * debian/patches/revert-better-resize-of-expandable-columns.patch
4 debian/patches/revert-use-minumum-natural-size-semantics.patch
5 - Port of an upstream bug:
6 https://bugzilla.gnome.org/show_bug.cgi?id=731054 (LP: #1427352)
7
8 -- Thiago Bellini Ribeiro <hackedbellini@gmail.com> Mon, 02 Mar 2015 16:26:25 -0300
9
1gtk+3.0 (3.10.8-0ubuntu1.4) trusty-security; urgency=medium10gtk+3.0 (3.10.8-0ubuntu1.4) trusty-security; urgency=medium
211
3 * debian/patches/no_popup_menu_in_gtk_window.patch12 * debian/patches/no_popup_menu_in_gtk_window.patch
413
=== added file 'debian/patches/revert-better-resize-of-expandable-columns.patch'
--- debian/patches/revert-better-resize-of-expandable-columns.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/revert-better-resize-of-expandable-columns.patch 2015-03-02 19:52:16 +0000
@@ -0,0 +1,123 @@
1From 73ff6a8e0ff307b8d14986c64918022364ff10e7 Mon Sep 17 00:00:00 2001
2From: Matthias Clasen <mclasen@redhat.com>
3Date: Sun, 1 Jun 2014 10:15:41 -0400
4Subject: Revert "Better resize of expandable columns"
5
6This reverts commit 0050d469b592ec571a5940f1ab1d842a76905e17.
7
8Conflicts:
9 gtk/gtktreeview.c
10
11--- a/gtk/gtktreeview.c
12+++ b/gtk/gtktreeview.c
13@@ -2544,71 +2544,6 @@ gtk_tree_view_get_preferred_height (GtkW
14 *natural = height;
15 }
16
17-static void
18-gtk_tree_view_modify_column_width (GtkTreeView *tree_view,
19- GtkTreeViewColumn *column,
20- gint width)
21-{
22- gboolean is_expand;
23- gint n_expand_others;
24- gint minimum, natural, natural_others;
25- gint expand;
26-
27- is_expand = gtk_tree_view_column_get_expand (column);
28- n_expand_others = tree_view->priv->n_expand_columns - (is_expand ? 1 : 0);
29-
30- _gtk_tree_view_column_request_width (column, &minimum, &natural);
31- natural_others = tree_view->priv->natural_width - natural;
32-
33- if (natural_others + width < tree_view->priv->width)
34- {
35- /* There is extra space that needs to be taken up by letting some other
36- * column(s) expand: by default, the last column. */
37- if (!n_expand_others)
38- {
39- GList *last = g_list_last (tree_view->priv->columns);
40- while (!gtk_tree_view_column_get_visible (last->data))
41- last = last->prev;
42-
43- if (column == last->data)
44- return;
45-
46- gtk_tree_view_column_set_expand (last->data, TRUE);
47- n_expand_others++;
48- }
49-
50- /* Now try to make this column expandable also. Solving the following
51- * equations reveals what the natural width should be to achieve the
52- * desired width after expanding:
53- *
54- * 1. natural + expand = desired_width
55- * 2. natural + natural_others + expand * (n_expand_others + 1) = total_width
56- *
57- * Solution:
58- * expand = (total_width - natural_others - desired_width) / n_expand_others
59- *
60- * It is possible for the solved natural width to be less than the
61- * minimum; in that case, we cannot let the column expand.
62- */
63- expand = (tree_view->priv->width - natural_others - width) / n_expand_others;
64-
65- if (minimum + expand > width)
66- {
67- if (is_expand)
68- gtk_tree_view_column_set_expand (column, FALSE);
69- }
70- else
71- {
72- if (!is_expand)
73- gtk_tree_view_column_set_expand (column, TRUE);
74-
75- width -= expand;
76- }
77- }
78-
79- gtk_tree_view_column_set_fixed_width (column, width);
80-}
81-
82 static int
83 gtk_tree_view_calculate_width_before_expander (GtkTreeView *tree_view)
84 {
85@@ -3386,6 +3321,9 @@ gtk_tree_view_button_press (GtkWidget
86 drag_data);
87
88 column_width = gtk_tree_view_column_get_width (column);
89+ gtk_tree_view_column_set_fixed_width (column, column_width);
90+ gtk_tree_view_column_set_expand (column, FALSE);
91+
92 gdk_window_get_device_position (tree_view->priv->bin_window,
93 gdk_event_get_device ((GdkEvent *) event),
94 &x, NULL, NULL);
95@@ -4137,14 +4075,14 @@ gtk_tree_view_motion_resize_column (GtkW
96 gdk_window_get_device_position (tree_view->priv->bin_window,
97 gdk_event_get_device ((GdkEvent *) event),
98 &x, NULL, NULL);
99-
100+
101 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
102 new_width = MAX (tree_view->priv->x_drag - x, 0);
103 else
104 new_width = MAX (x - tree_view->priv->x_drag, 0);
105-
106- if (new_width != gtk_tree_view_column_get_width (column))
107- gtk_tree_view_modify_column_width (tree_view, column, new_width);
108+
109+ if (new_width != gtk_tree_view_column_get_fixed_width (column))
110+ gtk_tree_view_column_set_fixed_width (column, new_width);
111
112 return FALSE;
113 }
114@@ -5869,7 +5807,8 @@ gtk_tree_view_key_press (GtkWidget *wi
115 column_width = column_width + 2;
116 }
117
118- gtk_tree_view_modify_column_width (tree_view, column, column_width);
119+ gtk_tree_view_column_set_fixed_width (column, column_width);
120+ gtk_tree_view_column_set_expand (column, FALSE);
121 return TRUE;
122 }
123
0124
=== added file 'debian/patches/revert-use-minumum-natural-size-semantics.patch'
--- debian/patches/revert-use-minumum-natural-size-semantics.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/revert-use-minumum-natural-size-semantics.patch 2015-03-02 19:52:16 +0000
@@ -0,0 +1,364 @@
1From a3cd0ee7d8a610feff39984254306cec4a6c9c73 Mon Sep 17 00:00:00 2001
2From: Matthias Clasen <mclasen@redhat.com>
3Date: Sun, 1 Jun 2014 10:16:01 -0400
4Subject: Revert "Use minimum/natural size semantics"
5
6This reverts commit 6d53c2339f79baa0b295ecc614f41f9daab2e132.
7
8https://bugzilla.gnome.org/show_bug.cgi?id=731054 showed some
9major regressions caused by this commit.
10
11--- a/gtk/gtktreeprivate.h
12+++ b/gtk/gtktreeprivate.h
13@@ -100,9 +100,7 @@ void _gtk_tree_view_column_unrealize_but
14
15 void _gtk_tree_view_column_set_tree_view (GtkTreeViewColumn *column,
16 GtkTreeView *tree_view);
17-void _gtk_tree_view_column_request_width (GtkTreeViewColumn *tree_column,
18- gint *minimum,
19- gint *natural);
20+gint _gtk_tree_view_column_request_width (GtkTreeViewColumn *tree_column);
21 void _gtk_tree_view_column_allocate (GtkTreeViewColumn *tree_column,
22 int x_offset,
23 int width);
24--- a/gtk/gtktreeview.c
25+++ b/gtk/gtktreeview.c
26@@ -386,10 +386,10 @@ struct _GtkTreeViewPrivate
27 gint drag_pos;
28 gint x_drag;
29
30- /* Column width allocation */
31- gint minimum_width;
32- gint natural_width;
33- gint n_expand_columns;
34+ /* Non-interactive Header Resizing, expand flag support */
35+ gint last_extra_space;
36+ gint last_extra_space_per_column;
37+ gint last_number_of_expand_columns;
38
39 /* ATK Hack */
40 GtkTreeDestroyCountFunc destroy_count_func;
41@@ -494,6 +494,8 @@ struct _GtkTreeViewPrivate
42
43 guint in_scroll : 1;
44
45+ guint post_validation_flag : 1;
46+
47 /* Whether our key press handler is to avoid sending an unhandled binding to the search entry */
48 guint search_entry_avoid_unhandled_binding : 1;
49
50@@ -1749,9 +1751,6 @@ gtk_tree_view_init (GtkTreeView *tree_vi
51 tree_view->priv->header_height = 1;
52 tree_view->priv->x_drag = 0;
53 tree_view->priv->drag_pos = -1;
54- tree_view->priv->minimum_width = 0;
55- tree_view->priv->natural_width = 0;
56- tree_view->priv->n_expand_columns = 0;
57 tree_view->priv->header_has_focus = FALSE;
58 tree_view->priv->pressed_button = -1;
59 tree_view->priv->press_start_x = -1;
60@@ -1785,6 +1784,8 @@ gtk_tree_view_init (GtkTreeView *tree_vi
61
62 tree_view->priv->tooltip_column = -1;
63
64+ tree_view->priv->post_validation_flag = FALSE;
65+
66 tree_view->priv->last_button_x = -1;
67 tree_view->priv->last_button_y = -1;
68
69@@ -2502,16 +2503,12 @@ gtk_tree_view_get_preferred_width (GtkWi
70 GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
71 GList *list;
72 GtkTreeViewColumn *column;
73- gint column_minimum, column_natural;
74+ gint width = 0;
75
76 /* we validate some rows initially just to make sure we have some size.
77 * In practice, with a lot of static lists, this should get a good width.
78 */
79 do_validate_rows (tree_view, FALSE);
80-
81- tree_view->priv->minimum_width = 0;
82- tree_view->priv->natural_width = 0;
83- tree_view->priv->n_expand_columns = 0;
84
85 /* keep this in sync with size_allocate below */
86 for (list = tree_view->priv->columns; list; list = list->next)
87@@ -2520,18 +2517,13 @@ gtk_tree_view_get_preferred_width (GtkWi
88 if (!gtk_tree_view_column_get_visible (column) || column == tree_view->priv->drag_column)
89 continue;
90
91- _gtk_tree_view_column_request_width (column, &column_minimum, &column_natural);
92- tree_view->priv->minimum_width += column_minimum;
93- tree_view->priv->natural_width += column_natural;
94-
95- if (gtk_tree_view_column_get_expand (column))
96- tree_view->priv->n_expand_columns++;
97+ width += _gtk_tree_view_column_request_width (column);
98 }
99
100 if (minimum != NULL)
101- *minimum = tree_view->priv->minimum_width;
102+ *minimum = width;
103 if (natural != NULL)
104- *natural = tree_view->priv->natural_width;
105+ *natural = width;
106 }
107
108 static void
109@@ -2646,9 +2638,12 @@ gtk_tree_view_size_allocate_columns (Gtk
110 GList *list, *first_column, *last_column;
111 GtkTreeViewColumn *column;
112 GtkAllocation widget_allocation;
113- gint minimum_width, natural_width, n_expand_columns, width;
114- gint column_minimum, column_natural, column_width;
115+ gint width = 0;
116+ gint extra, extra_per_column, extra_for_last;
117+ gint full_requested_width = 0;
118+ gint number_of_expand_columns = 0;
119 gboolean rtl;
120+ gboolean update_expand;
121
122 tree_view = GTK_TREE_VIEW (widget);
123
124@@ -2668,65 +2663,111 @@ gtk_tree_view_size_allocate_columns (Gtk
125
126 rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
127
128- gtk_widget_get_allocation (widget, &widget_allocation);
129+ /* find out how many extra space and expandable columns we have */
130+ for (list = tree_view->priv->columns; list != last_column->next; list = list->next)
131+ {
132+ column = (GtkTreeViewColumn *)list->data;
133
134- minimum_width = tree_view->priv->minimum_width;
135- natural_width = tree_view->priv->natural_width;
136- n_expand_columns = tree_view->priv->n_expand_columns;
137+ if (!gtk_tree_view_column_get_visible (column) || column == tree_view->priv->drag_column)
138+ continue;
139
140- width = MAX (widget_allocation.width, minimum_width);
141+ full_requested_width += _gtk_tree_view_column_request_width (column);
142
143- /* We change the width here. The user might have been resizing columns,
144- * which changes the total width of the tree view. This is of
145- * importance for getting the horizontal scroll bar right.
146+ if (gtk_tree_view_column_get_expand (column))
147+ number_of_expand_columns++;
148+ }
149+
150+ /* Only update the expand value if the width of the widget has changed,
151+ * or the number of expand columns has changed, or if there are no expand
152+ * columns, or if we didn't have an size-allocation yet after the
153+ * last validated node.
154 */
155- if (tree_view->priv->width != width)
156+ update_expand = (width_changed && *width_changed == TRUE)
157+ || number_of_expand_columns != tree_view->priv->last_number_of_expand_columns
158+ || number_of_expand_columns == 0
159+ || tree_view->priv->post_validation_flag == TRUE;
160+
161+ tree_view->priv->post_validation_flag = FALSE;
162+
163+ gtk_widget_get_allocation (widget, &widget_allocation);
164+ if (!update_expand)
165 {
166- tree_view->priv->width = width;
167- if (width_changed)
168- *width_changed = TRUE;
169+ extra = tree_view->priv->last_extra_space;
170+ extra_for_last = MAX (widget_allocation.width - full_requested_width - extra, 0);
171 }
172+ else
173+ {
174+ extra = MAX (widget_allocation.width - full_requested_width, 0);
175+ extra_for_last = 0;
176+
177+ tree_view->priv->last_extra_space = extra;
178+ }
179+
180+ if (number_of_expand_columns > 0)
181+ extra_per_column = extra/number_of_expand_columns;
182+ else
183+ extra_per_column = 0;
184
185- /* iterate through columns in reverse order */
186- for (list = (rtl ? first_column : last_column);
187- list != (rtl ? last_column->next : first_column->prev);
188- list = (rtl ? list->next : list->prev))
189+ if (update_expand)
190 {
191+ tree_view->priv->last_extra_space_per_column = extra_per_column;
192+ tree_view->priv->last_number_of_expand_columns = number_of_expand_columns;
193+ }
194+
195+ for (list = (rtl ? last_column : first_column);
196+ list != (rtl ? first_column->prev : last_column->next);
197+ list = (rtl ? list->prev : list->next))
198+ {
199+ gint column_width;
200+
201 column = list->data;
202
203 if (!gtk_tree_view_column_get_visible (column) || column == tree_view->priv->drag_column)
204 continue;
205
206- _gtk_tree_view_column_request_width (column, &column_minimum, &column_natural);
207-
208- column_width = column_natural;
209+ column_width = _gtk_tree_view_column_request_width (column);
210
211- if (width > natural_width)
212- {
213- /* We need to expand some columns. If there are none marked to
214- * expand, give all the extra space to the last column. */
215- if (n_expand_columns == 0)
216+ if (gtk_tree_view_column_get_expand (column))
217+ {
218+ if (number_of_expand_columns == 1)
219 {
220- column_width = column_natural + (width - natural_width);
221+ /* We add the remander to the last column as
222+ * */
223+ column_width += extra;
224 }
225- else if (gtk_tree_view_column_get_expand (column))
226+ else
227 {
228- column_width = column_natural + (width - natural_width) / n_expand_columns;
229- n_expand_columns--;
230+ column_width += extra_per_column;
231+ extra -= extra_per_column;
232+ number_of_expand_columns --;
233 }
234- }
235- else if (width < natural_width)
236+ }
237+ else if (number_of_expand_columns == 0 &&
238+ list == last_column)
239 {
240- /* We need to shrink some columns. Starting with later columns,
241- * shrink each one down to its minimum width as necessary. */
242- column_width = MAX (column_natural + (width - natural_width), column_minimum);
243+ column_width += extra;
244 }
245-
246- _gtk_tree_view_column_allocate (column, width - column_width, column_width);
247-
248- minimum_width -= column_minimum;
249- natural_width -= column_natural;
250- width -= column_width;
251+
252+ /* In addition to expand, the last column can get even more
253+ * extra space so all available space is filled up.
254+ */
255+ if (extra_for_last > 0 && list == last_column)
256+ column_width += extra_for_last;
257+
258+ _gtk_tree_view_column_allocate (column, width, column_width);
259+
260+ width += column_width;
261+ }
262+
263+ /* We change the width here. The user might have been resizing columns,
264+ * which changes the total width of the tree view. This is of
265+ * importance for getting the horizontal scroll bar right.
266+ */
267+ if (tree_view->priv->width != width)
268+ {
269+ tree_view->priv->width = width;
270+ if (width_changed)
271+ *width_changed = TRUE;
272 }
273 }
274
275@@ -6241,6 +6282,7 @@ validate_row (GtkTreeView *tree_view,
276 _gtk_rbtree_node_set_height (tree, node, height);
277 }
278 _gtk_rbtree_node_mark_valid (tree, node);
279+ tree_view->priv->post_validation_flag = TRUE;
280
281 return retval;
282 }
283--- a/gtk/gtktreeviewcolumn.c
284+++ b/gtk/gtktreeviewcolumn.c
285@@ -2087,48 +2087,48 @@ gtk_tree_view_column_get_x_offset (GtkTr
286 return tree_column->priv->x_offset;
287 }
288
289-void
290-_gtk_tree_view_column_request_width (GtkTreeViewColumn *tree_column,
291- gint *minimum,
292- gint *natural)
293+gint
294+_gtk_tree_view_column_request_width (GtkTreeViewColumn *tree_column)
295 {
296- GtkTreeViewColumnPrivate *priv = tree_column->priv;
297- gint minimum_width = 1, natural_width = 1;
298- gint button_minimum, button_natural;
299+ GtkTreeViewColumnPrivate *priv;
300+ gint real_requested_width;
301+
302+ priv = tree_column->priv;
303
304- if (priv->column_type != GTK_TREE_VIEW_COLUMN_FIXED)
305+ if (priv->fixed_width != -1)
306 {
307- gtk_cell_area_context_get_preferred_width (priv->cell_area_context, &minimum_width, &natural_width);
308- minimum_width += priv->padding;
309- natural_width += priv->padding;
310-
311- if (gtk_tree_view_get_headers_visible (GTK_TREE_VIEW (priv->tree_view)))
312- {
313- gtk_widget_get_preferred_width (priv->button, &button_minimum, &button_natural);
314- minimum_width = MAX (minimum_width, button_minimum);
315- natural_width = MAX (natural_width, button_natural);
316- }
317+ real_requested_width = priv->fixed_width;
318 }
319+ else if (gtk_tree_view_get_headers_visible (GTK_TREE_VIEW (priv->tree_view)))
320+ {
321+ gint button_request;
322+ gint requested_width;
323
324- if (priv->fixed_width != -1)
325- natural_width = MAX (priv->fixed_width, minimum_width);
326+ gtk_cell_area_context_get_preferred_width (priv->cell_area_context, &requested_width, NULL);
327+ requested_width += priv->padding;
328
329- if (priv->min_width != -1)
330+ gtk_widget_get_preferred_width (priv->button, &button_request, NULL);
331+ real_requested_width = MAX (requested_width, button_request);
332+ }
333+ else
334 {
335- minimum_width = MAX (minimum_width, priv->min_width);
336- natural_width = MAX (natural_width, priv->min_width);
337+ gint requested_width;
338+
339+ gtk_cell_area_context_get_preferred_width (priv->cell_area_context, &requested_width, NULL);
340+ requested_width += priv->padding;
341+
342+ real_requested_width = requested_width;
343+ if (real_requested_width < 0)
344+ real_requested_width = 0;
345 }
346
347+ if (priv->min_width != -1)
348+ real_requested_width = MAX (real_requested_width, priv->min_width);
349+
350 if (priv->max_width != -1)
351- {
352- minimum_width = MIN (minimum_width, priv->max_width);
353- natural_width = MIN (natural_width, priv->max_width);
354- }
355+ real_requested_width = MIN (real_requested_width, priv->max_width);
356
357- if (minimum != NULL)
358- *minimum = minimum_width;
359- if (natural != NULL)
360- *natural = natural_width;
361+ return real_requested_width;
362 }
363
364 void
0365
=== modified file 'debian/patches/series'
--- debian/patches/series 2015-01-15 15:01:30 +0000
+++ debian/patches/series 2015-03-02 19:52:16 +0000
@@ -24,3 +24,5 @@
24use-secrets-service-for-cups-auth_info.patch24use-secrets-service-for-cups-auth_info.patch
25printing-initialize-auth_info.patch25printing-initialize-auth_info.patch
26no_popup_menu_in_gtk_window.patch26no_popup_menu_in_gtk_window.patch
27revert-use-minumum-natural-size-semantics.patch
28revert-better-resize-of-expandable-columns.patch

Subscribers

People subscribed via source and target branches

to all changes: