summaryrefslogtreecommitdiff
path: root/gtk/gtktextview.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-05-04 22:30:46 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-05-11 20:33:23 -0400
commitaeef59fda973426e605644c6c5a4f83f43a91f63 (patch)
treefb1ad1a4cd9d222e27ba60a43673d9218b2f7333 /gtk/gtktextview.c
parent84632b090130c4199eb2972e054e08c544380077 (diff)
downloadgtk+-aeef59fda973426e605644c6c5a4f83f43a91f63.tar.gz
textview: Derive from GtkWidget
Drop the GtkContainer vfuncs. As a replacement for gtk_container_remove, make gtk_text_view_remove public.
Diffstat (limited to 'gtk/gtktextview.c')
-rw-r--r--gtk/gtktextview.c83
1 files changed, 10 insertions, 73 deletions
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index d5c543cef6..44e24a1255 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -155,7 +155,7 @@ enum
TEXT_HANDLE_N_HANDLES
};
-struct _GtkTextViewPrivate
+struct _GtkTextViewPrivate
{
GtkTextLayout *layout;
GtkTextBuffer *buffer;
@@ -561,14 +561,6 @@ static void gtk_text_view_set_vadjustment_values (GtkTextView *text_view);
static void gtk_text_view_update_im_spot_location (GtkTextView *text_view);
static void gtk_text_view_insert_emoji (GtkTextView *text_view);
-/* Container methods */
-static void gtk_text_view_add (GtkContainer *container,
- GtkWidget *child);
-static void gtk_text_view_remove (GtkContainer *container,
- GtkWidget *child);
-static void gtk_text_view_forall (GtkContainer *container,
- GtkCallback callback,
- gpointer callback_data);
static void update_node_ordering (GtkWidget *widget);
/* GtkTextHandle handlers */
@@ -661,7 +653,7 @@ static gint text_window_get_height (GtkTextWindow *win);
static guint signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE_WITH_CODE (GtkTextView, gtk_text_view, GTK_TYPE_CONTAINER,
+G_DEFINE_TYPE_WITH_CODE (GtkTextView, gtk_text_view, GTK_TYPE_WIDGET,
G_ADD_PRIVATE (GtkTextView)
G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
@@ -803,7 +795,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
/* Default handlers and virtual methods
*/
@@ -822,10 +813,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
widget_class->size_allocate = gtk_text_view_size_allocate;
widget_class->snapshot = gtk_text_view_snapshot;
- container_class->add = gtk_text_view_add;
- container_class->remove = gtk_text_view_remove;
- container_class->forall = gtk_text_view_forall;
-
klass->move_cursor = gtk_text_view_move_cursor;
klass->set_anchor = gtk_text_view_set_anchor;
klass->insert_at_cursor = gtk_text_view_insert_at_cursor;
@@ -3776,11 +3763,12 @@ gtk_text_view_remove_validate_idles (GtkTextView *text_view)
static void
gtk_text_view_dispose (GObject *object)
{
- GtkTextView *text_view;
- GtkTextViewPrivate *priv;
+ GtkTextView *text_view = GTK_TEXT_VIEW (object);
+ GtkTextViewPrivate *priv = text_view->priv;
+ GtkWidget *child;
- text_view = GTK_TEXT_VIEW (object);
- priv = text_view->priv;
+ while ((child = gtk_widget_get_first_child (GTK_WIDGET (text_view))))
+ gtk_text_view_remove (text_view, child);
gtk_text_view_remove_validate_idles (text_view);
gtk_text_view_set_buffer (text_view, NULL);
@@ -5734,26 +5722,10 @@ gtk_text_view_snapshot (GtkWidget *widget,
}
}
-/*
- * Container
- */
-
-static void
-gtk_text_view_add (GtkContainer *container,
- GtkWidget *child)
-{
- /* There isn't really a good default for what to do when
- * using gtk_container_add() for @child. So we default to
- * placing it at 0,0 in the text window.
- */
- gtk_text_view_add_overlay (GTK_TEXT_VIEW (container), child, 0, 0);
-}
-
-static void
-gtk_text_view_remove (GtkContainer *container,
- GtkWidget *child)
+void
+gtk_text_view_remove (GtkTextView *text_view,
+ GtkWidget *child)
{
- GtkTextView *text_view = GTK_TEXT_VIEW (container);
GtkTextViewPrivate *priv = text_view->priv;
AnchoredChild *ac;
@@ -5799,41 +5771,6 @@ gtk_text_view_remove (GtkContainer *container,
anchored_child_free (ac);
}
-static void
-gtk_text_view_forall (GtkContainer *container,
- GtkCallback callback,
- gpointer callback_data)
-{
- const GList *iter;
- GtkTextView *text_view;
- GtkTextViewPrivate *priv;
-
- g_return_if_fail (GTK_IS_TEXT_VIEW (container));
- g_return_if_fail (callback != NULL);
-
- text_view = GTK_TEXT_VIEW (container);
- priv = text_view->priv;
-
- if (priv->left_child)
- callback (GTK_WIDGET (priv->left_child), callback_data);
- if (priv->right_child)
- callback (GTK_WIDGET (priv->right_child), callback_data);
- if (priv->top_child)
- callback (GTK_WIDGET (priv->top_child), callback_data);
- if (priv->bottom_child)
- callback (GTK_WIDGET (priv->bottom_child), callback_data);
- if (priv->center_child)
- callback (GTK_WIDGET (priv->center_child), callback_data);
-
- iter = priv->anchored_children.head;
- while (iter != NULL)
- {
- const AnchoredChild *ac = iter->data;
- iter = iter->next;
- callback (ac->widget, callback_data);
- }
-}
-
#define CURSOR_ON_MULTIPLIER 2
#define CURSOR_OFF_MULTIPLIER 1
#define CURSOR_PEND_MULTIPLIER 3