Merge lp:~jeremywootten/pantheon-files/fix-1605930-filechooser-click-behaviour into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Merged at revision: 2256
Proposed branch: lp:~jeremywootten/pantheon-files/fix-1605930-filechooser-click-behaviour
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 109 lines (+44/-17)
1 file modified
filechooser-module/FileChooserDialog.vala (+44/-17)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-1605930-filechooser-click-behaviour
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+300991@code.launchpad.net

Description of the change

This branch sets the "activate-on-single-click" property of the filechooser according to the Files preferences.

To post a comment you must log in.
Revision history for this message
Zisu Andrei (matzipan) wrote :

It's not clear to me: what exactly is the bug? When I open the Gtk3 filechooser (Epiphany file chooser), I can select with a single click. Am I looking at the right thing?

Revision history for this message
Cody Garver (codygarver) wrote :

@matzipan Epiphany does not use the filechooser for whatever reason. The issue is that apps that do, like Audience, require double click to OPEN a file or folder, regardless of the gsetting.

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-05-06 10:36:16 +0000
3+++ filechooser-module/FileChooserDialog.vala 2016-07-24 11:44:06 +0000
4@@ -1,5 +1,5 @@
5 /*-
6- * Copyright (c) 2015 elementary LLC (http://launchpad.net/elementary)
7+ * Copyright (c) 2015-6 elementary LLC (http://launchpad.net/elementary)
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11@@ -19,6 +19,9 @@
12 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
13 */
14
15+/*** The Gtk.FileChooserWidget widget names and paths can be found in "gtkfilechooserwidget.ui"
16+ * in the Gtk+3 source code package. Changes to that file could break this code.
17+***/
18 public class CustomFileChooserDialog : Object {
19 private static Gtk.FileChooserDialog chooser_dialog;
20 private static Gtk.Widget rootwidget;
21@@ -42,6 +45,7 @@
22 private string current_path = null;
23 private bool is_previous = false;
24 private bool is_button_next = false;
25+ private bool is_single_click = true;
26
27 public CustomFileChooserDialog (Gtk.FileChooserDialog dialog) {
28 previous_paths = new GLib.Queue<string> ();
29@@ -51,6 +55,9 @@
30 chooser_dialog.can_focus = true;
31 chooser_dialog.deletable = false;
32
33+ var settings = new Settings ("org.pantheon.files.preferences");
34+ is_single_click = settings.get_boolean ("single-click");
35+
36 assign_container_box ();
37 remove_gtk_widgets ();
38 setup_filter_box ();
39@@ -131,23 +138,23 @@
40 (root as Gtk.Container).get_children ().foreach ((w0) => {
41 if (w0.get_name () == GTK_PATHBAR_PATH[0]) {
42 /* Add top separator between headerbar and filechooser when is not Save action */
43- var chooserwidget = w0 as Gtk.Container;
44- chooserwidget.vexpand = true;
45-
46- (root as Gtk.Container).remove (w0);
47- var root_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
48+ var chooserwidget = w0 as Gtk.Container;
49+ chooserwidget.vexpand = true;
50+
51+ (root as Gtk.Container).remove (w0);
52+ var root_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
53+ root_box.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL));
54+ root_box.add (chooserwidget);
55+
56+ if (chooser_dialog.get_extra_widget () == null) {
57 root_box.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL));
58- root_box.add (chooserwidget);
59-
60- if (chooser_dialog.get_extra_widget () == null) {
61- root_box.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL));
62- }
63-
64- (root as Gtk.Container).add (root_box);
65- rootwidget = chooserwidget;
66- rootwidget = w0;
67- rootwidget.can_focus = true;
68- transform_rootwidget_container (rootwidget, w0);
69+ }
70+
71+ (root as Gtk.Container).add (root_box);
72+ rootwidget = chooserwidget;
73+ rootwidget = w0;
74+ rootwidget.can_focus = true;
75+ transform_rootwidget_container (rootwidget, w0);
76 }
77 });
78 });
79@@ -222,10 +229,30 @@
80 });
81
82 (w2 as Gtk.Container).remove (w3);
83+ } else if (w3.get_name () == "list_and_preview_box") { /* file browser list and preview box */
84+ var tv = find_tree_view (w3);
85+ tv.set_activate_on_single_click (is_single_click);
86 }
87 });
88 }
89
90+ private Gtk.TreeView? find_tree_view (Gtk.Widget browser_box) {
91+ /* Locate the TreeView and set its click behaviour */
92+ Gtk.TreeView? tv = null;
93+ ((Gtk.Container)browser_box).get_children ().foreach ((w) => {
94+ ((Gtk.Container)w).get_children ().foreach ((w) => {
95+ ((Gtk.Container)w).get_children ().foreach ((w) => {
96+ ((Gtk.Container)w).get_children ().foreach ((w) => {
97+ if (w is Gtk.TreeView) {
98+ tv =(Gtk.TreeView)w;
99+ }
100+ });
101+ });
102+ });
103+ });
104+ return tv;
105+ }
106+
107 private void assign_container_box () {
108 container_box = chooser_dialog.get_action_area () as Gtk.Box;
109 container_box.valign = Gtk.Align.CENTER;

Subscribers

People subscribed via source and target branches

to all changes: