]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtktextview.c
treeview: Don't emit cursor-changed in destruction
[~andy/gtk] / gtk / gtktextview.c
index c94ff403fdfa8fd8371e2b082a0be92896112294..2de8a1e623be9f15d7b3bf23ead0c54b9a9580cb 100644 (file)
@@ -239,7 +239,7 @@ struct _GtkTextViewPrivate
   guint vscroll_policy : 1;
   guint cursor_handle_dragged : 1;
   guint selection_handle_dragged : 1;
-  guint populate_toolbar : 1;
+  guint populate_all   : 1;
 };
 
 struct _GtkTextPendingScroll
@@ -295,7 +295,7 @@ enum
   PROP_VSCROLL_POLICY,
   PROP_INPUT_PURPOSE,
   PROP_INPUT_HINTS,
-  PROP_POPULATE_TOOLBAR
+  PROP_POPULATE_ALL
 };
 
 static void gtk_text_view_finalize             (GObject          *object);
@@ -863,18 +863,17 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
                                                        GTK_INPUT_HINT_NONE,
                                                        G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
-  /** GtkTextView:populate-toolbar:
+  /** GtkTextView:populate-all:
    *
-   * If ::populate-toolbar is %TRUE, the #GtkTextView::populate-popup
-   * signal is also emitted for touch popups. In this case, the
-   * container is a #GtkToolbar.
+   * If ::populate-all is %TRUE, the #GtkTextView::populate-popup
+   * signal is also emitted for touch popups.
    *
    * Since: 3.8
    */
   g_object_class_install_property (gobject_class,
-                                   PROP_POPULATE_TOOLBAR,
-                                   g_param_spec_boolean ("populate-toolbar",
-                                                         P_("Populate toolbar"),
+                                   PROP_POPULATE_ALL,
+                                   g_param_spec_boolean ("populate-all",
+                                                         P_("Populate all"),
                                                          P_("Whether to emit ::populate-popup for touch popups"),
                                                          FALSE,
                                                          GTK_PARAM_READWRITE));
@@ -1142,17 +1141,22 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
   /**
    * GtkTextView::populate-popup:
    * @text_view: The text view on which the signal is emitted
-   * @popup: the menu or toolbar that is being populated
+   * @popup: the container that is being populated
    *
-   * The ::populate-popup signal gets emitted before showing the 
+   * The ::populate-popup signal gets emitted before showing the
    * context menu of the text view.
    *
    * If you need to add items to the context menu, connect
-   * to this signal and append your items to the @popup.
+   * to this signal and append your items to the @popup, which
+   * will be a #GtkMenu in this case.
    *
    * If #GtkEntry::populate-toolbar is %TRUE, this signal will
    * also be emitted to populate touch popups. In this case,
-   * @popup will be a toolbar instead of a menu.
+   * @popup will be a different container, e.g. a #GtkToolbar.
+   *
+   * The signal handler should not make assumptions about the
+   * type of @widget, but check whether @popup is a #GtkMenu
+   * or #GtkToolbar or another kind of container.
    */
   signals[POPULATE_POPUP] =
     g_signal_new (I_("populate-popup"),
@@ -3287,8 +3291,8 @@ gtk_text_view_set_property (GObject         *object,
       gtk_text_view_set_input_hints (text_view, g_value_get_flags (value));
       break;
 
-    case PROP_POPULATE_TOOLBAR:
-      text_view->priv->populate_toolbar = g_value_get_boolean (value);
+    case PROP_POPULATE_ALL:
+      text_view->priv->populate_all = g_value_get_boolean (value);
       break;
 
     default:
@@ -3395,8 +3399,8 @@ gtk_text_view_get_property (GObject         *object,
       g_value_set_flags (value, gtk_text_view_get_input_hints (text_view));
       break;
 
-    case PROP_POPULATE_TOOLBAR:
-      g_value_set_boolean (value, priv->populate_toolbar);
+    case PROP_POPULATE_ALL:
+      g_value_set_boolean (value, priv->populate_all);
       break;
 
     default:
@@ -8800,7 +8804,7 @@ activate_bubble_cb (GtkWidget   *item,
 {
   const gchar *signal = g_object_get_data (G_OBJECT (item), "gtk-signal");
   g_signal_emit_by_name (text_view, signal);
-  gtk_bubble_window_popdown (GTK_BUBBLE_WINDOW (text_view->priv->selection_bubble));
+  _gtk_bubble_window_popdown (GTK_BUBBLE_WINDOW (text_view->priv->selection_bubble));
 }
 
 static void
@@ -8846,7 +8850,7 @@ bubble_targets_received (GtkClipboard     *clipboard,
     gtk_widget_destroy (priv->selection_bubble);
 
   window = gtk_widget_get_window (GTK_WIDGET (text_view));
-  priv->selection_bubble = gtk_bubble_window_new ();
+  priv->selection_bubble = _gtk_bubble_window_new ();
   toolbar = GTK_WIDGET (gtk_toolbar_new ());
   gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_TEXT);
   gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
@@ -8867,13 +8871,13 @@ bubble_targets_received (GtkClipboard     *clipboard,
   append_bubble_action (text_view, toolbar, GTK_STOCK_PASTE, "paste-clipboard",
                         can_insert && has_clipboard);
 
-  if (priv->populate_toolbar)
+  if (priv->populate_all)
     g_signal_emit (text_view, signals[POPULATE_POPUP], 0, toolbar);
 
   gtk_text_view_get_selection_rect (text_view, &rect);
   rect.x -= priv->xoffset;
   rect.y -= priv->yoffset;
-  gtk_bubble_window_popup (GTK_BUBBLE_WINDOW (priv->selection_bubble),
+  _gtk_bubble_window_popup (GTK_BUBBLE_WINDOW (priv->selection_bubble),
                            window, &rect, GTK_POS_TOP);
 
   priv->selection_bubble_timeout_id = 0;
@@ -8900,7 +8904,7 @@ gtk_text_view_selection_bubble_popup_unset (GtkTextView *text_view)
   priv = text_view->priv;
 
   if (priv->selection_bubble)
-    gtk_bubble_window_popdown (GTK_BUBBLE_WINDOW (priv->selection_bubble));
+    _gtk_bubble_window_popdown (GTK_BUBBLE_WINDOW (priv->selection_bubble));
 
   if (priv->selection_bubble_timeout_id)
     {
@@ -9097,7 +9101,8 @@ text_window_scroll        (GtkTextWindow *win,
 
   if (dx != 0 || dy != 0)
     {
-      gtk_bubble_window_popdown (GTK_BUBBLE_WINDOW (priv->selection_bubble));
+      if (priv->selection_bubble)
+        _gtk_bubble_window_popdown (GTK_BUBBLE_WINDOW (priv->selection_bubble));
       gdk_window_scroll (win->bin_window, dx, dy);
     }
 }