gtk+ r19844 - trunk/gtk



Author: federico
Date: Thu Mar 13 00:43:54 2008
New Revision: 19844
URL: http://svn.gnome.org/viewvc/gtk+?rev=19844&view=rev

Log:
Use a timer for the completion feedback window

Signed-off-by: Federico Mena Quintero <federico gnu org>


Modified:
   trunk/gtk/gtkfilechooserentry.c

Modified: trunk/gtk/gtkfilechooserentry.c
==============================================================================
--- trunk/gtk/gtkfilechooserentry.c	(original)
+++ trunk/gtk/gtkfilechooserentry.c	Thu Mar 13 00:43:54 2008
@@ -74,6 +74,7 @@
 
   GtkWidget *completion_feedback_window;
   GtkWidget *completion_feedback_label;
+  guint completion_feedback_timeout_id;
 
   guint has_completion : 1;
   guint in_change      : 1;
@@ -87,6 +88,8 @@
   N_COLUMNS
 };
 
+#define COMPLETION_FEEDBACK_TIMEOUT_MS 2000
+
 static void     gtk_file_chooser_entry_iface_init     (GtkEditableClass *iface);
 
 static void     gtk_file_chooser_entry_finalize       (GObject          *object);
@@ -828,6 +831,27 @@
   gtk_widget_show (chooser_entry->completion_feedback_label);
 }
 
+static gboolean
+completion_feedback_timeout_cb (gpointer data)
+{
+  GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (data);
+
+  chooser_entry->completion_feedback_timeout_id = 0;
+
+  remove_completion_feedback (chooser_entry);
+  return FALSE;
+}
+
+static void
+install_completion_feedback_timer (GtkFileChooserEntry *chooser_entry)
+{
+  g_assert (chooser_entry->completion_feedback_timeout_id == 0);
+
+  chooser_entry->completion_feedback_timeout_id = gdk_threads_add_timeout (COMPLETION_FEEDBACK_TIMEOUT_MS,
+									   completion_feedback_timeout_cb,
+									   chooser_entry);
+}
+
 static void
 show_completion_feedback_window (GtkFileChooserEntry *chooser_entry)
 {
@@ -854,7 +878,7 @@
   gtk_window_move (GTK_WINDOW (chooser_entry->completion_feedback_window), feedback_x, feedback_y);
   gtk_widget_show (chooser_entry->completion_feedback_window);
 
-  /* FIXME: install timer */
+  install_completion_feedback_timer (chooser_entry);
 }
 
 static void
@@ -879,7 +903,11 @@
   chooser_entry->completion_feedback_window = NULL;
   chooser_entry->completion_feedback_label = NULL;
 
-  /* FIXME: remove timer */
+  if (chooser_entry->completion_feedback_timeout_id != 0)
+    {
+      g_source_remove (chooser_entry->completion_feedback_timeout_id);
+      chooser_entry->completion_feedback_timeout_id = 0;
+    }
 }
 
 static void



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