[gnome-text-editor] vim: show incremental command text



commit ae6d103fcf16122f88cfdc00e15a307086fa241f
Author: Christian Hergert <chergert redhat com>
Date:   Thu Nov 11 23:46:05 2021 -0800

    vim: show incremental command text
    
    This is updated as the user types to help display interactive commands like
    1000G.

 src/TextEditor.css        |  2 +-
 src/editor-page-private.h |  2 ++
 src/editor-page-vim.c     | 25 ++++---------------------
 src/editor-page.c         |  2 ++
 src/editor-page.ui        | 18 +++++++++++++++---
 5 files changed, 24 insertions(+), 25 deletions(-)
---
diff --git a/src/TextEditor.css b/src/TextEditor.css
index d4f1ff8..9cec28b 100644
--- a/src/TextEditor.css
+++ b/src/TextEditor.css
@@ -118,7 +118,7 @@ flap > scrolledwindow.preferences > viewport {
   background: @theme_bg_color;
 }
 
-label.vim-command-bar {
+box.statusbar {
   font-family: monospace;
   min-width: 100px;
   padding: 3px 6px;
diff --git a/src/editor-page-private.h b/src/editor-page-private.h
index ea6dea9..1d4548f 100644
--- a/src/editor-page-private.h
+++ b/src/editor-page-private.h
@@ -57,7 +57,9 @@ struct _EditorPage
   EditorSearchBar         *search_bar;
   GtkInfoBar              *changed_infobar;
   GtkInfoBar              *infobar;
+  GtkLabel                *vim_command;
   GtkLabel                *vim_command_bar;
+  GtkBox                  *statusbar;
   GtkEventController      *vim;
 
   guint                    close_requested : 1;
diff --git a/src/editor-page-vim.c b/src/editor-page-vim.c
index 87afa2b..623c9dd 100644
--- a/src/editor-page-vim.c
+++ b/src/editor-page-vim.c
@@ -24,20 +24,6 @@
 #include "editor-page-private.h"
 #include "editor-session.h"
 
-static void
-on_notify_command_bar_text_cb (EditorPage            *self,
-                               GParamSpec            *pspec,
-                               GtkSourceVimIMContext *im_context)
-{
-  const char *label;
-
-  g_assert (EDITOR_IS_PAGE (self));
-  g_assert (GTK_SOURCE_IS_VIM_IM_CONTEXT (im_context));
-
-  label = gtk_source_vim_im_context_get_command_bar_text (im_context);
-  gtk_label_set_label (self->vim_command_bar, label);
-}
-
 static void
 on_vim_write_cb (EditorPage            *self,
                  GtkSourceView         *view,
@@ -150,11 +136,8 @@ on_keybindings_changed_cb (EditorPage *self,
           GtkIMContext *im_context;
 
           im_context = gtk_source_vim_im_context_new ();
-          g_signal_connect_object (im_context,
-                                   "notify::command-bar-text",
-                                   G_CALLBACK (on_notify_command_bar_text_cb),
-                                   self,
-                                   G_CONNECT_SWAPPED);
+          g_object_bind_property (im_context, "command-bar-text", self->vim_command_bar, "label", 0);
+          g_object_bind_property (im_context, "command-text", self->vim_command, "label", 0);
           g_signal_connect_object (im_context,
                                    "write",
                                    G_CALLBACK (on_vim_write_cb),
@@ -177,7 +160,7 @@ on_keybindings_changed_cb (EditorPage *self,
           gtk_event_controller_key_set_im_context (GTK_EVENT_CONTROLLER_KEY (self->vim), im_context);
           gtk_widget_add_controller (GTK_WIDGET (self->view), self->vim);
 
-          gtk_widget_show (GTK_WIDGET (self->vim_command_bar));
+          gtk_widget_show (GTK_WIDGET (self->statusbar));
         }
     }
   else
@@ -185,7 +168,7 @@ on_keybindings_changed_cb (EditorPage *self,
       if (self->vim)
         {
           gtk_label_set_label (self->vim_command_bar, NULL);
-          gtk_widget_hide (GTK_WIDGET (self->vim_command_bar));
+          gtk_widget_hide (GTK_WIDGET (self->statusbar));
           gtk_widget_remove_controller (GTK_WIDGET (self), self->vim);
           self->vim = NULL;
         }
diff --git a/src/editor-page.c b/src/editor-page.c
index 118701b..5772478 100644
--- a/src/editor-page.c
+++ b/src/editor-page.c
@@ -629,8 +629,10 @@ editor_page_class_init (EditorPageClass *klass)
   gtk_widget_class_bind_template_child (widget_class, EditorPage, scroller);
   gtk_widget_class_bind_template_child (widget_class, EditorPage, search_bar);
   gtk_widget_class_bind_template_child (widget_class, EditorPage, search_revealer);
+  gtk_widget_class_bind_template_child (widget_class, EditorPage, statusbar);
   gtk_widget_class_bind_template_child (widget_class, EditorPage, view);
   gtk_widget_class_bind_template_child (widget_class, EditorPage, vim_command_bar);
+  gtk_widget_class_bind_template_child (widget_class, EditorPage, vim_command);
   gtk_widget_class_bind_template_callback (widget_class, get_child_position_cb);
   gtk_widget_class_bind_template_callback (widget_class, goto_line_entry_activate_cb);
 
diff --git a/src/editor-page.ui b/src/editor-page.ui
index 97c0c14..1bdd63c 100644
--- a/src/editor-page.ui
+++ b/src/editor-page.ui
@@ -146,14 +146,26 @@
           </object>
         </child>
         <child>
-          <object class="GtkLabel" id="vim_command_bar">
-            <property name="xalign">0</property>
+          <object class="GtkBox" id="statusbar">
             <property name="valign">end</property>
+            <property name="hexpand">true</property>
             <property name="vexpand">false</property>
             <property name="visible">false</property>
+            <property name="spacing">12</property>
             <style>
-              <class name="vim-command-bar"/>
+              <class name="statusbar"/>
             </style>
+            <child>
+              <object class="GtkLabel" id="vim_command_bar">
+                <property name="hexpand">true</property>
+                <property name="xalign">0</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel" id="vim_command">
+                <property name="xalign">1</property>
+              </object>
+            </child>
           </object>
         </child>
       </object>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]