1999-03-11 Miguel de Icaza <miguel@nuclecu.unam.mx>

* gdesktop.c (do_mount_umount): Use g_readlink here.

	* gpopup2.c (handle_eject): Small tuning.  And use g_readlink :-).

	* gmount.c (mount_point_to_device): New function.  Mapes a mount
	point to its device.  Required since we are now using the mount
	point (as this is not ambiguous) as the key for the devices and
	the eject command needs the device name, not the mount point.

	* gdesktop.c (desktop_icon_info_open): First try to see if
	filename is mountable.  Then do the directory tests and the file
	launching tests.  Fixes mount-by-double click.

	* gmount.c (setup_devices): Use new tigert icon.
This commit is contained in:
Miguel de Icaza 1999-03-11 07:53:26 +00:00
parent 9be5d13eb3
commit cbebd9cd27
8 changed files with 91 additions and 30 deletions

View File

@ -1,3 +1,20 @@
1999-03-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gmount.c (setup_devices): Use new tigert icon.
* gdesktop.c (do_mount_umount): Use g_readlink here.
* gpopup2.c (handle_eject): Small tuning. And use g_readlink :-).
* gmount.c (mount_point_to_device): New function. Mapes a mount
point to its device. Required since we are now using the mount
point (as this is not ambiguous) as the key for the devices and
the eject command needs the device name, not the mount point.
* gdesktop.c (desktop_icon_info_open): First try to see if
filename is mountable. Then do the directory tests and the file
launching tests. Fixes mount-by-double click.
1999-03-10 Federico Mena Quintero <federico@nuclecu.unam.mx>
* glayout.c (save_panel_types): Do not save the setup of a desktop

View File

@ -103,6 +103,7 @@ ICONS = \
i-executable.png \
i-fifo.png \
i-floppy.png \
i-nfs.png \
i-printer.png \
i-regular.png \
i-sock.png \

View File

@ -982,7 +982,7 @@ do_mount_umount (char *filename, gboolean is_mount)
static char *mount_command;
static char *umount_command;
char *op;
char buffer [128];
char *buffer;
int count;
if (is_mount){
@ -995,10 +995,9 @@ do_mount_umount (char *filename, gboolean is_mount)
op = umount_command;
}
count = readlink (filename, buffer, sizeof (buffer));
if (count == -1)
buffer = g_readlink (filename);
if (buffer == NULL)
return FALSE;
buffer [count] = 0;
if (op){
char *command;
@ -1013,8 +1012,10 @@ do_mount_umount (char *filename, gboolean is_mount)
close_error_pipe (0, 0);
pclose (f);
g_free (buffer);
return TRUE;
}
g_free (buffer);
return FALSE;
}
@ -1061,13 +1062,17 @@ gboolean
do_eject (char *filename)
{
char *eject_command = find_command (eject_known_locations);
char *command;
char *command, *device;
FILE *f;
if (!eject_command)
return FALSE;
command = g_strconcat (eject_command, " ", filename, NULL);
device = mount_point_to_device (filename);
if (!device)
return;
command = g_strconcat (eject_command, " ", device, NULL);
open_error_pipe ();
f = popen (command, "r");
if (f == NULL)
@ -1102,6 +1107,9 @@ desktop_icon_info_open (DesktopIconInfo *dii)
{
char *filename;
file_entry *fe;
int is_mounted;
char *point;
int launch = FALSE;
if (dii->url){
gnome_url_show (dii->url);
@ -1115,24 +1123,20 @@ desktop_icon_info_open (DesktopIconInfo *dii)
return;
}
if (S_ISDIR (fe->buf.st_mode) || link_isdir (fe))
new_panel_at (filename);
else {
int is_mounted;
char *point;
int launch = FALSE;
if (is_mountable (filename, fe, &is_mounted, &point)){
if (!is_mounted){
if (try_to_mount (filename, fe))
launch = TRUE;
} else
if (is_mountable (filename, fe, &is_mounted, &point)){
if (!is_mounted){
if (try_to_mount (filename, fe))
launch = TRUE;
if (launch)
new_panel_at (point);
g_free (point);
} else {
} else
launch = TRUE;
if (launch)
new_panel_at (point);
g_free (point);
} else {
if (S_ISDIR (fe->buf.st_mode) || link_isdir (fe))
new_panel_at (filename);
else {
int size;
char *buf;

View File

@ -116,7 +116,6 @@ assign_other (void)
for (p = containers; p; p = p->next)
if (p->data != current_panel_ptr){
other_panel_ptr = p->data;
printf ("PANEL: Found another other\n");
break;
}
}

View File

@ -213,6 +213,29 @@ get_mountable_devices (void)
return list;
}
char *
mount_point_to_device (char *mount_point)
{
FILE *f;
struct mntent *mnt;
f = setmntent ("/etc/fstab", "r");
if (f == NULL)
return NULL;
while ((mnt = getmntent (f))){
if (strcmp (mnt->mnt_dir, mount_point) == 0){
char *v;
v = g_strdup (mnt->mnt_fsname);
endmntent (f);
return v;
}
}
endmntent (f);
return NULL;
}
#else
char *
@ -233,6 +256,11 @@ is_block_device_mounted (char *mount_point)
return TRUE;
}
char *
mount_point_to_device (char *mount_point)
{
return NULL;
}
#endif
@ -360,7 +388,7 @@ setup_devices (void)
} else if (dit->type == TYPE_NFS){
release_format = TRUE;
format = g_strdup_printf (_("NFS dir %s"), dit->mount_point);
icon = "i-blockdev.png";
icon = "i-nfs.png";
count = nfs_count++;
} else {
format = _("Device %d");

View File

@ -14,7 +14,8 @@
void gmount_setup_devices (void);
void desktop_cleanup_devices (void);
char *is_block_device_mountable (char *devname);
gboolean is_block_device_mounted (char *devname);
char *is_block_device_mountable (char *mount_point);
gboolean is_block_device_mounted (char *mount_point);
char *mount_point_to_device (char *mount_point);
#endif

View File

@ -612,12 +612,23 @@ static void
handle_eject (GtkWidget *widget, WPanel *panel)
{
char *full_name;
char *lname;
g_assert (is_a_desktop_panel (panel));
full_name = get_full_filename (panel);
do_mount_umount (full_name, FALSE);
do_eject (full_name);
lname = g_readlink (full_name);
if (!lname){
g_free (full_name);
return;
}
if (is_block_device_mounted (lname))
do_mount_umount (full_name, FALSE);
do_eject (lname);
g_free (lname);
g_free (full_name);
}

BIN
gnome/i-nfs.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB