Add progress indicator to the HildonEditToolbar.
authorAlberto Garcia <agarcia@igalia.com>
Mon, 18 May 2009 16:05:51 +0000 (18:05 +0200)
committerAlberto Garcia <agarcia@igalia.com>
Mon, 15 Jun 2009 18:12:13 +0000 (20:12 +0200)
* 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)

ChangeLog
hildon/Makefile.am
hildon/hildon-banner.c
hildon/hildon-edit-toolbar-private.h [new file with mode: 0644]
hildon/hildon-edit-toolbar.c
hildon/hildon-gtk.c
hildon/hildon-private.c
hildon/hildon-private.h

index 1fb6197..f21fca7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
 2009-06-15  Alberto Garcia  <agarcia@igalia.com>
 
+       * 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)
+
+2009-06-15  Alberto Garcia  <agarcia@igalia.com>
+
        * hildon/hildon-app-menu-private.h
        * hildon/hildon-app-menu.c (hildon_app_menu_insert)
        (hildon_app_menu_add_filter, +menu_item_button_event)
index 849491c..1bb42a6 100644 (file)
@@ -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    \
index 11b8ca8..9cfc7e8 100644 (file)
@@ -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 (file)
index 0000000..0021ddf
--- /dev/null
@@ -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__ */
index c288c71..9b8d910 100644 (file)
@@ -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);
+    }
+}
index e0d8b4c..e1b6f3d 100644 (file)
 #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);
+        }
+    }
 }
 
 /**
index b7190c8..739c2c9 100644 (file)
@@ -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;
+}
index 67b79f4..8302025 100644 (file)
@@ -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__ */