[gtk+/wip/otte/gadget: 5/8] iconhelper: Finish gadget conversion
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/gadget: 5/8] iconhelper: Finish gadget conversion
- Date: Mon, 14 Dec 2015 17:55:48 +0000 (UTC)
commit 8f00ba126f6b01eeef5b5ca23ffb807dba837575
Author: Benjamin Otte <otte redhat com>
Date: Mon Dec 14 04:00:31 2015 +0100
iconhelper: Finish gadget conversion
Implement missing vfuncs
gtk/gtkiconhelper.c | 77 ++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkiconhelperprivate.h | 2 +
2 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index bc82ee0..deac87c 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -84,6 +84,60 @@ _gtk_icon_helper_clear (GtkIconHelper *self)
}
static void
+gtk_icon_helper_get_preferred_size (GtkCssGadget *gadget,
+ GtkOrientation orientation,
+ gint for_size,
+ gint *minimum,
+ gint *natural,
+ gint *minimum_baseline,
+ gint *natural_baseline)
+{
+ GtkIconHelper *self = GTK_ICON_HELPER (gadget);
+ int icon_width, icon_height;
+
+ _gtk_icon_helper_get_size (self, &icon_width, &icon_height);
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ *minimum = *natural = icon_width;
+ else
+ *minimum = *natural = icon_height;
+
+ if (minimum_baseline)
+ *minimum_baseline = 0;
+ if (natural_baseline)
+ *natural_baseline = 0;
+}
+
+static void
+gtk_icon_helper_allocate (GtkCssGadget *gadget,
+ const GtkAllocation *allocation,
+ int baseline,
+ GtkAllocation *out_clip)
+{
+ GTK_CSS_GADGET_CLASS (gtk_icon_helper_parent_class)->allocate (gadget, allocation, baseline, out_clip);
+}
+
+static gboolean
+gtk_icon_helper_draw (GtkCssGadget *gadget,
+ cairo_t *cr,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ GtkIconHelper *self = GTK_ICON_HELPER (gadget);
+ int icon_width, icon_height;
+
+ _gtk_icon_helper_get_size (self, &icon_width, &icon_height);
+ _gtk_icon_helper_draw (self,
+ cr,
+ x + (width - icon_width) / 2,
+ y + (height - icon_height) / 2);
+
+ return FALSE;
+}
+
+static void
gtk_icon_helper_style_changed (GtkCssGadget *gadget,
GtkCssStyleChange *change)
{
@@ -128,6 +182,9 @@ gtk_icon_helper_class_init (GtkIconHelperClass *klass)
GtkCssGadgetClass *gadget_class = GTK_CSS_GADGET_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ gadget_class->get_preferred_size = gtk_icon_helper_get_preferred_size;
+ gadget_class->allocate = gtk_icon_helper_allocate;
+ gadget_class->draw = gtk_icon_helper_draw;
gadget_class->style_changed = gtk_icon_helper_style_changed;
object_class->constructed = gtk_icon_helper_constructed;
@@ -783,6 +840,26 @@ gtk_icon_helper_new (GtkCssNode *node,
NULL);
}
+GtkCssGadget *
+gtk_icon_helper_new_named (const char *name,
+ GtkWidget *owner)
+{
+ GtkIconHelper *result;
+ GtkCssNode *node;
+
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_WIDGET (owner), NULL);
+
+ node = gtk_css_node_new ();
+ gtk_css_node_set_name (node, g_intern_string (name));
+
+ result = gtk_icon_helper_new (node, owner);
+
+ g_object_unref (node);
+
+ return GTK_CSS_GADGET (result);
+}
+
void
_gtk_icon_helper_draw (GtkIconHelper *self,
cairo_t *cr,
diff --git a/gtk/gtkiconhelperprivate.h b/gtk/gtkiconhelperprivate.h
index fc3acf0..291fb40 100644
--- a/gtk/gtkiconhelperprivate.h
+++ b/gtk/gtkiconhelperprivate.h
@@ -70,6 +70,8 @@ GType gtk_icon_helper_get_type (void) G_GNUC_CONST;
GtkIconHelper *gtk_icon_helper_new (GtkCssNode *node,
GtkWidget *owner);
+GtkCssGadget *gtk_icon_helper_new_named (const char *name,
+ GtkWidget *owner);
void _gtk_icon_helper_clear (GtkIconHelper *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]