예제 #1
0
xmlNodePtr
eel_xml_get_child_by_name_and_property (xmlNodePtr parent,
                                        const char *child_name,
                                        const char *property_name,
                                        const char *property_value)
{
    xmlNodePtr child;
    xmlChar *property;
    gboolean match;

    if (parent == NULL)
    {
        return NULL;
    }
    for (child = eel_xml_get_children (parent); child != NULL; child = child->next)
    {
        if (strcmp (child->name, child_name) == 0)
        {
            property = xmlGetProp (child, property_name);
            match = eel_strcmp (property, property_value) == 0;
            xmlFree (property);
            if (match)
            {
                return child;
            }
        }
    }
    return NULL;
}
void
nautilus_progress_info_set_details (NautilusProgressInfo *info,
				    const char           *details)
{
	G_LOCK (progress_info);
	
	if (eel_strcmp (info->details, details) != 0) {
		g_free (info->details);
		info->details = g_strdup (details);
		
		info->changed_at_idle = TRUE;
		queue_idle (info, FALSE);
	}
  
	G_UNLOCK (progress_info);
}
예제 #3
0
/* "." for the directory-as-file, otherwise the filename */
NautilusFile *
nautilus_directory_find_file_by_internal_filename (NautilusDirectory *directory,
						   const char *internal_filename)
{
	NautilusFile *result;

	if (eel_strcmp (internal_filename, ".") == 0) {
		result = nautilus_directory_get_existing_corresponding_file (directory);
		if (result != NULL) {
			nautilus_file_unref (result);
		}
	} else {
		result = nautilus_directory_find_file_by_name (directory, internal_filename);
	}

	return result;
}
void
nautilus_progress_info_take_details (NautilusProgressInfo *info,
				     char           *details)
{
	G_LOCK (progress_info);
	
	if (eel_strcmp (info->details, details) != 0) {
		g_free (info->details);
		info->details = details;
		
		info->changed_at_idle = TRUE;
		queue_idle (info, FALSE);
	} else {
		g_free (details);
	}
  
	G_UNLOCK (progress_info);
}
void
nautilus_progress_info_take_status (NautilusProgressInfo *info,
				    char *status)
{
	G_LOCK (progress_info);
	
	if (eel_strcmp (info->status, status) != 0) {
		g_free (info->status);
		info->status = status;
		
		info->changed_at_idle = TRUE;
		queue_idle (info, FALSE);
	} else {
		g_free (status);
	}
	
	G_UNLOCK (progress_info);
}
static char*
format_name_for_display (NautilusCustomizationData *data, const char* name)
{
	char *formatted_str, *mapped_name;

	if (!eel_strcmp(name, RESET_IMAGE_NAME)) {
		return g_strdup (_("Reset"));
	}

	/* map file names to display names using the mappings defined in the hash table */
	
	formatted_str = strip_extension (name);
	if (data->name_map_hash != NULL) {
		mapped_name = g_hash_table_lookup (data->name_map_hash, formatted_str);
		if (mapped_name) {
			g_free (formatted_str);
			formatted_str = g_strdup (mapped_name);
		}	
	}
			
	return formatted_str;	
}
gboolean
nautilus_customization_data_get_next_element_for_display (NautilusCustomizationData *data,
							  char **emblem_name,
							  GdkPixbuf **pixbuf_out,
							  char **label_out)
{
	GFileInfo *current_file_info;
	char *image_file_name;
	GdkPixbuf *pixbuf;
	GdkPixbuf *orig_pixbuf;
	gboolean is_reset_image;
	
	g_return_val_if_fail (data != NULL, FALSE);
	g_return_val_if_fail (emblem_name != NULL, FALSE);
	g_return_val_if_fail (pixbuf_out != NULL, FALSE);
	g_return_val_if_fail (label_out != NULL, FALSE);
	
	if (data->current_file_list == NULL) {
		if (data->reading_mode == READ_PUBLIC_CUSTOMIZATIONS) {
			if (data->private_file_list == NULL) {
				return FALSE;
			}
			data->reading_mode = READ_PRIVATE_CUSTOMIZATIONS;
			data->current_file_list = data->private_file_list;
			return nautilus_customization_data_get_next_element_for_display (data,
											 emblem_name,
											 pixbuf_out,
											 label_out);
		}
		else {
			return FALSE;
		}
	}
	
	
	current_file_info = data->current_file_list->data;
	data->current_file_list = data->current_file_list->next;

	g_assert (current_file_info != NULL);

	if (!eel_istr_has_prefix (g_file_info_get_content_type (current_file_info), "image/")
	    || eel_istr_has_prefix (g_file_info_get_name (current_file_info), ".")) {
		return nautilus_customization_data_get_next_element_for_display (data,
										 emblem_name,
										 pixbuf_out,
										 label_out);
	}

	image_file_name = get_file_path_for_mode (data,
						  g_file_info_get_name (current_file_info));
	orig_pixbuf = gdk_pixbuf_new_from_file (image_file_name, NULL);

	if (orig_pixbuf == NULL) {
		orig_pixbuf = rsvg_pixbuf_from_file_at_max_size (image_file_name,
								 data->maximum_icon_width, 
								 data->maximum_icon_height,
								 NULL);
	}
	g_free (image_file_name);

	if (orig_pixbuf == NULL) {
		return nautilus_customization_data_get_next_element_for_display (data,
										 emblem_name,
										 pixbuf_out,
										 label_out);
	}

	is_reset_image = eel_strcmp(g_file_info_get_name (current_file_info), RESET_IMAGE_NAME) == 0;

	*emblem_name = g_strdup (g_file_info_get_name (current_file_info));

	if (strcmp (data->customization_name, "patterns") == 0 &&
	    data->pattern_frame != NULL) {
		pixbuf = nautilus_customization_make_pattern_chit (orig_pixbuf, data->pattern_frame, FALSE, is_reset_image);
	} else {
		pixbuf = eel_gdk_pixbuf_scale_down_to_fit (orig_pixbuf, 
							   data->maximum_icon_width, 
							   data->maximum_icon_height);
	}

	g_object_unref (orig_pixbuf);
	
	*pixbuf_out = pixbuf;
	
	*label_out = format_name_for_display (data, g_file_info_get_name (current_file_info));

	if (data->reading_mode == READ_PRIVATE_CUSTOMIZATIONS) {
		data->private_data_was_displayed = TRUE;
	}
	return TRUE;
}