Scanning devices now can run external program g-print

This commit is contained in:
Miguel de Icaza 1999-02-25 05:11:35 +00:00
parent f4ddffd7a3
commit 8220628b18
8 changed files with 67 additions and 14 deletions

View File

@ -1,5 +1,13 @@
1999-02-24 Miguel de Icaza <miguel@nuclecu.unam.mx> 1999-02-24 Miguel de Icaza <miguel@nuclecu.unam.mx>
* 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 * gicon.c (gicon_get_filename_for_icon): Return const char *, this
tells the user of this routine "you better not touch or free this tells the user of this routine "you better not touch or free this
you dofus". you dofus".

View File

@ -51,6 +51,7 @@ GNOMESRCS = \
gpopup.c \ gpopup.c \
gpopup2.c \ gpopup2.c \
gprefs.c \ gprefs.c \
gprint.c \
gprop.c \ gprop.c \
gnome-file-property-dialog.c \ gnome-file-property-dialog.c \
gscreen.c \ gscreen.c \
@ -151,6 +152,7 @@ OBJS = \
gpopup.o \ gpopup.o \
gpopup2.o \ gpopup2.o \
gprefs.o \ gprefs.o \
gprint.o \
gprop.o \ gprop.o \
gnome-file-property-dialog.o \ gnome-file-property-dialog.o \
gscreen.o \ gscreen.o \

View File

@ -1820,7 +1820,7 @@ create_desktop_dir (void)
} }
g_free (home_link_name); g_free (home_link_name);
gmount_setup_devices (FALSE); gmount_setup_devices ();
} }
} }
@ -2123,7 +2123,9 @@ handle_new_window (GtkWidget *widget, gpointer data)
void void
desktop_rescan_devices (void) desktop_rescan_devices (void)
{ {
gmount_setup_devices (TRUE); desktop_cleanup_devices ();
gmount_setup_devices ();
gprint_setup_devices ();
desktop_reload_icons (FALSE, 0, 0); desktop_reload_icons (FALSE, 0, 0);
} }

View File

@ -409,7 +409,7 @@ GnomeUIInfo gnome_panel_about_menu [] = {
GnomeUIInfo gnome_panel_desktop_menu [] = { GnomeUIInfo gnome_panel_desktop_menu [] = {
GNOMEUIINFO_ITEM_NONE (N_("Arrange Icons"), NULL, desktop_arrange_icons), GNOMEUIINFO_ITEM_NONE (N_("Arrange Icons"), NULL, desktop_arrange_icons),
GNOMEUIINFO_SEPARATOR, 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_ITEM_NONE (N_("Rescan Desktop"), NULL, do_desktop_rescan_devices),
GNOMEUIINFO_END GNOMEUIINFO_END
}; };

View File

@ -203,9 +203,13 @@ is_block_device_mounted (char *devname)
#endif #endif
/* Cleans up the desktop directory from device files */ /*
static void * Cleans up the desktop directory from device files
cleanup_devices (void) *
* Includes block devices and printers.
*/
void
desktop_cleanup_devices (void)
{ {
DIR *dir; DIR *dir;
struct dirent *dent; struct dirent *dent;
@ -216,6 +220,7 @@ cleanup_devices (void)
return; return;
} }
gnome_metadata_lock ();
while ((dent = mc_readdir (dir)) != NULL) { while ((dent = mc_readdir (dir)) != NULL) {
char *full_name; char *full_name;
char *buf; char *buf;
@ -229,7 +234,8 @@ cleanup_devices (void)
} }
g_free (full_name); g_free (full_name);
} }
gnome_metadata_unlock ();
mc_closedir (dir); mc_closedir (dir);
} }
@ -238,6 +244,7 @@ static void
create_device_link (char *dev_name, char *short_dev_name, char *caption, char *icon) create_device_link (char *dev_name, char *short_dev_name, char *caption, char *icon)
{ {
char *full_name; char *full_name;
char type = 'D';
full_name = g_concat_dir_and_file (desktop_directory, short_dev_name); full_name = g_concat_dir_and_file (desktop_directory, short_dev_name);
if (mc_symlink (dev_name, full_name) != 0) { 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-filename", strlen (icon) + 1, icon);
gnome_metadata_set (full_name, "icon-caption", strlen (caption) + 1, caption); 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); g_free (full_name);
} }
@ -309,10 +316,8 @@ setup_devices (void)
} }
void void
gmount_setup_devices (int cleanup) gmount_setup_devices (void)
{ {
if (cleanup)
cleanup_devices ();
setup_devices (); setup_devices ();
} }

View File

@ -11,7 +11,8 @@
#include <glib.h> #include <glib.h>
void gmount_setup_devices (int cleanup); void gmount_setup_devices (void);
void desktop_cleanup_devices (void);
char *is_block_device_mountable (char *devname); char *is_block_device_mountable (char *devname);
gboolean is_block_device_mounted (char *devname); gboolean is_block_device_mounted (char *devname);

35
gnome/gprint.c Normal file
View File

@ -0,0 +1,35 @@
/*
*
* Copyright (C) 1998-1999 The Free Software Foundation
*
* Authors: Miguel de Icaza <miguel@nuclecu.unam.mx>
*/
#include <config.h>
#include "main.h"
#include "util.h"
#include <libgnome/libgnome.h>
#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);
}

View File

@ -2526,7 +2526,7 @@ enum {
}; };
static void static void
process_args (int c, char *option_arg) process_args (int c, const char *option_arg)
{ {
switch (c) { switch (c) {
case 'V': case 'V':