[nautilus-actions] No more try to convert all/allfiles to something else
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] No more try to convert all/allfiles to something else
- Date: Mon, 14 Feb 2011 23:52:47 +0000 (UTC)
commit 2075f638abd524be8b389a6ab02752c56ba723c2
Author: Pierre Wieser <pwieser trychlos org>
Date: Sat Feb 12 18:06:28 2011 +0100
No more try to convert all/allfiles to something else
Used to convert 'all/allfiles' mimetype to '*/*' mimetype plus 'file' scheme, which was wrong.
A better solution would be to convert to '*/*;!inode/directory' mimetypes, but is not really
more useful that just having 'all/allfiles'.
src/api/na-object-api.h | 2 +-
src/api/na-object.h | 2 +-
src/core/na-icontext.c | 69 +++++++++++++++++++++++-------------------
src/core/na-object-item.c | 4 ++
src/core/na-object-profile.c | 32 +++++++++++++++++--
src/io-desktop/nadp-reader.c | 10 +-----
src/nact/nact-main-window.c | 2 +-
7 files changed, 74 insertions(+), 47 deletions(-)
---
diff --git a/src/api/na-object-api.h b/src/api/na-object-api.h
index 5a622fb..57d21ac 100644
--- a/src/api/na-object-api.h
+++ b/src/api/na-object-api.h
@@ -38,7 +38,7 @@
* @include: nautilus-actions/na-object-api.h
*
* We define here a common API which makes easier to write (and read)
- * the code ; all object functions are named na_object ; all arguments
+ * the code; all object functions are named na_object; all arguments
* are casted directly in the macro.
*/
diff --git a/src/api/na-object.h b/src/api/na-object.h
index 6cd2d4c..7b92b93 100644
--- a/src/api/na-object.h
+++ b/src/api/na-object.h
@@ -42,7 +42,7 @@
* derived.
*
* All the API described here is rather private. External code should
- * use the API described in <na-object-api.h>.
+ * use the API described in <filename>nautilus-actions/na-object-api.h</filename>.
*/
#include <glib-object.h>
diff --git a/src/core/na-icontext.c b/src/core/na-icontext.c
index 8f3d6be..1aeb020 100644
--- a/src/core/na-icontext.c
+++ b/src/core/na-icontext.c
@@ -54,15 +54,15 @@ struct _NAIContextInterfacePrivate {
void *empty; /* so that gcc -pedantic is happy */
};
-static gboolean st_initialized = FALSE;
-static gboolean st_finalized = FALSE;
+static const gchar *st_mimetype_all = "*/*";
+
+static gboolean st_initialized = FALSE;
+static gboolean st_finalized = FALSE;
static GType register_type( void );
static void interface_base_init( NAIContextInterface *klass );
static void interface_base_finalize( NAIContextInterface *klass );
-static void convert_allfiles_mimetype( NAIContext *context );
-
static gboolean v_is_candidate( NAIContext *object, guint target, GList *selection );
static gboolean is_candidate_for_target( const NAIContext *object, guint target, GList *files );
@@ -262,6 +262,7 @@ na_icontext_is_valid( const NAIContext *context )
gboolean
na_icontext_is_all_mimetypes( const NAIContext *context )
{
+ static const gchar *thisfn = "na_icontext_is_all_mimetypes";
gboolean is_all;
GSList *mimetypes, *im;
@@ -272,18 +273,20 @@ na_icontext_is_all_mimetypes( const NAIContext *context )
for( im = mimetypes ; im ; im = im->next ){
if( !im->data || !strlen( im->data )){
+ g_warning( "%s: empty mimetype for context=%p", thisfn, ( void * ) context );
continue;
}
const gchar *imtype = ( const gchar * ) im->data;
if( !strcmp( imtype, "*" ) ||
- !strcmp( imtype, "*/*" ) ||
+ !strcmp( imtype, st_mimetype_all ) ||
+ !strcmp( imtype, "*/all" ) ||
!strcmp( imtype, "all" ) ||
!strcmp( imtype, "all/*" ) ||
!strcmp( imtype, "all/all" )){
continue;
}
is_all = FALSE;
- break;
+ /* do not break here so that we are able to check all mimetypes */
}
na_core_utils_slist_free( mimetypes );
@@ -316,8 +319,6 @@ na_icontext_is_all_mimetypes( const NAIContext *context )
void
na_icontext_read_done( NAIContext *context )
{
- convert_allfiles_mimetype( context );
-
na_object_set_all_mimetypes( context, na_icontext_is_all_mimetypes( context ));
}
@@ -414,6 +415,9 @@ na_icontext_replace_folder( NAIContext *context, const gchar *old, const gchar *
na_core_utils_slist_free( folders );
}
+#if 0
+static const gchar *st_mimetype_notdir = "!inode/directory";
+
/*
* Convert 'all/allfiles' mimetype to 'all/all' + 'file' scheme.
* This takes into account
@@ -423,45 +427,48 @@ na_icontext_replace_folder( NAIContext *context, const gchar *old, const gchar *
static void
convert_allfiles_mimetype( NAIContext *context )
{
- GSList *mimetypes, *im;
- GSList *schemes;
- gchar *tmp;
- gboolean modified;
+ static const gchar *thisfn = "na_icontext_convert_allfiles_mimetype";
+ GSList *mimetypes, *im, *new_mimetypes;
+ const gchar *prev_type;
- modified = FALSE;
mimetypes = na_object_get_mimetypes( context );
- schemes = na_object_get_schemes( context );
+ new_mimetypes = NULL;
+ prev_type = NULL;
for( im = mimetypes ; im ; im = im->next ){
if( !im->data || !strlen( im->data )){
continue;
}
- gchar *imtype = ( gchar * ) im->data;
- gboolean positive = is_positive_assertion( imtype );
- guint i = ( positive ? 0 : 1 );
+ const gchar *imtype = ( const gchar * ) im->data;
+
+ if( !strcmp( imtype, "allfiles" ) ||
+ !strcmp( imtype, "*/allfiles" ) ||
+ !strcmp( imtype, "allfiles/*" ) ||
+ !strcmp( imtype, "allfiles/all" ) ||
+ !strcmp( imtype, "all/allfiles" )){
+
+ new_mimetypes = g_slist_prepend( new_mimetypes, g_strdup( st_mimetype_all ));
+ new_mimetypes = g_slist_prepend( new_mimetypes, g_strdup( st_mimetype_notdir ));
+ prev_type = imtype;
- if( !strcmp( imtype+i, "allfiles" ) ||
- !strcmp( imtype+i, "allfiles/*" ) ||
- !strcmp( imtype+i, "allfiles/all" ) ||
- !strcmp( imtype+i, "all/allfiles" )){
+ } else if( strcmp( imtype, st_mimetype_all ) && strcmp( imtype, st_mimetype_notdir )){
- g_free( im->data );
- im->data = g_strdup( "all/all" );
- tmp = g_strdup_printf( "%sfile", positive ? "" : "!" );
- schemes = g_slist_prepend( schemes, tmp );
- modified = TRUE;
+ new_mimetypes = g_slist_prepend( new_mimetypes, g_strdup( imtype ));
}
}
- if( modified ){
- na_object_set_mimetypes( context, mimetypes );
- na_object_set_schemes( context, schemes );
+ if( mimetypes ){
+ if( prev_type ){
+ g_debug( "%s: changing %s to %s;%s", thisfn, prev_type, st_mimetype_all, st_mimetype_notdir );
+ }
+ na_object_set_mimetypes( context, g_slist_reverse( new_mimetypes ));
}
na_core_utils_slist_free( mimetypes );
- na_core_utils_slist_free( schemes );
+ na_core_utils_slist_free( new_mimetypes );
}
+#endif
static gboolean
v_is_candidate( NAIContext *context, guint target, GList *selection )
@@ -798,7 +805,7 @@ is_mimetype_of( const gchar *mimetype, const gchar *fgroup, const gchar *fsubgro
gboolean is_type_of;
gchar *mgroup, *msubgroup;
- if( !strcmp( mimetype, "*" ) || !strcmp( mimetype, "*/*" )){
+ if( !strcmp( mimetype, "*" ) || !strcmp( mimetype, st_mimetype_all )){
return( TRUE );
}
diff --git a/src/core/na-object-item.c b/src/core/na-object-item.c
index 2da6ad8..040869b 100644
--- a/src/core/na-object-item.c
+++ b/src/core/na-object-item.c
@@ -152,6 +152,10 @@ instance_init( GTypeInstance *instance, gpointer klass )
self = NA_OBJECT_ITEM( instance );
self->private = g_new0( NAObjectItemPrivate, 1 );
+
+ self->private->dispose_has_run = FALSE;
+ self->private->writable = TRUE;
+ self->private->reason = 0;
}
static void
diff --git a/src/core/na-object-profile.c b/src/core/na-object-profile.c
index 5c5a82f..e826f34 100644
--- a/src/core/na-object-profile.c
+++ b/src/core/na-object-profile.c
@@ -448,20 +448,28 @@ icontext_is_candidate( NAIContext *object, guint target, GList *selection )
static gboolean
convert_pre_v3_parameters( NAObjectProfile *profile )
{
+ static const gchar *thisfn = "na_object_profile_convert_pre_v3_parameters";
gboolean path_changed, parms_changed;
+ gchar *before;
gchar *path = na_object_get_path( profile );
+ before = g_strdup( path );
path_changed = convert_pre_v3_parameters_str( path );
if( path_changed ){
na_object_set_path( profile, path );
+ g_debug( "%s: path=%s changed to %s", thisfn, before, path );
}
+ g_free( before );
g_free( path );
gchar *parms = na_object_get_parameters( profile );
+ before = g_strdup( parms );
parms_changed = convert_pre_v3_parameters_str( parms );
if( parms_changed ){
na_object_set_parameters( profile, parms );
+ g_debug( "%s: parameters=%s changed to %s", thisfn, before, parms );
}
+ g_free( before );
g_free( parms );
return( path_changed || parms_changed );
@@ -470,7 +478,6 @@ convert_pre_v3_parameters( NAObjectProfile *profile )
static gboolean
convert_pre_v3_parameters_str( gchar *str )
{
- static const gchar *thisfn = "na_object_profile_convert_pre_v3_parameters_str";
gboolean changed;
gchar *iter = str;
@@ -479,7 +486,6 @@ convert_pre_v3_parameters_str( gchar *str )
strlen( iter ) > 0 &&
( iter = g_strstr_len( iter, strlen( iter ), "%" )) != NULL ){
- g_debug( "%s: iter[1]='%c'", thisfn, iter[1] );
switch( iter[1] ){
/* as a special optimization case, "%d/%f" parameters
@@ -541,13 +547,15 @@ convert_pre_v3_parameters_str( gchar *str )
static gboolean
convert_pre_v3_multiple( NAObjectProfile *profile )
{
+ static const gchar *thisfn = "na_object_profile_convert_pre_v3_multiple";
gboolean accept_multiple;
gchar *selection_count;
accept_multiple = na_object_is_multiple( profile );
selection_count = g_strdup( accept_multiple ? ">0" : "=1" );
na_object_set_selection_count( profile, selection_count );
- g_debug( "na_object_profile_convert_pre_v3_multiple: set selection_count=%s", selection_count );
+ g_debug( "%s: accept_multiple=%s changed to selection_count= %s",
+ thisfn, accept_multiple ? "True":"False", selection_count );
g_free( selection_count );
return( TRUE );
@@ -564,15 +572,23 @@ convert_pre_v3_multiple( NAObjectProfile *profile )
static gboolean
convert_pre_v3_isfiledir( NAObjectProfile *profile )
{
+ static const gchar *thisfn = "na_object_profile_convert_pre_v3_isfiledir";
+ gboolean is_all_mimetypes;
gboolean converted;
gboolean isfile, isdir;
GSList *mimetypes;
+ GSList *before_list;
+ gchar *before_str, *after_str;
converted = FALSE;
- if( na_icontext_is_all_mimetypes( NA_ICONTEXT( profile ))){
+ is_all_mimetypes = na_icontext_is_all_mimetypes( NA_ICONTEXT( profile ));
+ g_debug( "%s: is_all_mimetypes=%s", thisfn, is_all_mimetypes ? "True":"False" );
+
+ if( is_all_mimetypes ){
converted = TRUE;
mimetypes = NULL;
+ before_list = na_object_get_mimetypes( profile );
isfile = na_object_is_file( profile );
isdir = na_object_is_dir( profile );
@@ -596,15 +612,23 @@ convert_pre_v3_isfiledir( NAObjectProfile *profile )
/* not files nor dir: this is an invalid case -> do not modify
* mimetypes
*/
+ g_warning( "%s: is_dir=False, is_file=False is invalid", thisfn );
converted = FALSE;
}
}
if( converted ){
na_object_set_mimetypes( profile, mimetypes );
+
+ before_str = na_core_utils_slist_join_at_end( before_list, ";" );
+ after_str = na_core_utils_slist_join_at_end( mimetypes, ";" );
+ g_debug( "%s; mimetypes=[%s] changed to [%s]", thisfn, before_str, after_str );
+ g_free( after_str );
+ g_free( before_str );
}
na_core_utils_slist_free( mimetypes );
+ na_core_utils_slist_free( before_list );
}
return( converted );
diff --git a/src/io-desktop/nadp-reader.c b/src/io-desktop/nadp-reader.c
index 9983c70..72580c8 100644
--- a/src/io-desktop/nadp-reader.c
+++ b/src/io-desktop/nadp-reader.c
@@ -483,7 +483,7 @@ read_start_profile_attach_profile( const NAIFactoryProvider *provider, NAObjectP
NADataBoxed *
nadp_reader_ifactory_provider_read_data( const NAIFactoryProvider *reader, void *reader_data, const NAIFactoryObject *object, const NADataDef *def, GSList **messages )
{
- static const gchar *thisfn = "nadp_reader_ifactory_provider_read_value";
+ static const gchar *thisfn = "nadp_reader_ifactory_provider_read_data";
NADataBoxed *boxed;
gboolean found;
NadpReaderData *nrd;
@@ -494,13 +494,6 @@ nadp_reader_ifactory_provider_read_data( const NAIFactoryProvider *reader, void
GSList *slist_value;
guint uint_value;
- /*g_debug( "%s: reader=%p (%s), reader_data=%p, def=%p (%s), messages=%p",
- thisfn,
- ( void * ) reader, G_OBJECT_TYPE_NAME( reader ),
- ( void * ) reader_data,
- ( void * ) def, def->name,
- ( void * ) messages );*/
-
g_return_val_if_fail( NA_IS_IFACTORY_PROVIDER( reader ), NULL );
g_return_val_if_fail( NADP_IS_DESKTOP_PROVIDER( reader ), NULL );
g_return_val_if_fail( NA_IS_IFACTORY_OBJECT( object ), NULL );
@@ -546,7 +539,6 @@ nadp_reader_ifactory_provider_read_data( const NAIFactoryProvider *reader, void
case NAFD_TYPE_BOOLEAN:
bool_value = nadp_desktop_file_get_boolean( nrd->ndf, group, def->desktop_entry, &found, na_core_utils_boolean_from_string( def->default_value ));
- g_debug( "%s: name=%s, found=%s, value=%s", thisfn, def->name, found ? "True":"False", bool_value ? "True":"False" );
if( found ){
boxed = na_data_boxed_new( def );
na_data_boxed_set_from_void( boxed, GUINT_TO_POINTER( bool_value ));
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 74718d2..52077db 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -1127,7 +1127,6 @@ setup_current_selection( NactMainWindow *window, NAObjectId *selected_row )
if( NA_IS_OBJECT_PROFILE( selected_row )){
window->private->current_profile = NA_OBJECT_PROFILE( selected_row );
- window->private->current_context = NA_ICONTEXT( selected_row );
window->private->current_item = NA_OBJECT_ITEM( na_object_get_parent( selected_row ));
} else {
@@ -1141,6 +1140,7 @@ setup_current_selection( NactMainWindow *window, NAObjectId *selected_row )
if( nb_profiles == 1 ){
profiles = na_object_get_items( selected_row );
window->private->current_profile = NA_OBJECT_PROFILE( profiles->data );
+ window->private->current_context = NA_ICONTEXT( profiles->data );
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]