Commit 0152281c authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

external applets now get restarted nicely. teh session saving stuff

Wed Mar 11 00:00:49 1998  George Lebl  <jirka@5z.com>

        * gnome-panel.idl, and just about every file: external applets
          now get restarted nicely. teh session saving stuff slightly
          revamped ... just as the starting stuff ... makes more sense
          now. it still segfaults but oh well ...

        * clock.c: ported it to the new gnome-panel.idl interface
parent 02a143af
Wed Mar 11 00:00:49 1998 George Lebl <jirka@5z.com>
* gnome-panel.idl, and just about every file: external applets
now get restarted nicely. teh session saving stuff slightly
revamped ... just as the starting stuff ... makes more sense
now. it still segfaults but oh well ...
* clock.c: ported it to the new gnome-panel.idl interface
Tue Mar 10 01:31:25 1998 Tom Tromey <tromey@cygnus.com>
* Makefile.am (CXX): Define.
......
Wed Mar 11 00:00:49 1998 George Lebl <jirka@5z.com>
* gnome-panel.idl, and just about every file: external applets
now get restarted nicely. teh session saving stuff slightly
revamped ... just as the starting stuff ... makes more sense
now. it still segfaults but oh well ...
* clock.c: ported it to the new gnome-panel.idl interface
Tue Mar 10 01:31:25 1998 Tom Tromey <tromey@cygnus.com>
* Makefile.am (CXX): Define.
......
......@@ -288,11 +288,14 @@ bind_top_applet_events(GtkWidget *widget, int id)
/*id will return a unique id for this applet for the applet to identify
itself as*/
char *
gnome_panel_prepare_and_transfer (GtkWidget *widget, char *path, int *id,
int panel, int pos)
gnome_panel_applet_request_id (GtkWidget *widget,
char *path,
int *id,
char **cfgpath)
{
char *result;
char *ior;
char *cfgpathback = NULL;
/* Create an applet object, I do pass the widget parameter to the
* constructor object to have a way of sort out to which object
......@@ -307,24 +310,44 @@ gnome_panel_prepare_and_transfer (GtkWidget *widget, char *path, int *id,
ior = orb_ptr->object_to_string (applet);
/*reserve a spot and get an id for this applet*/
*id = panel_client->applet_request_id(ior,path,cfgpathback);
if(cfgpath==NULL) {
CORBA::string_free(cfgpathback);
} else if(cfgpathback != NULL) {
*cfgpath = g_strdup(cfgpathback);
CORBA::string_free(cfgpathback);
} else {
*cfgpath = NULL;
}
return 0;
}
/*id will return a unique id for this applet for the applet to identify
itself as*/
char *
gnome_panel_prepare_and_transfer (GtkWidget *widget, int id)
{
char *result;
gtk_widget_realize(widget);
gtk_widget_show(widget);
printf ("Transfiriendo: %d\n", GDK_WINDOW_XWINDOW (widget->window));
/*reserve a spot and get an id for this applet*/
*id = panel_client->reserve_applet_spot(ior,path,panel,pos);
/*reparent the window*/
panel_client->reparent_window_id (GDK_WINDOW_XWINDOW (widget->window),
*id);
bind_top_applet_events(widget,*id);
id);
bind_top_applet_events(widget,id);
printf ("Transferido\n");
return 0;
}
void
applet_corba_gtk_main (char *str)
{
......
......@@ -3,8 +3,9 @@
BEGIN_GNOME_DECLS
char *gnome_panel_prepare_and_transfer (GtkWidget *widget, char *path, int *id,
int panel, int pos);
char *gnome_panel_applet_request_id (GtkWidget *widget, char *path, int *id,
char **cfgpath);
char *gnome_panel_prepare_and_transfer (GtkWidget *widget, int id);
int gnome_panel_applet_init_corba (void);
void applet_corba_gtk_main (char *str);
......
......@@ -212,6 +212,10 @@ main(int argc, char **argv)
{
GtkWidget *clock;
char *result;
char *cfgpath;
char *mypath;
char *myinvoc;
panel_corba_register_arguments ();
gnome_init("clock_applet", NULL, argc, argv, 0, NULL);
......@@ -223,6 +227,20 @@ main(int argc, char **argv)
aw = applet_widget_new ();
mypath = getcwd(NULL,0);
myinvoc = g_copy_strings(mypath,"/",argv[0],NULL);
free(mypath);
result = gnome_panel_applet_request_id(aw,myinvoc,&applet_id,&cfgpath);
g_free(myinvoc);
if (result){
printf ("Could not talk to the Panel: %s\n", result);
exit (1);
}
/*use cfg path for loading up data!*/
g_free(cfgpath);
clock = create_clock_widget (GTK_WIDGET(aw));
gtk_widget_show(clock);
applet_widget_add (APPLET_WIDGET (aw), clock);
......@@ -230,7 +248,7 @@ main(int argc, char **argv)
/*FIXME: do session saving, find out panel and pos from the panel
so we can restore them on the next startup*/
result = gnome_panel_prepare_and_transfer(aw,argv[0],&applet_id,0,0);
result = gnome_panel_prepare_and_transfer(aw,applet_id);
printf ("Done\n");
if (result){
printf ("Could not talk to the Panel: %s\n", result);
......
module GNOME {
interface Panel {
/* Sends the object identifier for the Applet server that contacts the Panel */
/* Sends the object identifier for the Applet server that
contacts the Panel */
void reparent_window_id (in unsigned long wid, in short id);
short reserve_applet_spot (in string ior, in string path, in short panel,in short pos);
short applet_request_id(in string ior,
in string path,
out string cfgpath);
void applet_remove_from_panel (in short id);
short applet_get_panel (in short id);
short applet_get_pos (in short id);
......
......@@ -36,7 +36,7 @@ GlobalConfig global_config = {
void
load_applet(char *id, char *params, int pos, int panel)
load_applet(char *id, char *params, int pos, int panel, char *cfgpath)
{
/*FIXME: somehow load the applet and call register_toy ... this
thing has to exec the applet or if it is a local applet then it
......@@ -44,13 +44,17 @@ load_applet(char *id, char *params, int pos, int panel)
register_toy*/
if(strcmp(id,EXTERN_ID) == 0) {
gchar *command;
AppletInfo * info;
g_return_if_fail (params != NULL);
reserve_applet_spot (cfgpath, params, panel, pos);
command = g_copy_strings ("(true;", params, ") &", NULL);
system (command);
g_free (command);
} else if(strcmp(id,MENU_ID) == 0) {
Menu *menu;
......@@ -114,7 +118,7 @@ load_default_applets(void)
{
/* XXX: the IDs for these applets are hardcoded here. */
load_applet("Menu", ".", PANEL_UNKNOWN_APPLET_POSITION,0);
load_applet("Menu", ".", PANEL_UNKNOWN_APPLET_POSITION,0,NULL);
/*
load_applet("Clock", NULL, PANEL_UNKNOWN_APPLET_POSITION,0);
load_applet("Mail check", NULL, PANEL_UNKNOWN_APPLET_POSITION,0);
......@@ -145,7 +149,11 @@ init_user_applets(void)
pos = gnome_config_get_int(buf);
sprintf(buf,"/panel/Applet_%d/panel=0",num);
panel = gnome_config_get_int(buf);
load_applet(applet_name, applet_params, pos, panel);
/*this is the config path to be passed to the applet when it
loads*/
sprintf(buf,"/panel/Applet_%d/",num);
load_applet(applet_name, applet_params, pos, panel, buf);
g_free(applet_name);
g_free(applet_params);
}
......
......@@ -94,7 +94,8 @@ free_app_def (GtkWidget *widget, void *data)
{
GnomeDesktopEntry *item = data;
gnome_desktop_entry_free (item);
if(item)
gnome_desktop_entry_free (item);
}
void
......@@ -116,7 +117,7 @@ free_string (GtkWidget *widget, void *data)
void
add_to_panel (char *applet, char *arg)
{
load_applet(applet,arg,PANEL_UNKNOWN_APPLET_POSITION,0);
load_applet(applet,arg,PANEL_UNKNOWN_APPLET_POSITION,0,NULL);
}
void
......
......@@ -21,14 +21,21 @@ public:
::reparent_window_id (wid,id);
}
CORBA::Short reserve_applet_spot (const char *ior,
const char *path,
CORBA::Short panel,
CORBA::Short pos) {
printf ("RESERVE_APPLET_SPOT!\n");
CORBA::Short applet_request_id (const char *ior,
const char *path,
char *&cfgpath) {
char *s=NULL;
int id;
printf ("REQUEST_ID!\n");
printf ("applet registered with IOR: %s\n", ior);
return ::reserve_applet_spot (ior,path,panel,pos);
id = ::applet_request_id (ior,path,&s);
if(s) {
cfgpath = CORBA::string_dup(s);
g_free(s);
}
return id;
}
CORBA::Short applet_get_panel (CORBA::Short id) {
printf ("APPLET_GET_PANEL!\n");
......
......@@ -128,6 +128,14 @@ save_applet_configuration(gpointer data, gpointer user_data)
gnome_config_set_string(fullpath, EXTERN_ID);
g_free(fullpath);
fullpath = g_copy_strings(path,"position",NULL);
gnome_config_set_int(fullpath, pos);
g_free(fullpath);
fullpath = g_copy_strings(path,"panel",NULL);
gnome_config_set_int(fullpath, panel);
g_free(fullpath);
/*have the applet do it's own session saving*/
send_applet_session_save(info->id,(*num)-2,panel,pos);
fullpath = g_copy_strings(path,"parameters",NULL);
......@@ -553,16 +561,56 @@ applet_add_callback(short id, char *callback_name, char *menuitem_text)
g_warning("Unimplemented\n");
}
int
applet_request_id (const char * ior, const char *path, char **cfgpath)
{
GtkWidget *eb;
GdkWindow *win;
GList *list;
AppletInfo *info;
int i;
for(i=0,list=applets;list!=NULL;list=g_list_next(list),i++) {
info = list->data;
if(info && info->type == APPLET_EXTERN_PENDING &&
strcmp(info->params,path)==0) {
*cfgpath = info->id;
info->id = g_strdup(ior);
return i;
}
}
reserve_applet_spot (ior, path, 0, 0);
info = g_new(AppletInfo,1);
info->type = APPLET_EXTERN_PENDING;
info->widget = NULL;
info->assoc = NULL;
info->data = NULL;
info->id = g_strdup(ior);
info->params = g_strdup(path);
info->flags = 0;
*cfgpath = g_strdup("");
applets = g_list_append(applets,info);
return i;
}
void
reparent_window_id (unsigned long winid, int id)
{
GtkWidget *eb;
GdkWindow *win;
int w,h;
AppletInfo *info;
printf ("I got this window ID to reparent: %d\n", winid);
/*FIXME: check for NULLS!*/
eb = ((AppletInfo *)(g_list_nth(applets,id)->data))->widget;
info = (AppletInfo *)(g_list_nth(applets,id)->data);
/*no longer pending*/
info->type = APPLET_EXTERN;
eb = info->widget;
win = gdk_window_foreign_new(winid);
gdk_window_get_size(win,&w,&h);
......@@ -574,13 +622,12 @@ reparent_window_id (unsigned long winid, int id)
printf ("leaving reparent\n");
}
int
reserve_applet_spot (const char * ior, const char *path, int panel, int pos)
void
reserve_applet_spot (const char *id, const char *path, int panel, int pos)
{
GtkWidget *eb;
GdkWindow *win;
GList *list;
int i;
printf ("entering reserve spot\n");
......@@ -589,18 +636,14 @@ reserve_applet_spot (const char * ior, const char *path, int panel, int pos)
/*we save the ior in the id field of the appletinfo and the
path in the params field*/
register_toy(eb,NULL,NULL,g_strdup(ior),g_strdup(path),pos,panel,0,APPLET_EXTERN);
for(i=0,list=applets;list!=NULL;list=g_list_next(list))
i++;
register_toy(eb,NULL,NULL,g_strdup(id),g_strdup(path),
pos,panel,0,APPLET_EXTERN_PENDING);
printf ("leaving reserve spot\n");
return i-1;
}
/*FIXME: add a function that does this, so generalize register_toy for this*/
static void
/*static void
add_reparent(GtkWidget *widget, gpointer data)
{
int id;
......@@ -613,7 +656,7 @@ add_reparent(GtkWidget *widget, gpointer data)
appletid = reserve_applet_spot("???","echo",0,0);
reparent_window_id (id,appletid);
}
}*/
GtkWidget *
create_panel_root_menu(PanelWidget *panel)
......@@ -637,12 +680,12 @@ create_panel_root_menu(PanelWidget *panel)
gtk_menu_append(GTK_MENU(panel_menu), menuitem);
gtk_widget_show(menuitem);
menuitem = gtk_menu_item_new_with_label(_("Add reparent (testing)"));
/*menuitem = gtk_menu_item_new_with_label(_("Add reparent (testing)"));
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
(GtkSignalFunc) add_reparent,
panel);
gtk_menu_append(GTK_MENU(panel_menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_show(menuitem);*/
menuitem = gtk_menu_item_new_with_label(_("Main menu"));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), root_menu);
......
......@@ -41,8 +41,10 @@ typedef enum {
typedef enum {
APPLET_EXTERN,
APPLET_EXTERN_PENDING,
APPLET_DRAWER,
APPLET_MENU
APPLET_MENU,
APPLET_LOGOUT
} AppletType;
typedef enum {
......@@ -91,7 +93,8 @@ void panel_quit(void);
void apply_global_config(void);
void reparent_window_id (unsigned long winid, int id);
int reserve_applet_spot (const char * ior, const char * path, int panel, int pos);
int applet_request_id (const char * ior, const char *path, char **cfgpath);
void reserve_applet_spot (const char *id, const char *path, int panel, int pos);
/*stuff for corba*/
int applet_get_panel(int id);
......@@ -101,7 +104,7 @@ void applet_drag_stop(int id);
void applet_add_callback(short id, char *callback_name, char *menuitem_text);
/*this is in main.c*/
void load_applet(char *id, char *params, int pos, int panel);
void load_applet(char *id, char *params, int pos, int panel, char *cfgpath);
void orientation_change(AppletInfo *info, PanelWidget *panel);
END_GNOME_DECLS
......
module GNOME {
interface Panel {
/* Sends the object identifier for the Applet server that contacts the Panel */
/* Sends the object identifier for the Applet server that
contacts the Panel */
void reparent_window_id (in unsigned long wid, in short id);
short reserve_applet_spot (in string ior, in string path, in short panel,in short pos);
short applet_request_id(in string ior,
in string path,
out string cfgpath);
void applet_remove_from_panel (in short id);
short applet_get_panel (in short id);
short applet_get_pos (in short id);
......
module GNOME {
interface Panel {
/* Sends the object identifier for the Applet server that contacts the Panel */
/* Sends the object identifier for the Applet server that
contacts the Panel */
void reparent_window_id (in unsigned long wid, in short id);
short reserve_applet_spot (in string ior, in string path, in short panel,in short pos);
short applet_request_id(in string ior,
in string path,
out string cfgpath);
void applet_remove_from_panel (in short id);
short applet_get_panel (in short id);
short applet_get_pos (in short id);
......
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