← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~mterry/indicator-datetime/robustify-location-popup into lp:indicator-datetime

 

Michael Terry has proposed merging lp:~mterry/indicator-datetime/robustify-location-popup into lp:indicator-datetime.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)

For more details, see:
https://code.launchpad.net/~mterry/indicator-datetime/robustify-location-popup/+merge/54552

Just a few cleanups to make sure that the location popup always appears.
-- 
https://code.launchpad.net/~mterry/indicator-datetime/robustify-location-popup/+merge/54552
Your team ayatana-commits is subscribed to branch lp:indicator-datetime.
=== modified file 'src/timezone-completion.c'
--- src/timezone-completion.c	2011-03-23 15:33:31 +0000
+++ src/timezone-completion.c	2011-03-23 15:56:32 +0000
@@ -80,6 +80,11 @@
 
   gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion), model);
   gtk_entry_completion_complete (GTK_ENTRY_COMPLETION (completion));
+
+  /* By this time, the changed signal has come and gone.  We didn't give a
+     model to use, so no popup appeared for user.  Poke the entry again to show
+     popup in 300ms. */
+  g_signal_emit_by_name (priv->entry, "changed");
 }
 
 static void
@@ -115,8 +120,14 @@
 
   JsonReader * reader = json_reader_new (json_parser_get_root (JSON_PARSER (object)));
 
+<<<<<<< TREE
   if (!json_reader_is_array (reader)) {
     g_object_unref (G_OBJECT (reader));
+=======
+  if (!json_reader_is_array (reader)) {
+    g_warning ("Could not parse geoname JSON data");
+    save_and_use_model (completion, priv->initial_model);
+>>>>>>> MERGE-SOURCE
     return;
   }
 
@@ -223,15 +234,6 @@
     return FALSE;
   }
 
-  const gchar * text = gtk_entry_get_text (priv->entry);
-
-  gpointer data;
-  if (g_hash_table_lookup_extended (priv->request_table, text, NULL, &data)) {
-    gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion), GTK_TREE_MODEL (data));
-    gtk_entry_completion_complete (GTK_ENTRY_COMPLETION (completion));
-    return FALSE;
-  }
-
   /* Cancel any ongoing request */
   if (priv->cancel) {
     g_cancellable_cancel (priv->cancel);
@@ -239,6 +241,7 @@
   }
   g_free (priv->request_text);
 
+  const gchar * text = gtk_entry_get_text (priv->entry);
   priv->request_text = g_strdup (text);
 
   gchar * escaped = g_uri_escape_string (text, NULL, FALSE);
@@ -259,7 +262,18 @@
   if (priv->queued_request) {
     g_source_remove (priv->queued_request);
   }
-  priv->queued_request = g_timeout_add (300, (GSourceFunc)request_zones, completion);
+
+  /* See if we've already got this one */
+  const gchar * text = gtk_entry_get_text (priv->entry);
+  gpointer data;
+  if (g_hash_table_lookup_extended (priv->request_table, text, NULL, &data)) {
+    gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion), GTK_TREE_MODEL (data));
+  }
+  else {
+    priv->queued_request = g_timeout_add (300, (GSourceFunc)request_zones, completion);
+    gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion), NULL);
+  }
+  gtk_entry_completion_complete (GTK_ENTRY_COMPLETION (completion));
 }
 
 void
@@ -267,6 +281,10 @@
 {
   TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
 
+  if (priv->queued_request) {
+    g_source_remove (priv->queued_request);
+    priv->queued_request = 0;
+  }
   if (priv->entry) {
     g_source_remove (priv->changed_id);
     g_object_remove_weak_pointer (G_OBJECT (priv->entry), (gpointer *)&priv->entry);


Follow ups