Commit 0e0b4560 authored by Emmanuele Bassi's avatar Emmanuele Bassi

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.
parent 73497c16
......@@ -1126,6 +1126,7 @@ templates = \
ui/gtksearchbar.ui \
ui/gtkscalebutton.ui \
ui/gtkstatusbar.ui \
ui/gtktooltipwindow.ui \
ui/gtkvolumebutton.ui \
ui/gtksidebarrow.ui
......
......@@ -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 *
......
<?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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment