[nautilus-actions] Remove background targeting indicators



commit 3fc85e6e1261c859a26d91c238e82b0fc09f76e3
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Mar 10 18:20:54 2010 +0100

    Remove background targeting indicators

 ChangeLog                    |    7 +
 src/api/na-object-api.h      |    1 -
 src/api/na-object-profile.h  |    4 +-
 src/core/na-object-profile.c |  269 ------------------------------------------
 4 files changed, 8 insertions(+), 273 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d8c0506..cb2acbd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,13 @@
 	* data/nautilus-actions.schemas.in:
 	Remove 'target-background' entry description.
 
+	* src/api/na-object-api.h
+	(na_object_is_target_background): Removed macro.
+
+	* src/api/na-object-profile.h
+	* src/core/na-object-profile.c
+	(na_object_profile_is_target_background): Removed function.
+
 2009-03-09 Pierre Wieser <pwieser trychlos org>
 
 	* src/io-gconf/nagp-writer.c (nagp_writer_write_data):
diff --git a/src/api/na-object-api.h b/src/api/na-object-api.h
index 964f4f3..c67fd9c 100644
--- a/src/api/na-object-api.h
+++ b/src/api/na-object-api.h
@@ -157,7 +157,6 @@ G_BEGIN_DECLS
 #define na_object_is_multiple( obj )					(( gboolean ) GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_MULTIPLE )))
 #define na_object_get_schemes( obj )					(( GSList * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_SCHEMES ))
 #define na_object_get_folders( obj )					(( GSList * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_FOLDERS ))
-#define na_object_is_target_background( obj )			na_object_profile_is_target_background( NA_OBJECT_PROFILE( obj ))
 
 #define na_object_set_path( obj, path )					na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_PATH, ( const void * )( path ))
 #define na_object_set_parameters( obj, parms )			na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_PARAMETERS, ( const void * )( parms ))
diff --git a/src/api/na-object-profile.h b/src/api/na-object-profile.h
index dec1509..9a41c9a 100644
--- a/src/api/na-object-profile.h
+++ b/src/api/na-object-profile.h
@@ -72,9 +72,7 @@ GType            na_object_profile_get_type( void );
 NAObjectProfile *na_object_profile_new( void );
 NAObjectProfile *na_object_profile_new_with_defaults( void );
 
-gboolean         na_object_profile_is_target_background( const NAObjectProfile *profile );
-
-gchar           *na_object_profile_parse_parameters    ( const NAObjectProfile *profile, gint target, GList *selected );
+gchar           *na_object_profile_parse_parameters( const NAObjectProfile *profile, gint target, GList *selected );
 
 G_END_DECLS
 
diff --git a/src/core/na-object-profile.c b/src/core/na-object-profile.c
index cda9c10..ffd8d26 100644
--- a/src/core/na-object-profile.c
+++ b/src/core/na-object-profile.c
@@ -58,11 +58,6 @@ struct NAObjectProfileClassPrivate {
  */
 struct NAObjectProfilePrivate {
 	gboolean dispose_has_run;
-
-	/* dynamic data set when reading from I/O providers (see read_done())
-	 * may also be a NADataBoxed, left as private variable as an exercise
-	 */
-	gboolean target_background;
 };
 
 #define PROFILE_NAME_PREFIX					"profile-"
@@ -89,8 +84,6 @@ static gboolean     ifactory_object_is_valid( const NAIFactoryObject *object );
 static void         ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages );
 static guint        ifactory_object_write_done( NAIFactoryObject *instance, const NAIFactoryProvider *writer, void *writer_data, GSList **messages );
 
-static void         set_target_background( NAObjectProfile *profile );
-
 static void         icontext_conditions_iface_init( NAIContextualInterface *iface );
 
 static gboolean     profile_is_valid( const NAObjectProfile *profile );
@@ -345,51 +338,9 @@ ifactory_object_is_valid( const NAIFactoryObject *object )
 static void
 ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages )
 {
-	set_target_background( NA_OBJECT_PROFILE( instance ));
-
 	na_factory_object_set_defaults( instance );
 }
 
-/*
- * set the target_background dynamic flag as a private data
- *
- * a profile is candidate for display on background callback, if:
- * - it doesn't target files, but only dirs
- * - it doesn't require a multiple selection
- * - basenames are set as default
- *
- * as of actions v2, this means:
- * - ifile is false
- * - isdir is true
- * - basenames = '*'
- * - mimetypes = '*'
- *
- * note that, though the conditions may be modified in NACT user
- * interface, they will be reloaded, and so this flag recomputed, when
- * the pivot reloads its tree after a save; and, as this flag is only
- * needed in the plugins, then we only need to compute at read_done()
- * time.
- */
-static void
-set_target_background( NAObjectProfile *profile )
-{
-	GSList *basenames = na_object_get_basenames( profile );
-	GSList *mimetypes = na_object_get_mimetypes( profile );
-
-	profile->private->target_background = \
-			!na_object_is_file( profile ) && \
-			na_object_is_dir( profile ) && \
-			( basenames == NULL ||
-					( g_slist_length( basenames ) == 1 &&
-							strcmp(( const char * ) basenames->data, "*" ) == 0 )) && \
-			( mimetypes == NULL ||
-					( g_slist_length( mimetypes ) == 1 &&
-							strcmp(( const char * ) mimetypes->data, "*" ) == 0 ));
-
-	na_core_utils_slist_free( basenames );
-	na_core_utils_slist_free( mimetypes );
-}
-
 static guint
 ifactory_object_write_done( NAIFactoryObject *instance, const NAIFactoryProvider *writer, void *writer_data, GSList **messages )
 {
@@ -508,226 +459,6 @@ na_object_profile_new_with_defaults( void )
 }
 
 /**
- * na_object_profile_is_target_background:
- * @profile: the #NAObjectProfile to be checked.
- *
- * Returns: %TRUE if this profile may be candidate when displaying
- * background actions, %FALSE else.
- */
-gboolean
-na_object_profile_is_target_background( const NAObjectProfile *profile )
-{
-	gboolean is_candidate;
-
-	g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), FALSE );
-
-	is_candidate = FALSE;
-
-	if( !profile->private->dispose_has_run ){
-
-		is_candidate = profile->private->target_background;
-	}
-
-	return( is_candidate );
-}
-
-#if 0
-static gboolean
-is_target_selection_candidate( const NAObjectProfile *profile, GList *files, gboolean from_nautilus )
-{
-	gboolean retv = FALSE;
-	GSList *basenames, *mimetypes, *schemes;
-	gboolean matchcase, multiple, isdir, isfile;
-	gboolean test_multiple_file = FALSE;
-	gboolean test_file_type = FALSE;
-	gboolean test_scheme = FALSE;
-	gboolean test_basename = FALSE;
-	gboolean test_mimetype = FALSE;
-	GList* glob_patterns = NULL;
-	GList* glob_mime_patterns = NULL;
-	GSList* iter;
-	GList* iter1;
-	GList* iter2;
-	guint dir_count = 0;
-	guint file_count = 0;
-	guint total_count = 0;
-	guint scheme_ok_count = 0;
-	guint glob_ok_count = 0;
-	guint mime_glob_ok_count = 0;
-	gboolean basename_match_ok = FALSE;
-	gboolean mimetype_match_ok = FALSE;
-	gchar *tmp_pattern, *tmp_filename, *tmp_filename2, *tmp_mimetype, *tmp_mimetype2;
-
-	basenames = na_object_get_basenames( profile );
-	matchcase = na_object_is_matchcase( profile );
-	multiple = na_object_is_multiple( profile );
-	isdir = na_object_is_dir( profile );
-	isfile = na_object_is_file( profile );
-	mimetypes = na_object_get_mimetypes( profile );
-	schemes = na_object_get_schemes( profile );
-
-	if( basenames && basenames->next != NULL &&
-			g_ascii_strcasecmp(( gchar * )( basenames->data ), "*" ) == 0 ){
-		/* if the only pattern is '*' then all files will match, so it
-		 * is not necessary to make the test for each of them
-		 */
-		test_basename = TRUE;
-
-	} else {
-		for (iter = basenames ; iter ; iter = iter->next ){
-
-			tmp_pattern = ( gchar * ) iter->data;
-			if( !matchcase ){
-				/* --> if case-insensitive asked, lower all the string
-				 * since the pattern matching function don't manage it
-				 * itself.
-				 */
-				tmp_pattern = g_ascii_strdown(( gchar * ) iter->data, strlen(( gchar * ) iter->data ));
-			}
-
-			glob_patterns = g_list_append( glob_patterns, g_pattern_spec_new( tmp_pattern ));
-
-			if( !matchcase ){
-				g_free( tmp_pattern );
-			}
-		}
-	}
-
-	if( mimetypes && mimetypes->next != NULL &&
-			( g_ascii_strcasecmp(( gchar * )( mimetypes->data ), "*" ) == 0 ||
-			  g_ascii_strcasecmp(( gchar * )( mimetypes->data), "*/*") == 0 )){
-		/* if the only pattern is '*' or * / * then all mimetypes will
-		 * match, so it is not necessary to make the test for each of them
-		 */
-		test_mimetype = TRUE;
-
-	} else {
-		for( iter = mimetypes ; iter ; iter = iter->next ){
-			glob_mime_patterns = g_list_append( glob_mime_patterns, g_pattern_spec_new(( gchar * ) iter->data ));
-		}
-	}
-
-	for( iter1 = files; iter1; iter1 = iter1->next ){
-
-		tmp_filename = tracked_to_basename( iter1->data, from_nautilus );
-
-		if( tmp_filename ){
-			tmp_mimetype = tracked_to_mimetype( iter1->data, from_nautilus );
-
-			if( !matchcase ){
-				/* --> if case-insensitive asked, lower all the string
-				 * since the pattern matching function don't manage it
-				 * itself.
-				 */
-				tmp_filename2 = g_ascii_strdown( tmp_filename, strlen( tmp_filename ));
-				g_free( tmp_filename );
-				tmp_filename = tmp_filename2;
-			}
-
-			/* --> for the moment we deal with all mimetypes case-insensitively */
-			tmp_mimetype2 = g_ascii_strdown( tmp_mimetype, strlen( tmp_mimetype ));
-			g_free( tmp_mimetype );
-			tmp_mimetype = tmp_mimetype2;
-
-			if( tracked_is_directory( iter1->data, from_nautilus )){
-				dir_count++;
-			} else {
-				file_count++;
-			}
-
-			scheme_ok_count += validate_schemes( schemes, iter1->data, from_nautilus );
-
-			if( !test_basename ){ /* if it is already ok, skip the test to improve performance */
-				basename_match_ok = FALSE;
-				iter2 = glob_patterns;
-				while( iter2 && !basename_match_ok ){
-					if( g_pattern_match_string(( GPatternSpec * ) iter2->data, tmp_filename )){
-						basename_match_ok = TRUE;
-					}
-					iter2 = iter2->next;
-				}
-
-				if( basename_match_ok ){
-					glob_ok_count++;
-				}
-			}
-
-			if( !test_mimetype ){ /* if it is already ok, skip the test to improve performance */
-				mimetype_match_ok = FALSE;
-				iter2 = glob_mime_patterns;
-				while( iter2 && !mimetype_match_ok ){
-					if (g_pattern_match_string(( GPatternSpec * ) iter2->data, tmp_mimetype )){
-						mimetype_match_ok = TRUE;
-					}
-					iter2 = iter2->next;
-				}
-
-				if( mimetype_match_ok ){
-					mime_glob_ok_count++;
-				}
-			}
-
-			g_free( tmp_mimetype );
-			g_free( tmp_filename );
-		}
-
-		total_count++;
-	}
-
-	if(( files != NULL ) && ( files->next == NULL ) && ( !multiple )){
-		test_multiple_file = TRUE;
-
-	} else if( multiple ){
-		test_multiple_file = TRUE;
-	}
-
-	if( isdir && isfile ){
-		if( dir_count > 0 || file_count > 0 ){
-			test_file_type = TRUE;
-		}
-	} else if( isdir && !isfile ){
-		if( file_count == 0 ){
-			test_file_type = TRUE;
-		}
-	} else if( !isdir && isfile ){
-		if( dir_count == 0 ){
-			test_file_type = TRUE;
-		}
-	}
-
-	if( scheme_ok_count == total_count ){
-		test_scheme = TRUE;
-	}
-
-	if( !test_basename ){ /* if not already tested */
-		if( glob_ok_count == total_count ){
-			test_basename = TRUE;
-		}
-	}
-
-	if( !test_mimetype ){ /* if not already tested */
-		if( mime_glob_ok_count == total_count ){
-			test_mimetype = TRUE;
-		}
-	}
-
-	if( test_basename && test_mimetype && test_file_type && test_scheme && test_multiple_file ){
-		retv = TRUE;
-	}
-
-	g_list_foreach (glob_patterns, (GFunc) g_pattern_spec_free, NULL);
-	g_list_free (glob_patterns);
-	g_list_foreach (glob_mime_patterns, (GFunc) g_pattern_spec_free, NULL);
-	g_list_free (glob_mime_patterns);
-	na_core_utils_slist_free( schemes );
-	na_core_utils_slist_free( mimetypes );
-	na_core_utils_slist_free( basenames );
-
-	return retv;
-}
-#endif
-
-/**
  * Expands the parameters path, in function of the found tokens.
  *
  * @profile: the selected profile.



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