Commit 88e0b8f6 authored by Vincent Untz's avatar Vincent Untz
Browse files

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.
parent 7454717e
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
......@@ -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>
......
......@@ -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)
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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);
......
/*
* 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__ */
......@@ -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)
......@@ -56,18 +50,6 @@ typedef enum {
PANEL_STATE_HIDDEN_RIGHT = 5
} 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,
......
......@@ -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;
......
This diff is collapsed.
......@@ -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