fm-directory-view.h 13.5 KB
Newer Older
Ettore Perazzoli's avatar
Ettore Perazzoli committed
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2
/* fm-directory-view.h
Ettore Perazzoli's avatar
Ettore Perazzoli committed
3
 *
Elliot Lee's avatar
Elliot Lee committed
4
 * Copyright (C) 1999, 2000  Free Software Foundaton
5
 * Copyright (C) 2000  Eazel, Inc.
Ettore Perazzoli's avatar
Ettore Perazzoli committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Author: Ettore Perazzoli
 */

25 26 27
#ifndef FM_DIRECTORY_VIEW_H
#define FM_DIRECTORY_VIEW_H

28
#include <bonobo/bonobo-ui-handler.h>
29
#include <gtk/gtkmenu.h>
30
#include <gtk/gtkscrolledwindow.h>
31
#include <libnautilus/nautilus-view.h>
32 33 34
#include <libnautilus-extensions/nautilus-directory.h>
#include <libnautilus-extensions/nautilus-file.h>
#include <libnautilus-extensions/nautilus-icon-container.h>
35 36 37

typedef struct FMDirectoryView FMDirectoryView;
typedef struct FMDirectoryViewClass FMDirectoryViewClass;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
38

39 40 41 42
/* Paths to use when creating & referring to bonobo menu items.
 * These are the new ones defined by FMDirectoryView. The
 * Nautilus-wide ones are in <libnautilus/nautilus-bonobo-ui.h>
 */
43 44
#define FM_DIRECTORY_VIEW_MENU_PATH_OPEN                      	"/File/Open"
#define FM_DIRECTORY_VIEW_MENU_PATH_OPEN_IN_NEW_WINDOW        	"/File/OpenNew"
45
#define FM_DIRECTORY_VIEW_MENU_PATH_OPEN_WITH			"/File/Open With"
46
#define FM_DIRECTORY_VIEW_MENU_PATH_NEW_FOLDER			"/File/New Folder"
47 48
#define FM_DIRECTORY_VIEW_MENU_PATH_SEPARATOR_AFTER_CLOSE	"/File/SeparatorAfterClose"
#define FM_DIRECTORY_VIEW_MENU_PATH_DELETE                    	"/File/Delete"
49
#define FM_DIRECTORY_VIEW_MENU_PATH_TRASH                    	"/File/Trash"
50
#define FM_DIRECTORY_VIEW_MENU_PATH_DUPLICATE                 	"/File/Duplicate"
51
#define FM_DIRECTORY_VIEW_MENU_PATH_EMPTY_TRASH                	"/File/Empty Trash"
52
#define FM_DIRECTORY_VIEW_MENU_PATH_SHOW_PROPERTIES            	"/File/Show Properties"
53 54 55
#define FM_DIRECTORY_VIEW_MENU_PATH_SEPARATOR_BEFORE_RESET      "/Edit/Before Reset"
#define FM_DIRECTORY_VIEW_MENU_PATH_RESET_BACKGROUND		"/Edit/Reset Background"
#define FM_DIRECTORY_VIEW_MENU_PATH_REMOVE_CUSTOM_ICONS         "/Edit/Remove Custom Icons"
56 57 58
#define FM_DIRECTORY_VIEW_MENU_PATH_OTHER_APPLICATION    	"/File/Open With/OtherApplication"
#define FM_DIRECTORY_VIEW_MENU_PATH_SEPARATOR_BEFORE_VIEWERS    "/File/Open With/SeparatorBeforeViewers"
#define FM_DIRECTORY_VIEW_MENU_PATH_OTHER_VIEWER	    	"/File/Open With/OtherViewer"
59

60 61 62
#define FM_TYPE_DIRECTORY_VIEW			(fm_directory_view_get_type ())
#define FM_DIRECTORY_VIEW(obj)			(GTK_CHECK_CAST ((obj), FM_TYPE_DIRECTORY_VIEW, FMDirectoryView))
#define FM_DIRECTORY_VIEW_CLASS(klass)		(GTK_CHECK_CLASS_CAST ((klass), FM_TYPE_DIRECTORY_VIEW, FMDirectoryViewClass))
63
#define FM_IS_DIRECTORY_VIEW(obj)		(GTK_CHECK_TYPE ((obj), FM_TYPE_DIRECTORY_VIEW))
64
#define FM_IS_DIRECTORY_VIEW_CLASS(klass)	(GTK_CHECK_CLASS_TYPE ((klass), FM_TYPE_DIRECTORY_VIEW))
Ettore Perazzoli's avatar
Ettore Perazzoli committed
65

66
typedef struct FMDirectoryViewDetails FMDirectoryViewDetails;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
67

68
struct FMDirectoryView {
69 70
	GtkScrolledWindow parent;
	FMDirectoryViewDetails *details;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
71 72
};

73
struct FMDirectoryViewClass {
74
	GtkScrolledWindowClass parent_class;
75

76 77 78 79 80
	/* The 'clear' signal is emitted to empty the view of its contents.
	 * It must be replaced by each subclass.
	 */
	void 	(* clear) 		 (FMDirectoryView *view);
	
81
	/* The 'begin_adding_files' signal is emitted before a set of files
82
	 * are added to the view. It can be replaced by a subclass to do any 
83
	 * necessary preparation for a set of new files. The default
84 85
	 * implementation does nothing.
	 */
86
	void 	(* begin_adding_files) (FMDirectoryView *view);
87
	
88
	/* The 'add_file' signal is emitted to add one file to the view.
89 90
	 * It must be replaced by each subclass.
	 */
91
	void 	(* add_file) 		 (FMDirectoryView *view, 
92
					  NautilusFile *file);
93

94 95
	/* The 'file_changed' signal is emitted to signal a change in a file,
	 * including the file being removed.
96 97 98 99 100 101
	 * It must be replaced by each subclass.
	 */
	void 	(* file_changed)         (FMDirectoryView *view, 
					  NautilusFile *file);

	/* The 'done_adding_files' signal is emitted after a set of files
102
	 * are added to the view. It can be replaced by a subclass to do any 
103
	 * necessary cleanup (typically, cleanup for code in begin_adding_files).
104 105
	 * The default implementation does nothing.
	 */
106
	void 	(* done_adding_files)    (FMDirectoryView *view);
107 108 109 110 111 112 113 114
	
	/* The 'begin_loading' signal is emitted before any of the contents
	 * of a directory are added to the view. It can be replaced by a 
	 * subclass to do any necessary preparation to start dealing with a
	 * new directory. The default implementation does nothing.
	 */
	void 	(* begin_loading) 	 (FMDirectoryView *view);

115
	/* The 'create_selection_context_menu_items' signal is emitted 
116 117 118 119
	 * when creating a context menu for the selected items. @files is
	 * the list of selected files; it isn't destroyed until the menu
	 * is destroyed so it can be used in callbacks.
	 * Subclasses might want to override this function to
120 121
	 * modify the menu contents.
	 */
122
	void 	(* create_selection_context_menu_items) 	 
123 124
					 (FMDirectoryView *view,
					  GtkMenu *menu,
125
					  GList *files);
126

127
	/* The 'create_background_context_menu_items' signal is emitted 
128 129 130 131
	 * when creating a context menu, either an item-specific one or
	 * a background one. Subclasses might want to override this to
	 * modify the menu contents.
	 */
132
	void 	(* create_background_context_menu_items) 	 
133 134
					 (FMDirectoryView *view,
					  GtkMenu *menu);
Pavel Cisler's avatar
Pavel Cisler committed
135
	 
136 137
	/* Function pointers that don't have corresponding signals */

138 139 140
	/* get_selection is not a signal; it is just a function pointer for
	 * subclasses to replace (override). Subclasses must replace it
	 * with a function that returns a newly-allocated GList of
141
	 * NautilusFile pointers.
142
	 */
143
	GList *	(* get_selection) 	 	(FMDirectoryView *view);
144
	
145 146
        /* bump_zoom_level is a function pointer that subclasses must override
         * to change the zoom level of an object. */
147 148 149
        void    (* bump_zoom_level)      	(FMDirectoryView *view,
					  	 int zoom_increment);

150 151 152 153 154 155 156
        /* zoom_to_level is a function pointer that subclasses must override
         * to set the zoom level of an object to the specified level. */
        void    (* zoom_to_level) 		(FMDirectoryView *view, 
        				         gint 		 level);

        /* restore_default_zoom_level is a function pointer that subclasses must override
         * to restore the zoom level of an object to a default setting. */
157
        void    (* restore_default_zoom_level) (FMDirectoryView *view);
158 159 160

        /* can_zoom_in is a function pointer that subclasses must override to
         * return whether the view is at maximum size (furthest-in zoom level) */
161
        gboolean (* can_zoom_in)	 	(FMDirectoryView *view);
162 163 164

        /* can_zoom_out is a function pointer that subclasses must override to
         * return whether the view is at minimum size (furthest-out zoom level) */
165
        gboolean (* can_zoom_out)	 	(FMDirectoryView *view);
166
        
167
        /* select_all is a function pointer that subclasses must override to
168
         * select all of the items in the view */
169
        void     (* select_all)	         	(FMDirectoryView *view);
170

171 172 173 174
        /* set_selection is a function pointer that subclasses must
         * override to select the specified items (and unselect all
         * others). The argument is a list of NautilusFiles. */

175 176
        void     (* set_selection)	 	(FMDirectoryView *view, 
        					 GList *selection);
177

178 179 180 181 182
        /* get_background is a function pointer that subclasses must
         * override to return the NautilusBackground for this view.
         */
        GtkWidget * (* get_background_widget)	(FMDirectoryView *view);

183 184 185 186
        /* merge_menus is a function pointer that subclasses can override to
         * add their own menu items to the window's menu bar.
         * If overridden, subclasses must call parent class's function.
         */
187
        void    (* merge_menus)         	(FMDirectoryView *view);
188 189 190 191 192 193

        /* update_menus is a function pointer that subclasses can override to
         * update the sensitivity or wording of menu items in the menu bar.
         * It is called (at least) whenever the selection changes. If overridden, 
         * subclasses must call parent class's function.
         */
194
        void    (* update_menus)         	(FMDirectoryView *view);
Ettore Perazzoli's avatar
Ettore Perazzoli committed
195

196 197
	/* get_required_metadata_keys is a function pointer that subclasses
	 * may override to request additional metadata to be read before showing
198
	 * the directory view. If overridden, subclasses must all parent class's
199 200
	 * function.
	 */
201
	void    (* get_required_metadata_keys)	(FMDirectoryView *view,
202 203
					  	 GList           **directory_metadata_keys,
					  	 GList           **file_metadata_keys);
204

205 206
	void	(* start_renaming_item)	 	(FMDirectoryView *view,
					  	 const char *uri);
207 208 209 210 211 212 213 214 215

	/* Preference change callbacks, overriden by icon and list views. 
	 * Icon and list views respond by synchronizing to the new preference
	 * values and forcing an update if appropriate.
	 */
	void	(* text_attribute_names_changed)(FMDirectoryView *view);
	void	(* font_family_changed)		(FMDirectoryView *view);
	void	(* click_policy_changed)	(FMDirectoryView *view);
	void	(* anti_aliased_mode_changed)	(FMDirectoryView *view);
216
};
217

218
/* GtkObject support */
Darin Adler's avatar
Darin Adler committed
219
GtkType            fm_directory_view_get_type                       (void);
220

221
/* Component embedding support */
Darin Adler's avatar
Darin Adler committed
222
NautilusView *     fm_directory_view_get_nautilus_view              (FMDirectoryView       *view);
223

224
/* URI handling */
Darin Adler's avatar
Darin Adler committed
225 226
void               fm_directory_view_load_uri                       (FMDirectoryView       *view,
								     const char            *uri);
227

228
/* Functions callable from the user interface and elsewhere. */
229 230
char *             fm_directory_view_get_uri		            (FMDirectoryView       *view);
gboolean           fm_directory_view_can_accept_item                (NautilusFile          *target_item,
Darin Adler's avatar
Darin Adler committed
231 232
								     const char            *item_uri,
								     FMDirectoryView       *view);
233
void		   fm_directory_view_display_selection_info	    (FMDirectoryView	   *view);
Darin Adler's avatar
Darin Adler committed
234 235 236 237
GList *            fm_directory_view_get_selection                  (FMDirectoryView       *view);
void               fm_directory_view_stop                           (FMDirectoryView       *view);
gboolean           fm_directory_view_can_zoom_in                    (FMDirectoryView       *view);
gboolean           fm_directory_view_can_zoom_out                   (FMDirectoryView       *view);
238
GtkWidget *	   fm_directory_view_get_background_widget 	    (FMDirectoryView	   *view);
Darin Adler's avatar
Darin Adler committed
239 240
void               fm_directory_view_bump_zoom_level                (FMDirectoryView       *view,
								     int                    zoom_increment);
241 242
void               fm_directory_view_zoom_to_level                  (FMDirectoryView        *view,
								     int                    zoom_level);
243
void               fm_directory_view_set_zoom_level		    (FMDirectoryView        *view,
244
								     int                    zoom_level);
245
void               fm_directory_view_restore_default_zoom_level     (FMDirectoryView       *view);
Darin Adler's avatar
Darin Adler committed
246 247 248
void               fm_directory_view_select_all                     (FMDirectoryView       *view);
void               fm_directory_view_set_selection                  (FMDirectoryView       *view,
								     GList                 *selection);
249
void               fm_directory_view_move_copy_items                (const GList           *item_uris,
Darin Adler's avatar
Darin Adler committed
250 251 252 253 254 255 256
								     const GdkPoint        *relative_item_points,
								     const char            *target_uri,
								     int                    copy_action,
								     int                    x,
								     int                    y,
								     FMDirectoryView       *view);
gint               fm_directory_view_get_context_menu_index         (const char            *menu_name);
257

258

259 260 261 262
/* Wrappers for signal emitters. These are normally called 
 * only by FMDirectoryView itself. They have corresponding signals
 * that observers might want to connect with.
 */
Darin Adler's avatar
Darin Adler committed
263 264
void               fm_directory_view_clear                          (FMDirectoryView       *view);
void               fm_directory_view_begin_loading                  (FMDirectoryView       *view);
265

266 267 268
/* Hooks for subclasses to call. These are normally called only by 
 * FMDirectoryView and its subclasses 
 */
269 270
void               fm_directory_view_activate_files                 (FMDirectoryView       *view,
								     GList          	   *files);
Darin Adler's avatar
Darin Adler committed
271 272 273 274 275 276
void               fm_directory_view_notify_selection_changed       (FMDirectoryView       *view);
BonoboUIHandler *  fm_directory_view_get_bonobo_ui_handler          (FMDirectoryView       *view);
NautilusDirectory *fm_directory_view_get_model                      (FMDirectoryView       *view);
void               fm_directory_view_pop_up_background_context_menu (FMDirectoryView       *view);
void               fm_directory_view_pop_up_selection_context_menu  (FMDirectoryView       *view); 
void               fm_directory_view_update_menus                   (FMDirectoryView       *view);
277 278 279 280 281
void		   fm_directory_view_add_menu_item		    (FMDirectoryView 	   *view, 
								     GtkMenu 		   *menu, 
								     const char 	   *label,
								     void 		  (* activate_handler) (GtkMenuItem *, FMDirectoryView *),
								     gboolean 		   sensitive);
Pavel Cisler's avatar
Pavel Cisler committed
282

283
#endif /* FM_DIRECTORY_VIEW_H */