[gnome-builder] editor: add GtkSizeGroup to keep document stack titles the same height
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor: add GtkSizeGroup to keep document stack titles the same height
- Date: Mon, 23 Mar 2015 23:19:53 +0000 (UTC)
commit 1cfd163659384af4f5fca7ae79d0a59a55927907
Author: Christian Hergert <christian hergert me>
Date: Sat Feb 7 17:11:43 2015 -0800
editor: add GtkSizeGroup to keep document stack titles the same height
src/documents/gb-document-grid.c | 58 +++++++++++++++++++++++++++++++
src/documents/gb-document-grid.h | 3 ++
src/documents/gb-document-stack.c | 27 ++++++++++++++
src/editor/gb-editor-workspace.c | 4 ++-
src/resources/ui/gb-editor-workspace.ui | 7 ++++
5 files changed, 98 insertions(+), 1 deletions(-)
---
diff --git a/src/documents/gb-document-grid.c b/src/documents/gb-document-grid.c
index a54bd8d..a14b737 100644
--- a/src/documents/gb-document-grid.c
+++ b/src/documents/gb-document-grid.c
@@ -28,6 +28,7 @@ struct _GbDocumentGridPrivate
{
GbDocumentManager *document_manager;
GbDocumentStack *last_focus;
+ GtkSizeGroup *title_size_group;
};
G_DEFINE_TYPE_WITH_PRIVATE (GbDocumentGrid, gb_document_grid, GTK_TYPE_BIN)
@@ -35,6 +36,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (GbDocumentGrid, gb_document_grid, GTK_TYPE_BIN)
enum {
PROP_0,
PROP_DOCUMENT_MANAGER,
+ PROP_TITLE_SIZE_GROUP,
LAST_PROP
};
@@ -839,6 +841,39 @@ gb_document_grid_parent_set (GtkWidget *widget,
}
}
+GtkSizeGroup *
+gb_document_grid_get_title_size_group (GbDocumentGrid *grid)
+{
+ g_return_val_if_fail (GB_IS_DOCUMENT_GRID (grid), NULL);
+
+ return grid->priv->title_size_group;
+}
+
+void
+gb_document_grid_set_title_size_group (GbDocumentGrid *grid,
+ GtkSizeGroup *title_size_group)
+{
+ GbDocumentGridPrivate *priv;
+
+ g_return_if_fail (GB_IS_DOCUMENT_GRID (grid));
+
+ priv = grid->priv;
+
+ if (g_set_object (&priv->title_size_group, title_size_group))
+ {
+ GList *stacks;
+ GList *iter;
+
+ stacks = gb_document_grid_get_stacks (grid);
+ for (iter = stacks; iter; iter = iter->next)
+ g_object_set (iter->data, "title-size-group", title_size_group, NULL);
+ g_list_free (stacks);
+
+ g_object_notify_by_pspec (G_OBJECT (grid),
+ gParamSpecs [PROP_TITLE_SIZE_GROUP]);
+ }
+}
+
static void
gb_document_grid_get_property (GObject *object,
guint prop_id,
@@ -853,6 +888,10 @@ gb_document_grid_get_property (GObject *object,
g_value_set_object (value, gb_document_grid_get_document_manager (self));
break;
+ case PROP_TITLE_SIZE_GROUP:
+ g_value_set_object (value, gb_document_grid_get_title_size_group (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -872,6 +911,10 @@ gb_document_grid_set_property (GObject *object,
gb_document_grid_set_document_manager (self, g_value_get_object (value));
break;
+ case PROP_TITLE_SIZE_GROUP:
+ gb_document_grid_set_title_size_group (self, g_value_get_object (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -921,6 +964,21 @@ gb_document_grid_class_init (GbDocumentGridClass *klass)
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_DOCUMENT_MANAGER,
gParamSpecs [PROP_DOCUMENT_MANAGER]);
+
+ /**
+ * GbDocumentGrid:title-size-group:
+ *
+ * A #GtkSizeGroup to be applied to document stacks. This can be used to
+ * enforce the height across a row of stacks.
+ */
+ gParamSpecs [PROP_TITLE_SIZE_GROUP] =
+ g_param_spec_object ("title-size-group",
+ _("Title Size Group"),
+ _("A size group to apply to stack titles."),
+ GTK_TYPE_SIZE_GROUP,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_TITLE_SIZE_GROUP,
+ gParamSpecs [PROP_TITLE_SIZE_GROUP]);
}
static void
diff --git a/src/documents/gb-document-grid.h b/src/documents/gb-document-grid.h
index a9c73b6..d6bc40a 100644
--- a/src/documents/gb-document-grid.h
+++ b/src/documents/gb-document-grid.h
@@ -68,6 +68,9 @@ GList *gb_document_grid_get_stacks (GbDocumentGrid *gri
void gb_document_grid_focus_document (GbDocumentGrid *grid,
GbDocument *document);
void gb_document_grid_close_untitled (GbDocumentGrid *grid);
+GtkSizeGroup *gb_document_grid_get_title_size_group (GbDocumentGrid *grid);
+void gb_document_grid_set_title_size_group (GbDocumentGrid *grid,
+ GtkSizeGroup *size_group);
G_END_DECLS
diff --git a/src/documents/gb-document-stack.c b/src/documents/gb-document-stack.c
index 7a26da8..8162c21 100644
--- a/src/documents/gb-document-stack.c
+++ b/src/documents/gb-document-stack.c
@@ -39,6 +39,7 @@ struct _GbDocumentStackPrivate
GtkStack *controls;
GtkStack *stack;
GtkMenuButton *stack_menu;
+ GtkBox *header_box;
};
G_DEFINE_TYPE_WITH_PRIVATE (GbDocumentStack, gb_document_stack, GTK_TYPE_BOX)
@@ -47,6 +48,7 @@ enum {
PROP_0,
PROP_ACTIVE_VIEW,
PROP_DOCUMENT_MANAGER,
+ PROP_TITLE_SIZE_GROUP,
LAST_PROP
};
@@ -791,6 +793,16 @@ gb_document_stack_next_document_activate (GSimpleAction *action,
}
static void
+gb_document_stack_set_title_size_group (GbDocumentStack *self,
+ GtkSizeGroup *size_group)
+{
+ g_return_if_fail (GB_IS_DOCUMENT_STACK (self));
+
+ if (size_group)
+ gtk_size_group_add_widget (size_group, GTK_WIDGET (self->priv->header_box));
+}
+
+static void
gb_document_stack_finalize (GObject *object)
{
GbDocumentStackPrivate *priv = GB_DOCUMENT_STACK (object)->priv;
@@ -843,6 +855,10 @@ gb_document_stack_set_property (GObject *object,
gb_document_stack_set_document_manager (self, g_value_get_object (value));
break;
+ case PROP_TITLE_SIZE_GROUP:
+ gb_document_stack_set_title_size_group (self, g_value_get_object (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -866,6 +882,7 @@ gb_document_stack_class_init (GbDocumentStackClass *klass)
gtk_widget_class_bind_template_child_internal_private (widget_class, GbDocumentStack, stack_menu);
gtk_widget_class_bind_template_child_internal_private (widget_class, GbDocumentStack, controls);
gtk_widget_class_bind_template_child_internal_private (widget_class, GbDocumentStack, document_button);
+ gtk_widget_class_bind_template_child_internal_private (widget_class, GbDocumentStack, header_box);
gParamSpecs [PROP_ACTIVE_VIEW] =
g_param_spec_object ("active-view",
@@ -885,6 +902,16 @@ gb_document_stack_class_init (GbDocumentStackClass *klass)
g_object_class_install_property (object_class, PROP_DOCUMENT_MANAGER,
gParamSpecs [PROP_DOCUMENT_MANAGER]);
+ gParamSpecs [PROP_TITLE_SIZE_GROUP] =
+ g_param_spec_object ("title-size-group",
+ _("Title Size Group"),
+ _("The size group for the titlebar."),
+ GTK_TYPE_SIZE_GROUP,
+ (G_PARAM_WRITABLE |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_TITLE_SIZE_GROUP,
+ gParamSpecs [PROP_TITLE_SIZE_GROUP]);
+
gSignals [CREATE_VIEW] =
g_signal_new ("create-view",
GB_TYPE_DOCUMENT_STACK,
diff --git a/src/editor/gb-editor-workspace.c b/src/editor/gb-editor-workspace.c
index adda68d..11f035f 100644
--- a/src/editor/gb-editor-workspace.c
+++ b/src/editor/gb-editor-workspace.c
@@ -45,8 +45,10 @@ struct _GbEditorWorkspacePrivate
{
GHashTable *command_map;
GtkPaned *paned;
- GbDocumentGrid *document_grid;
gchar *current_folder_uri;
+
+ GbDocumentGrid *document_grid;
+ GtkSizeGroup *title_size_group;
};
G_DEFINE_TYPE_WITH_PRIVATE (GbEditorWorkspace, gb_editor_workspace,
diff --git a/src/resources/ui/gb-editor-workspace.ui b/src/resources/ui/gb-editor-workspace.ui
index c1d0f01..3d8c229 100644
--- a/src/resources/ui/gb-editor-workspace.ui
+++ b/src/resources/ui/gb-editor-workspace.ui
@@ -40,9 +40,16 @@
<object class="GbDocumentGrid" id="document_grid">
<property name="visible">True</property>
<property name="hexpand">True</property>
+ <property name="title_size_group">title_size_group</property>
</object>
</child>
</object>
</child>
</template>
+ <object class="GtkSizeGroup" id="title_size_group">
+ <property name="mode">vertical</property>
+ <widgets>
+ <widget name="project_label"/>
+ </widgets>
+ </object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]