~ubuntu-branches/ubuntu/raring/nautilus/raring

« back to all changes in this revision

Viewing changes to src/nautilus-places-sidebar.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher, Jeremy Bicha
  • Date: 2012-01-31 13:45:01 UTC
  • mfrom: (1.17.25)
  • Revision ID: package-import@ubuntu.com-20120131134501-yn7mqny7fgzx9fao
Tags: 1:3.3.4-0ubuntu1
* New upstream version which fixes:
  - "Opening Popupmenu in Context of Folder with List-View impossible?"
    (lp: #126540)
  - "'Create folder in here' context menu option for nautilus" (lp: #61786)
  - the file count and the size count change in opposite direction.
    (lp: #503330)
  - the mounts in the place menu should have a properties entry.
    (lp: #846289)
  - add command line option to select file (lp: #575719)
  - Media in 'Places' side bar should have same context menu as in 
    'Computer' (lp: #230098)
* debian/nautilus-data.install:
  - updated, ui and icons have been moved into gresources
* debian/patches/05_desktop_menu_export.patch:
   - updated to correctly include the gresources desktop definition

[ Jeremy Bicha ]
* New upstream release.
* debian/control.in:
  - Bump minimum GTK and glib
* Refreshed patches
* Dropped upstream patches:
  - 17_dont_allow_new_tab_on_desktop.patch
  - 18_fix_crash_in_get_current_uri.patch
  - 19_lazily_initialize_notification_service.patch
  - git_sideplace_sorting.patch
  - git_next_row.patch
  - git_dont_document_browser_option.patch
  - git_browser_compat.patch
  - git_bookmarks_reordering.patch
  - git_listview_context_menus.patch
  - git_use_gtk_grid.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#include "nautilus-application.h"
50
50
#include "nautilus-bookmark-list.h"
51
51
#include "nautilus-places-sidebar.h"
 
52
#include "nautilus-properties-window.h"
52
53
#include "nautilus-window.h"
53
54
#include "nautilus-window-slot.h"
54
55
 
91
92
        GtkWidget *popup_menu_empty_trash_item;
92
93
        GtkWidget *popup_menu_start_item;
93
94
        GtkWidget *popup_menu_stop_item;
 
95
        GtkWidget *popup_menu_properties_separator_item;
 
96
        GtkWidget *popup_menu_properties_item;
94
97
 
95
98
        /* volume mounting - delayed open process */
96
99
        gboolean mounting;
263
266
}
264
267
 
265
268
static gboolean
 
269
should_show_desktop (void)
 
270
{
 
271
        return g_settings_get_boolean (gnome_background_preferences, NAUTILUS_PREFERENCES_SHOW_DESKTOP) &&
 
272
               !g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR);
 
273
}
 
274
 
 
275
static gboolean
266
276
is_built_in_bookmark (NautilusFile *file)
267
277
{
268
278
        gboolean built_in;
272
282
                return TRUE;
273
283
        }
274
284
 
 
285
        if (nautilus_file_is_desktop_directory (file) && !should_show_desktop ()) {
 
286
                return FALSE;
 
287
        }
 
288
 
275
289
        built_in = FALSE;
276
290
 
277
291
        for (idx = 0; idx < G_USER_N_DIRECTORIES; idx++) {
675
689
                               &last_iter, &select_path);
676
690
        g_free (mount_uri);
677
691
 
678
 
        if (g_settings_get_boolean (gnome_background_preferences, NAUTILUS_PREFERENCES_SHOW_DESKTOP) &&
679
 
            !g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR)) {
 
692
        if (should_show_desktop ()) {
680
693
                /* desktop */
681
694
                desktop_path = nautilus_get_desktop_directory ();
682
695
                mount_uri = g_filename_to_uri (desktop_path, NULL, NULL);
1070
1083
        SectionType section_type;
1071
1084
 
1072
1085
        if (!gtk_tree_view_get_dest_row_at_pos (tree_view,
1073
 
                                           x,
1074
 
                                           y,
1075
 
                                           path,
1076
 
                                           pos)) {
 
1086
                                                x, y,
 
1087
                                                path, pos)) {
1077
1088
                return FALSE;
1078
1089
        }
1079
1090
 
1570
1581
        sidebar->popup_menu_start_item = NULL;
1571
1582
        sidebar->popup_menu_stop_item = NULL;
1572
1583
        sidebar->popup_menu_empty_trash_item = NULL;
 
1584
        sidebar->popup_menu_properties_separator_item = NULL;
 
1585
        sidebar->popup_menu_properties_item = NULL;
1573
1586
}
1574
1587
 
1575
1588
static void
1640
1653
        GDrive *drive = NULL;
1641
1654
        GVolume *volume = NULL;
1642
1655
        GMount *mount = NULL;
 
1656
        GFile *location;
 
1657
        NautilusDirectory *directory;
1643
1658
        gboolean show_mount;
1644
1659
        gboolean show_unmount;
1645
1660
        gboolean show_eject;
1647
1662
        gboolean show_start;
1648
1663
        gboolean show_stop;
1649
1664
        gboolean show_empty_trash;
 
1665
        gboolean show_properties;
1650
1666
        char *uri = NULL;
1651
1667
        
1652
1668
        type = PLACES_BUILT_IN;
1681
1697
        show_empty_trash = (uri != NULL) &&
1682
1698
                           (!strcmp (uri, "trash:///"));
1683
1699
 
 
1700
        /* Only show properties for local mounts */
 
1701
        show_properties = (mount != NULL);
 
1702
        if (mount != NULL) {
 
1703
                location = g_mount_get_default_location (mount);
 
1704
                directory = nautilus_directory_get (location);
 
1705
 
 
1706
                show_properties = nautilus_directory_is_local (directory);
 
1707
 
 
1708
                nautilus_directory_unref (directory);
 
1709
                g_object_unref (location);
 
1710
        }
 
1711
 
1684
1712
        gtk_widget_set_visible (sidebar->popup_menu_separator_item,
1685
1713
                      show_mount || show_unmount || show_eject || show_empty_trash);
1686
1714
        gtk_widget_set_visible (sidebar->popup_menu_mount_item, show_mount);
1690
1718
        gtk_widget_set_visible (sidebar->popup_menu_start_item, show_start);
1691
1719
        gtk_widget_set_visible (sidebar->popup_menu_stop_item, show_stop);
1692
1720
        gtk_widget_set_visible (sidebar->popup_menu_empty_trash_item, show_empty_trash);
 
1721
        gtk_widget_set_visible (sidebar->popup_menu_properties_separator_item, show_properties);
 
1722
        gtk_widget_set_visible (sidebar->popup_menu_properties_item, show_properties);
1693
1723
 
1694
1724
        /* Adjust start/stop items to reflect the type of the drive */
1695
1725
        gtk_menu_item_set_label (GTK_MENU_ITEM (sidebar->popup_menu_start_item), _("_Start"));
1877
1907
                         NautilusWindowOpenFlags               flags)
1878
1908
{
1879
1909
        GtkTreeModel *model;
1880
 
        GtkTreePath *path;
1881
1910
        GtkTreeIter iter;
 
1911
        GtkTreePath *path = NULL;
1882
1912
 
1883
1913
        model = gtk_tree_view_get_model (sidebar->tree_view);
1884
1914
        gtk_tree_view_get_cursor (sidebar->tree_view, &path, NULL);
1885
1915
 
1886
 
        gtk_tree_model_get_iter (model, &iter, path);
1887
 
 
1888
 
        open_selected_bookmark (sidebar, model, &iter, flags);
 
1916
        if (path != NULL && gtk_tree_model_get_iter (model, &iter, path)) {
 
1917
                open_selected_bookmark (sidebar, model, &iter, flags);
 
1918
        }
1889
1919
 
1890
1920
        gtk_tree_path_free (path);
1891
1921
}
2500
2530
        return find_prev_or_next_row (sidebar, iter, FALSE);
2501
2531
}
2502
2532
 
 
2533
static void
 
2534
properties_cb (GtkMenuItem           *item,
 
2535
               NautilusPlacesSidebar *sidebar)
 
2536
{
 
2537
        GtkTreeModel *model;
 
2538
        GtkTreePath *path = NULL;
 
2539
        GtkTreeIter iter;
 
2540
        GList *list;
 
2541
        NautilusFile *file;
 
2542
        char *uri;
 
2543
 
 
2544
        model = gtk_tree_view_get_model (sidebar->tree_view);
 
2545
        gtk_tree_view_get_cursor (sidebar->tree_view, &path, NULL);
 
2546
 
 
2547
        if (path == NULL || !gtk_tree_model_get_iter (model, &iter, path)) {
 
2548
                gtk_tree_path_free (path);
 
2549
                return;
 
2550
        }
 
2551
 
 
2552
        gtk_tree_model_get (model, &iter, PLACES_SIDEBAR_COLUMN_URI, &uri, -1);
 
2553
 
 
2554
        if (uri != NULL) {
 
2555
 
 
2556
                file = nautilus_file_get_by_uri (uri);
 
2557
                list = g_list_prepend (NULL, nautilus_file_ref (file));
 
2558
 
 
2559
                nautilus_properties_window_present (list, GTK_WIDGET (sidebar), NULL);
 
2560
 
 
2561
                nautilus_file_list_free (list);
 
2562
                g_free (uri);
 
2563
        }
 
2564
 
 
2565
        gtk_tree_path_free (path);
 
2566
}
 
2567
 
2503
2568
/* Handler for GtkWidget::key-press-event on the shortcuts list */
2504
2569
static gboolean
2505
2570
bookmarks_key_press_event_cb (GtkWidget             *widget,
2699
2764
        gtk_widget_show (item);
2700
2765
        gtk_menu_shell_append (GTK_MENU_SHELL (sidebar->popup_menu), item);
2701
2766
 
 
2767
        /* Properties menu item */
 
2768
 
 
2769
        sidebar->popup_menu_properties_separator_item =
 
2770
                GTK_WIDGET (eel_gtk_menu_append_separator (GTK_MENU (sidebar->popup_menu)));
 
2771
 
 
2772
        item = gtk_menu_item_new_with_mnemonic (_("_Properties"));
 
2773
        sidebar->popup_menu_properties_item = item;
 
2774
        g_signal_connect (item, "activate",
 
2775
                          G_CALLBACK (properties_cb), sidebar);
 
2776
        gtk_widget_show (item);
 
2777
        gtk_menu_shell_append (GTK_MENU_SHELL (sidebar->popup_menu), item);
 
2778
 
2702
2779
        bookmarks_check_popup_sensitivity (sidebar);
2703
2780
}
2704
2781
 
2714
2791
{
2715
2792
        bookmarks_update_popup_menu (sidebar);
2716
2793
        eel_pop_up_context_menu (GTK_MENU(sidebar->popup_menu),
2717
 
                              EEL_DEFAULT_POPUP_MENU_DISPLACEMENT,
2718
 
                              EEL_DEFAULT_POPUP_MENU_DISPLACEMENT,
2719
 
                              event);
 
2794
                                 event);
2720
2795
}
2721
2796
 
2722
2797
/* Callback used for the GtkWidget::popup-menu signal of the shortcuts list */
2882
2957
bookmarks_button_press_event_cb (GtkWidget             *widget,
2883
2958
                                 GdkEventButton        *event,
2884
2959
                                 NautilusPlacesSidebar *sidebar)
 
2960
 
2885
2961
{
 
2962
        GtkTreeModel *model;
 
2963
        GtkTreeView *tree_view;
 
2964
        GtkTreeIter iter;
 
2965
        GtkTreePath *path = NULL;
 
2966
        gboolean retval = FALSE;
 
2967
 
2886
2968
        if (event->type != GDK_BUTTON_PRESS) {
2887
2969
                /* ignore multiple clicks */
2888
2970
                return TRUE;
2889
2971
        }
2890
2972
 
 
2973
        tree_view = GTK_TREE_VIEW (widget);
 
2974
        model = gtk_tree_view_get_model (tree_view);
 
2975
        gtk_tree_view_get_path_at_pos (tree_view, (int) event->x, (int) event->y, 
 
2976
                                       &path, NULL, NULL, NULL);
 
2977
 
 
2978
        if (path == NULL || !gtk_tree_model_get_iter (model, &iter, path)) {
 
2979
                return FALSE;
 
2980
        }
 
2981
 
2891
2982
        if (event->button == 3) {
2892
2983
                bookmarks_popup_menu (sidebar, event);
2893
2984
        } else if (event->button == 2) {
2894
 
                GtkTreeModel *model;
2895
 
                GtkTreePath *path;
2896
 
                GtkTreeIter iter;
2897
 
                GtkTreeView *tree_view;
2898
2985
                NautilusWindowOpenFlags flags = 0;
2899
 
                gboolean res;
2900
 
 
2901
 
                tree_view = GTK_TREE_VIEW (widget);
2902
 
                g_assert (tree_view == sidebar->tree_view);
2903
 
 
2904
 
                model = gtk_tree_view_get_model (tree_view);
2905
 
 
2906
 
                res = gtk_tree_view_get_path_at_pos (tree_view, (int) event->x, (int) event->y, 
2907
 
                                                     &path, NULL, NULL, NULL);
2908
 
 
2909
 
                if (!res) {
2910
 
                        return FALSE;
2911
 
                }
2912
 
 
2913
 
                gtk_tree_model_get_iter (model, &iter, path);
2914
2986
 
2915
2987
                if (g_settings_get_boolean (nautilus_preferences,
2916
2988
                                            NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
2922
2994
                }
2923
2995
 
2924
2996
                open_selected_bookmark (sidebar, model, &iter, flags);
2925
 
 
2926
 
                if (path != NULL) {
2927
 
                        gtk_tree_path_free (path);
2928
 
                        return TRUE;
2929
 
                }
 
2997
                retval = TRUE;
2930
2998
        }
2931
2999
 
2932
 
        return FALSE;
 
3000
        gtk_tree_path_free (path);
 
3001
 
 
3002
        return retval;
2933
3003
}
2934
3004
 
2935
3005