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

always look for an empty spot first unless insert_at_pos is given. But

Fri Jan 21 22:38:07 2000  George Lebl <jirka@5z.com>

	* panel-widget.c: always look for an empty spot first unless
	  insert_at_pos is given.  But then if that fails insert at
	  pos.

	* applet.[ch],menu.[ch],extern.[ch],drawer.[ch],logout.[ch],
	  swallow.[ch],status.[ch],session.c,panel.c: take an extra
	  argument to register_toy (exactpos) which specifies if to
	  look for an open spot or to insert exactly.  All the
	  load_*_applet have to take this parameter

	* panel.c: cleanup the drop stuff.  use extract_uris and copy
	  the extract_file func from HEAD gnome-libs and use that to get
	  local filenames.
parent dac58a13
Fri Jan 21 22:38:07 2000 George Lebl <jirka@5z.com>
* panel-widget.c: always look for an empty spot first unless
insert_at_pos is given. But then if that fails insert at
pos.
* applet.[ch],menu.[ch],extern.[ch],drawer.[ch],logout.[ch],
swallow.[ch],status.[ch],session.c,panel.c: take an extra
argument to register_toy (exactpos) which specifies if to
look for an open spot or to insert exactly. All the
load_*_applet have to take this parameter
* panel.c: cleanup the drop stuff. use extract_uris and copy
the extract_file func from HEAD gnome-libs and use that to get
local filenames.
Wed Jan 19 21:30:34 2000 George Lebl <jirka@5z.com>
* extern.c,applet.c: cosmetic code changes, and add _() around
......
Fri Jan 21 22:38:07 2000 George Lebl <jirka@5z.com>
* panel-widget.c: always look for an empty spot first unless
insert_at_pos is given. But then if that fails insert at
pos.
* applet.[ch],menu.[ch],extern.[ch],drawer.[ch],logout.[ch],
swallow.[ch],status.[ch],session.c,panel.c: take an extra
argument to register_toy (exactpos) which specifies if to
look for an open spot or to insert exactly. All the
load_*_applet have to take this parameter
* panel.c: cleanup the drop stuff. use extract_uris and copy
the extract_file func from HEAD gnome-libs and use that to get
local filenames.
Wed Jan 19 21:30:34 2000 George Lebl <jirka@5z.com>
* extern.c,applet.c: cosmetic code changes, and add _() around
......
......@@ -515,14 +515,17 @@ applet_destroy(GtkWidget *w, AppletInfo *info)
g_list_free(info->user_menu);
}
int
gboolean
register_toy(GtkWidget *applet,
gpointer data,
PanelWidget *panel,
int pos,
gboolean exactpos,
AppletType type)
{
AppletInfo *info;
int newpos;
gboolean insert_at_pos;
g_return_val_if_fail(applet != NULL, FALSE);
g_return_val_if_fail(panel != NULL, FALSE);
......@@ -574,11 +577,23 @@ register_toy(GtkWidget *applet,
applets_to_sync = TRUE;
/*add at the beginning if pos == -1*/
if(panel_widget_add_full(panel, applet, pos>=0?pos:0, TRUE,
pos>=0?FALSE:TRUE)==-1) {
if(pos>=0) {
newpos = pos;
insert_at_pos = FALSE;
} else {
newpos = 0;
insert_at_pos = TRUE;
}
/* if exact pos is on then insert at that precise location */
if(exactpos)
insert_at_pos = TRUE;
if(panel_widget_add_full(panel, applet, newpos, TRUE,
insert_at_pos)==-1) {
GSList *list;
for(list = panels; list != NULL; list = g_slist_next(list))
if(panel_widget_add_full(panel, applet, 0,TRUE,FALSE)!=-1)
if(panel_widget_add_full(panel, applet, 0,
TRUE, TRUE)!=-1)
break;
if(!list) {
/*can't put it anywhere, clean up*/
......
......@@ -53,11 +53,12 @@ struct _AppletInfo {
gpointer data; /*the per applet structure, if it exists*/
};
int register_toy(GtkWidget *applet,
gpointer data,
PanelWidget *panel,
int pos,
AppletType type);
gboolean register_toy(GtkWidget *applet,
gpointer data,
PanelWidget *panel,
int pos,
gboolean exactpos,
AppletType type);
void panel_clean_applet(AppletInfo *info);
......
......@@ -365,7 +365,7 @@ drawer_size_alloc(BasePWidget *basep, GtkAllocation *alloc, gpointer data)
void
load_drawer_applet(int mypanel, char *pixmap, char *tooltip,
PanelWidget *panel, int pos)
PanelWidget *panel, int pos, gboolean exactpos)
{
Drawer *drawer;
PanelOrientType orient = get_applet_orient(panel);
......@@ -381,8 +381,8 @@ load_drawer_applet(int mypanel, char *pixmap, char *tooltip,
g_return_if_fail(li != NULL);
dr_pd = li->data;
drawer=create_drawer_applet(dr_pd->panel, tooltip,
pixmap, orient);
drawer = create_drawer_applet(dr_pd->panel, tooltip,
pixmap, orient);
drawer_widget_change_orient(DRAWER_WIDGET(dr_pd->panel),
orient);
......@@ -391,7 +391,17 @@ load_drawer_applet(int mypanel, char *pixmap, char *tooltip,
if(!drawer)
return;
register_toy(drawer->button,drawer, panel, pos, APPLET_DRAWER);
{
GtkWidget *dw = drawer->drawer;
if(!register_toy(drawer->button,drawer,
panel, pos, exactpos, APPLET_DRAWER)) {
/* by this time drawer has been freed as register_toy
has destroyed drawer->button */
gtk_widget_destroy(dw);
return;
}
}
gtk_signal_connect_after(GTK_OBJECT(drawer->drawer),
"size_allocate",
......
......@@ -17,7 +17,7 @@ typedef struct {
} Drawer;
void load_drawer_applet(int mypanel, char *pixmap, char *tooltip,
PanelWidget *panel, int pos);
PanelWidget *panel, int pos, gboolean exactpos);
void set_drawer_applet_orient(Drawer *drawer, PanelOrientType orient);
......
......@@ -445,14 +445,14 @@ reserve_applet_spot (Extern *ext, PanelWidget *panel, int pos,
g_return_val_if_fail(socket!=NULL,0);
gtk_container_add(GTK_CONTAINER(ext->ebox),socket);
gtk_container_add(GTK_CONTAINER(ext->ebox), socket);
gtk_widget_show_all (ext->ebox);
gtk_widget_show_all(ext->ebox);
/*we save the obj in the id field of the appletinfo and the
path in the path field */
ext->info = NULL;
if(!register_toy(ext->ebox,ext,panel,pos,type)) {
if(!register_toy(ext->ebox, ext, panel, pos, ext->exactpos, type)) {
/* the ebox is destroyed in register_toy */
ext->ebox = NULL;
g_warning(_("Couldn't add applet"));
......@@ -471,7 +471,8 @@ reserve_applet_spot (Extern *ext, PanelWidget *panel, int pos,
}
void
load_extern_applet(char *goad_id, char *cfgpath, PanelWidget *panel, int pos, int queue)
load_extern_applet(char *goad_id, char *cfgpath, PanelWidget *panel,
int pos, gboolean exactpos, gboolean queue)
{
Extern *ext;
POA_GNOME_PanelSpot *panelspot_servant;
......@@ -485,6 +486,7 @@ load_extern_applet(char *goad_id, char *cfgpath, PanelWidget *panel, int pos, in
ext = g_new0(Extern,1);
ext->started = FALSE;
ext->exactpos = exactpos;
ext->send_position = FALSE;
ext->send_draw = FALSE;
ext->orient = -1;
......@@ -610,6 +612,7 @@ s_panel_add_applet_full(POA_GNOME_Panel *servant,
have already reserved a spot for it*/
ext = g_new0(Extern,1);
ext->started = FALSE;
ext->exactpos = FALSE;
ext->send_position = FALSE;
ext->send_draw = FALSE;
ext->orient = -1;
......
......@@ -19,7 +19,8 @@ struct _Extern {
char *goad_id;
char *cfg;
GtkWidget *ebox;
int started;
gboolean started;
gboolean exactpos;
gboolean send_position;
gboolean send_draw;
PanelOrientation orient; /* current orient, if it doesn't change,
......@@ -32,7 +33,8 @@ struct _Extern {
};
void extern_clean(Extern *ext);
void load_extern_applet(char *goad_id, char *cfgpath, PanelWidget *panel, int pos, int queue);
void load_extern_applet(char *goad_id, char *cfgpath, PanelWidget *panel,
int pos, gboolean exactpos, gboolean queue);
void load_queued_externs(void);
void panel_corba_clean_up(void);
......
......@@ -67,9 +67,9 @@ launch (Launcher *launcher, int argc, char *argv[])
goad_id = get_applet_goad_id_from_dentry(item);
if(goad_id) {
load_extern_applet(goad_id,NULL,
load_extern_applet(goad_id, NULL,
panels->data,
0,FALSE);
0, FALSE, FALSE);
} else {
g_warning(_("Can't get goad_id from desktop entry!"));
}
......@@ -437,31 +437,34 @@ launcher_properties(Launcher *launcher)
void
load_launcher_applet_full (char *params, GnomeDesktopEntry *dentry,
PanelWidget *panel, int pos)
PanelWidget *panel, int pos, gboolean exactpos)
{
Launcher *launcher;
launcher = create_launcher(params,dentry);
if(launcher) {
register_toy(launcher->button,launcher, panel, pos,
APPLET_LAUNCHER);
if(!launcher)
return;
gtk_tooltips_set_tip (panel_tooltips,
launcher->button,
launcher->dentry->comment,NULL);
if(!register_toy(launcher->button, launcher, panel, pos, exactpos,
APPLET_LAUNCHER))
return;
applet_add_callback(applets_last->data,"properties",
GNOME_STOCK_MENU_PROP,
_("Properties..."));
}
gtk_tooltips_set_tip (panel_tooltips,
launcher->button,
launcher->dentry->comment,NULL);
applet_add_callback(applets_last->data,"properties",
GNOME_STOCK_MENU_PROP,
_("Properties..."));
}
static void
really_add_launcher(GtkWidget *d,int button, gpointer data)
really_add_launcher(GtkWidget *d, int button, gpointer data)
{
GnomeDEntryEdit *dedit = GNOME_DENTRY_EDIT(data);
int pos = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(d),"pos"));
gboolean exactpos = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(d),"exactpos"));
PanelWidget *panel = gtk_object_get_data(GTK_OBJECT(d),"panel");
GnomeDesktopEntry *dentry;
......@@ -472,14 +475,14 @@ really_add_launcher(GtkWidget *d,int button, gpointer data)
g_free(dentry->name);
dentry->name=g_strdup("???");
}
load_launcher_applet_full (NULL, dentry, panel, pos);
load_launcher_applet_full (NULL, dentry, panel, pos, exactpos);
panel_config_sync();
}
gtk_widget_destroy(d);
}
void
ask_about_launcher(char *file, PanelWidget *panel, int pos)
ask_about_launcher(char *file, PanelWidget *panel, int pos, gboolean exactpos)
{
GtkWidget *d;
GtkWidget *notebook;
......@@ -512,6 +515,8 @@ ask_about_launcher(char *file, PanelWidget *panel, int pos)
gtk_object_set_data(GTK_OBJECT(d),"pos", GINT_TO_POINTER(pos));
gtk_object_set_data(GTK_OBJECT(d),"exactpos",
GINT_TO_POINTER(exactpos));
gtk_object_set_data(GTK_OBJECT(d),"panel",panel);
gtk_signal_connect(GTK_OBJECT(d),"clicked",
......@@ -528,7 +533,8 @@ ask_about_launcher(char *file, PanelWidget *panel, int pos)
void
load_launcher_applet_from_info(char *name, char *comment,
char **exec, int execn, char *icon,
PanelWidget *panel, int pos)
PanelWidget *panel, int pos,
gboolean exactpos)
{
GnomeDesktopEntry *dentry = g_new0(GnomeDesktopEntry,1);
dentry->name = g_strdup(name);
......@@ -542,14 +548,15 @@ load_launcher_applet_from_info(char *name, char *comment,
dentry->type = g_strdup("Application");
load_launcher_applet_full (NULL,dentry,panel, pos);
load_launcher_applet_full (NULL, dentry, panel, pos, exactpos);
panel_config_sync();
}
void
load_launcher_applet_from_info_url(char *name, char *comment,
char *url, char *icon,
PanelWidget *panel, int pos)
PanelWidget *panel, int pos,
gboolean exactpos)
{
char *exec[] = { NULL, NULL };
GnomeDesktopEntry *dentry = g_new0(GnomeDesktopEntry,1);
......@@ -564,12 +571,13 @@ load_launcher_applet_from_info_url(char *name, char *comment,
dentry->icon = g_strdup(icon);
dentry->type = g_strdup("URL");
load_launcher_applet_full (NULL,dentry,panel, pos);
load_launcher_applet_full(NULL, dentry, panel, pos, exactpos);
panel_config_sync();
}
void
load_launcher_applet(char *params, PanelWidget *panel, int pos)
load_launcher_applet(char *params, PanelWidget *panel, int pos,
gboolean exactpos)
{
load_launcher_applet_full (params,NULL,panel, pos);
load_launcher_applet_full(params, NULL, panel, pos, exactpos);
}
......@@ -22,17 +22,21 @@ typedef struct {
} Launcher;
void load_launcher_applet_full(char *params, GnomeDesktopEntry *dentry,
PanelWidget *panel, int pos);
void load_launcher_applet(char *params, PanelWidget *panel, int pos);
PanelWidget *panel, int pos, gboolean exactpos);
void load_launcher_applet(char *params, PanelWidget *panel, int pos,
gboolean exactpos);
void load_launcher_applet_from_info(char *name, char *comment,
char **exec, int execn, char *icon,
PanelWidget *panel, int pos);
PanelWidget *panel, int pos,
gboolean exactpos);
void load_launcher_applet_from_info_url(char *name, char *comment,
char *url, char *icon,
PanelWidget *panel, int pos);
PanelWidget *panel, int pos,
gboolean exactpos);
void launcher_properties(Launcher *launcher);
void ask_about_launcher(char *file, PanelWidget *panel, int pos);
void ask_about_launcher(char *file, PanelWidget *panel, int pos,
gboolean exactpos);
END_GNOME_DECLS
......
......@@ -53,14 +53,15 @@ create_logout_widget(void)
}
void
load_logout_applet(PanelWidget *panel, int pos)
load_logout_applet(PanelWidget *panel, int pos, gboolean exactpos)
{
GtkWidget *logout;
logout = create_logout_widget();
if(!logout)
return;
if(logout)
register_toy(logout, NULL, panel, pos, APPLET_LOGOUT);
register_toy(logout, NULL, panel, pos, exactpos, APPLET_LOGOUT);
}
static GtkWidget *
......@@ -86,13 +87,14 @@ create_lock_widget(void)
}
void
load_lock_applet(PanelWidget *panel, int pos)
load_lock_applet(PanelWidget *panel, int pos, gboolean exactpos)
{
GtkWidget *lock;
lock = create_lock_widget();
if(lock)
register_toy(lock, NULL, panel, pos, APPLET_LOCK);
if(!lock)
return;
register_toy(lock, NULL, panel, pos, exactpos, APPLET_LOCK);
}
......@@ -12,8 +12,8 @@
BEGIN_GNOME_DECLS
void load_logout_applet(PanelWidget *panel, int pos);
void load_lock_applet(PanelWidget *panel, int pos);
void load_logout_applet(PanelWidget *panel, int pos, gboolean exactpos);
void load_lock_applet(PanelWidget *panel, int pos, gboolean exactpos);
END_GNOME_DECLS
......
......@@ -354,7 +354,7 @@ remove_menuitem (GtkWidget *widget, char *item_loc)
static void
add_app_to_panel (GtkWidget *widget, char *item_loc)
{
load_launcher_applet(item_loc, current_panel,0);
load_launcher_applet(item_loc, current_panel, 0, FALSE);
}
......@@ -386,8 +386,7 @@ add_drawers_from_dir(char *dirname, char *name, int pos, PanelWidget *panel)
subdir_name = name;
pixmap_name = item_info?item_info->icon:NULL;
load_drawer_applet(-1,pixmap_name,subdir_name,
panel,pos);
load_drawer_applet(-1, pixmap_name, subdir_name, panel, pos, FALSE);
g_return_if_fail(applets_last!=NULL);
info = applets_last->data;
......@@ -425,7 +424,8 @@ add_drawers_from_dir(char *dirname, char *name, int pos, PanelWidget *panel)
load_launcher_applet_full (filename,
dentry,
newpanel,
INT_MAX/2);
INT_MAX/2,
FALSE);
}
}
g_free(filename);
......@@ -464,9 +464,9 @@ add_menu_to_panel (GtkWidget *widget, gpointer data)
flags |= MAIN_MENU_DEBIAN_SUB;
if(mf)
load_menu_applet(mf->menudir,flags, current_panel, 0);
load_menu_applet(mf->menudir, flags, current_panel, 0, FALSE);
else
load_menu_applet(NULL,flags, current_panel, 0);
load_menu_applet(NULL, flags, current_panel, 0, FALSE);
}
static PanelWidget *
......@@ -1167,24 +1167,26 @@ setup_applet_drag (GtkWidget *menuitem, char *goad_id)
static void
add_drawer_to_panel (GtkWidget *widget, gpointer data)
{
load_drawer_applet(-1,NULL,NULL, get_panel_from_menu_data(widget->parent), 0);
load_drawer_applet(-1, NULL, NULL,
get_panel_from_menu_data(widget->parent), 0, FALSE);
}
static void
add_logout_to_panel (GtkWidget *widget, gpointer data)
{
load_logout_applet(get_panel_from_menu_data(widget->parent), 0);
load_logout_applet(get_panel_from_menu_data(widget->parent), 0, FALSE);
}
static void
add_lock_to_panel (GtkWidget *widget, gpointer data)
{
load_lock_applet(get_panel_from_menu_data(widget->parent), 0);
load_lock_applet(get_panel_from_menu_data(widget->parent), 0, FALSE);
}
static void
try_add_status_to_panel (GtkWidget *widget, gpointer data)
{
if(!load_status_applet(get_panel_from_menu_data(widget->parent), 0)) {
if(!load_status_applet(get_panel_from_menu_data(widget->parent),
0, FALSE)) {
GtkWidget *mbox;
mbox = gnome_message_box_new(_("You already have a status "
"dock on the panel. You can "
......@@ -1217,9 +1219,9 @@ add_applet (GtkWidget *w, char *item_loc)
gnome_error_dialog(_("Can't get goad_id from desktop entry!"));
return;
}
load_extern_applet(goad_id,NULL,
load_extern_applet(goad_id, NULL,
get_panel_from_menu_data(w->parent),
0,FALSE);
0, FALSE, FALSE);
g_free(goad_id);
}
......@@ -2371,13 +2373,13 @@ current_panel_config(GtkWidget *w, gpointer data)
static void
ask_about_launcher_cb(GtkWidget *w, gpointer data)
{
ask_about_launcher(NULL,get_panel_from_menu_data(w->parent),0);
ask_about_launcher(NULL, get_panel_from_menu_data(w->parent), 0, FALSE);
}
static void
ask_about_swallowing_cb(GtkWidget *w, gpointer data)
{
ask_about_swallowing(get_panel_from_menu_data(w->parent),0);
ask_about_swallowing(get_panel_from_menu_data(w->parent), 0, FALSE);
}
static void
......@@ -3701,26 +3703,27 @@ set_menu_applet_orient(Menu *menu, PanelOrientType orient)
void
load_menu_applet(char *params, int main_menu_flags,
PanelWidget *panel, int pos)
PanelWidget *panel, int pos, gboolean exactpos)
{
Menu *menu;
menu = create_menu_applet(params, ORIENT_UP,main_menu_flags);
menu = create_menu_applet(params, ORIENT_UP, main_menu_flags);
if(menu) {
char *tmp;
register_toy(menu->button,menu,
panel,pos,APPLET_MENU);
if(!register_toy(menu->button, menu,
panel, pos, exactpos, APPLET_MENU))
return;
menu->info = applets_last->data;
applet_add_callback(menu->info,"properties",
applet_add_callback(menu->info, "properties",
GNOME_STOCK_MENU_PROP,
_("Properties..."));
if(params && strcmp(params,".")==0 &&
if(params && strcmp(params, ".")==0 &&
(tmp = gnome_is_program_in_path("gmenu"))) {
g_free(tmp);
applet_add_callback(menu->info,"edit_menus",
applet_add_callback(menu->info, "edit_menus",
NULL,
_("Edit menus..."));
}
......
......@@ -43,7 +43,7 @@ struct _Menu {
};
void load_menu_applet(char *params, int main_menu_flags,
PanelWidget *panel, int pos);
PanelWidget *panel, int pos, gboolean exactpos);
void add_menu_widget (Menu *menu, GSList *menudirl, int main_menu,
int fake_subs);
......
......@@ -26,7 +26,7 @@ GSList *panels=NULL; /*other panels we might want to move the applet to*/
/*there can universally be only one applet being dragged since we assume
we only have one mouse :) */
int panel_applet_in_drag = FALSE;
gboolean panel_applet_in_drag = FALSE;
static void panel_widget_class_init (PanelWidgetClass *klass);
static void panel_widget_init (PanelWidget *panel_widget);
......@@ -57,7 +57,7 @@ int pw_drawer_step = 20;
int pw_auto_step = 10;
int pw_minimized_size = 6;
int pw_minimize_delay = 300;
int pw_disable_animations = FALSE;
gboolean pw_disable_animations = FALSE;
PanelMovementType pw_movement_type = PANEL_SWITCH_MOVE;
int pw_applet_padding = 3;
......@@ -2425,7 +2425,7 @@ panel_widget_add_forbidden(PanelWidget *panel)
}
int
panel_widget_add_full (PanelWidget *panel, GtkWidget *applet, int pos, int bind_lower_events, int insert_at_pos)
panel_widget_add_full (PanelWidget *panel, GtkWidget *applet, int pos, gboolean bind_lower_events, gboolean insert_at_pos)
{
AppletData *ad = NULL;
......@@ -2444,15 +2444,22 @@ panel_widget_add_full (PanelWidget *panel, GtkWidget *applet, int pos, int bind_
pos = pw_applet_padding;
if(!insert_at_pos) {
if(pw_movement_type != PANEL_FREE_MOVE ||
panel->packed) {
if(panel->packed) {
if(get_applet_list_pos(panel,pos))
/*this is a slight hack so that this applet
is inserted AFTER an applet with this pos
number*/
pos++;
} else
pos = panel_widget_find_empty_pos(panel,pos);
} else {
int newpos = panel_widget_find_empty_pos(panel,pos);
if(newpos>=0)
pos = newpos;
else if(get_applet_list_pos(panel,pos))
/*this is a slight hack so that this applet
is inserted AFTER an applet with this pos
number*/
pos++;
}
}
if(pos==-1) return -1;
......@@ -2717,7 +2724,7 @@ panel_widget_change_global(int explicit_step,
int minimized_size,
int minimize_delay,
PanelMovementType move_type,
int disable_animations,
gboolean disable_animations,
int applet_padding)
{
if(explicit_step>0)
......
......@@ -70,7 +70,7 @@ struct _PanelWidget
gboolean rotate_pixmap_bg; /*rotate pixmap on vertical
panels */
int packed;
gboolean packed;
AppletData *currently_dragged_applet;
......@@ -122,7 +122,7 @@ struct _PanelWidgetClass
};
guint panel_widget_get_type (void);
GtkWidget * panel_widget_new (int packed,
GtkWidget * panel_widget_new (gboolean packed,
PanelOrientation orient,
int sz,
PanelBackType back_type,
......@@ -136,8 +136,8 @@ GtkWidget * panel_widget_new (int packed,
int panel_widget_add_full (PanelWidget *panel,
GtkWidget *applet,
int pos,
int bind_lower_events,
int insert_at_pos);
gboolean bind_lower_events,
gboolean insert_at_pos);
#define panel_widget_add(panel,applet,pos) (panel_widget_add_full(panel,applet,pos,TRUE,FALSE))
/*needs to be called for drawers after add*/
......@@ -195,7 +195,7 @@ void panel_widget_change_global (int explicit_step,
int minimized_size,
int minimize_delay,
PanelMovementType move_type,
int disable_animations,
gboolean disable_animations,
int applet_padding);
void panel_widget_set_back_pixmap (PanelWidget *panel,
......@@ -237,7 +237,7 @@ void panel_widget_get_applet_rgb_bg(PanelWidget *panel,
/*extern GSList *panels;*/
extern int panel_applet_in_drag;
extern gboolean panel_applet_in_drag;
END_GNOME_DECLS
......
......@@ -770,6 +770,167 @@ panel_sub_event_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
return FALSE;
}
static gchar *
extract_filename (const gchar* uri)
{
/* file uri with a hostname */
if (strncmp(uri, "file://", strlen("file://"))==0) {
char *hostname = g_strdup(&uri[strlen("file://")]);
char *p = strchr(hostname,'/');
char *path;
char localhostname[1024];
/* if we can't find the '/' this uri is bad */
if(!p) {
g_free(hostname);
return NULL;
}
/* if no hostname */
if(p==hostname)
return hostname;
path = g_strdup(p);
*p = '\0';
/* if really local */
if(g_strcasecmp(hostname,"localhost")==0) {
g_free(hostname);
return path;
}
/* ok get the hostname */
if(gethostname(localhostname,
sizeof(localhostname)) < 0) {
strcpy(localhostname,"");
}
/* if really local */
if(localhostname[0] &&
g_strcasecmp(hostname,localhostname)==0) {
g_free(hostname);
return path;
}
g_free(hostname);
g_free(path);
return NULL;
/* if the file doesn't have the //, we take it containing
a local path */
} else if (strncmp(uri, "file:", strlen("file:"))==0) {
const char *path = &uri[strlen("file:")];
/* if empty bad */
if(!*path) return NULL;
return g_strdup(path);
}
return NULL;
}
static void
drop_url(PanelWidget *panel, int pos, char *url)
{
char *p = g_strdup_printf("Open URL: %s",url);
load_launcher_applet_from_info_url(url, p, url, "netscape.png",