[nautilus-actions] Implement new order semantic
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Implement new order semantic
- Date: Fri, 2 Oct 2009 22:41:54 +0000 (UTC)
commit 659cdf39f14eef152695d73220cfa7701dc57efa
Author: Pierre Wieser <pwieser trychlos org>
Date: Mon Sep 28 21:07:59 2009 +0200
Implement new order semantic
ChangeLog | 21 ++++-
src/common/na-iio-provider.c | 42 ++------
src/common/na-iprefs.c | 77 +++++++++++----
src/common/na-iprefs.h | 5 +-
src/common/na-pivot.c | 47 +++++++++
src/common/na-pivot.h | 4 +
src/nact/nact-assistant-export.c | 17 ---
src/nact/nact-main-window.c | 17 ---
src/nact/nact-preferences-editor.c | 139 +++++++++-----------------
src/nact/nact-tree-model.c | 38 ++++++--
src/nact/nautilus-actions-config-tool.ui | 159 ++++++++++++++++++++++--------
src/plugin/nautilus-actions.c | 17 ---
12 files changed, 336 insertions(+), 247 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 66eea08..987b4e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,17 +17,26 @@
* src/common/na-iio-provider.c (na_iio_provider_get_items_tree):
Dump the hierarchy tree before the alphabetical sort.
Implement the new actions sorting semantic when loading the tree.
+ Move the sorting functions to NAPivot class.
+
+ * src/common/na-iprefs.c:
+ * src/common/na-iprefs.h (na_iprefs_is_alphabetical_order):
+ Renamed as na_iprefs_get_alphabetical_order().
+ Move NAIPrefs data to instance object.
+
+ * src/common/na-pivot.c:
+ * src/common/na-pivot.h
+ (na_pivot_sort_alpha_asc, na_pivot_sort_alpha_desc): New functions.
* src/nact/base-iprefs.c:
* src/nact/base-iprefs.c (base_iprefs_get_bool,
base_iprefs_set_bool):
Replace the BaseWindow argument by a BaseIPrefs one.
Define three new UI preferences.
- (na_iprefs_is_alphabetical_order):
- Renamed as na_iprefs_get_alphabetical_order().
* src/nact/nact-assistant-export.c:
Implements IActionsList::get_treeview_name virtual function.
+ Remove useless NAIPrefs implementation.
* src/nact/nact-clipboard.c:
* src/nact/nact-main-window.c:
@@ -37,6 +46,7 @@
No more check for action existancy in NAPivot.
No more forward nact-tab-updatable-item-updated signal.
Implements IActionsList::get_treeview_name virtual function.
+ Remove useless NAIPrefs implementation.
* src/nact/nact-iactions-list.c:
* src/nact/nact-iactions-list.h
@@ -52,7 +62,12 @@
* src/nact/nact-preferences-editor.c:
Edit the new UI preferences.
- Do not implement BaseIPrefs interface.
+ Do not implement BaseIPrefs nor NAIPrefs interfaces.
+ Implement new order mode semantic.
+
+ * src/nact/nact-tree-model.c (sort_actions_list):
+ Implement new order mode semantic.
+ Use new NAPivot sort functions.
* src/nact/nautilus-actions-config-tool.actions:
Define new View menu.
diff --git a/src/common/na-iio-provider.c b/src/common/na-iio-provider.c
index 24bb549..1a6685f 100644
--- a/src/common/na-iio-provider.c
+++ b/src/common/na-iio-provider.c
@@ -62,8 +62,6 @@ static gboolean do_is_willing_to_write( const NAIIOProvider *instance );
static gboolean do_is_writable( const NAIIOProvider *instance, const NAObject *item );
static GList *sort_tree( const NAPivot *pivot, GList *tree, GCompareFunc fn );
-static gint compare_label_alpha_asc_fn( const NAObjectId *a, const NAObjectId *b );
-static gint compare_label_alpha_desc_fn( const NAObjectId *a, const NAObjectId *b );
/**
* Registers the GType of this interface.
@@ -179,19 +177,22 @@ na_iio_provider_get_items_tree( const NAPivot *pivot )
na_utils_free_string_list( level_zero );
na_object_free_items( merged );
- g_debug( "%s: tree before alphabetical reordering", thisfn );
+ g_debug( "%s: tree before alphabetical reordering (if any)", thisfn );
na_object_dump_tree( hierarchy );
g_debug( "%s: end of tree", thisfn );
order_mode = na_iprefs_get_alphabetical_order( NA_IPREFS( pivot ));
switch( order_mode ){
+ case PREFS_ORDER_ALPHA_ASCENDING:
+ hierarchy = sort_tree( pivot, hierarchy, ( GCompareFunc ) na_pivot_sort_alpha_asc );
+ break;
+
case PREFS_ORDER_ALPHA_DESCENDING:
- hierarchy = sort_tree( pivot, hierarchy, compare_label_alpha_desc_fn );
+ hierarchy = sort_tree( pivot, hierarchy, ( GCompareFunc ) na_pivot_sort_alpha_desc );
break;
- case PREFS_ORDER_ALPHA_ASCENDING:
+ case PREFS_ORDER_MANUAL:
default:
- hierarchy = sort_tree( pivot, hierarchy, compare_label_alpha_asc_fn );
break;
}
}
@@ -457,19 +458,19 @@ do_is_writable( const NAIIOProvider *instance, const NAObject *item )
}
static GList *
-sort_tree( const NAPivot *pivot, GList *tree )
+sort_tree( const NAPivot *pivot, GList *tree, GCompareFunc fn )
{
GList *sorted;
GList *items, *it;
- sorted = g_list_sort( tree, ( GCompareFunc ) compare_label_alpha_fn );
+ sorted = g_list_sort( tree, fn );
/* recursively sort each level of the tree
*/
for( it = sorted ; it ; it = it->next ){
if( NA_IS_OBJECT_ITEM( it->data )){
items = na_object_get_items( it->data );
- items = sort_tree( pivot, items );
+ items = sort_tree( pivot, items, fn );
na_object_set_items( it->data, items );
na_object_free_items( items );
}
@@ -477,26 +478,3 @@ sort_tree( const NAPivot *pivot, GList *tree )
return( sorted );
}
-
-static gint
-compare_label_alpha_asc_fn( const NAObjectId *a, const NAObjectId *b )
-{
- gchar *label_a, *label_b;
- gint compare;
-
- label_a = na_object_get_label( a );
- label_b = na_object_get_label( b );
-
- compare = g_utf8_collate( label_a, label_b );
-
- g_free( label_b );
- g_free( label_a );
-
- return( compare );
-}
-
-static gint
-compare_label_alpha_desc_fn( const NAObjectId *a, const NAObjectId *b )
-{
- return( -1 * compare_label_alpha_asc_fn( a, b ));
-}
diff --git a/src/common/na-iprefs.c b/src/common/na-iprefs.c
index 4adadf9..694d4c9 100644
--- a/src/common/na-iprefs.c
+++ b/src/common/na-iprefs.c
@@ -39,22 +39,35 @@
/* private interface data
*/
struct NAIPrefsInterfacePrivate {
- GConfClient *client;
+ void *empty; /* so that gcc -pedantic is happy */
};
+/* private data initialized the first time an instance calls a function
+ * of the public api
+ */
+typedef struct {
+ GConfClient *client;
+}
+ NAIPrefsPrivate;
+
+#define NA_IPREFS_PRIVATE_DATA "na-iprefs-private-data"
+
static gboolean st_initialized = FALSE;
static gboolean st_finalized = FALSE;
-static GType register_type( void );
-static void interface_base_init( NAIPrefsInterface *klass );
-static void interface_base_finalize( NAIPrefsInterface *klass );
+static GType register_type( void );
+static void interface_base_init( NAIPrefsInterface *klass );
+static void interface_base_finalize( NAIPrefsInterface *klass );
+
+static gboolean read_bool( NAIPrefs *instance, const gchar *name, gboolean default_value );
+static gint read_int( NAIPrefs *instance, const gchar *name, gint default_value );
+static GSList *read_string_list( NAIPrefs *instance, const gchar *name );
+static void write_bool( NAIPrefs *instance, const gchar *name, gboolean value );
+static void write_int( NAIPrefs *instance, const gchar *name, gint value );
+static void write_string_list( NAIPrefs *instance, const gchar *name, GSList *list );
-static gboolean read_bool( NAIPrefs *instance, const gchar *name, gboolean default_value );
-static gint read_int( NAIPrefs *instance, const gchar *name, gint default_value );
-static GSList *read_string_list( NAIPrefs *instance, const gchar *name );
-static void write_bool( NAIPrefs *instance, const gchar *name, gboolean value );
-static void write_int( NAIPrefs *instance, const gchar *name, gint value );
-static void write_string_list( NAIPrefs *instance, const gchar *name, GSList *list );
+static void setup_private_data( NAIPrefs *instance );
+static GConfClient *get_gconf_client( NAIPrefs *instance );
GType
na_iprefs_get_type( void )
@@ -106,8 +119,6 @@ interface_base_init( NAIPrefsInterface *klass )
klass->private = g_new0( NAIPrefsInterfacePrivate, 1 );
- klass->private->client = gconf_client_get_default();
-
st_initialized = TRUE;
}
}
@@ -144,6 +155,7 @@ na_iprefs_get_level_zero_items( NAIPrefs *instance )
g_return_val_if_fail( NA_IS_IPREFS( instance ), NULL );
if( st_initialized && !st_finalized ){
+ setup_private_data( instance );
level_zero = read_string_list( instance, PREFS_LEVEL_ZERO_ITEMS );
}
@@ -163,6 +175,7 @@ na_iprefs_set_level_zero_items( NAIPrefs *instance, GSList *order )
g_return_if_fail( NA_IS_IPREFS( instance ));
if( st_initialized && !st_finalized ){
+ setup_private_data( instance );
write_string_list( instance, PREFS_LEVEL_ZERO_ITEMS, order );
}
}
@@ -187,6 +200,7 @@ na_iprefs_get_alphabetical_order( NAIPrefs *instance )
g_return_val_if_fail( NA_IS_IPREFS( instance ), PREFS_ORDER_ALPHA_ASCENDING );
if( st_initialized && !st_finalized ){
+ setup_private_data( instance );
alpha_order = read_int( instance, PREFS_DISPLAY_ALPHABETICAL_ORDER, PREFS_ORDER_ALPHA_ASCENDING );
}
@@ -207,6 +221,7 @@ na_iprefs_set_alphabetical_order( NAIPrefs *instance, gint mode )
g_return_if_fail( NA_IS_IPREFS( instance ));
if( st_initialized && !st_finalized ){
+ setup_private_data( instance );
write_int( instance, PREFS_DISPLAY_ALPHABETICAL_ORDER, mode );
}
}
@@ -232,6 +247,7 @@ na_iprefs_should_add_about_item( NAIPrefs *instance )
g_return_val_if_fail( NA_IS_IPREFS( instance ), FALSE );
if( st_initialized && !st_finalized ){
+ setup_private_data( instance );
about = read_bool( instance, PREFS_ADD_ABOUT_ITEM, TRUE );
}
@@ -251,6 +267,7 @@ na_iprefs_set_add_about_item( NAIPrefs *instance, gboolean enabled )
g_return_if_fail( NA_IS_IPREFS( instance ));
if( st_initialized && !st_finalized ){
+ setup_private_data( instance );
write_bool( instance, PREFS_ADD_ABOUT_ITEM, enabled );
}
}
@@ -262,7 +279,7 @@ read_bool( NAIPrefs *instance, const gchar *name, gboolean default_value )
gboolean ret;
path = g_strdup_printf( "%s/%s", NA_GCONF_PREFS_PATH, name );
- ret = na_gconf_utils_read_bool( NA_IPREFS_GET_INTERFACE( instance )->private->client, path, TRUE, default_value );
+ ret = na_gconf_utils_read_bool( get_gconf_client( instance ), path, TRUE, default_value );
g_free( path );
return( ret );
@@ -275,7 +292,7 @@ read_int( NAIPrefs *instance, const gchar *name, gint default_value )
gint ret;
path = g_strdup_printf( "%s/%s", NA_GCONF_PREFS_PATH, name );
- ret = na_gconf_utils_read_int( NA_IPREFS_GET_INTERFACE( instance )->private->client, path, TRUE, default_value );
+ ret = na_gconf_utils_read_int( get_gconf_client( instance ), path, TRUE, default_value );
g_free( path );
return( ret );
@@ -288,7 +305,7 @@ read_string_list( NAIPrefs *instance, const gchar *name )
GSList *list;
path = g_strdup_printf( "%s/%s", NA_GCONF_PREFS_PATH, name );
- list = na_gconf_utils_read_string_list( NA_IPREFS_GET_INTERFACE( instance )->private->client, path );
+ list = na_gconf_utils_read_string_list( get_gconf_client( instance ), path );
g_free( path );
return( list );
@@ -300,7 +317,7 @@ write_bool( NAIPrefs *instance, const gchar *name, gboolean value )
gchar *path;
path = g_strdup_printf( "%s/%s", NA_GCONF_PREFS_PATH, name );
- na_gconf_utils_write_bool( NA_IPREFS_GET_INTERFACE( instance )->private->client, path, value, NULL );
+ na_gconf_utils_write_bool( get_gconf_client( instance ), path, value, NULL );
g_free( path );
}
@@ -310,7 +327,7 @@ write_int( NAIPrefs *instance, const gchar *name, gint value )
gchar *path;
path = g_strdup_printf( "%s/%s", NA_GCONF_PREFS_PATH, name );
- na_gconf_utils_write_int( NA_IPREFS_GET_INTERFACE( instance )->private->client, path, value, NULL );
+ na_gconf_utils_write_int( get_gconf_client( instance ), path, value, NULL );
g_free( path );
}
@@ -320,6 +337,30 @@ write_string_list( NAIPrefs *instance, const gchar *name, GSList *list )
gchar *path;
path = g_strdup_printf( "%s/%s", NA_GCONF_PREFS_PATH, name );
- na_gconf_utils_write_string_list( NA_IPREFS_GET_INTERFACE( instance )->private->client, path, list, NULL );
+ na_gconf_utils_write_string_list( get_gconf_client( instance ), path, list, NULL );
g_free( path );
}
+
+static void
+setup_private_data( NAIPrefs *instance )
+{
+ NAIPrefsPrivate *ipp;
+
+ ipp = ( NAIPrefsPrivate * ) g_object_get_data( G_OBJECT( instance ), NA_IPREFS_PRIVATE_DATA );
+ if( !ipp ){
+ ipp = g_new0( NAIPrefsPrivate, 1 );
+ ipp->client = gconf_client_get_default();
+ g_object_set_data( G_OBJECT( instance ), NA_IPREFS_PRIVATE_DATA, ipp );
+ }
+}
+
+static GConfClient *
+get_gconf_client( NAIPrefs *instance )
+{
+ NAIPrefsPrivate *ipp;
+
+ ipp = ( NAIPrefsPrivate * ) g_object_get_data( G_OBJECT( instance ), NA_IPREFS_PRIVATE_DATA );
+ g_return_val_if_fail( ipp, NULL );
+
+ return( ipp->client );
+}
diff --git a/src/common/na-iprefs.h b/src/common/na-iprefs.h
index 092fb66..a1f28c0 100644
--- a/src/common/na-iprefs.h
+++ b/src/common/na-iprefs.h
@@ -37,8 +37,9 @@
* @include: common/na-iprefs.h
*
* This interface should only be implemented by #NAPivot. This is
- * because the interface stores in its class private area some data
- * only relevant for one client (GConfClient, GConf monitors, etc.).
+ * because the interface stores as an implementor structure some data
+ * which are only relevant for one client (GConfClient, GConf monitors,
+ * etc.).
*
* Though all modules may use the public functions na_iprefs_xxx(),
* only #NAPivot will receive update notifications, taking itself care
diff --git a/src/common/na-pivot.c b/src/common/na-pivot.c
index c9a7bff..36fae68 100644
--- a/src/common/na-pivot.c
+++ b/src/common/na-pivot.c
@@ -635,6 +635,53 @@ na_pivot_set_automatic_reload( NAPivot *pivot, gboolean reload )
}
}
+/**
+ * na_pivot_sort_alpha_asc:
+ * @a: first #NAObjectId.
+ * @b: second #NAObjectId.
+ *
+ * Sort the objects in alphabetical ascending order of their label.
+ *
+ * Returns:
+ * -1 if @a must be sorted before @b,
+ * 0 if @a and @b are equal from the local point of view,
+ * 1 if @a must be sorted after @b.
+ */
+gint
+na_pivot_sort_alpha_asc( const NAObjectId *a, const NAObjectId *b )
+{
+ gchar *label_a, *label_b;
+ gint compare;
+
+ label_a = na_object_get_label( a );
+ label_b = na_object_get_label( b );
+
+ compare = g_utf8_collate( label_a, label_b );
+
+ g_free( label_b );
+ g_free( label_a );
+
+ return( compare );
+}
+
+/**
+ * na_pivot_sort_alpha_desc:
+ * @a: first #NAObjectId.
+ * @b: second #NAObjectId.
+ *
+ * Sort the objects in alphabetical descending order of their label.
+ *
+ * Returns:
+ * -1 if @a must be sorted before @b,
+ * 0 if @a and @b are equal from the local point of view,
+ * 1 if @a must be sorted after @b.
+ */
+gint
+na_pivot_sort_alpha_desc( const NAObjectId *a, const NAObjectId *b )
+{
+ return( -1 * na_pivot_sort_alpha_asc( a, b ));
+}
+
static NAObject *
get_item_from_tree( const NAPivot *pivot, GList *tree, uuid_t uuid )
{
diff --git a/src/common/na-pivot.h b/src/common/na-pivot.h
index 5638247..3df9471 100644
--- a/src/common/na-pivot.h
+++ b/src/common/na-pivot.h
@@ -75,6 +75,7 @@
*/
#include "na-object-class.h"
+#include "na-object-id-class.h"
#include "na-ipivot-consumer.h"
G_BEGIN_DECLS
@@ -125,6 +126,9 @@ void na_pivot_register_consumer( NAPivot *pivot, const NAIPivotConsumer *co
gboolean na_pivot_get_automatic_reload( const NAPivot *pivot );
void na_pivot_set_automatic_reload( NAPivot *pivot, gboolean reload );
+gint na_pivot_sort_alpha_asc( const NAObjectId *a, const NAObjectId *b );
+gint na_pivot_sort_alpha_desc( const NAObjectId *a, const NAObjectId *b );
+
/* data passed from the storage subsystem when an action is changed
*/
enum {
diff --git a/src/nact/nact-assistant-export.c b/src/nact/nact-assistant-export.c
index 9faf4e8..11bf083 100644
--- a/src/nact/nact-assistant-export.c
+++ b/src/nact/nact-assistant-export.c
@@ -94,7 +94,6 @@ static BaseAssistantClass *st_parent_class = NULL;
static GType register_type( void );
static void class_init( NactAssistantExportClass *klass );
static void iactions_list_iface_init( NactIActionsListInterface *iface );
-static void iprefs_iface_init( NAIPrefsInterface *iface );
static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *application );
static void instance_finalize( GObject *application );
@@ -179,20 +178,12 @@ register_type( void )
NULL
};
- static const GInterfaceInfo iprefs_iface_info = {
- ( GInterfaceInitFunc ) iprefs_iface_init,
- NULL,
- NULL
- };
-
g_debug( "%s", thisfn );
type = g_type_register_static( BASE_ASSISTANT_TYPE, "NactAssistantExport", &info, 0 );
g_type_add_interface_static( type, NACT_IACTIONS_LIST_TYPE, &iactions_list_iface_info );
- g_type_add_interface_static( type, NA_IPREFS_TYPE, &iprefs_iface_info );
-
return( type );
}
@@ -236,14 +227,6 @@ iactions_list_iface_init( NactIActionsListInterface *iface )
}
static void
-iprefs_iface_init( NAIPrefsInterface *iface )
-{
- static const gchar *thisfn = "nact_assistant_export_iprefs_iface_init";
-
- g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
-}
-
-static void
instance_init( GTypeInstance *instance, gpointer klass )
{
static const gchar *thisfn = "nact_assistant_export_instance_init";
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index af09436..a40e86a 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -123,7 +123,6 @@ static void icommand_tab_iface_init( NactICommandTabInterface *iface );
static void iconditions_tab_iface_init( NactIConditionsTabInterface *iface );
static void iadvanced_tab_iface_init( NactIAdvancedTabInterface *iface );
static void ipivot_consumer_iface_init( NAIPivotConsumerInterface *iface );
-static void iprefs_na_iface_init( NAIPrefsInterface *iface );
static void iprefs_base_iface_init( BaseIPrefsInterface *iface );
static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
@@ -219,12 +218,6 @@ register_type( void )
NULL
};
- static const GInterfaceInfo iprefs_na_iface_info = {
- ( GInterfaceInitFunc ) iprefs_na_iface_init,
- NULL,
- NULL
- };
-
static const GInterfaceInfo iprefs_base_iface_info = {
( GInterfaceInitFunc ) iprefs_base_iface_init,
NULL,
@@ -247,8 +240,6 @@ register_type( void )
g_type_add_interface_static( type, NA_IPIVOT_CONSUMER_TYPE, &ipivot_consumer_iface_info );
- g_type_add_interface_static( type, NA_IPREFS_TYPE, &iprefs_na_iface_info );
-
g_type_add_interface_static( type, BASE_IPREFS_TYPE, &iprefs_base_iface_info );
return( type );
@@ -397,14 +388,6 @@ ipivot_consumer_iface_init( NAIPivotConsumerInterface *iface )
}
static void
-iprefs_na_iface_init( NAIPrefsInterface *iface )
-{
- static const gchar *thisfn = "nact_main_window_iprefs_na_iface_init";
-
- g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
-}
-
-static void
iprefs_base_iface_init( BaseIPrefsInterface *iface )
{
static const gchar *thisfn = "nact_main_window_iprefs_base_iface_init";
diff --git a/src/nact/nact-preferences-editor.c b/src/nact/nact-preferences-editor.c
index afa77c0..f660a56 100644
--- a/src/nact/nact-preferences-editor.c
+++ b/src/nact/nact-preferences-editor.c
@@ -57,7 +57,6 @@ static GObjectClass *st_parent_class = NULL;
static GType register_type( void );
static void class_init( NactPreferencesEditorClass *klass );
-static void iprefs_na_iface_init( NAIPrefsInterface *iface );
static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *dialog );
static void instance_finalize( GObject *dialog );
@@ -68,10 +67,6 @@ static gchar *base_get_iprefs_window_id( BaseWindow *window );
static gchar *base_get_dialog_name( BaseWindow *window );
static void on_base_initial_load_dialog( NactPreferencesEditor *editor, gpointer user_data );
static void on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data );
-/*static void setup_buttons( NactPreferencesEditor *dialog, gboolean is_modified );
-static void on_modified_field( NactWindow *dialog );*/
-static void on_sort_alpha_toggled( GtkToggleButton *button, NactPreferencesEditor *editor );
-static void on_add_about_toggled( GtkToggleButton *button, NactPreferencesEditor *editor );
static void on_cancel_clicked( GtkButton *button, NactPreferencesEditor *editor );
static void on_ok_clicked( GtkButton *button, NactPreferencesEditor *editor );
static void save_preferences( NactPreferencesEditor *editor );
@@ -108,18 +103,10 @@ register_type( void )
( GInstanceInitFunc ) instance_init
};
- static const GInterfaceInfo iprefs_na_iface_info = {
- ( GInterfaceInitFunc ) iprefs_na_iface_init,
- NULL,
- NULL
- };
-
g_debug( "%s", thisfn );
type = g_type_register_static( BASE_DIALOG_TYPE, "NactPreferencesEditor", &info, 0 );
- g_type_add_interface_static( type, NA_IPREFS_TYPE, &iprefs_na_iface_info );
-
return( type );
}
@@ -147,14 +134,6 @@ class_init( NactPreferencesEditorClass *klass )
}
static void
-iprefs_na_iface_init( NAIPrefsInterface *iface )
-{
- static const gchar *thisfn = "nact_preferences_editor_iprefs_na_iface_init";
-
- g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
-}
-
-static void
instance_init( GTypeInstance *instance, gpointer klass )
{
static const gchar *thisfn = "nact_preferences_editor_instance_init";
@@ -284,29 +263,38 @@ static void
on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
{
static const gchar *thisfn = "nact_preferences_editor_on_runtime_init_dialog";
- gboolean sort_alpha, add_about_item;
+ NactApplication *application;
+ NAPivot *pivot;
+ gint order_mode;
+ gboolean add_about_item;
gboolean relabel;
GtkWidget *button;
g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
- sort_alpha = na_iprefs_is_alphabetical_order( NA_IPREFS( editor ));
- button = base_window_get_widget( BASE_WINDOW( editor ), "SortAlphabeticalButton" );
- gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), sort_alpha );
- base_window_signal_connect_by_name(
- BASE_WINDOW( editor ),
- "SortAlphabeticalButton",
- "toggled",
- G_CALLBACK( on_sort_alpha_toggled ));
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
+ pivot = nact_application_get_pivot( application );
- add_about_item = na_iprefs_should_add_about_item( NA_IPREFS( editor ));
+ order_mode = na_iprefs_get_alphabetical_order( NA_IPREFS( pivot ));
+ switch( order_mode ){
+ case PREFS_ORDER_ALPHA_ASCENDING:
+ button = base_window_get_widget( BASE_WINDOW( editor ), "OrderAlphaAscButton" );
+ break;
+
+ case PREFS_ORDER_ALPHA_DESCENDING:
+ button = base_window_get_widget( BASE_WINDOW( editor ), "OrderAlphaDescButton" );
+ break;
+
+ case PREFS_ORDER_MANUAL:
+ default:
+ button = base_window_get_widget( BASE_WINDOW( editor ), "OrderManualButton" );
+ break;
+ }
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), TRUE );
+
+ add_about_item = na_iprefs_should_add_about_item( NA_IPREFS( pivot ));
button = base_window_get_widget( BASE_WINDOW( editor ), "AddAboutButton" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), add_about_item );
- base_window_signal_connect_by_name(
- BASE_WINDOW( editor ),
- "AddAboutButton",
- "toggled",
- G_CALLBACK( on_add_about_toggled ));
base_window_signal_connect_by_name(
BASE_WINDOW( editor ),
@@ -333,58 +321,6 @@ on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), relabel );
}
-/*
- * rationale:
- * - while the preferences are not modified, only the cancel
- * button is activated (showed as close)
- * - when at least one preference has been modified, we have a OK and a
- * cancel buttons
- */
-/*static void
-setup_buttons( NactPreferencesEditor *editor, gboolean is_modified )
-{
- GtkWidget *cancel_stock = gtk_button_new_from_stock( GTK_STOCK_CANCEL );
- GtkWidget *close_stock = gtk_button_new_from_stock( GTK_STOCK_CLOSE );
-
- GtkWidget *cancel_button = base_window_get_widget( BASE_WINDOW( editor ), "CancelButton" );
- gtk_button_set_label( GTK_BUTTON( cancel_button ), is_modified ? _( "_Cancel" ) : _( "_Close" ));
- gtk_button_set_image( GTK_BUTTON( cancel_button ), is_modified ? gtk_button_get_image( GTK_BUTTON( cancel_stock )) : gtk_button_get_image( GTK_BUTTON( close_stock )));
-
- gtk_widget_destroy( close_stock );
- gtk_widget_destroy( cancel_stock );
-
- GtkWidget *ok_button = base_window_get_widget( BASE_WINDOW( editor ), "OKButton" );
- gtk_widget_set_sensitive( ok_button, is_modified );
-}*/
-
-/*static void
-on_modified_field( NactWindow *window )
-{
- static const gchar *thisfn = "nact_preferences_editor_on_modified_field";
-
- g_assert( NACT_IS_PREFERENCES_EDITOR( window ));
- NactPreferencesEditor *editor = ( NACT_PREFERENCES_EDITOR( window ));
-
- gboolean is_modified = is_edited_modified( editor );
- setup_dialog_title( editor, is_modified );
-
- gboolean can_save = is_modified &&
- (( editor->private->show_profile_item && nact_iprofile_item_has_label( window )) ||
- nact_imenu_item_has_label( window ));
-
- setup_buttons( editor, can_save );
-}*/
-
-static void
-on_sort_alpha_toggled( GtkToggleButton *button, NactPreferencesEditor *editor )
-{
-}
-
-static void
-on_add_about_toggled( GtkToggleButton *button, NactPreferencesEditor *editor )
-{
-}
-
static void
on_cancel_clicked( GtkButton *button, NactPreferencesEditor *editor )
{
@@ -404,17 +340,36 @@ on_ok_clicked( GtkButton *button, NactPreferencesEditor *editor )
static void
save_preferences( NactPreferencesEditor *editor )
{
+ NactApplication *application;
+ NAPivot *pivot;
GtkWidget *button;
+ gint order_mode;
gboolean enabled;
gboolean relabel;
- button = base_window_get_widget( BASE_WINDOW( editor ), "SortAlphabeticalButton" );
- enabled = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
- na_iprefs_set_alphabetical_order( NA_IPREFS( editor ), enabled );
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
+ pivot = nact_application_get_pivot( application );
+
+ order_mode = PREFS_ORDER_ALPHA_ASCENDING;
+ button = base_window_get_widget( BASE_WINDOW( editor ), "OrderAlphaAscButton" );
+ if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ))){
+ order_mode = PREFS_ORDER_ALPHA_ASCENDING;
+ } else {
+ button = base_window_get_widget( BASE_WINDOW( editor ), "OrderAlphaDescButton" );
+ if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ))){
+ order_mode = PREFS_ORDER_ALPHA_DESCENDING;
+ } else {
+ button = base_window_get_widget( BASE_WINDOW( editor ), "OrderManualButton" );
+ if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ))){
+ order_mode = PREFS_ORDER_MANUAL;
+ }
+ }
+ }
+ na_iprefs_set_alphabetical_order( NA_IPREFS( pivot ), order_mode );
button = base_window_get_widget( BASE_WINDOW( editor ), "AddAboutButton" );
enabled = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
- na_iprefs_set_add_about_item( NA_IPREFS( editor ), enabled );
+ na_iprefs_set_add_about_item( NA_IPREFS( pivot ), enabled );
button = base_window_get_widget( BASE_WINDOW( editor ), "RelabelMenuButton" );
relabel = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index 50fc02f..2a63e99 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -42,6 +42,7 @@
#include <common/na-utils.h>
#include "egg-tree-multi-dnd.h"
+#include "nact-application.h"
#include "nact-iactions-list.h"
#include "nact-clipboard.h"
#include "nact-tree-model.h"
@@ -1453,19 +1454,38 @@ on_drag_data_received( GtkWidget *widget, GdkDragContext *drag_context, gint x,
static gint
sort_actions_list( GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, BaseWindow *window )
{
- static const gchar *thisfn = "nact_tree_model_sort_actions_list";
- gchar *labela, *labelb;
- gint ret;
+ /*static const gchar *thisfn = "nact_tree_model_sort_actions_list";*/
+ NAObjectId *obj_a, *obj_b;
+ NactApplication *application;
+ NAPivot *pivot;
+ gint order_mode;
+ gint ret = 0;
- g_debug( "%s: model=%p, a=%p, b=%p, window=%p", thisfn, ( void * ) model, ( void * ) a, ( void * ) b, ( void * ) window );
+ /*g_debug( "%s: model=%p, a=%p, b=%p, window=%p", thisfn, ( void * ) model, ( void * ) a, ( void * ) b, ( void * ) window );*/
- gtk_tree_model_get( model, a, IACTIONS_LIST_LABEL_COLUMN, &labela, -1 );
- gtk_tree_model_get( model, b, IACTIONS_LIST_LABEL_COLUMN, &labelb, -1 );
+ application = NACT_APPLICATION( base_window_get_application( window ));
+ pivot = nact_application_get_pivot( application );
+ order_mode = na_iprefs_get_alphabetical_order( NA_IPREFS( pivot ));
- ret = g_utf8_collate( labela, labelb );
+ gtk_tree_model_get( model, a, IACTIONS_LIST_NAOBJECT_COLUMN, &obj_a, -1 );
+ gtk_tree_model_get( model, b, IACTIONS_LIST_NAOBJECT_COLUMN, &obj_b, -1 );
- g_free( labela );
- g_free( labelb );
+ switch( order_mode ){
+ case PREFS_ORDER_ALPHA_ASCENDING:
+ ret = na_pivot_sort_alpha_asc( obj_a, obj_b );
+ break;
+
+ case PREFS_ORDER_ALPHA_DESCENDING:
+ ret = na_pivot_sort_alpha_desc( obj_a, obj_b );
+ break;
+
+ case PREFS_ORDER_MANUAL:
+ default:
+ break;
+ }
+
+ g_object_unref( obj_b );
+ g_object_unref( obj_a );
return( ret );
}
diff --git a/src/nact/nautilus-actions-config-tool.ui b/src/nact/nautilus-actions-config-tool.ui
index 213bc67..d329576 100644
--- a/src/nact/nautilus-actions-config-tool.ui
+++ b/src/nact/nautilus-actions-config-tool.ui
@@ -1014,10 +1014,10 @@ Defining several profiles lets you have several commands, each applying with a d
<child>
<object class="GtkFileChooserWidget" id="ImportFileChooser">
<property name="visible">True</property>
- <property name="use_preview_label">False</property>
- <property name="preview_widget_active">False</property>
<property name="select_multiple">True</property>
<property name="local_only">False</property>
+ <property name="use_preview_label">False</property>
+ <property name="preview_widget_active">False</property>
</object>
<packing>
<property name="position">0</property>
@@ -1616,62 +1616,141 @@ Be warned: you will not be prompted another time. This mode may be dangerous.</p
<object class="GtkVBox" id="vbox25">
<property name="visible">True</property>
<child>
- <object class="GtkFrame" id="frame1">
+ <object class="GtkVBox" id="vbox28">
<property name="visible">True</property>
- <property name="border_width">6</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">in</property>
<child>
- <object class="GtkAlignment" id="alignment1">
+ <object class="GtkFrame" id="frame3">
<property name="visible">True</property>
- <property name="left_padding">12</property>
+ <property name="border_width">6</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">in</property>
<child>
- <object class="GtkVBox" id="vbox17">
+ <object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
- <property name="border_width">6</property>
+ <property name="left_padding">12</property>
<child>
- <object class="GtkCheckButton" id="SortAlphabeticalButton">
- <property name="label" translatable="yes">_Sort actions in alphabetical order</property>
+ <object class="GtkVBox" id="vbox30">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="tooltip_text" translatable="yes">When checked, the actions will be forced to be displayed in ascending alphabetical order of their label. They cannot be reordered in the user interface.</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
+ <property name="border_width">6</property>
+ <child>
+ <object class="GtkRadioButton" id="OrderAlphaAscButton">
+ <property name="label" translatable="yes">_Ascending alphabetical order</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">The actions will be sorted in ascending alphabetical order.</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="OrderAlphaDescButton">
+ <property name="label" translatable="yes">_Descending alphabetical order</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">The actions will be sorted in descending alphabetical order.</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">OrderAlphaAscButton</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="OrderManualButton">
+ <property name="label" translatable="yes">_Manual order</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">The actions will not be automatically sorted. Instead, the user is free to order them manually.</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">OrderAlphaAscButton</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
- <packing>
- <property name="position">0</property>
- </packing>
</child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xpad">4</property>
+ <property name="label" translatable="yes"><b>Items ordering</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox29">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="border_width">6</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
<child>
- <object class="GtkCheckButton" id="AddAboutButton">
- <property name="label" translatable="yes">Add an '_About Nautilus Actions' item in the Nautilus context menu</property>
+ <object class="GtkVBox" id="vbox17">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="tooltip_text" translatable="yes">When checked and a root submenu is defined, an 'About Nautilus Actions' item will be added at the end of the root submenu in the Nautilus context menu.</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
+ <property name="border_width">6</property>
+ <child>
+ <object class="GtkCheckButton" id="AddAboutButton">
+ <property name="label" translatable="yes">Add an '_About Nautilus Actions' item in the Nautilus context menu</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
</object>
- <packing>
- <property name="position">1</property>
- </packing>
</child>
</object>
</child>
+ <child type="label">
+ <object class="GtkLabel" id="label41">
+ <property name="visible">True</property>
+ <property name="xpad">4</property>
+ <property name="label" translatable="yes"><b>Nautilus menu layout</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
</object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label41">
- <property name="visible">True</property>
- <property name="xpad">5</property>
- <property name="label" translatable="yes"><b>Nautilus menu layout</b></property>
- <property name="use_markup">True</property>
- </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
</object>
<packing>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
@@ -1753,7 +1832,7 @@ Be warned: you will not be prompted another time. This mode may be dangerous.</p
<child type="label">
<object class="GtkLabel" id="label42">
<property name="visible">True</property>
- <property name="label" translatable="yes"><b> Relabeling items when pasted or duplicated </b></property>
+ <property name="label" translatable="yes"><b>Relabeling items when pasted or duplicated</b></property>
<property name="use_markup">True</property>
</object>
</child>
diff --git a/src/plugin/nautilus-actions.c b/src/plugin/nautilus-actions.c
index 6707330..d6fde41 100644
--- a/src/plugin/nautilus-actions.c
+++ b/src/plugin/nautilus-actions.c
@@ -67,7 +67,6 @@ static GType st_actions_type = 0;
static void class_init( NautilusActionsClass *klass );
static void menu_provider_iface_init( NautilusMenuProviderIface *iface );
static void ipivot_consumer_iface_init( NAIPivotConsumerInterface *iface );
-static void iprefs_iface_init( NAIPrefsInterface *iface );
static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *object );
static void instance_finalize( GObject *object );
@@ -116,12 +115,6 @@ nautilus_actions_register_type( GTypeModule *module )
NULL
};
- static const GInterfaceInfo iprefs_iface_info = {
- ( GInterfaceInitFunc ) iprefs_iface_init,
- NULL,
- NULL
- };
-
g_debug( "%s: module=%p", thisfn, ( void * ) module );
g_assert( st_actions_type == 0 );
@@ -130,8 +123,6 @@ nautilus_actions_register_type( GTypeModule *module )
g_type_module_add_interface( module, st_actions_type, NAUTILUS_TYPE_MENU_PROVIDER, &menu_provider_iface_info );
g_type_module_add_interface( module, st_actions_type, NA_IPIVOT_CONSUMER_TYPE, &ipivot_consumer_iface_info );
-
- g_type_module_add_interface( module, st_actions_type, NA_IPREFS_TYPE, &iprefs_iface_info );
}
static void
@@ -173,14 +164,6 @@ ipivot_consumer_iface_init( NAIPivotConsumerInterface *iface )
}
static void
-iprefs_iface_init( NAIPrefsInterface *iface )
-{
- static const gchar *thisfn = "nautilus_actions_iprefs_iface_init";
-
- g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
-}
-
-static void
instance_init( GTypeInstance *instance, gpointer klass )
{
static const gchar *thisfn = "nautilus_actions_instance_init";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]