GNOME Bugzilla – Bug 437648
[patch] consider global greasemonkey scripts as well
Last modified: 2007-08-07 15:55:09 UTC
Up until now the greasemonkey extension only considers scripts in ~/.gnome2/epiphany/extensions/data/greasemonkey/ It'd be nice to also consider scripts that were globally installed and updated through packages. The patch adds that functionality and reads the global scripts directory from /apps/epiphany/extensions/greasemonkey/global_scripts_directory
Created attachment 87997 [details] [review] consider scripts in a global dir as well
Let's make this a fixed location instead of a pref.
Created attachment 89062 [details] [review] updated patch
if (mkdir_recursive (path) == 0) While you're at it, can you just remove the mkdir_recursive function and just use "if (g_mkdir_with_parents (path, 0700) >= 0)" here? { extension->priv->scripts = load_scripts (path); + global_scripts = load_scripts("/usr/share/epiphany-extensions/greasemonkey/scripts"); + g_hash_table_foreach(global_scripts, + (*ephy_greasemonkey_quick_hash_add), + extension->priv->scripts); This shouldn't be in the "if (mkdir....)" branch, since it's independent of the user dir. Please move the hashtable creation out of load_scripts() into ephy_greasemonkey_extension_init, and just make load_scripts add the scripts to that hashtable. (The code above leaked the created hash table!) Do we want to monitor the system dir too, or is it enough to load the scripts only at startup?
Created attachment 91664 [details] [review] new patch new patch - let me know if this is what you intended it to be.
+ for (dir = 0; dir <= sizeof(dirs); dir++) Use G_N_ELEMENTS instead od sizeof() here. + if (g_mkdir_with_parents (path, 0700) >= 0) I think you need to set errno = 0 before this call, and add "|| errno == EEXIST" to the check. With those fixed and tested, ok to commit. Thanks for the patch!
Created attachment 91666 [details] [review] using errno and G_N_ELEMENTS
+ for (dir = 0; dir <= G_N_ELEMENTS(dirs); dir++) You need "<" not "<=".
I've commited the change with the modification to trunk for Daniel since he has no SVN access at the moment to do it * extensions/greasemonkey/ephy-greasemonkey-extension.c: (load_scripts), (ephy_greasemonkey_extension_init): commit change from Daniel Holbach <dholbach@ubuntu.com> to "add a global greasmonkey directory" (#437648)
Created attachment 92905 [details] [review] don't break when the directory is not created The change breaks user scripts when the system directory doesn't exit, continuing instead of returning when a directory doesn't exit make it work correctly
2007-08-07 Sebastien Bacher <seb128@ubuntu.com> * extensions/greasemonkey/ephy-greasemonkey-extension.c: (load_scripts): don't break when the directory is not created (Closes: #437648)