[Xfce4-commits] <xfce4-panel:devel> Implement removed signal in panel plugin.
Nick Schermer
noreply at xfce.org
Tue Sep 29 11:16:01 CEST 2009
Updating branch refs/heads/devel
to 582a62fcb6bee2df6e58113fe1f69cc4df574563 (commit)
from 741a69c403b2c6556536eb700f567951713eb99f (commit)
commit 582a62fcb6bee2df6e58113fe1f69cc4df574563
Author: Nick Schermer <nick at xfce.org>
Date: Tue Sep 29 11:12:11 2009 +0200
Implement removed signal in panel plugin.
This signal is only emitted when the user permanently removes
a plugin from the panel and can be used by developers to
removed custom settings. Bug #5694.
common/panel-dbus.h | 1 +
libxfce4panel/xfce-panel-plugin-provider.c | 22 ++++++++--
libxfce4panel/xfce-panel-plugin-provider.h | 3 +
libxfce4panel/xfce-panel-plugin.c | 58 +++++++++++++++++++++++-----
libxfce4panel/xfce-panel-plugin.h | 1 +
panel/panel-application.c | 3 +
panel/panel-plugin-external.c | 15 +++++++
wrapper/main.c | 4 ++
wrapper/wrapper-plug.c | 2 +-
9 files changed, 93 insertions(+), 16 deletions(-)
diff --git a/common/panel-dbus.h b/common/panel-dbus.h
index a659495..e4658e2 100644
--- a/common/panel-dbus.h
+++ b/common/panel-dbus.h
@@ -36,6 +36,7 @@ enum _DBusPropertyChanged
PROPERTY_CHANGED_PROVIDER_EMIT_SAVE,
PROPERTY_CHANGED_PROVIDER_EMIT_SHOW_CONFIGURE,
PROPERTY_CHANGED_PROVIDER_EMIT_SHOW_ABOUT,
+ PROPERTY_CHANGED_PROVIDER_REMOVE,
/* wrapper plug */
PROPERTY_CHANGED_WRAPPER_BACKGROUND_ALPHA,
diff --git a/libxfce4panel/xfce-panel-plugin-provider.c b/libxfce4panel/xfce-panel-plugin-provider.c
index 5854e75..825c2a6 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.c
+++ b/libxfce4panel/xfce-panel-plugin-provider.c
@@ -36,7 +36,8 @@ enum
-static void xfce_panel_plugin_provider_class_init (gpointer klass);
+static void xfce_panel_plugin_provider_class_init (gpointer klass,
+ gpointer klass_data);
@@ -53,7 +54,7 @@ xfce_panel_plugin_provider_get_type (void)
{
type = g_type_register_static_simple (G_TYPE_INTERFACE, I_("XfcePanelPluginProvider"),
sizeof (XfcePanelPluginProviderIface),
- (GClassInitFunc) xfce_panel_plugin_provider_class_init,
+ xfce_panel_plugin_provider_class_init,
0, NULL, 0);
}
@@ -63,7 +64,8 @@ xfce_panel_plugin_provider_get_type (void)
static void
-xfce_panel_plugin_provider_class_init (gpointer klass)
+xfce_panel_plugin_provider_class_init (gpointer klass,
+ gpointer klass_data)
{
provider_signals[PROVIDER_SIGNAL] =
g_signal_new (I_("provider-signal"),
@@ -167,7 +169,7 @@ xfce_panel_plugin_provider_show_configure (XfcePanelPluginProvider *provider)
{
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
- return (*XFCE_PANEL_PLUGIN_PROVIDER_GET_IFACE (provider)->show_configure) (provider);
+ (*XFCE_PANEL_PLUGIN_PROVIDER_GET_IFACE (provider)->show_configure) (provider);
}
@@ -187,5 +189,15 @@ xfce_panel_plugin_provider_show_about (XfcePanelPluginProvider *provider)
{
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
- return (*XFCE_PANEL_PLUGIN_PROVIDER_GET_IFACE (provider)->show_about) (provider);
+ (*XFCE_PANEL_PLUGIN_PROVIDER_GET_IFACE (provider)->show_about) (provider);
+}
+
+
+
+void
+xfce_panel_plugin_provider_remove (XfcePanelPluginProvider *provider)
+{
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+
+ (*XFCE_PANEL_PLUGIN_PROVIDER_GET_IFACE (provider)->remove) (provider);
}
diff --git a/libxfce4panel/xfce-panel-plugin-provider.h b/libxfce4panel/xfce-panel-plugin-provider.h
index d433c0c..007db13 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.h
+++ b/libxfce4panel/xfce-panel-plugin-provider.h
@@ -67,6 +67,7 @@ struct _XfcePanelPluginProviderIface
void (*show_configure) (XfcePanelPluginProvider *provider);
gboolean (*get_show_about) (XfcePanelPluginProvider *provider);
void (*show_about) (XfcePanelPluginProvider *provider);
+ void (*remove) (XfcePanelPluginProvider *provider);
};
/* signals send from the plugin to the panel (possibly
@@ -121,6 +122,8 @@ gboolean xfce_panel_plugin_provider_get_show_about (XfcePanelPluginProv
void xfce_panel_plugin_provider_show_about (XfcePanelPluginProvider *provider);
+void xfce_panel_plugin_provider_remove (XfcePanelPluginProvider *provider);
+
G_END_DECLS
#endif /* !__XFCE_PANEL_PLUGIN_PROVIDER_H__ */
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index 70b50d7..d314fc2 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -77,6 +77,7 @@ static gboolean xfce_panel_plugin_get_show_configure (XfcePanelPluginPr
static void xfce_panel_plugin_show_configure (XfcePanelPluginProvider *provider);
static gboolean xfce_panel_plugin_get_show_about (XfcePanelPluginProvider *provider);
static void xfce_panel_plugin_show_about (XfcePanelPluginProvider *provider);
+static void xfce_panel_plugin_remove (XfcePanelPluginProvider *provider);
static void xfce_panel_plugin_take_window_notify (gpointer data,
GObject *where_the_object_was);
@@ -102,6 +103,7 @@ enum
CONFIGURE_PLUGIN,
FREE_DATA,
ORIENTATION_CHANGED,
+ REMOVED,
SAVE,
SIZE_CHANGED,
SCREEN_POSITION_CHANGED,
@@ -258,6 +260,30 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
G_TYPE_NONE, 1, GTK_TYPE_ORIENTATION);
/**
+ * XfcePanelPlugin::removed
+ * @plugin : an #XfcePanelPlugin.
+ *
+ * This signal is emmitted when the plugin is permanently removed from
+ * the panel configuration by the user. Developers can use this signal
+ * to cleanup custom setting locations that for example store passwords.
+ *
+ * Note that if you use the xfconf channel and base property provided
+ * by xfce_panel_plugin_get_property_base() or the rc file location
+ * returned by xfce_panel_plugin_save_location(), the panel will take
+ * care of removing those settings.
+ *
+ * Since: 4.8
+ **/
+ plugin_signals[REMOVED] =
+ g_signal_new (I_("removed"),
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (XfcePanelPluginClass, removed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
* XfcePanelPlugin::save
* @plugin : an #XfcePanelPlugin.
*
@@ -483,6 +509,7 @@ xfce_panel_plugin_provider_init (XfcePanelPluginProviderIface *iface)
iface->show_configure = xfce_panel_plugin_show_configure;
iface->get_show_about = xfce_panel_plugin_get_show_about;
iface->show_about = xfce_panel_plugin_show_about;
+ iface->remove = xfce_panel_plugin_remove;
}
@@ -709,36 +736,36 @@ xfce_panel_plugin_menu_move (XfcePanelPlugin *plugin)
static void
xfce_panel_plugin_menu_remove (XfcePanelPlugin *plugin)
{
- GtkWidget *widget;
+ GtkWidget *dialog;
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
/* create question dialog (same code is also in panel-preferences-dialog.c) */
- widget = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
_("Are you sure that you want to remove \"%s\"?"),
xfce_panel_plugin_get_display_name (plugin));
- gtk_window_set_screen (GTK_WINDOW (widget),
+ gtk_window_set_screen (GTK_WINDOW (dialog),
gtk_widget_get_screen (GTK_WIDGET (plugin)));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (widget),
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
_("If you remove the item from the panel, it is permanently lost."));
- gtk_dialog_add_buttons (GTK_DIALOG (widget), GTK_STOCK_CANCEL,
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog), GTK_STOCK_CANCEL,
GTK_RESPONSE_NO, GTK_STOCK_REMOVE, GTK_RESPONSE_YES, NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (widget), GTK_RESPONSE_NO);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_NO);
/* run the dialog */
- if (gtk_dialog_run (GTK_DIALOG (widget)) == GTK_RESPONSE_YES)
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES)
{
/* hide the dialog */
- gtk_widget_hide (widget);
+ gtk_widget_hide (dialog);
/* ask the panel or wrapper to remove the plugin */
xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
PROVIDER_SIGNAL_REMOVE_PLUGIN);
}
- /* destroy */
- gtk_widget_destroy (widget);
+ /* destroy window */
+ gtk_widget_destroy (dialog);
}
@@ -1148,6 +1175,17 @@ xfce_panel_plugin_show_about (XfcePanelPluginProvider *provider)
static void
+xfce_panel_plugin_remove (XfcePanelPluginProvider *provider)
+{
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
+
+ /* emit removed signal */
+ g_signal_emit (G_OBJECT (provider), plugin_signals[REMOVED], 0);
+}
+
+
+
+static void
xfce_panel_plugin_take_window_notify (gpointer data,
GObject *where_the_object_was)
{
diff --git a/libxfce4panel/xfce-panel-plugin.h b/libxfce4panel/xfce-panel-plugin.h
index 3c8b812..db6f26b 100644
--- a/libxfce4panel/xfce-panel-plugin.h
+++ b/libxfce4panel/xfce-panel-plugin.h
@@ -58,6 +58,7 @@ struct _XfcePanelPluginClass
void (*save) (XfcePanelPlugin *plugin);
void (*about) (XfcePanelPlugin *plugin);
void (*configure_plugin) (XfcePanelPlugin *plugin);
+ void (*removed) (XfcePanelPlugin *plugin);
/*< private >*/
void (*reserved1) (void);
diff --git a/panel/panel-application.c b/panel/panel-application.c
index 4ce1dc2..7d4553b 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -476,6 +476,9 @@ 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_remove (provider);
+
/* store the provider's unique id and name */
unique_id = xfce_panel_plugin_provider_get_unique_id (provider);
name = g_strdup (xfce_panel_plugin_provider_get_name (provider));
diff --git a/panel/panel-plugin-external.c b/panel/panel-plugin-external.c
index cfd4cfb..de70047 100644
--- a/panel/panel-plugin-external.c
+++ b/panel/panel-plugin-external.c
@@ -66,6 +66,7 @@ static gboolean panel_plugin_external_get_show_configure (XfcePanelPluginPr
static void panel_plugin_external_show_configure (XfcePanelPluginProvider *provider);
static gboolean panel_plugin_external_get_show_about (XfcePanelPluginProvider *provider);
static void panel_plugin_external_show_about (XfcePanelPluginProvider *provider);
+static void panel_plugin_external_remove (XfcePanelPluginProvider *provider);
static void panel_plugin_external_set_sensitive (PanelPluginExternal *external);
static void panel_plugin_external_set_property (PanelPluginExternal *external,
DBusPropertyChanged property,
@@ -174,6 +175,7 @@ panel_plugin_external_provider_init (XfcePanelPluginProviderIface *iface)
iface->show_configure = panel_plugin_external_show_configure;
iface->get_show_about = panel_plugin_external_get_show_about;
iface->show_about = panel_plugin_external_show_about;
+ iface->remove = panel_plugin_external_remove;
}
@@ -662,6 +664,19 @@ panel_plugin_external_show_about (XfcePanelPluginProvider *provider)
static void
+panel_plugin_external_remove (XfcePanelPluginProvider *provider)
+{
+ panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (provider));
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+
+ /* send signal to wrapper */
+ panel_plugin_external_set_property_noop (PANEL_PLUGIN_EXTERNAL (provider),
+ PROPERTY_CHANGED_PROVIDER_REMOVE);
+}
+
+
+
+static void
panel_plugin_external_set_sensitive (PanelPluginExternal *external)
{
GValue value = { 0, };
diff --git a/wrapper/main.c b/wrapper/main.c
index 3426c34..11afb6f 100644
--- a/wrapper/main.c
+++ b/wrapper/main.c
@@ -123,6 +123,10 @@ dbus_gproxy_property_changed (DBusGProxy *dbus_gproxy,
xfce_panel_plugin_provider_show_about (provider);
break;
+ case PROPERTY_CHANGED_PROVIDER_REMOVE:
+ xfce_panel_plugin_provider_remove (provider);
+ break;
+
case PROPERTY_CHANGED_WRAPPER_QUIT:
gtk_main_quit ();
break;
diff --git a/wrapper/wrapper-plug.c b/wrapper/wrapper-plug.c
index 416e9ca..a0c3549 100644
--- a/wrapper/wrapper-plug.c
+++ b/wrapper/wrapper-plug.c
@@ -59,7 +59,7 @@ gchar *wrapper_name = NULL;
-G_DEFINE_TYPE (WrapperPlug, wrapper_plug, GTK_TYPE_PLUG);
+G_DEFINE_TYPE (WrapperPlug, wrapper_plug, GTK_TYPE_PLUG)
More information about the Xfce4-commits
mailing list