[gnome-panel/wip/3.0-freeze-break] panel: Port toplevel configuration to GSettings
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/3.0-freeze-break] panel: Port toplevel configuration to GSettings
- Date: Fri, 25 Mar 2011 18:36:47 +0000 (UTC)
commit b0279bd9242a5d5394ff8be0b5f8152144ab4abf
Author: Vincent Untz <vuntz gnome org>
Date: Fri Mar 25 04:12:06 2011 +0100
panel: Port toplevel configuration to GSettings
This is big, but actually mostly straightforward.
The panel properties dialog still needs to be ported, and there is some
code commented out (with #if 0) to enable build without porting this
yet.
We needed to split some enums in a new file (panel-enums-gsettings.h),
so that we can generate GSettings schemas for them and use enums for
keys.
Note that we also drop the opacity key for background, as we directly
store RGBA in the color key now.
data/Makefile.am | 4 +
data/org.gnome.gnome-panel.toplevel.gschema.xml | 17 +-
gnome-panel/Makefile.am | 6 +-
gnome-panel/applet.c | 4 +-
gnome-panel/launcher.c | 2 +-
gnome-panel/panel-addto.c | 44 +-
gnome-panel/panel-background.c | 104 ++-
gnome-panel/panel-background.h | 24 +-
gnome-panel/panel-enums-gsettings.h | 55 ++
gnome-panel/panel-enums.h | 20 +-
gnome-panel/panel-layout.c | 60 ++
gnome-panel/panel-profile.c | 1177 +----------------------
gnome-panel/panel-properties-dialog.c | 8 +
gnome-panel/panel-schemas.h | 8 +
gnome-panel/panel-toplevel.c | 366 +++++++-
gnome-panel/panel-toplevel.h | 3 +
gnome-panel/panel.c | 2 +-
17 files changed, 632 insertions(+), 1272 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index a4a6fd4..7351dd2 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,5 +1,8 @@
SUBDIRS = 16x16 22x22 24x24 32x32 48x48 scalable
+gsettings_ENUM_NAMESPACE = org.gnome.gnome-panel
+gsettings_ENUM_FILES = $(top_srcdir)/gnome-panel/panel-enums-gsettings.h
+
gsettings_SCHEMAS = \
org.gnome.gnome-panel.gschema.xml \
org.gnome.gnome-panel.launcher.gschema.xml \
@@ -17,6 +20,7 @@ EXTRA_DIST = \
$(default_layout_DATA)
CLEANFILES = \
+ $(gsettings__enum_file) \
*.gschema.valid
-include $(top_srcdir)/git.mk
diff --git a/data/org.gnome.gnome-panel.toplevel.gschema.xml b/data/org.gnome.gnome-panel.toplevel.gschema.xml
index 1946bec..432c5d6 100644
--- a/data/org.gnome.gnome-panel.toplevel.gschema.xml
+++ b/data/org.gnome.gnome-panel.toplevel.gschema.xml
@@ -20,7 +20,7 @@
<summary>Expand to occupy entire screen width</summary>
<description>If true, the panel will occupy the entire screen width (height if this is a vertical panel). In this mode the panel can only be placed at a screen edge. If false, the panel will only be large enough to accommodate the applets, launchers and buttons on the panel.</description>
</key>
- <key name="orientation" type="s">
+ <key name="orientation" enum="org.gnome.gnome-panel.PanelOrientation">
<default>'top'</default>
<summary>Panel orientation</summary>
<description>The orientation of the panel. Possible values are "top", "bottom", "left", "right". In expanded mode the key specifies which screen edge the panel is on. In un-expanded mode the difference between "top" and "bottom" is less important - both indicate that this is a horizontal panel - but still give a useful hint as to how some panel objects should behave. For example, on a "top" panel a menu button will pop up its menu below the panel, whereas on a "bottom" panel the menu will be popped up above the panel.</description>
@@ -90,7 +90,7 @@
<summary>Visible pixels when hidden</summary>
<description>Specifies the number of pixels visible when the panel is automatically hidden into a corner. This key is only relevant if the auto_hide key is true.</description>
</key>
- <key name="animation-speed" type="s">
+ <key name="animation-speed" enum="org.gnome.gnome-panel.PanelAnimationSpeed">
<default>'fast'</default>
<summary>Animation speed</summary>
<description>The speed in which panel animations should occur. Possible values are "slow", "medium" and "fast". This key is only relevant if the enable_animations key is true.</description>
@@ -98,21 +98,16 @@
<child name="background" schema="org.gnome.gnome-panel.toplevel.background"/>
</schema>
<schema id="org.gnome.gnome-panel.toplevel.background">
- <key name="type" type="s">
- <default>'gtk'</default>
+ <key name="type" enum="org.gnome.gnome-panel.PanelBackgroundType">
+ <default>'none'</default>
<summary>Background type</summary>
- <description>Which type of background should be used for this panel. Possible values are "gtk" - the default GTK+ widget background will be used, "color" - the color key will be used as background color or "image" - the image specified by the image key will be used as background.</description>
+ <description>Which type of background should be used for this panel. Possible values are "none" - the default GTK+ widget background will be used, "color" - the color key will be used as background color or "image" - the image specified by the image key will be used as background.</description>
</key>
<key name="color" type="s">
- <default>'#ffffff'</default>
+ <default>'rgba(255,255,255,.2)'</default>
<summary>Background color</summary>
<description>Specifies the background color for the panel in #RGB format.</description>
</key>
- <key name="opacity" type="i">
- <default>6000</default>
- <summary>Background color opacity</summary>
- <description>Specifies the opacity of the background color format. If the color is not completely opaque (a value of less than 65535), the color will be composited onto the desktop background image.</description>
- </key>
<key name="image" type="s">
<default>''</default>
<summary>Background image</summary>
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index 72051be..bbc3706 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -108,6 +108,7 @@ panel_headers = \
panel-bindings.h \
panel-profile.h \
panel-enums.h \
+ panel-enums-gsettings.h \
panel-force-quit.h \
panel-lockdown.h \
panel-addto.h \
@@ -177,8 +178,9 @@ gnome-panel-add: gnome-panel-add.in Makefile
< $< > $@
$(AM_V_at)chmod a+x $@
-panel_enum_headers = \
- $(top_srcdir)/gnome-panel/panel-enums.h \
+panel_enum_headers = \
+ $(top_srcdir)/gnome-panel/panel-enums.h \
+ $(top_srcdir)/gnome-panel/panel-enums-gsettings.h \
$(top_srcdir)/gnome-panel/panel-types.h
panel-marshal.h: panel-marshal.list $(GLIB_GENMARSHAL)
diff --git a/gnome-panel/applet.c b/gnome-panel/applet.c
index 45926c8..95648d2 100644
--- a/gnome-panel/applet.c
+++ b/gnome-panel/applet.c
@@ -894,7 +894,7 @@ panel_applet_load_idle_handler (gpointer dummy)
for (l = panel_applets_to_load; l; l = l->next) {
applet = l->data;
- toplevel = panel_profile_get_toplevel_by_id (applet->toplevel_id);
+ toplevel = panel_toplevel_get_by_id (applet->toplevel_id);
if (toplevel)
break;
}
@@ -1070,7 +1070,7 @@ panel_applet_get_toplevel_id (AppletInfo *applet)
if (!panel_widget)
return NULL;
- return panel_profile_get_toplevel_id (panel_widget->toplevel);
+ return panel_toplevel_get_toplevel_id (panel_widget->toplevel);
}
static gboolean
diff --git a/gnome-panel/launcher.c b/gnome-panel/launcher.c
index 7188d7d..105a38b 100644
--- a/gnome-panel/launcher.c
+++ b/gnome-panel/launcher.c
@@ -1009,7 +1009,7 @@ panel_launcher_create (PanelToplevel *toplevel,
int position,
const char *location)
{
- panel_launcher_create_with_id (panel_profile_get_toplevel_id (toplevel),
+ panel_launcher_create_with_id (panel_toplevel_get_toplevel_id (toplevel),
position,
location);
}
diff --git a/gnome-panel/panel-addto.c b/gnome-panel/panel-addto.c
index 7f5e4c9..63442bf 100644
--- a/gnome-panel/panel-addto.c
+++ b/gnome-panel/panel-addto.c
@@ -963,7 +963,7 @@ panel_addto_dialog_free (PanelAddtoDialog *dialog)
client = panel_gconf_get_client ();
if (dialog->name_notify)
- gconf_client_notify_remove (client, dialog->name_notify);
+ g_signal_handler_disconnect (client, dialog->name_notify);
dialog->name_notify = 0;
if (dialog->search_text)
@@ -1016,11 +1016,12 @@ panel_addto_dialog_free (PanelAddtoDialog *dialog)
}
static void
-panel_addto_name_change (PanelAddtoDialog *dialog,
- const char *name)
+panel_addto_name_change (PanelAddtoDialog *dialog)
{
- char *label;
+ const char *name;
+ char *label;
+ name = panel_toplevel_get_name (dialog->panel_widget->toplevel);
label = NULL;
if (!PANEL_GLIB_STR_EMPTY (name))
@@ -1038,27 +1039,11 @@ panel_addto_name_change (PanelAddtoDialog *dialog,
}
static void
-panel_addto_name_notify (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
+panel_addto_name_notify (GObject *gobject,
+ GParamSpec *pspec,
PanelAddtoDialog *dialog)
{
- GConfValue *value;
- const char *key;
- const char *text = NULL;
-
- key = panel_gconf_basename (gconf_entry_get_key (entry));
-
- if (strcmp (key, "name"))
- return;
-
- value = gconf_entry_get_value (entry);
-
- if (value && value->type == GCONF_VALUE_STRING)
- text = gconf_value_get_string (value);
-
- if (text)
- panel_addto_name_change (dialog, text);
+ panel_addto_name_change (dialog);
}
static gboolean
@@ -1261,12 +1246,10 @@ panel_addto_dialog_new (PanelWidget *panel_widget)
dialog->panel_widget = panel_widget;
dialog->name_notify =
- panel_profile_toplevel_notify_add (
- dialog->panel_widget->toplevel,
- "name",
- (GConfClientNotifyFunc) panel_addto_name_notify,
- dialog);
-
+ g_signal_connect (dialog->panel_widget->toplevel,
+ "notify::name",
+ G_CALLBACK (panel_addto_name_notify),
+ dialog);
dialog->addto_dialog = gtk_dialog_new ();
gtk_dialog_add_button (GTK_DIALOG (dialog->addto_dialog),
@@ -1384,8 +1367,7 @@ panel_addto_dialog_new (PanelWidget *panel_widget)
panel_widget_register_open_dialog (panel_widget,
dialog->addto_dialog);
- panel_addto_name_change (dialog,
- panel_toplevel_get_name (dialog->panel_widget->toplevel));
+ panel_addto_name_change (dialog);
return dialog;
}
diff --git a/gnome-panel/panel-background.c b/gnome-panel/panel-background.c
index 228721c..3163b62 100644
--- a/gnome-panel/panel-background.c
+++ b/gnome-panel/panel-background.c
@@ -33,6 +33,7 @@
#include <cairo-xlib.h>
#include "panel-background-monitor.h"
+#include "panel-schemas.h"
#include "panel-util.h"
@@ -506,7 +507,7 @@ load_background_file (PanelBackground *background)
panel_background_update_has_alpha (background);
}
-void
+static void
panel_background_set_type (PanelBackground *background,
PanelBackgroundType type)
{
@@ -535,7 +536,7 @@ panel_background_set_color_no_update (PanelBackground *background,
panel_background_update_has_alpha (background);
}
-void
+static void
panel_background_set_color (PanelBackground *background,
const GdkRGBA *color)
{
@@ -567,7 +568,7 @@ panel_background_set_image_no_update (PanelBackground *background,
panel_background_update_has_alpha (background);
}
-void
+static void
panel_background_set_image (PanelBackground *background,
const char *image)
{
@@ -589,7 +590,7 @@ panel_background_set_fit_no_update (PanelBackground *background,
background->fit_image = fit_image != FALSE;
}
-void
+static void
panel_background_set_fit (PanelBackground *background,
gboolean fit_image)
{
@@ -610,7 +611,7 @@ panel_background_set_stretch_no_update (PanelBackground *background,
background->stretch_image = stretch_image != FALSE;
}
-void
+static void
panel_background_set_stretch (PanelBackground *background,
gboolean stretch_image)
{
@@ -631,7 +632,7 @@ panel_background_set_rotate_no_update (PanelBackground *background,
background->rotate_image = rotate_image != FALSE;
}
-void
+static void
panel_background_set_rotate (PanelBackground *background,
gboolean rotate_image)
{
@@ -645,20 +646,87 @@ panel_background_set_rotate (PanelBackground *background,
panel_background_transform (background);
}
+static void
+panel_background_settings_changed (GSettings *settings,
+ char *key,
+ PanelBackground *background)
+{
+ char *value_str;
+ gboolean value_boolean;
+
+ if (g_strcmp0 (key, PANEL_BACKGROUND_TYPE_KEY) == 0) {
+ PanelBackgroundType type;
+ type = g_settings_get_enum (settings, key);
+ panel_background_set_type (background, type);
+ } else if (g_strcmp0 (key, PANEL_BACKGROUND_COLOR_KEY) == 0) {
+ GdkRGBA color;
+ value_str = g_settings_get_string (settings, key);
+ if (gdk_rgba_parse (&color, value_str))
+ panel_background_set_color (background, &color);
+ g_free (value_str);
+ } else if (g_strcmp0 (key, PANEL_BACKGROUND_IMAGE_KEY) == 0) {
+ value_str = g_settings_get_string (settings, key);
+ panel_background_set_image (background, value_str);
+ g_free (value_str);
+ } else if (g_strcmp0 (key, PANEL_BACKGROUND_FIT_KEY) == 0) {
+ value_boolean = g_settings_get_boolean (settings, key);
+ panel_background_set_fit (background, value_boolean);
+ } else if (g_strcmp0 (key, PANEL_BACKGROUND_STRETCH_KEY) == 0) {
+ value_boolean = g_settings_get_boolean (settings, key);
+ panel_background_set_stretch (background, value_boolean);
+ } else if (g_strcmp0 (key, PANEL_BACKGROUND_ROTATE_KEY) == 0) {
+ value_boolean = g_settings_get_boolean (settings, key);
+ panel_background_set_rotate (background, value_boolean);
+ } else {
+ g_assert_not_reached ();
+ }
+}
+
void
-panel_background_set (PanelBackground *background,
- PanelBackgroundType type,
- const GdkRGBA *color,
- const char *image,
- gboolean fit_image,
- gboolean stretch_image,
- gboolean rotate_image)
+panel_background_settings_init (PanelBackground *background,
+ GSettings *settings)
{
- panel_background_set_color_no_update (background, color);
+ PanelBackgroundType type;
+ char *color_str;
+ GdkRGBA color;
+ char *image;
+ gboolean fit_image;
+ gboolean stretch_image;
+ gboolean rotate_image;
+
+ g_assert (background->settings == NULL);
+
+ background->settings = g_object_ref (settings);
+ g_signal_connect (background->settings, "changed",
+ G_CALLBACK (panel_background_settings_changed),
+ background);
+
+ color_str = g_settings_get_string (background->settings,
+ PANEL_BACKGROUND_COLOR_KEY);
+ if (!gdk_rgba_parse (&color, color_str))
+ gdk_rgba_parse (&color, "rgba(255,255,255,.2)");
+ panel_background_set_color_no_update (background, &color);
+ g_free (color_str);
+
+ image = g_settings_get_string (background->settings,
+ PANEL_BACKGROUND_IMAGE_KEY);
panel_background_set_image_no_update (background, image);
+ g_free (image);
+
+ fit_image = g_settings_get_boolean (background->settings,
+ PANEL_BACKGROUND_FIT_KEY);
panel_background_set_fit_no_update (background, fit_image);
+
+ stretch_image = g_settings_get_boolean (background->settings,
+ PANEL_BACKGROUND_STRETCH_KEY);
panel_background_set_stretch_no_update (background, stretch_image);
+
+ rotate_image = g_settings_get_boolean (background->settings,
+ PANEL_BACKGROUND_ROTATE_KEY);
panel_background_set_rotate_no_update (background, rotate_image);
+
+ type = g_settings_get_enum (background->settings,
+ PANEL_BACKGROUND_TYPE_KEY);
panel_background_set_type (background, type);
}
@@ -778,6 +846,8 @@ panel_background_init (PanelBackground *background,
PanelBackgroundChangedNotify notify_changed,
gpointer user_data)
{
+ background->settings = NULL;
+
background->type = PANEL_BACK_NONE;
background->notify_changed = notify_changed;
background->user_data = user_data;
@@ -827,6 +897,10 @@ panel_background_free (PanelBackground *background)
free_transformed_resources (background);
+ if (background->settings)
+ g_object_unref (background->settings);
+ background->settings = NULL;
+
if (background->image)
g_free (background->image);
background->image = NULL;
diff --git a/gnome-panel/panel-background.h b/gnome-panel/panel-background.h
index e9b86df..eb9a93a 100644
--- a/gnome-panel/panel-background.h
+++ b/gnome-panel/panel-background.h
@@ -39,6 +39,8 @@ typedef void (*PanelBackgroundChangedNotify)
gpointer user_data);
struct _PanelBackground {
+ GSettings *settings;
+
PanelBackgroundType type;
PanelBackgroundChangedNotify notify_changed;
@@ -76,26 +78,10 @@ struct _PanelBackground {
void panel_background_init (PanelBackground *background,
PanelBackgroundChangedNotify notify_changed,
gpointer user_data);
+void panel_background_settings_init (PanelBackground *background,
+ GSettings *settings);
void panel_background_free (PanelBackground *background);
-void panel_background_set (PanelBackground *background,
- PanelBackgroundType type,
- const GdkRGBA *color,
- const char *image,
- gboolean fit_image,
- gboolean stretch_image,
- gboolean rotate_image);
-void panel_background_set_type (PanelBackground *background,
- PanelBackgroundType type);
-void panel_background_set_color (PanelBackground *background,
- const GdkRGBA *color);
-void panel_background_set_image (PanelBackground *background,
- const char *image);
-void panel_background_set_fit (PanelBackground *background,
- gboolean fit_image);
-void panel_background_set_stretch (PanelBackground *background,
- gboolean stretch_image);
-void panel_background_set_rotate (PanelBackground *background,
- gboolean rotate_image);
+
void panel_background_set_default_style (PanelBackground *background,
GdkRGBA *color,
cairo_pattern_t *pattern);
diff --git a/gnome-panel/panel-enums-gsettings.h b/gnome-panel/panel-enums-gsettings.h
new file mode 100644
index 0000000..a559657
--- /dev/null
+++ b/gnome-panel/panel-enums-gsettings.h
@@ -0,0 +1,55 @@
+/*
+ * panel-enums-gsettings.h:
+ *
+ * Copyright (C) 2003 Sun Microsystems, 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:
+ * Mark McLoughlin <mark skynet ie>
+ */
+
+#ifndef __PANEL_ENUMS_GSETTINGS_H__
+#define __PANEL_ENUMS_GSETTINGS_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+
+typedef enum {
+ PANEL_ORIENTATION_TOP = 1 << 0,
+ PANEL_ORIENTATION_RIGHT = 1 << 1,
+ PANEL_ORIENTATION_BOTTOM = 1 << 2,
+ PANEL_ORIENTATION_LEFT = 1 << 3
+} PanelOrientation;
+
+
+typedef enum {
+ PANEL_ANIMATION_SLOW = 0,
+ PANEL_ANIMATION_MEDIUM = 1,
+ PANEL_ANIMATION_FAST = 2
+} PanelAnimationSpeed;
+
+typedef enum {
+ PANEL_BACK_NONE = 0,
+ PANEL_BACK_COLOR = 1,
+ PANEL_BACK_IMAGE = 2
+} PanelBackgroundType;
+
+G_END_DECLS
+
+#endif /* __PANEL_ENUMS_GSETTINGS_H__ */
diff --git a/gnome-panel/panel-enums.h b/gnome-panel/panel-enums.h
index 811ae05..6132e0d 100644
--- a/gnome-panel/panel-enums.h
+++ b/gnome-panel/panel-enums.h
@@ -26,16 +26,10 @@
#define __PANEL_ENUMS_H__
#include <glib.h>
+#include "panel-enums-gsettings.h"
G_BEGIN_DECLS
-typedef enum {
- PANEL_ORIENTATION_TOP = 1 << 0,
- PANEL_ORIENTATION_RIGHT = 1 << 1,
- PANEL_ORIENTATION_BOTTOM = 1 << 2,
- PANEL_ORIENTATION_LEFT = 1 << 3
-} PanelOrientation;
-
#define PANEL_HORIZONTAL_MASK (PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)
#define PANEL_VERTICAL_MASK (PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)
@@ -57,18 +51,6 @@ typedef enum {
} PanelState;
typedef enum {
- PANEL_ANIMATION_SLOW = 0,
- PANEL_ANIMATION_MEDIUM = 1,
- PANEL_ANIMATION_FAST = 2
-} PanelAnimationSpeed;
-
-typedef enum {
- PANEL_BACK_NONE = 0,
- PANEL_BACK_COLOR = 1,
- PANEL_BACK_IMAGE = 2
-} PanelBackgroundType;
-
-typedef enum {
PANEL_GCONF_TOPLEVELS,
PANEL_GCONF_OBJECTS,
PANEL_GCONF_APPLETS
diff --git a/gnome-panel/panel-layout.c b/gnome-panel/panel-layout.c
index 0ecb0bb..f2a87d9 100644
--- a/gnome-panel/panel-layout.c
+++ b/gnome-panel/panel-layout.c
@@ -32,8 +32,11 @@
#include <libpanel-util/panel-cleanup.h>
#include <libpanel-util/panel-dconf.h>
+#include <libpanel-util/panel-glib.h>
#include <libpanel-util/panel-gsettings.h>
+#include "panel.h"
+#include "panel-multiscreen.h"
#include "panel-schemas.h"
#include "panel-toplevel.h"
@@ -543,6 +546,52 @@ panel_layout_append_from_file (const char *layout_file,
\******************/
+static void
+panel_layout_load_toplevel (const char *toplevel_id)
+{
+ PanelToplevel *toplevel;
+ char *path;
+ GSettings *settings;
+ int screen;
+
+ if (PANEL_GLIB_STR_EMPTY (toplevel_id))
+ return;
+
+ path = g_strdup_printf ("%s%s/",
+ PANEL_LAYOUT_TOPLEVEL_PATH, toplevel_id);
+
+ /* Check that the screen is valid */
+ settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA, path);
+ screen = g_settings_get_int (settings, PANEL_TOPLEVEL_SCREEN);
+ g_object_unref (settings);
+
+ if (screen < 0 || screen >= panel_multiscreen_screens ()) {
+ g_free (path);
+ return;
+ }
+
+ toplevel = g_object_new (PANEL_TYPE_TOPLEVEL,
+ "toplevel-id", toplevel_id,
+ "settings-path", path,
+ NULL);
+
+ g_free (path);
+
+ /* FIXME: we shouldn't have to do this manually */
+ panel_setup (toplevel);
+
+ gtk_widget_show (GTK_WIDGET (toplevel));
+}
+
+static void
+panel_layout_load_object (const char *object_id)
+{
+ if (PANEL_GLIB_STR_EMPTY (object_id))
+ return;
+
+ /* TODO */
+}
+
static char *
panel_layout_get_default_layout_file (void)
{
@@ -598,6 +647,7 @@ panel_layout_load (void)
{
char **toplevels;
char **objects;
+ int i;
panel_layout_init ();
@@ -633,9 +683,19 @@ panel_layout_load (void)
}
}
+ for (i = 0; toplevels[i] != NULL; i++)
+ panel_layout_load_toplevel (toplevels[i]);
+
+ g_strfreev (toplevels);
+
objects = g_settings_get_strv (layout_settings,
PANEL_LAYOUT_OBJECT_ID_LIST);
+ for (i = 0; objects[i] != NULL; i++)
+ panel_layout_load_object (objects[i]);
+
+ g_strfreev (objects);
+
panel_layout_ensure_toplevel_per_screen ();
return TRUE;
diff --git a/gnome-panel/panel-profile.c b/gnome-panel/panel-profile.c
index 77b71ce..0ae4c2a 100644
--- a/gnome-panel/panel-profile.c
+++ b/gnome-panel/panel-profile.c
@@ -40,30 +40,6 @@
#include "panel-toplevel.h"
#include "panel-lockdown.h"
-typedef struct {
- GdkScreen *screen;
- int monitor;
- int size;
- int x;
- int x_right;
- gboolean x_centered;
- int y;
- int y_bottom;
- gboolean y_centered;
- PanelOrientation orientation;
-
- guint screen_changed : 1;
- guint monitor_changed : 1;
- guint size_changed : 1;
- guint x_changed : 1;
- guint x_right_changed : 1;
- guint x_centered_changed : 1;
- guint y_changed : 1;
- guint y_bottom_changed : 1;
- guint y_centered_changed : 1;
- guint orientation_changed : 1;
-} ToplevelLocationChange;
-
typedef const char *(*PanelProfileGetIdFunc) (gpointer object);
typedef gboolean (*PanelProfileOnLoadQueue) (const char *id);
typedef void (*PanelProfileLoadFunc) (GConfClient *client,
@@ -80,13 +56,6 @@ static GConfEnumStringPair panel_orientation_map [] = {
{ 0, NULL }
};
-static GConfEnumStringPair panel_animation_speed_map [] = {
- { PANEL_ANIMATION_SLOW, "slow" },
- { PANEL_ANIMATION_MEDIUM, "medium" },
- { PANEL_ANIMATION_FAST, "fast" },
- { 0, NULL }
-};
-
static GConfEnumStringPair panel_background_type_map [] = {
{ PANEL_BACK_NONE, "gtk" },
{ PANEL_BACK_COLOR, "color" },
@@ -106,10 +75,6 @@ static GConfEnumStringPair panel_object_type_map [] = {
{ 0, NULL }
};
-static GQuark toplevel_id_quark = 0;
-static GQuark queued_changes_quark = 0;
-static GQuark commit_timeout_quark = 0;
-
static void panel_profile_object_id_list_update (GConfClient *client,
GConfValue *value,
PanelGConfKeyType type);
@@ -139,44 +104,6 @@ panel_profile_map_orientation (PanelOrientation orientation)
return gconf_enum_to_string (panel_orientation_map, orientation);
}
-gboolean
-panel_profile_map_speed_string (const char *str,
- PanelAnimationSpeed *speed)
-{
- int mapped;
-
- g_return_val_if_fail (speed != NULL, FALSE);
-
- if (!str)
- return FALSE;
-
- if (!gconf_string_to_enum (panel_animation_speed_map, str, &mapped))
- return FALSE;
-
- *speed = mapped;
-
- return TRUE;
-}
-
-gboolean
-panel_profile_map_background_type_string (const char *str,
- PanelBackgroundType *background_type)
-{
- int mapped;
-
- g_return_val_if_fail (background_type != NULL, FALSE);
-
- if (!str)
- return FALSE;
-
- if (!gconf_string_to_enum (panel_background_type_map, str, &mapped))
- return FALSE;
-
- *background_type = mapped;
-
- return TRUE;
-}
-
const char *
panel_profile_map_background_type (PanelBackgroundType background_type)
{
@@ -202,44 +129,6 @@ panel_profile_map_object_type_string (const char *str,
return TRUE;
}
-static void
-panel_profile_set_toplevel_id (PanelToplevel *toplevel,
- const char *id)
-{
- if (!toplevel_id_quark)
- toplevel_id_quark = g_quark_from_static_string ("panel-toplevel-id");
-
- g_object_set_qdata_full (G_OBJECT (toplevel),
- toplevel_id_quark,
- g_strdup (id),
- g_free);
-}
-
-const char *
-panel_profile_get_toplevel_id (PanelToplevel *toplevel)
-{
- if (!toplevel_id_quark)
- return NULL;
-
- return g_object_get_qdata (G_OBJECT (toplevel), toplevel_id_quark);
-}
-
-PanelToplevel *
-panel_profile_get_toplevel_by_id (const char *toplevel_id)
-{
- GSList *toplevels, *l;
-
- if (!toplevel_id || !toplevel_id [0])
- return NULL;
-
- toplevels = panel_toplevel_list_toplevels ();
- for (l = toplevels; l; l = l->next)
- if (!strcmp (panel_profile_get_toplevel_id (l->data), toplevel_id))
- return l->data;
-
- return NULL;
-}
-
char *
panel_profile_find_new_id (PanelGConfKeyType type)
{
@@ -295,70 +184,13 @@ panel_profile_find_new_id (PanelGConfKeyType type)
return retval;
}
-static void
-panel_profile_set_queued_changes (PanelToplevel *toplevel,
- GConfChangeSet *changes)
-{
- if (!queued_changes_quark)
- queued_changes_quark = g_quark_from_static_string ("panel-queued-changes");
-
- g_object_set_qdata_full (G_OBJECT (toplevel),
- queued_changes_quark,
- changes,
- (GDestroyNotify) gconf_change_set_unref);
-}
-
-static GConfChangeSet *
-panel_profile_get_queued_changes (GObject *object)
-{
- if (!queued_changes_quark)
- return NULL;
-
- return g_object_get_qdata (object, queued_changes_quark);
-}
-
-static void
-panel_profile_remove_commit_timeout (guint timeout)
-{
- g_source_remove (timeout);
-}
-
-static void
-panel_profile_set_commit_timeout (PanelToplevel *toplevel,
- guint timeout)
-{
- GDestroyNotify destroy_notify;
-
- if (!commit_timeout_quark)
- commit_timeout_quark = g_quark_from_static_string ("panel-queued-timeout");
-
- if (timeout)
- destroy_notify = (GDestroyNotify) panel_profile_remove_commit_timeout;
- else
- destroy_notify = NULL;
-
- g_object_set_qdata_full (G_OBJECT (toplevel),
- commit_timeout_quark,
- GUINT_TO_POINTER (timeout),
- destroy_notify);
-}
-
-static guint
-panel_profile_get_commit_timeout (GObject *object)
-{
- if (!commit_timeout_quark)
- return 0;
-
- return GPOINTER_TO_UINT (g_object_get_qdata (object, commit_timeout_quark));
-}
-
static const char *
panel_profile_get_toplevel_key (PanelToplevel *toplevel,
const char *key)
{
const char *id;
- id = panel_profile_get_toplevel_id (toplevel);
+ id = panel_toplevel_get_toplevel_id (toplevel);
return panel_gconf_full_key (PANEL_GCONF_TOPLEVELS, id, key);
}
@@ -390,26 +222,6 @@ panel_profile_set_background_type (PanelToplevel *toplevel,
NULL);
}
-PanelBackgroundType
-panel_profile_get_background_type (PanelToplevel *toplevel)
-{
- PanelBackgroundType background_type;
- GConfClient *client;
- const char *key;
- char *str;
-
- client = panel_gconf_get_client ();
-
- key = panel_profile_get_toplevel_key (toplevel, "background/type");
- str = gconf_client_get_string (client, key, NULL);
-
- if (!str || !panel_profile_map_background_type_string (str, &background_type))
- background_type = PANEL_BACK_NONE;
-
- g_free (str);
-
- return background_type;
-}
TOPLEVEL_IS_WRITABLE_FUNC ("background/type", background, type)
@@ -522,40 +334,6 @@ panel_profile_get_background_image (PanelToplevel *toplevel)
TOPLEVEL_IS_WRITABLE_FUNC ("background/image", background, image)
void
-panel_profile_set_toplevel_name (PanelToplevel *toplevel,
- const char *name)
-{
- GConfClient *client;
- const char *key;
-
- client = panel_gconf_get_client ();
-
- key = panel_profile_get_toplevel_key (toplevel, "name");
-
- if (name && name [0])
- gconf_client_set_string (client, key, name, NULL);
- else
- gconf_client_unset (client, key, NULL);
-}
-
-char *
-panel_profile_get_toplevel_name (PanelToplevel *toplevel)
-{
- GConfClient *client;
- const char *key;
- char *retval;
-
- client = panel_gconf_get_client ();
-
- key = panel_profile_get_toplevel_key (toplevel, "name");
- retval = gconf_client_get_string (client, key, NULL);
-
- return retval;
-}
-
-TOPLEVEL_IS_WRITABLE_FUNC ("name", toplevel, name)
-
-void
panel_profile_set_toplevel_orientation (PanelToplevel *toplevel,
PanelOrientation orientation)
{
@@ -622,277 +400,8 @@ TOPLEVEL_GET_SET_FUNCS ("expand", toplevel, bool, expand,
TOPLEVEL_GET_SET_FUNCS ("auto_hide", toplevel, bool, auto_hide, gboolean)
TOPLEVEL_GET_SET_FUNCS ("enable_buttons", toplevel, bool, enable_buttons, gboolean)
TOPLEVEL_GET_SET_FUNCS ("enable_arrows", toplevel, bool, enable_arrows, gboolean)
-TOPLEVEL_GET_SET_FUNCS ("background/fit", background, bool, fit, gboolean)
-TOPLEVEL_GET_SET_FUNCS ("background/stretch", background, bool, stretch, gboolean)
-TOPLEVEL_GET_SET_FUNCS ("background/rotate", background, bool, rotate, gboolean)
-
-static PanelBackgroundType
-get_background_type (GConfClient *client,
- const char *toplevel_dir)
-{
- PanelBackgroundType background_type;
- GError *error = NULL;
- const char *key;
- char *type_str;
-
- key = panel_gconf_sprintf ("%s/background/type", toplevel_dir);
- type_str = gconf_client_get_string (client, key, &error);
- if (error) {
- g_warning (_("Error reading GConf string value '%s': %s"),
- key, error->message);
- g_error_free (error);
- return PANEL_BACK_NONE;
- }
-
- if (!type_str || !panel_profile_map_background_type_string (type_str, &background_type))
- background_type = PANEL_BACK_NONE;
-
- g_free (type_str);
-
- return background_type;
-}
-
-static void
-get_background_color (GConfClient *client,
- const char *toplevel_dir,
- GdkRGBA *color)
-{
- GError *error;
- const char *key;
- char *color_str;
- guint16 alpha;
-
- error = NULL;
- key = panel_gconf_sprintf ("%s/background/color", toplevel_dir);
- color_str = gconf_client_get_string (client, key, &error);
- if (error) {
- g_warning (_("Error reading GConf string value '%s': %s"),
- key, error->message);
- g_error_free (error);
- } else if (!color_str || !gdk_rgba_parse (color, color_str)) {
- color->red = 0.;
- color->green = 0.;
- color->blue = 0.;
- color->alpha = 1.;
- }
-
- g_free (color_str);
-
- error = NULL;
- key = panel_gconf_sprintf ("%s/background/opacity", toplevel_dir);
- alpha = gconf_client_get_int (client, key, &error);
- if (error) {
- g_warning (_("Error reading GConf integer value '%s': %s"),
- key, error->message);
- g_error_free (error);
- color->alpha = 1.; /* fallback to fully opaque */
- } else {
- color->alpha = alpha / 65535.;
- }
-}
-
-static char *
-get_background_image (GConfClient *client,
- const char *toplevel_dir,
- gboolean *fit,
- gboolean *stretch,
- gboolean *rotate)
-{
- const char *key;
- GError *error = NULL;
- char *image;
-
- key = panel_gconf_sprintf ("%s/background/image", toplevel_dir);
- image = gconf_client_get_string (client, key, &error);
- if (error) {
- g_warning (_("Error reading GConf string value '%s': %s"),
- key, error->message);
- g_error_free (error);
- }
-
- key = panel_gconf_sprintf ("%s/background/fit", toplevel_dir);
- *fit = gconf_client_get_bool (client, key, NULL);
-
- key = panel_gconf_sprintf ("%s/background/stretch", toplevel_dir);
- *stretch = gconf_client_get_bool (client, key, NULL);
-
- key = panel_gconf_sprintf ("%s/background/rotate", toplevel_dir);
- *rotate = gconf_client_get_bool (client, key, NULL);
-
- return image;
-}
-
-static void
-panel_profile_load_background (PanelToplevel *toplevel,
- GConfClient *client,
- const char *toplevel_dir)
-{
- PanelWidget *panel_widget;
- PanelBackground *background;
- PanelBackgroundType background_type;
- GdkRGBA color;
- char *image;
- gboolean fit;
- gboolean stretch;
- gboolean rotate;
-
- panel_widget = panel_toplevel_get_panel_widget (toplevel);
- background = &panel_widget->background;
-
- background_type = get_background_type (client, toplevel_dir);
-
- get_background_color (client, toplevel_dir, &color);
-
- image = get_background_image (client, toplevel_dir, &fit, &stretch, &rotate);
-
- panel_background_set (background,
- background_type,
- &color,
- image,
- fit,
- stretch,
- rotate);
-
- g_free (image);
-}
-
-static gboolean
-panel_profile_commit_toplevel_changes (PanelToplevel *toplevel)
-{
- GConfChangeSet *queued_changes;
-
- queued_changes = panel_profile_get_queued_changes (G_OBJECT (toplevel));
- if (queued_changes)
- gconf_client_commit_change_set (
- panel_gconf_get_client (),
- queued_changes, FALSE, NULL);
-
- panel_profile_set_queued_changes (toplevel, NULL);
- panel_profile_set_commit_timeout (toplevel, 0);
-
- return FALSE;
-}
-
-static void
-panel_profile_queue_toplevel_location_change (PanelToplevel *toplevel,
- ToplevelLocationChange *change)
-{
- GConfChangeSet *queued_changes;
- guint commit_timeout;
-
- queued_changes = panel_profile_get_queued_changes (G_OBJECT (toplevel));
- if (!queued_changes) {
- queued_changes = gconf_change_set_new ();
- panel_profile_set_queued_changes (toplevel, queued_changes);
- }
-
- if (change->screen_changed)
- gconf_change_set_set_int (
- queued_changes,
- panel_profile_get_toplevel_key (toplevel, "screen"),
- gdk_screen_get_number (change->screen));
-
- if (change->monitor_changed)
- gconf_change_set_set_int (
- queued_changes,
- panel_profile_get_toplevel_key (toplevel, "monitor"),
- change->monitor);
-
- if (change->size_changed)
- gconf_change_set_set_int (
- queued_changes,
- panel_profile_get_toplevel_key (toplevel, "size"),
- change->size);
-
- if (change->orientation_changed)
- gconf_change_set_set_string (
- queued_changes,
- panel_profile_get_toplevel_key (toplevel, "orientation"),
- gconf_enum_to_string (panel_orientation_map, change->orientation));
-
- if (!panel_toplevel_get_expand (toplevel)) {
- if (change->x_changed)
- gconf_change_set_set_int (
- queued_changes,
- panel_profile_get_toplevel_key (toplevel, "x"),
- change->x);
-
- if (change->x_right_changed)
- gconf_change_set_set_int (
- queued_changes,
- panel_profile_get_toplevel_key (toplevel, "x_right"),
- change->x_right);
-
- if (change->x_centered_changed)
- gconf_change_set_set_bool (
- queued_changes,
- panel_profile_get_toplevel_key (toplevel, "x_centered"),
- change->x_centered);
-
- if (change->y_changed)
- gconf_change_set_set_int (
- queued_changes,
- panel_profile_get_toplevel_key (toplevel, "y"),
- change->y);
-
- if (change->y_bottom_changed)
- gconf_change_set_set_int (
- queued_changes,
- panel_profile_get_toplevel_key (toplevel, "y_bottom"),
- change->y_bottom);
-
- if (change->y_centered_changed)
- gconf_change_set_set_bool (
- queued_changes,
- panel_profile_get_toplevel_key (toplevel, "y_centered"),
- change->y_centered);
- }
-
- commit_timeout = panel_profile_get_commit_timeout (G_OBJECT (toplevel));
- if (!commit_timeout) {
- commit_timeout =
- g_timeout_add (500,
- (GSourceFunc) panel_profile_commit_toplevel_changes,
- toplevel);
- panel_profile_set_commit_timeout (toplevel, commit_timeout);
- }
-}
-
-#define TOPLEVEL_LOCATION_CHANGED_HANDLER(c) \
- static void \
- panel_profile_toplevel_##c##_changed (PanelToplevel *toplevel) \
- { \
- ToplevelLocationChange change = { NULL }; \
- change.c##_changed = TRUE; \
- change.c = panel_toplevel_get_##c (toplevel); \
- panel_profile_queue_toplevel_location_change (toplevel, &change); \
- }
-
-TOPLEVEL_LOCATION_CHANGED_HANDLER(monitor)
-TOPLEVEL_LOCATION_CHANGED_HANDLER(size)
-TOPLEVEL_LOCATION_CHANGED_HANDLER(orientation)
-TOPLEVEL_LOCATION_CHANGED_HANDLER(x_centered)
-TOPLEVEL_LOCATION_CHANGED_HANDLER(y_centered)
-
-#define TOPLEVEL_POSITION_CHANGED_HANDLER(c) \
- static void \
- panel_profile_toplevel_##c##_changed (PanelToplevel *toplevel) \
- { \
- ToplevelLocationChange change = { NULL }; \
- int x, y, x_right, y_bottom; \
- change.c##_changed = TRUE; \
- panel_toplevel_get_position (toplevel, \
- &x, &x_right, \
- &y, &y_bottom); \
- change.c = c; \
- panel_profile_queue_toplevel_location_change (toplevel, &change); \
- }
-
-TOPLEVEL_POSITION_CHANGED_HANDLER(x)
-TOPLEVEL_POSITION_CHANGED_HANDLER(x_right)
-TOPLEVEL_POSITION_CHANGED_HANDLER(y)
-TOPLEVEL_POSITION_CHANGED_HANDLER(y_bottom)
+#if 0
static void
panel_profile_toplevel_screen_changed (PanelToplevel *toplevel)
{
@@ -909,58 +418,6 @@ panel_profile_connect_to_toplevel (PanelToplevel *toplevel)
{
g_signal_connect (toplevel, "notify::screen",
G_CALLBACK (panel_profile_toplevel_screen_changed), NULL);
- g_signal_connect (toplevel, "notify::monitor",
- G_CALLBACK (panel_profile_toplevel_monitor_changed), NULL);
- g_signal_connect (toplevel, "notify::size",
- G_CALLBACK (panel_profile_toplevel_size_changed), NULL);
- g_signal_connect (toplevel, "notify::x",
- G_CALLBACK (panel_profile_toplevel_x_changed), NULL);
- g_signal_connect (toplevel, "notify::x-right",
- G_CALLBACK (panel_profile_toplevel_x_right_changed), NULL);
- g_signal_connect (toplevel, "notify::x-centered",
- G_CALLBACK (panel_profile_toplevel_x_centered_changed), NULL);
- g_signal_connect (toplevel, "notify::y",
- G_CALLBACK (panel_profile_toplevel_y_changed), NULL);
- g_signal_connect (toplevel, "notify::y-bottom",
- G_CALLBACK (panel_profile_toplevel_y_bottom_changed), NULL);
- g_signal_connect (toplevel, "notify::y-centered",
- G_CALLBACK (panel_profile_toplevel_y_centered_changed), NULL);
- g_signal_connect (toplevel, "notify::orientation",
- G_CALLBACK (panel_profile_toplevel_orientation_changed), NULL);
-}
-
-static void
-set_name_from_string (PanelToplevel *toplevel,
- const char *str)
-{
- if (!str)
- return;
-
- panel_toplevel_set_name (toplevel, str);
-}
-
-static void
-set_orientation_from_string (PanelToplevel *toplevel,
- const char *str)
-{
- PanelOrientation orientation;
-
- if (!str || !panel_profile_map_orientation_string (str, &orientation))
- return;
-
- panel_toplevel_set_orientation (toplevel, orientation);
-}
-
-static void
-set_animation_speed_from_string (PanelToplevel *toplevel,
- const char *str)
-{
- PanelAnimationSpeed animation_speed;
-
- if (!str || !panel_profile_map_speed_string (str, &animation_speed))
- return;
-
- panel_toplevel_set_animation_speed (toplevel, animation_speed);
}
static void
@@ -977,66 +434,6 @@ panel_profile_toplevel_change_notify (GConfClient *client,
if (!(value = gconf_entry_get_value (entry)))
return;
-#define UPDATE_STRING(k, n) \
- if (!strcmp (key, k)) { \
- if (value->type == GCONF_VALUE_STRING) \
- set_##n##_from_string (toplevel, \
- gconf_value_get_string (value)); \
- }
-
-#define UPDATE_INT(k, n) \
- if (!strcmp (key, k)) { \
- if (value->type == GCONF_VALUE_INT) \
- panel_toplevel_set_##n (toplevel, \
- gconf_value_get_int (value)); \
- }
-
-#define UPDATE_BOOL(k, n) \
- if (!strcmp (key, k)) { \
- if (value->type == GCONF_VALUE_BOOL) \
- panel_toplevel_set_##n (toplevel, \
- gconf_value_get_bool (value)); \
- }
-
-#define UPDATE_POS(k, n, n2) \
- if (!strcmp (key, k)) { \
- if (value->type == GCONF_VALUE_INT) { \
- int x, x_right, y, y_bottom; \
- panel_toplevel_get_position (toplevel, &x, &x_right, \
- &y, &y_bottom); \
- panel_toplevel_set_##n ( \
- toplevel, \
- gconf_value_get_int (value), \
- n2, \
- panel_toplevel_get_##n##_centered (toplevel)); \
- } \
- }
-
-#define UPDATE_POS2(k, n, n2) \
- if (!strcmp (key, k)) { \
- if (value->type == GCONF_VALUE_INT) { \
- int x, x_right, y, y_bottom; \
- panel_toplevel_get_position (toplevel, &x, &x_right, \
- &y, &y_bottom); \
- panel_toplevel_set_##n ( \
- toplevel, \
- n, \
- gconf_value_get_int (value), \
- panel_toplevel_get_##n##_centered (toplevel)); \
- } \
- }
-
-#define UPDATE_CENTERED(k, n, n2) \
- if (!strcmp (key, k)) { \
- if (value->type == GCONF_VALUE_BOOL) { \
- int x, x_right, y, y_bottom; \
- panel_toplevel_get_position (toplevel, &x, &x_right, \
- &y, &y_bottom); \
- panel_toplevel_set_##n ( \
- toplevel, n, n2, gconf_value_get_bool (value)); \
- } \
- }
-
if (!strcmp (key, "screen")) {
if (value->type == GCONF_VALUE_INT) {
GdkScreen *screen;
@@ -1055,140 +452,8 @@ panel_profile_toplevel_change_notify (GConfClient *client,
}
}
- else UPDATE_INT ("monitor", monitor)
- else UPDATE_STRING ("name", name)
- else UPDATE_BOOL ("expand", expand)
- else UPDATE_STRING ("orientation", orientation)
- else UPDATE_INT ("size", size)
- else UPDATE_POS ("x", x, x_right)
- else UPDATE_POS ("y", y, y_bottom)
- else UPDATE_POS2 ("x_right", x, x_right)
- else UPDATE_POS2 ("y_bottom", y, y_bottom)
- else UPDATE_CENTERED ("x_centered", x, x_right)
- else UPDATE_CENTERED ("y_centered", y, y_bottom)
- else UPDATE_BOOL ("auto_hide", auto_hide)
- else UPDATE_BOOL ("enable_buttons", enable_buttons)
- else UPDATE_BOOL ("enable_arrows", enable_arrows)
- else UPDATE_INT ("hide_delay", hide_delay)
- else UPDATE_INT ("unhide_delay", unhide_delay)
- else UPDATE_INT ("auto_hide_size", auto_hide_size)
- else UPDATE_STRING ("animation_speed", animation_speed)
-}
-
-static void
-panel_profile_background_change_notify (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- PanelToplevel *toplevel)
-{
- PanelWidget *panel_widget;
- PanelBackground *background;
- GConfValue *value;
- const char *key;
-
- key = panel_gconf_basename (gconf_entry_get_key (entry));
-
- if (!(value = gconf_entry_get_value (entry)))
- return;
-
- panel_widget = panel_toplevel_get_panel_widget (toplevel);
- background = &panel_widget->background;
-
- if (!strcmp (key, "type")) {
- if (value->type == GCONF_VALUE_STRING) {
- PanelBackgroundType background_type;
-
- if (panel_profile_map_background_type_string (
- gconf_value_get_string (value),
- &background_type)) {
- panel_background_set_type (background, background_type);
- panel_toplevel_update_edges (toplevel);
- }
- }
- } else if (!strcmp (key, "color")) {
- if (value->type == GCONF_VALUE_STRING) {
- GdkRGBA color;
- const char *str;
- const GdkRGBA *bg_color;
-
- str = gconf_value_get_string (value);
-
- if (gdk_rgba_parse (&color, str)) {
- /* we save rgba nowadays, but the opacity
- * setting is still living in a different key
- */
- bg_color = panel_background_get_color (background);
- color.alpha = bg_color->alpha;
- panel_background_set_color (background, &color);
- }
- }
- } else if (!strcmp (key, "opacity")) {
- if (value->type == GCONF_VALUE_INT) {
- guint16 opacity;
- const GdkRGBA *bg_color;
- GdkRGBA color;
-
- opacity = gconf_value_get_int (value);
- bg_color = panel_background_get_color (background);
- color = *bg_color;
- color.alpha = opacity / 65535.;
- panel_background_set_color (background, &color);
- }
- } else if (!strcmp (key, "image")) {
- if (value->type == GCONF_VALUE_STRING)
- panel_background_set_image (background,
- gconf_value_get_string (value));
- } else if (!strcmp (key, "fit")) {
- if (value->type == GCONF_VALUE_BOOL)
- panel_background_set_fit (background,
- gconf_value_get_bool (value));
- } else if (!strcmp (key, "stretch")) {
- if (value->type == GCONF_VALUE_BOOL)
- panel_background_set_stretch (background,
- gconf_value_get_bool (value));
- } else if (!strcmp (key, "rotate")) {
- if (value->type == GCONF_VALUE_BOOL)
- panel_background_set_rotate (background,
- gconf_value_get_bool (value));
- }
-}
-
-static void
-panel_profile_disconnect_toplevel (PanelToplevel *toplevel,
- gpointer data)
-{
- GConfClient *client;
- guint notify_id = GPOINTER_TO_UINT (data);
-
- client = panel_gconf_get_client ();
-
- gconf_client_notify_remove (client, notify_id);
-}
-
-guint
-panel_profile_toplevel_notify_add (PanelToplevel *toplevel,
- const char *key,
- GConfClientNotifyFunc func,
- gpointer data)
-{
- GConfClient *client;
- const char *tmp;
- guint retval;
-
- client = panel_gconf_get_client ();
-
- if (!key)
- tmp = panel_gconf_sprintf (PANEL_CONFIG_DIR "/toplevels/%s",
- panel_profile_get_toplevel_id (toplevel));
- else
- tmp = panel_gconf_sprintf (PANEL_CONFIG_DIR "/toplevels/%s/%s",
- panel_profile_get_toplevel_id (toplevel),
- key);
-
- retval = gconf_client_notify_add (client, tmp, func, data, NULL, NULL);
-
- return retval;
}
+#endif
static void
panel_profile_save_id_list (PanelGConfKeyType type,
@@ -1459,7 +724,7 @@ panel_profile_delete_toplevel (PanelToplevel *toplevel)
{
const char *toplevel_id;
- toplevel_id = panel_profile_get_toplevel_id (toplevel);
+ toplevel_id = panel_toplevel_get_toplevel_id (toplevel);
panel_profile_delete_toplevel_objects (toplevel_id, PANEL_GCONF_OBJECTS);
panel_profile_delete_toplevel_objects (toplevel_id, PANEL_GCONF_APPLETS);
@@ -1467,212 +732,6 @@ panel_profile_delete_toplevel (PanelToplevel *toplevel)
panel_profile_remove_from_list (PANEL_GCONF_TOPLEVELS, toplevel_id);
}
-static GdkScreen *
-get_toplevel_screen (GConfClient *client,
- const char *toplevel_dir)
-{
- GError *error = NULL;
- GdkDisplay *display;
- const char *key;
- int screen_n;
-
- key = panel_gconf_sprintf ("%s/screen", toplevel_dir);
- screen_n = gconf_client_get_int (client, key, &error);
- if (error) {
- g_warning (_("Error reading GConf integer value '%s': %s"),
- key, error->message);
- g_error_free (error);
- return gdk_screen_get_default ();
- }
-
- display = gdk_display_get_default ();
-
- if (screen_n < 0 || screen_n >= gdk_display_get_n_screens (display)) {
-#if 0
- g_warning (_("Panel '%s' is set to be displayed on screen %d which "
- "is not currently available. Not loading this panel."),
- toplevel_dir, screen_n);
-#endif
- return NULL;
- }
-
- return gdk_display_get_screen (display, screen_n);
-}
-
-PanelToplevel *
-panel_profile_load_toplevel (GConfClient *client,
- const char *profile_dir,
- PanelGConfKeyType type,
- const char *toplevel_id)
-{
- PanelToplevel *toplevel;
- GdkScreen *screen;
- GError *error;
- const char *key;
- char *toplevel_dir;
- guint notify_id;
-
- if (!toplevel_id || !toplevel_id [0])
- return NULL;
-
- toplevel_dir = g_strdup_printf ("%s/toplevels/%s", profile_dir, toplevel_id);
-
- if (!gconf_client_dir_exists (client, toplevel_dir, NULL))
- panel_gconf_associate_schemas_in_dir (
- client, toplevel_dir, PANEL_SCHEMAS_DIR "/toplevels");
-
- gconf_client_add_dir (client,
- toplevel_dir,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
-
- key = panel_gconf_sprintf ("%s/background", toplevel_dir);
- gconf_client_add_dir (client,
- key,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
-
- if (!(screen = get_toplevel_screen (client, toplevel_dir))) {
- gconf_client_remove_dir (client, key, NULL);
- gconf_client_remove_dir (client, toplevel_dir, NULL);
- g_free (toplevel_dir);
- return NULL;
- }
-
- toplevel = g_object_new (PANEL_TYPE_TOPLEVEL,
- "screen", screen,
- NULL);
-
-#define GET_INT(k, fn) \
- { \
- int val; \
- error = NULL; \
- key = panel_gconf_sprintf ("%s/" k, toplevel_dir); \
- val = gconf_client_get_int (client, key, &error); \
- if (!error) \
- panel_toplevel_set_##fn (toplevel, val); \
- else { \
- g_warning (_("Error reading GConf integer value '%s': %s"), \
- key, error->message); \
- g_error_free (error); \
- } \
- }
-
-#define GET_BOOL(k, fn) \
- { \
- gboolean val; \
- error = NULL; \
- key = panel_gconf_sprintf ("%s/" k, toplevel_dir); \
- val = gconf_client_get_bool (client, key, &error); \
- if (!error) \
- panel_toplevel_set_##fn (toplevel, val); \
- else { \
- g_warning (_("Error reading GConf boolean value '%s': %s"), \
- key, error->message); \
- g_error_free (error); \
- } \
- }
-
-#define GET_STRING(k, fn) \
- { \
- char *val; \
- error = NULL; \
- key = panel_gconf_sprintf ("%s/" k, toplevel_dir); \
- val = gconf_client_get_string (client, key, &error); \
- if (!error && val) { \
- set_##fn##_from_string (toplevel, val); \
- g_free (val); \
- } else if (error) { \
- g_warning (_("Error reading GConf string value '%s': %s"), \
- key, error->message); \
- g_error_free (error); \
- } \
- }
-
- GET_STRING ("name", name);
- GET_INT ("monitor", monitor);
- GET_BOOL ("expand", expand);
- GET_STRING ("orientation", orientation);
- GET_INT ("size", size);
- GET_BOOL ("auto_hide", auto_hide);
- GET_BOOL ("enable_buttons", enable_buttons);
- GET_BOOL ("enable_arrows", enable_arrows);
- GET_INT ("hide_delay", hide_delay);
- GET_INT ("unhide_delay", unhide_delay);
- GET_INT ("auto_hide_size", auto_hide_size);
- GET_STRING ("animation_speed", animation_speed);
-
-#define GET_POSITION(a, b, c, fn) \
- { \
- gboolean centered; \
- int position; \
- int position2; \
- key = panel_gconf_sprintf ("%s/" c, toplevel_dir); \
- centered = gconf_client_get_bool (client, key, &error); \
- if (!error) { \
- key = panel_gconf_sprintf ("%s/" a, toplevel_dir); \
- position = gconf_client_get_int (client, key, &error); \
- } \
- if (!error) { \
- GConfValue *value; \
- key = panel_gconf_sprintf ("%s/" b, toplevel_dir); \
- /* we need to do this since the key was added in 2.19 and \
- * the default value returned when the key is not set \
- * (for people coming from older versions) is 0, which \
- * is not what we want. */ \
- value = gconf_client_get_without_default (client, key, &error);\
- if (value && value->type == GCONF_VALUE_INT) \
- position2 = gconf_value_get_int (value); \
- else \
- position2 = -1; \
- \
- if (value) \
- gconf_value_free (value); \
- } \
- if (!error) \
- panel_toplevel_set_##fn (toplevel, position, position2, \
- centered); \
- else { \
- g_warning (_("Error reading GConf integer value '%s': %s"), \
- key, error->message); \
- g_error_free (error); \
- } \
- }
-
- GET_POSITION ("x", "x_right", "x_centered", x);
- GET_POSITION ("y", "y_bottom", "y_centered", y);
-
- panel_profile_load_background (toplevel, client, toplevel_dir);
-
- panel_profile_set_toplevel_id (toplevel, toplevel_id);
-
- panel_profile_connect_to_toplevel (toplevel);
-
- notify_id = panel_profile_toplevel_notify_add (
- toplevel,
- NULL,
- (GConfClientNotifyFunc) panel_profile_toplevel_change_notify,
- toplevel);
- g_signal_connect (toplevel, "destroy",
- G_CALLBACK (panel_profile_disconnect_toplevel),
- GUINT_TO_POINTER (notify_id));
-
- notify_id = panel_profile_toplevel_notify_add (
- toplevel,
- "background",
- (GConfClientNotifyFunc) panel_profile_background_change_notify,
- toplevel);
- g_signal_connect (toplevel, "destroy",
- G_CALLBACK (panel_profile_disconnect_toplevel),
- GUINT_TO_POINTER (notify_id));
-
- g_free (toplevel_dir);
-
- panel_setup (toplevel);
-
- return toplevel;
-}
-
static void
panel_profile_load_and_show_toplevel (GConfClient *client,
const char *profile_dir,
@@ -1685,12 +744,10 @@ panel_profile_load_and_show_toplevel (GConfClient *client,
GConfValue *value;
gboolean loading_queued_applets;
- toplevel = panel_profile_load_toplevel (client, profile_dir, type, toplevel_id);
+ toplevel = NULL;
if (!toplevel)
return;
- gtk_widget_show (GTK_WIDGET (toplevel));
-
loading_queued_applets = FALSE;
/* reload list of objects to get those that might be on the new
@@ -1725,11 +782,6 @@ panel_profile_load_and_show_toplevel_startup (GConfClient *client,
PanelGConfKeyType type,
const char *toplevel_id)
{
- PanelToplevel *toplevel;
-
- toplevel = panel_profile_load_toplevel (client, profile_dir, type, toplevel_id);
- if (toplevel)
- gtk_widget_show (GTK_WIDGET (toplevel));
}
static void
@@ -1737,7 +789,7 @@ panel_profile_destroy_toplevel (const char *id)
{
PanelToplevel *toplevel;
- if (!(toplevel = panel_profile_get_toplevel_by_id (id)))
+ if (!(toplevel = panel_toplevel_get_by_id (id)))
return;
gtk_widget_destroy (GTK_WIDGET (toplevel));
@@ -1793,7 +845,7 @@ panel_profile_prepare_object (PanelObjectType object_type,
gboolean right_stick)
{
return panel_profile_prepare_object_with_id (object_type,
- panel_profile_get_toplevel_id (toplevel),
+ panel_toplevel_get_toplevel_id (toplevel),
position,
right_stick);
}
@@ -2053,7 +1105,7 @@ panel_profile_toplevel_id_list_notify (GConfClient *client,
PANEL_GCONF_TOPLEVELS,
existing_toplevels,
toplevel_ids,
- (PanelProfileGetIdFunc) panel_profile_get_toplevel_id,
+ (PanelProfileGetIdFunc) panel_toplevel_get_toplevel_id,
(PanelProfileLoadFunc) panel_profile_load_and_show_toplevel,
(PanelProfileOnLoadQueue) NULL);
@@ -2061,7 +1113,7 @@ panel_profile_toplevel_id_list_notify (GConfClient *client,
PANEL_GCONF_TOPLEVELS,
existing_toplevels,
toplevel_ids,
- (PanelProfileGetIdFunc) panel_profile_get_toplevel_id,
+ (PanelProfileGetIdFunc) panel_toplevel_get_toplevel_id,
(PanelProfileDestroyFunc) panel_profile_destroy_toplevel);
g_slist_free (existing_toplevels);
@@ -2173,215 +1225,6 @@ panel_profile_load_list (GConfClient *client,
g_slist_free (list);
}
-static GSList *
-panel_profile_copy_defaults_for_screen (GConfClient *client,
- const char *profile_dir,
- int screen_n,
- PanelGConfKeyType type)
-{
- GSList *default_ids, *l;
- GSList *new_ids = NULL;
- const char *key;
- const char *id_list, *type_str;
-
- id_list = panel_gconf_key_type_to_id_list (type);
-
- switch (type) {
- case PANEL_GCONF_TOPLEVELS:
- type_str = "toplevels";
- break;
- case PANEL_GCONF_OBJECTS:
- type_str = "objects";
- break;
- case PANEL_GCONF_APPLETS:
- type_str = "applets";
- break;
- default:
- type_str = NULL;
- g_assert_not_reached ();
- break;
- }
-
- key = panel_gconf_sprintf (PANEL_DEFAULTS_DIR "/general/%s", id_list);
- default_ids = gconf_client_get_list (client, key, GCONF_VALUE_STRING, NULL);
-
- for (l = default_ids; l; l = l->next) {
- char *default_id = l->data;
- char *new_id;
- char *src_dir;
- char *dest_dir;
-
- new_id = g_strdup_printf ("%s_screen%d", default_id, screen_n);
-
- src_dir = g_strdup_printf (PANEL_DEFAULTS_DIR "/%s/%s", type_str, default_id);
- dest_dir = g_strdup_printf ("%s/%s/%s", profile_dir, type_str, new_id);
-
- panel_gconf_copy_dir (client, src_dir, dest_dir);
-
- new_ids = g_slist_prepend (new_ids, new_id);
-
- g_free (src_dir);
- g_free (dest_dir);
- g_free (l->data);
- }
- g_slist_free (default_ids);
-
- return new_ids;
-}
-
-static void
-panel_profile_append_new_ids (GConfClient *client,
- PanelGConfKeyType type,
- GSList *new_ids)
-{
- GSList *list, *l;
- const char *key;
- const char *id_list;
-
- id_list = panel_gconf_key_type_to_id_list (type);
-
- key = panel_gconf_general_key (id_list);
- list = gconf_client_get_list (client, key, GCONF_VALUE_STRING, NULL);
-
- for (l = new_ids; l; l = l->next)
- list = g_slist_append (list, l->data);
-
- g_slist_free (new_ids);
-
- gconf_client_set_list (client, key, GCONF_VALUE_STRING, list, NULL);
-
- for (l = list; l; l = l->next)
- g_free (l->data);
- g_slist_free (list);
-}
-
-static void
-panel_profile_copy_default_objects_for_screen (GConfClient *client,
- const char *profile_dir,
- int screen_n,
- PanelGConfKeyType type)
-{
- GSList *new_objects, *l, *next;
-
- new_objects = panel_profile_copy_defaults_for_screen (client, profile_dir, screen_n, type);
-
- for (l = new_objects; l; l = next) {
- char *object_id = l->data;
- const char *key;
- char *toplevel_id;
- char *new_toplevel_id;
-
- next = l->next;
-
- key = panel_gconf_full_key (type, object_id, "toplevel_id");
- toplevel_id = gconf_client_get_string (client, key, NULL);
- if (!toplevel_id) {
- new_objects = g_slist_remove_link (new_objects, l);
- g_free (l->data);
- g_slist_free_1 (l);
- continue;
- }
-
- new_toplevel_id = g_strdup_printf ("%s_screen%d", toplevel_id, screen_n);
- gconf_client_set_string (client, key, new_toplevel_id, NULL);
-
- g_free (toplevel_id);
- g_free (new_toplevel_id);
- }
-
- panel_profile_append_new_ids (client, type, new_objects);
-}
-
-/* FIXME:
- * We might want to do something more sophisticated like hardcode
- * the default panel setup as the fallback panels.
- */
-static GSList *
-panel_profile_create_fallback_toplevel_list (GConfClient *client,
- const char *profile_dir)
-{
- char *id;
- char *dir;
-
- id = panel_profile_find_new_id (PANEL_GCONF_TOPLEVELS);
-
- dir = g_strdup_printf ("%s/toplevels/%s", profile_dir, id);
- panel_gconf_associate_schemas_in_dir (client, dir, PANEL_SCHEMAS_DIR "/toplevels");
- g_free (dir);
-
- return g_slist_prepend (NULL, id);
-}
-
-static void
-panel_profile_load_defaults_on_screen (GConfClient *client,
- const char *profile_dir,
- GdkScreen *screen)
-{
- GSList *new_toplevels, *l;
- int screen_n;
-
- screen_n = gdk_screen_get_number (screen);
-
- new_toplevels = panel_profile_copy_defaults_for_screen (
- client, profile_dir, screen_n, PANEL_GCONF_TOPLEVELS);
- if (!new_toplevels) {
- g_warning ("Failed to load default panel configuration. panel-default-setup.entries "
- "hasn't been installed using gconftool-2 --load ?\n");
- new_toplevels = panel_profile_create_fallback_toplevel_list (client, profile_dir);
- }
-
- for (l = new_toplevels; l; l = l->next) {
- char *toplevel_id = l->data;
- const char *key;
-
- key = panel_gconf_full_key (PANEL_GCONF_TOPLEVELS,
- toplevel_id,
- "screen");
- gconf_client_set_int (client, key, screen_n, NULL);
- }
-
- panel_profile_append_new_ids (client, PANEL_GCONF_TOPLEVELS, new_toplevels);
-
- panel_profile_copy_default_objects_for_screen (
- client, profile_dir, screen_n, PANEL_GCONF_OBJECTS);
- panel_profile_copy_default_objects_for_screen (
- client, profile_dir, screen_n, PANEL_GCONF_APPLETS);
-}
-
-static void
-panel_profile_ensure_toplevel_per_screen (GConfClient *client,
- const char *profile_dir)
-{
- GSList *toplevels;
- GSList *empty_screens = NULL;
- GSList *l;
- GdkDisplay *display;
- int n_screens, i;
-
- 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);
- }
-
- for (l = empty_screens; l; l = l->next)
- panel_profile_load_defaults_on_screen (client, profile_dir, l->data);
-
- g_slist_free (empty_screens);
-}
-
void
panel_profile_load (void)
{
@@ -2407,8 +1250,6 @@ panel_profile_load (void)
panel_profile_load_object,
(GConfClientNotifyFunc) panel_profile_object_id_list_notify);
- panel_profile_ensure_toplevel_per_screen (client, PANEL_CONFIG_DIR);
-
panel_applet_load_queued_applets (TRUE);
}
diff --git a/gnome-panel/panel-properties-dialog.c b/gnome-panel/panel-properties-dialog.c
index 653b322..c0fe748 100644
--- a/gnome-panel/panel-properties-dialog.c
+++ b/gnome-panel/panel-properties-dialog.c
@@ -454,6 +454,7 @@ panel_properties_dialog_setup_background_radios (PanelPropertiesDialog *dialog,
dialog->color_widgets = PANEL_GTK_BUILDER_GET (gui, "color_widgets");
dialog->image_widgets = PANEL_GTK_BUILDER_GET (gui, "image_widgets");
+#if 0
background_type = panel_profile_get_background_type (dialog->toplevel);
switch (background_type) {
case PANEL_BACK_NONE:
@@ -469,6 +470,7 @@ panel_properties_dialog_setup_background_radios (PanelPropertiesDialog *dialog,
active_radio = NULL;
g_assert_not_reached ();
}
+#endif
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (active_radio), TRUE);
@@ -636,6 +638,7 @@ panel_properties_dialog_update_background_type (PanelPropertiesDialog *dialog,
if (!value || value->type != GCONF_VALUE_STRING)
return;
+#if 0
if (!panel_profile_map_background_type_string (gconf_value_get_string (value),
&background_type))
return;
@@ -655,6 +658,7 @@ panel_properties_dialog_update_background_type (PanelPropertiesDialog *dialog,
g_assert_not_reached ();
break;
}
+#endif
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (active_radio), TRUE);
}
@@ -789,24 +793,28 @@ panel_properties_dialog_new (PanelToplevel *toplevel,
G_CALLBACK (panel_properties_update_arrows_toggle_visible),
dialog);
+#if 0
dialog->toplevel_notify =
panel_profile_toplevel_notify_add (
dialog->toplevel,
NULL,
(GConfClientNotifyFunc) panel_properties_dialog_toplevel_notify,
dialog);
+#endif
panel_properties_dialog_setup_color_button (dialog, gui);
panel_properties_dialog_setup_image_chooser (dialog, gui);
panel_properties_dialog_setup_opacity_scale (dialog, gui);
panel_properties_dialog_setup_background_radios (dialog, gui);
+#if 0
dialog->background_notify =
panel_profile_toplevel_notify_add (
dialog->toplevel,
"background",
(GConfClientNotifyFunc) panel_properties_dialog_background_notify,
dialog);
+#endif
panel_toplevel_push_autohide_disabler (dialog->toplevel);
panel_widget_register_open_dialog (panel_toplevel_get_panel_widget (dialog->toplevel),
diff --git a/gnome-panel/panel-schemas.h b/gnome-panel/panel-schemas.h
index b6fda2c..27a6884 100644
--- a/gnome-panel/panel-schemas.h
+++ b/gnome-panel/panel-schemas.h
@@ -52,6 +52,14 @@
#define PANEL_TOPLEVEL_AUTO_HIDE_SIZE "auto-hide-size"
#define PANEL_TOPLEVEL_ANIMATION_SPEED "animation-speed"
+#define PANEL_BACKGROUND_SCHEMA_CHILD "background"
+#define PANEL_BACKGROUND_TYPE_KEY "type"
+#define PANEL_BACKGROUND_COLOR_KEY "color"
+#define PANEL_BACKGROUND_IMAGE_KEY "image"
+#define PANEL_BACKGROUND_FIT_KEY "fit"
+#define PANEL_BACKGROUND_STRETCH_KEY "stretch"
+#define PANEL_BACKGROUND_ROTATE_KEY "rotate"
+
#define PANEL_OBJECT_SCHEMA "org.gnome.gnome-panel.object"
#define PANEL_OBJECT_IID_KEY "object-iid"
#define PANEL_OBJECT_TOPLEVEL_ID_KEY "toplevel-id"
diff --git a/gnome-panel/panel-toplevel.c b/gnome-panel/panel-toplevel.c
index 7c24b41..fa57668 100644
--- a/gnome-panel/panel-toplevel.c
+++ b/gnome-panel/panel-toplevel.c
@@ -35,6 +35,8 @@
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
+#include <libpanel-util/panel-glib.h>
+
#include "panel-profile.h"
#include "panel-frame.h"
#include "panel-xutils.h"
@@ -46,6 +48,7 @@
#include "panel-bindings.h"
#include "panel-struts.h"
#include "panel-lockdown.h"
+#include "panel-schemas.h"
G_DEFINE_TYPE (PanelToplevel, panel_toplevel, GTK_TYPE_WINDOW)
@@ -73,6 +76,13 @@ typedef enum {
} PanelGrabOpType;
struct _PanelToplevelPrivate {
+ char *toplevel_id;
+
+ char *settings_path;
+ GSettings *settings;
+ GSettings *delayed_settings;
+ guint apply_delayed_id;
+
gboolean expand;
PanelOrientation orientation;
int size;
@@ -198,6 +208,8 @@ enum {
enum {
PROP_0,
+ PROP_TOPLEVEL_ID,
+ PROP_SETTINGS_PATH,
PROP_NAME,
PROP_EXPAND,
PROP_ORIENTATION,
@@ -224,6 +236,11 @@ static GSList *toplevel_list = NULL;
static void panel_toplevel_calculate_animation_end_geometry (PanelToplevel *toplevel);
+static void panel_toplevel_bind_gsettings (PanelToplevel *toplevel);
+static void panel_toplevel_set_toplevel_id (PanelToplevel *toplevel,
+ const char *toplevel_id);
+static void panel_toplevel_set_settings_path (PanelToplevel *toplevel,
+ const char *settings_path);
static void panel_toplevel_set_animate (PanelToplevel *toplevel,
gboolean animate);
@@ -239,6 +256,24 @@ panel_toplevel_list_toplevels (void)
return toplevel_list;
}
+PanelToplevel *
+panel_toplevel_get_by_id (const char *toplevel_id)
+{
+ GSList *l;
+
+ if (PANEL_GLIB_STR_EMPTY (toplevel_id))
+ return NULL;
+
+ for (l = toplevel_list; l; l = l->next) {
+ PanelToplevel *toplevel = l->data;
+
+ if (!g_strcmp0 (toplevel->priv->toplevel_id, toplevel_id))
+ return toplevel;
+ }
+
+ return NULL;
+}
+
gboolean
panel_toplevel_is_last (PanelToplevel *toplevel)
{
@@ -3445,6 +3480,27 @@ panel_toplevel_screen_changed (GtkWidget *widget,
gtk_widget_queue_resize (widget);
}
+static GObject *
+panel_toplevel_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
+{
+ GObject *obj;
+ PanelToplevel *toplevel;
+
+ obj = G_OBJECT_CLASS (panel_toplevel_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_properties);
+
+ toplevel = PANEL_TOPLEVEL (obj);
+
+ /* We can't do that in init() as init() will set the properties to
+ * their default, and this would write to gsettings */
+ panel_toplevel_bind_gsettings (toplevel);
+
+ return obj;
+}
+
static void
panel_toplevel_set_property (GObject *object,
guint prop_id,
@@ -3458,6 +3514,12 @@ panel_toplevel_set_property (GObject *object,
toplevel = PANEL_TOPLEVEL (object);
switch (prop_id) {
+ case PROP_TOPLEVEL_ID:
+ panel_toplevel_set_toplevel_id (toplevel, g_value_get_string (value));
+ break;
+ case PROP_SETTINGS_PATH:
+ panel_toplevel_set_settings_path (toplevel, g_value_get_string (value));
+ break;
case PROP_NAME:
panel_toplevel_set_name (toplevel, g_value_get_string (value));
break;
@@ -3552,6 +3614,12 @@ panel_toplevel_get_property (GObject *object,
toplevel = PANEL_TOPLEVEL (object);
switch (prop_id) {
+ case PROP_TOPLEVEL_ID:
+ g_value_set_string (value, toplevel->priv->toplevel_id);
+ break;
+ case PROP_SETTINGS_PATH:
+ g_value_set_string (value, toplevel->priv->settings_path);
+ break;
case PROP_NAME:
g_value_set_string (value, panel_toplevel_get_name (toplevel));
break;
@@ -3635,6 +3703,26 @@ panel_toplevel_finalize (GObject *object)
g_free (toplevel->priv->name);
toplevel->priv->name = NULL;
+ if (toplevel->priv->apply_delayed_id)
+ g_source_remove (toplevel->priv->apply_delayed_id);
+ toplevel->priv->apply_delayed_id = 0;
+
+ if (toplevel->priv->delayed_settings)
+ g_object_unref (toplevel->priv->delayed_settings);
+ toplevel->priv->delayed_settings= NULL;
+
+ if (toplevel->priv->settings)
+ g_object_unref (toplevel->priv->settings);
+ toplevel->priv->settings= NULL;
+
+ if (toplevel->priv->settings_path)
+ g_free (toplevel->priv->settings_path);
+ toplevel->priv->settings_path = NULL;
+
+ if (toplevel->priv->toplevel_id)
+ g_free (toplevel->priv->toplevel_id);
+ toplevel->priv->toplevel_id = NULL;
+
G_OBJECT_CLASS (panel_toplevel_parent_class)->finalize (object);
}
@@ -3648,6 +3736,7 @@ panel_toplevel_class_init (PanelToplevelClass *klass)
binding_set = gtk_binding_set_by_class (klass);
+ gobject_class->constructor = panel_toplevel_constructor;
gobject_class->set_property = panel_toplevel_set_property;
gobject_class->get_property = panel_toplevel_get_property;
gobject_class->dispose = panel_toplevel_dispose;
@@ -3686,6 +3775,26 @@ panel_toplevel_class_init (PanelToplevelClass *klass)
g_object_class_install_property (
gobject_class,
+ PROP_TOPLEVEL_ID,
+ g_param_spec_string (
+ "toplevel-id",
+ "Panel identifier",
+ "Unique identifier of this panel",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_SETTINGS_PATH,
+ g_param_spec_string (
+ "settings-path",
+ "GSettings path",
+ "The GSettings path used for this panel",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (
+ gobject_class,
PROP_NAME,
g_param_spec_string (
"name",
@@ -3778,7 +3887,7 @@ panel_toplevel_class_init (PanelToplevelClass *klass)
gobject_class,
PROP_Y_BOTTOM,
g_param_spec_int (
- "y_bottom",
+ "y-bottom",
"Y position, from the bottom",
"The Y position of the panel, starting from the bottom of the screen",
-1,
@@ -4071,6 +4180,13 @@ panel_toplevel_init (PanelToplevel *toplevel)
{
toplevel->priv = PANEL_TOPLEVEL_GET_PRIVATE (toplevel);
+ toplevel->priv->toplevel_id = NULL;
+
+ toplevel->priv->settings_path = NULL;
+ toplevel->priv->settings = NULL;
+ toplevel->priv->delayed_settings = NULL;
+ toplevel->priv->apply_delayed_id = 0;
+
toplevel->priv->expand = TRUE;
toplevel->priv->orientation = PANEL_ORIENTATION_BOTTOM;
toplevel->priv->size = DEFAULT_SIZE;
@@ -4173,6 +4289,243 @@ panel_toplevel_get_panel_widget (PanelToplevel *toplevel)
return toplevel->priv->panel_widget;
}
+static gboolean
+panel_toplevel_apply_delayed_settings (PanelToplevel *toplevel)
+{
+ g_settings_apply (toplevel->priv->delayed_settings);
+
+ toplevel->priv->apply_delayed_id = 0;
+
+ return FALSE;
+}
+
+static void
+panel_toplevel_apply_delayed_settings_queue (PanelToplevel *toplevel)
+{
+ if (toplevel->priv->apply_delayed_id != 0)
+ return;
+
+ toplevel->priv->apply_delayed_id = g_timeout_add (500,
+ (GSourceFunc) panel_toplevel_apply_delayed_settings,
+ toplevel);
+}
+
+static gboolean
+panel_toplevel_settings_bind_get_screen (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
+{
+ PanelToplevel *toplevel = PANEL_TOPLEVEL (user_data);
+ GdkDisplay *display;
+ GdkScreen *screen;
+ int screen_n;
+
+ display = gdk_display_get_default ();
+ screen_n = g_variant_get_int32 (variant);
+
+ if (screen_n < 0 || screen_n >= gdk_display_get_n_screens (display)) {
+ /* Trigger an event so that the gsettings key gets updated, to
+ * to set the key back to an actual available screen so it will
+ * get loaded on next startup. */
+ g_object_notify (G_OBJECT (toplevel), "screen");
+ return FALSE;
+ }
+
+ screen = gdk_display_get_screen (display, screen_n);
+
+ if (screen != NULL)
+ g_value_set_object (value, screen);
+
+ return (screen != NULL);
+}
+
+static GVariant *
+panel_toplevel_settings_bind_set_screen (const GValue *value,
+ const GVariantType *expected_type,
+ gpointer user_data)
+{
+ GdkScreen *screen = g_value_get_object (value);
+
+ if (!screen || GDK_IS_SCREEN (screen))
+ screen = gdk_screen_get_default ();
+
+ return g_variant_new ("i", gdk_screen_get_number (screen));
+}
+
+static void
+panel_toplevel_bind_gsettings (PanelToplevel *toplevel)
+{
+ /* Delayed settings: the ones related to the position */
+
+ g_settings_bind (toplevel->priv->delayed_settings,
+ PANEL_TOPLEVEL_MONITOR,
+ toplevel,
+ "monitor",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->delayed_settings,
+ PANEL_TOPLEVEL_SIZE,
+ toplevel,
+ "size",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->delayed_settings,
+ PANEL_TOPLEVEL_ORIENTATION,
+ toplevel,
+ "orientation",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->delayed_settings,
+ PANEL_TOPLEVEL_X,
+ toplevel,
+ "x",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->delayed_settings,
+ PANEL_TOPLEVEL_X_RIGHT,
+ toplevel,
+ "x-right",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->delayed_settings,
+ PANEL_TOPLEVEL_X_CENTERED,
+ toplevel,
+ "x-centered",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->delayed_settings,
+ PANEL_TOPLEVEL_Y,
+ toplevel,
+ "y",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->delayed_settings,
+ PANEL_TOPLEVEL_Y_BOTTOM,
+ toplevel,
+ "y-bottom",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->delayed_settings,
+ PANEL_TOPLEVEL_Y_CENTERED,
+ toplevel,
+ "y-centered",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ /* Normal settings */
+
+ g_settings_bind_with_mapping (toplevel->priv->settings,
+ PANEL_TOPLEVEL_SCREEN,
+ toplevel,
+ "screen",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY,
+ panel_toplevel_settings_bind_get_screen,
+ panel_toplevel_settings_bind_set_screen,
+ toplevel, NULL);
+
+ g_settings_bind (toplevel->priv->settings,
+ PANEL_TOPLEVEL_NAME,
+ toplevel,
+ "name",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->settings,
+ PANEL_TOPLEVEL_EXPAND,
+ toplevel,
+ "expand",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->settings,
+ PANEL_TOPLEVEL_AUTO_HIDE,
+ toplevel,
+ "auto-hide",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->settings,
+ PANEL_TOPLEVEL_HIDE_DELAY,
+ toplevel,
+ "hide-delay",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->settings,
+ PANEL_TOPLEVEL_UNHIDE_DELAY,
+ toplevel,
+ "unhide-delay",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->settings,
+ PANEL_TOPLEVEL_AUTO_HIDE_SIZE,
+ toplevel,
+ "auto-hide-size",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->settings,
+ PANEL_TOPLEVEL_ANIMATION_SPEED,
+ toplevel,
+ "animation-speed",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->settings,
+ PANEL_TOPLEVEL_ENABLE_BUTTONS,
+ toplevel,
+ "buttons-enabled",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->settings,
+ PANEL_TOPLEVEL_ENABLE_ARROWS,
+ toplevel,
+ "arrows-enabled",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (toplevel->priv->settings,
+ PANEL_TOPLEVEL_NAME,
+ toplevel,
+ "name",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+}
+
+static void
+panel_toplevel_set_toplevel_id (PanelToplevel *toplevel,
+ const char *toplevel_id)
+{
+ g_assert (toplevel->priv->toplevel_id == NULL);
+
+ toplevel->priv->toplevel_id = g_strdup (toplevel_id);
+}
+
+G_CONST_RETURN char *
+panel_toplevel_get_toplevel_id (PanelToplevel *toplevel)
+{
+ g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL);
+
+ return toplevel->priv->toplevel_id;
+}
+
+static void
+panel_toplevel_set_settings_path (PanelToplevel *toplevel,
+ const char *settings_path)
+{
+ GSettings *settings_background;
+
+ g_assert (toplevel->priv->settings_path == NULL);
+ g_assert (toplevel->priv->settings == NULL);
+ g_assert (toplevel->priv->delayed_settings == NULL);
+
+ toplevel->priv->settings_path = g_strdup (settings_path);
+ toplevel->priv->settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA,
+ settings_path);
+ toplevel->priv->delayed_settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA,
+ settings_path);
+ g_settings_delay (toplevel->priv->delayed_settings);
+
+ settings_background = g_settings_get_child (toplevel->priv->settings,
+ PANEL_BACKGROUND_SCHEMA_CHILD);
+ /* FIXME: ideally, move this inside panel-widget.c since we're not
+ * supposed to know about the backgrounds here */
+ panel_background_settings_init (&toplevel->priv->panel_widget->background,
+ settings_background);
+ g_object_unref (settings_background);
+}
+
static void
panel_toplevel_update_name (PanelToplevel *toplevel)
{
@@ -4392,6 +4745,7 @@ panel_toplevel_set_orientation (PanelToplevel *toplevel,
gtk_widget_queue_resize (GTK_WIDGET (toplevel));
+ panel_toplevel_apply_delayed_settings_queue (toplevel);
g_object_notify (G_OBJECT (toplevel), "orientation");
g_object_thaw_notify (G_OBJECT (toplevel));
@@ -4421,6 +4775,7 @@ panel_toplevel_set_size (PanelToplevel *toplevel,
gtk_widget_queue_resize (GTK_WIDGET (toplevel));
+ panel_toplevel_apply_delayed_settings_queue (toplevel);
g_object_notify (G_OBJECT (toplevel), "size");
}
@@ -4496,8 +4851,10 @@ panel_toplevel_set_x (PanelToplevel *toplevel,
g_object_notify (G_OBJECT (toplevel), "x-centered");
}
- if (changed)
+ if (changed) {
+ panel_toplevel_apply_delayed_settings_queue (toplevel);
gtk_widget_queue_resize (GTK_WIDGET (toplevel));
+ }
g_object_thaw_notify (G_OBJECT (toplevel));
}
@@ -4534,8 +4891,10 @@ panel_toplevel_set_y (PanelToplevel *toplevel,
g_object_notify (G_OBJECT (toplevel), "y-centered");
}
- if (changed)
+ if (changed) {
+ panel_toplevel_apply_delayed_settings_queue (toplevel);
gtk_widget_queue_resize (GTK_WIDGET (toplevel));
+ }
g_object_thaw_notify (G_OBJECT (toplevel));
}
@@ -4657,6 +5016,7 @@ panel_toplevel_set_monitor (PanelToplevel *toplevel,
if (monitor < panel_multiscreen_monitors (screen))
panel_toplevel_set_monitor_internal (toplevel, monitor, TRUE);
+ panel_toplevel_apply_delayed_settings_queue (toplevel);
g_object_notify (G_OBJECT (toplevel), "monitor");
}
diff --git a/gnome-panel/panel-toplevel.h b/gnome-panel/panel-toplevel.h
index ceb60ec..27f8bff 100644
--- a/gnome-panel/panel-toplevel.h
+++ b/gnome-panel/panel-toplevel.h
@@ -76,6 +76,7 @@ GType panel_toplevel_get_type (void) G_GNUC_CONST;
PanelWidget *panel_toplevel_get_panel_widget (PanelToplevel *toplevel);
+G_CONST_RETURN char *panel_toplevel_get_toplevel_id (PanelToplevel *toplevel);
void panel_toplevel_set_name (PanelToplevel *toplevel,
const char *name);
G_CONST_RETURN char *panel_toplevel_get_name (PanelToplevel *toplevel);
@@ -158,7 +159,9 @@ void panel_toplevel_update_edges (PanelToplevel
gboolean panel_toplevel_is_last (PanelToplevel *toplevel);
int panel_toplevel_get_minimum_size (PanelToplevel *toplevel);
int panel_toplevel_get_maximum_size (PanelToplevel *toplevel);
+
GSList *panel_toplevel_list_toplevels (void);
+PanelToplevel *panel_toplevel_get_by_id (const char *toplevel_id);
G_END_DECLS
diff --git a/gnome-panel/panel.c b/gnome-panel/panel.c
index 45b95b7..b3a5ea7 100644
--- a/gnome-panel/panel.c
+++ b/gnome-panel/panel.c
@@ -552,7 +552,7 @@ drop_nautilus_desktop_uri (PanelWidget *panel,
return FALSE;
success = TRUE;
- id = panel_profile_get_toplevel_id (panel->toplevel);
+ id = panel_toplevel_get_toplevel_id (panel->toplevel);
basename = uri + strlen ("x-nautilus-desktop:///");
if (strncmp (basename, "trash", strlen ("trash")) == 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]