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

removed the query call as multiple applets will be handeled on the panel

Tue May 12 01:29:19 1998  George Lebl  <jirka@5z.com>

        * gnome-panel.idl,mico-glue.cc,applet-lib.cc:
          removed the query call as multiple applets
          will be handeled on the panel side

        * gnome-panel.idl,mico-glue.cc,applet-lib.cc,main.c,
          panel.[ch],menu.c: added support for parameters
          to applets, seems pretty hackish mainly because
          it tries not to break existing config file format,
          which it doesn't as far as I can see
parent b69d59b1
Tue May 12 01:29:19 1998 George Lebl <jirka@5z.com>
* gnome-panel.idl,mico-glue.cc,applet-lib.cc:
removed the query call as multiple applets
will be handeled on the panel side
* gnome-panel.idl,mico-glue.cc,applet-lib.cc,main.c,
panel.[ch],menu.c: added support for parameters
to applets, seems pretty hackish mainly because
it tries not to break existing config file format,
which it doesn't as far as I can see
Mon May 11 00:44:25 1998 George Lebl <jirka@5z.com>
* main.c: start applets witha shell and get the pid
......
Tue May 12 01:29:19 1998 George Lebl <jirka@5z.com>
* gnome-panel.idl,mico-glue.cc,applet-lib.cc:
removed the query call as multiple applets
will be handeled on the panel side
* gnome-panel.idl,mico-glue.cc,applet-lib.cc,main.c,
panel.[ch],menu.c: added support for parameters
to applets, seems pretty hackish mainly because
it tries not to break existing config file format,
which it doesn't as far as I can see
Mon May 11 00:44:25 1998 George Lebl <jirka@5z.com>
* main.c: start applets witha shell and get the pid
......
......@@ -94,7 +94,7 @@ public:
}
}
void start_new_applet (const char *ccookie,
const char *params)
const char *param)
{
CHECK_COOKIE ();
/*FIXME: start new applet*/
......@@ -300,6 +300,7 @@ bind_top_applet_events(GtkWidget *widget, int applet_id)
itself as*/
char *
gnome_panel_applet_request_id (char *path,
char *param,
int *applet_id,
char **cfgpath,
char **globcfgpath,
......@@ -319,7 +320,9 @@ gnome_panel_applet_request_id (char *path,
try {
/*reserve a spot and get an id for this applet*/
*applet_id = panel_client->applet_request_id(cookie,
path,cfg,
path,
param,
cfg,
globcfg,
wid);
} catch (...) {
......
......@@ -15,7 +15,7 @@ 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, int *applet_id,
char *gnome_panel_applet_request_id (char *path, char *param, int *applet_id,
char **cfgpath, char **globcfgpath,
guint32 *winid);
char *gnome_panel_applet_register (GtkWidget *widget, int applet_id);
......
......@@ -160,6 +160,12 @@ applet_widget_register_callback(AppletWidget *applet,
GtkWidget *
applet_widget_new(gchar *argv0)
{
return applet_widget_new_with_param(argv0,"");
}
GtkWidget *
applet_widget_new_with_param(gchar *argv0, gchar *param)
{
AppletWidget *applet;
char *result;
......@@ -173,10 +179,13 @@ applet_widget_new(gchar *argv0)
if(!myinvoc)
return 0;
if(!param)
param="";
if (!gnome_panel_applet_init_corba())
g_error("Could not communicate with the panel\n");
result = gnome_panel_applet_request_id(myinvoc, &applet_id,
result = gnome_panel_applet_request_id(myinvoc, param, &applet_id,
&cfgpath, &globcfgpath,
&winid);
if (result)
......
......@@ -60,6 +60,7 @@ struct _AppletWidgetClass
guint applet_widget_get_type (void);
GtkWidget* applet_widget_new (gchar *argv0);
GtkWidget* applet_widget_new_with_param (gchar *argv0, gchar *param);
/*set tooltip over the applet, NULL to remove a tooltip*/
void applet_widget_set_tooltip (AppletWidget *applet,
......
......@@ -4,14 +4,10 @@
#
module GNOME {
interface Panel {
/*for applets who can have multiple widgets*/
short applet_query_about(in string cookie,
in string path,
out string ior);
/* requests an ID on the panel */
short applet_request_id(in string cookie,
in string path,
in string param,
out string cfgpath,
out string globcfgpath,
out unsigned long wid);
......@@ -57,7 +53,7 @@ module GNOME {
/* params is only used if the applet process handeles more
applet types */
void start_new_applet (in string cookie, in string params);
void start_new_applet (in string cookie, in string param);
};
};
......@@ -52,6 +52,7 @@ GlobalConfig global_config = {
typedef struct _LoadApplet LoadApplet;
struct _LoadApplet {
char *id_str;
char *path;
char *params;
int pos;
int panel;
......@@ -108,12 +109,14 @@ static struct argp parser =
static void panel_setup(PanelWidget *panel);
void
queue_load_applet(char *id_str, char *params, int pos, int panel, char *cfgpath)
queue_load_applet(char *id_str, char *path, char *params, int pos, int panel, char *cfgpath)
{
LoadApplet *l;
l = g_new(LoadApplet,1);
l->id_str=g_strdup(id_str);
if(path) l->path=g_strdup(path);
else l->path = NULL;
l->params=g_strdup(params);
l->pos=pos;
l->panel=panel;
......@@ -137,55 +140,63 @@ monitor_drawers(GtkWidget *w, gpointer data)
void
load_applet(char *id_str, char *params, int pos, int panel, char *cfgpath)
load_applet(char *id_str, char *path, char *params, int pos, int panel,
char *cfgpath)
{
if(strcmp(id_str,EXTERN_ID) == 0) {
gchar *fullparams;
gchar *fullpath;
/*start nothing, applet is taking care of everything*/
if(params == NULL ||
params[0] == '\0')
if(path == NULL ||
path[0] == '\0')
return;
/*VERY UGLY compatibility hack for the old launcher applet*/
if(strcmp(params,"#panel.application.launcher")==0) {
if(strcmp(path,"#panel.application.launcher")==0) {
gchar *p;
p = g_copy_strings(cfgpath,"path=",NULL);
fullparams = gnome_config_get_string(p);
fullpath = gnome_config_get_string(p);
g_free(p);
load_applet(LAUNCHER_ID,fullparams,pos,panel,cfgpath);
g_free(fullparams);
load_applet(LAUNCHER_ID,NULL,fullpath,pos,panel,
cfgpath);
g_free(fullpath);
return;
}
/*make it an absolute path, same as the applets will
interpret it and the applets will sign themselves as
this, so it has to be exactly the same*/
if(params[0]!='#')
fullparams = get_full_path(params);
if(path[0]!='#')
fullpath = get_full_path(path);
else
fullparams = g_strdup(params);
fullpath = g_strdup(path);
if(reserve_applet_spot (id_str, fullparams, panel, pos,
if(reserve_applet_spot (id_str, fullpath,params, panel, pos,
cfgpath, APPLET_EXTERN_PENDING)==0) {
g_free(fullparams);
g_free(fullpath);
return;
}
/*'#' marks an applet that will take care of starting
itself but wants us to reserve a spot for it*/
if(params[0]!='#') {
if(path[0]!='#') {
/*this applet is dumb and wants us to start it :)*/
AppletChild *child;
FILE *fp;
char buf[256];
gint i;
char *param;
child = g_new(AppletChild,1);
g_snprintf(buf,256,"(true;%s & echo $! )", fullparams);
if(!params)
param = "";
else
param = params;
g_snprintf(buf,256,"(true;%s %s & echo $! )",
fullpath,param);
fp = popen(buf,"r");
fscanf(fp,"%d",&child->pid);
fclose(fp);
......@@ -197,14 +208,14 @@ load_applet(char *id_str, char *params, int pos, int panel, char *cfgpath)
children = g_list_prepend(children,child);
}
g_free(fullparams);
g_free(fullpath);
} else if(strcmp(id_str,MENU_ID) == 0) {
Menu *menu;
menu = create_menu_applet(params, MENU_UP);
register_toy(menu->button,menu->menu,menu,MENU_ID,params,pos,
panel,NULL,APPLET_MENU);
register_toy(menu->button,menu->menu,menu,MENU_ID,NULL,params,
pos,panel,NULL,APPLET_MENU);
if(!params || strcmp(params,".")==0)
main_menu_count++;
} else if(strcmp(id_str,LAUNCHER_ID) == 0) {
......@@ -212,7 +223,7 @@ load_applet(char *id_str, char *params, int pos, int panel, char *cfgpath)
launcher = create_launcher(params);
register_toy(launcher->button,NULL,launcher,LAUNCHER_ID,
register_toy(launcher->button,NULL,launcher,LAUNCHER_ID,NULL,
params,pos,panel,NULL,APPLET_LAUNCHER);
gtk_tooltips_set_tip (panel_tooltips,launcher->button->parent,
......@@ -263,7 +274,7 @@ load_applet(char *id_str, char *params, int pos, int panel, char *cfgpath)
g_return_if_fail(drawer != NULL);
register_toy(drawer->button,drawer->drawer,drawer,DRAWER_ID,
params, pos, panel, NULL, APPLET_DRAWER);
NULL, params, pos, panel, NULL, APPLET_DRAWER);
panelarr = g_new(PanelWidget *,2);
panelarr[0] = PANEL_WIDGET(drawer->drawer);
......@@ -284,14 +295,14 @@ load_applet(char *id_str, char *params, int pos, int panel, char *cfgpath)
swallow = create_swallow_applet(params, SWALLOW_HORIZONTAL);
register_toy(swallow->table,NULL,swallow,SWALLOW_ID,params,pos,
panel,NULL,APPLET_SWALLOW);
register_toy(swallow->table,NULL,swallow,SWALLOW_ID,NULL,
params,pos, panel,NULL,APPLET_SWALLOW);
} else if(strcmp(id_str,LOGOUT_ID) == 0) {
GtkWidget *logout;
logout = create_logout_widget();
register_toy(logout,NULL,NULL,LOGOUT_ID,params,pos,
register_toy(logout,NULL,NULL,LOGOUT_ID,NULL,params,pos,
panel,NULL,APPLET_LOGOUT);
}
}
......@@ -303,8 +314,10 @@ load_queued_applets(void)
for(list = load_queue;list!=NULL;list=g_list_next(list)) {
LoadApplet *l=list->data;
load_applet(l->id_str,l->params,l->pos,l->panel,l->cfgpath);
load_applet(l->id_str,l->path,l->params,l->pos,l->panel,
l->cfgpath);
g_free(l->id_str);
if(l->path) g_free(l->path);
g_free(l->params);
g_free(l->cfgpath);
g_free(l);
......@@ -327,8 +340,9 @@ add_forbidden_to_panels(void)
static void
load_default_applets(void)
{
queue_load_applet(MENU_ID, ".", PANEL_UNKNOWN_APPLET_POSITION,0,NULL);
queue_load_applet(EXTERN_ID, "clock_applet",
queue_load_applet(MENU_ID, NULL, ".", PANEL_UNKNOWN_APPLET_POSITION,
0,NULL);
queue_load_applet(EXTERN_ID, "clock_applet", "",
PANEL_UNKNOWN_APPLET_POSITION,0,NULL);
}
......@@ -337,6 +351,7 @@ init_user_applets(void)
{
char *applet_name;
char *applet_params;
char *applet_path;
int pos=0,panel;
char buf[256];
int count,num;
......@@ -346,25 +361,34 @@ init_user_applets(void)
if(count<=0)
load_default_applets();
for(num=1;num<=count;num++) {
g_snprintf(buf,256,"%sApplet_%d/id=Unknown",
old_panel_cfg_path, num);
applet_name = gnome_config_get_string(buf);
g_snprintf(buf,256,"%sApplet_%d/parameters=",
old_panel_cfg_path, num);
applet_params = gnome_config_get_string(buf);
g_snprintf(buf,256,"%sApplet_%d/position=%d",
old_panel_cfg_path, num,
g_snprintf(buf,256,"%sApplet_%d/", old_panel_cfg_path, num);
gnome_config_push_prefix(buf);
applet_name = gnome_config_get_string("id=Unknown");
/*fairly ugly hack to preserve config file compatibility*/
if(strcmp(applet_name,"Extern")==0) {
applet_path = gnome_config_get_string("parameters=");
applet_params = gnome_config_get_string("parameters2=");
} else {
applet_path = NULL;
applet_params = gnome_config_get_string("parameters=");
}
g_snprintf(buf,256,"position=%d",
PANEL_UNKNOWN_APPLET_POSITION);
pos = gnome_config_get_int(buf);
g_snprintf(buf,256,"%sApplet_%d/panel=0",
old_panel_cfg_path, num);
panel = gnome_config_get_int(buf);
panel = gnome_config_get_int("panel=0");
/*this is the config path to be passed to the applet when it
loads*/
g_snprintf(buf,256,"%sApplet_%d/",old_panel_cfg_path,num);
queue_load_applet(applet_name, applet_params, pos, panel, buf);
queue_load_applet(applet_name, applet_path, applet_params,
pos, panel, buf);
gnome_config_pop_prefix();
g_free(applet_name);
if(applet_path) g_free(applet_path);
g_free(applet_params);
}
}
......
......@@ -140,9 +140,9 @@ free_string (GtkWidget *widget, void *data)
}
static gint
add_to_panel (char *applet, char *arg)
add_to_panel (char *applet, char *path, char *arg)
{
load_applet(applet,arg,PANEL_UNKNOWN_APPLET_POSITION,0,NULL);
load_applet(applet,path,arg,PANEL_UNKNOWN_APPLET_POSITION,0,NULL);
return TRUE;
}
......@@ -151,20 +151,53 @@ add_app_to_panel (GtkWidget *widget, void *data)
{
GnomeDesktopEntry *ii = data;
return add_to_panel (LAUNCHER_ID, ii->location);
return add_to_panel (LAUNCHER_ID, NULL, ii->location);
}
static gint
add_dir_to_panel (GtkWidget *widget, void *data)
{
return add_to_panel (MENU_ID, data);
return add_to_panel (MENU_ID, NULL, data);
}
/* a fairly dumb parser, spaces have to be escaped with \ not in
quotes!!!*/
static void
get_path_param(gchar *in, gchar **path, gchar **param)
{
gchar *p;
*path = g_strdup(in);
p = *path;
do
p=strchr(p,' ');
while(p && p>*path && *(p-1)=='\\');
if(!p || p>*path) {
*param = g_strdup("");
} else {
*p = '\0';
*param = g_strdup(p+1);
}
}
static gint
add_applet (GtkWidget *w, gpointer data)
{
GnomeDesktopEntry *ii = data;
return add_to_panel(EXTERN_ID,ii->exec);
char *path;
char *param;
gint r;
/*parse out the path and arguments with this really REALLY dumb*/
get_path_param(ii->exec,&path,&param);
r = add_to_panel(EXTERN_ID,path,param);
g_free(path);
g_free(param);
return r;
}
static GtkWidget *
......@@ -385,7 +418,7 @@ panel_configure (GtkWidget *widget, void *data)
static void
add_applet_to_panel_data(GtkWidget *widget, gpointer data)
{
add_to_panel((char *)data, NULL);
add_to_panel((char *)data, NULL, NULL);
}
static gint
......@@ -395,7 +428,7 @@ act_really_add_swallow(GtkWidget *w, gpointer data)
GtkWidget *d = gtk_object_get_user_data(GTK_OBJECT(entry));
gtk_widget_hide(d);
add_to_panel(SWALLOW_ID, gtk_entry_get_text(GTK_ENTRY(entry)));
add_to_panel(SWALLOW_ID, NULL, gtk_entry_get_text(GTK_ENTRY(entry)));
return TRUE;
}
......@@ -407,7 +440,8 @@ really_add_swallow(GtkWidget *d,gint button, gpointer data)
gtk_widget_hide(d);
if(button == 0)
add_to_panel(SWALLOW_ID, gtk_entry_get_text(GTK_ENTRY(entry)));
add_to_panel(SWALLOW_ID, NULL,
gtk_entry_get_text(GTK_ENTRY(entry)));
return TRUE;
}
......
......@@ -19,15 +19,9 @@
class Panel_impl : virtual public GNOME::Panel_skel {
public:
CORBA::Short applet_query_about (const char *ccookie,
const char *path,
char *&ior) {
CHECK_COOKIE_V (0);
/*FIXME query for applet*/
return 0;
}
CORBA::Short applet_request_id (const char *ccookie,
const char *path,
const char *param,
char *&cfgpath,
char *&globcfgpath,
CORBA::ULong &wid) {
......@@ -37,7 +31,7 @@ public:
guint32 winid;
CHECK_COOKIE_V (0);
applet_id = ::applet_request_id (path,&cfg,&globcfg,&winid);
applet_id = ::applet_request_id (path,param,&cfg,&globcfg,&winid);
wid = winid;
if(cfg) {
......
......@@ -135,6 +135,10 @@ save_applet_configuration(AppletInfo *info, gint *num)
g_free(fullpath);
fullpath = g_copy_strings(path,"parameters",NULL);
gnome_config_set_string(fullpath, info->path);
g_free(fullpath);
fullpath = g_copy_strings(path,"parameters2",NULL);
gnome_config_set_string(fullpath, info->params);
g_free(fullpath);
} else
......@@ -446,6 +450,8 @@ panel_clean_applet(gint applet_id)
if(info->id_str) g_free(info->id_str);
info->id_str=NULL;
if(info->path) g_free(info->path);
info->path=NULL;
if(info->params) g_free(info->params);
info->params=NULL;
if(info->cfg) g_free(info->cfg);
......@@ -772,7 +778,7 @@ applet_add_callback(gint applet_id, char *callback_name, char *menuitem_text)
}
int
applet_request_id (const char *path, char **cfgpath,
applet_request_id (const char *path, const char *param, char **cfgpath,
char **globcfgpath, guint32 * winid)
{
AppletInfo *info;
......@@ -780,7 +786,8 @@ applet_request_id (const char *path, char **cfgpath,
for(info=(AppletInfo *)applets->data,i=0;i<applet_count;i++,info++) {
if(info && info->type == APPLET_EXTERN_PENDING &&
strcmp(info->params,path)==0) {
strcmp(info->path,path)==0 &&
strcmp(info->params,param)==0) {
/*we started this and already reserved a spot
for it, including the socket widget*/
*cfgpath = info->cfg;
......@@ -792,7 +799,7 @@ applet_request_id (const char *path, char **cfgpath,
}
}
*winid = reserve_applet_spot (EXTERN_ID, path, 0, 0, NULL,
*winid = reserve_applet_spot (EXTERN_ID, path, param, 0, 0, NULL,
APPLET_EXTERN_RESERVED);
if(*winid == 0) {
*globcfgpath = NULL;
......@@ -835,8 +842,8 @@ applet_register (const char * ior, int applet_id)
/*note that type should be APPLET_EXTERN_RESERVED or APPLET_EXTERN_PENDING
only*/
guint32
reserve_applet_spot (const char *id_str, const char *path, int panel,
int pos, char *cfgpath, AppletType type)
reserve_applet_spot (const char *id_str, const char *path, const char *param,
int panel, int pos, char *cfgpath, AppletType type)
{
GtkWidget *socket;
......@@ -847,9 +854,9 @@ reserve_applet_spot (const char *id_str, const char *path, int panel,
gtk_widget_show (socket);
/*we save the ior in the id field of the appletinfo and the
path in the params field*/
path in the path field*/
if(!register_toy(socket,NULL,NULL,g_strdup(id_str),g_strdup(path),
pos,panel,cfgpath, type)) {
g_strdup(param), pos,panel,cfgpath, type)) {
g_warning("Couldn't add applet");
return 0;
}
......@@ -869,7 +876,7 @@ panel_add_main_menu(GtkWidget *w, gpointer data)
PanelWidget *panel = data;
gint panel_num = find_panel(panel);
load_applet(MENU_ID,NULL,PANEL_UNKNOWN_APPLET_POSITION,
load_applet(MENU_ID,NULL,NULL,PANEL_UNKNOWN_APPLET_POSITION,
panel_num!=-1?panel_num:0,NULL);
return TRUE;
......@@ -980,6 +987,7 @@ register_toy(GtkWidget *applet,
GtkWidget * assoc,
gpointer data,
char *id_str,
char *path,
char *params,
int pos,
int panel,
......@@ -1017,6 +1025,10 @@ register_toy(GtkWidget *applet,
info.menu = NULL;
info.data = data;
info.id_str = g_strdup(id_str);
if(path)
info.path = g_strdup(path);
else
info.path = NULL;
if(params)
info.params = g_strdup(params);
else
......@@ -1048,6 +1060,8 @@ register_toy(GtkWidget *applet,
gtk_widget_unref(eventbox);
if(info.cfg)
g_free(info.cfg);
if(info.path)
g_free(info.path);
if(info.params)
g_free(info.params);
g_free(info.id_str);
......
......@@ -77,8 +77,8 @@ struct _AppletInfo {
gpointer data;
gchar *id_str; /*used for IOR or string Id*/
gchar *cfg; /*used for passing around the per applet config path*/
gchar *params; /*used for parameters to internal applets and for path
for external applets*/
gchar *path; /*used for path on external applets */
gchar *params; /*used for parameters to applets */
GList *user_menu; /*list of AppletUserMenu items for callbacks*/
gint destroy_callback;
};
......@@ -99,6 +99,7 @@ gint register_toy(GtkWidget *applet,
GtkWidget *assoc,
gpointer data,
char *id_str,
char *path,
char *params,
int pos,
int panel,
......@@ -112,11 +113,12 @@ void apply_global_config(void);
void panel_clean_applet(gint applet_id);
/*stuff for corba*/
int applet_request_id (const char *path, char **cfgpath,
int applet_request_id (const char *path, const char *param, char **cfgpath,
char **globcfgpath, guint32 *winid);
void applet_register (const char * ior, int applet_id);
void applet_request_glob_cfg (char **globcfgpath);
guint32 reserve_applet_spot (const char *id_str, const char *path,
const char *param,
int panel, int pos, char *cfgpath,
AppletType type);
void applet_abort_id(gint applet_id);
......@@ -134,7 +136,8 @@ void applet_remove_from_panel(gint applet_id);
extern char *cookie;
/*this is in main.c*/
void load_applet(char *id, char *params, int pos, int panel, char *cfgpath);
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) \
......
......@@ -4,14 +4,10 @@
#
module GNOME {
interface Panel {
/*for applets who can have multiple widgets*/
short applet_query_about(in string cookie,
in string path,
out string ior);
/* requests an ID on the panel */
short applet_request_id(in string cookie,
in string path,
in string param,
out string cfgpath,
out string globcfgpath,
out unsigned long wid);
......@@ -57,7 +53,7 @@ module GNOME {
/* params is only used if the applet process handeles more
applet types */
void start_new_applet (in string cookie, in string params);
void start_new_applet (in string cookie, in string param);
};
};
......@@ -4,14 +4,10 @@
#
module GNOME {
interface Panel {
/*for applets who can have multiple widgets*/
short applet_query_about(in string cookie,
in string path,
out string ior);
/* requests an ID on the panel */
short applet_request_id(in string cookie,
in string path,
in string param,
out string cfgpath,
out string globcfgpath,
out unsigned long wid);
......@@ -57,7 +53,7 @@ module GNOME {
/* params is only used if the applet process handeles more
applet types */
void start_new_applet (in string cookie, in string params);
void start_new_applet (in string cookie, in string param);
};
};
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