[gnome-builder] editor: don't require "source-view" property in highlighter.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor: don't require "source-view" property in highlighter.
- Date: Tue, 9 Sep 2014 01:20:05 +0000 (UTC)
commit 69bc3413e4cab88795319cac7b8a9ac6ca8dbb10
Author: Christian Hergert <christian hergert me>
Date: Mon Sep 8 18:18:51 2014 -0700
editor: don't require "source-view" property in highlighter.
It creates an annoying circular dependency, which prevents fully
settings things up in the UI file.
src/editor/gb-source-search-highlighter.c | 51 +---------------------------
src/editor/gb-source-search-highlighter.h | 2 +-
src/editor/gb-source-view.c | 3 +-
3 files changed, 5 insertions(+), 51 deletions(-)
---
diff --git a/src/editor/gb-source-search-highlighter.c b/src/editor/gb-source-search-highlighter.c
index 709245c..8e2e9fe 100644
--- a/src/editor/gb-source-search-highlighter.c
+++ b/src/editor/gb-source-search-highlighter.c
@@ -49,14 +49,6 @@ G_DEFINE_TYPE_WITH_PRIVATE (GbSourceSearchHighlighter,
static GParamSpec * gParamSpecs[LAST_PROP];
static guint gSignals[LAST_SIGNAL];
-GbSourceSearchHighlighter *
-gb_source_search_highlighter_new (GtkSourceView *source_view)
-{
- return g_object_new (GB_TYPE_SOURCE_SEARCH_HIGHLIGHTER,
- "source-view", source_view,
- NULL);
-}
-
static void
add_match (GtkTextView *text_view,
cairo_region_t *region,
@@ -166,6 +158,7 @@ draw_bezel (cairo_t *cr,
void
gb_source_search_highlighter_draw (GbSourceSearchHighlighter *highlighter,
+ GtkTextView *text_view,
cairo_t *cr)
{
GbSourceSearchHighlighterPrivate *priv;
@@ -175,7 +168,6 @@ gb_source_search_highlighter_draw (GbSourceSearchHighlighter *highlighter,
GtkSourceStyle *style;
GtkTextBuffer *buffer;
GdkRectangle area;
- GtkTextView *text_view;
GtkTextIter begin;
GtkTextIter end;
GdkRGBA color;
@@ -183,16 +175,15 @@ gb_source_search_highlighter_draw (GbSourceSearchHighlighter *highlighter,
GdkRGBA color2;
g_return_if_fail (GB_IS_SOURCE_SEARCH_HIGHLIGHTER (highlighter));
+ g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
g_return_if_fail (cr);
priv = highlighter->priv;
if (!priv->search_context ||
- !priv->source_view ||
!gtk_source_search_context_get_highlight (priv->search_context))
return;
- text_view = GTK_TEXT_VIEW (priv->source_view);
buffer = gtk_text_view_get_buffer (text_view);
scheme = gtk_source_buffer_get_style_scheme (GTK_SOURCE_BUFFER (buffer));
style = gtk_source_style_scheme_get_style (scheme, "search-match");
@@ -263,22 +254,6 @@ gb_source_search_highlighter_draw (GbSourceSearchHighlighter *highlighter,
cairo_region_destroy (match_region);
}
-static void
-gb_source_search_highlighter_set_source_view (GbSourceSearchHighlighter *highlighter,
- GtkSourceView *source_view)
-{
- GbSourceSearchHighlighterPrivate *priv;
-
- g_return_if_fail (GB_IS_SOURCE_SEARCH_HIGHLIGHTER (highlighter));
- g_return_if_fail (GTK_SOURCE_IS_VIEW (source_view));
-
- priv = highlighter->priv;
-
- priv->source_view = source_view;
- g_object_add_weak_pointer (G_OBJECT (source_view),
- (gpointer *) &priv->source_view);
-}
-
void
gb_source_search_highlighter_set_search_context (GbSourceSearchHighlighter *highlighter,
GtkSourceSearchContext *search_context)
@@ -319,13 +294,6 @@ gb_source_search_highlighter_finalize (GObject *object)
g_clear_object (&priv->search_context);
g_clear_object (&priv->search_settings);
- if (priv->source_view)
- {
- g_object_remove_weak_pointer (G_OBJECT (priv->source_view),
- (gpointer *) &priv->source_view);
- priv->source_view = NULL;
- }
-
G_OBJECT_CLASS (gb_source_search_highlighter_parent_class)->finalize (object);
}
@@ -347,10 +315,6 @@ gb_source_search_highlighter_set_property (GObject *object,
gb_source_search_highlighter_set_search_settings (highlighter, g_value_get_object (value));
break;
- case PROP_SOURCE_VIEW:
- gb_source_search_highlighter_set_source_view (highlighter, g_value_get_object (value));
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -383,17 +347,6 @@ gb_source_search_highlighter_class_init (GbSourceSearchHighlighterClass *klass)
g_object_class_install_property (object_class, PROP_SEARCH_SETTINGS,
gParamSpecs[PROP_SEARCH_SETTINGS]);
- gParamSpecs[PROP_SOURCE_VIEW] =
- g_param_spec_object ("source-view",
- _ ("Source View"),
- _ ("Source View"),
- GTK_SOURCE_TYPE_VIEW,
- (G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class, PROP_SOURCE_VIEW,
- gParamSpecs[PROP_SOURCE_VIEW]);
-
gSignals[CHANGED] = g_signal_new ("changed",
GB_TYPE_SOURCE_SEARCH_HIGHLIGHTER,
G_SIGNAL_RUN_FIRST,
diff --git a/src/editor/gb-source-search-highlighter.h b/src/editor/gb-source-search-highlighter.h
index 06898d0..dd2a603 100644
--- a/src/editor/gb-source-search-highlighter.h
+++ b/src/editor/gb-source-search-highlighter.h
@@ -51,12 +51,12 @@ struct _GbSourceSearchHighlighterClass
};
GType gb_source_search_highlighter_get_type (void) G_GNUC_CONST;
-GbSourceSearchHighlighter *gb_source_search_highlighter_new (GtkSourceView
*source_view);
void gb_source_search_highlighter_set_search_context (GbSourceSearchHighlighter
*highlighter,
GtkSourceSearchContext
*search_context);
void gb_source_search_highlighter_set_search_settings (GbSourceSearchHighlighter
*highlighter,
GtkSourceSearchSettings
*search_settings);
void gb_source_search_highlighter_draw (GbSourceSearchHighlighter
*highlighter,
+ GtkTextView
*text_view,
cairo_t *cr);
G_END_DECLS
diff --git a/src/editor/gb-source-view.c b/src/editor/gb-source-view.c
index d393f48..8e56b00 100644
--- a/src/editor/gb-source-view.c
+++ b/src/editor/gb-source-view.c
@@ -930,7 +930,8 @@ gb_source_view_draw_layer (GtkTextView *text_view,
if (priv->show_shadow && priv->search_highlighter)
{
cairo_save (cr);
- gb_source_search_highlighter_draw (priv->search_highlighter, cr);
+ gb_source_search_highlighter_draw (priv->search_highlighter,
+ text_view, cr);
cairo_restore (cr);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]