Commit e7d9f82a authored by Darin Adler's avatar Darin Adler
Browse files

Merge all changes from gnome-vfs-1 branch to HEAD.

parent e0d6ca4c
......@@ -2,4 +2,5 @@ Makefile
Makefile.in
.deps
.libs
nautilus-mime-type-capplet
file-types-capplet
file-types-capplet.desktop
INCLUDES = -I. \
-I$(top_srcdir) \
-I$(srcdir) \
NULL =
SUBDIRS = libuuid
INCLUDES = -I. \
-I$(top_srcdir) \
-I$(srcdir) \
-I$(top_srcdir)/intl -I$(top_builddir)/intl \
-I$(top_srcdir)/libgnomevfs \
$(CAPPLET_INCLUDEDIR) \
......@@ -9,36 +13,49 @@ INCLUDES = -I. \
$(GTK_CFLAGS) \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I$(includedir) \
$(VFS_CFLAGS) $(WERROR)
$(VFS_CFLAGS) $(WERROR) \
$(NULL)
bin_PROGRAMS = nautilus-mime-type-capplet
nautilus_mime_type_capplet_SOURCES = \
bin_PROGRAMS = file-types-capplet
file_types_capplet_SOURCES = \
nautilus-mime-type-capplet.h \
nautilus-mime-type-capplet-dialogs.h \
nautilus-mime-type-icon-entry.h \
nautilus-mime-type-capplet.c \
nautilus-mime-type-capplet-dialogs.c \
nautilus-mime-type-icon-entry.c
nautilus-mime-type-icon-entry.c \
$(NULL)
nautilus_mime_type_capplet_LDADD = \
file_types_capplet_LDADD = \
$(CAPPLET_LIBDIR) \
$(CAPPLET_LIBS) \
$(ORBIT_LIBS) \
$(OAF_LIBS) \
$(INTLLIBS) \
$(top_builddir)/libgnomevfs/libgnomevfs.la \
-lgdk_pixbuf
-lgdk_pixbuf \
$/libuuid/libuuid.a \
$(NULL)
sysdir = $(datadir)/control-center
sys_DATA = nautilus-mime-type.desktop
sysdir = $(datadir)/control-center/Documents
sys_in_files = file-types-capplet.desktop.in
sys_DATA = $(sys_in_files:.desktop.in=.desktop)
settingsdir = $(datadir)/gnome/apps/Settings
settings_DATA = nautilus-mime-type.desktop
settings_DATA = $(sys_DATA)
desktop_in_file = file-types-capplet.desktop.in
desktop_file = $(desktop_in_file:.desktop.in=.desktop)
@XML_I18N_MERGE_DESKTOP_RULE@
EXTRA_DIST = \
$(sys_DATA)
$(sys_DATA) $(desktop_in_file)
......
......@@ -30,6 +30,7 @@ void show_edit_components_dialog (const char *mime_type);
char *name_from_oaf_server_info (OAF_ServerInfo *server);
char *nautilus_mime_type_capplet_show_new_mime_window (void);
char *nautilus_mime_type_capplet_show_new_extension_window (void);
char *nautilus_mime_type_capplet_show_change_extension_window (const char *mime_type);
char *nautilus_mime_type_capplet_show_change_extension_window (const char *mime_type,
gboolean *new_list);
#endif /* NAUTILUS_MIME_TYPE_CAPPLET_DIALOGS_H */
This diff is collapsed.
[Desktop Entry]
_Name=File Types and Programs
_Comment=Specify which programs are used to open or view each file type
Icon=gnome-ccmime.png
Exec=file-types-capplet
Terminal=0
Type=Application
......@@ -25,11 +25,11 @@
#ifndef NAUTILUS_MIME_TYPE_CAPPLET_H
#define NAUTILUS_MIME_TYPE_CAPPLET_H
void nautilus_mime_type_capplet_update_info (const char *mime_type);
void nautilus_mime_type_capplet_update_application_info (const char *mime_type);
void nautilus_mime_type_capplet_update_viewer_info (const char *mime_type);
void nautilus_mime_type_capplet_add_extension (const char *extension);
const char *nautilus_mime_type_capplet_get_selected_item_mime_type (void);
void nautilus_mime_type_capplet_update_mime_list_icon (const char *mime_string);
void nautilus_mime_type_capplet_update_info (const char *mime_type);
void nautilus_mime_type_capplet_update_application_info (const char *mime_type);
void nautilus_mime_type_capplet_update_viewer_info (const char *mime_type);
void nautilus_mime_type_capplet_add_extension (const char *extension);
const char *nautilus_mime_type_capplet_get_selected_item_mime_type (void);
void nautilus_mime_type_capplet_update_mime_list_icon_and_description (const char *mime_string);
#endif /* NAUTILUS_MIME_TYPE_CAPPLET_H */
......@@ -142,6 +142,7 @@ entry_activated(GtkWidget *widget, NautilusMimeIconEntry *ientry)
struct stat buf;
GnomeIconSelection * gis;
gchar *filename;
GtkButton *OK_button;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_ENTRY (widget));
......@@ -161,9 +162,11 @@ entry_activated(GtkWidget *widget, NautilusMimeIconEntry *ientry)
if (gis->file_list)
gnome_icon_selection_show_icons(gis);
} else {
/* We pretend like ok has been called */
entry_changed (NULL, ientry);
gtk_widget_hide (ientry->pick_dialog);
/* FIXME: This is a hack to act exactly like we've clicked the
* OK button. This should be structured more cleanly.
*/
OK_button = GTK_BUTTON (GNOME_DIALOG (ientry->pick_dialog)->buttons->data);
gtk_button_clicked (OK_button);
}
}
......@@ -274,41 +277,6 @@ browse_clicked (GnomeFileEntry *fentry, NautilusMimeIconEntry *ientry)
GTK_OBJECT(fs));
}
static void
icon_selected_cb (GtkButton *button, NautilusMimeIconEntry *icon_entry)
{
const gchar *icon;
GnomeIconSelection *gis;
gchar *path, *filename;
const char *mime_type;
GtkWidget *entry;
g_return_if_fail (icon_entry != NULL);
g_return_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (icon_entry));
gis = gtk_object_get_user_data (GTK_OBJECT (icon_entry));
gnome_icon_selection_stop_loading (gis);
icon = gnome_icon_selection_get_icon (gis, TRUE);
if (icon != NULL) {
entry = nautilus_mime_type_icon_entry_gtk_entry (icon_entry);
gtk_entry_set_text (GTK_ENTRY (entry), icon);
entry_changed (NULL, icon_entry);
path = nautilus_mime_type_icon_entry_get_relative_filename (NAUTILUS_MIME_ICON_ENTRY (icon_entry));
if (path != NULL) {
filename = strrchr (path, '/');
if (filename != NULL) {
filename++;
mime_type = nautilus_mime_type_capplet_get_selected_item_mime_type ();
gnome_vfs_mime_set_icon (mime_type, filename);
nautilus_mime_type_capplet_update_mime_list_icon (mime_type);
}
g_free (path);
}
}
}
static void
cancel_pressed (GtkButton * button, NautilusMimeIconEntry * icon_entry)
{
......@@ -322,31 +290,6 @@ cancel_pressed (GtkButton * button, NautilusMimeIconEntry * icon_entry)
}
static void
gil_icon_selected_cb (GnomeIconList *gil, gint num, GdkEvent *event, NautilusMimeIconEntry *icon_entry)
{
const gchar * icon;
GnomeIconSelection * gis;
g_return_if_fail (icon_entry != NULL);
g_return_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (icon_entry));
gis = gtk_object_get_user_data(GTK_OBJECT(icon_entry));
icon = gnome_icon_selection_get_icon(gis, TRUE);
if (icon != NULL) {
GtkWidget *e = nautilus_mime_type_icon_entry_gtk_entry(icon_entry);
gtk_entry_set_text(GTK_ENTRY(e),icon);
}
if(event && event->type == GDK_2BUTTON_PRESS && ((GdkEventButton *)event)->button == 1) {
gnome_icon_selection_stop_loading(gis);
entry_changed (NULL, icon_entry);
gtk_widget_hide(icon_entry->pick_dialog);
}
}
void
nautilus_mime_type_show_icon_selection (NautilusMimeIconEntry *icon_entry)
{
......@@ -360,7 +303,7 @@ nautilus_mime_type_show_icon_selection (NautilusMimeIconEntry *icon_entry)
fe = GNOME_FILE_ENTRY (icon_entry->fentry);
p = gnome_file_entry_get_full_path (fe, FALSE);
curfile = nautilus_mime_type_icon_entry_get_filename (icon_entry);
curfile = nautilus_mime_type_icon_entry_get_full_filename (icon_entry);
/* Are we part of a modal window? If so, we need to be modal too. */
tl = gtk_widget_get_toplevel (GTK_WIDGET (icon_entry->frame));
......@@ -434,12 +377,12 @@ nautilus_mime_type_show_icon_selection (NautilusMimeIconEntry *icon_entry)
gtk_object_set_user_data(GTK_OBJECT(icon_entry), iconsel);
gnome_icon_selection_add_directory (GNOME_ICON_SELECTION(iconsel), icon_entry->pick_dialog_dir);
/* Hide the file entry until we figure out how to deal with icon paths
outside of the standard gnome paths */
/*gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (icon_entry->pick_dialog)->vbox),
gtk_window_set_title (GTK_WINDOW (icon_entry->pick_dialog), _("Select an icon"));
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (icon_entry->pick_dialog)->vbox),
icon_entry->fentry, FALSE, FALSE, 0);
*/
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(icon_entry->pick_dialog)->vbox),
iconsel, TRUE, TRUE, 0);
......@@ -451,17 +394,15 @@ nautilus_mime_type_show_icon_selection (NautilusMimeIconEntry *icon_entry)
gnome_icon_selection_select_icon(GNOME_ICON_SELECTION(iconsel),
g_filename_pointer(curfile));
gnome_dialog_button_connect(GNOME_DIALOG (icon_entry->pick_dialog),
0, /* OK button */
GTK_SIGNAL_FUNC (icon_selected_cb),
icon_entry);
/* FIXME:
* OK button is handled by caller, Cancel button is handled here.
* This could be cleaned up further.
*/
gnome_dialog_button_connect(GNOME_DIALOG(icon_entry->pick_dialog),
1, /* Cancel button */
GTK_SIGNAL_FUNC(cancel_pressed),
icon_entry);
gtk_signal_connect_after(GTK_OBJECT(GNOME_ICON_SELECTION(iconsel)->gil), "select_icon",
GTK_SIGNAL_FUNC(gil_icon_selected_cb),
icon_entry);
} else {
GnomeIconSelection *gis =
gtk_object_get_user_data(GTK_OBJECT(icon_entry));
......@@ -476,27 +417,24 @@ nautilus_mime_type_show_icon_selection (NautilusMimeIconEntry *icon_entry)
gchar *
nautilus_mime_type_icon_entry_get_relative_filename (NautilusMimeIconEntry *ientry)
{
char *filename;
char **path_parts;
filename = nautilus_mime_type_icon_entry_get_filename (NAUTILUS_MIME_ICON_ENTRY (ientry));
path_parts = g_strsplit (filename, "/share/pixmaps/", 0);
g_free (filename);
filename = NULL;
char *filename;
char *result;
char **path_parts;
result = NULL;
filename = nautilus_mime_type_icon_entry_get_full_filename (NAUTILUS_MIME_ICON_ENTRY (ientry));
if (filename != NULL) {
path_parts = g_strsplit (filename, "/share/pixmaps/", 0);
g_free (filename);
if (path_parts[1] != NULL) {
result = g_strdup (path_parts[1]);
}
if (path_parts[1] != NULL) {
filename = g_strdup (path_parts[1]);
} else {
/* FIXME: bugzilla.eazel.com 4797 */
g_warning ("user picked up an icon not in $(prefix)/share/pixmaps\n");
filename = g_strdup ("");
g_strfreev (path_parts);
}
g_strfreev (path_parts);
return filename;
return result;
}
static void
......@@ -690,7 +628,7 @@ nautilus_mime_type_icon_entry_set_icon (NautilusMimeIconEntry *ientry, const gch
}
/**
* nautilus_mime_type_icon_entry_get_filename:
* nautilus_mime_type_icon_entry_get_full_filename:
* @ientry: the NautilusMimeIconEntry to work with
*
* Description: Gets the file name of the image if it was possible
......@@ -701,7 +639,7 @@ nautilus_mime_type_icon_entry_set_icon (NautilusMimeIconEntry *ientry, const gch
* couldn't load the file
**/
gchar *
nautilus_mime_type_icon_entry_get_filename (NautilusMimeIconEntry *ientry)
nautilus_mime_type_icon_entry_get_full_filename (NautilusMimeIconEntry *ientry)
{
GtkWidget *child;
......
......@@ -63,7 +63,7 @@ GtkWidget *nautilus_mime_type_icon_entry_gnome_entry (NautilusMimeIconEntry *ien
GtkWidget *nautilus_mime_type_icon_entry_gtk_entry (NautilusMimeIconEntry *ientry);
/*only return a file if it was possible to load it with imlib*/
gchar *nautilus_mime_type_icon_entry_get_filename (NautilusMimeIconEntry *ientry);
gchar *nautilus_mime_type_icon_entry_get_full_filename (NautilusMimeIconEntry *ientry);
gchar *nautilus_mime_type_icon_entry_get_relative_filename (NautilusMimeIconEntry *ientry);
void nautilus_mime_type_show_icon_selection (NautilusMimeIconEntry * ientry);
......
NULL =
noinst_LIBRARIES = libuuid.a
noinst_HEADERS = \
uuid.h \
uuidP.h \
$(NULL)
libuuid_a_SOURCES = \
clear.c \
compare.c \
copy.c \
gen_uuid.c \
isnull.c \
pack.c \
parse.c \
unpack.c \
unparse.c \
uuid_time.c \
$(NULL)
INCLUDES = \
$(GLIB_CFLAGS) \
$(WERROR) \
$(NULL)
/*
* clear.c -- Clear a UUID
*
* Copyright (C) 1996, 1997 Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*/
#include "string.h"
#include "uuidP.h"
void uuid_clear(uuid_t uu)
{
memset(uu, 0, 16);
}
/*
* compare.c --- compare whether or not two UUID's are the same
*
* Returns 0 if the two UUID's are different, and 1 if they are the same.
*
* Copyright (C) 1996, 1997 Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*/
#include "uuidP.h"
#include <string.h>
#define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1);
int uuid_compare(uuid_t uu1, uuid_t uu2)
{
struct uuid uuid1, uuid2;
uuid_unpack(uu1, &uuid1);
uuid_unpack(uu2, &uuid2);
UUCMP(uuid1.time_low, uuid2.time_low);
UUCMP(uuid1.time_mid, uuid2.time_mid);
UUCMP(uuid1.time_hi_and_version, uuid2.time_hi_and_version);
UUCMP(uuid1.clock_seq, uuid2.clock_seq);
return memcmp(uuid1.node, uuid2.node, 6);
}
/*
* copy.c --- copy UUIDs
*
* Copyright (C) 1996, 1997 Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*/
#include "uuidP.h"
void uuid_copy(uuid_t uu1, uuid_t uu2)
{
unsigned char *cp1, *cp2;
int i;
for (i=0, cp1 = uu1, cp2 = uu2; i < 16; i++)
*cp1++ = *cp2++;
}
/*
* gen_uuid.c --- generate a DCE-compatible uuid
*
* Copyright (C) 1996, 1997 Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*/
#include <config.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#ifdef HAVE_SYS_SOCKIO_H
#include <sys/sockio.h>
#endif
#ifdef HAVE_NET_IF_H
#include <net/if.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "uuidP.h"
#ifdef HAVE_SRANDOM
#define srand(x) srandom(x)
#define rand() random()
#endif
/*
* Generate a series of random bytes. Use /dev/urandom if possible,
* and if not, use srandom/random.
*/
static void get_random_bytes(void *buf, int nbytes)
{
static int fd = -2;
int i;
char *cp = (char *) buf;
if (fd == -2) {
fd = open("/dev/urandom", O_RDONLY);
srand((getpid() << 16) ^ getuid() ^ time(0));
}
if (fd >= 0) {
while (nbytes > 0) {
i = read(fd, cp, nbytes);
if (i < 0) {
if ((errno == EINTR) || (errno == EAGAIN))
continue;
break;
}
nbytes -= i;
cp += i;
}
}
if (nbytes == 0)
return;
/* XXX put something better here if no /dev/random! */
for (i=0; i < nbytes; i++)
*cp++ = rand() & 0xFF;
return;
}
/*
* Get the ethernet hardware address, if we can find it...
*/
static int get_node_id(unsigned char *node_id)
{
#ifdef HAVE_NET_IF_H
int sd;
struct ifreq ifr, *ifrp;
struct ifconf ifc;
char buf[1024];
int n, i;
unsigned char *a;
/*
* BSD 4.4 defines the size of an ifreq to be
* max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len
* However, under earlier systems, sa_len isn't present, so the size is
* just sizeof(struct ifreq)
*/
#ifdef HAVE_SA_LEN
#ifndef max
#define max(a,b) ((a) > (b) ? (a) : (b))
#endif
#define ifreq_size(i) max(sizeof(struct ifreq),\
sizeof((i).ifr_name)+(i).ifr_addr.sa_len)
#else
#define ifreq_size(i) sizeof(struct ifreq)
#endif /* HAVE_SA_LEN*/
sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
if (sd < 0) {
return -1;
}
memset(buf, 0, sizeof(buf));
ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;
if (ioctl (sd, SIOCGIFCONF, (char *)&ifc) < 0) {
close(sd);
return -1;
}
n = ifc.ifc_len;
for (i = 0; i < n; i+= ifreq_size(*ifr) ) {
ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i);
strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ);
#ifdef SIOCGIFHWADDR
if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0)
continue;
a = (unsigned char *) &ifr.ifr_hwaddr.sa_data;
#else
#ifdef SIOCGENADDR
if (ioctl(sd, SIOCGENADDR, &ifr) < 0)
continue;
a = (unsigned char *) ifr.ifr_enaddr;
#else
/*
* XXX we don't have a way of getting the hardware
* address
*/
close(sd);
return 0;
#endif /* SIOCGENADDR */
#endif /* SIOCGIFHWADDR */
if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])
continue;
if (node_id) {
memcpy(node_id, a, 6);
close(sd);
return 1;
}
}
close(sd);
#endif
return 0;
}
/* Assume that the gettimeofday() has microsecond granularity */
#define MAX_ADJUSTMENT 10