/* Encode a "text/plain" selection; this is a broken URL -- just * "file:" with a path after it (no escaping or anything). We are * trying to make the old gnome_uri_list_extract_filenames function * happy, so this is coded to its idiosyncrasises. */ static void add_one_compatible_uri (const char *uri, int x, int y, int w, int h, gpointer data) { GString *result; char *local_path; result = (GString *) data; /* For URLs that do not have a file: scheme, there's no harm * in passing the real URL. But for URLs that do have a file: * scheme, we have to send a URL that will work with the old * gnome-libs function or nothing will be able to understand * it. */ if (!eel_istr_has_prefix (uri, "file:")) { g_string_append (result, uri); g_string_append (result, "\r\n"); } else { local_path = g_filename_from_uri (uri, NULL, NULL); /* Check for characters that confuse the old * gnome_uri_list_extract_filenames implementation, and just leave * out any paths with those in them. */ if (is_path_that_gnome_uri_list_extract_filenames_can_parse (local_path)) { g_string_append (result, "file:"); g_string_append (result, local_path); g_string_append (result, "\r\n"); } g_free (local_path); } }
static gboolean selection_is_image_file (GList *selection_list) { const char *mime_type; NemoDragSelectionItem *selected_item; gboolean result; GFile *location; GFileInfo *info; /* Make sure only one item is selected */ if (selection_list == NULL || selection_list->next != NULL) { return FALSE; } selected_item = selection_list->data; mime_type = NULL; location = g_file_new_for_uri (selected_item->uri); info = g_file_query_info (location, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, 0, NULL, NULL); if (info) { mime_type = g_file_info_get_content_type (info); } result = eel_istr_has_prefix (mime_type, "image/"); if (info) { g_object_unref (info); } g_object_unref (location); return result; }
gboolean eel_uri_is_desktop (const char *uri) { return eel_istr_has_prefix (uri, EEL_DESKTOP_URI); }
gboolean eel_uri_is_search (const char *uri) { return eel_istr_has_prefix (uri, EEL_SEARCH_URI); }
gboolean eel_uri_is_trash (const char *uri) { return eel_istr_has_prefix (uri, "trash:"); }
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; }