annotate src/view_file/view_file_list.c @ 2817:e6f95baec8b5

Fix #624: Filter files by shell or regular expression pattern https://github.com/BestImageViewer/geeqie/issues/624 An option on Select/Show File Filter (or the toolbar) to provide regular expression file-filtering of the currently displayed folder.
author Colin Clark <colin.clark@cclark.uk>
date Wed, 15 Aug 2018 19:43:06 +0100
parents 2feed80bcd34
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1 /*
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2 * Copyright (C) 2004 John Ellis
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
3 * Copyright (C) 2008 - 2016 The Geeqie Team
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
4 *
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
5 * Author: John Ellis
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
6 *
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
10 * (at your option) any later version.
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
11 *
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
15 * GNU General Public License for more details.
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
16 *
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License along
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
18 * with this program; if not, write to the Free Software Foundation, Inc.,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
20 */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
21
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
22 #include "main.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
23 #include "view_file_list.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
24
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
25 #include "bar.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
26 #include "cache_maint.h"
2793
2feed80bcd34 Collections changes
Colin Clark <colin.clark@cclark.uk>
parents: 2772
diff changeset
27 #include "collect.h"
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
28 #include "dnd.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
29 #include "editors.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
30 #include "img-view.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
31 #include "layout.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
32 #include "layout_image.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
33 #include "menu.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
34 #include "metadata.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
35 #include "thumb.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
36 #include "utilops.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
37 #include "ui_fileops.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
38 #include "ui_menu.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
39 #include "ui_tree_edit.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
40 #include "uri_utils.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
41 #include "view_file.h"
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
42
2793
2feed80bcd34 Collections changes
Colin Clark <colin.clark@cclark.uk>
parents: 2772
diff changeset
43
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
44 #include <gdk/gdkkeysyms.h> /* for keyboard values */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
45
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
46 /* Index to tree store */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
47 enum {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
48 FILE_COLUMN_POINTER = 0,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
49 FILE_COLUMN_VERSION,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
50 FILE_COLUMN_THUMB,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
51 FILE_COLUMN_FORMATTED,
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
52 FILE_COLUMN_FORMATTED_WITH_STARS,
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
53 FILE_COLUMN_NAME,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
54 FILE_COLUMN_SIDECARS,
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
55 FILE_COLUMN_STAR_RATING,
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
56 FILE_COLUMN_SIZE,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
57 FILE_COLUMN_DATE,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
58 FILE_COLUMN_EXPANDED,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
59 FILE_COLUMN_COLOR,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
60 FILE_COLUMN_MARKS,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
61 FILE_COLUMN_MARKS_LAST = FILE_COLUMN_MARKS + FILEDATA_MARKS_SIZE - 1,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
62 FILE_COLUMN_COUNT
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
63 };
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
64
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
65
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
66 /* Index to tree view */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
67 enum {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
68 FILE_VIEW_COLUMN_MARKS = 0,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
69 FILE_VIEW_COLUMN_MARKS_LAST = FILE_VIEW_COLUMN_MARKS + FILEDATA_MARKS_SIZE - 1,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
70 FILE_VIEW_COLUMN_THUMB,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
71 FILE_VIEW_COLUMN_FORMATTED,
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
72 FILE_VIEW_COLUMN_FORMATTED_WITH_STARS,
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
73 FILE_VIEW_COLUMN_STAR_RATING,
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
74 FILE_VIEW_COLUMN_SIZE,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
75 FILE_VIEW_COLUMN_DATE,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
76 FILE_VIEW_COLUMN_COUNT
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
77 };
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
78
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
79
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
80
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
81 static gboolean vflist_row_is_selected(ViewFile *vf, FileData *fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
82 static gboolean vflist_row_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
83 static void vflist_populate_view(ViewFile *vf, gboolean force);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
84 static gboolean vflist_is_multiline(ViewFile *vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
85 static void vflist_set_expanded(ViewFile *vf, GtkTreeIter *iter, gboolean expanded);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
86
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
87
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
88 /*
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
89 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
90 * misc
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
91 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
92 */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
93 typedef struct {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
94 FileData *fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
95 GtkTreeIter *iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
96 gboolean found;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
97 gint row;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
98 } ViewFileFindRowData;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
99
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
100 static gboolean vflist_find_row_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
101 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
102 ViewFileFindRowData *find = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
103 FileData *fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
104 gtk_tree_model_get(model, iter, FILE_COLUMN_POINTER, &fd, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
105 if (fd == find->fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
106 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
107 *find->iter = *iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
108 find->found = TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
109 return TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
110 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
111 find->row++;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
112 return FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
113 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
114
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
115 static gint vflist_find_row(ViewFile *vf, FileData *fd, GtkTreeIter *iter)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
116 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
117 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
118 ViewFileFindRowData data = {fd, iter, FALSE, 0};
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
119
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
120 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
121 gtk_tree_model_foreach(store, vflist_find_row_cb, &data);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
122
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
123 if (data.found)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
124 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
125 return data.row;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
126 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
127
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
128 return -1;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
129 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
130
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
131 static FileData *vflist_find_data_by_coord(ViewFile *vf, gint x, gint y, GtkTreeIter *iter)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
132 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
133 GtkTreePath *tpath;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
134 GtkTreeViewColumn *column;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
135
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
136 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), x, y,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
137 &tpath, &column, NULL, NULL))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
138 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
139 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
140 GtkTreeIter row;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
141 FileData *fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
142
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
143 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
144 gtk_tree_model_get_iter(store, &row, tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
145 gtk_tree_path_free(tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
146 gtk_tree_model_get(store, &row, FILE_COLUMN_POINTER, &fd, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
147
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
148 return fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
149 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
150
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
151 return NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
152 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
153
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
154 static gboolean vflist_store_clear_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
155 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
156 FileData *fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
157 gtk_tree_model_get(model, iter, FILE_COLUMN_POINTER, &fd, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
158
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
159 /* it seems that gtk_tree_store_clear may call some callbacks
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
160 that use the column. Set the pointer to NULL to be safe. */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
161 gtk_tree_store_set(GTK_TREE_STORE(model), iter, FILE_COLUMN_POINTER, NULL, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
162 file_data_unref(fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
163 return FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
164 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
165
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
166 static void vflist_store_clear(ViewFile *vf, gboolean unlock_files)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
167 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
168 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
169 GList *files = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
170
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
171 if (unlock_files && vf->marks_enabled)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
172 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
173 // unlock locked files in this directory
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
174 filelist_read(vf->dir_fd, &files, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
175 while (files)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
176 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
177 FileData *fd = files->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
178 files = files->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
179 file_data_unlock(fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
180 file_data_unref(fd); // undo the ref that got added in filelist_read
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
181 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
182 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
183
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
184 g_list_free(files);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
185 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
186 gtk_tree_model_foreach(store, vflist_store_clear_cb, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
187 gtk_tree_store_clear(GTK_TREE_STORE(store));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
188 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
189
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
190 void vflist_color_set(ViewFile *vf, FileData *fd, gboolean color_set)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
191 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
192 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
193 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
194
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
195 if (vflist_find_row(vf, fd, &iter) < 0) return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
196 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
197 gtk_tree_store_set(GTK_TREE_STORE(store), &iter, FILE_COLUMN_COLOR, color_set, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
198 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
199
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
200 static void vflist_move_cursor(ViewFile *vf, GtkTreeIter *iter)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
201 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
202 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
203 GtkTreePath *tpath;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
204
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
205 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
206
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
207 tpath = gtk_tree_model_get_path(store, iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
208 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vf->listview), tpath, NULL, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
209 gtk_tree_path_free(tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
210 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
211
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
212
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
213 /*
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
214 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
215 * dnd
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
216 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
217 */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
218
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
219 static void vflist_dnd_get(GtkWidget *widget, GdkDragContext *context,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
220 GtkSelectionData *selection_data, guint info,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
221 guint time, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
222 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
223 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
224 GList *list = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
225
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
226 if (!VFLIST(vf)->click_fd) return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
227
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
228 if (vflist_row_is_selected(vf, VFLIST(vf)->click_fd))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
229 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
230 list = vf_selection_get_list(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
231 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
232 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
233 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
234 list = g_list_append(NULL, file_data_ref(VFLIST(vf)->click_fd));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
235 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
236
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
237 if (!list) return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
238 uri_selection_data_set_uris_from_filelist(selection_data, list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
239 filelist_free(list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
240 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
241
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
242 static void vflist_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
243 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
244 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
245
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
246 vflist_color_set(vf, VFLIST(vf)->click_fd, TRUE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
247
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
248 if (VFLIST(vf)->thumbs_enabled &&
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
249 VFLIST(vf)->click_fd && VFLIST(vf)->click_fd->thumb_pixbuf)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
250 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
251 guint items;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
252
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
253 if (vflist_row_is_selected(vf, VFLIST(vf)->click_fd))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
254 items = vf_selection_count(vf, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
255 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
256 items = 1;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
257
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
258 dnd_set_drag_icon(widget, context, VFLIST(vf)->click_fd->thumb_pixbuf, items);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
259 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
260 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
261
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
262 static void vflist_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
263 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
264 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
265
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
266 vflist_color_set(vf, VFLIST(vf)->click_fd, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
267
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
268 if (gdk_drag_context_get_selected_action(context) == GDK_ACTION_MOVE)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
269 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
270 vf_refresh(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
271 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
272 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
273
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
274 static void vflist_drag_data_received(GtkWidget *entry_widget, GdkDragContext *context,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
275 int x, int y, GtkSelectionData *selection,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
276 guint info, guint time, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
277 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
278 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
279
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
280 if (info == TARGET_TEXT_PLAIN) {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
281 FileData *fd = vflist_find_data_by_coord(vf, x, y, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
282
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
283 if (fd) {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
284 /* Add keywords to file */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
285 gchar *str = (gchar *) gtk_selection_data_get_text(selection);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
286 GList *kw_list = string_to_keywords_list(str);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
287
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
288 metadata_append_list(fd, KEYWORD_KEY, kw_list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
289 string_list_free(kw_list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
290 g_free(str);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
291 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
292 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
293 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
294
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
295 void vflist_dnd_init(ViewFile *vf)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
296 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
297 gtk_drag_source_set(vf->listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
298 dnd_file_drag_types, dnd_file_drag_types_count,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
299 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
300 gtk_drag_dest_set(vf->listview, GTK_DEST_DEFAULT_ALL,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
301 dnd_file_drag_types, dnd_file_drag_types_count,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
302 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
303
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
304 g_signal_connect(G_OBJECT(vf->listview), "drag_data_get",
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
305 G_CALLBACK(vflist_dnd_get), vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
306 g_signal_connect(G_OBJECT(vf->listview), "drag_begin",
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
307 G_CALLBACK(vflist_dnd_begin), vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
308 g_signal_connect(G_OBJECT(vf->listview), "drag_end",
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
309 G_CALLBACK(vflist_dnd_end), vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
310 g_signal_connect(G_OBJECT(vf->listview), "drag_data_received",
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
311 G_CALLBACK(vflist_drag_data_received), vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
312 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
313
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
314 /*
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
315 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
316 * pop-up menu
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
317 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
318 */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
319
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
320 GList *vflist_selection_get_one(ViewFile *vf, FileData *fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
321 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
322 GList *list = g_list_append(NULL, file_data_ref(fd));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
323
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
324 if (fd->sidecar_files)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
325 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
326 /* check if the row is expanded */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
327 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
328 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
329
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
330 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
331 if (vflist_find_row(vf, fd, &iter) >= 0)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
332 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
333 GtkTreePath *tpath;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
334
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
335 tpath = gtk_tree_model_get_path(store, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
336 if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(vf->listview), tpath))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
337 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
338 /* unexpanded - add whole group */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
339 GList *work = fd->sidecar_files;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
340 while (work)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
341 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
342 FileData *sfd = work->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
343 list = g_list_prepend(list, file_data_ref(sfd));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
344 work = work->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
345 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
346 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
347 gtk_tree_path_free(tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
348 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
349 list = g_list_reverse(list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
350 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
351
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
352 return list;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
353 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
354
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
355 GList *vflist_pop_menu_file_list(ViewFile *vf)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
356 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
357 if (!VFLIST(vf)->click_fd) return NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
358
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
359 if (vflist_row_is_selected(vf, VFLIST(vf)->click_fd))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
360 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
361 return vf_selection_get_list(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
362 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
363 return vflist_selection_get_one(vf, VFLIST(vf)->click_fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
364 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
365
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
366
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
367 void vflist_pop_menu_view_cb(GtkWidget *widget, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
368 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
369 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
370
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
371 if (vflist_row_is_selected(vf, VFLIST(vf)->click_fd))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
372 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
373 GList *list;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
374
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
375 list = vf_selection_get_list(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
376 view_window_new_from_list(list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
377 filelist_free(list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
378 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
379 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
380 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
381 view_window_new(VFLIST(vf)->click_fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
382 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
383 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
384
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
385 void vflist_pop_menu_rename_cb(GtkWidget *widget, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
386 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
387 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
388 GList *list;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
389
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
390 list = vf_pop_menu_file_list(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
391 if (options->file_ops.enable_in_place_rename &&
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
392 list && !list->next && VFLIST(vf)->click_fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
393 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
394 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
395 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
396
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
397 filelist_free(list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
398
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
399 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
400 if (vflist_find_row(vf, VFLIST(vf)->click_fd, &iter) >= 0)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
401 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
402 GtkTreePath *tpath;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
403
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
404 tpath = gtk_tree_model_get_path(store, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
405 tree_edit_by_path(GTK_TREE_VIEW(vf->listview), tpath,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
406 FILE_VIEW_COLUMN_FORMATTED, VFLIST(vf)->click_fd->name,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
407 vflist_row_rename_cb, vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
408 gtk_tree_path_free(tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
409 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
410 return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
411 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
412
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
413 file_util_rename(NULL, list, vf->listview);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
414 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
415
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
416 void vflist_pop_menu_thumbs_cb(GtkWidget *widget, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
417 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
418 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
419
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
420 vflist_color_set(vf, VFLIST(vf)->click_fd, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
421 if (vf->layout)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
422 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
423 layout_thumb_set(vf->layout, !VFLIST(vf)->thumbs_enabled);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
424 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
425 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
426 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
427 vflist_thumb_set(vf, !VFLIST(vf)->thumbs_enabled);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
428 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
429 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
430
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
431 void vflist_star_rating_set(ViewFile *vf, gboolean enable)
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
432 {
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
433 GList *columns, *work;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
434
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
435 columns = gtk_tree_view_get_columns(GTK_TREE_VIEW(vf->listview));
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
436
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
437 work = columns;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
438 while (work)
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
439 {
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
440 GtkTreeViewColumn *column = work->data;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
441 gint col_idx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_store_idx"));
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
442 work = work->next;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
443
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
444 if (vflist_is_multiline(vf))
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
445 {
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
446 if (col_idx == FILE_COLUMN_FORMATTED_WITH_STARS)
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
447 {
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
448 gtk_tree_view_column_set_visible(column, enable);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
449 }
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
450 if (col_idx == FILE_COLUMN_FORMATTED)
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
451 {
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
452 gtk_tree_view_column_set_visible(column, !enable);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
453 }
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
454 }
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
455 else
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
456 {
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
457 if (col_idx == FILE_COLUMN_STAR_RATING)
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
458 {
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
459 gtk_tree_view_column_set_visible(column, enable);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
460 }
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
461 }
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
462 }
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
463 g_list_free(columns);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
464 }
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
465
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
466 void vflist_pop_menu_show_star_rating_cb(GtkWidget *widget, gpointer data)
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
467 {
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
468 ViewFile *vf = data;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
469
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
470 options->show_star_rating = !options->show_star_rating;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
471
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
472 vflist_populate_view(vf, TRUE);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
473
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
474 vflist_color_set(vf, VFLIST(vf)->click_fd, FALSE);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
475 vflist_star_rating_set(vf, options->show_star_rating);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
476 }
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
477
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
478 void vflist_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
479 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
480 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
481
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
482 vflist_color_set(vf, VFLIST(vf)->click_fd, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
483 vf_refresh(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
484 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
485 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
486
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
487 void vflist_popup_destroy_cb(GtkWidget *widget, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
488 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
489 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
490 vflist_color_set(vf, VFLIST(vf)->click_fd, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
491 VFLIST(vf)->click_fd = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
492 vf->popup = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
493 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
494
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
495
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
496 /*
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
497 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
498 * callbacks
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
499 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
500 */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
501
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
502 static gboolean vflist_row_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
503 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
504 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
505 gchar *new_path;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
506
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
507 if (!new || !new[0]) return FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
508
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
509 new_path = g_build_filename(vf->dir_fd->path, new, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
510
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
511 if (strchr(new, G_DIR_SEPARATOR) != NULL)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
512 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
513 gchar *text = g_strdup_printf(_("Invalid file name:\n%s"), new);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
514 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, vf->listview);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
515 g_free(text);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
516 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
517 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
518 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
519 gchar *old_path = g_build_filename(vf->dir_fd->path, old, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
520 FileData *fd = file_data_new_group(old_path); /* get the fd from cache */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
521 file_util_rename_simple(fd, new_path, vf->listview);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
522 file_data_unref(fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
523 g_free(old_path);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
524 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
525
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
526 g_free(new_path);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
527
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
528 return FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
529 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
530
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
531 static void vflist_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
532 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
533 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
534 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
535 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
536 GtkTreePath *tpath;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
537 gint cw, ch;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
538
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
539 if (vflist_find_row(vf, VFLIST(vf)->click_fd, &iter) < 0) return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
540 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
541 tpath = gtk_tree_model_get_path(store, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
542 tree_view_get_cell_clamped(GTK_TREE_VIEW(vf->listview), tpath, FILE_COLUMN_NAME - 1, TRUE, x, y, &cw, &ch);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
543 gtk_tree_path_free(tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
544 *y += ch;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
545 popup_menu_position_clamp(menu, x, y, 0);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
546 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
547
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
548 gboolean vflist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
549 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
550 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
551 GtkTreePath *tpath;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
552
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
553 if (event->keyval != GDK_KEY_Menu) return FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
554
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
555 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vf->listview), &tpath, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
556 if (tpath)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
557 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
558 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
559 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
560
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
561 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
562 gtk_tree_model_get_iter(store, &iter, tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
563 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &VFLIST(vf)->click_fd, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
564 gtk_tree_path_free(tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
565 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
566 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
567 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
568 VFLIST(vf)->click_fd = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
569 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
570
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
571 vf->popup = vf_pop_menu(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
572 gtk_menu_popup(GTK_MENU(vf->popup), NULL, NULL, vflist_menu_position_cb, vf, 0, GDK_CURRENT_TIME);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
573
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
574 return TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
575 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
576
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
577 gboolean vflist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
578 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
579 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
580 GtkTreePath *tpath;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
581 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
582 FileData *fd = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
583 GtkTreeViewColumn *column;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
584
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
585 vf->clicked_mark = 0;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
586
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
587 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
588 &tpath, &column, NULL, NULL))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
589 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
590 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
591 gint col_idx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_store_idx"));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
592
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
593 if (bevent->button == MOUSE_BUTTON_LEFT &&
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
594 col_idx >= FILE_COLUMN_MARKS && col_idx <= FILE_COLUMN_MARKS_LAST)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
595 return FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
596
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
597 if (col_idx >= FILE_COLUMN_MARKS && col_idx <= FILE_COLUMN_MARKS_LAST)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
598 vf->clicked_mark = 1 + (col_idx - FILE_COLUMN_MARKS);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
599
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
600 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
601
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
602 gtk_tree_model_get_iter(store, &iter, tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
603 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
604 gtk_tree_path_free(tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
605 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
606
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
607 VFLIST(vf)->click_fd = fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
608
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
609 if (bevent->button == MOUSE_BUTTON_RIGHT)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
610 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
611 vf->popup = vf_pop_menu(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
612 gtk_menu_popup(GTK_MENU(vf->popup), NULL, NULL, NULL, NULL,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
613 bevent->button, bevent->time);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
614 return TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
615 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
616
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
617 if (!fd) return FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
618
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
619 if (bevent->button == MOUSE_BUTTON_MIDDLE)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
620 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
621 if (!vflist_row_is_selected(vf, fd))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
622 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
623 vflist_color_set(vf, fd, TRUE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
624 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
625 return TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
626 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
627
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
628
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
629 if (bevent->button == MOUSE_BUTTON_LEFT && bevent->type == GDK_BUTTON_PRESS &&
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
630 !(bevent->state & GDK_SHIFT_MASK ) &&
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
631 !(bevent->state & GDK_CONTROL_MASK ) &&
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
632 vflist_row_is_selected(vf, fd))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
633 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
634 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
635
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
636 gtk_widget_grab_focus(widget);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
637
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
638
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
639 /* returning FALSE and further processing of the event is needed for
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
640 correct operation of the expander, to show the sidecar files.
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
641 It however resets the selection of multiple files. With this condition
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
642 it should work for both cases */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
643 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
644 return (gtk_tree_selection_count_selected_rows(selection) > 1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
645 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
646
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
647 if (bevent->button == MOUSE_BUTTON_LEFT && bevent->type == GDK_2BUTTON_PRESS)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
648 {
2793
2feed80bcd34 Collections changes
Colin Clark <colin.clark@cclark.uk>
parents: 2772
diff changeset
649 if (VFLIST(vf)->click_fd->format_class == FORMAT_CLASS_COLLECTION)
2feed80bcd34 Collections changes
Colin Clark <colin.clark@cclark.uk>
parents: 2772
diff changeset
650 {
2feed80bcd34 Collections changes
Colin Clark <colin.clark@cclark.uk>
parents: 2772
diff changeset
651 collection_window_new(VFLIST(vf)->click_fd->path);
2feed80bcd34 Collections changes
Colin Clark <colin.clark@cclark.uk>
parents: 2772
diff changeset
652 }
2feed80bcd34 Collections changes
Colin Clark <colin.clark@cclark.uk>
parents: 2772
diff changeset
653 else
2feed80bcd34 Collections changes
Colin Clark <colin.clark@cclark.uk>
parents: 2772
diff changeset
654 {
2feed80bcd34 Collections changes
Colin Clark <colin.clark@cclark.uk>
parents: 2772
diff changeset
655 if (vf->layout) layout_image_full_screen_start(vf->layout);
2feed80bcd34 Collections changes
Colin Clark <colin.clark@cclark.uk>
parents: 2772
diff changeset
656 }
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
657 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
658
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
659 return FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
660 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
661
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
662 gboolean vflist_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
663 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
664 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
665 GtkTreePath *tpath;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
666 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
667 FileData *fd = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
668
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
669 if (bevent->button == MOUSE_BUTTON_MIDDLE)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
670 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
671 vflist_color_set(vf, VFLIST(vf)->click_fd, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
672 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
673
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
674 if (bevent->button != MOUSE_BUTTON_LEFT && bevent->button != MOUSE_BUTTON_MIDDLE)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
675 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
676 return TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
677 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
678
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
679 if ((bevent->x != 0 || bevent->y != 0) &&
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
680 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
681 &tpath, NULL, NULL, NULL))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
682 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
683 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
684
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
685 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
686 gtk_tree_model_get_iter(store, &iter, tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
687 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
688 gtk_tree_path_free(tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
689 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
690
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
691 if (bevent->button == MOUSE_BUTTON_MIDDLE)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
692 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
693 if (fd && VFLIST(vf)->click_fd == fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
694 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
695 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
696
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
697 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
698 if (vflist_row_is_selected(vf, fd))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
699 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
700 gtk_tree_selection_unselect_iter(selection, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
701 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
702 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
703 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
704 gtk_tree_selection_select_iter(selection, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
705 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
706 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
707 return TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
708 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
709
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
710 if (fd && VFLIST(vf)->click_fd == fd &&
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
711 !(bevent->state & GDK_SHIFT_MASK ) &&
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
712 !(bevent->state & GDK_CONTROL_MASK ) &&
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
713 vflist_row_is_selected(vf, fd))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
714 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
715 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
716
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
717 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
718 gtk_tree_selection_unselect_all(selection);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
719 gtk_tree_selection_select_iter(selection, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
720 vflist_move_cursor(vf, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
721 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
722
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
723 return FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
724 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
725
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
726 static void vflist_select_image(ViewFile *vf, FileData *sel_fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
727 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
728 FileData *read_ahead_fd = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
729 gint row;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
730 FileData *cur_fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
731
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
732 if (!sel_fd) return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
733
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
734 cur_fd = layout_image_get_fd(vf->layout);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
735 if (sel_fd == cur_fd) return; /* no change */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
736
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
737 row = g_list_index(vf->list, sel_fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
738 // FIXME sidecar data
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
739
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
740 if (sel_fd && options->image.enable_read_ahead && row >= 0)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
741 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
742 if (row > g_list_index(vf->list, cur_fd) &&
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
743 (guint) (row + 1) < vf_count(vf, NULL))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
744 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
745 read_ahead_fd = vf_index_get_data(vf, row + 1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
746 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
747 else if (row > 0)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
748 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
749 read_ahead_fd = vf_index_get_data(vf, row - 1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
750 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
751 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
752
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
753 layout_image_set_with_ahead(vf->layout, sel_fd, read_ahead_fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
754 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
755
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
756 static gboolean vflist_select_idle_cb(gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
757 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
758 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
759
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
760 if (!vf->layout)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
761 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
762 VFLIST(vf)->select_idle_id = 0;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
763 return FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
764 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
765
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
766 vf_send_update(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
767
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
768 if (VFLIST(vf)->select_fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
769 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
770 vflist_select_image(vf, VFLIST(vf)->select_fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
771 VFLIST(vf)->select_fd = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
772 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
773
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
774 VFLIST(vf)->select_idle_id = 0;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
775 return FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
776 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
777
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
778 static void vflist_select_idle_cancel(ViewFile *vf)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
779 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
780 if (VFLIST(vf)->select_idle_id)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
781 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
782 g_source_remove(VFLIST(vf)->select_idle_id);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
783 VFLIST(vf)->select_idle_id = 0;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
784 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
785 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
786
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
787 static gboolean vflist_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
788 gboolean path_currently_selected, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
789 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
790 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
791 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
792
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
793 if (!path_currently_selected &&
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
794 gtk_tree_model_get_iter(store, &iter, tpath))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
795 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
796 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &VFLIST(vf)->select_fd, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
797 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
798 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
799 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
800 VFLIST(vf)->select_fd = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
801 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
802
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
803 if (vf->layout &&
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
804 !VFLIST(vf)->select_idle_id)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
805 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
806 VFLIST(vf)->select_idle_id = g_idle_add(vflist_select_idle_cb, vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
807 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
808
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
809 return TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
810 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
811
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
812 static void vflist_expand_cb(GtkTreeView *tree_view, GtkTreeIter *iter, GtkTreePath *path, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
813 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
814 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
815 vflist_set_expanded(vf, iter, TRUE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
816 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
817
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
818 static void vflist_collapse_cb(GtkTreeView *tree_view, GtkTreeIter *iter, GtkTreePath *path, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
819 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
820 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
821 vflist_set_expanded(vf, iter, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
822 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
823
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
824 /*
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
825 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
826 * misc
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
827 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
828 */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
829
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
830
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
831 static gchar* vflist_get_formatted(ViewFile *vf, const gchar *name, const gchar *sidecars, const gchar *size, const gchar *time, gboolean expanded, gboolean with_stars, const gchar *star_rating)
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
832 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
833 gboolean multiline = vflist_is_multiline(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
834 gchar *text;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
835
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
836 if (multiline)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
837 {
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
838 if (with_stars)
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
839 {
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
840 text = g_strdup_printf("%s %s\n%s\n%s\n%s", name, expanded ? "" : sidecars, size, time, star_rating);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
841 }
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
842 else
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
843 {
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
844 text = g_strdup_printf("%s %s\n%s\n%s", name, expanded ? "" : sidecars, size, time);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
845 }
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
846 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
847 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
848 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
849 text = g_strdup_printf("%s %s", name, expanded ? "" : sidecars);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
850 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
851 return text;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
852 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
853
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
854 static void vflist_set_expanded(ViewFile *vf, GtkTreeIter *iter, gboolean expanded)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
855 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
856 GtkTreeStore *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
857 gchar *name;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
858 gchar *sidecars;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
859 gchar *size;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
860 gchar *time;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
861 gchar *formatted;
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
862 gchar *formatted_with_stars;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
863 gchar *star_rating;
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
864 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
865
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
866 gtk_tree_model_get(GTK_TREE_MODEL(store), iter,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
867 FILE_COLUMN_NAME, &name,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
868 FILE_COLUMN_SIDECARS, &sidecars,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
869 FILE_COLUMN_SIZE, &size,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
870 FILE_COLUMN_DATE, &time,
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
871 FILE_COLUMN_STAR_RATING, &star_rating,
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
872 -1);
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
873
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
874 formatted = vflist_get_formatted(vf, name, sidecars, size, time, expanded, FALSE, NULL);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
875 formatted_with_stars = vflist_get_formatted(vf, name, sidecars, size, time, expanded, TRUE, star_rating);
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
876
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
877 gtk_tree_store_set(store, iter, FILE_COLUMN_FORMATTED, formatted,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
878 FILE_COLUMN_EXPANDED, expanded,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
879 -1);
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
880 gtk_tree_store_set(store, iter, FILE_COLUMN_FORMATTED_WITH_STARS, formatted_with_stars,
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
881 FILE_COLUMN_EXPANDED, expanded,
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
882 -1);
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
883 g_free(time);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
884 g_free(size);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
885 g_free(sidecars);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
886 g_free(name);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
887 g_free(formatted);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
888 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
889
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
890 static void vflist_setup_iter(ViewFile *vf, GtkTreeStore *store, GtkTreeIter *iter, FileData *fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
891 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
892 gchar *size;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
893 gchar *sidecars = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
894 gchar *name;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
895 const gchar *time = text_from_time(fd->date);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
896 gchar *link = islink(fd->path) ? GQ_LINK_STR : "";
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
897 const gchar *disabled_grouping;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
898 gchar *formatted;
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
899 gchar *formatted_with_stars;
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
900 gboolean expanded = FALSE;
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
901 gchar *star_rating;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
902
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
903 if (options->show_star_rating)
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
904 {
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
905 star_rating = metadata_read_rating_stars(fd);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
906 }
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
907 else
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
908 {
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
909 star_rating = NULL;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
910 }
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
911
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
912 if (fd->sidecar_files) /* expanded has no effect on files without sidecars */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
913 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
914 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, FILE_COLUMN_EXPANDED, &expanded, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
915 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
916
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
917 sidecars = file_data_sc_list_to_string(fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
918
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
919 disabled_grouping = fd->disable_grouping ? _(" [NO GROUPING]") : "";
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
920 name = g_strdup_printf("%s%s%s", link, fd->name, disabled_grouping);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
921 size = text_from_size(fd->size);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
922
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
923 formatted = vflist_get_formatted(vf, name, sidecars, size, time, expanded, FALSE, NULL);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
924 formatted_with_stars = vflist_get_formatted(vf, name, sidecars, size, time, expanded, TRUE, star_rating);
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
925
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
926 gtk_tree_store_set(store, iter, FILE_COLUMN_POINTER, fd,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
927 FILE_COLUMN_VERSION, fd->version,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
928 FILE_COLUMN_THUMB, fd->thumb_pixbuf,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
929 FILE_COLUMN_FORMATTED, formatted,
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
930 FILE_COLUMN_FORMATTED_WITH_STARS, formatted_with_stars,
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
931 FILE_COLUMN_SIDECARS, sidecars,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
932 FILE_COLUMN_NAME, name,
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
933 FILE_COLUMN_STAR_RATING, star_rating,
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
934 FILE_COLUMN_SIZE, size,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
935 FILE_COLUMN_DATE, time,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
936 #define STORE_SET_IS_SLOW 1
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
937 #if STORE_SET_IS_SLOW
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
938 /* this is 3x faster on a directory with 20000 files */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
939 FILE_COLUMN_MARKS + 0, file_data_get_mark(fd, 0),
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
940 FILE_COLUMN_MARKS + 1, file_data_get_mark(fd, 1),
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
941 FILE_COLUMN_MARKS + 2, file_data_get_mark(fd, 2),
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
942 FILE_COLUMN_MARKS + 3, file_data_get_mark(fd, 3),
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
943 FILE_COLUMN_MARKS + 4, file_data_get_mark(fd, 4),
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
944 FILE_COLUMN_MARKS + 5, file_data_get_mark(fd, 5),
2600
c6a11c0bade8 Bug fix #509: Increase number of marks to 10
Tomasz Golinski <tomaszg@math.uwb.edu.pl>
parents: 2553
diff changeset
945 FILE_COLUMN_MARKS + 6, file_data_get_mark(fd, 6),
c6a11c0bade8 Bug fix #509: Increase number of marks to 10
Tomasz Golinski <tomaszg@math.uwb.edu.pl>
parents: 2553
diff changeset
946 FILE_COLUMN_MARKS + 7, file_data_get_mark(fd, 7),
c6a11c0bade8 Bug fix #509: Increase number of marks to 10
Tomasz Golinski <tomaszg@math.uwb.edu.pl>
parents: 2553
diff changeset
947 FILE_COLUMN_MARKS + 8, file_data_get_mark(fd, 8),
c6a11c0bade8 Bug fix #509: Increase number of marks to 10
Tomasz Golinski <tomaszg@math.uwb.edu.pl>
parents: 2553
diff changeset
948 FILE_COLUMN_MARKS + 9, file_data_get_mark(fd, 9),
c6a11c0bade8 Bug fix #509: Increase number of marks to 10
Tomasz Golinski <tomaszg@math.uwb.edu.pl>
parents: 2553
diff changeset
949 #if FILEDATA_MARKS_SIZE != 10
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
950 #error this needs to be updated
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
951 #endif
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
952 #endif
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
953 FILE_COLUMN_COLOR, FALSE, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
954
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
955 #if !STORE_SET_IS_SLOW
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
956 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
957 gint i;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
958 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
959 gtk_tree_store_set(store, iter, FILE_COLUMN_MARKS + i, file_data_get_mark(fd, i), -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
960 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
961 #endif
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
962 g_free(size);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
963 g_free(sidecars);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
964 g_free(name);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
965 g_free(formatted);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
966 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
967
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
968 static void vflist_setup_iter_recursive(ViewFile *vf, GtkTreeStore *store, GtkTreeIter *parent_iter, GList *list, GList *selected, gboolean force)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
969 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
970 GList *work;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
971 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
972 gboolean valid;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
973 gint num_ordered = 0;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
974 gint num_prepended = 0;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
975
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
976 valid = gtk_tree_model_iter_children(GTK_TREE_MODEL(store), &iter, parent_iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
977
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
978 work = list;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
979 while (work)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
980 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
981 gint match;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
982 FileData *fd = work->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
983 gboolean done = FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
984
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
985 while (!done)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
986 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
987 FileData *old_fd = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
988 gint old_version = 0;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
989
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
990 if (valid)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
991 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
992 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
993 FILE_COLUMN_POINTER, &old_fd,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
994 FILE_COLUMN_VERSION, &old_version,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
995 -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
996
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
997 if (fd == old_fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
998 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
999 match = 0;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1000 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1001 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1002 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1003 if (parent_iter)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1004 match = filelist_sort_compare_filedata_full(fd, old_fd, SORT_NAME, TRUE); /* always sort sidecars by name */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1005 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1006 match = filelist_sort_compare_filedata_full(fd, old_fd, vf->sort_method, vf->sort_ascend);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1007
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1008 if (match == 0) g_warning("multiple fd for the same path");
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1009 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1010
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1011 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1012 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1013 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1014 match = -1;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1015 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1016
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1017 if (match < 0)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1018 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1019 GtkTreeIter new;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1020
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1021 if (valid)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1022 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1023 num_ordered++;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1024 gtk_tree_store_insert_before(store, &new, parent_iter, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1025 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1026 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1027 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1028 /*
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1029 here should be used gtk_tree_store_append, but this function seems to be O(n)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1030 and it seems to be much faster to add new entries to the beginning and reorder later
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1031 */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1032 num_prepended++;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1033 gtk_tree_store_prepend(store, &new, parent_iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1034 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1035
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1036 vflist_setup_iter(vf, store, &new, file_data_ref(fd));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1037 vflist_setup_iter_recursive(vf, store, &new, fd->sidecar_files, selected, force);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1038
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1039 if (g_list_find(selected, fd))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1040 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1041 /* renamed files - the same fd appears at different position - select it again*/
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1042 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1043 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1044 gtk_tree_selection_select_iter(selection, &new);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1045 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1046
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1047 done = TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1048 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1049 else if (match > 0)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1050 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1051 file_data_unref(old_fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1052 valid = gtk_tree_store_remove(store, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1053 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1054 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1055 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1056 num_ordered++;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1057 if (fd->version != old_version || force)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1058 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1059 vflist_setup_iter(vf, store, &iter, fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1060 vflist_setup_iter_recursive(vf, store, &iter, fd->sidecar_files, selected, force);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1061 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1062
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1063 if (valid) valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1064
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1065 done = TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1066 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1067 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1068 work = work->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1069 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1070
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1071 while (valid)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1072 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1073 FileData *old_fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1074 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &old_fd, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1075 file_data_unref(old_fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1076
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1077 valid = gtk_tree_store_remove(store, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1078 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1079
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1080 /* move the prepended entries to the correct position */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1081 if (num_prepended)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1082 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1083 gint i;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1084 gint num_total = num_prepended + num_ordered;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1085 gint *new_order = g_malloc(num_total * sizeof(gint));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1086
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1087 for (i = 0; i < num_total; i++)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1088 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1089 if (i < num_ordered)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1090 new_order[i] = num_prepended + i;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1091 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1092 new_order[i] = num_total - 1 - i;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1093 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1094 gtk_tree_store_reorder(store, parent_iter, new_order);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1095
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1096 g_free(new_order);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1097 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1098 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1099
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1100 void vflist_sort_set(ViewFile *vf, SortType type, gboolean ascend)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1101 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1102 gint i;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1103 GHashTable *fd_idx_hash = g_hash_table_new(NULL, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1104 gint *new_order;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1105 GtkTreeStore *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1106 GList *work;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1107
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1108 if (vf->sort_method == type && vf->sort_ascend == ascend) return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1109 if (!vf->list) return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1110
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1111 work = vf->list;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1112 i = 0;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1113 while (work)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1114 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1115 FileData *fd = work->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1116 g_hash_table_insert(fd_idx_hash, fd, GINT_TO_POINTER(i));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1117 i++;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1118 work = work->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1119 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1120
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1121 vf->sort_method = type;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1122 vf->sort_ascend = ascend;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1123
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1124 vf->list = filelist_sort(vf->list, vf->sort_method, vf->sort_ascend);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1125
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1126 new_order = g_malloc(i * sizeof(gint));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1127
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1128 work = vf->list;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1129 i = 0;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1130 while (work)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1131 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1132 FileData *fd = work->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1133 new_order[i] = GPOINTER_TO_INT(g_hash_table_lookup(fd_idx_hash, fd));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1134 i++;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1135 work = work->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1136 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1137
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1138 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1139 gtk_tree_store_reorder(store, NULL, new_order);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1140
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1141 g_free(new_order);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1142 g_hash_table_destroy(fd_idx_hash);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1143 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1144
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1145 /*
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1146 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1147 * thumb updates
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1148 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1149 */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1150
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1151
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1152 void vflist_thumb_progress_count(GList *list, gint *count, gint *done)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1153 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1154 GList *work = list;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1155 while (work)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1156 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1157 FileData *fd = work->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1158 work = work->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1159
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1160 if (fd->thumb_pixbuf) (*done)++;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1161
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1162 if (fd->sidecar_files)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1163 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1164 vflist_thumb_progress_count(fd->sidecar_files, count, done);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1165 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1166 (*count)++;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1167 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1168 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1169
2770
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1170 void vflist_read_metadata_progress_count(GList *list, gint *count, gint *done)
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1171 {
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1172 GList *work = list;
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1173 while (work)
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1174 {
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1175 FileData *fd = work->data;
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1176 work = work->next;
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1177
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1178 if (fd->metadata_in_idle_loaded) (*done)++;
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1179
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1180 if (fd->sidecar_files)
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1181 {
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1182 vflist_read_metadata_progress_count(fd->sidecar_files, count, done);
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1183 }
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1184 (*count)++;
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1185 }
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1186 }
2e819f4a7a41 Read metadata in the idle loop
Colin Clark <colin.clark@cclark.uk>
parents: 2600
diff changeset
1187
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1188 void vflist_set_thumb_fd(ViewFile *vf, FileData *fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1189 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1190 GtkTreeStore *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1191 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1192
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1193 if (!fd || vflist_find_row(vf, fd, &iter) < 0) return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1194
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1195 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1196 gtk_tree_store_set(store, &iter, FILE_COLUMN_THUMB, fd->thumb_pixbuf, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1197 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1198
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1199 FileData *vflist_thumb_next_fd(ViewFile *vf)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1200 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1201 GtkTreePath *tpath;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1202 FileData *fd = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1203
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1204 /* first check the visible files */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1205
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1206 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1207 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1208 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1209 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1210 gboolean valid = TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1211
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1212 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1213 gtk_tree_model_get_iter(store, &iter, tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1214 gtk_tree_path_free(tpath);
2523
46f57b0ed091 Remove all references to "IconData"
Omari Stephens <xsdg@google.com>
parents: 2521
diff changeset
1215 tpath = NULL;
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1216
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1217 while (!fd && valid && tree_view_row_get_visibility(GTK_TREE_VIEW(vf->listview), &iter, FALSE) == 0)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1218 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1219 FileData *nfd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1220
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1221 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &nfd, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1222
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1223 if (!nfd->thumb_pixbuf) fd = nfd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1224
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1225 valid = gtk_tree_model_iter_next(store, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1226 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1227 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1228
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1229 /* then find first undone */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1230
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1231 if (!fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1232 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1233 GList *work = vf->list;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1234 while (work && !fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1235 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1236 FileData *fd_p = work->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1237 if (!fd_p->thumb_pixbuf)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1238 fd = fd_p;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1239 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1240 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1241 GList *work2 = fd_p->sidecar_files;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1242
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1243 while (work2 && !fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1244 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1245 fd_p = work2->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1246 if (!fd_p->thumb_pixbuf) fd = fd_p;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1247 work2 = work2->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1248 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1249 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1250 work = work->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1251 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1252 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1253
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1254 return fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1255 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1256
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1257 /*
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1258 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1259 * row stuff
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1260 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1261 */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1262
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1263 gint vflist_index_by_fd(ViewFile *vf, FileData *fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1264 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1265 gint p = 0;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1266 GList *work, *work2;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1267
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1268 work = vf->list;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1269 while (work)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1270 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1271 FileData *list_fd = work->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1272 if (list_fd == fd) return p;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1273
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1274 work2 = list_fd->sidecar_files;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1275 while (work2)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1276 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1277 /* FIXME: return the same index also for sidecars
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1278 it is sufficient for next/prev navigation but it should be rewritten
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1279 without using indexes at all
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1280 */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1281 FileData *sidecar_fd = work2->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1282 if (sidecar_fd == fd) return p;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1283 work2 = work2->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1284 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1285
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1286 work = work->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1287 p++;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1288 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1289
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1290 return -1;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1291 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1292
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1293 /*
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1294 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1295 * selections
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1296 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1297 */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1298
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1299 static gboolean vflist_row_is_selected(ViewFile *vf, FileData *fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1300 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1301 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1302 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1303 GList *slist;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1304 GList *work;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1305 gboolean found = FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1306
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1307 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1308 slist = gtk_tree_selection_get_selected_rows(selection, &store);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1309 work = slist;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1310 while (!found && work)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1311 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1312 GtkTreePath *tpath = work->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1313 FileData *fd_n;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1314 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1315
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1316 gtk_tree_model_get_iter(store, &iter, tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1317 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd_n, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1318 if (fd_n == fd) found = TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1319 work = work->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1320 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1321 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1322 g_list_free(slist);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1323
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1324 return found;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1325 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1326
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1327 gboolean vflist_index_is_selected(ViewFile *vf, gint row)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1328 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1329 FileData *fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1330
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1331 fd = vf_index_get_data(vf, row);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1332 return vflist_row_is_selected(vf, fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1333 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1334
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1335 guint vflist_selection_count(ViewFile *vf, gint64 *bytes)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1336 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1337 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1338 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1339 GList *slist;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1340 guint count;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1341
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1342 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1343 slist = gtk_tree_selection_get_selected_rows(selection, &store);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1344
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1345 if (bytes)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1346 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1347 gint64 b = 0;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1348 GList *work;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1349
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1350 work = slist;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1351 while (work)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1352 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1353 GtkTreePath *tpath = work->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1354 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1355 FileData *fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1356
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1357 gtk_tree_model_get_iter(store, &iter, tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1358 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1359 b += fd->size;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1360
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1361 work = work->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1362 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1363
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1364 *bytes = b;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1365 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1366
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1367 count = g_list_length(slist);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1368 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1369 g_list_free(slist);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1370
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1371 return count;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1372 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1373
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1374 GList *vflist_selection_get_list(ViewFile *vf)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1375 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1376 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1377 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1378 GList *slist;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1379 GList *list = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1380 GList *work;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1381
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1382 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1383 slist = gtk_tree_selection_get_selected_rows(selection, &store);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1384 work = slist;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1385 while (work)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1386 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1387 GtkTreePath *tpath = work->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1388 FileData *fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1389 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1390
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1391 gtk_tree_model_get_iter(store, &iter, tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1392 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1393
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1394 list = g_list_prepend(list, file_data_ref(fd));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1395
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1396 if (!fd->parent && !gtk_tree_view_row_expanded(GTK_TREE_VIEW(vf->listview), tpath))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1397 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1398 /* unexpanded - add whole group */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1399 GList *work2 = fd->sidecar_files;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1400 while (work2)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1401 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1402 FileData *sfd = work2->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1403 list = g_list_prepend(list, file_data_ref(sfd));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1404 work2 = work2->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1405 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1406 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1407
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1408 work = work->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1409 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1410 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1411 g_list_free(slist);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1412
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1413 return g_list_reverse(list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1414 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1415
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1416 GList *vflist_selection_get_list_by_index(ViewFile *vf)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1417 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1418 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1419 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1420 GList *slist;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1421 GList *list = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1422 GList *work;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1423
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1424 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1425 slist = gtk_tree_selection_get_selected_rows(selection, &store);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1426 work = slist;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1427 while (work)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1428 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1429 GtkTreePath *tpath = work->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1430 FileData *fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1431 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1432
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1433 gtk_tree_model_get_iter(store, &iter, tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1434 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1435
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1436 list = g_list_prepend(list, GINT_TO_POINTER(g_list_index(vf->list, fd)));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1437
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1438 work = work->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1439 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1440 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1441 g_list_free(slist);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1442
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1443 return g_list_reverse(list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1444 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1445
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1446 void vflist_select_all(ViewFile *vf)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1447 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1448 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1449
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1450 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1451 gtk_tree_selection_select_all(selection);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1452
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1453 VFLIST(vf)->select_fd = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1454 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1455
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1456 void vflist_select_none(ViewFile *vf)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1457 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1458 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1459
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1460 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1461 gtk_tree_selection_unselect_all(selection);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1462 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1463
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1464 static gboolean tree_model_iter_prev(GtkTreeModel *store, GtkTreeIter *iter)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1465 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1466 GtkTreePath *tpath;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1467 gboolean result;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1468
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1469 tpath = gtk_tree_model_get_path(store, iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1470 result = gtk_tree_path_prev(tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1471 if (result)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1472 gtk_tree_model_get_iter(store, iter, tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1473
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1474 gtk_tree_path_free(tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1475
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1476 return result;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1477 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1478
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1479 static gboolean tree_model_get_iter_last(GtkTreeModel *store, GtkTreeIter *iter)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1480 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1481 if (!gtk_tree_model_get_iter_first(store, iter))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1482 return FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1483
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1484 while (TRUE)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1485 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1486 GtkTreeIter next = *iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1487
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1488 if (gtk_tree_model_iter_next(store, &next))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1489 *iter = next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1490 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1491 break;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1492 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1493
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1494 return TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1495 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1496
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1497 void vflist_select_invert(ViewFile *vf)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1498 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1499 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1500 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1501 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1502 gboolean valid;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1503
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1504 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1505 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1506
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1507 /* Backward iteration prevents scrolling to the end of the list,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1508 * it scrolls to the first selected row instead. */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1509 valid = tree_model_get_iter_last(store, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1510
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1511 while (valid)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1512 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1513 gboolean selected = gtk_tree_selection_iter_is_selected(selection, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1514
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1515 if (selected)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1516 gtk_tree_selection_unselect_iter(selection, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1517 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1518 gtk_tree_selection_select_iter(selection, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1519
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1520 valid = tree_model_iter_prev(store, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1521 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1522 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1523
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1524 void vflist_select_by_fd(ViewFile *vf, FileData *fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1525 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1526 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1527
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1528 if (vflist_find_row(vf, fd, &iter) < 0) return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1529
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1530 tree_view_row_make_visible(GTK_TREE_VIEW(vf->listview), &iter, TRUE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1531
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1532 if (!vflist_row_is_selected(vf, fd))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1533 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1534 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1535 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1536 GtkTreePath *tpath;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1537
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1538 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1539 gtk_tree_selection_unselect_all(selection);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1540 gtk_tree_selection_select_iter(selection, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1541 vflist_move_cursor(vf, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1542
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1543 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1544 tpath = gtk_tree_model_get_path(store, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1545 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vf->listview), tpath, NULL, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1546 gtk_tree_path_free(tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1547 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1548 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1549
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1550 static void vflist_select_closest(ViewFile *vf, FileData *sel_fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1551 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1552 GList *work;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1553 FileData *fd = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1554
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1555 if (sel_fd->parent) sel_fd = sel_fd->parent;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1556 work = vf->list;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1557
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1558 while (work)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1559 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1560 gint match;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1561 fd = work->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1562 work = work->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1563
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1564 match = filelist_sort_compare_filedata_full(fd, sel_fd, vf->sort_method, vf->sort_ascend);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1565
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1566 if (match >= 0) break;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1567 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1568
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1569 if (fd) vflist_select_by_fd(vf, fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1570
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1571 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1572
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1573 void vflist_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1574 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1575 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1576 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1577 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1578 gboolean valid;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1579 gint n = mark - 1;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1580
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1581 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1582
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1583 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1584 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1585
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1586 valid = gtk_tree_model_get_iter_first(store, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1587 while (valid)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1588 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1589 FileData *fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1590 gboolean mark_val, selected;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1591 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &fd, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1592
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1593 mark_val = file_data_get_mark(fd, n);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1594 selected = gtk_tree_selection_iter_is_selected(selection, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1595
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1596 switch (mode)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1597 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1598 case MTS_MODE_SET: selected = mark_val;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1599 break;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1600 case MTS_MODE_OR: selected = mark_val || selected;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1601 break;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1602 case MTS_MODE_AND: selected = mark_val && selected;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1603 break;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1604 case MTS_MODE_MINUS: selected = !mark_val && selected;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1605 break;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1606 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1607
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1608 if (selected)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1609 gtk_tree_selection_select_iter(selection, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1610 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1611 gtk_tree_selection_unselect_iter(selection, &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1612
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1613 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1614 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1615 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1616
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1617 void vflist_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1618 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1619 GtkTreeModel *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1620 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1621 GList *slist;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1622 GList *work;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1623 gint n = mark - 1;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1624
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1625 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1626
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1627 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1628 slist = gtk_tree_selection_get_selected_rows(selection, &store);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1629 work = slist;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1630 while (work)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1631 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1632 GtkTreePath *tpath = work->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1633 FileData *fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1634 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1635
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1636 gtk_tree_model_get_iter(store, &iter, tpath);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1637 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1638
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1639 /* the change has a very limited range and the standard notification would trigger
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1640 complete re-read of the directory - try to do only minimal update instead */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1641 file_data_unregister_notify_func(vf_notify_cb, vf); /* we don't need the notification */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1642
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1643 switch (mode)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1644 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1645 case STM_MODE_SET: file_data_set_mark(fd, n, 1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1646 break;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1647 case STM_MODE_RESET: file_data_set_mark(fd, n, 0);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1648 break;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1649 case STM_MODE_TOGGLE: file_data_set_mark(fd, n, !file_data_get_mark(fd, n));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1650 break;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1651 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1652
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1653 if (!file_data_filter_marks(fd, vf_marks_get_filter(vf))) /* file no longer matches the filter -> remove it */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1654 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1655 vf_refresh_idle(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1656 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1657 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1658 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1659 /* mark functions can have various side effects - update all columns to be sure */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1660 vflist_setup_iter(vf, GTK_TREE_STORE(store), &iter, fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1661 /* mark functions can change sidecars too */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1662 vflist_setup_iter_recursive(vf, GTK_TREE_STORE(store), &iter, fd->sidecar_files, NULL, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1663 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1664
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1665
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1666 file_data_register_notify_func(vf_notify_cb, vf, NOTIFY_PRIORITY_MEDIUM);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1667
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1668 work = work->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1669 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1670 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1671 g_list_free(slist);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1672 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1673
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1674 /*
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1675 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1676 * core (population)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1677 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1678 */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1679
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1680 static void vflist_listview_set_columns(GtkWidget *listview, gboolean thumb, gboolean multiline)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1681 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1682 GtkTreeViewColumn *column;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1683 GtkCellRenderer *cell;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1684 GList *list;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1685
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1686 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), FILE_VIEW_COLUMN_THUMB);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1687 if (!column) return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1688
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1689 gtk_tree_view_column_set_fixed_width(column, options->thumbnails.max_width + 4);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1690
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1691 list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1692 if (!list) return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1693 cell = list->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1694 g_list_free(list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1695
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1696 g_object_set(G_OBJECT(cell), "height", options->thumbnails.max_height, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1697 gtk_tree_view_column_set_visible(column, thumb);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1698
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1699 if (options->show_star_rating)
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1700 {
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1701 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), FILE_VIEW_COLUMN_FORMATTED_WITH_STARS);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1702 if (!column) return;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1703 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(listview), column);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1704 gtk_tree_view_column_set_visible(column, TRUE);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1705
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1706 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), FILE_VIEW_COLUMN_FORMATTED);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1707 if (!column) return;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1708 gtk_tree_view_column_set_visible(column, FALSE);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1709 }
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1710 else
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1711 {
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1712 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), FILE_VIEW_COLUMN_FORMATTED);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1713 if (!column) return;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1714 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(listview), column);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1715 gtk_tree_view_column_set_visible(column, TRUE);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1716
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1717 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), FILE_VIEW_COLUMN_FORMATTED_WITH_STARS);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1718 if (!column) return;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1719 gtk_tree_view_column_set_visible(column, FALSE);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1720 }
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1721
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1722 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), FILE_VIEW_COLUMN_STAR_RATING);
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1723 if (!column) return;
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
1724 gtk_tree_view_column_set_visible(column, !multiline && options->show_star_rating);
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1725
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1726 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), FILE_VIEW_COLUMN_SIZE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1727 if (!column) return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1728 gtk_tree_view_column_set_visible(column, !multiline);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1729
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1730 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), FILE_VIEW_COLUMN_DATE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1731 if (!column) return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1732 gtk_tree_view_column_set_visible(column, !multiline);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1733 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1734
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1735 static gboolean vflist_is_multiline(ViewFile *vf)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1736 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1737 return (VFLIST(vf)->thumbs_enabled && options->thumbnails.max_height >= 48);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1738 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1739
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1740
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1741 static void vflist_populate_view(ViewFile *vf, gboolean force)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1742 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1743 GtkTreeStore *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1744 GList *selected;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1745
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1746 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1747
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1748 vf_thumb_stop(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1749
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1750 if (!vf->list)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1751 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1752 vflist_store_clear(vf, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1753 vf_send_update(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1754 return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1755 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1756
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1757 vflist_listview_set_columns(vf->listview, VFLIST(vf)->thumbs_enabled, vflist_is_multiline(vf));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1758
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1759 selected = vflist_selection_get_list(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1760
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1761 vflist_setup_iter_recursive(vf, store, NULL, vf->list, selected, force);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1762
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1763 if (selected && vflist_selection_count(vf, NULL) == 0)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1764 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1765 /* all selected files disappeared */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1766 vflist_select_closest(vf, selected->data);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1767 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1768
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1769 filelist_free(selected);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1770
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1771 vf_send_update(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1772 vf_thumb_update(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1773 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1774
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1775 gboolean vflist_refresh(ViewFile *vf)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1776 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1777 GList *old_list;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1778 gboolean ret = TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1779
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1780 old_list = vf->list;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1781 vf->list = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1782
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1783 DEBUG_1("%s vflist_refresh: read dir", get_exec_time());
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1784 if (vf->dir_fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1785 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1786 file_data_unregister_notify_func(vf_notify_cb, vf); /* we don't need the notification of changes detected by filelist_read */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1787
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1788 ret = filelist_read(vf->dir_fd, &vf->list, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1789
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1790 if (vf->marks_enabled)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1791 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1792 // When marks are enabled, lock FileDatas so that we don't end up re-parsing XML
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1793 // each time a mark is changed.
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1794 file_data_lock_list(vf->list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1795 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1796 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1797 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1798 // FIXME: only do this when needed (aka when we just switched from
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1799 // FIXME: marks-enabled to marks-disabled)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1800 file_data_unlock_list(vf->list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1801 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1802
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1803 vf->list = file_data_filter_marks_list(vf->list, vf_marks_get_filter(vf));
2817
e6f95baec8b5 Fix #624: Filter files by shell or regular expression pattern
Colin Clark <colin.clark@cclark.uk>
parents: 2793
diff changeset
1804 vf->list = g_list_first(vf->list);
e6f95baec8b5 Fix #624: Filter files by shell or regular expression pattern
Colin Clark <colin.clark@cclark.uk>
parents: 2793
diff changeset
1805 vf->list = file_data_filter_file_filter_list(vf->list, vf_file_filter_get_filter(vf));
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1806 file_data_register_notify_func(vf_notify_cb, vf, NOTIFY_PRIORITY_MEDIUM);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1807
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1808 DEBUG_1("%s vflist_refresh: sort", get_exec_time());
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1809 vf->list = filelist_sort(vf->list, vf->sort_method, vf->sort_ascend);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1810 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1811
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1812 DEBUG_1("%s vflist_refresh: populate view", get_exec_time());
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1813
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1814 vflist_populate_view(vf, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1815
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1816 DEBUG_1("%s vflist_refresh: free filelist", get_exec_time());
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1817
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1818 filelist_free(old_list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1819 DEBUG_1("%s vflist_refresh: done", get_exec_time());
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1820
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1821 return ret;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1822 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1823
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1824
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1825
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1826 /* this overrides the low default of a GtkCellRenderer from 100 to CELL_HEIGHT_OVERRIDE, something sane for our purposes */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1827
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1828 #define CELL_HEIGHT_OVERRIDE 512
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1829
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1830 static void cell_renderer_height_override(GtkCellRenderer *renderer)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1831 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1832 GParamSpec *spec;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1833
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1834 spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(renderer)), "height");
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1835 if (spec && G_IS_PARAM_SPEC_INT(spec))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1836 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1837 GParamSpecInt *spec_int;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1838
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1839 spec_int = G_PARAM_SPEC_INT(spec);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1840 if (spec_int->maximum < CELL_HEIGHT_OVERRIDE) spec_int->maximum = CELL_HEIGHT_OVERRIDE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1841 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1842 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1843
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1844 static GdkColor *vflist_listview_color_shifted(GtkWidget *widget)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1845 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1846 static GdkColor color;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1847 static GtkWidget *done = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1848
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1849 if (done != widget)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1850 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1851 GtkStyle *style;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1852
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1853 style = gtk_widget_get_style(widget);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1854 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1855 shift_color(&color, -1, 0);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1856 done = widget;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1857 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1858
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1859 return &color;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1860 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1861
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1862 static void vflist_listview_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1863 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1864 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1865 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1866 gboolean set;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1867
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1868 gtk_tree_model_get(tree_model, iter, FILE_COLUMN_COLOR, &set, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1869 g_object_set(G_OBJECT(cell),
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1870 "cell-background-gdk", vflist_listview_color_shifted(vf->listview),
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1871 "cell-background-set", set, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1872 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1873
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1874 static void vflist_listview_add_column(ViewFile *vf, gint n, const gchar *title, gboolean image, gboolean right_justify, gboolean expand)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1875 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1876 GtkTreeViewColumn *column;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1877 GtkCellRenderer *renderer;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1878
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1879 column = gtk_tree_view_column_new();
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1880 gtk_tree_view_column_set_title(column, title);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1881 gtk_tree_view_column_set_min_width(column, 4);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1882
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1883 if (!image)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1884 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1885 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1886 renderer = gtk_cell_renderer_text_new();
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1887 if (right_justify)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1888 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1889 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1890 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1891 gtk_tree_view_column_pack_start(column, renderer, TRUE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1892 gtk_tree_view_column_add_attribute(column, renderer, "text", n);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1893 if (expand)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1894 gtk_tree_view_column_set_expand(column, TRUE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1895 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1896 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1897 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1898 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1899 renderer = gtk_cell_renderer_pixbuf_new();
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1900 cell_renderer_height_override(renderer);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1901 gtk_tree_view_column_pack_start(column, renderer, TRUE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1902 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", n);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1903 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1904
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1905 gtk_tree_view_column_set_cell_data_func(column, renderer, vflist_listview_color_cb, vf, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1906 g_object_set_data(G_OBJECT(column), "column_store_idx", GUINT_TO_POINTER(n));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1907 g_object_set_data(G_OBJECT(renderer), "column_store_idx", GUINT_TO_POINTER(n));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1908
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1909 gtk_tree_view_append_column(GTK_TREE_VIEW(vf->listview), column);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1910 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1911
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1912 static void vflist_listview_mark_toggled_cb(GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1913 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1914 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1915 GtkTreeStore *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1916 GtkTreePath *path = gtk_tree_path_new_from_string(path_str);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1917 GtkTreeIter iter;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1918 FileData *fd;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1919 gboolean marked;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1920 guint col_idx;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1921
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1922 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1923 if (!path || !gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path))
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1924 return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1925
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1926 col_idx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell), "column_store_idx"));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1927
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1928 g_assert(col_idx >= FILE_COLUMN_MARKS && col_idx <= FILE_COLUMN_MARKS_LAST);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1929
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1930 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &fd, col_idx, &marked, -1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1931 marked = !marked;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1932
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1933 /* the change has a very limited range and the standard notification would trigger
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1934 complete re-read of the directory - try to do only minimal update instead */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1935 file_data_unregister_notify_func(vf_notify_cb, vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1936 file_data_set_mark(fd, col_idx - FILE_COLUMN_MARKS, marked);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1937 if (!file_data_filter_marks(fd, vf_marks_get_filter(vf))) /* file no longer matches the filter -> remove it */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1938 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1939 vf_refresh_idle(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1940 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1941 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1942 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1943 /* mark functions can have various side effects - update all columns to be sure */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1944 vflist_setup_iter(vf, GTK_TREE_STORE(store), &iter, fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1945 /* mark functions can change sidecars too */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1946 vflist_setup_iter_recursive(vf, GTK_TREE_STORE(store), &iter, fd->sidecar_files, NULL, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1947 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1948 file_data_register_notify_func(vf_notify_cb, vf, NOTIFY_PRIORITY_MEDIUM);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1949
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1950 gtk_tree_path_free(path);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1951 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1952
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1953 static void vflist_listview_add_column_toggle(ViewFile *vf, gint n, const gchar *title)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1954 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1955 GtkTreeViewColumn *column;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1956 GtkCellRenderer *renderer;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1957
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1958 renderer = gtk_cell_renderer_toggle_new();
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1959 column = gtk_tree_view_column_new_with_attributes(title, renderer, "active", n, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1960
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1961 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1962 g_object_set_data(G_OBJECT(column), "column_store_idx", GUINT_TO_POINTER(n));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1963 g_object_set_data(G_OBJECT(renderer), "column_store_idx", GUINT_TO_POINTER(n));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1964
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1965 gtk_tree_view_append_column(GTK_TREE_VIEW(vf->listview), column);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1966 gtk_tree_view_column_set_fixed_width(column, 22);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1967 gtk_tree_view_column_set_visible(column, vf->marks_enabled);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1968
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1969
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1970 g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(vflist_listview_mark_toggled_cb), vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1971 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1972
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1973 /*
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1974 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1975 * base
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1976 *-----------------------------------------------------------------------------
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1977 */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1978
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1979 gboolean vflist_set_fd(ViewFile *vf, FileData *dir_fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1980 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1981 gboolean ret;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1982 if (!dir_fd) return FALSE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1983 if (vf->dir_fd == dir_fd) return TRUE;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1984
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1985 file_data_unref(vf->dir_fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1986 vf->dir_fd = file_data_ref(dir_fd);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1987
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1988 /* force complete reload */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1989 vflist_store_clear(vf, TRUE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1990
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1991 filelist_free(vf->list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1992 vf->list = NULL;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1993
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1994 ret = vf_refresh(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1995 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1996 return ret;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1997 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1998
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
1999 void vflist_destroy_cb(GtkWidget *widget, gpointer data)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2000 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2001 ViewFile *vf = data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2002
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2003 file_data_unregister_notify_func(vf_notify_cb, vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2004
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2005 vflist_select_idle_cancel(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2006 vf_refresh_idle_cancel(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2007 vf_thumb_stop(vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2008
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2009 filelist_free(vf->list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2010 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2011
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2012 ViewFile *vflist_new(ViewFile *vf, FileData *dir_fd)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2013 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2014 GtkTreeStore *store;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2015 GtkTreeSelection *selection;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2016 GType flist_types[FILE_COLUMN_COUNT];
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2017 gint i;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2018 gint column;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2019
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2020 vf->info = g_new0(ViewFileInfoList, 1);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2021
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2022 flist_types[FILE_COLUMN_POINTER] = G_TYPE_POINTER;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2023 flist_types[FILE_COLUMN_VERSION] = G_TYPE_INT;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2024 flist_types[FILE_COLUMN_THUMB] = GDK_TYPE_PIXBUF;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2025 flist_types[FILE_COLUMN_FORMATTED] = G_TYPE_STRING;
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
2026 flist_types[FILE_COLUMN_FORMATTED_WITH_STARS] = G_TYPE_STRING;
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2027 flist_types[FILE_COLUMN_NAME] = G_TYPE_STRING;
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
2028 flist_types[FILE_COLUMN_STAR_RATING] = G_TYPE_STRING;
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2029 flist_types[FILE_COLUMN_SIDECARS] = G_TYPE_STRING;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2030 flist_types[FILE_COLUMN_SIZE] = G_TYPE_STRING;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2031 flist_types[FILE_COLUMN_DATE] = G_TYPE_STRING;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2032 flist_types[FILE_COLUMN_EXPANDED] = G_TYPE_BOOLEAN;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2033 flist_types[FILE_COLUMN_COLOR] = G_TYPE_BOOLEAN;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2034 for (i = FILE_COLUMN_MARKS; i < FILE_COLUMN_MARKS + FILEDATA_MARKS_SIZE; i++)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2035 flist_types[i] = G_TYPE_BOOLEAN;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2036
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2037 store = gtk_tree_store_newv(FILE_COLUMN_COUNT, flist_types);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2038
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2039 vf->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2040 g_object_unref(store);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2041
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2042 g_signal_connect(G_OBJECT(vf->listview), "row-expanded",
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2043 G_CALLBACK(vflist_expand_cb), vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2044
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2045 g_signal_connect(G_OBJECT(vf->listview), "row-collapsed",
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2046 G_CALLBACK(vflist_collapse_cb), vf);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2047
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2048 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2049 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_MULTIPLE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2050 gtk_tree_selection_set_select_function(selection, vflist_select_cb, vf, NULL);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2051
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2052 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vf->listview), FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2053 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vf->listview), FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2054
2772
6645d929ffba Fix #614: Wrap and/or truncate long file names in file list view
Colin Clark <colin.clark@cclark.uk>
parents: 2771
diff changeset
2055 gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(vf->listview), FILE_COLUMN_FORMATTED);
6645d929ffba Fix #614: Wrap and/or truncate long file names in file list view
Colin Clark <colin.clark@cclark.uk>
parents: 2771
diff changeset
2056
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2057 column = 0;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2058
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2059 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2060 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2061 vflist_listview_add_column_toggle(vf, i + FILE_COLUMN_MARKS, "");
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2062 g_assert(column == FILE_VIEW_COLUMN_MARKS + i);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2063 column++;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2064 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2065
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2066 vflist_listview_add_column(vf, FILE_COLUMN_THUMB, "", TRUE, FALSE, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2067 g_assert(column == FILE_VIEW_COLUMN_THUMB);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2068 column++;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2069
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2070 vflist_listview_add_column(vf, FILE_COLUMN_FORMATTED, _("Name"), FALSE, FALSE, TRUE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2071 g_assert(column == FILE_VIEW_COLUMN_FORMATTED);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2072 column++;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2073
2771
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
2074 vflist_listview_add_column(vf, FILE_COLUMN_FORMATTED_WITH_STARS, _("NameStars"), FALSE, FALSE, TRUE);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
2075 g_assert(column == FILE_VIEW_COLUMN_FORMATTED_WITH_STARS);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
2076 column++;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
2077
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
2078 vflist_listview_add_column(vf, FILE_COLUMN_STAR_RATING, _("Stars"), FALSE, FALSE, FALSE);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
2079 g_assert(column == FILE_VIEW_COLUMN_STAR_RATING);
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
2080 column++;
3aa4c31b93ff Show star rating in files pane
Colin Clark <colin.clark@cclark.uk>
parents: 2770
diff changeset
2081
2521
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2082 vflist_listview_add_column(vf, FILE_COLUMN_SIZE, _("Size"), FALSE, TRUE, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2083 g_assert(column == FILE_VIEW_COLUMN_SIZE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2084 column++;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2085
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2086 vflist_listview_add_column(vf, FILE_COLUMN_DATE, _("Date"), FALSE, TRUE, FALSE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2087 g_assert(column == FILE_VIEW_COLUMN_DATE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2088 column++;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2089
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2090 file_data_register_notify_func(vf_notify_cb, vf, NOTIFY_PRIORITY_MEDIUM);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2091 return vf;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2092 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2093
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2094 void vflist_thumb_set(ViewFile *vf, gboolean enable)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2095 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2096 if (VFLIST(vf)->thumbs_enabled == enable) return;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2097
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2098 VFLIST(vf)->thumbs_enabled = enable;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2099
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2100 /* vflist_populate_view is better than vf_refresh:
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2101 - no need to re-read the directory
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2102 - force update because the formatted string has changed
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2103 */
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2104 if (vf->layout)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2105 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2106 vflist_populate_view(vf, TRUE);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2107 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2108 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2109 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2110
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2111 void vflist_marks_set(ViewFile *vf, gboolean enable)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2112 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2113 GList *columns, *work;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2114
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2115 columns = gtk_tree_view_get_columns(GTK_TREE_VIEW(vf->listview));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2116
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2117 work = columns;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2118 while (work)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2119 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2120 GtkTreeViewColumn *column = work->data;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2121 gint col_idx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_store_idx"));
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2122 work = work->next;
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2123
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2124 if (col_idx <= FILE_COLUMN_MARKS_LAST && col_idx >= FILE_COLUMN_MARKS)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2125 gtk_tree_view_column_set_visible(column, enable);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2126 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2127
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2128 if (enable)
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2129 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2130 // Previously disabled, which means that vf->list is complete
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2131 file_data_lock_list(vf->list);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2132 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2133 else
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2134 {
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2135 // Previously enabled, which means that vf->list is incomplete
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2136 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2137
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2138 g_list_free(columns);
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2139 }
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2140
3a586dd0188a Refactor: move view_file implementations to their own subdirectory.
Omari Stephens <xsdg@google.com>
parents:
diff changeset
2141 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */