[gnome-builder/wip/gtk4-port] libide/search: stub out search popover
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/search: stub out search popover
- Date: Wed, 13 Apr 2022 00:25:13 +0000 (UTC)
commit fc0bfbd43d8d94122848d086b781d1b6d6940e1a
Author: Christian Hergert <chergert redhat com>
Date: Tue Apr 12 17:20:49 2022 -0700
libide/search: stub out search popover
src/libide/search/ide-search-init.c | 35 ++++++
src/libide/search/ide-search-popover.c | 149 ++++++++++++++++++++++++++
src/libide/search/ide-search-popover.h | 43 ++++++++
src/libide/search/ide-search-popover.ui | 24 +++++
src/libide/search/ide-search-private.h | 29 +++++
src/libide/search/libide-search.gresource.xml | 6 ++
src/libide/search/libide-search.h | 23 ++--
src/libide/search/meson.build | 19 +++-
src/main.c | 2 +
9 files changed, 317 insertions(+), 13 deletions(-)
---
diff --git a/src/libide/search/ide-search-init.c b/src/libide/search/ide-search-init.c
new file mode 100644
index 000000000..74cbffbba
--- /dev/null
+++ b/src/libide/search/ide-search-init.c
@@ -0,0 +1,35 @@
+/* ide-search-init.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "ide-search-init"
+
+#include "config.h"
+
+#include "ide-search-popover.h"
+#include "ide-search-private.h"
+#include "ide-search-resources.h"
+
+void
+_ide_search_init (void)
+{
+ g_type_ensure (IDE_TYPE_SEARCH_POPOVER);
+
+ g_resources_register (ide_search_get_resource ());
+}
diff --git a/src/libide/search/ide-search-popover.c b/src/libide/search/ide-search-popover.c
new file mode 100644
index 000000000..c0d1ef2a1
--- /dev/null
+++ b/src/libide/search/ide-search-popover.c
@@ -0,0 +1,149 @@
+/* ide-search-popover.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "ide-search-popover"
+
+#include "config.h"
+
+#include "ide-search-popover.h"
+#include "ide-search-resources.h"
+
+struct _IdeSearchPopover
+{
+ GtkPopover parent_instance;
+ IdeContext *context;
+};
+
+enum {
+ PROP_0,
+ PROP_CONTEXT,
+ N_PROPS
+};
+
+G_DEFINE_FINAL_TYPE (IdeSearchPopover, ide_search_popover, GTK_TYPE_POPOVER)
+
+static GParamSpec *properties [N_PROPS];
+
+static void
+ide_search_popover_set_context (IdeSearchPopover *self,
+ IdeContext *context)
+{
+ g_assert (IDE_IS_SEARCH_POPOVER (self));
+ g_assert (IDE_IS_CONTEXT (context));
+
+ if (g_set_object (&self->context, context))
+ {
+ /* TODO: Setup addins */
+ }
+}
+
+static void
+ide_search_popover_dispose (GObject *object)
+{
+ IdeSearchPopover *self = (IdeSearchPopover *)object;
+
+ g_clear_object (&self->context);
+
+ G_OBJECT_CLASS (ide_search_popover_parent_class)->dispose (object);
+}
+
+static void
+ide_search_popover_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ IdeSearchPopover *self = IDE_SEARCH_POPOVER (object);
+
+ switch (prop_id)
+ {
+ case PROP_CONTEXT:
+ g_value_set_object (value, ide_search_popover_get_context (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ide_search_popover_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ IdeSearchPopover *self = IDE_SEARCH_POPOVER (object);
+
+ switch (prop_id)
+ {
+ case PROP_CONTEXT:
+ ide_search_popover_set_context (self, g_value_get_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ide_search_popover_class_init (IdeSearchPopoverClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->dispose = ide_search_popover_dispose;
+ object_class->get_property = ide_search_popover_get_property;
+ object_class->set_property = ide_search_popover_set_property;
+
+ properties [PROP_CONTEXT] =
+ g_param_spec_object ("context",
+ "Context",
+ "The project context",
+ IDE_TYPE_CONTEXT,
+ (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
+
+ g_resources_register (ide_search_get_resource ());
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/libide-search/ide-search-popover.ui");
+}
+
+static void
+ide_search_popover_init (IdeSearchPopover *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+/**
+ * ide_search_popover_get_context:
+ * @self: a #IdeSearchPopover
+ *
+ * Gets the context for the search popover.
+ *
+ * Returns: (transfer none) (nullable): an #IdeContext or %NULL
+ */
+IdeContext *
+ide_search_popover_get_context (IdeSearchPopover *self)
+{
+ g_return_val_if_fail (IDE_IS_SEARCH_POPOVER (self), NULL);
+
+ return self->context;
+}
diff --git a/src/libide/search/ide-search-popover.h b/src/libide/search/ide-search-popover.h
new file mode 100644
index 000000000..0991be5a7
--- /dev/null
+++ b/src/libide/search/ide-search-popover.h
@@ -0,0 +1,43 @@
+/* ide-search-popover.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#if !defined (IDE_SEARCH_INSIDE) && !defined (IDE_SEARCH_COMPILATION)
+# error "Only <libide-search.h> can be included directly."
+#endif
+
+#include <gtk/gtk.h>
+
+#include <libide-core.h>
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_SEARCH_POPOVER (ide_search_popover_get_type())
+
+IDE_AVAILABLE_IN_ALL
+G_DECLARE_FINAL_TYPE (IdeSearchPopover, ide_search_popover, IDE, SEARCH_POPOVER, GtkPopover)
+
+IDE_AVAILABLE_IN_ALL
+GtkWidget *ide_search_popover_new (IdeContext *context);
+IDE_AVAILABLE_IN_ALL
+IdeContext *ide_search_popover_get_context (IdeSearchPopover *self);
+
+G_END_DECLS
diff --git a/src/libide/search/ide-search-popover.ui b/src/libide/search/ide-search-popover.ui
new file mode 100644
index 000000000..f3e0350dc
--- /dev/null
+++ b/src/libide/search/ide-search-popover.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="IdeSearchPopover" parent="GtkPopover">
+ <property name="has-arrow">false</property>
+ <property name="width-request">500</property>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="vexpand">true</property>
+ <child>
+ <object class="GtkHeaderBar">
+ <property name="show-title-buttons">false</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="vexpand">true</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/libide/search/ide-search-private.h b/src/libide/search/ide-search-private.h
new file mode 100644
index 000000000..7eb678f2a
--- /dev/null
+++ b/src/libide/search/ide-search-private.h
@@ -0,0 +1,29 @@
+/* ide-search-private.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+void _ide_search_init (void);
+
+G_END_DECLS
diff --git a/src/libide/search/libide-search.gresource.xml b/src/libide/search/libide-search.gresource.xml
new file mode 100644
index 000000000..baf08e378
--- /dev/null
+++ b/src/libide/search/libide-search.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/libide-search">
+ <file preprocess="xml-stripblanks">ide-search-popover.ui</file>
+ </gresource>
+</gresources>
diff --git a/src/libide/search/libide-search.h b/src/libide/search/libide-search.h
index da0730aec..f7168f90d 100644
--- a/src/libide/search/libide-search.h
+++ b/src/libide/search/libide-search.h
@@ -24,16 +24,15 @@
#include <libide-threading.h>
#define IDE_SEARCH_INSIDE
-
-#include "ide-fuzzy-index-builder.h"
-#include "ide-fuzzy-index-cursor.h"
-#include "ide-fuzzy-index.h"
-#include "ide-fuzzy-index-match.h"
-#include "ide-fuzzy-mutable-index.h"
-#include "ide-pattern-spec.h"
-#include "ide-search-engine.h"
-#include "ide-search-provider.h"
-#include "ide-search-reducer.h"
-#include "ide-search-result.h"
-
+# include "ide-fuzzy-index-builder.h"
+# include "ide-fuzzy-index-cursor.h"
+# include "ide-fuzzy-index.h"
+# include "ide-fuzzy-index-match.h"
+# include "ide-fuzzy-mutable-index.h"
+# include "ide-pattern-spec.h"
+# include "ide-search-engine.h"
+# include "ide-search-popover.h"
+# include "ide-search-provider.h"
+# include "ide-search-reducer.h"
+# include "ide-search-result.h"
#undef IDE_SEARCH_INSIDE
diff --git a/src/libide/search/meson.build b/src/libide/search/meson.build
index 075b5725c..a7a708904 100644
--- a/src/libide/search/meson.build
+++ b/src/libide/search/meson.build
@@ -14,6 +14,7 @@ libide_search_public_headers = [
'ide-fuzzy-mutable-index.h',
'ide-pattern-spec.h',
'ide-search-engine.h',
+ 'ide-search-popover.h',
'ide-search-provider.h',
'ide-search-reducer.h',
'ide-search-result.h',
@@ -34,12 +35,28 @@ libide_search_public_sources = [
'ide-fuzzy-mutable-index.c',
'ide-pattern-spec.c',
'ide-search-engine.c',
+ 'ide-search-popover.c',
'ide-search-provider.c',
'ide-search-reducer.c',
'ide-search-result.c',
]
-libide_search_sources = libide_search_public_sources
+libide_search_private_sources = [
+ 'ide-search-init.c',
+]
+
+libide_search_sources = libide_search_public_sources + libide_search_private_sources
+
+#
+# Generated Resource Files
+#
+
+libide_search_resources = gnome.compile_resources(
+ 'ide-search-resources',
+ 'libide-search.gresource.xml',
+ c_name: 'ide_search',
+)
+libide_search_sources += libide_search_resources
#
# Dependencies
diff --git a/src/main.c b/src/main.c
index 67951a50c..77c2023b2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -40,6 +40,7 @@
#include "ide-build-ident.h"
#include "ide-editor-private.h"
#include "ide-gtk-private.h"
+#include "ide-search-private.h"
#include "ide-shell-private.h"
#include "ide-terminal-private.h"
#include "ide-thread-private.h"
@@ -289,6 +290,7 @@ main (gint argc,
/* Ensure availability of some symbols possibly dropped in link */
_ide_gtk_init ();
+ _ide_search_init ();
_ide_editor_init ();
_ide_terminal_init ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]