No longer need to confirm when launching applications
This commit is contained in:
parent
c7f2e956ae
commit
5aed562176
|
@ -55,6 +55,7 @@ struct _DesktopIcon
|
||||||
char * exec;
|
char * exec;
|
||||||
char * tryexec;
|
char * tryexec;
|
||||||
|
|
||||||
|
gboolean confirm;
|
||||||
gboolean immutable; /* cannot be deleted */
|
gboolean immutable; /* cannot be deleted */
|
||||||
gboolean selected;
|
gboolean selected;
|
||||||
gboolean updated; /* XXX for desktop refresh */
|
gboolean updated; /* XXX for desktop refresh */
|
||||||
|
@ -152,9 +153,7 @@ DesktopIcon * desktopicon_new(Desktop * desktop, char const * name,
|
||||||
name++;
|
name++;
|
||||||
}
|
}
|
||||||
if((desktopicon = _desktopicon_new_do(desktop, image, name)) == NULL)
|
if((desktopicon = _desktopicon_new_do(desktop, image, name)) == NULL)
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
desktopicon->isdir = isdir;
|
desktopicon->isdir = isdir;
|
||||||
desktopicon_set_executable(desktopicon, isexec);
|
desktopicon_set_executable(desktopicon, isexec);
|
||||||
desktopicon->mimetype = mimetype;
|
desktopicon->mimetype = mimetype;
|
||||||
|
@ -231,6 +230,7 @@ DesktopIcon * desktopicon_new_application(Desktop * desktop, char const * path)
|
||||||
}
|
}
|
||||||
desktopicon->exec = exec;
|
desktopicon->exec = exec;
|
||||||
desktopicon->tryexec = tryexec;
|
desktopicon->tryexec = tryexec;
|
||||||
|
desktopicon_set_confirm(desktopicon, FALSE);
|
||||||
desktopicon_set_executable(desktopicon, TRUE);
|
desktopicon_set_executable(desktopicon, TRUE);
|
||||||
desktopicon_set_immutable(desktopicon, TRUE);
|
desktopicon_set_immutable(desktopicon, TRUE);
|
||||||
return desktopicon;
|
return desktopicon;
|
||||||
|
@ -285,6 +285,13 @@ gboolean desktopicon_get_updated(DesktopIcon * desktopicon)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* desktopicon_set_confirm */
|
||||||
|
void desktopicon_set_confirm(DesktopIcon * desktopicon, gboolean confirm)
|
||||||
|
{
|
||||||
|
desktopicon->confirm = confirm;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* desktopicon_set_executable */
|
/* desktopicon_set_executable */
|
||||||
void desktopicon_set_executable(DesktopIcon * desktopicon, gboolean executable)
|
void desktopicon_set_executable(DesktopIcon * desktopicon, gboolean executable)
|
||||||
{
|
{
|
||||||
|
@ -375,6 +382,7 @@ static DesktopIcon * _desktopicon_new_do(Desktop * desktop, GdkPixbuf * image,
|
||||||
return NULL;
|
return NULL;
|
||||||
memset(desktopicon, 0, sizeof(*desktopicon));
|
memset(desktopicon, 0, sizeof(*desktopicon));
|
||||||
desktopicon->desktop = desktop;
|
desktopicon->desktop = desktop;
|
||||||
|
desktopicon->confirm = TRUE;
|
||||||
desktopicon->updated = TRUE;
|
desktopicon->updated = TRUE;
|
||||||
/* window */
|
/* window */
|
||||||
desktopicon->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
desktopicon->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
|
@ -679,12 +687,41 @@ static void _on_icon_edit(gpointer data)
|
||||||
mime_action(mime, "edit", desktopicon->path);
|
mime_action(mime, "edit", desktopicon->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean _run_confirm(DesktopIcon * desktopicon);
|
||||||
static void _on_icon_run(gpointer data)
|
static void _on_icon_run(gpointer data)
|
||||||
{
|
{
|
||||||
DesktopIcon * desktopicon = data;
|
DesktopIcon * desktopicon = data;
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
if(desktopicon->confirm != FALSE && _run_confirm(desktopicon) != TRUE)
|
||||||
|
return;
|
||||||
|
if((pid = fork()) == -1)
|
||||||
|
desktop_error(desktopicon->desktop, "fork", 0);
|
||||||
|
else if(pid != 0)
|
||||||
|
return;
|
||||||
|
if(desktopicon->tryexec != NULL) /* XXX ugly */
|
||||||
|
{
|
||||||
|
execlp(desktopicon->tryexec, desktopicon->tryexec, NULL);
|
||||||
|
desktop_error(NULL, desktopicon->tryexec, 0);
|
||||||
|
}
|
||||||
|
if(desktopicon->exec != NULL)
|
||||||
|
{
|
||||||
|
/* FIXME it's actually a format string */
|
||||||
|
execlp(desktopicon->exec, desktopicon->exec, NULL);
|
||||||
|
desktop_error(NULL, desktopicon->exec, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
execl(desktopicon->path, desktopicon->path, NULL);
|
||||||
|
desktop_error(NULL, desktopicon->path, 0);
|
||||||
|
}
|
||||||
|
exit(127);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean _run_confirm(DesktopIcon * desktopicon)
|
||||||
|
{
|
||||||
GtkWidget * dialog;
|
GtkWidget * dialog;
|
||||||
int res;
|
int res;
|
||||||
pid_t pid;
|
|
||||||
|
|
||||||
dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
|
dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
|
||||||
GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, "%s",
|
GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, "%s",
|
||||||
|
@ -697,31 +734,7 @@ static void _on_icon_run(gpointer data)
|
||||||
gtk_window_set_title(GTK_WINDOW(dialog), _("Warning"));
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Warning"));
|
||||||
res = gtk_dialog_run(GTK_DIALOG(dialog));
|
res = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||||
gtk_widget_destroy(dialog);
|
gtk_widget_destroy(dialog);
|
||||||
if(res != GTK_RESPONSE_YES)
|
return (res == GTK_RESPONSE_YES) ? TRUE : FALSE;
|
||||||
return;
|
|
||||||
if((pid = fork()) == -1)
|
|
||||||
desktop_error(desktopicon->desktop, "fork", 0);
|
|
||||||
else if(pid == 0)
|
|
||||||
{
|
|
||||||
if(desktopicon->tryexec != NULL) /* XXX ugly */
|
|
||||||
{
|
|
||||||
execlp(desktopicon->tryexec, desktopicon->tryexec,
|
|
||||||
NULL);
|
|
||||||
desktop_error(NULL, desktopicon->tryexec, 0);
|
|
||||||
}
|
|
||||||
if(desktopicon->exec != NULL)
|
|
||||||
{
|
|
||||||
/* FIXME it's actually a format string */
|
|
||||||
execlp(desktopicon->exec, desktopicon->exec, NULL);
|
|
||||||
desktop_error(NULL, desktopicon->exec, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
execl(desktopicon->path, desktopicon->path, NULL);
|
|
||||||
desktop_error(NULL, desktopicon->path, 0);
|
|
||||||
}
|
|
||||||
exit(127);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _on_icon_open_with(gpointer data)
|
static void _on_icon_open_with(gpointer data)
|
||||||
|
|
|
@ -54,6 +54,7 @@ char const * desktopicon_get_name(DesktopIcon * desktopicon);
|
||||||
char const * desktopicon_get_path(DesktopIcon * desktopicon);
|
char const * desktopicon_get_path(DesktopIcon * desktopicon);
|
||||||
gboolean desktopicon_get_selected(DesktopIcon * desktopicon);
|
gboolean desktopicon_get_selected(DesktopIcon * desktopicon);
|
||||||
gboolean desktopicon_get_updated(DesktopIcon * desktopicon);
|
gboolean desktopicon_get_updated(DesktopIcon * desktopicon);
|
||||||
|
void desktopicon_set_confirm(DesktopIcon * desktopicon, gboolean confirm);
|
||||||
void desktopicon_set_executable(DesktopIcon * desktopicon, gboolean executable);
|
void desktopicon_set_executable(DesktopIcon * desktopicon, gboolean executable);
|
||||||
void desktopicon_set_first(DesktopIcon * desktopicon, gboolean first);
|
void desktopicon_set_first(DesktopIcon * desktopicon, gboolean first);
|
||||||
void desktopicon_set_icon(DesktopIcon * desktopicon, GdkPixbuf * icon);
|
void desktopicon_set_icon(DesktopIcon * desktopicon, GdkPixbuf * icon);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user