Commit 35eedce9 authored by Mark McLoughlin's avatar Mark McLoughlin Committed by Mark McLoughlin

fix silly. (panel_applet_load_from_unique_id): use

2002-01-07  Mark McLoughlin  <mark@skynet.ie>

        * applet.c: (panel_applet_get_full_gconf_key): fix silly.
        (panel_applet_load_from_unique_id): use
        panel_applet_frame_load_from_gconf and load launchers.
        (panel_applet_load_list): replace list_key arg with type arg.
        (panel_applet_load_applets_from_gconf): upd.
        (panel_applet_save_position): suggest a sync.
        (panel_applet_save_to_gconf): save launchers.

        * launcher.[ch]:
        (launcher_save_to_gconf), (launcher_load_from_gconf): impl.
        (load_launcher_applet_full), (load_launcher_applet): add a
        gconf_key arg.
        (really_add_launcher), (load_launcher_applet_from_info),
        (load_launcher_applet_from_info_url): upd.

        * menu.c: (add_app_to_panel), (add_drawers_from_dir),
        (add_launcher): upd for launcher change.

        * panel.c: (drop_urilist), (drop_internal_icon): ditto.

        * panel-applet-frame.[ch]:
        (panel_applet_frame_load_from_gconf): impl.
parent 3082173b
2002-01-07 Mark McLoughlin <mark@skynet.ie>
* applet.c: (panel_applet_get_full_gconf_key): fix silly.
(panel_applet_load_from_unique_id): use
panel_applet_frame_load_from_gconf and load launchers.
(panel_applet_load_list): replace list_key arg with type arg.
(panel_applet_load_applets_from_gconf): upd.
(panel_applet_save_position): suggest a sync.
(panel_applet_save_to_gconf): save launchers.
* launcher.[ch]:
(launcher_save_to_gconf), (launcher_load_from_gconf): impl.
(load_launcher_applet_full), (load_launcher_applet): add a
gconf_key arg.
(really_add_launcher), (load_launcher_applet_from_info),
(load_launcher_applet_from_info_url): upd.
* menu.c: (add_app_to_panel), (add_drawers_from_dir),
(add_launcher): upd for launcher change.
* panel.c: (drop_urilist), (drop_internal_icon): ditto.
* panel-applet-frame.[ch]:
(panel_applet_frame_load_from_gconf): impl.
2002-01-07 Mark McLoughlin <mark@skynet.ie>
Move applet loading/saving to/from gconf into applet.c where
......
......@@ -830,15 +830,16 @@ panel_applet_get_full_gconf_key (AppletType type,
char *retval = NULL;
if (type == APPLET_BONOBO)
retval = panel_gconf_applets_default_profile_get_full_key (profile, object_id, key);
retval = panel_gconf_applets_profile_get_full_key (profile, object_id, key);
else
retval = panel_gconf_objects_default_profile_get_full_key (profile, object_id, key);
retval = panel_gconf_objects_profile_get_full_key (profile, object_id, key);
return retval;
}
static void
panel_applet_load_from_unique_id (GConfClient *gconf_client,
panel_applet_load_from_unique_id (AppletType type,
GConfClient *gconf_client,
const char *profile,
const char *unique_id)
{
......@@ -850,7 +851,7 @@ panel_applet_load_from_unique_id (GConfClient *gconf_client,
int position;
gboolean right_stick;
temp_key = panel_gconf_applets_default_profile_get_full_key (profile, unique_id, "object-type");
temp_key = panel_applet_get_full_gconf_key (type, profile, unique_id, "object-type");
type_string = gconf_client_get_string (gconf_client, temp_key, NULL);
if (!gconf_string_to_enum (object_type_enum_map, type_string, (int *) &applet_type)) {
......@@ -861,15 +862,15 @@ panel_applet_load_from_unique_id (GConfClient *gconf_client,
g_free (temp_key);
g_free (type_string);
temp_key = panel_gconf_applets_default_profile_get_full_key (profile, unique_id, "position");
temp_key = panel_applet_get_full_gconf_key (type, profile, unique_id, "position");
position = gconf_client_get_int (gconf_client, temp_key, NULL);
g_free (temp_key);
temp_key = panel_gconf_applets_default_profile_get_full_key (profile, unique_id, "panel-id");
temp_key = panel_applet_get_full_gconf_key (type, profile, unique_id, "panel-id");
panel_id = gconf_client_get_string (gconf_client, temp_key, NULL);
g_free (temp_key);
temp_key = panel_gconf_applets_default_profile_get_full_key (profile, unique_id, "right-stick");
temp_key = panel_applet_get_full_gconf_key (type, profile, unique_id, "right-stick");
right_stick = gconf_client_get_bool (gconf_client, temp_key, NULL);
g_free (temp_key);
......@@ -882,17 +883,25 @@ panel_applet_load_from_unique_id (GConfClient *gconf_client,
position += right_stick ? G_MAXINT/2 : 0;
switch (applet_type) {
case APPLET_BONOBO: {
char *applet_iid;
temp_key = panel_gconf_applets_default_profile_get_full_key (profile, unique_id, "bonobo-iid");
applet_iid = gconf_client_get_string (gconf_client, temp_key, NULL);
g_free (temp_key);
panel_applet_frame_load (applet_iid, panel_widget, position, unique_id);
g_free (applet_iid);
}
case APPLET_BONOBO:
panel_applet_frame_load_from_gconf (panel_widget, position, unique_id);
break;
case APPLET_DRAWER:
break;
case APPLET_SWALLOW:
break;
case APPLET_MENU:
break;
case APPLET_LAUNCHER:
launcher_load_from_gconf (panel_widget, position, unique_id);
break;
case APPLET_LOGOUT:
break;
case APPLET_LOCK:
break;
case APPLET_STATUS:
break;
case APPLET_RUN:
break;
default:
break;
......@@ -900,19 +909,22 @@ panel_applet_load_from_unique_id (GConfClient *gconf_client,
}
static void
panel_applet_load_list (GConfClient *client,
const char *profile,
const char *list_key)
panel_applet_load_list (AppletType type,
GConfClient *client,
const char *profile)
{
GSList *id_list, *l;
char *temp_key;
char *temp_key = NULL;
temp_key = panel_gconf_general_profile_get_full_key (profile, list_key);
if (type == APPLET_BONOBO)
temp_key = panel_gconf_general_profile_get_full_key (profile, "applet-id-list");
else
temp_key = panel_gconf_general_profile_get_full_key (profile, "object-id-list");
id_list = gconf_client_get_list (panel_gconf_get_client (), temp_key, GCONF_VALUE_STRING, NULL);
for (l = id_list; l; l = l->next)
panel_applet_load_from_unique_id (client, profile, (char *) l->data);
panel_applet_load_from_unique_id (type, client, profile, (char *) l->data);
g_free (temp_key);
g_slist_foreach (id_list, (GFunc) g_free, NULL);
......@@ -928,8 +940,8 @@ panel_applet_load_applets_from_gconf (void)
client = panel_gconf_get_client ();
profile = session_get_current_profile ();
panel_applet_load_list (client, profile, "applet-id-list");
panel_applet_load_list (client, profile, "object-id-list");
panel_applet_load_list (APPLET_BONOBO, client, profile);
panel_applet_load_list (APPLET_EMPTY, client, profile);
}
void
......@@ -954,6 +966,8 @@ panel_applet_save_position (AppletInfo *applet_info,
temp_key = panel_applet_get_full_gconf_key (applet_info->type, profile, gconf_key, "right-stick");
gconf_client_set_bool (client, temp_key, panel_applet_get_right_stick (applet_info), NULL);
g_free (temp_key);
gconf_client_suggest_sync (client, NULL);
}
void
......@@ -1005,9 +1019,26 @@ panel_applet_save_to_gconf (AppletInfo *applet_info)
panel_applet_frame_save_to_gconf (PANEL_APPLET_FRAME (applet_info->data),
applet_info->gconf_key);
break;
case APPLET_DRAWER:
break;
case APPLET_SWALLOW:
break;
case APPLET_MENU:
break;
case APPLET_LAUNCHER:
launcher_save_to_gconf ((Launcher *) applet_info->data,
applet_info->gconf_key);
break;
case APPLET_LOGOUT: /* no object specific stuff to save */
case APPLET_LOCK:
case APPLET_STATUS:
case APPLET_RUN:
break;
default:
break;
}
gconf_client_suggest_sync (client, NULL);
}
AppletInfo *
......
......@@ -30,6 +30,7 @@
#include "menu.h"
#include "panel-util.h"
#include "panel-config-global.h"
#include "panel-gconf.h"
#include "session.h"
#include "xstuff.h"
......@@ -596,9 +597,57 @@ launcher_properties (Launcher *launcher)
gtk_widget_show_all (launcher->prop_dialog);
}
void
launcher_save_to_gconf (Launcher *launcher,
const char *gconf_key)
{
GConfClient *client;
char *profile;
char *temp_key;
const char *location;
client = panel_gconf_get_client ();
profile = session_get_current_profile ();
location = gnome_desktop_item_get_location (launcher->ditem);
temp_key = panel_gconf_applets_default_profile_get_full_key (profile, gconf_key, "base-location");
gconf_client_set_string (client, temp_key, location, NULL);
g_free (temp_key);
}
void
launcher_load_from_gconf (PanelWidget *panel_widget,
gint position,
const char *gconf_key)
{
GConfClient *client;
char *profile;
char *temp_key;
char *base_location;
g_return_if_fail (panel_widget);
g_return_if_fail (gconf_key);
client = panel_gconf_get_client ();
profile = session_get_current_profile ();
temp_key = panel_gconf_applets_default_profile_get_full_key (profile, gconf_key, "base-location");
base_location = gconf_client_get_string (client, temp_key, NULL);
g_free (temp_key);
load_launcher_applet (base_location, panel_widget, position, TRUE, gconf_key);
g_free (base_location);
}
Launcher *
load_launcher_applet_full (const char *params, GnomeDesktopItem *ditem,
PanelWidget *panel, int pos, gboolean exactpos)
load_launcher_applet_full (const char *params,
GnomeDesktopItem *ditem,
PanelWidget *panel,
int pos,
gboolean exactpos,
const char *gconf_key)
{
Launcher *launcher;
......@@ -610,7 +659,7 @@ load_launcher_applet_full (const char *params, GnomeDesktopItem *ditem,
launcher->info = panel_applet_register (launcher->button, launcher,
free_launcher, panel, pos,
exactpos, APPLET_LAUNCHER,
NULL);
gconf_key);
if (!launcher->info) {
/*
* Don't free launcher here, the button has
......@@ -649,7 +698,7 @@ really_add_launcher (GtkWidget *dialog, int response, gpointer data)
ditem = gnome_ditem_edit_get_ditem (dedit);
ditem = gnome_desktop_item_copy (ditem);
launcher = load_launcher_applet_full (NULL, ditem, panel, pos, exactpos);
launcher = load_launcher_applet_full (NULL, ditem, panel, pos, exactpos, NULL);
if (launcher != NULL)
launcher_hoard (launcher);
......@@ -760,7 +809,7 @@ load_launcher_applet_from_info (const char *name, const char *comment,
gnome_desktop_item_set_entry_type (ditem,
GNOME_DESKTOP_ITEM_TYPE_APPLICATION);
launcher = load_launcher_applet_full (NULL, ditem, panel, pos, exactpos);
launcher = load_launcher_applet_full (NULL, ditem, panel, pos, exactpos, NULL);
if (launcher != NULL)
launcher_save (launcher);
......@@ -791,7 +840,7 @@ load_launcher_applet_from_info_url (const char *name, const char *comment,
gnome_desktop_item_set_entry_type (ditem,
GNOME_DESKTOP_ITEM_TYPE_LINK);
launcher = load_launcher_applet_full (NULL, ditem, panel, pos, exactpos);
launcher = load_launcher_applet_full (NULL, ditem, panel, pos, exactpos, NULL);
if (launcher != NULL)
launcher_save (launcher);
......@@ -801,10 +850,13 @@ load_launcher_applet_from_info_url (const char *name, const char *comment,
}
Launcher *
load_launcher_applet (const char *params, PanelWidget *panel, int pos,
gboolean exactpos)
load_launcher_applet (const char *params,
PanelWidget *panel,
int pos,
gboolean exactpos,
const char *gconf_key)
{
return load_launcher_applet_full (params, NULL, panel, pos, exactpos);
return load_launcher_applet_full (params, NULL, panel, pos, exactpos, gconf_key);
}
static char *
......
......@@ -33,15 +33,19 @@ typedef struct {
* otherwise things may be removed from disk when they shouldn't
* etc. Also always hoard if an applet which owns a desktop already
* exists.*/
Launcher * load_launcher_applet_full (const char *params,
Launcher * load_launcher_applet_full (const char *params,
GnomeDesktopItem *ditem,
PanelWidget *panel,
int pos,
gboolean exactpos);
Launcher * load_launcher_applet (const char *params,
PanelWidget *panel,
int pos,
gboolean exactpos);
PanelWidget *panel,
int pos,
gboolean exactpos,
const char *gconf_key);
Launcher * load_launcher_applet (const char *params,
PanelWidget *panel,
int pos,
gboolean exactpos,
const char *gconf_key);
Launcher * load_launcher_applet_from_info (const char *name,
const char *comment,
const char *exec,
......@@ -58,6 +62,13 @@ Launcher * load_launcher_applet_from_info_url(const char *name,
gboolean exactpos);
void launcher_properties (Launcher *launcher);
void launcher_save_to_gconf (Launcher *launcher,
const char *gconf_key);
void launcher_load_from_gconf (PanelWidget *panel_widget,
gint position,
const char *gconf_key);
void ask_about_launcher (const char *file,
PanelWidget *panel,
int pos,
......
......@@ -979,7 +979,7 @@ add_app_to_panel (GtkWidget *widget, const char *item_loc)
PanelWidget *panel = get_panel_from_menu_data (widget, TRUE);
Launcher *launcher;
launcher = load_launcher_applet (item_loc, panel, 0, FALSE);
launcher = load_launcher_applet (item_loc, panel, 0, FALSE, NULL);
if (launcher != NULL)
launcher_hoard (launcher);
......@@ -1053,7 +1053,8 @@ add_drawers_from_dir (const char *dirname, const char *name,
dentry,
newpanel,
G_MAXINT/2,
FALSE);
FALSE,
NULL);
if (launcher != NULL)
launcher_hoard (launcher);
......@@ -1941,7 +1942,7 @@ add_launcher (GtkWidget *w, const char *item_loc)
Launcher *launcher;
launcher = load_launcher_applet
(item_loc, get_panel_from_menu_data (w, TRUE), 0, FALSE);
(item_loc, get_panel_from_menu_data (w, TRUE), 0, FALSE, NULL);
if (launcher != NULL)
launcher_hoard (launcher);
......
......@@ -62,6 +62,31 @@ panel_applet_frame_save_to_gconf (PanelAppletFrame *frame,
g_free (temp_key);
}
void
panel_applet_frame_load_from_gconf (PanelWidget *panel_widget,
gint position,
const char *gconf_key)
{
GConfClient *client;
char *profile;
char *temp_key;
char *applet_iid;
g_return_if_fail (panel_widget);
g_return_if_fail (gconf_key);
client = panel_gconf_get_client ();
profile = session_get_current_profile ();
temp_key = panel_gconf_applets_default_profile_get_full_key (profile, gconf_key, "bonobo-iid");
applet_iid = gconf_client_get_string (client, temp_key, NULL);
g_free (temp_key);
panel_applet_frame_load (applet_iid, panel_widget, position, gconf_key);
g_free (applet_iid);
}
static void
popup_handle_remove (BonoboUIComponent *uic,
PanelAppletFrame *frame,
......
......@@ -72,8 +72,6 @@ void panel_applet_frame_load (const gchar *iid,
void panel_applet_frame_load_applets (void);
void panel_applet_frame_save_to_gconf (PanelAppletFrame *frame,
const char *gconf_key);
void panel_applet_frame_change_orient (PanelAppletFrame *frame,
PanelOrient orient);
......@@ -95,6 +93,13 @@ void panel_applet_frame_get_expand_flags (PanelAppletFrame *frame,
gboolean *expand_major,
gboolean *expand_minor);
void panel_applet_frame_save_to_gconf (PanelAppletFrame *frame,
const char *gconf_key);
void panel_applet_frame_load_from_gconf (PanelWidget *panel_widget,
gint position,
const char *gconf_key);
G_END_DECLS
#endif /* __PANEL_APPLET_FRAME_H__ */
......@@ -1036,7 +1036,7 @@ drop_urilist (PanelWidget *panel, int pos, char *urilist,
strcmp(mimetype, "application/x-kde-app-info") == 0)) {
Launcher *launcher;
launcher = load_launcher_applet (uri, panel, pos, TRUE);
launcher = load_launcher_applet (uri, panel, pos, TRUE, NULL);
if (launcher != NULL)
launcher_hoard (launcher);
......@@ -1118,7 +1118,7 @@ drop_internal_icon (PanelWidget *panel, int pos, const char *icon_name,
old_launcher = NULL;
}
launcher = load_launcher_applet (icon_name, panel, pos, TRUE);
launcher = load_launcher_applet (icon_name, panel, pos, TRUE, NULL);
if (launcher != NULL) {
launcher_hoard (launcher);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment