[gnome-builder] devhelp: add action to focus devhelp search
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] devhelp: add action to focus devhelp search
- Date: Mon, 21 Dec 2015 08:02:37 +0000 (UTC)
commit 12cbe4a732b4c2032600fa9a22370e9c3eec013c
Author: Christian Hergert <chergert redhat com>
Date: Sat Dec 5 23:41:15 2015 -0800
devhelp: add action to focus devhelp search
plugins/devhelp/gbp-devhelp-panel.c | 13 +++++++++++++
plugins/devhelp/gbp-devhelp-panel.h | 5 +++--
plugins/devhelp/gbp-devhelp-workbench-addin.c | 19 +++++++++++++++++++
3 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/plugins/devhelp/gbp-devhelp-panel.c b/plugins/devhelp/gbp-devhelp-panel.c
index 37588a6..3b0577c 100644
--- a/plugins/devhelp/gbp-devhelp-panel.c
+++ b/plugins/devhelp/gbp-devhelp-panel.c
@@ -25,6 +25,7 @@
struct _GbpDevhelpPanel
{
GtkBin parent_instance;
+
DhBookManager *books;
DhSidebar *sidebar;
};
@@ -181,3 +182,15 @@ static void
gbp_devhelp_panel_init (GbpDevhelpPanel *self)
{
}
+
+void
+gbp_devhelp_panel_focus_search (GbpDevhelpPanel *self)
+{
+ IdeWorkbench *workbench;
+
+ g_return_if_fail (GBP_IS_DEVHELP_PANEL (self));
+
+ workbench = ide_widget_get_workbench (GTK_WIDGET (self));
+ ide_workbench_focus (workbench, GTK_WIDGET (self->sidebar));
+ dh_sidebar_set_search_focus (self->sidebar);
+}
diff --git a/plugins/devhelp/gbp-devhelp-panel.h b/plugins/devhelp/gbp-devhelp-panel.h
index 50437d8..b52dcb7 100644
--- a/plugins/devhelp/gbp-devhelp-panel.h
+++ b/plugins/devhelp/gbp-devhelp-panel.h
@@ -27,8 +27,9 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GbpDevhelpPanel, gbp_devhelp_panel, GBP, DEVHELP_PANEL, GtkBin)
-void gbp_devhelp_panel_set_uri (GbpDevhelpPanel *self,
- const gchar *uri);
+void gbp_devhelp_panel_set_uri (GbpDevhelpPanel *self,
+ const gchar *uri);
+void gbp_devhelp_panel_focus_search (GbpDevhelpPanel *self);
G_END_DECLS
diff --git a/plugins/devhelp/gbp-devhelp-workbench-addin.c b/plugins/devhelp/gbp-devhelp-workbench-addin.c
index 2a21803..e38f05a 100644
--- a/plugins/devhelp/gbp-devhelp-workbench-addin.c
+++ b/plugins/devhelp/gbp-devhelp-workbench-addin.c
@@ -49,12 +49,25 @@ gbp_devhelp_workbench_addin_init (GbpDevhelpWorkbenchAddin *self)
}
static void
+focus_devhelp_search (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbpDevhelpWorkbenchAddin *self = user_data;
+
+ g_assert (GBP_IS_DEVHELP_WORKBENCH_ADDIN (self));
+
+ gbp_devhelp_panel_focus_search (self->panel);
+}
+
+static void
gbp_devhelp_workbench_addin_load (IdeWorkbenchAddin *addin,
IdeWorkbench *workbench)
{
GbpDevhelpWorkbenchAddin *self = (GbpDevhelpWorkbenchAddin *)addin;
IdePerspective *perspective;
GtkWidget *pane;
+ GSimpleAction *action;
g_assert (IDE_IS_WORKBENCH_ADDIN (self));
g_assert (IDE_IS_WORKBENCH (workbench));
@@ -74,6 +87,10 @@ gbp_devhelp_workbench_addin_load (IdeWorkbenchAddin *addin,
NULL);
ide_layout_pane_add_page (IDE_LAYOUT_PANE (pane), GTK_WIDGET (self->panel),
_("Devhelp"), "devhelp-symbolic");
+
+ action = g_simple_action_new ("focus-devhelp-search", NULL);
+ g_signal_connect_object (action, "activate", G_CALLBACK (focus_devhelp_search), self, 0);
+ g_action_map_add_action (G_ACTION_MAP (workbench), G_ACTION (action));
}
static void
@@ -96,6 +113,8 @@ gbp_devhelp_workbench_addin_unload (IdeWorkbenchAddin *addin,
g_assert (IDE_IS_LAYOUT_PANE (pane));
ide_layout_pane_remove_page (IDE_LAYOUT_PANE (pane), GTK_WIDGET (self->panel));
+
+ g_action_map_remove_action (G_ACTION_MAP (workbench), "focus-devhelp-search");
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]