2007-12-11 A. Walton <awalton@svn.gnome.org>
[nautilus.git] / libnautilus-private / nautilus-view.c
blob47058f3ac592604a956bf96d1e43de0d796f66f0
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
3 nautilus-view.c: Interface for nautilus views
5 Copyright (C) 2004 Red Hat Inc.
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.
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.
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.
22 Author: Alexander Larsson <alexl@redhat.com>
25 #include <config.h>
26 #include "nautilus-view.h"
28 enum {
29 TITLE_CHANGED,
30 ZOOM_PARAMETERS_CHANGED,
31 ZOOM_LEVEL_CHANGED,
32 LAST_SIGNAL
35 static guint nautilus_view_signals[LAST_SIGNAL] = { 0 };
37 static void
38 nautilus_view_base_init (gpointer g_class)
40 static gboolean initialized = FALSE;
42 if (! initialized) {
43 nautilus_view_signals[TITLE_CHANGED] =
44 g_signal_new ("title_changed",
45 NAUTILUS_TYPE_VIEW,
46 G_SIGNAL_RUN_LAST,
47 G_STRUCT_OFFSET (NautilusViewIface, title_changed),
48 NULL, NULL,
49 g_cclosure_marshal_VOID__VOID,
50 G_TYPE_NONE, 0);
52 nautilus_view_signals[ZOOM_PARAMETERS_CHANGED] =
53 g_signal_new ("zoom_parameters_changed",
54 NAUTILUS_TYPE_VIEW,
55 G_SIGNAL_RUN_LAST,
56 G_STRUCT_OFFSET (NautilusViewIface, zoom_parameters_changed),
57 NULL, NULL,
58 g_cclosure_marshal_VOID__VOID,
59 G_TYPE_NONE, 0);
61 nautilus_view_signals[ZOOM_LEVEL_CHANGED] =
62 g_signal_new ("zoom_level_changed",
63 NAUTILUS_TYPE_VIEW,
64 G_SIGNAL_RUN_LAST,
65 G_STRUCT_OFFSET (NautilusViewIface, zoom_level_changed),
66 NULL, NULL,
67 g_cclosure_marshal_VOID__VOID,
68 G_TYPE_NONE, 0);
70 initialized = TRUE;
74 GType
75 nautilus_view_get_type (void)
77 static GType type = 0;
79 if (!type) {
80 const GTypeInfo info = {
81 sizeof (NautilusViewIface),
82 nautilus_view_base_init,
83 NULL,
84 NULL,
85 NULL,
86 NULL,
89 NULL
92 type = g_type_register_static (G_TYPE_INTERFACE,
93 "NautilusView",
94 &info, 0);
95 g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
98 return type;
101 const char *
102 nautilus_view_get_view_id (NautilusView *view)
104 g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL);
106 return (* NAUTILUS_VIEW_GET_IFACE (view)->get_view_id) (view);
109 GtkWidget *
110 nautilus_view_get_widget (NautilusView *view)
112 g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL);
114 return (* NAUTILUS_VIEW_GET_IFACE (view)->get_widget) (view);
117 void
118 nautilus_view_load_location (NautilusView *view,
119 const char *location_uri)
121 g_return_if_fail (NAUTILUS_IS_VIEW (view));
122 g_return_if_fail (location_uri != NULL);
124 (* NAUTILUS_VIEW_GET_IFACE (view)->load_location) (view,
125 location_uri);
128 void
129 nautilus_view_stop_loading (NautilusView *view)
131 g_return_if_fail (NAUTILUS_IS_VIEW (view));
133 (* NAUTILUS_VIEW_GET_IFACE (view)->stop_loading) (view);
137 nautilus_view_get_selection_count (NautilusView *view)
139 g_return_val_if_fail (NAUTILUS_IS_VIEW (view), 0);
141 return (* NAUTILUS_VIEW_GET_IFACE (view)->get_selection_count) (view);
144 GList *
145 nautilus_view_get_selection (NautilusView *view)
147 g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL);
149 return (* NAUTILUS_VIEW_GET_IFACE (view)->get_selection) (view);
152 void
153 nautilus_view_set_selection (NautilusView *view,
154 GList *list)
156 g_return_if_fail (NAUTILUS_IS_VIEW (view));
158 (* NAUTILUS_VIEW_GET_IFACE (view)->set_selection) (view,
159 list);
163 char *
164 nautilus_view_get_first_visible_file (NautilusView *view)
166 g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL);
168 return (* NAUTILUS_VIEW_GET_IFACE (view)->get_first_visible_file) (view);
171 void
172 nautilus_view_scroll_to_file (NautilusView *view,
173 const char *uri)
175 g_return_if_fail (NAUTILUS_IS_VIEW (view));
177 (* NAUTILUS_VIEW_GET_IFACE (view)->scroll_to_file) (view, uri);
180 char *
181 nautilus_view_get_title (NautilusView *view)
183 g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL);
185 if (NAUTILUS_VIEW_GET_IFACE (view)->get_title != NULL) {
186 return (* NAUTILUS_VIEW_GET_IFACE (view)->get_title) (view);
187 } else {
188 return NULL;
193 gboolean
194 nautilus_view_supports_zooming (NautilusView *view)
196 g_return_val_if_fail (NAUTILUS_IS_VIEW (view), FALSE);
198 return (* NAUTILUS_VIEW_GET_IFACE (view)->supports_zooming) (view);
201 void
202 nautilus_view_bump_zoom_level (NautilusView *view,
203 int zoom_increment)
205 g_return_if_fail (NAUTILUS_IS_VIEW (view));
207 (* NAUTILUS_VIEW_GET_IFACE (view)->bump_zoom_level) (view,
208 zoom_increment);
211 void
212 nautilus_view_zoom_to_level (NautilusView *view,
213 NautilusZoomLevel level)
215 g_return_if_fail (NAUTILUS_IS_VIEW (view));
217 (* NAUTILUS_VIEW_GET_IFACE (view)->zoom_to_level) (view,
218 level);
221 void
222 nautilus_view_restore_default_zoom_level (NautilusView *view)
224 g_return_if_fail (NAUTILUS_IS_VIEW (view));
226 (* NAUTILUS_VIEW_GET_IFACE (view)->restore_default_zoom_level) (view);
229 gboolean
230 nautilus_view_can_zoom_in (NautilusView *view)
232 g_return_val_if_fail (NAUTILUS_IS_VIEW (view), FALSE);
234 return (* NAUTILUS_VIEW_GET_IFACE (view)->can_zoom_in) (view);
237 gboolean
238 nautilus_view_can_zoom_out (NautilusView *view)
240 g_return_val_if_fail (NAUTILUS_IS_VIEW (view), FALSE);
242 return (* NAUTILUS_VIEW_GET_IFACE (view)->can_zoom_out) (view);
245 NautilusZoomLevel
246 nautilus_view_get_zoom_level (NautilusView *view)
248 g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NAUTILUS_ZOOM_LEVEL_STANDARD);
250 return (* NAUTILUS_VIEW_GET_IFACE (view)->get_zoom_level) (view);
253 void
254 nautilus_view_grab_focus (NautilusView *view)
256 g_return_if_fail (NAUTILUS_IS_VIEW (view));
258 if (NAUTILUS_VIEW_GET_IFACE (view)->grab_focus != NULL) {
259 (* NAUTILUS_VIEW_GET_IFACE (view)->grab_focus) (view);
263 void
264 nautilus_view_pop_up_location_context_menu (NautilusView *view,
265 GdkEventButton *event)
267 g_return_if_fail (NAUTILUS_IS_VIEW (view));
269 if (NAUTILUS_VIEW_GET_IFACE (view)->pop_up_location_context_menu != NULL) {
270 (* NAUTILUS_VIEW_GET_IFACE (view)->pop_up_location_context_menu) (view, event);