[gnome-builder] greeter: add activate_first API to section
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] greeter: add activate_first API to section
- Date: Sat, 18 Nov 2017 03:48:31 +0000 (UTC)
commit a07dd73952e5252a143effdd093361b291269bd4
Author: Christian Hergert <chergert redhat com>
Date: Fri Nov 17 19:46:22 2017 -0800
greeter: add activate_first API to section
src/libide/greeter/ide-greeter-section.c | 37 +++++++++++++++++++++++++++--
src/libide/greeter/ide-greeter-section.h | 23 ++++++++++--------
2 files changed, 47 insertions(+), 13 deletions(-)
---
diff --git a/src/libide/greeter/ide-greeter-section.c b/src/libide/greeter/ide-greeter-section.c
index 230446a..c3644d2 100644
--- a/src/libide/greeter/ide-greeter-section.c
+++ b/src/libide/greeter/ide-greeter-section.c
@@ -81,16 +81,20 @@ ide_greeter_section_get_priority (IdeGreeterSection *self)
*
* Refilter the visibile items based on the current search.
*
+ * Returns: %TRUE if at least one element matched.
+ *
* Since: 3.28
*/
-void
+gboolean
ide_greeter_section_filter (IdeGreeterSection *self,
DzlPatternSpec *spec)
{
- g_return_if_fail (IDE_IS_GREETER_SECTION (self));
+ g_return_val_if_fail (IDE_IS_GREETER_SECTION (self), FALSE);
if (IDE_GREETER_SECTION_GET_IFACE (self)->filter)
- IDE_GREETER_SECTION_GET_IFACE (self)->filter (self, spec);
+ return IDE_GREETER_SECTION_GET_IFACE (self)->filter (self, spec);
+
+ return FALSE;
}
void
@@ -102,3 +106,30 @@ ide_greeter_section_emit_project_activated (IdeGreeterSection *self,
g_signal_emit (self, signals [PROJECT_ACTIVATED], 0, project_info);
}
+
+/**
+ * ide_greeter_section_activate_first:
+ * @self: a #IdeGreeterSection
+ *
+ * Active the first item in the section. This happens when the user
+ * hits Enter within the search box to select the first visible item
+ * in the search result set.
+ *
+ * Ensure the given item is visible before activating it.
+ *
+ * If no item matched, then return %FALSE.
+ *
+ * Returns: %TRUE if an item was activated
+ *
+ * Since: 3.28
+ */
+gboolean
+ide_greeter_section_activate_first (IdeGreeterSection *self)
+{
+ g_return_val_if_fail (IDE_IS_GREETER_SECTION (self), FALSE);
+
+ if (IDE_GREETER_SECTION_GET_IFACE (self)->activate_first)
+ return IDE_GREETER_SECTION_GET_IFACE (self)->activate_first (self);
+
+ return FALSE;
+}
diff --git a/src/libide/greeter/ide-greeter-section.h b/src/libide/greeter/ide-greeter-section.h
index 741e261..93e269b 100644
--- a/src/libide/greeter/ide-greeter-section.h
+++ b/src/libide/greeter/ide-greeter-section.h
@@ -34,20 +34,23 @@ struct _IdeGreeterSectionInterface
{
GTypeInterface parent_iface;
- void (*project_activated) (IdeGreeterSection *self,
- IdeProjectInfo *project_info);
- gint (*get_priority) (IdeGreeterSection *self);
- void (*filter) (IdeGreeterSection *self,
- DzlPatternSpec *pattern);
+ void (*project_activated) (IdeGreeterSection *self,
+ IdeProjectInfo *project_info);
+ gint (*get_priority) (IdeGreeterSection *self);
+ gboolean (*filter) (IdeGreeterSection *self,
+ DzlPatternSpec *pattern);
+ gboolean (*activate_first) (IdeGreeterSection *self);
};
IDE_AVAILABLE_IN_3_28
-gint ide_greeter_section_get_priority (IdeGreeterSection *self);
+gint ide_greeter_section_get_priority (IdeGreeterSection *self);
IDE_AVAILABLE_IN_3_28
-void ide_greeter_section_filter (IdeGreeterSection *self,
- DzlPatternSpec *spec);
+gboolean ide_greeter_section_filter (IdeGreeterSection *self,
+ DzlPatternSpec *spec);
IDE_AVAILABLE_IN_3_28
-void ide_greeter_section_emit_project_activated (IdeGreeterSection *self,
- IdeProjectInfo *project_info);
+void ide_greeter_section_emit_project_activated (IdeGreeterSection *self,
+ IdeProjectInfo *project_info);
+IDE_AVAILABLE_IN_3_28
+gboolean ide_greeter_section_activate_first (IdeGreeterSection *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]