[gnome-builder/wip/gtk4-port] plugins/editorui: set initial text to current position
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] plugins/editorui: set initial text to current position
- Date: Thu, 2 Jun 2022 04:30:17 +0000 (UTC)
commit c80f6423be3afe53bcdcc8069a2e40f1858c2566
Author: Christian Hergert <chergert redhat com>
Date: Wed Jun 1 21:30:09 2022 -0700
plugins/editorui: set initial text to current position
.../editorui/gbp-editorui-workspace-addin.c | 24 ++++++++++++++++++++++
1 file changed, 24 insertions(+)
---
diff --git a/src/plugins/editorui/gbp-editorui-workspace-addin.c
b/src/plugins/editorui/gbp-editorui-workspace-addin.c
index 84427a42e..5bc14c16f 100644
--- a/src/plugins/editorui/gbp-editorui-workspace-addin.c
+++ b/src/plugins/editorui/gbp-editorui-workspace-addin.c
@@ -426,6 +426,25 @@ go_to_line_changed_cb (GbpEditoruiWorkspaceAddin *self,
IDE_EXIT;
}
+static void
+show_go_to_line_cb (GbpEditoruiWorkspaceAddin *self,
+ IdeEntryPopover *popover)
+{
+ g_autofree char *text = NULL;
+ IdeSourceView *view;
+ guint line;
+ guint column;
+
+ g_assert (GBP_IS_EDITORUI_WORKSPACE_ADDIN (self));
+ g_assert (IDE_IS_ENTRY_POPOVER (popover));
+
+ view = ide_editor_page_get_view (self->page);
+ ide_source_view_get_visual_position (view, &line, &column);
+ text = g_strdup_printf ("%u:%u", line+1, column+1);
+ ide_entry_popover_set_text (popover, text);
+ ide_entry_popover_select_all (popover);
+}
+
static const GActionEntry actions[] = {
{ "open-in-new-frame", open_in_new_frame },
{ "open-in-new-workspace", open_in_new_workspace },
@@ -554,6 +573,11 @@ gbp_editorui_workspace_addin_load (IdeWorkspaceAddin *addin,
"button-text", _("Go"),
"title", _("Go to Line"),
NULL);
+ g_signal_connect_object (popover,
+ "show",
+ G_CALLBACK (show_go_to_line_cb),
+ self,
+ G_CONNECT_SWAPPED);
g_signal_connect_object (popover,
"changed",
G_CALLBACK (go_to_line_changed_cb),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]