[gnome-builder] gui: add get_priority() vfunc for commands



commit c5dd0a807dd38216d157f07ede49658f9ca3fe82
Author: Christian Hergert <chergert redhat com>
Date:   Tue Aug 6 17:59:05 2019 -0700

    gui: add get_priority() vfunc for commands

 src/libide/gui/ide-command.c | 29 +++++++++++++++++++++++++++++
 src/libide/gui/ide-command.h |  3 +++
 2 files changed, 32 insertions(+)
---
diff --git a/src/libide/gui/ide-command.c b/src/libide/gui/ide-command.c
index 8d99d7638..5a923ed1b 100644
--- a/src/libide/gui/ide-command.c
+++ b/src/libide/gui/ide-command.c
@@ -151,3 +151,32 @@ ide_command_get_subtitle (IdeCommand *self)
 
   return NULL;
 }
+
+/**
+ * ide_command_get_priority:
+ * @self: a #IdeCommand
+ *
+ * Gets the priority for the command.
+ *
+ * This is generally just useful when using the command bar so that the items
+ * may be sorted in a useful manner.
+ *
+ * Command providers may want to use the typed_text for the query operation
+ * to calculate a score with fuzzy matching.
+ *
+ * The lower the value, the higher priority.
+ *
+ * Returns: an integer with the sort priority
+ *
+ * Since: 3.34
+ */
+gint
+ide_command_get_priority (IdeCommand *self)
+{
+  g_return_val_if_fail (IDE_IS_COMMAND (self), G_MAXINT);
+
+  if (IDE_COMMAND_GET_IFACE (self)->get_priority)
+    return IDE_COMMAND_GET_IFACE (self)->get_priority (self);
+
+  return G_MAXINT;
+}
diff --git a/src/libide/gui/ide-command.h b/src/libide/gui/ide-command.h
index 26f4f4c7a..57ad694ae 100644
--- a/src/libide/gui/ide-command.h
+++ b/src/libide/gui/ide-command.h
@@ -46,8 +46,11 @@ struct _IdeCommandInterface
   gboolean  (*run_finish)   (IdeCommand           *self,
                              GAsyncResult         *result,
                              GError              **error);
+  gint      (*get_priority) (IdeCommand           *self);
 };
 
+IDE_AVAILABLE_IN_3_34
+gint      ide_command_get_priority (IdeCommand           *self);
 IDE_AVAILABLE_IN_3_32
 gchar    *ide_command_get_title    (IdeCommand           *self);
 IDE_AVAILABLE_IN_3_32


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]