1999-02-17 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gpopup.c (create_actions): Add ejectable * gdesktop.c (do_eject): Add eject command.
Этот коммит содержится в:
родитель
b1a06edfdb
Коммит
2aa1314dba
@ -1,3 +1,9 @@
|
||||
1999-02-17 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* gpopup.c (create_actions): Add ejectable
|
||||
|
||||
* gdesktop.c (do_eject): Add eject command.
|
||||
|
||||
1999-02-16 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* gpopup.c (create_actions): Add support for mountable icons.
|
||||
|
@ -920,6 +920,52 @@ do_mount_umount (char *filename, gboolean is_mount)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static char *eject_known_locations [] = {
|
||||
"/usr/bin/eject",
|
||||
"/sbin/eject",
|
||||
"/bin/eject",
|
||||
NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* Returns whether the device is ejectable
|
||||
*
|
||||
* Right now the test only checks if this system has the eject
|
||||
* command
|
||||
*/
|
||||
gboolean
|
||||
is_ejectable (char *filename)
|
||||
{
|
||||
if (find_command (eject_known_locations))
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ejects the device pointed by filename
|
||||
*/
|
||||
gboolean
|
||||
do_eject (char *filename)
|
||||
{
|
||||
char *eject_command = find_command (eject_known_locations);
|
||||
char *command;
|
||||
FILE *f;
|
||||
|
||||
if (!eject_command)
|
||||
return;
|
||||
command = g_strconcat (eject_command, " ", filename, NULL);
|
||||
open_error_pipe ();
|
||||
f = popen (command, "r");
|
||||
if (f == NULL)
|
||||
close_error_pipe (1, _("While running the eject command"));
|
||||
else
|
||||
close_error_pipe (0, 0);
|
||||
pclose (f);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
try_to_mount (char *filename, file_entry *fe)
|
||||
{
|
||||
|
@ -33,7 +33,8 @@ enum {
|
||||
F_DICON = 1 << 5, /* Applies to desktop icons */
|
||||
F_PANEL = 1 << 6, /* Applies to files from a panel window */
|
||||
F_MOUNTABLE = 1 << 7, /* Only if the device is mountable */
|
||||
F_UNMOUNTABLE = 1 << 8 /* Only if the device is unmountable */
|
||||
F_UNMOUNTABLE = 1 << 8, /* Only if the device is unmountable */
|
||||
F_EJECTABLE = 1 << 9 /* Only if the device is ejectable */
|
||||
};
|
||||
|
||||
struct action {
|
||||
@ -138,6 +139,16 @@ dicon_mount (GtkWidget *widget, DesktopIconInfo *dii)
|
||||
g_free (full);
|
||||
}
|
||||
|
||||
static void
|
||||
dicon_eject (GtkWidget *widget, DesktopIconInfo *dii)
|
||||
{
|
||||
char *full = g_concat_dir_and_file (desktop_directory, dii->filename);
|
||||
|
||||
do_mount_umount (full, FALSE);
|
||||
do_eject (full);
|
||||
g_free (full);
|
||||
}
|
||||
|
||||
static void
|
||||
panel_action_properties (GtkWidget *widget, WPanel *panel)
|
||||
{
|
||||
@ -247,6 +258,7 @@ static struct action file_actions[] = {
|
||||
{ N_("Properties"), F_SINGLE | F_DICON, (GtkSignalFunc) dicon_properties },
|
||||
{ N_("Mount device"), F_SINGLE|F_MOUNTABLE|F_DICON, (GtkSignalFunc) dicon_mount },
|
||||
{ N_("Unmount device"), F_SINGLE|F_UNMOUNTABLE|F_DICON, (GtkSignalFunc) dicon_unmount },
|
||||
{ N_("Eject device"), F_SINGLE|F_EJECTABLE|F_DICON, (GtkSignalFunc) dicon_eject },
|
||||
{ "", F_SINGLE, NULL },
|
||||
{ N_("Open"), F_PANEL | F_ALL, (GtkSignalFunc) panel_action_open },
|
||||
{ N_("Open"), F_DICON | F_ALL, (GtkSignalFunc) dicon_execute },
|
||||
@ -383,6 +395,30 @@ create_actions (GtkWidget *menu, WPanel *panel,
|
||||
}
|
||||
}
|
||||
|
||||
if (action->flags & (F_EJECTABLE)){
|
||||
char *fullname;
|
||||
file_entry *fe;
|
||||
int v;
|
||||
int is_mounted;
|
||||
|
||||
fullname = g_concat_dir_and_file (desktop_directory, dii->filename);
|
||||
fe = file_entry_from_file (fullname);
|
||||
if (fe){
|
||||
v = is_mountable (fullname, fe, &is_mounted);
|
||||
file_entry_free (fe);
|
||||
g_free (fullname);
|
||||
|
||||
if (!v)
|
||||
continue;
|
||||
|
||||
if (!is_ejectable (fullname))
|
||||
continue;
|
||||
} else {
|
||||
g_free (fullname);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Create the appropriate GnomeUIInfo structure for the menu item */
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user