[gnome-builder/wip/plugins] devhelp: add accelerator for devhelp search



commit 74f024a7703848ab03d177e0608657816c9e67c8
Author: Christian Hergert <christian hergert me>
Date:   Wed Jun 10 21:42:12 2015 -0700

    devhelp: add accelerator for devhelp search
    
    Part of me wants the panel to hover in, and then disappear on focus-out.

 plugins/devhelp/gb-devhelp-panel.c |   38 ++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/plugins/devhelp/gb-devhelp-panel.c b/plugins/devhelp/gb-devhelp-panel.c
index 6d70df5..816e0ca 100644
--- a/plugins/devhelp/gb-devhelp-panel.c
+++ b/plugins/devhelp/gb-devhelp-panel.c
@@ -57,11 +57,35 @@ enum {
 static GParamSpec *gParamSpecs [LAST_PROP];
 
 static void
+focus_devhelp_search_cb (GSimpleAction  *action,
+                         GVariant       *variant,
+                         GbDevhelpPanel *self)
+{
+  GtkWidget *workspace;
+  GtkWidget *pane;
+
+  g_assert (G_IS_SIMPLE_ACTION (action));
+  g_assert (GB_IS_DEVHELP_PANEL (self));
+
+  workspace = gb_workbench_get_workspace (self->workbench);
+  pane = gb_workspace_get_right_pane (GB_WORKSPACE (workspace));
+
+  gtk_container_child_set (GTK_CONTAINER (workspace), pane,
+                           "reveal", TRUE,
+                           NULL);
+
+  dh_sidebar_set_search_focus (DH_SIDEBAR (self->sidebar));
+}
+
+static void
 gb_devhelp_panel_load (GbWorkbenchAddin *addin)
 {
   GbDevhelpPanel *self = (GbDevhelpPanel *)addin;
   GtkWidget *workspace;
   GtkWidget *pane;
+  const gchar * const accels[] = { "<ctrl><shift>f", NULL };
+  GSimpleAction *action;
+  GApplication *app;
 
   g_assert (GB_IS_DEVHELP_PANEL (self));
 
@@ -70,6 +94,20 @@ gb_devhelp_panel_load (GbWorkbenchAddin *addin)
   gb_workspace_pane_add_page (GB_WORKSPACE_PANE (pane), GTK_WIDGET (self),
                               _("Documentation"), "help-contents-symbolic");
 
+  action = g_simple_action_new ("focus-devhelp-search", NULL);
+  g_signal_connect_object (action,
+                           "activate",
+                           G_CALLBACK (focus_devhelp_search_cb),
+                           self,
+                           0);
+  g_action_map_add_action (G_ACTION_MAP (self->workbench), G_ACTION (action));
+  g_clear_object (&action);
+
+  app = g_application_get_default ();
+  gtk_application_set_accels_for_action (GTK_APPLICATION (app),
+                                         "win.focus-devhelp-search",
+                                         accels);
+
   gtk_widget_show (GTK_WIDGET (self));
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]