]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkentrycompletion.c
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
[~andy/gtk] / gtk / gtkentrycompletion.c
index f2abe951c2af8a216befd225da81b7d0d69fa9ae..689debb8f9d9dc4980a064c7ca9b562006476563 100644 (file)
@@ -905,6 +905,18 @@ gtk_entry_completion_get_entry (GtkEntryCompletion *completion)
   return completion->priv->entry;
 }
 
+static void
+filter_model_changed_cb (GtkTreeModel     *model,
+                        GtkTreePath      *path,
+                        GtkTreeIter      *iter,
+                        gpointer          user_data)
+{
+  GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data);
+
+  if (GTK_WIDGET_VISIBLE (completion->priv->popup_window))
+    _gtk_entry_completion_resize_popup (completion);  
+}
+
 /**
  * gtk_entry_completion_set_model:
  * @completion: A #GtkEntryCompletion.
@@ -930,9 +942,13 @@ gtk_entry_completion_set_model (GtkEntryCompletion *completion,
                                           gtk_entry_completion_visible_func,
                                           completion,
                                           NULL);
+
   gtk_tree_view_set_model (GTK_TREE_VIEW (completion->priv->tree_view),
                            GTK_TREE_MODEL (completion->priv->filter_model));
   g_object_unref (G_OBJECT (completion->priv->filter_model));
+
+  if (GTK_WIDGET_VISIBLE (completion->priv->popup_window))
+    _gtk_entry_completion_resize_popup (completion);
 }
 
 /**
@@ -1205,39 +1221,6 @@ gtk_entry_completion_get_text_column (GtkEntryCompletion *completion)
 
 /* private */
 
-/* lame copy from gtkentry.c */
-static void
-get_borders (GtkEntry *entry,
-             gint     *xborder,
-             gint     *yborder)
-{
-  GtkWidget *widget = GTK_WIDGET (entry);
-  gint focus_width;
-  gboolean interior_focus;
-
-  gtk_widget_style_get (widget,
-                        "interior-focus", &interior_focus,
-                        "focus-line-width", &focus_width,
-                        NULL);
-
-  if (entry->has_frame)
-    {
-      *xborder = widget->style->xthickness;
-      *yborder = widget->style->ythickness;
-    }
-  else
-    {
-      *xborder = 0;
-      *yborder = 0;
-    }
-
-  if (!interior_focus)
-    {
-      *xborder += focus_width;
-      *yborder += focus_width;
-    }
-}
-
 static gboolean
 gtk_entry_completion_list_enter_notify (GtkWidget        *widget,
                                        GdkEventCrossing *event,
@@ -1275,12 +1258,12 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
   GtkTreePath *path;
   gboolean above;
   gint width;
-  
-  gdk_window_get_origin (completion->priv->entry->window, &x, &y);
-  get_borders (GTK_ENTRY (completion->priv->entry), &x_border, &y_border);
 
-  x += x_border;
-  y += 2 * y_border;
+  if (!completion->priv->entry->window)
+    return FALSE;
+
+  gdk_window_get_origin (completion->priv->entry->window, &x, &y);
+  _gtk_entry_get_borders (GTK_ENTRY (completion->priv->entry), &x_border, &y_border);
 
   matches = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->filter_model), NULL);
 
@@ -1363,6 +1346,9 @@ _gtk_entry_completion_popup (GtkEntryCompletion *completion)
   if (GTK_WIDGET_MAPPED (completion->priv->popup_window))
     return;
 
+  if (!GTK_WIDGET_MAPPED (completion->priv->entry))
+    return;
+
   completion->priv->ignore_enter = TRUE;
     
   column = gtk_tree_view_get_column (GTK_TREE_VIEW (completion->priv->action_view), 0);
@@ -1378,7 +1364,7 @@ _gtk_entry_completion_popup (GtkEntryCompletion *completion)
   _gtk_entry_completion_resize_popup (completion);
 
   gtk_widget_show (completion->priv->popup_window);
-
+    
   gtk_grab_add (completion->priv->popup_window);
   gdk_pointer_grab (completion->priv->popup_window->window, TRUE,
                     GDK_BUTTON_PRESS_MASK |