[gnome-builder] terminal: subclass VteTerminal



commit efd44f2e2435e578ff967586bd87db64c1eeb5bc
Author: Christian Hergert <christian hergert me>
Date:   Wed Mar 2 15:36:34 2016 -0800

    terminal: subclass VteTerminal
    
    So we have a bit more control of how things work in Builder, we'll just
    subclass VteTerminal and add binding set entries for our keybindings.

 data/keybindings/shared.css          |   10 ------
 plugins/terminal/Makefile.am         |    2 +
 plugins/terminal/gb-terminal-view.c  |    5 ++-
 plugins/terminal/gb-terminal-view.ui |    2 +-
 plugins/terminal/gb-terminal.c       |   56 ++++++++++++++++++++++++++++++++++
 plugins/terminal/gb-terminal.h       |   43 ++++++++++++++++++++++++++
 6 files changed, 106 insertions(+), 12 deletions(-)
---
diff --git a/data/keybindings/shared.css b/data/keybindings/shared.css
index e1473bc..d4726a3 100644
--- a/data/keybindings/shared.css
+++ b/data/keybindings/shared.css
@@ -4,16 +4,6 @@
   bind "F2" { "action" ("project-tree", "rename-file", "") };
 }
 
- binding-set builder-vte-terminal
-{
-  bind "<ctrl><shift>c" { "copy-clipboard" () };
-  bind "<ctrl><shift>v" { "paste-clipboard" () };
-}
-
-vte-terminal {
-  -gtk-key-bindings: builder-vte-terminal;
-}
-
 @binding-set builder-command-bar-entry
 {
   bind "<ctrl>a" { "move-cursor" (paragraph-ends, -1, 0) };
diff --git a/plugins/terminal/Makefile.am b/plugins/terminal/Makefile.am
index a9da69d..f164254 100644
--- a/plugins/terminal/Makefile.am
+++ b/plugins/terminal/Makefile.am
@@ -10,6 +10,8 @@ plugin_LTLIBRARIES = libterminal.la
 dist_plugin_DATA = terminal.plugin
 
 libterminal_la_SOURCES = \
+       gb-terminal.c \
+       gb-terminal.h \
        gb-terminal-application-addin.c \
        gb-terminal-application-addin.h \
        gb-terminal-plugin.c \
diff --git a/plugins/terminal/gb-terminal-view.c b/plugins/terminal/gb-terminal-view.c
index 7368ef0..103520f 100644
--- a/plugins/terminal/gb-terminal-view.c
+++ b/plugins/terminal/gb-terminal-view.c
@@ -20,6 +20,7 @@
 #include <ide.h>
 #include <vte/vte.h>
 
+#include "gb-terminal.h"
 #include "gb-terminal-view.h"
 #include "gb-terminal-view-private.h"
 #include "gb-terminal-view-actions.h"
@@ -406,7 +407,7 @@ gb_terminal_set_split_view (IdeLayoutView   *view,
     {
       style_context = gtk_widget_get_style_context (GTK_WIDGET (view));
 
-      self->terminal_bottom = g_object_new (VTE_TYPE_TERMINAL,
+      self->terminal_bottom = g_object_new (GB_TYPE_TERMINAL,
                                             "audible-bell", FALSE,
                                             "scrollback-lines", G_MAXUINT,
                                             "expand", TRUE,
@@ -563,6 +564,8 @@ gb_terminal_view_class_init (GbTerminalViewClass *klass)
                          (G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_properties (object_class, LAST_PROP, properties);
+
+  g_type_ensure (GB_TYPE_TERMINAL);
 }
 
 static void
diff --git a/plugins/terminal/gb-terminal-view.ui b/plugins/terminal/gb-terminal-view.ui
index 2ef98e8..8a66b06 100644
--- a/plugins/terminal/gb-terminal-view.ui
+++ b/plugins/terminal/gb-terminal-view.ui
@@ -13,7 +13,7 @@
             <property name="expand">true</property>
             <property name="visible">true</property>
             <child>
-              <object class="VteTerminal" id="terminal_top">
+              <object class="GbTerminal" id="terminal_top">
                 <property name="audible-bell">false</property>
                 <property name="expand">true</property>
                 <property name="visible">true</property>
diff --git a/plugins/terminal/gb-terminal.c b/plugins/terminal/gb-terminal.c
new file mode 100644
index 0000000..946b934
--- /dev/null
+++ b/plugins/terminal/gb-terminal.c
@@ -0,0 +1,56 @@
+/* gb-terminal.c
+ *
+ * Copyright (C) 2016 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gb-terminal.h"
+
+struct _GbTerminal
+{
+  VteTerminal parent;
+};
+
+struct _GbTerminalClass
+{
+  VteTerminalClass parent;
+};
+
+G_DEFINE_TYPE (GbTerminal, gb_terminal, VTE_TYPE_TERMINAL)
+
+static void
+gb_terminal_class_init (GbTerminalClass *klass)
+{
+  GtkBindingSet *binding_set;
+
+  binding_set = gtk_binding_set_by_class (klass);
+
+  gtk_binding_entry_add_signal (binding_set,
+                                GDK_KEY_c,
+                                GDK_SHIFT_MASK | GDK_CONTROL_MASK,
+                                "copy-clipboard",
+                                0);
+
+  gtk_binding_entry_add_signal (binding_set,
+                                GDK_KEY_v,
+                                GDK_SHIFT_MASK | GDK_CONTROL_MASK,
+                                "paste-clipboard",
+                                0);
+}
+
+static void
+gb_terminal_init (GbTerminal *self)
+{
+}
diff --git a/plugins/terminal/gb-terminal.h b/plugins/terminal/gb-terminal.h
new file mode 100644
index 0000000..794d395
--- /dev/null
+++ b/plugins/terminal/gb-terminal.h
@@ -0,0 +1,43 @@
+/* gb-terminal.h
+ *
+ * Copyright (C) 2016 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GB_TERMINAL_H
+#define GB_TERMINAL_H
+
+#include <vte/vte.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_TERMINAL            (gb_terminal_get_type())
+#define GB_TERMINAL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_TERMINAL, GbTerminal))
+#define GB_TERMINAL_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_TERMINAL, GbTerminal const))
+#define GB_TERMINAL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GB_TYPE_TERMINAL, GbTerminalClass))
+#define GB_IS_TERMINAL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GB_TYPE_TERMINAL))
+#define GB_IS_TERMINAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GB_TYPE_TERMINAL))
+#define GB_TERMINAL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GB_TYPE_TERMINAL, GbTerminalClass))
+
+typedef struct _GbTerminal      GbTerminal;
+typedef struct _GbTerminalClass GbTerminalClass;
+
+GType gb_terminal_get_type (void);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (GbTerminal, g_object_unref)
+
+G_END_DECLS
+
+#endif /* GB_TERMINAL_H */


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