static GdkPixbuf * photos_base_item_create_placeholder_icon (const gchar *icon_name) { GApplication *app; GdkPixbuf *centered_pixbuf = NULL; GdkPixbuf *pixbuf = NULL; GdkPixbuf *ret_val = NULL; GError *error; GIcon *icon = NULL; GList *windows; GtkIconInfo *info = NULL; GtkIconTheme *theme; GtkStyleContext *context; gint icon_size; gint scale; app = g_application_get_default (); windows = gtk_application_get_windows (GTK_APPLICATION (app)); if (windows == NULL) goto out; icon = g_themed_icon_new (icon_name); scale = photos_application_get_scale_factor (PHOTOS_APPLICATION (app)); theme = gtk_icon_theme_get_default (); info = gtk_icon_theme_lookup_by_gicon_for_scale (theme, icon, 16, scale, GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_FORCE_SYMBOLIC); if (info == NULL) goto out; context = gtk_widget_get_style_context (GTK_WIDGET (windows->data)); error = NULL; pixbuf = gtk_icon_info_load_symbolic_for_context (info, context, NULL, &error); if (error != NULL) { g_warning ("Unable to load icon '%s': %s", icon_name, error->message); g_error_free (error); goto out; } icon_size = photos_utils_get_icon_size (); centered_pixbuf = photos_utils_center_pixbuf (pixbuf, icon_size); photos_utils_border_pixbuf (centered_pixbuf); ret_val = centered_pixbuf; centered_pixbuf = NULL; out: g_clear_object (¢ered_pixbuf); g_clear_object (&pixbuf); g_clear_object (&info); g_clear_object (&icon); return ret_val; }
GIcon * photos_utils_icon_from_rdf_type (const gchar *type) { GIcon *ret_val = NULL; gint size; size = photos_utils_get_icon_size (); if (strstr (type, "nfo#DataContainer") != NULL) ret_val = photos_utils_create_collection_icon (size, NULL); return ret_val; }
static GIcon * photos_base_item_create_symbolic_emblem (const gchar *name) { GIcon *pix; gint size; size = photos_utils_get_icon_size (); pix = photos_utils_create_symbolic_icon (name, size); if (pix == NULL) pix = g_themed_icon_new (name); return pix; }
static gboolean photos_facebook_item_create_thumbnail (PhotosBaseItem *item, GCancellable *cancellable, GError **error) { GFBGraphPhoto *photo; const GFBGraphPhotoImage *thumbnail_image; gchar *local_path, *local_dir; GFile *local_file, *remote_file; gboolean ret_val = FALSE; photo = photos_facebook_get_gfbgraph_photo (item, cancellable, error); if (photo == NULL) { g_error ("Can't get the photo from the Facebook Graph\n"); } else { thumbnail_image = gfbgraph_photo_get_image_near_width (photo, photos_utils_get_icon_size ()); if (thumbnail_image == NULL) { g_error ("Can't get a photo size to create the thumbnail.\n"); } else { remote_file = g_file_new_for_uri (thumbnail_image->source); local_path = gnome_desktop_thumbnail_path_for_uri (photos_base_item_get_uri (item), GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL); local_file = g_file_new_for_path (local_path); local_dir = g_path_get_dirname (local_path); g_mkdir_with_parents (local_dir, 0700); g_debug ("Downloading %s from Facebook to %s", thumbnail_image->source, local_path); if (g_file_copy (remote_file, local_file, G_FILE_COPY_ALL_METADATA | G_FILE_COPY_OVERWRITE, cancellable, NULL, NULL, error)) ret_val = TRUE; g_free (local_path); g_free (local_dir); g_clear_object (&local_file); g_clear_object (&remote_file); } } return ret_val; }
GIcon * photos_utils_get_icon_from_item (PhotosBaseItem *item) { GIcon *icon = NULL; gboolean is_remote = FALSE; const gchar *identifier; const gchar *mime_type; identifier = photos_base_item_get_identifier (item); if (identifier != NULL) { if (g_str_has_prefix (identifier, "facebook:") || g_str_has_prefix (identifier, "flickr:") || g_str_has_prefix (identifier, "google:")) is_remote = TRUE; } if (!is_remote) icon = photos_utils_get_thumbnail_icon (item); if (icon != NULL) goto out; mime_type = photos_base_item_get_mime_type (item); if (mime_type != NULL) icon = g_content_type_get_icon (mime_type); if (icon != NULL) goto out; if (photos_base_item_is_collection (item)) { gint size; size = photos_utils_get_icon_size (); icon = photos_utils_create_collection_icon (size, NULL); } if (icon != NULL) goto out; icon = g_themed_icon_new ("image-x-generic"); out: return icon; }