aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--data/art/Makefile.am1
-rw-r--r--data/art/epiphany-tab-loading.gifbin825 -> 0 bytes
-rw-r--r--lib/widgets/ephy-spinner.c97
-rw-r--r--lib/widgets/ephy-spinner.h5
-rw-r--r--src/ephy-notebook.c47
-rwxr-xr-xsrc/toolbar.c43
7 files changed, 111 insertions, 96 deletions
diff --git a/ChangeLog b/ChangeLog
index e9a0f3d12..1575369ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2004-07-02 Christian Persch <chpe@cvs.gnome.org>
+
+ * data/art/Makefile.am:
+ R data/art/epiphany-tab-loading.gif:
+ * lib/widgets/ephy-spinner.c: (get_spinner_dimensions),
+ (ephy_spinner_init), (ephy_spinner_expose),
+ (ephy_spinner_unload_images), (scale_to_real_size),
+ (ephy_spinner_set_size), (ephy_spinner_size_request):
+ * lib/widgets/ephy-spinner.h:
+ * src/ephy-notebook.c: (sync_load_status), (build_tab_label):
+ * src/toolbar.c: (fixed_toolbar_reconfigured_cb), (toolbar_init):
+
+ Remove our tab loading animation and use mini-spinners instead.
+
2004-07-02 Marco Pesenti Gritti <marco@gnome.org>
* src/bookmarks/ephy-bookmark-action.c:
diff --git a/data/art/Makefile.am b/data/art/Makefile.am
index 4960dae23..cc27b7231 100644
--- a/data/art/Makefile.am
+++ b/data/art/Makefile.am
@@ -6,7 +6,6 @@ art_DATA = \
epiphany-history.png \
epiphany-popup-hidden.png \
epiphany-bookmarks.png \
- epiphany-tab-loading.gif \
hand-open.png
appicon_DATA = epiphany-bookmarks.png
diff --git a/data/art/epiphany-tab-loading.gif b/data/art/epiphany-tab-loading.gif
deleted file mode 100644
index cce32f20f..000000000
--- a/data/art/epiphany-tab-loading.gif
+++ /dev/null
Binary files differ
diff --git a/lib/widgets/ephy-spinner.c b/lib/widgets/ephy-spinner.c
index 7467b85cb..0bee4488f 100644
--- a/lib/widgets/ephy-spinner.c
+++ b/lib/widgets/ephy-spinner.c
@@ -2,7 +2,8 @@
* Nautilus
*
* Copyright (C) 2000 Eazel, Inc.
- * Copyright (C) 2002 Marco Pesenti Gritti
+ * Copyright (C) 2002-2004 Marco Pesenti Gritti
+ * Copyright (C) 2004 Christian Persch
*
* Nautilus is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,6 +36,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtkicontheme.h>
+#include <gtk/gtkiconfactory.h>
#define spinner_DEFAULT_TIMEOUT 100 /* Milliseconds Per Frame */
@@ -45,14 +47,12 @@ struct EphySpinnerDetails
GList *image_list;
GdkPixbuf *quiescent_pixbuf;
GtkIconTheme *icon_theme;
+ GtkIconSize size;
int max_frame;
int delay;
int current_frame;
guint timer_task;
-
- gboolean ready;
- gboolean small_mode;
};
static void ephy_spinner_class_init (EphySpinnerClass *class);
@@ -125,6 +125,11 @@ get_spinner_dimensions (EphySpinner *spinner, int *spinner_width, int* spinner_h
GList *image_list;
GdkPixbuf *pixbuf;
+ if (spinner->details->image_list == NULL)
+ {
+ ephy_spinner_load_images (spinner);
+ }
+
current_width = 0;
current_height = 0;
@@ -186,9 +191,7 @@ ephy_spinner_init (EphySpinner *spinner)
spinner->details->max_frame = 0;
spinner->details->current_frame = 0;
spinner->details->timer_task = 0;
-
- ephy_spinner_load_images (spinner);
- gtk_widget_show (widget);
+ spinner->details->size = GTK_ICON_SIZE_INVALID;
}
/* handler for handling theme changes */
@@ -236,18 +239,19 @@ select_spinner_image (EphySpinner *spinner)
static int
ephy_spinner_expose (GtkWidget *widget, GdkEventExpose *event)
{
- EphySpinner *spinner;
+ EphySpinner *spinner = EPHY_SPINNER (widget);
GdkPixbuf *pixbuf;
GdkGC *gc;
int x_offset, y_offset, width, height;
GdkRectangle pix_area, dest;
- g_return_val_if_fail (EPHY_IS_SPINNER (widget), FALSE);
-
- spinner = EPHY_SPINNER (widget);
-
if (!GTK_WIDGET_DRAWABLE (spinner)) return TRUE;
+ if (spinner->details->image_list == NULL)
+ {
+ ephy_spinner_load_images (spinner);
+ }
+
pixbuf = select_spinner_image (spinner);
if (pixbuf == NULL)
{
@@ -373,8 +377,6 @@ ephy_spinner_stop (EphySpinner *spinner)
static void
ephy_spinner_unload_images (EphySpinner *spinner)
{
- GList *current_entry;
-
if (spinner->details->quiescent_pixbuf != NULL)
{
g_object_unref (spinner->details->quiescent_pixbuf);
@@ -382,13 +384,7 @@ ephy_spinner_unload_images (EphySpinner *spinner)
}
/* unref all the images in the list, and then let go of the list itself */
- current_entry = spinner->details->image_list;
- while (current_entry != NULL)
- {
- g_object_unref (current_entry->data);
- current_entry = current_entry->next;
- }
-
+ g_list_foreach (spinner->details->image_list, (GFunc) g_object_unref, NULL);
g_list_free (spinner->details->image_list);
spinner->details->image_list = NULL;
@@ -399,15 +395,24 @@ static GdkPixbuf *
scale_to_real_size (EphySpinner *spinner, GdkPixbuf *pixbuf)
{
GdkPixbuf *result;
- int size;
+ int sw, sh, pw, ph;
+
+ if (spinner->details->size == GTK_ICON_SIZE_INVALID)
+ {
+ return g_object_ref (pixbuf);
+ }
- size = gdk_pixbuf_get_height (pixbuf);
+ if (!gtk_icon_size_lookup (spinner->details->size, &sw, &sh))
+ {
+ return NULL;
+ }
- if (spinner->details->small_mode)
+ pw = gdk_pixbuf_get_width (pixbuf);
+ ph = gdk_pixbuf_get_height (pixbuf);
+
+ if (pw != sw || ph != sh)
{
- result = gdk_pixbuf_scale_simple (pixbuf,
- size * 2 / 3,
- size * 2 / 3,
+ result = gdk_pixbuf_scale_simple (pixbuf, sw, sh,
GDK_INTERP_BILINEAR);
}
else
@@ -513,20 +518,21 @@ ephy_spinner_load_images (EphySpinner *spinner)
}
/*
- * ephy_spinner_set_small_mode:
+ * ephy_spinner_set_size:
* @spinner: a #EphySpinner
- * @new_mode: pass true to enable the small mode, false to disable
+ * @size: the size of type %GtkIconSize
*
- * Set the size mode of the spinner. We need a small mode to deal
- * with only icons toolbars.
+ * Set the size of the spinner. Use %GTK_ICON_SIZE_INVALID to use the
+ * native size of the icon.
**/
void
-ephy_spinner_set_small_mode (EphySpinner *spinner, gboolean new_mode)
+ephy_spinner_set_size (EphySpinner *spinner, GtkIconSize size)
{
- if (new_mode != spinner->details->small_mode)
+ if (size != spinner->details->size)
{
- spinner->details->small_mode = new_mode;
- ephy_spinner_load_images (spinner);
+ ephy_spinner_unload_images (spinner);
+
+ spinner->details->size = size;
gtk_widget_queue_resize (GTK_WIDGET (spinner));
}
@@ -537,14 +543,27 @@ ephy_spinner_set_small_mode (EphySpinner *spinner, gboolean new_mode)
static void
ephy_spinner_size_request (GtkWidget *widget, GtkRequisition *requisition)
{
- int spinner_width, spinner_height;
EphySpinner *spinner = EPHY_SPINNER (widget);
+ int width = 0, height = 0;
- get_spinner_dimensions (spinner, &spinner_width, &spinner_height);
+ if (spinner->details->size == GTK_ICON_SIZE_INVALID)
+ {
+ get_spinner_dimensions (spinner, &width, &height);
+ }
+ else
+ {
+ gtk_icon_size_lookup (spinner->details->size, &width, &height);
+ }
+
+ requisition->width = width;
+ requisition->height = height;
/* allocate some extra margin so we don't butt up against toolbar edges */
- requisition->width = spinner_width + 4;
- requisition->height = spinner_height + 4;
+ if (spinner->details->size != GTK_ICON_SIZE_MENU)
+ {
+ requisition->width += 4;
+ requisition->height += 4;
+ }
}
static void
diff --git a/lib/widgets/ephy-spinner.h b/lib/widgets/ephy-spinner.h
index a2d0ad3a5..98e55dafd 100644
--- a/lib/widgets/ephy-spinner.h
+++ b/lib/widgets/ephy-spinner.h
@@ -30,6 +30,7 @@
#define EPHY_SPINNER_H
#include <gtk/gtkeventbox.h>
+#include <gtk/gtkenums.h>
G_BEGIN_DECLS
@@ -63,8 +64,8 @@ void ephy_spinner_start (EphySpinner *throbber);
void ephy_spinner_stop (EphySpinner *throbber);
-void ephy_spinner_set_small_mode (EphySpinner *spinner,
- gboolean new_mode);
+void ephy_spinner_set_size (EphySpinner *spinner,
+ GtkIconSize size);
G_END_DECLS
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index cbe261eb0..e09543f72 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -36,6 +36,7 @@
#include "ephy-debug.h"
#include "ephy-favicon-cache.h"
#include "ephy-ellipsizing-label.h"
+#include "ephy-spinner.h"
#include <glib-object.h>
#include <gtk/gtkeventbox.h>
@@ -727,22 +728,23 @@ ephy_notebook_finalize (GObject *object)
static void
sync_load_status (EphyTab *tab, GParamSpec *pspec, GtkWidget *proxy)
{
- GtkWidget *animation = NULL, *icon = NULL;
+ GtkWidget *spinner, *icon;
- animation = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "loading-image"));
+ spinner = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "spinner"));
icon = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "icon"));
- g_return_if_fail (animation != NULL && icon != NULL);
+ g_return_if_fail (spinner != NULL && icon != NULL);
- switch (ephy_tab_get_load_status (tab))
+ if (ephy_tab_get_load_status (tab))
{
- case TRUE:
- gtk_widget_hide (icon);
- gtk_widget_show (animation);
- break;
- case FALSE:
- gtk_widget_hide (animation);
- gtk_widget_show (icon);
- break;
+ gtk_widget_hide (icon);
+ gtk_widget_show (spinner);
+ ephy_spinner_start (EPHY_SPINNER (spinner));
+ }
+ else
+ {
+ ephy_spinner_stop (EPHY_SPINNER (spinner));
+ gtk_widget_hide (spinner);
+ gtk_widget_show (icon);
}
}
@@ -841,12 +843,9 @@ tab_label_style_set_cb (GtkWidget *label,
static GtkWidget *
build_tab_label (EphyNotebook *nb, EphyTab *tab)
{
- GtkWidget *label, *hbox, *label_hbox, *close_button, *image;
- int h, w;
- GtkWidget *window;
- GtkWidget *loading_image, *icon;
- GtkWidget *label_ebox;
- GdkPixbufAnimation *loading_pixbuf;
+ GtkWidget *window, *hbox, *label_hbox, *label_ebox;
+ GtkWidget *label, *close_button, *image, *spinner, *icon;
+ int h = -1, w = -1;
window = gtk_widget_get_toplevel (GTK_WIDGET (nb));
@@ -877,12 +876,10 @@ build_tab_label (EphyNotebook *nb, EphyTab *tab)
G_CALLBACK (close_button_clicked_cb),
tab);
- /* setup load feedback image */
- /* FIXME: make the animation themeable */
- loading_pixbuf = gdk_pixbuf_animation_new_from_file (ephy_file ("epiphany-tab-loading.gif"), NULL);
- loading_image = gtk_image_new_from_animation (loading_pixbuf);
- g_object_unref (loading_pixbuf);
- gtk_box_pack_start (GTK_BOX (label_hbox), loading_image, FALSE, FALSE, 0);
+ /* setup load feedback */
+ spinner = ephy_spinner_new ();
+ ephy_spinner_set_size (EPHY_SPINNER (spinner), GTK_ICON_SIZE_MENU);
+ gtk_box_pack_start (GTK_BOX (label_hbox), spinner, FALSE, FALSE, 0);
/* setup site icon, empty by default */
icon = gtk_image_new ();
@@ -909,7 +906,7 @@ build_tab_label (EphyNotebook *nb, EphyTab *tab)
g_object_set_data (G_OBJECT (hbox), "label", label);
g_object_set_data (G_OBJECT (hbox), "label-ebox", label_ebox);
- g_object_set_data (G_OBJECT (hbox), "loading-image", loading_image);
+ g_object_set_data (G_OBJECT (hbox), "spinner", spinner);
g_object_set_data (G_OBJECT (hbox), "icon", icon);
g_object_set_data (G_OBJECT (hbox), "close-button", close_button);
g_object_set_data (G_OBJECT (hbox), "tooltips", nb->priv->title_tips);
diff --git a/src/toolbar.c b/src/toolbar.c
index 16981fb02..bcff8f91f 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -399,39 +399,24 @@ toolbar_set_window (Toolbar *t, EphyWindow *window)
}
static void
-toolbar_style_changed_cb (GtkToolbar *toolbar,
- GtkToolbarStyle style,
- GtkWidget *spinner)
+fixed_toolbar_reconfigured_cb (GtkToolItem *fixed_item,
+ EphySpinner *spinner)
{
- gboolean small;
+ GtkToolbarStyle style;
+ GtkIconSize size;
- small = (style != GTK_TOOLBAR_BOTH);
+ style = gtk_tool_item_get_toolbar_style (fixed_item);
- ephy_spinner_set_small_mode (EPHY_SPINNER (spinner), small);
-}
-
-static void
-parent_set_cb (GtkWidget *item,
- GtkObject *old_parent,
- GtkWidget *spinner)
-{
- if (old_parent != NULL)
+ if (style == GTK_TOOLBAR_BOTH)
{
- g_return_if_fail (GTK_IS_TOOLBAR (old_parent));
-
- g_signal_handlers_disconnect_by_func
- (old_parent, G_CALLBACK (toolbar_style_changed_cb),
- spinner);
+ size = GTK_ICON_SIZE_INVALID;
}
-
- if (item->parent)
+ else
{
- g_return_if_fail (GTK_IS_TOOLBAR (item->parent));
-
- g_signal_connect (item->parent, "style_changed",
- G_CALLBACK (toolbar_style_changed_cb),
- spinner);
+ size = GTK_ICON_SIZE_LARGE_TOOLBAR;
}
+
+ ephy_spinner_set_size (spinner, size);
}
static void
@@ -452,10 +437,10 @@ toolbar_init (Toolbar *t)
gtk_container_add (GTK_CONTAINER (item), spinner);
gtk_widget_show (GTK_WIDGET (item));
- g_signal_connect (item, "parent_set",
- G_CALLBACK (parent_set_cb), spinner);
-
egg_editable_toolbar_set_fixed (EGG_EDITABLE_TOOLBAR (t), item);
+
+ g_signal_connect (item, "toolbar-reconfigured",
+ G_CALLBACK (fixed_toolbar_reconfigured_cb), spinner);
}
static void