tab: don't inherit from GtkBox

We need center box anyway, which does not expose the class.
This commit is contained in:
Christian Hergert
2021-10-01 13:27:18 -07:00
parent fe290a588b
commit 1085fbb6c5
3 changed files with 32 additions and 53 deletions

View File

@ -28,8 +28,9 @@
struct _SysprofTab
{
GtkBox parent_instance;
GtkWidget parent_instance;
GtkWidget *center_box;
GtkButton *close_button;
GtkLabel *title;
GtkImage *recording;
@ -37,7 +38,7 @@ struct _SysprofTab
SysprofDisplay *display;
};
G_DEFINE_TYPE (SysprofTab, sysprof_tab, GTK_TYPE_BOX)
G_DEFINE_TYPE (SysprofTab, sysprof_tab, GTK_TYPE_WIDGET)
enum {
PROP_0,
@ -71,6 +72,7 @@ sysprof_tab_dispose (GObject *object)
{
SysprofTab *self = (SysprofTab *)object;
g_clear_pointer (&self->center_box, gtk_widget_unparent);
g_clear_weak_pointer (&self->display);
G_OBJECT_CLASS (sysprof_tab_parent_class)->dispose (object);
@ -127,6 +129,8 @@ sysprof_tab_class_init (SysprofTabClass *klass)
object_class->set_property = sysprof_tab_set_property;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-tab.ui");
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
gtk_widget_class_bind_template_child (widget_class, SysprofTab, center_box);
gtk_widget_class_bind_template_child (widget_class, SysprofTab, close_button);
gtk_widget_class_bind_template_child (widget_class, SysprofTab, recording);
gtk_widget_class_bind_template_child (widget_class, SysprofTab, title);

View File

@ -28,7 +28,7 @@ G_BEGIN_DECLS
#define SYSPROF_TYPE_TAB (sysprof_tab_get_type())
G_DECLARE_FINAL_TYPE (SysprofTab, sysprof_tab, SYSPROF, TAB, GtkBox)
G_DECLARE_FINAL_TYPE (SysprofTab, sysprof_tab, SYSPROF, TAB, GtkWidget)
GtkWidget *sysprof_tab_new (SysprofDisplay *display);

View File

@ -1,60 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<template class="SysprofTab" parent="GtkBox">
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<template class="SysprofTab" parent="GtkWidget">
<property name="hexpand">true</property>
<property name="spacing">6</property>
<child>
<object class="GtkImage" id="recording">
<property name="visible">false</property>
<property name="icon-name">media-record-symbolic</property>
<property name="pixel-size">16</property>
<property name="hexpand">true</property>
<property name="halign">end</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="pack-type">start</property>
</packing>
</child>
<child type="center">
<object class="GtkLabel" id="title">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="close_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">window-close-symbolic</property>
<object class="GtkCenterBox" id="center_box">
<child type="start">
<object class="GtkImage" id="recording">
<property name="visible">false</property>
<property name="icon-name">media-record-symbolic</property>
<property name="pixel-size">16</property>
<property name="hexpand">true</property>
<property name="halign">end</property>
</object>
</child>
<child type="center">
<object class="GtkLabel" id="title">
</object>
</child>
<child type="end">
<object class="GtkButton" id="close_button">
<property name="receives_default">False</property>
<property name="icon_name">window-close-symbolic</property>
<style>
<class name="flat"/>
<class name="small-button"/>
<class name="image-button"/>
</style>
</object>
</child>
<style>
<class name="flat"/>
<class name="small-button"/>
</style>
</object>
<packing>
<property name="pack-type">end</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</template>
</interface>