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

Subscribers

People subscribed via source and target branches

to all changes: