[gnome-builder/global-search] workbench: wire up search widget to workbench.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/global-search] workbench: wire up search widget to workbench.
- Date: Sat, 13 Dec 2014 11:54:20 +0000 (UTC)
commit acf89a417c5a1f4137e7292d0964b2e16497a89b
Author: Christian Hergert <christian hergert me>
Date: Sat Dec 13 03:54:07 2014 -0800
workbench: wire up search widget to workbench.
src/resources/ui/gb-workbench.ui | 13 +++++++++-
src/workbench/gb-workbench.c | 51 ++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 1 deletions(-)
---
diff --git a/src/resources/ui/gb-workbench.ui b/src/resources/ui/gb-workbench.ui
index d3d6e3a..343e3cc 100644
--- a/src/resources/ui/gb-workbench.ui
+++ b/src/resources/ui/gb-workbench.ui
@@ -25,8 +25,9 @@
</object>
</child>
<child>
- <object class="GtkMenuButton" id="search_button">
+ <object class="GtkMenuButton" id="search_menu_button">
<property name="visible">True</property>
+ <property name="popover">search_popover</property>
<style>
<class name="image-button"/>
<class name="text-button"/>
@@ -246,4 +247,14 @@
</object>
</child>
</template>
+ <object class="GtkPopover" id="search_popover">
+ <property name="visible">True</property>
+ <property name="modal">True</property>
+ <property name="relative-to">search_entry</property>
+ <child>
+ <object class="GbSearchDisplay" id="search_display">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
</interface>
diff --git a/src/workbench/gb-workbench.c b/src/workbench/gb-workbench.c
index 06b9e1e..4d20e14 100644
--- a/src/workbench/gb-workbench.c
+++ b/src/workbench/gb-workbench.c
@@ -29,6 +29,7 @@
#include "gb-document-manager.h"
#include "gb-editor-workspace.h"
#include "gb-log.h"
+#include "gb-search-display.h"
#include "gb-widget.h"
#include "gb-workbench.h"
#include "gedit-menu-stack-switcher.h"
@@ -45,6 +46,9 @@ struct _GbWorkbenchPrivate
GbCreditsWidget *credits;
GbWorkspace *editor;
GtkMenuButton *add_button;
+ GtkMenuButton *search_menu_button;
+ GtkPopover *search_popover;
+ GbSearchDisplay *search_display;
GtkButton *back_button;
GeditMenuStackSwitcher *gear_menu_button;
GtkButton *new_tab;
@@ -374,6 +378,22 @@ on_roll_credits (GSimpleAction *action,
}
static void
+gb_workbench_search_focus (GbWorkbench *workbench,
+ GdkEventFocus *focus,
+ GtkSearchEntry *search_entry)
+{
+ GbWorkbenchPrivate *priv;
+
+ g_return_if_fail (GB_IS_WORKBENCH (workbench));
+ g_return_if_fail (GTK_IS_SEARCH_ENTRY (search_entry));
+
+ priv = workbench->priv;
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->search_menu_button),
+ TRUE);
+}
+
+static void
gb_workbench_constructed (GObject *object)
{
static const GActionEntry actions[] = {
@@ -433,6 +453,12 @@ gb_workbench_constructed (GObject *object)
G_CALLBACK (on_command_bar_notify_child_revealed),
workbench);
+ g_signal_connect_object (priv->search_entry,
+ "focus-in-event",
+ G_CALLBACK (gb_workbench_search_focus),
+ workbench,
+ G_CONNECT_SWAPPED);
+
G_OBJECT_CLASS (gb_workbench_parent_class)->constructed (object);
EXIT;
@@ -610,6 +636,16 @@ gb_workbench_delete_event (GtkWidget *widget,
}
static void
+gb_workbench_popover_closed (GbWorkbench *workbench,
+ GtkPopover *popover)
+{
+ g_return_if_fail (GB_IS_WORKBENCH (workbench));
+ g_return_if_fail (GTK_IS_POPOVER (popover));
+
+ gtk_widget_hide (GTK_WIDGET (popover));
+}
+
+static void
gb_workbench_dispose (GObject *object)
{
GbWorkbenchPrivate *priv;
@@ -732,8 +768,14 @@ gb_workbench_class_init (GbWorkbenchClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GbWorkbench,
header_bar);
gtk_widget_class_bind_template_child_private (widget_class, GbWorkbench,
+ search_display);
+ gtk_widget_class_bind_template_child_private (widget_class, GbWorkbench,
search_entry);
gtk_widget_class_bind_template_child_private (widget_class, GbWorkbench,
+ search_menu_button);
+ gtk_widget_class_bind_template_child_private (widget_class, GbWorkbench,
+ search_popover);
+ gtk_widget_class_bind_template_child_private (widget_class, GbWorkbench,
switcher);
gtk_widget_class_bind_template_child_private (widget_class, GbWorkbench,
stack);
@@ -741,6 +783,7 @@ gb_workbench_class_init (GbWorkbenchClass *klass)
g_type_ensure (GB_TYPE_COMMAND_BAR);
g_type_ensure (GB_TYPE_CREDITS_WIDGET);
g_type_ensure (GB_TYPE_EDITOR_WORKSPACE);
+ g_type_ensure (GB_TYPE_SEARCH_DISPLAY);
g_type_ensure (GEDIT_TYPE_MENU_STACK_SWITCHER);
}
@@ -770,4 +813,12 @@ gb_workbench_init (GbWorkbench *workbench)
workbench->priv->navigation_list = g_object_new (GB_TYPE_NAVIGATION_LIST,
"workbench", workbench,
NULL);
+
+ gtk_popover_set_relative_to (workbench->priv->search_popover,
+ GTK_WIDGET (workbench->priv->search_entry));
+ g_signal_connect_object (workbench->priv->search_popover,
+ "closed",
+ G_CALLBACK (gb_workbench_popover_closed),
+ workbench,
+ G_CONNECT_SWAPPED);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]