[gnome-builder] libide: add "default" mode for IdeSourceViewMode
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: add "default" mode for IdeSourceViewMode
- Date: Mon, 23 Mar 2015 23:54:12 +0000 (UTC)
commit 47c4a4bb90fc613f9b6da2f7a2abedcd94b110b1
Author: Christian Hergert <christian hergert me>
Date: Wed Mar 4 13:30:36 2015 -0800
libide: add "default" mode for IdeSourceViewMode
CSS keybinding selectors will always be able to select the default mode
using the following.
IdeSourceViewMode.default {
}
This is necessary as without a mode we cannot dispatch key presses. (They
will get swallowed by input methods).
libide/ide-source-view.c | 55 ++++++++++++++++++++++++++++++++++-----------
1 files changed, 41 insertions(+), 14 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 5ebd87c..6542e66 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -1232,23 +1232,14 @@ ide_source_view_do_indent (IdeSourceView *self,
}
static gboolean
-ide_source_view_key_press_event (GtkWidget *widget,
- GdkEventKey *event)
+ide_source_view_do_mode (IdeSourceView *self,
+ GdkEventKey *event)
{
- IdeSourceView *self = (IdeSourceView *)widget;
IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
- GtkTextBuffer *buffer;
- IdeSourceSnippet *snippet;
gboolean ret = FALSE;
g_assert (IDE_IS_SOURCE_VIEW (self));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self));
-
- /*
- * If we are in a non-default mode, dispatch the event to the mode. This allows custom
- * keybindings like Emacs and Vim to be implemented using gtk-bindings CSS.
- */
if (priv->mode)
{
IdeSourceViewMode *mode;
@@ -1284,9 +1275,37 @@ ide_source_view_key_press_event (GtkWidget *widget,
g_object_unref (mode);
if (handled)
- return TRUE;
+ ret = TRUE;
}
+ if (!priv->mode)
+ priv->mode = _ide_source_view_mode_new (GTK_WIDGET (self), "default",
+ IDE_SOURCE_VIEW_MODE_TYPE_PERMANENT);
+
+ return ret;
+}
+
+static gboolean
+ide_source_view_key_press_event (GtkWidget *widget,
+ GdkEventKey *event)
+{
+ IdeSourceView *self = (IdeSourceView *)widget;
+ IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+ GtkTextBuffer *buffer;
+ IdeSourceSnippet *snippet;
+ gboolean ret = FALSE;
+
+ g_assert (IDE_IS_SOURCE_VIEW (self));
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self));
+
+ /*
+ * If we are in a non-default mode, dispatch the event to the mode. This allows custom
+ * keybindings like Emacs and Vim to be implemented using gtk-bindings CSS.
+ */
+ if (ide_source_view_do_mode (self, event))
+ return TRUE;
+
/*
* Handle movement through the tab stops of the current snippet if needed.
*/
@@ -1563,8 +1582,13 @@ ide_source_view_real_set_mode (IdeSourceView *self,
g_clear_object (&priv->mode);
- if (mode != NULL)
- priv->mode = _ide_source_view_mode_new (GTK_WIDGET (self), mode, type);
+ if (mode == NULL)
+ {
+ mode = "default";
+ type = IDE_SOURCE_VIEW_MODE_TYPE_PERMANENT;
+ }
+
+ priv->mode = _ide_source_view_mode_new (GTK_WIDGET (self), mode, type);
IDE_EXIT;
}
@@ -1589,6 +1613,9 @@ ide_source_view_constructed (GObject *object)
G_OBJECT_CLASS (ide_source_view_parent_class)->constructed (object);
+ if (!priv->mode)
+ ide_source_view_real_set_mode (self, "default", IDE_SOURCE_VIEW_MODE_TYPE_PERMANENT);
+
gutter = gtk_source_view_get_gutter (GTK_SOURCE_VIEW (self), GTK_TEXT_WINDOW_LEFT);
priv->line_change_renderer = g_object_new (IDE_TYPE_LINE_CHANGE_GUTTER_RENDERER,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]