~elementary-apps/pantheon-files/find-function-part2

« back to all changes in this revision

Viewing changes to src/View/AbstractTreeView.vala

  • Committer: Jeremy Wootten
  • Date: 2017-02-04 13:36:10 UTC
  • mfrom: (2412.1.58 pantheon-files)
  • Revision ID: jeremy@elementaryos.org-20170204133610-mvwfsvos5p4njkd3
Merge trunk to r2470

Show diffs side-by-side

added added

removed removed

Lines of Context:
197
197
            int x, y, cx, cy, depth;
198
198
            path = null;
199
199
 
200
 
            if (event.window != tree.get_bin_window ())
 
200
            if (event.window != tree.get_bin_window ()) {
201
201
                return ClickZone.INVALID;
 
202
            }
202
203
 
203
204
            x = (int)event.x;
204
205
            y = (int)event.y;
205
206
 
 
207
            /* Determine whether there whitespace at this point.  Note: this function returns false when the
 
208
             * position is on the edge of the cell, even though this appears to be blank. We
 
209
             * deal with this below. */
 
210
            var is_blank = tree.is_blank_at_pos ((int)event.x, (int)event.y, null, null, null, null);
 
211
 
206
212
            tree.get_path_at_pos ((int)event.x, (int)event.y, out p, out c, out cx, out cy);
207
213
            path = p;
208
214
            depth = p != null ? p.get_depth () : 0;
 
215
 
 
216
            /* Determine whether on edge of cell and designate as blank */
 
217
            Gdk.Rectangle area;
 
218
            tree.get_cell_area (p, c, out area);
 
219
            int height = area.height;
 
220
 
 
221
            is_blank = is_blank || cy < 5 || cy > height - 5;
 
222
 
209
223
            /* Do not allow rubberbanding to start except on a row in tree view */
210
 
            zone = (p != null ? ClickZone.BLANK_PATH : ClickZone.INVALID);
 
224
            zone = (p != null && is_blank ? ClickZone.BLANK_PATH : ClickZone.INVALID);
211
225
 
212
226
            if (p != null && c != null && c == name_column) {
213
 
                int? x_offset = null, width = null;
214
 
                Gdk.Rectangle area;
215
 
 
216
 
                tree.get_cell_area (p, c, out area);
217
 
 
218
 
                width = area.width;
219
227
                int orig_x = area.x + ICON_XPAD;
220
228
 
221
229
                if (x > orig_x) { /* y must be in range */
226
234
                        zone = ClickZone.HELPER;
227
235
                    } else if (on_icon) {
228
236
                        zone = ClickZone.ICON;
229
 
                    } else {
230
 
                        c.cell_get_position (name_renderer, out x_offset, out width);
231
 
                        int expander_width = ICON_XPAD;
232
 
                        if (tree.show_expanders) {
233
 
                            var expander_val = GLib.Value (typeof (int));
234
 
                            tree.style_get_property ("expander-size", ref expander_val);
235
 
                            int expander_size = expander_val.get_int () + tree.get_level_indentation () + 3;
236
 
                            expander_width += expander_size * (depth) + zoom_level;
237
 
                        }
238
 
                        orig_x = expander_width + x_offset;
239
 
                        if (right_margin_unselects_all && cx >= orig_x + width - 6)
240
 
                            zone = ClickZone.INVALID; /* Cause unselect all to occur on right margin */
241
 
                        else {
242
 
                            zone = ClickZone.NAME;
243
 
                        }
 
237
                    } else if (!is_blank) {
 
238
                        zone = ClickZone.NAME;
244
239
                    }
245
240
                } else {
246
241
                    zone = ClickZone.EXPANDER;
251
246
            return zone;
252
247
        }
253
248
 
 
249
        protected override bool handle_secondary_button_click (Gdk.EventButton event) {
 
250
            /* In Column and List Views show background menu on all white space to allow
 
251
             * creation of new folder when view full. */
 
252
            if (click_zone == ClickZone.BLANK_PATH) {
 
253
                unselect_all ();
 
254
            }
 
255
            return base.handle_secondary_button_click (event);
 
256
        }
 
257
 
254
258
        protected override void scroll_to_cell (Gtk.TreePath? path, bool scroll_to_top) {
255
259
            if (tree == null || path == null || slot == null || /* slot should not be null but see lp:1595438 */
256
260
                slot.directory.permission_denied || slot.directory.is_empty ()) {