[gnome-builder/wip/chergert/perspective] devhelp: fix shift+k documentation search
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/perspective] devhelp: fix shift+k documentation search
- Date: Mon, 14 Dec 2015 10:57:04 +0000 (UTC)
commit 475fc0ebeb983f5ad9655325cce4e2757295da60
Author: Christian Hergert <chergert redhat com>
Date: Mon Dec 14 02:56:17 2015 -0800
devhelp: fix shift+k documentation search
libide/editor/ide-editor-frame.c | 27 --------
libide/editor/ide-editor-view.c | 4 +-
plugins/devhelp/Makefile.am | 2 +
plugins/devhelp/gbp-devhelp-editor-view-addin.c | 81 +++++++++++++++++++++++
plugins/devhelp/gbp-devhelp-editor-view-addin.h | 32 +++++++++
plugins/devhelp/gbp-devhelp-panel.c | 7 ++-
plugins/devhelp/gbp-devhelp-panel.h | 3 +-
plugins/devhelp/gbp-devhelp-plugin.c | 4 +
plugins/devhelp/gbp-devhelp-workbench-addin.c | 2 +-
9 files changed, 130 insertions(+), 32 deletions(-)
---
diff --git a/libide/editor/ide-editor-frame.c b/libide/editor/ide-editor-frame.c
index 546ec42..df5d4d3 100644
--- a/libide/editor/ide-editor-frame.c
+++ b/libide/editor/ide-editor-frame.c
@@ -555,27 +555,6 @@ ide_editor_frame__source_view_focus_location (IdeEditorFrame *self,
ide_editor_perspective_focus_location (IDE_EDITOR_PERSPECTIVE (editor), location);
}
-static void
-ide_editor_frame__source_view_request_documentation (IdeEditorFrame *self,
- IdeSourceView *source_view)
-{
- GtkTextBuffer *buffer;
- GtkTextIter begin;
- GtkTextIter end;
- GVariant *param;
- g_autofree gchar *text = NULL;
-
- g_assert (IDE_IS_EDITOR_FRAME (self));
- g_assert (IDE_IS_SOURCE_VIEW (source_view));
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (source_view));
- gtk_text_buffer_get_selection_bounds (buffer, &begin, &end);
- text = gtk_text_iter_get_slice (&begin, &end);
-
- param = g_variant_new_string (text);
- ide_widget_action (GTK_WIDGET (self), "workbench", "search-docs", param);
-}
-
static gboolean
ide_editor_frame_get_show_map (IdeEditorFrame *self)
{
@@ -698,12 +677,6 @@ ide_editor_frame_constructed (GObject *object)
self,
G_CONNECT_SWAPPED);
- g_signal_connect_object (self->source_view,
- "request-documentation",
- G_CALLBACK (ide_editor_frame__source_view_request_documentation),
- self,
- G_CONNECT_SWAPPED);
-
g_signal_connect_object (self->search_entry,
"key-press-event",
G_CALLBACK (ide_editor_frame__search_key_press_event),
diff --git a/libide/editor/ide-editor-view.c b/libide/editor/ide-editor-view.c
index 2d0d631..3f4c6f9 100644
--- a/libide/editor/ide-editor-view.c
+++ b/libide/editor/ide-editor-view.c
@@ -422,8 +422,8 @@ ide_editor_view_grab_focus (GtkWidget *widget)
}
static void
-ide_editor_view_request_documentation (IdeEditorView *self,
- IdeSourceView *source_view)
+ide_editor_view_request_documentation (IdeEditorView *self,
+ IdeSourceView *source_view)
{
g_autofree gchar *word = NULL;
IdeBuffer *buffer;
diff --git a/plugins/devhelp/Makefile.am b/plugins/devhelp/Makefile.am
index 16dfe2b..9065c3c 100644
--- a/plugins/devhelp/Makefile.am
+++ b/plugins/devhelp/Makefile.am
@@ -10,6 +10,8 @@ plugin_LTLIBRARIES = libdevhelp-plugin.la
dist_plugin_DATA = devhelp.plugin
libdevhelp_plugin_la_SOURCES = \
+ gbp-devhelp-editor-view-addin.c \
+ gbp-devhelp-editor-view-addin.h \
gbp-devhelp-panel.c \
gbp-devhelp-panel.h \
gbp-devhelp-plugin.c \
diff --git a/plugins/devhelp/gbp-devhelp-editor-view-addin.c b/plugins/devhelp/gbp-devhelp-editor-view-addin.c
new file mode 100644
index 0000000..73fb07b
--- /dev/null
+++ b/plugins/devhelp/gbp-devhelp-editor-view-addin.c
@@ -0,0 +1,81 @@
+/* gbp-devhelp-editor-view-addin.c
+ *
+ * Copyright (C) 2015 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gbp-devhelp-editor-view-addin.h"
+#include "gbp-devhelp-panel.h"
+
+struct _GbpDevhelpEditorViewAddin
+{
+ GObject parent_instance;
+};
+
+static void iface_init (IdeEditorViewAddinInterface *iface);
+
+G_DEFINE_TYPE_EXTENDED (GbpDevhelpEditorViewAddin, gbp_devhelp_editor_view_addin, G_TYPE_OBJECT, 0,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_EDITOR_VIEW_ADDIN, iface_init))
+
+static void
+request_documentation_cb (GbpDevhelpEditorViewAddin *self,
+ const gchar *word,
+ IdeEditorView *view)
+{
+ GtkWidget *layout;
+ GtkWidget *panel;
+ GtkWidget *pane;
+
+ g_assert (IDE_IS_EDITOR_VIEW (view));
+ g_assert (GBP_IS_DEVHELP_EDITOR_VIEW_ADDIN (self));
+
+ layout = gtk_widget_get_ancestor (GTK_WIDGET (view), IDE_TYPE_LAYOUT);
+ if (layout == NULL)
+ return;
+
+ pane = ide_layout_get_right_pane (IDE_LAYOUT (layout));
+ panel = ide_widget_find_child_typed (pane, GBP_TYPE_DEVHELP_PANEL);
+ gbp_devhelp_panel_focus_search (GBP_DEVHELP_PANEL (panel), word);
+}
+
+static void
+gbp_devhelp_editor_view_addin_load (IdeEditorViewAddin *addin,
+ IdeEditorView *view)
+{
+ g_assert (GBP_IS_DEVHELP_EDITOR_VIEW_ADDIN (addin));
+ g_assert (IDE_IS_EDITOR_VIEW (view));
+
+ g_signal_connect_object (view,
+ "request-documentation",
+ G_CALLBACK (request_documentation_cb),
+ addin,
+ G_CONNECT_SWAPPED);
+}
+
+static void
+gbp_devhelp_editor_view_addin_class_init (GbpDevhelpEditorViewAddinClass *klass)
+{
+}
+
+static void
+gbp_devhelp_editor_view_addin_init (GbpDevhelpEditorViewAddin *self)
+{
+}
+
+static void
+iface_init (IdeEditorViewAddinInterface *iface)
+{
+ iface->load = gbp_devhelp_editor_view_addin_load;
+}
diff --git a/plugins/devhelp/gbp-devhelp-editor-view-addin.h b/plugins/devhelp/gbp-devhelp-editor-view-addin.h
new file mode 100644
index 0000000..f898e16
--- /dev/null
+++ b/plugins/devhelp/gbp-devhelp-editor-view-addin.h
@@ -0,0 +1,32 @@
+/* gbp-devhelp-editor-view-addin.h
+ *
+ * Copyright (C) 2015 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GBP_DEVHELP_EDITOR_VIEW_ADDIN_H
+#define GBP_DEVHELP_EDITOR_VIEW_ADDIN_H
+
+#include <ide.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_DEVHELP_EDITOR_VIEW_ADDIN (gbp_devhelp_editor_view_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpDevhelpEditorViewAddin, gbp_devhelp_editor_view_addin, GBP,
DEVHELP_EDITOR_VIEW_ADDIN, GObject)
+
+G_END_DECLS
+
+#endif /* GBP_DEVHELP_EDITOR_VIEW_ADDIN_H */
diff --git a/plugins/devhelp/gbp-devhelp-panel.c b/plugins/devhelp/gbp-devhelp-panel.c
index 3b0577c..187b49b 100644
--- a/plugins/devhelp/gbp-devhelp-panel.c
+++ b/plugins/devhelp/gbp-devhelp-panel.c
@@ -184,7 +184,8 @@ gbp_devhelp_panel_init (GbpDevhelpPanel *self)
}
void
-gbp_devhelp_panel_focus_search (GbpDevhelpPanel *self)
+gbp_devhelp_panel_focus_search (GbpDevhelpPanel *self,
+ const gchar *keyword)
{
IdeWorkbench *workbench;
@@ -192,5 +193,9 @@ gbp_devhelp_panel_focus_search (GbpDevhelpPanel *self)
workbench = ide_widget_get_workbench (GTK_WIDGET (self));
ide_workbench_focus (workbench, GTK_WIDGET (self->sidebar));
+
dh_sidebar_set_search_focus (self->sidebar);
+
+ if (keyword)
+ dh_sidebar_set_search_string (self->sidebar, keyword);
}
diff --git a/plugins/devhelp/gbp-devhelp-panel.h b/plugins/devhelp/gbp-devhelp-panel.h
index b52dcb7..40f6c4d 100644
--- a/plugins/devhelp/gbp-devhelp-panel.h
+++ b/plugins/devhelp/gbp-devhelp-panel.h
@@ -29,7 +29,8 @@ G_DECLARE_FINAL_TYPE (GbpDevhelpPanel, gbp_devhelp_panel, GBP, DEVHELP_PANEL, Gt
void gbp_devhelp_panel_set_uri (GbpDevhelpPanel *self,
const gchar *uri);
-void gbp_devhelp_panel_focus_search (GbpDevhelpPanel *self);
+void gbp_devhelp_panel_focus_search (GbpDevhelpPanel *self,
+ const gchar *keyword);
G_END_DECLS
diff --git a/plugins/devhelp/gbp-devhelp-plugin.c b/plugins/devhelp/gbp-devhelp-plugin.c
index 3d2a158..b9ba4f6 100644
--- a/plugins/devhelp/gbp-devhelp-plugin.c
+++ b/plugins/devhelp/gbp-devhelp-plugin.c
@@ -19,6 +19,7 @@
#include <ide.h>
#include <libpeas/peas.h>
+#include "gbp-devhelp-editor-view-addin.h"
#include "gbp-devhelp-search-provider.h"
#include "gbp-devhelp-workbench-addin.h"
@@ -26,6 +27,9 @@ void
peas_register_types (PeasObjectModule *module)
{
peas_object_module_register_extension_type (module,
+ IDE_TYPE_EDITOR_VIEW_ADDIN,
+ GBP_TYPE_DEVHELP_EDITOR_VIEW_ADDIN);
+ peas_object_module_register_extension_type (module,
IDE_TYPE_WORKBENCH_ADDIN,
GBP_TYPE_DEVHELP_WORKBENCH_ADDIN);
peas_object_module_register_extension_type (module,
diff --git a/plugins/devhelp/gbp-devhelp-workbench-addin.c b/plugins/devhelp/gbp-devhelp-workbench-addin.c
index d8d5a63..9bae37d 100644
--- a/plugins/devhelp/gbp-devhelp-workbench-addin.c
+++ b/plugins/devhelp/gbp-devhelp-workbench-addin.c
@@ -57,7 +57,7 @@ focus_devhelp_search (GSimpleAction *action,
g_assert (GBP_IS_DEVHELP_WORKBENCH_ADDIN (self));
- gbp_devhelp_panel_focus_search (self->panel);
+ gbp_devhelp_panel_focus_search (self->panel, NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]