[Xfce4-commits] <xfce4-panel:master> Panel: Save plugin-ids when removing and moving items.
Nick Schermer
noreply at xfce.org
Mon Mar 26 19:48:01 CEST 2012
Updating branch refs/heads/master
to 29e84de7e07b5c15de7ac18b88b5de1c511a2dc4 (commit)
from ea4b8412d3733b1e47309820679c236e8da1e037 (commit)
commit 29e84de7e07b5c15de7ac18b88b5de1c511a2dc4
Author: Nick Schermer <nick at xfce.org>
Date: Mon Mar 26 19:45:39 2012 +0200
Panel: Save plugin-ids when removing and moving items.
panel/panel-application.c | 175 +++++++++++++++++++-------------------
panel/panel-application.h | 4 +
panel/panel-preferences-dialog.c | 17 +++-
3 files changed, 107 insertions(+), 89 deletions(-)
diff --git a/panel/panel-application.c b/panel/panel-application.c
index 1f22002..ee5e6dc 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -94,9 +94,6 @@ static void panel_application_drag_leave (GtkWidget *w
GdkDragContext *context,
guint drag_time,
PanelApplication *application);
-static void panel_application_save_window (PanelApplication *application,
- PanelWindow *window,
- PanelSaveTypes save_types);
@@ -692,6 +689,9 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider *provide
/* remove the plugin configuration */
panel_application_plugin_delete_config (application, name, unique_id);
g_free (name);
+
+ /* save new ids */
+ panel_application_save_window (application, window, SAVE_PLUGIN_IDS);
}
break;
@@ -1137,89 +1137,6 @@ panel_application_window_id_exists (PanelApplication *application,
-static void
-panel_application_save_window (PanelApplication *application,
- PanelWindow *window,
- PanelSaveTypes save_types)
-{
- GList *children, *lp;
- GtkWidget *itembar;
- XfcePanelPluginProvider *provider;
- gchar buf[50];
- XfconfChannel *channel = application->xfconf;
- GPtrArray *array = NULL;
- GValue *value;
- gint plugin_id;
- gint panel_id;
-
- /* skip this window if it is locked */
- if (panel_window_get_locked (window)
- || !PANEL_HAS_FLAG (save_types, SAVE_PLUGIN_IDS | SAVE_PLUGIN_PROVIDERS))
- return;
-
- panel_id = panel_window_get_id (window);
- panel_debug (PANEL_DEBUG_APPLICATION,
- "saving /panels/panel-%d: ids=%s, providers=%s",
- panel_id,
- PANEL_DEBUG_BOOL (PANEL_HAS_FLAG (save_types, SAVE_PLUGIN_IDS)),
- PANEL_DEBUG_BOOL (PANEL_HAS_FLAG (save_types, SAVE_PLUGIN_PROVIDERS)));
-
- /* get the itembar children */
- itembar = gtk_bin_get_child (GTK_BIN (window));
- children = gtk_container_get_children (GTK_CONTAINER (itembar));
-
- /* only cleanup and continue if there are no children */
- if (PANEL_HAS_FLAG (save_types, SAVE_PLUGIN_IDS))
- {
- if (G_UNLIKELY (children == NULL))
- {
- g_snprintf (buf, sizeof (buf), "/panels/panel-%d/plugin-ids", panel_id);
- if (xfconf_channel_has_property (channel, buf))
- xfconf_channel_reset_property (channel, buf, FALSE);
- return;
- }
-
- array = g_ptr_array_new ();
- }
-
- /* walk all the plugin children */
- for (lp = children; lp != NULL; lp = lp->next)
- {
- provider = XFCE_PANEL_PLUGIN_PROVIDER (lp->data);
-
- if (array != NULL)
- {
- plugin_id = xfce_panel_plugin_provider_get_unique_id (provider);
-
- /* add plugin id to the array */
- value = g_new0 (GValue, 1);
- g_value_init (value, G_TYPE_INT);
- g_value_set_int (value, plugin_id);
- g_ptr_array_add (array, value);
-
- /* make sure the plugin type-name is store in the plugin item */
- g_snprintf (buf, sizeof (buf), "/plugins/plugin-%d", plugin_id);
- xfconf_channel_set_string (channel, buf, xfce_panel_plugin_provider_get_name (provider));
- }
-
- /* ask the plugin to save */
- if (PANEL_HAS_FLAG (save_types, SAVE_PLUGIN_PROVIDERS))
- xfce_panel_plugin_provider_save (provider);
- }
-
- if (array != NULL)
- {
- /* store the plugin ids for this panel */
- g_snprintf (buf, sizeof (buf), "/panels/panel-%d/plugin-ids", panel_id);
- xfconf_channel_set_arrayv (channel, buf, array);
- xfconf_array_free (array);
- }
-
- g_list_free (children);
-}
-
-
-
PanelApplication *
panel_application_get (void)
{
@@ -1337,6 +1254,92 @@ panel_application_save (PanelApplication *application,
void
+panel_application_save_window (PanelApplication *application,
+ PanelWindow *window,
+ PanelSaveTypes save_types)
+{
+ GList *children, *lp;
+ GtkWidget *itembar;
+ XfcePanelPluginProvider *provider;
+ gchar buf[50];
+ XfconfChannel *channel = application->xfconf;
+ GPtrArray *array = NULL;
+ GValue *value;
+ gint plugin_id;
+ gint panel_id;
+
+ panel_return_if_fail (PANEL_IS_APPLICATION (application));
+ panel_return_if_fail (PANEL_IS_WINDOW (window));
+
+ /* skip this window if it is locked */
+ if (panel_window_get_locked (window)
+ || !PANEL_HAS_FLAG (save_types, SAVE_PLUGIN_IDS | SAVE_PLUGIN_PROVIDERS))
+ return;
+
+ panel_id = panel_window_get_id (window);
+ panel_debug (PANEL_DEBUG_APPLICATION,
+ "saving /panels/panel-%d: ids=%s, providers=%s",
+ panel_id,
+ PANEL_DEBUG_BOOL (PANEL_HAS_FLAG (save_types, SAVE_PLUGIN_IDS)),
+ PANEL_DEBUG_BOOL (PANEL_HAS_FLAG (save_types, SAVE_PLUGIN_PROVIDERS)));
+
+ /* get the itembar children */
+ itembar = gtk_bin_get_child (GTK_BIN (window));
+ children = gtk_container_get_children (GTK_CONTAINER (itembar));
+
+ /* only cleanup and continue if there are no children */
+ if (PANEL_HAS_FLAG (save_types, SAVE_PLUGIN_IDS))
+ {
+ if (G_UNLIKELY (children == NULL))
+ {
+ g_snprintf (buf, sizeof (buf), "/panels/panel-%d/plugin-ids", panel_id);
+ if (xfconf_channel_has_property (channel, buf))
+ xfconf_channel_reset_property (channel, buf, FALSE);
+ return;
+ }
+
+ array = g_ptr_array_new ();
+ }
+
+ /* walk all the plugin children */
+ for (lp = children; lp != NULL; lp = lp->next)
+ {
+ provider = XFCE_PANEL_PLUGIN_PROVIDER (lp->data);
+
+ if (array != NULL)
+ {
+ plugin_id = xfce_panel_plugin_provider_get_unique_id (provider);
+
+ /* add plugin id to the array */
+ value = g_new0 (GValue, 1);
+ g_value_init (value, G_TYPE_INT);
+ g_value_set_int (value, plugin_id);
+ g_ptr_array_add (array, value);
+
+ /* make sure the plugin type-name is store in the plugin item */
+ g_snprintf (buf, sizeof (buf), "/plugins/plugin-%d", plugin_id);
+ xfconf_channel_set_string (channel, buf, xfce_panel_plugin_provider_get_name (provider));
+ }
+
+ /* ask the plugin to save */
+ if (PANEL_HAS_FLAG (save_types, SAVE_PLUGIN_PROVIDERS))
+ xfce_panel_plugin_provider_save (provider);
+ }
+
+ if (array != NULL)
+ {
+ /* store the plugin ids for this panel */
+ g_snprintf (buf, sizeof (buf), "/panels/panel-%d/plugin-ids", panel_id);
+ xfconf_channel_set_arrayv (channel, buf, array);
+ xfconf_array_free (array);
+ }
+
+ g_list_free (children);
+}
+
+
+
+void
panel_application_take_dialog (PanelApplication *application,
GtkWindow *dialog)
{
diff --git a/panel/panel-application.h b/panel/panel-application.h
index ac28119..dbc4df8 100644
--- a/panel/panel-application.h
+++ b/panel/panel-application.h
@@ -54,6 +54,10 @@ void panel_application_load (PanelApplication *applic
void panel_application_save (PanelApplication *application,
PanelSaveTypes save_types);
+void panel_application_save_window (PanelApplication *application,
+ PanelWindow *window,
+ PanelSaveTypes save_types);
+
void panel_application_take_dialog (PanelApplication *application,
GtkWindow *dialog);
diff --git a/panel/panel-preferences-dialog.c b/panel/panel-preferences-dialog.c
index 7fbabd6..05ccfcb 100644
--- a/panel/panel-preferences-dialog.c
+++ b/panel/panel-preferences-dialog.c
@@ -1031,6 +1031,11 @@ panel_preferences_dialog_item_move (GtkWidget *button,
GTK_WIDGET (provider),
position + direction);
+ /* save the new ids */
+ panel_application_save_window (dialog->application,
+ dialog->active,
+ SAVE_PLUGIN_IDS);
+
/* unblock the changed signal */
g_signal_handler_unblock (G_OBJECT (itembar), dialog->items_changed_handler_id);
@@ -1208,9 +1213,15 @@ panel_preferences_dialog_item_row_changed (GtkTreeModel *model,
/* move the item on the panel */
if (position != store_position)
- panel_itembar_reorder_child (PANEL_ITEMBAR (itembar),
- GTK_WIDGET (provider),
- store_position);
+ {
+ panel_itembar_reorder_child (PANEL_ITEMBAR (itembar),
+ GTK_WIDGET (provider),
+ store_position);
+
+ panel_application_save_window (dialog->application,
+ dialog->active,
+ SAVE_PLUGIN_IDS);
+ }
}
More information about the Xfce4-commits
mailing list