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

fixed a race when starting applets, by having two states for applets

Fri Mar 13 02:42:56 1998  George Lebl  <jirka@5z.com>

        * panel.[ch]: fixed a race when starting applets, by
          having two states for applets (PENDING and RESERVED),
          this fixes the panel "loosing" applets in invocation

        * all files: commented out most debugging output, since it
          was getting difficult to use puts/printf since the new
          debugging was lost in the old etc ...

        * clock.c: once again I use an idle handler for killing
          myself. this solves the mico exception which wasn't
          all that nice really.
parent 54cb9c34
Fri Mar 13 02:42:56 1998 George Lebl <jirka@5z.com>
* panel.[ch]: fixed a race when starting applets, by
having two states for applets (PENDING and RESERVED),
this fixes the panel "loosing" applets in invocation
* all files: commented out most debugging output, since it
was getting difficult to use puts/printf since the new
debugging was lost in the old etc ...
* clock.c: once again I use an idle handler for killing
myself. this solves the mico exception which wasn't
all that nice really.
1998-03-13 Raja R Harinath <harinath@cs.umn.edu>
* Makefile.am (INCLUDES): Include $(srcdir) too.
......
Fri Mar 13 02:42:56 1998 George Lebl <jirka@5z.com>
* panel.[ch]: fixed a race when starting applets, by
having two states for applets (PENDING and RESERVED),
this fixes the panel "loosing" applets in invocation
* all files: commented out most debugging output, since it
was getting difficult to use puts/printf since the new
debugging was lost in the old etc ...
* clock.c: once again I use an idle handler for killing
myself. this solves the mico exception which wasn't
all that nice really.
1998-03-13 Raja R Harinath <harinath@cs.umn.edu>
* Makefile.am (INCLUDES): Include $(srcdir) too.
......
......@@ -285,14 +285,14 @@ gnome_panel_prepare_and_transfer (GtkWidget *widget, int id)
gtk_widget_realize(widget);
gtk_widget_show(widget);
printf ("Transfiriendo: %d\n", GDK_WINDOW_XWINDOW (widget->window));
/*printf ("Transfiriendo: %d\n", GDK_WINDOW_XWINDOW (widget->window));*/
/*reparent the window*/
panel_client->reparent_window_id (GDK_WINDOW_XWINDOW (widget->window),
id);
bind_top_applet_events(widget,id);
printf ("Transferido\n");
/*printf ("Transferido\n");*/
return 0;
}
......
......@@ -174,18 +174,16 @@ void
change_orient(int id, int orient)
{
PanelOrientType o = (PanelOrientType)orient;
puts("CHANGE_ORIENT");
}
void
session_save(int id, const char *cfgpath)
{
/*FIXME: save the position*/
puts("SESSION_SAVE");
/*save the session here*/
}
static gint
applet_die(gpointer data)
quit_clock(gpointer data)
{
exit(0);
}
......@@ -193,11 +191,10 @@ applet_die(gpointer data)
void
shutdown_applet(int id)
{
puts("SHUTDOWN_APPLET");
/*kill our window*/
gtk_widget_unref(aw);
exit(0);
//gtk_timeout_add(100,applet_die,NULL);
/*kill our window using destroy to avoid warnings we need to
kill the aw but we also need to return from this call*/
gtk_widget_destroy(aw);
gtk_idle_add(quit_clock,NULL);
}
void
......@@ -221,8 +218,9 @@ main(int argc, char **argv)
gnome_init("clock_applet", NULL, argc, argv, 0, NULL);
if (!gnome_panel_applet_init_corba ()){
fprintf (stderr, "Could not comunicate with the panel\n");
exit (1);
g_error ("Could not comunicate with the panel\n");
/*fprintf (stderr, "Could not comunicate with the panel\n");*/
/*exit (1);*/
}
aw = applet_widget_new ();
......@@ -241,7 +239,7 @@ main(int argc, char **argv)
g_free(cfgpath);
gnome_panel_applet_register_callback (aw,
gnome_panel_applet_register_callback (APPLET_WIDGET(aw),
applet_id,
"test",
"TEST CALLBACK",
......@@ -256,10 +254,10 @@ 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,applet_id);
printf ("Done\n");
/*printf ("Done\n");*/
if (result){
printf ("Could not talk to the Panel: %s\n", result);
exit (1);
g_error ("Could not talk to the Panel: %s\n", result);
/*exit (1);*/
}
applet_corba_gtk_main ("IDL:GNOME/Applet:1.0");
......
......@@ -48,11 +48,9 @@ load_applet(char *id, char *params, int pos, int panel, char *cfgpath)
g_return_if_fail (params != NULL);
reserve_applet_spot (cfgpath, params, panel, pos);
reserve_applet_spot (cfgpath, params, panel, pos,
APPLET_EXTERN_PENDING);
puts("-------------------------------------------");
puts(" LOADING EXTERN APPLET");
puts("-------------------------------------------");
command = g_copy_strings ("(true;", params, ") &", NULL);
system (command);
......
......@@ -17,8 +17,6 @@ class Panel_impl : virtual public GNOME::Panel_skel {
public:
void reparent_window_id (CORBA::ULong wid,
CORBA::Short id) {
printf ("REPARENT!\n");
::reparent_window_id (wid,id);
}
CORBA::Short applet_request_id (const char *ior,
......@@ -27,9 +25,6 @@ public:
char *s=NULL;
int id;
printf ("REQUEST_ID!\n");
printf ("applet registered with IOR: %s\n", ior);
id = ::applet_request_id (ior,path,&s);
if(s) {
cfgpath = CORBA::string_dup(s);
......@@ -38,32 +33,22 @@ public:
return id;
}
CORBA::Short applet_get_panel (CORBA::Short id) {
printf ("APPLET_GET_PANEL!\n");
return ::applet_get_panel (id);
}
CORBA::Short applet_get_pos (CORBA::Short id) {
printf ("APPLET_GET_POS!\n");
return ::applet_get_pos (id);
}
void applet_show_menu (CORBA::Short id) {
printf ("APPLET_SHOW_MENU!\n");
::applet_show_menu (id);
}
void applet_drag_start (CORBA::Short id) {
printf ("APPLET_DRAG_START!\n");
::applet_drag_start (id);
}
void applet_drag_stop (CORBA::Short id) {
printf ("APPLET_DRAG_STOP!\n");
::applet_drag_stop (id);
}
void applet_remove_from_panel (CORBA::Short id) {
printf ("APPLET_REMOVE_FROM_PANEL!\n");
printf ("APPLET_REMOVE_FROM_PANEL not implemented!\n");
/*FIXME: */
}
void applet_add_callback (CORBA::Short id,
......@@ -124,12 +109,7 @@ send_applet_shutdown_applet (const char *ior, int id)
GNOME::Applet_var applet = GNOME::Applet::_narrow (obj);
/* Now, use corba to invoke the routine in the panel */
try {
applet->shutdown_applet(id);
} catch ( ... ) {
/*FIXME: only incomplete exception handeled here*/
puts("EXCEPTION");
}
applet->shutdown_applet(id);
}
void
......
......@@ -102,7 +102,9 @@ save_applet_configuration(gpointer data, gpointer user_data)
GList *list;
/*obviously no need for saving*/
if(info->type==APPLET_EXTERN_PENDING && info->type==APPLET_EMPTY)
if(info->type==APPLET_EXTERN_PENDING ||
info->type==APPLET_EXTERN_RESERVED ||
info->type==APPLET_EMPTY)
return;
pos = -1;
......@@ -294,9 +296,9 @@ panel_session_save (GnomeClient *client,
for(i=0,list=applets;list!=NULL;list = g_list_next(list),i++) {
info = list->data;
if(info->type == APPLET_EXTERN) {
printf("SHUTTING DOWN EXTERN (%d)\n",i);
/*printf("SHUTTING DOWN EXTERN (%d)\n",i);*/
send_applet_shutdown_applet(info->id,i);
puts("DONE");
/*puts("DONE");*/
}
if(info->menu)
gtk_widget_unref(info->menu);
......@@ -310,14 +312,14 @@ panel_session_save (GnomeClient *client,
/*prevent searches through the g_list to speed
up this thing*/
puts("unreffing root menu");
/*puts("unreffing root menu");*/
gtk_widget_unref(root_menu);
puts("done");
/*puts("done");*/
/*FIXME: unref all menus here */
}
puts("AFTER_SESSION_SAVE");
/*puts("AFTER_SESSION_SAVE");*/
/* Always successful. */
......@@ -330,9 +332,9 @@ panel_quit(void)
if (! GNOME_CLIENT_CONNECTED (client)) {
panel_session_save (client, 1, GNOME_SAVE_BOTH, 1,
GNOME_INTERACT_NONE, 0, NULL);
puts("BEFORE_GTK_MAIN_QUIT");
/*puts("BEFORE_GTK_MAIN_QUIT");*/
gtk_main_quit ();
puts("AFTER_GTK_MAIN_QUIT");
/*puts("AFTER_GTK_MAIN_QUIT");*/
/* We don't want to return, because we've probably been
called from an applet which has since been dlclose()'d,
and we'd end up with a SEGV when we tried to return to
......@@ -415,6 +417,7 @@ applet_callback_callback(GtkWidget *widget, gpointer data)
menu->info->applet_id,
menu->name);
} else if(menu->info->type != APPLET_EXTERN_PENDING &&
menu->info->type==APPLET_EXTERN_RESERVED &&
menu->info->type != APPLET_EMPTY) {
/*handle internal applet callbacks here*/
}
......@@ -592,11 +595,12 @@ applet_request_id (const char * ior, const char *path, char **cfgpath)
info->id = g_strdup(ior);
/*we started this and already reserved a spot
for it, including the eventbox widget*/
info->type = APPLET_EXTERN_RESERVED;
return i;
}
}
reserve_applet_spot (ior, path, 0, 0);
reserve_applet_spot (ior, path, 0, 0, APPLET_EXTERN_RESERVED);
*cfgpath = g_strdup("");
return i;
}
......@@ -608,8 +612,8 @@ reparent_window_id (unsigned long winid, int id)
GdkWindow *win;
int w,h;
AppletInfo *info;
printf ("I got this window ID to reparent: %d\n", winid);
/*printf ("I got this window ID to reparent: %d\n", winid);*/
/*FIXME: check for NULLS!*/
info = (AppletInfo *)(g_list_nth(applets,id)->data);
......@@ -619,22 +623,25 @@ reparent_window_id (unsigned long winid, int id)
win = gdk_window_foreign_new(winid);
gdk_window_get_size(win,&w,&h);
printf ("setting window size to: %d %d\n", w, h);
/*printf ("setting window size to: %d %d\n", w, h);*/
gtk_widget_set_usize(eb,w,h);
gdk_window_reparent(win,eb->window,0,0);
printf ("leaving reparent\n");
/*printf ("leaving reparent\n");*/
}
/*note taht type should be APPLET_EXTERN_RESERVED or APPLET_EXTERN_PENDING
only*/
void
reserve_applet_spot (const char *id, const char *path, int panel, int pos)
reserve_applet_spot (const char *id, const char *path, int panel, int pos,
AppletType type)
{
GtkWidget *eb;
GdkWindow *win;
GList *list;
printf ("entering reserve spot\n");
/*printf ("entering reserve spot\n");*/
eb = gtk_event_box_new();
gtk_widget_show (eb);
......@@ -642,9 +649,9 @@ reserve_applet_spot (const char *id, 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(id),g_strdup(path),
pos,panel,0,APPLET_EXTERN_PENDING);
pos,panel,0,type);
printf ("leaving reserve spot\n");
/*printf ("leaving reserve spot\n");*/
}
/*FIXME: add a function that does this, so generalize register_toy for this*/
......@@ -782,5 +789,5 @@ register_toy(GtkWidget *applet,
orientation_change(info,panelw);
printf ("The window id for %s is: %d\n",id, GDK_WINDOW_XWINDOW (eventbox->window));
/*printf ("The window id for %s is: %d\n",id, GDK_WINDOW_XWINDOW (eventbox->window));*/
}
......@@ -42,6 +42,7 @@ typedef enum {
typedef enum {
APPLET_EXTERN,
APPLET_EXTERN_RESERVED,
APPLET_EXTERN_PENDING,
APPLET_DRAWER,
APPLET_MENU,
......@@ -106,11 +107,13 @@ void apply_global_config(void);
void reparent_window_id (unsigned long winid, int id);
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);
void reserve_applet_spot (const char *id, const char *path, int panel,
int pos, AppletType type);
/*stuff for corba*/
int applet_get_panel(int id);
int applet_get_pos(int id);
void applet_show_menu(int id);
void applet_drag_start(int id);
void applet_drag_stop(int id);
void applet_add_callback(short id, char *callback_name, char *menuitem_text);
......
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