static gboolean add_single_file_from_media (BgPicturesSource *bg_source, GFile *file, GrlMedia *media) { GDateTime *mtime; const gchar *content_type; gint64 mtime_unix; content_type = grl_media_get_mime (media); /* only GRL_METADATA_KEY_CREATION_DATE is implemented in the Flickr * plugin, GRL_METADATA_KEY_MODIFICATION_DATE is not */ mtime = grl_media_get_creation_date (media); if (!mtime) mtime = grl_media_get_modification_date (media); if (mtime) mtime_unix = g_date_time_to_unix (mtime); else mtime_unix = g_get_real_time () / G_USEC_PER_SEC; return add_single_file (bg_source, file, content_type, (guint64) mtime_unix, NULL); }
static void element_browser (gpointer data, gpointer user_data) { GrlMedia *media = GRL_MEDIA (data); GrlSource *source = GRL_SOURCE (user_data); /* Check if we got a valid media object as some plugins may call the callback with a NULL media under certain circumstances (for example when they cannot estimate the number of remaining results and they find suddenly they don't have any more results to send) */ if (!media) { g_debug ("Media element is NULL!"); goto out; } const gchar *title = grl_media_get_title (media); /* If the media is a container, that means we will browse it again */ if (grl_media_is_container (media)) { guint childcount = grl_media_get_childcount (media); g_debug ("\t Got '%s' (container with %d elements)", title, childcount); source_browser (source, media); } else { const gchar *url = grl_media_get_url (media); const gchar *mime = grl_media_get_mime (media); GDateTime *date = grl_media_get_modification_date (media); time_t rawdate = g_date_time_to_unix(date); g_printf ("\t Got '%s', of type '%s', ctime is '%s'\n", title, mime, ctime(&rawdate)); g_printf ("\t\t URL: %s\n", url); } out: g_object_unref (media); }