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

remove applets that die (only those started on startup)

Fri Apr 17 19:42:32 1998  George Lebl  <jirka@5z.com>

        * panel.c,main.c: remove applets that die (only
          those started on startup)
parent 614c90ac
Fri Apr 17 19:42:32 1998 George Lebl <jirka@5z.com>
* panel.c,main.c: remove applets that die (only
those started on startup)
Fri Apr 17 17:31:19 1998 George Lebl <jirka@5z.com> Fri Apr 17 17:31:19 1998 George Lebl <jirka@5z.com>
* panel.c: move from menu now works * panel.c: move from menu now works
......
Fri Apr 17 19:42:32 1998 George Lebl <jirka@5z.com>
* panel.c,main.c: remove applets that die (only
those started on startup)
Fri Apr 17 17:31:19 1998 George Lebl <jirka@5z.com> Fri Apr 17 17:31:19 1998 George Lebl <jirka@5z.com>
* panel.c: move from menu now works * panel.c: move from menu now works
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <config.h> #include <config.h>
#include <string.h> #include <string.h>
#include <signal.h>
#include <waitflags.h>
#include <gnome.h> #include <gnome.h>
#include "panel-widget.h" #include "panel-widget.h"
#include "panel.h" #include "panel.h"
...@@ -53,6 +55,16 @@ struct _LoadApplet { ...@@ -53,6 +55,16 @@ struct _LoadApplet {
char *cfgpath; char *cfgpath;
}; };
static GList * children = NULL;
typedef struct _AppletChild AppletChild;
struct _AppletChild {
AppletInfo *info;
pid_t pid;
};
GList *load_queue=NULL; GList *load_queue=NULL;
/* True if parsing determined that all the work is already done. */ /* True if parsing determined that all the work is already done. */
...@@ -108,7 +120,7 @@ void ...@@ -108,7 +120,7 @@ void
load_applet(char *id_str, char *params, int pos, int panel, char *cfgpath) load_applet(char *id_str, char *params, int pos, int panel, char *cfgpath)
{ {
if(strcmp(id_str,EXTERN_ID) == 0) { if(strcmp(id_str,EXTERN_ID) == 0) {
gchar *command; /*gchar *command;*/
gchar *fullparams; gchar *fullparams;
/*make it an absolute path, same as the applets will /*make it an absolute path, same as the applets will
...@@ -125,18 +137,41 @@ load_applet(char *id_str, char *params, int pos, int panel, char *cfgpath) ...@@ -125,18 +137,41 @@ load_applet(char *id_str, char *params, int pos, int panel, char *cfgpath)
params[0] == '\0') params[0] == '\0')
return; return;
reserve_applet_spot (id_str, fullparams, panel, pos, cfgpath, if(reserve_applet_spot (id_str, fullparams, panel, pos, cfgpath,
APPLET_EXTERN_PENDING); APPLET_EXTERN_PENDING)==0)
return;
/*'#' marks an applet that will take care of starting /*'#' marks an applet that will take care of starting
itself but wants us to reserve a spot for it*/ itself but wants us to reserve a spot for it*/
if(params[0]!='#') { if(params[0]!='#') {
AppletChild *child;
GList *list;
child = g_new(AppletChild,1);
child->pid=fork();
if(child->pid==-1)
g_error("Can't fork!");
if(child->pid==0) {
execlp(fullparams,fullparams,NULL);
g_error("Can't execlp!");
_exit(1);
}
/*this applet is dumb and wants us to start it :)*/ /*this applet is dumb and wants us to start it :)*/
command = g_copy_strings ("(true;", fullparams, ") &", /*command = g_copy_strings ("(true;", fullparams, ") &",
NULL); NULL);*/
for(list=applets;g_list_next(list)!=NULL;
list=g_list_next(list))
;
system (command); child->info = list->data;
g_free (command);
children = g_list_prepend(children,child);
/*system (command);
g_free (command);*/
} }
g_free(fullparams); g_free(fullparams);
...@@ -767,6 +802,23 @@ panel_connect_client (GnomeClient *client, ...@@ -767,6 +802,23 @@ panel_connect_client (GnomeClient *client,
} }
void
sigchld_handler(int type)
{
GList *list;
pid_t pid = waitpid(0,NULL,WNOHANG);
if(pid <= 0)
return;
for(list=children;list!=NULL;list=g_list_next(list)) {
AppletChild *child=list->data;
if(child->pid == pid) {
panel_clean_applet(child->info);
break;
}
}
}
int int
...@@ -780,6 +832,8 @@ main(int argc, char **argv) ...@@ -780,6 +832,8 @@ main(int argc, char **argv)
bindtextdomain(PACKAGE, GNOMELOCALEDIR); bindtextdomain(PACKAGE, GNOMELOCALEDIR);
textdomain(PACKAGE); textdomain(PACKAGE);
signal(SIGCHLD, sigchld_handler);
client = gnome_client_new_default (); client = gnome_client_new_default ();
gtk_signal_connect (GTK_OBJECT (client), "save_yourself", gtk_signal_connect (GTK_OBJECT (client), "save_yourself",
......
...@@ -331,7 +331,7 @@ move_applet_callback(GtkWidget *widget, gpointer data) ...@@ -331,7 +331,7 @@ move_applet_callback(GtkWidget *widget, gpointer data)
panel_widget_applet_move_use_idle(panel); panel_widget_applet_move_use_idle(panel);
} }
static void void
panel_clean_applet(AppletInfo *info) panel_clean_applet(AppletInfo *info)
{ {
PanelWidget *panel; PanelWidget *panel;
...@@ -739,8 +739,10 @@ reserve_applet_spot (const char *id_str, const char *path, int panel, ...@@ -739,8 +739,10 @@ reserve_applet_spot (const char *id_str, const char *path, int panel,
/*we save the ior in the id field of the appletinfo and the /*we save the ior in the id field of the appletinfo and the
path in the params field*/ path in the params field*/
if(!register_toy(socket,NULL,NULL,g_strdup(id_str),g_strdup(path), if(!register_toy(socket,NULL,NULL,g_strdup(id_str),g_strdup(path),
pos,panel,cfgpath, type)) pos,panel,cfgpath, type)) {
g_warning("Couldn't add applet");
return 0; return 0;
}
return GDK_WINDOW_XWINDOW(socket->window); return GDK_WINDOW_XWINDOW(socket->window);
} }
...@@ -890,7 +892,6 @@ register_toy(GtkWidget *applet, ...@@ -890,7 +892,6 @@ register_toy(GtkWidget *applet,
gtk_object_set_data(GTK_OBJECT(eventbox), gtk_object_set_data(GTK_OBJECT(eventbox),
PANEL_APPLET_ASSOC_PANEL_KEY,assoc); PANEL_APPLET_ASSOC_PANEL_KEY,assoc);
if(pos==PANEL_UNKNOWN_APPLET_POSITION) if(pos==PANEL_UNKNOWN_APPLET_POSITION)
pos = 0; pos = 0;
while(panel_widget_add(panelw, eventbox, pos)==-1) { while(panel_widget_add(panelw, eventbox, pos)==-1) {
...@@ -903,6 +904,7 @@ register_toy(GtkWidget *applet, ...@@ -903,6 +904,7 @@ register_toy(GtkWidget *applet,
g_free(info->params); g_free(info->params);
g_free(info->id_str); g_free(info->id_str);
g_free(info); g_free(info);
g_warning("Can't find an empty spot");
return FALSE; return FALSE;
} }
panelw = PANEL_WIDGET(list->data); panelw = PANEL_WIDGET(list->data);
......
...@@ -101,6 +101,8 @@ void panel_quit(void); ...@@ -101,6 +101,8 @@ void panel_quit(void);
void apply_global_config(void); void apply_global_config(void);
void panel_clean_applet(AppletInfo *info);
/*stuff for corba*/ /*stuff for corba*/
int applet_request_id (const char *path, char **cfgpath, int applet_request_id (const char *path, char **cfgpath,
char **globcfgpath, guint32 *winid); char **globcfgpath, guint32 *winid);
......
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