[gnome-builder/wip/chergert/layout] editor: add context menu back to search entry
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/layout] editor: add context menu back to search entry
- Date: Wed, 12 Jul 2017 21:24:28 +0000 (UTC)
commit d2c17eb2729798c1a90d322ec901098d969080d9
Author: Christian Hergert <chergert redhat com>
Date: Wed Jul 12 14:22:13 2017 -0700
editor: add context menu back to search entry
data/gtk/menus.ui | 32 ++++++++++++++++++++++----------
libide/editor/ide-editor-search-bar.c | 25 +++++++++++++++++++++++++
2 files changed, 47 insertions(+), 10 deletions(-)
---
diff --git a/data/gtk/menus.ui b/data/gtk/menus.ui
index b5dc219..afec72a 100644
--- a/data/gtk/menus.ui
+++ b/data/gtk/menus.ui
@@ -222,35 +222,47 @@
</submenu>
</section>
</menu>
- <menu id="ide-editor-frame-search-menu">
- <section id="ide-editor-frame-search-menu-settings-section">
+ <menu id="ide-editor-search-bar-entry-menu">
+ <section id="ide-editor-search-bar-entry-menu-settings-section">
+ <item>
+ <attribute name="label" translatable="yes">Regular expressions</attribute>
+ <attribute name="action">search-settings.regex-enabled</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Case sensitive</attribute>
+ <attribute name="action">search-settings.case-sensitive</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Match whole word only</attribute>
+ <attribute name="action">search-settings.at-word-boundaries</attribute>
+ </item>
<item>
<attribute name="label" translatable="yes">_Wrap Around</attribute>
- <attribute name="action">search-entry.change-wrap-around</attribute>
+ <attribute name="action">search-settings.wrap-around</attribute>
</item>
</section>
- <section id="ide-editor-frame-search-menu-clipboard-section">
+ <section id="ide-editor-search-bar-entry-menu-clipboard-section">
<item>
<attribute name="label" translatable="yes">Cu_t</attribute>
- <attribute name="action">search-entry.cut-clipboard</attribute>
+ <attribute name="action">entry.cut-clipboard</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Copy</attribute>
- <attribute name="action">search-entry.copy-clipboard</attribute>
+ <attribute name="action">entry.copy-clipboard</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Paste</attribute>
- <attribute name="action">search-entry.paste-clipboard</attribute>
+ <attribute name="action">entry.paste-clipboard</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Delete</attribute>
- <attribute name="action">search-entry.delete-selection</attribute>
+ <attribute name="action">entry.delete-selection</attribute>
</item>
</section>
- <section id="ide-editor-frame-search-menu-selection-section">
+ <section id="ide-editor-search-bar-entry-menu-selection-section">
<item>
<attribute name="label" translatable="yes">Select _All</attribute>
- <attribute name="action">search-entry.select-all</attribute>
+ <attribute name="action">entry.select-all</attribute>
</item>
</section>
</menu>
diff --git a/libide/editor/ide-editor-search-bar.c b/libide/editor/ide-editor-search-bar.c
index 56f6839..cb4f5af 100644
--- a/libide/editor/ide-editor-search-bar.c
+++ b/libide/editor/ide-editor-search-bar.c
@@ -23,6 +23,7 @@
#include "ide-macros.h"
+#include "application/ide-application.h"
#include "editor/ide-editor-search-bar.h"
struct _IdeEditorSearchBar
@@ -549,6 +550,23 @@ ide_editor_search_bar_bind_settings (IdeEditorSearchBar *self,
}
static void
+search_entry_populate_popup (IdeEditorSearchBar *self,
+ GtkWidget *widget,
+ GdTaggedEntry *entry)
+{
+ g_assert (IDE_IS_EDITOR_SEARCH_BAR (self));
+ g_assert (GTK_IS_MENU (widget));
+ g_assert (GTK_IS_ENTRY (entry));
+
+ if (GTK_IS_MENU (widget))
+ {
+ DzlApplication *app = DZL_APPLICATION (IDE_APPLICATION_DEFAULT);
+ GMenu *menu = dzl_application_get_menu_by_id (app, "ide-editor-search-bar-entry-menu");
+ gtk_menu_shell_bind_model (GTK_MENU_SHELL (widget), G_MENU_MODEL (menu), NULL, TRUE);
+ }
+}
+
+static void
ide_editor_search_bar_destroy (GtkWidget *widget)
{
IdeEditorSearchBar *self = (IdeEditorSearchBar *)widget;
@@ -718,6 +736,13 @@ ide_editor_search_bar_init (IdeEditorSearchBar *self)
G_N_ELEMENTS (search_bar_actions),
self);
gtk_widget_insert_action_group (GTK_WIDGET (self), "search-bar", G_ACTION_GROUP (actions));
+
+ dzl_widget_action_group_attach (self->search_entry, "entry");
+
+ g_signal_connect_swapped (self->search_entry,
+ "populate-popup",
+ G_CALLBACK (search_entry_populate_popup),
+ self);
}
GtkWidget *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]