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 165568 - Support global lockdown keys
Support global lockdown keys
Status: RESOLVED FIXED
Product: gedit
Classification: Applications
Component: general
unspecified
Other All
: High major
: ---
Assigned To: Gedit maintainers
Gedit maintainers
: 341860 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-01-29 01:15 UTC by spark
Modified: 2006-06-15 14:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch against CVS HEAD (v. 1) (19.80 KB, patch)
2005-02-01 17:52 UTC, Paolo Maggi
none Details | Review
lockdown patch (34.29 KB, patch)
2006-05-30 16:28 UTC, Steve Frécinaux
none Details | Review
part 1 of the patch (17.80 KB, patch)
2006-06-11 14:18 UTC, Steve Frécinaux
committed Details | Review
part 2 of the patch (17.79 KB, patch)
2006-06-12 14:33 UTC, Steve Frécinaux
committed Details | Review

Description spark 2005-01-29 01:15:10 UTC
Currently, gedit doesn't seem to honour the global lockdown keys
disable_printing, disable_print_setup or disable_save_to_disk.
Comment 1 Paolo Maggi 2005-01-29 10:18:27 UTC
I didn't know about these global lockdown keys.
Where can I find more info about them?
Comment 2 spark 2005-01-29 14:37:53 UTC
Paolo, theres some discussion of lockdown in the desktop-devel thread starting at:
http://mail.gnome.org/archives/desktop-devel-list/2003-September/msg00594.html

Google throws up
http://primates.ximian.com/~clahey/epiphany-disable-printing.patch as the patch
for Epiphany to support printing lockdown. Epiphany also supports the other
global keys, and has it's own as well.

Hope this helps.
Comment 3 Paolo Maggi 2005-02-01 14:17:28 UTC
We should also support disable_command_line in the shell_output plugin.

The keys are in "/desktop/gnome/lockdown/"
Comment 4 Paolo Maggi 2005-02-01 17:52:25 UTC
Created attachment 36831 [details] [review]
Patch against CVS HEAD (v. 1)

The attached patch should add support for all the 4 global lockdown keys.
I'm not sure we can include it for gnome 2.10 since we are quite late in the
development cycle and the patch introduces some UI and string changes.
Even if I have already tested the patch and I'm quite confident about its
quality, in order to prevent unexpected side effects, I'd prefer to punt it and
commit it on CVS HEAD as soon as gedit 2.10.0 will be released.
Comment 5 Paolo Maggi 2005-02-02 15:47:16 UTC
My patches does not disable autosave, I need to fix it before committing.
Comment 6 Paolo Maggi 2005-08-23 16:17:40 UTC
Sigh... I have to punt this bug again, it is already too late in the development
cycle. 
Comment 7 Paolo Borelli 2006-05-15 14:23:09 UTC
*** Bug 341860 has been marked as a duplicate of this bug. ***
Comment 8 Steve Frécinaux 2006-05-30 16:28:43 UTC
Created attachment 66476 [details] [review]
lockdown patch

This patch uses a GeditApp property to track the lockdown state.
Comment 9 Steve Frécinaux 2006-06-07 13:29:12 UTC
Paolo, could you please have a look at the patch ? thanks.
Comment 10 Paolo Maggi 2006-06-11 11:46:40 UTC
Comment on attachment 66476 [details] [review]
lockdown patch

I think we can commit this patch in an incremetal way.

We can start committing the GeditApp e GeditPrefsManager part.

Here my comments on that part.

> struct _GeditAppPrivate
> {
>-	GList	    *windows;
>-	GeditWindow *active_window;
>+	GList	         *windows;
>+	GeditWindow      *active_window;
>+	guint		  lockdown;
> }

In order to improve code readability please use GeditLockdownMask instead of guint.

>+guint
>+gedit_app_get_lockdown (GeditApp *app)
>+{
>+	g_return_val_if_fail (GEDIT_IS_APP (app), FALSE);

Return "0" or better "all lockdown" since it is safer.

> 
> /*
>+ * Lockdown mask definition
>+ */
>+typedef enum
>+{
>+	GEDIT_LOCKDOWN_COMMAND_LINE	= 1 << 1,

It should start from "1 << 0"

> 
>+/* Lockdown state */
>+guint		 gedit_app_get_lockdown			(GeditApp *app);
>+
> /*
>  * Non exported functions
>  */
>@@ -101,6 +115,12 @@ GeditWindow	*_gedit_app_restore_window		
> GeditWindow	*_gedit_app_get_window_in_workspace	(GeditApp  *app,
> 							 GdkScreen *screen,
> 							 gint       workspace);
>+void		 _gedit_app_set_lockdown		(GeditApp *app,
>+							 guint     lockdown);
>+void		 _gedit_app_set_lockdown_bit		(GeditApp          *app,
>+							 GeditLockdownMask  bit,
>+							 gboolean           value);
>+

Use GeditLockdownMask instead of guint.
 
>+
>+/* Global Lockdown */
>+guint
>+gedit_prefs_manager_get_lockdown (void)

Use GeditLockdownMask instead of guint.

>+
>+/* Global lockdown */
>+guint			 gedit_prefs_manager_get_lockdown			(void);

Ditto.


I have also a general comment about the patch.

It introduces a new way for managing "global" preferences.
I think the new way is more elegant than the current one but at the same way I'm a bit worried about it since it breaks code consistency. 
May be we should start using the same approach for future changes.

BTW, please commit the first part of the patch.

I will review the second part later.

Note that we should also disable the External Tool plugin if "disable_command_line" is true.
Comment 11 Steve Frécinaux 2006-06-11 11:57:06 UTC
(In reply to comment #10)

> In order to improve code readability please use GeditLockdownMask instead of
> guint.

I used guint because it was what gtk+ did (I took GtkWidget as an example) and I was not sure the compiler would allow a combination of several enum values. But I can make the change, it would slightly improve the readability.

> Note that we should also disable the External Tool plugin if
> "disable_command_line" is true.

I did also do a patch for the Terminal plugin (from gedit-plugins). Anyway the rationale we ended with was that the manager of a locked down box could just not install these sensible plugins. What is your opinion about that ?

Comment 12 Steve Frécinaux 2006-06-11 11:59:20 UTC
Note that commiting this part will also need the commit of the glib-mkenum part, since it's required when registering the property.
Comment 13 Paolo Maggi 2006-06-11 12:40:11 UTC
Sure, I mean we can commit the non-UI related part of the work (GeditApp, Prefs and mkenum stuff).

Looking at gedit-tab.c patch it seems you do not manage changes to the lockdown state after tab initialization.
Comment 14 Paolo Maggi 2006-06-11 13:19:19 UTC
I think we should try to minimize application specific configuration changes to create a lookdown environment.
So I think we should disable the features in the plugins and don't ask the administrator to uninstall specific plugins.
Comment 15 Steve Frécinaux 2006-06-11 14:18:20 UTC
Created attachment 67126 [details] [review]
part 1 of the patch

I've comitted the first part of the patch.

2006-06-11  Steve Frécinaux  <steve@istique.net>

	Fix for bug #165568 – Support global lockdown keys (first part)

	* gedit/gedit-app.[ch]: define GeditLockdownMask as a flag type, add a 
	'lockdown' property to GeditApp, of type GeditLockdownMask, and define
	its getter/setter.
	
	* gedit/gedit-prefs-manager.[ch]: define a new helper function
	gedit_prefs_manager_get_lockdown.
	
	* gedit/gedit-prefs-manager-app.c: Listen to lockdown GConf folder
	changes. Update GeditApp's lockdown properties when a lockdown key is
	changed.
	
	* gedit/gedit-enum-types.h.template:
	* gedit/gedit-enum-types.c.template:
	* gedit/Makefile.am:
	
	Autogenerate type definitions for exported enums using glib-mkenums.

	* configure.ac: add GLIB_MKENUMS definition.
Comment 16 jessevdk@gmail.com 2006-06-11 15:42:10 UTC
You would also need to disable shell and python snippets.
Comment 17 Steve Frécinaux 2006-06-12 14:33:13 UTC
Created attachment 67188 [details] [review]
part 2 of the patch

This is the second part of the patch, which is related to the UI.

The autosave status update has been fixed, and s/guint/GeditLockdownMask where needed.
Comment 18 Steve Frécinaux 2006-06-13 19:06:39 UTC
pbor quickly reviewed the patch and said it looks ok, so I'll commit this last patch thursday...
Comment 19 Steve Frécinaux 2006-06-15 14:11:46 UTC
comitted in HEAD.

2006-06-15  Steve Frécinaux  <steve@istique.net>

	Fix for bug #165568 – Support global lockdown keys (second part)

	* gedit/gedit-window.c: disable some menu entries according the current 
	lockdown state; listen to app's lockdown property changes to update the
	menus sensitivity and autosave status accordingly.
	
	* gedit/gedit-ui.h: move FilePageSetup from always sensitive actions.

	* gedit/gedit-tab.c: do not enable autosave if save_to_disk is disabled.
	
	* gedit/dialogs/gedit-close-confirmation-dialog.c: adapt the dialog to
	the case save_to_disk is disabled.