Commit 79d19de3 authored by Mark McLoughlin's avatar Mark McLoughlin Committed by Mark McLoughlin

kill APPLET_RUN stuff. (panel_applet_load_from_unique_id),

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

        * applet.c:
        (applet_callback_callback): kill APPLET_RUN stuff.
        (panel_applet_load_from_unique_id),
        (panel_applet_save_to_gconf): load/save drawers, swallowed
        apps, status docks, logout and lock buttons.

        * drawer.[ch]:
        (load_drawer_applet): add gconf_key arg.
        (drawer_save_to_gconf), (drawer_load_from_gconf): impl.

        * swallow.[ch]: (really_add_swallow): upd.
        (load_swallow_applet): add gconf_key param.
        (swallow_save_to_gconf), (swallow_load_from_gconf): impl.

        * menu.[ch]: (add_drawers_from_dir), (add_drawer_to_panel):
        upd for drawers changes.

        * panel.c: (drop_internal_applet): ditto.

        * panel-main.h: kill panel_main_get_current_profile.

        * session.c: (panel_session_save_applets), (panel_quit):
        kill old applets loading/saving stuff.
parent 34002244
2002-01-07 Mark McLoughlin <mark@skynet.ie>
* applet.c:
(applet_callback_callback): kill APPLET_RUN stuff.
(panel_applet_load_from_unique_id),
(panel_applet_save_to_gconf): load/save drawers, swallowed
apps, status docks, logout and lock buttons.
* drawer.[ch]:
(load_drawer_applet): add gconf_key arg.
(drawer_save_to_gconf), (drawer_load_from_gconf): impl.
* swallow.[ch]: (really_add_swallow): upd.
(load_swallow_applet): add gconf_key param.
(swallow_save_to_gconf), (swallow_load_from_gconf): impl.
* menu.[ch]: (add_drawers_from_dir), (add_drawer_to_panel):
upd for drawers changes.
* panel.c: (drop_internal_applet): ditto.
* panel-main.h: kill panel_main_get_current_profile.
* session.c: (panel_session_save_applets), (panel_quit):
kill old applets loading/saving stuff.
2002-01-07 Mark McLoughlin <mark@skynet.ie>
* applet.c: (panel_applet_load_from_unique_id),
......
......@@ -17,6 +17,7 @@
#include "button-widget.h"
#include "drawer.h"
#include "launcher.h"
#include "logout.h"
#include "menu-properties.h"
#include "menu-util.h"
#include "panel-config.h"
......@@ -50,7 +51,6 @@ static GConfEnumStringPair object_type_enum_map [] = {
{ APPLET_EMPTY, "empty-object" },
{ APPLET_LOCK, "lock-object" },
{ APPLET_STATUS, "status-object" },
{ APPLET_RUN, "run-object" },
{ APPLET_BONOBO, "bonobo-applet" },
};
......@@ -277,10 +277,6 @@ applet_callback_callback(GtkWidget *widget, gpointer data)
if (strcmp (menu->name, "help") == 0)
panel_show_help ("specialobjects", "STATUSDOC");
break;
case APPLET_RUN:
if (strcmp (menu->name, "help") == 0)
panel_show_help ("specialobjects", "RUNBUTTON");
break;
case APPLET_BONOBO:
/*
* Applet's menu's are handled differently
......@@ -887,8 +883,10 @@ panel_applet_load_from_unique_id (AppletType type,
panel_applet_frame_load_from_gconf (panel_widget, position, unique_id);
break;
case APPLET_DRAWER:
drawer_load_from_gconf (panel_widget, position, unique_id);
break;
case APPLET_SWALLOW:
/*swallow_load_from_gconf (panel_widget, position, unique_id);*/
break;
case APPLET_MENU:
menu_load_from_gconf (panel_widget, position, unique_id);
......@@ -897,12 +895,13 @@ panel_applet_load_from_unique_id (AppletType type,
launcher_load_from_gconf (panel_widget, position, unique_id);
break;
case APPLET_LOGOUT:
load_logout_applet (panel_widget, position, TRUE);
break;
case APPLET_LOCK:
load_lock_applet (panel_widget, position, TRUE);
break;
case APPLET_STATUS:
break;
case APPLET_RUN:
load_status_applet (panel_widget, position, TRUE);
break;
default:
break;
......@@ -1021,8 +1020,12 @@ panel_applet_save_to_gconf (AppletInfo *applet_info)
applet_info->gconf_key);
break;
case APPLET_DRAWER:
drawer_save_to_gconf ((Drawer *) applet_info->data,
applet_info->gconf_key);
break;
case APPLET_SWALLOW:
/*swallow_save_to_gconf ((Drawer *) applet_info->data,
applet_info->gconf_key);*/
break;
case APPLET_MENU:
menu_save_to_gconf ((Menu *) applet_info->data,
......@@ -1035,8 +1038,6 @@ panel_applet_save_to_gconf (AppletInfo *applet_info)
case APPLET_LOGOUT: /* no object specific stuff to save */
case APPLET_LOCK:
case APPLET_STATUS:
case APPLET_RUN:
break;
default:
break;
}
......
......@@ -15,7 +15,6 @@ G_BEGIN_DECLS
#define LAUNCHER_ID "Launcher"
#define LOCK_ID "Lock"
#define STATUS_ID "Status"
#define RUN_ID "Run"
#define BONOBO_ID "Bonobo"
typedef enum {
......@@ -27,7 +26,6 @@ typedef enum {
APPLET_EMPTY,
APPLET_LOCK,
APPLET_STATUS,
APPLET_RUN,
APPLET_BONOBO
} AppletType;
......
......@@ -24,6 +24,7 @@
#include "button-widget.h"
#include "drawer-widget.h"
#include "panel-config-global.h"
#include "panel-gconf.h"
#include "panel-util.h"
#include "session.h"
#include "xstuff.h"
......@@ -34,6 +35,7 @@ extern gboolean commie_mode;
extern int panels_to_sync;
extern GtkTooltips *panel_tooltips;
extern GSList *panels;
#undef DRAWER_DEBUG
......@@ -424,8 +426,13 @@ button_size_alloc(GtkWidget *widget, GtkAllocation *alloc, Drawer *drawer)
}
Drawer *
load_drawer_applet (gchar *mypanel_id, const char *pixmap, const char *tooltip,
PanelWidget *panel, int pos, gboolean exactpos)
load_drawer_applet (gchar *mypanel_id,
const char *pixmap,
const char *tooltip,
PanelWidget *panel,
int pos,
gboolean exactpos,
const char *gconf_key)
{
Drawer *drawer;
PanelOrient orient = get_applet_orient (panel);
......@@ -473,7 +480,7 @@ load_drawer_applet (gchar *mypanel_id, const char *pixmap, const char *tooltip,
pos,
exactpos,
APPLET_DRAWER,
NULL);
gconf_key);
if (!info) {
gtk_widget_destroy (dw);
......@@ -511,3 +518,86 @@ load_drawer_applet (gchar *mypanel_id, const char *pixmap, const char *tooltip,
return drawer;
}
void
drawer_save_to_gconf (Drawer *drawer,
const char *gconf_key)
{
GConfClient *client;
char *profile;
char *temp_key;
g_return_if_fail (drawer && BASEP_IS_WIDGET (drawer->drawer));
g_return_if_fail (PANEL_IS_WIDGET (BASEP_WIDGET (drawer->drawer)->panel));
client = panel_gconf_get_client ();
profile = session_get_current_profile ();
temp_key = panel_gconf_objects_default_profile_get_full_key (profile, gconf_key, "parameters");
gconf_client_set_int (client, temp_key,
g_slist_index (panels, BASEP_WIDGET (drawer->drawer)->panel),
NULL);
g_free (temp_key);
temp_key = panel_gconf_objects_default_profile_get_full_key (profile, gconf_key, "unique-drawer-panel-id");
gconf_client_set_string (client, temp_key,
PANEL_WIDGET (BASEP_WIDGET (drawer->drawer)->panel)->unique_id,
NULL);
g_free (temp_key);
temp_key = panel_gconf_objects_default_profile_get_full_key (profile, gconf_key, "pixmap");
gconf_client_set_string (client, temp_key, drawer->pixmap, NULL);
g_free (temp_key);
temp_key = panel_gconf_objects_default_profile_get_full_key (profile, gconf_key, "tooltip");
gconf_client_set_string (client, temp_key, drawer->tooltip, NULL);
g_free (temp_key);
}
void
drawer_load_from_gconf (PanelWidget *panel_widget,
gint position,
const char *gconf_key)
{
GConfClient *client;
char *profile;
char *temp_key;
int panel;
char *panel_id;
char *pixmap;
char *tooltip;
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_objects_default_profile_get_full_key (profile, gconf_key, "parameters");
panel = gconf_client_get_int (client, temp_key, NULL);
g_free (temp_key);
temp_key = panel_gconf_objects_default_profile_get_full_key (profile, gconf_key, "unique-drawer-panel-id");
panel_id = gconf_client_get_string (client, temp_key, NULL);
g_free (temp_key);
temp_key = panel_gconf_objects_default_profile_get_full_key (profile, gconf_key, "pixmap");
pixmap = gconf_client_get_string (client, temp_key, NULL);
g_free (temp_key);
temp_key = panel_gconf_objects_default_profile_get_full_key (profile, gconf_key, "tooltip");
tooltip = gconf_client_get_string (client, temp_key, NULL);
g_free (temp_key);
if (!panel_id < 0 && panel >= 0) {
PanelWidget *pw = g_slist_nth_data (panels, panel);
if (pw)
panel_id = g_strdup (pw->unique_id);
}
load_drawer_applet (panel_id, pixmap, tooltip, panel_widget, position, TRUE, gconf_key);
g_free (panel_id);
g_free (pixmap);
g_free (tooltip);
}
......@@ -21,7 +21,15 @@ Drawer *load_drawer_applet (gchar *mypanel,
const char *tooltip,
PanelWidget *panel,
int pos,
gboolean exactpos);
gboolean exactpos,
const char *gconf_key);
void drawer_save_to_gconf (Drawer *drawer,
const char *gconf_key);
void drawer_load_from_gconf (PanelWidget *panel_widget,
gint position,
const char *gconf_key);
void set_drawer_applet_orient(Drawer *drawer, PanelOrient orient);
......
......@@ -1014,7 +1014,7 @@ add_drawers_from_dir (const char *dirname, const char *name,
subdir_name = name;
pixmap_name = item_info != NULL ? item_info->icon : NULL;
drawer = load_drawer_applet (NULL, pixmap_name, subdir_name, panel, pos, FALSE);
drawer = load_drawer_applet (NULL, pixmap_name, subdir_name, panel, pos, FALSE, NULL);
if (!drawer) {
g_warning("Can't load a drawer");
return;
......@@ -1896,7 +1896,7 @@ static void
add_drawer_to_panel (GtkWidget *widget, gpointer data)
{
load_drawer_applet (NULL, NULL, NULL,
get_panel_from_menu_data(widget, TRUE), 0, FALSE);
get_panel_from_menu_data(widget, TRUE), 0, FALSE, NULL);
}
static void
......
......@@ -116,7 +116,7 @@ GtkWidget * create_root_menu (GtkWidget *root_menu,
/* some gtk code cut-n-paste action */
void our_gtk_menu_position (GtkMenu *menu);
void menu_save_to_gconf (Menu *launcher,
void menu_save_to_gconf (Menu *menu,
const char *gconf_key);
void menu_load_from_gconf (PanelWidget *panel_widget,
......
#ifndef __PANEL_MAIN_H__
#define __PANEL_MAIN_H__
gchar *panel_main_get_current_profile (void);
#endif /* __PANEL_MAIN_H__ */
......@@ -1177,7 +1177,7 @@ drop_internal_applet (PanelWidget *panel, int pos, const char *applet_type,
drop_menu (panel, pos, menu);
} else if (strcmp(applet_type,"DRAWER:NEW")==0) {
load_drawer_applet(NULL, NULL, NULL, panel, pos, TRUE);
load_drawer_applet(NULL, NULL, NULL, panel, pos, TRUE, NULL);
} else if (strcmp (applet_type, "LOGOUT:NEW") == 0) {
load_logout_applet (panel, pos, TRUE);
......
......@@ -194,91 +194,6 @@ panel_session_save_applets (GSList *applets_list)
g_return_if_fail (info && info->widget);
panel_applet_save_position (info, info->gconf_key);
switch (info->type) {
#ifdef FIXME
case APPLET_EMPTY:
/*
* just save id
*/
break;
case APPLET_DRAWER: {
int i;
Drawer *drawer = info->data;
gnome_config_set_string("id", DRAWER_ID);
i = g_slist_index(panels,
BASEP_WIDGET(drawer->drawer)->panel);
if(i>=0)
gnome_config_set_int("parameters",i);
gnome_config_set_string ("unique_drawer_panel_id",
PANEL_WIDGET (BASEP_WIDGET(drawer->drawer)->panel)->unique_id);
gnome_config_set_string("pixmap",
drawer->pixmap);
gnome_config_set_string("tooltip",
drawer->tooltip);
}
break;
case APPLET_SWALLOW: {
Swallow *swallow = info->data;
gnome_config_set_string("id", SWALLOW_ID);
gnome_config_set_string("parameters",
swallow->title);
gnome_config_set_string("execpath",
swallow->path);
gnome_config_set_int("width",swallow->width);
gnome_config_set_int("height",swallow->height);
}
break;
case APPLET_MENU: {
Menu *menu = info->data;
gnome_config_set_string("id", MENU_ID);
gnome_config_set_string("parameters",
menu->path);
gnome_config_set_int("main_menu_flags",
menu->main_menu_flags);
gnome_config_set_bool("global_main",
menu->global_main);
gnome_config_set_bool("custom_icon",
menu->custom_icon);
gnome_config_set_string("custom_icon_file",
menu->custom_icon_file);
}
break;
case APPLET_LAUNCHER: {
Launcher *launcher = info->data;
const char *location;
gnome_config_set_string ("id", LAUNCHER_ID);
/* clean old launcher info */
gnome_config_clean_key ("parameters");
launcher_save (launcher);
location = gnome_desktop_item_get_location (launcher->ditem);
gnome_config_set_string ("base_location", location);
}
break;
case APPLET_LOGOUT:
gnome_config_set_string("id", LOGOUT_ID);
break;
case APPLET_LOCK:
gnome_config_set_string("id", LOCK_ID);
break;
case APPLET_STATUS:
gnome_config_set_string("id", STATUS_ID);
break;
case APPLET_RUN:
gnome_config_set_string("id", RUN_ID);
break;
default:
g_warning ("Unknown applet type encountered: %d; ignoring.",
info->type);
#endif /* FIXME */
default:
break;
}
}
}
......@@ -652,188 +567,6 @@ panel_quit (void)
GNOME_INTERACT_ANY, 0, 1);
}
#ifdef FIXME /* replaced by panel_applet_frame_load_applets - keeping old code temporarily for reference */
static void
session_init_applets (void)
{
GString *buf;
int count, num;
char *prefix;
const char *sep;
buf = g_string_new (NULL);
g_string_sprintf (buf, "%spanel%s/Config/applet_count",
prefix, sep);
count = conditional_get_int (buf->str, 0, NULL);
for (num = 1; num <= count; num++) {
char *applet_name;
int pos = 0, panel_num, panel_id;
PanelWidget *panel;
g_string_sprintf (buf, "%sApplet_Config%s/Applet_%d/",
prefix, sep, num);
gnome_config_push_prefix (buf->str);
if ( ! conditional_true ("Conditional")) {
gnome_config_pop_prefix ();
continue;
}
applet_name = conditional_get_string ("id", "Unknown", NULL);
if (strcmp (applet_name, EMPTY_ID) == 0) {
g_free (applet_name);
gnome_config_pop_prefix ();
continue;
} else if (strcmp (applet_name, "Unknown") == 0) {
g_warning ("Unknown applet type!");
g_free (applet_name);
gnome_config_pop_prefix ();
continue;
}
pos = conditional_get_int ("position", 0, NULL);
panel_id = conditional_get_int ("unique_panel_id", -1, NULL);
if (panel_id < 0) {
GSList *list;
panel_num = conditional_get_int ("panel", 0, NULL);
list = g_slist_nth (panels, panel_num);
if (list == NULL) {
g_warning ("Can't find panel, "
"putting applet on the first one");
panel = panels->data;
} else
panel = list->data;
} else {
panel = panel_widget_get_by_id (panel_id);
if (panel == NULL) {
g_warning ("Can't find panel, "
"putting applet on the first one");
panel = panels->data;
}
}
/* if this isn't true, then we are smoking some serious crack */
g_assert (panel != NULL);
/*if we are to right stick this, make the number large,
G_MAXINT/2 should allways be large enough */
pos += (conditional_get_bool ("right_stick", FALSE, NULL)
? G_MAXINT/2 : 0);
if (!strcmp (applet_name, BONOBO_ID)) {
char *iid;
iid = conditional_get_string ("iid", NULL, NULL);
if (iid && iid [0] )
panel_applet_frame_load (iid, panel, pos);
g_free (iid);
} else if (!strcmp (applet_name, LAUNCHER_ID)) {
gboolean hoard = FALSE;
Launcher *launcher;
char *file;
file = conditional_get_string ("base_location", NULL,
NULL);
if (string_empty (file)) {
g_free (file);
file = conditional_get_string ("parameters",
NULL, NULL);
hoard = TRUE;
}
launcher = load_launcher_applet(file, panel, pos, TRUE);
g_free(file);
/* If this was an old style launcher, hoard it now */
if (hoard && launcher != NULL)
launcher_hoard (launcher);
} else if (strcmp (applet_name, LOGOUT_ID) == 0) {
load_logout_applet (panel, pos, TRUE);
} else if (strcmp (applet_name, LOCK_ID) == 0) {
load_lock_applet (panel, pos, TRUE);
} else if (strcmp (applet_name, STATUS_ID) == 0) {
load_status_applet (panel, pos, TRUE);
} else if (strcmp (applet_name, SWALLOW_ID) == 0) {
char *path = conditional_get_string ("execpath",
NULL, NULL);
char *params = conditional_get_string ("parameters",
NULL, NULL);
int width = conditional_get_int ("width", 0, NULL);
int height = conditional_get_int ("height", 0, NULL);
load_swallow_applet (path, params, width, height,
panel, pos, TRUE);
g_free (path);
g_free (params);
} else if (strcmp (applet_name, MENU_ID) == 0) {
char *path = conditional_get_string ("path",
"applications:/", NULL);
gboolean main_menu =
conditional_get_bool ("main_menu", TRUE, NULL);
gboolean global_main =
conditional_get_bool ("global_main", TRUE, NULL);
gboolean custom_icon =
conditional_get_bool ("custom_icon", FALSE,
NULL);
char *custom_icon_file =
conditional_get_string ("custom_icon_file",
NULL, NULL);
int flags = conditional_get_int ("main_menu_flags",
get_default_menu_flags (),
NULL);
if (flags < 0)
flags = get_default_menu_flags ();
load_menu_applet (path, main_menu,
flags, global_main,
custom_icon, custom_icon_file,
panel, pos, TRUE);
g_free (custom_icon_file);
g_free (path);
} else if (strcmp (applet_name, DRAWER_ID) == 0) {
int mypanel = conditional_get_int ("parameters", -1,
NULL);
int mypanel_id = conditional_get_int
("unique_drawer_panel_id", -1, NULL);
char *pixmap = conditional_get_string ("pixmap",
NULL, NULL);
char *tooltip = conditional_get_string ("tooltip",
NULL, NULL);
if (mypanel_id < 0 && mypanel >= 0) {
PanelWidget *pw = g_slist_nth_data (panels, mypanel);
if (pw != NULL)
mypanel_id = pw->unique_id;
}
/* FIXME - temporarily to get the id stuff right
load_drawer_applet (mypanel_id, pixmap, tooltip,
panel, pos, TRUE);
*/
g_free (pixmap);
g_free (tooltip);
} else {
g_warning ("Unknown applet type!");
}
gnome_config_pop_prefix ();
g_free (applet_name);
}
g_string_free (buf, TRUE);
g_free (prefix);
}
#endif /* FIXME */
static void
session_init_panels(void)
{
......
......@@ -27,6 +27,8 @@
#include "panel.h"
#include "panel-util.h"
#include "panel-widget.h"
#include "panel-gconf.h"
#include "session.h"
#include "xstuff.h"
/* from gtkhandlebox.c */
......@@ -221,7 +223,7 @@ really_add_swallow (GtkWidget *d, int response, gpointer data)
GTK_SPIN_BUTTON(width_s)),
gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(height_s)),
panel, pos, exactpos);
panel, pos, exactpos, NULL);
gtk_widget_destroy(d);
}
......@@ -423,8 +425,14 @@ set_swallow_applet_orient(Swallow *swallow, SwallowOrient orient)
}
void
load_swallow_applet (const char *path, const char *params, int width, int height,
PanelWidget *panel, int pos, gboolean exactpos)
load_swallow_applet (const char *path,
const char *params,
int width,
int height,
PanelWidget *panel,
int pos,
gboolean exactpos,
const char *gconf_key)
{
Swallow *swallow;
AppletInfo *info;
......@@ -437,7 +445,7 @@ load_swallow_applet (const char *path, const char *params, int width, int height
info = panel_applet_register (swallow->ebox, ref_swallow (swallow),
(GDestroyNotify) unref_swallow,
panel, pos, exactpos, APPLET_SWALLOW,
NULL);
gconf_key);
if (!info)
return;
......@@ -447,3 +455,74 @@ load_swallow_applet (const char *path, const char *params, int width, int height
swallow_launch (swallow);
}
void
swallow_save_to_gconf (Swallow *swallow,
const char *gconf_key)
{
GConfClient *client;
char *profile;
char *temp_key;
g_return_if_fail (swallow);
client = panel_gconf_get_client ();
profile = session_get_current_profile ();
temp_key = panel_gconf_objects_default_profile_get_full_key (profile, gconf_key, "exec-path");
gconf_client_set_string (client, temp_key, swallow->path, NULL);
g_free (temp_key);
temp_key = panel_gconf_objects_default_profile_get_full_key (profile, gconf_key, "parameters");
gconf_client_set_string (client, temp_key, swallow->title, NULL);
g_free (temp_key);
temp_key = panel_gconf_objects_default_profile_get_full_key (profile, gconf_key, "width");
gconf_client_set_int (client, temp_key, swallow->width, NULL);
g_free (temp_key);
temp_key = panel_gconf_objects_default_profile_get_full_key (profile, gconf_key, "height");
gconf_client_set_int (client, temp_key, swallow->height, NULL);
g_free (temp_key);
}
void
swallow_load_from_gconf (PanelWidget *panel_widget,
gint position,
const char *gconf_key)
{
GConfClient *client;
char *profile;
char *temp_key;
char *path;
char *params;
int width;
int height;
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_objects_default_profile_get_full_key (profile, gconf_key, "exec-path");
path = gconf_client_get_string (client, temp_key, NULL);
g_free (temp_key);
temp_key = panel_gconf_objects_default_profile_get_full_key (profile, gconf_key, "parameters");
params = gconf_client_get_string (client, temp_key, NULL);
g_free (temp_key);
temp_key = panel_gconf_objects_default_profile_get_full_key (profile, gconf_key, "width");
width = gconf_client_get_int (client, temp_key, NULL);
g_free (temp_key);
temp_key = panel_gconf_objects_default_profile_get_full_key (profile, gconf_key, "height");
height = gconf_client_get_int (client, temp_key, NULL);
g_free (temp_key);
load_swallow_applet (path, params, width, height, panel_widget, position, TRUE, gconf_key);
g_free (path);
g_free (params);
}
......@@ -25,8 +25,22 @@ typedef struct {
gboolean clean_remove;
} Swallow;
void load_swallow_applet(const char *path, const char *params, int width, int height,
PanelWidget *panela, int pos, gboolean exactpos);
void load_swallow_applet (const char *path,
const char *params,
int width,
int height,
PanelWidget *panela,
int pos,
gboolean exactpos,
const char *gconf_key);
void swallow_save_to_gconf (Swallow *swallow,
const char *gconf_key);
void swallow_load_from_gconf (PanelWidget *panel_widget,
gint position,
const char *gconf_key);
void set_swallow_applet_orient(Swallow *swallow, SwallowOrient orient);
/*I couldn't resist the naming of this function*/
......