diff options
author | Raphael Graf <r@undefined.ch> | 2011-07-20 18:19:50 +0000 |
---|---|---|
committer | Raphael Graf <r@undefined.ch> | 2011-07-20 18:19:50 +0000 |
commit | f3e6db6dedca1b5e5273d33100bb307fe9742f71 (patch) | |
tree | 39c7a30654e1cca71719cb85e63897f3873697cd | |
parent | 898fb15c58a3c5b5ab99cf73c1c09456e8bb58eb (diff) | |
download | xombrero-f3e6db6dedca1b5e5273d33100bb307fe9742f71.tar.gz |
Check webkit version at compile time. Fixes FS#129.
ok marco@
-rw-r--r-- | xxxterm.c | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/xxxterm.c b/xxxterm.c index b28a561..9afe682 100644 --- a/xxxterm.c +++ b/xxxterm.c @@ -5918,15 +5918,15 @@ abort_favicon_download(struct tab *t) { DNPRINTF(XT_D_DOWNLOAD, "%s: down %p\n", __func__, t->icon_download); - if (!WEBKIT_CHECK_VERSION(1, 4, 0)) { - if (t->icon_download) { - g_signal_handlers_disconnect_by_func(G_OBJECT(t->icon_download), - G_CALLBACK(favicon_download_status_changed_cb), t->wv); - webkit_download_cancel(t->icon_download); - t->icon_download = NULL; - } else - free_favicon(t); - } +#if !WEBKIT_CHECK_VERSION(1, 4, 0) + if (t->icon_download) { + g_signal_handlers_disconnect_by_func(G_OBJECT(t->icon_download), + G_CALLBACK(favicon_download_status_changed_cb), t->wv); + webkit_download_cancel(t->icon_download); + t->icon_download = NULL; + } else + free_favicon(t); +#endif xt_icon_from_name(t, "text-html"); } @@ -5935,80 +5935,80 @@ void notify_icon_loaded_cb(WebKitWebView *wv, gchar *uri, struct tab *t) { GdkPixbuf *pb; - gchar *name_hash, file[PATH_MAX]; - struct stat sb; DNPRINTF(XT_D_DOWNLOAD, "%s %s\n", __func__, uri); if (uri == NULL || t == NULL) return; - if (WEBKIT_CHECK_VERSION(1, 4, 0)) { - /* take icon from WebKitIconDatabase */ - pb = webkit_web_view_get_icon_pixbuf(wv); - if (pb) { - xt_icon_from_pixbuf(t, pb); - g_object_unref(pb); - } else - xt_icon_from_name(t, "text-html"); - - } else if (WEBKIT_CHECK_VERSION(1, 1, 18)) { - /* download icon to cache dir */ - if (t->icon_request) { - DNPRINTF(XT_D_DOWNLOAD, "%s: download in progress\n", __func__); - return; - } +#if WEBKIT_CHECK_VERSION(1, 4, 0) + /* take icon from WebKitIconDatabase */ + pb = webkit_web_view_get_icon_pixbuf(wv); + if (pb) { + xt_icon_from_pixbuf(t, pb); + g_object_unref(pb); + } else + xt_icon_from_name(t, "text-html"); +#elif WEBKIT_CHECK_VERSION(1, 1, 18) + /* download icon to cache dir */ + gchar *name_hash, file[PATH_MAX]; + struct stat sb; - /* check to see if we got the icon in cache */ - name_hash = g_compute_checksum_for_string(G_CHECKSUM_SHA256, uri, -1); - snprintf(file, sizeof file, "%s/%s.ico", cache_dir, name_hash); - g_free(name_hash); + if (t->icon_request) { + DNPRINTF(XT_D_DOWNLOAD, "%s: download in progress\n", __func__); + return; + } - if (!stat(file, &sb)) { - if (sb.st_size > 0) { - DNPRINTF(XT_D_DOWNLOAD, "%s: loading from cache %s\n", - __func__, file); - set_favicon_from_file(t, file); - return; - } + /* check to see if we got the icon in cache */ + name_hash = g_compute_checksum_for_string(G_CHECKSUM_SHA256, uri, -1); + snprintf(file, sizeof file, "%s/%s.ico", cache_dir, name_hash); + g_free(name_hash); - /* corrupt icon so trash it */ - DNPRINTF(XT_D_DOWNLOAD, "%s: corrupt icon %s\n", - __func__, file); - unlink(file); - } - - /* create download for icon */ - t->icon_request = webkit_network_request_new(uri); - if (t->icon_request == NULL) { - DNPRINTF(XT_D_DOWNLOAD, "%s: invalid uri %s\n", - __func__, uri); + if (!stat(file, &sb)) { + if (sb.st_size > 0) { + DNPRINTF(XT_D_DOWNLOAD, "%s: loading from cache %s\n", + __func__, file); + set_favicon_from_file(t, file); return; } - t->icon_download = webkit_download_new(t->icon_request); - if (t->icon_download == NULL) - return; + /* corrupt icon so trash it */ + DNPRINTF(XT_D_DOWNLOAD, "%s: corrupt icon %s\n", + __func__, file); + unlink(file); + } - /* we have to free icon_dest_uri later */ - t->icon_dest_uri = g_strdup_printf("file://%s", file); - webkit_download_set_destination_uri(t->icon_download, - t->icon_dest_uri); - - if (webkit_download_get_status(t->icon_download) == - WEBKIT_DOWNLOAD_STATUS_ERROR) { - g_object_unref(t->icon_request); - g_free(t->icon_dest_uri); - t->icon_request = NULL; - t->icon_dest_uri = NULL; - return; - } + /* create download for icon */ + t->icon_request = webkit_network_request_new(uri); + if (t->icon_request == NULL) { + DNPRINTF(XT_D_DOWNLOAD, "%s: invalid uri %s\n", + __func__, uri); + return; + } - g_signal_connect(G_OBJECT(t->icon_download), "notify::status", - G_CALLBACK(favicon_download_status_changed_cb), t->wv); + t->icon_download = webkit_download_new(t->icon_request); + if (t->icon_download == NULL) + return; - webkit_download_start(t->icon_download); + /* we have to free icon_dest_uri later */ + t->icon_dest_uri = g_strdup_printf("file://%s", file); + webkit_download_set_destination_uri(t->icon_download, + t->icon_dest_uri); + + if (webkit_download_get_status(t->icon_download) == + WEBKIT_DOWNLOAD_STATUS_ERROR) { + g_object_unref(t->icon_request); + g_free(t->icon_dest_uri); + t->icon_request = NULL; + t->icon_dest_uri = NULL; + return; } + + g_signal_connect(G_OBJECT(t->icon_download), "notify::status", + G_CALLBACK(favicon_download_status_changed_cb), t->wv); + + webkit_download_start(t->icon_download); +#endif } void |