1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 
3 /* fm-list-model.h - a GtkTreeModel for file lists.
4 
5    Copyright (C) 2001, 2002 Anders Carlsson
6 
7    The Mate Library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Library General Public License as
9    published by the Free Software Foundation; either version 2 of the
10    License, or (at your option) any later version.
11 
12    The Mate Library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Library General Public License for more details.
16 
17    You should have received a copy of the GNU Library General Public
18    License along with the Mate Library; see the file COPYING.LIB.  If not,
19    write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20    Boston, MA 02110-1301, USA.
21 
22    Authors: Anders Carlsson <andersca@gnu.org>
23 */
24 
25 #include <gtk/gtk.h>
26 #include <gdk/gdk.h>
27 
28 #include <libcaja-private/caja-file.h>
29 #include <libcaja-private/caja-directory.h>
30 
31 #include <libcaja-extension/caja-column.h>
32 
33 #ifndef FM_LIST_MODEL_H
34 #define FM_LIST_MODEL_H
35 
36 #define FM_TYPE_LIST_MODEL fm_list_model_get_type()
37 #define FM_LIST_MODEL(obj) \
38   (G_TYPE_CHECK_INSTANCE_CAST ((obj), FM_TYPE_LIST_MODEL, FMListModel))
39 #define FM_LIST_MODEL_CLASS(klass) \
40   (G_TYPE_CHECK_CLASS_CAST ((klass), FM_TYPE_LIST_MODEL, FMListModelClass))
41 #define FM_IS_LIST_MODEL(obj) \
42   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FM_TYPE_LIST_MODEL))
43 #define FM_IS_LIST_MODEL_CLASS(klass) \
44   (G_TYPE_CHECK_CLASS_TYPE ((klass), FM_TYPE_LIST_MODEL))
45 #define FM_LIST_MODEL_GET_CLASS(obj) \
46   (G_TYPE_INSTANCE_GET_CLASS ((obj), FM_TYPE_LIST_MODEL, FMListModelClass))
47 
48 enum
49 {
50     FM_LIST_MODEL_FILE_COLUMN,
51     FM_LIST_MODEL_SUBDIRECTORY_COLUMN,
52     FM_LIST_MODEL_SMALLEST_ICON_COLUMN,
53     FM_LIST_MODEL_SMALLER_ICON_COLUMN,
54     FM_LIST_MODEL_SMALL_ICON_COLUMN,
55     FM_LIST_MODEL_STANDARD_ICON_COLUMN,
56     FM_LIST_MODEL_LARGE_ICON_COLUMN,
57     FM_LIST_MODEL_LARGER_ICON_COLUMN,
58     FM_LIST_MODEL_LARGEST_ICON_COLUMN,
59     FM_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN,
60     FM_LIST_MODEL_NUM_COLUMNS
61 };
62 
63 typedef struct FMListModelDetails FMListModelDetails;
64 
65 typedef struct FMListModel
66 {
67     GObject parent_instance;
68     FMListModelDetails *details;
69 } FMListModel;
70 
71 typedef struct
72 {
73     GObjectClass parent_class;
74 
75     void (* subdirectory_unloaded)(FMListModel *model,
76                                    CajaDirectory *subdirectory);
77 } FMListModelClass;
78 
79 GType    fm_list_model_get_type                          (void);
80 gboolean fm_list_model_add_file                          (FMListModel          *model,
81         CajaFile         *file,
82         CajaDirectory    *directory);
83 void     fm_list_model_file_changed                      (FMListModel          *model,
84         CajaFile         *file,
85         CajaDirectory    *directory);
86 gboolean fm_list_model_is_empty                          (FMListModel          *model);
87 guint    fm_list_model_get_length                        (FMListModel          *model);
88 void     fm_list_model_remove_file                       (FMListModel          *model,
89         CajaFile         *file,
90         CajaDirectory    *directory);
91 void     fm_list_model_clear                             (FMListModel          *model);
92 gboolean fm_list_model_get_tree_iter_from_file           (FMListModel          *model,
93         CajaFile         *file,
94         CajaDirectory    *directory,
95         GtkTreeIter          *iter);
96 GList *  fm_list_model_get_all_iters_for_file            (FMListModel          *model,
97         CajaFile         *file);
98 gboolean fm_list_model_get_first_iter_for_file           (FMListModel          *model,
99         CajaFile         *file,
100         GtkTreeIter          *iter);
101 void     fm_list_model_set_should_sort_directories_first (FMListModel          *model,
102         gboolean              sort_directories_first);
103 
104 int      fm_list_model_get_sort_column_id_from_attribute (FMListModel *model,
105         GQuark       attribute);
106 GQuark   fm_list_model_get_attribute_from_sort_column_id (FMListModel *model,
107         int sort_column_id);
108 void     fm_list_model_sort_files                        (FMListModel *model,
109         GList **files);
110 
111 CajaZoomLevel fm_list_model_get_zoom_level_from_column_id (int               column);
112 int               fm_list_model_get_column_id_from_zoom_level (CajaZoomLevel zoom_level);
113 
114 CajaFile *    fm_list_model_file_for_path (FMListModel *model, GtkTreePath *path);
115 gboolean          fm_list_model_load_subdirectory (FMListModel *model, GtkTreePath *path, CajaDirectory **directory);
116 void              fm_list_model_unload_subdirectory (FMListModel *model, GtkTreeIter *iter);
117 
118 void              fm_list_model_set_drag_view (FMListModel *model,
119         GtkTreeView *view,
120         int begin_x,
121         int begin_y);
122 
123 GtkTargetList *   fm_list_model_get_drag_target_list (void);
124 
125 int               fm_list_model_compare_func (FMListModel *model,
126         CajaFile *file1,
127         CajaFile *file2);
128 
129 
130 int               fm_list_model_add_column (FMListModel *model,
131         CajaColumn *column);
132 
133 void              fm_list_model_subdirectory_done_loading (FMListModel       *model,
134         CajaDirectory *directory);
135 
136 void              fm_list_model_set_highlight_for_files (FMListModel *model,
137         GList *files);
138 
139 #endif /* FM_LIST_MODEL_H */
140