Commit 256c431a authored by Elliot Lee's avatar Elliot Lee
Browse files

Build converters. Stop installing the now-unneeded .schemes file.



* components/help/Makefile.am: Build converters. Stop installing
the now-unneeded .schemes file.

* components/websearch/ntl-web-search.c: Get rid of
gnome_button_can_default()

* libnautilus/nautilus-icons-view-icon-item.c: Get rid of missing
prototypes and associated warnings by including needed headers.

* src/ntl-types.h, src/ntl-uri-map.[ch], src/ntl-window.h,
src/ntl-window-msgs.c: Remove scheme mapping functionality (now
done in gnome-vfs). Use asynchronous version of get_file_info.
parent 6e68aefb
2000-02-07 Elliot Lee <sopwith@redhat.com>
* components/help/Makefile.am: Build converters. Stop installing
the now-unneeded .schemes file.
* components/websearch/ntl-web-search.c: Get rid of
gnome_button_can_default()
* libnautilus/nautilus-icons-view-icon-item.c: Get rid of missing
prototypes and associated warnings by including needed headers.
* src/ntl-types.h, src/ntl-uri-map.[ch], src/ntl-window.h,
src/ntl-window-msgs.c: Remove scheme mapping functionality (now
done in gnome-vfs). Use asynchronous version of get_file_info.
2000-02-04 John Sullivan <sullivan@eazel.com>
Zooming now shows different information at different
......
SUBDIRS=converters
bin_PROGRAMS=hyperbola
INCLUDES=-I$(top_srcdir) -I$(top_builddir) \
......@@ -11,13 +13,10 @@ hyperbola_SOURCES= \
hyperbola-filefmt.c \
hyperbola-filefmt.h
EXTRA_DIST=pages.map hyperbola.goad hyperbola.schemes
EXTRA_DIST=pages.map hyperbola.goad
goaddir=$(sysconfdir)/CORBA/servers
goad_DATA=hyperbola.goad
mapdatadir=$(datadir)/hyperbola/maps
mapdata_DATA=pages.map
smapdir=$(sysconfdir)/nautilus/scheme-mappings
smap_DATA=hyperbola.schemes
......@@ -182,7 +182,6 @@ make_obj(BonoboGenericFactory *Factory, const char *goad_id, gpointer closure)
gtk_container_add(GTK_CONTAINER(frame), vbox);
hview->btn_search = gnome_pixmap_button(gnome_stock_pixmap_widget(frame, GNOME_STOCK_PIXMAP_SEARCH), _("Search"));
gnome_button_can_default(GTK_BUTTON(hview->btn_search), TRUE);
gtk_signal_connect(GTK_OBJECT(hview->btn_search), "clicked", do_search, hview);
gtk_box_pack_start(GTK_BOX(vbox), hview->btn_search, FALSE, FALSE, GNOME_PAD);
......
......@@ -26,11 +26,13 @@
#include "nautilus-icons-view-icon-item.h"
#include <math.h>
#include <string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libart_lgpl/art_rgb_pixbuf_affine.h>
#include <libgnomeui/gnome-canvas-util.h>
#include "gnome-icon-container-private.h"
#include "nautilus-gtk-macros.h"
#include "nautilus-string.h"
/* Private part of the NautilusIconsViewIconItem structure */
struct _NautilusIconsViewIconItemDetails {
......
......@@ -26,11 +26,13 @@
#include "nautilus-icons-view-icon-item.h"
#include <math.h>
#include <string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libart_lgpl/art_rgb_pixbuf_affine.h>
#include <libgnomeui/gnome-canvas-util.h>
#include "gnome-icon-container-private.h"
#include "nautilus-gtk-macros.h"
#include "nautilus-string.h"
/* Private part of the NautilusIconsViewIconItem structure */
struct _NautilusIconsViewIconItemDetails {
......
......@@ -26,11 +26,13 @@
#include "nautilus-icons-view-icon-item.h"
#include <math.h>
#include <string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libart_lgpl/art_rgb_pixbuf_affine.h>
#include <libgnomeui/gnome-canvas-util.h>
#include "gnome-icon-container-private.h"
#include "nautilus-gtk-macros.h"
#include "nautilus-string.h"
/* Private part of the NautilusIconsViewIconItem structure */
struct _NautilusIconsViewIconItemDetails {
......
......@@ -34,31 +34,6 @@
#include <limits.h>
#include <ctype.h>
typedef struct {
enum { MAP_COMPONENT, MAP_TRANSFORM } type;
union {
char *component_iid;
char *transform_info;
} u;
char *output_mimetype;
} SchemeMapping;
static GHashTable *scheme_mappings = NULL;
static void
nautilus_navinfo_add_mapping(const char *scheme, int type, const char *data, const char *mimetype)
{
SchemeMapping *ent;
ent = g_new0(SchemeMapping, 1);
ent->type = type;
ent->u.component_iid = g_strdup(data);
ent->output_mimetype = g_strdup(mimetype);
g_hash_table_insert(scheme_mappings, g_strdup(scheme), ent);
}
static NautilusViewIdentifier *
nautilus_view_identifier_new (const char *iid, const char *name)
{
......@@ -85,149 +60,6 @@ nautilus_view_identifier_free (NautilusViewIdentifier *identifier)
}
}
static void
navinfo_read_map_file(const char *fn)
{
FILE *fh;
char aline[LINE_MAX];
fh = fopen(fn, "r");
if(!fh)
return;
while(fgets(aline, sizeof(aline), fh))
{
char *sname, *type, *mimetype, *data;
int typeval;
if(isspace(aline[0]) || aline[0] == '#')
continue;
sname = strtok(aline, " \t");
type = strtok(NULL, " \t");
mimetype = strtok(NULL, " \t");
data = strtok(NULL, "\n");
if(!sname || !type || !mimetype || !data)
continue;
if(!strcasecmp(type, "component"))
typeval = MAP_COMPONENT;
else if(!strcasecmp(type, "transform"))
typeval = MAP_TRANSFORM;
else
{
g_warning("Unrecognized scheme mapping type %s", type);
continue;
}
if(!strcasecmp(mimetype, "NULL"))
mimetype = NULL;
nautilus_navinfo_add_mapping(sname, typeval, data, mimetype);
}
fclose(fh);
}
static void
navinfo_load_mappings(char *dir)
{
DIR *dirh;
struct dirent *dent;
dirh = opendir(dir);
if(!dirh)
goto out;
readdir(dirh);
readdir(dirh);
while((dent = readdir(dirh))) {
char full_name[PATH_MAX];
g_snprintf(full_name, sizeof(full_name), "%s/%s", dir, dent->d_name);
navinfo_read_map_file(full_name);
}
closedir(dirh);
out:
g_free(dir);
}
static gboolean
my_notify_when_ready(gpointer data)
{
NautilusNavigationInfo *navi = data;
navi->notify_tag = 0;
navi->notify_ready(navi, navi->data);
return FALSE;
}
void
nautilus_navinfo_init(void)
{
GSList *dirs = NULL;
if(!scheme_mappings)
scheme_mappings = g_hash_table_new(g_str_hash, g_str_equal);
#if 0
gnome_file_locate(gnome_file_domain_config, "nautilus/scheme-mappings", TRUE, &dirs);
#else
{
char *ctmp;
ctmp = gnome_config_file("nautilus/scheme-mappings");
if(ctmp)
dirs = g_slist_append(NULL, ctmp);
}
#endif
g_slist_foreach(dirs, (GFunc)navinfo_load_mappings, NULL);
g_slist_free(dirs); /* The contents are already freed by navinfo_load_mappings */
}
static void
nautilus_navinfo_map(NautilusNavigationInfo *navinfo)
{
SchemeMapping *mapping;
char scheme[128], *ctmp;
g_assert(scheme_mappings);
ctmp = strchr(navinfo->navinfo.requested_uri, ':');
if(!ctmp)
goto out;
g_snprintf(scheme, sizeof(scheme), "%.*s", (int)(ctmp - navinfo->navinfo.requested_uri), navinfo->navinfo.requested_uri);
mapping = g_hash_table_lookup(scheme_mappings, scheme);
if(!mapping)
goto out;
switch(mapping->type)
{
case MAP_COMPONENT:
navinfo->navinfo.actual_uri = g_strdup_printf("component:%s", mapping->u.component_iid);
break;
case MAP_TRANSFORM:
navinfo->navinfo.actual_uri = g_strdup_printf(mapping->u.transform_info,
ctmp+1, ctmp+1, ctmp+1, /* hello, lame hack! :) */
ctmp+1, ctmp+1, ctmp+1);
break;
}
navinfo->navinfo.content_type = g_strdup(mapping->output_mimetype);
return;
out:
navinfo->navinfo.actual_uri = g_strdup(navinfo->navinfo.requested_uri);
}
static void
nautilus_navinfo_append_globals(gpointer value, gpointer data)
{
......@@ -236,53 +68,24 @@ nautilus_navinfo_append_globals(gpointer value, gpointer data)
*target = g_slist_prepend(*target, g_strdup(value));
}
guint
nautilus_navinfo_new(Nautilus_NavigationRequestInfo *nri,
Nautilus_NavigationInfo *old_navinfo,
NautilusNavigationInfoFunc notify_when_ready,
gpointer notify_data)
static void
my_notify_when_ready(GnomeVFSAsyncHandle *ah, GnomeVFSResult result,
GnomeVFSFileInfo *vfs_fileinfo,
gpointer data)
{
const char *meta_keys[] = {"icon-filename", NULL};
NautilusNavigationInfo *navinfo;
navinfo = g_new0(NautilusNavigationInfo, 1);
navinfo->notify_ready = notify_when_ready;
navinfo->data = notify_data;
NautilusNavigationInfo *navinfo = data;
NautilusNavigationInfoFunc notify_ready = navinfo->notify_ready;
gpointer notify_ready_data = navinfo->data;
if(old_navinfo)
{
navinfo->navinfo.referring_uri = old_navinfo->requested_uri;
navinfo->navinfo.actual_referring_uri = old_navinfo->actual_uri;
navinfo->navinfo.referring_content_type = old_navinfo->content_type;
}
navinfo->navinfo.requested_uri = g_strdup(nri->requested_uri);
navinfo->ah = NULL;
nautilus_navinfo_map(navinfo);
if(!navinfo->navinfo.content_type) /* May have already been filed in by nautilus_navinfo_map() */
if(result != GNOME_VFS_OK)
{
GnomeVFSFileInfo *vfs_fileinfo;
GnomeVFSResult res;
vfs_fileinfo = gnome_vfs_file_info_new();
res = gnome_vfs_get_file_info(navinfo->navinfo.actual_uri,
vfs_fileinfo,
GNOME_VFS_FILE_INFO_GETMIMETYPE
|GNOME_VFS_FILE_INFO_FOLLOWLINKS,
meta_keys);
if(res != GNOME_VFS_OK)
{
gnome_vfs_file_info_unref(vfs_fileinfo);
nautilus_navinfo_free(navinfo); navinfo = NULL;
goto out;
}
navinfo->navinfo.content_type = g_strdup(gnome_vfs_file_info_get_mime_type(vfs_fileinfo));
gnome_vfs_file_info_unref(vfs_fileinfo);
nautilus_navinfo_free(navinfo); navinfo = NULL;
goto out;
}
navinfo->navinfo.content_type = g_strdup(gnome_vfs_file_info_get_mime_type(vfs_fileinfo));
/* Given a content type and a URI, what do we do? Basically the "expert system" below
tries to answer that question
......@@ -344,18 +147,59 @@ nautilus_navinfo_new(Nautilus_NavigationRequestInfo *nri,
g_slist_foreach(nautilus_prefs.global_meta_views, nautilus_navinfo_append_globals, &navinfo->meta_iids);
if(notify_when_ready)
navinfo->notify_tag = g_idle_add(my_notify_when_ready, navinfo);
out:
notify_ready(navinfo, notify_ready_data);
}
void
nautilus_navinfo_init(void)
{
}
gpointer
nautilus_navinfo_new(Nautilus_NavigationRequestInfo *nri,
Nautilus_NavigationInfo *old_navinfo,
NautilusNavigationInfoFunc notify_when_ready,
gpointer notify_data)
{
GnomeVFSResult res;
const char *meta_keys[] = {"icon-filename", NULL};
NautilusNavigationInfo *navinfo;
navinfo = g_new0(NautilusNavigationInfo, 1);
navinfo->notify_ready = notify_when_ready;
navinfo->data = notify_data;
if(old_navinfo)
{
navinfo->navinfo.referring_uri = old_navinfo->requested_uri;
navinfo->navinfo.actual_referring_uri = old_navinfo->actual_uri;
navinfo->navinfo.referring_content_type = old_navinfo->content_type;
}
navinfo->navinfo.requested_uri = g_strdup(nri->requested_uri);
res = gnome_vfs_async_get_file_info(&navinfo->ah, navinfo->navinfo.requested_uri,
GNOME_VFS_FILE_INFO_GETMIMETYPE
|GNOME_VFS_FILE_INFO_FOLLOWLINKS,
meta_keys, my_notify_when_ready, navinfo);
if(res != GNOME_VFS_OK)
{
notify_when_ready(NULL, notify_data);
nautilus_navinfo_free(navinfo); navinfo = NULL;
goto out;
}
out:
return navinfo?navinfo->notify_tag:0;
return navinfo?navinfo->ah:NULL;
}
void
nautilus_navinfo_free(NautilusNavigationInfo *navinfo)
{
if(navinfo->notify_tag)
g_source_remove(navinfo->notify_tag);
if(navinfo->ah)
gnome_vfs_async_cancel(navinfo->ah);
g_slist_foreach(navinfo->content_identifiers, (GFunc)nautilus_view_identifier_free, NULL);
g_slist_free(navinfo->content_identifiers);
......
......@@ -31,10 +31,10 @@
#include "ntl-view.h"
void nautilus_navinfo_init(void);
guint nautilus_navinfo_new(Nautilus_NavigationRequestInfo *nri,
Nautilus_NavigationInfo *old_navinfo,
NautilusNavigationInfoFunc notify_when_ready,
gpointer notify_data);
gpointer nautilus_navinfo_new(Nautilus_NavigationRequestInfo *nri,
Nautilus_NavigationInfo *old_navinfo,
NautilusNavigationInfoFunc notify_when_ready,
gpointer notify_data);
void nautilus_navinfo_free(NautilusNavigationInfo *navinfo);
#endif
......@@ -84,7 +84,7 @@ struct _NautilusWindow {
enum { NW_LOADING_INFO, NW_LOADING_VIEWS, NW_IDLE } state;
guint cancel_tag;
gpointer cancel_tag;
guint action_tag;
guint16 made_changes, making_changes;
......
......@@ -84,7 +84,7 @@ struct _NautilusWindow {
enum { NW_LOADING_INFO, NW_LOADING_VIEWS, NW_IDLE } state;
guint cancel_tag;
gpointer cancel_tag;
guint action_tag;
guint16 made_changes, making_changes;
......
......@@ -84,7 +84,7 @@ struct _NautilusWindow {
enum { NW_LOADING_INFO, NW_LOADING_VIEWS, NW_IDLE } state;
guint cancel_tag;
gpointer cancel_tag;
guint action_tag;
guint16 made_changes, making_changes;
......
......@@ -379,7 +379,7 @@ nautilus_window_free_load_info(NautilusWindow *window)
window->error_views = NULL;
window->new_meta_views = NULL;
window->new_content_view = NULL;
window->cancel_tag = 0;
window->cancel_tag = NULL;
window->action_tag = 0;
window->made_changes = 0;
window->state = NW_IDLE;
......@@ -577,7 +577,12 @@ nautilus_window_update_state(gpointer data)
window->reset_to_idle = FALSE;
if(window->cancel_tag)
g_source_remove(window->cancel_tag);
{
gnome_vfs_async_cancel(window->cancel_tag);
if(window->pending_ni)
window->pending_ni->ah = NULL;
window->cancel_tag = NULL;
}
if(window->pending_ni)
{
......@@ -743,7 +748,7 @@ nautilus_window_set_state_info(NautilusWindow *window, ...)
g_message("NAVINFO_RECEIVED");
#endif
window->pending_ni = va_arg(args, NautilusNavigationInfo*);
window->cancel_tag = 0;
window->cancel_tag = NULL;
window->changes_pending = TRUE;
break;
case VIEW_ERROR:
......@@ -850,7 +855,7 @@ nautilus_window_change_location_2(NautilusNavigationInfo *navi, gpointer data)
/* Do various error checking here */
window->cancel_tag = 0;
window->cancel_tag = NULL;
if(!navi)
{
......
......@@ -84,7 +84,7 @@ struct _NautilusWindow {
enum { NW_LOADING_INFO, NW_LOADING_VIEWS, NW_IDLE } state;
guint cancel_tag;
gpointer cancel_tag;
guint action_tag;
guint16 made_changes, making_changes;
......
......@@ -50,9 +50,11 @@ struct _NautilusNavigationInfo {
GSList *content_identifiers; /* list of NautilusViewIdentifiers */
GSList *meta_iids; /* list of iid strings */
guint notify_tag;
/* internal usage */
NautilusNavigationInfoFunc notify_ready;
gpointer data;
GnomeVFSAsyncHandle *ah;
};
#endif
......@@ -34,31 +34,6 @@
#include <limits.h>
#include <ctype.h>
typedef struct {
enum { MAP_COMPONENT, MAP_TRANSFORM } type;
union {
char *component_iid;
char *transform_info;
} u;
char *output_mimetype;
} SchemeMapping;
static GHashTable *scheme_mappings = NULL;
static void
nautilus_navinfo_add_mapping(const char *scheme, int type, const char *data, const char *mimetype)
{
SchemeMapping *ent;
ent = g_new0(SchemeMapping, 1);
ent->type = type;
ent->u.component_iid = g_strdup(data);
ent->output_mimetype = g_strdup(mimetype);
g_hash_table_insert(scheme_mappings, g_strdup(scheme), ent);
}
static NautilusViewIdentifier *
nautilus_view_identifier_new (const char *iid, const char *name)
{
......@@ -85,149 +60,6 @@ nautilus_view_identifier_free (NautilusViewIdentifier *identifier)
}
}
static void
navinfo_read_map_file(const char *fn)
{
FILE *fh;
char aline[LINE_MAX];
fh = fopen(fn, "r");
if(!fh)
return;
while(fgets(aline, sizeof(aline), fh))
{
char *sname, *type, *mimetype, *data;
int typeval;
if(isspace(aline[0]) || aline[0] == '#')
continue;
sname = strtok(aline, " \t");
type = strtok(NULL, " \t");
mimetype = strtok(NULL, " \t");
data = strtok(NULL, "\n");
if(!sname || !type || !mimetype || !data)
continue;
if(!strcasecmp(type, "component"))
typeval = MAP_COMPONENT;
else if(!strcasecmp(type, "transform"))
typeval = MAP_TRANSFORM;
else
{
g_warning("Unrecognized scheme mapping type %s", type);
continue;
}
if(!strcasecmp(mimetype, "NULL"))
mimetype = NULL;
nautilus_navinfo_add_mapping(sname, typeval, data, mimetype);
}
fclose(fh);
}
static void
navinfo_load_mappings(char *dir)
{
DIR *dirh;
struct dirent *dent;
dirh = opendir(dir);
if(!dirh)
goto out;
readdir(dirh);
readdir(dirh);