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

implement run queue, this will start up applets in a row, reducing load on

Mon May 18 23:35:13 1998  George Lebl  <jirka@5z.com>

        * panel.[ch],main.c: implement run queue, this will start up
          applets in a row, reducing load on the machine, flicker,
          though it doesn't do much for speed as I thought it would,
          maybe when we use ORBit and the applets will start up faster
          it will be noticable as they are not fighting over X
parent dcc36f23
Mon May 18 23:35:13 1998 George Lebl <jirka@5z.com>
* panel.[ch],main.c: implement run queue, this will start up
applets in a row, reducing load on the machine, flicker,
though it doesn't do much for speed as I thought it would,
maybe when we use ORBit and the applets will start up faster
it will be noticable as they are not fighting over X
Mon May 18 21:31:53 1998 George Lebl <jirka@5z.com>
* panel.c: fix segfault
......
Mon May 18 23:35:13 1998 George Lebl <jirka@5z.com>
* panel.[ch],main.c: implement run queue, this will start up
applets in a row, reducing load on the machine, flicker,
though it doesn't do much for speed as I thought it would,
maybe when we use ORBit and the applets will start up faster
it will be noticable as they are not fighting over X
Mon May 18 21:31:53 1998 George Lebl <jirka@5z.com>
* panel.c: fix segfault
......
......@@ -78,6 +78,22 @@ gint just_exit = 0;
/* The security cookie */
char *cookie;
/*execution queue stuff, execute only one applet in a row, thereby getting
rid of some problems with applet*/
gint current_exec = -1;
guint cur_timeout=0;
typedef struct _ExecQueue ExecQueue;
struct _ExecQueue {
gint applet_id;
gchar *path;
gchar *param;
};
GList *exec_queue=NULL;
/* These are the arguments that our application supports. */
static struct argp_option arguments[] =
{
......@@ -109,6 +125,96 @@ static struct argp parser =
/*needed for drawers*/
static void panel_setup(PanelWidget *panel);
static void really_exec_prog(gint applet_id, gchar *path, gchar *param);
static void exec_queue_start_next(void);
static gint
exec_queue_timeout(gpointer data)
{
g_warning("TIMED OUT waiting to applet ID: %d!",current_exec);
cur_timeout = -1;
exec_queue_start_next();
return FALSE;
}
static void
really_exec_prog(gint applet_id, gchar *path, gchar *param)
{
/*this applet is dumb and wants us to start it :)*/
AppletChild *child;
child = g_new(AppletChild,1);
child->pid = fork();
if(child->pid < 0)
g_error("Can't fork!");
if(child->pid == 0) {
if(strlen(param)>0)
execl(path,path,param,NULL);
else
execl(path,path,NULL);
g_error("Can't execl!");
}
printf("started applet, pid: %d\n",child->pid);
child->applet_id = applet_id;
children = g_list_prepend(children,child);
current_exec = applet_id;
cur_timeout = gtk_timeout_add(30*100,exec_queue_timeout,NULL);
}
static void
exec_queue_start_next(void)
{
ExecQueue *eq;
current_exec = -1;
if(cur_timeout>0)
gtk_timeout_remove(cur_timeout);
cur_timeout=0;
if(!exec_queue)
return;
eq = exec_queue->data;
really_exec_prog(eq->applet_id, eq->path, eq->param);
g_free(eq->path);
if(eq->param) g_free(eq->param);
g_free(eq);
exec_queue = g_list_remove_link(exec_queue,exec_queue);
}
void
exec_queue_done(gint applet_id)
{
if(applet_id>-1 && applet_id==current_exec)
exec_queue_start_next();
}
static void
exec_prog(gint applet_id, gchar *path, gchar *param)
{
if(current_exec==-1) {
really_exec_prog(applet_id,path,param);
} else {
ExecQueue *eq = g_new(ExecQueue,1);
eq->applet_id = applet_id;
eq->path = g_strdup(path);
if(param)
eq->param = g_strdup(param);
else
eq->param = NULL;
exec_queue = g_list_append(exec_queue,eq);
}
}
static void
queue_load_applet(gchar *id_str, gchar *path, gchar *params, gint dorestart,
gint pos, gint panel, gchar *cfgpath)
......@@ -200,29 +306,8 @@ load_applet(gchar *id_str, gchar *path, gchar *params, gint dorestart,
}
}
if(path[0]!='#') {
/*this applet is dumb and wants us to start it :)*/
AppletChild *child;
child = g_new(AppletChild,1);
child->pid = fork();
if(child->pid < 0)
g_error("Can't fork!");
if(child->pid == 0) {
if(strlen(param)>0)
execl(fullpath,fullpath,param,NULL);
else
execl(fullpath,fullpath,NULL);
g_error("Can't execl!");
}
printf("started applet, pid: %d\n",child->pid);
child->applet_id = applet_count-1;
children = g_list_prepend(children,child);
}
if(path[0]!='#')
exec_prog(applet_count-1,fullpath,param);
g_free(fullpath);
} else if(strcmp(id_str,MENU_ID) == 0) {
......@@ -921,6 +1006,8 @@ sigchld_handler(int type)
panel_clean_applet(child->applet_id);
exec_queue_done(child->applet_id);
g_free(child);
children=g_list_remove_link(children,list);
return;
......
......@@ -302,15 +302,15 @@ save_panel_configuration(gpointer data, gpointer user_data)
if (panel->back_pixmap) {
gnome_config_set_string("backpixmap", panel->back_pixmap ? panel->back_pixmap : "");
gnome_config_clean_key("backcolor");
} else {
gnome_config_clean_key("backcolor");
} else if(panel->back_color.pixel>0) {
char buf[32];
gnome_config_clean_key("backpixmap");
g_snprintf(buf, sizeof(buf), "#%02x%02x%02x",
(guint)panel->back_color.red/256,
(guint)panel->back_color.green/256,
(guint)panel->back_color.blue/256);
gnome_config_set_string("backcolor", buf);
gnome_config_clean_key("backpixmap");
}
......@@ -947,6 +947,7 @@ applet_request_id (const char *path, const char *param,
}
*cfgpath = NULL;
*globcfgpath = g_strdup(old_panel_cfg_path);
return i;
}
......@@ -962,6 +963,9 @@ applet_register (const char * ior, int applet_id)
AppletInfo *info = get_applet_info(applet_id);
PanelWidget *panel;
/*start the next applet in queue*/
exec_queue_done(applet_id);
g_return_if_fail(info != NULL);
panel = gtk_object_get_data(GTK_OBJECT(info->widget),
......
......@@ -144,6 +144,9 @@ void mulapp_load_or_add_to_queue(gchar *path,gchar *param);
void mulapp_add_to_queue(gchar *path, gint applet_id);
/*exec queue done function from main.c*/
void exec_queue_done(gint applet_id);
extern char *cookie;
......
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