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

bugfix for multiple applets

Fri May 22 03:05:15 1998  George Lebl  <jirka@5z.com>

        * applet-widget.c: bugfix for multiple applets

        * mulapp.[ch]: ripped this out from panel.c, for
          cleanup purposes

        * main.h: created to store the prototypes of functions
          from main.c instead of theim loitering in panel.h
parent e00eb84b
Fri May 22 03:05:15 1998 George Lebl <jirka@5z.com>
* applet-widget.c: bugfix for multiple applets
* mulapp.[ch]: ripped this out from panel.c, for
cleanup purposes
* main.h: created to store the prototypes of functions
from main.c instead of theim loitering in panel.h
Fri May 22 00:46:25 1998 George Lebl <jirka@5z.com>
* applet-widget.[ch]: rearranged soem stuff to make more
......
Fri May 22 03:05:15 1998 George Lebl <jirka@5z.com>
* applet-widget.c: bugfix for multiple applets
* mulapp.[ch]: ripped this out from panel.c, for
cleanup purposes
* main.h: created to store the prototypes of functions
from main.c instead of theim loitering in panel.h
Fri May 22 00:46:25 1998 George Lebl <jirka@5z.com>
* applet-widget.[ch]: rearranged soem stuff to make more
......
......@@ -58,6 +58,7 @@ panel_SOURCES = \
gdkextra.c \
gdkextra.h \
main.c \
main.h \
menu.c \
cookie.c \
menu.h \
......@@ -76,6 +77,8 @@ panel_SOURCES = \
panel-widget.c \
panel-widget.h \
panel-util.c \
mulapp.c \
mulapp.h \
launcher.c \
launcher.h \
logout.c \
......
......@@ -299,8 +299,8 @@ bind_top_applet_events(GtkWidget *widget, int applet_id)
/*id will return a unique id for this applet for the applet to identify
itself as*/
char *
gnome_panel_applet_request_id (char *path,
char *param,
gnome_panel_applet_request_id (const char *path,
const char *param,
int dorestart,
int *applet_id,
char **cfgpath,
......
......@@ -15,7 +15,8 @@ char *get_full_path(char *argv0);
the current session stuff (not in this file, but implemented in any
applet)*/
char *gnome_panel_applet_request_id (char *path, char *param, int dorestart,
char *gnome_panel_applet_request_id (const char *path, const char *param,
int dorestart,
int *applet_id, char **cfgpath,
char **globcfgpath, guint32 *winid);
char *gnome_panel_applet_register (GtkWidget *widget, int applet_id);
......
......@@ -194,8 +194,6 @@ applet_widget_new_with_param(const gchar *param)
if (result)
g_error("Could not talk to the panel: %s\n", result);
g_free(myinvoc);
applet = APPLET_WIDGET (gtk_type_new (applet_widget_get_type ()));
GTK_PLUG(applet)->socket_window = gdk_window_foreign_new (winid);
......
......@@ -18,6 +18,7 @@
#include "drawer.h"
#include "swallow.h"
#include "logout.h"
#include "mulapp.h"
#include "mico-glue.h"
#include "mico-parse.h"
#include "panel-util.h"
......@@ -25,7 +26,8 @@
#include "cookie.h"
/*GList *panels = NULL;*/
#include "main.h"
GArray *applets;
gint applet_count;
......@@ -141,13 +143,13 @@ really_exec_prog(gint applet_id, gchar *path, gchar *param)
{
/*check if this is an applet which is a multi applet and
has something already loaded*/
if(mulapp_is_in_queue(path)) {
puts("multi applet, just contacting existing applet");
if(mulapp_is_in_list(path)) {
mulapp_load_or_add_to_queue(path,param);
return TRUE;
} else {
AppletChild *child;
child = g_new(AppletChild,1);
child->pid = fork();
......@@ -205,6 +207,8 @@ exec_queue_start_next(void)
} while(ret);
}
/* this applet has finished loading, if it was the one we were waiting
on, start the next applet */
void
exec_queue_done(gint applet_id)
{
......@@ -300,7 +304,6 @@ load_applet(gchar *id_str, gchar *path, gchar *params,
fullpath = get_full_path(path);
else
fullpath = g_strdup(path);
if(reserve_applet_spot (id_str, fullpath,params,
panel, pos, cfgpath,
......
#ifndef MAIN_H
#define MAIN_H
BEGIN_GNOME_DECLS
void load_applet(char *id, char *path, char *params,
int pos, int panel, char *cfgpath);
void orientation_change(gint applet_id, PanelWidget *panel);
/* this applet has finished loading, if it was the one we were waiting
on, start the next applet */
void exec_queue_done(gint applet_id);
END_GNOME_DECLS
#endif
/* Gnome panel: multiple applet functionality
* (C) 1998 the Free Software Foundation
*
* Author: George Lebl
*/
#include <config.h>
#include <gnome.h>
#include <stdio.h>
#include <string.h>
#include "panel.h"
#include "mulapp.h"
extern GArray *applets;
extern gint applet_count;
/*multiple applet load queue*/
typedef struct _MultiLoadQueue MultiLoadQueue;
struct _MultiLoadQueue {
gchar *path;
gchar *ior;
GList *params; /*this is a list of parameters, each parameter
represents one applet to start with that
parameter, or an empty string to start an
applet without parameters, there is never a NULL*/
};
static GList *multiple_applet_load_list=NULL;
/*check if we are running an extern applet with a certain path*/
static gint
is_applet_running(const gchar *path)
{
gint i;
AppletInfo *info;
for(info=(AppletInfo *)applets->data,i=0;i<applet_count;i++,info++) {
if((info->type == APPLET_EXTERN ||
info->type == APPLET_EXTERN_PENDING ||
info->type == APPLET_EXTERN_RESERVED) &&
strcmp(info->path,path)==0) {
return TRUE;
}
}
return FALSE;
}
/* remove applets which are no longer on the panel from the list of multi
applets */
void
mulapp_remove_empty_from_list(void)
{
GList *list;
for(list=multiple_applet_load_list;list!=NULL;list=g_list_next(list)){
MultiLoadQueue *mq = list->data;
if(!is_applet_running(mq->path)) {
multiple_applet_load_list =
g_list_remove_link(multiple_applet_load_list,
list);
if(mq->params) g_warning("Whoops! there were applets "
"to be started while the "
"main one disappeared, this "
"should never happen and "
"most likely indicates a bug");
g_free(mq->path);
if(mq->ior) g_free(mq->ior);
g_free(mq);
/*since we should restart the loop now*/
mulapp_remove_empty_from_list();
return;
}
}
}
/*is this path in the list of multi applets*/
gint
mulapp_is_in_list(const gchar *path)
{
GList *list;
mulapp_remove_empty_from_list();
for(list=multiple_applet_load_list;list!=NULL;list=g_list_next(list)){
MultiLoadQueue *mq = list->data;
if(strcmp(mq->path,path)==0)
return TRUE;
}
return FALSE;
}
/*if the parent is already in queue, load the applet or add the param,
into a queue*/
void
mulapp_load_or_add_to_queue(const gchar *path,const gchar *param)
{
GList *list;
mulapp_remove_empty_from_list();
for(list=multiple_applet_load_list;list!=NULL;list=g_list_next(list)){
MultiLoadQueue *mq = list->data;
if(strcmp(mq->path,path)==0) {
if(mq->ior)
send_applet_start_new_applet(mq->ior,param);
else
mq->params = g_list_prepend(mq->params,
g_strdup(param));
return;
}
}
}
/*add this path to the list of multi applets*/
void
mulapp_add_to_list(const gchar *path)
{
MultiLoadQueue *mq;
mq = g_new(MultiLoadQueue,1);
mq->path = g_strdup(path);
mq->ior = NULL;
mq->params = NULL;
multiple_applet_load_list = g_list_prepend(multiple_applet_load_list,
mq);
}
/*we know the ior so let's store that and start all the applets that have
accumulated in the queue for this executable*/
void
mulapp_add_ior_and_free_queue(const gchar *path, const gchar *ior)
{
GList *list;
mulapp_remove_empty_from_list();
for(list=multiple_applet_load_list;list!=NULL;list=g_list_next(list)){
MultiLoadQueue *mq = list->data;
if(strcmp(mq->path,path)==0) {
GList *li;
if(mq->ior && strcmp(mq->ior,ior)!=0)
g_warning("What? there already was an applet "
"before with different IOR?");
else
mq->ior = g_strdup(ior);
if(!mq->params)
return;
for(li=mq->params;li!=NULL;li=g_list_next(li)) {
gchar *param = li->data;
send_applet_start_new_applet(mq->ior,param);
g_free(param);
}
g_list_free(mq->params);
mq->params = NULL;
return;
}
}
}
/* Gnome panel: multiple applet functionality
* (C) 1998 the Free Software Foundation
*
* Author: George Lebl
*/
#ifndef MULAPP_H
#define MULAPP_H
BEGIN_GNOME_DECLS
/*is this path in the list of multi applets*/
gint mulapp_is_in_list(const gchar *path);
/*if the parent is already in queue, load the applet or add the param,
into a queue*/
void mulapp_load_or_add_to_queue(const gchar *path,const gchar *param);
/*add this path to the list of multi applets*/
void mulapp_add_to_list(const gchar *path);
/*we know the ior so let's store that and start all the applets that have
accumulated in the queue for this executable*/
void mulapp_add_ior_and_free_queue(const gchar *path, const gchar *ior);
/* remove applets which are no longer on the panel from the list of multi
applets */
void mulapp_remove_empty_from_list(void);
END_GNOME_DECLS
#endif
......@@ -16,6 +16,7 @@
#include "panel.h"
#include "menu.h"
#include "launcher.h"
#include "mulapp.h"
#include "mico-glue.h"
#include "panel_config.h"
#include "panel_config_global.h"
......@@ -26,7 +27,6 @@
GDK_POINTER_MOTION_MASK | \
GDK_POINTER_MOTION_HINT_MASK)
/*extern GList *panels;*/
extern GArray *applets;
extern gint applet_count;
......@@ -45,133 +45,6 @@ extern char *old_panel_cfg_path;
extern gint main_menu_count;
/*multiple applet load queue*/
typedef struct _MultiLoadQueue MultiLoadQueue;
struct _MultiLoadQueue {
gchar *path;
gchar *ior;
GList *params;
};
static GList *multiple_applet_load_queue=NULL;
static gint
is_applet_running(const gchar *path)
{
gint i;
AppletInfo *info;
for(info=(AppletInfo *)applets->data,i=0;i<applet_count;i++,info++) {
if((info->type == APPLET_EXTERN ||
info->type == APPLET_EXTERN_PENDING ||
info->type == APPLET_EXTERN_RESERVED) &&
strcmp(info->path,path)==0) {
return TRUE;
}
}
return FALSE;
}
static void
mulapp_remove_emptyfrom_queue(void)
{
GList *list;
for(list=multiple_applet_load_queue;list!=NULL;list=g_list_next(list)){
MultiLoadQueue *mq = list->data;
if(!is_applet_running(mq->path)) {
multiple_applet_load_queue =
g_list_remove_link(multiple_applet_load_queue,
list);
if(mq->params) g_warning("Whoops! there were applets "
"to be started while the "
"main one disappeared, this "
"should never happen and "
"most likely indicates a bug");
g_free(mq->path);
if(mq->ior) g_free(mq->ior);
g_free(mq);
/*since we should restart the loop now*/
mulapp_remove_emptyfrom_queue();
return;
}
}
}
gint
mulapp_is_in_queue(const gchar *path)
{
GList *list;
mulapp_remove_emptyfrom_queue();
for(list=multiple_applet_load_queue;list!=NULL;list=g_list_next(list)){
MultiLoadQueue *mq = list->data;
if(strcmp(mq->path,path)==0)
return TRUE;
}
return FALSE;
}
/*if the parent is already in queue, load the applet or add the param,
into a queue*/
void
mulapp_load_or_add_to_queue(const gchar *path,const gchar *param)
{
GList *list;
mulapp_remove_emptyfrom_queue();
for(list=multiple_applet_load_queue;list!=NULL;list=g_list_next(list)){
MultiLoadQueue *mq = list->data;
if(strcmp(mq->path,path)==0) {
if(mq->ior)
send_applet_start_new_applet(mq->ior,param);
else
mq->params = g_list_prepend(mq->params,
g_strdup(param));
return;
}
}
}
void
mulapp_add_to_queue(const gchar *path)
{
MultiLoadQueue *mq;
mq = g_new(MultiLoadQueue,1);
mq->path = g_strdup(path);
mq->ior = NULL;
mq->params = NULL;
multiple_applet_load_queue = g_list_prepend(multiple_applet_load_queue,
mq);
}
static void
mulapp_add_ior_and_free_queue(const gchar *path, const gchar *ior)
{
GList *list;
mulapp_remove_emptyfrom_queue();
for(list=multiple_applet_load_queue;list!=NULL;list=g_list_next(list)){
MultiLoadQueue *mq = list->data;
if(strcmp(mq->path,path)==0) {
GList *li;
if(mq->ior && strcmp(mq->ior,ior)!=0)
g_warning("What? there already was an applet "
"before with different IOR?");
else
mq->ior = g_strdup(ior);
if(!mq->params)
return;
for(li=mq->params;li!=NULL;li=g_list_next(li)) {
gchar *param = li->data;
send_applet_start_new_applet(mq->ior,param);
g_free(param);
}
g_list_free(mq->params);
mq->params = NULL;
return;
}
}
}
void
apply_global_config(void)
{
......@@ -608,7 +481,7 @@ panel_clean_applet(gint applet_id)
info->user_menu = g_list_remove_link(info->user_menu,
info->user_menu);
}
mulapp_remove_emptyfrom_queue();
mulapp_remove_empty_from_list();
}
static void
......@@ -952,8 +825,8 @@ applet_request_id (const char *path, const char *param,
*globcfgpath = g_strdup(old_panel_cfg_path);
info->type = APPLET_EXTERN_RESERVED;
*winid=GDK_WINDOW_XWINDOW(info->applet_widget->window);
if(!dorestart && !mulapp_is_in_queue(path))
mulapp_add_to_queue(path);
if(!dorestart && !mulapp_is_in_list(path))
mulapp_add_to_list(path);
return i;
}
......@@ -970,8 +843,8 @@ applet_request_id (const char *path, const char *param,
*globcfgpath = g_strdup(old_panel_cfg_path);
info = get_applet_info(applet_count-1);
if(!dorestart && !mulapp_is_in_queue(path))
mulapp_add_to_queue(path);
if(!dorestart && !mulapp_is_in_list(path))
mulapp_add_to_list(path);
return i;
}
......
......@@ -134,27 +134,8 @@ void applet_add_callback(gint applet_id,
void applet_set_tooltip(gint applet_id, const char *tooltip);
void applet_remove_from_panel(gint applet_id);
/*multi applet que functions*/
gint mulapp_is_in_queue(const gchar *path);
/*if the parent is already in queue, load the applet or add the param,
into a queue*/
void mulapp_load_or_add_to_queue(const gchar *path,const gchar *param);
void mulapp_add_to_queue(const gchar *path);
/*exec queue done function from main.c*/
void exec_queue_done(gint applet_id);
extern char *cookie;
/*this is in main.c*/
void load_applet(char *id, char *path, char *params,
int pos, int panel, char *cfgpath);
void orientation_change(gint applet_id, PanelWidget *panel);
#define get_applet_info(applet_id) \
((applet_id>=0 && applet_id<applet_count) ? \
(&g_array_index(applets,AppletInfo,applet_id)):NULL)
......
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