[gnome-builder/wip/gtk4-port: 313/343] libide/gui: add API for workspaces to have statusbars
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 313/343] libide/gui: add API for workspaces to have statusbars
- Date: Mon, 4 Apr 2022 20:02:20 +0000 (UTC)
commit ee4c6dfceba3f6d3f01b8e895aaec0de6e6d2c14
Author: Christian Hergert <chergert redhat com>
Date: Sat Apr 2 02:48:59 2022 -0700
libide/gui: add API for workspaces to have statusbars
And also be able to retrieve them at will.
src/libide/gui/ide-primary-workspace.ui | 2 +-
src/libide/gui/ide-workspace.c | 65 ++++++++++++++++++++++++++++++++-
src/libide/gui/ide-workspace.h | 35 ++++++++++--------
3 files changed, 84 insertions(+), 18 deletions(-)
---
diff --git a/src/libide/gui/ide-primary-workspace.ui b/src/libide/gui/ide-primary-workspace.ui
index ab550e306..06709b5e0 100644
--- a/src/libide/gui/ide-primary-workspace.ui
+++ b/src/libide/gui/ide-primary-workspace.ui
@@ -82,7 +82,7 @@
</child>
</object>
</child>
- <child>
+ <child internal-child="statusbar">
<object class="PanelStatusbar">
<child type="suffix">
<object class="PanelDockSwitcher">
diff --git a/src/libide/gui/ide-workspace.c b/src/libide/gui/ide-workspace.c
index dce5380ca..68920df2b 100644
--- a/src/libide/gui/ide-workspace.c
+++ b/src/libide/gui/ide-workspace.c
@@ -55,6 +55,9 @@ typedef struct
*/
IdeExtensionSetAdapter *addins;
+ /* A statusbar, if any, that was added to the workspace */
+ PanelStatusbar *statusbar;
+
/* A MRU that is updated as pages are focused. It allows us to move through
* the pages in the order they've been most-recently focused.
*/
@@ -556,6 +559,12 @@ ide_workspace_init (IdeWorkspace *self)
adw_application_window_set_content (ADW_APPLICATION_WINDOW (self),
GTK_WIDGET (priv->box));
+ if (IDE_WORKSPACE_GET_CLASS (self)->has_statusbar)
+ {
+ priv->statusbar = PANEL_STATUSBAR (panel_statusbar_new ());
+ gtk_box_append (priv->box, GTK_WIDGET (priv->statusbar));
+ }
+
/* Track focus change to propagate to addins */
g_signal_connect (self,
"notify::focus-widget",
@@ -851,14 +860,66 @@ ide_workspace_add_child (GtkBuildable *buildable,
if (GTK_IS_WIDGET (object))
{
if (g_strcmp0 (type, "titlebar") == 0)
- gtk_box_prepend (priv->box, GTK_WIDGET (object));
+ {
+ gtk_box_prepend (priv->box, GTK_WIDGET (object));
+ }
else
- gtk_box_append (priv->box, GTK_WIDGET (object));
+ {
+ gtk_box_append (priv->box, GTK_WIDGET (object));
+
+ if (priv->statusbar != NULL)
+ gtk_box_reorder_child_after (priv->box, GTK_WIDGET (priv->statusbar), GTK_WIDGET (object));
+ }
}
}
+static GObject *
+ide_workspace_get_internal_child (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ const char *id)
+{
+ IdeWorkspace *self = (IdeWorkspace *)buildable;
+ IdeWorkspacePrivate *priv = ide_workspace_get_instance_private (self);
+
+ g_assert (IDE_IS_WORKSPACE (self));
+ g_assert (GTK_IS_BUILDER (builder));
+ g_assert (id != NULL);
+
+ if (g_strcmp0 (id, "statusbar") == 0)
+ {
+ if (priv->statusbar == NULL)
+ {
+ priv->statusbar = PANEL_STATUSBAR (panel_statusbar_new ());
+ gtk_box_append (priv->box, GTK_WIDGET (priv->statusbar));
+ }
+
+ return G_OBJECT (priv->statusbar);
+ }
+
+ return NULL;
+}
+
static void
buildable_iface_init (GtkBuildableIface *iface)
{
iface->add_child = ide_workspace_add_child;
+ iface->get_internal_child = ide_workspace_get_internal_child;
+}
+
+/**
+ * ide_workspace_get_statusbar:
+ * @self: a #IdeWorkspace
+ *
+ * Gets the statusbar if any.
+ *
+ * Returns: (transfer none) (nullable): a #PanelStatusbar or %NULL
+ */
+PanelStatusbar *
+ide_workspace_get_statusbar (IdeWorkspace *self)
+{
+ IdeWorkspacePrivate *priv = ide_workspace_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_WORKSPACE (self), NULL);
+
+ return priv->statusbar;
}
diff --git a/src/libide/gui/ide-workspace.h b/src/libide/gui/ide-workspace.h
index c79d5641e..c69d6cf26 100644
--- a/src/libide/gui/ide-workspace.h
+++ b/src/libide/gui/ide-workspace.h
@@ -51,6 +51,9 @@ struct _IdeWorkspaceClass
const gchar *kind;
+ guint has_statusbar : 1;
+ guint _unused_flags : 31;
+
void (*context_set) (IdeWorkspace *self,
IdeContext *context);
void (*foreach_page) (IdeWorkspace *self,
@@ -80,29 +83,31 @@ struct _IdeWorkspaceClass
};
IDE_AVAILABLE_IN_ALL
-void ide_workspace_class_set_kind (IdeWorkspaceClass *klass,
+void ide_workspace_class_set_kind (IdeWorkspaceClass *klass,
const gchar *kind);
IDE_AVAILABLE_IN_ALL
-IdeHeaderBar *ide_workspace_get_header_bar (IdeWorkspace *self);
+IdeHeaderBar *ide_workspace_get_header_bar (IdeWorkspace *self);
+IDE_AVAILABLE_IN_ALL
+IdeContext *ide_workspace_get_context (IdeWorkspace *self);
IDE_AVAILABLE_IN_ALL
-IdeContext *ide_workspace_get_context (IdeWorkspace *self);
+GCancellable *ide_workspace_get_cancellable (IdeWorkspace *self);
IDE_AVAILABLE_IN_ALL
-GCancellable *ide_workspace_get_cancellable (IdeWorkspace *self);
+void ide_workspace_foreach_page (IdeWorkspace *self,
+ IdePageCallback callback,
+ gpointer user_data);
IDE_AVAILABLE_IN_ALL
-void ide_workspace_foreach_page (IdeWorkspace *self,
- IdePageCallback callback,
- gpointer user_data);
+IdePage *ide_workspace_get_most_recent_page (IdeWorkspace *self);
IDE_AVAILABLE_IN_ALL
-IdePage *ide_workspace_get_most_recent_page (IdeWorkspace *self);
+IdeFrame *ide_workspace_get_most_recent_frame (IdeWorkspace *self);
IDE_AVAILABLE_IN_ALL
-IdeFrame *ide_workspace_get_most_recent_frame (IdeWorkspace *self);
+void ide_workspace_add_pane (IdeWorkspace *self,
+ IdePane *pane,
+ IdePanelPosition *position);
IDE_AVAILABLE_IN_ALL
-void ide_workspace_add_pane (IdeWorkspace *self,
- IdePane *pane,
- IdePanelPosition *position);
+void ide_workspace_add_page (IdeWorkspace *self,
+ IdePage *pane,
+ IdePanelPosition *position);
IDE_AVAILABLE_IN_ALL
-void ide_workspace_add_page (IdeWorkspace *self,
- IdePage *pane,
- IdePanelPosition *position);
+PanelStatusbar *ide_workspace_get_statusbar (IdeWorkspace *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]