xed-view: Add some margin to the top and left of the text view

This commit is contained in:
JosephMcc 2017-02-10 00:18:17 -08:00
parent ad31cd9e36
commit c620e48c96
3 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,16 @@
#include "xed-view-gutter-renderer.h"
#define XED_VIEW_GUTTER_RENDERER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), XED_VIEW_GUTTER_RENDERER, XedViewGutterRendererPrivate))
G_DEFINE_TYPE (XedViewGutterRenderer, xed_view_gutter_renderer, GTK_SOURCE_TYPE_GUTTER_RENDERER)
static void
xed_view_gutter_renderer_class_init (XedViewGutterRendererClass *klass)
{
GtkSourceGutterRendererClass *renderer_class = GTK_SOURCE_GUTTER_RENDERER_CLASS (klass);
}
static void
xed_view_gutter_renderer_init (XedViewGutterRenderer *self)
{
}

View File

@ -0,0 +1,35 @@
#ifndef __XED_VIEW_GUTTER_RENDERER_H__
#define __XED_VIEW_GUTTER_RENDERER_H__
#include <gtksourceview/gtksource.h>
G_BEGIN_DECLS
#define XED_TYPE_VIEW_GUTTER_RENDERER (xed_view_gutter_renderer_get_type ())
#define XED_VIEW_GUTTER_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_VIEW_GUTTER_RENDERER, XedViewGutterRenderer))
#define XED_VIEW_GUTTER_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_VIEW_GUTTER_RENDERER, XedViewGutterRendererClass))
#define XED_IS_VIEW_GUTTER_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_VIEW_GUTTER_RENDERER))
#define XED_IS_VIEW_GUTTER_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_VIEW_GUTTER_RENDERER))
#define XED_VIEW_GUTTER_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_VIEW_GUTTER_RENDERER, XedViewGutterRendererClass))
typedef struct _XedViewGutterRenderer XedViewGutterRenderer;
typedef struct _XedViewGutterRendererClass XedViewGutterRendererClass;
typedef struct _XedViewGutterRendererPrivate XedViewGutterRendererPrivate;
struct _XedViewGutterRenderer
{
GtkSourceGutterRenderer parent;
XedViewGutterRendererPrivate *priv;
};
struct _XedViewGutterRendererClass
{
GtkSourceGutterRendererClass parent_instance;
};
GType xed_view_gutter_renderer_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __XED_VIEW_GUTTER_RENDERER_H__ */

View File

@ -10,6 +10,7 @@
#include <glib/gi18n.h>
#include "xed-view.h"
#include "xed-view-gutter-renderer.h"
#include "xed-view-activatable.h"
#include "xed-plugins-engine.h"
#include "xed-debug.h"
@ -32,6 +33,7 @@ struct _XedViewPrivate
GSettings *editor_settings;
GtkTextBuffer *current_buffer;
PeasExtensionSet *extensions;
GtkSourceGutterRenderer *renderer;
guint view_realized : 1;
};
@ -143,6 +145,7 @@ xed_view_dispose (GObject *object)
g_clear_object (&view->priv->extensions);
g_clear_object (&view->priv->editor_settings);
g_clear_object (&view->priv->renderer);
current_buffer_removed (view);
@ -163,6 +166,7 @@ xed_view_constructed (GObject *object)
XedView *view;
XedViewPrivate *priv;
gboolean use_default_font;
GtkSourceGutter *gutter;
view = XED_VIEW (object);
priv = view->priv;
@ -246,6 +250,15 @@ xed_view_constructed (GObject *object)
"indent_on_tab", TRUE,
NULL);
gutter = gtk_source_view_get_gutter (GTK_SOURCE_VIEW (view), GTK_TEXT_WINDOW_LEFT);
priv->renderer = g_object_new (XED_TYPE_VIEW_GUTTER_RENDERER,
"size", 2,
NULL);
g_object_ref (priv->renderer);
gtk_source_gutter_insert (gutter, priv->renderer, 0);
gtk_text_view_set_top_margin (GTK_TEXT_VIEW (view), 2);
G_OBJECT_CLASS (xed_view_parent_class)->constructed (object);
}