[yelp] [yelp-window] Use LOADING in location entry for a throbber



commit 4b3dc88988fe100b3bba3918e19a290ba0356583
Author: Shaun McCance <shaunm gnome org>
Date:   Mon May 3 10:06:56 2010 -0500

    [yelp-window] Use LOADING in location entry for a throbber

 libyelp/yelp-location-entry.c |   41 ++++++++++++++++++++++++++++++++++++-----
 src/yelp-window.c             |   12 +++++++++++-
 2 files changed, 47 insertions(+), 6 deletions(-)
---
diff --git a/libyelp/yelp-location-entry.c b/libyelp/yelp-location-entry.c
index b29a410..d85f3d8 100644
--- a/libyelp/yelp-location-entry.c
+++ b/libyelp/yelp-location-entry.c
@@ -61,6 +61,8 @@
  * will cause the FIXME signal to be emitted.
  **/
 
+static void     location_entry_dispose         (GObject            *object);
+static void     location_entry_finalize        (GObject            *object);
 static void     location_entry_get_property    (GObject           *object,
                                                 guint              prop_id,
                                                 GValue            *value,
@@ -132,22 +134,23 @@ static gboolean entry_match_selected                (GtkEntryCompletion *complet
 typedef struct _YelpLocationEntryPrivate  YelpLocationEntryPrivate;
 struct _YelpLocationEntryPrivate
 {
-    GtkWidget *text_entry;
+    GtkWidget          *text_entry;
 
     gint       desc_column;
     gint       icon_column;
     gint       flags_column;
     gboolean   enable_search;
 
-    GtkTreeRowReference *row;
-
     gboolean   search_mode;
+    guint      pulse;
 
     GtkCellRenderer *icon_cell;
 
-    /* owned by entry, do not free */
     GtkEntryCompletion *completion;
     gint                completion_desc_column;
+
+    /* free this, and only this */
+    GtkTreeRowReference *row;
 };
 
 enum {
@@ -177,6 +180,8 @@ yelp_location_entry_class_init (YelpLocationEntryClass *klass)
 
     object_class = G_OBJECT_CLASS (klass);
   
+    object_class->dispose = location_entry_dispose;
+    object_class->finalize = location_entry_finalize;
     object_class->get_property = location_entry_get_property;
     object_class->set_property = location_entry_set_property;
 
@@ -358,6 +363,30 @@ yelp_location_entry_init (YelpLocationEntry *entry)
 }
 
 static void
+location_entry_dispose (GObject *object)
+{
+    YelpLocationEntryPrivate *priv = GET_PRIV (object);
+
+    if (priv->row) {
+        gtk_tree_row_reference_free (priv->row);
+        priv->row = NULL;
+    }
+
+    if (priv->pulse > 0) {
+        g_source_remove (priv->pulse);
+        priv->pulse = 0;
+    }
+
+    G_OBJECT_CLASS (yelp_location_entry_parent_class)->dispose (object);
+}
+
+static void
+location_entry_finalize (GObject *object)
+{
+    G_OBJECT_CLASS (yelp_location_entry_parent_class)->finalize (object);
+}
+
+static void
 location_entry_get_property   (GObject      *object,
                                guint         prop_id,
                                GValue       *value,
@@ -554,7 +583,9 @@ location_entry_set_entry (YelpLocationEntry *entry, gboolean emit)
             gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->text_entry),
                                                GTK_ENTRY_ICON_PRIMARY,
                                                "image-loading");
-            g_timeout_add (80, location_entry_pulse, entry);
+            if (priv->pulse > 0)
+                g_source_remove (priv->pulse);
+            priv->pulse = g_timeout_add (80, location_entry_pulse, entry);
         }
         else {
             gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->text_entry),
diff --git a/src/yelp-window.c b/src/yelp-window.c
index e9a6b84..3cc2d5d 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -864,10 +864,19 @@ view_loaded (YelpView   *view,
 {
     gchar **ids;
     gint i;
+    GtkTreeIter iter;
+    gint flags;
     YelpWindowPrivate *priv = GET_PRIV (window);
     YelpDocument *document = yelp_view_get_document (view);
-    ids = yelp_document_list_page_ids (document);
 
+    gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->history), &iter);
+    gtk_tree_model_get (priv->history, &iter, COL_FLAGS, &flags, -1);
+    if (flags & YELP_LOCATION_ENTRY_IS_LOADING) {
+        flags = flags ^ YELP_LOCATION_ENTRY_IS_LOADING;
+        gtk_list_store_set (priv->history, &iter, COL_FLAGS, flags, -1);
+    }
+
+    ids = yelp_document_list_page_ids (document);
     gtk_list_store_clear (priv->completion);
     for (i = 0; ids[i]; i++) {
         GtkTreeIter iter;
@@ -945,6 +954,7 @@ view_uri_selected (YelpView     *view,
                             COL_TITLE, _("Loading"),
                             COL_ICON, "help-contents",
                             COL_URI, struri,
+                            COL_FLAGS, YELP_LOCATION_ENTRY_IS_LOADING,
                             -1);
         /* Limit to 15 entries. There are two extra for the search entry and
          * the separator above it.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]