Ejemplo n.º 1
0
/*
 * at this time, the object has been allocated and its id has been set
 * read here the subitems key, which may be 'Profiles' or 'ItemsList'
 * depending of the exact class of the NAObjectItem
 */
void
nadp_reader_ifactory_provider_read_start( const NAIFactoryProvider *reader, void *reader_data, const NAIFactoryObject *serializable, GSList **messages )
{
	static const gchar *thisfn = "nadp_reader_ifactory_provider_read_start";

	g_return_if_fail( NA_IS_IFACTORY_PROVIDER( reader ));
	g_return_if_fail( NADP_IS_DESKTOP_PROVIDER( reader ));
	g_return_if_fail( NA_IS_IFACTORY_OBJECT( serializable ));

	if( !NADP_DESKTOP_PROVIDER( reader )->private->dispose_has_run ){

		g_debug( "%s: reader=%p (%s), reader_data=%p, serializable=%p (%s), messages=%p",
				thisfn,
				( void * ) reader, G_OBJECT_TYPE_NAME( reader ),
				( void * ) reader_data,
				( void * ) serializable, G_OBJECT_TYPE_NAME( serializable ),
				( void * ) messages );

		if( NA_IS_OBJECT_ITEM( serializable )){
			read_start_read_subitems_key( reader, NA_OBJECT_ITEM( serializable ), ( NadpReaderData * ) reader_data, messages );
			na_object_set_iversion( serializable, 3 );
		}

		if( NA_IS_OBJECT_PROFILE( serializable )){
			read_start_profile_attach_profile( reader, NA_OBJECT_PROFILE( serializable ), ( NadpReaderData * ) reader_data, messages );
		}
	}
}
Ejemplo n.º 2
0
/*
 * find a profile candidate to be executed for the given uris
 */
static NAObjectProfile *
get_profile_for_targets( NAObjectAction *action, GList *targets )
{
	/*static const gchar *thisfn = "caja_actions_run_get_profile_for_targets";*/
	GList *profiles, *ip;
	NAObjectProfile *candidate;

	candidate = NULL;
	profiles = na_object_get_items( action );

	for( ip = profiles ; ip && !candidate ; ip = ip->next ){
		if( na_icontext_is_candidate( NA_ICONTEXT( ip->data ), ITEM_TARGET_ANY, targets )){
			candidate = NA_OBJECT_PROFILE( ip->data );
		}
	}

	return( candidate );
}
Ejemplo n.º 3
0
void
nagp_reader_read_start( const NAIFactoryProvider *provider, void *reader_data, const NAIFactoryObject *object, GSList **messages  )
{
	static const gchar *thisfn = "nagp_reader_read_start";

	g_return_if_fail( NA_IS_IFACTORY_PROVIDER( provider ));
	g_return_if_fail( NAGP_IS_GCONF_PROVIDER( provider ));
	g_return_if_fail( NA_IS_IFACTORY_OBJECT( object ));

	if( !NAGP_GCONF_PROVIDER( provider )->private->dispose_has_run ){

		g_debug( "%s: provider=%p (%s), reader_data=%p, object=%p (%s), messages=%p",
				thisfn,
				( void * ) provider, G_OBJECT_TYPE_NAME( provider ),
				( void * ) reader_data,
				( void * ) object, G_OBJECT_TYPE_NAME( object ),
				( void * ) messages );

		if( NA_IS_OBJECT_PROFILE( object )){
			read_start_profile_attach_profile( provider, NA_OBJECT_PROFILE( object ), ( ReaderData * ) reader_data, messages );
		}
	}
}
Ejemplo n.º 4
0
/*
 * allocate a new action, and fill it with values read from command-line
 */
static NAObjectAction *
get_action_from_cmdline( void )
{
	NAObjectAction *action;
	NAObjectProfile *profile;
	int i;
	GSList *basenames;
	GSList *mimetypes;
	GSList *schemes;
	GSList *folders;
	gboolean toolbar_same_label;
	gchar *msg;
	GSList *only_show_in;
	GSList *not_show_in;
	GSList *capabilities;

	action = na_object_action_new_with_defaults();
	profile = NA_OBJECT_PROFILE(( GList * ) na_object_get_items( action )->data );

	na_object_set_label( action, label );
	if( tooltip && g_utf8_strlen( tooltip, -1 )){
		na_object_set_tooltip( action, tooltip );
	}
	if( icon && g_utf8_strlen( icon, -1 )){
		na_object_set_icon( action, icon );
	}
	na_object_set_enabled( action, enabled );
	na_object_set_target_selection( action, target_selection );
	na_object_set_target_location( action, target_location );
	na_object_set_target_toolbar( action, target_toolbar );

	toolbar_same_label = FALSE;
	if( !label_toolbar || !g_utf8_strlen( label_toolbar, -1 )){
		label_toolbar = g_strdup( label );
		toolbar_same_label = TRUE;
	}
	na_object_set_toolbar_same_label( action, toolbar_same_label );
	na_object_set_toolbar_label( action, label_toolbar );

	na_object_set_path( profile, command );
	na_object_set_parameters( profile, parameters );

	i = 0;
	basenames = NULL;
	while( basenames_array != NULL && basenames_array[i] != NULL ){
		basenames = g_slist_append( basenames, g_strdup( basenames_array[i] ));
		i++;
	}
	if( basenames && g_slist_length( basenames )){
		na_object_set_basenames( profile, basenames );
		na_core_utils_slist_free( basenames );
	}

	na_object_set_matchcase( profile, matchcase );

	mimetypes = NULL;
	if( isfile ){
		msg = g_strdup_printf( DEPRECATED, "accept-files", "mimetype" );
		g_warning( "%s", msg );
		g_free( msg );
	}
	if( isdir ){
		msg = g_strdup_printf( DEPRECATED, "accept-dirs", "mimetype" );
		g_warning( "%s", msg );
		g_free( msg );
	}
	if( isfile && !isdir ){
		mimetypes = g_slist_prepend( mimetypes, g_strdup( "all/allfiles" ));
	} else if( isdir && !isfile ){
		mimetypes = g_slist_prepend( mimetypes, g_strdup( "inode/directory" ));
	}
	i = 0;
	while( mimetypes_array != NULL && mimetypes_array[i] != NULL ){
		mimetypes = g_slist_append( mimetypes, g_strdup( mimetypes_array[i] ));
		i++;
	}
	if( mimetypes && g_slist_length( mimetypes )){
		na_object_set_mimetypes( profile, mimetypes );
		na_core_utils_slist_free( mimetypes );
	}

	if( accept_multiple ){
		msg = g_strdup_printf( DEPRECATED, "accept-multiple", "selection-count" );
		g_warning( "%s", msg );
		g_free( msg );
		selection_count = g_strdup( ">0" );
	}
	if( strlen( selection_count )){
		na_object_set_selection_count( profile, selection_count );
	}

	i = 0;
	schemes = NULL;
	while( schemes_array != NULL && schemes_array[i] != NULL ){
		schemes = g_slist_append( schemes, g_strdup( schemes_array[i] ));
		i++;
	}
	if( schemes && g_slist_length( schemes )){
		na_object_set_schemes( profile, schemes );
		na_core_utils_slist_free( schemes );
	}

	i = 0;
	folders = NULL;
	while( folders_array != NULL && folders_array[i] != NULL ){
		folders = g_slist_append( folders, g_strdup( folders_array[i] ));
		i++;
	}
	if( folders && g_slist_length( folders )){
		na_object_set_folders( profile, folders );
		na_core_utils_slist_free( folders );
	}

	if( onlyshow_array ){
		only_show_in = NULL;
		for( i = 0 ; onlyshow_array[i] && strlen( onlyshow_array[i] ) ; ++i ){
			only_show_in = g_slist_append( only_show_in, g_strdup( onlyshow_array[i] ));
		}
		if( only_show_in && g_slist_length( only_show_in )){
			na_object_set_only_show_in( profile, only_show_in );
			na_core_utils_slist_free( only_show_in );
		}
	}

	if( notshow_array ){
		not_show_in = NULL;
		for( i = 0 ; notshow_array[i] && strlen( notshow_array[i] ) ; ++i ){
			not_show_in = g_slist_append( not_show_in, g_strdup( notshow_array[i] ));
		}
		if( not_show_in && g_slist_length( not_show_in )){
			na_object_set_not_show_in( profile, not_show_in );
			na_core_utils_slist_free( not_show_in );
		}
	}

	if( try_exec && strlen( try_exec )){
		na_object_set_try_exec( profile, try_exec );
	}

	if( show_registered && strlen( show_registered )){
		na_object_set_show_if_registered( profile, show_registered );
	}

	if( show_true && strlen( show_true )){
		na_object_set_show_if_true( profile, show_true );
	}

	if( show_running && strlen( show_running )){
		na_object_set_show_if_running( profile, show_running );
	}

	if( capability_array ){
		capabilities = NULL;
		for( i = 0 ; capability_array[i] && strlen( capability_array[i] ) ; ++i ){
			const gchar *cap = ( const gchar * ) capability_array[i];
			/* 'Owner', 'Readable', 'Writable', 'Executable' and 'Local' */
			if( strcmp( cap, "Owner" ) &&
				strcmp( cap, "Readable" ) &&
				strcmp( cap, "Writable" ) &&
				strcmp( cap, "Executable" ) &&
				strcmp( cap, "Local" )){
					g_warning( "%s: unknown capability", cap );
			}  else {
				capabilities = g_slist_append( capabilities, g_strdup( capability_array[i] ));
			}
		}
		if( capabilities && g_slist_length( capabilities )){
			na_object_set_capabilities( profile, capabilities );
			na_core_utils_slist_free( capabilities );
		}
	}

	return( action );
}