[gnome-builder] headerbar: implement global-search keyboard activation
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] headerbar: implement global-search keyboard activation
- Date: Tue, 28 Jun 2016 00:06:38 +0000 (UTC)
commit 43d66a5414bc38939cb692f88336841233fd61c5
Author: Christian Hergert <chergert redhat com>
Date: Fri Jun 24 13:37:04 2016 -0700
headerbar: implement global-search keyboard activation
This fixes keyboard activation of global search using the new headerbar
design.
libide/application/ide-application-actions.c | 10 +++++-----
libide/workbench/ide-workbench-actions.c | 17 ++++++++++++++++-
libide/workbench/ide-workbench-header-bar.c | 25 +++++++++++++------------
3 files changed, 34 insertions(+), 18 deletions(-)
---
diff --git a/libide/application/ide-application-actions.c b/libide/application/ide-application-actions.c
index 3b266eb..e43b77c 100644
--- a/libide/application/ide-application-actions.c
+++ b/libide/application/ide-application-actions.c
@@ -331,13 +331,13 @@ ide_application_actions_init (IdeApplication *self)
/*
* FIXME: Once we get a new shortcuts engine, port these to that.
*/
+ gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.help", help);
+ gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.preferences", preferences);
+ gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.shortcuts", shortcuts);
+ gtk_application_set_accels_for_action (GTK_APPLICATION (self), "dockbin.bottom-visible", bottom);
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "dockbin.left-visible", left);
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "dockbin.right-visible", right);
- gtk_application_set_accels_for_action (GTK_APPLICATION (self), "dockbin.bottom-visible", bottom);
- gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.preferences", preferences);
- gtk_application_set_accels_for_action (GTK_APPLICATION (self), "perspective.global-search", global_search);
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "perspective.new-file", new_file);
- gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.shortcuts", shortcuts);
- gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.help", help);
+ gtk_application_set_accels_for_action (GTK_APPLICATION (self), "win.global-search", global_search);
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "win.show-command-bar", command_bar);
}
diff --git a/libide/workbench/ide-workbench-actions.c b/libide/workbench/ide-workbench-actions.c
index dbe486f..c885699 100644
--- a/libide/workbench/ide-workbench-actions.c
+++ b/libide/workbench/ide-workbench-actions.c
@@ -24,8 +24,9 @@
#include "application/ide-application.h"
#include "buffers/ide-buffer-manager.h"
-#include "workbench/ide-workbench-private.h"
#include "workbench/ide-workbench.h"
+#include "workbench/ide-workbench-header-bar.h"
+#include "workbench/ide-workbench-private.h"
static void
ide_workbench_actions_open_with_dialog_cb (GObject *object,
@@ -179,11 +180,25 @@ ide_workbench_actions_opacity (GSimpleAction *action,
gtk_widget_set_opacity (GTK_WIDGET (workbench), opacity);
}
+static void
+ide_workbench_actions_global_search (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ IdeWorkbench *self = user_data;
+
+ g_assert (G_IS_SIMPLE_ACTION (action));
+ g_assert (IDE_IS_WORKBENCH (self));
+
+ ide_workbench_header_bar_focus_search (self->header_bar);
+}
+
void
ide_workbench_actions_init (IdeWorkbench *self)
{
GPropertyAction *action;
const GActionEntry actions[] = {
+ { "global-search", ide_workbench_actions_global_search },
{ "opacity", NULL, "i", "100", ide_workbench_actions_opacity },
{ "open-with-dialog", ide_workbench_actions_open_with_dialog },
{ "save-all", ide_workbench_actions_save_all },
diff --git a/libide/workbench/ide-workbench-header-bar.c b/libide/workbench/ide-workbench-header-bar.c
index dee31b6..dbb72cf 100644
--- a/libide/workbench/ide-workbench-header-bar.c
+++ b/libide/workbench/ide-workbench-header-bar.c
@@ -21,6 +21,7 @@
#include <egg-priority-box.h>
#include "application/ide-application.h"
+#include "search/ide-omni-search-entry.h"
#include "util/ide-gtk.h"
#include "workbench/ide-perspective.h"
#include "workbench/ide-workbench.h"
@@ -28,13 +29,14 @@
typedef struct
{
- GtkMenuButton *menu_button;
- EggPriorityBox *center_box;
- EggPriorityBox *center_right_box;
- EggPriorityBox *center_left_box;
- EggPriorityBox *right_box;
- EggPriorityBox *left_box;
- IdeOmniBar *omni_bar;
+ GtkMenuButton *menu_button;
+ EggPriorityBox *center_box;
+ EggPriorityBox *center_right_box;
+ EggPriorityBox *center_left_box;
+ EggPriorityBox *right_box;
+ EggPriorityBox *left_box;
+ IdeOmniBar *omni_bar;
+ IdeOmniSearchEntry *search_entry;
} IdeWorkbenchHeaderBarPrivate;
static void buildable_iface_init (GtkBuildableIface *iface);
@@ -56,12 +58,13 @@ ide_workbench_header_bar_class_init (IdeWorkbenchHeaderBarClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/ui/ide-workbench-header-bar.ui");
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, center_box);
- gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, center_right_box);
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, center_left_box);
+ gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, center_right_box);
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, left_box);
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, menu_button);
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, omni_bar);
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, right_box);
+ gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, search_entry);
}
static void
@@ -82,13 +85,11 @@ ide_workbench_header_bar_init (IdeWorkbenchHeaderBar *self)
void
ide_workbench_header_bar_focus_search (IdeWorkbenchHeaderBar *self)
{
- GtkWidget *entry;
+ IdeWorkbenchHeaderBarPrivate *priv = ide_workbench_header_bar_get_instance_private (self);
g_return_if_fail (IDE_IS_WORKBENCH_HEADER_BAR (self));
- entry = gtk_header_bar_get_custom_title (GTK_HEADER_BAR (self));
- if (GTK_IS_ENTRY (entry))
- gtk_widget_grab_focus (GTK_WIDGET (entry));
+ gtk_widget_grab_focus (GTK_WIDGET (priv->search_entry));
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]