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 437648 - [patch] consider global greasemonkey scripts as well
[patch] consider global greasemonkey scripts as well
Status: RESOLVED FIXED
Product: epiphany-extensions
Classification: Deprecated
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: epiphany-extensions-maint
epiphany-extensions-maint
Depends on:
Blocks:
 
 
Reported: 2007-05-11 08:51 UTC by Daniel Holbach
Modified: 2007-08-07 15:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
consider scripts in a global dir as well (4.25 KB, patch)
2007-05-11 08:52 UTC, Daniel Holbach
reviewed Details | Review
updated patch (1.06 KB, patch)
2007-05-30 19:03 UTC, Daniel Holbach
needs-work Details | Review
new patch (2.66 KB, patch)
2007-07-12 10:28 UTC, Daniel Holbach
reviewed Details | Review
using errno and G_N_ELEMENTS (3.03 KB, patch)
2007-07-12 11:28 UTC, Daniel Holbach
committed Details | Review
don't break when the directory is not created (573 bytes, patch)
2007-08-02 10:13 UTC, Sebastien Bacher
committed Details | Review

Description Daniel Holbach 2007-05-11 08:51:28 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
Comment 1 Daniel Holbach 2007-05-11 08:52:16 UTC
Created attachment 87997 [details] [review]
consider scripts in a global dir as well
Comment 2 Christian Persch 2007-05-30 18:38:26 UTC
Let's make this a fixed location instead of a pref.
Comment 3 Daniel Holbach 2007-05-30 19:03:50 UTC
Created attachment 89062 [details] [review]
updated patch
Comment 4 Christian Persch 2007-06-28 13:25:31 UTC
 	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?
Comment 5 Daniel Holbach 2007-07-12 10:28:04 UTC
Created attachment 91664 [details] [review]
new patch

new patch - let me know if this is what you intended it to be.
Comment 6 Christian Persch 2007-07-12 10:49:13 UTC
+	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!
Comment 7 Daniel Holbach 2007-07-12 11:28:48 UTC
Created attachment 91666 [details] [review]
using errno and G_N_ELEMENTS
Comment 8 Christian Persch 2007-07-12 11:31:22 UTC
+	for (dir = 0; dir <= G_N_ELEMENTS(dirs); dir++)

You need "<" not "<=".
Comment 9 Sebastien Bacher 2007-07-12 12:27:11 UTC
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)
Comment 10 Sebastien Bacher 2007-08-02 10:13:12 UTC
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
Comment 11 Sebastien Bacher 2007-08-07 15:55:09 UTC
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)