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>
* 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>
* panel.c: move from menu now works
......
......@@ -8,6 +8,8 @@
#include <config.h>
#include <string.h>
#include <signal.h>
#include <waitflags.h>
#include <gnome.h>
#include "panel-widget.h"
#include "panel.h"
......@@ -53,6 +55,16 @@ struct _LoadApplet {
char *cfgpath;
};
static GList * children = NULL;
typedef struct _AppletChild AppletChild;
struct _AppletChild {
AppletInfo *info;
pid_t pid;
};
GList *load_queue=NULL;
/* True if parsing determined that all the work is already done. */
......@@ -108,7 +120,7 @@ void
load_applet(char *id_str, char *params, int pos, int panel, char *cfgpath)
{
if(strcmp(id_str,EXTERN_ID) == 0) {
gchar *command;
/*gchar *command;*/
gchar *fullparams;
/*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)
params[0] == '\0')
return;
reserve_applet_spot (id_str, fullparams, panel, pos, cfgpath,
APPLET_EXTERN_PENDING);
if(reserve_applet_spot (id_str, fullparams, panel, pos, cfgpath,
APPLET_EXTERN_PENDING)==0)
return;
/*'#' marks an applet that will take care of starting
itself but wants us to reserve a spot for it*/
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 :)*/
command = g_copy_strings ("(true;", fullparams, ") &",
NULL);
/*command = g_copy_strings ("(true;", fullparams, ") &",
NULL);*/
for(list=applets;g_list_next(list)!=NULL;
list=g_list_next(list))
;
system (command);
g_free (command);
child->info = list->data;
children = g_list_prepend(children,child);
/*system (command);
g_free (command);*/
}
g_free(fullparams);
......@@ -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
......@@ -780,6 +832,8 @@ main(int argc, char **argv)
bindtextdomain(PACKAGE, GNOMELOCALEDIR);
textdomain(PACKAGE);
signal(SIGCHLD, sigchld_handler);
client = gnome_client_new_default ();
gtk_signal_connect (GTK_OBJECT (client), "save_yourself",
......
......@@ -331,7 +331,7 @@ move_applet_callback(GtkWidget *widget, gpointer data)
panel_widget_applet_move_use_idle(panel);
}
static void
void
panel_clean_applet(AppletInfo *info)
{
PanelWidget *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
path in the params field*/
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 GDK_WINDOW_XWINDOW(socket->window);
}
......@@ -890,7 +892,6 @@ register_toy(GtkWidget *applet,
gtk_object_set_data(GTK_OBJECT(eventbox),
PANEL_APPLET_ASSOC_PANEL_KEY,assoc);
if(pos==PANEL_UNKNOWN_APPLET_POSITION)
pos = 0;
while(panel_widget_add(panelw, eventbox, pos)==-1) {
......@@ -903,6 +904,7 @@ register_toy(GtkWidget *applet,
g_free(info->params);
g_free(info->id_str);
g_free(info);
g_warning("Can't find an empty spot");
return FALSE;
}
panelw = PANEL_WIDGET(list->data);
......
......@@ -101,6 +101,8 @@ void panel_quit(void);
void apply_global_config(void);
void panel_clean_applet(AppletInfo *info);
/*stuff for corba*/
int applet_request_id (const char *path, char **cfgpath,
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