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>
26 #include "nautilus-view.h"
30 ZOOM_PARAMETERS_CHANGED
,
35 static guint nautilus_view_signals
[LAST_SIGNAL
] = { 0 };
38 nautilus_view_base_init (gpointer g_class
)
40 static gboolean initialized
= FALSE
;
43 nautilus_view_signals
[TITLE_CHANGED
] =
44 g_signal_new ("title_changed",
47 G_STRUCT_OFFSET (NautilusViewIface
, title_changed
),
49 g_cclosure_marshal_VOID__VOID
,
52 nautilus_view_signals
[ZOOM_PARAMETERS_CHANGED
] =
53 g_signal_new ("zoom_parameters_changed",
56 G_STRUCT_OFFSET (NautilusViewIface
, zoom_parameters_changed
),
58 g_cclosure_marshal_VOID__VOID
,
61 nautilus_view_signals
[ZOOM_LEVEL_CHANGED
] =
62 g_signal_new ("zoom_level_changed",
65 G_STRUCT_OFFSET (NautilusViewIface
, zoom_level_changed
),
67 g_cclosure_marshal_VOID__VOID
,
75 nautilus_view_get_type (void)
77 static GType type
= 0;
80 const GTypeInfo info
= {
81 sizeof (NautilusViewIface
),
82 nautilus_view_base_init
,
92 type
= g_type_register_static (G_TYPE_INTERFACE
,
95 g_type_interface_add_prerequisite (type
, G_TYPE_OBJECT
);
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
);
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
);
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
,
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
);
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
);
153 nautilus_view_set_selection (NautilusView
*view
,
156 g_return_if_fail (NAUTILUS_IS_VIEW (view
));
158 (* NAUTILUS_VIEW_GET_IFACE (view
)->set_selection
) (view
,
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
);
172 nautilus_view_scroll_to_file (NautilusView
*view
,
175 g_return_if_fail (NAUTILUS_IS_VIEW (view
));
177 (* NAUTILUS_VIEW_GET_IFACE (view
)->scroll_to_file
) (view
, uri
);
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
);
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
);
202 nautilus_view_bump_zoom_level (NautilusView
*view
,
205 g_return_if_fail (NAUTILUS_IS_VIEW (view
));
207 (* NAUTILUS_VIEW_GET_IFACE (view
)->bump_zoom_level
) (view
,
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
,
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
);
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
);
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
);
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
);
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
);
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
);