1
1

Scanning devices now can run external program g-print

Этот коммит содержится в:
Miguel de Icaza 1999-02-25 05:11:35 +00:00
родитель f4ddffd7a3
Коммит 8220628b18
8 изменённых файлов: 67 добавлений и 14 удалений

Просмотреть файл

@ -1,5 +1,13 @@
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
tells the user of this routine "you better not touch or free this
you dofus".

Просмотреть файл

@ -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 \

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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
};

Просмотреть файл

@ -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 ();
}

Просмотреть файл

@ -11,7 +11,8 @@
#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);
gboolean is_block_device_mounted (char *devname);

35
gnome/gprint.c Обычный файл
Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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':