aboutsummaryrefslogtreecommitdiff
path: root/hildon
diff options
context:
space:
mode:
authorAlberto Garcia <agarcia@igalia.com>2009-05-18 18:05:51 +0200
committerAlberto Garcia <agarcia@igalia.com>2009-06-15 20:12:13 +0200
commite5dd13c992214bd9e6ca26071dcdfa8ce675dc0d (patch)
treead7b0aea03c7711ecd11f589b406909c620ddaef /hildon
parentdeb4d90f1e582d6efb892422a44ddda23c8802b0 (diff)
Add progress indicator to the HildonEditToolbar.
* hildon/Makefile.am * hildon/hildon-edit-toolbar-private.h * hildon/hildon-edit-toolbar.c (+hildon_edit_toolbar_set_progress_indicator) (hildon_edit_toolbar_init): Add progress indicator to the toolbar. * hildon/hildon-gtk.c (hildon_gtk_window_set_progress_indicator): If the window contains a HildonEditToolbar, enable the progress indicator there too. * hildon/hildon-private.h * hildon/hildon-private.c (+hildon_private_create_animation) * hildon/hildon-banner.c (-hildon_banner_create_animation): Moved to hildon-private.c Fixes: NB#102373 (Progress indicator also for the Edit mode toolbar)
Diffstat (limited to 'hildon')
-rw-r--r--hildon/Makefile.am1
-rw-r--r--hildon/hildon-banner.c47
-rw-r--r--hildon/hildon-edit-toolbar-private.h34
-rw-r--r--hildon/hildon-edit-toolbar.c43
-rw-r--r--hildon/hildon-gtk.c11
-rw-r--r--hildon/hildon-private.c44
-rw-r--r--hildon/hildon-private.h7
7 files changed, 138 insertions, 49 deletions
diff --git a/hildon/Makefile.am b/hildon/Makefile.am
index 849491c..1bb42a6 100644
--- a/hildon/Makefile.am
+++ b/hildon/Makefile.am
@@ -171,6 +171,7 @@ noinst_HEADERS = hildon-calendar-popup-private.h \
hildon-color-chooser-private.h \
hildon-controlbar-private.h \
hildon-date-editor-private.h \
+ hildon-edit-toolbar-private.h \
hildon-find-toolbar-private.h \
hildon-font-selection-dialog-private.h \
hildon-get-password-dialog-private.h \
diff --git a/hildon/hildon-banner.c b/hildon/hildon-banner.c
index 11b8ca8..9cfc7e8 100644
--- a/hildon/hildon-banner.c
+++ b/hildon/hildon-banner.c
@@ -84,6 +84,7 @@
#undef HILDON_DISABLE_DEPRECATED
#include "hildon-banner.h"
+#include "hildon-private.h"
#include "hildon-defines.h"
#include "hildon-gtk.h"
@@ -922,47 +923,6 @@ hildon_banner_get_instance_for_widget (GtkWidget *widget,
return g_object_new (HILDON_TYPE_BANNER, "parent-window", window, "is-timed", timed, NULL);
}
-static GtkWidget *
-hildon_banner_create_animation (void)
-{
- GtkWidget *image;
- GdkPixbufSimpleAnim *anim;
- GdkPixbuf *frame;
- GtkIconTheme *theme;
- GError *error = NULL;
- gchar *icon_name;
- gint i;
-
- anim = gdk_pixbuf_simple_anim_new (HILDON_ICON_PIXEL_SIZE_STYLUS,
- HILDON_ICON_PIXEL_SIZE_STYLUS,
- HILDON_BANNER_ANIMATION_FRAMERATE);
- gdk_pixbuf_simple_anim_set_loop (anim, TRUE);
- theme = gtk_icon_theme_get_default ();
-
- for (i = 1; i <= HILDON_BANNER_ANIMATION_NFRAMES; i++) {
- icon_name = g_strdup_printf (HILDON_BANNER_ANIMATION_TMPL, i);
- frame = gtk_icon_theme_load_icon (theme, icon_name, HILDON_ICON_PIXEL_SIZE_STYLUS,
- 0, &error);
-
- if (error) {
- g_warning ("Icon theme lookup for icon `%s' failed: %s",
- icon_name, error->message);
- g_error_free (error);
- error = NULL;
- } else {
- gdk_pixbuf_simple_anim_add_frame (anim, frame);
- }
-
- g_object_unref (frame);
- g_free (icon_name);
- }
-
- image = gtk_image_new_from_animation (GDK_PIXBUF_ANIMATION (anim));
- g_object_unref (anim);
-
- return image;
-}
-
/**
* hildon_banner_show_information:
* @widget: the #GtkWidget that is the owner of the banner
@@ -1171,7 +1131,10 @@ hildon_banner_show_animation (GtkWidget *widget,
g_return_val_if_fail (text != NULL, NULL);
- image_widget = hildon_banner_create_animation ();
+ image_widget = hildon_private_create_animation (
+ HILDON_BANNER_ANIMATION_FRAMERATE,
+ HILDON_BANNER_ANIMATION_TMPL,
+ HILDON_BANNER_ANIMATION_NFRAMES);
/* Prepare banner */
banner = hildon_banner_get_instance_for_widget (widget, FALSE);
diff --git a/hildon/hildon-edit-toolbar-private.h b/hildon/hildon-edit-toolbar-private.h
new file mode 100644
index 0000000..0021ddf
--- /dev/null
+++ b/hildon/hildon-edit-toolbar-private.h
@@ -0,0 +1,34 @@
+/*
+ * This file is a part of hildon
+ *
+ * Copyright (C) 2009 Nokia Corporation, all rights reserved.
+ *
+ * Contact: Rodrigo Novo <rodrigo.novo@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __HILDON_EDIT_TOOLBAR_PRIVATE_H__
+#define __HILDON_EDIT_TOOLBAR_PRIVATE_H__
+
+#include "hildon-edit-toolbar.h"
+
+void G_GNUC_INTERNAL
+hildon_edit_toolbar_set_progress_indicator (HildonEditToolbar *toolbar,
+ gboolean show);
+
+#endif /* __HILDON_EDIT_TOOLBAR_PRIVATE_H__ */
diff --git a/hildon/hildon-edit-toolbar.c b/hildon/hildon-edit-toolbar.c
index c288c71..9b8d910 100644
--- a/hildon/hildon-edit-toolbar.c
+++ b/hildon/hildon-edit-toolbar.c
@@ -59,6 +59,8 @@
*/
#include "hildon-edit-toolbar.h"
+#include "hildon-edit-toolbar-private.h"
+#include "hildon-private.h"
#include "hildon-gtk.h"
G_DEFINE_TYPE (HildonEditToolbar, hildon_edit_toolbar, GTK_TYPE_HBOX);
@@ -66,6 +68,10 @@ G_DEFINE_TYPE (HildonEditToolbar, hildon_edit_
#define TOOLBAR_LEFT_PADDING 24
#define TOOLBAR_RIGHT_PADDING 8
+#define HILDON_EDIT_TOOLBAR_ANIMATION_FRAMERATE ((float)1000/150)
+#define HILDON_EDIT_TOOLBAR_ANIMATION_TMPL "indicator_update%d"
+#define HILDON_EDIT_TOOLBAR_ANIMATION_NFRAMES 8
+
#define HILDON_EDIT_TOOLBAR_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
HILDON_TYPE_EDIT_TOOLBAR, HildonEditToolbarPrivate));
@@ -74,7 +80,9 @@ typedef struct _HildonEditToolbarPrivate Hildon
struct _HildonEditToolbarPrivate
{
+ GtkBox *hbox;
GtkLabel *label;
+ GtkWidget *animation;
GtkButton *button;
GtkButton *arrow;
};
@@ -209,11 +217,14 @@ hildon_edit_toolbar_init (HildonEditToolbar *self)
GtkWidget *separator;
GtkAlignment *align;
GtkBox *hbox = GTK_BOX (self);
- GtkBox *hbox2;
- hbox2 = GTK_BOX (gtk_hbox_new (FALSE, 0));
+ priv->hbox = GTK_BOX (gtk_hbox_new (FALSE, 0));
align = GTK_ALIGNMENT (gtk_alignment_new (0, 0.5, 1, 1));
priv->label = GTK_LABEL (gtk_label_new (NULL));
+ priv->animation = hildon_private_create_animation (
+ HILDON_EDIT_TOOLBAR_ANIMATION_FRAMERATE,
+ HILDON_EDIT_TOOLBAR_ANIMATION_TMPL,
+ HILDON_EDIT_TOOLBAR_ANIMATION_NFRAMES);
priv->button = GTK_BUTTON (hildon_gtk_button_new (HILDON_SIZE_AUTO));
separator = gtk_vseparator_new ();
priv->arrow = GTK_BUTTON (gtk_button_new ());
@@ -230,15 +241,19 @@ hildon_edit_toolbar_init (HildonEditToolbar *self)
gtk_widget_set_name (GTK_WIDGET (self), "toolbar-edit-mode");
gtk_widget_set_name (GTK_WIDGET (priv->arrow), "hildon-edit-toolbar-arrow");
- gtk_container_add (GTK_CONTAINER (align), GTK_WIDGET (hbox2));
- gtk_box_pack_start (hbox2, GTK_WIDGET (priv->label), TRUE, TRUE, 0);
- gtk_box_pack_start (hbox2, GTK_WIDGET (priv->button), FALSE, FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (align), GTK_WIDGET (priv->hbox));
+ gtk_box_pack_start (priv->hbox, GTK_WIDGET (priv->label), TRUE, TRUE, 0);
+ gtk_box_pack_start (priv->hbox, priv->animation, TRUE, TRUE, 10);
+ gtk_box_pack_start (priv->hbox, GTK_WIDGET (priv->button), FALSE, FALSE, 0);
+
+ gtk_widget_set_no_show_all (priv->animation, TRUE);
gtk_box_pack_start (hbox, GTK_WIDGET (align), TRUE, TRUE, 0);
gtk_box_pack_start (hbox, separator, FALSE, FALSE, 0);
gtk_box_pack_start (hbox, GTK_WIDGET (priv->arrow), FALSE, FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (priv->label), 0, 0.5);
+ gtk_misc_set_alignment (GTK_MISC (priv->animation), 0, 0.5);
gtk_widget_show_all (GTK_WIDGET (align));
gtk_widget_show_all (separator);
@@ -323,3 +338,21 @@ hildon_edit_toolbar_new_with_text (const gchar *label,
return toolbar;
}
+
+void G_GNUC_INTERNAL
+hildon_edit_toolbar_set_progress_indicator (HildonEditToolbar *toolbar,
+ gboolean show)
+{
+ HildonEditToolbarPrivate *priv;
+ g_return_if_fail (HILDON_IS_EDIT_TOOLBAR (toolbar));
+ priv = HILDON_EDIT_TOOLBAR_GET_PRIVATE (toolbar);
+ if (show) {
+ gtk_widget_show (priv->animation);
+ gtk_box_set_child_packing (priv->hbox, GTK_WIDGET (priv->label),
+ FALSE, FALSE, 0, GTK_PACK_START);
+ } else {
+ gtk_box_set_child_packing (priv->hbox, GTK_WIDGET (priv->label),
+ TRUE, TRUE, 0, GTK_PACK_START);
+ gtk_widget_hide (priv->animation);
+ }
+}
diff --git a/hildon/hildon-gtk.c b/hildon/hildon-gtk.c
index e0d8b4c..e1b6f3d 100644
--- a/hildon/hildon-gtk.c
+++ b/hildon/hildon-gtk.c
@@ -28,6 +28,10 @@
#include <gdk/gdkx.h>
#include "hildon-gtk.h"
+#include "hildon-window.h"
+#include "hildon-window-private.h"
+#include "hildon-edit-toolbar.h"
+#include "hildon-edit-toolbar-private.h"
typedef void (*HildonFlagFunc) (GtkWindow *window, gpointer userdata);
@@ -406,6 +410,13 @@ hildon_gtk_window_set_progress_indicator (GtkWindow *window,
guint state)
{
set_flag (window, (HildonFlagFunc) do_set_progress_indicator, GUINT_TO_POINTER (state));
+ if (HILDON_IS_WINDOW (window)) {
+ HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (window);
+ if (priv->edit_toolbar) {
+ HildonEditToolbar *tb = HILDON_EDIT_TOOLBAR (priv->edit_toolbar);
+ hildon_edit_toolbar_set_progress_indicator (tb, state);
+ }
+ }
}
/**
diff --git a/hildon/hildon-private.c b/hildon/hildon-private.c
index b7190c8..739c2c9 100644
--- a/hildon/hildon-private.c
+++ b/hildon/hildon-private.c
@@ -1,7 +1,7 @@
/*
* This file is a part of hildon
*
- * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
+ * Copyright (C) 2005, 2006, 2009 Nokia Corporation, all rights reserved.
*
* Contact: Rodrigo Novo <rodrigo.novo@nokia.com>
*
@@ -31,6 +31,7 @@
#include "hildon-private.h"
#include "hildon-date-editor.h"
#include "hildon-time-editor.h"
+#include "hildon-defines.h"
/* This function is a private function of hildon. It hadles focus
* changing for composite hildon widgets: HildonDateEditor,
@@ -79,3 +80,44 @@ hildon_private_composite_focus (GtkWidget *widget,
}
+G_GNUC_INTERNAL GtkWidget *
+hildon_private_create_animation (gfloat framerate,
+ const gchar *template,
+ gint nframes)
+{
+ GtkWidget *image;
+ GdkPixbufSimpleAnim *anim;
+ GtkIconTheme *theme;
+ gint i;
+
+ anim = gdk_pixbuf_simple_anim_new (HILDON_ICON_PIXEL_SIZE_STYLUS,
+ HILDON_ICON_PIXEL_SIZE_STYLUS,
+ framerate);
+ gdk_pixbuf_simple_anim_set_loop (anim, TRUE);
+ theme = gtk_icon_theme_get_default ();
+
+ for (i = 1; i <= nframes; i++) {
+ GdkPixbuf *frame;
+ GError *error = NULL;
+ gchar *icon_name = g_strdup_printf (template, i);
+ frame = gtk_icon_theme_load_icon (theme, icon_name,
+ HILDON_ICON_PIXEL_SIZE_STYLUS,
+ 0, &error);
+
+ if (error) {
+ g_warning ("Icon theme lookup for icon `%s' failed: %s",
+ icon_name, error->message);
+ g_error_free (error);
+ } else {
+ gdk_pixbuf_simple_anim_add_frame (anim, frame);
+ }
+
+ g_object_unref (frame);
+ g_free (icon_name);
+ }
+
+ image = gtk_image_new_from_animation (GDK_PIXBUF_ANIMATION (anim));
+ g_object_unref (anim);
+
+ return image;
+}
diff --git a/hildon/hildon-private.h b/hildon/hildon-private.h
index 67b79f4..8302025 100644
--- a/hildon/hildon-private.h
+++ b/hildon/hildon-private.h
@@ -1,7 +1,7 @@
/*
* This file is a part of hildon
*
- * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
+ * Copyright (C) 2005, 2006, 2009 Nokia Corporation, all rights reserved.
*
* Contact: Rodrigo Novo <rodrigo.novo@nokia.com>
*
@@ -36,6 +36,11 @@ hildon_private_composite_focus (GtkWidget *widget,
GtkDirectionType direction,
GtkDirectionType *effective_direction);
+G_GNUC_INTERNAL GtkWidget *
+hildon_private_create_animation (gfloat framerate,
+ const gchar *template,
+ gint nframes);
+
G_END_DECLS
#endif /* __HILDON_PRIVATE_H__ */