[nautilus-actions] Sort actions in the display order
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Sort actions in the display order
- Date: Tue, 25 Aug 2009 19:23:29 +0000 (UTC)
commit 53b6ae2e8b050d27250da62ea7c7a76b74016344
Author: Pierre Wieser <pwieser trychlos org>
Date: Tue Aug 25 21:26:32 2009 +0200
Sort actions in the display order
Rationale: GConf returns subdirs of the key in a random order. To be sure to display
actions in the Nautilus context menu in the same order than they are displayed in
NACT, we sort the actions right after the load operation.
ChangeLog | 3 +++
src/common/na-iio-provider.c | 32 +++++++++++++++++++++++++++++++-
2 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2bfae3b..a756b34 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,9 @@
Add a comment about
nautilus_menu_provider_emit_items_updated_signal().
+ * src/common/na-iio-provider.c:
+ Sort the actions in the same order as they are displayed.
+
* src/nact/nact-assistant.c:
* src/nact/nact-assistant.h:
Implement a work-around for bug #589745 (apply message).
diff --git a/src/common/na-iio-provider.c b/src/common/na-iio-provider.c
index eb8573b..23b92f7 100644
--- a/src/common/na-iio-provider.c
+++ b/src/common/na-iio-provider.c
@@ -48,6 +48,8 @@ static void interface_base_finalize( NAIIOProviderInterface *klass );
static gboolean do_is_willing_to_write( const NAIIOProvider *instance );
static gboolean do_is_writable( const NAIIOProvider *instance, const NAAction *action );
static guint write_action( const NAIIOProvider *instance, NAAction *action, gchar **message );
+static GSList *sort_actions( const NAPivot *pivot, GSList *actions );
+static gint compare_actions_label_alpha_fn( const NAAction *a, const NAAction *b );
/**
* Registers the GType of this interface.
@@ -171,7 +173,7 @@ na_iio_provider_read_actions( const NAPivot *pivot )
}
}
- return( actions );
+ return( sort_actions( pivot, actions ));
}
/**
@@ -316,3 +318,31 @@ write_action( const NAIIOProvider *provider, NAAction *action, gchar **message )
return( NA_IIO_PROVIDER_GET_INTERFACE( provider )->write_action( provider, action, message ));
}
+
+/*
+ * sort the actions so that they are in the same order than when they
+ * are displayed in NACT
+ */
+static GSList *
+sort_actions( const NAPivot *pivot, GSList *actions )
+{
+ GSList *sorted;
+
+ sorted = g_slist_sort( actions, ( GCompareFunc ) compare_actions_label_alpha_fn );
+
+ return( sorted );
+}
+
+static gint
+compare_actions_label_alpha_fn( const NAAction *a, const NAAction *b )
+{
+ gchar *label_a, *label_b;
+ gint compare;
+
+ label_a = na_action_get_label( a );
+ label_b = na_action_get_label( b );
+
+ compare = g_utf8_collate( label_a, label_b );
+
+ return( compare );
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]