Commit 5da6a269 authored by Vincent Untz's avatar Vincent Untz
Browse files

panel: Drop panel-profile.[ch] and remove dead code in panel-gconf.[ch]

parent f7ef5d80
......@@ -60,7 +60,6 @@ panel_sources = \
panel-multiscreen.c \
panel-a11y.c \
panel-bindings.c \
panel-profile.c \
panel-force-quit.c \
panel-lockdown.c \
panel-addto.c \
......@@ -107,7 +106,6 @@ panel_headers = \
panel-multiscreen.h \
panel-a11y.h \
panel-bindings.h \
panel-profile.h \
panel-enums.h \
panel-enums-gsettings.h \
panel-force-quit.h \
......
......@@ -28,7 +28,6 @@
#include "panel-separator.h"
#include "panel-toplevel.h"
#include "panel-util.h"
#include "panel-profile.h"
#include "panel-menu-button.h"
#include "panel-globals.h"
#include "panel-properties-dialog.h"
......
......@@ -20,7 +20,6 @@
#include <libpanel-util/panel-cleanup.h>
#include <libpanel-util/panel-glib.h>
#include "panel-profile.h"
#include "panel-shell.h"
#include "panel-multiscreen.h"
#include "panel-session.h"
......@@ -98,8 +97,6 @@ main (int argc, char **argv)
panel_multiscreen_init ();
panel_init_stock_icons_and_items ();
panel_profile_load ();
if (!panel_layout_load ()) {
panel_cleanup_do ();
return 1;
......
......@@ -39,7 +39,6 @@
#include "panel.h"
#include "panel-stock-icons.h"
#include "panel-action-button.h"
#include "panel-profile.h"
#include "panel-menu-button.h"
#include "panel-menu-items.h"
#include "panel-globals.h"
......
......@@ -45,7 +45,6 @@
#include "panel-layout.h"
#include "panel-lockdown.h"
#include "panel-util.h"
#include "panel-profile.h"
#include "panel-addto.h"
#include "panel-icon-names.h"
......
......@@ -35,7 +35,6 @@
#include "panel-applets-manager.h"
#include "panel-bindings.h"
#include "panel-profile.h"
#include "panel.h"
#include "applet.h"
#include "panel-marshal.h"
......
......@@ -30,7 +30,7 @@
#include <glib/gi18n.h>
#include "panel-gconf.h"
#include "panel-profile.h"
#include "panel-toplevel.h"
#include "panel-xutils.h"
#define BINDINGS_PREFIX "/apps/metacity/window_keybindings"
......
......@@ -26,7 +26,6 @@
#include <libpanel-util/panel-glib.h>
#include "panel-applets-manager.h"
#include "panel-profile.h"
#include "panel-schemas.h"
#include "panel-compatibility.h"
......
......@@ -25,8 +25,7 @@
#ifndef __PANEL_COMPATIBILITY_H__
#define __PANEL_COMPATIBILITY_H__
#include <glib.h>
#include <gconf/gconf-client.h>
#include <gio/gio.h>
G_BEGIN_DECLS
......
......@@ -41,7 +41,6 @@
#include "panel-util.h"
#include "panel.h"
#include "menu.h"
#include "panel-profile.h"
#include "panel-properties-dialog.h"
#include "panel-layout.h"
#include "panel-lockdown.h"
......
......@@ -50,12 +50,6 @@ typedef enum {
PANEL_STATE_HIDDEN_RIGHT = 5
} PanelState;
typedef enum {
PANEL_GCONF_TOPLEVELS,
PANEL_GCONF_OBJECTS,
PANEL_GCONF_APPLETS
} PanelGConfKeyType;
typedef enum {
PANEL_OBJECT_MENU,
PANEL_OBJECT_LAUNCHER,
......
......@@ -101,74 +101,6 @@ panel_gconf_sprintf (const char *format,
return buffer;
}
const char *
panel_gconf_key_type_to_id_list (PanelGConfKeyType type)
{
char *retval;
switch (type) {
case PANEL_GCONF_TOPLEVELS:
retval = "toplevel_id_list";
break;
case PANEL_GCONF_APPLETS:
retval = "applet_id_list";
break;
case PANEL_GCONF_OBJECTS:
retval = "object_id_list";
break;
default:
retval = NULL;
g_assert_not_reached ();
break;
}
return retval;
}
const char *
panel_gconf_general_key (const char *key)
{
return panel_gconf_sprintf (PANEL_CONFIG_DIR "/general/%s", key);
}
const char *
panel_gconf_full_key (PanelGConfKeyType type,
const char *id,
const char *key)
{
char *subdir = NULL;
switch (type) {
case PANEL_GCONF_TOPLEVELS:
subdir = "toplevels";
break;
case PANEL_GCONF_OBJECTS:
subdir = "objects";
break;
case PANEL_GCONF_APPLETS:
subdir = "applets";
break;
default:
g_assert_not_reached ();
break;
}
return panel_gconf_sprintf (PANEL_CONFIG_DIR "/%s/%s/%s",
subdir, id, key);
}
const char *
panel_gconf_basename (const char *key)
{
char *retval;
g_return_val_if_fail (key != NULL, NULL);
retval = strrchr (key, '/');
return retval ? retval + 1 : NULL;
}
static void
panel_notify_object_dead (guint notify_id)
{
......@@ -201,58 +133,3 @@ panel_gconf_notify_add_while_alive (const char *key,
return notify_id;
}
void
panel_gconf_associate_schemas_in_dir (GConfClient *client,
const char *profile_dir,
const char *schema_dir)
{
GSList *list, *l;
#ifdef PANEL_GCONF_DEBUG
g_print ("associating schemas in %s to %s\n", schema_dir, profile_dir);
#endif
list = gconf_client_all_entries (client, schema_dir, NULL);
for (l = list; l; l = l->next) {
GConfEntry *entry = l->data;
const char *key;
char *tmp;
tmp = g_path_get_basename (gconf_entry_get_key (entry));
key = panel_gconf_sprintf ("%s/%s", profile_dir, tmp);
g_free (tmp);
gconf_engine_associate_schema (
client->engine, key, gconf_entry_get_key (entry), NULL);
gconf_entry_unref (entry);
}
g_slist_free (list);
list = gconf_client_all_dirs (client, schema_dir, NULL);
for (l = list; l; l = l->next) {
char *subdir = l->data;
char *prefs_subdir;
char *schema_subdir;
char *tmp;
tmp = g_path_get_basename (subdir);
prefs_subdir = g_strdup_printf ("%s/%s", profile_dir, tmp);
schema_subdir = g_strdup_printf ("%s/%s", schema_dir, tmp);
panel_gconf_associate_schemas_in_dir (
client, prefs_subdir, schema_subdir);
g_free (prefs_subdir);
g_free (schema_subdir);
g_free (subdir);
g_free (tmp);
}
g_slist_free (list);
}
......@@ -28,36 +28,16 @@
#include <gconf/gconf-client.h>
#include "panel-enums.h"
#define PANEL_CONFIG_DIR "/apps/panel"
#define PANEL_SCHEMAS_DIR "/schemas/apps/panel"
#define PANEL_DEFAULTS_DIR "/apps/panel/default_setup"
#define PANEL_OLD_CONFIG_DIR "/apps/panel/profiles/default"
G_BEGIN_DECLS
GConfClient *panel_gconf_get_client (void);
const char *panel_gconf_sprintf (const char *format, ...) G_GNUC_PRINTF (1, 2);
const char *panel_gconf_basename (const char *key);
const char *panel_gconf_general_key (const char *key);
const char *panel_gconf_full_key (PanelGConfKeyType type,
const char *id,
const char *key);
const char *panel_gconf_key_type_to_id_list (PanelGConfKeyType type);
guint panel_gconf_notify_add (const char *key,
GConfClientNotifyFunc notify_func,
gpointer user_data);
guint panel_gconf_notify_add_while_alive (const char *key,
GConfClientNotifyFunc notify_func,
GObject *alive_object);
void panel_gconf_associate_schemas_in_dir (GConfClient *client,
const char *profile_dir,
const char *schema_dir);
G_END_DECLS
#endif /* __PANEL_GCONF_H__ */
......@@ -26,6 +26,9 @@
#define __PANEL_LAYOUT_H__
#include <glib.h>
#include <gdk/gdk.h>
#include "panel-enums.h"
G_BEGIN_DECLS
......
/*
* panel-profile.c:
*
* 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>
*/
#include <config.h>
#include "panel-profile.h"
#include <string.h>
#include <glib/gi18n.h>
#include <libpanel-util/panel-list.h>
#include "applet.h"
#include "panel-gconf.h"
#include "panel.h"
#include "panel-object-loader.h"
#include "panel-widget.h"
#include "panel-util.h"
#include "panel-multiscreen.h"
#include "panel-toplevel.h"
#include "panel-lockdown.h"
static GConfEnumStringPair panel_object_type_map [] = {
{ PANEL_OBJECT_MENU, "menu-object" },
{ PANEL_OBJECT_LAUNCHER, "launcher-object" },
{ PANEL_OBJECT_APPLET, "external-applet" },
{ PANEL_OBJECT_ACTION, "action-applet" },
{ PANEL_OBJECT_MENU_BAR, "menu-bar" },
{ PANEL_OBJECT_SEPARATOR, "separator" },
/* The following is for backwards compatibility with 2.30.x and earlier */
{ PANEL_OBJECT_APPLET, "bonobo-applet" },
{ 0, NULL }
};
char *
panel_profile_find_new_id (PanelGConfKeyType type)
{
GConfClient *client;
GSList *l, *existing_ids;
const char *key;
char *retval = NULL;
char *prefix;
char *dir;
int i;
client = panel_gconf_get_client ();
switch (type) {
case PANEL_GCONF_TOPLEVELS:
prefix = "panel";
dir = "toplevels";
break;
case PANEL_GCONF_OBJECTS:
prefix = "object";
dir = "objects";
break;
case PANEL_GCONF_APPLETS:
prefix = "applet";
dir = "applets";
break;
default:
prefix = dir = NULL;
g_assert_not_reached ();
break;
}
key = panel_gconf_sprintf (PANEL_CONFIG_DIR "/%s", dir);
existing_ids = gconf_client_all_dirs (client, key, NULL);
for (i = 0; !retval; i++) {
retval = g_strdup_printf ("%s_%d", prefix, i);
for (l = existing_ids; l; l = l->next)
if (!strcmp (panel_gconf_basename (l->data), retval)) {
g_free (retval);
retval = NULL;
break;
}
}
g_assert (retval != NULL);
for (l = existing_ids; l; l = l->next)
g_free (l->data);
g_slist_free (existing_ids);
return retval;
}
static void
panel_profile_save_id_list (PanelGConfKeyType type,
GSList *list,
gboolean resave)
{
GConfClient *client;
const char *key;
const char *id_list;
g_assert (!(resave && list != NULL));
client = panel_gconf_get_client ();
id_list = panel_gconf_key_type_to_id_list (type);
key = panel_gconf_general_key (id_list);
if (resave)
list = gconf_client_get_list (client, key, GCONF_VALUE_STRING, NULL);
else {
/* Make sure the elements in the list appear only once. We only
* do it when we save a list with new elements. */
list = panel_g_slist_make_unique (list,
(GCompareFunc) strcmp,
TRUE);
}
gconf_client_set_list (client, key, GCONF_VALUE_STRING, list, NULL);
g_slist_foreach (list, (GFunc) g_free, NULL);
g_slist_free (list);
}
void
panel_profile_add_to_list (PanelGConfKeyType type,
const char *id)
{
GConfClient *client;
GSList *list;
const char *key;
const char *id_list;
char *new_id;
client = panel_gconf_get_client ();
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);
new_id = id ? g_strdup (id) : panel_profile_find_new_id (type);
list = g_slist_append (list, new_id);
panel_profile_save_id_list (type, list, FALSE);
}
char *
panel_profile_prepare_object_with_id (PanelObjectType object_type,
const char *toplevel_id,
int position,
gboolean right_stick)
{
PanelGConfKeyType key_type;
GConfClient *client;
const char *key;
char *id;
char *dir;
key_type = (object_type == PANEL_OBJECT_APPLET) ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS;
client = panel_gconf_get_client ();
id = panel_profile_find_new_id (key_type);
dir = g_strdup_printf (PANEL_CONFIG_DIR "/%s/%s",
(key_type == PANEL_GCONF_APPLETS) ? "applets" : "objects",
id);
panel_gconf_associate_schemas_in_dir (client, dir, PANEL_SCHEMAS_DIR "/objects");
key = panel_gconf_full_key (key_type, id, "object_type");
gconf_client_set_string (client,
key,
gconf_enum_to_string (panel_object_type_map, object_type),
NULL);
key = panel_gconf_full_key (key_type, id, "toplevel_id");
gconf_client_set_string (client, key, toplevel_id, NULL);
key = panel_gconf_full_key (key_type, id, "position");
gconf_client_set_int (client, key, position, NULL);
key = panel_gconf_full_key (key_type, id, "panel_right_stick");
gconf_client_set_bool (client, key, right_stick, NULL);
g_free (dir);
return id;
}
char *
panel_profile_prepare_object (PanelObjectType object_type,
PanelToplevel *toplevel,
int position,
gboolean right_stick)
{
return panel_profile_prepare_object_with_id (object_type,
panel_toplevel_get_toplevel_id (toplevel),
position,
right_stick);
}
void
panel_profile_load (void)
{
}
/*
* panel-profile.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_PROFILE_H__
#define __PANEL_PROFILE_H__
#include <glib.h>
#include <gdk/gdk.h>
#include <gconf/gconf-client.h>
#include "panel-toplevel.h"
#include "panel-enums.h"
#include "panel-types.h"
#include "applet.h"
G_BEGIN_DECLS
void panel_profile_load (void);
const char *panel_profile_get_toplevel_id (PanelToplevel *toplevel);
PanelToplevel *panel_profile_get_toplevel_by_id (const char *toplevel_id);
char *panel_profile_find_new_id (PanelGConfKeyType type);
void panel_profile_add_to_list (PanelGConfKeyType type,
const char *id);
void panel_profile_remove_from_list (PanelGConfKeyType type,
const char *id);
gboolean panel_profile_id_lists_are_writable (void);
void panel_profile_create_toplevel (GdkScreen *screen);
PanelToplevel *panel_profile_load_toplevel (GConfClient *client,
const char *profile_dir,
PanelGConfKeyType type,
const char *toplevel_id);
void panel_profile_delete_toplevel (PanelToplevel *toplevel);
char *panel_profile_prepare_object (PanelObjectType object_type,
PanelToplevel *toplevel,
int position,
gboolean right_stick);
char *panel_profile_prepare_object_with_id (PanelObjectType object_type,
const char *toplevel_id,
int position,
gboolean right_stick);
void panel_profile_delete_object (AppletInfo *applet_info);
void panel_profile_set_toplevel_name (PanelToplevel *toplevel,
const char *name);
char *panel_profile_get_toplevel_name (PanelToplevel *toplevel);
gboolean panel_profile_is_writable_toplevel_name (PanelToplevel *toplevel);
void panel_profile_set_toplevel_orientation (PanelToplevel *toplevel,
PanelOrientation orientation);
PanelOrientation
panel_profile_get_toplevel_orientation (PanelToplevel *toplevel);
gboolean panel_profile_is_writable_toplevel_orientation (PanelToplevel *toplevel);
void panel_profile_set_toplevel_size (PanelToplevel *toplevel,
int size);
int panel_profile_get_toplevel_size (PanelToplevel *toplevel);
gboolean panel_profile_is_writable_toplevel_size (PanelToplevel *toplevel);
void panel_profile_set_toplevel_expand (PanelToplevel *toplevel,
gboolean expand);
gboolean panel_profile_get_toplevel_expand (PanelToplevel *toplevel);
gboolean panel_profile_is_writable_toplevel_expand (PanelToplevel *toplevel);
void panel_profile_set_toplevel_auto_hide (PanelToplevel *toplevel,
gboolean auto_hide);
gboolean panel_profile_get_toplevel_auto_hide (PanelToplevel *toplevel);
gboolean panel_profile_is_writable_toplevel_auto_hide (PanelToplevel *toplevel);
void panel_profile_set_toplevel_enable_buttons (PanelToplevel *toplevel,
gboolean enable_buttons);
gboolean panel_profile_get_toplevel_enable_buttons (PanelToplevel *toplevel);
gboolean panel_profile_is_writable_toplevel_enable_buttons (PanelToplevel *toplevel);