My favorites | Sign in
Project Logo
Project hosting will be READ-ONLY Wednesday at 8am PST due to brief network maintenance.
                
New issue | Search
for
| Advanced search | Search tips
Issue 96: Fix Deskbar-Applet bug #452205: Deskbar does not notice when preferred browser changed for web searches
2 people starred this issue and may be notified of changes. Back to list
Status:  Completed
Owner:  itssebp
Closed:  Jan 2008
Code
ClaimedBy-aantny


Sign in to add a comment
 
Reported by itssebp, Jan 10, 2008
Task title: Deskbar does not notice when preferred browser changed for web
searches

Benefits: Adding this feature, the user can change his preferred browser
from firefox to epiphany or wise versa and Deskbar will automatically
activate the correct modules if applicable.

Requirements:
* Python skills
* Latest Deskbar-Applet version from the subversion repository.

Task description:

The default browser is stored in the GConf key
"/desktop/gnome/url-handlers/http/command". When the value changes
you have to check if the new value represents a mozilla based browser or
epiphany. When one or more modules of the mozilla/epiphany modules are
enabled, disable them and activate the modules belonging to the new browser.

You can monitor GConf keys for changes (see deskbar.core.GConfStore for
examples). Modules are stored in deskbar.core.ModuleList. Disabling modules
works with deskbar.core.ModuleLoader class. Instances of both classes can
be accessed from deskbar.core.CoreImpl.

Please attach the patch to the bugzilla entry.

Links:
* http://bugzilla.gnome.org/show_bug.cgi?id=452205
* http://svn.gnome.org/svn/deskbar-applet/trunk

Estimated time: Three days

Primary contact: Sebastian Pölsterl (marduk <at> k-d-w <dot> org, sebp in
#deskbar on irc.gimp.net)
 
Comment 1 by andre.klapper, Jan 10, 2008
(No comment was entered for this change.)
Status: Open
Comment 2 by aantny, Jan 10, 2008
Do to technical difficulties, I unclaim the sound-juicer task and claim this one.
Comment 3 by andre.klapper, Jan 10, 2008
(No comment was entered for this change.)
Status: Claimed
Labels: ClaimedBy-aantny
Comment 4 by aantny, Jan 11, 2008
Sebp:
I'm running into a slight difficulty. I can use
ModuleList.get_module_instance_from_name() for enabled modules, but
DisabledModuleList has no correspounding function. I've attached the diff file so
that you can see what I'm trying to do.
browser.diff
4.8 KB   Download
Comment 5 by itssebp, Jan 12, 2008
I see. I have to think about it. I let you now when I came up with a solution.
Comment 6 by aantny, Jan 12, 2008
Sebp,
The disabled modules don't have a get_filename method because they aren't truely
loaded like the other modules are.
Comment 7 by aantny, Jan 12, 2008
Ignore my last comment because its wrong.

The problem is that the DisableModulesList class keeps track of the classes of
disabled modules but not the module's themselves. In order to reload the modules we
need the module's file name.

You can usually get the file name from the module's __file__ attribute, but we can't
do that because we only have access to the classes in the files. The classes have a
built it __class__ attribute, but its a string and *not* a reference to the actual
class, so that doesn't help us.

There are two possible solutions and both are somewhat hackish. Both of them work by
saving the modules's filename in DisabledModuleList.

The first solution would be to add on an extra parameter to the
module-not-initialized signal containing the module's file name. We would then save
the file name in a new column in DisabledModuleList.

The second way is a bit more hackish, but its *much* simpler. We simply add on a new
attribute to the class before we emit the signal. It would look something like this.

def import_module(self, filename):
...
   module.filename = filename
   self.emit("module-not-initialized", module)

I know that the explanation isn't so clear... I'll post code soon showing what I mean.
Comment 8 by aantny, Jan 12, 2008
The code I've attached should do the job. Its a bit hackish, but look it over and
tell me what you think. 

One problem with it is that the preferences window still shows the old modules. I
think I know what the problem is, but I'm too tired to fix it now.

Btw, the Epiphany Web History module is missing a requirments method.
browsers.diff
5.7 KB   Download
Comment 9 by aantny, Jan 12, 2008
Patch attached.
browsers.diff
7.3 KB   Download
Comment 10 by aantny, Jan 13, 2008
Patch attached. It fixes several small bugs.
browsers.diff
8.1 KB   Download
Comment 11 by itssebp, Jan 13, 2008
I reviewed you patch. I encountered two issues:
* When the new browser is neither firefox nor epiphany you should disable the web modules
* Instead of module.stop() and module.set_enabled(False) you should use
CoreImpl.stop_module
Comment 12 by aantny, Jan 13, 2008
Some of the functions in ModuleList seem to be broken. I'm getting the following
traceback when using CoreImpl.Stop:
Traceback (most recent call last):
  File "/home/natan/deskbar-trunk/deskbar/core/ModuleList.py", line 139, in
module_toggled_cb
    self[self.get_position_from_context(module)[0]][self.ENABLED_COL] =
module.is_enabled()
TypeError: could not parse subscript as a tree path

Comment 13 by aantny, Jan 14, 2008
Patch attached. I've fixed everything up. I'm not using CoreImpl.stop_module()
because it seems to be broken.
browsers.diff
8.5 KB   Download
Comment 14 by itssebp, Jan 15, 2008
You still have the problem that the new list of enabled modules isn't written to
GConf. I think best is to move DeskbarPreferences.update_gconf to CoreImpl class and
use it their to update the list. You might not need to disable the modules manually
then, too. In addition, I think you should add to
CoreImpl._on_enabled_modules_changed that newly added modules will be loaded.
Obviously, there's unfinished work in this method.

I tried to find the error when using CoreImpl.stop_module. Nevertheless, you should
use both CoreImpl.initialize_module and CoreImpl.stop_module. Duplicate code is a bad
thing.

To sum up it should work when you change CoreImpl._on_enabled_modules_changed that it
initializes new modules and if you only call CoreImpl.stop_module and
CoreImpl.initialize_module in _on_default_browser_changed method. Have a look at
DeskbarPreferences, too, how it handles enabling and disabling modules.

I'm sorry these issues didn't came to mind before. If you think it's too much work
now, you can resign from this task.
Comment 15 by aantny, Jan 15, 2008
I'm definitly up to the task, and I don't mind the extra work. Besides, there aren't
very many open tasks at the moment, so its definitly better than working on nothing.

I'll post later if I have any questions.
Comment 16 by aantny, Jan 16, 2008
I found the problem with CoreImpl.stop_module. The modules were being stopped
asyncrously and the code in _on_default_browser_changed assumed that they would be
stopped immediately. I'm now using async=False, and I don't think that the time delay
is significant enough to be of concern. The function should be called very rarely,
and when it is called a maximum of three modules are stopped.

I moved DeskbarPreferences.update_gconf to CoreImpl, but we still need disable the
modules manually. update_gconf only toggles a module's enabled status, but we also
need to move the disabled modules into DisabledModuleList which is for modules with
errors.

I made the other changes that you suggested and the patch is attached. It should be
in finished form, but I'll make any other changes that you think are necessary.
browsers.diff
11.5 KB   Download
Comment 17 by itssebp, Jan 16, 2008
It works like a charm now. Thanks a lot for your awesome work.

I have another small issue, it's not important, therefore you don't have to fix it,
you already completed the task. When you change the default browser when Deskbar is
not running it will not change the web modules. I don't know if it's possible that it
does, when starting Deskbar again. As I mentioned before, I think most users won't
come across this issue.

I'm going to commit your patch tomorrow. Thanks a lot for all your work.
Comment 18 by aantny, Jan 17, 2008
No problem. I wouldn't mind taking another task for deskbar, if you write another one up.

I think the simplest way to fix that issue would be to add on another method to the
api called "alternatives" or something like that. We would call the method whenever a
module's requirments method returns false.

I'm not sure whether that's very practical or not. I can't think of that many other
cases where it would be useful.

Anyway, can someone please mark this task as completed?
Comment 19 by itssebp, Jan 17, 2008
(No comment was entered for this change.)
Status: Completed
Comment 20 by aantny, Feb 05, 2008
Hello Sebp,
I'm leaving this comment here because I'm not sure how else I should contact you. ;)

I'm doing some work on creating a universal applet format, and I think it would
pretty neat if we could get some kind of integration with the deskbar. There's an
overview of the reasons for this here: http://theesylum.com/2008/02/01/desktop-20/

Tell me what you think.
Sign in to add a comment

Hosted by Google Code