2008-05-05 Paolo Borelli <pborelli@katamail.com>
[nautilus.git] / src / nautilus-throbber.c
blobf8db07d103c000a4bf4a71119ad8da5f02fca487
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
3 /*
4 * Nautilus
6 * Copyright (C) 2000 Eazel, Inc.
7 * Copyright (C) 2006 Christian Persch
9 * Nautilus is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * Nautilus is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * Author: Andy Hertzfeld <andy@eazel.com>
25 * This is the throbber (for busy feedback) for the location bar
29 #include <config.h>
31 #include "nautilus-throbber.h"
33 #include <eel/eel-debug.h>
34 #include <eel/eel-glib-extensions.h>
35 #include <eel/eel-gtk-extensions.h>
36 #include <eel/eel-accessibility.h>
37 #include <glib/gi18n.h>
39 static AtkObject *nautilus_throbber_get_accessible (GtkWidget *widget);
41 G_DEFINE_TYPE (NautilusThrobber, nautilus_throbber, EPHY_TYPE_SPINNER)
43 static void
44 nautilus_throbber_init (NautilusThrobber *throbber)
48 void
49 nautilus_throbber_start (NautilusThrobber *throbber)
51 ephy_spinner_start (EPHY_SPINNER (throbber));
54 void
55 nautilus_throbber_stop (NautilusThrobber *throbber)
57 ephy_spinner_stop (EPHY_SPINNER (throbber));
60 void
61 nautilus_throbber_set_size (NautilusThrobber *throbber, GtkIconSize size)
63 ephy_spinner_set_size (EPHY_SPINNER (throbber), size);
66 static void
67 nautilus_throbber_class_init (NautilusThrobberClass *class)
69 GtkWidgetClass *widget_class;
71 widget_class = GTK_WIDGET_CLASS (class);
73 widget_class->get_accessible = nautilus_throbber_get_accessible;
76 static AtkObjectClass *a11y_parent_class = NULL;
78 static void
79 nautilus_throbber_accessible_initialize (AtkObject *accessible,
80 gpointer widget)
82 atk_object_set_name (accessible, _("throbber"));
83 atk_object_set_description (accessible, _("provides visual status"));
85 a11y_parent_class->initialize (accessible, widget);
88 static void
89 nautilus_throbber_accessible_class_init (AtkObjectClass *klass)
91 a11y_parent_class = g_type_class_peek_parent (klass);
93 klass->initialize = nautilus_throbber_accessible_initialize;
96 static void
97 nautilus_throbber_accessible_image_get_size (AtkImage *image,
98 gint *width,
99 gint *height)
101 GtkWidget *widget;
103 widget = GTK_ACCESSIBLE (image)->widget;
104 if (!widget) {
105 *width = *height = 0;
106 } else {
107 *width = widget->allocation.width;
108 *height = widget->allocation.height;
112 static void
113 nautilus_throbber_accessible_image_interface_init (AtkImageIface *iface)
115 iface->get_image_size = nautilus_throbber_accessible_image_get_size;
118 static GType
119 nautilus_throbber_accessible_get_type (void)
121 static GType type = 0;
123 /* Action interface
124 Name etc. ... */
125 if (G_UNLIKELY (type == 0)) {
126 const GInterfaceInfo atk_image_info = {
127 (GInterfaceInitFunc) nautilus_throbber_accessible_image_interface_init,
128 (GInterfaceFinalizeFunc) NULL,
129 NULL
132 type = eel_accessibility_create_derived_type
133 ("NautilusThrobberAccessible",
134 GTK_TYPE_IMAGE,
135 nautilus_throbber_accessible_class_init);
137 g_type_add_interface_static (type, ATK_TYPE_IMAGE,
138 &atk_image_info);
141 return type;
144 static AtkObject *
145 nautilus_throbber_get_accessible (GtkWidget *widget)
147 AtkObject *accessible;
149 if ((accessible = eel_accessibility_get_atk_object (widget))) {
150 return accessible;
153 accessible = g_object_new
154 (nautilus_throbber_accessible_get_type (), NULL);
156 return eel_accessibility_set_atk_object_return (widget, accessible);
159 GtkWidget *
160 nautilus_throbber_new (void)
162 return g_object_new (NAUTILUS_TYPE_THROBBER, NULL);