Exemplo n.º 1
0
static void
write_done_write_subitems_list( CappDesktopFile *ndp, NAObjectItem *item )
{
	static const gchar *thisfn = "cadp_writer_write_done_write_subitems_list";
	GSList *subitems;
	GSList *profile_groups, *ip;
	gchar *tmp;

	subitems = na_object_get_items_slist( item );
	tmp = g_strdup_printf( "%s (written subitems)", thisfn );
	na_core_utils_slist_dump( tmp, subitems );
	g_free( tmp );

	cadp_desktop_file_set_string_list(
			ndp,
			CADP_GROUP_DESKTOP,
			NA_IS_OBJECT_ACTION( item ) ? CADP_KEY_PROFILES : CADP_KEY_ITEMS_LIST,
			subitems );

	profile_groups = cadp_desktop_file_get_profiles( ndp );
	tmp = g_strdup_printf( "%s (existing profiles)", thisfn );
	na_core_utils_slist_dump( tmp, profile_groups );
	g_free( tmp );

	for( ip = profile_groups ; ip ; ip = ip->next ){
		if( na_core_utils_slist_count( subitems, ( const gchar * ) ip->data ) == 0 ){
			g_debug( "%s: deleting (removed) profile %s", thisfn, ( const gchar * ) ip->data );
			cadp_desktop_file_remove_profile( ndp, ( const gchar * ) ip->data );
		}
	}

	na_core_utils_slist_free( profile_groups );
	na_core_utils_slist_free( subitems );
}
Exemplo n.º 2
0
/**
 * na_core_utils_slist_are_equal:
 * @a: a GSList of strings.
 * @b: another GSList of strings to be compared with @first.
 *
 * Compare two string lists, without regards to the order.
 *
 * Returns: %TRUE if the two lists have same content.
 *
 * Since: 2.30
 */
gboolean
na_core_utils_slist_are_equal( GSList *a, GSList *b )
{
	GSList *il;

	for( il = a ; il ; il = il->next ){
		const gchar *str = ( const gchar * ) il->data;
		if( na_core_utils_slist_count( b, str ) == 0 ){
			return( FALSE );
		}
	}

	for( il = b ; il ; il = il->next ){
		const gchar *str = ( const gchar * ) il->data;
		if( na_core_utils_slist_count( a, str ) == 0 ){
			return( FALSE );
		}
	}

	return( TRUE );
}
Exemplo n.º 3
0
/**
 * na_core_utils_slist_setup_element:
 * @list: the GSList of strings to be setup.
 * @element: the string to add to or remove of the list.
 * @set: whether the @element should be set or removed.
 *
 * Setup the @list so that the @element is once in the @list if @set is %TRUE,
 * or not if @set is %FALSE.
 *
 * Returns: the updated @list.
 *
 * Since: 2.30
 */
GSList *
na_core_utils_slist_setup_element( GSList *list, const gchar *element, gboolean set )
{
	guint count;

	count = na_core_utils_slist_count( list, element );

	if( set && count == 0 ){
		list = g_slist_prepend( list, g_strdup( element ));
	}
	if( !set && count > 0 ){
		list = na_core_utils_slist_remove_ascii( list, element );
	}

	return( list );
}