mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
snapshot: Convert GtkButton and subclasses
This commit is contained in:
parent
4c9033b62d
commit
ab47479045
@ -125,8 +125,7 @@ static void gtk_button_map (GtkWidget * widget);
|
||||
static void gtk_button_unmap (GtkWidget * widget);
|
||||
static void gtk_button_size_allocate (GtkWidget * widget,
|
||||
GtkAllocation * allocation);
|
||||
static GskRenderNode *gtk_button_get_render_node (GtkWidget *widget,
|
||||
GskRenderer *renderer);
|
||||
static void gtk_button_snapshot (GtkWidget * widget, GtkSnapshot *snapshot);
|
||||
static gint gtk_button_grab_broken (GtkWidget * widget,
|
||||
GdkEventGrabBroken * event);
|
||||
static gint gtk_button_key_release (GtkWidget * widget, GdkEventKey * event);
|
||||
@ -170,6 +169,13 @@ static void gtk_button_allocate (GtkCssGadget *gadget,
|
||||
GtkAllocation *out_clip,
|
||||
gpointer data);
|
||||
static void gtk_button_set_child_type (GtkButton *button, guint child_type);
|
||||
static gboolean gtk_button_render (GtkCssGadget *gadget,
|
||||
GtkSnapshot *snapshot,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
gpointer data);
|
||||
|
||||
static GParamSpec *props[LAST_PROP] = { NULL, };
|
||||
static guint button_signals[LAST_SIGNAL] = { 0 };
|
||||
@ -224,7 +230,7 @@ gtk_button_class_init (GtkButtonClass *klass)
|
||||
widget_class->map = gtk_button_map;
|
||||
widget_class->unmap = gtk_button_unmap;
|
||||
widget_class->size_allocate = gtk_button_size_allocate;
|
||||
widget_class->get_render_node = gtk_button_get_render_node;
|
||||
widget_class->snapshot = gtk_button_snapshot;
|
||||
widget_class->grab_broken_event = gtk_button_grab_broken;
|
||||
widget_class->key_release_event = gtk_button_key_release;
|
||||
widget_class->enter_notify_event = gtk_button_enter_notify;
|
||||
@ -474,7 +480,7 @@ gtk_button_init (GtkButton *button)
|
||||
gtk_button_measure,
|
||||
gtk_button_allocate,
|
||||
NULL,
|
||||
NULL,
|
||||
gtk_button_render,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
@ -886,20 +892,29 @@ gtk_button_allocate (GtkCssGadget *gadget,
|
||||
gtk_container_get_children_clip (GTK_CONTAINER (widget), out_clip);
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
gtk_button_get_render_node (GtkWidget *widget,
|
||||
GskRenderer *renderer)
|
||||
static void
|
||||
gtk_button_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GskRenderNode *res = gtk_css_gadget_get_render_node (GTK_BUTTON (widget)->priv->gadget,
|
||||
renderer,
|
||||
gtk_widget_has_visible_focus (widget));
|
||||
gtk_css_gadget_snapshot (GTK_BUTTON (widget)->priv->gadget, snapshot);
|
||||
}
|
||||
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
static gboolean
|
||||
gtk_button_render (GtkCssGadget *gadget,
|
||||
GtkSnapshot *snapshot,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
gtk_container_propagate_render_node (GTK_CONTAINER (widget), renderer, res);
|
||||
widget = gtk_css_gadget_get_owner (gadget);
|
||||
|
||||
return res;
|
||||
GTK_WIDGET_CLASS (gtk_button_parent_class)->snapshot (widget, snapshot);
|
||||
|
||||
return gtk_widget_has_visible_focus (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -80,9 +80,8 @@
|
||||
|
||||
static void gtk_check_button_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static GskRenderNode *gtk_check_button_get_render_node (GtkWidget *widget,
|
||||
GskRenderer *renderer);
|
||||
|
||||
static void gtk_check_button_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot);
|
||||
|
||||
typedef struct {
|
||||
GtkCssGadget *gadget;
|
||||
@ -210,7 +209,7 @@ gtk_check_button_class_init (GtkCheckButtonClass *class)
|
||||
|
||||
widget_class->measure = gtk_check_button_measure;
|
||||
widget_class->size_allocate = gtk_check_button_size_allocate;
|
||||
widget_class->get_render_node = gtk_check_button_get_render_node;
|
||||
widget_class->snapshot = gtk_check_button_snapshot;
|
||||
widget_class->state_flags_changed = gtk_check_button_state_flags_changed;
|
||||
widget_class->direction_changed = gtk_check_button_direction_changed;
|
||||
|
||||
@ -382,18 +381,16 @@ gtk_check_button_size_allocate (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
gtk_check_button_get_render_node (GtkWidget *widget,
|
||||
GskRenderer *renderer)
|
||||
static void
|
||||
gtk_check_button_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (GTK_CHECK_BUTTON (widget));
|
||||
|
||||
if (!gtk_toggle_button_get_mode (GTK_TOGGLE_BUTTON (widget)))
|
||||
return GTK_WIDGET_CLASS (gtk_check_button_parent_class)->get_render_node (widget, renderer);
|
||||
GTK_WIDGET_CLASS (gtk_check_button_parent_class)->snapshot (widget, snapshot);
|
||||
else
|
||||
return gtk_css_gadget_get_render_node (priv->gadget,
|
||||
renderer,
|
||||
gtk_widget_has_visible_focus (widget));
|
||||
gtk_css_gadget_snapshot (priv->gadget, snapshot);
|
||||
}
|
||||
|
||||
GtkCssNode *
|
||||
|
@ -899,6 +899,46 @@ gtk_model_button_allocate (GtkCssGadget *gadget,
|
||||
gdk_rectangle_union (out_clip, &check_clip, out_clip);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_model_button_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkCssGadget *gadget;
|
||||
|
||||
if (GTK_MODEL_BUTTON (widget)->iconic)
|
||||
gadget = GTK_BUTTON (widget)->priv->gadget;
|
||||
else
|
||||
gadget = GTK_MODEL_BUTTON (widget)->gadget;
|
||||
|
||||
gtk_css_gadget_snapshot (gadget, snapshot);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_model_button_render (GtkCssGadget *gadget,
|
||||
GtkSnapshot *snapshot,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkModelButton *button;
|
||||
GtkWidget *child;
|
||||
|
||||
widget = gtk_css_gadget_get_owner (gadget);
|
||||
button = GTK_MODEL_BUTTON (widget);
|
||||
|
||||
if (gtk_css_node_get_visible (gtk_css_gadget_get_node (button->indicator_gadget)))
|
||||
gtk_css_gadget_snapshot (button->indicator_gadget, snapshot);
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (widget));
|
||||
if (child)
|
||||
gtk_container_snapshot_child (GTK_CONTAINER (widget), child, snapshot);
|
||||
|
||||
return gtk_widget_has_visible_focus (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_model_button_destroy (GtkWidget *widget)
|
||||
{
|
||||
@ -943,38 +983,6 @@ gtk_model_button_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (gtk_model_button_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
gtk_model_button_get_render_node (GtkWidget *widget, GskRenderer *renderer)
|
||||
{
|
||||
GtkCssGadget *button_gadget;
|
||||
GskRenderNode *button_node;
|
||||
GskRenderNode *indicator_node;
|
||||
|
||||
if (GTK_MODEL_BUTTON (widget)->iconic)
|
||||
button_gadget = GTK_BUTTON (widget)->priv->gadget;
|
||||
else
|
||||
button_gadget = GTK_MODEL_BUTTON (widget)->gadget;
|
||||
|
||||
button_node = gtk_css_gadget_get_render_node (button_gadget, renderer,
|
||||
gtk_widget_has_visible_focus (widget));
|
||||
|
||||
if (button_node == NULL)
|
||||
return NULL;
|
||||
|
||||
indicator_node = gtk_css_gadget_get_render_node (GTK_MODEL_BUTTON (widget)->indicator_gadget,
|
||||
renderer, FALSE);
|
||||
|
||||
if (indicator_node != NULL)
|
||||
{
|
||||
gsk_render_node_append_child (button_node, indicator_node);
|
||||
gsk_render_node_unref (indicator_node);
|
||||
}
|
||||
|
||||
gtk_container_propagate_render_node (GTK_CONTAINER (widget), renderer, button_node);
|
||||
|
||||
return button_node;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_model_button_class_init (GtkModelButtonClass *class)
|
||||
{
|
||||
@ -988,10 +996,10 @@ gtk_model_button_class_init (GtkModelButtonClass *class)
|
||||
|
||||
widget_class->measure = gtk_model_button_measure_;
|
||||
widget_class->size_allocate = gtk_model_button_size_allocate;
|
||||
widget_class->snapshot = gtk_model_button_snapshot;
|
||||
widget_class->destroy = gtk_model_button_destroy;
|
||||
widget_class->state_flags_changed = gtk_model_button_state_flags_changed;
|
||||
widget_class->direction_changed = gtk_model_button_direction_changed;
|
||||
widget_class->get_render_node = gtk_model_button_get_render_node;
|
||||
|
||||
button_class->clicked = gtk_model_button_clicked;
|
||||
|
||||
@ -1147,7 +1155,7 @@ gtk_model_button_init (GtkModelButton *button)
|
||||
gtk_model_button_measure,
|
||||
gtk_model_button_allocate,
|
||||
NULL,
|
||||
NULL,
|
||||
gtk_model_button_render,
|
||||
NULL,
|
||||
NULL);
|
||||
button->indicator_gadget = gtk_builtin_icon_new ("check",
|
||||
|
Loading…
Reference in New Issue
Block a user