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 696948 - Update extensions directly from the UI
Update extensions directly from the UI
Status: RESOLVED FIXED
Product: gnome-tweak-tool
Classification: Applications
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GNOME Tweak Tool maintainer(s)
GNOME Tweak Tool maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-03-31 05:24 UTC by Alex Muñoz
Modified: 2013-09-10 08:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Allow updating extensions (5.33 KB, patch)
2013-03-31 05:27 UTC, Alex Muñoz
rejected Details | Review
Allow updating extensions (7.01 KB, patch)
2013-04-01 04:16 UTC, Alex Muñoz
rejected Details | Review
Allow updating extensions (9.25 KB, patch)
2013-04-08 02:37 UTC, Alex Muñoz
needs-work Details | Review
Allow updating extensions (9.54 KB, patch)
2013-04-10 05:48 UTC, Alex Muñoz
committed Details | Review

Description Alex Muñoz 2013-03-31 05:24:43 UTC
The extensions should be updated directly from the UI
Comment 1 Alex Muñoz 2013-03-31 05:27:21 UTC
Created attachment 240189 [details] [review]
Allow updating extensions
Comment 2 John Stowers 2013-03-31 08:48:25 UTC
Please use the egowrapper.py here. I want to keep this conceptually separate to the rest of the code in case the web api changes, etc.

https://github.com/nzjrs/gnome-tweak-tool/blob/ego/gtweak/egowrapper.py
Comment 3 John Stowers 2013-03-31 08:48:48 UTC
Review of attachment 240189 [details] [review]:

sorry
Comment 4 Alex Muñoz 2013-04-01 04:16:59 UTC
Created attachment 240277 [details] [review]
Allow updating extensions
Comment 5 John Stowers 2013-04-01 06:14:15 UTC
Review of attachment 240277 [details] [review]:

Please import egowrapper as it was in the ego branch. Add a second parameter (the uuid) to the got-extension-info signal.

create one ego instance in the ShellExtensionTweakGroup object (so that the number of simultaneous connections to e.g.o is limited by the SoupSessionAsync object. We don't want to denial-of-service the website). Then do something like the following (in each tweak, or in the tweak group)

egowrapper.connect("got-extension-info" self._got_info)

def got_info(self, uuid, info):
    if uuid == self.this_tweak_uuid:
       if there is some upgrade by looking at info:
           self._add_upgrade_button()

::: gtweak/egowrapper.py
@@ +34,3 @@
+        self._extension = extension
+        self._widget = widget
+        self._button = button

Buttons and ui objects should not belong here, use something closer to the egowrapper in my branch.

::: gtweak/tweaks/tweak_shell_extensions.py
@@ +112,3 @@
+        stream = Gio.File.new_for_uri(url)
+        stream.load_contents_async(None, self.download_file_complete, uuid)
+        self.widget.remove(btn)

Shouldn't you just call the update dbus method on the gnome shell object?

@@ +116,3 @@
+    def download_file_complete(self, extension_file, res, uuid):
+        content = extension_file.load_contents_finish(res)[1]
+        stream = Gio.File.new_for_uri(url)

This is the sort of code I wan't left in the egowrapper object. Just use my copy from the ego branch.

@@ +154,3 @@
+            f = chooser
+        else:
+            f = chooser.get_filename()

Don't know why this is here

@@ +214,3 @@
         #set button back to default state
+        if type(chooser) != str:
+            chooser.unselect_all()

Don't know why this is here
Comment 6 Alex Muñoz 2013-04-08 02:37:05 UTC
Created attachment 240918 [details] [review]
Allow updating extensions
Comment 7 John Stowers 2013-04-08 20:23:53 UTC
Review of attachment 240918 [details] [review]:

Almost there, great work.

::: gtweak/tweaks/tweak_shell_extensions.py
@@ +108,3 @@
+        self.widget.set_sensitive(False)
+        thread = threading.Thread(target=self.download_extension, args=(btn,uuid,))
+        thread.start()

Hmm, it is annoying that you need to use a thread here.... I presume this is because install_remote_extension blocks?

@@ +114,3 @@
+        if status == 's':
+            self.widget.remove(btn)
+        thread.start()

This is being run from the non_main thread, and is unsafe. I'm surprised it didnt crash here. GObject.threads_init() doesnt prevent this.

You should do this

if status == 's':
    GObject.idle_add(lambda x: s.set_sensitive(True), widget)

that way the Gtk call is made in the gtk thread.

Don't bother removing the button, just change the sensitivity.

@@ +122,3 @@
+        self.widget.reorder_child(button, 1)
+        if self.widget.get_visible() == True:
+        if status == 's':

OK, although you should add a comment saying why you need to test visibility here (in case the user has gone to a different section?)
Comment 8 Alex Muñoz 2013-04-10 05:45:35 UTC
(In reply to comment #7)
> Review of attachment 240918 [details] [review]:
> 
> Almost there, great work.
> 
> ::: gtweak/tweaks/tweak_shell_extensions.py
> @@ +108,3 @@
> +        self.widget.set_sensitive(False)
> +        thread = threading.Thread(target=self.download_extension,
> args=(btn,uuid,))
> +        thread.start()
> 
> Hmm, it is annoying that you need to use a thread here.... I presume this is
> because install_remote_extension blocks?

Yes, when I call to the install remote extension directly from the main thread, the UI freezes while downloads the extension.

> @@ +114,3 @@
> +        if status == 's':
> +            self.widget.remove(btn)
> +        thread.start()
> 
> This is being run from the non_main thread, and is unsafe. I'm surprised it
> didnt crash here. GObject.threads_init() doesnt prevent this.
> 
> You should do this
> 
> if status == 's':
>     GObject.idle_add(lambda x: s.set_sensitive(True), widget)
> 
> that way the Gtk call is made in the gtk thread.
> 
> Don't bother removing the button, just change the sensitivity.
> 
> @@ +122,3 @@
> +        self.widget.reorder_child(button, 1)
> +        if self.widget.get_visible() == True:
> +        if status == 's':
> 
> OK, although you should add a comment saying why you need to test visibility
> here (in case the user has gone to a different section?)
Comment 9 Alex Muñoz 2013-04-10 05:48:21 UTC
Created attachment 241114 [details] [review]
Allow updating extensions
Comment 10 John Stowers 2013-04-15 20:15:10 UTC
Attachment 241114 [details] pushed as 08f8cda - Allow updating extensions
Comment 11 Owen Taylor 2013-05-09 03:48:20 UTC
The use of threading here is entirely unnecessary, and probably harmful - http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html describes passing reply_handler in when calling a D-Bus method to make it async.
Comment 12 John Stowers 2013-06-09 08:10:27 UTC
Reopening for Alex to fix add per Owens suggestion
Comment 13 John Stowers 2013-07-17 19:34:01 UTC
Alex, ping?
Comment 14 John Stowers 2013-09-10 08:20:00 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.