Browse Source

Add Xfconf based kiosk locking to the panel.

Each panel can be locked individually though Xfconf and
new API function xfce_panel_plugin_get_locked() for plugins;
although it might be safer for plugins to directly check the
Xfconf channel.
upstream/xfce4-panel-4.10.1
Nick Schermer 12 years ago
parent
commit
1f42438a2c
  1. 15
      common/panel-dbus.h
  2. 1
      docs/references/libxfce4panel-sections.txt
  3. 7
      libxfce4panel/libxfce4panel-deprecated.h
  4. 1
      libxfce4panel/libxfce4panel.symbols
  5. 11
      libxfce4panel/xfce-panel-plugin-provider.c
  6. 5
      libxfce4panel/xfce-panel-plugin-provider.h
  7. 245
      libxfce4panel/xfce-panel-plugin.c
  8. 2
      libxfce4panel/xfce-panel-plugin.h
  9. 90
      panel/panel-application.c
  10. 2
      panel/panel-application.h
  11. 24
      panel/panel-dialogs.c
  12. 2
      panel/panel-dialogs.h
  13. 5
      panel/panel-item-dialog.c
  14. 17
      panel/panel-plugin-external-46.c
  15. 23
      panel/panel-plugin-external.c
  16. 19
      panel/panel-preferences-dialog.c
  17. 2
      panel/panel-preferences-dialog.glade
  18. 122
      panel/panel-window.c
  19. 5
      panel/panel-window.h
  20. 2
      wrapper/main.c

15
common/panel-dbus.h

@ -32,13 +32,14 @@
#define SIGNAL_SET_SIZE SIGNAL_PREFIX_S "a"
#define SIGNAL_SET_ORIENTATION SIGNAL_PREFIX_S "b"
#define SIGNAL_SET_SCREEN_POSITION SIGNAL_PREFIX_S "c"
#define SIGNAL_SAVE SIGNAL_PREFIX_S "d"
#define SIGNAL_SHOW_CONFIGURE SIGNAL_PREFIX_S "e"
#define SIGNAL_SHOW_ABOUT SIGNAL_PREFIX_S "f"
#define SIGNAL_REMOVED SIGNAL_PREFIX_S "g"
#define SIGNAL_WRAPPER_SET_SENSITIVE SIGNAL_PREFIX_S "h"
#define SIGNAL_WRAPPER_BACKGROUND_ALPHA SIGNAL_PREFIX_S "i"
#define SIGNAL_WRAPPER_QUIT SIGNAL_PREFIX_S "j"
#define SIGNAL_SET_LOCKED SIGNAL_PREFIX_S "d"
#define SIGNAL_SAVE SIGNAL_PREFIX_S "e"
#define SIGNAL_SHOW_CONFIGURE SIGNAL_PREFIX_S "f"
#define SIGNAL_SHOW_ABOUT SIGNAL_PREFIX_S "g"
#define SIGNAL_REMOVED SIGNAL_PREFIX_S "h"
#define SIGNAL_WRAPPER_SET_SENSITIVE SIGNAL_PREFIX_S "i"
#define SIGNAL_WRAPPER_BACKGROUND_ALPHA SIGNAL_PREFIX_S "j"
#define SIGNAL_WRAPPER_QUIT SIGNAL_PREFIX_S "k"
/* special types for dbus communication */
#define PANEL_TYPE_DBUS_SET_MESSAGE dbus_g_type_get_struct ("GValueArray", \

1
docs/references/libxfce4panel-sections.txt

@ -113,6 +113,7 @@ xfce_panel_plugin_get_expand
xfce_panel_plugin_set_expand
xfce_panel_plugin_get_orientation
xfce_panel_plugin_get_screen_position
xfce_panel_plugin_get_locked
xfce_panel_plugin_take_window
xfce_panel_plugin_add_action_widget
xfce_panel_plugin_menu_insert_item

7
libxfce4panel/libxfce4panel-deprecated.h

@ -36,6 +36,7 @@ enum /*< skip >*/
PANEL_CLIENT_EVENT_REMOVED,
PANEL_CLIENT_EVENT_SAVE,
PANEL_CLIENT_EVENT_SET_BACKGROUND_ALPHA,
PANEL_CLIENT_EVENT_SET_LOCKED,
PANEL_CLIENT_EVENT_SET_ORIENTATION,
PANEL_CLIENT_EVENT_SET_SCREEN_POSITION,
PANEL_CLIENT_EVENT_SET_SENSITIVE,
@ -117,6 +118,10 @@ enum /*< skip >*/
gtk_widget_queue_draw (plug); \
break; \
\
case PANEL_CLIENT_EVENT_SET_LOCKED: \
xfce_panel_plugin_provider_set_locked (provider, !!value) \
break; \
\
case PANEL_CLIENT_EVENT_SET_ORIENTATION: \
xfce_panel_plugin_provider_set_orientation (provider, value); \
break; \
@ -126,7 +131,7 @@ enum /*< skip >*/
break; \
\
case PANEL_CLIENT_EVENT_SET_SENSITIVE: \
gtk_widget_set_sensitive (plug, value); \
gtk_widget_set_sensitive (plug, !!value); \
break; \
\
case PANEL_CLIENT_EVENT_SET_SIZE: \

1
libxfce4panel/libxfce4panel.symbols

@ -95,6 +95,7 @@ xfce_panel_plugin_get_arguments G_GNUC_PURE
xfce_panel_plugin_get_size G_GNUC_PURE
xfce_panel_plugin_get_expand G_GNUC_PURE
xfce_panel_plugin_set_expand
xfce_panel_plugin_get_locked
xfce_panel_plugin_get_orientation G_GNUC_PURE
xfce_panel_plugin_get_screen_position G_GNUC_PURE
xfce_panel_plugin_take_window

11
libxfce4panel/xfce-panel-plugin-provider.c

@ -222,5 +222,16 @@ xfce_panel_plugin_provider_remote_event (XfcePanelPluginProvider *provider,
void
xfce_panel_plugin_provider_set_locked (XfcePanelPluginProvider *provider,
gboolean locked)
{
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
(*XFCE_PANEL_PLUGIN_PROVIDER_GET_INTERFACE (provider)->set_locked) (provider, locked);
}
#define __XFCE_PANEL_PLUGIN_PROVIDER_C__
#include <libxfce4panel/libxfce4panel-aliasdef.c>

5
libxfce4panel/xfce-panel-plugin-provider.h

@ -65,6 +65,8 @@ struct _XfcePanelPluginProviderInterface
gboolean (*remote_event) (XfcePanelPluginProvider *provider,
const gchar *name,
const GValue *value);
void (*set_locked) (XfcePanelPluginProvider *provider,
gboolean locked);
};
/* signals send from the plugin to the panel (possibly through the wrapper) */
@ -148,6 +150,9 @@ gboolean xfce_panel_plugin_provider_remote_event (XfcePanelP
const gchar *name,
const GValue *value);
void xfce_panel_plugin_provider_set_locked (XfcePanelPluginProvider *provider,
gboolean locked);
G_END_DECLS
#endif /* !__XFCE_PANEL_PLUGIN_PROVIDER_H__ */

245
libxfce4panel/xfce-panel-plugin.c

@ -96,6 +96,8 @@ static void xfce_panel_plugin_removed (XfcePanelPluginPr
static gboolean xfce_panel_plugin_remote_event (XfcePanelPluginProvider *provider,
const gchar *name,
const GValue *value);
static void xfce_panel_plugin_set_locked (XfcePanelPluginProvider *provider,
gboolean locked);
static void xfce_panel_plugin_take_window_notify (gpointer data,
GObject *where_the_object_was);
@ -152,6 +154,7 @@ struct _XfcePanelPluginPrivate
guint expand : 1;
GtkOrientation orientation;
XfceScreenPosition screen_position;
guint locked : 1;
/* flags for rembering states */
PluginFlags flags;
@ -168,7 +171,9 @@ struct _XfcePanelPluginPrivate
static guint plugin_signals[LAST_SIGNAL];
static guint plugin_signals[LAST_SIGNAL];
static GQuark item_properties = 0;
static GQuark item_about = 0;
@ -531,6 +536,9 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
FALSE,
G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS));
item_properties = g_quark_from_static_string ("item-properties");
item_about = g_quark_from_static_string ("item-about");
}
@ -554,6 +562,7 @@ xfce_panel_plugin_init (XfcePanelPlugin *plugin)
plugin->priv->menu_blocked = 0;
plugin->priv->panel_lock = 0;
plugin->priv->flags = 0;
plugin->priv->locked = TRUE;
/* hide the event box window to make the plugin transparent */
gtk_event_box_set_visible_window (GTK_EVENT_BOX (plugin), FALSE);
@ -576,6 +585,7 @@ xfce_panel_plugin_provider_init (XfcePanelPluginProviderInterface *iface)
iface->show_about = xfce_panel_plugin_show_about;
iface->removed = xfce_panel_plugin_removed;
iface->remote_event = xfce_panel_plugin_remote_event;
iface->set_locked = xfce_panel_plugin_set_locked;
}
@ -768,8 +778,9 @@ xfce_panel_plugin_button_press_event (GtkWidget *widget,
menu = xfce_panel_plugin_menu_get (plugin);
/* if the menu is block, some items are insensitive */
item = g_object_get_data (G_OBJECT (menu), g_intern_static_string ("properties-item"));
gtk_widget_set_sensitive (item, plugin->priv->menu_blocked == 0);
item = g_object_get_qdata (G_OBJECT (menu), item_properties);
if (item != NULL)
gtk_widget_set_sensitive (item, plugin->priv->menu_blocked == 0);
/* popup the menu */
gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time);
@ -836,8 +847,9 @@ xfce_panel_plugin_menu_add_items (XfcePanelPlugin *plugin)
panel_return_if_fail (XFCE_PANEL_PLUGIN_CONSTRUCTED (plugin));
/* open items dialog */
xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
PROVIDER_SIGNAL_ADD_NEW_ITEMS);
if (!xfce_panel_plugin_get_locked (plugin))
xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
PROVIDER_SIGNAL_ADD_NEW_ITEMS);
}
@ -850,8 +862,9 @@ xfce_panel_plugin_menu_panel_preferences (XfcePanelPlugin *plugin)
panel_return_if_fail (XFCE_PANEL_PLUGIN_CONSTRUCTED (plugin));
/* open preferences dialog */
xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
PROVIDER_SIGNAL_PANEL_PREFERENCES);
if (!xfce_panel_plugin_get_locked (plugin))
xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
PROVIDER_SIGNAL_PANEL_PREFERENCES);
}
@ -904,11 +917,14 @@ xfce_panel_plugin_menu_get (XfcePanelPlugin *plugin)
GtkWidget *menu, *submenu;
GtkWidget *item;
GtkWidget *image;
gboolean locked;
panel_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), NULL);
if (G_UNLIKELY (plugin->priv->menu == NULL))
{
locked = xfce_panel_plugin_get_locked (plugin);
menu = gtk_menu_new ();
gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (plugin), NULL);
@ -923,85 +939,91 @@ xfce_panel_plugin_menu_get (XfcePanelPlugin *plugin)
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* properties item */
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_PROPERTIES, NULL);
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (xfce_panel_plugin_show_configure), plugin);
g_object_set_data (G_OBJECT (menu), g_intern_static_string ("properties-item"), item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
if (PANEL_HAS_FLAG (plugin->priv->flags, PLUGIN_FLAG_SHOW_CONFIGURE))
gtk_widget_show (item);
/* about item */
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (xfce_panel_plugin_show_about), plugin);
g_object_set_data (G_OBJECT (menu), g_intern_static_string ("about-item"), item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
if (PANEL_HAS_FLAG (plugin->priv->flags, PLUGIN_FLAG_SHOW_ABOUT))
gtk_widget_show (item);
/* move item */
item = gtk_image_menu_item_new_with_mnemonic (_("_Move"));
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (xfce_panel_plugin_menu_move), plugin);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
image = gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
/* separator */
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* remove */
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_REMOVE, NULL);
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (xfce_panel_plugin_menu_remove), plugin);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* separator */
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
if (!locked)
{
/* properties item */
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_PROPERTIES, NULL);
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (xfce_panel_plugin_show_configure), plugin);
g_object_set_qdata (G_OBJECT (menu), item_properties, item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
if (PANEL_HAS_FLAG (plugin->priv->flags, PLUGIN_FLAG_SHOW_CONFIGURE))
gtk_widget_show (item);
/* about item */
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (xfce_panel_plugin_show_about), plugin);
g_object_set_qdata (G_OBJECT (menu), item_about, item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
if (PANEL_HAS_FLAG (plugin->priv->flags, PLUGIN_FLAG_SHOW_ABOUT))
gtk_widget_show (item);
/* move item */
item = gtk_image_menu_item_new_with_mnemonic (_("_Move"));
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (xfce_panel_plugin_menu_move), plugin);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
image = gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
/* separator */
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* remove */
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_REMOVE, NULL);
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (xfce_panel_plugin_menu_remove), plugin);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* separator */
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
}
/* create a panel submenu item */
submenu = gtk_menu_new ();
item = gtk_image_menu_item_new_with_mnemonic ("_Xfce Panel");
item = gtk_menu_item_new_with_mnemonic ("_Xfce Panel");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
gtk_widget_show (item);
/* add new items */
item = gtk_image_menu_item_new_with_mnemonic (_("Add _New Items..."));
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (xfce_panel_plugin_menu_add_items), plugin);
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
gtk_widget_show (item);
image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
/* customize panel */
item = gtk_image_menu_item_new_with_mnemonic (_("Panel Pr_eferences..."));
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (xfce_panel_plugin_menu_panel_preferences), plugin);
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
gtk_widget_show (item);
image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
/* separator */
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
gtk_widget_show (item);
if (!locked)
{
/* add new items */
item = gtk_image_menu_item_new_with_mnemonic (_("Add _New Items..."));
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (xfce_panel_plugin_menu_add_items), plugin);
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
gtk_widget_show (item);
image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
/* customize panel */
item = gtk_image_menu_item_new_with_mnemonic (_("Panel Pr_eferences..."));
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (xfce_panel_plugin_menu_panel_preferences), plugin);
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
gtk_widget_show (item);
image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
/* separator */
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
gtk_widget_show (item);
}
/* quit item */
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
@ -1157,10 +1179,13 @@ xfce_panel_plugin_set_screen_position (XfcePanelPluginProvider *provider,
static void
xfce_panel_plugin_save (XfcePanelPluginProvider *provider)
{
XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (provider);
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
/* only send the save signal if the plugin is not locked */
if (XFCE_PANEL_PLUGIN (provider)->priv->menu_blocked == 0)
if (XFCE_PANEL_PLUGIN (provider)->priv->menu_blocked == 0
&& !xfce_panel_plugin_get_locked (plugin))
g_signal_emit (G_OBJECT (provider), plugin_signals[SAVE], 0);
}
@ -1186,8 +1211,8 @@ xfce_panel_plugin_show_configure (XfcePanelPluginProvider *provider)
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
/* emit configure-plugin signal */
if (G_LIKELY (plugin->priv->menu_blocked == 0))
if (plugin->priv->menu_blocked == 0
&& !xfce_panel_plugin_get_locked (plugin))
g_signal_emit (G_OBJECT (plugin), plugin_signals[CONFIGURE_PLUGIN], 0);
}
@ -1248,6 +1273,29 @@ xfce_panel_plugin_remote_event (XfcePanelPluginProvider *provider,
static void
xfce_panel_plugin_set_locked (XfcePanelPluginProvider *provider,
gboolean locked)
{
XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (provider);
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
if (G_LIKELY (plugin->priv->locked != locked))
{
plugin->priv->locked = locked;
/* destroy the menu if it exists */
if (plugin->priv->menu != NULL)
{
gtk_widget_destroy (GTK_WIDGET (plugin->priv->menu));
plugin->priv->menu = NULL;
}
}
}
static void
xfce_panel_plugin_take_window_notify (gpointer data,
GObject *where_the_object_was)
@ -1615,7 +1663,7 @@ xfce_panel_plugin_menu_show_configure (XfcePanelPlugin *plugin)
{
/* get and show the properties item */
menu = xfce_panel_plugin_menu_get (plugin);
item = g_object_get_data (G_OBJECT (menu), g_intern_static_string ("properties-item"));
item = g_object_get_qdata (G_OBJECT (menu), item_properties);
if (G_LIKELY (item != NULL))
gtk_widget_show (item);
}
@ -1650,7 +1698,7 @@ xfce_panel_plugin_menu_show_about (XfcePanelPlugin *plugin)
{
/* get and show the about item */
menu = xfce_panel_plugin_menu_get (plugin);
item = g_object_get_data (G_OBJECT (menu), g_intern_static_string ("about-item"));
item = g_object_get_qdata (G_OBJECT (menu), item_about);
if (G_LIKELY (item != NULL))
gtk_widget_show (item);
}
@ -1662,6 +1710,35 @@ xfce_panel_plugin_menu_show_about (XfcePanelPlugin *plugin)
/**
* xfce_panel_plugin_remove:
* @plugin : an #XfcePanelPlugin.
*
* Whether the plugin is locked (not allowing customization). This
* is emitted through the panel based on the Xfconf locking of the
* panel window the plugin is embedded on.
*
* It is however possible to send a fake signal to the plugin to
* override this propery, so you should only use this for interface
* elements and (if you use Xfconf) check the locking yourself
* before you write any values or query the kiosk mode using the
* api in libxfce4util.
*
* Returns: %TRUE if the user is not allowed to modify the plugin,
* %FALSE is customization is allowed.
*
* Since: 4.8.0
**/
gboolean
xfce_panel_plugin_get_locked (XfcePanelPlugin *plugin)
{
g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), TRUE);
return plugin->priv->locked;
}
/**
* xfce_panel_plugin_remove:
* @plugin : an #XfcePanelPlugin.

2
libxfce4panel/xfce-panel-plugin.h

@ -136,6 +136,8 @@ void xfce_panel_plugin_menu_show_configure (XfcePanelPlugin *
void xfce_panel_plugin_menu_show_about (XfcePanelPlugin *plugin);
gboolean xfce_panel_plugin_get_locked (XfcePanelPlugin *plugin);
void xfce_panel_plugin_remove (XfcePanelPlugin *plugin);
void xfce_panel_plugin_block_menu (XfcePanelPlugin *plugin);

90
panel/panel-application.c

@ -253,7 +253,7 @@ panel_application_xfconf_window_bindings (PanelApplication *application,
gchar *property_base;
const PanelProperty properties[] =
{
{ "locked", G_TYPE_BOOLEAN },
{ "position-locked", G_TYPE_BOOLEAN },
{ "autohide", G_TYPE_BOOLEAN },
{ "span-monitors", G_TYPE_BOOLEAN },
{ "horizontal", G_TYPE_BOOLEAN },
@ -279,6 +279,10 @@ panel_application_xfconf_window_bindings (PanelApplication *application,
panel_properties_bind (application->xfconf, G_OBJECT (window),
property_base, properties, save_properties);
/* set locking for this panel */
panel_window_set_locked (window,
xfconf_channel_is_property_locked (application->xfconf, property_base));
g_free (property_base);
}
@ -465,8 +469,10 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider *provide
switch (provider_signal)
{
case PROVIDER_SIGNAL_MOVE_PLUGIN:
/* start plugin drag */
panel_application_plugin_move (GTK_WIDGET (provider), application);
/* check the window locking, not that of the provider, because
* the users might have worked around that and both should be identical */
if (!panel_window_get_locked (window))
panel_application_plugin_move (GTK_WIDGET (provider), application);
break;
case PROVIDER_SIGNAL_EXPAND_PLUGIN:
@ -500,28 +506,33 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider *provide
break;
case PROVIDER_SIGNAL_REMOVE_PLUGIN:
/* give plugin the opportunity to cleanup special configuration */
xfce_panel_plugin_provider_removed (provider);
/* check the window locking, not that of the provider, because
* the users might have worked around that and both should be identical */
if (!panel_window_get_locked (window))
{
/* give plugin the opportunity to cleanup special configuration */
xfce_panel_plugin_provider_removed (provider);
/* store the provider's unique id and name (lost after destroy) */
unique_id = xfce_panel_plugin_provider_get_unique_id (provider);
name = g_strdup (xfce_panel_plugin_provider_get_name (provider));
/* store the provider's unique id and name (lost after destroy) */
unique_id = xfce_panel_plugin_provider_get_unique_id (provider);
name = g_strdup (xfce_panel_plugin_provider_get_name (provider));
/* destroy the plugin */
gtk_widget_destroy (GTK_WIDGET (provider));
/* destroy the plugin */
gtk_widget_destroy (GTK_WIDGET (provider));
/* remove the plugin configuration */
panel_application_plugin_delete_config (application, name, unique_id);
g_free (name);
/* remove the plugin configuration */
panel_application_plugin_delete_config (application, name, unique_id);
g_free (name);
}
break;
case PROVIDER_SIGNAL_ADD_NEW_ITEMS:
/* open the items dialog */
/* open the items dialog, locking is handled in the object */
panel_item_dialog_show (window);
break;
case PROVIDER_SIGNAL_PANEL_PREFERENCES:
/* open the panel preferences */
/* open the panel preferences, locking is handled in the object */
panel_preferences_dialog_show (window);
break;
@ -571,6 +582,10 @@ panel_application_plugin_insert (PanelApplication *application,
panel_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
panel_return_val_if_fail (name != NULL, FALSE);
/* leave if the window is locked */
if (panel_window_get_locked (window))
return FALSE;
/* create a new panel plugin */
provider = panel_module_factory_new_plugin (application->factory,
name, screen, unique_id,
@ -720,6 +735,13 @@ panel_application_drag_data_received (PanelWindow *window,
panel_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
panel_return_if_fail (PANEL_IS_ITEMBAR (itembar));
/* we don't allow any kind of drops here when the panel is locked */
if (panel_window_get_locked (window))
{
gdk_drag_status (context, 0, drag_time);
return;
}
/* get the application */
application = panel_application_get ();
@ -865,6 +887,10 @@ panel_application_drag_motion (GtkWidget *window,
panel_return_val_if_fail (PANEL_IS_APPLICATION (application), FALSE);
panel_return_val_if_fail (!application->drop_occurred, FALSE);
/* don't allow anything when the window is locked */
if (panel_window_get_locked (PANEL_WINDOW (window)))
goto not_a_drop_zone;
/* determine the drag target */
target = gtk_drag_dest_find_target (window, context, NULL);
@ -904,6 +930,7 @@ panel_application_drag_motion (GtkWidget *window,
panel_itembar_get_drop_index (PANEL_ITEMBAR (itembar), x, y));
}
not_a_drop_zone:
gdk_drag_status (context, drag_action, drag_time);
return (drag_action == 0);
@ -1007,6 +1034,10 @@ panel_application_save (PanelApplication *application,
for (li = application->windows, i = 0; li != NULL; li = li->next, i++)
{
/* skip this window if it is locked */
if (panel_window_get_locked (li->data))
continue;
/* get the itembar children */
itembar = gtk_bin_get_child (GTK_BIN (li->data));
children = gtk_container_get_children (GTK_CONTAINER (itembar));
@ -1053,7 +1084,8 @@ panel_application_save (PanelApplication *application,
}
/* store the number of panels */
xfconf_channel_set_uint (channel, "/panels", i);
if (!xfconf_channel_is_property_locked (channel, "/panels"))
xfconf_channel_set_uint (channel, "/panels", i);
}
@ -1311,3 +1343,29 @@ panel_application_windows_autohide (PanelApplication *application,
panel_window_thaw_autohide (PANEL_WINDOW (li->data));
}
}
gboolean
panel_application_get_locked (PanelApplication *application)
{
GSList *li;
panel_return_val_if_fail (PANEL_IS_APPLICATION (application), TRUE);
panel_return_val_if_fail (XFCONF_IS_CHANNEL (application->xfconf), TRUE);
/* don't even look for the individual window if the
* entire channel is locked */
if (xfconf_channel_is_property_locked (application->xfconf, "/"))
return TRUE;
/* if one of the windows is not locked, the user can still modify
* some settings, so then we return %FALSE */
for (li = application->windows; li != NULL; li = li->next)
if (!panel_window_get_locked (li->data))
return FALSE;
/* TODO we could extend this to a plugin basis (ie. panels are
* locked but maybe not all the plugins) */
return TRUE;
}

2
panel/panel-application.h

@ -75,6 +75,8 @@ void panel_application_windows_sensitive (PanelApplication *applic
void panel_application_windows_autohide (PanelApplication *application,
gboolean freeze);
gboolean panel_application_get_locked (PanelApplication *application);
G_END_DECLS
#endif /* !__PANEL_APPLICATION_H__ */

24
panel/panel-dialogs.c

@ -26,6 +26,7 @@
#include <exo/exo.h>
#include <libxfce4util/libxfce4util.h>
#include <libxfce4ui/libxfce4ui.h>
#include <common/panel-private.h>
#include <libxfce4panel/libxfce4panel.h>
@ -146,6 +147,29 @@ panel_dialogs_choose_panel (PanelApplication *application)
gboolean
panel_dialogs_kiosk_warning (void)
{
PanelApplication *application;
gboolean locked;
application = panel_application_get ();
locked = panel_application_get_locked (application);
g_object_unref (G_OBJECT (application));
if (locked)
{
xfce_dialog_show_warning (NULL,
_("Because the panel is running in kiosk mode, you are not allowed "
"to make changes to the panel configuration as a regular user"),
_("Modifying the panel is not allowed"));
}
return locked;
}
gboolean
panel_dialogs_restart_plugin (GtkWindow *parent,
const gchar *plugin_name)

2
panel/panel-dialogs.h

@ -28,6 +28,8 @@ void panel_dialogs_show_about (void);
gint panel_dialogs_choose_panel (PanelApplication *application);
gboolean panel_dialogs_kiosk_warning (void);
gboolean panel_dialogs_restart_plugin (GtkWindow *parent,
const gchar *plugin_name);

5
panel/panel-item-dialog.c

@ -33,6 +33,7 @@
#include <panel/panel-application.h>
#include <panel/panel-item-dialog.h>
#include <panel/panel-dialogs.h>
#include <panel/panel-module.h>
#include <panel/panel-module-factory.h>
#include <panel/panel-preferences-dialog.h>
@ -701,6 +702,10 @@ panel_item_dialog_show (PanelWindow *window)
panel_return_if_fail (window == NULL || PANEL_IS_WINDOW (window));
/* check if not the entire application is locked */
if (panel_dialogs_kiosk_warning ())
return;
if (G_LIKELY (dialog_singleton == NULL))
{
/* create new dialog singleton */

17
panel/panel-plugin-external-46.c

@ -85,6 +85,8 @@ static void panel_plugin_external_46_removed (XfcePanelPlu
static gboolean panel_plugin_external_46_remote_event (XfcePanelPluginProvider *provider,
const gchar *name,
const GValue *value);
static void panel_plugin_external_46_set_locked (XfcePanelPluginProvider *provider,
gboolean locked);
static void panel_plugin_external_46_set_sensitive (PanelPluginExternal46 *external);
static void panel_plugin_external_46_child_watch (GPid pid,
gint status,
@ -235,6 +237,7 @@ panel_plugin_external_46_provider_init (XfcePanelPluginProviderInterface *iface)
iface->show_about = panel_plugin_external_46_show_about;
iface->removed = panel_plugin_external_46_removed;
iface->remote_event = panel_plugin_external_46_remote_event;
iface->set_locked = panel_plugin_external_46_set_locked;
}
@ -740,6 +743,20 @@ panel_plugin_external_46_remote_event (XfcePanelPluginProvider *provider,
static void
panel_plugin_external_46_set_locked (XfcePanelPluginProvider *provider,
gboolean locked)
{
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL_46 (provider));
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
panel_plugin_external_46_queue_add (PANEL_PLUGIN_EXTERNAL_46 (provider),
PANEL_CLIENT_EVENT_SET_LOCKED,
locked);
}
static void
panel_plugin_external_46_set_sensitive (PanelPluginExternal46 *external)
{

23
panel/panel-plugin-external.c

@ -99,6 +99,8 @@ static void panel_plugin_external_removed (XfcePanelPlugin
static gboolean panel_plugin_external_remote_event (XfcePanelPluginProvider *provider,
const gchar *name,
const GValue *value);
static void panel_plugin_external_set_locked (XfcePanelPluginProvider *provider,
gboolean locked);
static void panel_plugin_external_set_sensitive (PanelPluginExternal *external);
static void panel_plugin_external_child_watch (GPid pid,
gint status,
@ -268,6 +270,7 @@ panel_plugin_external_provider_init (XfcePanelPluginProviderInterface *iface)
iface->show_about = panel_plugin_external_show_about;
iface->removed = panel_plugin_external_removed;
iface->remote_event = panel_plugin_external_remote_event;
iface->set_locked = panel_plugin_external_set_locked;
}
@ -852,6 +855,26 @@ panel_plugin_external_remote_event (XfcePanelPluginProvider *provider,
static void
panel_plugin_external_set_locked (XfcePanelPluginProvider *provider,
gboolean locked)
{
GValue value = { 0, };
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (provider));
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
g_value_init (&value, G_TYPE_BOOLEAN);
g_value_set_boolean (&value, locked);
panel_plugin_external_queue_add (PANEL_PLUGIN_EXTERNAL (provider),
FALSE, SIGNAL_SET_LOCKED, &value);
g_value_unset (&value);
}
static void
panel_plugin_external_set_sensitive (PanelPluginExternal *external)
{

19
panel/panel-preferences-dialog.c

@ -31,6 +31,7 @@
#include <panel/panel-window.h>
#include <panel/panel-application.h>
#include <panel/panel-dialogs.h>
#include <panel/panel-module.h>
#include <panel/panel-itembar.h>
#include <panel/panel-item-dialog.h>
@ -353,7 +354,7 @@ panel_preferences_dialog_bindings_update (PanelPreferencesDialog *dialog)
/* hook up the bindings */
panel_preferences_dialog_bindings_add (dialog, "horizontal", "active");
panel_preferences_dialog_bindings_add (dialog, "span-monitors", "active");
panel_preferences_dialog_bindings_add (dialog, "locked", "active");
panel_preferences_dialog_bindings_add (dialog, "position-locked", "active");
panel_preferences_dialog_bindings_add (dialog, "autohide", "active");
panel_preferences_dialog_bindings_add (dialog, "size", "value");
panel_preferences_dialog_bindings_add (dialog, "length", "value");
@ -519,6 +520,7 @@ panel_preferences_dialog_panel_combobox_changed (GtkComboBox *combobo
gint nth;
GtkWidget *itembar;
GObject *object;
gboolean locked = TRUE;
panel_return_if_fail (GTK_IS_COMBO_BOX (combobox));
panel_return_if_fail (PANEL_IS_PREFERENCES_DIALOG (dialog));
@ -548,8 +550,19 @@ panel_preferences_dialog_panel_combobox_changed (GtkComboBox *combobo
/* update the items treeview */
panel_preferences_dialog_item_store_rebuild (itembar, dialog);
/* make the entire notebook insensitive when the window is locked */
locked = panel_window_get_locked (dialog->active);
object = gtk_builder_get_object (GTK_BUILDER (dialog), "notebook");
panel_return_if_fail (GTK_IS_WIDGET (object));
gtk_widget_set_sensitive (GTK_WIDGET (object), !locked);
}
/* sensitivity of the remove button */
object = gtk_builder_get_object (GTK_BUILDER (dialog), "panel-remove");
panel_return_if_fail (GTK_IS_WIDGET (object));
gtk_widget_set_sensitive (GTK_WIDGET (object), !locked);
/* sensitivity of the add button in item tab */
object = gtk_builder_get_object (GTK_BUILDER (dialog), "item-add");
panel_return_if_fail (GTK_IS_WIDGET (object));
@ -973,6 +986,10 @@ panel_preferences_dialog_show (PanelWindow *active)
panel_return_if_fail (active == NULL || PANEL_IS_WINDOW (active));
/* check if not the entire application is locked */
if (panel_dialogs_kiosk_warning ())
return;
if (G_LIKELY (dialog_singleton == NULL))
{
/* create new dialog singleton */

2
panel/panel-preferences-dialog.glade

@ -229,7 +229,7 @@
</packing>
</child>
<child>
<object class="GtkCheckButton" id="locked">
<object class="GtkCheckButton" id="position-locked">
<property name="label" translatable="yes">_Lock panel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>

122
panel/panel-window.c

@ -135,7 +135,7 @@ enum
PROP_HORIZONTAL,
PROP_SIZE,
PROP_LENGTH,
PROP_LOCKED,
PROP_POSITION_LOCKED,
PROP_AUTOHIDE,
PROP_SPAN_MONITORS,
PROP_OUTPUT_NAME,
@ -221,6 +221,10 @@ struct _PanelWindow
{
PanelBaseWindow __parent__;
/* whether the user is allowed to make
* changes to this window */
guint locked : 1;
/* screen and working area of this panel */
GdkScreen *screen;
GdkRectangle area;
@ -251,8 +255,8 @@ struct _PanelWindow
gint popup_delay;
gint popdown_delay;
/* whether the window is locked */
guint locked : 1;
/* whether the window position is locked */
guint position_locked : 1;
/* window base point */
gint base_x;
@ -327,8 +331,8 @@ panel_window_class_init (PanelWindowClass *klass)
EXO_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_LOCKED,
g_param_spec_boolean ("locked", NULL, NULL,
PROP_POSITION_LOCKED,
g_param_spec_boolean ("position-locked", NULL, NULL,
FALSE,
EXO_PARAM_READWRITE));
@ -391,6 +395,7 @@ panel_window_class_init (PanelWindowClass *klass)
static void
panel_window_init (PanelWindow *window)
{
window->locked = TRUE;
window->screen = NULL;
window->struts_edge = STRUTS_EDGE_NONE;
window->struts_disabled = FALSE;
@ -399,7 +404,7 @@ panel_window_init (PanelWindow *window)
window->length = 0.10;
window->snap_position = SNAP_POSITION_NONE;
window->span_monitors = FALSE;
window->locked = FALSE;
window->position_locked = FALSE;
window->autohide_state = AUTOHIDE_DISABLED;
window->autohide_timeout_id = 0;
window->autohide_block = 0;
@ -453,8 +458,8 @@ panel_window_get_property (GObject *object,
g_value_set_uint (value, rint (window->length * 100.00));
break;
case PROP_LOCKED:
g_value_set_boolean (value, window->locked);
case PROP_POSITION_LOCKED:
g_value_set_boolean (value, window->position_locked);
break;
case PROP_AUTOHIDE:
@ -557,11 +562,11 @@ panel_window_set_property (GObject *object,
}
break;
case PROP_LOCKED:
case PROP_POSITION_LOCKED:
val_bool = g_value_get_boolean (value);
if (window->locked != val_bool)
if (window->position_locked != val_bool)
{
window->locked = !!val_bool;
window->position_locked = !!val_bool;
gtk_widget_queue_resize (GTK_WIDGET (window));
}
break;
@ -661,7 +666,7 @@ panel_window_expose_event (GtkWidget *widget,
/* expose the background and borders handled in PanelBaseWindow */
(*GTK_WIDGET_CLASS (panel_window_parent_class)->expose_event) (widget, event);
if (window->locked || !GTK_WIDGET_DRAWABLE (widget))
if (window->position_locked || !GTK_WIDGET_DRAWABLE (widget))
goto end;
if (window->horizontal)
@ -891,7 +896,7 @@ panel_window_button_press_event (GtkWidget *widget,
if (event->button == 1
&& event->type == GDK_BUTTON_PRESS
&& !window->locked
&& !window->position_locked
&& modifiers == 0)
{
panel_return_val_if_fail (window->grab_time == 0, FALSE);
@ -995,7 +1000,7 @@ panel_window_size_request (GtkWidget *widget,
gtk_widget_size_request (GTK_BIN (widget)->child, &child_requisition);
/* handle size */
if (!window->locked)
if (!window->position_locked)
{
if (window->horizontal)
extra_width += 2 * HANDLE_SIZE_TOTAL;
@ -1108,7 +1113,7 @@ panel_window_size_allocate (GtkWidget *widget,
child_alloc.height--;
/* keep space for the panel handles if not locked */
if (!window->locked)
if (!window->position_locked)
{
if (window->horizontal)
{
@ -2004,16 +2009,6 @@ panel_window_menu_deactivate (GtkMenu *menu,
static void
panel_window_menu_add_items (PanelWindow *window)
{
panel_return_if_fail (PANEL_IS_WINDOW (window));
panel_item_dialog_show (window);
}
static void
panel_window_menu_popup (PanelWindow *window,
guint32 event_time)
@ -2042,31 +2037,34 @@ panel_window_menu_popup (PanelWindow *window,
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* add new items */
item = gtk_image_menu_item_new_with_mnemonic (_("Add _New Items..."));
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (panel_window_menu_add_items), window);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
/* customize panel */
item = gtk_image_menu_item_new_with_mnemonic (_("Panel Pr_eferences..."));
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (panel_preferences_dialog_show), window);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
if (!panel_window_get_locked (window))
{
/* add new items */
item = gtk_image_menu_item_new_with_mnemonic (_("Add _New Items..."));
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (panel_item_dialog_show), window);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
/* customize panel */
item = gtk_image_menu_item_new_with_mnemonic (_("Panel Pr_eferences..."));
g_signal_connect_swapped (G_OBJECT (item), "activate",
G_CALLBACK (panel_preferences_dialog_show), window);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
}
/* quit item */
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
@ -2227,6 +2225,9 @@ panel_window_set_povider_info (PanelWindow *window,
panel_window_set_plugin_orientation (provider, window);
panel_window_set_plugin_screen_position (provider, window);
xfce_panel_plugin_provider_set_locked (XFCE_PANEL_PLUGIN_PROVIDER (provider),
panel_window_get_locked (window));
if (PANEL_BASE_WINDOW (window)->background_alpha < 1.0)
{
if (PANEL_IS_PLUGIN_EXTERNAL (provider))
@ -2269,3 +2270,24 @@ panel_window_thaw_autohide (PanelWindow *window)
&& window->autohide_state != AUTOHIDE_DISABLED)
panel_window_autohide_queue (window, AUTOHIDE_POPDOWN);
}
void
panel_window_set_locked (PanelWindow *window,
gboolean locked)
{
panel_return_if_fail (PANEL_IS_WINDOW (window));
window->locked = locked;
}
gboolean
panel_window_get_locked (PanelWindow *window)
{
panel_return_val_if_fail (PANEL_IS_WINDOW (window), TRUE);
return window->locked;
}

5
panel/panel-window.h

@ -44,6 +44,11 @@ void panel_window_freeze_autohide (PanelWindow *window);
void panel_window_thaw_autohide (PanelWindow *window);
void panel_window_set_locked (PanelWindow *window,
gboolean locked);
gboolean panel_window_get_locked (PanelWindow *window);
G_END_DECLS
#endif /* !__PANEL_WINDOW_H__ */

2
wrapper/main.c

@ -93,6 +93,8 @@ wrapper_gproxy_set (DBusGProxy *dbus_gproxy,
xfce_panel_plugin_provider_set_orientation (provider, g_value_get_uint (value));
else if (strcmp (property, SIGNAL_SET_SCREEN_POSITION) == 0)
xfce_panel_plugin_provider_set_screen_position (provider, g_value_get_uint (value));
else if (strcmp (property, SIGNAL_SET_LOCKED) == 0)
xfce_panel_plugin_provider_set_locked (provider, g_value_get_boolean (value));
else if (strcmp (property, SIGNAL_WRAPPER_BACKGROUND_ALPHA) == 0)
{
plug = g_object_get_qdata (G_OBJECT (provider), plug_quark);

Loading…
Cancel
Save