[gtk+] tooltipwindow: Use a builder UI file
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] tooltipwindow: Use a builder UI file
- Date: Wed, 11 Nov 2015 12:29:37 +0000 (UTC)
commit 0e0b45602a8d74d4ddd3633118679a0b0fa09a35
Author: Emmanuele Bassi <ebassi gnome org>
Date: Wed Nov 11 12:27:07 2015 +0000
tooltipwindow: Use a builder UI file
It's not a hugely complicated file, but it's easier to deal with some of
the details of tooltip windows styling if we have a UI file to edit,
instead of source code.
gtk/Makefile.am | 1 +
gtk/gtktooltipwindow.c | 27 +++++++--------------------
gtk/ui/gtktooltipwindow.ui | 41 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+), 20 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index fd49c14..3c57ca5 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -1126,6 +1126,7 @@ templates = \
ui/gtksearchbar.ui \
ui/gtkscalebutton.ui \
ui/gtkstatusbar.ui \
+ ui/gtktooltipwindow.ui \
ui/gtkvolumebutton.ui \
ui/gtksidebarrow.ui
diff --git a/gtk/gtktooltipwindow.c b/gtk/gtktooltipwindow.c
index cb7cb53..4c9d517 100644
--- a/gtk/gtktooltipwindow.c
+++ b/gtk/gtktooltipwindow.c
@@ -65,6 +65,11 @@ gtk_tooltip_window_class_init (GtkTooltipWindowClass *klass)
gtk_widget_class_set_css_name (widget_class, I_("tooltip"));
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_TOOL_TIP);
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/ui/gtktooltipwindow.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, GtkTooltipWindow, box);
+ gtk_widget_class_bind_template_child (widget_class, GtkTooltipWindow, image);
+ gtk_widget_class_bind_template_child (widget_class, GtkTooltipWindow, label);
}
static void
@@ -72,28 +77,10 @@ gtk_tooltip_window_init (GtkTooltipWindow *self)
{
GtkWindow *window = GTK_WINDOW (self);
- gtk_window_set_type_hint (window, GDK_WINDOW_TYPE_HINT_TOOLTIP);
- gtk_window_set_resizable (window, FALSE);
- gtk_window_set_use_subsurface (window, TRUE);
+ gtk_widget_init_template (GTK_WIDGET (self));
+ gtk_window_set_use_subsurface (window, TRUE);
_gtk_window_request_csd (window);
-
- /* FIXME: don't hardcode the padding */
- self->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_widget_set_margin_start (self->box, 6);
- gtk_widget_set_margin_end (self->box, 6);
- gtk_widget_set_margin_top (self->box, 6);
- gtk_widget_set_margin_bottom (self->box, 6);
- gtk_container_add (GTK_CONTAINER (self), self->box);
- gtk_widget_show (self->box);
-
- self->image = gtk_image_new ();
- gtk_box_pack_start (GTK_BOX (self->box), self->image, FALSE, FALSE, 0);
-
- self->label = gtk_label_new ("");
- gtk_label_set_line_wrap (GTK_LABEL (self->label), TRUE);
- gtk_label_set_max_width_chars (GTK_LABEL (self->label), MAX_TOOLTIP_LINE_WIDTH);
- gtk_box_pack_start (GTK_BOX (self->box), self->label, FALSE, FALSE, 0);
}
GtkWidget *
diff --git a/gtk/ui/gtktooltipwindow.ui b/gtk/ui/gtktooltipwindow.ui
new file mode 100644
index 0000000..1cb2de0
--- /dev/null
+++ b/gtk/ui/gtktooltipwindow.ui
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="gtk30">
+ <!-- interface-requires gtk+ 3.10 -->
+ <template class="GtkTooltipWindow" parent="GtkWindow">
+ <property name="resizable">0</property>
+ <property name="type_hint">tooltip</property>
+ <child>
+ <object class="GtkBox" id="box">
+ <property name="orientation">horizontal</property>
+ <property name="visible">1</property>
+ <property name="spacing">6</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="margin_start">6</property>
+ <property name="margin_end">6</property>
+ <child>
+ <object class="GtkImage" id="image">
+ <property name="visible">0</property>
+ <property name="icon_name">image-missing</property>
+ </object>
+ <packing>
+ <property name="fill">0</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">0</property>
+ <property name="wrap">1</property>
+ <property name="max_width_chars">70</property>
+ <property name="label"></property>
+ </object>
+ <packing>
+ <property name="fill">0</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]