~elementary-apps/pantheon-files/trunk

« back to all changes in this revision

Viewing changes to src/fm-directory-view.h

  • Committer: am.monkeyd at gmail
  • Date: 2010-11-08 13:17:02 UTC
  • Revision ID: am.monkeyd@gmail.com-20101108131702-rqeywh4r5pyx2ycz
let's roll

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
2
/* fm-directory-view.h
 
3
 *
 
4
 * Copyright (C) 1999, 2000  Free Software Foundaton
 
5
 * Copyright (C) 2000, 2001  Eazel, Inc.
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU 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
 * This program 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
 * General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public
 
18
 * License along with this program; if not, write to the
 
19
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
20
 * Boston, MA 02111-1307, USA.
 
21
 *
 
22
 * Authors: Ettore Perazzoli
 
23
 *          Darin Adler <darin@bentspoon.com>
 
24
 *          John Sullivan <sullivan@eazel.com>
 
25
 *          Pavel Cisler <pavel@eazel.com>
 
26
 */
 
27
 
 
28
#ifndef FM_DIRECTORY_VIEW_H
 
29
#define FM_DIRECTORY_VIEW_H
 
30
 
 
31
#include <gtk/gtk.h>
 
32
#include "gof-directory-async.h"
 
33
#include "gof-file.h"
 
34
#include "marlin-window-columns.h"
 
35
#include "gof-window-slot.h"
 
36
#include <gio/gio.h>
 
37
 
 
38
typedef struct FMDirectoryView FMDirectoryView;
 
39
typedef struct FMDirectoryViewClass FMDirectoryViewClass;
 
40
 
 
41
#define FM_TYPE_DIRECTORY_VIEW fm_directory_view_get_type()
 
42
#define FM_DIRECTORY_VIEW(obj) \
 
43
  (G_TYPE_CHECK_INSTANCE_CAST ((obj), FM_TYPE_DIRECTORY_VIEW, FMDirectoryView))
 
44
#define FM_DIRECTORY_VIEW_CLASS(klass) \
 
45
  (G_TYPE_CHECK_CLASS_CAST ((klass), FM_TYPE_DIRECTORY_VIEW, FMDirectoryViewClass))
 
46
#define FM_IS_DIRECTORY_VIEW(obj) \
 
47
  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FM_TYPE_DIRECTORY_VIEW))
 
48
#define FM_IS_DIRECTORY_VIEW_CLASS(klass) \
 
49
  (G_TYPE_CHECK_CLASS_TYPE ((klass), FM_TYPE_DIRECTORY_VIEW))
 
50
#define FM_DIRECTORY_VIEW_GET_CLASS(obj) \
 
51
  (G_TYPE_INSTANCE_GET_CLASS ((obj), FM_TYPE_DIRECTORY_VIEW, FMDirectoryViewClass))
 
52
 
 
53
typedef struct FMDirectoryViewDetails FMDirectoryViewDetails;
 
54
 
 
55
struct FMDirectoryView {
 
56
        GtkScrolledWindow parent;
 
57
        FMDirectoryViewDetails *details;
 
58
};
 
59
 
 
60
struct FMDirectoryViewClass {
 
61
        GtkScrolledWindowClass parent_class;
 
62
 
 
63
        /* The 'clear' signal is emitted to empty the view of its contents.
 
64
         * It must be replaced by each subclass.
 
65
         */
 
66
//      void    (* clear)                (FMDirectoryView *view);
 
67
        
 
68
        /* The 'begin_file_changes' signal is emitted before a set of files
 
69
         * are added to the view. It can be replaced by a subclass to do any 
 
70
         * necessary preparation for a set of new files. The default
 
71
         * implementation does nothing.
 
72
         */
 
73
        //void  (* begin_file_changes) (FMDirectoryView *view);
 
74
        
 
75
        /* The 'add_file' signal is emitted to add one file to the view.
 
76
         * It must be replaced by each subclass.
 
77
         */
 
78
        void    (* add_file)             (FMDirectoryView *view, 
 
79
                                          GOFFile *file,
 
80
                                          GOFDirectoryAsync *directory);
 
81
#if 0
 
82
        void    (* remove_file)          (FMDirectoryView *view, 
 
83
                                          GOFFile *file,
 
84
                                          GOFDirectoryAsync *directory);
 
85
 
 
86
        /* The 'file_changed' signal is emitted to signal a change in a file,
 
87
         * including the file being removed.
 
88
         * It must be replaced by each subclass.
 
89
         */
 
90
        void    (* file_changed)         (FMDirectoryView *view, 
 
91
                                          GOFFile *file,
 
92
                                          GOFDirectoryAsync *directory);
 
93
 
 
94
        /* The 'end_file_changes' signal is emitted after a set of files
 
95
         * are added to the view. It can be replaced by a subclass to do any 
 
96
         * necessary cleanup (typically, cleanup for code in begin_file_changes).
 
97
         * The default implementation does nothing.
 
98
         */
 
99
        //void  (* end_file_changes)    (FMDirectoryView *view);
 
100
        
 
101
        //void    (* flush_added_files)  (FMDirectoryView *view);
 
102
        
 
103
        /* The 'begin_loading' signal is emitted before any of the contents
 
104
         * of a directory are added to the view. It can be replaced by a 
 
105
         * subclass to do any necessary preparation to start dealing with a
 
106
         * new directory. The default implementation does nothing.
 
107
         */
 
108
        void    (* begin_loading)        (FMDirectoryView *view);
 
109
 
 
110
        /* The 'end_loading' signal is emitted after all of the contents
 
111
         * of a directory are added to the view. It can be replaced by a 
 
112
         * subclass to do any necessary clean-up. The default implementation 
 
113
         * does nothing.
 
114
         *
 
115
         * If all_files_seen is true, the handler may assume that
 
116
         * no load error ocurred, and all files of the underlying
 
117
         * directory were loaded.
 
118
         *
 
119
         * Otherwise, end_loading was emitted due to cancellation,
 
120
         * which usually means that not all files are available.
 
121
         */
 
122
        void    (* end_loading)          (FMDirectoryView *view,
 
123
                                          gboolean all_files_seen);
 
124
 
 
125
        /* The 'load_error' signal is emitted when the directory model
 
126
         * reports an error in the process of monitoring the directory's
 
127
         * contents.  The load error indicates that the process of 
 
128
         * loading the contents has ended, but the directory is still
 
129
         * being monitored. The default implementation handles common
 
130
         * load failures like ACCESS_DENIED.
 
131
         */
 
132
        void    (* load_error)           (FMDirectoryView *view,
 
133
                                          GError *error);
 
134
 
 
135
        /* Function pointers that don't have corresponding signals */
 
136
 
 
137
        /* reset_to_defaults is a function pointer that subclasses must 
 
138
         * override to set sort order, zoom level, etc to match default
 
139
         * values. 
 
140
         */
 
141
        void     (* reset_to_defaults)           (FMDirectoryView *view);
 
142
 
 
143
        /* get_selection is not a signal; it is just a function pointer for
 
144
         * subclasses to replace (override). Subclasses must replace it
 
145
         * with a function that returns a newly-allocated GList of
 
146
         * GOFFile pointers.
 
147
         */
 
148
        GList * (* get_selection)               (FMDirectoryView *view);
 
149
        
 
150
        /* get_selection_for_file_transfer  is a function pointer for
 
151
         * subclasses to replace (override). Subclasses must replace it
 
152
         * with a function that returns a newly-allocated GList of
 
153
         * GOFFile pointers. The difference from get_selection is
 
154
         * that any files in the selection that also has a parent folder
 
155
         * in the selection is not included.
 
156
         */
 
157
        GList * (* get_selection_for_file_transfer)(FMDirectoryView *view);
 
158
        
 
159
        /* select_all is a function pointer that subclasses must override to
 
160
         * select all of the items in the view */
 
161
        void     (* select_all)                 (FMDirectoryView *view);
 
162
 
 
163
        /* set_selection is a function pointer that subclasses must
 
164
         * override to select the specified items (and unselect all
 
165
         * others). The argument is a list of GOFFiles. */
 
166
 
 
167
        void     (* set_selection)              (FMDirectoryView *view, 
 
168
                                                 GList *selection);
 
169
                                                 
 
170
        /* invert_selection is a function pointer that subclasses must
 
171
         * override to invert selection. */
 
172
 
 
173
        void     (* invert_selection)           (FMDirectoryView *view);                                                 
 
174
 
 
175
        /* Return an array of locations of selected icons in their view. */
 
176
        //GArray * (* get_selected_icon_locations) (FMDirectoryView *view);
 
177
 
 
178
        guint    (* get_item_count)             (FMDirectoryView *view);
 
179
 
 
180
        /* bump_zoom_level is a function pointer that subclasses must override
 
181
         * to change the zoom level of an object. */
 
182
        /*void    (* bump_zoom_level)           (FMDirectoryView *view,
 
183
                                                 int zoom_increment);*/
 
184
 
 
185
        /* zoom_to_level is a function pointer that subclasses must override
 
186
         * to set the zoom level of an object to the specified level. */
 
187
        /*void    (* zoom_to_level)             (FMDirectoryView *view, 
 
188
                                                 NautilusZoomLevel level);*/
 
189
 
 
190
        //NautilusZoomLevel (* get_zoom_level)    (FMDirectoryView *view);
 
191
 
 
192
        /* restore_default_zoom_level is a function pointer that subclasses must override
 
193
         * to restore the zoom level of an object to a default setting. */
 
194
        //void    (* restore_default_zoom_level) (FMDirectoryView *view);
 
195
 
 
196
        /* can_zoom_in is a function pointer that subclasses must override to
 
197
         * return whether the view is at maximum size (furthest-in zoom level) */
 
198
        //gboolean (* can_zoom_in)              (FMDirectoryView *view);
 
199
 
 
200
        /* can_zoom_out is a function pointer that subclasses must override to
 
201
         * return whether the view is at minimum size (furthest-out zoom level) */
 
202
        //gboolean (* can_zoom_out)             (FMDirectoryView *view);
 
203
        
 
204
        /* reveal_selection is a function pointer that subclasses may
 
205
         * override to make sure the selected items are sufficiently
 
206
         * apparent to the user (e.g., scrolled into view). By default,
 
207
         * this does nothing.
 
208
         */
 
209
        void     (* reveal_selection)           (FMDirectoryView *view);
 
210
 
 
211
        /* get_background is a function pointer that subclasses must
 
212
         * override to return the EelBackground for this view.
 
213
         */
 
214
        //GtkWidget * (* get_background_widget) (FMDirectoryView *view);
 
215
 
 
216
        /* merge_menus is a function pointer that subclasses can override to
 
217
         * add their own menu items to the window's menu bar.
 
218
         * If overridden, subclasses must call parent class's function.
 
219
         */
 
220
        //void    (* merge_menus)               (FMDirectoryView *view);
 
221
        //void    (* unmerge_menus)             (FMDirectoryView *view);
 
222
 
 
223
        /* update_menus is a function pointer that subclasses can override to
 
224
         * update the sensitivity or wording of menu items in the menu bar.
 
225
         * It is called (at least) whenever the selection changes. If overridden, 
 
226
         * subclasses must call parent class's function.
 
227
         */
 
228
        //void    (* update_menus)              (FMDirectoryView *view);
 
229
 
 
230
        /* sort_files is a function pointer that subclasses can override
 
231
         * to provide a sorting order to determine which files should be
 
232
         * presented when only a partial list is provided.
 
233
         */
 
234
        int     (* compare_files)              (FMDirectoryView *view,
 
235
                                                GOFFile    *a,
 
236
                                                GOFFile    *b);
 
237
 
 
238
        /* get_emblem_names_to_exclude is a function pointer that subclasses
 
239
         * may override to specify a set of emblem names that should not
 
240
         * be displayed with each file. By default, all emblems returned by
 
241
         * GOFFile are displayed.
 
242
         */
 
243
        //char ** (* get_emblem_names_to_exclude)       (FMDirectoryView *view);
 
244
 
 
245
        /* file_limit_reached is a function pointer that subclasses may
 
246
         * override to control what happens when a directory is loaded
 
247
         * that has more files than Nautilus can handle. The default
 
248
         * implmentation puts up a dialog box that is appropriate to
 
249
         * display when the user explicitly tried to visit a location that
 
250
         * they would think of as a normal directory.
 
251
         */
 
252
        //void (* file_limit_reached)           (FMDirectoryView *view);
 
253
 
 
254
        /* supports_properties is a function pointer that subclasses may
 
255
         * override to control whether the "Show Properties" menu item
 
256
         * should be enabled for selected items. The default implementation 
 
257
         * returns TRUE.
 
258
         */
 
259
        //gboolean (* supports_properties)      (FMDirectoryView *view);
 
260
 
 
261
        /* supports_zooming is a function pointer that subclasses may
 
262
         * override to control whether or not the zooming control and
 
263
         * menu items should be enabled. The default implementation
 
264
         * returns TRUE.
 
265
         */
 
266
        //gboolean (* supports_zooming)         (FMDirectoryView *view);
 
267
 
 
268
        /* using_manual_layout is a function pointer that subclasses may
 
269
         * override to control whether or not items can be freely positioned
 
270
         * on the user-visible area.
 
271
         * Note that this value is not guaranteed to be constant within the
 
272
         * view's lifecycle. */
 
273
        //gboolean (* using_manual_layout)     (FMDirectoryView *view);
 
274
 
 
275
        /* is_read_only is a function pointer that subclasses may
 
276
         * override to control whether or not the user is allowed to
 
277
         * change the contents of the currently viewed directory. The
 
278
         * default implementation checks the permissions of the
 
279
         * directory.
 
280
         */
 
281
        gboolean (* is_read_only)               (FMDirectoryView *view);
 
282
 
 
283
        /* is_empty is a function pointer that subclasses must
 
284
         * override to report whether the view contains any items.
 
285
         */
 
286
        gboolean (* is_empty)                   (FMDirectoryView *view);
 
287
 
 
288
        /* supports_creating_files is a function pointer that subclasses may
 
289
         * override to control whether or not new items can be created.
 
290
         * be accepted. The default implementation checks whether the
 
291
         * user has write permissions for the viewed directory, and whether
 
292
         * the viewed directory is in the trash.
 
293
         */
 
294
        gboolean (* supports_creating_files)    (FMDirectoryView *view);
 
295
 
 
296
        /* accepts_dragged_files is a function pointer that subclasses may
 
297
         * override to control whether or not files can be dropped in this
 
298
         * location. The default implementation returns TRUE.
 
299
         */
 
300
        //gboolean (* accepts_dragged_files)    (FMDirectoryView *view);
 
301
 
 
302
        /*gboolean (* can_rename_file)            (FMDirectoryView *view,
 
303
                                                 GOFFile *file);*/
 
304
        /* select_all specifies whether the whole filename should be selected
 
305
         * or only its basename (i.e. everything except the extension)
 
306
         * */
 
307
        void     (* start_renaming_file)        (FMDirectoryView *view,
 
308
                                                 GOFFile *file,
 
309
                                                 gboolean select_all);
 
310
 
 
311
        /*gboolean (* file_still_belongs)               (FMDirectoryView *view,
 
312
                                                 GOFFile         *file,
 
313
                                                 GOFDirectoryAsync *directory);
 
314
                                                 */
 
315
 
 
316
        /* convert *point from widget's coordinate system to a coordinate
 
317
         * system used for specifying file operation positions, which is view-specific.
 
318
         *
 
319
         * This is used by the the icon view, which converts the screen position to a zoom
 
320
         * level-independent coordinate system.
 
321
         */
 
322
        /*void (* widget_to_file_operation_position) (FMDirectoryView *view,
 
323
                                                    GdkPoint
 
324
         *position);*/
 
325
 
 
326
        /* Preference change callbacks, overriden by icon and list views. 
 
327
         * Icon and list views respond by synchronizing to the new preference
 
328
         * values and forcing an update if appropriate.
 
329
         */
 
330
        /*void  (* text_attribute_names_changed)   (FMDirectoryView *view);
 
331
        void    (* embedded_text_policy_changed)   (FMDirectoryView *view);
 
332
        void    (* image_display_policy_changed)   (FMDirectoryView *view);
 
333
        void    (* click_policy_changed)           (FMDirectoryView *view);
 
334
        void    (* sort_directories_first_changed) (FMDirectoryView *view);
 
335
 
 
336
        void    (* emblems_changed)                (FMDirectoryView *view);
 
337
 
 
338
        void    (* set_is_active)                  (FMDirectoryView *view,
 
339
                                                    gboolean
 
340
                                                    is_active);*/
 
341
 
 
342
        /* Signals used only for keybindings */
 
343
        /*gboolean (* trash)                         (FMDirectoryView *view);
 
344
        gboolean (* delete)                        (FMDirectoryView *view);*/
 
345
#endif
 
346
};
 
347
 
 
348
/* GObject support */
 
349
GType           fm_directory_view_get_type                         (void);
 
350
void            fm_directory_view_add_subdirectory (FMDirectoryView *view, GOFDirectoryAsync *directory);
 
351
void            fm_directory_view_remove_subdirectory (FMDirectoryView *view, GOFDirectoryAsync *directory);
 
352
void            fm_directory_view_column_add_location (FMDirectoryView *dview, GFile *location);
 
353
void            fm_directory_view_column_add_preview (FMDirectoryView *dview, GFile *location);
 
354
void            fm_directory_view_set_active_slot (FMDirectoryView *dview);
 
355
void            fm_directory_view_load_location (FMDirectoryView *directory_view, GFile *location);
 
356
 
 
357
 
 
358
#endif /* FM_DIRECTORY_VIEW_H */