[gnome-builder/wip/gtk4-port: 540/736] 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: 540/736] plugins/editorui: add insert/overwrite indicator
- Date: Tue, 26 Apr 2022 01:46:30 +0000 (UTC)
commit decc8036e328ae1396e596e90d5aa80871e205be
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]