Merge lp:~donadigo/pantheon-files/fix-treeview-detection into lp:~elementary-apps/pantheon-files/trunk

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Felipe Escoto
Approved revision: 2261
Merged at revision: 2261
Proposed branch: lp:~donadigo/pantheon-files/fix-treeview-detection
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 52 lines (+18/-8)
1 file modified
filechooser-module/FileChooserDialog.vala (+18/-8)
To merge this branch: bzr merge lp:~donadigo/pantheon-files/fix-treeview-detection
Reviewer Review Type Date Requested Status
Felipe Escoto (community) Approve
Review via email: mp+301579@code.launchpad.net

Commit message

- FileChooser Module: fix Treeview detection

Description of the change

This branch fixes that the code assumes that there is only one widget per container, but in reality there can be more, it fails because the next widget does not need to be a container.

It also does add a guard against null TreeView in case something's gone wrong with detecting the widget.

To post a comment you must log in.
Revision history for this message
Felipe Escoto (philip.scott) wrote :

Fixes the crashes it was giving

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'filechooser-module/FileChooserDialog.vala'
2--- filechooser-module/FileChooserDialog.vala 2016-07-25 17:50:23 +0000
3+++ filechooser-module/FileChooserDialog.vala 2016-07-30 20:14:58 +0000
4@@ -35,6 +35,7 @@
5 /* Paths to widgets */
6 private const string[] GTK_PATHBAR_PATH = { "widget", "browse_widgets_box", "browse_files_box", "browse_header_revealer" };
7 private const string[] GTK_FILTERCHOOSER_PATH = { "extra_and_filters", "filter_combo_hbox" };
8+ private const string[] GTK_TREEVIEW_PATH = { "browse_files_stack", "browse_files_swin", "browse_files_tree_view" };
9 private const string PLACES_SIDEBAR_PATH = "places_sidebar";
10
11 private GLib.Queue<string> previous_paths;
12@@ -231,7 +232,9 @@
13 (w2 as Gtk.Container).remove (w3);
14 } else if (w3.get_name () == "list_and_preview_box") { /* file browser list and preview box */
15 var tv = find_tree_view (w3);
16- tv.set_activate_on_single_click (is_single_click);
17+ if (tv != null) {
18+ tv.set_activate_on_single_click (is_single_click);
19+ }
20 }
21 });
22 }
23@@ -240,16 +243,23 @@
24 /* Locate the TreeView and set its click behaviour */
25 Gtk.TreeView? tv = null;
26 ((Gtk.Container)browser_box).get_children ().foreach ((w) => {
27- ((Gtk.Container)w).get_children ().foreach ((w) => {
28+ if (w.get_name () == GTK_TREEVIEW_PATH[0]) {
29 ((Gtk.Container)w).get_children ().foreach ((w) => {
30- ((Gtk.Container)w).get_children ().foreach ((w) => {
31- if (w is Gtk.TreeView) {
32- tv =(Gtk.TreeView)w;
33- }
34- });
35+ if (w.name == "GtkBox") {
36+ ((Gtk.Container)w).get_children ().foreach ((w) => {
37+ if (w.get_name () == GTK_TREEVIEW_PATH[1]) {
38+ ((Gtk.Container)w).get_children ().foreach ((w) => {
39+ if (w.get_name () == GTK_TREEVIEW_PATH[2]) {
40+ tv = (Gtk.TreeView)w;
41+ }
42+ });
43+ }
44+ });
45+ }
46 });
47- });
48+ }
49 });
50+
51 return tv;
52 }
53

Subscribers

People subscribed via source and target branches

to all changes: