textviewchild: Derive from GtkWidget

GtkContainer is going away.
This commit is contained in:
Matthias Clasen 2020-05-08 01:05:06 -04:00
parent bf543e0367
commit 47139bc506
3 changed files with 18 additions and 40 deletions

View File

@ -4391,7 +4391,7 @@ gtk_text_view_set_gutter (GtkTextView *text_view,
return;
new_child = GTK_TEXT_VIEW_CHILD (gtk_text_view_child_new (win));
gtk_container_add (GTK_CONTAINER (new_child), widget);
gtk_text_view_child_add (new_child, widget);
*childp = g_object_ref (new_child);
gtk_widget_set_parent (GTK_WIDGET (new_child), GTK_WIDGET (text_view));

View File

@ -37,7 +37,7 @@ typedef struct
struct _GtkTextViewChild
{
GtkContainer parent_instance;
GtkWidget parent_instance;
GtkTextWindowType window_type;
GQueue overlays;
int xoffset;
@ -51,7 +51,7 @@ enum {
N_PROPS
};
G_DEFINE_TYPE (GtkTextViewChild, gtk_text_view_child, GTK_TYPE_CONTAINER)
G_DEFINE_TYPE (GtkTextViewChild, gtk_text_view_child, GTK_TYPE_WIDGET)
static GParamSpec *properties[N_PROPS];
@ -107,12 +107,10 @@ gtk_text_view_child_get_overlay (GtkTextViewChild *self,
return NULL;
}
static void
gtk_text_view_child_add (GtkContainer *container,
void
gtk_text_view_child_add (GtkTextViewChild *self,
GtkWidget *widget)
{
GtkTextViewChild *self = GTK_TEXT_VIEW_CHILD (container);
if (self->child != NULL)
{
g_warning ("%s allows a single child and already contains a %s",
@ -125,12 +123,10 @@ gtk_text_view_child_add (GtkContainer *container,
gtk_widget_set_parent (widget, GTK_WIDGET (self));
}
static void
gtk_text_view_child_remove (GtkContainer *container,
void
gtk_text_view_child_remove (GtkTextViewChild *self,
GtkWidget *widget)
{
GtkTextViewChild *self = GTK_TEXT_VIEW_CHILD (container);
if (widget == self->child)
{
self->child = NULL;
@ -146,26 +142,6 @@ gtk_text_view_child_remove (GtkContainer *container,
}
}
static void
gtk_text_view_child_forall (GtkContainer *container,
GtkCallback callback,
gpointer callback_data)
{
GtkTextViewChild *self = GTK_TEXT_VIEW_CHILD (container);
const GList *iter;
if (self->child != NULL)
callback (self->child, callback_data);
iter = self->overlays.head;
while (iter != NULL)
{
Overlay *overlay = iter->data;
iter = iter->next;
callback (overlay->widget, callback_data);
}
}
static void
gtk_text_view_child_measure (GtkWidget *widget,
GtkOrientation orientation,
@ -390,7 +366,6 @@ gtk_text_view_child_class_init (GtkTextViewChildClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
object_class->dispose = gtk_text_view_child_dispose;
object_class->constructed = gtk_text_view_child_constructed;
@ -401,10 +376,6 @@ gtk_text_view_child_class_init (GtkTextViewChildClass *klass)
widget_class->size_allocate = gtk_text_view_child_size_allocate;
widget_class->snapshot = gtk_text_view_child_snapshot;
container_class->add = gtk_text_view_child_add;
container_class->remove = gtk_text_view_child_remove;
container_class->forall = gtk_text_view_child_forall;
/**
* GtkTextViewChild:window-type:
*

View File

@ -18,18 +18,25 @@
#ifndef __GTK_TEXT_VIEW_CHILD_PRIVATE_H__
#define __GTK_TEXT_VIEW_CHILD_PRIVATE_H__
#include <gtk/gtkcontainer.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtktextview.h>
#define GTK_TYPE_TEXT_VIEW_CHILD (gtk_text_view_child_get_type())
G_GNUC_INTERNAL
G_DECLARE_FINAL_TYPE (GtkTextViewChild, gtk_text_view_child, GTK, TEXT_VIEW_CHILD, GtkContainer)
G_DECLARE_FINAL_TYPE (GtkTextViewChild, gtk_text_view_child, GTK, TEXT_VIEW_CHILD, GtkWidget)
G_GNUC_INTERNAL
GtkWidget *gtk_text_view_child_new (GtkTextWindowType window_type);
G_GNUC_INTERNAL
GtkTextWindowType gtk_text_view_child_get_window_type (GtkTextViewChild *self);
G_GNUC_INTERNAL
void gtk_text_view_child_add (GtkTextViewChild *self,
GtkWidget *widget);
G_GNUC_INTERNAL
void gtk_text_view_child_remove (GtkTextViewChild *self,
GtkWidget *widget);
G_GNUC_INTERNAL
void gtk_text_view_child_add_overlay (GtkTextViewChild *self,
GtkWidget *widget,