[gnome-builder/wip/gtk4-port: 525/1774] plugins/editorui: add insert/overwrite indicator
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 525/1774] plugins/editorui: add insert/overwrite indicator
- Date: Mon, 11 Jul 2022 22:31:15 +0000 (UTC)
commit 926e91918fe1cadfab35459af778a41049b2d897
Author: Christian Hergert <chergert redhat com>
Date: Sat Apr 9 10:07:46 2022 -0700
plugins/editorui: add insert/overwrite indicator
This will need some special casing with Vim still, but we can figure that
out later on. The problem is that we abuse "overwrite" mode when using Vim
emulation to look like a block cursor since GTK does not allow us to
control the cursor style independently.
.../editorui/gbp-editorui-workspace-addin.c | 33 ++++++++++++++++++++++
1 file changed, 33 insertions(+)
---
diff --git a/src/plugins/editorui/gbp-editorui-workspace-addin.c
b/src/plugins/editorui/gbp-editorui-workspace-addin.c
index d305e0d91..9a312c926 100644
--- a/src/plugins/editorui/gbp-editorui-workspace-addin.c
+++ b/src/plugins/editorui/gbp-editorui-workspace-addin.c
@@ -54,6 +54,8 @@ struct _GbpEditoruiWorkspaceAddin
GtkMenuButton *encoding;
GtkLabel *encoding_label;
+ GtkLabel *mode_label;
+
guint queued_cursor_moved;
};
@@ -70,6 +72,24 @@ static void
}
}
+static void
+notify_overwrite_cb (GbpEditoruiWorkspaceAddin *self)
+{
+ IdeSourceView *view;
+
+ g_assert (GBP_IS_EDITORUI_WORKSPACE_ADDIN (self));
+
+ if ((view = ide_signal_group_get_target (self->view_signals)))
+ {
+ gboolean overwrite = gtk_text_view_get_overwrite (GTK_TEXT_VIEW (view));
+
+ if (overwrite)
+ gtk_label_set_label (self->mode_label, "OVR");
+ else
+ gtk_label_set_label (self->mode_label, "INS");
+ }
+}
+
static void
notify_indentation_cb (GbpEditoruiWorkspaceAddin *self)
{
@@ -306,6 +326,11 @@ gbp_editorui_workspace_addin_load (IdeWorkspaceAddin *addin,
G_CALLBACK (notify_indentation_cb),
self,
G_CONNECT_SWAPPED);
+ ide_signal_group_connect_object (self->view_signals,
+ "notify::overwrite",
+ G_CALLBACK (notify_overwrite_cb),
+ self,
+ G_CONNECT_SWAPPED);
/* Encoding */
encoding_menu = ide_editor_encoding_menu_new ("editorui.encoding");
@@ -333,6 +358,12 @@ gbp_editorui_workspace_addin_load (IdeWorkspaceAddin *addin,
NULL);
panel_statusbar_add_suffix (self->statusbar, GTK_WIDGET (self->line_ends));
+ self->mode_label = g_object_new (GTK_TYPE_LABEL,
+ "label", "INS",
+ "width-chars", 4,
+ NULL);
+ panel_statusbar_add_suffix (self->statusbar, GTK_WIDGET (self->mode_label));
+
/* Indentation status, tabs/spaces/etc */
menu = ide_application_get_menu_by_id (IDE_APPLICATION_DEFAULT, "editorui-indent-menu");
self->indentation_label = g_object_new (GTK_TYPE_LABEL, NULL);
@@ -414,6 +445,7 @@ gbp_editorui_workspace_addin_page_changed (IdeWorkspaceAddin *addin,
ide_signal_group_set_target (self->buffer_signals, buffer);
ide_signal_group_set_target (self->view_signals, view);
+ notify_overwrite_cb (self);
notify_indentation_cb (self);
update_position (self);
@@ -421,6 +453,7 @@ gbp_editorui_workspace_addin_page_changed (IdeWorkspaceAddin *addin,
gtk_widget_set_visible (GTK_WIDGET (self->line_ends), page != NULL);
gtk_widget_set_visible (GTK_WIDGET (self->position), page != NULL);
gtk_widget_set_visible (GTK_WIDGET (self->encoding), page != NULL);
+ gtk_widget_set_visible (GTK_WIDGET (self->mode_label), page != NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]