Commit 43d66a54 authored by Christian Hergert's avatar Christian Hergert
Browse files

headerbar: implement global-search keyboard activation

This fixes keyboard activation of global search using the new headerbar
design.
parent 29391c36
......@@ -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);
}
......@@ -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 },
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment