[gnome-builder/wip/gtk4-port] libide/editor: use IdePanelPosition for destination frame
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/editor: use IdePanelPosition for destination frame
- Date: Thu, 7 Apr 2022 22:09:24 +0000 (UTC)
commit 100dc7a8c52c42c2a2d502c5549ba217e1ea5da8
Author: Christian Hergert <chergert redhat com>
Date: Thu Apr 7 15:09:20 2022 -0700
libide/editor: use IdePanelPosition for destination frame
This ensures that we use the panel position across all of the plubming. It
fixes the last step in making sure that when we open a new document it can
be opened in an open frame before always landing on top of the document
that is currently open.
src/libide/editor/ide-editor.c | 52 ++++++++++------------
src/libide/editor/ide-editor.h | 12 ++---
src/libide/lsp/ide-lsp-search-result.c | 7 +--
.../editorui/gbp-editorui-workbench-addin.c | 6 +--
4 files changed, 33 insertions(+), 44 deletions(-)
---
diff --git a/src/libide/editor/ide-editor.c b/src/libide/editor/ide-editor.c
index 9d2f443a7..64cbf886d 100644
--- a/src/libide/editor/ide-editor.c
+++ b/src/libide/editor/ide-editor.c
@@ -37,10 +37,10 @@ typedef struct _Focus
} Focus;
static Focus *
-focus_new (IdeWorkspace *workspace,
- IdeFrame *frame,
- IdeBuffer *buffer,
- IdeLocation *location)
+focus_new (IdeWorkspace *workspace,
+ IdePanelPosition *position,
+ IdeBuffer *buffer,
+ IdeLocation *location)
{
IdeBufferManager *bufmgr;
IdeContext *context;
@@ -48,7 +48,7 @@ focus_new (IdeWorkspace *workspace,
GFile *file = NULL;
g_assert (IDE_IS_WORKSPACE (workspace));
- g_assert (!frame || IDE_IS_FRAME (frame));
+ g_assert (position != NULL);
g_assert (!buffer || IDE_IS_BUFFER (buffer));
g_assert (!location || IDE_IS_LOCATION (location));
g_assert (buffer != NULL || location != NULL);
@@ -70,12 +70,7 @@ focus_new (IdeWorkspace *workspace,
buffer = ide_buffer_manager_find_buffer (bufmgr, file);
focus = g_atomic_rc_box_alloc0 (sizeof *focus);
-
- if (frame != NULL)
- focus->position = ide_frame_get_position (frame);
- else
- focus->position = ide_panel_position_new ();
-
+ focus->position = ide_panel_position_ref (position);
g_set_object (&focus->workspace, workspace);
g_set_object (&focus->buffer, buffer);
g_set_object (&focus->location, location);
@@ -204,17 +199,17 @@ ide_editor_load_file_cb (GObject *object,
}
static void
-do_focus (IdeWorkspace *workspace,
- IdeFrame *frame,
- IdeBuffer *buffer,
- IdeLocation *location)
+do_focus (IdeWorkspace *workspace,
+ IdePanelPosition *position,
+ IdeBuffer *buffer,
+ IdeLocation *location)
{
+ g_autoptr(IdePanelPosition) local_position = NULL;
IdeBufferManager *bufmgr;
IdeContext *context;
Focus *focus;
g_assert (IDE_IS_WORKSPACE (workspace));
- g_assert (!frame || IDE_IS_FRAME (frame));
g_assert (!buffer || IDE_IS_BUFFER (buffer));
g_assert (!location || IDE_IS_LOCATION (location));
g_assert (buffer != NULL || location != NULL);
@@ -225,7 +220,10 @@ do_focus (IdeWorkspace *workspace,
g_assert (IDE_IS_CONTEXT (context));
g_assert (IDE_IS_BUFFER_MANAGER (bufmgr));
- focus = focus_new (workspace, frame, buffer, location);
+ if (position == NULL)
+ position = local_position = ide_panel_position_new ();
+
+ focus = focus_new (workspace, position, buffer, location);
if (focus->buffer == NULL)
ide_buffer_manager_load_file_async (bufmgr,
@@ -240,27 +238,23 @@ do_focus (IdeWorkspace *workspace,
}
void
-ide_editor_focus_location (IdeWorkspace *workspace,
- IdeFrame *frame,
- IdeLocation *location)
+ide_editor_focus_location (IdeWorkspace *workspace,
+ IdePanelPosition *position,
+ IdeLocation *location)
{
g_return_if_fail (IDE_IS_WORKSPACE (workspace));
- g_return_if_fail (!frame || IDE_IS_FRAME (frame));
- g_return_if_fail (!frame || GTK_WIDGET (workspace) == gtk_widget_get_ancestor (GTK_WIDGET (frame),
IDE_TYPE_WORKSPACE));
g_return_if_fail (IDE_IS_LOCATION (location));
- do_focus (workspace, frame, NULL, location);
+ do_focus (workspace, position, NULL, location);
}
void
-ide_editor_focus_buffer (IdeWorkspace *workspace,
- IdeFrame *frame,
- IdeBuffer *buffer)
+ide_editor_focus_buffer (IdeWorkspace *workspace,
+ IdePanelPosition *position,
+ IdeBuffer *buffer)
{
g_return_if_fail (IDE_IS_WORKSPACE (workspace));
- g_return_if_fail (!frame || IDE_IS_FRAME (frame));
- g_return_if_fail (!frame || GTK_WIDGET (workspace) == gtk_widget_get_ancestor (GTK_WIDGET (frame),
IDE_TYPE_WORKSPACE));
g_return_if_fail (IDE_IS_BUFFER (buffer));
- do_focus (workspace, frame, buffer, NULL);
+ do_focus (workspace, position, buffer, NULL);
}
diff --git a/src/libide/editor/ide-editor.h b/src/libide/editor/ide-editor.h
index 652b5b82c..a908116de 100644
--- a/src/libide/editor/ide-editor.h
+++ b/src/libide/editor/ide-editor.h
@@ -27,12 +27,12 @@
G_BEGIN_DECLS
IDE_AVAILABLE_IN_ALL
-void ide_editor_focus_location (IdeWorkspace *workspace,
- IdeFrame *frame,
- IdeLocation *location);
+void ide_editor_focus_location (IdeWorkspace *workspace,
+ IdePanelPosition *position,
+ IdeLocation *location);
IDE_AVAILABLE_IN_ALL
-void ide_editor_focus_buffer (IdeWorkspace *workspace,
- IdeFrame *frame,
- IdeBuffer *buffer);
+void ide_editor_focus_buffer (IdeWorkspace *workspace,
+ IdePanelPosition *position,
+ IdeBuffer *buffer);
G_END_DECLS
diff --git a/src/libide/lsp/ide-lsp-search-result.c b/src/libide/lsp/ide-lsp-search-result.c
index 29d7e4f49..ddf22a552 100644
--- a/src/libide/lsp/ide-lsp-search-result.c
+++ b/src/libide/lsp/ide-lsp-search-result.c
@@ -112,17 +112,14 @@ ide_lsp_search_result_activate (IdeSearchResult *result,
IdeLspSearchResult *self = (IdeLspSearchResult *)result;
IdeWorkspace *workspace;
- IdeFrame *frame;
g_assert (IDE_IS_LSP_SEARCH_RESULT (self));
g_assert (GTK_IS_WIDGET (last_focus));
- if (!last_focus ||
- !(workspace = ide_widget_get_workspace (last_focus)))
+ if (!last_focus || !(workspace = ide_widget_get_workspace (last_focus)))
return;
- frame = ide_workspace_get_most_recent_frame (workspace);
- ide_editor_focus_location (workspace, frame, self->location);
+ ide_editor_focus_location (workspace, NULL, self->location);
}
static void
diff --git a/src/plugins/editorui/gbp-editorui-workbench-addin.c
b/src/plugins/editorui/gbp-editorui-workbench-addin.c
index b0108601e..bbdef6aa0 100644
--- a/src/plugins/editorui/gbp-editorui-workbench-addin.c
+++ b/src/plugins/editorui/gbp-editorui-workbench-addin.c
@@ -202,13 +202,11 @@ gbp_editorui_workbench_addin_open_cb (GObject *object,
location = ide_location_new (state->file,
state->at_line,
state->at_line_offset);
- ide_editor_focus_location (workspace, NULL, location);
+ ide_editor_focus_location (workspace, state->position, location);
}
else
{
- IdeFrame *frame = ide_workspace_get_most_recent_frame (workspace);
-
- ide_editor_focus_buffer (workspace, frame, buffer);
+ ide_editor_focus_buffer (workspace, state->position, buffer);
}
failure:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]