[Xfce4-commits] <xfce4-panel:master> Remove plugin when dropping in items dialog (bug #6976).
Nick Schermer
noreply at xfce.org
Tue Dec 21 21:26:01 CET 2010
Updating branch refs/heads/master
to de21c4eeb536a82ce7473a05f358373745f75330 (commit)
from 79310a0c941bb29791ea97b47724bc7dbf04c974 (commit)
commit de21c4eeb536a82ce7473a05f358373745f75330
Author: Nick Schermer <nick at xfce.org>
Date: Sat Dec 18 13:26:33 2010 +0100
Remove plugin when dropping in items dialog (bug #6976).
libxfce4panel/xfce-panel-macros-46.h | 4 ++
libxfce4panel/xfce-panel-plugin-provider.c | 9 +++
libxfce4panel/xfce-panel-plugin-provider.h | 6 ++-
libxfce4panel/xfce-panel-plugin.c | 12 ++++
panel/panel-application.c | 21 +++++++
panel/panel-item-dialog.c | 80 ++++++++++++++++++++++------
panel/panel-plugin-external.c | 14 +++++
wrapper/main.c | 4 ++
8 files changed, 132 insertions(+), 18 deletions(-)
diff --git a/libxfce4panel/xfce-panel-macros-46.h b/libxfce4panel/xfce-panel-macros-46.h
index fd97159..bf1557b 100644
--- a/libxfce4panel/xfce-panel-macros-46.h
+++ b/libxfce4panel/xfce-panel-macros-46.h
@@ -363,6 +363,10 @@ G_BEGIN_DECLS
gtk_widget_queue_draw (plug); \
break; \
\
+ case PROVIDER_PROP_TYPE_ACTION_ASK_REMOVE: \
+ xfce_panel_plugin_provider_ask_remove (provider); \
+ break; \
+ \
default: \
g_warning ("Received unknow client event %u", type); \
break; \
diff --git a/libxfce4panel/xfce-panel-plugin-provider.c b/libxfce4panel/xfce-panel-plugin-provider.c
index ab1caa3..cc73c53 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.c
+++ b/libxfce4panel/xfce-panel-plugin-provider.c
@@ -246,5 +246,14 @@ xfce_panel_plugin_provider_set_locked (XfcePanelPluginProvider *provider,
+void
+xfce_panel_plugin_provider_ask_remove (XfcePanelPluginProvider *provider)
+{
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+
+ (*XFCE_PANEL_PLUGIN_PROVIDER_GET_INTERFACE (provider)->ask_remove) (provider);
+}
+
+
#define __XFCE_PANEL_PLUGIN_PROVIDER_C__
#include <libxfce4panel/libxfce4panel-aliasdef.c>
diff --git a/libxfce4panel/xfce-panel-plugin-provider.h b/libxfce4panel/xfce-panel-plugin-provider.h
index cf82e3a..59b6a68 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.h
+++ b/libxfce4panel/xfce-panel-plugin-provider.h
@@ -68,6 +68,7 @@ struct _XfcePanelPluginProviderInterface
guint *handle);
void (*set_locked) (XfcePanelPluginProvider *provider,
gboolean locked);
+ void (*ask_remove) (XfcePanelPluginProvider *provider);
};
/* signals send from the plugin to the panel (possibly through the wrapper) */
@@ -109,7 +110,8 @@ typedef enum /*< skip >*/
PROVIDER_PROP_TYPE_ACTION_QUIT_FOR_RESTART, /* none */
PROVIDER_PROP_TYPE_ACTION_BACKGROUND_UNSET, /* none */
PROVIDER_PROP_TYPE_ACTION_SHOW_CONFIGURE, /* none */
- PROVIDER_PROP_TYPE_ACTION_SHOW_ABOUT /* none */
+ PROVIDER_PROP_TYPE_ACTION_SHOW_ABOUT, /* none */
+ PROVIDER_PROP_TYPE_ACTION_ASK_REMOVE /* none */
}
XfcePanelPluginProviderPropType;
@@ -179,6 +181,8 @@ gboolean xfce_panel_plugin_provider_remote_event (XfcePanelP
void xfce_panel_plugin_provider_set_locked (XfcePanelPluginProvider *provider,
gboolean locked);
+void xfce_panel_plugin_provider_ask_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 e0b039f..b06885a 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -106,6 +106,7 @@ static gboolean xfce_panel_plugin_remote_event (XfcePanelPluginPr
guint *handle);
static void xfce_panel_plugin_set_locked (XfcePanelPluginProvider *provider,
gboolean locked);
+static void xfce_panel_plugin_ask_remove (XfcePanelPluginProvider *provider);
static void xfce_panel_plugin_take_window_notify (gpointer data,
GObject *where_the_object_was);
static void xfce_panel_plugin_menu_item_destroy (GtkWidget *item,
@@ -619,6 +620,7 @@ xfce_panel_plugin_provider_init (XfcePanelPluginProviderInterface *iface)
iface->removed = xfce_panel_plugin_removed;
iface->remote_event = xfce_panel_plugin_remote_event;
iface->set_locked = xfce_panel_plugin_set_locked;
+ iface->ask_remove = xfce_panel_plugin_ask_remove;
}
@@ -1392,6 +1394,16 @@ xfce_panel_plugin_set_locked (XfcePanelPluginProvider *provider,
static void
+xfce_panel_plugin_ask_remove (XfcePanelPluginProvider *provider)
+{
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
+
+ xfce_panel_plugin_menu_remove (XFCE_PANEL_PLUGIN (provider));
+}
+
+
+
+static void
xfce_panel_plugin_take_window_notify (gpointer data,
GObject *where_the_object_was)
{
diff --git a/panel/panel-application.c b/panel/panel-application.c
index 6e268b0..4c9e483 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -365,6 +365,23 @@ panel_application_load (PanelApplication *application)
static void
+panel_application_plugin_move_drag_data_get (GtkWidget *item,
+ GdkDragContext *drag_context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint drag_time,
+ PanelApplication *application)
+{
+ /* set some data, we never use this, but GTK_DEST_DEFAULT_ALL
+ * used in the item dialog requires this */
+ gtk_selection_data_set (selection_data,
+ selection_data->target, 8,
+ (const guchar *) "0", 1);
+}
+
+
+
+static void
panel_application_plugin_move_drag_end (GtkWidget *item,
GdkDragContext *context,
PanelApplication *application)
@@ -375,6 +392,8 @@ panel_application_plugin_move_drag_end (GtkWidget *item,
/* disconnect this signal */
g_signal_handlers_disconnect_by_func (G_OBJECT (item),
G_CALLBACK (panel_application_plugin_move_drag_end), application);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (item),
+ G_CALLBACK (panel_application_plugin_move_drag_data_get), application);
/* make the window sensitive again */
panel_application_windows_sensitive (application, TRUE);
@@ -416,6 +435,8 @@ panel_application_plugin_move (GtkWidget *item,
/* signal to make the window sensitive again on a drag end */
g_signal_connect (G_OBJECT (item), "drag-end",
G_CALLBACK (panel_application_plugin_move_drag_end), application);
+ g_signal_connect (G_OBJECT (item), "drag-data-get",
+ G_CALLBACK (panel_application_plugin_move_drag_data_get), application);
}
diff --git a/panel/panel-item-dialog.c b/panel/panel-item-dialog.c
index f6293e1..3ba0d13 100644
--- a/panel/panel-item-dialog.c
+++ b/panel/panel-item-dialog.c
@@ -68,22 +68,30 @@ static void panel_item_dialog_drag_begin (GtkWidget
static void panel_item_dialog_drag_data_get (GtkWidget *treeview,
GdkDragContext *context,
GtkSelectionData *selection_data,
- guint info,
- guint drag_time,
- PanelItemDialog *dialog);
-static void panel_item_dialog_populate_store (PanelItemDialog *dialog);
-static gint panel_item_dialog_compare_func (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- gpointer user_data);
-static gboolean panel_item_dialog_visible_func (GtkTreeModel *model,
- GtkTreeIter *iter,
- gpointer user_data);
-static void panel_item_dialog_text_renderer (GtkTreeViewColumn *column,
- GtkCellRenderer *renderer,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- gpointer user_data);
+ guint info,
+ guint drag_time,
+ PanelItemDialog *dialog);
+static void panel_item_dialog_drag_data_received (GtkWidget *treeview,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint drag_time,
+ PanelItemDialog *dialog);
+static void panel_item_dialog_populate_store (PanelItemDialog *dialog);
+static gint panel_item_dialog_compare_func (GtkTreeModel *model,
+ GtkTreeIter *a,
+ GtkTreeIter *b,
+ gpointer user_data);
+static gboolean panel_item_dialog_visible_func (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data);
+static void panel_item_dialog_text_renderer (GtkTreeViewColumn *column,
+ GtkCellRenderer *renderer,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data);
@@ -116,7 +124,12 @@ enum
static const GtkTargetEntry drag_targets[] =
{
- { "xfce-panel/plugin-name", 0, 0 },
+ { "xfce-panel/plugin-name", 0, 0 }
+};
+
+static const GtkTargetEntry drop_targets[] =
+{
+ { "xfce-panel/plugin-widget", GTK_TARGET_SAME_APP, 0 }
};
@@ -248,6 +261,11 @@ panel_item_dialog_init (PanelItemDialog *dialog)
g_signal_connect (G_OBJECT (treeview), "drag-begin", G_CALLBACK (panel_item_dialog_drag_begin), dialog);
g_signal_connect (G_OBJECT (treeview), "drag-data-get", G_CALLBACK (panel_item_dialog_drag_data_get), dialog);
+ /* remove plugin when dropping it back in the treeview */
+ gtk_drag_dest_set (GTK_WIDGET (treeview), GTK_DEST_DEFAULT_ALL,
+ drop_targets, G_N_ELEMENTS (drop_targets), GDK_ACTION_MOVE);
+ g_signal_connect (G_OBJECT (treeview), "drag-data-received", G_CALLBACK (panel_item_dialog_drag_data_received), dialog);
+
/* icon renderer */
renderer = gtk_cell_renderer_pixbuf_new ();
column = gtk_tree_view_column_new_with_attributes ("", renderer, "icon-name", COLUMN_ICON_NAME, "sensitive", COLUMN_SENSITIVE, NULL);
@@ -531,6 +549,34 @@ panel_item_dialog_drag_data_get (GtkWidget *treeview,
static void
+panel_item_dialog_drag_data_received (GtkWidget *treeview,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint drag_time,
+ PanelItemDialog *dialog)
+{
+ GtkWidget *widget;
+
+ panel_return_if_fail (GTK_IS_TREE_VIEW (treeview));
+ panel_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
+ panel_return_if_fail (PANEL_IS_ITEM_DIALOG (dialog));
+
+ /* ask the plugin to cleanup when we destroy a panel window */
+ widget = gtk_drag_get_source_widget (context);
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget));
+ xfce_panel_plugin_provider_ask_remove (XFCE_PANEL_PLUGIN_PROVIDER (widget));
+
+ gtk_drag_finish (context, TRUE, FALSE, drag_time);
+
+ g_signal_stop_emission_by_name (G_OBJECT (treeview), "drag-data-received");
+}
+
+
+
+static void
panel_item_dialog_populate_store (PanelItemDialog *dialog)
{
GList *modules, *li;
diff --git a/panel/panel-plugin-external.c b/panel/panel-plugin-external.c
index 9266220..d2a057c 100644
--- a/panel/panel-plugin-external.c
+++ b/panel/panel-plugin-external.c
@@ -101,6 +101,7 @@ static gboolean panel_plugin_external_remote_event (XfcePanelPlug
guint *handler_id);
static void panel_plugin_external_set_locked (XfcePanelPluginProvider *provider,
gboolean locked);
+static void panel_plugin_external_ask_remove (XfcePanelPluginProvider *provider);
static void panel_plugin_external_set_sensitive (PanelPluginExternal *external);
@@ -230,6 +231,7 @@ panel_plugin_external_provider_init (XfcePanelPluginProviderInterface *iface)
iface->removed = panel_plugin_external_removed;
iface->remote_event = panel_plugin_external_remote_event;
iface->set_locked = panel_plugin_external_set_locked;
+ iface->ask_remove = panel_plugin_external_ask_remove;
}
@@ -1000,6 +1002,18 @@ panel_plugin_external_set_locked (XfcePanelPluginProvider *provider,
static void
+panel_plugin_external_ask_remove (XfcePanelPluginProvider *provider)
+{
+ panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (provider));
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+
+ panel_plugin_external_queue_add_action (PANEL_PLUGIN_EXTERNAL (provider),
+ PROVIDER_PROP_TYPE_ACTION_ASK_REMOVE);
+}
+
+
+
+static void
panel_plugin_external_set_sensitive (PanelPluginExternal *external)
{
GValue value = { 0, };
diff --git a/wrapper/main.c b/wrapper/main.c
index 11a04cf..0deb4be 100644
--- a/wrapper/main.c
+++ b/wrapper/main.c
@@ -143,6 +143,10 @@ wrapper_gproxy_set (DBusGProxy *dbus_gproxy,
xfce_panel_plugin_provider_show_about (provider);
break;
+ case PROVIDER_PROP_TYPE_ACTION_ASK_REMOVE:
+ xfce_panel_plugin_provider_ask_remove (provider);
+ break;
+
default:
panel_assert_not_reached ();
break;
More information about the Xfce4-commits
mailing list