~ubuntu-branches/ubuntu/trusty/nautilus/trusty-proposed

« back to all changes in this revision

Viewing changes to .pc/interactive_search.patch/src/nautilus-list-view.c

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2014-01-02 16:50:06 UTC
  • mfrom: (1.17.43)
  • Revision ID: package-import@ubuntu.com-20140102165006-1ghk9ropzitdc8pp
Tags: 1:3.10.1-0ubuntu1
* New upstream release
* debian/control.in: bump depend on gtk+ 3.9.11
* debian/patches:
  - Dropped git patches, that are included in new version
  - 06_never_exec_nonexec_launchers.patch, refreshed
  - disconnect-extra-location-widgets.patch, dropped included in new version
  - 16_unity_new_documents.patch, refreshed
  - ubuntu_show_titlebar.patch, disable CSD titlebar on non-GNOME sessions
  - ubuntu_titlebar_css.patch, theme fixes (LP: #1272602)

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "nautilus-list-model.h"
32
32
#include "nautilus-error-reporting.h"
33
33
#include "nautilus-view-dnd.h"
34
 
#include "nautilus-view-factory.h"
35
34
 
36
35
#include <string.h>
37
36
#include <eel/eel-vfs-extensions.h>
141
140
                                                                  GError            *error,
142
141
                                                                  gpointer           callback_data);
143
142
 
 
143
static void   apply_columns_settings                             (NautilusListView *list_view,
 
144
                                                                  char **column_order,
 
145
                                                                  char **visible_columns);
 
146
static char **get_visible_columns                                (NautilusListView *list_view);
 
147
static char **get_default_visible_columns                        (NautilusListView *list_view);
 
148
static char **get_column_order                                   (NautilusListView *list_view);
 
149
static char **get_default_column_order                           (NautilusListView *list_view);
 
150
 
144
151
 
145
152
G_DEFINE_TYPE (NautilusListView, nautilus_list_view, NAUTILUS_TYPE_VIEW);
146
153
 
 
154
static const char * default_search_visible_columns[] = {
 
155
        "name", "size", "type", "where", NULL
 
156
};
 
157
 
 
158
static const char * default_search_columns_order[] = {
 
159
        "name", "size", "type", "where", NULL
 
160
};
 
161
 
147
162
static const char * default_trash_visible_columns[] = {
148
163
        "name", "size", "type", "trashed_on", "trash_orig_path", NULL
149
164
};
381
396
        view->details->drag_button = 0;
382
397
}
383
398
 
384
 
static GdkPixbuf *
385
 
get_drag_pixbuf (NautilusListView *view)
 
399
static cairo_surface_t *
 
400
get_drag_surface (NautilusListView *view)
386
401
{
387
402
        GtkTreeModel *model;
388
403
        GtkTreePath *path;
389
404
        GtkTreeIter iter;
390
 
        GdkPixbuf *ret;
 
405
        cairo_surface_t *ret;
391
406
        GdkRectangle cell_area;
392
407
        
393
408
        ret = NULL;
488
503
                     NautilusListView *view)
489
504
{
490
505
        GList *selection_cache;
491
 
        GdkPixbuf *pixbuf;
 
506
        cairo_surface_t *surface;
492
507
 
493
 
        pixbuf = get_drag_pixbuf (view);
494
 
        if (pixbuf) {
495
 
                gtk_drag_set_icon_pixbuf (context,
496
 
                                          pixbuf,
497
 
                                          0, 0);
498
 
                g_object_unref (pixbuf);
 
508
        surface = get_drag_surface (view);
 
509
        if (surface) {
 
510
                gtk_drag_set_icon_surface (context, surface);
 
511
                cairo_surface_destroy (surface);
499
512
        } else {
500
513
                gtk_drag_set_icon_default (context);
501
514
        }
819
832
                        gtk_widget_grab_focus (widget);
820
833
                }
821
834
 
822
 
                if (is_simple_click) {
 
835
                if (is_simple_click && !on_expander) {
823
836
                        view->details->drag_started = FALSE;
824
837
                        view->details->drag_button = event->button;
825
838
                        view->details->drag_x = event->x;
1436
1449
}
1437
1450
 
1438
1451
static void
 
1452
column_header_menu_toggled (GtkCheckMenuItem *menu_item,
 
1453
                            NautilusListView *list_view)
 
1454
{
 
1455
        NautilusFile *file;
 
1456
        char **visible_columns;
 
1457
        char **column_order;
 
1458
        const char *column;
 
1459
        GList *list = NULL;
 
1460
        GList *l;
 
1461
        int i;
 
1462
 
 
1463
        file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (list_view));
 
1464
        visible_columns = get_visible_columns (list_view);
 
1465
        column_order = get_column_order (list_view);
 
1466
        column = g_object_get_data (G_OBJECT (menu_item), "column-name");
 
1467
 
 
1468
        for (i = 0; visible_columns[i] != NULL; ++i) {
 
1469
                list = g_list_prepend (list, visible_columns[i]);
 
1470
        }
 
1471
 
 
1472
        if (gtk_check_menu_item_get_active (menu_item)) {
 
1473
                list = g_list_prepend (list, g_strdup (column));
 
1474
        } else {
 
1475
                l = g_list_find_custom (list, column, (GCompareFunc) g_strcmp0);
 
1476
                list = g_list_delete_link (list, l);
 
1477
        }
 
1478
 
 
1479
        list = g_list_reverse (list);
 
1480
        nautilus_file_set_metadata_list (file,
 
1481
                                         NAUTILUS_METADATA_KEY_LIST_VIEW_VISIBLE_COLUMNS,
 
1482
                                         list);
 
1483
 
 
1484
        g_free (visible_columns);
 
1485
 
 
1486
        visible_columns = g_new0 (char *, g_list_length (list) + 1);
 
1487
        for (i = 0, l = list; l != NULL; ++i, l = l->next) {
 
1488
                visible_columns[i] = l->data;
 
1489
        }
 
1490
 
 
1491
        /* set view values ourselves, as new metadata could not have been
 
1492
         * updated yet.
 
1493
         */
 
1494
        apply_columns_settings (list_view, column_order, visible_columns);
 
1495
 
 
1496
        g_list_free (list);
 
1497
        g_strfreev (column_order);
 
1498
        g_strfreev (visible_columns);
 
1499
}
 
1500
 
 
1501
static void
 
1502
column_header_menu_use_default (GtkMenuItem *menu_item,
 
1503
                                NautilusListView *list_view)
 
1504
{
 
1505
        NautilusFile *file;
 
1506
        char **default_columns;
 
1507
        char **default_order;
 
1508
 
 
1509
        file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (list_view));
 
1510
 
 
1511
        nautilus_file_set_metadata_list (file, NAUTILUS_METADATA_KEY_LIST_VIEW_COLUMN_ORDER, NULL);
 
1512
        nautilus_file_set_metadata_list (file, NAUTILUS_METADATA_KEY_LIST_VIEW_VISIBLE_COLUMNS, NULL);
 
1513
 
 
1514
        default_columns = get_default_visible_columns (list_view);
 
1515
        default_order = get_default_column_order (list_view);
 
1516
 
 
1517
        /* set view values ourselves, as new metadata could not have been
 
1518
         * updated yet.
 
1519
         */
 
1520
        apply_columns_settings (list_view, default_order, default_columns);
 
1521
 
 
1522
        g_strfreev (default_columns);
 
1523
        g_strfreev (default_order);
 
1524
}
 
1525
 
 
1526
static gboolean
 
1527
column_header_clicked (GtkWidget *column_button,
 
1528
                       GdkEventButton *event,
 
1529
                       NautilusListView *list_view)
 
1530
{
 
1531
        NautilusFile *file;
 
1532
        char **visible_columns;
 
1533
        char **column_order;
 
1534
        GList *all_columns;
 
1535
        GHashTable *visible_columns_hash;
 
1536
        int i;
 
1537
        GList *l;
 
1538
        GtkWidget *menu;
 
1539
        GtkWidget *menu_item;
 
1540
 
 
1541
        if (event->button != GDK_BUTTON_SECONDARY) {
 
1542
                return FALSE;
 
1543
        }
 
1544
 
 
1545
        file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (list_view));
 
1546
 
 
1547
        visible_columns = get_visible_columns (list_view);
 
1548
        column_order = get_column_order (list_view);
 
1549
 
 
1550
        all_columns = nautilus_get_columns_for_file (file);
 
1551
        all_columns = nautilus_sort_columns (all_columns, column_order);
 
1552
 
 
1553
        /* hash table to lookup if a given column should be visible */
 
1554
        visible_columns_hash = g_hash_table_new_full (g_str_hash,
 
1555
                                                      g_str_equal,
 
1556
                                                      (GDestroyNotify) g_free,
 
1557
                                                      (GDestroyNotify) g_free);
 
1558
        /* always show name column */
 
1559
        g_hash_table_insert (visible_columns_hash, g_strdup ("name"), g_strdup ("name"));
 
1560
        if (visible_columns != NULL) {
 
1561
                for (i = 0; visible_columns[i] != NULL; ++i) {
 
1562
                        g_hash_table_insert (visible_columns_hash,
 
1563
                                             g_ascii_strdown (visible_columns[i], -1),
 
1564
                                             g_ascii_strdown (visible_columns[i], -1));
 
1565
                }
 
1566
        }
 
1567
 
 
1568
        menu = gtk_menu_new ();
 
1569
 
 
1570
        for (l = all_columns; l != NULL; l = l->next) {
 
1571
                char *name;
 
1572
                char *label;
 
1573
                char *lowercase;
 
1574
 
 
1575
                g_object_get (G_OBJECT (l->data),
 
1576
                              "name", &name,
 
1577
                              "label", &label,
 
1578
                              NULL);
 
1579
                lowercase = g_ascii_strdown (name, -1);
 
1580
 
 
1581
                menu_item = gtk_check_menu_item_new_with_label (label);
 
1582
                gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
 
1583
 
 
1584
                g_object_set_data_full (G_OBJECT (menu_item),
 
1585
                                        "column-name", name, g_free);
 
1586
 
 
1587
                /* name is always visible */
 
1588
                if (strcmp (lowercase, "name") == 0) {
 
1589
                        gtk_widget_set_sensitive (menu_item, FALSE);
 
1590
                }
 
1591
 
 
1592
                if (g_hash_table_lookup (visible_columns_hash, lowercase) != NULL) {
 
1593
                        gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
 
1594
                                                        TRUE);
 
1595
                }
 
1596
 
 
1597
                g_signal_connect (menu_item,
 
1598
                                  "toggled",
 
1599
                                  G_CALLBACK (column_header_menu_toggled),
 
1600
                                  list_view);
 
1601
 
 
1602
                g_free (lowercase);
 
1603
                g_free (label);
 
1604
        }
 
1605
 
 
1606
        menu_item = gtk_separator_menu_item_new ();
 
1607
        gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
 
1608
 
 
1609
        menu_item = gtk_menu_item_new_with_label (_("Use Default"));
 
1610
        gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
 
1611
 
 
1612
        g_signal_connect (menu_item,
 
1613
                          "activate",
 
1614
                          G_CALLBACK (column_header_menu_use_default),
 
1615
                          list_view);
 
1616
 
 
1617
        gtk_widget_show_all (menu);
 
1618
        gtk_menu_popup_for_device (GTK_MENU (menu),
 
1619
                                   gdk_event_get_device ((GdkEvent *) event),
 
1620
                                   NULL, NULL, NULL, NULL, NULL,
 
1621
                                   event->button, event->time);
 
1622
 
 
1623
        g_hash_table_destroy (visible_columns_hash);
 
1624
        nautilus_column_list_free (all_columns);
 
1625
        g_strfreev (column_order);
 
1626
        g_strfreev (visible_columns);
 
1627
 
 
1628
        return TRUE;
 
1629
}
 
1630
 
 
1631
static void
1439
1632
apply_columns_settings (NautilusListView *list_view,
1440
1633
                        char **column_order,
1441
1634
                        char **visible_columns)
1496
1689
 
1497
1690
        view_columns = g_list_reverse (view_columns);
1498
1691
 
1499
 
        /* remove columns that are not present in the configuration */
 
1692
        /* hide columns that are not present in the configuration */
1500
1693
        old_view_columns = gtk_tree_view_get_columns (list_view->details->tree_view);
1501
1694
        for (l = old_view_columns; l != NULL; l = l->next) {
1502
1695
                if (g_list_find (view_columns, l->data) == NULL) {
1503
 
                        gtk_tree_view_remove_column (list_view->details->tree_view, l->data);
 
1696
                        gtk_tree_view_column_set_visible (l->data, FALSE);
1504
1697
                }
1505
1698
        }
1506
1699
        g_list_free (old_view_columns);
1507
1700
 
1508
 
        /* append new columns from the configuration */
1509
 
        old_view_columns = gtk_tree_view_get_columns (list_view->details->tree_view);
 
1701
        /* show new columns from the configuration */
1510
1702
        for (l = view_columns; l != NULL; l = l->next) {
1511
 
                if (g_list_find (old_view_columns, l->data) == NULL) {
1512
 
                        gtk_tree_view_append_column (list_view->details->tree_view, l->data);
1513
 
                }
 
1703
                gtk_tree_view_column_set_visible (l->data, TRUE);
1514
1704
        }
1515
 
        g_list_free (old_view_columns);
1516
1705
 
1517
1706
        /* place columns in the correct order */
1518
1707
        prev_view_column = NULL;
1561
1750
}
1562
1751
 
1563
1752
static void
 
1753
location_cell_data_func (GtkTreeViewColumn *column,
 
1754
                         GtkCellRenderer   *renderer,
 
1755
                         GtkTreeModel      *model,
 
1756
                         GtkTreeIter       *iter,
 
1757
                         NautilusListView  *view,
 
1758
                         gboolean           show_trash_orig)
 
1759
{
 
1760
        NautilusDirectory *directory;
 
1761
        GFile *home_location;
 
1762
        NautilusFile *file;
 
1763
        GFile *dir_location;
 
1764
        GFile *base_location;
 
1765
        gchar *where = NULL;
 
1766
 
 
1767
        directory = nautilus_view_get_model (NAUTILUS_VIEW (view));
 
1768
 
 
1769
        home_location = g_file_new_for_path (g_get_home_dir ());
 
1770
 
 
1771
        gtk_tree_model_get (model, iter,
 
1772
                            NAUTILUS_LIST_MODEL_FILE_COLUMN, &file,
 
1773
                            -1);
 
1774
 
 
1775
        /* The file might be NULL if we just toggled an expander
 
1776
         * and we're still loading the subdirectory.
 
1777
         */
 
1778
        if (file == NULL) {
 
1779
                return;
 
1780
        }
 
1781
 
 
1782
        if (show_trash_orig && nautilus_file_is_in_trash (file)) {
 
1783
                NautilusFile *orig_file;
 
1784
 
 
1785
                orig_file = nautilus_file_get_trash_original_file (file);
 
1786
 
 
1787
                if (orig_file != NULL) {
 
1788
                        nautilus_file_unref (file);
 
1789
                        file = orig_file;
 
1790
                }
 
1791
        }
 
1792
 
 
1793
        if (!nautilus_file_is_in_recent (file)) {
 
1794
                dir_location = nautilus_file_get_parent_location (file);
 
1795
        } else {
 
1796
                GFile *activation_location;
 
1797
 
 
1798
                activation_location = nautilus_file_get_activation_location (file);
 
1799
                dir_location = g_file_get_parent (activation_location);
 
1800
 
 
1801
                g_object_unref (activation_location);
 
1802
        }
 
1803
 
 
1804
        if (!NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
 
1805
                base_location = g_object_ref (home_location);
 
1806
        } else {
 
1807
                NautilusQuery *query;
 
1808
                gchar *base_uri;
 
1809
                NautilusFile *base;
 
1810
 
 
1811
                query = nautilus_search_directory_get_query (NAUTILUS_SEARCH_DIRECTORY (directory));
 
1812
                base_uri = nautilus_query_get_location (query);
 
1813
                base = nautilus_file_get_by_uri (base_uri);
 
1814
 
 
1815
                if (!nautilus_file_is_in_recent (base)) {
 
1816
                        base_location = nautilus_file_get_location (base);
 
1817
                } else {
 
1818
                        base_location = g_object_ref (home_location);
 
1819
                }
 
1820
 
 
1821
                nautilus_file_unref (base);
 
1822
                g_free (base_uri);
 
1823
                g_object_unref (query);
 
1824
        }
 
1825
 
 
1826
        if (g_file_equal (home_location, dir_location)) {
 
1827
                where = g_strdup (_("Home"));
 
1828
        } else if (g_file_equal (base_location, dir_location)) {
 
1829
                /* Only occurs when search result is
 
1830
                 * a direct child of the base location
 
1831
                 */
 
1832
                where = g_strdup ("");
 
1833
        } else if (g_file_has_prefix (dir_location, base_location)) {
 
1834
                gchar *relative_path;
 
1835
 
 
1836
                relative_path = g_file_get_relative_path (base_location,
 
1837
                                                          dir_location);
 
1838
                where = g_filename_display_name (relative_path);
 
1839
 
 
1840
                g_free (relative_path);
 
1841
        }
 
1842
 
 
1843
        if (where != NULL) {
 
1844
                g_object_set (G_OBJECT (renderer),
 
1845
                              "text", where,
 
1846
                              NULL);
 
1847
 
 
1848
                g_free (where);
 
1849
        }
 
1850
 
 
1851
        g_object_unref (base_location);
 
1852
        g_object_unref (dir_location);
 
1853
        nautilus_file_unref (file);
 
1854
        g_object_unref (home_location);
 
1855
}
 
1856
 
 
1857
 
 
1858
static void
 
1859
where_cell_data_func (GtkTreeViewColumn *column,
 
1860
                      GtkCellRenderer   *renderer,
 
1861
                      GtkTreeModel      *model,
 
1862
                      GtkTreeIter       *iter,
 
1863
                      NautilusListView  *view)
 
1864
{
 
1865
        location_cell_data_func (column, renderer, model, iter, view, FALSE);
 
1866
}
 
1867
 
 
1868
static void
 
1869
trash_orig_path_cell_data_func (GtkTreeViewColumn *column,
 
1870
                                GtkCellRenderer   *renderer,
 
1871
                                GtkTreeModel      *model,
 
1872
                                GtkTreeIter       *iter,
 
1873
                                NautilusListView  *view)
 
1874
{
 
1875
        location_cell_data_func (column, renderer, model, iter, view, TRUE);
 
1876
}
 
1877
 
 
1878
 
 
1879
static void
1564
1880
set_up_pixbuf_size (NautilusListView *view)
1565
1881
{
1566
1882
        int icon_size;
1575
1891
        gtk_tree_view_columns_autosize (view->details->tree_view);
1576
1892
}
1577
1893
 
 
1894
static gint
 
1895
get_icon_scale_callback (NautilusListModel *model,
 
1896
                         NautilusListView  *view)
 
1897
{
 
1898
        return gtk_widget_get_scale_factor (GTK_WIDGET (view->details->tree_view));
 
1899
}
 
1900
 
1578
1901
static void
1579
1902
create_and_set_up_tree_view (NautilusListView *view)
1580
1903
{
1588
1911
        view->details->tree_view = GTK_TREE_VIEW (gtk_tree_view_new ());
1589
1912
        view->details->columns = g_hash_table_new_full (g_str_hash, 
1590
1913
                                                        g_str_equal,
1591
 
                                                        (GDestroyNotify)g_free,
1592
 
                                                        (GDestroyNotify) g_object_unref);
 
1914
                                                        (GDestroyNotify) g_free,
 
1915
                                                        NULL);
1593
1916
        gtk_tree_view_set_enable_search (view->details->tree_view, FALSE);
1594
1917
 
1595
1918
        view->details->drag_dest = 
1661
1984
        g_signal_connect_object (view->details->model, "subdirectory-unloaded",
1662
1985
                                 G_CALLBACK (subdirectory_unloaded_callback), view, 0);
1663
1986
 
 
1987
        g_signal_connect_object (view->details->model, "get-icon-scale",
 
1988
                                 G_CALLBACK (get_icon_scale_callback), view, 0);
 
1989
 
1664
1990
        gtk_tree_selection_set_mode (gtk_tree_view_get_selection (view->details->tree_view), GTK_SELECTION_MULTIPLE);
1665
1991
        gtk_tree_view_set_rules_hint (view->details->tree_view, TRUE);
1666
1992
 
1695
2021
                if (!strcmp (name, "name")) {
1696
2022
                        /* Create the file name column */
1697
2023
                        view->details->file_name_column = gtk_tree_view_column_new ();
1698
 
                        g_object_ref_sink (view->details->file_name_column);
 
2024
                        gtk_tree_view_append_column (view->details->tree_view,
 
2025
                                                     view->details->file_name_column);
1699
2026
                        view->details->file_name_column_num = column_num;
1700
2027
                        
1701
2028
                        g_hash_table_insert (view->details->columns,
1702
2029
                                             g_strdup ("name"), 
1703
2030
                                             view->details->file_name_column);
1704
2031
 
 
2032
                        g_signal_connect (gtk_tree_view_column_get_button (view->details->file_name_column),
 
2033
                                          "button-press-event",
 
2034
                                          G_CALLBACK (column_header_clicked),
 
2035
                                          view);
 
2036
 
1705
2037
                        gtk_tree_view_set_search_column (view->details->tree_view, column_num);
1706
2038
 
1707
2039
                        gtk_tree_view_column_set_sort_column_id (view->details->file_name_column, column_num);
1725
2057
                        gtk_tree_view_column_pack_start (view->details->file_name_column, cell, FALSE);
1726
2058
                        gtk_tree_view_column_set_attributes (view->details->file_name_column,
1727
2059
                                                             cell,
1728
 
                                                             "pixbuf", nautilus_list_model_get_column_id_from_zoom_level (view->details->zoom_level),
 
2060
                                                             "surface", nautilus_list_model_get_column_id_from_zoom_level (view->details->zoom_level),
1729
2061
                                                             NULL);
1730
2062
                        
1731
2063
                        cell = gtk_cell_renderer_text_new ();
1756
2088
                                                                           cell,
1757
2089
                                                                           "text", column_num,
1758
2090
                                                                           NULL);
1759
 
                        g_object_ref_sink (column);
 
2091
                        gtk_tree_view_append_column (view->details->tree_view, column);
1760
2092
                        gtk_tree_view_column_set_sort_column_id (column, column_num);
1761
2093
                        g_hash_table_insert (view->details->columns, 
1762
2094
                                             g_strdup (name), 
1763
2095
                                             column);
 
2096
 
 
2097
                        g_signal_connect (gtk_tree_view_column_get_button (column),
 
2098
                                          "button-press-event",
 
2099
                                          G_CALLBACK (column_header_clicked),
 
2100
                                          view);
1764
2101
                        
1765
2102
                        gtk_tree_view_column_set_resizable (column, TRUE);
1766
 
                        gtk_tree_view_column_set_visible (column, TRUE);
1767
2103
                        gtk_tree_view_column_set_sort_order (column, sort_order);
 
2104
 
 
2105
                        if (!strcmp (name, "where")) {
 
2106
                                gtk_tree_view_column_set_cell_data_func (column, cell,
 
2107
                                                                         (GtkTreeCellDataFunc) where_cell_data_func,
 
2108
                                                                         view, NULL);
 
2109
                        } else if (!strcmp (name, "trash_orig_path")) {
 
2110
                                gtk_tree_view_column_set_cell_data_func (column, cell,
 
2111
                                                                         (GtkTreeCellDataFunc) trash_orig_path_cell_data_func,
 
2112
                                                                         view, NULL);
 
2113
                        }
1768
2114
                }
1769
2115
                g_free (name);
1770
2116
                g_free (label);
1803
2149
}
1804
2150
 
1805
2151
static char **
 
2152
get_default_visible_columns (NautilusListView *list_view)
 
2153
{
 
2154
        NautilusFile *file;
 
2155
        NautilusDirectory *directory;
 
2156
 
 
2157
        file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (list_view));
 
2158
 
 
2159
        if (nautilus_file_is_in_trash (file)) {
 
2160
                return g_strdupv ((gchar **) default_trash_visible_columns);
 
2161
        }
 
2162
 
 
2163
        directory = nautilus_view_get_model (NAUTILUS_VIEW (list_view));
 
2164
        if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
 
2165
                return g_strdupv ((gchar **) default_search_visible_columns);
 
2166
        }
 
2167
 
 
2168
        return g_settings_get_strv (nautilus_list_view_preferences,
 
2169
                                    NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS);
 
2170
}
 
2171
 
 
2172
static char **
1806
2173
get_visible_columns (NautilusListView *list_view)
1807
2174
{
1808
2175
        NautilusFile *file;
1809
2176
        GList *visible_columns;
1810
 
        char **ret;
1811
 
 
1812
 
        ret = NULL;
1813
2177
 
1814
2178
        file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (list_view));
1815
2179
 
1816
 
        visible_columns = nautilus_file_get_metadata_list 
 
2180
        visible_columns = nautilus_file_get_metadata_list
1817
2181
                (file,
1818
2182
                 NAUTILUS_METADATA_KEY_LIST_VIEW_VISIBLE_COLUMNS);
1819
2183
 
1827
2191
                }
1828
2192
                g_ptr_array_add (res, NULL);
1829
2193
 
1830
 
                ret = (char **) g_ptr_array_free (res, FALSE);
1831
2194
                g_list_free (visible_columns);
1832
 
        }
1833
 
 
1834
 
        if (ret != NULL) {
1835
 
                return ret;
1836
 
        }
1837
 
 
1838
 
        return nautilus_file_is_in_trash (file) ?
1839
 
                g_strdupv ((gchar **) default_trash_visible_columns) :
1840
 
                g_settings_get_strv (nautilus_list_view_preferences,
1841
 
                                     NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS);
 
2195
 
 
2196
                return (char **) g_ptr_array_free (res, FALSE);
 
2197
        }
 
2198
 
 
2199
        return get_default_visible_columns (list_view);
 
2200
}
 
2201
 
 
2202
static char **
 
2203
get_default_column_order (NautilusListView *list_view)
 
2204
{
 
2205
        NautilusFile *file;
 
2206
        NautilusDirectory *directory;
 
2207
 
 
2208
        file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (list_view));
 
2209
 
 
2210
        if (nautilus_file_is_in_trash (file)) {
 
2211
                return g_strdupv ((gchar **) default_trash_columns_order);
 
2212
        }
 
2213
 
 
2214
        directory = nautilus_view_get_model (NAUTILUS_VIEW (list_view));
 
2215
        if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
 
2216
                return g_strdupv ((gchar **) default_search_columns_order);
 
2217
        }
 
2218
 
 
2219
        return g_settings_get_strv (nautilus_list_view_preferences,
 
2220
                                    NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER);
1842
2221
}
1843
2222
 
1844
2223
static char **
1846
2225
{
1847
2226
        NautilusFile *file;
1848
2227
        GList *column_order;
1849
 
        char **ret;
1850
 
 
1851
 
        ret = NULL;
1852
2228
 
1853
2229
        file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (list_view));
1854
2230
 
1855
 
        column_order = nautilus_file_get_metadata_list 
 
2231
        column_order = nautilus_file_get_metadata_list
1856
2232
                (file,
1857
2233
                 NAUTILUS_METADATA_KEY_LIST_VIEW_COLUMN_ORDER);
1858
2234
 
1866
2242
                }
1867
2243
                g_ptr_array_add (res, NULL);
1868
2244
 
1869
 
                ret = (char **) g_ptr_array_free (res, FALSE);
1870
2245
                g_list_free (column_order);
1871
 
        }
1872
 
 
1873
 
        if (ret != NULL) {
1874
 
                return ret;
1875
 
        }
1876
 
 
1877
 
        return nautilus_file_is_in_trash (file) ?
1878
 
                g_strdupv ((gchar **) default_trash_columns_order) :
1879
 
                g_settings_get_strv (nautilus_list_view_preferences,
1880
 
                                     NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER);
 
2246
 
 
2247
                return (char **) g_ptr_array_free (res, FALSE);
 
2248
        }
 
2249
 
 
2250
        return get_default_column_order (list_view);
1881
2251
}
1882
2252
 
1883
2253
static void
2543
2913
        /* set view values ourselves, as new metadata could not have been
2544
2914
         * updated yet.
2545
2915
         */
2546
 
        default_columns = nautilus_file_is_in_trash (file) ?
2547
 
                g_strdupv ((gchar **) default_trash_visible_columns) :
2548
 
                g_settings_get_strv (nautilus_list_view_preferences,
2549
 
                                     NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS);
2550
 
 
2551
 
        default_order = nautilus_file_is_in_trash (file) ?
2552
 
                g_strdupv ((gchar **) default_trash_columns_order) :
2553
 
                g_settings_get_strv (nautilus_list_view_preferences,
2554
 
                                     NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER);
 
2916
        default_columns = get_default_visible_columns (view);
 
2917
        default_order = get_default_column_order (view);
2555
2918
 
2556
2919
        apply_columns_settings (view, default_order, default_columns);
2557
2920
        column_chooser_set_from_arrays (chooser, view,
2582
2945
        window = gtk_dialog_new_with_buttons (str,
2583
2946
                                              GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
2584
2947
                                              GTK_DIALOG_DESTROY_WITH_PARENT,
2585
 
                                              GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
 
2948
                                              _("_Close"), GTK_RESPONSE_CLOSE,
2586
2949
                                              NULL);
2587
2950
        g_free (str);
2588
2951
        g_signal_connect (window, "response", 
2725
3088
        NautilusFile *file;
2726
3089
        const gchar *default_sort_order;
2727
3090
        gboolean default_sort_reversed;
 
3091
        char **default_columns;
 
3092
        char **default_order;
2728
3093
 
2729
3094
        file = nautilus_view_get_directory_as_file (view);
2730
3095
 
2742
3107
                 default_sort_reversed ? GTK_SORT_DESCENDING : GTK_SORT_ASCENDING);
2743
3108
 
2744
3109
        nautilus_list_view_set_zoom_level (NAUTILUS_LIST_VIEW (view), get_default_zoom_level (), FALSE);
2745
 
        set_columns_settings_from_metadata_and_preferences (NAUTILUS_LIST_VIEW (view));
 
3110
 
 
3111
        default_columns = get_default_visible_columns (NAUTILUS_LIST_VIEW (view));
 
3112
        default_order = get_default_column_order (NAUTILUS_LIST_VIEW (view));
 
3113
 
 
3114
        apply_columns_settings (NAUTILUS_LIST_VIEW (view), default_order, default_columns);
 
3115
 
 
3116
        g_strfreev (default_columns);
 
3117
        g_strfreev (default_order);
2746
3118
}
2747
3119
 
2748
3120
static void
2770
3142
        column = nautilus_list_model_get_column_id_from_zoom_level (new_level);
2771
3143
        gtk_tree_view_column_set_attributes (view->details->file_name_column,
2772
3144
                                             GTK_CELL_RENDERER (view->details->pixbuf_cell),
2773
 
                                             "pixbuf", column,
 
3145
                                             "surface", column,
2774
3146
                                             NULL);
2775
3147
 
2776
3148
        nautilus_view_update_menus (NAUTILUS_VIEW (view));
3286
3658
                                  G_CALLBACK (list_view_notify_clipboard_info), list_view);
3287
3659
}
3288
3660
 
3289
 
static NautilusView *
3290
 
nautilus_list_view_create (NautilusWindowSlot *slot)
 
3661
NautilusView *
 
3662
nautilus_list_view_new (NautilusWindowSlot *slot)
3291
3663
{
3292
 
        NautilusListView *view;
3293
 
 
3294
 
        view = g_object_new (NAUTILUS_TYPE_LIST_VIEW,
 
3664
        return g_object_new (NAUTILUS_TYPE_LIST_VIEW,
3295
3665
                             "window-slot", slot,
3296
3666
                             NULL);
3297
 
        return NAUTILUS_VIEW (view);
3298
 
}
3299
 
 
3300
 
static gboolean
3301
 
nautilus_list_view_supports_uri (const char *uri,
3302
 
                                 GFileType file_type,
3303
 
                                 const char *mime_type)
3304
 
{
3305
 
        if (file_type == G_FILE_TYPE_DIRECTORY) {
3306
 
                return TRUE;
3307
 
        }
3308
 
        if (strcmp (mime_type, NAUTILUS_SAVED_SEARCH_MIMETYPE) == 0){
3309
 
                return TRUE;
3310
 
        }
3311
 
        if (g_str_has_prefix (uri, "trash:")) {
3312
 
                return TRUE;
3313
 
        }
3314
 
        if (g_str_has_prefix (uri, EEL_SEARCH_URI)) {
3315
 
                return TRUE;
3316
 
        }
3317
 
 
3318
 
        return FALSE;
3319
 
}
3320
 
 
3321
 
static NautilusViewInfo nautilus_list_view = {
3322
 
        NAUTILUS_LIST_VIEW_ID,
3323
 
        /* translators: this is used in the view selection dropdown
3324
 
         * of navigation windows and in the preferences dialog */
3325
 
        N_("List View"),
3326
 
        /* translators: this is used in the view menu */
3327
 
        N_("_List"),
3328
 
        N_("The list view encountered an error."),
3329
 
        N_("The list view encountered an error while starting up."),
3330
 
        N_("Display this location with the list view."),
3331
 
        nautilus_list_view_create,
3332
 
        nautilus_list_view_supports_uri
3333
 
};
3334
 
 
3335
 
void
3336
 
nautilus_list_view_register (void)
3337
 
{
3338
 
        nautilus_list_view.view_combo_label = _(nautilus_list_view.view_combo_label);
3339
 
        nautilus_list_view.view_menu_label_with_mnemonic = _(nautilus_list_view.view_menu_label_with_mnemonic);
3340
 
        nautilus_list_view.error_label = _(nautilus_list_view.error_label);
3341
 
        nautilus_list_view.startup_error_label = _(nautilus_list_view.startup_error_label);
3342
 
        nautilus_list_view.display_location_label = _(nautilus_list_view.display_location_label);
3343
 
 
3344
 
        nautilus_view_factory_register (&nautilus_list_view);
3345
3667
}
3346
3668
 
3347
3669
GtkTreeView*