[gtk/kill-containers: 40/99] textview: Derive from GtkWidget
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/kill-containers: 40/99] textview: Derive from GtkWidget
- Date: Sun, 10 May 2020 02:26:25 +0000 (UTC)
commit 157e3afe8e133d25c9fb9ec3fabe7ea7579d9cfc
Author: Matthias Clasen <mclasen redhat com>
Date: Mon May 4 22:30:46 2020 -0400
textview: Derive from GtkWidget
Drop the GtkContainer vfuncs. As a replacement for
gtk_container_remove, make gtk_text_view_remove public.
docs/reference/gtk/gtk4-sections.txt | 1 +
gtk/a11y/gtktextviewaccessible.c | 2 +-
gtk/a11y/gtktextviewaccessible.h | 6 +--
gtk/gtktextview.c | 74 +++---------------------------------
gtk/gtktextview.h | 10 +++--
5 files changed, 17 insertions(+), 76 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index b08edbccb0..e404a5cf94 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -2801,6 +2801,7 @@ gtk_text_view_backward_display_line_start
gtk_text_view_starts_display_line
gtk_text_view_move_visually
gtk_text_view_add_child_at_anchor
+gtk_text_view_remove
GtkTextChildAnchor
gtk_text_child_anchor_new
gtk_text_child_anchor_get_widgets
diff --git a/gtk/a11y/gtktextviewaccessible.c b/gtk/a11y/gtktextviewaccessible.c
index ba15122db0..109d56bc17 100644
--- a/gtk/a11y/gtktextviewaccessible.c
+++ b/gtk/a11y/gtktextviewaccessible.c
@@ -61,7 +61,7 @@ static void mark_set_cb (GtkTextBuffer *buffer,
static void atk_editable_text_interface_init (AtkEditableTextIface *iface);
static void atk_text_interface_init (AtkTextIface *iface);
-G_DEFINE_TYPE_WITH_CODE (GtkTextViewAccessible, gtk_text_view_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE,
+G_DEFINE_TYPE_WITH_CODE (GtkTextViewAccessible, gtk_text_view_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
G_ADD_PRIVATE (GtkTextViewAccessible)
G_IMPLEMENT_INTERFACE (ATK_TYPE_EDITABLE_TEXT, atk_editable_text_interface_init)
G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init))
diff --git a/gtk/a11y/gtktextviewaccessible.h b/gtk/a11y/gtktextviewaccessible.h
index 78bd3ca0a1..f8436e150e 100644
--- a/gtk/a11y/gtktextviewaccessible.h
+++ b/gtk/a11y/gtktextviewaccessible.h
@@ -22,7 +22,7 @@
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
-#include <gtk/a11y/gtkcontaineraccessible.h>
+#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
@@ -39,14 +39,14 @@ typedef struct _GtkTextViewAccessiblePrivate GtkTextViewAccessiblePrivate;
struct _GtkTextViewAccessible
{
- GtkContainerAccessible parent;
+ GtkWidgetAccessible parent;
GtkTextViewAccessiblePrivate *priv;
};
struct _GtkTextViewAccessibleClass
{
- GtkContainerAccessibleClass parent_class;
+ GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 12189f58f1..96fa6bb1e4 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
*/
@@ -824,10 +815,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
widget_class->grab_focus = gtk_widget_grab_focus_self;
widget_class->focus = gtk_widget_focus_all;
- 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;
@@ -5736,26 +5723,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;
@@ -5801,41 +5772,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
diff --git a/gtk/gtktextview.h b/gtk/gtktextview.h
index 3d824b2517..098de5e4e0 100644
--- a/gtk/gtktextview.h
+++ b/gtk/gtktextview.h
@@ -29,7 +29,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif
-#include <gtk/gtkcontainer.h>
+#include <gtk/gtkwidget.h>
#include <gtk/gtkimcontext.h>
#include <gtk/gtktextbuffer.h>
@@ -107,7 +107,7 @@ typedef struct _GtkTextViewClass GtkTextViewClass;
struct _GtkTextView
{
- GtkContainer parent_instance;
+ GtkWidget parent_instance;
/*< private >*/
@@ -150,7 +150,7 @@ struct _GtkTextView
*/
struct _GtkTextViewClass
{
- GtkContainerClass parent_class;
+ GtkWidgetClass parent_class;
/*< public >*/
@@ -329,6 +329,10 @@ void gtk_text_view_move_overlay (GtkTextView *text_view,
gint xpos,
gint ypos);
+GDK_AVAILABLE_IN_ALL
+void gtk_text_view_remove (GtkTextView *text_view,
+ GtkWidget *child);
+
/* Default style settings (fallbacks if no tag affects the property) */
GDK_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]