Removed lockdown support (tied with MATE)

This commit is contained in:
Clement Lefebvre 2016-01-25 16:47:40 +00:00
parent f8e40ce128
commit 8da17d74e8
11 changed files with 47 additions and 342 deletions

View File

@ -3,14 +3,12 @@
XeditAppPrivate XeditAppPrivate
<TITLE>XeditApp</TITLE> <TITLE>XeditApp</TITLE>
XeditApp XeditApp
XeditLockdownMask
xedit_app_get_default xedit_app_get_default
xedit_app_create_window xedit_app_create_window
xedit_app_get_windows xedit_app_get_windows
xedit_app_get_active_window xedit_app_get_active_window
xedit_app_get_documents xedit_app_get_documents
xedit_app_get_views xedit_app_get_views
xedit_app_get_lockdown
<SUBSECTION Standard> <SUBSECTION Standard>
XEDIT_APP XEDIT_APP
XEDIT_IS_APP XEDIT_IS_APP
@ -579,11 +577,6 @@ GPM_SHOWN_IN_MENU_ENCODINGS
GPM_SYNTAX_HL_DIR GPM_SYNTAX_HL_DIR
GPM_SYNTAX_HL_ENABLE GPM_SYNTAX_HL_ENABLE
GPM_WRITABLE_VFS_SCHEMES GPM_WRITABLE_VFS_SCHEMES
GPM_LOCKDOWN_DIR
GPM_LOCKDOWN_COMMAND_LINE
GPM_LOCKDOWN_PRINTING
GPM_LOCKDOWN_PRINT_SETUP
GPM_LOCKDOWN_SAVE_TO_DISK
GPM_DEFAULT_USE_DEFAULT_FONT GPM_DEFAULT_USE_DEFAULT_FONT
GPM_DEFAULT_EDITOR_FONT GPM_DEFAULT_EDITOR_FONT
GPM_DEFAULT_USE_DEFAULT_COLORS GPM_DEFAULT_USE_DEFAULT_COLORS
@ -750,7 +743,6 @@ xedit_prefs_manager_get_restore_cursor_position
xedit_prefs_manager_get_enable_search_highlighting xedit_prefs_manager_get_enable_search_highlighting
xedit_prefs_manager_set_enable_search_highlighting xedit_prefs_manager_set_enable_search_highlighting
xedit_prefs_manager_enable_search_highlighting_can_set xedit_prefs_manager_enable_search_highlighting_can_set
xedit_prefs_manager_get_lockdown
</SECTION> </SECTION>
<SECTION> <SECTION>
@ -789,8 +781,6 @@ xedit_utils_format_uri_for_display
<SECTION> <SECTION>
<FILE>xedit-enum-types</FILE> <FILE>xedit-enum-types</FILE>
XEDIT_TYPE_LOCKDOWN_MASK
xedit_lockdown_mask_get_type
XEDIT_TYPE_CONVERT_ERROR XEDIT_TYPE_CONVERT_ERROR
xedit_convert_error_get_type xedit_convert_error_get_type
XEDIT_TYPE_DEBUG_SECTION XEDIT_TYPE_DEBUG_SECTION

View File

@ -79,19 +79,6 @@
;; Enumerations and flags ... ;; Enumerations and flags ...
(define-flags LockdownMask
(in-module "Xedit")
(c-name "XeditLockdownMask")
(gtype-id "XEDIT_TYPE_LOCKDOWN_MASK")
(values
'("command-line" "XEDIT_LOCKDOWN_COMMAND_LINE")
'("printing" "XEDIT_LOCKDOWN_PRINTING")
'("print-setup" "XEDIT_LOCKDOWN_PRINT_SETUP")
'("save-to-disk" "XEDIT_LOCKDOWN_SAVE_TO_DISK")
'("all" "XEDIT_LOCKDOWN_ALL")
)
)
(define-flags SearchFlags (define-flags SearchFlags
(in-module "Xedit") (in-module "Xedit")
(c-name "XeditSearchFlags") (c-name "XeditSearchFlags")
@ -223,12 +210,6 @@
(return-type "GList*") (return-type "GList*")
) )
(define-method get_lockdown
(of-object "XeditApp")
(c-name "xedit_app_get_lockdown")
(return-type "XeditLockdownMask")
)
;; From ../../xedit/xedit-document.h ;; From ../../xedit/xedit-document.h

View File

@ -74,7 +74,6 @@ struct _XeditCloseConfirmationDialogPrivate
GtkTreeModel *list_store; GtkTreeModel *list_store;
gboolean disable_save_to_disk;
}; };
#define XEDIT_CLOSE_CONFIRMATION_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ #define XEDIT_CLOSE_CONFIRMATION_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
@ -160,33 +159,26 @@ set_logout_mode (XeditCloseConfirmationDialog *dlg,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
} }
if (dlg->priv->disable_save_to_disk)
const gchar *stock_id = GTK_STOCK_SAVE;
if (GET_MODE (dlg->priv) == SINGLE_DOC_MODE)
{ {
gtk_dialog_set_default_response (GTK_DIALOG (dlg), XeditDocument *doc;
GTK_RESPONSE_NO);
doc = XEDIT_DOCUMENT (dlg->priv->unsaved_documents->data);
if (xedit_document_get_readonly (doc) ||
xedit_document_is_untitled (doc))
stock_id = GTK_STOCK_SAVE_AS;
} }
else
{
const gchar *stock_id = GTK_STOCK_SAVE;
if (GET_MODE (dlg->priv) == SINGLE_DOC_MODE) gtk_dialog_add_button (GTK_DIALOG (dlg),
{ stock_id,
XeditDocument *doc; GTK_RESPONSE_YES);
doc = XEDIT_DOCUMENT (dlg->priv->unsaved_documents->data); gtk_dialog_set_default_response (GTK_DIALOG (dlg),
GTK_RESPONSE_YES);
if (xedit_document_get_readonly (doc) ||
xedit_document_is_untitled (doc))
stock_id = GTK_STOCK_SAVE_AS;
}
gtk_dialog_add_button (GTK_DIALOG (dlg),
stock_id,
GTK_RESPONSE_YES);
gtk_dialog_set_default_response (GTK_DIALOG (dlg),
GTK_RESPONSE_YES);
}
} }
static void static void
@ -196,10 +188,6 @@ xedit_close_confirmation_dialog_init (XeditCloseConfirmationDialog *dlg)
dlg->priv = XEDIT_CLOSE_CONFIRMATION_DIALOG_GET_PRIVATE (dlg); dlg->priv = XEDIT_CLOSE_CONFIRMATION_DIALOG_GET_PRIVATE (dlg);
dlg->priv->disable_save_to_disk =
xedit_app_get_lockdown (xedit_app_get_default ())
& XEDIT_LOCKDOWN_SAVE_TO_DISK;
gtk_container_set_border_width (GTK_CONTAINER (dlg), 5); gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
14); 14);
@ -530,16 +518,7 @@ build_single_doc_dialog (XeditCloseConfirmationDialog *dlg)
doc_name = xedit_document_get_short_name_for_display (doc); doc_name = xedit_document_get_short_name_for_display (doc);
if (dlg->priv->disable_save_to_disk) str = g_markup_printf_escaped (_("Save changes to document \"%s\" before closing?"), doc_name);
{
str = g_markup_printf_escaped (_("Changes to document \"%s\" will be permanently lost."),
doc_name);
}
else
{
str = g_markup_printf_escaped (_("Save changes to document \"%s\" before closing?"),
doc_name);
}
g_free (doc_name); g_free (doc_name);
@ -550,10 +529,7 @@ build_single_doc_dialog (XeditCloseConfirmationDialog *dlg)
g_free (markup_str); g_free (markup_str);
/* Secondary label */ /* Secondary label */
if (dlg->priv->disable_save_to_disk) str = get_text_secondary_label (doc);
str = g_strdup (_("Saving has been disabled by the system administrator."));
else
str = get_text_secondary_label (doc);
secondary_label = gtk_label_new (str); secondary_label = gtk_label_new (str);
g_free (str); g_free (str);
gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
@ -656,19 +632,17 @@ create_treeview (XeditCloseConfirmationDialogPrivate *priv)
priv->list_store = GTK_TREE_MODEL (store); priv->list_store = GTK_TREE_MODEL (store);
/* Add columns */ /* Add columns */
if (!priv->disable_save_to_disk)
{
renderer = gtk_cell_renderer_toggle_new ();
g_signal_connect (renderer, "toggled",
G_CALLBACK (save_toggled), store);
column = gtk_tree_view_column_new_with_attributes ("Save?", renderer = gtk_cell_renderer_toggle_new ();
renderer, g_signal_connect (renderer, "toggled",
"active", G_CALLBACK (save_toggled), store);
SAVE_COLUMN,
NULL); column = gtk_tree_view_column_new_with_attributes ("Save?",
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); renderer,
} "active",
SAVE_COLUMN,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
renderer = gtk_cell_renderer_text_new (); renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Name", column = gtk_tree_view_column_new_with_attributes ("Name",
@ -734,20 +708,13 @@ build_multiple_docs_dialog (XeditCloseConfirmationDialog *dlg)
#endif #endif
gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE); gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
if (priv->disable_save_to_disk) str = g_strdup_printf (
str = g_strdup_printf ( ngettext ("There is %d document with unsaved changes. "
ngettext ("Changes to %d document will be permanently lost.", "Save changes before closing?",
"Changes to %d documents will be permanently lost.", "There are %d documents with unsaved changes. "
g_list_length (priv->unsaved_documents)), "Save changes before closing?",
g_list_length (priv->unsaved_documents)); g_list_length (priv->unsaved_documents)),
else g_list_length (priv->unsaved_documents));
str = g_strdup_printf (
ngettext ("There is %d document with unsaved changes. "
"Save changes before closing?",
"There are %d documents with unsaved changes. "
"Save changes before closing?",
g_list_length (priv->unsaved_documents)),
g_list_length (priv->unsaved_documents));
markup_str = g_strconcat ("<span weight=\"bold\" size=\"larger\">", str, "</span>", NULL); markup_str = g_strconcat ("<span weight=\"bold\" size=\"larger\">", str, "</span>", NULL);
g_free (str); g_free (str);
@ -759,10 +726,7 @@ build_multiple_docs_dialog (XeditCloseConfirmationDialog *dlg)
vbox2 = gtk_vbox_new (FALSE, 8); vbox2 = gtk_vbox_new (FALSE, 8);
gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
if (priv->disable_save_to_disk) select_label = gtk_label_new_with_mnemonic (_("S_elect the documents you want to save:"));
select_label = gtk_label_new_with_mnemonic (_("Docum_ents with unsaved changes:"));
else
select_label = gtk_label_new_with_mnemonic (_("S_elect the documents you want to save:"));
gtk_box_pack_start (GTK_BOX (vbox2), select_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox2), select_label, FALSE, FALSE, 0);
gtk_label_set_line_wrap (GTK_LABEL (select_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (select_label), TRUE);
@ -784,10 +748,7 @@ build_multiple_docs_dialog (XeditCloseConfirmationDialog *dlg)
gtk_container_add (GTK_CONTAINER (scrolledwindow), treeview); gtk_container_add (GTK_CONTAINER (scrolledwindow), treeview);
/* Secondary label */ /* Secondary label */
if (priv->disable_save_to_disk) secondary_label = gtk_label_new (_("If you don't save, "
secondary_label = gtk_label_new (_("Saving has been disabled by the system administrator."));
else
secondary_label = gtk_label_new (_("If you don't save, "
"all your changes will be permanently lost.")); "all your changes will be permanently lost."));
gtk_box_pack_start (GTK_BOX (vbox2), secondary_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox2), secondary_label, FALSE, FALSE, 0);

View File

@ -55,16 +55,12 @@
enum enum
{ {
PROP_0, PROP_0,
PROP_LOCKDOWN
}; };
struct _XeditAppPrivate struct _XeditAppPrivate
{ {
GList *windows; GList *windows;
XeditWindow *active_window; XeditWindow *active_window;
XeditLockdownMask lockdown;
GtkPageSetup *page_setup; GtkPageSetup *page_setup;
GtkPrintSettings *print_settings; GtkPrintSettings *print_settings;
}; };
@ -96,9 +92,6 @@ xedit_app_get_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_LOCKDOWN:
g_value_set_flags (value, xedit_app_get_lockdown (app));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -113,16 +106,6 @@ xedit_app_class_init (XeditAppClass *klass)
object_class->finalize = xedit_app_finalize; object_class->finalize = xedit_app_finalize;
object_class->get_property = xedit_app_get_property; object_class->get_property = xedit_app_get_property;
g_object_class_install_property (object_class,
PROP_LOCKDOWN,
g_param_spec_flags ("lockdown",
"Lockdown",
"The lockdown mask",
XEDIT_TYPE_LOCKDOWN_MASK,
0,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
g_type_class_add_private (object_class, sizeof(XeditAppPrivate)); g_type_class_add_private (object_class, sizeof(XeditAppPrivate));
} }
@ -332,9 +315,6 @@ xedit_app_init (XeditApp *app)
app->priv = XEDIT_APP_GET_PRIVATE (app); app->priv = XEDIT_APP_GET_PRIVATE (app);
load_accels (); load_accels ();
/* initial lockdown state */
app->priv->lockdown = xedit_prefs_manager_get_lockdown ();
} }
static void static void
@ -792,60 +772,6 @@ xedit_app_get_views (XeditApp *app)
return res; return res;
} }
/**
* xedit_app_get_lockdown:
* @app: a #XeditApp
*
* Gets the lockdown mask (see #XeditLockdownMask) for the application.
* The lockdown mask determines which functions are locked down using
* the MATE-wise lockdown GSettings keys.
**/
XeditLockdownMask
xedit_app_get_lockdown (XeditApp *app)
{
g_return_val_if_fail (XEDIT_IS_APP (app), XEDIT_LOCKDOWN_ALL);
return app->priv->lockdown;
}
static void
app_lockdown_changed (XeditApp *app)
{
GList *l;
for (l = app->priv->windows; l != NULL; l = l->next)
_xedit_window_set_lockdown (XEDIT_WINDOW (l->data),
app->priv->lockdown);
g_object_notify (G_OBJECT (app), "lockdown");
}
void
_xedit_app_set_lockdown (XeditApp *app,
XeditLockdownMask lockdown)
{
g_return_if_fail (XEDIT_IS_APP (app));
app->priv->lockdown = lockdown;
app_lockdown_changed (app);
}
void
_xedit_app_set_lockdown_bit (XeditApp *app,
XeditLockdownMask bit,
gboolean value)
{
g_return_if_fail (XEDIT_IS_APP (app));
if (value)
app->priv->lockdown |= bit;
else
app->priv->lockdown &= ~bit;
app_lockdown_changed (app);
}
/* Returns a copy */ /* Returns a copy */
GtkPageSetup * GtkPageSetup *
_xedit_app_get_default_page_setup (XeditApp *app) _xedit_app_get_default_page_setup (XeditApp *app)

View File

@ -73,18 +73,6 @@ struct _XeditAppClass
GObjectClass parent_class; GObjectClass parent_class;
}; };
/*
* Lockdown mask definition
*/
typedef enum
{
XEDIT_LOCKDOWN_COMMAND_LINE = 1 << 0,
XEDIT_LOCKDOWN_PRINTING = 1 << 1,
XEDIT_LOCKDOWN_PRINT_SETUP = 1 << 2,
XEDIT_LOCKDOWN_SAVE_TO_DISK = 1 << 3,
XEDIT_LOCKDOWN_ALL = 0xF
} XeditLockdownMask;
/* /*
* Public methods * Public methods
*/ */
@ -104,9 +92,6 @@ GList *xedit_app_get_documents (XeditApp *app);
/* Returns a newly allocated list with all the views */ /* Returns a newly allocated list with all the views */
GList *xedit_app_get_views (XeditApp *app); GList *xedit_app_get_views (XeditApp *app);
/* Lockdown state */
XeditLockdownMask xedit_app_get_lockdown (XeditApp *app);
/* /*
* Non exported functions * Non exported functions
*/ */
@ -117,17 +102,6 @@ XeditWindow *_xedit_app_get_window_in_viewport (XeditApp *app,
gint workspace, gint workspace,
gint viewport_x, gint viewport_x,
gint viewport_y); gint viewport_y);
void _xedit_app_set_lockdown (XeditApp *app,
XeditLockdownMask lockdown);
void _xedit_app_set_lockdown_bit (XeditApp *app,
XeditLockdownMask bit,
gboolean value);
/*
* This one is a xedit-window function, but we declare it here to avoid
* #include headaches since it needs the XeditLockdownMask declaration.
*/
void _xedit_window_set_lockdown (XeditWindow *window,
XeditLockdownMask lockdown);
/* global print config */ /* global print config */
GtkPageSetup *_xedit_app_get_default_page_setup (XeditApp *app); GtkPageSetup *_xedit_app_get_default_page_setup (XeditApp *app);

View File

@ -116,10 +116,6 @@ static void xedit_prefs_manager_active_plugins_changed (GSettings *settings,
gchar *key, gchar *key,
gpointer user_data); gpointer user_data);
static void xedit_prefs_manager_lockdown_changed (GSettings *settings,
gchar *key,
gpointer user_data);
/* GUI state is serialized to a .desktop file, not in GSettings */ /* GUI state is serialized to a .desktop file, not in GSettings */
#define XEDIT_STATE_DEFAULT_WINDOW_STATE 0 #define XEDIT_STATE_DEFAULT_WINDOW_STATE 0
@ -717,11 +713,6 @@ xedit_prefs_manager_app_init (void)
"changed::" GPM_ACTIVE_PLUGINS, "changed::" GPM_ACTIVE_PLUGINS,
G_CALLBACK (xedit_prefs_manager_active_plugins_changed), G_CALLBACK (xedit_prefs_manager_active_plugins_changed),
NULL); NULL);
g_signal_connect (xedit_prefs_manager->lockdown_settings,
"changed",
G_CALLBACK (xedit_prefs_manager_lockdown_changed),
NULL);
} }
return xedit_prefs_manager != NULL; return xedit_prefs_manager != NULL;
@ -1439,37 +1430,3 @@ xedit_prefs_manager_active_plugins_changed (GSettings *settings,
} }
} }
static void
xedit_prefs_manager_lockdown_changed (GSettings *settings,
gchar *key,
gpointer user_data)
{
XeditApp *app;
gboolean locked;
xedit_debug (DEBUG_PREFS);
locked = g_settings_get_boolean (settings, key);
app = xedit_app_get_default ();
if (strcmp (key, GPM_LOCKDOWN_COMMAND_LINE) == 0)
_xedit_app_set_lockdown_bit (app,
XEDIT_LOCKDOWN_COMMAND_LINE,
locked);
else if (strcmp (key, GPM_LOCKDOWN_PRINTING) == 0)
_xedit_app_set_lockdown_bit (app,
XEDIT_LOCKDOWN_PRINTING,
locked);
else if (strcmp (key, GPM_LOCKDOWN_PRINT_SETUP) == 0)
_xedit_app_set_lockdown_bit (app,
XEDIT_LOCKDOWN_PRINT_SETUP,
locked);
else if (strcmp (key, GPM_LOCKDOWN_SAVE_TO_DISK) == 0)
_xedit_app_set_lockdown_bit (app,
XEDIT_LOCKDOWN_SAVE_TO_DISK,
locked);
}

View File

@ -36,7 +36,6 @@ typedef struct _XeditPrefsManager XeditPrefsManager;
struct _XeditPrefsManager { struct _XeditPrefsManager {
GSettings *settings; GSettings *settings;
GSettings *lockdown_settings;
GSettings *interface_settings; GSettings *interface_settings;
}; };

View File

@ -143,7 +143,6 @@ xedit_prefs_manager_init (void)
{ {
xedit_prefs_manager = g_new0 (XeditPrefsManager, 1); xedit_prefs_manager = g_new0 (XeditPrefsManager, 1);
xedit_prefs_manager->settings = g_settings_new (XEDIT_SCHEMA); xedit_prefs_manager->settings = g_settings_new (XEDIT_SCHEMA);
xedit_prefs_manager->lockdown_settings = g_settings_new (GPM_LOCKDOWN_SCHEMA);
xedit_prefs_manager->interface_settings = g_settings_new (GPM_INTERFACE_SCHEMA); xedit_prefs_manager->interface_settings = g_settings_new (GPM_INTERFACE_SCHEMA);
} }
@ -159,8 +158,6 @@ xedit_prefs_manager_shutdown (void)
g_object_unref (xedit_prefs_manager->settings); g_object_unref (xedit_prefs_manager->settings);
xedit_prefs_manager->settings = NULL; xedit_prefs_manager->settings = NULL;
g_object_unref (xedit_prefs_manager->lockdown_settings);
xedit_prefs_manager->lockdown_settings = NULL;
g_object_unref (xedit_prefs_manager->interface_settings); g_object_unref (xedit_prefs_manager->interface_settings);
xedit_prefs_manager->interface_settings = NULL; xedit_prefs_manager->interface_settings = NULL;
} }
@ -917,25 +914,3 @@ xedit_prefs_manager_active_plugins_can_set (void)
return xedit_prefs_manager_key_is_writable (GPM_ACTIVE_PLUGINS); return xedit_prefs_manager_key_is_writable (GPM_ACTIVE_PLUGINS);
} }
/* Global Lockdown */
XeditLockdownMask
xedit_prefs_manager_get_lockdown (void)
{
guint lockdown = 0;
if (g_settings_get_boolean (xedit_prefs_manager->lockdown_settings, GPM_LOCKDOWN_COMMAND_LINE))
lockdown |= XEDIT_LOCKDOWN_COMMAND_LINE;
if (g_settings_get_boolean (xedit_prefs_manager->lockdown_settings, GPM_LOCKDOWN_PRINTING))
lockdown |= XEDIT_LOCKDOWN_PRINTING;
if (g_settings_get_boolean (xedit_prefs_manager->lockdown_settings, GPM_LOCKDOWN_PRINT_SETUP))
lockdown |= XEDIT_LOCKDOWN_PRINT_SETUP;
if (g_settings_get_boolean (xedit_prefs_manager->lockdown_settings, GPM_LOCKDOWN_SAVE_TO_DISK))
lockdown |= XEDIT_LOCKDOWN_SAVE_TO_DISK;
return lockdown;
}

View File

@ -111,13 +111,6 @@
#define GPM_INTERFACE_SCHEMA "org.mate.interface" #define GPM_INTERFACE_SCHEMA "org.mate.interface"
#define GPM_SYSTEM_FONT "monospace-font-name" #define GPM_SYSTEM_FONT "monospace-font-name"
/* Global Lockdown keys */
#define GPM_LOCKDOWN_SCHEMA "org.mate.lockdown"
#define GPM_LOCKDOWN_COMMAND_LINE "disable-command-line"
#define GPM_LOCKDOWN_PRINTING "disable-printing"
#define GPM_LOCKDOWN_PRINT_SETUP "disable-print-setup"
#define GPM_LOCKDOWN_SAVE_TO_DISK "disable-save-to-disk"
/* Fallback default values. Keep in sync with org.x.editor.gschema.xml */ /* Fallback default values. Keep in sync with org.x.editor.gschema.xml */
#define GPM_DEFAULT_AUTO_SAVE_INTERVAL 10 /* minutes */ #define GPM_DEFAULT_AUTO_SAVE_INTERVAL 10 /* minutes */
#define GPM_DEFAULT_MAX_RECENTS 5 #define GPM_DEFAULT_MAX_RECENTS 5
@ -323,9 +316,6 @@ GSList *xedit_prefs_manager_get_active_plugins (void);
void xedit_prefs_manager_set_active_plugins (const GSList *plugins); void xedit_prefs_manager_set_active_plugins (const GSList *plugins);
gboolean xedit_prefs_manager_active_plugins_can_set (void); gboolean xedit_prefs_manager_active_plugins_can_set (void);
/* Global lockdown */
XeditLockdownMask xedit_prefs_manager_get_lockdown (void);
/* GSettings utilities */ /* GSettings utilities */
GSList* xedit_prefs_manager_get_gslist (GSettings *settings, const gchar *key); GSList* xedit_prefs_manager_get_gslist (GSettings *settings, const gchar *key);
void xedit_prefs_manager_set_gslist (GSettings *settings, const gchar *key, GSList *list); void xedit_prefs_manager_set_gslist (GSettings *settings, const gchar *key, GSList *list);

View File

@ -1478,7 +1478,6 @@ xedit_tab_init (XeditTab *tab)
{ {
GtkWidget *sw; GtkWidget *sw;
XeditDocument *doc; XeditDocument *doc;
XeditLockdownMask lockdown;
tab->priv = XEDIT_TAB_GET_PRIVATE (tab); tab->priv = XEDIT_TAB_GET_PRIVATE (tab);
@ -1504,9 +1503,7 @@ xedit_tab_init (XeditTab *tab)
GTK_POLICY_AUTOMATIC); GTK_POLICY_AUTOMATIC);
/* Manage auto save data */ /* Manage auto save data */
lockdown = xedit_app_get_lockdown (xedit_app_get_default ()); tab->priv->auto_save = xedit_prefs_manager_get_auto_save ();
tab->priv->auto_save = xedit_prefs_manager_get_auto_save () &&
!(lockdown & XEDIT_LOCKDOWN_SAVE_TO_DISK);
tab->priv->auto_save = (tab->priv->auto_save != FALSE); tab->priv->auto_save = (tab->priv->auto_save != FALSE);
tab->priv->auto_save_interval = xedit_prefs_manager_get_auto_save_interval (); tab->priv->auto_save_interval = xedit_prefs_manager_get_auto_save_interval ();
@ -2670,17 +2667,10 @@ xedit_tab_set_auto_save_enabled (XeditTab *tab,
gboolean enable) gboolean enable)
{ {
XeditDocument *doc = NULL; XeditDocument *doc = NULL;
XeditLockdownMask lockdown;
xedit_debug (DEBUG_TAB); xedit_debug (DEBUG_TAB);
g_return_if_fail (XEDIT_IS_TAB (tab)); g_return_if_fail (XEDIT_IS_TAB (tab));
/* Force disabling when lockdown is active */
lockdown = xedit_app_get_lockdown (xedit_app_get_default());
if (lockdown & XEDIT_LOCKDOWN_SAVE_TO_DISK)
enable = FALSE;
doc = xedit_tab_get_document (tab); doc = xedit_tab_get_document (tab);
if (tab->priv->auto_save == enable) if (tab->priv->auto_save == enable)

View File

@ -666,14 +666,11 @@ set_sensitivity_according_to_tab (XeditWindow *window,
gboolean editable; gboolean editable;
XeditTabState state; XeditTabState state;
GtkClipboard *clipboard; GtkClipboard *clipboard;
XeditLockdownMask lockdown;
g_return_if_fail (XEDIT_TAB (tab)); g_return_if_fail (XEDIT_TAB (tab));
xedit_debug (DEBUG_WINDOW); xedit_debug (DEBUG_WINDOW);
lockdown = xedit_app_get_lockdown (xedit_app_get_default ());
state = xedit_tab_get_state (tab); state = xedit_tab_get_state (tab);
state_normal = (state == XEDIT_TAB_STATE_NORMAL); state_normal = (state == XEDIT_TAB_STATE_NORMAL);
@ -691,8 +688,7 @@ set_sensitivity_according_to_tab (XeditWindow *window,
(state_normal || (state_normal ||
(state == XEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) || (state == XEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) ||
(state == XEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW)) && (state == XEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW)) &&
!xedit_document_get_readonly (doc) && !xedit_document_get_readonly (doc));
!(lockdown & XEDIT_LOCKDOWN_SAVE_TO_DISK));
action = gtk_action_group_get_action (window->priv->action_group, action = gtk_action_group_get_action (window->priv->action_group,
"FileSaveAs"); "FileSaveAs");
@ -700,8 +696,7 @@ set_sensitivity_according_to_tab (XeditWindow *window,
(state_normal || (state_normal ||
(state == XEDIT_TAB_STATE_SAVING_ERROR) || (state == XEDIT_TAB_STATE_SAVING_ERROR) ||
(state == XEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) || (state == XEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) ||
(state == XEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW)) && (state == XEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW)));
!(lockdown & XEDIT_LOCKDOWN_SAVE_TO_DISK));
action = gtk_action_group_get_action (window->priv->action_group, action = gtk_action_group_get_action (window->priv->action_group,
"FileRevert"); "FileRevert");
@ -713,15 +708,13 @@ set_sensitivity_according_to_tab (XeditWindow *window,
action = gtk_action_group_get_action (window->priv->action_group, action = gtk_action_group_get_action (window->priv->action_group,
"FilePrintPreview"); "FilePrintPreview");
gtk_action_set_sensitive (action, gtk_action_set_sensitive (action,
state_normal && state_normal);
!(lockdown & XEDIT_LOCKDOWN_PRINTING));
action = gtk_action_group_get_action (window->priv->action_group, action = gtk_action_group_get_action (window->priv->action_group,
"FilePrint"); "FilePrint");
gtk_action_set_sensitive (action, gtk_action_set_sensitive (action,
(state_normal || (state_normal ||
(state == XEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW)) && (state == XEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW)));
!(lockdown & XEDIT_LOCKDOWN_PRINTING));
action = gtk_action_group_get_action (window->priv->close_action_group, action = gtk_action_group_get_action (window->priv->close_action_group,
"FileClose"); "FileClose");
@ -2445,9 +2438,6 @@ static void
set_sensitivity_according_to_window_state (XeditWindow *window) set_sensitivity_according_to_window_state (XeditWindow *window)
{ {
GtkAction *action; GtkAction *action;
XeditLockdownMask lockdown;
lockdown = xedit_app_get_lockdown (xedit_app_get_default ());
/* We disable File->Quit/SaveAll/CloseAll while printing to avoid to have two /* We disable File->Quit/SaveAll/CloseAll while printing to avoid to have two
operations (save and print/print preview) that uses the message area at operations (save and print/print preview) that uses the message area at
@ -2467,8 +2457,7 @@ set_sensitivity_according_to_window_state (XeditWindow *window)
action = gtk_action_group_get_action (window->priv->action_group, action = gtk_action_group_get_action (window->priv->action_group,
"FileSaveAll"); "FileSaveAll");
gtk_action_set_sensitive (action, gtk_action_set_sensitive (action,
!(window->priv->state & XEDIT_WINDOW_STATE_PRINTING) && !(window->priv->state & XEDIT_WINDOW_STATE_PRINTING));
!(lockdown & XEDIT_LOCKDOWN_SAVE_TO_DISK));
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group, action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
"FileNew"); "FileNew");
@ -2530,33 +2519,6 @@ update_tab_autosave (GtkWidget *widget,
xedit_tab_set_auto_save_enabled (tab, *enabled); xedit_tab_set_auto_save_enabled (tab, *enabled);
} }
void
_xedit_window_set_lockdown (XeditWindow *window,
XeditLockdownMask lockdown)
{
XeditTab *tab;
GtkAction *action;
gboolean autosave;
/* start/stop autosave in each existing tab */
autosave = xedit_prefs_manager_get_auto_save ();
gtk_container_foreach (GTK_CONTAINER (window->priv->notebook),
update_tab_autosave,
&autosave);
/* update menues wrt the current active tab */
tab = xedit_window_get_active_tab (window);
set_sensitivity_according_to_tab (window, tab);
action = gtk_action_group_get_action (window->priv->action_group,
"FileSaveAll");
gtk_action_set_sensitive (action,
!(window->priv->state & XEDIT_WINDOW_STATE_PRINTING) &&
!(lockdown & XEDIT_LOCKDOWN_SAVE_TO_DISK));
}
static void static void
analyze_tab_state (XeditTab *tab, analyze_tab_state (XeditTab *tab,
XeditWindow *window) XeditWindow *window)