~elementary-apps/pantheon-files/trunk

« back to all changes in this revision

Viewing changes to libwidgets/LocationBar.vala

  • Committer: RabbitBot
  • Author(s): jeremy at elementaryos, Jeremy Wootten
  • Date: 2014-11-23 05:01:42 UTC
  • mfrom: (1459.1.202 all-views-vala)
  • Revision ID: rabbitbot-20141123050142-t685f3zxs1vayioq
* Convert Slot, Miller, DirectoryView, ListView, ColumnView and IconView to Vala.
* Use standard Gtk.TreeView and Gtk.IconView
* Address a number of bugs associated with the views.
* Some changes made to ViewContainer - new slots only made when view mode changes, not when location changes.
* For improved accessibility, helper emblem appears in all views but only when the icons are above a minimum size.
* Implemented bookmarking from context menu
* Implemented "Open in New Window" in context menu
* Context menu and app menu reimplemented without deprecated code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
185
185
                escape ();
186
186
                return true;
187
187
        }
188
 
        
189
188
        return base.key_press_event (event);
190
189
    }
191
190
 
192
191
    public override bool button_press_event (Gdk.EventButton event) {
193
192
        if (is_focus)    
194
193
            return base.button_press_event (event);
195
 
        
 
194
 
196
195
        foreach (BreadcrumbsElement element in elements)
197
196
            element.pressed = false;
198
197
 
242
241
            var el = get_element_from_coordinates ((int) event.x, (int) event.y);
243
242
            if (el != null) {
244
243
                selected = elements.index_of (el);
245
 
                var newpath = get_path_from_element (el);
 
244
                var newpath = sanitise_path (get_path_from_element (el));
246
245
                path_changed (get_file_for_path (newpath));
247
246
            } else
248
247
                grab_focus ();
318
317
        if (search_mode)
319
318
            set_entry_text ("");
320
319
        else
321
 
            set_entry_text (GLib.Uri.unescape_string (get_elements_path ()
322
 
                    .replace ("file:////", "/")
323
 
                    .replace ("file:///", "/")
324
 
                    .replace ("trash:///", "")
325
 
                    .replace ("network:///", "")));
 
320
            set_entry_text (sanitise_path (GLib.Uri.unescape_string (get_elements_path ())));
 
321
                    
326
322
                
327
323
        return base.focus_in_event (event);
328
324
    }
 
325
 
 
326
    string sanitise_path (string path) {
 
327
        return path.replace ("file:////", "/")
 
328
                   .replace ("file:///", "/")
 
329
                   .replace ("trash:///", "")
 
330
                   .replace ("network:///", "");
 
331
    }
329
332
    
330
333
    void on_grab_focus () {
331
334
        select_region (0, 0);
398
401
        icons.append (icon);
399
402
    }
400
403
    
401
 
    public void complete () {        
 
404
    public void complete () {
402
405
        if (text_completion.length == 0)
403
406
            return;
404
407
 
428
431
    
429
432
    public void set_entry_cursor (Gdk.Cursor? cursor) {
430
433
        /* Only child 13 needs to be modified for the cursor - there may be a better way to do this */
 
434
        /* TODO - this doesn't work ? */
431
435
        get_window ().get_children ().nth_data (13).set_cursor (cursor ?? new Gdk.Cursor (Gdk.CursorType.XTERM));
432
436
    }
433
437
    
439
443
            secondary_icon_tooltip_text = tooltip;
440
444
        }
441
445
    }
442
 
    
 
446
 
443
447
    public double get_all_breadcrumbs_width (out int breadcrumbs_count) {
444
448
        double total_width = 0.0;
445
449
        breadcrumbs_count = 0;
478
482
                    break;
479
483
            }
480
484
        }
481
 
 
482
485
        return newpath;
483
486
    }
484
487
 
493
496
            if (element.display)
494
497
                strpath += element.text + "/";
495
498
        }
496
 
 
497
499
        return strpath;
498
500
    }
499
501
    
530
532
     * @param event a button event to compute the coords of the new menu.
531
533
     *
532
534
     **/
533
 
    private bool select_bread_from_coord (Gdk.EventButton event) {    
 
535
    private bool select_bread_from_coord (Gdk.EventButton event) {
534
536
        var el = get_element_from_coordinates ((int) event.x, (int) event.y);
535
537
 
536
538
        if (el != null) {