[gedit-plugins/wip/chergert/gsv-4: 2/2] build: port to gtksourceview-4
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins/wip/chergert/gsv-4: 2/2] build: port to gtksourceview-4
- Date: Wed, 26 Sep 2018 19:32:01 +0000 (UTC)
commit c8e0b2b5bf2dde722a44564c8087ee6fdbc9fc61
Author: Christian Hergert <chergert redhat com>
Date: Wed Sep 26 12:31:25 2018 -0700
build: port to gtksourceview-4
This updates the gedit-plugins to use GtkSourceView-4. This should only
be done in conjunction with GNOME/gedit!11 to land GtkSourceView-4 in
gedit.
configure.ac | 2 +-
plugins/codecomment/codecomment.py | 2 +-
plugins/colorschemer/schemer/languages.py | 2 +-
.../drawspaces/gedit-drawspaces-app-activatable.c | 32 ++++++++---------
.../drawspaces/gedit-drawspaces-app-activatable.h | 11 ++++++
.../drawspaces/gedit-drawspaces-view-activatable.c | 41 ++++++++++++++++++++--
plugins/findinfiles/Makefile.am | 2 +-
plugins/translate/translate/__init__.py | 2 +-
8 files changed, 70 insertions(+), 24 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index cc3b06c..d871aca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,7 +57,7 @@ PKG_CHECK_MODULES(GEDIT, [
glib-2.0 >= 2.32.0
gio-2.0 >= 2.32.0
gtk+-3.0 >= 3.9.0
- gtksourceview-3.0 >= 3.21.3
+ gtksourceview-4 >= 4.0.2
libpeas-1.0 >= 1.7.0
libpeas-gtk-1.0 >= 1.7.0
gedit >= 3.16.0
diff --git a/plugins/codecomment/codecomment.py b/plugins/codecomment/codecomment.py
index 991f968..94b63f6 100644
--- a/plugins/codecomment/codecomment.py
+++ b/plugins/codecomment/codecomment.py
@@ -23,7 +23,7 @@
import gi
gi.require_version('Gtk', '3.0')
-gi.require_version('GtkSource', '3.0')
+gi.require_version('GtkSource', '4.0')
from gi.repository import GObject, Gio, Gtk, GtkSource, Gedit
from gpdefs import *
diff --git a/plugins/colorschemer/schemer/languages.py b/plugins/colorschemer/schemer/languages.py
index a9971d3..2ad9e09 100644
--- a/plugins/colorschemer/schemer/languages.py
+++ b/plugins/colorschemer/schemer/languages.py
@@ -21,7 +21,7 @@
# please keep these in alphabetical order so it is easy to follow
-# see available languages: /usr/share/gtksourceview-3.0/language-specs
+# see available languages: /usr/share/gtksourceview-4/language-specs
# or run in python >>> GtkSource.LanguageManager().get_language_ids()
samples = {}
diff --git a/plugins/drawspaces/gedit-drawspaces-app-activatable.c
b/plugins/drawspaces/gedit-drawspaces-app-activatable.c
index 0cbe326..16bb821 100644
--- a/plugins/drawspaces/gedit-drawspaces-app-activatable.c
+++ b/plugins/drawspaces/gedit-drawspaces-app-activatable.c
@@ -42,7 +42,7 @@ typedef struct _DrawspacesConfigureWidget DrawspacesConfigureWidget;
struct _DrawspacesConfigureWidget
{
GSettings *settings;
- GtkSourceDrawSpacesFlags flags;
+ guint flags;
GtkWidget *content;
@@ -194,7 +194,7 @@ widget_destroyed (GtkWidget *obj, gpointer widget_pointer)
}
static void
-set_flag (DrawspacesConfigureWidget *widget, GtkSourceDrawSpacesFlags flag, gboolean active)
+set_flag (DrawspacesConfigureWidget *widget, guint flag, gboolean active)
{
widget->flags = active ? widget->flags | flag : widget->flags & ~flag;
g_settings_set_flags (widget->settings,
@@ -206,49 +206,49 @@ static void
on_draw_tabs_toggled (GtkToggleButton *button,
DrawspacesConfigureWidget *widget)
{
- set_flag (widget, GTK_SOURCE_DRAW_SPACES_TAB, gtk_toggle_button_get_active (button));
+ set_flag (widget, GEDIT_DRAW_SPACES_TAB, gtk_toggle_button_get_active (button));
}
static void
on_draw_spaces_toggled (GtkToggleButton *button,
DrawspacesConfigureWidget *widget)
{
- set_flag (widget, GTK_SOURCE_DRAW_SPACES_SPACE, gtk_toggle_button_get_active (button));
+ set_flag (widget, GEDIT_DRAW_SPACES_SPACE, gtk_toggle_button_get_active (button));
}
static void
on_draw_newline_toggled (GtkToggleButton *button,
DrawspacesConfigureWidget *widget)
{
- set_flag (widget, GTK_SOURCE_DRAW_SPACES_NEWLINE, gtk_toggle_button_get_active (button));
+ set_flag (widget, GEDIT_DRAW_SPACES_NEWLINE, gtk_toggle_button_get_active (button));
}
static void
on_draw_nbsp_toggled (GtkToggleButton *button,
DrawspacesConfigureWidget *widget)
{
- set_flag (widget, GTK_SOURCE_DRAW_SPACES_NBSP, gtk_toggle_button_get_active (button));
+ set_flag (widget, GEDIT_DRAW_SPACES_NBSP, gtk_toggle_button_get_active (button));
}
static void
on_draw_leading_toggled (GtkToggleButton *button,
DrawspacesConfigureWidget *widget)
{
- set_flag (widget, GTK_SOURCE_DRAW_SPACES_LEADING, gtk_toggle_button_get_active (button));
+ set_flag (widget, GEDIT_DRAW_SPACES_LEADING, gtk_toggle_button_get_active (button));
}
static void
on_draw_text_toggled (GtkToggleButton *button,
DrawspacesConfigureWidget *widget)
{
- set_flag (widget, GTK_SOURCE_DRAW_SPACES_TEXT, gtk_toggle_button_get_active (button));
+ set_flag (widget, GEDIT_DRAW_SPACES_TEXT, gtk_toggle_button_get_active (button));
}
static void
on_draw_trailing_toggled (GtkToggleButton *button,
DrawspacesConfigureWidget *widget)
{
- set_flag (widget, GTK_SOURCE_DRAW_SPACES_TRAILING, gtk_toggle_button_get_active (button));
+ set_flag (widget, GEDIT_DRAW_SPACES_TRAILING, gtk_toggle_button_get_active (button));
}
static DrawspacesConfigureWidget *
@@ -283,20 +283,20 @@ get_configuration_widget (GeditDrawspacesAppActivatable *activatable)
g_object_unref (builder);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->draw_tabs),
- widget->flags & GTK_SOURCE_DRAW_SPACES_TAB);
+ widget->flags & GEDIT_DRAW_SPACES_TAB);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->draw_spaces),
- widget->flags & GTK_SOURCE_DRAW_SPACES_SPACE);
+ widget->flags & GEDIT_DRAW_SPACES_SPACE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->draw_newline),
- widget->flags & GTK_SOURCE_DRAW_SPACES_NEWLINE);
+ widget->flags & GEDIT_DRAW_SPACES_NEWLINE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->draw_nbsp),
- widget->flags & GTK_SOURCE_DRAW_SPACES_NBSP);
+ widget->flags & GEDIT_DRAW_SPACES_NBSP);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->draw_leading),
- widget->flags & GTK_SOURCE_DRAW_SPACES_LEADING);
+ widget->flags & GEDIT_DRAW_SPACES_LEADING);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->draw_text),
- widget->flags & GTK_SOURCE_DRAW_SPACES_TEXT);
+ widget->flags & GEDIT_DRAW_SPACES_TEXT);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->draw_trailing),
- widget->flags & GTK_SOURCE_DRAW_SPACES_TRAILING);
+ widget->flags & GEDIT_DRAW_SPACES_TRAILING);
g_signal_connect (widget->draw_tabs,
"toggled",
diff --git a/plugins/drawspaces/gedit-drawspaces-app-activatable.h
b/plugins/drawspaces/gedit-drawspaces-app-activatable.h
index 191eaf7..ac93ddc 100644
--- a/plugins/drawspaces/gedit-drawspaces-app-activatable.h
+++ b/plugins/drawspaces/gedit-drawspaces-app-activatable.h
@@ -45,6 +45,17 @@ struct _GeditDrawspacesAppActivatableClass
GObjectClass parent_class;
};
+enum _GeditDrawSpacesFlags {
+ GEDIT_DRAW_SPACES_SPACE = 1 << 0,
+ GEDIT_DRAW_SPACES_TAB = 1 << 1,
+ GEDIT_DRAW_SPACES_NEWLINE = 1 << 2,
+ GEDIT_DRAW_SPACES_NBSP = 1 << 3,
+ GEDIT_DRAW_SPACES_LEADING = 1 << 4,
+ GEDIT_DRAW_SPACES_TEXT = 1 << 5,
+ GEDIT_DRAW_SPACES_TRAILING = 1 << 6,
+ GEDIT_DRAW_SPACES_ALL = 0x7f
+};
+
GType gedit_drawspaces_app_activatable_get_type (void) G_GNUC_CONST;
G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
diff --git a/plugins/drawspaces/gedit-drawspaces-view-activatable.c
b/plugins/drawspaces/gedit-drawspaces-view-activatable.c
index 7c84a87..e2eb395 100644
--- a/plugins/drawspaces/gedit-drawspaces-view-activatable.c
+++ b/plugins/drawspaces/gedit-drawspaces-view-activatable.c
@@ -18,6 +18,7 @@
* along with gedit. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "gedit-drawspaces-app-activatable.h"
#include "gedit-drawspaces-view-activatable.h"
#include <gedit/gedit-view.h>
@@ -29,7 +30,7 @@ typedef struct _GeditDrawspacesViewActivatablePrivate
{
GeditView *view;
GSettings *settings;
- GtkSourceDrawSpacesFlags flags;
+ guint flags;
guint enable : 1;
} GeditDrawspacesViewActivatablePrivate;
@@ -135,13 +136,47 @@ get_config_options (GeditDrawspacesViewActivatable *activatable)
SETTINGS_KEY_DRAW_SPACES);
}
+static inline void
+parse_flags (guint flags,
+ GtkSourceSpaceTypeFlags *type,
+ GtkSourceSpaceLocationFlags *location)
+{
+ *type = GTK_SOURCE_SPACE_TYPE_NONE;
+ *location = GTK_SOURCE_SPACE_LOCATION_NONE;
+
+ if (flags & GEDIT_DRAW_SPACES_SPACE)
+ *type |= GTK_SOURCE_SPACE_TYPE_SPACE;
+ if (flags & GEDIT_DRAW_SPACES_TAB)
+ *type |= GTK_SOURCE_SPACE_TYPE_TAB;
+ if (flags & GEDIT_DRAW_SPACES_NEWLINE)
+ *type |= GTK_SOURCE_SPACE_TYPE_NEWLINE;
+ if (flags & GEDIT_DRAW_SPACES_NBSP)
+ *type |= GTK_SOURCE_SPACE_TYPE_NBSP;
+
+ if (flags & GEDIT_DRAW_SPACES_LEADING)
+ *location |= GTK_SOURCE_SPACE_LOCATION_LEADING;
+ if (flags & GEDIT_DRAW_SPACES_TEXT)
+ *location |= GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT;
+ if (flags & GEDIT_DRAW_SPACES_TRAILING)
+ *location |= GTK_SOURCE_SPACE_LOCATION_TRAILING;
+}
+
static void
draw_spaces (GeditDrawspacesViewActivatable *activatable)
{
GeditDrawspacesViewActivatablePrivate *priv = gedit_drawspaces_view_activatable_get_instance_private
(activatable);
+ GtkSourceSpaceDrawer *drawer;
+ GtkSourceSpaceTypeFlags type;
+ GtkSourceSpaceLocationFlags location;
+
+ parse_flags (priv->flags, &type, &location);
+
+ drawer = gtk_source_view_get_space_drawer (GTK_SOURCE_VIEW (priv->view));
- gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW (priv->view),
- priv->enable ? priv->flags : 0);
+ /* Clear all existing spaces in the matrix before setting */
+ gtk_source_space_drawer_set_types_for_locations (drawer, GTK_SOURCE_SPACE_LOCATION_ALL, 0);
+ gtk_source_space_drawer_set_types_for_locations (drawer, location, type);
+ gtk_source_space_drawer_set_enable_matrix (drawer, priv->enable);
}
static void
diff --git a/plugins/findinfiles/Makefile.am b/plugins/findinfiles/Makefile.am
index bc7da9a..d261cdc 100644
--- a/plugins/findinfiles/Makefile.am
+++ b/plugins/findinfiles/Makefile.am
@@ -18,7 +18,7 @@ plugins_findinfiles_libfindinfiles_la_VALAFLAGS = \
--pkg config \
--pkg gedit \
--pkg PeasGtk-1.0 \
- --pkg GtkSource-3.0 \
+ --pkg GtkSource-4 \
--pkg gtk+-3.0 \
--pkg gio-2.0 \
--pkg posix \
diff --git a/plugins/translate/translate/__init__.py b/plugins/translate/translate/__init__.py
index 992d71f..c842a26 100644
--- a/plugins/translate/translate/__init__.py
+++ b/plugins/translate/translate/__init__.py
@@ -19,7 +19,7 @@
import gi
gi.require_version('Gtk', '3.0')
-gi.require_version('GtkSource', '3.0')
+gi.require_version('GtkSource', '4.0')
gi.require_version('PeasGtk', '1.0')
from gi.repository import GObject, Gio, Gtk, Gedit, PeasGtk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]