1999-02-18 Federico Mena Quintero <federico@nuclecu.unam.mx>
* setup.c: Declare extern int tree_panel_visible for the GNOME version. 1999-02-18 Federico Mena Quintero <federico@nuclecu.unam.mx> * gmount.c (gmount_setup_devices): New function to set up the mountable devices on the desktop directory. Moved over from gdesktop.c. Added an argument that specifies whether it should clean up the device list first. (cleanup_devices): Delete the metadata for the devices. (setup_devices): Free the list of device names. Use the proper icon for each device. (create_device_link): Better error checking. * gdesktop.c (create_desktop_dir): Use gmount_setup_devices(). (desktop_icon_info_destroy): Made static. (desktop_popup_items): The command for rescanning mountable devices should go here. (handle_rescan_devices): Call gmount and refresh the desktop. * gdesktop.h: Removed the declaration of tree_panel_visible, since it has nothing to do with the desktop. * glayout.c (gnome_panel_commands_menu): Removed the recreate devices command. * gdesktop.c (desktop_popup_items): Added a new command to create a file window.
Этот коммит содержится в:
родитель
9fc940706c
Коммит
b169beea0e
@ -1,3 +1,29 @@
|
||||
1999-02-18 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
||||
|
||||
* gmount.c (gmount_setup_devices): New function to set up the
|
||||
mountable devices on the desktop directory. Moved over from
|
||||
gdesktop.c. Added an argument that specifies whether it should
|
||||
clean up the device list first.
|
||||
(cleanup_devices): Delete the metadata for the devices.
|
||||
(setup_devices): Free the list of device names. Use the proper
|
||||
icon for each device.
|
||||
(create_device_link): Better error checking.
|
||||
|
||||
* gdesktop.c (create_desktop_dir): Use gmount_setup_devices().
|
||||
(desktop_icon_info_destroy): Made static.
|
||||
(desktop_popup_items): The command for rescanning mountable
|
||||
devices should go here.
|
||||
(handle_rescan_devices): Call gmount and refresh the desktop.
|
||||
|
||||
* gdesktop.h: Removed the declaration of tree_panel_visible, since
|
||||
it has nothing to do with the desktop.
|
||||
|
||||
* glayout.c (gnome_panel_commands_menu): Removed the recreate
|
||||
devices command.
|
||||
|
||||
* gdesktop.c (desktop_popup_items): Added a new command to create
|
||||
a file window.
|
||||
|
||||
1999-02-17 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
||||
|
||||
* gdesktop.c (do_mount_umount): Removed unused variable.
|
||||
|
163
gnome/gdesktop.c
163
gnome/gdesktop.c
@ -24,10 +24,10 @@
|
||||
#include "gmain.h"
|
||||
#include "gmetadata.h"
|
||||
#include "gdnd.h"
|
||||
#include "gmount.h"
|
||||
#include "gpopup.h"
|
||||
#include "../vfs/vfs.h"
|
||||
#include "main.h"
|
||||
#include "gmount.h"
|
||||
|
||||
/* Name of the user's desktop directory (i.e. ~/desktop) */
|
||||
#define DESKTOP_DIR_NAME "desktop"
|
||||
@ -291,6 +291,18 @@ desktop_icon_info_place (DesktopIconInfo *dii, int xpos, int ypos)
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
/* Destroys the specified desktop icon */
|
||||
static void
|
||||
desktop_icon_info_destroy (DesktopIconInfo *dii)
|
||||
{
|
||||
gtk_widget_destroy (dii->dicon);
|
||||
remove_from_slot (dii);
|
||||
|
||||
g_free (dii->url);
|
||||
g_free (dii->filename);
|
||||
g_free (dii);
|
||||
}
|
||||
|
||||
/* Destroys all the current desktop icons */
|
||||
static void
|
||||
destroy_desktop_icons (void)
|
||||
@ -1725,23 +1737,6 @@ desktop_icon_update_url (DesktopIconInfo *dii)
|
||||
g_free (fullname);
|
||||
}
|
||||
|
||||
/**
|
||||
* desktop_icon_info_destroy:
|
||||
* @dii: The desktop icon to destroy
|
||||
*
|
||||
* Destroys the specified desktop icon.
|
||||
**/
|
||||
void
|
||||
desktop_icon_info_destroy (DesktopIconInfo *dii)
|
||||
{
|
||||
gtk_widget_destroy (dii->dicon);
|
||||
remove_from_slot (dii);
|
||||
|
||||
g_free (dii->url);
|
||||
g_free (dii->filename);
|
||||
g_free (dii);
|
||||
}
|
||||
|
||||
/* Creates the layout information array */
|
||||
static void
|
||||
create_layout_info (void)
|
||||
@ -1753,110 +1748,8 @@ create_layout_info (void)
|
||||
layout_slots = g_new0 (struct layout_slot, layout_cols * layout_rows);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_trashcan (char *desktop_dir)
|
||||
{
|
||||
char *trashcan_dir;
|
||||
char *trash_pix;
|
||||
|
||||
trashcan_dir = g_concat_dir_and_file (desktop_directory, _("Trashcan"));
|
||||
trash_pix = g_concat_dir_and_file (ICONDIR, "trash.xpm");
|
||||
|
||||
if (!g_file_exists (trashcan_dir)){
|
||||
mkdir (trashcan_dir, 0777);
|
||||
gnome_metadata_set (
|
||||
trashcan_dir, "icon-filename", strlen (trash_pix) + 1, trash_pix);
|
||||
}
|
||||
|
||||
g_free (trashcan_dir);
|
||||
g_free (trash_pix);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_devices (void)
|
||||
{
|
||||
GList *list = get_list_of_mountable_devices ();
|
||||
GList *l;
|
||||
int floppy = 0;
|
||||
int generic = 0;
|
||||
int hd = 0;
|
||||
char buffer [60];
|
||||
const char *device_icon = ICONDIR "i-blockdev.png";
|
||||
|
||||
if (!list)
|
||||
return;
|
||||
|
||||
/* Create the links */
|
||||
for (l = list; l; l = l->next){
|
||||
char *full;
|
||||
char *name = l->data;
|
||||
char *short_dev_name = x_basename (name);
|
||||
char *format = NULL;
|
||||
int count;
|
||||
|
||||
if (strncmp (short_dev_name, "fd", 2) == 0){
|
||||
format = _("floppy %d");
|
||||
count = floppy++;
|
||||
} else if (strncmp (short_dev_name, "hd", 2) == 0 || strncmp (short_dev_name, "sd", 2) == 0){
|
||||
format = _("disk %d");
|
||||
count = hd++;
|
||||
} else {
|
||||
format = _("device %d");
|
||||
count = generic++;
|
||||
}
|
||||
|
||||
g_snprintf (buffer, sizeof (buffer), format, count);
|
||||
|
||||
full = g_concat_dir_and_file (desktop_directory, short_dev_name);
|
||||
symlink (name, full);
|
||||
|
||||
gnome_metadata_set (
|
||||
full, "icon-filename",
|
||||
strlen (device_icon) + 1, device_icon);
|
||||
gnome_metadata_set (
|
||||
full, "icon-caption",
|
||||
strlen (buffer)+1, buffer);
|
||||
gnome_metadata_set (
|
||||
full, "is-desktop-device",
|
||||
1, &buffer [0]);
|
||||
g_free (full);
|
||||
}
|
||||
|
||||
/* release the list */
|
||||
for (l = list; l; l = l->next)
|
||||
g_free (l->data);
|
||||
g_list_free (l);
|
||||
}
|
||||
|
||||
void
|
||||
desktop_setup_devices ()
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *dent;
|
||||
|
||||
dir = mc_opendir (desktop_directory);
|
||||
if (!dir)
|
||||
return;
|
||||
while ((dent = mc_readdir (dir)) != NULL){
|
||||
char *full = g_concat_dir_and_file (desktop_directory, dent->d_name);
|
||||
int size;
|
||||
char *buf;
|
||||
|
||||
if (gnome_metadata_get (full, "is-desktop-device", &size, &buf) == 0){
|
||||
mc_unlink (full);
|
||||
g_free (buf);
|
||||
}
|
||||
g_free (full);
|
||||
}
|
||||
mc_closedir (dir);
|
||||
|
||||
setup_devices ();
|
||||
reload_desktop_icons (FALSE, 0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that the user's desktop directory exists, and if not, create
|
||||
* the default desktop setup.
|
||||
/* Check that the user's desktop directory exists, and if not, create the
|
||||
* default desktop setup.
|
||||
*/
|
||||
static void
|
||||
create_desktop_dir (void)
|
||||
@ -1879,15 +1772,14 @@ create_desktop_dir (void)
|
||||
if (mc_symlink (gnome_user_home_dir, home_link_name) != 0) {
|
||||
message (FALSE,
|
||||
_("Warning"),
|
||||
_("Could not symlink %s to %s; will not have initial desktop icons."),
|
||||
_("Could not symlink %s to %s; "
|
||||
"will not have initial desktop icons."),
|
||||
gnome_user_home_dir, home_link_name);
|
||||
}
|
||||
g_free (home_link_name);
|
||||
|
||||
setup_devices ();
|
||||
gmount_setup_devices (FALSE);
|
||||
}
|
||||
|
||||
/* setup_trashcan (desktop_directory); */
|
||||
}
|
||||
|
||||
/* Property placed on target windows */
|
||||
@ -2185,6 +2077,21 @@ handle_arrange_icons (GtkWidget *widget, gpointer data)
|
||||
arrange_desktop_icons ();
|
||||
}
|
||||
|
||||
/* Callback for creating a new panel window */
|
||||
static void
|
||||
handle_new_window (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
new_panel_at (gnome_user_home_dir);
|
||||
}
|
||||
|
||||
/* Callback for rescanning the mountable devices */
|
||||
static void
|
||||
handle_rescan_devices (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
gmount_setup_devices (TRUE);
|
||||
reload_desktop_icons (FALSE, 0, 0);
|
||||
}
|
||||
|
||||
/* Callback for rescanning the desktop directory */
|
||||
static void
|
||||
handle_rescan_desktop (GtkWidget *widget, gpointer data)
|
||||
@ -2195,6 +2102,10 @@ handle_rescan_desktop (GtkWidget *widget, gpointer data)
|
||||
/* The popup menu for the desktop */
|
||||
static GnomeUIInfo desktop_popup_items[] = {
|
||||
GNOMEUIINFO_ITEM_NONE (N_("Arrange Icons"), NULL, handle_arrange_icons),
|
||||
GNOMEUIINFO_SEPARATOR,
|
||||
GNOMEUIINFO_ITEM_NONE (N_("Create New Window"), NULL, handle_new_window),
|
||||
GNOMEUIINFO_SEPARATOR,
|
||||
GNOMEUIINFO_ITEM_NONE (N_("Rescan Mountable Devices"), NULL, handle_rescan_devices),
|
||||
GNOMEUIINFO_ITEM_NONE (N_("Rescan Desktop"), NULL, handle_rescan_desktop),
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
@ -25,7 +25,6 @@ extern int desktop_use_shaped_icons; /* Whether to use shaped icons or not (for
|
||||
extern int desktop_auto_placement; /* Whether to auto-place icons or not (user placement) */
|
||||
extern int desktop_snap_icons; /* Whether to snap icons to the grid or not */
|
||||
extern char *desktop_directory;
|
||||
extern int tree_panel_visible;
|
||||
|
||||
/* Initializes the desktop -- init DnD, load the default desktop icons, etc. */
|
||||
void desktop_init (void);
|
||||
@ -47,7 +46,6 @@ typedef struct {
|
||||
int tmp_selected : 1; /* Temp storage for original selection while rubberbanding */
|
||||
} DesktopIconInfo;
|
||||
|
||||
void desktop_icon_info_destroy (DesktopIconInfo *dii);
|
||||
void desktop_icon_info_open (DesktopIconInfo *dii);
|
||||
void desktop_icon_info_delete (DesktopIconInfo *dii);
|
||||
|
||||
@ -56,6 +54,5 @@ void file_entry_free (file_entry *fe);
|
||||
|
||||
gboolean is_mountable (char *filename, file_entry *fe, int *is_mounted);
|
||||
gboolean do_mount_umount (char *filename, gboolean is_mount);
|
||||
void desktop_setup_devices ();
|
||||
|
||||
#endif
|
||||
|
@ -360,8 +360,6 @@ GnomeUIInfo gnome_panel_commands_menu [] = {
|
||||
#ifdef WITH_BACKGROUND
|
||||
GNOMEUIINFO_ITEM_NONE( N_("_Background jobs..."), N_("List of background operations"), jobs_cmd ),
|
||||
#endif
|
||||
GNOMEUIINFO_SEPARATOR,
|
||||
GNOMEUIINFO_ITEM_NONE( N_("Recreate desktop devices"), N_("Recreates the devices shown on the desktop"), desktop_setup_devices ),
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
|
129
gnome/gmount.c
129
gnome/gmount.c
@ -2,7 +2,8 @@
|
||||
*
|
||||
* Copyright (C) 1998-1999 The Free Software Foundation
|
||||
*
|
||||
* Author: Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
* Authors: Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
* Federico Mena <federico@nuclecu.unam.mx>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
@ -82,10 +83,19 @@ void free (void *ptr);
|
||||
#define MOUNTED_GETMNTTBL
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <gnome.h>
|
||||
#include "../vfs/vfs.h"
|
||||
#include "dialog.h"
|
||||
#include "gdesktop.h"
|
||||
#include "gmount.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
#ifdef MOUNTED_GETMNTENT1
|
||||
|
||||
gboolean
|
||||
is_block_device_mountable (char *devname)
|
||||
{
|
||||
@ -171,3 +181,118 @@ is_block_device_mounted (char *devname)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Cleans up the desktop directory from device files */
|
||||
static void
|
||||
cleanup_devices (void)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *dent;
|
||||
|
||||
dir = mc_opendir (desktop_directory);
|
||||
if (!dir) {
|
||||
g_warning ("Could not clean up desktop devices");
|
||||
return;
|
||||
}
|
||||
|
||||
while ((dent = mc_readdir (dir)) != NULL) {
|
||||
char *full_name;
|
||||
char *buf;
|
||||
int size;
|
||||
|
||||
full_name = g_concat_dir_and_file (desktop_directory, dent->d_name);
|
||||
if (gnome_metadata_get (full_name, "is-desktop-device", &size, &buf) == 0) {
|
||||
mc_unlink (full_name);
|
||||
gnome_metadata_delete (full_name);
|
||||
g_free (buf);
|
||||
}
|
||||
g_free (full_name);
|
||||
}
|
||||
|
||||
mc_closedir (dir);
|
||||
}
|
||||
|
||||
/* Creates the desktop link for the specified device */
|
||||
static void
|
||||
create_device_link (char *dev_name, char *short_dev_name, char *caption, char *icon)
|
||||
{
|
||||
char *full_name;
|
||||
|
||||
full_name = g_concat_dir_and_file (desktop_directory, short_dev_name);
|
||||
if (mc_symlink (dev_name, full_name) != 0) {
|
||||
message (FALSE,
|
||||
_("Warning"),
|
||||
_("Could not symlink %s to %s; "
|
||||
"will not have such a desktop device icon."),
|
||||
dev_name, full_name);
|
||||
return;
|
||||
}
|
||||
|
||||
gnome_metadata_set (full_name, "icon-filename", strlen (icon) + 1, icon);
|
||||
gnome_metadata_set (full_name, "icon-caption", strlen (caption) + 1, caption);
|
||||
gnome_metadata_set (full_name, "is-desktop-device", 1, full_name); /* hack a boolean value */
|
||||
|
||||
g_free (full_name);
|
||||
}
|
||||
|
||||
/* Creates the desktop links to the mountable devices */
|
||||
static void
|
||||
setup_devices (void)
|
||||
{
|
||||
GList *list, *l;
|
||||
int floppy_count;
|
||||
int hd_count;
|
||||
int generic_count;
|
||||
|
||||
list = get_list_of_mountable_devices ();
|
||||
|
||||
floppy_count = hd_count = generic_count = 0;
|
||||
|
||||
for (l = list; l; l = l->next) {
|
||||
char *dev_name;
|
||||
char *short_dev_name;
|
||||
char *format;
|
||||
char *icon;
|
||||
int count;
|
||||
char buffer[128];
|
||||
|
||||
dev_name = l->data;
|
||||
short_dev_name = x_basename (dev_name);
|
||||
|
||||
/* Create the format/icon/count. This could use better heuristics. */
|
||||
|
||||
if (strncmp (short_dev_name, "fd", 2) == 0) {
|
||||
format = _("Floppy %d");
|
||||
icon = "i-floppy.png";
|
||||
count = floppy_count++;
|
||||
} else if (strncmp (short_dev_name, "hd", 2) == 0
|
||||
|| strncmp (short_dev_name, "sd", 2) == 0) {
|
||||
format = _("Disk %d");
|
||||
icon = "i-blockdev.png";
|
||||
count = hd_count++;
|
||||
} else {
|
||||
format = _("Device %d");
|
||||
icon = "i-blockdev.png";
|
||||
count = generic_count++;
|
||||
}
|
||||
|
||||
g_snprintf (buffer, sizeof (buffer), format, count);
|
||||
|
||||
/* Create the actual link */
|
||||
|
||||
create_device_link (dev_name, short_dev_name, buffer, icon);
|
||||
g_free (l->data);
|
||||
}
|
||||
|
||||
g_free (list);
|
||||
}
|
||||
|
||||
void
|
||||
gmount_setup_devices (int cleanup)
|
||||
{
|
||||
if (cleanup)
|
||||
cleanup_devices ();
|
||||
|
||||
setup_devices ();
|
||||
}
|
||||
|
@ -2,7 +2,8 @@
|
||||
*
|
||||
* Copyright (C) 1998-1999 The Free Software Foundation
|
||||
*
|
||||
* Author: Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
* Authors: Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
* Federico Mena <federico@nuclecu.unam.mx>
|
||||
*/
|
||||
|
||||
#ifndef GMOUNT_H
|
||||
@ -10,8 +11,12 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
void gmount_setup_devices (int cleanup);
|
||||
|
||||
#if 0
|
||||
gboolean is_block_device_mountable (char *devname);
|
||||
gboolean is_block_device_mounted (char *devname);
|
||||
GList *get_list_of_mountable_devices (void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,3 +1,8 @@
|
||||
1999-02-18 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
||||
|
||||
* setup.c: Declare extern int tree_panel_visible for the GNOME
|
||||
version.
|
||||
|
||||
1999-02-17 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
||||
|
||||
* dir.c (if_link_is_exe): Made this function take in a directory
|
||||
|
@ -65,6 +65,7 @@ extern int ftpfs_first_cd_then_ls;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GNOME
|
||||
extern int tree_panel_visible;
|
||||
extern int we_can_afford_the_speed;
|
||||
#endif
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user