[gnome-builder] command-bar: plumb search priority to new vfunc
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] command-bar: plumb search priority to new vfunc
- Date: Wed, 7 Aug 2019 01:00:57 +0000 (UTC)
commit 10eba301fe1e9e89be159299145a7c21e0369030
Author: Christian Hergert <chergert redhat com>
Date: Tue Aug 6 18:00:42 2019 -0700
command-bar: plumb search priority to new vfunc
.../command-bar/gbp-command-bar-command-provider.c | 14 +-------------
src/plugins/command-bar/gbp-gaction-command.c | 18 +++++++++---------
src/plugins/command-bar/gbp-gaction-command.h | 14 ++++++--------
3 files changed, 16 insertions(+), 30 deletions(-)
---
diff --git a/src/plugins/command-bar/gbp-command-bar-command-provider.c
b/src/plugins/command-bar/gbp-command-bar-command-provider.c
index 9da24cca2..e8fc5453f 100644
--- a/src/plugins/command-bar/gbp-command-bar-command-provider.c
+++ b/src/plugins/command-bar/gbp-command-bar-command-provider.c
@@ -32,16 +32,6 @@ struct _GbpCommandBarCommandProvider
GObject parent_instance;
};
-static gint
-sort_actions_by_priority (gconstpointer a,
- gconstpointer b)
-{
- GbpGactionCommand *cmd_a = *(GbpGactionCommand **)a;
- GbpGactionCommand *cmd_b = *(GbpGactionCommand **)b;
-
- return gbp_gaction_command_compare (cmd_a, cmd_b);
-}
-
static void
add_from_group (const gchar *needle,
GPtrArray *results,
@@ -84,7 +74,7 @@ add_from_group (const gchar *needle,
continue;
title = ide_completion_fuzzy_highlight (actions[j], needle);
- command = gbp_gaction_command_new (widget, prefix, actions[j], NULL, title, priority);
+ command = gbp_gaction_command_new (widget, prefix, actions[j], NULL, title, (gint)priority);
g_ptr_array_add (results, g_steal_pointer (&command));
}
}
@@ -151,8 +141,6 @@ gbp_command_bar_command_provider_query_async (IdeCommandProvider *provider,
else
populate_gactions_at_widget (needle, results, GTK_WIDGET (surface), seen);
- g_ptr_array_sort (results, sort_actions_by_priority);
-
ide_task_return_pointer (task,
g_steal_pointer (&results),
g_ptr_array_unref);
diff --git a/src/plugins/command-bar/gbp-gaction-command.c b/src/plugins/command-bar/gbp-gaction-command.c
index 9ffbf7dfa..a18ccf6c6 100644
--- a/src/plugins/command-bar/gbp-gaction-command.c
+++ b/src/plugins/command-bar/gbp-gaction-command.c
@@ -32,7 +32,7 @@ struct _GbpGactionCommand
gchar *name;
GVariant *param;
gchar *title;
- guint priority;
+ gint priority;
};
static void
@@ -77,12 +77,19 @@ gbp_gaction_command_get_title (IdeCommand *command)
return g_strdup (self->title);
}
+static gint
+gbp_gaction_command_get_priority (IdeCommand *command)
+{
+ return GBP_GACTION_COMMAND (command)->priority;
+}
+
static void
command_iface_init (IdeCommandInterface *iface)
{
iface->run_async = gbp_gaction_command_run_async;
iface->run_finish = gbp_gaction_command_run_finish;
iface->get_title = gbp_gaction_command_get_title;
+ iface->get_priority = gbp_gaction_command_get_priority;
}
G_DEFINE_TYPE_WITH_CODE (GbpGactionCommand, gbp_gaction_command, IDE_TYPE_OBJECT,
@@ -128,7 +135,7 @@ gbp_gaction_command_new (GtkWidget *widget,
const gchar *name,
GVariant *param,
const gchar *title,
- guint priority)
+ gint priority)
{
GbpGactionCommand *self;
@@ -151,10 +158,3 @@ gbp_gaction_command_new (GtkWidget *widget,
return g_steal_pointer (&self);
}
-
-gint
-gbp_gaction_command_compare (GbpGactionCommand *a,
- GbpGactionCommand *b)
-{
- return (gint)a->priority - (gint)b->priority;
-}
diff --git a/src/plugins/command-bar/gbp-gaction-command.h b/src/plugins/command-bar/gbp-gaction-command.h
index 13cf7a7e3..73ed99463 100644
--- a/src/plugins/command-bar/gbp-gaction-command.h
+++ b/src/plugins/command-bar/gbp-gaction-command.h
@@ -28,13 +28,11 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GbpGactionCommand, gbp_gaction_command, GBP, GACTION_COMMAND, IdeObject)
-gint gbp_gaction_command_compare (GbpGactionCommand *a,
- GbpGactionCommand *b);
-GbpGactionCommand *gbp_gaction_command_new (GtkWidget *widget,
- const gchar *group,
- const gchar *name,
- GVariant *param,
- const gchar *title,
- guint priority);
+GbpGactionCommand *gbp_gaction_command_new (GtkWidget *widget,
+ const gchar *group,
+ const gchar *name,
+ GVariant *param,
+ const gchar *title,
+ gint priority);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]