After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 707569 - Reimplement the Flickr source using Grilo
Reimplement the Flickr source using Grilo
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Background
3.9.x
Other All
: Normal enhancement
: ---
Assigned To: Debarshi Ray
Control-Center Maintainers
3.12
: 636869 (view as bug list)
Depends on: 724615
Blocks:
 
 
Reported: 2013-09-05 14:44 UTC by Debarshi Ray
Modified: 2014-02-18 10:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
background: Remove uses of libsocialweb (9.46 KB, patch)
2013-09-06 15:58 UTC, Debarshi Ray
accepted-commit_after_freeze Details | Review
background: Don't access possibly invalid object (941 bytes, patch)
2013-09-06 15:59 UTC, Debarshi Ray
committed Details | Review
background: Implement the Flickr source using Grilo (18.97 KB, patch)
2013-09-06 15:59 UTC, Debarshi Ray
needs-work Details | Review
background: Remove uses of libsocialweb (8.78 KB, patch)
2013-09-09 13:32 UTC, Debarshi Ray
none Details | Review
background: Implement the Flickr source using Grilo (18.48 KB, patch)
2013-09-09 13:33 UTC, Debarshi Ray
needs-work Details | Review
background: Remove uses of libsocialweb (8.46 KB, patch)
2013-09-09 14:29 UTC, Debarshi Ray
reviewed Details | Review
background: Remove uses of libsocialweb and BgFlickrSource (12.54 KB, patch)
2014-02-11 16:13 UTC, Debarshi Ray
committed Details | Review
background: Remove redundant and unused parameter from add_single_file (3.19 KB, patch)
2014-02-12 16:49 UTC, Debarshi Ray
reviewed Details | Review
background: Minor clean up (963 bytes, patch)
2014-02-12 16:49 UTC, Debarshi Ray
committed Details | Review
background: Add support for Flickr pictures (16.03 KB, patch)
2014-02-12 16:50 UTC, Debarshi Ray
needs-work Details | Review
background: Remove redundant and unused parameter from add_single_file (3.41 KB, patch)
2014-02-13 14:04 UTC, Debarshi Ray
needs-work Details | Review
background: Remove redundant and unused parameter from add_single_file (3.25 KB, patch)
2014-02-13 14:21 UTC, Debarshi Ray
committed Details | Review
background: Add support for Flickr pictures (15.95 KB, patch)
2014-02-13 14:46 UTC, Debarshi Ray
none Details | Review
background: Add CcBackgroundGriloMiner (12.81 KB, patch)
2014-02-17 09:19 UTC, Debarshi Ray
accepted-commit_now Details | Review
background: Add support for Flickr pictures (9.07 KB, patch)
2014-02-17 09:20 UTC, Debarshi Ray
needs-work Details | Review
background: Add CcBackgroundGriloMiner (13.99 KB, patch)
2014-02-17 19:05 UTC, Debarshi Ray
committed Details | Review
background: Add support for Flickr pictures (10.55 KB, patch)
2014-02-18 09:17 UTC, Debarshi Ray
accepted-commit_now Details | Review
background: Add support for Flickr pictures (10.55 KB, patch)
2014-02-18 09:23 UTC, Debarshi Ray
none Details | Review
background: Add support for Flickr pictures (10.35 KB, patch)
2014-02-18 10:13 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2013-09-05 14:44:47 UTC
The Flickr integration for gnome-photos uses Grilo for the protocol / API implementation. We should reimplement the Background panel's BgFlickrSource using the same stack so that the same code paths are used by both gnome-control-center and gnome-photos, and we reduce the dependency footprint.
Comment 1 Bastien Nocera 2013-09-05 16:38:25 UTC
The Flickr source was supposed to show "related" sources, eg. best/most recent pictures from friends. So this would require us only showing the flickr source when the user has Flickr setup in GOA, and not in other circumstances.
Comment 2 Debarshi Ray 2013-09-06 12:06:56 UTC
(In reply to comment #1)
> So this would require us only showing the flickr source
> when the user has Flickr setup in GOA, and not in other circumstances.

Yes, that is the idea.
Comment 3 Debarshi Ray 2013-09-06 15:58:50 UTC
Created attachment 254265 [details] [review]
background: Remove uses of libsocialweb
Comment 4 Debarshi Ray 2013-09-06 15:59:21 UTC
Created attachment 254266 [details] [review]
background: Don't access possibly invalid object
Comment 5 Debarshi Ray 2013-09-06 15:59:46 UTC
Created attachment 254267 [details] [review]
background: Implement the Flickr source using Grilo
Comment 6 Bastien Nocera 2013-09-06 17:15:55 UTC
Review of attachment 254265 [details] [review]:

Does this actually compile and work (eg. not crash)?

If so, that's fine to commit, but I'd rather the cc-background-chooser-dialog.c ifdef removals were changes to "#if 0" so that the UI isn't actually enabled.
Comment 7 Bastien Nocera 2013-09-06 17:19:16 UTC
Review of attachment 254266 [details] [review]:

This needs to be committed to master.
Comment 8 Bastien Nocera 2013-09-06 17:23:25 UTC
Review of attachment 254267 [details] [review]:

::: panels/background/bg-flickr-source.h
@@ +71,3 @@
 GType bg_flickr_source_get_type (void) G_GNUC_CONST;
 
+BgFlickrSource *bg_flickr_source_new (GList *accounts);

I would make this fallible, using GInitable...

::: panels/background/cc-background-chooser-dialog.c
@@ +296,3 @@
   priv->colors_source = bg_colors_source_new ();
+
+  if (client != NULL)

...And do all this GOA work inside the flickr source.
Comment 9 Bastien Nocera 2013-09-06 17:24:03 UTC
Review of attachment 254265 [details] [review]:

Marking as after freeze, I doubt this will go in for 3.10 though you can try once the code itself is sorted.
Comment 10 Debarshi Ray 2013-09-06 19:57:27 UTC
(In reply to comment #6)
> Review of attachment 254265 [details] [review]:
> 
> Does this actually compile and work (eg. not crash)?

Yes, it works.

> If so, that's fine to commit, but I'd rather the cc-background-chooser-dialog.c
> ifdef removals were changes to "#if 0" so that the UI isn't actually enabled.

I kept this as a separate commit mainly for the purposes of the review. We can squash it.
Comment 11 Debarshi Ray 2013-09-06 22:46:28 UTC
(In reply to comment #9)
> Review of attachment 254265 [details] [review]:
> 
> Marking as after freeze, I doubt this will go in for 3.10 though you can try
> once the code itself is sorted.

Allan specifically wanted it last week after we realized that gnome-photos is not yet ready for prime time (no import from camera, no search) and we need one other core module to leverage GOA's Flickr support in some way.
Comment 12 Debarshi Ray 2013-09-09 13:32:33 UTC
Created attachment 254479 [details] [review]
background: Remove uses of libsocialweb

Ue #if 0 instead of removing the #ifdefs.
Comment 13 Debarshi Ray 2013-09-09 13:33:38 UTC
Created attachment 254481 [details] [review]
background: Implement the Flickr source using Grilo

Make BgFlickrSource creation fallible using GInitable and move the GOA accounts checking code inside it.
Comment 14 Debarshi Ray 2013-09-09 14:29:42 UTC
Created attachment 254490 [details] [review]
background: Remove uses of libsocialweb

Fix conflicts caused by bug 707602
Comment 15 Rui Matos 2013-09-12 13:40:47 UTC
Review of attachment 254481 [details] [review]:

Showing only a limited number of pictures isn't great. Ideally we would load more on demand as the user scrolls, but for now I guess we need need to somehow let the user know that we are capping the amount of pictures. And perhaps let the user open up gnome-photos or something?

But if we were going to open gnome-photos in the first place this whole Flickr source wouldn't be needed...

I think this needs some more design input. Unfortunately, that will likely push this feature out of 3.10 :-(

::: panels/background/bg-flickr-source.c
@@ +75,3 @@
+          g_warning ("Failed to load image: %s", error->message);
+          goto out;
+        }

If we were cancelled we also want to goto out

@@ +89,3 @@
+                "shading", G_DESKTOP_BACKGROUND_SHADING_SOLID,
+                "source_url", url,
+                NULL);

Don't you also have to set

"flags", CC_BACKGROUND_ITEM_HAS_URI | CC_BACKGROUND_ITEM_HAS_SHADING,

?

@@ +122,3 @@
+          g_free (path);
+          goto out;
+        }

If we were cancelled we also want to goto out

@@ +206,3 @@
+    }
+
+  if (priv->count == 60)

This should at least be a #define.

@@ +325,3 @@
+  error = NULL;
+  if (!grl_registry_load_plugin_by_id (registry, "grl-flickr", &error))
+    g_error ("%s", error->message);

g_error() isn't acceptable IMO.

I think a better approach would be to record that we couldn't initialize the grilo plugin here and then on _inititable_init() error out yielding an invalid BgFlickrSource instance which then allows us to skip adding the Flickr radio button to the UI.

::: panels/background/bg-flickr-source.h
@@ +25,3 @@
 #define _BG_FLICKR_SOURCE_H
 
+#include <glib.h>

Not needed

::: panels/background/cc-background-chooser-dialog.c
@@ +284,3 @@
   priv->pictures_source = bg_pictures_source_new ();
   priv->colors_source = bg_colors_source_new ();
+  priv->flickr_source = bg_flickr_source_new (NULL);

This needs to be cleared in dispose()

@@ +337,3 @@
   g_object_set_data (G_OBJECT (button), "source", priv->colors_source);
 
+  if (priv->flickr_source != NULL)

It can't ever be NULL, right? It might be invalid though, if you agree with my suggestion above
Comment 16 Rui Matos 2013-09-12 13:42:20 UTC
Review of attachment 254490 [details] [review]:

Ok, consider it a-c-n if/when the other patch is accepted
Comment 17 Debarshi Ray 2014-02-11 15:59:32 UTC
After talking to the Allan and others in #gnome-design, the current plan is:
 - to not have a separate view for Flickr because we do not discriminate among local and cloud sources
 - only show the N most recent photos from Flickr
Comment 18 Debarshi Ray 2014-02-11 16:13:59 UTC
Created attachment 268807 [details] [review]
background: Remove uses of libsocialweb and BgFlickrSource
Comment 19 Debarshi Ray 2014-02-12 16:49:00 UTC
Created attachment 268936 [details] [review]
background: Remove redundant and unused parameter from add_single_file
Comment 20 Debarshi Ray 2014-02-12 16:49:33 UTC
Created attachment 268937 [details] [review]
background: Minor clean up
Comment 21 Debarshi Ray 2014-02-12 16:50:44 UTC
Created attachment 268939 [details] [review]
background: Add support for Flickr pictures
Comment 22 Bastien Nocera 2014-02-13 12:19:49 UTC
Review of attachment 268807 [details] [review]:

Looks good.
Comment 23 Bastien Nocera 2014-02-13 12:24:40 UTC
Review of attachment 268936 [details] [review]:

Not quite, it's only needed for "xml" wallpapers, not for all local/native files.

I would always set it instead.
Comment 24 Bastien Nocera 2014-02-13 12:25:58 UTC
Review of attachment 268937 [details] [review]:

Fine.
Comment 25 Bastien Nocera 2014-02-13 12:42:53 UTC
Review of attachment 268939 [details] [review]:

I'd prefer the grilo specific bits be moved in a separate file, which could have a simpler API as well.

For example, an "available" property on that separate object that will trigger adding/removing the remote photos would be good.
Send a signal in that object with the title/url of the item when the account is added/removed (toggled on/off).

::: panels/background/bg-pictures-source.c
@@ +58,3 @@
+
+  GList *accounts;
+  guint count;

count of what?

@@ +341,3 @@
+    }
+
+  /* since we were not cancelled, we can now cast user_data

That's not needed.

@@ +424,2 @@
   item = cc_background_item_new (uri);
+  flags |= CC_BACKGROUND_ITEM_HAS_SHADING;

Why remove the shading flag and still set it below?

@@ +959,3 @@
+  caps = grl_source_get_caps (source, GRL_OP_BROWSE);
+  options = grl_operation_options_new (caps);
+  grl_operation_options_set_flags (options, GRL_RESOLVE_FAST_ONLY);

Add a filter to only get images, and set the number of items at 50 on the search options.
Comment 26 Debarshi Ray 2014-02-13 14:04:06 UTC
Created attachment 269011 [details] [review]
background: Remove redundant and unused parameter from add_single_file
Comment 27 Bastien Nocera 2014-02-13 14:07:32 UTC
Review of attachment 269011 [details] [review]:

Looks good.
Comment 28 Debarshi Ray 2014-02-13 14:14:05 UTC
(In reply to comment #25)
> Review of attachment 268939 [details] [review]:

> For example, an "available" property on that separate object that will trigger
> adding/removing the remote photos would be good.
> Send a signal in that object with the title/url of the item when the account is
> added/removed (toggled on/off).

We can ignore the possibility of the account being toggled while the chooser-dialog is displayed because it is impossible to use the Online Accounts and Background panel simultaneously.

> @@ +424,2 @@
>    item = cc_background_item_new (uri);
> +  flags |= CC_BACKGROUND_ITEM_HAS_SHADING;
> 
> Why remove the shading flag and still set it below?

|= would set the flag, not unset it. Right?
Comment 29 Debarshi Ray 2014-02-13 14:18:14 UTC
Review of attachment 269011 [details] [review]:

I made a mistake.

::: panels/background/bg-pictures-source.c
@@ +336,3 @@
+      needs_download = FALSE;
+      source_uri = g_strdup (uri);
+      flags |= CC_BACKGROUND_ITEM_HAS_URI;

This will break the build. The flags variable leaked in while rebasing from the subsequent patch.

@@ +351,3 @@
 		"placement", G_DESKTOP_BACKGROUND_STYLE_ZOOM,
                 "modified", mtime,
+                "needs-download", needs_download,

This can just be !is_native.
Comment 30 Debarshi Ray 2014-02-13 14:21:30 UTC
Created attachment 269015 [details] [review]
background: Remove redundant and unused parameter from add_single_file

This is better.
Comment 31 Bastien Nocera 2014-02-13 14:25:17 UTC
Review of attachment 269015 [details] [review]:

Looks good
Comment 32 Debarshi Ray 2014-02-13 14:46:34 UTC
Created attachment 269025 [details] [review]
background: Add support for Flickr pictures
Comment 33 Debarshi Ray 2014-02-13 14:57:58 UTC
*** Bug 636869 has been marked as a duplicate of this bug. ***
Comment 34 Debarshi Ray 2014-02-17 09:19:36 UTC
Created attachment 269367 [details] [review]
background: Add CcBackgroundGriloMiner
Comment 35 Debarshi Ray 2014-02-17 09:20:18 UTC
Created attachment 269368 [details] [review]
background: Add support for Flickr pictures
Comment 36 Bastien Nocera 2014-02-17 17:56:31 UTC
Review of attachment 269367 [details] [review]:

Rest looks fine. Just make sure it doesn't blow up if there's a Flickr account configured and the grl-flickr plugin isn't there.

::: panels/background/cc-background-grilo-miner.c
@@ +297,3 @@
+                                       G_TYPE_FROM_CLASS (klass),
+                                       G_SIGNAL_RUN_LAST,
+                                       0,    /* class_offset */

You can remove those comments.

@@ +323,3 @@
+
+void
+cc_background_grilo_miner_start (CcBackgroundGriloMiner *self)

What happens when I call start and the grl-flickr plugin couldn't be loaded?
Comment 37 Bastien Nocera 2014-02-17 18:03:14 UTC
Review of attachment 269368 [details] [review]:

::: configure.ac
@@ +123,3 @@
+                  gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED_VERSION
+                  goa-1.0 >= $GOA_REQUIRED_VERSION
+                  grilo-0.2 >= $GRILO_REQUIRED_VERSION)

You'll need to move the configure.ac changes to the other patch (or the Makefile.am changes to this one) so that the build doesn't break in between the 2 (which might be useful for debugging).

::: panels/background/bg-pictures-source.c
@@ +825,3 @@
+  file = g_file_new_for_uri (uri);
+  g_object_set_data_full (G_OBJECT (file), "grl-media", g_object_ref (media), g_object_unref);
+  g_file_query_info_async (file,

Why do that? The remote HTTP server is unlikely to give us much useful information, and it's a round-trip to the server to find that out.
Comment 38 Debarshi Ray 2014-02-17 18:51:42 UTC
(In reply to comment #36)
> Review of attachment 269367 [details] [review]:
> 
> Rest looks fine. Just make sure it doesn't blow up if there's a Flickr account
> configured and the grl-flickr plugin isn't there.

Yes, I checked.

> ::: panels/background/cc-background-grilo-miner.c
> @@ +297,3 @@
> +                                       G_TYPE_FROM_CLASS (klass),
> +                                       G_SIGNAL_RUN_LAST,
> +                                       0,    /* class_offset */
> 
> You can remove those comments.

Ok.

> @@ +323,3 @@
> +
> +void
> +cc_background_grilo_miner_start (CcBackgroundGriloMiner *self)
> 
> What happens when I call start and the grl-flickr plugin couldn't be loaded?

You get a WARNING on the console that the plugin could not be loaded and query_online_source will never be called leading to no media-found signal being emitted.
Comment 39 Debarshi Ray 2014-02-17 19:05:36 UTC
Created attachment 269455 [details] [review]
background: Add CcBackgroundGriloMiner

Moved the configure.ac changes from the other patch to this one.
Comment 40 Debarshi Ray 2014-02-18 09:10:05 UTC
(In reply to comment #37)
> Review of attachment 269368 [details] [review]:
> 
> ::: configure.ac
> @@ +123,3 @@
> +                  gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED_VERSION
> +                  goa-1.0 >= $GOA_REQUIRED_VERSION
> +                  grilo-0.2 >= $GRILO_REQUIRED_VERSION)
> 
> You'll need to move the configure.ac changes to the other patch (or the
> Makefile.am changes to this one) so that the build doesn't break in between the
> 2 (which might be useful for debugging).

Done. I moved the configure.ac hunk to the other patch.

> ::: panels/background/bg-pictures-source.c
> @@ +825,3 @@
> +  file = g_file_new_for_uri (uri);
> +  g_object_set_data_full (G_OBJECT (file), "grl-media", g_object_ref (media),
> g_object_unref);
> +  g_file_query_info_async (file,
> 
> Why do that? The remote HTTP server is unlikely to give us much useful
> information, and it's a round-trip to the server to find that out.

I was doing it to get the mime type because grl_media_get_mime was coming out as NULL, but you are right. We can work around it using g_content_type_guess on the URI.
Comment 41 Bastien Nocera 2014-02-18 09:12:32 UTC
(In reply to comment #40)
> (In reply to comment #37)
<snip>
> > Why do that? The remote HTTP server is unlikely to give us much useful
> > information, and it's a round-trip to the server to find that out.
> 
> I was doing it to get the mime type because grl_media_get_mime was coming out
> as NULL, but you are right. We can work around it using g_content_type_guess on
> the URI.

Or fix the grilo plugin to set the mime-type?
Comment 42 Debarshi Ray 2014-02-18 09:17:35 UTC
Created attachment 269515 [details] [review]
background: Add support for Flickr pictures
Comment 43 Debarshi Ray 2014-02-18 09:23:36 UTC
Created attachment 269516 [details] [review]
background: Add support for Flickr pictures
Comment 44 Bastien Nocera 2014-02-18 09:36:26 UTC
Review of attachment 269515 [details] [review]:

::: panels/background/bg-pictures-source.c
@@ +530,3 @@
+  /* grl_media_get_mime does not work with the Flickr plugin */
+  uri = g_file_get_uri (file);
+  content_type = g_content_type_guess (uri, NULL, 0, NULL);

Looks good apart from that.
Comment 45 Debarshi Ray 2014-02-18 10:13:14 UTC
Created attachment 269522 [details] [review]
background: Add support for Flickr pictures

Changed it to use grl_media_get_mime on the assumption that we will have a Grilo release with the feature.