[gnome-builder/wip/chergert/hover] hover: use request-documentation to display hover info
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/hover] hover: use request-documentation to display hover info
- Date: Tue, 17 Jul 2018 19:29:13 +0000 (UTC)
commit f67eb189035262453ef12fa05cb4430086f11908
Author: Christian Hergert <chergert redhat com>
Date: Tue Jul 17 12:27:57 2018 -0700
hover: use request-documentation to display hover info
src/libide/hover/ide-hover-private.h | 12 +++++++-----
src/libide/hover/ide-hover.c | 32 ++++++++++++++++++++++++++++++++
src/libide/sourceview/ide-source-view.c | 27 ++++++---------------------
3 files changed, 45 insertions(+), 26 deletions(-)
---
diff --git a/src/libide/hover/ide-hover-private.h b/src/libide/hover/ide-hover-private.h
index 3d45b6fca..ba341cc18 100644
--- a/src/libide/hover/ide-hover-private.h
+++ b/src/libide/hover/ide-hover-private.h
@@ -28,10 +28,12 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (IdeHover, ide_hover, IDE, HOVER, GObject)
-IdeHover *_ide_hover_new (IdeSourceView *view);
-void _ide_hover_set_context (IdeHover *self,
- IdeContext *context);
-void _ide_hover_set_language (IdeHover *self,
- const gchar *language);
+IdeHover *_ide_hover_new (IdeSourceView *view);
+void _ide_hover_display (IdeHover *self,
+ const GtkTextIter *iter);
+void _ide_hover_set_context (IdeHover *self,
+ IdeContext *context);
+void _ide_hover_set_language (IdeHover *self,
+ const gchar *language);
G_END_DECLS
diff --git a/src/libide/hover/ide-hover.c b/src/libide/hover/ide-hover.c
index a7b38f029..832c513c2 100644
--- a/src/libide/hover/ide-hover.c
+++ b/src/libide/hover/ide-hover.c
@@ -329,6 +329,38 @@ ide_hover_delay_display (IdeHover *self)
self, NULL);
}
+void
+_ide_hover_display (IdeHover *self,
+ const GtkTextIter *iter)
+{
+ IdeSourceView *view;
+ GdkRectangle rect;
+
+ g_assert (IDE_IS_HOVER (self));
+ g_assert (iter != NULL);
+
+ if (self->state != IDE_HOVER_STATE_INITIAL)
+ return;
+
+ if (!(view = dzl_signal_group_get_target (self->signals)))
+ return;
+
+ g_assert (GTK_IS_TEXT_VIEW (view));
+
+ dzl_clear_source (&self->delay_display_source);
+
+ gtk_text_view_get_iter_location (GTK_TEXT_VIEW (view), iter, &rect);
+ gtk_text_view_buffer_to_window_coords (GTK_TEXT_VIEW (view),
+ GTK_TEXT_WINDOW_TEXT,
+ rect.x, rect.y,
+ &rect.x, &rect.y);
+
+ self->motion_x = rect.x;
+ self->motion_y = rect.y;
+
+ ide_hover_motion_timeout_cb (self);
+}
+
static inline gboolean
should_ignore_event (IdeSourceView *view,
GdkWindow *event_window)
diff --git a/src/libide/sourceview/ide-source-view.c b/src/libide/sourceview/ide-source-view.c
index fc2811523..faa0343aa 100644
--- a/src/libide/sourceview/ide-source-view.c
+++ b/src/libide/sourceview/ide-source-view.c
@@ -230,7 +230,6 @@ enum {
CLEAR_SELECTION,
CLEAR_SNIPPETS,
CYCLE_COMPLETION,
- DOCUMENTATION_REQUESTED,
DECREASE_FONT_SIZE,
DELETE_SELECTION,
DRAW_BUBBLES,
@@ -5260,31 +5259,17 @@ ide_source_view_real_find_references (IdeSourceView *self)
static void
ide_source_view_real_request_documentation (IdeSourceView *self)
{
- g_autofree gchar *word = NULL;
- GtkTextBuffer *buffer;
- GtkTextIter begin;
- GtkTextIter end;
+ IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+ GtkTextIter iter;
g_assert (IDE_IS_SOURCE_VIEW (self));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self));
-
- if (!gtk_text_buffer_get_selection_bounds (buffer, &begin, &end))
- {
- gtk_text_iter_order (&begin, &end);
-
- if (!_ide_source_iter_starts_extra_natural_word (&begin))
- {
- _ide_source_iter_backward_extra_natural_word_start (&begin);
- end = begin;
- }
-
- _ide_source_iter_forward_extra_natural_word_end (&end);
- }
+ if (priv->buffer == NULL)
+ return;
- word = gtk_text_iter_get_slice (&begin, &end);
+ ide_buffer_get_selection_bounds (priv->buffer, &iter, NULL);
- g_signal_emit (self, signals [DOCUMENTATION_REQUESTED], 0, word);
+ _ide_hover_display (priv->hover, &iter);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]