[gnome-builder/wip/gtk4-port] libide/gui: add vfunc to get headerbar
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/gui: add vfunc to get headerbar
- Date: Sun, 8 May 2022 19:44:14 +0000 (UTC)
commit 6d8882fbeaab86f2dae44f32fa515170b1092939
Author: Christian Hergert <chergert redhat com>
Date: Sun May 8 12:43:02 2022 -0700
libide/gui: add vfunc to get headerbar
We cant use the fallback GtkWindow API for this as it doesn't work with
libadwaita where all of the window content is within a box.
src/libide/editor/ide-editor-workspace.c | 7 ++++
src/libide/gui/ide-primary-workspace.c | 7 ++++
src/libide/gui/ide-workspace.c | 16 ++++----
src/libide/gui/ide-workspace.h | 67 ++++++++++++++++----------------
4 files changed, 56 insertions(+), 41 deletions(-)
---
diff --git a/src/libide/editor/ide-editor-workspace.c b/src/libide/editor/ide-editor-workspace.c
index 2cd9f14ad..d12edb5a8 100644
--- a/src/libide/editor/ide-editor-workspace.c
+++ b/src/libide/editor/ide-editor-workspace.c
@@ -172,6 +172,12 @@ ide_editor_workspace_can_search (IdeWorkspace *workspace)
return TRUE;
}
+static IdeHeaderBar *
+ide_editor_workspace_get_header_bar (IdeWorkspace *workspace)
+{
+ return IDE_EDITOR_WORKSPACE (workspace)->header_bar;
+}
+
static void
ide_editor_workspace_dispose (GObject *object)
{
@@ -202,6 +208,7 @@ ide_editor_workspace_class_init (IdeEditorWorkspaceClass *klass)
workspace_class->context_set = ide_editor_workspace_context_set;
workspace_class->get_frame_at_position = ide_editor_workspace_get_frame_at_position;
workspace_class->get_most_recent_frame = ide_editor_workspace_get_most_recent_frame;
+ workspace_class->get_header_bar = ide_editor_workspace_get_header_bar;
ide_workspace_class_set_kind (workspace_class, "editor");
diff --git a/src/libide/gui/ide-primary-workspace.c b/src/libide/gui/ide-primary-workspace.c
index 56aeb7574..48fc5e071 100644
--- a/src/libide/gui/ide-primary-workspace.c
+++ b/src/libide/gui/ide-primary-workspace.c
@@ -179,6 +179,12 @@ ide_primary_workspace_can_search (IdeWorkspace *workspace)
return TRUE;
}
+static IdeHeaderBar *
+ide_primary_workspace_get_header_bar (IdeWorkspace *workspace)
+{
+ return IDE_PRIMARY_WORKSPACE (workspace)->header_bar;
+}
+
static void
ide_primary_workspace_dispose (GObject *object)
{
@@ -211,6 +217,7 @@ ide_primary_workspace_class_init (IdePrimaryWorkspaceClass *klass)
workspace_class->context_set = ide_primary_workspace_context_set;
workspace_class->get_frame_at_position = ide_primary_workspace_get_frame_at_position;
workspace_class->get_most_recent_frame = ide_primary_workspace_get_most_recent_frame;
+ workspace_class->get_header_bar = ide_primary_workspace_get_header_bar;
ide_workspace_class_set_kind (workspace_class, "primary");
diff --git a/src/libide/gui/ide-workspace.c b/src/libide/gui/ide-workspace.c
index 02bbdca83..955ec7944 100644
--- a/src/libide/gui/ide-workspace.c
+++ b/src/libide/gui/ide-workspace.c
@@ -452,6 +452,12 @@ ide_workspace_real_can_search (IdeWorkspace *self)
return FALSE;
}
+static IdeHeaderBar *
+ide_workspace_real_get_header_bar (IdeWorkspace *workspace)
+{
+ return NULL;
+}
+
static void
ide_workspace_dispose (GObject *object)
{
@@ -541,6 +547,7 @@ ide_workspace_class_init (IdeWorkspaceClass *klass)
klass->get_most_recent_frame = ide_workspace_real_get_most_recent_frame;
klass->restore_size = ide_workspace_restore_size;
klass->save_size = ide_workspace_save_size;
+ klass->get_header_bar = ide_workspace_real_get_header_bar;
/**
* IdeWorkspace:context:
@@ -701,16 +708,9 @@ ide_workspace_foreach_page (IdeWorkspace *self,
IdeHeaderBar *
ide_workspace_get_header_bar (IdeWorkspace *self)
{
- GtkWidget *ret = NULL;
-
g_return_val_if_fail (IDE_IS_WORKSPACE (self), NULL);
- ret = gtk_window_get_titlebar (GTK_WINDOW (self));
-
- if (IDE_IS_HEADER_BAR (ret))
- return IDE_HEADER_BAR (ret);
-
- return NULL;
+ return IDE_WORKSPACE_GET_CLASS (self)->get_header_bar (self);
}
/**
diff --git a/src/libide/gui/ide-workspace.h b/src/libide/gui/ide-workspace.h
index d0e29fda6..07631e72f 100644
--- a/src/libide/gui/ide-workspace.h
+++ b/src/libide/gui/ide-workspace.h
@@ -54,39 +54,40 @@ struct _IdeWorkspaceClass
guint has_statusbar : 1;
guint _unused_flags : 31;
- void (*context_set) (IdeWorkspace *self,
- IdeContext *context);
- void (*foreach_page) (IdeWorkspace *self,
- IdePageCallback callback,
- gpointer user_data);
- IdePage *(*get_most_recent_page) (IdeWorkspace *self);
- IdeFrame *(*get_most_recent_frame) (IdeWorkspace *self);
- void (*agree_to_close_async) (IdeWorkspace *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (*agree_to_close_finish) (IdeWorkspace *self,
- GAsyncResult *result,
- GError **error);
- void (*add_pane) (IdeWorkspace *self,
- IdePane *pane,
- IdePanelPosition *position);
- void (*add_page) (IdeWorkspace *self,
- IdePage *page,
- IdePanelPosition *position);
- void (*add_overlay) (IdeWorkspace *self,
- GtkWidget *overlay);
- void (*remove_overlay) (IdeWorkspace *self,
- GtkWidget *overlay);
- PanelFrame *(*get_frame_at_position) (IdeWorkspace *self,
- IdePanelPosition *position);
- void (*restore_size) (IdeWorkspace *self,
- int width,
- int height);
- gboolean (*save_size) (IdeWorkspace *self,
- int *width,
- int *height);
- gboolean (*can_search) (IdeWorkspace *self);
+ void (*context_set) (IdeWorkspace *self,
+ IdeContext *context);
+ void (*foreach_page) (IdeWorkspace *self,
+ IdePageCallback callback,
+ gpointer user_data);
+ IdeHeaderBar *(*get_header_bar) (IdeWorkspace *self);
+ IdePage *(*get_most_recent_page) (IdeWorkspace *self);
+ IdeFrame *(*get_most_recent_frame) (IdeWorkspace *self);
+ void (*agree_to_close_async) (IdeWorkspace *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*agree_to_close_finish) (IdeWorkspace *self,
+ GAsyncResult *result,
+ GError **error);
+ void (*add_pane) (IdeWorkspace *self,
+ IdePane *pane,
+ IdePanelPosition *position);
+ void (*add_page) (IdeWorkspace *self,
+ IdePage *page,
+ IdePanelPosition *position);
+ void (*add_overlay) (IdeWorkspace *self,
+ GtkWidget *overlay);
+ void (*remove_overlay) (IdeWorkspace *self,
+ GtkWidget *overlay);
+ PanelFrame *(*get_frame_at_position) (IdeWorkspace *self,
+ IdePanelPosition *position);
+ void (*restore_size) (IdeWorkspace *self,
+ int width,
+ int height);
+ gboolean (*save_size) (IdeWorkspace *self,
+ int *width,
+ int *height);
+ gboolean (*can_search) (IdeWorkspace *self);
};
IDE_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]