midori/katze/katze-net.h
Christian Dywan 5c69e0269d Implement KatzeNet as a generic URI loader
KatzeNet can from now on be used where
URIs are handled and one would have used
libSoup and/ or local file handling as
appropriate, whereas KatzeNet does both.

Since we are displaying icons in several
places KatzeNet also provides an icon
loader that saves us from doublicating
even more code.

All bookmarks and also history items have
icons now, since KatzeNet makes that
incredibly easy.

Search engines are also using favicons
now, and right now custom icons don't
work, we still need to fix that.

Note that only icons are cached, nothing
else and the code is known to have a
hidden, hard to reproduce crasher which
may appear when an icon is newly loaded.
2008-10-24 00:09:12 +02:00

86 lines
2.6 KiB
C

/*
Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
See the file COPYING for the full license text.
*/
#ifndef __KATZE_NET_H__
#define __KATZE_NET_H__
#include "katze-utils.h"
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define KATZE_TYPE_NET \
(katze_net_get_type ())
#define KATZE_NET(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_NET, KatzeNet))
#define KATZE_NET_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_NET, KatzeNetClass))
#define KATZE_IS_NET(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_NET))
#define KATZE_IS_NET_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_NET))
#define KATZE_NET_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_NET, KatzeNetClass))
typedef struct _KatzeNet KatzeNet;
typedef struct _KatzeNetClass KatzeNetClass;
GType
katze_net_get_type (void);
KatzeNet*
katze_net_new (void);
typedef enum
{
KATZE_NET_VERIFIED,
KATZE_NET_MOVED,
KATZE_NET_NOT_FOUND,
KATZE_NET_FAILED,
KATZE_NET_DONE
} KatzeNetStatus;
typedef struct
{
gchar* uri;
KatzeNetStatus status;
gchar* mime_type;
gchar* data;
gsize length;
} KatzeNetRequest;
typedef gboolean (*KatzeNetStatusCb) (KatzeNetRequest* request,
gpointer user_data);
typedef void (*KatzeNetTransferCb) (KatzeNetRequest* request,
gpointer user_data);
void
katze_net_load_uri (KatzeNet* net,
const gchar* uri,
KatzeNetStatusCb status_cb,
KatzeNetTransferCb transfer_cb,
gpointer user_data);
typedef void (*KatzeNetIconCb) (GdkPixbuf* icon,
gpointer user_data);
GdkPixbuf*
katze_net_load_icon (KatzeNet* net,
const gchar* uri,
KatzeNetIconCb icon_cb,
GtkWidget* widget,
gpointer user_data);
G_END_DECLS
#endif /* __KATZE_NET_H__ */