[gnome-panel/wip/3.0-freeze-break] panel: Add code to import a panel layout in GSettings



commit 9e57c47d3c67fa9bfb71f0e2fb7d2eef75662602
Author: Vincent Untz <vuntz gnome org>
Date:   Thu Mar 24 20:50:45 2011 +0100

    panel: Add code to import a panel layout in GSettings
    
    Now, on first start, we will populate GSettings with a layout.
    
    This is the first step for the migration to GSettings for
    toplevels/objects.

 gnome-panel/Makefile.am     |    3 +
 gnome-panel/main.c          |    6 +
 gnome-panel/panel-layout.c  |  630 +++++++++++++++++++++++++++++++++++++++++++
 gnome-panel/panel-layout.h  |   39 +++
 gnome-panel/panel-schemas.h |   37 +++
 5 files changed, 715 insertions(+), 0 deletions(-)
---
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index 63e0c2f..72051be 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -12,6 +12,7 @@ AM_CPPFLAGS =							\
 	-I$(srcdir)						\
 	-I$(top_builddir)/gnome-panel				\
 	-I$(top_builddir)/gnome-panel/libpanel-util		\
+	-DPANELDATADIR=\""$(datadir)/gnome-panel"\"		\
 	-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"	\
 	-DBUILDERDIR=\""$(uidir)"\"				\
 	-DICONDIR=\""$(datadir)/gnome-panel/pixmaps"\"		\
@@ -64,6 +65,7 @@ panel_sources =			\
 	panel-lockdown.c	\
 	panel-addto.c		\
 	panel-ditem-editor.c	\
+	panel-layout.c		\
 	panel-modules.c		\
 	panel-applet-info.c
 
@@ -111,6 +113,7 @@ panel_headers =			\
 	panel-addto.h		\
 	panel-ditem-editor.h	\
 	panel-icon-names.h	\
+	panel-layout.h		\
 	panel-modules.h		\
 	panel-schemas.h		\
 	panel-applet-info.h
diff --git a/gnome-panel/main.c b/gnome-panel/main.c
index 624961f..d4b502a 100644
--- a/gnome-panel/main.c
+++ b/gnome-panel/main.c
@@ -27,6 +27,7 @@
 #include "panel-stock-icons.h"
 #include "panel-action-protocol.h"
 #include "panel-icon-names.h"
+#include "panel-layout.h"
 #include "xstuff.h"
 
 #include "nothing.cP"
@@ -99,6 +100,11 @@ main (int argc, char **argv)
 
 	panel_profile_load ();
 
+	if (!panel_layout_load ()) {
+		panel_cleanup_do ();
+		return 1;
+	}
+
 	xstuff_init ();
 
 	/* Flush to make sure our struts are seen by everyone starting
diff --git a/gnome-panel/panel-layout.c b/gnome-panel/panel-layout.c
new file mode 100644
index 0000000..eb81243
--- /dev/null
+++ b/gnome-panel/panel-layout.c
@@ -0,0 +1,630 @@
+/*
+ * panel-layout.c:
+ * vim: set et:
+ *
+ * Copyright (C) 2011 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors:
+ *	Vincent Untz <vuntz gnome org>
+ */
+
+
+#include <string.h>
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+#include <gdk/gdk.h>
+
+#include <libpanel-util/panel-cleanup.h>
+#include <libpanel-util/panel-gsettings.h>
+
+#include "panel-schemas.h"
+#include "panel-toplevel.h"
+
+#include "panel-layout.h"
+
+#define PANEL_LAYOUT_ERROR panel_layout_error_quark ()
+static GSettings *layout_settings = NULL;
+
+static GQuark
+panel_layout_error_quark (void)
+{
+        static GQuark ret = 0;
+
+        if (ret == 0)
+                ret = g_quark_from_static_string ("panel_layout_error");
+
+        return ret;
+}
+
+static void
+panel_layout_init (void)
+{
+        if (layout_settings == NULL) {
+                layout_settings = g_settings_new (PANEL_LAYOUT_SCHEMA);
+                panel_cleanup_register (panel_cleanup_unref_and_nullify,
+                                        &layout_settings);
+        }
+}
+
+
+/************************************\
+ * Adding to the layout from a file *
+\************************************/
+
+
+typedef struct {
+        const char *name;
+        GType       type;
+} PanelLayoutKeyDefinition;
+
+static PanelLayoutKeyDefinition panel_layout_toplevel_keys[] = {
+        { PANEL_TOPLEVEL_NAME,            G_TYPE_STRING   },
+        { PANEL_TOPLEVEL_SCREEN,          G_TYPE_INT      },
+        { PANEL_TOPLEVEL_MONITOR,         G_TYPE_INT      },
+        { PANEL_TOPLEVEL_EXPAND,          G_TYPE_BOOLEAN  },
+        { PANEL_TOPLEVEL_ORIENTATION,     G_TYPE_STRING   },
+        { PANEL_TOPLEVEL_SIZE,            G_TYPE_INT      },
+        { PANEL_TOPLEVEL_X,               G_TYPE_INT      },
+        { PANEL_TOPLEVEL_Y,               G_TYPE_INT      },
+        { PANEL_TOPLEVEL_X_RIGHT,         G_TYPE_INT      },
+        { PANEL_TOPLEVEL_Y_BOTTOM,        G_TYPE_INT      },
+        { PANEL_TOPLEVEL_X_CENTERED,      G_TYPE_BOOLEAN  },
+        { PANEL_TOPLEVEL_Y_CENTERED,      G_TYPE_BOOLEAN  },
+        { PANEL_TOPLEVEL_AUTO_HIDE,       G_TYPE_BOOLEAN  },
+        { PANEL_TOPLEVEL_ENABLE_BUTTONS,  G_TYPE_BOOLEAN  },
+        { PANEL_TOPLEVEL_ENABLE_ARROWS,   G_TYPE_BOOLEAN  },
+        { PANEL_TOPLEVEL_HIDE_DELAY,      G_TYPE_INT      },
+        { PANEL_TOPLEVEL_UNHIDE_DELAY,    G_TYPE_INT      },
+        { PANEL_TOPLEVEL_AUTO_HIDE_SIZE,  G_TYPE_INT      },
+        { PANEL_TOPLEVEL_ANIMATION_SPEED, G_TYPE_STRING   }
+};
+
+static PanelLayoutKeyDefinition panel_layout_object_keys[] = {
+        { PANEL_OBJECT_IID_KEY,         G_TYPE_STRING   },
+        { PANEL_OBJECT_TOPLEVEL_ID_KEY, G_TYPE_STRING   },
+        { PANEL_OBJECT_POSITION_KEY,    G_TYPE_INT      },
+        { PANEL_OBJECT_PACK_END_KEY,    G_TYPE_BOOLEAN  }
+};
+
+static gboolean
+panel_layout_append_self_check (GSettings                 *settings,
+                                PanelLayoutKeyDefinition  *key_definitions,
+                                int                        key_definitions_len,
+                                GError                   **error)
+{
+        char **settings_keys = NULL;
+        int    i, j;
+
+        /* Don't do those checks twice; we use a static array with a boolean
+         * for each set of key definitions we might want to check, and mark the
+         * booleans to TRUE once we've entered this function once for a set. */
+        static gboolean self_check_done[2] = {FALSE, FALSE};
+
+        g_assert (key_definitions == panel_layout_toplevel_keys ||
+                  key_definitions == panel_layout_object_keys);
+
+        if (key_definitions == panel_layout_toplevel_keys) {
+            if (self_check_done[0])
+                    return TRUE;
+            else
+                    self_check_done[0] = TRUE;
+        }
+        if (key_definitions == panel_layout_object_keys) {
+            if (self_check_done[1])
+                    return TRUE;
+            else
+                    self_check_done[1] = TRUE;
+        }
+        /* End hacky way of avoiding double-checks */
+
+        g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+        settings_keys = g_settings_list_keys (settings);
+
+        for (i = 0; settings_keys[i] != NULL; i++) {
+                gboolean found = FALSE;
+
+                for (j = 0; j < key_definitions_len; j++) {
+                        if (g_strcmp0 (settings_keys[i],
+                                       key_definitions[j].name) == 0) {
+                                found = TRUE;
+                                break;
+                        }
+                }
+
+                if (!found) {
+                        g_set_error (error, PANEL_LAYOUT_ERROR, 0,
+                                     "Mismatch between keys defined in schema and keys known to gnome-panel ('%s' is not known)",
+                                     settings_keys[i]);
+                        g_strfreev (settings_keys);
+                        return FALSE;
+                }
+        }
+
+        g_strfreev (settings_keys);
+
+        if (i != key_definitions_len) {
+                g_set_error (error, PANEL_LAYOUT_ERROR, 0,
+                             "Mismatch between keys defined in schema and keys known to gnome-panel (%d keys in schema, %d keys known to gnome-panel)",
+                             i, j);
+                return FALSE;
+        }
+
+        return TRUE;
+}
+
+static char *
+panel_layout_find_free_id (const char *id_list_key,
+                           const char *schema,
+                           const char *try_id,
+                           int         screen_for_toplevels)
+{
+        char      *unique_id;
+        char     **existing_ids;
+        gboolean   existing;
+        int        index;
+        int        i;
+
+        /* TODO also check it doesn't exist in dconf */
+        existing_ids = g_settings_get_strv (layout_settings,
+                                            id_list_key);
+
+        index = 0;
+        existing = TRUE;
+
+        /* If a specific id is specified, try to use it; it might be
+         * free */
+        if (try_id) {
+                if (screen_for_toplevels != -1 &&
+                    g_strcmp0 (schema, PANEL_TOPLEVEL_SCHEMA) == 0)
+                        unique_id = g_strdup_printf ("%s-screen%d",
+                                                     try_id,
+                                                     screen_for_toplevels);
+                else
+                        unique_id = g_strdup (try_id);
+
+                existing = FALSE;
+
+                for (i = 0; existing_ids[i] != NULL; i++) {
+                        if (g_strcmp0 (unique_id,
+                                       existing_ids[i]) == 0) {
+                                existing = TRUE;
+                                break;
+                        }
+                }
+
+                if (existing)
+                        g_free (unique_id);
+
+        } else {
+                if (g_strcmp0 (schema, PANEL_TOPLEVEL_SCHEMA) == 0)
+                        try_id = "toplevel";
+                else if (g_strcmp0 (schema, PANEL_OBJECT_SCHEMA) == 0)
+                        try_id = "object";
+                else
+                        g_assert_not_reached ();
+        }
+
+        /* Append an index at the end of the id to find a unique
+         * id, not used yet */
+        while (existing) {
+                if (screen_for_toplevels != -1 &&
+                    g_strcmp0 (schema, PANEL_TOPLEVEL_SCHEMA) == 0)
+                        unique_id = g_strdup_printf ("%s-screen%d-%d",
+                                                     try_id,
+                                                     screen_for_toplevels,
+                                                     index);
+                else
+                        unique_id = g_strdup_printf ("%s-%d", try_id, index);
+
+                existing = FALSE;
+
+                for (i = 0; existing_ids[i] != NULL; i++) {
+                        if (g_strcmp0 (unique_id,
+                                       existing_ids[i]) == 0) {
+                                existing = TRUE;
+                                break;
+                        }
+                }
+
+                g_free (unique_id);
+                index++;
+        }
+
+        g_strfreev (existing_ids);
+
+        return unique_id;
+}
+
+static gboolean
+panel_layout_append_group_helper (GKeyFile                  *keyfile,
+                                  const char                *group,
+                                  int                        set_screen_to,
+                                  const char                *group_prefix,
+                                  const char                *id_list_key,
+                                  const char                *schema,
+                                  const char                *path_prefix,
+                                  const char                *default_prefix,
+                                  PanelLayoutKeyDefinition  *key_definitions,
+                                  int                        key_definitions_len,
+                                  gboolean                   dry_run,
+                                  GError                   **error,
+                                  const char                *type_for_error_message)
+{
+        gboolean    retval = FALSE;
+        const char *id;
+        char       *unique_id = NULL;
+        char       *path = NULL;
+        GSettings  *settings = NULL;
+        char      **keyfile_keys = NULL;
+        char       *value_str;
+        int         value_int;
+        gboolean    value_boolean;
+        int         i, j;
+
+        g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+        /* Try to extract an id from the group, by stripping the prefix,
+         * and create a unique id out of that */
+        id = group + strlen (group_prefix);
+        while (g_ascii_isspace (*id))
+                id++;
+
+        if (!*id)
+                id = NULL;
+
+        if (id && !panel_gsettings_is_valid_keyname (id, error))
+                return FALSE;
+
+        unique_id = panel_layout_find_free_id (id_list_key, schema,
+                                               id, set_screen_to);
+
+        path = g_strdup_printf ("%s/%s/", path_prefix, unique_id);
+        settings = g_settings_new_with_path (schema, path);
+        g_free (path);
+
+        /* Check that what the code knows matches what the schemas say */
+        if (!panel_layout_append_self_check (settings,
+                                             key_definitions,
+                                             key_definitions_len,
+                                             error))
+                goto out;
+
+        keyfile_keys = g_key_file_get_keys (keyfile, group, NULL, error);
+
+        if (!keyfile_keys)
+                goto out;
+
+        /* Now do the real work: we validate/add keys from the keyfile */
+        for (i = 0; keyfile_keys[i] != NULL; i++) {
+                gboolean found = FALSE;
+
+                for (j = 0; j < key_definitions_len; j++) {
+                        if (g_strcmp0 (keyfile_keys[i],
+                                       key_definitions[j].name) == 0) {
+                                found = TRUE;
+                                break;
+                        }
+                }
+
+                if (!found) {
+                        g_set_error (error, PANEL_LAYOUT_ERROR, 0,
+                                     "Unknown key '%s' for %s",
+                                     keyfile_keys[i],
+                                     type_for_error_message);
+                        return FALSE;
+                }
+
+                switch (key_definitions[j].type) {
+                        case G_TYPE_STRING:
+                                value_str = g_key_file_get_string (
+                                                        keyfile,
+                                                        group, keyfile_keys[i],
+                                                        error);
+                                if (!value_str)
+                                        goto out;
+
+                                if (!dry_run)
+                                        g_settings_set_string (settings,
+                                                               key_definitions[j].name,
+                                                               value_str);
+                                g_free (value_str);
+                                break;
+
+                        case G_TYPE_INT:
+                                value_int = g_key_file_get_integer (
+                                                        keyfile,
+                                                        group, keyfile_keys[i],
+                                                        error);
+                                if (error && *error)
+                                        goto out;
+
+                                if (!dry_run)
+                                        g_settings_set_int (settings,
+                                                            key_definitions[j].name,
+                                                            value_int);
+                                break;
+
+                        case G_TYPE_BOOLEAN:
+                                value_boolean = g_key_file_get_boolean (
+                                                        keyfile,
+                                                        group, keyfile_keys[i],
+                                                        error);
+                                if (error && *error)
+                                        goto out;
+
+                                if (!dry_run)
+                                        g_settings_set_boolean (settings,
+                                                                key_definitions[j].name,
+                                                                value_boolean);
+                                break;
+                        default:
+                                g_assert_not_reached ();
+                                break;
+                }
+        }
+
+        if (!dry_run) {
+                if (set_screen_to != -1 &&
+                    g_strcmp0 (schema, PANEL_TOPLEVEL_SCHEMA) == 0)
+                        g_settings_set_int (settings,
+                                            PANEL_TOPLEVEL_SCREEN,
+                                            set_screen_to);
+
+                panel_gsettings_append_strv (layout_settings,
+                                             id_list_key,
+                                             unique_id);
+        }
+
+        retval = TRUE;
+
+out:
+        if (keyfile_keys)
+                g_strfreev (keyfile_keys);
+        if (settings)
+                g_object_unref (settings);
+        if (unique_id)
+                g_free (unique_id);
+
+        return retval;
+}
+
+static gboolean
+panel_layout_append_group (GKeyFile    *keyfile,
+                           const char  *group,
+                           int          screen_for_toplevels,
+                           gboolean     dry_run,
+                           GError     **error)
+{
+        g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+        if (g_strcmp0 (group, "Toplevel") == 0 ||
+            g_str_has_prefix (group, "Toplevel "))
+                return panel_layout_append_group_helper (
+                                        keyfile, group,
+                                        screen_for_toplevels,
+                                        "Toplevel",
+                                        PANEL_LAYOUT_TOPLEVEL_ID_LIST,
+                                        PANEL_TOPLEVEL_SCHEMA,
+                                        PANEL_LAYOUT_TOPLEVEL_PATH,
+                                        PANEL_LAYOUT_TOPLEVEL_DEFAULT_PREFIX,
+                                        panel_layout_toplevel_keys,
+                                        G_N_ELEMENTS (panel_layout_toplevel_keys),
+                                        dry_run, error, "toplevel");
+        else if (g_strcmp0 (group, "Object") == 0 ||
+                 g_str_has_prefix (group, "Object "))
+                return panel_layout_append_group_helper (
+                                        keyfile, group,
+                                        -1,
+                                        "Object",
+                                        PANEL_LAYOUT_OBJECT_ID_LIST,
+                                        PANEL_OBJECT_SCHEMA,
+                                        PANEL_LAYOUT_OBJECT_PATH,
+                                        PANEL_LAYOUT_OBJECT_DEFAULT_PREFIX,
+                                        panel_layout_object_keys,
+                                        G_N_ELEMENTS (panel_layout_object_keys),
+                                        dry_run, error, "object");
+
+        g_set_error (error, PANEL_LAYOUT_ERROR, 0,
+                     "Unknown group '%s'", group);
+
+        return FALSE;
+}
+
+static void
+panel_layout_append_from_file_real (const char *layout_file,
+                                    int         screen_for_toplevels,
+                                    gboolean    error_fatal)
+{
+        GError    *error = NULL;
+        GKeyFile  *keyfile = NULL;
+        char     **groups = NULL;
+        gboolean   found_one = FALSE;
+        int        i;
+
+        panel_layout_init ();
+
+        keyfile = g_key_file_new ();
+
+        error = NULL;
+        if (!g_key_file_load_from_file (keyfile, layout_file,
+                                        G_KEY_FILE_NONE, &error))
+                goto out;
+
+        groups = g_key_file_get_groups (keyfile, NULL);
+
+        /* First pass to validate: we don't want to add only a subset of the
+         * layout; the whole layout has to be valid */
+        for (i = 0; groups[i] != NULL; i++) {
+                if (!panel_layout_append_group (keyfile, groups[i],
+                                                screen_for_toplevels,
+                                                TRUE, &error))
+                        goto out;
+                else
+                        found_one = TRUE;
+        }
+
+        if (!found_one) {
+                error = g_error_new (PANEL_LAYOUT_ERROR, 0,
+                                     "No defined toplevel or object");
+                goto out;
+        }
+
+        /* Second pass to really add the layout. We know there'll be no error
+         * since the first pass worked. */
+        for (i = 0; groups[i] != NULL; i++)
+                panel_layout_append_group (keyfile, groups[i],
+                                           screen_for_toplevels,
+                                           FALSE, NULL);
+
+out:
+        if (error) {
+                g_printerr ("Error while parsing default layout from '%s': %s\n",
+                            layout_file, error->message);
+                g_error_free (error);
+
+                if (error_fatal)
+                        g_assert_not_reached ();
+        }
+
+        if (groups)
+                g_strfreev (groups);
+
+        if (keyfile)
+                g_key_file_free (keyfile);
+}
+
+static void
+panel_layout_append_from_file_for_screen (const char *layout_file,
+                                          GdkScreen  *screen)
+{
+        int screen_n = gdk_screen_get_number (screen);
+
+        panel_layout_append_from_file_real (layout_file, screen_n, FALSE);
+}
+
+void
+panel_layout_append_from_file (const char *layout_file,
+                               gboolean    error_fatal)
+{
+        panel_layout_append_from_file_real (layout_file, -1, error_fatal);
+}
+
+/******************\
+ * Loading layout *
+\******************/
+
+
+static char *
+panel_layout_get_default_layout_file (void)
+{
+        return g_build_filename (PANELDATADIR,
+                                 "panel-default-layout.layout",
+                                 NULL);
+}
+
+static void
+panel_layout_ensure_toplevel_per_screen (void)
+{
+        GSList     *toplevels;
+        GSList     *empty_screens = NULL;
+        GSList     *l;
+        GdkDisplay *display;
+        int         n_screens, i;
+        char       *default_layout_file;
+
+        toplevels = panel_toplevel_list_toplevels ();
+
+        display = gdk_display_get_default ();
+
+        n_screens = gdk_display_get_n_screens (display);
+        for (i = 0; i < n_screens; i++) {
+                GdkScreen *screen;
+
+                screen = gdk_display_get_screen (display, i);
+
+                for (l = toplevels; l; l = l->next)
+                        if (gtk_window_get_screen (l->data) == screen)
+                                break;
+
+                if (!l)
+                        empty_screens = g_slist_prepend (empty_screens, screen);
+        }
+
+        if (empty_screens == NULL)
+                return;
+
+        default_layout_file = panel_layout_get_default_layout_file ();
+
+        for (l = empty_screens; l; l = l->next)
+                panel_layout_append_from_file_for_screen (default_layout_file,
+                                                          l->data);
+
+        g_free (default_layout_file);
+
+        g_slist_free (empty_screens);
+}
+
+gboolean
+panel_layout_load (void)
+{
+        char **toplevels;
+        char **objects;
+
+        panel_layout_init ();
+
+        toplevels = g_settings_get_strv (layout_settings,
+                                         PANEL_LAYOUT_TOPLEVEL_ID_LIST);
+
+        if (!toplevels[0]) {
+                char *default_layout_file;
+
+                g_strfreev (toplevels);
+
+                if (!g_settings_is_writable (layout_settings,
+                                             PANEL_LAYOUT_TOPLEVEL_ID_LIST) ||
+                    !g_settings_is_writable (layout_settings,
+                                             PANEL_LAYOUT_OBJECT_ID_LIST)) {
+                        g_printerr (_("Cannot create initial panel layout.\n"));
+
+                        return FALSE;
+                }
+
+                default_layout_file = panel_layout_get_default_layout_file ();
+                panel_layout_append_from_file (default_layout_file, TRUE);
+                g_free (default_layout_file);
+
+                toplevels = g_settings_get_strv (layout_settings,
+                                                 PANEL_LAYOUT_TOPLEVEL_ID_LIST);
+
+                if (!toplevels[0]) {
+                        g_strfreev (toplevels);
+                        g_printerr (_("Cannot create initial panel layout.\n"));
+
+                        return FALSE;
+                }
+        }
+
+        objects = g_settings_get_strv (layout_settings,
+                                       PANEL_LAYOUT_OBJECT_ID_LIST);
+
+        panel_layout_ensure_toplevel_per_screen ();
+
+        return TRUE;
+}
diff --git a/gnome-panel/panel-layout.h b/gnome-panel/panel-layout.h
new file mode 100644
index 0000000..428a31e
--- /dev/null
+++ b/gnome-panel/panel-layout.h
@@ -0,0 +1,39 @@
+/*
+ * panel-layout.h:
+ *
+ * Copyright (C) 2011 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors:
+ *	Vincent Untz <vuntz gnome org>
+ */
+
+#ifndef __PANEL_LAYOUT_H__
+#define __PANEL_LAYOUT_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+void panel_layout_append_from_file (const char *layout_file,
+                                    gboolean    error_fatal);
+
+gboolean panel_layout_load (void);
+
+G_END_DECLS
+
+#endif /* __PANEL_LAYOUT_H__ */
diff --git a/gnome-panel/panel-schemas.h b/gnome-panel/panel-schemas.h
index 1ef4d20..4846ce2 100644
--- a/gnome-panel/panel-schemas.h
+++ b/gnome-panel/panel-schemas.h
@@ -21,4 +21,41 @@
 #define PANEL_RUN_ENABLE_LIST_KEY        "enable-program-list"
 #define PANEL_RUN_SHOW_LIST_KEY          "show-program-list"
 
+#define PANEL_LAYOUT_SCHEMA               "org.gnome.gnome-panel.layout"
+#define PANEL_LAYOUT_TOPLEVEL_ID_LIST     "toplevel-id-list"
+#define PANEL_LAYOUT_OBJECT_ID_LIST       "object-id-list"
+
+#define PANEL_LAYOUT_TOPLEVEL_PATH           "/org/gnome/gnome-panel/layout/toplevels"
+#define PANEL_LAYOUT_TOPLEVEL_DEFAULT_PREFIX "toplevel"
+#define PANEL_LAYOUT_OBJECT_PATH             "/org/gnome/gnome-panel/layout/objects"
+#define PANEL_LAYOUT_OBJECT_DEFAULT_PREFIX   "object"
+#define PANEL_LAYOUT_OBJECT_CONFIG_SUFFIX    "instance-config"
+
+#define PANEL_TOPLEVEL_SCHEMA           "org.gnome.gnome-panel.toplevel"
+#define PANEL_TOPLEVEL_NAME             "name"
+#define PANEL_TOPLEVEL_SCREEN           "screen"
+#define PANEL_TOPLEVEL_MONITOR          "monitor"
+#define PANEL_TOPLEVEL_EXPAND           "expand"
+#define PANEL_TOPLEVEL_ORIENTATION      "orientation"
+#define PANEL_TOPLEVEL_SIZE             "size"
+#define PANEL_TOPLEVEL_X                "x"
+#define PANEL_TOPLEVEL_Y                "y"
+#define PANEL_TOPLEVEL_X_RIGHT          "x-right"
+#define PANEL_TOPLEVEL_Y_BOTTOM         "y-bottom"
+#define PANEL_TOPLEVEL_X_CENTERED       "x-centered"
+#define PANEL_TOPLEVEL_Y_CENTERED       "y-centered"
+#define PANEL_TOPLEVEL_AUTO_HIDE        "auto-hide"
+#define PANEL_TOPLEVEL_ENABLE_BUTTONS   "enable-buttons"
+#define PANEL_TOPLEVEL_ENABLE_ARROWS    "enable-arrows"
+#define PANEL_TOPLEVEL_HIDE_DELAY       "hide-delay"
+#define PANEL_TOPLEVEL_UNHIDE_DELAY     "unhide-delay"
+#define PANEL_TOPLEVEL_AUTO_HIDE_SIZE   "auto-hide-size"
+#define PANEL_TOPLEVEL_ANIMATION_SPEED  "animation-speed"
+
+#define PANEL_OBJECT_SCHEMA             "org.gnome.gnome-panel.object"
+#define PANEL_OBJECT_IID_KEY            "object-iid"
+#define PANEL_OBJECT_TOPLEVEL_ID_KEY    "toplevel-id"
+#define PANEL_OBJECT_POSITION_KEY       "position"
+#define PANEL_OBJECT_PACK_END_KEY       "pack-end"
+
 #endif /* __PANEL_SCHEMAS_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]