[Xfce4-commits] [xfce/xfce4-panel] 04/06: Automatically migrate old "autohide" properties to "autohide-behavior"

noreply at xfce.org noreply at xfce.org
Fri Sep 5 02:12:38 CEST 2014


This is an automated email from the git hooks/post-receive script.

andrzejr pushed a commit to branch master
in repository xfce/xfce4-panel.

commit c75751bd5de0d2369f8203a5ce582f2cd3f674c1
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Tue Jul 29 11:33:40 2014 +0200

    Automatically migrate old "autohide" properties to "autohide-behavior"
    
    We could write a migration script for it to avoid additional code being
    added to the panel itself but the solution presented here is simple and
    works: when a panel is created (e.g. during startup), we check whether
    there is an old "autohide" property in the Xfconf channel. If the new
    "autohide-behavior" property is not yet set, we translate "autohide"
    FALSE and TRUE into "autohide-behavior" NEVER and ALWAYS, respectively.
    We then reset the "autohide" property and thereby achieve an automatic,
    transparent migration from old to new.
---
 panel/panel-application.c |    3 +++
 panel/panel-window.c      |   49 +++++++++++++++++++++++++++++++++++++++++++++
 panel/panel-window.h      |   33 +++++++++++++++++-------------
 3 files changed, 71 insertions(+), 14 deletions(-)

diff --git a/panel/panel-application.c b/panel/panel-application.c
index e5c4aaf..06ad96f 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -313,6 +313,9 @@ panel_application_xfconf_window_bindings (PanelApplication *application,
   /* create the property base */
   property_base = g_strdup_printf ("/panels/panel-%d", panel_window_get_id (window));
 
+  /* migrate old autohide property */
+  panel_window_migrate_autohide_property (window, application->xfconf, property_base);
+
   /* bind all the properties */
   panel_properties_bind (application->xfconf, G_OBJECT (window),
                          property_base, properties, save_properties);
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 363952e..4d7924c 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -36,6 +36,7 @@
 #include <libwnck/libwnck.h>
 
 #include <exo/exo.h>
+#include <xfconf/xfconf.h>
 #include <common/panel-private.h>
 #include <common/panel-debug.h>
 #include <common/panel-utils.h>
@@ -2963,3 +2964,51 @@ panel_window_focus (PanelWindow *window)
   gtk_window_present (GTK_WINDOW (window));
 #endif
 }
+
+
+
+void
+panel_window_migrate_autohide_property (PanelWindow   *window,
+                                        XfconfChannel *xfconf,
+                                        const gchar   *property_base)
+{
+  gboolean autohide;
+  gchar   *new_property;
+  gchar   *old_property;
+
+  panel_return_if_fail (PANEL_IS_WINDOW (window));
+  panel_return_if_fail (XFCONF_IS_CHANNEL (xfconf));
+  panel_return_if_fail (property_base != NULL && *property_base != '\0');
+
+  old_property = g_strdup_printf ("%s/autohide", property_base);
+
+  /* check if we have an old "autohide" property for this panel */
+  if (xfconf_channel_has_property (xfconf, old_property))
+    {
+      new_property = g_strdup_printf ("%s/autohide-behavior", property_base);
+
+      /* migrate from old "autohide" to new "autohide-behavior" if the latter
+       * isn't set already */
+      if (!xfconf_channel_has_property (xfconf, new_property))
+        {
+          /* find out whether or not autohide was enabled in the old config */
+          autohide = xfconf_channel_get_bool (xfconf, old_property, FALSE);
+
+          /* set autohide behavior to always or never, depending on whether it
+           * was enabled in the old configuration */
+          if (xfconf_channel_set_uint (xfconf,
+                                       new_property,
+                                       autohide ? AUTOHIDE_BEHAVIOR_ALWAYS
+                                                : AUTOHIDE_BEHAVIOR_NEVER))
+            {
+              /* remove the old autohide property */
+              xfconf_channel_reset_property (xfconf, old_property, FALSE);
+            }
+        }
+      else
+        {
+          /* the new property is already set, simply remove the old property */
+          xfconf_channel_reset_property (xfconf, old_property, FALSE);
+        }
+    }
+}
diff --git a/panel/panel-window.h b/panel/panel-window.h
index e31d2b6..f5aa603 100644
--- a/panel/panel-window.h
+++ b/panel/panel-window.h
@@ -20,6 +20,7 @@
 #define __PANEL_WINDOW_H__
 
 #include <gtk/gtk.h>
+#include <xfconf/xfconf.h>
 
 G_BEGIN_DECLS
 
@@ -33,29 +34,33 @@ typedef struct _PanelWindow      PanelWindow;
 #define PANEL_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANEL_TYPE_WINDOW))
 #define PANEL_WINDOW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), PANEL_TYPE_WINDOW, PanelWindowClass))
 
-GType      panel_window_get_type         (void) G_GNUC_CONST;
+GType      panel_window_get_type                  (void) G_GNUC_CONST;
 
-GtkWidget *panel_window_new              (GdkScreen   *screen,
-                                          gint         id) G_GNUC_MALLOC;
+GtkWidget *panel_window_new                       (GdkScreen     *screen,
+                                                   gint           id) G_GNUC_MALLOC;
 
-gint       panel_window_get_id           (PanelWindow *window);
+gint       panel_window_get_id                    (PanelWindow   *window);
 
-gboolean   panel_window_has_position     (PanelWindow *window);
+gboolean   panel_window_has_position              (PanelWindow   *window);
 
-void       panel_window_set_povider_info (PanelWindow *window,
-                                          GtkWidget   *provider,
-                                          gboolean     moving_to_other_panel);
+void       panel_window_set_povider_info          (PanelWindow   *window,
+                                                   GtkWidget     *provider,
+                                                   gboolean       moving_to_other_panel);
 
-void       panel_window_freeze_autohide  (PanelWindow *window);
+void       panel_window_freeze_autohide           (PanelWindow   *window);
 
-void       panel_window_thaw_autohide    (PanelWindow *window);
+void       panel_window_thaw_autohide             (PanelWindow   *window);
 
-void       panel_window_set_locked       (PanelWindow *window,
-                                          gboolean     locked);
+void       panel_window_set_locked                (PanelWindow   *window,
+                                                   gboolean       locked);
 
-gboolean   panel_window_get_locked       (PanelWindow *window);
+gboolean   panel_window_get_locked                (PanelWindow   *window);
 
-void       panel_window_focus            (PanelWindow *window);
+void       panel_window_focus                     (PanelWindow   *window);
+
+void       panel_window_migrate_autohide_property (PanelWindow   *window,
+                                                   XfconfChannel *xfconf,
+                                                   const gchar   *property_base);
 
 G_END_DECLS
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list