diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2015-11-11 12:27:07 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2015-11-11 12:27:07 +0000 |
commit | 0e0b45602a8d74d4ddd3633118679a0b0fa09a35 (patch) | |
tree | 03c4829847ce8256c7beb417af99ad86ac23425a /gtk/gtktooltipwindow.c | |
parent | 73497c16aed5f05d35c212be63a8a1f71de6ae88 (diff) | |
download | gtk+-0e0b45602a8d74d4ddd3633118679a0b0fa09a35.tar.gz |
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.
Diffstat (limited to 'gtk/gtktooltipwindow.c')
-rw-r--r-- | gtk/gtktooltipwindow.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/gtk/gtktooltipwindow.c b/gtk/gtktooltipwindow.c index cb7cb53fc9..4c9d51715a 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 * |