diff --git a/gnome/ChangeLog b/gnome/ChangeLog index eb44c79d6..258c38975 100644 --- a/gnome/ChangeLog +++ b/gnome/ChangeLog @@ -1,5 +1,13 @@ 1999-02-24 Miguel de Icaza + * gmount.c (desktop_cleanup_devices): Export this routine now and + call it from gdeskop instead of overloading gmount_setup_devices. + + * gprint.c: Sample file, it uses an externally provided program + (not in 1.0 so far) to setup printer devices. + + * gmount.c (gmount_setup_devices): No longer cleans up here. + * gicon.c (gicon_get_filename_for_icon): Return const char *, this tells the user of this routine "you better not touch or free this you dofus". diff --git a/gnome/Makefile.in b/gnome/Makefile.in index 4848e0335..23db21e40 100644 --- a/gnome/Makefile.in +++ b/gnome/Makefile.in @@ -51,6 +51,7 @@ GNOMESRCS = \ gpopup.c \ gpopup2.c \ gprefs.c \ + gprint.c \ gprop.c \ gnome-file-property-dialog.c \ gscreen.c \ @@ -151,6 +152,7 @@ OBJS = \ gpopup.o \ gpopup2.o \ gprefs.o \ + gprint.o \ gprop.o \ gnome-file-property-dialog.o \ gscreen.o \ diff --git a/gnome/gdesktop.c b/gnome/gdesktop.c index 22ef495c0..669693f64 100644 --- a/gnome/gdesktop.c +++ b/gnome/gdesktop.c @@ -1820,7 +1820,7 @@ create_desktop_dir (void) } g_free (home_link_name); - gmount_setup_devices (FALSE); + gmount_setup_devices (); } } @@ -2123,7 +2123,9 @@ handle_new_window (GtkWidget *widget, gpointer data) void desktop_rescan_devices (void) { - gmount_setup_devices (TRUE); + desktop_cleanup_devices (); + gmount_setup_devices (); + gprint_setup_devices (); desktop_reload_icons (FALSE, 0, 0); } diff --git a/gnome/glayout.c b/gnome/glayout.c index 4739154cf..991dbbf77 100644 --- a/gnome/glayout.c +++ b/gnome/glayout.c @@ -409,7 +409,7 @@ GnomeUIInfo gnome_panel_about_menu [] = { GnomeUIInfo gnome_panel_desktop_menu [] = { GNOMEUIINFO_ITEM_NONE (N_("Arrange Icons"), NULL, desktop_arrange_icons), GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("Rescan Mountable Devices"), NULL, desktop_rescan_devices), + GNOMEUIINFO_ITEM_NONE (N_("Rescan System Devices"), NULL, desktop_rescan_devices), GNOMEUIINFO_ITEM_NONE (N_("Rescan Desktop"), NULL, do_desktop_rescan_devices), GNOMEUIINFO_END }; diff --git a/gnome/gmount.c b/gnome/gmount.c index 6d6e38c5e..d1bedff33 100644 --- a/gnome/gmount.c +++ b/gnome/gmount.c @@ -203,9 +203,13 @@ is_block_device_mounted (char *devname) #endif -/* Cleans up the desktop directory from device files */ -static void -cleanup_devices (void) +/* + * Cleans up the desktop directory from device files + * + * Includes block devices and printers. + */ +void +desktop_cleanup_devices (void) { DIR *dir; struct dirent *dent; @@ -216,6 +220,7 @@ cleanup_devices (void) return; } + gnome_metadata_lock (); while ((dent = mc_readdir (dir)) != NULL) { char *full_name; char *buf; @@ -229,7 +234,8 @@ cleanup_devices (void) } g_free (full_name); } - + gnome_metadata_unlock (); + mc_closedir (dir); } @@ -238,6 +244,7 @@ static void create_device_link (char *dev_name, char *short_dev_name, char *caption, char *icon) { char *full_name; + char type = 'D'; full_name = g_concat_dir_and_file (desktop_directory, short_dev_name); if (mc_symlink (dev_name, full_name) != 0) { @@ -251,7 +258,7 @@ create_device_link (char *dev_name, char *short_dev_name, char *caption, char *i 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 */ + gnome_metadata_set (full_name, "is-desktop-device", 1, &type); /* hack a boolean value */ g_free (full_name); } @@ -309,10 +316,8 @@ setup_devices (void) } void -gmount_setup_devices (int cleanup) +gmount_setup_devices (void) { - if (cleanup) - cleanup_devices (); - setup_devices (); } + diff --git a/gnome/gmount.h b/gnome/gmount.h index d2b0a00cc..b53589e2c 100644 --- a/gnome/gmount.h +++ b/gnome/gmount.h @@ -11,7 +11,8 @@ #include -void gmount_setup_devices (int cleanup); +void gmount_setup_devices (void); +void desktop_cleanup_devices (void); char *is_block_device_mountable (char *devname); gboolean is_block_device_mounted (char *devname); diff --git a/gnome/gprint.c b/gnome/gprint.c new file mode 100644 index 000000000..56831987d --- /dev/null +++ b/gnome/gprint.c @@ -0,0 +1,35 @@ +/* + * + * Copyright (C) 1998-1999 The Free Software Foundation + * + * Authors: Miguel de Icaza + */ + +#include +#include "main.h" +#include "util.h" +#include +#include "gdesktop.h" + +void +gprint_setup_devices (void) +{ + static char *gprint_path; + char *desktop_quoted; + char *command; + + if (!gprint_path) + gprint_path = gnome_is_program_in_path ("g-print"); + + if (!gprint_path) + return; + + desktop_quoted = name_quote (desktop_directory, 0); + command = g_strconcat (gprint_path, " --create-printers ", desktop_quoted, NULL); + g_free (desktop_quoted); + + my_system (EXECUTE_WAIT | EXECUTE_AS_SHELL, shell, command); + g_free (command); +} + + diff --git a/src/main.c b/src/main.c index b0619341b..a276212ea 100644 --- a/src/main.c +++ b/src/main.c @@ -2526,7 +2526,7 @@ enum { }; static void -process_args (int c, char *option_arg) +process_args (int c, const char *option_arg) { switch (c) { case 'V':