~midori/midori/trunk

« back to all changes in this revision

Viewing changes to katze/midori-paths.vala

  • Committer: Tarmac
  • Author(s): Christian Dywan
  • Date: 2013-06-19 21:00:46 UTC
  • mfrom: (6216.1.10 midori.butcher)
  • Revision ID: tarmac-20130619210046-i3yv8cnkyjuafubb
Bump WebKit requirement to 1.8.3 and drop support for earlier versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
151
151
#endif
152
152
                tmp_dir = get_runtime_dir ();
153
153
            }
154
 
#if HAVE_WEBKIT_1_3_13
155
154
            if (user_data_dir != null) {
156
155
                string folder = Path.build_filename (user_data_dir, "webkit", "icondatabase");
157
156
#if HAVE_WEBKIT2
158
157
                WebKit.WebContext.get_default ().set_favicon_database_directory (folder);
159
 
#elif HAVE_WEBKIT_1_8_0
 
158
#else
160
159
                WebKit.get_favicon_database ().set_path (folder);
161
 
#elif HAVE_WEBKIT_1_3_13
162
 
                WebKit.get_icon_database ().set_path (folder);
163
160
#endif
164
161
            }
165
 
#endif
166
162
            if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "paths") == 0) {
167
163
                stdout.printf ("config: %s\ncache: %s\nuser_data: %s\ntmp: %s\n",
168
164
                               config_dir, cache_dir, user_data_dir, tmp_dir);
420
416
            assert (user_data_dir != null);
421
417
#if HAVE_WEBKIT2
422
418
            WebKit.WebContext.get_default ().get_favicon_database ().clear ();
423
 
#elif HAVE_WEBKIT_1_8_0
 
419
#else
424
420
            WebKit.get_favicon_database ().clear ();
425
 
#elif HAVE_WEBKIT_1_3_13
426
 
            WebKit.get_icon_database ().clear ();
427
421
#endif
428
422
            /* FIXME: Exclude search engine icons */
429
 
            remove_path (Path.build_filename (cache_dir, "icons"));
430
423
            remove_path (Path.build_filename (user_data_dir, "webkit", "icondatabase"));
431
424
        }
432
425
 
441
434
            /* TODO async
442
435
            var database = WebKit.WebContext.get_default ().get_favicon_database ();
443
436
            database.get_favicon.begin (uri, null); */
444
 
#elif HAVE_WEBKIT_1_8_0
 
437
#else
445
438
            Gdk.Pixbuf? pixbuf = WebKit.get_favicon_database ()
446
439
                .try_get_favicon_pixbuf (uri, icon_width, icon_height);
447
440
            if (pixbuf != null)
448
441
                return pixbuf;
449
 
#elif HAVE_WEBKIT_1_3_13
450
 
            Gdk.Pixbuf? pixbuf = WebKit.get_icon_database ().get_icon_pixbuf (uri);
451
 
            if (pixbuf != null)
452
 
                return pixbuf.scale_simple (icon_width, icon_height, Gdk.InterpType.BILINEAR);
453
 
#else
454
 
            if (Midori.URI.is_http (uri)) {
455
 
                try {
456
 
                    uint i = 8;
457
 
                    while (uri[i] != '\0' && uri[i] != '/')
458
 
                        i++;
459
 
                    string icon_uri = (uri[i] == '/')
460
 
                        ? uri.substring (0, i) + "/favicon.ico"
461
 
                        : uri + "/favicon.ico";
462
 
                    string checksum = Checksum.compute_for_string (ChecksumType.MD5, icon_uri, -1);
463
 
                    string filename = checksum + Midori.Download.get_extension_for_uri (icon_uri) ?? "";
464
 
                    string path = Path.build_filename (get_cache_dir_for_reading (), "icons", filename);
465
 
                    Gdk.Pixbuf? pixbuf = new Gdk.Pixbuf.from_file_at_size (path, icon_width, icon_height);
466
 
                    if (pixbuf != null)
467
 
                        return pixbuf;
468
 
                }
469
 
                catch (GLib.Error error) { }
470
 
            }
471
442
#endif
472
443
            if (widget != null)
473
444
                return widget.render_icon (Gtk.STOCK_FILE, Gtk.IconSize.MENU, null);