summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Hertzfeld <andy@src.gnome.org>2000-08-30 09:08:42 +0000
committerAndy Hertzfeld <andy@src.gnome.org>2000-08-30 09:08:42 +0000
commitb07d1d4cf31c63a1dd357d054cd39813e6b3dc77 (patch)
tree845e6a9acc7a93e8ccc24e2e0847c8bca0ab10fc
parent1cd321c684850a3d4ca2a42abe66ba5fb776caa9 (diff)
downloadnautilus-b07d1d4cf31c63a1dd357d054cd39813e6b3dc77.tar.gz
added a netscape like throbber to give busy feedback while loading pages.
added a netscape like throbber to give busy feedback while loading pages. It uses a generic image from Arlo, but different themes can/will include other animations. There's still a little more left to do.
-rw-r--r--ChangeLog45
-rw-r--r--configure.in1
-rw-r--r--icons/Makefile.am2
-rw-r--r--icons/throbber/.cvsignore2
-rw-r--r--icons/throbber/001.pngbin0 -> 1343 bytes
-rw-r--r--icons/throbber/002.pngbin0 -> 1402 bytes
-rw-r--r--icons/throbber/003.pngbin0 -> 1385 bytes
-rw-r--r--icons/throbber/004.pngbin0 -> 1369 bytes
-rw-r--r--icons/throbber/005.pngbin0 -> 1390 bytes
-rw-r--r--icons/throbber/006.pngbin0 -> 1338 bytes
-rw-r--r--icons/throbber/007.pngbin0 -> 1416 bytes
-rw-r--r--icons/throbber/008.pngbin0 -> 1396 bytes
-rw-r--r--icons/throbber/009.pngbin0 -> 1384 bytes
-rw-r--r--icons/throbber/010.pngbin0 -> 1389 bytes
-rw-r--r--icons/throbber/Makefile.am19
-rw-r--r--icons/throbber/rest.pngbin0 -> 1475 bytes
-rw-r--r--src/Makefile.am2
-rw-r--r--src/nautilus-navigation-window.c9
-rw-r--r--src/nautilus-navigation-window.h3
-rw-r--r--src/nautilus-object-window.c9
-rw-r--r--src/nautilus-object-window.h3
-rw-r--r--src/nautilus-spatial-window.c9
-rw-r--r--src/nautilus-spatial-window.h3
-rw-r--r--src/nautilus-throbber.c390
-rw-r--r--src/nautilus-throbber.h67
-rw-r--r--src/nautilus-toolbar.c11
-rw-r--r--src/nautilus-toolbar.h3
-rw-r--r--src/nautilus-window-toolbars.c17
-rw-r--r--src/nautilus-window.c9
-rw-r--r--src/nautilus-window.h3
30 files changed, 600 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index db9514b09..bc3a01891 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,48 @@
+2000-08-30 Andy Hertzfeld <andy@eazel.com>
+
+ added a Netscape-like throbber widget to the toolbar, to give busy feedback. It uses
+ uses a generic animation from Arlo, but it's themable. It still needs some clean-up
+ but it's mostly done.
+
+ * configure.in:
+ * icons/Makefile.am:
+ * icons/throbber
+ * icons/throbber/.cvsignore:
+ * icons/throbber/Makefile.am:
+ * icons/throbber/*.png:
+ added a directory of frame images for the generic throbber.
+
+ * src/Makefile.am:
+ * src/nautilus-throbber.c,h: (nautilus_throbber_initialize_class),
+ (nautilus_throbber_destroy), (get_throbber_dimensions),
+ (nautilus_throbber_initialize), (nautilus_throbber_new),
+ (nautilus_throbber_theme_changed), (draw_pixbuf),
+ (select_throbber_image), (draw_throbber_image),
+ (nautilus_throbber_draw), (nautilus_throbber_expose),
+ (bump_throbber_frame), (nautilus_throbber_start),
+ (nautilus_throbber_stop), (nautilus_throbber_unload_images),
+ (load_themed_image), (make_throbber_frame_name),
+ (nautilus_throbber_load_images),
+ (nautilus_throbber_button_press_event),
+ (nautilus_throbber_size_allocate):
+ added a throbber widget that animates while pages are loaded.
+
+ * src/nautilus-toolbar.h:
+ made the nautilus toolbar know about the throbber
+ * src/nautilus-toolbar.c,h: (nautilus_toolbar_set_throbber),
+ (nautilus_toolbar_size_allocate):
+ made the nautilus toolbar position the throbber on the far right
+
+ * src/nautilus-window-toolbars.c: (allocate_throbber),
+ (nautilus_window_initialize_toolbars):
+ allocate the throbber when we make the toolbar
+
+ * src/nautilus-window.c: (nautilus_window_allow_stop):
+ tell the throbber to start and stop when page loading begins/ends. We piggy-back
+ off of the stop button.
+ * src/nautilus-window.h:
+ made the nautilus_window know about the throbber
+
2000-08-29 Mike Fleming <mfleming@eazel.com>
* src/nautilus-first-time-druid.c:
diff --git a/configure.in b/configure.in
index 2a55a0e4b..af7cf5e40 100644
--- a/configure.in
+++ b/configure.in
@@ -440,6 +440,7 @@ icons/arlo/Makefile
icons/arlo/sidebar_tab_pieces/Makefile
icons/arlo/backgrounds/Makefile
icons/eazel/Makefile
+icons/throbber/Makefile
icons/vector/Makefile
data/Makefile
data/top/Makefile
diff --git a/icons/Makefile.am b/icons/Makefile.am
index 8bad15339..405a1699e 100644
--- a/icons/Makefile.am
+++ b/icons/Makefile.am
@@ -1,6 +1,6 @@
NULL=
-SUBDIRS = arlo eazel vector
+SUBDIRS = arlo eazel vector throbber
icondir = $(datadir)/pixmaps/nautilus
diff --git a/icons/throbber/.cvsignore b/icons/throbber/.cvsignore
new file mode 100644
index 000000000..282522db0
--- /dev/null
+++ b/icons/throbber/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/icons/throbber/001.png b/icons/throbber/001.png
new file mode 100644
index 000000000..983dd96ab
--- /dev/null
+++ b/icons/throbber/001.png
Binary files differ
diff --git a/icons/throbber/002.png b/icons/throbber/002.png
new file mode 100644
index 000000000..4893c2cef
--- /dev/null
+++ b/icons/throbber/002.png
Binary files differ
diff --git a/icons/throbber/003.png b/icons/throbber/003.png
new file mode 100644
index 000000000..74ae652f3
--- /dev/null
+++ b/icons/throbber/003.png
Binary files differ
diff --git a/icons/throbber/004.png b/icons/throbber/004.png
new file mode 100644
index 000000000..4fb64f3f2
--- /dev/null
+++ b/icons/throbber/004.png
Binary files differ
diff --git a/icons/throbber/005.png b/icons/throbber/005.png
new file mode 100644
index 000000000..6e94eec1c
--- /dev/null
+++ b/icons/throbber/005.png
Binary files differ
diff --git a/icons/throbber/006.png b/icons/throbber/006.png
new file mode 100644
index 000000000..dfe184e07
--- /dev/null
+++ b/icons/throbber/006.png
Binary files differ
diff --git a/icons/throbber/007.png b/icons/throbber/007.png
new file mode 100644
index 000000000..8ad45c77c
--- /dev/null
+++ b/icons/throbber/007.png
Binary files differ
diff --git a/icons/throbber/008.png b/icons/throbber/008.png
new file mode 100644
index 000000000..84fc597fb
--- /dev/null
+++ b/icons/throbber/008.png
Binary files differ
diff --git a/icons/throbber/009.png b/icons/throbber/009.png
new file mode 100644
index 000000000..dcf773154
--- /dev/null
+++ b/icons/throbber/009.png
Binary files differ
diff --git a/icons/throbber/010.png b/icons/throbber/010.png
new file mode 100644
index 000000000..9c30fadf7
--- /dev/null
+++ b/icons/throbber/010.png
Binary files differ
diff --git a/icons/throbber/Makefile.am b/icons/throbber/Makefile.am
new file mode 100644
index 000000000..4beff4cb9
--- /dev/null
+++ b/icons/throbber/Makefile.am
@@ -0,0 +1,19 @@
+NULL=
+
+throbberdir = $(datadir)/pixmaps/nautilus/throbber
+
+throbber_DATA = \
+ 001.png \
+ 002.png \
+ 003.png \
+ 004.png \
+ 005.png \
+ 006.png \
+ 007.png \
+ 008.png \
+ 009.png \
+ 010.png \
+ rest.png \
+ $(NULL)
+
+EXTRA_DIST = $(throbber_DATA)
diff --git a/icons/throbber/rest.png b/icons/throbber/rest.png
new file mode 100644
index 000000000..f80d03b73
--- /dev/null
+++ b/icons/throbber/rest.png
Binary files differ
diff --git a/src/Makefile.am b/src/Makefile.am
index 6c5a79475..80a4918d8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -69,6 +69,7 @@ noinst_HEADERS = \
nautilus-switchable-navigation-bar.h \
nautilus-switchable-search-bar.h \
nautilus-theme-selector.h \
+ nautilus-throbber.h \
nautilus-toolbar.h \
nautilus-view-frame-private.h \
nautilus-view-frame.h \
@@ -105,6 +106,7 @@ nautilus_SOURCES = \
nautilus-switchable-navigation-bar.c \
nautilus-switchable-search-bar.c \
nautilus-theme-selector.c \
+ nautilus-throbber.c \
nautilus-toolbar.c \
nautilus-view-frame-bonobo-control.c \
nautilus-view-frame-bonobo-embeddable.c \
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index 03671114e..f68915e48 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -35,6 +35,7 @@
#include "nautilus-sidebar.h"
#include "nautilus-signaller.h"
#include "nautilus-switchable-navigation-bar.h"
+#include "nautilus-throbber.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-zoom-control.h"
#include <ctype.h>
@@ -1063,6 +1064,14 @@ void
nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive (window->stop_button, allow);
+ if (window->throbber == NULL)
+ return;
+
+ if (allow) {
+ nautilus_throbber_start (NAUTILUS_THROBBER (window->throbber));
+ } else {
+ nautilus_throbber_stop (NAUTILUS_THROBBER (window->throbber));
+ }
}
void
diff --git a/src/nautilus-navigation-window.h b/src/nautilus-navigation-window.h
index 55e1bcc35..783f4b5e3 100644
--- a/src/nautilus-navigation-window.h
+++ b/src/nautilus-navigation-window.h
@@ -114,7 +114,8 @@ struct NautilusWindow {
GtkWidget *home_button;
GtkWidget *zoom_control;
-
+ GtkWidget *throbber;
+
/* Pending changes */
NautilusNavigationInfo *pending_ni;
NautilusViewFrame *new_content_view, *new_requesting_view;
diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c
index 03671114e..f68915e48 100644
--- a/src/nautilus-object-window.c
+++ b/src/nautilus-object-window.c
@@ -35,6 +35,7 @@
#include "nautilus-sidebar.h"
#include "nautilus-signaller.h"
#include "nautilus-switchable-navigation-bar.h"
+#include "nautilus-throbber.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-zoom-control.h"
#include <ctype.h>
@@ -1063,6 +1064,14 @@ void
nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive (window->stop_button, allow);
+ if (window->throbber == NULL)
+ return;
+
+ if (allow) {
+ nautilus_throbber_start (NAUTILUS_THROBBER (window->throbber));
+ } else {
+ nautilus_throbber_stop (NAUTILUS_THROBBER (window->throbber));
+ }
}
void
diff --git a/src/nautilus-object-window.h b/src/nautilus-object-window.h
index 55e1bcc35..783f4b5e3 100644
--- a/src/nautilus-object-window.h
+++ b/src/nautilus-object-window.h
@@ -114,7 +114,8 @@ struct NautilusWindow {
GtkWidget *home_button;
GtkWidget *zoom_control;
-
+ GtkWidget *throbber;
+
/* Pending changes */
NautilusNavigationInfo *pending_ni;
NautilusViewFrame *new_content_view, *new_requesting_view;
diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c
index 03671114e..f68915e48 100644
--- a/src/nautilus-spatial-window.c
+++ b/src/nautilus-spatial-window.c
@@ -35,6 +35,7 @@
#include "nautilus-sidebar.h"
#include "nautilus-signaller.h"
#include "nautilus-switchable-navigation-bar.h"
+#include "nautilus-throbber.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-zoom-control.h"
#include <ctype.h>
@@ -1063,6 +1064,14 @@ void
nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive (window->stop_button, allow);
+ if (window->throbber == NULL)
+ return;
+
+ if (allow) {
+ nautilus_throbber_start (NAUTILUS_THROBBER (window->throbber));
+ } else {
+ nautilus_throbber_stop (NAUTILUS_THROBBER (window->throbber));
+ }
}
void
diff --git a/src/nautilus-spatial-window.h b/src/nautilus-spatial-window.h
index 55e1bcc35..783f4b5e3 100644
--- a/src/nautilus-spatial-window.h
+++ b/src/nautilus-spatial-window.h
@@ -114,7 +114,8 @@ struct NautilusWindow {
GtkWidget *home_button;
GtkWidget *zoom_control;
-
+ GtkWidget *throbber;
+
/* Pending changes */
NautilusNavigationInfo *pending_ni;
NautilusViewFrame *new_content_view, *new_requesting_view;
diff --git a/src/nautilus-throbber.c b/src/nautilus-throbber.c
new file mode 100644
index 000000000..ee9a194af
--- /dev/null
+++ b/src/nautilus-throbber.c
@@ -0,0 +1,390 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/*
+ * Nautilus
+ *
+ * Copyright (C) 2000 Eazel, Inc.
+ *
+ * Nautilus 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.
+ *
+ * Nautilus 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: Andy Hertzfeld <andy@eazel.com>
+ *
+ * This is the throbber (for busy feedback) for the location bar
+ *
+ */
+
+#include <config.h>
+#include "nautilus-throbber.h"
+
+#include <libgnome/gnome-defs.h>
+
+#include <math.h>
+#include <gnome.h>
+#include <gdk/gdk.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gtk/gtksignal.h>
+#include <gtk/gtkmenu.h>
+#include <gtk/gtkmenuitem.h>
+#include <libgnome/gnome-util.h>
+#include <libgnomeui/gnome-pixmap.h>
+#include <libnautilus-extensions/nautilus-gtk-macros.h>
+#include <libnautilus-extensions/nautilus-gtk-extensions.h>
+#include <libnautilus-extensions/nautilus-glib-extensions.h>
+#include <libnautilus-extensions/nautilus-global-preferences.h>
+#include <libnautilus-extensions/nautilus-icon-factory.h>
+#include <libnautilus-extensions/nautilus-file-utilities.h>
+#include <libnautilus-extensions/nautilus-theme.h>
+
+struct NautilusThrobberDetails {
+ GList *image_list;
+
+ GdkPixbuf *quiescent_pixbuf;
+
+ int max_frame;
+ int current_frame;
+ int last_frame_time;
+ int frame_time_increment;
+
+ int timer_task;
+};
+
+static void nautilus_throbber_initialize_class (NautilusThrobberClass *klass);
+static void nautilus_throbber_initialize (NautilusThrobber *throbber);
+static void nautilus_throbber_destroy (GtkObject *object);
+static void nautilus_throbber_draw (GtkWidget *widget,
+ GdkRectangle *box);
+static int nautilus_throbber_expose (GtkWidget *widget,
+ GdkEventExpose *event);
+static gboolean nautilus_throbber_button_press_event (GtkWidget *widget,
+ GdkEventButton *event);
+static void nautilus_throbber_load_images (NautilusThrobber *throbber);
+static void nautilus_throbber_unload_images (NautilusThrobber *throbber);
+static void nautilus_throbber_theme_changed (gpointer user_data);
+static void nautilus_throbber_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
+
+NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusThrobber, nautilus_throbber, GTK_TYPE_EVENT_BOX)
+
+static void
+nautilus_throbber_initialize_class (NautilusThrobberClass *throbber_class)
+{
+ GtkObjectClass *object_class = GTK_OBJECT_CLASS (throbber_class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (throbber_class);
+
+ object_class->destroy = nautilus_throbber_destroy;
+
+ widget_class->draw = nautilus_throbber_draw;
+ widget_class->expose_event = nautilus_throbber_expose;
+ widget_class->button_press_event = nautilus_throbber_button_press_event;
+ widget_class->size_allocate = nautilus_throbber_size_allocate;
+}
+
+static void
+nautilus_throbber_destroy (GtkObject *object)
+{
+ nautilus_throbber_unload_images (NAUTILUS_THROBBER (object));
+
+ nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME,
+ nautilus_throbber_theme_changed,
+ object);
+
+ g_free (NAUTILUS_THROBBER (object)->details);
+
+ NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
+}
+
+/* loop through all the images taking their union to compute the width and height of the throbber */
+static void
+get_throbber_dimensions (NautilusThrobber *throbber, int *throbber_width, int* throbber_height)
+{
+ int current_width, current_height;
+
+ /* start with the quiescent image */
+ current_width = gdk_pixbuf_get_width (throbber->details->quiescent_pixbuf);
+ current_height = gdk_pixbuf_get_height (throbber->details->quiescent_pixbuf);
+
+ /* loop through all the installed images, taking the union */
+
+ /* return the result */
+ *throbber_width = current_width;
+ *throbber_height = current_height;
+}
+
+/* initialize the throbber */
+static void
+nautilus_throbber_initialize (NautilusThrobber *throbber)
+{
+ GtkWidget *widget = GTK_WIDGET (throbber);
+ int throbber_width, throbber_height;
+
+ GTK_WIDGET_UNSET_FLAGS (throbber, GTK_NO_WINDOW);
+
+ gtk_widget_set_events (widget,
+ gtk_widget_get_events (widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
+
+ throbber->details = g_new0 (NautilusThrobberDetails, 1);
+
+ /* set up the instance variables to appropriate defaults */
+ throbber->details->frame_time_increment = 100;
+ throbber->details->timer_task = -1;
+
+ /* allocate the pixmap that holds the image */
+ nautilus_throbber_load_images (throbber);
+
+ get_throbber_dimensions (throbber, &throbber_width, &throbber_height);
+ gtk_widget_set_usize (GTK_WIDGET (throbber), throbber_width, throbber_height);
+
+ /* add a callback for when the theme changes */
+ nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_THEME,
+ nautilus_throbber_theme_changed,
+ throbber);
+
+}
+
+/* allocate a new throbber */
+GtkWidget*
+nautilus_throbber_new ()
+{
+ NautilusThrobber *throbber = gtk_type_new (nautilus_throbber_get_type ());
+ return GTK_WIDGET (throbber);
+}
+
+/* handler for handling theme changes */
+static void
+nautilus_throbber_theme_changed (gpointer user_data)
+{
+ NautilusThrobber *throbber;
+
+ throbber = NAUTILUS_THROBBER (user_data);
+ gtk_widget_hide (GTK_WIDGET (throbber));
+ nautilus_throbber_load_images (throbber);
+ gtk_widget_show (GTK_WIDGET (throbber));
+}
+
+
+/* utility to simplify drawing */
+static void
+draw_pixbuf (GdkPixbuf *pixbuf, GdkDrawable *drawable, int x, int y)
+{
+ gdk_pixbuf_render_to_drawable_alpha (pixbuf, drawable, 0, 0, x, y,
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf),
+ GDK_PIXBUF_ALPHA_BILEVEL, 128, GDK_RGB_DITHER_MAX,
+ 0, 0);
+}
+
+/* here's the routine that selects the image to draw, based on the throbber's state */
+
+static GdkPixbuf *
+select_throbber_image (NautilusThrobber *throbber)
+{
+ GList *element;
+
+ if (throbber->details->timer_task == -1)
+ return throbber->details->quiescent_pixbuf;
+
+ if (throbber->details->image_list == NULL)
+ return NULL;
+
+ element = g_list_nth (throbber->details->image_list, throbber->details->current_frame);
+
+ return (GdkPixbuf*) element->data;
+}
+
+/* draw the throbber into the passed-in rectangle */
+
+static void
+draw_throbber_image (GtkWidget *widget, GdkRectangle *box)
+{
+ NautilusThrobber *throbber;
+ GdkPixbuf *pixbuf;
+
+ throbber = NAUTILUS_THROBBER (widget);
+
+ pixbuf = select_throbber_image (throbber);
+
+ draw_pixbuf (pixbuf, widget->window, box->x, box->y);
+}
+
+static void
+nautilus_throbber_draw (GtkWidget *widget, GdkRectangle *box)
+{
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (NAUTILUS_IS_THROBBER (widget));
+
+ draw_throbber_image (widget, box);
+}
+
+/* handle expose events */
+
+static int
+nautilus_throbber_expose (GtkWidget *widget, GdkEventExpose *event)
+{
+ GdkRectangle box;
+ g_return_val_if_fail (widget != NULL, FALSE);
+ g_return_val_if_fail (NAUTILUS_IS_THROBBER (widget), FALSE);
+
+ box.x = 0; box.y = 0;
+ box.width = widget->allocation.width;
+ box.height = widget->allocation.height;
+
+ draw_throbber_image (widget, &box);
+
+ return FALSE;
+}
+
+/* here's the actual timeout task to bump the frame and schedule a redraw */
+
+static int
+bump_throbber_frame (NautilusThrobber *throbber)
+{
+ throbber->details->current_frame += 1;
+ if (throbber->details->current_frame > throbber->details->max_frame) {
+ throbber->details->current_frame = 0;
+ }
+
+ gtk_widget_queue_draw (GTK_WIDGET (throbber));
+ return TRUE;
+}
+
+
+/* routines to start and stop the throbber */
+
+void
+nautilus_throbber_start (NautilusThrobber *throbber)
+{
+ if (throbber->details->timer_task != -1)
+ gtk_timeout_remove(throbber->details->timer_task);
+
+ throbber->details->timer_task = gtk_timeout_add (100, (GtkFunction) bump_throbber_frame, throbber);
+}
+
+void
+nautilus_throbber_stop (NautilusThrobber *throbber)
+{
+ if (throbber->details->timer_task != -1)
+ gtk_timeout_remove(throbber->details->timer_task);
+
+ throbber->details->timer_task = -1;
+ gtk_widget_queue_draw (GTK_WIDGET (throbber));
+
+}
+
+/* routines to load the images used to draw the control */
+
+/* unload all the images, and the list itself */
+
+static void
+nautilus_throbber_unload_images (NautilusThrobber *throbber)
+{
+ GList *current_entry;
+
+ if (throbber->details->quiescent_pixbuf != NULL) {
+ gdk_pixbuf_unref (throbber->details->quiescent_pixbuf);
+ throbber->details->quiescent_pixbuf = NULL;
+ }
+
+ /* unref all the images in the list, and then let go of the list itself */
+ current_entry = throbber->details->image_list;
+ while (current_entry != NULL) {
+ gdk_pixbuf_unref ((GdkPixbuf*) current_entry->data);
+ current_entry = current_entry->next;
+ }
+
+ g_list_free (throbber->details->image_list);
+ throbber->details->image_list = NULL;
+}
+
+static GdkPixbuf*
+load_themed_image (const char *file_name)
+{
+ GdkPixbuf *pixbuf;
+ char *image_path;
+
+ image_path = nautilus_theme_get_image_path (file_name);
+ if (image_path) {
+ pixbuf = gdk_pixbuf_new_from_file (image_path);
+ g_free (image_path);
+ return pixbuf;
+ }
+ return NULL;
+}
+
+/* utility to make the throbber frame name from the index */
+
+static char *
+make_throbber_frame_name (int index)
+{
+ return g_strdup_printf ("throbber/%03d.png", index);
+}
+
+/* load all of the images of the throbber sequentially */
+static void
+nautilus_throbber_load_images (NautilusThrobber *throbber)
+{
+ int index;
+ char *throbber_frame_name;
+ GdkPixbuf *pixbuf;
+
+ nautilus_throbber_unload_images (throbber);
+
+ throbber->details->quiescent_pixbuf = load_themed_image ("throbber/rest.png");
+ /* images are of the form throbber/001.png, 002.png, etc, so load them into a list
+ * until we get an error.
+ */
+ throbber->details->max_frame = -1;
+ index = 1;
+ while (TRUE) {
+ throbber_frame_name = make_throbber_frame_name (index);
+ pixbuf = load_themed_image (throbber_frame_name);
+ if (pixbuf != NULL)
+ g_message ("loaded %s!", throbber_frame_name);
+ g_free (throbber_frame_name);
+ if (pixbuf == NULL)
+ break;
+
+ throbber->details->image_list = g_list_prepend (throbber->details->image_list, pixbuf);
+ index += 1;
+ throbber->details->max_frame += 1;
+ }
+
+}
+
+/* handle button presses */
+
+static gboolean
+nautilus_throbber_button_press_event (GtkWidget *widget, GdkEventButton *event)
+{
+ /*
+ NautilusThrobber *throbber = NAUTILUS_THROBBER (widget);
+ */
+ g_message ("clicked!");
+ return TRUE;
+}
+
+/* handle setting the size */
+static void
+nautilus_throbber_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
+{
+ int throbber_width, throbber_height;
+ NautilusThrobber *throbber = NAUTILUS_THROBBER (widget);
+
+ NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, size_allocate, (widget, allocation));
+
+ get_throbber_dimensions (throbber, &throbber_width, &throbber_height);
+
+ widget->allocation.width = throbber_width;
+ widget->allocation.height = throbber_height;
+}
+
diff --git a/src/nautilus-throbber.h b/src/nautilus-throbber.h
new file mode 100644
index 000000000..d4d6669f3
--- /dev/null
+++ b/src/nautilus-throbber.h
@@ -0,0 +1,67 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/*
+ * Nautilus
+ *
+ * Copyright (C) 2000 Eazel, Inc.
+ *
+ * Nautilus 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.
+ *
+ * Nautilus 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: Andy Hertzfeld <andy@eazel.com>
+ *
+ * This is the header file for the throbber on the location bar
+ *
+ */
+
+#ifndef NAUTILUS_THROBBER_H
+#define NAUTILUS_THROBBER_H
+
+#include <gdk/gdk.h>
+#include <gtk/gtkeventbox.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define NAUTILUS_TYPE_THROBBER (nautilus_throbber_get_type ())
+#define NAUTILUS_THROBBER(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_THROBBER, NautilusThrobber))
+#define NAUTILUS_THROBBER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_THROBBER, NautilusThrobberClass))
+#define NAUTILUS_IS_THROBBER(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_THROBBER))
+#define NAUTILUS_IS_THROBBER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_THROBBER))
+
+typedef struct NautilusThrobber NautilusThrobber;
+typedef struct NautilusThrobberClass NautilusThrobberClass;
+typedef struct NautilusThrobberDetails NautilusThrobberDetails;
+
+struct NautilusThrobber {
+ GtkEventBox parent;
+ NautilusThrobberDetails *details;
+};
+
+struct NautilusThrobberClass {
+ GtkEventBoxClass parent_class;
+};
+
+GtkType nautilus_throbber_get_type (void);
+GtkWidget * nautilus_throbber_new (void);
+
+void nautilus_throbber_start (NautilusThrobber *throbber);
+void nautilus_throbber_stop (NautilusThrobber *throbber);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* NAUTILUS_THROBBER_H */
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 3bee0c81f..896be8abc 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -77,6 +77,10 @@ nautilus_toolbar_set_button_spacing (NautilusToolbar *toolbar, int spacing)
toolbar->button_spacing = spacing;
}
+void nautilus_toolbar_set_throbber (NautilusToolbar *bar, GtkWidget *new_throbber)
+{
+ bar->throbber = new_throbber;
+}
static void
nautilus_toolbar_size_allocate (GtkWidget *widget,
@@ -161,6 +165,7 @@ nautilus_toolbar_size_allocate (GtkWidget *widget,
else
alloc.x = allocation->x + (allocation->width - width_to_use) / 2;
+
gtk_widget_size_allocate (child->widget, &alloc);
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
@@ -184,6 +189,12 @@ nautilus_toolbar_size_allocate (GtkWidget *widget,
else
alloc.x = allocation->x + (allocation->width - child_requisition.width) / 2;
+ /* special case the throbber, so it's positioned at the far right */
+
+ if (child->widget == nautilus_toolbar->throbber) {
+ alloc.x = widget->allocation.width - alloc.width;
+ }
+
gtk_widget_size_allocate (child->widget, &alloc);
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
diff --git a/src/nautilus-toolbar.h b/src/nautilus-toolbar.h
index f1fc65de2..6a569db24 100644
--- a/src/nautilus-toolbar.h
+++ b/src/nautilus-toolbar.h
@@ -41,6 +41,7 @@
typedef struct NautilusToolbar {
GtkToolbar parent;
int button_spacing;
+ GtkWidget *throbber;
} NautilusToolbar;
typedef struct {
@@ -50,5 +51,5 @@ typedef struct {
GtkType nautilus_toolbar_get_type (void);
GtkWidget* nautilus_toolbar_new (void);
void nautilus_toolbar_set_button_spacing (NautilusToolbar *toolbar, int spacing);
-
+void nautilus_toolbar_set_throbber (NautilusToolbar *toolbar, GtkWidget *throbber);
#endif /* NAUTILUS_TOOLBAR_H */
diff --git a/src/nautilus-window-toolbars.c b/src/nautilus-window-toolbars.c
index c1fc8987c..3260faa08 100644
--- a/src/nautilus-window-toolbars.c
+++ b/src/nautilus-window-toolbars.c
@@ -29,6 +29,7 @@
#include <config.h>
#include "nautilus-application.h"
+#include "nautilus-throbber.h"
#include "nautilus-toolbar.h"
#include "nautilus-window-private.h"
#include "nautilus-window.h"
@@ -329,6 +330,18 @@ set_up_toolbar_images (NautilusWindow *window)
g_free(theme_name);
}
+static GtkWidget*
+allocate_throbber (GtkWidget *toolbar)
+{
+ GtkWidget *throbber;
+
+ throbber = nautilus_throbber_new ();
+ gtk_widget_show (throbber);
+ gtk_toolbar_append_widget (GTK_TOOLBAR (toolbar), throbber, NULL, NULL);
+ nautilus_toolbar_set_throbber (NAUTILUS_TOOLBAR (toolbar), throbber);
+ return throbber;
+}
+
static void
set_up_toolbar_images_callback (gpointer callback_data)
{
@@ -349,8 +362,10 @@ nautilus_window_initialize_toolbars (NautilusWindow *window)
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH);
nautilus_toolbar_set_button_spacing (NAUTILUS_TOOLBAR (toolbar), 50);
- gnome_app_fill_toolbar_with_data (GTK_TOOLBAR (toolbar), toolbar_info, app->accel_group, app);
+ gnome_app_fill_toolbar_with_data (GTK_TOOLBAR (toolbar), toolbar_info, app->accel_group, app);
remember_buttons(window, toolbar_info);
+ window->throbber = allocate_throbber (toolbar);
+
set_up_toolbar_images (window);
gnome_app_set_toolbar (app, GTK_TOOLBAR (toolbar));
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 03671114e..f68915e48 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -35,6 +35,7 @@
#include "nautilus-sidebar.h"
#include "nautilus-signaller.h"
#include "nautilus-switchable-navigation-bar.h"
+#include "nautilus-throbber.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-zoom-control.h"
#include <ctype.h>
@@ -1063,6 +1064,14 @@ void
nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
{
gtk_widget_set_sensitive (window->stop_button, allow);
+ if (window->throbber == NULL)
+ return;
+
+ if (allow) {
+ nautilus_throbber_start (NAUTILUS_THROBBER (window->throbber));
+ } else {
+ nautilus_throbber_stop (NAUTILUS_THROBBER (window->throbber));
+ }
}
void
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index 55e1bcc35..783f4b5e3 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -114,7 +114,8 @@ struct NautilusWindow {
GtkWidget *home_button;
GtkWidget *zoom_control;
-
+ GtkWidget *throbber;
+
/* Pending changes */
NautilusNavigationInfo *pending_ni;
NautilusViewFrame *new_content_view, *new_requesting_view;