summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Dywan <christian@twotoasts.de>2018-07-09 14:31:56 +0200
committerChristian Dywan <christian@twotoasts.de>2018-07-09 14:31:56 +0200
commit961f439fccbd02aebeaa69ee9f052ab695971a61 (patch)
treec7a529b13a45ad147acf14a959ca97bfa3565ac4
parentb8958a437d4bfd81d30f1d78c8cf7973f8b1e569 (diff)
downloadmidori-git-961f439fccbd02aebeaa69ee9f052ab695971a61.tar.gz
Rewrite browser core completely in Vala
-rw-r--r--.bzrignore14
-rw-r--r--.gitignore7
-rw-r--r--AUTHORS79
-rw-r--r--CMakeLists.txt287
-rw-r--r--ChangeLog2
-rw-r--r--EXPAT18
-rw-r--r--GNUmakefile.in27
-rw-r--r--HACKING181
-rw-r--r--README10
-rw-r--r--TODO65
-rw-r--r--TRANSLATE45
-rw-r--r--cmake/FindConvert.cmake19
-rw-r--r--cmake/GIR.cmake38
-rw-r--r--cmake/GLibHelpers.cmake71
-rw-r--r--cmake/GtkDoc.cmake61
-rw-r--r--config.h.in21
-rw-r--r--config/CMakeLists.txt23
-rw-r--r--config/extensions/adblock/config2
-rw-r--r--config/search36
-rwxr-xr-xconfigure83
-rw-r--r--core/CMakeLists.txt96
-rw-r--r--core/about.vala21
-rw-r--r--core/app.vala117
-rw-r--r--core/browser.vala345
-rw-r--r--core/clear-private-data.vala93
-rw-r--r--core/completion.vala89
-rw-r--r--core/database.vala (renamed from midori/midori-database.vala)328
-rw-r--r--core/download-button.vala122
-rw-r--r--core/favicon.vala55
-rw-r--r--core/history.vala44
-rw-r--r--core/loggable.vala42
-rw-r--r--core/main.vala (renamed from extensions/feed-panel/feed-rss.h)20
-rw-r--r--core/network-check.vala34
-rw-r--r--core/statusbar.vala26
-rw-r--r--core/suggestion-row.vala81
-rw-r--r--core/switcher.vala52
-rw-r--r--core/tab.vala167
-rw-r--r--core/tally.vala89
-rw-r--r--core/urlbar.vala320
-rw-r--r--data/CMakeLists.txt36
-rw-r--r--data/about.css100
-rw-r--r--data/adblock.list55
-rw-r--r--data/adblock/element_hider.js35
-rw-r--r--data/autosuggestcontrol.css14
-rw-r--r--data/autosuggestcontrol.js322
-rw-r--r--data/bookmarks/Create.sql91
-rw-r--r--data/bookmarks/Import_old_db_bookmarks.sql6
-rw-r--r--data/error.html30
-rw-r--r--data/faq.css149
-rw-r--r--data/faq.html1256
-rw-r--r--data/flummi/Create.sql6
-rw-r--r--data/forms/Create.sql6
-rw-r--r--data/gtk3.css52
-rw-r--r--data/logo-shade.svg150
-rw-r--r--data/main.rc (renamed from data/midori.rc)0
-rw-r--r--data/midori-private.desktop.in15
-rw-r--r--data/midori.appdata.xml.in6
-rw-r--r--data/midori.desktop.in12
-rw-r--r--data/midori.swfbin652 -> 0 bytes
-rw-r--r--data/nojs/nojs-statusicon-allowed.pngbin444 -> 0 bytes
-rw-r--r--data/nojs/nojs-statusicon-denied.pngbin605 -> 0 bytes
-rw-r--r--data/nojs/nojs-statusicon-mixed.pngbin630 -> 0 bytes
-rw-r--r--data/notes/Create.sql8
-rw-r--r--data/speeddial-head.html351
-rw-r--r--data/tabby/Create.sql33
-rw-r--r--data/tabby/Update1.sql4
-rw-r--r--docs/api/CMakeLists.txt14
-rw-r--r--extensions/CMakeLists.txt134
-rw-r--r--extensions/about.vala373
-rw-r--r--extensions/adblock/config.vala146
-rw-r--r--extensions/adblock/element.vala36
-rw-r--r--extensions/adblock/extension.vala872
-rw-r--r--extensions/adblock/filter.vala52
-rw-r--r--extensions/adblock/keys.vala47
-rw-r--r--extensions/adblock/options.vala32
-rw-r--r--extensions/adblock/pattern.vala26
-rw-r--r--extensions/adblock/subscriptions.vala404
-rw-r--r--extensions/adblock/updater.vala158
-rw-r--r--extensions/adblock/whitelist.vala30
-rw-r--r--extensions/adblock/widgets.vala292
-rw-r--r--extensions/addons.c1935
-rw-r--r--extensions/apps.vala544
-rw-r--r--extensions/colorful-tabs.c271
-rw-r--r--extensions/cookie-manager/cookie-manager-page.c1159
-rw-r--r--extensions/cookie-manager/cookie-manager-page.h49
-rw-r--r--extensions/cookie-manager/cookie-manager.c345
-rw-r--r--extensions/cookie-manager/cookie-manager.h50
-rw-r--r--extensions/cookie-manager/main.c45
-rw-r--r--extensions/cookie-permissions/cookie-permission-manager-preferences-window.c931
-rw-r--r--extensions/cookie-permissions/cookie-permission-manager-preferences-window.h55
-rw-r--r--extensions/cookie-permissions/cookie-permission-manager.c1126
-rw-r--r--extensions/cookie-permissions/cookie-permission-manager.h72
-rw-r--r--extensions/cookie-permissions/main.c76
-rw-r--r--extensions/copy-tabs.c107
-rw-r--r--extensions/delayed-load.vala63
-rw-r--r--extensions/devpet.vala270
-rw-r--r--extensions/domain-keys.vala72
-rw-r--r--extensions/external-download-manager.vala366
-rw-r--r--extensions/feed-panel/feed-atom.c334
-rw-r--r--extensions/feed-panel/feed-atom.h25
-rw-r--r--extensions/feed-panel/feed-panel.c851
-rw-r--r--extensions/feed-panel/feed-panel.h51
-rw-r--r--extensions/feed-panel/feed-parse.c275
-rw-r--r--extensions/feed-panel/feed-parse.h85
-rw-r--r--extensions/feed-panel/feed-rss.c272
-rw-r--r--extensions/feed-panel/katze-net.c214
-rw-r--r--extensions/feed-panel/katze-net.h71
-rw-r--r--extensions/feed-panel/main.c512
-rw-r--r--extensions/flummi.vala94
-rw-r--r--extensions/formhistory/formhistory-frontend.h64
-rw-r--r--extensions/formhistory/formhistory-gdom-frontend.c507
-rw-r--r--extensions/formhistory/formhistory.c668
-rw-r--r--extensions/history-list.vala665
-rw-r--r--extensions/mouse-gestures.c535
-rw-r--r--extensions/nojs/README.md1
-rw-r--r--extensions/nojs/main.c79
-rw-r--r--extensions/nojs/nojs-preferences.c1022
-rw-r--r--extensions/nojs/nojs-preferences.h55
-rw-r--r--extensions/nojs/nojs-view.c807
-rw-r--r--extensions/nojs/nojs-view.h71
-rw-r--r--extensions/nojs/nojs.c1044
-rw-r--r--extensions/nojs/nojs.h89
-rw-r--r--extensions/notes.vala459
-rw-r--r--extensions/nsplugin-manager.vala71
-rw-r--r--extensions/open-with.vala846
-rw-r--r--extensions/shortcuts.c322
-rw-r--r--extensions/status-clock.c179
-rw-r--r--extensions/statusbar-features.c267
-rw-r--r--extensions/tab-panel.c680
-rw-r--r--extensions/tabby.vala802
-rw-r--r--extensions/tabs-minimized.c87
-rw-r--r--extensions/tabs2one.c410
-rw-r--r--extensions/toolbar-editor.c640
-rw-r--r--extensions/transfers.vala583
-rw-r--r--extensions/webmedia-now-playing.vala148
-rw-r--r--gir/CMakeLists.txt15
-rw-r--r--gresource.xml28
-rw-r--r--icons/16x16/categories/extension.pngbin780 -> 0 bytes
-rw-r--r--icons/16x16/status/internet-news-reader.pngbin832 -> 0 bytes
-rw-r--r--icons/22x22/categories/extension.pngbin1105 -> 0 bytes
-rw-r--r--icons/22x22/status/internet-news-reader.pngbin1249 -> 0 bytes
-rw-r--r--icons/24x24/status/adblock-blocked.svg174
-rw-r--r--icons/24x24/status/adblock-disabled.svg174
-rw-r--r--icons/24x24/status/adblock-enabled.svg537
-rw-r--r--icons/CMakeLists.txt13
-rw-r--r--icons/icon-theme.cachebin412 -> 0 bytes
-rw-r--r--icons/index.theme20
-rw-r--r--icons/scalable/categories/extension.svg199
-rw-r--r--icons/scalable/status/internet-news-reader.svg280
-rw-r--r--katze/gtk3-compat.c243
-rw-r--r--katze/gtk3-compat.h93
-rw-r--r--katze/katze-array.c580
-rw-r--r--katze/katze-array.h157
-rw-r--r--katze/katze-arrayaction.c928
-rw-r--r--katze/katze-arrayaction.h59
-rw-r--r--katze/katze-cellrenderercomboboxtext.c495
-rw-r--r--katze/katze-cellrenderercomboboxtext.h58
-rw-r--r--katze/katze-http-auth.c464
-rw-r--r--katze/katze-http-auth.h42
-rw-r--r--katze/katze-item.c862
-rw-r--r--katze/katze-item.h153
-rw-r--r--katze/katze-preferences.c393
-rw-r--r--katze/katze-preferences.h70
-rw-r--r--katze/katze-separatoraction.vala28
-rw-r--r--katze/katze-utils.c1169
-rw-r--r--katze/katze-utils.h143
-rw-r--r--katze/katze.h28
-rw-r--r--katze/katze.vapi47
-rw-r--r--katze/midori-hsts.vala211
-rw-r--r--katze/midori-paths.vala491
-rw-r--r--katze/midori-uri.vala338
-rw-r--r--midori/CMakeLists.txt86
-rw-r--r--midori/main.c448
-rw-r--r--midori/marshal.list15
-rw-r--r--midori/midori-app.c1315
-rw-r--r--midori/midori-app.h108
-rw-r--r--midori/midori-array.c1126
-rw-r--r--midori/midori-array.h42
-rw-r--r--midori/midori-bookmarks-db.c1151
-rw-r--r--midori/midori-bookmarks-db.h79
-rw-r--r--midori/midori-bookmarksdatabase.vala100
-rw-r--r--midori/midori-browser.c7527
-rw-r--r--midori/midori-browser.h199
-rw-r--r--midori/midori-completion.vala199
-rw-r--r--midori/midori-contextaction.vala146
-rw-r--r--midori/midori-dialog.vala147
-rw-r--r--midori/midori-download.vala439
-rw-r--r--midori/midori-extension.c1259
-rw-r--r--midori/midori-extension.h153
-rw-r--r--midori/midori-extensions-column.vala14
-rw-r--r--midori/midori-frontend.c637
-rw-r--r--midori/midori-frontend.h47
-rw-r--r--midori/midori-history.c78
-rw-r--r--midori/midori-history.h27
-rw-r--r--midori/midori-historycompletion.vala66
-rw-r--r--midori/midori-historydatabase.vala145
-rw-r--r--midori/midori-locationaction.c1920
-rw-r--r--midori/midori-locationaction.h92
-rw-r--r--midori/midori-notebook.vala576
-rw-r--r--midori/midori-panedaction.vala83
-rw-r--r--midori/midori-panel.c981
-rw-r--r--midori/midori-panel.h76
-rw-r--r--midori/midori-platform.h40
-rw-r--r--midori/midori-preferences.c637
-rw-r--r--midori/midori-preferences.h64
-rw-r--r--midori/midori-privatedata.c468
-rw-r--r--midori/midori-privatedata.h43
-rw-r--r--midori/midori-searchaction.c1721
-rw-r--r--midori/midori-searchaction.h100
-rw-r--r--midori/midori-searchcompletion.vala75
-rw-r--r--midori/midori-session.c387
-rw-r--r--midori/midori-session.h33
-rw-r--r--midori/midori-settings.vala193
-rw-r--r--midori/midori-speeddial.vala426
-rw-r--r--midori/midori-stock.h39
-rw-r--r--midori/midori-tab.vala296
-rw-r--r--midori/midori-view.c5052
-rw-r--r--midori/midori-view.h268
-rw-r--r--midori/midori-viewable.vala23
-rw-r--r--midori/midori-viewcompletion.vala98
-rw-r--r--midori/midori-websettings.c1674
-rw-r--r--midori/midori-websettings.h204
-rw-r--r--midori/midori-window.vala248
-rw-r--r--midori/midori.h40
-rw-r--r--midori/midori.vapi295
-rw-r--r--midori/sokoke.c1021
-rw-r--r--midori/sokoke.h122
-rw-r--r--midori/webkitgtk-3.0.deps6
-rw-r--r--midori/webkitgtk-3.0.vapi841
-rw-r--r--panels/midori-bookmarks.c1423
-rw-r--r--panels/midori-bookmarks.h42
-rw-r--r--panels/midori-extensions.c544
-rw-r--r--panels/midori-extensions.h45
-rw-r--r--panels/midori-history.c994
-rw-r--r--panels/midori-history.h40
-rw-r--r--po/CMakeLists.txt4
-rw-r--r--po/POTFILES.in136
-rw-r--r--snap/snapcraft.yaml31
-rw-r--r--tests/CMakeLists.txt23
-rw-r--r--tests/actions.vala67
-rw-r--r--tests/app.vala93
-rw-r--r--tests/bookmarks.c206
-rw-r--r--tests/browser.c219
-rw-r--r--tests/completion.vala202
-rw-r--r--tests/database.vala58
-rw-r--r--tests/download.vala166
-rw-r--r--tests/extensions.c278
-rw-r--r--tests/hsts.vala32
-rwxr-xr-xtests/license.sh5
-rw-r--r--tests/magic-uri.c470
-rw-r--r--tests/notebook.vala33
-rw-r--r--tests/properties.c117
-rw-r--r--tests/searchaction.vala71
-rw-r--r--tests/speeddial.vala106
-rw-r--r--tests/tab.vala306
-rw-r--r--toolbars/midori-findbar.c331
-rw-r--r--toolbars/midori-findbar.h65
-rwxr-xr-xtools/check-style173
-rwxr-xr-xtools/midori-dev87
-rwxr-xr-xtools/release57
-rwxr-xr-xtools/sanitize_bzr.sh75
-rwxr-xr-xtools/screenshot83
-rw-r--r--ui/about.ui9
-rw-r--r--ui/browser.ui218
-rw-r--r--ui/clear-private-data.ui101
-rw-r--r--ui/download-button.ui55
-rw-r--r--ui/download-row.ui69
-rw-r--r--ui/menus.ui56
-rw-r--r--ui/network-check.ui22
-rw-r--r--ui/shortcuts.ui167
-rw-r--r--ui/suggestion-row.ui46
-rw-r--r--ui/tab.ui32
-rw-r--r--ui/tally.ui52
-rw-r--r--ui/urlbar.ui25
-rw-r--r--vapi/config.vapi7
-rw-r--r--vapi/javascriptcoregtk-4.0.vapi150
-rw-r--r--vapi/webkit2gtk-4.0.vapi (renamed from midori/webkit2gtk-4.0.vapi)282
-rw-r--r--vapi/webkit2gtk-web-extension-4.0.vapi (renamed from midori/webkit2gtk-web-extension-4.0.vapi)925
-rwxr-xr-xwin32/makedist/makedist.midori394
-rw-r--r--win32/makedist/midori.icobin36660 -> 0 bytes
-rw-r--r--win32/makedist/midori.nsi626
-rwxr-xr-xwin32/makedist/win32-release64
-rw-r--r--win32/old/README_OPENSUSE_MINGW.txt92
-rwxr-xr-xwin32/old/x86-mingw32-opensuse/crossconfig.sh29
-rwxr-xr-xwin32/old/x86-mingw32-opensuse/install.sh94
-rw-r--r--win32/old/x86-mingw32-opensuse/packages.list89
286 files changed, 4250 insertions, 78127 deletions
diff --git a/.bzrignore b/.bzrignore
deleted file mode 100644
index c2f23a30..00000000
--- a/.bzrignore
+++ /dev/null
@@ -1,14 +0,0 @@
-Makefile
-
-.waf-*
-.lock-wscript
-_build
-
-po/.intltool-merge-cache
-po/LINGUAS
-po/POTFILES
-po/stamp-it
-po/*.gmo
-
-packages.version
-GNUmakefile
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..ec1c9e39
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+_build
+
+snap/.snapcraft
+parts
+stage
+prime
+*.snap
diff --git a/AUTHORS b/AUTHORS
deleted file mode 100644
index 31b6fdd3..00000000
--- a/AUTHORS
+++ /dev/null
@@ -1,79 +0,0 @@
-This file is licensed under the terms of the expat license, see the file EXPAT.
-
-Developers:
- Christian Dywan <christian@twotoasts.de>
-
-Contributors:
- Ori Bernstein <ori@eigenstate.org>
- Przemek Sitek <el.pescado@gazeta.pl>
- Enrico Tröger <enrico.troeger@uvena.de>
- Arnaud Renevier <arenevier@fdn.fr>
- Dale Whittaker <dayul@users.sf.net>
- Anders F Björklund <afb@macports.org>
- Alexander Hesse <alex@phicode.de>
- Brian Vuyk <brian@brianvuyk.com>
- Nick Schermer <nick@xfce.org>
- Matthias Kruk <mkruk@matthiaskruk.de>
- Johannes Reinhardt <jreinhardt@ist-dein-freund.de>
- Jean-François Guchens <zcx000@gmail.com>
- Jérôme Geulfucci <jeromeg@xfce.org>
- Alexander Butenko <a.butenka@gmail.com>
-
-Graphics:
- extension: Nancy Runge <nancy@twotoasts.de>
- midori: Nancy Runge <nancy@twotoasts.de>
- news-feed: Nancy Runge <nancy@twotoasts.de>
- logo-shade: Nancy Runge <nancy@twotoasts.de>
-
-Translations:
- cs: David Stancl <dstancl@dstancl.cz>
- da: Per Kongstad <p_kongstad@op.pl>
- de: Enrico Tröger <enrico.troeger@uvena.de>
- de: Christian Dywan <christian@twotoasts.de>
- el: Evaggelos Balaskas <ebalaskas@ebalaskas.gr>
- en_GB: Bastien Nocera <hadess@hadess.net>
- en_GB: Abigail Brady <morwen@evilmagic.org>
- es: Miguel Anxo Bouzada <mbouzada@gmail.com>
- es: Antonio Sanchez <introlinux@gmail.com>
- es: Christian Dywan <christian@twotoasts.de>
- es: Elega <elega@elega.com.ar>
- et: Kristjan Siimson <epost@ksiimson.se>
- fi: Elias Julkunen <elias.julkunen@gmail.com>
- fr: Christian Dywan <christian@twotoasts.de>
- fr: Adrien Nader <camaradetux@gmail.com>
- fr: Robert-André Mauchin <zebob.m@pengzone.org>
- fr: Pascal Gervais <pggervais@yahoo.ca>
- fr: Jérôme Geulfucci <jeromeg@xfce.org>
- gl: Miguel Anxo Bouzada <mbouzada@gmail.com>
- he: Shlomi Israel <sijproject@gmail.com>
- hu: SZERVÁC Attila <sas@321.hu>
- id: Andhika Padmawan <andhika.padmawan@gmail.com>
- it: Sergio Durzu <sergio.durzu@ildeposito.org>
- it: Luca Perri <kurama_luka@yahoo.it>
- ja: Masato Hashimoto <cabezon.hashimoto@gmail.com>
- nl: Vincent Tunru <projects@vinnl.nl>
- no: Olav Andreas Lindekleiv <olalinde@gmail.com>
- pl: Przemysław Sitek <el.pescado@gazeta.pl>
- pl: Lukasz Romanowicz <romanowicz88@gmail.com>
- pt_PT: Sérgio Marques <smarquespt@gmail.com>
- pt_BR: Rogério Brito <rbrito@ime.usp.br>
- ro: Igor Știrbu <igor.stirbu@gmail.com>
- ro: Mișu Moldovan <dumol@gnome.ro>
- ru: Troitskiy Nikita <niktr@mail.ru>
- ru: Anton Shestakov <engored@ya.ru>
- sk: Robert Hartl <hartl.robert@gmail.com>
- sr: Miloš Popović <gpopac@gmail.com>
- sv: Mikael Magnusson <mikachu@comhem.se>
- tr: Mirat Can Bayrak <MiratCanBayrak@gmail.com>
- tr: Gökmen Görgen <gkmngrgn@gmail.com>
- uk: Dmitry Nikitin <luckas_fb@mail.ru>
- zh_CN: Stanley Zhang <yatzhang@gmail.com>
- zh_TW: Wei-Lun Chao <william.chao@ossii.com.tw>
-
-Code from other projects:
- GTK+/ GdkPixbuf, Matthias Clasen <mclasen@redhat.com>
- GTK+/ GtkEntry, Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- GTK+/ GtkToolbar, Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- Modified by the GTK+ Team and others 1997-2000
- libSoup/ CookieJarText, Copyright (C) 2008 Xan Lopez <xan@gnome.org>, Dan Winship <danw@gnome.org>
- libSylph, Copyright 1999-2008 Hiroyuki Yamamoto, Copyright 2006-2009 Enrico Tröger <enrico.troeger@uvena.de>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 02cb7fa1..7b67aa51 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,294 +1,83 @@
-# Copyright (C) 2013 Christian Dywan <christian@twotoasts.de>
+# Copyright (C) 2013-2018 Christian Dywan <christian@twotoasts.de>
-cmake_minimum_required(VERSION 2.6)
-cmake_policy(VERSION 2.6)
-# Work-around a bug in the included FindGettext fixed with 2.8.8
-# See http://www.cmake.org/pipermail/cmake-commits/2012-February/012117.html
-if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_LESS "2.8.8")
- cmake_policy(SET CMP0002 OLD)
-endif ()
-project(midori C)
-add_definitions("-DPACKAGE_NAME=\"${CMAKE_PROJECT_NAME}\"")
-add_definitions("-DPACKAGE_BUGREPORT=\"https://bugs.launchpad.net/midori\"")
+cmake_minimum_required(VERSION 3.0)
+cmake_policy(VERSION 3.0)
-set(VERSION 0.5.11)
-add_definitions("-DMIDORI_VERSION_SUFFIX=\"${VERSION}\"")
-
-string(REPLACE "." ";" VERSION_LIST ${VERSION})
-LIST(GET VERSION_LIST 0 MIDORI_MAJOR_VERSION)
-add_definitions("-DMIDORI_MAJOR_VERSION=${MIDORI_MAJOR_VERSION}")
-LIST(GET VERSION_LIST 1 MIDORI_MINOR_VERSION)
-add_definitions("-DMIDORI_MINOR_VERSION=${MIDORI_MINOR_VERSION}")
-LIST(GET VERSION_LIST 2 MIDORI_MICRO_VERSION)
-add_definitions("-DMIDORI_MICRO_VERSION=${MIDORI_MICRO_VERSION}")
+# dh_translations detects this if there's no variable used
+set (GETTEXT_PACKAGE "midori")
+add_definitions("-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\"")
+project(${GETTEXT_PACKAGE} C)
+set(PROJECT_BUGS https://github.com/midori-browser/core/issues)
+set(PROJECT_WEBSITE http://www.midori-browser.org)
+set(CORE_VERSION 0.6.0)
-execute_process(COMMAND "bzr" "revno"
+execute_process(COMMAND "git" "describe" "--tags"
OUTPUT_VARIABLE REVISION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (REVISION)
- set(VERSION "${VERSION}~r${REVISION}")
+ set(CORE_VERSION "${CORE_VERSION}~r${REVISION}")
# All warnings are errors in development builds
set(VALAFLAGS ${VALAFLAGS} --fatal-warnings)
- set(CFLAGS "${CFLAGS}")
+else ()
+ # No runtime type checks
+ set(VALAFLAGS ${VALAFLAGS} --disable-assert)
endif ()
-add_definitions("-DPACKAGE_VERSION=\"${VERSION}\"")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
# Disallow building during install to avoid permission problems
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1)
find_package(Vala REQUIRED)
-vala_require("0.16.0")
+vala_require("0.30.0")
set(VALAFLAGS ${VALAFLAGS}
- --enable-deprecated
--debug
+ --target-glib=2.48
)
include(GNUInstallDirs)
set(DATADIR ${CMAKE_INSTALL_FULL_DATADIR})
-add_definitions("-DMDATADIR=\"${DATADIR}\"")
-add_definitions("-DSYSCONFDIR=\"${CMAKE_INSTALL_FULL_SYSCONFDIR}\"")
-add_definitions("-DLIBDIR=\"${CMAKE_INSTALL_FULL_LIBDIR}\"")
-add_definitions("-DDOCDIR=\"${CMAKE_INSTALL_FULL_DOCDIR}\"")
-
-add_definitions("-DENABLE_NLS=1")
-add_definitions("-DLOCALEDIR=\"${CMAKE_INSTALL_FULL_LOCALEDIR}\"")
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/config.h" "/* # generated file (stub) */")
-add_definitions("-DHAVE_CONFIG_H=1")
-
-find_file (UNISTD unistd.h)
-if (UNISTD)
- add_definitions("-DHAVE_UNISTD_H")
-endif ()
-
-if (UNIX)
- find_file (SIGNAL signal.h)
- if (SIGNAL)
- add_definitions("-DHAVE_SIGNAL_H")
- endif ()
-
- find_file (EXEC_INFO execinfo.h)
- if (EXEC_INFO)
- set(VALAFLAGS ${VALAFLAGS} -D HAVE_EXECINFO_H)
- endif ()
-endif ()
-
-find_library (X11 X11)
-if (X11)
- # Pass /usr/X11R6/include for OpenBSD
- find_file (SCRNSAVER X11/extensions/scrnsaver.h /usr/X11R6/include)
- find_library (XSS Xss /usr/lib/X11R6/lib)
- if (SCRNSAVER AND XSS)
- add_definitions("-DHAVE_X11_EXTENSIONS_SCRNSAVER_H")
- set(OPTS_LIBRARIES "${OPTS_LIBRARIES};${XSS};${X11}")
- endif ()
-endif ()
-
-if (WIN32)
- set(VALAFLAGS ${VALAFLAGS} -D HAVE_WIN32)
-endif ()
-if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
- set(VALAFLAGS ${VALAFLAGS} -D HAVE_FREEBSD)
-endif ()
-
-if (${CMAKE_SYSTEM_NAME} MATCHES "DragonFly")
- set(VALAFLAGS ${VALAFLAGS} -D HAVE_DRAGONFLY)
- set(DFLY 1)
-endif ()
-
-if (APPLE)
- add_definitions("-DHAVE_OSX=1")
- set(VALAFLAGS ${VALAFLAGS} -D HAVE_OSX)
-else ()
- add_definitions("-DHAVE_OSX=0")
-endif ()
+configure_file(config.h.in config.h @ONLY)
find_package(PkgConfig)
pkg_check_modules(DEPS REQUIRED
- libxml-2.0>=2.6
sqlite3>=3.6.19
- gmodule-2.0
- gio-2.0>=2.32.3
- libsoup-gnome-2.4>=2.37.1
+ gio-2.0>=2.48.0
+ libsoup-gnome-2.4>=2.48.0
)
-add_definitions("-DHAVE_LIBXML")
-add_definitions("-DGIO_VERSION=\"${DEPS_gio-2.0_VERSION}\"")
-add_definitions("-DLIBSOUP_VERSION=\"${DEPS_libsoup-gnome-2.4_VERSION}\"")
-set(PKGS posix linux libxml-2.0 sqlite3 gmodule-2.0 gio-2.0 libsoup-2.4)
-if (${DEPS_libsoup-gnome-2.4_VERSION} VERSION_GREATER "2.40.0")
- # valac 0.16 didn't have the bindings yet
- # For consistency we need to ensure C code makes the same assumptions
- if (${VALA_VERSION} VERSION_GREATER "0.17.0")
- add_definitions("-DHAVE_LIBSOUP_2_40_0")
- set(VALAFLAGS ${VALAFLAGS} -D HAVE_LIBSOUP_2_40_0)
- endif ()
-endif ()
-if (${DEPS_libsoup-gnome-2.4_VERSION} VERSION_GREATER "2.48.0")
- add_definitions("-DHAVE_LIBSOUP_2_48_0")
- set(VALAFLAGS ${VALAFLAGS} -D HAVE_LIBSOUP_2_48_0)
-endif ()
-
-if (${DEPS_gio-2.0_VERSION} VERSION_GREATER "2.40.0" OR WIN32)
- add_definitions("-DLIBNOTIFY_VERSION=\"No\"")
-else ()
- pkg_check_modules(NOTIFY REQUIRED libnotify)
- add_definitions("-DLIBNOTIFY_VERSION=\"${NOTIFY_VERSION}\"")
- add_definitions("-DHAVE_LIBNOTIFY")
- set(OPTS_INCLUDE_DIRS "${OPTS_INCLUDE_DIRS};${NOTIFY_INCLUDE_DIRS}")
- set(OPTS_LIBRARIES "${OPTS_LIBRARIES};${NOTIFY_LIBRARIES}")
- set(PKGS ${PKGS} libnotify)
-endif ()
-
-option(USE_GTK3 "Use GTK+3" OFF)
-option(HALF_BRO_INCOM_WEBKIT2 "Serve as a guniea pig" OFF)
-option(USE_ZEITGEIST "Zeitgeist history integration" ON)
-option(USE_GRANITE "Fancy notebook and pop-overs" OFF)
-option(USE_APIDOCS "API documentation" OFF)
-option(USE_GIR "Generate GObject Introspection bindings" OFF)
-option(EXTRA_WARNINGS "Additional compiler warnings" OFF)
-
-# GTK+3 is implied here, whether set or not
-if (USE_GRANITE OR HALF_BRO_INCOM_WEBKIT2)
- set(USE_GTK3 ON)
-endif ()
-
-if (USE_GRANITE)
- pkg_check_modules(GRANITE granite>=0.2)
- set(OPTS_INCLUDE_DIRS "${OPTS_INCLUDE_DIRS};${GRANITE_INCLUDE_DIRS}")
- set(OPTS_LIBRARIES "${OPTS_LIBRARIES};${GRANITE_LIBRARIES}")
- add_definitions("-DHAVE_GRANITE")
- add_definitions("-DGRANITE_VERSION=\"${GRANITE_VERSION}\"")
- set(VALAFLAGS ${VALAFLAGS} -D HAVE_GRANITE)
- set(PKGS ${PKGS} granite)
-else ()
- add_definitions("-DGRANITE_VERSION=\"No\"")
-endif()
-
-if (USE_ZEITGEIST)
- pkg_check_modules(ZEITGEIST REQUIRED zeitgeist-2.0>=0.3.14)
- set(OPTS_INCLUDE_DIRS "${OPTS_INCLUDE_DIRS};${ZEITGEIST_INCLUDE_DIRS}")
- set(OPTS_LIBRARIES "${OPTS_LIBRARIES};${ZEITGEIST_LIBRARIES}")
- add_definitions("-DHAVE_ZEITGEIST")
- set(PKGS ${PKGS} zeitgeist-2.0)
-endif()
-
-if (WIN32)
- add_definitions("-DGCR_VERSION=\"No\"")
-else ()
- if (USE_GTK3)
- pkg_check_modules(GCR REQUIRED gcr-3>=2.32)
- else ()
- pkg_check_modules(GCR REQUIRED gcr-base-3>=2.32)
- endif ()
- add_definitions("-DGCR_VERSION=\"${GCR_VERSION}\"")
- add_definitions("-DHAVE_GCR")
- set(OPTS_INCLUDE_DIRS ${OPTS_INCLUDE_DIRS} ${GCR_INCLUDE_DIRS})
- set(OPTS_LIBRARIES ${OPTS_LIBRARIES} ${GCR_LIBRARIES})
-endif ()
-
-if (HALF_BRO_INCOM_WEBKIT2)
- pkg_check_modules(DEPS_GTK REQUIRED
- gtk+-3.0>=3.10.0
- webkit2gtk-4.0>=2.3.91
- )
- add_definitions("-DHAVE_WEBKIT2")
- add_definitions("-DGTK_VERSION=\"${DEPS_GTK_gtk+-3.0_VERSION}\"")
- add_definitions("-DWEBKIT_VERSION=\"${DEPS_GTK_webkit2gtk-4.0_VERSION}\"")
- set(PKGS ${PKGS} gtk+-3.0)
- # set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkit2gtk-web-extension-4.0.vapi")
- set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkit2gtk-4.0.vapi")
- set(VALAFLAGS ${VALAFLAGS} -D HAVE_GTK3)
- set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2)
- set(VALAFLAGS ${VALAFLAGS} -D HAVE_WEBKIT2_3_91)
-elseif (USE_GTK3)
- pkg_check_modules(DEPS_GTK REQUIRED
- gtk+-3.0>=3.10.0
- webkitgtk-3.0>=1.8.1
- javascriptcoregtk-3.0
- )
- add_definitions("-DGTK_VERSION=\"${DEPS_GTK_gtk+-3.0_VERSION}\"")
- add_definitions("-DWEBKIT_VERSION=\"${DEPS_GTK_webkitgtk-3.0_VERSION}\"")
- set(PKGS ${PKGS} gtk+-3.0)
- set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkitgtk-3.0.vapi")
- set(VALAFLAGS ${VALAFLAGS} -D HAVE_GTK3)
-else ()
- pkg_check_modules(DEPS_GTK REQUIRED
- gtk+-2.0>=2.24.0
- webkit-1.0>=1.8.1
- javascriptcoregtk-1.0
- )
- add_definitions("-DGTK_VERSION=\"${DEPS_GTK_gtk+-2.0_VERSION}\"")
- add_definitions("-DWEBKIT_VERSION=\"${DEPS_GTK_webkit-1.0_VERSION}\"")
- set(PKGS ${PKGS} gtk+-2.0)
- set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/midori/webkitgtk-3.0.vapi")
-endif ()
-set(EXTRA_VAPIS ${EXTRA_VAPIS} "${CMAKE_SOURCE_DIR}/katze/katze.vapi")
+set(PKGS sqlite3 gio-2.0 libsoup-2.4)
-# dh_translations detects this if there's no variable used
-set (GETTEXT_PACKAGE "midori")
-add_definitions("-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\"")
+pkg_check_modules(DEPS_GTK REQUIRED
+ gtk+-3.0>=3.12.0
+ webkit2gtk-4.0>=2.18
+ gcr-ui-3>=2.32
+ )
+set(PKGS ${PKGS} gtk+-3.0 libsoup-2.4 gcr-ui-3)
+set(EXTRA_VAPIS
+ ${CMAKE_SOURCE_DIR}/vapi/config.vapi
+ ${CMAKE_SOURCE_DIR}/vapi/webkit2gtk-4.0.vapi
+ ${CMAKE_SOURCE_DIR}/vapi/javascriptcoregtk-4.0.vapi)
-set(CFLAGS "${CFLAGS} -Wall -Wundef -Wno-deprecated-declarations -g")
-
-if (EXTRA_WARNINGS)
- LIST(APPEND EXTRA_CFLAGS_LIST
- -Wextra
- -Wno-unused-parameter
- -Wno-missing-field-initializers
- -Wno-comment
- -Waggregate-return
- -Wredundant-decls
- -Wshadow -Wpointer-arith -Wcast-align
- -Winline -Wformat-security -fno-common
- -Winit-self -Wundef
- -Wnested-externs
- )
- string(REPLACE ";" " " EXTRA_CFLAGS "${EXTRA_CFLAGS_LIST}")
- set(CFLAGS "${CFLAGS} ${EXTRA_CFLAGS}")
-else ()
- if (REVISION)
- set(CFLAGS "${CFLAGS} -Werror")
- endif()
-endif ()
+add_definitions("-DGCR_API_SUBJECT_TO_CHANGE")
+set(CFLAGS "${CFLAGS} -g")
# Explicitly add -fPIC for older toolchains
-set(VALA_CFLAGS "-g -fPIC")
+set(VALA_CFLAGS "-g -fPIC -w -Werror")
-# With compiler versions that can, enable exactly the non-spurious warnings
-# in Vala-generated C, otherwise disable warnings
-if ((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "5.0.0")
- OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "3.0.0"))
- set(VALA_CFLAGS "${VALA_CFLAGS} -Werror=implicit-function-declaration")
- set(VALA_CFLAGS "${VALA_CFLAGS} -Wno-incompatible-pointer-types")
- set(VALA_CFLAGS "${VALA_CFLAGS} -Wno-discarded-qualifiers")
- set(VALA_CFLAGS "${VALA_CFLAGS} -Wno-deprecated-declarations")
-else ()
- set(VALA_CFLAGS "${VALA_CFLAGS} -w")
-endif ()
+set(LIBCORE "${CMAKE_PROJECT_NAME}-core")
-set(LIBMIDORI "${CMAKE_PROJECT_NAME}-core")
+configure_file(config.h.in config.h @ONLY)
# CMake provides no uninstall target by design
add_custom_target (uninstall
COMMAND "xargs" "rm" "-v" "<" "install_manifest.txt")
-install(FILES AUTHORS COPYING ChangeLog EXPAT README DESTINATION ${CMAKE_INSTALL_DOCDIR})
+install(FILES COPYING README DESTINATION ${CMAKE_INSTALL_DOCDIR})
-add_subdirectory (midori)
-add_subdirectory (extensions)
+add_subdirectory (core)
enable_testing()
add_subdirectory (tests)
add_subdirectory (po)
add_subdirectory (icons)
add_subdirectory (data)
-add_subdirectory (config)
-
-if (USE_APIDOCS)
- add_subdirectory (docs/api)
-endif ()
-if (USE_GIR)
- add_subdirectory (gir)
-endif ()
diff --git a/ChangeLog b/ChangeLog
index 43318d2f..1b656d3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,3 @@
-This file is licensed under the terms of the expat license, see the file EXPAT.
-
v0.5.11
Add fake theme for built-in icons
* Don't truncate long speed dial titles if there's room to display them
diff --git a/EXPAT b/EXPAT
deleted file mode 100644
index 7da1ab30..00000000
--- a/EXPAT
+++ /dev/null
@@ -1,18 +0,0 @@
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/GNUmakefile.in b/GNUmakefile.in
deleted file mode 100644
index b1459a56..00000000
--- a/GNUmakefile.in
+++ /dev/null
@@ -1,27 +0,0 @@
-# Based on "http://iany.me/wiki/Makefile/" by "Ian Yang" licensed under "CC by 3.0"
-
-BUILD_FOLDER := _build
-
-CUSTOM_TARGETS := cmake
-
-# Do not try to use custom target when invoking external makefile
-EXTERNAL_TARGETS := $(filter-out $(CUSTOM_TARGETS), $(MAKECMDGOALS))
-
-# Call all targets using `Makefile` in build directory in one `make` command.
-$(or $(lastword $(EXTERNAL_TARGETS)),all):
- $(MAKE) -C $(BUILD_FOLDER) $(EXTERNAL_TARGETS)
-
-# If no targets are specified, use the dummy `all` target
-.PHONY: $(EXTERNAL_TARGETS) all
-
-# Do nothing for all targets but last. Also quiet the message "Noting to be done on xxx"
-$(filter-out $(lastword $(EXTERNAL_TARGETS)), $(EXTERNAL_TARGETS)):
- @cd .
-
-cmake: $(BUILD_FOLDER)
- cd $(BUILD_FOLDER) && cmake ..
-
-$(BUILD_FOLDER):
- mkdir $(BUILD_FOLDER)
-
-.PHONY: cmake
diff --git a/HACKING b/HACKING
index b6d35906..fa37825c 100644
--- a/HACKING
+++ b/HACKING
@@ -4,21 +4,21 @@
====== Check out the sources ======
-bzr branch lp:midori
+git clone https://github.com/midori-browser/core.git
-The development **trunk** (master, tip) is the latest iteration of the next release. Browse it online and look for other branches at http://code.launchpad.net/midori or http://bazaar.launchpad.net/~midori/midori/trunk/tarball download a tarball of the latest revision.
+The development **master** (trunk, tip) is the latest iteration of the next release. Browse it online and look for other branches.
-//The code used to be hosted in git.xfce.org/apps/midori.//
+//The code used to be hosted at lp:midori and git.xfce.org/apps/midori respectively.//
Keep your copy updated:
-bzr merge --pull
+git pull --rebase
====== Join IRC chat rooms ======
Join irc://irc.freenode.net/midori #midori on Freenode https://kiwiirc.com/client/irc.freenode.net/midori or use webchat to talk about Midori, discuss bugs and new ideas.
====== Contribute other than touching code ======
- * http://bugs.launchpad.net/midori Go through problem reports and check Unconfirmed bugs or those lacking information and mark any duplicates you spot
+ * https://github.com/midori-browser/core/issues Go through problem reports and check Unconfirmed bugs or those lacking information and mark any duplicates you spot
* https://www.bountysource.com/#trackers/130181-midori Add a bounty for a feature or bug you'd like to support
* https://translations.launchpad.net/midori/trunk/+pots/trunk Translate to your own language
* https://github.com/eustasy/midori-browser.org/issues Report website bugs
@@ -37,13 +37,10 @@ cd _build
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
make
sudo make install
-sudo gtk-update-icon-cache /usr/share/icons/hicolor
//Advanced Tip: Pass "-G Ninja" to cmake to use http://martine.github.io/ninja/ Ninja instead of make (usually packaged as ninja or ninja-build).//
-If using GTK+3 you'll want to add -DUSE_GTK3=1 to the cmake command line.
-
You can build Midori using another C Compiler for example Clang. Just
add -DCMAKE_C_COMPILER=/path/to/compiler to the cmake arguments.
Then you can build following your normal procedure. Like this:
@@ -52,39 +49,41 @@ make
Midori can be **run without being installed**.
-_build/midori/midori
+_build/midori
-You can use a **temporary folder for testing** without affecting normal settings
+====== Testing ======
-_build/midori/midori -c /tmp/midoridev
+===== Unit tests =====
You'll want to **unit test** the code if you're testing a new version or contributed your own changes:
xvfb-run make check
-Automated daily builds in Launchpad (https://launchpad.net/~elementary-os/+archive/daily ppa:elementary-os/daily and https://launchpad.net/~midori/+archive/midori-dev ppa:midori/midori-dev) run these tests as well.
-====== Debugging issues ======
-
-Testing an installed release may reveal crashers or memory corruption which require investigating from a local build and obtaining a stacktrace (backtrace, crash log).
-
-_build/midori/midori -g [OPTIONAL ARGUMENTS]
+===== Manual checklist =====
-If the problem is a warning, not a crash GLib has a handy feature
+* Browser window starts up normally, with optional URL(s) on the command line
+* Tabs have icons, a close button if there's more than one and can be switched
+* Urlbar suggests from typed search or URL, completes from history and highlights key
+* Private data can be cleared
+* Shortcuts window shows most important hotkeys
+* Download button lists on-going and finished downloads
+* javascript:alert("test"), javascript:confirm("test") and javascript:input("test") work
+* Websites can (un)toggle fullscreen mode
-env G_DEBUG=all _build/midori/midori -g
-
-For more specific debugging output, depending on the feature in question you may use
-
-env MIDORI_DEBUG=help _build/midori/midori
+====== Debugging issues ======
-Whilst -g is convenient you may want to use proper gdb:
+Testing an installed release may reveal crashers or memory corruption which require investigating from a local build and obtaining a stacktrace (backtrace, crash log).
-gdb
-file _build/midori/midori
+gdb _build/midori
run
bt
+
+If the problem is a warning, not a crash GLib has a handy feature
+
+env G_DEBUG=all gdb _build/midori
+
On Windows you can open the folder where Midori is installed and double-click gdb.exe. A black command line window should appear.
file midori.exe
@@ -95,8 +94,8 @@ bt
To verify a regression you might need to revert a particular change:
-# Revert only r6304
-bzr merge . -r 6304..6303
+# Revert only d54c7e45
+git revert d54c7e45
====== Coding style and quality ======
@@ -104,112 +103,59 @@ Midori code should in general have:
* 4 space indentation, no tabs
* Between 80 to 120 columns
- * Prefer /* */ style comments
+ * Use // or /* */ style comments
* Call variables //animal// and //animal_shelter// instead of <del>camelCase</del>
* Keep a space between functions/ keywords and round parentheses
-
-For Vala:
-
* Prefer //new Gtk.Widget ()// over //using Gtk; new Widget ()//
+ * Midori and GLib namespaces should be omitted
+ * Don't use //private// specifiers (which is the default)
* Stick to standard Vala-style curly parentheses on the same line
* Cuddled //} else {// and //} catch (Error error) {//
-For C:
-
- * Always keep { and } on their own line
-
-//Extensions may historically diverge from the standard styling on a case-by-case basis//
-
====== Committing code ======
-Tell Bazaar your name if you haven't yet
- bzr whoami "Real Name <email@address>"
+Tell Git your name if you haven't yet
+ git config user.email "<email@address>"
+ git config user.name "Real Name"
See what you did so far
- bzr diff
+ git diff
Get an overview of changed and new files
- bzr status
+ git status -u
Add new files, move/ rename or delete
- bzr add FILENAME
- bzr mv OLDFILE NEWFILE
- bzr rm FILENAME
+ git add FILENAME
+ mv OLDFILE NEWFILE
+ rm FILENAME
-Commit all current changes - Bazaar automatically picks up edited files. //If you're used to git, think of an implicit staging area.//
- bzr commit -p
+Commit all current changes, selected interactively
+ git commit -p -v
-If you have one or more related bug reports you should pass them as arguments. Once these commits are merged the bug will automatically be closed and the commit log shows clickable links to the reports.
- bzr commit -p --fixes=lp:1111999
+If you have one or more related bug reports you should mention them in the commit message. Once these commits are merged the bug will automatically be closed and the commit log shows clickable links to the reports.
+ Fixes: #123
If you've done several commits
- bzr log | less
- bzr log -p | less
+ git log
In the case you committed something wrong or want to ammend it:
- bzr uncommit
+ git reset --soft HEAD^
-If you end up with unrelated debugging code or other patches in the current changes, it's sometimes handy to temporarily clean up. //This may be seen as bzr's version of git stash.//
- bzr shelve
- bzr commit -p
- bzr unshelve
+If you end up with unrelated debugging code or other patches in the current changes, it's sometimes handy to temporarily clean up. //This may be seen as git's version of bzr shelve.//
+ git stash save
+ git commit -p -v
+ git stash apply
Remember to keep your branch updated:
- bzr merge --pull
+ git pull --rebase
-As a general rule of thumb, ''bzr help COMMAND'' gives you an explanation of any command and ''bzr help commands'' lists all available commands.
+As a general rule of thumb, ''git COMMAND --help'' gives you an explanation of any command and ''git --help -a'' lists all available commands.
-//If you're a die-hard git user, http://zyga.github.io/git-lp/ checkout git-lp to use git commands with the Bazaar repository.//
====== Push proposed changes ======
-If you haven't yet, https://launchpad.net/~/+editsshkeys check that Launchpad has your SSH key - you can create an SSH key with **Passwords and Keys** aka **Seahorse** or ''ssh-keygen -t rsa'' - and use ''bzr launchpad-login'' to make youself known to bzr locally.
-
-If you checked out trunk, and added your patch(es), just **push it under your username** in Launchpad and you can **propose it for merging into trunk**. This will automatically request a **review from other developers** who can then comment on it and provide feedback.
-
-bzr push --remember lp:~USERNAME/midori/fix-bug1120383 && bzr lp-propose-merge lp:midori
-
-lp-propose-merge command may not be working on some distributions like Arch or Fedora.
-In case you get error like //bzr: ERROR: Unable to import library "launchpadlib": No module named launchpadlib// just use Launchpad's Web UI to propose a merge.
-
-
-**What happens to all the branches?**
-
-Leave the branches alone, **approved branches are cleared automatically** by Launchpad.
-
-For larger feature branches, **use the team** in Launchpad to allow other developers to work on the code with you.
-
-bzr push --remember lp:~midori/midori/featuritis && bzr lp-propose-merge lp:midori
-
-What if I want to help out on an **existing merge request** that I can't push to?
-
-
-bzr branch ~OTHERPERSON/midori/fix-bug1120383
-cd fix-bug1120383
-# make commits
-bzr push lp:USERNAME~/midori/fix-bug1120383
-bzr lp-propose-merge ~OTHERPERSON/midori/fix-bug1120383
-
-
-Updating a branch that may be out of sync with trunk:
-
-
-bzr pull
-bzr: ERROR: These branches have diverged
-bzr merge lp:midori
-# Hand-edit conflicting changes
-bzr resolve FILENAME
-# If any conflicts remain continue fixing
-bzr commit -m 'Merge lp:midori'
-
-
-Save a little bandwidth, **branch from an existing local copy** that you keep around:
-
-
-bzr branch lp:midori midori
-bzr branch midori midori.fix-bug1120383
-cd midori.fix-bug1120383
-bzr pull lp:midori
+If you haven't yet, https://github.com/settings/keys check that GitHub has your SSH key - you can create an SSH key with **Passwords and Keys** aka **Seahorse** or ''ssh-keygen -t rsa'' - and specify Host github.com with User git in your SSH config.
+To make your own changes, just **fork** the project on GitHub, add your patch(es) and **push it under your username** on GitHub and you can **propose it for merging into master**. This will automatically request a **review from other developers** who can then comment on it and provide feedback.
====== Backwards compatibility ======
As of Midori 0.5.4 the formula is:
@@ -224,12 +170,6 @@ As of Midori 0.5.4 the formula is:
| gtk2 | 2.24.13 | 2.24.13 |
| soup | 2.38.1 | 2.40 |
| webkit | 1.8.3-1.fc17 | 1.10.0-0ubuntu1 |
-====== Midori with(out) Granite ======
-When built with Granite (-DUSE_GRANITE=1 or --enable-granite) there're a few key differences:
- * Preferences uses a http://valadoc.elementaryos.org/Granite/Granite.Widgets.StaticNotebook.html Granite.Widgets.StaticNotebook
- * URL completion styling is slightly different
- * Clear Private Data uses **Granite.Widgets.LightWindow**
- * Edit Bookmark and Security Details use http://valadoc.elementaryos.org/Granite/Granite.Widgets.PopOver.html Granite.Widgets.PopOver instead of Gtk.Window
====== Midori for Windows ======
@@ -254,7 +194,7 @@ For 32-bit builds:
mkdir _mingw32
cd _mingw32
-mingw32-cmake .. -DUSE_ZEITGEIST=0 -DUSE_GTK3=1 -DCMAKE_INSTALL_PREFIX=/usr/i686-w64-mingw32/sys-root/mingw -DCMAKE_VERBOSE_MAKEFILE=0
+mingw32-cmake .. -DCMAKE_INSTALL_PREFIX=/usr/i686-w64-mingw32/sys-root/mingw -DCMAKE_VERBOSE_MAKEFILE=0
make
sudo make install
@@ -262,7 +202,7 @@ For 64-bit builds:
mkdir _mingw64
cd _mingw64
-mingw64-cmake .. -DUSE_ZEITGEIST=0 -DUSE_GTK3=1 -DCMAKE_INSTALL_PREFIX=/usr/x86_64-w64-mingw32/sys-root/mingw -DCMAKE_VERBOSE_MAKEFILE=0
+mingw64-cmake .. -DCMAKE_INSTALL_PREFIX=/usr/x86_64-w64-mingw32/sys-root/mingw -DCMAKE_VERBOSE_MAKEFILE=0
make
sudo make install
@@ -358,15 +298,6 @@ http://www.cmake.org/files/v2.8/cmake-2.8.12.2-win32-x86.exe Installer
When installing check the installer checkbox "add to path"
-==== Bazaar ====
-http://wiki.bazaar.canonical.com/WindowsDownloads Homepage
-
-We will get 2.4 Stable Release (standalone)
-
-http://launchpad.net/bzr/2.4/2.4.2/+download/bzr-2.4.2-1-setup.exe Installer
-
-When installing check the installer checkbox "add to path"
-
==== Vala ====
http://ftp.gnome.org/pub/gnome/sources/vala/0.20/vala-0.20.0.tar.xz Source
@@ -377,7 +308,7 @@ You use msys.bat to launch a shell
====== Jargon ======
* freeze: a period of bug fixes only eg. 4/2 cycle means 4 weeks of features and 2 weeks to focus on resolving existing problems
- * MR: merge request, a branch proposed for review
+ * PR: pull request, a branch proposed for review, analogous to MR (merge request) with Bazaar
* ninja: an internal tab, usually empty label, used for taking screenshots
* fortress: user of an ancient release like 0.4.3 as found on Raspberry Pie, Debian, Ubuntu
- * katze, sokoke, tabby: API names and coincidentally cat breeds \ No newline at end of file
+ * katze, sokoke, tabby: legacy API names and coincidentally cat breeds
diff --git a/README b/README
index 8894f94a..818e3fe2 100644
--- a/README
+++ b/README
@@ -1,5 +1,3 @@
-This file is licensed under the terms of the expat license, see the file EXPAT.
-
Midori is a fast little WebKit browser with support for HTML5. It can manage
many open tabs and windows. The URL bar completes history, bookmarks, search
engines and open tabs out of the box. Web developers can use the powerful
@@ -14,15 +12,13 @@ A number of extensions are included by default:
* Managing cookies and scripts via NoJS and Cookie Security Manager.
* Switching open tabs in a vertical panel or a popup window.
-Requirements: GLib 2.32.3, GTK+ 2.24, WebkitGTK+ 1.8.1, libXML2,
- libsoup 2.27.90, sqlite 3.0, Vala 0.16, libnotify
-
-Optional: GTK+ 3.0, gcr, Granite 0.2, WebKit2GTK+ 1.11.91/ 2.0.0
+Requirements: GLib 2.48.0, GTK+ 3.12, gcr-3 2.32, WebKit2GTK+ 2.18
+ libsoup 2.48.0, sqlite 3.6.19, Vala 0.30
For installation instructions read the file HACKING.
Please report comments, suggestions and bugs to:
- https://bugs.launchpad.net/midori
+ https://github.com/midori-browser/core/issues
And join the IRC channel #midori on irc.freenode.net
diff --git a/TODO b/TODO
deleted file mode 100644
index 2743d0f3..00000000
--- a/TODO
+++ /dev/null
@@ -1,65 +0,0 @@
-This file is licensed under the terms of the expat license, see the file EXPAT.
-
-TODO:
- . Detect opensearch engines on sites: http://searchplugins.net/pluginlist.aspx
- . Request network if not connected and re-open the url on success
- . Make cookie manager horizontal if the window is wide
- . Handle SSL like SSH: confirm any cert on first connection, warn about any change in subsequent connections
- . Support @run-at document-start: http://dev.chromium.org/developers/design-documents/user-scripts
- . Show New Window icon in statusbar for new-window links
- . Validate search engine tokens
- . Easily register stock items in extensions (mouse gestures, input-mouse)
- . Show graphical error when a bookmarklet fails to run
- . Implement no_proxy, https_proxy
- . Fix icons with white background to be transparent?
- . Visually indicate that a tab is being opened even if outside the visible tabs
- . Implement live bookmarks, see http://johnbokma.com/firefox/rss-and-live-bookmarks.html
- . Add a dialog (right-cick) to Addons, to edit @include and @exclude
- . Show URI in css overlay tooltips if statusbar is hidden
- . Statusbar/ transferbar doesn't show right-click menu
- . Consider pango_layout_set_auto_dir
- . Support max-age for Flash cookies
- . Implement "Open image" which opens an image with an external application
- . Add custom actions extension; example Set Wallpaper
- . Show loading tabs in the tab panel extension
- . Switching browser window: Ctrl+Shift+PageUp/PageDown
- . Switching panel: Ctrl+Alt+PageUp/PageDown
- . Bookmark folder context menu, "Sort by Name"
- . Adblock Block image: dialog to edit regex before adding
- . Replace "disable plugins" with showing a "load plugins automatically", where unchecking that keeps a placeholder that can be clicked to play
- . Show "Type an address or keywords to search" in empty location even when focussed
- . Show "Search hostname" in (can't resolve) error page, www.heyarnold.twotoastsde == typo?
- . Allow -e Set setting or so
- . Remember if inspector was attached or not
- . Icon in empty entry to paste from clipboard
- . Show suggestions in error page, ie. missing www. or www. not existing for a domain: http://www.svcl.org/
- . Warn when closing tab with unsubmitted form
- . Always allow popups, keep hidden, show icon to ask whether to show popups
- . Make Shift + Click download the link
- . Show a loading mouse pointer
- . Export of the bookmarks file, or using one from a specific path
- . Custom context menu actions, like in Thunar or Epiphany
- . Analogus to blocked popups, blocked scripts moving layers on load (extension)
- . Statusbar icon 'cookies blocked', icon 'popups blocked'
- . Auto-group tabs by opener, with colors?
- . Mark (dogear) a selection so that it isn't cleared implicitly, multiply on one page
- . Check specific bookmarks for updates automatically (extension)
- . Mark "new" as well as "actually modified" tabs specially (even over sessions)
- . Save screenshot of a document?
- . Right-click a textbox in a search form and choose 'add to websearch'
- . Honor design principle "no warnings but undo of backups"?
- . Support widgets 1.0 spec in tool windows and standalone?
- . Protected tabs prompt when attempting to close them
- . Optional http redirection manually or on timeout via SoupMessage::restarted
- . Style: none, compatible (b/w), default, [styles], "media", ["media" styles]
- . Mouse pointer coordinates in the status bar (extension)
- . Draw rectangle with the mouse, x/y/x2/y2 in the statusbar (extension)
- . Shared bookmarks and config
- . Prevent dead tabs: download, aborted page
- . In right to left pages the scroll bar should be on the left
- . drag tab between windows
- . zeitgeist extension to add history
- . kiosk mode: http://www.twotoasts.de/bugs/index.php?do=details&task_id=605#comment2651
- . Find Inline → <key> → Open selected hyperlink
- . open selected addresses in tabs
- . scrolling by just moving the mouse pointer to the edge of the window
diff --git a/TRANSLATE b/TRANSLATE
deleted file mode 100644
index 3b7a4d73..00000000
--- a/TRANSLATE
+++ /dev/null
@@ -1,45 +0,0 @@
-This file is licensed under the terms of the expat license, see the file EXPAT.
-
-+++ Translating Midori +++
-
-The recommended tool for translating Midori is Transifex, which is what all
-Xfce projects use. It makes the life of translators and developers easier.
-That said, it is also possible to manually create or update a .po file and
-send a .po or .diff file via email or Flyspray.
-Either way the following instructions should get you started.
-
-There is no template in the repository. To create a localization template:
-
-./waf build --update-po
-
-You can use the same command in the future to update the template. It is
-recommended to do that always before you update localizations.
-
-If you want to add a new language 'aa', create it like this:
-
-cd po
-msginit -l aa_CC -o aa.po -i midori.pot
-sed -i 's/PACKAGE/midori/g' aa.po
-
-To check your language 'aa' for errors, do this:
-
-msgfmt -c --check-accelerators=_ aa.po
-
-To test your changes, run Midori like so:
-
-./waf build --run
-
-This is a convenience command that will setup localization in
-the build folder so you don't need to install translations.
-
-To run Midori in a particular language, run it like this:
-
-LANG=fr_FR.utf8 ./waf build --run
-
-As a general rule, your localization should be based off of the
-current git repository or the latest midori.pot in git.
-
-Some strings have comments, starting with 'i18n', which are meant
-to describe the role of a string to translators.
-Please don't hesitate to ask for additional descriptive comments
-for any unclear strings that you are uncertain about.
diff --git a/cmake/FindConvert.cmake b/cmake/FindConvert.cmake
deleted file mode 100644
index 8f536700..00000000
--- a/cmake/FindConvert.cmake
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright (C) 2013 Christian Dywan
-# Copyright (C) 2013 Olivier Duchateau
-
-find_program (RSVG_CONVERT rsvg-convert)
-
-if (RSVG_CONVERT)
- set (CONVERT_FOUND TRUE)
- macro (SVG2PNG filename install_destination)
- string(REPLACE "/" "_" target ${filename})
- file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${filename}")
- add_custom_target ("${target}.png" ALL
- ${RSVG_CONVERT} --keep-aspect-ratio --format=png "${CMAKE_CURRENT_SOURCE_DIR}/${filename}.svg"
- --output "${CMAKE_CURRENT_BINARY_DIR}/${filename}.png"
- )
- install (FILES "${CMAKE_CURRENT_BINARY_DIR}/${filename}.png"
- DESTINATION ${install_destination})
- endmacro (SVG2PNG filename)
-endif ()
-
diff --git a/cmake/GIR.cmake b/cmake/GIR.cmake
deleted file mode 100644
index 0fda5c8b..00000000
--- a/cmake/GIR.cmake
+++ /dev/null
@@ -1,38 +0,0 @@
-# GIR.cmake
-#
-# Macros for building Gobject Introspection bindings for Midori API
-find_program (GIR_SCANNER_BIN g-ir-scanner)
-find_program (GIR_COMPILER_BIN g-ir-compiler)
-
-if (GIR_SCANNER_BIN AND GIR_COMPILER_BIN)
-
- set (GIR_FOUND TRUE)
- set (GIR_VERSION "${MIDORI_MAJOR_VERSION}.${MIDORI_MINOR_VERSION}")
- macro (gir_build module namespace)
- add_custom_target ("g-ir-scanner_${module}" ALL
- ${GIR_SCANNER_BIN} -Imidori -I${CMAKE_SOURCE_DIR}/ -I${CMAKE_BINARY_DIR}/midori -I${CMAKE_SOURCE_DIR}/${module} -I${CMAKE_SOURCE_DIR}/toolbars -I.
- --header-only -n ${namespace} --identifier-prefix ${namespace}
- ${CMAKE_SOURCE_DIR}/${module}/${module}-*.c ${CMAKE_SOURCE_DIR}/${module}/${module}-*.h
- --pkg gtk+-2.0 --pkg webkit-1.0 --pkg gio-2.0 --pkg gobject-2.0
- --warn-all -iGObject-2.0 -iGLib-2.0 -iGtk-2.0
- --nsversion ${GIR_VERSION}
- -o ${CMAKE_CURRENT_BINARY_DIR}/${namespace}-${GIR_VERSION}.gir
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
- DEPENDS ${CMAKE_PROJECT_NAME})
- add_custom_target ("g-ir-compiler_${module}" ALL
- ${GIR_COMPILER_BIN} ${CMAKE_CURRENT_BINARY_DIR}/${namespace}-${GIR_VERSION}.gir
- --output ${CMAKE_CURRENT_BINARY_DIR}/${namespace}-${GIR_VERSION}.typelib
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
- DEPENDS g-ir-scanner_${module})
-
- endmacro (gir_build module namespace)
-
- macro (gir module namespace)
- gir_build (${module} ${namespace})
-
- install (FILES "${CMAKE_CURRENT_BINARY_DIR}/${namespace}-${GIR_VERSION}.gir"
- DESTINATION "${CMAKE_INSTALL_DATADIR}/gir-1.0/")
- install (FILES "${CMAKE_CURRENT_BINARY_DIR}/${namespace}-${GIR_VERSION}.typelib"
- DESTINATION "${CMAKE_INSTALL_LIBDIR}/girepository-1.0/")
- endmacro (gir module)
-endif ()
diff --git a/cmake/GLibHelpers.cmake b/cmake/GLibHelpers.cmake
deleted file mode 100644
index f777dd50..00000000
--- a/cmake/GLibHelpers.cmake
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright (C) 2010 David Sansome <me@davidsansome.com>
-cmake_minimum_required(VERSION 2.6)
-if(POLICY CMP0011)
- cmake_policy(SET CMP0011 NEW)
-endif(POLICY CMP0011)
-
-find_program(GLIB_MKENUMS glib-mkenums)
-find_program(GLIB_GENMARSHAL glib-genmarshal)
-
-macro(add_glib_marshal outfiles name prefix otherinclude)
- add_custom_command(
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
- COMMAND ${GLIB_GENMARSHAL} --header "--prefix=${prefix}"
- "${CMAKE_CURRENT_SOURCE_DIR}/${name}.list"
- > "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.list"
- )
- add_custom_command(
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
- COMMAND echo "\\#include \\\"${otherinclude}\\\"" > "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
- COMMAND echo "\\#include \\\"glib-object.h\\\"" >> "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
- COMMAND echo "\\#include \\\"${name}.h\\\"" >> "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
- COMMAND ${GLIB_GENMARSHAL} --body "--prefix=${prefix}"
- "${CMAKE_CURRENT_SOURCE_DIR}/${name}.list"
- >> "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.list"
- "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
- )
- list(APPEND ${outfiles} "${CMAKE_CURRENT_BINARY_DIR}/${name}.c")
-endmacro(add_glib_marshal)
-
-macro(add_glib_enumtypes_t outfiles name htemplate ctemplate)
- add_custom_command(
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
- COMMAND ${GLIB_MKENUMS}
- --template "${htemplate}"
- ${ARGN} > "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- DEPENDS ${ARGN} "${htemplate}"
- )
- add_custom_command(
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
- COMMAND ${GLIB_MKENUMS}
- --template "${ctemplate}"
- ${ARGN} > "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- DEPENDS ${ARGN} ${ctemplate}
- "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
- )
- list(APPEND ${outfiles} "${CMAKE_CURRENT_BINARY_DIR}/${name}.c")
-endmacro(add_glib_enumtypes_t)
-
-macro(add_glib_enumtypes outfiles name includeguard)
- set(htemplate "${CMAKE_CURRENT_BINARY_DIR}/${name}.h.template")
- set(ctemplate "${CMAKE_CURRENT_BINARY_DIR}/${name}.c.template")
-
- # Write the .h template
- add_custom_command(
- OUTPUT ${htemplate} ${ctemplate}
- COMMAND ${CMAKE_COMMAND}
- "-Dctemplate=${ctemplate}"
- "-Dhtemplate=${htemplate}"
- "-Dname=${name}"
- "-Dincludeguard=${includeguard}"
- "\"-Dheaders=${ARGN}\""
- -P "${CMAKE_SOURCE_DIR}/CMake/MakeGLibEnumTemplates.cmake"
- DEPENDS "${CMAKE_SOURCE_DIR}/CMake/MakeGLibEnumTemplates.cmake" ${headers}
- )
-
- add_glib_enumtypes_t(${outfiles} ${name} ${htemplate} ${ctemplate} ${ARGN})
-endmacro(add_glib_enumtypes)
diff --git a/cmake/GtkDoc.cmake b/cmake/GtkDoc.cmake
deleted file mode 100644
index d6e8cf49..00000000
--- a/cmake/GtkDoc.cmake
+++ /dev/null
@@ -1,61 +0,0 @@
-# GtkDoc.cmake
-#
-# Macros for building Midori API documentation.
-# Copyright (C) 2013 Olivier Duchateau
-
-find_program (GTKDOC_SCAN_BIN gtkdoc-scan)
-find_program (GTKDOC_MKDB_BIN gtkdoc-mkdb)
-find_program (GTKDOC_MKHTML_BIN gtkdoc-mkhtml)
-find_program (GTKDOC_MKTMPL_BIN gtkdoc-mktmpl)
-
-if (GTKDOC_SCAN_BIN AND GTKDOC_MKTMPL_BIN AND GTKDOC_MKDB_BIN
- AND GTKDOC_MKHTML_BIN)
-
- set (GTKDOC_FOUND TRUE)
-
- macro (gtkdoc_build module)
- message("gtkdoc: module ${module}")
- # file (MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module}")
- add_custom_target ("gtkdoc-scan_${module}" ALL
- ${GTKDOC_SCAN_BIN} --module=${module}
- --source-dir="${CMAKE_SOURCE_DIR}/${module}"
- --output-dir="${CMAKE_CURRENT_BINARY_DIR}/${module}"
- --rebuild-sections --rebuild-types
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
-
- add_custom_target ("gtkdoc-tmpl_${module}" ALL
- ${GTKDOC_MKTMPL_BIN} --module=${module}
- --output-dir="${CMAKE_CURRENT_BINARY_DIR}"
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module}"
- DEPENDS "gtkdoc-scan_${module}")
-
- add_custom_target ("gtkdoc-docbook_${module}" ALL
- ${GTKDOC_MKDB_BIN} --module=${module}
- --output-dir="xml"
- --source-dir="${CMAKE_SOURCE_DIR}/${module}"
- --source-suffixes=c,h --output-format=xml
- --default-includes=${module}/${module}.h
- --sgml-mode --main-sgml-file=${module}.sgml
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module}"
- DEPENDS "gtkdoc-tmpl_${module}")
-
- # Keep this target alone, otherwise build fails
- add_custom_target ("gtkdoc-html_${module}" ALL
- ${GTKDOC_MKHTML_BIN} ${module}
- "${CMAKE_CURRENT_BINARY_DIR}/${module}/${module}.sgml"
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module}/html"
- DEPENDS "gtkdoc-docbook_${module}")
-
- endmacro (gtkdoc_build module)
-
- macro (gtkdoc module)
- file (MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module}/html")
- gtkdoc_build (${module})
-
- set (DOC_DIR "html/midori-${MIDORI_MAJOR_VERSION}-${MIDORI_MINOR_VERSION}")
- install (DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module}/html/"
- DESTINATION "${CMAKE_INSTALL_DATADIR}/gtk-doc/${DOC_DIR}/${module}"
- PATTERN "html/*"
- PATTERN "index.sgml" EXCLUDE)
- endmacro (gtkdoc module)
-endif ()
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 00000000..ec23bbcd
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,21 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+#cmakedefine CORE_VERSION "@CORE_VERSION@"
+#cmakedefine PROJECT_NAME "@CMAKE_PROJECT_NAME@"
+#cmakedefine PROJECT_BUGS "@PROJECT_BUGS@"
+#cmakedefine PROJECT_WEBSITE "@PROJECT_WEBSITE@"
+
+#cmakedefine DATADIR "@DATADIR@"
+#cmakedefine SYSCONFDIR "@CMAKE_INSTALL_FULL_SYSCONFDIR@"
+#cmakedefine LIBDIR "@CMAKE_INSTALL_FULL_LIBDIR@"
+#cmakedefine DOCDIR "@CMAKE_INSTALL_FULL_DOCDIR@"
+#cmakedefine LOCALEDIR "@CMAKE_INSTALL_FULL_LOCALEDIR@"
diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt
deleted file mode 100644
index 4f1cd7fc..00000000
--- a/config/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright (C) 2013 Olivier Duchateau
-
-set (SYSCONFDIR ${CMAKE_INSTALL_FULL_SYSCONFDIR})
-set (XDG_CONFIG_DIR "xdg/${CMAKE_PROJECT_NAME}")
-
-file (GLOB_RECURSE CONFIG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
-list (REMOVE_ITEM CONFIG_FILES "CMakeLists.txt")
-
-if (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
- set(CMAKE_INSTALL_SYSCONFDIR "/etc")
-endif()
-
-foreach (FILE ${CONFIG_FILES})
- string (FIND ${FILE} "adblock" ADBLOCK_CONF)
- if (ADBLOCK_CONF GREATER -1)
- string (REPLACE "config" "" dirname ${FILE})
- install (FILES ${FILE}
- DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/${XDG_CONFIG_DIR}/${dirname}")
- else ()
- install (FILES ${FILE}
- DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/${XDG_CONFIG_DIR}")
- endif ()
-endforeach ()
diff --git a/config/extensions/adblock/config b/config/extensions/adblock/config
deleted file mode 100644
index 4f735570..00000000
--- a/config/extensions/adblock/config
+++ /dev/null
@@ -1,2 +0,0 @@
-[settings]
-filters=https://easylist-downloads.adblockplus.org/easylist.txt;https://easylist-downloads.adblockplus.org/easyprivacy.txt
diff --git a/config/search b/config/search
deleted file mode 100644
index 1a0aebeb..00000000
--- a/config/search
+++ /dev/null
@@ -1,36 +0,0 @@
-[Duck Duck Go]
-name=Duck Duck Go
-text=Privacy-aware Web Search
-uri=https://duckduckgo.com/?q=%s
-token=dd
-
-[Yahoo]
-name=Yahoo
-text=Yahoo Web Search
-uri=http://search.yahoo.com/search?p=
-token=y
-
-[Google]
-name=Google
-text=Web Search
-uri=http://www.google.com/search?q=%s
-token=g
-
-[Wikipedia]
-name=Wikipedia
-text=The free encyclopedia
-uri=http://en.wikipedia.org/wiki/Special:Search/%s
-token=wp
-
-[TheFreeDictionary]
-name=The Free Dictionary
-text=Dictionary, Encyclopedia and Thesaurus
-uri=http://www.thefreedictionary.com/%s
-token=fd
-
-[Google Translate]
-name=Google Translate
-text=Localize text or URL
-uri=http://translate.google.com/?q=
-token=gt
-
diff --git a/configure b/configure
deleted file mode 100755
index 17021acc..00000000
--- a/configure
+++ /dev/null
@@ -1,83 +0,0 @@
-#! /bin/sh
-#
-# Copyright (C) 2013 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.
-#
-#~ Usage:
-#~ ./configure [OPTIONS]
-#~ Options:
-#~ --prefix=PREFIX Installation prefix
-#~ --enable-gtk3 Use GTK+3
-#~ --disable-zeitgeist Disable Zeitgeist history integration
-#~ --enable-granite Fancy notebook and pop-overs
-#~ --enable-apidocs API documentation
-#~
-#~ Environment:
-#~ VALAC if defined the valac executable to use, for example valac-0.16
-#
-
-if [ -z `command -v cmake` ]; then
- echo Fatal: cmake not installed
- exit 1
-fi
-
-while [ $# != 0 ]; do
- case $1 in
- --enable-gtk3)
- ARGS="$ARGS -DUSE_GTK3=1";;
- --disable-zeitgeist)
- ARGS="$ARGS -DUSE_ZEITGEIST=0";;
- --enable-granite)
- ARGS="$ARGS -DUSE_GRANITE=1";;
- --enable-apidocs)
- ARGS="$ARGS -DUSE_APIDOCS=1";;
- --extra-warnings)
- ARGS="$ARGS -DEXTRA_WARNINGS=1";;
- --prefix=*)
- ARGS="$ARGS -DCMAKE_INSTALL_PREFIX=${1#*=}";;
- *)
- grep -e '^#~' $0 | sed s/#~//
- exit
- esac
- shift
-done
-
-BUILD_DIR="_build"
-
-if [ ! -f GNUmakefile ]; then
- cp -v GNUmakefile.in GNUmakefile || exit 1
-fi
-
-# cmake was invoked in toplevel folder before
-# clean up cmake generated build files to prevent conflicts
-if [ -f CMakeCache.txt ]; then
- echo
- echo '####################################################################################'
- echo 'CMake build files detected in toplevel folder !!'
- echo 'Please always run "cmake" command from distinct folder when you use cmake yourself.'
- echo '####################################################################################'
- echo
- echo 'Cleaning up...'
- echo
-
- rm -fr $BUILD_DIR
- rm CMakeCache.txt config.h Makefile
- find . -iname CMakeFiles -type d|xargs rm -fr
- find . -iname cmake_install.cmake -exec rm {} \;
- find . -iname CTestTestfile.cmake -exec rm {} \;
-
- find . -iname *-folders -type d|xargs rm -fr
- rm -fr data/logo-shade
-fi
-
-mkdir -p $BUILD_DIR && cd $BUILD_DIR || exit 1
-cmake $ARGS .. || exit 1
-
-echo
-echo "Configuring done, run \"make\" to compile"
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
new file mode 100644
index 00000000..d12f5fb7
--- /dev/null
+++ b/core/CMakeLists.txt
@@ -0,0 +1,96 @@
+# Copyright (C) 2013-2018 Christian Dywan <christian@twotoasts.de>
+
+set(LIBCORE_VERSION ${CORE_VERSION})
+set(LIBCORE_SOVERSION 0)
+
+file(GLOB LIBCORE_SOURCE *.vala)
+list(REMOVE_ITEM LIBCORE_SOURCE "main.vala")
+set(MAIN_SOURCE
+ main.vala
+ )
+
+include(ValaPrecompile)
+vala_precompile(LIBCORE_SOURCE_C ${LIBCORE}
+ ${LIBCORE_SOURCE}
+PACKAGES
+ ${PKGS}
+OPTIONS
+ ${VALAFLAGS}
+ --gresources="${CMAKE_SOURCE_DIR}/gresource.xml"
+CUSTOM_VAPIS
+ ${EXTRA_VAPIS}
+GENERATE_VAPI
+ "${LIBCORE}"
+GENERATE_HEADER
+ "${LIBCORE}"
+)
+
+vala_precompile(MAIN_SOURCE_C ${CMAKE_PROJECT_NAME}
+ ${MAIN_SOURCE}
+PACKAGES
+ ${PKGS}
+OPTIONS
+ ${VALAFLAGS}
+CUSTOM_VAPIS
+ ${EXTRA_VAPIS}
+GENERATE_VAPI
+ "${CMAKE_PROJECT_NAME}"
+GENERATE_HEADER
+ "${CMAKE_PROJECT_NAME}"
+)
+
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/resources.c
+ COMMENT "Built resource"
+ COMMAND glib-compile-resources
+ --sourcedir ${CMAKE_SOURCE_DIR}
+ --generate-source
+ --target ${CMAKE_CURRENT_BINARY_DIR}/resources.c
+ ${CMAKE_SOURCE_DIR}/gresource.xml)
+
+add_library("${LIBCORE}" SHARED ${LIBCORE_SOURCE_C} ${CMAKE_CURRENT_BINARY_DIR}/resources.c)
+target_link_libraries("${LIBCORE}"
+ ${DEPS_LIBRARIES}
+ ${DEPS_GTK_LIBRARIES}
+ )
+set_target_properties("${LIBCORE}" PROPERTIES
+ COMPILE_FLAGS "${VALA_CFLAGS}"
+ POSITION_INDEPENDENT_CODE ON
+ COMPILE_FLAGS ${VALA_CFLAGS}
+ SOVERSION ${LIBCORE_SOVERSION}
+ VERSION ${LIBCORE_VERSION}
+ )
+
+include_directories(
+ ${CMAKE_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${DEPS_INCLUDE_DIRS}
+ ${DEPS_GTK_INCLUDE_DIRS}
+ )
+if (WIN32)
+ install(TARGETS ${LIBCORE}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ )
+else ()
+ install(TARGETS ${LIBCORE}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ )
+endif ()
+
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+
+if (WIN32)
+ add_executable(${CMAKE_PROJECT_NAME} WIN32 ${MAIN_SOURCE_C} "${CMAKE_SOURCE_DIR}/data/main.rc")
+else()
+ add_executable(${CMAKE_PROJECT_NAME} ${MAIN_SOURCE_C})
+endif()
+
+target_link_libraries(${CMAKE_PROJECT_NAME}
+ ${LIBCORE})
+set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
+ COMPILE_FLAGS ${VALA_CFLAGS}
+ )
+install(TARGETS ${CMAKE_PROJECT_NAME}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ )
diff --git a/core/about.vala b/core/about.vala
new file mode 100644
index 00000000..a0662716
--- /dev/null
+++ b/core/about.vala
@@ -0,0 +1,21 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ [GtkTemplate (ui = "/ui/about.ui")]
+ public class About : Gtk.AboutDialog {
+ public About (Gtk.Window parent) {
+ Object (transient_for: parent,
+ website: Config.PROJECT_WEBSITE,
+ version: Config.CORE_VERSION);
+ }
+ }
+}
diff --git a/core/app.vala b/core/app.vala
new file mode 100644
index 00000000..188a6f55
--- /dev/null
+++ b/core/app.vala
@@ -0,0 +1,117 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ public class App : Gtk.Application {
+ public static bool incognito = false;
+ static bool version = false;
+ const OptionEntry[] options = {
+ { "private", 'p', 0, OptionArg.NONE, ref incognito, N_("Private browsing, no changes are saved"), null },
+ { "version", 'V', 0, OptionArg.NONE, ref version, N_("Display version number"), null },
+ { null }
+ };
+ const ActionEntry[] actions = {
+ { "win-incognito-new", win_incognito_new_activated },
+ { "quit", quit_activated },
+ };
+
+ public App () {
+ Object (application_id: "org.midori-browser.midori",
+ flags: ApplicationFlags.HANDLES_OPEN);
+
+ add_main_option_entries (options);
+ }
+
+ public override void startup () {
+ base.startup ();
+
+ Intl.bindtextdomain (Config.PROJECT_NAME, null);
+ Intl.bind_textdomain_codeset (Config.PROJECT_NAME, "UTF-8");
+ Intl.textdomain (Config.PROJECT_NAME);
+
+ Gtk.Window.set_default_icon_name (Config.PROJECT_NAME);
+
+ var context = WebKit.WebContext.get_default ();
+ string config = Path.build_path (Path.DIR_SEPARATOR_S,
+ Environment.get_user_config_dir (), Environment.get_prgname ());
+ DirUtils.create_with_parents (config, 0700);
+ string cookies = Path.build_filename (config, "cookies");
+ context.get_cookie_manager ().set_persistent_storage (cookies, WebKit.CookiePersistentStorage.SQLITE);
+ string cache = Path.build_path (Path.DIR_SEPARATOR_S,
+ Environment.get_user_cache_dir (), Environment.get_prgname ());
+ string icons = Path.build_path (Path.DIR_SEPARATOR_S, cache, "icondatabase");
+ context.set_favicon_database_directory (icons);
+ context.set_web_extensions_directory ("web");
+ context.initialize_web_extensions.connect (() => {
+ context.set_web_extensions_initialization_user_data ("");
+ });
+
+ add_action_entries (actions, this);
+
+ var action = new SimpleAction ("win-new", VariantType.STRING);
+ action.activate.connect (win_new_activated);
+ add_action (action);
+ }
+
+ void win_new_activated (Action action, Variant? parameter) {
+ var browser = incognito
+ ? new Browser.incognito (this)
+ : new Browser (this);
+ string? uri = parameter.get_string () != "" ? parameter.get_string () : null;
+ browser.add (new Tab (null, browser.web_context, uri));
+ }
+
+ void win_incognito_new_activated () {
+ var browser = new Browser.incognito (this);
+ browser.add (new Tab (null, browser.web_context));
+ }
+
+ void quit_activated () {
+ quit ();
+ }
+
+ protected override void window_added (Gtk.Window window) {
+ base.window_added (window);
+ }
+
+ protected override void activate () {
+ if (incognito) {
+ activate_action ("win-incognito-new", null);
+ return;
+ }
+ activate_action ("win-new", "");
+ }
+
+ protected override void open (File[] files, string hint) {
+ var browser = incognito
+ ? new Browser.incognito (this)
+ : (active_window as Browser ?? new Browser (this));
+ foreach (File file in files) {
+ browser.add (new Tab (browser.tab, browser.web_context, file.get_uri ()));
+ }
+ }
+
+ protected override int handle_local_options (VariantDict options) {
+ if (version) {
+ stdout.printf ("%s %s\n" +
+ "Copyright 2007-2018 Christian Dywan\n" +
+ "Please report comments, suggestions and bugs to:\n" +
+ " %s\n" +
+ "Check for new versions at:\n" +
+ " %s\n ",
+ Config.PROJECT_NAME, Config.CORE_VERSION,
+ Config.PROJECT_BUGS, Config.PROJECT_WEBSITE);
+ return 0;
+ }
+ return -1;
+ }
+ }
+}
diff --git a/core/browser.vala b/core/browser.vala
new file mode 100644
index 00000000..b96e5e72
--- /dev/null
+++ b/core/browser.vala
@@ -0,0 +1,345 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ [GtkTemplate (ui = "/ui/browser.ui")]
+ public class Browser : Gtk.ApplicationWindow {
+ public WebKit.WebContext web_context { get; construct set; }
+ public bool is_loading { get { return tab != null && tab.is_loading; } }
+ public Tab? tab { get; protected set; }
+ public ListStore trash { get; protected set; }
+
+ const ActionEntry[] actions = {
+ { "tab-new", tab_new_activated },
+ { "tab-close", tab_close_activated },
+ { "close", close_activated },
+ { "tab-reopen", tab_reopen_activated },
+ { "goto", goto_activated },
+ { "go-back", go_back_activated },
+ { "go-forward", go_forward_activated },
+ { "tab-reload", tab_reload_activated },
+ { "tab-stop-loading", tab_stop_loading_activated },
+ { "tab-previous", tab_previous_activated },
+ { "tab-next", tab_next_activated },
+ { "show-downloads", show_downloads_activated },
+ { "find", find_activated },
+ { "print", print_activated },
+ { "show-inspector", show_inspector_activated },
+ { "clear-private-data", clear_private_data_activated },
+ { "about", about_activated },
+ };
+ [GtkChild]
+ DownloadButton downloads;
+ [GtkChild]
+ Gtk.MenuButton profile;
+ [GtkChild]
+ Gtk.Image profile_icon;
+ [GtkChild]
+ Gtk.ActionBar navigationbar;
+ [GtkChild]
+ Gtk.Button go_back;
+ [GtkChild]
+ Gtk.Button go_forward;
+ [GtkChild]
+ Gtk.Button reload;
+ [GtkChild]
+ Gtk.Button stop_loading;
+ [GtkChild]
+ Urlbar urlbar;
+ [GtkChild]
+ Gtk.MenuButton menubutton;
+ [GtkChild]
+ Gtk.Stack tabs;
+ [GtkChild]
+ Gtk.Overlay overlay;
+ [GtkChild]
+ Statusbar statusbar;
+ [GtkChild]
+ Gtk.SearchBar search;
+ [GtkChild]
+ Gtk.SearchEntry search_entry;
+
+ List<Binding> bindings;
+
+ construct {
+ overlay.add_events (Gdk.EventMask.ENTER_NOTIFY_MASK);
+ overlay.enter_notify_event.connect ((event) => {
+ statusbar.hide ();
+ statusbar.halign = statusbar.halign == Gtk.Align.START ? Gtk.Align.END : Gtk.Align.START;
+ statusbar.show ();
+ return false;
+ });
+
+ add_action_entries (actions, this);
+
+ notify["application"].connect ((pspec) => {
+ application.set_accels_for_action ("win.tab-new", { "<Primary>t" });
+ application.set_accels_for_action ("win.tab-close", { "<Primary>w" });
+ application.set_accels_for_action ("win.close", { "<Primary><Shift>w" });
+ application.set_accels_for_action ("win.tab-reopen", { "<Primary><Shift>t" });
+ application.set_accels_for_action ("win.show-downloads", { "<Primary><Shift>j" });
+ application.set_accels_for_action ("win.find", { "<Primary>f", "slash" });
+ application.set_accels_for_action ("win.print", { "<Primary>p" });
+ application.set_accels_for_action ("win.show-inspector", { "<Primary><Shift>i" });
+ application.set_accels_for_action ("win.goto", { "<Primary>l", "F7" });
+ application.set_accels_for_action ("win.go-back", { "<Alt>Left", "BackSpace" });
+ application.set_accels_for_action ("win.go-forward", { "<Alt>Right", "<Shift>BackSpace" });
+ application.set_accels_for_action ("win.tab-reload", { "<Primary>r", "F5" });
+ application.set_accels_for_action ("win.tab-stop-loading", { "Escape" });
+ application.set_accels_for_action ("win.tab-previous", { "<Primary><Shift>Tab" });
+ application.set_accels_for_action ("win.tab-next", { "<Primary>Tab" });
+ application.set_accels_for_action ("win.clear-private-data", { "<Primary><Shift>Delete" });
+
+ for (var i = 0; i < 10; i++) {
+ application.set_accels_for_action ("win.tab-by-index(%d)".printf(i),
+ { "<Alt>%d".printf (i < 9 ? i + 1 : 0) });
+ }
+ application.set_accels_for_action ("win.tab-zoom(0.1)", { "<Primary>plus", "<Primary>equal" });
+ application.set_accels_for_action ("win.tab-zoom(-0.1)", { "<Primary>minus" });
+ application.set_accels_for_action ("win.tab-zoom(1.0)", { "<Primary>0" });
+
+ profile.menu_model = application.get_menu_by_id ("profile-menu");
+ menubutton.menu_model = application.get_menu_by_id ("browser-menu");
+
+ application.bind_busy_property (this, "is-loading");
+ });
+
+ // Action for switching tabs via Alt+number
+ var action = new SimpleAction ("tab-by-index", VariantType.INT32);
+ action.activate.connect (tab_by_index_activated);
+ add_action (action);
+ // Action for zooming
+ action = new SimpleAction ("tab-zoom", VariantType.DOUBLE);
+ action.activate.connect (tab_zoom_activated);
+ add_action (action);
+
+ trash = new ListStore (typeof (DatabaseItem));
+
+ urlbar.notify["uri"].connect ((pspec) => {
+ if (urlbar.uri.has_prefix ("javascript:")) {
+ tab.run_javascript.begin (urlbar.uri.substring (11, -1), null);
+ } else if (urlbar.uri != tab.uri) {
+ tab.load_uri (urlbar.uri);
+ }
+ });
+ tabs.notify["visible-child"].connect (() => {
+ if (bindings != null) {
+ foreach (var binding in bindings) {
+ binding.unbind ();
+ }
+ }
+ tab = (Tab)tabs.visible_child;
+ if (tab != null) {
+ go_back.sensitive = tab.can_go_back;
+ go_forward.sensitive = tab.can_go_forward;
+ reload.visible = !tab.is_loading;
+ stop_loading.visible = tab.is_loading;
+ urlbar.progress_fraction = tab.progress;
+ title = tab.display_title;
+ urlbar.secure = tab.secure;
+ statusbar.label = tab.link_uri;
+ urlbar.uri = tab.uri;
+ navigationbar.visible = !tab.pinned;
+ bindings.append (tab.bind_property ("can-go-back", go_back, "sensitive"));
+ bindings.append (tab.bind_property ("can-go-forward", go_forward, "sensitive"));
+ bindings.append (tab.bind_property ("is-loading", reload, "visible", BindingFlags.INVERT_BOOLEAN));
+ bindings.append (tab.bind_property ("is-loading", stop_loading, "visible"));
+ bindings.append (tab.bind_property ("progress", urlbar, "progress-fraction"));
+ bindings.append (tab.bind_property ("display-title", this, "title"));
+ bindings.append (tab.bind_property ("secure", urlbar, "secure"));
+ bindings.append (tab.bind_property ("link-uri", statusbar, "label"));
+ bindings.append (tab.bind_property ("uri", urlbar, "uri"));
+ bindings.append (tab.bind_property ("pinned", navigationbar, "visible", BindingFlags.INVERT_BOOLEAN));
+ } else {
+ var previous_tab = tabs.get_children ().nth_data (0);
+ if (previous_tab == null)
+ close ();
+ else
+ tab = (Tab)previous_tab;
+ }
+ });
+
+ search_entry.activate.connect (find_text);
+ search_entry.search_changed.connect (find_text);
+ search_entry.next_match.connect (find_text);
+ search_entry.previous_match.connect (() => {
+ find_text_backwards (true);
+ });
+
+ var provider = new Gtk.CssProvider ();
+ provider.load_from_resource ("/data/gtk3.css");
+ Gtk.StyleContext.add_provider_for_screen (get_screen (), provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
+
+ public Browser (App app) {
+ Object (application: app, visible: true,
+ web_context: WebKit.WebContext.get_default ());
+ }
+
+ public Browser.incognito (App app) {
+ Object (application: app, visible: true,
+ web_context: new WebKit.WebContext.ephemeral ());
+
+ profile.sensitive = false;
+ remove_action ("clear-private-data");
+ get_style_context ().add_class ("incognito");
+ profile_icon.icon_name = "user-not-tracked-symbolic";
+ }
+
+ public override bool key_press_event (Gdk.EventKey event) {
+ // Give key handling in widgets precedence over actions
+ // eg. Backspace in textfields should delete rather than go back
+ if (propagate_key_event (event)) {
+ return true;
+ }
+ if (base.key_press_event (event)) {
+ // Popdown completion if a key binding was fired
+ urlbar.popdown ();
+ return true;
+ }
+ return false;
+ }
+
+ void tab_new_activated () {
+ add (new Tab (tab, web_context));
+ }
+
+ void tab_close_activated () {
+ tab.try_close ();
+ }
+
+ void close_activated () {
+ close ();
+ }
+
+ void tab_reopen_activated () {
+ uint index = trash.get_n_items ();
+ if (index > 0) {
+ var item = trash.get_object (index - 1) as DatabaseItem;
+ add (new Tab (tab, web_context, item.uri));
+ trash.remove (index - 1);
+ }
+ }
+
+ void goto_activated () {
+ urlbar.grab_focus ();
+ }
+
+ void go_back_activated () {
+ tab.go_back ();
+ }
+
+ void go_forward_activated () {
+ tab.go_forward ();
+ }
+
+ void tab_reload_activated () {
+ tab.reload ();
+ }
+
+ void tab_stop_loading_activated () {
+ tab.stop_loading ();
+ }
+
+ void tab_previous_activated () {
+ int index = tabs.get_children ().index (tab);
+ var previous = tabs.get_children ().nth_data (index - 1);
+ if (previous != null)
+ tabs.visible_child = (Tab)previous;
+ }
+
+ void tab_next_activated () {
+ int index = tabs.get_children ().index (tab);
+ var next = tabs.get_children ().nth_data (index + 1);
+ if (next != null)
+ tabs.visible_child = (Tab)next;
+ }
+
+ void tab_zoom_activated (Action action, Variant? parameter) {
+ double zoom_level = parameter.get_double ();
+ tab.zoom_level = zoom_level == 1.0 ? 1.0 : (tab.zoom_level + zoom_level);
+ }
+
+ void tab_by_index_activated (Action action, Variant? parameter) {
+ var nth_tab = tabs.get_children ().nth_data (parameter.get_int32 ());
+ if (nth_tab != null) {
+ tabs.visible_child = nth_tab;
+ }
+ }
+
+ void show_downloads_activated () {
+ downloads.show_downloads ();
+ }
+
+ void find_activated () {
+ search.show ();
+ search.search_mode_enabled = true;
+ search_entry.grab_focus ();
+ }
+
+ void find_text () {
+ find_text_backwards (false);
+ }
+
+ void find_text_backwards (bool backwards) {
+ uint options = WebKit.FindOptions.WRAP_AROUND;
+ // Smart case: case sensitive if starting with an uppercase character
+ if (search_entry.text[0].islower ()) {
+ options |= WebKit.FindOptions.CASE_INSENSITIVE;
+ }
+ if (backwards) {
+ options |= WebKit.FindOptions.BACKWARDS;
+ }
+ tab.get_find_controller ().search (search_entry.text, options, int.MAX);
+ }
+
+ void print_activated () {
+ tab.print (new WebKit.PrintOperation (tab));
+ }
+
+ void show_inspector_activated () {
+ tab.get_inspector ().show ();
+ }
+
+ public new void add (Tab tab) {
+ tab.create.connect ((action) => {
+ var new_tab = new Tab (tab, web_context, action.get_request ().uri);
+ add (new_tab);
+ return new_tab;
+ });
+ tab.enter_fullscreen.connect (() => {
+ navigationbar.hide ();
+ return false;
+ });
+ tab.leave_fullscreen.connect (() => {
+ navigationbar.visible = !tab.pinned;
+ return false;
+ });
+ tab.close.connect (() => {
+ trash.append (tab.item);
+ });
+ // Support Gtk.StackSwitcher
+ tab.notify["display-title"].connect ((pspec) => {
+ tabs.child_set (tab, "title", tab.display_title);
+ });
+ tabs.add_titled (tab, tab.id, tab.display_title);
+ }
+
+ void clear_private_data_activated () {
+ new ClearPrivateData (this).show ();
+ }
+
+ void about_activated () {
+ new About (this).show ();
+ }
+ }
+}
diff --git a/core/clear-private-data.vala b/core/clear-private-data.vala
new file mode 100644
index 00000000..f2f33036
--- /dev/null
+++ b/core/clear-private-data.vala
@@ -0,0 +1,93 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ [GtkTemplate (ui = "/ui/clear-private-data.ui")]
+ public class ClearPrivateData : Gtk.Dialog {
+ [GtkChild]
+ Gtk.ComboBoxText timerange;
+ [GtkChild]
+ Gtk.CheckButton history;
+ [GtkChild]
+ Gtk.CheckButton websitedata;
+ [GtkChild]
+ Gtk.CheckButton cache;
+ public ClearPrivateData (Gtk.Window parent) {
+ Object (transient_for: parent,
+ // Adding this property via GtkBuilder doesn't work
+ // "for technical reasons, this property is declared as an integer"
+ use_header_bar: 1);
+ }
+
+ public override void show () {
+ populate_data.begin ();
+ try {
+ var database = HistoryDatabase.get_default ();
+ ulong handler = 0;
+ handler = database.items_changed.connect ((position, added, removed) => {
+ history.sensitive = database.get_n_items () > 0;
+ SignalHandler.disconnect (database, handler);
+ });
+ history.sensitive = database.get_n_items () > 0;
+ } catch (DatabaseError error) {
+ debug ("Failed to check history: %s", error.message);
+ }
+ base.show ();
+ }
+
+ async void populate_data (Cancellable? cancellable=null) {
+ var manager = WebKit.WebContext.get_default ().website_data_manager;
+ try {
+ var data = yield manager.fetch (WebKit.WebsiteDataTypes.ALL, cancellable);
+ foreach (var website in data) {
+ if (((website.get_types () & WebKit.WebsiteDataTypes.COOKIES) != 0) ||
+ ((website.get_types () & WebKit.WebsiteDataTypes.LOCAL_STORAGE) != 0) ||
+ ((website.get_types () & WebKit.WebsiteDataTypes.WEBSQL_DATABASES) != 0) ||
+ ((website.get_types () & WebKit.WebsiteDataTypes.INDEXEDDB_DATABASES) != 0)) {
+ websitedata.sensitive = true;
+ } else if ((website.get_types () & WebKit.WebsiteDataTypes.DISK_CACHE) != 0) {
+ cache.sensitive = true;
+ }
+ }
+ } catch (Error error) {
+ debug ("Failed to fetch data: %s", error.message);
+ }
+ }
+
+ public override void response (int response_id) {
+ if (response_id == Gtk.ResponseType.OK) {
+ var timespan = timerange.active_id == "last-hour"
+ ? TimeSpan.HOUR : TimeSpan.DAY;
+ WebKit.WebsiteDataTypes types = 0;
+ if (websitedata.active) {
+ types |= WebKit.WebsiteDataTypes.COOKIES;
+ types |= WebKit.WebsiteDataTypes.LOCAL_STORAGE;
+ types |= WebKit.WebsiteDataTypes.WEBSQL_DATABASES;
+ types |= WebKit.WebsiteDataTypes.INDEXEDDB_DATABASES;
+ }
+ if (types != 0) {
+ var manager = WebKit.WebContext.get_default ().website_data_manager;
+ manager.clear.begin (types, timespan, null);
+ }
+ if (history.active) {
+ // Note: TimeSpan is defined in microseconds
+ int64 age = new DateTime.now_local ().to_unix () - timespan / 1000000;
+ try {
+ HistoryDatabase.get_default ().clear.begin (age);
+ } catch (DatabaseError error) {
+ debug ("Failed to clear history: %s", error.message);
+ }
+ }
+ }
+ close ();
+ }
+ }
+}
diff --git a/core/completion.vala b/core/completion.vala
new file mode 100644
index 00000000..22b262ce
--- /dev/null
+++ b/core/completion.vala
@@ -0,0 +1,89 @@
+/*
+ Copyright (C) 2012-2018 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.
+*/
+
+namespace Midori {
+ public class SuggestionItem : DatabaseItem {
+ public string? search { get; protected set; }
+
+ SuggestionItem (string uri, string? title) {
+ base (uri, title, 0);
+ }
+
+ public SuggestionItem.for_input (string uri, string? title) {
+ base (uri, title, 0);
+ this.search = uri;
+ }
+ }
+
+ public class Completion : Object, ListModel {
+ List<ListModel> models = new List<ListModel> ();
+ public string? key { get; set; default = null; }
+
+ construct {
+ var model = new ListStore (typeof (DatabaseItem));
+ // Allow DuckDuckGo to distinguish Midori and in turn share revenue
+ model.append (new SuggestionItem.for_input ("https://duckduckgo.com/?q=%s&t=midori", _("Search with DuckDuckGo")));
+ models.append (model);
+
+ try {
+ add (HistoryDatabase.get_default ());
+ } catch (DatabaseError error) {
+ debug ("Failed to initialize completion model: %s", error.message);
+ }
+ }
+
+ public Completion () {
+ }
+
+ void add (ListModel model) {
+ if (model is Database) {
+ bind_property ("key", model, "key");
+ }
+ model.items_changed.connect (model_changed);
+ models.append (model);
+ }
+
+ void model_changed (ListModel model, uint position, uint removed, uint added) {
+ uint index = 0;
+ foreach (var other in models) {
+ if (model == other) {
+ items_changed (position + index, removed, added);
+ break;
+ }
+ index += other.get_n_items ();
+ }
+ }
+
+ public Type get_item_type () {
+ return typeof (DatabaseItem);
+ }
+
+ public Object? get_item (uint position) {
+ uint index = 0;
+ foreach (var model in models) {
+ uint count = model.get_n_items ();
+ if (position < index + count) {
+ return model.get_item (position - index);
+ }
+ index += count;
+ }
+ return null;
+ }
+
+ public uint get_n_items () {
+ uint count = 0;
+ foreach (var model in models) {
+ count += model.get_n_items ();
+ }
+ return count;
+ }
+ }
+}
diff --git a/midori/midori-database.vala b/core/database.vala
index ba871447..9fc0612d 100644
--- a/midori/midori-database.vala
+++ b/core/database.vala
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013 Christian Dywan <christian@twotoats.de>
+ Copyright (C) 2013-2018 Christian Dywan <christian@twotoats.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -10,9 +10,6 @@
*/
namespace Midori {
- /*
- * Since: 0.5.6
- */
public errordomain DatabaseError {
OPEN,
NAMING,
@@ -22,15 +19,9 @@ namespace Midori {
TYPE,
}
- /*
- * Since: 0.5.8
- */
public delegate bool DatabaseCallback () throws DatabaseError;
- /*
- * Since: 0.5.7
- */
- public class DatabaseStatement : GLib.Object, GLib.Initable {
+ public class DatabaseStatement : Object, Initable {
public Sqlite.Statement? stmt { get { return _stmt; } }
protected Sqlite.Statement _stmt = null;
public Database? database { get; set construct; }
@@ -42,10 +33,10 @@ namespace Midori {
init ();
}
- public virtual bool init (GLib.Cancellable? cancellable = null) throws DatabaseError {
+ public virtual bool init (Cancellable? cancellable = null) throws DatabaseError {
int result = database.db.prepare_v2 (query, -1, out _stmt, null);
if (result != Sqlite.OK)
- throw new DatabaseError.COMPILE ("Failed to compile statement: %s".printf (database.db.errmsg ()));
+ throw new DatabaseError.COMPILE ("Failed to compile statement '%s': %s".printf (query, database.db.errmsg ()));
return true;
}
@@ -64,20 +55,18 @@ namespace Midori {
if (ptype == typeof (string)) {
string text = args.arg ();
stmt.bind_text (pindex, text);
- if (database.trace)
- stdout.printf ("%s=%s ", pname, text);
+ database.debug ("%s=%s", pname, text);
} else if (ptype == typeof (int64)) {
int64 integer = args.arg ();
stmt.bind_int64 (pindex, integer);
- if (database.trace)
- stdout.printf ("%s=%s ", pname, integer.to_string ());
+ database.debug ("%s=%s", pname, integer.to_string ());
} else if (ptype == typeof (double)) {
double stuntman = args.arg ();
stmt.bind_double (pindex, stuntman);
- if (database.trace)
- stdout.printf ("%s=%s ", pname, stuntman.to_string ());
- } else
+ database.debug ("%s=%s", pname, stuntman.to_string ());
+ } else {
throw new DatabaseError.TYPE ("Invalid type '%s' for '%s' in statement: %s".printf (ptype.name (), pname, query));
+ }
}
/*
@@ -103,7 +92,6 @@ namespace Midori {
/*
* Returns the id of the last inserted row.
* It is an error to ask for an id without having inserted a row.
- * Since: 0.5.8
*/
public int64 row_id () throws DatabaseError {
if (last_row_id == -1)
@@ -111,7 +99,7 @@ namespace Midori {
return last_row_id;
}
- private int column_index (string name) throws DatabaseError {
+ int column_index (string name) throws DatabaseError {
for (int i = 0; i < stmt.column_count (); i++) {
if (name == stmt.column_name (i))
return i;
@@ -157,14 +145,57 @@ namespace Midori {
}
}
- /*
- * Since: 0.5.6
- */
- public class Database : GLib.Object, GLib.Initable {
- internal bool trace = false;
+ public class DatabaseItem : Object {
+ public Database? database { get; set; }
+ public string uri { get; set; }
+ public string? title { get; set; }
+ public int64 date { get; set; }
+
+ public DatabaseItem (string uri, string? title, int64 date=0) {
+ Object (uri: uri,
+ title: title,
+ date: date);
+ notify["title"].connect ((pspec) => {
+ if (database != null) {
+ database.update.begin (this);
+ }
+ });
+ }
+
+ /*
+ * Delete the item, or no-op if it can't be deleted.
+ */
+ public async bool delete () {
+ if (database != null) {
+ try {
+ return yield database.delete (this);
+ } catch (DatabaseError error) {
+ critical ("Failed to delete %s: %s", uri, error.message);
+ }
+ }
+ return false;
+ }
+ }
+
+ public const DebugKey[] keys = {
+ { "historydatabase", DebugFlags.HISTORY },
+ };
+
+ public enum DebugFlags {
+ NONE,
+ HISTORY,
+ }
+
+ public class Database : Object, Initable, ListModel, Loggable {
public Sqlite.Database? db { get { return _db; } }
protected Sqlite.Database? _db = null;
+ public string? table { get; protected set; default = null; }
public string path { get; protected set; default = ":memory:"; }
+ string? _key = null;
+ public string? key { get { return _key; } set {
+ _key = value;
+ populate.begin ();
+ } }
/*
* A new database successfully opened for the first time.
@@ -185,27 +216,45 @@ namespace Midori {
if (path.has_prefix (":memory:"))
return ":memory:";
else if (!Path.is_absolute (path))
- return Midori.Paths.get_config_filename_for_writing (path);
+ return Path.build_filename (Environment.get_user_config_dir (),
+ Environment.get_prgname (), path);
return path;
}
- public virtual bool init (GLib.Cancellable? cancellable = null) throws DatabaseError {
+ public virtual bool init (Cancellable? cancellable = null) throws DatabaseError {
+ if (table == null) {
+ string basename = Path.get_basename (path);
+ string[] parts = basename.split (".");
+ if (parts != null && parts[0] != null && parts[1] != null) {
+ table = parts[0];
+ } else if (path == ":memory:") {
+ table = "memory";
+ } else {
+ throw new DatabaseError.NAMING ("Failed to deduce table from %s".printf (path));
+ }
+ }
+
string real_path = resolve_path (path);
- bool exists = exists(real_path);
+ bool exists = exists (real_path);
+
+ int flags = 0;
+ if (App.incognito) {
+ flags |= Sqlite.OPEN_READONLY;
+ } else {
+ flags |= Sqlite.OPEN_CREATE;
+ flags |= Sqlite.OPEN_READWRITE;
+ }
- if (Sqlite.Database.open_v2 (real_path, out _db) != Sqlite.OK)
+ if (Sqlite.Database.open_v2 (real_path, out _db, flags) != Sqlite.OK) {
throw new DatabaseError.OPEN ("Failed to open database %s".printf (real_path));
+ }
- string token = Environment.get_variable ("MIDORI_DEBUG") ?? "";
- string basename = Path.get_basename (path);
- string[] parts = basename.split (".");
- trace = ("db:" + parts[0]) in token;
- if (trace) {
- stdout.printf ("§§ Tracing %s\n", path);
+ if (logging) {
+ debug ("Tracing %s", path);
db.profile ((sql, nanoseconds) => {
/* sqlite as of this writing isn't more precise than ms */
string milliseconds = (nanoseconds / 1000000).to_string ();
- stdout.printf ("§§ %s: %s (%sms)\n", path, sql, milliseconds);
+ debug ("%s (%sms)", sql, milliseconds);
});
}
@@ -213,8 +262,9 @@ namespace Midori {
db.exec ("PRAGMA synchronous = NORMAL; PRAGMA temp_store = MEMORY;");
db.exec ("PRAGMA count_changes = OFF;");
- if (real_path == ":memory:")
- return true;
+ if (real_path == ":memory:") {
+ return exec ("CREATE TABLE %s (uri text, title text, date integer)".printf (table));
+ }
int64 user_version;
Sqlite.Statement stmt;
@@ -246,35 +296,18 @@ namespace Midori {
return true;
}
- public bool exists (string path) {
- return GLib.FileUtils.test (path, GLib.FileTest.EXISTS);
- }
-
-
- /*
- * Since: 0.5.8
- */
-
- public bool attach (string path, string alias) throws DatabaseError {
- string real_path = resolve_path (path);
- if (!exists (real_path))
- throw new DatabaseError.OPEN ("Failed to attach database %s".printf (path));
- return exec ("ATTACH DATABASE '%s' AS '%s';".printf (real_path, alias));
+ public bool exists (string path) {
+ return FileUtils.test (path, FileTest.EXISTS);
}
public bool exec_script (string filename) throws DatabaseError {
- string basename = Path.get_basename (path);
- string[] parts = basename.split (".");
- if (!(parts != null && parts[0] != null && parts[1] != null))
- throw new DatabaseError.NAMING ("Failed to deduce schema filename from %s".printf (path));
- string schema_filename = Midori.Paths.get_res_filename (parts[0] + "/" + filename + ".sql");
- string schema;
+ string schema_path = "/data/%s/%s.sql".printf (table, filename);
try {
- FileUtils.get_contents (schema_filename, out schema, null);
+ var schema = resources_lookup_data (schema_path, ResourceLookupFlags.NONE);
+ transaction (()=> { return exec ((string)schema.get_data ()); });
} catch (Error error) {
- throw new DatabaseError.FILENAME ("Failed to open schema: %s".printf (schema_filename));
+ throw new DatabaseError.FILENAME ("Failed to open schema: %s".printf (schema_path));
}
- transaction (()=> { return exec (schema); });
return true;
}
@@ -294,7 +327,6 @@ namespace Midori {
/*
* Prepare a statement with optionally binding parameters by name.
* See also DatabaseStatement.bind().
- * Since: 0.5.7
*/
public DatabaseStatement prepare (string query, ...) throws DatabaseError {
var statement = new DatabaseStatement (this, query);
@@ -315,9 +347,173 @@ namespace Midori {
throw new DatabaseError.TYPE ("Invalid type '%s' in statement: %s".printf (ptype.name (), query));
pname = args.arg ();
}
- if (trace)
- stdout.printf ("\n");
return statement;
}
+
+ /*
+ * Delete an item from the database, where the URI matches.
+ */
+ public async bool delete (DatabaseItem item) throws DatabaseError {
+ string sqlcmd = """
+ DELETE FROM %s WHERE uri = :uri
+ """.printf (table);
+ DatabaseStatement statement;
+ try {
+ statement = prepare (sqlcmd,
+ ":uri", typeof (string), item.uri);
+ if (statement.exec ()) {
+ if (_items != null) {
+ int index = _items.index (item);
+ _items.remove (item);
+ items_changed (index, 1, 0);
+ }
+ return true;
+ }
+ } catch (Error error) {
+ critical (_("Failed to delete from %s: %s"), table, error.message);
+ }
+ return false;
+ }
+
+ /*
+ * Determine if the item is in the database, where the URI matches.
+ */
+ public bool contains (DatabaseItem item) throws DatabaseError {
+ string sqlcmd = """
+ SELECT uri FROM %s WHERE uri = :uri
+ """.printf (table);
+ DatabaseStatement statement;
+ try {
+ statement = prepare (sqlcmd,
+ ":uri", typeof (string), item.uri);
+ return statement.step ();
+ } catch (Error error) {
+ critical (_("Failed to select from %s: %s"), table, error.message);
+ }
+ return false;
+ }
+
+ /*
+ * Query items from the database, matching filter if given.
+ */
+ public async List<DatabaseItem>? query (string? filter=null, int64 max_items=15, Cancellable? cancellable=null) throws DatabaseError {
+ string sqlcmd = """
+ SELECT uri, title, date, count () AS ct FROM %s
+ WHERE uri LIKE :filter OR title LIKE :filter
+ GROUP BY uri
+ ORDER BY ct DESC LIMIT :limit
+ """.printf (table);
+ DatabaseStatement statement;
+ try {
+ string real_filter = "%" + (filter ?? "").replace (" ", "%") + "%";
+ statement = prepare (sqlcmd,
+ ":filter", typeof (string), real_filter,
+ ":limit", typeof (int64), max_items);
+ } catch (Error error) {
+ critical (_("Failed to select from %s: %s"), table, error.message);
+ return null;
+ }
+
+ var items = new List<DatabaseItem> ();
+ try {
+ while (statement.step ()) {
+ string uri = statement.get_string ("uri");
+ string title = statement.get_string ("title");
+ int64 date = statement.get_int64 ("date");
+ var item = new DatabaseItem (uri, title, date);
+ item.database = this;
+ items.append (item);
+
+ uint src = Idle.add (query.callback);
+ yield;
+ Source.remove (src);
+
+ if (cancellable != null && cancellable.is_cancelled ())
+ return null;
+ }
+ } catch (Error error) {
+ critical (_("Failed to select from %s: %s"), table, error.message);
+ }
+
+ if (cancellable != null && cancellable.is_cancelled ())
+ return null;
+ return items;
+ }
+
+ /*
+ * Update an existing item, where URI and date match.
+ */
+ public async bool update (DatabaseItem item) throws DatabaseError {
+ string sqlcmd = """
+ UPDATE %s SET TITLE=:title WHERE uri = :uri AND date=:date
+ """.printf (table);
+ DatabaseStatement statement;
+ try {
+ statement = prepare (sqlcmd,
+ ":uri", typeof (string), item.uri,
+ ":title", typeof (string), item.title,
+ ":date", typeof (int64), item.uri);
+ if (statement.exec ()) {
+ if (_items != null) {
+ items_changed (_items.index (item), 0, 0);
+ }
+ return true;
+ }
+ } catch (Error error) {
+ critical (_("Failed to update %s: %s"), table, error.message);
+ }
+ return false;
+ }
+
+ /*
+ * Insert an item into the database.
+ */
+ public async bool insert (DatabaseItem item) throws DatabaseError {
+ item.database = this;
+
+ string sqlcmd = """
+ INSERT INTO %s (uri, title, date) VALUES (:uri, :title, :date)
+ """.printf (table);
+ var statement = prepare (sqlcmd,
+ ":uri", typeof (string), item.uri,
+ ":title", typeof (string), item.title,
+ ":date", typeof (int64), item.date);
+ if (statement.exec ()) {
+ if (_items != null) {
+ _items.append (item);
+ items_changed (_items.index (item), 0, 1);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public Type get_item_type () {
+ return typeof (DatabaseItem);
+ }
+
+ List<DatabaseItem>? _items = null;
+
+ public Object? get_item (uint position) {
+ return _items.nth_data (position);
+ }
+
+ public uint get_n_items () {
+ if (_items == null) {
+ populate.begin ();
+ return 0;
+ }
+ return _items.length ();
+ }
+
+ async void populate () {
+ try {
+ uint old_length = _items.length ();
+ _items = yield query (key);
+ items_changed (0, old_length, _items.length ());
+ } catch (DatabaseError error) {
+ debug ("Failed to populate: %s", error.message);
+ }
+ }
}
}
diff --git a/core/download-button.vala b/core/download-button.vala
new file mode 100644
index 00000000..215e5885
--- /dev/null
+++ b/core/download-button.vala
@@ -0,0 +1,122 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ [GtkTemplate (ui = "/ui/download-button.ui")]
+ public class DownloadButton : Gtk.Button {
+ public virtual signal void show_downloads () {
+ popover.show ();
+ }
+
+ [GtkChild]
+ public Gtk.Popover popover;
+ [GtkChild]
+ public Gtk.ListBox listbox;
+
+ ListStore model = new ListStore (typeof (DownloadItem));
+
+ construct {
+ listbox.bind_model (model, create_row);
+ popover.relative_to = this;
+
+ var context = WebKit.WebContext.get_default ();
+ context.download_started.connect (download_started);
+ }
+
+ void download_started (WebKit.Download download) {
+ model.append (new DownloadItem.with_download (download));
+ }
+
+ public Gtk.Widget create_row (Object item) {
+ visible = true;
+ return new DownloadRow ((DownloadItem)item);
+ }
+ }
+
+ public class DownloadItem : Object {
+ public string? mime_type = null;
+ public string content_type { owned get {
+ string? content_type = ContentType.guess (filename, null, null);
+ if (content_type == null) {
+ content_type = ContentType.from_mime_type (mime_type);
+ if (content_type == null)
+ content_type = ContentType.from_mime_type ("application/octet-stream");
+ }
+ return content_type;
+ } }
+ public Icon icon { owned get {
+ var icon = GLib.ContentType.get_icon (content_type) as ThemedIcon;
+ icon.append_name ("text-html-symbolic");
+ return icon;
+ } }
+
+ public string? filename { get; protected set; default = null; }
+ public string? basename { get; protected set; default = null; }
+ public double progress { get; protected set; default = 0.0; }
+ public WebKit.Download? download { get; protected set; default = null; }
+ public bool loading { get; protected set; default = false; }
+ public void cancel () {
+ if (download != null) {
+ download.cancel ();
+ download = null;
+ loading = false;
+ }
+ }
+
+ construct {
+ notify["filename"].connect ((pspec) => {
+ if (filename != null) {
+ try {
+ basename = Filename.display_basename (Filename.from_uri (filename));
+ } catch (ConvertError error) {
+ debug ("Failed to convert: %s", error.message);
+ }
+ }
+ });
+ }
+
+ public DownloadItem (string filename) {
+ Object (filename: filename);
+ }
+
+ public DownloadItem.with_download (WebKit.Download download) {
+ Object (download: download, loading: true);
+ download.bind_property ("destination", this, "filename");
+ download.bind_property ("estimated-progress", this, "progress");
+ }
+ }
+
+ [GtkTemplate (ui = "/ui/download-row.ui")]
+ public class DownloadRow : Gtk.ListBoxRow {
+ public DownloadItem item { get; protected set; }
+
+ [GtkChild]
+ public Gtk.Image icon;
+ [GtkChild]
+ public Gtk.Label filename;
+ [GtkChild]
+ public Gtk.ProgressBar progress;
+ [GtkChild]
+ public Gtk.Button cancel;
+
+ public DownloadRow (DownloadItem item) {
+ Object (item: item);
+ icon.gicon = item.icon;
+ item.bind_property ("icon", icon, "gicon");
+ filename.label = item.basename;
+ item.bind_property ("basename", filename, "label");
+ progress.fraction = item.progress;
+ item.bind_property ("progress", progress, "fraction");
+ cancel.visible = item.loading;
+ item.bind_property ("loading", cancel, "visible");
+ }
+ }
+}
diff --git a/core/favicon.vala b/core/favicon.vala
new file mode 100644
index 00000000..0cd4593c
--- /dev/null
+++ b/core/favicon.vala
@@ -0,0 +1,55 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ public class Favicon : Gtk.Image {
+ string? _uri = null;
+ public string? uri { get { return _uri; } set {
+ // Reset icon without losing the size
+ int _icon_size = icon_size;
+ gicon = null;
+ icon_size = _icon_size;
+
+ _uri = value;
+ load_icon.begin ();
+ } }
+
+ construct {
+ var database = WebKit.WebContext.get_default ().get_favicon_database ();
+ database.favicon_changed.connect ((page_uri, favicon_uri) => {
+ if (page_uri == uri) {
+ load_icon.begin ();
+ }
+ });
+ }
+
+ async void load_icon (Cancellable? cancellable = null) {
+ var database = WebKit.WebContext.get_default ().get_favicon_database ();
+ try {
+ var surface = yield database.get_favicon (uri, cancellable);
+ var image = (Cairo.ImageSurface)surface;
+ var pixbuf = Gdk.pixbuf_get_from_surface (image, 0, 0, image.get_width (), image.get_height ());
+ gicon = (Icon)scale_to_icon_size (pixbuf);
+ } catch (Error error) {
+ debug ("Icon failed to load: %s", error.message);
+ }
+ }
+
+ Gdk.Pixbuf scale_to_icon_size (Gdk.Pixbuf pixbuf) {
+ int icon_width = 16, icon_height = 16;
+ Gtk.icon_size_lookup ((Gtk.IconSize)icon_size, out icon_width, out icon_height);
+ // Take scale factor into account
+ icon_width *= scale_factor;
+ icon_height *= scale_factor;
+ return pixbuf.scale_simple (icon_width, icon_height, Gdk.InterpType.BILINEAR);
+ }
+ }
+}
diff --git a/core/history.vala b/core/history.vala
new file mode 100644
index 00000000..4d70502b
--- /dev/null
+++ b/core/history.vala
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2013-2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ public class HistoryDatabase : Database {
+ static HistoryDatabase? _default = null;
+
+ public static HistoryDatabase get_default () throws DatabaseError {
+ if (_default == null) {
+ _default = new HistoryDatabase ();
+ }
+ return _default;
+ }
+
+ HistoryDatabase () throws DatabaseError {
+ Object (path: "history.db");
+ init ();
+
+ try {
+ exec ("SELECT day FROM history LIMIT 1");
+ } catch (Error error) {
+ exec_script ("Day");
+ }
+ }
+
+ public async bool clear (int64 maximum_age=0) throws DatabaseError {
+ unowned string sqlcmd = """
+ DELETE FROM history WHERE date >= :maximum_age;
+ DELETE FROM search WHERE date >= :maximum_age;
+ """;
+ var statement = prepare (sqlcmd,
+ ":maximum_age", typeof (int64), maximum_age);
+ return statement.exec ();
+ }
+ }
+}
diff --git a/core/loggable.vala b/core/loggable.vala
new file mode 100644
index 00000000..88854791
--- /dev/null
+++ b/core/loggable.vala
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ public interface Loggable : Object {
+ static string? _domain = null;
+ static bool? _logging = null;
+ public string domain { owned get {
+ if (_domain == null) {
+ _domain = get_type ().name ().substring (6, -1).down ();
+ }
+ return _domain;
+ } }
+
+ public bool logging { get {
+ if (_logging == null) {
+ uint flag = int.MAX;
+ foreach (var key in keys) {
+ if (key.key == domain) {
+ flag = key.value;
+ }
+ }
+ string debug_string = Environment.get_variable ("G_MESSAGES_DEBUG");
+ uint flags = parse_debug_string (debug_string, keys);
+ _logging = (flags & flag) != 0;
+ }
+ return _logging;
+ } }
+
+ public void debug (string format, ...) {
+ logv (domain, LogLevelFlags.LEVEL_DEBUG, format, va_list ());
+ }
+ }
+}
diff --git a/extensions/feed-panel/feed-rss.h b/core/main.vala
index d5ccc047..ee89e3e7 100644
--- a/extensions/feed-panel/feed-rss.h
+++ b/core/main.vala
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2009 Dale Whittaker <dayul@users.sf.net>
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -9,17 +9,7 @@
See the file COPYING for the full license text.
*/
-#ifndef __FEED_RSS_H__
-#define __FEED_RSS_H__
-
-#include "feed-parse.h"
-
-G_BEGIN_DECLS
-
-FeedParser*
-rss_init_parser (void);
-
-G_END_DECLS
-
-#endif /* __FEED_RSS_H__ */
-
+static int main (string[] args) {
+ var app = new Midori.App ();
+ return app.run (args);
+}
diff --git a/core/network-check.vala b/core/network-check.vala
new file mode 100644
index 00000000..245988b3
--- /dev/null
+++ b/core/network-check.vala
@@ -0,0 +1,34 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ [GtkTemplate (ui = "/ui/network-check.ui")]
+ public class NetworkCheck : Gtk.ActionBar {
+ [GtkChild]
+ Gtk.Button login;
+
+ construct {
+ login.clicked.connect (login_clicked);
+
+ var monitor = NetworkMonitor.get_default ();
+ visible = monitor.connectivity == NetworkConnectivity.PORTAL;
+ monitor.notify["connectivity"].connect ((pspec) => {
+ visible = monitor.connectivity == NetworkConnectivity.PORTAL;
+ });
+
+ }
+
+ void login_clicked () {
+ var browser = ((Browser)get_toplevel ());
+ browser.add (new Tab (browser.tab, browser.web_context, "http://example.com"));
+ }
+ }
+}
diff --git a/core/statusbar.vala b/core/statusbar.vala
new file mode 100644
index 00000000..954adee7
--- /dev/null
+++ b/core/statusbar.vala
@@ -0,0 +1,26 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ public class Statusbar : Gtk.Statusbar {
+ string? _label = null;
+ public string? label { get { return _label; } set {
+ if (value != null && value != "") {
+ _label = value;
+ show ();
+ } else {
+ _label = "";
+ hide ();
+ }
+ push (1, _label);
+ } }
+ }
+}
diff --git a/core/suggestion-row.vala b/core/suggestion-row.vala
new file mode 100644
index 00000000..3521f782
--- /dev/null
+++ b/core/suggestion-row.vala
@@ -0,0 +1,81 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ [GtkTemplate (ui = "/ui/suggestion-row.ui")]
+ public class SuggestionRow : Gtk.ListBoxRow {
+ public DatabaseItem item { get; protected set; }
+ string? escaped_uri = null;
+ string? escaped_title = null;
+ public string? location { get; set; }
+ public Regex? regex { get; set; }
+ public string? key { get; set; }
+ [GtkChild]
+ Gtk.Box box;
+ [GtkChild]
+ Favicon icon;
+ [GtkChild]
+ Gtk.Label title;
+ [GtkChild]
+ Gtk.Label uri;
+ public SuggestionRow (DatabaseItem item) {
+ Object (item: item);
+ if (item is SuggestionItem) {
+ box.set_child_packing (title, true, true, 0, Gtk.PackType.END);
+ notify["location"].connect ((pspec) => {
+ if (location != null) {
+ item.uri = location;
+ icon.icon_name = "go-jump-symbolic";
+ uri.label = Markup.escape_text (location);
+ title.label = "";
+ }
+ });
+ notify["key"].connect ((pspec) => {
+ if (key != null) {
+ var suggestion = (SuggestionItem)item;
+ item.uri = suggestion.search.printf (Uri.escape_string (key, ":/", true));
+ icon.icon_name = "edit-find-symbolic";
+ uri.label = Markup.escape_text (key);
+ title.label = item.title;
+ }
+ });
+ } else {
+ icon.uri = item.uri;
+ escaped_title = item.title != null ? Markup.escape_text (item.title) : "";
+ title.label = escaped_title;
+ escaped_uri = Markup.escape_text (strip_uri_prefix (item.uri));
+ uri.label = escaped_uri;
+ notify["regex"].connect ((pspec) => {
+ if (regex != null) {
+ try {
+ var highlight = "<b>\\1</b>";
+ uri.label = regex.replace (escaped_uri, -1, 0, highlight);
+ title.label = regex.replace (escaped_title, -1, 0, highlight);
+ } catch (RegexError error) {
+ debug ("Failed to apply regex: %s", error.message);
+ }
+ }
+ });
+ }
+ }
+
+ string? strip_uri_prefix (string uri) {
+ bool is_http = uri.has_prefix ("http://") || uri.has_prefix ("https://");
+ if (is_http || uri.has_prefix ("file://")) {
+ string stripped_uri = uri.split ("://")[1];
+ if (is_http && stripped_uri.has_prefix ("www."))
+ return stripped_uri.substring (4, -1);
+ return stripped_uri;
+ }
+ return uri;
+ }
+ }
+}
diff --git a/core/switcher.vala b/core/switcher.vala
new file mode 100644
index 00000000..4ba504e8
--- /dev/null
+++ b/core/switcher.vala
@@ -0,0 +1,52 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ public class Switcher : Gtk.Box {
+ HashTable<Gtk.Widget, Tally> buttons;
+ public Gtk.Stack? stack { get; set; }
+ public bool show_close_buttons { get; protected set; }
+
+ construct {
+ buttons = new HashTable<Gtk.Widget, Tally> (direct_hash, direct_equal);
+ notify["stack"].connect ((pspec) => {
+ stack.add.connect ((widget) => {
+ if (buttons.lookup (widget) == null && widget is Tab) {
+ var button = new Tally ((Tab)widget);
+ buttons.insert (widget, button);
+ button.active = stack.visible_child == widget;
+ button.clicked.connect (() => {
+ stack.visible_child = widget;
+ });
+ show_close_buttons = buttons.size () > 1;
+ button.show_close = show_close_buttons;
+ bind_property ("show-close-buttons", button, "show-close");
+ add (button);
+ }
+ });
+ stack.notify["visible-child"].connect (visible_child_changed);
+ stack.remove.connect ((widget) => {
+ buttons.take (widget).destroy ();
+ show_close_buttons = buttons.size () > 1;
+ });
+ });
+ }
+
+ void visible_child_changed (ParamSpec pspec) {
+ var button = buttons.lookup (stack.visible_child);
+ if (button != null) {
+ foreach (var b in get_children ()) {
+ ((Tally)b).active = (b == button);
+ }
+ }
+ }
+ }
+}
diff --git a/core/tab.vala b/core/tab.vala
new file mode 100644
index 00000000..f7837cff
--- /dev/null
+++ b/core/tab.vala
@@ -0,0 +1,167 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ [GtkTemplate (ui = "/ui/tab.ui")]
+ public class Tab : WebKit.WebView {
+ public string id { owned get { return "%p".printf (this); } }
+ public double progress { get; protected set; }
+ public new bool can_go_back { get; protected set; }
+ public new bool can_go_forward { get; protected set; }
+ public DatabaseItem? item { get; protected set; default = null; }
+ public string display_title { get; protected set; }
+ public bool pinned { get; set; }
+ public bool secure { get; protected set; }
+ public string link_uri { get; protected set; }
+
+ [GtkChild]
+ Gtk.Popover popover;
+ [GtkChild]
+ Gtk.Label message;
+ [GtkChild]
+ Gtk.Entry entry;
+ [GtkChild]
+ Gtk.Button confirm;
+
+ construct {
+ notify["estimated-load-progress"].connect (update_progress);
+ notify["is-loading"].connect (update_progress);
+ notify["uri"].connect ((pspec) => {
+ display_title = uri;
+ can_go_back = base.can_go_back ();
+ can_go_forward = base.can_go_forward ();
+ });
+ notify["title"].connect ((pspec) => {
+ display_title = (title != null && title != "") ? title : uri;
+ if (item != null) {
+ item.title = display_title;
+ }
+ });
+ }
+
+ public Tab (Tab? related, WebKit.WebContext web_context, string? uri = null) {
+ Object (related_view: related, web_context: web_context, visible: true);
+
+ get_settings ().set_user_agent_with_application_details (
+ Config.PROJECT_NAME, Config.CORE_VERSION);
+ get_settings ().enable_developer_extras = true;
+ load_uri (uri ?? "about:blank");
+ }
+
+ void update_progress (ParamSpec pspec) {
+ // Update back/ forward state here since there's no signal
+ can_go_back = base.can_go_back ();
+ can_go_forward = base.can_go_forward ();
+
+ if (is_loading && estimated_load_progress < 1.0) {
+ // When loading we want to see at minimum 10% progress
+ progress = estimated_load_progress.clamp (0.1, 1.0);
+ } else {
+ // When we are finished, we don't want to *see* progress anymore
+ progress = 0.0;
+ }
+ }
+
+ public override void load_changed (WebKit.LoadEvent load_event) {
+ if (load_event == WebKit.LoadEvent.COMMITTED) {
+ item = new DatabaseItem (uri, display_title, new DateTime.now_local ().to_unix ());
+ try {
+ var history = HistoryDatabase.get_default ();
+ history.insert.begin (item);
+ } catch (DatabaseError error) {
+ debug ("Failed to insert history item: %s", error.message);
+ }
+ secure = get_tls_info (null, null);
+ }
+ }
+
+ public override void mouse_target_changed (WebKit.HitTestResult result, uint modifiers) {
+ link_uri = result.link_uri;
+ }
+
+ public override bool print (WebKit.PrintOperation operation) {
+ operation.run_dialog (get_toplevel () as Gtk.Window);
+ return true;
+ }
+
+ public override void close () {
+ destroy ();
+ }
+
+ public override bool script_dialog (WebKit.ScriptDialog dialog) {
+ message.label = dialog.get_message ();
+ // Render inactive without setting sensitive which affects the popover
+ opacity = 0.3;
+ popover.closed.connect (() => {
+ opacity = 1.0;
+ });
+
+ switch (dialog.get_dialog_type ()) {
+ case WebKit.ScriptDialogType.ALERT:
+ break;
+ case WebKit.ScriptDialogType.CONFIRM:
+ case WebKit.ScriptDialogType.BEFORE_UNLOAD_CONFIRM:
+ confirm.visible = true;
+ popover.closed.connect (() => {
+ dialog.confirm_set_confirmed (false);
+ });
+ confirm.clicked.connect (() => {
+ dialog.confirm_set_confirmed (true);
+ });
+ break;
+ case WebKit.ScriptDialogType.PROMPT:
+ entry.placeholder_text = dialog.prompt_get_default_text ();
+ entry.visible = true;
+ confirm.visible = true;
+ popover.closed.connect (() => {
+ dialog.prompt_set_text ("");
+ });
+ confirm.clicked.connect (() => {
+ dialog.prompt_set_text (entry.text);
+ });
+ break;
+ }
+ popover.show ();
+ return true;
+ }
+
+ public override bool decide_policy (WebKit.PolicyDecision decision, WebKit.PolicyDecisionType type) {
+ switch (type) {
+ case WebKit.PolicyDecisionType.NAVIGATION_ACTION:
+ var action = ((WebKit.NavigationPolicyDecision)decision).navigation_action;
+ if (action.is_user_gesture ()) {
+ // Middle click or ^click for new tab
+ bool has_ctrl = (action.get_modifiers () & Gdk.ModifierType.CONTROL_MASK) != 0;
+ if (action.get_mouse_button () == 2
+ || (has_ctrl && action.get_mouse_button () == 1)) {
+ create (action);
+ decision.ignore ();
+ return true;
+ }
+ }
+ break;
+ case WebKit.PolicyDecisionType.NEW_WINDOW_ACTION:
+ var action = ((WebKit.NavigationPolicyDecision)decision).navigation_action;
+ create (action);
+ decision.ignore ();
+ return true;
+ case WebKit.PolicyDecisionType.RESPONSE:
+ var response_decision = ((WebKit.ResponsePolicyDecision)decision);
+ if (!response_decision.is_mime_type_supported ()) {
+ decision.download ();
+ return true;
+ }
+ break;
+ }
+ return false;
+ }
+ }
+}
diff --git a/core/tally.vala b/core/tally.vala
new file mode 100644
index 00000000..aae8ceed
--- /dev/null
+++ b/core/tally.vala
@@ -0,0 +1,89 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ [GtkTemplate (ui = "/ui/tally.ui")]
+ public class Tally : Gtk.EventBox {
+ public Tab tab { get; protected set; }
+ public string? uri { get; set; }
+ public string? title { get; set; }
+ bool _show_close;
+ public bool show_close { get { return _show_close; } set {
+ _show_close = value;
+ close.visible = _show_close && !tab.pinned;
+ } }
+
+ public signal void clicked ();
+ // Implement toggled state of Gtk.ToggleButton
+ bool _active = false;
+ public bool active { get { return _active; } set {
+ _active = value;
+ if (_active) {
+ set_state_flags (Gtk.StateFlags.CHECKED, false);
+ } else {
+ unset_state_flags (Gtk.StateFlags.CHECKED);
+ }
+ } }
+
+ [GtkChild]
+ Gtk.Label caption;
+ [GtkChild]
+ Gtk.Spinner spinner;
+ [GtkChild]
+ Favicon favicon;
+ [GtkChild]
+ Gtk.Button close;
+
+ public Tally (Tab tab) {
+ Object (tab: tab, uri: tab.uri, title: tab.display_title, visible: tab.visible);
+ tab.bind_property ("uri", this, "uri");
+ tab.bind_property ("display-title", this, "title");
+ tab.bind_property ("visible", this, "visible");
+ close.clicked.connect (() => { tab.try_close (); });
+ tab.notify["is-loading"].connect ((pspec) => {
+ favicon.visible = !tab.is_loading;
+ spinner.visible = !favicon.visible;
+ });
+
+ // Pinned tab style: icon only
+ caption.visible = !tab.pinned;
+ tab.notify["pinned"].connect ((pspec) => {
+ caption.visible = !tab.pinned;
+ close.visible = _show_close && !tab.pinned;
+ });
+ }
+
+ construct {
+ bind_property ("uri", favicon, "uri");
+ bind_property ("title", caption, "label");
+ add_events (Gdk.EventMask.ENTER_NOTIFY_MASK);
+ add_events (Gdk.EventMask.LEAVE_NOTIFY_MASK);
+ enter_notify_event.connect ((event) => {
+ set_state_flags (Gtk.StateFlags.PRELIGHT, false);
+ });
+ leave_notify_event.connect ((event) => {
+ unset_state_flags (Gtk.StateFlags.PRELIGHT);
+ });
+ }
+
+ protected override bool button_release_event (Gdk.EventButton event) {
+ switch (event.button) {
+ case 1:
+ clicked ();
+ break;
+ case 3:
+ tab.try_close ();
+ break;
+ }
+ return true;
+ }
+ }
+}
diff --git a/core/urlbar.vala b/core/urlbar.vala
new file mode 100644
index 00000000..1b5c70b6
--- /dev/null
+++ b/core/urlbar.vala
@@ -0,0 +1,320 @@
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.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.
+*/
+
+namespace Midori {
+ [GtkTemplate (ui = "/ui/urlbar.ui")]
+ public class Urlbar : Gtk.Entry {
+ public string? key { get; protected set; }
+ public Regex? regex { get; protected set; }
+ public string? location { get; protected set; }
+ string _uri;
+ public string uri { get {
+ return _uri;
+ } set {
+ _uri = value;
+ location = value;
+ // Treat about:blank specially
+ text = value != "about:blank" ? value : "";
+ } }
+ bool _secure = false;
+ public bool secure { get { return _secure; } set {
+ _secure = value;
+ primary_icon_name = value ? "channel-secure-symbolic" : null;
+ primary_icon_activatable = value;
+ } }
+
+ [GtkChild]
+ Gtk.Popover? suggestions;
+ [GtkChild]
+ Gtk.ListBox listbox;
+ Gtk.ListBoxRow? selected_row { get; protected set; default = null; }
+ [GtkChild]
+ Gtk.Popover security;
+ [GtkChild]
+ Gtk.Box security_box;
+ Gcr.CertificateWidget? details = null;
+
+ construct {
+ size_allocate.connect (resize);
+ suggestions.hide.connect (() => {
+ Gtk.grab_remove (suggestions);
+ });
+
+ listbox.row_selected.connect ((row) => {
+ if (row != null && selected_row != row) {
+ var suggestion_row = (SuggestionRow)row;
+ string? new_text = suggestion_row.item.uri;
+ if (suggestion_row.item is SuggestionItem) {
+ new_text = key;
+ }
+ if (new_text != null && new_text != text) {
+ text = new_text;
+ set_position (-1);
+ }
+ }
+ selected_row = row;
+ });
+ listbox.row_activated.connect ((row) => {
+ popdown ();
+ var suggestion = (SuggestionRow)row;
+ uri = suggestion.item.uri;
+ });
+
+ icon_press.connect (icon_pressed);
+ }
+
+ public Gtk.Widget create_row (Object item) {
+ var suggestion = new SuggestionRow ((DatabaseItem)item);
+ suggestion.key = key;
+ bind_property ("key", suggestion, "key");
+ suggestion.regex = regex;
+ bind_property ("regex", suggestion, "regex");
+ suggestion.location = location;
+ bind_property ("location", suggestion, "location");
+ return suggestion;
+ }
+
+ protected override bool key_press_event (Gdk.EventKey event) {
+ // Listbox
+ if (suggestions.visible) {
+ bool has_shift = (event.state & Gdk.ModifierType.SHIFT_MASK) != 0;
+ switch (event.keyval) {
+ case Gdk.Key.Tab:
+ case Gdk.Key.ISO_Left_Tab:
+ case Gdk.Key.Down:
+ case Gdk.Key.KP_Down:
+ listbox.move_cursor (Gtk.MovementStep.DISPLAY_LINES,
+ has_shift ? -1 : 1);
+ return true;
+ case Gdk.Key.Up:
+ case Gdk.Key.KP_Up:
+ listbox.move_cursor (Gtk.MovementStep.DISPLAY_LINES, -1);
+ return true;
+ case Gdk.Key.Left:
+ case Gdk.Key.KP_Left:
+ case Gdk.Key.Right:
+ case Gdk.Key.KP_Right:
+ popdown ();
+ return base.key_press_event (event);
+ case Gdk.Key.Delete:
+ case Gdk.Key.KP_Delete:
+ var suggestion_row = (SuggestionRow)selected_row;
+ if (suggestion_row != null) {
+ listbox.move_cursor (Gtk.MovementStep.DISPLAY_LINES, -1);
+ suggestion_row.item.delete.begin ();
+ }
+ return true;
+ case Gdk.Key.Escape:
+ popdown ();
+ return true;
+ }
+ // The list receives events first, then the popover
+ if (!listbox.key_press_event (event)) {
+ if (suggestions.key_press_event (event)) {
+ return true;
+ }
+ }
+ }
+ // Entry
+ switch (event.keyval) {
+ case Gdk.Key.Tab:
+ case Gdk.Key.ISO_Left_Tab:
+ return false;
+ case Gdk.Key.ISO_Enter:
+ case Gdk.Key.KP_Enter:
+ case Gdk.Key.Return:
+ bool has_ctrl = (event.state & Gdk.ModifierType.CONTROL_MASK) != 0;
+ if (has_ctrl) {
+ popdown ();
+ bool has_shift = (event.state & Gdk.ModifierType.SHIFT_MASK) != 0;
+ if (has_shift) {
+ Application.get_default ().activate_action ("win-new", text);
+ } else {
+ var browser = ((Browser)get_toplevel ());
+ browser.add (new Tab (browser.tab, browser.web_context, text));
+ }
+ } else {
+ listbox.activate_cursor_row ();
+ }
+ return true;
+ case Gdk.Key.Down:
+ case Gdk.Key.KP_Down:
+ complete ();
+ return true;
+ case Gdk.Key.Escape:
+ text = uri;
+ // Propagate to allow Escape to stop loading
+ return false;
+ }
+
+ // Interpret input
+ bool entry_handled_key_press = base.key_press_event (event);
+
+ location = magic_uri (text);
+ if (location == null) {
+ try {
+ key = text;
+ regex = new Regex ("(%s)".printf (Regex.escape_string (key)),
+ RegexCompileFlags.CASELESS);
+ } catch (RegexError error) {
+ debug ("Failed to create regex: %s", error.message);
+ }
+ } else {
+ regex = null;
+ }
+
+ // No completion on control characters
+ unichar character = Gdk.keyval_to_unicode (event.keyval);
+ if (character != 0 && event.is_modifier == 0) {
+ complete ();
+ }
+
+ return entry_handled_key_press;
+ }
+
+ string? magic_uri (string text) {
+ if (Path.is_absolute (text)) {
+ try {
+ return Filename.to_uri (text);
+ } catch (ConvertError error ) {
+ debug ("Failed to convert URI to filename: %s", error.message);
+ return text;
+ }
+ } else if (FileUtils.test (text, FileTest.EXISTS | FileTest.IS_REGULAR)) {
+ return File.new_for_commandline_arg (text).get_uri ();
+ }else if (is_external (text)) {
+ return text;
+ } else if (text.has_prefix ("geo:")) {
+ // Parse URI geo:48.202778,16.368472;crs=wgs84;u=40 as location
+ return text;
+ } else if (is_location (text)) {
+ return text;
+ } else if (is_ip_address (text)) {
+ return "http://" + text;
+ } else if (text == "localhost" || "." in text) {
+ return "http://" + text;
+ } else if (text == "") {
+ return "about:blank";
+ }
+ // This seems to be keywords for a search
+ return null;
+ }
+
+ bool is_location (string uri) {
+ /* file:// is not considered a location for security reasons */
+ return (("://" in uri && !(" " in uri)))
+ || uri.has_prefix ("http://")
+ || uri.has_prefix ("https://")
+ || uri.has_prefix ("about:")
+ || (uri.has_prefix ("data:") && (";" in uri))
+ || uri.has_prefix ("javascript:");
+ }
+
+ bool is_external (string uri) {
+ if (uri.has_prefix ("file://")) {
+ return true;
+ }
+ var scheme = Uri.parse_scheme (uri);
+ return scheme != null
+ && AppInfo.get_default_for_uri_scheme (scheme) != null;
+ }
+
+ bool is_ip_address (string uri) {
+ /* Quick check for IPv4 or IPv6, no validation.
+ hostname_is_ip_address () is not used because
+ we'd have to separate the path from the URI first. */
+ /* Skip leading user/ password */
+ if ("@" in uri)
+ return is_ip_address (uri.split ("@")[1]);
+ /* IPv4 */
+ if (uri[0] != '0' && uri[0].isdigit () && "." in uri)
+ return true;
+ /* IPv6 */
+ if (uri[0].isalnum () && uri[1].isalnum ()
+ && uri[2].isalnum () && uri[3].isalnum () && uri[4] == ':'
+ && (uri[5] == ':' || uri[5].isalnum ()))
+ return true;
+ return false;
+ }
+
+ protected override bool focus_out_event (Gdk.EventFocus event) {
+ suggestions.hide ();
+ return base.focus_out_event (event);
+ }
+
+ /*
+ https://ac.duckduckgo.com/ac/?q={searchTerms}&type=list
+ ["cat",["catlux","cathay pacific","cats","catherine zeta-jones","caterpillar","cathy fischer","cate blanchett","cat stevens","catwoman","catch the millionaire"]]
+ https://encrypted.google.com/complete/search?output=firefox&q={searchTerms}
+ ["cat",["catching fire","catalina island","catching fire movie","cathay pacific","caterpillar","cats","catching fire cast","catwoman","catherine zeta jones","cato"]]
+ */
+
+ public void popdown () {
+ // Note: Guard against popover being destroyed before popdown
+ if (suggestions != null) {
+ suggestions.hide ();
+ grab_focus_without_selecting ();
+ }
+ }
+
+ void resize (Gtk.Allocation allocation) {
+ // 2/3 of window size
+ int width;
+ ((Gtk.Window)(get_toplevel ())).get_size (out width, null);
+ width = (int)(width / 1.5);
+ listbox.set_size_request (width, -1);
+ }
+
+ void complete () {
+ if (!suggestions.visible) {
+ suggestions.set_default_widget (this);
+ suggestions.relative_to = this;
+ var completion = new Completion ();
+ bind_property ("key", completion, "key");
+ listbox.bind_model (completion, create_row);
+ }
+ suggestions.show ();
+ Gtk.grab_add (suggestions);
+ suggestions.grab_focus ();
+ }
+
+ void icon_pressed (Gtk.EntryIconPosition position, Gdk.Event event) {
+ TlsCertificate tls;
+ TlsCertificateFlags flags;
+ ((Browser)get_toplevel ()).tab.get_tls_info (out tls, out flags);
+ var certificate = tls != null ? new Gcr.SimpleCertificate (tls.certificate.data) : null;
+ if (details == null) {
+ var icon_area = get_icon_area (position);
+ security.relative_to = this;
+ security.pointing_to = icon_area;
+ // Clicking expander causes an assertion:
+ // Gtk.Widget.is_ancestor: is Gtk.Widget
+ // Override popdown here to avoid that problem.
+ security.button_press_event.connect ((event) => {
+ var widget = Gtk.get_event_widget (event);
+ if (widget != this && !widget.is_ancestor (security)) {
+ security.hide ();
+ }
+ return true;
+ });
+
+ // Insert widget here because Gtk.Builder won't recognize the type
+ details = new Gcr.CertificateWidget (null);
+ details.show ();
+ security_box.add (details);
+ security_box.reorder_child (details, 0);
+ } else {
+ details.certificate = certificate;
+ }
+ security.show ();
+ }
+ }
+}
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index 50859cfb..8e86bd49 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -1,9 +1,4 @@
-# Copyright (C) 2013 Christian Dywan <christian@twotoasts.de>
-
-include(FindConvert)
-if (NOT CONVERT_FOUND)
- message(FATAL_ERROR "rsvg-convert not found")
-endif ()
+# Copyright (C) 2013-2018 Christian Dywan <christian@twotoasts.de>
include(FindIntltool)
if (NOT INTLTOOL_MERGE_FOUND)
@@ -16,9 +11,7 @@ file(GLOB_RECURSE DATA_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
list(REMOVE_ITEM DATA_FILES "CMakeLists.txt")
foreach(FILE ${DATA_FILES})
- if (${FILE} MATCHES "faq.")
- install(FILES ${FILE} DESTINATION ${CMAKE_INSTALL_DOCDIR})
- elseif (${FILE} MATCHES ".desktop")
+ if (${FILE} MATCHES ".desktop")
if (NOT WIN32)
string(REPLACE ".desktop.in" "" DESKTOP_ID ${FILE})
INTLTOOL_MERGE_DESKTOP (${DESKTOP_ID} po)
@@ -28,31 +21,6 @@ foreach(FILE ${DATA_FILES})
string(REPLACE ".appdata.xml.in" "" DESKTOP_ID ${FILE})
INTLTOOL_MERGE_APPDATA (${DESKTOP_ID} po)
endif ()
- elseif (${FILE} MATCHES "\\.svg$")
- string(REPLACE ".svg" "" IMG_ID ${FILE})
- string (FIND ${FILE} "/" IS_DIR)
- if (IS_DIR GREATER -1)
- string(REPLACE "/" ";" DIR_LIST ${FILE})
- LIST(GET DIR_LIST 0 S_DIR)
- SVG2PNG (${IMG_ID} "${CMAKE_INSTALL_DATADIR}/midori/res/${S_DIR}")
- else ()
- SVG2PNG (${IMG_ID} "${CMAKE_INSTALL_DATADIR}/midori/res/")
- endif()
- # These are being handled in add_executable for the "midori" binary
- elseif (${FILE} MATCHES "\\.ico$")
- elseif (${FILE} MATCHES "\\.rc$")
- # This is only meant for testing, and not used in production
- elseif (${FILE} MATCHES "\\.swf$")
- else()
- string(FIND ${FILE} "/" IS_DIR)
- if (IS_DIR GREATER -1)
- string(REPLACE "/" ";" DIR_LIST ${FILE})
- LIST(GET DIR_LIST 0 S_DIR)
- LIST(GET DIR_LIST 1 S_FILE)
- install(FILES ${S_DIR}/${S_FILE} DESTINATION ${CMAKE_INSTALL_DATADIR}/midori/res/${S_DIR})
- else ()
- install(FILES ${FILE} DESTINATION ${CMAKE_INSTALL_DATADIR}/midori/res/)
- endif()
endif()
endforeach()
diff --git a/data/about.css b/data/about.css
deleted file mode 100644
index 61a767d0..00000000
--- a/data/about.css
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- about: page style template for Midori.
- This file is licensed under the terms of the expat license, see the file EXPAT.
- */
-body {
- background-color: #dedede;
- color: #222222;
- font-family: 'Open Sans', 'Droid Sans', Arial, sans-serif;
- font-size: 14px;
- font-style: normal;
- font-variant: normal;
- font-weight: normal;
- margin-top: 100px;
-}
-
-html[dir="rtl"] #icon {
- float: right;
- padding-right: 1%;
-}
-
-.indent {
- margin-left: 5%;
-}
-
-#main {
- max-width: 50%;
- margin-left: auto;
- margin-right: auto;
- min-width: 480px;
- background-repeat: no-repeat;
- background-color: #ffffff;
- border: 1px solid rgba(0, 0, 0, .3);
- padding: 25px;
- -webkit-border-radius: 4px;
- -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.1);
- background-position-x: 22px;
- background-position-y: 54px;
-}
-
-#text {
- margin-left: 15%;
-}
-
-h1 {
- font-family: 'Open Sans', 'Droid Sans', arial, sans-serif;
- font-size: 32px;
- font-style: normal;
- font-variant: normal;
- font-weight: 300;
- width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
-}
-
-html[dir="ltr"] #logo {
- right: 15px;
-}
-
-html[dir="rtl"] #logo {
- left: 15px;
-}
-
-button span,
-button img {
- vertical-align: middle;
- padding: 2px 1px;
-}
-
-button {
- font-size: 14px;
-}
-
-.message {
- overflow: hidden;
- text-overflow: ellipsis;
-}
-
-.description {
- font-size: 1em;
- overflow: hidden;
- text-overflow: ellipsis;
-}
-
-#suggestions {
- overflow: hidden;
- text-overflow: ellipsis;
-}
-
-#button {
- text-align: right;
-}
-
-#logo {
- position: absolute; bottom: 15px;
- z-index: -1;
-}
-
-form {
- margin-bottom: 0px;
-}
diff --git a/data/adblock.list b/data/adblock.list
deleted file mode 100644
index ba8d4bb5..00000000
--- a/data/adblock.list
+++ /dev/null
@@ -1,55 +0,0 @@
-[Adblock Plus 2.0]
-! Version: 201402142200
-! Title: Exercise
-! Last modified: 11 Feb 2014 22:00 UTC
-! Expires: 3 days (update frequency)
-! Homepage: http://www.midori-browser.org
-! Licence: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
-! Copyright (C) 2014 Christian Dywan <christian@twotoasts.de>
-!
-! Some freeform text:
-! Yadayada http://example.com/ e-mail (somebody@example.com).
-!
-!-----Spam eggs--------!
-! *** la:le/lu_foo_bar.txt ***
-|/http://ads.blub.boing/*$domain=xxx.com
-|/http://ads.blub.boing/*$domain=xxx.com,foo.fr,coco.at
-/market.php?$domain=adf.ly|foo.com
-/?placement=$script,domain=putlocker.com|sockshare.com
-
-! Some basic filters
-*ads.foo.bar*
-*ads.bogus.name*
-||^http://ads.bla.blub/*
-engine.adct.ru/*?
-/addyn|*|adtech;
-doubleclick.net/pfadx/*.mtvi
-objects.tremormedia.com/embed/xml/*.xml?r=
-videostrip.com^*/admatcherclient.
-test.dom/test?var
-/adpage.
-br.gcl.ru/cgi-bin/br/
-_300x600.
-_rectangle_ads.
-+adverts/
--2/ads/
-
-! CSS elements
-old.tv,delicio.us,longc.at###box
-##.zRightAdNote
-###advertisingModule160x600
-##a[href$="/vghd.shtml"]
-imagetwist.com###left[align="center"] > center > a[target="_blank"]
-
-! Options
-||videobox.com/?tid=$popup
-||sexsearchcom.com^$popup,third-party
-||206.217.206.137^$third-party
-/spopunder^$popup
-||putlocker.com^*.php?*title$subdocument
-://ads.$popup
-
-! Whitelist
-@@||hortifor.com/images/*120x60$~third-party
-@@||stickam.com/wb/www/category/300x250/$image
-@@||adultadworld.com/adhandler/$subdocument
diff --git a/data/adblock/element_hider.js b/data/adblock/element_hider.js
deleted file mode 100644
index c9ad4bdf..00000000
--- a/data/adblock/element_hider.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- Copyright (C) 2014 Alexander V. Butenko <a.butenka@gmail.com>
-
- 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.
- */
-function getElementsByAttribute (strTagName, strAttributeName, arrAttributeValue) {
- var arrElements = document.getElementsByTagName (strTagName);
- var arrReturnElements = new Array();
- for (var j=0; j<arrAttributeValue.length; j++) {
- var strAttributeValue = arrAttributeValue[j];
- for (var i=0; i<arrElements.length; i++) {
- var oCurrent = arrElements[i];
- var oAttribute = oCurrent.getAttribute && oCurrent.getAttribute (strAttributeName);
- if (oAttribute && oAttribute.length > 0 && strAttributeValue.indexOf (oAttribute) != -1)
- arrReturnElements.push (oCurrent);
- }
- }
- return arrReturnElements;
-};
-
-function hideElementBySrc (uris) {
- var oElements = getElementsByAttribute('img', 'src', uris);
- if (oElements.length == 0)
- oElements = getElementsByAttribute ('iframe', 'src', uris);
- for (var i=0; i<oElements.length; i++) {
- oElements[i].style.visibility = 'hidden !important';
- oElements[i].style.width = '0';
- oElements[i].style.height = '0';
- }
-};
diff --git a/data/autosuggestcontrol.css b/data/autosuggestcontrol.css
deleted file mode 100644
index a34bc268..00000000
--- a/data/autosuggestcontrol.css
+++ /dev/null
@@ -1,14 +0,0 @@
-div.suggestions {
- -webkit-appearance: listbox;
- text-align: left;
- position: absolute;
- z-index: 999;
-}
-div.suggestions div {
- cursor: default;
- padding: 0px 3px;
-}
-div.suggestions div.current {
- background-color: #3366cc;
- color: white;
-}
diff --git a/data/autosuggestcontrol.js b/data/autosuggestcontrol.js
deleted file mode 100644
index 9c65d16d..00000000
--- a/data/autosuggestcontrol.js
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- An autosuggest textbox control.
- Copyright (C) 2012 Nicholas C. Zakas (Author) example: http://www.nczonline.net/
- Adopted for Midori by Alexander V. Butenko <a.butenka@gmail.com>
-
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the Nicholas C. Zakas nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
- oProvider /*:SuggestionProvider*/) {
- /**
- * The currently selected suggestions.
- * @scope private
- */
- this.cur /*:int*/ = -1;
- /**
- * The dropdown list layer.
- * @scope private
- */
- this.layer = null;
- /**
- * Suggestion provider for the autosuggest feature.
- * @scope private.
- */
- this.provider /*:SuggestionProvider*/ = oProvider;
- /**
- * The textbox to capture.
- * @scope private
- */
- this.textbox /*:HTMLInputElement*/ = oTextbox;
- //initialize the control
- this.init();
-}
-
-/**
- * Autosuggests one or more suggestions for what the user has typed.
- * If no suggestions are passed in, then no autosuggest occurs.
- * @scope private
- * @param aSuggestions An array of suggestion strings.
- * @param bTypeAhead If the control should provide a type ahead suggestion.
- */
-AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/) {
- if (aSuggestions.length > 0) {
- this.showSuggestions(aSuggestions);
- } else {
- this.hideSuggestions();
- }
-};
-
-/**
- * Creates the dropdown layer to display multiple suggestions.
- * @scope private
- */
-AutoSuggestControl.prototype.createDropDown = function () {
- var sDiv = document.getElementById("suggestions_box");
- if (sDiv) {
- this.layer = sDiv;
- return;
- }
- this.layer = document.createElement("div");
- this.layer.className = "suggestions";
- this.layer.id = "suggestions_box";
- this.layer.style.visibility = "hidden";
- this.layer.style.width = this.textbox.offsetWidth;
- document.body.appendChild(this.layer);
-};
-
-/**
- * Gets the left coordinate of the textbox.
- * @scope private
- * @return The left coordinate of the textbox in pixels.
- */
-AutoSuggestControl.prototype.getLeft = function () /*:int*/ {
- var oNode = this.textbox;
- var iLeft = 0;
- while (oNode.tagName != "BODY") {
- iLeft += oNode.offsetLeft;
- oNode = oNode.offsetParent;
- }
- return iLeft;
-};
-
-/**
- * Gets the top coordinate of the textbox.
- * @scope private
- * @return The top coordinate of the textbox in pixels.
- */
-AutoSuggestControl.prototype.getTop = function () /*:int*/ {
- var oNode = this.textbox;
- var iTop = 0;
- while(oNode.tagName != "BODY") {
- iTop += oNode.offsetTop;
- oNode = oNode.offsetParent;
- }
- return iTop;
-};
-
-/**
- * Handles three keydown events.
- * @scope private
- * @param oEvent The event object for the keydown event.
- */
-AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) {
- switch(oEvent.keyCode) {
- case 38: //up arrow
- this.previousSuggestion();
- break;
- case 40: //down arrow
- this.nextSuggestion();
- break;
- case 13: //enter
- this.hideSuggestions();
- break;
- }
-};
-
-/**
- * Handles keyup events.
- * @scope private
- * @param oEvent The event object for the keyup event.
- */
-AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) {
- var iKeyCode = oEvent.keyCode;
- if (iKeyCode == 8 || iKeyCode == 46) {
- this.provider.requestSuggestions(this);
- //make sure not to interfere with non-character keys
- } else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123) ) {
- //ignore
- } else if (oEvent.ctrlKey) {
- this.hideSuggestions();
- } else {
- //request suggestions from the suggestion provider
- this.provider.requestSuggestions(this);
- }
-};
-
-/**
- * Hides the suggestion dropdown.
- * @scope private
- */
-AutoSuggestControl.prototype.hideSuggestions = function () {
- this.layer.style.visibility = "hidden";
-};
-
-/**
- * Highlights the given node in the suggestions dropdown.
- * @scope private
- * @param oSuggestionNode The node representing a suggestion in the dropdown.
- */
-AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) {
- for (var i=0; i < this.layer.childNodes.length; i++) {
- var oNode = this.layer.childNodes[i];
- if (oNode == oSuggestionNode) {
- oNode.className = "current"
- } else if (oNode.className == "current") {
- oNode.className = "";
- }
- }
-};
-
-/**
- * Initializes the textbox with event handlers for
- * auto suggest functionality.
- * @scope private
- */
-AutoSuggestControl.prototype.init = function () {
- //save a reference to this object
- var oThis = this;
-
- //assign the onkeyup event handler
- this.textbox.onkeyup = function (oEvent) {
- //check for the proper location of the event object
- if (!oEvent) {
- oEvent = window.event;
- }
- //call the handleKeyUp() method with the event object
- oThis.handleKeyUp(oEvent);
- };
-
- //assign onkeydown event handler
- this.textbox.onkeydown = function (oEvent) {
- //check for the proper location of the event object
- if (!oEvent) {
- oEvent = window.event;
- }
- //call the handleKeyDown() method with the event object
- oThis.handleKeyDown(oEvent);
- };
-
- //assign onblur event handler (hides suggestions)
- if (!this.textbox.onblur)
- this.textbox.onblur = function () { oThis.hideSuggestions(); };
- if (!this.textbox.onclick)
- this.textbox.onclick = function () { oThis.hideSuggestions(); };
-
- //create the suggestions dropdown
- this.createDropDown();
-};
-
-/**
- * Highlights the next suggestion in the dropdown and
- * places the suggestion into the textbox.
- * @scope private
- */
-AutoSuggestControl.prototype.nextSuggestion = function () {
- var cSuggestionNodes = this.layer.childNodes;
-
- if (!cSuggestionNodes.length)
- return;
-
- if (this.cur == cSuggestionNodes.length-1)
- this.cur = -1;
-
- var oNode = cSuggestionNodes[++this.cur];
- this.highlightSuggestion(oNode);
- this.textbox.value = oNode.firstChild.nodeValue;
-};
-
-/**
- * Highlights the previous suggestion in the dropdown and
- * places the suggestion into the textbox.
- * @scope private
- */
-AutoSuggestControl.prototype.previousSuggestion = function () {
- var cSuggestionNodes = this.layer.childNodes;
-
- if (!cSuggestionNodes.length)
- return;
-
- if (this.cur == -1 || this.cur == 0)
- this.cur = cSuggestionNodes.length;
-
- var oNode = cSuggestionNodes[--this.cur];
- this.highlightSuggestion(oNode);
- this.textbox.value = oNode.firstChild.nodeValue;
-};
-
-/**
- * Builds the suggestion layer contents, moves it into position,
- * and displays the layer.
- * @scope private
- * @param aSuggestions An array of suggestions for the control.
- */
-AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {
- var oThis = this;
- var oDiv = null;
- this.layer.innerHTML = ""; //clear contents of the layer
-
- for (var i=0; i < aSuggestions.length; i++) {
- oDiv = document.createElement("div");
- oDiv.appendChild(document.createTextNode(aSuggestions[i]));
- this.layer.appendChild(oDiv);
- }
-
- this.layer.style.left = this.getLeft() + "px";
- this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
- this.layer.style.visibility = "visible";
- this.layer.style.position = "absolute";
- this.layer.onmousedown =
- this.layer.onmouseup =
- this.layer.onmouseover = function (oEvent) {
- var oEvent = oEvent || window.event;
- var oTarget = oEvent.target || oEvent.srcElement;
-
- if (oEvent.type == "mousedown") {
- oThis.textbox.value = oTarget.firstChild.nodeValue;
- oThis.hideSuggestions();
- } else if (oEvent.type == "mouseover") {
- oThis.highlightSuggestion(oTarget);
- } else {
- oThis.textbox.focus();
- }
- };
-};
-
-/**
- * Request suggestions for the given autosuggest control.
- * @scope protected
- * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
- */
-FormSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/) {
- var aSuggestions = [];
- var sTextboxValue = oAutoSuggestControl.textbox.value.toLowerCase();
-
- if (!this.suggestions)
- return;
-
- //search for matching suggestions
- if (sTextboxValue.length)
- for (var i=0; i < this.suggestions.length; i++) {
- if (this.suggestions[i].toLowerCase().indexOf(sTextboxValue) == 0) {
- aSuggestions.push(this.suggestions[i]);
- }
- }
- //provide suggestions to the control
- oAutoSuggestControl.autosuggest(aSuggestions);
-};
-
-function initSuggestions () {
- var inputs = document.getElementsByTagName ("input");
- if (inputs.length == 0)
- return false;
-
- for (var i=0;i<inputs.length;i++)
- {
- var ename = inputs[i].getAttribute("name");
- var eid = inputs[i].getAttribute("id");
- var autocomplete = inputs[i].getAttribute ("autocomplete");
-
- if (!ename && eid)
- ename=eid;
- if (inputs[i].type == "text" && autocomplete != "off")
- var smth = new AutoSuggestControl (inputs[i], new FormSuggestions (ename));
- }
- return true;
-};
diff --git a/data/bookmarks/Create.sql b/data/bookmarks/Create.sql
deleted file mode 100644
index 7500fc2c..00000000
--- a/data/bookmarks/Create.sql
+++ /dev/null
@@ -1,91 +0,0 @@
-CREATE TABLE IF NOT EXISTS bookmarks
-(
- id INTEGER PRIMARY KEY AUTOINCREMENT,
- parentid INTEGER DEFAULT NULL,
- title TEXT,
- uri TEXT,
- desc TEXT,
- app INTEGER,
- toolbar INTEGER,
- pos_panel INTEGER,
- pos_bar INTEGER,
- created DATE DEFAULT CURRENT_TIMESTAMP,
- last_visit DATE,
- visit_count INTEGER DEFAULT 0,
- nick TEXT,
-
- FOREIGN KEY(parentid) REFERENCES bookmarks(id) ON DELETE CASCADE
-);
-
-/* trigger: insert panel position */
-CREATE TRIGGER IF NOT EXISTS bookmarkInsertPosPanel
-AFTER INSERT ON bookmarks FOR EACH ROW
-BEGIN UPDATE bookmarks SET pos_panel = (
-SELECT ifnull(MAX(pos_panel),0)+1 FROM bookmarks WHERE
-(NEW.parentid IS NOT NULL AND parentid = NEW.parentid)
-OR (NEW.parentid IS NULL AND parentid IS NULL))
-WHERE id = NEW.id; END;
-
-/* trigger: insert Bookmarkbar position */
-CREATE TRIGGER IF NOT EXISTS bookmarkInsertPosBar
-AFTER INSERT ON bookmarks FOR EACH ROW WHEN NEW.toolbar=1
-BEGIN UPDATE bookmarks SET pos_bar = (
-SELECT ifnull(MAX(pos_bar),0)+1 FROM bookmarks WHERE
-((NEW.parentid IS NOT NULL AND parentid = NEW.parentid)
-OR (NEW.parentid IS NULL AND parentid IS NULL)) AND toolbar=1)
-WHERE id = NEW.id; END;
-
-/* trigger: update panel position */
-CREATE TRIGGER IF NOT EXISTS bookmarkUpdatePosPanel
-BEFORE UPDATE OF parentid ON bookmarks FOR EACH ROW
-WHEN ((NEW.parentid IS NULL OR OLD.parentid IS NULL)
-AND NEW.parentid IS NOT OLD.parentid) OR
-((NEW.parentid IS NOT NULL AND OLD.parentid IS NOT NULL)
-AND NEW.parentid!=OLD.parentid)
-BEGIN UPDATE bookmarks SET pos_panel = pos_panel-1
-WHERE ((OLD.parentid IS NOT NULL AND parentid = OLD.parentid)
-OR (OLD.parentid IS NULL AND parentid IS NULL)) AND pos_panel > OLD.pos_panel;
-UPDATE bookmarks SET pos_panel = (
-SELECT ifnull(MAX(pos_panel),0)+1 FROM bookmarks
-WHERE (NEW.parentid IS NOT NULL AND parentid = NEW.parentid)
-OR (NEW.parentid IS NULL AND parentid IS NULL))
-WHERE id = OLD.id; END;
-
-/* trigger: update Bookmarkbar position */
-CREATE TRIGGER IF NOT EXISTS bookmarkUpdatePosBar0
-AFTER UPDATE OF parentid, toolbar ON bookmarks FOR EACH ROW
-WHEN ((NEW.parentid IS NULL OR OLD.parentid IS NULL)
-AND NEW.parentid IS NOT OLD.parentid)
-OR ((NEW.parentid IS NOT NULL AND OLD.parentid IS NOT NULL)
-AND NEW.parentid!=OLD.parentid) OR (OLD.toolbar=1 AND NEW.toolbar=0)
-BEGIN UPDATE bookmarks SET pos_bar = NULL WHERE id = NEW.id;
-UPDATE bookmarks SET pos_bar = pos_bar-1
-WHERE ((OLD.parentid IS NOT NULL AND parentid = OLD.parentid)
-OR (OLD.parentid IS NULL AND parentid IS NULL)) AND pos_bar > OLD.pos_bar; END;
-
-/* trigger: update Bookmarkbar position */
-CREATE TRIGGER IF NOT EXISTS bookmarkUpdatePosBar1
-BEFORE UPDATE OF parentid, toolbar ON bookmarks FOR EACH ROW
-WHEN ((NEW.parentid IS NULL OR OLD.parentid IS NULL)
-AND NEW.parentid IS NOT OLD.parentid) OR
-((NEW.parentid IS NOT NULL AND OLD.parentid IS NOT NULL)
-AND NEW.parentid!=OLD.parentid) OR (OLD.toolbar=0 AND NEW.toolbar=1)
-BEGIN UPDATE bookmarks SET pos_bar = (
-SELECT ifnull(MAX(pos_bar),0)+1 FROM bookmarks WHERE
-(NEW.parentid IS NOT NULL AND parentid = NEW.parentid)
-OR (NEW.parentid IS NULL AND parentid IS NULL))
-WHERE id = OLD.id; END;
-
-/* trigger: delete panel position */
-CREATE TRIGGER IF NOT EXISTS bookmarkDeletePosPanel
-AFTER DELETE ON bookmarks FOR EACH ROW
-BEGIN UPDATE bookmarks SET pos_panel = pos_panel-1
-WHERE ((OLD.parentid IS NOT NULL AND parentid = OLD.parentid)
-OR (OLD.parentid IS NULL AND parentid IS NULL)) AND pos_panel > OLD.pos_panel; END;
-
-/* trigger: delete Bookmarkbar position */
-CREATE TRIGGER IF NOT EXISTS bookmarkDeletePosBar
-AFTER DELETE ON bookmarks FOR EACH ROW WHEN OLD.toolbar=1
-BEGIN UPDATE bookmarks SET pos_bar = pos_bar-1
-WHERE ((OLD.parentid IS NOT NULL AND parentid = OLD.parentid)
-OR (OLD.parentid IS NULL AND parentid IS NULL)) AND pos_bar > OLD.pos_bar; END;
diff --git a/data/bookmarks/Import_old_db_bookmarks.sql b/data/bookmarks/Import_old_db_bookmarks.sql
deleted file mode 100644
index 5e023cda..00000000
--- a/data/bookmarks/Import_old_db_bookmarks.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-INSERT INTO main.bookmarks (parentid, title, uri, desc, app, toolbar)
-SELECT NULL AS parentid, title, uri, desc, app, toolbar
-FROM old_db.bookmarks;
-UPDATE main.bookmarks SET parentid = (
-SELECT id FROM main.bookmarks AS b1 WHERE b1.title = (
-SELECT folder FROM old_db.bookmarks WHERE title = main.bookmarks.title));
diff --git a/data/error.html b/data/error.html
deleted file mode 100644
index 73cae7a4..00000000
--- a/data/error.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!--
- Error page template for Midori.
- This file is licensed under the terms of the expat license, see the file EXPAT.
--->
-<html dir="{dir}">
-<head>
-<title>{title}</title>
-{favicon}
-<link rel="stylesheet" type="text/css" href="res://about.css" />
-</head>
-<body>
-<img id="logo" src="res://logo-shade.png" />
-<div id="main" style="background-image: url({error_icon});">
- <div id="text">
- <h1>{title}</h1>
- <p class="message">{message}<br><i>{description}</i></p>
- {suggestions}
- </div>
- <form method="GET" action="{uri}" id="button">
- <button type="submit" onclick="location.reload(); return false;" {autofocus}>
- <img style="{hide-button-images}" src="stock://gtk-refresh"/>
- <span>{tryagain}</span>
- </button>
- </form>
- </div>
-
-<br style="clear: both;"/>
-</div>
-</body>
-</html>
diff --git a/data/faq.css b/data/faq.css
deleted file mode 100644
index 5d92ae19..00000000
--- a/data/faq.css
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
-:Author: Christian Dywan
-:Contact: christian@twotoasts.de
-:Copyright: This file is licensed under the terms of the expat license, see the file EXPAT.
-
-Stylesheet for Midori's documentation based on a version of Enrico Troeger.
-*/
-
-@media screen {
-
- html, body {
- width: 100% !important;
- height: 100% !important;
- margin: 0 !important;
- padding: 0 !important;
- }
-
- * {
- background: #f6fff3 !important;
- color: #404040 !important;
- font-size: 14pt !important;
- font-family: serif !important;
- text-align: justify !important;
- line-height: 1.4em !important;
- word-spacing: 0.4mm !important;
- letter-spacing: 0.2mm !important;
- -webkit-column-count: auto !important;
- -webkit-column-width: auto !important;
- -webkit-box-shadow: none !important;
- width: auto !important;
- word-wrap: break-word !important;
- }
-
- div, p {
- padding: 5pt !important;
- }
-
- li {
- padding-left: 5pt !important;
- }
-
- img, *[accesskey], form *, form, iframe,
- *[id^=navigation], *[id$=navigation], *[id*=navigation], .collapsed, .expanded {
- display: none !important
- }
-
- /* FIXME: we want "images bigger than 50px here" */
- img[width] {
- display: inline !important
- }
-
- :link, :link * {
- color: #013100 !important;
- text-decoration: underline !important;
- }
-
- :visited, :visited * {
- color: #7E558E !important;
- text-decoration: underline !important;
- }
-
- a:hover {
- text-decoration: none !important;
- }
-
- h1, h2, h3 {
- font-family: serif !important;
- color: #002a00 !important;
- }
-
- h1 {
- border-top: 1px dotted;
- margin-top: 2em;
- }
-
- h1.title {
- text-align: left }
-
- h2 {
- margin-top: 30px;
- }
-
- h2.subtitle {
- text-align: left }
-
- h3 {
- padding-left: 3px;
- }
-
- blockquote, pre {
- border: 1px solid;
- padding: 0.4em;
- }
-
- blockquote {
- font-family: sans-serif;
- background-color: #DBEDD5;
- border: 1px dotted;
- border-left: 4px solid;
- border-color: #9FD98C;
- }
-
- pre {
- background-color: #deefd4;
- border: 1px dotted;
- border-left: 4px solid;
- border-color: #9acb7d;
- }
-
- tt, pre, code {
- color: #002a00;
- }
-
- table {
- border: 1px solid #9acb7f;
- }
-
- th {
- border: none;
- background-color: #9acb7d;
- }
-
- tr:nth-child(even) {
- background-color: #d3eac6;
- }
-
- td {
- border: none;
- }
-
- .docinfo-name {
- color: #002a00;
- }
-
- p.admonition-title {
- color: #990000;
- font-weight: bold;
- }
-
- div.note {
- margin: 1em 3em;
- padding: 0em;
- }
-
- dt {
- font-style: italic;
- }
-
-}
diff --git a/data/faq.html b/data/faq.html
deleted file mode 100644
index 78ca4f0d..00000000
--- a/data/faq.html
+++ /dev/null
@@ -1,1256 +0,0 @@
-<!DOCTYPE html>
-<html lang="en" dir="ltr">
-<head>
- <meta charset="utf-8" />
- <title>midori:faq</title>
-<meta name="generator" content="DokuWiki"/>
-<meta name="robots" content="index,follow"/>
-<meta name="keywords" content="midori,faq"/>
-<link rel="search" type="application/opensearchdescription+xml" href="/lib/exe/opensearch.php" title="Xfce Wiki"/>
-<link rel="start" href="/"/>
-<link rel="contents" href="/midori/faq?do=index" title="Sitemap"/>
-<link rel="alternate" type="application/rss+xml" title="Recent changes" href="/feed.php"/>
-<link rel="alternate" type="application/rss+xml" title="Current namespace" href="/feed.php?mode=list&amp;ns=midori"/>
-<link rel="alternate" type="text/html" title="Plain HTML" href="/_export/xhtml/midori/faq"/>
-<link rel="alternate" type="text/plain" title="Wiki Markup" href="/_export/raw/midori/faq"/>
-<link rel="canonical" href="http://wiki.xfce.org/midori/faq"/>
-<link rel="stylesheet" href="faq.css" />
-<script type="text/javascript">/*<![CDATA[*/var NS='midori';var JSINFO = {"id":"midori:faq","namespace":"midori"};
-/*!]]>*/</script>
-<script type="text/javascript" charset="utf-8" src="/lib/exe/js.php?tseed=af5aadc3291d3baa2d8665b51a0cedf3"></script>
-</head>
-<body>
-<div class="dokuwiki export">
-<!-- TOC START -->
-<div id="dw__toc">
-<h3 class="toggle">Table of Contents</h3>
-<div>
-
-<ul class="toc">
-<li class="level1"><div class="li"><a href="#midori_-_frequently_asked_questions">Midori - Frequently asked questions</a></div></li>
-<li class="level1"><div class="li"><a href="#about_midori">About Midori</a></div></li>
-<li class="level1"><div class="li"><a href="#common_problems">Common problems</a></div>
-<ul class="toc">
-<li class="level2"><div class="li"><a href="#security_features">Security features</a></div></li>
-<li class="level2"><div class="li"><a href="#flash_doesn_t_work">Flash doesn&#039;t work</a></div></li>
-</ul>
-</li>
-<li class="level1"><div class="li"><a href="#privacy">Privacy</a></div>
-<ul class="toc">
-<li class="level2"><div class="li"><a href="#blacklist_cookies">Blacklist cookies</a></div></li>
-<li class="level2"><div class="li"><a href="#adblock">Adblock</a></div></li>
-</ul>
-</li>
-<li class="level1"><div class="li"><a href="#modes">Modes</a></div>
-<ul class="toc">
-<li class="level2"><div class="li"><a href="#web_applications">Web Applications</a></div></li>
-<li class="level2"><div class="li"><a href="#private_browsing">Private Browsing</a></div></li>
-<li class="level2"><div class="li"><a href="#portable_modewin32">Portable mode/ Win32</a></div></li>
-<li class="level2"><div class="li"><a href="#kiosk_mode">Kiosk mode</a></div></li>
-<li class="level2"><div class="li"><a href="#always_open_midori_in_fullscreen">Always open Midori in Fullscreen</a></div></li>
-<li class="level2"><div class="li"><a href="#overriding_settings_and_loading_extensions">Overriding settings and loading extensions</a></div></li>
-</ul>
-</li>
-<li class="level1"><div class="li"><a href="#proxy_servers">Proxy servers</a></div></li>
-<li class="level1"><div class="li"><a href="#keyboard_hotkeys">Keyboard Hotkeys</a></div></li>
-<li class="level1"><div class="li"><a href="#mouse_gestures">Mouse Gestures</a></div></li>
-<li class="level1"><div class="li"><a href="#user_scripts_and_styles">User scripts and styles</a></div>
-<ul class="toc">
-<li class="level2"><div class="li"><a href="#user_styles">User styles</a></div></li>
-</ul>
-</li>
-<li class="level1"><div class="li"><a href="#midori_architecture">Midori Architecture</a></div>
-<ul class="toc">
-<li class="level2"><div class="li"><a href="#webkit_version_numbers">WebKit Version Numbers</a></div></li>
-</ul>
-</li>
-<li class="level1"><div class="li"><a href="#midori_and_mediaherald">Midori and mediaHerald</a></div></li>
-</ul>
-</div>
-</div>
-<!-- TOC END -->
-
-<h1 class="sectionedit1" id="midori_-_frequently_asked_questions">Midori - Frequently asked questions</h1>
-<div class="level1">
-
-<p>
-<strong>This document is licensed under the <abbr title="GNU Lesser General Public License">LGPL</abbr> 2.1.</strong>
-</p>
-
-<p>
-This is <a href="http://wiki.xfce.org/midori/faq">a snapshot of the online FAQ</a> about the Midori Web Browser. Anyone should feel free to improve or extend this page, but keep it clean and easy to read for other users.
-</p>
-
-</div>
-<!-- EDIT1 SECTION "Midori - Frequently asked questions" [1-286] -->
-<h1 class="sectionedit2" id="about_midori">About Midori</h1>
-<div class="level1">
-
-</div>
-
-<h4 id="what_is_midori_and_why_should_i_use_it">What is &quot;Midori&quot; and why should I use it?</h4>
-<div class="level4">
-
-<p>
-Midori is a Web browser that aims to be lightweight and fast. It aligns well with the Xfce philosophy of making the most out of available resources. It has a customizable interface using the GTK+ toolkit.
-</p>
-
-</div>
-
-<h4 id="how_to_pronounce_midori_and_what_does_the_name_mean">How to pronounce Midori and what does the name mean?</h4>
-<div class="level4">
-
-<p>
-Pronounce it “midoɺi”, with a Spanish/ Japanese “r” or “Mee-Doh-Ree” in English or read it Italian. The name comes from the Japanese word 緑 (みどり) for the colour “green”.
-</p>
-
-</div>
-
-<h4 id="what_does_the_logo_mean">What does the logo mean?</h4>
-<div class="level4">
-
-<p>
-The paw of a green cat. Obviously. Also it resembles the letter “M” in “Midori”. The curving is supposed to emphasize speed.
-</p>
-
-</div>
-
-<h4 id="on_which_platforms_does_midori_run_currently">On which platforms does Midori run currently?</h4>
-<div class="level4">
-
-<p>
-Midori is portable and should run on all platforms that its dependencies support. Releases exist on various Linux distributions, for Windows versions prior to 8.1 (for now), and BSD.
-</p>
-
-</div>
-
-<h4 id="under_which_license_is_midori_distributed">Under which license is Midori distributed?</h4>
-<div class="level4">
-
-<p>
-Midori and all delivered artwork are licensed under the LGPL2.
-</p>
-
-</div>
-<!-- EDIT2 SECTION "About Midori" [287-1323] -->
-<h1 class="sectionedit3" id="common_problems">Common problems</h1>
-<div class="level1">
-
-</div>
-
-<h4 id="why_does_google_mailcalendarmaps_facebook_not_work_or_show_mobile_version">Why does Google Mail/ Calendar/ Maps, Facebook not work or show mobile version?</h4>
-<div class="level4">
-
-<p>
-Some websites give up if they don&#039;t recognize your browser as Chrome, Firefox, <abbr title="Internet Explorer">IE</abbr>, etc.
-</p>
-
-<p>
-You can change the browser name sent to web sites at Preferences &gt; Network &gt; Identify As
-</p>
-
-<p>
-Either choose a predefined user-agent or choose Custom and find a suitable string in <a href="http://useragentstring.com/pages/useragentstring.php" class="urlextern" title="http://useragentstring.com/pages/useragentstring.php" rel="nofollow">a list</a>.
-</p>
-
-<p>
-Many other websites use similar means of detecting the browser.
-</p>
-
-<p>
-Google <a href="http://web.archive.org/web/20100625211333/http://code.google.com/p/doctype/wiki/ArticleGoogleChromeCompatFAQ" class="urlextern" title="http://web.archive.org/web/20100625211333/http://code.google.com/p/doctype/wiki/ArticleGoogleChromeCompatFAQ" rel="nofollow">previously recommended</a> the superior practice for website creators of checking which features are present rather than browser name/version, but has since weakened this stance with their browser&#039;s growing market share.
-</p>
-
-</div>
-
-<h4 id="there_are_missing_iconswarnings">There are missing icons/ warnings</h4>
-<div class="level4">
-
-<p>
-Midori uses a wide variety of icons which may not be present in all themes. For instance icons for a new tab, to represent scripts, or the throbber may not available. To fix this, install a Freedesktop.org <abbr title="specification">spec</abbr> compliant icon theme, such as Elementary, Faenza, Buuf or GNOME.
-</p>
-
-<p>
-if you need to set a custom path for these to be “searched in” (Kiosks and embedded devices for example):
-</p>
-
-<p>
-XDG_DATA_HOME=/path/to/location
-</p>
-
-<p>
-will add an extra path for the icons/… directory
-</p>
-
-<p>
-In addition, GTK3 may remove icons from menus. This may be changed by placing
-</p>
-<pre class="code">gtk-menu-images=true</pre>
-
-<p>
- in the file ~/.config/gtk-3.0/settings.ini
-</p>
-
-</div>
-
-<h4 id="tweaking_midori_on_the_gtk_level">Tweaking Midori on the Gtk level</h4>
-<div class="level4">
-
-<p>
-If you don&#039;t have a desktop application that takes care of Gtk settings or if your interface doesn&#039;t support a particular feature, you can modify any settings easily manually by specifying them in a text file called ~/.gtkrc-2.0 or /etc/gtk-2.0/gtkrc:
-</p>
-
-<p>
-Use Tango as a fallback for your icon theme:
-</p>
-<pre class="code">gtk-icon-theme-name = &quot;MySuperFancyTheme&quot;
-gtk-fallback-icon-theme = &quot;Tango&quot;</pre>
-
-<p>
-Use a smaller toolbar:
-</p>
-<pre class="code">gtk-toolbar-icon-size = GTK_ICON_SIZE_SMALL_TOOLBAR</pre>
-
-<p>
-Only for those not running a complete DE like Xfce, Elementary, etc…<br/>
-
-There is a preference: Preferences → Browsing → Toolbar Style: Small icons
-</p>
-
-<p>
-Enable changing hotkeys while hovering menu items:
-</p>
-<pre class="code">gtk-can-change-accels = 1</pre>
-
-</div>
-
-<h4 id="disable_middle_click_pasting">Disable middle click pasting</h4>
-<div class="level4">
-
-<p>
-As of GTK+ &gt;= 3.4 one can disable it globally in ~/.gtkrc-2.0
-</p>
-<pre class="code">gtk-enable-primary-paste = 0</pre>
-
-<p>
-Otherwise by adding a line to ~/.config/midori/config
-</p>
-<pre class="code">middle-click-opens-selection=false</pre>
-
-</div>
-
-<h4 id="midori_crashes_shortly_before_pages_are_loaded">Midori crashes shortly before pages are loaded</h4>
-<div class="level4">
-
-<p>
-There appears to be an issue with Glib 2.16. The recommended solution is to upgrade your Glib package to 2.18.
-</p>
-
-</div>
-
-<h4 id="how_can_i_change_the_cache_folder_to_tmpfs">How can I change the cache folder (to tmpfs)?</h4>
-<div class="level4">
-
-<p>
-On Linux and BSD, you can set XDG_CACHE_HOME for all applications, or just Midori. Midori saves icons and cache files in that location. The default is ~/.cache.
-</p>
-
-<p>
-export XDG_CACHE_HOME=/dev/shm
-</p>
-
-</div>
-<!-- EDIT3 SECTION "Common problems" [1324-4267] -->
-<h2 class="sectionedit4" id="security_features">Security features</h2>
-<div class="level2">
-
-</div>
-
-<h4 id="hstshttp_strict_transport_security">HSTS/ HTTP Strict Transport Security</h4>
-<div class="level4">
-
-<p>
-Midori &gt;= 0.4.7 automatically picks up the Strict-Transport-Security header and caches sites locally. By design, there&#039;s no UI. System administrators can however place a pre-loaded cache at /etc/xdg/midori/hsts.
-</p>
-
-</div>
-
-<h4 id="certificate_handling">Certificate Handling</h4>
-<div class="level4">
-
-<p>
-Midori uses the system&#039;s ca-certificates, the exact locations depend on the distribution.
-</p>
-
-<p>
-Midori &gt;= 0.4.7 supports <a href="http://git.gnome.org/browse/gcr/tree/gcr" class="urlextern" title="http://git.gnome.org/browse/gcr/tree/gcr" rel="nofollow">gcr</a> for certificate display and management, you can click the lock in the urlbar to see detailed information. Earlier versions, or one without gcr will not handle certificates beyond the lock icon in the urlbar.
-</p>
-
-</div>
-
-<h5 id="error_granting_trustcouldn_t_find_a_place_to_store_the_imported_certificate">Error granting trust: Couldn&#039;t find a place to store the imported certificate</h5>
-<div class="level5">
-
-<p>
-No key store is available or it&#039;s incorrectly setup. By default GNOME keyring can do this. Under Xfce it is recommended to enable “GNOME services” under “Session and Startup settings”. To make sure, that the output of “gnome-keyring –startup” is correctly sent to the environment, you can add “export `gnome-keyring-daemon –start`” to .xinitrc.
-</p>
-
-</div>
-
-<h5 id="a_testcase_for_self-signed_certificates">A testcase for self-signed certificates</h5>
-<div class="level5">
-
-<p>
-<a href="https://selfsigned.notyours.dk:444/menu.gif" class="urlextern" title="https://selfsigned.notyours.dk:444/menu.gif" rel="nofollow">https://selfsigned.notyours.dk:444/menu.gif</a>
-</p>
-
-</div>
-<!-- EDIT4 SECTION "Security features" [4268-5485] -->
-<h2 class="sectionedit5" id="flash_doesn_t_work">Flash doesn&#039;t work</h2>
-<div class="level2">
-
-</div>
-
-<h4 id="windows_support">Windows support</h4>
-<div class="level4">
-
-<p>
-Starting with WebkitGTK+ 1.8.2 (Midori 0.4.7) Netscape plugins are now supported if they&#039;re installed in Application Data\Mozilla\plugins or bin\Plugins in Midori&#039;s folder (ie. NPSWF32.dll for Flash).
-</p>
-
-</div>
-
-<h4 id="netscape_plugins_on_linux_bsd_and_os_x">Netscape plugins on Linux, BSD and OS X</h4>
-<div class="level4">
-
-<p>
-You need to set MOZ_PLUGIN_PATH, for example like this:
-</p>
-<pre class="code bash"><span class="kw3">export</span> <span class="re2">MOZ_PLUGIN_PATH</span>=<span class="st0">&quot;/usr/lib/mozilla/plugins&quot;</span></pre>
-
-<p>
-The official Flash plugin is called libflashplayer.so .
-</p>
-
-<p>
-You can either run that above line and run Midori in the same terminal afterwards or, for the long term, put it in ~/.bash_profile or /etc/profile.d or your respective distribution&#039;s place for this.
-</p>
-
-</div>
-
-<h4 id="flash_is_crashingno_flash_with_gtk_3">Flash is crashing/ No Flash with GTK+3</h4>
-<div class="level4">
-
-<p>
-nspluginwrapper is a program that runs Flash and other Netscape plugins in a separate process. So a crash can&#039;t crash the whole browser and Flash, which is GTK+2 can run in GTK+3.
-</p>
-<pre class="code bash"><span class="kw2">sudo</span> <span class="kw2">apt-get install</span> nspluginwrapper
-<span class="co0"># On Debian/ Ubuntu - on other systems http://get.adobe.com/de/flashplayer/</span>
-<span class="kw2">sudo</span> <span class="kw2">apt-get install</span> flashplugin-installer
-<span class="co0"># cd into the folder where the plugin was installed</span>
-nspluginwrapper <span class="re5">-v</span> <span class="re5">-a</span> <span class="re5">-n</span> <span class="re5">-i</span> libflashplayer.so</pre>
-
-<p>
-~/.mozilla can also be used with Adobe&#039;s tarball if system-wide install is not an option. The approach is confirmed to work with x86-64 as well.
-</p>
-
-<p>
-Another remedy is using WebKit2 - starting with Midori 0.4.9 experimental support is available, <a href="https://trac.webkit.org/wiki/WebKitGTK/WebKit2Roadmap" class="urlextern" title="https://trac.webkit.org/wiki/WebKitGTK/WebKit2Roadmap" rel="nofollow">progress on WebKit2GTK+ can be seen in the WebKit wiki</a>.
-</p>
-
-</div>
-
-<h4 id="https_urls_won_t_load">HTTPS URLS won&#039;t load</h4>
-<div class="level4">
-
-<p>
-That&#039;s a problem with WebKit. You can work around it to some extent if you start Midori like so:
-</p>
-<pre class="code bash"><span class="kw3">export</span> <span class="re2">WEBKIT_IGNORE_SSL_ERRORS</span>=<span class="st0">&quot;1&quot;</span> midori</pre>
-
-</div>
-
-<h4 id="bit_encryption_isn_t_supported">256-bit encryption isn&#039;t supported?</h4>
-<div class="level4">
-
-<p>
-There&#039;s no official support right now. It&#039;s possible to <a href="https://opensource.conformal.com/fluxbb/viewtopic.php?pid=1332#p1332" class="urlextern" title="https://opensource.conformal.com/fluxbb/viewtopic.php?pid=1332#p1332" rel="nofollow">patch glib-networking to enable 256-bit SSL</a>.
-</p>
-
-</div>
-
-<h4 id="scroll_with_middle_mouse_buttonpan-scrolling">Scroll with middle mouse button/ pan-scrolling</h4>
-<div class="level4">
-
-<p>
-Windows-style middle-click behavior is
-</p>
-
-<p>
-<a href="http://ubuntuforums.org/showthread.php?t=478418" class="urlextern" title="http://ubuntuforums.org/showthread.php?t=478418" rel="nofollow">http://ubuntuforums.org/showthread.php?t=478418</a>
-</p>
-
-<p>
-Bug: <a href="https://bugs.launchpad.net/webkit/+bug/871425" class="urlextern" title="https://bugs.launchpad.net/webkit/+bug/871425" rel="nofollow">https://bugs.launchpad.net/webkit/+bug/871425</a><br/>
-
-Upstream Bug: <a href="https://bugs.webkit.org/show_bug.cgi?id=50561" class="urlextern" title="https://bugs.webkit.org/show_bug.cgi?id=50561" rel="nofollow">https://bugs.webkit.org/show_bug.cgi?id=50561</a>
-</p>
-
-</div>
-
-<h4 id="html5_videoaudio_doesn_t_play">HTML5 Video/ Audio doesn&#039;t play</h4>
-<div class="level4">
-
-<p>
-<a href="#midori_architecture" title="midori:faq ↵" class="wikilink1">Midori uses GStreamer</a> for HTML5 audio and video support. Codecs, which handle particular formats of audio or video, are provided by GStreamer plugins which may need to be installed separately. Midori may be built with GTK+2 or GTK+3 (visit about:version to check), which correspond to GStreamer versions of 0.10 or 1.0 respectively.
-</p>
-<ol>
-<li class="level1"><div class="li"> You need gstreamer(0.10/1.0)-pulse if you&#039;re using PulseAudio.</div>
-</li>
-<li class="level1"><div class="li"> You may need gstreamer(0.10/1.0)-alsa for ALSA, depending on your distribution.</div>
-</li>
-<li class="level1"><div class="li"> You need plugins for Theora, gstreamer(0.10/1.0)-base and MPEG-4 incluing aac (e.g. gst-plugins-faad), gstreamer(0.10/1.0)-bad. For WebM, you&#039;ll need plugins for vorbis (-base), matroska (-good), and vp8 (-bad). Have a look at <a href="http://www.gstreamer.net/documentation/plugins.html" class="urlextern" title="http://www.gstreamer.net/documentation/plugins.html" rel="nofollow">http://www.gstreamer.net/documentation/plugins.html</a> for details.</div>
-</li>
-<li class="level1"><div class="li"> For Youtube or Vimeo, you need WebKitGTK+ 1.1.20 or newer.</div>
-</li>
-<li class="level1"><div class="li"> You can <a href="http://ie.microsoft.com/testdrive/Graphics/VideoFormatSupport/Default.html" class="urlextern" title="http://ie.microsoft.com/testdrive/Graphics/VideoFormatSupport/Default.html" rel="nofollow">test your installed codecs here</a>..</div>
-</li>
-<li class="level1"><div class="li"> You can look at about:version to see which video codecs you have installed.</div>
-</li>
-</ol>
-
-</div>
-
-<h4 id="java_doesn_t_work_applets_don_t_show_up">Java doesn&#039;t work, applets don&#039;t show up</h4>
-<div class="level4">
-
-<p>
-Java is supported in WebKitGTK+ since 1.1.22. If you need Java, you need to upgrade to at least that version. Sun/ Oracle Java as well as IcedTea are known to work. Distribution specific setup might be required, such as setting LD_LIBRARY_PATH to include the location of libxul.so and making a symbolic link for libnpjp2.so to /usr/lib/mozilla.
-</p>
-
-<p>
-icedtea6 version 1.8 and above has been known to crash midori. If this is the case for you, try sun-jre.
-</p>
-
-</div>
-
-<h4 id="how_do_i_get_rid_of_the_menubar">How do I get rid of the menubar?</h4>
-<div class="level4">
-
-<p>
-In the menubar, go to View → Toolbars → Menubar, voilà the menubar is gone and a new icon appears at the right end of the toolbar. Click the icon to access functionality that otherwise sits in the menubar.
-Midori 0.3.2 disables the menubar by default.
-</p>
-
-</div>
-
-<h4 id="why_can_t_i_use_periods_when_searching_from_the_location_bar">Why can&#039;t I use periods when searching from the location bar?</h4>
-<div class="level4">
-
-<p>
-Midori tries to make a smart guess on whether you are searching for something or typing a valid address by hand. Yet there are ambiguous cases so it fails.
-</p>
-
-<p>
-Try using &#039;g&#039; in front of the search terms, like &#039;g Ms.Marple&#039;. The &#039;g&#039; is a token that tells the browser you want to use Google. See Tools &gt; Manage Search Engines or right-click the location bar and select the menu item, to look at search engines and tokens.
-</p>
-
-</div>
-
-<h4 id="how_can_i_reload_and_bypass_the_cache">How can I reload and bypass the cache?</h4>
-<div class="level4">
-
-<p>
-Hold the Shift key while clicking Refresh in the toolbar (this works in Chromium, Mozilla, Opera and Safari, too).
-Since Midori 0.3.2 you can use Ctrl+Shift+R.
-</p>
-
-</div>
-
-<h4 id="how_do_i_make_tabs_pinnedstickyminimized">How do I make tabs pinned/ sticky/ minimized?</h4>
-<div class="level4">
-
-<p>
-Right-click the tab label, and click &#039;Minimize&#039; or &#039;Show Tab Icon Only&#039; (Midori 0.3.5 or older).
-</p>
-
-</div>
-
-<h4 id="why_doesn_t_google_live_search_work">Why doesn&#039;t Google &quot;live search&quot; work?</h4>
-<div class="level4">
-
-<p>
-You need to set Preferences &gt; Network &gt; Identify As to Firefox.
-</p>
-
-</div>
-
-<h4 id="google_docs_says_clear_your_caches">Google Docs says &quot;Clear your caches&quot;</h4>
-<div class="level4">
-
-<p>
-If you use the Adblock extension, EasyPrivacy may conflict with Google Docs. Disable the subscription if you use it. Otherwise try disabling Adblock entirely.
-</p>
-
-</div>
-
-<h4 id="opening_html_email_with_mutt">Opening html email with Mutt</h4>
-<div class="level4">
-
-<p>
-Place the following in ~/.mutt/mailcap or ~/.mailcap:
-</p>
-<pre class="code">text/html; midori -a &#039;%s&#039;; test=test -n &quot;$DISPLAY&quot;; nametemplate=%s.html</pre>
-
-</div>
-
-<h4 id="scrolling_on_website_xyz_is_very_slow">Scrolling on website xyz is very slow</h4>
-<div class="level4">
-<ol>
-<li class="level1"><div class="li"> Go to Tools &gt; Extensions</div>
-</li>
-<li class="level1"><div class="li"> Enable &#039;User Addons&#039; if it&#039;s not yet enabled</div>
-</li>
-<li class="level1"><div class="li"> Create a text file .local/share/midori/styles/scrollfix.user.css</div>
-</li>
-<li class="level1"><div class="li"> Put this into the file: * {-webkit-box-shadow: none !important;}</div>
-</li>
-</ol>
-
-</div>
-
-<h4 id="file_opening_doesn_t_workpdfs_are_opened_with_gimp">File opening doesn&#039;t work/ PDFs are opened with GIMP</h4>
-<div class="level4">
-
-<p>
-Midori opens files with GIO, and falls back to xdg-open, exo-open or gnome-open if these are available. All of this relies on freedesktop.org MIME configuration. To tweak this there are multiple options:
-</p>
-<ol>
-<li class="level1"><div class="li"> Use &#039;Open With&#039; with a graphical file manager</div>
-</li>
-<li class="level1"><div class="li"> Edit ~/.local/share/applications/defaults.list with a text editor</div>
-</li>
-<li class="level1"><div class="li"> Run something like ‘xdg-mime default evince.desktop application/pdf’</div>
-</li>
-</ol>
-
-<p>
-xdg-open knows how to handle GNOME, KDE and Xfce.
-LXDE is unfortunately not supported yet, see <a href="https://bugs.freedesktop.org/show_bug.cgi?id=26058" class="urlextern" title="https://bugs.freedesktop.org/show_bug.cgi?id=26058" rel="nofollow">https://bugs.freedesktop.org/show_bug.cgi?id=26058</a>
-</p>
-
-</div>
-
-<h4 id="open_magnetircaptbitcoinwith_an_application">Open magnet:, irc:, apt:, bitcoin: with an application</h4>
-<div class="level4">
-
-<p>
-As of git 2011-03-05 02:40:00 UTC and Midori 0.3.3 you can
-</p>
-
-<p>
-Add a line to ~/.local/share/applications/mimeapps.list:
-</p>
-<pre class="code">x-scheme-handler/magnet=transmission-gtk.desktop</pre>
-
-<p>
-Or install an application which advertises the scheme like so:
-</p>
-<pre class="code">MimeType=x-scheme-handler/magnet;</pre>
-
-<p>
-Note that incomplete .desktop files will silently fail and it will look as if it doesn&#039;t exist.
-</p>
-
-<p>
-For <a href="http://electrum.org/bitcoin_URIs.html" class="urlextern" title="http://electrum.org/bitcoin_URIs.html" rel="nofollow">bitcoin:</a>, try <a href="http://electrum.org/index.html" class="urlextern" title="http://electrum.org/index.html" rel="nofollow">Electrum</a> or <a href="http://multibit.org/" class="urlextern" title="http://multibit.org/" rel="nofollow">Multibit</a>.
-</p>
-
-</div>
-
-<h4 id="spell_check">Spell check</h4>
-<div class="level4">
-
-<p>
-First enable spell checking:
-Edit→Preferences→Behavior and check “Enable Spell Checking”.
-</p>
-
-<p>
-Now while typing any errors should get underlined in red. To get suggestions, highlight the word and right-click. You should see a list of suggestions at the top of the menu.
-</p>
-
-<p>
-On Windows <a href="http://download.services.openoffice.org/files/contrib/dictionaries/" class="urlextern" title="http://download.services.openoffice.org/files/contrib/dictionaries/" rel="nofollow">you need to download OpenOffice dictionaries</a>, find the zipped file(s) for your locale(s) and unpack the contents into share/myspell/dicts/ in your Midori installation. The folder should contain *.aff and *.dic files
-</p>
-
-</div>
-
-<h4 id="is_it_possible_to_disable_same_origin_policy_what_webkit_settings_not_in_the_preferences_can_i_change">Is it possible to disable Same Origin Policy? What Webkit settings not in the preferences can I change?</h4>
-<div class="level4">
-
-<p>
-You can change <a href="http://webkitgtk.org/reference/webkitgtk/stable/WebKitWebSettings.html" class="urlextern" title="http://webkitgtk.org/reference/webkitgtk/stable/WebKitWebSettings.html" rel="nofollow">all values of WebKitWebSettings</a> in the config file (~/.config/midori/config on unices, %APPDATA%\midori\config [please check :)] on Windows). For example, to disable Same Origin Policy for local files, add
-</p>
-<pre class="code">enable-universal-access-from-file-uris=true</pre>
-
-<p>
- to your config file.
-</p>
-
-</div>
-
-<h4 id="how_do_i_change_the_proxy_server_from_the_toolbar_or_statusbar">How do I change the proxy server from the toolbar or statusbar?</h4>
-<div class="level4">
-<ol>
-<li class="level1"><div class="li"> Activate the Statusbar Features plugin.</div>
-</li>
-<li class="level1"><div class="li"> Close Midori.</div>
-</li>
-<li class="level1"><div class="li"> Create a folder ~/.config/midori/extensions/libstatusbar-features.so/</div>
-</li>
-<li class="level1"><div class="li"> Create a text file “config”</div>
-</li>
-<li class="level1"><div class="li"> Type the following for the default setup:</div>
-</li>
-</ol>
-<pre class="code"> [settings]
- items=auto-load-images;enable-scripts;enable-plugins;identify-as;zoom-level</pre>
-
-<p>
-Add button types separated by semicolon:
-</p>
-<ul>
-<li class="level1"><div class="li"> proxy-type Proxy Server</div>
-</li>
-<li class="level1"><div class="li"> preferred-encoding Character Set/ Encoding</div>
-</li>
-<li class="level1"><div class="li"> enable-spell-checking Spell Check</div>
-</li>
-<li class="level1"><div class="li"> zoom-text-and-images Only zoom in text, or text and images</div>
-</li>
-<li class="level1"><div class="li"> first-party-cookies-only First party cookies only</div>
-</li>
-<li class="level1"><div class="li"> site-data-rules see <a href="#blacklist_cookies" title="midori:faq ↵" class="wikilink1">Blacklisting cookies</a></div>
-</li>
-</ul>
-
-<p>
-Most settings listed at <a href="http://webkitgtk.org/reference/webkitgtk/stable/WebKitWebSettings.html" class="urlextern" title="http://webkitgtk.org/reference/webkitgtk/stable/WebKitWebSettings.html" rel="nofollow">http://webkitgtk.org/reference/webkitgtk/stable/WebKitWebSettings.html</a> will also work as button types.
-</p>
-
-</div>
-<!-- EDIT5 SECTION "Flash doesn't work" [5486-14378] -->
-<h1 class="sectionedit6" id="privacy">Privacy</h1>
-<div class="level1">
-
-</div>
-<!-- EDIT6 SECTION "Privacy" [14379-14401] -->
-<h2 class="sectionedit7" id="blacklist_cookies">Blacklist cookies</h2>
-<div class="level2">
-
-<p>
-As of Midori 0.4.4 you can add a hidden option to ~/.config/midori/config like so:
-</p>
-<pre class="code">site-data-rules=-google.com,-facebook.com,!bugzilla.gnome.org,+bugs.launchpad.net</pre>
-<ol>
-<li class="level1"><div class="li"> Values prefixed with “-” are always blocked</div>
-</li>
-<li class="level1"><div class="li"> Values prefixed with “+” are always accepted</div>
-</li>
-<li class="level1"><div class="li"> Values prefixed with “!” are not cleared in Clear Private Data</div>
-</li>
-<li class="level1"><div class="li"> No wildcards.</div>
-</li>
-<li class="level1"><div class="li"> LSO, local storage and application caches ignore all policies.</div>
-</li>
-</ol>
-
-<p>
-The feature is currently experimental and will change in future versions.
-</p>
-
-</div>
-<!-- EDIT7 SECTION "Blacklist cookies" [14402-14938] -->
-<h2 class="sectionedit8" id="adblock">Adblock</h2>
-<div class="level2">
-
-<p>
-The Advertisement Blocker can be activated under Extensions. It uses the same lists as Adblock Plus. URLs are blocked completely and never loaded. Lists can be added through the option button on the right side in the extension list.
-</p>
-
-</div>
-<!-- EDIT8 SECTION "Adblock" [14939-15194] -->
-<h1 class="sectionedit9" id="modes">Modes</h1>
-<div class="level1">
-
-</div>
-<!-- EDIT9 SECTION "Modes" [15195-15215] -->
-<h2 class="sectionedit10" id="web_applications">Web Applications</h2>
-<div class="level2">
-
-<p>
-There are two closely related features to open websites as dedicated windows of their own. You can do the following to use them:
-</p>
-<ol>
-<li class="level1"><div class="li"> Right-click a hyperlink → Open as Web Application</div>
-</li>
-<li class="level1"><div class="li"> Add or Edit a bookmark → [x] Run as web application</div>
-</li>
-<li class="level1"><div class="li"> Type ‘midori -a <a href="http://foo.bar" class="urlextern" title="http://foo.bar" rel="nofollow">http://foo.bar</a>’ on a command line</div>
-</li>
-</ol>
-
-<p>
- You can also add options such as ‘-e Fullscreen’, ‘-e Navigationbar’ or ‘-e Statusbar’ (as of Midori 0.2.9 ‘midori –help-execute will list all available commands’)
-</p>
-
-</div>
-<!-- EDIT10 SECTION "Web Applications" [15216-15732] -->
-<h2 class="sectionedit11" id="private_browsing">Private Browsing</h2>
-<div class="level2">
-
-<p>
-File menu/ App Menu button → Private Browsing
-</p>
-
-<p>
-A private window is a separate process, so crashes don&#039;t affect the normal browser session. No sensitive data such as cookies, history or bookmarks are stored. No extensions are loaded. Panels are not available.
-</p>
-
-<p>
-As of Midori 0.2.9 Private Browsing uses preferences, cookies, keyboard shortcuts and search engines from the normal session, but it won&#039;t save any changes. This behaviour can be emulated from the command line with “-a” and “-c”.
-</p>
-
-<p>
-As of Midori 0.3.4 the –private command line switch opens a private browsing instance with normal preferences, cookies, shortcuts and search engines. But no changes will be saved.
-<abbr title="Domain Name System">DNS</abbr> prefetching is disabled in this mode, also referrers are stripped down to the hostname when navigating between different websites.
-</p>
-
-<p>
-The same options available to -a/ –app can be used for private browsing mode.
-</p>
-
-</div>
-<!-- EDIT11 SECTION "Private Browsing" [15733-16652] -->
-<h2 class="sectionedit12" id="portable_modewin32">Portable mode/ Win32</h2>
-<div class="level2">
-
-<p>
-On Windows builds, -P/ –portable causes all data to be written to the “profile” folder in the Midori folder. Everything, including temporary files and cache, is stored in a sub-folder without touching the system. So Midori can be run eg. from a USB stick on different machines.
-</p>
-
-</div>
-<!-- EDIT12 SECTION "Portable mode/ Win32" [16653-16966] -->
-<h2 class="sectionedit13" id="kiosk_mode">Kiosk mode</h2>
-<div class="level2">
-
-<p>
-There is no specific mode, instead you use several command line switches. A typical fullscreen setup with no toolbar that opens about:blank and resets the session after 2 minutes of inactivity for instance:
-</p>
-<pre class="code bash">midori <span class="re5">-i</span> <span class="nu0">120</span> <span class="re5">-e</span> Fullscreen <span class="re5">-e</span> Navigationbar <span class="re5">-a</span> about:blank</pre>
-
-<p>
-Available commands for -e can be listed with “midori –help-execute”.
-</p>
-
-<p>
-If needed, a customized profile can be created with “midori -c /path/to/folder”. Using the shortcut editor extension, keyboard shortcuts can be removed as needed. Afterwards just append “-c /path/to/folder” to the kiosk mode command line.
-</p>
-
-<p>
-To restrict pages that can be opened, you can use a regular expression. The expression is a blacklist. To block undesirable sites you can do something like:
-</p>
-<pre class="code bash"><span class="re5">-b</span> <span class="st_h">'youtube|youporn'</span></pre>
-
-<p>
-By negating the expression you can also whitelist pages.
-</p>
-<pre class="code bash"><span class="re5">-b</span> <span class="st_h">'^(?!.*?(gmail|mail\.google|accounts\.google)).*'</span></pre>
-
-<p>
-Any links outside end up in an error page. All images and other files won&#039;t be loaded.
-</p>
-
-</div>
-<!-- EDIT13 SECTION "Kiosk mode" [16967-18004] -->
-<h2 class="sectionedit14" id="always_open_midori_in_fullscreen">Always open Midori in Fullscreen</h2>
-<div class="level2">
-
-<p>
-Using the WM to get Midori into fullscreen mode, or calling “midori -e Fullscreen” is the typical way. On the next startup Midori will remember the last window size and state.
-</p>
-
-<p>
-If for whatever reason this isn&#039;t enough, <a href="https://live.gnome.org/DevilsPie" class="urlextern" title="https://live.gnome.org/DevilsPie" rel="nofollow">DevilsPie</a> can force Midori to the desired state:
-</p>
-
-<p>
-~/.devilspie/midori.ds
-</p>
-
-<p>
-(begin
-</p>
-<pre class="code"> (if
- (and
- (is (application_name) &quot;Midori&quot;)
- )
- (begin
- (maximize)
- )
- )</pre>
-
-<p>
-)
-</p>
-
-</div>
-<!-- EDIT14 SECTION "Always open Midori in Fullscreen" [18005-18532] -->
-<h2 class="sectionedit15" id="overriding_settings_and_loading_extensions">Overriding settings and loading extensions</h2>
-<div class="level2">
-
-<p>
-As of Midori 0.5.0 the –execute command line switch got more powerful:
-</p>
-
-<p>
-<code>midori -e libcolorful-tabs.so=true</code>
-</p>
-
-<p>
-<code>midori -e enable-javascript=false</code>
-</p>
-
-</div>
-<!-- EDIT15 SECTION "Overriding settings and loading extensions" [18533-18740] -->
-<h1 class="sectionedit16" id="proxy_servers">Proxy servers</h1>
-<div class="level1">
-
-<p>
-By running a local proxy you can modify web content even before it has reached Midori. That allows you to do things similar to what user scripts and user styles provide and even others that neither is suitable for.
-</p>
-
-</div>
-
-<h4 id="privoxy">Privoxy</h4>
-<div class="level4">
-
-<p>
-Privoxy is a non-caching web proxy with filter capabilites and particular support for blocking advertisements before even loading them.
-</p>
-
-<p>
-<a href="http://www.privoxy.org/faq/" class="urlextern" title="http://www.privoxy.org/faq/" rel="nofollow">http://www.privoxy.org/faq/</a>
-</p>
-
-</div>
-
-<h4 id="mousehole">Mousehole</h4>
-<div class="level4">
-
-<p>
-Mousehole is a scriptable proxy server written in Ruby.
-</p>
-
-<p>
-<a href="http://code.whytheluckystiff.net/mouseHole/" class="urlextern" title="http://code.whytheluckystiff.net/mouseHole/" rel="nofollow">http://code.whytheluckystiff.net/mouseHole/</a>
-</p>
-
-</div>
-
-<h4 id="polipo">Polipo</h4>
-<div class="level4">
-
-<p>
- Polipo is a caching web proxy (a web cache) designed to be used by one
- person or a small group of people. It is similar in spirit to WWWOFFLE, but
- the implementation techniques are more like the ones used by Squid.
-</p>
-
-<p>
-<a href="http://www.pps.jussieu.fr/~jch/software/polipo/" class="urlextern" title="http://www.pps.jussieu.fr/~jch/software/polipo/" rel="nofollow">http://www.pps.jussieu.fr/~jch/software/polipo/</a>
-</p>
-
-</div>
-
-<h4 id="are_socks_proxy_servers_supported">Are SOCKS proxy servers supported?</h4>
-<div class="level4">
-
-<p>
-As of Midori 0.5.0 and libSoup 2.40 SOCKS proxies can be used, the Preferences dialog lists detected types and accepts curl syntax.
-</p>
-
-<p>
-libSoup &lt; 2.40 only supports HTTP proxy servers directly. A way to use SOCKS on Unix is to use tsocks with SSH as follows:
-</p>
-<ol>
-<li class="level1"><div class="li"> Install &#039;tsocks&#039;</div>
-</li>
-<li class="level1"><div class="li"> Open /etc/tsocks.conf in an editor</div>
-</li>
-<li class="level1"><div class="li"> Type something like this, you can choose the port freely: <pre class="code">server = 127.0.0.1
-server_type = 5
-server_port = 5555</pre>
-</div>
-</li>
-<li class="level1"><div class="li"> Open an SSH connection with the same port: <pre class="code"> ssh -D localhost:5555 myhost.com </pre>
-</div>
-</li>
-<li class="level1"><div class="li"> Run Midori with “tsocks” in front of it: <pre class="code"> tsocks midori </pre>
-</div>
-</li>
-<li class="level1"><div class="li"> Now you can use for example <a href="http://www.whatsmyip.org/" class="urlextern" title="http://www.whatsmyip.org/" rel="nofollow">http://www.whatsmyip.org/</a> to verify that you are using a SOCKS connection. The IP address should match the one of your SSH host. Remember to keep the SSH login running, and don&#039;t suspend it, otherwise it won&#039;t work.</div>
-</li>
-<li class="level1"><div class="li"> If the connection fails for some reason, you should see a connection error.</div>
-</li>
-</ol>
-
-</div>
-<!-- EDIT16 SECTION "Proxy servers" [18741-20562] -->
-<h1 class="sectionedit17" id="keyboard_hotkeys">Keyboard Hotkeys</h1>
-<div class="level1">
-
-</div>
-
-<h4 id="hjkl">HJKL</h4>
-<div class="level4">
-
-<p>
-You can use the Vim-like key bindings [hjkl] to navigate a page. h=left j=down k=up l=right In a picture:
-</p>
-<pre class="code"> k
- h l
- j</pre>
-
-<p>
-You can also use the arrow keys to do the same.
-</p>
-
-</div>
-
-<h4 id="following_links">Following Links</h4>
-<div class="level4">
-
-<p>
-To enable Hints in Midori, similar to vimperator in Firefox or xxxterm, press .
-</p>
-
-<p>
-With hints enabled, type the link number, and press Enter to open the link in the current tab, or Ctrl-Enter to open the link in a new tab. To clear a typed link number before pressing Enter or Ctrl-Enter, use Escape.
-</p>
-
-</div>
-
-<h4 id="use_ctrl_shift_tab_to_switch_between_pages">Use Ctrl(+Shift)+Tab to switch between pages</h4>
-<div class="level4">
-
-<p>
-Since Midori 0.3.5 Ctrl+Tab is supported by default.
-</p>
-
-<p>
-In older versions you can enable the History List extension under Tools → Extensions.
-</p>
-
-</div>
-
-<h4 id="customizing_keyboard_shortcuts">Customizing keyboard shortcuts</h4>
-<div class="level4">
-
-<p>
-Enable the Shortcuts extension Tools → Extensions. To edit a keybinding Tools → Customize Shortcuts…
-</p>
-
-</div>
-
-<h4 id="using_find">Using Find</h4>
-<div class="level4">
-
-<p>
-Default shortcuts for Find are:
-</p>
-
-<p>
-Find: Ctrl+f “/” and “,”<br/>
-
-FindNext: Ctrl+g and Enter<br/>
-
-FindPrevious: Shift+Ctrl+g<br/>
-
-</p>
-
-<p>
-Dismissing Find:
-</p>
-
-<p>
-When using Ctrl+f to bring up Find, use Ctrl+f again or ESC. When using “/” or “,” to bring up Find, the previous works here as well and by simply moving focus away from the Find box. For example: a Tab or a mouse click anywhere[besides links of course].
-</p>
-
-</div>
-<!-- EDIT17 SECTION "Keyboard Hotkeys" [20563-21895] -->
-<h1 class="sectionedit18" id="mouse_gestures">Mouse Gestures</h1>
-<div class="level1">
-
-<p>
-By default the right mouse button initiates gestures.
-</p>
-
-<p>
-You can change the button (for example, to the middle mouse button) using a hidden option:
-</p>
-<ol>
-<li class="level1"><div class="li"> Create a text file ~/.config/midori/extensions/libmouse-gestures.so/<strong>config</strong> .</div>
-</li>
-<li class="level1"><div class="li"> Type the following in there:</div>
-</li>
-</ol>
-<pre class="code"> [settings]
- button=2</pre>
-
-<p>
-As of Midori 0.5.0 individual gestures can be configured freely in the file ~/.config/midori/extensions/libmouse-gestures.so/<strong>gestures</strong> .
-Consult “midori –help-execute” for a list of available actions, which are placed on the left of the equals sign. On the right goes a sequence of directions, (W)est, (E)east, (N)orth, (S)outh, (S)outh(W)est, etc., with a semicolon (;) after each, as shown below:
-</p>
-<pre class="code"> [gestures]
- Quit=W;E;
- TabPrevious=SW;
- TabNext=SE;</pre>
-
-<p>
-Additionally, there are programs allowing mouse gestures system-wide, for example <a href="http://easystroke.wiki.sourceforge.net/" class="urlextern" title="http://easystroke.wiki.sourceforge.net/" rel="nofollow">EasyStroke</a>.
-</p>
-
-</div>
-<!-- EDIT18 SECTION "Mouse Gestures" [21896-22828] -->
-<h1 class="sectionedit19" id="user_scripts_and_styles">User scripts and styles</h1>
-<div class="level1">
-
-<p>
-UserScripts are scripts applied on some, or on all web pages. They can modify pages locally to add or alter functionality. That includes fixing bugs in web pages. User scripts are also available in other browsers, in the form of <a href="http://www.greasespot.net" class="urlextern" title="http://www.greasespot.net" rel="nofollow">Mozilla&#039;s Greasemonkey</a> or <a href="http://www.opera.com/support/tutorials/userjs/" class="urlextern" title="http://www.opera.com/support/tutorials/userjs/" rel="nofollow">Opera&#039;s User JavaScript</a>.
-</p>
-
-</div>
-
-<h4 id="how_to_install_a_userscript">How to install a UserScript</h4>
-<div class="level4">
-
-<p>
-First enable the “User Addons” extension. It will show up as a “User Scripts” panel (and it also provides “User Styles”).
-</p>
-
-<p>
-Now you need to find some scripts. You can find some at <a href="http://userscripts.org/" class="urlextern" title="http://userscripts.org/" rel="nofollow">userscripts.org</a>. Most scripts work fine, some may be written specifically for other browsers.
-</p>
-
-<p>
-If you have Midori 0.3.0 or newer, you will be offered to install scripts as soon as you see them on the page.
-</p>
-
-<p>
-To manually install a userscript, you have to download the script as a file, and put it in the folder <strong>~/.local/share/midori/scripts</strong>. You need to create that folder if it doesn&#039;t exist yet. Midori will automatically see and use it, which you can also see in the user scripts panel.
-</p>
-
-<p>
-If the script is only shown as source code on the page, you first have to create a new text file in a text editor, copy the source code into the new file, and save it as my-user-script.js where “.js” is the extension.
-</p>
-
-</div>
-
-<h4 id="compatibility_with_greasemonkey">Compatibility with GreaseMonkey</h4>
-<div class="level4">
-
-<p>
-As previously mentioned, Midori can use most scripts you will find. Midori supports Greasemonkey&#039;s <em>@include</em> and <em>@exclude</em> metadata so that scripts are only loaded on appropriate pages. Midori doesn&#039;t support advanced metadata, such as @require and @resource, so user scripts can&#039;t define dependencies on other scripts - most of the time this isn&#039;t a problem. Midori also does not support <a href="http://wiki.greasespot.net/API_reference" class="urlextern" title="http://wiki.greasespot.net/API_reference" rel="nofollow">Greasemonkey API</a>. Scripts must also be compatible with Webkit, since Midori is based on WebKit. A Greasemonkey script that makes use of functionality of Gecko/ Firefox will not work in Midori.
-</p>
-
-</div>
-
-<h4 id="flash_blocking_via_a_user_script">Flash blocking via a User script</h4>
-<div class="level4">
-
-<p>
-You can use <a href="http://userscripts.org/scripts/show/45343" class="urlextern" title="http://userscripts.org/scripts/show/45343" rel="nofollow">BlockFlash2</a> as a user script which replaces all Flash elements with a button that says “Play Flash”.
-</p>
-
-</div>
-
-<h4 id="flash_blocking_via_a_user_style">Flash blocking via a User style</h4>
-<div class="level4">
-
-<p>
-You can also use <a href="http://rightfootin.blogspot.com/2009/04/flashblock-wannabe.html" class="urlextern" title="http://rightfootin.blogspot.com/2009/04/flashblock-wannabe.html" rel="nofollow">FlashBlock WannaBe</a> as a user script in order to replace Flash elements with placeholders and load them on click. The script is pretty advanced compared to most Flash blockers found on the web.
-</p>
-
-</div>
-<!-- EDIT19 SECTION "User scripts and styles" [22829-25383] -->
-<h2 class="sectionedit20" id="user_styles">User styles</h2>
-<div class="level2">
-
-<p>
-User styles are <abbr title="Cascading Style Sheets">CSS</abbr> Cascading Style sheets that are loaded locally and applied on top of web pages, similar to User scripts, in order to add or alter functionality and also fix bugs.
-</p>
-
-</div>
-
-<h4 id="how_to_install_a_user_style">How to install a user style</h4>
-<div class="level4">
-
-<p>
-First, you need to find some styles (or write your own). You can find some at <a href="http://userstyles.org/" class="urlextern" title="http://userstyles.org/" rel="nofollow">userstyles.org</a>. Many styles may or may not work, depending on whether the author decided to use browser specific features.
-</p>
-
-<p>
-To install a user style, you have to download the style as a file, and put it in the following directory <strong>~/.local/share/midori/styles</strong> (you may need to create that directory if it does not exist). Midori will automatically see and use it, which you can also see in the user styles panel.
-</p>
-
-<p>
-Note, if the style is only shown as source code on the page, you first have to create a new text file in a text editor, copy the source code into the new file, and save it as my-user-style.css where “.css” is the extension.
-</p>
-
-</div>
-
-<h4 id="how_to_install_a_user_style_before_midori_0020">How to install a user style before Midori 0.0.20</h4>
-<div class="level4">
-
-<p>
-Open up the Preferences and use the file chooser button beside User Stylesheet to choose a style sheet file. The style sheet will from now on be applied to all sites automatically.
-</p>
-
-</div>
-
-<h4 id="a_user_css_to_display_the_url_when_a_link_is_hovered">A user css to display the url when a link is hovered</h4>
-<div class="level4">
-
-<p>
-This user css is used to display the corresponding url when a link is hovered. This is similar to what chromium/chrome provides when hovering over a link, shown on the bottom left of the page. Add the following to <strong>~/.local/share/midori/styles</strong>, then restart Midori and make sure that it is enabled Tools → Userstyles.
-</p>
-
-<p>
-Customize as needed:
-</p>
-<pre class="code css">a<span class="br0">&#91;</span>href<span class="br0">&#93;</span><span class="re2">:hover </span><span class="br0">&#123;</span>
- <span class="kw1">text-decoration</span><span class="sy0">:</span> <span class="kw2">none</span> !important<span class="sy0">;</span>
- <span class="br0">&#125;</span>
- a<span class="br0">&#91;</span>href<span class="br0">&#93;</span><span class="re2">:hover</span><span class="re2">:after </span><span class="br0">&#123;</span>
- <span class="kw1">content</span><span class="sy0">:</span> attr<span class="br0">&#40;</span>href<span class="br0">&#41;</span><span class="sy0">;</span>
- <span class="kw1">position</span><span class="sy0">:</span> <span class="kw2">fixed</span><span class="sy0">;</span> <span class="kw1">left</span><span class="sy0">:</span> <span class="re3">4px</span><span class="sy0">;</span> <span class="kw1">bottom</span><span class="sy0">:</span> <span class="re3">4px</span><span class="sy0">;</span>
- <span class="kw1">padding</span><span class="sy0">:</span> <span class="nu0">0</span> <span class="re3">6px</span> !important<span class="sy0">;</span>
- <span class="kw1">max-width</span><span class="sy0">:</span> <span class="re3">95%</span><span class="sy0">;</span> <span class="kw1">overflow</span><span class="sy0">:</span> <span class="kw2">hidden</span><span class="sy0">;</span>
- <span class="kw1">white-space</span><span class="sy0">:</span> <span class="kw2">nowrap</span><span class="sy0">;</span> text-overflow<span class="sy0">:</span> ellipsis<span class="sy0">;</span>
- <span class="kw1">font</span><span class="sy0">:</span><span class="re3">10pt</span> <span class="kw2">sans-serif</span> !important<span class="sy0">;</span> <span class="kw1">text-shadow</span><span class="sy0">:</span> <span class="nu0">0</span> <span class="nu0">0</span> <span class="re3">12px</span> <span class="kw2">white</span><span class="sy0">;</span>
- <span class="kw1">background-color</span><span class="sy0">:</span> ButtonFace !important<span class="sy0">;</span> <span class="kw1">color</span><span class="sy0">:</span> ButtonText !important<span class="sy0">;</span>
- opacity<span class="sy0">:</span> <span class="nu0">0.8</span><span class="sy0">;</span> <span class="kw1">outline</span><span class="sy0">:</span> ButtonFace <span class="kw2">solid</span> <span class="kw2">thick</span><span class="sy0">;</span>
- <span class="kw1">z-index</span><span class="sy0">:</span> <span class="nu0">9999</span><span class="sy0">;</span>
- <span class="br0">&#125;</span></pre>
-
-</div>
-
-<h4 id="tweaking_fonts_via_css">Tweaking fonts via CSS</h4>
-<div class="level4">
-
-<p>
-If changing system-wide font settings isn&#039;t bringing the desired results or rendering should be tweaked only for websites <abbr title="Cascading Style Sheets">CSS</abbr> can be an alternative. Add the following to <strong>~/.local/share/midori/styles</strong>, then restart Midori and make sure that it is enabled Tools → Userstyles.
-</p>
-
-<p>
-Customize as needed:
-</p>
-<pre class="code css"><span class="sy0">*</span> <span class="br0">&#123;</span>
- font-smooth<span class="sy0">:</span><span class="kw2">always</span><span class="sy0">;</span>
- -webkit-font-smoothing<span class="sy0">:</span> antialiased<span class="sy0">;</span>
- text-rendering<span class="sy0">:</span> optimizeLegibility
-<span class="br0">&#125;</span></pre>
-
-</div>
-<!-- EDIT20 SECTION "User styles" [25384-28087] -->
-<h1 class="sectionedit21" id="midori_architecture">Midori Architecture</h1>
-<div class="level1">
-
-<p>
-Midori stands on the shoulders of three giants in particular: the software libraries <a href="http://www.gtk.org/" class="urlextern" title="http://www.gtk.org/" rel="nofollow">GTK+</a>, <a href="http://webkitgtk.org/" class="urlextern" title="http://webkitgtk.org/" rel="nofollow">WebKitGTK+</a>, and <a href="https://developer.gnome.org/libsoup/" class="urlextern" title="https://developer.gnome.org/libsoup/" rel="nofollow">libsoup</a>. GTK+ provides the buttons, windows and menus, WebKitGTK+ draws and controls web pages, and libsoup downloads those pages.
-</p>
-
-<p>
-WebKitGTK+ itself uses two other important libraries: <a href="https://www.webkit.org/projects/javascript/index.html" class="urlextern" title="https://www.webkit.org/projects/javascript/index.html" rel="nofollow">JavaScriptCore</a>, a WebKit project which runs scripts on web pages; and <a href="http://gstreamer.freedesktop.org/" class="urlextern" title="http://gstreamer.freedesktop.org/" rel="nofollow">GStreamer</a>, which plays HTML5 video and audio.
-</p>
-
-</div>
-<!-- EDIT21 SECTION "Midori Architecture" [28088-28718] -->
-<h2 class="sectionedit22" id="webkit_version_numbers">WebKit Version Numbers</h2>
-<div class="level2">
-
-<p>
-WebKit is the core of the Midori browser, and it determines how web pages are rendered. Because WebKit is a complex piece of software and compatible with various libraries, its version numbers and naming schemes can at times be confusing.
-</p>
-
-<p>
-WebKit itself is a library which works in many environments, such as Windows, <abbr title="Operating System">OS</abbr> X, and various Linux DE. There are different “ports”, one of which corresponds to each of these environments, and each of which is slightly different in bugs and features at any given time. The WebKit port used by Midori (because Midori is built with GTK+) is WebKitGTK+.
-</p>
-
-<p>
-WebKitGTK+ can be compiled against either GTK+2 or GTK+3. This will result in library filenames like libwebkitgtk-1.0.so or libwebkitgtk-3.0.so, respectively. This has nothing to do with the version of WebKit itself.
-</p>
-
-<p>
-WebKit has a “new <abbr title="Application Programming Interface">API</abbr> layer … designed from the ground up to support a split process model”–so pages can crash without the entire browser crashing. This layer is called WebKit2, and for WebKitGTK+ it requires building against GTK+3, producing a library file called libwebkit2gtk-3.0.so.
-</p>
-
-<p>
-To find out the version of WebKitGTK+ your build of Midori is using, visit about:version.
-</p>
-
-</div>
-
-<h4 id="version_number_interactions">Version Number Interactions</h4>
-<div class="level4">
-
-<p>
-The WebKit2 <abbr title="Application Programming Interface">API</abbr> layer is available from fairly old WebKit versions through the present, but Midori&#039;s WebKit2 support requires version 2.0.0 or newer of WebKitGTK+. Current versions of WebKitGTK+ continue to support GTK+2 and GTK+3 (the latter since 1.4.x or so). As stated above, the WebKit2 <abbr title="Application Programming Interface">API</abbr> layer is only available with GTK+3.
-</p>
-
-<p>
-Midori&#039;s support for WebKit2 is still provisional, and likely unsuitable for real-world daily usage; much work is being done in this area so that Midori can use WebKit2 by default at some point in the future.
-</p>
-
-</div>
-<!-- EDIT22 SECTION "WebKit Version Numbers" [28719-30528] -->
-<h1 class="sectionedit23" id="midori_and_mediaherald">Midori and mediaHerald</h1>
-<div class="level1">
-
-<p>
-mediaHerald is a dbus service (/org/midori/mediaHeraldallow) users to connect to dbus and check the titme and url of the video that midori plays in <strong>YOUTUBE</strong>, <strong>VIMEO</strong> or <strong>DAILYMOTION</strong>, the extension which does the work is called webmedia-now-playing.
-</p>
-
-<p>
-If you want to get the video title and the uri is easy more than easy <img src="/lib/images/smileys/icon_smile.gif" class="icon" alt=":-)" /> .
-</p>
-<pre class="code bash"><span class="co0">#!/bin/sh</span>
-&nbsp;
-<span class="kw3">eval</span> $<span class="br0">&#40;</span>dbus-send <span class="re5">--session</span> <span class="re5">--print-reply</span> <span class="re5">--dest</span>=org.midori.mediaHerald <span class="sy0">/</span>org<span class="sy0">/</span>midori<span class="sy0">/</span>mediaHerald org.freedesktop.DBus.Properties.GetAll string:<span class="st0">&quot;org.midori.mediaHerald&quot;</span> <span class="sy0">|</span> <span class="kw2">awk</span> <span class="st_h">'
- /string *&quot;VideoTitle/{
- while (1) {
- getline line
- if (line ~ /string &quot;/)
- sub(/.*string /, &quot;TITLE=&quot;, line)
- print line
- break
- }
- }
- /string *&quot;VideoUri/{
- while (1) {
- getline line
- if (line ~ /string &quot;/)
- sub(/.*string /, &quot;URI=&quot;, line)
- print line
- break
- }
- }
- '</span><span class="br0">&#41;</span>
-<span class="kw3">echo</span> <span class="st0">&quot;Midori is now playing: <span class="es2">$TITLE</span> ,the uri is: <span class="es2">$URI</span>&quot;</span></pre>
-
-</div>
-<!-- EDIT23 SECTION "Midori and mediaHerald" [30529-] --></div>
-</body>
-</html>
diff --git a/data/flummi/Create.sql b/data/flummi/Create.sql
deleted file mode 100644
index e9efc421..00000000
--- a/data/flummi/Create.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-CREATE TABLE IF NOT EXISTS tasks
-(
- id INTEGER PRIMARY KEY,
- once INTEGER DEFAULT 1,
- command TEXT DEFAULT NULL
-);
diff --git a/data/forms/Create.sql b/data/forms/Create.sql
deleted file mode 100644
index 6630d317..00000000
--- a/data/forms/Create.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-CREATE TABLE IF NOT EXISTS forms
-(
- domain text,
- field text,
- value text
-)
diff --git a/data/gtk3.css b/data/gtk3.css
index 9a95489c..7925b7d2 100644
--- a/data/gtk3.css
+++ b/data/gtk3.css
@@ -1,29 +1,31 @@
-.notebook tab .button {
- -GtkButton-default-border: 0;
- -GtkButton-default-outside-border: 0;
- -GtkButton-inner-border: 0;
- -GtkWidget-focus-line-width: 0;
- -GtkWidget-focus-padding: 0;
- padding: 0;
- border-width: 1px 1px 0 0;
-}
+/*
+ Copyright (C) 2018 Christian Dywan <christian@twotoats.de>
-GtkOverlay > * {
- padding: 4px;
- border-style: solid;
- border-radius: 0 5px 0 0;
- border-width: 1px 1px 0 0;
-}
+ 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.
-GtkOverlay MidoriFindbar {
- border-radius: 0 0 0 5px;
- border-width: 0 0 1px 1px; /* top right bottom left */
-}
+ See the file COPYING for the full license text.
+*/
-/* Kill grey backround on inactive buttons */
-GtkDrawingArea,
-GtkImage,
-GtkImage:insensitive,
-GtkImage:selected {
- background-color: @transparent;
+.tab:not(:checked) {
+ opacity: 0.7;
+}
+.tab:hover {
+ box-shadow: inset 0 3px darker(@theme_selected_bg_color);
+}
+.tab:checked {
+ box-shadow: inset 0 3px @theme_selected_bg_color;
+}
+.tab label {
+ text-shadow: none;
+}
+.tab:backdrop, .tab:only-child {
+ border: none;
+ box-shadow: none;
+}
+.tab button {
+ padding: 0;
+ margin: 0;
}
diff --git a/data/logo-shade.svg b/data/logo-shade.svg
deleted file mode 100644
index 7a21a99b..00000000
--- a/data/logo-shade.svg
+++ /dev/null
@@ -1,150 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="307.65372"
- height="350"
- id="svg2418"
- sodipodi:version="0.32"
- inkscape:version="0.46"
- version="1.0"
- inkscape:export-filename="/home/user/logo-shade.png"
- inkscape:export-xdpi="90"
- inkscape:export-ydpi="90"
- sodipodi:docname="logo-shade.svg"
- inkscape:output_extension="org.inkscape.output.svg.inkscape">
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- gridtolerance="10000"
- guidetolerance="10"
- objecttolerance="10"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="1.03"
- inkscape:cx="74.949357"
- inkscape:cy="143.09941"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="false"
- inkscape:window-width="1253"
- inkscape:window-height="682"
- inkscape:window-x="0"
- inkscape:window-y="22" />
- <defs
- id="defs2420">
- <linearGradient
- id="linearGradient3412">
- <stop
- id="stop3414"
- offset="0"
- style="stop-color:#ffffff;stop-opacity:0.59836066;" />
- <stop
- id="stop3416"
- offset="1"
- style="stop-color:#97f839;stop-opacity:0;" />
- </linearGradient>
- <linearGradient
- id="linearGradient3458">
- <stop
- id="stop3460"
- offset="0"
- style="stop-color:#88fe38;stop-opacity:1;" />
- <stop
- id="stop3462"
- offset="1"
- style="stop-color:#ffffff;stop-opacity:0;" />
- </linearGradient>
- <inkscape:perspective
- id="perspective2426"
- inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
- inkscape:vp_z="744.09448 : 526.18109 : 1"
- inkscape:vp_y="0 : 1000 : 0"
- inkscape:vp_x="0 : 526.18109 : 1"
- sodipodi:type="inkscape:persp3d" />
- <linearGradient
- id="linearGradient3458-648">
- <stop
- id="stop2423"
- offset="0"
- style="stop-color:#bababa;stop-opacity:1;" />
- <stop
- id="stop2425"
- offset="1"
- style="stop-color:#ffffff;stop-opacity:0;" />
- </linearGradient>
- <linearGradient
- id="linearGradient3412-967">
- <stop
- id="stop2429"
- offset="0"
- style="stop-color:#ffffff;stop-opacity:0.59836066;" />
- <stop
- id="stop2431"
- offset="1"
- style="stop-color:#bababa;stop-opacity:0;" />
- </linearGradient>
- </defs>
- <metadata
- id="metadata2423">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:creator>
- <cc:Agent>
- <dc:title>Nancy Runge &lt;nancy@twotoasts.de&gt;</dc:title>
- </cc:Agent>
- </dc:creator>
- <cc:license
- rdf:resource="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html" />
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- transform="translate(-280.66056,-644.09745)"
- id="layer1"
- inkscape:groupmode="layer"
- inkscape:label="Layer 1">
- <g
- id="g2546"
- style="fill:#ffffff;fill-opacity:1;stroke:#bcbcbc;stroke-opacity:1"
- transform="matrix(2.7318355,0,0,2.7318355,-731.07518,-1421.3016)">
- <path
- sodipodi:nodetypes="ccsscccsc"
- id="path3598"
- d="M 479.0149,757.44485 C 463.33929,760.3524 390.05715,768.6009 373.75783,823.05659 C 368.99751,841.48441 371.67629,866.55457 392.88608,865.62945 C 394.38911,865.56465 394.54399,866.0597 395.07871,867.32475 C 403.8111,887.98406 426.11314,884.657 430.13518,876.12801 C 430.41248,875.53998 429.75994,876.1331 430.13518,876.12801 C 452.01909,891.1113 463.94687,870.37434 470.8404,851.89287 C 479.26032,835.85799 484.40756,769.09622 479.90163,773.41411 C 403.13312,846.97906 403.28006,782.18757 479.0149,757.44485"
- style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#bcbcbc;stroke-width:2.79349113000000004;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- id="path3606"
- d="M 394.6271,866.42646 C 389.11843,841.31269 395.51037,833.40754 398.10369,830.14819"
- style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#bcbcbc;stroke-width:2.79349113000000004;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- sodipodi:nodetypes="cc" />
- <path
- id="path3608"
- d="M 430.04511,875.57142 C 422.884,860.41673 424.07276,847.90995 429.16085,838.58891"
- style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#bcbcbc;stroke-width:2.79349113000000004;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- sodipodi:nodetypes="cc" />
- </g>
- <g
- id="g2551"
- style="fill:#e8e8e8;fill-opacity:1;stroke:none"
- transform="matrix(2.7318355,0,0,2.7318355,-731.59243,-1420.9344)">
- <path
- sodipodi:nodetypes="cccccccccccc"
- id="path2553"
- d="M 447.08573,768.31725 C 436.04919,774.1595 397.92257,781.58705 381.33359,820.27881 C 377.02863,833.88105 375.31278,851.44676 387.44516,857.54862 C 385.16801,848.06163 387.57514,834.11288 393.43272,827.57808 C 397.5473,821.96506 405.70797,826.00823 403.09775,831.29165 C 401.29067,836.46522 394.76631,843.8643 399.87669,863.28435 C 404.09154,874.85534 415.25599,879.58634 422.43347,873.92723 C 414.92666,858.12585 420.32228,825.17457 433.92305,832.69366 C 440.70334,836.82119 424.80942,848.38632 435.43821,869.81488 C 448.73626,880.75776 460.15899,863.55615 464.02222,850.63024 C 472.18961,832.82769 477.16809,790.8233 475.1786,786.29359 C 410.97397,845.50147 395.61545,794.24336 447.07098,768.23969"
- style="fill:#e8e8e8;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.79349113;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- </g>
- </g>
-</svg>
diff --git a/data/midori.rc b/data/main.rc
index 63a5dc09..63a5dc09 100644
--- a/data/midori.rc
+++ b/data/main.rc
diff --git a/data/midori-private.desktop.in b/data/midori-private.desktop.in
deleted file mode 100644
index f34f914b..00000000
--- a/data/midori-private.desktop.in
+++ /dev/null
@@ -1,15 +0,0 @@
-[Desktop Entry]
-Version=1.0
-Type=Application
-_Name=Midori Private Browsing
-_GenericName=Private Browsing
-_Comment=Open a new private browsing window
-Categories=GTK;Network;WebBrowser;
-Exec=midori --private %U
-Icon=midori
-Terminal=false
-StartupNotify=true
-NotShowIn=Pantheon;
-X-Osso-Type=application/x-executable
-X-Osso-Service=midori
-
diff --git a/data/midori.appdata.xml.in b/data/midori.appdata.xml.in
index 8c0e6b3b..f1b7fb5e 100644
--- a/data/midori.appdata.xml.in
+++ b/data/midori.appdata.xml.in
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright 2015 Christian Dywan <christian@twotoasts.de> -->
+<!-- Copyright 2015-2018 Christian Dywan <christian@twotoasts.de> -->
<component type="desktop">
<id>midori.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
- <project_license>LGPL-2.1 and MIT</project_license>
+ <project_license>LGPL-2.1</project_license>
<name>Midori</name>
<icon type="stock">midori</icon>
<summary>A fast and lightweight web browser</summary>
@@ -32,5 +32,5 @@
</screenshots>
<update_contact>christian@twotoasts.de</update_contact>
<developer_name>Christian Dywan</developer_name>
- <url type="bugtracker">https://bugs.launchpad.net/midori</url>
+ <url type="bugtracker">https://github.com/midori-browser/core/issues</url>
</component>
diff --git a/data/midori.desktop.in b/data/midori.desktop.in
index 9115f7dd..ffd1df70 100644
--- a/data/midori.desktop.in
+++ b/data/midori.desktop.in
@@ -14,17 +14,7 @@ Icon=midori
Terminal=false
StartupNotify=true
X-GNOME-UsesNotifications=true
-X-Osso-Type=application/x-executable
-X-Osso-Service=midori
-Actions=TabNew;WindowNew;Private;
-
-[Desktop Action TabNew]
-_Name=New Tab
-Exec=midori -e TabNew
-
-[Desktop Action WindowNew]
-_Name=New Window
-Exec=midori -e WindowNew
+Actions=Private;
[Desktop Action Private]
_Name=New Private Browsing Window
diff --git a/data/midori.swf b/data/midori.swf
deleted file mode 100644
index d16df89c..00000000
--- a/data/midori.swf
+++ /dev/null
Binary files differ
diff --git a/data/nojs/nojs-statusicon-allowed.png b/data/nojs/nojs-statusicon-allowed.png
deleted file mode 100644
index 8204bc45..00000000
--- a/data/nojs/nojs-statusicon-allowed.png
+++ /dev/null
Binary files differ
diff --git a/data/nojs/nojs-statusicon-denied.png b/data/nojs/nojs-statusicon-denied.png
deleted file mode 100644
index d67cb6d9..00000000
--- a/data/nojs/nojs-statusicon-denied.png
+++ /dev/null
Binary files differ
diff --git a/data/nojs/nojs-statusicon-mixed.png b/data/nojs/nojs-statusicon-mixed.png
deleted file mode 100644
index 425f6dc6..00000000
--- a/data/nojs/nojs-statusicon-mixed.png
+++ /dev/null
Binary files differ
diff --git a/data/notes/Create.sql b/data/notes/Create.sql
deleted file mode 100644
index 0980b638..00000000
--- a/data/notes/Create.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-CREATE TABLE IF NOT EXISTS notes
-(
- id INTEGER PRIMARY KEY,
- uri TEXT,
- title TEXT,
- note_content TEXT,
- tstamp INTEGER
-);
diff --git a/data/speeddial-head.html b/data/speeddial-head.html
deleted file mode 100644
index 70def637..00000000
--- a/data/speeddial-head.html
+++ /dev/null
@@ -1,351 +0,0 @@
-<!--
- Speed Dial head template for Midori.
- Copyright (C) 2009 Jean-François Guchens <zcx000@gmail.com>
- Copyright (C) 2011 Paweł Forysiuk <tuxator@o2.pl>
- Copyright (C) 2011 Cassidy James <email@cassidyjames.com>
- This file is licensed under the terms of the expat license, see the file EXPAT.
--->
-
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>{title}</title>
- <style>
-
- /* Animations */
-
- @-webkit-keyframes popin {
- 0% { opacity: 0.0; -webkit-transform: scale(0.00); }
- 75% { opacity: 0.5; -webkit-transform: scale(1.15); }
- 100% { opacity: 1.0; -webkit-transform: scale(1.00); }
- }
-
- /* Styles */
-
- * {
- margin: 0;
- padding: 0;
- cursor: default;
- font-size: 13px;
- color: #4d4d4d;
- -webkit-user-select: none;
- }
-
- html, body {
- font-family: sans-serif;
- width: 100%;
- height: 100%;
- outline: 0;
- background: #eee;
- }
-
- input {
- width: 85%;
- }
-
- #content {
- width: 96%;
- height: 85%;
- margin: 0 auto;
- padding-top: 5%;
- padding-left: 2%;
- }
-
- div.shortcut {
- width: 25%;
- height: 33%;
- float: left;
- }
-
- div.shortcut .preview {
- width: 85%;
- height: 75%;
- margin: auto;
- box-shadow: 0 1px 3px rgba(0,0,0,0.12),
- 0 1px 2px rgba(0,0,0,0.24);
- position: relative;
- border-radius: 3px;
- transition: all 200ms ease-in-out;
- outline: none;
- }
-
- div.shortcut .preview img {
- width: 100%;
- height: 100%;
- cursor: pointer;
- border-radius: 3px;
- }
-
- div.shortcut .preview.new {
- background-color: rgba(0,0,0,0.05);
- border: 1px solid rgba(0,0,0,0.15);
-
- box-shadow: inset 0 0 1px 1px rgba(0,0,0,0.05),
- 0 1px 0 0 rgba(255,255,255,0.40);
- overflow: hidden;
- }
-
- div.shortcut .preview.new .add {
- background-color: #777;
- width: 64px;
- height: 64px;
- line-height: 64px;
- text-align: center;
- border-radius: 32px;
- position: absolute;
- left: 50%;
- top: 50%;
- margin-left: -32px;
- margin-top: -32px;
- box-shadow: 0 1px 3px rgba(0,0,0,0.12),
- 0 1px 2px rgba(0,0,0,0.24);
- outline: none;
- }
-
- div.shortcut .preview.new .add:after {
- content: "+";
- color: #fff;
- font-size: 48px;
- display: inline-block;
- }
-
- .title {
- background: transparent;
- border: 2px solid transparent;
- display: block;
- text-align: center;
- margin: 8px;
- margin-left: auto;
- margin-right: auto;
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
- cursor: text;
- outline: none;
- transition: all 200ms ease-in-out;
- padding-bottom: 6px;
- }
-
- .preview.new ~ .title {
- cursor: default;
- }
-
- .title.active {
- border-bottom-color: #4CAF50;
- }
-
- .cross {
- color: #fff;
- display: block;
- width: 32px;
- height: 32px;
- text-align: center;
- line-height: 32px;
- top: -14px;
- right: -14px;
- position: absolute;
- cursor: pointer;
- opacity: 0;
- background-color: #555;
- border-radius: 16px;
- box-shadow: 0 1px 3px rgba(0,0,0,0.12),
- 0 1px 2px rgba(0,0,0,0.24);
- }
-
- .cross:after {
- content: '+';
- -webkit-transform: rotate(45deg);
- font-size: 22px;
- display: inline-block;
- }
-
- div.shortcut .preview:hover .cross {
- -webkit-animation: popin 250ms ease-in-out;
- opacity: 1;
- }
-
- .box.added {
- display:none;
- }
-
- .selectable {
- -webkit-user-select: text;
- }
- </style>
-
- <script type="text/javascript">
- var previousName = "";
-
- function input_key_down (ev) {
- // 13 is the key code for enter
- if(ev.keyCode == 13) ev.target.blur();
- // 27 is the key code for escape
- if(ev.keyCode == 27) {
- ev.target.value = previousName;
- ev.target.blur();
- }
- }
-
- function add_tile (ev) {
- ev.preventDefault();
-
- var url = prompt ("{enter_shortcut_address}", "http://");
- if (!url)
- return false;
-
- if (url.indexOf ("://") == -1)
- url = "http://" + url;
-
- var id = ev.target.parentNode.parentNode.id;
- console.log ("speed_dial-save-add " + id + " " + url);
- }
-
- function done_editing_title (ev) {
- input = ev.target;
- input.className = "title";
-
- var name = ev.target.value;
- if (name == "")
- name = previousName;
- var id = ev.target.parentNode.id;
- console.log ("speed_dial-save-rename " + id + " " + name);
- }
-
- function editing_tile (ev) {
- input = ev.target;
- previousName = input.value;
- // indicate to user they are editing the title
- input.className = input.className + " active";
- }
-
- function delete_tile (ev) {
- ev.preventDefault();
-
- if (!confirm("{are_you_sure}"))
- return;
-
- var id = ev.target.parentNode.parentNode.id;
- console.log ("speed_dial-save-delete " + id);
- }
-
- var firstNode, secondNode;
- var cursor;
-
- var get_dial_div = function (ele) {
- var dial_div;
- if (ele.nodeName == 'IMG')
- dial_div = ele.parentNode.parentNode.parentNode;
- if (ele.className == 'title')
- dial_div = ele.parentNode;
- if (ele.className.indexOf ('shortcut') != -1)
- dial_div = ele;
- return dial_div;
- }
-
- function click (ev) {
- if (ev == undefined)
- return;
-
- /* If the target of the event is an element of class title
- * and not also of class add-shortcut we are editing title
- */
- var classes = ev.target.className.split(" ");
- var edit_title = false;
- for (var i = 0; i < classes.length; i++) {
- if(classes[i] == "add-shortcut") {
- edit_title = false;
- break;
- }
- if(classes[i] == "title")
- edit_title = true;
- }
-
- if(edit_title)
- return;
-
- ev.preventDefault();
- var ele = ev.target;
- cursor = ele.style.cursor;
- ele.style.cursor = 'move';
-
- var eparent = get_dial_div (ele);
- if (eparent != undefined) {
- eparent.className = 'shortcut selected';
- firstNode = eparent.id;
- }
- };
-
- function up (ev) {
- if (ev == undefined)
- return;
-
- ev.preventDefault();
- ele = ev.target;
- var eparent = get_dial_div (ele);
-
- ele.style.cursor = cursor;
- if(eparent != undefined) secondNode = eparent.id;
- else return;
-
- /* ommit just mere clicking the dial */
- if (firstNode != secondNode && firstNode != undefined)
- swap();
- };
-
- function over (ev) {
- if (ev == undefined)
- return;
-
- ev.preventDefault();
- var ele = ev.target;
- var eparent = get_dial_div (ele);
-
- var dial = document.getElementsByClassName("shortcut");
- if (firstNode != undefined)
- {
- eparent.className = 'shortcut selected';
- for (var i = 0; i < dial.length; i++) {
- if (eparent.id != firstNode.id && dial[i].id != eparent.id) {
- dial[i].className = 'shortcut';
- }
- }
- }
- ele.style.cursor = cursor;
- }
-
- function swap () {
- console.log ("speed_dial-save-swap " + firstNode + " " + secondNode);
- };
-
- function init () {
- var new_tile = document.getElementsByClassName ("preview new");
- new_tile[0].addEventListener ('click', add_tile, false);
-
- var titles = document.getElementsByClassName ("title");
- var len = titles.length;
- for (var i = 0; i < len; i++) {
- if (titles[i].parentNode.childNodes[0].className != "preview new") {
- titles[i].addEventListener ('click', editing_tile, false);
- titles[i].addEventListener ('blur', done_editing_title, false);
- titles[i].addEventListener ('keydown', input_key_down, false);
- }
- }
-
- var crosses = document.getElementsByClassName ("cross");
- var len = crosses.length;
- for (var i = 0; i < len; i++)
- crosses[i].addEventListener ('click', delete_tile, false);
-
- var occupied_tiles = document.getElementsByClassName ("shortcut");
- var len = occupied_tiles.length;
- for (var i = 0; i < len; i++) {
- if (occupied_tiles[i].childNodes[0].className != "preview new") {
- occupied_tiles[i].addEventListener('mousedown', click, false);
- occupied_tiles[i].addEventListener('mouseover', over, false);
- occupied_tiles[i].addEventListener('mouseup', up, false);
- }
- }
- }
- </script>
-</head>
-<body onload="init ();">
- <div id="content">
diff --git a/data/tabby/Create.sql b/data/tabby/Create.sql
deleted file mode 100644
index 0b5690bd..00000000
--- a/data/tabby/Create.sql
+++ /dev/null
@@ -1,33 +0,0 @@
-CREATE TABLE IF NOT EXISTS sessions
-(
- id INTEGER PRIMARY KEY,
- parent_id INTEGER DEFAULT 0,
- crdate INTEGER DEFAULT 0,
- tstamp INTEGER DEFAULT 0,
- closed INTEGER DEFAULT 0,
- title TEXT DEFAULT NULL,
- FOREIGN KEY(parent_id) REFERENCES sessions(id)
-);
-
-CREATE TABLE IF NOT EXISTS tabs
-(
- id INTEGER PRIMARY KEY,
- session_id INTEGER NOT NULL,
- uri TEXT DEFAULT NULL,
- icon TEXT DEFAULT NULL,
- title TEXT DEFAULT NULL,
- crdate INTEGER DEFAULT 0,
- tstamp INTEGER DEFAULT 0,
- closed INTEGER DEFAULT 0,
- FOREIGN KEY(session_id) REFERENCES sessions(id)
-);
-
-CREATE TABLE IF NOT EXISTS tab_history
-(
- id INTEGER PRIMARY KEY,
- tab_id INTEGER,
- url TEXT,
- icon TEXT,
- title TEXT,
- FOREIGN KEY(tab_id) REFERENCES tabs(id)
-);
diff --git a/data/tabby/Update1.sql b/data/tabby/Update1.sql
deleted file mode 100644
index 26b72103..00000000
--- a/data/tabby/Update1.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-ALTER TABLE tabs ADD sorting REAL DEFAULT 0;
-
-CREATE INDEX sorting on tabs (sorting ASC);
-CREATE INDEX tstamp on tabs (tstamp ASC);
diff --git a/docs/api/CMakeLists.txt b/docs/api/CMakeLists.txt
deleted file mode 100644
index f14f771b..00000000
--- a/docs/api/CMakeLists.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (C) 2013 Olivier Duchateau
-
-include (GtkDoc)
-
-if (GTKDOC_FOUND)
- list (APPEND MODULES "katze" "midori")
- foreach (MOD ${MODULES})
- if (EXISTS "${CMAKE_SOURCE_DIR}/${MOD}")
- gtkdoc (${MOD})
- endif ()
- endforeach ()
-else ()
- message (FATAL_ERROR "gtk-doc not found")
-endif ()
diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt
deleted file mode 100644
index fecb1694..00000000
--- a/extensions/CMakeLists.txt
+++ /dev/null
@@ -1,134 +0,0 @@
-# Copyright (C) 2013 Christian Dywan <christian@twotoasts.de>
-
-set(EXTENSIONDIR "${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_PROJECT_NAME}")
-include_directories(
- "${CMAKE_SOURCE_DIR}"
- "${CMAKE_SOURCE_DIR}/midori"
- "${CMAKE_SOURCE_DIR}/katze"
- ${DEPS_INCLUDE_DIRS}
- ${OPTS_INCLUDE_DIRS}
- ${DEPS_GTK_INCLUDE_DIRS}
- ${OPTS_GTK_INCLUDE_DIRS}
- ${CMAKE_BINARY_DIR}
- "${CMAKE_BINARY_DIR}/midori"
- )
-file(GLOB EXTENSIONS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
-if (HALF_BRO_INCOM_WEBKIT2)
- list(REMOVE_ITEM EXTENSIONS
- "cookie-permissions"
- "addons.c"
- "formhistory"
- "external-download-manager.vala"
- "nojs"
- "nsplugin-manager.vala"
- "tabs2one.c"
- )
-endif ()
-
-# FIXME: re-enable webmedia extension
-# once we have working notifications on win
-if (WIN32)
- list(REMOVE_ITEM EXTENSIONS "webmedia-now-playing.vala")
-endif()
-
-# FIXME: not stable enough for release
-if (NOT REVISION)
- list(REMOVE_ITEM EXTENSIONS "tabs2one.c")
-endif()
-
-foreach(UNIT_SRC ${EXTENSIONS})
- string(FIND ${UNIT_SRC} ".c" UNIT_EXTENSION)
- if (UNIT_EXTENSION GREATER -1)
- string(REPLACE ".c" "" UNIT ${UNIT_SRC})
- add_library(${UNIT} MODULE ${UNIT_SRC})
- target_link_libraries(${UNIT}
- ${LIBMIDORI}
- )
- set_target_properties(${UNIT} PROPERTIES
- COMPILE_FLAGS ${CFLAGS}
- )
- install(TARGETS ${UNIT}
- LIBRARY DESTINATION ${EXTENSIONDIR}
- )
- endif ()
-endforeach ()
-
-foreach(UNIT_SRC ${EXTENSIONS})
- string(FIND ${UNIT_SRC} "." UNIT_EXTENSION)
- if (UNIT_EXTENSION EQUAL -1)
- file(GLOB UNIT_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${UNIT_SRC}/*.c")
- file(GLOB UNIT_FILES_VALA RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${UNIT_SRC}/*.vala")
- if (UNIT_FILES_VALA)
- include(ValaPrecompile)
- vala_precompile(UNIT_SRC_C ${UNIT_SRC}
- ${UNIT_FILES_VALA}
- PACKAGES
- ${PKGS}
- OPTIONS
- ${VALAFLAGS}
- --use-header="${CMAKE_PROJECT_NAME}-core.h"
- GENERATE_HEADER
- "${UNIT_SRC}"
- GENERATE_HEADER
- ${UNIT}
- CUSTOM_VAPIS
- ${EXTRA_VAPIS}
- "${CMAKE_SOURCE_DIR}/midori/midori.vapi"
- "${CMAKE_BINARY_DIR}/midori/${LIBMIDORI}.vapi"
- )
- set(UNIT_FILES ${UNIT_FILES} ${UNIT_SRC_C})
- endif ()
- if (UNIT_FILES)
- add_library(${UNIT_SRC} MODULE ${UNIT_FILES})
- target_link_libraries(${UNIT_SRC}
- ${LIBMIDORI}
- )
- install(TARGETS ${UNIT_SRC}
- LIBRARY DESTINATION ${EXTENSIONDIR}
- )
- # extensions with vala code get the lenient VALA_CFLAGS
- # others get the usual CFLAGS with -Wall and -Werror
- if (UNIT_FILES_VALA)
- set_target_properties(${UNIT_SRC} PROPERTIES
- COMPILE_FLAGS ${VALA_CFLAGS}
- )
- else ()
- set_target_properties(${UNIT_SRC} PROPERTIES
- COMPILE_FLAGS ${CFLAGS}
- )
- endif ()
- endif ()
- endif ()
-endforeach ()
-
-foreach(UNIT_SRC ${EXTENSIONS})
- string(FIND ${UNIT_SRC} ".vala" UNIT_EXTENSION)
- if (UNIT_EXTENSION GREATER -1)
- string(REPLACE ".vala" "" UNIT ${UNIT_SRC})
- include(ValaPrecompile)
- vala_precompile(UNIT_SRC_C ${UNIT}
- ${UNIT_SRC}
- PACKAGES
- ${PKGS}
- OPTIONS
- ${VALAFLAGS}
- --use-header="${CMAKE_PROJECT_NAME}-core.h"
- GENERATE_HEADER
- ${UNIT}
- CUSTOM_VAPIS
- ${EXTRA_VAPIS}
- "${CMAKE_SOURCE_DIR}/midori/midori.vapi"
- "${CMAKE_BINARY_DIR}/midori/${LIBMIDORI}.vapi"
- )
- add_library(${UNIT} MODULE ${UNIT_SRC_C})
- target_link_libraries(${UNIT}
- ${LIBMIDORI}
- )
- set_target_properties(${UNIT} PROPERTIES
- COMPILE_FLAGS "${VALA_CFLAGS}"
- )
- install(TARGETS ${UNIT}
- LIBRARY DESTINATION ${EXTENSIONDIR}
- )
- endif ()
-endforeach ()
diff --git a/extensions/about.vala b/extensions/about.vala
deleted file mode 100644
index bc834b33..00000000
--- a/extensions/about.vala
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- Copyright (C) 2013 André Stösel <andre@stoesel.de>
- Copyright (C) 2014 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.
-*/
-
-namespace About {
- private abstract class Page : GLib.Object {
- public abstract string uri { get; set; }
- public abstract void get_contents (Midori.View view, string uri);
- protected void load_html (Midori.View view, string content, string uri) {
- #if HAVE_WEBKIT2
- view.web_view.load_html (content, uri);
- #else
- view.web_view.load_html_string (content, uri);
- #endif
- }
- }
-
- private class Widgets : Page {
- public override string uri { get; set; default = "about:widgets"; }
- public override void get_contents (Midori.View view, string uri) {
- string[] widgets = {
- "<input value=\"demo\"%s>",
- "<p><input type=\"password\" value=\"demo\"%s></p>",
- "<p><input type=\"checkbox\" value=\"demo\"%s> demo</p>",
- "<p><input type=\"radio\" value=\"demo\"%s> demo</p>",
- "<p><select%s><option>foo bar</option><option selected>spam eggs</option></select></p>",
- "<p><select%s size=\"3\"><option>foo bar</option><option selected>spam eggs</option></select></p>",
- "<p><input type=\"file\"%s></p>",
- "<p><input type=\"file\" multiple%s></p>",
- "<input type=\"button\" value=\"demo\"%s>",
- "<p><input type=\"email\" value=\"user@localhost.com\"%s></p>",
- "<input type=\"url\" value=\"http://www.example.com\"%s>",
- "<input type=\"tel\" value=\"+1 234 567 890\" pattern=\"^[0+][1-9 /-]*$\"%s>",
- "<input type=\"number\" min=1 max=9 step=1 value=\"4\"%s>",
- "<input type=\"range\" min=1 max=9 step=1 value=\"4\"%s>",
- "<input type=\"date\" min=1990-01-01 max=2010-01-01%s>",
- "<input type=\"search\" placeholder=\"demo\"%s>",
- "<textarea%s>Lorem ipsum doloret sit amet…</textarea>",
- "<input type=\"color\" value=\"#d1eeb9\"%s>",
- "<progress min=1 max=9 value=4 %s></progress>",
- "<keygen type=\"rsa\" challenge=\"235ldahlae983dadfar\"%s>",
- "<p><input type=\"reset\"%s></p>",
- "<input type=\"submit\"%s>"
- };
-
- string content = """<html>
- <head>
- <style>
- .fallback::-webkit-slider-thumb,
- .fallback, .fallback::-webkit-file-upload-button {
- -webkit-appearance: none !important;
- }
- .column {
- display:inline-block; vertical-align:top;
- width:25%;
- margin-right:1%;
- }
- </style>
- <title>%s</title>
- </head>
- <body>
- <h1>%s</h1>
- <div class="column">%s</div>
- <div class="column">%s</div>
- <div class="column">%s</div>
- <p><a href="http://example.com" target="wp" onclick="javascript:window.open('http://example.com','wp','width=320, height=240, toolbar=false'); return false;">Popup window</a></p>
- </body>
- </html>""";
-
- string[] widget_options = {"", " disabled", " class=\"fallback\""};
- string[] widgets_formated = {"", "", ""};
-
- for (int i = 0; i < widget_options.length && i < widgets_formated.length; i++) {
- for (int j = 0; j < widgets.length; j++) {
- widgets_formated[i] = widgets_formated[i] + widgets[j].printf (widget_options[i]);
- }
- }
-
- this.load_html (view, content.printf (uri, uri, widgets_formated[0], widgets_formated[1], widgets_formated[2]), uri);
- }
- }
-
- private class Version : Page {
- public override string uri { get; set; }
- private GLib.HashTable<string, Page> about_pages;
-
- public Version (string alias, HashTable<string, Page> about_pages) {
- this.uri = alias;
- this.about_pages = about_pages;
- }
-
- private string list_about_uris () {
- string links = "";
- foreach (unowned string uri in about_pages.get_keys ())
- links = links + "<a href=\"%s\">%s</a> &nbsp;".printf (uri, uri);
- return "<p>%s</p>".printf (links);
- }
-
- public override void get_contents (Midori.View view, string uri) {
- string contents = """<html>
- <head><title>about:version</title></head>
- <body>
- <h1>a<span style="position: absolute; left: -1000px; top: -1000px">lias a=b; echo Copy carefully #</span>bout:version</h1>
- <p>%s</p>
- <img src="res://logo-shade.png" style="position: absolute; right: 15px; bottom: 15px; z-index: -9;">
- <table>
- <tr><td>Command line %s</td></tr>
- %s
- <tr><td>Platform %s %s %s</td></tr>
- <tr><td>Identification %s</td></tr>
- %s
- </table>
- <table>
- %s
- </table>
- %s
- </body>
- </html>""";
-
- GLib.StringBuilder versions = new GLib.StringBuilder ();
- Midori.View.list_versions (versions, true);
-
- string ident;
- unowned string architecture;
- unowned string platform;
- unowned string sys_name = Midori.WebSettings.get_system_name (out architecture, out platform);
- view.settings.get ("user-agent", out ident);
-
- GLib.StringBuilder video_formats = new GLib.StringBuilder ();
- view.list_video_formats (video_formats, true);
-
- GLib.StringBuilder ns_plugins = new GLib.StringBuilder ();
- view.list_plugins (ns_plugins, true);
-
- /* TODO: list active extensions */
-
- this.load_html (view, contents.printf (
- _("Version numbers in brackets show the version used at runtime."),
- Midori.Paths.get_command_line_str (true),
- versions.str,
- platform, sys_name, architecture != null ? architecture : "",
- ident,
- video_formats.str,
- ns_plugins.str,
- this.list_about_uris ()
- ), uri);
- }
- }
-
- private class Private : Page {
- public override string uri { get; set; default = "about:private"; }
- public override void get_contents (Midori.View view, string uri) {
- this.load_html (view, """<html dir="ltr">
- <head>
- <title>%s</title>
- <link rel="stylesheet" type="text/css" href="res://about.css">
- </head>
- <body>
- <img id="logo" src="res://logo-shade.png" />
- <div id="main" style="background-image: url(stock://dialog/gtk-dialog-info);">
- <div id="text">
- <h1>%s</h1>
- <p class="message">%s</p><ul class=" suggestions"><li>%s</li><li>%s</li><li>%s</li></ul>
- <p class="message">%s</p><ul class=" suggestions"><li>%s</li><li>%s</li><li>%s</li><li>%s</li></ul>
- </div><br style="clear: both"></div>
- </body>
- </html>""".printf (
- _("Private Browsing"), _("Private Browsing"),
- _("Midori doesn't store any personal data:"),
- _("No history or web cookies are being saved."),
- _("Extensions are disabled."),
- _("HTML5 storage, local database and application caches are disabled."),
- _("Midori prevents websites from tracking the user:"),
- _("Referrer URLs are stripped down to the hostname."),
- _("DNS prefetching is disabled."),
- _("The language and timezone are not revealed to websites."),
- _("Flash and other Netscape plugins cannot be listed by websites.")
- ), uri);
- }
- }
-
- private class Paths : Page {
- public override string uri { get; set; default = "about:paths"; }
- public override void get_contents (Midori.View view, string uri) {
- string res_dir = Midori.Paths.get_res_filename ("about.css");
- string lib_dir = Midori.Paths.get_lib_path (PACKAGE_NAME);
- this.load_html (view, """<html>
- <body>
- <h1>%s</h1>
- <p>config: <code>%s</code></p>
- <p>res: <code>%s</code></p>
- <p>data: <code>%s/%s</code></p>
- <p>lib: <code>%s</code></p>
- <p>cache: <code>%s</code></p>
- <p>tmp: <code>%s</code></p>
- </body>
- </html>""".printf (
- uri, Midori.Paths.get_config_dir_for_reading (), res_dir,
- Midori.Paths.get_user_data_dir_for_reading (), PACKAGE_NAME,
- lib_dir, Midori.Paths.get_cache_dir_for_reading (), Midori.Paths.get_tmp_dir ()
- ), uri);
- }
- }
-
- private class Dial : Page {
- public override string uri { get; set; default = "about:dial"; }
- public override void get_contents (Midori.View view, string uri) {
- var browser = Midori.Browser.get_for_widget (view);
- Midori.SpeedDial dial;
- browser.get ("speed-dial", out dial);
- if (dial == null)
- return;
- try {
- this.load_html (view, dial.get_html (), uri);
- } catch (Error error) {
- this.load_html (view, error.message, uri);
- }
- }
- }
-
- private class Geolocation : Page {
- public override string uri { get; set; default = "about:geolocation"; }
- public override void get_contents (Midori.View view, string uri) {
- this.load_html (view, """<html>
- <body>
- <a href="http://dev.w3.org/geo/api/spec-source.html" id="method"></a>
- <span id="locationInfo"><noscript>No Geolocation without Javascript</noscript></span>
- <script>
- function displayLocation (position) {
- var geouri = 'geo:' + position.coords.latitude + ',' + position.coords.longitude + ',' + position.coords.altitude + ',u=' + position.coords.accuracy;
- document.getElementById('locationInfo').innerHTML = '<a href="' + geouri + '">' + geouri + '</a><br><code>'
- + ' timestamp: ' + position.timestamp
- + ' latitude: ' + position.coords.latitude
- + ' longitude: ' + position.coords.longitude
- + ' altitude: ' + position.coords.altitude + '<br>'
- + ' accuracy: ' + position.coords.accuracy
- + ' altitudeAccuracy: ' + position.coords.altitudeAccuracy
- + ' heading: ' + position.coords.heading
- + ' speed: ' + position.coords.speed
- + '</code>';
- }
- function handleError (error) {
- var errorMessage = '<b>' + ['Unknown error', 'Permission denied', 'Position failed', 'Timed out'][error.code] + '</b>';
- if (error.code == 3) document.getElementById('locationInfo').innerHTML += (' ' + errorMessage);
- else document.getElementById('locationInfo').innerHTML = errorMessage;
- }
- if (navigator.geolocation) {
- var options = { enableHighAccuracy: true, timeout: 60000, maximumAge: "Infinite" };
- if (navigator.geolocation.watchPosition) {
- document.getElementById('method').innerHTML = '<code>geolocation.watchPosition</code>:';
- navigator.geolocation.watchPosition(displayLocation, handleError, options);
- } else {
- document.getElementById('method').innerHTML = '<code>geolocation.getCurrentPosition</code>:';
- navigator.geolocation.getCurrentPosition(displayLocation, handleError);
- }
- } else
- document.getElementById('locationInfo').innerHTML = 'Geolocation unavailable';
- </script>
- </body>
- </html>""", uri);
- }
- }
-
- private class Redirects : Page {
- public override string uri { get; set; }
- private string property;
- public Redirects (string alias, string property) {
- this.uri = alias;
- this.property = property;
- }
- public override void get_contents (Midori.View view, string uri) {
- string new_uri = uri;
- view.settings.get (property, out new_uri);
- if (uri == "about:search")
- new_uri = Midori.URI.for_search (new_uri, "");
- view.set_uri (new_uri);
- }
- }
-
- private class Manager : Midori.Extension {
- private GLib.HashTable<string, Page>? about_pages;
-
- private void register (Page page) {
- this.about_pages.insert (page.uri, page);
- }
-
- private bool about_content (Midori.View view, string uri) {
- unowned Page? page = this.about_pages.get (uri);
- if (page != null) {
- page.get_contents (view, uri);
- return true;
- }
-
- return false;
- }
-
- private void tab_added (Midori.Browser browser, Midori.View view) {
- view.about_content.connect (this.about_content);
- }
-
- private void tab_removed (Midori.Browser browser, Midori.View view) {
- view.about_content.disconnect (this.about_content);
- }
-
- private void browser_added (Midori.Browser browser) {
- foreach (Midori.View tab in browser.get_tabs ()) {
- this.tab_added (browser, tab);
- }
- browser.add_tab.connect (this.tab_added);
- browser.remove_tab.connect (this.tab_removed);
- }
-
- private void browser_removed (Midori.Browser browser) {
- foreach (Midori.View tab in browser.get_tabs ()) {
- this.tab_removed (browser, tab);
- }
- browser.add_tab.disconnect (this.tab_added);
- browser.remove_tab.disconnect (this.tab_removed);
- }
-
- public void activated (Midori.App app) {
- this.about_pages = new GLib.HashTable<string, Page> (GLib.str_hash, GLib.str_equal);
- register (new Widgets ());
- register (new Version ("about:", about_pages));
- register (new Version ("about:version", about_pages));
- register (new Private ());
- register (new Paths ());
- register (new Geolocation ());
- register (new Redirects ("about:new", "tabhome"));
- register (new Redirects ("about:home", "homepage"));
- register (new Redirects ("about:search", "location-entry-search"));
- register (new Dial ());
-
- foreach (Midori.Browser browser in app.get_browsers ()) {
- this.browser_added (browser);
- }
- app.add_browser.connect (this.browser_added);
- }
-
- public void deactivated () {
- Midori.App app = this.get_app ();
- foreach (Midori.Browser browser in app.get_browsers ()) {
- this.browser_removed (browser);
- }
- app.add_browser.disconnect (this.browser_added);
-
- this.about_pages = null;
- }
-
- internal Manager () {
- GLib.Object (name: "About pages",
- description: "Internal about: handler",
- version: "0.1",
- authors: "André Stösel <andre@stoesel.de>");
-
- this.activate.connect (this.activated);
- this.deactivate.connect (this.deactivated);
- }
- }
-}
-
-public Midori.Extension extension_init () {
- return new About.Manager ();
-}
-
diff --git a/extensions/adblock/config.vala b/extensions/adblock/config.vala
deleted file mode 100644
index 83867a74..00000000
--- a/extensions/adblock/config.vala
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- Copyright (C) 2014 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.
-*/
-
-namespace Adblock {
- public class Config : GLib.Object {
- List<Subscription> subscriptions;
- public string? path { get; private set; }
- KeyFile keyfile;
- bool should_save;
- public bool enabled { get; set; }
-
- public Config (string? path, string? presets) {
- should_save = false;
- subscriptions = new GLib.List<Subscription> ();
- enabled = true;
- this.path = path;
- size = 0;
- load_file (path);
- load_file (presets);
- should_save = true;
- }
-
- void load_file (string? filename) {
- if (filename == null)
- return;
-
- keyfile = new GLib.KeyFile ();
- try {
- keyfile.load_from_file (filename, GLib.KeyFileFlags.NONE);
- string[] filters = keyfile.get_string_list ("settings", "filters");
- foreach (unowned string filter in filters) {
- bool active = false;
- string uri = filter;
- if (filter.has_prefix ("http-/"))
- uri = "http:" + filter.substring (5);
- else if (filter.has_prefix ("file-/"))
- uri = "file:" + filter.substring (5);
- else if (filter.has_prefix ("http-:"))
- uri = "https" + filter.substring (5);
- else
- active = true;
- Subscription sub = new Subscription (uri);
- sub.active = active;
- sub.add_feature (new Updater ());
- add (sub);
- }
- enabled = !keyfile.get_boolean ("settings", "disabled");
- } catch (KeyFileError.KEY_NOT_FOUND key_error) {
- /* It's no error if a key is missing */
- } catch (KeyFileError.GROUP_NOT_FOUND group_error) {
- /* It's no error if a group is missing */
- } catch (FileError.NOENT exist_error) {
- /* It's no error if no config file exists */
- } catch (GLib.Error settings_error) {
- warning ("Error reading settings from %s: %s\n", filename, settings_error.message);
- }
-
- notify["enabled"].connect (enabled_changed);
- }
-
- void enabled_changed (ParamSpec pspec) {
- keyfile.set_boolean ("settings", "disabled", !enabled);
- save ();
- }
-
- void active_changed (Object subscription, ParamSpec pspec) {
- update_filters ();
- }
-
- void update_filters () {
- var filters = new StringBuilder ();
- foreach (unowned Subscription sub in subscriptions) {
- if (!sub.mutable)
- continue;
- if (sub.uri.has_prefix ("http:") && !sub.active)
- filters.append ("http-" + sub.uri.substring (4));
- else if (sub.uri.has_prefix ("file:") && !sub.active)
- filters.append ("file-" + sub.uri.substring (5));
- else if (sub.uri.has_prefix ("https:") && !sub.active)
- filters.append ("http-" + sub.uri.substring (5));
- else
- filters.append (sub.uri);
- filters.append_c (';');
- }
-
- if (filters.str.has_suffix (";"))
- filters.truncate (filters.len - 1);
- string[] list = filters.str.split (";");
- keyfile.set_string_list ("settings", "filters", list);
-
- save ();
- }
-
-
- public void save () {
- try {
- FileUtils.set_contents (path, keyfile.to_data ());
- } catch (Error error) {
- warning ("Failed to save settings: %s", error.message);
- }
- }
-
- /* foreach support */
- public new unowned Subscription? get (uint index) {
- return subscriptions.nth_data (index);
- }
- public uint size { get; private set; }
-
- bool contains (Subscription subscription) {
- foreach (unowned Subscription sub in subscriptions)
- if (sub.uri == subscription.uri)
- return true;
- return false;
- }
-
- public bool add (Subscription sub) {
- if (contains (sub))
- return false;
-
- sub.notify["active"].connect (active_changed);
- subscriptions.append (sub);
- size++;
- if (should_save)
- update_filters ();
- return true;
- }
-
- public void remove (Subscription sub) {
- if (!contains (sub))
- return;
-
- subscriptions.remove (sub);
- sub.notify["active"].disconnect (active_changed);
- update_filters ();
- size--;
- }
- }
-}
diff --git a/extensions/adblock/element.vala b/extensions/adblock/element.vala
deleted file mode 100644
index 0e928131..00000000
--- a/extensions/adblock/element.vala
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- Copyright (C) 2014 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.
-*/
-
-namespace Adblock {
- public class Element : Feature {
- public HashTable<string, string> blockcssprivate;
- bool debug_element;
-
- public Element () {
- base ();
- debug_element = "adblock:element" in (Environment.get_variable ("MIDORI_DEBUG") ?? "");
- }
-
- public override void clear () {
- blockcssprivate = new HashTable<string, string> (str_hash, str_equal);
- }
-
- public string? lookup (string domain) {
- return blockcssprivate.lookup (domain);
- }
-
- public void insert (string domain, string value) {
- if (debug_element)
- stdout.printf ("Element to be blocked %s => %s\n", domain, value);
- blockcssprivate.insert (domain, value);
- }
- }
-}
diff --git a/extensions/adblock/extension.vala b/extensions/adblock/extension.vala
deleted file mode 100644
index 9868f11a..00000000
--- a/extensions/adblock/extension.vala
+++ /dev/null
@@ -1,872 +0,0 @@
-/*
- Copyright (C) 2009-2014 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2009-2012 Alexander Butenko <a.butenka@gmail.com>
-
- 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.
-*/
-
-namespace Adblock {
- public enum Directive {
- ALLOW,
- BLOCK
- }
-
- public enum State {
- ENABLED,
- DISABLED,
- BLOCKED
- }
-
- public string? parse_subscription_uri (string? uri) {
- if (uri == null)
- return null;
-
- if (uri.has_prefix ("http") || uri.has_prefix ("abp") || uri.has_prefix ("file"))
- {
- string sub_uri = uri;
- if (uri.has_prefix ("abp:")) {
- uri.replace ("abp://", "abp:");
- if (uri.has_prefix ("abp:subscribe?location=")) {
- /* abp://subscripe?location=http://example.com&title=foo */
- string[] parts = uri.substring (23, -1).split ("&", 2);
- sub_uri = parts[0];
- }
- }
-
- string decoded_uri = Soup.URI.decode (sub_uri);
- return decoded_uri;
- }
- return null;
- }
-
- public class Extension : Midori.Extension {
- internal Config config;
- internal Subscription custom;
- internal StringBuilder hider_selectors;
- internal StatusIcon status_icon;
- internal SubscriptionManager manager;
- internal bool debug_element;
-#if !USE_CSS_SELECTOR_FOR_BLOCKED_RESOURCES
- internal string? js_hider_function_body;
-#endif
-
-#if HAVE_WEBKIT2
-#if !HAVE_WEBKIT2_3_91
- public Extension.WebExtension (WebKit.WebExtension web_extension) {
- init ();
- web_extension.page_created.connect (page_created);
- }
-
- void page_created (WebKit.WebPage web_page) {
- web_page.send_request.connect (send_request);
- }
-
- bool send_request (WebKit.WebPage web_page, WebKit.URIRequest request, WebKit.URIResponse? redirected_response) {
- return request_handled (request.uri, web_page.uri);
- }
-#endif
-#endif
-
- public Extension () {
- GLib.Object (name: _("Advertisement blocker"),
- description: _("Block advertisements according to a filter list"),
- version: "2.0",
- authors: "Christian Dywan <christian@twotoasts.de>");
- activate.connect (extension_activated);
- deactivate.connect (extension_deactivated);
- open_preferences.connect (extension_preferences);
- }
-
- void extension_preferences () {
- manager.add_subscription (null);
- }
-
- void extension_activated (Midori.App app) {
-#if HAVE_WEBKIT2
- string cache_dir = Environment.get_user_cache_dir ();
- string wk2path = Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "wk2ext");
- Midori.Paths.mkdir_with_parents (wk2path);
- string filename = "libadblock." + GLib.Module.SUFFIX;
- var wk2link = File.new_for_path (wk2path).get_child (filename);
- var library = File.new_for_path (Midori.Paths.get_lib_path (PACKAGE_NAME)).get_child (filename);
- try {
- wk2link.make_symbolic_link (library.get_path ());
- } catch (IOError.EXISTS exist_error) {
- /* It's no error if the file already exists. */
- } catch (Error error) {
- critical ("Failed to create WebKit2 link: %s", error.message);
- }
-#endif
- init ();
- foreach (var browser in app.get_browsers ())
- browser_added (browser);
- app.add_browser.connect (browser_added);
- app.remove_browser.connect (browser_removed);
- }
-
- void extension_deactivated () {
- var app = get_app ();
- foreach (var browser in app.get_browsers ())
- browser_removed (browser);
- app.add_browser.disconnect (browser_added);
- app.remove_browser.disconnect (browser_removed);
- }
-
- void browser_added (Midori.Browser browser) {
- foreach (var tab in browser.get_tabs ())
- tab_added (tab);
- browser.add_tab.connect (tab_added);
- browser.remove_tab.connect (tab_removed);
-
- browser.add_action (status_icon);
- }
-
- void browser_removed (Midori.Browser browser) {
- foreach (var tab in browser.get_tabs ())
- tab_removed (tab);
- browser.add_tab.disconnect (tab_added);
- browser.remove_tab.disconnect (tab_removed);
- browser.remove_action (status_icon);
- }
-
- void tab_added (Midori.View view) {
- view.navigation_requested.connect (navigation_requested);
-#if !HAVE_WEBKIT2
- view.web_view.resource_request_starting.connect (resource_requested);
-#endif
- view.notify["load-status"].connect (load_status_changed);
- view.context_menu.connect (context_menu);
- }
-
- void tab_removed (Midori.View view) {
-#if !HAVE_WEBKIT2
- view.web_view.resource_request_starting.disconnect (resource_requested);
-#endif
- view.navigation_requested.disconnect (navigation_requested);
- view.notify["load-status"].disconnect (load_status_changed);
- view.context_menu.disconnect (context_menu);
- }
-
- void load_status_changed (Object object, ParamSpec pspec) {
- var view = object as Midori.View;
- if (config.enabled) {
- if (view.load_status == Midori.LoadStatus.FINISHED)
- inject_css (view, view.uri);
- }
- }
-
- void context_menu (WebKit.HitTestResult hit_test_result, Midori.ContextAction menu) {
- string label, uri;
- if ((hit_test_result.context & WebKit.HitTestResultContext.IMAGE) != 0) {
- label = _("Bl_ock image");
- uri = hit_test_result.image_uri;
- } else if ((hit_test_result.context & WebKit.HitTestResultContext.LINK) != 0) {
- label = _("Bl_ock link");
- uri = hit_test_result.link_uri;
- } else
- return;
- var action = new Gtk.Action ("BlockElement", label, null, null);
- action.activate.connect ((action) => {
- CustomRulesEditor custom_rules_editor = new CustomRulesEditor (custom);
- custom_rules_editor.set_uri (uri);
- custom_rules_editor.show();
- });
- menu.add (action);
- }
-
-#if !HAVE_WEBKIT2
- void resource_requested (WebKit.WebView web_view, WebKit.WebFrame frame,
- WebKit.WebResource resource, WebKit.NetworkRequest request, WebKit.NetworkResponse? response) {
-
- WebKit.WebFrame main_frame = web_view.get_main_frame ();
-
- WebKit.WebDataSource? ds = main_frame.get_provisional_data_source ();
- WebKit.NetworkRequest? main_frame_request = (ds != null) ? ds.get_request () : null;
- string? main_frame_uri = (main_frame_request != null) ? main_frame_request.uri : null;
-
- bool is_main_frame_request = (frame == main_frame) && (request.uri == main_frame_uri);
- if (!is_main_frame_request && request_handled (request.uri, web_view.uri)) {
- request.set_uri ("about:blank");
- }
- }
-#endif
-
- bool navigation_requested (Midori.Tab tab, string uri) {
- if (uri.has_prefix ("abp:")) {
- string parsed_uri = parse_subscription_uri (uri);
- manager.add_subscription (parsed_uri);
- return true;
- }
- status_icon.set_state (config.enabled ? State.ENABLED : State.DISABLED);
- return false;
- }
-
-#if USE_CSS_SELECTOR_FOR_BLOCKED_RESOURCES
- string? get_hider_css_for_blocked_resources () {
- if (hider_selectors.str == "")
- return null;
-
- /* Hide elements that were blocked, otherwise we will get "broken image" icon */
- var code = new StringBuilder (hider_selectors.str);
- string hider_css;
- if (debug_element)
- hider_css = " { background-color: red; border: 4px solid green; }";
- else
- hider_css = " { visiblility: hidden; width: 0; height: 0; }";
-
- code.truncate (code.len -3);
- code.append (hider_css);
- if (debug_element)
- stdout.printf ("hider css: %s\n", code.str);
- return code.str;
- }
-#else
- string? fetch_js_hider_function_body () {
- string filename = Midori.Paths.get_res_filename ("adblock/element_hider.js");
- File js_file = GLib.File.new_for_path (filename);
- try {
- uint8[] function_body;
- js_file.load_contents (null, out function_body, null);
- return (string)function_body;
- }
- catch (Error error) {
- warning ("Error while loading adblock hider js: %s\n", error.message);
- }
- return null;
- }
-
- string? get_hider_js_for_blocked_resorces () {
- if (hider_selectors.str == "")
- return null;
-
- if (js_hider_function_body == null || js_hider_function_body == "")
- return null;
-
- var js = new StringBuilder ("(function() {");
- js.append (js_hider_function_body);
- js.append ("var uris=new Array ();");
- js.append (hider_selectors.str);
- js.append (" hideElementBySrc (uris);})();");
-
- return js.str;
- }
-#endif
-
- string[]? get_domains_for_uri (string uri) {
- if (uri == null)
- return null;
- string[]? domains = null;
- string domain = Midori.URI.parse_hostname (uri, null);
- string[] subdomains = domain.split (".");
- if (subdomains == null || subdomains.length == 0)
- return null;
- int cnt = subdomains.length - 1;
- var subdomain = new StringBuilder (subdomains[cnt]);
- subdomain.prepend_c ('.');
- cnt--;
- while (cnt >= 0) {
- subdomain.prepend (subdomains[cnt]);
- domains += subdomain.str;
- subdomain.prepend_c ('.');
- cnt--;
- }
- return domains;
- }
-
- string? get_hider_css_rules_for_uri (string page_uri) {
- if (page_uri == null)
- return null;
- string[]? domains = get_domains_for_uri (page_uri);
- if (domains == null)
- return null;
- var code = new StringBuilder ();
- int blockscnt = 0;
- string? style = null;
- foreach (unowned Subscription sub in config) {
- foreach (unowned Feature feature in sub) {
- var element = feature as Element;
- if (element != null) {
- foreach (unowned string subdomain in domains) {
- style = element.lookup (subdomain);
- if (style != null) {
- code.append (style);
- code.append_c (',');
- blockscnt++;
- }
- }
- }
- }
- }
-
- if (blockscnt == 0)
- return null;
- code.truncate (code.len - 1);
-
- string hider_css;
- if (debug_element)
- hider_css = " { background-color: red !important; border: 4px solid green !important; }";
- else
- hider_css = " { display: none !important }";
-
- code.append (hider_css);
- if (debug_element)
- stdout.printf ("css: %s\n", code.str);
-
- return code.str;
- }
-
- void inject_css (Midori.View view, string page_uri) {
- /* Don't block ads on internal pages */
- if (!Midori.URI.is_http (page_uri))
- return;
-
- if ("adblock:element" in (Environment.get_variable ("MIDORI_DEBUG") ?? ""))
- debug_element = true;
- else
- debug_element = status_icon.debug_element_toggled;
-
-#if USE_CSS_SELECTOR_FOR_BLOCKED_RESOURCES
- string? blocked_css = get_hider_css_for_blocked_resources ();
- if (blocked_css != null)
- view.inject_stylesheet (blocked_css);
-#else
- string? blocked_js = get_hider_js_for_blocked_resorces ();
- if (blocked_js != null)
- view.execute_script (blocked_js, null);
-#endif
- string? style = get_hider_css_rules_for_uri (page_uri);
- if (style != null)
- view.inject_stylesheet (style);
- }
-
- internal void init () {
- hider_selectors = new StringBuilder ();
- load_config ();
- manager = new SubscriptionManager (config);
- status_icon = new StatusIcon (config, manager);
- foreach (unowned Subscription sub in config) {
- try {
- sub.parse ();
- } catch (GLib.Error error) {
- warning ("Error parsing %s: %s", sub.uri, error.message);
- }
- }
- config.notify["size"].connect (subscriptions_added_removed);
- manager.description_label.activate_link.connect (open_link);
-#if !USE_CSS_SELECTOR_FOR_BLOCKED_RESOURCES
- js_hider_function_body = fetch_js_hider_function_body ();
-#endif
- }
-
- bool open_link (string uri) {
- var browser = get_app ().browser;
- var view = browser.add_uri (uri);
- browser.tab = view;
- return true;
- }
-
- void subscriptions_added_removed (ParamSpec pspec) {
- hider_selectors = new StringBuilder ();
- }
-
- void load_config () {
-#if HAVE_WEBKIT2
- string config_dir = Path.build_filename (GLib.Environment.get_user_config_dir (), PACKAGE_NAME, "extensions", "libadblock." + GLib.Module.SUFFIX);
- Midori.Paths.mkdir_with_parents (config_dir);
-#else
- string config_dir = Midori.Paths.get_extension_config_dir ("adblock");
-#endif
- string presets = Midori.Paths.get_extension_preset_filename ("adblock", "config");
- string filename = Path.build_filename (config_dir, "config");
- config = new Config (filename, presets);
- string custom_list = GLib.Path.build_filename (config_dir, "custom.list");
- try {
- custom = new Subscription (Filename.to_uri (custom_list, null));
- custom.mutable = false;
- custom.title = _("Custom");
- config.add (custom);
- } catch (Error error) {
- custom = null;
- warning ("Failed to add custom list %s: %s", custom_list, error.message);
- }
- }
-
- public Adblock.Directive get_directive_for_uri (string request_uri, string page_uri) {
- if (!config.enabled)
- return Directive.ALLOW;
-
- /* Always allow the main page */
- if (request_uri == page_uri)
- return Directive.ALLOW;
-
- /* Skip adblock on internal pages */
- if (Midori.URI.is_blank (page_uri))
- return Directive.ALLOW;
-
- /* Skip adblock on favicons and non http schemes */
- if (!Midori.URI.is_http (request_uri) || request_uri.has_suffix ("favicon.ico"))
- return Directive.ALLOW;
-
- Directive? directive = null;
- foreach (unowned Subscription sub in config) {
- directive = sub.get_directive (request_uri, page_uri);
- if (directive != null)
- break;
- }
-
- if (directive == null)
- directive = Directive.ALLOW;
- else if (directive == Directive.BLOCK) {
- status_icon.set_state (State.BLOCKED);
-#if USE_CSS_SELECTOR_FOR_BLOCKED_RESOURCES
- hider_selectors.append ("img[src*=\"%s\"] , iframe[src*=\"%s\"] , ".printf (request_uri, request_uri));
-#else
- hider_selectors.append (" uris.push ('%s');\n".printf (request_uri));
-#endif
- }
- return directive;
- }
-
- internal bool request_handled (string request_uri, string page_uri) {
- return get_directive_for_uri (request_uri, page_uri) == Directive.BLOCK;
- }
- }
-
- static void debug (string format, ...) {
- bool debug_match = "adblock:match" in (Environment.get_variable ("MIDORI_DEBUG") ?? "");
- if (!debug_match)
- return;
-
- var args = va_list ();
- stdout.vprintf (format + "\n", args);
- }
-
- internal static string? fixup_regex (string prefix, string? src) {
- if (src == null)
- return null;
-
- var fixed = new StringBuilder ();
- fixed.append(prefix);
-
- uint i = 0;
- if (src[0] == '*')
- i++;
- uint l = src.length;
- while (i < l) {
- char c = src[i];
- switch (c) {
- case '*':
- fixed.append (".*"); break;
- case '|':
- case '^':
- case '+':
- break;
- case '?':
- case '[':
- case ']':
- case '.':
- case '(':
- case ')':
- fixed.append_printf ("\\%c", c); break;
- default:
- fixed.append_c (c); break;
- }
- i++;
- }
- return fixed.str;
- }
-}
-
-#if HAVE_WEBKIT2
-#if !HAVE_WEBKIT2_3_91
-Adblock.Extension? filter;
-public static void webkit_web_extension_initialize (WebKit.WebExtension web_extension) {
- filter = new Adblock.Extension.WebExtension (web_extension);
-}
-#endif
-#endif
-
-public Midori.Extension extension_init () {
- return new Adblock.Extension ();
-}
-
-static string? tmp_folder = null;
-string get_test_file (string contents) {
- if (tmp_folder == null)
- tmp_folder = Midori.Paths.make_tmp_dir ("adblockXXXXXX");
- string checksum = Checksum.compute_for_string (ChecksumType.MD5, contents);
- string file = Path.build_path (Path.DIR_SEPARATOR_S, tmp_folder, checksum);
- try {
- FileUtils.set_contents (file, contents, -1);
- } catch (Error file_error) {
- GLib.error (file_error.message);
- }
- return file;
-}
-
-struct TestCaseConfig {
- public string content;
- public uint size;
- public bool enabled;
-}
-
-const TestCaseConfig[] configs = {
- { "", 0, true },
- { "[settings]", 0, true },
- { "[settings]\nfilters=foo;", 1, true },
- { "[settings]\nfilters=foo;\ndisabled=true", 1, false }
-};
-
-void test_adblock_config () {
- assert (new Adblock.Config (null, null).size == 0);
-
- foreach (var conf in configs) {
- var config = new Adblock.Config (get_test_file (conf.content), null);
- if (config.size != conf.size)
- error ("Wrong size %s rather than %s:\n%s",
- config.size.to_string (), conf.size.to_string (), conf.content);
- if (config.enabled != conf.enabled)
- error ("Wrongly got enabled=%s rather than %s:\n%s",
- config.enabled.to_string (), conf.enabled.to_string (), conf.content);
- }
-}
-
-struct TestCaseSub {
- public string uri;
- public bool active;
-}
-
-const TestCaseSub[] subs = {
- { "http://foo.com", true },
- { "http://bar.com", false },
- { "https://spam.com", true },
- { "https://eggs.com", false },
- { "file:///bla", true },
- { "file:///blub", false }
-};
-
-void test_adblock_subs () {
- var config = new Adblock.Config (get_test_file ("""
-[settings]
-filters=http://foo.com;http-//bar.com;https://spam.com;http-://eggs.com;file:///bla;file-///blub;http://foo.com;
-"""), null);
-
- assert (config.enabled);
- foreach (var sub in subs) {
- bool found = false;
- foreach (unowned Adblock.Subscription subscription in config) {
- if (subscription.uri == sub.uri) {
- assert (subscription.active == sub.active);
- found = true;
- }
- }
- if (!found)
- error ("%s not found", sub.uri);
- }
-
- /* 6 unique URLs, 1 duplicate */
- assert (config.size == 6);
- /* Duplicates aren't added again either */
- assert (!config.add (new Adblock.Subscription ("https://spam.com")));
-
- /* Saving the config and loading it should give back identical results */
- config.save ();
- var copy = new Adblock.Config (config.path, null);
- assert (copy.size == config.size);
- assert (copy.enabled == config.enabled);
- for (int i = 0; i < config.size; i++) {
- assert (copy[i].uri == config[i].uri);
- assert (copy[i].active == config[i].active);
- }
- /* Enabled status should be saved and loaded */
- config.enabled = false;
- copy = new Adblock.Config (config.path, null);
- assert (copy.enabled == config.enabled);
- /* Flipping individual active values should be retained after saving */
- foreach (unowned Adblock.Subscription sub in config)
- sub.active = !sub.active;
- copy = new Adblock.Config (config.path, null);
- for (uint i = 0; i < config.size; i++) {
- if (config[i].active != copy[i].active) {
- string contents;
- try {
- FileUtils.get_contents (config.path, out contents, null);
- } catch (Error file_error) {
- error (file_error.message);
- }
- error ("%s is %s but should be %s:\n%s",
- copy[i].uri, copy[i].active ? "active" : "disabled", config[i].active ? "active" : "disabled", contents);
- }
- }
-
- /* Adding and removing works, changes size */
- var s = new Adblock.Subscription ("http://en.de");
- assert (config.add (s));
- assert (config.size == 7);
- config.remove (s);
- assert (config.size == 6);
- /* If it was removed before we should be able to add it again */
- assert (config.add (s));
- assert (config.size == 7);
-}
-
-void test_adblock_init () {
- /* No config */
- var extension = new Adblock.Extension ();
- extension.init ();
- assert (extension.config.enabled);
- /* Defaults plus custom */
- if (extension.config.size != 3)
- error ("Expected 3 initial subs, got %s".printf (
- extension.config.size.to_string ()));
- assert (extension.status_icon.state == Adblock.State.ENABLED);
-
- /* Add new subscription */
- string path = Midori.Paths.get_res_filename ("adblock.list");
- string uri;
- try {
- uri = Filename.to_uri (path, null);
- } catch (Error error) {
- GLib.error (error.message);
- }
- var sub = new Adblock.Subscription (uri);
- extension.config.add (sub);
- assert (extension.status_icon.state == Adblock.State.ENABLED);
- assert (extension.config.size == 4);
- try {
- sub.parse ();
- } catch (GLib.Error error) {
- GLib.error (error.message);
- }
- /* The page itself never hits */
- assert (!extension.request_handled ("https://ads.bogus.name/blub", "https://ads.bogus.name/blub"));
- /* Favicons don't either */
- assert (!extension.request_handled ("https://foo.com", "https://ads.bogus.name/blub/favicon.ico"));
- assert (extension.status_icon.state == Adblock.State.ENABLED);
- /* Some sanity checks to be sure there's no earlier problem */
- assert (sub.title == "Exercise");
- assert (sub.get_directive ("https://ads.bogus.name/blub", "") == Adblock.Directive.BLOCK);
- /* A rule hit should add to the cache */
- assert (extension.request_handled ("https://ads.bogus.name/blub", "https://foo.com"));
- assert (extension.status_icon.state == Adblock.State.BLOCKED);
- assert (extension.hider_selectors.str != "");
- /* Disabled means no request should be handled */
- extension.config.enabled = false;
- assert (!extension.request_handled ("https://ads.bogus.name/blub", "https://foo.com"));
- // FIXME: assert (extension.status_icon.state == Adblock.State.DISABLED);
- /* Removing a subscription should clear the cached CSS */
- extension.config.remove (sub);
- assert (extension.hider_selectors.str == "");
- assert (extension.config.size == 3);
- /* Now let's add a custom rule */
- extension.config.enabled = true;
- extension.custom.add_rule ("/adpage.");
- assert (extension.custom.get_directive ("http://www.engadget.com/_uac/adpage.html", "http://foo.com") == Adblock.Directive.BLOCK);
- assert (extension.request_handled ("http://www.engadget.com/_uac/adpage.html", "http://foo.com"));
- assert (extension.status_icon.state == Adblock.State.BLOCKED);
- /* Second attempt, from cache, same result */
- assert (extension.custom.get_directive ("http://www.engadget.com/_uac/adpage.html", "http://foo.com") == Adblock.Directive.BLOCK);
- assert (extension.request_handled ("http://www.engadget.com/_uac/adpage.html", "http://foo.com"));
- /* Another custom rule */
- extension.custom.add_rule ("/images/*.png");
- assert (extension.custom.get_directive ("http://alpha.beta.com/images/yota.png", "https://foo.com") == Adblock.Directive.BLOCK);
- assert (extension.request_handled ("http://alpha.beta.com/images/yota.png", "https://foo.com"));
- /* Second attempt, from cache, same result */
- assert (extension.request_handled ("http://alpha.beta.com/images/yota.png", "https://foo.com"));
- /* Similar uri but .jpg should pass */
- assert (!extension.request_handled ("http://alpha.beta.com/images/yota.jpg", "https://foo.com"));
- assert (extension.custom.get_directive ("http://alpha.beta.com/images/yota.jpg", "https://foo.com") != Adblock.Directive.BLOCK);
- /* Add whitelist rule */
- extension.custom.add_rule ("@@http://alpha.beta.com/images/drop*bear.png");
- assert (!extension.request_handled ("http://alpha.beta.com/images/drop-bear.png", "https://foo.com"));
- assert (!extension.request_handled ("http://alpha.beta.com/images/dropzone_bear.png", "https://foo.com"));
- assert (extension.custom.get_directive ("http://alpha.beta.com/images/drop-bear.png", "https://foo.com") != Adblock.Directive.BLOCK);
- /* Doesn't match whitelist, matches *.png rule, should be blocked */
- assert (extension.request_handled ("http://alpha.beta.com/images/bear.png", "https://foo.com"));
- assert (extension.custom.get_directive ("http://alpha.beta.com/images/bear.png", "https://foo.com") == Adblock.Directive.BLOCK);
- }
-
-struct TestCaseLine {
- public string line;
- public string fixed;
-}
-
-const TestCaseLine[] lines = {
- { null, null },
- { "!", "!" },
- { "@@", "@@" },
- { "##", "##" },
- { "[", "\\[" },
- { "+advert/", "advert/" },
- { "*foo", "foo" },
- { "f*oo", "f.*oo" },
- { "?foo", "\\?foo" },
- { "foo?", "foo\\?" },
- { ".*foo/bar", "..*foo/bar" },
- { ".*.*.*.info/popup", "\\..*\\..*\\..*\\.info/popup" },
- { "http://bla.blub/*", "http://bla.blub/.*" },
- { "bag?r[]=*cpa", "bag\\?r\\[\\]=.*cpa" },
- { "(facebookLike,", "\\(facebookLike," }
-};
-
-void test_adblock_fixup_regexp () {
- foreach (var line in lines) {
- Katze.assert_str_equal (line.line, Adblock.fixup_regex ("", line.line), line.fixed);
- }
-}
-
-struct TestCasePattern {
- public string uri;
- public Adblock.Directive directive;
-}
-
-const TestCasePattern[] patterns = {
- { "http://www.engadget.com/_uac/adpage.html", Adblock.Directive.BLOCK },
- { "http://test.dom/test?var=1", Adblock.Directive.BLOCK },
- { "http://ads.foo.bar/teddy", Adblock.Directive.BLOCK },
- { "http://ads.fuu.bar/teddy", Adblock.Directive.ALLOW },
- { "https://ads.bogus.name/blub", Adblock.Directive.BLOCK },
- // FIXME { "http://ads.bla.blub/kitty", Adblock.Directive.BLOCK },
- // FIXME { "http://ads.blub.boing/soda", Adblock.Directive.BLOCK },
- { "http://ads.foo.boing/beer", Adblock.Directive.ALLOW },
- { "https://testsub.engine.adct.ru/test?id=1", Adblock.Directive.BLOCK },
- { "http://test.ltd/addyn/test/test?var=adtech;&var2=1", Adblock.Directive.BLOCK },
- { "http://add.doubleclick.net/pfadx/aaaa.mtvi", Adblock.Directive.BLOCK },
- { "http://add.doubleclick.net/pfadx/aaaa.mtv", Adblock.Directive.ALLOW },
- { "http://objects.tremormedia.com/embed/xml/list.xml?r=", Adblock.Directive.BLOCK },
- { "http://qq.videostrip.c/sub/admatcherclient.php", Adblock.Directive.ALLOW },
- { "http://qq.videostrip.com/sub/admatcherclient.php", Adblock.Directive.BLOCK },
- { "http://qq.videostrip.com/sub/admatcherclient.php", Adblock.Directive.BLOCK },
- { "http://br.gcl.ru/cgi-bin/br/test", Adblock.Directive.BLOCK },
- { "https://bugs.webkit.org/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&keywords_type=allwords&keywords=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=substring&email1=&emailassigned_to2=1&emailreporter2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&query_based_on=gtkport&field0-0-0=keywords&type0-0-0=anywordssubstr&value0-0-0=Gtk%20Cairo%20soup&field0-0-1=short_desc&type0-0-1=anywordssubstr&value0-0-1=Gtk%20Cairo%20soup%20autoconf%20automake%20autotool&field0-0-2=component&type0-0-2=equals&value0-0-2=WebKit%20Gtk", Adblock.Directive.ALLOW },
- { "http://www.engadget.com/2009/09/24/google-hits-android-rom-modder-with-a-cease-and-desist-letter/", Adblock.Directive.ALLOW },
- { "http://karibik-invest.com/es/bienes_raices/search.php?sqT=19&sqN=&sqMp=&sqL=0&qR=1&sqMb=&searchMode=1&action=B%FAsqueda", Adblock.Directive.ALLOW },
- { "http://google.com", Adblock.Directive.ALLOW }
-};
-
-string pretty_directive (Adblock.Directive? directive) {
- if (directive == null)
- return "none";
- return directive.to_string ();
-}
-
-void test_adblock_pattern () {
- string path = Midori.Paths.get_res_filename ("adblock.list");
- string uri;
- try {
- uri = Filename.to_uri (path, null);
- } catch (Error error) {
- GLib.error (error.message);
- }
- var sub = new Adblock.Subscription (uri);
- try {
- sub.parse ();
- } catch (Error error) {
- GLib.error (error.message);
- }
- foreach (var pattern in patterns) {
- Adblock.Directive? directive = sub.get_directive (pattern.uri, "");
- if (directive == null)
- directive = Adblock.Directive.ALLOW;
- if (directive != pattern.directive) {
- error ("%s expected for %s but got %s",
- pretty_directive (pattern.directive), pattern.uri, pretty_directive (directive));
- }
- }
-}
-
-string pretty_date (DateTime? date) {
- if (date == null)
- return "N/A";
- return date.to_string ();
-}
-
-struct TestUpdateExample {
- public string content;
- public bool result;
- public bool valid;
-}
-
- const TestUpdateExample[] examples = {
- { "[Adblock Plus 1.1]\n! Last modified: 05 Sep 2010 11:00 UTC\n! This list expires after 48 hours\n", true, true },
- { "[Adblock Plus 1.1]\n! Last modified: 05.09.2010 11:00 UTC\n! Expires: 2 days (update frequency)\n", true, true },
- { "[Adblock Plus 1.1]\n! Updated: 05 Nov 2024 11:00 UTC\n! Expires: 5 days (update frequency)\n", false, true },
- { "[Adblock]\n! dutchblock v3\n! This list expires after 14 days\n|http://b*.mookie1.com/\n", false, true },
- { "[Adblock Plus 2.0]\n! Last modification time (GMT): 2012.11.05 13:33\n! Expires: 5 days (update frequency)\n", true, true },
- { "[Adblock Plus 2.0]\n! Last modification time (GMT): 2012.11.05 13:33\n", true, true },
- { "[Adblock]\n ! dummy, i dont have any dates\n", false, true },
- /* non-standard update time metadata as found in http://abp.mozilla-hispano.org/nauscopio/filtros.txt */
- { "[Adblock Plus 2.0]\n ! Last modified: Oct 26, 2013 18:00 UTC\n ! This list expires after 5 days\n! Last modified by maty: 12Oct2013\n! \n", false, true },
- { "\n", false, false }
- };
-
-void test_subscription_update () {
- string uri;
- FileIOStream iostream;
- File file;
- try {
- file = File.new_tmp ("midori_adblock_update_test_XXXXXX", out iostream);
- uri = file.get_uri ();
- } catch (Error error) {
- GLib.error (error.message);
- }
- var sub = new Adblock.Subscription (uri);
- var updater = new Adblock.Updater ();
- sub.add_feature (updater);
-
- foreach (var example in examples) {
- try {
- file.replace_contents (example.content.data, null, false, FileCreateFlags.NONE, null);
- sub.clear ();
- sub.parse ();
- } catch (Error error) {
- GLib.error (error.message);
- }
- if (example.valid != sub.valid)
- error ("Subscription expected to be %svalid but %svalid:\n%s",
- example.valid ? "" : "in", sub.valid ? "" : "in", example.content);
- if (example.result != updater.needs_update)
- error ("Update%s expected for:\n%s\nLast Updated: %s\nExpires: %s",
- example.result ? "" : " not", example.content,
- pretty_date (updater.last_updated), pretty_date (updater.expires));
- }
-}
-
-struct TestSubUri {
- public string? src_uri;
- public string? dst_uri;
-}
-
-const TestSubUri[] suburis =
-{
- { null, null },
- { "not-a-link", null },
- { "http://some.uri", "http://some.uri" },
- { "abp:subscribe?location=https%3A%2F%2Feasylist-downloads.adblockplus.org%2Fabpindo%2Beasylist.txt&title=ABPindo%2BEasyList", "https://easylist-downloads.adblockplus.org/abpindo+easylist.txt" }
-};
-
-void test_subscription_uri_parsing () {
- string? parsed_uri;
- foreach (var example in suburis) {
- parsed_uri = Adblock.parse_subscription_uri (example.src_uri);
- if (parsed_uri != example.dst_uri)
- error ("Subscription expected to be %svalid but %svalid:\n%s",
- example.dst_uri, parsed_uri, example.src_uri);
- }
-}
-
-public void extension_test () {
- Test.add_func ("/extensions/adblock2/config", test_adblock_config);
- Test.add_func ("/extensions/adblock2/subs", test_adblock_subs);
- Test.add_func ("/extensions/adblock2/init", test_adblock_init);
- Test.add_func ("/extensions/adblock2/parse", test_adblock_fixup_regexp);
- Test.add_func ("/extensions/adblock2/pattern", test_adblock_pattern);
- Test.add_func ("/extensions/adblock2/update", test_subscription_update);
- Test.add_func ("/extensions/adblock2/subsparse", test_subscription_uri_parsing);
-}
-
diff --git a/extensions/adblock/filter.vala b/extensions/adblock/filter.vala
deleted file mode 100644
index 5e3ba34c..00000000
--- a/extensions/adblock/filter.vala
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- Copyright (C) 2009-2014 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2009-2012 Alexander Butenko <a.butenka@gmail.com>
-
- 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.
-*/
-
-namespace Adblock {
- public abstract class Filter : Feature {
- Options optslist;
- protected HashTable<string, Regex?> rules;
-
- public virtual void insert (string sig, Regex regex) {
- rules.insert (sig, regex);
- }
-
- public virtual Regex? lookup (string sig) {
- return rules.lookup (sig);
- }
-
- public virtual uint size () {
- return rules.size ();
- }
-
- protected Filter (Options options) {
- optslist = options;
- clear ();
- }
-
- public override void clear () {
- rules = new HashTable<string, Regex> (str_hash, str_equal);
- }
-
- protected bool check_rule (Regex regex, string pattern, string request_uri, string page_uri) throws Error {
- if (!regex.match_full (request_uri))
- return false;
-
- var opts = optslist.lookup (pattern);
- if (opts != null && Regex.match_simple (",third-party", opts,
- RegexCompileFlags.CASELESS, RegexMatchFlags.NOTEMPTY))
- if (page_uri != null && regex.match_full (page_uri))
- return false;
- debug ("blocked by pattern regexp=%s -- %s", regex.get_pattern (), request_uri);
- return true;
- }
- }
-}
diff --git a/extensions/adblock/keys.vala b/extensions/adblock/keys.vala
deleted file mode 100644
index 5ed987fb..00000000
--- a/extensions/adblock/keys.vala
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Copyright (C) 2009-2014 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2009-2012 Alexander Butenko <a.butenka@gmail.com>
-
- 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.
-*/
-
-namespace Adblock {
- public class Keys : Filter {
- List<Regex> blacklist;
-
- public Keys (Options options) {
- base (options);
- }
-
- public override void clear () {
- base.clear ();
- blacklist = new List<Regex> ();
- }
-
- public override Directive? match (string request_uri, string page_uri) throws Error {
- string? uri = fixup_regex ("", request_uri);
- if (uri == null)
- return null;
-
- int signature_size = 8;
- int pos, l = uri.length;
- for (pos = l - signature_size; pos >= 0; pos--) {
- string signature = uri.offset (pos).ndup (signature_size);
- var regex = rules.lookup (signature);
- if (regex == null || blacklist.find (regex) != null)
- continue;
-
- if (check_rule (regex, uri, request_uri, page_uri))
- return Directive.BLOCK;
- blacklist.prepend (regex);
- }
-
- return null;
- }
- }
-}
diff --git a/extensions/adblock/options.vala b/extensions/adblock/options.vala
deleted file mode 100644
index cc82e85b..00000000
--- a/extensions/adblock/options.vala
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- Copyright (C) 2014 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.
-*/
-
-namespace Adblock {
- public class Options : GLib.Object {
- HashTable<string, string?> optslist;
-
- public Options () {
- clear ();
- }
-
- public void insert (string sig, string? opts) {
- optslist.insert (sig, opts);
- }
-
- public string? lookup (string sig) {
- return optslist.lookup (sig);
- }
-
- public void clear () {
- optslist = new HashTable<string, string?> (str_hash, str_equal);
- }
- }
-}
diff --git a/extensions/adblock/pattern.vala b/extensions/adblock/pattern.vala
deleted file mode 100644
index b95943aa..00000000
--- a/extensions/adblock/pattern.vala
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- Copyright (C) 2009-2014 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2009-2012 Alexander Butenko <a.butenka@gmail.com>
-
- 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.
-*/
-
-namespace Adblock {
- public class Pattern : Filter {
- public Pattern (Options options) {
- base (options);
- }
-
- public override Directive? match (string request_uri, string page_uri) throws Error {
- foreach (unowned string patt in rules.get_keys ())
- if (check_rule (rules.lookup (patt), patt, request_uri, page_uri))
- return Directive.BLOCK;
- return null;
- }
- }
-}
diff --git a/extensions/adblock/subscriptions.vala b/extensions/adblock/subscriptions.vala
deleted file mode 100644
index 6396217f..00000000
--- a/extensions/adblock/subscriptions.vala
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- Copyright (C) 2009-2014 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2009-2012 Alexander Butenko <a.butenka@gmail.com>
-
- 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.
-*/
-
-namespace Adblock {
- public abstract class Feature : GLib.Object {
- public virtual bool header (string key, string value) {
- return false;
- }
- public virtual bool parsed (File file) {
- return true;
- }
- public virtual Directive? match (string request_uri, string page_uri) throws Error {
- return null;
- }
- public virtual void clear () {
- }
- }
-
- public class Subscription : GLib.Object {
- public string? path;
- bool debug_parse;
- public string uri { get; set; default = null; }
- public string title { get; set; default = null; }
- public bool active { get; set; default = true; }
- public bool mutable { get; set; default = true; }
- public bool valid { get; private set; default = true; }
- HashTable<string, Directive?> cache;
- List<Feature> features;
- public Pattern pattern;
- public Keys keys;
- public Options optslist;
- public Whitelist whitelist;
- public Element element;
-#if !HAVE_WEBKIT2
- WebKit.Download? download;
-#endif
-
- public Subscription (string uri) {
- debug_parse = "adblock:parse" in (Environment.get_variable ("MIDORI_DEBUG") ?? "");
-
- this.uri = uri;
-
- this.optslist = new Options ();
- this.whitelist = new Whitelist (optslist);
- add_feature (this.whitelist);
- this.keys = new Keys (optslist);
- add_feature (this.keys);
- this.pattern = new Pattern (optslist);
- add_feature (this.pattern);
- this.element = new Element ();
- add_feature (this.element);
- clear ();
- }
-
- public void add_feature (Feature feature) {
- features.append (feature);
- size++;
- }
-
- /* foreach support */
- public new unowned Feature? get (uint index) {
- return features.nth_data (index);
- }
- public uint size { get; private set; }
-
- public void clear () {
- cache = new HashTable<string, Directive?> (str_hash, str_equal);
- foreach (unowned Feature feature in features)
- feature.clear ();
- optslist.clear ();
- }
-
- internal void parse_line (string? line) throws Error {
- if (line.has_prefix ("@@")) {
- if (line.contains("$") && line.contains ("domain"))
- return;
- if (line.has_prefix ("@@||"))
- add_url_pattern ("^", "whitelist", line.offset (4));
- else if (line.has_prefix ("@@|"))
- add_url_pattern ("^", "whitelist", line.offset (3));
- else
- add_url_pattern ("", "whitelist", line.offset (2));
- return;
- }
- /* TODO: [include] [exclude] */
- if (line[0] == '[')
- return;
-
- /* CSS block hider */
- if (line.has_prefix ("##")) {
- /* TODO */
- return;
- }
- if (line[0] == '#')
- return;
-
- /* TODO: CSS hider whitelist */
- if ("#@#" in line)
- return;
-
- /* Per domain CSS hider rule */
- if ("##" in line) {
- frame_add_private (line, "##");
- return;
- }
- if ("#" in line) {
- frame_add_private (line, "#");
- return;
- }
-
- /* URL blocker rule */
- if (line.has_prefix ("|")) {
- /* TODO: handle options and domains excludes */
- if (line.contains("$"))
- return;
-
- if (line.has_prefix ("||"))
- add_url_pattern ("", "fulluri", line.offset (2));
- else
- add_url_pattern ("^", "fulluri", line.offset (1));
- return /* add_url_pattern */;
- }
-
- add_url_pattern ("", "uri", line);
- return /* add_url_pattern */;
- }
-
- void frame_add_private (string line, string sep) {
- string[] data = line.split (sep, 2);
- if (!(data[1] != null && data[1] != "")
- || data[1].chr (-1, '\'') != null
- || (data[1].chr (-1, ':') != null
- && !Regex.match_simple (".*\\[.*:.*\\].*", data[1],
- RegexCompileFlags.CASELESS, RegexMatchFlags.NOTEMPTY))) {
- return;
- }
-
- if (data[0].chr (-1, ',') != null) {
- string[] domains = data[0].split (",", -1);
-
- foreach (unowned string domain in domains) {
- /* Ignore Firefox-specific option */
- if (domain == "~pregecko2")
- continue;
- string stripped = domain.strip ();
- /* FIXME: ~ should negate match */
- if (stripped[0] == '~')
- stripped = stripped.substring (1, -1);
- update_css_hash (stripped, data[1]);
- }
- }
- else {
- update_css_hash (data[0], data[1]);
- }
- }
-
- bool css_element_seems_valid (string element) {
- bool is_valid = true;
- string[] valid_elements = { "::after", "::before", "a", "abbr", "address", "article", "aside",
- "b", "blockquote", "caption", "center", "cite", "code", "div", "dl", "dt", "dd", "em",
- "feed", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6",
- "header", "hgroup", "i", "iframe", "iframe html *", "img", "kbd", "label", "legend", "li",
- "m", "main", "marquee", "menu", "nav", "ol", "option", "p", "pre", "q", "samp", "section",
- "small", "span", "strong", "summary", "table", "tr", "tbody", "td", "th", "thead", "tt", "ul" };
-
- if (!element.has_prefix (".") && !element.has_prefix ("#")
- && !(element.split("[")[0] in valid_elements))
- is_valid = false;
-
-
- bool debug_selectors = "adblock:css" in (Environment.get_variable ("MIDORI_DEBUG") ?? "");
- if (debug_selectors)
- stdout.printf ("Adblock '%s' %s: %s\n",
- this.title, is_valid ? "selector" : "INVALID?", element);
-
- return is_valid;
- }
-
- void update_css_hash (string domain, string value) {
- if (css_element_seems_valid (value)) {
- string? olddata = element.lookup (domain);
- if (olddata != null) {
- string newdata = olddata + " , " + value;
- element.insert (domain, newdata);
- } else {
- element.insert (domain, value);
- }
- }
- }
-
- void add_url_pattern (string prefix, string type, string line) throws Error {
- string[]? data = line.split ("$", 2);
- if (data == null || data[0] == null)
- return;
-
- string patt, opts;
- patt = data[0];
- opts = type;
-
- if (data[1] != null)
- opts = type + "," + data[1];
-
- if (Regex.match_simple ("subdocument", opts,
- RegexCompileFlags.CASELESS, RegexMatchFlags.NOTEMPTY))
- return;
-
- string format_patt = fixup_regex (prefix, patt);
- if (debug_parse)
- stdout.printf ("got: %s opts %s\n", format_patt, opts);
- compile_regexp (format_patt, opts);
- /* return format_patt */
- }
-
- bool compile_regexp (string? patt, string opts) throws Error {
- if (patt == null)
- return false;
- try {
- var regex = new Regex (patt, RegexCompileFlags.OPTIMIZE, RegexMatchFlags.NOTEMPTY);
- /* is pattern is already a regex? */
- if (Regex.match_simple ("^/.*[\\^\\$\\*].*/$", patt,
- RegexCompileFlags.UNGREEDY, RegexMatchFlags.NOTEMPTY)
- || (opts != null && opts.contains ("whitelist"))) {
- if (debug_parse)
- stdout.printf ("patt: %s\n", patt);
- if (opts.contains ("whitelist"))
- this.whitelist.insert (patt, regex);
- else
- this.pattern.insert (patt, regex);
- this.optslist.insert (patt, opts);
- return false;
- } else { /* nope, no regex */
- int pos = 0, len;
- int signature_size = 8;
- string sig;
- len = patt.length;
-
- /* chop up pattern into substrings for faster matching */
- for (pos = len - signature_size; pos>=0; pos--)
- {
- sig = patt.offset (pos).ndup (signature_size);
- /* we don't have a * nor \\, does not look like regex, save chunk as "key" */
- if (!Regex.match_simple ("[\\*]", sig, RegexCompileFlags.UNGREEDY, RegexMatchFlags.NOTEMPTY) && keys.lookup (sig) == null) {
- this.keys.insert (sig, regex);
- this.optslist.insert (sig, opts);
- } else {
- /* starts with * or \\ - save as regex */
- if ((sig.has_prefix ("*") || sig.has_prefix("\\")) && this.pattern.lookup (sig) == null) {
- this.pattern.insert (sig, regex);
- this.optslist.insert (sig, opts);
- }
- }
- }
- }
- return false;
- }
- catch (Error error) {
- warning ("Adblock compile regexp: %s", error.message);
- return true;
- }
- }
-
- public void parse_header (string header) throws Error {
- /* Headers come in two forms
- ! Foo: Bar
- ! Some freeform text
- */
- string key = header;
- string value = "";
- if (header.contains (":")) {
- string[] parts = header.split (":", 2);
- if (parts[0] != null && parts[0] != ""
- && parts[1] != null && parts[1] != "") {
- key = parts[0].substring (2, -1);
- value = parts[1].substring (1, -1);
- }
- }
- debug ("Header '%s' says '%s'", key, value);
- if (key == "Title")
- title = value;
- foreach (unowned Feature feature in features) {
- if (feature.header (key, value))
- break;
- }
- }
-
-#if !HAVE_WEBKIT2
- void download_status (ParamSpec pspec) {
- if (download.get_status () != WebKit.DownloadStatus.FINISHED)
- return;
-
- download = null;
- try {
- parse ();
- } catch (Error error) {
- warning ("Error parsing %s: %s", uri, error.message);
- }
- }
-#endif
-
- public void parse () throws Error
- {
- if (!active)
- return;
-
- debug ("Parsing %s (%s)", uri, path);
-
- clear ();
-
- if (uri.has_prefix ("file://"))
- path = Filename.from_uri (uri);
- else {
- string cache_dir = GLib.Path.build_filename (GLib.Environment.get_user_cache_dir (), PACKAGE_NAME, "adblock");
- Midori.Paths.mkdir_with_parents (cache_dir);
- string filename = Checksum.compute_for_string (ChecksumType.MD5, this.uri, -1);
- path = GLib.Path.build_filename (cache_dir, filename);
- }
-
- File filter_file = File.new_for_path (path);
- DataInputStream stream;
- try {
- stream = new DataInputStream (filter_file.read ());
- } catch (IOError.NOT_FOUND exist_error) {
-#if HAVE_WEBKIT2
- /* TODO */
-#else
- /* Don't bother trying to download local files */
- if (!uri.has_prefix ("file://")) {
- if (download != null)
- return;
-
- string destination_uri = Filename.to_uri (path, null);
- debug ("Fetching %s to %s now", uri, destination_uri);
- download = new WebKit.Download (new WebKit.NetworkRequest (uri));
- if (!Midori.Download.has_enough_space (download, destination_uri, true))
- throw new FileError.EXIST ("Can't download to \"%s\"", path);
- download.destination_uri = destination_uri;
- download.notify["status"].connect (download_status);
- download.start ();
- }
-#endif
- return;
- }
-
- valid = false;
- string? line;
- while ((line = stream.read_line (null)) != null) {
- if (line == null)
- continue;
- string chomped = line.chomp ();
- if (chomped == "")
- continue;
- if (line[0] == '!')
- parse_header (chomped);
- else
- parse_line (chomped);
- /* The file isn't completely empty */
- valid = true;
- }
-
- foreach (unowned Feature feature in features) {
- if (!feature.parsed (filter_file))
- valid = false;
- }
- }
-
- public Directive? get_directive (string request_uri, string page_uri) {
- try {
- Directive? directive = cache.lookup (request_uri);
- if (directive != null)
- return directive;
- foreach (unowned Feature feature in features) {
- directive = feature.match (request_uri, page_uri);
- if (directive != null) {
- debug ("%s gave %s for %s (%s)\n",
- feature.get_type ().name (), directive.to_string (), request_uri, page_uri);
- return directive;
- }
- }
- } catch (Error error) {
- warning ("Adblock match error: %s\n", error.message);
- }
- return null;
- }
-
- public void add_rule (string rule) {
- try {
- var file = File.new_for_uri (uri);
- file.append_to (FileCreateFlags.NONE).write (("%s\n".printf (rule)).data);
- parse ();
- } catch (Error error) {
- warning ("Failed to add custom rule: %s", error.message);
- }
- }
- }
-}
diff --git a/extensions/adblock/updater.vala b/extensions/adblock/updater.vala
deleted file mode 100644
index 9a1b68f8..00000000
--- a/extensions/adblock/updater.vala
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- Copyright (C) 2014 Paweł Forysiuk <tuxator@o2.pl>
- Copyright (C) 2014 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.
-*/
-
-namespace Adblock {
- public class Updater : Feature {
- string expires_meta;
- string last_mod_meta;
- public DateTime last_updated { get; set; }
- public DateTime expires { get; set; }
- public bool needs_update { get; set; }
-
- public Updater () {
- }
-
- public override void clear () {
- expires_meta = null;
- last_mod_meta = null;
- last_updated = null;
- expires = null;
- needs_update = false;
- }
-
- public override bool header (string key, string value) {
- if (key.has_prefix ("Last mod") || key == "Updated") {
- last_mod_meta = value;
- return true;
- } else if (key == "Expires") {
- /* ! Expires: 5 days (update frequency) */
- expires_meta = value;
- return true;
- } else if (key.has_prefix ("! This list expires after")) {
- /* ! This list expires after 14 days */
- expires_meta = key.substring (26, -1);
- return true;
- }
- return false;
- }
-
- public override bool parsed (File file) {
- process_dates (file);
- /* It's not an error to have no update headers, we go for defaults */
- return true;
- }
-
- int get_month_from_string (string? month) {
- if (month == null)
- return 0;
-
- string[] months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
- for (int i = 0; i<= months.length; i++)
- {
- if (month.has_prefix (months[i]))
- return i+1;
- }
- return 0;
- }
-
- void process_dates (File file) {
- DateTime now = new DateTime.now_local ();
- last_updated = null;
- expires = null;
-
- /* We have "last modification" metadata */
- if (last_mod_meta != null && (last_mod_meta.contains (" ") && last_mod_meta[0].isdigit () == true)) {
- int h = 0, min = 0, d, m, y;
- /* Date in a form of: 20.08.2012 12:34 */
- if (last_mod_meta.contains (".") || last_mod_meta.contains("-")) {
- string[] parts = last_mod_meta.split (" ", 2);
- string[] date_parts;
- string split_char = " ";
-
- /* contains time part ? */
- if (parts[1] != "" && parts[1].contains (":")) {
- string[] time_parts = parts[1].split (":", 2);
- h = int.parse(time_parts[0]);
- min = int.parse(time_parts[1]);
- }
-
- /* check if dot or dash was used as a delimiter */
- if (parts[0].contains ("."))
- split_char = ".";
- else if (parts[0].contains ("-"))
- split_char = "-";
-
- date_parts = parts[0].split (split_char, 3);
- m = int.parse(date_parts[1]);
- if (date_parts[2].length == 4) {
- y = int.parse(date_parts[2]);
- d = int.parse(date_parts[0]);
- } else {
- y = int.parse(date_parts[0]);
- d = int.parse(date_parts[2]);
- }
- last_updated = new DateTime.local (y, m, d, h, min, 0.0);
- } else { /* Date in a form of: 20 Mar 2012 12:34 */
- string[] parts = last_mod_meta.split (" ", 4);
- if (parts.length >= 3) {
- /* contains time part ? */
- if (parts.length >= 4 && parts[3].contains (":")) {
- string[] time_parts = parts[3].split (":", 2);
- h = int.parse(time_parts[0]);
- min = int.parse(time_parts[1]);
- }
-
- m = get_month_from_string (parts[1]);
- if (parts[2].length == 4) {
- y = int.parse(parts[2]);
- d = int.parse(parts[0]);
- } else {
- y = int.parse(parts[0]);
- d = int.parse(parts[2]);
- }
- last_updated = new DateTime.local (y, m, d, h, min, 0.0);
- }
- }
- }
- if (last_updated == null) {
- /* FIXME: use file modification date if there's no update header
- try {
- string modified = FileAttribute.TIME_MODIFIED;
- var info = file.query_filesystem_info (modified);
- last_updated = new DateTime.from_timeval_local (info.get_modification_time ());
- } catch (Error error) {
- last_updated = now;
- }
- */
- last_updated = now;
- }
-
- /* We have "expires" metadata */
- if (expires_meta != null) {
- if (expires_meta.contains ("days")) {
- string[] parts = expires_meta.split (" ");
- expires = last_updated.add_days (int.parse (parts[0]));
- } else if (expires_meta.contains ("hours")) {
- string[] parts = expires_meta.split (" ");
- expires = last_updated.add_hours (int.parse (parts[0]));
- }
- } else {
- /* No expire metadata found, assume x days */
- int days_to_expire = 7;
- expires = last_updated.add_days (days_to_expire);
- }
-
- /* Check if we are past expire date */
- needs_update = now.compare (expires) == 1;
- }
- }
-}
diff --git a/extensions/adblock/whitelist.vala b/extensions/adblock/whitelist.vala
deleted file mode 100644
index f088a2df..00000000
--- a/extensions/adblock/whitelist.vala
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- Copyright (C) 2014 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2014 Paweł Forysiuk <tuxator@o2.pl>
-
- 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.
-*/
-
-namespace Adblock {
- public class Whitelist : Filter {
- public Whitelist (Options options) {
- base (options);
- }
-
- public override Directive? match (string request_uri, string page_uri) throws Error {
- foreach (unowned string white in rules.get_keys ()) {
- var regex = rules.lookup (white);
- if (!regex.match_full (request_uri))
- return null;
- if (Regex.match_simple (regex.get_pattern (), request_uri, RegexCompileFlags.UNGREEDY, RegexMatchFlags.NOTEMPTY))
- return Directive.ALLOW;
- }
- return null;
- }
- }
-}
diff --git a/extensions/adblock/widgets.vala b/extensions/adblock/widgets.vala
deleted file mode 100644
index 757d35bc..00000000
--- a/extensions/adblock/widgets.vala
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- Copyright (C) 2009-2014 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2009-2012 Alexander Butenko <a.butenka@gmail.com>
-
- 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.
-*/
-
-namespace Adblock {
-
-
- public class StatusIcon : Midori.ContextAction {
- Config config;
- SubscriptionManager manager;
- public State state;
- public bool debug_element_toggled;
-
- public StatusIcon (Adblock.Config config, SubscriptionManager manager) {
- GLib.Object (name: "AdblockStatusMenu");
-
- this.config = config;
- this.manager = manager;
- this.debug_element_toggled = false;
-
- var item = new Midori.ContextAction ("Preferences",
- _("Preferences"), null, Gtk.STOCK_PREFERENCES);
- item.activate.connect (() => {
- manager.add_subscription (null);
- });
- add (item);
-
- add (null);
-
- var checkitem = new Gtk.ToggleAction ("Disable", _("Disable"), null, null);
- checkitem.set_active (!config.enabled);
- checkitem.toggled.connect (() => {
- config.enabled = !checkitem.active;
- set_state (config.enabled ? Adblock.State.ENABLED : Adblock.State.DISABLED);
- });
- add (checkitem);
-
- var hideritem = new Gtk.ToggleAction ("HiddenElements",
- _("Display hidden elements"), null, null);
- hideritem.set_active (debug_element_toggled);
- hideritem.toggled.connect (() => {
- this.debug_element_toggled = hideritem.active;
- });
- add (hideritem);
- set_status (config.enabled ? "enabled" : "disabled");
- }
-
- void set_status (string status) {
- gicon = new GLib.ThemedIcon ("adblock-%s".printf (status));
- }
-
- public void set_state (Adblock.State state) {
- this.state = state;
-
- if (this.state == State.BLOCKED) {
- set_status ("blocked");
- tooltip = _("Blocking");
- } else if (this.state == State.ENABLED) {
- set_status ("enabled");
- tooltip = _("Enabled");
- } else if (this.state == State.DISABLED) {
- set_status ("disabled");
- tooltip = _("Disabled");
- } else
- assert_not_reached ();
- }
- }
-
- public class SubscriptionManager {
- Gtk.TreeView treeview;
- Gtk.ListStore liststore;
- Adblock.Config config;
- public Gtk.Label description_label;
- string description;
-
- public SubscriptionManager (Config config) {
- this.config = config;
- this.liststore = new Gtk.ListStore (1, typeof (Subscription));
- this.description_label = new Gtk.Label (null);
- this.description = _("Type the address of a preconfigured filter list in the text entry and hit Enter.\n");
- this.description += _("You can find more lists by visiting following sites:\n %s, %s\n".printf (
- "<a href=\"http://adblockplus.org/en/subscriptions\">adblockplus.org/en/subscriptions</a>",
- "<a href=\"http://easylist.adblockplus.org/\">easylist.adblockplus.org</a>"
- ));
- }
-
- public void add_subscription (string? uri) {
- var dialog = new Gtk.Dialog.with_buttons (_("Configure Advertisement filters"),
- null,
-#if !HAVE_GTK3
- Gtk.DialogFlags.NO_SEPARATOR |
-#endif
- Gtk.DialogFlags.DESTROY_WITH_PARENT,
- Gtk.STOCK_HELP, Gtk.ResponseType.HELP,
- Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE);
-#if HAVE_GTK3
- dialog.get_widget_for_response (Gtk.ResponseType.HELP).get_style_context ().add_class ("help_button");
-#endif
- dialog.set_icon_name (Gtk.STOCK_PROPERTIES);
- dialog.set_response_sensitive (Gtk.ResponseType.HELP, false);
-
- var hbox = new Gtk.HBox (false, 0);
- (dialog.get_content_area () as Gtk.Box).pack_start (hbox, true, true, 12);
- var vbox = new Gtk.VBox (false, 0);
- hbox.pack_start (vbox, true, true, 4);
- this.description_label.set_markup (this.description);
- this.description_label.set_line_wrap (true);
- vbox.pack_start (this.description_label, false, false, 4);
-
- var entry = new Gtk.Entry ();
- if (uri != null)
- entry.set_text (uri);
- vbox.pack_start (entry, false, false, 4);
-
- liststore = new Gtk.ListStore (1, typeof (Subscription));
- treeview = new Gtk.TreeView.with_model (liststore);
- treeview.set_headers_visible (false);
- var column = new Gtk.TreeViewColumn ();
- var renderer_toggle = new Gtk.CellRendererToggle ();
- column.pack_start (renderer_toggle, false);
- column.set_cell_data_func (renderer_toggle, (column, renderer, model, iter) => {
- Subscription sub;
- liststore.get (iter, 0, out sub);
- renderer.set ("active", sub.active,
- "sensitive", sub.mutable);
- });
- renderer_toggle.toggled.connect ((path) => {
- Gtk.TreeIter iter;
- if (liststore.get_iter_from_string (out iter, path)) {
- Subscription sub;
- liststore.get (iter, 0, out sub);
- sub.active = !sub.active;
- }
- });
- treeview.append_column (column);
-
- column = new Gtk.TreeViewColumn ();
- var renderer_text = new Gtk.CellRendererText ();
- column.pack_start (renderer_text, false);
- renderer_text.set ("editable", true);
- // TODO: renderer_text.edited.connect
- column.set_cell_data_func (renderer_text, (column, renderer, model, iter) => {
- Subscription sub;
- liststore.get (iter, 0, out sub);
- string status = "";
- foreach (unowned Feature feature in sub) {
- var updater = feature as Adblock.Updater;
- if (updater != null) {
- if (updater.last_updated != null)
- status = updater.last_updated.format (_("Last update: %x %X"));
- }
- }
- if (!sub.valid)
- status = _("File incomplete - broken download?");
- renderer.set ("markup", (Markup.printf_escaped ("<b>%s</b>\n%s",
- sub.title ?? sub.uri, status)));
- });
- treeview.append_column (column);
-
- column = new Gtk.TreeViewColumn ();
- Gtk.CellRendererPixbuf renderer_button = new Gtk.CellRendererPixbuf ();
- column.pack_start (renderer_button, false);
- column.set_cell_data_func (renderer_button, on_render_button);
- treeview.append_column (column);
-
- var scrolled = new Gtk.ScrolledWindow (null, null);
- scrolled.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
- scrolled.add (treeview);
- vbox.pack_start (scrolled);
- int height;
- treeview.create_pango_layout ("a\nb").get_pixel_size (null, out height);
- scrolled.set_size_request (-1, height * 5);
-
- foreach (unowned Subscription sub in config)
- liststore.insert_with_values (null, 0, 0, sub);
- treeview.button_release_event.connect (button_released);
-
- entry.activate.connect (() => {
- string? parsed_uri = Adblock.parse_subscription_uri (entry.text);
- if (parsed_uri != null) {
- var sub = new Subscription (parsed_uri);
- if (config.add (sub)) {
- liststore.insert_with_values (null, 0, 0, sub);
- try {
- sub.parse ();
- } catch (GLib.Error error) {
- warning ("Error parsing %s: %s", sub.uri, error.message);
- }
- }
- }
- entry.text = "";
- });
-
- dialog.get_content_area ().show_all ();
-
- dialog.response.connect ((response)=>{ dialog.destroy (); });
- dialog.show ();
- }
-
- void on_render_button (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- Subscription sub;
- liststore.get (iter, 0, out sub);
-
- renderer.set ("stock-id", sub.mutable ? Gtk.STOCK_DELETE : null,
- "stock-size", Gtk.IconSize.MENU);
- }
-
- public bool button_released (Gdk.EventButton event) {
- Gtk.TreePath? path;
- Gtk.TreeViewColumn column;
- if (treeview.get_path_at_pos ((int)event.x, (int)event.y, out path, out column, null, null)) {
- if (path != null) {
- if (column == treeview.get_column (2)) {
- Gtk.TreeIter iter;
- if (liststore.get_iter (out iter, path)) {
- Subscription sub;
- liststore.get (iter, 0, out sub);
- if (sub.mutable) {
- config.remove (sub);
- liststore.remove (iter);
- return true;
- }
- }
- }
- }
- }
- return false;
- }
- }
-
- class CustomRulesEditor {
- Gtk.Dialog dialog;
- Subscription custom;
- public string? rule { get; set; }
-
- public CustomRulesEditor (Subscription custom) {
- this.custom = custom;
- }
-
- public void set_uri (string uri) {
- this.rule = uri;
- }
-
- public void show () {
- this.dialog = new Gtk.Dialog.with_buttons (_("Edit rule"),
- null,
-#if !HAVE_GTK3
- Gtk.DialogFlags.NO_SEPARATOR |
-#endif
- Gtk.DialogFlags.DESTROY_WITH_PARENT,
- Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
- Gtk.STOCK_ADD, Gtk.ResponseType.ACCEPT);
- dialog.set_icon_name (Gtk.STOCK_ADD);
- dialog.resizable = false;
-
- var hbox = new Gtk.HBox (false, 8);
- var sizegroup = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
- hbox.border_width = 5;
- var label = new Gtk.Label.with_mnemonic (_("_Rule:"));
- sizegroup.add_widget (label);
- hbox.pack_start (label, false, false, 0);
- (dialog.get_content_area () as Gtk.Box).pack_start (hbox, false, true, 0);
-
- var entry = new Gtk.Entry ();
- sizegroup.add_widget (entry);
- entry.activates_default = true;
- entry.set_text (this.rule);
- hbox.pack_start (entry, true, true, 0);
-
- dialog.get_content_area ().show_all ();
-
- dialog.set_default_response (Gtk.ResponseType.ACCEPT);
- if (dialog.run () != Gtk.ResponseType.ACCEPT)
- return;
-
- this.rule = entry.get_text ();
- this.dialog.destroy ();
- custom.add_rule (this.rule);
- }
- }
-
-}
diff --git a/extensions/addons.c b/extensions/addons.c
deleted file mode 100644
index 319c290c..00000000
--- a/extensions/addons.c
+++ /dev/null
@@ -1,1935 +0,0 @@
-/*
- Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2008-2010 Arno Renevier <arno@renevier.net>
- Copyright (C) 2010-2011 Paweł Forysiuk <tuxator@o2.pl>
-
- 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.
-*/
-
-/* This extensions add support for user addons: userscripts and userstyles */
-
-#include <midori/midori.h>
-#include "midori-core.h"
-#include <glib/gstdio.h>
-
-#include "config.h"
-#if HAVE_UNISTD_H
- #include <unistd.h>
-#endif
-
-#ifndef X_OK
- #define X_OK 1
-#endif
-
-typedef enum
-{
- ADDON_NONE,
- ADDONS_USER_SCRIPTS,
- ADDONS_USER_STYLES
-} AddonsKind;
-
-#define ADDONS_TYPE \
- (addons_get_type ())
-#define ADDONS(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), ADDONS_TYPE, Addons))
-#define ADDONS_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), ADDONS_TYPE, AddonsClass))
-#define IS_ADDONS(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ADDONS_TYPE))
-#define IS_ADDONS_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), ADDONS_TYPE))
-#define ADDONS_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), ADDONS_TYPE, AddonsClass))
-
-typedef struct _Addons Addons;
-typedef struct _AddonsClass AddonsClass;
-
-struct _AddonsClass
-{
- GtkVBoxClass parent_class;
-};
-
-struct _Addons
-{
- GtkVBox parent_instance;
-
- GtkWidget* toolbar;
- GtkWidget* treeview;
-
- AddonsKind kind;
-};
-
-static void
-addons_iface_init (MidoriViewableIface* iface);
-
-static gchar*
-addons_convert_to_simple_regexp (const gchar* pattern);
-
-G_DEFINE_TYPE_WITH_CODE (Addons, addons, GTK_TYPE_VBOX,
- G_IMPLEMENT_INTERFACE (MIDORI_TYPE_VIEWABLE,
- addons_iface_init));
-
-struct AddonElement
-{
- gchar* fullpath;
- gchar* displayname;
- gchar* description;
- gchar* script_content;
-
- gboolean enabled;
- gboolean broken;
-
- GSList* includes;
- GSList* excludes;
-};
-
-struct AddonsList
-{
- GtkListStore* liststore;
- GSList* elements;
-};
-
-static void
-addons_install_response (GtkWidget* infobar,
- gint response_id,
- MidoriView* view)
-{
- if (response_id == GTK_RESPONSE_ACCEPT)
- {
- const gchar* uri = midori_view_get_display_uri (view);
- if (uri && *uri)
- {
- gchar* hostname, *path;
- gchar* dest_uri, *filename, *dest_path, *temp_uri, *folder_path;
- const gchar* folder;
- WebKitNetworkRequest* request;
- WebKitDownload* download;
-
- hostname = midori_uri_parse_hostname (uri, &path);
- temp_uri = NULL;
- filename = NULL;
- folder = NULL;
-
- if (g_str_has_suffix (uri, ".user.js"))
- folder = "scripts";
- else if (g_str_has_suffix (uri, ".user.css"))
- folder = "styles";
- else if (!g_strcmp0 (hostname, "userscripts.org"))
- {
- /* http://userscripts.org/scripts/ACTION/SCRIPT_ID/NAME */
- gchar* subpage = strchr (strchr (path + 1, '/') + 1, '/');
- if (subpage && subpage[0] == '/' && g_ascii_isdigit (subpage[1]))
- {
- const gchar* js_script;
- WebKitWebView* web_view;
- WebKitWebFrame* web_frame;
-
- js_script = "document.getElementById('heading').childNodes[3].childNodes[1].textContent";
- web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view));
- web_frame = webkit_web_view_get_main_frame (web_view);
-
- if (WEBKIT_IS_WEB_FRAME (web_frame))
- {
- JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
- gchar* value = sokoke_js_script_eval (js_context, js_script, NULL);
- if (value && *value)
- filename = g_strdup_printf ("%s.user.js", value);
- g_free (value);
- }
-
- /* rewrite uri to get source js */
- temp_uri = g_strdup_printf ("http://%s/scripts/source/%s.user.js",
- hostname, subpage + 1);
- uri = temp_uri;
- folder = "scripts";
- }
- }
- else if (!g_strcmp0 (hostname, "userstyles.org"))
- {
- /* http://userstyles.org/styles/STYLE_ID/NAME */
- gchar* subpage = strchr (path + 1, '/');
- if (subpage && subpage[0] == '/' && g_ascii_isdigit (subpage[1]))
- {
- const gchar* js_script;
- WebKitWebView* web_view;
- WebKitWebFrame* web_frame;
- gchar** style_id;
-
- js_script = "document.getElementById('stylish-description').innerHTML;";
- web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view));
- web_frame = webkit_web_view_get_main_frame (web_view);
-
- if (WEBKIT_IS_WEB_FRAME (web_frame))
- {
- JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
- gchar* value = sokoke_js_script_eval (js_context, js_script, NULL);
- if (value && *value)
- filename = g_strdup_printf ("%s.css", value);
- g_free (value);
- }
- /* rewrite uri to get css */
- style_id = g_strsplit (subpage + 1, "/", 2);
- temp_uri = g_strdup_printf ("http://%s/styles/%s.css", hostname, style_id[0]);
- g_strfreev (style_id);
- uri = temp_uri;
- folder = "styles";
- }
- }
-
- if (!filename)
- filename = g_path_get_basename (uri);
- folder_path = g_build_path (G_DIR_SEPARATOR_S,
- midori_paths_get_user_data_dir (), PACKAGE_NAME, folder, NULL);
-
- if (!g_file_test (folder_path, G_FILE_TEST_EXISTS))
- katze_mkdir_with_parents (folder_path, 0700);
- dest_path = g_build_path (G_DIR_SEPARATOR_S, folder_path, filename, NULL);
-
- request = webkit_network_request_new (uri);
- download = webkit_download_new (request);
- g_object_unref (request);
-
- dest_uri = g_filename_to_uri (dest_path, NULL, NULL);
- webkit_download_set_destination_uri (download, dest_uri);
- webkit_download_start (download);
-
- g_free (filename);
- g_free (dest_uri);
- g_free (temp_uri);
- g_free (dest_path);
- g_free (folder_path);
- g_free (hostname);
- }
- }
- gtk_widget_destroy (GTK_WIDGET (infobar));
-}
-
-static void
-addons_uri_install (MidoriView* view,
- AddonsKind kind)
-{
- const gchar* message;
- const gchar* button_text;
-
- if (kind == ADDONS_USER_SCRIPTS)
- {
- /* i18n: An infobar shows up when viewing a script on userscripts.org */
- message = _("This page appears to contain a user script. Do you wish to install it?");
- button_text = _("_Install user script");
- }
- else if (kind == ADDONS_USER_STYLES)
- {
- /* i18n: An infobar shows up when viewing a style on userstyles.org */
- message = _("This page appears to contain a user style. Do you wish to install it?");
- button_text = _("_Install user style");
- }
- else
- g_assert_not_reached ();
-
- midori_view_add_info_bar (view, GTK_MESSAGE_QUESTION, message,
- G_CALLBACK (addons_install_response), view,
- button_text, GTK_RESPONSE_ACCEPT,
- _("Don't install"), GTK_RESPONSE_CANCEL, NULL);
-}
-
-static void
-addons_notify_load_status_cb (MidoriView* view,
- GParamSpec* pspec,
- MidoriExtension* extension)
-{
- const gchar* uri = midori_view_get_display_uri (view);
-
- if (midori_tab_get_view_source (MIDORI_TAB (view)))
- return;
-
- if (uri && *uri)
- {
- if (midori_view_get_load_status (view) == MIDORI_LOAD_COMMITTED)
- {
- /* casual sites goes by uri suffix */
- if (g_str_has_suffix (uri, ".user.js"))
- addons_uri_install (view, ADDONS_USER_SCRIPTS);
- else if (g_str_has_suffix (uri, ".user.css"))
- addons_uri_install (view, ADDONS_USER_STYLES);
- else
- {
- gchar* path;
- gchar* hostname = midori_uri_parse_hostname (uri, &path);
- if (!g_strcmp0 (hostname, "userscripts.org")
- && (g_str_has_prefix (path, "/scripts/show/")
- || g_str_has_prefix (path, "/scripts/review/")))
- {
- /* Main (with desc) and "source view" pages */
- addons_uri_install (view, ADDONS_USER_SCRIPTS);
- }
- else if (!g_strcmp0 (hostname, "userstyles.org")
- && g_str_has_prefix (path, "/styles/"))
- {
- gchar* subpage = strchr (path + 1, '/');
- /* Main page with style description */
- if (subpage && subpage[0] == '/' && g_ascii_isdigit (subpage[1]))
- addons_uri_install (view, ADDONS_USER_STYLES);
- }
- g_free (hostname);
- }
- }
- }
-}
-
-static void
-addons_button_add_clicked_cb (GtkToolItem* toolitem,
- Addons* addons)
-{
- gchar* addons_type;
- gchar* path;
- GtkWidget* dialog;
- GtkFileFilter* filter;
-
- if (addons->kind == ADDONS_USER_SCRIPTS)
- {
- addons_type = g_strdup ("userscripts");
- path = g_build_path (G_DIR_SEPARATOR_S, midori_paths_get_user_data_dir (),
- PACKAGE_NAME, "scripts", NULL);
- }
- else if (addons->kind == ADDONS_USER_STYLES)
- {
- addons_type = g_strdup ("userstyles");
- path = g_build_path (G_DIR_SEPARATOR_S, midori_paths_get_user_data_dir (),
- PACKAGE_NAME, "styles", NULL);
- }
- else
- g_assert_not_reached ();
-
- dialog = gtk_file_chooser_dialog_new (_("Choose file"),
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (addons))),
- GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
-
- gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
-
- filter = gtk_file_filter_new ();
-
- if (addons->kind == ADDONS_USER_SCRIPTS)
- {
- gtk_file_filter_set_name (filter, _("Userscripts"));
- gtk_file_filter_add_pattern (filter, "*.js");
- }
- else if (addons->kind == ADDONS_USER_STYLES)
- {
- gtk_file_filter_set_name (filter, _("Userstyles"));
- gtk_file_filter_add_pattern (filter, "*.css");
- }
- else
- g_assert_not_reached ();
-
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
-
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
- {
- GSList* files;
-
- if (!g_file_test (path, G_FILE_TEST_EXISTS))
- katze_mkdir_with_parents (path, 0700);
-
- files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (dialog));
- while (files)
- {
- GFile* src_file;
- GError* error = NULL;
-
- src_file = files->data;
- if (G_IS_FILE (src_file))
- {
- GFile* dest_file;
- gchar* dest_file_path;
-
- dest_file_path = g_build_path (G_DIR_SEPARATOR_S, path,
- g_file_get_basename (src_file), NULL);
-
- dest_file = g_file_new_for_path (dest_file_path);
-
- g_file_copy (src_file, dest_file,
- G_FILE_COPY_OVERWRITE | G_FILE_COPY_BACKUP,
- NULL, NULL, NULL, &error);
-
- if (error)
- {
- GtkWidget* msg_box;
- msg_box = gtk_message_dialog_new (
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (addons))),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- "%s", error->message);
-
- gtk_window_set_title (GTK_WINDOW (msg_box), _("Error"));
- gtk_dialog_run (GTK_DIALOG (msg_box));
- gtk_widget_destroy (msg_box);
- g_error_free (error);
- }
-
- g_object_unref (src_file);
- g_object_unref (dest_file);
- g_free (dest_file_path);
- }
- files = g_slist_next (files);
- }
- g_slist_free (files);
- }
-
- g_free (addons_type);
- g_free (path);
- gtk_widget_destroy (dialog);
-}
-
-static void
-addons_button_delete_clicked_cb (GtkWidget* toolitem,
- Addons* addons)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
- GtkTreePath* path;
- GtkTreeRowReference* row;
- gchar* fullpath;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (addons->treeview),
- &model, &iter))
- {
- struct AddonElement* element;
- gint delete_response;
- GtkWidget* dialog;
- gchar* markup;
-
- gtk_tree_model_get (model, &iter, 0, &element, -1);
- fullpath = g_strdup (element->fullpath);
-
- path = gtk_tree_model_get_path (model, &iter);
- row = gtk_tree_row_reference_new (model, path);
- gtk_tree_path_free (path);
- dialog = gtk_message_dialog_new (
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (addons))),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_CANCEL,
- _("Do you want to delete '%s'?"),
- element->displayname);
- gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_DELETE, GTK_RESPONSE_YES);
-
- gtk_window_set_title (GTK_WINDOW (dialog),
- addons->kind == ADDONS_USER_SCRIPTS
- ? _("Delete user script")
- : _("Delete user style"));
-
- markup = g_markup_printf_escaped (
- _("The file <b>%s</b> will be permanently deleted."),
- element->fullpath);
- gtk_message_dialog_format_secondary_markup (
- GTK_MESSAGE_DIALOG (dialog), "%s", markup);
- g_free (markup);
-
- /* The execution of gtk_dialog_run allows the directory watcher to
- rebuild the treeview and the element list, so our references may be
- invalid afterward */
- delete_response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog));
-
- if (delete_response == GTK_RESPONSE_YES)
- {
- GError* error = NULL;
- GFile* file;
- gboolean result;
-
- file = g_file_new_for_path (fullpath);
- result = g_file_delete (file, NULL, &error);
-
- if (!result && error)
- {
- GtkWidget* msg_box;
- msg_box = gtk_message_dialog_new (
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (addons))),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- "%s", error->message);
-
- gtk_window_set_title (GTK_WINDOW (msg_box), _("Error"));
- gtk_dialog_run (GTK_DIALOG (msg_box));
- gtk_widget_destroy (msg_box);
- g_error_free (error);
- }
-
- /* The row reference may have been invalidated if the
- filesystem watcher deleted the row concurrently */
- if (result && gtk_tree_row_reference_valid (row))
- {
- path = gtk_tree_row_reference_get_path (row);
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_path_free (path);
- gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
- }
-
- gtk_tree_row_reference_free (row);
- g_object_unref (file);
- }
- g_free (fullpath);
- }
-}
-static void
-addons_open_in_editor_clicked_cb (GtkWidget* toolitem,
- Addons* addons)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (addons->treeview),
- &model, &iter))
- {
- struct AddonElement* element;
- MidoriWebSettings* settings;
- MidoriBrowser* browser;
- gchar* text_editor;
-
- browser = midori_browser_get_for_widget (GTK_WIDGET (addons->treeview));
- settings = midori_browser_get_settings (browser);
-
- gtk_tree_model_get (model, &iter, 0, &element, -1);
-
- g_object_get (settings, "text-editor", &text_editor, NULL);
- if (text_editor && *text_editor)
- sokoke_spawn_program (text_editor, TRUE, element->fullpath, TRUE, FALSE);
- else
- {
- gchar* element_uri = g_filename_to_uri (element->fullpath, NULL, NULL);
- gboolean handled = FALSE;
- g_signal_emit_by_name (midori_browser_get_current_tab (browser), "open-uri", element_uri, &handled);
- g_free (element_uri);
- }
-
- g_free (text_editor);
- }
-}
-
-static void
-addons_open_target_folder_clicked_cb (GtkWidget* toolitem,
- Addons* addons)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
- gchar* folder;
- gchar* folder_uri;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (addons->treeview),
- &model, &iter))
- {
- struct AddonElement* element;
-
- gtk_tree_model_get (model, &iter, 0, &element, -1);
- folder = g_path_get_dirname (element->fullpath);
- }
- else
- {
- folder = g_build_path (G_DIR_SEPARATOR_S, midori_paths_get_user_data_dir (),
- PACKAGE_NAME, addons->kind == ADDONS_USER_SCRIPTS
- ? "scripts" : "styles", NULL);
- katze_mkdir_with_parents (folder, 0700);
- }
-
- folder_uri = g_filename_to_uri (folder, NULL, NULL);
- g_free (folder);
-
- MidoriBrowser* browser = midori_browser_get_for_widget (addons->treeview);
- gboolean handled = FALSE;
- g_signal_emit_by_name (midori_browser_get_current_tab (browser), "open-uri", folder_uri, &handled);
- g_free (folder_uri);
-}
-
-static void
-addons_popup_item (GtkMenu* menu,
- const gchar* stock_id,
- const gchar* label,
- struct AddonElement* element,
- gpointer callback,
- Addons* addons)
-{
- GtkWidget* menuitem;
-
- menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
- if (label)
- gtk_label_set_text_with_mnemonic (GTK_LABEL (gtk_bin_get_child (
- GTK_BIN (menuitem))), label);
- if (!strcmp (stock_id, GTK_STOCK_EDIT))
- gtk_widget_set_sensitive (menuitem, element->fullpath !=NULL);
- else if (strcmp (stock_id, GTK_STOCK_DELETE))
- gtk_widget_set_sensitive (menuitem, element->fullpath !=NULL);
- g_object_set_data (G_OBJECT (menuitem), "AddonElement", &element);
- g_signal_connect (menuitem, "activate", G_CALLBACK(callback), addons);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- gtk_widget_show (menuitem);
-}
-
-static void
-addons_popup (GtkWidget* widget,
- GdkEventButton* event,
- struct AddonElement* element,
- Addons* addons)
-{
- GtkWidget* menu;
-
- menu = gtk_menu_new ();
- addons_popup_item (GTK_MENU (menu), GTK_STOCK_EDIT, _("Open in Text Editor"),
- element, addons_open_in_editor_clicked_cb, addons);
- addons_popup_item (GTK_MENU (menu), GTK_STOCK_OPEN, _("Open Target Folder"),
- element, addons_open_target_folder_clicked_cb, addons);
- addons_popup_item (GTK_MENU (menu), GTK_STOCK_DELETE, NULL,
- element, addons_button_delete_clicked_cb, addons);
- katze_widget_popup (widget, GTK_MENU (menu), event, KATZE_MENU_POSITION_CURSOR);
-}
-
-static gboolean
-addons_popup_menu_cb (GtkWidget *widget,
- Addons* addons)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
- {
- struct AddonElement* element;
- gtk_tree_model_get (model, &iter, 0, &element, -1);
- addons_popup (widget, NULL, element, addons);
- return TRUE;
- }
- return FALSE;
-}
-
-static gboolean
-addons_button_release_event_cb (GtkWidget* widget,
- GdkEventButton* event,
- Addons* addons)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- if (event->button != 3)
- return FALSE;
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
- {
- struct AddonElement* element;
- gtk_tree_model_get (model, &iter, 0, &element, -1);
- addons_popup (widget, NULL, element, addons);
- return TRUE;
- }
- return FALSE;
-}
-
-GtkWidget*
-addons_get_toolbar (MidoriViewable* viewable)
-{
- GtkWidget* toolbar;
- GtkToolItem* toolitem;
-
- g_return_val_if_fail (IS_ADDONS (viewable), NULL);
-
- if (!ADDONS (viewable)->toolbar)
- {
- toolbar = gtk_toolbar_new ();
- toolitem = gtk_tool_item_new ();
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_show (GTK_WIDGET (toolitem));
-
- /* add button */
- toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_ADD);
- gtk_tool_item_set_is_important (toolitem, TRUE);
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (addons_button_add_clicked_cb), viewable);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem), _("Add new addon"));
- gtk_widget_show (GTK_WIDGET (toolitem));
-
- /* Text editor button */
- toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_EDIT);
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (addons_open_in_editor_clicked_cb), viewable);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
- _("Open in Text Editor"));
- gtk_widget_show (GTK_WIDGET (toolitem));
-
- /* Target folder button */
- toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DIRECTORY);
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (addons_open_target_folder_clicked_cb), viewable);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
- _("Open Target Folder"));
- gtk_widget_show (GTK_WIDGET (toolitem));
-
- /* Delete button */
- toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DELETE);
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (addons_button_delete_clicked_cb), viewable);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem), _("Remove selected addon"));
- gtk_widget_show (GTK_WIDGET (toolitem));
- ADDONS (viewable)->toolbar = toolbar;
-
- g_signal_connect (toolbar, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &ADDONS (viewable)->toolbar);
- }
-
- return ADDONS (viewable)->toolbar;
-}
-
-static const gchar*
-addons_get_label (MidoriViewable* viewable)
-{
- Addons* addons = ADDONS (viewable);
- if (addons->kind == ADDONS_USER_SCRIPTS)
- return _("Userscripts");
- else if (addons->kind == ADDONS_USER_STYLES)
- return _("Userstyles");
- return NULL;
-}
-
-static const gchar*
-addons_get_stock_id (MidoriViewable* viewable)
-{
- Addons* addons = ADDONS (viewable);
- if (addons->kind == ADDONS_USER_SCRIPTS)
- return STOCK_SCRIPT;
- else if (addons->kind == ADDONS_USER_STYLES)
- return STOCK_STYLE;
- return NULL;
-}
-
-static void
-addons_iface_init (MidoriViewableIface* iface)
-{
- iface->get_stock_id = addons_get_stock_id;
- iface->get_label = addons_get_label;
- iface->get_toolbar = addons_get_toolbar;
-}
-
-static void
-addons_free_elements (GSList* elements)
-{
- struct AddonElement* element;
-
- while (elements)
- {
- element = elements->data;
- g_free (element->fullpath);
- g_free (element->displayname);
- g_free (element->description);
- g_free (element->script_content);
- g_slist_free (element->includes);
- g_slist_free (element->excludes);
- g_slice_free (struct AddonElement, element);
-
- elements = g_slist_next (elements);
- }
-}
-
-static void
-addons_class_init (AddonsClass* class)
-{
-}
-
-static void
-addons_treeview_render_tick_cb (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- struct AddonElement *element;
-
- gtk_tree_model_get (model, iter, 0, &element, -1);
-
- g_object_set (renderer,
- "active", element->enabled,
- "sensitive", !element->broken,
- NULL);
-}
-
-static void
-addons_cell_renderer_toggled_cb (GtkCellRendererToggle* renderer,
- const gchar* path,
- Addons* addons)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (addons->treeview));
- if (gtk_tree_model_get_iter_from_string (model, &iter, path))
- {
- struct AddonElement *element;
- GtkTreePath* tree_path;
-
- gtk_tree_model_get (model, &iter, 0, &element, -1);
-
- element->enabled = !element->enabled;
-
- /* After enabling or disabling an element, the tree view
- is not updated automatically; we need to notify tree model
- in order to take the modification into account */
- tree_path = gtk_tree_path_new_from_string (path);
- gtk_tree_model_row_changed (model, tree_path, &iter);
- gtk_tree_path_free (tree_path);
- }
-}
-
-static void
-addons_treeview_render_text_cb (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- struct AddonElement *element;
-
- gtk_tree_model_get (model, iter, 0, &element, -1);
-
- g_object_set (renderer, "text", element->displayname,
- "sensitive", element->enabled,
- "ellipsize", PANGO_ELLIPSIZE_END,
- NULL);
-}
-
-static void
-addons_treeview_row_activated_cb (GtkTreeView* treeview,
- GtkTreePath* path,
- GtkTreeViewColumn* column,
- Addons* addons)
-{
- GtkTreeModel* model = gtk_tree_view_get_model (treeview);
- GtkTreeIter iter;
- if (gtk_tree_model_get_iter (model, &iter, path))
- {
- struct AddonElement *element;
-
- gtk_tree_model_get (model, &iter, 0, &element, -1);
-
- element->enabled = !element->enabled;
-
- /* After enabling or disabling an element, the tree view
- is not updated automatically; we need to notify tree model
- in order to take the modification into account */
- gtk_tree_model_row_changed (model, path, &iter);
- }
-}
-
-static GSList*
-addons_get_directories (AddonsKind kind)
-{
- gchar* folder_name;
- GSList* directories;
- const char* const* datadirs;
- gchar* path;
-
- g_assert (kind == ADDONS_USER_SCRIPTS || kind == ADDONS_USER_STYLES);
-
- directories = NULL;
- if (kind == ADDONS_USER_SCRIPTS)
- folder_name = g_strdup ("scripts");
- else if (kind == ADDONS_USER_STYLES)
- folder_name = g_strdup ("styles");
- else
- g_assert_not_reached ();
-
- path = g_build_path (G_DIR_SEPARATOR_S, midori_paths_get_user_data_dir (),
- PACKAGE_NAME, folder_name, NULL);
- directories = g_slist_prepend (directories, path);
-
- datadirs = g_get_system_data_dirs ();
- while (*datadirs)
- {
- path = g_build_path (G_DIR_SEPARATOR_S, *datadirs,
- PACKAGE_NAME, folder_name, NULL);
- if (g_slist_find (directories, path) == NULL)
- directories = g_slist_prepend (directories, path);
- else
- g_free (path);
- datadirs++;
- }
-
- g_free (folder_name);
-
- return directories;
-}
-
-static GSList*
-addons_get_files (AddonsKind kind)
-{
- GSList* files;
- GDir* addon_dir;
- GSList* directories;
- const gchar* filename;
- gchar* dirname;
- gchar* fullname;
- gchar* file_extension;
-
- g_assert (kind == ADDONS_USER_SCRIPTS || kind == ADDONS_USER_STYLES);
-
- if (kind == ADDONS_USER_SCRIPTS)
- file_extension = ".js";
- else if (kind == ADDONS_USER_STYLES)
- file_extension = ".css";
- else
- g_assert_not_reached ();
-
- files = NULL;
-
- directories = addons_get_directories (kind);
- while (directories)
- {
- dirname = directories->data;
- if ((addon_dir = g_dir_open (dirname, 0, NULL)))
- {
- while ((filename = g_dir_read_name (addon_dir)))
- {
- if (g_str_has_suffix (filename, file_extension))
- {
- fullname = g_build_filename (dirname, filename, NULL);
- if (g_slist_find (files, fullname) == NULL)
- files = g_slist_prepend (files, fullname);
- }
- }
- g_dir_close (addon_dir);
- }
- g_free (dirname);
- directories = g_slist_next (directories);
- }
-
- g_slist_free (directories);
-
- return files;
-}
-
-static gboolean
-js_metadata_from_file (const gchar* filename,
- GSList** includes,
- GSList** excludes,
- gchar** name,
- gchar** description)
-{
- GIOChannel* channel;
- gboolean found_meta;
- gchar* line;
- gchar* rest_of_line;
-
- if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
- return FALSE;
-
- channel = g_io_channel_new_file (filename, "r", 0);
- if (!channel)
- return FALSE;
-
- found_meta = FALSE;
-
- while (g_io_channel_read_line (channel, &line, NULL, NULL, NULL)
- == G_IO_STATUS_NORMAL)
- {
- g_strstrip (line);
- if (g_str_has_prefix (line, "// ==UserScript=="))
- found_meta = TRUE;
- else if (found_meta)
- {
- if (g_str_has_prefix (line, "// ==/UserScript=="))
- found_meta = FALSE;
- else if (g_str_has_prefix (line, "// @require")
- || g_str_has_prefix (line, "// @resource"))
- {
- /* We don't support these, so abort here */
- g_free (line);
- g_io_channel_shutdown (channel, false, 0);
- if (includes != NULL)
- {
- g_slist_free (*includes);
- *includes = NULL;
- }
- if (excludes != NULL)
- {
- g_slist_free (*excludes);
- *excludes = NULL;
- }
- return FALSE;
- }
- else if (includes && g_str_has_prefix (line, "// @include"))
- {
- gchar* re = NULL;
- rest_of_line = g_strdup (line + strlen ("// @include"));
- rest_of_line = g_strstrip (rest_of_line);
- re = addons_convert_to_simple_regexp (rest_of_line);
- *includes = g_slist_prepend (*includes, re);
- }
- else if (excludes && g_str_has_prefix (line, "// @exclude"))
- {
- gchar* re = NULL;
- rest_of_line = g_strdup (line + strlen ("// @exclude"));
- rest_of_line = g_strstrip (rest_of_line);
- re = addons_convert_to_simple_regexp (rest_of_line);
- *excludes = g_slist_prepend (*excludes, re);
- }
- else if (name && g_str_has_prefix (line, "// @name"))
- {
- if (!strncmp (line, "// @namespace", 13))
- continue;
- rest_of_line = g_strdup (line + strlen ("// @name"));
- rest_of_line = g_strstrip (rest_of_line);
- *name = rest_of_line;
- }
- else if (description && g_str_has_prefix (line, "// @description"))
- {
- rest_of_line = g_strdup (line + strlen ("// @description"));
- rest_of_line = g_strstrip (rest_of_line);
- *description = rest_of_line;
- }
- }
- g_free (line);
- }
- g_io_channel_shutdown (channel, false, 0);
- g_io_channel_unref (channel);
-
- return TRUE;
-}
-
-static gboolean
-css_metadata_from_file (const gchar* filename,
- GSList** includes,
- GSList** excludes)
-{
- GIOChannel* channel;
- gchar* line;
- gchar* rest_of_line;
- gboolean line_has_meta;
-
- if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
- return FALSE;
-
- channel = g_io_channel_new_file (filename, "r", 0);
- if (!channel)
- return FALSE;
-
- line_has_meta = FALSE;
- while (g_io_channel_read_line (channel, &line, NULL, NULL, NULL)
- == G_IO_STATUS_NORMAL)
- {
- g_strstrip (line);
- if (g_str_has_prefix (line, "@-moz-document") || line_has_meta)
- { /* FIXME: We merely look for includes. We should honor blocks. */
- if (includes)
- {
- gchar** parts;
- guint i;
-
- if (g_str_has_prefix (line, "@-moz-document"))
- rest_of_line = g_strdup (line + strlen ("@-moz-document"));
- else
- rest_of_line = g_strdup (line);
-
- rest_of_line = g_strstrip (rest_of_line);
- line_has_meta = !g_str_has_suffix (rest_of_line, "{");
-
- parts = g_strsplit_set (rest_of_line, " ,", 0);
- i = 0;
- while (parts[i] && *parts[i] != '{')
- {
- gchar* value = NULL;
- if (g_str_has_prefix (parts[i], "url-prefix("))
- value = &parts[i][strlen ("url-prefix(")];
- else if (g_str_has_prefix (parts[i], "domain("))
- value = &parts[i][strlen ("domain(")];
- else if (g_str_has_prefix (parts[i], "url("))
- value = &parts[i][strlen ("url(")];
- if (value)
- {
- guint begin, end;
- gchar* domain;
- gchar* tmp_domain;
- gchar* re = NULL;
-
- line_has_meta = TRUE;
- begin = value[0] == '"' || value[0] == '\'' ? 1 : 0;
- end = 1;
- while (value[end] != '\0' && value[end] != ')')
- ++end;
-
- domain = g_strndup (value + begin, end - begin * 2);
- if (!midori_uri_is_location (domain)
- && !g_str_has_prefix (domain, "file://"))
- tmp_domain = g_strdup_printf ("http*://*%s/*", domain);
- else
- tmp_domain = domain;
-
- re = addons_convert_to_simple_regexp (tmp_domain);
- *includes = g_slist_prepend (*includes, re);
- g_free (domain);
- }
- i++;
- }
- g_strfreev (parts);
- g_free (rest_of_line);
- }
- else
- line_has_meta = FALSE;
- }
- g_free (line);
- }
- g_io_channel_shutdown (channel, false, 0);
- g_io_channel_unref (channel);
-
- return TRUE;
-}
-
-static gboolean
-addons_get_element_content (gchar* file_path,
- AddonsKind kind,
- gboolean has_metadata,
- gchar** content)
-{
- gchar* file_content;
- GString* content_chunks;
- guint meta, comment;
- guint i, n;
-
- g_assert (kind == ADDONS_USER_SCRIPTS || kind == ADDONS_USER_STYLES);
-
- if (g_file_get_contents (file_path, &file_content, NULL, NULL))
- {
- if (kind == ADDONS_USER_SCRIPTS)
- {
- *content = g_strdup_printf (
- "window.addEventListener ('DOMContentLoaded',"
- "function () { %s }, true);", file_content);
- }
- else if (kind == ADDONS_USER_STYLES)
- {
- meta = 0;
- comment = 0;
- n = strlen (file_content);
- content_chunks = g_string_new_len (NULL, n);
- for (i = 0; i < n; i++)
- {
- /* Replace line breaks with spaces */
- if (file_content[i] == '\n' || file_content[i] == '\r')
- file_content[i] = ' ';
- /* Change all single quotes to double quotes */
- if (file_content[i] == '\'')
- file_content[i] = '\"';
- if (!meta && file_content[i] == '@')
- {
- meta++;
- }
- else if (meta == 1
- && (file_content[i] == '-' || file_content[i] == 'n'))
- {
- meta++;
- }
- else if (meta == 2 && file_content[i] == '{')
- {
- meta++;
- continue;
- }
- else if (meta == 3 && file_content[i] == '{')
- meta++;
- else if (meta == 4 && file_content[i] == '}')
- meta--;
- else if (meta == 3 && file_content[i] == '}')
- {
- meta = 0;
- continue;
- }
-
- if (file_content[i] == '/' && file_content[i+1] == '*')
- comment++;
- /* Check whether we have comment ending, merely '*' or '/' */
- else if (comment == 2
- && file_content[i] == '*' && file_content[i+1] == '/')
- {
- comment--;
- }
- else if (comment == 1
- && file_content[i-1] == '*' && file_content[i] == '/')
- {
- comment--;
- continue;
- }
-
- /* Skip consecutive spaces */
- if (file_content[i] == ' '
- && i > 0 && file_content[i - 1] == ' ')
- continue;
-
- /* Append actual data to string */
- if ((meta == 0 || meta >= 3) && !comment)
- g_string_append_c (content_chunks, file_content[i]);
- }
-
- if (has_metadata)
- {
- *content = g_strdup_printf (
- "window.addEventListener ('DOMContentLoaded',"
- "function () {"
- "var mystyle = document.createElement(\"style\");"
- "mystyle.setAttribute(\"type\", \"text/css\");"
- "mystyle.appendChild(document.createTextNode('%s'));"
- "var head = document.getElementsByTagName(\"head\")[0];"
- "if (head) head.appendChild(mystyle);"
- "else document.documentElement.insertBefore"
- "(mystyle, document.documentElement.firstChild);"
- "}, true);",
- content_chunks->str);
- g_string_free (content_chunks, TRUE);
- }
- else
- {
- *content = content_chunks->str;
- g_string_free (content_chunks, FALSE);
- }
- }
- g_free (file_content);
- if (*content)
- return TRUE;
- }
- return FALSE;
-}
-
-static void
-addons_update_elements (MidoriExtension* extension,
- AddonsKind kind)
-{
- GSList* addon_files;
- gchar* name;
- gchar* fullpath;
- struct AddonElement* element;
- struct AddonsList* addons_list;
- GSList* elements = NULL;
- GtkListStore* liststore = NULL;
- GtkTreeIter iter;
- gchar* config_file;
- GKeyFile* keyfile;
-
- if (kind == ADDONS_USER_SCRIPTS)
- addons_list = g_object_get_data (G_OBJECT (extension), "scripts-list");
- else if (kind == ADDONS_USER_STYLES)
- addons_list = g_object_get_data (G_OBJECT (extension), "styles-list");
- else
- g_assert_not_reached ();
-
- if (addons_list)
- {
- liststore = addons_list->liststore;
- elements = addons_list->elements;
- }
-
- if (elements)
- addons_free_elements (elements);
-
- if (liststore)
- gtk_list_store_clear (liststore);
- else
- liststore = gtk_list_store_new (4, G_TYPE_POINTER,
- G_TYPE_INT,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- keyfile = g_key_file_new ();
- config_file = g_build_filename (midori_extension_get_config_dir (extension),
- "addons", NULL);
- g_key_file_load_from_file (keyfile, config_file, G_KEY_FILE_NONE, NULL);
-
- addon_files = addons_get_files (kind);
-
- elements = NULL;
- while (addon_files)
- {
- gchar* filename;
- gchar* tooltip;
-
- fullpath = addon_files->data;
- element = g_slice_new (struct AddonElement);
- element->displayname = g_filename_display_basename (fullpath);
- element->fullpath = fullpath;
- element->enabled = TRUE;
- element->broken = FALSE;
- element->includes = NULL;
- element->excludes = NULL;
- element->description = NULL;
- element->script_content = NULL;
-
- if (kind == ADDONS_USER_SCRIPTS)
- {
- name = NULL;
- if (!js_metadata_from_file (fullpath,
- &element->includes, &element->excludes,
- &name, &element->description))
- element->broken = TRUE;
-
- if (name)
- katze_assign (element->displayname, name);
-
- if (!element->broken)
- if (!addons_get_element_content (fullpath, kind, FALSE,
- &(element->script_content)))
- element->broken = TRUE;
-
- if (g_key_file_get_integer (keyfile, "scripts", fullpath, NULL) & 1)
- element->enabled = FALSE;
- }
- else if (kind == ADDONS_USER_STYLES)
- {
- if (!css_metadata_from_file (fullpath,
- &element->includes,
- &element->excludes))
- element->broken = TRUE;
-
- if (!element->broken)
- if (!addons_get_element_content (fullpath, kind,
- element->includes || element->excludes,
- &(element->script_content)))
- element->broken = TRUE;
-
- if (g_key_file_get_integer (keyfile, "styles", fullpath, NULL) & 1)
- element->enabled = FALSE;
- }
-
- filename = g_path_get_basename (element->fullpath);
- if (element->description)
- tooltip = g_markup_printf_escaped ("%s\n\n%s",
- filename, element->description);
- else
- tooltip = g_markup_escape_text (filename, -1);
- g_free (filename);
-
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter,
- 0, element, 1, 0, 2, element->fullpath,
- 3, tooltip, -1);
-
- g_free (tooltip);
- addon_files = g_slist_next (addon_files);
- elements = g_slist_prepend (elements, element);
- }
- g_free (config_file);
- g_key_file_free (keyfile);
-
- g_slice_free (struct AddonsList, addons_list);
- addons_list = g_slice_new (struct AddonsList);
- addons_list->elements = elements;
- addons_list->liststore = liststore;
-
- if (kind == ADDONS_USER_SCRIPTS)
- g_object_set_data (G_OBJECT (extension), "scripts-list", addons_list);
- else if (kind == ADDONS_USER_STYLES)
- g_object_set_data (G_OBJECT (extension), "styles-list", addons_list);
-}
-
-static void
-addons_init (Addons* addons)
-{
- GtkTreeViewColumn* column;
- GtkCellRenderer* renderer_text;
- GtkCellRenderer* renderer_toggle;
-
- addons->treeview = gtk_tree_view_new ();
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (addons->treeview), FALSE);
- column = gtk_tree_view_column_new ();
- renderer_toggle = gtk_cell_renderer_toggle_new ();
- gtk_tree_view_column_pack_start (column, renderer_toggle, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_toggle,
- (GtkTreeCellDataFunc)addons_treeview_render_tick_cb,
- addons->treeview, NULL);
- g_signal_connect (renderer_toggle, "toggled",
- G_CALLBACK (addons_cell_renderer_toggled_cb), addons);
- gtk_tree_view_append_column (GTK_TREE_VIEW (addons->treeview), column);
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_expand (column, TRUE);
- renderer_text = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer_text, TRUE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_text,
- (GtkTreeCellDataFunc)addons_treeview_render_text_cb,
- addons->treeview, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (addons->treeview), column);
- gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (addons->treeview), 3);
- g_signal_connect (addons->treeview, "row-activated",
- G_CALLBACK (addons_treeview_row_activated_cb),
- addons);
- g_signal_connect (addons->treeview, "button-release-event",
- G_CALLBACK (addons_button_release_event_cb),
- addons);
- g_signal_connect (addons->treeview, "popup-menu",
- G_CALLBACK (addons_popup_menu_cb),
- addons);
- gtk_widget_show (addons->treeview);
- gtk_box_pack_start (GTK_BOX (addons), addons->treeview, TRUE, TRUE, 0);
-}
-
-static gchar*
-addons_convert_to_simple_regexp (const gchar* pattern)
-{
- guint len;
- gchar* dest;
- guint pos;
- guint i;
- gchar c;
-
- len = strlen (pattern);
- dest = g_malloc0 (len * 2 + 2);
- dest[0] = '^';
- pos = 1;
-
- for (i = 0; i < len; i++)
- {
- c = pattern[i];
- switch (c)
- {
- case '*':
- dest[pos] = '.';
- dest[pos + 1] = c;
- pos++;
- pos++;
- break;
- case '.' :
- case '?' :
- case '^' :
- case '$' :
- case '+' :
- case '{' :
- case '[' :
- case '|' :
- case '(' :
- case ')' :
- case ']' :
- case '\\' :
- dest[pos] = '\\';
- dest[pos + 1] = c;
- pos++;
- pos++;
- break;
- case ' ' :
- break;
- default:
- dest[pos] = pattern[i];
- pos ++;
- }
- }
- return dest;
-}
-
-static gboolean
-addons_may_run (const gchar* uri,
- GSList** includes,
- GSList** excludes)
-{
- gboolean match;
- GSList* list;
-
- if (*includes)
- match = FALSE;
- else
- match = TRUE;
-
- list = *includes;
- while (list)
- {
- gboolean matched = g_regex_match_simple (list->data, uri, 0, 0);
- if (matched)
- {
- match = TRUE;
- break;
- }
- list = g_slist_next (list);
- }
- if (!match)
- return FALSE;
-
- list = *excludes;
- while (list)
- {
- gboolean matched = g_regex_match_simple (list->data, uri, 0, 0);
- if (matched)
- {
- match = FALSE;
- break;
- }
- list = g_slist_next (list);
- }
- return match;
-}
-
-static gboolean
-addons_skip_element (struct AddonElement* element,
- gchar* uri)
-{
- if (midori_debug("addons:match"))
- {
- g_print("%s: %s on %s matched: %d\n", G_STRFUNC,
- element->displayname, uri, addons_may_run (uri, &element->includes, &element->excludes));
- }
-
- if (!element->enabled || element->broken)
- return TRUE;
- if (element->includes || element->excludes)
- if (!addons_may_run (uri, &element->includes, &element->excludes))
- return TRUE;
- return FALSE;
-}
-
-static void
-addons_context_ready_cb (WebKitWebView* web_view,
- WebKitWebFrame* web_frame,
- JSContextRef js_context,
- JSObjectRef js_window,
- MidoriExtension* extension)
-{
- gchar* uri;
- GSList* scripts, *styles;
- struct AddonElement* script, *style;
- struct AddonsList* scripts_list, *styles_list;
- const gchar* page_uri;
-
- page_uri = webkit_web_frame_get_uri (web_frame);
- if (!midori_uri_is_http (page_uri) && !midori_uri_is_blank (page_uri))
- return;
-
- /* Not a main frame! Abort */
- if (web_frame != webkit_web_view_get_main_frame (web_view))
- return;
-
- uri = katze_object_get_string (web_view, "uri");
- scripts_list = g_object_get_data (G_OBJECT (extension), "scripts-list");
- scripts = scripts_list->elements;
- while (scripts)
- {
- script = scripts->data;
- if (addons_skip_element (script, uri))
- {
- scripts = g_slist_next (scripts);
- continue;
- }
- if (script->script_content)
- webkit_web_view_execute_script (web_view, script->script_content);
- scripts = g_slist_next (scripts);
- }
-
- styles_list = g_object_get_data (G_OBJECT (extension), "styles-list");
- styles = styles_list->elements;
- while (styles)
- {
- style = styles->data;
- if (addons_skip_element (style, uri))
- {
- styles = g_slist_next (styles);
- continue;
- }
- if (style->script_content)
- webkit_web_view_execute_script (web_view, style->script_content);
- styles = g_slist_next (styles);
- }
- g_free (uri);
-}
-
-static void
-addons_add_tab_cb (MidoriBrowser* browser,
- MidoriView* view,
- MidoriExtension* extension)
-{
- GtkWidget* web_view = midori_view_get_web_view (view);
- g_signal_connect (web_view, "window-object-cleared",
- G_CALLBACK (addons_context_ready_cb), extension);
- g_signal_connect (view, "notify::load-status",
- G_CALLBACK (addons_notify_load_status_cb), extension);
-}
-
-static void
-addons_browser_destroy (MidoriBrowser* browser,
- MidoriExtension* extension)
-{
- GtkWidget* scripts, *styles;
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs; tabs = g_list_next (tabs))
- {
- GtkWidget* web_view = midori_view_get_web_view (tabs->data);
- g_signal_handlers_disconnect_by_func (
- web_view, addons_context_ready_cb, extension);
- }
- g_list_free (tabs);
- g_signal_handlers_disconnect_by_func (browser, addons_add_tab_cb, extension);
-
- scripts = (GtkWidget*)g_object_get_data (G_OBJECT (browser), "scripts-addons");
- gtk_widget_destroy (scripts);
- styles = (GtkWidget*)g_object_get_data (G_OBJECT (browser), "styles-addons");
- gtk_widget_destroy (styles);
-}
-
-static char*
-addons_generate_global_stylesheet (MidoriExtension* extension)
-{
- GSList* styles;
- struct AddonElement* style;
- struct AddonsList* styles_list;
- GString* style_string = g_string_new ("");
-
- styles_list = g_object_get_data (G_OBJECT (extension), "styles-list");
- styles = styles_list->elements;
- while (styles != NULL)
- {
- style = styles->data;
- if (style->enabled &&
- !(style->includes || style->excludes || style->broken))
- {
- style_string = g_string_append (style_string, style->script_content);
- }
- styles = g_slist_next (styles);
- }
-
- return g_string_free (style_string, FALSE);
-}
-
-static void
-addons_apply_global_stylesheet (MidoriExtension* extension)
-{
- MidoriApp* app = midori_extension_get_app (extension);
- MidoriWebSettings* settings = katze_object_get_object (app, "settings");
- gchar* data = addons_generate_global_stylesheet (extension);
- midori_web_settings_add_style (settings, "addons", data);
- g_free (data);
- g_object_unref (settings);
-}
-
-GtkWidget*
-addons_new (AddonsKind kind, MidoriExtension* extension)
-{
- GtkWidget* addons;
- GtkListStore* liststore;
- struct AddonsList* list;
-
- addons = g_object_new (ADDONS_TYPE, NULL);
- ADDONS (addons)->kind = kind;
-
- if (kind == ADDONS_USER_SCRIPTS)
- list = g_object_get_data (G_OBJECT (extension), "scripts-list");
- else if (kind == ADDONS_USER_STYLES)
- list = g_object_get_data (G_OBJECT (extension), "styles-list");
- else
- g_assert_not_reached ();
-
- liststore = list->liststore;
- gtk_tree_view_set_model (GTK_TREE_VIEW (ADDONS(addons)->treeview),
- GTK_TREE_MODEL (liststore));
- gtk_widget_queue_draw (GTK_WIDGET (ADDONS(addons)->treeview));
-
- if (kind == ADDONS_USER_STYLES)
- g_signal_connect_swapped (liststore, "row-changed",
- G_CALLBACK (addons_apply_global_stylesheet), extension);
-
- return addons;
-}
-
-static void
-addons_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension)
-{
- GtkWidget* panel;
- GtkWidget* scripts, *styles;
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs; tabs = g_list_next (tabs))
- addons_add_tab_cb (browser, tabs->data, extension);
- g_list_free (tabs);
- g_signal_connect (browser, "add-tab",
- G_CALLBACK (addons_add_tab_cb), extension);
- panel = katze_object_get_object (browser, "panel");
-
- scripts = addons_new (ADDONS_USER_SCRIPTS, extension);
- gtk_widget_show (scripts);
- midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (scripts));
- g_object_set_data (G_OBJECT (browser), "scripts-addons", scripts);
-
- styles = addons_new (ADDONS_USER_STYLES, extension);
- gtk_widget_show (styles);
- midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (styles));
- g_object_set_data (G_OBJECT (browser), "styles-addons", styles);
-
- g_object_unref (panel);
-}
-
-static void
-addons_save_settings (MidoriApp* app,
- MidoriExtension* extension)
-{
- struct AddonsList* scripts_list, *styles_list;
- struct AddonElement* script, *style;
- GSList* scripts, *styles;
- GKeyFile* keyfile;
- const gchar* config_dir;
- gchar* config_file;
- GError* error = NULL;
-
- keyfile = g_key_file_new ();
-
- /* scripts */
- scripts_list = g_object_get_data (G_OBJECT (extension), "scripts-list");
- scripts = scripts_list->elements;
- while (scripts)
- {
- script = scripts->data;
- if (!script->enabled)
- g_key_file_set_integer (keyfile, "scripts", script->fullpath, 1);
- scripts = g_slist_next (scripts);
- }
-
- /* styles */
- styles_list = g_object_get_data (G_OBJECT (extension), "styles-list");
- styles = styles_list->elements;
- while (styles)
- {
- style = styles->data;
- if (!style->enabled)
- g_key_file_set_integer (keyfile, "styles", style->fullpath, 1);
- styles = g_slist_next (styles);
- }
-
- config_dir = midori_extension_get_config_dir (extension);
- config_file = g_build_filename (config_dir, "addons", NULL);
- if (config_dir != NULL)
- katze_mkdir_with_parents (config_dir, 0700);
- sokoke_key_file_save_to_file (keyfile, config_file, &error);
- if (error && midori_extension_get_config_dir (extension) != NULL)
- {
- g_warning (_("The configuration of the extension '%s' couldn't be saved: %s\n"),
- _("User addons"), error->message);
- g_error_free (error);
- }
-
- g_free (config_file);
- g_key_file_free (keyfile);
-}
-
-static void
-addons_disable_monitors (MidoriExtension* extension)
-{
- GSList* monitors;
-
- monitors = g_object_get_data (G_OBJECT (extension), "monitors");
- if (!monitors)
- return;
-
- g_slist_foreach (monitors, (GFunc)g_file_monitor_cancel, NULL);
- g_slist_free (monitors);
- g_object_set_data (G_OBJECT (extension), "monitors", NULL);
-}
-
-static void
-addons_deactivate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- MidoriWebSettings* settings = katze_object_get_object (app, "settings");
- KatzeArray* browsers;
- MidoriBrowser* browser;
- GSource* source;
-
- addons_disable_monitors (extension);
- addons_save_settings (NULL, extension);
- midori_web_settings_remove_style (settings, "addons");
-
- browsers = katze_object_get_object (app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- addons_browser_destroy (browser, extension);
-
- source = g_object_get_data (G_OBJECT (extension), "monitor-timer");
- if (source && !g_source_is_destroyed (source))
- g_source_destroy (source);
-
- g_signal_handlers_disconnect_by_func (
- app, addons_app_add_browser_cb, extension);
- g_signal_handlers_disconnect_by_func (
- app, addons_save_settings, extension);
- g_signal_handlers_disconnect_by_func (
- extension, addons_deactivate_cb, app);
-
- g_object_unref (browsers);
- g_object_unref (settings);
-}
-
-static gboolean
-addons_reset_all_elements_cb (MidoriExtension* extension)
-{
- addons_save_settings (NULL, extension);
- addons_update_elements (extension, ADDONS_USER_STYLES);
- addons_update_elements (extension, ADDONS_USER_SCRIPTS);
- g_object_set_data (G_OBJECT (extension), "monitor-timer", NULL);
- return FALSE;
-}
-
-static void
-addons_directory_monitor_changed (GFileMonitor* monitor,
- GFile* child,
- GFile* other_file,
- GFileMonitorEvent flags,
- MidoriExtension* extension)
-{
- GFileInfo* info;
- GSource* source;
-
- info = g_file_query_info (child,
- "standard::is-hidden,standard::is-backup", 0, NULL, NULL);
- if (info != NULL)
- {
- gboolean hidden = g_file_info_get_is_hidden (info)
- || g_file_info_get_is_backup (info);
- g_object_unref (info);
- if (hidden)
- return;
- }
-
- /* We receive a lot of change events, so we use a timeout to trigger
- elements update only once */
- source = g_object_get_data (G_OBJECT (extension), "monitor-timer");
- if (source && !g_source_is_destroyed (source))
- g_source_destroy (source);
-
- source = g_timeout_source_new_seconds (1);
- g_source_set_callback (source, (GSourceFunc)addons_reset_all_elements_cb,
- extension, NULL);
- g_source_attach (source, NULL);
- g_object_set_data (G_OBJECT (extension), "monitor-timer", source);
- g_source_unref (source);
-}
-
-static void
-addons_monitor_directories (MidoriExtension* extension,
- AddonsKind kind)
-{
- GSList* directories;
- GError* error;
- GSList* monitors;
- GFileMonitor* monitor;
- GFile* directory;
-
- g_assert (kind == ADDONS_USER_SCRIPTS || kind == ADDONS_USER_STYLES);
-
- monitors = g_object_get_data (G_OBJECT (extension), "monitors");
-
- directories = addons_get_directories (kind);
- while (directories)
- {
- directory = g_file_new_for_path (directories->data);
- directories = g_slist_next (directories);
- error = NULL;
- monitor = g_file_monitor_directory (directory,
- G_FILE_MONITOR_NONE,
- NULL, &error);
- if (monitor)
- {
- g_signal_connect (monitor, "changed",
- G_CALLBACK (addons_directory_monitor_changed), extension);
- monitors = g_slist_prepend (monitors, monitor);
- }
- else
- {
- g_warning (_("Can't monitor folder '%s': %s"),
- g_file_get_parse_name (directory), error->message);
- g_error_free (error);
- }
- g_object_unref (directory);
- }
- g_object_set_data (G_OBJECT (extension), "monitors", monitors);
- g_slist_free (directories);
-}
-
-static void
-addons_activate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- MidoriWebSettings* settings = katze_object_get_object (app, "settings");
- KatzeArray* browsers;
- MidoriBrowser* browser;
- gchar* data;
-
- browsers = katze_object_get_object (app, "browsers");
- addons_update_elements (extension, ADDONS_USER_STYLES);
- addons_monitor_directories (extension, ADDONS_USER_STYLES);
- addons_update_elements (extension, ADDONS_USER_SCRIPTS);
- addons_monitor_directories (extension, ADDONS_USER_SCRIPTS);
- data = addons_generate_global_stylesheet (extension);
- midori_web_settings_add_style (settings, "addons", data);
-
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- addons_app_add_browser_cb (app, browser, extension);
- g_object_unref (browsers);
- g_object_unref (settings);
- g_free (data);
-
- g_signal_connect (app, "add-browser",
- G_CALLBACK (addons_app_add_browser_cb), extension);
-
- g_signal_connect (app, "quit",
- G_CALLBACK (addons_save_settings), extension);
-
- g_signal_connect (extension, "deactivate",
- G_CALLBACK (addons_deactivate_cb), app);
-}
-
-static void
-test_addons_simple_regexp (void)
-{
- typedef struct
- {
- const gchar* before;
- const gchar* after;
- } RegexItem;
- guint i;
-
- static const RegexItem items[] = {
- { "*", "^.*" },
- { "http://", "^http://" },
- { "https://", "^https://" },
- { "http*://", "^http://" },
- { "http*://", "^https://" },
- { "about:blank", "^about:blank" },
- { "file://", "^file://" },
- { "ftp://", "^ftp://" },
- { "https://bugzilla.mozilla.org/", "^https://bugzilla\\.mozilla\\.org/" },
- { "http://92.48.103.52/fantasy3/*", "^http://92\\.48\\.103\\.52/fantasy3/.*" },
- { "http://www.rpg.co.uk/fantasy/*", "^http://www\\.rpg\\.co\\.uk/fantasy/.*" },
- { "http://cookpad.com/recipe/*", "^http://cookpad\\.com/recipe/.*" },
- { "https://*/*post_bug.cgi", "^https://.*/.*post_bug\\.cgi" },
- };
-
- for (i = 0; i < G_N_ELEMENTS (items); i++)
- {
- gchar* result = addons_convert_to_simple_regexp (items[i].before);
- const gchar* after = items[i].after ? items[i].after : items[i].before;
- katze_assert_str_equal (items[i].before, result, after);
- g_free (result);
- }
-}
-
-void
-extension_test (void)
-{
- g_test_add_func ("/extensions/addons/simple_regexp", test_addons_simple_regexp);
-}
-
-MidoriExtension*
-extension_init (void)
-{
- MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", _("User addons"),
- "description", _("Support for userscripts and userstyles"),
- "version", "0.1" MIDORI_VERSION_SUFFIX,
- "authors", "Arno Renevier <arno@renevier.net>",
- NULL);
- g_signal_connect (extension, "activate",
- G_CALLBACK (addons_activate_cb), NULL);
-
- return extension;
-}
diff --git a/extensions/apps.vala b/extensions/apps.vala
deleted file mode 100644
index f0d034b3..00000000
--- a/extensions/apps.vala
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- Copyright (C) 2013 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.
-*/
-
-namespace Apps {
- const string APP_PREFIX = PACKAGE_NAME + " -a ";
- const string PROFILE_PREFIX = PACKAGE_NAME + " -c ";
-
- private class Launcher : GLib.Object, GLib.Initable {
- internal GLib.File file;
- internal string name;
- internal string icon_name;
- internal string exec;
- internal string uri;
-
- internal static string get_favicon_name_for_uri (string prefix, GLib.File folder, string uri, bool testing)
- {
- string icon_name = Midori.Stock.WEB_BROWSER;
-
- if (testing == true)
- return icon_name;
-
- if (prefix != PROFILE_PREFIX)
- {
- try {
- var pixbuf = Midori.Paths.get_icon (uri, null);
- if (pixbuf == null)
- throw new FileError.EXIST ("No favicon loaded");
- string icon_filename = folder.get_child ("icon.png").get_path ();
- pixbuf.save (icon_filename, "png", null, "compression", "7", null);
-#if HAVE_WIN32
- string doubleslash_icon = icon_filename.replace ("\\", "\\\\");
- icon_name = doubleslash_icon;
-#else
- icon_name = icon_filename;
-#endif
- }
- catch (Error error) {
- GLib.warning (_("Failed to fetch application icon in %s: %s"), folder.get_path (), error.message);
- }
- }
- return icon_name;
- }
-
- internal static string prepare_desktop_file (string prefix, string name, string uri, string title, string icon_name)
- {
- string exec;
-#if HAVE_WIN32
- string doubleslash_uri = uri.replace ("\\", "\\\\");
- string quoted_uri = GLib.Shell.quote (doubleslash_uri);
- exec = prefix + quoted_uri;
-#else
- exec = prefix + uri;
-#endif
- var keyfile = new GLib.KeyFile ();
- string entry = "Desktop Entry";
-
- keyfile.set_string (entry, "Version", "1.0");
- keyfile.set_string (entry, "Type", "Application");
- keyfile.set_string (entry, "Name", name);
- keyfile.set_string (entry, "Exec", exec);
- keyfile.set_string (entry, "TryExec", PACKAGE_NAME);
- keyfile.set_string (entry, "Icon", icon_name);
- keyfile.set_string (entry, "Categories", "Network;");
- /*
- Using the sanitized URI as a class matches midori_web_app_new
- So dock type launchers can distinguish different apps with the same executable
- */
- if (exec.has_prefix (APP_PREFIX))
- keyfile.set_string (entry, "StartupWMClass", uri.delimit (":.\\/", '_'));
-
- return keyfile.to_data();
- }
-
- internal static File get_app_folder () {
- var data_dir = File.new_for_path (Midori.Paths.get_user_data_dir ()).get_child (PACKAGE_NAME);
- return data_dir.get_child ("apps");
- }
-
- internal static async File create_app (string uri, string title, Gtk.Widget? proxy) {
- string checksum = Checksum.compute_for_string (ChecksumType.MD5, uri, -1);
- var folder = get_app_folder ();
- yield Launcher.create (APP_PREFIX, folder.get_child (checksum),
- uri, title, proxy);
- return folder.get_child (checksum);
- }
-
- internal static File get_profile_folder () {
- var data_dir = File.new_for_path (Midori.Paths.get_user_data_dir ()).get_child (PACKAGE_NAME);
- return data_dir.get_child ("profiles");
- }
-
- internal static async File create_profile (Gtk.Widget? proxy) {
- string uuid = g_dbus_generate_guid ();
- string config = Path.build_path (Path.DIR_SEPARATOR_S,
- Midori.Paths.get_user_data_dir (), PACKAGE_NAME, "profiles", uuid);
- var folder = get_profile_folder ();
- yield Launcher.create (PROFILE_PREFIX, folder.get_child (uuid),
- config, _("Midori (%s)").printf (uuid), proxy);
- return folder.get_child (uuid);
- }
-
- internal static async void create (string prefix, GLib.File folder, string uri, string title, Gtk.Widget proxy) {
- /* Strip LRE leading character and / */
- string name = title.delimit ("‪/", ' ').strip();
- string filename = Midori.Download.clean_filename (name);
- string icon_name = Midori.Stock.WEB_BROWSER;
- bool testing = false;
- if (proxy == null)
- testing = true;
- var file = folder.get_child ("desc");
-
- try {
- folder.make_directory_with_parents (null);
- } catch (IOError.EXISTS exist_error) {
- /* It's no error if the folder already exists */
- } catch (Error error) {
- warning (_("Failed to create new launcher (%s): %s"), file.get_path (), error.message);
- }
-
- icon_name = get_favicon_name_for_uri (prefix, folder, uri, testing);
- string desktop_file = prepare_desktop_file (prefix, name, uri, title, icon_name);
-
- try {
- var stream = yield file.replace_async (null, false, GLib.FileCreateFlags.NONE);
- yield stream.write_async (desktop_file.data);
- // Create a launcher/ menu
-#if HAVE_WIN32
- Midori.Sokoke.create_win32_desktop_lnk (prefix, filename, uri);
-#else
- var data_dir = File.new_for_path (Midori.Paths.get_user_data_dir ());
- var desktop_dir = data_dir.get_child ("applications");
- try {
- desktop_dir.make_directory_with_parents (null);
- } catch (IOError.EXISTS exist_error) {
- /* It's no error if the folder already exists */
- }
-
- yield file.copy_async (desktop_dir.get_child (filename + ".desktop"),
- GLib.FileCopyFlags.NONE);
-#endif
- if (proxy != null) {
- var browser = proxy.get_toplevel () as Midori.Browser;
- browser.send_notification (_("Launcher created"),
- _("You can now run <b>%s</b> from your launcher or menu").printf (name));
- }
- }
- catch (Error error) {
- warning (_("Failed to create new launcher (%s): %s"), file.get_path (), error.message);
- if (proxy != null) {
- var browser = proxy.get_toplevel () as Midori.Browser;
- browser.send_notification (_("Error creating launcher"),
- _("Failed to create new launcher (%s): %s").printf (file.get_path (), error.message));
- }
- }
- }
-
- internal Launcher (GLib.File file) {
- this.file = file;
- }
-
- bool init (GLib.Cancellable? cancellable) throws GLib.Error {
- var keyfile = new GLib.KeyFile ();
- try {
- keyfile.load_from_file (file.get_child ("desc").get_path (), GLib.KeyFileFlags.NONE);
- } catch (Error desc_error) {
- throw new FileError.EXIST (_("No file \"desc\" found"));
- }
-
- exec = keyfile.get_string ("Desktop Entry", "Exec");
- if (!exec.has_prefix (APP_PREFIX) && !exec.has_prefix (PROFILE_PREFIX))
- return false;
-
- name = keyfile.get_string ("Desktop Entry", "Name");
- icon_name = keyfile.get_string ("Desktop Entry", "Icon");
- uri = exec.replace (APP_PREFIX, "").replace (PROFILE_PREFIX, "");
- return true;
- }
- }
-
- private class Sidebar : Gtk.VBox, Midori.Viewable {
- Gtk.Toolbar? toolbar = null;
- Gtk.ListStore store = new Gtk.ListStore (1, typeof (Launcher));
- Gtk.TreeView treeview;
- Katze.Array array;
- GLib.File app_folder;
- GLib.File profile_folder;
-
- public unowned string get_stock_id () {
- return Midori.Stock.WEB_BROWSER;
- }
-
- public unowned string get_label () {
- return _("Applications");
- }
-
- public Gtk.Widget get_toolbar () {
- if (toolbar == null) {
- toolbar = new Gtk.Toolbar ();
-
- var profile = new Gtk.ToolButton.from_stock (Gtk.STOCK_ADD);
- profile.label = _("New _Profile");
- profile.tooltip_text = _("Creates a new, independent profile and a launcher");
- profile.use_underline = true;
- profile.is_important = true;
- profile.show ();
- profile.clicked.connect (() => {
- Launcher.create_profile.begin (this);
- });
- toolbar.insert (profile, -1);
-
- var app = new Gtk.ToolButton.from_stock (Gtk.STOCK_ADD);
- app.label = _("New _App");
- app.tooltip_text = _("Creates a new app for a specific site");
- app.use_underline = true;
- app.is_important = true;
- app.show ();
- app.clicked.connect (() => {
- var view = (get_toplevel () as Midori.Browser).tab as Midori.View;
- string checksum = Checksum.compute_for_string (ChecksumType.MD5, view.get_display_uri (), -1);
- Launcher.create.begin (APP_PREFIX, app_folder.get_child (checksum),
- view.get_display_uri (), view.get_display_title (), this);
- });
- toolbar.insert (app, -1);
- }
- return toolbar;
- }
-
- void row_activated (Gtk.TreePath path, Gtk.TreeViewColumn column) {
- Gtk.TreeIter iter;
- if (store.get_iter (out iter, path)) {
- Launcher launcher;
- store.get (iter, 0, out launcher);
- try {
- GLib.Process.spawn_command_line_async (launcher.exec);
- }
- catch (Error error) {
- var browser = get_toplevel () as Midori.Browser;
- browser.send_notification (_("Error launching"), error.message);
- }
- }
- }
-
- bool button_released (Gdk.EventButton event) {
- Gtk.TreePath? path;
- Gtk.TreeViewColumn column;
- if (event.button != 1)
- return false;
- if (treeview.get_path_at_pos ((int)event.x, (int)event.y, out path, out column, null, null)) {
- if (path != null) {
- if (column == treeview.get_column (2)) {
- Gtk.TreeIter iter;
- if (store.get_iter (out iter, path)) {
- Launcher launcher;
- store.get (iter, 0, out launcher);
- try {
- launcher.file.trash (null);
- store.remove (iter);
-
- string filename = Midori.Download.clean_filename (launcher.name);
-#if HAVE_WIN32
- string lnk_filename = Midori.Sokoke.get_win32_desktop_lnk_path_for_filename (filename);
- if (GLib.FileUtils.test (lnk_filename, GLib.FileTest.EXISTS)) {
- var lnk_file = File.new_for_path (lnk_filename);
- lnk_file.trash ();
- }
-#else
- var data_dir = File.new_for_path (Midori.Paths.get_user_data_dir ());
- data_dir.get_child ("applications").get_child (filename + ".desktop").trash ();
-#endif
- }
- catch (Error error) {
- GLib.critical ("Failed to remove launcher (%s): %s", launcher.file.get_path (), error.message);
- }
- return true;
- }
- }
- }
- }
- return false;
- }
-
- public Sidebar (Katze.Array array, GLib.File app_folder, GLib.File profile_folder) {
- Gtk.TreeViewColumn column;
-
- treeview = new Gtk.TreeView.with_model (store);
- treeview.headers_visible = false;
-
- store.set_sort_column_id (0, Gtk.SortType.ASCENDING);
- store.set_sort_func (0, tree_sort_func);
-
- column = new Gtk.TreeViewColumn ();
- Gtk.CellRendererPixbuf renderer_icon = new Gtk.CellRendererPixbuf ();
- column.pack_start (renderer_icon, false);
- column.set_cell_data_func (renderer_icon, on_render_icon);
- treeview.append_column (column);
-
- column = new Gtk.TreeViewColumn ();
- column.set_sizing (Gtk.TreeViewColumnSizing.AUTOSIZE);
- Gtk.CellRendererText renderer_text = new Gtk.CellRendererText ();
- column.pack_start (renderer_text, true);
- column.set_expand (true);
- column.set_cell_data_func (renderer_text, on_render_text);
- treeview.append_column (column);
-
- column = new Gtk.TreeViewColumn ();
- Gtk.CellRendererPixbuf renderer_button = new Gtk.CellRendererPixbuf ();
- column.pack_start (renderer_button, false);
- column.set_cell_data_func (renderer_button, on_render_button);
- treeview.append_column (column);
-
- treeview.row_activated.connect (row_activated);
- treeview.button_release_event.connect (button_released);
- treeview.show ();
- pack_start (treeview, true, true, 0);
-
- this.array = array;
- array.add_item.connect (launcher_added);
- array.remove_item.connect (launcher_removed);
- foreach (GLib.Object item in array.get_items ())
- launcher_added (item);
-
- this.app_folder = app_folder;
- this.profile_folder = profile_folder;
- }
-
- private int tree_sort_func (Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b) {
- Launcher launcher1, launcher2;
- model.get (a, 0, out launcher1);
- model.get (b, 0, out launcher2);
- return strcmp (launcher1.name, launcher2.name);
- }
- void launcher_added (GLib.Object item) {
- var launcher = item as Launcher;
- Gtk.TreeIter iter;
- store.append (out iter);
- store.set (iter, 0, launcher);
- }
-
- void launcher_removed (GLib.Object item) {
- // TODO remove iter
- }
-
- private void on_render_icon (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- Launcher launcher;
- model.get (iter, 0, out launcher);
-
- try {
- int icon_width = 48, icon_height = 48;
- Gtk.icon_size_lookup_for_settings (get_settings (),
- Gtk.IconSize.DIALOG, out icon_width, out icon_height);
- var pixbuf = new Gdk.Pixbuf.from_file_at_size (launcher.icon_name, icon_width, icon_height);
- renderer.set ("pixbuf", pixbuf);
- }
- catch (Error error) {
- renderer.set ("icon-name", launcher.icon_name);
- }
- renderer.set ("stock-size", Gtk.IconSize.DIALOG,
- "xpad", 4);
- }
-
- private void on_render_text (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- Launcher launcher;
- model.get (iter, 0, out launcher);
- renderer.set ("markup",
- Markup.printf_escaped ("<b>%s</b>\n%s",
- launcher.name, launcher.uri),
- "ellipsize", Pango.EllipsizeMode.END);
- }
-
- void on_render_button (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- renderer.set ("stock-id", Gtk.STOCK_DELETE,
- "stock-size", Gtk.IconSize.MENU);
- }
- }
-
- private class Manager : Midori.Extension {
- internal Katze.Array array;
- internal GLib.File app_folder;
- internal GLib.File profile_folder;
- internal GLib.List<GLib.FileMonitor> monitors;
- internal GLib.List<Gtk.Widget> widgets;
-
- void app_changed (GLib.File file, GLib.File? other, GLib.FileMonitorEvent event) {
- try {
- switch (event) {
- case GLib.FileMonitorEvent.DELETED:
- // TODO array.remove_item ();
- break;
- case GLib.FileMonitorEvent.CREATED:
- var launcher = new Launcher (file);
- if (launcher.init ())
- array.add_item (launcher);
- break;
- case GLib.FileMonitorEvent.CHANGED:
- // TODO
- break;
- }
- }
- catch (Error error) {
- warning ("Application changed (%s): %s", file.get_path (), error.message);
- }
- }
-
- async void populate_apps (File app_folder) {
- try {
- try {
- app_folder.make_directory_with_parents (null);
- } catch (IOError.EXISTS exist_error) {
- /* It's no error if the folder already exists */
- }
-
- var monitor = app_folder.monitor_directory (0, null);
- monitor.changed.connect (app_changed);
- monitors.append (monitor);
-
- var enumerator = yield app_folder.enumerate_children_async ("standard::name", 0);
- while (true) {
- var files = yield enumerator.next_files_async (10);
- if (files == null)
- break;
- foreach (var info in files) {
- var file = app_folder.get_child (info.get_name ());
- try {
- var launcher = new Launcher (file);
- if (launcher.init ())
- array.add_item (launcher);
- }
- catch (Error error) {
- warning ("Failed to parse launcher (%s): %s", file.get_path (), error.message);
- }
- }
- }
- }
- catch (Error io_error) {
- warning ("Failed to list apps (%s): %s",
- app_folder.get_path (), io_error.message);
- }
- }
-
- void browser_added (Midori.Browser browser) {
- var accels = new Gtk.AccelGroup ();
- browser.add_accel_group (accels);
- var action_group = browser.get_action_group ();
-
- var action = new Gtk.Action ("CreateLauncher", _("Create _Launcher"),
- _("Creates a new app for a specific site"), null);
- action.activate.connect (() => {
- var view = browser.tab as Midori.View;
- Launcher.create_app.begin (view.get_display_uri (), view.get_display_title (), view);
- });
- action_group.add_action_with_accel (action, "<Ctrl><Shift>A");
- action.set_accel_group (accels);
- action.connect_accelerator ();
-
- var viewable = new Sidebar (array, app_folder, profile_folder);
- viewable.show ();
- browser.panel.append_page (viewable);
- widgets.append (viewable);
- }
-
- void activated (Midori.App app) {
- array = new Katze.Array (typeof (Launcher));
- monitors = new GLib.List<GLib.FileMonitor> ();
- app_folder = Launcher.get_app_folder ();
- populate_apps.begin (app_folder);
- profile_folder = Launcher.get_profile_folder ();
- populate_apps.begin (profile_folder);
- widgets = new GLib.List<Gtk.Widget> ();
- foreach (var browser in app.get_browsers ())
- browser_added (browser);
- app.add_browser.connect (browser_added);
- }
-
- void deactivated () {
- var app = get_app ();
- foreach (var monitor in monitors)
- monitor.changed.disconnect (app_changed);
- monitors = null;
-
- app.add_browser.disconnect (browser_added);
- foreach (var widget in widgets)
- widget.destroy ();
- foreach (var browser in app.get_browsers ()) {
- var action_group = browser.get_action_group ();
- var action = action_group.get_action ("CreateLauncher");
- action_group.remove_action (action);
- }
-
- }
-
- internal Manager () {
- GLib.Object (name: _("Web App Manager"),
- description: _("Manage websites installed as applications"),
- version: "0.1" + Midori.VERSION_SUFFIX,
- authors: "Christian Dywan <christian@twotoasts.de>");
-
- this.activate.connect (activated);
- this.deactivate.connect (deactivated);
- }
- }
-}
-
-public Midori.Extension extension_init () {
- return new Apps.Manager ();
-}
-
-class ExtensionsAppsDesktop : Midori.Test.Job {
- public static void test () { new ExtensionsAppsDesktop ().run_sync (); }
- public override async void run (Cancellable cancellable) throws GLib.Error {
- string uri = "http://example.com";
- string checksum = Checksum.compute_for_string (ChecksumType.MD5, uri, -1);
- var apps = Apps.Launcher.get_app_folder ().get_child (checksum);
- Midori.Paths.remove_path (apps.get_path ());
-
- var data_dir = File.new_for_path (Midori.Paths.get_user_data_dir ());
- var desktop_dir = data_dir.get_child ("applications");
- Midori.Paths.remove_path (desktop_dir.get_child ("Example.desktop").get_path ());
-
- var folder = yield Apps.Launcher.create_app (uri, "Example", null);
- var launcher = new Apps.Launcher (folder);
- launcher.init ();
- Katze.assert_str_equal (folder.get_path (), launcher.uri, uri);
- yield Apps.Launcher.create_profile (null);
- }
-}
-
-public void extension_test () {
- Test.add_func ("/extensions/apps/desktop", ExtensionsAppsDesktop.test);
-}
-
diff --git a/extensions/colorful-tabs.c b/extensions/colorful-tabs.c
deleted file mode 100644
index 1f201ef9..00000000
--- a/extensions/colorful-tabs.c
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- Copyright (C) 2009-2013 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2010 Samuel Creshal <creshal@arcor.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.
-*/
-
-#include <midori/midori.h>
-
-static void
-get_foreground_color_for_GdkColor (GdkColor* color,
- GdkColor* fgcolor)
-{
- gfloat brightness, r, g, b;
-
- r = color->red / 255;
- g = color->green / 255;
- b = color->blue / 255;
-
- /* For math used see algorithms for converting from rgb to yuv */
- brightness = 0.299 * r + 0.587 * g + 0.114 * b;
-
- /* Ensure high contrast by enforcing black/ white text colour. */
- /* Brigthness (range 0-255) equals value of y from YUV color space. */
- if (brightness < 128)
- gdk_color_parse ("white", fgcolor);
- else
- gdk_color_parse ("black", fgcolor);
-}
-
-static void
-adjust_brightness (GdkColor* color)
-{
- guint dark_grey = 137 * 255;
- guint adjustment = 78 * 255;
- guint blue = 39 * 255;
- guint readjust = 19 * 255;
-
- if ((color->red < dark_grey)
- && (color->green < dark_grey)
- && (color->blue < dark_grey))
- {
- color->red += adjustment;
- color->green += adjustment;
- color->blue += adjustment;
- }
-
- if (color->red < blue)
- color->red = readjust;
- else
- color->red -= readjust;
-
- if (color->blue < blue)
- color->blue = readjust;
- else
- color->blue -= readjust;
-
- if (color->green < blue)
- color->green = readjust;
- else
- color->green -= readjust;
-}
-
-static void
-view_get_bgcolor_for_favicon (GdkPixbuf* icon,
- GdkColor* color)
-{
- GdkPixbuf* newpix;
- guchar* pixels;
-
- newpix = gdk_pixbuf_scale_simple (icon, 1, 1, GDK_INTERP_BILINEAR);
-
- // Sometimes gdk_pixbuf_scale may fail, return gracefully
- g_return_if_fail (newpix != NULL);
-
- pixels = gdk_pixbuf_get_pixels (newpix);
- color->red = pixels[0] * 255;
- color->green = pixels[1] * 255;
- color->blue = pixels[2] * 255;
-
- adjust_brightness (color);
-}
-
-static void
-view_get_bgcolor_for_hostname (gchar* hostname,
- GdkColor* color)
-{
- gchar* hash, *colorstr;
-
- hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, hostname, 1);
- colorstr = g_strndup (hash, 6 + 1);
- colorstr[0] = '#';
- gdk_color_parse (colorstr, color);
-
- g_free (hash);
- g_free (colorstr);
-
- adjust_brightness (color);
-}
-
-static void
-colorful_tabs_view_notify_uri_cb (MidoriView* view,
- GParamSpec* pspec,
- MidoriExtension* extension)
-{
- const gchar* uri = midori_view_get_display_uri (view);
- if (!*uri)
- return;
-
- if (!midori_uri_is_blank (uri))
- {
- gchar* hostname = midori_uri_parse_hostname (uri, NULL);
- if (hostname)
- {
- GdkColor fgcolor, color;
- GdkPixbuf* icon = midori_view_get_icon (view);
-
- if (icon)
- view_get_bgcolor_for_favicon (icon, &color);
- else
- view_get_bgcolor_for_hostname (hostname, &color);
-
- get_foreground_color_for_GdkColor (&color, &fgcolor);
- midori_view_set_colors (view, &fgcolor, &color);
-
- g_free (hostname);
- }
- }
- else
- midori_view_set_colors (view, NULL, NULL);
-}
-
-static void
-colorful_tabs_browser_add_tab_cb (MidoriBrowser* browser,
- GtkWidget* view,
- MidoriExtension* extension)
-{
- colorful_tabs_view_notify_uri_cb (MIDORI_VIEW (view), NULL, extension);
- g_signal_connect (view, "notify::icon",
- G_CALLBACK (colorful_tabs_view_notify_uri_cb), extension);
-}
-
-static void
-colorful_tabs_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension);
-
-static void
-colorful_tabs_deactivate_cb (MidoriExtension* extension,
- MidoriBrowser* browser)
-{
- GList* children;
- MidoriApp* app = midori_extension_get_app (extension);
-
- g_signal_handlers_disconnect_by_func (
- app, colorful_tabs_app_add_browser_cb, extension);
- g_signal_handlers_disconnect_by_func (
- browser, colorful_tabs_browser_add_tab_cb, extension);
- g_signal_handlers_disconnect_by_func (
- extension, colorful_tabs_deactivate_cb, browser);
-
- children = midori_browser_get_tabs (MIDORI_BROWSER (browser));
- for (; children; children = g_list_next (children))
- {
- midori_view_set_colors (children->data, NULL, NULL);
- g_signal_handlers_disconnect_by_func (
- children->data, colorful_tabs_view_notify_uri_cb, extension);
- }
- g_list_free (children);
-}
-
-static void
-colorful_tabs_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension)
-{
- GList* children;
-
- children = midori_browser_get_tabs (MIDORI_BROWSER (browser));
- for (; children; children = g_list_next (children))
- colorful_tabs_browser_add_tab_cb (browser, children->data, extension);
- g_list_free (children);
-
- g_signal_connect (browser, "add-tab",
- G_CALLBACK (colorful_tabs_browser_add_tab_cb), extension);
- g_signal_connect (extension, "deactivate",
- G_CALLBACK (colorful_tabs_deactivate_cb), browser);
-}
-
-
-static void
-colorful_tabs_activate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- KatzeArray* browsers;
- MidoriBrowser* browser;
-
- browsers = katze_object_get_object (app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- colorful_tabs_app_add_browser_cb (app, browser, extension);
- g_signal_connect (app, "add-browser",
- G_CALLBACK (colorful_tabs_app_add_browser_cb), extension);
-
- g_object_unref (browsers);
-}
-
-void test_colour_for_hostname (void)
-{
- GdkColor color;
- GdkColor fgcolor;
-
- typedef struct
- {
- const gchar* host;
- const gchar* fgcolor;
- const gchar* color;
- } ColorItem;
-
- static const ColorItem items[] = {
- { "www.last.fm", "#ffffffffffff", "#12ed7da312ed" },
- { "git.xfce.org", "#ffffffffffff", "#1c424c72e207" },
- { "elementaryos.org", "#000000000000", "#50dbac36b43e" },
- { "news.ycombinator.com", "#000000000000", "#a5cba6cc5278" },
- { "cgit.freedesktop.org", "#000000000000", "#95bb8db37ca2" },
- { "get.cm", "#ffffffffffff", "#1c424c72e207" },
- };
-
- guint i;
- for (i = 0; i < G_N_ELEMENTS (items); i++)
- {
- view_get_bgcolor_for_hostname ((gchar*)items[i].host, &color);
- get_foreground_color_for_GdkColor (&color, &fgcolor);
-
- g_assert_cmpstr (items[i].color, ==, gdk_color_to_string (&color));
- g_assert_cmpstr (items[i].fgcolor, ==, gdk_color_to_string (&fgcolor));
- }
-}
-
-void
-extension_test (void)
-{
- #ifndef HAVE_WEBKIT2
- g_object_set_data (G_OBJECT (webkit_get_default_session ()),
- "midori-session-initialized", (void*)1);
- #endif
-
- /* TODO: Add test which uses favicon codepath */
-
- g_test_add_func ("/extensions/colorful_tabs/hostname_colour", test_colour_for_hostname);
-}
-
-MidoriExtension*
-extension_init (void)
-{
- MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", _("Colorful Tabs"),
- "description", _("Tint each tab distinctly"),
- "version", "0.5" MIDORI_VERSION_SUFFIX,
- "authors", "Christian Dywan <christian@twotoasts.de>, Samuel Creshal <creshal@arcor.de>",
- NULL);
-
- g_signal_connect (extension, "activate",
- G_CALLBACK (colorful_tabs_activate_cb), NULL);
-
- return extension;
-}
diff --git a/extensions/cookie-manager/cookie-manager-page.c b/extensions/cookie-manager/cookie-manager-page.c
deleted file mode 100644
index b42a219f..00000000
--- a/extensions/cookie-manager/cookie-manager-page.c
+++ /dev/null
@@ -1,1159 +0,0 @@
-/*
- Copyright (C) 2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)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.
-*/
-
-#include <gdk/gdkkeysyms.h>
-
-#include <midori/midori.h>
-#include "katze/katze.h"
-#include <time.h>
-
-#include "cookie-manager.h"
-#include "cookie-manager-page.h"
-
-#define CM_EMPTY_LABEL_TEXT "\n\n\n\n\n\n"
-
-
-struct _CookieManagerPagePrivate
-{
- CookieManager *parent;
-
- GtkWidget *treeview;
- GtkTreeStore *store;
- GtkTreeModel *filter;
-
- GtkWidget *filter_entry;
- gboolean ignore_changed_filter;
-
- GtkWidget *desc_label;
- GtkWidget *delete_button;
- GtkWidget *delete_popup_button;
- GtkWidget *delete_all_button;
- GtkWidget *expand_buttons[4];
-
- GtkWidget *toolbar;
- GtkWidget *popup_menu;
-};
-
-enum
-{
- PROP_0,
- PROP_STORE,
- PROP_PARENT
-};
-
-
-static void cookie_manager_page_finalize(GObject *object);
-static void cookie_manager_page_viewable_iface_init(MidoriViewableIface *iface);
-
-static void cm_button_delete_clicked_cb(GtkToolButton *button, CookieManagerPage *cmp);
-static void cm_button_delete_all_clicked_cb(GtkToolButton *button, CookieManagerPage *cmp);
-static void cm_tree_popup_collapse_activate_cb(GtkMenuItem *item, CookieManagerPage *cmp);
-static void cm_tree_popup_expand_activate_cb(GtkMenuItem *item, CookieManagerPage *cmp);
-static void cm_filter_tree(CookieManagerPage *cmp, const gchar *filter_text);
-
-typedef void (*CMPathWalkFunc) (GtkTreePath *path);
-
-
-G_DEFINE_TYPE_WITH_CODE(CookieManagerPage, cookie_manager_page, GTK_TYPE_VBOX,
- G_IMPLEMENT_INTERFACE(MIDORI_TYPE_VIEWABLE,
- cookie_manager_page_viewable_iface_init));
-
-
-
-static const gchar *cookie_manager_page_get_label(MidoriViewable *viewable)
-{
- return _("Cookie Manager");
-}
-
-
-static const gchar *cookie_manager_page_get_stock_id(MidoriViewable *viewable)
-{
- return GTK_STOCK_DIALOG_AUTHENTICATION;
-}
-
-
-static void cm_create_toolbar(CookieManagerPage *cmp)
-{
- CookieManagerPagePrivate *priv = cmp->priv;
- GtkWidget *toolbar;
- GtkToolItem *toolitem;
-
- priv->toolbar = toolbar = gtk_toolbar_new();
- toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_DELETE);
- gtk_tool_item_set_is_important(toolitem, TRUE);
- g_signal_connect(toolitem, "clicked", G_CALLBACK(cm_button_delete_clicked_cb), cmp);
- gtk_widget_show(GTK_WIDGET(toolitem));
- gtk_widget_set_sensitive(GTK_WIDGET(toolitem), FALSE);
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
- priv->delete_button = GTK_WIDGET(toolitem);
-
- toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_DELETE);
- gtk_tool_button_set_label(GTK_TOOL_BUTTON(toolitem), _("Delete All"));
- gtk_tool_item_set_tooltip_text(toolitem,
- _("Deletes all shown cookies. "
- "If a filter is set, only those cookies are deleted which match the filter."));
- gtk_tool_item_set_is_important(toolitem, TRUE);
- g_signal_connect(toolitem, "clicked", G_CALLBACK(cm_button_delete_all_clicked_cb), cmp);
- gtk_widget_show(GTK_WIDGET(toolitem));
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
- priv->delete_all_button = GTK_WIDGET(toolitem);
-
- toolitem = gtk_separator_tool_item_new();
- gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(toolitem), FALSE);
- gtk_tool_item_set_expand(toolitem, TRUE);
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
- gtk_widget_show(GTK_WIDGET(toolitem));
-
- toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_ADD);
- gtk_tool_item_set_tooltip_text(toolitem, _("Expand All"));
- g_signal_connect(toolitem, "clicked", G_CALLBACK(cm_tree_popup_expand_activate_cb), cmp);
- gtk_widget_show(GTK_WIDGET(toolitem));
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
- priv->expand_buttons[0] = GTK_WIDGET(toolitem);
-
- toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_REMOVE);
- gtk_tool_item_set_tooltip_text(toolitem, _("Collapse All"));
- g_signal_connect(toolitem, "clicked", G_CALLBACK(cm_tree_popup_collapse_activate_cb), cmp);
- gtk_widget_show(GTK_WIDGET(toolitem));
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
- priv->expand_buttons[1] = GTK_WIDGET(toolitem);
-}
-
-
-static GtkWidget *cookie_manager_page_get_toolbar(MidoriViewable *viewable)
-{
- CookieManagerPage *cmp = COOKIE_MANAGER_PAGE(viewable);
- CookieManagerPagePrivate *priv = cmp->priv;
-
- return priv->toolbar;
-}
-
-
-static void cookie_manager_page_viewable_iface_init(MidoriViewableIface* iface)
-{
- iface->get_stock_id = cookie_manager_page_get_stock_id;
- iface->get_label = cookie_manager_page_get_label;
- iface->get_toolbar = cookie_manager_page_get_toolbar;
-}
-
-
-static void cookie_manager_page_pre_cookies_change_cb(CookieManager *cm, CookieManagerPage *cmp)
-{
- CookieManagerPagePrivate *priv = cmp->priv;
-
- g_object_ref(priv->filter);
- gtk_tree_view_set_model(GTK_TREE_VIEW(priv->treeview), NULL);
-}
-
-
-static void cookie_manager_page_cookies_changed_cb(CookieManager *cm, CookieManagerPage *cmp)
-{
- const gchar *filter_text;
- CookieManagerPagePrivate *priv = cmp->priv;
-
- gtk_tree_view_set_model(GTK_TREE_VIEW(priv->treeview), GTK_TREE_MODEL(priv->filter));
- g_object_unref(priv->filter);
-
- /* if a filter is set, apply it again but ignore the place holder text */
- if (!g_object_get_data (G_OBJECT (priv->filter_entry), "sokoke_showing_default"))
- {
- filter_text = gtk_entry_get_text(GTK_ENTRY(priv->filter_entry));
- if (*filter_text != '\0')
- {
- cm_filter_tree(cmp, filter_text);
- gtk_tree_view_expand_all(GTK_TREE_VIEW(priv->treeview));
- }
- }
-}
-
-
-static void cookie_manager_page_filter_changed_cb(CookieManager *cm, const gchar *text,
- CookieManagerPage *cmp)
-{
- CookieManagerPagePrivate *priv = cmp->priv;
-
- priv->ignore_changed_filter = TRUE;
- gtk_entry_set_text(GTK_ENTRY(priv->filter_entry), text);
- priv->ignore_changed_filter = FALSE;
-}
-
-
-static void cookie_manager_page_finalize(GObject *object)
-{
- CookieManagerPage *cmp = COOKIE_MANAGER_PAGE(object);
- CookieManagerPagePrivate *priv = cmp->priv;
-
- gtk_widget_destroy(priv->popup_menu);
-
- g_signal_handlers_disconnect_by_func(priv->parent,
- cookie_manager_page_pre_cookies_change_cb, object);
- g_signal_handlers_disconnect_by_func(priv->parent,
- cookie_manager_page_cookies_changed_cb, object);
- g_signal_handlers_disconnect_by_func(priv->parent,
- cookie_manager_page_filter_changed_cb, object);
-
- G_OBJECT_CLASS(cookie_manager_page_parent_class)->finalize(object);
-}
-
-
-static void cookie_manager_page_set_property(GObject *object, guint prop_id, const GValue *value,
- GParamSpec *pspec)
-{
- CookieManagerPage *cmp = COOKIE_MANAGER_PAGE(object);
- CookieManagerPagePrivate *priv = cmp->priv;
- switch (prop_id)
- {
- case PROP_STORE:
- {
- priv->store = g_value_get_object(value);
-
- /* setting filter and model */
- priv->filter = gtk_tree_model_filter_new(GTK_TREE_MODEL(priv->store), NULL);
- gtk_tree_model_filter_set_visible_column(GTK_TREE_MODEL_FILTER(priv->filter),
- COOKIE_MANAGER_COL_VISIBLE);
- gtk_tree_view_set_model(GTK_TREE_VIEW(priv->treeview), GTK_TREE_MODEL(priv->filter));
- g_object_unref(priv->filter);
- break;
- }
- case PROP_PARENT:
- {
- if (priv->parent != NULL)
- {
- g_signal_handlers_disconnect_by_func(priv->parent,
- cookie_manager_page_pre_cookies_change_cb, object);
- g_signal_handlers_disconnect_by_func(priv->parent,
- cookie_manager_page_cookies_changed_cb, object);
- g_signal_handlers_disconnect_by_func(priv->parent,
- cookie_manager_page_filter_changed_cb, object);
- }
- priv->parent = g_value_get_object(value);
-
- g_signal_connect(priv->parent, "pre-cookies-change",
- G_CALLBACK(cookie_manager_page_pre_cookies_change_cb), object);
- g_signal_connect(priv->parent, "cookies-changed",
- G_CALLBACK(cookie_manager_page_cookies_changed_cb), object);
- g_signal_connect(priv->parent, "filter-changed",
- G_CALLBACK(cookie_manager_page_filter_changed_cb), object);
- break;
- }
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-
-static void cookie_manager_page_class_init(CookieManagerPageClass *klass)
-{
- GObjectClass *g_object_class;
- g_object_class = G_OBJECT_CLASS(klass);
-
- g_object_class->finalize = cookie_manager_page_finalize;
- g_object_class->set_property = cookie_manager_page_set_property;
-
- g_object_class_install_property(g_object_class,
- PROP_STORE,
- g_param_spec_object(
- "store",
- "Treestore",
- "The tree store",
- GTK_TYPE_TREE_STORE,
- G_PARAM_WRITABLE));
-
- g_object_class_install_property(g_object_class,
- PROP_PARENT,
- g_param_spec_object(
- "parent",
- "Parent",
- "The CookieManager parent instance",
- COOKIE_MANAGER_TYPE,
- G_PARAM_WRITABLE));
-
- g_type_class_add_private(klass, sizeof(CookieManagerPagePrivate));
-}
-
-
-static void cm_set_button_sensitiveness(CookieManagerPage *cmp, gboolean set)
-{
- CookieManagerPagePrivate *priv = cmp->priv;
- gboolean expand_set = (gtk_tree_model_iter_n_children(priv->filter, NULL) > 0);
- guint i, len;
-
- gtk_widget_set_sensitive(priv->delete_popup_button, set);
- gtk_widget_set_sensitive(priv->delete_button, set);
-
- gtk_widget_set_sensitive(priv->delete_all_button, expand_set);
- len = G_N_ELEMENTS(priv->expand_buttons);
- for (i = 0; i < len; i++)
- {
- gtk_widget_set_sensitive(priv->expand_buttons[i], expand_set);
- }
-}
-
-
-static void cm_free_selection_list(GList *rows, GFunc func)
-{
- g_list_foreach(rows, func, NULL);
- g_list_free(rows);
-}
-
-
-/* Fast version of g_list_length(). It only checks for the first few elements of
- * the list and returns the length 0, 1 or 2 where 2 means 2 elements or more. */
-static gint cm_list_length(GList *list)
-{
- if (list == NULL)
- return 0;
- else if (list->next == NULL)
- return 1;
- else if (list->next != NULL)
- return 2;
-
- return 0; /* safe default */
-}
-
-
-static void cm_tree_popup_collapse_activate_cb(GtkMenuItem *item, CookieManagerPage *cmp)
-{
- CookieManagerPagePrivate *priv = cmp->priv;
-
- gtk_tree_view_collapse_all(GTK_TREE_VIEW(priv->treeview));
-}
-
-
-static void cm_tree_popup_expand_activate_cb(GtkMenuItem *item, CookieManagerPage *cmp)
-{
- CookieManagerPagePrivate *priv = cmp->priv;
-
- gtk_tree_view_expand_all(GTK_TREE_VIEW(priv->treeview));
-}
-
-
-static void cm_store_remove(CookieManagerPage *cmp, GtkTreeIter *iter_model)
-{
- GtkTreeIter iter_store;
- CookieManagerPagePrivate *priv = cmp->priv;
-
- gtk_tree_model_filter_convert_iter_to_child_iter(
- GTK_TREE_MODEL_FILTER(priv->filter), &iter_store, iter_model);
- gtk_tree_store_remove(priv->store, &iter_store);
-}
-
-
-static void cm_delete_cookie(CookieManagerPage *cmp, GtkTreeModel *model, GtkTreeIter *child)
-{
- SoupCookie *cookie;
- CookieManagerPagePrivate *priv = cmp->priv;
-
- gtk_tree_model_get(model, child, COOKIE_MANAGER_COL_COOKIE, &cookie, -1);
-
- cookie_manager_delete_cookie(priv->parent, cookie);
-}
-
-
-static gboolean cm_try_to_select(CMPathWalkFunc path_func, GtkTreeSelection *selection,
- GtkTreeModel *model, GtkTreePath *path)
-{
- GtkTreeIter iter;
-
- if (gtk_tree_path_get_depth(path) <= 0) /* sanity check */
- return FALSE;
-
- /* modify the path using the passed function */
- if (path_func != NULL)
- path_func(path);
-
- if (gtk_tree_path_get_depth(path) <= 0) /* sanity check */
- return FALSE;
-
- /* check whether the path points to something valid and if so, select it */
- if (gtk_tree_model_get_iter(model, &iter, path))
- {
- GtkTreeView *treeview = gtk_tree_selection_get_tree_view(selection);
- gboolean was_expanded = gtk_tree_view_row_expanded(treeview, path);
- /* to get gtk_tree_selection_select_path() working, we need to expand the row first
- * if it isn't expanded yet, at least when the row is a parent item */
- if (! was_expanded)
- gtk_tree_view_expand_to_path(treeview, path);
-
- gtk_tree_selection_select_path(selection, path);
-
- if (! was_expanded) /* restore the previous state */
- gtk_tree_view_collapse_row(treeview, path);
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-/* select an item after deletion */
-static void cm_select_path(CookieManagerPage *cmp, GtkTreeModel *model, GtkTreePath *path)
-{
- CookieManagerPagePrivate *priv = cmp->priv;
- GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview));
- CMPathWalkFunc path_funcs[] = {
- (CMPathWalkFunc) gtk_tree_path_prev, (CMPathWalkFunc) gtk_tree_path_up,
- (CMPathWalkFunc) gtk_tree_path_next, NULL };
- CMPathWalkFunc *path_func;
-
- /* first try selecting the item directly to which path points */
- if (! cm_try_to_select(NULL, selection, model, path))
- { /* if this failed, modify the path until we found something valid */
- path_func = path_funcs;
- while (*path_func != NULL)
- {
- if (cm_try_to_select(*path_func, selection, model, path))
- break;
- path_func++;
- }
- }
-}
-
-
-static void cm_delete_item(CookieManagerPage *cmp)
-{
- GtkTreeIter iter, iter_store, child;
- GtkTreeModel *model;
- GtkTreePath *path, *last_path;
- GtkTreeSelection *selection;
- GList *rows, *row;
- GList *refs = NULL;
- CookieManagerPagePrivate *priv = cmp->priv;
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview));
- rows = gtk_tree_selection_get_selected_rows(selection, &model);
- if (cm_list_length(rows) == 0)
- return;
-
- last_path = gtk_tree_path_copy(g_list_nth_data(rows, 0));
-
- /* as paths will change during delete, first create GtkTreeRowReferences for
- * all selected rows */
- row = rows;
- do
- {
- refs = g_list_append(refs, gtk_tree_row_reference_new(model, (GtkTreePath*) (row->data)));
- } while ((row = row->next) != NULL);
-
- row = refs;
- do
- {
- /* get iter */
- path = gtk_tree_row_reference_get_path((GtkTreeRowReference*) row->data);
- if (path == NULL)
- continue;
- gtk_tree_model_get_iter(model, &iter, path);
-
- if (gtk_tree_model_iter_has_child(model, &iter))
- {
- while (gtk_tree_model_iter_children(model, &child, &iter))
- {
- cm_delete_cookie(cmp, model, &child);
- cm_store_remove(cmp, &child);
- /* we retrieve again the iter at path because it got invalid by the delete operation */
- gtk_tree_model_get_iter(model, &iter, path);
- }
- /* remove/hide the parent */
- gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(priv->filter),
- &iter_store, &iter);
- if (gtk_tree_model_iter_has_child(GTK_TREE_MODEL(priv->store), &iter_store))
- gtk_tree_store_set(priv->store, &iter_store, COOKIE_MANAGER_COL_VISIBLE, FALSE, -1);
- else
- cm_store_remove(cmp, &iter);
- }
- else
- {
- GtkTreePath *path_store, *path_model;
-
- gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(priv->filter),
- &iter_store, &iter);
- path_store = gtk_tree_model_get_path(GTK_TREE_MODEL(priv->store), &iter_store);
- path_model = gtk_tree_model_get_path(model, &iter);
-
- cm_delete_cookie(cmp, model, &iter);
- gtk_tree_store_remove(priv->store, &iter_store);
-
- /* check whether the parent still has children, otherwise delete it */
- if (gtk_tree_path_up(path_store))
- {
- gtk_tree_model_get_iter(GTK_TREE_MODEL(priv->store), &iter_store, path_store);
- if (! gtk_tree_model_iter_has_child(GTK_TREE_MODEL(priv->store), &iter_store))
- /* remove the empty parent */
- gtk_tree_store_remove(priv->store, &iter_store);
- }
- /* now for the filter model */
- if (gtk_tree_path_up(path_model))
- {
- gtk_tree_model_get_iter(model, &iter, path_model);
- if (! gtk_tree_model_iter_has_child(model, &iter))
- {
- gtk_tree_model_filter_convert_iter_to_child_iter(
- GTK_TREE_MODEL_FILTER(priv->filter), &iter_store, &iter);
- /* hide the empty parent */
- gtk_tree_store_set(priv->store, &iter_store, COOKIE_MANAGER_COL_VISIBLE, FALSE, -1);
- }
- }
- gtk_tree_path_free(path_store);
- gtk_tree_path_free(path_model);
- }
- gtk_tree_path_free(path);
- } while ((row = row->next) != NULL);
- cm_free_selection_list(rows, (GFunc) gtk_tree_path_free);
- cm_free_selection_list(refs, (GFunc) gtk_tree_row_reference_free);
-
- cm_select_path(cmp, model, last_path);
- gtk_tree_path_free(last_path);
-}
-
-
-static void cm_button_delete_clicked_cb(GtkToolButton *button, CookieManagerPage *cmp)
-{
- cm_delete_item(cmp);
-}
-
-
-static void cm_delete_all_cookies_real(CookieManagerPage *cmp)
-{
- CookieManagerPagePrivate *priv = cmp->priv;
- GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(priv->treeview));
- GtkTreeIter iter, iter_store, child;
- GtkTreePath *path_first, *path;
-
- path_first = gtk_tree_path_new_first();
- while (gtk_tree_model_get_iter(model, &iter, path_first))
- {
- path = gtk_tree_model_get_path(model, &iter);
- while (gtk_tree_model_iter_children(model, &child, &iter))
- {
- cm_delete_cookie(cmp, model, &child);
- cm_store_remove(cmp, &child);
- /* we retrieve again the iter at path because it got invalid by the delete operation */
- gtk_tree_model_get_iter(model, &iter, path);
- }
- gtk_tree_path_free(path);
- /* remove/hide the parent */
- gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(priv->filter),
- &iter_store, &iter);
- if (gtk_tree_model_iter_has_child(GTK_TREE_MODEL(priv->store), &iter_store))
- gtk_tree_store_set(priv->store, &iter_store, COOKIE_MANAGER_COL_VISIBLE, FALSE, -1);
- else
- cm_store_remove(cmp, &iter);
- }
- /* now that we deleted all matching cookies, we reset the filter */
- gtk_entry_set_text(GTK_ENTRY(priv->filter_entry), "");
- cm_set_button_sensitiveness(cmp, FALSE);
-
- cm_select_path(cmp, model, path_first);
- gtk_tree_path_free(path_first);
-}
-
-
-static void cm_button_delete_all_clicked_cb(GtkToolButton *button, CookieManagerPage *cmp)
-{
- GtkWidget *dialog;
- const gchar *filter_text;
- MidoriBrowser *toplevel = midori_browser_get_for_widget(GTK_WIDGET(button));
- CookieManagerPagePrivate *priv = cmp->priv;
-
- dialog = gtk_message_dialog_new(GTK_WINDOW(toplevel),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_YES_NO,
- _("Do you really want to delete all cookies?"));
-
- gtk_window_set_title(GTK_WINDOW(dialog), _("Question"));
- /* steal Midori's icon :) */
- if (toplevel != NULL)
- gtk_window_set_icon_name(GTK_WINDOW(dialog), gtk_window_get_icon_name(GTK_WINDOW(toplevel)));
-
- if (!g_object_get_data (G_OBJECT (priv->filter_entry), "sokoke_showing_default"))
- {
- filter_text = gtk_entry_get_text(GTK_ENTRY(priv->filter_entry));
- if (*filter_text != '\0')
- {
- gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
- _("Only cookies which match the filter will be deleted."));
- }
- }
-
- if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES)
- cm_delete_all_cookies_real(cmp);
-
- gtk_widget_destroy(dialog);
-}
-
-
-static const gchar *cm_skip_leading_dot(const gchar *text)
-{
- return (*text == '.') ? text + 1 : text;
-}
-
-
-static void cm_tree_drag_data_get_cb(GtkWidget *widget, GdkDragContext *drag_context,
- GtkSelectionData *data, guint info, guint ltime,
- CookieManagerPage *cmp)
-{
- GtkTreeIter iter, iter_store;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GList *rows;
- CookieManagerPagePrivate *priv = cmp->priv;
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview));
- rows = gtk_tree_selection_get_selected_rows(selection, &model);
- if (cm_list_length(rows) != 1)
- {
- cm_free_selection_list(rows, (GFunc) gtk_tree_path_free);
- return;
- }
- /* get iter */
- gtk_tree_model_get_iter(model, &iter, (GtkTreePath*) (g_list_nth_data(rows, 0)));
-
- gtk_tree_model_filter_convert_iter_to_child_iter(
- GTK_TREE_MODEL_FILTER(model), &iter_store, &iter);
-
- if (gtk_tree_store_iter_is_valid(priv->store, &iter_store))
- {
- SoupCookie *cookie;
- gchar *name;
- const gchar *text;
-
- gtk_tree_model_get(model, &iter,
- COOKIE_MANAGER_COL_NAME, &name,
- COOKIE_MANAGER_COL_COOKIE, &cookie,
- -1);
-
- if (name != NULL)
- {
- GtkTreeIter parent;
- /* get the name of the parent item which should be a domain item */
- if (cookie != NULL && gtk_tree_model_iter_parent(model, &parent, &iter))
- {
- g_free(name);
- gtk_tree_model_get(model, &parent, COOKIE_MANAGER_COL_NAME, &name, -1);
- }
-
- text = cm_skip_leading_dot(name);
- gtk_selection_data_set_text(data, text, -1);
- }
- g_free(name);
- }
-}
-
-
-static gchar *cm_get_cookie_description_text(SoupCookie *cookie)
-{
- gchar *expires;
- gchar *text;
-
- g_return_val_if_fail(cookie != NULL, NULL);
-
- if (cookie->expires != NULL)
- {
- time_t expiration_time = soup_date_to_time_t(cookie->expires);
- GDateTime* date = g_date_time_new_from_unix_local(expiration_time);
- expires = g_date_time_format(date, "%c");
- g_date_time_unref(date);
- }
- else
- expires = g_strdup(_("At the end of the session"));
-
- text = g_markup_printf_escaped(
- _("<b>Host</b>: %s\n<b>Name</b>: %s\n<b>Value</b>: %s\n<b>Path</b>: %s\n"
- "<b>Secure</b>: %s\n<b>Expires</b>: %s"),
- cookie->domain,
- cookie->name,
- cookie->value,
- cookie->path,
- /* i18n: is this cookie secure (SSL)? yes/ no */
- cookie->secure ? _("Yes") : _("No"),
- expires);
- g_free(expires);
-
- return text;
-}
-
-
-static gchar *cm_get_domain_description_text(const gchar *domain, gint cookie_count)
-{
- gchar *str, *text;
-
- domain = cm_skip_leading_dot(domain);
-
- text = g_markup_printf_escaped(
- _("<b>Domain</b>: %s\n<b>Cookies</b>: %d"),
- domain, cookie_count);
-
- str = g_strconcat(text, "\n\n\n\n", NULL);
-
- g_free(text);
-
- return str;
-}
-
-
-static gboolean cm_tree_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode,
- GtkTooltip *tooltip, CookieManagerPage *cmp)
-{
- GtkTreeIter iter;
- GtkTreeModel *model;
-
- if (gtk_tree_view_get_tooltip_context(GTK_TREE_VIEW(widget), &x, &y,
- keyboard_mode, &model, NULL, &iter))
- {
- gchar *tooltip_text;
- SoupCookie *cookie;
-
- gtk_tree_model_get(model, &iter, COOKIE_MANAGER_COL_COOKIE, &cookie, -1);
-
- if (cookie == NULL) /* not an item */
- return FALSE;
-
- tooltip_text = cm_get_cookie_description_text(cookie);
-
- gtk_tooltip_set_markup(tooltip, tooltip_text);
-
- g_free(tooltip_text);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean cm_filter_match(const gchar *haystack, const gchar *needle)
-{
- gchar *haystack_lowered, *needle_lowered;
- gboolean result;
-
- /* empty strings always match */
- if (haystack == NULL || needle == NULL || *needle == '\0')
- return TRUE;
-
- haystack_lowered = g_utf8_strdown(haystack, -1);
- needle_lowered = g_utf8_strdown(needle, -1);
-
- /* if one of both could not be converted into lower case, skip those */
- if (haystack_lowered == NULL || needle_lowered == NULL)
- return FALSE;
-
- result = (strstr(haystack_lowered, needle_lowered) != NULL);
-
- g_free(haystack_lowered);
- g_free(needle_lowered);
-
- return result;
-}
-
-
-static void cm_filter_tree(CookieManagerPage *cmp, const gchar *filter_text)
-{
- GtkTreeIter iter, child;
- GtkTreeModel *model;
- gboolean show_child, show_parent;
- gboolean child_visible;
- gint i, n;
- gchar *name;
- gchar *domain;
- CookieManagerPagePrivate *priv = cmp->priv;
-
- model = GTK_TREE_MODEL(priv->store);
- if (! gtk_tree_model_get_iter_first(model, &iter))
- return;
-
- do
- {
- if (gtk_tree_model_iter_has_child(model, &iter))
- {
- child_visible = FALSE;
-
- gtk_tree_model_get(model, &iter, COOKIE_MANAGER_COL_NAME, &domain, -1);
- show_parent = cm_filter_match(domain, filter_text);
- g_free(domain);
- n = gtk_tree_model_iter_n_children(model, &iter);
- for (i = 0; i < n; i++)
- {
- gtk_tree_model_iter_nth_child(model, &child, &iter, i);
-
- gtk_tree_model_get(model, &child, COOKIE_MANAGER_COL_NAME, &name, -1);
- show_child = show_parent || cm_filter_match(name, filter_text);
- g_free(name);
-
- if (show_child)
- child_visible = TRUE;
-
- gtk_tree_store_set(priv->store, &child, COOKIE_MANAGER_COL_VISIBLE, show_child, -1);
- }
- gtk_tree_store_set(priv->store, &iter, COOKIE_MANAGER_COL_VISIBLE, child_visible, -1);
- }
- }
- while (gtk_tree_model_iter_next(model, &iter));
-}
-
-
-static void cm_filter_entry_changed_cb(GtkEditable *editable, CookieManagerPage *cmp)
-{
- const gchar *text;
- CookieManagerPagePrivate *priv = cmp->priv;
-
- if (priv->ignore_changed_filter)
- return;
-
- if (!g_object_get_data (G_OBJECT (editable), "sokoke_showing_default"))
- text = gtk_entry_get_text(GTK_ENTRY(editable));
- else
- text = NULL;
- cm_filter_tree(cmp, text);
-
- cookie_manager_update_filter(priv->parent, text);
-
- if (text && *text)
- gtk_tree_view_collapse_all(GTK_TREE_VIEW(priv->treeview));
- else
- gtk_tree_view_expand_all(GTK_TREE_VIEW(priv->treeview));
-}
-
-static void cm_tree_selection_changed_cb(GtkTreeSelection *selection, CookieManagerPage *cmp)
-{
- GList *rows;
- GtkTreeIter iter, iter_store;
- GtkTreeModel *model;
- gchar *text, *name;
- gboolean valid = TRUE;
- gboolean delete_possible = TRUE;
- guint rows_len;
- SoupCookie *cookie;
- CookieManagerPagePrivate *priv = cmp->priv;
-
- rows = gtk_tree_selection_get_selected_rows(selection, &model);
- rows_len = cm_list_length(rows);
- if (rows_len == 0)
- {
- valid = FALSE;
- delete_possible = FALSE;
- }
- else if (rows_len == 1)
- {
- /* get iter */
- gtk_tree_model_get_iter(model, &iter, (GtkTreePath*) (g_list_nth_data(rows, 0)));
-
- gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model),
- &iter_store, &iter);
- }
- else
- valid = FALSE;
-
- if (valid && gtk_tree_store_iter_is_valid(priv->store, &iter_store))
- {
- gtk_tree_model_get(model, &iter, COOKIE_MANAGER_COL_COOKIE, &cookie, -1);
- if (cookie != NULL)
- {
- text = cm_get_cookie_description_text(cookie);
-
- gtk_label_set_markup(GTK_LABEL(priv->desc_label), text);
-
- g_free(text);
- }
- else
- {
- gtk_tree_model_get(model, &iter, COOKIE_MANAGER_COL_NAME, &name, -1);
- if (name != NULL)
- {
- gint cookie_count = gtk_tree_model_iter_n_children(model, &iter);
-
- text = cm_get_domain_description_text(name, cookie_count);
- gtk_label_set_markup(GTK_LABEL(priv->desc_label), text);
-
- g_free(text);
- g_free(name);
- }
- }
- }
- /* This is a bit hack'ish but we add some empty lines to get a minimum height of the
- * label at the bottom without any font size calculation. */
- if (! valid)
- gtk_label_set_text(GTK_LABEL(priv->desc_label), CM_EMPTY_LABEL_TEXT);
- cm_set_button_sensitiveness(cmp, delete_possible);
-
- cm_free_selection_list(rows, (GFunc) gtk_tree_path_free);
-}
-
-
-static void cm_tree_show_popup_menu(GtkWidget *widget, GdkEventButton *event, CookieManagerPage *cmp)
-{
- gint button, event_time;
- CookieManagerPagePrivate *priv = cmp->priv;
-
- if (event != NULL)
- {
- button = event->button;
- event_time = event->time;
- }
- else
- {
- button = 0;
- event_time = gtk_get_current_event_time ();
- }
-
- gtk_menu_popup(GTK_MENU(priv->popup_menu), NULL, NULL, NULL, NULL, button, event_time);
-}
-
-
-static gboolean cm_tree_popup_menu_cb(GtkWidget *widget, CookieManagerPage *cmp)
-{
- cm_tree_show_popup_menu(widget, NULL, cmp);
- return TRUE;
-}
-
-
-static gboolean cm_tree_button_release_event_cb(GtkWidget *widget, GdkEventButton *ev,
- CookieManagerPage *cmp)
-{
- if (MIDORI_EVENT_CONTEXT_MENU(ev))
- {
- cm_tree_show_popup_menu(widget, ev, cmp);
- return TRUE;
- }
- return FALSE;
-}
-
-
-static gboolean cm_tree_key_press_cb(GtkWidget *widget, GdkEventKey *event, CookieManagerPage *cmp)
-{
- if (event->keyval == GDK_KEY_Delete && !
- (event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)))
- {
- cm_delete_item(cmp);
- return TRUE;
- }
- return FALSE;
-}
-
-
-static gboolean cm_tree_button_press_event_cb(GtkWidget *widget, GdkEventButton *ev,
- CookieManagerPage *cmp)
-{
- gboolean ret = FALSE;
-
- if (ev->type == GDK_2BUTTON_PRESS)
- {
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GList *rows;
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
- rows = gtk_tree_selection_get_selected_rows(selection, &model);
- if (cm_list_length(rows) == 1)
- {
- /* get iter */
- gtk_tree_model_get_iter(model, &iter, (GtkTreePath*) (g_list_nth_data(rows, 0)));
- /* double click on parent node expands/collapses it */
- if (gtk_tree_model_iter_has_child(model, &iter))
- {
- GtkTreePath *path = gtk_tree_model_get_path(model, &iter);
-
- if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(widget), path))
- gtk_tree_view_collapse_row(GTK_TREE_VIEW(widget), path);
- else
- gtk_tree_view_expand_row(GTK_TREE_VIEW(widget), path, FALSE);
-
- gtk_tree_path_free(path);
-
- ret = TRUE;
- }
- }
- cm_free_selection_list(rows, (GFunc) gtk_tree_path_free);
- }
- return ret;
-}
-
-
-static void cm_tree_render_text_cb(GtkTreeViewColumn *column, GtkCellRenderer *renderer, GtkTreeModel *model,
- GtkTreeIter *iter, gpointer data)
-{
- gchar *name;
-
- gtk_tree_model_get(model, iter, COOKIE_MANAGER_COL_NAME, &name, -1);
-
- if (name != NULL && *name != '.')
- {
- gchar *display_name = g_strconcat(" ", name, NULL);
- g_object_set(renderer, "text", display_name, NULL);
- g_free(display_name);
- }
- else
- g_object_set(renderer, "text", name, NULL);
- g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
-
- g_free(name);
-}
-
-
-static GtkWidget *cm_tree_prepare(CookieManagerPage *cmp)
-{
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkTreeSelection *sel;
- GtkWidget *item;
- GtkWidget *menu;
- GtkWidget *treeview;
- CookieManagerPagePrivate *priv = cmp->priv;
-
- treeview = priv->treeview = gtk_tree_view_new();
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(
- _("Name"), renderer, "text", COOKIE_MANAGER_COL_NAME, NULL);
- gtk_tree_view_column_set_expand (column, TRUE);
- gtk_tree_view_column_set_sort_indicator(column, TRUE);
- gtk_tree_view_column_set_sort_column_id(column, COOKIE_MANAGER_COL_NAME);
- gtk_tree_view_column_set_resizable(column, TRUE);
- gtk_tree_view_column_set_cell_data_func(column, renderer,
- (GtkTreeCellDataFunc) cm_tree_render_text_cb, NULL, NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-
- gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE);
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE);
- gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), COOKIE_MANAGER_COL_NAME);
-
- /* selection handling */
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
- gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
-
- /* signals */
- g_signal_connect(sel, "changed", G_CALLBACK(cm_tree_selection_changed_cb), cmp);
- g_signal_connect(treeview, "key-press-event", G_CALLBACK(cm_tree_key_press_cb), cmp);
- g_signal_connect(treeview, "button-press-event", G_CALLBACK(cm_tree_button_press_event_cb), cmp);
- g_signal_connect(treeview, "button-release-event", G_CALLBACK(cm_tree_button_release_event_cb), cmp);
- g_signal_connect(treeview, "popup-menu", G_CALLBACK(cm_tree_popup_menu_cb), cmp);
-
- /* tooltips */
- gtk_widget_set_has_tooltip(treeview, TRUE);
- g_signal_connect(treeview, "query-tooltip", G_CALLBACK(cm_tree_query_tooltip), cmp);
-
- /* drag'n'drop */
- gtk_tree_view_enable_model_drag_source(
- GTK_TREE_VIEW(treeview),
- GDK_BUTTON1_MASK,
- NULL,
- 0,
- GDK_ACTION_COPY
- );
- gtk_drag_source_add_text_targets(treeview);
- g_signal_connect(treeview, "drag-data-get", G_CALLBACK(cm_tree_drag_data_get_cb), cmp);
-
- /* popup menu */
- priv->popup_menu = menu = gtk_menu_new();
-
- item = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE, NULL);
- gtk_widget_show(item);
- gtk_container_add(GTK_CONTAINER(menu), item);
- g_signal_connect(item, "activate", G_CALLBACK(cm_button_delete_clicked_cb), cmp);
- priv->delete_popup_button = item;
-
- item = gtk_separator_menu_item_new();
- gtk_widget_show(item);
- gtk_container_add(GTK_CONTAINER(menu), item);
-
- item = gtk_image_menu_item_new_with_mnemonic(_("_Expand All"));
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
- gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
- gtk_widget_show(item);
- gtk_container_add(GTK_CONTAINER(menu), item);
- g_signal_connect(item, "activate", G_CALLBACK(cm_tree_popup_expand_activate_cb), cmp);
- priv->expand_buttons[2] = item;
-
- item = gtk_image_menu_item_new_with_mnemonic(_("_Collapse All"));
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
- gtk_image_new_from_icon_name(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
- gtk_widget_show(item);
- gtk_container_add(GTK_CONTAINER(menu), item);
- g_signal_connect(item, "activate", G_CALLBACK(cm_tree_popup_collapse_activate_cb), cmp);
- priv->expand_buttons[3] = item;
-
- return treeview;
-}
-
-
-static void cookie_manager_page_init(CookieManagerPage *self)
-{
- GtkWidget *tree_swin;
- GtkWidget *desc_swin;
- GtkWidget *paned;
- GtkWidget *filter_hbox;
- GtkWidget *treeview;
- CookieManagerPagePrivate *priv;
-
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- COOKIE_MANAGER_PAGE_TYPE, CookieManagerPagePrivate);
- priv = self->priv;
- priv->ignore_changed_filter = FALSE;
-
- cm_create_toolbar(self);
-
- priv->desc_label = gtk_label_new(CM_EMPTY_LABEL_TEXT);
- gtk_label_set_selectable(GTK_LABEL(priv->desc_label), TRUE);
- gtk_label_set_line_wrap(GTK_LABEL(priv->desc_label), TRUE);
- gtk_label_set_line_wrap_mode(GTK_LABEL(priv->desc_label), PANGO_WRAP_CHAR);
- gtk_misc_set_alignment(GTK_MISC(priv->desc_label), 0, 0);
- gtk_misc_set_padding(GTK_MISC(priv->desc_label), 3, 3);
- gtk_widget_show(priv->desc_label);
-
- desc_swin = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(desc_swin),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(desc_swin), GTK_SHADOW_NONE);
- gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(desc_swin), priv->desc_label);
- gtk_widget_show(desc_swin);
-
- treeview = cm_tree_prepare(self);
- gtk_widget_show(treeview);
-
- tree_swin = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tree_swin),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_container_add(GTK_CONTAINER(tree_swin), treeview);
- gtk_widget_show(tree_swin);
-
- priv->filter_entry = sokoke_search_entry_new (_("Search Cookies by Name or Domain"));
- gtk_widget_show(priv->filter_entry);
- g_signal_connect(priv->filter_entry, "changed", G_CALLBACK(cm_filter_entry_changed_cb), self);
- g_signal_connect(priv->filter_entry, "activate", G_CALLBACK(cm_filter_entry_changed_cb), self);
-
- filter_hbox = gtk_hbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(filter_hbox), priv->filter_entry, TRUE, TRUE, 3);
- gtk_widget_show(filter_hbox);
-
- paned = gtk_vpaned_new();
- gtk_paned_pack1(GTK_PANED(paned), tree_swin, TRUE, FALSE);
- gtk_paned_pack2(GTK_PANED(paned), desc_swin, FALSE, FALSE);
- gtk_widget_show(paned);
-
- gtk_box_pack_start(GTK_BOX(self), filter_hbox, FALSE, FALSE, 5);
- gtk_box_pack_start(GTK_BOX(self), paned, TRUE, TRUE, 0);
-}
-
-
-GtkWidget *cookie_manager_page_new(CookieManager *parent, GtkTreeStore *store,
- const gchar *filter_text)
-{
- GtkWidget *cmp;
-
- cmp = g_object_new(COOKIE_MANAGER_PAGE_TYPE, "parent", parent, "store", store, NULL);
-
- if (filter_text != NULL)
- cookie_manager_page_filter_changed_cb(parent, filter_text, COOKIE_MANAGER_PAGE(cmp));
-
- return cmp;
-}
-
diff --git a/extensions/cookie-manager/cookie-manager-page.h b/extensions/cookie-manager/cookie-manager-page.h
deleted file mode 100644
index e2a9d9a8..00000000
--- a/extensions/cookie-manager/cookie-manager-page.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- Copyright (C) 2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)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 __COOKIE_MANAGER_PAGE_H__
-#define __COOKIE_MANAGER_PAGE_H__
-
-G_BEGIN_DECLS
-
-#define COOKIE_MANAGER_PAGE_TYPE (cookie_manager_page_get_type())
-#define COOKIE_MANAGER_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
- COOKIE_MANAGER_PAGE_TYPE, CookieManagerPage))
-#define COOKIE_MANAGER_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\
- COOKIE_MANAGER_PAGE_TYPE, CookieManagerPageClass))
-#define IS_COOKIE_MANAGER_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
- COOKIE_MANAGER_PAGE_TYPE))
-#define IS_COOKIE_MANAGER_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\
- COOKIE_MANAGER_PAGE_TYPE))
-
-typedef struct _CookieManagerPage CookieManagerPage;
-typedef struct _CookieManagerPageClass CookieManagerPageClass;
-typedef struct _CookieManagerPagePrivate CookieManagerPagePrivate;
-
-struct _CookieManagerPage
-{
- GtkVBox parent;
- CookieManagerPagePrivate* priv;
-};
-
-struct _CookieManagerPageClass
-{
- GtkVBoxClass parent_class;
-};
-
-GType cookie_manager_page_get_type (void);
-GtkWidget* cookie_manager_page_new (CookieManager *parent,
- GtkTreeStore *store,
- const gchar *filter_text);
-
-G_END_DECLS
-
-#endif /* __COOKIE_MANAGER_PAGE_H__ */
diff --git a/extensions/cookie-manager/cookie-manager.c b/extensions/cookie-manager/cookie-manager.c
deleted file mode 100644
index de6b83fb..00000000
--- a/extensions/cookie-manager/cookie-manager.c
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- Copyright (C) 2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)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.
-*/
-
-#include "config.h"
-#include <midori/midori.h>
-#include "katze/katze.h"
-#include <libsoup/soup-cookie-jar-sqlite.h>
-
-#include "cookie-manager.h"
-#include "cookie-manager-page.h"
-
-typedef struct _CookieManagerPrivate CookieManagerPrivate;
-
-struct _CookieManager
-{
- GObject parent;
- CookieManagerPrivate* priv;
-};
-
-struct _CookieManagerClass
-{
- GObjectClass parent_class;
-};
-
-struct _CookieManagerPrivate
-{
- MidoriApp *app;
- MidoriExtension *extension;
-
- GSList *panel_pages;
-
- GtkTreeStore *store;
- GSList *cookies;
- SoupCookieJar *jar;
- guint timer_id;
- gint ignore_changed_count;
-
- gchar *filter_text;
-};
-
-static void cookie_manager_finalize(GObject *object);
-static void cookie_manager_app_add_browser_cb(MidoriApp *app, MidoriBrowser *browser,
- CookieManager *cm);
-
-enum
-{
- COOKIES_CHANGED,
- PRE_COOKIES_CHANGE,
- FILTER_CHANGED,
-
- LAST_SIGNAL
-};
-static guint signals[LAST_SIGNAL];
-
-
-G_DEFINE_TYPE(CookieManager, cookie_manager, G_TYPE_OBJECT);
-
-
-static void cookie_manager_class_init(CookieManagerClass *klass)
-{
- GObjectClass *g_object_class;
-
- g_object_class = G_OBJECT_CLASS(klass);
-
- g_object_class->finalize = cookie_manager_finalize;
-
- signals[COOKIES_CHANGED] = g_signal_new(
- "cookies-changed",
- G_TYPE_FROM_CLASS(klass),
- (GSignalFlags) 0,
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[PRE_COOKIES_CHANGE] = g_signal_new(
- "pre-cookies-change",
- G_TYPE_FROM_CLASS(klass),
- (GSignalFlags) 0,
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[FILTER_CHANGED] = g_signal_new(
- "filter-changed",
- G_TYPE_FROM_CLASS(klass),
- (GSignalFlags) 0,
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-
- g_type_class_add_private(klass, sizeof(CookieManagerPrivate));
-}
-
-
-static void cookie_manager_panel_pages_foreach(gpointer ptr, gpointer data)
-{
- if (ptr != NULL && GTK_IS_WIDGET(ptr))
- gtk_widget_destroy(GTK_WIDGET(ptr));
-}
-
-
-static void cookie_manager_page_destroy_cb(GObject *page, CookieManager *cm)
-{
- CookieManagerPrivate *priv = cm->priv;
-
- priv->panel_pages = g_slist_remove(priv->panel_pages, page);
-}
-
-
-static void cookie_manager_app_add_browser_cb(MidoriApp *app, MidoriBrowser *browser,
- CookieManager *cm)
-{
- MidoriPanel *panel;
- GtkWidget *page;
- CookieManagerPrivate *priv = cm->priv;
-
- panel = katze_object_get_object(browser, "panel");
-
- page = cookie_manager_page_new(cm, priv->store, priv->filter_text);
- gtk_widget_show(page);
- midori_panel_append_page(panel, MIDORI_VIEWABLE(page));
- g_signal_connect(page, "destroy", G_CALLBACK(cookie_manager_page_destroy_cb), cm);
-
- priv->panel_pages = g_slist_append(priv->panel_pages, page);
-
- g_object_unref(panel);
-}
-
-
-static void cookie_manager_free_cookie_list(CookieManager *cm)
-{
- CookieManagerPrivate *priv = cm->priv;
-
- if (priv->cookies != NULL)
- {
- GSList *l;
-
- for (l = priv->cookies; l != NULL; l = g_slist_next(l))
- soup_cookie_free(l->data);
- g_slist_free(priv->cookies);
- priv->cookies = NULL;
- }
-}
-
-
-static void cookie_manager_refresh_store(CookieManager *cm)
-{
- GSList *l;
- GHashTable *parents;
- GtkTreeIter iter;
- GtkTreeIter *parent_iter;
- SoupCookie *cookie;
- CookieManagerPrivate *priv = cm->priv;
-
- g_signal_emit(cm, signals[PRE_COOKIES_CHANGE], 0);
-
- gtk_tree_store_clear(priv->store);
-
- /* free the old list */
- cookie_manager_free_cookie_list(cm);
-
- priv->cookies = soup_cookie_jar_all_cookies(priv->jar);
-
- /* Hashtable holds domain names as keys, the corresponding tree iters as values */
- parents = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
-
- for (l = priv->cookies; l != NULL; l = g_slist_next(l))
- {
- cookie = l->data;
-
- /* look for the parent item for the current domain name and create it if it doesn't exist */
- if ((parent_iter = (GtkTreeIter*) g_hash_table_lookup(parents, cookie->domain)) == NULL)
- {
- parent_iter = g_new0(GtkTreeIter, 1);
-
- gtk_tree_store_append(priv->store, parent_iter, NULL);
- gtk_tree_store_set(priv->store, parent_iter,
- COOKIE_MANAGER_COL_NAME, cookie->domain,
- COOKIE_MANAGER_COL_COOKIE, NULL,
- COOKIE_MANAGER_COL_VISIBLE, TRUE,
- -1);
-
- g_hash_table_insert(parents, g_strdup(cookie->domain), parent_iter);
- }
-
- gtk_tree_store_append(priv->store, &iter, parent_iter);
- gtk_tree_store_set(priv->store, &iter,
- COOKIE_MANAGER_COL_NAME, cookie->name,
- COOKIE_MANAGER_COL_COOKIE, cookie,
- COOKIE_MANAGER_COL_VISIBLE, TRUE,
- -1);
- }
- g_hash_table_destroy(parents);
-
- g_signal_emit(cm, signals[COOKIES_CHANGED], 0);
-}
-
-
-static gboolean cookie_manager_delayed_refresh(CookieManager *cm)
-{
- CookieManagerPrivate *priv = cm->priv;
-
- cookie_manager_refresh_store(cm);
- priv->timer_id = 0;
-
- return FALSE;
-}
-
-
-static void cookie_manager_jar_changed_cb(SoupCookieJar *jar, SoupCookie *old, SoupCookie *new,
- CookieManager *cm)
-{
- CookieManagerPrivate *priv = cm->priv;
-
- if (priv->ignore_changed_count > 0)
- {
- priv->ignore_changed_count--;
- return;
- }
-
- /* We delay these events a little bit to avoid too many rebuilds of the tree.
- * Some websites (like Flyspray bugtrackers sent a whole bunch of cookies at once. */
- if (priv->timer_id == 0)
- priv->timer_id = midori_timeout_add_seconds(
- 1, (GSourceFunc) cookie_manager_delayed_refresh, cm, NULL);
-}
-
-
-static void cookie_manager_finalize(GObject *object)
-{
- CookieManager *cm = COOKIE_MANAGER(object);
- CookieManagerPrivate *priv = cm->priv;
-
- g_signal_handlers_disconnect_by_func(priv->app, cookie_manager_app_add_browser_cb, cm);
- g_signal_handlers_disconnect_by_func(priv->jar, cookie_manager_jar_changed_cb, cm);
-
- /* remove all panel pages from open windows */
- g_slist_foreach(priv->panel_pages, cookie_manager_panel_pages_foreach, NULL);
- g_slist_free(priv->panel_pages);
-
- /* clean cookies */
- if (priv->timer_id > 0)
- g_source_remove(priv->timer_id);
-
- cookie_manager_free_cookie_list(cm);
-
- g_object_unref(priv->store);
- g_free(priv->filter_text);
- g_object_unref(priv->jar);
-
- G_OBJECT_CLASS(cookie_manager_parent_class)->finalize(object);
-}
-
-
-static void cookie_manager_init(CookieManager *self)
-{
- CookieManagerPrivate *priv;
-
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- COOKIE_MANAGER_TYPE, CookieManagerPrivate);
- priv = self->priv;
- /* create the main store */
- priv->store = gtk_tree_store_new(COOKIE_MANAGER_N_COLUMNS,
- G_TYPE_STRING, SOUP_TYPE_COOKIE, G_TYPE_BOOLEAN);
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(priv->store),
- COOKIE_MANAGER_COL_NAME, GTK_SORT_ASCENDING);
-
- /* setup soup */
-#ifdef HAVE_WEBKIT2
- gchar *filename = midori_paths_get_config_filename_for_writing ("cookies.db");
- priv->jar = soup_cookie_jar_sqlite_new (filename, FALSE);
- g_free(filename);
-#else
- SoupSession *session = webkit_get_default_session();
- priv->jar = SOUP_COOKIE_JAR(soup_session_get_feature(session, soup_cookie_jar_get_type()));
- g_object_ref(priv->jar);
-#endif
- g_signal_connect(priv->jar, "changed", G_CALLBACK(cookie_manager_jar_changed_cb), self);
-
- cookie_manager_refresh_store(self);
-}
-
-
-void cookie_manager_update_filter(CookieManager *cm, const gchar *text)
-{
- CookieManagerPrivate *priv = cm->priv;
-
- katze_assign(priv->filter_text, g_strdup(text));
-
- g_signal_emit(cm, signals[FILTER_CHANGED], 0, text);
-}
-
-
-void cookie_manager_delete_cookie(CookieManager *cm, SoupCookie *cookie)
-{
- CookieManagerPrivate *priv = cm->priv;
-
- if (cookie != NULL)
- {
- priv->ignore_changed_count++;
-
- soup_cookie_jar_delete_cookie(priv->jar, cookie);
- /* the SoupCookie object is freed when the whole list gets updated */
- }
-}
-
-
-CookieManager *cookie_manager_new(MidoriExtension *extension, MidoriApp *app)
-{
- CookieManager *cm;
- CookieManagerPrivate *priv;
- KatzeArray *browsers;
- MidoriBrowser *browser;
-
- cm = g_object_new(COOKIE_MANAGER_TYPE, NULL);
-
- priv = cm->priv;
- priv->app = app;
- priv->extension = extension;
-
- /* add the cookie manager panel page to existing browsers */
- browsers = katze_object_get_object(app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- cookie_manager_app_add_browser_cb(app, browser, cm);
- g_object_unref(browsers);
-
- g_signal_connect(app, "add-browser", G_CALLBACK(cookie_manager_app_add_browser_cb), cm);
-
- return cm;
-}
-
diff --git a/extensions/cookie-manager/cookie-manager.h b/extensions/cookie-manager/cookie-manager.h
deleted file mode 100644
index 4e2ba32b..00000000
--- a/extensions/cookie-manager/cookie-manager.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- Copyright (C) 2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)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 __COOKIE_MANAGER_H__
-#define __COOKIE_MANAGER_H__
-
-G_BEGIN_DECLS
-
-#define STOCK_COOKIE_MANAGER "cookie-manager"
-
-enum
-{
- COOKIE_MANAGER_COL_NAME,
- COOKIE_MANAGER_COL_COOKIE,
- COOKIE_MANAGER_COL_VISIBLE,
- COOKIE_MANAGER_N_COLUMNS
-};
-
-
-#define COOKIE_MANAGER_TYPE (cookie_manager_get_type())
-#define COOKIE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
- COOKIE_MANAGER_TYPE, CookieManager))
-#define COOKIE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\
- COOKIE_MANAGER_TYPE, CookieManagerClass))
-#define IS_COOKIE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
- COOKIE_MANAGER_TYPE))
-#define IS_COOKIE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\
- COOKIE_MANAGER_TYPE))
-
-typedef struct _CookieManager CookieManager;
-typedef struct _CookieManagerClass CookieManagerClass;
-
-GType cookie_manager_get_type (void);
-CookieManager* cookie_manager_new (MidoriExtension *extension, MidoriApp *app);
-
-void cookie_manager_delete_cookie(CookieManager *cm, SoupCookie *cookie);
-void cookie_manager_update_filter(CookieManager *cm, const gchar *text);
-
-G_END_DECLS
-
-#endif /* __COOKIE-MANAGER_H__ */
diff --git a/extensions/cookie-manager/main.c b/extensions/cookie-manager/main.c
deleted file mode 100644
index 8a72b707..00000000
--- a/extensions/cookie-manager/main.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Copyright (C) 2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)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.
-*/
-
-#include "config.h"
-#include <midori/midori.h>
-
-#include "cookie-manager.h"
-
-CookieManager *cm = NULL;
-
-
-static void cm_deactivate_cb(MidoriExtension *extension, gpointer data)
-{
- g_object_unref(cm);
-}
-
-
-static void cm_activate_cb(MidoriExtension *extension, MidoriApp *app, gpointer data)
-{
- cm = cookie_manager_new(extension, app);
-}
-
-
-MidoriExtension *extension_init(void)
-{
- MidoriExtension *extension = g_object_new(MIDORI_TYPE_EXTENSION,
- "name", _("Cookie Manager"),
- "description", _("List, view and delete cookies"),
- "version", "0.2" MIDORI_VERSION_SUFFIX,
- "authors", "Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>",
- NULL);
-
- g_signal_connect(extension, "activate", G_CALLBACK(cm_activate_cb), NULL);
- g_signal_connect(extension, "deactivate", G_CALLBACK(cm_deactivate_cb), NULL);
-
- return extension;
-}
diff --git a/extensions/cookie-permissions/cookie-permission-manager-preferences-window.c b/extensions/cookie-permissions/cookie-permission-manager-preferences-window.c
deleted file mode 100644
index 2546ab1b..00000000
--- a/extensions/cookie-permissions/cookie-permission-manager-preferences-window.c
+++ /dev/null
@@ -1,931 +0,0 @@
-/*
- Copyright (C) 2013 Stephan Haller <nomad@froevel.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.
-*/
-
-#include "cookie-permission-manager-preferences-window.h"
-
-/* Define this class in GObject system */
-G_DEFINE_TYPE(CookiePermissionManagerPreferencesWindow,
- cookie_permission_manager_preferences_window,
- GTK_TYPE_DIALOG)
-
-/* Properties */
-enum
-{
- PROP_0,
-
- PROP_MANAGER,
-
- PROP_LAST
-};
-
-static GParamSpec* CookiePermissionManagerPreferencesWindowProperties[PROP_LAST]={ 0, };
-
-/* Private structure - access only by public API if needed */
-#define COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), TYPE_COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW, CookiePermissionManagerPreferencesWindowPrivate))
-
-struct _CookiePermissionManagerPreferencesWindowPrivate
-{
- /* Extension related */
- CookiePermissionManager *manager;
- sqlite3 *database;
-
- /* Dialog related */
- GtkWidget *contentArea;
- GtkListStore *listStore;
- GtkWidget *list;
- GtkTreeSelection *listSelection;
- GtkWidget *editingCombo;
- GtkWidget *deleteButton;
- GtkWidget *deleteAllButton;
- GtkWidget *unknownPolicyCombo;
- GtkWidget *addDomainEntry;
- GtkWidget *addDomainPolicyCombo;
- GtkWidget *addDomainButton;
-
- gint signalManagerChangedDatabaseID;
- gint signalManagerUnknownPolicyID;
- gint signalUnknownPolicyID;
-};
-
-enum
-{
- DOMAIN_COLUMN,
- POLICY_COLUMN,
- N_COLUMN
-};
-
-
-/* IMPLEMENTATION: Private variables and methods */
-
-/* "Add domain"-button was pressed */
-static void _cookie_permission_manager_preferences_on_add_domain_clicked(CookiePermissionManagerPreferencesWindow *self,
- gpointer *inUserData)
-{
- CookiePermissionManagerPreferencesWindowPrivate *priv=self->priv;
- gchar *domain;
- const gchar *domainStart, *domainEnd;
- gchar *realDomain;
- GtkTreeIter policyIter;
-
- g_return_if_fail(priv->database);
-
- /* Get domain name entered */
- domain=g_hostname_to_ascii(gtk_entry_get_text(GTK_ENTRY(priv->addDomainEntry)));
-
- /* Trim whitespaces from start and end of entered domain name */
- domainStart=domain;
- while(*domainStart && g_ascii_isspace(*domainStart)) domainStart++;
-
- domainEnd=domain+strlen(domain)-1;
- while(*domainEnd && g_ascii_isspace(*domainEnd)) domainEnd--;
- if(domainEnd<=domainStart) return;
-
- /* Seperate domain name from whitespaces */
- realDomain=g_strndup(domain, domainEnd-domainStart+1);
- if(!realDomain) return;
-
- /* Get policy from combo box */
- if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(priv->addDomainPolicyCombo), &policyIter))
- {
- gchar *sql;
- gchar *error=NULL;
- gint success;
- gint policy;
- gchar *policyName;
-
- /* Get policy value to set for domain */
- gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(priv->addDomainPolicyCombo)),
- &policyIter,
- 0, &policy,
- 1, &policyName,
- -1);
-
- /* Add domain name and the selected policy to database */
- sql=sqlite3_mprintf("INSERT OR REPLACE INTO policies (domain, value) VALUES ('%q', %d);",
- realDomain,
- policy);
- success=sqlite3_exec(priv->database, sql, NULL, NULL, &error);
-
- /* Show error message if any */
- if(success==SQLITE_OK)
- {
- gtk_list_store_append(priv->listStore, &policyIter);
- gtk_list_store_set(priv->listStore,
- &policyIter,
- DOMAIN_COLUMN, realDomain,
- POLICY_COLUMN, policyName,
- -1);
- }
- else g_warning(_("SQL fails: %s"), error);
-
-
- if(error) sqlite3_free(error);
-
- /* Free allocated resources */
- sqlite3_free(sql);
- }
-
- /* Free allocated resources */
- g_free(realDomain);
- g_free(domain);
-}
-
-/* Entry containing domain name which may be added to list has changed */
-static void _cookie_permission_manager_preferences_on_add_domain_entry_changed(CookiePermissionManagerPreferencesWindow *self,
- GtkEditable *inEditable)
-{
- CookiePermissionManagerPreferencesWindowPrivate *priv=self->priv;
- gchar *asciiDomain, *checkAsciiDomain;
- gchar *asciiDomainStart, *asciiDomainEnd;
- gint dots;
- gboolean isValid=FALSE;
-
- /* Get ASCII representation of domain name entered */
- asciiDomain=g_hostname_to_ascii(gtk_entry_get_text(GTK_ENTRY(priv->addDomainEntry)));
-
- /* Trim whitespaces from start and end of entered domain name */
- asciiDomainStart=asciiDomain;
- while(*asciiDomainStart && g_ascii_isspace(*asciiDomainStart)) asciiDomainStart++;
-
- asciiDomainEnd=asciiDomain+strlen(asciiDomain)-1;
- while(*asciiDomainEnd && g_ascii_isspace(*asciiDomainEnd)) asciiDomainEnd--;
-
- /* We allow only domain names and not cookie domain name so entered name
- * must not start with a dot
- */
- checkAsciiDomain=asciiDomainStart;
- isValid=(*asciiDomainStart!='.' && *asciiDomainEnd!='.');
-
- /* Now check if ASCII domain name is valid (very very simple check)
- * and contains a hostname besides TLD
- */
- dots=0;
-
- while(*checkAsciiDomain &&
- checkAsciiDomain<=asciiDomainEnd &&
- isValid)
- {
- /* Check for dot as (at least the first one) seperates hostname from TLD */
- if(*checkAsciiDomain=='.') dots++;
- else
- {
- /* Check for valid characters in domain name.
- * Valid domain name can only contain ASCII alphabetic letters,
- * digits (0-9) and hyphens ('-')
- */
- isValid=(g_ascii_isalpha(*checkAsciiDomain) ||
- g_ascii_isdigit(*checkAsciiDomain) ||
- *checkAsciiDomain=='-');
- }
-
- checkAsciiDomain++;
- }
-
- /* If we have not reached the trimmed end of string something must have gone wrong
- * and domain entered is invalid. If domain name entered excluding dots is longer
- * than 255 character it is also invalid.
- */
- if(checkAsciiDomain<asciiDomainEnd) isValid=FALSE;
- else if((checkAsciiDomain-asciiDomainStart-dots)>255) isValid=FALSE;
-
- /* We need at least one dot in domain name (minimum number of dots to seperate
- * hostname from TLD)
- */
- isValid=(isValid && dots>0);
-
- /* Activate "add" button if hostname (equal to domain name here) is valid */
- gtk_widget_set_sensitive(priv->addDomainButton, isValid);
-
- /* Free allocated resources */
- g_free(asciiDomain);
-}
-
-/* Fill domain list with stored policies */
-static void _cookie_permission_manager_preferences_window_fill(CookiePermissionManagerPreferencesWindow *self)
-{
- CookiePermissionManagerPreferencesWindowPrivate *priv=self->priv;
- gint success;
- sqlite3_stmt *statement=NULL;
-
- /* Clear tree/list view */
- gtk_list_store_clear(priv->listStore);
-
- /* If no database is present return here */
- if(!priv->database) return;
-
- /* Fill list store with policies from database */
- success=sqlite3_prepare_v2(priv->database,
- "SELECT domain, value FROM policies;",
- -1,
- &statement,
- NULL);
- if(statement && success==SQLITE_OK)
- {
- gchar *domain;
- gint policy;
- gchar *policyName;
- GtkTreeIter iter;
-
- while(sqlite3_step(statement)==SQLITE_ROW)
- {
- /* Get values */
- domain=(gchar*)sqlite3_column_text(statement, 0);
- policy=sqlite3_column_int(statement, 1);
-
- switch(policy)
- {
- case COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT:
- policyName=_("Accept");
- break;
-
- case COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT_FOR_SESSION:
- policyName=_("Accept for session");
- break;
-
- case COOKIE_PERMISSION_MANAGER_POLICY_BLOCK:
- policyName=_("Block");
- break;
-
- default:
- policyName=NULL;
- break;
- }
-
- if(policyName)
- {
- gtk_list_store_append(priv->listStore, &iter);
- gtk_list_store_set(priv->listStore,
- &iter,
- DOMAIN_COLUMN, domain,
- POLICY_COLUMN, policyName,
- -1);
- }
- }
- }
- else g_warning(_("SQL fails: %s"), sqlite3_errmsg(priv->database));
-
- sqlite3_finalize(statement);
-}
-
-/* Database instance in manager changed */
-static void _cookie_permission_manager_preferences_window_manager_database_changed(CookiePermissionManagerPreferencesWindow *self,
- GParamSpec *inSpec,
- gpointer inUserData)
-{
- CookiePermissionManagerPreferencesWindowPrivate *priv=self->priv;
- CookiePermissionManager *manager=COOKIE_PERMISSION_MANAGER(inUserData);
- const gchar *databaseFilename;
-
- /* Close connection to any open database */
- if(priv->database) sqlite3_close(priv->database);
- priv->database=NULL;
-
- /* Get pointer to new database and open database */
- g_object_get(manager, "database-filename", &databaseFilename, NULL);
- if(databaseFilename)
- {
- gint success;
-
- success=sqlite3_open(databaseFilename, &priv->database);
- if(success!=SQLITE_OK)
- {
- g_warning(_("Could not open database of extenstion: %s"), sqlite3_errmsg(priv->database));
-
- if(priv->database) sqlite3_close(priv->database);
- priv->database=NULL;
- }
- }
-
- /* Fill list with new database */
- _cookie_permission_manager_preferences_window_fill(self);
-
- /* Set up availability of management buttons */
- gtk_widget_set_sensitive(priv->deleteAllButton, priv->database!=NULL);
- gtk_widget_set_sensitive(priv->list, priv->database!=NULL);
-
- return;
-}
-
-/* unknown-policy in manager changed or drop-down changed */
-static void _cookie_permission_manager_preferences_window_manager_unknown_policy_changed(CookiePermissionManagerPreferencesWindow *self,
- GParamSpec *inSpec,
- gpointer inUserData)
-{
- CookiePermissionManagerPreferencesWindowPrivate *priv=self->priv;
- CookiePermissionManager *manager=COOKIE_PERMISSION_MANAGER(inUserData);
- CookiePermissionManagerPolicy policy;
-
- /* Get new unknown-policy value */
- g_object_get(manager, "unknown-policy", &policy, NULL);
-
- /* Set value in combobox (blocking signal to avoid loops) */
- g_signal_handler_block(priv->unknownPolicyCombo, priv->signalUnknownPolicyID);
- gtk_combo_box_set_active(GTK_COMBO_BOX(priv->unknownPolicyCombo), policy);
- g_signal_handler_unblock(priv->unknownPolicyCombo, priv->signalUnknownPolicyID);
-}
-
-static void _cookie_permission_manager_preferences_window_unknown_policy_changed(CookiePermissionManagerPreferencesWindow *self,
- gpointer *inUserData)
-{
- CookiePermissionManagerPreferencesWindowPrivate *priv=self->priv;
- CookiePermissionManagerPolicy policy;
- GtkTreeIter policyIter;
-
- if(!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(priv->unknownPolicyCombo), &policyIter))
- return;
-
- gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(priv->unknownPolicyCombo)),
- &policyIter,
- 0, &policy,
- -1);
-
- /* Get toogle state of widget (but block signal for manager) and set in manager */
- g_signal_handler_block(priv->manager, priv->signalManagerUnknownPolicyID);
- g_object_set(priv->manager, "unknown-policy", policy, NULL);
- g_signal_handler_unblock(priv->manager, priv->signalManagerUnknownPolicyID);
-}
-
-static void _cookie_permission_manager_preferences_on_policy_editing_started(CookiePermissionManagerPreferencesWindow *self,
- GtkCellEditable *editable,
- gchar *path,
- gpointer *inUserData)
-{
- CookiePermissionManagerPreferencesWindowPrivate *priv=self->priv;
-
- priv->editingCombo=NULL;
-
- if(!GTK_IS_COMBO_BOX(editable)) return;
-
- priv->editingCombo=GTK_WIDGET(editable);
-}
-
-static void _cookie_permission_manager_preferences_on_policy_editing_canceled(CookiePermissionManagerPreferencesWindow *self,
- gpointer *inUserData)
-{
- CookiePermissionManagerPreferencesWindowPrivate *priv=self->priv;
-
- priv->editingCombo=NULL;
-}
-
-static void _cookie_permission_manager_preferences_on_policy_edited(CookiePermissionManagerPreferencesWindow *self,
- gchar *path,
- gchar *newText,
- gpointer *inUserData)
-{
- CookiePermissionManagerPreferencesWindowPrivate *priv=self->priv;
- gchar *domain;
- GtkTreeIter iter;
- GtkTreeIter policyIter;
-
- g_return_if_fail(priv->database);
-
- if (priv->editingCombo == NULL) return;
-
- gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(priv->listStore), &iter, path);
-
- gtk_tree_model_get(GTK_TREE_MODEL(priv->listStore),
- &iter,
- DOMAIN_COLUMN, &domain,
- -1);
-
- /* Get policy from combo box */
- if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(priv->editingCombo), &policyIter))
- {
- gchar *sql;
- gchar *error=NULL;
- gint success;
- gint policy;
- gchar *policyName;
-
- /* Get policy value to set for domain */
- gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(priv->editingCombo)),
- &policyIter,
- 0, &policy,
- 1, &policyName,
- -1);
-
- g_return_if_fail(g_strcmp0(policyName, newText)==0);
-
- /* Add domain name and the selected policy to database */
- sql=sqlite3_mprintf("UPDATE policies SET value = %d WHERE domain = '%q';",
- policy,
- domain);
- success=sqlite3_exec(priv->database, sql, NULL, NULL, &error);
-
- /* Show error message if any */
- if(success==SQLITE_OK)
- {
- gtk_list_store_set(priv->listStore,
- &iter,
- POLICY_COLUMN, newText,
- -1);
- }
- else g_warning(_("SQL fails: %s"), error);
-
-
- if(error) sqlite3_free(error);
-
- /* Free allocated resources */
- sqlite3_free(sql);
- }
-
- priv->editingCombo=NULL;
-}
-
-/* Selection in list changed */
-void _cookie_permission_manager_preferences_changed_selection(CookiePermissionManagerPreferencesWindow *self,
- GtkTreeSelection *inSelection)
-{
- gboolean selected=(gtk_tree_selection_count_selected_rows(inSelection)>0 ? TRUE: FALSE);
-
- gtk_widget_set_sensitive(self->priv->deleteButton, selected);
-}
-
-/* Delete button was clicked on selection */
-void _cookie_permission_manager_preferences_on_delete_selection(CookiePermissionManagerPreferencesWindow *self,
- GtkButton *inButton)
-{
- CookiePermissionManagerPreferencesWindowPrivate *priv=self->priv;
- GList *rows, *row, *refs=NULL;
- GtkTreeRowReference *ref;
- GtkTreeModel *model=GTK_TREE_MODEL(priv->listStore);
- GtkTreeIter iter;
- GtkTreePath *path;
- gchar *domain;
- gchar *sql;
- gint success;
- gchar *error;
-
- /* Get selected rows in list and create a row reference because
- * we will modify the model while iterating through selected rows
- */
- rows=gtk_tree_selection_get_selected_rows(priv->listSelection, &model);
- for(row=rows; row; row=row->next)
- {
- ref=gtk_tree_row_reference_new(model, (GtkTreePath*)row->data);
- refs=g_list_prepend(refs, ref);
- }
- g_list_foreach(rows,(GFunc)gtk_tree_path_free, NULL);
- g_list_free(rows);
-
- /* Delete each selected row by its reference */
- for(row=refs; row; row=row->next)
- {
- /* Get domain from selected row */
- path=gtk_tree_row_reference_get_path((GtkTreeRowReference*)row->data);
- gtk_tree_model_get_iter(model, &iter, path);
- gtk_tree_model_get(model, &iter, DOMAIN_COLUMN, &domain, -1);
-
- /* Delete domain from database */
- sql=sqlite3_mprintf("DELETE FROM policies WHERE domain='%q';", domain);
- success=sqlite3_exec(priv->database,
- sql,
- NULL,
- NULL,
- &error);
- if(success!=SQLITE_OK || error)
- {
- if(error)
- {
- g_critical(_("Failed to execute database statement: %s"), error);
- sqlite3_free(error);
- }
- else g_critical(_("Failed to execute database statement: %s"), sqlite3_errmsg(priv->database));
- }
- sqlite3_free(sql);
-
- /* Delete row from model */
- gtk_list_store_remove(priv->listStore, &iter);
- }
- g_list_foreach(refs,(GFunc)gtk_tree_row_reference_free, NULL);
- g_list_free(refs);
-}
-
-/* Delete all button was clicked */
-void _cookie_permission_manager_preferences_on_delete_all(CookiePermissionManagerPreferencesWindow *self,
- GtkButton *inButton)
-{
- CookiePermissionManagerPreferencesWindowPrivate *priv=self->priv;
- gint success;
- gchar *error=NULL;
- GtkWidget *dialog;
- gint dialogResponse;
-
- /* Ask user if he really wants to delete all permissions */
- dialog=gtk_message_dialog_new(GTK_WINDOW(self),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_YES_NO,
- _("Do you really want to delete all cookie permissions?"));
-
- gtk_window_set_title(GTK_WINDOW(dialog), _("Delete all cookie permissions?"));
- gtk_window_set_icon_name(GTK_WINDOW(dialog), GTK_STOCK_PROPERTIES);
-
- gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
- _("This action will delete all cookie permissions. "
- "You will be asked for permissions again for each web site visited."));
-
- dialogResponse=gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
-
- if(dialogResponse==GTK_RESPONSE_NO) return;
-
- /* Delete all permission */
- success=sqlite3_exec(priv->database,
- "DELETE FROM policies;",
- NULL,
- NULL,
- &error);
-
- if(success!=SQLITE_OK || error)
- {
- if(error)
- {
- g_critical(_("Failed to execute database statement: %s"), error);
- sqlite3_free(error);
- }
- }
-
- /* Re-setup list */
- _cookie_permission_manager_preferences_window_fill(self);
-}
-
-/* Sorting callbacks */
-static gint _cookie_permission_manager_preferences_sort_string_callback(GtkTreeModel *inModel,
- GtkTreeIter *inLeft,
- GtkTreeIter *inRight,
- gpointer inUserData)
-{
- gchar *left, *right;
- gint column=GPOINTER_TO_INT(inUserData);
- gint result;
-
- gtk_tree_model_get(inModel, inLeft, column, &left, -1);
- gtk_tree_model_get(inModel, inRight, column, &right, -1);
-
- result=g_strcmp0(left, right);
-
- g_free(left);
- g_free(right);
-
- return(result);
-}
-
-/* IMPLEMENTATION: GObject */
-
-/* Finalize this object */
-static void cookie_permission_manager_preferences_window_finalize(GObject *inObject)
-{
- CookiePermissionManagerPreferencesWindowPrivate *priv=COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW(inObject)->priv;
-
- /* Dispose allocated resources */
- if(priv->database) sqlite3_close(priv->database);
- priv->database=NULL;
-
- if(priv->manager)
- {
- if(priv->signalManagerChangedDatabaseID) g_signal_handler_disconnect(priv->manager, priv->signalManagerChangedDatabaseID);
- priv->signalManagerChangedDatabaseID=0;
-
- if(priv->signalManagerUnknownPolicyID) g_signal_handler_disconnect(priv->manager, priv->signalManagerUnknownPolicyID);
- priv->signalManagerUnknownPolicyID=0;
-
- g_object_unref(priv->manager);
- priv->manager=NULL;
- }
-
- /* Call parent's class finalize method */
- G_OBJECT_CLASS(cookie_permission_manager_preferences_window_parent_class)->finalize(inObject);
-}
-
-/* Set/get properties */
-static void cookie_permission_manager_preferences_window_set_property(GObject *inObject,
- guint inPropID,
- const GValue *inValue,
- GParamSpec *inSpec)
-{
- CookiePermissionManagerPreferencesWindow *self=COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW(inObject);
- CookiePermissionManagerPreferencesWindowPrivate *priv=self->priv;
- GObject *manager;
-
- switch(inPropID)
- {
- /* Construct-only properties */
- case PROP_MANAGER:
- /* Release old manager if available and disconnect signals */
- if(priv->manager)
- {
- if(priv->signalManagerChangedDatabaseID) g_signal_handler_disconnect(priv->manager, priv->signalManagerChangedDatabaseID);
- priv->signalManagerChangedDatabaseID=0;
-
- if(priv->signalManagerUnknownPolicyID) g_signal_handler_disconnect(priv->manager, priv->signalManagerUnknownPolicyID);
- priv->signalManagerUnknownPolicyID=0;
-
- g_object_unref(priv->manager);
- priv->manager=NULL;
- }
-
- /* Set new cookie permission manager and
- * listen to changes in database property
- */
- manager=g_value_get_object(inValue);
- if(manager)
- {
- priv->manager=g_object_ref(manager);
-
- priv->signalManagerChangedDatabaseID=
- g_signal_connect_swapped(priv->manager,
- "notify::database-filename",
- G_CALLBACK(_cookie_permission_manager_preferences_window_manager_database_changed),
- self);
- _cookie_permission_manager_preferences_window_manager_database_changed(self, NULL, priv->manager);
-
- priv->signalManagerUnknownPolicyID=
- g_signal_connect_swapped(priv->manager,
- "notify::unknown-policy",
- G_CALLBACK(_cookie_permission_manager_preferences_window_manager_unknown_policy_changed),
- self);
- _cookie_permission_manager_preferences_window_manager_unknown_policy_changed(self, NULL, priv->manager);
- }
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
- break;
- }
-}
-
-static void cookie_permission_manager_preferences_window_get_property(GObject *inObject,
- guint inPropID,
- GValue *outValue,
- GParamSpec *inSpec)
-{
- CookiePermissionManagerPreferencesWindow *self=COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW(inObject);
-
- switch(inPropID)
- {
- case PROP_MANAGER:
- g_value_set_object(outValue, self->priv->manager);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
- break;
- }
-}
-
-/* Class initialization
- * Override functions in parent classes and define properties and signals
- */
-static void cookie_permission_manager_preferences_window_class_init(CookiePermissionManagerPreferencesWindowClass *klass)
-{
- GObjectClass *gobjectClass=G_OBJECT_CLASS(klass);
-
- /* Override functions */
- gobjectClass->finalize=cookie_permission_manager_preferences_window_finalize;
- gobjectClass->set_property=cookie_permission_manager_preferences_window_set_property;
- gobjectClass->get_property=cookie_permission_manager_preferences_window_get_property;
-
- /* Set up private structure */
- g_type_class_add_private(klass, sizeof(CookiePermissionManagerPreferencesWindowPrivate));
-
- /* Define properties */
- CookiePermissionManagerPreferencesWindowProperties[PROP_MANAGER]=
- g_param_spec_object("manager",
- _("Cookie permission manager"),
- _("Instance of current cookie permission manager"),
- TYPE_COOKIE_PERMISSION_MANAGER,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
- g_object_class_install_properties(gobjectClass, PROP_LAST, CookiePermissionManagerPreferencesWindowProperties);
-}
-
-/* Object initialization
- * Create private structure and set up default values
- */
-static void cookie_permission_manager_preferences_window_init(CookiePermissionManagerPreferencesWindow *self)
-{
- CookiePermissionManagerPreferencesWindowPrivate *priv;
- GtkTreeSortable *sortableList;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkWidget *widget;
- gchar *text;
- gchar *dialogTitle;
- GtkWidget *scrolled;
- GtkWidget *vbox;
- GtkWidget *hbox;
- gint width, height;
- GtkListStore *list;
- GtkTreeIter listIter;
-
- priv=self->priv=COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW_GET_PRIVATE(self);
-
- /* Set up default values */
- priv->manager=NULL;
-
- /* Get content area to add gui controls to */
- priv->contentArea=gtk_dialog_get_content_area(GTK_DIALOG(self));
-#ifdef HAVE_GTK3
- vbox=gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE);
-#else
- vbox=gtk_vbox_new(FALSE, 0);
-#endif
-
- /* Set up dialog */
- dialogTitle=_("Configure cookie permission");
-
- gtk_window_set_title(GTK_WINDOW(self), dialogTitle);
- gtk_window_set_icon_name(GTK_WINDOW(self), GTK_STOCK_PROPERTIES);
-
- sokoke_widget_get_text_size(GTK_WIDGET(self), "M", &width, &height);
- gtk_window_set_default_size(GTK_WINDOW(self), width*52, -1);
-
- widget=sokoke_xfce_header_new(gtk_window_get_icon_name(GTK_WINDOW(self)), dialogTitle);
- if(widget) gtk_box_pack_start(GTK_BOX(priv->contentArea), widget, FALSE, FALSE, 0);
-
- gtk_dialog_add_button(GTK_DIALOG(self), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
-
- /* Set up description */
- widget=gtk_label_new(NULL);
- text=g_strdup_printf(_("Below is a list of all web sites and the policy set for them. "
- "You can delete policies by marking the entries and clicking on <i>Delete</i>."
- "You can also add a policy for a domain manually by entering the domain below, "
- "choosing the policy and clicking on <i>Add</i>."));
- gtk_label_set_markup(GTK_LABEL(widget), text);
- g_free(text);
- gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
- gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 4);
-
- /* Set up model for cookie domain list */
- priv->listStore=gtk_list_store_new(N_COLUMN,
- G_TYPE_STRING, /* DOMAIN_COLUMN */
- G_TYPE_STRING /* POLICY_COLUMN */);
-
- sortableList=GTK_TREE_SORTABLE(priv->listStore);
- gtk_tree_sortable_set_sort_func(sortableList,
- DOMAIN_COLUMN,
- (GtkTreeIterCompareFunc)_cookie_permission_manager_preferences_sort_string_callback,
- GINT_TO_POINTER(DOMAIN_COLUMN),
- NULL);
- gtk_tree_sortable_set_sort_func(sortableList,
- POLICY_COLUMN,
- (GtkTreeIterCompareFunc)_cookie_permission_manager_preferences_sort_string_callback,
- GINT_TO_POINTER(POLICY_COLUMN),
- NULL);
- gtk_tree_sortable_set_sort_column_id(sortableList, DOMAIN_COLUMN, GTK_SORT_ASCENDING);
-
- /* Set up domain addition widgets */
-#ifdef HAVE_GTK3
- hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE);
-#else
- hbox=gtk_hbox_new(FALSE, 0);
-#endif
-
- priv->addDomainEntry=gtk_entry_new();
- gtk_entry_set_max_length(GTK_ENTRY(priv->addDomainEntry), 64);
- gtk_container_add(GTK_CONTAINER(hbox), priv->addDomainEntry);
- g_signal_connect_swapped(priv->addDomainEntry, "changed", G_CALLBACK(_cookie_permission_manager_preferences_on_add_domain_entry_changed), self);
-
- list=gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING);
- gtk_list_store_append(list, &listIter);
- gtk_list_store_set(list, &listIter, 0, COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT, 1, _("Accept"), -1);
- gtk_list_store_append(list, &listIter);
- gtk_list_store_set(list, &listIter, 0, COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT_FOR_SESSION, 1, _("Accept for session"), -1);
- gtk_list_store_append(list, &listIter);
- gtk_list_store_set(list, &listIter, 0, COOKIE_PERMISSION_MANAGER_POLICY_BLOCK, 1, _("Block"), -1);
-
- priv->addDomainPolicyCombo=gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
- gtk_combo_box_set_active(GTK_COMBO_BOX(priv->addDomainPolicyCombo), 0);
- gtk_container_add(GTK_CONTAINER(hbox), priv->addDomainPolicyCombo);
-
- renderer=gtk_cell_renderer_text_new();
- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(priv->addDomainPolicyCombo), renderer, TRUE);
- gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(priv->addDomainPolicyCombo), renderer, "text", 1);
-
- priv->addDomainButton=gtk_button_new_from_stock(GTK_STOCK_ADD);
- gtk_widget_set_sensitive(priv->addDomainButton, FALSE);
- gtk_container_add(GTK_CONTAINER(hbox), priv->addDomainButton);
- g_signal_connect_swapped(priv->addDomainButton, "clicked", G_CALLBACK(_cookie_permission_manager_preferences_on_add_domain_clicked), self);
-
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 5);
-
- /* Set up cookie domain list */
- priv->list=gtk_tree_view_new_with_model(GTK_TREE_MODEL(priv->listStore));
-
-#ifndef HAVE_GTK3
- gtk_widget_set_size_request(priv->list, -1, 300);
-#endif
-
- priv->listSelection=gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->list));
- gtk_tree_selection_set_mode(priv->listSelection, GTK_SELECTION_MULTIPLE);
- g_signal_connect_swapped(priv->listSelection, "changed", G_CALLBACK(_cookie_permission_manager_preferences_changed_selection), self);
-
- renderer=gtk_cell_renderer_text_new();
- column=gtk_tree_view_column_new_with_attributes(_("Domain"),
- renderer,
- "text", DOMAIN_COLUMN,
- NULL);
- gtk_tree_view_column_set_sort_column_id(column, DOMAIN_COLUMN);
- gtk_tree_view_append_column(GTK_TREE_VIEW(priv->list), column);
-
- renderer=gtk_cell_renderer_combo_new();
- g_object_set(G_OBJECT(renderer), "model", list, "text-column", 1, "has-entry", false, "editable", true, NULL);
- g_signal_connect_swapped(renderer, "editing-started", G_CALLBACK(_cookie_permission_manager_preferences_on_policy_editing_started), self);
- g_signal_connect_swapped(renderer, "editing-canceled", G_CALLBACK(_cookie_permission_manager_preferences_on_policy_editing_canceled), self);
- g_signal_connect_swapped(renderer, "edited", G_CALLBACK(_cookie_permission_manager_preferences_on_policy_edited), self);
- column=gtk_tree_view_column_new_with_attributes(_("Policy"),
- renderer,
- "text", POLICY_COLUMN,
- NULL);
- gtk_tree_view_column_set_sort_column_id(column, POLICY_COLUMN);
- gtk_tree_view_append_column(GTK_TREE_VIEW(priv->list), column);
-
- scrolled=gtk_scrolled_window_new(NULL, NULL);
-#ifdef HAVE_GTK3
- gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(scrolled), height*10);
-#endif
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_container_add(GTK_CONTAINER(scrolled), priv->list);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
- gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 5);
-
- /* Set up cookie domain list management buttons */
-#ifdef HAVE_GTK3
- hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE);
-#else
- hbox=gtk_hbox_new(FALSE, 0);
-#endif
-
- priv->deleteButton=gtk_button_new_from_stock(GTK_STOCK_DELETE);
- gtk_widget_set_sensitive(priv->deleteButton, FALSE);
- gtk_container_add(GTK_CONTAINER(hbox), priv->deleteButton);
- g_signal_connect_swapped(priv->deleteButton, "clicked", G_CALLBACK(_cookie_permission_manager_preferences_on_delete_selection), self);
-
- priv->deleteAllButton=gtk_button_new_with_mnemonic(_("Delete _all"));
- gtk_button_set_image(GTK_BUTTON(priv->deleteAllButton), gtk_image_new_from_stock(GTK_STOCK_DELETE, GTK_ICON_SIZE_BUTTON));
- gtk_widget_set_sensitive(priv->deleteAllButton, FALSE);
- gtk_container_add(GTK_CONTAINER(hbox), priv->deleteAllButton);
- g_signal_connect_swapped(priv->deleteAllButton, "clicked", G_CALLBACK(_cookie_permission_manager_preferences_on_delete_all), self);
-
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 5);
-
- /* Add "unknown-policy" combo */
-#ifdef HAVE_GTK3
- hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE);
-#else
- hbox=gtk_hbox_new(FALSE, 0);
-#endif
- widget=gtk_label_new(_("Policy for cookies from domains not in the list: "));
- gtk_container_add(GTK_CONTAINER(hbox), widget);
-
- list=gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING);
- gtk_list_store_append(list, &listIter);
- gtk_list_store_set(list, &listIter, 0, COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED, 1, _("Ask for a decision"), -1);
- gtk_list_store_append(list, &listIter);
- gtk_list_store_set(list, &listIter, 0, COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT, 1, _("Accept"), -1);
- gtk_list_store_append(list, &listIter);
- gtk_list_store_set(list, &listIter, 0, COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT_FOR_SESSION, 1, _("Accept for session"), -1);
- gtk_list_store_append(list, &listIter);
- gtk_list_store_set(list, &listIter, 0, COOKIE_PERMISSION_MANAGER_POLICY_BLOCK, 1, _("Block"), -1);
-
- priv->unknownPolicyCombo=gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
- gtk_combo_box_set_active(GTK_COMBO_BOX(priv->unknownPolicyCombo), 0);
- gtk_container_add(GTK_CONTAINER(hbox), priv->unknownPolicyCombo);
-
- renderer=gtk_cell_renderer_text_new();
- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(priv->unknownPolicyCombo), renderer, TRUE);
- gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(priv->unknownPolicyCombo), renderer, "text", 1);
-
- priv->signalUnknownPolicyID=g_signal_connect_swapped(priv->unknownPolicyCombo,
- "changed",
- G_CALLBACK(_cookie_permission_manager_preferences_window_unknown_policy_changed),
- self);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 5);
-
- /* Finalize setup of content area */
- gtk_box_pack_start(GTK_BOX(priv->contentArea), vbox, TRUE, TRUE, 0);
-}
-
-/* Implementation: Public API */
-
-/* Create new object */
-GtkWidget* cookie_permission_manager_preferences_window_new(CookiePermissionManager *inManager)
-{
- return(g_object_new(TYPE_COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW,
- "manager", inManager,
- NULL));
-}
diff --git a/extensions/cookie-permissions/cookie-permission-manager-preferences-window.h b/extensions/cookie-permissions/cookie-permission-manager-preferences-window.h
deleted file mode 100644
index 155b8902..00000000
--- a/extensions/cookie-permissions/cookie-permission-manager-preferences-window.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- Copyright (C) 2013 Stephan Haller <nomad@froevel.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 __COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW__
-#define __COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW__
-
-#include "config.h"
-#include <midori/midori.h>
-
-#include "cookie-permission-manager.h"
-
-G_BEGIN_DECLS
-
-#define TYPE_COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW (cookie_permission_manager_preferences_window_get_type())
-#define COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW, CookiePermissionManagerPreferencesWindow))
-#define IS_COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW))
-#define COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW, CookiePermissionManagerPreferencesWindowClass))
-#define IS_COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW))
-#define COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW, CookiePermissionManagerPreferencesWindowClass))
-
-typedef struct _CookiePermissionManagerPreferencesWindow CookiePermissionManagerPreferencesWindow;
-typedef struct _CookiePermissionManagerPreferencesWindowClass CookiePermissionManagerPreferencesWindowClass;
-typedef struct _CookiePermissionManagerPreferencesWindowPrivate CookiePermissionManagerPreferencesWindowPrivate;
-
-struct _CookiePermissionManagerPreferencesWindow
-{
- /* Parent instance */
- GtkDialog parent_instance;
-
- /* Private structure */
- CookiePermissionManagerPreferencesWindowPrivate *priv;
-};
-
-struct _CookiePermissionManagerPreferencesWindowClass
-{
- /* Parent class */
- GtkDialogClass parent_class;
-};
-
-/* Public API */
-GType cookie_permission_manager_preferences_window_get_type(void);
-
-GtkWidget* cookie_permission_manager_preferences_window_new(CookiePermissionManager *inManager);
-
-G_END_DECLS
-
-#endif /* __COOKIE_PERMISSION_MANAGER_PREFERENCES_WINDOW__ */
diff --git a/extensions/cookie-permissions/cookie-permission-manager.c b/extensions/cookie-permissions/cookie-permission-manager.c
deleted file mode 100644
index 4b53cb47..00000000
--- a/extensions/cookie-permissions/cookie-permission-manager.c
+++ /dev/null
@@ -1,1126 +0,0 @@
-/*
- Copyright (C) 2013 Stephan Haller <nomad@froevel.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.
-*/
-
-#include "cookie-permission-manager.h"
-
-#include <errno.h>
-
-/* Remove next line if we found a way to show details in infobar */
-#define NO_INFOBAR_DETAILS
-
-/* Define this class in GObject system */
-G_DEFINE_TYPE(CookiePermissionManager,
- cookie_permission_manager,
- G_TYPE_OBJECT)
-
-/* Properties */
-enum
-{
- PROP_0,
-
- PROP_EXTENSION,
- PROP_APPLICATION,
-
- PROP_DATABASE,
- PROP_DATABASE_FILENAME,
- PROP_UNKNOWN_POLICY,
-
- PROP_LAST
-};
-
-static GParamSpec* CookiePermissionManagerProperties[PROP_LAST]={ 0, };
-
-/* Private structure - access only by public API if needed */
-#define COOKIE_PERMISSION_MANAGER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), TYPE_COOKIE_PERMISSION_MANAGER, CookiePermissionManagerPrivate))
-
-struct _CookiePermissionManagerPrivate
-{
- /* Extension related */
- MidoriExtension *extension;
- MidoriApp *application;
- sqlite3 *database;
- gchar *databaseFilename;
- CookiePermissionManagerPolicy unknownPolicy;
-
- /* Cookie jar related */
- SoupSession *session;
- SoupCookieJar *cookieJar;
- SoupSessionFeatureInterface *featureIface;
- gint cookieJarChangedID;
-};
-
-enum
-{
- DOMAIN_COLUMN,
- PATH_COLUMN,
- NAME_COLUMN,
- VALUE_COLUMN,
- EXPIRE_DATE_COLUMN,
- N_COLUMN
-};
-
-struct _CookiePermissionManagerModalInfobar
-{
- GMainLoop *mainLoop;
- gint response;
-};
-
-typedef struct _CookiePermissionManagerModalInfobar CookiePermissionManagerModalInfobar;
-
-/* IMPLEMENTATION: Private variables and methods */
-
-/* Show common error dialog */
-static void _cookie_permission_manager_error(CookiePermissionManager *self, const gchar *inReason)
-{
- GtkWidget *dialog;
-
- /* Show confirmation dialog for undetermined cookies */
- dialog=gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("A fatal error occurred which prevents "
- "the cookie permission manager extension "
- "to continue. You should disable it."));
-
- gtk_window_set_title(GTK_WINDOW(dialog), _("Error in cookie permission manager extension"));
- gtk_window_set_icon_name(GTK_WINDOW (dialog), "midori");
-
- gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
- "%s:\n%s",
- _("Reason"),
- inReason);
-
- gtk_dialog_run(GTK_DIALOG(dialog));
-
- /* Free up allocated resources */
- gtk_widget_destroy(dialog);
-}
-
-/* Open database containing policies for cookie domains.
- * Create database and setup table structure if it does not exist yet.
- */
-static void _cookie_permission_manager_open_database(CookiePermissionManager *self)
-{
- CookiePermissionManagerPrivate *priv=self->priv;
- const gchar *configDir;
- gchar *error=NULL;
- gint success;
- sqlite3_stmt *statement=NULL;
-
- /* Close any open database */
- if(priv->database)
- {
- g_free(priv->databaseFilename);
- priv->databaseFilename=NULL;
-
- sqlite3_close(priv->database);
- priv->database=NULL;
-
- g_object_notify_by_pspec(G_OBJECT(self), CookiePermissionManagerProperties[PROP_DATABASE]);
- g_object_notify_by_pspec(G_OBJECT(self), CookiePermissionManagerProperties[PROP_DATABASE_FILENAME]);
- }
-
- /* Build path to database file */
- configDir=midori_extension_get_config_dir(priv->extension);
- if(!configDir)
- return;
-
- if(katze_mkdir_with_parents(configDir, 0700))
- {
- g_warning(_("Could not create configuration folder for extension: %s"), g_strerror(errno));
-
- _cookie_permission_manager_error(self, _("Could not create configuration folder for extension."));
- return;
- }
-
- /* Open database */
- priv->databaseFilename=g_build_filename(configDir, COOKIE_PERMISSION_DATABASE, NULL);
- success=sqlite3_open(priv->databaseFilename, &priv->database);
- if(success!=SQLITE_OK)
- {
- g_warning(_("Could not open database of extenstion: %s"), sqlite3_errmsg(priv->database));
-
- g_free(priv->databaseFilename);
- priv->databaseFilename=NULL;
-
- if(priv->database) sqlite3_close(priv->database);
- priv->database=NULL;
-
- _cookie_permission_manager_error(self, _("Could not open database of extension."));
- return;
- }
-
- /* Create table structure if it does not exist */
- success=sqlite3_exec(priv->database,
- "CREATE TABLE IF NOT EXISTS "
- "policies(domain text, value integer);",
- NULL,
- NULL,
- &error);
-
- if(success==SQLITE_OK)
- {
- success=sqlite3_exec(priv->database,
- "CREATE UNIQUE INDEX IF NOT EXISTS "
- "domain ON policies (domain);",
- NULL,
- NULL,
- &error);
- }
-
- if(success==SQLITE_OK)
- {
- success=sqlite3_exec(priv->database,
- "PRAGMA journal_mode=TRUNCATE;",
- NULL,
- NULL,
- &error);
- }
-
- if(success!=SQLITE_OK || error)
- {
- _cookie_permission_manager_error(self, _("Could not set up database structure of extension."));
-
- if(error)
- {
- g_critical(_("Failed to execute database statement: %s"), error);
- sqlite3_free(error);
- }
-
- g_free(priv->databaseFilename);
- priv->databaseFilename=NULL;
-
- sqlite3_close(priv->database);
- priv->database=NULL;
- return;
- }
-
- // Delete all cookies allowed only in one session
- success=sqlite3_prepare_v2(priv->database,
- "SELECT domain FROM policies WHERE value=? ORDER BY domain DESC;",
- -1,
- &statement,
- NULL);
- if(statement && success==SQLITE_OK) success=sqlite3_bind_int(statement, 1, COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT_FOR_SESSION);
- if(statement && success==SQLITE_OK)
- {
- while(sqlite3_step(statement)==SQLITE_ROW)
- {
- gchar *domain=(gchar*)sqlite3_column_text(statement, 0);
- GSList *cookies, *cookie;
-
-#ifdef HAVE_LIBSOUP_2_40_0
- SoupURI *uri;
-
- uri=soup_uri_new(NULL);
- soup_uri_set_host(uri, domain);
- soup_uri_set_path(uri, "/");
- cookies=soup_cookie_jar_get_cookie_list(priv->cookieJar, uri, TRUE);
- for(cookie=cookies; cookie; cookie=cookie->next)
- {
- soup_cookie_jar_delete_cookie(priv->cookieJar, (SoupCookie*)cookie->data);
- }
- soup_cookies_free(cookies);
- soup_uri_free(uri);
-#else
- cookies=soup_cookie_jar_all_cookies(priv->cookieJar);
- for(cookie=cookies; cookie; cookie=cookie->next)
- {
- if(soup_cookie_domain_matches((SoupCookie*)cookie->data, domain))
- {
- soup_cookie_jar_delete_cookie(priv->cookieJar, (SoupCookie*)cookie->data);
- }
- }
- soup_cookies_free(cookies);
-#endif
- }
- }
- else g_warning(_("SQL fails: %s"), sqlite3_errmsg(priv->database));
-
- sqlite3_finalize(statement);
-
- g_object_notify_by_pspec(G_OBJECT(self), CookiePermissionManagerProperties[PROP_DATABASE]);
- g_object_notify_by_pspec(G_OBJECT(self), CookiePermissionManagerProperties[PROP_DATABASE_FILENAME]);
-}
-
-/* Get policy for cookies from domain */
-static gint _cookie_permission_manager_get_policy(CookiePermissionManager *self, SoupCookie *inCookie)
-{
- CookiePermissionManagerPrivate *priv=self->priv;
- sqlite3_stmt *statement=NULL;
- gchar *domain;
- gint error;
- gint policy=COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED;
- gboolean foundPolicy=FALSE;
-
- /* Check for open database */
- g_return_val_if_fail(priv->database, COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED);
-
- /* Lookup policy for cookie domain in database */
- domain=g_strdup(soup_cookie_get_domain(inCookie));
- if(*domain=='.') *domain='%';
-
- error=sqlite3_prepare_v2(priv->database,
- "SELECT domain, value FROM policies WHERE domain LIKE ? ORDER BY domain DESC;",
- -1,
- &statement,
- NULL);
- if(statement && error==SQLITE_OK) error=sqlite3_bind_text(statement, 1, domain, -1, NULL);
- if(statement && error==SQLITE_OK)
- {
- while(policy==COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED &&
- sqlite3_step(statement)==SQLITE_ROW)
- {
- gchar *policyDomain=(gchar*)sqlite3_column_text(statement, 0);
-
- if(soup_cookie_domain_matches(inCookie, policyDomain))
- {
- policy=sqlite3_column_int(statement, 1);
- foundPolicy=TRUE;
- }
- }
- }
- else g_warning(_("SQL fails: %s"), sqlite3_errmsg(priv->database));
-
- sqlite3_finalize(statement);
-
- /* Check if policy is undetermined. If it is then check if this policy was set by user.
- * If it was not set by user, check what to do.
- */
- if(!foundPolicy)
- {
- /* A SoupCookieJar that doesn't want to accept any cookies should override the user's
- * choice, in case of e.g. private mode, to err on the side of caution. */
- SoupCookieJarAcceptPolicy soup_policy=soup_cookie_jar_get_accept_policy(priv->cookieJar);
-
- if(soup_policy==SOUP_COOKIE_JAR_ACCEPT_ALWAYS || soup_policy==SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY)
- {
- policy=priv->unknownPolicy;
- }
- else
- {
- if(soup_policy!=SOUP_COOKIE_JAR_ACCEPT_NEVER)
- g_critical(_("Could not determine global cookie policy to set for domain: %s"), domain);
- policy=COOKIE_PERMISSION_MANAGER_POLICY_BLOCK;
- }
- }
-
- /* Release allocated resources */
- g_free(domain);
-
- return(policy);
-}
-
-/* Ask user what to do with cookies from domain(s) which were neither marked accepted nor blocked */
-static gint _cookie_permission_manager_sort_cookies_by_domain(SoupCookie *inLeft, SoupCookie *inRight)
-{
- const gchar *domainLeft=soup_cookie_get_domain(inLeft);
- const gchar *domainRight=soup_cookie_get_domain(inRight);
-
- if(*domainLeft=='.') domainLeft++;
- if(*domainRight=='.') domainRight++;
-
- return(g_ascii_strcasecmp(domainLeft, domainRight));
-}
-
-static GSList* _cookie_permission_manager_get_number_domains_and_cookies(CookiePermissionManager *self,
- GSList *inCookies,
- gint *ioNumberDomains,
- gint *ioNumberCookies)
-{
- GSList *sortedList, *iter;
- gint domains, cookies;
- const gchar *lastDomain=NULL;
- const gchar *cookieDomain;
-
- /* Make copy and sort cookies in new list */
- sortedList=g_slist_copy(inCookies);
-
- /* Sort cookies by domain to prevent a doman counted multiple times */
- sortedList=g_slist_sort(sortedList, (GCompareFunc)_cookie_permission_manager_sort_cookies_by_domain);
-
- /* Iterate through list and count domains and cookies */
- domains=cookies=0;
- for(iter=sortedList; iter; iter=iter->next)
- {
- cookieDomain=soup_cookie_get_domain((SoupCookie*)iter->data);
-
- if(!lastDomain || g_ascii_strcasecmp(lastDomain, cookieDomain)!=0)
- {
- domains++;
- lastDomain=cookieDomain;
- }
-
- cookies++;
- }
-
- /* Store counted numbers to final variables */
- if(ioNumberDomains) *ioNumberDomains=domains;
- if(ioNumberCookies) *ioNumberCookies=cookies;
-
- /* Return the copied but sorted cookie list. Caller is responsible to free
- * this list with g_slist_free
- */
- return(sortedList);
-}
-
-/* FIXME: Find a way to add "details" widget */
-#ifndef NO_INFOBAR_DETAILS
-static void _cookie_permission_manager_when_ask_expander_changed(CookiePermissionManager *self,
- GParamSpec *inSpec,
- gpointer inUserData)
-{
- GtkExpander *expander=GTK_EXPANDER(inUserData);
-
- midori_extension_set_boolean(self->priv->extension, "show-details-when-ask", gtk_expander_get_expanded(expander));
-}
-#endif
-
-static gboolean _cookie_permission_manager_on_infobar_webview_navigate(WebKitWebView *inView,
- WebKitWebFrame *inFrame,
- WebKitNetworkRequest *inRequest,
- WebKitWebNavigationAction *inAction,
- WebKitWebPolicyDecision *inDecision,
- gpointer inUserData)
-{
- /* Destroy info bar - that calls another callback which quits main loop */
- GtkWidget *infobar=GTK_WIDGET(inUserData);
-
- gtk_widget_destroy(infobar);
-
- /* Let the default handler decide */
- return(FALSE);
-}
-
-static void _cookie_permission_manager_on_infobar_destroy(GtkWidget* inInfobar,
- gpointer inUserData)
-{
- CookiePermissionManagerModalInfobar *modalInfo=(CookiePermissionManagerModalInfobar*)inUserData;
-
- /* Quit main loop */
- if(g_main_loop_is_running(modalInfo->mainLoop)) g_main_loop_quit(modalInfo->mainLoop);
-}
-
-static void _cookie_permission_manager_on_infobar_policy_decision(GtkWidget* inInfobar,
- gint inResponse,
- gpointer inUserData)
-{
- CookiePermissionManagerModalInfobar *modalInfo;
-
- /* Get modal info struct */
- modalInfo=(CookiePermissionManagerModalInfobar*)g_object_get_data(G_OBJECT(inInfobar), "cookie-permission-manager-infobar-data");
-
- /* Store response */
- modalInfo->response=inResponse;
-
- /* Quit main loop */
- if(g_main_loop_is_running(modalInfo->mainLoop)) g_main_loop_quit(modalInfo->mainLoop);
-}
-
-static gint _cookie_permission_manager_ask_for_policy(CookiePermissionManager *self,
- MidoriView *inView,
- SoupMessage *inMessage,
- GSList *inUnknownCookies)
-{
- /* Ask user for policy of unkndown domains in an undistracting way.
- * The idea is to put the message not in a modal window but into midori's info bar.
- * Then we'll set up our own GMainLoop to simulate a modal info bar. We need to
- * connect to all possible signals of info bar, web view and so on to handle user's
- * decision and to get out of our own GMainLoop. After that webkit resumes processing
- * data.
- */
- CookiePermissionManagerPrivate *priv=self->priv;
- GtkWidget *infobar;
-/* FIXME: Find a way to add "details" widget */
-#ifndef NO_INFOBAR_DETAILS
- GtkWidget *widget;
- GtkWidget *contentArea;
- GtkWidget *vbox, *hbox;
- GtkWidget *expander;
- GtkListStore *listStore;
- GtkTreeIter listIter;
- GtkWidget *scrolled;
- GtkWidget *list;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
-#endif
- gchar *text;
- gint numberDomains, numberCookies;
- GSList *sortedCookies, *cookies;
- WebKitWebView *webkitView;
- CookiePermissionManagerModalInfobar *modalInfo;
-
- /* Get webkit view of midori view */
- webkitView=WEBKIT_WEB_VIEW(midori_view_get_web_view(inView));
- modalInfo=g_new0(CookiePermissionManagerModalInfobar, 1);
-
- /* Create a copy of cookies and sort them */
- sortedCookies=_cookie_permission_manager_get_number_domains_and_cookies(self,
- inUnknownCookies,
- &numberDomains,
- &numberCookies);
-
-/* FIXME: Find a way to add "details" widget */
-#ifndef NO_INFOBAR_DETAILS
- /* Create list model and fill in data */
- listStore=gtk_list_store_new(N_COLUMN,
- G_TYPE_STRING, /* DOMAIN_COLUMN */
- G_TYPE_STRING, /* PATH_COLUMN */
- G_TYPE_STRING, /* NAME_COLUMN */
- G_TYPE_STRING, /* VALUE_COLUMN */
- G_TYPE_STRING /* EXPIRE_DATE_COLUMN */);
-
- for(cookies=sortedCookies; cookies; cookies=cookies->next)
- {
- SoupCookie *cookie=(SoupCookie*)cookies->data;
- SoupDate *cookieDate=soup_cookie_get_expires(cookie);
-
- if(cookieDate) text=soup_date_to_string(cookieDate, SOUP_DATE_HTTP);
- else text=g_strdup(_("Till session end"));
-
- gtk_list_store_append(listStore, &listIter);
- gtk_list_store_set(listStore,
- &listIter,
- DOMAIN_COLUMN, soup_cookie_get_domain(cookie),
- PATH_COLUMN, soup_cookie_get_path(cookie),
- NAME_COLUMN, soup_cookie_get_name(cookie),
- VALUE_COLUMN, soup_cookie_get_value(cookie),
- EXPIRE_DATE_COLUMN, text,
- -1);
-
- g_free(text);
- }
-#endif
-
- /* Create description text */
- if(numberDomains==1)
- {
- const gchar *cookieDomain=soup_cookie_get_domain((SoupCookie*)sortedCookies->data);
-
- if(*cookieDomain=='.') cookieDomain++;
-
- if(numberCookies>1)
- text=g_strdup_printf(_("The website %s wants to store %d cookies."), cookieDomain, numberCookies);
- else
- text=g_strdup_printf(_("The website %s wants to store a cookie."), cookieDomain);
- }
- else
- {
- text=g_strdup_printf(_("Multiple websites want to store %d cookies in total."), numberCookies);
- }
-
- /* Create info bar message and buttons */
- infobar=midori_view_add_info_bar(inView,
- GTK_MESSAGE_QUESTION,
- text,
- G_CALLBACK(_cookie_permission_manager_on_infobar_policy_decision),
- NULL,
- _("_Accept"), COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT,
- _("Accept for this _session"), COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT_FOR_SESSION,
- _("De_ny"), COOKIE_PERMISSION_MANAGER_POLICY_BLOCK,
- _("Deny _this time"), COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED,
- NULL);
- g_free(text);
-
- /* midori_view_add_info_bar() in version 0.4.8 expects a GObject as user data
- * but I don't want to create an GObject just for a simple struct. So set object
- * data by our own
- */
- g_object_set_data_full(G_OBJECT(infobar), "cookie-permission-manager-infobar-data", modalInfo, (GDestroyNotify)g_free);
-
-/* FIXME: Find a way to add "details" widget */
-#ifndef NO_INFOBAR_DETAILS
- /* Get content area of infobar */
- contentArea=gtk_info_bar_get_content_area(GTK_INFO_BAR(infobar));
-
- /* Create list and set up columns of list */
- list=gtk_tree_view_new_with_model(GTK_TREE_MODEL(listStore));
-#ifndef HAVE_GTK3
- gtk_widget_set_size_request(list, -1, 100);
-#endif
-
- renderer=gtk_cell_renderer_text_new();
- column=gtk_tree_view_column_new_with_attributes(_("Domain"),
- renderer,
- "text", DOMAIN_COLUMN,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
-
- renderer=gtk_cell_renderer_text_new();
- column=gtk_tree_view_column_new_with_attributes(_("Path"),
- renderer,
- "text", PATH_COLUMN,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
-
- renderer=gtk_cell_renderer_text_new();
- column=gtk_tree_view_column_new_with_attributes(_("Name"),
- renderer,
- "text", NAME_COLUMN,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
-
- renderer=gtk_cell_renderer_text_new();
- column=gtk_tree_view_column_new_with_attributes(_("Value"),
- renderer,
- "text", VALUE_COLUMN,
- NULL);
- g_object_set(G_OBJECT(renderer),
- "ellipsize", PANGO_ELLIPSIZE_END,
- "width-chars", 30,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
-
- renderer=gtk_cell_renderer_text_new();
- column=gtk_tree_view_column_new_with_attributes(_("Expire date"),
- renderer,
- "text", EXPIRE_DATE_COLUMN,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
-
- scrolled=gtk_scrolled_window_new(NULL, NULL);
-#ifdef HAVE_GTK3
- gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(scrolled), 100);
-#endif
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_container_add(GTK_CONTAINER(scrolled), list);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
- gtk_container_add(GTK_CONTAINER(expander), scrolled);
-
- gtk_widget_show_all(vbox);
- gtk_container_add(GTK_CONTAINER(contentArea), vbox);
-
- /* Set state of expander based on config 'show-details-when-ask' */
- gtk_expander_set_expanded(GTK_EXPANDER(expander),
- midori_extension_get_boolean(priv->extension, "show-details-when-ask"));
- g_signal_connect_swapped(expander, "notify::expanded", G_CALLBACK(_cookie_permission_manager_when_ask_expander_changed), self);
-#endif
-
- /* Show all widgets of info bar */
- gtk_widget_show_all(infobar);
-
- /* Connect signals to quit main loop */
- g_signal_connect(webkitView, "navigation-policy-decision-requested", G_CALLBACK(_cookie_permission_manager_on_infobar_webview_navigate), infobar);
- g_signal_connect(infobar, "destroy", G_CALLBACK(_cookie_permission_manager_on_infobar_destroy), modalInfo);
-
- /* Let info bar be modal and set response to default */
- modalInfo->response=COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED;
- modalInfo->mainLoop=g_main_loop_new(NULL, FALSE);
-
- GDK_THREADS_LEAVE();
- g_main_loop_run(modalInfo->mainLoop);
- GDK_THREADS_ENTER();
-
- g_main_loop_unref(modalInfo->mainLoop);
-
- modalInfo->mainLoop=NULL;
-
- /* Disconnect signal handler to webkit's web view */
- g_signal_handlers_disconnect_by_func(webkitView, G_CALLBACK(_cookie_permission_manager_on_infobar_webview_navigate), infobar);
-
- /* Store user's decision in database if it is not a temporary block.
- * We use the already sorted list of cookies to prevent multiple
- * updates of database for the same domain. This sorted list is a copy
- * to avoid a reorder of cookies
- */
- if(modalInfo->response!=COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED)
- {
- const gchar *lastDomain=NULL;
-
- /* Iterate through cookies and store decision for each domain once */
- for(cookies=sortedCookies; cookies; cookies=cookies->next)
- {
- SoupCookie *cookie=(SoupCookie*)cookies->data;
- const gchar *cookieDomain=soup_cookie_get_domain(cookie);
-
- if(*cookieDomain=='.') cookieDomain++;
-
- /* Store decision if new domain found while iterating through cookies */
- if(!lastDomain || g_ascii_strcasecmp(lastDomain, cookieDomain)!=0)
- {
- gchar *sql;
- gchar *error=NULL;
- gint success;
-
- sql=sqlite3_mprintf("INSERT OR REPLACE INTO policies (domain, value) VALUES ('%q', %d);",
- cookieDomain,
- modalInfo->response);
- success=sqlite3_exec(priv->database, sql, NULL, NULL, &error);
- if(success!=SQLITE_OK) g_warning(_("SQL fails: %s"), error);
- if(error) sqlite3_free(error);
- sqlite3_free(sql);
-
- lastDomain=cookieDomain;
- }
- }
- }
-
- /* Free up allocated resources */
- g_slist_free(sortedCookies);
-
- /* Return response */
- return(modalInfo->response==COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED ?
- COOKIE_PERMISSION_MANAGER_POLICY_BLOCK : modalInfo->response);
-}
-
-/* A cookie was changed outside a request (e.g. Javascript) */
-static void _cookie_permission_manager_on_cookie_changed(CookiePermissionManager *self,
- SoupCookie *inOldCookie,
- SoupCookie *inNewCookie,
- SoupCookieJar *inCookieJar)
-{
- /* Do not check changed cookies because they must have been allowed before.
- * Also do not check removed cookies because they are removed ;)
- */
- if(inNewCookie==NULL || inOldCookie) return;
-
- /* New cookie is a new cookie so check */
- switch(_cookie_permission_manager_get_policy(self, inNewCookie))
- {
- case COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT:
- case COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT_FOR_SESSION:
- break;
-
- case COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED:
- /* Fallthrough!
- * The problem here is that we don't know the view to ask user
- * for policy to follow for this cookie domain. Therefore we
- * delete the cookie from jar and assume that we will be asked
- * again in _cookie_permission_manager_on_response_received().
- */
-
- default:
- soup_cookie_jar_delete_cookie(inCookieJar, inNewCookie);
- break;
- }
-}
-
-/* We received the HTTP headers of the request and it contains cookie-managing headers */
-static void _cookie_permission_manager_on_response_received(WebKitWebView *inView,
- WebKitWebFrame *inFrame,
- WebKitWebResource *inResource,
- WebKitNetworkResponse *inResponse,
- gpointer inUserData)
-{
- g_return_if_fail(IS_COOKIE_PERMISSION_MANAGER(inUserData));
-
- CookiePermissionManager *self=COOKIE_PERMISSION_MANAGER(inUserData);
- CookiePermissionManagerPrivate *priv=self->priv;
- GSList *newCookies, *cookie;
- GSList *unknownCookies=NULL, *acceptedCookies=NULL;
- SoupURI *firstParty;
- SoupCookieJarAcceptPolicy cookiePolicy;
- gint unknownCookiesPolicy;
- SoupMessage *message;
-
- /* If policy is to deny all cookies return immediately */
- cookiePolicy=soup_cookie_jar_get_accept_policy(priv->cookieJar);
- if(cookiePolicy==SOUP_COOKIE_JAR_ACCEPT_NEVER) return;
-
- /* Get SoupMessage */
- message=webkit_network_response_get_message(inResponse);
- if(!message || !SOUP_IS_MESSAGE(message)) return;
-
- /* Iterate through cookies in response and check if they should be
- * blocked (remove from cookies list) or accepted (added to cookie jar).
- * If we could not determine what to do collect these cookies and
- * ask user
- */
- newCookies=soup_cookies_from_response(message);
- firstParty=soup_message_get_first_party(message);
- for(cookie=newCookies; cookie; cookie=cookie->next)
- {
- switch(_cookie_permission_manager_get_policy(self, cookie->data))
- {
- case COOKIE_PERMISSION_MANAGER_POLICY_BLOCK:
- soup_cookie_free(cookie->data);
- break;
-
- case COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT:
- case COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT_FOR_SESSION:
- if((cookiePolicy==SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY &&
- firstParty!=NULL &&
- firstParty->host &&
- soup_cookie_domain_matches(cookie->data, firstParty->host)) ||
- cookiePolicy==SOUP_COOKIE_JAR_ACCEPT_ALWAYS)
- {
- acceptedCookies=g_slist_prepend(acceptedCookies, cookie->data);
- }
- else soup_cookie_free(cookie->data);
- break;
-
- case COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED:
- default:
- if((cookiePolicy==SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY &&
- firstParty!=NULL &&
- firstParty->host &&
- soup_cookie_domain_matches(cookie->data, firstParty->host)) ||
- cookiePolicy==SOUP_COOKIE_JAR_ACCEPT_ALWAYS)
- {
- unknownCookies=g_slist_prepend(unknownCookies, cookie->data);
- }
- else soup_cookie_free(cookie->data);
- break;
- }
- }
-
- /* Prepending an item to list is the fastest method but the order of cookies
- * is reversed now and may be added to cookie jar in the wrong order. So we
- * need to reverse list now of both - undetermined and accepted cookies
- */
- unknownCookies=g_slist_reverse(unknownCookies);
- acceptedCookies=g_slist_reverse(acceptedCookies);
-
- /* Ask user for his decision what to do with cookies whose policy is undetermined
- * But only ask if there is any undetermined one
- */
- if(g_slist_length(unknownCookies)>0)
- {
- /* Get view */
- MidoriView *view;
-
- view=MIDORI_VIEW(g_object_get_data(G_OBJECT(inView), "midori-view"));
-
- /* Ask for user's decision */
- unknownCookiesPolicy=_cookie_permission_manager_ask_for_policy(self, view, message, unknownCookies);
- if(unknownCookiesPolicy==COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT ||
- unknownCookiesPolicy==COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT_FOR_SESSION)
- {
- /* Add accepted undetermined cookies to cookie jar */
- for(cookie=unknownCookies; cookie; cookie=cookie->next)
- {
- soup_cookie_jar_add_cookie(priv->cookieJar, (SoupCookie*)cookie->data);
- }
- }
- else
- {
- /* Free cookies because they should be blocked */
- for(cookie=unknownCookies; cookie; cookie=cookie->next)
- {
- soup_cookie_free((SoupCookie*)cookie->data);
- }
- }
- }
-
- /* Add accepted cookies to cookie jar */
- for(cookie=acceptedCookies; cookie; cookie=cookie->next)
- {
- soup_cookie_jar_add_cookie(priv->cookieJar, (SoupCookie*)cookie->data);
- }
-
- /* Free list of cookies */
- g_slist_free(unknownCookies);
- g_slist_free(acceptedCookies);
- g_slist_free(newCookies);
-}
-
-/* A tab to a browser was added */
-static void _cookie_permission_manager_on_add_tab(CookiePermissionManager *self, MidoriView *inView, gpointer inUserData)
-{
- /* Listen to starting network requests */
- WebKitWebView *webkitView=WEBKIT_WEB_VIEW(midori_view_get_web_view(inView));
-
- g_object_set_data(G_OBJECT(webkitView), "midori-view", inView);
- g_signal_connect(webkitView, "resource-response-received", G_CALLBACK(_cookie_permission_manager_on_response_received), self);
-}
-
-/* A browser window was added */
-static void _cookie_permission_manager_on_add_browser(CookiePermissionManager *self,
- MidoriBrowser *inBrowser,
- gpointer inUserData)
-{
- GList *tabs, *iter;
-
- /* Set up all current available tabs in browser */
- tabs=midori_browser_get_tabs(inBrowser);
- for(iter=tabs; iter; iter=g_list_next(iter))
- {
- _cookie_permission_manager_on_add_tab(self, iter->data, inBrowser);
- }
- g_list_free(tabs);
-
- /* Listen to new tabs opened in browser and existing ones closed */
- g_signal_connect_swapped(inBrowser, "add-tab", G_CALLBACK(_cookie_permission_manager_on_add_tab), self);
-}
-
-/* Application property has changed */
-static void _cookie_permission_manager_on_application_changed(CookiePermissionManager *self)
-{
- CookiePermissionManagerPrivate *priv=COOKIE_PERMISSION_MANAGER(self)->priv;
- GList *browsers, *iter;
-
- /* Set up all current open browser windows */
- browsers=midori_app_get_browsers(priv->application);
- for(iter=browsers; iter; iter=g_list_next(iter))
- {
- _cookie_permission_manager_on_add_browser(self, MIDORI_BROWSER(iter->data), priv->application);
- }
- g_list_free(browsers);
-
- /* Listen to new browser windows opened and existing ones closed */
- g_signal_connect_swapped(priv->application, "add-browser", G_CALLBACK(_cookie_permission_manager_on_add_browser), self);
-}
-
-/* IMPLEMENTATION: GObject */
-
-/* Finalize this object */
-static void cookie_permission_manager_finalize(GObject *inObject)
-{
- CookiePermissionManager *self=COOKIE_PERMISSION_MANAGER(inObject);
- CookiePermissionManagerPrivate *priv=self->priv;
- GList *browsers, *browser;
- GList *tabs, *tab;
- WebKitWebView *webkitView;
-
- /* Dispose allocated resources */
- if(priv->databaseFilename)
- {
- g_free(priv->databaseFilename);
- priv->databaseFilename=NULL;
- g_object_notify_by_pspec(inObject, CookiePermissionManagerProperties[PROP_DATABASE_FILENAME]);
- }
-
- if(priv->database)
- {
- sqlite3_close(priv->database);
- priv->database=NULL;
- g_object_notify_by_pspec(inObject, CookiePermissionManagerProperties[PROP_DATABASE]);
- }
-
- g_signal_handler_disconnect(priv->cookieJar, priv->cookieJarChangedID);
- g_object_steal_data(G_OBJECT(priv->cookieJar), "cookie-permission-manager");
-
- g_signal_handlers_disconnect_by_data(priv->application, self);
-
- browsers=midori_app_get_browsers(priv->application);
- for(browser=browsers; browser; browser=g_list_next(browser))
- {
- g_signal_handlers_disconnect_by_data(browser->data, self);
-
- tabs=midori_browser_get_tabs(MIDORI_BROWSER(browser->data));
- for(tab=tabs; tab; tab=g_list_next(tab))
- {
- webkitView=WEBKIT_WEB_VIEW(midori_view_get_web_view(MIDORI_VIEW(tab->data)));
- g_signal_handlers_disconnect_by_data(webkitView, self);
- }
- g_list_free(tabs);
- }
- g_list_free(browsers);
-
- /* Call parent's class finalize method */
- G_OBJECT_CLASS(cookie_permission_manager_parent_class)->finalize(inObject);
-}
-
-/* Set/get properties */
-static void cookie_permission_manager_set_property(GObject *inObject,
- guint inPropID,
- const GValue *inValue,
- GParamSpec *inSpec)
-{
- CookiePermissionManager *self=COOKIE_PERMISSION_MANAGER(inObject);
-
- switch(inPropID)
- {
- /* Construct-only properties */
- case PROP_EXTENSION:
- self->priv->extension=g_value_get_object(inValue);
- _cookie_permission_manager_open_database(self);
- break;
-
- case PROP_APPLICATION:
- self->priv->application=g_value_get_object(inValue);
- _cookie_permission_manager_on_application_changed(self);
- break;
-
- case PROP_UNKNOWN_POLICY:
- cookie_permission_manager_set_unknown_policy(self, g_value_get_int(inValue));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
- break;
- }
-}
-
-static void cookie_permission_manager_get_property(GObject *inObject,
- guint inPropID,
- GValue *outValue,
- GParamSpec *inSpec)
-{
- CookiePermissionManager *self=COOKIE_PERMISSION_MANAGER(inObject);
-
- switch(inPropID)
- {
- case PROP_EXTENSION:
- g_value_set_object(outValue, self->priv->extension);
- break;
-
- case PROP_APPLICATION:
- g_value_set_object(outValue, self->priv->application);
- break;
-
- case PROP_DATABASE:
- g_value_set_pointer(outValue, self->priv->database);
- break;
-
- case PROP_DATABASE_FILENAME:
- g_value_set_string(outValue, self->priv->databaseFilename);
- break;
-
- case PROP_UNKNOWN_POLICY:
- g_value_set_int(outValue, self->priv->unknownPolicy);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
- break;
- }
-}
-
-/* Class initialization
- * Override functions in parent classes and define properties and signals
- */
-static void cookie_permission_manager_class_init(CookiePermissionManagerClass *klass)
-{
- GObjectClass *gobjectClass=G_OBJECT_CLASS(klass);
-
- /* Override functions */
- gobjectClass->finalize=cookie_permission_manager_finalize;
- gobjectClass->set_property=cookie_permission_manager_set_property;
- gobjectClass->get_property=cookie_permission_manager_get_property;
-
- /* Set up private structure */
- g_type_class_add_private(klass, sizeof(CookiePermissionManagerPrivate));
-
- /* Define properties */
- CookiePermissionManagerProperties[PROP_EXTENSION]=
- g_param_spec_object("extension",
- _("Extension instance"),
- _("The Midori extension instance for this extension"),
- MIDORI_TYPE_EXTENSION,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
- CookiePermissionManagerProperties[PROP_APPLICATION]=
- g_param_spec_object("application",
- _("Application instance"),
- _("The Midori application instance this extension belongs to"),
- MIDORI_TYPE_APP,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
- CookiePermissionManagerProperties[PROP_DATABASE]=
- g_param_spec_pointer("database",
- _("Database instance"),
- _("Pointer to sqlite database instance used by this extension"),
- G_PARAM_READABLE);
-
- CookiePermissionManagerProperties[PROP_DATABASE_FILENAME]=
- g_param_spec_string("database-filename",
- _("Database path"),
- _("Path to sqlite database instance used by this extension"),
- NULL,
- G_PARAM_READABLE);
-
- CookiePermissionManagerProperties[PROP_UNKNOWN_POLICY]=
- g_param_spec_int("unknown-policy",
- _("Unknown domain policy"),
- _("The policy to use for domains not individually configured."
- " This only acts to further restrict the global cookie policy set in Midori settings."),
- COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED,
- COOKIE_PERMISSION_MANAGER_POLICY_BLOCK,
- COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
-
- g_object_class_install_properties(gobjectClass, PROP_LAST, CookiePermissionManagerProperties);
-}
-
-/* Object initialization
- * Create private structure and set up default values
- */
-static void cookie_permission_manager_init(CookiePermissionManager *self)
-{
- CookiePermissionManagerPrivate *priv;
-
- priv=self->priv=COOKIE_PERMISSION_MANAGER_GET_PRIVATE(self);
-
- /* Set up default values */
- priv->database=NULL;
- priv->databaseFilename=NULL;
- priv->unknownPolicy=COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED;
-
- /* Hijack session's cookie jar to handle cookies requests on our own in HTTP streams
- * but remember old handlers to restore them on deactivation
- */
- priv->session=webkit_get_default_session();
- priv->cookieJar=SOUP_COOKIE_JAR(soup_session_get_feature(priv->session, SOUP_TYPE_COOKIE_JAR));
- priv->featureIface=SOUP_SESSION_FEATURE_GET_CLASS(priv->cookieJar);
- g_object_set_data(G_OBJECT(priv->cookieJar), "cookie-permission-manager", self);
-
- /* Listen to changed cookies set or changed by other sources like javascript */
- priv->cookieJarChangedID=g_signal_connect_swapped(priv->cookieJar, "changed", G_CALLBACK(_cookie_permission_manager_on_cookie_changed), self);
-}
-
-/* Implementation: Public API */
-
-/* Create new object */
-CookiePermissionManager* cookie_permission_manager_new(MidoriExtension *inExtension, MidoriApp *inApp)
-{
- return(g_object_new(TYPE_COOKIE_PERMISSION_MANAGER,
- "extension", inExtension,
- "application", inApp,
- NULL));
-}
-
-/* Get/set policy to ask for policy if unknown for a domain */
-CookiePermissionManagerPolicy cookie_permission_manager_get_unknown_policy(CookiePermissionManager *self)
-{
- g_return_val_if_fail(IS_COOKIE_PERMISSION_MANAGER(self), COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED);
-
- return(self->priv->unknownPolicy);
-}
-
-void cookie_permission_manager_set_unknown_policy(CookiePermissionManager *self, CookiePermissionManagerPolicy inPolicy)
-{
- g_return_if_fail(IS_COOKIE_PERMISSION_MANAGER(self));
-
- if(inPolicy!=self->priv->unknownPolicy)
- {
- self->priv->unknownPolicy=inPolicy;
- midori_extension_set_integer(self->priv->extension, "unknown-policy", inPolicy);
- g_object_notify_by_pspec(G_OBJECT(self), CookiePermissionManagerProperties[PROP_UNKNOWN_POLICY]);
- }
-}
-
-/************************************************************************************/
-
-/* Implementation: Enumeration */
-GType cookie_permission_manager_policy_get_type(void)
-{
- static volatile gsize g_define_type_id__volatile=0;
-
- if(g_once_init_enter(&g_define_type_id__volatile))
- {
- static const GEnumValue values[]=
- {
- { COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED, "COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED", N_("Undetermined") },
- { COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT, "COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT", N_("Accept") },
- { COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT_FOR_SESSION, "COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT_FOR_SESSION", N_("Accept for session") },
- { COOKIE_PERMISSION_MANAGER_POLICY_BLOCK, "COOKIE_PERMISSION_MANAGER_POLICY_BLOCK", N_("Block") },
- { 0, NULL, NULL }
- };
-
- GType g_define_type_id=g_enum_register_static(g_intern_static_string("CookiePermissionManagerPolicy"), values);
- g_once_init_leave(&g_define_type_id__volatile, g_define_type_id);
- }
-
- return(g_define_type_id__volatile);
-}
diff --git a/extensions/cookie-permissions/cookie-permission-manager.h b/extensions/cookie-permissions/cookie-permission-manager.h
deleted file mode 100644
index 1ba5a0ba..00000000
--- a/extensions/cookie-permissions/cookie-permission-manager.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Copyright (C) 2013 Stephan Haller <nomad@froevel.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 __COOKIE_PERMISSION_MANAGER__
-#define __COOKIE_PERMISSION_MANAGER__
-
-#include "config.h"
-#include <midori/midori.h>
-
-#define COOKIE_PERMISSION_DATABASE "domains.db"
-
-G_BEGIN_DECLS
-
-/* Cookie permission manager enums */
-typedef enum
-{
- COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED,
- COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT,
- COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT_FOR_SESSION,
- COOKIE_PERMISSION_MANAGER_POLICY_BLOCK
-} CookiePermissionManagerPolicy;
-
-/* Cookie permission manager object */
-#define TYPE_COOKIE_PERMISSION_MANAGER (cookie_permission_manager_get_type())
-#define COOKIE_PERMISSION_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_COOKIE_PERMISSION_MANAGER, CookiePermissionManager))
-#define IS_COOKIE_PERMISSION_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_COOKIE_PERMISSION_MANAGER))
-#define COOKIE_PERMISSION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_COOKIE_PERMISSION_MANAGER, CookiePermissionManagerClass))
-#define IS_COOKIE_PERMISSION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_COOKIE_PERMISSION_MANAGER))
-#define COOKIE_PERMISSION_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_COOKIE_PERMISSION_MANAGER, CookiePermissionManagerClass))
-
-typedef struct _CookiePermissionManager CookiePermissionManager;
-typedef struct _CookiePermissionManagerClass CookiePermissionManagerClass;
-typedef struct _CookiePermissionManagerPrivate CookiePermissionManagerPrivate;
-
-struct _CookiePermissionManager
-{
- /* Parent instance */
- GObject parent_instance;
-
- /* Private structure */
- CookiePermissionManagerPrivate *priv;
-};
-
-struct _CookiePermissionManagerClass
-{
- /* Parent class */
- GObjectClass parent_class;
-};
-
-/* Public API */
-GType cookie_permission_manager_get_type(void);
-
-CookiePermissionManager* cookie_permission_manager_new(MidoriExtension *inExtension, MidoriApp *inApp);
-
-CookiePermissionManagerPolicy cookie_permission_manager_get_unknown_policy(CookiePermissionManager *self);
-void cookie_permission_manager_set_unknown_policy(CookiePermissionManager *self, CookiePermissionManagerPolicy inPolicy);
-
-/* Enumeration */
-GType cookie_permission_manager_policy_get_type(void) G_GNUC_CONST;
-#define COOKIE_PERMISSION_MANAGER_TYPE_POLICY (cookie_permission_manager_policy_get_type())
-
-G_END_DECLS
-
-#endif /* __COOKIE_PERMISSION_MANAGER__ */
diff --git a/extensions/cookie-permissions/main.c b/extensions/cookie-permissions/main.c
deleted file mode 100644
index 1efc04f6..00000000
--- a/extensions/cookie-permissions/main.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- Copyright (C) 2013 Stephan Haller <nomad@froevel.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.
-*/
-
-#include "cookie-permission-manager.h"
-#include "cookie-permission-manager-preferences-window.h"
-
-/* Global instance */
-CookiePermissionManager *cpm=NULL;
-
-/* This extension was activated */
-static void _cpm_on_activate(MidoriExtension *inExtension, MidoriApp *inApp, gpointer inUserData)
-{
- g_return_if_fail(cpm==NULL);
-
- cpm=cookie_permission_manager_new(inExtension, inApp);
- g_object_set(cpm, "unknown-policy", midori_extension_get_integer(inExtension, "unknown-policy"), NULL);
-}
-
-/* This extension was deactivated */
-static void _cpm_on_deactivate(MidoriExtension *inExtension, gpointer inUserData)
-{
- g_return_if_fail(cpm);
-
- g_object_unref(cpm);
- cpm=NULL;
-}
-
-/* Preferences of this extension should be opened */
-static void _cpm_on_open_preferences_response(GtkWidget* inDialog,
- gint inResponse,
- MidoriExtension* inExtension)
-{
- gtk_widget_destroy(inDialog);
-}
-
-static void _cpm_on_open_preferences(MidoriExtension *inExtension)
-{
- g_return_if_fail(cpm);
-
- /* Show preferences window */
- GtkWidget* dialog;
-
- dialog=cookie_permission_manager_preferences_window_new(cpm);
- gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
- g_signal_connect(dialog, "response", G_CALLBACK (_cpm_on_open_preferences_response), inExtension);
- gtk_widget_show_all(dialog);
-}
-
-/* Main entry for extension */
-MidoriExtension *extension_init(void)
-{
- /* Set up extension */
- MidoriExtension *extension=g_object_new(MIDORI_TYPE_EXTENSION,
- "name", _("Cookie Security Manager"),
- "description", _("Manage cookie permission per site"),
- "version", "0.1" MIDORI_VERSION_SUFFIX,
- "authors", "Stephan Haller <nomad@froevel.de>",
- NULL);
-
- midori_extension_install_integer(extension, "unknown-policy", COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED);
- midori_extension_install_boolean(extension, "show-details-when-ask", FALSE);
-
- g_signal_connect(extension, "activate", G_CALLBACK(_cpm_on_activate), NULL);
- g_signal_connect(extension, "deactivate", G_CALLBACK(_cpm_on_deactivate), NULL);
- g_signal_connect(extension, "open-preferences", G_CALLBACK(_cpm_on_open_preferences), NULL);
-
- return(extension);
-}
diff --git a/extensions/copy-tabs.c b/extensions/copy-tabs.c
deleted file mode 100644
index 8c349a40..00000000
--- a/extensions/copy-tabs.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- Copyright (C) 2008-2010 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.
-*/
-
-#include <midori/midori.h>
-
-static void
-copy_tabs_apply_cb (GtkWidget* menuitem,
- MidoriBrowser* browser)
-{
- GList* children;
- GString* text = g_string_sized_new (256);
- GtkClipboard* clipboard = gtk_widget_get_clipboard (menuitem,
- GDK_SELECTION_CLIPBOARD);
-
- children = midori_browser_get_tabs (MIDORI_BROWSER (browser));
- for (; children; children = g_list_next (children))
- {
- g_string_append (text, midori_view_get_display_uri (children->data));
- g_string_append_c (text, '\n');
- }
- gtk_clipboard_set_text (clipboard, text->str, -1);
- g_string_free (text, TRUE);
- g_list_free (children);
-}
-
-static void
-copy_tabs_browser_populate_tool_menu_cb (MidoriBrowser* browser,
- GtkWidget* menu,
- MidoriExtension* extension)
-{
- GtkWidget* menuitem = gtk_menu_item_new_with_mnemonic (_("Copy Tab _Addresses"));
-
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (copy_tabs_apply_cb), browser);
- gtk_widget_show (menuitem);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-}
-
-static void
-copy_tabs_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension);
-
-static void
-copy_tabs_deactivate_cb (MidoriExtension* extension,
- MidoriBrowser* browser)
-{
- MidoriApp* app = midori_extension_get_app (extension);
-
- g_signal_handlers_disconnect_by_func (
- browser, copy_tabs_browser_populate_tool_menu_cb, extension);
- g_signal_handlers_disconnect_by_func (
- extension, copy_tabs_deactivate_cb, browser);
- g_signal_handlers_disconnect_by_func (
- app, copy_tabs_app_add_browser_cb, extension);
-}
-
-static void
-copy_tabs_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension)
-{
- g_signal_connect (browser, "populate-tool-menu",
- G_CALLBACK (copy_tabs_browser_populate_tool_menu_cb), extension);
- g_signal_connect (extension, "deactivate",
- G_CALLBACK (copy_tabs_deactivate_cb), browser);
-}
-
-static void
-copy_tabs_activate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- KatzeArray* browsers;
- MidoriBrowser* browser;
-
- browsers = katze_object_get_object (app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- copy_tabs_app_add_browser_cb (app, browser, extension);
- g_object_unref (browsers);
- g_signal_connect (app, "add-browser",
- G_CALLBACK (copy_tabs_app_add_browser_cb), extension);
-}
-
-MidoriExtension*
-extension_init (void)
-{
- MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", _("Copy Addresses of Tabs"),
- "description", _("Copy the addresses of all tabs to the clipboard"),
- "version", "0.1" MIDORI_VERSION_SUFFIX,
- "authors", "MonkeyOfDoom <pixelmonkey@ensellitis.com>",
- NULL);
-
- g_signal_connect (extension, "activate",
- G_CALLBACK (copy_tabs_activate_cb), NULL);
-
- return extension;
-}
-
diff --git a/extensions/delayed-load.vala b/extensions/delayed-load.vala
deleted file mode 100644
index 1ad9102c..00000000
--- a/extensions/delayed-load.vala
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- Copyright (C) 2012-2013 André Stösel <andre@stoesel.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.
-*/
-
-namespace DelayedLoad {
- private class Manager : Midori.Extension {
- private void tab_changed (Midori.View? old_view, Midori.View? new_view) {
- if (new_view != null) {
- unowned Katze.Item item = new_view.get_proxy_item ();
-
- int64 delay = item.get_meta_integer ("delay");
- if (delay == Midori.Delay.PENDING_UNDELAY && new_view.progress < 1.0) {
- new_view.reload (true);
- }
- }
- }
-
- private void browser_added (Midori.Browser browser) {
- browser.switch_tab.connect_after (this.tab_changed);
- }
-
- private void browser_removed (Midori.Browser browser) {
- browser.switch_tab.disconnect (this.tab_changed);
- }
-
- public void activated (Midori.App app) {
- foreach (Midori.Browser browser in app.get_browsers ()) {
- browser_added (browser);
- }
- app.add_browser.connect (browser_added);
- }
-
- public void deactivated () {
- Midori.App app = get_app ();
- foreach (Midori.Browser browser in app.get_browsers ()) {
- browser_removed (browser);
- }
- app.add_browser.disconnect (browser_added);
- }
-
- internal Manager () {
- GLib.Object (name: _("Delayed load"),
- description: _("Delay page load until you actually use the tab."),
- version: "0.2",
- authors: "André Stösel <andre@stoesel.de>");
-
- activate.connect (this.activated);
- deactivate.connect (this.deactivated);
- }
- }
-}
-
-public Midori.Extension extension_init () {
- return new DelayedLoad.Manager ();
-}
-
diff --git a/extensions/devpet.vala b/extensions/devpet.vala
deleted file mode 100644
index 8af341ba..00000000
--- a/extensions/devpet.vala
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- Copyright (C) 2013 André Stösel <andre@stoesel.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.
-*/
-
-Gtk.IconTheme theme;
-
-namespace DevPet {
- enum TreeCells {
- MESSAGE,
- BACKTRACE,
- STOCK,
- COUNT
- }
-
- private class DataWindow : Gtk.Window {
- public string message {get; construct; }
- public string backtrace {get; construct; }
-
- private void create_content () {
- this.title = this.message;
- this.set_default_size (500, 500);
-
- Gtk.VBox vbox = new Gtk.VBox (false, 1);
- this.add (vbox);
-
- Gtk.TextBuffer message_buffer = new Gtk.TextBuffer (null);
- message_buffer.set_text (this.message);
-
- Gtk.TextView message_text_view = new Gtk.TextView.with_buffer (message_buffer);
- message_text_view.editable = false;
-
- Gtk.TextBuffer backtrace_buffer = new Gtk.TextBuffer (null);
- backtrace_buffer.set_text (this.backtrace);
-
- Gtk.TextView backtrace_text_view = new Gtk.TextView.with_buffer (backtrace_buffer);
- backtrace_text_view.editable = false;
-
- Gtk.ScrolledWindow message_scroll = new Gtk.ScrolledWindow (null, null);
- message_scroll.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
- message_scroll.add (message_text_view);
-
- Gtk.ScrolledWindow backtrace_scroll = new Gtk.ScrolledWindow (null, null);
- backtrace_scroll.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
- backtrace_scroll.add (backtrace_text_view);
-
- vbox.pack_start (message_scroll, false, false, 0);
- vbox.pack_end (backtrace_scroll, true, true, 0);
-
- this.show_all ();
- }
-
- internal DataWindow (string message, string backtrace) {
- GLib.Object (type: Gtk.WindowType.TOPLEVEL,
- window_position: Gtk.WindowPosition.CENTER,
- message: message,
- backtrace: backtrace);
-
- this.create_content ();
- }
- }
-
- private class LogWindow : Gtk.Window {
- private Manager manager;
-
- private void clear_list () {
- this.manager.clear_list ();
- this.destroy ();
- }
-
- #if HAVE_EXECINFO_H
- private void row_activated (Gtk.TreePath path, Gtk.TreeViewColumn column) {
- Gtk.TreeIter iter;
- if (this.manager.list_store.get_iter (out iter, path)) {
- string message;
- string backtrace;
- this.manager.list_store.get(iter,
- TreeCells.MESSAGE, out message,
- TreeCells.BACKTRACE, out backtrace, -1);
-
- DataWindow data_window = new DataWindow (message, backtrace);
- data_window.show ();
- }
- }
- #endif
-
- private void create_content () {
- this.title = "Midori - DevPet";
- this.set_default_size (500, 250);
- this.destroy.connect (this.manager.log_window_closed);
-
- Gtk.VBox vbox = new Gtk.VBox (false, 1);
- this.add (vbox);
-
- #if HAVE_EXECINFO_H
- Gtk.Label label = new Gtk.Label (_("Double click for more information"));
- vbox.pack_start (label, false, false, 0);
- #endif
-
- Gtk.ScrolledWindow scroll_windows = new Gtk.ScrolledWindow (null, null);
- scroll_windows.set_policy (Gtk.PolicyType.NEVER , Gtk.PolicyType.AUTOMATIC);
- scroll_windows.set_shadow_type (Gtk.ShadowType.ETCHED_IN);
-
-
- Gtk.Button clear = new Gtk.Button.from_stock ("gtk-clear");
- clear.clicked.connect (this.clear_list);
-
- vbox.pack_start (scroll_windows, true, true, 0);
- vbox.pack_start (clear, false, false, 0);
-
-
- Gtk.TreeView treeview = new Gtk.TreeView.with_model (this.manager.list_store);
- scroll_windows.add (treeview);
-
- treeview.insert_column_with_attributes (
- -1, "Type",
- new Gtk.CellRendererPixbuf (), "stock-id", TreeCells.STOCK);
- treeview.insert_column_with_attributes (
- -1, "Message",
- new Gtk.CellRendererText (), "text", TreeCells.MESSAGE);
-
- #if HAVE_EXECINFO_H
- treeview.row_activated.connect (this.row_activated);
- #endif
-
- this.show_all ();
- }
-
- internal LogWindow (Manager manager) {
- GLib.Object (type: Gtk.WindowType.TOPLEVEL,
- window_position: Gtk.WindowPosition.CENTER);
-
- this.manager = manager;
- this.create_content ();
- }
- }
-
- private class Manager : Midori.Extension {
- public Gtk.ListStore list_store;
- private Gtk.StatusIcon? trayicon = null;
- private LogWindow? log_window;
- private GLib.LogFunc default_log_func;
- private GLib.LogLevelFlags icon_flag = GLib.LogLevelFlags.LEVEL_DEBUG;
-
- public void clear_list() {
- this.icon_flag = GLib.LogLevelFlags.LEVEL_DEBUG;
- if(this.trayicon != null)
- this.trayicon.set_visible (false);
- this.list_store.clear ();
- }
-
- public void log_window_closed () {
- this.log_window = null;
- }
-
- private unowned string get_stock_from_log_level (GLib.LogLevelFlags flags) {
- if ((flags & LogLevelFlags.LEVEL_CRITICAL) == flags || (flags & LogLevelFlags.LEVEL_ERROR) == flags) {
- return Gtk.Stock.DIALOG_ERROR;
- } else if ((flags & LogLevelFlags.LEVEL_WARNING) == flags) {
- return Gtk.Stock.DIALOG_WARNING;
- }
- return Gtk.Stock.DIALOG_INFO;
- }
-
- private void ensure_trayicon() {
- if(this.trayicon != null)
- return;
-
- this.trayicon = new Gtk.StatusIcon ();
- this.trayicon.set_tooltip_text ("Midori - DevPet");
- this.trayicon.activate.connect(this.show_error_log);
- }
-
- private void log_handler(string? domain, GLib.LogLevelFlags flags, string message) {
- Gtk.TreeIter iter;
- unowned string stock = this.get_stock_from_log_level (flags);
-
- this.ensure_trayicon();
-
- if (flags < this.icon_flag) {
- this.icon_flag = flags;
- this.trayicon.set_from_stock (stock);
- }
-
- #if HAVE_EXECINFO_H
- string bt = "";
- void* buffer[100];
- int num = Linux.backtrace (buffer, 100);
- /* Upstream bug: https://git.gnome.org/browse/vala/commit/?id=f402af94e8471c8314ee7a312260a776e4d6fbe2 */
- unowned string[] symbols = Midori.Linux.backtrace_symbols (buffer, num);
- if (symbols != null) {
- /* we don't need the first three lines */
- for (int i = 3; i < num; i++) {
- bt += "\r\n%s".printf(symbols[i]);
- }
- }
- #endif
-
- this.list_store.append (out iter);
- this.list_store.set (iter,
- TreeCells.MESSAGE, message,
- #if HAVE_EXECINFO_H
- TreeCells.BACKTRACE, bt,
- #endif
- TreeCells.STOCK, stock);
-
- this.trayicon.set_visible (true);
- }
-
- private void show_error_log () {
- if (this.log_window == null) {
- this.log_window = new LogWindow (this);
- this.log_window.show ();
- } else {
- if (this.log_window.is_active) {
- this.log_window.hide ();
- } else {
- this.log_window.present ();
- }
- }
- }
-
- private void activated (Midori.App app) {
- this.default_log_func = GLib.Log.default_handler;
- GLib.Log.set_default_handler (this.log_handler);
- if (this.trayicon != null) {
- int length = 0;
- this.list_store.foreach((model, path, iter) => {
- length++;
- return false;
- });
-
- if (length > 0) {
- this.trayicon.set_visible (true);
- }
- }
- }
-
- private void deactivated () {
- if (this.trayicon != null)
- this.trayicon.set_visible (false);
-
- GLib.Log.set_default_handler (this.default_log_func);
- }
-
- internal Manager () {
- GLib.Object (name: _("DevPet"),
- description: _("This extension shows glib error messages in systray."),
- version: "0.1",
- authors: "André Stösel <andre@stoesel.de>");
-
- this.list_store = new Gtk.ListStore (TreeCells.COUNT, typeof(string), typeof(string), typeof (string));
-
- this.activate.connect (this.activated);
- this.deactivate.connect (this.deactivated);
- }
- }
-}
-
-public Midori.Extension extension_init () {
- theme = Gtk.IconTheme.get_default ();
- return new DevPet.Manager ();
-}
-
diff --git a/extensions/domain-keys.vala b/extensions/domain-keys.vala
deleted file mode 100644
index 366ec41d..00000000
--- a/extensions/domain-keys.vala
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Copyright (C) 2014 James Axl <bilimish@yandex.ru>
-
- 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.
-*/
-
-namespace DomainHotkeys {
- class Manager : Midori.Extension {
- internal Manager () {
- GLib.Object (name: _("Domain Hotkeys"),
- description: _("Add www. and .com/.country_domain and proceed with Ctrl+Enter/Shift+Enter"),
- version: "0.1" + Midori.VERSION_SUFFIX,
- authors: "James Axl <bilimish@yandex.ru>");
- activate.connect (this.activated);
- deactivate.connect (this.deactivated);
- }
-
- bool key_press_event (Midori.LocationAction action, Gdk.EventKey event_key) {
- if (event_key.keyval == Gdk.keyval_from_name ("Return")) {
- if ((bool)(event_key.state & Gdk.ModifierType.CONTROL_MASK)) {
- location_action_submit_uri_with_suffix (action, ".com");
- return true;
- } else if((bool)(event_key.state & Gdk.ModifierType.SHIFT_MASK)) {
- var domain = C_("Domain", ".com");
- location_action_submit_uri_with_suffix (action, domain);
- return true;
- }
- }
- return false;
- }
-
- void location_action_submit_uri_with_suffix (Midori.LocationAction action, string suffix) {
- var url = action.get_text ();
- string completed_url = "www." + url + suffix;
- action.submit_uri (completed_url, false);
- }
-
- void browser_added (Midori.Browser browser) {
- var action_group = browser.get_action_group ();
- var action = action_group.get_action ("Location") as Midori.LocationAction;
- action.key_press_event.connect (key_press_event);
- }
-
- void activated (Midori.App app) {
- foreach (var browser in app.get_browsers ())
- browser_added (browser);
- app.add_browser.connect (browser_added);
- }
-
- void browser_removed (Midori.Browser browser) {
- var action_group = browser.get_action_group ();
- var action = action_group.get_action ("Location") as Midori.LocationAction;
- action.key_press_event.disconnect (key_press_event);
- }
-
- void deactivated () {
- var app = get_app ();
- app.add_browser.disconnect (browser_added);
- foreach (var browser in app.get_browsers ())
- browser_removed (browser);
- }
- }
-}
-
-public Midori.Extension extension_init () {
- return new DomainHotkeys.Manager ();
-}
diff --git a/extensions/external-download-manager.vala b/extensions/external-download-manager.vala
deleted file mode 100644
index 3828b7a8..00000000
--- a/extensions/external-download-manager.vala
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- Copyright (C) 2012 André Stösel <andre@stoesel.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.
-*/
-
-namespace EDM {
-#if !HAVE_WIN32
- [DBus (name = "net.launchpad.steadyflow.App")]
- interface SteadyflowInterface : GLib.Object {
- public abstract void AddFile (string url) throws IOError;
- }
-#endif
-
- private class DownloadRequest : GLib.Object {
- public string uri;
- public string auth;
- public string referer;
- public string? cookie_header;
- }
-
- internal Manager manager;
-
- private class Manager : GLib.Object {
- private Soup.CookieJar cookie_jar;
- private GLib.PtrArray download_managers = new GLib.PtrArray ();
-
- public bool download_requested (Midori.View view, WebKit.Download download) {
- Midori.DownloadType download_type = download.get_data<Midori.DownloadType> ("midori-download-type");
-
- if (download_type == Midori.DownloadType.SAVE) {
- var dlReq = new DownloadRequest ();
-
- #if HAVE_WEBKIT2
- dlReq.uri = download.request.get_uri ();
- weak Soup.MessageHeaders headers = download.request.get_http_headers ();
- #else
- dlReq.uri = download.get_uri ();
- var request = download.get_network_request ();
- var message = request.get_message ();
- weak Soup.MessageHeaders headers = message.request_headers;
- #endif
-
- dlReq.auth = headers.get ("Authorization");
- dlReq.referer = headers.get ("Referer");
- dlReq.cookie_header = this.cookie_jar.get_cookies (new Soup.URI (dlReq.uri), true);
-
- for (var i = 0 ; i < download_managers.len; i++) {
- var dm = download_managers.index (i) as ExternalDownloadManager;
- if (dm.download (dlReq))
- return true;
- }
- }
- return false;
- }
-
- public void tab_added (Midori.Browser browser, Midori.View view) {
- view.download_requested.connect (download_requested);
- }
-
- public void tab_removed (Midori.Browser browser, Midori.View view) {
- view.download_requested.disconnect(download_requested);
- }
-
- public void browser_added (Midori.Browser browser) {
- foreach (var tab in browser.get_tabs ())
- tab_added (browser, tab);
- browser.add_tab.connect (tab_added);
- browser.remove_tab.connect (tab_removed);
- }
-
- public void browser_removed (Midori.Browser browser) {
- foreach (var tab in browser.get_tabs ())
- tab_removed (browser, tab);
- browser.add_tab.disconnect (tab_added);
- browser.remove_tab.disconnect (tab_removed);
- }
-
- public void activated (Midori.Extension extension, Midori.App app) {
- this.download_managers.add (extension);
- if (this.download_managers.len == 1) {
- foreach (var browser in app.get_browsers ())
- browser_added (browser);
- app.add_browser.connect (browser_added);
- }
- }
-
- public void deactivated (Midori.Extension extension) {
- this.download_managers.remove (extension);
- if (this.download_managers.len == 0) {
- var app = extension.get_app ();
- foreach (var browser in app.get_browsers ())
- browser_removed (browser);
- app.add_browser.disconnect (browser_added);
- }
- }
-
- construct {
- #if HAVE_WEBKIT2
- var session= new Session ();
- #else
- var session = WebKit.get_default_session ();
- #endif
- this.cookie_jar = session.get_feature (typeof (Soup.CookieJar)) as Soup.CookieJar;
- }
- }
-
- private abstract class ExternalDownloadManager : Midori.Extension {
- public void activated (Midori.App app) {
- manager.activated (this, app);
- }
-
- public void deactivated () {
- manager.deactivated (this);
- }
-
- public void handle_exception (GLib.Error error) {
- string ext_name;
- this.get ("name",out ext_name);
- var dialog = new Gtk.MessageDialog (null, Gtk.DialogFlags.MODAL,
- Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE,
- _("An error occurred when attempting to download a file with the following plugin:\n" +
- "%s\n\n" +
- "Error:\n%s\n\n" +
- "Carry on without this plugin."
- ),
- ext_name, error.message);
- dialog.response.connect ((a) => { dialog.destroy (); });
- dialog.run ();
- }
-
- public abstract bool download (DownloadRequest dlReq);
- }
-
-#if !HAVE_WIN32
- private class Aria2 : ExternalDownloadManager {
- public override bool download (DownloadRequest dlReq) {
- var url = Soup.value_array_new ();
- Soup.value_array_insert (url, 0, typeof (string), dlReq.uri);
-
- GLib.HashTable<string, GLib.Value?> options = Soup.value_hash_new ();
- var referer = new GLib.Value (typeof (string));
- referer.set_string (dlReq.referer);
- options.insert ("referer", referer);
-
- var headers = Soup.value_array_new ();
- if (dlReq.cookie_header != null) {
- Soup.value_array_insert (headers, 0, typeof (string), "Cookie: " + dlReq.cookie_header);
- }
-
- if (headers.n_values > 0)
- options.insert ("header", headers);
-
- var message = Soup.XMLRPC.request_new ("http://127.0.0.1:6800/rpc",
- "aria2.addUri",
- typeof (ValueArray), url,
- typeof(HashTable), options);
- var session = new Soup.SessionSync ();
- session.send_message (message);
-
- /* Check if the plug-in actually recieved an reply.
- * The parse method do not warns us about it. And the exception
- * never is launched.*/
- if (message.status_code != 200) {
- var dialog = new Gtk.MessageDialog (null, Gtk.DialogFlags.MODAL,
- Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE,
- "%s",
- _("The plug-in was unable to connect with aria2:\n" +
- "Please make sure that aria2 is running with rpc enabled ie: aria2c --enable-rpc\n" +
- "If it's so, check it also is using the port 6800.\n" +
- "Lastly Check the configuration of your firewall.\n" +
- "Whitelist aria2 and the port 6800 if they aren't."
- ));
- dialog.response.connect ((a) => { dialog.destroy (); });
- dialog.run ();
- }
-
- try {
- Value v;
- Soup.XMLRPC.parse_method_response ((string) message.response_body.flatten ().data, -1, out v);
- return true;
- } catch (Error e) {
- this.handle_exception (e);
- }
-
- return false;
- }
-
- internal Aria2 () {
- GLib.Object (name: _("External Download Manager - Aria2"),
- description: _("Download files with Aria2"),
- version: "0.1" + Midori.VERSION_SUFFIX,
- authors: "André Stösel <andre@stoesel.de>",
- key: "aria2");
-
- this.activate.connect (activated);
- this.deactivate.connect (deactivated);
- }
- }
-
- private class SteadyFlow : ExternalDownloadManager {
- public override bool download (DownloadRequest dlReq) {
- try {
- SteadyflowInterface dm = Bus.get_proxy_sync (
- BusType.SESSION,
- "net.launchpad.steadyflow.App",
- "/net/launchpad/steadyflow/app");
- dm.AddFile (dlReq.uri);
- return true;
- } catch (Error e) {
- this.handle_exception (e);
- }
- return false;
- }
-
- internal SteadyFlow () {
- GLib.Object (name: _("External Download Manager - SteadyFlow"),
- description: _("Download files with SteadyFlow"),
- version: "0.1" + Midori.VERSION_SUFFIX,
- authors: "André Stösel <andre@stoesel.de>",
- key: "steadyflow");
-
- this.activate.connect (activated);
- this.deactivate.connect (deactivated);
- }
- }
-#endif
-
- private class CommandLinePreferences : Gtk.Dialog {
- protected Gtk.Entry input;
- protected CommandLine commandline;
-
- public CommandLinePreferences(CommandLine cl) {
- this.commandline = cl;
-
- string ext_name;
- this.get ("name",out ext_name);
-
- this.title = _("Preferences for %s").printf (ext_name);
- if (this.get_class ().find_property ("has-separator") != null)
- this.set ("has-separator", false);
- this.border_width = 5;
- this.set_modal (true);
- this.set_default_size (400, 100);
- this.create_widgets ();
-
- this.response.connect (response_cb);
- }
-
- private void response_cb (Gtk.Dialog source, int response_id) {
- switch (response_id) {
- case Gtk.ResponseType.APPLY:
- this.commandline.set_string ("commandline", this.input.get_text ());
- this.commandline.update_description (this.commandline.get_app ());
- this.destroy ();
- break;
- case Gtk.ResponseType.CANCEL:
- this.destroy ();
- break;
- }
- }
-
- private void create_widgets () {
- Gtk.Label text = new Gtk.Label (_("Command:"));
- this.input = new Gtk.Entry ();
- this.input.set_text (this.commandline.get_string ("commandline"));
-
-
-#if HAVE_GTK3
- Gtk.Box vbox = get_content_area () as Gtk.Box;
- vbox.pack_start (text, false, false, 0);
- vbox.pack_start (this.input, false, true, 0);
-#else
- this.vbox.pack_start (text, false, false, 0);
- this.vbox.pack_start (this.input, false, true, 0);
-#endif
-
- this.add_button (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL);
- this.add_button (Gtk.STOCK_APPLY, Gtk.ResponseType.APPLY);
-
- this.show_all ();
- }
- }
-
- private class CommandLine : ExternalDownloadManager {
- private void show_preferences () {
- CommandLinePreferences dialog = new CommandLinePreferences (this);
- dialog.show ();
- }
-
- private string replace_quoted (string context, string replace, string? with) {
- return context.replace(replace, with != null ? GLib.Shell.quote(with) : "\'\'");
- }
-
- public override bool download (DownloadRequest dlReq) {
- try {
- string cmd = this.get_string ("commandline");
- cmd = replace_quoted(cmd, "{REFERER}", dlReq.referer);
- cmd = replace_quoted(cmd, "{COOKIES}", dlReq.cookie_header != null ? "Cookie: " + dlReq.cookie_header : null);
- cmd = cmd.replace("{URL}", GLib.Shell.quote (dlReq.uri));
- GLib.Process.spawn_command_line_async (cmd);
- return true;
- } catch (Error e) {
- this.handle_exception (e);
- }
- return false;
- }
-
- static string description_with_command (string commandline) {
- string command;
- try {
- string[] argvp;
- Shell.parse_argv (commandline, out argvp);
- command = argvp[0];
- }
- catch (Error error) {
- command = commandline.split (" ")[0];
- }
- return _("Download files with \"%s\" or a custom command").printf (command);
- }
-
- internal void update_description (Midori.App app) {
- this.description = description_with_command (get_string ("commandline"));
- }
-
- internal CommandLine () {
-#if HAVE_WIN32
- string default_commandline = "\"%s\\FlashGet\\flashget.exe\" {URL}".printf (Environment.get_variable ("ProgramFiles"));
-#elif HAVE_FREEBSD || HAVE_DRAGONFLY
- string default_commandline = "fetch HTTP_REFERER={REFERER} {URL}";
-#else
- string default_commandline = "wget --no-check-certificate --referer={REFERER} --header={COOKIES} {URL}";
-#endif
-
- GLib.Object (name: _("External Download Manager - CommandLine"),
- description: description_with_command (default_commandline),
- version: "0.1" + Midori.VERSION_SUFFIX,
- authors: "André Stösel <andre@stoesel.de>",
- key: "commandline");
-
- this.install_string ("commandline", default_commandline);
-
- this.activate.connect (activated);
- this.activate.connect (update_description);
- this.deactivate.connect (deactivated);
- this.open_preferences.connect (show_preferences);
- }
- }
-}
-
-public Katze.Array extension_init () {
- EDM.manager = new EDM.Manager();
-
- var extensions = new Katze.Array( typeof (Midori.Extension));
- #if !HAVE_WIN32
- extensions.add_item (new EDM.Aria2 ());
- extensions.add_item (new EDM.SteadyFlow ());
- #endif
- extensions.add_item (new EDM.CommandLine ());
- return extensions;
-}
diff --git a/extensions/feed-panel/feed-atom.c b/extensions/feed-panel/feed-atom.c
deleted file mode 100644
index 7b4f5373..00000000
--- a/extensions/feed-panel/feed-atom.c
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- Copyright (C) 2009-2010 Dale Whittaker <dayul@users.sf.net>
-
- 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.
-*/
-
-#include "feed-atom.h"
-
-static gboolean
-atom_is_valid (FeedParser* fparser)
-{
- xmlNodePtr node;
-
- node = fparser->node;
-
- if (!(xmlStrcmp (node->name, BAD_CAST "feed")) &&
- !(xmlStrcmp (node->ns->href, BAD_CAST "http://www.w3.org/2005/Atom"))
- )
- return TRUE;
-
- return FALSE;
-}
-
-static gboolean
-atom_update (FeedParser* fparser)
-{
- xmlNodePtr node;
- xmlNodePtr child;
- gint64 date;
- gint64 newdate;
-
- date = katze_item_get_added (fparser->item);
-
- node = fparser->node;
- child = node->children;
- while (child)
- {
- if (child->type == XML_ELEMENT_NODE)
- {
- if (!(xmlStrcmp (child->name, BAD_CAST "updated")))
- {
- fparser->node = child;
- newdate = feed_get_element_date (fparser);
- fparser->node = node;
- return (date != newdate);
- }
- }
- child = child->next;
- }
- return TRUE;
-}
-
-static gboolean
-atom_preferred_link (const gchar* old,
- const gchar* new)
-{
- guint i;
- gint iold;
- gint inew;
- gchar* rels[5] =
- {
- "enclosure",
- "via",
- "related",
- "alternate",
- "self",
- };
-
- iold = inew = -1;
- for (i = 0; i < 5; i++)
- {
- if (old && g_str_equal (old, rels[i]))
- iold = i;
- if (new && g_str_equal (new, rels[i]))
- inew = i;
- }
- return (inew > iold);
-}
-
-static void
-atom_get_link (KatzeItem* item,
- xmlNodePtr node)
-{
- gchar* oldtype;
- gchar* newtype;
- gchar* oldrel;
- gchar* newrel;
- gchar* href;
- gboolean oldishtml;
- gboolean newishtml;
- gboolean newlink;
-
- oldtype = (gchar*)katze_item_get_meta_string (item, "feedpanel:linktype");
- oldrel = (gchar*)katze_item_get_meta_string (item, "feedpanel:linkrel");
-
- newtype = (gchar*)xmlGetProp (node, BAD_CAST "type");
- newrel = (gchar*)xmlGetProp (node, BAD_CAST "rel");
- href = (gchar*)xmlGetProp (node, BAD_CAST "href");
-
- if (!newrel)
- newrel = g_strdup ("alternate");
-
- oldishtml = (oldtype && g_str_equal (oldtype, "text/html"));
- newishtml = (newtype && g_str_equal (newtype, "text/html"));
-
- /* prefer HTML links over anything else.
- * if the previous link was already HTML, decide which link
- * we prefer.
- */
- if ((newishtml && oldishtml) || (!newishtml && !oldishtml))
- newlink = atom_preferred_link (oldrel, newrel);
- else
- newlink = newishtml;
-
- if (newlink)
- {
- katze_item_set_uri (item, href);
- katze_item_set_meta_string (item, "feedpanel:linkrel", newrel);
- katze_item_set_meta_string (item, "feedpanel:linktype", newtype);
- }
-
- xmlFree (href);
- xmlFree (newrel);
- xmlFree (newtype);
-}
-
-static void
-atom_preparse_entry (FeedParser* fparser)
-{
- fparser->item = katze_item_new ();
-}
-
-static void
-atom_parse_entry (FeedParser* fparser)
-{
- xmlNodePtr node;
- gchar* content;
- gint64 date;
-
- node = fparser->node;
- content = NULL;
-
- if (!xmlStrcmp (node->name, BAD_CAST "id"))
- {
- content = feed_get_element_string (fparser);
- katze_item_set_token (fparser->item, content);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "title"))
- {
- content = feed_get_element_string (fparser);
- katze_item_set_name (fparser->item, content);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "summary"))
- {
- content = feed_get_element_markup (fparser);
- katze_item_set_text (fparser->item, content);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "updated"))
- {
- date = feed_get_element_date (fparser);
- katze_item_set_added (fparser->item, date);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "icon"))
- {
- content = feed_get_element_string (fparser);
- katze_item_set_icon (fparser->item, content);
- }
- /* FIXME content can be used in some cases where there
- * is no summary, but it needs additional work,
- * as it can be HTML, or base64 encoded.
- * see the spec.
- */
- else if (!xmlStrcmp (node->name, BAD_CAST "content"))
- {
- /* Only retrieve content if there is no summary */
- if (!katze_item_get_text (fparser->item))
- {
- content = feed_get_element_markup (fparser);
- katze_item_set_text (fparser->item, content);
- }
- }
- else if (!(xmlStrcmp (node->name, BAD_CAST "link")))
- atom_get_link (fparser->item, node);
-
- g_free (content);
-}
-
-static void
-atom_postparse_entry (FeedParser* fparser)
-{
- if (!*fparser->error)
- {
- /*
- * Verify that the required Atom elements are added
- * (as per the spec)
- */
- if (!katze_item_get_token (fparser->item) ||
- !katze_item_get_name (fparser->item) ||
- !katze_item_get_uri (fparser->item) ||
- !katze_item_get_added (fparser->item))
- {
- feed_parser_set_error (fparser, FEED_PARSE_ERROR_MISSING_ELEMENT,
- _("Failed to find required Atom \"entry\" elements in XML data."));
- }
- }
-
- if (KATZE_IS_ITEM (fparser->item))
- {
- katze_item_set_meta_string (fparser->item, "feedpanel:linkrel", NULL);
- katze_item_set_meta_string (fparser->item, "feedpanel:linktype", NULL);
-
- if (*fparser->error)
- {
- g_object_unref (fparser->item);
- fparser->item = NULL;
- }
- }
-}
-
-static void
-atom_parse_feed (FeedParser* fparser)
-{
- FeedParser* eparser;
- xmlNodePtr node;
- gchar* content;
- gint64 date;
-
- node = fparser->node;
- content = NULL;
-
- if (!xmlStrcmp (node->name, BAD_CAST "id"))
- {
- content = feed_get_element_string (fparser);
- katze_item_set_token (fparser->item, content);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "title"))
- {
- content = feed_get_element_string (fparser);
- katze_item_set_name (fparser->item, content);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "subtitle"))
- {
- content = feed_get_element_markup (fparser);
- katze_item_set_text (fparser->item, content);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "updated"))
- {
- date = feed_get_element_date (fparser);
- katze_item_set_added (fparser->item, date);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "icon"))
- {
- content = feed_get_element_string (fparser);
- katze_item_set_icon (fparser->item, content);
- }
- else if (!(xmlStrcmp (node->name, BAD_CAST "link")))
- {
- atom_get_link (fparser->item, node);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "entry"))
- {
- eparser = g_new0 (FeedParser, 1);
- eparser->doc = fparser->doc;
- eparser->node = fparser->node;
- eparser->error = fparser->error;
- eparser->preparse = atom_preparse_entry;
- eparser->parse = atom_parse_entry;
- eparser->postparse = atom_postparse_entry;
-
- feed_parse_node (eparser);
-
- if (KATZE_IS_ITEM (eparser->item))
- {
- KatzeItem* item;
- if (!(item = feed_item_exists (KATZE_ARRAY (fparser->item), eparser->item)))
- katze_array_add_item (KATZE_ARRAY (fparser->item), eparser->item);
- else
- {
- g_object_unref (eparser->item);
- katze_array_move_item (KATZE_ARRAY (fparser->item), item, 0);
- }
- }
- g_free (eparser);
-
- }
- g_free (content);
-}
-
-static void
-atom_postparse_feed (FeedParser* fparser)
-{
- if (KATZE_IS_ARRAY (fparser->item))
- {
- katze_item_set_meta_string (fparser->item, "feedpanel:linkrel", NULL);
- katze_item_set_meta_string (fparser->item, "feedpanel:linktype", NULL);
- }
-
- if (!*fparser->error)
- {
- /*
- * Verify that the required Atom elements are added
- * (as per the spec)
- */
- if (!katze_item_get_token (fparser->item) ||
- !katze_item_get_name (fparser->item) ||
- !katze_item_get_added (fparser->item))
- {
- feed_parser_set_error (fparser, FEED_PARSE_ERROR_MISSING_ELEMENT,
- _("Failed to find required Atom \"feed\" elements in XML data."));
- }
- }
-}
-
-FeedParser*
-atom_init_parser (void)
-{
- FeedParser* fparser;
-
- fparser = g_new0 (FeedParser, 1);
- g_return_val_if_fail (fparser, NULL);
-
- fparser->isvalid = atom_is_valid;
- fparser->update = atom_update;
- fparser->parse = atom_parse_feed;
- fparser->postparse = atom_postparse_feed;
-
- return fparser;
-}
-
diff --git a/extensions/feed-panel/feed-atom.h b/extensions/feed-panel/feed-atom.h
deleted file mode 100644
index df73c8b5..00000000
--- a/extensions/feed-panel/feed-atom.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- Copyright (C) 2009 Dale Whittaker <dayul@users.sf.net>
-
- 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 __FEED_ATOM_H__
-#define __FEED_ATOM_H__
-
-#include "feed-parse.h"
-
-G_BEGIN_DECLS
-
-FeedParser*
-atom_init_parser (void);
-
-G_END_DECLS
-
-#endif /* __FEED_ATOM_H__ */
-
diff --git a/extensions/feed-panel/feed-panel.c b/extensions/feed-panel/feed-panel.c
deleted file mode 100644
index b4e565a0..00000000
--- a/extensions/feed-panel/feed-panel.c
+++ /dev/null
@@ -1,851 +0,0 @@
-/*
- Copyright (C) 2009-2010 Dale Whittaker <dayul@users.sf.net>
-
- 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.
-*/
-
-#include "feed-panel.h"
-
-#include <midori/midori.h>
-#include <time.h>
-
-#define STOCK_FEED_PANEL "feed-panel"
-
-struct _FeedPanel
-{
- GtkVBox parent_instance;
-
- GtkWidget* toolbar;
- GtkWidget* treeview;
- GtkWidget* webview;
- GtkWidget* delete;
-};
-
-struct _FeedPanelClass
-{
- GtkVBoxClass parent_class;
-};
-
-static void
-feed_panel_viewable_iface_init (MidoriViewableIface* iface);
-
-static void
-feed_panel_insert_item (FeedPanel* panel,
- GtkTreeStore* treestore,
- GtkTreeIter* parent,
- KatzeItem* item);
-
-static void
-feed_panel_disconnect_feed (FeedPanel* panel,
- KatzeArray* feed);
-
-G_DEFINE_TYPE_WITH_CODE (FeedPanel, feed_panel, GTK_TYPE_VBOX,
- G_IMPLEMENT_INTERFACE (MIDORI_TYPE_VIEWABLE,
- feed_panel_viewable_iface_init));
-
-enum
-{
- ADD_FEED,
- REMOVE_FEED,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-feed_panel_treeview_render_icon_cb (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- FeedPanel* panel)
-{
- GdkPixbuf* pixbuf;
- KatzeItem* item;
- KatzeItem* pitem;
- const gchar* uri;
-
- gtk_tree_model_get (model, iter, 0, &item, -1);
- g_assert (KATZE_IS_ITEM (item));
-
- if (!KATZE_IS_ARRAY (item))
- {
- pitem = katze_item_get_parent (item);
- g_assert (KATZE_IS_ITEM (pitem));
- }
- else
- pitem = item;
-
- if ((uri = katze_item_get_uri (pitem)))
- {
- if (!(pixbuf = midori_paths_get_icon (uri, NULL)))
- pixbuf = gtk_widget_render_icon (panel->treeview, STOCK_NEWS_FEED, GTK_ICON_SIZE_MENU, NULL);
- }
- else
- pixbuf = gtk_widget_render_icon (panel->treeview, GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_MENU, NULL);
-
- g_object_set (renderer, "pixbuf", pixbuf, NULL);
-
- if (pixbuf)
- g_object_unref (pixbuf);
-}
-
-static void
-feed_panel_treeview_render_text_cb (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- KatzeItem* item;
- const gchar* title;
-
- gtk_tree_model_get (model, iter, 0, &item, -1);
- g_assert (KATZE_IS_ITEM (item));
-
- title = katze_item_get_name (item);
- if (!title || !*title || g_str_equal (title, " "))
- title = katze_item_get_text (item);
- if (!title || !*title || g_str_equal (title, " "))
- title = katze_item_get_uri (item);
-
- g_object_set (renderer, "text", title, NULL);
- g_object_unref (item);
-}
-
-static void
-feed_panel_add_item_cb (KatzeArray* parent,
- KatzeItem* child,
- FeedPanel* panel)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
- GtkTreeIter child_iter;
- KatzeItem* item;
- gint i;
-
- g_return_if_fail (FEED_IS_PANEL (panel));
- g_return_if_fail (KATZE_IS_ARRAY (parent));
- g_return_if_fail (KATZE_IS_ITEM (child));
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (panel->treeview));
-
- if (katze_item_get_parent (KATZE_ITEM (parent)))
- {
- if (KATZE_IS_ARRAY (child))
- {
- gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &child_iter,
- NULL, G_MAXINT, 0, child, -1);
- }
- else
- {
-
- i = 0;
- while (gtk_tree_model_iter_nth_child (model, &iter, NULL, i++))
- {
- gtk_tree_model_get (model, &iter, 0, &item, -1);
- if (item == KATZE_ITEM (parent))
- {
- gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &child_iter,
- &iter, 0, 0, child, -1);
-
- g_object_unref (child);
- g_object_unref (item);
- break;
- }
- g_object_unref (item);
- }
- }
- }
- feed_panel_insert_item (panel, GTK_TREE_STORE (model), &child_iter, child);
-}
-
-static void
-feed_panel_remove_iter (GtkTreeModel* model,
- KatzeItem* removed_item)
-{
- guint i;
- GtkTreeIter iter;
-
- i = 0;
- while (gtk_tree_model_iter_nth_child (model, &iter, NULL, i))
- {
- KatzeItem* item;
-
- gtk_tree_model_get (model, &iter, 0, &item, -1);
-
- if (item == removed_item)
- {
- gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
- g_object_unref (item);
- break;
- }
- g_object_unref (item);
- i++;
- }
-}
-
-static void
-feed_panel_remove_item_cb (KatzeArray* item,
- KatzeItem* child,
- FeedPanel* panel)
-{
- GtkTreeModel* model;
- KatzeItem* pitem;
-
- g_return_if_fail (FEED_IS_PANEL (panel));
- g_return_if_fail (KATZE_IS_ARRAY (item));
- g_return_if_fail (KATZE_IS_ITEM (child));
-
- if (KATZE_IS_ARRAY (child))
- feed_panel_disconnect_feed (panel, KATZE_ARRAY (child));
-
- if (!katze_item_get_parent (KATZE_ITEM (item)))
- {
- gint n;
-
- n = katze_array_get_length (KATZE_ARRAY (child));
- g_assert (n == 1);
- pitem = katze_array_get_nth_item (KATZE_ARRAY (child), 0);
- }
- else
- pitem = child;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (panel->treeview));
- feed_panel_remove_iter (model, pitem);
- g_object_unref (pitem);
-}
-
-static void
-feed_panel_move_item_cb (KatzeArray* feed,
- KatzeItem* child,
- gint position,
- FeedPanel* panel)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
- guint i;
-
- g_return_if_fail (FEED_IS_PANEL (panel));
- g_return_if_fail (KATZE_IS_ARRAY (feed));
- g_return_if_fail (KATZE_IS_ITEM (child));
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (panel->treeview));
-
- i = 0;
- while (gtk_tree_model_iter_nth_child (model, &iter, NULL, i))
- {
- KatzeItem* item;
-
- gtk_tree_model_get (model, &iter, 0, &item, -1);
-
- if (item == child)
- {
- gtk_tree_store_move_after (GTK_TREE_STORE (model), &iter, NULL);
- g_object_unref (item);
- break;
- }
- g_object_unref (item);
- i++;
- }
-}
-
-static void
-feed_panel_disconnect_feed (FeedPanel* panel,
- KatzeArray* feed)
-{
- KatzeItem* item;
-
- g_return_if_fail (KATZE_IS_ARRAY (feed));
-
- g_signal_handlers_disconnect_by_func (feed,
- feed_panel_add_item_cb, panel);
- g_signal_handlers_disconnect_by_func (feed,
- feed_panel_remove_item_cb, panel);
- g_signal_handlers_disconnect_by_func (feed,
- feed_panel_move_item_cb, panel);
-
- KATZE_ARRAY_FOREACH_ITEM (item, feed)
- {
- if (KATZE_IS_ARRAY (item))
- feed_panel_disconnect_feed (panel, KATZE_ARRAY (item));
- g_object_unref (item);
- }
-}
-
-static void
-feed_panel_insert_item (FeedPanel* panel,
- GtkTreeStore* treestore,
- GtkTreeIter* parent,
- KatzeItem* item)
-{
- g_return_if_fail (KATZE_IS_ITEM (item));
-
- if (KATZE_IS_ARRAY (item))
- {
- g_signal_connect_after (item, "add-item",
- G_CALLBACK (feed_panel_add_item_cb), panel);
- g_signal_connect_after (item, "move-item",
- G_CALLBACK (feed_panel_move_item_cb), panel);
-
- if (!parent)
- {
- g_signal_connect (item, "remove-item",
- G_CALLBACK (feed_panel_remove_item_cb), panel);
- }
- }
-}
-
-static void
-feed_panel_row_activated_cb (GtkTreeView* treeview,
- GtkTreePath* path,
- GtkTreeViewColumn* column,
- FeedPanel* panel)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
- KatzeItem* item;
- const gchar* uri;
-
- model = gtk_tree_view_get_model (treeview);
-
- if (gtk_tree_model_get_iter (model, &iter, path))
- {
- gtk_tree_model_get (model, &iter, 0, &item, -1);
- uri = katze_item_get_uri (item);
- if (uri && *uri)
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (panel));
- GtkWidget* view = midori_browser_add_item (browser, item);
- MidoriWebSettings* settings = midori_browser_get_settings (browser);
- if (!katze_object_get_boolean (settings, "open-tabs-in-the-background"))
- midori_browser_set_current_tab (browser, view);
- }
- g_object_unref (item);
- }
-}
-
-static void
-feed_panel_cursor_or_row_changed_cb (GtkTreeView* treeview,
- FeedPanel* panel)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
- KatzeItem* item;
- gboolean sensitive = FALSE;
-
- if (katze_tree_view_get_selected_iter (treeview, &model, &iter))
- {
- const gchar* uri;
- const gchar* text;
-
- gtk_tree_model_get (model, &iter, 0, &item, -1);
- uri = katze_item_get_uri (item);
-
- if (KATZE_IS_ARRAY (item))
- {
- text = NULL;
- if (!uri)
- text = g_strdup (katze_item_get_text (KATZE_ITEM (item)));
- else
- {
- KatzeItem* parent = katze_item_get_parent (item);
- gint64 added = katze_item_get_added (item);
- g_assert (KATZE_IS_ARRAY (parent));
- if (added)
- {
- GDateTime* date = g_date_time_new_from_unix_local (added);
- gchar* pretty = g_date_time_format (date, "%c");
- g_date_time_unref (date);
-
- /* i18n: The local date a feed was last updated */
- gchar* last_updated = g_strdup_printf (C_("Feed", "Last updated: %s."), pretty);
- text = g_strdup_printf (
- "<html><head><title>feed</title></head>"
- "<body><h3>%s</h3><p />%s</body></html>",
- katze_item_get_uri (KATZE_ITEM (parent)), last_updated);
- g_free (pretty);
- g_free (last_updated);
- }
- else
- {
- text = g_strdup_printf (
- "<html><head><title>feed</title></head>"
- "<body><h3>%s</h3></body></html>", katze_item_get_uri (KATZE_ITEM (parent)));
- }
- }
- midori_view_set_html (MIDORI_VIEW (panel->webview), text ? text : "", uri, NULL);
- g_free ((gchar*) text);
-
- sensitive = TRUE;
- }
- else
- {
- text = katze_item_get_text (item);
- midori_view_set_html (MIDORI_VIEW (panel->webview), text ? text : "", uri, NULL);
- }
- g_object_unref (item);
- }
- if (GTK_IS_WIDGET (panel->delete))
- gtk_widget_set_sensitive (panel->delete, sensitive);
-}
-
-static void
-feed_panel_popup_item (GtkWidget* menu,
- const gchar* stock_id,
- const gchar* label,
- KatzeItem* item,
- gpointer callback,
- FeedPanel* panel)
-{
- GtkWidget* menuitem;
-
- menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
- if (label)
- gtk_label_set_text_with_mnemonic (GTK_LABEL (gtk_bin_get_child (
- GTK_BIN (menuitem))), label);
- g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
- g_signal_connect (menuitem, "activate", G_CALLBACK (callback), panel);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- gtk_widget_show (menuitem);
-}
-
-static void
-feed_panel_open_activate_cb (GtkWidget* menuitem,
- FeedPanel* panel)
-{
- KatzeItem* item;
- const gchar* uri;
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
- uri = katze_item_get_uri (item);
-
- if (uri && *uri)
- {
- MidoriBrowser* browser;
-
- browser = midori_browser_get_for_widget (GTK_WIDGET (panel));
- midori_browser_set_current_uri (browser, uri);
- }
-}
-
-static void
-feed_panel_open_in_tab_activate_cb (GtkWidget* menuitem,
- FeedPanel* panel)
-{
- KatzeItem* item;
- const gchar* uri;
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
-
- if ((uri = katze_item_get_uri (item)) && *uri)
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (panel));
- GtkWidget* view = midori_browser_add_item (browser, item);
- MidoriWebSettings* settings = midori_browser_get_settings (browser);
- if (!katze_object_get_boolean (settings, "open-tabs-in-the-background"))
- midori_browser_set_current_tab (browser, view);
- }
-}
-
-static void
-feed_panel_open_in_window_activate_cb (GtkWidget* menuitem,
- FeedPanel* panel)
-{
- KatzeItem* item;
- const gchar* uri;
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
- uri = katze_item_get_uri (item);
-
- if (uri && *uri)
- {
- MidoriBrowser* browser;
- MidoriBrowser* new_browser;
-
- browser = midori_browser_get_for_widget (GTK_WIDGET (panel));
- g_signal_emit_by_name (browser, "new-window", NULL, &new_browser);
- midori_browser_add_uri (new_browser, uri);
- }
-}
-
-static void
-feed_panel_delete_activate_cb (GtkWidget* menuitem,
- FeedPanel* panel)
-{
- KatzeItem* item;
-
- g_return_if_fail (FEED_IS_PANEL (panel));
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
- g_signal_emit (panel, signals[REMOVE_FEED], 0, item);
-}
-
-static void
-feed_panel_popup (GtkWidget* widget,
- GdkEventButton* event,
- KatzeItem* item,
- FeedPanel* panel)
-{
- GtkWidget* menu;
-
- menu = gtk_menu_new ();
- if (!KATZE_IS_ARRAY (item))
- {
- feed_panel_popup_item (menu, GTK_STOCK_OPEN, NULL,
- item, feed_panel_open_activate_cb, panel);
- feed_panel_popup_item (menu, STOCK_TAB_NEW, _("Open in New _Tab"),
- item, feed_panel_open_in_tab_activate_cb, panel);
- feed_panel_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"),
- item, feed_panel_open_in_window_activate_cb, panel);
- }
- else
- {
- feed_panel_popup_item (menu, GTK_STOCK_DELETE, NULL,
- item, feed_panel_delete_activate_cb, panel);
- }
-
- katze_widget_popup (widget, GTK_MENU (menu),
- event, KATZE_MENU_POSITION_CURSOR);
-}
-
-static gboolean
-feed_panel_button_release_event_cb (GtkWidget* widget,
- GdkEventButton* event,
- FeedPanel* panel)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- if (event->button != 2 && event->button != 3)
- return FALSE;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
- {
- KatzeItem* item;
-
- gtk_tree_model_get (model, &iter, 0, &item, -1);
-
- if (event->button == 2)
- {
- const gchar* uri = katze_item_get_uri (item);
-
- if (uri && *uri)
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (panel));
- GtkWidget* view = midori_browser_add_item (browser, item);
- MidoriWebSettings* settings = midori_browser_get_settings (browser);
- if (!katze_object_get_boolean (settings, "open-tabs-in-the-background"))
- midori_browser_set_current_tab (browser, view);
- }
- }
- else
- feed_panel_popup (widget, event, item, panel);
-
- g_object_unref (item);
- return TRUE;
- }
- return FALSE;
-}
-
-static void
-feed_panel_popup_menu_cb (GtkWidget* widget,
- FeedPanel* panel)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
- KatzeItem* item;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
- {
- gtk_tree_model_get (model, &iter, 0, &item, -1);
- feed_panel_popup (widget, NULL, item, panel);
- g_object_unref (item);
- }
-}
-
-void
-feed_panel_add_feeds (FeedPanel* panel,
- KatzeItem* feed)
-{
- GtkTreeModel* model;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (panel->treeview));
- g_assert (GTK_IS_TREE_MODEL (model));
-
- feed_panel_insert_item (panel, GTK_TREE_STORE (model), NULL, feed);
-}
-
-static gboolean
-webview_button_press_event_cb (GtkWidget* widget,
- GdkEventButton* event)
-{
- /* Disable the popup menu */
- return MIDORI_EVENT_CONTEXT_MENU (event);
-}
-
-#ifndef HAVE_WEBKIT2
-static gboolean
-webview_navigation_request_cb (WebKitWebView* web_view,
- WebKitWebFrame* frame,
- WebKitNetworkRequest* request,
- WebKitWebNavigationAction* navigation_action,
- WebKitWebPolicyDecision* policy_decision,
- FeedPanel* panel)
-{
- if (webkit_web_navigation_action_get_reason (navigation_action) ==
- WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED)
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (panel));
- const gchar* uri = webkit_network_request_get_uri (request);
- GtkWidget* view = midori_browser_add_uri (browser, uri);
- midori_browser_set_current_tab (browser, view);
- webkit_web_policy_decision_ignore (policy_decision);
-
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-static const gchar*
-feed_panel_get_label (MidoriViewable* viewable)
-{
- return _("Feeds");
-}
-
-static const gchar*
-feed_panel_get_stock_id (MidoriViewable* viewable)
-{
- return STOCK_FEED_PANEL;
-}
-
-static void
-feed_panel_add_clicked_cb (GtkWidget* toolitem,
- FeedPanel* panel)
-{
- g_return_if_fail (FEED_IS_PANEL (panel));
-
- g_signal_emit (panel, signals[ADD_FEED], 0);
-}
-
-static void
-feed_panel_delete_clicked_cb (GtkWidget* toolitem,
- FeedPanel* panel)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- g_return_if_fail (FEED_IS_PANEL (panel));
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (panel->treeview),
- &model, &iter))
- {
- KatzeItem* item;
-
- gtk_tree_model_get (model, &iter, 0, &item, -1);
- g_signal_emit (panel, signals[REMOVE_FEED], 0, item);
- g_object_unref (item);
- }
-}
-
-static GtkWidget*
-feed_panel_get_toolbar (MidoriViewable* viewable)
-{
- FeedPanel* panel = FEED_PANEL (viewable);
-
- if (!panel->toolbar)
- {
- GtkWidget* toolbar;
- GtkToolItem* toolitem;
-
- toolbar = gtk_toolbar_new ();
- panel->toolbar = toolbar;
- toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_ADD);
- gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem), _("Add new feed"));
- gtk_tool_item_set_is_important (toolitem, TRUE);
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (feed_panel_add_clicked_cb), panel);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_show (GTK_WIDGET (toolitem));
- toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DELETE);
- gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem), _("Delete feed"));
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (feed_panel_delete_clicked_cb), panel);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_show (GTK_WIDGET (toolitem));
- panel->delete = GTK_WIDGET (toolitem);;
-
- feed_panel_cursor_or_row_changed_cb (
- GTK_TREE_VIEW (panel->treeview), panel);
- g_signal_connect (panel->delete, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &panel->delete);
- }
-
- return panel->toolbar;
-}
-
-static void
-feed_panel_finalize (GObject* object)
-{
-}
-
-static void
-feed_panel_viewable_iface_init (MidoriViewableIface* iface)
-{
- iface->get_stock_id = feed_panel_get_stock_id;
- iface->get_label = feed_panel_get_label;
- iface->get_toolbar = feed_panel_get_toolbar;
-}
-
-static void
-feed_panel_class_init (FeedPanelClass* class)
-{
- GObjectClass* gobject_class;
-
- signals[ADD_FEED] = g_signal_new (
- "add-feed",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[REMOVE_FEED] = g_signal_new (
- "remove-feed",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = feed_panel_finalize;
-}
-
-static void
-feed_panel_init (FeedPanel* panel)
-{
- GtkTreeStore* model;
- GtkWidget* treewin;
- GtkWidget* treeview;
- GtkWidget* webview;
- GtkWidget* paned;
- GtkTreeViewColumn* column;
- GtkCellRenderer* renderer_pixbuf;
- GtkCellRenderer* renderer_text;
- GtkIconFactory *factory;
- GtkIconSource *icon_source;
- GtkIconSet *icon_set;
- MidoriWebSettings* settings;
- PangoFontDescription* font_desc;
- const gchar* family;
- gint size;
- GtkStockItem items[] =
- {
- { STOCK_FEED_PANEL, N_("_Feeds"), 0, 0, NULL }
- };
-
- factory = gtk_icon_factory_new ();
- gtk_stock_add (items, G_N_ELEMENTS (items));
- icon_set = gtk_icon_set_new ();
- icon_source = gtk_icon_source_new ();
- gtk_icon_source_set_icon_name (icon_source, STOCK_NEWS_FEED);
- gtk_icon_set_add_source (icon_set, icon_source);
- gtk_icon_source_free (icon_source);
- gtk_icon_factory_add (factory, STOCK_FEED_PANEL, icon_set);
- gtk_icon_set_unref (icon_set);
- gtk_icon_factory_add_default (factory);
- g_object_unref (factory);
-
- model = gtk_tree_store_new (1, KATZE_TYPE_ITEM);
- treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
- panel->treeview = treeview;
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
- column = gtk_tree_view_column_new ();
- renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_pixbuf,
- (GtkTreeCellDataFunc)feed_panel_treeview_render_icon_cb,
- panel, NULL);
- renderer_text = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer_text, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_text,
- (GtkTreeCellDataFunc)feed_panel_treeview_render_text_cb,
- treeview, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
- g_object_unref (model);
- g_object_connect (treeview,
- "signal::row-activated",
- feed_panel_row_activated_cb, panel,
- "signal::cursor-changed",
- feed_panel_cursor_or_row_changed_cb, panel,
- "signal::columns-changed",
- feed_panel_cursor_or_row_changed_cb, panel,
- "signal::button-release-event",
- feed_panel_button_release_event_cb, panel,
- "signal::popup-menu",
- feed_panel_popup_menu_cb, panel,
- NULL);
- gtk_widget_show (treeview);
-
-#if GTK_CHECK_VERSION(3,0,0)
- font_desc = (PangoFontDescription*)gtk_style_context_get_font (
- gtk_widget_get_style_context (treeview), GTK_STATE_FLAG_NORMAL);
-#else
- font_desc = treeview->style->font_desc;
-#endif
- family = pango_font_description_get_family (font_desc);
- size = pango_font_description_get_size (font_desc) / PANGO_SCALE;
- settings = midori_web_settings_new ();
- g_object_set (settings, "default-font-family", family,
- "default-font-size", size, NULL);
- webview = midori_view_new_with_item (NULL, settings);
- gtk_widget_set_size_request (webview, -1, 50);
- g_object_connect (midori_tab_get_web_view (MIDORI_TAB (webview)),
- #ifndef HAVE_WEBKIT2
- "signal::navigation-policy-decision-requested",
- webview_navigation_request_cb, panel,
- #endif
- "signal::button-press-event",
- webview_button_press_event_cb, NULL,
- "signal::button-release-event",
- webview_button_press_event_cb, NULL,
- NULL);
- panel->webview = webview;
-
- treewin = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (treewin),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (treewin),
- GTK_SHADOW_IN);
- gtk_container_add (GTK_CONTAINER (treewin), treeview);
- gtk_widget_show (treewin);
-
- paned = gtk_vpaned_new ();
- gtk_paned_pack1 (GTK_PANED (paned), treewin, TRUE, FALSE);
- gtk_paned_pack2 (GTK_PANED (paned), webview, TRUE, TRUE);
- gtk_box_pack_start (GTK_BOX (panel), paned, TRUE, TRUE, 0);
- gtk_widget_show (webview);
- gtk_widget_show (paned);
-}
-
-GtkWidget*
-feed_panel_new (void)
-{
- FeedPanel* panel = g_object_new (FEED_TYPE_PANEL, NULL);
-
- return GTK_WIDGET (panel);
-}
-
diff --git a/extensions/feed-panel/feed-panel.h b/extensions/feed-panel/feed-panel.h
deleted file mode 100644
index 2530feb3..00000000
--- a/extensions/feed-panel/feed-panel.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- Copyright (C) 2009 Dale Whittaker <dayul@users.sf.net>
-
- 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 __FEED_PANEL_H__
-#define __FEED_PANEL_H__
-
-#include <midori/midori.h>
-
-G_BEGIN_DECLS
-
-#define FEED_TYPE_PANEL \
- (feed_panel_get_type ())
-#define FEED_PANEL(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), FEED_TYPE_PANEL, FeedPanel))
-#define FEED_PANEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), FEED_TYPE_PANEL, FeedPanelClass))
-#define FEED_IS_PANEL(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FEED_TYPE_PANEL))
-#define FEED_IS_PANEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), FEED_TYPE_PANEL))
-#define FEED_PANEL_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), FEED_TYPE_PANEL, FeedPanelClass))
-
-typedef struct _FeedPanel FeedPanel;
-typedef struct _FeedPanelClass FeedPanelClass;
-
-void
-feed_panel_add_feeds (FeedPanel* panel,
- KatzeItem* feed);
-
-void
-feed_panel_set_editable (FeedPanel* panel,
- gboolean editable);
-
-GType
-feed_panel_get_type (void);
-
-GtkWidget*
-feed_panel_new (void);
-
-G_END_DECLS
-
-#endif /* __FEED_PANEL_H__ */
diff --git a/extensions/feed-panel/feed-parse.c b/extensions/feed-panel/feed-parse.c
deleted file mode 100644
index c19f5c06..00000000
--- a/extensions/feed-panel/feed-parse.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- Copyright (C) 2009-2010 Dale Whittaker <dayul@users.sf.net>
-
- 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.
-*/
-
-#include "feed-parse.h"
-#include <time.h>
-
-gchar*
-feed_get_element_markup (FeedParser* fparser)
-{
- xmlNodePtr node;
-
- node = fparser->node;
-
- if (node->children &&
- !xmlIsBlankNode (node->children) &&
- node->children->type == XML_ELEMENT_NODE)
- {
- return ((gchar*) xmlNodeGetContent (node->children));
- }
-
- if (!node->children ||
- xmlIsBlankNode (node->children) ||
- (node->children->type != XML_TEXT_NODE &&
- node->children->type != XML_CDATA_SECTION_NODE)
- )
- {
- /* Some servers add required elements with no content,
- * create a dummy string to handle it.
- */
- return g_strdup (" ");
- }
- return (gchar*)xmlNodeListGetString (fparser->doc, node->children, 1);
-}
-
-static void
-handle_markup_chars (void* user_data,
- const xmlChar* ch,
- int len)
-{
- if (len > 0)
- {
- gchar** markup;
- gchar* temp;
-
- markup = (gchar**)user_data;
- temp = g_strndup ((gchar*)ch, len);
- *markup = (*markup) ? g_strconcat (*markup, temp, NULL) : g_strdup (temp);
- g_free (temp);
- }
-}
-
-gchar*
-feed_remove_markup (gchar* markup)
-{
- const xmlChar* stag;
- if (((stag = xmlStrchr (BAD_CAST markup, '<')) && xmlStrchr (stag, '>')) ||
- xmlStrchr (BAD_CAST markup, '&'))
- {
- gchar* text = NULL;
- htmlSAXHandlerPtr psax;
-
- psax = g_new0 (htmlSAXHandler, 1);
- psax->characters = handle_markup_chars;
- htmlSAXParseDoc (BAD_CAST markup, "UTF-8", psax, &text);
- g_free (psax);
- g_free (markup);
- return text;
- }
- return markup;
-}
-
-gchar*
-feed_get_element_string (FeedParser* fparser)
-{
- gchar* markup;
-
- markup = feed_get_element_markup (fparser);
- return feed_remove_markup (markup);
-}
-
-gint64
-feed_get_element_date (FeedParser* fparser)
-{
- time_t date;
- gchar* content;
-
- date = 0;
- content = feed_get_element_string (fparser);
-
- if (content)
- {
- SoupDate* sdate;
-
- sdate = soup_date_new_from_string (content);
- if (sdate)
- {
- date = soup_date_to_time_t (sdate);
- soup_date_free (sdate);
- }
- g_free (content);
- }
- return ((gint64)date);
-}
-
-KatzeItem*
-feed_item_exists (KatzeArray* array,
- KatzeItem* item)
-{
- const gchar* guid;
- gchar* hstr;
- guint hash;
-
- guid = katze_item_get_token (item);
- if (!guid)
- {
- hstr = g_strjoin (NULL,
- katze_item_get_name (item),
- katze_item_get_uri (item),
- katze_item_get_text (item),
- NULL);
- hash = g_str_hash (hstr);
- g_free (hstr);
-
- hstr = g_strdup_printf ("%u", hash);
- katze_item_set_token (item, hstr);
- g_free (hstr);
-
- guid = katze_item_get_token (item);
- }
-
- return (katze_array_find_token (array, guid));
-}
-
-void
-feed_parse_node (FeedParser* fparser)
-{
- xmlNodePtr node;
- xmlNodePtr child;
-
- if (!*fparser->error)
- {
- if (fparser->preparse)
- (*fparser->preparse) (fparser);
-
- if (fparser->parse)
- {
- node = fparser->node;
- child = node->last;
-
- while (child)
- {
- if (child->type == XML_ELEMENT_NODE)
- {
- fparser->node = child;
-
- (*fparser->parse) (fparser);
-
- if (*fparser->error)
- break;
- }
- child = child->prev;
- }
- fparser->node = node;
- }
-
- if (fparser->postparse)
- (*fparser->postparse) (fparser);
- }
-}
-
-static void
-feed_parse_doc (xmlDocPtr doc,
- GSList* parsers,
- KatzeArray* array,
- GError** error)
-{
- FeedParser* fparser;
- xmlNodePtr root;
- gboolean isvalid;
-
- root = xmlDocGetRootElement (doc);
-
- if (!root)
- {
- *error = g_error_new (FEED_PARSE_ERROR,
- FEED_PARSE_ERROR_MISSING_ELEMENT,
- _("Failed to find root element in feed XML data."));
- return;
- }
-
- while (parsers)
- {
- fparser = (FeedParser*)parsers->data;
- fparser->error = error;
- fparser->doc = doc;
- fparser->node = root;
-
- if (fparser && fparser->isvalid)
- {
- isvalid = (*fparser->isvalid) (fparser);
-
- if (*fparser->error)
- return;
-
- if (isvalid)
- {
- fparser->item = KATZE_ITEM (array);
-
- if (fparser->update &&
- (*fparser->update) (fparser))
- feed_parse_node (fparser);
- }
- }
- else
- isvalid = FALSE;
-
- fparser->error = NULL;
- fparser->doc = NULL;
- fparser->node = NULL;
-
- if (isvalid)
- return;
-
- parsers = g_slist_next (parsers);
- }
-
- *error = g_error_new (FEED_PARSE_ERROR,
- FEED_PARSE_ERROR_INVALID_FORMAT,
- _("Unsupported feed format."));
-}
-
-gboolean
-parse_feed (gchar* data,
- gint64 length,
- GSList* parsers,
- KatzeArray* array,
- GError** error)
-{
- xmlDocPtr doc;
- xmlErrorPtr xerror;
-
- LIBXML_TEST_VERSION
-
- doc = xmlReadMemory (
- data, length, "feedfile.xml", NULL,
- XML_PARSE_NOWARNING | XML_PARSE_NOERROR /*| XML_PARSE_RECOVER*/
- );
-
- if (doc)
- {
- feed_parse_doc (doc, parsers, array, error);
- xmlFreeDoc (doc);
- }
- else
- {
- xerror = xmlGetLastError ();
- *error = g_error_new (FEED_PARSE_ERROR,
- FEED_PARSE_ERROR_PARSE,
- _("Failed to parse XML feed: %s"),
- xerror->message);
- xmlResetLastError ();
- }
- xmlMemoryDump ();
-
- return *error ? FALSE : TRUE;
-}
-
diff --git a/extensions/feed-panel/feed-parse.h b/extensions/feed-panel/feed-parse.h
deleted file mode 100644
index 31685feb..00000000
--- a/extensions/feed-panel/feed-parse.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- Copyright (C) 2009 Dale Whittaker <dayul@users.sf.net>
-
- 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 __FEED_PARSE_H__
-#define __FEED_PARSE_H__
-
-#include <midori/midori.h>
-
-#if HAVE_CONFIG_H
- #include <config.h>
-#endif
-
-#include <libsoup/soup.h>
-#include <libxml/parser.h>
-#include <libxml/HTMLparser.h>
-
-G_BEGIN_DECLS
-
-#define FEED_PARSE_ERROR g_quark_from_string("FEED_PARSE_ERROR")
-
-typedef enum
-{
- FEED_PARSE_ERROR_PARSE,
- FEED_PARSE_ERROR_INVALID_FORMAT,
- FEED_PARSE_ERROR_INVALID_VERSION,
- FEED_PARSE_ERROR_MISSING_ELEMENT
-
-} FeedBarError;
-
-typedef struct _FeedParser
-{
- xmlDocPtr doc; /* The XML document */
- xmlNodePtr node; /* The XML node at a specific point */
- KatzeItem* item;
- GError** error;
-
- gboolean (*isvalid) (struct _FeedParser* fparser);
- gboolean (*update) (struct _FeedParser* fparser);
- void (*preparse) (struct _FeedParser* fparser);
- void (*parse) (struct _FeedParser* fparser);
- void (*postparse) (struct _FeedParser* fparser);
-
-} FeedParser;
-
-#define feed_parser_set_error(fparser, err, msg) \
- *(fparser)->error = g_error_new ( \
- FEED_PARSE_ERROR, (err), (msg))
-
-gchar*
-feed_get_element_string (FeedParser* fparser);
-
-gchar*
-feed_remove_markup (gchar* markup);
-
-gchar*
-feed_get_element_markup (FeedParser* fparser);
-
-gint64
-feed_get_element_date (FeedParser* fparser);
-
-KatzeItem*
-feed_item_exists (KatzeArray* array,
- KatzeItem* item);
-void
-feed_parse_node (FeedParser* fparser);
-
-gboolean
-parse_feed (gchar* data,
- gint64 length,
- GSList* parsers,
- KatzeArray* array,
- GError** error);
-
-G_END_DECLS
-
-#endif /* __FEED_PARSE_H__ */
-
diff --git a/extensions/feed-panel/feed-rss.c b/extensions/feed-panel/feed-rss.c
deleted file mode 100644
index d27649fb..00000000
--- a/extensions/feed-panel/feed-rss.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- Copyright (C) 2009-2010 Dale Whittaker <dayul@users.sf.net>
-
- 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.
-*/
-
-#include "feed-rss.h"
-
-static gboolean
-rss_is_valid (FeedParser* fparser)
-{
- xmlNodePtr node;
- xmlNodePtr child;
- xmlChar* str;
- gboolean valid;
-
- node = fparser->node;
-
- if (!(xmlStrcmp (node->name, BAD_CAST "rss")))
- {
- if ((str = xmlGetProp (node, BAD_CAST "version")))
- {
- if (!xmlStrcmp (str, BAD_CAST "2.0") || !xmlStrcmp (str, BAD_CAST "0.92"))
- valid = TRUE;
- else
- valid = FALSE;
-
- xmlFree (str);
-
- if (valid)
- {
- child = node->children;
- while (child)
- {
- if (child->type == XML_ELEMENT_NODE &&
- !(xmlStrcmp (child->name, BAD_CAST "channel")))
- {
- fparser->node = child;
- return TRUE;
- }
- child = child->next;
- }
-
- feed_parser_set_error (fparser, FEED_PARSE_ERROR_MISSING_ELEMENT,
- _("Failed to find \"channel\" element in RSS XML data."));
- }
- else
- {
- feed_parser_set_error (fparser, FEED_PARSE_ERROR_INVALID_VERSION,
- _("Unsupported RSS version found."));
- }
- }
- }
- return FALSE;
-}
-
-static gboolean
-rss_update (FeedParser* fparser)
-{
- xmlNodePtr node;
- xmlNodePtr child;
- gint64 date;
- gint64 newdate;
-
- date = katze_item_get_added (fparser->item);
-
- node = fparser->node;
- child = node->children;
- while (child)
- {
- if (child->type == XML_ELEMENT_NODE)
- {
- if (!(xmlStrcmp (child->name, BAD_CAST "lastBuildDate")))
- {
- fparser->node = child;
- newdate = feed_get_element_date (fparser);
- fparser->node = node;
- return (date != newdate || date == 0);
- }
- }
- child = child->next;
- }
- return TRUE;
-}
-
-static void
-rss_preparse_item (FeedParser* fparser)
-{
- fparser->item = katze_item_new ();
-}
-
-static void
-rss_parse_item (FeedParser* fparser)
-{
- xmlNodePtr node;
- gchar* content;
- gint64 date;
-
- node = fparser->node;
- content = NULL;
-
- if (!xmlStrcmp (node->name, BAD_CAST "guid"))
- {
- content = feed_get_element_string (fparser);
- katze_item_set_token (fparser->item, content);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "title"))
- {
- content = feed_get_element_string (fparser);
- katze_item_set_name (fparser->item, content);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "description"))
- {
- content = feed_get_element_markup (fparser);
- katze_item_set_text (fparser->item, content);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "pubDate"))
- {
- date = feed_get_element_date (fparser);
- katze_item_set_added (fparser->item, date);
- }
- else if (!(xmlStrcmp (node->name, BAD_CAST "link")))
- {
- content = feed_get_element_string (fparser);
- katze_item_set_uri (fparser->item, content);
- }
- g_free (content);
-}
-
-static void
-rss_postparse_item (FeedParser* fparser)
-{
- if (!*fparser->error)
- {
- /*
- * Verify that the required RSS elements are added
- * (as per the spec)
- */
- if (!katze_item_get_name (fparser->item))
- {
- gchar* desc;
-
- desc = (gchar*)katze_item_get_text (fparser->item);
- if (!desc)
- {
- feed_parser_set_error (fparser, FEED_PARSE_ERROR_MISSING_ELEMENT,
- _("Failed to find required RSS \"item\" elements in XML data."));
- }
- else
- {
- desc = feed_remove_markup (g_strdup (desc));
- if (desc)
- {
- katze_item_set_name (fparser->item, desc);
- g_free (desc);
- }
- else
- {
- if ((desc = (gchar*)katze_item_get_uri (fparser->item)))
- katze_item_set_name (fparser->item, desc);
- }
- }
- }
- }
-
- if (*fparser->error && KATZE_IS_ITEM (fparser->item))
- {
- g_object_unref (fparser->item);
- fparser->item = NULL;
- }
-}
-
-static void
-rss_parse_channel (FeedParser* fparser)
-{
- FeedParser* eparser;
- xmlNodePtr node;
- gchar* content;
- gint64 date;
-
- node = fparser->node;
- content = NULL;
-
- if (!xmlStrcmp (node->name, BAD_CAST "title"))
- {
- content = feed_get_element_string (fparser);
- katze_item_set_name (fparser->item, content);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "description"))
- {
- content = feed_get_element_markup (fparser);
- katze_item_set_text (fparser->item, content);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "lastBuildDate"))
- {
- date = feed_get_element_date (fparser);
- katze_item_set_added (fparser->item, date);
- }
- else if (!(xmlStrcmp (node->name, BAD_CAST "link")))
- {
- content = feed_get_element_string (fparser);
- katze_item_set_uri (fparser->item, content);
- }
- else if (!xmlStrcmp (node->name, BAD_CAST "item"))
- {
- eparser = g_new0 (FeedParser, 1);
- eparser->doc = fparser->doc;
- eparser->node = fparser->node;
- eparser->error = fparser->error;
- eparser->preparse = rss_preparse_item;
- eparser->parse = rss_parse_item;
- eparser->postparse = rss_postparse_item;
-
- feed_parse_node (eparser);
-
- if (KATZE_IS_ITEM (eparser->item))
- {
- KatzeItem* item;
- if (!(item = feed_item_exists (KATZE_ARRAY (fparser->item), eparser->item)))
- katze_array_add_item (KATZE_ARRAY (fparser->item), eparser->item);
- else
- {
- g_object_unref (eparser->item);
- katze_array_move_item (KATZE_ARRAY (fparser->item), item, 0);
- }
- }
- g_free (eparser);
-
- }
- g_free (content);
-}
-
-static void
-rss_postparse_channel (FeedParser* fparser)
-{
- if (!*fparser->error)
- {
- /*
- * Verify that the required RSS elements are added
- * (as per the spec)
- */
- if (!katze_item_get_name (fparser->item) ||
- !katze_item_get_text (fparser->item) ||
- !katze_item_get_uri (fparser->item))
- {
- feed_parser_set_error (fparser, FEED_PARSE_ERROR_MISSING_ELEMENT,
- _("Failed to find required RSS \"channel\" elements in XML data."));
- }
- }
-}
-
-FeedParser*
-rss_init_parser (void)
-{
- FeedParser* fparser;
-
- fparser = g_new0 (FeedParser, 1);
- g_return_val_if_fail (fparser, NULL);
-
- fparser->isvalid = rss_is_valid;
- fparser->update = rss_update;
- fparser->parse = rss_parse_channel;
- fparser->postparse = rss_postparse_channel;
-
- return fparser;
-}
-
diff --git a/extensions/feed-panel/katze-net.c b/extensions/feed-panel/katze-net.c
deleted file mode 100644
index 5cca255f..00000000
--- a/extensions/feed-panel/katze-net.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- Copyright (C) 2008-2009 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.
-*/
-
-#if HAVE_CONFIG_H
- #include <config.h>
-#endif
-
-#if HAVE_UNISTD_H
- #include <unistd.h>
-#endif
-
-#include "katze-net.h"
-#include "midori-core.h"
-
-#include <glib/gstdio.h>
-#include <libsoup/soup.h>
-
-struct _KatzeNet
-{
- GObject parent_instance;
-};
-
-struct _KatzeNetClass
-{
- GObjectClass parent_class;
-};
-
-G_DEFINE_TYPE (KatzeNet, katze_net, G_TYPE_OBJECT)
-
-static void
-katze_net_finalize (GObject* object);
-
-static void
-katze_net_class_init (KatzeNetClass* class)
-{
- GObjectClass* gobject_class;
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = katze_net_finalize;
-}
-
-static void
-katze_net_init (KatzeNet* net)
-{
-}
-
-static void
-katze_net_finalize (GObject* object)
-{
- G_OBJECT_CLASS (katze_net_parent_class)->finalize (object);
-}
-
-typedef struct
-{
- KatzeNetStatusCb status_cb;
- KatzeNetTransferCb transfer_cb;
- gpointer user_data;
- KatzeNetRequest* request;
-} KatzeNetPriv;
-
-#ifndef HAVE_WEBKIT2
-static void
-katze_net_priv_free (KatzeNetPriv* priv)
-{
- KatzeNetRequest* request = priv->request;
- g_free (request->uri);
- g_free (request->mime_type);
- g_free (request->data);
- g_slice_free (KatzeNetRequest, request);
- g_slice_free (KatzeNetPriv, priv);
-}
-
-static void
-katze_net_got_body_cb (SoupMessage* msg,
- KatzeNetPriv* priv);
-
-static void
-katze_net_got_headers_cb (SoupMessage* msg,
- KatzeNetPriv* priv)
-{
- KatzeNetRequest* request = priv->request;
-
- switch (msg->status_code)
- {
- case 200:
- request->status = KATZE_NET_VERIFIED;
- break;
- case 301:
- request->status = KATZE_NET_MOVED;
- break;
- default:
- request->status = KATZE_NET_NOT_FOUND;
- }
-
- if (!priv->status_cb (request, priv->user_data))
- {
- g_signal_handlers_disconnect_by_func (msg, katze_net_got_headers_cb, priv);
- g_signal_handlers_disconnect_by_func (msg, katze_net_got_body_cb, priv);
- soup_session_cancel_message (webkit_get_default_session (), msg, 1);
- }
-}
-
-static void
-katze_net_got_body_cb (SoupMessage* msg,
- KatzeNetPriv* priv)
-{
- KatzeNetRequest* request = priv->request;
-
- if (msg->response_body->length > 0)
- {
- request->data = g_memdup (msg->response_body->data,
- msg->response_body->length);
- request->length = msg->response_body->length;
- }
-
- priv->transfer_cb (request, priv->user_data);
-}
-
-static void
-katze_net_finished_cb (SoupMessage* msg,
- KatzeNetPriv* priv)
-{
- katze_net_priv_free (priv);
-}
-
-static gboolean
-katze_net_default_cb (KatzeNetPriv* priv)
-{
- KatzeNetRequest* request;
-
- request = priv->request;
- request->status = KATZE_NET_NOT_FOUND;
- if (priv->status_cb)
- priv->status_cb (request, priv->user_data);
- katze_net_priv_free (priv);
- return FALSE;
-}
-#endif
-
-/**
- * katze_net_load_uri:
- * @net: a #KatzeNet, or %NULL
- * @uri: an URI string
- * @status_cb: function to call for status information
- * @transfer_cb: function to call upon transfer
- * @user_data: data to pass to the callback
- *
- * Requests a transfer of @uri.
- *
- * @status_cb will be called when the status of @uri
- * is verified. The specified callback may be called
- * multiple times unless cancelled.
- *
- * @transfer_cb will be called when the data @uri is
- * pointing to was transferred. Note that even a failed
- * transfer may transfer data.
- *
- * @status_cb will always to be called at least once.
- **/
-void
-katze_net_load_uri (KatzeNet* net,
- const gchar* uri,
- KatzeNetStatusCb status_cb,
- KatzeNetTransferCb transfer_cb,
- gpointer user_data)
-{
-#ifndef HAVE_WEBKIT2
- KatzeNetRequest* request;
- KatzeNetPriv* priv;
- SoupMessage* msg;
-
- g_return_if_fail (uri != NULL);
-
- if (!status_cb && !transfer_cb)
- return;
-
- request = g_slice_new (KatzeNetRequest);
- request->uri = g_strdup (uri);
- request->mime_type = NULL;
- request->data = NULL;
-
- priv = g_slice_new (KatzeNetPriv);
- priv->status_cb = status_cb;
- priv->transfer_cb = transfer_cb;
- priv->user_data = user_data;
- priv->request = request;
-
- if (midori_uri_is_http (uri))
- {
- msg = soup_message_new ("GET", uri);
- if (status_cb)
- g_signal_connect (msg, "got-headers",
- G_CALLBACK (katze_net_got_headers_cb), priv);
- if (transfer_cb)
- g_signal_connect (msg, "got-body",
- G_CALLBACK (katze_net_got_body_cb), priv);
- g_signal_connect (msg, "finished",
- G_CALLBACK (katze_net_finished_cb), priv);
- soup_session_queue_message (webkit_get_default_session (), msg, NULL, NULL);
- return;
- }
-
- g_idle_add ((GSourceFunc)katze_net_default_cb, priv);
-#endif
-}
-
diff --git a/extensions/feed-panel/katze-net.h b/extensions/feed-panel/katze-net.h
deleted file mode 100644
index 0fc8893f..00000000
--- a/extensions/feed-panel/katze-net.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- 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"
-
-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) G_GNUC_CONST;
-
-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;
- gint64 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);
-
-G_END_DECLS
-
-#endif /* __KATZE_NET_H__ */
diff --git a/extensions/feed-panel/main.c b/extensions/feed-panel/main.c
deleted file mode 100644
index a605238c..00000000
--- a/extensions/feed-panel/main.c
+++ /dev/null
@@ -1,512 +0,0 @@
-/*
- Copyright (C) 2009 Dale Whittaker <dale@users.sf.net>
-
- 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.
-*/
-
-#include "feed-panel.h"
-#include "feed-atom.h"
-#include "feed-rss.h"
-
-#include "katze-net.h"
-#include <midori/midori.h>
-
-#define EXTENSION_NAME "Feed Panel"
-
-#define feed_get_flags(feed) \
- GPOINTER_TO_INT (g_object_get_data (G_OBJECT ((feed)), "flags"))
-
-#define feed_set_flags(feed, flags) \
- g_object_set_data (G_OBJECT ((feed)), "flags", \
- GINT_TO_POINTER ((flags)))
-
-#define feed_has_flags(feed, flags) \
- ((flags) & feed_get_flags ((feed)))
-
-#define feed_add_flags(feed, flags) \
- feed_set_flags ((feed), (feed_get_flags ((feed)) | (flags)))
-
-#define feed_remove_flags(feed, flags) \
- feed_set_flags ((feed), (feed_get_flags ((feed)) & ~(flags)))
-
-typedef struct
-{
- MidoriBrowser* browser;
- MidoriExtension* extension;
- GtkWidget* panel;
- KatzeArray* feeds;
- GSList* parsers;
-
- guint source_id;
- gboolean is_running;
-
-} FeedPrivate;
-
-typedef struct
-{
- MidoriExtension* extension;
- GSList* parsers;
- KatzeArray* feed;
-
-} FeedNetPrivate;
-
-enum
-{
- FEED_READ = 1,
- FEED_REMOVE
-};
-
-static void
-feed_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension);
-
-static gboolean
-secondary_icon_released_cb (GtkAction* action,
- GtkWidget* widget,
- FeedPrivate* priv);
-
-static void
-feed_deactivate_cb (MidoriExtension* extension,
- FeedPrivate* priv)
-{
- if (priv)
- {
- MidoriApp* app = midori_extension_get_app (extension);
- GtkActionGroup* action_group;
- GtkAction* action;
-
- action_group = midori_browser_get_action_group (priv->browser);
- action = gtk_action_group_get_action (action_group, "Location");
- g_signal_handlers_disconnect_by_func (action,
- secondary_icon_released_cb, priv);
-
- g_signal_handlers_disconnect_by_func (app,
- feed_app_add_browser_cb, extension);
- g_signal_handlers_disconnect_by_func (extension,
- feed_deactivate_cb, priv);
-
- if (priv->source_id)
- g_source_remove (priv->source_id);
- g_slist_foreach (priv->parsers, (GFunc)g_free, NULL);
- g_slist_free (priv->parsers);
- if (priv->feeds)
- g_object_unref (priv->feeds);
- gtk_widget_destroy (priv->panel);
- g_free (priv);
- }
-}
-
-static KatzeArray*
-feed_add_item (KatzeArray* feeds,
- const gchar* uri)
-{
- if (katze_array_find_token (feeds, uri))
- {
- GtkWidget* dialog;
-
- dialog = gtk_message_dialog_new (
- NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- _("Error"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("Feed '%s' already exists"), uri);
- gtk_window_set_title (GTK_WINDOW (dialog), EXTENSION_NAME);
- gtk_widget_show (dialog);
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), dialog);
- return NULL;
- }
- else
- {
- KatzeArray* child;
-
- KatzeArray* feed = katze_array_new (KATZE_TYPE_ARRAY);
- child = katze_array_new (KATZE_TYPE_ITEM);
- katze_item_set_uri (KATZE_ITEM (feed), uri);
- katze_item_set_token (KATZE_ITEM (feed), uri);
- katze_item_set_uri (KATZE_ITEM (child), uri);
- katze_array_add_item (feeds, feed);
- katze_array_add_item (feed, child);
- return feed;
- }
-}
-
-static void
-feed_save_items (MidoriExtension* extension,
- KatzeArray* feed)
-{
- KatzeItem* item;
- gchar** sfeeds;
- gint i, n;
-
- g_return_if_fail (KATZE_IS_ARRAY (feed));
-
- n = katze_array_get_length (feed);
- sfeeds = g_new (gchar*, n + 1);
-
- i = 0;
- KATZE_ARRAY_FOREACH_ITEM (item, feed)
- {
- sfeeds[i] = (gchar*) katze_item_get_uri (KATZE_ITEM (item));
- i++;
- }
- sfeeds[n] = NULL;
-
- midori_extension_set_string_list (extension, "feeds", sfeeds, n);
- g_free (sfeeds);
-}
-
-static void
-feed_handle_net_error (FeedNetPrivate* netpriv,
- const gchar* msg)
-{
- KatzeItem* child;
- const gchar* uri;
- gint n;
-
- n = katze_array_get_length (netpriv->feed);
- g_assert (n == 1);
- child = katze_array_get_nth_item (netpriv->feed, 0);
- g_assert (KATZE_IS_ARRAY (child));
-
- uri = katze_item_get_uri (KATZE_ITEM (netpriv->feed));
- katze_item_set_name (child, uri);
- katze_item_set_text (child, msg);
- katze_item_set_uri (child, NULL);
- feed_remove_flags (netpriv->feed, FEED_READ);
-}
-
-static gboolean
-feed_status_cb (KatzeNetRequest* request,
- FeedNetPrivate* netpriv)
-{
- if (request->status == KATZE_NET_FAILED ||
- request->status == KATZE_NET_NOT_FOUND)
- {
- gchar* msg;
-
- msg = g_strdup_printf (_("Error loading feed '%s'"),
- katze_item_get_uri (KATZE_ITEM (netpriv->feed)));
- feed_handle_net_error (netpriv, msg);
- g_free (msg);
-
- return FALSE;
- }
- return TRUE;
-}
-
-static void
-feed_transfer_cb (KatzeNetRequest* request,
- FeedNetPrivate* netpriv)
-{
- GError* error;
-
- if (request->status == KATZE_NET_MOVED)
- return;
-
- g_return_if_fail (KATZE_IS_ARRAY (netpriv->feed));
-
- error = NULL;
-
- if (request->data)
- {
- KatzeArray* item;
- const gchar* uri;
- gint n;
-
- n = katze_array_get_length (netpriv->feed);
- g_assert (n == 1);
- item = katze_array_get_nth_item (netpriv->feed, 0);
- g_assert (KATZE_IS_ARRAY (item));
- uri = katze_item_get_uri (KATZE_ITEM (netpriv->feed));
- katze_item_set_uri (KATZE_ITEM (item), uri);
-
- if (!parse_feed (request->data, request->length,
- netpriv->parsers, item, &error))
- {
- feed_handle_net_error (netpriv, error->message);
- g_error_free (error);
- }
-
- if (feed_has_flags (netpriv->feed, FEED_REMOVE))
- {
- KatzeArray* parent;
-
- /* deferred remove */
- parent = katze_item_get_parent (KATZE_ITEM (netpriv->feed));
- katze_array_remove_item (parent, netpriv->feed);
- feed_save_items (netpriv->extension, parent);
- }
- else
- {
- feed_remove_flags (netpriv->feed, FEED_REMOVE);
- feed_remove_flags (netpriv->feed, FEED_READ);
- }
- }
-
- netpriv->parsers = NULL;
- netpriv->feed = NULL;
- g_free (netpriv);
-}
-
-static void
-update_feed (FeedPrivate* priv,
- KatzeItem* feed)
-{
- if (!(feed_has_flags (feed, FEED_READ)))
- {
- FeedNetPrivate* netpriv;
-
- feed_add_flags (feed, FEED_READ);
- netpriv = g_new0 (FeedNetPrivate, 1);
- netpriv->parsers = priv->parsers;
- netpriv->extension = priv->extension;
- netpriv->feed = KATZE_ARRAY (feed);
-
- katze_net_load_uri (NULL,
- katze_item_get_uri (feed),
- (KatzeNetStatusCb) feed_status_cb,
- (KatzeNetTransferCb) feed_transfer_cb,
- netpriv);
- }
-}
-
-static gboolean
-update_feeds (FeedPrivate* priv)
-{
- KatzeItem* feed;
- gint i;
- gint n;
-
- if (!priv->is_running)
- {
- priv->is_running = TRUE;
- n = katze_array_get_length (priv->feeds);
-
- for (i = 0; i < n; i++)
- {
- feed = katze_array_get_nth_item (priv->feeds, i);
- update_feed (priv, feed);
- }
- }
- priv->is_running = FALSE;
- return TRUE;
-}
-
-static gboolean
-secondary_icon_released_cb (GtkAction* action,
- GtkWidget* widget,
- FeedPrivate* priv)
-{
- GtkWidget* view;
-
- g_assert (KATZE_IS_ARRAY (priv->feeds));
-
- if (gtk_window_get_focus (GTK_WINDOW (priv->browser)) == widget)
- return FALSE;
-
- if ((view = midori_browser_get_current_tab (priv->browser)))
- {
- const gchar* uri;
-
- uri = g_object_get_data (G_OBJECT (view), "news-feeds");
- if (uri && *uri)
- {
- KatzeArray* feed;
-
- if ((feed = feed_add_item (priv->feeds, uri)))
- {
- MidoriPanel* panel = katze_object_get_object (priv->browser, "panel");
- gint i = midori_panel_page_num (panel, priv->panel);
- midori_panel_set_current_page (panel, i);
- gtk_widget_show (GTK_WIDGET (panel));
- g_object_unref (panel);
- feed_save_items (priv->extension, priv->feeds);
- update_feed (priv, KATZE_ITEM (feed));
- return TRUE;
- }
- }
- }
-
- return FALSE;
-}
-
-static void
-panel_add_feed_cb (FeedPanel* panel,
- FeedPrivate* priv)
-{
- GtkWidget* dialog;
- GtkSizeGroup* sizegroup;
- GtkWidget* hbox;
- GtkWidget* label;
- GtkWidget* entry;
-
- dialog = gtk_dialog_new_with_buttons (
- _("New feed"), GTK_WINDOW (priv->browser),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_ADD);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_container_set_border_width (GTK_CONTAINER(gtk_dialog_get_content_area( GTK_DIALOG (dialog))), 5);
- sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
- hbox = gtk_hbox_new (FALSE, 8);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
- label = gtk_label_new_with_mnemonic (_("_Address:"));
- gtk_size_group_add_widget (sizegroup, label);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- entry = gtk_entry_new ();
- gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
- gtk_entry_set_text (GTK_ENTRY (entry), "");
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, FALSE, TRUE, 0);
- gtk_widget_show_all (hbox);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
- {
- const gchar* uri;
-
- g_assert (KATZE_IS_ARRAY (priv->feeds));
-
- uri = gtk_entry_get_text (GTK_ENTRY (entry));
- if (uri && *uri)
- {
- KatzeArray* feed;
-
- feed = feed_add_item (priv->feeds, uri);
- if (feed)
- {
- feed_save_items (priv->extension, priv->feeds);
- update_feed (priv, KATZE_ITEM (feed));
- }
- }
- }
- gtk_widget_destroy (dialog);
-}
-
-static void
-panel_remove_feed_cb (FeedPanel* panel,
- KatzeItem* item,
- FeedPrivate* priv)
-{
- KatzeArray* feed;
-
- feed = katze_item_get_parent (item);
-
- g_assert (KATZE_IS_ARRAY (priv->feeds));
- g_assert (KATZE_IS_ARRAY (feed));
-
- if (feed_has_flags (feed, FEED_READ))
- feed_add_flags (feed, FEED_REMOVE);
- else
- {
- feed_add_flags (feed, FEED_READ);
- katze_array_remove_item (priv->feeds, feed);
- feed_save_items (priv->extension, priv->feeds);
- }
-}
-
-static void
-feed_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension)
-{
- GtkWidget* panel;
- GtkWidget* addon;
- GtkActionGroup* action_group;
- GtkAction* action;
- KatzeArray* feeds;
- KatzeArray* feed;
- FeedPrivate* priv;
- gchar** sfeeds;
- gsize i;
- gsize n;
-
- priv = g_new0 (FeedPrivate, 1);
-
- panel = katze_object_get_object (browser, "panel");
- addon = feed_panel_new ();
- gtk_widget_show (addon);
- midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));
- g_object_unref (panel);
-
- feeds = katze_array_new (KATZE_TYPE_ARRAY);
- feed_panel_add_feeds (FEED_PANEL (addon), KATZE_ITEM (feeds));
-
- priv->extension = extension;
- priv->browser = browser;
- priv->panel = addon;
- priv->feeds = feeds;
- priv->parsers = g_slist_prepend (priv->parsers, atom_init_parser ());
- priv->parsers = g_slist_prepend (priv->parsers, rss_init_parser ());
-
- sfeeds = midori_extension_get_string_list (extension, "feeds", &n);
- if (sfeeds != NULL)
- for (i = 0; i < n; i++)
- {
- if (sfeeds[i])
- {
- feed = feed_add_item (feeds, sfeeds[i]);
- if (feed)
- update_feed (priv, KATZE_ITEM (feed));
- }
- }
- action_group = midori_browser_get_action_group (browser);
- action = gtk_action_group_get_action (action_group, "Location");
-
- g_signal_connect (addon, "add-feed",
- G_CALLBACK (panel_add_feed_cb), priv);
- g_signal_connect (addon, "remove-feed",
- G_CALLBACK (panel_remove_feed_cb), priv);
- g_signal_connect (action, "secondary-icon-released",
- G_CALLBACK (secondary_icon_released_cb), priv);
- g_signal_connect (extension, "deactivate",
- G_CALLBACK (feed_deactivate_cb), priv);
-
- priv->source_id = midori_timeout_add_seconds (
- 600, (GSourceFunc) update_feeds, priv, NULL);
-}
-
-static void
-feed_activate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- KatzeArray* browsers;
- MidoriBrowser* browser;
-
- browsers = katze_object_get_object (app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- feed_app_add_browser_cb (app, browser, extension);
- g_object_unref (browsers);
-
- g_signal_connect (app, "add-browser",
- G_CALLBACK (feed_app_add_browser_cb), extension);
-}
-
-MidoriExtension*
-extension_init (void)
-{
- MidoriExtension* extension;
-
- extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", _("Feed Panel"),
- "description", _("Read Atom/ RSS feeds"),
- "version", "0.1" MIDORI_VERSION_SUFFIX,
- "authors", "Dale Whittaker <dayul@users.sf.net>",
- NULL);
-
- midori_extension_install_string_list (extension, "feeds", NULL, 0);
-
- g_signal_connect (extension, "activate",
- G_CALLBACK (feed_activate_cb), NULL);
-
- return extension;
-}
diff --git a/extensions/flummi.vala b/extensions/flummi.vala
deleted file mode 100644
index 7e8decb2..00000000
--- a/extensions/flummi.vala
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- Copyright (C) 2013 André Stösel <andre@stoesel.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.
-*/
-
-namespace Flummi {
- private class Manager : Midori.Extension {
- private bool bounce () {
- try {
- Midori.App app = this.get_app ();
- Midori.Browser? browser = app.browser;
-
- if (browser == null || browser.tab == null) {
- return true;
- }
-
-
- Midori.Database database = new Midori.Database ("flummi.db");
- unowned Sqlite.Database db = database.db;
-
- string sqlcmd = "SELECT id, once, command FROM tasks ORDER BY id;";
-
- Sqlite.Statement stmt;
- if (db.prepare_v2 (sqlcmd, -1, out stmt, null) != Sqlite.OK) {
- GLib.critical ("Failed to select from database: %s", db.errmsg ());
- return false;
- }
-
- int result = stmt.step ();
- if (!(result == Sqlite.DONE || result == Sqlite.ROW)) {
- GLib.critical ("Failed to select from database: %s", db.errmsg ());
- return false;
- }
-
- Sqlite.Statement del_stmt;
- sqlcmd = "DELETE FROM `tasks` WHERE id = :task_id;";
- if (db.prepare_v2 (sqlcmd, -1, out del_stmt, null) != Sqlite.OK) {
- GLib.critical ("Failed to update database: %s", db.errmsg ());
- return false;
- }
-
- while (result == Sqlite.ROW) {
- int64 id = stmt.column_int64 (0);
- int64 once = stmt.column_int64 (1);
- string command = stmt.column_text (2);
-
- string[] commands = { command };
-
- if (!app.send_command (commands)) {
- GLib.critical ("Command failed: %s", command);
- return false;
- }
-
- if (once > 0) {
- del_stmt.bind_int64 (del_stmt.bind_parameter_index (":task_id"), id);
- if (del_stmt.step () != Sqlite.DONE) {
- GLib.critical ("Failed to delete record %lf.\nError: %s", id, db.errmsg ());
- return false;
- }
- }
-
- result = stmt.step ();
- }
- } catch (Midori.DatabaseError schema_error) {
- GLib.error (schema_error.message);
- }
-
- return false;
- }
-
- private void activated (Midori.App app) {
- GLib.Idle.add (this.bounce);
- }
-
- internal Manager () {
- GLib.Object (name: _("Flummi"),
- description: _("This extension provides a task queue for update jobs or recurring events."),
- version: "0.1",
- authors: "André Stösel <andre@stoesel.de>");
-
- this.activate.connect (this.activated);
- }
- }
-}
-
-public Midori.Extension extension_init () {
- return new Flummi.Manager ();
-}
diff --git a/extensions/formhistory/formhistory-frontend.h b/extensions/formhistory/formhistory-frontend.h
deleted file mode 100644
index 3fb0b02e..00000000
--- a/extensions/formhistory/formhistory-frontend.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- Copyright (C) 2009-2012 Alexander Butenko <a.butenka@gmail.com>
- Copyright (C) 2009-2012 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.
-*/
-
-#ifndef __FORMHISTORY_FRONTEND_H__
-#define __FORMHISTORY_FRONTEND_H__
-#include <midori/midori.h>
-#include <glib/gstdio.h>
-
-#include "config.h"
-#if HAVE_UNISTD_H
- #include <unistd.h>
-#endif
-
-#define MAXPASSSIZE 64
-
-typedef struct
-{
- MidoriDatabase* database;
- sqlite3* db;
- WebKitDOMElement* element;
- int completion_timeout;
- GtkTreeModel* completion_model;
- GtkWidget* treeview;
- GtkWidget* popup;
- gchar* oldkeyword;
- glong selection_index;
- gchar* master_password;
- int master_password_canceled;
-} FormHistoryPriv;
-
-typedef struct
-{
- gchar* domain;
- gchar* form_data;
- FormHistoryPriv* priv;
-} FormhistoryPasswordEntry;
-
-FormHistoryPriv*
-formhistory_private_new ();
-
-void
-formhistory_private_destroy (FormHistoryPriv *priv);
-
-gboolean
-formhistory_construct_popup_gui (FormHistoryPriv* priv);
-
-void
-formhistory_setup_suggestions (WebKitWebView* web_view,
- JSContextRef js_context,
- MidoriExtension* extension);
-
-void
-formhistory_suggestions_hide_cb (WebKitDOMElement* element,
- WebKitDOMEvent* dom_event,
- FormHistoryPriv* priv);
-
-#endif
diff --git a/extensions/formhistory/formhistory-gdom-frontend.c b/extensions/formhistory/formhistory-gdom-frontend.c
deleted file mode 100644
index 8f739210..00000000
--- a/extensions/formhistory/formhistory-gdom-frontend.c
+++ /dev/null
@@ -1,507 +0,0 @@
-/*
- Copyright (C) 2009-2012 Alexander Butenko <a.butenka@gmail.com>
- Copyright (C) 2009-2012 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.
-*/
-#include "formhistory-frontend.h"
-#define COMPLETION_DELAY 200
-
-FormHistoryPriv*
-formhistory_private_new ()
-{
- FormHistoryPriv* priv = g_slice_new (FormHistoryPriv);
- priv->oldkeyword = g_strdup ("");
- priv->selection_index = -1;
- return priv;
-}
-
-void
-formhistory_suggestions_hide_cb (WebKitDOMElement* element,
- WebKitDOMEvent* dom_event,
- FormHistoryPriv* priv)
-{
- if (gtk_widget_get_visible (priv->popup))
- gtk_widget_hide (priv->popup);
- priv->selection_index = -1;
-}
-
-static void
-formhistory_suggestion_set (GtkTreePath* path,
- FormHistoryPriv* priv)
-{
- GtkTreeIter iter;
- gchar* value;
-
- if (!gtk_tree_model_get_iter (priv->completion_model, &iter, path))
- return;
-
- gtk_tree_model_get (priv->completion_model, &iter, 0, &value, -1);
- g_object_set (priv->element, "value", value, NULL);
- g_free (value);
-}
-
-static gboolean
-formhistory_suggestion_selected_cb (GtkWidget* treeview,
- GdkEventButton* event,
- FormHistoryPriv* priv)
-
-{
- GtkTreePath* path;
-
- if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview),
- event->x, event->y, &path, NULL, NULL, NULL))
- {
- formhistory_suggestion_set (path, priv);
- formhistory_suggestions_hide_cb (NULL, NULL, priv);
- gtk_tree_path_free (path);
- return TRUE;
- }
- return FALSE;
-}
-static void
-formhistory_suggestion_remove (GtkTreePath* path,
- FormHistoryPriv* priv)
-{
- GtkTreeIter iter;
- gchar* sqlcmd;
- char* errmsg = NULL;
- gchar* name;
- gchar* value;
-
- if (!gtk_tree_model_get_iter (priv->completion_model, &iter, path))
- return;
-
- if (!priv->db)
- return;
-
- gtk_tree_model_get (priv->completion_model, &iter, 0, &value, -1);
- g_object_get (priv->element, "name", &name, NULL);
- gtk_list_store_remove (GTK_LIST_STORE (priv->completion_model), &iter);
-
- sqlcmd = sqlite3_mprintf ("DELETE FROM forms WHERE field = '%q' AND value = '%q'",
- name, value);
- g_free (name);
- g_free (value);
- sqlite3_exec (priv->db, sqlcmd, NULL, NULL, &errmsg);
- sqlite3_free (sqlcmd);
-}
-
-static void
-get_absolute_offset_for_element (WebKitDOMElement* element,
- WebKitDOMDocument* element_document,
- WebKitDOMNodeList* frames,
- glong* x,
- glong* y,
- gboolean ismainframe)
-{
- WebKitDOMElement* offset_parent;
- gint offset_top = 0, offset_left = 0;
- gulong i;
-
- g_object_get (element, "offset-left", &offset_left,
- "offset-top", &offset_top,
- "offset-parent", &offset_parent,
- NULL);
- *x += offset_left;
- *y += offset_top;
- /* To avoid deadlock check only first element of the mainframe parent */
- if (ismainframe == TRUE)
- return;
- if (offset_parent)
- goto finish;
-
- /* Element havent returned any parents. Thats mean or there is no parents or we are inside the frame
- Loop over all frames we have to find frame == element_document which is a root for our element
- and get its offsets */
- for (i = 0; i < webkit_dom_node_list_get_length (frames); i++)
- {
- WebKitDOMDocument *fdoc;
- WebKitDOMNode *frame = webkit_dom_node_list_item (frames, i);
-
- if (WEBKIT_DOM_IS_HTML_IFRAME_ELEMENT (frame))
- fdoc = webkit_dom_html_iframe_element_get_content_document (WEBKIT_DOM_HTML_IFRAME_ELEMENT (frame));
- else
- fdoc = webkit_dom_html_frame_element_get_content_document (WEBKIT_DOM_HTML_FRAME_ELEMENT (frame));
- if (fdoc == element_document)
- {
- offset_parent = WEBKIT_DOM_ELEMENT (frame);
- ismainframe = TRUE;
- /* Add extra 4px to ~cover size of borders */
- *y += 4;
- break;
- }
- }
-finish:
- if (offset_parent)
- get_absolute_offset_for_element (offset_parent, element_document, frames, x, y, ismainframe);
-}
-
-static void
-formhistory_reposition_popup (FormHistoryPriv* priv)
-{
- WebKitDOMDocument* element_document;
- WebKitDOMNodeList* frames;
- GtkWidget* view;
- GdkWindow* window;
- GtkWidget* toplevel;
- gint rx, ry;
- gint wx, wy;
- glong x = 0, y = 0;
- glong height;
-
- view = g_object_get_data (G_OBJECT (priv->element), "webview");
- toplevel = gtk_widget_get_toplevel (view);
- /* Position of a root window */
- window = gtk_widget_get_window (toplevel);
- gdk_window_get_position (window, &rx, &ry);
-
- /* Postion of webview in root window */
- window = gtk_widget_get_window (view);
- gdk_window_get_position (window, &wx, &wy);
-
- /* Position of editbox on the webview */
- frames = g_object_get_data (G_OBJECT (priv->element), "framelist");
- element_document = g_object_get_data (G_OBJECT (priv->element), "doc");
- get_absolute_offset_for_element (priv->element, element_document, frames, &x, &y, FALSE);
- /* Add height as menu should start under editbox, now on top of it */
- g_object_get (priv->element, "client-height", &height, NULL);
- y += height + 1;
- gtk_window_move (GTK_WINDOW (priv->popup), rx + wx + x, ry +wy + y);
-
- /* Window configuration */
- gtk_window_set_screen (GTK_WINDOW (priv->popup), gtk_widget_get_screen (view));
- gtk_window_set_transient_for (GTK_WINDOW (priv->popup), GTK_WINDOW (toplevel));
- gtk_tree_view_columns_autosize (GTK_TREE_VIEW (priv->treeview));
- /* FIXME: Adjust size according to treeview width and some reasonable height */
- gtk_window_resize (GTK_WINDOW (priv->popup), 50, 80);
-}
-
-static gboolean
-formhistory_suggestions_show (FormHistoryPriv* priv)
-{
- GtkListStore* store;
- static sqlite3_stmt* stmt;
- gchar* value, * name;
- const char* sqlcmd;
- gint result;
- gchar* likedvalue;
- int pos = 0;
-
- g_return_val_if_fail (priv->element, FALSE);
-
- g_object_get (priv->element,
- "name", &name,
- "value", &value,
- NULL);
-
- katze_assign (priv->oldkeyword, g_strdup (value));
- if (!priv->popup)
- formhistory_construct_popup_gui (priv);
-
- if (!stmt)
- {
- if (!priv->db)
- goto free_data;
-
- sqlcmd = "SELECT DISTINCT value FROM forms WHERE field = ?1 and value like ?2";
- sqlite3_prepare_v2 (priv->db, sqlcmd, strlen (sqlcmd) + 1, &stmt, NULL);
- }
-
- likedvalue = g_strdup_printf ("%s%%", value);
- sqlite3_bind_text (stmt, 1, name, -1, NULL);
- sqlite3_bind_text (stmt, 2, likedvalue, -1, g_free);
- result = sqlite3_step (stmt);
-
- if (result != SQLITE_ROW)
- {
- if (result == SQLITE_ERROR)
- g_print (_("Failed to select suggestions\n"));
- sqlite3_reset (stmt);
- sqlite3_clear_bindings (stmt);
- formhistory_suggestions_hide_cb (NULL, NULL, priv);
- goto free_data;
- }
-
- store = GTK_LIST_STORE (priv->completion_model);
- gtk_list_store_clear (store);
-
- while (result == SQLITE_ROW)
- {
- const unsigned char* text = sqlite3_column_text (stmt, 0);
- pos++;
- gtk_list_store_insert_with_values (store, NULL, pos, 0, text, -1);
- result = sqlite3_step (stmt);
- }
- sqlite3_reset (stmt);
- sqlite3_clear_bindings (stmt);
-
- if (!gtk_widget_get_visible (priv->popup))
- {
- formhistory_reposition_popup (priv);
- gtk_widget_show_all (priv->popup);
- }
-
-free_data:
- g_free (name);
- g_free (value);
- return FALSE;
-}
-
-static void
-formhistory_editbox_key_pressed_cb (WebKitDOMElement* element,
- WebKitDOMEvent* dom_event,
- FormHistoryPriv* priv)
-{
- glong key;
- GtkTreePath* path;
- gchar* keyword;
- gint matches;
-
- /* FIXME: Priv is still set after module is disabled */
- g_return_if_fail (priv);
- g_return_if_fail (element);
-
- if (priv->completion_timeout > 0)
- g_source_remove (priv->completion_timeout);
-
- katze_object_assign (priv->element, g_object_ref (element));
-
- key = webkit_dom_ui_event_get_key_code (WEBKIT_DOM_UI_EVENT (dom_event));
- switch (key)
- {
- /* ESC key*/
- case 27:
- case 35:
- case 36:
- /* Left key*/
- case 37:
- /* Right key*/
- case 39:
- /* Enter key*/
- case 13:
- if (key == 27)
- g_object_set (element, "value", priv->oldkeyword, NULL);
- formhistory_suggestions_hide_cb (element, dom_event, priv);
- return;
- break;
- /* Del key */
- case 46:
- /* Up key */
- case 38:
- /* Down key */
- case 40:
-
- if (!gtk_widget_get_visible (priv->popup))
- {
- formhistory_suggestions_show (priv);
- return;
- }
- matches = gtk_tree_model_iter_n_children (priv->completion_model, NULL);
- if (key == 38)
- {
- if (priv->selection_index <= 0)
- priv->selection_index = matches - 1;
- else
- priv->selection_index = MAX (priv->selection_index - 1, 0);
- }
- else if (key == 40)
- {
- if (priv->selection_index == matches - 1)
- priv->selection_index = 0;
- else
- priv->selection_index = MIN (priv->selection_index + 1, matches -1);
- }
- if (priv->selection_index == -1)
- {
- /* No element is selected */
- return;
- }
-
- path = gtk_tree_path_new_from_indices (priv->selection_index, -1);
- if (key == 46)
- {
- g_object_set (element, "value", priv->oldkeyword, NULL);
- formhistory_suggestion_remove (path, priv);
- matches--;
- }
-
- if (matches == 0)
- formhistory_suggestions_hide_cb (element, dom_event, priv);
- else
- {
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->treeview), path, NULL, FALSE);
- formhistory_suggestion_set (path, priv);
- }
- gtk_tree_path_free (path);
- return;
- break;
- /* PgUp, PgDn, Ins */
- case 33:
- case 34:
- case 45:
- /* Shift, Ctrl, Alt, Tab, Caps Lock*/
- case 16:
- case 17:
- case 18:
- case 20:
- case 9:
- return;
- break;
- }
-
- g_object_get (element, "value", &keyword, NULL);
- if (!(keyword && *keyword && *keyword != ' '))
- {
- formhistory_suggestions_hide_cb (element, dom_event, priv);
- goto free_data;
- }
-
- /* If the same keyword is submitted there's no need to regenerate suggestions */
- if (gtk_widget_get_visible (priv->popup) &&
- !g_strcmp0 (keyword, priv->oldkeyword))
- goto free_data;
- priv->completion_timeout = midori_timeout_add (COMPLETION_DELAY,
- (GSourceFunc)formhistory_suggestions_show, priv, NULL);
-free_data:
- g_free (keyword);
-}
-
-static void
-formhistory_DOMContentLoaded_cb (WebKitDOMElement* window,
- WebKitDOMEvent* dom_event,
- FormHistoryPriv* priv)
-{
- gulong i;
- WebKitDOMDocument* doc;
- WebKitDOMNodeList* inputs;
- WebKitDOMNodeList* frames;
- GtkWidget* web_view;
-
- if (WEBKIT_DOM_IS_DOCUMENT (window))
- doc = WEBKIT_DOM_DOCUMENT (window);
- else
- doc = webkit_dom_dom_window_get_document (WEBKIT_DOM_DOM_WINDOW (window));
- inputs = webkit_dom_document_query_selector_all (doc, "input[type='text']", NULL);
- frames = g_object_get_data (G_OBJECT (window), "framelist");
- web_view = g_object_get_data (G_OBJECT (window), "webview");
-
- for (i = 0; i < webkit_dom_node_list_get_length (inputs); i++)
- {
- WebKitDOMNode* element = webkit_dom_node_list_item (inputs, i);
- gchar* autocomplete = webkit_dom_html_input_element_get_autocomplete (
- WEBKIT_DOM_HTML_INPUT_ELEMENT (element));
- gboolean off = !g_strcmp0 (autocomplete, "off");
- g_free (autocomplete);
- if (off)
- continue;
-
- g_object_set_data (G_OBJECT (element), "doc", doc);
- g_object_set_data (G_OBJECT (element), "webview", web_view);
- g_object_set_data (G_OBJECT (element), "framelist", frames);
- /* Add dblclick? */
- webkit_dom_event_target_add_event_listener (
- WEBKIT_DOM_EVENT_TARGET (element), "keyup",
- G_CALLBACK (formhistory_editbox_key_pressed_cb), false,
- priv);
- webkit_dom_event_target_add_event_listener (
- WEBKIT_DOM_EVENT_TARGET (element), "blur",
- G_CALLBACK (formhistory_suggestions_hide_cb), false,
- priv);
- }
-}
-
-void
-formhistory_setup_suggestions (WebKitWebView* web_view,
- JSContextRef js_context,
- MidoriExtension* extension)
-{
- WebKitDOMDocument* doc;
- WebKitDOMNodeList* frames;
- gulong i;
-
- FormHistoryPriv* priv = g_object_get_data (G_OBJECT (extension), "priv");
- doc = webkit_web_view_get_dom_document (web_view);
- frames = webkit_dom_document_query_selector_all (doc, "iframe, frame", NULL);
- g_object_set_data (G_OBJECT (doc), "framelist", frames);
- g_object_set_data (G_OBJECT (doc), "webview", web_view);
- /* Connect to DOMContentLoaded of the main frame */
- webkit_dom_event_target_add_event_listener(
- WEBKIT_DOM_EVENT_TARGET (doc), "DOMContentLoaded",
- G_CALLBACK (formhistory_DOMContentLoaded_cb), false,
- priv);
-
- /* Connect to DOMContentLoaded of frames */
- for (i = 0; i < webkit_dom_node_list_get_length (frames); i++)
- {
- WebKitDOMDOMWindow* framewin;
-
- WebKitDOMNode* frame = webkit_dom_node_list_item (frames, i);
- if (WEBKIT_DOM_IS_HTML_IFRAME_ELEMENT (frame))
- framewin = webkit_dom_html_iframe_element_get_content_window (WEBKIT_DOM_HTML_IFRAME_ELEMENT (frame));
- else
- framewin = webkit_dom_html_frame_element_get_content_window (WEBKIT_DOM_HTML_FRAME_ELEMENT (frame));
- g_object_set_data (G_OBJECT (framewin), "framelist", frames);
- g_object_set_data (G_OBJECT (framewin), "webview", (GtkWidget*)web_view);
- webkit_dom_event_target_add_event_listener (
- WEBKIT_DOM_EVENT_TARGET (framewin), "DOMContentLoaded",
- G_CALLBACK (formhistory_DOMContentLoaded_cb), false,
- priv);
- }
- formhistory_suggestions_hide_cb (NULL, NULL, priv);
-}
-
-void
-formhistory_private_destroy (FormHistoryPriv *priv)
-{
- katze_object_assign (priv->database, NULL);
- katze_assign (priv->oldkeyword, NULL);
- gtk_widget_destroy (priv->popup);
- priv->popup = NULL;
- katze_object_assign (priv->element, NULL);
- g_slice_free (FormHistoryPriv, priv);
-}
-
-gboolean
-formhistory_construct_popup_gui (FormHistoryPriv* priv)
-{
- GtkTreeModel* model = NULL;
- GtkWidget* popup;
- GtkWidget* popup_frame;
- GtkWidget* scrolled;
- GtkWidget* treeview;
- GtkCellRenderer* renderer;
- GtkTreeViewColumn* column;
-
- model = (GtkTreeModel*) gtk_list_store_new (1, G_TYPE_STRING);
- priv->completion_model = model;
- popup = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_window_set_type_hint (GTK_WINDOW (popup), GDK_WINDOW_TYPE_HINT_COMBO);
- popup_frame = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (popup_frame), GTK_SHADOW_ETCHED_IN);
- gtk_container_add (GTK_CONTAINER (popup), popup_frame);
- scrolled = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
- "hscrollbar-policy", GTK_POLICY_NEVER,
- "vscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL);
- gtk_container_add (GTK_CONTAINER (popup_frame), scrolled);
- treeview = gtk_tree_view_new_with_model (model);
- priv->treeview = treeview;
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
- gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (treeview), TRUE);
- gtk_container_add (GTK_CONTAINER (scrolled), treeview);
- gtk_widget_set_size_request (gtk_scrolled_window_get_vscrollbar (
- GTK_SCROLLED_WINDOW (scrolled)), -1, 0);
-
- renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes ("suggestions", renderer, "text", 0, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
- priv->popup = popup;
- priv->element = NULL;
-
- g_signal_connect (treeview, "button-press-event",
- G_CALLBACK (formhistory_suggestion_selected_cb), priv);
- return TRUE;
-}
diff --git a/extensions/formhistory/formhistory.c b/extensions/formhistory/formhistory.c
deleted file mode 100644
index 060ac1c7..00000000
--- a/extensions/formhistory/formhistory.c
+++ /dev/null
@@ -1,668 +0,0 @@
-/*
- Copyright (C) 2009-2012 Alexander Butenko <a.butenka@gmail.com>
- Copyright (C) 2009-2012 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.
-*/
-#define MAXCHARS 60
-#define MINCHARS 2
-#define GTK_RESPONSE_IGNORE 99
-#include "formhistory-frontend.h"
-
-static void
-formhistory_toggle_state_cb (GtkAction* action,
- MidoriBrowser* browser);
-
-static void
-formhistory_update_database (gpointer db,
- const gchar* host,
- const gchar* key,
- const gchar* value)
-{
- gchar* sqlcmd;
- gchar* errmsg;
- gint success;
-
- if (!(value && *value))
- return;
-
- sqlcmd = sqlite3_mprintf ("INSERT INTO forms VALUES('%q', '%q', '%q')",
- host, key, value);
- success = sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg);
- sqlite3_free (sqlcmd);
- if (success != SQLITE_OK)
- {
- g_printerr (_("Failed to add form value: %s\n"), errmsg);
- g_free (errmsg);
- return;
- }
-}
-
-static gchar*
-formhistory_get_login_data (gpointer db,
- const gchar* uri)
-{
- gchar* domain;
- static sqlite3_stmt* stmt;
- gint result;
- gchar* value = NULL;
-
- g_return_val_if_fail (db != NULL, NULL);
- g_return_val_if_fail (uri != NULL, NULL);
- domain = midori_uri_parse_hostname (uri, NULL);
- g_return_val_if_fail (domain != NULL, NULL);
-
- if (!stmt)
- {
- const gchar* sqlcmd = "SELECT value FROM forms WHERE domain = ?1 and field = 'MidoriPasswordManager' limit 1";
- sqlite3_prepare_v2 (db, sqlcmd, strlen (sqlcmd) + 1, &stmt, NULL);
- }
- sqlite3_bind_text (stmt, 1, domain, -1, NULL);
- result = sqlite3_step (stmt);
- if (result == SQLITE_ROW)
- value = g_strdup ((gchar*)sqlite3_column_text (stmt, 0));
- sqlite3_reset (stmt);
- sqlite3_clear_bindings (stmt);
- g_free (domain);
- return value;
-}
-
-static gboolean
-formhistory_check_master_password (GtkWidget* parent,
- FormHistoryPriv* priv)
-{
- GtkWidget* dialog;
- GtkWidget* content_area;
- GtkWidget* hbox;
- GtkWidget* image;
- GtkWidget* label;
- GtkWidget* entry;
- const gchar* title;
- static int alive;
- gboolean ret = FALSE;
-
- /* Password is set */
- if (priv->master_password && *priv->master_password)
- return TRUE;
-
- /* Other prompt is active */
- if (alive == 1)
- return FALSE;
-
- /* Prompt was cancelled */
- if (priv->master_password_canceled == 1)
- return FALSE;
-
- alive = 1;
- title = _("Form history");
- dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_DIALOG_AUTHENTICATION);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_container_set_border_width (GTK_CONTAINER (content_area), 5);
-
- hbox = gtk_hbox_new (FALSE, 8);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
- image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION,
- GTK_ICON_SIZE_DIALOG);
- gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
-
- label = gtk_label_new (_("Master password required\n"
- "to open password database"));
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, TRUE, 0);
-
- entry = gtk_entry_new ();
- g_object_set (entry, "truncate-multiline", TRUE, NULL);
- gtk_entry_set_visibility(GTK_ENTRY (entry),FALSE);
- gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
- gtk_box_pack_start (GTK_BOX (content_area), entry, FALSE, TRUE, 0);
-
- gtk_widget_show_all (entry);
- gtk_widget_show_all (hbox);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
- {
- /* FIXME: add password verification */
- katze_assign (priv->master_password,
- g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))));
- ret = TRUE;
- }
- else
- priv->master_password_canceled = 1;
-
- gtk_widget_destroy (dialog);
- alive = 0;
-
- return ret;
-}
-
-static gchar*
-formhistory_encrypt (const gchar* data,
- const gchar* password)
-{
- /* TODO: Implement persistent storage/ keyring support */
- return NULL;
-}
-
-static void
-formhistory_remember_password_response (GtkWidget* infobar,
- gint response_id,
- FormhistoryPasswordEntry* entry)
-{
- gchar* encrypted_form;
-
- if (response_id == GTK_RESPONSE_IGNORE)
- goto cleanup;
-
- if (formhistory_check_master_password (NULL, entry->priv))
- {
- if (response_id != GTK_RESPONSE_ACCEPT)
- katze_assign (entry->form_data, g_strdup ("never"));
-
- if ((encrypted_form = formhistory_encrypt (entry->form_data,
- entry->priv->master_password)))
- formhistory_update_database (entry->priv->db, entry->domain, "MidoriPasswordManager", encrypted_form);
- g_free (encrypted_form);
- }
-
-cleanup:
- g_free (entry->form_data);
- g_free (entry->domain);
- g_slice_free (FormhistoryPasswordEntry, entry);
- gtk_widget_destroy (infobar);
-}
-
-static gboolean
-formhistory_navigation_decision_cb (WebKitWebView* web_view,
- WebKitWebFrame* web_frame,
- WebKitNetworkRequest* request,
- WebKitWebNavigationAction* action,
- WebKitWebPolicyDecision* decision,
- MidoriExtension* extension)
-{
- FormHistoryPriv* priv;
- JSContextRef js_context;
- gchar* value;
-
- /* The script returns form data in the form "field_name|,|value|,|field_type".
- We are handling only input fields with 'text' or 'password' type.
- The field separator is "|||" */
- const gchar* script = "function dumpForm (inputs) {"
- " var out = '';"
- " for (var i = 0; i < inputs.length; i++) {"
- " if (inputs[i].getAttribute('autocomplete') == 'off' && "
- " inputs[i].type == 'text')"
- " continue;"
- " if (inputs[i].value && (inputs[i].type == 'text' || inputs[i].type == 'password')) {"
- " var ename = inputs[i].getAttribute('name');"
- " var eid = inputs[i].getAttribute('id');"
- " if (!eid && ename)"
- " eid=ename;"
- " out += eid+'|,|'+inputs[i].value +'|,|'+inputs[i].type +'|||';"
- " }"
- " }"
- " return out;"
- "}"
- "dumpForm (document.getElementsByTagName('input'))";
-
- if (webkit_web_navigation_action_get_reason (action) != WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED)
- return FALSE;
-
- priv = g_object_get_data (G_OBJECT (extension), "priv");
- js_context = webkit_web_frame_get_global_context (web_frame);
- value = sokoke_js_script_eval (js_context, script, NULL);
-
- formhistory_suggestions_hide_cb (NULL, NULL, priv);
- if (value && *value)
- {
- gchar** inputs = g_strsplit (value, "|||", 0);
- guint i = 0;
- while (inputs[i] != NULL)
- {
- gchar** parts = g_strsplit (inputs[i], "|,|", 3);
- if (parts && parts[0] && parts[1] && parts[2])
- {
- if (strcmp (parts[2], "password"))
- formhistory_update_database (priv->db, NULL, parts[0], parts[1]);
- else
- {
- #if 0
- FormhistoryPasswordEntry* entry;
- #endif
- gchar* data = formhistory_get_login_data (priv->db, webkit_web_frame_get_uri (web_frame));
- if (data)
- {
- g_free (data);
- break;
- }
- #if 0
- entry = g_slice_new (FormhistoryPasswordEntry);
- /* Domain and form data are freed from infopanel callback*/
- entry->form_data = g_strdup (value);
- entry->domain = domain;
- entry->priv = priv;
- g_object_set_data (G_OBJECT (web_view), "FormHistoryPasswordEntry", entry);
- #endif
- }
- }
- g_strfreev (parts);
- i++;
- }
- g_strfreev (inputs);
- g_free (value);
- }
- return FALSE;
-}
-
-static void
-formhistory_window_object_cleared_cb (WebKitWebView* web_view,
- WebKitWebFrame* web_frame,
- JSContextRef js_context,
- JSObjectRef js_window,
- MidoriExtension* extension)
-{
- const gchar* page_uri;
- FormhistoryPasswordEntry* entry;
- GtkWidget* view;
-
- page_uri = webkit_web_frame_get_uri (web_frame);
- if (!page_uri)
- return;
-
- if (!midori_uri_is_http (page_uri) && !g_str_has_prefix (page_uri, "file"))
- return;
-
- formhistory_setup_suggestions (web_view, js_context, extension);
-
- entry = g_object_get_data (G_OBJECT (web_view), "FormHistoryPasswordEntry");
- if (entry)
- {
- const gchar* message = _("Remember password on this page?");
- view = midori_browser_get_current_tab (midori_app_get_browser (
- midori_extension_get_app (extension)));
- midori_view_add_info_bar (MIDORI_VIEW (view), GTK_MESSAGE_QUESTION, message,
- G_CALLBACK (formhistory_remember_password_response), entry,
- _("Remember"), GTK_RESPONSE_ACCEPT,
- _("Not now"), GTK_RESPONSE_IGNORE,
- _("Never for this page"), GTK_RESPONSE_CANCEL, NULL);
- g_object_set_data (G_OBJECT (web_view), "FormHistoryPasswordEntry", NULL);
- }
-}
-
-static gchar*
-formhistory_decrypt (const gchar* data,
- const gchar* password)
-{
- /* TODO: Implement persistent storage/ keyring support */
- return NULL;
-}
-
-static void
-formhistory_fill_login_data (JSContextRef js_context,
- FormHistoryPriv* priv,
- const gchar* data)
-{
- gchar* decrypted_data = NULL;
- guint i = 0;
- GString *script;
- gchar** inputs;
-
- /* Handle case that user dont want to store password */
- if (!strncmp (data, "never", 5))
- return;
-
- #if 0
- if (!formhistory_check_master_password (NULL, priv))
- return;
- #endif
-
- if (!(decrypted_data = formhistory_decrypt (data, priv->master_password)))
- return;
-
- script = g_string_new ("");
- inputs = g_strsplit (decrypted_data, "|||", 0);
- while (inputs[i] != NULL)
- {
- gchar** parts = g_strsplit (inputs[i], "|,|", 3);
- if (parts && parts[0] && parts[1] && parts[2])
- {
- g_string_append_printf (script, "node = null;"
- "node = document.getElementById ('%s');"
- "if (!node) { node = document.getElementsByName ('%s')[0]; }"
- "if (node && node.type == '%s') { node.value = '%s'; }",
- parts[0], parts[0], parts[2], parts[1]);
- }
- g_strfreev (parts);
- i++;
- }
- g_free (decrypted_data);
- g_strfreev (inputs);
- g_free (sokoke_js_script_eval (js_context, script->str, NULL));
- g_string_free (script, TRUE);
-}
-
-static void
-formhistory_frame_loaded_cb (WebKitWebView* web_view,
- WebKitWebFrame* web_frame,
- MidoriExtension* extension)
-{
- const gchar* page_uri;
- const gchar* count_request;
- FormHistoryPriv* priv;
- JSContextRef js_context;
- gchar* data;
- gchar* count;
-
- page_uri = webkit_web_frame_get_uri (web_frame);
- if (!page_uri)
- return;
-
- count_request = "document.querySelectorAll('input[type=password]').length";
- js_context = webkit_web_frame_get_global_context (web_frame);
- count = sokoke_js_script_eval (js_context, count_request, NULL);
- if (count && count[0] == '0')
- {
- g_free (count);
- return;
- }
- g_free (count);
-
- priv = g_object_get_data (G_OBJECT (extension), "priv");
- data = formhistory_get_login_data (priv->db, webkit_web_frame_get_uri (web_frame));
-
- if (!data)
- return;
- formhistory_fill_login_data (js_context, priv, data);
- g_free (data);
-}
-
-static void
-formhistory_deactivate_cb (MidoriExtension* extension,
- MidoriBrowser* browser);
-
-static void
-formhistory_add_tab_cb (MidoriBrowser* browser,
- MidoriView* view,
- MidoriExtension* extension)
-{
- GtkWidget* web_view = midori_view_get_web_view (view);
-
- g_signal_connect (web_view, "window-object-cleared",
- G_CALLBACK (formhistory_window_object_cleared_cb), extension);
- g_signal_connect (web_view, "navigation-policy-decision-requested",
- G_CALLBACK (formhistory_navigation_decision_cb), extension);
- g_signal_connect (web_view, "onload-event",
- G_CALLBACK (formhistory_frame_loaded_cb), extension);
-}
-
-static void
-formhistory_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension)
-{
-
- GtkAccelGroup* acg = gtk_accel_group_new ();
- GtkActionGroup* action_group = midori_browser_get_action_group (browser);
- GtkAction* action = gtk_action_new ("FormHistoryToggleState",
- _("Toggle form history state"),
- _("Activate or deactivate form history for the current tab."), NULL);
- gtk_window_add_accel_group (GTK_WINDOW (browser), acg);
-
- g_object_set_data (G_OBJECT (browser), "FormHistoryExtension", extension);
-
- g_signal_connect (action, "activate",
- G_CALLBACK (formhistory_toggle_state_cb), browser);
-
- gtk_action_group_add_action_with_accel (action_group, action, "<Ctrl><Shift>F");
- gtk_action_set_accel_group (action, acg);
- gtk_action_connect_accelerator (action);
-
- if (midori_extension_get_boolean (extension, "always-load"))
- {
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs; tabs = g_list_next (tabs))
- formhistory_add_tab_cb (browser, tabs->data, extension);
- g_list_free (tabs);
- g_signal_connect (browser, "add-tab",
- G_CALLBACK (formhistory_add_tab_cb), extension);
- }
- g_signal_connect (extension, "deactivate",
- G_CALLBACK (formhistory_deactivate_cb), browser);
-}
-
-static void
-formhistory_deactivate_tab (MidoriView* view,
- MidoriExtension* extension)
-{
- GtkWidget* web_view = midori_view_get_web_view (view);
-
- g_signal_handlers_disconnect_by_func (
- web_view, formhistory_window_object_cleared_cb, extension);
- g_signal_handlers_disconnect_by_func (
- web_view, formhistory_navigation_decision_cb, extension);
- g_signal_handlers_disconnect_by_func (
- web_view, formhistory_frame_loaded_cb, extension);
-}
-
-static void
-formhistory_deactivate_cb (MidoriExtension* extension,
- MidoriBrowser* browser)
-{
- MidoriApp* app = midori_extension_get_app (extension);
- FormHistoryPriv* priv = g_object_get_data (G_OBJECT (extension), "priv");
-
- GtkActionGroup* action_group = midori_browser_get_action_group (browser);
- GtkAction* action;
-
- g_signal_handlers_disconnect_by_func (
- browser, formhistory_add_tab_cb, extension);
- g_signal_handlers_disconnect_by_func (
- extension, formhistory_deactivate_cb, browser);
- g_signal_handlers_disconnect_by_func (
- app, formhistory_app_add_browser_cb, extension);
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs; tabs = g_list_next (tabs))
- formhistory_deactivate_tab (tabs->data, extension);
- g_list_free (tabs);
-
- g_object_set_data (G_OBJECT (browser), "FormHistoryExtension", NULL);
- action = gtk_action_group_get_action (action_group, "FormHistoryToggleState");
- if (action != NULL)
- {
- gtk_action_group_remove_action (action_group, action);
- g_object_unref (action);
- }
-
- formhistory_private_destroy (priv);
-}
-
-static FormHistoryPriv*
-formhistory_new (const gchar* config_dir)
-{
- gchar* filename;
- GError* error = NULL;
- FormHistoryPriv* priv = formhistory_private_new ();
- priv->master_password = NULL;
- priv->master_password_canceled = 0;
- formhistory_construct_popup_gui (priv);
-
- if (config_dir == NULL)
- {
- priv->db = NULL;
- return priv;
- }
-
- filename = g_build_filename (config_dir, "forms.db", NULL);
- priv->database = midori_database_new (filename, &error);
- g_free (filename);
- if (error != NULL)
- {
- g_critical ("%s", error->message);
- g_error_free (error);
- priv->db = NULL;
- return priv;
- }
-
- priv->db = midori_database_get_db (MIDORI_DATABASE (priv->database));
- g_warn_if_fail (priv->db != NULL);
- return priv;
-}
-
-static void
-formhistory_activate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- const gchar* config_dir = midori_extension_get_config_dir (extension);
- FormHistoryPriv* priv = formhistory_new (config_dir);
- KatzeArray* browsers = katze_object_get_object (app, "browsers");
- MidoriBrowser* browser;
- g_object_set_data (G_OBJECT (extension), "priv", priv);
-
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- formhistory_app_add_browser_cb (app, browser, extension);
- g_signal_connect (app, "add-browser",
- G_CALLBACK (formhistory_app_add_browser_cb), extension);
- g_object_unref (browsers);
-}
-
-static void
-formhistory_preferences_response_cb (GtkWidget* dialog,
- gint response_id,
- MidoriExtension* extension)
-{
- GtkWidget* checkbox;
- gboolean old_state;
- gboolean new_state;
- MidoriApp* app;
- KatzeArray* browsers;
- MidoriBrowser* browser;
-
- if (response_id == GTK_RESPONSE_APPLY)
- {
- checkbox = g_object_get_data (G_OBJECT (dialog), "always-load-checkbox");
- new_state = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox));
- old_state = midori_extension_get_boolean (extension, "always-load");
-
- if (old_state != new_state)
- {
- midori_extension_set_boolean (extension, "always-load", new_state);
-
- app = midori_extension_get_app (extension);
- browsers = katze_object_get_object (app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- {
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs; tabs = g_list_next (tabs))
- formhistory_deactivate_tab (tabs->data, extension);
- g_signal_handlers_disconnect_by_func (
- browser, formhistory_add_tab_cb, extension);
-
- if (new_state)
- {
- for (; tabs; tabs = g_list_next (tabs))
- formhistory_add_tab_cb (browser, tabs->data, extension);
- g_signal_connect (browser, "add-tab",
- G_CALLBACK (formhistory_add_tab_cb), extension);
- }
- g_list_free (tabs);
- }
- }
- }
- gtk_widget_destroy (dialog);
-}
-
-static void
-formhistory_preferences_cb (MidoriExtension* extension)
-{
- GtkWidget* dialog;
- GtkWidget* content_area;
- GtkWidget* checkbox;
-
- dialog = gtk_dialog_new ();
-
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_APPLY, GTK_RESPONSE_APPLY);
-
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- checkbox = gtk_check_button_new_with_label (_("Only activate form history via hotkey (Ctrl+Shift+F) per tab"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox),
- !midori_extension_get_boolean (extension, "always-load"));
- g_object_set_data (G_OBJECT (dialog), "always-load-checkbox", checkbox);
- gtk_box_pack_start (GTK_BOX (content_area), checkbox, FALSE, TRUE, 0);
- /* FIXME: Add pref to disable password manager */
-
- g_signal_connect (dialog,
- "response",
- G_CALLBACK (formhistory_preferences_response_cb),
- extension);
- gtk_widget_show_all (dialog);
-}
-
-static void
-formhistory_toggle_state_cb (GtkAction* action,
- MidoriBrowser* browser)
-{
- MidoriView* view = MIDORI_VIEW (midori_browser_get_current_tab (browser));
- MidoriExtension* extension = g_object_get_data (G_OBJECT (browser), "FormHistoryExtension");
- GtkWidget* web_view = midori_view_get_web_view (view);
-
- if (g_signal_handler_find (web_view, G_SIGNAL_MATCH_FUNC,
- g_signal_lookup ("window-object-cleared", MIDORI_TYPE_VIEW), 0, NULL,
- formhistory_window_object_cleared_cb, extension))
- {
- formhistory_deactivate_tab (view, extension);
- }
- else
- formhistory_add_tab_cb (browser, view, extension);
-}
-
-static void
-test_formhistory_login (void)
-{
- gchar* config_dir = midori_paths_get_extension_config_dir ("formhistory");
- FormHistoryPriv* priv = formhistory_new (config_dir);
- g_free (formhistory_get_login_data (priv->db, "http://example.com"));
- g_free (formhistory_get_login_data (priv->db, "http://beispiel.de"));
- formhistory_update_database (priv->db, "http://example.com", "MidoriPasswordManager", "lalelu");
- formhistory_update_database (priv->db, NULL, "spam", "eggs");
- g_free (formhistory_get_login_data (priv->db, "http://example.com"));
- g_free (formhistory_get_login_data (priv->db, "http://beispiel.de"));
- g_free (config_dir);
- formhistory_private_destroy (priv);
-}
-
-void
-extension_test (void)
-{
- g_test_add_func ("/extensions/formhistory/login", test_formhistory_login);
-}
-
-MidoriExtension*
-extension_init (void)
-{
- MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", _("Form history filler"),
- "description", _("Stores history of entered form data"),
- "version", "2.0" MIDORI_VERSION_SUFFIX,
- "authors", "Alexander V. Butenko <a.butenka@gmail.com>",
- NULL);
-
- midori_extension_install_boolean (extension, "always-load", TRUE);
- g_signal_connect (extension, "activate",
- G_CALLBACK (formhistory_activate_cb), NULL);
- g_signal_connect (extension, "open-preferences",
- G_CALLBACK (formhistory_preferences_cb), NULL);
-
- return extension;
-}
diff --git a/extensions/history-list.vala b/extensions/history-list.vala
deleted file mode 100644
index db719278..00000000
--- a/extensions/history-list.vala
+++ /dev/null
@@ -1,665 +0,0 @@
-/*
- Copyright (C) 2010-2013 André Stösel <andre@stoesel.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.
-*/
-
-namespace HistoryList {
- enum TabTreeCells {
- TREE_CELL_PIXBUF,
- TREE_CELL_STRING,
- TREE_CELL_FG,
- TREE_CELL_BG,
- TREE_CELL_POINTER,
- TREE_CELL_COUNT
- }
-
- enum TabClosingBehavior {
- NONE,
- LAST,
- NEW
- }
-
- enum TabClosingBehaviorModel {
- TEXT,
- VALUE
- }
-
- private abstract class HistoryWindow : Gtk.Window {
- public Midori.Browser browser { get; construct set; }
- protected Gtk.TreeView? treeview = null;
-
- public HistoryWindow (Midori.Browser browser) {
- GLib.Object (type: Gtk.WindowType.POPUP,
- window_position: Gtk.WindowPosition.CENTER,
- browser: browser);
- }
-
- public virtual void walk (int step) {
- Gtk.TreePath? path;
- Gtk.TreeViewColumn? column;
-
- this.treeview.get_cursor (out path, out column);
- if (path == null)
- return;
-
- unowned int[] indices = path.get_indices ();
- int new_index = indices[0] + step;
-
- var model = this.treeview.get_model () as Gtk.ListStore;
-
- int length = model.iter_n_children(null);
- while (new_index < 0 || new_index >= length)
- new_index = new_index < 0 ? length + new_index : new_index - length;
-
- path = new Gtk.TreePath.from_indices (new_index);
- this.treeview.set_cursor (path, column, false);
- }
-
- public abstract void make_update ();
- public abstract void clean_up ();
- public abstract void close_tab ();
- }
-
- private class TabWindow : HistoryWindow {
- protected Gtk.HBox? hbox;
- protected Gtk.VBox? vbox;
- protected bool is_dirty = false;
- protected Gtk.ScrolledWindow? scroll_windows;
-
- protected void store_append_row (GLib.PtrArray list, Gtk.ListStore store) {
- for (var i = list.len; i > 0; i--) {
- Midori.View view = list.index (i - 1) as Midori.View;
-
- Gdk.Pixbuf? icon = null;
- view.get ("icon", ref icon);
-
- unowned string title = view.get_display_title ();
-
- Gtk.TreeIter iter;
- store.append (out iter);
- store.set (iter, TabTreeCells.TREE_CELL_PIXBUF, icon,
- TabTreeCells.TREE_CELL_STRING, title,
- TabTreeCells.TREE_CELL_FG, view.fg_color,
- TabTreeCells.TREE_CELL_BG, view.bg_color,
- TabTreeCells.TREE_CELL_POINTER, view);
- }
- }
-
- protected virtual void insert_rows (Gtk.ListStore store) {
- unowned GLib.PtrArray list = this.browser.get_data<GLib.PtrArray> ("history-list-tab-history");
- unowned GLib.PtrArray list_new = this.browser.get_data<GLib.PtrArray> ("history-list-tab-history-new");
- store_append_row (list, store);
- store_append_row (list_new, store);
- }
-
- protected void resize_treeview () {
- Gtk.Requisition requisition;
- int height;
- int max_lines = 10;
-#if HAVE_GTK3
- requisition = Gtk.Requisition();
- this.treeview.get_preferred_size(out requisition, null);
-#else
- this.treeview.size_request (out requisition);
-#endif
- Gtk.ListStore model = this.treeview.get_model () as Gtk.ListStore;
- int length = model.iter_n_children(null);
- if (length > max_lines) {
- height = requisition.height / length * max_lines + 2;
- } else {
- height = requisition.height + 2;
- }
- this.scroll_windows.set_size_request (320, height);
- this.resize (320, height);
-
- }
-
- public TabWindow (Midori.Browser browser) {
- base (browser);
-
- this.vbox = new Gtk.VBox (false, 1);
- this.add (this.vbox);
-
- this.hbox = new Gtk.HBox (false, 1);
-
- this.scroll_windows = new Gtk.ScrolledWindow (null, null);
- this.scroll_windows.set_policy (Gtk.PolicyType.NEVER , Gtk.PolicyType.AUTOMATIC);
- this.scroll_windows.set_shadow_type (Gtk.ShadowType.ETCHED_IN);
- this.hbox.pack_start (this.scroll_windows, true, true, 0);
-
- var store = new Gtk.ListStore (TabTreeCells.TREE_CELL_COUNT,
- typeof (Gdk.Pixbuf), typeof (string),
- typeof (Gdk.Color), typeof (Gdk.Color), typeof (void*));
-
- this.insert_rows (store);
-
- this.vbox.pack_start (this.hbox, true, true, 0);
-
- this.treeview = new Gtk.TreeView.with_model (store);
- this.scroll_windows.add (treeview);
-
- this.treeview.set_model (store);
- this.treeview.set ("headers-visible", false);
-
- this.treeview.insert_column_with_attributes (
- -1, "Icon",
- new Gtk.CellRendererPixbuf (), "pixbuf", TabTreeCells.TREE_CELL_PIXBUF,
- "cell-background-gdk", TabTreeCells.TREE_CELL_BG);
- this.treeview.insert_column_with_attributes (
- -1, "Title",
- new Gtk.CellRendererText (), "text", TabTreeCells.TREE_CELL_STRING,
- "foreground-gdk", TabTreeCells.TREE_CELL_FG,
- "cell-background-gdk", TabTreeCells.TREE_CELL_BG);
-
- this.show_all ();
- this.resize_treeview ();
- }
-
- public override void make_update () {
- this.is_dirty = true;
-
- Gtk.TreePath? path;
- Gtk.TreeViewColumn? column;
-
- this.treeview.get_cursor (out path, out column);
- if (path == null)
- return;
-
- var model = this.treeview.get_model () as Gtk.ListStore;
-
- Gtk.TreeIter iter;
- unowned Midori.View? view = null;
-
- if (!model.get_iter (out iter, path))
- return;
- model.get (iter, TabTreeCells.TREE_CELL_POINTER, out view);
- this.browser.set ("tab", view);
- }
-
- public override void clean_up () {
- if(this.is_dirty) {
- Gtk.TreePath? path;
- Gtk.TreeViewColumn? column;
-
- this.treeview.get_cursor (out path, out column);
-
- path = new Gtk.TreePath.from_indices (0);
- this.treeview.set_cursor (path, column, false);
-
- this.make_update ();
- this.is_dirty = false;
- }
- }
-
- public override void close_tab () {
- Gtk.TreePath? path;
- Gtk.TreeViewColumn? column;
-
- this.treeview.get_cursor (out path, out column);
-
- Gtk.ListStore model = this.treeview.get_model () as Gtk.ListStore;
- int length = model.iter_n_children(null);
-
- if (length > 1) {
- Gtk.TreeIter iter;
- unowned Midori.View? view = null;
-
- model.get_iter (out iter, path);
- model.get (iter, TabTreeCells.TREE_CELL_POINTER, out view);
-#if !HAVE_GTK3
- /* removing the selected cursor causes a segfault when using GTK2 */
- if (path.prev () == false)
- path.next ();
- this.treeview.set_cursor (path, column, false);
-#endif
-
- /*
- FixMe: the retrun value of `Gtk.ListStore.remove` should be checked
- Note: in some cases the return value of `Gtk.ListStore.remove` is wrong
- */
- model.remove (iter);
- this.browser.close_tab (view);
- if (length > 2)
- this.resize_treeview ();
- else
- this.hide ();
- }
- }
- }
-
- private class NewTabWindow : TabWindow {
- protected bool old_tabs = false;
- protected bool first_step = true;
-
- protected override void insert_rows (Gtk.ListStore store) {
- unowned GLib.PtrArray list = this.browser.get_data<GLib.PtrArray> ("history-list-tab-history-new");
- store_append_row (list, store);
-
- if ((int)list.len == 0) {
- this.old_tabs = true;
- var label = new Gtk.Label (_("There are no unvisited tabs"));
- this.vbox.pack_start (label, true, true, 0);
- unowned GLib.PtrArray list_old = this.browser.get_data<GLib.PtrArray> ("history-list-tab-history");
- store_append_row (list_old, store);
- }
- }
-
- public override void walk (int step) {
- if (this.first_step == false || step != 1) {
- base.walk (step);
- }
- this.first_step = false;
- }
-
- public override void clean_up () {
- if(this.is_dirty) {
- if(this.old_tabs) {
- base.clean_up ();
- } else {
- unowned GLib.PtrArray list = this.browser.get_data<GLib.PtrArray> ("history-list-tab-history");
- Midori.View view = list.index (list.len - 1) as Midori.View;
- this.browser.set ("tab", view);
- }
- }
- }
-
- public NewTabWindow (Midori.Browser browser) {
- base (browser);
- }
- }
-
- private class PreferencesDialog : Gtk.Dialog {
- protected Manager hl_manager;
- protected Gtk.ComboBox closing_behavior;
-
- public PreferencesDialog (Manager manager) {
- this.hl_manager = manager;
-
- this.title = _("Preferences for %s").printf( _("History-List"));
- if (this.get_class ().find_property ("has-separator") != null)
- this.set ("has-separator", false);
- this.border_width = 5;
- this.set_modal (true);
- this.set_default_size (350, 100);
- this.create_widgets ();
-
- this.response.connect (response_cb);
- }
-
- private void response_cb (Gtk.Dialog source, int response_id) {
- switch (response_id) {
- case Gtk.ResponseType.APPLY:
- int value;
- Gtk.TreeIter iter;
-
- this.closing_behavior.get_active_iter (out iter);
- var model = this.closing_behavior.get_model ();
- model.get (iter, TabClosingBehaviorModel.VALUE, out value);
-
- this.hl_manager.set_integer ("TabClosingBehavior", value);
- this.hl_manager.preferences_changed ();
-
- this.destroy ();
- break;
- case Gtk.ResponseType.CANCEL:
- this.destroy ();
- break;
- }
- }
-
- private void create_widgets () {
- Gtk.ListStore model;
- Gtk.TreeIter iter;
- Gtk.TreeIter? active_iter = null;
-
- var table = new Gtk.Table (1, 2, true);
- var renderer = new Gtk.CellRendererText ();
-
- var label = new Gtk.Label ( _("Tab closing behavior"));
- table.attach_defaults (label, 0, 1, 0, 1);
-
- var tab_closing_behavior = this.hl_manager.get_integer ("TabClosingBehavior");
-
- model = new Gtk.ListStore (2, typeof (string), typeof (int));
-
- model.append (out iter);
- model.set (iter, TabClosingBehaviorModel.TEXT, _("Do nothing"),
- TabClosingBehaviorModel.VALUE, TabClosingBehavior.NONE);
- if (TabClosingBehavior.NONE == tab_closing_behavior)
- active_iter = iter;
-
- model.append (out iter);
- model.set (iter, TabClosingBehaviorModel.TEXT, _("Switch to last viewed tab"),
- TabClosingBehaviorModel.VALUE, TabClosingBehavior.LAST);
- if (TabClosingBehavior.LAST == tab_closing_behavior)
- active_iter = iter;
-
- model.append (out iter);
- model.set (iter, TabClosingBehaviorModel.TEXT, _("Switch to newest tab"),
- TabClosingBehaviorModel.VALUE, TabClosingBehavior.NEW);
- if (TabClosingBehavior.NEW == tab_closing_behavior)
- active_iter = iter;
-
- this.closing_behavior = new Gtk.ComboBox.with_model (model);
- this.closing_behavior.set_active_iter (active_iter);
- this.closing_behavior.pack_start (renderer, true);
- this.closing_behavior.set_attributes (renderer, "text", 0);
-
- table.attach_defaults (this.closing_behavior, 1, 2, 0, 1);
-
-#if !HAVE_WIN32
- var proxy = Katze.property_proxy (this.hl_manager.get_app ().settings, "flash-window-on-new-bg-tabs", null);
- (proxy as Gtk.Button).label = _("Flash window on background tabs");
- table.attach_defaults (proxy, 0, 2, 1, 2);
-#endif
-
-#if HAVE_GTK3
- (get_content_area() as Gtk.Box).pack_start (table, false, true, 0);
-#else
- this.vbox.pack_start (table, false, true, 0);
-#endif
-
- this.add_button (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL);
- this.add_button (Gtk.STOCK_APPLY, Gtk.ResponseType.APPLY);
-
- this.show_all ();
- }
- }
-
- private class Manager : Midori.Extension {
- public signal void preferences_changed ();
-
- protected uint escKeyval;
- protected uint delKeyval;
- protected uint modifier_count;
- protected int closing_behavior;
- protected HistoryWindow? history_window;
- protected ulong[] tmp_sig_ids = new ulong[2];
- protected bool ignoreNextChange = false;
-
- public void preferences_changed_cb () {
- this.closing_behavior = this.get_integer ("TabClosingBehavior");
- }
-
- public bool is_key_a_modifier (Gdk.EventKey event_key) {
-#if HAVE_WIN32
- /* On win is_modifier check does not seem to work */
- if (event_key.keyval == Gdk.keyval_from_name("Control_L"))
- return true;
-#else
- if (event_key.is_modifier > 0)
- return true;
-#endif
- return false;
- }
-
- public bool key_press (Gdk.EventKey event_key) {
- if (is_key_a_modifier (event_key)) {
- this.modifier_count++;
- }
- return false;
- }
-
- public bool key_release (Gdk.EventKey event_key, Midori.Browser browser) {
- if (is_key_a_modifier (event_key)) {
- this.modifier_count--;
- }
- if (this.modifier_count == 0 || event_key.keyval == this.escKeyval) {
- browser.disconnect (this.tmp_sig_ids[0]);
- browser.disconnect (this.tmp_sig_ids[1]);
- if (this.modifier_count == 0) {
- this.history_window.make_update ();
- } else {
- this.modifier_count = 0;
- this.history_window.clean_up ();
- }
- this.history_window.destroy ();
- this.history_window = null;
- } else if (event_key.keyval == this.delKeyval) {
- this.history_window.close_tab ();
- }
- return false;
- }
-
- public void walk (Gtk.Action action, Midori.Browser browser, Type type, int step) {
- Midori.View? view = null;
- view = browser.get_data<Midori.View?> ("history-list-last-change");
- if (view != null) {
- this.tab_list_resort (browser, view);
- browser.set_data<Midori.View?> ("history-list-last-change", null);
- }
-
- if (this.history_window == null || this.history_window.get_type () != type) {
- if (this.history_window == null) {
- this.modifier_count = Midori.Sokoke.gtk_action_count_modifiers (action);
- this.tmp_sig_ids[0] = browser.key_press_event.connect ((ek) => {
- return this.key_press (ek);
- });
- this.tmp_sig_ids[1] = browser.key_release_event.connect ((ek) => {
- return this.key_release (ek, browser);
- });
- } else {
- this.history_window.destroy ();
- this.history_window = null;
- }
- /*
- Bug: https://bugzilla.gnome.org/show_bug.cgi?id=618750
- Code: this.history_window = (Gtk.Window) GLib.Object.new (type);
- */
- if (type == typeof (TabWindow)) {
- this.history_window = new TabWindow (browser);
- } else if (type == typeof (NewTabWindow)) {
- this.history_window = new NewTabWindow (browser);
- }
- }
- var hw = this.history_window as HistoryWindow;
- hw.walk (step);
- }
-
- public void special_function (Gtk.Action action, Midori.Browser browser) {
- if (this.history_window != null) {
- this.ignoreNextChange = true;
- this.history_window.make_update ();
- }
- }
-
- void browser_added (Midori.Browser browser) {
- ulong sidTabNext, sidTabPrevious;
- var acg = new Gtk.AccelGroup ();
- browser.add_accel_group (acg);
- var action_group = browser.get_action_group ();
-
- Gtk.Action action;
-
- action = action_group.get_action ("TabNext");
- browser.block_action (action);
- sidTabNext = action.activate.connect ((a) => {
- this.walk (a, browser, typeof (TabWindow), 1);
- });
-
- action = action_group.get_action ("TabPrevious");
- browser.block_action (action);
- sidTabPrevious = action.activate.connect ((a) => {
- this.walk (a, browser, typeof (TabWindow), -1);
- });
-
- action = new Gtk.Action ("HistoryListNextNewTab",
- _("Next new Tab (History List)"),
- _("Next new tab from history"), null);
- action.activate.connect ((a) => {
- this.walk (a, browser, typeof (NewTabWindow), 1);
- });
- action_group.add_action_with_accel (action, "<Ctrl>1");
- action.set_accel_group (acg);
- action.connect_accelerator ();
-
- action = new Gtk.Action ("HistoryListPreviousNewTab",
- _("Previous new Tab (History List)"),
- _("Previous new tab from history"), null);
- action.activate.connect ((a) => {
- this.walk (a, browser, typeof (NewTabWindow), -1);
- });
- action_group.add_action_with_accel (action, "<Ctrl>2");
- action.set_accel_group (acg);
- action.connect_accelerator ();
-
- action = new Gtk.Action ("HistoryListSpecialFunction",
- _("Display tab in background (History List)"),
- _("Display the current selected tab in background"), null);
- action.activate.connect ((a) => {
- this.special_function (a, browser);
- });
- action_group.add_action_with_accel (action, "<Ctrl>3");
- action.set_accel_group (acg);
- action.connect_accelerator ();
-
- browser.set_data<ulong> ("history-list-sid-tab-next", sidTabNext);
- browser.set_data<ulong> ("history-list-sid-tab-previous", sidTabPrevious);
-
- browser.set_data<GLib.PtrArray*> ("history-list-tab-history",
- new GLib.PtrArray ());
- browser.set_data<GLib.PtrArray*> ("history-list-tab-history-new",
- new GLib.PtrArray ());
- browser.set_data<Midori.View?> ("history-list-last-change", null);
-
- foreach (var tab in browser.get_tabs ())
- tab_added (browser, tab);
- browser.add_tab.connect (tab_added);
- browser.remove_tab.connect (tab_removed);
- browser.switch_tab.connect (this.tab_changed);
- }
-
- void browser_removed (Midori.Browser browser) {
- string[] callbacks = { "HistoryListNextNewTab", "HistoryListPreviousNewTab",
- "HistoryListSpecialFunction" };
- ulong sidTabNext, sidTabPrevious;
- sidTabNext = browser.get_data<ulong> ("history-list-sid-tab-next");
- sidTabPrevious = browser.get_data<ulong> ("history-list-sid-tab-previous");
-
- Gtk.Action action;
- Gtk.ActionGroup action_group;
- action_group = browser.get_action_group ();
-
- action = action_group.get_action ("TabNext");
- action.disconnect (sidTabNext);
- browser.unblock_action (action);
- action = action_group.get_action ("TabPrevious");
- action.disconnect (sidTabPrevious);
- browser.unblock_action (action);
-
- for (int i = 0; i < callbacks.length; i++) {
- action = action_group.get_action (callbacks[i]);
- if (action != null)
- action_group.remove_action (action);
- }
-
- browser.add_tab.disconnect (tab_added);
- browser.remove_tab.disconnect (tab_removed);
- browser.switch_tab.disconnect (this.tab_changed);
- }
-
- void tab_added (Midori.Browser browser, Midori.View view) {
- unowned GLib.PtrArray list = browser.get_data<GLib.PtrArray> ("history-list-tab-history-new");
- list.add (view);
- }
-
- void tab_removed (Midori.Browser browser, Midori.View view) {
- unowned GLib.PtrArray list = browser.get_data<GLib.PtrArray> ("history-list-tab-history");
- unowned GLib.PtrArray list_new = browser.get_data<GLib.PtrArray> ("history-list-tab-history-new");
- list.remove (view);
- list_new.remove (view);
-
- Midori.View? current_view = browser.tab as Midori.View;
-
- if (current_view != view)
- return;
-
- if (this.closing_behavior == TabClosingBehavior.LAST || this.closing_behavior == TabClosingBehavior.NEW) {
- browser.set_data<Midori.View?> ("history-list-last-change", null);
-
- if ((int) list.len > 0 || (int) list_new.len > 0) {
- TabWindow hw;
- if (this.closing_behavior == TabClosingBehavior.LAST)
- hw = new TabWindow (browser);
- else
- hw = new NewTabWindow (browser);
- hw.make_update ();
- hw.destroy ();
- }
- }
- }
-
- void tab_changed (Midori.View? old_view, Midori.View? new_view) {
- if(this.ignoreNextChange) {
- this.ignoreNextChange = false;
- } else {
- Midori.Browser? browser = Midori.Browser.get_for_widget (new_view);
- Midori.View? last_view
- = browser.get_data<Midori.View?> ("history-list-last-change");
-
- if (last_view != null) {
- this.tab_list_resort (browser, last_view);
- }
- browser.set_data<Midori.View?> ("history-list-last-change", new_view);
- }
- }
-
- void tab_list_resort (Midori.Browser browser, Midori.View view) {
- unowned GLib.PtrArray list = browser.get_data<GLib.PtrArray> ("history-list-tab-history");
- unowned GLib.PtrArray list_new = browser.get_data<GLib.PtrArray> ("history-list-tab-history-new");
- list.remove (view);
- list_new.remove (view);
- list.add (view);
- }
-
- void activated (Midori.App app) {
- this.preferences_changed ();
- foreach (var browser in app.get_browsers ())
- browser_added (browser);
- app.add_browser.connect (browser_added);
- app.remove_browser.connect (browser_removed);
- }
-
- void deactivated () {
- var app = get_app ();
- foreach (var browser in app.get_browsers ())
- browser_removed (browser);
- app.add_browser.disconnect (browser_added);
- app.remove_browser.disconnect (browser_removed);
- }
-
- void show_preferences () {
- var dialog = new PreferencesDialog (this);
- dialog.show ();
- }
-
- internal Manager () {
- GLib.Object (name: _("History List"),
- description: _("Move to the last used tab when switching or closing tabs"),
- version: "0.4" + Midori.VERSION_SUFFIX,
- authors: "André Stösel <andre@stoesel.de>");
-
- this.install_integer ("TabClosingBehavior", TabClosingBehavior.LAST);
-
- this.activate.connect (activated);
- this.deactivate.connect (deactivated);
- this.open_preferences.connect (show_preferences);
- this.preferences_changed.connect (preferences_changed_cb);
- }
- construct {
- this.escKeyval = Gdk.keyval_from_name ("Escape");
- this.delKeyval = Gdk.keyval_from_name ("Delete");
- }
- }
-}
-
-public Midori.Extension extension_init () {
- return new HistoryList.Manager ();
-}
-
diff --git a/extensions/mouse-gestures.c b/extensions/mouse-gestures.c
deleted file mode 100644
index f105e153..00000000
--- a/extensions/mouse-gestures.c
+++ /dev/null
@@ -1,535 +0,0 @@
-/*
- Copyright (C) 2009 Matthias Kruk <mkruk@matthiaskruk.de>
- Copyright (C) 2009-2010 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.
-*/
-
-#include <midori/midori.h>
-#include <math.h>
-
-typedef struct _MouseGesture MouseGesture;
-typedef enum _MouseButton MouseButton;
-
-enum _MouseButton
-{
- MOUSE_BUTTON_LEFT = 1,
- MOUSE_BUTTON_RIGHT = 3,
- MOUSE_BUTTON_MIDDLE = 2,
- MOUSE_BUTTON_UNSET = 0
-};
-
-/* equivalent to the angle measured anticlockwise from east, divided by 45 or pi/4 */
-typedef enum
-{
- STROKE_EAST = 0,
- STROKE_NORTHEAST,
- STROKE_NORTH,
- STROKE_NORTHWEST,
- STROKE_WEST,
- STROKE_SOUTHWEST,
- STROKE_SOUTH,
- STROKE_SOUTHEAST,
- STROKE_NONE,
-} MouseGestureDirection;
-
-static const gchar* direction_names[]=
-{
- "E",
- "NE",
- "N",
- "NW",
- "W",
- "SW",
- "S",
- "SE",
- "NONE",
-};
-
-#define N_DIRECTIONS 8
-
-#define DEVIANCE (15 * M_PI / 180)
-#define MINLENGTH 30
-
-char** config_actions = NULL;
-MouseGestureDirection** config_gestures = NULL;
-
-const char* default_actions[]=
-{
- "TabClose",
- "Reload",
- "TabNew",
- "Stop",
- "Forward",
- "Back",
- NULL
-};
-
-const MouseGestureDirection default_gesture_strokes[] =
-{
- STROKE_SOUTH, STROKE_EAST, STROKE_NONE,
- STROKE_SOUTH, STROKE_WEST, STROKE_NONE,
- STROKE_SOUTH, STROKE_NONE,
- STROKE_NORTH, STROKE_NONE,
- STROKE_EAST, STROKE_NONE,
- STROKE_WEST, STROKE_NONE,
- STROKE_NONE,
-};
-
-const MouseGestureDirection* default_gestures[] =
-{
- &default_gesture_strokes[0],
- &default_gesture_strokes[3],
- &default_gesture_strokes[6],
- &default_gesture_strokes[8],
- &default_gesture_strokes[10],
- &default_gesture_strokes[12],
- &default_gesture_strokes[14],
-};
-
-static gboolean
-parse_direction (const char* str, MouseGestureDirection* dir)
-{
- int i;
- for (i = 0; i < N_DIRECTIONS; i++)
- {
- if(!strcmp(str, direction_names[i]))
- {
- *dir = i;
- return TRUE;
- }
- }
- return FALSE;
-}
-
-static gboolean
-strokes_equal (const MouseGestureDirection* a, const MouseGestureDirection* b)
-{
- int i;
- for (i = 0; a[i] != STROKE_NONE && b[i] != STROKE_NONE; i++)
- {
- if(a[i] != b[i])
- return FALSE;
- }
- return a[i] == b[i];
-}
-
-struct MouseGestureNode
-{
- double x;
- double y;
-};
-
-static guint
-dist_sqr (guint x1, guint y1, guint x2, guint y2)
-{
- guint xdiff = 0, ydiff = 0;
- // Remember that x1, x2, y1 and y2 are guint unsigned integers.
- // Subtracting a greater number from a lower one is undefined.
- // This guards against that.
-
- if (x1 > x2)
- xdiff = x1 - x2;
- else
- xdiff = x2 - x1;
- if (y1 > y2)
- ydiff = y1 - y2;
- else
- ydiff = y2 - y1;
- return xdiff * xdiff + ydiff * ydiff;
-}
-
-static float
-get_angle_for_direction (MouseGestureDirection direction)
-{
- return direction * 2 * M_PI / N_DIRECTIONS;
-}
-
-static MouseGestureDirection
-nearest_direction_for_angle (float angle)
-{
- /* move halfway to the next direction so we can floor to round */
- angle += M_PI / N_DIRECTIONS;
-
- /* ensure we stay within [0, 2pi) */
- if (angle >= 2 * M_PI)
- angle -= 2 * M_PI;
-
- return (MouseGestureDirection)((angle * N_DIRECTIONS) / (2* M_PI));
-}
-
-static gboolean
-vector_follows_direction (float angle, float distance, MouseGestureDirection direction)
-{
- if (direction == STROKE_NONE)
- return distance < MINLENGTH / 2;
-
- float dir_angle = get_angle_for_direction (direction);
- if (fabsf (angle - dir_angle) < DEVIANCE || fabsf (angle - dir_angle + 2 * (float)(M_PI)) < DEVIANCE)
- return TRUE;
-
- if(distance < MINLENGTH / 2)
- return TRUE;
-
- return FALSE;
-}
-
-/* returns the angle in the range [0, 2pi) (anticlockwise from east) from point 1 to 2 */
-static float
-get_angle_between_points (guint x1, guint y1, guint x2, guint y2)
-{
- float distance = sqrtf (dist_sqr (x1, y1, x2, y2));
-
- /* compute the angle of the vector from a to b */
- float cval=((signed int)x2 - (signed int)x1) / distance;
- float angle = acosf (cval);
- if(y2 > y1)
- angle = 2 * M_PI - angle;
-
- return angle;
-}
-
-#define N_NODES 8
-
-struct _MouseGesture
-{
- MouseButton button;
- MouseGestureDirection strokes[N_NODES + 1];
- struct MouseGestureNode locations[N_NODES];
- struct MouseGestureNode last_pos;
- float last_distance;
- /* the index of the location to be filled next */
- guint count;
- MouseButton last;
-};
-
-MouseGesture *gesture = NULL;
-
-static void
-mouse_gesture_clear (MouseGesture *g)
-{
- memset(g->locations, 0, sizeof(g->locations));
- g->strokes[0] = STROKE_NONE;
- g->count = 0;
- g->last_distance = 0;
- g->last = MOUSE_BUTTON_UNSET;
-}
-
-MouseGesture* mouse_gesture_new (void)
-{
- MouseGesture* g = g_slice_new (MouseGesture);
- mouse_gesture_clear (g);
-
- return g;
-}
-
-static gboolean
-mouse_gestures_button_press_event_cb (GtkWidget* web_view,
- GdkEvent* event,
- MidoriBrowser* browser)
-{
- if (event->button.button == gesture->button)
- {
- /* If the gesture was previously cleaned,
- start a new gesture and coordinates. */
- if (gesture->count == MOUSE_BUTTON_UNSET)
- {
- gesture->locations[gesture->count].x = event->button.x;
- gesture->locations[gesture->count].y = event->button.y;
- gesture->last_pos = gesture->locations[gesture->count];
- gesture->last = event->button.button;
- }
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-mouse_gestures_motion_notify_event_cb (GtkWidget* web_view,
- GdkEvent* event,
- MidoriBrowser* browser)
-{
- /* wait until a button has been pressed */
- if (gesture->last != MOUSE_BUTTON_UNSET)
- {
- guint x, y, oldx, oldy;
- float angle, distance;
- MouseGestureDirection old_direction, new_direction;
-
- x = event->motion.x;
- y = event->motion.y;
- oldx = gesture->locations[gesture->count].x;
- oldy = gesture->locations[gesture->count].y;
-
- old_direction = gesture->strokes[gesture->count];
-
- angle = get_angle_between_points (oldx, oldy, x, y);
- distance = sqrtf (dist_sqr (oldx, oldy, x, y));
-
- /* wait until minimum distance has been reached to set an initial direction. */
- if (old_direction == STROKE_NONE)
- {
- if (distance >= MINLENGTH)
- {
- gesture->strokes[gesture->count] = nearest_direction_for_angle (angle);
- if (midori_debug ("mouse"))
- g_print ("mouse_gestures detected %s\n", direction_names[gesture->strokes[gesture->count]]);
- }
- }
- else if (!vector_follows_direction (angle, distance, old_direction)
- || distance < gesture->last_distance)
- {
- /* if path curves or we've reversed our movement, try to detect a new direction */
- angle = get_angle_between_points (gesture->last_pos.x, gesture->last_pos.y, x, y);
- new_direction = nearest_direction_for_angle (angle);
-
- if (new_direction != old_direction && gesture->count + 1 < N_NODES)
- {
- /* record this node and return to an indeterminate direction */
- gesture->count++;
- gesture->strokes[gesture->count] = STROKE_NONE;
- gesture->locations[gesture->count].x = x;
- gesture->locations[gesture->count].y = y;
- gesture->last_distance = 0;
- }
- }
- else if(distance > gesture->last_distance)
- {
- /* if following the same direction, store the progress along it for later divergence checks */
- gesture->last_pos.x = x;
- gesture->last_pos.y = y;
- gesture->last_distance = distance;
- }
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-mouse_gestures_activate_action (MidoriView* view,
- const gchar* name)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view));
- midori_browser_activate_action (browser, name);
- return TRUE;
-}
-
-static gboolean
-mouse_gestures_button_release_event_cb (GtkWidget* web_view,
- GdkEventButton* event,
- MidoriView* view)
-{
- int i;
-
- if (gesture->strokes[gesture->count] != STROKE_NONE)
- {
- gesture->count++;
- gesture->strokes[gesture->count] = STROKE_NONE;
- }
-
- const MouseGestureDirection** gestures = config_gestures ?
- (const MouseGestureDirection**)config_gestures :
- default_gestures;
- const gchar** actions = config_actions ? (const char**)config_actions : default_actions;
-
- for(i = 0; gestures[i][0] != STROKE_NONE; i++)
- {
- if(strokes_equal (gesture->strokes, gestures[i]))
- {
- mouse_gesture_clear (gesture);
- return mouse_gestures_activate_action (view, actions[i]);
- }
- }
-
- mouse_gesture_clear (gesture);
-
- if (MIDORI_EVENT_CONTEXT_MENU (event))
- {
- GtkWidget* menu = gtk_menu_new ();
- midori_view_populate_popup (view, menu, TRUE);
- katze_widget_popup (GTK_WIDGET (web_view), GTK_MENU (menu),
- event, KATZE_MENU_POSITION_CURSOR);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-mouse_gestures_load_config (MidoriExtension* extension)
-{
- int i;
- gchar* config_file;
- gsize n_keys;
- gchar** keys;
- GKeyFile* keyfile;
-
- config_file = g_build_filename (midori_extension_get_config_dir (extension),
- "gestures", NULL);
- keyfile = g_key_file_new ();
- g_key_file_load_from_file (keyfile, config_file, G_KEY_FILE_NONE, NULL);
- g_free (config_file);
-
- if (!keyfile)
- return;
-
- keys = g_key_file_get_keys (keyfile, "gestures", &n_keys, NULL);
- if (!keys)
- return;
-
- if(config_gestures)
- {
- g_strfreev ((gchar**)config_gestures);
- g_strfreev (config_actions);
- }
- config_gestures = g_malloc ((n_keys + 1) * sizeof (MouseGestureDirection*));
- config_actions = g_malloc (n_keys * sizeof (gchar*));
-
- for(i = 0; keys[i]; i++)
- {
- gsize n_strokes;
- guint j;
- gchar** stroke_strings = g_key_file_get_string_list (keyfile, "gestures", keys[i], &n_strokes,
- NULL);
-
- config_gestures[i] = g_malloc ((n_strokes + 1) * sizeof (MouseGestureDirection));
-
- for (j = 0; j < n_strokes; j++)
- {
- if (!parse_direction (stroke_strings[j], &config_gestures[i][j]))
- g_warning ("mouse-gestures: failed to parse direction \"%s\"\n", stroke_strings[j]);
- }
- config_gestures[i][j] = STROKE_NONE;
-
- config_actions[i] = keys[i];
- g_strfreev (stroke_strings);
- }
- config_gestures[i] = g_malloc (sizeof (MouseGestureDirection));
- config_gestures[i][0] = STROKE_NONE;
-
- g_free (keys);
- g_key_file_free (keyfile);
-}
-
-static void
-mouse_gestures_add_tab_cb (MidoriBrowser* browser,
- MidoriView* view,
- MidoriExtension* extension)
-{
- GtkWidget* web_view = midori_view_get_web_view (view);
-
- g_object_connect (web_view,
- "signal::button-press-event",
- mouse_gestures_button_press_event_cb, browser,
- "signal::motion-notify-event",
- mouse_gestures_motion_notify_event_cb, browser,
- "signal::button-release-event",
- mouse_gestures_button_release_event_cb, view,
- NULL);
-}
-
-static void
-mouse_gestures_deactivate_cb (MidoriExtension* extension,
- MidoriBrowser* browser);
-
-static void
-mouse_gestures_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension)
-{
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs; tabs = g_list_next (tabs))
- mouse_gestures_add_tab_cb (browser, tabs->data, extension);
- g_list_free (tabs);
- g_signal_connect (browser, "add-tab",
- G_CALLBACK (mouse_gestures_add_tab_cb), extension);
- g_signal_connect (extension, "deactivate",
- G_CALLBACK (mouse_gestures_deactivate_cb), browser);
-}
-
-static void
-mouse_gestures_deactivate_tabs (MidoriView* view,
- MidoriBrowser* browser)
-{
- GtkWidget* web_view = midori_view_get_web_view (view);
-
- g_object_disconnect (web_view,
- "any_signal::button-press-event",
- mouse_gestures_button_press_event_cb, browser,
- "any_signal::motion-notify-event",
- mouse_gestures_motion_notify_event_cb, browser,
- "any_signal::button-release-event",
- mouse_gestures_button_release_event_cb, view,
- NULL);
-}
-
-static void
-mouse_gestures_deactivate_cb (MidoriExtension* extension,
- MidoriBrowser* browser)
-{
- MidoriApp* app = midori_extension_get_app (extension);
-
- g_signal_handlers_disconnect_by_func (
- extension, mouse_gestures_deactivate_cb, browser);
- g_signal_handlers_disconnect_by_func (
- app, mouse_gestures_app_add_browser_cb, extension);
- g_signal_handlers_disconnect_by_func (
- browser, mouse_gestures_add_tab_cb, extension);
-
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs; tabs = g_list_next (tabs))
- mouse_gestures_deactivate_tabs (tabs->data, browser);
- g_list_free (tabs);
- g_slice_free (MouseGesture, gesture);
- if(config_gestures)
- {
- g_strfreev ((gchar**)config_gestures);
- config_gestures = NULL;
- g_strfreev (config_actions);
- config_actions = NULL;
- }
-}
-
-static void
-mouse_gestures_activate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- KatzeArray* browsers;
- MidoriBrowser* browser;
-
- gesture = mouse_gesture_new ();
- gesture->button = midori_extension_get_integer (extension, "button");
- mouse_gestures_load_config (extension);
-
- browsers = katze_object_get_object (app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- mouse_gestures_app_add_browser_cb (app, browser, extension);
- g_signal_connect (app, "add-browser",
- G_CALLBACK (mouse_gestures_app_add_browser_cb), extension);
-
- g_object_unref (browsers);
-}
-
-MidoriExtension*
-extension_init (void)
-{
- MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", _("Mouse Gestures"),
- "description", _("Control Midori by moving the mouse"),
- "version", "0.2" MIDORI_VERSION_SUFFIX,
- "authors", "Matthias Kruk <mkruk@matthiaskruk.de>", NULL);
- midori_extension_install_integer (extension, "button", MOUSE_BUTTON_RIGHT);
- midori_extension_install_integer (extension, "actions", MOUSE_BUTTON_RIGHT);
-
- g_signal_connect (extension, "activate",
- G_CALLBACK (mouse_gestures_activate_cb), NULL);
-
- return extension;
-}
diff --git a/extensions/nojs/README.md b/extensions/nojs/README.md
deleted file mode 100644
index 3255980f..00000000
--- a/extensions/nojs/README.md
+++ /dev/null
@@ -1 +0,0 @@
-This is an extension for Midori web browser. With this extension you can manage which sites are allowed to execute javascript.
diff --git a/extensions/nojs/main.c b/extensions/nojs/main.c
deleted file mode 100644
index 74fefe26..00000000
--- a/extensions/nojs/main.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- Copyright (C) 2013 Stephan Haller <nomad@froevel.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.
-*/
-
-#include "nojs.h"
-#include "nojs-preferences.h"
-
-/* Global instance */
-NoJS *noJS=NULL;
-
-/* This extension was activated */
-static void _nojs_on_activate(MidoriExtension *inExtension, MidoriApp *inApp, gpointer inUserData)
-{
- g_return_if_fail(noJS==NULL);
-
- noJS=nojs_new(inExtension, inApp);
- nojs_set_policy_for_unknown_domain(noJS, midori_extension_get_integer(inExtension, "unknown-domain-policy"));
- nojs_set_allow_local_pages(noJS, midori_extension_get_boolean(inExtension, "allow-local-pages"));
- nojs_set_only_second_level_domain(noJS, midori_extension_get_boolean(inExtension, "only-second-level"));
-}
-
-/* This extension was deactivated */
-static void _nojs_on_deactivate(MidoriExtension *inExtension, gpointer inUserData)
-{
- g_return_if_fail(noJS);
-
- g_object_unref(noJS);
- noJS=NULL;
-}
-
-/* Preferences of this extension should be opened */
-static void _nojs_on_preferences_response(GtkWidget* inDialog,
- gint inResponse,
- gpointer *inUserData)
-{
- gtk_widget_destroy(inDialog);
-}
-
-static void _nojs_on_open_preferences(MidoriExtension *inExtension)
-{
- g_return_if_fail(noJS);
-
- /* Show preferences window */
- GtkWidget* dialog;
-
- dialog=nojs_preferences_new(noJS);
- gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
- g_signal_connect(dialog, "response", G_CALLBACK (_nojs_on_preferences_response), NULL);
- gtk_widget_show_all(dialog);
-}
-
-/* Main entry for extension */
-MidoriExtension *extension_init(void)
-{
- /* Set up extension */
- MidoriExtension *extension=g_object_new(MIDORI_TYPE_EXTENSION,
- "name", _("NoJS"),
- "description", _("Manage javascript permission per site"),
- "version", "0.1" MIDORI_VERSION_SUFFIX,
- "authors", "Stephan Haller <nomad@froevel.de>",
- NULL);
-
- midori_extension_install_integer(extension, "unknown-domain-policy", NOJS_POLICY_BLOCK);
- midori_extension_install_boolean(extension, "allow-local-pages", TRUE);
- midori_extension_install_boolean(extension, "only-second-level", TRUE);
-
- g_signal_connect(extension, "activate", G_CALLBACK(_nojs_on_activate), NULL);
- g_signal_connect(extension, "deactivate", G_CALLBACK(_nojs_on_deactivate), NULL);
- g_signal_connect(extension, "open-preferences", G_CALLBACK(_nojs_on_open_preferences), NULL);
-
- return(extension);
-}
diff --git a/extensions/nojs/nojs-preferences.c b/extensions/nojs/nojs-preferences.c
deleted file mode 100644
index 38900e9a..00000000
--- a/extensions/nojs/nojs-preferences.c
+++ /dev/null
@@ -1,1022 +0,0 @@
-/*
- Copyright (C) 2013 Stephan Haller <nomad@froevel.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.
-*/
-
-#include "nojs-preferences.h"
-
-/* Define this class in GObject system */
-G_DEFINE_TYPE(NoJSPreferences,
- nojs_preferences,
- GTK_TYPE_DIALOG)
-
-/* Properties */
-enum
-{
- PROP_0,
-
- PROP_MANAGER,
-
- PROP_LAST
-};
-
-static GParamSpec* NoJSPreferencesProperties[PROP_LAST]={ 0, };
-
-/* Private structure - access only by public API if needed */
-#define NOJS_PREFERENCES_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), TYPE_NOJS_PREFERENCES, NoJSPreferencesPrivate))
-
-struct _NoJSPreferencesPrivate
-{
- /* Extension related */
- NoJS *manager;
- sqlite3 *database;
-
- /* Dialog related */
- GtkWidget *contentArea;
- GtkListStore *listStore;
- GtkWidget *list;
- GtkTreeSelection *listSelection;
- GtkWidget *editingCombo;
- GtkWidget *deleteButton;
- GtkWidget *deleteAllButton;
- GtkWidget *allowLocalPagesCheckbox;
- GtkWidget *blockUnknownDomainsCheckbox;
- GtkWidget *checkSecondLevelOnlyCheckbox;
- GtkWidget *addDomainEntry;
- GtkWidget *addDomainPolicyCombo;
- GtkWidget *addDomainButton;
-
- gint signalAllowLocalPagesToggledID;
- gint signalBlockUnknownDomainsToggledID;
- gint signalCheckSecondLevelOnlyToggledID;
-
- gint signalManagerChangedDatabaseID;
- gint signalManagerChangedAllowLocalPagesID;
- gint signalManagerChangedUnknownDomainPolicyID;
- gint signalManagerChangedCheckSecondLevelID;
-};
-
-enum
-{
- DOMAIN_COLUMN,
- POLICY_COLUMN,
- N_COLUMN
-};
-
-
-/* IMPLEMENTATION: Private variables and methods */
-
-/* "Add domain"-button was pressed */
-static void _nojs_preferences_on_add_domain_clicked(NoJSPreferences *self,
- gpointer *inUserData)
-{
- NoJSPreferencesPrivate *priv=self->priv;
- gchar *domain;
- const gchar *domainStart, *domainEnd;
- gchar *realDomain;
- GtkTreeIter policyIter;
-
- g_return_if_fail(priv->database);
-
- /* Get domain name entered */
- domain=g_hostname_to_ascii(gtk_entry_get_text(GTK_ENTRY(priv->addDomainEntry)));
-
- /* Trim whitespaces from start and end of entered domain name */
- domainStart=domain;
- while(*domainStart && g_ascii_isspace(*domainStart)) domainStart++;
-
- domainEnd=domain+strlen(domain)-1;
- while(*domainEnd && g_ascii_isspace(*domainEnd)) domainEnd--;
- if(domainEnd<=domainStart) return;
-
- /* Seperate domain name from whitespaces */
- realDomain=g_strndup(domain, domainEnd-domainStart+1);
- if(!realDomain) return;
-
- /* Get policy from combo box */
- if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(priv->addDomainPolicyCombo), &policyIter))
- {
- gchar *sql;
- gchar *error=NULL;
- gint success;
- gint policy;
- gchar *policyName;
-
- /* Get policy value to set for domain */
- gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(priv->addDomainPolicyCombo)),
- &policyIter,
- 0, &policy,
- 1, &policyName,
- -1);
-
- /* Add domain name and the selected policy to database */
- sql=sqlite3_mprintf("INSERT OR REPLACE INTO policies (site, value) VALUES ('%q', %d);",
- realDomain,
- policy);
- success=sqlite3_exec(priv->database, sql, NULL, NULL, &error);
-
- /* Show error message if any */
- if(success==SQLITE_OK)
- {
- gtk_list_store_append(priv->listStore, &policyIter);
- gtk_list_store_set(priv->listStore,
- &policyIter,
- DOMAIN_COLUMN, realDomain,
- POLICY_COLUMN, policyName,
- -1);
- }
- else g_warning(_("SQL fails: %s"), error);
-
-
- if(error) sqlite3_free(error);
-
- /* Free allocated resources */
- sqlite3_free(sql);
- }
-
- /* Free allocated resources */
- g_free(realDomain);
- g_free(domain);
-}
-
-/* Entry containing domain name which may be added to list has changed */
-static void _nojs_preferences_on_add_domain_entry_changed(NoJSPreferences *self,
- GtkEditable *inEditable)
-{
- NoJSPreferencesPrivate *priv=self->priv;
- gchar *asciiDomain, *checkAsciiDomain;
- gchar *asciiDomainStart, *asciiDomainEnd;
- gint dots;
- gboolean isValid=FALSE;
-
- /* Get ASCII representation of domain name entered */
- asciiDomain=g_hostname_to_ascii(gtk_entry_get_text(GTK_ENTRY(priv->addDomainEntry)));
-
- /* Trim whitespaces from start and end of entered domain name */
- asciiDomainStart=asciiDomain;
- while(*asciiDomainStart && g_ascii_isspace(*asciiDomainStart)) asciiDomainStart++;
-
- asciiDomainEnd=asciiDomain+strlen(asciiDomain)-1;
- while(*asciiDomainEnd && g_ascii_isspace(*asciiDomainEnd)) asciiDomainEnd--;
-
- /* We allow only domain names and not cookie domain name so entered name
- * must not start with a dot
- */
- checkAsciiDomain=asciiDomainStart;
- isValid=(*asciiDomainStart!='.' && *asciiDomainEnd!='.');
-
- /* Now check if ASCII domain name is valid (very very simple check)
- * and contains a hostname besides TLD
- */
- dots=0;
-
- while(*checkAsciiDomain &&
- checkAsciiDomain<=asciiDomainEnd &&
- isValid)
- {
- /* Check for dot as (at least the first one) seperates hostname from TLD */
- if(*checkAsciiDomain=='.') dots++;
- else
- {
- /* Check for valid characters in domain name.
- * Valid domain name can only contain ASCII alphabetic letters,
- * digits (0-9) and hyphens ('-')
- */
- isValid=(g_ascii_isalpha(*checkAsciiDomain) ||
- g_ascii_isdigit(*checkAsciiDomain) ||
- *checkAsciiDomain=='-');
- }
-
- checkAsciiDomain++;
- }
-
- /* If we have not reached the trimmed end of string something must have gone wrong
- * and domain entered is invalid. If domain name entered excluding dots is longer
- * than 255 character it is also invalid.
- */
- if(checkAsciiDomain<asciiDomainEnd) isValid=FALSE;
- else if((checkAsciiDomain-asciiDomainStart-dots)>255) isValid=FALSE;
-
- /* We need at least one dot in domain name (minimum number of dots to seperate
- * hostname from TLD)
- */
- isValid=(isValid && dots>0);
-
- /* Activate "add" button if hostname (equal to domain name here) is valid */
- gtk_widget_set_sensitive(priv->addDomainButton, isValid);
-
- /* Free allocated resources */
- g_free(asciiDomain);
-}
-
-/* Fill domain list with stored policies */
-static void _nojs_preferences_fill(NoJSPreferences *self)
-{
- NoJSPreferencesPrivate *priv=self->priv;
- gint success;
- sqlite3_stmt *statement=NULL;
-
- /* Clear tree/list view */
- gtk_list_store_clear(priv->listStore);
-
- /* If no database is present return here */
- if(!priv->database) return;
-
- /* Fill list store with policies from database */
- success=sqlite3_prepare_v2(priv->database,
- "SELECT site, value FROM policies;",
- -1,
- &statement,
- NULL);
- if(statement && success==SQLITE_OK)
- {
- gchar *domain;
- gint policy;
- gchar *policyName;
- GtkTreeIter iter;
-
- while(sqlite3_step(statement)==SQLITE_ROW)
- {
- /* Get values */
- domain=(gchar*)sqlite3_column_text(statement, 0);
- policy=sqlite3_column_int(statement, 1);
-
- switch(policy)
- {
- case NOJS_POLICY_ACCEPT:
- policyName=_("Accept");
- break;
-
- case NOJS_POLICY_ACCEPT_TEMPORARILY:
- policyName=_("Accept for session");
- break;
-
- case NOJS_POLICY_BLOCK:
- policyName=_("Block");
- break;
-
- default:
- policyName=NULL;
- break;
- }
-
- if(policyName)
- {
- gtk_list_store_append(priv->listStore, &iter);
- gtk_list_store_set(priv->listStore,
- &iter,
- DOMAIN_COLUMN, domain,
- POLICY_COLUMN, policyName,
- -1);
- }
- }
- }
- else g_warning(_("SQL fails: %s"), sqlite3_errmsg(priv->database));
-
- sqlite3_finalize(statement);
-}
-
-/* Database instance in manager changed */
-static void _nojs_preferences_on_manager_database_changed(NoJSPreferences *self,
- GParamSpec *inSpec,
- gpointer inUserData)
-{
- NoJSPreferencesPrivate *priv=self->priv;
- NoJS *manager=NOJS(inUserData);
- gchar *databaseFile;
-
- /* Close connection to any open database */
- if(priv->database) sqlite3_close(priv->database);
- priv->database=NULL;
-
- /* Get pointer to new database and open database */
- g_object_get(manager, "database-filename", &databaseFile, NULL);
- if(databaseFile)
- {
- gint success;
-
- success=sqlite3_open(databaseFile, &priv->database);
- if(success!=SQLITE_OK)
- {
- g_warning(_("Could not open database of extension: %s"), sqlite3_errmsg(priv->database));
-
- if(priv->database) sqlite3_close(priv->database);
- priv->database=NULL;
- }
-
- g_free(databaseFile);
- }
-
- /* Fill list with new database */
- _nojs_preferences_fill(self);
-
- /* Set up availability of management buttons */
- gtk_widget_set_sensitive(priv->deleteAllButton, priv->database!=NULL);
- gtk_widget_set_sensitive(priv->list, priv->database!=NULL);
-
- return;
-}
-
-/* Allow-local-pages changed in check-box or manager */
-static void _nojs_preferences_on_allow_local_pages_changed(NoJSPreferences *self,
- gpointer *inUserData)
-{
- NoJSPreferencesPrivate *priv=self->priv;
- gboolean state;
-
- /* Get toggle state of widget (but block signal for manager) and set in manager */
- g_signal_handler_block(priv->manager, priv->signalManagerChangedAllowLocalPagesID);
-
- state=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->allowLocalPagesCheckbox));
- nojs_set_allow_local_pages(priv->manager, state);
-
- g_signal_handler_unblock(priv->manager, priv->signalManagerChangedAllowLocalPagesID);
-}
-
-static void _nojs_preferences_on_manager_allow_local_pages_changed(NoJSPreferences *self,
- GParamSpec *inSpec,
- gpointer inUserData)
-{
- NoJSPreferencesPrivate *priv=self->priv;
- NoJS *manager=NOJS(inUserData);
- gboolean state;
-
- /* Get new value from manager */
- state=nojs_get_allow_local_pages(manager);
-
- /* Set toggle in widget (but block signal for toggle) */
- g_signal_handler_block(priv->allowLocalPagesCheckbox, priv->signalAllowLocalPagesToggledID);
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->allowLocalPagesCheckbox), state);
-
- g_signal_handler_unblock(priv->allowLocalPagesCheckbox, priv->signalAllowLocalPagesToggledID);
-}
-
-/* Block-unknown-domains changed in check-box or manager */
-static void _nojs_preferences_on_block_unknown_domains_changed(NoJSPreferences *self,
- gpointer *inUserData)
-{
- NoJSPreferencesPrivate *priv=self->priv;
- gboolean state;
- NoJSPolicy policy;
-
- /* Get toggle state of widget (but block signal for manager) and set in manager */
- g_signal_handler_block(priv->manager, priv->signalManagerChangedUnknownDomainPolicyID);
-
- state=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->blockUnknownDomainsCheckbox));
- policy=(state ? NOJS_POLICY_BLOCK : NOJS_POLICY_ACCEPT);
- nojs_set_policy_for_unknown_domain(priv->manager, policy);
-
- g_signal_handler_unblock(priv->manager, priv->signalManagerChangedUnknownDomainPolicyID);
-}
-
-static void _nojs_preferences_on_manager_unknown_domain_policy_changed(NoJSPreferences *self,
- GParamSpec *inSpec,
- gpointer inUserData)
-{
- NoJSPreferencesPrivate *priv=self->priv;
- NoJS *manager=NOJS(inUserData);
- NoJSPolicy policy;
- gboolean state;
-
- /* Get new value from manager */
- policy=nojs_get_policy_for_unknown_domain(manager);
-
- /* Set toggle in widget (but block signal for toggle) */
- g_signal_handler_block(priv->blockUnknownDomainsCheckbox, priv->signalBlockUnknownDomainsToggledID);
-
- state=(policy==NOJS_POLICY_BLOCK ? TRUE : FALSE);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->blockUnknownDomainsCheckbox), state);
-
- g_signal_handler_unblock(priv->blockUnknownDomainsCheckbox, priv->signalBlockUnknownDomainsToggledID);
-}
-
-/* Only-second-level changed in check-box or manager */
-static void _nojs_preferences_on_check_second_level_only_changed(NoJSPreferences *self,
- gpointer *inUserData)
-{
- NoJSPreferencesPrivate *priv=self->priv;
- gboolean state;
-
- /* Get toggle state of widget (but block signal for manager) and set in manager */
- g_signal_handler_block(priv->manager, priv->signalManagerChangedCheckSecondLevelID);
-
- state=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->checkSecondLevelOnlyCheckbox));
- nojs_set_only_second_level_domain(priv->manager, state);
-
- g_signal_handler_unblock(priv->manager, priv->signalManagerChangedCheckSecondLevelID);
-}
-
-static void _nojs_preferences_on_manager_only_second_level_changed(NoJSPreferences *self,
- GParamSpec *inSpec,
- gpointer inUserData)
-{
- NoJSPreferencesPrivate *priv=self->priv;
- NoJS *manager=NOJS(inUserData);
- gboolean state;
-
- /* Get new value from manager */
- state=nojs_get_only_second_level_domain(manager);
-
- /* Set toggle in widget (but block signal for toggle) */
- g_signal_handler_block(priv->checkSecondLevelOnlyCheckbox, priv->signalCheckSecondLevelOnlyToggledID);
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkSecondLevelOnlyCheckbox), state);
-
- g_signal_handler_unblock(priv->checkSecondLevelOnlyCheckbox, priv->signalCheckSecondLevelOnlyToggledID);
-}
-
-static void _nojs_preferences_on_policy_editing_started(NoJSPreferences *self,
- GtkCellEditable *editable,
- gchar *path,
- gpointer *inUserData)
-{
- NoJSPreferencesPrivate *priv=self->priv;
-
- priv->editingCombo=NULL;
-
- if(!GTK_IS_COMBO_BOX(editable)) return;
-
- priv->editingCombo=GTK_WIDGET(editable);
-}
-
-static void _nojs_preferences_on_policy_editing_canceled(NoJSPreferences *self,
- gpointer *inUserData)
-{
- NoJSPreferencesPrivate *priv=self->priv;
-
- priv->editingCombo=NULL;
-}
-
-static void _nojs_preferences_on_policy_edited(NoJSPreferences *self,
- gchar *path,
- gchar *newText,
- gpointer *inUserData)
-{
- NoJSPreferencesPrivate *priv=self->priv;
- gchar *domain;
- GtkTreeIter iter;
- GtkTreeIter policyIter;
-
- g_return_if_fail(priv->database);
-
- if (priv->editingCombo == NULL) return;
-
- gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(priv->listStore), &iter, path);
-
- gtk_tree_model_get(GTK_TREE_MODEL(priv->listStore),
- &iter,
- DOMAIN_COLUMN, &domain,
- -1);
-
- /* Get policy from combo box */
- if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(priv->editingCombo), &policyIter))
- {
- gchar *sql;
- gchar *error=NULL;
- gint success;
- gint policy;
- gchar *policyName;
-
- /* Get policy value to set for domain */
- gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(priv->editingCombo)),
- &policyIter,
- 0, &policy,
- 1, &policyName,
- -1);
-
- g_return_if_fail(g_strcmp0(policyName, newText)==0);
-
- /* Add domain name and the selected policy to database */
- sql=sqlite3_mprintf("UPDATE policies SET value = %d WHERE site = '%q';",
- policy,
- domain);
- success=sqlite3_exec(priv->database, sql, NULL, NULL, &error);
-
- /* Show error message if any */
- if(success==SQLITE_OK)
- {
- gtk_list_store_set(priv->listStore,
- &iter,
- POLICY_COLUMN, newText,
- -1);
- }
- else g_warning(_("SQL fails: %s"), error);
-
-
- if(error) sqlite3_free(error);
-
- /* Free allocated resources */
- sqlite3_free(sql);
- }
-
- priv->editingCombo=NULL;
-}
-
-/* Selection in list changed */
-void _nojs_preferences_changed_selection(NoJSPreferences *self,
- GtkTreeSelection *inSelection)
-{
- gboolean selected=(gtk_tree_selection_count_selected_rows(inSelection)>0 ? TRUE: FALSE);
-
- gtk_widget_set_sensitive(self->priv->deleteButton, selected);
-}
-
-/* Delete button was clicked on selection */
-void _nojs_preferences_on_delete_selection(NoJSPreferences *self,
- GtkButton *inButton)
-{
- NoJSPreferencesPrivate *priv=self->priv;
- GList *rows, *row, *refs=NULL;
- GtkTreeRowReference *ref;
- GtkTreeModel *model=GTK_TREE_MODEL(priv->listStore);
- GtkTreeIter iter;
- GtkTreePath *path;
- gchar *domain;
- gchar *sql;
- gint success;
- gchar *error;
-
- /* Get selected rows in list and create a row reference because
- * we will modify the model while iterating through selected rows
- */
- rows=gtk_tree_selection_get_selected_rows(priv->listSelection, &model);
- for(row=rows; row; row=row->next)
- {
- ref=gtk_tree_row_reference_new(model, (GtkTreePath*)row->data);
- refs=g_list_prepend(refs, ref);
- }
- g_list_foreach(rows,(GFunc)gtk_tree_path_free, NULL);
- g_list_free(rows);
-
- /* Delete each selected row by its reference */
- for(row=refs; row; row=row->next)
- {
- /* Get domain from selected row */
- path=gtk_tree_row_reference_get_path((GtkTreeRowReference*)row->data);
- gtk_tree_model_get_iter(model, &iter, path);
- gtk_tree_model_get(model, &iter, DOMAIN_COLUMN, &domain, -1);
-
- /* Delete domain from database */
- sql=sqlite3_mprintf("DELETE FROM policies WHERE site='%q';", domain);
- success=sqlite3_exec(priv->database,
- sql,
- NULL,
- NULL,
- &error);
- if(success!=SQLITE_OK || error)
- {
- if(error)
- {
- g_critical(_("Failed to execute database statement: %s"), error);
- sqlite3_free(error);
- }
- else g_critical(_("Failed to execute database statement: %s"), sqlite3_errmsg(priv->database));
- }
- sqlite3_free(sql);
-
- /* Delete row from model */
- gtk_list_store_remove(priv->listStore, &iter);
- }
- g_list_foreach(refs,(GFunc)gtk_tree_row_reference_free, NULL);
- g_list_free(refs);
-}
-
-/* Delete all button was clicked */
-void _nojs_preferences_on_delete_all(NoJSPreferences *self,
- GtkButton *inButton)
-{
- NoJSPreferencesPrivate *priv=self->priv;
- gint success;
- gchar *error=NULL;
- GtkWidget *dialog;
- gint dialogResponse;
-
- /* Ask user if he really wants to delete all permissions */
- dialog=gtk_message_dialog_new(GTK_WINDOW(self),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_YES_NO,
- _("Do you really want to delete all JavaScript permissions?"));
-
- gtk_window_set_title(GTK_WINDOW(dialog), _("Delete all JavaScript permissions?"));
- gtk_window_set_icon_name(GTK_WINDOW(dialog), GTK_STOCK_PROPERTIES);
-
- gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
- _("This action will delete all JavaScript permissions. "
- "You will be asked for permissions again for each web site visited."));
-
- dialogResponse=gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
-
- if(dialogResponse==GTK_RESPONSE_NO) return;
-
- /* Delete all permission */
- success=sqlite3_exec(priv->database,
- "DELETE FROM policies;",
- NULL,
- NULL,
- &error);
-
- if(success!=SQLITE_OK || error)
- {
- if(error)
- {
- g_critical(_("Failed to execute database statement: %s"), error);
- sqlite3_free(error);
- }
- }
-
- /* Re-setup list */
- _nojs_preferences_fill(self);
-}
-
-/* Sorting callbacks */
-static gint _nojs_preferences_sort_string_callback(GtkTreeModel *inModel,
- GtkTreeIter *inLeft,
- GtkTreeIter *inRight,
- gpointer inUserData)
-{
- gchar *left, *right;
- gint column=GPOINTER_TO_INT(inUserData);
- gint result;
-
- gtk_tree_model_get(inModel, inLeft, column, &left, -1);
- gtk_tree_model_get(inModel, inRight, column, &right, -1);
-
- result=g_strcmp0(left, right);
-
- g_free(left);
- g_free(right);
-
- return(result);
-}
-
-/* IMPLEMENTATION: GObject */
-
-/* Finalize this object */
-static void nojs_preferences_finalize(GObject *inObject)
-{
- NoJSPreferencesPrivate *priv=NOJS_PREFERENCES(inObject)->priv;
-
- /* Dispose allocated resources */
- if(priv->database) sqlite3_close(priv->database);
- priv->database=NULL;
-
- if(priv->manager)
- {
- if(priv->signalManagerChangedDatabaseID) g_signal_handler_disconnect(priv->manager, priv->signalManagerChangedDatabaseID);
- priv->signalManagerChangedDatabaseID=0;
-
- if(priv->signalManagerChangedAllowLocalPagesID) g_signal_handler_disconnect(priv->manager, priv->signalManagerChangedAllowLocalPagesID);
- priv->signalManagerChangedAllowLocalPagesID=0;
-
- if(priv->signalManagerChangedUnknownDomainPolicyID) g_signal_handler_disconnect(priv->manager, priv->signalManagerChangedUnknownDomainPolicyID);
- priv->signalManagerChangedUnknownDomainPolicyID=0;
-
- if(priv->signalManagerChangedCheckSecondLevelID) g_signal_handler_disconnect(priv->manager, priv->signalManagerChangedCheckSecondLevelID);
- priv->signalManagerChangedCheckSecondLevelID=0;
-
- g_object_unref(priv->manager);
- priv->manager=NULL;
- }
-
- /* Call parent's class finalize method */
- G_OBJECT_CLASS(nojs_preferences_parent_class)->finalize(inObject);
-}
-
-/* Set/get properties */
-static void nojs_preferences_set_property(GObject *inObject,
- guint inPropID,
- const GValue *inValue,
- GParamSpec *inSpec)
-{
- NoJSPreferences *self=NOJS_PREFERENCES(inObject);
- NoJSPreferencesPrivate *priv=self->priv;
- GObject *manager;
-
- switch(inPropID)
- {
- /* Construct-only properties */
- case PROP_MANAGER:
- /* Release old manager if available and disconnect signals */
- if(priv->manager)
- {
- if(priv->signalManagerChangedDatabaseID) g_signal_handler_disconnect(priv->manager, priv->signalManagerChangedDatabaseID);
- priv->signalManagerChangedDatabaseID=0;
-
- if(priv->signalManagerChangedAllowLocalPagesID) g_signal_handler_disconnect(priv->manager, priv->signalManagerChangedAllowLocalPagesID);
- priv->signalManagerChangedAllowLocalPagesID=0;
-
- if(priv->signalManagerChangedUnknownDomainPolicyID) g_signal_handler_disconnect(priv->manager, priv->signalManagerChangedUnknownDomainPolicyID);
- priv->signalManagerChangedUnknownDomainPolicyID=0;
-
- if(priv->signalManagerChangedCheckSecondLevelID) g_signal_handler_disconnect(priv->manager, priv->signalManagerChangedCheckSecondLevelID);
- priv->signalManagerChangedCheckSecondLevelID=0;
-
- g_object_unref(priv->manager);
- priv->manager=NULL;
- }
-
- /* Set new JavaScript permission manager and
- * listen to changes in database property
- */
- manager=g_value_get_object(inValue);
- if(manager)
- {
- priv->manager=g_object_ref(manager);
-
- priv->signalManagerChangedDatabaseID=
- g_signal_connect_swapped(priv->manager,
- "notify::database-filename",
- G_CALLBACK(_nojs_preferences_on_manager_database_changed),
- self);
- _nojs_preferences_on_manager_database_changed(self, NULL, priv->manager);
-
- priv->signalManagerChangedAllowLocalPagesID=
- g_signal_connect_swapped(priv->manager,
- "notify::allow-local-pages",
- G_CALLBACK(_nojs_preferences_on_manager_allow_local_pages_changed),
- self);
- _nojs_preferences_on_manager_allow_local_pages_changed(self, NULL, priv->manager);
-
- priv->signalManagerChangedUnknownDomainPolicyID=
- g_signal_connect_swapped(priv->manager,
- "notify::unknown-domain-policy",
- G_CALLBACK(_nojs_preferences_on_manager_unknown_domain_policy_changed),
- self);
- _nojs_preferences_on_manager_unknown_domain_policy_changed(self, NULL, priv->manager);
-
- priv->signalManagerChangedCheckSecondLevelID=
- g_signal_connect_swapped(priv->manager,
- "notify::only-second-level",
- G_CALLBACK(_nojs_preferences_on_manager_only_second_level_changed),
- self);
- _nojs_preferences_on_manager_only_second_level_changed(self, NULL, priv->manager);
- }
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
- break;
- }
-}
-
-static void nojs_preferences_get_property(GObject *inObject,
- guint inPropID,
- GValue *outValue,
- GParamSpec *inSpec)
-{
- NoJSPreferences *self=NOJS_PREFERENCES(inObject);
-
- switch(inPropID)
- {
- case PROP_MANAGER:
- g_value_set_object(outValue, self->priv->manager);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
- break;
- }
-}
-
-/* Class initialization
- * Override functions in parent classes and define properties and signals
- */
-static void nojs_preferences_class_init(NoJSPreferencesClass *klass)
-{
- GObjectClass *gobjectClass=G_OBJECT_CLASS(klass);
-
- /* Override functions */
- gobjectClass->finalize=nojs_preferences_finalize;
- gobjectClass->set_property=nojs_preferences_set_property;
- gobjectClass->get_property=nojs_preferences_get_property;
-
- /* Set up private structure */
- g_type_class_add_private(klass, sizeof(NoJSPreferencesPrivate));
-
- /* Define properties */
- NoJSPreferencesProperties[PROP_MANAGER]=
- g_param_spec_object("manager",
- _("Manager instance"),
- _("Instance to global NoJS manager"),
- TYPE_NOJS,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
- g_object_class_install_properties(gobjectClass, PROP_LAST, NoJSPreferencesProperties);
-}
-
-/* Object initialization
- * Create private structure and set up default values
- */
-static void nojs_preferences_init(NoJSPreferences *self)
-{
- NoJSPreferencesPrivate *priv;
- GtkTreeSortable *sortableList;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkWidget *widget;
- gchar *dialogTitle;
- GtkWidget *scrolled;
- GtkWidget *vbox;
- GtkWidget *hbox;
- gint width, height;
- GtkListStore *list;
- GtkTreeIter listIter;
-
- priv=self->priv=NOJS_PREFERENCES_GET_PRIVATE(self);
-
- /* Set up default values */
- priv->manager=NULL;
-
- /* Get content area to add gui controls to */
- priv->contentArea=gtk_dialog_get_content_area(GTK_DIALOG(self));
-#if GTK_CHECK_VERSION (3, 0, 0)
- vbox=gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE);
-#else
- vbox=gtk_vbox_new(FALSE, 0);
-#endif
-
- /* Set up dialog */
- dialogTitle=_("Configure NoJS");
-
- gtk_window_set_title(GTK_WINDOW(self), dialogTitle);
- gtk_window_set_icon_name(GTK_WINDOW(self), GTK_STOCK_PROPERTIES);
-
- sokoke_widget_get_text_size(GTK_WIDGET(self), "M", &width, &height);
- gtk_window_set_default_size(GTK_WINDOW(self), width*52, -1);
-
- widget=sokoke_xfce_header_new(gtk_window_get_icon_name(GTK_WINDOW(self)), dialogTitle);
- if(widget) gtk_box_pack_start(GTK_BOX(priv->contentArea), widget, FALSE, FALSE, 0);
-
- gtk_dialog_add_button(GTK_DIALOG(self), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
-
- /* Set up description */
- widget=gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(widget),
- _("Below is a list of all web sites and the policy set for them. "
- "You can delete policies by marking the entries and clicking on <i>Delete</i>."));
- gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
- gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 4);
-
- /* Set up domain list */
- priv->listStore=gtk_list_store_new(N_COLUMN,
- G_TYPE_STRING, /* DOMAIN_COLUMN */
- G_TYPE_STRING /* POLICY_COLUMN */);
-
- sortableList=GTK_TREE_SORTABLE(priv->listStore);
- gtk_tree_sortable_set_sort_func(sortableList,
- DOMAIN_COLUMN,
- (GtkTreeIterCompareFunc)_nojs_preferences_sort_string_callback,
- GINT_TO_POINTER(DOMAIN_COLUMN),
- NULL);
- gtk_tree_sortable_set_sort_func(sortableList,
- POLICY_COLUMN,
- (GtkTreeIterCompareFunc)_nojs_preferences_sort_string_callback,
- GINT_TO_POINTER(POLICY_COLUMN),
- NULL);
- gtk_tree_sortable_set_sort_column_id(sortableList, DOMAIN_COLUMN, GTK_SORT_ASCENDING);
-
- /* Set up domain addition widgets */
-#ifdef HAVE_GTK3
- hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE);
-#else
- hbox=gtk_hbox_new(FALSE, 0);
-#endif
-
- priv->addDomainEntry=gtk_entry_new();
- gtk_entry_set_max_length(GTK_ENTRY(priv->addDomainEntry), 64);
- gtk_container_add(GTK_CONTAINER(hbox), priv->addDomainEntry);
- g_signal_connect_swapped(priv->addDomainEntry, "changed", G_CALLBACK(_nojs_preferences_on_add_domain_entry_changed), self);
-
- list=gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING);
- gtk_list_store_append(list, &listIter);
- gtk_list_store_set(list, &listIter, 0, NOJS_POLICY_ACCEPT, 1, _("Accept"), -1);
- gtk_list_store_append(list, &listIter);
- gtk_list_store_set(list, &listIter, 0, NOJS_POLICY_ACCEPT_TEMPORARILY, 1, _("Accept for session"), -1);
- gtk_list_store_append(list, &listIter);
- gtk_list_store_set(list, &listIter, 0, NOJS_POLICY_BLOCK, 1, _("Block"), -1);
-
- priv->addDomainPolicyCombo=gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
- gtk_combo_box_set_active(GTK_COMBO_BOX(priv->addDomainPolicyCombo), 0);
- gtk_container_add(GTK_CONTAINER(hbox), priv->addDomainPolicyCombo);
-
- renderer=gtk_cell_renderer_text_new();
- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(priv->addDomainPolicyCombo), renderer, TRUE);
- gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(priv->addDomainPolicyCombo), renderer, "text", 1);
-
- priv->addDomainButton=gtk_button_new_from_stock(GTK_STOCK_ADD);
- gtk_widget_set_sensitive(priv->addDomainButton, FALSE);
- gtk_container_add(GTK_CONTAINER(hbox), priv->addDomainButton);
- g_signal_connect_swapped(priv->addDomainButton, "clicked", G_CALLBACK(_nojs_preferences_on_add_domain_clicked), self);
-
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 5);
-
- /* Set up domain list view */
- priv->list=gtk_tree_view_new_with_model(GTK_TREE_MODEL(priv->listStore));
-
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gtk_widget_set_size_request(priv->list, -1, 300);
-#endif
-
- priv->listSelection=gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->list));
- gtk_tree_selection_set_mode(priv->listSelection, GTK_SELECTION_MULTIPLE);
- g_signal_connect_swapped(priv->listSelection, "changed", G_CALLBACK(_nojs_preferences_changed_selection), self);
-
- renderer=gtk_cell_renderer_text_new();
- column=gtk_tree_view_column_new_with_attributes(_("Domain"),
- renderer,
- "text", DOMAIN_COLUMN,
- NULL);
- gtk_tree_view_column_set_sort_column_id(column, DOMAIN_COLUMN);
- gtk_tree_view_append_column(GTK_TREE_VIEW(priv->list), column);
-
- renderer=gtk_cell_renderer_combo_new();
- g_object_set(G_OBJECT(renderer), "model", list, "text-column", 1, "has-entry", false, "editable", true, NULL);
- g_signal_connect_swapped(renderer, "editing-started", G_CALLBACK(_nojs_preferences_on_policy_editing_started), self);
- g_signal_connect_swapped(renderer, "editing-canceled", G_CALLBACK(_nojs_preferences_on_policy_editing_canceled), self);
- g_signal_connect_swapped(renderer, "edited", G_CALLBACK(_nojs_preferences_on_policy_edited), self);
- column=gtk_tree_view_column_new_with_attributes(_("Policy"),
- renderer,
- "text", POLICY_COLUMN,
- NULL);
- gtk_tree_view_column_set_sort_column_id(column, POLICY_COLUMN);
- gtk_tree_view_append_column(GTK_TREE_VIEW(priv->list), column);
-
- scrolled=gtk_scrolled_window_new(NULL, NULL);
-#if GTK_CHECK_VERSION (3, 0, 0)
- gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(scrolled), height*10);
-#endif
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_container_add(GTK_CONTAINER(scrolled), priv->list);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
- gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 5);
-
- /* Set up JavaScript domain list management buttons */
-#if GTK_CHECK_VERSION (3, 0, 0)
- hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE);
-#else
- hbox=gtk_hbox_new(FALSE, 0);
-#endif
-
- priv->deleteButton=gtk_button_new_from_stock(GTK_STOCK_DELETE);
- gtk_widget_set_sensitive(priv->deleteButton, FALSE);
- gtk_container_add(GTK_CONTAINER(hbox), priv->deleteButton);
- g_signal_connect_swapped(priv->deleteButton, "clicked", G_CALLBACK(_nojs_preferences_on_delete_selection), self);
-
- priv->deleteAllButton=gtk_button_new_with_mnemonic(_("Delete _all"));
- gtk_button_set_image(GTK_BUTTON(priv->deleteAllButton), gtk_image_new_from_stock(GTK_STOCK_DELETE, GTK_ICON_SIZE_BUTTON));
- gtk_widget_set_sensitive(priv->deleteAllButton, FALSE);
- gtk_container_add(GTK_CONTAINER(hbox), priv->deleteAllButton);
- g_signal_connect_swapped(priv->deleteAllButton, "clicked", G_CALLBACK(_nojs_preferences_on_delete_all), self);
-
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 5);
-
- /* Add "allow-local-pages" checkbox */
- priv->allowLocalPagesCheckbox=gtk_check_button_new_with_mnemonic(_("A_llow scripts on local pages"));
- priv->signalAllowLocalPagesToggledID=g_signal_connect_swapped(priv->allowLocalPagesCheckbox,
- "toggled",
- G_CALLBACK(_nojs_preferences_on_allow_local_pages_changed),
- self);
- gtk_box_pack_start(GTK_BOX(vbox), priv->allowLocalPagesCheckbox, FALSE, TRUE, 5);
-
- /* Add "block-unknown-domains" checkbox */
- priv->blockUnknownDomainsCheckbox=gtk_check_button_new_with_mnemonic(_("Bloc_k scripts at unknown domains by default"));
- priv->signalBlockUnknownDomainsToggledID=g_signal_connect_swapped(priv->blockUnknownDomainsCheckbox,
- "toggled",
- G_CALLBACK(_nojs_preferences_on_block_unknown_domains_changed),
- self);
- gtk_box_pack_start(GTK_BOX(vbox), priv->blockUnknownDomainsCheckbox, FALSE, TRUE, 5);
-
- /* Add "check-second-level-only" checkbox */
- priv->checkSecondLevelOnlyCheckbox=gtk_check_button_new_with_mnemonic(_("S_et permissions on second-level domain"));
- priv->signalCheckSecondLevelOnlyToggledID=g_signal_connect_swapped(priv->checkSecondLevelOnlyCheckbox,
- "toggled",
- G_CALLBACK(_nojs_preferences_on_check_second_level_only_changed),
- self);
- gtk_box_pack_start(GTK_BOX(vbox), priv->checkSecondLevelOnlyCheckbox, FALSE, TRUE, 5);
-
- /* Finalize setup of content area */
- gtk_box_pack_start(GTK_BOX(priv->contentArea), vbox, TRUE, TRUE, 0);
-}
-
-/* Implementation: Public API */
-
-/* Create new object */
-GtkWidget* nojs_preferences_new(NoJS *inManager)
-{
- return(g_object_new(TYPE_NOJS_PREFERENCES,
- "manager", inManager,
- NULL));
-}
diff --git a/extensions/nojs/nojs-preferences.h b/extensions/nojs/nojs-preferences.h
deleted file mode 100644
index 27336584..00000000
--- a/extensions/nojs/nojs-preferences.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- Copyright (C) 2013 Stephan Haller <nomad@froevel.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 __NOJS_PREFERENCES__
-#define __NOJS_PREFERENCES__
-
-#include "config.h"
-#include <midori/midori.h>
-
-#include "nojs.h"
-
-G_BEGIN_DECLS
-
-#define TYPE_NOJS_PREFERENCES (nojs_preferences_get_type())
-#define NOJS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_NOJS_PREFERENCES, NoJSPreferences))
-#define IS_NOJS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_NOJS_PREFERENCES))
-#define NOJS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_NOJS_PREFERENCES, NoJSPreferencesClass))
-#define IS_NOJS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_NOJS_PREFERENCES))
-#define NOJS_PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_NOJS_PREFERENCES, NoJSPreferencesClass))
-
-typedef struct _NoJSPreferences NoJSPreferences;
-typedef struct _NoJSPreferencesClass NoJSPreferencesClass;
-typedef struct _NoJSPreferencesPrivate NoJSPreferencesPrivate;
-
-struct _NoJSPreferences
-{
- /* Parent instance */
- GtkDialog parent_instance;
-
- /* Private structure */
- NoJSPreferencesPrivate *priv;
-};
-
-struct _NoJSPreferencesClass
-{
- /* Parent class */
- GtkDialogClass parent_class;
-};
-
-/* Public API */
-GType nojs_preferences_get_type(void);
-
-GtkWidget* nojs_preferences_new(NoJS *inManager);
-
-G_END_DECLS
-
-#endif /* __NOJS_PREFERENCES__ */
diff --git a/extensions/nojs/nojs-view.c b/extensions/nojs/nojs-view.c
deleted file mode 100644
index 0086481d..00000000
--- a/extensions/nojs/nojs-view.c
+++ /dev/null
@@ -1,807 +0,0 @@
-/*
- Copyright (C) 2013 Stephan Haller <nomad@froevel.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.
-*/
-
-#include "nojs-view.h"
-#include "nojs-preferences.h"
-
-/* Define this class in GObject system */
-G_DEFINE_TYPE(NoJSView,
- nojs_view,
- G_TYPE_OBJECT)
-
-/* Properties */
-enum
-{
- PROP_0,
-
- PROP_MANAGER,
- PROP_BROWSER,
- PROP_VIEW,
- PROP_MENU_ICON_STATE,
-
- PROP_LAST
-};
-
-static GParamSpec* NoJSViewProperties[PROP_LAST]={ 0, };
-
-/* Private structure - access only by public API if needed */
-#define NOJS_VIEW_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), TYPE_NOJS_VIEW, NoJSViewPrivate))
-
-struct _NoJSViewPrivate
-{
- /* Extension related */
- NoJS *manager;
- MidoriBrowser *browser;
- MidoriView *view;
-
- GtkWidget *menu;
- gboolean menuPolicyWasChanged;
- NoJSMenuIconState menuIconState;
-
- GSList *resourceURIs;
-};
-
-/* IMPLEMENTATION: Private variables and methods */
-
-/* Preferences of this extension should be opened */
-static void _nojs_view_on_preferences_response(GtkWidget* inDialog,
- gint inResponse,
- gpointer *inUserData)
-{
- gtk_widget_destroy(inDialog);
-}
-
-static void _nojs_view_on_open_preferences(NoJSView *self, gpointer inUserData)
-{
- g_return_if_fail(NOJS_IS_VIEW(self));
-
- NoJSViewPrivate *priv=self->priv;
-
- /* Show preferences window */
- GtkWidget* dialog;
-
- dialog=nojs_preferences_new(priv->manager);
- gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
- g_signal_connect(dialog, "response", G_CALLBACK (_nojs_view_on_preferences_response), self);
- gtk_widget_show_all(dialog);
-}
-
-/* Selection was done in menu */
-static void _nojs_view_on_menu_selection_done(NoJSView *self, gpointer inUserData)
-{
- g_return_if_fail(NOJS_IS_VIEW(self));
-
- NoJSViewPrivate *priv=self->priv;
-
- /* Check if any policy was changed and reload page */
- if(priv->menuPolicyWasChanged!=FALSE)
- {
- /* Reset flag that any policy was changed */
- priv->menuPolicyWasChanged=FALSE;
-
- /* Reload page */
- midori_view_reload(priv->view, FALSE);
-g_message("%s: Reloading page %s as policy has changed", __func__, midori_view_get_display_uri(priv->view));
- }
-}
-
-/* Destroy menu */
-static void _nojs_view_destroy_menu(NoJSView *self)
-{
- g_return_if_fail(NOJS_IS_VIEW(self));
- g_return_if_fail(self->priv->menu!=NULL);
-
- NoJSViewPrivate *priv=self->priv;
-
- /* Empty menu and list of domains added to menu */
- gtk_widget_destroy(priv->menu);
- priv->menu=NULL;
-
- /* Reset menu icon to default state */
- priv->menuIconState=NOJS_MENU_ICON_STATE_UNDETERMINED;
- g_object_notify_by_pspec(G_OBJECT(self), NoJSViewProperties[PROP_MENU_ICON_STATE]);
-}
-
-/* Create empty menu */
-static void _nojs_view_create_empty_menu(NoJSView *self)
-{
- g_return_if_fail(NOJS_IS_VIEW(self));
- g_return_if_fail(self->priv->menu==NULL);
-
- NoJSViewPrivate *priv=self->priv;
- GtkWidget *item;
-
- /* Create new menu and set up default items */
- priv->menu=gtk_menu_new();
-
- item=gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES, NULL);
- g_signal_connect_swapped(item, "activate", G_CALLBACK(_nojs_view_on_open_preferences), self);
- gtk_menu_shell_prepend(GTK_MENU_SHELL(priv->menu), item);
- gtk_widget_show_all(item);
-
- /* Reset flag that any policy was changed */
- priv->menuPolicyWasChanged=FALSE;
-
- /* Reset menu icon to default state */
- priv->menuIconState=NOJS_MENU_ICON_STATE_UNDETERMINED;
- g_object_notify_by_pspec(G_OBJECT(self), NoJSViewProperties[PROP_MENU_ICON_STATE]);
-
- /* Connect signal to menu */
- g_signal_connect_swapped(priv->menu, "selection-done", G_CALLBACK(_nojs_view_on_menu_selection_done), self);
-}
-
-/* Change visibility state of menu item for a domain depending on policy */
-static gboolean _nojs_view_menu_item_change_policy(NoJSView *self, const gchar *inDomain, NoJSPolicy inPolicy)
-{
- g_return_val_if_fail(NOJS_IS_VIEW(self), FALSE);
- g_return_val_if_fail(inDomain, FALSE);
-
- NoJSViewPrivate *priv=self->priv;
- GList *items, *iter;
- gboolean updated;
-
- /* Handle accept-for-session like accept when showing or hiding menu items */
- if(inPolicy==NOJS_POLICY_ACCEPT_TEMPORARILY) inPolicy=NOJS_POLICY_ACCEPT;
-
- /* Update menu items */
- updated=FALSE;
- items=gtk_container_get_children(GTK_CONTAINER(priv->menu));
- for(iter=items; iter; iter=iter->next)
- {
- /* Only check and update menu items (not separators and so on) */
- if(GTK_IS_MENU_ITEM(iter->data))
- {
- GtkMenuItem *item=GTK_MENU_ITEM(iter->data);
- const gchar *itemDomain;
- NoJSPolicy itemPolicy;
-
- itemDomain=(const gchar*)g_object_get_data(G_OBJECT(item), "domain");
- itemPolicy=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), "policy"));
-
- /* Handle accept-for-session like accept when showing or hiding menu items */
- if(itemPolicy==NOJS_POLICY_ACCEPT_TEMPORARILY) itemPolicy=NOJS_POLICY_ACCEPT;
-
- /* If menu item has "domain"-data update its visibility state
- * depending on matching policy
- */
- if(g_strcmp0(itemDomain, inDomain)==0)
- {
- if(itemPolicy==inPolicy) gtk_widget_hide(GTK_WIDGET(item));
- else gtk_widget_show_all(GTK_WIDGET(item));
-
- /* Set flag that at least one menu item was updated */
- updated=TRUE;
- }
- }
- }
- g_list_free(items);
-
- /* Return flag indicating if at least one menu item was updated */
- return(updated);
-}
-
-/* A menu item was selected */
-static void _nojs_view_on_menu_item_activate(NoJSView *self, gpointer inUserData)
-{
- g_return_if_fail(NOJS_IS_VIEW(self));
- g_return_if_fail(GTK_IS_MENU_ITEM(inUserData));
-
- NoJSViewPrivate *priv=self->priv;
- GtkMenuItem *item=GTK_MENU_ITEM(inUserData);
- const gchar *domain;
- NoJSPolicy policy;
-
- /* Get domain and policy to set */
- domain=(const gchar*)g_object_get_data(G_OBJECT(item), "domain");
- policy=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), "policy"));
- g_return_if_fail(domain);
- g_return_if_fail(policy>=NOJS_POLICY_ACCEPT && policy<=NOJS_POLICY_BLOCK);
-
- /* Set policy for domain and update menu items */
- _nojs_view_menu_item_change_policy(self, domain, policy);
- nojs_set_policy(priv->manager, domain, policy);
-
- /* Set flag that a policy was changed */
- priv->menuPolicyWasChanged=TRUE;
-}
-
-/* Add site to menu */
-static void _nojs_view_add_site_to_menu(NoJSView *self, const gchar *inDomain, NoJSPolicy inPolicy)
-{
- g_return_if_fail(NOJS_IS_VIEW(self));
- g_return_if_fail(inDomain);
-
- NoJSViewPrivate *priv=self->priv;
- GtkWidget *item;
- gchar *itemLabel;
- GtkWidget *itemImage;
- static gint INSERT_POSITION=1;
- NoJSMenuIconState newMenuIconState;
-
- /* Create menu object if not available */
- if(!priv->menu) _nojs_view_create_empty_menu(self);
-
- /* Check if domain was already added to menu. If it exists just update it. */
- if(_nojs_view_menu_item_change_policy(self, inDomain, inPolicy)==TRUE) return;
-
- /* Add menu item(s) for domain */
- itemLabel=g_strdup_printf(_("Deny %s"), inDomain);
- item=gtk_image_menu_item_new_with_label(itemLabel);
- itemImage=gtk_image_new_from_stock (GTK_STOCK_NO, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), itemImage);
- gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
- gtk_menu_shell_insert(GTK_MENU_SHELL(priv->menu), item, INSERT_POSITION);
- if(inPolicy!=NOJS_POLICY_BLOCK) gtk_widget_show_all(item);
- g_object_set_data_full(G_OBJECT(item), "domain", g_strdup(inDomain), (GDestroyNotify)g_free);
- g_object_set_data(G_OBJECT(item), "policy", GINT_TO_POINTER(NOJS_POLICY_BLOCK));
- g_signal_connect_swapped(item, "activate", G_CALLBACK(_nojs_view_on_menu_item_activate), self);
- g_free(itemLabel);
-
- itemLabel=g_strdup_printf(_("Allow %s"), inDomain);
- item=gtk_image_menu_item_new_with_label(itemLabel);
- itemImage=gtk_image_new_from_stock (GTK_STOCK_YES, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), itemImage);
- gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
- gtk_menu_shell_insert(GTK_MENU_SHELL(priv->menu), item, INSERT_POSITION);
- if(inPolicy!=NOJS_POLICY_ACCEPT && inPolicy!=NOJS_POLICY_ACCEPT_TEMPORARILY) gtk_widget_show_all(item);
- g_object_set_data_full(G_OBJECT(item), "domain", g_strdup(inDomain), (GDestroyNotify)g_free);
- g_object_set_data(G_OBJECT(item), "policy", GINT_TO_POINTER(NOJS_POLICY_ACCEPT));
- g_signal_connect_swapped(item, "activate", G_CALLBACK(_nojs_view_on_menu_item_activate), self);
- g_free(itemLabel);
-
- itemLabel=g_strdup_printf(_("Allow %s this session"), inDomain);
- item=gtk_image_menu_item_new_with_label(itemLabel);
- itemImage=gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), itemImage);
- gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
- gtk_menu_shell_insert(GTK_MENU_SHELL(priv->menu), item, INSERT_POSITION);
- if(inPolicy!=NOJS_POLICY_ACCEPT && inPolicy!=NOJS_POLICY_ACCEPT_TEMPORARILY) gtk_widget_show_all(item);
- g_object_set_data_full(G_OBJECT(item), "domain", g_strdup(inDomain), (GDestroyNotify)g_free);
- g_object_set_data(G_OBJECT(item), "policy", GINT_TO_POINTER(NOJS_POLICY_ACCEPT_TEMPORARILY));
- g_signal_connect_swapped(item, "activate", G_CALLBACK(_nojs_view_on_menu_item_activate), self);
- g_free(itemLabel);
-
- /* Add seperator to seperate actions for this domain from the other domains */
- item=gtk_separator_menu_item_new();
- gtk_menu_shell_insert(GTK_MENU_SHELL(priv->menu), item, INSERT_POSITION);
- gtk_widget_show_all(item);
-
- /* Determine state of status icon */
- if(priv->menuIconState!=NOJS_MENU_ICON_STATE_MIXED)
- {
- switch(inPolicy)
- {
- case NOJS_POLICY_ACCEPT:
- case NOJS_POLICY_ACCEPT_TEMPORARILY:
- newMenuIconState=NOJS_MENU_ICON_STATE_ALLOWED;
- break;
-
- case NOJS_POLICY_BLOCK:
- newMenuIconState=NOJS_MENU_ICON_STATE_DENIED;
- break;
-
- default:
- newMenuIconState=NOJS_MENU_ICON_STATE_MIXED;
- break;
- }
-
- if(priv->menuIconState==NOJS_MENU_ICON_STATE_UNDETERMINED ||
- priv->menuIconState!=newMenuIconState)
- {
- priv->menuIconState=newMenuIconState;
- g_object_notify_by_pspec(G_OBJECT(self), NoJSViewProperties[PROP_MENU_ICON_STATE]);
- }
- }
-}
-
-/* Status of loading a site has changed */
-static void _nojs_view_on_load_status_changed(NoJSView *self, GParamSpec *inSpec, gpointer inUserData)
-{
- g_return_if_fail(NOJS_IS_VIEW(self));
- g_return_if_fail(WEBKIT_IS_WEB_VIEW(inUserData));
-
- NoJSViewPrivate *priv=self->priv;
- WebKitWebView *webkitView=WEBKIT_WEB_VIEW(inUserData);
- WebKitWebSettings *settings=webkit_web_view_get_settings(webkitView);
- WebKitLoadStatus status;
- SoupURI *uri;
-
- /* Get URI of document loading/loaded */
- uri=soup_uri_new(webkit_web_view_get_uri(webkitView));
-
- /* Check load status */
- status=webkit_web_view_get_load_status(webkitView);
-
- /* Check if a view was emptied, e.g. for a new document going to be loaded soon */
- if(status==WEBKIT_LOAD_PROVISIONAL)
- {
- /* Create a new empty menu */
- _nojs_view_destroy_menu(self);
- _nojs_view_create_empty_menu(self);
-
- /* Free list of resource URIs, that's the list of URIs for all resources
- * of a page
- */
- if(priv->resourceURIs)
- {
- g_slist_free_full(priv->resourceURIs, (GDestroyNotify)g_free);
- priv->resourceURIs=NULL;
- }
- }
-
- /* Check if document loading is going to start. Do not check special pages. */
- if(status==WEBKIT_LOAD_COMMITTED &&
- uri &&
- uri->scheme &&
- g_strcmp0(uri->scheme, "about")!=0)
- {
- /* Check if domain is black-listed or white-listed and enable or
- * disable javascript accordingly. But if settings match already
- * the state it should get do not set it again to avoid reloads of page.
- */
- gchar *domain;
- NoJSPolicy policy;
- gboolean currentScriptsEnabled;
- gboolean newScriptsEnabled;
-
- domain=nojs_get_domain(priv->manager, uri);
- policy=nojs_get_policy(priv->manager, uri);
- if(policy==NOJS_POLICY_UNDETERMINED)
- {
- policy=nojs_get_policy_for_unknown_domain(priv->manager);
- // TODO: Show nick_name of policy (enum) to use in warning
- g_warning("Got invalid policy. Using default policy for unknown domains.");
- }
-
- newScriptsEnabled=(policy==NOJS_POLICY_BLOCK ? FALSE : TRUE);
- g_object_get(G_OBJECT(settings), "enable-scripts", &currentScriptsEnabled, NULL);
-
- if(newScriptsEnabled!=currentScriptsEnabled)
- {
- g_object_set(G_OBJECT(settings), "enable-scripts", newScriptsEnabled, NULL);
- // TODO: Set uri also to ensure this uri is going to be reloaded
- }
-
- if(domain)
- {
- _nojs_view_add_site_to_menu(self, domain, policy);
- g_free(domain);
- }
- }
-
- /* Free allocated resources */
- if(uri) soup_uri_free(uri);
-}
-
-/* A request is going to sent */
-static void _nojs_view_on_resource_request_starting(NoJSView *self,
- WebKitWebFrame *inFrame,
- WebKitWebResource *inResource,
- WebKitNetworkRequest *inRequest,
- WebKitNetworkResponse *inResponse,
- gpointer inUserData)
-{
- g_return_if_fail(NOJS_IS_VIEW(self));
-
- NoJSViewPrivate *priv=self->priv;
- SoupMessage *message;
- SoupURI *uri;
- gchar *uriText;
-
- /* Remember resource URIs requesting */
- message=(inRequest ? webkit_network_request_get_message(inRequest) : NULL);
- if(message)
- {
- uri=soup_message_get_uri(message);
- if(uri)
- {
- uriText=soup_uri_to_string(uri, FALSE);
- priv->resourceURIs=g_slist_prepend(priv->resourceURIs, uriText);
- }
- }
-
- message=(inResponse ? webkit_network_response_get_message(inResponse) : NULL);
- if(message)
- {
- uri=soup_message_get_uri(message);
- if(uri)
- {
- uriText=soup_uri_to_string(uri, FALSE);
- priv->resourceURIs=g_slist_prepend(priv->resourceURIs, uriText);
- }
- }
-}
-
-/* A policy has changed */
-static void _nojs_view_on_policy_changed(NoJSView *self, gchar *inDomain, gpointer inUserData)
-{
- g_return_if_fail(NOJS_IS_VIEW(self));
- g_return_if_fail(inDomain);
-
- NoJSViewPrivate *priv=self->priv;
- GList *items, *iter;
- gboolean reloaded;
-
- /* Check if the policy of a domain has changed this view has referenced resources to */
- reloaded=FALSE;
- items=gtk_container_get_children(GTK_CONTAINER(priv->menu));
- for(iter=items; reloaded==FALSE && iter; iter=iter->next)
- {
- if(GTK_IS_MENU_ITEM(iter->data))
- {
- const gchar *itemDomain;
-
- /* Check if domain matches menu item */
- itemDomain=(const gchar*)g_object_get_data(G_OBJECT(iter->data), "domain");
- if(g_strcmp0(itemDomain, inDomain)==0)
- {
- /* Found domain in our menu so reload page */
- midori_view_reload(priv->view, FALSE);
- reloaded=TRUE;
- }
- }
- }
- g_list_free(items);
-}
-
-/* A javascript URI is going to loaded or blocked */
-static void _nojs_view_on_uri_load_policy_status(NoJSView *self, gchar *inURI, NoJSPolicy inPolicy, gpointer inUserData)
-{
- g_return_if_fail(NOJS_IS_VIEW(self));
-
- NoJSViewPrivate *priv=self->priv;
- GSList *iter;
- gchar *checkURI;
-
- /* Check if uri (accepted or blocked) might be one of ours */
- for(iter=priv->resourceURIs; iter; iter=iter->next)
- {
- checkURI=(gchar*)iter->data;
- if(g_strcmp0(checkURI, inURI)==0)
- {
- SoupURI *uri;
- gchar *domain;
-
- uri=soup_uri_new(inURI);
- domain=nojs_get_domain(priv->manager, uri);
- if(domain)
- {
- _nojs_view_add_site_to_menu(self, domain, inPolicy);
- g_free(domain);
- }
-
- soup_uri_free(uri);
- break;
- }
- }
-}
-
-/* Property "view" has changed */
-static void _nojs_view_on_view_changed(NoJSView *self, MidoriView *inView)
-{
- NoJSViewPrivate *priv=self->priv;
- WebKitWebView *webkitView;
-
- /* Disconnect signal on old view */
- if(priv->view)
- {
- webkitView=WEBKIT_WEB_VIEW(midori_view_get_web_view(priv->view));
- g_signal_handlers_disconnect_by_data(webkitView, self);
- g_object_set_data(G_OBJECT(priv->view), "nojs-view-instance", NULL);
- g_object_unref(priv->view);
- priv->view=NULL;
- }
-
- /* Set new view if valid pointer */
- if(!inView) return;
-
- priv->view=g_object_ref(inView);
- g_object_set_data(G_OBJECT(priv->view), "nojs-view-instance", self);
-
- /* Listen to changes of load-status in view */
- webkitView=WEBKIT_WEB_VIEW(midori_view_get_web_view(priv->view));
- g_signal_connect_swapped(webkitView, "notify::load-status", G_CALLBACK(_nojs_view_on_load_status_changed), self);
- g_signal_connect_swapped(webkitView, "resource-request-starting", G_CALLBACK(_nojs_view_on_resource_request_starting), self);
-
- /* Create empty menu */
- _nojs_view_destroy_menu(self);
- _nojs_view_create_empty_menu(self);
-
- /* Release list of resource URIs */
- if(priv->resourceURIs)
- {
- g_slist_free_full(priv->resourceURIs, (GDestroyNotify)g_free);
- priv->resourceURIs=NULL;
- }
-}
-
-/* This extension is going to be deactivated */
-static void _nojs_view_on_extension_deactivated(NoJSView *self, MidoriExtension *inExtension)
-{
- g_return_if_fail(NOJS_IS_VIEW(self));
-
- /* Dispose allocated resources by unreferencing ourselve */
- g_object_unref(self);
-}
-
-/* Property "manager" has changed */
-static void _nojs_view_on_manager_changed(NoJSView *self, NoJS *inNoJS)
-{
- g_return_if_fail(NOJS_IS_VIEW(self));
- g_return_if_fail(!inNoJS || IS_NOJS(inNoJS));
-
- NoJSViewPrivate *priv=self->priv;
- MidoriExtension *extension;
-
- /* Release reference to old manager and clean up */
- if(priv->manager)
- {
- g_object_get(priv->manager, "extension", &extension, NULL);
- g_signal_handlers_disconnect_by_data(extension, self);
- g_object_unref(extension);
-
- g_signal_handlers_disconnect_by_data(priv->manager, self);
- g_object_unref(priv->manager);
- priv->manager=NULL;
- }
-
- /* Set new view if valid pointer */
- if(!inNoJS) return;
-
- priv->manager=g_object_ref(inNoJS);
-
- /* Connect signals to manager */
- g_signal_connect_swapped(priv->manager, "uri-load-policy-status", G_CALLBACK(_nojs_view_on_uri_load_policy_status), self);
- g_signal_connect_swapped(priv->manager, "policy-changed", G_CALLBACK(_nojs_view_on_policy_changed), self);
-
- /* Connect signal to get noticed when extension is going to be deactivated
- * to release all references to GObjects
- */
- g_object_get(priv->manager, "extension", &extension, NULL);
- g_signal_connect_swapped(extension, "deactivate", G_CALLBACK(_nojs_view_on_extension_deactivated), self);
- g_object_unref(extension);
-}
-
-/* IMPLEMENTATION: GObject */
-
-/* Finalize this object */
-static void nojs_view_finalize(GObject *inObject)
-{
- NoJSView *self=NOJS_VIEW(inObject);
- NoJSViewPrivate *priv=self->priv;
-
- /* Dispose allocated resources */
- if(priv->manager)
- {
- MidoriExtension *extension;
-
- g_object_get(priv->manager, "extension", &extension, NULL);
- g_signal_handlers_disconnect_by_data(extension, self);
- g_object_unref(extension);
-
- g_signal_handlers_disconnect_by_data(priv->manager, self);
- g_object_unref(priv->manager);
- priv->manager=NULL;
- }
-
- if(priv->browser)
- {
- g_object_unref(priv->browser);
- priv->browser=NULL;
- }
-
- if(priv->view)
- {
- _nojs_view_on_view_changed(self, NULL);
- }
-
- if(priv->menu)
- {
- gtk_widget_destroy(priv->menu);
- priv->menu=NULL;
- }
-
- if(priv->resourceURIs)
- {
- g_slist_free_full(priv->resourceURIs, (GDestroyNotify)g_free);
- priv->resourceURIs=NULL;
- }
-
- /* Call parent's class finalize method */
- G_OBJECT_CLASS(nojs_view_parent_class)->finalize(inObject);
-}
-
-/* Set/get properties */
-static void nojs_view_set_property(GObject *inObject,
- guint inPropID,
- const GValue *inValue,
- GParamSpec *inSpec)
-{
- NoJSView *self=NOJS_VIEW(inObject);
-
- switch(inPropID)
- {
- /* Construct-only properties */
- case PROP_MANAGER:
- _nojs_view_on_manager_changed(self, NOJS(g_value_get_object(inValue)));
- break;
-
- case PROP_BROWSER:
- if(self->priv->browser) g_object_unref(self->priv->browser);
- self->priv->browser=g_object_ref(g_value_get_object(inValue));
- break;
-
- case PROP_VIEW:
- _nojs_view_on_view_changed(self, MIDORI_VIEW(g_value_get_object(inValue)));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
- break;
- }
-}
-
-static void nojs_view_get_property(GObject *inObject,
- guint inPropID,
- GValue *outValue,
- GParamSpec *inSpec)
-{
- NoJSView *self=NOJS_VIEW(inObject);
-
- switch(inPropID)
- {
- case PROP_MANAGER:
- g_value_set_object(outValue, self->priv->manager);
- break;
-
- case PROP_BROWSER:
- g_value_set_object(outValue, self->priv->browser);
- break;
-
- case PROP_VIEW:
- g_value_set_object(outValue, self->priv->view);
- break;
-
- case PROP_MENU_ICON_STATE:
- g_value_set_enum(outValue, self->priv->menuIconState);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
- break;
- }
-}
-
-/* Class initialization
- * Override functions in parent classes and define properties and signals
- */
-static void nojs_view_class_init(NoJSViewClass *klass)
-{
- GObjectClass *gobjectClass=G_OBJECT_CLASS(klass);
-
- /* Override functions */
- gobjectClass->finalize=nojs_view_finalize;
- gobjectClass->set_property=nojs_view_set_property;
- gobjectClass->get_property=nojs_view_get_property;
-
- /* Set up private structure */
- g_type_class_add_private(klass, sizeof(NoJSViewPrivate));
-
- /* Define properties */
- NoJSViewProperties[PROP_MANAGER]=
- g_param_spec_object("manager",
- _("Manager instance"),
- _("Instance to global NoJS manager"),
- TYPE_NOJS,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
- NoJSViewProperties[PROP_BROWSER]=
- g_param_spec_object("browser",
- _("Browser window"),
- _("The Midori browser instance this view belongs to"),
- MIDORI_TYPE_BROWSER,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
- NoJSViewProperties[PROP_VIEW]=
- g_param_spec_object("view",
- _("View"),
- _("The Midori view instance this view belongs to"),
- MIDORI_TYPE_VIEW,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
- NoJSViewProperties[PROP_MENU_ICON_STATE]=
- g_param_spec_enum("menu-icon-state",
- _("Menu icon state"),
- _("State of menu icon to show in status bar"),
- NOJS_TYPE_MENU_ICON_STATE,
- NOJS_MENU_ICON_STATE_UNDETERMINED,
- G_PARAM_READABLE);
-
- g_object_class_install_properties(gobjectClass, PROP_LAST, NoJSViewProperties);
-}
-
-/* Object initialization
- * Create private structure and set up default values
- */
-static void nojs_view_init(NoJSView *self)
-{
- NoJSViewPrivate *priv;
-
- priv=self->priv=NOJS_VIEW_GET_PRIVATE(self);
-
- /* Set up default values */
- priv->manager=NULL;
- priv->browser=NULL;
- priv->view=NULL;
-
- priv->menu=NULL;
- priv->menuPolicyWasChanged=FALSE;
- priv->menuIconState=NOJS_MENU_ICON_STATE_UNDETERMINED;
-
- priv->resourceURIs=NULL;
-
- /* Create empty menu */
- _nojs_view_create_empty_menu(self);
-}
-
-/* Implementation: Public API */
-
-/* Create new object */
-NoJSView* nojs_view_new(NoJS *inNoJS, MidoriBrowser *inBrowser, MidoriView *inView)
-{
- return(g_object_new(TYPE_NOJS_VIEW,
- "manager", inNoJS,
- "browser", inBrowser,
- "view", inView,
- NULL));
-}
-
-/* Get menu widget for this view */
-GtkMenu* nojs_view_get_menu(NoJSView *self)
-{
- g_return_val_if_fail(NOJS_IS_VIEW(self), NULL);
-
- return(GTK_MENU(self->priv->menu));
-}
-
-/* Get image used for menu icon in status bar */
-NoJSMenuIconState nojs_view_get_menu_icon_state(NoJSView *self)
-{
- g_return_val_if_fail(NOJS_IS_VIEW(self), NOJS_MENU_ICON_STATE_UNDETERMINED);
-
- return(self->priv->menuIconState);
-}
-
-/************************************************************************************/
-
-/* Implementation: Enumeration */
-GType nojs_menu_icon_state_get_type(void)
-{
- static volatile gsize g_define_type_id__volatile=0;
-
- if(g_once_init_enter(&g_define_type_id__volatile))
- {
- static const GEnumValue values[]=
- {
- { NOJS_MENU_ICON_STATE_UNDETERMINED, "NOJS_MENU_ICON_STATE_UNDETERMINED", N_("Undetermined") },
- { NOJS_MENU_ICON_STATE_ALLOWED, "NOJS_MENU_ICON_STATE_ALLOWED", N_("Allowed") },
- { NOJS_MENU_ICON_STATE_MIXED, "NOJS_MENU_ICON_STATE_MIXED", N_("Mixed") },
- { NOJS_MENU_ICON_STATE_DENIED, "NOJS_MENU_ICON_STATE_DENIED", N_("Denied") },
- { 0, NULL, NULL }
- };
-
- GType g_define_type_id=g_enum_register_static(g_intern_static_string("NoJSMenuIconState"), values);
- g_once_init_leave(&g_define_type_id__volatile, g_define_type_id);
- }
-
- return(g_define_type_id__volatile);
-}
diff --git a/extensions/nojs/nojs-view.h b/extensions/nojs/nojs-view.h
deleted file mode 100644
index d88d40d9..00000000
--- a/extensions/nojs/nojs-view.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- Copyright (C) 2013 Stephan Haller <nomad@froevel.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 __NOJS_VIEW__
-#define __NOJS_VIEW__
-
-#include "config.h"
-#include "nojs.h"
-#include <midori/midori.h>
-
-G_BEGIN_DECLS
-
-/* NoJS view enums */
-typedef enum
-{
- NOJS_MENU_ICON_STATE_UNDETERMINED,
- NOJS_MENU_ICON_STATE_ALLOWED,
- NOJS_MENU_ICON_STATE_MIXED,
- NOJS_MENU_ICON_STATE_DENIED
-} NoJSMenuIconState;
-
-/* NoJS view object */
-#define TYPE_NOJS_VIEW (nojs_view_get_type())
-#define NOJS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_NOJS_VIEW, NoJSView))
-#define NOJS_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_NOJS_VIEW))
-#define NOJS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_NOJS_VIEW, NoJSViewClass))
-#define NOJS_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_NOJS_VIEW))
-#define NOJS_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_NOJS_VIEW, NoJSViewClass))
-
-typedef struct _NoJSView NoJSView;
-typedef struct _NoJSViewClass NoJSViewClass;
-typedef struct _NoJSViewPrivate NoJSViewPrivate;
-
-struct _NoJSView
-{
- /* Parent instance */
- GObject parent_instance;
-
- /* Private structure */
- NoJSViewPrivate *priv;
-};
-
-struct _NoJSViewClass
-{
- /* Parent class */
- GObjectClass parent_class;
-};
-
-/* Public API */
-GType nojs_view_get_type(void);
-
-NoJSView* nojs_view_new(NoJS *inNoJS, MidoriBrowser *inBrowser, MidoriView *inView);
-
-GtkMenu* nojs_view_get_menu(NoJSView *self);
-NoJSMenuIconState nojs_view_get_menu_icon_state(NoJSView *self);
-
-/* Enumeration */
-GType nojs_menu_icon_state_get_type(void) G_GNUC_CONST;
-#define NOJS_TYPE_MENU_ICON_STATE (nojs_menu_icon_state_get_type())
-
-G_END_DECLS
-
-#endif /* __NOJS_VIEW__ */
diff --git a/extensions/nojs/nojs.c b/extensions/nojs/nojs.c
deleted file mode 100644
index 7e6b39f0..00000000
--- a/extensions/nojs/nojs.c
+++ /dev/null
@@ -1,1044 +0,0 @@
-/*
- Copyright (C) 2013 Stephan Haller <nomad@froevel.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.
-*/
-
-#include "nojs.h"
-#include "nojs-view.h"
-
-#include <errno.h>
-
-/* Define this class in GObject system */
-G_DEFINE_TYPE(NoJS,
- nojs,
- G_TYPE_OBJECT)
-
-/* Properties */
-enum
-{
- PROP_0,
-
- PROP_EXTENSION,
- PROP_APPLICATION,
-
- PROP_DATABASE,
- PROP_DATABASE_FILENAME,
- PROP_ALLOW_LOCAL_PAGES,
- PROP_ONLY_SECOND_LEVEL,
- PROP_UNKNOWN_DOMAIN_POLICY,
-
- PROP_LAST
-};
-
-static GParamSpec* NoJSProperties[PROP_LAST]={ 0, };
-
-/* Signals */
-enum
-{
- URI_LOAD_POLICY_STATUS,
- POLICY_CHANGED,
-
- SIGNAL_LAST
-};
-
-static guint NoJSSignals[SIGNAL_LAST]={ 0, };
-
-/* Private structure - access only by public API if needed */
-#define NOJS_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), TYPE_NOJS, NoJSPrivate))
-
-struct _NoJSPrivate
-{
- /* Extension related */
- MidoriExtension *extension;
- MidoriApp *application;
- sqlite3 *database;
- gchar *databaseFilename;
- gboolean allowLocalPages;
- gboolean checkOnlySecondLevel;
- NoJSPolicy unknownDomainPolicy;
-
- guint requestStartedSignalID;
-};
-
-/* Taken from http://www.w3.org/html/wg/drafts/html/master/scripting-1.html#scriptingLanguages
- * A list of javascript mime types
- */
-static const gchar* javascriptTypes[]= {
- "application/ecmascript",
- "application/javascript",
- "application/x-ecmascript",
- "application/x-javascript",
- "text/ecmascript",
- "text/javascript",
- "text/javascript1.0",
- "text/javascript1.1",
- "text/javascript1.2",
- "text/javascript1.3",
- "text/javascript1.4",
- "text/javascript1.5",
- "text/jscript",
- "text/livescript",
- "text/x-ecmascript",
- "text/x-javascript",
- NULL
- };
-
-/* IMPLEMENTATION: Private variables and methods */
-
-/* Closure for: void (*closure)(NoJS *self, gchar *inURI, NoJSPolicy inPolicy) */
-static void _nojs_closure_VOID__STRING_ENUM(GClosure *inClosure,
- GValue *ioReturnValue G_GNUC_UNUSED,
- guint inNumberValues,
- const GValue *inValues,
- gpointer inInvocationHint G_GNUC_UNUSED,
- gpointer inMarshalData)
-{
- typedef void (*GMarshalFunc_VOID__STRING_ENUM)(gpointer inObject, gpointer inArg1, gint inArg2, gpointer inUserData);
-
- register GMarshalFunc_VOID__STRING_ENUM callback;
- register GCClosure *closure=(GCClosure*)inClosure;
- register gpointer object, userData;
-
- g_return_if_fail(inNumberValues==3);
-
- if(G_CCLOSURE_SWAP_DATA(inClosure))
- {
- object=inClosure->data;
- userData=g_value_peek_pointer(inValues+0);
- }
- else
- {
- object=g_value_peek_pointer(inValues+0);
- userData=inClosure->data;
- }
-
- callback=(GMarshalFunc_VOID__STRING_ENUM)(inMarshalData ? inMarshalData : closure->callback);
-
- callback(object,
- (gchar*)g_value_get_string(inValues+1),
- g_value_get_enum(inValues+2),
- userData);
-}
-
-/* Show common error dialog */
-static void _nojs_error(NoJS *self, const gchar *inReason)
-{
- g_return_if_fail(IS_NOJS(self));
- g_return_if_fail(inReason);
-
- GtkWidget *dialog;
-
- /* Show confirmation dialog for undetermined cookies */
- dialog=gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("A fatal error occurred which prevents "
- "the NoJS extension to continue. "
- "You should disable it."));
-
- gtk_window_set_title(GTK_WINDOW(dialog), _("Error in NoJS extension"));
- gtk_window_set_icon_name(GTK_WINDOW (dialog), "midori");
-
- gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
- "%s:\n%s",
- _("Reason"),
- inReason);
-
- gtk_dialog_run(GTK_DIALOG(dialog));
-
- /* Free up allocated resources */
- gtk_widget_destroy(dialog);
-}
-
-/* Open database containing policies for javascript sites.
- * Create database and setup table structure if it does not exist yet.
- */
-static void _nojs_open_database(NoJS *self)
-{
- g_return_if_fail(IS_NOJS(self));
-
- NoJSPrivate *priv=self->priv;
- const gchar *configDir;
- gchar *sql;
- gchar *error=NULL;
- gint success;
-
- /* Close any open database */
- if(priv->database)
- {
- priv->databaseFilename=NULL;
-
- sqlite3_close(priv->database);
- priv->database=NULL;
-
- g_object_notify_by_pspec(G_OBJECT(self), NoJSProperties[PROP_DATABASE]);
- g_object_notify_by_pspec(G_OBJECT(self), NoJSProperties[PROP_DATABASE_FILENAME]);
- }
-
- /* Build path to database file */
- configDir=midori_extension_get_config_dir(priv->extension);
- if(!configDir)
- return;
-
- if(katze_mkdir_with_parents(configDir, 0700))
- {
- g_warning(_("Could not create configuration folder for extension: %s"), g_strerror(errno));
-
- _nojs_error(self, _("Could not create configuration folder for extension."));
- return;
- }
-
- /* Open database */
- priv->databaseFilename=g_build_filename(configDir, NOJS_DATABASE, NULL);
- success=sqlite3_open(priv->databaseFilename, &priv->database);
- if(success!=SQLITE_OK)
- {
- g_warning(_("Could not open database of extension: %s"), sqlite3_errmsg(priv->database));
-
- g_free(priv->databaseFilename);
- priv->databaseFilename=NULL;
-
- if(priv->database) sqlite3_close(priv->database);
- priv->database=NULL;
-
- _nojs_error(self, _("Could not open database of extension."));
- return;
- }
-
- /* Create table structure if it does not exist */
- success=sqlite3_exec(priv->database,
- "CREATE TABLE IF NOT EXISTS "
- "policies(site text, value integer);",
- NULL,
- NULL,
- &error);
-
- if(success==SQLITE_OK)
- {
- success=sqlite3_exec(priv->database,
- "CREATE UNIQUE INDEX IF NOT EXISTS "
- "site ON policies (site);",
- NULL,
- NULL,
- &error);
- }
-
- if(success==SQLITE_OK)
- {
- success=sqlite3_exec(priv->database,
- "PRAGMA journal_mode=TRUNCATE;",
- NULL,
- NULL,
- &error);
- }
-
- if(success!=SQLITE_OK || error)
- {
- _nojs_error(self, _("Could not set up database structure of extension."));
-
- if(error)
- {
- g_critical(_("Failed to execute database statement: %s"), error);
- sqlite3_free(error);
- }
-
- g_free(priv->databaseFilename);
- priv->databaseFilename=NULL;
-
- sqlite3_close(priv->database);
- priv->database=NULL;
- return;
- }
-
- /* Delete all temporarily allowed sites */
- sql=sqlite3_mprintf("DELETE FROM policies WHERE value=%d;", NOJS_POLICY_ACCEPT_TEMPORARILY);
- success=sqlite3_exec(priv->database, sql, NULL, NULL, &error);
- if(success!=SQLITE_OK) g_warning(_("SQL fails: %s"), error);
- if(error) sqlite3_free(error);
- sqlite3_free(sql);
-
- g_object_notify_by_pspec(G_OBJECT(self), NoJSProperties[PROP_DATABASE]);
- g_object_notify_by_pspec(G_OBJECT(self), NoJSProperties[PROP_DATABASE_FILENAME]);
-}
-
-/* A request through libsoup is going to start and http headers must be
- * checked for content type
- */
-static void _nojs_on_got_headers(NoJS *self, gpointer inUserData)
-{
- g_return_if_fail(IS_NOJS(self));
- g_return_if_fail(SOUP_IS_MESSAGE(inUserData));
-
- NoJSPrivate *priv=self->priv;
- SoupMessage *message=SOUP_MESSAGE(inUserData);
- SoupSession *session=webkit_get_default_session();
- SoupMessageHeaders *headers;
- SoupMessageBody *body;
- const gchar *contentType;
- SoupURI *uri;
- gchar *uriText;
- NoJSPolicy policy;
- gboolean isJS;
- const gchar **iter;
-
- /* Get headers from message to retrieve content type */
- g_object_get(message, "response-headers", &headers, NULL);
- if(!headers)
- {
- g_warning("Could not get headers from message to check for javascript.");
- return;
- }
-
- /* Get content type of uri and check if it is a javascript resource */
- contentType=soup_message_headers_get_content_type(headers, NULL);
-
- isJS=FALSE;
- iter=javascriptTypes;
- while(*iter && !isJS)
- {
- isJS=(g_strcmp0(contentType, *iter)==0);
- iter++;
- }
-
- if(!isJS) return;
-
- /* The document being loaded is javascript so get URI from message,
- * get policy for domain of URI and emit signal
- */
- uri=soup_message_get_uri(message);
- policy=nojs_get_policy(self, uri);
-
- if(policy==NOJS_POLICY_UNDETERMINED)
- {
- g_warning("Got invalid policy. Using default policy for unknown domains.");
- policy=priv->unknownDomainPolicy;
- }
-
- uriText=soup_uri_to_string(uri, FALSE);
-
- g_signal_emit(self, NoJSSignals[URI_LOAD_POLICY_STATUS], 0, uriText, policy==NOJS_POLICY_UNDETERMINED ? NOJS_POLICY_BLOCK : policy);
-
- g_free(uriText);
-
- /* Return here if policy is any type of accept */
- if(policy!=NOJS_POLICY_UNDETERMINED && policy!=NOJS_POLICY_BLOCK) return;
-
- /* Cancel this message */
- soup_session_cancel_message(session, message, SOUP_STATUS_CANCELLED);
-
- /* Discard any load data */
- g_object_get(message, "response-body", &body, NULL);
- if(body) soup_message_body_truncate(body);
-}
-
-static void _nojs_on_request_started(NoJS *self,
- SoupMessage *inMessage,
- SoupSocket *inSocket,
- gpointer inUserData)
-{
- g_return_if_fail(IS_NOJS(self));
- g_return_if_fail(SOUP_IS_MESSAGE(inMessage));
-
- /* Connect to "got-headers" to cancel loading javascript documents early */
- g_signal_connect_swapped(inMessage, "got-headers", G_CALLBACK(_nojs_on_got_headers), self);
-}
-
-/* The icon in statusbar was clicked */
-static void _nojs_on_statusbar_icon_clicked(MidoriBrowser *inBrowser, gpointer inUserData)
-{
- g_return_if_fail(MIDORI_IS_BROWSER(inBrowser));
-
- MidoriView *activeView;
- NoJSView *view;
- GtkMenu *menu;
-
- /* Get current active midori view */
- activeView=MIDORI_VIEW(midori_browser_get_current_tab(inBrowser));
- g_return_if_fail(MIDORI_IS_VIEW(activeView));
-
- /* Get NoJS view of current active midori view */
- view=NOJS_VIEW(g_object_get_data(G_OBJECT(activeView), "nojs-view-instance"));
- g_return_if_fail(NOJS_IS_VIEW(view));
-
- /* Get menu of current view */
- menu=nojs_view_get_menu(view);
- g_return_if_fail(menu);
-
- /* Show menu */
- gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time());
-}
-
-gchar* nojs_get_icon_path (const gchar* icon)
-{
- gchar* nojs_dir = midori_paths_get_res_filename("nojs");
- return g_build_filename (nojs_dir, icon, NULL);
-}
-
-/* Menu icon of a view has changed */
-static void _nojs_on_menu_icon_changed(MidoriBrowser *inBrowser, GParamSpec *inSpec, gpointer inUserData)
-{
- g_return_if_fail(MIDORI_IS_BROWSER(inBrowser));
- g_return_if_fail(NOJS_IS_VIEW(inUserData));
-
- NoJSView *view=NOJS_VIEW(inUserData);
- NoJSMenuIconState menuIconState;
- GtkWidget *statusbarIcon;
- GtkWidget *buttonImage;
- gchar *imageFilename;
-
- /* Get icon in status bar of this browser */
- statusbarIcon=GTK_WIDGET(g_object_get_data(G_OBJECT(inBrowser), "nojs-statusicon"));
- g_return_if_fail(GTK_IS_WIDGET(statusbarIcon));
-
- /* Get menu icon state of view */
- menuIconState=nojs_view_get_menu_icon_state(view);
-
- /* Create image for statusbar button */
- imageFilename=NULL;
- switch(menuIconState)
- {
- case NOJS_MENU_ICON_STATE_ALLOWED:
- imageFilename=nojs_get_icon_path("nojs-statusicon-allowed.png");
- break;
-
- case NOJS_MENU_ICON_STATE_MIXED:
- imageFilename=nojs_get_icon_path("nojs-statusicon-mixed.png");
- break;
-
- case NOJS_MENU_ICON_STATE_DENIED:
- case NOJS_MENU_ICON_STATE_UNDETERMINED:
- imageFilename=nojs_get_icon_path("nojs-statusicon-denied.png");
- break;
- }
-
- buttonImage=gtk_image_new_from_file(imageFilename);
- g_free(imageFilename);
-
- /* Set image at statusbar button */
- gtk_button_set_image(GTK_BUTTON(statusbarIcon), buttonImage);
-}
-
-/* A tab in browser was activated */
-static void _nojs_on_switch_tab(NoJS *self, MidoriView *inOldView, MidoriView *inNewView, gpointer inUserData)
-{
- g_return_if_fail(IS_NOJS(self));
- g_return_if_fail(MIDORI_IS_BROWSER(inUserData));
-
- MidoriBrowser *browser=MIDORI_BROWSER(inUserData);
- NoJSView *view;
-
- /* Disconnect signal handlers from old view */
- if(inOldView)
- {
- /* Get NoJS view of old view */
- view=(NoJSView*)g_object_get_data(G_OBJECT(inOldView), "nojs-view-instance");
- g_return_if_fail(NOJS_IS_VIEW(view));
-
- /* Disconnect signal handlers */
- g_signal_handlers_disconnect_by_func(view, G_CALLBACK(_nojs_on_menu_icon_changed), browser);
- }
-
- /* Get NoJS view of new view */
- view=(NoJSView*)g_object_get_data(G_OBJECT(inNewView), "nojs-view-instance");
- g_return_if_fail(NOJS_IS_VIEW(view));
-
- /* Connect signals */
- g_signal_connect_swapped(view, "notify::menu-icon-state", G_CALLBACK(_nojs_on_menu_icon_changed), browser);
-
- /* Update menu icon*/
- _nojs_on_menu_icon_changed(browser, NULL, view);
-}
-
-/* A tab of a browser was removed */
-static void _nojs_on_remove_tab(NoJS *self, MidoriView *inView, gpointer inUserData)
-{
- g_return_if_fail(IS_NOJS(self));
-
- NoJSView *view;
-
- /* Get NoJS view of current active midori view */
- view=NOJS_VIEW(g_object_get_data(G_OBJECT(inView), "nojs-view-instance"));
- g_return_if_fail(NOJS_IS_VIEW(view));
-
- g_object_unref(view);
-}
-
-/* A tab of a browser was added */
-static void _nojs_on_add_tab(NoJS *self, MidoriView *inView, gpointer inUserData)
-{
- g_return_if_fail(IS_NOJS(self));
- g_return_if_fail(MIDORI_IS_BROWSER(inUserData));
-
- /* Create nojs view and add to tab */
- MidoriBrowser *browser=MIDORI_BROWSER(inUserData);
-
- nojs_view_new(self, browser, inView);
-}
-
-/* A browser window was added */
-static void _nojs_on_add_browser(NoJS *self, MidoriBrowser *inBrowser, gpointer inUserData)
-{
- g_return_if_fail(IS_NOJS(self));
- g_return_if_fail(MIDORI_IS_BROWSER(inBrowser));
-
- GList *tabs, *iter;
- GtkWidget *statusbar;
- GtkWidget *statusbarIcon;
- MidoriView *view;
- NoJSView *nojsView;
-
- /* Set up all current available tabs in browser */
- tabs=midori_browser_get_tabs(inBrowser);
- for(iter=tabs; iter; iter=g_list_next(iter)) _nojs_on_add_tab(self, iter->data, inBrowser);
- g_list_free(tabs);
-
- /* Add status bar icon to browser */
- g_object_get(inBrowser, "statusbar", &statusbar, NULL);
- if(statusbar)
- {
- /* Create and set up status icon */
- statusbarIcon=gtk_button_new();
- gtk_button_set_relief(GTK_BUTTON(statusbarIcon), GTK_RELIEF_NONE);
- gtk_widget_show_all(statusbarIcon);
- gtk_box_pack_end(GTK_BOX(statusbar), statusbarIcon, FALSE, FALSE, 0);
- g_object_set_data_full(G_OBJECT(inBrowser), "nojs-statusicon", g_object_ref(statusbarIcon), (GDestroyNotify)gtk_widget_destroy);
-
- /* Connect signals */
- g_signal_connect_swapped(statusbarIcon, "clicked", G_CALLBACK(_nojs_on_statusbar_icon_clicked), inBrowser);
-
- /* Release our reference to statusbar and status icon */
- g_object_unref(statusbarIcon);
- g_object_unref(statusbar);
-
- /* Update menu icon*/
- view=MIDORI_VIEW(midori_browser_get_current_tab(inBrowser));
- if(view)
- {
- nojsView=(NoJSView*)g_object_get_data(G_OBJECT(view), "nojs-view-instance");
- if(nojsView) _nojs_on_menu_icon_changed(inBrowser, NULL, nojsView);
- }
- }
-
- /* Listen to new tabs opened in browser */
- g_signal_connect_swapped(inBrowser, "add-tab", G_CALLBACK(_nojs_on_add_tab), self);
- g_signal_connect_swapped(inBrowser, "switch-tab", G_CALLBACK(_nojs_on_switch_tab), self);
- g_signal_connect_swapped(inBrowser, "remove-tab", G_CALLBACK(_nojs_on_remove_tab), self);
-}
-
-/* Application property has changed */
-static void _nojs_on_application_changed(NoJS *self)
-{
- g_return_if_fail(IS_NOJS(self));
-
- NoJSPrivate *priv=NOJS(self)->priv;
- GList *browsers, *iter;
-
- /* Set up all current open browser windows */
- browsers=midori_app_get_browsers(priv->application);
- for(iter=browsers; iter; iter=g_list_next(iter)) _nojs_on_add_browser(self, MIDORI_BROWSER(iter->data), priv->application);
- g_list_free(browsers);
-
- /* Listen to new browser windows opened */
- g_signal_connect_swapped(priv->application, "add-browser", G_CALLBACK(_nojs_on_add_browser), self);
-
- /* Notify about property change */
- g_object_notify_by_pspec(G_OBJECT(self), NoJSProperties[PROP_APPLICATION]);
-}
-
-/* IMPLEMENTATION: GObject */
-
-/* Finalize this object */
-static void nojs_finalize(GObject *inObject)
-{
- NoJS *self=NOJS(inObject);
- NoJSPrivate *priv=self->priv;
- GList *browsers, *browser;
- GList *tabs, *tab;
- WebKitWebView *webkitView;
- SoupSession *session;
-
- /* Dispose allocated resources */
- session=webkit_get_default_session();
- g_signal_handlers_disconnect_by_data(session, self);
-
- if(priv->databaseFilename)
- {
- g_free(priv->databaseFilename);
- priv->databaseFilename=NULL;
- }
-
- if(priv->database)
- {
- sqlite3_close(priv->database);
- priv->database=NULL;
- }
-
- if(priv->application)
- {
- g_signal_handlers_disconnect_by_data(priv->application, self);
-
- browsers=midori_app_get_browsers(priv->application);
- for(browser=browsers; browser; browser=g_list_next(browser))
- {
- g_signal_handlers_disconnect_by_data(browser->data, self);
- g_object_set_data(G_OBJECT(browser->data), "nojs-statusicon", NULL);
-
- tabs=midori_browser_get_tabs(MIDORI_BROWSER(browser->data));
- for(tab=tabs; tab; tab=g_list_next(tab))
- {
- g_signal_handlers_disconnect_by_data(tab->data, self);
-
- webkitView=WEBKIT_WEB_VIEW(midori_view_get_web_view(MIDORI_VIEW(tab->data)));
- g_signal_handlers_disconnect_by_data(webkitView, self);
- }
- g_list_free(tabs);
- }
- g_list_free(browsers);
-
- priv->application=NULL;
- }
-
- /* Call parent's class finalize method */
- G_OBJECT_CLASS(nojs_parent_class)->finalize(inObject);
-}
-
-/* Set/get properties */
-static void nojs_set_property(GObject *inObject,
- guint inPropID,
- const GValue *inValue,
- GParamSpec *inSpec)
-{
- NoJS *self=NOJS(inObject);
-
- switch(inPropID)
- {
- /* Construct-only properties */
- case PROP_EXTENSION:
- self->priv->extension=g_value_get_object(inValue);
- _nojs_open_database(self);
- break;
-
- case PROP_APPLICATION:
- self->priv->application=g_value_get_object(inValue);
- _nojs_on_application_changed(self);
- break;
-
- case PROP_ALLOW_LOCAL_PAGES:
- self->priv->allowLocalPages=g_value_get_boolean(inValue);
- g_object_notify_by_pspec(G_OBJECT(self), NoJSProperties[PROP_ALLOW_LOCAL_PAGES]);
- break;
-
- case PROP_ONLY_SECOND_LEVEL:
- self->priv->checkOnlySecondLevel=g_value_get_boolean(inValue);
- g_object_notify_by_pspec(G_OBJECT(self), NoJSProperties[PROP_ONLY_SECOND_LEVEL]);
- break;
-
- case PROP_UNKNOWN_DOMAIN_POLICY:
- self->priv->unknownDomainPolicy=g_value_get_enum(inValue);
- g_object_notify_by_pspec(G_OBJECT(self), NoJSProperties[PROP_UNKNOWN_DOMAIN_POLICY]);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
- break;
- }
-}
-
-static void nojs_get_property(GObject *inObject,
- guint inPropID,
- GValue *outValue,
- GParamSpec *inSpec)
-{
- NoJS *self=NOJS(inObject);
-
- switch(inPropID)
- {
- case PROP_EXTENSION:
- g_value_set_object(outValue, self->priv->extension);
- break;
-
- case PROP_APPLICATION:
- g_value_set_object(outValue, self->priv->application);
- break;
-
- case PROP_DATABASE:
- g_value_set_pointer(outValue, self->priv->database);
- break;
-
- case PROP_DATABASE_FILENAME:
- g_value_set_string(outValue, self->priv->databaseFilename);
- break;
-
- case PROP_ALLOW_LOCAL_PAGES:
- g_value_set_boolean(outValue, self->priv->allowLocalPages);
- break;
-
- case PROP_ONLY_SECOND_LEVEL:
- g_value_set_boolean(outValue, self->priv->checkOnlySecondLevel);
- break;
-
- case PROP_UNKNOWN_DOMAIN_POLICY:
- g_value_set_enum(outValue, self->priv->unknownDomainPolicy);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
- break;
- }
-}
-
-/* Class initialization
- * Override functions in parent classes and define properties and signals
- */
-static void nojs_class_init(NoJSClass *klass)
-{
- GObjectClass *gobjectClass=G_OBJECT_CLASS(klass);
-
- /* Override functions */
- gobjectClass->finalize=nojs_finalize;
- gobjectClass->set_property=nojs_set_property;
- gobjectClass->get_property=nojs_get_property;
-
- /* Set up private structure */
- g_type_class_add_private(klass, sizeof(NoJSPrivate));
-
- /* Define properties */
- NoJSProperties[PROP_EXTENSION]=
- g_param_spec_object("extension",
- _("Extension instance"),
- _("The Midori extension instance for this extension"),
- MIDORI_TYPE_EXTENSION,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
- NoJSProperties[PROP_APPLICATION]=
- g_param_spec_object("application",
- _("Application instance"),
- _("The Midori application instance this extension belongs to"),
- MIDORI_TYPE_APP,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
- NoJSProperties[PROP_DATABASE]=
- g_param_spec_pointer("database",
- _("Database instance"),
- _("Pointer to sqlite database instance used by this extension"),
- G_PARAM_READABLE);
-
- NoJSProperties[PROP_DATABASE_FILENAME]=
- g_param_spec_string("database-filename",
- _("Database path"),
- _("Path to sqlite database instance used by this extension"),
- NULL,
- G_PARAM_READABLE);
-
- NoJSProperties[PROP_ALLOW_LOCAL_PAGES]=
- g_param_spec_boolean("allow-local-pages",
- _("Allow local pages"),
- _("Allow scripts to run on local (file://) pages"),
- TRUE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
-
- NoJSProperties[PROP_ONLY_SECOND_LEVEL]=
- g_param_spec_boolean("only-second-level",
- _("Only second level"),
- _("Reduce each domain to its second-level (e.g. www.example.org to example.org) for comparison"),
- TRUE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
-
- NoJSProperties[PROP_UNKNOWN_DOMAIN_POLICY]=
- g_param_spec_enum("unknown-domain-policy",
- _("Unknown domain policy"),
- _("Policy to use for unknown domains"),
- NOJS_TYPE_POLICY,
- NOJS_POLICY_BLOCK,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
-
- g_object_class_install_properties(gobjectClass, PROP_LAST, NoJSProperties);
-
- /* Define signals */
-
- /* Why does this signal exist?
- *
- * The problem I faced when developing this extension was
- * that I needed to cancel a SoupMessage as soon as possible
- * (when http headers were received).
- * I tried to connect to signal "resource-response-received"
- * of WebKitWebView but the SoupMessage instance was not
- * exactly the same which were sent or received by SoupSession.
- * So I could not cancel the SoupMessage or better: I cancelled
- * a SoupMessage which is not be handled so it had no effect.
- * The body of SoupMessage was still being loaded and javascript
- * was executed. I think the problem is that webkit-gtk creates
- * a copy of the real SoupMessage which is going to be sent and
- * received.
- *
- * So I decided to connect to signal "got-headers" of every
- * SoupMessage sent by the default SoupSession which I notice
- * by connecting to signal "request-started" of SoupSession. Each
- * NoJSView connects to signal "resource-request-starting" of
- * WebKitWebView to remember each URI going to be loaded. When
- * a SoupMessage hits "got-headers" and is a javascript resource
- * I can cancel the message immediately and clear the body which
- * causes webkit-gtk to copy a empty body if it does at all as the
- * SoupMessage was cancelled. Then I emit this signal
- * "uri-load-policy-status" to notify each view but the cancellation.
- * (It also notifies all views if it is going to load to keep the
- * menu in right state.) Each view will check if it _could_ be a
- * resource itself requested and will update its menu accordingly.
- * It might happen that a request will match two views because only
- * the URI will be checked by the view because I cannot determine
- * to which view the SoupMessage belongs to. But it doesn't matter
- * because if a javascript resource was denied or allowed in one view
- * it is likely be denied or allowed in other views too ;)
- */
- NoJSSignals[URI_LOAD_POLICY_STATUS]=
- g_signal_new("uri-load-policy-status",
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(NoJSClass, uri_load_policy_status),
- NULL,
- NULL,
- _nojs_closure_VOID__STRING_ENUM,
- G_TYPE_NONE,
- 2,
- G_TYPE_STRING,
- NOJS_TYPE_POLICY);
-
- NoJSSignals[POLICY_CHANGED]=
- g_signal_new("policy-changed",
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(NoJSClass, policy_changed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
-}
-
-/* Object initialization
- * Create private structure and set up default values
- */
-
-static void nojs_init(NoJS *self)
-{
- NoJSPrivate *priv;
- SoupSession *session;
-
- priv=self->priv=NOJS_GET_PRIVATE(self);
-
- /* Set up default values */
- priv->database=NULL;
- priv->databaseFilename=NULL;
- priv->allowLocalPages=TRUE;
- priv->checkOnlySecondLevel=TRUE;
- priv->unknownDomainPolicy=NOJS_POLICY_BLOCK;
-
- /* Connect to signals on session to be able to cancel messages
- * loading javascript documents
- */
- session=webkit_get_default_session();
- g_signal_connect_swapped(session, "request-started", G_CALLBACK(_nojs_on_request_started), self);
-}
-
-/* Implementation: Public API */
-
-/* Create new object */
-NoJS* nojs_new(MidoriExtension *inExtension, MidoriApp *inApp)
-{
- return(g_object_new(TYPE_NOJS,
- "extension", inExtension,
- "application", inApp,
- NULL));
-}
-
-/* Retrieves domain from uri depending on preferences (e.g. only second level domain) */
-gchar* nojs_get_domain(NoJS *self, SoupURI *inURI)
-{
- g_return_val_if_fail(IS_NOJS(self), NULL);
- g_return_val_if_fail(inURI, NULL);
-
- NoJSPrivate *priv=self->priv;
- const gchar *realDomain;
- gchar *finalDomain;
-
- /* Get domain of site to lookup */
- realDomain=soup_uri_get_host(inURI);
-
- if(priv->checkOnlySecondLevel)
- finalDomain=midori_uri_get_base_domain(realDomain);
- else
- finalDomain=midori_uri_to_ascii(realDomain);
-
- /* Return domain */
- return(finalDomain);
-}
-
-/* Get/set policy for javascript from site */
-gint nojs_get_policy(NoJS *self, SoupURI *inURI)
-{
- g_return_val_if_fail(IS_NOJS(self), NOJS_POLICY_UNDETERMINED);
- g_return_val_if_fail(inURI, NOJS_POLICY_UNDETERMINED);
-
- NoJSPrivate *priv=self->priv;
- sqlite3_stmt *statement=NULL;
- gint error;
- gint policy=NOJS_POLICY_UNDETERMINED;
- gchar *inDomain;
-
- /* Check to allow local pages */
- if(soup_uri_get_scheme(inURI) == SOUP_URI_SCHEME_FILE)
- {
- if(priv->allowLocalPages) return(NOJS_POLICY_ACCEPT);
- else return(priv->unknownDomainPolicy);
- }
-
- /* Check for open database */
- g_return_val_if_fail(priv->database, policy);
-
- /* Get domain from URI */
- inDomain=nojs_get_domain(self, inURI);
-
- /* Lookup policy for site in database */
- error=sqlite3_prepare_v2(priv->database,
- "SELECT site, value FROM policies WHERE site LIKE ? LIMIT 1;",
- -1,
- &statement,
- NULL);
- if(statement && error==SQLITE_OK) error=sqlite3_bind_text(statement, 1, inDomain, -1, NULL);
- if(statement && error==SQLITE_OK)
- {
- if(sqlite3_step(statement)==SQLITE_ROW) policy=sqlite3_column_int(statement, 1);
- }
- else g_warning(_("SQL fails: %s"), sqlite3_errmsg(priv->database));
-
- sqlite3_finalize(statement);
-
- /* If we have not found a policy for the domain then it is an unknown domain.
- * Get default policy for unknown domains.
- */
- if(policy==NOJS_POLICY_UNDETERMINED) policy=priv->unknownDomainPolicy;
-
- return(policy);
-}
-
-void nojs_set_policy(NoJS *self, const gchar *inDomain, NoJSPolicy inPolicy)
-{
- g_return_if_fail(IS_NOJS(self));
- g_return_if_fail(inDomain);
- g_return_if_fail(inPolicy>=NOJS_POLICY_ACCEPT && inPolicy<=NOJS_POLICY_BLOCK);
-
- NoJSPrivate *priv=self->priv;
- gchar *sql;
- gchar *error=NULL;
- gint success;
-
- /* Check for open database */
- g_return_if_fail(priv->database);
-
- /* Update policy in database */
- sql=sqlite3_mprintf("INSERT OR REPLACE INTO policies (site, value) VALUES ('%q', %d);",
- inDomain,
- inPolicy);
- success=sqlite3_exec(priv->database, sql, NULL, NULL, &error);
- if(success!=SQLITE_OK) g_warning(_("SQL fails: %s"), error);
- if(error) sqlite3_free(error);
- sqlite3_free(sql);
-
- /* Emit signal to notify about policy change */
- if(success==SQLITE_OK) g_signal_emit(self, NoJSSignals[POLICY_CHANGED], 0, inDomain);
-}
-
-/* Get/set default policy for unknown domains */
-NoJSPolicy nojs_get_policy_for_unknown_domain(NoJS *self)
-{
- g_return_val_if_fail(IS_NOJS(self), NOJS_POLICY_UNDETERMINED);
-
- return(self->priv->unknownDomainPolicy);
-}
-
-void nojs_set_policy_for_unknown_domain(NoJS *self, NoJSPolicy inPolicy)
-{
- g_return_if_fail(IS_NOJS(self));
- g_return_if_fail(inPolicy>=NOJS_POLICY_ACCEPT && inPolicy<=NOJS_POLICY_BLOCK);
-
- if(self->priv->unknownDomainPolicy!=inPolicy)
- {
- self->priv->unknownDomainPolicy=inPolicy;
- midori_extension_set_integer(self->priv->extension, "unknown-domain-policy", inPolicy);
- g_object_notify_by_pspec(G_OBJECT(self), NoJSProperties[PROP_UNKNOWN_DOMAIN_POLICY]);
- }
-}
-
-/* Get/set flag to allow javascript on local pages */
-gboolean nojs_get_allow_local_pages(NoJS *self)
-{
- g_return_val_if_fail(IS_NOJS(self), TRUE);
-
- return(self->priv->allowLocalPages);
-}
-
-void nojs_set_allow_local_pages(NoJS *self, gboolean inAllow)
-{
- g_return_if_fail(IS_NOJS(self));
-
- if(self->priv->allowLocalPages!=inAllow)
- {
- self->priv->allowLocalPages=inAllow;
- midori_extension_set_boolean(self->priv->extension, "allow-local-pages", inAllow);
- g_object_notify_by_pspec(G_OBJECT(self), NoJSProperties[PROP_ALLOW_LOCAL_PAGES]);
- }
-}
-
-/* Get/set flag to check for second-level domains only */
-gboolean nojs_get_only_second_level_domain(NoJS *self)
-{
- g_return_val_if_fail(IS_NOJS(self), TRUE);
-
- return(self->priv->checkOnlySecondLevel);
-}
-
-void nojs_set_only_second_level_domain(NoJS *self, gboolean inOnlySecondLevel)
-{
- g_return_if_fail(IS_NOJS(self));
-
- if(self->priv->checkOnlySecondLevel!=inOnlySecondLevel)
- {
- self->priv->checkOnlySecondLevel=inOnlySecondLevel;
- midori_extension_set_boolean(self->priv->extension, "only-second-level", inOnlySecondLevel);
- g_object_notify_by_pspec(G_OBJECT(self), NoJSProperties[PROP_ONLY_SECOND_LEVEL]);
- }
-}
-
-/************************************************************************************/
-
-/* Implementation: Enumeration */
-GType nojs_policy_get_type(void)
-{
- static volatile gsize g_define_type_id__volatile=0;
-
- if(g_once_init_enter(&g_define_type_id__volatile))
- {
- static const GEnumValue values[]=
- {
- { NOJS_POLICY_UNDETERMINED, "NOJS_POLICY_UNDETERMINED", N_("Undetermined") },
- { NOJS_POLICY_ACCEPT, "NOJS_POLICY_ACCEPT", N_("Accept") },
- { NOJS_POLICY_ACCEPT_TEMPORARILY, "NOJS_POLICY_ACCEPT_TEMPORARILY", N_("Accept temporarily") },
- { NOJS_POLICY_BLOCK, "NOJS_POLICY_BLOCK", N_("Block") },
- { 0, NULL, NULL }
- };
-
- GType g_define_type_id=g_enum_register_static(g_intern_static_string("NoJSPolicy"), values);
- g_once_init_leave(&g_define_type_id__volatile, g_define_type_id);
- }
-
- return(g_define_type_id__volatile);
-}
diff --git a/extensions/nojs/nojs.h b/extensions/nojs/nojs.h
deleted file mode 100644
index 20bf7374..00000000
--- a/extensions/nojs/nojs.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- Copyright (C) 2013 Stephan Haller <nomad@froevel.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 __NOJS__
-#define __NOJS__
-
-#include "config.h"
-#include <midori/midori.h>
-
-#define NOJS_DATABASE "nojs.db"
-
-G_BEGIN_DECLS
-
-/* NoJS manager enums */
-typedef enum
-{
- NOJS_POLICY_UNDETERMINED,
- NOJS_POLICY_ACCEPT,
- NOJS_POLICY_ACCEPT_TEMPORARILY,
- NOJS_POLICY_BLOCK
-} NoJSPolicy;
-
-/* NoJS manager object */
-#define TYPE_NOJS (nojs_get_type())
-#define NOJS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_NOJS, NoJS))
-#define IS_NOJS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_NOJS))
-#define NOJS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_NOJS, NoJSClass))
-#define IS_NOJS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_NOJS))
-#define NOJS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_NOJS, NoJSClass))
-
-typedef struct _NoJS NoJS;
-typedef struct _NoJSClass NoJSClass;
-typedef struct _NoJSPrivate NoJSPrivate;
-
-struct _NoJS
-{
- /* Parent instance */
- GObject parent_instance;
-
- /* Private structure */
- NoJSPrivate *priv;
-};
-
-struct _NoJSClass
-{
- /* Parent class */
- GObjectClass parent_class;
-
- /* Virtual functions */
- void (*uri_load_policy_status)(NoJS *self, gchar *inURI, NoJSPolicy inPolicy);
- void (*policy_changed)(NoJS *self, gchar *inDomain);
-};
-
-/* Public API */
-GType nojs_get_type(void);
-
-NoJS* nojs_new(MidoriExtension *inExtension, MidoriApp *inApp);
-
-gchar* nojs_get_domain(NoJS *self, SoupURI *inURI);
-
-gint nojs_get_policy(NoJS *self, SoupURI *inURI);
-void nojs_set_policy(NoJS *self, const gchar *inDomain, NoJSPolicy inPolicy);
-
-NoJSPolicy nojs_get_policy_for_unknown_domain(NoJS *self);
-void nojs_set_policy_for_unknown_domain(NoJS *self, NoJSPolicy inPolicy);
-
-gboolean nojs_get_allow_local_pages(NoJS *self);
-void nojs_set_allow_local_pages(NoJS *self, gboolean inAllow);
-
-gboolean nojs_get_only_second_level_domain(NoJS *self);
-void nojs_set_only_second_level_domain(NoJS *self, gboolean inOnlySecondLevel);
-
-gchar* nojs_get_icon_path (const gchar* icon);
-
-/* Enumeration */
-GType nojs_policy_get_type(void) G_GNUC_CONST;
-#define NOJS_TYPE_POLICY (nojs_policy_get_type())
-
-G_END_DECLS
-
-#endif /* __NOJS__ */
diff --git a/extensions/notes.vala b/extensions/notes.vala
deleted file mode 100644
index f0ccfe62..00000000
--- a/extensions/notes.vala
+++ /dev/null
@@ -1,459 +0,0 @@
-/*
- Copyright (C) 2013 Paweł Forysiuk <tuxator@o2.pl>
-
- 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.
-*/
-
-namespace ClipNotes {
-
- Midori.Database database;
- unowned Sqlite.Database db;
- Gtk.ListStore notes_list_store;
- Note? current_note;
-
- class Note : GLib.Object {
- public int64 id { get; set; }
- public string title { get; set; }
- public string? uri { get; set; default = null; }
- public string content { get; set; default = ""; }
-
- public void add (string title, string? uri, string note_content)
- {
- GLib.DateTime time = new DateTime.now_local ();
- string sqlcmd = "INSERT INTO `notes` (`uri`, `title`, `note_content`, `tstamp` ) VALUES (:uri, :title, :note_content, :tstamp);";
- Midori.DatabaseStatement statement;
- try {
- statement = database.prepare (sqlcmd,
- ":uri", typeof (string), uri,
- ":title", typeof (string), title,
- ":note_content", typeof (string), note_content,
- ":tstamp", typeof (int64), time.to_unix ());
-
- statement.step ();
-
- append_note (this);
- } catch (Error error) {
- critical (_("Failed to add new note to database: %s\n"), error.message);
- }
-
- this.id = db.last_insert_rowid ();
- this.uri = uri;
- this.title = title;
- this.content = note_content;
- }
-
- public void remove ()
- {
- string sqlcmd = "DELETE FROM `notes` WHERE id= :id;";
- Midori.DatabaseStatement statement;
- try {
- statement = database.prepare (sqlcmd,
- ":id", typeof (int64), this.id);
-
- statement.step ();
- remove_note (this.id);
- } catch (Error error) {
- critical (_("Falied to remove note from database: %s\n"), error.message);
- }
- }
-
- public void rename (string new_title)
- {
- string sqlcmd = "UPDATE `notes` SET title= :title WHERE id = :id;";
- Midori.DatabaseStatement statement;
- try {
- statement = database.prepare (sqlcmd,
- ":id", typeof (int64), this.id,
- ":title", typeof (string), new_title);
- statement.step ();
- } catch (Error error) {
- critical (_("Falied to rename note: %s\n"), error.message);
- }
-
- this.title = new_title;
- }
-
- public void update (string new_content)
- {
- string sqlcmd = "UPDATE `notes` SET note_content= :content WHERE id = :id;";
- Midori.DatabaseStatement statement;
- try {
- statement = database.prepare (sqlcmd,
- ":id", typeof (int64), this.id,
- ":content", typeof (string), new_content);
- statement.step ();
- } catch (Error error) {
- critical (_("Falied to update note: %s\n"), error.message);
- }
- this.content = new_content;
- }
- }
-
- void append_note (Note note)
- {
- /* Strip LRE leading character */
- if (note.title != null && note.title.has_prefix ("‪"))
- note.title = note.title.replace ("‪", "");
-
- Gtk.TreeIter iter;
- notes_list_store.append (out iter);
- notes_list_store.set (iter, 0, note);
- }
-
- void remove_note (int64 id)
- {
- Gtk.TreeIter iter;
- if (notes_list_store.iter_children (out iter, null)) {
- do {
- Note note;
- notes_list_store.get (iter, 0, out note);
- if (id == note.id) {
- if (current_note == note) {
- current_note = null;
- }
- notes_list_store.remove (iter);
- break;
- }
- } while (notes_list_store.iter_next (ref iter));
- }
- }
-
-
- private class Sidebar : Gtk.VBox, Midori.Viewable {
- Gtk.Toolbar? toolbar = null;
- Gtk.Label note_label;
- Gtk.TreeView notes_tree_view;
- Gtk.TextView note_text_view = new Gtk.TextView ();
-
- public unowned string get_stock_id () {
- return Gtk.STOCK_EDIT;
- }
-
- public unowned string get_label () {
- return _("Notes");
- }
-
- public Gtk.Widget get_toolbar () {
- if (toolbar == null) {
- toolbar = new Gtk.Toolbar ();
- var new_note_button = new Gtk.ToolButton.from_stock (Gtk.STOCK_EDIT);
- new_note_button.label = _("New Note");
- new_note_button.tooltip_text = _("Creates a new empty note, unrelated to opened pages");
- new_note_button.use_underline = true;
- new_note_button.is_important = true;
- new_note_button.show ();
- new_note_button.clicked.connect (() => {
- var note = new Note ();
- note.add (_("New note"), null, "");
- });
- toolbar.insert (new_note_button, -1);
- }
- return toolbar;
- }
-
- internal void title_edited (Gtk.CellRendererText renderer, string? path_str, string? new_title) {
- var path = new Gtk.TreePath.from_string (path_str);
- Gtk.TreeIter iter;
- notes_list_store.get_iter (out iter, path);
- Note note;
- notes_list_store.get (iter, 0, out note);
- note.rename (new_title);
- notes_list_store.set (iter, 0, note);
- }
-
- public Sidebar () {
- Gtk.TreeViewColumn column;
-
- notes_list_store = new Gtk.ListStore (1, typeof (Note));
- notes_tree_view = new Gtk.TreeView.with_model (notes_list_store);
- notes_tree_view.headers_visible = true;
- notes_tree_view.button_press_event.connect (button_pressed);
- notes_tree_view.get_selection().changed.connect (selection_changed);
-
- notes_list_store.set_sort_column_id (0, Gtk.SortType.ASCENDING);
- notes_list_store.set_sort_func (0, tree_sort_func);
-
- column = new Gtk.TreeViewColumn ();
- Gtk.CellRendererPixbuf renderer_icon = new Gtk.CellRendererPixbuf ();
- column.pack_start (renderer_icon, false);
- column.set_cell_data_func (renderer_icon, on_render_icon);
- notes_tree_view.append_column (column);
-
- column = new Gtk.TreeViewColumn ();
- Gtk.CellRendererText renderer_title = new Gtk.CellRendererText ();
- renderer_title.editable = true;
- renderer_title.edited.connect (title_edited);
- column.set_title (_("Notes"));
- column.pack_start (renderer_title, true);
- column.set_cell_data_func (renderer_title, on_render_note_title);
- notes_tree_view.append_column (column);
-
- try {
- string sqlcmd = "SELECT id, uri, title, note_content FROM notes";
- var statement = database.prepare (sqlcmd);
- while (statement.step ()) {
- var note = new Note ();
- note.id = statement.get_int64 ("id");
- note.uri = statement.get_string ("uri");
- note.title = statement.get_string ("title");
- note.content = statement.get_string ("note_content");
-
- append_note (note);
- }
- } catch (Error error) {
- critical (_("Failed to select from notes database: %s\n"), error.message);
- }
-
- notes_tree_view.show ();
- pack_start (notes_tree_view, false, false, 0);
-
- note_label = new Gtk.Label (null);
- note_label.show ();
- pack_start (note_label, false, false, 0);
-
- note_text_view.set_wrap_mode (Gtk.WrapMode.WORD);
- note_text_view.show ();
- note_text_view.focus_out_event.connect (focus_lost);
- pack_start (note_text_view, true, true, 0);
- }
-
- int tree_sort_func (Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b) {
- Note note1, note2;
- model.get (a, 0, out note1);
- model.get (b, 0, out note2);
- return strcmp (note1.title, note2.title);
- }
-
- void save_current_note () {
- if (current_note != null) {
- string note_content = note_text_view.buffer.text;
- if (note_content != current_note.content)
- current_note.update (note_content);
- }
- }
-
- bool focus_lost (Gdk.EventFocus event) {
- save_current_note ();
- return false;
- }
-
- private void on_render_note_title (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- Note note;
- model.get (iter, 0, out note);
- renderer.set ("markup", GLib.Markup.printf_escaped ("%s", note.title),
- "ellipsize", Pango.EllipsizeMode.END);
- }
-
- private void on_render_icon (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- Note note;
- model.get (iter, 0, out note);
-
- var pixbuf = Midori.Paths.get_icon (note.uri, null);
- if (pixbuf != null) {
- int icon_width = 16, icon_height = 16;
- Gtk.icon_size_lookup_for_settings (get_settings (),
- Gtk.IconSize.MENU, out icon_width, out icon_height);
- pixbuf = pixbuf.scale_simple (icon_width, icon_height, Gdk.InterpType.TILES);
- }
- renderer.set ("pixbuf", pixbuf);
- }
-
- private void selection_changed (Gtk.TreeSelection selection)
- {
- save_current_note ();
- show_note_content (selection);
- }
-
- bool button_pressed (Gdk.EventButton event) {
- if (event.button == 1) {
- if (event.type == Gdk.EventType.2BUTTON_PRESS) {
- return show_note_webpage_in_new_tab (event, false);
- }
- }
- if (event.button == 2)
- return show_note_webpage_in_new_tab (event, true);
- if (event.button == 3)
- return show_popup_menu (event);
- return false;
- }
-
- bool show_note_content (Gtk.TreeSelection selection) {
- Gtk.TreeIter iter;
- if (selection.get_selected (null, out iter)) {
- Note note;
- notes_list_store.get (iter, 0, out note);
-
- if (note != current_note) {
- note_text_view.buffer.text = note.content;
- current_note = note;
- }
-
- return true;
- } else {
- note_text_view.buffer.text = "";
- }
- return false;
- }
-
- bool show_note_webpage_in_new_tab (Gdk.EventButton? event, bool new_tab) {
- Gtk.TreeIter iter;
- if (notes_tree_view.get_selection ().get_selected (null, out iter)) {
- Note note;
- notes_list_store.get (iter, 0, out note);
- if (note.uri != null) {
- var browser = Midori.Browser.get_for_widget (notes_tree_view);
- if (new_tab) {
- browser.add_uri (note.uri);
- } else {
- var tab = browser.tab as Midori.View;
- tab.set_uri (note.uri);
- }
- return true;
- }
- }
- return false;
- }
-
- bool show_popup_menu (Gdk.EventButton? event) {
- return_val_if_fail (event.window == notes_tree_view.get_bin_window(), false);
- Gtk.TreePath path = null;
- notes_tree_view.get_path_at_pos ((int)event.x, (int)event.y, out path,
- null, null, null);
- if (path != null) {
- Gtk.TreeIter iter;
- notes_list_store.get_iter (out iter, path);
- Note note;
- notes_list_store.get (iter, 0, out note);
-
- var menu = new Gtk.Menu ();
-
- var menuitem = new Gtk.ImageMenuItem.with_label (_("Rename note"));
- var image = new Gtk.Image.from_stock (Gtk.STOCK_EDIT, Gtk.IconSize.MENU);
- menuitem.always_show_image = true;
- menuitem.set_image (image);
- menuitem.activate.connect (() => {
- notes_tree_view.set_cursor (path,
- notes_tree_view.get_column (1), true);
- });
- menu.append (menuitem);
-
-
- menuitem = new Gtk.ImageMenuItem.with_label (_("Copy note to clipboard"));
- image = new Gtk.Image.from_stock (Gtk.STOCK_COPY, Gtk.IconSize.MENU);
- menuitem.always_show_image = true;
- menuitem.set_image (image);
- menuitem.activate.connect (() => {
- get_clipboard (Gdk.SELECTION_CLIPBOARD).set_text (note.content, -1);
- });
- menu.append (menuitem);
-
-
- menuitem = new Gtk.ImageMenuItem.with_label (_("Remove note"));
- image = new Gtk.Image.from_stock (Gtk.STOCK_DELETE, Gtk.IconSize.MENU);
- menuitem.always_show_image = true;
- menuitem.set_image (image);
- menuitem.activate.connect (() => {
- note.remove ();
- });
- menu.append (menuitem);
-
- menu.show_all ();
- Katze.widget_popup (notes_tree_view, menu, null, Katze.MenuPos.CURSOR);
- return true;
- }
- return false;
- }
- }
-
-
- private class Manager : Midori.Extension {
- internal GLib.List<Gtk.Widget> widgets;
-
- void tab_added (Midori.Browser browser, Midori.Tab tab) {
-
- tab.context_menu.connect (add_menu_items);
-
- }
-
- void add_menu_items (Midori.Tab tab, WebKit.HitTestResult hit_test_result, Midori.ContextAction menu) {
-#if !HAVE_WEBKIT2
- if ((hit_test_result.context & WebKit.HitTestResultContext.SELECTION) == 0)
- return;
-#endif
-
- var view = tab as Midori.View;
- var action = new Gtk.Action ("Notes", _("Copy selection as note"), null, null);
- action.activate.connect ((action)=> {
- if (view.has_selection () == true)
- {
- string selected_text = view.get_selected_text ();
- string uri = view.get_display_uri ();
- string title = view.get_display_title ();
- var note = new Note();
- note.add (title, uri, selected_text);
- }
- });
-
- menu.add (action);
- }
-
- void browser_added (Midori.Browser browser) {
- var viewable = new Sidebar ();
- viewable.show ();
- browser.panel.append_page (viewable);
- widgets.append (viewable);
-
- foreach (var tab in browser.get_tabs ())
- tab_added (browser, tab);
-
- browser.add_tab.connect (tab_added);
- }
-
- void activated (Midori.App app) {
- string config_path = this.get_config_dir () ?? ":memory:";
- string db_path = GLib.Path.build_path (Path.DIR_SEPARATOR_S, config_path, "notes.db");
- try {
- database = new Midori.Database (db_path);
- } catch (Midori.DatabaseError schema_error) {
- error (schema_error.message);
- }
- db = database.db;
-
- widgets = new GLib.List<Gtk.Widget> ();
- app.add_browser.connect (browser_added);
- foreach (var browser in app.get_browsers ())
- browser_added (browser);
- }
-
- void deactivated () {
- var app = get_app ();
- app.add_browser.disconnect (browser_added);
- foreach (var widget in widgets)
- widget.destroy ();
- }
-
- internal Manager () {
- GLib.Object (name: _("Notes"),
- description: _("Save text clips from websites as notes"),
- version: "0.1" + Midori.VERSION_SUFFIX,
- authors: "Paweł Forysiuk");
-
- this.activate.connect (activated);
- this.deactivate.connect (deactivated);
- }
- }
-
-}
-
-public Midori.Extension extension_init () {
- return new ClipNotes.Manager ();
-}
diff --git a/extensions/nsplugin-manager.vala b/extensions/nsplugin-manager.vala
deleted file mode 100644
index 264d0b46..00000000
--- a/extensions/nsplugin-manager.vala
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- Copyright (C) 2012 André Stösel <andre@stoesel.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.
-*/
-
-namespace NSPlugins {
- private int active_plugins = 0;
-
- private class Extension : Midori.Extension {
- protected WebKit.WebPlugin plugin;
-
- void activated (Midori.App app) {
- active_plugins += 1;
- this.plugin.set_enabled (true);
- app.settings.enable_plugins = active_plugins > 0;
- }
-
- void deactivated () {
- Midori.App app = this.get_app ();
- active_plugins -= 1;
- this.plugin.set_enabled (false);
- app.settings.enable_plugins = active_plugins > 0;
- }
-
- internal Extension (WebKit.WebPlugin plugin) {
- string desc = plugin.get_description ();
- try {
- var regex = new Regex ("<a.+href.+>(.+)</a>");
- desc = regex.replace (desc, -1, 0, "<u>\\1</u>");
- desc = desc.replace ("<br>", "\n");
- }
- catch (Error error) { }
- GLib.Object (stock_id: Midori.Stock.PLUGINS,
- name: plugin.get_name (),
- description: desc,
- use_markup: true,
- key: GLib.Path.get_basename (plugin.get_path ()),
- version: "(%s)".printf ("Netscape plugins"),
- authors: "");
-
- this.plugin = plugin;
- this.plugin.set_enabled (false);
-
- this.activate.connect (activated);
- this.deactivate.connect (deactivated);
- }
- }
-}
-
-public Katze.Array? extension_init () {
- if (!Midori.WebSettings.has_plugin_support ())
- return null;
-
- var extensions = new Katze.Array( typeof (Midori.Extension));
- WebKit.WebPluginDatabase pdb = WebKit.get_web_plugin_database ();
- SList<WebKit.WebPlugin> plugins = pdb.get_plugins ();
-
- foreach (WebKit.WebPlugin plugin in plugins) {
- if (Midori.WebSettings.skip_plugin (plugin.get_path ()))
- continue;
- extensions.add_item (new NSPlugins.Extension (plugin));
- }
- return extensions;
-}
-
diff --git a/extensions/open-with.vala b/extensions/open-with.vala
deleted file mode 100644
index bd31de2e..00000000
--- a/extensions/open-with.vala
+++ /dev/null
@@ -1,846 +0,0 @@
-/*
- Copyright (C) 2014 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.
-*/
-
-#if HAVE_WIN32
-namespace Sokoke {
- extern static Gdk.Pixbuf get_gdk_pixbuf_from_win32_executable (string path);
-}
-#endif
-
-namespace ExternalApplications {
- /* Spawn the application specified by @app_info on the uri, trying to
- remember the association between the content-type and the application
- chosen
- Returns whether the application was spawned successfully. */
- bool open_app_info (AppInfo app_info, string uri, string content_type) {
- Midori.URI.recursive_fork_protection (uri, true);
-
- try {
- var uris = new List<File> ();
- uris.append (File.new_for_uri (uri));
- app_info.launch (uris, null);
- } catch (Error error) {
- warning ("Failed to open \"%s\": %s", uri, error.message);
- return false;
- }
- /* Failing to save the association is a non-fatal error so report success */
- try {
- new Associations ().remember (content_type, app_info);
- } catch (Error error) {
- warning ("Failed to save association for \"%s\": %s", uri, error.message);
- }
- return true;
- }
-
- class Associations : Object {
-#if HAVE_WIN32
- string config_dir;
- string filename;
- KeyFile keyfile;
-
- public Associations () {
- config_dir = Midori.Paths.get_extension_config_dir ("open-with");
- filename = Path.build_filename (config_dir, "config");
- keyfile = new KeyFile ();
-
- try {
- keyfile.load_from_file (filename, KeyFileFlags.NONE);
- } catch (FileError.NOENT exist_error) {
- /* It's no error if no config file exists */
- } catch (Error error) {
- warning ("Failed to load associations: %s", error.message);
- }
- }
-
- /* Determine a handler command-line for @content_type and spawn it on @uri.
- Returns whether a handler was found and spawned successfully. */
- public bool open (string content_type, string uri) {
- Midori.URI.recursive_fork_protection (uri, true);
- try {
- string commandline = keyfile.get_string ("mimes", content_type);
- if ("%u" in commandline)
- commandline = commandline.replace ("%u", Shell.quote (uri));
- else if ("%F" in commandline)
- commandline = commandline.replace ("%F", Shell.quote (Filename.from_uri (uri)));
- return Process.spawn_command_line_async (commandline);
- } catch (KeyFileError error) {
- /* Not remembered before */
- return false;
- } catch (Error error) {
- warning ("Failed to open \"%s\": %s", uri, error.message);
- return false;
- }
- }
-
- /* Save @app_info in the persistent store as the handler for @content_type */
- public void remember (string content_type, AppInfo app_info) throws Error {
- keyfile.set_string ("mimes", content_type, get_commandline (app_info));
- FileUtils.set_contents (filename, keyfile.to_data ());
- }
-
- /* Save @commandline in the persistent store as the handler for @content_type */
- public void remember_custom_commandline (string content_type, string commandline, string name, string uri) {
- keyfile.set_string ("mimes", content_type, commandline);
- try {
- FileUtils.set_contents (filename, keyfile.to_data ());
- } catch (Error error) {
- warning ("Failed to remember custom command line for \"%s\": %s", uri, error.message);
- }
- open (content_type, uri);
- }
- }
-#else
- public Associations () {
- }
-
- /* Find a handler application for @content_type and spawn it on @uri.
- Returns whether a handler was found and spawned successfully. */
- public bool open (string content_type, string uri) {
- var app_info = AppInfo.get_default_for_type (content_type, false);
- if (app_info == null)
- return false;
- return open_app_info (app_info, uri, content_type);
- }
-
- /* Save @app_info as the last-used handler for @content_type */
- public void remember (string content_type, AppInfo app_info) throws Error {
- app_info.set_as_last_used_for_type (content_type);
- app_info.set_as_default_for_type (content_type);
- }
-
- /* Save @commandline as a new system MIME handler for @content_type */
- public void remember_custom_commandline (string content_type, string commandline, string name, string uri) {
- try {
- var app_info = AppInfo.create_from_commandline (commandline, name,
- "%u" in commandline ? AppInfoCreateFlags.SUPPORTS_URIS : AppInfoCreateFlags.NONE);
- open_app_info (app_info, uri, content_type);
- } catch (Error error) {
- warning ("Failed to remember custom command line for \"%s\": %s", uri, error.message);
- }
- }
- }
-#endif
-
- static string get_commandline (AppInfo app_info) {
- return app_info.get_commandline () ?? app_info.get_executable ();
- }
-
- /* Generate markup of the application's name followed by a description line. */
- static string describe_app_info (AppInfo app_info) {
- string name = app_info.get_display_name () ?? (Path.get_basename (app_info.get_executable ()));
- string desc = app_info.get_description () ?? get_commandline (app_info);
- return Markup.printf_escaped ("<b>%s</b>\n%s", name, desc);
- }
-
- static Icon? app_info_get_icon (AppInfo app_info) {
- #if HAVE_WIN32
- return Sokoke.get_gdk_pixbuf_from_win32_executable (app_info.get_executable ());
- #else
- return app_info.get_icon ();
- #endif
- }
-
- class CustomizerDialog : Gtk.Dialog {
- public Gtk.Entry name_entry;
- public Gtk.Entry commandline_entry;
-
- public CustomizerDialog (AppInfo app_info, Gtk.Widget widget) {
- var browser = Midori.Browser.get_for_widget (widget);
- transient_for = browser;
-
- title = _("Custom…");
-#if !HAVE_GTK3
- has_separator = false;
-#endif
- destroy_with_parent = true;
- set_icon_name (Gtk.STOCK_OPEN);
- resizable = false;
- add_buttons (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
- Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT);
-
- var vbox = new Gtk.VBox (false, 8);
- vbox.border_width = 8;
- (get_content_area () as Gtk.Box).pack_start (vbox, true, true, 8);
-
- var sizegroup = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
- var label = new Gtk.Label (_("Name:"));
- sizegroup.add_widget (label);
- label.set_alignment (0.0f, 0.5f);
- vbox.pack_start (label, false, false, 0);
- name_entry = new Gtk.Entry ();
- name_entry.activates_default = true;
- sizegroup.add_widget (name_entry);
- vbox.pack_start (name_entry, true, true, 0);
-
- label = new Gtk.Label (_("Command Line:"));
- sizegroup.add_widget (label);
- label.set_alignment (0.0f, 0.5f);
- vbox.pack_start (label, false, false, 0);
- commandline_entry = new Gtk.Entry ();
- commandline_entry.activates_default = true;
- sizegroup.add_widget (name_entry);
- sizegroup.add_widget (commandline_entry);
- vbox.pack_start (commandline_entry, true, true, 0);
- get_content_area ().show_all ();
- set_default_response (Gtk.ResponseType.ACCEPT);
-
- name_entry.text = app_info.get_name ();
- commandline_entry.text = get_commandline (app_info);
- }
- }
-
- private class Chooser : Gtk.VBox {
- Gtk.ListStore store = new Gtk.ListStore (1, typeof (AppInfo));
- Gtk.TreeView treeview;
- List<AppInfo> available;
- string content_type;
- string uri;
-
- public Chooser (string uri, string content_type) {
- this.content_type = content_type;
- this.uri = uri;
-
- Gtk.TreeViewColumn column;
-
- treeview = new Gtk.TreeView.with_model (store);
- treeview.headers_visible = false;
-
- store.set_sort_column_id (0, Gtk.SortType.ASCENDING);
- store.set_sort_func (0, tree_sort_func);
-
- column = new Gtk.TreeViewColumn ();
- Gtk.CellRendererPixbuf renderer_icon = new Gtk.CellRendererPixbuf ();
- column.pack_start (renderer_icon, false);
- column.set_cell_data_func (renderer_icon, on_render_icon);
- treeview.append_column (column);
-
- column = new Gtk.TreeViewColumn ();
- column.set_sizing (Gtk.TreeViewColumnSizing.AUTOSIZE);
- Gtk.CellRendererText renderer_text = new Gtk.CellRendererText ();
- column.pack_start (renderer_text, true);
- column.set_expand (true);
- column.set_cell_data_func (renderer_text, on_render_text);
- treeview.append_column (column);
-
- treeview.row_activated.connect (row_activated);
- treeview.show ();
- var scrolled = new Gtk.ScrolledWindow (null, null);
- scrolled.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
- scrolled.add (treeview);
- pack_start (scrolled);
- int height;
- treeview.create_pango_layout ("a\nb").get_pixel_size (null, out height);
- scrolled.set_size_request (-1, height * 5);
- treeview.button_release_event.connect (button_released);
- treeview.tooltip_text = _("Right-click a suggestion to customize it");
-
- available = new List<AppInfo> ();
- foreach (var app_info in AppInfo.get_all_for_type (content_type))
- launcher_added (app_info, uri);
-
- if (store.iter_n_children (null) < 1) {
- foreach (var app_info in AppInfo.get_all ())
- launcher_added (app_info, uri);
- }
- }
-
- bool button_released (Gdk.EventButton event) {
- if (event.button == 3)
- return show_popup_menu (event);
- return false;
- }
-
- bool show_popup_menu (Gdk.EventButton? event) {
- Gtk.TreeIter iter;
- if (treeview.get_selection ().get_selected (null, out iter)) {
- AppInfo app_info;
- store.get (iter, 0, out app_info);
-
- var menu = new Gtk.Menu ();
- var menuitem = new Gtk.ImageMenuItem.with_mnemonic (_("Custom…"));
- menuitem.image = new Gtk.Image.from_stock (Gtk.STOCK_EDIT, Gtk.IconSize.MENU);
- menuitem.activate.connect (() => {
- customize_app_info (app_info, content_type, uri);
- });
- menu.append (menuitem);
- menu.show_all ();
- Katze.widget_popup (treeview, menu, null, Katze.MenuPos.CURSOR);
-
- return true;
- }
- return false;
- }
-
- void customize_app_info (AppInfo app_info, string content_type, string uri) {
- var dialog = new CustomizerDialog (app_info, this);
- bool accept = dialog.run () == Gtk.ResponseType.ACCEPT;
- if (accept) {
- string name = dialog.name_entry.text;
- string commandline = dialog.commandline_entry.text;
- new Associations ().remember_custom_commandline (content_type, commandline, name, uri);
- customized (app_info, content_type, uri);
- }
- dialog.destroy ();
- }
-
- public List<AppInfo> get_available () {
- return available.copy ();
- }
-
- public AppInfo get_app_info () {
- Gtk.TreeIter iter;
- if (treeview.get_selection ().get_selected (null, out iter)) {
- AppInfo app_info;
- store.get (iter, 0, out app_info);
- return app_info;
- }
- assert_not_reached ();
- }
-
- void on_render_icon (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- AppInfo app_info;
- model.get (iter, 0, out app_info);
-
- renderer.set ("gicon", app_info_get_icon (app_info),
- "stock-size", Gtk.IconSize.DIALOG,
- "xpad", 4);
- }
-
- void on_render_text (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- AppInfo app_info;
- model.get (iter, 0, out app_info);
- renderer.set ("markup", describe_app_info (app_info),
- "ellipsize", Pango.EllipsizeMode.END);
- }
-
- void launcher_added (AppInfo app_info, string uri) {
- if (!app_info.should_show ())
- return;
-
- Gtk.TreeIter iter;
- store.append (out iter);
- store.set (iter, 0, app_info);
-
- available.append (app_info);
- }
-
- int tree_sort_func (Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b) {
- AppInfo app_info1, app_info2;
- model.get (a, 0, out app_info1);
- model.get (b, 0, out app_info2);
- return strcmp (app_info1.get_display_name (), app_info2.get_display_name ());
- }
-
- void row_activated (Gtk.TreePath path, Gtk.TreeViewColumn column) {
- Gtk.TreeIter iter;
- if (store.get_iter (out iter, path)) {
- AppInfo app_info;
- store.get (iter, 0, out app_info);
- selected (app_info);
- }
- }
-
- public signal void selected (AppInfo app_info);
- public signal void customized (AppInfo app_info, string content_type, string uri);
- }
-
- class ChooserDialog : Gtk.Dialog {
- public Chooser chooser { get; private set; }
-
- public ChooserDialog (string uri, string content_type, Gtk.Widget widget) {
- string filename;
- if (uri.has_prefix ("file://"))
- filename = Midori.Download.get_basename_for_display (uri);
- else
- filename = uri;
-
- var browser = Midori.Browser.get_for_widget (widget);
- transient_for = browser;
-
- title = _("Choose application");
-#if !HAVE_GTK3
- has_separator = false;
-#endif
- destroy_with_parent = true;
- set_icon_name (Gtk.STOCK_OPEN);
- resizable = true;
- add_buttons (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
- Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT);
-
- var vbox = new Gtk.VBox (false, 8);
- vbox.border_width = 8;
- (get_content_area () as Gtk.Box).pack_start (vbox, true, true, 8);
- var label = new Gtk.Label (_("Select an application to open \"%s\"".printf (filename)));
- label.ellipsize = Pango.EllipsizeMode.MIDDLE;
- vbox.pack_start (label, false, false, 0);
- if (uri == "")
- label.no_show_all = true;
- chooser = new Chooser (uri, content_type);
- vbox.pack_start (chooser, true, true, 0);
-
- get_content_area ().show_all ();
-
- Gtk.Requisition req;
-#if HAVE_GTK3
- get_content_area ().get_preferred_size (null, out req);
-#else
- get_content_area ().size_request (out req);
-#endif
- (this as Gtk.Window).set_default_size (req.width*2, req.height*3/2);
-
- set_default_response (Gtk.ResponseType.ACCEPT);
- chooser.selected.connect ((app_info) => {
- response (Gtk.ResponseType.ACCEPT);
- });
- chooser.customized.connect ((app_info, content_type, uri) => {
- response (Gtk.ResponseType.CANCEL);
- });
- }
-
- public AppInfo? open_with () {
- show ();
- bool accept = run () == Gtk.ResponseType.ACCEPT;
- hide ();
-
- if (!accept)
- return null;
- return chooser.get_app_info ();
- }
- }
-
- class ChooserButton : Gtk.Button {
- public AppInfo? app_info { get; set; }
- public string? commandline { get; set; }
- ChooserDialog dialog;
- Gtk.Label app_name;
- Gtk.Image icon;
-
- public ChooserButton (string mime_type, string? commandline) {
- string content_type = ContentType.from_mime_type (mime_type);
- dialog = new ChooserDialog ("", content_type, this);
- app_info = null;
- foreach (var candidate in dialog.chooser.get_available ()) {
- if (get_commandline (candidate) == commandline)
- app_info = candidate;
- }
-
- var hbox = new Gtk.HBox (false, 4);
- icon = new Gtk.Image ();
- hbox.pack_start (icon, false, false, 0);
- app_name = new Gtk.Label (null);
- app_name.use_markup = true;
- app_name.ellipsize = Pango.EllipsizeMode.END;
- hbox.pack_start (app_name, true, true, 0);
- add (hbox);
- show_all ();
- update_label ();
-
- clicked.connect (() => {
- dialog.transient_for = this.get_toplevel () as Gtk.Window;
- app_info = dialog.open_with ();
- string new_commandline = app_info != null ? get_commandline (app_info) : null;
- commandline = new_commandline;
- selected (new_commandline);
- update_label ();
- });
- }
-
- void update_label () {
- app_name.label = app_info != null ? describe_app_info (app_info).replace ("\n", " ") : _("None");
- icon.set_from_gicon (app_info != null ? app_info_get_icon (app_info) : null, Gtk.IconSize.BUTTON);
- }
-
- public signal void selected (string? commandline);
- }
-
- class Types : Gtk.VBox {
- public Gtk.ListStore store = new Gtk.ListStore (2, typeof (string), typeof (AppInfo));
- Gtk.TreeView treeview;
-
- public Types () {
- Gtk.TreeViewColumn column;
-
- treeview = new Gtk.TreeView.with_model (store);
- treeview.headers_visible = false;
-
- store.set_sort_column_id (0, Gtk.SortType.ASCENDING);
- store.set_sort_func (0, tree_sort_func);
-
- column = new Gtk.TreeViewColumn ();
- column.set_sizing (Gtk.TreeViewColumnSizing.AUTOSIZE);
- Gtk.CellRendererPixbuf renderer_type_icon = new Gtk.CellRendererPixbuf ();
- column.pack_start (renderer_type_icon, false);
- column.set_cell_data_func (renderer_type_icon, on_render_type_icon);
- treeview.append_column (column);
-
- column = new Gtk.TreeViewColumn ();
- column.set_sizing (Gtk.TreeViewColumnSizing.AUTOSIZE);
- Gtk.CellRendererText renderer_type_text = new Gtk.CellRendererText ();
- column.pack_start (renderer_type_text, true);
- column.set_expand (true);
- column.set_cell_data_func (renderer_type_text, on_render_type_text);
- treeview.append_column (column);
-
- column = new Gtk.TreeViewColumn ();
- column.set_sizing (Gtk.TreeViewColumnSizing.AUTOSIZE);
- Gtk.CellRendererPixbuf renderer_icon = new Gtk.CellRendererPixbuf ();
- column.pack_start (renderer_icon, false);
- column.set_cell_data_func (renderer_icon, on_render_icon);
- treeview.append_column (column);
-
- column = new Gtk.TreeViewColumn ();
- column.set_sizing (Gtk.TreeViewColumnSizing.AUTOSIZE);
- Gtk.CellRendererText renderer_text = new Gtk.CellRendererText ();
- column.pack_start (renderer_text, true);
- column.set_expand (true);
- column.set_cell_data_func (renderer_text, on_render_text);
- treeview.append_column (column);
-
- treeview.row_activated.connect (row_activated);
- treeview.show ();
- var scrolled = new Gtk.ScrolledWindow (null, null);
- scrolled.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
- scrolled.add (treeview);
- pack_start (scrolled);
- int height;
- treeview.create_pango_layout ("a\nb").get_pixel_size (null, out height);
- scrolled.set_size_request (-1, height * 5);
-
- foreach (unowned string content_type in ContentType.list_registered ())
- launcher_added (content_type);
- foreach (unowned string scheme in Vfs.get_default ().get_supported_uri_schemes ())
- launcher_added ("x-scheme-handler/" + scheme);
-
- treeview.size_allocate.connect_after ((allocation) => {
- treeview.columns_autosize ();
- });
- }
-
- void on_render_type_icon (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- string content_type;
- store.get (iter, 0, out content_type);
-
- renderer.set ("gicon", ContentType.get_icon (content_type),
- "stock-size", Gtk.IconSize.BUTTON,
- "xpad", 4);
- }
-
- void on_render_type_text (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- string content_type;
- AppInfo app_info;
- store.get (iter, 0, out content_type, 1, out app_info);
-
- string desc, mime_type;
- if (content_type.has_prefix ("x-scheme-handler/")) {
- desc = content_type.split ("/")[1] + "://";
- mime_type = "";
- } else {
- desc = ContentType.get_description (content_type);
- mime_type = ContentType.get_mime_type (content_type);
- }
-
- renderer.set ("markup",
- Markup.printf_escaped ("<b>%s</b>\n%s",
- desc, mime_type),
-#if HAVE_GTK3
- "max-width-chars", 30,
-#endif
- "width-chars", 30,
- "ellipsize", Pango.EllipsizeMode.END);
- }
-
- void on_render_icon (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- AppInfo app_info;
- model.get (iter, 1, out app_info);
-
- renderer.set ("gicon", app_info_get_icon (app_info),
- "stock-size", Gtk.IconSize.MENU,
- "xpad", 4);
- }
-
- void on_render_text (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- AppInfo app_info;
- model.get (iter, 1, out app_info);
- renderer.set ("markup", describe_app_info (app_info),
-#if HAVE_GTK3
- "max-width-chars", 30,
-#endif
- "width-chars", 30,
- "ellipsize", Pango.EllipsizeMode.END);
- }
-
- void launcher_added (string content_type) {
- var app_info = AppInfo.get_default_for_type (content_type, false);
- if (app_info == null)
- return;
-
- Gtk.TreeIter iter;
- store.append (out iter);
- store.set (iter, 0, content_type, 1, app_info);
- }
-
- int tree_sort_func (Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b) {
- string content_type1, content_type2;
- model.get (a, 0, out content_type1);
- model.get (b, 0, out content_type2);
- return strcmp (content_type1, content_type2);
- }
-
- void row_activated (Gtk.TreePath path, Gtk.TreeViewColumn column) {
- Gtk.TreeIter iter;
- if (store.get_iter (out iter, path)) {
- string content_type;
- store.get (iter, 0, out content_type);
- selected (content_type, iter);
- }
- }
-
- public signal void selected (string content_type, Gtk.TreeIter iter);
- }
-
-
- private class Manager : Midori.Extension {
- enum NextStep {
- TRY_OPEN,
- OPEN_WITH
- }
-
- bool open_uri (Midori.Tab tab, string uri) {
- string content_type = get_content_type (uri, null);
- return open_with_type (uri, content_type, tab, NextStep.TRY_OPEN);
- }
-
- bool navigation_requested (Midori.Tab tab, string uri) {
- /* FIXME: Make this a list of known/internal uris to pass-thru */
- if (uri.has_prefix ("file://") || Midori.URI.is_http (uri) || Midori.URI.is_blank (uri))
- return false;
-
- /* Don't find app for abp links, we should handle them internally */
- if (uri.has_prefix("abp:"))
- return true;
-
- string content_type = get_content_type (uri, null);
- open_with_type (uri, content_type, tab, NextStep.TRY_OPEN);
- return true;
- }
-
- string get_content_type (string uri, string? mime_type) {
- if (!uri.has_prefix ("file://") && !Midori.URI.is_http (uri)) {
- string protocol = uri.split(":", 2)[0];
- return "x-scheme-handler/" + protocol;
- } else if (mime_type == null) {
- string filename;
- bool uncertain;
- try {
- filename = Filename.from_uri (uri);
- } catch (Error error) {
- filename = uri;
- }
- return ContentType.guess (filename, null, out uncertain);
- }
- return ContentType.from_mime_type (mime_type);
- }
-
- /* Returns %TRUE if the attempt to download and open failed immediately, %FALSE otherwise */
- bool open_with_type (string uri, string content_type, Gtk.Widget widget, NextStep next_step) {
- #if HAVE_WEBKIT2
- return open_now (uri, content_type, widget, next_step);
- #else
- if (!Midori.URI.is_http (uri))
- return open_now (uri, content_type, widget, next_step);
- /* Don't download websites */
- if (content_type == "application/octet-stream")
- return open_now (uri, content_type, widget, next_step);
-
- var download = new WebKit.Download (new WebKit.NetworkRequest (uri));
- download.destination_uri = Midori.Download.prepare_destination_uri (download, null);
- if (!Midori.Download.has_enough_space (download, download.destination_uri))
- return false;
-
- download.notify["status"].connect ((pspec) => {
- if (download.status == WebKit.DownloadStatus.FINISHED) {
- open_now (download.destination_uri, content_type, widget, next_step);
- }
- else if (download.status == WebKit.DownloadStatus.ERROR)
- Midori.show_message_dialog (Gtk.MessageType.ERROR,
- _("Download error"),
- _("Cannot open '%s' because the download failed."
- ).printf (download.destination_uri), false);
- });
- download.start ();
- return true;
- #endif
- }
-
- /* If @next_step is %NextStep.TRY_OPEN, tries to pick a handler automatically.
- If the automatic handler did not exist or could not run, asks for an application.
- Returns whether an application was found and launched successfully. */
- bool open_now (string uri, string content_type, Gtk.Widget widget, NextStep next_step) {
- if (next_step == NextStep.TRY_OPEN && (new Associations ()).open (content_type, uri))
- return true;
- /* if opening directly failed or wasn't tried, ask for an association */
- if (open_with (uri, content_type, widget) != null)
- return true;
- return false;
- }
-
- /* Returns the application chosen to open the uri+content_type if the application
- was spawned successfully, %NULL if none was chosen or running was unsuccessful. */
- AppInfo? open_with (string uri, string content_type, Gtk.Widget widget) {
- var dialog = new ChooserDialog (uri, content_type, widget);
-
- var app_info = dialog.open_with ();
- dialog.destroy ();
-
- if (uri == "")
- return app_info;
-
- if (app_info == null)
- return app_info;
-
- return open_app_info (app_info, uri, content_type) ? app_info : null;
- }
-
- void context_menu (Midori.Tab tab, WebKit.HitTestResult hit_test_result, Midori.ContextAction menu) {
- if ((hit_test_result.context & WebKit.HitTestResultContext.LINK) != 0) {
- string uri = hit_test_result.link_uri;
- var action = new Gtk.Action ("OpenWith", _("Open _with…"), null, null);
- action.activate.connect ((action) => {
- open_with_type (uri, get_content_type (uri, null), tab, NextStep.OPEN_WITH);
- });
- menu.add (action);
- }
-#if !HAVE_WEBKIT2
- if ((hit_test_result.context & WebKit.HitTestResultContext.IMAGE) != 0) {
- string uri = hit_test_result.image_uri;
- var action = new Gtk.Action ("OpenImageInViewer", _("Open in Image _Viewer"), null, null);
- action.activate.connect ((action) => {
- open_with_type (uri, get_content_type (uri, null), tab, NextStep.TRY_OPEN);
- });
- menu.add (action);
- }
-#endif
- }
-
- void show_preferences (Katze.Preferences preferences) {
- var settings = get_app ().settings;
- var category = preferences.add_category (_("File Types"), Gtk.STOCK_FILE);
- preferences.add_group (null);
-
- var sizegroup = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
- var label = new Gtk.Label (_("Text Editor"));
- sizegroup.add_widget (label);
- label.set_alignment (0.0f, 0.5f);
- preferences.add_widget (label, "indented");
- var entry = new ChooserButton ("text/plain", settings.text_editor);
- sizegroup.add_widget (entry);
- entry.selected.connect ((commandline) => {
- settings.text_editor = commandline;
- });
- preferences.add_widget (entry, "spanned");
-
- label = new Gtk.Label (_("News Aggregator"));
- sizegroup.add_widget (label);
- label.set_alignment (0.0f, 0.5f);
- preferences.add_widget (label, "indented");
- entry = new ChooserButton ("application/rss+xml", settings.news_aggregator);
- sizegroup.add_widget (entry);
- entry.selected.connect ((commandline) => {
- settings.news_aggregator = commandline;
- });
- preferences.add_widget (entry, "spanned");
-
- var types = new Types ();
- types.selected.connect ((content_type, iter) => {
- var app_info = open_with ("", content_type, preferences);
- if (app_info == null)
- return;
- try {
- app_info.set_as_default_for_type (content_type);
- types.store.set (iter, 1, app_info);
- } catch (Error error) {
- warning ("Failed to select default for \"%s\": %s", content_type, error.message);
- }
- });
- category.pack_start (types, true, true, 0);
- types.show_all ();
- }
-
- public void tab_added (Midori.Browser browser, Midori.View view) {
- view.navigation_requested.connect_after (navigation_requested);
- view.open_uri.connect (open_uri);
- view.context_menu.connect (context_menu);
- }
-
- public void tab_removed (Midori.Browser browser, Midori.View view) {
- view.navigation_requested.disconnect (navigation_requested);
- view.open_uri.disconnect (open_uri);
- view.context_menu.disconnect (context_menu);
- }
-
- void browser_added (Midori.Browser browser) {
- foreach (var tab in browser.get_tabs ())
- tab_added (browser, tab);
- browser.add_tab.connect (tab_added);
- browser.remove_tab.connect (tab_removed);
- browser.show_preferences.connect (show_preferences);
- }
-
- void activated (Midori.App app) {
- foreach (var browser in app.get_browsers ())
- browser_added (browser);
- app.add_browser.connect (browser_added);
- }
-
- void browser_removed (Midori.Browser browser) {
- foreach (var tab in browser.get_tabs ())
- tab_removed (browser, tab);
- browser.add_tab.disconnect (tab_added);
- browser.remove_tab.disconnect (tab_removed);
- browser.show_preferences.disconnect (show_preferences);
- }
-
- void deactivated () {
- var app = get_app ();
- foreach (var browser in app.get_browsers ())
- browser_removed (browser);
- app.add_browser.disconnect (browser_added);
-
- }
-
- internal Manager () {
- GLib.Object (name: "External Applications",
- description: "Choose what to open unknown file types with",
- version: "0.1" + Midori.VERSION_SUFFIX,
- authors: "Christian Dywan <christian@twotoasts.de>");
-
- this.activate.connect (activated);
- this.deactivate.connect (deactivated);
- }
- }
-}
-
-public Midori.Extension extension_init () {
- return new ExternalApplications.Manager ();
-}
-
diff --git a/extensions/shortcuts.c b/extensions/shortcuts.c
deleted file mode 100644
index 79453ad5..00000000
--- a/extensions/shortcuts.c
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- Copyright (C) 2009 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.
-*/
-
-#include <midori/midori.h>
-
-#include "config.h"
-
-static void
-shortcuts_browser_populate_tool_menu_cb (MidoriBrowser* browser,
- GtkWidget* menu,
- MidoriExtension* extension);
-
-static void
-shortcuts_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension);
-
-static void
-shortcuts_deactivate_cb (MidoriExtension* extension,
- MidoriBrowser* browser)
-{
- MidoriApp* app = midori_extension_get_app (extension);
-
- g_signal_handlers_disconnect_by_func (
- browser, shortcuts_browser_populate_tool_menu_cb, extension);
- g_signal_handlers_disconnect_by_func (
- extension, shortcuts_deactivate_cb, browser);
- g_signal_handlers_disconnect_by_func (
- app, shortcuts_app_add_browser_cb, extension);
-}
-
-static void
-shortcuts_accel_edited_cb (GtkCellRenderer* renderer,
- const gchar* tree_path,
- guint accel_key,
- GdkModifierType accel_mods,
- guint keycode,
- GtkTreeModel* model)
-{
- GtkTreeIter iter;
-
- if (gtk_tree_model_get_iter_from_string (model, &iter, tree_path))
- {
- GtkAction* action;
- const gchar* accel_path;
- GtkTreeIter child_iter;
- GtkTreeModel* liststore;
-
- gtk_tree_model_get (model, &iter, 6, &action, -1);
- accel_path = gtk_action_get_accel_path (action);
- gtk_accel_map_change_entry (accel_path, accel_key, accel_mods, TRUE);
-
- gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (model),
- &child_iter, &iter);
- liststore = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (model));
- gtk_list_store_set (GTK_LIST_STORE (liststore),
- &child_iter, 1, accel_key, 2, accel_mods, -1);
-
- g_object_unref (action);
- }
-}
-
-static void
-shortcuts_accel_cleared_cb (GtkCellRenderer* renderer,
- const gchar* tree_path,
- GtkTreeModel* model)
-{
- GtkTreeIter iter;
-
- if (gtk_tree_model_get_iter_from_string (model, &iter, tree_path))
- {
- GtkAction* action;
- const gchar* accel_path;
- GtkTreeIter child_iter;
- GtkTreeModel* liststore;
-
- gtk_tree_model_get (model, &iter, 6, &action, -1);
- accel_path = gtk_action_get_accel_path (action);
- gtk_accel_map_change_entry (accel_path, 0, 0, FALSE);
-
- gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (model),
- &child_iter, &iter);
- liststore = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (model));
- gtk_list_store_set (GTK_LIST_STORE (liststore),
- &child_iter, 1, 0, 2, 0, -1);
-
- g_object_unref (action);
- }
-}
-
-static gchar*
-shortcuts_label_for_action (GtkAction* action)
-{
- const gchar* name = gtk_action_get_name (action);
- gchar* label;
- gchar* stripped;
-
- if (g_str_equal (name, "ReloadStop"))
- {
- label = NULL;
- stripped = g_strdup (_("Reload page or stop loading"));
- }
- else if ((label = katze_object_get_string (action, "label")))
- stripped = katze_strip_mnemonics (label);
- else
- {
- GtkStockItem item;
-
- g_object_get (action, "stock-id", &label, NULL);
- if (gtk_stock_lookup (label, &item))
- stripped = katze_strip_mnemonics (item.label);
- else
- stripped = g_strdup ("");
- }
-
- g_free (label);
- return stripped;
-}
-
-static gboolean
-shortcuts_hotkey_for_action (GtkAction* action,
- GtkAccelKey* key)
-{
- const gchar* accel_path = gtk_action_get_accel_path (action);
- if (accel_path)
- if (gtk_accel_map_lookup_entry (accel_path, key))
- return TRUE;
-
- return FALSE;
-}
-
-static GtkWidget*
-shortcuts_get_preferences_dialog (MidoriExtension* extension)
-{
- MidoriApp* app;
- GtkWidget* browser;
- const gchar* dialog_title;
- GtkWidget* dialog;
- gint width, height;
- GtkWidget* xfce_heading;
- GtkWidget* hbox;
- GtkListStore* liststore;
- GtkTreeModel* model;
- GtkWidget* treeview;
- GtkTreeViewColumn* column;
- GtkCellRenderer* renderer;
- GtkWidget* scrolled;
- GtkActionGroup* action_group;
- GList* actions;
- guint i;
- GtkAction* action;
- GtkWidget* dialog_vbox;
- #if HAVE_OSX
- GtkWidget* icon;
- #endif
-
- app = midori_extension_get_app (extension);
- browser = katze_object_get_object (app, "browser");
-
- dialog_title = _("Customize Keyboard shortcuts");
- dialog = gtk_dialog_new_with_buttons (dialog_title, GTK_WINDOW (browser),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
- #if !HAVE_OSX
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
- #endif
- NULL);
- gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PROPERTIES);
- sokoke_widget_get_text_size (dialog, "M", &width, &height);
- gtk_window_set_default_size (GTK_WINDOW (dialog), width * 52, height * 24);
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), dialog);
-
- dialog_vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
- if ((xfce_heading = sokoke_xfce_header_new (
- gtk_window_get_icon_name (GTK_WINDOW (dialog)), dialog_title)))
- gtk_box_pack_start (GTK_BOX (dialog_vbox),
- xfce_heading, FALSE, FALSE, 0);
- hbox = gtk_hbox_new (FALSE, 0);
-
- gtk_box_pack_start (GTK_BOX (dialog_vbox), hbox,
- TRUE, TRUE, 12);
- liststore = gtk_list_store_new (7,
- G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_BOOLEAN,
- G_TYPE_STRING, GTK_TYPE_ACTION);
- model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (liststore));
- treeview = gtk_tree_view_new_with_model (model);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
- column = gtk_tree_view_column_new ();
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "text", 0);
- gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
- column = gtk_tree_view_column_new ();
- renderer = gtk_cell_renderer_accel_new ();
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "accel-key", 1);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "accel-mods", 2);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "accel-mode", 3);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "sensitive", 4);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), renderer, "editable", 4);
- g_signal_connect (renderer, "accel-edited",
- G_CALLBACK (shortcuts_accel_edited_cb), model);
- g_signal_connect (renderer, "accel-cleared",
- G_CALLBACK (shortcuts_accel_cleared_cb), model);
- gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
- scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_container_add (GTK_CONTAINER (scrolled), treeview);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
- GTK_SHADOW_IN);
- gtk_box_pack_start (GTK_BOX (hbox), scrolled, TRUE, TRUE, 5);
-
- action_group = midori_browser_get_action_group (MIDORI_BROWSER (browser));
- actions = gtk_action_group_list_actions (action_group);
- i = 0;
- /* FIXME: Catch added and removed actions */
- while ((action = g_list_nth_data (actions, i++)))
- {
- gchar* label = shortcuts_label_for_action (action);
- GtkAccelKey key;
- gboolean has_hotkey = shortcuts_hotkey_for_action (action, &key);
- gtk_list_store_insert_with_values (GTK_LIST_STORE (liststore),
- NULL, G_MAXINT, 0, label, 1, key.accel_key, 2, key.accel_mods,
- 3, GTK_CELL_RENDERER_ACCEL_MODE_OTHER,
- 4, has_hotkey, 6, action, -1);
- g_free (label);
- }
- g_list_free (actions);
-
- g_object_unref (liststore);
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
- 0, GTK_SORT_ASCENDING);
- g_object_unref (model);
-
- gtk_widget_show_all (gtk_dialog_get_content_area(GTK_DIALOG (dialog)));
-
- g_object_unref (browser);
-
- return dialog;
-}
-
-static void
-shortcuts_menu_configure_shortcuts_activate_cb (GtkWidget* menuitem,
- MidoriExtension* extension)
-{
- static GtkWidget* dialog = NULL;
-
- if (!dialog)
- {
- dialog = shortcuts_get_preferences_dialog (extension);
- g_signal_connect (dialog, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &dialog);
- gtk_widget_show (dialog);
- }
- else
- gtk_window_present (GTK_WINDOW (dialog));
-}
-
-static void
-shortcuts_browser_populate_tool_menu_cb (MidoriBrowser* browser,
- GtkWidget* menu,
- MidoriExtension* extension)
-{
- GtkWidget* menuitem;
-
- menuitem = gtk_menu_item_new_with_mnemonic (_("Customize Sh_ortcuts…"));
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (shortcuts_menu_configure_shortcuts_activate_cb), extension);
- gtk_widget_show (menuitem);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-}
-
-static void
-shortcuts_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension)
-{
- g_signal_connect (browser, "populate-tool-menu",
- G_CALLBACK (shortcuts_browser_populate_tool_menu_cb), extension);
- g_signal_connect (extension, "deactivate",
- G_CALLBACK (shortcuts_deactivate_cb), browser);
-}
-
-static void
-shortcuts_activate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- KatzeArray* browsers;
- MidoriBrowser* browser;
-
- browsers = katze_object_get_object (app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- shortcuts_app_add_browser_cb (app, browser, extension);
- g_signal_connect (app, "add-browser",
- G_CALLBACK (shortcuts_app_add_browser_cb), extension);
- g_object_unref (browsers);
-}
-
-MidoriExtension*
-extension_init (void)
-{
- MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", _("Shortcuts"),
- "description", _("View and edit keyboard shortcuts"),
- "version", "0.1" MIDORI_VERSION_SUFFIX,
- "authors", "Christian Dywan <christian@twotoasts.de>",
- NULL);
-
- g_signal_connect (extension, "activate",
- G_CALLBACK (shortcuts_activate_cb), NULL);
-
- return extension;
-}
diff --git a/extensions/status-clock.c b/extensions/status-clock.c
deleted file mode 100644
index a94a262e..00000000
--- a/extensions/status-clock.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- Copyright (C) 2010 Arno Renevier <arno@renevier.net>
-
- 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.
-*/
-
-/*
- * This extension adds time and/or date in midori statusbar. Format for time
- * display can be configured by creating a desktop entry file named
- * ~/.config/midori/extensions/libclock.so/config
- *
- * That file must contain a section "settings", and a key "format". That format
- * will be used as format parameter to strftime. For example, If you want to
- * display full date and time according to your locale, "config" must contain:
- *
- * [settings]
- * format=%c
- *
- * If that file does not exist, or format specification cannot be read, format
- * fallback to %R which means time will be display with a 24-hour notation. For
- * example, 13:53
- */
-
-#include <midori/midori.h>
-
-#include "config.h"
-
-#define DEFAULT_FORMAT "%R"
-
-static void
-clock_deactivate_cb (MidoriExtension* extension,
- MidoriApp* app);
-
-static void
-clock_set_timeout (MidoriBrowser* browser,
- guint interval);
-
-static gboolean
-clock_set_current_time (MidoriBrowser* browser)
-{
- guint interval;
- MidoriExtension* extension = g_object_get_data (G_OBJECT (browser), "clock-extension");
- GtkWidget* label = g_object_get_data (G_OBJECT (browser), "clock-label");
- const gchar* format = midori_extension_get_string (extension, "format");
-
- GDateTime* date = g_date_time_new_now_local ();
- gint seconds = g_date_time_get_seconds (date);
- gchar* pretty = g_date_time_format (date, format);
- gtk_label_set_label (GTK_LABEL (label), pretty);
- g_free (pretty);
- g_date_time_unref (date);
-
- if (g_strstr_len (format, -1, "%c")
- || g_strstr_len (format, -1, "%N")
- || g_strstr_len (format, -1, "%s")
- || g_strstr_len (format, -1, "%S")
- || g_strstr_len (format, -1, "%T")
- || g_strstr_len (format, -1, "%X")
- )
- interval = 1;
- else
- /* FIXME: Occasionally there are more than 60 seconds in a minute. */
- interval = MAX (60 - seconds, 1);
-
- clock_set_timeout (browser, interval);
-
- return FALSE;
-}
-
-static void
-clock_set_timeout (MidoriBrowser* browser,
- guint interval)
-{
- GSource* source;
- source = g_timeout_source_new_seconds (interval);
- g_source_set_callback (source, (GSourceFunc)clock_set_current_time, browser, NULL);
- g_source_attach (source, NULL);
- g_object_set_data (G_OBJECT (browser), "clock-timer", source);
- g_source_unref (source);
-}
-
-static void
-clock_browser_destroy_cb (MidoriBrowser* browser,
- gpointer data)
-{
- GSource* source;
- source = g_object_get_data (G_OBJECT (browser), "clock-timer");
- g_source_destroy (source);
- g_signal_handlers_disconnect_by_func (browser, clock_browser_destroy_cb, NULL);
-}
-
-static void
-clock_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension)
-{
- GtkWidget* statusbar;
- GtkWidget* label;
-
- label = gtk_label_new (NULL);
-
- statusbar = katze_object_get_object (browser, "statusbar");
- gtk_box_pack_end (GTK_BOX (statusbar), label, FALSE, FALSE, 0);
-
- g_object_set_data (G_OBJECT (browser), "clock-label", label);
- g_object_set_data (G_OBJECT (browser), "clock-extension", extension);
-
- clock_set_current_time (browser);
- gtk_widget_show (label);
-
- g_object_unref (statusbar);
-
- g_signal_connect (browser, "destroy", G_CALLBACK (clock_browser_destroy_cb), NULL);
-}
-
-static void
-clock_deactivate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- KatzeArray* browsers;
- MidoriBrowser* browser;
- GtkWidget* label;
-
- browsers = katze_object_get_object (app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- {
- clock_browser_destroy_cb (browser, NULL);
- label = g_object_get_data (G_OBJECT (browser), "clock-label");
- gtk_widget_destroy (label);
- g_object_set_data (G_OBJECT (browser), "clock-label", NULL);
- }
-
- g_signal_handlers_disconnect_by_func (
- app, clock_app_add_browser_cb, extension);
- g_signal_handlers_disconnect_by_func (
- extension, clock_deactivate_cb, app);
- g_object_unref (browsers);
-}
-
-static void
-clock_activate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- KatzeArray* browsers;
- MidoriBrowser* browser;
-
- browsers = katze_object_get_object (app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- clock_app_add_browser_cb (app, browser, extension);
- g_signal_connect (app, "add-browser",
- G_CALLBACK (clock_app_add_browser_cb), extension);
-
- g_signal_connect (extension, "deactivate",
- G_CALLBACK (clock_deactivate_cb), app);
-
- g_object_unref (browsers);
-}
-
-MidoriExtension*
-extension_init (void)
-{
- MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", _("Statusbar Clock"),
- "description", _("Display date and time in the statusbar"),
- "version", "0.1" MIDORI_VERSION_SUFFIX,
- "authors", "Arno Renevier <arno@renevier.net>",
- NULL);
- midori_extension_install_string (extension, "format", DEFAULT_FORMAT);
-
- g_signal_connect (extension, "activate",
- G_CALLBACK (clock_activate_cb), NULL);
-
- return extension;
-}
diff --git a/extensions/statusbar-features.c b/extensions/statusbar-features.c
deleted file mode 100644
index 616c6979..00000000
--- a/extensions/statusbar-features.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- Copyright (C) 2008-2011 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.
-*/
-
-#include <midori/midori.h>
-
-typedef struct
-{
- const gchar* label;
- gdouble level;
-} ZoomLevel;
-
-const ZoomLevel zoom_levels[] =
-{
- { "200%", 2.0 },
- { "175%", 1.75 },
- { "150%", 1.5 },
- { "125%", 1.25 },
- { "100%", 1.0 },
- { "50%" , 0.5 },
- { "25%" , 0.25 }
-};
-
-static void
-statusbar_features_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension);
-
-static void
-statusbar_features_toolbar_notify_toolbar_style_cb (GtkWidget* toolbar,
- GParamSpec* pspec,
- GtkWidget* button)
-{
- GtkToolbarStyle style = katze_object_get_enum (toolbar, "toolbar-style");
- const gchar* text = g_object_get_data (G_OBJECT (button), "feature-label");
- switch (style)
- {
- case GTK_TOOLBAR_BOTH:
- case GTK_TOOLBAR_BOTH_HORIZ:
- gtk_button_set_label (GTK_BUTTON (button), text);
- gtk_widget_show (gtk_button_get_image (GTK_BUTTON (button)));
- break;
- case GTK_TOOLBAR_TEXT:
- gtk_button_set_label (GTK_BUTTON (button), text);
- gtk_widget_hide (gtk_button_get_image (GTK_BUTTON (button)));
- break;
- case GTK_TOOLBAR_ICONS:
- gtk_button_set_label (GTK_BUTTON (button), "");
- gtk_widget_show (gtk_button_get_image (GTK_BUTTON (button)));
- break;
- default:
- g_assert_not_reached ();
- }
-}
-
-static void
-statusbar_features_browser_notify_tab_cb (MidoriBrowser* browser,
- GParamSpec* pspec,
- GtkWidget* combobox)
-{
- MidoriView* view = MIDORI_VIEW (midori_browser_get_current_tab (browser));
- gchar* text;
-
- if (view == NULL)
- return;
-
- text = g_strdup_printf ("%d%%", (gint)(midori_view_get_zoom_level (view) * 100));
- gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combobox))), text);
- g_free (text);
-}
-
-static void
-statusbar_features_deactivate_cb (MidoriExtension* extension,
- GtkWidget* bbox)
-{
- MidoriApp* app = midori_extension_get_app (extension);
- MidoriBrowser* browser = midori_browser_get_for_widget (bbox);
- GtkWidget* toolbar = katze_object_get_object (browser, "navigationbar");
-
- gtk_widget_destroy (bbox);
- g_signal_handlers_disconnect_matched (toolbar, G_SIGNAL_MATCH_FUNC,
- 0, -1, NULL, statusbar_features_toolbar_notify_toolbar_style_cb, NULL);
- g_object_unref (toolbar);
- g_signal_handlers_disconnect_by_func (
- extension, statusbar_features_deactivate_cb, bbox);
- g_signal_handlers_disconnect_by_func (
- app, statusbar_features_app_add_browser_cb, extension);
- g_signal_handlers_disconnect_matched (browser, G_SIGNAL_MATCH_FUNC,
- 0, -1, NULL, statusbar_features_browser_notify_tab_cb, NULL);
-}
-
-static void
-statusbar_features_zoom_level_changed_cb (GtkWidget* combobox,
- MidoriBrowser* browser)
-{
- MidoriView* view = MIDORI_VIEW (midori_browser_get_current_tab (browser));
- GtkWidget* entry = gtk_bin_get_child (GTK_BIN (combobox));
- const gchar* zoom_level_text = gtk_entry_get_text (GTK_ENTRY (entry));
- gdouble zoom_level = g_ascii_strtod (zoom_level_text, NULL);
- midori_view_set_zoom_level (view, zoom_level / 100.0);
-}
-
-GtkWidget*
-statusbar_features_property_proxy (MidoriWebSettings* settings,
- const gchar* property,
- GtkWidget* toolbar)
-{
- const gchar* kind = NULL;
- GtkWidget* button;
- GtkWidget* image;
- if (!strcmp (property, "auto-load-images")
- || !strcmp (property, "enable-javascript")
- || !strcmp (property, "enable-plugins"))
- kind = "toggle";
- else if (!strcmp (property, "identify-as"))
- kind = "custom-user-agent";
- else if (strstr (property, "font") != NULL)
- kind = "font";
- else if (!strcmp (property, "zoom-level"))
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (toolbar);
- guint i;
- button = gtk_combo_box_text_new_with_entry ();
- gtk_entry_set_width_chars (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (button))), 4);
- for (i = 0; i < G_N_ELEMENTS (zoom_levels); i++)
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (button), zoom_levels[i].label);
- g_signal_connect (button, "changed",
- G_CALLBACK (statusbar_features_zoom_level_changed_cb), browser);
- g_signal_connect (browser, "notify::tab",
- G_CALLBACK (statusbar_features_browser_notify_tab_cb), button);
- statusbar_features_browser_notify_tab_cb (browser, NULL, button);
- return button;
- }
-
- button = katze_property_proxy (settings, property, kind);
- if (GTK_IS_BIN (button))
- {
- GtkWidget* label = gtk_bin_get_child (GTK_BIN (button));
- if (GTK_IS_LABEL (label))
- gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
- }
-
- if (!strcmp (property, "auto-load-images"))
- {
- g_object_set_data (G_OBJECT (button), "feature-label", _("Images"));
- image = gtk_image_new_from_stock (STOCK_IMAGE, GTK_ICON_SIZE_MENU);
- gtk_button_set_image (GTK_BUTTON (button), image);
- gtk_widget_set_tooltip_text (button, _("Load images automatically"));
- }
- else if (!strcmp (property, "enable-javascript"))
- {
- g_object_set_data (G_OBJECT (button), "feature-label", _("Scripts"));
- image = gtk_image_new_from_stock (STOCK_SCRIPT, GTK_ICON_SIZE_MENU);
- gtk_button_set_image (GTK_BUTTON (button), image);
- gtk_widget_set_tooltip_text (button, _("Enable scripts"));
- }
- else if (!strcmp (property, "enable-plugins"))
- {
- if (!midori_web_settings_has_plugin_support ())
- gtk_widget_hide (button);
- g_object_set_data (G_OBJECT (button), "feature-label", _("Netscape plugins"));
- image = gtk_image_new_from_stock (MIDORI_STOCK_PLUGINS, GTK_ICON_SIZE_MENU);
- gtk_button_set_image (GTK_BUTTON (button), image);
- gtk_widget_set_tooltip_text (button, _("Enable Netscape plugins"));
- }
- if (GTK_IS_TOOLBAR (toolbar) && GTK_IS_BUTTON (button))
- {
- statusbar_features_toolbar_notify_toolbar_style_cb (toolbar, NULL, button);
- g_signal_connect (toolbar, "notify::toolbar-style",
- G_CALLBACK (statusbar_features_toolbar_notify_toolbar_style_cb), button);
- }
- return button;
-}
-
-static void
-statusbar_features_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension)
-{
- GtkWidget* statusbar;
- GtkWidget* bbox;
- MidoriWebSettings* settings;
- GtkWidget* toolbar;
- GtkWidget* button;
- gsize i;
- gchar** filters;
-
- /* FIXME: Monitor each view and modify its settings individually
- instead of merely replicating the global preferences. */
-
- statusbar = katze_object_get_object (browser, "statusbar");
- bbox = gtk_hbox_new (FALSE, 0);
- settings = midori_browser_get_settings (browser);
- toolbar = katze_object_get_object (browser, "navigationbar");
-
- filters = midori_extension_get_string_list (extension, "items", NULL);
- if (filters && *filters)
- {
- i = 0;
- while (filters[i] != NULL)
- {
- button = statusbar_features_property_proxy (settings, filters[i], toolbar);
- gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
- i++;
- }
- }
- else
- {
- button = statusbar_features_property_proxy (settings, "auto-load-images", toolbar);
- gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
- button = statusbar_features_property_proxy (settings, "enable-javascript", toolbar);
- gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
- button = statusbar_features_property_proxy (settings, "enable-plugins", toolbar);
- gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
- button = statusbar_features_property_proxy (settings, "identify-as", toolbar);
- gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
- button = statusbar_features_property_proxy (settings, "zoom-level", toolbar);
- gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
- }
- gtk_widget_show_all (bbox);
- gtk_box_pack_end (GTK_BOX (statusbar), bbox, FALSE, FALSE, 3);
- g_object_unref (statusbar);
- g_object_unref (toolbar);
-
- g_strfreev (filters);
- g_signal_connect (extension, "deactivate",
- G_CALLBACK (statusbar_features_deactivate_cb), bbox);
-}
-
-static void
-statusbar_features_activate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- KatzeArray* browsers;
- MidoriBrowser* browser;
-
- browsers = katze_object_get_object (app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- statusbar_features_app_add_browser_cb (app, browser, extension);
- g_signal_connect (app, "add-browser",
- G_CALLBACK (statusbar_features_app_add_browser_cb), extension);
- g_object_unref (browsers);
-}
-
-MidoriExtension*
-extension_init (void)
-{
- MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", _("Statusbar Features"),
- "description", _("Easily toggle features on web pages on and off"),
- "version", "0.1" MIDORI_VERSION_SUFFIX,
- "authors", "Christian Dywan <christian@twotoasts.de>",
- NULL);
- midori_extension_install_string_list (extension, "items", NULL, G_MAXSIZE);
-
- g_signal_connect (extension, "activate",
- G_CALLBACK (statusbar_features_activate_cb), NULL);
-
- return extension;
-}
diff --git a/extensions/tab-panel.c b/extensions/tab-panel.c
deleted file mode 100644
index 6e199bf1..00000000
--- a/extensions/tab-panel.c
+++ /dev/null
@@ -1,680 +0,0 @@
-/*
- Copyright (C) 2008-2013 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.
-*/
-
-#include <midori/midori.h>
-
-#define STOCK_TAB_PANEL "tab-panel"
-
-static void
-tab_panel_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension);
-
-static void
-tab_panel_settings_notify_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- GtkTreeModel* model);
-
-static void
-tab_panel_browser_add_tab_cb (MidoriBrowser* browser,
- GtkWidget* view,
- MidoriExtension* extension);
-
-static void
-tab_panel_browser_remove_tab_cb (MidoriBrowser* browser,
- GtkWidget* view,
- MidoriExtension* extension);
-
-static void
-tab_panel_browser_notify_tab_cb (MidoriBrowser* browser,
- GParamSpec* pspec,
- GtkTreeView* treeview);
-static void
-tab_panel_browser_move_tab_cb (MidoriBrowser* browser,
- GtkWidget* notebook,
- gint cur_pos,
- gint new_pos,
- gpointer user_data);
-
-static void
-tab_panel_view_notify_minimized_cb (GtkWidget* view,
- GParamSpec* pspec,
- MidoriExtension* extension);
-
-static void
-tab_panel_view_notify_icon_cb (GtkWidget* view,
- GParamSpec* pspec,
- MidoriExtension* extension);
-
-static void
-tab_panel_view_notify_title_cb (GtkWidget* view,
- GParamSpec* pspec,
- MidoriExtension* extension);
-
-static GtkTreeModel*
-tab_panel_get_model_for_browser (MidoriBrowser* browser)
-{
- return g_object_get_data (G_OBJECT (browser), "tab-panel-ext-model");
-}
-
-static GtkWidget*
-tab_panel_get_toolbar_for_browser (MidoriBrowser* browser)
-{
- return g_object_get_data (G_OBJECT (browser), "tab-panel-ext-toolbar");
-}
-
-static GtkToolItem*
-tab_panel_get_toolitem_for_view (GtkWidget* view)
-{
- return g_object_get_data (G_OBJECT (view), "tab-panel-ext-toolitem");
-}
-
-static gboolean
-tab_panel_get_iter_for_view (GtkTreeModel* model,
- GtkTreeIter* iter,
- gpointer view)
-{
- guint i = 0;
-
- while (gtk_tree_model_iter_nth_child (model, iter, NULL, i))
- {
- MidoriView* view_;
-
- gtk_tree_model_get (model, iter, 0, &view_, -1);
- g_object_unref (view_);
- if (view_ == view)
- return TRUE;
- i++;
- }
-
- return FALSE;
-}
-
-static void
-tab_panel_deactivate_cb (MidoriExtension* extension,
- GtkWidget* treeview)
-{
- MidoriApp* app = midori_extension_get_app (extension);
- MidoriBrowser* browser = midori_browser_get_for_widget (treeview);
- GtkTreeModel* model = tab_panel_get_model_for_browser (browser);
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs; tabs = g_list_next (tabs))
- {
- g_signal_handlers_disconnect_by_func (
- tabs->data, tab_panel_view_notify_minimized_cb, extension);
- g_signal_handlers_disconnect_by_func (
- tabs->data, tab_panel_view_notify_icon_cb, extension);
- g_signal_handlers_disconnect_by_func (
- tabs->data, tab_panel_view_notify_title_cb, extension);
- }
- g_list_free (tabs);
-
- g_signal_handlers_disconnect_by_func (
- extension, tab_panel_deactivate_cb, treeview);
- g_signal_handlers_disconnect_by_func (
- app, tab_panel_app_add_browser_cb, extension);
- g_signal_handlers_disconnect_by_func (
- browser, tab_panel_browser_add_tab_cb, extension);
- g_signal_handlers_disconnect_by_func (
- browser, tab_panel_browser_remove_tab_cb, extension);
- g_signal_handlers_disconnect_by_func (
- browser, tab_panel_browser_notify_tab_cb, treeview);
- g_signal_handlers_disconnect_by_func (
- browser, tab_panel_settings_notify_cb, model);
- g_signal_handlers_disconnect_by_func (
- browser, tab_panel_browser_move_tab_cb, NULL);
-
- gtk_widget_destroy (treeview);
- g_object_unref (model);
- g_object_set_data (G_OBJECT (browser), "tab-panel-ext-model", NULL);
- g_object_set (browser, "show-tabs", TRUE, NULL);
-
-}
-
-static void
-midori_extension_cursor_or_row_changed_cb (GtkTreeView* treeview,
- MidoriExtension* extension)
-{
- /* Nothing to do */
-}
-
-static gboolean
-tab_panel_treeview_query_tooltip_cb (GtkWidget* treeview,
- gint x,
- gint y,
- gboolean keyboard_tip,
- GtkTooltip* tooltip,
- gpointer user_data)
-{
- GtkTreeIter iter;
- GtkTreePath* path;
- GtkTreeModel* model;
- MidoriView* view;
-
- if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (treeview),
- &x, &y, keyboard_tip, &model, &path, &iter))
- return FALSE;
-
- gtk_tree_model_get (model, &iter, 0, &view, -1);
-
- gtk_tooltip_set_text (tooltip, midori_view_get_display_title (view));
- gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (treeview), tooltip, path);
-
- gtk_tree_path_free (path);
- g_object_unref (view);
-
- return TRUE;
-}
-
-static void
-midori_extension_row_activated_cb (GtkTreeView* treeview,
- GtkTreePath* path,
- GtkTreeViewColumn* column,
- MidoriExtension* extension)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- model = gtk_tree_view_get_model (treeview);
-
- if (gtk_tree_model_get_iter (model, &iter, path))
- {
- GtkWidget* view;
- MidoriBrowser* browser;
-
- gtk_tree_model_get (model, &iter, 0, &view, -1);
- browser = midori_browser_get_for_widget (GTK_WIDGET (treeview));
- midori_browser_set_current_tab (browser, view);
-
- g_object_unref (view);
- }
-}
-
-static void
-tab_panel_popup (GtkWidget* widget,
- GdkEventButton* event,
- GtkWidget* view)
-{
- GtkWidget* menu = midori_view_get_tab_menu (MIDORI_VIEW (view));
-
- katze_widget_popup (widget, GTK_MENU (menu), event, KATZE_MENU_POSITION_CURSOR);
-}
-
-static gboolean
-midori_extension_button_release_event_cb (GtkWidget* widget,
- GdkEventButton* event,
- MidoriExtension* extension)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- if (event->button < 1 || event->button > 3)
- return FALSE;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
- {
- GtkWidget* view;
-
- gtk_tree_model_get (model, &iter, 0, &view, -1);
-
- if (event->button == 1)
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (widget);
- GtkTreeViewColumn* column;
- if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
- event->x, event->y, NULL, &column, NULL, NULL)
- && column == gtk_tree_view_get_column (GTK_TREE_VIEW (widget), 1))
- midori_browser_close_tab (browser, view);
- else
- midori_browser_set_current_tab (browser, view);
- }
- else if (event->button == 2)
- midori_browser_close_tab (midori_browser_get_for_widget (widget), view);
- else
- tab_panel_popup (widget, event, view);
-
- g_object_unref (view);
- return TRUE;
- }
- return FALSE;
-}
-
-static gboolean
-midori_extension_key_release_event_cb (GtkWidget* widget,
- GdkEventKey* event,
- MidoriExtension* extension)
-{
- /* Nothing to do */
-
- return FALSE;
-}
-
-static void
-midori_extension_popup_menu_cb (GtkWidget* widget,
- MidoriExtension* extension)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
- {
- GtkWidget* view;
-
- gtk_tree_model_get (model, &iter, 0, &view, -1);
- tab_panel_popup (widget, NULL, view);
- g_object_unref (view);
- }
-}
-
-static void
-tab_panel_settings_notify_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- GtkTreeModel* model)
-{
- gboolean buttons = katze_object_get_boolean (settings, "close-buttons-on-tabs");
- guint i;
- GtkTreeIter iter;
-
- i = 0;
- while (gtk_tree_model_iter_nth_child (model, &iter, NULL, i++))
- gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 2, buttons, -1);
-}
-
-static void
-tab_panel_remove_view (MidoriBrowser* browser,
- GtkWidget* view,
- gboolean minimized)
-{
- if (minimized)
- {
- GtkToolItem* toolitem = tab_panel_get_toolitem_for_view (view);
- gtk_widget_destroy (GTK_WIDGET (toolitem));
- }
- else
- {
- GtkTreeModel* model = tab_panel_get_model_for_browser (browser);
- GtkTreeIter iter;
- if (tab_panel_get_iter_for_view (model, &iter, view))
- gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
- }
-}
-
-static void
-tab_panel_view_notify_minimized_cb (GtkWidget* view,
- GParamSpec* pspec,
- MidoriExtension* extension)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (view);
- gboolean minimized = katze_object_get_boolean (view, "minimized");
-
- tab_panel_remove_view (browser, view, !minimized);
- tab_panel_browser_add_tab_cb (browser, view, extension);
-}
-
-static void
-tab_panel_view_notify_icon_cb (GtkWidget* view,
- GParamSpec* pspec,
- MidoriExtension* extension)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (view);
- gboolean minimized = katze_object_get_boolean (view, "minimized");
- GdkPixbuf* icon = midori_view_get_icon (MIDORI_VIEW (view));
-
- if (minimized)
- {
- GtkToolItem* toolitem = tab_panel_get_toolitem_for_view (view);
- GtkWidget* image = gtk_tool_button_get_icon_widget (GTK_TOOL_BUTTON (toolitem));
- gtk_image_set_from_pixbuf (GTK_IMAGE (image), icon);
- }
- else
- {
- GtkTreeModel* model = tab_panel_get_model_for_browser (browser);
- GtkTreeIter iter;
- GdkColor* fg = midori_tab_get_fg_color (MIDORI_TAB (view));
- GdkColor* bg = midori_tab_get_bg_color (MIDORI_TAB (view));
-
- if (tab_panel_get_iter_for_view (model, &iter, view))
- gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
- 3, icon,
- 6, bg,
- 7, fg,
- -1);
- }
-}
-
-static void
-tab_panel_view_notify_title_cb (GtkWidget* view,
- GParamSpec* pspec,
- MidoriExtension* extension)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (view);
- gboolean minimized = katze_object_get_boolean (view, "minimized");
- const gchar* title = midori_view_get_display_title (MIDORI_VIEW (view));
-
- if (minimized)
- {
- GtkToolItem* toolitem = tab_panel_get_toolitem_for_view (view);
- gtk_tool_item_set_tooltip_text (toolitem, title);
- }
- else
- {
- GtkTreeModel* model = tab_panel_get_model_for_browser (browser);
- GtkTreeIter iter;
- GdkColor* fg = midori_tab_get_fg_color (MIDORI_TAB (view));
- GdkColor* bg = midori_tab_get_bg_color (MIDORI_TAB (view));
- if (tab_panel_get_iter_for_view (model, &iter, view))
- {
- gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
- 4, title,
- 5, midori_view_get_label_ellipsize (MIDORI_VIEW (view)),
- 6, bg,
- 7, fg,
- -1);
- }
- }
-}
-
-static void
-tab_panel_toolitem_clicked_cb (GtkToolItem* toolitem,
- GtkWidget* view)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (view);
- midori_browser_set_current_tab (browser, view);
-}
-
-static gboolean
-tab_panel_toolitem_button_press_event_cb (GtkToolItem* toolitem,
- GdkEventButton* event,
- GtkWidget* view)
-{
- if (MIDORI_EVENT_CONTEXT_MENU (event))
- {
- tab_panel_popup (GTK_WIDGET (toolitem), event, view);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-tab_panel_browser_add_tab_cb (MidoriBrowser* browser,
- GtkWidget* view,
- MidoriExtension* extension)
-{
- gint page = midori_browser_page_num (browser, view);
- MidoriWebSettings* settings = midori_browser_get_settings (browser);
- gboolean minimized = katze_object_get_boolean (view, "minimized");
- GdkPixbuf* icon = midori_view_get_icon (MIDORI_VIEW (view));
- const gchar* title = midori_view_get_display_title (MIDORI_VIEW (view));
- GtkTreeModel* model = tab_panel_get_model_for_browser (browser);
-
- if (minimized)
- {
- GtkWidget* toolbar = tab_panel_get_toolbar_for_browser (browser);
- GtkWidget* image = gtk_image_new_from_pixbuf (
- midori_view_get_icon (MIDORI_VIEW (view)));
- GtkToolItem* toolitem = gtk_tool_button_new (image, NULL);
- gtk_tool_item_set_tooltip_text (toolitem, title);
- gtk_widget_show (image);
- g_object_set_data (G_OBJECT (view), "tab-panel-ext-toolitem", toolitem);
- gtk_widget_show (GTK_WIDGET (toolitem));
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (tab_panel_toolitem_clicked_cb), view);
- g_signal_connect (gtk_bin_get_child (GTK_BIN (toolitem)), "button-press-event",
- G_CALLBACK (tab_panel_toolitem_button_press_event_cb), view);
- }
- else
- {
- GtkTreeIter iter;
- gboolean buttons = katze_object_get_boolean (settings, "close-buttons-on-tabs");
- gint ellipsize = midori_view_get_label_ellipsize (MIDORI_VIEW (view));
- GdkColor* fg = midori_tab_get_fg_color (MIDORI_TAB (view));
- GdkColor* bg = midori_tab_get_bg_color (MIDORI_TAB (view));
-
- gtk_tree_store_insert_with_values (GTK_TREE_STORE (model),
- &iter, NULL, page, 0, view, 1, GTK_STOCK_CLOSE, 2, buttons,
- 3, icon, 4, title, 5, ellipsize, 6, bg, 7, fg, -1);
- }
-
- if (!g_signal_handler_find (view, G_SIGNAL_MATCH_FUNC,
- g_signal_lookup ("notify", MIDORI_TYPE_VIEW), 0, NULL,
- tab_panel_view_notify_minimized_cb, extension))
- {
- g_signal_connect (settings, "notify::close-buttons-on-tabs",
- G_CALLBACK (tab_panel_settings_notify_cb), model);
- g_signal_connect (view, "notify::minimized",
- G_CALLBACK (tab_panel_view_notify_minimized_cb), extension);
- g_signal_connect (view, "notify::icon",
- G_CALLBACK (tab_panel_view_notify_icon_cb), extension);
- g_signal_connect (view, "notify::title",
- G_CALLBACK (tab_panel_view_notify_title_cb), extension);
- }
-}
-
-static void
-tab_panel_browser_remove_tab_cb (MidoriBrowser* browser,
- GtkWidget* view,
- MidoriExtension* extension)
-{
- gboolean minimized = katze_object_get_boolean (view, "minimized");
-
- if (!g_object_get_data (G_OBJECT (browser), "midori-browser-destroyed"))
- tab_panel_remove_view (browser, view, minimized);
-}
-
-static void
-tab_panel_browser_notify_tab_cb (MidoriBrowser* browser,
- GParamSpec* pspec,
- GtkTreeView* treeview)
-{
- GtkTreeModel* model = tab_panel_get_model_for_browser (browser);
- GtkTreeIter iter;
- GtkWidget* view;
-
- if (g_object_get_data (G_OBJECT (browser), "midori-browser-destroyed"))
- return;
-
- view = midori_browser_get_current_tab (browser);
- if (tab_panel_get_iter_for_view (model, &iter, view))
- {
- GtkTreeSelection* selection = gtk_tree_view_get_selection (treeview);
- gtk_tree_selection_select_iter (selection, &iter);
- }
-}
-
-static void
-tab_panel_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension)
-{
- GtkTreeStore* model;
- GtkWidget* treeview;
- GtkTreeViewColumn* column;
- GtkCellRenderer* renderer_pixbuf;
- GtkCellRenderer* renderer_text;
- GtkWidget* panel;
- GtkWidget* toolbar;
- gint i;
- /* GtkToolItem* toolitem; */
-
- g_object_set (browser, "show-tabs", FALSE, NULL);
-
- panel = katze_object_get_object (browser, "panel");
-
- model = gtk_tree_store_new (8, MIDORI_TYPE_VIEW,
- G_TYPE_STRING, G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, G_TYPE_STRING,
- G_TYPE_INT, GDK_TYPE_COLOR, GDK_TYPE_COLOR);
- g_object_set_data (G_OBJECT (browser), "tab-panel-ext-model", model);
- treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
- gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (treeview), FALSE);
- g_signal_connect (treeview, "query-tooltip",
- G_CALLBACK (tab_panel_treeview_query_tooltip_cb), NULL);
- gtk_widget_set_has_tooltip (treeview, TRUE);
- column = gtk_tree_view_column_new ();
- renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_pixbuf,
- "pixbuf", 3, "cell-background-gdk", 6, NULL);
- renderer_text = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer_text, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_text,
- "text", 4, "ellipsize", 5,
- "cell-background-gdk", 6, "foreground-gdk", 7, NULL);
- gtk_tree_view_column_set_expand (column, TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
- column = gtk_tree_view_column_new ();
- renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_pixbuf,
- "stock-id", 1, "follow-state", 2,
- "visible", 2, "cell-background-gdk", 6, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
- g_object_connect (treeview,
- "signal::row-activated",
- midori_extension_row_activated_cb, extension,
- "signal::cursor-changed",
- midori_extension_cursor_or_row_changed_cb, extension,
- "signal::columns-changed",
- midori_extension_cursor_or_row_changed_cb, extension,
- "signal::button-release-event",
- midori_extension_button_release_event_cb, extension,
- "signal::key-release-event",
- midori_extension_key_release_event_cb, extension,
- "signal::popup-menu",
- midori_extension_popup_menu_cb, extension,
- NULL);
- gtk_widget_show (treeview);
-
- toolbar = gtk_toolbar_new ();
- g_object_set_data (G_OBJECT (browser), "tab-panel-ext-toolbar", toolbar);
- gtk_widget_show (toolbar);
-
- GtkActionGroup* actions = midori_browser_get_action_group (browser);
- GtkAction* action = gtk_action_group_get_action (actions, "TabNew");
- GtkWidget* toolitem = gtk_action_create_tool_item (action);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (toolitem), -1);
-
- action = gtk_action_group_get_action (actions, "Separator");
- toolitem = gtk_action_create_tool_item (action);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (toolitem), -1);
-
- /*
- TODO: Implement optional thumbnail images
- toolitem = gtk_toggle_tool_button_new_from_stock (STOCK_IMAGE);
- gtk_tool_item_set_is_important (toolitem, TRUE);
- g_signal_connect (toolitem, "toggled",
- G_CALLBACK (tab_panel_button_thumbnail_toggled_cb), notebook);
- gtk_widget_show (GTK_WIDGET (toolitem));
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1); */
-
- i = midori_panel_append_widget (MIDORI_PANEL (panel), treeview,
- STOCK_TAB_PANEL, _("Tab Panel"), toolbar);
- if (gtk_widget_get_visible (GTK_WIDGET (browser)))
- midori_panel_set_current_page (MIDORI_PANEL (panel), i);
- g_object_unref (panel);
-
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs; tabs = g_list_next (tabs))
- tab_panel_browser_add_tab_cb (browser, tabs->data, extension);
- g_list_free (tabs);
-
- g_signal_connect_after (browser, "add-tab",
- G_CALLBACK (tab_panel_browser_add_tab_cb), extension);
- g_signal_connect (browser, "remove-tab",
- G_CALLBACK (tab_panel_browser_remove_tab_cb), extension);
- g_signal_connect (browser, "notify::tab",
- G_CALLBACK (tab_panel_browser_notify_tab_cb), treeview);
- g_signal_connect (extension, "deactivate",
- G_CALLBACK (tab_panel_deactivate_cb), treeview);
- g_signal_connect (browser, "move-tab",
- G_CALLBACK (tab_panel_browser_move_tab_cb), NULL);
-}
-
-static void
-tab_panel_activate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- KatzeArray* browsers;
- MidoriBrowser* browser;
-
- browsers = katze_object_get_object (app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- tab_panel_app_add_browser_cb (app, browser, extension);
- g_object_unref (browsers);
- g_signal_connect (app, "add-browser",
- G_CALLBACK (tab_panel_app_add_browser_cb), extension);
-}
-
-static void
-tab_panel_browser_move_tab_cb (MidoriBrowser* browser,
- GtkWidget* notebook,
- gint cur_pos,
- gint new_pos,
- gpointer user_data)
-{
- GtkTreeIter cur, new;
- gint last_page;
- GtkTreeModel *model;
-
- last_page = midori_browser_get_n_pages (browser) - 1;
- model = tab_panel_get_model_for_browser (browser);
-
- gtk_tree_model_iter_nth_child (model, &cur, NULL, cur_pos);
-
- if (cur_pos == 0 && new_pos == last_page)
- gtk_tree_store_move_before (GTK_TREE_STORE (model), &cur, NULL);
- else if (cur_pos == last_page && new_pos == 0)
- gtk_tree_store_move_after (GTK_TREE_STORE (model), &cur, NULL);
- else
- {
- gtk_tree_model_iter_nth_child (model, &new, NULL, new_pos);
- gtk_tree_store_swap (GTK_TREE_STORE (model), &cur, &new);
- }
-}
-
-MidoriExtension*
-extension_init (void)
-{
- GtkIconFactory* factory;
- GtkIconSource* icon_source;
- GtkIconSet* icon_set;
- static GtkStockItem items[] =
- {
- { STOCK_TAB_PANEL, N_("T_ab Panel"), 0, 0, NULL },
- };
- MidoriExtension* extension;
-
- factory = gtk_icon_factory_new ();
- gtk_stock_add (items, G_N_ELEMENTS (items));
- icon_set = gtk_icon_set_new ();
- icon_source = gtk_icon_source_new ();
- gtk_icon_source_set_icon_name (icon_source, GTK_STOCK_INDEX);
- gtk_icon_set_add_source (icon_set, icon_source);
- gtk_icon_source_free (icon_source);
- gtk_icon_factory_add (factory, STOCK_TAB_PANEL, icon_set);
- gtk_icon_set_unref (icon_set);
- gtk_icon_factory_add_default (factory);
- g_object_unref (factory);
-
- extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", _("Tab Panel"),
- "description", _("Show tabs in a vertical panel"),
- "version", "0.1" MIDORI_VERSION_SUFFIX,
- "authors", "Christian Dywan <christian@twotoasts.de>",
- NULL);
-
- g_signal_connect (extension, "activate",
- G_CALLBACK (tab_panel_activate_cb), NULL);
-
- return extension;
-}
diff --git a/extensions/tabby.vala b/extensions/tabby.vala
deleted file mode 100644
index c5173a78..00000000
--- a/extensions/tabby.vala
+++ /dev/null
@@ -1,802 +0,0 @@
-/*
- Copyright (C) 2013 André Stösel <andre@stoesel.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.
-*/
-
-namespace Tabby {
- int IDLE_RESTORE_COUNT = 13;
- /* FixMe: don't use a global object */
- Midori.App? APP;
-
- /* function called from Manager object */
- public interface IStorage : GLib.Object {
- public abstract Katze.Array get_saved_sessions ();
- public abstract Base.Session get_new_session ();
- public abstract void restore_last_sessions ();
- public abstract void import_session (Katze.Array tabs);
- }
-
- public interface ISession : GLib.Object {
- public abstract Katze.Array get_tabs ();
- /* Add one tab to the database */
- public abstract void add_item (Katze.Item item);
- /* Attach to a browser */
- public abstract void attach (Midori.Browser browser);
- /* Attach to a browser and populate it with tabs from the database */
- public abstract void restore (Midori.Browser browser);
- /* Remove all tabs from the database */
- public abstract void remove ();
- /* Run when a browser is closed */
- public abstract void close ();
- }
-
- public enum SessionState {
- OPEN,
- CLOSED,
- RESTORING
- }
-
- namespace Base {
- /* each base class should connect to all necessary signals and provide an abstract function to handle them */
-
- public abstract class Storage : GLib.Object, IStorage {
- public Midori.App app { get; construct; }
-
- public abstract Katze.Array get_saved_sessions ();
- public abstract Base.Session get_new_session ();
-
- public void start_new_session () {
- Katze.Array sessions = new Katze.Array (typeof (Session));
- this.init_sessions (sessions);
- }
-
- public void restore_last_sessions () {
- Katze.Array sessions = this.get_saved_sessions ();
- this.init_sessions (sessions);
- }
-
- private void init_sessions (Katze.Array sessions) {
- if (sessions.is_empty ()) {
- sessions.add_item (this.get_new_session ());
- }
-
- GLib.List<unowned Katze.Item> items = sessions.get_items ();
- foreach (Katze.Item item in items) {
- Session session = item as Session;
- Midori.Browser browser = this.app.create_browser ();
-
- /* FixMe: tabby-session should be set in .restore and .attch */
- browser.set_data<Base.Session> ("tabby-session", session as Base.Session);
-
- app.add_browser (browser);
- browser.show ();
-
- session.restore (browser);
- }
- }
-
- public virtual void import_session (Katze.Array tabs) {
- Session session = this.get_new_session ();
- GLib.List<unowned Katze.Item> items = tabs.get_items ();
- double i = 0;
- foreach (Katze.Item item in items) {
- item.set_meta_string ("sorting", i.to_string());
- // See midori_browser_step_history: don't add to history
- item.set_meta_string ("history-step", "ignore");
- i += 1024;
- session.add_item (item);
- }
- }
- }
-
- public abstract class Session : GLib.Object, ISession {
- protected GLib.SList<double?> tab_sorting;
-
- public Midori.Browser? browser { get; protected set; default = null; }
- public SessionState state { get; protected set; default = SessionState.CLOSED; }
-
- public abstract void add_item (Katze.Item item);
- public abstract void uri_changed (Midori.View view, string uri);
- public abstract void data_changed (Midori.View view);
- public abstract void tab_added (Midori.Browser browser, Midori.View view);
- public abstract void tab_removed (Midori.Browser browser, Midori.View view);
- public abstract void tab_switched (Midori.View? old_view, Midori.View? new_view);
- public abstract void tab_reordered (Gtk.Widget tab, uint pos);
-
- public abstract void remove ();
-
- public abstract Katze.Array get_tabs ();
- public abstract double get_max_sorting ();
-
- public void attach (Midori.Browser browser) {
- this.browser = browser;
-
- browser.add_tab.connect_after (this.tab_added);
- browser.add_tab.connect (this.helper_data_changed);
-
- browser.remove_tab.connect (this.tab_removed);
- browser.switch_tab.connect (this.tab_switched);
- browser.delete_event.connect_after(this.delete_event);
- browser.notebook.page_reordered.connect_after (this.tab_reordered);
-
- this.state = SessionState.OPEN;
-
- foreach (Midori.View view in browser.get_tabs ()) {
- this.tab_added (browser, view);
- this.helper_data_changed (browser, view);
- }
- }
-
- public void restore (Midori.Browser browser) {
- this.browser = browser;
-
- Katze.Array tabs = this.get_tabs ();
- unowned Katze.Array? open_uris = browser.get_data ("tabby-open-uris");
-
- if(tabs.is_empty () && open_uris == null) {
- /* Using get here to avoid MidoriMidoriStartup in generated C with Vala 0.20.1 */
- int load_on_startup;
- APP.settings.get ("load-on-startup", out load_on_startup);
-
- Katze.Item item = new Katze.Item ();
-
- if (load_on_startup == Midori.MidoriStartup.BLANK_PAGE) {
- item.uri = "about:dial";
- } else {
- item.uri = "about:home";
- }
-
- tabs.add_item (item);
- }
-
- browser.add_tab.connect_after (this.tab_added);
- browser.add_tab.connect (this.helper_data_changed);
-
- browser.remove_tab.connect (this.tab_removed);
- browser.switch_tab.connect (this.tab_switched);
- browser.delete_event.connect_after(this.delete_event);
- browser.notebook.page_reordered.connect_after (this.tab_reordered);
-
- GLib.List<unowned Katze.Item> items = new GLib.List<unowned Katze.Item> ();
- if (open_uris != null) {
- items.concat (open_uris.get_items ());
- }
- items.concat (tabs.get_items ());
- unowned GLib.List<unowned Katze.Item> u_items = items;
-
- bool delay = false;
- bool should_delay = false;
-
- int load_on_startup;
- APP.settings.get ("load-on-startup", out load_on_startup);
- should_delay = load_on_startup == Midori.MidoriStartup.DELAYED_PAGES;
-
- if (APP.crashed == true) {
- delay = true;
- should_delay = true;
- }
-
- this.state = SessionState.RESTORING;
-
- GLib.Idle.add (() => {
- /* Note: we need to use `items` for something to maintain a valid reference */
- GLib.PtrArray new_tabs = new GLib.PtrArray ();
- if (items.length () > 0) {
- for (int i = 0; i < IDLE_RESTORE_COUNT; i++) {
- if (u_items == null) {
- this.helper_reorder_tabs (new_tabs);
- this.state = SessionState.OPEN;
- return false;
- }
-
- Katze.Item t_item = u_items.data<Katze.Item>;
-
- t_item.set_meta_integer ("append", 1);
-
- if (delay && should_delay)
- t_item.set_meta_integer ("delay", Midori.Delay.DELAYED);
- else
- delay = true;
-
- unowned Gtk.Widget tab = browser.add_item (t_item);
- new_tabs.add (tab);
-
- u_items = u_items.next;
- }
- this.helper_reorder_tabs (new_tabs);
- }
- if (u_items == null) {
- this.state = SessionState.OPEN;
- return false;
- }
- return true;
- });
- }
-
- public virtual void close () {
- if (this.state == SessionState.CLOSED) {
- assert (this.browser == null);
- } else {
- this.state = SessionState.CLOSED;
-
- this.browser.add_tab.disconnect (this.tab_added);
- this.browser.add_tab.disconnect (this.helper_data_changed);
- this.browser.remove_tab.disconnect (this.tab_removed);
- this.browser.switch_tab.disconnect (this.tab_switched);
- this.browser.delete_event.disconnect (this.delete_event);
- this.browser.notebook.page_reordered.disconnect (this.tab_reordered);
-
- this.browser = null;
- }
- }
-
-#if HAVE_GTK3
- protected bool delete_event (Gtk.Widget widget, Gdk.EventAny event) {
-#else
- protected bool delete_event (Gtk.Widget widget, Gdk.Event event) {
-#endif
-
- this.close ();
- return false;
-
- }
-
- protected double get_tab_sorting (Midori.View view) {
- int this_pos = this.browser.notebook.page_num (view);
- Midori.View prev_view = this.browser.notebook.get_nth_page (this_pos - 1) as Midori.View;
- Midori.View next_view = this.browser.notebook.get_nth_page (this_pos + 1) as Midori.View;
-
- string prev_meta_sorting = null;
- string next_meta_sorting = null;
- double prev_sorting, next_sorting, this_sorting;
-
- if (prev_view != null) {
- unowned Katze.Item prev_item = prev_view.get_proxy_item ();
- prev_meta_sorting = prev_item.get_meta_string ("sorting");
- }
-
- if (prev_meta_sorting == null)
- if (this.state == SessionState.RESTORING)
- prev_sorting = this.get_max_sorting ();
- else
- prev_sorting = double.parse ("0");
- else
- prev_sorting = double.parse (prev_meta_sorting);
-
- if (next_view != null) {
- unowned Katze.Item next_item = next_view.get_proxy_item ();
- next_meta_sorting = next_item.get_meta_string ("sorting");
- }
-
- if (next_meta_sorting == null)
- next_sorting = prev_sorting + 2048;
- else
- next_sorting = double.parse (next_meta_sorting);
-
- this_sorting = prev_sorting + (next_sorting - prev_sorting) / 2;
-
- return this_sorting;
- }
-
- private void load_status (GLib.Object _view, ParamSpec pspec) {
- Midori.View view = (Midori.View)_view;
-
- if (view.load_status == Midori.LoadStatus.PROVISIONAL) {
- unowned Katze.Item item = view.get_proxy_item ();
-
- int64 delay = item.get_meta_integer ("delay");
- if (delay == Midori.Delay.UNDELAYED) {
- view.web_view.notify["uri"].connect ( () => {
- this.uri_changed (view, view.web_view.uri);
- });
- view.web_view.notify["title"].connect ( () => {
- this.data_changed (view);
- });
-
- }
-
- view.notify["load-status"].disconnect (load_status);
- }
- }
-
- private void helper_data_changed (Midori.Browser browser, Midori.View view) {
- view.notify["load-status"].connect (load_status);
-
- view.new_view.connect (this.helper_duplicate_tab);
- }
-
- private void helper_reorder_tabs (GLib.PtrArray new_tabs) {
- CompareDataFunc<double?> helper_compare_data = (a, b) => {
- if (a > b)
- return 1;
- else if(a < b)
- return -1;
- return 0;
- };
-
- GLib.CompareFunc<double?> helper_compare_func = (a,b) => {
- return a == b ? 0 : -1;
- };
-
- this.browser.notebook.page_reordered.disconnect (this.tab_reordered);
- for(var i = 0; i < new_tabs.len; i++) {
- Midori.View tab = new_tabs.index(i) as Midori.View;
-
- unowned Katze.Item item = tab.get_proxy_item ();
-
- double sorting;
- string? sorting_string = item.get_meta_string ("sorting");
- if (sorting_string != null) { /* we have to use a seperate if condition to avoid a `possibly unassigned local variable` error */
- if (double.try_parse (item.get_meta_string ("sorting"), out sorting)) {
- this.tab_sorting.insert_sorted_with_data (sorting, helper_compare_data);
-
- int index = this.tab_sorting.position (this.tab_sorting.find_custom (sorting, helper_compare_func));
-
- this.browser.notebook.reorder_child (tab, index);
- }
- }
- }
- this.browser.notebook.page_reordered.connect_after (this.tab_reordered);
- }
-
- private void helper_duplicate_tab (Midori.View view, Midori.View new_view, Midori.NewView where, bool user_initiated) {
- unowned Katze.Item item = view.get_proxy_item ();
- unowned Katze.Item new_item = new_view.get_proxy_item ();
- int64 tab_id = item.get_meta_integer ("tabby-id");
- int64 new_tab_id = new_item.get_meta_integer ("tabby-id");
-
- if (tab_id > 0 && tab_id == new_tab_id) {
- new_item.set_meta_integer ("tabby-id", 0);
- }
- }
-
- construct {
- this.tab_sorting = new GLib.SList<double?> ();
- }
- }
- }
-
- namespace Local {
- private class Session : Base.Session {
- public int64 id { get; private set; }
- private Midori.Database database;
-
- public override void add_item (Katze.Item item) {
- GLib.DateTime time = new DateTime.now_local ();
- string? sorting = item.get_meta_string ("sorting") ?? "1";
- string sqlcmd = "INSERT INTO `tabs` (`crdate`, `tstamp`, `session_id`, `uri`, `title`, `sorting`) VALUES (:crdate, :tstamp, :session_id, :uri, :title, :sorting);";
-
- int64 tstamp = item.get_meta_integer ("tabby-tstamp");
- if (tstamp < 0) { // new tab without focus
- tstamp = 0;
- }
-
- try {
- var statement = database.prepare (sqlcmd,
- ":crdate", typeof (int64), time.to_unix (),
- ":tstamp", typeof (int64), tstamp,
- ":session_id", typeof (int64), this.id,
- ":uri", typeof (string), item.uri,
- ":title", typeof (string), item.name,
- ":sorting", typeof (double), double.parse (sorting));
- statement.exec ();
- int64 tab_id = statement.row_id ();
- item.set_meta_integer ("tabby-id", tab_id);
- } catch (Error error) {
- critical (_("Failed to update database: %s"), error.message);
- }
- }
-
- protected override void uri_changed (Midori.View view, string uri) {
- unowned Katze.Item item = view.get_proxy_item ();
- int64 tab_id = item.get_meta_integer ("tabby-id");
- string sqlcmd = "UPDATE `tabs` SET uri = :uri WHERE session_id = :session_id AND id = :tab_id;";
- try {
- database.prepare (sqlcmd,
- ":uri", typeof (string), uri,
- ":session_id", typeof (int64), this.id,
- ":tab_id", typeof (int64), tab_id).exec ();
- } catch (Error error) {
- critical (_("Failed to update database: %s"), error.message);
- }
- }
-
- protected override void data_changed (Midori.View view) {
- unowned Katze.Item item = view.get_proxy_item ();
- int64 tab_id = item.get_meta_integer ("tabby-id");
- string sqlcmd = "UPDATE `tabs` SET title = :title WHERE session_id = :session_id AND id = :tab_id;";
- try {
- database.prepare (sqlcmd,
- ":title", typeof (string), view.get_display_title (),
- ":session_id", typeof (int64), this.id,
- ":tab_id", typeof (int64), tab_id).exec ();
- } catch (Error error) {
- critical (_("Failed to update database: %s"), error.message);
- }
- }
-
- protected override void tab_added (Midori.Browser browser, Midori.View view) {
- unowned Katze.Item item = view.get_proxy_item ();
- int64 tab_id = item.get_meta_integer ("tabby-id");
- if (tab_id < 1) {
- double sorting = this.get_tab_sorting (view);
- item.set_meta_string ("sorting", sorting.to_string ());
- this.add_item (item);
- }
- }
-
- protected override void tab_removed (Midori.Browser browser, Midori.View view) {
- unowned Katze.Item item = view.get_proxy_item ();
- int64 tab_id = item.get_meta_integer ("tabby-id");
- /* FixMe: mark as deleted */
- string sqlcmd = "DELETE FROM `tabs` WHERE session_id = :session_id AND id = :tab_id;";
- try {
- database.prepare (sqlcmd,
- ":session_id", typeof (int64), this.id,
- ":tab_id", typeof (int64), tab_id).exec ();
- } catch (Error error) {
- critical (_("Failed to update database: %s"), error.message);
- }
- }
-
- protected override void tab_switched (Midori.View? old_view, Midori.View? new_view) {
- GLib.DateTime time = new DateTime.now_local ();
- unowned Katze.Item item = new_view.get_proxy_item ();
- int64 tab_id = item.get_meta_integer ("tabby-id");
- int64 tstamp = time.to_unix();
- item.set_meta_integer ("tabby-tstamp", tstamp);
- string sqlcmd = "UPDATE `tabs` SET tstamp = :tstamp WHERE session_id = :session_id AND id = :tab_id;";
- try {
- database.prepare (sqlcmd,
- ":session_id", typeof (int64), this.id,
- ":tab_id", typeof (int64), tab_id,
- ":tstamp", typeof (int64), tstamp).exec ();
- } catch (Error error) {
- critical (_("Failed to update database: %s"), error.message);
- }
- }
-
- protected override void tab_reordered (Gtk.Widget tab, uint pos) {
- Midori.View view = tab as Midori.View;
-
- double sorting = this.get_tab_sorting (view);
- unowned Katze.Item item = view.get_proxy_item ();
- int64 tab_id = item.get_meta_integer ("tabby-id");
- string sqlcmd = "UPDATE `tabs` SET sorting = :sorting WHERE session_id = :session_id AND id = :tab_id;";
- try {
- database.prepare (sqlcmd,
- ":session_id", typeof (int64), this.id,
- ":tab_id", typeof (int64), tab_id,
- ":sorting", typeof (double), sorting).exec ();
- } catch (Error error) {
- critical (_("Failed to update database: %s"), error.message);
- }
-
- item.set_meta_string ("sorting", sorting.to_string ());
- }
-
- public override void remove() {
- string sqlcmd = """
- DELETE FROM `tabs` WHERE session_id = :session_id;
- DELETE FROM `sessions` WHERE id = :session_id;
- """;
- try {
- database.prepare (sqlcmd,
- ":session_id", typeof (int64), this.id). exec ();
- } catch (Error error) {
- critical (_("Failed to update database: %s"), error.message);
- }
- }
-
- public override void close () {
- /* base.close may unset this.browser, so hold onto it */
- Midori.Browser? my_browser = this.browser;
- base.close ();
-
- bool should_break = true;
- if (my_browser != null && !my_browser.destroy_with_parent) {
- foreach (Midori.Browser browser in APP.get_browsers ()) {
- if (browser != my_browser && !browser.destroy_with_parent) {
- should_break = false;
- break;
- }
- }
-
- if (should_break) {
- return;
- }
- }
-
- GLib.DateTime time = new DateTime.now_local ();
- string sqlcmd = "UPDATE `sessions` SET closed = 1, tstamp = :tstamp WHERE id = :session_id;";
- try {
- database.prepare (sqlcmd,
- ":session_id", typeof (int64), this.id,
- ":tstamp", typeof (int64), time.to_unix ()).exec ();
- } catch (Error error) {
- critical (_("Failed to update database: %s"), error.message);
- }
- }
-
- public override Katze.Array get_tabs() {
- Katze.Array tabs = new Katze.Array (typeof (Katze.Item));
-
- string sqlcmd = "SELECT id, uri, title, sorting FROM tabs WHERE session_id = :session_id ORDER BY tstamp DESC";
- try {
- var statement = database.prepare (sqlcmd,
- ":session_id", typeof (int64), this.id);
- while (statement.step ()) {
- Katze.Item item = new Katze.Item ();
- int64 id = statement.get_int64 ("id");
- string uri = statement.get_string ("uri");
- string title = statement.get_string ("title");
- double sorting = statement.get_double ("sorting");
- item.uri = uri;
- item.name = title;
- item.set_meta_integer ("tabby-id", id);
- item.set_meta_string ("sorting", sorting.to_string ());
- // See midori_browser_step_history: don't add to history
- item.set_meta_string ("history-step", "ignore");
- tabs.add_item (item);
- }
- } catch (Error error) {
- critical (_("Failed to select from database: %s"), error.message);
- }
- return tabs;
- }
-
- public override double get_max_sorting () {
- string sqlcmd = "SELECT MAX(sorting) FROM tabs WHERE session_id = :session_id";
- try {
- var statement = database.prepare (sqlcmd,
- ":session_id", typeof (int64), this.id);
- statement.step ();
- double sorting = statement.get_double ("MAX(sorting)");
- if (!sorting.is_nan ()) {
- return sorting;
- }
- } catch (Error error) {
- critical (_("Failed to select from database: %s"), error.message);
- }
-
- return 0.0;
- }
-
- internal Session (Midori.Database database) {
- this.database = database;
-
- GLib.DateTime time = new DateTime.now_local ();
-
- string sqlcmd = "INSERT INTO `sessions` (`tstamp`) VALUES (:tstamp);";
-
- try {
- var statement = database.prepare (sqlcmd,
- ":tstamp", typeof (int64), time.to_unix ());
- statement.exec ();
- this.id = statement.row_id ();
- } catch (Error error) {
- critical (_("Failed to update database: %s"), error.message);
- }
- }
-
- internal Session.with_id (Midori.Database database, int64 id) {
- this.database = database;
- this.id = id;
-
- GLib.DateTime time = new DateTime.now_local ();
- string sqlcmd = "UPDATE `sessions` SET closed = 0, tstamp = :tstamp WHERE id = :session_id;";
-
- try {
- database.prepare (sqlcmd,
- ":session_id", typeof (int64), this.id,
- ":tstamp", typeof (int64), time.to_unix ()).exec ();
- } catch (Error error) {
- critical (_("Failed to update database: %s"), error.message);
- }
- }
- }
-
- private class Storage : Base.Storage {
- private Midori.Database database;
-
- public override Katze.Array get_saved_sessions () {
- Katze.Array sessions = new Katze.Array (typeof (Session));
-
- string sqlcmd = """
- SELECT id, closed FROM sessions WHERE closed = 0
- UNION
- SELECT * FROM (SELECT id, closed FROM sessions WHERE closed = 1 ORDER BY tstamp DESC LIMIT 1)
- ORDER BY closed;
- """;
- try {
- var statement = database.prepare (sqlcmd);
- while (statement.step ()) {
- int64 id = statement.get_int64 ("id");
- int64 closed = statement.get_int64 ("closed");
- if (closed == 0 || sessions.is_empty ()) {
- sessions.add_item (new Session.with_id (this.database, id));
- }
- }
- } catch (Error error) {
- critical (_("Failed to select from database: %s"), error.message);
- }
-
- if (sessions.is_empty ()) {
- sessions.add_item (new Session (this.database));
- }
-
- return sessions;
- }
-
- public override void import_session (Katze.Array tabs) {
- try {
- database.transaction (()=>{
- base.import_session(tabs); return true;
- });
- } catch (Error error) {
- critical (_("Failed to select from database: %s"), error.message);
- }
- }
-
- public override Base.Session get_new_session () {
- return new Session (this.database) as Base.Session;
- }
-
- internal Storage (Midori.App app) {
- GLib.Object (app: app);
-
- try {
- database = new Midori.Database ("tabby.db");
- } catch (Midori.DatabaseError schema_error) {
- error (schema_error.message);
- }
-
- if (database.first_use) {
- string config_file = Midori.Paths.get_config_filename_for_reading ("session.xbel");
- try {
- Katze.Array old_session = new Katze.Array (typeof (Katze.Item));
- Midori.array_from_file (old_session, config_file, "xbel-tiny");
- this.import_session (old_session);
- } catch (GLib.FileError file_error) {
- /* no old session.xbel -> could be a new profile -> ignore it */
- } catch (GLib.Error error) {
- critical (_("Failed to import legacy session: %s"), error.message);
- }
- }
- }
- }
- }
-
- private class Manager : Midori.Extension {
- private Base.Storage storage;
- private bool load_session () {
- /* Using get here to avoid MidoriMidoriStartup in generated C with Vala 0.20.1 */
- int load_on_startup;
- APP.settings.get ("load-on-startup", out load_on_startup);
- if (load_on_startup == Midori.MidoriStartup.BLANK_PAGE
- || load_on_startup == Midori.MidoriStartup.HOMEPAGE) {
- this.storage.start_new_session ();
- } else {
- this.storage.restore_last_sessions ();
- }
-
- /* FIXME: execute_commands should be called before session creation */
- GLib.Idle.add (this.execute_commands);
-
- return false;
- }
-
- private bool execute_commands () {
- Midori.App app = this.get_app ();
- unowned string?[] commands = app.get_data ("execute-commands");
-
- if (commands != null) {
- app.send_command (commands);
- }
-
- return false;
- }
-
- private void set_open_uris (Midori.Browser browser) {
- Midori.App app = this.get_app ();
- unowned string?[] uris = app.get_data ("open-uris");
-
- if (uris != null) {
- Katze.Array tabs = new Katze.Array (typeof (Katze.Item));
-
- for(int i = 0; uris[i] != null; i++) {
- Katze.Item item = new Katze.Item ();
- item.name = uris[i];
- item.uri = Midori.Sokoke.magic_uri (uris[i], true, true);
- if (item.uri != null) {
- tabs.add_item (item);
- }
- }
- if (!tabs.is_empty()) {
- browser.set_data ("tabby-open-uris", tabs);
- }
- }
-
- app.add_browser.disconnect (this.set_open_uris);
- }
-
- private void browser_added (Midori.Browser browser) {
- Base.Session? session = browser.get_data<Base.Session> ("tabby-session");
- if (session == null) {
- session = this.storage.get_new_session () as Base.Session;
- browser.set_data<Base.Session> ("tabby-session", session);
- session.attach (browser);
- }
- }
-
- private void browser_removed (Midori.Browser browser) {
- Base.Session? session = browser.get_data<Base.Session> ("tabby-session");
- if (session == null) {
- GLib.warning ("missing session");
- } else {
- session.close ();
-
- /* Using get here to avoid MidoriMidoriStartup in generated C with Vala 0.20.1 */
- int load_on_startup;
- APP.settings.get ("load-on-startup", out load_on_startup);
-
- if (browser.destroy_with_parent
- || load_on_startup < Midori.MidoriStartup.LAST_OPEN_PAGES) {
- /* Remove js popups and close if not restoring on startup */
- session.remove ();
- }
- }
- }
-
- private void activated (Midori.App app) {
- APP = app;
- unowned string? restore_count = GLib.Environment.get_variable ("TABBY_RESTORE_COUNT");
- if (restore_count != null) {
- int count = int.parse (restore_count);
- if (count >= 1) {
- IDLE_RESTORE_COUNT = count;
- }
- }
-
- /* FixMe: provide an option to replace Local.Storage with IStorage based Objects */
- this.storage = new Local.Storage (this.get_app ()) as Base.Storage;
-
- app.add_browser.connect (this.set_open_uris);
- app.add_browser.connect (this.browser_added);
- app.remove_browser.connect (this.browser_removed);
-
- GLib.Idle.add (this.load_session);
- }
-
- private void deactivated () {
- /* set_open_uris will disconnect itself if called,
- but it may have been called before we are deactivated */
- APP.add_browser.disconnect (this.set_open_uris);
- APP.add_browser.disconnect (this.browser_added);
- APP.remove_browser.disconnect (this.browser_removed);
- APP = null;
-
- this.storage = null;
- }
-
- internal Manager () {
- GLib.Object (name: _("Tabby"),
- description: _("Tab and session management."),
- version: "0.1",
- authors: "André Stösel <andre@stoesel.de>");
-
- this.activate.connect (this.activated);
- this.deactivate.connect (this.deactivated);
- }
- }
-}
-
-public Midori.Extension extension_init () {
- return new Tabby.Manager ();
-}
diff --git a/extensions/tabs-minimized.c b/extensions/tabs-minimized.c
deleted file mode 100644
index 0e097865..00000000
--- a/extensions/tabs-minimized.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- Copyright (C) 2008-2010 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.
-*/
-
-#include <midori/midori.h>
-
-static void
-tabs_minimized_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension);
-
-static void
-tabs_minimized_add_tab_cb (MidoriBrowser* browser,
- MidoriView* tab,
- MidoriExtension* extension);
-
-static void
-tabs_minimized_deactivate_cb (MidoriExtension* extension,
- MidoriBrowser* browser)
-{
- MidoriApp* app = midori_extension_get_app (extension);
-
- g_signal_handlers_disconnect_by_func (
- extension, tabs_minimized_deactivate_cb, browser);
- g_signal_handlers_disconnect_by_func (
- app, tabs_minimized_app_add_browser_cb, extension);
- g_signal_handlers_disconnect_by_func (
- browser, tabs_minimized_add_tab_cb, extension);
-}
-
-static void
-tabs_minimized_add_tab_cb (MidoriBrowser* browser,
- MidoriView* tab,
- MidoriExtension* extension)
-{
- g_object_set (tab, "minimized", TRUE, NULL);
-}
-
-static void
-tabs_minimized_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension)
-{
- g_signal_connect (browser, "add-tab",
- G_CALLBACK (tabs_minimized_add_tab_cb), extension);
- g_signal_connect (extension, "deactivate",
- G_CALLBACK (tabs_minimized_deactivate_cb), browser);
-}
-
-static void
-tabs_minimized_activate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- KatzeArray* browsers;
- MidoriBrowser* browser;
-
- browsers = katze_object_get_object (app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- tabs_minimized_app_add_browser_cb (app, browser, extension);
- g_object_unref (browsers);
- g_signal_connect (app, "add-browser",
- G_CALLBACK (tabs_minimized_app_add_browser_cb), extension);
-}
-
-MidoriExtension*
-extension_init (void)
-{
- MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", _("Only Icons on Tabs by default"),
- "description", _("New tabs have no label by default"),
- "version", "0.1" MIDORI_VERSION_SUFFIX,
- "authors", "MonkeyOfDoom <pixelmonkey@ensellitis.com>",
- NULL);
-
- g_signal_connect (extension, "activate",
- G_CALLBACK (tabs_minimized_activate_cb), NULL);
-
- return extension;
-}
-
diff --git a/extensions/tabs2one.c b/extensions/tabs2one.c
deleted file mode 100644
index 2017da23..00000000
--- a/extensions/tabs2one.c
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- Copyright (C) 2013 Eder Sosa <eder.sohe@gmail.com>
-
- 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.
-*/
-
-#include <midori/midori.h>
-
-typedef struct
-{
- gchar* folder;
- gchar* filename;
- gchar* uri;
-} tabs2onePriv;
-
-static tabs2onePriv* priv;
-
-tabs2onePriv*
-tabs2one_private_new ()
-{
- tabs2onePriv* priv = g_slice_new (tabs2onePriv);
- priv->folder = NULL;
- priv->filename = NULL;
- priv->uri = NULL;
-
- return priv;
-}
-
-void tabs2one_private_destroy (tabs2onePriv* priv)
-{
- katze_assign (priv->folder, NULL);
- katze_assign (priv->filename, NULL);
- katze_assign (priv->uri, NULL);
- g_slice_free (tabs2onePriv, priv);
-}
-
-static void
-tabs2one_dom_click_restore_item_cb (WebKitDOMNode *element,
- WebKitDOMEvent *dom_event,
- WebKitWebView *webview);
-
-static void
-tabs2one_dom_click_remove_item_cb (WebKitDOMNode *element,
- WebKitDOMEvent *dom_event,
- WebKitWebView *webview);
-
-static gchar*
-tabs2one_id_generator (void)
-{
- GString* id = g_string_new("");
- GRand* generator = g_rand_new();
- gint32 id1 = g_rand_int_range (generator, 1000, 9999);
- gint32 id2 = g_rand_int_range (generator, 1000, 9999);
- g_rand_free(generator);
- g_string_printf(id, "%i-%i", id1, id2);
- return g_string_free(id, FALSE);
-}
-
-static void
-tabs2one_dom_create_item (WebKitDOMDocument* doc,
- const gchar* icon,
- const gchar* uri,
- const gchar* title)
-{
- WebKitDOMElement* body = webkit_dom_document_query_selector(doc, "body", NULL);
- WebKitDOMElement* item = webkit_dom_document_create_element(doc, "div", NULL);
- WebKitDOMElement* favicon = webkit_dom_document_create_element(doc, "img", NULL);
- WebKitDOMElement* link = webkit_dom_document_create_element(doc, "a", NULL);
- WebKitDOMElement* close_link = webkit_dom_document_create_element(doc, "a", NULL);
- WebKitDOMElement* close_button = webkit_dom_document_create_element (doc, "img", NULL);
- WebKitDOMElement* br = webkit_dom_document_create_element(doc, "br", NULL);
- WebKitDOMText* content = webkit_dom_document_create_text_node(doc, title);
-
- webkit_dom_element_set_attribute(item, "id", tabs2one_id_generator(), NULL);
- webkit_dom_element_set_attribute(item, "class", "item", NULL);
- webkit_dom_element_set_attribute(item, "style", "padding: 5px;", NULL);
-
- webkit_dom_element_set_attribute(close_link, "class", "close-link", NULL);
- webkit_dom_element_set_attribute(close_link, "target", "_blank", NULL);
- webkit_dom_element_set_attribute(close_link, "href", "about:blank", NULL);
- webkit_dom_element_set_attribute(close_button, "src", "res://close.png", NULL);
- webkit_dom_element_set_attribute(close_button, "width", "16px", NULL);
- webkit_dom_element_set_attribute(close_button, "height", "16px", NULL);
-
- webkit_dom_element_set_attribute(favicon, "src", icon, NULL);
- webkit_dom_element_set_attribute(favicon, "width", "16px", NULL);
- webkit_dom_element_set_attribute(favicon, "height", "16px", NULL);
- webkit_dom_element_set_attribute(favicon, "style", "padding-left: 5px;", NULL);
-
- webkit_dom_element_set_attribute(link, "class", "restore-link",NULL);
- webkit_dom_element_set_attribute(link, "href", uri, NULL);
- webkit_dom_element_set_attribute(link, "style", "padding-left: 5px;", NULL);
- webkit_dom_element_set_attribute(link, "target", "_blank", NULL);
-
- webkit_dom_node_append_child(WEBKIT_DOM_NODE(link), WEBKIT_DOM_NODE(content), NULL);
- webkit_dom_node_append_child(WEBKIT_DOM_NODE(item), WEBKIT_DOM_NODE(close_link), NULL);
- webkit_dom_node_append_child(WEBKIT_DOM_NODE(close_link), WEBKIT_DOM_NODE(close_button), NULL);
- webkit_dom_node_append_child(WEBKIT_DOM_NODE(item), WEBKIT_DOM_NODE(favicon), NULL);
- webkit_dom_node_append_child(WEBKIT_DOM_NODE(item), WEBKIT_DOM_NODE(link), NULL);
- webkit_dom_node_append_child(WEBKIT_DOM_NODE(item), WEBKIT_DOM_NODE(br), NULL);
- webkit_dom_node_append_child(WEBKIT_DOM_NODE(body), WEBKIT_DOM_NODE(item), NULL);
-}
-
-static void
-tabs2one_cache_create_dir (void)
-{
- midori_paths_mkdir_with_parents (priv->folder, 0700);
-}
-
-static gchar*
-tabs2one_cache_get_filename (void)
-{
- return priv->filename;
-}
-
-static gchar*
-tabs2one_cache_get_uri (void)
-{
- return priv->uri;
-}
-
-static bool
-tabs2one_cache_exist (void)
-{
- return g_file_test (priv->filename, G_FILE_TEST_EXISTS);
-}
-
-static gboolean
-tabs2one_is_uri_tabs2one_tab (const gchar* uri)
-{
- return g_str_equal (uri, tabs2one_cache_get_uri ());
-}
-
-static void
-tabs2one_dom_add_click_listeners (WebKitDOMDocument* doc,
- WebKitWebView* webview)
-{
- WebKitDOMNodeList *elements = webkit_dom_document_query_selector_all(doc, ".restore-link", NULL);
-
- int i;
-
- for (i = 0; i < webkit_dom_node_list_get_length(elements); i++)
- {
- WebKitDOMNode *element = webkit_dom_node_list_item(elements, i);
- webkit_dom_event_target_add_event_listener(
- WEBKIT_DOM_EVENT_TARGET(element), "click",
- G_CALLBACK (tabs2one_dom_click_restore_item_cb), TRUE, webview);
- }
-
- elements = webkit_dom_document_query_selector_all(doc, ".close-link", NULL);
- for (i = 0; i < webkit_dom_node_list_get_length(elements); i++)
- {
- WebKitDOMNode *element = webkit_dom_node_list_item(elements, i);
- webkit_dom_event_target_add_event_listener(
- WEBKIT_DOM_EVENT_TARGET(element), "click",
- G_CALLBACK (tabs2one_dom_click_remove_item_cb), TRUE, webview);
- }
-}
-
-static bool
-tabs2one_cache_write_file (WebKitWebView* webview)
-{
- WebKitDOMDocument* doc = webkit_web_view_get_dom_document(webview);
- WebKitDOMHTMLDocument* dochtml = (WebKitDOMHTMLDocument*)doc;
- WebKitDOMHTMLElement* elementhtml = (WebKitDOMHTMLElement*)dochtml;
- const gchar* content = webkit_dom_html_element_get_inner_html(elementhtml);
- if (content == NULL)
- return FALSE;
-
- tabs2one_dom_add_click_listeners (doc, webview);
-
- return g_file_set_contents(tabs2one_cache_get_filename (), content, -1, NULL);
-}
-
-static void
-tabs2one_onload_create_items_cb(WebKitWebView* webview,
- WebKitWebFrame* webframe,
- MidoriBrowser* browser)
-{
- WebKitDOMDocument* doc = webkit_web_view_get_dom_document(webview);
-
- const gchar* icon;
- const gchar* title;
- const gchar* uri;
-
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs; tabs = g_list_next (tabs))
- {
- icon = midori_view_get_icon_uri (tabs->data);
- if (icon == NULL) icon = "";
- title = midori_view_get_display_title (tabs->data);
- uri = midori_view_get_display_uri (tabs->data);
-
- if (!tabs2one_is_uri_tabs2one_tab (uri))
- {
- if (!midori_uri_is_blank (uri))
- tabs2one_dom_create_item(doc, icon, uri, title);
- }
- }
-
-
- if (tabs2one_cache_write_file (webview))
- {
- tabs = midori_browser_get_tabs (browser);
- while ((tabs = g_list_next (tabs)))
- midori_browser_close_tab (browser, tabs->data);
-
- tabs2one_dom_add_click_listeners (doc, webview);
- midori_browser_set_current_uri (browser, tabs2one_cache_get_uri ());
- }
-
- g_list_free(tabs);
-}
-
-static void
-tabs2one_reload_connected_events_cb(WebKitWebView* webview,
- WebKitWebFrame* frame,
- MidoriView* view)
-{
- const gchar* uri = midori_view_get_display_uri(view);
-
- if (tabs2one_is_uri_tabs2one_tab (uri))
- {
- WebKitDOMDocument* doc = webkit_web_view_get_dom_document(webview);
- tabs2one_dom_add_click_listeners (doc, webview);
- }
-}
-
-
-static void
-tabs2one_add_tab_cb (MidoriBrowser* browser,
- MidoriView* view,
- MidoriExtension* extension)
-{
- WebKitWebView* webview = WEBKIT_WEB_VIEW (midori_view_get_web_view(view));
- g_signal_connect (webview, "document-load-finished",
- G_CALLBACK (tabs2one_reload_connected_events_cb), view);
-}
-
-static void
-tabs2one_dom_click_restore_item_cb (WebKitDOMNode *element,
- WebKitDOMEvent *dom_event,
- WebKitWebView *webview)
-{
- webkit_dom_event_prevent_default (dom_event);
- MidoriView* view = midori_view_get_for_widget (GTK_WIDGET (webview));
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (webview));
- WebKitDOMNode* item = webkit_dom_node_get_parent_node (element);
- WebKitDOMNode* body = webkit_dom_node_get_parent_node (item);
- const gchar* uri = webkit_dom_element_get_attribute(WEBKIT_DOM_ELEMENT(element), "href");
- midori_browser_add_uri (browser, uri);
-
- WebKitDOMDocument* doc = webkit_web_view_get_dom_document (webview);
- webkit_dom_node_remove_child(body, item, NULL);
- tabs2one_cache_write_file (webview);
-
- WebKitDOMNodeList *elements = webkit_dom_document_query_selector_all(doc, ".restore-link", NULL);
- if (webkit_dom_node_list_get_length(elements) <= 0){
- midori_browser_close_tab(browser, GTK_WIDGET(view));
- }
-}
-
-static void
-tabs2one_dom_click_remove_item_cb (WebKitDOMNode *element,
- WebKitDOMEvent *dom_event,
- WebKitWebView *webview)
-{
- webkit_dom_event_prevent_default (dom_event);
- MidoriView* view = midori_view_get_for_widget (GTK_WIDGET (webview));
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (webview));
- WebKitDOMNode* item = webkit_dom_node_get_parent_node (element);
- WebKitDOMNode* body = webkit_dom_node_get_parent_node (item);
-
- WebKitDOMDocument* doc = webkit_web_view_get_dom_document (webview);
- webkit_dom_node_remove_child(body, item, NULL);
- tabs2one_cache_write_file (webview);
-
- WebKitDOMNodeList *elements = webkit_dom_document_query_selector_all(doc, ".close-link", NULL);
- if (webkit_dom_node_list_get_length(elements) <= 0){
- midori_browser_close_tab(browser, GTK_WIDGET(view));
- }
-}
-
-static void
-tabs2one_apply_cb (GtkWidget* menuitem,
- MidoriBrowser* browser)
-{
- GtkWidget* tab = NULL;
-
- if (!tabs2one_cache_exist ())
- {
- GString* tpl = g_string_new ("<html>\n<title>");
-
- g_string_append_printf (tpl, "%s", _("Tabs to One"));
- g_string_append (tpl, "</title>\n<head><meta charset=\"utf-8\"></head><body>\n");
- g_string_append_printf (tpl, "<h2>%s</h2>\n", _("Tabs you collected so far"));
- g_string_append_printf (tpl, "<div><span>%s</span></div>\n", _("Clicking an item restores a tab."));
- g_string_append (tpl, "</body>\n</html>\n");
-
- g_file_set_contents(tabs2one_cache_get_filename (), g_string_free (tpl, FALSE), -1, NULL);
- }
-
- tab = midori_browser_add_uri (browser, tabs2one_cache_get_uri ());
-
- WebKitWebView* webview = WEBKIT_WEB_VIEW (midori_view_get_web_view(MIDORI_VIEW (tab)));
- midori_browser_set_current_tab (browser, tab);
-
- g_signal_connect (webview, "document-load-finished",
- G_CALLBACK (tabs2one_onload_create_items_cb), browser);
-}
-
-static void
-tabs2one_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension);
-
-static void
-tabs2one_browser_populate_tool_menu_cb (MidoriBrowser* browser,
- GtkWidget* menu,
- MidoriExtension* extension)
-{
- GtkWidget* menuitem = gtk_menu_item_new_with_mnemonic (_("Tabs to _One"));
-
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (tabs2one_apply_cb), browser);
- gtk_widget_show (menuitem);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-}
-
-static void
-tabs2one_deactivate_cb (MidoriExtension* extension,
- MidoriBrowser* browser)
-{
- MidoriApp* app = midori_extension_get_app (extension);
-
- g_signal_handlers_disconnect_by_func (
- browser, tabs2one_browser_populate_tool_menu_cb, extension);
- g_signal_handlers_disconnect_by_func (
- extension, tabs2one_deactivate_cb, browser);
- g_signal_handlers_disconnect_by_func (
- app, tabs2one_app_add_browser_cb, extension);
- g_signal_handlers_disconnect_by_func (
- browser, tabs2one_add_tab_cb, extension);
-
- tabs2one_private_destroy (priv);
-}
-
-static void
-tabs2one_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- MidoriExtension* extension)
-{
- g_signal_connect (browser, "populate-tool-menu",
- G_CALLBACK (tabs2one_browser_populate_tool_menu_cb), extension);
- g_signal_connect (extension, "deactivate",
- G_CALLBACK (tabs2one_deactivate_cb), browser);
- g_signal_connect_after (browser, "add-tab",
- G_CALLBACK (tabs2one_add_tab_cb), extension);
-
- tabs2one_cache_create_dir();
-}
-
-static void
-tabs2one_activate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- const gchar* config_dir = midori_extension_get_config_dir (extension);
- priv = tabs2one_private_new ();
- KatzeArray* browsers;
- MidoriBrowser* browser;
- gchar* filename, *uri;
-
- filename = g_build_filename (config_dir, "tabs2one.html", NULL);
- uri = g_filename_to_uri (filename, NULL, NULL);
-
- priv->filename = g_strdup (filename);
- priv->uri = g_strdup (uri);
- priv->folder = g_strdup (config_dir);
-
- browsers = katze_object_get_object (app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- tabs2one_app_add_browser_cb (app, browser, extension);
- g_object_unref (browsers);
- g_signal_connect (app, "add-browser",
- G_CALLBACK (tabs2one_app_add_browser_cb), extension);
-
- g_free (filename);
- g_free (uri);
-}
-
-MidoriExtension*
-extension_init (void)
-{
- MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", _("Tabs to One"),
- "description", _("Closes all open tabs and creates new tab with tabs links"),
- "version", "0.1" MIDORI_VERSION_SUFFIX,
- "authors", "Eder Sosa <eder.sohe@gmail.com>",
- NULL);
-
- g_signal_connect (extension, "activate",
- G_CALLBACK (tabs2one_activate_cb), NULL);
-
- return extension;
-}
diff --git a/extensions/toolbar-editor.c b/extensions/toolbar-editor.c
deleted file mode 100644
index 5aebc058..00000000
--- a/extensions/toolbar-editor.c
+++ /dev/null
@@ -1,640 +0,0 @@
-/*
- Copyright (C) 2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)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.
-*/
-
-#include <midori/midori.h>
-
-#include "config.h"
-
-typedef struct
-{
- GtkWidget *dialog;
-
- GtkTreeView *tree_available;
- GtkTreeView *tree_used;
-
- GtkListStore *store_available;
- GtkListStore *store_used;
-
- GtkTreePath *last_drag_path;
- GtkTreeViewDropPosition last_drag_pos;
-
- GtkWidget *drag_source;
-
- GtkActionGroup *action_group;
- MidoriBrowser *browser;
-} TBEditorWidget;
-
-typedef struct
-{
- GSList *used_items, *all_items;
- TBEditorWidget *tbw;
-} TBEditorWindow;
-
-enum
-{
- TB_EDITOR_COL_ACTION,
- TB_EDITOR_COL_LABEL,
- TB_EDITOR_COL_ICON,
- TB_EDITOR_COLS_MAX
-};
-
-static TBEditorWindow *tbe_window=NULL;
-
-static const GtkTargetEntry tb_editor_dnd_targets[] =
-{
- { "MIDORI_TB_EDITOR_ROW", 0, 0 }
-};
-static const gint tb_editor_dnd_targets_len = G_N_ELEMENTS(tb_editor_dnd_targets);
-
-static void tb_editor_browser_populate_toolbar_menu_cb(MidoriBrowser *browser, GtkWidget *menu,
- MidoriExtension *ext);
-
-static void tb_editor_app_add_browser_cb(MidoriApp *app, MidoriBrowser *browser, MidoriExtension *ext);
-
-
-static void tb_editor_deactivate_cb(MidoriExtension *extension, MidoriBrowser *browser)
-{
- MidoriApp *app = midori_extension_get_app(extension);
-
- g_signal_handlers_disconnect_by_func(browser, tb_editor_browser_populate_toolbar_menu_cb, extension);
- g_signal_handlers_disconnect_by_func(extension, tb_editor_deactivate_cb, browser);
- g_signal_handlers_disconnect_by_func(app, tb_editor_app_add_browser_cb, extension);
-}
-
-
-static void tb_editor_set_item_values(TBEditorWidget *tbw, const gchar *action_name,
- GtkListStore *store, GtkTreeIter *iter)
-{
- gchar *icon = NULL;
- gchar *label = NULL;
- gchar *label_clean = NULL;
- GtkAction *action;
-
- action = gtk_action_group_get_action(tbw->action_group, action_name);
- if (action != NULL)
- {
- icon = katze_object_get_string(action, "icon-name");
- if (icon == NULL)
- {
- icon = katze_object_get_string(action, "stock-id");
- }
-
- label = katze_object_get_string(action, "label");
- if (label != NULL)
- label_clean = katze_strip_mnemonics(label);
- }
-
- gtk_list_store_set(store, iter,
- TB_EDITOR_COL_ACTION, action_name,
- TB_EDITOR_COL_LABEL, label_clean,
- TB_EDITOR_COL_ICON, icon,
- -1);
-
- g_free(icon);
- g_free(label);
- g_free(label_clean);
-}
-
-
-static GSList *tb_editor_array_to_list(const gchar **items)
-{
- const gchar **name;
- GSList *list = NULL;
-
- name = items;
- while (*name != NULL)
- {
- /* A "new tab" button is already part of the notebook */
- if (*name[0] != '\0' && strcmp (*name, "TabNew"))
- list = g_slist_append(list, g_strdup(*name));
- name++;
- }
-
- return list;
-}
-
-
-static GSList *tb_editor_parse_active_items(MidoriBrowser *browser)
-{
- gchar *items;
- gchar **names;
- GSList *list = NULL;
- MidoriWebSettings *settings;
-
- settings = midori_browser_get_settings(browser);
- g_object_get(settings, "toolbar-items", &items, NULL);
-
- names = g_strsplit(items ? items : "", ",", 0);
- list = tb_editor_array_to_list((const gchar **) names);
-
- g_strfreev(names);
- g_free(items);
-
- return list;
-}
-
-
-static GSList *tb_editor_get_available_actions(MidoriBrowser *browser)
-{
- GSList *list = NULL;
-
- list = tb_editor_array_to_list(midori_browser_get_toolbar_actions(browser));
-
- return list;
-}
-
-
-static void tb_editor_scroll_to_iter(GtkTreeView *treeview, GtkTreeIter *iter)
-{
- GtkTreePath *path = gtk_tree_model_get_path(gtk_tree_view_get_model(treeview), iter);
- gtk_tree_view_scroll_to_cell(treeview, path, NULL, TRUE, 0.5, 0.0);
- gtk_tree_path_free(path);
-}
-
-
-static void tb_editor_free_path(TBEditorWidget *tbw)
-{
- if (tbw->last_drag_path != NULL)
- {
- gtk_tree_path_free(tbw->last_drag_path);
- tbw->last_drag_path = NULL;
- }
-}
-
-
-static void tb_editor_btn_remove_clicked_cb(GtkWidget *button, TBEditorWidget *tbw)
-{
- GtkTreeModel *model_used;
- GtkTreeSelection *selection_used;
- GtkTreeIter iter_used, iter_new;
- gchar *action_name;
-
- selection_used = gtk_tree_view_get_selection(tbw->tree_used);
- if (gtk_tree_selection_get_selected(selection_used, &model_used, &iter_used))
- {
- gtk_tree_model_get(model_used, &iter_used, TB_EDITOR_COL_ACTION, &action_name, -1);
- {
- if (gtk_list_store_remove(tbw->store_used, &iter_used))
- gtk_tree_selection_select_iter(selection_used, &iter_used);
-
- if (g_strcmp0(action_name, "Separator") != 0)
- {
- gtk_list_store_append(tbw->store_available, &iter_new);
- tb_editor_set_item_values(tbw, action_name, tbw->store_available, &iter_new);
- tb_editor_scroll_to_iter(tbw->tree_available, &iter_new);
- }
- }
- g_free(action_name);
- }
-}
-
-
-static void tb_editor_btn_add_clicked_cb(GtkWidget *button, TBEditorWidget *tbw)
-{
- GtkTreeModel *model_available;
- GtkTreeSelection *selection_available, *selection_used;
- GtkTreeIter iter_available, iter_new, iter_selected;
- gchar *action_name;
-
- selection_available = gtk_tree_view_get_selection(tbw->tree_available);
- if (gtk_tree_selection_get_selected(selection_available, &model_available, &iter_available))
- {
- gtk_tree_model_get(model_available, &iter_available, TB_EDITOR_COL_ACTION, &action_name, -1);
- if (g_strcmp0(action_name, "Separator") != 0)
- {
- if (gtk_list_store_remove(tbw->store_available, &iter_available))
- gtk_tree_selection_select_iter(selection_available, &iter_available);
- }
-
- selection_used = gtk_tree_view_get_selection(tbw->tree_used);
- if (gtk_tree_selection_get_selected(selection_used, NULL, &iter_selected))
- {
- gtk_list_store_insert_before(tbw->store_used, &iter_new, &iter_selected);
- tb_editor_set_item_values(tbw, action_name, tbw->store_used, &iter_new);
- }
- else
- {
- gtk_list_store_append(tbw->store_used, &iter_new);
- tb_editor_set_item_values(tbw, action_name, tbw->store_used, &iter_new);
- }
-
- tb_editor_scroll_to_iter(tbw->tree_used, &iter_new);
-
- g_free(action_name);
- }
-}
-
-
-static gboolean tb_editor_drag_motion_cb(GtkWidget *widget, GdkDragContext *drag_context,
- gint x, gint y, guint ltime, TBEditorWidget *tbw)
-{
- if (tbw->last_drag_path != NULL)
- gtk_tree_path_free(tbw->last_drag_path);
- gtk_tree_view_get_drag_dest_row(GTK_TREE_VIEW(widget),
- &(tbw->last_drag_path), &(tbw->last_drag_pos));
-
- return FALSE;
-}
-
-
-static void tb_editor_drag_data_get_cb(GtkWidget *widget, GdkDragContext *context,
- GtkSelectionData *data, guint info, guint ltime,
- TBEditorWidget *tbw)
-{
- GtkTreeIter iter;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GdkAtom atom;
- gchar *name;
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
- if (! gtk_tree_selection_get_selected(selection, &model, &iter))
- return;
-
- gtk_tree_model_get(model, &iter, TB_EDITOR_COL_ACTION, &name, -1);
- if (name == NULL || *name == '\0')
- {
- g_free(name);
- return;
- }
-
- atom = gdk_atom_intern(tb_editor_dnd_targets[0].target, FALSE);
- gtk_selection_data_set(data, atom, 8, (guchar*) name, strlen(name));
-
- g_free(name);
-
- tbw->drag_source = widget;
-}
-
-
-static void tb_editor_drag_data_rcvd_cb(GtkWidget *widget, GdkDragContext *context,
- gint x, gint y, GtkSelectionData *data, guint info,
- guint ltime, TBEditorWidget *tbw)
-{
- GtkTreeView *tree = GTK_TREE_VIEW(widget);
- gboolean del = FALSE;
-
- if (gtk_selection_data_get_length (data) >= 0 && gtk_selection_data_get_format (data) == 8)
- {
- gboolean is_sep;
- gchar *text = NULL;
-
- text = (gchar*) gtk_selection_data_get_data (data);
-
- is_sep = (g_strcmp0(text, "Separator") == 0);
- /* If the source of the action is equal to the target, we do just re-order and so need
- * to delete the separator to get it moved, not just copied. */
- if (is_sep && widget == tbw->drag_source)
- is_sep = FALSE;
-
- if (tree != tbw->tree_available || ! is_sep)
- {
- GtkTreeIter iter, iter_before, *iter_before_ptr;
- GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(tree));
-
- if (tbw->last_drag_path != NULL)
- {
- gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter_before, tbw->last_drag_path);
-
- if (gtk_list_store_iter_is_valid(store, &iter_before))
- iter_before_ptr = &iter_before;
- else
- iter_before_ptr = NULL;
-
- if (tbw->last_drag_pos == GTK_TREE_VIEW_DROP_BEFORE ||
- tbw->last_drag_pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE)
- gtk_list_store_insert_before(store, &iter, iter_before_ptr);
- else
- gtk_list_store_insert_after(store, &iter, iter_before_ptr);
-
- tb_editor_set_item_values(tbw, text, store, &iter);
- }
- else
- {
- gtk_list_store_append(store, &iter);
- tb_editor_set_item_values(tbw, text, store, &iter);
- }
-
- tb_editor_scroll_to_iter(tree, &iter);
- }
- if (tree != tbw->tree_used || ! is_sep)
- del = TRUE;
- }
-
- tbw->drag_source = NULL; /* reset the value just to be sure */
- tb_editor_free_path(tbw);
- gtk_drag_finish(context, TRUE, del, ltime);
-}
-
-
-static gboolean tb_editor_foreach_used(GtkTreeModel *model, GtkTreePath *path,
- GtkTreeIter *iter, gpointer data)
-{
- gchar *action_name;
-
- gtk_tree_model_get(model, iter, TB_EDITOR_COL_ACTION, &action_name, -1);
-
- if (action_name != NULL && *action_name != '\0')
- {
- g_string_append(data, action_name);
- g_string_append_c(data, ',');
- }
-
- g_free(action_name);
- return FALSE;
-}
-
-
-static void tb_editor_update_toolbar(TBEditorWidget *tbw)
-{
- MidoriWebSettings *settings;
- GString *str = g_string_new(NULL);
-
- gtk_tree_model_foreach(GTK_TREE_MODEL(tbw->store_used), tb_editor_foreach_used, str);
-
- settings = midori_browser_get_settings(tbw->browser);
- g_object_set(settings, "toolbar-items", str->str, NULL);
-
- g_string_free(str, TRUE);
-}
-
-
-static void tb_editor_available_items_changed_cb(GtkTreeModel *model, GtkTreePath *arg1,
- GtkTreeIter *arg2, TBEditorWidget *tbw)
-{
- tb_editor_update_toolbar(tbw);
-}
-
-
-static void tb_editor_available_items_deleted_cb(GtkTreeModel *model, GtkTreePath *arg1,
- TBEditorWidget *tbw)
-{
- tb_editor_update_toolbar(tbw);
-}
-
-
-static TBEditorWidget *tb_editor_create_dialog(MidoriBrowser *parent)
-{
- GtkWidget *dialog, *vbox, *hbox, *vbox_buttons, *button_add, *button_remove;
- GtkWidget *swin_available, *swin_used, *tree_available, *tree_used, *label;
- GtkCellRenderer *text_renderer, *icon_renderer;
- GtkTreeViewColumn *column;
- TBEditorWidget *tbw = g_new(TBEditorWidget, 1);
-
- dialog = gtk_dialog_new_with_buttons(_("Customize Toolbar"),
- GTK_WINDOW(parent),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
- vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
- gtk_box_set_spacing(GTK_BOX(vbox), 6);
- gtk_widget_set_name(dialog, "GeanyDialog");
- gtk_window_set_default_size(GTK_WINDOW(dialog), -1, 400);
- gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
-
- tbw->store_available = gtk_list_store_new(TB_EDITOR_COLS_MAX,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
- tbw->store_used = gtk_list_store_new(TB_EDITOR_COLS_MAX,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
-
- label = gtk_label_new(
- _("Select items to be displayed on the toolbar. Items can be reordered by drag and drop."));
- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
-
- tree_available = gtk_tree_view_new();
- gtk_tree_view_set_model(GTK_TREE_VIEW(tree_available), GTK_TREE_MODEL(tbw->store_available));
- gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree_available), TRUE);
- gtk_tree_sortable_set_sort_column_id(
- GTK_TREE_SORTABLE(tbw->store_available), TB_EDITOR_COL_LABEL, GTK_SORT_ASCENDING);
-
- icon_renderer = gtk_cell_renderer_pixbuf_new();
- column = gtk_tree_view_column_new_with_attributes(
- NULL, icon_renderer, "stock-id", TB_EDITOR_COL_ICON, NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(tree_available), column);
-
- text_renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(
- _("Available Items"), text_renderer, "text", TB_EDITOR_COL_LABEL, NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(tree_available), column);
-
- swin_available = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin_available),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swin_available), GTK_SHADOW_ETCHED_IN);
- gtk_container_add(GTK_CONTAINER(swin_available), tree_available);
-
- tree_used = gtk_tree_view_new();
- gtk_tree_view_set_model(GTK_TREE_VIEW(tree_used), GTK_TREE_MODEL(tbw->store_used));
- gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree_used), TRUE);
- gtk_tree_view_set_reorderable(GTK_TREE_VIEW(tree_used), TRUE);
-
- icon_renderer = gtk_cell_renderer_pixbuf_new();
- column = gtk_tree_view_column_new_with_attributes(
- NULL, icon_renderer, "stock-id", TB_EDITOR_COL_ICON, NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(tree_used), column);
-
- text_renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(
- _("Displayed Items"), text_renderer, "text", TB_EDITOR_COL_LABEL, NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(tree_used), column);
-
- swin_used = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin_used),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swin_used), GTK_SHADOW_ETCHED_IN);
- gtk_container_add(GTK_CONTAINER(swin_used), tree_used);
-
- /* drag'n'drop */
- gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(tree_available), GDK_BUTTON1_MASK,
- tb_editor_dnd_targets, tb_editor_dnd_targets_len, GDK_ACTION_MOVE);
- gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(tree_available),
- tb_editor_dnd_targets, tb_editor_dnd_targets_len, GDK_ACTION_MOVE);
- g_signal_connect(tree_available, "drag-data-get",
- G_CALLBACK(tb_editor_drag_data_get_cb), tbw);
- g_signal_connect(tree_available, "drag-data-received",
- G_CALLBACK(tb_editor_drag_data_rcvd_cb), tbw);
- g_signal_connect(tree_available, "drag-motion",
- G_CALLBACK(tb_editor_drag_motion_cb), tbw);
-
- gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(tree_used), GDK_BUTTON1_MASK,
- tb_editor_dnd_targets, tb_editor_dnd_targets_len, GDK_ACTION_MOVE);
- gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(tree_used),
- tb_editor_dnd_targets, tb_editor_dnd_targets_len, GDK_ACTION_MOVE);
- g_signal_connect(tree_used, "drag-data-get",
- G_CALLBACK(tb_editor_drag_data_get_cb), tbw);
- g_signal_connect(tree_used, "drag-data-received",
- G_CALLBACK(tb_editor_drag_data_rcvd_cb), tbw);
- g_signal_connect(tree_used, "drag-motion",
- G_CALLBACK(tb_editor_drag_motion_cb), tbw);
-
-
- button_add = gtk_button_new();
- gtk_button_set_image(GTK_BUTTON(button_add),
- gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON));
- button_remove = gtk_button_new();
- g_signal_connect(button_add, "clicked", G_CALLBACK(tb_editor_btn_add_clicked_cb), tbw);
- gtk_button_set_image(GTK_BUTTON(button_remove),
- gtk_image_new_from_stock(GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON));
- g_signal_connect(button_remove, "clicked", G_CALLBACK(tb_editor_btn_remove_clicked_cb), tbw);
-
- vbox_buttons = gtk_vbox_new(FALSE, 6);
- /* FIXME this is a little hack'ish, any better ideas? */
- gtk_box_pack_start(GTK_BOX(vbox_buttons), gtk_label_new(""), TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(vbox_buttons), button_add, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox_buttons), button_remove, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox_buttons), gtk_label_new(""), TRUE, TRUE, 0);
-
- hbox = gtk_hbox_new(FALSE, 6);
- gtk_box_pack_start(GTK_BOX(hbox), swin_available, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), vbox_buttons, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), swin_used, TRUE, TRUE, 0);
-
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 6);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
-
- gtk_widget_show_all(vbox);
-
- g_object_unref(tbw->store_available);
- g_object_unref(tbw->store_used);
-
- tbw->dialog = dialog;
- tbw->tree_available = GTK_TREE_VIEW(tree_available);
- tbw->tree_used = GTK_TREE_VIEW(tree_used);
-
- tbw->last_drag_path = NULL;
-
- return tbw;
-}
-
-static void tb_editor_response_cb(GtkWidget* inDialog,
- gint inResponse,
- gpointer inUserData)
-{
- gtk_widget_destroy(tbe_window->tbw->dialog);
-
- g_slist_foreach(tbe_window->used_items, (GFunc) g_free, NULL);
- g_slist_foreach(tbe_window->all_items, (GFunc) g_free, NULL);
- g_slist_free(tbe_window->used_items);
- g_slist_free(tbe_window->all_items);
- tb_editor_free_path(tbe_window->tbw);
- g_free(tbe_window->tbw);
-
- g_free(tbe_window);
- tbe_window=NULL;
-}
-
-static void tb_editor_menu_configure_toolbar_activate_cb(GtkWidget *menuitem, MidoriBrowser *browser)
-{
- /* create toolbar-editor window if not available */
- if(tbe_window==NULL)
- {
- GSList *node;
- GtkTreeIter iter;
- GtkTreePath *path;
-
- /* create storage for window data */
- tbe_window=g_new0(TBEditorWindow, 1);
-
- /* read the current active toolbar items */
- tbe_window->used_items = tb_editor_parse_active_items(browser);
-
- /* get all available actions */
- tbe_window->all_items = tb_editor_get_available_actions(browser);
-
- /* create the GUI */
- tbe_window->tbw = tb_editor_create_dialog(browser);
-
- /* cache some pointers, this is safe enough since the dialog is run modally */
- tbe_window->tbw->action_group = midori_browser_get_action_group(browser);
- tbe_window->tbw->browser = browser;
-
- /* fill the stores */
- for (node = tbe_window->all_items; node != NULL; node = node->next)
- {
- if (strcmp(node->data, "Separator") == 0 ||
- g_slist_find_custom(tbe_window->used_items, node->data, (GCompareFunc) strcmp) == NULL)
- {
- gtk_list_store_append(tbe_window->tbw->store_available, &iter);
- tb_editor_set_item_values(tbe_window->tbw, node->data, tbe_window->tbw->store_available, &iter);
- }
- }
- for (node = tbe_window->used_items; node != NULL; node = node->next)
- {
- gtk_list_store_append(tbe_window->tbw->store_used, &iter);
- tb_editor_set_item_values(tbe_window->tbw, node->data, tbe_window->tbw->store_used, &iter);
- }
- /* select first item */
- path = gtk_tree_path_new_from_string("0");
- gtk_tree_selection_select_path(gtk_tree_view_get_selection(tbe_window->tbw->tree_used), path);
- gtk_tree_path_free(path);
-
- /* connect the changed signals after populating the store */
- g_signal_connect(tbe_window->tbw->store_used, "row-changed",
- G_CALLBACK(tb_editor_available_items_changed_cb), tbe_window->tbw);
- g_signal_connect(tbe_window->tbw->store_used, "row-deleted",
- G_CALLBACK(tb_editor_available_items_deleted_cb), tbe_window->tbw);
-
- /* connect signal for detecting window close */
- g_signal_connect(tbe_window->tbw->dialog, "response", G_CALLBACK (tb_editor_response_cb), NULL);
- }
-
- /* show dialog and make it modal */
- gtk_window_set_modal(GTK_WINDOW(tbe_window->tbw->dialog), TRUE);
- gtk_widget_show_all(tbe_window->tbw->dialog);
-}
-
-static void tb_editor_browser_populate_toolbar_menu_cb(MidoriBrowser *browser, GtkWidget *menu,
- MidoriExtension *ext)
-{
- GtkWidget* separator;
- GtkWidget* menuitem;
-
- separator = gtk_separator_menu_item_new ();
- gtk_widget_show (separator);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), separator);
- menuitem = gtk_menu_item_new_with_mnemonic (_("_Customize Toolbar…"));
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (tb_editor_menu_configure_toolbar_activate_cb), browser);
- gtk_widget_show (menuitem);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-}
-
-static void tb_editor_app_add_browser_cb(MidoriApp *app, MidoriBrowser *browser, MidoriExtension *ext)
-{
- g_signal_connect(browser, "populate-toolbar-menu", G_CALLBACK(tb_editor_browser_populate_toolbar_menu_cb), ext);
- g_signal_connect(ext, "deactivate", G_CALLBACK(tb_editor_deactivate_cb), browser);
-}
-
-
-static void tb_editor_activate_cb(MidoriExtension *extension, MidoriApp *app)
-{
- KatzeArray *browsers;
- MidoriBrowser *browser;
-
- browsers = katze_object_get_object(app, "browsers");
- KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
- tb_editor_app_add_browser_cb(app, browser, extension);
- g_signal_connect(app, "add-browser", G_CALLBACK(tb_editor_app_add_browser_cb), extension);
- g_object_unref(browsers);
-}
-
-MidoriExtension *extension_init(void)
-{
- MidoriExtension* extension = g_object_new(MIDORI_TYPE_EXTENSION,
- "name", _("Toolbar Editor"),
- "description", _("Easily edit the toolbar layout"),
- "version", "0.1" MIDORI_VERSION_SUFFIX,
- "authors", "Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>",
- NULL);
-
- g_signal_connect(extension, "activate", G_CALLBACK(tb_editor_activate_cb), NULL);
-
- return extension;
-}
diff --git a/extensions/transfers.vala b/extensions/transfers.vala
deleted file mode 100644
index ae95fa2a..00000000
--- a/extensions/transfers.vala
+++ /dev/null
@@ -1,583 +0,0 @@
-/*
- Copyright (C) 2009-2013 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.
-*/
-
-namespace Gtk {
- extern static void widget_size_request (Gtk.Widget widget, out Gtk.Requisition requisition);
-}
-
-namespace Sokoke {
- extern static void widget_get_text_size (Gtk.Widget widget, string sample, out int width, out int height);
-}
-
-namespace Transfers {
- private class Transfer : GLib.Object {
- internal uint poll_source = 0;
- internal WebKit.Download download;
-
- internal virtual signal void changed ()
- {
- string tooltip = Midori.Download.calculate_tooltip (download);
- this.set_data ("tooltip", tooltip);
- }
- internal signal void remove ();
- internal signal void removed ();
-
- internal int action { get {
- return Midori.Download.get_type (download);
- } }
- internal double progress { get {
- return Midori.Download.get_progress (download);
- } }
-#if HAVE_WEBKIT2
- public bool succeeded { get; protected set; default = false; }
- public bool finished { get; protected set; default = false; }
- internal string destination { get {
- return download.destination;
- } }
-#else
- internal bool succeeded { get {
- return download.status == WebKit.DownloadStatus.FINISHED;
- } }
- internal bool finished { get {
- return Midori.Download.is_finished (download);
- } }
- internal string destination { get {
- return download.destination_uri;
- } }
-#endif
-
- internal Transfer (WebKit.Download download) {
- poll_source = Timeout.add(1000/10, () => {
- changed ();
- return true;
- });
- this.download = download;
- #if HAVE_WEBKIT2
- download.finished.connect (() => {
- succeeded = finished = true;
- changed ();
- Source.remove (poll_source);
- poll_source = 0;
- });
- download.failed.connect (() => {
- succeeded = false;
- finished = true;
- changed ();
- Source.remove (poll_source);
- poll_source = 0;
- });
- #else
- download.notify["status"].connect (() => {
- changed ();
- if (download.status == WebKit.DownloadStatus.FINISHED || download.status == WebKit.DownloadStatus.ERROR) {
- Source.remove (poll_source);
- poll_source = 0;
- }
- });
- #endif
- }
- }
-
- static bool pending_transfers (Katze.Array array) {
- foreach (GLib.Object item in array.get_items ()) {
- var transfer = item as Transfer;
- if (!transfer.finished)
- return true;
- }
- return false;
- }
-
- private class Sidebar : Gtk.VBox, Midori.Viewable {
- Gtk.Toolbar? toolbar = null;
- Gtk.ToolButton clear;
- Gtk.ListStore store = new Gtk.ListStore (1, typeof (Transfer));
- Gtk.TreeView treeview;
- Katze.Array array;
-
- public unowned string get_stock_id () {
- return Midori.Stock.TRANSFER;
- }
-
- public unowned string get_label () {
- return _("Transfers");
- }
-
- public Gtk.Widget get_toolbar () {
- if (toolbar == null) {
- toolbar = new Gtk.Toolbar ();
- toolbar.set_icon_size (Gtk.IconSize.BUTTON);
- toolbar.insert (new Gtk.ToolItem (), -1);
- var separator = new Gtk.SeparatorToolItem ();
- separator.draw = false;
- separator.set_expand (true);
- toolbar.insert (separator, -1);
- clear = new Gtk.ToolButton.from_stock (Gtk.STOCK_CLEAR);
- clear.label = _("Clear All");
- clear.is_important = true;
- clear.clicked.connect (clear_clicked);
- clear.sensitive = !array.is_empty ();
- toolbar.insert (clear, -1);
- toolbar.show_all ();
- }
- return toolbar;
- }
-
- void clear_clicked () {
- foreach (GLib.Object item in array.get_items ()) {
- var transfer = item as Transfer;
- if (transfer.finished)
- transfer.remove ();
- }
- }
-
- public Sidebar (Katze.Array array) {
- Gtk.TreeViewColumn column;
-
- treeview = new Gtk.TreeView.with_model (store);
- treeview.headers_visible = false;
-
- store.set_sort_column_id (0, Gtk.SortType.ASCENDING);
- store.set_sort_func (0, tree_sort_func);
-
- column = new Gtk.TreeViewColumn ();
- Gtk.CellRendererPixbuf renderer_icon = new Gtk.CellRendererPixbuf ();
- column.pack_start (renderer_icon, false);
- column.set_cell_data_func (renderer_icon, on_render_icon);
- treeview.append_column (column);
-
- column = new Gtk.TreeViewColumn ();
- column.set_sizing (Gtk.TreeViewColumnSizing.AUTOSIZE);
- Gtk.CellRendererProgress renderer_progress = new Gtk.CellRendererProgress ();
- column.pack_start (renderer_progress, true);
- column.set_expand (true);
- column.set_cell_data_func (renderer_progress, on_render_text);
- treeview.append_column (column);
-
- column = new Gtk.TreeViewColumn ();
- Gtk.CellRendererPixbuf renderer_button = new Gtk.CellRendererPixbuf ();
- column.pack_start (renderer_button, false);
- column.set_cell_data_func (renderer_button, on_render_button);
- treeview.append_column (column);
-
- treeview.row_activated.connect (row_activated);
- treeview.button_release_event.connect (button_released);
- treeview.popup_menu.connect (menu_popup);
- treeview.show ();
- pack_start (treeview, true, true, 0);
-
- this.array = array;
- array.add_item.connect (transfer_added);
- array.remove_item.connect_after (transfer_removed);
- foreach (GLib.Object item in array.get_items ())
- transfer_added (item);
- }
-
- void row_activated (Gtk.TreePath path, Gtk.TreeViewColumn column) {
- Gtk.TreeIter iter;
- if (store.get_iter (out iter, path)) {
- Transfer transfer;
- store.get (iter, 0, out transfer);
-
- try {
- if (Midori.Download.action_clear (transfer.download, treeview))
- transfer.remove ();
- } catch (Error error) {
- // Failure to open is the only known possibility here
- GLib.warning (_("Failed to open download: %s"), error.message);
- }
- }
- }
-
- bool button_released (Gdk.EventButton event) {
- if (event.button == 3)
- return show_popup_menu (event);
- return false;
- }
-
- bool menu_popup () {
- return show_popup_menu (null);
- }
-
- bool show_popup_menu (Gdk.EventButton? event) {
- Gtk.TreeIter iter;
- if (treeview.get_selection ().get_selected (null, out iter)) {
- Transfer transfer;
- store.get (iter, 0, out transfer);
-
- var menu = new Gtk.Menu ();
- var menuitem = new Gtk.ImageMenuItem.from_stock (Gtk.STOCK_OPEN, null);
- menuitem.activate.connect (() => {
- try {
- Midori.Download.open (transfer.download, treeview);
- } catch (Error error_open) {
- GLib.warning (_("Failed to open download: %s"), error_open.message);
- }
- });
- menuitem.sensitive = transfer.succeeded;
- menu.append (menuitem);
- menuitem = new Gtk.ImageMenuItem.with_mnemonic (_("Open Destination _Folder"));
- menuitem.image = new Gtk.Image.from_stock (Gtk.STOCK_DIRECTORY, Gtk.IconSize.MENU);
- menuitem.activate.connect (() => {
- var folder = GLib.File.new_for_uri (transfer.destination);
- (Midori.Browser.get_for_widget (this).tab as Midori.Tab).open_uri (folder.get_parent ().get_uri ());
- });
- menu.append (menuitem);
- menuitem = new Gtk.ImageMenuItem.with_mnemonic (_("Copy Link Loc_ation"));
- menuitem.activate.connect (() => {
- string uri = transfer.destination;
- get_clipboard (Gdk.SELECTION_PRIMARY).set_text (uri, -1);
- get_clipboard (Gdk.SELECTION_CLIPBOARD).set_text (uri, -1);
- });
- menuitem.image = new Gtk.Image.from_stock (Gtk.STOCK_COPY, Gtk.IconSize.MENU);
- menu.append (menuitem);
- menu.show_all ();
- Katze.widget_popup (treeview, menu, null, Katze.MenuPos.CURSOR);
-
- return true;
- }
- return false;
- }
-
- int tree_sort_func (Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b) {
- Transfer transfer1, transfer2;
- model.get (a, 0, out transfer1);
- model.get (b, 0, out transfer2);
- return (transfer1.finished ? 1 : 0) - (transfer2.finished ? 1 : 0);
- }
-
- void transfer_changed (GLib.Object item) {
- treeview.queue_draw ();
- }
-
- void transfer_added (GLib.Object item) {
- var transfer = item as Transfer;
- Gtk.TreeIter iter;
- store.append (out iter);
- store.set (iter, 0, transfer);
- transfer.changed.connect (() => transfer_changed (transfer));
- clear.sensitive = true;
- }
-
- void transfer_removed (GLib.Object item) {
- var transfer = item as Transfer;
- transfer.changed.disconnect (transfer_changed);
- Gtk.TreeIter iter;
- if (store.iter_children (out iter, null)) {
- do {
- Transfer found;
- store.get (iter, 0, out found);
- if (transfer == found) {
- store.remove (iter);
- break;
- }
- } while (store.iter_next (ref iter));
- }
- if (array.is_empty ())
- clear.sensitive = false;
- }
-
- void on_render_icon (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- Transfer transfer;
- model.get (iter, 0, out transfer);
- string content_type = Midori.Download.get_content_type (transfer.download, null);
- var icon = GLib.ContentType.get_icon (content_type) as ThemedIcon;
- icon.append_name ("text-html");
- renderer.set ("gicon", icon,
- "stock-size", Gtk.IconSize.DND,
- "xpad", 1, "ypad", 12);
- }
-
- void on_render_text (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- Transfer transfer;
- model.get (iter, 0, out transfer);
- renderer.set ("text", transfer.get_data<string>("tooltip") ?? "",
- "value", (int)(transfer.progress * 100));
- }
-
- void on_render_button (Gtk.CellLayout column, Gtk.CellRenderer renderer,
- Gtk.TreeModel model, Gtk.TreeIter iter) {
-
- Transfer transfer;
- model.get (iter, 0, out transfer);
- string stock_id = Midori.Download.action_stock_id (transfer.download);
- renderer.set ("stock-id", stock_id,
- "stock-size", Gtk.IconSize.MENU);
- }
- }
-
- private class TransferButton : Gtk.ToolItem {
- Transfer transfer;
- Gtk.ProgressBar progress;
- Gtk.Image icon;
- Gtk.Button button;
-
- public TransferButton (Transfer transfer) {
- this.transfer = transfer;
-
- var box = new Gtk.HBox (false, 0);
- progress = new Gtk.ProgressBar ();
-#if HAVE_GTK3
- progress.show_text = true;
-#endif
- progress.ellipsize = Pango.EllipsizeMode.MIDDLE;
- string filename = Midori.Download.get_basename_for_display (transfer.destination);
- progress.text = filename;
- int width;
- Sokoke.widget_get_text_size (progress, "M", out width, null);
- progress.set_size_request (width * 10, 1);
- box.pack_start (progress, false, false, 0);
-
- icon = new Gtk.Image ();
- button = new Gtk.Button ();
- button.relief = Gtk.ReliefStyle.NONE;
- button.set_focus_on_click (false);
- button.clicked.connect (button_clicked);
- button.add (icon);
- box.pack_start (button, false, false, 0);
-
- add (box);
- show_all ();
-
- transfer.changed.connect (transfer_changed);
- transfer_changed ();
- transfer.removed.connect (transfer_removed);
- }
-
- void button_clicked () {
- try {
- if (Midori.Download.action_clear (transfer.download, button))
- transfer.remove ();
- } catch (Error error) {
- // Failure to open is the only known possibility here
- GLib.warning (_("Failed to open download: %s"), error.message);
- }
- }
-
- void transfer_changed () {
- progress.fraction = Midori.Download.get_progress (transfer.download);
- progress.tooltip_text = transfer.get_data<string>("tooltip") ?? "";
- string stock_id = Midori.Download.action_stock_id (transfer.download);
- icon.set_from_stock (stock_id, Gtk.IconSize.MENU);
- }
-
- void transfer_removed () {
- destroy ();
- }
- }
-
- private class Toolbar : Gtk.Toolbar {
- Katze.Array array;
- Gtk.ToolButton clear;
-
- void clear_clicked () {
- foreach (GLib.Object item in array.get_items ()) {
- var transfer = item as Transfer;
- if (transfer.finished)
- array.remove_item (item);
- }
- }
-
- public Toolbar (Katze.Array array) {
- set_icon_size (Gtk.IconSize.BUTTON);
- set_style (Gtk.ToolbarStyle.BOTH_HORIZ);
- show_arrow = false;
-
- clear = new Gtk.ToolButton.from_stock (Gtk.STOCK_CLEAR);
- clear.label = _("Clear All");
- clear.is_important = true;
- clear.clicked.connect (clear_clicked);
- clear.sensitive = !array.is_empty ();
- insert (clear, -1);
- clear.show ();
- clear.sensitive = false;
-
- this.array = array;
- array.add_item.connect (transfer_added);
- array.remove_item.connect_after (transfer_removed);
- foreach (GLib.Object item in array.get_items ())
- transfer_added (item);
- }
-
- void transfer_added (GLib.Object item) {
- var transfer = item as Transfer;
- /* Newest item on the left */
- insert (new TransferButton (transfer), 0);
- clear.sensitive = true;
- show ();
-
- Gtk.Requisition req;
- Gtk.widget_size_request (parent, out req);
- int reqwidth = req.width;
- int winwidth;
- (get_toplevel () as Gtk.Window).get_size (out winwidth, null);
- if (reqwidth > winwidth)
- clear_clicked ();
- }
-
- void transfer_removed (GLib.Object item) {
- clear.sensitive = pending_transfers (array);
- if (array.is_empty ())
- hide ();
- }
- }
-
- private class Manager : Midori.Extension {
- internal Katze.Array array;
- internal GLib.List<Gtk.Widget> widgets;
- internal GLib.List<string> notifications;
- internal uint notification_timeout;
-
- void download_added (WebKit.Download download) {
- var transfer = new Transfer (download);
- transfer.remove.connect (transfer_remove);
- transfer.changed.connect (transfer_changed);
- array.remove_item.connect (transfer_removed);
- array.add_item (transfer);
- }
-
- bool notification_timeout_triggered () {
- notification_timeout = 0;
- if (notifications.length () > 0) {
- string filename = notifications.nth_data(0);
- string msg;
- if (notifications.length () == 1)
- msg = _("The file '<b>%s</b>' has been downloaded.").printf (filename);
- else
- msg = _("'<b>%s</b>' and %d other files have been downloaded.").printf (filename, (int) notifications.length ());
- get_app ().send_notification (_("Transfer completed"), msg);
- notifications = new GLib.List<string> ();
- }
- return false;
- }
-
- void transfer_changed (Transfer transfer) {
- if (transfer.succeeded) {
- /* FIXME: The following 2 blocks ought to be done in core */
- if (transfer.action == Midori.DownloadType.OPEN) {
- try {
- if (Midori.Download.action_clear (transfer.download, widgets.nth_data (0)))
- transfer.remove ();
- } catch (Error error) {
- // Failure to open is the only known possibility here
- GLib.warning (_("Failed to open download: %s"), error.message);
- }
- }
-
- string uri = transfer.destination;
- string filename = Midori.Download.get_basename_for_display (uri);
- var item = new Katze.Item ();
- item.uri = uri;
- item.name = filename;
- Midori.Browser.update_history (item, "download", "create");
- if (!Midori.Download.has_wrong_checksum (transfer.download))
- Gtk.RecentManager.get_default ().add_item (uri);
-
- notifications.append (filename);
- if (notification_timeout == 0) {
- notification_timeout_triggered ();
- notification_timeout = Midori.Timeout.add_seconds (60, notification_timeout_triggered);
- }
- }
- }
-
- void transfer_remove (Transfer transfer) {
- array.remove_item (transfer);
- }
-
- void transfer_removed (GLib.Object item) {
- var transfer = item as Transfer;
- transfer.removed ();
- }
-
-#if HAVE_GTK3
- bool browser_closed (Gtk.Widget widget, Gdk.EventAny event) {
-#else
- bool browser_closed (Gtk.Widget widget, Gdk.Event event) {
-#endif
- var browser = widget as Midori.Browser;
- if (pending_transfers (array)) {
- var dialog = new Gtk.MessageDialog (browser,
- Gtk.DialogFlags.DESTROY_WITH_PARENT,
- Gtk.MessageType.WARNING, Gtk.ButtonsType.NONE,
- "%s",
- _("Some files are being downloaded"));
- dialog.title = _("Some files are being downloaded");
- dialog.add_buttons (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
- _("_Quit Midori"), Gtk.ResponseType.ACCEPT);
- dialog.format_secondary_text (
- _("The transfers will be cancelled if Midori quits."));
- bool cancel = dialog.run () != Gtk.ResponseType.ACCEPT;
- dialog.destroy ();
- return cancel;
- }
- return false;
- }
-
- void browser_added (Midori.Browser browser) {
- var viewable = new Sidebar (array);
- viewable.show ();
- browser.panel.append_page (viewable);
- widgets.append (viewable);
- var toolbar = new Toolbar (array);
-#if HAVE_GTK3
- browser.statusbar.pack_end (toolbar, false, false);
-#else
- browser.statusbar.pack_start (toolbar, false, false);
-#endif
- widgets.append (toolbar);
- // TODO: popover
- // TODO: progress in dock item
- browser.add_download.connect (download_added);
- browser.delete_event.connect (browser_closed);
- }
-
- void activated (Midori.App app) {
- array = new Katze.Array (typeof (Transfer));
- widgets = new GLib.List<Gtk.Widget> ();
- notifications = new GLib.List<string> ();
- notification_timeout = 0;
- foreach (var browser in app.get_browsers ())
- browser_added (browser);
- app.add_browser.connect (browser_added);
- }
-
- void deactivated () {
- var app = get_app ();
- app.add_browser.disconnect (browser_added);
- foreach (var browser in app.get_browsers ()) {
- browser.add_download.disconnect (download_added);
- browser.delete_event.disconnect (browser_closed);
- }
- foreach (var widget in widgets)
- widget.destroy ();
- array.remove_item.disconnect (transfer_removed);
- }
-
- internal Manager () {
- GLib.Object (name: _("Transfer Manager"),
- description: _("View downloaded files"),
- version: "0.1" + Midori.VERSION_SUFFIX,
- authors: "Christian Dywan <christian@twotoasts.de>");
-
- this.activate.connect (activated);
- this.deactivate.connect (deactivated);
- }
- }
-}
-
-public Midori.Extension extension_init () {
- return new Transfers.Manager ();
-}
-
diff --git a/extensions/webmedia-now-playing.vala b/extensions/webmedia-now-playing.vala
deleted file mode 100644
index 2800412e..00000000
--- a/extensions/webmedia-now-playing.vala
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- Copyright (C) 2014 James Axl <axlrose112@gmail.com>
-
- 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.
-*/
-
-namespace WebMedia {
-
- private class Manager : Midori.Extension {
- DbusService dbus_service { get; set; }
- WebMediaNotify web_media_notify { get; set; }
- string web_media_uri { get; set; }
- string web_media_title { get; set; }
- internal Manager () {
- GLib.Object (name: _("Webmedia now-playing"),
- description: _("Share 'youtube, vimeo, dailymotion, coub and zippcast' that you are playing in Midori using org.midori.mediaHerald"),
- version: "0.1" + Midori.VERSION_SUFFIX,
- authors: "James Axl <axlrose112@gmail.com>");
- activate.connect (this.activated);
- deactivate.connect (this.deactivated);
- }
-
- void youtube_validation (Object object, ParamSpec pspec) {
- var browser = object as Midori.Browser;
- if(browser.uri == browser.title || browser.uri.contains(browser.title)) return;
- if (web_media_uri == browser.uri) return;
- if (web_media_title == browser.title) return;
- web_media_uri = browser.uri;
- web_media_title = browser.title;
- try {
- var youtube = new Regex("""(http|https)://www.youtube.com/watch\?v=[&=_\-A-Za-z0-9.\|]+""");
- var vimeo = new Regex("""(http|https)://vimeo.com/[0-9]+""");
- var dailymotion = new Regex("""(http|https)://www.dailymotion.com/video/[_\-A-Za-z0-9]+""");
- var coub = new Regex("""(http|https)://coub.com/view/[&=_\-A-Za-z0-9.\|]+""");
- var zippcast = new Regex("""(http|https)://www.zippcast.com/video/[&=_\-A-Za-z0-9.\|]+""");
-
- string website = null;
- if (web_media_uri.contains("youtube") || web_media_uri.contains("vimeo") ||
- web_media_uri.contains ("dailymotion") || web_media_uri.contains ("coub") ||
- web_media_uri.contains ("zippcast") ) {
- if (youtube.match(web_media_uri))
- website = "Youtube";
- else if (vimeo.match(web_media_uri))
- website = "Vimeo";
- else if (dailymotion.match(web_media_uri))
- website = "Dailymotion";
- else if (coub.match(web_media_uri))
- website = "Coub";
- else if (zippcast.match(web_media_uri))
- website = "ZippCast";
-
- if (website != null) {
- dbus_service.video_title = web_media_title;
- web_media_notify.notify_media = website;
- web_media_notify.notify_video_title = web_media_title;
- dbus_service.video_uri = web_media_uri;
- web_media_notify.show_notify();
- }
- }
- } catch(RegexError e) {
- warning ("%s", e.message);
- }
- }
-
- void browser_added (Midori.Browser browser) {
- browser.notify["title"].connect (youtube_validation);
- }
-
- void activated (Midori.App app) {
- dbus_service = new DbusService();
- web_media_notify = new WebMediaNotify(app);
- foreach (var browser in app.get_browsers ())
- browser_added (browser);
- app.add_browser.connect (browser_added);
- dbus_service.register_service();
- }
-
- void deactivated () {
- var app = get_app ();
- app.add_browser.disconnect (browser_added);
- dbus_service.unregister_service();
- foreach (var browser in app.get_browsers ())
- browser.notify["title"].disconnect (youtube_validation);
- }
- }
-
- [DBus (name = "org.midori.mediaHerald")]
- public class DbusService : Object {
- uint service { get; set; }
- uint own_name_id { get; set; }
- DBusConnection dbus_service_connection { get; set; }
- public string video_title { get; set; }
- public string video_uri { get; set; }
-
- public DbusService() {
- dbus_empty();
- }
-
- public void dbus_empty() {
- video_title = null;
- video_uri = null;
- }
-
- public void register_service() {
- own_name_id = Bus.own_name (BusType.SESSION, "org.midori.mediaHerald", BusNameOwnerFlags.NONE,
- on_bus_aquired,
- () => {},
- () => stderr.printf ("Could not acquire name\n"));
- }
-
- public void unregister_service() {
- Bus.unown_name(own_name_id);
- dbus_service_connection.unregister_object (service);
- }
-
- void on_bus_aquired (DBusConnection connection) {
- try {
- dbus_service_connection = connection;
- service = connection.register_object ("/org/midori/mediaHerald", this);
- } catch (IOError e) {
- stderr.printf ("Could not register service\n");
- }
- }
- }
-
- public class WebMediaNotify : Object {
- public Midori.App app { get; set; }
- public string notify_video_title { get; set; }
- public string notify_media { get; set; }
-
- public WebMediaNotify (Midori.App app) {
- Object (app: app);
- }
-
- public void show_notify () {
- app.send_notification ("Midori is playing in " + notify_media, notify_video_title);
- }
- }
-}
-
-public Midori.Extension extension_init () {
- return new WebMedia.Manager ();
-}
diff --git a/gir/CMakeLists.txt b/gir/CMakeLists.txt
deleted file mode 100644
index 24a6960a..00000000
--- a/gir/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright (C) 2013 Olivier Duchateau
-
-include (GIR)
-
-if (GIR_FOUND)
- list (APPEND MODULES "Katze" "Midori")
- foreach (MOD ${MODULES})
- string(TOLOWER ${MOD} LOWER_MOD)
- if (EXISTS "${CMAKE_SOURCE_DIR}/${LOWER_MOD}")
- gir (${LOWER_MOD} ${MOD})
- endif ()
- endforeach ()
-else ()
- message (FATAL_ERROR "g-ir-scanner not found")
-endif ()
diff --git a/gresource.xml b/gresource.xml
new file mode 100644
index 00000000..43c5a206
--- /dev/null
+++ b/gresource.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/midori-browser/midori">
+ <file>icons/16x16/apps/midori.png</file>
+ <file>icons/22x22/apps/midori.png</file>
+ <file>icons/scalable/apps/midori.svg</file>
+ <file>icons/index.theme</file>
+ </gresource>
+ <gresource prefix="/org/midori-browser/midori/gtk">
+ <file compressed="true" preprocess="xml-stripblanks" alias="menus.ui">ui/menus.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks" alias="help-overlay.ui">ui/shortcuts.ui</file>
+ </gresource>
+ <gresource prefix="/">
+ <file compressed="true">data/gtk3.css</file>
+ <file compressed="true">data/history/Create.sql</file>
+ <file compressed="true">data/history/Day.sql</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/about.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/browser.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/clear-private-data.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/download-button.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/download-row.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/network-check.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/suggestion-row.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/tab.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/tally.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/urlbar.ui</file>
+ </gresource>
+</gresources>
diff --git a/icons/16x16/categories/extension.png b/icons/16x16/categories/extension.png
deleted file mode 100644
index 9dcd27e1..00000000
--- a/icons/16x16/categories/extension.png
+++ /dev/null
Binary files differ
diff --git a/icons/16x16/status/internet-news-reader.png b/icons/16x16/status/internet-news-reader.png
deleted file mode 100644
index 05363c5a..00000000
--- a/icons/16x16/status/internet-news-reader.png
+++ /dev/null
Binary files differ
diff --git a/icons/22x22/categories/extension.png b/icons/22x22/categories/extension.png
deleted file mode 100644
index fb9c45e9..00000000
--- a/icons/22x22/categories/extension.png
+++ /dev/null
Binary files differ
diff --git a/icons/22x22/status/internet-news-reader.png b/icons/22x22/status/internet-news-reader.png
deleted file mode 100644
index 3cf9465b..00000000
--- a/icons/22x22/status/internet-news-reader.png
+++ /dev/null
Binary files differ
diff --git a/icons/24x24/status/adblock-blocked.svg b/icons/24x24/status/adblock-blocked.svg
deleted file mode 100644
index 5f734ecc..00000000
--- a/icons/24x24/status/adblock-blocked.svg
+++ /dev/null
@@ -1,174 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- id="svg7384"
- height="24"
- width="24"
- version="1.1">
- <title
- id="title9167">Gnome Symbolic Icon Theme</title>
- <defs
- id="defs10">
- <linearGradient
- id="linearGradient4558">
- <stop
- offset="0"
- style="stop-color:#ffffff;stop-opacity:1"
- id="stop4560" />
- <stop
- offset="0.22383958"
- style="stop-color:#ffffff;stop-opacity:0.23529412"
- id="stop4562" />
- <stop
- offset="0.59868193"
- style="stop-color:#ffffff;stop-opacity:0.15686275"
- id="stop4564" />
- <stop
- offset="1"
- style="stop-color:#ffffff;stop-opacity:0.39215687"
- id="stop4566" />
- </linearGradient>
- <linearGradient
- id="linearGradient8838">
- <stop
- id="stop8840"
- style="stop-color:#000000;stop-opacity:1"
- offset="0" />
- <stop
- id="stop8842"
- style="stop-color:#000000;stop-opacity:0"
- offset="1" />
- </linearGradient>
- <radialGradient
- cx="62.625"
- cy="4.625"
- r="10.625"
- fx="62.625"
- fy="4.625"
- id="radialGradient3049"
- xlink:href="#linearGradient8838"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(1.0352941,0,0,0.42352883,-52.835297,17.541176)" />
- <linearGradient
- id="linearGradient4632-0-6-4-3-4-0">
- <stop
- id="stop4634-4-4-7-7-4-8"
- style="stop-color:#e9e9e9;stop-opacity:1"
- offset="0" />
- <stop
- id="stop4636-3-1-5-1-3-9"
- style="stop-color:#b4b4b4;stop-opacity:1"
- offset="1" />
- </linearGradient>
- <linearGradient
- y2="87.722054"
- x2="-38.289993"
- y1="44.545967"
- x1="-38.289993"
- gradientTransform="matrix(0.4666607,0,0,0.46428558,29.868435,-18.719767)"
- gradientUnits="userSpaceOnUse"
- id="linearGradient3647"
- xlink:href="#linearGradient4632-0-6-4-3-4-0" />
- <linearGradient
- y2="52.920029"
- x2="-25.723886"
- y1="29.608633"
- x1="-25.723886"
- gradientTransform="matrix(0.62762637,0,0,0.7245642,29.541728,-17.849962)"
- gradientUnits="userSpaceOnUse"
- id="linearGradient4556"
- xlink:href="#linearGradient4558" />
- <linearGradient
- gradientUnits="userSpaceOnUse"
- y2="22.055216"
- x2="9.424572"
- y1="-10.106976"
- x1="9.424572"
- id="linearGradient4826"
- xlink:href="#linearGradient3690" />
- <linearGradient
- id="linearGradient3690">
- <stop
- id="stop3692"
- style="stop-color:#ffeb9f;stop-opacity:1"
- offset="0" />
- <stop
- id="stop3694"
- style="stop-color:#ffd57e;stop-opacity:1"
- offset="0.26238" />
- <stop
- id="stop3696"
- style="stop-color:#ffbc43;stop-opacity:1"
- offset="0.66093999" />
- <stop
- id="stop3698"
- style="stop-color:#ff921a;stop-opacity:1"
- offset="1" />
- </linearGradient>
- </defs>
- <metadata
- id="metadata90">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title>Gnome Symbolic Icon Theme</dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <path
- style="display:inline;overflow:visible;visibility:visible;opacity:0.3;fill:url(#radialGradient3049);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.99999988;marker:none"
- id="path8836"
- d="M 23,19.499999 C 23,21.985281 18.075131,24 12,24 5.924868,24 1,21.985281 1,19.499999 1,17.014718 5.924868,15 12,15 c 6.075131,0 11,2.014718 11,4.499999 l 0,0 z" />
- <g
- id="layer12"
- transform="translate(-111.61542,-593.4038)">
- <path
- style="color:#000000;text-indent:0;text-transform:none;block-progression:tb;fill:#bebebe"
- id="path4222"
- d="m 228.01,607.02 c -3.86,0 -7.0073,3.166 -7.0073,7.0103 0,3.8443 3.1472,6.9787 7.0073,6.9787 3.86,0 7.0073,-3.1344 7.0073,-6.9787 0,-3.8443 -3.1472,-7.0103 -7.0073,-7.0103 z m 0,2.021 c 2.7769,0 5.0097,2.2237 5.0097,4.9893 0,2.7656 -2.2328,4.9577 -5.0097,4.9577 -2.777,0 -5.0097,-2.1921 -5.0097,-4.9577 0,-2.7656 2.2328,-4.9893 5.0097,-4.9893 z" />
- <path
- style="color:#000000;text-indent:0;text-transform:none;block-progression:tb;fill:#bebebe"
- id="path4992"
- d="m 231.41,609.44 -8,8 1.4062,1.4062 8,-8 -1.4062,-1.4062 z" />
- </g>
- <path
- id="path2987"
- d="M 3.8914706,16.884163 C 3.4103263,16.122175 3.0583616,14.874941 3.003735,13.738353 2.9786317,13.216042 2.9904131,12.872245 3.036357,12.786398 3.0800139,12.704824 3.2418563,12.617784 3.4482218,12.564894 3.8914458,12.4513 4.5265161,12.144239 5.8961843,11.381288 l 1.1165232,-0.62194 0.7570601,-0.02403 c 0.8929799,-0.02835 1.2830044,0.06299 2.0579192,0.481909 0.2812132,0.152025 0.5479652,0.304385 0.5927812,0.338577 0.07081,0.05402 -1.5991187,1.535031 -6.2292646,5.524569 -0.1025198,0.08834 -0.1324231,0.06876 -0.2997328,-0.196208 l 0,0 z"
- style="fill:#000000;fill-opacity:0" />
- <path
- id="path2989"
- d="M 7.5676774,20.795393 C 7.0256619,20.469009 6.4290755,19.979639 5.8305085,19.370422 5.33023,18.861243 5.3242581,18.851054 5.4600194,18.738315 c 0.075892,-0.06302 1.7041174,-1.472213 3.6182787,-3.131535 2.6060709,-2.259116 3.5165739,-3.011455 3.6247259,-2.995077 0.291451,0.04413 0.329784,0.188652 0.290923,1.096772 -0.07204,1.683495 -0.589725,2.952665 -1.866622,4.576271 -0.495094,0.629525 -1.366327,1.526375 -1.8854314,1.94087 C 8.8466967,20.541173 8.091686,21.030508 8,21.030508 c -0.023031,0 -0.2175765,-0.105802 -0.4323226,-0.235115 z"
- style="fill:#000000;fill-opacity:0" />
- <path
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:url(#linearGradient3647);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999988;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
- id="path3016-2"
- d="M 11.955413,2 C 7.9002937,2 7.8501927,4.7877367 2.5027824,5.2314411 c 0,0 -1.4090126,3.5442522 0.4904667,8.3842799 C 4.1916569,16.66936 9.2619851,21.973865 11.821648,22 l 0.356704,0 C 14.738015,21.97387 19.808345,16.66936 21.00675,13.615721 22.906231,8.7756933 21.497217,5.2314411 21.497217,5.2314411 16.149808,4.7877367 16.099706,2 12.044587,2 Z" />
- <path
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.3;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.99999988;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate;filter-blend-mode:normal;filter-gaussianBlur-deviation:0"
- id="path3016-2-1"
- d="m 11.955413,2.037717 c -4.0551193,0 -4.1052203,2.7877367 -9.4526306,3.2314411 0,0 -1.4090126,3.5442522 0.4904667,8.3842799 1.1984078,3.053639 6.268736,8.358144 8.8283989,8.384279 l 0.356704,0 c 2.559663,-0.02613 7.629993,-5.33064 8.828398,-8.384279 C 22.906231,8.8134103 21.497217,5.2691581 21.497217,5.2691581 16.149808,4.8254537 16.099706,2.037717 12.044587,2.037717 Z" />
- <path
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient4556);stroke-width:1.00000012;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate;filter-blend-mode:normal;filter-gaussianBlur-deviation:0"
- id="path3016-2-1-1"
- d="m 11.955413,3.0543523 c -3.6409345,0 -3.5027696,2.4488582 -8.6995673,3.1184816 0,0 -0.9319349,4.2684311 1.0552641,7.8571351 2.0746863,3.746699 5.7415922,6.964978 7.5105382,6.991113 l 0.356704,0 c 1.844253,-0.02613 6.613358,-4.502271 7.811763,-7.55591 C 21.889596,8.6251444 20.668848,6.2104871 20.668848,6.2104871 15.283785,5.2772916 15.723174,3.0543523 12.044587,3.0543523 Z" />
- <path
- id="path4589-8"
- d="m 11.064453,6.0934752 c -0.736072,0.090507 -1.0911094,0.3766442 -2.0078124,0.8730469 -0.8858,0.4796687 -2.3650342,1.4601803 -4.1914062,1.8769531 -0.170321,1.0649711 -0.2082425,2.6048188 0.7578125,5.0664058 0.116224,0.296146 0.4021556,0.809023 0.7597656,1.353516 L 15.701172,7.3591002 C 15.45871,7.2188299 15.133552,7.0695094 14.943359,6.9665221 13.721089,6.3046514 13.519899,6.0934752 12.044922,6.0934752 l -0.08984,0 c -0.368744,0 -0.645267,-0.030169 -0.890625,0 z M 18.509766,8.6696471 8.1210938,17.489959 c 0.2477189,0.280185 0.4984735,0.574654 0.7578124,0.830078 0.7636571,0.752121 1.5605298,1.389459 2.1855468,1.791016 0.448862,0.28838 0.808903,0.402687 0.845703,0.435547 l 0.222656,0 c 0.07681,-0.04063 0.388401,-0.16935 0.802735,-0.435547 0.625016,-0.401557 1.421891,-1.038895 2.185547,-1.791016 1.527315,-1.504244 2.93633,-3.59597 3.255859,-4.410156 0.966054,-2.461587 0.928134,-4.0014347 0.757813,-5.0664058 -0.218887,-0.049956 -0.416513,-0.1089482 -0.625,-0.1738281 z"
- style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.5;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate" />
- <path
- id="path4589"
- d="M 11.064453 4.7949219 C 10.328381 4.8854287 9.9733436 5.1715661 9.0566406 5.6679688 C 8.1708406 6.1476375 6.6916064 7.1281491 4.8652344 7.5449219 C 4.6949134 8.609893 4.6569919 10.149741 5.6230469 12.611328 C 5.7392709 12.907474 6.0252025 13.420351 6.3828125 13.964844 L 15.701172 6.0605469 C 15.45871 5.9202766 15.133552 5.7709561 14.943359 5.6679688 C 13.721089 5.006098 13.519899 4.7949219 12.044922 4.7949219 L 11.955078 4.7949219 C 11.586334 4.7949219 11.309811 4.7647529 11.064453 4.7949219 z M 18.509766 7.3710938 L 8.1210938 16.191406 C 8.3688127 16.471591 8.6195673 16.76606 8.8789062 17.021484 C 9.6425633 17.773605 10.439436 18.410943 11.064453 18.8125 C 11.513315 19.10088 11.873356 19.215187 11.910156 19.248047 L 12.132812 19.248047 C 12.209618 19.207416 12.521213 19.078697 12.935547 18.8125 C 13.560563 18.410943 14.357438 17.773605 15.121094 17.021484 C 16.648409 15.51724 18.057424 13.425514 18.376953 12.611328 C 19.343007 10.149741 19.305087 8.609893 19.134766 7.5449219 C 18.915879 7.4949656 18.718253 7.4359737 18.509766 7.3710938 z "
- style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:url(#linearGradient4826);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate" />
- <path
- d="M 11.128906,5.3183594 C 10.506281,5.3949169 10.249824,5.6231282 9.3085938,6.1328125 8.5357819,6.551297 7.1129542,7.4260208 5.3789062,7.9121094 5.2513275,8.8949358 5.2491088,10.21101 6.1152344,12.417969 c 0.049097,0.125103 0.2561506,0.460783 0.4121094,0.732422 L 14.759766,6.1679688 c -0.02188,-0.011461 -0.04786,-0.024056 -0.06836,-0.035156 C 13.449105,5.4600947 13.469472,5.3242188 12.044922,5.3242188 l -0.08984,0 c -0.39756,0 -0.67088,-0.024954 -0.826172,-0.00586 z M 18.621094,7.96875 8.8808594,16.240234 c 0.1231185,0.137329 0.2502373,0.287189 0.3691406,0.404297 0.7390542,0.72789 1.516664,1.34813 2.099609,1.722657 0.197093,0.126625 0.375877,0.215395 0.511719,0.277343 0.0626,0.02855 0.113457,0.05021 0.160156,0.07031 0.04444,-0.02072 0.08032,-0.03876 0.146485,-0.07227 0.127024,-0.06432 0.293344,-0.153914 0.482422,-0.27539 0.582944,-0.374528 1.360556,-0.994768 2.099609,-1.722657 0.7343,-0.723208 1.455186,-1.602505 2.023438,-2.394531 0.568251,-0.792026 0.991833,-1.527549 1.111328,-1.832031 0.851966,-2.170884 0.856786,-3.4700009 0.736328,-4.449219 z"
- id="path4628"
- style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;marker:none;enable-background:accumulate;opacity:0.15" />
-</svg>
diff --git a/icons/24x24/status/adblock-disabled.svg b/icons/24x24/status/adblock-disabled.svg
deleted file mode 100644
index 4228e75b..00000000
--- a/icons/24x24/status/adblock-disabled.svg
+++ /dev/null
@@ -1,174 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- id="svg7384"
- height="24"
- width="24"
- version="1.1">
- <title
- id="title9167">Gnome Symbolic Icon Theme</title>
- <defs
- id="defs10">
- <linearGradient
- id="linearGradient4558">
- <stop
- offset="0"
- style="stop-color:#ffffff;stop-opacity:1"
- id="stop4560" />
- <stop
- offset="0.22383958"
- style="stop-color:#ffffff;stop-opacity:0.23529412"
- id="stop4562" />
- <stop
- offset="0.59868193"
- style="stop-color:#ffffff;stop-opacity:0.15686275"
- id="stop4564" />
- <stop
- offset="1"
- style="stop-color:#ffffff;stop-opacity:0.39215687"
- id="stop4566" />
- </linearGradient>
- <linearGradient
- id="linearGradient8838">
- <stop
- id="stop8840"
- style="stop-color:#000000;stop-opacity:1"
- offset="0" />
- <stop
- id="stop8842"
- style="stop-color:#000000;stop-opacity:0"
- offset="1" />
- </linearGradient>
- <radialGradient
- cx="62.625"
- cy="4.625"
- r="10.625"
- fx="62.625"
- fy="4.625"
- id="radialGradient3049"
- xlink:href="#linearGradient8838"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(1.0352941,0,0,0.42352883,-52.835297,17.541176)" />
- <linearGradient
- id="linearGradient4632-0-6-4-3-4-0">
- <stop
- id="stop4634-4-4-7-7-4-8"
- style="stop-color:#e9e9e9;stop-opacity:1"
- offset="0" />
- <stop
- id="stop4636-3-1-5-1-3-9"
- style="stop-color:#b4b4b4;stop-opacity:1"
- offset="1" />
- </linearGradient>
- <linearGradient
- y2="87.722054"
- x2="-38.289993"
- y1="44.545967"
- x1="-38.289993"
- gradientTransform="matrix(0.4666607,0,0,0.46428558,29.868435,-18.719767)"
- gradientUnits="userSpaceOnUse"
- id="linearGradient3647"
- xlink:href="#linearGradient4632-0-6-4-3-4-0" />
- <linearGradient
- y2="52.920029"
- x2="-25.723886"
- y1="29.608633"
- x1="-25.723886"
- gradientTransform="matrix(0.62762637,0,0,0.7245642,29.541728,-17.849962)"
- gradientUnits="userSpaceOnUse"
- id="linearGradient4556"
- xlink:href="#linearGradient4558" />
- <linearGradient
- gradientUnits="userSpaceOnUse"
- y2="34.073879"
- x2="9.424572"
- y1="0.045435004"
- x1="9.424572"
- id="linearGradient4826"
- xlink:href="#linearGradient3242-8" />
- <linearGradient
- id="linearGradient3242-8">
- <stop
- offset="0"
- style="stop-color:#f8b17e;stop-opacity:1"
- id="stop3244-2" />
- <stop
- offset="0.26238"
- style="stop-color:#e35d4f;stop-opacity:1"
- id="stop3246-9" />
- <stop
- offset="0.66093999"
- style="stop-color:#c6262e;stop-opacity:1"
- id="stop3248-10" />
- <stop
- offset="1"
- style="stop-color:#690b54;stop-opacity:1"
- id="stop3250-2" />
- </linearGradient>
- </defs>
- <metadata
- id="metadata90">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title>Gnome Symbolic Icon Theme</dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <path
- style="display:inline;overflow:visible;visibility:visible;opacity:0.3;fill:url(#radialGradient3049);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.99999988;marker:none"
- id="path8836"
- d="M 23,19.499999 C 23,21.985281 18.075131,24 12,24 5.924868,24 1,21.985281 1,19.499999 1,17.014718 5.924868,15 12,15 c 6.075131,0 11,2.014718 11,4.499999 l 0,0 z" />
- <g
- id="layer12"
- transform="translate(-111.61542,-593.4038)">
- <path
- style="color:#000000;text-indent:0;text-transform:none;block-progression:tb;fill:#bebebe"
- id="path4222"
- d="m 228.01,607.02 c -3.86,0 -7.0073,3.166 -7.0073,7.0103 0,3.8443 3.1472,6.9787 7.0073,6.9787 3.86,0 7.0073,-3.1344 7.0073,-6.9787 0,-3.8443 -3.1472,-7.0103 -7.0073,-7.0103 z m 0,2.021 c 2.7769,0 5.0097,2.2237 5.0097,4.9893 0,2.7656 -2.2328,4.9577 -5.0097,4.9577 -2.777,0 -5.0097,-2.1921 -5.0097,-4.9577 0,-2.7656 2.2328,-4.9893 5.0097,-4.9893 z" />
- <path
- style="color:#000000;text-indent:0;text-transform:none;block-progression:tb;fill:#bebebe"
- id="path4992"
- d="m 231.41,609.44 -8,8 1.4062,1.4062 8,-8 -1.4062,-1.4062 z" />
- </g>
- <path
- id="path2987"
- d="M 3.8914706,16.884163 C 3.4103263,16.122175 3.0583616,14.874941 3.003735,13.738353 2.9786317,13.216042 2.9904131,12.872245 3.036357,12.786398 3.0800139,12.704824 3.2418563,12.617784 3.4482218,12.564894 3.8914458,12.4513 4.5265161,12.144239 5.8961843,11.381288 l 1.1165232,-0.62194 0.7570601,-0.02403 c 0.8929799,-0.02835 1.2830044,0.06299 2.0579192,0.481909 0.2812132,0.152025 0.5479652,0.304385 0.5927812,0.338577 0.07081,0.05402 -1.5991187,1.535031 -6.2292646,5.524569 -0.1025198,0.08834 -0.1324231,0.06876 -0.2997328,-0.196208 l 0,0 z"
- style="fill:#000000;fill-opacity:0" />
- <path
- id="path2989"
- d="M 7.5676774,20.795393 C 7.0256619,20.469009 6.4290755,19.979639 5.8305085,19.370422 5.33023,18.861243 5.3242581,18.851054 5.4600194,18.738315 c 0.075892,-0.06302 1.7041174,-1.472213 3.6182787,-3.131535 2.6060709,-2.259116 3.5165739,-3.011455 3.6247259,-2.995077 0.291451,0.04413 0.329784,0.188652 0.290923,1.096772 -0.07204,1.683495 -0.589725,2.952665 -1.866622,4.576271 -0.495094,0.629525 -1.366327,1.526375 -1.8854314,1.94087 C 8.8466967,20.541173 8.091686,21.030508 8,21.030508 c -0.023031,0 -0.2175765,-0.105802 -0.4323226,-0.235115 z"
- style="fill:#000000;fill-opacity:0" />
- <path
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:url(#linearGradient3647);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999988;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
- id="path3016-2"
- d="M 11.955413,2 C 7.9002937,2 7.8501927,4.7877367 2.5027824,5.2314411 c 0,0 -1.4090126,3.5442522 0.4904667,8.3842799 C 4.1916569,16.66936 9.2619851,21.973865 11.821648,22 l 0.356704,0 C 14.738015,21.97387 19.808345,16.66936 21.00675,13.615721 22.906231,8.7756933 21.497217,5.2314411 21.497217,5.2314411 16.149808,4.7877367 16.099706,2 12.044587,2 Z" />
- <path
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.3;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.99999988;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate;filter-blend-mode:normal;filter-gaussianBlur-deviation:0"
- id="path3016-2-1"
- d="m 11.955413,2.037717 c -4.0551193,0 -4.1052203,2.7877367 -9.4526306,3.2314411 0,0 -1.4090126,3.5442522 0.4904667,8.3842799 1.1984078,3.053639 6.268736,8.358144 8.8283989,8.384279 l 0.356704,0 c 2.559663,-0.02613 7.629993,-5.33064 8.828398,-8.384279 C 22.906231,8.8134103 21.497217,5.2691581 21.497217,5.2691581 16.149808,4.8254537 16.099706,2.037717 12.044587,2.037717 Z" />
- <path
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient4556);stroke-width:1.00000012;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate;filter-blend-mode:normal;filter-gaussianBlur-deviation:0"
- id="path3016-2-1-1"
- d="m 11.955413,3.0543523 c -3.6409345,0 -3.5027696,2.4488582 -8.6995673,3.1184816 0,0 -0.9319349,4.2684311 1.0552641,7.8571351 2.0746863,3.746699 5.7415922,6.964978 7.5105382,6.991113 l 0.356704,0 c 1.844253,-0.02613 6.613358,-4.502271 7.811763,-7.55591 C 21.889596,8.6251444 20.668848,6.2104871 20.668848,6.2104871 15.283785,5.2772916 15.723174,3.0543523 12.044587,3.0543523 Z" />
- <path
- id="path4589-8"
- d="m 11.064453,6.0934752 c -0.736072,0.090507 -1.0911094,0.3766442 -2.0078124,0.8730469 -0.8858,0.4796687 -2.3650342,1.4601803 -4.1914062,1.8769531 -0.170321,1.0649711 -0.2082425,2.6048188 0.7578125,5.0664058 0.116224,0.296146 0.4021556,0.809023 0.7597656,1.353516 L 15.701172,7.3591002 C 15.45871,7.2188299 15.133552,7.0695094 14.943359,6.9665221 13.721089,6.3046514 13.519899,6.0934752 12.044922,6.0934752 l -0.08984,0 c -0.368744,0 -0.645267,-0.030169 -0.890625,0 z M 18.509766,8.6696471 8.1210938,17.489959 c 0.2477189,0.280185 0.4984735,0.574654 0.7578124,0.830078 0.7636571,0.752121 1.5605298,1.389459 2.1855468,1.791016 0.448862,0.28838 0.808903,0.402687 0.845703,0.435547 l 0.222656,0 c 0.07681,-0.04063 0.388401,-0.16935 0.802735,-0.435547 0.625016,-0.401557 1.421891,-1.038895 2.185547,-1.791016 1.527315,-1.504244 2.93633,-3.59597 3.255859,-4.410156 0.966054,-2.461587 0.928134,-4.0014347 0.757813,-5.0664058 -0.218887,-0.049956 -0.416513,-0.1089482 -0.625,-0.1738281 z"
- style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.5;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate" />
- <path
- id="path4589"
- d="M 11.064453 4.7949219 C 10.328381 4.8854287 9.9733436 5.1715661 9.0566406 5.6679688 C 8.1708406 6.1476375 6.6916064 7.1281491 4.8652344 7.5449219 C 4.6949134 8.609893 4.6569919 10.149741 5.6230469 12.611328 C 5.7392709 12.907474 6.0252025 13.420351 6.3828125 13.964844 L 15.701172 6.0605469 C 15.45871 5.9202766 15.133552 5.7709561 14.943359 5.6679688 C 13.721089 5.006098 13.519899 4.7949219 12.044922 4.7949219 L 11.955078 4.7949219 C 11.586334 4.7949219 11.309811 4.7647529 11.064453 4.7949219 z M 18.509766 7.3710938 L 8.1210938 16.191406 C 8.3688127 16.471591 8.6195673 16.76606 8.8789062 17.021484 C 9.6425633 17.773605 10.439436 18.410943 11.064453 18.8125 C 11.513315 19.10088 11.873356 19.215187 11.910156 19.248047 L 12.132812 19.248047 C 12.209618 19.207416 12.521213 19.078697 12.935547 18.8125 C 13.560563 18.410943 14.357438 17.773605 15.121094 17.021484 C 16.648409 15.51724 18.057424 13.425514 18.376953 12.611328 C 19.343007 10.149741 19.305087 8.609893 19.134766 7.5449219 C 18.915879 7.4949656 18.718253 7.4359737 18.509766 7.3710938 z "
- style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:url(#linearGradient4826);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate" />
- <path
- d="M 11.128906,5.3183594 C 10.506281,5.3949169 10.249824,5.6231282 9.3085938,6.1328125 8.5357819,6.551297 7.1129542,7.4260208 5.3789062,7.9121094 5.2513275,8.8949358 5.2491088,10.21101 6.1152344,12.417969 c 0.049097,0.125103 0.2561506,0.460783 0.4121094,0.732422 L 14.759766,6.1679688 c -0.02188,-0.011461 -0.04786,-0.024056 -0.06836,-0.035156 C 13.449105,5.4600947 13.469472,5.3242188 12.044922,5.3242188 l -0.08984,0 c -0.39756,0 -0.67088,-0.024954 -0.826172,-0.00586 z M 18.621094,7.96875 8.8808594,16.240234 c 0.1231185,0.137329 0.2502373,0.287189 0.3691406,0.404297 0.7390542,0.72789 1.516664,1.34813 2.099609,1.722657 0.197093,0.126625 0.375877,0.215395 0.511719,0.277343 0.0626,0.02855 0.113457,0.05021 0.160156,0.07031 0.04444,-0.02072 0.08032,-0.03876 0.146485,-0.07227 0.127024,-0.06432 0.293344,-0.153914 0.482422,-0.27539 0.582944,-0.374528 1.360556,-0.994768 2.099609,-1.722657 0.7343,-0.723208 1.455186,-1.602505 2.023438,-2.394531 0.568251,-0.792026 0.991833,-1.527549 1.111328,-1.832031 0.851966,-2.170884 0.856786,-3.4700009 0.736328,-4.449219 z"
- id="path4628"
- style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;marker:none;enable-background:accumulate;opacity:0.15" />
-</svg>
diff --git a/icons/24x24/status/adblock-enabled.svg b/icons/24x24/status/adblock-enabled.svg
deleted file mode 100644
index d626be38..00000000
--- a/icons/24x24/status/adblock-enabled.svg
+++ /dev/null
@@ -1,537 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- version="1.1"
- width="24"
- height="24"
- id="svg7384"
- inkscape:version="0.91 r"
- sodipodi:docname="enabled.svg">
- <sodipodi:namedview
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1"
- objecttolerance="10"
- gridtolerance="10"
- guidetolerance="10"
- inkscape:pageopacity="0"
- inkscape:pageshadow="2"
- inkscape:window-width="1440"
- inkscape:window-height="845"
- id="namedview10"
- showgrid="false"
- inkscape:zoom="13.395833"
- inkscape:cx="7.7438827"
- inkscape:cy="16.369428"
- inkscape:window-x="0"
- inkscape:window-y="30"
- inkscape:window-maximized="1"
- inkscape:current-layer="svg7384">
- <inkscape:grid
- type="xygrid"
- id="grid3350" />
- </sodipodi:namedview>
- <title
- id="title9167">Gnome Symbolic Icon Theme</title>
- <defs
- id="defs10">
- <linearGradient
- id="linearGradient4558">
- <stop
- id="stop4560"
- style="stop-color:#ffffff;stop-opacity:1"
- offset="0" />
- <stop
- id="stop4562"
- style="stop-color:#ffffff;stop-opacity:0.23529412"
- offset="0.22383958" />
- <stop
- id="stop4564"
- style="stop-color:#ffffff;stop-opacity:0.15686275"
- offset="0.59868193" />
- <stop
- id="stop4566"
- style="stop-color:#ffffff;stop-opacity:0.39215687"
- offset="1" />
- </linearGradient>
- <linearGradient
- id="linearGradient8838">
- <stop
- offset="0"
- style="stop-color:#000000;stop-opacity:1"
- id="stop8840" />
- <stop
- offset="1"
- style="stop-color:#000000;stop-opacity:0"
- id="stop8842" />
- </linearGradient>
- <radialGradient
- gradientTransform="matrix(1.0352941,0,0,0.42352883,-52.835297,17.541176)"
- gradientUnits="userSpaceOnUse"
- xlink:href="#linearGradient8838"
- id="radialGradient3049"
- fy="4.625"
- fx="62.625"
- r="10.625"
- cy="4.625"
- cx="62.625" />
- <linearGradient
- id="linearGradient4632-0-6-4-3-4-0">
- <stop
- offset="0"
- style="stop-color:#e9e9e9;stop-opacity:1"
- id="stop4634-4-4-7-7-4-8" />
- <stop
- offset="1"
- style="stop-color:#b4b4b4;stop-opacity:1"
- id="stop4636-3-1-5-1-3-9" />
- </linearGradient>
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient4632-0-6-4-3-4-0"
- id="linearGradient3647"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.4666607,0,0,0.46428558,29.868435,-18.719767)"
- x1="-38.289993"
- y1="44.545967"
- x2="-38.289993"
- y2="87.722054" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient4558"
- id="linearGradient4556"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.62762637,0,0,0.7245642,29.541728,-17.849962)"
- x1="-25.723886"
- y1="29.608633"
- x2="-25.723886"
- y2="52.920029" />
- <linearGradient
- gradientTransform="translate(-0.2938755,2.5949995)"
- gradientUnits="userSpaceOnUse"
- xlink:href="#linearGradient8838"
- id="linearGradient6883"
- y2="30.98424"
- x2="22.642942"
- y1="26.966721"
- x1="22.642942" />
- <linearGradient
- gradientTransform="translate(-0.2938755,2.5949995)"
- gradientUnits="userSpaceOnUse"
- xlink:href="#linearGradient8838"
- id="linearGradient6886"
- y2="30.98424"
- x2="22.642942"
- y1="26.966721"
- x1="22.642942" />
- <linearGradient
- gradientTransform="matrix(0.86503711,0,0,1.0140235,-91.244634,3.7436765)"
- gradientUnits="userSpaceOnUse"
- xlink:href="#linearGradient6786"
- id="linearGradient6784"
- y2="33.33271"
- x2="132.3414"
- y1="2.2922528"
- x1="132.3414" />
- <linearGradient
- id="linearGradient6786">
- <stop
- offset="0"
- style="stop-color:#ffffff;stop-opacity:1"
- id="stop6788" />
- <stop
- offset="0.46352294"
- style="stop-color:#ffffff;stop-opacity:0.23529412"
- id="stop6790" />
- <stop
- offset="0.76175833"
- style="stop-color:#ffffff;stop-opacity:0.15686275"
- id="stop6792" />
- <stop
- offset="1"
- style="stop-color:#ffffff;stop-opacity:0.39215687"
- id="stop6794" />
- </linearGradient>
- <linearGradient
- gradientTransform="matrix(0.80749834,0,0,0.83374395,59.410297,-0.3364531)"
- gradientUnits="userSpaceOnUse"
- xlink:href="#linearGradient8838"
- id="linearGradient3394-3"
- y2="3.6336823"
- x2="-51.786404"
- y1="53.514328"
- x1="-51.786404" />
- <linearGradient
- id="linearGradient3600-8-3">
- <stop
- offset="0"
- style="stop-color:#f4f4f4;stop-opacity:1"
- id="stop3828-7-6" />
- <stop
- offset="0.6956892"
- style="stop-color:#e9e9e9;stop-opacity:1"
- id="stop3794" />
- <stop
- offset="1"
- style="stop-color:#dbdbdb;stop-opacity:1"
- id="stop3604-2-5" />
- </linearGradient>
- <linearGradient
- id="linearGradient8838-561-565">
- <stop
- offset="0"
- style="stop-color:#0a0a0a;stop-opacity:1"
- id="stop4621" />
- <stop
- offset="1"
- style="stop-color:#0a0a0a;stop-opacity:0"
- id="stop4623" />
- </linearGradient>
- <radialGradient
- gradientTransform="matrix(2.1647059,0,0,0.7529402,-111.56471,34.517647)"
- gradientUnits="userSpaceOnUse"
- xlink:href="#linearGradient8838-561-565"
- id="radialGradient6953"
- fy="4.625"
- fx="62.625"
- r="10.625"
- cy="4.625"
- cx="62.625" />
- <radialGradient
- gradientTransform="matrix(0,1.7177641,-1.500366,0,28.565093,-35.624161)"
- gradientUnits="userSpaceOnUse"
- xlink:href="#linearGradient3600-8-3"
- id="radialGradient3792"
- fy="3.0403864"
- fx="24.003401"
- r="20.984106"
- cy="3.0403864"
- cx="24.003401" />
- <linearGradient
- y2="30.98424"
- x2="22.642942"
- y1="26.966721"
- x1="22.642942"
- gradientTransform="matrix(0.65217391,0,0,0.65217391,0.15616468,2.2227214)"
- gradientUnits="userSpaceOnUse"
- id="linearGradient3023"
- xlink:href="#linearGradient8838"
- inkscape:collect="always" />
- <radialGradient
- r="20.984106"
- fy="3.0403864"
- fx="24.003401"
- cy="3.0403864"
- cx="24.003401"
- gradientTransform="matrix(0,1.1202809,-0.97849956,0,18.977231,-22.70282)"
- gradientUnits="userSpaceOnUse"
- id="radialGradient3034"
- xlink:href="#linearGradient3600-8-3"
- inkscape:collect="always" />
- <radialGradient
- r="20.984106"
- fy="3.0403864"
- fx="24.003401"
- cy="3.0403864"
- cx="24.003401"
- gradientTransform="matrix(0,1.1202809,-0.97849956,0,18.977231,-22.70282)"
- gradientUnits="userSpaceOnUse"
- id="radialGradient3813"
- xlink:href="#linearGradient3600-8-3"
- inkscape:collect="always" />
- <radialGradient
- r="18"
- fy="38"
- fx="26"
- cy="38"
- cx="26"
- gradientTransform="matrix(1,0,0,0.33333333,0,25.333333)"
- gradientUnits="userSpaceOnUse"
- id="radialGradient4665"
- xlink:href="#linearGradient8838"
- inkscape:collect="always" />
- <radialGradient
- r="19"
- fy="-0.99997467"
- fx="24"
- cy="-0.99997467"
- cx="24"
- gradientTransform="matrix(-3.9999999,0,0,-3.2105264,45.74315,-11.698447)"
- gradientUnits="userSpaceOnUse"
- id="radialGradient4667"
- xlink:href="#linearGradient4223"
- inkscape:collect="always" />
- <linearGradient
- id="linearGradient4223">
- <stop
- id="stop4225"
- style="stop-color:#cdf87e;stop-opacity:1"
- offset="0" />
- <stop
- id="stop4227"
- style="stop-color:#a2e34f;stop-opacity:1"
- offset="0.26238" />
- <stop
- id="stop4229"
- style="stop-color:#68b723;stop-opacity:1"
- offset="0.66093999" />
- <stop
- id="stop4231"
- style="stop-color:#1d7e0d;stop-opacity:1"
- offset="1" />
- </linearGradient>
- <linearGradient
- y2="40"
- x2="28"
- y1="20"
- x1="28"
- gradientUnits="userSpaceOnUse"
- id="linearGradient4669"
- xlink:href="#linearGradient4546"
- inkscape:collect="always" />
- <linearGradient
- id="linearGradient4546">
- <stop
- id="stop4548"
- style="stop-color:#ffffff;stop-opacity:1"
- offset="0" />
- <stop
- id="stop4550"
- style="stop-color:#ffffff;stop-opacity:0.23529412"
- offset="0.33333334" />
- <stop
- id="stop4552"
- style="stop-color:#ffffff;stop-opacity:0.15686275"
- offset="0.95056331" />
- <stop
- id="stop4554"
- style="stop-color:#ffffff;stop-opacity:0.39215687"
- offset="1" />
- </linearGradient>
- <clipPath
- id="clipPath4631"
- clipPathUnits="userSpaceOnUse">
- <path
- inkscape:connector-curvature="0"
- id="path4633"
- d="m 18,21 c -4.994649,0 -9,4.005351 -9,9 l 0,2 c 0,4.994649 4.005351,9 9,9 l 18,0 c 0.291005,0 0.595612,-0.03033 0.90625,-0.0625 0.164957,-0.01665 0.343572,-0.0382 0.5,-0.0625 0.199113,-0.03129 0.353176,-0.07756 0.5625,-0.125 0.0355,-0.008 0.03758,0.002 0.0625,0 0.218054,-0.05088 0.442966,-0.09019 0.65625,-0.15625 L 38.96875,40.5 39.1875,40.71875 c 1.321675,1.292865 3.339421,1.62433 5.0625,0.8125 -0.854684,-0.590174 -1.70835,-1.221522 -2.375,-2.0625 l -0.28125,-0.375 0.34375,-0.3125 c 0.12104,-0.106162 0.277237,-0.245985 0.4375,-0.40625 0.208233,-0.208236 0.400103,-0.398273 0.5625,-0.59375 0.07931,-0.09546 0.10524,-0.11495 0.0625,-0.0625 0.15692,-0.192563 0.297542,-0.432061 0.46875,-0.6875 0.09522,-0.141184 0.16811,-0.269097 0.25,-0.40625 0.05562,-0.09374 0.1253,-0.228314 0.21875,-0.40625 0.103006,-0.194932 0.17576,-0.34428 0.21875,-0.4375 0.06734,-0.146884 0.1409,-0.32834 0.21875,-0.53125 0.06354,-0.164982 0.13073,-0.2679 0.15625,-0.34375 0.01249,-0.03725 0.03148,-0.118206 0.0625,-0.21875 0.07714,-0.249066 0.14052,-0.47772 0.1875,-0.6875 0.01928,-0.08779 0.03966,-0.218312 0.0625,-0.34375 0.03827,-0.205597 0.06782,-0.42249 0.09375,-0.65625 -0.0082,0.07577 -0.01322,0.03973 0,-0.09375 C 44.9696,32.588254 45,32.298353 45,32 l 0,-2 c 0,-4.994649 -4.005351,-9 -9,-9 l -18,0 z"
- style="fill:#b84747;fill-opacity:1;stroke:none" />
- </clipPath>
- <radialGradient
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(1,0,0,0.33333333,0,25.333333)"
- r="18"
- fy="38"
- fx="26"
- cy="38"
- cx="26"
- id="radialGradient4572"
- xlink:href="#linearGradient8838"
- inkscape:collect="always" />
- <radialGradient
- r="19"
- fy="-0.99997467"
- fx="24"
- cy="-0.99997467"
- cx="24"
- gradientTransform="matrix(3.9999999,0,0,-3.2105264,-141.24316,4.301554)"
- gradientUnits="userSpaceOnUse"
- id="radialGradient4649"
- xlink:href="#linearGradient4129"
- inkscape:collect="always" />
- <linearGradient
- id="linearGradient4129">
- <stop
- id="stop4131"
- style="stop-color:#90dbec;stop-opacity:1"
- offset="0" />
- <stop
- id="stop4133"
- style="stop-color:#42baea;stop-opacity:1"
- offset="0.26238" />
- <stop
- id="stop4135"
- style="stop-color:#3689e6;stop-opacity:1"
- offset="0.704952" />
- <stop
- id="stop4137"
- style="stop-color:#2b63a0;stop-opacity:1"
- offset="1" />
- </linearGradient>
- <clipPath
- id="clipPath3103"
- clipPathUnits="userSpaceOnUse">
- <path
- inkscape:connector-curvature="0"
- id="path3105"
- d="m 18,21 c -4.994649,0 -9,4.005351 -9,9 l 0,2 c 0,4.994649 4.005351,9 9,9 l 18,0 c 0.291005,0 0.595612,-0.03033 0.90625,-0.0625 0.164957,-0.01665 0.343572,-0.0382 0.5,-0.0625 0.199113,-0.03129 0.353176,-0.07756 0.5625,-0.125 0.0355,-0.008 0.03758,0.002 0.0625,0 0.218054,-0.05088 0.442966,-0.09019 0.65625,-0.15625 L 38.96875,40.5 39.1875,40.71875 c 1.321675,1.292865 3.339421,1.62433 5.0625,0.8125 -0.854684,-0.590174 -1.70835,-1.221522 -2.375,-2.0625 l -0.28125,-0.375 0.34375,-0.3125 c 0.12104,-0.106162 0.277237,-0.245985 0.4375,-0.40625 0.208233,-0.208236 0.400103,-0.398273 0.5625,-0.59375 0.07931,-0.09546 0.10524,-0.11495 0.0625,-0.0625 0.15692,-0.192563 0.297542,-0.432061 0.46875,-0.6875 0.09522,-0.141184 0.16811,-0.269097 0.25,-0.40625 0.05562,-0.09374 0.1253,-0.228314 0.21875,-0.40625 0.103006,-0.194932 0.17576,-0.34428 0.21875,-0.4375 0.06734,-0.146884 0.1409,-0.32834 0.21875,-0.53125 0.06354,-0.164982 0.13073,-0.2679 0.15625,-0.34375 0.01249,-0.03725 0.03148,-0.118206 0.0625,-0.21875 0.07714,-0.249066 0.14052,-0.47772 0.1875,-0.6875 0.01928,-0.08779 0.03966,-0.218312 0.0625,-0.34375 0.03827,-0.205597 0.06782,-0.42249 0.09375,-0.65625 -0.0082,0.07577 -0.01322,0.03973 0,-0.09375 C 44.9696,32.588254 45,32.298353 45,32 l 0,-2 c 0,-4.994649 -4.005351,-9 -9,-9 l -18,0 z"
- style="fill:#b84747;fill-opacity:1;stroke:none" />
- </clipPath>
- <radialGradient
- inkscape:collect="always"
- xlink:href="#linearGradient8838"
- id="radialGradient3115"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(1,0,0,0.33333333,0,25.333333)"
- cx="26"
- cy="38"
- fx="26"
- fy="38"
- r="18" />
- <radialGradient
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(-7.8155022e-8,3.4259259,-4.4444444,-1.013903e-7,44.88889,-42.814815)"
- r="13.5"
- fy="6.5"
- fx="16"
- cy="6.5"
- cx="16"
- id="radialGradient3893"
- xlink:href="#linearGradient4129"
- inkscape:collect="always" />
- <radialGradient
- r="13.5"
- fy="6.5"
- fx="16"
- cy="6.5"
- cx="16"
- gradientTransform="matrix(-7.8155022e-8,3.4259259,-4.4444444,-1.013903e-7,44.88889,-42.814815)"
- gradientUnits="userSpaceOnUse"
- id="radialGradient3915"
- xlink:href="#linearGradient4129"
- inkscape:collect="always" />
- <radialGradient
- r="13.5"
- fy="6.5"
- fx="16"
- cy="6.5"
- cx="16"
- gradientTransform="matrix(-7.8155022e-8,3.4259259,-4.4444444,-1.013903e-7,44.88889,-42.814815)"
- gradientUnits="userSpaceOnUse"
- id="radialGradient3918"
- xlink:href="#linearGradient4129"
- inkscape:collect="always" />
- <clipPath
- id="clipPath3932"
- clipPathUnits="userSpaceOnUse">
- <path
- inkscape:connector-curvature="0"
- id="path3934"
- d="M 9.5,13 C 6.4443514,13 4,15.444351 4,18.5 l 0,3 C 4,24.555649 6.4443514,27 9.5,27 l 14,0 c 0.219638,0 0.431898,-0.0097 0.625,-0.03125 l 0.21875,-0.03125 0.1875,0.15625 c 0.904516,0.812057 2.163157,0.95166 3.34375,0.59375 -0.424928,-0.320003 -0.881722,-0.595637 -1.25,-1 L 26.25,26.28125 26.71875,25.9375 C 28.101099,24.936953 29,23.340469 29,21.5 l 0,-3 C 29,15.444351 26.555649,13 23.5,13 l -14,0 z"
- style="fill:#000000;fill-opacity:1;stroke:none" />
- </clipPath>
- <clipPath
- id="clipPath3061"
- clipPathUnits="userSpaceOnUse">
- <path
- sodipodi:nodetypes="ssssscccccccssss"
- style="fill:#000000;fill-opacity:1;stroke:none"
- d="M 9.5,14 C 6.4443514,14 4,16.444351 4,19.5 l 0,2 C 4,24.555649 6.4443514,27 9.5,27 l 10,0 c 0.219638,0 0.431898,-0.0097 0.625,-0.03125 l 0.21875,-0.03125 0.1875,0.15625 c 0.904516,0.812057 2.163157,0.95166 3.34375,0.59375 -0.424928,-0.320003 -0.881722,-0.595637 -1.25,-1 L 22.25,26.28125 22.71875,25.9375 C 24.101099,24.936953 25,23.340469 25,21.5 l 0,-2 C 25,16.444351 22.555649,14 19.5,14 z"
- id="path3063"
- inkscape:connector-curvature="0" />
- </clipPath>
- <clipPath
- id="clipPath3075"
- clipPathUnits="userSpaceOnUse">
- <path
- inkscape:connector-curvature="0"
- id="path3077"
- d="M 9.5,15 C 6.4443514,15 4,17.444351 4,20.5 l 0,1 C 4,24.555649 6.4443514,27 9.5,27 l 6,0 c 0.219638,0 0.431898,-0.0097 0.625,-0.03125 l 0.21875,-0.03125 0.1875,0.15625 c 0.904516,0.812057 2.163157,0.95166 3.34375,0.59375 -0.424928,-0.320003 -0.881722,-0.595637 -1.25,-1 L 18.25,26.28125 18.71875,25.9375 C 20.101099,24.936953 21,23.340469 21,21.5 l 0,-1 C 21,17.444351 18.555649,15 15.5,15 z"
- style="fill:#000000;fill-opacity:1;stroke:none"
- sodipodi:nodetypes="ssssscccccccssss" />
- </clipPath>
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient4223"
- id="linearGradient4826"
- x1="9.424572"
- y1="-10.106976"
- x2="9.424572"
- y2="25.414469"
- gradientUnits="userSpaceOnUse" />
- </defs>
- <metadata
- id="metadata90">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title>Gnome Symbolic Icon Theme</dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <path
- d="M 23,19.499999 C 23,21.985281 18.075131,24 12,24 5.924868,24 1,21.985281 1,19.499999 1,17.014718 5.924868,15 12,15 c 6.075131,0 11,2.014718 11,4.499999 l 0,0 z"
- inkscape:connector-curvature="0"
- id="path8836"
- style="display:inline;overflow:visible;visibility:visible;opacity:0.3;fill:url(#radialGradient3049);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.99999988;marker:none" />
- <g
- transform="translate(-111.61542,-593.4038)"
- id="layer12">
- <path
- d="m 228.01,607.02 c -3.86,0 -7.0073,3.166 -7.0073,7.0103 0,3.8443 3.1472,6.9787 7.0073,6.9787 3.86,0 7.0073,-3.1344 7.0073,-6.9787 0,-3.8443 -3.1472,-7.0103 -7.0073,-7.0103 z m 0,2.021 c 2.7769,0 5.0097,2.2237 5.0097,4.9893 0,2.7656 -2.2328,4.9577 -5.0097,4.9577 -2.777,0 -5.0097,-2.1921 -5.0097,-4.9577 0,-2.7656 2.2328,-4.9893 5.0097,-4.9893 z"
- id="path4222"
- style="color:#000000;text-indent:0;text-transform:none;block-progression:tb;fill:#bebebe"
- inkscape:connector-curvature="0" />
- <path
- d="m 231.41,609.44 -8,8 1.4062,1.4062 8,-8 -1.4062,-1.4062 z"
- id="path4992"
- style="color:#000000;text-indent:0;text-transform:none;block-progression:tb;fill:#bebebe"
- inkscape:connector-curvature="0" />
- </g>
- <path
- style="fill:#000000;fill-opacity:0"
- d="M 3.8914706,16.884163 C 3.4103263,16.122175 3.0583616,14.874941 3.003735,13.738353 2.9786317,13.216042 2.9904131,12.872245 3.036357,12.786398 3.0800139,12.704824 3.2418563,12.617784 3.4482218,12.564894 3.8914458,12.4513 4.5265161,12.144239 5.8961843,11.381288 l 1.1165232,-0.62194 0.7570601,-0.02403 c 0.8929799,-0.02835 1.2830044,0.06299 2.0579192,0.481909 0.2812132,0.152025 0.5479652,0.304385 0.5927812,0.338577 0.07081,0.05402 -1.5991187,1.535031 -6.2292646,5.524569 -0.1025198,0.08834 -0.1324231,0.06876 -0.2997328,-0.196208 l 0,0 z"
- id="path2987"
- inkscape:connector-curvature="0" />
- <path
- style="fill:#000000;fill-opacity:0"
- d="M 7.5676774,20.795393 C 7.0256619,20.469009 6.4290755,19.979639 5.8305085,19.370422 5.33023,18.861243 5.3242581,18.851054 5.4600194,18.738315 c 0.075892,-0.06302 1.7041174,-1.472213 3.6182787,-3.131535 2.6060709,-2.259116 3.5165739,-3.011455 3.6247259,-2.995077 0.291451,0.04413 0.329784,0.188652 0.290923,1.096772 -0.07204,1.683495 -0.589725,2.952665 -1.866622,4.576271 -0.495094,0.629525 -1.366327,1.526375 -1.8854314,1.94087 C 8.8466967,20.541173 8.091686,21.030508 8,21.030508 c -0.023031,0 -0.2175765,-0.105802 -0.4323226,-0.235115 z"
- id="path2989"
- inkscape:connector-curvature="0" />
- <path
- d="M 11.955413,2 C 7.9002937,2 7.8501927,4.7877367 2.5027824,5.2314411 c 0,0 -1.4090126,3.5442522 0.4904667,8.3842799 C 4.1916569,16.66936 9.2619851,21.973865 11.821648,22 l 0.356704,0 C 14.738015,21.97387 19.808345,16.66936 21.00675,13.615721 22.906231,8.7756933 21.497217,5.2314411 21.497217,5.2314411 16.149808,4.7877367 16.099706,2 12.044587,2 Z"
- id="path3016-2"
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:url(#linearGradient3647);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999988;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="scsccscss" />
- <path
- d="m 11.955413,2.037717 c -4.0551193,0 -4.1052203,2.7877367 -9.4526306,3.2314411 0,0 -1.4090126,3.5442522 0.4904667,8.3842799 1.1984078,3.053639 6.268736,8.358144 8.8283989,8.384279 l 0.356704,0 c 2.559663,-0.02613 7.629993,-5.33064 8.828398,-8.384279 C 22.906231,8.8134103 21.497217,5.2691581 21.497217,5.2691581 16.149808,4.8254537 16.099706,2.037717 12.044587,2.037717 Z"
- id="path3016-2-1"
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.3;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.99999988;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate;filter-blend-mode:normal;filter-gaussianBlur-deviation:0"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="scsccscss" />
- <path
- d="m 11.955413,3.0543523 c -3.6409345,0 -3.5027696,2.4488582 -8.6995673,3.1184816 0,0 -0.9319349,4.2684311 1.0552641,7.8571351 2.0746863,3.746699 5.7415922,6.964978 7.5105382,6.991113 l 0.356704,0 c 1.844253,-0.02613 6.613358,-4.502271 7.811763,-7.55591 C 21.889596,8.6251444 20.668848,6.2104871 20.668848,6.2104871 15.283785,5.2772916 15.723174,3.0543523 12.044587,3.0543523 Z"
- id="path3016-2-1-1"
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient4556);stroke-width:1.00000012;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate;filter-blend-mode:normal;filter-gaussianBlur-deviation:0"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="scsccscss" />
- <path
- style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.5;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate"
- d="m 11.064453,6.0934752 c -0.736072,0.090507 -1.0911094,0.3766442 -2.0078124,0.8730469 -0.8858,0.4796687 -2.3650342,1.4601803 -4.1914062,1.8769531 -0.170321,1.0649711 -0.2082425,2.6048188 0.7578125,5.0664058 0.116224,0.296146 0.4021556,0.809023 0.7597656,1.353516 L 15.701172,7.3591002 C 15.45871,7.2188299 15.133552,7.0695094 14.943359,6.9665221 13.721089,6.3046514 13.519899,6.0934752 12.044922,6.0934752 l -0.08984,0 c -0.368744,0 -0.645267,-0.030169 -0.890625,0 z M 18.509766,8.6696471 8.1210938,17.489959 c 0.2477189,0.280185 0.4984735,0.574654 0.7578124,0.830078 0.7636571,0.752121 1.5605298,1.389459 2.1855468,1.791016 0.448862,0.28838 0.808903,0.402687 0.845703,0.435547 l 0.222656,0 c 0.07681,-0.04063 0.388401,-0.16935 0.802735,-0.435547 0.625016,-0.401557 1.421891,-1.038895 2.185547,-1.791016 1.527315,-1.504244 2.93633,-3.59597 3.255859,-4.410156 0.966054,-2.461587 0.928134,-4.0014347 0.757813,-5.0664058 -0.218887,-0.049956 -0.416513,-0.1089482 -0.625,-0.1738281 z"
- id="path4589-8"
- inkscape:connector-curvature="0" />
- <path
- style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:url(#linearGradient4826);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate"
- d="M 11.064453 4.7949219 C 10.328381 4.8854287 9.9733436 5.1715661 9.0566406 5.6679688 C 8.1708406 6.1476375 6.6916064 7.1281491 4.8652344 7.5449219 C 4.6949134 8.609893 4.6569919 10.149741 5.6230469 12.611328 C 5.7392709 12.907474 6.0252025 13.420351 6.3828125 13.964844 L 15.701172 6.0605469 C 15.45871 5.9202766 15.133552 5.7709561 14.943359 5.6679688 C 13.721089 5.006098 13.519899 4.7949219 12.044922 4.7949219 L 11.955078 4.7949219 C 11.586334 4.7949219 11.309811 4.7647529 11.064453 4.7949219 z M 18.509766 7.3710938 L 8.1210938 16.191406 C 8.3688127 16.471591 8.6195673 16.76606 8.8789062 17.021484 C 9.6425633 17.773605 10.439436 18.410943 11.064453 18.8125 C 11.513315 19.10088 11.873356 19.215187 11.910156 19.248047 L 12.132812 19.248047 C 12.209618 19.207416 12.521213 19.078697 12.935547 18.8125 C 13.560563 18.410943 14.357438 17.773605 15.121094 17.021484 C 16.648409 15.51724 18.057424 13.425514 18.376953 12.611328 C 19.343007 10.149741 19.305087 8.609893 19.134766 7.5449219 C 18.915879 7.4949656 18.718253 7.4359737 18.509766 7.3710938 z "
- id="path4589" />
- <path
- sodipodi:type="inkscape:offset"
- inkscape:radius="-0.52832085"
- inkscape:original="M 11.064453 4.7949219 C 10.328381 4.8854287 9.9733436 5.171566 9.0566406 5.6679688 C 8.1708406 6.1476374 6.6916064 7.1281491 4.8652344 7.5449219 C 4.6949134 8.609893 4.6569919 10.149741 5.6230469 12.611328 C 5.7392709 12.907474 6.0252025 13.420351 6.3828125 13.964844 L 15.701172 6.0605469 C 15.45871 5.9202766 15.133552 5.770956 14.943359 5.6679688 C 13.721089 5.006098 13.519899 4.7949219 12.044922 4.7949219 L 11.955078 4.7949219 C 11.586334 4.7949219 11.309811 4.7647529 11.064453 4.7949219 z M 18.509766 7.3710938 L 8.1210938 16.191406 C 8.3688127 16.471591 8.6195673 16.76606 8.8789062 17.021484 C 9.6425633 17.773605 10.439436 18.410943 11.064453 18.8125 C 11.513315 19.10088 11.873356 19.215187 11.910156 19.248047 L 12.132812 19.248047 C 12.209623 19.207417 12.521213 19.078697 12.935547 18.8125 C 13.560563 18.410943 14.357438 17.773605 15.121094 17.021484 C 16.648409 15.51724 18.057424 13.425514 18.376953 12.611328 C 19.343007 10.149741 19.305087 8.609893 19.134766 7.5449219 C 18.915879 7.4949659 18.718253 7.4359737 18.509766 7.3710938 z "
- style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;marker:none;enable-background:accumulate;opacity:0.15"
- id="path4628"
- d="M 11.128906,5.3183594 C 10.506281,5.3949169 10.249824,5.6231282 9.3085938,6.1328125 8.5357819,6.551297 7.1129542,7.4260208 5.3789062,7.9121094 5.2513275,8.8949358 5.2491088,10.21101 6.1152344,12.417969 c 0.049097,0.125103 0.2561506,0.460783 0.4121094,0.732422 L 14.759766,6.1679688 c -0.02188,-0.011461 -0.04786,-0.024056 -0.06836,-0.035156 C 13.449105,5.4600947 13.469472,5.3242188 12.044922,5.3242188 l -0.08984,0 c -0.39756,0 -0.67088,-0.024954 -0.826172,-0.00586 z M 18.621094,7.96875 8.8808594,16.240234 c 0.1231185,0.137329 0.2502373,0.287189 0.3691406,0.404297 0.7390542,0.72789 1.516664,1.34813 2.099609,1.722657 0.197093,0.126625 0.375877,0.215395 0.511719,0.277343 0.0626,0.02855 0.113457,0.05021 0.160156,0.07031 0.04444,-0.02072 0.08032,-0.03876 0.146485,-0.07227 0.127024,-0.06432 0.293344,-0.153914 0.482422,-0.27539 0.582944,-0.374528 1.360556,-0.994768 2.099609,-1.722657 0.7343,-0.723208 1.455186,-1.602505 2.023438,-2.394531 0.568251,-0.792026 0.991833,-1.527549 1.111328,-1.832031 0.851966,-2.170884 0.856786,-3.4700009 0.736328,-4.449219 z" />
-</svg>
diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt
index 92ad03bf..6fa17719 100644
--- a/icons/CMakeLists.txt
+++ b/icons/CMakeLists.txt
@@ -1,20 +1,11 @@
-# Copyright (C) 2013 Christian Dywan <christian@twotoasts.de>
-
-if (UNIX)
- EXECUTE_PROCESS(COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/hicolor)
-endif ()
+# Copyright (C) 2013-2018 Christian Dywan <christian@twotoasts.de>
macro(install_icon name cat size)
file(GLOB FILENAME RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${size}/${cat}/${name}.*")
install(FILES ${FILENAME} DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/${size}/${cat})
endmacro()
-foreach(SIZE 16x16 22x22 24x24 scalable)
+foreach(SIZE 16x16 22x22 scalable)
install_icon(midori apps ${SIZE})
- install_icon(extension categories ${SIZE})
- install_icon(internet-news-reader status ${SIZE})
- install_icon(adblock-enabled status ${SIZE})
- install_icon(adblock-blocked status ${SIZE})
- install_icon(adblock-disabled status ${SIZE})
endforeach()
diff --git a/icons/icon-theme.cache b/icons/icon-theme.cache
deleted file mode 100644
index 47cd3923..00000000
--- a/icons/icon-theme.cache
+++ /dev/null
Binary files differ
diff --git a/icons/index.theme b/icons/index.theme
index 3d47231f..7e8354f2 100644
--- a/icons/index.theme
+++ b/icons/index.theme
@@ -3,10 +3,22 @@ Name=Midori
Comment=Fallback Icons shipped with Midori
Inherits=hicolor
Example=midori
-Directories=status/24,
+Directories=16/apps,22/apps,scalable/apps
-[status/24]
-Size=24
-Context=Status
+[16/apps]
+Size=16
+Context=Applications
Type=Fixed
+[22/apps]
+Size=22
+Context=Applications
+Type=Fixed
+
+[scalable/apps]
+Size=48
+MinSize=24
+MaxSize=256
+Context=Applications
+Type=Scalable
+
diff --git a/icons/scalable/categories/extension.svg b/icons/scalable/categories/extension.svg
deleted file mode 100644
index b3cb4f78..00000000
--- a/icons/scalable/categories/extension.svg
+++ /dev/null
@@ -1,199 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="48"
- height="48"
- id="svg2"
- sodipodi:version="0.32"
- inkscape:version="0.46"
- version="1.0"
- sodipodi:docname="puzzle.svg"
- inkscape:output_extension="org.inkscape.output.svg.inkscape">
- <defs
- id="defs4">
- <linearGradient
- inkscape:collect="always"
- id="linearGradient3301">
- <stop
- style="stop-color:#888a85;stop-opacity:1;"
- offset="0"
- id="stop3303" />
- <stop
- style="stop-color:#888a85;stop-opacity:0;"
- offset="1"
- id="stop3305" />
- </linearGradient>
- <linearGradient
- id="linearGradient3259">
- <stop
- style="stop-color:#254109;stop-opacity:1;"
- offset="0"
- id="stop3261" />
- <stop
- style="stop-color:#c1f093;stop-opacity:0;"
- offset="1"
- id="stop3263" />
- </linearGradient>
- <linearGradient
- id="linearGradient3229">
- <stop
- style="stop-color:#6fcb15;stop-opacity:1;"
- offset="0"
- id="stop3231" />
- <stop
- style="stop-color:#73d216;stop-opacity:0;"
- offset="1"
- id="stop3233" />
- </linearGradient>
- <inkscape:perspective
- sodipodi:type="inkscape:persp3d"
- inkscape:vp_x="0 : 526.18109 : 1"
- inkscape:vp_y="0 : 1000 : 0"
- inkscape:vp_z="744.09448 : 526.18109 : 1"
- inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
- id="perspective10" />
- <inkscape:perspective
- id="perspective2447"
- inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
- inkscape:vp_z="744.09448 : 526.18109 : 1"
- inkscape:vp_y="0 : 1000 : 0"
- inkscape:vp_x="0 : 526.18109 : 1"
- sodipodi:type="inkscape:persp3d" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3229"
- id="linearGradient3235"
- x1="371.78729"
- y1="555.55804"
- x2="320.8378"
- y2="501.43228"
- gradientUnits="userSpaceOnUse" />
- <filter
- inkscape:collect="always"
- id="filter3287"
- x="-0.013903426"
- width="1.0278069"
- y="-0.11628319"
- height="1.2325664">
- <feGaussianBlur
- inkscape:collect="always"
- stdDeviation="0.20189084"
- id="feGaussianBlur3289" />
- </filter>
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3229"
- id="linearGradient3299"
- gradientUnits="userSpaceOnUse"
- x1="371.78729"
- y1="555.55804"
- x2="320.8378"
- y2="501.43228" />
- <radialGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3301"
- id="radialGradient3307"
- cx="17.704134"
- cy="44.27507"
- fx="17.704134"
- fy="44.27507"
- r="17.425131"
- gradientTransform="matrix(1.4191617,0,0,0.1195652,-7.4208958,38.981304)"
- gradientUnits="userSpaceOnUse" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3229"
- id="linearGradient3310"
- gradientUnits="userSpaceOnUse"
- x1="371.78729"
- y1="555.55804"
- x2="307.07446"
- y2="483.37579"
- gradientTransform="translate(0.1262691,0)" />
- </defs>
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="7.9195959"
- inkscape:cx="-31.755352"
- inkscape:cy="29.67997"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="true"
- inkscape:snap-global="false"
- inkscape:window-width="997"
- inkscape:window-height="795"
- inkscape:window-x="0"
- inkscape:window-y="0">
- <inkscape:grid
- type="xygrid"
- id="grid2455"
- visible="true"
- enabled="true" />
- </sodipodi:namedview>
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:creator>
- <cc:Agent>
- <dc:title>Nancy Runge</dc:title>
- </cc:Agent>
- </dc:creator>
- <dc:rights>
- <cc:Agent>
- <dc:title>licenced under LGPL</dc:title>
- </cc:Agent>
- </dc:rights>
- <dc:title>Extensions</dc:title>
- <dc:publisher>
- <cc:Agent>
- <dc:title>http://www.twotoasts.de</dc:title>
- </cc:Agent>
- </dc:publisher>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Ebene 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(-334.84263,-513.45087)">
- <path
- sodipodi:type="arc"
- style="opacity:0.52803034;fill:url(#radialGradient3307);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter3287)"
- id="path3257"
- sodipodi:cx="20.834396"
- sodipodi:cy="44.275063"
- sodipodi:rx="17.425131"
- sodipodi:ry="2.0834396"
- d="M 38.259527,44.275063 A 17.425131,2.0834396 0 1 1 3.4092655,44.275063 A 17.425131,2.0834396 0 1 1 38.259527,44.275063 z"
- transform="matrix(1.2065218,0,0,1.6363637,333.12839,482.68731)" />
- <path
- style="fill:#c1f093;fill-opacity:1;fill-rule:evenodd;stroke:#499402;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
- d="M 337.59808,522.17297 L 337.72435,533.84844 C 339.47847,534.10639 341.10631,535.92142 342.86043,535.22887 C 354.484,532.75774 350.70132,551.41563 342.10964,542.50639 C 340.64788,541.6646 339.18611,542.12627 337.72435,542.15558 L 337.67073,553.72581 L 353.23389,553.73869 C 354.05552,552.4318 354.72796,551.87106 354.60115,550.08995 C 351.64196,539.72544 369.94217,539.26102 360.04106,550.78887 C 359.83384,551.92692 361.24191,552.43363 361.98031,553.57168 L 369.96412,553.44765 L 369.96412,540.88184 C 370.96339,539.9698 371.96266,540.18833 372.96193,540.17836 C 384.45308,546.41513 382.69169,524.21109 372.50653,532.25474 C 371.79768,532.78933 371.04359,533.05251 370.0988,532.17145 L 370.0988,521.99757 L 362.85737,521.99757 C 361.30432,524.66021 361.13738,525.26649 361.37766,526.1182 C 368.03927,535.17088 347.04741,536.92703 352.54122,528.11641 C 354.21415,526.75748 354.49233,523.14925 354.4376,521.99756 L 337.57862,522.11095"
- id="path2453"
- sodipodi:nodetypes="ccccccccccccccccccccc" />
- <path
- style="fill:url(#linearGradient3310);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.87325984000000001;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
- d="M 339.0736,523.88908 L 339.37844,532.79484 C 340.92793,533.01753 342.49273,534.03344 344.04222,533.43557 C 356.8745,532.10371 351.782,552.26286 342.62716,544.9362 C 341.58846,543.57814 340.36483,543.48432 339.0736,543.50962 L 339.13777,552.19979 L 352.02889,552.1019 C 352.95857,551.13679 354.00081,551.05253 352.57409,548.46314 C 352.71994,537.89846 369.3947,537.1685 362.99814,549.56575 C 362.81509,550.54821 362.19137,550.54855 362.84363,551.53102 L 368.46752,551.51322 L 368.46752,540.12957 C 369.78113,538.48037 371.66756,538.44729 372.54418,538.45083 C 381.58291,544.2191 381.40416,527.19794 373.12406,533.66401 C 372.91206,535.1722 368.70591,534.44374 368.40791,532.60997 L 368.40791,523.55909 L 363.61838,523.64838 C 362.51436,525.85772 363.34904,526.38112 363.56129,527.11639 C 368.40591,536.59135 346.45266,539.32394 350.48782,528.03786 C 351.96559,526.86471 353.37203,524.01762 352.60941,523.55908 L 338.78855,523.65697"
- id="path3227"
- sodipodi:nodetypes="ccccccccccccccccccccc" />
- </g>
-</svg>
diff --git a/icons/scalable/status/internet-news-reader.svg b/icons/scalable/status/internet-news-reader.svg
deleted file mode 100644
index 2a2f6238..00000000
--- a/icons/scalable/status/internet-news-reader.svg
+++ /dev/null
@@ -1,280 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- id="svg2"
- sodipodi:version="0.32"
- inkscape:version="0.46"
- width="48"
- height="48"
- xml:space="preserve"
- sodipodi:docname="tango-rss.svg"
- version="1.0"
- inkscape:output_extension="org.inkscape.output.svg.inkscape"><metadata
- id="metadata7"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
- id="defs5"><linearGradient
- id="linearGradient3300"><stop
- style="stop-color:#ce5c00;stop-opacity:1;"
- offset="0"
- id="stop3302" /><stop
- style="stop-color:#893d00;stop-opacity:1;"
- offset="1"
- id="stop3304" /></linearGradient><linearGradient
- id="linearGradient3275"><stop
- style="stop-color:#ffffff;stop-opacity:1;"
- offset="0"
- id="stop3277" /><stop
- style="stop-color:#f57900;stop-opacity:0;"
- offset="1"
- id="stop3279" /></linearGradient><inkscape:perspective
- sodipodi:type="inkscape:persp3d"
- inkscape:vp_x="0 : 526.18109 : 1"
- inkscape:vp_y="0 : 1000 : 0"
- inkscape:vp_z="744.09448 : 526.18109 : 1"
- inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
- id="perspective9" /><clipPath
- clipPathUnits="userSpaceOnUse"
- id="clipPath17"><path
- d="M 0,128 L 128,128 L 128,0 L 0,0 L 0,128 z"
- id="path19" /></clipPath><linearGradient
- x1="0"
- y1="0"
- x2="1"
- y2="0"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(-104.01236,104.01237,104.01237,104.01237,116.00586,11.994141)"
- spreadMethod="pad"
- id="linearGradient37"><stop
- style="stop-opacity:1;stop-color:#d95b29"
- offset="0"
- id="stop39" /><stop
- style="stop-opacity:1;stop-color:#fb9e3a"
- offset="0.5"
- id="stop41" /><stop
- style="stop-opacity:1;stop-color:#e3702d"
- offset="1"
- id="stop43" /></linearGradient><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3275"
- id="linearGradient3281"
- x1="28.140682"
- y1="59.007069"
- x2="123.56256"
- y2="64.008011"
- gradientUnits="userSpaceOnUse" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3275"
- id="linearGradient3283"
- gradientUnits="userSpaceOnUse"
- x1="-22.962652"
- y1="-26.856916"
- x2="113.12444"
- y2="103.36325" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3275"
- id="linearGradient3285"
- gradientUnits="userSpaceOnUse"
- x1="4.4374332"
- y1="64.008011"
- x2="123.56256"
- y2="64.008011" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3275"
- id="linearGradient3287"
- gradientUnits="userSpaceOnUse"
- x1="4.4374332"
- y1="64.008011"
- x2="123.56256"
- y2="64.008011" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3300"
- id="linearGradient3306"
- x1="-0.98719376"
- y1="119.27105"
- x2="39.936729"
- y2="88.299164"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.9961613,0,0,1.0000405,6.8742977e-4,-4.4021459e-3)" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3300"
- id="linearGradient3351"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.9961613,0,0,1.0000405,6.8742977e-4,-4.4021459e-3)"
- x1="-0.98719376"
- y1="119.27105"
- x2="39.936729"
- y2="88.299164" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3275"
- id="linearGradient3353"
- gradientUnits="userSpaceOnUse"
- x1="-22.962652"
- y1="-26.856916"
- x2="113.12444"
- y2="103.36325" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3275"
- id="linearGradient3355"
- gradientUnits="userSpaceOnUse"
- x1="4.4374332"
- y1="64.008011"
- x2="123.56256"
- y2="64.008011" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3275"
- id="linearGradient3357"
- gradientUnits="userSpaceOnUse"
- x1="4.4374332"
- y1="64.008011"
- x2="123.56256"
- y2="64.008011" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3275"
- id="linearGradient3359"
- gradientUnits="userSpaceOnUse"
- x1="28.140682"
- y1="59.007069"
- x2="123.56256"
- y2="64.008011" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3300"
- id="linearGradient3209"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.9961613,0,0,1.0000405,6.8742977e-4,-4.4021459e-3)"
- x1="-0.98719376"
- y1="119.27105"
- x2="39.936729"
- y2="88.299164" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3275"
- id="linearGradient3211"
- gradientUnits="userSpaceOnUse"
- x1="-22.962652"
- y1="-26.856916"
- x2="113.12444"
- y2="103.36325" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3275"
- id="linearGradient3213"
- gradientUnits="userSpaceOnUse"
- x1="4.4374332"
- y1="64.008011"
- x2="123.56256"
- y2="64.008011" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3275"
- id="linearGradient3215"
- gradientUnits="userSpaceOnUse"
- x1="4.4374332"
- y1="64.008011"
- x2="123.56256"
- y2="64.008011" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3275"
- id="linearGradient3217"
- gradientUnits="userSpaceOnUse"
- x1="28.140682"
- y1="59.007069"
- x2="123.56256"
- y2="64.008011" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3300"
- id="linearGradient3232"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.9961613,0,0,1.0000405,6.4944458e-2,-4.4021459e-3)"
- x1="-0.98719376"
- y1="119.27105"
- x2="39.936729"
- y2="88.299164" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3275"
- id="linearGradient3234"
- gradientUnits="userSpaceOnUse"
- x1="-17.119463"
- y1="-35.774288"
- x2="113.12444"
- y2="103.36325" /></defs><sodipodi:namedview
- inkscape:window-height="720"
- inkscape:window-width="888"
- inkscape:pageshadow="2"
- inkscape:pageopacity="0.0"
- guidetolerance="10.0"
- gridtolerance="10.0"
- objecttolerance="10.0"
- borderopacity="1.0"
- bordercolor="#666666"
- pagecolor="#ffffff"
- id="base"
- showgrid="true"
- inkscape:snap-global="false"
- showguides="true"
- inkscape:guide-bbox="true"
- inkscape:zoom="8.8034794"
- inkscape:cx="3.3324561"
- inkscape:cy="40.010499"
- inkscape:window-x="542"
- inkscape:window-y="39"
- inkscape:current-layer="g11"><inkscape:grid
- type="xygrid"
- id="grid2432"
- visible="true"
- enabled="true" /></sodipodi:namedview><g
- id="g11"
- inkscape:groupmode="layer"
- inkscape:label="feed-icon-legacy"
- transform="matrix(1.25,0,0,-1.25,0,160)"><path
- style="fill:#fcaf3e;fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient3232);stroke-width:0.80048220999999986"
- d="M 38.002169,119.5841 C 38.136627,124.13453 33.833799,128.04502 29.34011,127.60391 C 22.114004,127.57701 14.884487,127.65816 7.6605468,127.56249 C 3.374464,127.23569 0.043196567,123.0315 0.4796428,118.78629 C 0.50646108,111.58944 0.42554092,104.38919 0.52093827,97.194505 C 0.84590169,92.898821 5.0383763,89.557076 9.2743628,89.994993 C 16.456202,90.021864 23.641448,89.940771 30.821119,90.036395 C 35.107237,90.362998 38.438787,94.566998 38.002169,98.8123 C 38.002169,105.73624 38.002169,112.66018 38.002169,119.5841 z"
- id="path21" /><g
- id="g27"
- transform="matrix(0.2954876,0,0,-0.2955267,0.3513908,127.60862)"
- style="fill:#f57900;fill-opacity:1"><g
- id="g33"
- style="fill:#f57900;fill-opacity:1"><g
- id="g35"
- style="fill:#f57900;fill-opacity:1"><path
- id="path45"
- d="M 123.429,29.915001 C 123.85961,15.464801 110.11454,3.1099424 95.831258,4.571 C 72.994905,4.6555834 50.147792,4.4001008 27.318303,4.7018714 C 13.655392,5.7359945 3.1212452,19.154954 4.571,32.63029 C 4.6555615,55.310488 4.4001543,78.001434 4.701815,100.67478 C 5.732848,114.33766 19.14685,124.88003 32.62429,123.429 C 55.309345,123.34447 78.005156,123.59982 100.68335,123.29816 C 114.34614,122.26269 124.87863,108.84276 123.429,95.36771 C 123.429,73.55014 123.429,51.732571 123.429,29.915001 z"
- style="fill:#f57900;fill-opacity:1;stroke:none" /></g></g></g><g
- id="g3267"
- transform="matrix(0.2954876,0,0,-0.2955267,0.3016452,127.60042)"
- style="fill:url(#linearGradient3217);fill-opacity:1"><g
- id="g3269"
- style="fill:url(#linearGradient3215);fill-opacity:1"><g
- id="g3271"
- style="fill:url(#linearGradient3213);fill-opacity:1"><path
- id="path3273"
- d="M 120.35364,17.922673 C 115.55613,8.6998977 107.96179,4.6474204 95.831258,4.571 C 72.994905,4.6555834 50.147792,4.4001008 27.318303,4.7018714 C 13.655392,5.7359945 3.1212452,19.154954 4.571,32.63029 C 4.6555615,55.310488 4.4001543,80.768894 4.701815,103.44224 C 6.1143957,104.77002 9.3538134,119.64674 16.281216,115.55817 C 32.747299,105.83986 62.937668,76.829161 61.921742,67.38561 C 61.921742,45.56804 120.35364,39.740243 120.35364,17.922673 z"
- style="fill:url(#linearGradient3234);fill-opacity:1;stroke:none"
- sodipodi:nodetypes="cccccscc" /></g></g></g><g
- id="g3295"
- transform="translate(-0.7068273,-0.4497993)"
- style="fill:#eeeeec;stroke:#eeeeec"><path
- transform="matrix(0.8,0,0,-0.8,0,128)"
- sodipodi:nodetypes="ccccc"
- id="path3293"
- d="M 8.7550201,7.1164658 C 27.144226,9.188466 39.179126,18.429426 40.883534,39.325301 L 35.180723,39.325301 C 33.384365,22.620491 23.902594,14.889021 8.8353414,13.381526 L 8.7550201,7.1164658 z"
- style="fill:#eeeeec;fill-opacity:1;fill-rule:evenodd;stroke:#eeeeec;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- sodipodi:nodetypes="ccccc"
- transform="matrix(0.8,0,0,-0.8,0,128)"
- id="path3291"
- d="M 9.0763052,24.2249 C 18.841763,24.662007 23.0271,30.700076 23.935743,39.405622 L 29.879518,39.485944 C 28.300152,25.30521 20.281142,19.207838 9.0763052,18.120482 L 9.0763052,24.2249 z"
- style="fill:#eeeeec;fill-opacity:1;fill-rule:evenodd;stroke:#eeeeec;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- transform="matrix(0.8,0,0,-0.8,0.8178584,128)"
- d="M 16.290628,35.107368 A 4.3635263,4.3537817 0 1 1 7.5635757,35.107368 A 4.3635263,4.3537817 0 1 1 16.290628,35.107368 z"
- sodipodi:ry="4.3537817"
- sodipodi:rx="4.3635263"
- sodipodi:cy="35.107368"
- sodipodi:cx="11.927102"
- id="path2493"
- style="opacity:1;fill:#eeeeec;fill-opacity:1;fill-rule:evenodd;stroke:#eeeeec;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- sodipodi:type="arc" /></g></g></svg> \ No newline at end of file
diff --git a/katze/gtk3-compat.c b/katze/gtk3-compat.c
deleted file mode 100644
index d8a37f2e..00000000
--- a/katze/gtk3-compat.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- Copyright (C) 2011-2012 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.
-*/
-
-#include "katze/gtk3-compat.h"
-
-#if !GTK_CHECK_VERSION (3, 2, 0)
-static void
-sokoke_widget_set_pango_font_style (GtkWidget* widget,
- PangoStyle style)
-{
- /* Conveniently change the pango font style
- For some reason we need to reset if we actually want the normal style */
- if (style == PANGO_STYLE_NORMAL)
- gtk_widget_modify_font (widget, NULL);
- else
- {
- PangoFontDescription* font_description = pango_font_description_new ();
- pango_font_description_set_style (font_description, PANGO_STYLE_ITALIC);
- gtk_widget_modify_font (widget, font_description);
- pango_font_description_free (font_description);
- }
-}
-
-/* returns TRUE if the entry is currently showing its placeholder text */
-static gboolean
-sokoke_entry_is_showing_default (GtkEntry* entry)
-{
- gint showing_default = GPOINTER_TO_INT (
- g_object_get_data (G_OBJECT (entry), "sokoke_showing_default"));
-
- const gchar* text = gtk_entry_get_text (entry);
- const gchar* default_text = (const gchar*)g_object_get_data (
- G_OBJECT (entry), "sokoke_default_text");
-
- return showing_default && !g_strcmp0(text, default_text);
-}
-
-/* returns TRUE if the entry is not being used by the user to perform entry or
-hold data at a given moment */
-static gboolean
-sokoke_entry_is_idle (GtkEntry* entry)
-{
- const gchar* text = gtk_entry_get_text (entry);
-
- /* if the default is visible or the user has left the entry blank */
- return sokoke_entry_is_showing_default(entry) ||
- (text && !*text && !gtk_widget_has_focus (GTK_WIDGET (entry)));
-}
-
-static gboolean
-sokoke_on_entry_text_changed (GtkEntry* entry,
- GParamSpec* pspec,
- gpointer userdata);
-
-static void
-sokoke_hide_placeholder_text (GtkEntry* entry)
-{
- if(sokoke_entry_is_showing_default (entry))
- {
- g_signal_handlers_block_by_func (entry, sokoke_on_entry_text_changed, NULL);
- gtk_entry_set_text (entry, "");
- g_signal_handlers_unblock_by_func (entry, sokoke_on_entry_text_changed, NULL);
- }
- g_object_set_data (G_OBJECT (entry), "sokoke_showing_default",
- GINT_TO_POINTER (0));
- sokoke_widget_set_pango_font_style (GTK_WIDGET (entry),
- PANGO_STYLE_NORMAL);
-}
-
-static gboolean
-sokoke_on_entry_focus_in_event (GtkEntry* entry,
- GdkEventFocus* event,
- gpointer userdata)
-{
- sokoke_hide_placeholder_text (entry);
- return FALSE;
-}
-
-static void
-sokoke_show_placeholder_text (GtkEntry* entry)
-{
- /* no need to do work if the widget is unfocused with placeholder */
- if(sokoke_entry_is_showing_default (entry))
- return;
-
- /* no need to do work if the placeholder is already visible */
- const gchar* text = gtk_entry_get_text (entry);
- if (text && !*text)
- {
- const gchar* default_text = (const gchar*)g_object_get_data (
- G_OBJECT (entry), "sokoke_default_text");
- g_object_set_data (G_OBJECT (entry),
- "sokoke_showing_default", GINT_TO_POINTER (1));
- g_signal_handlers_block_by_func (entry, sokoke_on_entry_text_changed, NULL);
- gtk_entry_set_text (entry, default_text);
- g_signal_handlers_unblock_by_func (entry, sokoke_on_entry_text_changed, NULL);
- sokoke_widget_set_pango_font_style (GTK_WIDGET (entry),
- PANGO_STYLE_ITALIC);
- }
-}
-
-static void
-sokoke_on_entry_drag_leave (GtkEntry* entry,
- GdkDragContext* drag_context,
- guint timestamp,
- gpointer user_data)
-{
- sokoke_show_placeholder_text (entry);
-}
-
-static gboolean
-sokoke_on_entry_text_changed (GtkEntry* entry,
- GParamSpec* pspec,
- gpointer userdata)
-{
- if(sokoke_entry_is_idle (entry))
- {
- sokoke_show_placeholder_text (entry);
- }
- else
- {
- sokoke_hide_placeholder_text (entry);
- }
-
- return TRUE;
-}
-
-static gboolean
-sokoke_on_entry_focus_out_event (GtkEntry* entry,
- GdkEventFocus* event,
- gpointer userdata)
-{
- sokoke_show_placeholder_text (entry);
- return FALSE;
-}
-
-static gboolean
-sokoke_on_entry_drag_motion (GtkEntry* entry,
- GdkDragContext* drag_context,
- gint x,
- gint y,
- guint timestamp,
- gpointer user_data)
-{
- sokoke_hide_placeholder_text (entry);
- return FALSE;
-}
-
-static gboolean
-sokoke_on_entry_drag_drop (GtkEntry* entry,
- GdkDragContext* drag_context,
- gint x,
- gint y,
- guint timestamp,
- gpointer user_data)
-{
- sokoke_hide_placeholder_text (entry);
- return FALSE;
-}
-
-static void
-sokoke_on_entry_popup (GtkEntry *entry,
- GtkWidget *popup,
- gpointer user_data)
-{
- /* If the user selects paste in the popup, we should hide the default
- when the menu closes so it pastes into a clean entry */
- g_signal_connect_swapped (popup, "destroy", G_CALLBACK (
- sokoke_hide_placeholder_text), entry);
-}
-
-void
-gtk_entry_set_placeholder_text (GtkEntry* entry,
- const gchar* default_text)
-{
- /* Note: The default text initially overwrites any previous text */
- gchar* old_default_text = g_object_get_data (G_OBJECT (entry), "sokoke_default_text");
- g_object_set_data (G_OBJECT (entry), "sokoke_default_text", (gpointer)default_text);
-
- if (default_text == NULL)
- {
- g_object_set_data (G_OBJECT (entry), "sokoke_showing_default", GINT_TO_POINTER (0));
- g_signal_handlers_disconnect_by_func (entry,
- G_CALLBACK (sokoke_on_entry_drag_motion), NULL);
- g_signal_handlers_disconnect_by_func (entry,
- G_CALLBACK (sokoke_on_entry_focus_in_event), NULL);
- g_signal_handlers_disconnect_by_func (entry,
- G_CALLBACK (sokoke_on_entry_drag_leave), NULL);
- g_signal_handlers_disconnect_by_func (entry,
- G_CALLBACK (sokoke_on_entry_drag_drop), NULL);
- g_signal_handlers_disconnect_by_func (entry,
- G_CALLBACK (sokoke_on_entry_focus_out_event), NULL);
- g_signal_handlers_disconnect_by_func (entry,
- G_CALLBACK (sokoke_on_entry_text_changed), NULL);
- g_signal_handlers_disconnect_by_func (entry,
- G_CALLBACK (sokoke_on_entry_popup), NULL);
- }
- else if (old_default_text == NULL)
- {
- g_object_set_data (G_OBJECT (entry), "sokoke_showing_default", GINT_TO_POINTER (1));
- sokoke_widget_set_pango_font_style (GTK_WIDGET (entry), PANGO_STYLE_ITALIC);
- gtk_entry_set_text (entry, default_text);
- g_signal_connect (entry, "drag-motion",
- G_CALLBACK (sokoke_on_entry_drag_motion), NULL);
- g_signal_connect (entry, "focus-in-event",
- G_CALLBACK (sokoke_on_entry_focus_in_event), NULL);
- g_signal_connect (entry, "drag-leave",
- G_CALLBACK (sokoke_on_entry_drag_leave), NULL);
- g_signal_connect (entry, "drag-drop",
- G_CALLBACK (sokoke_on_entry_drag_drop), NULL);
- g_signal_connect (entry, "focus-out-event",
- G_CALLBACK (sokoke_on_entry_focus_out_event), NULL);
- g_signal_connect (entry, "notify::text",
- G_CALLBACK (sokoke_on_entry_text_changed), NULL);
- g_signal_connect (entry, "populate-popup",
- G_CALLBACK (sokoke_on_entry_popup), NULL);
- }
- else if (!gtk_widget_has_focus (GTK_WIDGET (entry)))
- {
- gint showing_default = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (entry), "sokoke_showing_default"));
- if (showing_default)
- {
- gtk_entry_set_text (entry, default_text);
- sokoke_widget_set_pango_font_style (GTK_WIDGET (entry), PANGO_STYLE_ITALIC);
- }
- }
-}
-
-const gchar*
-gtk_entry_get_placeholder_text (GtkEntry* entry)
-{
- return g_object_get_data (G_OBJECT (entry), "sokoke_default_text");
-}
-#endif
-
diff --git a/katze/gtk3-compat.h b/katze/gtk3-compat.h
deleted file mode 100644
index eeb9b873..00000000
--- a/katze/gtk3-compat.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- Copyright (C) 2011-2012 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.
-*/
-
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-
-#ifndef H_GTK3_COMPAT_20110110
-#define H_GTK3_COMPAT_20110110
-
-G_BEGIN_DECLS
-
-#if GTK_CHECK_VERSION (3, 2, 0) && defined (GTK_DISABLE_DEPRECATED)
- #define GTK_TYPE_VBOX GTK_TYPE_BOX
- #define GtkVBox GtkBox
- #define GtkVBoxClass GtkBoxClass
- #define gtk_vbox_new(hmg,spc) g_object_new (GTK_TYPE_BOX, \
- "homogeneous", hmg, "spacing", spc, \
- "orientation", GTK_ORIENTATION_VERTICAL, NULL)
- #define GTK_TYPE_HBOX GTK_TYPE_BOX
- #define GtkHBox GtkBox
- #define GtkHBoxClass GtkBoxClass
- #define gtk_hbox_new(hmg,spc) g_object_new (GTK_TYPE_BOX, \
- "homogeneous", hmg, "spacing", spc, \
- "orientation", GTK_ORIENTATION_HORIZONTAL, NULL)
- #define gtk_hseparator_new() g_object_new (GTK_TYPE_SEPARATOR, NULL)
- #define gtk_hpaned_new() g_object_new (GTK_TYPE_PANED, NULL)
- #define gtk_vpaned_new() g_object_new (GTK_TYPE_PANED, \
- "orientation", GTK_ORIENTATION_VERTICAL, NULL)
- /* FIXME */
- #define gtk_widget_render_icon(wdgt, stk, sz, dtl) \
- gtk_widget_render_icon_pixbuf(wdgt, stk, sz)
- #define gtk_widget_size_request(wdgt, req) \
- gtk_widget_get_preferred_size(wdgt, req, NULL)
-#endif
-
-#if GTK_CHECK_VERSION (3, 0, 0)
- #define GTK_DIALOG_NO_SEPARATOR 0
-#endif
-
-#if !GTK_CHECK_VERSION (3, 2, 0)
- void gtk_entry_set_placeholder_text (GtkEntry* entry, const gchar* text);
- const gchar* gtk_entry_get_placeholder_text (GtkEntry* entry);
-#endif
-
-#ifndef GDK_KEY_Return
- #define GDK_KEY_0 GDK_0
- #define GDK_KEY_BackSpace GDK_BackSpace
- #define GDK_KEY_space GDK_space
- #define GDK_KEY_F5 GDK_F5
- #define GDK_KEY_KP_Equal GDK_KP_Equal
- #define GDK_KEY_KP_Enter GDK_KP_Enter
- #define GDK_KEY_KP_Left GDK_KP_Left
- #define GDK_KEY_KP_Right GDK_KP_Right
- #define GDK_KEY_KP_Delete GDK_KP_Delete
- #define GDK_KEY_KP_Down GDK_KP_Down
- #define GDK_KEY_KP_Up GDK_KP_Up
- #define GDK_KEY_KP_Divide GDK_KP_Divide
- #define GDK_KEY_Tab GDK_Tab
- #define GDK_KEY_ISO_Left_Tab GDK_ISO_Left_Tab
- #define GDK_KEY_equal GDK_equal
- #define GDK_KEY_ISO_Enter GDK_ISO_Enter
- #define GDK_KEY_Left GDK_Left
- #define GDK_KEY_Right GDK_Right
- #define GDK_KEY_Escape GDK_Escape
- #define GDK_KEY_Page_Up GDK_Page_Up
- #define GDK_KEY_Page_Down GDK_Page_Down
- #define GDK_KEY_Delete GDK_Delete
- #define GDK_KEY_Down GDK_Down
- #define GDK_KEY_Up GDK_Up
- #define GDK_KEY_B GDK_B
- #define GDK_KEY_H GDK_H
- #define GDK_KEY_J GDK_J
- #define GDK_KEY_Return GDK_Return
-#endif
-
-#ifdef GDK_WINDOWING_X11
- #include <gdk/gdkx.h>
- #ifndef GDK_IS_X11_DISPLAY
- #define GDK_IS_X11_DISPLAY(display) TRUE
- #endif
-#endif
-
-G_END_DECLS
-
-#endif
diff --git a/katze/katze-array.c b/katze/katze-array.c
deleted file mode 100644
index 5fd98008..00000000
--- a/katze/katze-array.c
+++ /dev/null
@@ -1,580 +0,0 @@
-/*
- Copyright (C) 2008-2011 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.
-*/
-
-#include "katze-array.h"
-
-#include "katze-utils.h"
-#include "marshal.h"
-
-#include <glib/gi18n.h>
-#include <string.h>
-
-/**
- * SECTION:katze-array
- * @short_description: A type aware item container
- * @see_also: #KatzeList
- *
- * #KatzeArray is a type aware container for items.
- */
-
-G_DEFINE_TYPE (KatzeArray, katze_array, KATZE_TYPE_ITEM);
-
-struct _KatzeArrayPrivate
-{
- GType type;
- GList* items;
-};
-
-enum
-{
- PROP_0,
-
- PROP_TYPE,
-
- N_PROPERTIES
-};
-
-enum {
- ADD_ITEM,
- REMOVE_ITEM,
- MOVE_ITEM,
- CLEAR,
- UPDATE,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-GList* kalistglobal;
-
-static void
-katze_array_finalize (GObject* object);
-
-static void
-_katze_array_update (KatzeArray* array)
-{
- g_object_set_data (G_OBJECT (array), "last-update",
- GINT_TO_POINTER (time (NULL)));
- if (!g_strcmp0 (g_getenv ("MIDORI_DEBUG"), "bookmarks") && KATZE_IS_ITEM (array))
- {
- const gchar *name = katze_item_get_name (KATZE_ITEM (array));
- if (name && *name)
- {
- g_print ("_katze_array_update: %s\n", name);
- }
- }
-}
-
-static void
-_katze_array_add_item (KatzeArray* array,
- gpointer item)
-{
- GType type = G_OBJECT_TYPE (item);
- g_object_ref (item);
- if (g_type_is_a (type, KATZE_TYPE_ITEM))
- katze_item_set_parent (item, array);
-
- array->priv->items = g_list_append (array->priv->items, item);
- _katze_array_update (array);
-}
-
-static void
-_katze_array_remove_item (KatzeArray* array,
- gpointer item)
-{
- array->priv->items = g_list_remove (array->priv->items, item);
-
- if (KATZE_IS_ITEM (item))
- katze_item_set_parent (item, NULL);
- g_object_unref (item);
- _katze_array_update (array);
-}
-
-static void
-_katze_array_move_item (KatzeArray* array,
- gpointer item,
- gint position)
-{
- array->priv->items = g_list_remove (array->priv->items, item);
- array->priv->items = g_list_insert (array->priv->items, item, position);
- _katze_array_update (array);
-}
-
-static void
-_katze_array_clear (KatzeArray* array)
-{
- GObject* item;
-
- while ((item = g_list_nth_data (array->priv->items, 0)))
- g_signal_emit (array, signals[REMOVE_ITEM], 0, item);
- g_list_free (array->priv->items);
- array->priv->items = NULL;
- _katze_array_update (array);
-}
-
-static void
-_katze_array_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- KatzeArray *array = KATZE_ARRAY (object);
-
- switch (property_id)
- {
- case PROP_TYPE:
- array->priv->type = g_value_get_gtype (value);
- break;
-
- default:
- /* We don't have any other property... */
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-katze_array_class_init (KatzeArrayClass* class)
-{
- GObjectClass* gobject_class;
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = katze_array_finalize;
-
- signals[ADD_ITEM] = g_signal_new (
- "add-item",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- G_STRUCT_OFFSET (KatzeArrayClass, add_item),
- 0,
- NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
-
- signals[REMOVE_ITEM] = g_signal_new (
- "remove-item",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- G_STRUCT_OFFSET (KatzeArrayClass, remove_item),
- 0,
- NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
-
- /**
- * KatzeArray::move-item:
- * @array: the object on which the signal is emitted
- * @item: the item being moved
- * @position: the new position of the item
- *
- * An item is moved to a new position.
- *
- * Since: 0.1.6
- **/
- signals[MOVE_ITEM] = g_signal_new (
- "move-item",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- G_STRUCT_OFFSET (KatzeArrayClass, move_item),
- 0,
- NULL,
- midori_cclosure_marshal_VOID__POINTER_INT,
- G_TYPE_NONE, 2,
- G_TYPE_POINTER,
- G_TYPE_INT);
-
- signals[CLEAR] = g_signal_new (
- "clear",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- G_STRUCT_OFFSET (KatzeArrayClass, clear),
- 0,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /**
- * KatzeArray::update:
- * @array: the object on which the signal is emitted
- *
- * The array changed and any display widgets should
- * be updated.
- *
- * Since: 0.3.0
- **/
- signals[UPDATE] = g_signal_new (
- "update",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- G_STRUCT_OFFSET (KatzeArrayClass, update),
- 0,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = katze_array_finalize;
- gobject_class->set_property = _katze_array_set_property;
-
- class->add_item = _katze_array_add_item;
- class->remove_item = _katze_array_remove_item;
- class->move_item = _katze_array_move_item;
- class->clear = _katze_array_clear;
- class->update = _katze_array_update;
-
-
- g_object_class_install_property (gobject_class,
- PROP_TYPE,
- g_param_spec_gtype (
- "type",
- "Type",
- "The array item type",
- G_TYPE_NONE,
- G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
-
- g_type_class_add_private (class, sizeof (KatzeArrayPrivate));
-}
-
-static void
-katze_array_init (KatzeArray* array)
-{
- array->priv = G_TYPE_INSTANCE_GET_PRIVATE (array,
- KATZE_TYPE_ARRAY, KatzeArrayPrivate);
-
- array->priv->type = G_TYPE_OBJECT;
- array->priv->items = NULL;
-}
-
-static void
-katze_array_finalize (GObject* object)
-{
- KatzeArray* array = KATZE_ARRAY (object);
- GList* items;
-
- for (items = array->priv->items; items; items = g_list_next (items))
- g_object_unref (items->data);
- g_list_free (array->priv->items);
-
- G_OBJECT_CLASS (katze_array_parent_class)->finalize (object);
-}
-
-/**
- * katze_array_new:
- * @type: the expected item type
- *
- * Creates a new #KatzeArray for @type items.
- *
- * The array will keep a reference on each object until
- * it is removed from the array.
- *
- * Return value: (transfer full): a new #KatzeArray
- **/
-KatzeArray*
-katze_array_new (GType type)
-{
- KatzeArray* array;
-
- g_return_val_if_fail (g_type_is_a (type, G_TYPE_OBJECT), NULL);
-
- array = g_object_new (KATZE_TYPE_ARRAY, "type", type, NULL);
-
- return array;
-}
-
-/**
- * katze_array_is_a:
- * @array: a #KatzeArray
- * @is_a_type: type to compare with
- *
- * Checks whether the array is compatible
- * with items of the specified type.
- *
- * Return value: %TRUE if @array is compatible with @is_a_type
- **/
-gboolean
-katze_array_is_a (KatzeArray* array,
- GType is_a_type)
-{
- g_return_val_if_fail (KATZE_IS_ARRAY (array), FALSE);
-
- return g_type_is_a (array->priv->type, is_a_type);
-}
-
-/**
- * katze_array_add_item:
- * @array: a #KatzeArray
- * @item: (type GObject) (transfer none): an item
- *
- * Adds an item to the array.
- *
- * If @item is a #KatzeItem its parent is set accordingly.
- **/
-void
-katze_array_add_item (KatzeArray* array,
- gpointer item)
-{
- g_return_if_fail (KATZE_IS_ARRAY (array));
-
- g_signal_emit (array, signals[ADD_ITEM], 0, item);
-}
-
-/**
- * katze_array_remove_item:
- * @array: a #KatzeArray
- * @item: (type GObject): an item
- *
- * Removes an item from the array.
- *
- * If @item is a #KatzeItem its parent is unset accordingly.
- **/
-void
-katze_array_remove_item (KatzeArray* array,
- gpointer item)
-{
- g_return_if_fail (KATZE_IS_ARRAY (array));
-
- g_signal_emit (array, signals[REMOVE_ITEM], 0, item);
-}
-
-/**
- * katze_array_get_nth_item:
- * @array: a #KatzeArray
- * @n: an index in the array
- *
- * Retrieves the item in @array at the position @n.
- *
- * Return value: (type GObject) (transfer none): an item, or %NULL
- **/
-gpointer
-katze_array_get_nth_item (KatzeArray* array,
- guint n)
-{
- g_return_val_if_fail (KATZE_IS_ARRAY (array), NULL);
-
- return g_list_nth_data (array->priv->items, n);
-}
-
-/**
- * katze_array_is_empty:
- * @array: a #KatzeArray
- *
- * Determines whether @array is empty.
- *
- * Return value: %TRUE if the array is empty
- **/
-gboolean
-katze_array_is_empty (KatzeArray* array)
-{
- g_return_val_if_fail (KATZE_IS_ARRAY (array), TRUE);
-
- return !g_list_nth_data (array->priv->items, 0);
-}
-
-/**
- * katze_array_get_item_index:
- * @array: a #KatzeArray
- * @item: (type GObject): an item in the array
- *
- * Retrieves the index of the item in @array.
- *
- * Return value: the index of the item, or -1 if the item is not
- * present in the array
- **/
-gint
-katze_array_get_item_index (KatzeArray* array,
- gpointer item)
-{
- g_return_val_if_fail (KATZE_IS_ARRAY (array), -1);
-
- return g_list_index (array->priv->items, item);
-}
-
-/**
- * katze_array_find_token:
- * @array: a #KatzeArray
- * @token: a token string, or "token keywords" string
- *
- * Looks up an item in the array which has the specified token.
- *
- * This function will fail and return NULL if the #KatzeArray's
- * element type is not based on #KatzeItem.
- *
- * Note that @token is by definition unique to one item.
- *
- * Since 0.4.4 @token can be a "token keywords" string.
- *
- * Return value: (type GObject) (transfer none): an item, or %NULL
- **/
-gpointer
-katze_array_find_token (KatzeArray* array,
- const gchar* token)
-{
- size_t token_length;
- GList* items;
-
- g_return_val_if_fail (KATZE_IS_ARRAY (array), NULL);
- g_return_val_if_fail (katze_array_is_a (array, KATZE_TYPE_ITEM), NULL);
- g_return_val_if_fail (token != NULL, NULL);
-
- token_length = strchr (token, ' ') - token;
- if (token_length < 1)
- token_length = strlen (token);
-
- for (items = array->priv->items; items; items = g_list_next (items))
- {
- const gchar* found_token = ((KatzeItem*)items->data)->token;
- if (found_token != NULL)
- {
- guint bigger_item = strlen (found_token) > token_length ? strlen (found_token) : token_length;
-
- if (strncmp (token, found_token, bigger_item) == 0)
- return items->data;
- }
- }
- return NULL;
-}
-
-/**
- * katze_array_find_uri:
- * @array: a #KatzeArray
- * @uri: an URI
- *
- * Looks up an item in the array which has the specified URI.
- *
- * This function will fail and return NULL if the #KatzeArray's
- * element type is not based on #KatzeItem.
- *
- * Return value: (type GObject) (transfer none): an item, or %NULL
- *
- * Since: 0.2.0
- **/
-gpointer
-katze_array_find_uri (KatzeArray* array,
- const gchar* uri)
-{
- GList* items;
-
- g_return_val_if_fail (KATZE_IS_ARRAY (array), NULL);
- g_return_val_if_fail (katze_array_is_a (array, KATZE_TYPE_ITEM), NULL);
- g_return_val_if_fail (uri != NULL, NULL);
-
- for (items = array->priv->items; items; items = g_list_next (items))
- {
- const gchar* found_uri = ((KatzeItem*)items->data)->uri;
- if (found_uri != NULL && !strcmp (found_uri, uri))
- return items->data;
- }
- return NULL;
-}
-
-/**
- * katze_array_get_length:
- * @array: a #KatzeArray
- *
- * Retrieves the number of items in @array.
- *
- * Return value: the length of the #KatzeArray
- **/
-guint
-katze_array_get_length (KatzeArray* array)
-{
- g_return_val_if_fail (KATZE_IS_ARRAY (array), 0);
-
- return g_list_length (array->priv->items);
-}
-
-/**
- * katze_array_move_item:
- * @array: a #KatzeArray
- * @item: (type GObject): the item being moved
- * @position: the new position of the item
- *
- * Moves @item to the position @position.
- *
- * Since: 0.1.6
- **/
-void
-katze_array_move_item (KatzeArray* array,
- gpointer item,
- gint position)
-{
- g_return_if_fail (KATZE_IS_ARRAY (array));
-
- g_signal_emit (array, signals[MOVE_ITEM], 0, item, position);
-}
-
-/**
- * katze_array_get_items:
- * @array: a #KatzeArray
- *
- * Retrieves the items as a list.
- *
- * Return value: (element-type GObject) (transfer container): a newly allocated #GList of items
- *
- * Since: 0.2.5
- **/
-GList*
-katze_array_get_items (KatzeArray* array)
-{
- g_return_val_if_fail (KATZE_IS_ARRAY (array), NULL);
-
- return g_list_copy (array->priv->items);
-}
-
-/**
- * katze_array_peek_items:
- * @array: a #KatzeArray
- *
- * Peeks at the KatzeArray's internal list of items.
- *
- * Return value: (element-type GObject) (transfer none): the #KatzeArray's internal #GList of items
- **/
-GList*
-katze_array_peek_items (KatzeArray* array)
-{
- g_return_val_if_fail (KATZE_IS_ARRAY (array), NULL);
-
- return array->priv->items;
-}
-
-/**
- * katze_array_clear:
- * @array: a #KatzeArray
- *
- * Deletes all items currently contained in @array.
- **/
-void
-katze_array_clear (KatzeArray* array)
-{
- g_return_if_fail (KATZE_IS_ARRAY (array));
-
- g_signal_emit (array, signals[CLEAR], 0);
-}
-
-/**
- * katze_array_update:
- * @array: a #KatzeArray
- *
- * Indicates that the array changed and any display
- * widgets should be updated.
- *
- * Since: 0.3.0
- **/
-void
-katze_array_update (KatzeArray* array)
-{
- g_return_if_fail (KATZE_IS_ARRAY (array));
-
- g_signal_emit (array, signals[UPDATE], 0);
-}
diff --git a/katze/katze-array.h b/katze/katze-array.h
deleted file mode 100644
index ccc3ca06..00000000
--- a/katze/katze-array.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- Copyright (C) 2008-2009 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_ARRAY_H__
-#define __KATZE_ARRAY_H__
-
-#include <katze/katze-item.h>
-
-G_BEGIN_DECLS
-
-#define KATZE_TYPE_ARRAY \
- (katze_array_get_type ())
-#define KATZE_ARRAY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_ARRAY, KatzeArray))
-#define KATZE_ARRAY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_ARRAY, KatzeArrayClass))
-#define KATZE_IS_ARRAY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_ARRAY))
-#define KATZE_IS_ARRAY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_ARRAY))
-#define KATZE_ARRAY_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_ARRAY, KatzeArrayClass))
-
-typedef struct _KatzeArray KatzeArray;
-typedef struct _KatzeArrayClass KatzeArrayClass;
-typedef struct _KatzeArrayPrivate KatzeArrayPrivate;
-
-struct _KatzeArray
-{
- KatzeItem parent_instance;
-
- KatzeArrayPrivate* priv;
-};
-
-struct _KatzeArrayClass
-{
- KatzeItemClass parent_class;
-
- /* Signals */
- void
- (*add_item) (KatzeArray* array,
- gpointer item);
- void
- (*remove_item) (KatzeArray* array,
- gpointer item);
- void
- (*move_item) (KatzeArray* array,
- gpointer item,
- gint index);
- void
- (*clear) (KatzeArray* array);
-
- void
- (*update) (KatzeArray* array);
-};
-
-GType
-katze_array_get_type (void) G_GNUC_CONST;
-
-KatzeArray*
-katze_array_new (GType type);
-
-gboolean
-katze_array_is_a (KatzeArray* array,
- GType is_a_type);
-
-void
-katze_array_add_item (KatzeArray* array,
- gpointer item);
-
-void
-katze_array_remove_item (KatzeArray* array,
- gpointer item);
-
-gpointer
-katze_array_get_nth_item (KatzeArray* array,
- guint n);
-
-gboolean
-katze_array_is_empty (KatzeArray* array);
-
-gint
-katze_array_get_item_index (KatzeArray* array,
- gpointer item);
-
-gpointer
-katze_array_find_token (KatzeArray* array,
- const gchar* token);
-
-gpointer
-katze_array_find_uri (KatzeArray* array,
- const gchar* uri);
-
-guint
-katze_array_get_length (KatzeArray* array);
-
-void
-katze_array_move_item (KatzeArray* array,
- gpointer item,
- gint position);
-
-GList*
-katze_array_get_items (KatzeArray* array);
-
-GList*
-katze_array_peek_items (KatzeArray* array);
-
-extern GList* kalistglobal;
-/* KATZE_ARRAY_FOREACH_ITEM:
- * @item: a #KatzeItem variable
- * @array: a #KatzeArray to loop through
- *
- * Loops through all items of the array. The macro can
- * be used like a for() loop.
- * If the array is modified during the loop, you must
- * use KATZE_ARRAY_FOREACH_ITEM_L instead.
- * */
-#define KATZE_ARRAY_FOREACH_ITEM(kaitem, kaarray) \
- for (kalistglobal = katze_array_peek_items (kaarray), \
- kaitem = kalistglobal ? kalistglobal->data : NULL; \
- kalistglobal != NULL; \
- kalistglobal = g_list_next (kalistglobal), \
- kaitem = kalistglobal ? kalistglobal->data : NULL)
-
-/* KATZE_ARRAY_FOREACH_ITEM_L:
- * @item: a #KatzeItem variable
- * @array: a #KatzeArray to loop through
- * @list: a #GList variable
- *
- * Loops through all items of the array. The list must be freed.
- *
- * Since: 0.3.0
- * */
-#define KATZE_ARRAY_FOREACH_ITEM_L(kaitem, kaarray, kalist) \
- for (kalist = katze_array_get_items (kaarray), \
- kaitem = kalist ? kalist->data : NULL; \
- kalist != NULL; \
- kalist = g_list_next (kalist), \
- kaitem = kalist ? kalist->data : NULL)
-
-void
-katze_array_clear (KatzeArray* array);
-
-void
-katze_array_update (KatzeArray* array);
-
-G_END_DECLS
-
-#endif /* __KATZE_ARRAY_H__ */
diff --git a/katze/katze-arrayaction.c b/katze/katze-arrayaction.c
deleted file mode 100644
index 50461477..00000000
--- a/katze/katze-arrayaction.c
+++ /dev/null
@@ -1,928 +0,0 @@
-/*
- Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2009 Enrico Tröger <enrico.troeger@uvena.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.
-*/
-
-#include "katze-arrayaction.h"
-
-#include "midori/midori-platform.h"
-#include "katze-utils.h"
-#include "marshal.h"
-
-#include <string.h>
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-
-#if HAVE_CONFIG_H
- #include "config.h"
-#endif
-
-struct _KatzeArrayAction
-{
- GtkAction parent_instance;
-
- KatzeArray* array;
- gboolean reversed;
-};
-
-struct _KatzeArrayActionClass
-{
- GtkActionClass parent_class;
-};
-
-G_DEFINE_TYPE (KatzeArrayAction, katze_array_action, GTK_TYPE_ACTION);
-
-enum
-{
- PROP_0,
-
- PROP_ARRAY,
- PROP_REVERSED
-};
-
-enum
-{
- POPULATE_POPUP,
- POPULATE_FOLDER,
- ACTIVATE_ITEM,
- ACTIVATE_ITEM_NEW_TAB,
- ACTIVATE_ITEM_ALT,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-katze_array_action_finalize (GObject* object);
-
-static void
-katze_array_action_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-katze_array_action_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-static void
-katze_array_action_activate (GtkAction* object);
-
-static GtkWidget*
-katze_array_action_create_tool_item (GtkAction* action);
-
-static GtkWidget*
-katze_array_action_create_menu_item (GtkAction* action);
-
-static void
-katze_array_action_connect_proxy (GtkAction* action,
- GtkWidget* proxy);
-
-static void
-katze_array_action_disconnect_proxy (GtkAction* action,
- GtkWidget* proxy);
-
-static void
-katze_array_action_proxy_clicked_cb (GtkWidget* proxy,
- KatzeArrayAction* array_action);
-
-static void
-katze_array_action_class_init (KatzeArrayActionClass* class)
-{
- GObjectClass* gobject_class;
- GtkActionClass* action_class;
-
- signals[POPULATE_POPUP] = g_signal_new ("populate-popup",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags) (G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- GTK_TYPE_MENU);
-
- /**
- * KatzeArrayAction::populate-folder:
- * @array: the object on which the signal is emitted
- * @menu: the menu shell being opened
- * @folder: the folder being opened
- *
- * A submenu is going to be opened for @folder,
- * the provided @menu can be populated accordingly.
- *
- * Unlike "populate-popup" this signal is emitted for
- * the toplevel folder and all subfolders.
- *
- * Return value: %TRUE if the event was handled. If %FALSE is returned,
- * the default "populate-popup" signal is emitted.
- *
- * Since: 0.2.8
- **/
-
- signals[POPULATE_FOLDER] = g_signal_new ("populate-folder",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags) (G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- midori_cclosure_marshal_BOOLEAN__OBJECT_OBJECT,
- G_TYPE_BOOLEAN, 2,
- GTK_TYPE_MENU_SHELL, KATZE_TYPE_ITEM);
-
- /**
- * KatzeArrayAction::activate-item:
- * @array: the object on which the signal is emitted
- * @item: the item being activated
- * @event: (allow-none): the event that caused the activation
- *
- * An item was activated.
- **/
- signals[ACTIVATE_ITEM] = g_signal_new ("activate-item",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags) (G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- KATZE_TYPE_ITEM);
-
- /**
- * KatzeArrayAction::activate-item-new-tab:
- * @array: the object on which the signal is emitted
- * @item: the item being activated
- * @event: (allow-none): the event that caused the activation
- *
- * An item was activated and should be opened in a new tab.
- *
- * Since: 0.5.10
- **/
- signals[ACTIVATE_ITEM_NEW_TAB] = g_signal_new ("activate-item-new-tab",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags) (G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- KATZE_TYPE_ITEM);
-
- /**
- * KatzeArrayAction::activate-item-alt:
- * @array: the object on which the signal is emitted
- * @proxy: the %GtkWidget that caught the event
- * @item: the item being activated
- * @event: the mouse button pressed event
- *
- * The specified @button has been pressed (but not yet released) on the item.
- *
- * Return value: %TRUE if the event was handled.
- **/
- signals[ACTIVATE_ITEM_ALT] = g_signal_new ("activate-item-alt",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags) (G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- midori_cclosure_marshal_BOOLEAN__OBJECT_OBJECT_POINTER,
- G_TYPE_BOOLEAN, 3,
- KATZE_TYPE_ITEM, GTK_TYPE_WIDGET, G_TYPE_POINTER);
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = katze_array_action_finalize;
- gobject_class->set_property = katze_array_action_set_property;
- gobject_class->get_property = katze_array_action_get_property;
-
- action_class = GTK_ACTION_CLASS (class);
- action_class->activate = katze_array_action_activate;
- action_class->create_menu_item = katze_array_action_create_menu_item;
- action_class->create_tool_item = katze_array_action_create_tool_item;
- action_class->connect_proxy = katze_array_action_connect_proxy;
- action_class->disconnect_proxy = katze_array_action_disconnect_proxy;
-
- g_object_class_install_property (gobject_class,
- PROP_ARRAY,
- g_param_spec_object (
- "array",
- "Array",
- "The array the action represents",
- KATZE_TYPE_ARRAY,
- G_PARAM_READWRITE));
-
- /**
- * KatzeArrayAction:reversed:
- *
- * Whether the array should be walked backwards when building menus.
- *
- * Since: 0.2.2
- **/
- g_object_class_install_property (gobject_class,
- PROP_REVERSED,
- g_param_spec_boolean (
- "reversed",
- "Reversed",
- "Whether the array should be walked backwards when building menus",
- FALSE,
- G_PARAM_READWRITE));
-}
-
-static void
-katze_array_action_init (KatzeArrayAction* array_action)
-{
- array_action->array = NULL;
- array_action->reversed = FALSE;
-}
-
-static void
-katze_array_action_finalize (GObject* object)
-{
- KatzeArrayAction* array_action = KATZE_ARRAY_ACTION (object);
-
- katze_object_assign (array_action->array, NULL);
-
- G_OBJECT_CLASS (katze_array_action_parent_class)->finalize (object);
-}
-
-static void
-katze_array_action_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- KatzeArrayAction* array_action = KATZE_ARRAY_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_ARRAY:
- katze_array_action_set_array (array_action, g_value_get_object (value));
- break;
- case PROP_REVERSED:
- array_action->reversed = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-katze_array_action_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- KatzeArrayAction* array_action = KATZE_ARRAY_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_ARRAY:
- g_value_set_object (value, array_action->array);
- break;
- case PROP_REVERSED:
- g_value_set_boolean (value, array_action->reversed);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-katze_array_action_activate (GtkAction* action)
-{
- if (GTK_ACTION_CLASS (katze_array_action_parent_class)->activate)
- GTK_ACTION_CLASS (katze_array_action_parent_class)->activate (action);
-}
-
-static void
-katze_array_action_activate_item (KatzeArrayAction* action,
- KatzeItem* item)
-{
- g_signal_emit (action, signals[ACTIVATE_ITEM], 0, item);
-}
-
-static void
-katze_array_action_activate_item_new_tab (KatzeArrayAction* action,
- KatzeItem* item)
-{
- g_signal_emit (action, signals[ACTIVATE_ITEM_NEW_TAB], 0, item);
-}
-
-static gboolean
-katze_array_action_activate_item_alt (KatzeArrayAction* action,
- KatzeItem* item,
- GdkEventButton* event,
- GtkWidget* proxy)
-{
- /* katze_array_action_activate_item emits the signal.
- * It can result from "clicked" event where the button event
- * is not provided.
- */
-
- gboolean handled = FALSE;
-
- g_assert (event);
-
- g_signal_emit (action, signals[ACTIVATE_ITEM_ALT], 0, item,
- proxy, event, &handled);
-
- return handled;
-}
-
-static void
-katze_array_action_menu_activate_cb (GtkWidget* proxy,
- KatzeArrayAction* array_action)
-{
- KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
-
- GdkEvent* event = gtk_get_current_event();
-
- if (event && MIDORI_EVENT_NEW_TAB (event))
- katze_array_action_activate_item_new_tab (array_action, item);
- else
- katze_array_action_activate_item (array_action, item);
-
- if (event)
- gdk_event_free (event);
-}
-
-static gboolean
-katze_array_action_menu_item_button_press_cb (GtkWidget* proxy,
- GdkEventButton* event,
- KatzeArrayAction* array_action)
-{
- KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
-
- return katze_array_action_activate_item_alt (array_action, item, event, proxy);
-}
-
-static gboolean
-katze_array_action_menu_button_press_cb (GtkWidget* proxy,
- GdkEventButton* event,
- KatzeArrayAction* array_action)
-{
- /* Override the button-press handler for menus which would
- open a submenu to instead show a popup menu
- */
-
- return katze_array_action_menu_item_button_press_cb (gtk_get_event_widget ((GdkEvent *) event), event, array_action);
-}
-
-static gboolean
-katze_array_action_tool_item_child_button_press_cb (GtkWidget* proxy,
- GdkEventButton* event,
- KatzeArrayAction* array_action)
-{
- GtkWidget* toolitem = gtk_widget_get_parent (proxy);
- KatzeItem* item = g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
-
- /* Left button clicks (e.g. for activation) should not be handled until button release */
- if (event->button == 1)
- return FALSE;
-
- return katze_array_action_activate_item_alt (array_action, item, event, proxy);
-}
-
-/* GtkToolItem does not emit the "clicked" event for middle-clicks, so handle them (but not
- regular or ctrl-clicks) manually via the button-release-event signal. */
-static gboolean
-katze_array_action_tool_item_child_button_release_cb (GtkWidget* proxy,
- GdkEventButton* event,
- KatzeArrayAction* array_action)
-{
- GtkWidget* toolitem = gtk_widget_get_parent (proxy);
- KatzeItem* item = g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
-
- /* We only need to handle middle-clicks here, since proper handling for
- * ctrl-clicks, right-clicks, and left-clicks has been done elsewhere. */
- if (event && MIDORI_EVENT_NEW_TAB (event))
- {
- katze_array_action_activate_item_new_tab (array_action, item);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-katze_array_action_menu_item_select_cb (GtkWidget* proxy,
- KatzeArrayAction* array_action);
-
-static GtkWidget*
-katze_array_action_menu_item_new (KatzeArrayAction* array_action,
- KatzeItem* item)
-{
- GtkWidget* menuitem = katze_image_menu_item_new_ellipsized (
- katze_item_get_name (item));
- GtkWidget* image = katze_item_get_image (item, menuitem);
-
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
- gtk_image_menu_item_set_always_show_image (
- GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
-
- g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
-
- if (KATZE_ITEM_IS_FOLDER (item))
- {
- GtkWidget* submenu = gtk_menu_new ();
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
- /* Handle popup menus on menuitems which have open submenus */
- g_signal_connect (submenu, "button-press-event",
- G_CALLBACK (katze_array_action_menu_button_press_cb), array_action);
- g_signal_connect (menuitem, "select",
- G_CALLBACK (katze_array_action_menu_item_select_cb), array_action);
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (katze_array_action_menu_item_select_cb), array_action);
- }
- else
- {
- /* We need the 'activate' signal for actual item activation */
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (katze_array_action_menu_activate_cb), array_action);
- }
-
- /* Connect to button-press-event to catch right-clicks to open popup menus.
- Note that this is also necessary for menuitems which have submenus
- but whose submenus are not open at present! */
- g_signal_connect (menuitem, "button-press-event",
- G_CALLBACK (katze_array_action_menu_item_button_press_cb), array_action);
-
- return menuitem;
-}
-
-/**
- * katze_array_action_generate_menu:
- * @array_action: a #KatzeArrayAction
- * @folder: the folder to represent
- * @menu: the menu shell to populate
- * @proxy: the proxy, or alternatively a widget in the same window
- *
- * Generates menu items according to @folder, in the way they
- * appear in automatically generated action proxies.
- * The primary use is for implementing "populate-folder".
- *
- * It is worth noting that @folder can be any folder and can
- * be generated dynamically if needed.
- *
- * The @proxy widget must be a related widget on the same screen,
- * but doesn't have to be a proxy of the action.
- *
- * Since: 0.2.8
- **/
-void
-katze_array_action_generate_menu (KatzeArrayAction* array_action,
- KatzeArray* array,
- GtkMenuShell* menu,
- GtkWidget* proxy)
-{
- gint i;
- gint summand;
- KatzeItem* item;
- GtkWidget* menuitem;
-
- g_return_if_fail (KATZE_IS_ARRAY_ACTION (array_action));
- g_return_if_fail (KATZE_IS_ITEM (array));
- g_return_if_fail (GTK_IS_MENU_SHELL (menu));
- g_return_if_fail (GTK_IS_TOOL_ITEM (proxy)
- || GTK_IS_MENU_ITEM (proxy)
- || GTK_IS_WINDOW (proxy));
-
- if (!KATZE_IS_ARRAY (array))
- return;
-
- if (array_action->reversed)
- {
- i = katze_array_get_length (array);
- summand = -1;
- }
- else
- {
- i = -1;
- summand = +1;
- }
- while ((item = katze_array_get_nth_item (array, i += summand)))
- {
- /* FIXME: The menu item should reflect changes to the item */
- if (KATZE_ITEM_IS_SEPARATOR (item))
- {
- menuitem = gtk_separator_menu_item_new ();
- gtk_widget_show (menuitem);
- gtk_menu_shell_append (menu, menuitem);
- continue;
- }
-
- menuitem = katze_array_action_menu_item_new (array_action, item);
-
- if (KATZE_ITEM_IS_FOLDER (item))
- {
- GtkWidget* submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menuitem));
- /* Make sure menu appears to contain items */
- gtk_menu_shell_append (GTK_MENU_SHELL (submenu),
- gtk_separator_menu_item_new ());
- }
-
- gtk_widget_show (menuitem);
- gtk_menu_shell_append (menu, menuitem);
- }
-}
-
-static gboolean
-katze_array_action_menu_item_need_update (KatzeArrayAction* array_action,
- GtkWidget* proxy)
-{
- GtkWidget* menu;
- KatzeArray* array;
- gint last_array_update, last_proxy_update;
- gboolean handled;
-
- array = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
- /* last-update is set on all arrays; consider public API */
- last_array_update = GPOINTER_TO_INT (
- g_object_get_data (G_OBJECT (array), "last-update"));
- last_proxy_update = GPOINTER_TO_INT (
- g_object_get_data (G_OBJECT (proxy), "last-update"));
- if (last_proxy_update > last_array_update)
- return FALSE;
-
- menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy));
- gtk_container_foreach (GTK_CONTAINER (menu),
- (GtkCallback)(gtk_widget_destroy), NULL);
- katze_array_action_generate_menu (array_action, array, GTK_MENU_SHELL (menu), proxy);
- g_signal_emit (array_action, signals[POPULATE_FOLDER], 0, menu, array, &handled);
- g_object_set_data (G_OBJECT (proxy), "last-update",
- GINT_TO_POINTER (time (NULL)));
- return TRUE;
-}
-
-static void
-katze_array_action_menu_item_select_cb (GtkWidget* proxy,
- KatzeArrayAction* array_action)
-{
- katze_array_action_menu_item_need_update (array_action, proxy);
-}
-
-static void
-katze_array_action_menu_deactivate_cb (GtkWidget* menu,
- GtkWidget* proxy)
-{
- void* array_action = g_object_get_data (G_OBJECT (menu), "KatzeArrayAction");
- g_signal_handlers_block_by_func (proxy,
- katze_array_action_proxy_clicked_cb, array_action);
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (proxy), FALSE);
- g_signal_handlers_unblock_by_func (proxy,
- katze_array_action_proxy_clicked_cb, array_action);
-}
-
-static void
-katze_array_action_proxy_clicked_cb (GtkWidget* proxy,
- KatzeArrayAction* array_action)
-{
- GtkWidget* menu;
- KatzeArray* array;
- gboolean handled = FALSE;
-
- array = KATZE_ARRAY (g_object_get_data (G_OBJECT (proxy), "KatzeItem"));
-
- if (GTK_IS_MENU_ITEM (proxy))
- {
- if (katze_array_action_menu_item_need_update (array_action, proxy))
- {
- g_signal_emit (array_action, signals[POPULATE_FOLDER], 0,
- gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)),
- array, &handled);
- if (!handled)
- g_signal_emit (array_action, signals[POPULATE_POPUP], 0,
- gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)));
- }
- return;
- }
-
- menu = gtk_menu_new ();
- gtk_menu_attach_to_widget (GTK_MENU (menu), proxy, NULL);
-
- if (!array)
- array = array_action->array;
- katze_array_action_generate_menu (array_action, array, GTK_MENU_SHELL (menu), proxy);
-
- g_signal_emit (array_action, signals[POPULATE_FOLDER], 0, menu, array, &handled);
- if (!handled)
- {
- /* populate-popup should only affect the main proxy */
- if (array == array_action->array)
- g_signal_emit (array_action, signals[POPULATE_POPUP], 0, menu);
- }
-
- katze_widget_popup (GTK_WIDGET (proxy), GTK_MENU (menu),
- NULL, KATZE_MENU_POSITION_LEFT);
- gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), TRUE);
- g_object_set_data (G_OBJECT (menu), "KatzeArrayAction", array_action);
- g_signal_connect (menu, "deactivate",
- G_CALLBACK (katze_array_action_menu_deactivate_cb), proxy);
-}
-
-static GtkWidget*
-katze_array_action_create_menu_item (GtkAction* action)
-{
- GtkWidget* menuitem;
-
- menuitem = gtk_menu_item_new ();
- return menuitem;
-}
-
-static GtkWidget*
-katze_array_action_create_tool_item (GtkAction* action)
-{
- GtkWidget* toolitem;
-
- toolitem = GTK_WIDGET (gtk_toggle_tool_button_new ());
- return toolitem;
-}
-
-static void
-katze_array_action_label_notify_cb (GtkToolButton* item,
- GParamSpec* pspec,
- GtkLabel* label)
-{
- const gchar* property;
- const gchar* text;
-
- if (!G_IS_PARAM_SPEC_STRING (pspec))
- return;
-
- property = g_param_spec_get_name (pspec);
- if (!strcmp (property, "label"))
- {
- text = gtk_tool_button_get_label (item);
- gtk_label_set_text (label, text);
- }
-}
-
-static void
-katze_array_action_item_notify_cb (KatzeItem* item,
- GParamSpec* pspec,
- GtkToolItem* toolitem)
-{
- const gchar* property;
- const gchar* title;
- const gchar* desc;
- GtkWidget* image;
-
- if (!G_IS_PARAM_SPEC_STRING (pspec))
- return;
-
- property = g_param_spec_get_name (pspec);
- if (!strcmp (property, "name"))
- {
- title = katze_item_get_name (item);
- if (title)
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), title);
- else
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem),
- katze_item_get_uri (item));
- }
- else if (!strcmp (property, "text"))
- {
- desc = katze_item_get_text (item);
- if (desc && *desc)
- gtk_tool_item_set_tooltip_text (toolitem, desc);
- else
- gtk_tool_item_set_tooltip_text (toolitem,
- katze_item_get_uri (item));
- }
- else if (KATZE_ITEM_IS_BOOKMARK (item) && !strcmp (property, "uri"))
- {
- image = katze_item_get_image (item, GTK_WIDGET (toolitem));
- gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (toolitem), image);
- }
- else if (!strcmp (property, "icon"))
- {
- image = katze_item_get_image (item, GTK_WIDGET (toolitem));
- gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (toolitem), image);
- }
-}
-
-static gboolean
-katze_array_action_proxy_create_menu_proxy_cb (GtkWidget* proxy,
- KatzeItem* item)
-{
- KatzeArrayAction* array_action;
- GtkWidget* menuitem;
-
- array_action = g_object_get_data (G_OBJECT (proxy), "KatzeArrayAction");
- menuitem = katze_array_action_menu_item_new (array_action, item);
- gtk_tool_item_set_proxy_menu_item (GTK_TOOL_ITEM (proxy),
- "katze-tool-item-menu", menuitem);
- return TRUE;
-}
-
-static void
-katze_array_action_toolitem_destroy_cb (GtkToolItem* toolitem,
- KatzeItem* item)
-{
- g_signal_handlers_disconnect_by_func (item,
- G_CALLBACK (katze_array_action_item_notify_cb), toolitem);
-}
-
-/**
- * katze_array_action_create_tool_item_for:
- * @array_action: a #KatzeArrayAction
- * @item: a #KatzeItem
- *
- * Creates a tool item for a particular @item, that also
- * reflects changes to its properties. In the case of
- * an array, the item will create a popup menu with
- * the contained items.
- *
- * Note that the label is reasonably ellipsized for you,
- * much like katze_image_menu_item_new_ellipsized().
- *
- * Return value: (transfer full): a new tool item
- **/
-GtkToolItem*
-katze_array_action_create_tool_item_for (KatzeArrayAction* array_action,
- KatzeItem* item)
-{
- const gchar* title;
- const gchar* uri;
- const gchar* desc;
- GtkToolItem* toolitem;
- GtkWidget* image;
- GtkWidget* label;
-
- title = katze_item_get_name (item);
- uri = katze_item_get_uri (item);
- desc = katze_item_get_text (item);
-
- if (KATZE_ITEM_IS_SEPARATOR (item))
- return gtk_separator_tool_item_new ();
-
- if (KATZE_ITEM_IS_FOLDER (item))
- toolitem = gtk_toggle_tool_button_new ();
- else
- toolitem = gtk_tool_button_new (NULL, "");
- g_signal_connect (toolitem, "create-menu-proxy",
- G_CALLBACK (katze_array_action_proxy_create_menu_proxy_cb), item);
- image = katze_item_get_image (item, GTK_WIDGET (toolitem));
- gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (toolitem), image);
- label = gtk_label_new (NULL);
- /* FIXME: Should text direction be respected here? */
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_label_set_max_width_chars (GTK_LABEL (label), 25);
- gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_MIDDLE);
- gtk_widget_show (label);
- gtk_tool_button_set_label_widget (GTK_TOOL_BUTTON (toolitem), label);
- /* GtkToolItem won't update our custom label, so we
- apply a little bit of 'magic' to fix that. */
- g_signal_connect (toolitem, "notify",
- G_CALLBACK (katze_array_action_label_notify_cb), label);
- if (title)
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), title);
- else
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), uri);
- gtk_tool_item_set_is_important (toolitem, TRUE);
- if (desc && *desc)
- gtk_tool_item_set_tooltip_text (toolitem, desc);
- else
- gtk_tool_item_set_tooltip_text (toolitem, uri);
-
- g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item);
- if (KATZE_ITEM_IS_FOLDER (item))
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (katze_array_action_proxy_clicked_cb), array_action);
- else if (KATZE_IS_ITEM (item))
- {
- /* Connect to "button-press-event" to handle right-clicks.
- * Tool items block the "button-press-event" but we can get it
- * when connecting it to the tool item's child widget
- */
- GtkWidget* child = gtk_bin_get_child (GTK_BIN (toolitem));
- g_signal_connect (child, "button-press-event",
- G_CALLBACK (katze_array_action_tool_item_child_button_press_cb), array_action);
-
- /* Connect to the "clicked" signal to handle normal keyboard and mouse
- * activations, checking the event to see if a new tab should be
- * opened. */
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (katze_array_action_menu_activate_cb), array_action);
-
- /* Connect to the "button-released-event" signal to handle middle clicks, since
- * GtkToolButton does not emit "clicked" for middle-clicks. */
- g_signal_connect (child, "button-release-event",
- G_CALLBACK (katze_array_action_tool_item_child_button_release_cb), array_action);
- }
-
- g_object_set_data (G_OBJECT (toolitem), "KatzeArrayAction", array_action);
- g_signal_connect (item, "notify",
- G_CALLBACK (katze_array_action_item_notify_cb), toolitem);
- g_signal_connect (toolitem, "destroy",
- G_CALLBACK (katze_array_action_toolitem_destroy_cb), item);
- return toolitem;
-}
-
-static void
-katze_array_action_connect_proxy (GtkAction* action,
- GtkWidget* proxy)
-{
- KatzeArrayAction* array_action = KATZE_ARRAY_ACTION (action);
- g_object_set_data (G_OBJECT (proxy), "KatzeItem", array_action->array);
-
- GTK_ACTION_CLASS (katze_array_action_parent_class)->connect_proxy (
- action, proxy);
-
- if (GTK_IS_TOOL_ITEM (proxy))
- {
- g_signal_connect (proxy, "clicked",
- G_CALLBACK (katze_array_action_proxy_clicked_cb), action);
- }
- else if (GTK_IS_MENU_ITEM (proxy))
- {
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (proxy), gtk_menu_new ());
- g_signal_connect (proxy, "select",
- G_CALLBACK (katze_array_action_proxy_clicked_cb), action);
- g_signal_connect (proxy, "activate",
- G_CALLBACK (katze_array_action_proxy_clicked_cb), action);
- }
-}
-
-static void
-katze_array_action_disconnect_proxy (GtkAction* action,
- GtkWidget* proxy)
-{
- g_signal_handlers_disconnect_by_func (proxy,
- G_CALLBACK (katze_array_action_proxy_clicked_cb), action);
-
- GTK_ACTION_CLASS (katze_array_action_parent_class)->disconnect_proxy
- (action, proxy);
-}
-
-/**
- * katze_array_action_get_array:
- * @array_action: a #KatzeArrayAction
- *
- * Obtain the array which backs the array action.
- *
- * Return value: (transfer none): the KatzeArray used by @array_action
- **/
-KatzeArray*
-katze_array_action_get_array (KatzeArrayAction* array_action)
-{
- g_return_val_if_fail (KATZE_IS_ARRAY_ACTION (array_action), NULL);
-
- return array_action->array;
-}
-
-void
-katze_array_action_set_array (KatzeArrayAction* array_action,
- KatzeArray* array)
-{
- GSList* proxies;
- KatzeArray *old_array = NULL;
-
- g_return_if_fail (KATZE_IS_ARRAY_ACTION (array_action));
- g_return_if_fail (!array || katze_array_is_a (array, KATZE_TYPE_ITEM));
-
- /* FIXME: Disconnect old array */
-
- old_array = array_action->array;
- if (array)
- g_object_ref (array);
- katze_object_assign (array_action->array, array);
-
- /* FIXME: Add and remove items dynamically */
- /*g_object_connect (array,
- "signal-after::add-item",
- katze_array_action_engines_add_item_cb, array_action,
- "signal-after::remove-item",
- katze_array_action_engines_remove_item_cb, array_action,
- NULL);*/
-
- g_object_notify (G_OBJECT (array_action), "array");
-
- proxies = gtk_action_get_proxies (GTK_ACTION (array_action));
- if (!proxies)
- return;
-
- do
- {
- KatzeArray* item = g_object_get_data (G_OBJECT (proxies->data), "KatzeItem");
-
- if (item && (item == old_array))
- g_object_set_data (G_OBJECT (proxies->data), "KatzeItem", array);
-
- gtk_widget_set_sensitive (proxies->data, array != NULL);
- }
- while ((proxies = g_slist_next (proxies)));
-
- if (array)
- katze_array_update (KATZE_ARRAY (array));
-}
diff --git a/katze/katze-arrayaction.h b/katze/katze-arrayaction.h
deleted file mode 100644
index dc2aaa36..00000000
--- a/katze/katze-arrayaction.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- 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_ARRAY_ACTION_H__
-#define __KATZE_ARRAY_ACTION_H__
-
-#include "katze-array.h"
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define KATZE_TYPE_ARRAY_ACTION \
- (katze_array_action_get_type ())
-#define KATZE_ARRAY_ACTION(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_ARRAY_ACTION, KatzeArrayAction))
-#define KATZE_ARRAY_ACTION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_ARRAY_ACTION, KatzeArrayActionClass))
-#define KATZE_IS_ARRAY_ACTION(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_ARRAY_ACTION))
-#define KATZE_IS_ARRAY_ACTION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_ARRAY_ACTION))
-#define KATZE_ARRAY_ACTION_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_ARRAY_ACTION, KatzeArrayActionClass))
-
-typedef struct _KatzeArrayAction KatzeArrayAction;
-typedef struct _KatzeArrayActionClass KatzeArrayActionClass;
-
-GType
-katze_array_action_get_type (void) G_GNUC_CONST;
-
-KatzeArray*
-katze_array_action_get_array (KatzeArrayAction* array_action);
-
-void
-katze_array_action_set_array (KatzeArrayAction* array_action,
- KatzeArray* array);
-
-GtkToolItem*
-katze_array_action_create_tool_item_for (KatzeArrayAction* array_action,
- KatzeItem* item);
-
-void
-katze_array_action_generate_menu (KatzeArrayAction* array_action,
- KatzeArray* folder,
- GtkMenuShell* menu,
- GtkWidget* proxy);
-
-G_END_DECLS
-
-#endif /* __KATZE_ARRAY_ACTION_H__ */
diff --git a/katze/katze-cellrenderercomboboxtext.c b/katze/katze-cellrenderercomboboxtext.c
deleted file mode 100644
index b867b933..00000000
--- a/katze/katze-cellrenderercomboboxtext.c
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- Copyright (C) 2008-2013 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.
-*/
-
-#include "katze-cellrenderercomboboxtext.h"
-
-#include "marshal.h"
-
-#include <string.h>
-#include <gdk/gdk.h>
-
-#define P_(String) (String)
-#define I_(String) (String)
-#define GTK_PARAM_READABLE G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
-#define GTK_PARAM_WRITABLE G_PARAM_WRITABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
-#define GTK_PARAM_READWRITE G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
-
-
-static void
-katze_cell_renderer_combobox_text_finalize (GObject* object);
-
-static void
-katze_cell_renderer_combobox_text_get_property (GObject* object,
- guint param_id,
- GValue* value,
- GParamSpec* pspec);
-static void
-katze_cell_renderer_combobox_text_set_property (GObject* object,
- guint param_id,
- const GValue* value,
- GParamSpec* pspec);
-static void
-katze_cell_renderer_combobox_text_get_size (GtkCellRenderer* cell,
- GtkWidget* widget,
-#if GTK_CHECK_VERSION(3,0,0)
- const GdkRectangle* cell_area,
-#else
- GdkRectangle* cell_area,
-#endif
- gint* x_offset,
- gint* y_offset,
- gint* width,
- gint* height);
-#if GTK_CHECK_VERSION(3,0,0)
-static void
-katze_cell_renderer_combobox_text_render (GtkCellRenderer *cell,
- cairo_t* cr,
- GtkWidget *widget,
- const GdkRectangle *background_area,
- const GdkRectangle *cell_area,
- GtkCellRendererState flags);
-#else
-static void
-katze_cell_renderer_combobox_text_render (GtkCellRenderer *cell,
- GdkDrawable *window,
- GtkWidget *widget,
- GdkRectangle *background_area,
- GdkRectangle *cell_area,
- GdkRectangle *expose_area,
- GtkCellRendererState flags);
-#endif
-
-enum {
- PROP_0,
-
- PROP_FOLDED_TEXT,
- PROP_FOLDED_MARKUP,
- PROP_FOLDED_ATTRIBUTES,
- PROP_UNFOLDED_TEXT,
- PROP_UNFOLDED_MARKUP,
- PROP_UNFOLDED_ATTRIBUTES,
-};
-
-#define KATZE_CELL_RENDERER_COMBOBOX_TEXT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KATZE_TYPE_CELL_RENDERER_COMBOBOX_TEXT, KatzeCellRendererComboBoxTextPrivate))
-
-typedef struct _KatzeCellRendererComboBoxTextPrivate KatzeCellRendererComboBoxTextPrivate;
-struct _KatzeCellRendererComboBoxTextPrivate
-{
- struct _Properties {
- PangoAttrList* extra_attrs;
-
- gchar* text;
-
- guint markup_set : 1;
- } props[2];
-};
-
-G_DEFINE_TYPE (KatzeCellRendererComboBoxText, katze_cell_renderer_combobox_text, GTK_TYPE_CELL_RENDERER_TEXT)
-
-static void
-katze_cell_renderer_combobox_text_init (KatzeCellRendererComboBoxText *celltext)
-{
- guint prop_index;
- KatzeCellRendererComboBoxTextPrivate *priv;
-
- priv = KATZE_CELL_RENDERER_COMBOBOX_TEXT_GET_PRIVATE (celltext);
-
- for (prop_index = 0 ; prop_index < 2; prop_index++)
- {
- priv->props[prop_index].text = NULL;
- priv->props[prop_index].extra_attrs = NULL;
- priv->props[prop_index].markup_set = FALSE;
- }
-}
-
-static void
-katze_cell_renderer_combobox_text_class_init (KatzeCellRendererComboBoxTextClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class);
-
- object_class->finalize = katze_cell_renderer_combobox_text_finalize;
-
- object_class->get_property = katze_cell_renderer_combobox_text_get_property;
- object_class->set_property = katze_cell_renderer_combobox_text_set_property;
-
- cell_class->get_size = katze_cell_renderer_combobox_text_get_size;
- cell_class->render = katze_cell_renderer_combobox_text_render;
-
- g_object_class_install_property (object_class,
- PROP_FOLDED_TEXT,
- g_param_spec_string ("folded-text",
- P_("Folded text"),
- P_("Text to render if combobox_text is closed. The string [text] is replaced by default text"),
- NULL,
- GTK_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_FOLDED_MARKUP,
- g_param_spec_string ("folded-markup",
- P_("Folded markup"),
- P_("Marked up text to render if combobox_text is closed. The string [text] is replaced by default text"),
- NULL,
- GTK_PARAM_WRITABLE));
-
- g_object_class_install_property (object_class,
- PROP_FOLDED_ATTRIBUTES,
- g_param_spec_boxed ("folded-attributes",
- P_("Folded attributes"),
- P_("A list of style attributes to apply to the text of the renderer if combobox_text is closed"),
- PANGO_TYPE_ATTR_LIST,
- GTK_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_UNFOLDED_TEXT,
- g_param_spec_string ("unfolded-text",
- P_("Unfolded text"),
- P_("Text to render if combobox_text is opened"),
- NULL,
- GTK_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_UNFOLDED_MARKUP,
- g_param_spec_string ("unfolded-markup",
- P_("Unfolded markup"),
- P_("Marked up text to render if combobox_text is opened"),
- NULL,
- GTK_PARAM_WRITABLE));
-
- g_object_class_install_property (object_class,
- PROP_UNFOLDED_ATTRIBUTES,
- g_param_spec_boxed ("unfolded-attributes",
- P_("Unfolded attributes"),
- P_("A list of style attributes to apply to the text of the renderer if combobox_text is opened"),
- PANGO_TYPE_ATTR_LIST,
- GTK_PARAM_READWRITE));
-
-
- g_type_class_add_private (object_class, sizeof (KatzeCellRendererComboBoxTextPrivate));
-}
-
-static void
-katze_cell_renderer_combobox_text_finalize (GObject *object)
-{
- guint prop_index;
- KatzeCellRendererComboBoxTextPrivate *priv;
-
- priv = KATZE_CELL_RENDERER_COMBOBOX_TEXT_GET_PRIVATE (object);
-
- for (prop_index = 0 ; prop_index < 2; prop_index++)
- {
- g_free (priv->props[prop_index].text);
- if (priv->props[prop_index].extra_attrs)
- pango_attr_list_unref (priv->props[prop_index].extra_attrs);
- }
-
- G_OBJECT_CLASS (katze_cell_renderer_combobox_text_parent_class)->finalize (object);
-}
-
-static void
-katze_cell_renderer_combobox_text_get_property (GObject* object,
- guint param_id,
- GValue* value,
- GParamSpec* pspec)
-{
- KatzeCellRendererComboBoxTextPrivate *priv;
-
- priv = KATZE_CELL_RENDERER_COMBOBOX_TEXT_GET_PRIVATE (object);
-
- switch (param_id)
- {
- case PROP_FOLDED_TEXT:
- g_value_set_string (value, priv->props[0].text);
- break;
-
- case PROP_FOLDED_ATTRIBUTES:
- g_value_set_boxed (value, priv->props[0].extra_attrs);
- break;
-
- case PROP_UNFOLDED_TEXT:
- g_value_set_string (value, priv->props[1].text);
- break;
-
- case PROP_UNFOLDED_ATTRIBUTES:
- g_value_set_boxed (value, priv->props[1].extra_attrs);
- break;
-
- case PROP_FOLDED_MARKUP:
- case PROP_UNFOLDED_MARKUP:
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-
-static void
-katze_cell_renderer_combobox_text_set_property (GObject* object,
- guint param_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- guint prop_index = 0;
- KatzeCellRendererComboBoxTextPrivate *priv;
-
- priv = KATZE_CELL_RENDERER_COMBOBOX_TEXT_GET_PRIVATE (object);
-
- switch (param_id)
- {
- case PROP_FOLDED_TEXT:
- prop_text:
- g_free (priv->props[prop_index].text);
-
- if (priv->props[prop_index].markup_set)
- {
- if (priv->props[prop_index].extra_attrs)
- {
- pango_attr_list_unref (priv->props[prop_index].extra_attrs);
- priv->props[prop_index].extra_attrs = NULL;
- }
- priv->props[prop_index].markup_set = FALSE;
- }
-
- priv->props[prop_index].text = g_value_dup_string (value);
- break;
-
- case PROP_FOLDED_ATTRIBUTES:
- prop_attributes:
- if (priv->props[prop_index].extra_attrs)
- pango_attr_list_unref (priv->props[prop_index].extra_attrs);
-
- priv->props[prop_index].extra_attrs = g_value_get_boxed (value);
- if (priv->props[prop_index].extra_attrs)
- pango_attr_list_ref (priv->props[prop_index].extra_attrs);
- break;
-
- case PROP_FOLDED_MARKUP:
- prop_markup:
- {
- const gchar *str;
- gchar *text = NULL;
- GError *error = NULL;
- PangoAttrList *attrs = NULL;
-
- str = g_value_get_string (value);
- if (str && !pango_parse_markup (str,
- -1,
- 0,
- &attrs,
- &text,
- NULL,
- &error))
- {
- g_warning ("Failed to set text from markup due to error parsing markup: %s",
- error->message);
- g_error_free (error);
- return;
- }
-
- g_free (priv->props[prop_index].text);
-
- if (priv->props[prop_index].extra_attrs)
- pango_attr_list_unref (priv->props[prop_index].extra_attrs);
-
- priv->props[prop_index].text = text;
- priv->props[prop_index].extra_attrs = attrs;
- priv->props[prop_index].markup_set = TRUE;
- }
- break;
-
- case PROP_UNFOLDED_TEXT:
- prop_index = 1;
- goto prop_text;
-
- case PROP_UNFOLDED_ATTRIBUTES:
- prop_index = 1;
- goto prop_attributes;
-
- case PROP_UNFOLDED_MARKUP:
- prop_index = 1;
- goto prop_markup;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-/**
- * katze_cell_renderer_combobox_text_new:
- *
- * Creates a new #KatzeCellRendererComboBoxText. Adjust how text is drawn using
- * object properties. Object properties can be
- * set globally (with g_object_set()). Also, with #GtkTreeViewColumn,
- * you can bind a property to a value in a #GtkTreeModel. For example,
- * you can bind the "text" property on the cell renderer to a string
- * value in the model, thus rendering a different string in each row
- * of the #GtkTreeView
- *
- * Return value: (transfer full): the new cell renderer
- **/
-GtkCellRenderer *
-katze_cell_renderer_combobox_text_new (void)
-{
- return g_object_new (KATZE_TYPE_CELL_RENDERER_COMBOBOX_TEXT, NULL);
-}
-
-static void
-set_text(KatzeCellRendererComboBoxText* cell,
- GtkWidget* widget,
- const gchar* repl)
-{
- const gchar *text = NULL;
- PangoAttrList* extra_attrs = NULL;
- GtkWidget* pwidget = gtk_widget_get_parent (widget);
- gboolean unfolded = FALSE;
- KatzeCellRendererComboBoxTextPrivate *priv;
-
- priv = KATZE_CELL_RENDERER_COMBOBOX_TEXT_GET_PRIVATE (cell);
-
- if (GTK_IS_MENU_ITEM (pwidget))
- {
- GtkWidget* menu = gtk_widget_get_parent (pwidget);
- GList* items;
-
- if (menu
- && (GTK_IS_MENU (menu))
- && (items = gtk_container_get_children (GTK_CONTAINER (menu)))
- && (GTK_WIDGET (items->data) == pwidget)
- && (g_list_length (items) > 1)
- && (GTK_IS_SEPARATOR_MENU_ITEM (g_list_next (items)->data)))
- {
- unfolded = TRUE;
- }
- }
-
- if (unfolded)
- {
- text = priv->props[1].text;
- extra_attrs = priv->props[1].extra_attrs;
- }
- else
- {
- text = priv->props[0].text;
- extra_attrs = priv->props[0].extra_attrs;
- }
-
- if (!text)
- {
- text = g_strdup (repl ? repl : "");
- }
- else
- {
- GString* string = g_string_new ("");
- const gchar* src = text;
- const guint skip = sizeof ("[text]") - 1;
- guint len;
-
- while (0 != (len = strlen(src)))
- {
- const gchar* found = strstr (src, "[text]");
-
- if (!found)
- {
- g_string_append (string, src);
- src += len;
- }
- else
- {
- g_string_append_len (string, src, found-src);
- if (repl)
- g_string_append (string, repl);
- src = found + skip;
- }
- }
-
- text = g_string_free (string, FALSE);
- }
-
- g_object_set (G_OBJECT (cell),
- "text", text,
- "attributes", extra_attrs,
- NULL);
-
- g_free ((gpointer)text);
-}
-
-static void
-katze_cell_renderer_combobox_text_get_size (GtkCellRenderer *cell,
- GtkWidget *widget,
-#if GTK_CHECK_VERSION(3,0,0)
- const GdkRectangle* cell_area,
-#else
- GdkRectangle* cell_area,
-#endif
- gint *x_offset,
- gint *y_offset,
- gint *width,
- gint *height)
-{
- const gchar *text = NULL;
-
- g_object_get (G_OBJECT (cell), "text", &text, NULL);
-
- set_text (KATZE_CELL_RENDERER_COMBOBOX_TEXT (cell), widget, text);
-
- GTK_CELL_RENDERER_CLASS (katze_cell_renderer_combobox_text_parent_class)->get_size (cell,
- widget, cell_area,
- x_offset, y_offset, width, height);
-
- g_object_set (G_OBJECT (cell), "text", text, NULL);
- g_free ((gpointer)text);
-}
-
-static void
-#if GTK_CHECK_VERSION(3,0,0)
-katze_cell_renderer_combobox_text_render (GtkCellRenderer *cell,
- cairo_t* cr,
- GtkWidget *widget,
- const GdkRectangle *background_area,
- const GdkRectangle *cell_area,
- GtkCellRendererState flags)
-#else
-katze_cell_renderer_combobox_text_render (GtkCellRenderer *cell,
- GdkDrawable *window,
- GtkWidget *widget,
- GdkRectangle *background_area,
- GdkRectangle *cell_area,
- GdkRectangle *expose_area,
- GtkCellRendererState flags)
-#endif
-{
- const gchar *text = NULL;
-
- g_object_get (G_OBJECT (cell), "text", &text, NULL);
-
- set_text (KATZE_CELL_RENDERER_COMBOBOX_TEXT (cell), widget, text);
-
-#if GTK_CHECK_VERSION(3,0,0)
- GTK_CELL_RENDERER_CLASS (katze_cell_renderer_combobox_text_parent_class)->render (cell,
- cr,
- widget,
- background_area,
- cell_area,
- flags);
-#else
- GTK_CELL_RENDERER_CLASS (katze_cell_renderer_combobox_text_parent_class)->render (cell,
- window,
- widget,
- background_area,
- cell_area,
- expose_area,
- flags);
-#endif
-
- g_object_set (G_OBJECT (cell), "text", text, NULL);
- g_free ((gpointer)text);
-}
diff --git a/katze/katze-cellrenderercomboboxtext.h b/katze/katze-cellrenderercomboboxtext.h
deleted file mode 100644
index 156e3353..00000000
--- a/katze/katze-cellrenderercomboboxtext.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- Copyright (C) 2008-2013 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_CELL_RENDERER_COMBOBOX_TEXT_H__
-#define __KATZE_CELL_RENDERER_COMBOBOX_TEXT_H__
-
-
-#include <gtk/gtk.h>
-
-#ifndef GSEAL
-#define GSEAL(String) String
-#endif
-
-G_BEGIN_DECLS
-
-
-#define KATZE_TYPE_CELL_RENDERER_COMBOBOX_TEXT (katze_cell_renderer_combobox_text_get_type ())
-#define KATZE_CELL_RENDERER_COMBOBOX_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_CELL_RENDERER_COMBOBOX_TEXT, KatzeCellRendererComboBoxText))
-#define KATZE_CELL_RENDERER_COMBOBOX_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_CELL_RENDERER_COMBOBOX_TEXT, KatzeCellRendererComboBoxTextClass))
-#define KATZE_IS_CELL_RENDERER_COMBOBOX_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_CELL_RENDERER_COMBOBOX_TEXT))
-#define KATZE_IS_CELL_RENDERER_COMBOBOX_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_CELL_RENDERER_COMBOBOX_TEXT))
-#define KATZE_CELL_RENDERER_COMBOBOX_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_CELL_RENDERER_COMBOBOX_TEXT, KatzeCellRendererComboBoxTextClass))
-
-typedef struct _KatzeCellRendererComboBoxText KatzeCellRendererComboBoxText;
-typedef struct _KatzeCellRendererComboBoxTextClass KatzeCellRendererComboBoxTextClass;
-
-struct _KatzeCellRendererComboBoxText
-{
- GtkCellRendererText parent;
-
- /*< private >*/
-};
-
-struct _KatzeCellRendererComboBoxTextClass
-{
- GtkCellRendererTextClass parent_class;
-
- /* Padding for future expansion */
- void (*_gtk_reserved1) (void);
- void (*_gtk_reserved2) (void);
- void (*_gtk_reserved3) (void);
- void (*_gtk_reserved4) (void);
-};
-
-GType katze_cell_renderer_combobox_text_get_type (void) G_GNUC_CONST;
-GtkCellRenderer *katze_cell_renderer_combobox_text_new (void);
-
-G_END_DECLS
-
-#endif /* __KATZE_CELL_RENDERER_COMBOBOX_TEXT_H__ */
diff --git a/katze/katze-http-auth.c b/katze/katze-http-auth.c
deleted file mode 100644
index 72c534ad..00000000
--- a/katze/katze-http-auth.c
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
- Copyright (C) 2008-2009 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.
-*/
-
-#if HAVE_CONFIG_H
- #include <config.h>
-#endif
-
-#include "katze-http-auth.h"
-#include "gtk3-compat.h"
-
-#include <libsoup/soup.h>
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
-
-struct _KatzeHttpAuth
-{
- GObject parent_instance;
- gchar* filename;
- GHashTable* logins;
-};
-
-struct _KatzeHttpAuthClass
-{
- GObjectClass parent_class;
-};
-
-typedef struct
-{
- KatzeHttpAuth* http_auth;
- SoupAuth* auth;
- gchar* username;
- gchar* password;
-} KatzeHttpAuthSave;
-
-typedef struct
-{
- gchar* username;
- gchar* password;
-} KatzeHttpAuthLogin;
-
-static void
-katze_http_auth_session_feature_iface_init (SoupSessionFeatureInterface *iface,
- gpointer data);
-
-G_DEFINE_TYPE_WITH_CODE (KatzeHttpAuth, katze_http_auth, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
- katze_http_auth_session_feature_iface_init));
-
-enum
-{
- PROP_0,
-
- PROP_FILENAME
-};
-
-static void
-katze_http_auth_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-katze_http_auth_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-static void
-katze_http_auth_finalize (GObject* object);
-
-static gchar*
-katze_http_auth_soup_auth_get_hash (SoupAuth* auth)
-{
- return g_strdup_printf ("%s:%s:%s",
- soup_auth_get_host (auth),
- soup_auth_get_scheme_name (auth),
- soup_auth_get_realm (auth));
-}
-
-static void
-authentication_message_got_headers_cb (SoupMessage* msg,
- KatzeHttpAuthSave* save)
-{
- /* Anything but 401 and 5xx means the password was accepted */
- if (msg->status_code != 401 && msg->status_code < 500)
- {
- gchar* opaque_info;
- FILE* file;
-
- opaque_info = katze_http_auth_soup_auth_get_hash (save->auth);
-
- if (!g_hash_table_lookup (save->http_auth->logins, opaque_info))
- {
- KatzeHttpAuthLogin* login = g_slice_new (KatzeHttpAuthLogin);
- login->username = save->username;
- login->password = save->password;
- g_hash_table_insert (save->http_auth->logins, opaque_info, login);
-
- if ((file = g_fopen (save->http_auth->filename, "a")))
- {
- fprintf (file, "%s\t%s\t%s\n", opaque_info,
- login->username, login->password);
- fclose (file);
- g_chmod (save->http_auth->filename, 0600);
- }
- }
- else
- {
- /* FIXME g_free (save->username);
- g_free (save->password); */
- }
- }
- else
- {
- /* FIXME g_free (save->username);
- g_free (save->password); */
- }
-
- /* FIXME g_object_unref (save->auth); */
- /* FIXME g_slice_free (KatzeHttpAuthSave, save); */
- g_signal_handlers_disconnect_by_func (msg,
- authentication_message_got_headers_cb, save);
-}
-
-static void
-authentication_dialog_response_cb (GtkWidget* dialog,
- gint response,
- KatzeHttpAuthSave* save)
-{
- SoupSession* session;
- SoupMessage* msg;
-
- msg = g_object_get_data (G_OBJECT (dialog), "msg");
-
- if (response == GTK_RESPONSE_OK)
- {
- GtkEntry* username = g_object_get_data (G_OBJECT (dialog), "username");
- GtkEntry* password = g_object_get_data (G_OBJECT (dialog), "password");
- GtkToggleButton* remember = g_object_get_data (G_OBJECT (dialog), "remember");
-
- soup_auth_authenticate (save->auth,
- gtk_entry_get_text (username), gtk_entry_get_text (password));
-
- if (gtk_toggle_button_get_active (remember) && save->http_auth->filename)
- {
- save->username = g_strdup (gtk_entry_get_text (username));
- save->password = g_strdup (gtk_entry_get_text (password));
- g_signal_connect (msg, "got-headers",
- G_CALLBACK (authentication_message_got_headers_cb), save);
- }
- else
- {
- g_object_unref (save->auth);
- g_slice_free (KatzeHttpAuthSave, save);
- }
- }
-
- session = g_object_get_data (G_OBJECT (dialog), "session");
- if (g_object_get_data (G_OBJECT (msg), "paused"))
- soup_session_unpause_message (session, msg);
- gtk_widget_destroy (dialog);
- g_object_unref (msg);
-}
-
-static void
-katze_http_auth_session_authenticate_cb (SoupSession* session,
- SoupMessage* msg,
- SoupAuth* auth,
- gboolean retrying,
- KatzeHttpAuth* http_auth)
-{
- gchar* opaque_info;
- KatzeHttpAuthLogin* login;
- GtkWidget* dialog;
- GtkSizeGroup* sizegroup;
- GtkWidget* hbox;
- GtkWidget* image;
- GtkWidget* label;
- GtkWidget* align;
- GtkWidget* entry;
- KatzeHttpAuthSave* save;
-
- /* We want to ask for authentication exactly once, so we
- enforce this with a tag. There might be a better way. */
- if (!retrying && g_object_get_data (G_OBJECT (msg), "katze-session-tag"))
- return;
-
- if (1)
- {
- /* We use another tag to indicate whether a message is paused.
- There doesn't seem to be API in libSoup to find that out. */
- soup_session_pause_message (session, g_object_ref (msg));
- g_object_set_data (G_OBJECT (msg), "paused", (void*)1);
- }
- g_object_set_data (G_OBJECT (msg), "katze-session-tag", (void*)1);
-
- opaque_info = katze_http_auth_soup_auth_get_hash (auth);
- login = g_hash_table_lookup (http_auth->logins, opaque_info);
- g_free (opaque_info);
-
- dialog = gtk_dialog_new_with_buttons (_("Authentication Required"),
- NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
- gtk_window_set_icon_name (GTK_WINDOW (dialog),
- GTK_STOCK_DIALOG_AUTHENTICATION);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 5);
-
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 5);
- hbox = gtk_hbox_new (FALSE, 6);
- image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION,
- GTK_ICON_SIZE_DIALOG);
- gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
- label = gtk_label_new (_("A username and a password are required\n"
- "to open this location:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, FALSE, TRUE, 0);
- label = gtk_label_new (soup_auth_get_host (auth));
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), label, FALSE, TRUE, 0);
- /* If the realm is merely the host, omit the realm label */
- if (g_strcmp0 (soup_auth_get_host (auth), soup_auth_get_realm (auth)))
- {
- label = gtk_label_new (soup_auth_get_realm (auth));
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), label, FALSE, TRUE, 0);
- }
- sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- hbox = gtk_hbox_new (FALSE, 6);
- label = gtk_label_new (_("Username"));
- align = gtk_alignment_new (0, 0.5, 0, 0);
- gtk_container_add (GTK_CONTAINER (align), label);
- gtk_size_group_add_widget (sizegroup, align);
- gtk_box_pack_start (GTK_BOX (hbox), align, TRUE, TRUE, 0);
- entry = gtk_entry_new ();
- if (login)
- gtk_entry_set_text (GTK_ENTRY (entry), login->username);
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
- gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
- g_object_set_data (G_OBJECT (dialog), "username", entry);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, FALSE, TRUE, 0);
- hbox = gtk_hbox_new (FALSE, 6);
- label = gtk_label_new (_("Password"));
- align = gtk_alignment_new (0, 0.5, 0, 0);
- gtk_container_add (GTK_CONTAINER (align), label);
- gtk_size_group_add_widget (sizegroup, align);
- gtk_box_pack_start (GTK_BOX (hbox), align, TRUE, TRUE, 0);
- entry = gtk_entry_new ();
- if (login)
- gtk_entry_set_text (GTK_ENTRY (entry), login->password);
- gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
- gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
- g_object_set_data (G_OBJECT (dialog), "password", entry);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, FALSE, TRUE, 0);
- hbox = gtk_hbox_new (FALSE, 6);
- label = gtk_check_button_new_with_mnemonic (_("_Remember password"));
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
- g_object_set_data (G_OBJECT (dialog), "remember", label);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (label), (login != NULL));
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, FALSE, TRUE, 0);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
- gtk_widget_show_all (gtk_dialog_get_content_area (GTK_DIALOG (dialog)));
-
- g_object_set_data (G_OBJECT (dialog), "session", session);
- g_object_set_data (G_OBJECT (dialog), "msg", msg);
-
- save = g_slice_new0 (KatzeHttpAuthSave);
- save->http_auth = http_auth;
- save->auth = g_object_ref (auth);
- g_signal_connect (dialog, "response",
- G_CALLBACK (authentication_dialog_response_cb), save);
- gtk_widget_show (dialog);
-}
-
-static void
-katze_http_auth_session_request_queued_cb (SoupSession* session,
- SoupMessage* msg,
- KatzeHttpAuth* http_auth)
-{
- /* WebKit has its own authentication dialog in recent versions.
- We want only one, and we choose our own to have localization. */
- GType type = g_type_from_name ("WebKitSoupAuthDialog");
- if (type)
- soup_session_remove_feature_by_type (session, type);
-
- g_signal_connect (session, "authenticate",
- G_CALLBACK (katze_http_auth_session_authenticate_cb), http_auth);
- g_signal_handlers_disconnect_by_func (session,
- katze_http_auth_session_request_queued_cb, http_auth);
-}
-
-static void
-katze_http_auth_attach (SoupSessionFeature* feature,
- SoupSession* session)
-{
- g_signal_connect (session, "request-queued",
- G_CALLBACK (katze_http_auth_session_request_queued_cb), feature);
-}
-
-static void
-katze_http_auth_detach (SoupSessionFeature* feature,
- SoupSession* session)
-{
- g_signal_handlers_disconnect_by_func (session,
- katze_http_auth_session_authenticate_cb, NULL);
- g_signal_handlers_disconnect_by_func (session,
- katze_http_auth_session_request_queued_cb, NULL);
-}
-
-static void
-katze_http_auth_session_feature_iface_init (SoupSessionFeatureInterface *iface,
- gpointer data)
-{
- iface->attach = katze_http_auth_attach;
- iface->detach = katze_http_auth_detach;
-}
-
-static void
-katze_http_auth_class_init (KatzeHttpAuthClass* class)
-{
- GObjectClass* gobject_class;
- GParamFlags flags;
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = katze_http_auth_finalize;
- gobject_class->set_property = katze_http_auth_set_property;
- gobject_class->get_property = katze_http_auth_get_property;
-
- flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
-
- /**
- * KatzeHttpAuth:filename:
- *
- * An absolute path and name of a file for storing logins.
- *
- * Since: 0.1.10
- */
- g_object_class_install_property (gobject_class,
- PROP_FILENAME,
- g_param_spec_string (
- "filename",
- "Filename",
- "An absolute path and name of a file for storing logins",
- NULL,
- flags));
-}
-
-static void
-katze_http_auth_login_free (KatzeHttpAuthLogin* login)
-{
- g_free (login->username);
- g_free (login->password);
- g_slice_free (KatzeHttpAuthLogin, login);
-}
-
-static void
-katze_http_auth_set_filename (KatzeHttpAuth* http_auth,
- const gchar* filename)
-{
- FILE* file;
-
- katze_assign (http_auth->filename, g_strdup (filename));
-
- g_hash_table_remove_all (http_auth->logins);
-
- if ((file = g_fopen (filename, "r")))
- {
- gchar line[255];
- guint number = 0;
-
- while (fgets (line, 255, file))
- {
- gchar** parts = g_strsplit (line, "\t", 3);
- if (parts && parts[0] && parts[1] && parts[2])
- {
- gint length = strlen (parts[2]);
- KatzeHttpAuthLogin* login = g_slice_new (KatzeHttpAuthLogin);
- login->username = parts[1];
- if (parts[2][length - 1] == '\n')
- length--;
- login->password = g_strndup (parts[2], length);
- g_hash_table_insert (http_auth->logins, parts[0], login);
- g_free (parts);
- }
- else
- {
- g_strfreev (parts);
- g_warning ("Error in line %d in HTTP Auth file", number);
- }
- number++;
- }
- fclose (file);
- }
-}
-
-static void
-katze_http_auth_init (KatzeHttpAuth* http_auth)
-{
- http_auth->filename = NULL;
-
- http_auth->logins = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify)g_free, (GDestroyNotify)katze_http_auth_login_free);
-}
-
-static void
-katze_http_auth_finalize (GObject* object)
-{
- KatzeHttpAuth* http_auth = KATZE_HTTP_AUTH (object);
-
- g_free (http_auth->filename);
-
- g_hash_table_unref (http_auth->logins);
-
- G_OBJECT_CLASS (katze_http_auth_parent_class)->finalize (object);
-}
-
-static void
-katze_http_auth_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- KatzeHttpAuth* http_auth = KATZE_HTTP_AUTH (object);
-
- switch (prop_id)
- {
- case PROP_FILENAME:
- katze_http_auth_set_filename (http_auth, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-katze_http_auth_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- KatzeHttpAuth* http_auth = KATZE_HTTP_AUTH (object);
-
- switch (prop_id)
- {
- case PROP_FILENAME:
- g_value_set_string (value, http_auth->filename);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
diff --git a/katze/katze-http-auth.h b/katze/katze-http-auth.h
deleted file mode 100644
index bbf2e392..00000000
--- a/katze/katze-http-auth.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- Copyright (C) 2009 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_HTTP_AUTH_H__
-#define __KATZE_HTTP_AUTH_H__
-
-#include "katze-utils.h"
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define KATZE_TYPE_HTTP_AUTH \
- (katze_http_auth_get_type ())
-#define KATZE_HTTP_AUTH(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_HTTP_AUTH, KatzeHttpAuth))
-#define KATZE_HTTP_AUTH_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_HTTP_AUTH, KatzeHttpAuthClass))
-#define KATZE_IS_HTTP_AUTH(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_HTTP_AUTH))
-#define KATZE_IS_HTTP_AUTH_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_HTTP_AUTH))
-#define KATZE_HTTP_AUTH_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_HTTP_AUTH, KatzeHttpAuthClass))
-
-typedef struct _KatzeHttpAuth KatzeHttpAuth;
-typedef struct _KatzeHttpAuthClass KatzeHttpAuthClass;
-
-GType
-katze_http_auth_get_type (void) G_GNUC_CONST;
-
-G_END_DECLS
-
-#endif /* __KATZE_HTTP_AUTH_H__ */
diff --git a/katze/katze-item.c b/katze/katze-item.c
deleted file mode 100644
index a2e065fa..00000000
--- a/katze/katze-item.c
+++ /dev/null
@@ -1,862 +0,0 @@
-/*
- Copyright (C) 2008-2009 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.
-*/
-
-#include "katze-item.h"
-#include "katze-utils.h"
-#include "midori/midori-core.h"
-
-#include <glib/gi18n.h>
-
-/**
- * SECTION:katze-item
- * @short_description: A useful item
- * @see_also: #KatzeArray
- *
- * #KatzeItem is a particularly useful item that provides
- * several commonly needed properties.
- */
-
-G_DEFINE_TYPE (KatzeItem, katze_item, G_TYPE_OBJECT);
-
-enum
-{
- PROP_0,
-
- PROP_NAME,
- PROP_TEXT,
- PROP_URI,
- PROP_ICON,
- PROP_TOKEN,
- PROP_ADDED,
- PROP_PARENT
-};
-
-enum {
- META_DATA_CHANGED,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-katze_item_finalize (GObject* object);
-
-static void
-katze_item_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-katze_item_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-static void
-katze_item_class_init (KatzeItemClass* class)
-{
- GObjectClass* gobject_class;
- GParamFlags flags;
-
- /**
- * KatzeItem::meta-data-changed:
- * @item: the object on which the signal is emitted
- * @key: the key that changed
- *
- * Emitted when a meta data value was changed.
- *
- * Since 0.2.2 details according to keys are supported.
- *
- * Since: 0.1.9
- */
- signals[META_DATA_CHANGED] = g_signal_new (
- "meta-data-changed",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST |G_SIGNAL_DETAILED),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = katze_item_finalize;
- gobject_class->set_property = katze_item_set_property;
- gobject_class->get_property = katze_item_get_property;
-
- flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
-
- g_object_class_install_property (gobject_class,
- PROP_NAME,
- g_param_spec_string (
- "name",
- "Name",
- "The name of the item",
- NULL,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_TEXT,
- g_param_spec_string (
- "text",
- "Text",
- "The descriptive text of the item",
- NULL,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_URI,
- g_param_spec_string (
- "uri",
- "URI",
- "The URI of the item",
- NULL,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_ICON,
- g_param_spec_string (
- "icon",
- "Icon",
- "The icon of the item",
- NULL,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_TOKEN,
- g_param_spec_string (
- "token",
- "Token",
- "The token of the item",
- NULL,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_ADDED,
- g_param_spec_int64 (
- "added",
- "Added",
- "When the item was added",
- G_MININT64,
- G_MAXINT64,
- 0,
- flags));
-
- /**
- * KatzeItem:parent:
- *
- * The parent of the item.
- *
- * Since: 0.1.2
- */
- g_object_class_install_property (gobject_class,
- PROP_PARENT,
- g_param_spec_object (
- "parent",
- "Parent",
- "The parent of the item",
- G_TYPE_OBJECT,
- flags));
-
- class->copy = NULL;
-}
-
-
-
-static void
-katze_item_init (KatzeItem* item)
-{
- item->metadata = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, g_free);
-}
-
-static void
-katze_item_finalize (GObject* object)
-{
- KatzeItem* item = KATZE_ITEM (object);
-
- g_free (item->name);
- g_free (item->text);
- g_free (item->uri);
- g_free (item->token);
-
- g_hash_table_unref (item->metadata);
-
- G_OBJECT_CLASS (katze_item_parent_class)->finalize (object);
-}
-
-static void
-katze_item_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- KatzeItem* item = KATZE_ITEM (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- katze_assign (item->name, g_value_dup_string (value));
- break;
- case PROP_TEXT:
- katze_assign (item->text, g_value_dup_string (value));
- break;
- case PROP_URI:
- katze_assign (item->uri, g_value_dup_string (value));
- break;
- case PROP_ICON:
- katze_item_set_icon (item, g_value_get_string (value));
- break;
- case PROP_TOKEN:
- katze_assign (item->token, g_value_dup_string (value));
- break;
- case PROP_ADDED:
- item->added = g_value_get_int64 (value);
- break;
- case PROP_PARENT:
- katze_item_set_parent (item, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-katze_item_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- KatzeItem* item = KATZE_ITEM (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- g_value_set_string (value, item->name);
- break;
- case PROP_TEXT:
- g_value_set_string (value, item->text);
- break;
- case PROP_URI:
- g_value_set_string (value, item->uri);
- break;
- case PROP_ICON:
- g_value_set_string (value, katze_item_get_icon (item));
- break;
- case PROP_TOKEN:
- g_value_set_string (value, item->token);
- break;
- case PROP_ADDED:
- g_value_set_int64 (value, item->added);
- break;
- case PROP_PARENT:
- g_value_set_object (value, item->parent);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/**
- * katze_item_new:
- *
- * Creates a new #KatzeItem.
- *
- * Return value: (transfer full): a new #KatzeItem
- **/
-KatzeItem*
-katze_item_new (void)
-{
- KatzeItem* item = g_object_new (KATZE_TYPE_ITEM, NULL);
-
- return item;
-}
-
-/**
- * katze_item_get_name:
- * @item: a #KatzeItem
- *
- * Retrieves the name of @item.
- *
- * Return value: the name of the item
- **/
-const gchar*
-katze_item_get_name (KatzeItem* item)
-{
- g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
-
- return item->name;
-}
-
-/**
- * katze_item_set_name:
- * @item: a #KatzeItem
- * @name: a string
- *
- * Sets the name of @item.
- **/
-void
-katze_item_set_name (KatzeItem* item,
- const gchar* name)
-{
- g_return_if_fail (KATZE_IS_ITEM (item));
-
- if (!g_strcmp0 (item->name, name))
- return;
-
- katze_assign (item->name, g_strdup (name));
- if (item->parent)
- katze_array_update ((KatzeArray*)item->parent);
- g_object_notify (G_OBJECT (item), "name");
-}
-
-/**
- * katze_item_get_text:
- * @item: a #KatzeItem
- *
- * Retrieves the descriptive text of @item.
- *
- * Return value: the text of the item
- **/
-const gchar*
-katze_item_get_text (KatzeItem* item)
-{
- g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
-
- return item->text;
-}
-
-/**
- * katze_item_set_text:
- * @item: a #KatzeItem
- * @text: a string
- *
- * Sets the descriptive text of @item.
- **/
-void
-katze_item_set_text (KatzeItem* item,
- const gchar* text)
-{
- g_return_if_fail (KATZE_IS_ITEM (item));
-
- katze_assign (item->text, g_strdup (text));
- g_object_notify (G_OBJECT (item), "text");
-}
-
-/**
- * katze_item_get_uri:
- * @item: a #KatzeItem
- *
- * Retrieves the URI of @item.
- *
- * Return value: the URI of the item
- **/
-const gchar*
-katze_item_get_uri (KatzeItem* item)
-{
- g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
-
- return item->uri;
-}
-
-/**
- * katze_item_set_uri:
- * @item: a #KatzeItem
- * @uri: a string
- *
- * Sets the URI of @item.
- **/
-void
-katze_item_set_uri (KatzeItem* item,
- const gchar* uri)
-{
- g_return_if_fail (KATZE_IS_ITEM (item));
-
- if (!g_strcmp0 (item->uri, uri))
- return;
-
- katze_assign (item->uri, g_strdup (uri));
- g_object_notify (G_OBJECT (item), "uri");
-}
-
-/**
- * katze_item_get_icon:
- * @item: a #KatzeItem
- *
- * Retrieves the icon of @item.
- *
- * Return value: the icon of the item
- **/
-const gchar*
-katze_item_get_icon (KatzeItem* item)
-{
- g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
-
- return katze_item_get_meta_string (item, "icon");
-}
-
-/**
- * katze_item_set_icon:
- * @item: a #KatzeItem
- * @icon: a string
- *
- * Sets the icon of @item.
- **/
-void
-katze_item_set_icon (KatzeItem* item,
- const gchar* icon)
-{
- g_return_if_fail (KATZE_IS_ITEM (item));
-
- if (!g_strcmp0 (katze_item_get_meta_string (item, "icon"), icon))
- return;
-
- katze_item_set_meta_string (item, "icon", icon);
- if (item->parent)
- katze_array_update ((KatzeArray*)item->parent);
- g_object_notify (G_OBJECT (item), "icon");
-}
-
-/**
- * katze_item_get_pixbuf:
- * @item: a #KatzeItem
- * @widget: a #GtkWidget, or %NULL
- *
- * Creates a #GdkPixbuf fit to display @item.
- *
- * Return value: (transfer full): the icon of the item, or %NULL
- *
- * Since: 0.4.6
- **/
-GdkPixbuf*
-katze_item_get_pixbuf (KatzeItem* item,
- GtkWidget* widget)
-{
- GdkPixbuf* pixbuf;
-
- g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
-
- if (widget && KATZE_ITEM_IS_FOLDER (item))
- return gtk_widget_render_icon (widget, GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU, NULL);
- if ((pixbuf = midori_paths_get_icon (item->uri, widget)))
- return pixbuf;
- return NULL;
-}
-
-static void
-katze_item_image_destroyed_cb (GtkWidget* image,
- KatzeItem* item);
-#ifndef HAVE_WEBKIT2
-static void
-katze_item_icon_loaded_cb (WebKitFaviconDatabase* database,
- const gchar* frame_uri,
- GtkWidget* image)
-{
- KatzeItem* item = g_object_get_data (G_OBJECT (image), "KatzeItem");
- GdkPixbuf* pixbuf;
- if (!g_strcmp0 (frame_uri, item->uri)
- && (pixbuf = midori_paths_get_icon (frame_uri, image)))
- {
- gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
- g_object_unref (pixbuf);
- /* This signal fires extremely often (WebKit bug?)
- we must throttle it (disconnect) once we have an icon */
- katze_item_image_destroyed_cb (image, g_object_ref (item));
- }
-}
-#endif
-
-static void
-katze_item_image_destroyed_cb (GtkWidget* image,
- KatzeItem* item)
-{
-#ifndef HAVE_WEBKIT2
- g_signal_handlers_disconnect_by_func (webkit_get_favicon_database (),
- katze_item_icon_loaded_cb, image);
-#endif
- g_object_unref (item);
-}
-
-/**
- * katze_item_get_image:
- * @item: a #KatzeItem
- * @widget: a #GtkWidget, or %NULL
- *
- * Creates a #GtkImage fit to display @item.
- *
- * Return value: (transfer floating): the icon of the item
- *
- * Since: 0.4.4
- * Since 0.4.8 a @widget was added and the image is set visible.
- **/
-GtkWidget*
-katze_item_get_image (KatzeItem* item,
- GtkWidget* widget)
-{
- GtkWidget* image;
- GdkPixbuf* pixbuf;
-
- g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
-
- pixbuf = katze_item_get_pixbuf (item, widget);
- image = gtk_image_new_from_gicon (G_ICON (pixbuf), GTK_ICON_SIZE_MENU);
- gtk_widget_show (image);
- if (pixbuf != NULL)
- g_object_unref (pixbuf);
- if (KATZE_ITEM_IS_FOLDER (item))
- return image;
- g_object_set_data (G_OBJECT (image), "KatzeItem", g_object_ref (item));
- g_signal_connect (image, "destroy",
- G_CALLBACK (katze_item_image_destroyed_cb), item);
-#ifndef HAVE_WEBKIT2
- g_signal_connect (webkit_get_favicon_database (), "icon-loaded",
- G_CALLBACK (katze_item_icon_loaded_cb), image);
-#endif
- return image;
-}
-
-/**
- * katze_item_get_token:
- * @item: a #KatzeItem
- *
- * Retrieves the token of @item.
- *
- * Return value: the token of the item
- **/
-const gchar*
-katze_item_get_token (KatzeItem* item)
-{
- g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
-
- return item->token;
-}
-
-/**
- * katze_item_set_token:
- * @item: a #KatzeItem
- * @token: a string
- *
- * Sets the token of @item.
- **/
-void
-katze_item_set_token (KatzeItem* item,
- const gchar* token)
-{
- g_return_if_fail (KATZE_IS_ITEM (item));
-
- katze_assign (item->token, g_strdup (token));
- g_object_notify (G_OBJECT (item), "token");
-}
-
-/**
- * katze_item_get_added:
- * @item: a #KatzeItem
- *
- * Determines when @item was added.
- *
- * Return value: a timestamp
- **/
-gint64
-katze_item_get_added (KatzeItem* item)
-{
- g_return_val_if_fail (KATZE_IS_ITEM (item), 0);
-
- return item->added;
-}
-
-/**
- * katze_item_set_added:
- * @item: a #KatzeItem
- * @added: a timestamp
- *
- * Sets when @item was added.
- **/
-void
-katze_item_set_added (KatzeItem* item,
- gint64 added)
-{
- g_return_if_fail (KATZE_IS_ITEM (item));
-
- item->added = added;
- g_object_notify (G_OBJECT (item), "added");
-}
-
-/**
- * katze_item_get_meta_keys:
- * @item: a #KatzeItem
- *
- * Retrieves a list of all meta keys.
- *
- * Return value: (element-type utf8) (transfer container): a newly allocated #GList of constant strings
- *
- * Since: 0.1.8
- **/
-GList*
-katze_item_get_meta_keys (KatzeItem* item)
-{
- g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
-
- return g_hash_table_get_keys (item->metadata);
-}
-
-static void
-katze_item_set_meta_data_value (KatzeItem* item,
- const gchar* key,
- gchar* value)
-{
- /* FIXME: Make the default namespace configurable */
- if (g_str_has_prefix (key, "midori:"))
- g_hash_table_insert (item->metadata, g_strdup (&key[7]), value);
- else
- g_hash_table_insert (item->metadata, g_strdup (key), value);
- g_signal_emit (item, signals[META_DATA_CHANGED], g_quark_from_string (key), key);
-}
-
-/**
- * katze_item_get_meta_string:
- * @item: a #KatzeItem
- * @key: the name of an integer value
- *
- * Retrieves a string value by the specified key from the
- * meta data of the item.
- *
- * Specify "namespace:key" or "key" to use the default namespace.
- *
- * Return value: a string, or %NULL
- *
- * Since: 0.1.8
- *
- * Since 0.4.4 "" is treated like %NULL.
- **/
-const gchar*
-katze_item_get_meta_string (KatzeItem* item,
- const gchar* key)
-{
- const gchar* value;
-
- g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
- g_return_val_if_fail (key != NULL, NULL);
-
- if (g_str_has_prefix (key, "midori:"))
- key = &key[7];
- value = g_hash_table_lookup (item->metadata, key);
- return value && *value ? value : NULL;
-}
-
-/**
- * katze_item_set_meta_string:
- * @item: a #KatzeItem
- * @key: the name of a string value
- * @value: the value as a string
- *
- * Saves the specified string value in the meta data of
- * the item under the specified key.
- *
- * Specify "namespace:key" or "key" to use the default namespace.
- *
- * Since: 0.1.8
- **/
-void
-katze_item_set_meta_string (KatzeItem* item,
- const gchar* key,
- const gchar* value)
-{
- g_return_if_fail (KATZE_IS_ITEM (item));
- g_return_if_fail (key != NULL);
-
- katze_item_set_meta_data_value (item, key, g_strdup (value));
-}
-
-/**
- * katze_item_get_meta_integer:
- * @item: a #KatzeItem
- * @key: the name of an integer value
- *
- * Retrieves an integer value by the specified key from the
- * meta data of the item.
- *
- * If the key is present but not representable as an
- * integer, -1 is returned.
- *
- * Return value: an integer value, or -1
- *
- * Since: 0.1.8
- **/
-gint64
-katze_item_get_meta_integer (KatzeItem* item,
- const gchar* key)
-{
- gpointer value;
-
- g_return_val_if_fail (KATZE_IS_ITEM (item), -1);
- g_return_val_if_fail (key != NULL, -1);
-
- if (g_str_has_prefix (key, "midori:"))
- key = &key[7];
- if (g_hash_table_lookup_extended (item->metadata, key, NULL, &value))
- return value ? g_ascii_strtoll (value, NULL, 0) : -1;
- return -1;
-}
-
-/**
- * katze_item_get_meta_boolean:
- * @item: a #KatzeItem
- * @key: the name of a boolean value
- *
- * The Value should be set with katze_item_set_meta_integer().
- * If the value is set and not 0, %TRUE will be returned.
- *
- * Since: 0.2.7
- **/
-gboolean
-katze_item_get_meta_boolean (KatzeItem* item,
- const gchar* key)
-{
- const gchar* value;
-
- g_return_val_if_fail (KATZE_IS_ITEM (item), FALSE);
- g_return_val_if_fail (key != NULL, FALSE);
-
- value = katze_item_get_meta_string (item, key);
- if (value == NULL || value[0] == '0')
- return FALSE;
- else
- return TRUE;
-}
-
-/**
- * katze_item_set_meta_integer:
- * @item: a #KatzeItem
- * @key: the name of an integer value
- *
- * Saves the specified integer value in the meta data of
- * the item under the specified key.
- *
- * A value of -1 is intepreted as unset.
- *
- * Since: 0.1.8
- **/
-void
-katze_item_set_meta_integer (KatzeItem* item,
- const gchar* key,
- gint64 value)
-{
- g_return_if_fail (KATZE_IS_ITEM (item));
- g_return_if_fail (key != NULL);
-
- if (value == -1)
- katze_item_set_meta_data_value (item, key, NULL);
- else
- {
- katze_item_set_meta_data_value (item, key,
- #ifdef G_GINT64_FORMAT
- g_strdup_printf ("%" G_GINT64_FORMAT, value));
- #else
- g_strdup_printf ("%li", value));
- #endif
- }
-}
-
-/**
- * katze_item_get_parent:
- * @item: a #KatzeItem
- *
- * Determines the parent of @item.
- *
- * Since 0.1.2 you can monitor the "parent" property.
- *
- * Return value: (type GObject) (transfer none): the parent of the item
- **/
-gpointer
-katze_item_get_parent (KatzeItem* item)
-{
- g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
-
- return item->parent;
-}
-
-/**
- * katze_item_set_parent:
- * @item: a #KatzeItem
- * @parent: the new parent
- *
- * Sets the parent of @item.
- *
- * This is intended for item container implementations. Notably
- * the new parent will not be notified of the change.
- *
- * Since 0.1.2 you can monitor the "parent" property, so unsetting
- * the parent is actually safe if the parent supports it.
- **/
-void
-katze_item_set_parent (KatzeItem* item,
- gpointer parent)
-{
- g_return_if_fail (KATZE_IS_ITEM (item));
- g_return_if_fail (!parent || G_IS_OBJECT (parent));
-
- if (parent)
- g_object_ref (parent);
- katze_object_assign (item->parent, parent);
- g_object_notify (G_OBJECT (item), "parent");
-}
-
-/**
- * katze_item_copy:
- * @item: a #KatzeItem
- *
- * Creates an exact copy of @item.
- *
- * Note that subclass specific features will only
- * be preserved if the class implements it.
- *
- * Since 0.4.3 meta data is copied.
- *
- * Return value: (transfer full): a new #KatzeItem
- *
- * Since: 0.1.3
- **/
-KatzeItem*
-katze_item_copy (KatzeItem* item)
-{
- KatzeItem* copy;
- GHashTableIter iter;
- const gchar* key;
- const gchar* value;
- KatzeItemClass* class;
-
- g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
-
- copy = g_object_new (G_OBJECT_TYPE (item),
- "name", item->name,
- "text", item->text,
- "uri", item->uri,
- "token", item->token,
- "added", item->added,
- "parent", item->parent,
- NULL);
-
- g_hash_table_iter_init (&iter, item->metadata);
- while (g_hash_table_iter_next (&iter, (void*)&key, (void*)&value))
- {
- if (g_str_has_prefix (key, "midori:"))
- key = &key[7];
- g_hash_table_insert (copy->metadata, g_strdup (key), g_strdup (value));
- }
-
- class = KATZE_ITEM_GET_CLASS (item);
- return class->copy ? class->copy (copy) : copy;
-}
diff --git a/katze/katze-item.h b/katze/katze-item.h
deleted file mode 100644
index 70876802..00000000
--- a/katze/katze-item.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- 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_ITEM_H__
-#define __KATZE_ITEM_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define KATZE_TYPE_ITEM \
- (katze_item_get_type ())
-#define KATZE_ITEM(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_ITEM, KatzeItem))
-#define KATZE_ITEM_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_ITEM, KatzeItemClass))
-#define KATZE_IS_ITEM(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_ITEM))
-#define KATZE_IS_ITEM_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_ITEM))
-#define KATZE_ITEM_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_ITEM, KatzeItemClass))
-#define KATZE_ITEM_IS_BOOKMARK(item) (item && katze_item_get_uri (item))
-#define KATZE_ITEM_IS_FOLDER(item) (item && !katze_item_get_uri (item))
-#define KATZE_ITEM_IS_SEPARATOR(item) (item == NULL)
-
-typedef struct _KatzeItem KatzeItem;
-typedef struct _KatzeItemClass KatzeItemClass;
-
-struct _KatzeItem
-{
- GObject parent_instance;
-
- gchar* name;
- gchar* text;
- gchar* uri;
- gchar* token;
- gint64 added;
- GHashTable* metadata;
-
- KatzeItem* parent;
-};
-
-struct _KatzeItemClass
-{
- GObjectClass parent_class;
-
- gpointer
- (*copy) (KatzeItem* item);
-};
-
-GType
-katze_item_get_type (void) G_GNUC_CONST;
-
-KatzeItem*
-katze_item_new (void);
-
-const gchar*
-katze_item_get_name (KatzeItem* item);
-
-void
-katze_item_set_name (KatzeItem* item,
- const gchar* name);
-
-const gchar*
-katze_item_get_text (KatzeItem* item);
-
-void
-katze_item_set_text (KatzeItem* item,
- const gchar* text);
-
-const gchar*
-katze_item_get_uri (KatzeItem* item);
-
-void
-katze_item_set_uri (KatzeItem* item,
- const gchar* uri);
-
-const gchar*
-katze_item_get_icon (KatzeItem* item);
-
-void
-katze_item_set_icon (KatzeItem* item,
- const gchar* icon);
-
-GdkPixbuf*
-katze_item_get_pixbuf (KatzeItem* item,
- GtkWidget* widget);
-
-GtkWidget*
-katze_item_get_image (KatzeItem* item,
- GtkWidget* widget);
-
-const gchar*
-katze_item_get_token (KatzeItem* item);
-
-void
-katze_item_set_token (KatzeItem* item,
- const gchar* token);
-
-gint64
-katze_item_get_added (KatzeItem* item);
-
-void
-katze_item_set_added (KatzeItem* item,
- gint64 added);
-
-GList*
-katze_item_get_meta_keys (KatzeItem* item);
-
-const gchar*
-katze_item_get_meta_string (KatzeItem* item,
- const gchar* key);
-
-void
-katze_item_set_meta_string (KatzeItem* item,
- const gchar* key,
- const gchar* value);
-
-gint64
-katze_item_get_meta_integer (KatzeItem* item,
- const gchar* key);
-
-gboolean
-katze_item_get_meta_boolean (KatzeItem* item,
- const gchar* key);
-
-void
-katze_item_set_meta_integer (KatzeItem* item,
- const gchar* key,
- gint64 value);
-
-gpointer
-katze_item_get_parent (KatzeItem* item);
-
-void
-katze_item_set_parent (KatzeItem* item,
- gpointer parent);
-
-KatzeItem*
-katze_item_copy (KatzeItem* item);
-
-G_END_DECLS
-
-#endif /* __MIDORI_WEB_ITEM_H__ */
diff --git a/katze/katze-preferences.c b/katze/katze-preferences.c
deleted file mode 100644
index 7a6dbd13..00000000
--- a/katze/katze-preferences.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- Copyright (C) 2007-2009 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.
-*/
-
-#include "katze-preferences.h"
-
-#if HAVE_CONFIG_H
- #include <config.h>
-#endif
-
-#include <string.h>
-#include <glib/gi18n.h>
-
-struct _KatzePreferencesPrivate
-{
- GtkWidget* notebook;
- GtkWidget* toolbar;
- GtkWidget* toolbutton;
- GtkSizeGroup* sizegroup;
- GtkSizeGroup* sizegroup2;
- GtkWidget* page;
- GtkWidget* frame;
- GtkWidget* box;
- GtkWidget* hbox;
-};
-
-G_DEFINE_TYPE (KatzePreferences, katze_preferences, GTK_TYPE_DIALOG);
-
-static void
-katze_preferences_finalize (GObject* object);
-
-static void
-katze_preferences_class_init (KatzePreferencesClass* class)
-{
- GObjectClass* gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = katze_preferences_finalize;
-
- g_type_class_add_private (class, sizeof (KatzePreferencesPrivate));
-}
-
-static void
-katze_preferences_response_cb (KatzePreferences* preferences,
- gint response)
-{
- if (response == GTK_RESPONSE_CLOSE || response == GTK_RESPONSE_APPLY)
- gtk_widget_destroy (GTK_WIDGET (preferences));
-}
-
-static void
-katze_preferences_init (KatzePreferences* preferences)
-{
- KatzePreferencesPrivate* priv;
- gchar* dialog_title;
-
- preferences->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE ((preferences),
- KATZE_TYPE_PREFERENCES, KatzePreferencesPrivate);
-
- dialog_title = g_strdup_printf (_("Preferences for %s"),
- g_get_application_name ());
- g_object_set (preferences,
- "icon-name", GTK_STOCK_PREFERENCES,
- "title", dialog_title,
-#if !GTK_CHECK_VERSION (2, 22, 0)
- "has-separator", FALSE,
-#endif
- NULL);
- g_free (dialog_title);
-
- #if !HAVE_OSX
- gtk_dialog_add_buttons (GTK_DIALOG (preferences),
- GTK_STOCK_HELP, GTK_RESPONSE_HELP,
- NULL);
- katze_widget_add_class (gtk_dialog_get_widget_for_response (
- GTK_DIALOG (preferences), GTK_RESPONSE_HELP), "help_button");
-
- gtk_dialog_add_buttons (GTK_DIALOG (preferences),
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
- NULL);
- #endif
-
- g_object_connect (preferences,
- "signal::response", katze_preferences_response_cb, NULL,
- NULL);
-
-}
-
-static void
-katze_preferences_finalize (GObject* object)
-{
- G_OBJECT_CLASS (katze_preferences_parent_class)->finalize (object);
-}
-
-/**
- * katze_preferences_new:
- * @parent: the parent window, or %NULL
- *
- * Creates a new preferences dialog.
- *
- * Return value: (transfer full): a new #KatzePreferences
- *
- * Since: 0.2.1
- **/
-GtkWidget*
-katze_preferences_new (GtkWindow* parent)
-{
- KatzePreferences* preferences;
-
- g_return_val_if_fail (!parent || GTK_IS_WINDOW (parent), NULL);
-
- preferences = g_object_new (KATZE_TYPE_PREFERENCES,
- "transient-for", parent,
- NULL);
-
- return GTK_WIDGET (preferences);
-}
-
-#if HAVE_OSX
-static void
-katze_preferences_help_clicked_cb (GtkWidget* button,
- GtkDialog* dialog)
-{
- gtk_dialog_response (dialog, GTK_RESPONSE_HELP);
-}
-
-static void
-katze_preferences_toolbutton_clicked_cb (GtkWidget* toolbutton,
- GtkWidget* page)
-{
- gpointer notebook = g_object_get_data (G_OBJECT (toolbutton), "notebook");
- guint n = gtk_notebook_page_num (notebook, page);
- gtk_notebook_set_current_page (notebook, n);
-}
-#endif
-
-static void
-katze_preferences_prepare (KatzePreferences* preferences)
-{
- KatzePreferencesPrivate* priv = preferences->priv;
-
- #if GTK_CHECK_VERSION (3, 10, 0) && !HAVE_OSX
- priv->notebook = gtk_stack_new ();
- #else
- priv->notebook = gtk_notebook_new ();
- #endif
- gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), 6);
-
- #if HAVE_OSX
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
- priv->toolbar = gtk_toolbar_new ();
- gtk_toolbar_set_style (GTK_TOOLBAR (priv->toolbar), GTK_TOOLBAR_BOTH);
- gtk_toolbar_set_show_arrow (GTK_TOOLBAR (priv->toolbar), FALSE);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (preferences))),
- priv->toolbar, FALSE, FALSE, 0);
- #else
- #if GTK_CHECK_VERSION (3, 10, 0) && !HAVE_OSX
- priv->toolbar = gtk_stack_switcher_new ();
- gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (priv->toolbar), GTK_STACK (priv->notebook));
- gtk_widget_set_halign (priv->toolbar, GTK_ALIGN_CENTER);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (preferences))),
- priv->toolbar, FALSE, FALSE, 0);
- #else
- priv->toolbar = NULL;
- #endif
-
- #endif
- priv->toolbutton = NULL;
- gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (preferences))),
- priv->notebook, TRUE, TRUE, 4);
-
- priv->sizegroup = NULL;
- priv->sizegroup2 = NULL;
- priv->page = NULL;
- priv->frame = NULL;
- priv->box = NULL;
- priv->hbox = NULL;
-
- g_signal_connect (priv->notebook, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &priv->notebook);
-
- #if HAVE_OSX
- GtkWidget* icon;
- GtkWidget* hbox = gtk_hbox_new (FALSE, 0);
- GtkWidget* button = gtk_button_new ();
- icon = gtk_image_new_from_stock (GTK_STOCK_HELP, GTK_ICON_SIZE_BUTTON);
- gtk_button_set_image (GTK_BUTTON (button), icon);
- g_signal_connect (button, "clicked",
- G_CALLBACK (katze_preferences_help_clicked_cb), preferences);
- gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 4);
- gtk_box_pack_end (GTK_BOX (GTK_DIALOG (preferences)->action_area),
- hbox, FALSE, FALSE, 0);
- #endif
- gtk_widget_show_all (gtk_dialog_get_content_area (GTK_DIALOG (preferences)));
-}
-
-#if GTK_CHECK_VERSION (3, 10, 0) & !HAVE_OSX
-/* these functions are used to clear the 100-px width set in GTK3's
-update_button function in gtk/gtkstackswitcher.c */
-
-static void
-clear_size_request (GtkWidget* widget)
-{
- gtk_widget_set_size_request (widget, -1, -1);
-}
-
-static void
-workaround_stack_switcher_sizing (GtkStackSwitcher* switcher)
-{
- gtk_container_forall (GTK_CONTAINER (switcher), (GtkCallback)clear_size_request, NULL);
-}
-#endif
-
-/**
- * katze_preferences_add_category:
- * @preferences: a #KatzePreferences instance
- * @label: a category label
- * @icon: an icon name
- *
- * Adds a new category with the specified label to the dialog.
- *
- * Return value: (transfer none): a new #GtkBox in the preferences widget to
- * hold the category's widgets
- *
- * Since: 0.2.1
- *
- * Since 0.3.4 a #GtkBox is returned that can be packed into.
- **/
-GtkWidget*
-katze_preferences_add_category (KatzePreferences* preferences,
- const gchar* label,
- const gchar* icon)
-{
- KatzePreferencesPrivate* priv;
-
- g_return_val_if_fail (KATZE_IS_PREFERENCES (preferences), NULL);
- g_return_val_if_fail (label != NULL, NULL);
- g_return_val_if_fail (icon != NULL, NULL);
-
- priv = preferences->priv;
-
- if (!priv->notebook)
- katze_preferences_prepare (preferences);
-
- priv->page = gtk_vbox_new (FALSE, 0);
- priv->sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- gtk_widget_show (priv->page);
- gtk_container_set_border_width (GTK_CONTAINER (priv->page), 4);
- #if GTK_CHECK_VERSION (3, 10, 0) & !HAVE_OSX
- gtk_stack_add_titled (GTK_STACK (priv->notebook),
- priv->page, label, label);
- workaround_stack_switcher_sizing (GTK_STACK_SWITCHER (priv->toolbar));
- #else
- gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
- priv->page, gtk_label_new (label));
-
- #endif
-
- #if HAVE_OSX
- priv->toolbutton = GTK_WIDGET (priv->toolbutton ?
- gtk_radio_tool_button_new_from_widget (
- GTK_RADIO_TOOL_BUTTON (priv->toolbutton))
- : gtk_radio_tool_button_new (NULL));
- gtk_widget_show (priv->toolbutton);
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (priv->toolbutton), label);
- gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (priv->toolbutton), icon);
- gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar),
- GTK_TOOL_ITEM (priv->toolbutton), -1);
- g_signal_connect (priv->toolbutton, "clicked",
- G_CALLBACK (katze_preferences_toolbutton_clicked_cb), priv->page);
- if (priv->toolbutton)
- g_object_set_data (G_OBJECT (priv->toolbutton), "notebook", priv->notebook);
- #endif
-
- return priv->page;
-}
-
-static GtkWidget*
-katze_hig_frame_new (const gchar* title)
-{
- /* Create a frame with no actual frame but a bold label and indentation */
- GtkWidget* frame = gtk_frame_new (NULL);
- #ifdef G_OS_WIN32
- gtk_frame_set_label (GTK_FRAME (frame), title);
- #else
- gchar* title_bold = g_strdup_printf ("<b>%s</b>", title);
- GtkWidget* label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label), title_bold);
- g_free (title_bold);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- #endif
- return frame;
-}
-
-/**
- * katze_preferences_add_group:
- * @preferences: a #KatzePreferences instance
- * @label: a group label, or %NULL
- *
- * Adds a new group with the specified label to the dialog.
- *
- * Since: 0.2.1
- *
- * Since 0.3.4 you can pass %NULL to hide the label.
- **/
-void
-katze_preferences_add_group (KatzePreferences* preferences,
- const gchar* label)
-{
- KatzePreferencesPrivate* priv;
-
- g_return_if_fail (KATZE_IS_PREFERENCES (preferences));
-
- priv = preferences->priv;
- priv->sizegroup2 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- priv->frame = label ? katze_hig_frame_new (label) :
- g_object_new (GTK_TYPE_FRAME, "shadow-type", GTK_SHADOW_NONE, NULL);
- gtk_container_set_border_width (GTK_CONTAINER (priv->frame), 4);
- gtk_box_pack_start (GTK_BOX (priv->page), priv->frame, FALSE, FALSE, 0);
- priv->box = gtk_vbox_new (FALSE, 4);
- gtk_container_set_border_width (GTK_CONTAINER (priv->box), 4);
- gtk_container_add (GTK_CONTAINER (priv->frame), priv->box);
- gtk_widget_show_all (priv->frame);
-}
-
-/**
- * katze_preferences_add_widget:
- * @preferences: a #KatzePreferences instance
- * @widget: a widget representing an option
- * @type: "filled", "indented", or "spanned"
- *
- * Adds a widget to the dialog.
- *
- * Since: 0.2.1
- **/
-void
-katze_preferences_add_widget (KatzePreferences* preferences,
- GtkWidget* widget,
- const gchar* type)
-{
- KatzePreferencesPrivate* priv;
- const gchar* _type;
-
- g_return_if_fail (KATZE_IS_PREFERENCES (preferences));
- g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (type != NULL);
-
- priv = preferences->priv;
- _type = g_intern_string (type);
-
- /* Showing implicitly widget and children is not the best idea,
- but lots of repeated function calls aren't either. */
- gtk_widget_show_all (widget);
-
- if (!priv->hbox)
- _type = g_intern_string ("indented");
-
- if (_type != g_intern_static_string ("spanned"))
- {
- priv->hbox = gtk_hbox_new (FALSE, 4);
- gtk_widget_show (priv->hbox);
- gtk_box_pack_start (GTK_BOX (priv->hbox), widget, TRUE, FALSE, 0);
- }
-
- if (_type == g_intern_static_string ("filled"))
- gtk_box_pack_start (GTK_BOX (priv->box), priv->hbox, TRUE, FALSE, 0);
- else if (_type == g_intern_static_string ("indented"))
- {
- GtkWidget* align = gtk_alignment_new (0, 0.5, 0, 0);
- gtk_widget_show (align);
- gtk_container_add (GTK_CONTAINER (align), priv->hbox);
- if (!GTK_IS_SPIN_BUTTON (widget))
- gtk_size_group_add_widget (priv->sizegroup, widget);
- gtk_box_pack_start (GTK_BOX (priv->box), align, TRUE, FALSE, 0);
- }
- else if (_type == g_intern_static_string ("spanned"))
- {
- GtkWidget* align = gtk_alignment_new (0, 0.5, 0, 0);
- gtk_widget_show (align);
- gtk_container_add (GTK_CONTAINER (align), widget);
- if (!GTK_IS_LABEL (widget) && !GTK_IS_SPIN_BUTTON (widget)
- && !(GTK_IS_BUTTON (widget) && !GTK_IS_TOGGLE_BUTTON (widget)))
- gtk_size_group_add_widget (priv->sizegroup2, widget);
- gtk_box_pack_start (GTK_BOX (priv->hbox), align, TRUE, FALSE, 0);
- }
-}
diff --git a/katze/katze-preferences.h b/katze/katze-preferences.h
deleted file mode 100644
index 1424ac61..00000000
--- a/katze/katze-preferences.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- Copyright (C) 2008-2009 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_PREFERENCES_H__
-#define __KATZE_PREFERENCES_H__
-
-#include "katze-utils.h"
-
-G_BEGIN_DECLS
-
-#define KATZE_TYPE_PREFERENCES \
- (katze_preferences_get_type ())
-#define KATZE_PREFERENCES(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_PREFERENCES, KatzePreferences))
-#define KATZE_PREFERENCES_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_PREFERENCES, KatzePreferencesClass))
-#define KATZE_IS_PREFERENCES(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_PREFERENCES))
-#define KATZE_IS_PREFERENCES_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_PREFERENCES))
-#define KATZE_PREFERENCES_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_PREFERENCES, KatzePreferencesClass))
-
-typedef struct _KatzePreferences KatzePreferences;
-typedef struct _KatzePreferencesClass KatzePreferencesClass;
-typedef struct _KatzePreferencesPrivate KatzePreferencesPrivate;
-
-struct _KatzePreferences
-{
- GtkDialog parent_instance;
-
- KatzePreferencesPrivate* priv;
-};
-
-struct _KatzePreferencesClass
-{
- GtkDialogClass parent_class;
-};
-
-GType
-katze_preferences_get_type (void) G_GNUC_CONST;
-
-GtkWidget*
-katze_preferences_new (GtkWindow* parent);
-
-GtkWidget*
-katze_preferences_add_category (KatzePreferences* preferences,
- const gchar* label,
- const gchar* icon);
-
-void
-katze_preferences_add_group (KatzePreferences* preferences,
- const gchar* label);
-
-void
-katze_preferences_add_widget (KatzePreferences* preferences,
- GtkWidget* widget,
- const gchar* type);
-
-G_END_DECLS
-
-#endif /* __KATZE_PREFERENCES_H__ */
diff --git a/katze/katze-separatoraction.vala b/katze/katze-separatoraction.vala
deleted file mode 100644
index 8b377e02..00000000
--- a/katze/katze-separatoraction.vala
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- Copyright (C) 2009-2013 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.
-*/
-
-namespace Katze {
- public class SeparatorAction : Gtk.Action {
- Gtk.MenuItem? menuitem = null;
- Gtk.ToolItem? toolitem = null;
-
- public override unowned Gtk.Widget create_menu_item () {
- menuitem = new Gtk.SeparatorMenuItem ();
- return menuitem;
- }
-
- public override unowned Gtk.Widget create_tool_item () {
- toolitem = new Gtk.SeparatorToolItem ();
- return toolitem;
- }
- }
-}
-
diff --git a/katze/katze-utils.c b/katze/katze-utils.c
deleted file mode 100644
index 4364e830..00000000
--- a/katze/katze-utils.c
+++ /dev/null
@@ -1,1169 +0,0 @@
-/*
- Copyright (C) 2007-2009 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.
-*/
-
-#include "gtk3-compat.h"
-
-#include "katze-utils.h"
-#include "katze-array.h"
-#include "midori-core.h"
-
-#include <glib/gstdio.h>
-#include <glib/gi18n.h>
-#include <gio/gio.h>
-
-#include <string.h>
-
-#if HAVE_CONFIG_H
- #include "config.h"
-#endif
-
-#if HAVE_UNISTD_H
- #include <unistd.h>
-#endif
-
-#define I_ g_intern_static_string
-
-static void
-proxy_toggle_button_toggled_cb (GtkToggleButton* button,
- GObject* object)
-{
- gboolean toggled;
- const gchar* property;
-
- toggled = gtk_toggle_button_get_active (button);
- property = g_object_get_data (G_OBJECT (button), "property");
- g_object_set (object, property, toggled, NULL);
-}
-
-static void
-proxy_file_file_set_cb (GtkFileChooser* button,
- GObject* object)
-{
- const gchar* file = gtk_file_chooser_get_filename (button);
- const gchar* property = g_object_get_data (G_OBJECT (button), "property");
- g_object_set (object, property, file, NULL);
-}
-
-static void
-proxy_folder_file_set_cb (GtkFileChooser* button,
- GObject* object)
-{
- const gchar* file = gtk_file_chooser_get_current_folder (button);
- const gchar* property = g_object_get_data (G_OBJECT (button), "property");
- g_object_set (object, property, file, NULL);
-}
-
-static void
-proxy_uri_file_set_cb (GtkFileChooser* button,
- GObject* object)
-{
- const gchar* file = gtk_file_chooser_get_uri (button);
- const gchar* property = g_object_get_data (G_OBJECT (button), "property");
- g_object_set (object, property, file, NULL);
-}
-
-#if GTK_CHECK_VERSION (3, 2, 0)
-static void
-proxy_font_chooser_font_activated_cb (GtkFontChooser* chooser,
- GObject* object)
-{
- PangoFontFamily* font_family = gtk_font_chooser_get_font_family (GTK_FONT_CHOOSER (chooser));
- const gchar* font_name = pango_font_family_get_name (font_family);
- const gchar* property = g_object_get_data (G_OBJECT (chooser), "property");
- g_object_set (object, property, font_name, NULL);
-}
-
-static gboolean
-proxy_font_chooser_filter_monospace_cb (PangoFontFamily* family,
- PangoFontFace* face,
- gpointer data)
-{
- gboolean monospace = GPOINTER_TO_INT (data);
- return monospace == pango_font_family_is_monospace (family);
-}
-#else
-static void
-proxy_combo_box_text_changed_cb (GtkComboBoxText* button,
- GObject* object)
-{
- gchar* text = gtk_combo_box_text_get_active_text (button);
- const gchar* property = g_object_get_data (G_OBJECT (button), "property");
- g_object_set (object, property, text, NULL);
- g_free (text);
-}
-#endif
-
-static gboolean
-proxy_entry_focus_out_event_cb (GtkEntry* entry,
- GdkEventFocus* event,
- GObject* object);
-
-static void
-proxy_entry_activate_cb (GtkEntry* entry,
- GObject* object)
-{
- const gchar* text = gtk_entry_get_text (entry);
- const gchar* property = g_object_get_data (G_OBJECT (entry), "property");
- g_object_set (object, property, text, NULL);
-}
-
-static gboolean
-proxy_entry_focus_out_event_cb (GtkEntry* entry,
- GdkEventFocus* event,
- GObject* object)
-{
- const gchar* text = gtk_entry_get_text (entry);
- const gchar* property = g_object_get_data (G_OBJECT (entry), "property");
- g_object_set (object, property, text, NULL);
- return FALSE;
-}
-
-static void
-proxy_days_changed_cb (GtkComboBox* combo,
- GObject* object)
-{
- gint active = gtk_combo_box_get_active (combo);
- const gchar* property = g_object_get_data (G_OBJECT (combo), "property");
- gint max_age;
- switch (active)
- {
- case 0: max_age = 0; break;
- case 1: max_age = 1; break;
- case 2: max_age = 7; break;
- case 3: max_age = 30; break;
- case 4: max_age = 365; break;
- default:
- max_age = 30;
- }
- g_object_set (object, property, max_age, NULL);
-}
-
-static void
-proxy_spin_button_changed_cb (GtkSpinButton* button,
- GObject* object)
-{
- GObjectClass* class = G_OBJECT_GET_CLASS (object);
- const gchar* property = g_object_get_data (G_OBJECT (button), "property");
- GParamSpec* pspec = g_object_class_find_property (class, property);
- if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_INT)
- {
- gint value = gtk_spin_button_get_value_as_int (button);
- g_object_set (object, property, value, NULL);
- }
- else
- {
- gdouble value = gtk_spin_button_get_value (button);
- g_object_set (object, property, value, NULL);
- }
-}
-
-static void
-proxy_combo_box_changed_cb (GtkComboBox* button,
- GObject* object)
-{
- gint value = gtk_combo_box_get_active (button);
- const gchar* property = g_object_get_data (G_OBJECT (button), "property");
- gint custom_value = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button),
- "katze-custom-value"));
- const gchar* custom_property = g_object_get_data (G_OBJECT (button),
- "katze-custom-property");
-
- if (custom_value)
- {
- GtkWidget* child = gtk_bin_get_child (GTK_BIN (button));
-
- if (value == custom_value && GTK_IS_CELL_VIEW (child))
- {
- GtkWidget* entry = gtk_entry_new ();
- gchar* custom_text = katze_object_get_string (object, custom_property);
- if (custom_text && *custom_text)
- gtk_entry_set_text (GTK_ENTRY (entry), custom_text);
- g_free (custom_text);
- gtk_widget_show (entry);
- gtk_container_add (GTK_CONTAINER (button), entry);
- gtk_widget_grab_focus (entry);
- g_signal_connect (entry, "focus-out-event",
- G_CALLBACK (proxy_entry_focus_out_event_cb), object);
- g_object_set_data_full (G_OBJECT (entry), "property",
- g_strdup (custom_property), g_free);
- }
- else if (value != custom_value && GTK_IS_ENTRY (child))
- {
- g_signal_handlers_block_by_func (
- button, proxy_combo_box_changed_cb, object);
- /* Force the combo to change the item again */
- gtk_widget_destroy (child);
- gtk_combo_box_set_active (button, value + 1);
- gtk_combo_box_set_active (button, value);
- g_signal_handlers_unblock_by_func (
- button, proxy_combo_box_changed_cb, object);
- }
- }
-
- g_object_set (object, property, value, NULL);
-
- if (custom_value)
- {
- if (value == custom_value)
- gtk_widget_set_tooltip_text (GTK_WIDGET (button), NULL);
- else
- {
- gchar* custom_text = katze_object_get_string (object, custom_property);
- gtk_widget_set_tooltip_text (GTK_WIDGET (button), custom_text);
- g_free (custom_text);
- }
- }
-}
-
-static void
-proxy_object_notify_boolean_cb (GObject* object,
- GParamSpec* pspec,
- GtkWidget* proxy)
-{
- const gchar* property = g_object_get_data (G_OBJECT (proxy), "property");
- gboolean value = katze_object_get_boolean (object, property);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (proxy), value);
-}
-
-static void
-proxy_object_notify_string_cb (GObject* object,
- GParamSpec* pspec,
- GtkWidget* proxy)
-{
- const gchar* property = g_object_get_data (G_OBJECT (proxy), "property");
- gchar* value = katze_object_get_string (object, property);
- gtk_entry_set_text (GTK_ENTRY (proxy), value);
- g_free (value);
-}
-
-static void
-proxy_widget_boolean_destroy_cb (GtkWidget* proxy,
- GObject* object)
-{
- g_signal_handlers_disconnect_by_func (object,
- proxy_object_notify_boolean_cb, proxy);
-}
-
-static void
-proxy_widget_string_destroy_cb (GtkWidget* proxy,
- GObject* object)
-{
- g_signal_handlers_disconnect_by_func (object,
- proxy_object_notify_string_cb, proxy);
-}
-
-/**
- * katze_property_proxy:
- * @object: a #GObject
- * @property: the name of a property
- * @hint: a special hint
- *
- * Create a widget of an appropriate type to represent the specified
- * object's property. If the property is writable changes of the value
- * through the widget will be reflected in the value of the property.
- *
- * Supported values for @hint are as follows:
- * "blurb": the blurb of the property will be used to provide a kind
- * of label, instead of the name.
- * "file": the widget created will be particularly suitable for
- * choosing an existing filename.
- * "folder": the widget created will be particularly suitable for
- * choosing an existing folder.
- * "uri": the widget created will be particularly suitable for
- * choosing an existing filename, encoded as an URI.
- * "font": the widget created will be particularly suitable for
- * choosing a variable-width font from installed fonts.
- * Since 0.1.6 the following hints are also supported:
- * "toggle": the widget created will be an empty toggle button. This
- * is only supported with boolean properties.
- * Since 0.1.8 "toggle" creates GtkCheckButton widgets without checkmarks.
- * Since 0.2.0 the following hints are also supported:
- * "font-monospace": the widget created will be particularly suitable for
- * choosing a fixed-width font from installed fonts.
- * Since 0.2.1 the following hints are also supported:
- * "application-TYPE": the widget created will be particularly suitable
- * for choosing an application to open TYPE files, ie. "text/plain".
- * "application-CATEGORY": the widget created will be particularly suitable
- * for choosing an application to open CATEGORY files, ie. "Network".
- * Since 0.5.8 the CATEGORY hint is no longer supported.
- * "custom-PROPERTY": the last value of an enumeration will be the "custom"
- * value, where the user may enter text freely, which then updates
- * the property PROPERTY instead. This applies only to enumerations.
- * Since 0.4.1 mnemonics are automatically stripped.
- * Since 0.2.9 the following hints are also supported:
- * "languages": the widget will be particularly suitable for choosing
- * multiple language codes, ie. "de,en_GB".
- * Since 0.3.6 the following hints are also supported:
- * "address": the widget will be particularly suitable for typing
- * a valid URI or IP address and highlight errors.
- * Since 0.4.0 the following hints are also supported:
- * "days": the widget will be particularly suitable for choosing
- * a period of time in days.
- *
- * Any other values for @hint are silently ignored.
- *
- * Since 0.1.2 strings without hints and booleans are truly synchronous
- * including property changes causing the proxy to be updated.
- *
- * Since 0.2.1 the proxy may contain a label if the platform
- * has according widgets.
- *
- * Return value: (transfer full): a new widget
- **/
-GtkWidget*
-katze_property_proxy (gpointer object,
- const gchar* property,
- const gchar* hint)
-{
- GObjectClass* class;
- GParamSpec* pspec;
- GType type;
- const gchar* nick;
- const gchar* _hint;
- GtkWidget* widget;
- gchar* string;
-
- g_return_val_if_fail (G_IS_OBJECT (object), NULL);
-
- class = G_OBJECT_GET_CLASS (object);
- pspec = g_object_class_find_property (class, property);
- if (!pspec)
- {
- g_warning (_("Property '%s' is invalid for %s"),
- property, G_OBJECT_CLASS_NAME (class));
- return gtk_label_new (property);
- }
-
- type = G_PARAM_SPEC_TYPE (pspec);
- nick = g_param_spec_get_nick (pspec);
- _hint = g_intern_string (hint);
- if (_hint == I_("blurb"))
- nick = g_param_spec_get_blurb (pspec);
- string = NULL;
- if (type == G_TYPE_PARAM_BOOLEAN)
- {
- gchar* notify_property;
- gboolean toggled = katze_object_get_boolean (object, property);
-
-
- widget = gtk_check_button_new ();
- if (_hint == I_("toggle"))
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (widget), FALSE);
- else
- gtk_button_set_label (GTK_BUTTON (widget), gettext (nick));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), toggled);
-
- g_signal_connect (widget, "toggled",
- G_CALLBACK (proxy_toggle_button_toggled_cb), object);
- notify_property = g_strdup_printf ("notify::%s", property);
- g_signal_connect (object, notify_property,
- G_CALLBACK (proxy_object_notify_boolean_cb), widget);
- g_signal_connect (widget, "destroy",
- G_CALLBACK (proxy_widget_boolean_destroy_cb), object);
- g_free (notify_property);
- }
- else if (type == G_TYPE_PARAM_STRING && _hint == I_("file"))
- {
- string = katze_object_get_string (object, property);
-
- widget = gtk_file_chooser_button_new (_("Choose file"),
- GTK_FILE_CHOOSER_ACTION_OPEN);
-
- if (!string)
- string = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value);
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget),
- string ? string : "");
- if (pspec->flags & G_PARAM_WRITABLE)
- g_signal_connect (widget, "selection-changed",
- G_CALLBACK (proxy_file_file_set_cb), object);
- }
- else if (type == G_TYPE_PARAM_STRING && _hint == I_("folder"))
- {
- string = katze_object_get_string (object, property);
-
- widget = gtk_file_chooser_button_new (_("Choose folder"),
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
- if (!string)
- string = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value);
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget),
- string ? string : "");
- if (pspec->flags & G_PARAM_WRITABLE)
- g_signal_connect (widget, "selection-changed",
- G_CALLBACK (proxy_folder_file_set_cb), object);
- }
- else if (type == G_TYPE_PARAM_STRING && _hint == I_("uri"))
- {
- string = katze_object_get_string (object, property);
-
- widget = gtk_file_chooser_button_new (_("Choose file"),
- GTK_FILE_CHOOSER_ACTION_OPEN);
- if (!string)
- string = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value);
- gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (widget),
- string ? string : "");
- g_signal_connect (widget, "file-set",
- G_CALLBACK (proxy_uri_file_set_cb), object);
- }
- else if (type == G_TYPE_PARAM_STRING && (_hint == I_("font")
- || _hint == I_("font-monospace")))
- {
- string = katze_object_get_string (object, property);
- if (!string)
- string = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value);
- /* 'sans' and 'sans-serif' are presumably the same */
- if (!g_strcmp0 (string, "sans-serif"))
- katze_assign (string, g_strdup ("sans"));
- gboolean monospace = _hint == I_("font-monospace");
-
- #if GTK_CHECK_VERSION (3, 2, 0)
- widget = gtk_font_button_new ();
- gtk_font_button_set_show_size (GTK_FONT_BUTTON (widget), FALSE);
- gtk_font_chooser_set_font (GTK_FONT_CHOOSER (widget), string);
- /* font-activated doesn't work with at least GTK+ 3.8.4 */
- g_signal_connect (widget, "font-set",
- G_CALLBACK (proxy_font_chooser_font_activated_cb), object);
- gtk_font_chooser_set_filter_func (GTK_FONT_CHOOSER (widget),
- (GtkFontFilterFunc)proxy_font_chooser_filter_monospace_cb, GINT_TO_POINTER (monospace), NULL);
- #else
- GtkComboBox* combo;
- gint n_families, i;
- PangoContext* context;
- PangoFontFamily** families;
-
- widget = gtk_combo_box_text_new ();
- combo = GTK_COMBO_BOX (widget);
- context = gtk_widget_get_pango_context (widget);
- pango_context_list_families (context, &families, &n_families);
- if (string)
- {
- gint j = 0;
- for (i = 0; i < n_families; i++)
- {
- if (monospace != pango_font_family_is_monospace (families[i]))
- continue;
- const gchar* font = pango_font_family_get_name (families[i]);
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), font);
- if (!g_ascii_strcasecmp (font, string))
- gtk_combo_box_set_active (combo, j);
- j++;
- }
- }
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (
- gtk_combo_box_get_model (combo)), 0, GTK_SORT_ASCENDING);
- g_signal_connect (widget, "changed",
- G_CALLBACK (proxy_combo_box_text_changed_cb), object);
- g_free (families);
- #endif
- }
- else if (type == G_TYPE_PARAM_STRING)
- {
- gchar* notify_property;
-
- if (_hint == I_("address"))
- widget = katze_uri_entry_new (NULL);
- else
- widget = gtk_entry_new ();
- g_object_get (object, property, &string, NULL);
- if (!string)
- string = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value);
- if (!(string && *string) && _hint == I_("languages"))
- {
- gchar* lang = g_strjoinv (",", (gchar**)g_get_language_names ());
- if (g_str_has_suffix (lang, ",C"))
- {
- string = g_strndup (lang, strlen (lang) - 2);
- g_free (lang);
- }
- else
- string = lang;
- }
- gtk_entry_set_text (GTK_ENTRY (widget), string ? string : "");
- g_signal_connect (widget, "activate",
- G_CALLBACK (proxy_entry_activate_cb), object);
- g_signal_connect (widget, "focus-out-event",
- G_CALLBACK (proxy_entry_focus_out_event_cb), object);
- notify_property = g_strdup_printf ("notify::%s", property);
- g_signal_connect (object, notify_property,
- G_CALLBACK (proxy_object_notify_string_cb), widget);
- g_signal_connect (widget, "destroy",
- G_CALLBACK (proxy_widget_string_destroy_cb), object);
- g_free (notify_property);
- }
- else if (type == G_TYPE_PARAM_DOUBLE)
- {
- gdouble value;
- g_object_get (object, property, &value, NULL);
-
- widget = gtk_spin_button_new_with_range (
- G_PARAM_SPEC_DOUBLE (pspec)->minimum,
- G_PARAM_SPEC_DOUBLE (pspec)->maximum, 1);
- /* Keep it narrow, 5 + 2 digits are usually fine */
- gtk_entry_set_width_chars (GTK_ENTRY (widget), 5 + 2);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), 2);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
- gtk_spin_button_set_increments (GTK_SPIN_BUTTON (widget), 0.1, -0.1);
- g_signal_connect (widget, "value-changed",
- G_CALLBACK (proxy_spin_button_changed_cb), object);
- }
- else if (type == G_TYPE_PARAM_FLOAT)
- {
- gfloat value;
- g_object_get (object, property, &value, NULL);
-
- widget = gtk_spin_button_new_with_range (
- G_PARAM_SPEC_FLOAT (pspec)->minimum,
- G_PARAM_SPEC_FLOAT (pspec)->maximum, 1);
- /* Keep it narrow, 5 + 2 digits are usually fine */
- gtk_entry_set_width_chars (GTK_ENTRY (widget), 5 + 2);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), 2);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
- g_signal_connect (widget, "value-changed",
- G_CALLBACK (proxy_spin_button_changed_cb), object);
- }
- else if (type == G_TYPE_PARAM_INT && _hint == I_("days"))
- {
- gint value = katze_object_get_int (object, property);
- gint active;
- widget = gtk_combo_box_text_new ();
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("1 hour"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("1 day"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("1 week"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("1 month"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("1 year"));
- switch (value)
- {
- case 0: active = 0; break;
- case 1: active = 1; break;
- case 7: active = 2; break;
- case 30: active = 3; break;
- case 365: active = 4; break;
- default:
- active = 3;
- }
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), active);
- g_signal_connect (widget, "changed",
- G_CALLBACK (proxy_days_changed_cb), object);
- }
- else if (type == G_TYPE_PARAM_INT)
- {
- gint value = katze_object_get_int (object, property);
-
- widget = gtk_spin_button_new_with_range (
- G_PARAM_SPEC_INT (pspec)->minimum,
- G_PARAM_SPEC_INT (pspec)->maximum, 1);
-
- /* Keep it narrow, 5 digits are usually fine */
- gtk_entry_set_width_chars (GTK_ENTRY (widget), 5);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
- g_signal_connect (widget, "value-changed",
- G_CALLBACK (proxy_spin_button_changed_cb), object);
- }
- else if (type == G_TYPE_PARAM_ENUM)
- {
- guint i;
- GEnumClass* enum_class = G_ENUM_CLASS (
- g_type_class_ref (pspec->value_type));
- gint value = katze_object_get_enum (object, property);
- const gchar* custom = NULL;
-
- if (hint && g_str_has_prefix (hint, "custom-"))
- custom = &hint[7];
-
- widget = gtk_combo_box_text_new ();
- for (i = 0; i < enum_class->n_values; i++)
- {
- const gchar* raw_label = gettext (enum_class->values[i].value_nick);
- gchar* label = katze_strip_mnemonics (raw_label);
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), label);
- g_free (label);
- }
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), value);
- g_signal_connect (widget, "changed",
- G_CALLBACK (proxy_combo_box_changed_cb), object);
- if (custom)
- {
- gchar* custom_text = katze_object_get_string (object, custom);
-
- if (value == (gint)(enum_class->n_values - 1))
- {
- GtkWidget* entry = gtk_entry_new ();
- gchar* text = katze_object_get_string (object, custom);
- if (text && *text)
- gtk_entry_set_text (GTK_ENTRY (entry), text);
- gtk_widget_show (entry);
- gtk_container_add (GTK_CONTAINER (widget), entry);
- g_signal_connect (entry, "focus-out-event",
- G_CALLBACK (proxy_entry_focus_out_event_cb), object);
- g_object_set_data_full (G_OBJECT (entry), "property",
- g_strdup (custom), g_free);
- gtk_widget_set_tooltip_text (widget, NULL);
- }
- else
- gtk_widget_set_tooltip_text (widget, custom_text);
-
- g_free (custom_text);
-
- g_object_set_data (G_OBJECT (widget), "katze-custom-value",
- GINT_TO_POINTER (enum_class->n_values - 1));
- g_object_set_data (G_OBJECT (widget), "katze-custom-property",
- (gpointer)custom);
- }
- g_type_class_unref (enum_class);
- }
- else
- widget = gtk_label_new (gettext (nick));
- g_free (string);
-
- gtk_widget_set_sensitive (widget, pspec->flags & G_PARAM_WRITABLE);
-
- g_object_set_data_full (G_OBJECT (widget), "property",
- g_strdup (property), g_free);
-
- return widget;
-}
-
-typedef struct
-{
- GtkWidget* widget;
- KatzeMenuPos position;
-} KatzePopupInfo;
-
-static void
-katze_widget_popup_position_menu (GtkMenu* menu,
- gint* x,
- gint* y,
- gboolean* push_in,
- gpointer user_data)
-{
- gint wx, wy;
- gint menu_width;
- GtkAllocation allocation;
- GtkRequisition menu_req;
- GtkRequisition widget_req;
- KatzePopupInfo* info = user_data;
- GtkWidget* widget = info->widget;
- GdkWindow* window = gtk_widget_get_window (widget);
- gint widget_height;
-
- if (!window)
- return;
-
- #if !GTK_CHECK_VERSION (3, 0, 0)
- if (GTK_IS_ENTRY (widget))
- window = gdk_window_get_parent (window);
- #endif
-
- /* Retrieve size and position of both widget and menu */
- gtk_widget_get_allocation (widget, &allocation);
- gdk_window_get_origin (window, &wx, &wy);
- wx += allocation.x;
- wy += allocation.y;
- #if GTK_CHECK_VERSION (3, 0, 0)
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL);
- gtk_widget_get_preferred_size (widget, &widget_req, NULL);
- #else
- gtk_widget_size_request (GTK_WIDGET (menu), &menu_req);
- gtk_widget_size_request (widget, &widget_req);
- #endif
- menu_width = menu_req.width;
- widget_height = widget_req.height; /* Better than allocation.height */
-
- /* Calculate menu position */
- if (info->position == KATZE_MENU_POSITION_CURSOR)
- ; /* Do nothing? */
- else if (info->position == KATZE_MENU_POSITION_RIGHT)
- {
- *x = wx + allocation.width - menu_width;
- *y = wy + widget_height;
- } else if (info->position == KATZE_MENU_POSITION_LEFT)
- {
- *x = wx;
- *y = wy + widget_height;
- }
-
- *push_in = TRUE;
-}
-
-/**
- * katze_widget_popup:
- * @widget: a widget
- * @menu: the menu to popup
- * @event: a button event, or %NULL
- * @pos: the preferred positioning
- *
- * Pops up the given menu relative to @widget. Use this
- * instead of writing custom positioning functions.
- *
- * Return value: a new label widget
- **/
-void
-katze_widget_popup (GtkWidget* widget,
- GtkMenu* menu,
- GdkEventButton* event,
- KatzeMenuPos pos)
-{
- int button, event_time;
- if (event)
- {
- button = event->button;
- event_time = event->time;
- }
- else
- {
- button = 0;
- event_time = gtk_get_current_event_time ();
- }
-
- if (!gtk_menu_get_attach_widget (menu))
- gtk_menu_attach_to_widget (menu, widget, NULL);
-
-
- if (widget)
- {
- KatzePopupInfo info = { widget, pos };
- gtk_menu_popup (menu, NULL, NULL,
- katze_widget_popup_position_menu, &info,
- button, event_time);
- }
- else
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, button, event_time);
-}
-
-/**
- * katze_image_menu_item_new_ellipsized:
- * @label: a label or %NULL
- *
- * Creates an image menu item where the label is
- * reasonably ellipsized for you.
- *
- * Return value: (transfer full): a new label widget
- **/
-GtkWidget*
-katze_image_menu_item_new_ellipsized (const gchar* label)
-{
- GtkWidget* menuitem;
- GtkWidget* label_widget;
-
- menuitem = gtk_image_menu_item_new ();
- label_widget = gtk_label_new (label);
- /* FIXME: Should text direction be respected here? */
- gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.0);
- gtk_label_set_max_width_chars (GTK_LABEL (label_widget), 50);
- gtk_label_set_ellipsize (GTK_LABEL (label_widget), PANGO_ELLIPSIZE_MIDDLE);
- gtk_widget_show (label_widget);
- gtk_container_add (GTK_CONTAINER (menuitem), label_widget);
-
- return menuitem;
-}
-
-/**
- * katze_tree_view_get_selected_iter:
- * @treeview: a #GtkTreeView
- * @model: a pointer to store the model, or %NULL
- * @iter: a pointer to store the iter, or %NULL
- *
- * Determines whether there is a selection in @treeview
- * and sets the @iter to the current selection.
- *
- * If there is a selection and @model is not %NULL, it is
- * set to the model, mainly for convenience.
- *
- * Either @model or @iter or both can be %NULL in which case
- * no value will be assigned in any case.
- *
- * Return value: %TRUE if there is a selection
- *
- * Since: 0.1.3
- **/
-gboolean
-katze_tree_view_get_selected_iter (GtkTreeView* treeview,
- GtkTreeModel** model,
- GtkTreeIter* iter)
-{
- GtkTreeSelection* selection;
-
- g_return_val_if_fail (GTK_IS_TREE_VIEW (treeview), FALSE);
-
- if ((selection = gtk_tree_view_get_selection (treeview)))
- if (gtk_tree_selection_get_selected (selection, model, iter))
- return TRUE;
- return FALSE;
-}
-
-void
-katze_bookmark_populate_tree_view (KatzeArray* array,
- GtkTreeStore* model,
- GtkTreeIter* parent)
-{
- KatzeItem* child;
- GtkTreeIter iter;
- GtkTreeIter root_iter;
-
- KATZE_ARRAY_FOREACH_ITEM (child, array)
- {
- if (KATZE_ITEM_IS_BOOKMARK (child))
- {
- gchar* tooltip = g_markup_escape_text (katze_item_get_uri (child), -1);
- gtk_tree_store_insert_with_values (model, NULL, parent,
- 0, 0, child, 1, tooltip, -1);
- g_free (tooltip);
- }
- else
- {
- gtk_tree_store_insert_with_values (model, &root_iter, parent,
- 0, 0, child, -1);
- /* That's an invisible dummy, so we always have an expander */
- gtk_tree_store_insert_with_values (model, &iter, &root_iter,
- 0, 0, NULL, -1);
- }
- }
-}
-
-/**
- * katze_strip_mnemonics:
- * @original: a string with mnemonics
- *
- * Parses the given string for mnemonics in the form
- * "B_utton" or "Button (_U)" and returns a string
- * without any mnemonics.
- *
- * Return value: a newly allocated string without mnemonics
- *
- * Since: 0.1.8
- **/
-gchar*
-katze_strip_mnemonics (const gchar* original)
-{
- /* A copy of _gtk_toolbar_elide_underscores
- Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- Copied from GTK+ 2.17.1 */
- gchar *q, *result;
- const gchar *p, *end;
- gsize len;
- gboolean last_underscore;
-
- if (!original)
- return NULL;
-
- len = strlen (original);
- q = result = g_malloc (len + 1);
- last_underscore = FALSE;
-
- end = original + len;
- for (p = original; p < end; p++)
- {
- if (!last_underscore && *p == '_')
- last_underscore = TRUE;
- else
- {
- last_underscore = FALSE;
- if (original + 2 <= p && p + 1 <= end &&
- p[-2] == '(' && p[-1] == '_' && p[0] != '_' && p[1] == ')')
- {
- q--;
- *q = '\0';
- p++;
- }
- else
- *q++ = *p;
- }
- }
-
- if (last_underscore)
- *q++ = '_';
-
- *q = '\0';
-
- return result;
-}
-
-const gchar*
-katze_skip_whitespace (const gchar* str)
-{
- if (str == NULL)
- return NULL;
- while (*str == ' ' || *str == '\t' || *str == '\n')
- str++;
- return str;
-}
-
-/**
- * katze_object_get_boolean:
- * @object: a #GObject
- * @property: the name of the property to get
- *
- * Retrieve the boolean value of the specified property.
- *
- * Return value: a boolean
- **/
-gboolean
-katze_object_get_boolean (gpointer object,
- const gchar* property)
-{
- gboolean value = FALSE;
-
- g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
- /* FIXME: Check value type */
-
- g_object_get (object, property, &value, NULL);
- return value;
-}
-
-/**
- * katze_object_get_int:
- * @object: a #GObject
- * @property: the name of the property to get
- *
- * Retrieve the integer value of the specified property.
- *
- * Return value: an integer
- **/
-gint
-katze_object_get_int (gpointer object,
- const gchar* property)
-{
- gint value = -1;
-
- g_return_val_if_fail (G_IS_OBJECT (object), -1);
- /* FIXME: Check value type */
-
- g_object_get (object, property, &value, NULL);
- return value;
-}
-
-/**
- * katze_object_get_enum:
- * @object: a #GObject
- * @property: the name of the property to get
- *
- * Retrieve the enum value of the specified property.
- *
- * Return value: an enumeration
- **/
-gint
-katze_object_get_enum (gpointer object,
- const gchar* property)
-{
- gint value = -1;
-
- g_return_val_if_fail (G_IS_OBJECT (object), -1);
- /* FIXME: Check value type */
-
- g_object_get (object, property, &value, NULL);
- return value;
-}
-
-/**
- * katze_object_get_string:
- * @object: a #GObject
- * @property: the name of the property to get
- *
- * Retrieve the string value of the specified property.
- *
- * Return value: a newly allocated string
- **/
-gchar*
-katze_object_get_string (gpointer object,
- const gchar* property)
-{
- gchar* value = NULL;
-
- g_return_val_if_fail (G_IS_OBJECT (object), NULL);
- /* FIXME: Check value type */
-
- g_object_get (object, property, &value, NULL);
- return value;
-}
-
-/**
- * katze_object_get_object:
- * @object: a #GObject
- * @property: the name of the property to get
- *
- * Retrieve the object value of the specified property.
- *
- * Return value: (transfer none): an object
- **/
-gpointer
-katze_object_get_object (gpointer object,
- const gchar* property)
-{
- GObject* value = NULL;
-
- g_return_val_if_fail (G_IS_OBJECT (object), NULL);
- /* FIXME: Check value type */
-
- g_object_get (object, property, &value, NULL);
- return value;
-}
-
-/**
- * katze_mkdir_with_parents:
- * @pathname: a pathname in the GLib file name encoding
- * @mode: permissions to use for newly created directories
- *
- * Create a directory if it doesn't already exist. Create intermediate
- * parent directories as needed, too.
- *
- * Returns: 0 if the directory already exists, or was successfully
- * created. Returns -1 if an error occurred, with errno set.
- *
- * Since: 0.2.1
- */
-int
-katze_mkdir_with_parents (const gchar* pathname,
- int mode)
-{
- midori_paths_mkdir_with_parents (pathname, mode);
- return 0;
-}
-
-static void
-katze_uri_entry_changed_cb (GtkWidget* entry,
- GtkWidget* other_widget)
-{
- const gchar* uri = gtk_entry_get_text (GTK_ENTRY (entry));
- gboolean valid = midori_uri_is_location (uri);
- if (!valid && g_object_get_data (G_OBJECT (entry), "allow_%s"))
- valid = uri && g_str_has_prefix (uri, "%s");
- if (!valid)
- valid = midori_uri_is_ip_address (uri);
-
- #if GTK_CHECK_VERSION (3, 2, 0)
- g_object_set_data (G_OBJECT (entry), "invalid", GINT_TO_POINTER (uri && *uri && !valid));
- gtk_widget_queue_draw (entry);
- #else
- if (uri && *uri && !valid)
- {
- GdkColor bg_color = { 0 };
- GdkColor fg_color = { 0 };
- gdk_color_parse ("#ef7070", &bg_color);
- gdk_color_parse ("#000", &fg_color);
- gtk_widget_modify_base (entry, GTK_STATE_NORMAL, &bg_color);
- gtk_widget_modify_text (entry, GTK_STATE_NORMAL, &fg_color);
- }
- else
- {
- gtk_widget_modify_base (entry, GTK_STATE_NORMAL, NULL);
- gtk_widget_modify_text (entry, GTK_STATE_NORMAL, NULL);
- }
- #endif
-
- if (other_widget != NULL)
- gtk_widget_set_sensitive (other_widget, valid);
-}
-
-#if GTK_CHECK_VERSION (3, 2, 0)
-static gboolean
-katze_uri_entry_draw_cb (GtkWidget* entry,
- cairo_t* cr,
- GtkWidget* other_widget)
-{
- const GdkRGBA color = { 0.9, 0., 0., 1. };
- double width = gtk_widget_get_allocated_width (entry);
- double height = gtk_widget_get_allocated_height (entry);
-
- if (!g_object_get_data (G_OBJECT (entry), "invalid"))
- return FALSE;
-
- /* FIXME: error-underline-color requires GtkTextView */
- gdk_cairo_set_source_rgba (cr, &color);
-
- pango_cairo_show_error_underline (cr, width * 0.15, height / 1.9,
- width * 0.75, height / 1.9 / 2);
- return TRUE;
-}
-#endif
-
-/**
- * katze_uri_entry_new:
- * @other_widget: a #GtkWidget, or %NULL
- *
- * Creates an entry that validates the typed URI.
- *
- * If @other_widget is given, it will become insensitive if
- * the input is not a valid URI.
- *
- * Returns: (transfer full): a #GtkEntry
- *
- * Since: 0.3.6
- */
-GtkWidget*
-katze_uri_entry_new (GtkWidget* other_widget)
-{
- GtkWidget* entry = gtk_entry_new ();
- #if GTK_CHECK_VERSION (3, 6, 0)
- gtk_entry_set_input_purpose (GTK_ENTRY (entry), GTK_INPUT_PURPOSE_URL);
- #endif
-
- gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY,
- g_themed_icon_new_with_default_fallbacks ("text-html-symbolic"));
- g_signal_connect (entry, "changed",
- G_CALLBACK (katze_uri_entry_changed_cb), other_widget);
- #if GTK_CHECK_VERSION (3, 2, 0)
- g_signal_connect_after (entry, "draw",
- G_CALLBACK (katze_uri_entry_draw_cb), other_widget);
- #endif
- return entry;
-}
-
-void
-katze_widget_add_class (GtkWidget* widget,
- const gchar* class_name)
-{
- #if GTK_CHECK_VERSION (3,0,0)
- GtkStyleContext* context = gtk_widget_get_style_context (widget);
- gtk_style_context_add_class (context, class_name);
- #endif
-}
-
-/**
- * katze_assert_str_equal:
- * @input: a string
- * @result: a string
- * @expected: a string
- *
- * Compares the two strings for equality, with verbose errors.
- *
- * Since: 0.4.3
- */
-void
-katze_assert_str_equal (const gchar* input,
- const gchar* result,
- const gchar* expected)
-{
- if (g_strcmp0 (result, expected))
- {
- g_error ("Input: %s\nExpected: %s\nResult: %s",
- input ? input : "NULL",
- expected ? expected : "NULL",
- result ? result : "NULL");
- }
-}
-
-void
-katze_window_set_sensible_default_size (GtkWindow* window)
-{
- GdkScreen* screen;
- GdkRectangle monitor;
- gint width, height;
-
- g_return_if_fail (GTK_IS_WINDOW (window));
-
- screen = gtk_window_get_screen (window);
- gdk_screen_get_monitor_geometry (screen, 0, &monitor);
- width = monitor.width / 1.7;
- height = monitor.height / 1.7;
- gtk_window_set_default_size (window, width, height);
- /* 700x100 is the approximate useful minimum dimensions */
- gtk_widget_set_size_request (GTK_WIDGET (window), 700, 100);
-}
-
diff --git a/katze/katze-utils.h b/katze/katze-utils.h
deleted file mode 100644
index 0460331a..00000000
--- a/katze/katze-utils.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- Copyright (C) 2007-2008 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2009 Dale Whittaker <dayul@users.sf.net>
-
- 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_UTILS_H__
-#define __KATZE_UTILS_H__
-
-#include <gtk/gtk.h>
-#include "katze-array.h"
-#include "gtk3-compat.h"
-
-G_BEGIN_DECLS
-
-/**
- * katze_assign:
- * @lvalue: a pointer
- * @rvalue: the new value
- *
- * Frees @lvalue if needed and assigns it the value of @rvalue.
- **/
-#define katze_assign(lvalue, rvalue) lvalue = (g_free (lvalue), rvalue)
-
-/**
- * katze_object_assign:
- * @lvalue: a gobject
- * @rvalue: the new value
- *
- * Unrefs @lvalue if needed and assigns it the value of @rvalue.
- **/
-#define katze_object_assign(lvalue, rvalue) \
- lvalue = ((lvalue ? g_object_unref (lvalue) : (void)0), rvalue)
-
-/**
- * katze_strv_assign:
- * @lvalue: a string list
- * @rvalue: the new value
- *
- * Frees @lvalue if needed and assigns it the value of @rvalue.
- *
- * Since: 0.1.7
- **/
-#define katze_strv_assign(lvalue, rvalue) lvalue = (g_strfreev (lvalue), rvalue)
-
-/**
- * katze_str_non_null:
- * @str: a string, or %NULL
- *
- * Returns "" if @str is %NULL.
- *
- * Since: 0.4.4
- **/
-static inline const gchar*
-katze_str_non_null (const gchar* str)
-{
- return str ? str : "";
-}
-
-GtkWidget*
-katze_property_proxy (gpointer object,
- const gchar* property,
- const gchar* hint);
-
-typedef enum {
- KATZE_MENU_POSITION_CURSOR = 0,
- KATZE_MENU_POSITION_LEFT,
- KATZE_MENU_POSITION_RIGHT
-} KatzeMenuPos;
-
-void
-katze_widget_popup (GtkWidget* widget,
- GtkMenu* menu,
- GdkEventButton* event,
- KatzeMenuPos pos);
-
-GtkWidget*
-katze_image_menu_item_new_ellipsized (const gchar* label);
-
-gboolean
-katze_tree_view_get_selected_iter (GtkTreeView* treeview,
- GtkTreeModel** model,
- GtkTreeIter* iter);
-
-void
-katze_bookmark_populate_tree_view (KatzeArray* array,
- GtkTreeStore* model,
- GtkTreeIter* parent);
-
-gchar*
-katze_strip_mnemonics (const gchar* original);
-
-const gchar*
-katze_skip_whitespace (const gchar* str);
-
-gint
-katze_object_get_boolean (gpointer object,
- const gchar* property);
-
-gint
-katze_object_get_int (gpointer object,
- const gchar* property);
-
-gint
-katze_object_get_enum (gpointer object,
- const gchar* property);
-
-gchar*
-katze_object_get_string (gpointer object,
- const gchar* property);
-
-gpointer
-katze_object_get_object (gpointer object,
- const gchar* property);
-
-int
-katze_mkdir_with_parents (const gchar* pathname,
- int mode);
-
-GtkWidget*
-katze_uri_entry_new (GtkWidget* other_widget);
-
-void
-katze_widget_add_class (GtkWidget* widget,
- const gchar* class_name);
-
-void
-katze_assert_str_equal (const gchar* input,
- const gchar* result,
- const gchar* expected);
-
-void
-katze_window_set_sensible_default_size (GtkWindow* window);
-
-G_END_DECLS
-
-#endif /* __KATZE_UTILS_H__ */
diff --git a/katze/katze.h b/katze/katze.h
deleted file mode 100644
index 6518b659..00000000
--- a/katze/katze.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- Copyright (C) 2007-2009 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_H__
-#define __KATZE_H__
-
-#include "katze-http-auth.h"
-#include "katze-utils.h"
-#include "katze-item.h"
-#include "katze-array.h"
-#include "katze-arrayaction.h"
-#include "katze-preferences.h"
-
-#ifndef HAVE_WEBKIT2
- #include <webkit/webkit.h>
-#else
- #include <webkit2/webkit2.h>
-#endif
-
-#endif /* __KATZE_H__ */
diff --git a/katze/katze.vapi b/katze/katze.vapi
deleted file mode 100644
index f53df7f5..00000000
--- a/katze/katze.vapi
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright (C) 2012 André Stösel <andre@stoesel.de>
- This file is licensed under the terms of the expat license, see the file EXPAT. */
-
-[CCode (cprefix = "Katze", lower_case_cprefix = "katze_")]
-namespace Katze {
- static void assert_str_equal (string input, string result, string? expected);
- static unowned Gtk.Widget property_proxy (void* object, string property, string? hint);
- [CCode (cheader_filename = "katze/katze.h", cprefix = "KATZE_MENU_POSITION_")]
- enum MenuPos {
- CURSOR,
- LEFT,
- RIGHT
- }
- static void widget_popup (Gtk.Widget? widget, Gtk.Menu menu, Gdk.EventButton? event, MenuPos pos);
-
- [CCode (cheader_filename = "katze/katze.h")]
- public class Array : Katze.Item {
- public Array (GLib.Type type);
- public signal void add_item (GLib.Object item);
- public signal void remove_item (GLib.Object item);
- public uint get_length ();
- public GLib.List<unowned Item> get_items ();
- public bool is_empty ();
- }
-
- [CCode (cheader_filename = "katze/katze.h")]
- public class Item : GLib.Object {
- public Item ();
- public string? uri { get; set; }
- public string? name { get; set; }
- public string? text { get; set; }
-
- public bool get_meta_boolean (string key);
- public int64 get_meta_integer (string key);
- public void set_meta_integer (string key, int64 value);
- public unowned string? get_meta_string (string key);
- public void set_meta_string (string key, string value);
- }
-
- [CCode (cheader_filename = "katze/katze.h")]
- public class Preferences : Gtk.Dialog {
- public unowned Gtk.Box add_category (string label, string icon);
- public void add_group (string? label);
- public void add_widget (Gtk.Widget widget, string type);
- }
-}
-
diff --git a/katze/midori-hsts.vala b/katze/midori-hsts.vala
deleted file mode 100644
index 16a0d5f6..00000000
--- a/katze/midori-hsts.vala
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- Copyright (C) 2012 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.
-*/
-
-namespace Midori {
- [CCode (cname = "g_hostname_is_ip_address")]
- extern bool hostname_is_ip_address (string hostname);
-
- public class HSTS : GLib.Object, Soup.SessionFeature {
- public class Directive {
- public Soup.Date? expires = null;
- public bool sub_domains = false;
-
- public Directive (string max_age, bool include_sub_domains) {
- expires = new Soup.Date.from_string (max_age);
- sub_domains = include_sub_domains;
- }
-
- public Directive.from_header (string header) {
- var param_list = Soup.header_parse_param_list (header);
- if (param_list == null)
- return;
-
- string? max_age = param_list.lookup ("max-age");
- if (max_age == null)
- return;
-
- if (max_age != null) {
- int val = max_age.to_int ();
- if (val != 0)
- expires = new Soup.Date.from_now (val);
- }
-
- if ("includeSubDomains" in header)
- sub_domains = true;
-
- Soup.header_free_param_list (param_list);
- }
-
- public bool is_expired () {
- return expires.is_past ();
- }
-
- public bool is_valid () {
- // The max-age parameter is *required*
- return expires != null;
- }
- }
-
- HashTable<string, Directive> whitelist;
- bool debug = false;
-
- public HSTS () {
- whitelist = new HashTable<string, Directive> (str_hash, str_equal);
- read_cache.begin (File.new_for_path (Paths.get_preset_filename (null, "hsts")));
- read_cache.begin (File.new_for_path (Paths.get_config_filename_for_reading ("hsts")));
- if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "hsts") == 0)
- debug = true;
- }
-
- async void read_cache (File file) {
- try {
- var stream = new DataInputStream (yield file.read_async ());
- do {
- string? line = yield stream.read_line_async ();
- if (line == null)
- break;
-
- // hostname ' ' expiration-date ' ' allow-subdomains <y|n>
- string[] parts = line.split (" ", 3);
- if (parts[0] == null || parts[1] == null || parts[2] == null)
- continue;
-
- var host = parts[0]._strip ();
- var expire = parts[1]._strip ();
- var allow_subdomains = bool.parse (parts[2]._strip ());
-
- var directive = new Directive (expire, allow_subdomains);
- if (directive.is_valid () && !directive.is_expired ()) {
- if (debug)
- stdout.printf ("HSTS: loading rule for %s\n", host);
- whitelist_append (host, directive);
- }
- } while (true);
- }
- catch (Error error) { }
- }
-
- void queued (Soup.Session session, Soup.Message message) {
- /* Only trust the HSTS headers sent over a secure connection */
- if (message.uri.scheme == "https") {
- message.finished.connect (strict_transport_security_handled);
- }
- else if (whitelist_lookup (message.uri.host)) {
- message.uri.set_scheme ("https");
- session.requeue_message (message);
- if (debug)
- stdout.printf ("HSTS: Enforce %s\n", message.uri.host);
- }
- }
-
- bool whitelist_lookup (string host) {
- Directive? directive = null;
- bool is_subdomain = false;
-
- if (hostname_is_ip_address (host))
- return false;
-
- // try an exact match first
- directive = whitelist.lookup (host);
-
- // no luck, try walking the domain tree
- if (directive == null) {
- int offset = 0;
- for (offset = host.index_of_char ('.', offset) + 1;
- offset > 0;
- offset = host.index_of_char ('.', offset) + 1) {
- string component = host.substring(offset);
-
- directive = whitelist.lookup (component);
- if (directive != null) {
- is_subdomain = true;
- break;
- }
- }
- }
-
- return directive != null &&
- !directive.is_expired () &&
- (is_subdomain? directive.sub_domains: true);
- }
-
- void whitelist_append (string host, Directive directive) {
- whitelist.insert (host, directive);
- }
-
- void whitelist_remove (string host) {
- whitelist.remove(host);
- }
-
- async void whitelist_serialize () {
- if (Midori.Paths.is_readonly ())
- return;
-
- string filename = Paths.get_config_filename_for_writing ("hsts");
- try {
- var file = File.new_for_path (filename);
- var stream = file.replace (null, false, FileCreateFlags.NONE);
-
- foreach (string host in whitelist.get_keys ()) {
- var directive = whitelist.lookup (host);
-
- // Don't serialize the expired directives
- if (directive.is_expired ())
- continue;
-
- yield stream.write_async (("%s %s %s\n".printf (host,
- directive.expires.to_string (Soup.DateFormat.ISO8601_COMPACT),
- directive.sub_domains.to_string ())).data);
- }
- yield stream.flush_async ();
- }
- catch (Error error) {
- critical ("Failed to update %s: %s", filename, error.message);
- }
- }
-
- void strict_transport_security_handled (Soup.Message message) {
- if (message == null || message.uri == null)
- return;
-
- unowned string? hsts = message.response_headers.get_one ("Strict-Transport-Security");
- if (hsts == null)
- return;
-
- var directive = new Directive.from_header (hsts);
-
- if (debug)
- stdout.printf ("HSTS: '%s' sets '%s' valid? %s\n",
- message.uri.host, hsts, directive.is_valid ().to_string ());
-
- if (directive.is_valid ())
- whitelist_append (message.uri.host, directive);
- else
- whitelist_remove (message.uri.host);
-
-
- whitelist_serialize.begin ();
- }
-
- /* No sub-features */
- public bool add_feature (Type type) { return false; }
- public bool remove_feature (Type type) { return false; }
- public bool has_feature (Type type) { return false; }
-
- public void attach (Soup.Session session) { session.request_queued.connect (queued); }
- public void detach (Soup.Session session) { /* FIXME disconnect */ }
-
- /* Never called but required by the interface */
- public void request_started (Soup.Session session, Soup.Message msg, Soup.Socket socket) { }
- public void request_queued (Soup.Session session, Soup.Message message) { }
- public void request_unqueued (Soup.Session session, Soup.Message msg) { }
- }
-}
diff --git a/katze/midori-paths.vala b/katze/midori-paths.vala
deleted file mode 100644
index bdd054db..00000000
--- a/katze/midori-paths.vala
+++ /dev/null
@@ -1,491 +0,0 @@
-/*
- Copyright (C) 2012 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.
-*/
-
-namespace GLib {
- #if HAVE_WIN32
- extern static string win32_get_package_installation_directory_of_module (void* hmodule = null);
- #endif
-}
-
-extern const string LIBDIR;
-extern const string MDATADIR;
-extern const string PACKAGE_NAME;
-extern const string SYSCONFDIR;
-extern const string MIDORI_VERSION_SUFFIX;
-const string MODULE_PREFIX = "lib";
-const string MODULE_SUFFIX = "." + GLib.Module.SUFFIX;
-
-namespace Midori {
- public enum RuntimeMode {
- UNDEFINED,
- NORMAL,
- APP,
- PRIVATE,
- PORTABLE
- }
-
- namespace Paths {
- static string? exec_path = null;
- static string[] command_line = null;
- static string? runtime_dir = null;
- static RuntimeMode mode = RuntimeMode.UNDEFINED;
-
- static string? config_dir = null;
- static string? readonly_dir = null;
- static string? cache_dir = null;
- static string? cache_dir_for_reading = null;
- static string? user_data_dir = null;
- static string? user_data_dir_for_reading = null;
- static string? tmp_dir = null;
-
- namespace Test {
- public void reset_runtime_mode () {
- mode = RuntimeMode.UNDEFINED;
- }
- }
-
- public static string get_config_dir_for_reading () {
- assert (mode != RuntimeMode.UNDEFINED);
- return readonly_dir ?? config_dir;
- }
-
- /* returns the path to a user configuration file whose contents should not be modified.
- to get the path to save settings, use get_config_filename() */
- public static string get_config_filename_for_reading (string filename) {
- assert (mode != RuntimeMode.UNDEFINED);
- return Path.build_path (Path.DIR_SEPARATOR_S,
- readonly_dir ?? config_dir, filename);
- }
-
- public bool is_readonly () {
- assert (mode != RuntimeMode.UNDEFINED);
- return readonly_dir != null;
- }
-
- public RuntimeMode get_runtime_mode () {
- assert (mode != RuntimeMode.UNDEFINED);
- return mode;
- }
-
- public static unowned string get_runtime_dir () {
- if (runtime_dir != null)
- return runtime_dir;
-
- #if HAVE_WIN32
- runtime_dir = Environment.get_variable ("XDG_RUNTIME_DIR");
- if (runtime_dir == null || runtime_dir == "")
- runtime_dir = Environment.get_user_data_dir ();
- #else
- runtime_dir = Environment.get_variable ("XDG_RUNTIME_DIR");
- if (runtime_dir == null || runtime_dir == "") {
- runtime_dir = Path.build_path (Path.DIR_SEPARATOR_S,
- Environment.get_tmp_dir (), PACKAGE_NAME + "-" + Environment.get_user_name ());
- mkdir_with_parents (runtime_dir);
- return runtime_dir;
- }
- #endif
- runtime_dir = Path.build_path (Path.DIR_SEPARATOR_S, runtime_dir, PACKAGE_NAME);
- mkdir_with_parents (runtime_dir);
- return runtime_dir;
- }
-
- public static void init (RuntimeMode new_mode, string? config) {
- assert (mode == RuntimeMode.UNDEFINED);
- assert (new_mode != RuntimeMode.UNDEFINED);
- mode = new_mode;
- if (mode == RuntimeMode.PORTABLE || mode == RuntimeMode.PRIVATE)
- Gtk.Settings.get_default ().gtk_recent_files_max_age = 0;
- if (mode == RuntimeMode.PORTABLE) {
- config_dir = Path.build_path (Path.DIR_SEPARATOR_S,
- exec_path, "profile", "config");
- cache_dir = Path.build_path (Path.DIR_SEPARATOR_S,
- exec_path, "profile", "cache");
- user_data_dir = Path.build_path (Path.DIR_SEPARATOR_S,
- exec_path, "profile", "misc");
- tmp_dir = Path.build_path (Path.DIR_SEPARATOR_S,
- exec_path, "profile", "tmp");
- }
- else if (mode == RuntimeMode.APP) {
- config_dir = Path.build_path (Path.DIR_SEPARATOR_S,
- Environment.get_user_data_dir (), PACKAGE_NAME, "apps",
- Checksum.compute_for_string (ChecksumType.MD5, config, -1));
- cache_dir = Path.build_path (Path.DIR_SEPARATOR_S,
- Environment.get_user_cache_dir (), PACKAGE_NAME);
- user_data_dir = Environment.get_user_data_dir ();
- user_data_dir_for_reading = Environment.get_user_data_dir ();
- tmp_dir = get_runtime_dir ();
- }
- else if (mode == RuntimeMode.PRIVATE) {
- string? real_config = config != null && !Path.is_absolute (config)
- ? Path.build_filename (Environment.get_current_dir (), config) : config;
- readonly_dir = real_config ?? Path.build_path (Path.DIR_SEPARATOR_S,
- Environment.get_user_config_dir (), PACKAGE_NAME);
- cache_dir_for_reading = Path.build_path (Path.DIR_SEPARATOR_S,
- Environment.get_user_cache_dir (), PACKAGE_NAME);
- user_data_dir_for_reading = Environment.get_user_data_dir ();
- tmp_dir = get_runtime_dir ();
- }
- else {
-#if HAVE_WEBKIT2_3_91
- /* Allow WebKit to spawn more than one rendering process */
- if (!("wk2:no-multi-render-process" in (Environment.get_variable ("MIDORI_DEBUG") ?? "")))
- WebKit.WebContext.get_default ().set_process_model (WebKit.ProcessModel.MULTIPLE_SECONDARY_PROCESSES);
-#endif
- string? real_config = config != null && !Path.is_absolute (config)
- ? Path.build_filename (Environment.get_current_dir (), config) : config;
- config_dir = real_config ?? Path.build_path (Path.DIR_SEPARATOR_S,
- Environment.get_user_config_dir (), PACKAGE_NAME);
- cache_dir = Path.build_path (Path.DIR_SEPARATOR_S,
- Environment.get_user_cache_dir (), PACKAGE_NAME);
- user_data_dir = Environment.get_user_data_dir ();
- tmp_dir = get_runtime_dir ();
- }
-#if HAVE_WEBKIT2
- if (cache_dir != null) {
- /* Cache and extension dir MUST be set no later than here to work */
- WebKit.WebContext.get_default ().set_web_extensions_directory (
- Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "wk2ext"));
- WebKit.WebContext.get_default ().set_disk_cache_directory (
- Path.build_path (Path.DIR_SEPARATOR_S, cache_dir, "web"));
- }
-
- if (config_dir != null) {
- var cookie_manager = WebKit.WebContext.get_default ().get_cookie_manager ();
- cookie_manager.set_persistent_storage (Path.build_filename (config_dir, "cookies.db"),
- WebKit.CookiePersistentStorage.SQLITE);
- }
-#endif
- if (user_data_dir != null) {
- string folder = Path.build_filename (user_data_dir, "webkit", "icondatabase");
-#if HAVE_WEBKIT2
- WebKit.WebContext.get_default ().set_favicon_database_directory (folder);
-#else
- WebKit.get_favicon_database ().set_path (folder);
-#endif
- }
- else
- {
-#if HAVE_WEBKIT2
- /* with wk2 set_favicon_database_directory can only be called once and actually
- initializes and enables the favicon database, so we do not call it in this case */
-#else
- /* wk1 documentation claims that the favicon database is not enabled unless
- a call to favicon_database.set_path is made, but in fact it must be explicitly
- disabled by setting to null (verified as of webkitgtk 2.3.1) */
- WebKit.get_favicon_database ().set_path (null);
-#endif
- }
-
- #if !HAVE_WIN32
- Gtk.IconTheme.get_default ().append_search_path (exec_path);
- #endif
-
- if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "paths") == 0) {
- stdout.printf ("config: %s\ncache: %s\nuser_data: %s\ntmp: %s\n",
- config_dir, cache_dir, user_data_dir, tmp_dir);
- }
- }
-
- public static void mkdir_with_parents (string path, int mode = 0700) {
- if (GLib.FileUtils.test (path, GLib.FileTest.EXISTS))
- return;
- int i = path.index_of_char (Path.DIR_SEPARATOR, 0);
- do {
- string fn = path.substring (i, -1);
- if (!GLib.FileUtils.test (path, GLib.FileTest.EXISTS)) {
- if (DirUtils.create (fn, mode) == -1) {
- /* Slow fallback; if this fails we fail */
- DirUtils.create_with_parents (path, mode);
- return;
- }
- }
- else if (!FileUtils.test (fn, FileTest.IS_SYMLINK))
- return; /* Failed */
-
- i = path.index_of_char (Path.DIR_SEPARATOR, i);
- }
- while (i != -1);
- }
-
- public static void remove_path (string path) {
- try {
- var dir = Dir.open (path, 0);
- string? name;
- while (true) {
- name = dir.read_name ();
- if (name == null)
- break;
- remove_path (Path.build_filename (path, name));
- }
- }
- catch (Error error) {
- FileUtils.remove (path);
- }
- }
-
- public static unowned string get_config_dir_for_writing () {
- assert (config_dir != null);
- mkdir_with_parents (config_dir);
- return config_dir;
- }
-
- public static string get_extension_config_dir (string extension) {
- assert (config_dir != null);
- string folder;
- if ("." in extension)
- folder = Path.build_filename (config_dir, "extensions", extension);
- else
- folder = Path.build_filename (config_dir, "extensions",
- MODULE_PREFIX + extension + "." + GLib.Module.SUFFIX);
- mkdir_with_parents (folder);
- return folder;
- }
-
- public static string get_extension_preset_filename (string extension, string filename) {
- assert (exec_path != null);
- string preset_filename = extension;
- if (extension.has_prefix (MODULE_PREFIX))
- preset_filename = extension.split (MODULE_PREFIX)[1];
- if (extension.has_suffix (MODULE_SUFFIX))
- preset_filename = preset_filename.split (MODULE_SUFFIX)[0];
- return get_preset_filename (Path.build_filename ("extensions", preset_filename), filename);
- }
-
- /* returns the path to a user configuration file to which it is permitted to write.
- this is also necessary for files whose state is synchronized to disk by a manager,
- e.g. cookies. */
- public static string get_config_filename_for_writing (string filename) {
- assert (mode != RuntimeMode.UNDEFINED);
- assert (config_dir != null);
- mkdir_with_parents (config_dir);
- return Path.build_path (Path.DIR_SEPARATOR_S, config_dir, filename);
- }
-
- public static unowned string get_cache_dir () {
- assert (cache_dir != null);
- return cache_dir;
- }
-
- public static unowned string get_user_data_dir () {
- assert (user_data_dir != null);
- return user_data_dir;
- }
-
- public static unowned string get_user_data_dir_for_reading () {
- assert (user_data_dir_for_reading != null || user_data_dir != null);
- if (user_data_dir != null)
- return user_data_dir;
- return user_data_dir_for_reading;
- }
-
- public static unowned string get_cache_dir_for_reading () {
- assert (cache_dir_for_reading != null || cache_dir != null);
- if (cache_dir != null)
- return cache_dir;
- return cache_dir_for_reading;
- }
-
- public static unowned string get_tmp_dir () {
- assert (tmp_dir != null);
- return tmp_dir;
- }
-
- public static string make_tmp_dir (string tmpl) {
- assert (tmp_dir != null);
- try {
- mkdir_with_parents (GLib.Environment.get_tmp_dir ());
- return DirUtils.make_tmp (tmpl);
- }
- catch (Error error) {
- GLib.error (error.message);
- }
- }
-
- public static void init_exec_path (string[] new_command_line) {
- assert (command_line == null);
- command_line = new_command_line;
- #if HAVE_WIN32
- exec_path = Environment.get_variable ("MIDORI_EXEC_PATH") ??
- win32_get_package_installation_directory_of_module ();
- #else
- string? executable;
- try {
- if (!Path.is_absolute (command_line[0])) {
- string program = Environment.find_program_in_path (command_line[0]);
- if (FileUtils.test (program, FileTest.IS_SYMLINK))
- executable = FileUtils.read_link (program);
- else
- executable = program;
- }
- else
- executable = FileUtils.read_link (command_line[0]);
- }
- catch (Error error) {
- executable = command_line[0];
- }
-
- exec_path = File.new_for_path (executable).get_parent ().get_parent ().get_path ();
- #endif
- if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "paths") == 0) {
- stdout.printf ("command_line: %s\nexec_path: %s\nres: %s\nlib: %s\n",
- get_command_line_str (true), exec_path,
- get_res_filename ("about.css"), get_lib_path (PACKAGE_NAME));
- }
- }
-
- public static unowned string[] get_command_line () {
- assert (command_line != null);
- return command_line;
- }
-
- public static string get_command_line_str (bool for_display) {
- assert (command_line != null);
- if (for_display)
- return string.joinv (" ", command_line).replace (Environment.get_home_dir (), "~");
- return string.joinv (" ", command_line).replace ("--debug", "").replace ("-g", "")
- .replace ("--diagnostic-dialog", "").replace ("-d", "");
- }
-
- public static string get_lib_path (string package) {
- assert (command_line != null);
- #if HAVE_WIN32
- return Path.build_filename (exec_path, "lib", package);
- #else
- string path = Path.build_filename (exec_path, "lib", package);
- if (GLib.FileUtils.test (path, GLib.FileTest.EXISTS))
- return path;
-
- if (package == PACKAGE_NAME) {
- /* Fallback to build folder */
- path = Path.build_filename ((File.new_for_path (exec_path).get_path ()), "extensions");
- if (GLib.FileUtils.test (path, GLib.FileTest.EXISTS))
- return path;
- }
-
- return Path.build_filename (LIBDIR, PACKAGE_NAME);
- #endif
- }
-
- public static string get_res_filename (string filename) {
- assert (command_line != null);
- assert (filename != "");
- #if HAVE_WIN32
- return Path.build_filename (exec_path, "share", PACKAGE_NAME, "res", filename);
- #else
- string path = Path.build_filename (exec_path, "share", PACKAGE_NAME, "res", filename);
- if (GLib.FileUtils.test (path, GLib.FileTest.EXISTS))
- return path;
-
- return build_folder ("data", null, filename) ??
- Path.build_filename (MDATADIR, PACKAGE_NAME, "res", filename);
- #endif
- }
-
- #if !HAVE_WIN32
- string? build_folder (string folder, string? middle, string filename) {
- /* Fallback to build folder */
- File? parent = File.new_for_path (exec_path);
- while (parent != null) {
- var data = parent.get_child (folder);
- if (middle != null)
- data = data.get_child (middle);
- var child = data.get_child (filename);
- if (child.query_exists ())
- return child.get_path ();
- parent = parent.get_parent ();
- }
- return null;
- }
- #endif
-
- /* returns the path to a file containing read-only data installed with the application
- if @res is true, looks in the midori resource folder specifically */
- public static string get_data_filename (string filename, bool res) {
- assert (command_line != null);
- string res1 = res ? PACKAGE_NAME : "";
- string res2 = res ? "res" : "";
-
- #if HAVE_WIN32
- return Path.build_filename (exec_path, "share", res1, res2, filename);
- #else
- string path = Path.build_filename (get_user_data_dir_for_reading (), res1, res2, filename);
- if (GLib.FileUtils.test (path, GLib.FileTest.EXISTS))
- return path;
-
- foreach (unowned string data_dir in Environment.get_system_data_dirs ()) {
- path = Path.build_filename (data_dir, res1, res2, filename);
- if (GLib.FileUtils.test (path, GLib.FileTest.EXISTS))
- return path;
- }
-
- return Path.build_filename (MDATADIR, res1, res2, filename);
- #endif
- }
-
- /* returns the path to a file containing system default configuration */
- public static string get_preset_filename (string? folder, string filename) {
- assert (exec_path != null);
-
- #if HAVE_WIN32
- return Path.build_filename (exec_path, "etc", "xdg", PACKAGE_NAME, folder ?? "", filename);
- #else
- foreach (unowned string config_dir in Environment.get_system_config_dirs ()) {
- string path = Path.build_filename (config_dir, PACKAGE_NAME, folder ?? "", filename);
- if (GLib.FileUtils.test (path, GLib.FileTest.EXISTS))
- return path;
- }
-
- return build_folder ("config", folder, filename) ??
- Path.build_filename (SYSCONFDIR, "xdg", PACKAGE_NAME, folder ?? "", filename);
- #endif
- }
-
- public static void clear_icons () {
- assert (cache_dir != null);
- assert (user_data_dir != null);
-#if HAVE_WEBKIT2
- WebKit.WebContext.get_default ().get_favicon_database ().clear ();
-#else
- WebKit.get_favicon_database ().clear ();
-#endif
- /* FIXME: Exclude search engine icons */
- remove_path (Path.build_filename (user_data_dir, "webkit", "icondatabase"));
- }
-
- /**
- * Looks up a pixbuf for the given @uri. If @widget is given a generic
- * file icon is used in case there's no icon.
- *
- * Deprecated: 0.5.8: Use Midori.URI.Icon or Midori.URI.get_icon instead.
- **/
- public static Gdk.Pixbuf? get_icon (string? uri, Gtk.Widget? widget) {
- if (!Midori.URI.is_resource (uri))
- return null;
- int icon_width = 16, icon_height = 16;
- if (widget != null)
- Gtk.icon_size_lookup_for_settings (widget.get_settings (),
- Gtk.IconSize.MENU, out icon_width, out icon_height);
- else
- icon_width = icon_height = 0 /* maximum size */;
-#if HAVE_WEBKIT2
- /* There is no sync API for WebKit2 */
-#else
- Gdk.Pixbuf? pixbuf = WebKit.get_favicon_database ()
- .try_get_favicon_pixbuf (uri, icon_width, icon_height);
- if (pixbuf != null)
- return pixbuf;
-#endif
- if (widget != null)
- return widget.render_icon (Gtk.STOCK_FILE, Gtk.IconSize.MENU, null);
- return null;
- }
- }
-}
diff --git a/katze/midori-uri.vala b/katze/midori-uri.vala
deleted file mode 100644
index f4b08811..00000000
--- a/katze/midori-uri.vala
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- Copyright (C) 2011 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.
-*/
-
-namespace GLib {
- extern static string hostname_to_unicode (string hostname);
- extern static string hostname_to_ascii (string hostname);
-}
-
-namespace Midori {
- public class URI : Object {
- static string? fork_uri = null;
-
- public static string? parse_hostname (string? uri, out string path) {
- path = null;
- if (uri == null)
- return uri;
- unowned string? hostname = uri.chr (-1, '/');
- if (hostname == null || hostname[1] != '/'
- || hostname.chr (-1, ' ') != null)
- return null;
- hostname = hostname.offset (2);
- if ((path = hostname.chr (-1, '/')) != null)
- return hostname.split ("/")[0];
- return hostname;
- }
- /* Deprecated: 0.4.3 */
- public static string parse (string uri, out string path) {
- return parse_hostname (uri, out path) ?? uri;
- }
- public static string to_ascii (string uri) {
- /* Convert hostname to ASCII. */
- string? proto = null;
- if (uri.chr (-1, '/') != null && uri.chr (-1, ':') != null)
- proto = uri.split ("://")[0];
- string? path = null;
- string? hostname = parse_hostname (uri, out path) ?? uri;
- string encoded = hostname_to_ascii (hostname);
- if (encoded != null) {
- return (proto ?? "")
- + (proto != null ? "://" : "")
- + encoded + path;
- }
- return uri;
- }
- public static string get_base_domain (string uri) {
-#if HAVE_LIBSOUP_2_40_0
- try {
- string ascii = to_ascii (uri);
- return Soup.tld_get_base_domain (ascii);
- } catch (Error error) {
- /* This is fine, we fallback to hostname */
- }
-#endif
- return parse_hostname (uri, null);
- }
-
- public static string unescape (string uri_str) {
- /* We cannot use g_uri_unescape_string, because it returns NULL if it
- encounters the sequence '%00', whereas the goal of this function is
- to unescape all escape sequences except %00, %0A, %0D, %20, and %25 */
- size_t len = uri_str.length;
- uint8[] uri = uri_str.data;
- var escaped = new StringBuilder();
- for (var i=0; i < len; i++)
- {
- uint8 c = uri[i];
- if (c == '%')
- {
- /* only unescape if there are enough chars for a valid escape sequence */
- if (i + 2 < len)
- {
- var x1 = ((char)uri[i+1]).xdigit_value();
- var x2 = ((char)uri[i+2]).xdigit_value();
- var x = (x1<<4) + x2;
- /* if the escape is valid and the character should be unescaped */
- if (x1 >= 0 && x2 >= 0 && x != '\0' && x != '\n' && x != '\r' && x != ' ' && x != '%')
- {
- /* consume the encoded characters */
- c = (uint8)x;
- i += 2;
- }
- }
- }
- escaped.append_c((char)c);
- }
- return escaped.str;
- }
-
- /* Strip http(s), file and www. for tab titles or completion */
- public static string strip_prefix_for_display (string uri) {
- if (is_http (uri) || uri.has_prefix ("file://")) {
- string stripped_uri = uri.split ("://")[1];
- if (is_http (uri) && stripped_uri.has_prefix ("www."))
- return stripped_uri.substring (4, -1);
- return stripped_uri;
- }
- return uri;
- }
-
- public static string format_for_display (string? uri) {
- /* Percent-decode and decode puniycode for user display */
- if (uri != null && uri.has_prefix ("http://")) {
- string unescaped = unescape (uri).replace(" ", "%20");
- if (!unescaped.validate ())
- return uri;
- string path;
- string? hostname = parse_hostname (unescaped, out path);
- if (hostname != null) {
- string decoded = hostname_to_unicode (hostname);
- if (decoded != null)
- return "http://" + decoded + path;
- }
- return unescaped;
- }
- return uri;
- }
- public static string for_search (string? uri, string keywords) {
- /* Take a search engine URI and insert specified keywords.
- Keywords are percent-encoded. If the uri contains a %s
- the keywords are inserted there, otherwise appended. */
- if (uri == null)
- return keywords;
- string escaped = GLib.Uri.escape_string (keywords, ":/", true);
- /* Allow DuckDuckGo to distinguish Midori and in turn share revenue */
- if (uri == "https://duckduckgo.com/?q=%s")
- return "https://duckduckgo.com/?q=%s&t=midori".printf (escaped);
- if (uri.str ("%s") != null)
- return uri.printf (escaped);
- return uri + escaped;
- }
- public static bool is_blank (string? uri) {
- return !(uri != null && uri != "" && !uri.has_prefix ("about:"));
- }
- public static bool is_http (string? uri) {
- return uri != null
- && (uri.has_prefix ("http://") || uri.has_prefix ("https://"));
- }
- public static bool is_resource (string? uri) {
- return uri != null
- && (is_http (uri)
- || (uri.has_prefix ("data:") && uri.chr (-1, ';') != null));
- }
- public static bool is_location (string? uri) {
- /* file:// is not considered a location for security reasons */
- return uri != null
- && ((uri.str ("://") != null && uri.chr (-1, ' ') == null)
- || is_http (uri)
- || uri.has_prefix ("about:")
- || (uri.has_prefix ("data:") && uri.chr (-1, ';') != null)
- || (uri.has_prefix ("geo:") && uri.chr (-1, ',') != null)
- || uri.has_prefix ("javascript:"));
- }
-
- public static bool is_ip_address (string? uri) {
- /* Quick check for IPv4 or IPv6, no validation.
- FIXME: Schemes are not handled
- hostname_is_ip_address () is not used because
- we'd have to separate the path from the URI first. */
- if (uri == null)
- return false;
- /* Skip leading user/ password */
- if (uri.chr (-1, '@') != null)
- return is_ip_address (uri.split ("@")[1]);
- /* IPv4 */
- if (uri[0] != '0' && uri[0].isdigit () && (uri.chr (4, '.') != null))
- return true;
- /* IPv6 */
- if (uri[0].isalnum () && uri[1].isalnum ()
- && uri[2].isalnum () && uri[3].isalnum () && uri[4] == ':'
- && (uri[5] == ':' || uri[5].isalnum ()))
- return true;
- return false;
- }
- public static bool is_valid (string? uri) {
- return uri != null
- && uri.chr (-1, ' ') == null
- && (URI.is_location (uri) || uri.chr (-1, '.') != null);
- }
-
- public static string? get_folder (string uri) {
- /* Base the start folder on the current view's uri if it is local */
- try {
- string? filename = Filename.from_uri (uri);
- if (filename != null) {
- string? dirname = Path.get_dirname (filename);
- if (dirname != null && FileUtils.test (dirname, FileTest.IS_DIR))
- return dirname;
- }
- }
- catch (Error error) { }
- return null;
- }
-
- public static GLib.ChecksumType get_fingerprint (string uri,
- out string checksum, out string label) {
-
- /* http://foo.bar/baz/spam.eggs#!algo!123456 */
- unowned string display = null;
- GLib.ChecksumType type = (GLib.ChecksumType)int.MAX;
-
- unowned string delimiter = "#!md5!";
- unowned string? fragment = uri.str (delimiter);
- if (fragment != null) {
- display = _("MD5-Checksum:");
- type = GLib.ChecksumType.MD5;
- }
-
- delimiter = "#!sha1!";
- fragment = uri.str (delimiter);
- if (fragment != null) {
- display = _("SHA1-Checksum:");
- type = GLib.ChecksumType.SHA1;
- }
-
- /* No SHA256: no known usage and no need for strong encryption */
-
- checksum = fragment != null ? fragment.offset (delimiter.length) : null;
- label = display;
- return type;
- }
-
- /*
- Protects against recursive invokations of Midori with the same URI.
- Consider a tel:// URI opened via Tab.open_uri, being handed off to GIO,
- which in turns calls exo-open, which in turn can't open tel:// and falls
- back to the browser ie. Midori.
- So: code opening URIs calls this function with %true, #Midori.App passes %false.
-
- Since: 0.5.8
- */
- public static bool recursive_fork_protection (string uri, bool set_uri) {
- if (set_uri)
- fork_uri = uri;
- return fork_uri != uri;
- }
-
- /**
- * Returns a Glib.Icon for the given @uri.
- *
- * Since: 0.5.8
- **/
- public static async GLib.Icon? get_icon (string uri, Cancellable? cancellable=null) throws Error {
-#if HAVE_WEBKIT2
- var database = WebKit.WebContext.get_default ().get_favicon_database ();
- var surface = yield database.get_favicon (uri, cancellable);
- var image = (Cairo.ImageSurface)surface;
- var pixbuf = Gdk.pixbuf_get_from_surface (image, 0, 0, image.get_width (), image.get_height ());
-#else
- var database = WebKit.get_favicon_database ();
- // We must not pass a Cancellable due to a crasher bug
- var pixbuf = yield database.get_favicon_pixbuf (uri, 0, 0, null);
-#endif
- return pixbuf as GLib.Icon;
- }
-
- /**
- * Returns a Glib.Icon for the given @uri or falls back to @fallback.
- *
- * Since: 0.5.8
- **/
- public static async GLib.Icon? get_icon_fallback (string uri, GLib.Icon? fallback=null, Cancellable? cancellable=null) {
- try {
- return yield get_icon (uri, cancellable);
- } catch (Error error) {
- debug ("Icon failed to load: %s", error.message);
- return fallback;
- }
- }
-
- /**
- * A Glib.Icon subclass that loads the icon for a given URI.
- * In the case of an error @fallback will be used.
- *
- * Since: 0.5.8
- **/
- public class Icon : InitiallyUnowned, GLib.Icon, LoadableIcon {
- public string uri { get; private set; }
- public GLib.Icon? fallback { get; private set; }
- InputStream? stream = null;
- public Icon (string website_uri, GLib.Icon? fallback=null) {
- uri = website_uri;
- /* TODO: Use fallback */
- this.fallback = fallback;
- }
- public bool equal (GLib.Icon? other) {
- return other is Icon && (other as Icon).uri == uri;
- }
- public uint hash () {
- return uri.hash ();
- }
- public InputStream load (int size, out string? type = null, Cancellable? cancellable = null) throws Error {
- /* Implementation notes:
- GTK+ up to GTK+ 3.10 loads any GLib.Icon synchronously
- Favicons may be cached but usually trigger loading here
- Only one async code path in favour of consistent results
- */
- if (stream != null) {
- type = "image/png";
- return stream;
- }
- load_async.begin (size, cancellable, (obj, res)=>{
- try {
- stream = load_async.end (res);
- }
- catch (Error error) {
- debug ("Icon failed to load: %s", error.message);
- }
- });
- throw new FileError.EXIST ("Triggered load - no data yet");
- }
-
- public async InputStream load_async (int size, Cancellable? cancellable = null, out string? type = null) throws Error {
- type = "image/png";
- if (stream != null)
- return stream;
- var icon = yield get_icon (uri, cancellable);
- if (icon != null && icon is Gdk.Pixbuf) {
- var pixbuf = icon as Gdk.Pixbuf;
- // TODO: scale it to "size" here
- uint8[] buffer;
- pixbuf.save_to_buffer (out buffer, "png");
- stream = new MemoryInputStream.from_data (buffer, null);
- }
- else
- throw new FileError.EXIST ("No icon available");
- return stream;
- }
- }
- }
-}
diff --git a/midori/CMakeLists.txt b/midori/CMakeLists.txt
deleted file mode 100644
index b8655e9a..00000000
--- a/midori/CMakeLists.txt
+++ /dev/null
@@ -1,86 +0,0 @@
-# Copyright (C) 2013 Christian Dywan <christian@twotoasts.de>
-
-set(LIBMIDORI_VERSION 0.5.5)
-set(LIBMIDORI_SOVERSION 0)
-
-file(GLOB MIDORI_VALA_SOURCE ../katze/*.vala *.vala ../panels/*.vala)
-file(GLOB LIBMIDORI_SOURCE ../katze/*.c ../panels/*.c ../toolbars/*.c midori-*.vala midori-*.c sokoke.c)
-include(GLibHelpers)
-add_glib_marshal(LIBMIDORI_SOURCE marshal ${CMAKE_PROJECT_NAME}_cclosure_marshal "midori.h")
-set(MIDORI_SOURCE
- main.c
- )
-
-include(ValaPrecompile)
-vala_precompile(LIBMIDORI_SOURCE_C ${CMAKE_PROJECT_NAME}
- ${MIDORI_VALA_SOURCE}
-PACKAGES
- ${PKGS}
-OPTIONS
- ${VALAFLAGS}
-CUSTOM_VAPIS
- ${EXTRA_VAPIS}
-GENERATE_VAPI
- "${CMAKE_PROJECT_NAME}-core"
-GENERATE_HEADER
- "${CMAKE_PROJECT_NAME}-core"
-)
-
-add_library("${LIBMIDORI}-vala" STATIC ${LIBMIDORI_SOURCE_C})
-target_link_libraries("${LIBMIDORI}-vala"
- ${DEPS_LIBRARIES}
- ${OPTS_LIBRARIES}
- ${DEPS_GTK_LIBRARIES}
- )
-set_target_properties("${LIBMIDORI}-vala" PROPERTIES
- COMPILE_FLAGS "${VALA_CFLAGS}"
- POSITION_INDEPENDENT_CODE ON
- )
-
-add_library(${LIBMIDORI} SHARED ${LIBMIDORI_SOURCE})
-include_directories(
- ${CMAKE_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}
- "${CMAKE_SOURCE_DIR}/katze"
- "${CMAKE_SOURCE_DIR}/toolbars"
- ${CMAKE_BINARY_DIR}
- ${DEPS_INCLUDE_DIRS}
- ${OPTS_INCLUDE_DIRS}
- ${DEPS_GTK_INCLUDE_DIRS}
- )
-target_link_libraries(${LIBMIDORI}
- "${LIBMIDORI}-vala"
- ${DEPS_LIBRARIES}
- ${OPTS_LIBRARIES}
- ${DEPS_GTK_LIBRARIES}
- )
-set_target_properties(${LIBMIDORI} PROPERTIES
- COMPILE_FLAGS ${CFLAGS}
- SOVERSION 1
- VERSION 0.0.0
- )
-if (WIN32)
- install(TARGETS ${LIBMIDORI}
- LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- )
-else ()
- install(TARGETS ${LIBMIDORI}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- )
-endif ()
-
-if (WIN32)
- add_executable(${CMAKE_PROJECT_NAME} WIN32 main.c "${CMAKE_SOURCE_DIR}/data/midori.rc")
-else()
- add_executable(${CMAKE_PROJECT_NAME} main.c)
-endif()
-
-target_link_libraries(${CMAKE_PROJECT_NAME}
- ${LIBMIDORI})
-set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
- COMPILE_FLAGS ${CFLAGS}
- )
-install(TARGETS ${CMAKE_PROJECT_NAME}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- )
diff --git a/midori/main.c b/midori/main.c
deleted file mode 100644
index 71acff57..00000000
--- a/midori/main.c
+++ /dev/null
@@ -1,448 +0,0 @@
-/*
- Copyright (C) 2007-2009 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2008 Dale Whittaker <dayul@users.sf.net>
-
- 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.
-*/
-
-#include "midori-frontend.h"
-#include "midori-platform.h"
-#include "midori-privatedata.h"
-#include "midori-searchaction.h"
-#include "midori/midori-session.h"
-#include <midori/midori-core.h>
-
-#include <config.h>
-#if HAVE_UNISTD_H
- #include <unistd.h>
-#endif
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib/gstdio.h>
-#include <glib/gi18n-lib.h>
-#include "katze/katze.h"
-#include <sqlite3.h>
-
-static void
-plain_entry_activate_cb (GtkWidget* entry,
- GtkWidget* web_view)
-{
- gchar* uri = sokoke_magic_uri (gtk_entry_get_text (GTK_ENTRY (entry)), FALSE, TRUE);
- webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), uri);
- g_free (uri);
-}
-
-#ifndef HAVE_WEBKIT2
-static void
-snapshot_load_finished_cb (GtkWidget* web_view,
- WebKitWebFrame* web_frame,
- gchar* filename)
-{
- GdkPixbuf* pixbuf = gtk_offscreen_window_get_pixbuf (GTK_OFFSCREEN_WINDOW (
- gtk_widget_get_parent (web_view)));
- gdk_pixbuf_save (pixbuf, filename, "png", NULL, "compression", "7", NULL);
- g_object_unref (pixbuf);
- g_print (_("Snapshot saved to: %s\n"), filename);
- gtk_main_quit ();
-}
-#endif
-
-static void
-midori_log_to_file (const gchar* log_domain,
- GLogLevelFlags log_level,
- const gchar* message,
- gpointer user_data)
-{
- FILE* logfile = fopen ((const char*)user_data, "a");
- gchar* level_name = "";
- time_t timestamp = time (NULL);
-
- switch (log_level)
- {
- /* skip irrelevant flags */
- case G_LOG_LEVEL_MASK:
- case G_LOG_FLAG_FATAL:
- case G_LOG_FLAG_RECURSION:
-
- case G_LOG_LEVEL_ERROR:
- level_name = "ERROR";
- break;
- case G_LOG_LEVEL_CRITICAL:
- level_name = "CRITICAL";
- break;
- case G_LOG_LEVEL_WARNING:
- level_name = "WARNING";
- break;
- case G_LOG_LEVEL_MESSAGE:
- level_name = "MESSAGE";
- break;
- case G_LOG_LEVEL_INFO:
- level_name = "INFO";
- break;
- case G_LOG_LEVEL_DEBUG:
- level_name = "DEBUG";
- break;
- }
-
- fprintf (logfile, "%s%s-%s **: %s\n", asctime (localtime (&timestamp)),
- log_domain ? log_domain : "Midori", level_name, message);
- fclose (logfile);
-}
-
-int
-main (int argc,
- char** argv)
-{
- gchar* webapp;
- gchar* config;
- gboolean private;
- gboolean portable;
- gboolean plain;
- gboolean diagnostic_dialog = FALSE;
- gboolean debug = FALSE;
- gboolean run;
- gchar* snapshot;
- gchar* logfile;
- gchar** execute;
- gboolean help_execute;
- gboolean version;
- gchar** uris;
- gchar* block_uris;
- gint inactivity_reset;
- GOptionEntry entries[] =
- {
- { "app", 'a', 0, G_OPTION_ARG_STRING, &webapp,
- N_("Run ADDRESS as a web application"), N_("ADDRESS") },
- { "config", 'c', 0, G_OPTION_ARG_FILENAME, &config,
- N_("Use FOLDER as configuration folder"), N_("FOLDER") },
- { "private", 'p', 0, G_OPTION_ARG_NONE, &private,
- N_("Private browsing, no changes are saved"), NULL },
- #ifdef G_OS_WIN32
- { "portable", 'P', 0, G_OPTION_ARG_NONE, &portable,
- N_("Portable mode, all runtime files are stored in one place"), NULL },
- #endif
- { "plain", '\0', 0, G_OPTION_ARG_NONE, &plain,
- N_("Plain GTK+ window with WebKit, akin to GtkLauncher"), NULL },
- { "diagnostic-dialog", 'd', 0, G_OPTION_ARG_NONE, &diagnostic_dialog,
- N_("Show a diagnostic dialog"), NULL },
- { "debug", 'g', 0, G_OPTION_ARG_NONE, &debug,
- N_("Run within gdb and save a backtrace on crash"), NULL },
- { "run", 'r', 0, G_OPTION_ARG_NONE, &run,
- N_("Run the specified filename as javascript"), NULL },
- { "snapshot", 's', 0, G_OPTION_ARG_STRING, &snapshot,
- N_("Take a snapshot of the specified URI"), NULL },
- { "execute", 'e', 0, G_OPTION_ARG_STRING_ARRAY, &execute,
- N_("Execute the specified command"), NULL },
- { "help-execute", 0, 0, G_OPTION_ARG_NONE, &help_execute,
- N_("List available commands to execute with -e/ --execute"), NULL },
- { "version", 'V', 0, G_OPTION_ARG_NONE, &version,
- N_("Display program version"), NULL },
- { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &uris,
- N_("Addresses"), NULL },
- { "block-uris", 'b', 0, G_OPTION_ARG_STRING, &block_uris,
- N_("Block URIs according to regular expression PATTERN"), _("PATTERN") },
- #ifdef HAVE_X11_EXTENSIONS_SCRNSAVER_H
- { "inactivity-reset", 'i', 0, G_OPTION_ARG_INT, &inactivity_reset,
- /* i18n: CLI: Close tabs, clear private data, open starting page */
- N_("Reset Midori after SECONDS seconds of inactivity"), N_("SECONDS") },
- #endif
- { "log-file", 'l', 0, G_OPTION_ARG_FILENAME, &logfile,
- N_("Redirects console warnings to the specified FILENAME"), N_("FILENAME")},
- { NULL }
- };
-
- /* Parse cli options */
- webapp = NULL;
- config = NULL;
- private = FALSE;
- portable = FALSE;
- plain = FALSE;
- run = FALSE;
- snapshot = NULL;
- logfile = NULL;
- execute = NULL;
- help_execute = FALSE;
- version = FALSE;
- uris = NULL;
- block_uris = NULL;
- inactivity_reset = 0;
- midori_app_setup (&argc, &argv, entries);
-
- if (debug)
- {
- gchar* gdb = g_find_program_in_path ("gdb");
- if (gdb == NULL)
- midori_error (_("Error: \"gdb\" can't be found\n"));
- sokoke_spawn_gdb (gdb, TRUE);
- g_free (gdb);
- return 0;
- }
-
- g_set_application_name (_("Midori"));
- /* Versioned prgname to override menuproxy blacklist */
- g_set_prgname (PACKAGE_NAME "4");
-
- if (version)
- {
- GString* versions = g_string_new ("");
- g_string_append_c (versions, '\n');
- midori_view_list_versions (versions, FALSE);
- /* FIXME Plugins may clutter output and hang
- midori_view_list_plugins (NULL, versions, FALSE); */
- g_print ("%s\n", versions->str);
- g_string_free (versions, TRUE);
-
- g_print (
- "Copyright (c) 2007-2013 Christian Dywan\n\n"
- "%s\n"
- "\t%s\n\n"
- "%s\n"
- "\thttp://www.midori-browser.org\n",
- _("Please report comments, suggestions and bugs to:"),
- PACKAGE_BUGREPORT,
- _("Check for new versions at:")
- );
- return 0;
- }
-
- if (help_execute)
- {
- MidoriBrowser* browser = midori_browser_new ();
- GtkActionGroup* action_group = midori_browser_get_action_group (browser);
- GList* actions = gtk_action_group_list_actions (action_group);
- GList* temp = actions;
- GObjectClass* class = G_OBJECT_GET_CLASS (midori_browser_get_settings (browser));
- guint i, n_properties;
- GParamSpec** pspecs = g_object_class_list_properties (class, &n_properties);
- guint length = 1;
- gchar* space;
-
- for (; temp; temp = g_list_next (temp))
- length = MAX (length, 1 + strlen (gtk_action_get_name (temp->data)));
- for (i = 0; i < n_properties; i++)
- length = MAX (length, 1 + strlen (g_param_spec_get_name (pspecs[i])));
-
- space = g_strnfill (length, ' ');
- for (; actions; actions = g_list_next (actions))
- {
- GtkAction* action = actions->data;
- const gchar* name = gtk_action_get_name (action);
- gchar* padding = g_strndup (space, strlen (space) - strlen (name));
- gchar* label = katze_object_get_string (action, "label");
- gchar* stripped = katze_strip_mnemonics (label);
- gchar* tooltip = katze_object_get_string (action, "tooltip");
- g_print ("%s%s%s%s%s\n", name, padding, stripped,
- tooltip ? ": " : "", tooltip ? tooltip : "");
- g_free (tooltip);
- g_free (padding);
- g_free (label);
- g_free (stripped);
- }
- g_list_free (actions);
- g_print ("\n");
-
- for (i = 0; i < n_properties; i++)
- {
- GParamSpec* pspec = pspecs[i];
- if (!(pspec->flags & G_PARAM_WRITABLE))
- continue;
- const gchar* property = g_param_spec_get_name (pspec);
- gchar* padding = g_strndup (space, strlen (space) - strlen (property));
- GType type = G_PARAM_SPEC_TYPE (pspec);
- const gchar* tname;
- GString* tname_string = NULL;
- if (type == G_TYPE_PARAM_STRING)
- tname = "string";
- else if (type == G_TYPE_PARAM_BOOLEAN)
- tname = "true/ false";
- else if (type == G_TYPE_PARAM_ENUM)
- {
- GEnumClass* enum_class = G_ENUM_CLASS (g_type_class_peek (pspec->value_type));
- guint j = 0;
- tname_string = g_string_new ("");
- for (j = 0; j < enum_class->n_values; j++)
- {
- g_string_append (tname_string, enum_class->values[j].value_name);
- g_string_append (tname_string, j == 2 ? "\n " : " ");
- }
- tname = tname_string->str;
- }
- else
- tname = "number";
- g_print ("%s%s%s\n", property, padding, tname);
- if (tname_string != NULL)
- g_string_free (tname_string, TRUE);
- g_free (padding);
- }
- g_free (pspecs);
-
- g_free (space);
- gtk_widget_destroy (GTK_WIDGET (browser));
- return 0;
- }
-
- if (snapshot)
- {
- GError* error = NULL;
- gchar* filename;
- GtkWidget* web_view;
- gchar* uri;
- GtkWidget* offscreen;
- GdkScreen* screen;
-
- gint fd = g_file_open_tmp ("snapshot-XXXXXX.png", &filename, &error);
- close (fd);
-
- if (error)
- {
- g_error ("%s", error->message);
- return 1;
- }
-
- if (g_unlink (filename) == -1)
- {
- g_error ("%s", g_strerror (errno));
- return 1;
- }
-
- web_view = webkit_web_view_new ();
- offscreen = gtk_offscreen_window_new ();
- gtk_container_add (GTK_CONTAINER (offscreen), web_view);
- if ((screen = gdk_screen_get_default ()))
- gtk_widget_set_size_request (web_view,
- gdk_screen_get_width (screen), gdk_screen_get_height (screen));
- else
- gtk_widget_set_size_request (web_view, 800, 600);
- gtk_widget_show_all (offscreen);
- #ifndef HAVE_WEBKIT2
- g_signal_connect (web_view, "load-finished",
- G_CALLBACK (snapshot_load_finished_cb), filename);
- #endif
- uri = sokoke_magic_uri (snapshot, FALSE, TRUE);
- webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), uri);
- g_free (uri);
- gtk_main ();
- g_free (filename);
- return 0;
- }
-
- if (logfile)
- {
- g_log_set_default_handler (midori_log_to_file, (gpointer)logfile);
- }
-
- if (plain)
- {
- GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
- GtkWidget* entry = gtk_entry_new ();
-#ifndef HAVE_WEBKIT2
- GtkWidget* scrolled = gtk_scrolled_window_new (NULL, NULL);
-#endif
- GtkWidget* web_view = webkit_web_view_new ();
- katze_window_set_sensible_default_size (GTK_WINDOW (window));
-
- gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
-#ifndef HAVE_WEBKIT2
- gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 0);
- gtk_container_add (GTK_CONTAINER (scrolled), web_view);
-#else
- gtk_box_pack_start (GTK_BOX (vbox), web_view, TRUE, TRUE, 0);
-#endif
- gtk_container_add (GTK_CONTAINER (window), vbox);
- gtk_entry_set_text (GTK_ENTRY (entry), uris && *uris ? *uris : "http://www.example.com");
- plain_entry_activate_cb (entry, web_view);
- g_signal_connect (entry, "activate",
- G_CALLBACK (plain_entry_activate_cb), web_view);
- g_signal_connect (window, "delete-event",
- G_CALLBACK (gtk_main_quit), window);
- gtk_widget_show_all (window);
- gtk_main ();
- return 0;
- }
-
- midori_private_data_register_built_ins ();
-
- if (run)
- {
- gchar* script = NULL;
- GError* error = NULL;
-
- if (g_file_get_contents (uris ? *uris : NULL, &script, NULL, &error))
- {
- midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, config);
-
- MidoriBrowser* browser = midori_browser_new ();
- MidoriWebSettings* settings = midori_browser_get_settings (browser);
-#ifndef HAVE_WEBKIT2
- g_object_set_data (G_OBJECT (webkit_get_default_session ()), "pass-through-console", (void*)1);
-#endif
- midori_load_soup_session (settings);
-
- gchar* msg = NULL;
- GtkWidget* view = midori_view_new_with_item (NULL, settings);
- g_object_set (settings, "open-new-pages-in", MIDORI_NEW_PAGE_WINDOW, NULL);
- midori_browser_add_tab (browser, view);
- gtk_widget_show_all (GTK_WIDGET (browser));
- gtk_widget_hide (GTK_WIDGET (browser));
- midori_view_execute_script (MIDORI_VIEW (view), script, &msg);
- if (msg != NULL)
- {
- g_error ("%s\n", msg);
- g_free (msg);
- }
- gtk_main ();
- }
- else if (error != NULL)
- {
- g_error ("%s\n", error->message);
- g_error_free (error);
- }
- else
- g_error ("%s\n", _("An unknown error occured"));
- g_free (script);
- return 0;
- }
-
- if (private)
- {
- MidoriBrowser* browser = midori_private_app_new (config, webapp,
- uris, execute, inactivity_reset, block_uris);
- g_signal_connect (browser, "destroy", G_CALLBACK (gtk_main_quit), NULL);
- g_signal_connect (browser, "quit", G_CALLBACK (gtk_main_quit), NULL);
- gtk_main ();
- return 0;
- }
-
- if (webapp)
- {
- MidoriBrowser* browser = midori_web_app_new (webapp,
- uris, execute, inactivity_reset, block_uris);
- g_signal_connect (browser, "destroy", G_CALLBACK (gtk_main_quit), NULL);
- g_signal_connect (browser, "quit", G_CALLBACK (gtk_main_quit), NULL);
- gtk_main ();
- return 0;
- }
-
- MidoriApp* app = midori_normal_app_new (config,
- portable ? "portable" : "normal", diagnostic_dialog,
- uris, execute, inactivity_reset, block_uris);
- if (app == NULL)
- return 0;
- if (app == (void*)0xdeadbeef)
- return 1;
-
- g_signal_connect (app, "quit", G_CALLBACK (gtk_main_quit), NULL);
- gtk_main ();
- midori_normal_app_on_quit (app);
- g_object_unref (app);
- return 0;
-}
-
diff --git a/midori/marshal.list b/midori/marshal.list
deleted file mode 100644
index d331229d..00000000
--- a/midori/marshal.list
+++ /dev/null
@@ -1,15 +0,0 @@
-BOOLEAN:POINTER
-BOOLEAN:OBJECT
-BOOLEAN:OBJECT,OBJECT
-BOOLEAN:OBJECT,OBJECT,POINTER
-BOOLEAN:VOID
-BOOLEAN:STRING
-OBJECT:OBJECT
-VOID:BOOLEAN,STRING
-VOID:OBJECT,ENUM,BOOLEAN
-VOID:OBJECT,INT,INT
-VOID:OBJECT,OBJECT
-VOID:POINTER,INT
-VOID:STRING,BOOLEAN
-VOID:STRING,INT,STRING
-VOID:STRING,STRING
diff --git a/midori/midori-app.c b/midori/midori-app.c
deleted file mode 100644
index 3faae38c..00000000
--- a/midori/midori-app.c
+++ /dev/null
@@ -1,1315 +0,0 @@
-/*
- Copyright (C) 2008-2013 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.
-*/
-
-/* When cross-compiling assume at least WinXP */
-#ifdef _WIN32
- #define _WIN32_WINNT 0x0501
- #include <unistd.h>
- #include <windows.h>
-#endif
-
-#if HAVE_CONFIG_H
- #include <config.h>
-#endif
-
-#include "midori-app.h"
-#include "midori-platform.h"
-#include "midori-core.h"
-
-#include <string.h>
-#include <gtk/gtk.h>
-#include <glib/gstdio.h>
-#include <glib/gi18n.h>
-
-#if ENABLE_NLS
- #include <libintl.h>
- #include <locale.h>
-#endif
-
-#ifdef HAVE_LIBNOTIFY
- #include <libnotify/notify.h>
- #ifndef NOTIFY_CHECK_VERSION
- #define NOTIFY_CHECK_VERSION(x,y,z) 0
- #endif
-#endif
-
-#ifdef HAVE_SIGNAL_H
- #include <signal.h>
-#endif
-
-struct _MidoriApp
-{
- GApplication parent_instance;
-
- MidoriWebSettings* settings;
- KatzeArray* bookmarks;
- KatzeArray* trash;
- KatzeArray* search_engines;
- KatzeArray* history;
- GKeyFile* speeddial;
- KatzeArray* extensions;
- KatzeArray* browsers;
-
- MidoriBrowser* browser;
-};
-
-static gchar* app_name = NULL;
-
-struct _MidoriAppClass
-{
- GApplicationClass parent_class;
-
- /* Signals */
- void
- (*add_browser) (MidoriApp* app,
- MidoriBrowser* browser);
- void
- (*remove_browser) (MidoriApp* app,
- MidoriBrowser* browser);
- void
- (*quit) (MidoriApp* app);
-};
-
-G_DEFINE_TYPE (MidoriApp, midori_app, G_TYPE_APPLICATION);
-
-enum
-{
- PROP_0,
-
- PROP_NAME,
- PROP_SETTINGS,
- PROP_BOOKMARKS,
- PROP_TRASH,
- PROP_SEARCH_ENGINES,
- PROP_HISTORY,
- PROP_SPEED_DIAL,
- PROP_EXTENSIONS,
- PROP_BROWSERS,
- PROP_BROWSER
-};
-
-enum {
- ADD_BROWSER,
- REMOVE_BROWSER,
- QUIT,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-midori_app_finalize (GObject* object);
-
-static void
-midori_app_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_app_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-static gboolean
-midori_browser_focus_in_event_cb (MidoriBrowser* browser,
- GdkEventFocus* event,
- MidoriApp* app)
-{
- app->browser = browser;
- g_object_notify (G_OBJECT (app), "browser");
- return FALSE;
-}
-
-static MidoriBrowser*
-midori_browser_new_window_cb (MidoriBrowser* browser,
- MidoriBrowser* new_browser,
- MidoriApp* app)
-{
- if (new_browser)
- g_object_set (new_browser,
- "settings", app->settings,
- "bookmarks", app->bookmarks,
- "trash", app->trash,
- "search-engines", app->search_engines,
- "history", app->history,
- "speed-dial", app->speeddial,
- NULL);
- else
- new_browser = midori_app_create_browser (app);
-
- midori_app_add_browser (app, new_browser);
- gtk_widget_show (GTK_WIDGET (new_browser));
-
- return new_browser;
-}
-
-static gboolean
-midori_browser_delete_event_cb (MidoriBrowser* browser,
- GdkEvent* event,
- MidoriApp* app)
-{
- return FALSE;
-}
-
-static gboolean
-midori_browser_destroy_cb (MidoriBrowser* browser,
- MidoriApp* app)
-{
- g_signal_emit (app, signals[REMOVE_BROWSER], 0, browser);
- katze_array_remove_item (app->browsers, browser);
- if (!katze_array_is_empty (app->browsers))
- {
- app->browser = katze_array_get_nth_item (app->browsers, 0);
- return FALSE;
- }
- midori_app_quit (app);
- return TRUE;
-}
-
-static void
-midori_browser_quit_cb (MidoriBrowser* browser,
- MidoriApp* app)
-{
- midori_app_quit (app);
-}
-
-static void
-_midori_app_add_browser (MidoriApp* app,
- MidoriBrowser* browser)
-{
- g_return_if_fail (MIDORI_IS_APP (app));
- g_return_if_fail (MIDORI_IS_BROWSER (browser));
-
- g_object_connect (browser,
- "signal::focus-in-event", midori_browser_focus_in_event_cb, app,
- "signal::new-window", midori_browser_new_window_cb, app,
- "signal::delete-event", midori_browser_delete_event_cb, app,
- "signal::destroy", midori_browser_destroy_cb, app,
- "signal::quit", midori_browser_quit_cb, app,
- NULL);
- g_signal_connect_swapped (browser, "send-notification",
- G_CALLBACK (midori_app_send_notification), app);
- katze_array_add_item (app->browsers, browser);
-
- #if GTK_CHECK_VERSION (3, 0, 0)
- if (app->browser == NULL)
- {
- gchar* filename;
- if ((filename = midori_paths_get_res_filename ("gtk3.css")))
- {
- GtkCssProvider* css_provider = gtk_css_provider_new ();
- GError* error = NULL;
- gtk_css_provider_load_from_path (css_provider, filename, &error);
- if (error == NULL)
- {
- gtk_style_context_add_provider_for_screen (
- gtk_widget_get_screen (GTK_WIDGET (browser)),
- GTK_STYLE_PROVIDER (css_provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- }
- else
- {
- g_warning ("Failed to load \"%s\": %s", filename, error->message);
- g_error_free (error);
- }
- g_free (filename);
- }
- }
- #endif
-
- app->browser = browser;
-}
-
-#ifdef HAVE_SIGNAL_H
-static MidoriApp* app_singleton;
-static void
-midori_app_signal_handler (int signal_id)
-{
- signal (signal_id, 0);
- if (!midori_paths_is_readonly ())
- midori_app_quit (app_singleton);
- if (kill (getpid (), signal_id))
- exit (1);
-}
-#endif
-
-static void
-_midori_app_quit (MidoriApp* app)
-{
- if (!midori_paths_is_readonly ())
- {
- gchar* config_file = midori_paths_get_config_filename_for_writing ("running");
- g_unlink (config_file);
- g_free (config_file);
- }
-}
-
-static void
-midori_app_class_init (MidoriAppClass* class)
-{
- GObjectClass* gobject_class;
-
- /**
- * MidoriApp::add-browser:
- * @app: the object on which the signal is emitted
- * @browser: a #MidoriBrowser
- *
- * A new browser is being added to the app,
- * see midori_app_add_browser().
- */
- signals[ADD_BROWSER] = g_signal_new (
- "add-browser",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- G_STRUCT_OFFSET (MidoriAppClass, add_browser),
- 0,
- NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- MIDORI_TYPE_BROWSER);
-
- /**
- * MidoriApp::remove-browser:
- * @app: the object on which the signal is emitted
- * @browser: a #MidoriBrowser
- *
- * A browser is being removed from the app because it
- * was destroyed.
- *
- * Since: 0.1.7
- */
- signals[REMOVE_BROWSER] = g_signal_new (
- "remove-browser",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- MIDORI_TYPE_BROWSER);
-
- /**
- * MidoriApp::quit:
- * @app: the object on which the signal is emitted
- * @browser: a #MidoriBrowser
- *
- * The app is being quit, see midori_app_quit().
- */
- signals[QUIT] = g_signal_new (
- "quit",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- G_STRUCT_OFFSET (MidoriAppClass, quit),
- 0,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = midori_app_finalize;
- gobject_class->set_property = midori_app_set_property;
- gobject_class->get_property = midori_app_get_property;
-
- class->add_browser = _midori_app_add_browser;
- class->quit = _midori_app_quit;
-
- /**
- * MidoriApp:name:
- *
- * The name of the instance.
- *
- * Since: 0.1.6
- */
- g_object_class_install_property (gobject_class,
- PROP_NAME,
- g_param_spec_string (
- "name",
- "Name",
- "The name of the instance",
- NULL,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_SETTINGS,
- g_param_spec_object (
- "settings",
- "Settings",
- "The associated settings",
- MIDORI_TYPE_WEB_SETTINGS,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_BOOKMARKS,
- g_param_spec_object (
- "bookmarks",
- "Bookmarks",
- "The bookmarks folder, containing all bookmarks",
- KATZE_TYPE_ARRAY,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_TRASH,
- g_param_spec_object (
- "trash",
- "Trash",
- "The trash, collecting recently closed tabs and windows",
- KATZE_TYPE_ARRAY,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_SEARCH_ENGINES,
- g_param_spec_object (
- "search-engines",
- "Search Engines",
- "The list of search engines",
- KATZE_TYPE_ARRAY,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_HISTORY,
- g_param_spec_object (
- "history",
- "History",
- "The list of history items",
- KATZE_TYPE_ARRAY,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_EXTENSIONS,
- g_param_spec_object (
- "extensions",
- "Extensions",
- "The list of extensions",
- KATZE_TYPE_ARRAY,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
-
-
- /**
- * MidoriApp:speed-dial:
- *
- * The speed dial configuration file.
- *
- * Since: 0.3.4
- */
- g_object_class_install_property (gobject_class,
- PROP_SPEED_DIAL,
- g_param_spec_pointer (
- "speed-dial",
- "Speeddial",
- "Pointer to key-value object with speed dial items",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriApp:browsers:
- *
- * The list of browsers.
- *
- * Since: 0.1.3
- */
- g_object_class_install_property (gobject_class,
- PROP_BROWSERS,
- g_param_spec_object (
- "browsers",
- "Browsers",
- "The list of browsers",
- KATZE_TYPE_ARRAY,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriApp:browser:
- *
- * The current browser, that is the one that was last used.
- *
- * Since: 0.1.3
- */
- g_object_class_install_property (gobject_class,
- PROP_BROWSER,
- g_param_spec_object (
- "browser",
- "Browser",
- "The current browser",
- MIDORI_TYPE_BROWSER,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-}
-
-static void
-midori_app_raise_window (GtkWindow* window,
- GdkScreen* screen)
-{
- if (screen)
- gtk_window_set_screen (window, screen);
- gtk_window_present (window);
- gtk_window_deiconify (window);
-}
-
-static void
-midori_app_debug_open (MidoriApp* app,
- GFile** files,
- gint n_files,
- const gchar* hint)
-{
- if (midori_debug ("app"))
- {
- g_print ("app(%s) open: %d files [",
- g_application_get_is_remote (G_APPLICATION (app)) ? "send" : "receive",
- n_files);
- gint i;
- for (i = 0; i < n_files; i++)
- {
- gchar* uri = g_file_get_uri (files[i]);
- g_print ("%s ", uri);
- g_free (uri);
- }
- g_print ("] hint '%s'\n", hint);
- }
-}
-
-static void
-midori_app_activate_cb (MidoriApp* app,
- gpointer user_data)
-{
- if (midori_debug ("app"))
- g_print ("app(receive) activate\n");
- if (app->browser)
- midori_app_raise_window (GTK_WINDOW (app->browser), NULL);
-}
-
-static void
-midori_app_open_cb (MidoriApp* app,
- GFile** files,
- gint n_files,
- gchar* hint,
- gpointer user_data)
-{
- midori_app_debug_open (app, files, n_files, hint);
-
- if (!strcmp (hint, "window"))
- {
- MidoriBrowser* browser = midori_app_create_browser (app);
- midori_app_add_browser (app, browser);
- midori_browser_add_uri (browser, "about:home");
- midori_browser_activate_action (browser, "Location");
- gtk_widget_show (GTK_WIDGET (browser));
- midori_app_raise_window (GTK_WINDOW (browser), NULL);
- return;
- }
-
- if (n_files == 0 && strcmp (hint, ""))
- {
- midori_browser_activate_action (app->browser, hint);
- return;
- }
-
- MidoriBrowser* browser;
- MidoriNewPage open_external_pages_in;
- gboolean first;
-
- g_object_get (app->settings, "open-new-pages-in", &open_external_pages_in, NULL);
- if (open_external_pages_in == MIDORI_NEW_PAGE_WINDOW)
- {
- browser = midori_app_create_browser (app);
- midori_app_add_browser (app, browser);
- gtk_widget_show (GTK_WIDGET (browser));
- }
- else
- browser = app->browser;
- midori_app_raise_window (GTK_WINDOW (browser), NULL);
-
- first = (open_external_pages_in == MIDORI_NEW_PAGE_CURRENT);
-
- gint i;
- for (i = 0; i < n_files; i++)
- {
- gchar* uri = g_file_get_uri (files[i]);
- if (midori_uri_recursive_fork_protection (uri, FALSE))
- {
- if (first)
- {
- midori_browser_set_current_uri (browser, uri);
- first = FALSE;
- }
- else
- {
- /* Switch to already open tab if possible */
- KatzeArray* items = midori_browser_get_proxy_array (browser);
- KatzeItem* found = katze_array_find_uri (items, uri);
- if (found != NULL)
- midori_browser_set_current_item (browser, found);
- else
- midori_browser_set_current_tab (browser,
- midori_browser_add_uri (browser, uri));
- }
- }
- g_free (uri);
- }
-}
-
-static void
-midori_app_startup_cb (GApplication* app,
- gpointer user_data)
-{
- g_signal_connect (app, "activate",
- G_CALLBACK (midori_app_activate_cb), NULL);
- g_signal_connect (app, "open",
- G_CALLBACK (midori_app_open_cb), NULL);
-}
-
-static void
-midori_app_network_changed (GNetworkMonitor* monitor,
- gboolean available,
- MidoriApp* app)
-{
- if (available)
- {
- MidoriBrowser *browser;
- KATZE_ARRAY_FOREACH_ITEM (browser, app->browsers) {
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs != NULL; tabs = g_list_next (tabs))
- if (midori_tab_get_load_error (MIDORI_TAB (tabs->data)) == MIDORI_LOAD_ERROR_NETWORK)
- midori_view_reload (tabs->data, FALSE);
- g_list_free (tabs);
- }
- }
-}
-
-static void
-midori_app_create_instance (MidoriApp* app)
-{
- if (g_application_get_is_registered (G_APPLICATION (app)))
- return;
-
- const gchar* config = midori_paths_get_config_dir_for_reading ();
- gchar* config_hash = g_strdup_printf ("%u", g_str_hash (config));
- gchar* config_hash_truncated = g_strndup (config_hash, 5);
- katze_assign (app_name, g_strdup_printf (
- "de.twotoasts.%s-%s", PACKAGE_NAME, config_hash_truncated));
- g_free (config_hash);
- g_free (config_hash_truncated);
- g_object_notify (G_OBJECT (app), "name");
-
- if (midori_debug ("app"))
- g_print ("app registering %s\n", app_name);
- g_object_set (app,
- "application-id", app_name,
- "flags", G_APPLICATION_HANDLES_OPEN,
- NULL);
- g_signal_connect (app, "startup", G_CALLBACK (midori_app_startup_cb), NULL);
-
- g_signal_connect (g_network_monitor_get_default (), "network-changed",
- G_CALLBACK (midori_app_network_changed), app);
-
- GError* error = NULL;
- if (!g_application_register (G_APPLICATION (app), NULL, &error))
- midori_error (error->message);
-}
-
-const gchar*
-midori_app_get_name (MidoriApp* app)
-{
- return app_name;
-}
-
-gboolean
-midori_app_get_crashed (MidoriApp* app)
-{
- static gint cache = -1;
-
- if (cache != -1)
- return (gboolean) cache;
-
- if (!midori_paths_is_readonly ())
- {
- /* We test for the presence of a dummy file which is created once
- and deleted during normal runtime, but persists in case of a crash. */
- gchar* config_file = midori_paths_get_config_filename_for_writing ("running");
- gboolean crashed = g_file_test (config_file, G_FILE_TEST_EXISTS);
- if (!crashed)
- g_file_set_contents (config_file, "RUNNING", -1, NULL);
- g_free (config_file);
- if (crashed) {
- cache = 1;
- return TRUE;
- }
- }
-
- cache = 0;
-
- return FALSE;
-}
-
-static void
-midori_app_init (MidoriApp* app)
-{
- #ifdef HAVE_SIGNAL_H
- app_singleton = app;
- #ifdef SIGHUP
- signal (SIGHUP, &midori_app_signal_handler);
- #endif
- #ifdef SIGINT
- signal (SIGINT, &midori_app_signal_handler);
- #endif
- #ifdef SIGTERM
- signal (SIGTERM, &midori_app_signal_handler);
- #endif
- #ifdef SIGQUIT
- signal (SIGQUIT, &midori_app_signal_handler);
- #endif
- #endif
-
- app->settings = NULL;
- app->bookmarks = NULL;
- app->trash = NULL;
- app->search_engines = NULL;
- app->history = NULL;
- app->speeddial = NULL;
- app->extensions = katze_array_new (KATZE_TYPE_ARRAY);
- app->browsers = katze_array_new (MIDORI_TYPE_BROWSER);
-
- #ifdef HAVE_LIBNOTIFY
- notify_init (PACKAGE_NAME);
- #endif
-}
-
-static void
-midori_app_finalize (GObject* object)
-{
- MidoriApp* app = MIDORI_APP (object);
-
- katze_assign (app_name, NULL);
- katze_object_assign (app->settings, NULL);
- katze_object_assign (app->bookmarks, NULL);
- katze_object_assign (app->trash, NULL);
- katze_object_assign (app->search_engines, NULL);
- katze_object_assign (app->history, NULL);
- app->speeddial = NULL;
- katze_object_assign (app->extensions, NULL);
- katze_object_assign (app->browsers, NULL);
-
- #ifdef HAVE_LIBNOTIFY
- if (notify_is_initted ())
- notify_uninit ();
- #endif
-
- G_OBJECT_CLASS (midori_app_parent_class)->finalize (object);
-}
-
-static void
-midori_app_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- MidoriApp* app = MIDORI_APP (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- katze_assign (app_name, g_value_dup_string (value));
- break;
- case PROP_SETTINGS:
- katze_object_assign (app->settings, g_value_dup_object (value));
- break;
- case PROP_BOOKMARKS:
- katze_object_assign (app->bookmarks, g_value_dup_object (value));
- break;
- case PROP_TRASH:
- katze_object_assign (app->trash, g_value_dup_object (value));
- break;
- case PROP_SEARCH_ENGINES:
- katze_object_assign (app->search_engines, g_value_dup_object (value));
- break;
- case PROP_HISTORY:
- katze_object_assign (app->history, g_value_dup_object (value));
- break;
- case PROP_SPEED_DIAL:
- app->speeddial = g_value_get_pointer (value);
- break;
- case PROP_EXTENSIONS:
- katze_object_assign (app->extensions, g_value_dup_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_app_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- MidoriApp* app = MIDORI_APP (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- g_value_set_string (value, app_name);
- break;
- case PROP_SETTINGS:
- g_value_set_object (value, app->settings);
- break;
- case PROP_BOOKMARKS:
- g_value_set_object (value, app->bookmarks);
- break;
- case PROP_TRASH:
- g_value_set_object (value, app->trash);
- break;
- case PROP_SEARCH_ENGINES:
- g_value_set_object (value, app->search_engines);
- break;
- case PROP_HISTORY:
- g_value_set_object (value, app->history);
- break;
- case PROP_SPEED_DIAL:
- g_value_set_pointer (value, app->speeddial);
- break;
- case PROP_EXTENSIONS:
- g_value_set_object (value, app->extensions);
- break;
- case PROP_BROWSERS:
- g_value_set_object (value, app->browsers);
- break;
- case PROP_BROWSER:
- g_value_set_object (value, app->browser);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/**
- * midori_app_new:
- *
- * Instantiates a new #MidoriApp singleton.
- *
- * Return value: a new #MidoriApp
- **/
-MidoriApp*
-midori_app_new (const gchar* name)
-{
- return g_object_new (MIDORI_TYPE_APP, "name", name, NULL);
-}
-
-/**
- * midori_app_new_proxy:
- * @app: a #MidoriApp, or %NULL
- *
- * Instantiates a proxy #MidoriApp that can be passed to untrusted code
- * or for sensitive use cases. Properties can be freely changed.
- *
- * Return value: a new #MidoriApp
- *
- * Since: 0.5.0
- **/
-MidoriApp*
-midori_app_new_proxy (MidoriApp* app)
-{
- g_return_val_if_fail (MIDORI_IS_APP (app) || !app, NULL);
-
- return midori_app_new (NULL);
-}
-
-static gboolean instance_is_not_running = FALSE;
-static gboolean instance_is_running = FALSE;
-
-void
-midori_app_set_instance_is_running (gboolean is_running)
-{
- instance_is_not_running = !is_running;
- instance_is_running = is_running;
-}
-
-/**
- * midori_app_instance_is_running:
- * @app: a #MidoriApp
- *
- * Determines whether an instance of Midori is
- * already running on the default display.
- *
- * Use the "name" property if you want to run more
- * than one instance.
- *
- * Return value: %TRUE if an instance is already running
- **/
-gboolean
-midori_app_instance_is_running (MidoriApp* app)
-{
- g_return_val_if_fail (MIDORI_IS_APP (app), FALSE);
-
- if (instance_is_not_running)
- return FALSE;
- else if (instance_is_running)
- return TRUE;
-
- midori_app_create_instance (app);
- return g_application_get_is_remote (G_APPLICATION (app));
-}
-
-/**
- * midori_app_instance_send_activate:
- * @app: a #MidoriApp
- *
- * Sends a message to an instance of Midori already
- * running on the default display, asking to activate it.
- *
- * Practically the current browser will be focussed.
- *
- * Return value: %TRUE if the message was sent successfully
- **/
-gboolean
-midori_app_instance_send_activate (MidoriApp* app)
-{
- g_return_val_if_fail (MIDORI_IS_APP (app), FALSE);
- g_return_val_if_fail (midori_app_instance_is_running (app), FALSE);
-
- if (midori_debug ("app"))
- g_print ("app(send) activate\n");
- g_application_activate (G_APPLICATION (app));
- return TRUE;
-}
-
-/**
- * midori_app_instance_send_new_browser:
- * @app: a #MidoriApp
- *
- * Sends a message to an instance of Midori already
- * running on the default display, asking to open a new browser.
- *
- * Return value: %TRUE if the message was sent successfully
- **/
-gboolean
-midori_app_instance_send_new_browser (MidoriApp* app)
-{
- g_return_val_if_fail (MIDORI_IS_APP (app), FALSE);
- g_return_val_if_fail (midori_app_instance_is_running (app), FALSE);
-
- midori_app_debug_open (app, NULL, -1, "window");
- g_application_open (G_APPLICATION (app), NULL, -1, "window");
- return TRUE;
-}
-
-/**
- * midori_app_instance_send_uris:
- * @app: a #MidoriApp
- * @uris: a string vector of URIs
- *
- * Sends a message to an instance of Midori already
- * running on the default display, asking to open @uris.
- *
- * The strings in @uris will each be opened in a new tab.
- *
- * Return value: %TRUE if the message was sent successfully
- **/
-gboolean
-midori_app_instance_send_uris (MidoriApp* app,
- gchar** uris)
-{
- g_return_val_if_fail (MIDORI_IS_APP (app), FALSE);
- g_return_val_if_fail (midori_app_instance_is_running (app), FALSE);
- g_return_val_if_fail (uris != NULL, FALSE);
-
- gint n_files = g_strv_length (uris);
- GFile** files = g_new (GFile*, n_files);
- /* Encode URLs to avoid GFile treating them wrongly */
- int i;
- for (i = 0; i < n_files; i++)
- {
- gchar* new_uri = sokoke_magic_uri (uris[i], TRUE, TRUE);
- files[i] = g_file_new_for_uri (new_uri);
- g_free (new_uri);
- }
- midori_app_debug_open (app, files, n_files, "");
- g_application_open (G_APPLICATION (app), files, n_files, "");
- return TRUE;
-}
-
-/**
- * midori_app_send_command:
- * @app: a #MidoriApp
- * @command: a string vector of a command to execute
- *
- * Sends a command to an instance of Midori, which
- * is either the current process or an already running
- * instance with the same name on the default display.
- *
- * Names of GtkAction objects of MidoriBrowser are recognized as commands.
- *
- * Return value: %TRUE if the message was sent successfully
- *
- * Since: 0.1.8
- **/
-gboolean
-midori_app_send_command (MidoriApp* app,
- gchar** command)
-{
- g_return_val_if_fail (MIDORI_IS_APP (app), FALSE);
- g_return_val_if_fail (command != NULL, FALSE);
-
- if (!midori_app_instance_is_running (app))
- {
- MidoriBrowser* browser = midori_browser_new ();
- int i;
- for (i = 0; command && command[i]; i++)
- midori_browser_assert_action (browser, command[i]);
- gtk_widget_destroy (GTK_WIDGET (browser));
- }
-
- gint n_files = g_strv_length (command);
- int i;
- for (i = 0; i < n_files; i++)
- {
- midori_app_debug_open (app, NULL, 0, command[i]);
- g_application_open (G_APPLICATION (app), NULL, 0, command[i]);
- }
- return TRUE;
-}
-
-/**
- * midori_app_add_browser:
- * @app: a #MidoriApp
- * @browser: a #MidoriBrowser
- *
- * Adds a #MidoriBrowser to the #MidoriApp.
- *
- * The app will take care of the browser's new-window and quit signals, as well
- * as watch window closing so that the last closed window quits the app.
- * Also the app watches focus changes to indicate the 'current' browser.
- *
- * Return value: a new #MidoriApp
- **/
-void
-midori_app_add_browser (MidoriApp* app,
- MidoriBrowser* browser)
-{
- g_return_if_fail (MIDORI_IS_APP (app));
- g_return_if_fail (MIDORI_IS_BROWSER (browser));
-
- g_signal_emit (app, signals[ADD_BROWSER], 0, browser);
-}
-
-void
-midori_app_set_browsers (MidoriApp* app,
- KatzeArray* browsers,
- MidoriBrowser* browser)
-{
- g_return_if_fail (MIDORI_IS_APP (app));
- g_return_if_fail (KATZE_IS_ARRAY (browsers));
- katze_object_assign (app->browsers, g_object_ref (browsers));
- app->browser = browser;
-}
-
-/**
- * midori_app_create_browser:
- * @app: a #MidoriApp
- *
- * Creates a #MidoriBrowser which inherits its settings,
- * bookmarks, trash, search engines and history from @app.
- *
- * Note that creating a browser this way can be a lot
- * faster than setting it up manually.
- *
- * Return value: a new #MidoriBrowser
- *
- * Since: 0.1.2
- **/
-MidoriBrowser*
-midori_app_create_browser (MidoriApp* app)
-{
- g_return_val_if_fail (MIDORI_IS_APP (app), NULL);
-
- return g_object_new (MIDORI_TYPE_BROWSER,
- "settings", app->settings,
- "bookmarks", app->bookmarks,
- "trash", app->trash,
- "search-engines", app->search_engines,
- "history", app->history,
- "speed-dial", app->speeddial,
- NULL);
-}
-
-/**
- * midori_app_get_browsers:
- * @app: a #MidoriApp
- *
- * Retrieves the browsers as a list.
- *
- * Return value: (transfer container) (element-type Midori.Browser): a newly allocated #Glist of #MidoriBrowser
- *
- * Since: 0.2.5
- **/
-GList*
-midori_app_get_browsers (MidoriApp* app)
-{
- g_return_val_if_fail (MIDORI_IS_APP (app), NULL);
-
- return katze_array_get_items (app->browsers);
-}
-
-/**
- * midori_app_get_browser:
- * @app: a #MidoriApp
- *
- * Determines the current browser, which is the one that was
- * last focussed.
- *
- * Return value: the current #MidoriBrowser
- *
- * Since: 0.2.5
- **/
-MidoriBrowser*
-midori_app_get_browser (MidoriApp* app)
-{
- g_return_val_if_fail (MIDORI_IS_APP (app), NULL);
-
- return app->browser;
-}
-
-/**
- * midori_app_quit:
- * @app: a #MidoriApp
- *
- * Quits the #MidoriApp.
- *
- * Since 0.1.2 the "quit" signal is always emitted before quitting.
- **/
-void
-midori_app_quit (MidoriApp* app)
-{
- g_return_if_fail (MIDORI_IS_APP (app));
-
- g_signal_emit (app, signals[QUIT], 0);
-}
-
-/**
- * midori_app_send_notification:
- * @app: a #MidoriApp
- * @title: title of the notification
- * @message: text of the notification, or NULL
- *
- * Send #message to a notification service to display it.
- *
- * There is no guarantee that the message has been sent and displayed, as
- * there might not be any notification service available.
- *
- * Since 0.1.7
- **/
-void
-midori_app_send_notification (MidoriApp* app,
- const gchar* title,
- const gchar* message)
-{
- g_return_if_fail (MIDORI_IS_APP (app));
- g_return_if_fail (title);
-
- #ifdef HAVE_LIBNOTIFY
- if (notify_is_initted ())
- {
- #if NOTIFY_CHECK_VERSION (0, 7, 0)
- NotifyNotification* note = notify_notification_new (title, message, "midori");
- #else
- NotifyNotification* note = notify_notification_new (title, message, "midori", NULL);
- #endif
- notify_notification_show (note, NULL);
- g_object_unref (note);
- }
- #elif !defined(G_OS_WIN32)
- GNotification* notification = g_notification_new (title);
- g_notification_set_body (notification, message);
- GIcon* icon = g_themed_icon_new ("midori");
- g_notification_set_icon (notification, icon);
- g_object_unref (icon);
- g_application_send_notification (G_APPLICATION (app), NULL, notification);
- g_object_unref (notification);
- #endif
-}
-
-/**
- * midori_app_setup:
- *
- * Saves the argument vector, initializes threading and registers
- * several custom stock items and prepares localization.
- *
- * Since: 0.4.2
- **/
-void
-midori_app_setup (gint *argc,
- gchar** *argument_vector,
- const GOptionEntry *entries)
-{
-
- GtkIconSource* icon_source;
- GtkIconSet* icon_set;
- GtkIconFactory* factory;
- gsize i;
- GError* error = NULL;
- gboolean success;
-
- static GtkStockItem items[] =
- {
- { "network-error" },
- { "network-idle" },
- { STOCK_IMAGE },
- { MIDORI_STOCK_WEB_BROWSER },
- { STOCK_NEWS_FEED },
- { STOCK_STYLE },
-
- { STOCK_BOOKMARKS, N_("_Bookmarks"), GDK_CONTROL_MASK | GDK_SHIFT_MASK, GDK_KEY_B },
- { STOCK_BOOKMARK_ADD, N_("Add Boo_kmark") },
- { STOCK_EXTENSION, N_("_Extensions") },
- { STOCK_HISTORY, N_("_History"), GDK_CONTROL_MASK | GDK_SHIFT_MASK, GDK_KEY_H },
- { STOCK_SCRIPT, N_("_Userscripts") },
- { STOCK_STYLE, N_("User_styles") },
- { STOCK_TAB_NEW, N_("New _Tab") },
- { MIDORI_STOCK_TRANSFER, N_("_Transfers"), GDK_CONTROL_MASK | GDK_SHIFT_MASK, GDK_KEY_J },
- { MIDORI_STOCK_PLUGINS, N_("Netscape p_lugins") },
- { STOCK_USER_TRASH, N_("_Closed Tabs") },
- { STOCK_WINDOW_NEW, N_("New _Window") },
- { STOCK_FOLDER_NEW, N_("New _Folder") },
- };
-
- /* Print messages to stdout on Win32 console, cf. AbiWord
- * http://svn.abisource.com/abiword/trunk/src/wp/main/win/Win32Main.cpp */
- #ifdef _WIN32
- if (fileno (stdout) != -1
- && _get_osfhandle (fileno (stdout)) != -1)
- {
- /* stdout is already being redirected to a file */
- }
- else
- {
- typedef BOOL (WINAPI *AttachConsole_t) (DWORD);
- AttachConsole_t p_AttachConsole =
- (AttachConsole_t) GetProcAddress (GetModuleHandle ("kernel32.dll"), "AttachConsole");
- if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS))
- {
- freopen ("CONOUT$", "w", stdout);
- dup2 (fileno (stdout), 1);
- freopen ("CONOUT$", "w", stderr);
- dup2 (fileno (stderr), 2);
- }
- }
- #endif
-
- /* Midori.Paths uses GFile */
- g_type_init ();
- /* Preserve argument vector */
- midori_paths_init_exec_path (*argument_vector, *argc);
-
- #ifdef G_OS_WIN32
- {
- gchar* exec_dir = g_win32_get_package_installation_directory_of_module (NULL);
- gchar* dr_mingw_dll = g_build_filename (exec_dir, "bin", "exchndl.dll", NULL);
-
- if (g_file_test (dr_mingw_dll, G_FILE_TEST_EXISTS)) {
- LoadLibrary(dr_mingw_dll);
- }
- g_free (exec_dir);
- g_free (dr_mingw_dll);
- }
- #endif
-
- #if ENABLE_NLS
- if (g_getenv ("MIDORI_NLSPATH"))
- bindtextdomain (GETTEXT_PACKAGE, g_getenv ("MIDORI_NLSPATH"));
- else
- #ifdef G_OS_WIN32
- {
- gchar* path = midori_paths_get_data_filename ("locale", FALSE);
- bindtextdomain (GETTEXT_PACKAGE, path);
- g_free (path);
- }
- #else
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
- #endif
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
- #endif
-
- #if GTK_CHECK_VERSION (3, 0, 0)
- success = gtk_init_with_args (argc, argument_vector, _("[Addresses]"),
- entries, GETTEXT_PACKAGE, &error);
- #else
- success = gtk_init_with_args (argc, argument_vector, _("[Addresses]"),
- (GOptionEntry*)entries, GETTEXT_PACKAGE, &error);
- #endif
-
- factory = gtk_icon_factory_new ();
- for (i = 0; i < G_N_ELEMENTS (items); i++)
- {
- icon_set = gtk_icon_set_new ();
- icon_source = gtk_icon_source_new ();
- gtk_icon_source_set_icon_name (icon_source, items[i].stock_id);
- gtk_icon_set_add_source (icon_set, icon_source);
- gtk_icon_source_free (icon_source);
- gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
- gtk_icon_set_unref (icon_set);
- }
- gtk_stock_add_static ((GtkStockItem*)items, G_N_ELEMENTS (items));
- gtk_icon_factory_add_default (factory);
- g_object_unref (factory);
-
- if (!success)
- midori_error (error->message);
-}
-
-void
-midori_error (const gchar* format,
- ...)
-{
- g_printerr ("%s - ", g_get_application_name ());
- va_list args;
- va_start (args, format);
- g_vfprintf (stderr, format, args);
- va_end (args);
- g_printerr ("\n");
- exit (1);
-}
-
-gboolean
-midori_debug (const gchar* token)
-{
- static const gchar* debug_token = NULL;
- const gchar* debug_tokens = "wk2:no-multi-render-process adblock:match adblock:parse adblock:time adblock:element adblock:css startup headers body referer cookies paths hsts unarmed db:bookmarks db:history db:tabby mouse app database addons:match ";
- if (debug_token == NULL)
- {
- gchar* found_token;
- const gchar* debug = g_getenv ("MIDORI_DEBUG");
- const gchar* legacy_touchscreen = g_getenv ("MIDORI_TOUCHSCREEN");
- if (legacy_touchscreen && *legacy_touchscreen)
- g_warning ("MIDORI_TOUCHSCREEN is obsolete: "
- "GTK+ 3.4 enables touchscreens automatically, "
- "older GTK+ versions aren't supported as of Midori 0.4.9");
- if (debug && (found_token = strstr (debug_tokens, debug)) && *(found_token + strlen (debug)) == ' ')
- debug_token = g_intern_static_string (debug);
- else if (debug)
- g_warning ("Unrecognized value '%s' for MIDORI_DEBUG.", debug);
- else
- debug_token = "NONE";
- if (!debug_token)
- {
- debug_token = "INVALID";
- g_print ("Supported values: %s\n", debug_tokens);
- }
- }
- if (debug_token != g_intern_static_string ("NONE")
- && !strstr (debug_tokens, token))
- g_warning ("Token '%s' passed to midori_debug is not a known token.", token);
- return debug_token == g_intern_static_string (token);
-}
-
diff --git a/midori/midori-app.h b/midori/midori-app.h
deleted file mode 100644
index 64cd278a..00000000
--- a/midori/midori-app.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- 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 __MIDORI_APP_H__
-#define __MIDORI_APP_H__
-
-#include <katze/katze.h>
-
-#include "midori-browser.h"
-#include "midori-websettings.h"
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_APP \
- (midori_app_get_type ())
-#define MIDORI_APP(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_APP, MidoriApp))
-#define MIDORI_APP_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_APP, MidoriAppClass))
-#define MIDORI_IS_APP(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_APP))
-#define MIDORI_IS_APP_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_APP))
-#define MIDORI_APP_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_APP, MidoriAppClass))
-
-typedef struct _MidoriApp MidoriApp;
-typedef struct _MidoriAppClass MidoriAppClass;
-
-GType
-midori_app_get_type (void) G_GNUC_CONST;
-
-MidoriApp*
-midori_app_new (const gchar* name);
-
-MidoriApp*
-midori_app_new_proxy (MidoriApp* app);
-
-const gchar*
-midori_app_get_name (MidoriApp* app);
-
-gboolean
-midori_app_get_crashed (MidoriApp* app);
-
-void
-midori_app_set_instance_is_running(gboolean is_running);
-
-gboolean
-midori_app_instance_is_running (MidoriApp* app);
-
-gboolean
-midori_app_instance_send_activate (MidoriApp* app);
-
-gboolean
-midori_app_instance_send_new_browser (MidoriApp* app);
-
-gboolean
-midori_app_instance_send_uris (MidoriApp* app,
- gchar** uris);
-
-gboolean
-midori_app_send_command (MidoriApp* app,
- gchar** command);
-
-void
-midori_app_add_browser (MidoriApp* app,
- MidoriBrowser* browser);
-
-MidoriBrowser*
-midori_app_create_browser (MidoriApp* app);
-
-MidoriBrowser*
-midori_app_get_browser (MidoriApp* app);
-
-GList*
-midori_app_get_browsers (MidoriApp* app);
-
-void
-midori_app_quit (MidoriApp* app);
-
-void
-midori_app_send_notification (MidoriApp* app,
- const gchar* title,
- const gchar* message);
-
-void
-midori_app_setup (gint *argc,
- gchar** *argument_vector,
- const GOptionEntry *entries);
-
-gboolean
-midori_debug (const gchar* token);
-
-void
-midori_error (const gchar* format,
- ...);
-
-G_END_DECLS
-
-#endif /* __MIDORI_APP_H__ */
diff --git a/midori/midori-array.c b/midori/midori-array.c
deleted file mode 100644
index 2a661c19..00000000
--- a/midori/midori-array.c
+++ /dev/null
@@ -1,1126 +0,0 @@
-/*
- Copyright (C) 2007-2009 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.
-*/
-
-#include <katze/katze.h>
-
-#if HAVE_CONFIG_H
- #include <config.h>
-#endif
-
-#include <glib/gstdio.h>
-#include <glib/gi18n.h>
-#include <sqlite3.h>
-
-#if HAVE_LIBXML
- #include <libxml/parser.h>
- #include <libxml/tree.h>
-#endif
-
-#if HAVE_UNISTD_H
- #include <unistd.h>
-#endif
-
-#define katze_str_equal(str1, str2) !strcmp (str1, str2)
-
-static void
-katze_xbel_parse_info (KatzeItem* item,
- xmlNodePtr cur);
-
-static gchar*
-katze_item_metadata_to_xbel (KatzeItem* item,
- gboolean tiny_xbel);
-
-#if HAVE_LIBXML
-static KatzeItem*
-katze_item_from_xmlNodePtr (xmlNodePtr cur)
-{
- KatzeItem* item;
-
- item = katze_item_new ();
- item->uri = (gchar*)xmlGetProp (cur, (xmlChar*)"href");
-
- cur = cur->xmlChildrenNode;
- while (cur)
- {
- if (katze_str_equal ((gchar*)cur->name, "title"))
- {
- gchar* value = g_strstrip ((gchar*)xmlNodeGetContent (cur));
- katze_item_set_name (item, value);
- xmlFree (value);
- }
- else if (katze_str_equal ((gchar*)cur->name, "desc"))
- {
- gchar* value = g_strstrip ((gchar*)xmlNodeGetContent (cur));
- katze_item_set_text (item, value);
- xmlFree (value);
- }
- else if (katze_str_equal ((gchar*)cur->name, "info"))
- katze_xbel_parse_info (item, cur);
- cur = cur->next;
- }
- return item;
-}
-
-/* Create an array from an xmlNodePtr */
-static KatzeArray*
-katze_array_from_xmlNodePtr (xmlNodePtr cur)
-{
- KatzeArray* array;
- xmlChar* key;
- KatzeItem* item;
-
- array = katze_array_new (KATZE_TYPE_ARRAY);
-
- key = xmlGetProp (cur, (xmlChar*)"folded");
- if (key)
- {
- /* if (!g_ascii_strncasecmp ((gchar*)key, "yes", 3))
- folder->folded = TRUE;
- else if (!g_ascii_strncasecmp ((gchar*)key, "no", 2))
- folder->folded = FALSE;
- else
- g_warning ("XBEL: Unknown value for folded."); */
- xmlFree (key);
- }
-
- cur = cur->xmlChildrenNode;
- while (cur)
- {
- if (katze_str_equal ((gchar*)cur->name, "title"))
- {
- gchar* value = g_strstrip ((gchar*)xmlNodeGetContent (cur));
- katze_item_set_name (KATZE_ITEM (array), value);
- xmlFree (value);
- }
- else if (katze_str_equal ((gchar*)cur->name, "desc"))
- {
- gchar* value = g_strstrip ((gchar*)xmlNodeGetContent (cur));
- katze_item_set_text (KATZE_ITEM (array), value);
- xmlFree (value);
- }
- else if (katze_str_equal ((gchar*)cur->name, "info"))
- katze_xbel_parse_info ((KatzeItem*)array, cur);
- else if (katze_str_equal ((gchar*)cur->name, "folder"))
- {
- item = (KatzeItem*)katze_array_from_xmlNodePtr (cur);
- katze_array_add_item (array, item);
- }
- else if (katze_str_equal ((gchar*)cur->name, "bookmark"))
- {
- item = katze_item_from_xmlNodePtr (cur);
- katze_array_add_item (array, item);
- }
- else if (katze_str_equal ((gchar*)cur->name, "separator"))
- {
- item = katze_item_new ();
- katze_array_add_item (array, item);
- }
- cur = cur->next;
- }
- return array;
-}
-
-static void
-katze_xbel_parse_info (KatzeItem* item,
- xmlNodePtr cur)
-{
- cur = cur->xmlChildrenNode;
- while (cur)
- {
- if (katze_str_equal ((gchar*)cur->name, "metadata"))
- {
- xmlChar* owner = xmlGetProp (cur, (xmlChar*)"owner");
- if (owner)
- g_strstrip ((gchar*)owner);
- else
- /* Albeit required, "owner" is not set by MicroB */
- owner = (xmlChar*)NULL;
- /* FIXME: Save metadata from unknown owners */
- if (!owner || katze_str_equal ((gchar*)owner, "http://www.twotoasts.de"))
- {
- xmlAttrPtr properties = cur->properties;
- xmlNodePtr children = cur->children;
- while (properties)
- {
- xmlChar* value;
-
- if (katze_str_equal ((gchar*)properties->name, "owner"))
- {
- properties = properties->next;
- continue;
- }
- value = xmlGetProp (cur, properties->name);
- if (properties->ns && properties->ns->prefix)
- {
- gchar* ns_value = g_strdup_printf ("%s:%s",
- properties->ns->prefix, properties->name);
- katze_item_set_meta_string (item,
- (gchar*)ns_value, (gchar*)value);
- g_free (ns_value);
- }
- else
- katze_item_set_meta_string (item,
- (gchar*)properties->name, (gchar*)value);
- xmlFree (value);
- properties = properties->next;
- }
- while (children)
- {
- xmlNodePtr grand_children = children->children;
- while (grand_children)
- {
- xmlChar* value = grand_children->content;
- gchar* ns_value;
- if (!owner)
- ns_value = g_strdup_printf (":%s", children->name);
- else if (katze_str_equal ((gchar*)owner, "http://www.twotoasts.de"))
- ns_value = g_strdup_printf ("midori:%s", children->name);
- else /* FIXME: Save metadata from unknown owners */
- ns_value = g_strdup_printf (":%s", children->name);
- katze_item_set_meta_string (item, ns_value, (gchar*)value);
- g_free (ns_value);
- grand_children = grand_children->next;
- }
-
- children = children->next;
- }
- }
- xmlFree (owner);
- }
- else if (!katze_str_equal ((gchar*)cur->name, "text"))
- g_critical ("Unexpected element <%s> in <metadata>.", cur->name);
- cur = cur->next;
- }
-}
-
-/* Loads the contents from an xmlNodePtr into an array. */
-static gboolean
-katze_array_from_xmlDocPtr (KatzeArray* array,
- gboolean tiny_xbel,
- xmlDocPtr doc)
-{
- xmlNodePtr cur;
- KatzeItem* item;
-
- if ((cur = xmlDocGetRootElement (doc)) == NULL)
- {
- /* Empty document */
- return FALSE;
- }
- if (katze_str_equal ((gchar*)cur->name, "xbel"))
- {
- /* XBEL 1.0 */
- gchar* value;
-
- value = (gchar*)xmlGetProp (cur, (xmlChar*)"version");
- if (!tiny_xbel && (!value || !katze_str_equal (value, "1.0")))
- g_warning ("XBEL version is not 1.0.");
- xmlFree (value);
-
- value = (gchar*)xmlGetProp (cur, (xmlChar*)"title");
- katze_item_set_name (KATZE_ITEM (array), value);
- xmlFree (value);
-
- value = (gchar*)xmlGetProp (cur, (xmlChar*)"desc");
- katze_item_set_text (KATZE_ITEM (array), value);
- xmlFree (value);
- }
- else if (katze_str_equal ((gchar*)cur->name, "RDF"))
- {
- /* Minimal RSS 1.0 support, enough to read bookmarks */
- cur = cur->xmlChildrenNode;
- while (cur)
- {
- item = NULL;
- if (katze_str_equal ((gchar*)cur->name, "item"))
- {
- xmlNodePtr cur_item;
- item = katze_item_new ();
-
- cur_item = cur->xmlChildrenNode;
- while (cur_item)
- {
- if (katze_str_equal ((gchar*)cur_item->name, "title"))
- {
- gchar* value = g_strstrip ((gchar*)xmlNodeGetContent (cur_item));
- katze_item_set_name (item, value);
- xmlFree (value);
- }
- else if (katze_str_equal ((gchar*)cur_item->name, "link"))
- {
- gchar* value = g_strstrip ((gchar*)xmlNodeGetContent (cur_item));
- katze_item_set_uri (item, value);
- xmlFree (value);
- }
- else if (katze_str_equal ((gchar*)cur_item->name, "subject"))
- {
- gchar* value = g_strstrip ((gchar*)xmlNodeGetContent (cur_item));
- /* FIXME: Create a folder according to the tag */
- xmlFree (value);
- }
- cur_item = cur_item->next;
- }
- }
- else if (katze_str_equal ((gchar*)cur->name, "channel"))
- /* Ignored */;
- else if (!katze_str_equal ((gchar*)cur->name, "text"))
- g_warning ("Unexpected attribute: %s", (gchar*)cur->name);
- if (item)
- katze_array_add_item (array, item);
- cur = cur->next;
- }
- return TRUE;
- }
- else
- {
- /* Wrong document kind */
- return FALSE;
- }
-
- cur = cur->xmlChildrenNode;
- while (cur)
- {
- item = NULL;
- if (katze_str_equal ((gchar*)cur->name, "folder"))
- item = (KatzeItem*)katze_array_from_xmlNodePtr (cur);
- else if (katze_str_equal ((gchar*)cur->name, "bookmark"))
- item = katze_item_from_xmlNodePtr (cur);
- else if (katze_str_equal ((gchar*)cur->name, "separator"))
- item = katze_item_new ();
- else if (katze_str_equal ((gchar*)cur->name, "info"))
- katze_xbel_parse_info (KATZE_ITEM (array), cur);
- else if (katze_str_equal ((gchar*)cur->name, "title"))
- {
- xmlNodePtr node = cur->xmlChildrenNode;
- katze_item_set_name (KATZE_ITEM (array), (gchar*)node->content);
- }
- else if (katze_str_equal ((gchar*)cur->name, "desc"))
- {
- xmlNodePtr node = cur->xmlChildrenNode;
- katze_item_set_text (KATZE_ITEM (array), (gchar*)node->content);
- }
- else if (!katze_str_equal ((gchar*)cur->name, "text"))
- g_warning ("Unexpected attribute: %s", (gchar*)cur->name);
- if (item)
- katze_array_add_item (array, item);
- cur = cur->next;
- }
- return TRUE;
-}
-
-static gchar*
-katze_unescape_html (const gchar* text)
-{
- gchar* amp = g_strstr_len (text, -1, "&");
-
- if (amp && *amp)
- {
- if (!strncmp (amp, "&quot;", 6) || !strncmp (amp, "&amp;", 5)
- || !strncmp (amp, "&lt;", 4) || !strncmp (amp, "&gt;", 4)
- || !strncmp (amp, "&apos;", 6))
- {
- guint i = 0;
- gchar** parts = g_strsplit_set (text, "&;", -1);
- GString *unescaped = g_string_new (NULL);
-
- while (parts[i])
- {
- if (katze_str_equal ("quot", parts[i]))
- g_string_append (unescaped, "\"");
- else if (katze_str_equal ("amp", parts[i]))
- g_string_append (unescaped, "&");
- else if (katze_str_equal ("lt", parts[i]))
- g_string_append (unescaped, "<");
- else if (katze_str_equal ("gt", parts[i]))
- g_string_append (unescaped, ">");
- else if (katze_str_equal ("apos", parts[i]))
- g_string_append (unescaped, "'");
- else
- g_string_append (unescaped, parts[i]);
- i++;
- }
- g_strfreev (parts);
-
- return g_string_free (unescaped, FALSE);
- }
- }
- return g_strdup (text);
-}
-
-static gboolean
-katze_array_from_netscape_file (KatzeArray* array,
- const gchar* filename)
-{
- gchar* line = NULL;
- GIOChannel* channel = g_io_channel_new_file (filename, "r", 0);
- KatzeArray* folder = array;
- KatzeItem* item = NULL;
-
- if (!channel)
- return FALSE;
-
- while (g_io_channel_read_line (channel, &line, NULL, NULL, NULL)
- == G_IO_STATUS_NORMAL)
- {
- g_strstrip (line);
- /* parse lines with bookmarks data only, skip the rest */
- if (!strncmp (line, "<D", 2) || !strncmp (line, "</D", 3))
- {
- gchar** element = g_strsplit_set (line, "<>", -1);
- /* current item */
- if (katze_str_equal (element[1], "DT"))
- {
- /* item is bookmark */
- if (!strncmp (element[3], "A HREF", 6))
- {
- gchar** parts = g_strsplit (line, "\"", -1);
- item = katze_item_new ();
- katze_array_add_item (folder, item);
- item->name = katze_unescape_html (element[4]);
- item->uri = katze_unescape_html (parts[1]);
- g_strfreev (parts);
- }
- /* item is folder */
- if (!strncmp (element[3], "H3", 2))
- {
- item = (KatzeItem*)katze_array_new (KATZE_TYPE_ARRAY);
- katze_array_add_item (folder, item);
- folder = (KatzeArray*)item;
- item->name = katze_unescape_html (element[4]);
- }
- }
- /* item description */
- if (item && katze_str_equal (element[1], "DD"))
- {
- if (element[2])
- {
- gchar* text = katze_unescape_html (element[2]);
- katze_item_set_text (item, text);
- g_free (text);
- }
- item = NULL;
- }
- /* end of current folder, level-up */
- if (katze_str_equal (element[1], "/DL"))
- {
- if (folder != array)
- folder = katze_item_get_parent ((KatzeItem*)folder);
- continue;
- }
- g_strfreev (element);
- }
- continue;
- }
- g_io_channel_shutdown (channel, FALSE, 0);
- g_io_channel_unref (channel);
- return TRUE;
-}
-
-static gboolean
-katze_array_from_opera_file (KatzeArray* array,
- const gchar* filename)
-{
- gchar* line = NULL;
- GIOChannel* channel = g_io_channel_new_file (filename, "r", 0);
- KatzeArray* folder = array;
- KatzeItem* item = NULL;
-
- if (!channel)
- return FALSE;
-
- while (g_io_channel_read_line (channel, &line, NULL, NULL, NULL)
- == G_IO_STATUS_NORMAL)
- {
- g_strstrip (line);
- /* skip file header */
- if (katze_str_equal (line, "Options: encoding = utf8, version=3")
- || katze_str_equal (line, "Opera Hotlist version 2.0"))
- {
- item = NULL;
- continue;
- }
- if (line[0] == '\0')
- {
- item = NULL;
- continue;
- }
- else if (line[0] == '-')
- {
- item = NULL;
- if (folder != array)
- folder = katze_item_get_parent ((KatzeItem*)folder);
- else
- g_warning ("A level-up although we are at the top level");
- continue;
- }
-
- if (line[0] == '#')
- {
- const gchar* element = &line[1];
- if (!g_ascii_strncasecmp (element, "FOLDER", 6))
- {
- item = (KatzeItem*)katze_array_new (KATZE_TYPE_ARRAY);
- katze_array_add_item (folder, item);
- folder = (KatzeArray*)item;
- }
- else if (!g_ascii_strncasecmp (element, "URL", 3))
- {
- item = katze_item_new ();
- katze_array_add_item (folder, item);
- }
- else
- g_warning ("Unexpected element: %s", element);
- }
- else if (item)
- {
- gchar** parts = g_strsplit (line, "=", 2);
-
- if (parts && parts[0] && parts[1])
- {
- if (katze_str_equal (parts[0], "NAME"))
- katze_item_set_name (item, parts[1]);
- else if (katze_str_equal (parts[0], "URL"))
- katze_item_set_uri (item, parts[1]);
- else if (katze_str_equal (parts[0], "DESCRIPTION"))
- katze_item_set_text (item, parts[1]);
- else if (katze_str_equal (parts[0], "CREATED"))
- katze_item_set_added (item, g_ascii_strtoull (parts[1], NULL, 10));
- /* FIXME: Implement visited time
- else if (katze_str_equal (parts[0], "VISITED"))
- katze_item_set_visited (item, g_ascii_strtoull (parts[1], NULL, 10)); */
- else if (katze_str_equal (parts[0], "ON PERSONALBAR"))
- katze_item_set_meta_integer (item, "toolbar",
- katze_str_equal (parts[1], "YES") ? 1 : -1);
- /* FIXME: Implement websites as panels
- else if (katze_str_equal (parts[0], "IN PANEL"))
- ; */
- }
- else
- g_warning ("Broken property: %s", line);
- g_strfreev (parts);
- }
- else
- g_warning ("Unexpected property outside of element: %s", line);
- }
- g_io_channel_shutdown (channel, FALSE, 0);
- g_io_channel_unref (channel);
- return TRUE;
-}
-
-/**
- * midori_array_from_file:
- * @array: a #KatzeArray
- * @filename: a filename to load from
- * @format: "xbel", "opera", or %NULL
- * @error: a #GError or %NULL
- *
- * Loads the contents of a file in the specified format.
- *
- * Since 0.2.2 @format can be %NULL to indicate that the
- * file should be loaded if it's any supported format.
- *
- * Return value: %TRUE on success, %FALSE otherwise
- *
- * Since: 0.1.6
- **/
-gboolean
-midori_array_from_file (KatzeArray* array,
- const gchar* filename,
- const gchar* format,
- GError** error)
-{
- g_return_val_if_fail (katze_array_is_a (array, KATZE_TYPE_ITEM), FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
- g_return_val_if_fail (!error || !*error, FALSE);
-
- if (!g_file_test (filename, G_FILE_TEST_EXISTS))
- {
- /* File doesn't exist */
- if (error)
- *error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_NOENT,
- _("File not found."));
- return FALSE;
- }
-
- if (!format)
- format = "";
-
- /* netscape html */
- if (!*format && g_str_has_suffix (filename, ".html"))
- {
- FILE* file;
- if ((file = g_fopen (filename, "r")))
- {
- gchar line[50];
- while (fgets (line, 50, file))
- {
- g_strstrip (line);
- if (katze_str_equal (line, "<!DOCTYPE NETSCAPE-Bookmark-file-1>"))
- {
- if (!katze_array_from_netscape_file (array, filename))
- {
- /* Parsing failed */
- fclose (file);
- if (error)
- *error = g_error_new_literal (G_FILE_ERROR,
- G_FILE_ERROR_FAILED, _("Malformed document."));
- return FALSE;
- }
- return TRUE;
- }
- else
- break;
- }
- fclose (file);
- }
- }
-
- /* Opera6 */
- if (katze_str_equal (format, "opera")
- || (!*format && g_str_has_suffix (filename, ".adr")))
- {
- FILE* file;
- if ((file = g_fopen (filename, "r")))
- {
- guint verify;
- gchar line[50];
-
- verify = 0;
- while (fgets (line, 50, file))
- {
- g_strstrip (line);
- if (verify == 0 && katze_str_equal (line, "Opera Hotlist version 2.0"))
- verify++;
- else if (verify == 1
- && katze_str_equal (line, "Options: encoding = utf8, version=3"))
- verify++;
- else if (verify == 2)
- {
- if (!katze_array_from_opera_file (array, filename))
- {
- /* Parsing failed */
- fclose (file);
- if (error)
- *error = g_error_new_literal (G_FILE_ERROR,
- G_FILE_ERROR_FAILED, _("Malformed document."));
- return FALSE;
- }
- return TRUE;
- }
- else
- break;
- }
- fclose (file);
- }
- }
-
- /* XBEL */
- if (katze_str_equal (format, "xbel")
- || katze_str_equal (format, "xbel-tiny")
- || !*format)
- {
- xmlDocPtr doc;
-
- if ((doc = xmlParseFile (filename)) == NULL)
- {
- /* No valid xml or broken encoding */
- if (error)
- *error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_FAILED,
- _("Malformed document."));
- return FALSE;
- }
-
- if (!katze_array_from_xmlDocPtr (array, katze_str_equal (format, "xbel-tiny"), doc))
- {
- /* Parsing failed */
- xmlFreeDoc (doc);
- if (error)
- *error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_FAILED,
- _("Malformed document."));
- return FALSE;
- }
- xmlFreeDoc (doc);
- return TRUE;
- }
-
- if (error)
- *error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_FAILED,
- _("Unrecognized bookmark format."));
- return FALSE;
-}
-#endif
-
-/* Inspired by append_escaped_text() from gmarkup.c in Glib.
- The main difference is that we filter out control characters. */
-static void
-string_append_escaped (GString *str,
- const gchar *text)
-{
- gssize length;
- const gchar* p;
- const gchar* end;
- gunichar c;
-
- length = strlen (text);
- p = text;
- end = text + length;
-
- while (p != end)
- {
- const gchar *next;
- next = g_utf8_next_char (p);
-
- switch (*p)
- {
- case '&':
- g_string_append (str, "&amp;");
- break;
- case '<':
- g_string_append (str, "&lt;");
- break;
- case '>':
- g_string_append (str, "&gt;");
- break;
- case '\'':
- g_string_append (str, "&apos;");
- break;
- case '"':
- g_string_append (str, "&quot;");
- break;
- default:
- c = g_utf8_get_char (p);
- if (g_unichar_iscntrl (c))
- g_string_append_c (str, ' ');
- else if ((0x1 <= c && c <= 0x8)
- || (0xb <= c && c <= 0xc)
- || (0xe <= c && c <= 0x1f)
- || (0x7f <= c && c <= 0x84)
- || (0x86 <= c && c <= 0x9f))
- g_string_append_printf (str, "&#x%x;", c);
- else
- g_string_append_len (str, p, next - p);
- break;
- }
-
- p = next;
- }
-}
-
-static void
-string_append_xml_element (GString* string,
- const gchar* name,
- const gchar* value)
-{
- if (value)
- {
- g_string_append_printf (string, "<%s>", name);
- string_append_escaped (string, value);
- g_string_append_printf (string, "</%s>\n", name);
- }
-}
-
-static void
-string_append_item (GString* string,
- KatzeItem* item,
- gboolean tiny_xbel)
-{
- gchar* metadata;
-
- g_return_if_fail (KATZE_IS_ITEM (item));
-
- metadata = katze_item_metadata_to_xbel (item, tiny_xbel);
- if (KATZE_IS_ARRAY (item))
- {
- KatzeItem* _item;
- KatzeArray* array = KATZE_ARRAY (item);
- GList* list;
-
- g_string_append (string, "<folder>\n");
- /* FIXME: " folded=\"no\" */
- string_append_xml_element (string, "title", katze_item_get_name (item));
- string_append_xml_element (string, "desc", katze_item_get_text (item));
- KATZE_ARRAY_FOREACH_ITEM_L (_item, array, list)
- string_append_item (string, _item, tiny_xbel);
- g_string_append (string, metadata);
- g_string_append (string, "</folder>\n");
- g_list_free (list);
- }
- else if (katze_item_get_uri (item))
- {
- g_string_append (string, "<bookmark href=\"");
- string_append_escaped (string, katze_item_get_uri (item));
- g_string_append (string, "\">\n");
- /* Strip LRE leading character */
- if (item->name != NULL && g_str_has_prefix (item->name, "‪"))
- string_append_xml_element (string, "title",
- g_utf8_next_char (strstr (item->name, "‪")));
- else
- string_append_xml_element (string, "title", item->name);
- string_append_xml_element (string, "desc", katze_item_get_text (item));
- g_string_append (string, metadata);
- g_string_append (string, "</bookmark>\n");
- }
- else
- g_string_append (string, "<separator/>\n");
- g_free (metadata);
-}
-
-static void
-string_append_netscape_item (GString* string,
- KatzeItem* item)
-{
- g_return_if_fail (KATZE_IS_ITEM (item));
-
- if (KATZE_IS_ARRAY (item))
- {
- KatzeItem* _item;
- KatzeArray* array = KATZE_ARRAY (item);
- GList* list;
-
- g_string_append (string, "\t<DT><H3 FOLDED ADD_DATE=\"\">");
- string_append_escaped (string, katze_item_get_name (item));
- g_string_append (string, "</H3>\n");
- g_string_append (string, "\t<DL><P>\n");
- KATZE_ARRAY_FOREACH_ITEM_L (_item, array, list)
- {
- g_string_append (string, "\t");
- string_append_netscape_item (string, _item);
- }
- g_string_append (string, "\t</DL><P>\n");
-
- g_list_free (list);
- }
- else if (katze_item_get_uri (item))
- {
- g_string_append (string, "\t<DT><A HREF=\"");
- string_append_escaped (string, katze_item_get_uri (item));
- g_string_append (string, "\" ADD_DATE=\"\" LAST_VISIT=\"\" LAST_MODIFIED=\"\">");
- string_append_escaped (string, katze_item_get_name (item));
- g_string_append (string, "</A>\n");
-
- if (g_strcmp0 (katze_str_non_null (katze_item_get_text (item)), ""))
- {
- g_string_append (string, "\t<DD>");
- string_append_escaped (string, katze_item_get_text (item));
- g_string_append (string, "\n");
- }
- }
-}
-
-static gchar*
-katze_item_metadata_to_xbel (KatzeItem* item,
- gboolean tiny_xbel)
-{
- GList* keys = katze_item_get_meta_keys (item);
- GString* markup;
- GString* markdown;
- /* FIXME: Allow specifying an alternative default namespace */
- /* FIXME: Support foreign namespaces with their own URI */
- gchar* namespace = NULL;
- const gchar* namespace_uri;
- gsize i;
- const gchar* key;
- const gchar* value;
-
- if (!keys)
- return NULL;
-
- markup = g_string_new ("<info>\n<metadata");
- markdown = g_string_new (NULL);
- i = 0;
- while ((key = g_list_nth_data (keys, i++)))
- if ((value = katze_item_get_meta_string (item, key)))
- {
- namespace = strchr (key, ':');
- if (key[0] == ':') /* MicroB uses un-namespaced children */
- {
- key = &key[1];
- g_string_append_printf (markdown, "<%s>", key);
- string_append_escaped (markdown, value);
- g_string_append_printf (markdown, "</%s>\n", key);
- }
- else if (namespace || tiny_xbel)
- {
- g_string_append_printf (markup, " %s=\"", key);
- string_append_escaped (markup, value);
- g_string_append_c (markup, '\"');
- }
- else
- {
- g_string_append_printf (markup, " midori:%s=\"", key);
- string_append_escaped (markup, value);
- g_string_append_c (markup, '\"');
- }
- }
- if (!namespace && !tiny_xbel)
- {
- namespace_uri = "http://www.twotoasts.de";
- g_string_append_printf (markup, " owner=\"%s\"", namespace_uri);
- }
- if (markdown->len)
- g_string_append_printf (markup, ">\n%s</metadata>\n</info>\n", markdown->str);
- else
- g_string_append_printf (markup, "/>\n</info>\n");
- g_string_free (markdown, TRUE);
- return g_string_free (markup, FALSE);
-}
-
-static gchar*
-katze_array_to_xbel (KatzeArray* array,
- gboolean tiny_xbel,
- GError** error)
-{
- gchar* metadata = katze_item_metadata_to_xbel (KATZE_ITEM (array), tiny_xbel);
- KatzeItem* item;
- GList* list;
-
- GString* markup = g_string_new ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- if (tiny_xbel)
- g_string_append (markup, "<xbel>\n");
- else
- g_string_append (markup,
- "<!DOCTYPE xbel PUBLIC \"+//IDN python.org//DTD "
- "XML Bookmark Exchange Language 1.0//EN//XML\" "
- "\"http://www.python.org/topics/xml/dtds/xbel-1.0.dtd\">\n"
- "<xbel version=\"1.0\" xmlns:midori=\"http://www.twotoasts.de\">\n");
- string_append_xml_element (markup, "title", katze_item_get_name (KATZE_ITEM (array)));
- string_append_xml_element (markup, "desc", katze_item_get_text (KATZE_ITEM (array)));
- g_string_append (markup, metadata ? metadata : "");
- KATZE_ARRAY_FOREACH_ITEM_L (item, array, list)
- string_append_item (markup, item, tiny_xbel);
- g_string_append (markup, "</xbel>\n");
-
- g_free (metadata);
- g_list_free (list);
-
- return g_string_free (markup, FALSE);
-}
-
-static gchar*
-katze_array_to_netscape_html (KatzeArray* array,
- GError** error)
-{
- KatzeItem* item;
- GList* list;
-
- /* The header, including the text, is the same as used in other browsers,
- see http://msdn.microsoft.com/en-us/library/aa753582(v=vs.85).aspx */
- GString* markup = g_string_new (
- "<!DOCTYPE NETSCAPE-Bookmark-file-1>\n"
- "<!--This is an automatically generated file.\n"
- "It will be read and overwritten.\n"
- "Do Not Edit! -->\n"
- "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">\n"
- "<Title>Bookmarks</Title>\n"
- "<H1>Bookmarks</H1>\n"
- "\n");
- g_string_append (markup, "<DL><P>\n");
- KATZE_ARRAY_FOREACH_ITEM_L (item, array, list)
- string_append_netscape_item (markup, item);
- g_string_append (markup, "</DL><P>\n");
-
- g_list_free (list);
- return g_string_free (markup, FALSE);
-}
-
-static gboolean
-midori_array_to_file_format (KatzeArray* array,
- const gchar* filename,
- const gchar* format,
- GError** error)
-{
- gchar* data;
- gboolean success;
-
- if (!g_strcmp0 (format, "xbel"))
- data = katze_array_to_xbel (array, FALSE, error);
- else if (!g_strcmp0 (format, "xbel-tiny"))
- data = katze_array_to_xbel (array, TRUE, error);
- else if (!g_strcmp0 (format, "netscape"))
- data = katze_array_to_netscape_html (array, error);
- else
- return FALSE;
-
- success = g_file_set_contents (filename, data, -1, error);
- g_free (data);
- return success;
-}
-
-/**
- * midori_array_to_file:
- * @array: a #KatzeArray
- * @filename: a filename to load from
- * @format: the desired format
- * @error: a #GError or %NULL
- *
- * Saves the contents to a file in the specified format.
- *
- * Return value: %TRUE on success, %FALSE otherwise
- *
- * Since: 0.1.6
- **/
-gboolean
-midori_array_to_file (KatzeArray* array,
- const gchar* filename,
- const gchar* format,
- GError** error)
-{
- g_return_val_if_fail (katze_array_is_a (array, KATZE_TYPE_ITEM), FALSE);
- g_return_val_if_fail (filename, FALSE);
- g_return_val_if_fail (!error || !*error, FALSE);
-
- if (!g_strcmp0 (format, "xbel")
- || !g_strcmp0 (format, "xbel-tiny")
- || !g_strcmp0 (format, "netscape"))
- return midori_array_to_file_format (array, filename, format, error);
-
- g_critical ("Cannot write KatzeArray to unknown format '%s'.", format);
- return FALSE;
-}
-
-/**
- * katze_item_set_value_from_columne:
- * @stmt: prepared statement
- * @column: column to read
- * @item: #KatzeItem to populate
- *
- * Stores the column in the given #KatzeItem.
- *
- * Since: 0.2.7
- **/
-void
-katze_item_set_value_from_column (sqlite3_stmt* stmt,
- gint column,
- KatzeItem* item)
-{
- const gchar* name;
-
- name = sqlite3_column_name (stmt, column);
- g_return_if_fail (name != NULL);
-
- if (g_str_equal (name, "uri"))
- {
- const unsigned char* uri;
- uri = sqlite3_column_text (stmt, column);
- if (uri && uri[0] && uri[0] != '(')
- katze_item_set_uri (item, (gchar*)uri);
- }
- else if (g_str_equal (name, "title") || g_str_equal (name, "name"))
- {
- const unsigned char* title;
- title = sqlite3_column_text (stmt, column);
- katze_item_set_name (item, (gchar*)title);
- }
- else if (g_str_equal (name, "date") || g_str_equal (name, "created"))
- {
- gint date;
- date = sqlite3_column_int64 (stmt, column);
- katze_item_set_added (item, date);
- }
- else if (g_str_equal (name, "day") || g_str_equal (name, "app")
- || g_str_equal (name, "toolbar") || g_str_equal (name, "id")
- || g_str_equal (name, "parentid") || g_str_equal (name, "seq")
- || g_str_equal (name, "last_visit") || g_str_equal (name, "visit_count")
- || g_str_equal (name, "pos_panel") || g_str_equal (name, "pos_bar"))
- {
- /* use text to properly handle NULL values */
- const unsigned char* text;
- text = sqlite3_column_text (stmt, column);
- katze_item_set_meta_string (item, name, (gchar*)text);
- }
- else if (g_str_equal (name, "desc"))
- {
- const unsigned char* text;
- text = sqlite3_column_text (stmt, column);
- katze_item_set_text (item, (gchar*)text);
- }
- else if (g_str_equal (name, "nick"))
- {
- const unsigned char* sql;
- sql = sqlite3_column_text (stmt, column);
- katze_item_set_meta_string (item, name, (gchar*)sql);
- }
- else
- g_critical ("%s: Unexpected column '%s'", G_STRFUNC, name);
-}
-
-/**
- * midori_array_from_statement:
- * @stmt: prepared statement
- *
- * Stores the result in a #KatzeArray.
- *
- * Return value: a #KatzeArray on success, %NULL otherwise
- *
- * Since: 0.2.7
- **/
-KatzeArray*
-katze_array_from_statement (sqlite3_stmt* stmt)
-{
- KatzeArray *array;
- gint result;
- gint cols;
-
- array = katze_array_new (KATZE_TYPE_ITEM);
- cols = sqlite3_column_count (stmt);
-
- while ((result = sqlite3_step (stmt)) == SQLITE_ROW)
- {
- gint i;
- KatzeItem* item;
-
- item = katze_item_new ();
- for (i = 0; i < cols; i++)
- katze_item_set_value_from_column (stmt, i, item);
-
- if (KATZE_ITEM_IS_FOLDER (item))
- {
- g_object_unref (item);
-
- item = KATZE_ITEM (katze_array_new (KATZE_TYPE_ITEM));
-
- for (i = 0; i < cols; i++)
- katze_item_set_value_from_column (stmt, i, item);
- }
-
- katze_array_add_item (array, item);
- }
-
- sqlite3_clear_bindings (stmt);
- sqlite3_reset (stmt);
- return array;
-}
-
-/**
- * midori_array_from_sqlite:
- * @db: opened database handler
- * @sqlcmd: SQL query
- *
- * Stores the result in a #KatzeArray.
- *
- * Return value: a #KatzeArray on success, %NULL otherwise
- *
- * Since: 0.2.7
- **/
-
-KatzeArray*
-katze_array_from_sqlite (sqlite3* db,
- const gchar* sqlcmd)
-{
- sqlite3_stmt* stmt;
- gint result;
-
- result = sqlite3_prepare_v2 (db, sqlcmd, -1, &stmt, NULL);
- if (result != SQLITE_OK)
- return NULL;
-
- return katze_array_from_statement (stmt);
-}
diff --git a/midori/midori-array.h b/midori/midori-array.h
deleted file mode 100644
index adaa1076..00000000
--- a/midori/midori-array.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- Copyright (C) 2007-2009 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 __MIDORI_ARRAY_H__
-#define __MIDORI_ARRAY_H__ 1
-
-#include <sqlite3.h>
-#include <katze/katze.h>
-
-gboolean
-midori_array_from_file (KatzeArray* array,
- const gchar* filename,
- const gchar* format,
- GError** error);
-
-gboolean
-midori_array_to_file (KatzeArray* array,
- const gchar* filename,
- const gchar* format,
- GError** error);
-
-void
-katze_item_set_value_from_column (sqlite3_stmt* stmt,
- gint column,
- KatzeItem* item);
-
-KatzeArray*
-katze_array_from_statement (sqlite3_stmt* stmt);
-
-KatzeArray*
-katze_array_from_sqlite (sqlite3* db,
- const gchar* sqlcmd);
-
-#endif /* !__MIDORI_ARRAY_H__ */
diff --git a/midori/midori-bookmarks-db.c b/midori/midori-bookmarks-db.c
deleted file mode 100644
index 1d4be61e..00000000
--- a/midori/midori-bookmarks-db.c
+++ /dev/null
@@ -1,1151 +0,0 @@
-/*
- Copyright (C) 2010 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2010 Alexander Butenko <a.butenka@gmail.com>
-
- 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.
-*/
-
-#include "midori-bookmarks-db.h"
-
-#include "midori-app.h"
-#include "midori-array.h"
-#include "sokoke.h"
-#include "midori-core.h"
-
-#include <glib/gstdio.h>
-#include <glib/gi18n.h>
-
-#include <config.h>
-#ifdef HAVE_UNISTD_H
- #include <unistd.h>
-#endif
-
-/**
- * SECTION:midory-bookmarks-db
- * @short_description: A #KatzeArray connected to a database
- * @see_also: #KatzeArray
- *
- * #MidoriBookmarksDb is a #KatzeArray specialized for database
- * interraction.
- */
-
-struct _MidoriBookmarksDb
-{
- KatzeArray parent_instance;
-
- sqlite3* db;
- GHashTable* all_items;
-};
-
-struct _MidoriBookmarksDbClass
-{
- KatzeArrayClass parent_class;
-
- /* Signals */
- void
- (*update_item) (MidoriBookmarksDb* bookmarks,
- gpointer item);
-};
-
-G_DEFINE_TYPE (MidoriBookmarksDb, midori_bookmarks_db, KATZE_TYPE_ARRAY);
-
-enum {
- UPDATE_ITEM,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-_midori_bookmarks_db_add_item (KatzeArray* array,
- gpointer item);
-
-static void
-_midori_bookmarks_db_update_item (MidoriBookmarksDb* bookmarks,
- gpointer item);
-
-static void
-_midori_bookmarks_db_remove_item (KatzeArray* array,
- gpointer item);
-
-static void
-_midori_bookmarks_db_move_item (KatzeArray* array,
- gpointer item,
- gint position);
-
-static void
-_midori_bookmarks_db_clear (KatzeArray* array);
-
-static void
-midori_bookmarks_db_finalize (GObject* object);
-
-static gint64
-midori_bookmarks_db_insert_item_db (sqlite3* db,
- KatzeItem* item,
- gint64 parentid);
-
-static gboolean
-midori_bookmarks_db_update_item_db (sqlite3* db,
- KatzeItem* item);
-
-static gboolean
-midori_bookmarks_db_remove_item_db (sqlite3* db,
- KatzeItem* item);
-
-static guint
-item_hash (gconstpointer item)
-{
- gint64 id = katze_item_get_meta_integer (KATZE_ITEM (item), "id");
- return g_int64_hash (&id);
-}
-
-static gboolean
-item_equal (gconstpointer item_a, gconstpointer item_b)
-{
- gint64 id_a = katze_item_get_meta_integer (KATZE_ITEM (item_a), "id");
- gint64 id_b = katze_item_get_meta_integer (KATZE_ITEM (item_b), "id");
- return (id_a == id_b)? TRUE : FALSE;
-}
-
-static void
-midori_bookmarks_db_class_init (MidoriBookmarksDbClass* class)
-{
- GObjectClass* gobject_class;
- KatzeArrayClass* katze_array_class;
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = midori_bookmarks_db_finalize;
-
- signals[UPDATE_ITEM] = g_signal_new (
- "update-item",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- G_STRUCT_OFFSET (MidoriBookmarksDbClass, update_item),
- 0,
- NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
-
- katze_array_class = KATZE_ARRAY_CLASS (class);
-
- katze_array_class->add_item = _midori_bookmarks_db_add_item;
- katze_array_class->remove_item = _midori_bookmarks_db_remove_item;
- katze_array_class->move_item = _midori_bookmarks_db_move_item;
- katze_array_class->clear = _midori_bookmarks_db_clear;
-
- class->update_item = _midori_bookmarks_db_update_item;
-}
-
-static void
-midori_bookmarks_db_init (MidoriBookmarksDb* bookmarks)
-{
- bookmarks->db = NULL;
- bookmarks->all_items = g_hash_table_new (item_hash, item_equal);
-
- katze_item_set_meta_integer (KATZE_ITEM (bookmarks), "id", -1);
- katze_item_set_name (KATZE_ITEM (bookmarks), _("Bookmarks"));
- g_hash_table_insert (bookmarks->all_items, bookmarks, bookmarks);
- /* g_object_ref (bookmarks); */
-}
-
-static void
-midori_bookmarks_db_finalize (GObject* object)
-{
- MidoriBookmarksDb* bookmarks = MIDORI_BOOKMARKS_DB (object);
-
- if (bookmarks->db)
- {
- sqlite3_close (bookmarks->db);
- }
-
- g_hash_table_unref (bookmarks->all_items);
-
- G_OBJECT_CLASS (midori_bookmarks_db_parent_class)->finalize (object);
-}
-
-/**
- * midori_bookmarks_db_get_item_parent:
- * @bookmarks: the main bookmarks array
- * @item: a #KatzeItem
- *
- * Internal function that find the parent of the @item thanks to its %parentid
- **/
-static KatzeArray*
-midori_bookmarks_db_get_item_parent (MidoriBookmarksDb* bookmarks,
- gpointer item)
-{
- gint64 parentid = katze_item_get_meta_integer (KATZE_ITEM (item), "parentid");
- KatzeItem *search = katze_item_new ();
- KatzeArray* parent;
-
- if (!parentid)
- {
- parentid = katze_item_get_meta_integer (KATZE_ITEM (bookmarks), "id");
- katze_item_set_meta_integer (KATZE_ITEM (item), "parentid", parentid);
- }
-
- katze_item_set_meta_integer(search, "id", parentid);
-
- parent = KATZE_ARRAY (g_hash_table_lookup (bookmarks->all_items, search));
-
- g_object_unref (search);
-
- if (!parent)
- {
- parent = KATZE_ARRAY (bookmarks);
- katze_item_set_meta_integer (KATZE_ITEM (item), "parentid",
- katze_item_get_meta_integer (KATZE_ITEM (bookmarks), "id"));
- }
-
- return parent;
-}
-
-/**
- * _midori_bookmarks_db_add_item:
- * @array: the main bookmarks array
- * @item: a #KatzeItem
- *
- * Internal function that overloads the #KatzeArray %katze_array_add_item().
- * It relays the add item to the appropriate #KatzeArray.
- **/
-static void
-_midori_bookmarks_db_add_item (KatzeArray* array,
- gpointer item)
-{
- MidoriBookmarksDb *bookmarks;
- KatzeArray* parent;
- KatzeArray* db_parent;
-
- g_return_if_fail (IS_MIDORI_BOOKMARKS_DB (array));
- g_return_if_fail (KATZE_IS_ITEM (item));
-
- bookmarks = MIDORI_BOOKMARKS_DB (array);
-
- parent = katze_item_get_parent (KATZE_ITEM (item));
-
- db_parent = midori_bookmarks_db_get_item_parent (bookmarks, item);
-
- if (parent == db_parent)
- {
- if (IS_MIDORI_BOOKMARKS_DB (parent))
- KATZE_ARRAY_CLASS (midori_bookmarks_db_parent_class)->update (parent);
- else if (KATZE_IS_ARRAY (parent))
- katze_array_update (parent);
- return;
- }
-
- if (IS_MIDORI_BOOKMARKS_DB (db_parent))
- KATZE_ARRAY_CLASS (midori_bookmarks_db_parent_class)->add_item (db_parent, item);
- else if (KATZE_IS_ARRAY (db_parent))
- katze_array_add_item (db_parent, item);
-
- g_assert (db_parent == katze_item_get_parent (KATZE_ITEM (item)));
-}
-
-/**
- * _midori_bookmarks_db_update_item:
- * @array: the main bookmarks array
- * @item: a #KatzeItem
- *
- * Internal function that implements the %midori_bookmarks_db_update_item() post-processing.
- * It relays an update to the appropriate #KatzeArray.
- **/
-static void
-_midori_bookmarks_db_update_item (MidoriBookmarksDb* bookmarks,
- gpointer item)
-{
- KatzeArray* parent;
-
- g_return_if_fail (IS_MIDORI_BOOKMARKS_DB (bookmarks));
- g_return_if_fail (KATZE_IS_ITEM (item));
-
- parent = katze_item_get_parent (KATZE_ITEM (item));
-
- g_return_if_fail (parent);
-
- if (IS_MIDORI_BOOKMARKS_DB (parent))
- KATZE_ARRAY_CLASS (midori_bookmarks_db_parent_class)->update (parent);
- else
- katze_array_update (parent);
-}
-
-/**
- * _midori_bookmarks_db_remove_item:
- * @array: the main bookmarks array
- * @item: a #KatzeItem
- *
- * Internal function that overloads the #KatzeArray %katze_array_remove_item().
- * It relays the remove item to the appropriate #KatzeArray.
- **/
-static void
-_midori_bookmarks_db_remove_item (KatzeArray* array,
- gpointer item)
-{
- KatzeArray* parent;
-
- g_return_if_fail (IS_MIDORI_BOOKMARKS_DB (array));
- g_return_if_fail (KATZE_IS_ITEM (item));
-
- parent = katze_item_get_parent (KATZE_ITEM (item));
-
- g_return_if_fail (parent);
-
- if (IS_MIDORI_BOOKMARKS_DB (parent))
- KATZE_ARRAY_CLASS (midori_bookmarks_db_parent_class)->remove_item (parent, item);
- else if (KATZE_IS_ARRAY (parent))
- katze_array_remove_item (parent, item);
-}
-
-/**
- * _midori_bookmarks_db_move_item:
- * @array: the main bookmarks array
- * @item: a #KatzeItem
- * @position: the new @item position
- *
- * Internal function that overloads the #KatzeArray %katze_array_move_item().
- * It relays the move @item to the appropriate #KatzeArray.
- **/
-static void
-_midori_bookmarks_db_move_item (KatzeArray* array,
- gpointer item,
- gint position)
-{
- KatzeArray* parent;
-
- g_return_if_fail (IS_MIDORI_BOOKMARKS_DB (array));
- g_return_if_fail (KATZE_IS_ITEM (item));
-
- parent = katze_item_get_parent (KATZE_ITEM (item));
-
- g_return_if_fail (parent);
-
- KATZE_ARRAY_CLASS (midori_bookmarks_db_parent_class)->move_item (parent, item, position);
-}
-
-/**
- * _midori_bookmarks_db_clear:
- * @array: the main bookmarks array
- *
- * Internal function that overloads the #KatzeArray %katze_array_clear().
- * It deletes the whole bookmarks data.
- **/
-static void
-_midori_bookmarks_db_clear (KatzeArray* array)
-{
- g_return_if_fail (IS_MIDORI_BOOKMARKS_DB (array));
-
- g_critical ("_midori_bookmarks_db_clear: not implemented\n");
-}
-
-/**
- * midori_bookmarks_db_signal_update_item:
- * @array: a #KatzeArray
- * @item: an item
- *
- * Notify an update of the item of the array.
- *
- **/
-static void
-midori_bookmarks_db_signal_update_item (MidoriBookmarksDb* array,
- gpointer item)
-{
- g_return_if_fail (IS_MIDORI_BOOKMARKS_DB (array));
-
- g_signal_emit (array, signals[UPDATE_ITEM], 0, item);
-}
-
-/**
- * midori_bookmarks_db_add_item_recursive:
- * @item: the removed #KatzeItem
- * @bookmarks : the main bookmarks array
- *
- * Internal function that creates memory records of the added @item.
- * If @item is a #KatzeArray, the function recursiveley adds records
- * of all its childs.
- **/
-static gint
-midori_bookmarks_db_add_item_recursive (MidoriBookmarksDb* bookmarks,
- KatzeItem* item)
-{
- GList* list;
- KatzeArray* array;
- gint64 id = 0;
- gint count = 0;
- gint64 parentid = katze_item_get_meta_integer (item, "parentid");
-
- id = midori_bookmarks_db_insert_item_db (bookmarks->db, item, parentid);
- count++;
-
- g_object_ref (item);
- g_hash_table_insert (bookmarks->all_items, item, item);
-
- if (!KATZE_IS_ARRAY (item))
- return count;
-
- array = KATZE_ARRAY (item);
-
- KATZE_ARRAY_FOREACH_ITEM_L (item, array, list)
- {
- katze_item_set_meta_integer (item, "parentid", id);
- count += midori_bookmarks_db_add_item_recursive (bookmarks, item);
- }
-
- g_list_free (list);
- return count;
-}
-
-/**
- * midori_bookmarks_db_remove_item_recursive:
- * @item: the removed #KatzeItem
- * @bookmarks : the main bookmarks array
- *
- * Internal function that removes memory records of the removed @item.
- * If @item is a #KatzeArray, the function recursiveley removes records
- * of all its childs.
- **/
-static void
-midori_bookmarks_db_remove_item_recursive (KatzeItem* item,
- MidoriBookmarksDb* bookmarks)
-{
- gpointer found;
- KatzeArray* array;
- KatzeItem* child;
- GList* list;
-
- if (NULL != (found = g_hash_table_lookup (bookmarks->all_items, item)))
- {
- g_hash_table_remove (bookmarks->all_items, found);
- g_object_unref (found);
- }
-
- if (!KATZE_IS_ARRAY (item))
- return;
-
- array = KATZE_ARRAY (item);
-
- KATZE_ARRAY_FOREACH_ITEM_L (child, array, list)
- {
- midori_bookmarks_db_remove_item_recursive (child, bookmarks);
- }
-
- g_list_free (list);
-}
-
-/**
- * midori_bookmarks_db_insert_item_db:
- * @db: the #sqlite3
- * @item: #KatzeItem the item to insert
- *
- * Internal function that does the actual SQL INSERT of the @item in @db.
- *
- * Since: 0.5.2
- **/
-static gint64
-midori_bookmarks_db_insert_item_db (sqlite3* db,
- KatzeItem* item,
- gint64 parentid)
-{
- gchar* sqlcmd;
- char* errmsg = NULL;
- KatzeItem* old_parent;
- gchar* new_parentid;
- gchar* id = NULL;
- const gchar* uri = NULL;
- const gchar* desc = NULL;
- gint64 seq = 0;
-
- /* Bookmarks must have a name, import may produce invalid items */
- g_return_val_if_fail (katze_item_get_name (item), seq);
-
- if (!db)
- return seq;
-
- if (katze_item_get_meta_integer (item, "id") > 0)
- id = g_strdup_printf ("%" G_GINT64_FORMAT, katze_item_get_meta_integer(item, "id"));
- else
- id = g_strdup_printf ("NULL");
-
- if (KATZE_ITEM_IS_BOOKMARK (item))
- uri = katze_item_get_uri (item);
-
- if (katze_item_get_text (item))
- desc = katze_item_get_text (item);
-
- /* Use folder, otherwise fallback to parent folder */
- old_parent = katze_item_get_parent (item);
- if (parentid > 0)
- new_parentid = g_strdup_printf ("%" G_GINT64_FORMAT, parentid);
- else if (old_parent && katze_item_get_meta_integer (old_parent, "id") > 0)
- new_parentid = g_strdup_printf ("%" G_GINT64_FORMAT, katze_item_get_meta_integer (old_parent, "id"));
- else
- new_parentid = g_strdup_printf ("NULL");
-
- sqlcmd = sqlite3_mprintf (
- "INSERT INTO bookmarks (id, parentid, title, uri, desc, toolbar, app) "
- "VALUES (%q, %q, '%q', '%q', '%q', %d, %d)",
- id,
- new_parentid,
- katze_item_get_name (item),
- katze_str_non_null (uri),
- katze_str_non_null (desc),
- katze_item_get_meta_boolean (item, "toolbar"),
- katze_item_get_meta_boolean (item, "app"));
-
- if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) == SQLITE_OK)
- {
- /* Get insert id */
- if (g_str_equal (id, "NULL"))
- {
- KatzeArray* seq_array;
-
- sqlite3_free (sqlcmd);
- sqlcmd = sqlite3_mprintf (
- "SELECT seq FROM sqlite_sequence WHERE name = 'bookmarks'");
-
- seq_array = katze_array_from_sqlite (db, sqlcmd);
- if (katze_array_get_nth_item (seq_array, 0))
- {
- KatzeItem* seq_item = katze_array_get_nth_item (seq_array, 0);
-
- seq = katze_item_get_meta_integer (seq_item, "seq");
- katze_item_set_meta_integer (item, "id", seq);
- }
- g_object_unref (seq_array);
- }
- }
- else
- {
- g_printerr (_("Failed to add bookmark item: %s\n"), errmsg);
- sqlite3_free (errmsg);
- }
-
- sqlite3_free (sqlcmd);
- g_free (new_parentid);
- g_free (id);
-
- return seq;
-}
-
-/**
- * midori_bookmarks_db_update_item_db:
- * @db: the #sqlite3
- * @item: #KatzeItem the item to update
- *
- * Internal function that does the actual SQL UPDATE of the @item in @db.
- *
- * Since: 0.5.2
- **/
-static gboolean
-midori_bookmarks_db_update_item_db (sqlite3* db,
- KatzeItem* item)
-{
- gchar* sqlcmd;
- char* errmsg = NULL;
- gchar* parentid;
- gboolean updated;
- gchar* id;
-
- id = g_strdup_printf ("%" G_GINT64_FORMAT,
- katze_item_get_meta_integer (item, "id"));
-
- if (katze_item_get_meta_integer (item, "parentid") > 0)
- parentid = g_strdup_printf ("%" G_GINT64_FORMAT,
- katze_item_get_meta_integer (item, "parentid"));
- else
- parentid = g_strdup_printf ("NULL");
-
- sqlcmd = sqlite3_mprintf (
- "UPDATE bookmarks SET "
- "parentid=%q, title='%q', uri='%q', desc='%q', toolbar=%d, app=%d "
- "WHERE id = %q ;",
- parentid,
- katze_item_get_name (item),
- katze_str_non_null (katze_item_get_uri (item)),
- katze_str_non_null (katze_item_get_meta_string (item, "desc")),
- katze_item_get_meta_boolean (item, "toolbar"),
- katze_item_get_meta_boolean (item, "app"),
- id);
-
- updated = TRUE;
- if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK)
- {
- updated = FALSE;
- g_printerr (_("Failed to update bookmark: %s\n"), errmsg);
- sqlite3_free (errmsg);
- }
-
- sqlite3_free (sqlcmd);
- g_free (parentid);
- g_free (id);
-
- return updated;
-}
-
-/**
- * midori_bookmarks_db_remove_item_db:
- * @db: the #sqlite3
- * @item: #KatzeItem the item to delete
- *
- * Internal function that does the actual SQL DELETE of the @item in @db.
- *
- * Since: 0.5.2
- **/
-static gboolean
-midori_bookmarks_db_remove_item_db (sqlite3* db,
- KatzeItem* item)
-{
- char* errmsg = NULL;
- gchar* sqlcmd;
- gboolean removed = TRUE;
- gchar* id;
-
- id = g_strdup_printf ("%" G_GINT64_FORMAT,
- katze_item_get_meta_integer (item, "id"));
-
- sqlcmd = sqlite3_mprintf ("DELETE FROM bookmarks WHERE id = %q", id);
-
- if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK)
- {
- g_printerr (_("Failed to remove bookmark item: %s\n"), errmsg);
- sqlite3_free (errmsg);
- removed = FALSE;
- }
-
- sqlite3_free (sqlcmd);
- g_free (id);
- return removed;
-}
-
-/**
- * midori_bookmarks_db_add_item:
- * @bookmarks: the main bookmark array
- * @item: #KatzeItem the item to update
- *
- * Adds the @item in the bookmark data base.
- *
- * Since: 0.5.2
- **/
-void
-midori_bookmarks_db_add_item (MidoriBookmarksDb* bookmarks, KatzeItem* item)
-{
- g_return_if_fail (IS_MIDORI_BOOKMARKS_DB (bookmarks));
- g_return_if_fail (KATZE_IS_ITEM (item));
- g_return_if_fail (NULL == katze_item_get_meta_string (item, "id"));
-
- midori_bookmarks_db_add_item_recursive (bookmarks, item);
-
- katze_array_add_item (KATZE_ARRAY (bookmarks), item);
-}
-
-/**
- * midori_bookmarks_db_update_item:
- * @bookmarks: the main bookmark array
- * @item: #KatzeItem the item to update
- *
- * Updates the @item in the bookmark data base.
- *
- * Since: 0.5.2
- **/
-void
-midori_bookmarks_db_update_item (MidoriBookmarksDb* bookmarks, KatzeItem* item)
-{
- g_return_if_fail (IS_MIDORI_BOOKMARKS_DB (bookmarks));
- g_return_if_fail (KATZE_IS_ITEM (item));
- g_return_if_fail (katze_item_get_meta_string (item, "id"));
- g_return_if_fail (0 != katze_item_get_meta_integer (item, "id"));
-
- midori_bookmarks_db_update_item_db (bookmarks->db, item);
-
- midori_bookmarks_db_signal_update_item (bookmarks, item);
-}
-
-/**
- * midori_bookmarks_db_remove_item:
- * @bookmarks: the main bookmark array
- * @item: #KatzeItem the item to remove
- *
- * Removes the @item from the bookmark data base.
- *
- * Since: 0.5.2
- **/
-void
-midori_bookmarks_db_remove_item (MidoriBookmarksDb* bookmarks, KatzeItem* item)
-{
- g_return_if_fail (IS_MIDORI_BOOKMARKS_DB (bookmarks));
- g_return_if_fail (KATZE_IS_ITEM (item));
- g_return_if_fail (katze_item_get_meta_string (item, "id"));
- g_return_if_fail (0 != katze_item_get_meta_integer (item, "id"));
-
- midori_bookmarks_db_remove_item_recursive (item, bookmarks);
- midori_bookmarks_db_remove_item_db (bookmarks->db, item);
-
- katze_array_remove_item (KATZE_ARRAY (bookmarks), item);
-}
-
-/**
- * midori_bookmarks_db_new:
- *
- * Initializes the bookmark data base.
- *
- * Returns: the main bookmarks array
- *
- * Since: 0.5.2
- **/
-MidoriBookmarksDb*
-midori_bookmarks_db_new (char** errmsg)
-{
- MidoriBookmarksDatabase* database;
- GError* error = NULL;
- sqlite3* db;
- MidoriBookmarksDb* bookmarks;
-
- g_return_val_if_fail (errmsg != NULL, NULL);
-
- database = midori_bookmarks_database_new (&error);
-
- if (error != NULL)
- {
- *errmsg = g_strdup (error->message);
- g_error_free (error);
- return NULL;
- }
-
- db = midori_database_get_db (MIDORI_DATABASE (database));
- g_return_val_if_fail (db != NULL, NULL);
-
- bookmarks = MIDORI_BOOKMARKS_DB (g_object_new (TYPE_MIDORI_BOOKMARKS_DB,
- "type", KATZE_TYPE_ITEM,
- NULL));
-
- bookmarks->db = db;
-
- g_object_set_data (G_OBJECT (bookmarks), "db", db);
- return bookmarks;
-}
-
-/**
- * midori_bookmarks_db_on_quit:
- * @bookmarks: the main bookmark array
- *
- * Delete the main bookmark array.
- *
- * Since: 0.5.2
- **/
-void
-midori_bookmarks_db_on_quit (MidoriBookmarksDb* bookmarks)
-{
- g_return_if_fail (IS_MIDORI_BOOKMARKS_DB (bookmarks));
-
- g_object_unref (bookmarks);
-}
-
-/**
- * midori_bookmarks_db_import_array:
- * @bookmarks: the main bookmark array
- * @array: #KatzeArray containing the items to import
- * @parentid: the id of folder
- *
- * Imports the items of @array as children of the folder
- * identfied by @parentid.
- *
- * Since: 0.5.2
- **/
-void
-midori_bookmarks_db_import_array (MidoriBookmarksDb* bookmarks,
- KatzeArray* array,
- gint64 parentid)
-{
- GList* list;
- KatzeItem* item;
-
- g_return_if_fail (IS_MIDORI_BOOKMARKS_DB (bookmarks));
- g_return_if_fail (KATZE_IS_ARRAY (array));
-
- KATZE_ARRAY_FOREACH_ITEM_L (item, array, list)
- {
- /* IDs coming from previously exported database must be forgotten */
- katze_item_set_meta_integer (item, "id", -1);
- katze_item_set_meta_integer (item, "parentid", parentid);
- midori_bookmarks_db_add_item (bookmarks, item);
- }
- g_list_free (list);
-}
-
-/**
- * midori_bookmarks_db_array_from_statement:
- * @stmt: the sqlite returned statement
- * @bookmarks: the database controller
- *
- * Internal function that populate a #KatzeArray by processing the @stmt
- * rows identifying:
- * a- if the item is already in memory
- * in this case the item data is updated with retreived database content
- * and the already existing item is populated in the returned #KatzeArray
- * b- if the data is a folder
- * a new #KatzeArray item is populated in the returned #KatzeArray and
- * memorized for future use.
- * c- if the data is a bookmark
- * a new #KatzeItem item is populated in the returned #KatzeArray and
- * memorized for furure use.
- *
- * Return value: the populated #KatzeArray
- **/
-static KatzeArray*
-midori_bookmarks_db_array_from_statement (sqlite3_stmt* stmt,
- MidoriBookmarksDb* bookmarks)
-{
- KatzeArray *array;
- gint result;
- gint cols;
-
- array = katze_array_new (KATZE_TYPE_ITEM);
- cols = sqlite3_column_count (stmt);
-
- while ((result = sqlite3_step (stmt)) == SQLITE_ROW)
- {
- gint i;
- KatzeItem* item;
- gpointer found;
-
- item = katze_item_new ();
- for (i = 0; i < cols; i++)
- katze_item_set_value_from_column (stmt, i, item);
-
- if (NULL != (found = g_hash_table_lookup (bookmarks->all_items, item)))
- {
- for (i = 0; i < cols; i++)
- katze_item_set_value_from_column (stmt, i, found);
-
- g_object_unref (item);
-
- item = found;
- }
- else if (KATZE_ITEM_IS_FOLDER (item))
- {
- g_object_unref (item);
-
- item = KATZE_ITEM (katze_array_new (KATZE_TYPE_ITEM));
-
- for (i = 0; i < cols; i++)
- katze_item_set_value_from_column (stmt, i, item);
-
- g_object_ref (item);
- g_hash_table_insert (bookmarks->all_items, item, item);
- }
- else
- {
- g_object_ref (item);
- g_hash_table_insert (bookmarks->all_items, item, item);
- }
-
- katze_array_add_item (array, item);
- }
-
- sqlite3_clear_bindings (stmt);
- sqlite3_reset (stmt);
- return array;
-}
-
-/**
- * midori_bookmarks_db_array_from_sqlite:
- * @array: the main bookmark array
- * @sqlcmd: the sqlcmd to execute
- *
- * Internal function that process the requested @sqlcmd.
- *
- * Return value: a #KatzeArray on success, %NULL otherwise
- **/
-static KatzeArray*
-midori_bookmarks_db_array_from_sqlite (MidoriBookmarksDb* bookmarks,
- const gchar* sqlcmd)
-{
- sqlite3_stmt* stmt;
- gint result;
-
- g_return_val_if_fail (bookmarks->db != NULL, NULL);
-
- result = sqlite3_prepare_v2 (bookmarks->db, sqlcmd, -1, &stmt, NULL);
- if (result != SQLITE_OK)
- return NULL;
-
- return midori_bookmarks_db_array_from_statement (stmt, bookmarks);
-}
-
-/**
- * midori_bookmarks_db_query_recursive:
- * @bookmarks: the main bookmark array
- * @fields: comma separated list of fields
- * @condition: condition, like "folder = '%q'"
- * @value: a value to be inserted if @condition contains %q
- * @recursive: if %TRUE include children
- *
- * Stores the result in a #KatzeArray.
- *
- * Return value: a #KatzeArray on success, %NULL otherwise
- *
- * Since: 0.5.2
- **/
-KatzeArray*
-midori_bookmarks_db_query_recursive (MidoriBookmarksDb* bookmarks,
- const gchar* fields,
- const gchar* condition,
- const gchar* value,
- gboolean recursive)
-{
- gchar* sqlcmd;
- char* sqlcmd_value;
- KatzeArray* array;
- KatzeItem* item;
- GList* list;
-
- g_return_val_if_fail (IS_MIDORI_BOOKMARKS_DB (bookmarks), NULL);
- g_return_val_if_fail (fields, NULL);
- g_return_val_if_fail (condition, NULL);
-
- sqlcmd = g_strdup_printf ("SELECT %s FROM bookmarks WHERE %s "
- "ORDER BY (uri='') ASC, title DESC", fields, condition);
- if (strstr (condition, "%q"))
- {
- sqlcmd_value = sqlite3_mprintf (sqlcmd, value ? value : "");
- array = midori_bookmarks_db_array_from_sqlite (bookmarks, sqlcmd_value);
- sqlite3_free (sqlcmd_value);
- }
- else
- array = midori_bookmarks_db_array_from_sqlite (bookmarks, sqlcmd);
- g_free (sqlcmd);
-
- if (!recursive)
- return array;
-
- KATZE_ARRAY_FOREACH_ITEM_L (item, array, list)
- {
- if (KATZE_ITEM_IS_FOLDER (item))
- {
- gchar* parentid = g_strdup_printf ("%" G_GINT64_FORMAT,
- katze_item_get_meta_integer (item, "id"));
- KatzeArray* subarray = midori_bookmarks_db_query_recursive (bookmarks,
- fields, "parentid=%q", parentid, TRUE);
- KatzeItem* subitem;
- GList* sublist;
-
- katze_array_clear (KATZE_ARRAY (item));
-
- KATZE_ARRAY_FOREACH_ITEM_L (subitem, subarray, sublist)
- {
- katze_array_add_item (KATZE_ARRAY (item), subitem);
- }
-
- g_object_unref (subarray);
- g_free (parentid);
- }
- }
- g_list_free (list);
- return array;
-}
-
-static gint64
-midori_bookmarks_db_count_from_sqlite (sqlite3* db,
- const gchar* sqlcmd)
-{
- gint64 count = -1;
- sqlite3_stmt* stmt;
- gint result;
-
- result = sqlite3_prepare_v2 (db, sqlcmd, -1, &stmt, NULL);
- if (result != SQLITE_OK)
- return -1;
-
- g_assert (sqlite3_column_count (stmt) == 1);
-
- if ((result = sqlite3_step (stmt)) == SQLITE_ROW)
- count = sqlite3_column_int64(stmt, 0);
-
- sqlite3_clear_bindings (stmt);
- sqlite3_reset (stmt);
-
- return count;
-}
-
-static gint64
-midori_bookmarks_db_count_recursive_by_id (MidoriBookmarksDb* bookmarks,
- const gchar* condition,
- const gchar* value,
- gint64 id,
- gboolean recursive)
-{
- gint64 count = -1;
- gchar* sqlcmd;
- char* sqlcmd_value;
- sqlite3_stmt* stmt;
- gint result;
- GList* ids;
- GList* iter_ids;
-
- g_return_val_if_fail (condition, -1);
- g_return_val_if_fail (MIDORI_BOOKMARKS_DB (bookmarks), -1);
- g_return_val_if_fail (bookmarks->db != NULL, -1);
-
- g_assert(!strstr("parentid", condition));
-
- if (id > 0)
- sqlcmd = g_strdup_printf ("SELECT COUNT(*) FROM bookmarks "
- "WHERE parentid = %" G_GINT64_FORMAT " AND %s",
- id,
- condition);
- else
- sqlcmd = g_strdup_printf ("SELECT COUNT(*) FROM bookmarks "
- "WHERE parentid IS NULL AND %s ",
- condition);
-
- if (strstr (condition, "%q"))
- {
- sqlcmd_value = sqlite3_mprintf (sqlcmd, value ? value : "");
- count = midori_bookmarks_db_count_from_sqlite (bookmarks->db, sqlcmd_value);
- sqlite3_free (sqlcmd_value);
- }
- else
- count = midori_bookmarks_db_count_from_sqlite (bookmarks->db, sqlcmd);
-
- g_free (sqlcmd);
-
- if (!recursive || (count < 0))
- return count;
-
- ids = NULL;
-
- if (id > 0)
- sqlcmd_value = sqlite3_mprintf (
- "SELECT id FROM bookmarks "
- "WHERE parentid = %" G_GINT64_FORMAT " AND uri = ''", id);
- else
- sqlcmd_value = sqlite3_mprintf (
- "SELECT id FROM bookmarks "
- "WHERE parentid IS NULL AND uri = ''");
-
- if (sqlite3_prepare_v2 (bookmarks->db, sqlcmd_value, -1, &stmt, NULL) == SQLITE_OK)
- {
- g_assert (sqlite3_column_count (stmt) == 1);
-
- if ((result = sqlite3_step (stmt)) == SQLITE_ROW)
- {
- gint64* pid = g_new (gint64, 1);
-
- *pid = sqlite3_column_int64(stmt, 0);
- ids = g_list_append (ids, pid);
- }
-
- sqlite3_clear_bindings (stmt);
- sqlite3_reset (stmt);
- }
-
- sqlite3_free (sqlcmd_value);
-
- iter_ids = ids;
- while (iter_ids)
- {
- gint64 sub_count = midori_bookmarks_db_count_recursive_by_id (bookmarks,
- condition,
- value,
- *(gint64*)(iter_ids->data),
- recursive);
-
- if (sub_count < 0)
- {
- g_list_free_full (ids, g_free);
- return -1;
- }
-
- count += sub_count;
- iter_ids = g_list_next (iter_ids);
- }
-
- g_list_free_full (ids, g_free);
- return count;
-}
-
-/**
- * midori_bookmarks_db_count_recursive:
- * @bookmarks: the main bookmark array
- * @condition: condition, like "folder = '%q'"
- * @value: a value to be inserted if @condition contains %q
- * @recursive: if %TRUE include children
- *
- * Return value: the number of elements on success, -1 otherwise
- *
- * Since: 0.5.2
- **/
-gint64
-midori_bookmarks_db_count_recursive (MidoriBookmarksDb* bookmarks,
- const gchar* condition,
- const gchar* value,
- KatzeItem* folder,
- gboolean recursive)
-{
- gint64 id = -1;
-
- g_return_val_if_fail (!folder || KATZE_ITEM_IS_FOLDER (folder), -1);
-
- id = folder ? katze_item_get_meta_integer (folder, "id") : 0;
-
- return midori_bookmarks_db_count_recursive_by_id (bookmarks, condition,
- value, id,
- recursive);
-}
-
-/**
- * midori_bookmarks_db_populate_folder:
- **/
-
-void
-midori_bookmarks_db_populate_folder (MidoriBookmarksDb* bookmarks,
- KatzeArray *folder)
-{
- const gchar* id = katze_item_get_meta_string (KATZE_ITEM (folder), "id");
- const gchar *condition;
- KatzeArray* array;
- KatzeItem* item;
- GList* list;
-
- if (id == NULL)
- {
- condition = "parentid is NULL";
- }
- else
- {
- condition = "parentid = %q";
- }
-
- array = midori_bookmarks_db_query_recursive (bookmarks,
- "id, title, parentid, uri, app, pos_panel, pos_bar", condition, id, FALSE);
-
- if (IS_MIDORI_BOOKMARKS_DB (folder))
- {
- KATZE_ARRAY_FOREACH_ITEM_L (item, folder, list)
- {
- KATZE_ARRAY_CLASS (midori_bookmarks_db_parent_class)->remove_item (folder, item);
- }
-
- KATZE_ARRAY_FOREACH_ITEM_L (item, array, list)
- {
- KATZE_ARRAY_CLASS (midori_bookmarks_db_parent_class)->add_item (folder, item);
- }
- }
- else
- {
- katze_array_clear(folder);
-
- KATZE_ARRAY_FOREACH_ITEM_L (item, array, list)
- {
- katze_array_add_item (folder, item);
- }
- }
-
- g_object_unref (array);
-}
diff --git a/midori/midori-bookmarks-db.h b/midori/midori-bookmarks-db.h
deleted file mode 100644
index 4a038658..00000000
--- a/midori/midori-bookmarks-db.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- Copyright (C) 2010 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2010 Alexander Butenko <a.butenka@gmail.com>
-
- 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 __MIDORI_BOOKMARKS_DB_H__
-#define __MIDORI_BOOKMARKS_DB_H__ 1
-
-#include <sqlite3.h>
-#include <katze/katze.h>
-
-G_BEGIN_DECLS
-
-#define TYPE_MIDORI_BOOKMARKS_DB \
- (midori_bookmarks_db_get_type ())
-#define MIDORI_BOOKMARKS_DB(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MIDORI_BOOKMARKS_DB, MidoriBookmarksDb))
-#define MIDORI_BOOKMARKS_DB_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MIDORI_BOOKMARKS_DB, MidoriBookmarksDbClass))
-#define IS_MIDORI_BOOKMARKS_DB(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MIDORI_BOOKMARKS_DB))
-#define IS_MIDORI_BOOKMARKS_DB_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MIDORI_BOOKMARKS_DB))
-#define MIDORI_BOOKMARKS_DB_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MIDORI_BOOKMARKS_DB, MidoriBookmarksDbClass))
-
-typedef struct _MidoriBookmarksDb MidoriBookmarksDb;
-typedef struct _MidoriBookmarksDbClass MidoriBookmarksDbClass;
-
-GType
-midori_bookmarks_db_get_type (void) G_GNUC_CONST;
-
-MidoriBookmarksDb*
-midori_bookmarks_db_new (char** errmsg);
-
-void
-midori_bookmarks_db_on_quit (MidoriBookmarksDb* bookmarks);
-
-void
-midori_bookmarks_db_add_item (MidoriBookmarksDb* bookmarks, KatzeItem* item);
-
-void
-midori_bookmarks_db_update_item (MidoriBookmarksDb* bookmarks, KatzeItem* item);
-
-void
-midori_bookmarks_db_remove_item (MidoriBookmarksDb* bookmarks, KatzeItem* item);
-
-void
-midori_bookmarks_db_import_array (MidoriBookmarksDb* bookmarks,
- KatzeArray* array,
- gint64 parentid);
-
-KatzeArray*
-midori_bookmarks_db_query_recursive (MidoriBookmarksDb* bookmarks,
- const gchar* fields,
- const gchar* condition,
- const gchar* value,
- gboolean recursive);
-
-gint64
-midori_bookmarks_db_count_recursive (MidoriBookmarksDb* bookmarks,
- const gchar* condition,
- const gchar* value,
- KatzeItem* folder,
- gboolean recursive);
-
-void
-midori_bookmarks_db_populate_folder (MidoriBookmarksDb* bookmarks,
- KatzeArray *folder);
-
-#endif /* !__MIDORI_BOOKMARKS_DB_H__ */
-
diff --git a/midori/midori-bookmarksdatabase.vala b/midori/midori-bookmarksdatabase.vala
deleted file mode 100644
index 95dec9b7..00000000
--- a/midori/midori-bookmarksdatabase.vala
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- Copyright (C) 2013 Andre Auzi <aauzi@free.fr>
- Copyright (C) 2013 Christian Dywan <christian@twotoats.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.
-*/
-
-namespace Midori {
- public class BookmarksDatabase : Midori.Database {
- public BookmarksDatabase () throws DatabaseError {
- Object (path: "bookmarks.db");
- preinit ();
- init ();
- exec ("PRAGMA foreign_keys = ON;");
- }
-
- protected void preinit () throws DatabaseError {
- string dbfile = Paths.get_config_filename_for_writing (path);
- string olddbfile = dbfile + ".old";
- string dbfile_v2 = Paths.get_config_filename_for_reading ("bookmarks_v2.db");
-
- if (GLib.FileUtils.test (dbfile_v2, GLib.FileTest.EXISTS)) {
- if (GLib.FileUtils.test (dbfile, GLib.FileTest.EXISTS)) {
- if (GLib.FileUtils.test (olddbfile, GLib.FileTest.EXISTS))
- Posix.unlink (olddbfile);
- GLib.FileUtils.rename (dbfile, olddbfile);
- }
-
- GLib.FileUtils.rename (dbfile_v2, dbfile);
-
- if (Sqlite.Database.open_v2 (dbfile, out _db) != Sqlite.OK)
- throw new DatabaseError.OPEN ("Failed to open database %s".printf (path));
-
- Sqlite.Statement stmt;
- if (db.prepare_v2 ("PRAGMA user_version;", -1, out stmt, null) != Sqlite.OK)
- throw new DatabaseError.EXECUTE ("Failed to compile statement %s".printf (db.errmsg ()));
- if (stmt.step () != Sqlite.ROW)
- throw new DatabaseError.EXECUTE ("Failed to get row %s".printf (db.errmsg ()));
- int64 user_version = stmt.column_int64 (0);
-
- if (user_version == 0) {
- exec ("PRAGMA user_version = 1;");
- }
-
- _db = null;
- } else if (GLib.FileUtils.test (dbfile, GLib.FileTest.EXISTS)) {
-
- if (Sqlite.Database.open_v2 (dbfile, out _db) != Sqlite.OK)
- throw new DatabaseError.OPEN ("Failed to open database %s".printf (path));
-
- Sqlite.Statement stmt;
- if (db.prepare_v2 ("PRAGMA user_version;", -1, out stmt, null) != Sqlite.OK)
- throw new DatabaseError.EXECUTE ("Failed to compile statement %s".printf (db.errmsg ()));
- if (stmt.step () != Sqlite.ROW)
- throw new DatabaseError.EXECUTE ("Failed to get row %s".printf (db.errmsg ()));
- int64 user_version = stmt.column_int64 (0);
-
- _db = null;
-
- if (user_version == 0) {
- if (GLib.FileUtils.test (olddbfile, GLib.FileTest.EXISTS))
- Posix.unlink (olddbfile);
-
- GLib.FileUtils.rename (dbfile, olddbfile);
-
- if (Sqlite.Database.open_v2 (dbfile, out _db) != Sqlite.OK)
- throw new DatabaseError.OPEN ("Failed to open database %s".printf (path));
-
- exec_script ("Create");
-
- attach (olddbfile, "old_db");
-
- bool failure = false;
- try {
- exec_script ("Import_old_db_bookmarks");
- } catch (DatabaseError error) {
- if (error is DatabaseError.EXECUTE)
- failure = true;
- else
- throw error;
- }
-
- /* try to get back to previous state */
- if (failure)
- exec ("ROLLBACK TRANSACTION;");
-
- exec ("DETACH DATABASE old_db;");
- exec ("PRAGMA user_version = 1;");
-
- _db = null;
- }
- }
- }
- }
-}
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
deleted file mode 100644
index 0e6cdaa1..00000000
--- a/midori/midori-browser.c
+++ /dev/null
@@ -1,7527 +0,0 @@
-/*
- Copyright (C) 2007-2013 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2008 Dale Whittaker <dayul@users.sf.net>
- Copyright (C) 2009 Jérôme Geulfucci <jeromeg@xfce.org>
-
- 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.
-*/
-
-#include "midori-browser.h"
-
-#include "midori-app.h"
-#include "midori-extension.h"
-#include "midori-array.h"
-#include "midori-view.h"
-#include "midori-preferences.h"
-#include "midori-panel.h"
-#include "midori-locationaction.h"
-#include "midori-searchaction.h"
-#include "midori-findbar.h"
-#include "midori-platform.h"
-#include "midori-privatedata.h"
-#include "midori-core.h"
-#include "midori-privatedata.h"
-#include "midori-bookmarks-db.h"
-#include "katze-cellrenderercomboboxtext.h"
-
-#include "marshal.h"
-
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
-#include <gdk/gdkkeysyms.h>
-#include <string.h>
-
-#include <config.h>
-
-#ifdef HAVE_GRANITE
- #include <granite.h>
-#endif
-
-#ifdef HAVE_ZEITGEIST
- #include <zeitgeist.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
- #include <unistd.h>
-#endif
-
-#include <sqlite3.h>
-
-#ifdef HAVE_X11_EXTENSIONS_SCRNSAVER_H
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
- #include <X11/extensions/scrnsaver.h>
- #include <gdk/gdkx.h>
-#endif
-
-struct _MidoriBrowser
-{
- MidoriWindow parent_instance;
- GtkActionGroup* action_group;
- GtkWidget* menubar;
- GtkWidget* throbber;
- GtkWidget* navigationbar;
- GtkWidget* bookmarkbar;
-
- GtkWidget* panel;
- GtkWidget* notebook;
-
- GtkWidget* inspector;
- GtkWidget* inspector_view;
-
- GtkWidget* find;
-
- GtkWidget* statusbar;
- GtkWidget* statusbar_contents;
- gchar* statusbar_text;
-
- gint last_window_width, last_window_height;
- guint alloc_timeout;
- guint panel_timeout;
-
- MidoriWebSettings* settings;
- KatzeArray* proxy_array;
- MidoriBookmarksDb* bookmarks;
- KatzeArray* trash;
- KatzeArray* search_engines;
- KatzeArray* history;
- MidoriHistoryDatabase* history_database;
- MidoriSpeedDial* dial;
- gboolean show_tabs;
-
- gboolean show_navigationbar;
- gboolean show_statusbar;
- guint maximum_history_age;
- guint last_web_search;
-
- gboolean bookmarkbar_populate;
-};
-
-G_DEFINE_TYPE (MidoriBrowser, midori_browser, MIDORI_TYPE_WINDOW)
-
-enum
-{
- PROP_0,
-
- PROP_MENUBAR,
- PROP_NAVIGATIONBAR,
- PROP_NOTEBOOK,
- PROP_PANEL,
- PROP_URI,
- PROP_TAB,
- PROP_LOAD_STATUS,
- PROP_STATUSBAR,
- PROP_STATUSBAR_TEXT,
- PROP_SETTINGS,
- PROP_PROXY_ITEMS,
- PROP_BOOKMARKS,
- PROP_TRASH,
- PROP_SEARCH_ENGINES,
- PROP_HISTORY,
- PROP_SPEED_DIAL,
- PROP_SHOW_TABS,
-};
-
-enum
-{
- NEW_WINDOW,
- ADD_TAB,
- REMOVE_TAB,
- MOVE_TAB,
- SWITCH_TAB,
- ACTIVATE_ACTION,
- ADD_DOWNLOAD,
- SEND_NOTIFICATION,
- POPULATE_TOOL_MENU,
- POPULATE_TOOLBAR_MENU,
- QUIT,
- SHOW_PREFERENCES,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-midori_browser_dispose (GObject* object);
-
-static void
-midori_browser_finalize (GObject* object);
-
-#ifdef HAVE_WEBKIT2
-void download_created_destination_cb (WebKitDownload *download,
- gchar *destination,
- gpointer user_data);
-#endif
-
-static void
-midori_browser_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_browser_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-gboolean
-midori_browser_open_bookmark (MidoriBrowser* browser,
- KatzeItem* item);
-
-static void
-midori_bookmarkbar_populate (MidoriBrowser* browser);
-static void
-midori_bookmarkbar_populate_idle (MidoriBrowser* browser);
-
-static void
-midori_bookmarkbar_clear (GtkWidget* toolbar);
-
-static void
-_midori_browser_set_toolbar_style (MidoriBrowser* browser,
- MidoriToolbarStyle toolbar_style);
-
-static void
-midori_browser_settings_notify (MidoriWebSettings* web_settings,
- GParamSpec* pspec,
- MidoriBrowser* browser);
-
-static void
-midori_browser_toolbar_popup_context_menu_history (MidoriBrowser* browser,
- GtkWidget* widget,
- gboolean back,
- gint x,
- gint y);
-void
-midori_panel_set_toolbar_style (MidoriPanel* panel,
- GtkToolbarStyle style);
-
-static void
-midori_browser_set_bookmarks (MidoriBrowser* browser,
- MidoriBookmarksDb* bookmarks);
-
-static void
-midori_browser_add_speed_dial (MidoriBrowser* browser);
-
-static void
-midori_browser_step_history (MidoriBrowser* browser,
- MidoriView* view);
-
-#define _action_by_name(brwsr, nme) \
- gtk_action_group_get_action (brwsr->action_group, nme)
-#define _action_set_sensitive(brwsr, nme, snstv) \
- gtk_action_set_sensitive (_action_by_name (brwsr, nme), snstv);
-#define _action_set_visible(brwsr, nme, vsbl) \
- gtk_action_set_visible (_action_by_name (brwsr, nme), vsbl);
-#define _action_set_active(brwsr, nme, actv) \
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION ( \
- _action_by_name (brwsr, nme)), actv);
-
-static void
-midori_browser_disconnect_tab (MidoriBrowser* browser,
- MidoriView* view);
-
-static gboolean
-midori_browser_is_fullscreen (MidoriBrowser* browser)
-{
- GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (browser));
- GdkWindowState state = window ? gdk_window_get_state (window) : 0;
- return state & GDK_WINDOW_STATE_FULLSCREEN;
-}
-
-static gboolean
-_toggle_tabbar_smartly (MidoriBrowser* browser,
- gboolean ignore_fullscreen)
-{
- gboolean has_tabs = midori_browser_get_n_pages (browser) > 1;
- gboolean show_tabs = !midori_browser_is_fullscreen (browser) || ignore_fullscreen;
- if (!browser->show_tabs)
- show_tabs = FALSE;
- midori_notebook_set_labels_visible (MIDORI_NOTEBOOK (browser->notebook), show_tabs);
- return has_tabs;
-}
-
-static void
-midori_browser_trash_clear_cb (KatzeArray* trash,
- MidoriBrowser* browser)
-{
- gboolean trash_empty = katze_array_is_empty (browser->trash);
- _action_set_sensitive (browser, "UndoTabClose", !trash_empty);
- _action_set_sensitive (browser, "Trash", !trash_empty);
-}
-
-static void
-_midori_browser_update_actions (MidoriBrowser* browser)
-{
- gboolean has_tabs = _toggle_tabbar_smartly (browser, FALSE);
- _action_set_sensitive (browser, "TabPrevious", has_tabs);
- _action_set_sensitive (browser, "TabNext", has_tabs);
-
- if (browser->trash)
- midori_browser_trash_clear_cb (browser->trash, browser);
-}
-
-static void
-midori_browser_update_secondary_icon (MidoriBrowser* browser,
- MidoriView* view,
- GtkAction* action)
-{
- if (g_object_get_data (G_OBJECT (view), "news-feeds"))
- {
- midori_location_action_set_secondary_icon (
- MIDORI_LOCATION_ACTION (action), STOCK_NEWS_FEED);
- _action_set_sensitive (browser, "AddNewsFeed", TRUE);
- }
- else
- {
- midori_location_action_set_secondary_icon (
- MIDORI_LOCATION_ACTION (action), NULL);
- _action_set_sensitive (browser, "AddNewsFeed", FALSE);
- }
-}
-
-static void
-_midori_browser_update_interface (MidoriBrowser* browser,
- MidoriView* view)
-{
- GtkAction* action;
-
- _action_set_sensitive (browser, "Back", midori_view_can_go_back (view));
- _action_set_sensitive (browser, "Forward", midori_tab_can_go_forward (MIDORI_TAB (view)));
- _action_set_sensitive (browser, "Previous",
- midori_view_get_previous_page (view) != NULL);
- _action_set_sensitive (browser, "Next",
- midori_view_get_next_page (view) != NULL);
-
- _action_set_sensitive (browser, "AddSpeedDial", !midori_view_is_blank (view));
- _action_set_sensitive (browser, "BookmarkAdd", !midori_view_is_blank (view));
- _action_set_sensitive (browser, "MailTo", !midori_view_is_blank (view));
- _action_set_sensitive (browser, "SaveAs", midori_tab_can_save (MIDORI_TAB (view)));
- _action_set_sensitive (browser, "ZoomIn", midori_view_can_zoom_in (view));
- _action_set_sensitive (browser, "ZoomOut", midori_view_can_zoom_out (view));
- _action_set_sensitive (browser, "ZoomNormal",
- midori_view_get_zoom_level (view) != 1.0f);
- _action_set_sensitive (browser, "Encoding",
- midori_tab_can_view_source (MIDORI_TAB (view)));
- _action_set_sensitive (browser, "SourceView",
- midori_tab_can_view_source (MIDORI_TAB (view)));
- _action_set_sensitive (browser, "SourceViewDom",
- midori_tab_can_view_source (MIDORI_TAB (view)));
-
- action = _action_by_name (browser, "NextForward");
- if (midori_tab_can_go_forward (MIDORI_TAB (view)))
- {
- g_object_set (action,
- "stock-id", GTK_STOCK_GO_FORWARD,
- "tooltip", _("Go forward to the next page"),
- "sensitive", TRUE, NULL);
- }
- else
- {
- g_object_set (action,
- "stock-id", GTK_STOCK_MEDIA_NEXT,
- "tooltip", _("Go to the next sub-page"),
- "sensitive", midori_view_get_next_page (view) != NULL, NULL);
- }
-
- action = _action_by_name (browser, "Location");
- if (midori_tab_is_blank (MIDORI_TAB (view)))
- {
- gchar* icon_names[] = { "edit-find-symbolic", "edit-find", NULL };
- GIcon* icon = g_themed_icon_new_from_names (icon_names, -1);
- midori_location_action_set_primary_icon (
- MIDORI_LOCATION_ACTION (action), icon, _("Web Search…"));
- g_object_unref (icon);
- }
- else
- midori_location_action_set_security_hint (
- MIDORI_LOCATION_ACTION (action), midori_tab_get_security (MIDORI_TAB (view)));
- midori_browser_update_secondary_icon (browser, view, action);
-}
-
-static void
-_midori_browser_set_statusbar_text (MidoriBrowser* browser,
- MidoriView* view,
- const gchar* text)
-{
- #if GTK_CHECK_VERSION (3, 2, 0)
- gboolean is_location = FALSE;
- #else
- GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
- gboolean is_location = widget && GTK_IS_ENTRY (widget)
- && GTK_IS_ALIGNMENT (gtk_widget_get_parent (widget));
- #endif
-
- katze_assign (browser->statusbar_text, midori_uri_format_for_display (text));
- if (view == NULL)
- return;
-
- if (!gtk_widget_get_visible (browser->statusbar) && !is_location
- && text && *text)
- {
- #if GTK_CHECK_VERSION (3, 2, 0)
- midori_view_set_overlay_text (view, browser->statusbar_text);
- #else
- GtkAction* action = _action_by_name (browser, "Location");
- MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);
- midori_location_action_set_text (location_action, browser->statusbar_text);
- midori_location_action_set_secondary_icon (location_action, NULL);
- #endif
- }
- else if (!gtk_widget_get_visible (browser->statusbar) && !is_location)
- {
- #if GTK_CHECK_VERSION (3, 2, 0)
- midori_view_set_overlay_text (view, NULL);
- #else
- GtkAction* action = _action_by_name (browser, "Location");
- MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);
- midori_browser_update_secondary_icon (browser, view, action);
- midori_location_action_set_text (location_action,
- midori_view_get_display_uri (view));
- #endif
- }
- else
- {
- gtk_statusbar_pop (GTK_STATUSBAR (browser->statusbar), 1);
- gtk_statusbar_push (GTK_STATUSBAR (browser->statusbar), 1,
- katze_str_non_null (browser->statusbar_text));
- }
-}
-
-void
-midori_browser_set_current_page_smartly (MidoriBrowser* browser,
- gint n)
-{
- if (!katze_object_get_boolean (browser->settings,
- "open-tabs-in-the-background"))
- midori_browser_set_current_page (browser, n);
-}
-
-/**
- * midori_browser_set_current_tab_smartly:
- * @browser: a #MidoriBrowser
- * @view: a #GtkWidget
- *
- * Switches to the tab containing @view iff open-tabs-in-the-background is %FALSE.
- *
- * Since: 0.4.9
- **/
-void
-midori_browser_set_current_tab_smartly (MidoriBrowser* browser,
- GtkWidget* view)
-{
- if (!katze_object_get_boolean (browser->settings,
- "open-tabs-in-the-background"))
- midori_browser_set_current_tab (browser, view);
-}
-
-static void
-_midori_browser_update_progress (MidoriBrowser* browser,
- MidoriView* view)
-{
- GtkAction* action;
- gdouble progress = midori_view_get_progress (view);
- gboolean loading = progress > 0.0;
-
- action = _action_by_name (browser, "Location");
- midori_location_action_set_progress (MIDORI_LOCATION_ACTION (action), progress);
-
- _action_set_sensitive (browser, "Reload", !loading);
- _action_set_sensitive (browser, "Stop", loading);
-
- action = _action_by_name (browser, "ReloadStop");
- if (!loading)
- {
- g_object_set (action,
- "stock-id", GTK_STOCK_REFRESH,
- "tooltip", _("Reload the current page"), NULL);
- }
- else
- {
- g_object_set (action,
- "stock-id", GTK_STOCK_STOP,
- "tooltip", _("Stop loading the current page"), NULL);
- }
-
- g_object_set (browser->throbber, "active", loading, "visible", loading, NULL);
-}
-
-/**
- * midori_browser_update_history:
- * @item: a #KatzeItem
- * @type: "website", "bookmark" or "download"
- * @event: "access", "leave", "modify", "delete"
- *
- * Since: 0.4.7
- **/
-void
-midori_browser_update_history (KatzeItem* item,
- const gchar* type,
- const gchar* event)
-{
- g_return_if_fail (!KATZE_ITEM_IS_SEPARATOR (item));
-
- #ifdef HAVE_ZEITGEIST
- const gchar* inter;
- ZeitgeistEvent* zgevent;
- ZeitgeistSubject* zgsubject;
-
- if (strstr (event, "access"))
- inter = ZEITGEIST_ZG_ACCESS_EVENT;
- else if (strstr (event, "leave"))
- inter = ZEITGEIST_ZG_LEAVE_EVENT;
- else if (strstr (event, "modify"))
- inter = ZEITGEIST_ZG_MODIFY_EVENT;
- else if (strstr (event, "create"))
- inter = ZEITGEIST_ZG_CREATE_EVENT;
- else if (strstr (event, "delete"))
- inter = ZEITGEIST_ZG_DELETE_EVENT;
- else
- g_assert_not_reached ();
-
- /* FIXME: Should insert folders into the log (ZEITGEIST_NFO_BOOKMARK_FOLDER) */
- if (KATZE_ITEM_IS_FOLDER (item))
- return;
-
- zgsubject = zeitgeist_subject_new_full (
- katze_item_get_uri (item),
- strstr (type, "bookmark") ? ZEITGEIST_NFO_BOOKMARK : ZEITGEIST_NFO_WEBSITE,
- zeitgeist_manifestation_for_uri (katze_item_get_uri (item)),
- katze_item_get_meta_string (item, "mime-type"),
- NULL,
- katze_item_get_name (item),
- NULL),
-
- zgevent = zeitgeist_event_new_full (
- inter,
- ZEITGEIST_ZG_USER_ACTIVITY,
- "application://midori.desktop",
- NULL,
- zgsubject,
- NULL),
-
- zeitgeist_log_insert_event_no_reply (zeitgeist_log_get_default (), zgevent, NULL);
-
- g_object_unref (zgevent);
- g_object_unref (zgsubject);
- #endif
-}
-
-static void
-midori_browser_update_history_title (MidoriBrowser* browser,
- KatzeItem* item)
-{
- sqlite3* db;
- static sqlite3_stmt* stmt = NULL;
-
- g_return_if_fail (katze_item_get_uri (item) != NULL);
-
- db = g_object_get_data (G_OBJECT (browser->history), "db");
- g_return_if_fail (db != NULL);
- if (!stmt)
- {
- const gchar* sqlcmd;
-
- sqlcmd = "UPDATE history SET title=? WHERE uri = ? and date=?";
- sqlite3_prepare_v2 (db, sqlcmd, -1, &stmt, NULL);
- }
- sqlite3_bind_text (stmt, 1, katze_item_get_name (item), -1, 0);
- sqlite3_bind_text (stmt, 2, katze_item_get_uri (item), -1, 0);
- sqlite3_bind_int64 (stmt, 3, katze_item_get_added (item));
-
- if (sqlite3_step (stmt) != SQLITE_DONE)
- g_printerr (_("Failed to update title: %s\n"), sqlite3_errmsg (db));
- sqlite3_reset (stmt);
- sqlite3_clear_bindings (stmt);
-
- midori_browser_update_history (item, "website", "access");
-}
-
-/**
- * midori_browser_assert_action:
- * @browser: a #MidoriBrowser
- * @name: action, setting=value expression or extension=true|false
- *
- * Assert that @name is a valid action or setting expression,
- * if it fails the program will terminate with an error.
- * To be used with command line interfaces.
- *
- * Since: 0.5.0
- **/
-void
-midori_browser_assert_action (MidoriBrowser* browser,
- const gchar* name)
-{
- g_return_if_fail (MIDORI_IS_BROWSER (browser));
- g_return_if_fail (name != NULL);
-
- if (strchr (name, '='))
- {
- gchar** parts = g_strsplit (name, "=", 0);
- GObjectClass* class = G_OBJECT_GET_CLASS (browser->settings);
- GParamSpec* pspec = g_object_class_find_property (class, parts[0]);
- if (pspec != NULL)
- {
- GType type = G_PARAM_SPEC_TYPE (pspec);
- if (!(
- (type == G_TYPE_PARAM_BOOLEAN && (!strcmp (parts[1], "true") || !strcmp (parts[1], "false")))
- || type == G_TYPE_PARAM_STRING
- || type == G_TYPE_PARAM_INT
- || type == G_TYPE_PARAM_FLOAT
- || type == G_TYPE_PARAM_DOUBLE
- || type == G_TYPE_PARAM_ENUM))
- midori_error (_("Value '%s' is invalid for %s"), parts[1], parts[0]);
- }
- else
- {
- gchar* extension_path = midori_paths_get_lib_path (PACKAGE_NAME);
- GObject* extension = midori_extension_load_from_file (extension_path, parts[0], FALSE, FALSE);
- g_free (extension_path);
- if (!extension || (strcmp (parts[1], "true") && strcmp (parts[1], "false")))
- midori_error (_("Unexpected setting '%s'"), name);
- }
- g_strfreev (parts);
- }
- else
- {
- GtkAction* action = _action_by_name (browser, name);
- if (!action)
- midori_error (_("Unexpected action '%s'."), name);
- }
-}
-
-void
-midori_app_set_browsers (MidoriApp* app,
- KatzeArray* browsers,
- MidoriBrowser* browser);
-
-static void
-_midori_browser_activate_action (MidoriBrowser* browser,
- const gchar* name)
-{
- g_return_if_fail (name != NULL);
-
- if (strchr (name, '='))
- {
- gchar** parts = g_strsplit (name, "=", 0);
- GObjectClass* class = G_OBJECT_GET_CLASS (browser->settings);
- GParamSpec* pspec = g_object_class_find_property (class, parts[0]);
- if (pspec != NULL)
- {
- GType type = G_PARAM_SPEC_TYPE (pspec);
- if (type == G_TYPE_PARAM_BOOLEAN && !strcmp ("true", parts[1]))
- g_object_set (browser->settings, parts[0], TRUE, NULL);
- else if (type == G_TYPE_PARAM_BOOLEAN && !strcmp ("false", parts[1]))
- g_object_set (browser->settings, parts[0], FALSE, NULL);
- else if (type == G_TYPE_PARAM_STRING)
- g_object_set (browser->settings, parts[0], parts[1], NULL);
- else if (type == G_TYPE_PARAM_INT || type == G_TYPE_PARAM_UINT)
- g_object_set (browser->settings, parts[0], atoi (parts[1]), NULL);
- else if (type == G_TYPE_PARAM_FLOAT || type == G_TYPE_PARAM_DOUBLE)
- g_object_set (browser->settings, parts[0], g_ascii_strtod (parts[1], NULL), NULL);
- else if (type == G_TYPE_PARAM_ENUM)
- {
- GEnumClass* enum_class = G_ENUM_CLASS (g_type_class_peek (pspec->value_type));
- GEnumValue* enum_value = g_enum_get_value_by_name (enum_class, parts[1]);
- if (enum_value != NULL)
- g_object_set (browser->settings, parts[0], enum_value->value, NULL);
- else
- g_warning (_("Value '%s' is invalid for %s"), parts[1], parts[0]);
- }
- else
- g_warning (_("Value '%s' is invalid for %s"), parts[1], parts[0]);
- }
- else
- {
- gchar* extension_path = midori_paths_get_lib_path (PACKAGE_NAME);
- GObject* extension = midori_extension_load_from_file (extension_path, parts[0], TRUE, FALSE);
- MidoriApp* app = midori_app_new_proxy (NULL);
- g_object_set (app,
- "settings", browser->settings,
- NULL);
- /* FIXME: tabs of multiple windows */
- KatzeArray* browsers = katze_array_new (MIDORI_TYPE_BROWSER);
- katze_array_add_item (browsers, browser);
- midori_app_set_browsers (app, browsers, browser);
- g_free (extension_path);
- if (extension && !strcmp (parts[1], "true"))
- midori_extension_activate (extension, parts[0], TRUE, app);
- else if (extension && !strcmp (parts[1], "false"))
- midori_extension_deactivate (MIDORI_EXTENSION (extension));
- else
- g_warning (_("Unexpected setting '%s'"), name);
- }
- g_strfreev (parts);
- }
- else
- {
- GtkAction* action = _action_by_name (browser, name);
- if (action)
- gtk_action_activate (action);
- else
- g_warning (_("Unexpected action '%s'."), name);
- }
-}
-
-static void
-midori_view_notify_icon_cb (MidoriView* view,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- if (midori_browser_get_current_tab (browser) != (GtkWidget*)view)
- return;
-
- if (midori_paths_get_runtime_mode () == MIDORI_RUNTIME_MODE_APP)
- gtk_window_set_icon (GTK_WINDOW (browser), midori_view_get_icon (view));
-}
-
-static void
-midori_view_notify_load_status_cb (GtkWidget* widget,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- MidoriView* view = MIDORI_VIEW (widget);
- MidoriLoadStatus load_status = midori_view_get_load_status (view);
-
- if (widget == midori_browser_get_current_tab (browser))
- {
- if (load_status == MIDORI_LOAD_COMMITTED)
- {
- const gchar* uri = midori_view_get_display_uri (view);
- GtkAction* action = _action_by_name (browser, "Location");
- midori_location_action_set_text (
- MIDORI_LOCATION_ACTION (action), uri);
-
- /* Focus the urlbar on blank pages */
- if (midori_view_is_blank (view))
- midori_browser_activate_action (browser, "Location");
- }
-
- _midori_browser_update_interface (browser, view);
- _midori_browser_set_statusbar_text (browser, view, NULL);
- }
-
- if (load_status == MIDORI_LOAD_FINISHED)
- katze_item_set_meta_string (midori_view_get_proxy_item (view),
- "history-step", NULL);
-
- g_object_notify (G_OBJECT (browser), "load-status");
-}
-
-static void
-midori_view_notify_progress_cb (GtkWidget* view,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- if (view == midori_browser_get_current_tab (browser))
- _midori_browser_update_progress (browser, MIDORI_VIEW (view));
-}
-
-static void
-midori_view_notify_uri_cb (GtkWidget* widget,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- if (widget == midori_browser_get_current_tab (browser))
- {
- MidoriView* view = MIDORI_VIEW (widget);
- const gchar* uri = midori_view_get_display_uri (view);
- GtkAction* action = _action_by_name (browser, "Location");
- midori_location_action_set_text (MIDORI_LOCATION_ACTION (action), uri);
- _action_set_sensitive (browser, "Back", midori_view_can_go_back (view));
- _action_set_sensitive (browser, "Forward", midori_tab_can_go_forward (MIDORI_TAB (view)));
- g_object_notify (G_OBJECT (browser), "uri");
- }
-}
-
-static void
-midori_browser_set_title (MidoriBrowser* browser,
- const gchar* title)
-{
- const gchar* custom_title = midori_settings_get_custom_title (MIDORI_SETTINGS (browser->settings));
- if (custom_title && *custom_title)
- gtk_window_set_title (GTK_WINDOW (browser), custom_title);
- else if (katze_object_get_boolean (browser->settings, "enable-private-browsing"))
- {
- gchar* window_title = g_strdup_printf (_("%s (Private Browsing)"), title);
- gtk_window_set_title (GTK_WINDOW (browser), window_title);
- g_free (window_title);
- }
- else
- gtk_window_set_title (GTK_WINDOW (browser), title);
-}
-
-static void
-midori_view_notify_title_cb (GtkWidget* widget,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- MidoriView* view = MIDORI_VIEW (widget);
- if (widget == midori_browser_get_current_tab (browser))
- {
- midori_browser_set_title (browser, midori_view_get_display_title (view));
- g_object_notify (G_OBJECT (browser), "title");
- }
- midori_browser_step_history (browser, view);
-}
-
-static void
-midori_browser_step_history (MidoriBrowser* browser,
- MidoriView* view)
-{
- if (midori_view_get_load_status (view) != MIDORI_LOAD_COMMITTED)
- return;
- if (!browser->history_database || !browser->maximum_history_age)
- return;
-
- KatzeItem* proxy = midori_view_get_proxy_item (view);
- const gchar* proxy_uri = katze_item_get_uri (proxy);
- if (midori_uri_is_blank (proxy_uri))
- return;
-
- //Do not save pages that fail to load in the history
- if (midori_tab_get_load_error (MIDORI_TAB (view)) == MIDORI_LOAD_ERROR_NETWORK)
- return;
-
- const gchar* history_step = katze_item_get_meta_string (proxy, "history-step");
- if (history_step == NULL)
- {
- GError* error = NULL;
- time_t now = time (NULL);
- katze_item_set_added (proxy, now);
- gint64 day = sokoke_time_t_to_julian (&now);
- midori_history_database_insert (browser->history_database,
- katze_item_get_uri (proxy),
- katze_item_get_name (proxy),
- katze_item_get_added (proxy), day, &error);
- if (error != NULL)
- {
- g_printerr (_("Failed to insert new history item: %s\n"), error->message);
- g_error_free (error);
- return;
- }
- katze_item_set_meta_string (proxy, "history-step", "update");
- /* FIXME: No signal for adding/ removing */
- katze_array_add_item (browser->history, proxy);
- katze_array_remove_item (browser->history, proxy);
- }
- else if (!strcmp (history_step, "update"))
- {
- if (proxy->name != NULL)
- midori_browser_update_history_title (browser, proxy);
- }
- else if (!strcmp (history_step, "ignore"))
- {
- /* This is set when restoring sessions */
- }
- else
- g_warning ("Unexpected history-step: %s", history_step);
-}
-
-static void
-midori_view_notify_zoom_level_cb (GtkWidget* view,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- if (view == midori_browser_get_current_tab (browser))
- _action_set_sensitive (browser, "ZoomNormal",
- midori_view_get_zoom_level (MIDORI_VIEW (view)) != 1.0f);
-}
-
-static void
-midori_view_notify_statusbar_text_cb (GtkWidget* view,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- gchar* text;
-
- if (view == midori_browser_get_current_tab (browser))
- {
- g_object_get (view, "statusbar-text", &text, NULL);
- _midori_browser_set_statusbar_text (browser, MIDORI_VIEW (view), text);
- g_free (text);
- }
-}
-
-static gboolean
-midori_bookmark_folder_button_reach_parent (GtkTreeModel* model, GtkTreeIter *iter, gint64 parentid)
-{
- do
- {
- gint64 id;
-
- gtk_tree_model_get (model, iter, 1, &id, -1);
-
- if (parentid == id)
- return TRUE;
-
- if (gtk_tree_model_iter_has_child (model, iter))
- {
- GtkTreeIter child;
- gtk_tree_model_iter_children (model, &child, iter);
- if (midori_bookmark_folder_button_reach_parent (model, &child, parentid))
- {
- *iter = child;
- return TRUE;
- }
- }
- }
- while (gtk_tree_model_iter_next (model, iter));
-
- return FALSE;
-}
-
-typedef struct _FolderEntry
-{
- const gchar *title;
- gint64 id;
- gint64 parentid;
-} FolderEntry;
-
-static void
-midori_bookmark_folder_free_folder_entry (FolderEntry* folder)
-{
- g_free ((gpointer)folder->title);
-}
-
-static GtkWidget*
-midori_bookmark_folder_button_new (MidoriBookmarksDb* array,
- gint64 selected_parentid)
-{
- GtkTreeStore* model;
- GtkWidget* combo;
- GtkCellRenderer* renderer;
- guint n;
- sqlite3* db;
- sqlite3_stmt* statement;
- gint result;
- const gchar* sqlcmd = "SELECT title, id, parentid FROM bookmarks WHERE uri='' ORDER BY parentid, title ASC";
- gint64 current_parentid;
- GtkTreeIter tree_iter;
- GtkTreeIter stock_parent_iter;
- GtkTreeIter* parent_iter;
- GList *folders = NULL;
-
- db = g_object_get_data (G_OBJECT (array), "db");
- g_return_val_if_fail (db != NULL, NULL);
-
- /* folder combo box model content:
- ** 0: title
- ** 1: id
- */
- model = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_INT64);
- combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model));
-
- /* setup combo layout
- ** 0: a folder icon
- ** 1: the folder name
- */
-
- gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo));
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- g_object_set (G_OBJECT (renderer),
- "stock-id", GTK_STOCK_DIRECTORY,
- "stock-size", GTK_ICON_SIZE_MENU,
- NULL);
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
-
- renderer = katze_cell_renderer_combobox_text_new ();
- g_object_set (G_OBJECT (renderer),
- "width-chars", 40, /* FIXME: figure out a way to define an acceptable string length */
- "ellipsize", PANGO_ELLIPSIZE_END,
- "unfolded-text", _("Select [text]"),
- NULL);
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "text", 0);
-
- /* read the folders list from the database */
- /* FIXME: this should be a service of midori/midori-bookmarks-db */
-
- if ((result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL)) == SQLITE_OK)
- {
- while ((result = sqlite3_step (statement)) == SQLITE_ROW)
- {
- FolderEntry* folder = g_new (FolderEntry, 1);
-
- folder->title = g_strdup ((const gchar*)sqlite3_column_text (statement, 0));
- folder->id = sqlite3_column_int64 (statement, 1);
- folder->parentid = sqlite3_column_int64 (statement, 2);
-
- folders = g_list_append (folders, folder);
- }
-
- sqlite3_clear_bindings (statement);
- sqlite3_reset (statement);
- }
-
- /* populate the combo box */
- /* FIXME: here we should have the root bookmark array's name and id, not hard encoded values */
-
- gtk_tree_store_insert_with_values (model, &tree_iter, NULL, G_MAXINT,
- 0, _("Bookmarks"), 1, (gint64)-1, -1);
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &tree_iter);
-
- current_parentid = -1;
- parent_iter = NULL;
- n = 1;
- while (g_list_first (folders))
- {
- gboolean something_done = FALSE;
- GList* list_iter = g_list_first (folders);
-
- do
- {
- FolderEntry* folder = list_iter->data;
- const gchar* title = folder->title;
- gint64 id = folder->id;
- gint64 parentid = folder->parentid;
-
- if (parentid != current_parentid) /* optimize case of sub-folders of the same parent */
- {
- if (!parentid)
- {
- /* folder's parent is the stree store root */
-
- current_parentid = -1;
- parent_iter = NULL;
- }
- else if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &tree_iter))
- {
- if (midori_bookmark_folder_button_reach_parent (
- GTK_TREE_MODEL (model), &tree_iter, parentid))
- {
- /* folder's parent found in the tree store */
-
- current_parentid = parentid;
- stock_parent_iter = tree_iter;
- parent_iter = &stock_parent_iter;
- }
- else
- {
- /* folder's parent not found, skip it */
-
- list_iter = g_list_next (list_iter);
- continue;
- }
- }
- else
- g_assert_not_reached ();
- }
-
- /* insert folder in the tree store and remove it from the folders list */
-
- gtk_tree_store_insert_with_values (model, &tree_iter, parent_iter, G_MAXINT,
- 0, title, 1, id, -1);
-
- if (id == selected_parentid)
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &tree_iter);
-
- n++;
-
- something_done = TRUE;
-
- g_free ((gpointer)title);
- folders = g_list_delete_link (folders, list_iter);
-
- list_iter = g_list_first (folders);
- }
- while (list_iter);
-
- if (!something_done) /* avoid infinite loop in case of orphan folders */
- break;
- }
-
- if (g_list_first (folders))
- {
- GList* iter;
- g_printerr ("midori_bookmark_folder_button_new: orphan folder(s) detected in bookmarks db\n");
-
- for (iter = g_list_first (folders) ; iter ; iter = g_list_next (iter))
- {
- FolderEntry* folder = iter->data;
- const gchar* title = folder->title;
- gint64 id = folder->id;
- gint64 parentid = folder->parentid;
-
- g_printerr (" id=%" G_GINT64_FORMAT ", parentid=%" G_GINT64_FORMAT ", title=%s\n",
- id, parentid, title);
- }
-
- g_list_free_full (folders, (GDestroyNotify)midori_bookmark_folder_free_folder_entry);
- }
-
- if (n < 2)
- gtk_widget_set_sensitive (combo, FALSE);
-
- return combo;
-}
-
-static gint64
-midori_bookmark_folder_button_get_active (GtkWidget* combo)
-{
- gint64 id = -1;
- GtkTreeIter iter;
-
- g_return_val_if_fail (GTK_IS_COMBO_BOX (combo), 0);
-
- if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter))
- {
- GtkTreeModel* model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
- gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, 1, &id, -1);
- }
-
- return id;
-}
-
-static void
-midori_browser_edit_bookmark_title_changed_cb (GtkEntry* entry,
- GtkWidget* button)
-{
- const gchar* title = gtk_entry_get_text (entry);
- gtk_widget_set_sensitive (button,
- title != NULL && title[0] != '\0');
-}
-
-static void
-midori_browser_edit_bookmark_response_cb (GtkWidget* dialog,
- gint response,
- MidoriBrowser* browser)
-{
- if (response == GTK_RESPONSE_ACCEPT)
- {
- KatzeItem* bookmark = g_object_get_data (G_OBJECT (dialog), "bookmark");
- GtkWidget* entry_title = g_object_get_data (G_OBJECT (dialog), "entry-title");
- katze_item_set_name (bookmark,
- gtk_entry_get_text (GTK_ENTRY (entry_title)));
- GtkWidget* check_toolbar = g_object_get_data (G_OBJECT (dialog), "check-toolbar");
- katze_item_set_meta_integer (bookmark, "toolbar",
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_toolbar)));
- GtkWidget* entry_uri = g_object_get_data (G_OBJECT (dialog), "entry-uri");
- if (!KATZE_IS_ARRAY (bookmark))
- katze_item_set_uri (bookmark,
- gtk_entry_get_text (GTK_ENTRY (entry_uri)));
-
- GtkWidget* combo_folder = g_object_get_data (G_OBJECT (dialog), "combo-folder");
- gint64 selected = midori_bookmark_folder_button_get_active (combo_folder);
- katze_item_set_meta_integer (bookmark, "parentid", selected);
-
- gboolean new_bookmark = g_object_get_data (G_OBJECT (dialog), "new-bookmark") != NULL;
- if (new_bookmark)
- midori_bookmarks_db_add_item (browser->bookmarks, bookmark);
- else
- midori_bookmarks_db_update_item (browser->bookmarks, bookmark);
- }
- gtk_widget_destroy (dialog);
-}
-
-static void
-midori_browser_edit_bookmark_add_speed_dial_cb (GtkWidget* button,
- KatzeItem* bookmark)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (button);
- midori_browser_add_speed_dial (browser);
- #if GTK_CHECK_VERSION (3, 12, 0)
- GtkWidget* dialog = gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER);
- #else
- GtkWidget* dialog = gtk_widget_get_toplevel (button);
- #endif
- midori_browser_edit_bookmark_response_cb (dialog, GTK_RESPONSE_DELETE_EVENT, browser);
-}
-
-static void
-midori_browser_edit_bookmark_create_launcher_cb (GtkWidget* button,
- KatzeItem* bookmark)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (button);
- GtkAction* action = g_object_get_data (G_OBJECT (button), "midori-action");
- gtk_action_activate (action);
- #if GTK_CHECK_VERSION (3, 12, 0)
- GtkWidget* dialog = gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER);
- #else
- GtkWidget* dialog = gtk_widget_get_toplevel (button);
- #endif
- midori_browser_edit_bookmark_response_cb (dialog, GTK_RESPONSE_DELETE_EVENT, browser);
-}
-
-#if GTK_CHECK_VERSION (3, 12, 0)
-static void
-midori_browser_edit_bookmark_button_cb (GtkWidget* button,
- MidoriBrowser* browser)
-{
- GtkWidget* dialog = gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER);
- midori_browser_edit_bookmark_response_cb (dialog, GTK_RESPONSE_ACCEPT, browser);
-}
-#endif
-
-/* Private function, used by MidoriBookmarks and MidoriHistory */
-/* static */ gboolean
-midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
- KatzeItem* bookmark_or_parent,
- gboolean new_bookmark,
- gboolean is_folder,
- GtkWidget* proxy)
-{
- KatzeItem* bookmark = bookmark_or_parent;
- const gchar* title;
- GtkWidget* dialog;
- GtkWidget* accept;
- GtkWidget* content_area;
- GtkWidget* actions;
- GtkWidget* view;
- GtkWidget* vbox;
- GtkWidget* hbox;
- GtkWidget* label;
- const gchar* value;
- GtkWidget* entry_title;
- GtkWidget* entry_uri;
- GtkWidget* combo_folder;
- GtkWidget* check_toolbar;
- gboolean return_status = FALSE;
-
- if (is_folder)
- title = new_bookmark ? _("New Folder") : _("Edit Folder");
- else
- title = new_bookmark ? _("New Bookmark") : _("Edit Bookmark");
- #if GTK_CHECK_VERSION (3, 12, 0)
- if (proxy != NULL)
- {
- dialog = gtk_popover_new (proxy);
- content_area = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_container_add (GTK_CONTAINER (dialog), content_area);
- actions = gtk_hbox_new (FALSE, 6);
- gtk_box_pack_end (GTK_BOX (content_area), actions, TRUE, TRUE, 0);
- accept = gtk_button_new_from_stock (new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_SAVE);
- gtk_box_pack_end (GTK_BOX (actions), accept, FALSE, FALSE, 0);
- g_signal_connect (accept, "clicked", G_CALLBACK (midori_browser_edit_bookmark_button_cb), browser);
- }
- else
- #endif
- {
- dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (browser),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, NULL, NULL);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- actions = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_end (GTK_BOX (content_area), actions, TRUE, TRUE, 0);
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
- gtk_window_set_icon_name (GTK_WINDOW (dialog),
- new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_REMOVE);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
- g_signal_connect (dialog, "response", G_CALLBACK (midori_browser_edit_bookmark_response_cb), browser);
- accept = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
- }
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);
-
- if (!is_folder)
- label = gtk_label_new (_("Type a name for this bookmark, and choose where to keep it."));
- else
- label = gtk_label_new (_("Type a name for this folder, and choose where to keep it."));
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 6);
- gtk_box_pack_start (GTK_BOX (content_area), vbox, FALSE, FALSE, 0);
-
- if (new_bookmark)
- {
- view = midori_browser_get_current_tab (browser);
- if (is_folder)
- {
- bookmark = (KatzeItem*)katze_array_new (KATZE_TYPE_ARRAY);
- katze_item_set_name (bookmark,
- midori_view_get_display_title (MIDORI_VIEW (view)));
- }
- else
- bookmark = g_object_new (KATZE_TYPE_ITEM,
- "uri", midori_view_get_display_uri (MIDORI_VIEW (view)),
- "name", midori_view_get_display_title (MIDORI_VIEW (view)), NULL);
- katze_item_set_meta_integer (
- bookmark, "parentid",
- (!bookmark_or_parent
- ? 0
- : katze_item_get_meta_integer (bookmark_or_parent, "id")));
- g_object_set_data (G_OBJECT (dialog), "new-bookmark", bookmark);
- }
- g_object_set_data_full (G_OBJECT (dialog), "bookmark", bookmark, (GDestroyNotify)g_object_unref);
-
- entry_title = gtk_entry_new ();
- gtk_entry_set_activates_default (GTK_ENTRY (entry_title), TRUE);
- value = katze_item_get_name (bookmark);
- gtk_entry_set_text (GTK_ENTRY (entry_title), katze_str_non_null (value));
- midori_browser_edit_bookmark_title_changed_cb (GTK_ENTRY (entry_title),
- accept);
- g_signal_connect (entry_title, "changed",
- G_CALLBACK (midori_browser_edit_bookmark_title_changed_cb), accept);
- gtk_box_pack_start (GTK_BOX (vbox), entry_title, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT (dialog), "entry-title", entry_title);
-
- entry_uri = NULL;
- if (!is_folder)
- {
- entry_uri = katze_uri_entry_new (accept);
- gtk_entry_set_activates_default (GTK_ENTRY (entry_uri), TRUE);
- gtk_entry_set_text (GTK_ENTRY (entry_uri), katze_item_get_uri (bookmark));
- gtk_box_pack_start (GTK_BOX (vbox), entry_uri, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT (dialog), "entry-uri", entry_uri);
- }
-
- combo_folder = midori_bookmark_folder_button_new (browser->bookmarks,
- katze_item_get_meta_integer (bookmark, "parentid"));
- gtk_box_pack_start (GTK_BOX (vbox), combo_folder, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT (dialog), "combo-folder", combo_folder);
-
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- check_toolbar = gtk_check_button_new_with_mnemonic (_("Show in Bookmarks _Bar"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_toolbar),
- katze_item_get_meta_boolean (bookmark, "toolbar"));
- gtk_box_pack_start (GTK_BOX (hbox), check_toolbar, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT (dialog), "check-toolbar", check_toolbar);
-
- if (new_bookmark && !is_folder)
- {
- label = gtk_button_new_with_mnemonic (_("Add to _Speed Dial"));
- g_signal_connect (label, "clicked",
- G_CALLBACK (midori_browser_edit_bookmark_add_speed_dial_cb), bookmark);
- gtk_box_pack_start (GTK_BOX (actions), label, FALSE, FALSE, 0);
-
- /* FIXME: There's no API for extending the bookmark dialog */
- GtkAction* action = _action_by_name (browser, "CreateLauncher");
- if (action != NULL)
- {
- label = gtk_button_new_with_mnemonic (gtk_action_get_label (action));
- g_object_set_data (G_OBJECT (label), "midori-action", action);
- g_signal_connect (label, "clicked",
- G_CALLBACK (midori_browser_edit_bookmark_create_launcher_cb), bookmark);
- gtk_box_pack_start (GTK_BOX (actions), label, FALSE, FALSE, 0);
- }
- }
-
- gtk_widget_show_all (content_area);
- gtk_widget_show (dialog);
-
- return return_status;
-}
-
-static gboolean
-midori_browser_prepare_download (MidoriBrowser* browser,
- WebKitDownload* download,
- const gchar* uri)
-
-{
- if (!midori_download_has_enough_space (download, uri, FALSE))
- return FALSE;
-
-#ifdef HAVE_WEBKIT2
- webkit_download_set_destination (download, uri);
-#else
- webkit_download_set_destination_uri (download, uri);
-#endif
- g_signal_emit (browser, signals[ADD_DOWNLOAD], 0, download);
- return TRUE;
-}
-
-#ifndef HAVE_WEBKIT2
-static void
-midori_browser_save_resources (GList* resources,
- const gchar* folder)
-{
- GList* list;
- katze_mkdir_with_parents (folder, 0700);
-
- for (list = resources; list; list = g_list_next (list))
- {
- WebKitWebResource* resource = WEBKIT_WEB_RESOURCE (list->data);
- GString* data = webkit_web_resource_get_data (resource);
-
- /* Resource could be adblocked, skip it in that case */
- if (!g_strcmp0 (webkit_web_resource_get_uri (resource), "about:blank"))
- continue;
-
- gchar* sub_filename = midori_download_get_filename_suggestion_for_uri (
- webkit_web_resource_get_mime_type (resource),
- webkit_web_resource_get_uri (resource));
- gchar* sub_path = g_build_filename (folder, sub_filename, NULL);
- sub_path = midori_download_get_unique_filename (sub_path);
- if (data)
- {
- GError* error = NULL;
- if (!g_file_set_contents (sub_path, data->str, data->len, &error))
- {
- g_warning ("Failed to save %s: %s", sub_filename, error->message);
- g_error_free (error);
- }
- }
- else
- g_warning ("Skipping empty resource %s", sub_filename);
- g_free (sub_filename);
- g_free (sub_path);
- }
-}
-#endif
-
-void
-midori_browser_save_uri (MidoriBrowser* browser,
- MidoriView* view,
- const gchar* uri)
-{
- static gchar* last_dir = NULL;
- GtkWidget* dialog;
- const gchar* title = midori_view_get_display_title (view);
- gchar* filename;
-
- dialog = (GtkWidget*)midori_file_chooser_dialog_new (_("Save file as"),
- GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);
- gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
-
- if (uri == NULL)
- uri = midori_view_get_display_uri (view);
-
- if (last_dir && *last_dir)
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), last_dir);
- else
- {
- gchar* dirname = midori_uri_get_folder (uri);
- if (dirname == NULL)
- dirname = katze_object_get_string (browser->settings, "download-folder");
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dirname);
- g_free (dirname);
- }
-
-#ifndef HAVE_WEBKIT2
- GList* resources = midori_view_get_resources (view);
- gboolean file_only = TRUE;
- GtkWidget* checkbox = NULL;
-
- if (resources != NULL && g_list_nth_data (resources, 1) != NULL)
- {
- file_only = FALSE;
- checkbox = gtk_check_button_new_with_mnemonic (_("Save associated _resources"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), TRUE);
- gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), checkbox);
- }
-
- if (!file_only && !g_str_equal (title, uri))
- filename = midori_download_clean_filename (title);
- else
- {
- gchar* mime_type = katze_object_get_object (view, "mime-type");
- filename = midori_download_get_filename_suggestion_for_uri (mime_type, uri);
- g_free (mime_type);
- }
- gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filename);
- g_free (filename);
-
- if (midori_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
- {
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- if (checkbox != NULL)
- file_only = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox));
- if (!file_only)
- {
- gchar* fullname = g_strconcat (filename, ".html", NULL);
- midori_view_save_source (view, uri, fullname, FALSE);
- g_free (fullname);
- midori_browser_save_resources (resources, filename);
- }
- else
- midori_view_save_source (view, uri, filename, FALSE);
- katze_assign (last_dir,
- gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog)));
- }
- g_list_foreach (resources, (GFunc)g_object_unref, NULL);
- g_list_free (resources);
-#else
- filename = midori_download_clean_filename (title);
- gchar* suggested_filename = g_strconcat (filename, ".mht", NULL);
- gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), suggested_filename);
-
- g_free (filename);
- g_free (suggested_filename);
- if (midori_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
- {
- gchar* destination_uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
- if (destination_uri != NULL)
- {
- midori_view_save_source (view, uri, destination_uri, false);
- g_free (destination_uri);
- }
- katze_assign (last_dir,
- gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog)));
- }
-#endif
- gtk_widget_destroy (dialog);
-}
-
-static void
-midori_browser_speed_dial_refresh_cb (MidoriSpeedDial* dial,
- MidoriBrowser* browser)
-{
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs != NULL; tabs = g_list_next (tabs))
- if (!strcmp (midori_tab_get_uri (tabs->data), "about:dial"))
- midori_view_reload (tabs->data, FALSE);
- g_list_free (tabs);
-}
-
-static void
-midori_browser_add_speed_dial (MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_get_current_tab (browser);
- midori_speed_dial_add (browser->dial,
- midori_view_get_display_uri (MIDORI_VIEW (view)),
- midori_view_get_display_title (MIDORI_VIEW (view)), NULL);
-}
-
-static gboolean
-midori_browser_tab_leave_notify_event_cb (GtkWidget* widget,
- GdkEventCrossing* event,
- MidoriBrowser* browser)
-{
- _midori_browser_set_statusbar_text (browser, MIDORI_VIEW (widget), NULL);
- return TRUE;
-}
-
-static void
-midori_browser_view_copy_to_item_history (GtkWidget* view,
- KatzeItem* item)
-{
-#ifndef HAVE_WEBKIT2
- WebKitWebView* copy_from;
- WebKitWebBackForwardList* list_from;
- guint length_from;
- gint i;
- GPtrArray* history;
-
- copy_from = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
- list_from = webkit_web_view_get_back_forward_list (copy_from);
- length_from = webkit_web_back_forward_list_get_back_length (list_from);
- history = g_ptr_array_new ();
-
- for (i = -length_from; i <= -1 ; i++)
- {
- WebKitWebHistoryItem* hist_item = webkit_web_back_forward_list_get_nth_item (list_from, i);
- if (hist_item == NULL)
- break;
- g_object_ref ((gpointer) hist_item);
- g_ptr_array_add (history, (gpointer) hist_item);
- }
- g_object_set_data (G_OBJECT (item), "tab-history", (gpointer) history);
-#endif
-}
-
-static void
-midori_view_destroy_cb (GtkWidget* view,
- MidoriBrowser* browser)
-{
- if (browser->proxy_array)
- {
- KatzeItem* item = midori_view_get_proxy_item (MIDORI_VIEW (view));
- if (katze_array_get_item_index (browser->proxy_array, item) != -1
- && !midori_tab_is_blank (MIDORI_TAB (view)))
- {
- if (browser->trash)
- {
- midori_browser_view_copy_to_item_history (view,item);
- katze_array_add_item (browser->trash, item);
- }
- midori_browser_update_history (item, "website", "leave");
- }
- midori_browser_disconnect_tab (browser, MIDORI_VIEW (view));
- g_signal_emit (browser, signals[REMOVE_TAB], 0, view);
- }
-}
-
-static void
-midori_view_attach_inspector_cb (GtkWidget* view,
- GtkWidget* inspector_view,
- MidoriBrowser* browser)
-{
- GtkWidget* toplevel = gtk_widget_get_toplevel (inspector_view);
- GtkWidget* scrolled = gtk_widget_get_parent (browser->inspector_view);
- if (browser->inspector_view == inspector_view)
- return;
-
- gtk_widget_hide (toplevel);
- gtk_widget_destroy (browser->inspector_view);
- gtk_widget_reparent (inspector_view, scrolled);
- gtk_widget_show_all (browser->inspector);
- browser->inspector_view = inspector_view;
- gtk_widget_destroy (toplevel);
- if (!katze_object_get_boolean (browser->settings, "last-inspector-attached"))
- g_object_set (browser->settings, "last-inspector-attached", TRUE, NULL);
-}
-
-static void
-midori_view_detach_inspector_cb (GtkWidget* view,
- GtkWidget* inspector_view,
- MidoriBrowser* browser)
-{
- GtkWidget* scrolled = gtk_widget_get_parent (GTK_WIDGET (inspector_view));
- GtkWidget* paned = gtk_widget_get_parent (scrolled);
- browser->inspector_view = gtk_viewport_new (NULL, NULL);
- gtk_container_remove (GTK_CONTAINER (scrolled), GTK_WIDGET (inspector_view));
- gtk_container_add (GTK_CONTAINER (scrolled), browser->inspector_view);
- gtk_widget_hide (paned);
- if (katze_object_get_boolean (browser->settings, "last-inspector-attached"))
- g_object_set (browser->settings, "last-inspector-attached", FALSE, NULL);
-}
-
-static void
-midori_browser_view_copy_history (GtkWidget* view_to,
- GtkWidget* view_from,
- gboolean omit_last)
-{
-#ifndef HAVE_WEBKIT2
- WebKitWebView* copy_from;
- WebKitWebBackForwardList* list_from;
- WebKitWebView* copy_to;
- WebKitWebBackForwardList* list_to;
- guint length_from;
- gint i;
-
- copy_from = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view_from)));
- list_from = webkit_web_view_get_back_forward_list (copy_from);
- copy_to = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view_to)));
- list_to = webkit_web_view_get_back_forward_list (copy_to);
- length_from = webkit_web_back_forward_list_get_back_length (list_from);
-
- for (i = -length_from; i <= (omit_last ? -1 : 0); i++)
- {
- WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_nth_item (list_from, i);
- if (item == NULL)
- break;
- webkit_web_back_forward_list_add_item (list_to, item);
- }
-#endif
-}
-
-
-static void
-midori_browser_view_copy_from_item_history (GtkWidget* view,
- KatzeItem* item)
-{
-#ifndef HAVE_WEBKIT2
- WebKitWebView* copy_to;
- WebKitWebBackForwardList* list_to;
- guint i;
- GPtrArray* list_from;
-
- copy_to = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
- list_to = webkit_web_view_get_back_forward_list (copy_to);
-
- if (item == NULL)
- return;
- list_from = g_object_get_data (G_OBJECT (item), "tab-history");
- if (list_from == NULL)
- return;
-
- for (i = 0; i < list_from->len; i++)
- {
- WebKitWebHistoryItem* hist_item = (WebKitWebHistoryItem*) g_ptr_array_index (list_from, i);
- if (hist_item == NULL)
- break;
- webkit_web_back_forward_list_add_item (list_to, hist_item);
- }
- g_ptr_array_unref (list_from);
-#endif
-}
-
-
-
-static gboolean
-midori_browser_notify_new_tab_timeout_cb (MidoriBrowser *browser)
-{
- #ifndef G_OS_WIN32
- gtk_window_set_opacity (GTK_WINDOW (browser), 1);
- #endif
- return G_SOURCE_REMOVE;
-}
-
-static void
-midori_browser_notify_new_tab (MidoriBrowser* browser)
-{
- if (katze_object_get_boolean (browser->settings, "flash-window-on-new-bg-tabs"))
- {
- #ifndef G_OS_WIN32
- gtk_window_set_opacity (GTK_WINDOW (browser), 0.8);
- #endif
- midori_timeout_add (100,
- (GSourceFunc) midori_browser_notify_new_tab_timeout_cb, browser, NULL);
- }
-}
-
-static bool
-midori_view_forward_external (GtkWidget* view,
- const gchar* uri,
- MidoriNewView where)
-{
- if (midori_paths_get_runtime_mode () == MIDORI_RUNTIME_MODE_APP)
- {
- gboolean handled = FALSE;
- g_signal_emit_by_name (view, "open-uri", uri, &handled);
- return handled;
- }
- else if (midori_paths_get_runtime_mode () == MIDORI_RUNTIME_MODE_PRIVATE)
- {
- if (where == MIDORI_NEW_VIEW_WINDOW)
- {
- sokoke_spawn_app (uri, TRUE);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-static void
-midori_view_new_tab_cb (GtkWidget* view,
- const gchar* uri,
- gboolean background,
- MidoriBrowser* browser)
-{
- if (midori_view_forward_external (view, uri, MIDORI_NEW_VIEW_TAB))
- return;
-
- GtkWidget* new_view = midori_browser_add_uri (browser, uri);
- if (view != NULL)
- midori_browser_view_copy_history (new_view, view, FALSE);
-
- if (!background)
- midori_browser_set_current_tab (browser, new_view);
- else
- midori_browser_notify_new_tab (browser);
-}
-
-static void
-midori_view_new_window_cb (GtkWidget* view,
- const gchar* uri,
- MidoriBrowser* browser)
-{
- if (midori_view_forward_external (
- view ? view : midori_browser_get_current_tab (browser),
- uri, MIDORI_NEW_VIEW_WINDOW))
- return;
-
- MidoriBrowser* new_browser;
- g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser);
- g_assert (new_browser != NULL);
- midori_view_new_tab_cb (view, uri, FALSE, new_browser);
-}
-
-static void
-midori_view_new_view_cb (GtkWidget* view,
- GtkWidget* new_view,
- MidoriNewView where,
- gboolean user_initiated,
- MidoriBrowser* browser)
-{
- if (midori_tab_get_is_dialog (MIDORI_TAB (view)))
- {
- /* Dialog: URL, no toolbars, no tabs */
- MidoriBrowser* new_browser;
- g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser);
- g_assert (new_browser != NULL);
- gtk_window_set_transient_for (GTK_WINDOW (new_browser), GTK_WINDOW (browser));
- gtk_window_set_destroy_with_parent (GTK_WINDOW (new_browser), TRUE);
- g_object_set (new_browser,
- "show-tabs", FALSE,
- NULL);
- sokoke_widget_set_visible (new_browser->menubar, FALSE);
- sokoke_widget_set_visible (new_browser->bookmarkbar, FALSE);
- sokoke_widget_set_visible (new_browser->statusbar, FALSE);
- _action_set_visible (new_browser, "CompactMenu", FALSE);
- _action_set_sensitive (new_browser, "Location", FALSE);
- midori_window_set_actions (MIDORI_WINDOW (new_browser), "Location");
- sokoke_widget_set_visible (new_browser->panel, FALSE);
- midori_browser_add_tab (new_browser, new_view);
- midori_browser_set_current_tab (new_browser, new_view);
- return;
- }
-
- if (midori_view_forward_external (view,
- katze_item_get_uri (midori_view_get_proxy_item (MIDORI_VIEW (new_view))),
- where))
- return;
-
- midori_browser_view_copy_history (new_view, view, TRUE);
- if (where == MIDORI_NEW_VIEW_WINDOW)
- {
- MidoriBrowser* new_browser;
- g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser);
- g_assert (new_browser != NULL);
- midori_browser_add_tab (new_browser, new_view);
- midori_browser_set_current_tab (new_browser, new_view);
- }
- else if (gtk_widget_get_parent (new_view) != browser->notebook)
- {
- midori_browser_add_tab (browser, new_view);
- if (where != MIDORI_NEW_VIEW_BACKGROUND)
- midori_browser_set_current_tab (browser, new_view);
- }
- else
- midori_browser_notify_new_tab (browser);
-
- if (!user_initiated)
- {
- GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (browser));
- GdkWindowState state = gdk_window_get_state (window);
- if ((state | GDK_WINDOW_STATE_MAXIMIZED)
- || (state | GDK_WINDOW_STATE_FULLSCREEN))
- {
- if (where == MIDORI_NEW_VIEW_WINDOW)
- g_signal_emit (browser, signals[SEND_NOTIFICATION], 0,
- _("New Window"), _("A new window has been opened"));
- else if (!browser->show_tabs)
- g_signal_emit (browser, signals[SEND_NOTIFICATION], 0,
- _("New Tab"), _("A new tab has been opened"));
- }
- }
-}
-
-#ifdef HAVE_WEBKIT2
-static void
-midori_browser_close_tab_idle (GObject* resource,
- GAsyncResult* result,
- gpointer view)
-{
- guchar* data = webkit_web_resource_get_data_finish (WEBKIT_WEB_RESOURCE (resource),
- result, NULL, NULL);
- if (data != NULL)
- return;
-#else
-static gboolean
-midori_browser_close_tab_idle (gpointer view)
-{
-#endif
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view));
- midori_browser_close_tab (browser, GTK_WIDGET (view));
-#ifndef HAVE_WEBKIT2
- return G_SOURCE_REMOVE;
-#endif
-}
-
-static gboolean
-midori_view_download_requested_cb (GtkWidget* view,
- WebKitDownload* download,
- MidoriBrowser* browser)
-{
- MidoriDownloadType type = midori_download_get_type (download);
- gboolean handled = TRUE;
-
- g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
- if (type == MIDORI_DOWNLOAD_CANCEL)
- {
- handled = FALSE;
- }
- #ifdef HAVE_WEBKIT2
- else if (!webkit_download_get_destination (download))
- #else
- else if (!webkit_download_get_destination_uri (download))
- #endif
- {
- if (type == MIDORI_DOWNLOAD_SAVE_AS)
- {
- static GtkWidget* dialog = NULL;
- gchar* filename;
-
- if (!dialog)
- {
- #ifdef HAVE_WEBKIT2
- const gchar* download_uri = webkit_uri_response_get_uri (
- webkit_download_get_response (download));
- #else
- const gchar* download_uri = webkit_download_get_uri (download);
- #endif
- gchar* folder;
- dialog = (GtkWidget*)midori_file_chooser_dialog_new (_("Save file"),
- GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);
- gtk_file_chooser_set_do_overwrite_confirmation (
- GTK_FILE_CHOOSER (dialog), TRUE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
- folder = midori_uri_get_folder (download_uri);
- if (folder == NULL)
- folder = katze_object_get_string (browser->settings, "download-folder");
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), folder);
- g_free (folder);
- g_signal_connect (dialog, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &dialog);
- }
- filename = midori_download_get_suggested_filename (download);
- gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filename);
- g_free (filename);
-
- if (midori_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
- {
- gtk_widget_hide (dialog);
- gchar* uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
- if (!midori_browser_prepare_download (browser, download, uri))
- {
- g_free (uri);
- return FALSE;
- }
- g_free (uri);
- }
- else
- {
- gtk_widget_hide (dialog);
- return FALSE;
- }
- }
- else
- {
- gchar* folder = type == MIDORI_DOWNLOAD_OPEN ? NULL
- : katze_object_get_string (browser->settings, "download-folder");
- gchar* destination_uri =
- midori_download_prepare_destination_uri (download, folder);
- midori_browser_prepare_download (browser, download, destination_uri);
- g_free (destination_uri);
- }
- #ifndef HAVE_WEBKIT2
- webkit_download_start (download);
- #endif
- }
-
- /* Close empty tabs due to download links with a target */
- if (midori_view_is_blank (MIDORI_VIEW (view)))
- {
- GtkWidget* web_view = midori_view_get_web_view (MIDORI_VIEW (view));
- #ifdef HAVE_WEBKIT2
- WebKitWebResource* resource = webkit_web_view_get_main_resource (WEBKIT_WEB_VIEW (web_view));
- webkit_web_resource_get_data (resource, NULL, midori_browser_close_tab_idle, view);
- #else
- WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
- WebKitWebDataSource* datasource = webkit_web_frame_get_data_source (web_frame);
- if (webkit_web_data_source_get_data (datasource) == NULL)
- g_idle_add (midori_browser_close_tab_idle, view);
- #endif
- }
- return handled;
-}
-
-void download_created_destination_cb (WebKitDownload *download,
- gchar *destination,
- gpointer user_data){
- g_print("%s: destination %s",G_STRFUNC,destination);
-}
-
-static void
-midori_view_search_text_cb (GtkWidget* view,
- gboolean found,
- gchar* typing,
- MidoriBrowser* browser)
-{
- midori_findbar_search_text (MIDORI_FINDBAR (browser->find), view, found, typing);
-}
-
-gint
-midori_browser_get_n_pages (MidoriBrowser* browser)
-{
- return midori_notebook_get_count (MIDORI_NOTEBOOK (browser->notebook));
-}
-
-static void
-_midori_browser_remove_tab (MidoriBrowser* browser,
- GtkWidget* widget)
-{
- gtk_widget_destroy (widget);
-}
-
-static void
-midori_browser_connect_tab (MidoriBrowser* browser,
- GtkWidget* view)
-{
- KatzeItem* item = midori_view_get_proxy_item (MIDORI_VIEW (view));
- katze_array_add_item (browser->proxy_array, item);
-
- g_object_connect (view,
- "signal::notify::icon",
- midori_view_notify_icon_cb, browser,
- "signal::notify::load-status",
- midori_view_notify_load_status_cb, browser,
- "signal::notify::progress",
- midori_view_notify_progress_cb, browser,
- "signal::notify::uri",
- midori_view_notify_uri_cb, browser,
- "signal::notify::title",
- midori_view_notify_title_cb, browser,
- "signal::notify::zoom-level",
- midori_view_notify_zoom_level_cb, browser,
- "signal::notify::statusbar-text",
- midori_view_notify_statusbar_text_cb, browser,
- "signal::attach-inspector",
- midori_view_attach_inspector_cb, browser,
- "signal::detach-inspector",
- midori_view_detach_inspector_cb, browser,
- "signal::new-tab",
- midori_view_new_tab_cb, browser,
- "signal::new-window",
- midori_view_new_window_cb, browser,
- "signal::new-view",
- midori_view_new_view_cb, browser,
- "signal-after::download-requested",
- midori_view_download_requested_cb, browser,
- "signal::search-text",
- midori_view_search_text_cb, browser,
- "signal::leave-notify-event",
- midori_browser_tab_leave_notify_event_cb, browser,
- "signal::destroy",
- midori_view_destroy_cb, browser,
- NULL);
-}
-
-static void
-midori_browser_disconnect_tab (MidoriBrowser* browser,
- MidoriView* view)
-{
- KatzeItem* item = midori_view_get_proxy_item (view);
- katze_array_remove_item (browser->proxy_array, item);
-
- /* We don't ever want to be in a situation with no tabs,
- so just create an empty one if the last one is closed.
- The only exception is when we are closing the window,
- which is indicated by the proxy array having been unset. */
- if (katze_array_is_empty (browser->proxy_array))
- {
- midori_browser_add_uri (browser, "about:new");
- midori_browser_set_current_page (browser, 0);
- }
-
- _midori_browser_update_actions (browser);
-
- g_object_disconnect (view,
- "any_signal",
- midori_view_notify_icon_cb, browser,
- "any_signal",
- midori_view_notify_load_status_cb, browser,
- "any_signal",
- midori_view_notify_progress_cb, browser,
- "any_signal",
- midori_view_notify_uri_cb, browser,
- "any_signal",
- midori_view_notify_title_cb, browser,
- "any_signal",
- midori_view_notify_zoom_level_cb, browser,
- "any_signal",
- midori_view_notify_statusbar_text_cb, browser,
- "any_signal::attach-inspector",
- midori_view_attach_inspector_cb, browser,
- "any_signal::detach-inspector",
- midori_view_detach_inspector_cb, browser,
- "any_signal::new-tab",
- midori_view_new_tab_cb, browser,
- "any_signal::new-window",
- midori_view_new_window_cb, browser,
- "any_signal::new-view",
- midori_view_new_view_cb, browser,
- "any_signal::download-requested::after",
- midori_view_download_requested_cb, browser,
- "any_signal::search-text",
- midori_view_search_text_cb, browser,
- "any_signal::leave-notify-event",
- midori_browser_tab_leave_notify_event_cb, browser,
- NULL);
-}
-
-static void
-_midori_browser_add_tab (MidoriBrowser* browser,
- GtkWidget* view)
-{
- KatzeItem* item = midori_view_get_proxy_item (MIDORI_VIEW (view));
- guint n;
-
- midori_browser_connect_tab (browser, view);
-
- if (!katze_item_get_meta_boolean (item, "append") &&
- katze_object_get_boolean (browser->settings, "open-tabs-next-to-current"))
- {
- n = midori_browser_get_current_page (browser) + 1;
- katze_array_move_item (browser->proxy_array, item, n);
- }
- else
- n = -1;
- katze_item_set_meta_integer (item, "append", -1);
-
- midori_notebook_insert (MIDORI_NOTEBOOK (browser->notebook), MIDORI_TAB (view), n);
-
- _midori_browser_update_actions (browser);
-}
-
-static void
-_midori_browser_quit (MidoriBrowser* browser)
-{
- /* Nothing to do */
-}
-
-static void
-_update_tooltip_if_changed (GtkAction* action,
- const gchar* text)
-{
- gchar *old;
- g_object_get (action, "tooltip", &old, NULL);
- if (g_strcmp0(old, text)) {
- g_object_set (action,
- "tooltip", text, NULL);
- }
- g_free (old);
-}
-
-static void
-_update_reload_tooltip (GtkWidget* widget,
- GdkEventKey* event,
- gboolean released)
-{
- MidoriBrowser* browser = MIDORI_BROWSER (widget);
-
- /* Update the reload/stop tooltip in case we are holding the hard refresh modifiers*/
- GtkAction *reload_stop = _action_by_name (browser, "ReloadStop");
- GtkAction *reload = _action_by_name (browser, "Reload");
- GdkModifierType mask;
- gdk_window_get_pointer (gtk_widget_get_window (widget), NULL, NULL, &mask);
- const gchar *target;
-
- if ( mask & GDK_SHIFT_MASK)
- {
- target = _("Reload page without caching");
- }
- else
- {
- target = _("Reload the current page");
- }
- _update_tooltip_if_changed (reload_stop, target);
- _update_tooltip_if_changed (reload, target);
-}
-
-static gboolean
-midori_browser_key_release_event (GtkWidget* widget,
- GdkEventKey* event)
-{
- _update_reload_tooltip (widget, event, TRUE);
- return GTK_WIDGET_CLASS (midori_browser_parent_class)->key_release_event (widget, event);
-}
-
-static gboolean
-midori_browser_key_press_event (GtkWidget* widget,
- GdkEventKey* event)
-{
- GtkWindow* window = GTK_WINDOW (widget);
- MidoriBrowser* browser = MIDORI_BROWSER (widget);
- GtkWidgetClass* widget_class;
- guint clean_state;
-
- _update_reload_tooltip(widget, event, FALSE);
- /* Interpret Ctrl(+Shift)+Tab as tab switching for compatibility */
- if (midori_browser_get_nth_tab (browser, 1) != NULL
- && event->keyval == GDK_KEY_Tab
- && (event->state & GDK_CONTROL_MASK))
- {
- midori_browser_activate_action (browser, "TabNext");
- return TRUE;
- }
- else if (event->keyval == GDK_KEY_ISO_Left_Tab
- && (event->state & GDK_CONTROL_MASK)
- && (event->state & GDK_SHIFT_MASK))
- {
- midori_browser_activate_action (browser, "TabPrevious");
- return TRUE;
- }
- /* Interpret Ctrl+= as Zoom In for compatibility */
- else if ((event->keyval == GDK_KEY_KP_Equal || event->keyval == GDK_KEY_equal)
- && (event->state & GDK_CONTROL_MASK))
- {
- midori_browser_activate_action (browser, "ZoomIn");
- return TRUE;
- }
- /* Interpret F5 as reloading for compatibility */
- else if (event->keyval == GDK_KEY_F5)
- {
- midori_browser_activate_action (browser, "Reload");
- return TRUE;
- }
-
-#ifndef HAVE_WEBKIT2
- GtkWidget* focus = gtk_window_get_focus (GTK_WINDOW (widget));
- if (focus == NULL)
- gtk_widget_grab_focus (midori_browser_get_current_tab (MIDORI_BROWSER (widget)));
- else if (G_OBJECT_TYPE (focus) == WEBKIT_TYPE_WEB_VIEW
- && event->keyval == GDK_KEY_space
- && (!(event->state & GDK_SHIFT_MASK))
- && !webkit_web_view_can_cut_clipboard (WEBKIT_WEB_VIEW (focus))
- && !webkit_web_view_can_paste_clipboard (WEBKIT_WEB_VIEW (focus)))
- {
- /* Space at the bottom of the page: Go to next page */
- MidoriView* view = midori_view_get_for_widget (focus);
- GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (focus));
- GtkAdjustment* vadjust = gtk_scrolled_window_get_vadjustment (scrolled);
- if (gtk_adjustment_get_value (vadjust)
- == (gtk_adjustment_get_upper (vadjust) - gtk_adjustment_get_page_size (vadjust)))
- {
- /* Duplicate here because the URI pointer might change */
- gchar* uri = g_strdup (midori_view_get_next_page (view));
- if (uri != NULL)
- {
- midori_view_set_uri (view, uri);
- g_free (uri);
- return TRUE;
- }
- }
- }
-#endif
-
- if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
- if (sokoke_window_activate_key (window, event))
- return TRUE;
-
- clean_state = event->state & gtk_accelerator_get_default_mod_mask();
- if (!clean_state && gtk_window_propagate_key_event (window, event))
- return TRUE;
-
- if (!(event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
- if (sokoke_window_activate_key (window, event))
- return TRUE;
-
- if (event->state && gtk_window_propagate_key_event (window, event))
- return TRUE;
-
- /* Interpret (Shift+)Backspace as going back (forward) for compatibility */
- if ((event->keyval == GDK_KEY_BackSpace)
- && (event->state & GDK_SHIFT_MASK))
- {
- midori_browser_activate_action (browser, "Forward");
- return TRUE;
- }
- else if (event->keyval == GDK_KEY_BackSpace)
- {
- midori_browser_activate_action (browser, "Back");
- return TRUE;
- }
-
- widget_class = g_type_class_peek_static (g_type_parent (GTK_TYPE_WINDOW));
- return widget_class->key_press_event (widget, event);
-}
-
-static void
-midori_browser_class_init (MidoriBrowserClass* class)
-{
- GtkWidgetClass* gtkwidget_class;
- GObjectClass* gobject_class;
- GParamFlags flags;
-
- /**
- * MidoriBrowser::new-window:
- * @browser: the object on which the signal is emitted
- * @window: a new browser window, or %NULL
- *
- * Emitted when a new browser window was created.
- *
- * Note: Before 0.1.7 the second argument was an URI string.
- *
- * Note: Since 0.2.1 the return value is a #MidoriBrowser
- *
- * Return value: a new #MidoriBrowser
- */
- signals[NEW_WINDOW] = g_signal_new (
- "new-window",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST),
- G_STRUCT_OFFSET (MidoriBrowserClass, new_window),
- 0,
- NULL,
- midori_cclosure_marshal_OBJECT__OBJECT,
- MIDORI_TYPE_BROWSER, 1,
- MIDORI_TYPE_BROWSER);
-
- signals[ADD_TAB] = g_signal_new (
- "add-tab",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- G_STRUCT_OFFSET (MidoriBrowserClass, add_tab),
- 0,
- NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- GTK_TYPE_WIDGET);
-
- signals[REMOVE_TAB] = g_signal_new (
- "remove-tab",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- G_STRUCT_OFFSET (MidoriBrowserClass, remove_tab),
- 0,
- NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- GTK_TYPE_WIDGET);
-
- /**
- * MidoriBrowser::move-tab:
- * @browser: the object on which the signal is emitted
- * @notebook: the notebook containing the tabs
- * @cur_pos: the current position of the tab
- * @new_pos: the new position of the tab
- *
- * Emitted when a tab is moved.
- *
- * Since: 0.3.3
- */
- signals[MOVE_TAB] = g_signal_new (
- "move-tab",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- 0,
- NULL,
- midori_cclosure_marshal_VOID__OBJECT_INT_INT,
- G_TYPE_NONE, 3,
- GTK_TYPE_WIDGET, G_TYPE_INT, G_TYPE_INT);
-
- /**
- * MidoriBrowser::switch-tab:
- * @browser: the object on which the signal is emitted
- * @old_view: the previous tab
- * @new_view: the new tab
- *
- * Emitted when a tab is switched.
- * There's no guarantee what the current tab is.
- *
- * Since: 0.4.7
- */
- signals[SWITCH_TAB] = g_signal_new (
- "switch-tab",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- 0,
- NULL,
- midori_cclosure_marshal_VOID__OBJECT_OBJECT,
- G_TYPE_NONE, 2,
- G_TYPE_OBJECT, G_TYPE_OBJECT);
-
- signals[ACTIVATE_ACTION] = g_signal_new (
- "activate-action",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- G_STRUCT_OFFSET (MidoriBrowserClass, activate_action),
- 0,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
- /**
- * MidoriBrowser::add-download:
- * @browser: the object on which the signal is emitted
- * @download: a new download
- *
- * Emitted when a new download was accepted and is
- * about to start. Download UI should hook up here.
- *
- * Emitting this signal manually is equal to a
- * user initiating and confirming a download
- *
- * Note: This requires WebKitGTK+ 1.1.3.
- *
- * Since: 0.1.5
- */
- signals[ADD_DOWNLOAD] = g_signal_new (
- "add-download",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- G_TYPE_OBJECT);
-
- /**
- * MidoriBrowser::send-notification:
- * @browser: the object on which the signal is emitted
- * @title: the title for the notification
- * @message: the message for the notification
- *
- * Emitted when a browser wants to display a notification message,
- * e.g. when a download has been completed or a new tab was opened.
- *
- * Since: 0.1.7
- */
- signals[SEND_NOTIFICATION] = g_signal_new (
- "send-notification",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- midori_cclosure_marshal_VOID__STRING_STRING,
- G_TYPE_NONE, 2,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- /**
- * MidoriBrowser::populate-tool-menu:
- * @browser: the object on which the signal is emitted
- * @menu: the #GtkMenu to populate
- *
- * Emitted when a Tool menu is displayed, such as the
- * toplevel Tools in the menubar or the compact menu.
- *
- * Since: 0.1.9
- */
- signals[POPULATE_TOOL_MENU] = g_signal_new (
- "populate-tool-menu",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- GTK_TYPE_MENU);
- /**
- * MidoriBrowser::populate-toolbar-menu:
- * @browser: the object on which the signal is emitted
- * @menu: the #GtkMenu to populate
- *
- * Emitted when a toolbar menu is displayed on right-click.
- *
- * Since: 0.3.4
- */
- signals[POPULATE_TOOLBAR_MENU] = g_signal_new (
- "populate-toolbar-menu",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- GTK_TYPE_MENU);
-
- signals[QUIT] = g_signal_new (
- "quit",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- G_STRUCT_OFFSET (MidoriBrowserClass, quit),
- 0,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /**
- * MidoriBrowser::show-preferences:
- * @browser: the object on which the signal is emitted
- * @preferences: the #KatzePreferences to populate
- *
- * Emitted when a preference dialogue displayed, to allow
- * adding of a new page, to be used sparingly.
- *
- * Since: 0.3.4
- */
- signals[SHOW_PREFERENCES] = g_signal_new (
- "show-preferences",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- KATZE_TYPE_PREFERENCES);
-
- class->add_tab = _midori_browser_add_tab;
- class->remove_tab = _midori_browser_remove_tab;
- class->activate_action = _midori_browser_activate_action;
- class->quit = _midori_browser_quit;
-
- gtkwidget_class = GTK_WIDGET_CLASS (class);
- gtkwidget_class->key_press_event = midori_browser_key_press_event;
- gtkwidget_class->key_release_event = midori_browser_key_release_event;
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->dispose = midori_browser_dispose;
- gobject_class->finalize = midori_browser_finalize;
- gobject_class->set_property = midori_browser_set_property;
- gobject_class->get_property = midori_browser_get_property;
-
- flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS;
-
- g_object_class_install_property (gobject_class,
- PROP_MENUBAR,
- g_param_spec_object (
- "menubar",
- "Menubar",
- "The menubar",
- GTK_TYPE_MENU_BAR,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_NAVIGATIONBAR,
- g_param_spec_object (
- "navigationbar",
- "Navigationbar",
- "The navigationbar",
- GTK_TYPE_CONTAINER,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_NOTEBOOK,
- g_param_spec_object (
- "notebook",
- "Notebook",
- "The notebook containing the views",
- GTK_TYPE_CONTAINER,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_PANEL,
- g_param_spec_object (
- "panel",
- "Panel",
- "The side panel embedded in the browser",
- MIDORI_TYPE_PANEL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_URI,
- g_param_spec_string (
- "uri",
- "URI",
- "The current URI",
- "",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_TAB,
- g_param_spec_object (
- "tab",
- "Tab",
- "The current tab",
- GTK_TYPE_WIDGET,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_LOAD_STATUS,
- g_param_spec_enum (
- "load-status",
- "Load Status",
- "The current load status",
- MIDORI_TYPE_LOAD_STATUS,
- MIDORI_LOAD_FINISHED,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriBrowser:statusbar:
- *
- * The widget representing the statusbar contents. This is
- * not an actual #GtkStatusbar but rather a #GtkBox.
- */
- g_object_class_install_property (gobject_class,
- PROP_STATUSBAR,
- g_param_spec_object (
- "statusbar",
- "Statusbar",
- "The statusbar",
- GTK_TYPE_BOX,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriBrowser:statusbar-text:
- *
- * The text that is displayed in the statusbar.
- *
- * This value reflects changes to the text visible in the statusbar, such
- * as the uri of a hyperlink the mouse hovers over or the description of
- * a menuitem.
- *
- * Setting this value changes the displayed text until the next change.
- */
- g_object_class_install_property (gobject_class,
- PROP_STATUSBAR_TEXT,
- g_param_spec_string (
- "statusbar-text",
- "Statusbar Text",
- "The text that is displayed in the statusbar",
- "",
- flags));
-
- /**
- * MidoriBrowser:settings:
- *
- * An associated settings instance that is shared among all web views.
- *
- * Setting this value is propagated to every present web view. Also
- * every newly created web view will use this instance automatically.
- *
- * If no settings are specified a default will be used.
- */
- g_object_class_install_property (gobject_class,
- PROP_SETTINGS,
- g_param_spec_object (
- "settings",
- "Settings",
- "The associated settings",
- MIDORI_TYPE_WEB_SETTINGS,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriBrowser:proxy-items:
- *
- * The open views, automatically updated, for session management.
- *
- * Since: 0.4.8
- */
- g_object_class_install_property (gobject_class,
- PROP_PROXY_ITEMS,
- g_param_spec_object (
- "proxy-items",
- "Proxy Items",
- "The open tabs as an array",
- KATZE_TYPE_ARRAY,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriBrowser:bookmarks:
- *
- * The bookmarks folder, containing all bookmarks.
- *
- * This is actually a reference to a bookmarks instance,
- * so if bookmarks should be used it must be initially set.
- */
- g_object_class_install_property (gobject_class,
- PROP_BOOKMARKS,
- g_param_spec_object (
- "bookmarks",
- "Bookmarks",
- "The bookmarks folder, containing all bookmarks",
- TYPE_MIDORI_BOOKMARKS_DB,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriBrowser:trash:
- *
- * The trash, that collects all closed tabs and windows.
- *
- * This is actually a reference to a trash instance, so if a trash should
- * be used it must be initially set.
- *
- * Note: In the future the trash might collect other types of items.
- */
- g_object_class_install_property (gobject_class,
- PROP_TRASH,
- g_param_spec_object (
- "trash",
- "Trash",
- "The trash, collecting recently closed tabs and windows",
- KATZE_TYPE_ARRAY,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriBrowser:search-engines:
- *
- * The list of search engines to be used for web search.
- *
- * This is actually a reference to a search engines instance,
- * so if search engines should be used it must be initially set.
- */
- g_object_class_install_property (gobject_class,
- PROP_SEARCH_ENGINES,
- g_param_spec_object (
- "search-engines",
- "Search Engines",
- "The list of search engines to be used for web search",
- KATZE_TYPE_ARRAY,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriBrowser:history:
- *
- * The list of history items.
- *
- * This is actually a reference to a history instance,
- * so if history should be used it must be initially set.
- */
- g_object_class_install_property (gobject_class,
- PROP_HISTORY,
- g_param_spec_object (
- "history",
- "History",
- "The list of history items",
- KATZE_TYPE_ARRAY,
- flags));
-
- /**
- * MidoriBrowser:speed-dial:
- *
- * The speed dial configuration file.
- *
- * Since: 0.3.4
- * Since 0.4.7 this is a Midori.SpeedDial instance.
- */
- g_object_class_install_property (gobject_class,
- PROP_SPEED_DIAL,
- g_param_spec_object (
- "speed-dial",
- "Speeddial",
- "Speed dial",
- MIDORI_TYPE_SPEED_DIAL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriBrowser:show-tabs:
- *
- * Whether or not to show tabs.
- *
- * If disabled, no tab labels are shown. This is intended for
- * extensions that want to provide alternative tab labels.
- *
- * Since 0.1.8
- */
- g_object_class_install_property (gobject_class,
- PROP_SHOW_TABS,
- g_param_spec_boolean (
- "show-tabs",
- "Show Tabs",
- "Whether or not to show tabs",
- TRUE,
- flags));
-
- #if !GTK_CHECK_VERSION (3, 0, 0)
- /* Add 2px space between tool buttons */
- gtk_rc_parse_string (
- "style \"tool-button-style\"\n {\n"
- "GtkToolButton::icon-spacing = 2\n }\n"
- "widget \"MidoriBrowser.*.MidoriBookmarkbar.Gtk*ToolButton\" "
- "style \"tool-button-style\"\n"
- "widget \"MidoriBrowser.*.MidoriFindbar.Gtk*ToolButton\" "
- "style \"tool-button-style\"\n");
- #endif
-}
-
-static void
-_action_window_new_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- midori_view_new_window_cb (NULL, "about:home", browser);
-}
-
-static void
-_action_tab_new_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_add_uri (browser, "about:new");
- midori_browser_set_current_tab (browser, view);
-}
-
-static void
-_action_private_browsing_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- sokoke_spawn_app ("about:private", TRUE);
-}
-
-static void
-_action_open_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- #if !GTK_CHECK_VERSION (3, 1, 10)
- static gchar* last_dir = NULL;
- gboolean folder_set = FALSE;
- #endif
- gchar* uri = NULL;
- GtkWidget* dialog;
- GtkWidget* view;
-
- dialog = (GtkWidget*)midori_file_chooser_dialog_new (_("Open file"),
- GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_OPEN);
-
- /* base the start folder on the current view's uri if it is local */
- view = midori_browser_get_current_tab (browser);
- if ((uri = (gchar*)midori_view_get_display_uri (MIDORI_VIEW (view))))
- {
- gchar* filename = g_filename_from_uri (uri, NULL, NULL);
- if (filename)
- {
- gchar* dirname = g_path_get_dirname (filename);
- if (dirname && g_file_test (dirname, G_FILE_TEST_IS_DIR))
- {
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dirname);
- #if !GTK_CHECK_VERSION (3, 1, 10)
- folder_set = TRUE;
- #endif
- }
-
- g_free (dirname);
- g_free (filename);
- }
- }
-
- #if !GTK_CHECK_VERSION (3, 1, 10)
- if (!folder_set && last_dir && *last_dir)
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), last_dir);
- #endif
-
- if (midori_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
- {
- #if !GTK_CHECK_VERSION (3, 1, 10)
- gchar* folder;
- folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
- katze_assign (last_dir, folder);
- #endif
- uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
- midori_browser_set_current_uri (browser, uri);
- g_free (uri);
-
- }
- gtk_widget_destroy (dialog);
-}
-
-static void
-_action_save_as_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_get_current_tab (browser);
- midori_browser_save_uri (browser, MIDORI_VIEW (view), NULL);
-}
-
-static void
-_action_add_speed_dial_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- midori_browser_add_speed_dial (browser);
-}
-
-static void
-midori_browser_subscribe_to_news_feed (MidoriBrowser* browser,
- const gchar* uri)
-{
- const gchar* news_aggregator = midori_settings_get_news_aggregator (MIDORI_SETTINGS (browser->settings));
- if (news_aggregator && *news_aggregator)
- {
- /* Thunderbird only accepts feed://, Liferea doesn't mind */
- gchar* feed = g_strdup (uri);
- if (g_str_has_prefix (feed, "http://"))
- {
- feed[0] = 'f';
- feed[1] = 'e';
- feed[2] = 'e';
- feed[3] = 'd';
- }
- /* Special-case Liferea because a helper script may be required */
- if (g_str_equal (news_aggregator, "liferea")
- && g_find_program_in_path ("liferea-add-feed"))
- sokoke_spawn_program ("liferea-add-feed", FALSE, feed, TRUE, FALSE);
- else
- sokoke_spawn_program (news_aggregator, TRUE, feed, TRUE, FALSE);
- g_free (feed);
- }
- else
- {
- gchar* description = g_strdup_printf ("%s\n\n%s", uri,
- _("To use the above URI open a news aggregator. "
- "There is usually a menu or button \"New Subscription\", "
- "\"New News Feed\" or similar.\n"
- "Alternatively go to Preferences, Applications in Midori, "
- "and select a News Aggregator. Next time you click the "
- "news feed icon, it will be added automatically."));
- sokoke_message_dialog (GTK_MESSAGE_INFO, _("New feed"), description, FALSE);
- g_free (description);
- }
-}
-
-static void
-_action_add_news_feed_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* view;
- const gchar* uri;
-
- if (!(view = midori_browser_get_current_tab (browser)))
- return;
- if (!(uri = g_object_get_data (G_OBJECT (view), "news-feeds")))
- return;
-
- midori_browser_subscribe_to_news_feed (browser, uri);
-}
-
-static void
-_action_compact_add_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* dialog;
- GtkBox* box;
- const gchar* actions[] = { "BookmarkAdd", "AddSpeedDial", "AddNewsFeed" };
- guint i;
-
- dialog = g_object_new (GTK_TYPE_DIALOG,
- "transient-for", browser,
- "title", _("Add a new bookmark"), NULL);
- box = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog)));
-
- for (i = 0; i < G_N_ELEMENTS (actions); i++)
- {
- gchar* label;
- GtkWidget* button;
-
- action = _action_by_name (browser, actions[i]);
- label = katze_object_get_string (action, "label");
- button = gtk_button_new_with_mnemonic (label);
- g_free (label);
- gtk_widget_set_name (button, "GtkButton-thumb");
- gtk_box_pack_start (box, button, TRUE, TRUE, 4);
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
- g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy), dialog);
- }
-
- gtk_widget_show (dialog);
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), dialog);
-}
-
-static void
-_action_tab_close_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* widget = midori_browser_get_current_tab (browser);
- midori_browser_close_tab (browser, widget);
-}
-
-static void
-_action_window_close_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- gboolean val = FALSE;
- GdkEvent* event = gtk_get_current_event();
-
- /* if current event is null, the action was activated by --execute */
- if (!event)
- {
- event = gdk_event_new (GDK_CLIENT_EVENT);
- }
- g_signal_emit_by_name (G_OBJECT (browser), "delete-event", event, &val);
- gdk_event_free (event);
-
- if (!val)
- gtk_widget_destroy (GTK_WIDGET (browser));
-}
-
-static void
-_action_mail_to_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- MidoriView* view = MIDORI_VIEW (midori_browser_get_current_tab (browser));
- gchar* uri = g_uri_escape_string (midori_view_get_display_uri (view), NULL, TRUE);
- gchar* title = g_uri_escape_string (midori_view_get_display_title (view), NULL, TRUE);
- gchar* mailto = g_strconcat ("mailto:?cc=&bcc=&subject=", title, "&body=", uri, NULL);
- gboolean handled = FALSE;
- g_signal_emit_by_name (view, "open-uri", mailto, &handled);
- g_free (mailto);
- g_free (title);
- g_free (uri);
-}
-
-static void
-_action_print_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_get_current_tab (browser);
-
- midori_view_print (MIDORI_VIEW (view));
-}
-
-static void
-_action_quit_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- g_signal_emit (browser, signals[QUIT], 0);
-}
-
-static void
-_action_edit_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
- gboolean can_undo = FALSE, can_redo = FALSE;
- gboolean can_cut = FALSE, can_copy = FALSE, can_paste = FALSE;
- gboolean has_selection, can_select_all = FALSE;
-
- if (WEBKIT_IS_WEB_VIEW (widget))
- {
- midori_tab_update_actions (MIDORI_TAB (midori_browser_get_current_tab (browser)), browser->action_group, NULL, NULL);
- return;
- }
- else if (GTK_IS_EDITABLE (widget))
- {
- GtkEditable* editable = GTK_EDITABLE (widget);
- has_selection = gtk_editable_get_selection_bounds (editable, NULL, NULL);
- can_cut = has_selection && gtk_editable_get_editable (editable);
- can_copy = has_selection;
- can_paste = gtk_editable_get_editable (editable);
- can_select_all = TRUE;
- }
- else if (GTK_IS_TEXT_VIEW (widget))
- {
- GtkTextView* text_view = GTK_TEXT_VIEW (widget);
- GtkTextBuffer* buffer = gtk_text_view_get_buffer (text_view);
- has_selection = gtk_text_buffer_get_has_selection (buffer);
- can_cut = gtk_text_view_get_editable (text_view);
- can_copy = has_selection;
- can_paste = gtk_text_view_get_editable (text_view) && has_selection;
- can_select_all = TRUE;
- }
-
- _action_set_sensitive (browser, "Undo", can_undo);
- _action_set_sensitive (browser, "Redo", can_redo);
- _action_set_sensitive (browser, "Cut", can_cut);
- _action_set_sensitive (browser, "Copy", can_copy);
- _action_set_sensitive (browser, "Paste", can_paste);
- _action_set_sensitive (browser, "Delete", can_cut);
- _action_set_sensitive (browser, "SelectAll", can_select_all);
-}
-
-static void
-_action_undo_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
- if (WEBKIT_IS_WEB_VIEW (widget))
-#ifdef HAVE_WEBKIT2
- webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_UNDO);
-#else
- webkit_web_view_undo (WEBKIT_WEB_VIEW (widget));
-#endif
-}
-
-static void
-_action_redo_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
- if (WEBKIT_IS_WEB_VIEW (widget))
-#ifdef HAVE_WEBKIT2
- webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_REDO);
-#else
- webkit_web_view_redo (WEBKIT_WEB_VIEW (widget));
-#endif
-}
-
-static void
-_action_cut_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
- if (G_LIKELY (widget) && g_signal_lookup ("cut-clipboard", G_OBJECT_TYPE (widget)))
- g_signal_emit_by_name (widget, "cut-clipboard");
-#ifdef HAVE_WEBKIT2
- else if (WEBKIT_IS_WEB_VIEW (widget))
- webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_CUT);
-#endif
-}
-
-static void
-_action_copy_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
- if (G_LIKELY (widget) && g_signal_lookup ("copy-clipboard", G_OBJECT_TYPE (widget)))
- g_signal_emit_by_name (widget, "copy-clipboard");
-#ifdef HAVE_WEBKIT2
- else if (WEBKIT_IS_WEB_VIEW (widget))
- webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_COPY);
-#endif
-}
-
-static void
-_action_paste_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
- if (G_LIKELY (widget) && g_signal_lookup ("paste-clipboard", G_OBJECT_TYPE (widget)))
- g_signal_emit_by_name (widget, "paste-clipboard");
-#ifdef HAVE_WEBKIT2
- else if (WEBKIT_IS_WEB_VIEW (widget))
- webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_PASTE);
-#endif
-}
-
-static void
-_action_delete_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
- if (G_LIKELY (widget))
- {
- if (GTK_IS_EDITABLE (widget))
- gtk_editable_delete_selection (GTK_EDITABLE (widget));
-#ifndef HAVE_WEBKIT2
- else if (WEBKIT_IS_WEB_VIEW (widget))
- webkit_web_view_delete_selection (WEBKIT_WEB_VIEW (widget));
-#endif
- else if (GTK_IS_TEXT_VIEW (widget))
- gtk_text_buffer_delete_selection (
- gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)), TRUE, FALSE);
- }
-}
-
-static void
-_action_select_all_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
- if (G_LIKELY (widget))
- {
- if (GTK_IS_EDITABLE (widget))
- gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
-#ifdef HAVE_WEBKIT2
- else if (WEBKIT_IS_WEB_VIEW (widget))
- webkit_web_view_execute_editing_command (WEBKIT_WEB_VIEW (widget), WEBKIT_EDITING_COMMAND_SELECT_ALL);
-#endif
- else if (g_signal_lookup ("select-all", G_OBJECT_TYPE (widget)))
- {
- if (GTK_IS_TEXT_VIEW (widget))
- g_signal_emit_by_name (widget, "select-all", TRUE);
- else if (GTK_IS_TREE_VIEW (widget))
- {
- gboolean dummy;
- g_signal_emit_by_name (widget, "select-all", &dummy);
- }
- else
- g_signal_emit_by_name (widget, "select-all");
- }
- }
-}
-
-static void
-_action_find_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_get_current_tab (browser);
- midori_findbar_invoke (MIDORI_FINDBAR (browser->find),
- midori_view_get_selected_text (MIDORI_VIEW (view)));
-}
-
-static void
-_action_find_next_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- midori_findbar_continue (MIDORI_FINDBAR (browser->find), TRUE);
-}
-
-static void
-_action_find_previous_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- midori_findbar_continue (MIDORI_FINDBAR (browser->find), FALSE);
-}
-
-/**
- * midori_browser_get_toolbar_actions:
- *
- * Retrieves a list of actions which are suitable for use in a toolbar.
- *
- * Return value: (array zero-terminated=1) (transfer none): a NULL-terminated array of strings with actions
- *
- * Since: 0.1.8
- **/
-const gchar**
-midori_browser_get_toolbar_actions (MidoriBrowser* browser)
-{
- static const gchar* actions[] = {
- "WindowNew", "TabNew", "Open", "SaveAs", "Print", "Find",
- "Fullscreen", "Preferences", "Window", "Bookmarks",
- "ReloadStop", "ZoomIn", "TabClose", "NextForward", "Location",
- "ZoomOut", "Separator", "Back", "Forward", "Homepage",
- "Panel", "Trash", "Search", "BookmarkAdd", "Previous", "Next", NULL };
-
- return actions;
-}
-
-/**
- * midori_browser_get_settings:
- *
- * Retrieves the settings instance of the browser.
- *
- * Return value: a #MidoriWebSettings instance
- *
- * Since: 0.2.5
- **/
-MidoriWebSettings*
-midori_browser_get_settings (MidoriBrowser* browser)
-{
- g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
-
- return browser->settings;
-}
-
-static gboolean
-midori_browser_toolbar_popup_context_menu_cb (GtkWidget* widget,
- gint x,
- gint y,
- gint button,
- MidoriBrowser* browser)
-{
- MidoriContextAction* menu = midori_context_action_new ("ToolbarContextMenu", NULL, NULL, NULL);
- midori_context_action_add_action_group (menu, browser->action_group);
- midori_context_action_add_by_name (menu, "Menubar");
- if (GTK_IS_TOOLBAR (browser->navigationbar))
- midori_context_action_add_by_name (menu, "Navigationbar");
- midori_context_action_add_by_name (menu, "Bookmarkbar");
- midori_context_action_add_by_name (menu, "Statusbar");
-
- GtkMenu* context_menu = midori_context_action_create_menu (menu, NULL, FALSE);
- g_signal_emit (browser, signals[POPULATE_TOOLBAR_MENU], 0, context_menu);
- katze_widget_popup (widget, GTK_MENU (context_menu), NULL,
- button == -1 ? KATZE_MENU_POSITION_LEFT : KATZE_MENU_POSITION_CURSOR);
- return TRUE;
-}
-
-static void
-midori_browser_bookmark_popup (GtkWidget* proxy,
- GdkEventButton* event,
- KatzeItem* item,
- MidoriBrowser* browser);
-
-static void
-midori_bookmarkbar_activate_item (GtkAction* action,
- KatzeItem* item,
- MidoriBrowser* browser)
-{
- midori_browser_open_bookmark (browser, item);
-}
-
-static void
-midori_bookmarkbar_activate_item_new_tab (GtkAction* action,
- KatzeItem* item,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_add_item (browser, item);
- midori_browser_set_current_tab_smartly (browser, view);
-}
-
-static gboolean
-midori_bookmarkbar_activate_item_alt (GtkAction* action,
- KatzeItem* item,
- GtkWidget* proxy,
- GdkEventButton* event,
- MidoriBrowser* browser)
-{
- g_assert (event);
-
- if (MIDORI_EVENT_CONTEXT_MENU (event))
- {
- midori_browser_bookmark_popup (proxy, NULL, item, browser);
- }
-
- return TRUE;
-}
-
-static void
-_action_trash_populate_popup (GtkAction* action,
- GtkMenu* menu,
- MidoriBrowser* browser)
-{
- GtkWidget* menuitem;
-
- menuitem = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- gtk_widget_show (menuitem);
- menuitem = gtk_action_create_menu_item (
- _action_by_name (browser, "TrashEmpty"));
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- gtk_widget_show (menuitem);
-}
-
-static GtkWidget*
-midori_browser_restore_tab (MidoriBrowser* browser,
- KatzeItem* item)
-{
- GtkWidget* view;
- g_object_ref (item);
- katze_array_remove_item (browser->trash, item);
- view = midori_browser_add_item (browser, item);
- midori_browser_view_copy_from_item_history (view,item);
-
- g_object_unref (item);
- return view;
-}
-
-static void
-_action_trash_activate_item (GtkAction* action,
- KatzeItem* item,
- MidoriBrowser* browser)
-{
- midori_browser_set_current_tab (browser,
- midori_browser_restore_tab (browser, item));
-}
-
-static void
-_action_trash_activate_item_new_tab (GtkAction* action,
- KatzeItem* item,
- MidoriBrowser* browser)
-{
- midori_browser_set_current_tab_smartly (browser,
- midori_browser_restore_tab (browser, item));
-}
-
-/* static */ gboolean
-midori_browser_open_bookmark (MidoriBrowser* browser,
- KatzeItem* item)
-{
- const gchar* uri = katze_item_get_uri (item);
- gchar* uri_fixed;
-
- if (!(uri && *uri))
- return FALSE;
-
- /* Imported bookmarks may lack a protocol */
- uri_fixed = sokoke_magic_uri (uri, TRUE, FALSE);
- if (!uri_fixed)
- uri_fixed = g_strdup (uri);
-
- if (katze_item_get_meta_boolean (item, "app"))
- sokoke_spawn_app (uri_fixed, FALSE);
- else
- {
- midori_browser_set_current_uri (browser, uri_fixed);
- gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
- }
- g_free (uri_fixed);
- return TRUE;
-}
-
-static void
-_action_tools_populate_popup (GtkAction* action,
- GtkMenu* default_menu,
- MidoriBrowser* browser)
-{
- MidoriContextAction* menu = midori_context_action_new ("ToolsMenu", NULL, NULL, NULL);
- midori_context_action_add_action_group (menu, browser->action_group);
- midori_context_action_add_by_name (menu, "ManageSearchEngines");
- midori_context_action_add_by_name (menu, "ClearPrivateData");
- midori_context_action_add_by_name (menu, "InspectPage");
- g_signal_emit (browser, signals[POPULATE_TOOL_MENU], 0, default_menu);
- midori_context_action_add (menu, NULL);
- gsize j = 0;
- GtkWidget* widget;
- while ((widget = midori_panel_get_nth_page (MIDORI_PANEL (browser->panel), j++)))
- midori_context_action_add (menu, g_object_get_data (G_OBJECT (widget), "midori-panel-action"));
- #ifdef G_OS_WIN32
- midori_context_action_add (menu, NULL);
- midori_context_action_add_by_name (menu, "Preferences");
- #endif
- midori_context_action_create_menu (menu, default_menu, TRUE);
-}
-
-static gboolean
-_action_bookmarks_populate_folder (GtkAction* action,
- GtkMenuShell* menu,
- KatzeArray* folder,
- MidoriBrowser* browser)
-{
- if (browser->bookmarks == NULL)
- return FALSE;
-
- midori_bookmarks_db_populate_folder (browser->bookmarks, folder);
-
- /* Clear items from dummy array here */
- gtk_container_foreach (GTK_CONTAINER (menu),
- (GtkCallback)(gtk_widget_destroy), NULL);
-
- /* "Add Bookmark", "Import Bookmarks", and "Export Bookmarks" at the top */
- if (folder == KATZE_ARRAY (browser->bookmarks))
- {
- GtkWidget* menuitem;
- menuitem = gtk_action_create_menu_item (_action_by_name (browser, "BookmarkAdd"));
- gtk_menu_shell_append (menu, menuitem);
- gtk_widget_show (menuitem);
- menuitem = gtk_action_create_menu_item (_action_by_name (browser, "BookmarksImport"));
- gtk_menu_shell_append (menu, menuitem);
- gtk_widget_show (menuitem);
- menuitem = gtk_action_create_menu_item (_action_by_name (browser, "BookmarksExport"));
- gtk_menu_shell_append (menu, menuitem);
- gtk_widget_show (menuitem);
- menuitem = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (menu, menuitem);
- gtk_widget_show (menuitem);
- }
-
- if (katze_array_is_empty (folder))
- {
- GtkWidget* menuitem = gtk_image_menu_item_new_with_label (_("Empty"));
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_menu_shell_append (menu, menuitem);
- gtk_widget_show (menuitem);
- return TRUE;
- }
-
- katze_array_action_generate_menu (KATZE_ARRAY_ACTION (action), folder,
- menu, GTK_WIDGET (browser));
- return TRUE;
-}
-
-static void
-_action_window_populate_popup (GtkAction* action,
- GtkMenu* default_menu,
- MidoriBrowser* browser)
-{
- MidoriContextAction* menu = midori_context_action_new ("WindowMenu", NULL, NULL, NULL);
- midori_context_action_add_action_group (menu, browser->action_group);
- midori_context_action_add (menu, NULL);
- midori_context_action_add_by_name (menu, "LastSession");
- midori_context_action_add_by_name (menu, "TabCurrent");
- midori_context_action_add_by_name (menu, "NextView");
- midori_context_action_add_by_name (menu, "TabNext");
- midori_context_action_add_by_name (menu, "TabPrevious");
- midori_context_action_create_menu (menu, default_menu, TRUE);
-}
-
-static void
-_action_window_activate_item (GtkAction* action,
- KatzeItem* item,
- MidoriBrowser* browser)
-{
- midori_browser_set_current_item (browser, item);
-}
-
-static void
-_action_compact_menu_populate_popup (GtkAction* action,
- GtkMenu* default_menu,
- MidoriBrowser* browser)
-{
- MidoriContextAction* menu = midori_context_action_new ("CompactMenu", NULL, NULL, NULL);
- midori_context_action_add_action_group (menu, browser->action_group);
- midori_context_action_add_by_name (menu, "WindowNew");
- midori_context_action_add_by_name (menu, "PrivateBrowsing");
- midori_context_action_add (menu, NULL);
- midori_context_action_add_by_name (menu, "Find");
- midori_context_action_add_by_name (menu, "Print");
- midori_context_action_add_by_name (menu, "Fullscreen");
- midori_context_action_add_by_name (menu, "MailTo");
- midori_context_action_add (menu, NULL);
- gsize j = 0;
- GtkWidget* widget;
- while ((widget = midori_panel_get_nth_page (MIDORI_PANEL (browser->panel), j++)))
- midori_context_action_add (menu, g_object_get_data (G_OBJECT (widget), "midori-panel-action"));
- midori_context_action_add (menu, NULL);
- midori_context_action_add_by_name (menu, "BookmarkAdd");
- midori_context_action_add_by_name (menu, "BookmarksImport");
- midori_context_action_add_by_name (menu, "BookmarksExport");
- midori_context_action_add_by_name (menu, "ClearPrivateData");
- g_signal_emit (browser, signals[POPULATE_TOOL_MENU], 0, default_menu);
- midori_context_action_add (menu, NULL);
- #ifndef HAVE_GRANITE
- midori_context_action_add_by_name (menu, "HelpFAQ");
- midori_context_action_add_by_name (menu, "HelpBugs");
- #endif
- midori_context_action_add_by_name (menu, "Preferences");
- midori_context_action_add_by_name (menu, "About");
- midori_context_action_create_menu (menu, default_menu, FALSE);
-}
-
-static void
-midori_preferences_response_help_cb (GtkWidget* preferences,
- gint response,
- MidoriBrowser* browser)
-{
- if (response == GTK_RESPONSE_HELP)
- midori_browser_activate_action (browser, "HelpFAQ");
-}
-
-static void
-_action_preferences_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- static GtkWidget* dialog = NULL;
-
- if (!dialog)
- {
- dialog = midori_preferences_new (GTK_WINDOW (browser), browser->settings);
- g_signal_emit (browser, signals[SHOW_PREFERENCES], 0, dialog);
- g_signal_connect (dialog, "response",
- G_CALLBACK (midori_preferences_response_help_cb), browser);
- g_signal_connect (dialog, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &dialog);
- gtk_widget_show (dialog);
- }
- else
- gtk_window_present (GTK_WINDOW (dialog));
-}
-
-static gboolean
-midori_browser_has_native_menubar (MidoriBrowser* browser)
-{
- static const gchar* ubuntu_menuproxy = NULL;
- if (ubuntu_menuproxy == NULL)
- ubuntu_menuproxy = g_getenv ("UBUNTU_MENUPROXY");
- /*
- * Values when the global menu is enabled
- * UBUNTU_MENUPROXY=libappmenu.so
- * UBUNTU_MENUPROXY=1
- * The official way to disable the menu is
- * UBUNTU_MENUPROXY=
- */
- return ubuntu_menuproxy && (strstr (ubuntu_menuproxy, ".so") || !strcmp (ubuntu_menuproxy, "1"));
-}
-
-static void
-_action_menubar_activate (GtkToggleAction* menubar_action,
- MidoriBrowser* browser)
-{
- gboolean active = gtk_toggle_action_get_active (menubar_action);
-
- if (midori_browser_has_native_menubar (browser))
- active = FALSE;
- midori_window_set_show_menubar (MIDORI_WINDOW (browser), active);
- if (katze_object_get_boolean (browser->settings, "show-menubar") != active)
- g_object_set (browser->settings, "show-menubar", active, NULL);
-
- sokoke_widget_set_visible (browser->menubar, active);
- g_object_set_data (G_OBJECT (browser), "midori-toolbars-visible",
- gtk_widget_get_visible (browser->menubar)
- || gtk_widget_get_visible (browser->navigationbar)
- ? (void*)0xdeadbeef : NULL);
-}
-
-static void
-_action_navigationbar_activate (GtkToggleAction* action,
- MidoriBrowser* browser)
-{
- gboolean active = gtk_toggle_action_get_active (action);
- g_object_set (browser->settings, "show-navigationbar", active, NULL);
- sokoke_widget_set_visible (browser->navigationbar, active);
-
- g_object_set_data (G_OBJECT (browser), "midori-toolbars-visible",
- gtk_widget_get_visible (browser->menubar)
- || gtk_widget_get_visible (browser->navigationbar)
- ? (void*)0xdeadbeef : NULL);
-}
-
-static void
-_action_bookmarkbar_activate (GtkToggleAction* action,
- MidoriBrowser* browser)
-{
- gboolean active = gtk_toggle_action_get_active (action);
- g_object_set (browser->settings, "show-bookmarkbar", active, NULL);
- sokoke_widget_set_visible (browser->bookmarkbar, active);
-}
-
-static void
-_action_statusbar_activate (GtkToggleAction* action,
- MidoriBrowser* browser)
-{
- gboolean active = gtk_toggle_action_get_active (action);
- g_object_set (browser->settings, "show-statusbar", active, NULL);
- sokoke_widget_set_visible (browser->statusbar, active);
-}
-
-static void
-_action_reload_stop_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_get_current_tab (browser);
- gchar* stock_id;
- g_object_get (action, "stock-id", &stock_id, NULL);
-
- /* Refresh or stop, depending on the stock id */
- if (!strcmp (stock_id, GTK_STOCK_REFRESH))
- {
- GdkModifierType state = (GdkModifierType)0;
- gint x, y;
- GdkWindow* window;
- gboolean from_cache = TRUE;
-
- if (!strcmp (gtk_action_get_name (action), "ReloadUncached"))
- from_cache = FALSE;
- else if ((window = gtk_widget_get_window (GTK_WIDGET (browser))))
- {
- gdk_window_get_pointer (window, &x, &y, &state);
- if (state & GDK_SHIFT_MASK)
- from_cache = FALSE;
- }
- midori_view_reload (MIDORI_VIEW (view), from_cache);
- }
- else
- midori_tab_stop_loading (MIDORI_TAB (view));
- g_free (stock_id);
-}
-
-static void
-_action_zoom_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_get_current_tab (browser);
-
- if (g_str_equal (gtk_action_get_name (action), "ZoomIn"))
- midori_view_set_zoom_level (MIDORI_VIEW (view),
- midori_view_get_zoom_level (MIDORI_VIEW (view)) + 0.10f);
- else if (g_str_equal (gtk_action_get_name (action), "ZoomOut"))
- midori_view_set_zoom_level (MIDORI_VIEW (view),
- midori_view_get_zoom_level (MIDORI_VIEW (view)) - 0.10f);
- else
- midori_view_set_zoom_level (MIDORI_VIEW (view), 1.0f);
-}
-
-static void
-_action_view_encoding_activate (GtkAction* action,
- GtkAction* current,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_get_current_tab (browser);
- const gchar* name = gtk_action_get_name (current);
- WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
-
- const gchar* encoding;
- if (!strcmp (name, "EncodingAutomatic"))
- encoding = NULL;
- else if (!strcmp (name, "EncodingChinese"))
- encoding = "BIG5";
- else if (!strcmp (name, "EncodingChineseSimplified"))
- encoding = "GB18030";
- else if (!strcmp (name, "EncodingJapanese"))
- encoding = "SHIFT_JIS";
- else if (!strcmp (name, "EncodingKorean"))
- encoding = "EUC-KR";
- else if (!strcmp (name, "EncodingRussian"))
- encoding = "KOI8-R";
- else if (!strcmp (name, "EncodingUnicode"))
- encoding = "UTF-8";
- else if (!strcmp (name, "EncodingWestern"))
- encoding = "ISO-8859-1";
- else
- g_assert_not_reached ();
- #ifdef HAVE_WEBKIT2
- webkit_web_view_set_custom_charset (web_view, encoding);
- #else
- webkit_web_view_set_custom_encoding (web_view, encoding);
- #endif
-}
-
-static void
-_action_source_view (GtkAction* action,
- MidoriBrowser* browser,
- gboolean use_dom)
-{
- #ifdef HAVE_WEBKIT2
- /* TODO: midori_view_save_source isn't async and not WebKit2-friendly */
- #else
- GtkWidget* view = midori_browser_get_current_tab (browser);
- gchar* filename = midori_view_save_source (MIDORI_VIEW (view), NULL, NULL, use_dom);
- gchar* text_editor;
- GAppInfo* info;
- g_object_get (browser->settings, "text-editor", &text_editor, NULL);
- if (text_editor && *text_editor)
- info = g_app_info_create_from_commandline (text_editor, NULL, 0, NULL);
- else
- info = g_app_info_get_default_for_type ("text/plain", FALSE);
- GFile* file = g_file_new_for_path (filename);
- GList* files = g_list_append (NULL, file);
- GError* error = NULL;
- GdkDisplay* display = gtk_widget_get_display (view);
- #if GTK_CHECK_VERSION (3, 0, 0)
- GdkAppLaunchContext* ctx = gdk_display_get_app_launch_context (display);
- #else
- GdkAppLaunchContext* ctx = gdk_app_launch_context_new ();
- gdk_app_launch_context_set_display (ctx, display);
- #endif
- if (!g_app_info_launch (info, files, G_APP_LAUNCH_CONTEXT (ctx), &error))
- {
- g_printerr ("Failed to open editor: %s", error->message);
- g_error_free (error);
- }
- g_object_unref (info);
- g_list_free (files);
- g_object_unref (file);
- g_free (filename);
- g_free (text_editor);
- #endif
-}
-
-static void
-_action_source_view_activate (GtkAction* action,
-MidoriBrowser* browser)
-{
- _action_source_view (action, browser, FALSE);
-}
-
-static void
-_action_source_view_dom_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- _action_source_view (action, browser, TRUE);
-}
-
-
-static void
-_action_caret_browsing_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- gint response;
- GtkWidget* dialog;
-
- if (!katze_object_get_boolean (browser->settings, "enable-caret-browsing"))
- {
- dialog = gtk_message_dialog_new (GTK_WINDOW (browser),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
- _("Toggle text cursor navigation"));
- gtk_window_set_title (GTK_WINDOW (dialog), _("Toggle text cursor navigation"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("Pressing F7 toggles Caret Browsing. When active, a text cursor appears in all websites."));
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- _("_Enable Caret Browsing"), GTK_RESPONSE_ACCEPT,
- NULL);
-
- response = midori_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- if (response != GTK_RESPONSE_ACCEPT)
- return;
- }
-
- g_object_set (browser->settings, "enable-caret-browsing",
- !katze_object_get_boolean (browser->settings, "enable-caret-browsing"), NULL);
-}
-
-static void
-_action_fullscreen_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GdkWindowState state;
-
- if (!gtk_widget_get_window (GTK_WIDGET (browser)))
- return;
-
- state = gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET (browser)));
- if (state & GDK_WINDOW_STATE_FULLSCREEN)
- {
- if (katze_object_get_boolean (G_OBJECT (browser->settings), "show-menubar"))
- gtk_widget_show (browser->menubar);
-
- if (katze_object_get_boolean (G_OBJECT (browser->settings), "show-panel"))
- gtk_widget_show (browser->panel);
-
- if (katze_object_get_boolean (G_OBJECT (browser->settings), "show-bookmarkbar"))
- gtk_widget_show (browser->bookmarkbar);
-
- if (browser->show_navigationbar)
- gtk_widget_show (browser->navigationbar);
-
- if (browser->show_statusbar)
- gtk_widget_show (browser->statusbar);
- _toggle_tabbar_smartly (browser, TRUE);
-
- gtk_window_unfullscreen (GTK_WINDOW (browser));
- }
- else
- {
- gtk_widget_hide (browser->menubar);
- gtk_widget_hide (browser->panel);
- gtk_widget_hide (browser->bookmarkbar);
- gtk_widget_hide (browser->navigationbar);
- gtk_widget_hide (browser->statusbar);
- midori_notebook_set_labels_visible (MIDORI_NOTEBOOK (browser->notebook), FALSE);
-
- gtk_window_fullscreen (GTK_WINDOW (browser));
- }
-}
-
-static void
-_action_scroll_somewhere_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
-#ifndef HAVE_WEBKIT2
- GtkWidget* view = midori_browser_get_current_tab (browser);
- WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
- const gchar* name = gtk_action_get_name (action);
-
- if (g_str_equal (name, "ScrollLeft"))
- webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_VISUAL_POSITIONS, -1);
- else if (g_str_equal (name, "ScrollDown"))
- webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_DISPLAY_LINES, 1);
- else if (g_str_equal (name, "ScrollUp"))
- webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_DISPLAY_LINES, -1);
- else if (g_str_equal (name, "ScrollRight"))
- webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_VISUAL_POSITIONS, 1);
-#endif
-}
-
-static void
-_action_readable_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_get_current_tab (browser);
- gchar* filename;
- gchar* stylesheet;
- gint i;
-
- filename = midori_paths_get_res_filename ("faq.css");
- stylesheet = NULL;
- if (!g_file_get_contents (filename, &stylesheet, NULL, NULL))
- {
- #ifdef G_OS_WIN32
- katze_assign (filename, midori_paths_get_data_filename ("doc/midori/faq.css", FALSE));
- #else
- katze_assign (filename, g_build_filename (DOCDIR, "faq.css", NULL));
- #endif
- g_file_get_contents (filename, &stylesheet, NULL, NULL);
- }
- if (!(stylesheet && *stylesheet))
- {
- g_free (filename);
- g_free (stylesheet);
- midori_view_add_info_bar (MIDORI_VIEW (view), GTK_MESSAGE_ERROR,
- "Stylesheet faq.css not found", NULL, view,
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
- return;
- }
-
- i = 0;
- while (stylesheet[i])
- {
- /* Replace line breaks with spaces */
- if (stylesheet[i] == '\n' || stylesheet[i] == '\r')
- stylesheet[i] = ' ';
- /* Change all single quotes to double quotes */
- else if (stylesheet[i] == '\'')
- stylesheet[i] = '\"';
- i++;
- }
-
- midori_tab_inject_stylesheet (MIDORI_TAB (view), stylesheet);
- g_free (stylesheet);
-}
-
-static gboolean
-_action_navigation_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- MidoriView* view;
- GtkWidget* tab;
- gchar* uri;
- const gchar* name;
- gboolean middle_click;
-
- g_assert (GTK_IS_ACTION (action));
-
- if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action),
- "midori-middle-click")))
- {
- middle_click = TRUE;
- g_object_set_data (G_OBJECT (action),
- "midori-middle-click",
- GINT_TO_POINTER(0));
- }
- else
- middle_click = FALSE;
-
- tab = midori_browser_get_current_tab (browser);
- view = MIDORI_VIEW (tab);
- name = gtk_action_get_name (action);
-
- if (!strcmp (name, "NextForward"))
- name = midori_tab_can_go_forward (MIDORI_TAB (view)) ? "Forward" : "Next";
-
- if (g_str_equal (name, "Back"))
- {
- if (middle_click)
- {
- WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view));
- #ifdef HAVE_WEBKIT2
- WebKitBackForwardList* list = webkit_web_view_get_back_forward_list (web_view);
- WebKitBackForwardListItem* item = webkit_back_forward_list_get_back_item (list);
- const gchar* back_uri = webkit_back_forward_list_item_get_uri (item);
- #else
- WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list (web_view);
- WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_forward_item (list);
- const gchar* back_uri = webkit_web_history_item_get_uri (item);
- #endif
-
- GtkWidget* new_view = midori_browser_add_uri (browser, back_uri);
- midori_browser_set_current_tab_smartly (browser, new_view);
- }
- else
- midori_view_go_back (view);
-
- return TRUE;
- }
- else if (g_str_equal (name, "Forward"))
- {
- if (middle_click)
- {
- WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view));
- #ifdef HAVE_WEBKIT2
- WebKitBackForwardList* list = webkit_web_view_get_back_forward_list (web_view);
- WebKitBackForwardListItem* item = webkit_back_forward_list_get_forward_item (list);
- const gchar* forward_uri = webkit_back_forward_list_item_get_uri (item);
- #else
- WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list (web_view);
- WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_forward_item (list);
- const gchar* forward_uri = webkit_web_history_item_get_uri (item);
- #endif
-
- GtkWidget* new_view = midori_browser_add_uri (browser, forward_uri);
- midori_browser_set_current_tab_smartly (browser, new_view);
- }
- else
- midori_tab_go_forward (MIDORI_TAB (view));
-
- return TRUE;
- }
- else if (g_str_equal (name, "Previous"))
- {
- /* Duplicate here because the URI pointer might change */
- uri = g_strdup (midori_view_get_previous_page (view));
-
- if (middle_click)
- {
- GtkWidget* new_view = midori_browser_add_uri (browser, uri);
- midori_browser_set_current_tab_smartly (browser, new_view);
- }
- else
- midori_view_set_uri (view, uri);
-
- g_free (uri);
- return TRUE;
- }
- else if (g_str_equal (name, "Next"))
- {
- /* Duplicate here because the URI pointer might change */
- uri = g_strdup (midori_view_get_next_page (view));
-
- if (middle_click)
- {
- GtkWidget* new_view = midori_browser_add_uri (browser, uri);
- midori_browser_set_current_tab_smartly (browser, new_view);
- }
- else
- midori_view_set_uri (view, uri);
-
- g_free (uri);
- return TRUE;
- }
- else if (g_str_equal (name, "Homepage"))
- {
- if (middle_click)
- {
- GtkWidget* new_view = midori_browser_add_uri (browser, "about:home");
- midori_browser_set_current_tab_smartly (browser, new_view);
- }
- else
- midori_view_set_uri (view, "about:home");
-
- return TRUE;
- }
- return FALSE;
-}
-
-static void
-_action_location_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- if (!gtk_widget_get_visible (browser->navigationbar))
- gtk_widget_show (browser->navigationbar);
-}
-
-static void
-_action_location_focus_in (GtkAction* action,
- MidoriBrowser* browser)
-{
- GdkScreen* screen = gtk_widget_get_screen (browser->notebook);
- GtkIconTheme* icon_theme = gtk_icon_theme_get_for_screen (screen);
- if (gtk_icon_theme_has_icon (icon_theme, "go-jump-symbolic"))
- midori_location_action_set_secondary_icon (
- MIDORI_LOCATION_ACTION (action), "go-jump-symbolic");
- else
- midori_location_action_set_secondary_icon (
- MIDORI_LOCATION_ACTION (action), GTK_STOCK_JUMP_TO);
-}
-
-static void
-_action_location_focus_out (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_get_current_tab (browser);
-
- if (!browser->show_navigationbar || midori_browser_is_fullscreen (browser))
- gtk_widget_hide (browser->navigationbar);
-
- midori_browser_update_secondary_icon (browser, MIDORI_VIEW (view), action);
-}
-
-static void
-_action_location_reset_uri (GtkAction* action,
- MidoriBrowser* browser)
-{
- midori_location_action_set_text (MIDORI_LOCATION_ACTION (action),
- midori_browser_get_current_uri (browser));
-}
-
-#ifndef HAVE_WEBKIT2
-static void
-midori_browser_item_icon_loaded_cb (WebKitFaviconDatabase* database,
- const gchar* frame_uri,
- KatzeItem* item)
-{
- gchar* uri = g_object_get_data (G_OBJECT (item), "browser-queue-icon");
- if (strcmp (frame_uri, uri))
- return;
-
- gchar* icon_uri = webkit_favicon_database_get_favicon_uri (
- webkit_get_favicon_database (), frame_uri);
- if (icon_uri != NULL)
- {
- g_free (icon_uri);
- katze_item_set_icon (item, frame_uri);
- /* This signal fires extremely often (WebKit bug?)
- we must throttle it (disconnect) once we have an icon */
- g_signal_handlers_disconnect_by_func (webkit_get_favicon_database (),
- midori_browser_item_icon_loaded_cb, item);
- }
-}
-#endif
-
-static void
-midori_browser_queue_item_for_icon (KatzeItem* item,
- const gchar* uri)
-{
-#ifndef HAVE_WEBKIT2
- if (katze_item_get_icon (item) != NULL)
- return;
- g_object_set_data_full (G_OBJECT (item), "browser-queue-icon", g_strdup (uri), g_free);
- g_signal_connect (webkit_get_favicon_database (), "icon-loaded",
- G_CALLBACK (midori_browser_item_icon_loaded_cb), item);
-#endif
-}
-
-static void
-_action_location_submit_uri (GtkAction* action,
- const gchar* uri,
- gboolean new_tab,
- MidoriBrowser* browser)
-{
- gchar* new_uri;
-
- /* Switch to already open tab if possible */
- KatzeItem* found = katze_array_find_uri (browser->proxy_array, uri);
- if (found != NULL && !new_tab
- && !g_str_equal (midori_browser_get_current_uri (browser), uri))
- {
- GtkWidget* view = midori_browser_get_current_tab (browser);
- midori_browser_set_current_item (browser, found);
- if (midori_view_is_blank (MIDORI_VIEW (view)))
- midori_browser_close_tab (browser, view);
- return;
- }
-
- uri = katze_skip_whitespace (uri);
- new_uri = sokoke_magic_uri (uri, TRUE, FALSE);
- if (!new_uri)
- {
- const gchar* keywords = NULL;
- const gchar* search_uri = NULL;
- KatzeItem* item;
-
- /* Do we have a keyword and a string? */
- if (browser->search_engines
- && (item = katze_array_find_token (browser->search_engines, uri)))
- {
- keywords = strchr (uri, ' ');
- if (keywords != NULL)
- keywords++;
- else
- keywords = "";
- search_uri = katze_item_get_uri (item);
- }
-
- if (keywords == NULL)
- {
- keywords = uri;
- search_uri = midori_settings_get_location_entry_search (
- MIDORI_SETTINGS (browser->settings));
- }
- new_uri = midori_uri_for_search (search_uri, keywords);
-
- if (browser->search_engines && item != NULL)
- midori_browser_queue_item_for_icon (item, new_uri);
-
- if (browser->history != NULL)
- {
- time_t now = time (NULL);
- gint64 day = sokoke_time_t_to_julian (&now);
- sqlite3* db = g_object_get_data (G_OBJECT (browser->history), "db");
- static sqlite3_stmt* statement = NULL;
-
- if (!statement)
- {
- const gchar* sqlcmd;
- sqlcmd = "INSERT INTO search (keywords, uri, day) VALUES (?,?,?)";
- sqlite3_prepare_v2 (db, sqlcmd, strlen (sqlcmd) + 1, &statement, NULL);
- }
- sqlite3_bind_text (statement, 1, keywords, -1, 0);
- sqlite3_bind_text (statement, 2, search_uri, -1, 0);
- sqlite3_bind_int64 (statement, 3, day);
-
- if (sqlite3_step (statement) != SQLITE_DONE)
- g_printerr (_("Failed to insert new history item: %s\n"),
- sqlite3_errmsg (db));
- sqlite3_reset (statement);
- if (sqlite3_step (statement) == SQLITE_DONE)
- sqlite3_clear_bindings (statement);
- }
- }
-
- if (new_tab)
- {
- GtkWidget* view = midori_browser_add_uri (browser, new_uri);
- midori_browser_set_current_tab (browser, view);
- }
- else
- midori_browser_set_current_uri (browser, new_uri);
- g_free (new_uri);
- gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
-}
-
-static void
-midori_browser_news_feed_clicked_cb (GtkWidget* menuitem,
- MidoriBrowser* browser)
-{
- gchar* uri = g_object_get_data (G_OBJECT (menuitem), "uri");
- midori_browser_subscribe_to_news_feed (browser, uri);
-}
-
-static void
-_action_paste_proceed_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkClipboard* clipboard = gtk_clipboard_get_for_display (
- gtk_widget_get_display (GTK_WIDGET (browser)),GDK_SELECTION_CLIPBOARD);
- gchar* uri = gtk_clipboard_wait_for_text (clipboard);
- if (uri != NULL)
- {
- _action_location_submit_uri (action, uri, FALSE, browser);
- g_free (uri);
- }
-}
-
-static gboolean
-_action_location_secondary_icon_released (GtkAction* action,
- GtkWidget* widget,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_get_current_tab (browser);
- const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view));
- const gchar* feed;
- /* Clicking icon on blank is equal to Paste and Proceed */
- if (midori_view_is_blank (MIDORI_VIEW (view)))
- _action_paste_proceed_activate (action, browser);
- else if (gtk_window_get_focus (GTK_WINDOW (browser)) == widget)
- {
- const gchar* text = gtk_entry_get_text (GTK_ENTRY (widget));
- _action_location_submit_uri (action, text, FALSE, browser);
- }
- else if ((feed = g_object_get_data (G_OBJECT (view), "news-feeds")))
- {
- KatzeArray* news_feeds;
- KatzeItem* item;
- KatzeItem* itemm;
-
- news_feeds = katze_object_get_object (G_OBJECT (view), "news-feeds");
- item = katze_array_get_nth_item (news_feeds, 0);
- if ((itemm = katze_array_get_nth_item (news_feeds, 1)))
- {
- guint i;
- GtkWidget* menu;
- GtkWidget* menuitem;
-
- menu = gtk_menu_new ();
- menuitem = gtk_menu_item_new_with_label (katze_item_get_name (item));
- g_object_set_data_full (G_OBJECT (menuitem), "uri",
- g_strdup (katze_item_get_uri (item)), (GDestroyNotify)g_free);
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (midori_browser_news_feed_clicked_cb), browser);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- menuitem = gtk_menu_item_new_with_label (katze_item_get_name (itemm));
- g_object_set_data_full (G_OBJECT (menuitem), "uri",
- g_strdup (katze_item_get_uri (itemm)), (GDestroyNotify)g_free);
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (midori_browser_news_feed_clicked_cb), browser);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- i = 2;
- while ((itemm = katze_array_get_nth_item (news_feeds, i++)))
- {
- menuitem = gtk_menu_item_new_with_label (
- katze_item_get_name (itemm));
- g_object_set_data_full (G_OBJECT (menuitem), "uri",
- g_strdup (katze_item_get_uri (itemm)), (GDestroyNotify)g_free);
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (midori_browser_news_feed_clicked_cb), browser);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- }
- gtk_container_foreach (GTK_CONTAINER (menu),
- (GtkCallback)(gtk_widget_show_all), NULL);
- katze_widget_popup (widget, GTK_MENU (menu), NULL,
- KATZE_MENU_POSITION_RIGHT);
- }
- else
- midori_browser_subscribe_to_news_feed (browser, feed);
- g_object_unref (news_feeds);
- }
- else
- _action_location_submit_uri (action, uri, FALSE, browser);
- return TRUE;
-}
-
-static void
-_action_search_submit (GtkAction* action,
- const gchar* keywords,
- gboolean new_tab,
- MidoriBrowser* browser)
-{
- KatzeItem* item;
- const gchar* url;
- gchar* search;
-
- item = katze_array_get_nth_item (browser->search_engines, browser->last_web_search);
- if (item)
- url = katze_item_get_uri (item);
- else /* The location entry search is our fallback */
- url = midori_settings_get_location_entry_search (MIDORI_SETTINGS (browser->settings));
-
- search = midori_uri_for_search (url, keywords);
- if (item != NULL)
- midori_browser_queue_item_for_icon (item, search);
-
- if (new_tab)
- {
- GtkWidget* view = midori_browser_add_uri (browser, search);
- midori_browser_set_current_tab_smartly (browser, view);
- }
- else
- midori_browser_set_current_uri (browser, search);
-
- g_free (search);
-}
-
-static void
-_action_search_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GSList* proxies = gtk_action_get_proxies (action);
- for (; proxies != NULL; proxies = g_slist_next (proxies))
- if (GTK_IS_TOOL_ITEM (proxies->data))
- {
- if (!gtk_widget_get_visible (browser->navigationbar))
- gtk_widget_show (browser->navigationbar);
- return;
- }
-
- midori_browser_set_current_uri (browser, "about:search");
- gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
-}
-
-static void
-_action_search_notify_current_item (GtkAction* action,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- MidoriSearchAction* search_action;
- KatzeItem* item;
- guint idx;
-
- search_action = MIDORI_SEARCH_ACTION (action);
- item = midori_search_action_get_current_item (search_action);
- if (item)
- idx = katze_array_get_item_index (browser->search_engines, item);
- else
- idx = 0;
-
- g_object_set (browser->settings, "last-web-search", idx, NULL);
- browser->last_web_search = idx;
-}
-
-static void
-_action_search_notify_default_item (GtkAction* action,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- MidoriSearchAction* search_action;
- KatzeItem* item;
-
- search_action = MIDORI_SEARCH_ACTION (action);
- item = midori_search_action_get_default_item (search_action);
- if (item)
- g_object_set (browser->settings, "location-entry-search",
- katze_item_get_uri (item), NULL);
-}
-
-static void
-_action_search_focus_out (GtkAction* action,
- MidoriBrowser* browser)
-{
- if ((gtk_widget_get_visible (browser->statusbar)
- && !browser->show_navigationbar)
- || midori_browser_is_fullscreen (browser))
- {
- gtk_widget_hide (browser->navigationbar);
- }
-}
-
-static void
-midori_browser_bookmark_open_activate_cb (GtkWidget* menuitem,
- MidoriBrowser* browser)
-{
- KatzeItem* item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
- midori_browser_open_bookmark (browser, item);
-}
-
-static void
-midori_browser_bookmark_open_in_tab_activate_cb (GtkWidget* menuitem,
- MidoriBrowser* browser)
-{
- KatzeItem* item;
- const gchar* uri;
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
- if (KATZE_IS_ARRAY (item))
- {
- KatzeItem* child;
- KatzeArray* array;
-
- array = midori_bookmarks_db_query_recursive (browser->bookmarks,
- "*", "parentid = %q", katze_item_get_meta_string (item, "id"), FALSE);
-
- KATZE_ARRAY_FOREACH_ITEM (child, KATZE_ARRAY (array))
- {
- if ((uri = katze_item_get_uri (child)) && *uri)
- {
- GtkWidget* view = midori_browser_add_item (browser, child);
- midori_browser_set_current_tab_smartly (browser, view);
- }
- }
- g_object_unref (G_OBJECT (array));
- }
- else
- {
- if ((uri = katze_item_get_uri (item)) && *uri)
- {
- GtkWidget* view = midori_browser_add_item (browser, item);
- midori_browser_set_current_tab_smartly (browser, view);
- }
- }
-}
-
-static void
-midori_browser_bookmark_open_in_window_activate_cb (GtkWidget* menuitem,
- MidoriBrowser* browser)
-{
- KatzeItem* item;
- const gchar* uri;
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
- uri = katze_item_get_uri (item);
- midori_view_new_window_cb (NULL, uri, browser);
-}
-
-static void
-midori_browser_bookmark_edit_activate_cb (GtkWidget* menuitem,
- GtkWidget* widget)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (widget);
- KatzeItem* item = g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
-
- if (KATZE_ITEM_IS_BOOKMARK (item))
- midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, FALSE, widget);
- else
- midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, TRUE, widget);
-}
-
-static void
-midori_browser_bookmark_delete_activate_cb (GtkWidget* menuitem,
- MidoriBrowser* browser)
-{
- KatzeItem* item;
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
- midori_bookmarks_db_remove_item (browser->bookmarks, item);
-}
-
-static gboolean
-midori_browser_toolbar_context_menu_cb (GtkWidget* toolbar,
- GtkWidget* widget,
- GtkAction* action,
- MidoriBrowser* browser)
-{
- const gchar* name = action ? gtk_action_get_name (action) : "";
- gboolean back = !g_strcmp0 (name, "Back");
- if (back
- || g_str_has_suffix (name, "Forward"))
- {
- midori_browser_toolbar_popup_context_menu_history (
- browser,
- widget,
- back, 0, 0);
- return TRUE;
- }
- return midori_browser_toolbar_popup_context_menu_cb (widget, 0, 0, 0, browser);
-}
-
-static void
-midori_browser_bookmark_popup (GtkWidget* widget,
- GdkEventButton* event,
- KatzeItem* item,
- MidoriBrowser* browser)
-{
- MidoriContextAction* menu = midori_context_action_new ("BookmarkContextMenu", NULL, NULL, NULL);
- if (KATZE_ITEM_IS_FOLDER (item))
- {
- gint child_bookmarks_count = midori_bookmarks_db_count_recursive (browser->bookmarks,
- "uri <> ''", NULL, item, FALSE);
-
- GtkAction* action = gtk_action_new ("BookmarkOpenAllTabs", _("Open all in _Tabs"), NULL, STOCK_TAB_NEW);
- gtk_action_set_sensitive (action, child_bookmarks_count > 0);
- g_object_set_data (G_OBJECT (action), "KatzeItem", item);
- g_signal_connect (action, "activate",
- G_CALLBACK (midori_browser_bookmark_open_in_tab_activate_cb), browser);
- midori_context_action_add (menu, action);
- }
- else
- {
- GtkAction* action = gtk_action_new ("BookmarkOpen", NULL, NULL, GTK_STOCK_OPEN);
- gtk_action_set_sensitive (action, katze_item_get_uri (item) != NULL);
- g_object_set_data (G_OBJECT (action), "KatzeItem", item);
- g_signal_connect (action, "activate",
- G_CALLBACK (midori_browser_bookmark_open_activate_cb), browser);
- midori_context_action_add (menu, action);
- action = gtk_action_new ("BookmarkOpenTab", NULL, NULL, STOCK_TAB_NEW);
- gtk_action_set_sensitive (action, katze_item_get_uri (item) != NULL);
- g_object_set_data (G_OBJECT (action), "KatzeItem", item);
- g_signal_connect (action, "activate",
- G_CALLBACK (midori_browser_bookmark_open_in_tab_activate_cb), browser);
- midori_context_action_add (menu, action);
- action = gtk_action_new ("BookmarkOpenWindow", _("Open in New _Window"), NULL, STOCK_WINDOW_NEW);
- gtk_action_set_sensitive (action, katze_item_get_uri (item) != NULL);
- g_object_set_data (G_OBJECT (action), "KatzeItem", item);
- g_signal_connect (action, "activate",
- G_CALLBACK (midori_browser_bookmark_open_in_window_activate_cb), browser);
- midori_context_action_add (menu, action);
- }
-
- midori_context_action_add (menu, NULL);
- GtkAction* action = gtk_action_new ("BookmarkEdit", NULL, NULL, GTK_STOCK_EDIT);
- gtk_action_set_sensitive (action, !KATZE_ITEM_IS_SEPARATOR (item));
- g_object_set_data (G_OBJECT (action), "KatzeItem", item);
- g_signal_connect (action, "activate",
- G_CALLBACK (midori_browser_bookmark_edit_activate_cb), browser);
- midori_context_action_add (menu, action);
- action = gtk_action_new ("BookmarkDelete", NULL, NULL, GTK_STOCK_DELETE);
- g_object_set_data (G_OBJECT (action), "KatzeItem", item);
- g_signal_connect (action, "activate",
- G_CALLBACK (midori_browser_bookmark_delete_activate_cb), browser);
- midori_context_action_add (menu, action);
-
- GtkMenu* context_menu = midori_context_action_create_menu (menu, NULL, FALSE);
- katze_widget_popup (widget, context_menu, event, KATZE_MENU_POSITION_CURSOR);
-}
-
-static gboolean
-midori_browser_menu_button_press_event_cb (GtkWidget* toolitem,
- GdkEventButton* event,
- MidoriBrowser* browser)
-{
- if (event->button != 3)
- return FALSE;
-
- /* GtkMenuBar catches button events on children with submenus,
- so we need to see if the actual widget is the menubar, and if
- it is an item, we forward it to the actual widget. */
- if ((GTK_IS_BOX (toolitem) || GTK_IS_MENU_BAR (toolitem)))
- {
- if (gtk_widget_get_window (toolitem) != event->window)
- return FALSE;
-
- midori_browser_toolbar_popup_context_menu_cb (
- GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ?
- gtk_widget_get_parent (toolitem) : toolitem,
- event->x, event->y, event->button, browser);
- return TRUE;
- }
- else if (GTK_IS_MENU_ITEM (toolitem))
- {
- gboolean handled;
- g_signal_emit_by_name (toolitem, "button-press-event", event, &handled);
- return handled;
- }
- return FALSE;
-}
-
-static gboolean
-midori_browser_menu_item_middle_click_event_cb (GtkWidget* toolitem,
- GdkEventButton* event,
- MidoriBrowser* browser)
-{
- if (MIDORI_EVENT_NEW_TAB (event))
- {
- GtkAction* action;
-
- action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (toolitem));
- g_object_set_data (G_OBJECT (action), "midori-middle-click", GINT_TO_POINTER (1));
-
- return _action_navigation_activate (action, browser);
- }
- return FALSE;
-}
-
-static void
-_action_bookmark_add_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* proxy = NULL;
- GSList* proxies = gtk_action_get_proxies (action);
- for (; proxies != NULL; proxies = g_slist_next (proxies))
- if (GTK_IS_TOOL_ITEM (proxies->data))
- {
- proxy = proxies->data;
- break;
- }
-
- if (g_str_equal (gtk_action_get_name (action), "BookmarkFolderAdd"))
- midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, TRUE, proxy);
- else
- midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE, proxy);
-}
-
-static void
-_action_bookmarks_import_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- typedef struct
- {
- const gchar* path;
- const gchar* name;
- const gchar* icon;
- } BookmarkClient;
- static const BookmarkClient bookmark_clients[] = {
-#ifdef G_OS_WIN32
- { "Opera/Opera/bookmarks.adr", N_("Opera 12.x"), "opera" },
- { "Mozilla/Firefox/Profiles/*/bookmarks.html", N_("Firefox (%s)"), "firefox" },
-#else
- { ".local/share/data/Arora/bookmarks.xbel", N_("Arora"), "arora" },
- { ".kazehakase/bookmarks.xml", N_("Kazehakase"), "kazehakase-icon" },
- { ".opera/bookmarks.adr", N_("Opera 12.x"), "opera" },
- { ".kde/share/apps/konqueror/bookmarks.xml", N_("Konqueror"), "konqueror" },
- { ".gnome2/epiphany/bookmarks.rdf", N_("Epiphany"), "epiphany" },
- { ".mozilla/firefox/*/bookmarks.html", N_("Firefox (%s)"), "firefox" },
- { ".config/midori/bookmarks.xbel", N_("Midori 0.2.6"), "midori" },
-#endif
- };
-
- GtkWidget* dialog;
- GtkWidget* content_area;
- GtkSizeGroup* sizegroup;
- GtkWidget* hbox;
- GtkWidget* label;
- GtkWidget* combo;
- GtkComboBox* combobox;
- GtkListStore* model;
- GtkCellRenderer* renderer;
- GtkWidget* combobox_folder;
- gint icon_width = 16;
- guint i;
- KatzeArray* bookmarks;
-
- dialog = gtk_dialog_new_with_buttons (
- _("Import bookmarks…"), GTK_WINDOW (browser),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- _("_Import bookmarks"), GTK_RESPONSE_ACCEPT,
- NULL);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_window_set_icon_name (GTK_WINDOW (dialog), STOCK_BOOKMARKS);
-
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_container_set_border_width (GTK_CONTAINER (content_area), 5);
- sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
- hbox = gtk_hbox_new (FALSE, 8);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
- label = gtk_label_new_with_mnemonic (_("_Application:"));
- gtk_size_group_add_widget (sizegroup, label);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- model = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_INT);
- combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model));
- renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "icon-name", 1);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "width", 3);
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "text", 0);
- combobox = GTK_COMBO_BOX (combo);
- gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (browser)),
- GTK_ICON_SIZE_MENU, &icon_width, NULL);
- for (i = 0; i < G_N_ELEMENTS (bookmark_clients); i++)
- {
- const gchar* location = bookmark_clients[i].path;
- const gchar* client = bookmark_clients[i].name;
-#ifdef G_OS_WIN32
- const gchar* home_dir = sokoke_get_win32_appdata_dir();
-#else
- const gchar* home_dir = g_get_home_dir();
-#endif
- gchar* path = NULL;
-
- /* Interpret * as 'any folder' */
- if (strchr (location, '*') != NULL)
- {
- gchar** parts = g_strsplit (location, "*", 2);
- GDir* dir;
- path = g_build_filename (home_dir, parts[0], NULL);
- if ((dir = g_dir_open (path, 0, NULL)))
- {
- const gchar* name;
- while ((name = g_dir_read_name (dir)))
- {
- gchar* file = g_build_filename (path, name, parts[1], NULL);
- if (g_file_test (file, G_FILE_TEST_EXISTS))
- {
- /* If name is XYZ.Name, we use Name only */
- gchar* real_name = strchr (name, '.');
- gchar* display = strstr (_(client), "%s")
- ? g_strdup_printf (_(client),
- real_name ? real_name + 1 : name)
- : g_strdup (_(client));
- gtk_list_store_insert_with_values (model, NULL, G_MAXINT,
- 0, display, 1, bookmark_clients[i].icon,
- 2, file, 3, icon_width, -1);
- g_free (display);
- }
- g_free (file);
- }
- g_dir_close (dir);
- }
- g_free (path);
- g_strfreev (parts);
- continue;
- }
-
- path = g_build_filename (home_dir, location, NULL);
- if (g_file_test (path, G_FILE_TEST_EXISTS))
- gtk_list_store_insert_with_values (model, NULL, G_MAXINT,
- 0, _(client), 1, bookmark_clients[i].icon,
- 2, path, 3, icon_width, -1);
- g_free (path);
- }
-
- gtk_list_store_insert_with_values (model, NULL, G_MAXINT,
- 0, _("Import from XBEL or HTML file"), 1, NULL, 2, NULL, 3, icon_width, -1);
- gtk_combo_box_set_active (combobox, 0);
- gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, TRUE, 0);
-
- combobox_folder = midori_bookmark_folder_button_new (browser->bookmarks, 0);
- gtk_box_pack_start (GTK_BOX (content_area), combobox_folder, FALSE, TRUE, 0);
- gtk_widget_show_all (content_area);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
- if (midori_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
- {
- GtkTreeIter iter;
- gchar* path = NULL;
- gint64 selected;
- GError* error;
-
- if (gtk_combo_box_get_active_iter (combobox, &iter))
- gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, 2, &path, -1);
- selected = midori_bookmark_folder_button_get_active (combobox_folder);
-
- gtk_widget_destroy (dialog);
- if (!path)
- {
- GtkWidget* file_dialog;
-
- file_dialog = (GtkWidget*)midori_file_chooser_dialog_new (_("Import from a file"),
- GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_OPEN);
- if (midori_dialog_run (GTK_DIALOG (file_dialog)) == GTK_RESPONSE_OK)
- path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_dialog));
- gtk_widget_destroy (file_dialog);
- }
-
- error = NULL;
- bookmarks = katze_array_new (KATZE_TYPE_ARRAY);
- if (path && !midori_array_from_file (bookmarks, path, NULL, &error))
- {
- sokoke_message_dialog (GTK_MESSAGE_ERROR,
- _("Failed to import bookmarks"),
- error ? error->message : "", FALSE);
- if (error)
- g_error_free (error);
- }
- midori_bookmarks_db_import_array (browser->bookmarks, bookmarks, selected);
- g_object_unref (bookmarks);
- g_free (path);
- }
- else
- gtk_widget_destroy (dialog);
-}
-
-static void
-_action_bookmarks_export_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* file_dialog;
- GtkFileFilter* filter;
- const gchar* format;
- gchar* path = NULL;
- GError* error;
- KatzeArray* bookmarks;
-
-wrong_format:
- file_dialog = (GtkWidget*)midori_file_chooser_dialog_new (_("Save file as"),
- GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);
- gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (file_dialog),
- "bookmarks.xbel");
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("XBEL Bookmarks"));
- gtk_file_filter_add_mime_type (filter, "application/xml");
- gtk_file_filter_add_pattern (filter, "*.xbel");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), filter);
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("Netscape Bookmarks"));
- gtk_file_filter_add_mime_type (filter, "text/html");
- gtk_file_filter_add_pattern (filter, "*.html");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), filter);
- if (midori_dialog_run (GTK_DIALOG (file_dialog)) == GTK_RESPONSE_OK)
- path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_dialog));
- gtk_widget_destroy (file_dialog);
-
- if (path == NULL)
- return;
-
- if (g_str_has_suffix (path, ".xbel"))
- format = "xbel";
- else if (g_str_has_suffix (path, ".html"))
- format = "netscape";
- else
- {
- sokoke_message_dialog (GTK_MESSAGE_ERROR,
- _("Midori can only export to XBEL (*.xbel) and Netscape (*.html)"),
- "", TRUE);
- katze_assign (path, NULL);
- goto wrong_format;
- }
-
- error = NULL;
- bookmarks = midori_bookmarks_db_query_recursive (browser->bookmarks,
- "*", "parentid IS NULL", NULL, TRUE);
- if (!midori_array_to_file (bookmarks, path, format, &error))
- {
- sokoke_message_dialog (GTK_MESSAGE_ERROR,
- _("Failed to export bookmarks"), error ? error->message : "", FALSE);
- if (error)
- g_error_free (error);
- }
- g_object_unref (bookmarks);
- g_free (path);
-}
-
-static void
-_action_manage_search_engines_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- static GtkWidget* dialog = NULL;
-
- if (!dialog)
- {
- dialog = midori_search_action_get_dialog (
- MIDORI_SEARCH_ACTION (_action_by_name (browser, "Search")));
- g_signal_connect (dialog, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &dialog);
- gtk_widget_show (dialog);
- }
- else
- gtk_window_present (GTK_WINDOW (dialog));
-}
-
-static void
-_action_clear_private_data_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- static GtkWidget* dialog = NULL;
-
- if (!dialog)
- {
- dialog = midori_private_data_get_dialog (browser);
- g_signal_connect (dialog, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &dialog);
- gtk_widget_show (dialog);
- }
- else
- gtk_window_present (GTK_WINDOW (dialog));
-}
-
-static void
-_action_inspect_page_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_get_current_tab (browser);
- WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
- WebKitWebInspector* inspector = webkit_web_view_get_inspector (web_view);
- webkit_web_inspector_show (inspector);
-}
-
-static void
-_action_tab_move_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- const gchar* name = gtk_action_get_name (action);
- gint new_pos;
- gint cur_pos = midori_browser_get_current_page (browser);
- GtkWidget* widget = midori_browser_get_nth_tab (browser, cur_pos);
-
- if (!strcmp (name, "TabMoveFirst"))
- new_pos = 0;
- else if (!strcmp (name, "TabMoveBackward"))
- {
- if (cur_pos > 0)
- new_pos = cur_pos - 1;
- else
- new_pos = midori_browser_get_n_pages (browser) - 1;
- }
- else if (!strcmp (name, "TabMoveForward"))
- {
- if (cur_pos == (midori_browser_get_n_pages (browser) - 1))
- new_pos = 0;
- else
- new_pos = cur_pos + 1;
- }
- else if (!strcmp (name, "TabMoveLast"))
- new_pos = midori_browser_get_n_pages (browser) - 1;
- else
- g_assert_not_reached ();
-
- midori_notebook_move (MIDORI_NOTEBOOK (browser->notebook), MIDORI_TAB (widget), new_pos);
- g_signal_emit (browser, signals[MOVE_TAB], 0, browser->notebook, cur_pos, new_pos);
-}
-
-static void
-_action_tab_previous_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- gint n = midori_browser_get_current_page (browser);
- midori_browser_set_current_page (browser, n - 1);
-}
-
-static void
-_action_tab_next_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- /* Advance one tab or jump to the first one if we are at the last one */
- gint n = midori_browser_get_current_page (browser);
- if (n == midori_browser_get_n_pages (browser) - 1)
- n = -1;
- midori_browser_set_current_page (browser, n + 1);
-}
-
-static void
-_action_tab_current_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_get_current_tab (browser);
- gtk_widget_grab_focus (view);
-}
-
-static void
-_action_next_view_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
-}
-
-static void
-_action_tab_minimize_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_get_current_tab (browser);
- g_object_set (view, "minimized",
- !katze_object_get_boolean (view, "minimized"), NULL);
-}
-
-static void
-_action_tab_duplicate_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* view = g_object_get_data (G_OBJECT (action), "tab");
- if (view == NULL)
- view = midori_browser_get_current_tab (browser);
- midori_view_duplicate (MIDORI_VIEW (view));
-}
-
-static void
-_action_tab_close_other_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_get_current_tab (browser);
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs; tabs = g_list_next (tabs))
- {
- if (tabs->data != view)
- midori_browser_close_tab (browser, tabs->data);
- }
- g_list_free (tabs);
-}
-
-static const gchar* credits_authors[] =
- { "Christian Dywan <christian@twotoasts.de>", NULL };
-static const gchar* credits_documenters[] =
- { "Christian Dywan <christian@twotoasts.de>", NULL };
-static const gchar* credits_artists[] =
- { "Nancy Runge <nancy@twotoasts.de>", NULL };
-
-static gchar*
-midori_browser_get_docs (gboolean error)
-{
- #ifdef G_OS_WIN32
- gchar* path = midori_paths_get_data_filename ("doc/midori/faq.html", FALSE);
- gchar* uri = g_filename_to_uri (path, NULL, NULL);
- g_free (path);
- return uri;
- #else
- gchar* path = midori_paths_get_res_filename ("faq.html");
- gboolean found = g_file_test (path, G_FILE_TEST_EXISTS);
- if (found)
- {
- gchar* uri = g_filename_to_uri (path, NULL, NULL);
- g_free (path);
- return uri;
- }
- g_free (path);
- return g_strdup ("file://" DOCDIR "/faq.html");
- #endif
-}
-
-static void
-_action_about_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- gchar* comments = g_strdup_printf ("%s\n%s",
- _("A lightweight web browser."),
- _("See about:version for version info."));
- const gchar* license =
- _("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.");
-
-#ifdef HAVE_GRANITE
- gchar* docs = midori_browser_get_docs (FALSE);
- /* Avoid granite_widgets_show_about_dialog for invalid memory and crashes */
- /* FIXME: granite: should return GtkWidget* like GTK+ */
- GtkWidget* dialog = (GtkWidget*)granite_widgets_about_dialog_new ();
- g_object_set (dialog,
- "translate", "https://translations.launchpad.net/midori",
- "bug", PACKAGE_BUGREPORT,
- "help", docs,
- "copyright", "2007-2015 Christian Dywan",
-#else
- GtkWidget* dialog = gtk_about_dialog_new ();
- g_object_set (dialog,
- "wrap-license", TRUE,
- "copyright", "Copyright © 2007-2015 Christian Dywan",
-#endif
- "transient-for", browser,
- "logo-icon-name", gtk_window_get_icon_name (GTK_WINDOW (browser)),
- "program-name", PACKAGE_NAME,
- "version", PACKAGE_VERSION,
- "comments", comments,
- "website", "http://www.midori-browser.org",
- "authors", credits_authors,
- "documenters", credits_documenters,
- "artists", credits_artists,
- "license", license,
- "translator-credits", _("translator-credits"),
- NULL);
- g_free (comments);
- #ifdef HAVE_GRANITE
- g_free (docs);
- #endif
- gtk_widget_show (dialog);
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), dialog);
-}
-
-static void
-_action_help_link_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- const gchar* action_name = gtk_action_get_name (action);
- gchar* uri = NULL;
- if (!strncmp ("HelpFAQ", action_name, 7))
- uri = midori_browser_get_docs (TRUE);
- else if (!strncmp ("HelpBugs", action_name, 8))
- {
- if (!g_spawn_command_line_async ("ubuntu-bug " PACKAGE_NAME, NULL))
- uri = g_strdup (PACKAGE_BUGREPORT);
- }
-
- if (uri)
- {
- GtkWidget* view = midori_browser_add_uri (browser, uri);
- midori_browser_set_current_tab (browser, view);
- g_free (uri);
- }
-}
-
-static void
-_action_panel_activate (GtkToggleAction* action,
- MidoriBrowser* browser)
-{
- gboolean active = gtk_toggle_action_get_active (action);
- g_object_set (browser->settings, "show-panel", active, NULL);
- sokoke_widget_set_visible (browser->panel, active);
-}
-
-static gboolean
-midori_browser_panel_timeout (GtkWidget* hpaned)
-{
- gint position = gtk_paned_get_position (GTK_PANED (hpaned));
- MidoriBrowser* browser = midori_browser_get_for_widget (hpaned);
- g_object_set (browser->settings, "last-panel-position", position, NULL);
- browser->panel_timeout = 0;
- return FALSE;
-}
-
-static void
-midori_panel_notify_position_cb (GObject* hpaned,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- if (!browser->panel_timeout)
- browser->panel_timeout = midori_timeout_add_seconds (5,
- (GSourceFunc)midori_browser_panel_timeout, hpaned, NULL);
-}
-
-static gboolean
-midori_panel_cycle_child_focus_cb (GtkWidget* hpaned,
- gboolean reversed,
- MidoriBrowser* browser)
-{
- /* Default cycle goes between all GtkPaned widgets.
- If focus is in the panel, focus the location as if it's a paned.
- If nothing is focussed, simply go to the location.
- Be sure to suppress the default because the signal can recurse. */
- GtkWidget* focus = gtk_window_get_focus (GTK_WINDOW (browser));
- if (gtk_widget_get_ancestor (focus, MIDORI_TYPE_PANEL)
- || !gtk_widget_get_ancestor (focus, GTK_TYPE_PANED))
- {
- g_signal_stop_emission_by_name (hpaned, "cycle-child-focus");
- midori_browser_activate_action (browser, "Location");
- return TRUE;
- }
- return FALSE;
-}
-
-static void
-midori_panel_notify_page_cb (MidoriPanel* panel,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- gint page = midori_panel_get_current_page (panel);
- if (page > -1)
- g_object_set (browser->settings, "last-panel-page", page, NULL);
-}
-
-static void
-midori_panel_notify_show_titles_cb (MidoriPanel* panel,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- gboolean show_titles = katze_object_get_boolean (panel, "show-titles");
- g_signal_handlers_block_by_func (browser->settings,
- midori_browser_settings_notify, browser);
- g_object_set (browser->settings, "compact-sidepanel", !show_titles, NULL);
- g_signal_handlers_unblock_by_func (browser->settings,
- midori_browser_settings_notify, browser);
-}
-
-static void
-midori_panel_notify_right_aligned_cb (MidoriPanel* panel,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- gboolean right_aligned = katze_object_get_boolean (panel, "right-aligned");
- GtkWidget* hpaned = gtk_widget_get_parent (browser->panel);
- GtkWidget* vpaned = gtk_widget_get_parent (browser->notebook);
- gint paned_position = gtk_paned_get_position (GTK_PANED (hpaned));
- GtkAllocation allocation;
- gint paned_size;
-
- gtk_widget_get_allocation (hpaned, &allocation);
- paned_size = allocation.width;
-
- g_object_set (browser->settings, "right-align-sidepanel", right_aligned, NULL);
-
- g_object_ref (browser->panel);
- g_object_ref (vpaned);
- gtk_container_remove (GTK_CONTAINER (hpaned), browser->panel);
- gtk_container_remove (GTK_CONTAINER (hpaned), vpaned);
- if (right_aligned)
- {
- gtk_paned_pack1 (GTK_PANED (hpaned), vpaned, TRUE, FALSE);
- gtk_paned_pack2 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
- }
- else
- {
- gtk_paned_pack1 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
- gtk_paned_pack2 (GTK_PANED (hpaned), vpaned, TRUE, FALSE);
- }
- gtk_paned_set_position (GTK_PANED (hpaned), paned_size - paned_position);
- g_object_unref (browser->panel);
- g_object_unref (vpaned);
-}
-
-static gboolean
-midori_panel_close_cb (MidoriPanel* panel,
- MidoriBrowser* browser)
-{
- _action_set_active (browser, "Panel", FALSE);
- return FALSE;
-}
-
-static void
-midori_browser_switched_tab_cb (MidoriNotebook* notebook,
- GtkWidget* old_widget,
- MidoriView* new_view,
- MidoriBrowser* browser)
-{
- GtkAction* action;
- const gchar* text;
- const gchar* uri;
-
- if (old_widget != NULL)
- {
- action = _action_by_name (browser, "Location");
- text = midori_location_action_get_text (MIDORI_LOCATION_ACTION (action));
- g_object_set_data_full (G_OBJECT (old_widget), "midori-browser-typed-text",
- g_strdup (text), g_free);
- }
-
- g_return_if_fail (MIDORI_IS_VIEW (new_view));
- g_return_if_fail (new_view != MIDORI_VIEW (old_widget));
-
- uri = g_object_get_data (G_OBJECT (new_view), "midori-browser-typed-text");
- if (!uri)
- uri = midori_view_get_display_uri (new_view);
- midori_browser_set_title (browser, midori_view_get_display_title (new_view));
- action = _action_by_name (browser, "Location");
- midori_location_action_set_text (MIDORI_LOCATION_ACTION (action), uri);
- if (midori_paths_get_runtime_mode () == MIDORI_RUNTIME_MODE_APP)
- gtk_window_set_icon (GTK_WINDOW (browser), midori_view_get_icon (new_view));
-
- g_signal_emit (browser, signals[SWITCH_TAB], 0, old_widget, new_view);
- _midori_browser_set_statusbar_text (browser, new_view, NULL);
- _midori_browser_update_interface (browser, new_view);
- _midori_browser_update_progress (browser, new_view);
-}
-
-static void
-midori_browser_notify_tab_cb (GtkWidget* notebook,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- g_object_freeze_notify (G_OBJECT (browser));
- g_object_notify (G_OBJECT (browser), "uri");
- g_object_notify (G_OBJECT (browser), "title");
- g_object_notify (G_OBJECT (browser), "tab");
- g_object_thaw_notify (G_OBJECT (browser));
-}
-
-static void
-midori_browser_tab_moved_cb (GtkWidget* notebook,
- MidoriView* view,
- guint page_num,
- MidoriBrowser* browser)
-{
- KatzeItem* item = midori_view_get_proxy_item (view);
- katze_array_move_item (browser->proxy_array, item, page_num);
-}
-
-static void
-midori_browser_notebook_create_window_cb (GtkWidget* notebook,
- GtkWidget* view,
- gint x,
- gint y,
- MidoriBrowser* browser)
-{
- MidoriBrowser* new_browser;
- g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser);
- if (new_browser)
- {
- gtk_window_move (GTK_WINDOW (new_browser), x, y);
- g_object_ref (view);
- midori_browser_disconnect_tab (browser, MIDORI_VIEW (view));
- midori_notebook_remove (MIDORI_NOTEBOOK (browser->notebook), MIDORI_TAB (view));
- midori_browser_add_tab (new_browser, view);
- g_object_unref (view);
- }
-}
-
-static void
-midori_browser_notebook_new_tab_cb (GtkWidget* notebook,
- MidoriBrowser* browser)
-{
- GtkWidget* view = midori_browser_add_uri (browser, "about:new");
- midori_browser_set_current_tab (browser, view);
-}
-
-static void
-midori_browser_notebook_context_menu_cb (MidoriNotebook* notebook,
- MidoriContextAction* menu,
- MidoriBrowser* browser)
-{
- midori_context_action_add_action_group (menu, browser->action_group);
- midori_context_action_add (menu, NULL);
- midori_context_action_add_by_name (menu, "TabNew");
- midori_context_action_add_by_name (menu, "UndoTabClose");
-}
-
-static void
-midori_browser_notebook_tab_context_menu_cb (MidoriNotebook* notebook,
- MidoriTab* tab,
- MidoriContextAction* menu,
- MidoriBrowser* browser)
-{
- midori_context_action_add_action_group (menu, browser->action_group);
- midori_context_action_add (menu, NULL);
- midori_context_action_add_by_name (menu, "TabNew");
- midori_context_action_add_by_name (menu, "UndoTabClose");
- if (MIDORI_IS_VIEW (tab))
- {
- GtkAction* action = gtk_action_new ("TabDuplicate", _("_Duplicate Current Tab"), NULL, NULL);
- g_object_set_data (G_OBJECT (action), "tab", tab);
- g_signal_connect (action, "activate",
- G_CALLBACK (_action_tab_duplicate_activate), browser);
- midori_context_action_add (menu, action);
- }
-}
-
-static void
-_action_undo_tab_close_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- guint last;
- KatzeItem* item;
-
- if (!browser->trash)
- return;
-
- /* Reopen the most recent trash item */
- last = katze_array_get_length (browser->trash) - 1;
- item = katze_array_get_nth_item (browser->trash, last);
- midori_browser_set_current_tab (browser,
- midori_browser_restore_tab (browser, item));
-}
-
-static void
-_action_trash_empty_activate (GtkAction* action,
- MidoriBrowser* browser)
-{
- if (browser->trash)
- katze_array_clear (browser->trash);
-}
-
-static const GtkActionEntry entries[] =
-{
- { "File", NULL, N_("_File") },
- { "WindowNew", STOCK_WINDOW_NEW,
- N_("New _Window"), "<Ctrl>n",
- N_("Open a new window"), G_CALLBACK (_action_window_new_activate) },
- { "TabNew", STOCK_TAB_NEW,
- NULL, "<Ctrl>t",
- N_("Open a new tab"), G_CALLBACK (_action_tab_new_activate) },
- { "PrivateBrowsing", NULL,
- N_("New P_rivate Browsing Window"), "<Ctrl><Shift>n",
- NULL, G_CALLBACK (_action_private_browsing_activate), },
- { "Open", GTK_STOCK_OPEN,
- NULL, "<Ctrl>o",
- N_("Open a file"), G_CALLBACK (_action_open_activate) },
- { "SaveAs", GTK_STOCK_SAVE_AS,
- N_("_Save Page As…"), "<Ctrl>s",
- N_("Save to a file"), G_CALLBACK (_action_save_as_activate) },
- { "AddSpeedDial", NULL,
- N_("Add to Speed _dial"), "<Ctrl>h",
- NULL, G_CALLBACK (_action_add_speed_dial_activate) },
- { "AddNewsFeed", NULL,
- N_("Subscribe to News _feed"), NULL,
- NULL, G_CALLBACK (_action_add_news_feed_activate) },
- { "CompactAdd", GTK_STOCK_ADD,
- NULL, NULL,
- NULL, G_CALLBACK (_action_compact_add_activate) },
- { "TabClose", GTK_STOCK_CLOSE,
- N_("_Close Tab"), "<Ctrl>w",
- N_("Close the current tab"), G_CALLBACK (_action_tab_close_activate) },
- { "WindowClose", NULL,
- N_("C_lose Window"), "<Ctrl><Shift>w",
- NULL, G_CALLBACK (_action_window_close_activate) },
- { "Print", GTK_STOCK_PRINT,
- NULL, "<Ctrl>p",
- N_("Print the current page"), G_CALLBACK (_action_print_activate) },
- { "MailTo", NULL,
- N_("Send Page Link Via Email"), "<Ctrl>m",
- NULL, G_CALLBACK (_action_mail_to_activate) },
- { "Quit", GTK_STOCK_QUIT,
- N_("Close a_ll Windows"), "<Ctrl><Shift>q",
- NULL, G_CALLBACK (_action_quit_activate) },
-
- { "Edit", NULL, N_("_Edit"), NULL, NULL, G_CALLBACK (_action_edit_activate) },
- { "Undo", GTK_STOCK_UNDO,
- NULL, "<Ctrl>z",
- NULL, G_CALLBACK (_action_undo_activate) },
- { "Redo", GTK_STOCK_REDO,
- NULL, "<Ctrl><Shift>z",
- NULL, G_CALLBACK (_action_redo_activate) },
- { "Cut", GTK_STOCK_CUT,
- NULL, "<Ctrl>x",
- NULL, G_CALLBACK (_action_cut_activate) },
- { "Copy", GTK_STOCK_COPY,
- NULL, "<Ctrl>c",
- NULL, G_CALLBACK (_action_copy_activate) },
- { "Paste", GTK_STOCK_PASTE,
- NULL, "<Ctrl>v",
- NULL, G_CALLBACK (_action_paste_activate) },
- { "PasteProceed", NULL,
- /* i18n: Right-click on Location, Open an URL from the clipboard */
- N_("Paste and p_roceed"), "<Ctrl><Shift>v",
- NULL, G_CALLBACK (_action_paste_proceed_activate) },
- { "Delete", GTK_STOCK_DELETE,
- NULL, NULL,
- NULL, G_CALLBACK (_action_delete_activate) },
- { "SelectAll", GTK_STOCK_SELECT_ALL,
- NULL, "<Ctrl>a",
- NULL, G_CALLBACK (_action_select_all_activate) },
- { "Find", GTK_STOCK_FIND,
- N_("_Find…"), "<Ctrl>f",
- N_("Find a word or phrase in the page"), G_CALLBACK (_action_find_activate) },
- { "FindNext", GTK_STOCK_GO_FORWARD,
- N_("Find _Next"), "<Ctrl>g",
- NULL, G_CALLBACK (_action_find_next_activate) },
- { "FindPrevious", GTK_STOCK_GO_BACK,
- N_("Find _Previous"), "<Ctrl><Shift>g",
- NULL, G_CALLBACK (_action_find_previous_activate) },
- { "Preferences", GTK_STOCK_PREFERENCES,
- NULL, "<Ctrl><Alt>p",
- N_("Configure the application preferences"), G_CALLBACK (_action_preferences_activate) },
-
- { "View", NULL, N_("_View") },
- { "Toolbars", NULL, N_("_Toolbars") },
- { "Reload", GTK_STOCK_REFRESH,
- NULL, "<Ctrl>r",
- N_("Reload the current page"), G_CALLBACK (_action_reload_stop_activate) },
- { "ReloadUncached", GTK_STOCK_REFRESH,
- N_("Reload page without caching"), "<Ctrl><Shift>r",
- NULL, G_CALLBACK (_action_reload_stop_activate) },
- { "Stop", GTK_STOCK_STOP,
- NULL, "Escape",
- N_("Stop loading the current page"), G_CALLBACK (_action_reload_stop_activate) },
- { "ReloadStop", GTK_STOCK_STOP,
- NULL, "",
- N_("Reload the current page"), G_CALLBACK (_action_reload_stop_activate) },
- { "ZoomIn", GTK_STOCK_ZOOM_IN,
- NULL, "<Ctrl>plus",
- N_("Increase the zoom level"), G_CALLBACK (_action_zoom_activate) },
- { "ZoomOut", GTK_STOCK_ZOOM_OUT,
- NULL, "<Ctrl>minus",
- N_("Decrease the zoom level"), G_CALLBACK (_action_zoom_activate) },
- { "ZoomNormal", GTK_STOCK_ZOOM_100,
- NULL, "<Ctrl>0",
- NULL, G_CALLBACK (_action_zoom_activate) },
- { "Encoding", NULL, N_("_Encoding") },
- { "SourceView", NULL,
- N_("View So_urce"), "<Ctrl><Alt>U",
- NULL, G_CALLBACK (_action_source_view_activate) },
- { "SourceViewDom", NULL,
- N_("View _DOM Source"), "<Ctrl><Alt><Shift>U",
- NULL, G_CALLBACK (_action_source_view_dom_activate) },
- { "CaretBrowsing", NULL,
- N_("Ca_ret Browsing"), "F7",
- NULL, G_CALLBACK (_action_caret_browsing_activate) },
- { "Fullscreen", GTK_STOCK_FULLSCREEN,
- NULL, "F11",
- N_("Toggle fullscreen view"), G_CALLBACK (_action_fullscreen_activate) },
- { "ScrollLeft", NULL,
- N_("Scroll _Left"), "h",
- NULL, G_CALLBACK (_action_scroll_somewhere_activate) },
- { "ScrollDown", NULL,
- N_("Scroll _Down"), "j",
- NULL, G_CALLBACK (_action_scroll_somewhere_activate) },
- { "ScrollUp", NULL,
- N_("Scroll _Up"), "k",
- NULL, G_CALLBACK (_action_scroll_somewhere_activate) },
- { "ScrollRight", NULL,
- N_("Scroll _Right"), "l",
- NULL, G_CALLBACK (_action_scroll_somewhere_activate) },
- { "Readable", NULL,
- N_("_Readable"), "<Ctrl><Alt>R",
- NULL, G_CALLBACK (_action_readable_activate) },
-
- { "Go", NULL, N_("_Go") },
- { "Back", GTK_STOCK_GO_BACK,
- NULL, "<Alt>Left",
- N_("Go back to the previous page"), G_CALLBACK (_action_navigation_activate) },
- { "Forward", GTK_STOCK_GO_FORWARD,
- NULL, "<Alt>Right",
- N_("Go forward to the next page"), G_CALLBACK (_action_navigation_activate) },
- { "Previous", GTK_STOCK_MEDIA_PREVIOUS,
- NULL, "<Alt><Shift>Left",
- /* i18n: Visit the previous logical page, ie. in a forum or blog */
- N_("Go to the previous sub-page"), G_CALLBACK (_action_navigation_activate) },
- { "Next", GTK_STOCK_MEDIA_NEXT,
- NULL, "<Alt><Shift>Right",
- /* i18n: Visit the following logical page, ie. in a forum or blog */
- N_("Go to the next sub-page"), G_CALLBACK (_action_navigation_activate) },
- { "NextForward", GTK_STOCK_MEDIA_NEXT,
- N_("Next or Forward"), "",
- N_("Go to the next sub-page or next page in history"), G_CALLBACK (_action_navigation_activate) },
- { "Homepage", GTK_STOCK_HOME,
- N_("_Homepage"), "<Alt>Home",
- N_("Go to your homepage"), G_CALLBACK (_action_navigation_activate) },
- { "TrashEmpty", GTK_STOCK_CLEAR,
- N_("Empty Trash"), "",
- NULL, G_CALLBACK (_action_trash_empty_activate) },
- { "UndoTabClose", GTK_STOCK_UNDELETE,
- N_("Undo _Close Tab"), "<Ctrl><Shift>t",
- NULL, G_CALLBACK (_action_undo_tab_close_activate) },
-
- { "BookmarkAdd", STOCK_BOOKMARK_ADD,
- NULL, "<Ctrl>d",
- N_("Add a new bookmark"), G_CALLBACK (_action_bookmark_add_activate) },
- { "BookmarkFolderAdd", NULL,
- N_("Add a new _folder"), "",
- NULL, G_CALLBACK (_action_bookmark_add_activate) },
- { "BookmarksImport", NULL,
- N_("_Import bookmarks…"), "",
- NULL, G_CALLBACK (_action_bookmarks_import_activate) },
- { "BookmarksExport", NULL,
- N_("_Export bookmarks…"), "",
- NULL, G_CALLBACK (_action_bookmarks_export_activate) },
- { "ManageSearchEngines", GTK_STOCK_PROPERTIES,
- N_("_Manage Search Engines…"), "<Ctrl><Alt>s",
- NULL, G_CALLBACK (_action_manage_search_engines_activate) },
- { "ClearPrivateData", NULL,
- N_("_Clear Private Data…"), "<Ctrl><Shift>Delete",
- NULL, G_CALLBACK (_action_clear_private_data_activate) },
- { "InspectPage", NULL,
- N_("_Inspect Page"), "<Ctrl><Shift>i",
- NULL, G_CALLBACK (_action_inspect_page_activate) },
-
- { "TabPrevious", GTK_STOCK_GO_BACK,
- N_("_Previous Tab"), "<Ctrl>Page_Up",
- NULL, G_CALLBACK (_action_tab_previous_activate) },
- { "TabNext", GTK_STOCK_GO_FORWARD,
- N_("_Next Tab"), "<Ctrl>Page_Down",
- NULL, G_CALLBACK (_action_tab_next_activate) },
- { "TabMoveFirst", NULL, N_("Move Tab to _first position"), NULL,
- NULL, G_CALLBACK (_action_tab_move_activate) },
- { "TabMoveBackward", NULL, N_("Move Tab _Backward"), "<Ctrl><Shift>Page_Up",
- NULL, G_CALLBACK (_action_tab_move_activate) },
- { "TabMoveForward", NULL, N_("_Move Tab Forward"), "<Ctrl><Shift>Page_Down",
- NULL, G_CALLBACK (_action_tab_move_activate) },
- { "TabMoveLast", NULL, N_("Move Tab to _last position"), NULL,
- NULL, G_CALLBACK (_action_tab_move_activate) },
- { "TabCurrent", NULL,
- N_("Focus _Current Tab"), "<Ctrl><Alt>Home",
- NULL, G_CALLBACK (_action_tab_current_activate) },
- { "NextView", NULL,
- N_("Focus _Next view"), "F6",
- NULL, G_CALLBACK (_action_next_view_activate) },
- { "TabMinimize", NULL,
- N_("Only show the Icon of the _Current Tab"), "",
- NULL, G_CALLBACK (_action_tab_minimize_activate) },
- { "TabDuplicate", NULL,
- N_("_Duplicate Current Tab"), "",
- NULL, G_CALLBACK (_action_tab_duplicate_activate) },
- { "TabCloseOther", NULL,
- N_("Close Ot_her Tabs"), "",
- NULL, G_CALLBACK (_action_tab_close_other_activate) },
- { "LastSession", NULL,
- N_("Open last _session"), NULL,
- NULL, NULL },
-
- { "Help", NULL, N_("_Help") },
- { "HelpFAQ", GTK_STOCK_HELP,
- N_("_Frequent Questions"), "F1",
- NULL, G_CALLBACK (_action_help_link_activate) },
- { "HelpBugs", NULL,
- N_("_Report a Problem…"), NULL,
- NULL, G_CALLBACK (_action_help_link_activate) },
- { "About", GTK_STOCK_ABOUT,
- NULL, "",
- NULL, G_CALLBACK (_action_about_activate) },
- { "Dummy", NULL, N_("_Tools") },
-};
-static const guint entries_n = G_N_ELEMENTS (entries);
-
-static const GtkToggleActionEntry toggle_entries[] =
-{
- { "Menubar", NULL,
- N_("_Menubar"), "",
- NULL, G_CALLBACK (_action_menubar_activate),
- FALSE },
- { "Navigationbar", NULL,
- N_("_Navigationbar"), "",
- NULL, G_CALLBACK (_action_navigationbar_activate),
- FALSE },
- { "Panel", GTK_STOCK_INDENT,
- N_("Side_panel"), "F9",
- N_("Sidepanel"), G_CALLBACK (_action_panel_activate),
- FALSE },
- { "Bookmarkbar", NULL,
- N_("_Bookmarkbar"), "",
- NULL, G_CALLBACK (_action_bookmarkbar_activate),
- FALSE },
- { "Statusbar", NULL,
- N_("_Statusbar"), "<Ctrl>j",
- NULL, G_CALLBACK (_action_statusbar_activate),
- FALSE },
-};
-
-static const GtkRadioActionEntry encoding_entries[] =
-{
- { "EncodingAutomatic", NULL,
- N_("_Automatic"), "",
- NULL, 1 },
- { "EncodingChinese", NULL,
- N_("Chinese Traditional (BIG5)"), "",
- NULL, 1 },
- { "EncodingChineseSimplified", NULL,
- N_("Chinese Simplified (GB18030)"), "",
- NULL, 1 },
- { "EncodingJapanese", NULL,
- /* i18n: A double underscore "__" is used to prevent the mnemonic */
- N_("Japanese (SHIFT__JIS)"), "",
- NULL, 1 },
- { "EncodingKorean", NULL,
- N_("Korean (EUC-KR)"), "",
- NULL, 1 },
- { "EncodingRussian", NULL,
- N_("Russian (KOI8-R)"), "",
- NULL, 1 },
- { "EncodingUnicode", NULL,
- N_("Unicode (UTF-8)"), "",
- NULL, 1 },
- { "EncodingWestern", NULL,
- N_("Western (ISO-8859-1)"), "",
- NULL, 1 },
- { "EncodingCustom", NULL,
- N_("Custom…"), "",
- NULL, 1 },
-};
-
-typedef struct {
- MidoriBrowser* browser;
- guint timeout;
-} MidoriInactivityTimeout;
-
-static gboolean
-midori_inactivity_timeout (gpointer data)
-{
- #ifdef HAVE_X11_EXTENSIONS_SCRNSAVER_H
- MidoriInactivityTimeout* mit = data;
- static Display* xdisplay = NULL;
- static XScreenSaverInfo* mit_info = NULL;
- static int has_extension = -1;
- int event_base, error_base;
-
- if (has_extension == -1)
- {
- GdkDisplay* display = gtk_widget_get_display (GTK_WIDGET (mit->browser));
- if (GDK_IS_X11_DISPLAY (display))
- {
- xdisplay = GDK_DISPLAY_XDISPLAY (display);
- has_extension = XScreenSaverQueryExtension (xdisplay, &event_base, &error_base);
- }
- else
- has_extension = 0;
- }
-
- if (has_extension)
- {
- if (!mit_info)
- mit_info = XScreenSaverAllocInfo ();
- XScreenSaverQueryInfo (xdisplay, RootWindow (xdisplay, 0), mit_info);
- if (mit_info->idle / 1000 > mit->timeout)
- {
- midori_private_data_clear_all (mit->browser);
- midori_browser_activate_action (mit->browser, "Homepage");
- }
- }
- #else
- /* TODO: Implement for other windowing systems */
- #endif
-
- return TRUE;
-}
-
-void
-midori_browser_set_inactivity_reset (MidoriBrowser* browser,
- gint inactivity_reset)
-{
- if (inactivity_reset > 0)
- {
- MidoriInactivityTimeout* mit = g_new (MidoriInactivityTimeout, 1);
- mit->browser = browser;
- mit->timeout = inactivity_reset;
- midori_timeout_add_seconds (
- inactivity_reset, midori_inactivity_timeout, mit, NULL);
- }
-}
-
-static gboolean
-midori_browser_window_state_event_cb (MidoriBrowser* browser,
- GdkEventWindowState* event)
-{
- MidoriWindowState window_state = MIDORI_WINDOW_NORMAL;
- if (event->new_window_state & GDK_WINDOW_STATE_ICONIFIED)
- window_state = MIDORI_WINDOW_MINIMIZED;
- else if (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED)
- window_state = MIDORI_WINDOW_MAXIMIZED;
- else if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
- window_state = MIDORI_WINDOW_FULLSCREEN;
- g_object_set (browser->settings, "last-window-state", window_state, NULL);
-
- return FALSE;
-}
-
-static gboolean
-midori_browser_alloc_timeout (MidoriBrowser* browser)
-{
- GtkWidget* widget = GTK_WIDGET (browser);
- GdkWindowState state = gdk_window_get_state (gtk_widget_get_window (widget));
-
- if (!(state &
- (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)))
- {
- GtkAllocation allocation;
- gtk_widget_get_allocation (widget, &allocation);
- if (allocation.width != browser->last_window_width)
- {
- browser->last_window_width = allocation.width;
- g_object_set (browser->settings,
- "last-window-width", browser->last_window_width, NULL);
- }
- if (allocation.height != browser->last_window_height)
- {
- browser->last_window_height = allocation.height;
- g_object_set (browser->settings,
- "last-window-height", allocation.height, NULL);
- }
- }
-
- browser->alloc_timeout = 0;
- return FALSE;
-}
-
-static void
-midori_browser_size_allocate_cb (MidoriBrowser* browser,
- GtkAllocation* allocation)
-{
- GtkWidget* widget = GTK_WIDGET (browser);
-
- if (!browser->alloc_timeout && gtk_widget_get_realized (widget))
- {
- gpointer last_page;
-
- if ((last_page = g_object_get_data (G_OBJECT (browser), "last-page")))
- {
- midori_panel_set_current_page (MIDORI_PANEL (browser->panel),
- GPOINTER_TO_INT (last_page));
- g_object_set_data (G_OBJECT (browser), "last-page", NULL);
- }
-
- browser->alloc_timeout = midori_timeout_add_seconds (5,
- (GSourceFunc)midori_browser_alloc_timeout, browser, NULL);
- }
-}
-
-static void
-midori_browser_destroy_cb (MidoriBrowser* browser)
-{
-
- g_object_set_data (G_OBJECT (browser), "midori-browser-destroyed", (void*)1);
-
- if (G_UNLIKELY (browser->panel_timeout))
- g_source_remove (browser->panel_timeout);
- if (G_UNLIKELY (browser->alloc_timeout))
- g_source_remove (browser->alloc_timeout);
-
- /* Destroy panel first, so panels don't need special care */
- gtk_widget_destroy (browser->panel);
- /* Destroy tabs second, so child widgets don't need special care */
- gtk_container_foreach (GTK_CONTAINER (browser->notebook),
- (GtkCallback) gtk_widget_destroy, NULL);
-}
-
-static const gchar* ui_markup =
- "<ui>"
- "<menubar>"
- "<menu action='File'>"
- "<menuitem action='WindowNew'/>"
- "<menuitem action='TabNew'/>"
- "<menuitem action='PrivateBrowsing'/>"
- "<separator/>"
- "<menuitem action='Open'/>"
- "<separator/>"
- "<menuitem action='SaveAs'/>"
- "<menuitem action='AddSpeedDial'/>"
- "<separator/>"
- "<menuitem action='TabClose'/>"
- "<menuitem action='WindowClose'/>"
- "<separator/>"
- "<menuitem action='MailTo'/>"
- "<menuitem action='Print'/>"
- "<separator/>"
- "<menuitem action='Quit'/>"
- "</menu>"
- "<menu action='Edit'>"
- "<menuitem action='Undo'/>"
- "<menuitem action='Redo'/>"
- "<separator/>"
- "<menuitem action='Cut'/>"
- "<menuitem action='Copy'/>"
- "<menuitem action='Paste'/>"
- "<menuitem action='PasteProceed'/>"
- "<menuitem action='Delete'/>"
- "<separator/>"
- "<menuitem action='SelectAll'/>"
- "<separator/>"
- "<menuitem action='Find'/>"
- "<menuitem action='FindNext'/>"
- #ifndef G_OS_WIN32
- "<separator/>"
- "<menuitem action='Preferences'/>"
- #endif
- "</menu>"
- "<menu action='View'>"
- "<menu action='Toolbars'>"
- "<menuitem action='Menubar'/>"
- "<menuitem action='Navigationbar'/>"
- "<menuitem action='Bookmarkbar'/>"
- "<menuitem action='Statusbar'/>"
- "</menu>"
- "<menuitem action='Panel'/>"
- "<separator/>"
- "<menuitem action='Stop'/>"
- "<menuitem action='Reload'/>"
- "<separator/>"
- "<menuitem action='ZoomIn'/>"
- "<menuitem action='ZoomOut'/>"
- "<menuitem action='ZoomNormal'/>"
- "<separator/>"
- "<menu action='Encoding'>"
- "<menuitem action='EncodingAutomatic'/>"
- "<menuitem action='EncodingChinese'/>"
- "<menuitem action='EncodingChineseSimplified'/>"
- "<menuitem action='EncodingJapanese'/>"
- "<menuitem action='EncodingKorean'/>"
- "<menuitem action='EncodingRussian'/>"
- "<menuitem action='EncodingUnicode'/>"
- "<menuitem action='EncodingWestern'/>"
- "<menuitem action='EncodingCustom'/>"
- "</menu>"
- "<menuitem action='Fullscreen'/>"
- "<menuitem action='Readable'/>"
- "<menuitem action='SourceView'/>"
- "<menuitem action='SourceViewDom'/>"
- "</menu>"
- "<menu action='Go'>"
- "<menuitem action='Back'/>"
- "<menuitem action='Forward'/>"
- "<menuitem action='Previous'/>"
- "<menuitem action='Next'/>"
- "<menuitem action='Homepage'/>"
- "<menuitem action='Location'/>"
- "<menuitem action='Search'/>"
- "<menuitem action='Trash'/>"
- "</menu>"
- "<menu action='Bookmarks'>"
- "<menuitem action='BookmarkAdd'/>"
- "<menuitem action='BookmarksImport'/>"
- "<menuitem action='BookmarksExport'/>"
- "</menu>"
- "<menuitem action='Tools'/>"
- "<menuitem action='Window'/>"
- "<menu action='Help'>"
- "<menuitem action='HelpFAQ'/>"
- "<menuitem action='HelpBugs'/>"
- "<separator/>"
- "<menuitem action='About'/>"
- "</menu>"
- /* For accelerators to work all actions need to be used
- *somewhere* in the UI definition */
- /* These also show up in Unity's HUD */
- "<menu action='Dummy'>"
- "<menuitem action='TabMoveFirst'/>"
- "<menuitem action='TabMoveBackward'/>"
- "<menuitem action='TabMoveForward'/>"
- "<menuitem action='TabMoveLast'/>"
- "<menuitem action='ScrollLeft'/>"
- "<menuitem action='ScrollDown'/>"
- "<menuitem action='ScrollUp'/>"
- "<menuitem action='ScrollRight'/>"
- "<menuitem action='FindPrevious'/>"
- "<menuitem action='BookmarkAdd'/>"
- "<menuitem action='BookmarkFolderAdd'/>"
- "<menuitem action='ManageSearchEngines'/>"
- "<menuitem action='ClearPrivateData'/>"
- "<menuitem action='TabPrevious'/>"
- "<menuitem action='TabNext'/>"
- "<menuitem action='TabCurrent'/>"
- "<menuitem action='NextView'/>"
- "<menuitem action='TabMinimize'/>"
- "<menuitem action='TabDuplicate'/>"
- "<menuitem action='TabCloseOther'/>"
- "<menuitem action='LastSession'/>"
- "<menuitem action='UndoTabClose'/>"
- "<menuitem action='TrashEmpty'/>"
- "<menuitem action='Preferences'/>"
- "<menuitem action='InspectPage'/>"
- "<menuitem action='ReloadUncached'/>"
- "<menuitem action='CaretBrowsing'/>"
- "</menu>"
- "</menubar>"
- "<toolbar name='toolbar_navigation'>"
- "</toolbar>"
- "</ui>";
-
-static void
-midori_browser_realize_cb (GtkStyle* style,
- MidoriBrowser* browser)
-{
- GdkScreen* screen = gtk_widget_get_screen (GTK_WIDGET (browser));
- if (screen)
- {
- GtkIconTheme* icon_theme = gtk_icon_theme_get_for_screen (screen);
- if (gtk_icon_theme_has_icon (icon_theme, "midori"))
- gtk_window_set_icon_name (GTK_WINDOW (browser), "midori");
- else
- gtk_window_set_icon_name (GTK_WINDOW (browser), MIDORI_STOCK_WEB_BROWSER);
- }
-}
-
-static void
-midori_browser_set_history (MidoriBrowser* browser,
- KatzeArray* history)
-{
- if (browser->history == history)
- return;
-
- if (history)
- g_object_ref (history);
- katze_object_assign (browser->history, history);
- katze_object_assign (browser->history_database, NULL);
-
- if (!history)
- return;
-
- GError* error = NULL;
- browser->history_database = midori_history_database_new (NULL, &error);
- if (error != NULL)
- {
- g_printerr (_("Failed to initialize history: %s"), error->message);
- g_printerr ("\n");
- g_error_free (error);
- return;
- }
- g_object_set (_action_by_name (browser, "Location"), "history",
- browser->history, NULL);
-}
-
-static void
-midori_browser_accel_switch_tab_activate_cb (GtkAccelGroup* accel_group,
- GObject* acceleratable,
- guint keyval,
- GdkModifierType modifiers)
-{
- GtkAccelGroupEntry* entry;
-
- if ((entry = gtk_accel_group_query (accel_group, keyval, modifiers, NULL)))
- {
- gint n;
- MidoriBrowser* browser;
- GtkWidget* view;
-
- /* Switch to n-th tab. 9 and 0 go to the last tab. */
- n = keyval - GDK_KEY_0;
- browser = g_object_get_data (G_OBJECT (accel_group), "midori-browser");
- if ((view = midori_browser_get_nth_tab (browser, n < 9 ? n - 1 : -1)))
- midori_browser_set_current_tab (browser, view);
- }
-}
-
-static void
-midori_browser_add_actions (MidoriBrowser* browser)
-{
- /* 0,053 versus 0,002 compared to gtk_action_group_add_ API */
- guint i;
- GSList* group = NULL;
- for (i = 0; i < G_N_ELEMENTS (entries); i++)
- {
- GtkActionEntry entry = entries[i];
- GtkAction* action = gtk_action_new (entry.name,
- _(entry.label), _(entry.tooltip), entry.stock_id);
- if (entry.callback)
- g_signal_connect (action, "activate", entry.callback, browser);
- gtk_action_group_add_action_with_accel (browser->action_group,
- GTK_ACTION (action), entry.accelerator);
- }
- for (i = 0; i < G_N_ELEMENTS (toggle_entries); i++)
- {
- GtkToggleActionEntry entry = toggle_entries[i];
- GtkToggleAction* action = gtk_toggle_action_new (entry.name,
- _(entry.label), _(entry.tooltip), entry.stock_id);
- if (entry.is_active)
- gtk_toggle_action_set_active (action, TRUE);
- if (entry.callback)
- g_signal_connect (action, "activate", entry.callback, browser);
- gtk_action_group_add_action_with_accel (browser->action_group,
- GTK_ACTION (action), entry.accelerator);
- }
- for (i = 0; i < G_N_ELEMENTS (encoding_entries); i++)
- {
- GtkRadioActionEntry entry = encoding_entries[i];
- GtkRadioAction* action = gtk_radio_action_new (entry.name,
- _(entry.label), _(entry.tooltip), entry.stock_id, entry.value);
- if (i == 0)
- {
- group = gtk_radio_action_get_group (action);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
- g_signal_connect (action, "changed",
- G_CALLBACK (_action_view_encoding_activate), browser);
- }
- else
- {
- gtk_radio_action_set_group (action, group);
- group = gtk_radio_action_get_group (action);
- }
- gtk_action_group_add_action_with_accel (browser->action_group,
- GTK_ACTION (action), entry.accelerator);
- }
-}
-
-static gboolean
-midori_browser_idle (gpointer data)
-{
- MidoriBrowser* browser = MIDORI_BROWSER (data);
-
- if (browser->bookmarkbar_populate)
- {
- midori_bookmarkbar_populate_idle (browser);
-
- browser->bookmarkbar_populate = FALSE;
- }
-
- return FALSE;
-}
-
-static void
-midori_browser_init (MidoriBrowser* browser)
-{
- GtkWidget* vbox;
- GtkUIManager* ui_manager;
- GtkAccelGroup* accel_group;
- guint i;
- GClosure* accel_closure;
- GError* error;
- GtkAction* action;
- GtkWidget* menuitem;
- GtkWidget* homepage;
- GtkWidget* back;
- GtkWidget* forward;
- GtkWidget* hpaned;
- GtkWidget* vpaned;
- GtkWidget* scrolled;
- KatzeArray* dummy_array;
-
- browser->settings = midori_web_settings_new ();
- browser->proxy_array = katze_array_new (KATZE_TYPE_ARRAY);
- browser->bookmarks = NULL;
- browser->history = NULL;
- browser->history_database = NULL;
- browser->trash = NULL;
- browser->search_engines = NULL;
- browser->dial = NULL;
-
- /* Setup the window metrics */
- g_signal_connect (browser, "realize",
- G_CALLBACK (midori_browser_realize_cb), browser);
- g_signal_connect (browser, "window-state-event",
- G_CALLBACK (midori_browser_window_state_event_cb), NULL);
- g_signal_connect (browser, "size-allocate",
- G_CALLBACK (midori_browser_size_allocate_cb), NULL);
- g_signal_connect (browser, "destroy",
- G_CALLBACK (midori_browser_destroy_cb), NULL);
- gtk_window_set_role (GTK_WINDOW (browser), "browser");
- gtk_window_set_icon_name (GTK_WINDOW (browser), MIDORI_STOCK_WEB_BROWSER);
- vbox = gtk_vbox_new (FALSE, 0);
- /* gtk_container_add (GTK_CONTAINER (browser), vbox);
- gtk_widget_show (vbox); */
- midori_window_set_contents (MIDORI_WINDOW (browser), vbox);
-
- /* Let us see some ui manager magic */
- browser->action_group = gtk_action_group_new ("Browser");
- gtk_action_group_set_translation_domain (browser->action_group, GETTEXT_PACKAGE);
- midori_window_add_action_group (MIDORI_WINDOW (browser), browser->action_group);
- midori_browser_add_actions (browser);
- ui_manager = gtk_ui_manager_new ();
- accel_group = gtk_ui_manager_get_accel_group (ui_manager);
- gtk_window_add_accel_group (GTK_WINDOW (browser), accel_group);
- gtk_ui_manager_insert_action_group (ui_manager, browser->action_group, 0);
-
- g_object_set_data (G_OBJECT (accel_group), "midori-browser", browser);
- accel_closure = g_cclosure_new (G_CALLBACK (
- midori_browser_accel_switch_tab_activate_cb), browser, NULL);
- for (i = 0; i < 10; i++)
- {
- gchar* accel_path = g_strdup_printf ("<Manual>/Browser/SwitchTab%d", i);
- gtk_accel_map_add_entry (accel_path, GDK_KEY_0 + i, GDK_MOD1_MASK);
- gtk_accel_group_connect_by_path (accel_group, accel_path, accel_closure);
- g_free (accel_path);
- }
- g_closure_unref (accel_closure);
-
- error = NULL;
- if (!gtk_ui_manager_add_ui_from_string (ui_manager, ui_markup, -1, &error))
- {
- g_message ("User interface couldn't be created: %s", error->message);
- g_error_free (error);
- }
-
- /* Hide the 'Dummy' which only holds otherwise unused actions */
- _action_set_visible (browser, "Dummy", FALSE);
-
- action = g_object_new (KATZE_TYPE_SEPARATOR_ACTION,
- "name", "Separator",
- "label", _("_Separator"),
- NULL);
- gtk_action_group_add_action (browser->action_group, action);
- g_object_unref (action);
-
- action = g_object_new (MIDORI_TYPE_LOCATION_ACTION,
- "name", "Location",
- "label", _("_Location…"),
- "stock-id", GTK_STOCK_JUMP_TO,
- "tooltip", _("Open a particular location"),
- "placeholder-text", _("Search or enter an address"),
- NULL);
- g_object_connect (action,
- "signal::activate",
- _action_location_activate, browser,
- "signal::focus-in",
- _action_location_focus_in, browser,
- "signal::focus-out",
- _action_location_focus_out, browser,
- "signal::reset-uri",
- _action_location_reset_uri, browser,
- "signal::submit-uri",
- _action_location_submit_uri, browser,
- "signal-after::secondary-icon-released",
- _action_location_secondary_icon_released, browser,
- NULL);
- gtk_action_group_add_action_with_accel (browser->action_group,
- action, "<Ctrl>L");
- g_object_unref (action);
-
- action = g_object_new (MIDORI_TYPE_SEARCH_ACTION,
- "name", "Search",
- "label", _("_Web Search…"),
- "stock-id", GTK_STOCK_FIND,
- "tooltip", _("Run a web search"),
- NULL);
- g_object_connect (action,
- "signal::activate",
- _action_search_activate, browser,
- "signal::submit",
- _action_search_submit, browser,
- "signal::focus-out",
- _action_search_focus_out, browser,
- "signal::notify::current-item",
- _action_search_notify_current_item, browser,
- "signal::notify::default-item",
- _action_search_notify_default_item, browser,
- NULL);
- gtk_action_group_add_action_with_accel (browser->action_group,
- action, "<Ctrl>K");
- g_object_unref (action);
-
- action = g_object_new (MIDORI_TYPE_PANED_ACTION,
- "name", "LocationSearch",
- NULL);
- gtk_action_group_add_action (browser->action_group, action);
- g_object_unref (action);
-
- action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
- "name", "Trash",
- "stock-id", STOCK_USER_TRASH,
- "tooltip", _("Reopen a previously closed tab or window"),
- NULL);
- g_object_connect (action,
- "signal::populate-popup",
- _action_trash_populate_popup, browser,
- "signal::activate-item",
- _action_trash_activate_item, browser,
- "signal::activate-item-new-tab",
- _action_trash_activate_item_new_tab, browser,
- NULL);
- gtk_action_group_add_action_with_accel (browser->action_group, action, "");
- g_object_unref (action);
-
- dummy_array = katze_array_new (KATZE_TYPE_ARRAY);
- katze_array_update (dummy_array);
- action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
- "name", "Bookmarks",
- "label", _("_Bookmarks"),
- "stock-id", STOCK_BOOKMARKS,
- "tooltip", _("Show the saved bookmarks"),
- "array", dummy_array /* updated, unique */,
- NULL);
- g_object_connect (action,
- "signal::populate-folder",
- _action_bookmarks_populate_folder, browser,
- "signal::activate-item-alt",
- midori_bookmarkbar_activate_item_alt, browser,
- "signal::activate-item",
- midori_bookmarkbar_activate_item, browser,
- "signal::activate-item-new-tab",
- midori_bookmarkbar_activate_item_new_tab, browser,
- NULL);
- gtk_action_group_add_action_with_accel (browser->action_group, action, "");
- g_object_unref (action);
- g_object_unref (dummy_array);
-
- dummy_array = katze_array_new (KATZE_TYPE_ITEM);
- katze_array_update (dummy_array);
- action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
- "name", "Tools",
- "label", _("_Tools"),
- "stock-id", GTK_STOCK_PREFERENCES,
- "array", dummy_array /* updated, unique */,
- NULL);
- g_object_connect (action,
- "signal::populate-popup",
- _action_tools_populate_popup, browser,
- NULL);
- gtk_action_group_add_action (browser->action_group, action);
- g_object_unref (action);
- g_object_unref (dummy_array);
-
- action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
- "name", "Window",
- "label", _("_Tabs"),
- "stock-id", GTK_STOCK_INDEX,
- "tooltip", _("Show a list of all open tabs"),
- "array", browser->proxy_array,
- NULL);
- g_object_connect (action,
- "signal::populate-popup",
- _action_window_populate_popup, browser,
- "signal::activate-item",
- _action_window_activate_item, browser,
- /* middle-clicks on tab menu entries behave like left-clicks */
- "signal::activate-item-new-tab",
- _action_window_activate_item, browser,
- NULL);
- gtk_action_group_add_action_with_accel (browser->action_group, action, "");
- g_object_unref (action);
-
- action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
- "name", "CompactMenu",
- "label", _("_Menu"),
- "stock-id", GTK_STOCK_PROPERTIES,
- "tooltip", _("Menu"),
- "array", katze_array_new (KATZE_TYPE_ITEM),
- NULL);
- g_object_connect (action,
- "signal::populate-popup",
- _action_compact_menu_populate_popup, browser,
- NULL);
- gtk_action_group_add_action (browser->action_group, action);
- g_object_unref (action);
-
- /* Create the menubar */
- browser->menubar = gtk_ui_manager_get_widget (ui_manager, "/menubar");
- midori_window_add_toolbar (MIDORI_WINDOW (browser), browser->menubar);
- gtk_widget_hide (browser->menubar);
- _action_set_visible (browser, "Menubar", !midori_browser_has_native_menubar (browser));
- g_signal_connect (browser->menubar, "button-press-event",
- G_CALLBACK (midori_browser_menu_button_press_event_cb), browser);
-
- menuitem = gtk_menu_item_new ();
- gtk_widget_show (menuitem);
- browser->throbber = gtk_spinner_new ();
- /* Wrap the spinner in an event box to retain its size when hidden */
- GtkWidget* throbber_box = gtk_event_box_new ();
- gtk_event_box_set_visible_window (GTK_EVENT_BOX (throbber_box), FALSE);
- gint icon_size = 16;
- gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (browser)),
- GTK_ICON_SIZE_MENU, &icon_size, NULL);
- gtk_widget_set_size_request (throbber_box, icon_size, icon_size);
- gtk_container_add (GTK_CONTAINER (throbber_box), browser->throbber);
- gtk_widget_show (throbber_box);
- gtk_container_add (GTK_CONTAINER (menuitem), throbber_box);
- #if GTK_CHECK_VERSION (3, 2, 0)
- /* FIXME: Doesn't work */
- gtk_widget_set_hexpand (menuitem, TRUE);
- gtk_widget_set_halign (menuitem, GTK_ALIGN_END);
- #else
- gtk_menu_item_set_right_justified (GTK_MENU_ITEM (menuitem), TRUE);
- #endif
- gtk_menu_shell_append (GTK_MENU_SHELL (browser->menubar), menuitem);
-
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (
- gtk_ui_manager_get_widget (ui_manager, "/menubar/File/WindowNew")), NULL);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (
- gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Location")), NULL);
-
- homepage = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Homepage");
- g_signal_connect (homepage, "button-press-event",
- G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser);
- back = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Back");
- g_signal_connect (back, "button-press-event",
- G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser);
- forward = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Forward");
- g_signal_connect (forward, "button-press-event",
- G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser);
- forward = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Previous");
- g_signal_connect (forward, "button-press-event",
- G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser);
- forward = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Next");
- g_signal_connect (forward, "button-press-event",
- G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser);
-
- _action_set_sensitive (browser, "EncodingCustom", FALSE);
- _action_set_visible (browser, "LastSession", FALSE);
-
- _action_set_visible (browser, "Bookmarks", browser->bookmarks != NULL);
- _action_set_visible (browser, "BookmarkAdd", browser->bookmarks != NULL);
- _action_set_visible (browser, "BookmarksImport", browser->bookmarks != NULL);
- _action_set_visible (browser, "BookmarksExport", browser->bookmarks != NULL);
- _action_set_visible (browser, "Bookmarkbar", browser->bookmarks != NULL);
- _action_set_visible (browser, "Trash", browser->trash != NULL);
- _action_set_visible (browser, "UndoTabClose", browser->trash != NULL);
-
- /* Create the navigationbar */
- browser->navigationbar = midori_window_get_toolbar (MIDORI_WINDOW (browser));
-
- /* Show visibility menu on right-clicking menubar or toolbars */
- g_signal_connect (browser, "context-menu",
- G_CALLBACK (midori_browser_toolbar_context_menu_cb), browser);
-
- /* Bookmarkbar */
- browser->bookmarkbar = gtk_toolbar_new ();
- gtk_widget_set_name (browser->bookmarkbar, "MidoriBookmarkbar");
- gtk_toolbar_set_icon_size (GTK_TOOLBAR (browser->bookmarkbar),
- GTK_ICON_SIZE_MENU);
- gtk_toolbar_set_style (GTK_TOOLBAR (browser->bookmarkbar),
- GTK_TOOLBAR_BOTH_HORIZ);
- midori_window_add_toolbar (MIDORI_WINDOW (browser), browser->bookmarkbar);
- g_signal_connect (browser->bookmarkbar, "popup-context-menu",
- G_CALLBACK (midori_browser_toolbar_popup_context_menu_cb), browser);
-
- /* Create the panel */
- hpaned = gtk_hpaned_new ();
- g_signal_connect (hpaned, "notify::position",
- G_CALLBACK (midori_panel_notify_position_cb),
- browser);
- g_signal_connect (hpaned, "cycle-child-focus",
- G_CALLBACK (midori_panel_cycle_child_focus_cb),
- browser);
- gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
- gtk_widget_show (hpaned);
- browser->panel = g_object_new (MIDORI_TYPE_PANEL,
- "action-group", browser->action_group,
- NULL);
- g_object_connect (browser->panel,
- "signal::notify::page",
- midori_panel_notify_page_cb, browser,
- "signal::notify::show-titles",
- midori_panel_notify_show_titles_cb, browser,
- "signal::notify::right-aligned",
- midori_panel_notify_right_aligned_cb, browser,
- "signal::close",
- midori_panel_close_cb, browser,
- NULL);
- gtk_paned_pack1 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
-
- /* Notebook, containing all views */
- vpaned = gtk_vpaned_new ();
- gtk_paned_pack2 (GTK_PANED (hpaned), vpaned, TRUE, FALSE);
- gtk_widget_show (vpaned);
- browser->notebook = midori_notebook_new ();
-
- gtk_paned_pack1 (GTK_PANED (vpaned), browser->notebook, FALSE, FALSE);
- g_signal_connect (browser->notebook, "tab-switched",
- G_CALLBACK (midori_browser_switched_tab_cb),
- browser);
- g_signal_connect (browser->notebook, "notify::tab",
- G_CALLBACK (midori_browser_notify_tab_cb), browser);
- g_signal_connect (browser->notebook, "tab-moved",
- G_CALLBACK (midori_browser_tab_moved_cb),
- browser);
- g_signal_connect (browser->notebook, "context-menu",
- G_CALLBACK (midori_browser_notebook_context_menu_cb),
- browser);
- g_signal_connect (browser->notebook, "tab-context-menu",
- G_CALLBACK (midori_browser_notebook_tab_context_menu_cb), browser);
- g_signal_connect (browser->notebook, "tab-detached",
- G_CALLBACK (midori_browser_notebook_create_window_cb), browser);
- g_signal_connect (browser->notebook, "new-tab",
- G_CALLBACK (midori_browser_notebook_new_tab_cb), browser);
- gtk_widget_show (browser->notebook);
-
- /* Inspector container */
- browser->inspector = gtk_vbox_new (FALSE, 0);
- gtk_paned_pack2 (GTK_PANED (vpaned), browser->inspector, FALSE, FALSE);
- scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_widget_set_can_focus (scrolled, TRUE);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
- GTK_SHADOW_ETCHED_IN);
- gtk_box_pack_start (GTK_BOX (browser->inspector), scrolled, TRUE, TRUE, 0);
- browser->inspector_view = gtk_viewport_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (scrolled), browser->inspector_view);
-
- /* Incremental findbar */
- browser->find = g_object_new (MIDORI_TYPE_FINDBAR, NULL);
- gtk_box_pack_start (GTK_BOX (vbox), browser->find, FALSE, FALSE, 0);
-
- /* Statusbar */
- browser->statusbar = gtk_statusbar_new ();
- browser->statusbar_contents =
- gtk_statusbar_get_message_area (GTK_STATUSBAR (browser->statusbar));
- gtk_box_pack_start (GTK_BOX (vbox), browser->statusbar, FALSE, FALSE, 0);
-
- g_signal_connect (browser->statusbar, "button-press-event",
- G_CALLBACK (midori_browser_menu_button_press_event_cb), browser);
-
- g_object_unref (ui_manager);
-}
-
-static void
-midori_browser_dispose (GObject* object)
-{
- MidoriBrowser* browser = MIDORI_BROWSER (object);
-
- /* We are done, the session mustn't change anymore */
- katze_object_assign (browser->proxy_array, NULL);
- g_signal_handlers_disconnect_by_func (browser->settings,
- midori_browser_settings_notify,
- browser);
- midori_browser_set_bookmarks (browser, NULL);
- midori_browser_set_history (browser, NULL);
-
- G_OBJECT_CLASS (midori_browser_parent_class)->dispose (object);
-}
-
-static void
-midori_browser_finalize (GObject* object)
-{
- MidoriBrowser* browser = MIDORI_BROWSER (object);
-
- katze_assign (browser->statusbar_text, NULL);
-
- katze_object_assign (browser->settings, NULL);
- katze_object_assign (browser->trash, NULL);
- katze_object_assign (browser->search_engines, NULL);
- katze_object_assign (browser->history, NULL);
- katze_object_assign (browser->history_database, NULL);
- katze_object_assign (browser->dial, NULL);
-
- g_idle_remove_by_data (browser);
-
- G_OBJECT_CLASS (midori_browser_parent_class)->finalize (object);
-}
-
-static void
-_midori_browser_set_toolbar_style (MidoriBrowser* browser,
- MidoriToolbarStyle toolbar_style)
-{
- GtkToolbarStyle gtk_toolbar_style;
- GtkIconSize icon_size;
- GtkSettings* gtk_settings = gtk_widget_get_settings (GTK_WIDGET (browser));
- g_object_get (gtk_settings, "gtk-toolbar-icon-size", &icon_size, NULL);
- if (toolbar_style == MIDORI_TOOLBAR_DEFAULT && gtk_settings)
- g_object_get (gtk_settings, "gtk-toolbar-style", &gtk_toolbar_style, NULL);
- else
- {
- switch (toolbar_style)
- {
- case MIDORI_TOOLBAR_SMALL_ICONS:
- icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR;
- case MIDORI_TOOLBAR_ICONS:
- gtk_toolbar_style = GTK_TOOLBAR_ICONS;
- break;
- case MIDORI_TOOLBAR_TEXT:
- gtk_toolbar_style = GTK_TOOLBAR_TEXT;
- break;
- case MIDORI_TOOLBAR_BOTH:
- gtk_toolbar_style = GTK_TOOLBAR_BOTH;
- break;
- case MIDORI_TOOLBAR_BOTH_HORIZ:
- case MIDORI_TOOLBAR_DEFAULT:
- gtk_toolbar_style = GTK_TOOLBAR_BOTH_HORIZ;
- }
- }
- if (GTK_IS_TOOLBAR (browser->navigationbar))
- {
- gtk_toolbar_set_style (GTK_TOOLBAR (browser->navigationbar),
- gtk_toolbar_style);
- gtk_toolbar_set_icon_size (GTK_TOOLBAR (browser->navigationbar), icon_size);
- }
- midori_panel_set_toolbar_style (MIDORI_PANEL (browser->panel),
- gtk_toolbar_style);
-}
-
-#ifndef HAVE_WEBKIT2
-static void
-midori_browser_toolbar_popup_context_menu_history_cb (GtkMenuItem* menu_item,
- MidoriBrowser* browser)
-{
- gint steps = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "steps"));
- MidoriView* view = MIDORI_VIEW (midori_browser_get_current_tab (browser));
- midori_view_go_back_or_forward (view, steps);
-}
-#endif
-
-static void
-midori_browser_toolbar_popup_context_menu_history (MidoriBrowser* browser,
- GtkWidget* widget,
- gboolean back,
- gint x,
- gint y)
-{
-#ifndef HAVE_WEBKIT2
- const gint step = back ? -1 : 1;
- gint steps = step;
- GtkWidget* menu;
- WebKitWebBackForwardList* list;
- WebKitWebHistoryItem* current_item;
- WebKitWebHistoryItem* history_item;
- WebKitWebHistoryItem* (*history_next)(WebKitWebBackForwardList*);
- void (*history_action)(WebKitWebBackForwardList*);
-
- list = webkit_web_view_get_back_forward_list (
- WEBKIT_WEB_VIEW (midori_view_get_web_view (
- MIDORI_VIEW (midori_browser_get_current_tab (browser)))));
-
- if (!list)
- return;
-
- menu = gtk_menu_new ();
-
- history_action = back ?
- webkit_web_back_forward_list_go_back :
- webkit_web_back_forward_list_go_forward;
- history_next = back ?
- webkit_web_back_forward_list_get_back_item :
- webkit_web_back_forward_list_get_forward_item;
- current_item = webkit_web_back_forward_list_get_current_item (list);
-
- for (; (history_item = history_next (list)); history_action (list), steps += step)
- {
- const gchar* uri = webkit_web_history_item_get_uri (history_item);
- GtkWidget* menu_item = gtk_image_menu_item_new_with_label (
- webkit_web_history_item_get_title (history_item));
- GdkPixbuf* pixbuf;
- if ((pixbuf = midori_paths_get_icon (uri, widget)))
- {
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
- gtk_image_new_from_pixbuf (pixbuf));
- g_object_unref (pixbuf);
- }
- g_object_set_data (G_OBJECT (menu_item), "uri", (gpointer)uri);
- g_object_set_data (G_OBJECT (menu_item), "steps", GINT_TO_POINTER (steps));
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
- g_signal_connect (G_OBJECT (menu_item), "activate",
- G_CALLBACK (midori_browser_toolbar_popup_context_menu_history_cb),
- browser);
- if (steps == (10 - 1))
- break;
- }
-
- webkit_web_back_forward_list_go_to_item (list, current_item);
- gtk_widget_show_all (menu);
-
- katze_widget_popup (widget, GTK_MENU (menu), NULL,
- KATZE_MENU_POSITION_LEFT);
-#endif
-}
-
-static void
-_midori_browser_update_settings (MidoriBrowser* browser)
-{
- gboolean remember_last_window_size;
- MidoriWindowState last_window_state;
- guint inactivity_reset;
- gboolean compact_sidepanel;
- gboolean right_align_sidepanel, open_panels_in_windows;
- gint last_panel_position, last_panel_page;
- gboolean show_menubar, show_bookmarkbar;
- gboolean show_panel;
- MidoriToolbarStyle toolbar_style;
- gchar* toolbar_items;
- gboolean close_buttons_left, close_buttons_on_tabs;
-
- g_object_get (browser->settings,
- "remember-last-window-size", &remember_last_window_size,
- "last-window-width", &browser->last_window_width,
- "last-window-height", &browser->last_window_height,
- "last-window-state", &last_window_state,
- "inactivity-reset", &inactivity_reset,
- "compact-sidepanel", &compact_sidepanel,
- "right-align-sidepanel", &right_align_sidepanel,
- "open-panels-in-windows", &open_panels_in_windows,
- "last-panel-position", &last_panel_position,
- "last-panel-page", &last_panel_page,
- "show-menubar", &show_menubar,
- "show-navigationbar", &browser->show_navigationbar,
- "show-bookmarkbar", &show_bookmarkbar,
- "show-panel", &show_panel,
- "show-statusbar", &browser->show_statusbar,
- "toolbar-style", &toolbar_style,
- "toolbar-items", &toolbar_items,
- "close-buttons-left", &close_buttons_left,
- "close-buttons-on-tabs", &close_buttons_on_tabs,
- "maximum-history-age", &browser->maximum_history_age,
- NULL);
-
- midori_notebook_set_close_buttons_visible (
- MIDORI_NOTEBOOK (browser->notebook), close_buttons_on_tabs);
- midori_notebook_set_close_buttons_left (
- MIDORI_NOTEBOOK (browser->notebook), close_buttons_left);
- midori_findbar_set_close_button_left (MIDORI_FINDBAR (browser->find),
- close_buttons_left);
- if (browser->dial != NULL)
- midori_speed_dial_set_close_buttons_left (browser->dial, close_buttons_left);
-
- midori_browser_set_inactivity_reset (browser, inactivity_reset);
-
- if (remember_last_window_size)
- {
- if (browser->last_window_width && browser->last_window_height)
- gtk_window_set_default_size (GTK_WINDOW (browser),
- browser->last_window_width, browser->last_window_height);
- else
- katze_window_set_sensible_default_size (GTK_WINDOW (browser));
- switch (last_window_state)
- {
- case MIDORI_WINDOW_MINIMIZED:
- gtk_window_iconify (GTK_WINDOW (browser));
- break;
- case MIDORI_WINDOW_MAXIMIZED:
- gtk_window_maximize (GTK_WINDOW (browser));
- break;
- case MIDORI_WINDOW_FULLSCREEN:
- gtk_window_fullscreen (GTK_WINDOW (browser));
- break;
- default:
- ;/* Do nothing. */
- }
- }
-
- _midori_browser_set_toolbar_style (browser, toolbar_style);
- _toggle_tabbar_smartly (browser, FALSE);
- midori_window_set_actions (MIDORI_WINDOW (browser), toolbar_items);
-
- if (browser->search_engines)
- {
- const gchar* default_search = midori_settings_get_location_entry_search (
- MIDORI_SETTINGS (browser->settings));
- KatzeItem* item;
-
- if ((item = katze_array_get_nth_item (browser->search_engines,
- browser->last_web_search)))
- midori_search_action_set_current_item (MIDORI_SEARCH_ACTION (
- _action_by_name (browser, "Search")), item);
-
- if (default_search != NULL
- && (item = katze_array_find_uri (browser->search_engines, default_search)))
- midori_search_action_set_default_item (MIDORI_SEARCH_ACTION (
- _action_by_name (browser, "Search")), item);
- }
-
- g_object_set (browser->panel, "show-titles", !compact_sidepanel,
- "right-aligned", right_align_sidepanel,
- "open-panels-in-windows", open_panels_in_windows, NULL);
- gtk_paned_set_position (GTK_PANED (gtk_widget_get_parent (browser->panel)),
- last_panel_position);
- /* The browser may not yet be visible, which means that we can't set the
- page. So we set it in midori_browser_size_allocate_cb */
- if (gtk_widget_get_visible (GTK_WIDGET (browser)))
- midori_panel_set_current_page (MIDORI_PANEL (browser->panel), last_panel_page);
- else
- g_object_set_data (G_OBJECT (browser), "last-page",
- GINT_TO_POINTER (last_panel_page));
-
- _action_set_active (browser, "Menubar", show_menubar);
- if (GTK_IS_TOOLBAR (browser->navigationbar))
- _action_set_active (browser, "Navigationbar", browser->show_navigationbar);
- _action_set_active (browser, "Bookmarkbar", show_bookmarkbar
- && browser->bookmarks != NULL);
- _action_set_active (browser, "Panel", show_panel);
- _action_set_active (browser, "Statusbar", browser->show_statusbar);
-
- g_free (toolbar_items);
-}
-
-static void
-midori_browser_settings_notify (MidoriWebSettings* web_settings,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- const gchar* name;
- GValue value = {0, };
-
- name = g_intern_string (pspec->name);
- g_value_init (&value, pspec->value_type);
- g_object_get_property (G_OBJECT (web_settings), name, &value);
-
- if (name == g_intern_string ("toolbar-style"))
- _midori_browser_set_toolbar_style (browser, g_value_get_enum (&value));
- else if (name == g_intern_string ("toolbar-items"))
- midori_window_set_actions (MIDORI_WINDOW (browser), g_value_get_string (&value));
- else if (name == g_intern_string ("compact-sidepanel"))
- {
- g_signal_handlers_block_by_func (browser->panel,
- midori_panel_notify_show_titles_cb, browser);
- g_object_set (browser->panel, "show-titles",
- !g_value_get_boolean (&value), NULL);
- g_signal_handlers_unblock_by_func (browser->panel,
- midori_panel_notify_show_titles_cb, browser);
- }
- else if (name == g_intern_string ("open-panels-in-windows"))
- g_object_set (browser->panel, "open-panels-in-windows",
- g_value_get_boolean (&value), NULL);
- else if (name == g_intern_string ("always-show-tabbar"))
- _toggle_tabbar_smartly (browser, FALSE);
- else if (name == g_intern_string ("show-menubar"))
- {
- _action_set_active (browser, "Menubar", g_value_get_boolean (&value));
- }
- else if (name == g_intern_string ("show-navigationbar"))
- {
- browser->show_navigationbar = g_value_get_boolean (&value);
- if (GTK_IS_TOOLBAR (browser->navigationbar))
- _action_set_active (browser, "Navigationbar", g_value_get_boolean (&value));
- }
- else if (name == g_intern_string ("show-bookmarkbar"))
- {
- _action_set_active (browser, "Bookmarkbar", g_value_get_boolean (&value));
- }
- else if (name == g_intern_string ("show-statusbar"))
- {
- browser->show_statusbar = g_value_get_boolean (&value);
- _action_set_active (browser, "Statusbar", g_value_get_boolean (&value));
- }
- else if (name == g_intern_string ("maximum-history-age"))
- browser->maximum_history_age = g_value_get_int (&value);
- else if (name == g_intern_string ("close-buttons-on-tabs"))
- midori_notebook_set_close_buttons_visible (
- MIDORI_NOTEBOOK (browser->notebook), g_value_get_boolean (&value));
- else if (name == g_intern_string ("close-buttons-left"))
- {
- midori_findbar_set_close_button_left (MIDORI_FINDBAR (browser->find),
- g_value_get_boolean (&value));
- midori_speed_dial_set_close_buttons_left (browser->dial,
- g_value_get_boolean (&value));
- midori_notebook_set_close_buttons_left (
- MIDORI_NOTEBOOK (browser->notebook), g_value_get_boolean (&value));
- }
- else if (name == g_intern_string ("inactivity-reset"))
- midori_browser_set_inactivity_reset (browser, g_value_get_uint (&value));
- else if (!g_object_class_find_property (G_OBJECT_GET_CLASS (web_settings),
- name))
- g_warning (_("Unexpected setting '%s'"), name);
- g_value_unset (&value);
-}
-
-static void
-midori_bookmarkbar_insert_item (GtkWidget* toolbar,
- KatzeItem* item)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (toolbar);
- GtkAction* action = _action_by_name (browser, "Bookmarks");
- GtkToolItem* toolitem = katze_array_action_create_tool_item_for (
- KATZE_ARRAY_ACTION (action), item);
- g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item);
-
- if (!KATZE_IS_ITEM (item)) /* Separator */
- gtk_tool_item_set_use_drag_window (toolitem, TRUE);
-
- gtk_widget_show (GTK_WIDGET (toolitem));
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
-}
-
-static void
-midori_bookmarkbar_add_item_cb (KatzeArray* bookmarks,
- KatzeItem* item,
- MidoriBrowser* browser)
-{
- if (gtk_widget_get_visible (browser->bookmarkbar))
- midori_bookmarkbar_populate (browser);
- else if (katze_item_get_meta_boolean (item, "toolbar"))
- _action_set_active (browser, "Bookmarkbar", TRUE);
- midori_browser_update_history (item, "bookmark", "created");
-}
-
-static void
-midori_bookmarkbar_update_item_cb (KatzeArray* bookmarks,
- KatzeItem* item,
- MidoriBrowser* browser)
-{
- if (gtk_widget_get_visible (browser->bookmarkbar))
- midori_bookmarkbar_populate (browser);
- midori_browser_update_history (item, "bookmark", "modify");
-}
-
-static void
-midori_bookmarkbar_remove_item_cb (KatzeArray* bookmarks,
- KatzeItem* item,
- MidoriBrowser* browser)
-{
- if (gtk_widget_get_visible (browser->bookmarkbar))
- midori_bookmarkbar_populate (browser);
- midori_browser_update_history (item, "bookmark", "delete");
-}
-
-static void
-midori_bookmarkbar_populate (MidoriBrowser* browser)
-{
- if (browser->bookmarkbar_populate)
- return;
-
- g_idle_add (midori_browser_idle, browser);
- browser->bookmarkbar_populate = TRUE;
-}
-
-static void
-midori_bookmarkbar_populate_idle (MidoriBrowser* browser)
-{
- KatzeArray* array;
- KatzeItem* item;
-
- midori_bookmarkbar_clear (browser->bookmarkbar);
-
- /* Use a dummy to ensure height of the toolbar */
- gtk_toolbar_insert (GTK_TOOLBAR (browser->bookmarkbar),
- gtk_separator_tool_item_new (), -1);
-
- array = midori_bookmarks_db_query_recursive (browser->bookmarks,
- "id, parentid, title, uri, desc, app, toolbar, pos_panel, pos_bar", "toolbar = 1", NULL, FALSE);
- if (!array)
- {
- _action_set_sensitive (browser, "BookmarkAdd", FALSE);
- _action_set_sensitive (browser, "BookmarkFolderAdd", FALSE);
- return;
- }
-
- KATZE_ARRAY_FOREACH_ITEM (item, array)
- {
- midori_bookmarkbar_insert_item (browser->bookmarkbar, item);
- }
- _action_set_sensitive (browser, "BookmarkAdd", TRUE);
- _action_set_sensitive (browser, "BookmarkFolderAdd", TRUE);
-}
-
-static void
-midori_bookmarkbar_clear (GtkWidget* toolbar)
-{
- GList* children = gtk_container_get_children (GTK_CONTAINER (toolbar));
- while (children != NULL)
- {
- gtk_widget_destroy (children->data);
- children = g_list_next (children);
- }
-}
-
-static void
-midori_browser_show_bookmarkbar_notify_value_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- MidoriBrowser* browser)
-{
- if (!katze_object_get_boolean (browser->settings, "show-bookmarkbar"))
- midori_bookmarkbar_clear (browser->bookmarkbar);
- else
- midori_bookmarkbar_populate (browser);
-}
-
-static void
-midori_browser_set_bookmarks (MidoriBrowser* browser,
- MidoriBookmarksDb* bookmarks)
-{
- MidoriWebSettings* settings;
-
- if (browser->bookmarks != NULL)
- {
- g_signal_handlers_disconnect_by_func (browser->bookmarks,
- midori_bookmarkbar_add_item_cb, browser);
- g_signal_handlers_disconnect_by_func (browser->bookmarks,
- midori_bookmarkbar_update_item_cb, browser);
- g_signal_handlers_disconnect_by_func (browser->bookmarks,
- midori_bookmarkbar_remove_item_cb, browser);
- }
-
- g_object_set (G_OBJECT (_action_by_name (browser, "Bookmarks")),
- "array", KATZE_ARRAY (bookmarks),
- NULL);
-
- settings = midori_browser_get_settings (browser);
- g_signal_handlers_disconnect_by_func (settings,
- midori_browser_show_bookmarkbar_notify_value_cb, browser);
- katze_object_assign (browser->bookmarks, bookmarks);
-
- _action_set_visible (browser, "Bookmarks", bookmarks != NULL);
- if (bookmarks != NULL)
- {
- /* FIXME: Proxies aren't shown propely. Why? */
- GSList* proxies = gtk_action_get_proxies (
- _action_by_name (browser, "Bookmarks"));
- for (; proxies; proxies = g_slist_next (proxies))
- gtk_widget_show (proxies->data);
- }
- _action_set_visible (browser, "BookmarkAdd", bookmarks != NULL);
- _action_set_visible (browser, "BookmarksImport", bookmarks != NULL);
- _action_set_visible (browser, "BookmarksExport", bookmarks != NULL);
- _action_set_visible (browser, "Bookmarkbar", bookmarks != NULL);
-
- if (!bookmarks)
- return;
-
- if (katze_object_get_boolean (browser->settings, "show-bookmarkbar"))
- _action_set_active (browser, "Bookmarkbar", TRUE);
- g_object_ref (bookmarks);
- g_signal_connect (settings, "notify::show-bookmarkbar",
- G_CALLBACK (midori_browser_show_bookmarkbar_notify_value_cb), browser);
- g_object_notify (G_OBJECT (settings), "show-bookmarkbar");
- g_signal_connect_after (bookmarks, "add-item",
- G_CALLBACK (midori_bookmarkbar_add_item_cb), browser);
- g_signal_connect_after (bookmarks, "update-item",
- G_CALLBACK (midori_bookmarkbar_update_item_cb), browser);
- g_signal_connect_after (bookmarks, "remove-item",
- G_CALLBACK (midori_bookmarkbar_remove_item_cb), browser);
-}
-
-static void
-midori_browser_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- MidoriBrowser* browser = MIDORI_BROWSER (object);
- KatzeItem* item;
-
- switch (prop_id)
- {
- case PROP_URI:
- midori_browser_set_current_uri (browser, g_value_get_string (value));
- break;
- case PROP_TAB:
- midori_browser_set_current_tab (browser, g_value_get_object (value));
- break;
- case PROP_STATUSBAR_TEXT:
- _midori_browser_set_statusbar_text (browser,
- MIDORI_VIEW (midori_browser_get_current_tab (browser)),
- g_value_get_string (value));
- break;
- case PROP_SETTINGS:
- g_signal_handlers_disconnect_by_func (browser->settings,
- midori_browser_settings_notify,
- browser);
- katze_object_assign (browser->settings, g_value_dup_object (value));
- if (!browser->settings)
- browser->settings = midori_web_settings_new ();
-
- _midori_browser_update_settings (browser);
- g_signal_connect (browser->settings, "notify",
- G_CALLBACK (midori_browser_settings_notify), browser);
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs; tabs = g_list_next (tabs))
- midori_view_set_settings (tabs->data, browser->settings);
- g_list_free (tabs);
- break;
- case PROP_BOOKMARKS:
- midori_browser_set_bookmarks (browser, g_value_get_object (value));
- break;
- case PROP_TRASH:
- /* FIXME: Disconnect handlers */
- katze_object_assign (browser->trash, g_value_dup_object (value));
- g_object_set (_action_by_name (browser, "Trash"),
- "array", browser->trash, "reversed", TRUE,
- NULL);
- _action_set_visible (browser, "Trash", browser->trash != NULL);
- _action_set_visible (browser, "UndoTabClose", browser->trash != NULL);
- if (browser->trash != NULL)
- {
- g_signal_connect_after (browser->trash, "clear",
- G_CALLBACK (midori_browser_trash_clear_cb), browser);
- midori_browser_trash_clear_cb (browser->trash, browser);
- }
- break;
- case PROP_SEARCH_ENGINES:
- {
- /* FIXME: Disconnect handlers */
- katze_object_assign (browser->search_engines, g_value_dup_object (value));
- midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
- _action_by_name (browser, "Location")), browser->search_engines);
- midori_search_action_set_search_engines (MIDORI_SEARCH_ACTION (
- _action_by_name (browser, "Search")), browser->search_engines);
- /* FIXME: Connect to updates */
-
- if (browser->search_engines)
- {
- const gchar* default_search = midori_settings_get_location_entry_search (
- MIDORI_SETTINGS (browser->settings));
- g_object_get (browser->settings, "last-web-search", &browser->last_web_search, NULL);
- item = katze_array_get_nth_item (browser->search_engines, browser->last_web_search);
- midori_search_action_set_current_item (MIDORI_SEARCH_ACTION (
- _action_by_name (browser, "Search")), item);
-
- if (default_search != NULL && (item = katze_array_find_uri (browser->search_engines, default_search)))
- midori_search_action_set_default_item (MIDORI_SEARCH_ACTION (
- _action_by_name (browser, "Search")), item);
- }
- break;
- }
- case PROP_HISTORY:
- midori_browser_set_history (browser, g_value_get_object (value));
- break;
- case PROP_SPEED_DIAL:
- if (browser->dial != NULL)
- g_signal_handlers_disconnect_by_func (browser->dial,
- midori_browser_speed_dial_refresh_cb, browser);
- katze_object_assign (browser->dial, g_value_dup_object (value));
- if (browser->dial != NULL)
- g_signal_connect (browser->dial, "refresh",
- G_CALLBACK (midori_browser_speed_dial_refresh_cb), browser);
- break;
- case PROP_SHOW_TABS:
- browser->show_tabs = g_value_get_boolean (value);
- _toggle_tabbar_smartly (browser, FALSE);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_browser_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- MidoriBrowser* browser = MIDORI_BROWSER (object);
-
- switch (prop_id)
- {
- case PROP_MENUBAR:
- g_value_set_object (value, browser->menubar);
- break;
- case PROP_NAVIGATIONBAR:
- g_value_set_object (value, browser->navigationbar);
- break;
- case PROP_NOTEBOOK:
- g_value_set_object (value, MIDORI_NOTEBOOK (browser->notebook)->notebook);
- break;
- case PROP_PANEL:
- g_value_set_object (value, browser->panel);
- break;
- case PROP_URI:
- g_value_set_string (value, midori_browser_get_current_uri (browser));
- break;
- case PROP_TAB:
- g_value_set_object (value, midori_browser_get_current_tab (browser));
- break;
- case PROP_LOAD_STATUS:
- {
- GtkWidget* view = midori_browser_get_current_tab (browser);
- if (view)
- g_value_set_enum (value,
- midori_view_get_load_status (MIDORI_VIEW (view)));
- else
- g_value_set_enum (value, MIDORI_LOAD_FINISHED);
- break;
- }
- case PROP_STATUSBAR:
- g_value_set_object (value, browser->statusbar_contents);
- break;
- case PROP_STATUSBAR_TEXT:
- g_value_set_string (value, browser->statusbar_text);
- break;
- case PROP_SETTINGS:
- g_value_set_object (value, browser->settings);
- break;
- case PROP_PROXY_ITEMS:
- g_value_set_object (value, browser->proxy_array);
- break;
- case PROP_BOOKMARKS:
- g_value_set_object (value, browser->bookmarks);
- break;
- case PROP_TRASH:
- g_value_set_object (value, browser->trash);
- break;
- case PROP_SEARCH_ENGINES:
- g_value_set_object (value, browser->search_engines);
- break;
- case PROP_HISTORY:
- g_value_set_object (value, browser->history);
- break;
- case PROP_SPEED_DIAL:
- g_value_set_object (value, browser->dial);
- break;
- case PROP_SHOW_TABS:
- g_value_set_boolean (value, browser->show_tabs);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/**
- * midori_browser_new:
- *
- * Creates a new browser widget.
- *
- * A browser is a window with a menubar, toolbars, a notebook, panels
- * and a statusbar. You should mostly treat it as an opaque widget.
- *
- * Return value: a new #MidoriBrowser
- **/
-MidoriBrowser*
-midori_browser_new (void)
-{
- MidoriBrowser* browser = g_object_new (MIDORI_TYPE_BROWSER,
- NULL);
-
- return browser;
-}
-
-/**
- * midori_browser_add_tab:
- * @browser: a #MidoriBrowser
- * @widget: a view
- *
- * Appends a view in the form of a new tab and creates an
- * according item in the Window menu.
- *
- * Since: 0.4.9: Return type is void
- **/
-void
-midori_browser_add_tab (MidoriBrowser* browser,
- GtkWidget* view)
-{
- g_return_if_fail (MIDORI_IS_BROWSER (browser));
- g_return_if_fail (GTK_IS_WIDGET (view));
-
-#ifndef HAVE_WEBKIT2
- if (!g_object_get_data (G_OBJECT (webkit_get_default_session ()),
- "midori-session-initialized"))
- g_critical ("midori_load_soup_session was not called!");
-#endif
- g_signal_emit (browser, signals[ADD_TAB], 0, view);
-}
-
-/**
- * midori_browser_page_num:
- * @browser: a #MidoriBrowser
- * @view: a child widget of the browser's notebook
- *
- * Retrieves the position of @view in the browser.
- *
- * If there is no page present at all, -1 is returned.
- *
- * Return value: the index of the view, or -1
- *
- * Since: 0.4.5
- **/
-gint
-midori_browser_page_num (MidoriBrowser* browser,
- GtkWidget* view)
-{
- g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
- g_return_val_if_fail (MIDORI_IS_VIEW (view), -1);
-
- return midori_notebook_get_tab_index (MIDORI_NOTEBOOK (browser->notebook), MIDORI_TAB (view));
-}
-
-
-/**
- * midori_browser_close_tab:
- * @browser: a #MidoriBrowser
- * @widget: a view
- *
- * Closes an existing view, removing it and
- * its associated menu item from the browser.
- **/
-void
-midori_browser_close_tab (MidoriBrowser* browser,
- GtkWidget* view)
-{
- g_return_if_fail (MIDORI_IS_BROWSER (browser));
- g_return_if_fail (GTK_IS_WIDGET (view));
-
- g_signal_emit (browser, signals[REMOVE_TAB], 0, view);
-}
-
-/**
- * midori_browser_add_item:
- * @browser: a #MidoriBrowser
- * @item: an item
- *
- * Return value: (type MidoriView) (transfer none): the added view
- *
- * Since: 0.4.9: Return type is GtkWidget*
- **/
-GtkWidget*
-midori_browser_add_item (MidoriBrowser* browser,
- KatzeItem* item)
-{
- const gchar* uri;
- GtkWidget* view;
-
- g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
- g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
-
- uri = katze_item_get_uri (item);
- view = midori_view_new_with_item (item, browser->settings);
- midori_browser_add_tab (browser, view);
- midori_view_set_uri (MIDORI_VIEW (view), uri);
- return view;
-}
-
-/**
- * midori_browser_add_uri:
- * @browser: a #MidoriBrowser
- * @uri: an URI
- *
- * Appends an uri in the form of a new view.
- *
- * Return value: (type MidoriView) (transfer none): the added view
- *
- * Since: 0.4.9: Return type is GtkWidget*
- **/
-GtkWidget*
-midori_browser_add_uri (MidoriBrowser* browser,
- const gchar* uri)
-{
- KatzeItem* item;
-
- g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
- g_return_val_if_fail (uri != NULL, NULL);
-
- item = katze_item_new ();
- item->uri = g_strdup (uri);
- return midori_browser_add_item (browser, item);
-}
-
-/**
- * midori_browser_activate_action:
- * @browser: a #MidoriBrowser
- * @name: action, setting=value expression or extension=true|false
- *
- * Activates the specified action. See also midori_browser_assert_action().
- **/
-void
-midori_browser_activate_action (MidoriBrowser* browser,
- const gchar* name)
-{
- g_return_if_fail (MIDORI_IS_BROWSER (browser));
- g_return_if_fail (name != NULL);
-
- g_signal_emit (browser, signals[ACTIVATE_ACTION], 0, name);
-}
-
-void
-midori_browser_set_action_visible (MidoriBrowser* browser,
- const gchar* name,
- gboolean visible)
-{
- g_return_if_fail (MIDORI_IS_BROWSER (browser));
- g_return_if_fail (name != NULL);
-
- _action_set_visible (browser, name, visible);
- _action_set_sensitive (browser, name, visible);
-}
-
-/**
- * midori_browser_block_action:
- * @browser: a #MidoriBrowser
- * @action: the action to be blocked
- *
- * Blocks built-in behavior of the specified action without
- * disabling it, which gives you a chance to connect your
- * own signal handling.
- * Call midori_browser_unblock_action() to undo the effect.
- *
- * Since: 0.3.4
- **/
-void
-midori_browser_block_action (MidoriBrowser* browser,
- GtkAction* action)
-{
- const gchar* name;
- guint i;
-
- g_return_if_fail (MIDORI_IS_BROWSER (browser));
- g_return_if_fail (GTK_IS_ACTION (action));
-
- name = gtk_action_get_name (action);
- for (i = 0; i < entries_n; i++)
- if (g_str_equal (entries[i].name, name))
- {
- g_signal_handlers_block_by_func (action, entries[i].callback, browser);
- return;
- }
- g_critical ("%s: Action \"%s\" can't be blocked.", G_STRFUNC, name);
-}
-
-/**
- * midori_browser_unblock_action:
- * @browser: a #MidoriBrowser
- * @action: the action to be unblocked
- *
- * Restores built-in behavior of the specified action after
- * previously blocking it with midori_browser_block_action().
- *
- * Since: 0.3.4
- **/
-void
-midori_browser_unblock_action (MidoriBrowser* browser,
- GtkAction* action)
-{
- const gchar* name;
- guint i;
-
- g_return_if_fail (MIDORI_IS_BROWSER (browser));
- g_return_if_fail (GTK_IS_ACTION (action));
-
- name = gtk_action_get_name (action);
- for (i = 0; i < entries_n; i++)
- if (g_str_equal (entries[i].name, name))
- {
- g_signal_handlers_unblock_by_func (action, entries[i].callback, browser);
- return;
- }
- g_critical ("%s: Action \"%s\" can't be unblocked.", G_STRFUNC, name);
-}
-
-
-/**
- * midori_browser_get_action_group:
- * @browser: a #MidoriBrowser
- *
- * Retrieves the action group holding all actions used
- * by the browser. It allows obtaining individual
- * actions and adding new actions.
- *
- * Return value: (transfer none): the action group of the browser
- *
- * Since: 0.1.4
- **/
-GtkActionGroup*
-midori_browser_get_action_group (MidoriBrowser* browser)
-{
- g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
-
- return browser->action_group;
-}
-
-/**
- * midori_browser_set_current_uri:
- * @browser: a #MidoriBrowser
- * @uri: an URI
- *
- * Loads the specified URI in the current view.
- *
- * If the current view is opaque, and cannot load
- * new pages, it will automatically open a new tab.
- **/
-void
-midori_browser_set_current_uri (MidoriBrowser* browser,
- const gchar* uri)
-{
- g_return_if_fail (MIDORI_IS_BROWSER (browser));
- g_return_if_fail (uri != NULL);
-
- midori_view_set_uri (MIDORI_VIEW (midori_browser_get_current_tab (browser)), uri);
-}
-
-/**
- * midori_browser_get_current_uri:
- * @browser: a #MidoriBrowser
- *
- * Determines the URI loaded in the current view.
- *
- * If there is no view present at all, %NULL is returned.
- *
- * Return value: the current URI, or %NULL
- **/
-const gchar*
-midori_browser_get_current_uri (MidoriBrowser* browser)
-{
- g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
-
- return midori_view_get_display_uri (MIDORI_VIEW (
- midori_browser_get_current_tab (browser)));
-}
-
-/**
- * midori_browser_set_current_page:
- * @browser: a #MidoriBrowser
- * @n: the index of a page
- *
- * Switches to the page with the index @n.
- *
- * The widget will also grab the focus automatically.
- **/
-void
-midori_browser_set_current_page (MidoriBrowser* browser,
- gint n)
-{
- GtkWidget* view;
-
- g_return_if_fail (MIDORI_IS_BROWSER (browser));
-
- view = midori_browser_get_nth_tab (browser, n);
- g_return_if_fail (view != NULL);
-
- midori_browser_set_tab (browser, view);
-}
-
-/**
- * midori_browser_get_current_page:
- * @browser: a #MidoriBrowser
- *
- * Determines the currently selected page.
- *
- * If there is no page present at all, %NULL is returned.
- *
- * Return value: the selected page, or -1
- **/
-gint
-midori_browser_get_current_page (MidoriBrowser* browser)
-{
- g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
-
- return midori_notebook_get_index (MIDORI_NOTEBOOK (browser->notebook));
-}
-
-/**
- * midori_browser_set_current_item:
- * @browser: a #MidoriBrowser
- * @item: a #KatzeItem
- *
- * Switches to the page containing @item, see also midori_browser_set_current_page().
- *
- * The widget will also grab the focus automatically.
- *
- * Since: 0.4.8
- **/
-void
-midori_browser_set_current_item (MidoriBrowser* browser,
- KatzeItem* item)
-{
- guint i;
- guint n = katze_array_get_length (browser->proxy_array);
-
- for (i = 0; i < n; i++)
- {
- GtkWidget* view = midori_browser_get_nth_tab (browser, i);
- if (midori_view_get_proxy_item (MIDORI_VIEW (view)) == item)
- midori_browser_set_current_page (browser, i);
- }
-}
-
-/**
- * midori_browser_get_nth_tab:
- * @browser: a #MidoriBrowser
- * @n: the index of a tab
- *
- * Retrieves the tab at the position @n.
- *
- * If there is no page present at all, %NULL is returned.
- *
- * Return value: (type MidoriTab) (transfer none): the selected page, or %NULL
- *
- * Since: 0.1.9
- **/
-GtkWidget*
-midori_browser_get_nth_tab (MidoriBrowser* browser,
- gint n)
-{
- g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
-
- return (GtkWidget*)midori_notebook_get_nth_tab (MIDORI_NOTEBOOK (browser->notebook), n);
-}
-
-/**
- * midori_browser_set_tab:
- * @browser: a #MidoriBrowser
- * @view: a #GtkWidget
- *
- * Switches to the page containing @view.
- *
- * The widget will also grab the focus automatically.
- *
- * Since: 0.2.6
- **/
-void
-midori_browser_set_current_tab (MidoriBrowser* browser,
- GtkWidget* view)
-{
- g_return_if_fail (MIDORI_IS_BROWSER (browser));
- g_return_if_fail (GTK_IS_WIDGET (view));
-
- midori_notebook_set_tab (MIDORI_NOTEBOOK (browser->notebook), MIDORI_TAB (view));
- if (midori_tab_is_blank (MIDORI_TAB (view)))
- midori_browser_activate_action (browser, "Location");
- else
- gtk_widget_grab_focus (view);
-
- midori_browser_notify_tab_cb (browser->notebook, NULL, browser);
-}
-
-/**
- * midori_browser_get_current_tab:
- * @browser: a #MidoriBrowser
- *
- * Retrieves the currently selected tab.
- *
- * If there is no tab present at all, %NULL is returned.
- *
- * See also midori_browser_get_current_page().
- *
- * Return value: (transfer none): the selected tab, or %NULL
- *
- * Since: 0.2.6
- **/
-GtkWidget*
-midori_browser_get_current_tab (MidoriBrowser* browser)
-{
- g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
-
- return (GtkWidget*)midori_notebook_get_tab (MIDORI_NOTEBOOK (browser->notebook));
-}
-
-/**
- * midori_browser_get_tabs:
- * @browser: a #MidoriBrowser
- *
- * Retrieves the tabs as a list.
- *
- * Return value: (element-type MidoriView) (transfer container): the browser's tabs
- *
- * Since: 0.2.5
- **/
-GList*
-midori_browser_get_tabs (MidoriBrowser* browser)
-{
- g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
-
- return gtk_container_get_children (GTK_CONTAINER (browser->notebook));
-}
-
-/**
- * midori_browser_get_proxy_array:
- * @browser: a #MidoriBrowser
- *
- * Retrieves a proxy array representing the respective proxy items.
- * The array is updated automatically.
- *
- * Return value: (transfer none): the proxy #KatzeArray
- **/
-KatzeArray*
-midori_browser_get_proxy_array (MidoriBrowser* browser)
-{
- g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
-
- return browser->proxy_array;
-}
-
-/**
- * midori_browser_get_for_widget:
- * @widget: a #GtkWidget
- *
- * Determines the browser appropriate for the specified widget.
- *
- * Return value: (transfer none): a #MidoriBrowser, or %NULL
- *
- * Since 0.1.7
- **/
-MidoriBrowser*
-midori_browser_get_for_widget (GtkWidget* widget)
-{
- gpointer browser;
-
- g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
- browser = gtk_widget_get_toplevel (GTK_WIDGET (widget));
- if (!MIDORI_IS_BROWSER (browser))
- {
- if (!GTK_IS_WINDOW (browser))
- return NULL;
-
- browser = gtk_window_get_transient_for (GTK_WINDOW (browser));
- if (!MIDORI_IS_BROWSER (browser))
- {
- /* For some reason, when called on the widget of the
- * application menubar we get here.
- */
-
- GList* top_levels = gtk_window_list_toplevels ();
- GList *iter;
-
- for (iter = top_levels; iter; iter = g_list_next (iter))
- {
- browser = iter->data;
-
- if (MIDORI_IS_BROWSER (browser) && gtk_widget_is_ancestor( GTK_WIDGET (browser), widget))
- {
- g_list_free (top_levels);
- return MIDORI_BROWSER (browser);
- }
- }
-
- g_list_free (top_levels);
- return NULL;
- }
- }
-
- return MIDORI_BROWSER (browser);
-}
-
-/**
- * midori_browser_quit:
- * @browser: a #MidoriBrowser
- *
- * Quits the browser, including any other browser windows.
- *
- * This function relys on the application implementing
- * the MidoriBrowser::quit signal. If the browser was added
- * to the MidoriApp, this is handled automatically.
- **/
-void
-midori_browser_quit (MidoriBrowser* browser)
-{
- g_return_if_fail (MIDORI_IS_BROWSER (browser));
-
- g_signal_emit (browser, signals[QUIT], 0);
-}
diff --git a/midori/midori-browser.h b/midori/midori-browser.h
deleted file mode 100644
index bccf6204..00000000
--- a/midori/midori-browser.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- 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 __MIDORI_BROWSER_H__
-#define __MIDORI_BROWSER_H__
-
-#include <katze/katze.h>
-#include "midori-view.h"
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_BROWSER \
- (midori_browser_get_type ())
-#define MIDORI_BROWSER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_BROWSER, MidoriBrowser))
-#define MIDORI_BROWSER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_BROWSER, MidoriBrowserClass))
-#define MIDORI_IS_BROWSER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_BROWSER))
-#define MIDORI_IS_BROWSER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_BROWSER))
-#define MIDORI_BROWSER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_BROWSER, MidoriBrowserClass))
-
-typedef struct _MidoriBrowser MidoriBrowser;
-typedef struct _MidoriBrowserClass MidoriBrowserClass;
-
-struct _MidoriBrowserClass
-{
- MidoriWindowClass parent_class;
-
- /* Signals */
- void
- (*window_object_cleared) (MidoriBrowser* browser,
-#ifndef HAVE_WEBKIT2
- WebKitWebFrame* web_frame,
-#else
- void* web_frame,
-#endif
- JSContextRef* context,
- JSObjectRef* window_object);
- void
- (*statusbar_text_changed) (MidoriBrowser* browser,
- const gchar* text);
- void
- (*element_motion) (MidoriBrowser* browser,
- const gchar* link_uri);
- void
- (*new_window) (MidoriBrowser* browser,
- const gchar* uri);
-
- void
- (*add_tab) (MidoriBrowser* browser,
- GtkWidget* view);
- void
- (*remove_tab) (MidoriBrowser* browser,
- GtkWidget* view);
- void
- (*activate_action) (MidoriBrowser* browser,
- const gchar* name);
- void
- (*quit) (MidoriBrowser* browser);
-};
-
-GType
-midori_browser_get_type (void) G_GNUC_CONST;
-
-MidoriBrowser*
-midori_browser_new (void);
-
-void
-midori_browser_add_tab (MidoriBrowser* browser,
- GtkWidget* widget);
-
-void
-midori_browser_close_tab (MidoriBrowser* browser,
- GtkWidget* widget);
-
-GtkWidget*
-midori_browser_add_item (MidoriBrowser* browser,
- KatzeItem* item);
-
-GtkWidget*
-midori_browser_add_uri (MidoriBrowser* browser,
- const gchar* uri);
-
-void
-midori_browser_activate_action (MidoriBrowser* browser,
- const gchar* name);
-
-void
-midori_browser_assert_action (MidoriBrowser* browser,
- const gchar* name);
-
-void
-midori_browser_block_action (MidoriBrowser* browser,
- GtkAction* action);
-
-void
-midori_browser_unblock_action (MidoriBrowser* browser,
- GtkAction* action);
-
-void
-midori_browser_set_action_visible (MidoriBrowser* browser,
- const gchar* name,
- gboolean visible);
-
-GtkActionGroup*
-midori_browser_get_action_group (MidoriBrowser* browser);
-
-void
-midori_browser_set_current_uri (MidoriBrowser* browser,
- const gchar* uri);
-
-const gchar*
-midori_browser_get_current_uri (MidoriBrowser* browser);
-
-void
-midori_browser_set_current_page_smartly (MidoriBrowser* browser,
- gint n);
-
-void
-midori_browser_set_current_tab_smartly (MidoriBrowser* browser,
- GtkWidget* view);
-
-void
-midori_browser_set_current_page (MidoriBrowser* browser,
- gint n);
-
-gint
-midori_browser_get_current_page (MidoriBrowser* browser);
-
-void
-midori_browser_set_current_item (MidoriBrowser* browser,
- KatzeItem* item);
-
-GtkWidget*
-midori_browser_get_nth_tab (MidoriBrowser* browser,
- gint n);
-
-void
-midori_browser_set_current_tab (MidoriBrowser* browser,
- GtkWidget* widget);
-#define midori_browser_set_tab midori_browser_set_current_tab
-
-GtkWidget*
-midori_browser_get_current_tab (MidoriBrowser* browser);
-#define midori_browser_get_tab midori_browser_get_current_tab
-
-gint
-midori_browser_page_num (MidoriBrowser* browser,
- GtkWidget* view);
-
-GList*
-midori_browser_get_tabs (MidoriBrowser* browser);
-
-gint
-midori_browser_get_n_pages (MidoriBrowser* browser);
-
-KatzeArray*
-midori_browser_get_proxy_array (MidoriBrowser* browser);
-
-MidoriBrowser*
-midori_browser_get_for_widget (GtkWidget* widget);
-
-void
-midori_browser_quit (MidoriBrowser* browser);
-
-const gchar**
-midori_browser_get_toolbar_actions (MidoriBrowser* browser);
-
-MidoriWebSettings*
-midori_browser_get_settings (MidoriBrowser* browser);
-
-void
-midori_browser_update_history (KatzeItem* item,
- const gchar* type,
- const gchar* event);
-
-void
-midori_browser_save_uri (MidoriBrowser* browser,
- MidoriView* view,
- const gchar* uri);
-
-void
-midori_browser_set_inactivity_reset (MidoriBrowser* browser,
- gint inactivity_reset);
-
-G_END_DECLS
-
-#endif /* __MIDORI_BROWSER_H__ */
diff --git a/midori/midori-completion.vala b/midori/midori-completion.vala
deleted file mode 100644
index 3db2dc82..00000000
--- a/midori/midori-completion.vala
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- Copyright (C) 2012-2013 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.
-*/
-
-namespace Midori {
- public class Suggestion : GLib.Object {
- public string? uri { get; set; }
- public string? markup { get; set; }
- public bool use_markup { get; set; }
- public string? background { get; set; }
- public GLib.Icon? icon { get; set; }
- public bool action { get; set; default = false; }
- public int priority {get; set; default = 0; }
-
- public Suggestion (string? uri, string? markup, bool use_markup=false,
- string? background=null, GLib.Icon? icon=null, int? priority=0) {
-
- GLib.Object (uri: uri, markup: markup, use_markup: use_markup,
- background: background, icon: icon, priority: priority);
- }
- }
-
- public abstract class Completion : GLib.Object {
- public string? description { get; set; }
- public int max_items { get; internal set; default = 25; }
- internal int position { get; set; }
-
- public abstract void prepare (GLib.Object app);
- public abstract bool can_complete (string prefix);
- public abstract bool can_action (string action);
- public abstract async List<Suggestion>? complete (string text, string? action, Cancellable cancellable);
- }
-
- public class Autocompleter : GLib.Object {
- private GLib.Object app;
- private List<Completion> completions;
- private int next_position;
- public Gtk.ListStore model { get; private set; }
- private bool need_to_clear = false;
- private uint current_count = 0;
- private Cancellable? cancellable = null;
-
- public enum Columns {
- ICON,
- URI,
- MARKUP,
- BACKGROUND,
- YALIGN,
- SIZE,
- PRIORITY,
- N
- }
-
- public Autocompleter (GLib.Object app) {
- this.app = app;
- completions = new List<Completion> ();
- next_position = 0;
- model = new Gtk.ListStore (Columns.N,
- typeof (GLib.Icon), typeof (string), typeof (string),
- typeof (string), typeof (float), typeof (uint), typeof (int));
- }
-
- public void add (Completion completion) {
- completion.prepare (app);
- completion.position = next_position;
- next_position += completion.max_items;
- completions.append (completion);
- }
-
- public bool can_complete (string text) {
- foreach (unowned Completion completion in completions)
- if (completion.can_complete (text))
- return true;
- return false;
- }
-
- private GLib.Icon? scale_if_needed (GLib.Icon? icon) {
- if (icon is Gdk.Pixbuf) {
- var pixbuf = icon as Gdk.Pixbuf;
- int icon_width = 16, icon_height = 16;
- Gtk.icon_size_lookup (Gtk.IconSize.MENU, out icon_width, out icon_height);
- if (pixbuf.width > icon_width || pixbuf.height > icon_height)
- return pixbuf.scale_simple (icon_width, icon_height, Gdk.InterpType.BILINEAR);
- }
- return icon;
- }
-
- private void fill_model (Midori.Completion completion, List<Midori.Suggestion>? suggestions) {
- if (need_to_clear) {
- model.clear ();
- need_to_clear = false;
- current_count = 0;
- }
- int start = 0;
- // find the first index with priority greater than the current one
- Gtk.TreeModelForeachFunc find_index = (model, path, iter) => {
- GLib.Value priority;
-
- model.get_value (iter,Columns.PRIORITY, out priority);
- if ((int)priority < completion.position) {
- start++;
- return false;
- }
- return true;
- };
- model.foreach(find_index);
- int count = 0;
- if (completion.description != null) {
- model.insert_with_values (null, start,
- Columns.URI, "about:completion-description",
- Columns.MARKUP, "<b>%s</b>\n".printf (Markup.escape_text (completion.description)),
- Columns.ICON, null,
- Columns.SIZE, Gtk.IconSize.MENU,
- Columns.BACKGROUND, null,
- Columns.YALIGN, 0.25,
- Columns.PRIORITY, completion.position);
- count++;
- }
-
- foreach (unowned Suggestion suggestion in suggestions) {
- if (suggestion.uri == null) {
- warning ("suggestion.uri != null");
- continue;
- }
- if (suggestion.markup == null) {
- warning ("suggestion.markup != null");
- continue;
- }
- model.insert_with_values (null, start + count,
- Columns.URI, suggestion.uri,
- Columns.MARKUP, suggestion.use_markup
- ? suggestion.markup : Markup.escape_text (suggestion.markup),
- Columns.ICON, scale_if_needed (suggestion.icon),
- Columns.SIZE, Gtk.IconSize.MENU,
- Columns.BACKGROUND, suggestion.background,
- Columns.YALIGN, 0.25,
- Columns.PRIORITY, completion.position);
-
- count++;
- if (count > completion.max_items)
- break;
- }
-
- current_count += count;
- populated (current_count);
- }
-
- public signal void populated (uint count);
-
- private async void complete_wrapped (Completion completion, string text, string? action, Cancellable cancellable) {
- List<Midori.Suggestion>? suggestions = yield completion.complete (text, action, cancellable);
- if (!cancellable.is_cancelled () && suggestions != null)
- fill_model (completion, suggestions);
- }
-
- public async void complete (string text) {
- if (cancellable != null)
- cancellable.cancel ();
- cancellable = new Cancellable ();
- need_to_clear = true;
-
- foreach (unowned Completion completion in completions) {
- if (completion.can_complete (text))
- yield complete_wrapped (completion, text, null, cancellable);
- }
- }
-
- public bool can_action (string action) {
- if (action == "about:completion-description")
- return true;
- foreach (unowned Completion completion in completions)
- if (completion.can_action (action))
- return true;
- return false;
- }
-
- public async void action (string action, string text) {
- if (action == "about:completion-description")
- return;
-
- if (cancellable != null)
- cancellable.cancel ();
- cancellable = new Cancellable ();
- need_to_clear = true;
-
- foreach (unowned Completion completion in completions) {
- if (completion.can_action (action))
- complete_wrapped.begin (completion, text, action, cancellable);
- }
- }
- }
-}
diff --git a/midori/midori-contextaction.vala b/midori/midori-contextaction.vala
deleted file mode 100644
index f911c20e..00000000
--- a/midori/midori-contextaction.vala
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- Copyright (C) 2013 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.
-*/
-
-namespace Midori {
- /* A context action represents an item that can be shown in a menu
- or toolbar. Context actions can be nested as needed.
- Since: 0.5.5 */
- public class ContextAction : Gtk.Action {
- List<Gtk.ActionGroup> action_groups;
- List<Gtk.Action> children;
- public ContextAction (string name, string? label, string? tooltip, string? stock_id) {
- GLib.Object (name: name, label: label, tooltip: tooltip, stock_id: stock_id);
- action_groups = new List<Gtk.ActionGroup> ();
- children = new List<ContextAction> ();
- }
-
- /*
- The action label will be escaped for mnemonics so for example
- "a_fairy_tale" will not get accel keys on "f" or "t".
-
- Since: 0.5.8
- */
- public ContextAction.escaped (string name, string label, string? tooltip, string? stock_id) {
- string? escaped_label = label.replace ("_", "__");
- GLib.Object (name: name, label: escaped_label, tooltip: tooltip, stock_id: stock_id);
- action_groups = new List<Gtk.ActionGroup> ();
- children = new List<ContextAction> ();
- }
-
- public delegate void ActionActivateCallback (Gtk.Action action);
- public void add_simple (string name, string? label, string? tooltip, string? stock_id, ActionActivateCallback callback) {
- var action = new ContextAction (name, label, tooltip, stock_id);
- action.activate.connect (() => { callback (action); });
- add (action);
- }
-
- public void add (Gtk.Action? action) {
- if (action == null) {
- add (new SeparatorContextAction ());
- return;
- }
-
- children.append (action);
- if (action is ContextAction) {
- foreach (var action_group in action_groups)
- (action as ContextAction).add_action_group (action_group);
- }
- }
-
- public void add_action_group (Gtk.ActionGroup action_group) {
- action_groups.append (action_group);
- }
-
- public void add_by_name (string name) {
- foreach (var action_group in action_groups) {
- var action = action_group.get_action (name);
- if (action != null) {
- add (action);
- return;
- }
- }
- warning ("Action %s not known to ContextAction", name);
- }
-
-#if HAVE_WEBKIT2
- public WebKit.ContextMenu create_webkit_context_menu (WebKit.ContextMenu? default_menu) {
- var menu = default_menu ?? new WebKit.ContextMenu ();
- foreach (var action in children) {
- WebKit.ContextMenuItem menuitem;
- if (action is SeparatorContextAction)
- menuitem = new WebKit.ContextMenuItem.separator ();
- else if (action is ContextAction
- && (action as ContextAction).children.nth_data (0) != null) {
- menuitem = new WebKit.ContextMenuItem (action);
- menuitem.set_submenu ((action as ContextAction).create_webkit_context_menu (null));
- }
- else
- menuitem = new WebKit.ContextMenuItem (action);
- // Visibility of the action is ignored, so we skip hidden items
- if (action.visible)
- menu.append (menuitem);
- }
- return menu;
- }
-#endif
-
- Gtk.ToolButton toolitem;
- public override unowned Gtk.Widget create_tool_item () {
- toolitem = base.create_tool_item () as Gtk.ToolButton;
- toolitem.clicked.connect (() => {
- var popup = create_menu (null, false);
- popup.show ();
- popup.attach_to_widget (toolitem, null);
- popup.popup (null, null, null, 1, Gtk.get_current_event_time ());
- });
- return toolitem;
- }
-
- public new Gtk.Menu create_menu (Gtk.Menu? default_menu, bool accels) {
- var menu = default_menu ?? new Gtk.Menu ();
- foreach (var action in children) {
- Gtk.MenuItem menuitem;
- if (action is SeparatorContextAction) {
- menuitem = new Gtk.SeparatorMenuItem ();
- menuitem.show ();
- }
- else if (action is ContextAction
- && (action as ContextAction).children.nth_data (0) != null) {
- menuitem = action.create_menu_item () as Gtk.MenuItem;
- menuitem.submenu = (action as ContextAction).create_menu (null, accels);
- }
- else
- menuitem = action.create_menu_item () as Gtk.MenuItem;
- /* Disable accels from the action in context menus */
- if (!accels) {
- var accel_label = menuitem.get_child () as Gtk.AccelLabel;
- if (accel_label != null)
- accel_label.accel_closure = null;
- }
- menu.append (menuitem);
- }
- return menu;
- }
-
- public Gtk.Action? get_by_name (string name) {
- foreach (var action in children)
- if (action.name == name)
- return action;
- return null;
- }
- }
-
- public class SeparatorContextAction : ContextAction {
- public SeparatorContextAction () {
- GLib.Object (name: "SeparatorContextAction", label: null, tooltip: null, stock_id: null);
- }
- }
-}
diff --git a/midori/midori-dialog.vala b/midori/midori-dialog.vala
deleted file mode 100644
index 64736c10..00000000
--- a/midori/midori-dialog.vala
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- Copyright (C) 2011-2013 Christian Dywan <christian@twotoats.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.
-*/
-
-namespace Midori {
- namespace Timeout {
- public uint add_seconds (uint interval, owned SourceFunc function) {
- if (Test.test_idle_timeouts)
- return GLib.Idle.add (function);
- return GLib.Timeout.add_seconds (interval, function);
- }
- public uint add (uint interval, owned SourceFunc function) {
- if (Test.test_idle_timeouts)
- return GLib.Idle.add (function);
- return GLib.Timeout.add (interval, function);
- }
- }
-
- namespace Test {
- public void init ([CCode (array_length_pos = 0.9)] ref unowned string[] args) {
- GLib.Test.init (ref args);
-
- /* Always log to stderr */
- Log.set_handler (null,
- LogLevelFlags.LEVEL_MASK | LogLevelFlags.FLAG_FATAL | LogLevelFlags.FLAG_RECURSION,
- (domain, log_levels, message) => {
- stderr.printf ("** %s\n", message);
- });
- }
-
- internal static uint test_max_timeout = 0;
- internal static string? test_first_try = null;
- public void grab_max_timeout () {
- int seconds = (Environment.get_variable ("MIDORI_TIMEOUT") ?? "42").to_int ();
- test_first_try = "once";
- test_max_timeout = GLib.Timeout.add_seconds (seconds > 0 ? seconds / 2 : 0, ()=>{
- stderr.printf ("Timed out %s%s\n", test_first_try,
- MainContext.default ().pending () ? " (loop)" : "");
- if (test_first_try == "twice")
- Process.exit (0);
- test_first_try = "twice";
- MainContext.default ().wakeup ();
- return true;
- });
- }
- public void release_max_timeout () {
- assert (test_max_timeout > 0);
- GLib.Source.remove (test_max_timeout);
- test_max_timeout = 0;
- }
-
- internal static bool test_idle_timeouts = false;
- public void idle_timeouts () {
- test_idle_timeouts = true;
- }
-
- public abstract class Job : GLib.Object {
- bool done;
- public abstract async void run (Cancellable cancellable) throws GLib.Error;
- async void run_wrapped (Cancellable cancellable) {
- try {
- yield run (cancellable);
- } catch (Error error) {
- GLib.error (error.message);
- }
- done = true;
- }
- public void run_sync () {
- var loop = MainContext.default ();
- var cancellable = new Cancellable ();
- done = false;
- run_wrapped.begin (cancellable);
- do { loop.iteration (true); } while (!done);
- }
- }
-
- public void log_set_fatal_handler_for_icons () {
- GLib.Test.log_set_fatal_handler ((domain, log_levels, message)=> {
- return !message.contains ("Error loading theme icon")
- && !message.contains ("Could not find the icon")
- && !message.contains ("Junk at end of value")
- && !message.contains ("gtk_notebook_get_tab_label: assertion `GTK_IS_WIDGET (child)' failed")
- && !message.contains ("get_column_number: assertion `i < gtk_tree_view_get_n_columns (treeview)' failed");
- });
-
- }
-
- internal static Gtk.ResponseType test_response = Gtk.ResponseType.NONE;
- public void set_dialog_response (Gtk.ResponseType response) {
- test_response = response;
- }
-
- internal static string? test_filename = null;
- public void set_file_chooser_filename (string filename) {
- test_filename = filename;
- }
- }
-
- public static void show_message_dialog (Gtk.MessageType type, string short, string detailed, bool modal) {
- var dialog = new Gtk.MessageDialog (null, 0, type, Gtk.ButtonsType.OK, "%s", short);
- dialog.format_secondary_text ("%s", detailed);
- if (modal) {
- dialog.run ();
- dialog.destroy ();
- } else {
- dialog.response.connect ((response) => {
- dialog.destroy ();
- });
- dialog.show ();
- }
- }
-
- public class FileChooserDialog : Gtk.FileChooserDialog {
- public FileChooserDialog (string title, Gtk.Window? window, Gtk.FileChooserAction action) {
- /* Creates a new file chooser dialog to Open or Save and Cancel.
- The positive response is %Gtk.ResponseType.OK. */
- unowned string stock_id = Gtk.Stock.OPEN;
- if (action == Gtk.FileChooserAction.SAVE)
- stock_id = Gtk.Stock.SAVE;
- this.title = title;
- transient_for = window;
- this.action = action;
- add_buttons (Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL,
- stock_id, Gtk.ResponseType.OK);
- icon_name = stock_id;
- }
- }
-
- namespace Dialog {
- public static new int run (Gtk.Dialog dialog) {
- if (Test.test_response != Gtk.ResponseType.NONE) {
- if (Test.test_filename != null && dialog is Gtk.FileChooser)
- (dialog as Gtk.FileChooser).set_filename (Test.test_filename);
- return Test.test_response;
- }
- return dialog.run ();
- }
- }
-}
-
diff --git a/midori/midori-download.vala b/midori/midori-download.vala
deleted file mode 100644
index 4a4da440..00000000
--- a/midori/midori-download.vala
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- Copyright (C) 2012-2013 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.
-*/
-
-namespace Sokoke {
- extern static bool message_dialog (Gtk.MessageType type, string short, string detailed, bool modal);
-}
-
-namespace Midori {
- namespace Download {
- public static bool is_finished (WebKit.Download download) {
-#if !HAVE_WEBKIT2
- switch (download.status) {
- case WebKit.DownloadStatus.FINISHED:
- case WebKit.DownloadStatus.CANCELLED:
- case WebKit.DownloadStatus.ERROR:
- return true;
- default:
- return false;
- }
-#else
- if (download.estimated_progress == 1)
- return true;
- return false;
-#endif
- }
-
- public static int get_type (WebKit.Download download) {
- return download.get_data<int> ("midori-download-type");
- }
-
- public static void set_type (WebKit.Download download, int type) {
- download.set_data<int> ("midori-download-type", type);
- }
-
-#if HAVE_WEBKIT2
- public static string get_filename (WebKit.Download download) {
- return download.get_data<string> ("midori-download-filename");
- }
- public static void set_filename (WebKit.Download download, string name) {
- download.set_data<string> ("midori-download-filename", name);
- }
-#endif
- public static double get_progress (WebKit.Download download) {
-#if !HAVE_WEBKIT2
- /* Avoid a bug in WebKit */
- if (download.status == WebKit.DownloadStatus.CREATED)
- return 0.0;
- return download.progress;
-#else
- return download.estimated_progress;
-#endif
- }
-
- public static string calculate_tooltip (WebKit.Download download) {
-#if !HAVE_WEBKIT2
- string filename = Midori.Download.get_basename_for_display (download.destination_uri);
- /* i18n: Download tooltip (size): 4KB of 43MB */
- string size = _("%s of %s").printf (
- format_size (download.current_size),
- format_size (download.total_size));
-
- /* Finished, no speed or remaining time */
- if (is_finished (download) || download.status == WebKit.DownloadStatus.CREATED)
- return "%s\n%s".printf (filename, size);
-
- uint64 total_size = download.total_size, current_size = download.current_size;
- double elapsed = download.get_elapsed_time (),
- diff = elapsed / current_size,
- estimated = (total_size - current_size) * diff;
- int hour = 3600, minute = 60;
- int hours = (int)(estimated / hour),
- minutes = (int)((estimated - (hours * hour)) / minute),
- seconds = (int)((estimated - (hours * hour) - (minutes * minute)));
- string hours_ = ngettext ("%d hour", "%d hours", hours).printf (hours);
- string minutes_ = ngettext ("%d minute", "%d minutes", minutes).printf (minutes);
- string seconds_ = ngettext ("%d second", "%d seconds", seconds).printf (seconds);
- double last_time = download.get_data<int> ("last-time");
-
- string eta = "";
- if (estimated > 0) {
- if (hours > 0)
- eta = hours_ + ", " + minutes_;
- else if (minutes >= 10)
- eta = minutes_;
- else if (minutes < 10 && minutes > 0)
- eta = minutes_ + ", " + seconds_;
- else if (seconds > 0)
- eta = seconds_;
- if (eta != "")
- /* i18n: Download tooltip (estimated time) : - 1 hour, 5 minutes remaning */
- eta = _(" - %s remaining").printf (eta);
- }
-
- string speed = "";
- uint64? last_size = download.get_data<uint64?> ("last-size");
- if (last_size != null && elapsed != last_time) {
- if (current_size != last_size) {
- speed = format_size ((uint64)(
- (current_size - last_size) / (elapsed - last_time)));
- download.set_data ("last-speed", speed.dup ());
- }
- else {
- speed = download.get_data ("last-speed");
- }
- }
- else
- /* i18n: Unknown number of bytes, used for transfer rate like ?B/s */
- speed = _("?B");
- /* i18n: Download tooltip (transfer rate): (130KB/s) */
- speed = _(" (%s/s)").printf (speed);
-
- if (elapsed - last_time > 0.0) {
- download.set_data<int> ("last-time", (int)elapsed);
- download.set_data<uint64?> ("last-size", current_size);
- }
-
- return "%s\n%s %s%s".printf (filename, size, speed, eta);
-#else
- string filename = Midori.Download.get_basename_for_display (download.destination);
-
- string size = "%s".printf (format_size (download.get_received_data_length ()));
- string speed = "";
- speed = format_size ((uint64)((download.get_received_data_length () * 1.0) / download.get_elapsed_time ()));
- speed = _(" (%s/s)").printf (speed);
- string progress = "%d%%".printf( (int) (download.get_estimated_progress ()*100));
- if (is_finished (download))
- return "%s\n %s".printf (filename, size);
- return "%s\n %s - %s".printf (filename, speed, progress);
-#endif
- }
-
- public static string get_content_type (WebKit.Download download, string? mime_type) {
-#if HAVE_WEBKIT2
- string? content_type = ContentType.guess (download.response.suggested_filename == null ?
- download.destination : download.response.suggested_filename,
- null, null);
-#else
- string? content_type = ContentType.guess (download.suggested_filename, null, null);
-#endif
- if (content_type == null) {
- content_type = ContentType.from_mime_type (mime_type);
- if (content_type == null)
- content_type = ContentType.from_mime_type ("application/octet-stream");
- }
- return content_type;
- }
-
- public static bool has_wrong_checksum (WebKit.Download download) {
- int status = download.get_data<int> ("checksum-status");
- if (status == 0) {
- /* Link Fingerprint */
- #if HAVE_WEBKIT2
- string? original_uri = download.get_request ().uri;
- #else
- string? original_uri = download.network_request.get_data<string> ("midori-original-uri");
- if (original_uri == null)
- original_uri = download.get_uri ();
- #endif
- string? fingerprint;
- ChecksumType checksum_type = URI.get_fingerprint (original_uri, out fingerprint, null);
- /* By default, no wrong checksum */
- status = 2;
- if (fingerprint != null) {
- try {
- #if HAVE_WEBKIT2
- string filename = Filename.from_uri (download.destination);
- #else
- string filename = Filename.from_uri (download.destination_uri);
- #endif
- string contents;
- size_t length;
- bool y = FileUtils.get_contents (filename, out contents, out length);
- string checksum = Checksum.compute_for_string (checksum_type, contents, length);
- /* Checksums are case-insensitive */
- if (!y || fingerprint.ascii_casecmp (checksum) != 0)
- status = 1; /* wrong checksum */
- }
- catch (Error error) {
- status = 1; /* wrong checksum */
- }
- }
- download.set_data<int> ("checksum-status", status);
- }
- return status == 1;
-
- }
-
- public static bool action_clear (WebKit.Download download, Gtk.Widget widget) throws Error {
-#if !HAVE_WEBKIT2
- switch (download.status) {
- case WebKit.DownloadStatus.CREATED:
- case WebKit.DownloadStatus.STARTED:
- download.cancel ();
- break;
- case WebKit.DownloadStatus.FINISHED:
- if (open (download, widget))
- return true;
- break;
- case WebKit.DownloadStatus.CANCELLED:
- return true;
- default:
- critical ("action_clear: %d", download.status);
- warn_if_reached ();
- break;
- }
- #else
-
- if (download.estimated_progress < 1) {
- download.cancel ();
- } else {
- if (open (download, widget))
- return true;
- }
-#endif
- return false;
- }
-
- public static string action_stock_id (WebKit.Download download) {
-#if !HAVE_WEBKIT2
- switch (download.status) {
- case WebKit.DownloadStatus.CREATED:
- case WebKit.DownloadStatus.STARTED:
- return Gtk.Stock.CANCEL;
- case WebKit.DownloadStatus.FINISHED:
- if (has_wrong_checksum (download))
- return Gtk.Stock.DIALOG_WARNING;
- return Gtk.Stock.OPEN;
- case WebKit.DownloadStatus.CANCELLED:
- return Gtk.Stock.CLEAR;
- case WebKit.DownloadStatus.ERROR:
- return Gtk.Stock.DIALOG_ERROR;
- default:
- critical ("action_stock_id: %d", download.status);
- warn_if_reached ();
- return Gtk.Stock.MISSING_IMAGE;
- }
-#else
- if (download.estimated_progress == 1)
- if (has_wrong_checksum (download))
- return Gtk.Stock.DIALOG_WARNING;
- else
- return Gtk.Stock.OPEN;
- return Gtk.Stock.CANCEL;
-#endif
- }
-
- /* returns whether an application was successfully launched to handle the file */
- public static bool open (WebKit.Download download, Gtk.Widget widget) throws Error {
- if (has_wrong_checksum (download)) {
- Sokoke.message_dialog (Gtk.MessageType.WARNING,
- _("The downloaded file is erroneous."),
- _("The checksum provided with the link did not match. This means the file is probably incomplete or was modified afterwards."),
- true);
- return true;
- } else {
- var browser = widget.get_toplevel ();
- Tab? tab = null;
- browser.get ("tab", &tab);
- if (tab != null)
- #if HAVE_WEBKIT2
- return tab.open_uri (download.destination);
- #else
- return tab.open_uri (download.destination_uri);
- #endif
- }
- return false;
- }
-
- public unowned string fallback_extension (string? extension, string mime_type) {
- if (extension != null && extension[0] != '\0')
- return extension;
- if ("css" in mime_type)
- return ".css";
- if ("javascript" in mime_type)
- return ".js";
- if ("html" in mime_type)
- return ".htm";
- if ("plain" in mime_type)
- return ".txt";
- return "";
- }
-
- public string clean_filename (string filename) {
- #if HAVE_WIN32
- return filename.delimit ("/\\<>:\"|?* ", '_');
- #else
- return filename.delimit ("/ ", '_');
- #endif
- }
-
- public string get_suggested_filename (WebKit.Download download) {
-#if !HAVE_WEBKIT2
- /* https://bugs.webkit.org/show_bug.cgi?id=83161
- https://d19vezwu8eufl6.cloudfront.net/nlp/slides%2F03-01-FormalizingNB.pdf */
- return clean_filename (download.get_suggested_filename ());
-#else
- string name = get_filename (download);
- if (name == null)
- return "";
- return name;
-#endif
- }
-
- /**
- * Returns a filename of the form "name.ext" to use as a suggested name for
- * a download of the given uri
- */
- public string get_filename_suggestion_for_uri (string mime_type, string uri) {
- return_val_if_fail (Midori.URI.is_location (uri), uri);
- string filename = File.new_for_uri (uri).get_basename ();
- if (uri.index_of_char ('.') == -1)
- return Path.build_filename (filename, fallback_extension (null, mime_type));
- return filename;
- }
-
- public static string? get_extension_for_uri (string uri, out string basename = null) {
- basename = null;
- /* Find the last slash and the last period *after* the last slash. */
- int last_slash = uri.last_index_of_char ('/');
- /* Huh, URI without slashes? */
- if (last_slash == -1)
- return null;
- int period = uri.last_index_of_char ('.', last_slash);
- if (period == -1)
- return null;
- /* Exclude the query: ?query=foobar */
- int query = uri.last_index_of_char ('?', period);
- /* The extension, or "." if it ended with a period */
- string extension = uri.substring (period, query - period);
- basename = uri.substring (0, period);
- return extension;
-
- }
-
- public string get_unique_filename (string filename) {
- if (GLib.FileUtils.test (filename, GLib.FileTest.EXISTS)) {
- string basename;
- string? extension = get_extension_for_uri (filename, out basename);
- string? new_filename = null;
- int i = 0;
- do {
- new_filename = "%s-%d%s".printf (basename, i++, extension ?? "");
- } while (GLib.FileUtils.test (new_filename, GLib.FileTest.EXISTS));
- return new_filename;
- }
- return filename;
- }
-
- /**
- * Returns a string showing a file:// URI's intended filename on
- * disk, suited for displaying to a user.
- *
- * The string returned is the basename (final path segment) of the
- * filename of the uri. If the uri is invalid, not file://, or has no
- * basename, the uri itself is returned.
- *
- * Since: 0.5.7
- **/
- public static string get_basename_for_display (string uri) {
- try {
- string filename = Filename.from_uri (uri);
- if(filename != null && filename != "")
- return Path.get_basename (filename);
- } catch (Error error) { }
- return uri;
- }
-
- public string prepare_destination_uri (WebKit.Download download, string? folder) {
- string suggested_filename = get_suggested_filename (download);
- string basename = Path.get_basename (suggested_filename);
- string download_dir;
- if (folder == null) {
- download_dir = Paths.get_tmp_dir ();
- Katze.mkdir_with_parents (download_dir, 0700);
- }
- else
- download_dir = folder;
- string destination_filename = Path.build_filename (download_dir, basename);
- try {
- return Filename.to_uri (get_unique_filename (destination_filename));
- }
- catch (Error error) {
- return "file://" + destination_filename;
- }
- }
-
- /**
- * Returns whether it seems possible to save @download to the path specified by
- * @destination_uri, considering space on disk and permissions
- */
- public static bool has_enough_space (WebKit.Download download, string destination_uri, bool quiet=false) {
-#if !HAVE_WEBKIT2
- var folder = File.new_for_uri (destination_uri).get_parent ();
- bool can_write;
- uint64 free_space;
- try {
- var info = folder.query_filesystem_info ("filesystem::free");
- free_space = info.get_attribute_uint64 ("filesystem::free");
- info = folder.query_info ("access::can-write", 0);
- can_write = info.get_attribute_boolean ("access::can-write");
- }
- catch (Error error) {
- can_write = false;
- free_space = 0;
- }
-
- if (free_space < download.total_size || !can_write) {
- string message;
- string detailed_message;
- if (!can_write) {
- message = _("The file \"%s\" can't be saved in this folder.").printf (
- Midori.Download.get_basename_for_display (destination_uri));
- detailed_message = _("You don't have permission to write in this location.");
- }
- else if (free_space < download.total_size) {
- message = _("There is not enough free space to download \"%s\".").printf (
- Midori.Download.get_basename_for_display (destination_uri));
- detailed_message = _("The file needs %s but only %s are left.").printf (
- format_size (download.total_size), format_size (free_space));
- }
- else
- assert_not_reached ();
- if (!quiet)
- Sokoke.message_dialog (Gtk.MessageType.ERROR, message, detailed_message, false);
- return false;
- }
-#endif
- return true;
- }
- }
-}
diff --git a/midori/midori-extension.c b/midori/midori-extension.c
deleted file mode 100644
index 634d7e4d..00000000
--- a/midori/midori-extension.c
+++ /dev/null
@@ -1,1259 +0,0 @@
-/*
- Copyright (C) 2008-2013 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2009 Dale Whittaker <dayul@users.sf.net>
-
- 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.
-*/
-
-#include "midori-extension.h"
-
-#include <katze/katze.h>
-#include "midori-platform.h"
-#include "midori-core.h"
-#include <glib/gi18n.h>
-
-G_DEFINE_TYPE (MidoriExtension, midori_extension, G_TYPE_OBJECT);
-
-struct _MidoriExtensionPrivate
-{
- gchar* stock_id;
- gchar* name;
- gchar* description;
- gboolean use_markup;
- gchar* version;
- gchar* authors;
- gchar* website;
- gchar* key;
-
- MidoriApp* app;
- gint active;
- gchar* config_dir;
- GList* lsettings;
- GHashTable* settings;
- GKeyFile* key_file;
-};
-
-typedef struct
-{
- gchar* name;
- GType type;
- gboolean default_value;
- gboolean value;
-} MESettingBoolean;
-
-typedef struct
-{
- gchar* name;
- GType type;
- gint default_value;
- gint value;
-} MESettingInteger;
-
-typedef struct
-{
- gchar* name;
- GType type;
- gchar* default_value;
- gchar* value;
-} MESettingString;
-
-typedef struct
-{
- gchar* name;
- GType type;
- gchar** default_value;
- gchar** value;
- gsize default_length;
- gsize length;
-} MESettingStringList;
-
-void me_setting_free (gpointer setting)
-{
- /* setting->name is freed by the GHashTable itself */
- MESettingString* string_setting = (MESettingString*)setting;
- MESettingStringList* strlist_setting = (MESettingStringList*)setting;
-
- if (string_setting->type == G_TYPE_STRING)
- {
- g_free (string_setting->default_value);
- g_free (string_setting->value);
- }
- if (strlist_setting->type == G_TYPE_STRV)
- {
- g_strfreev (strlist_setting->default_value);
- g_strfreev (strlist_setting->value);
- }
- g_free (setting);
-}
-
-#define midori_extension_can_install_setting(extension, name) \
- if (extension->priv->active > 0) \
- { \
- g_critical ("%s: Settings have to be installed before " \
- "the extension is activated.", G_STRFUNC); \
- return; \
- } \
- if (g_hash_table_lookup (extension->priv->settings, name)) \
- { \
- g_critical ("%s: A setting with the name '%s' is already installed.", \
- G_STRFUNC, name); \
- return; \
- }
-
-#define me_setting_install(stype, _name, gtype, _default_value, _value) \
- setting = g_new (stype, 1); \
- setting->name = _name; \
- setting->type = gtype; \
- setting->default_value = _default_value; \
- setting->value = _value; \
- g_hash_table_insert (extension->priv->settings, setting->name, setting); \
- extension->priv->lsettings = g_list_prepend \
- (extension->priv->lsettings, setting);
-
-#define me_setting_type(setting, gtype, rreturn) \
-if (!setting) { \
-g_critical ("%s: There is no setting with the name '%s' installed.", G_STRFUNC, name); \
-rreturn; } \
-if (setting->type != gtype) { \
-g_critical ("%s: The setting '%s' is not a string.", G_STRFUNC, name); \
-rreturn; }
-
-enum
-{
- PROP_0,
-
- PROP_STOCK_ID,
- PROP_NAME,
- PROP_DESCRIPTION,
- PROP_USE_MARKUP,
- PROP_VERSION,
- PROP_AUTHORS,
- PROP_WEBSITE,
- PROP_KEY
-};
-
-enum {
- ACTIVATE,
- DEACTIVATE,
- OPEN_PREFERENCES,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-midori_extension_finalize (GObject* object);
-
-static void
-midori_extension_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_extension_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_extension_class_init (MidoriExtensionClass* class)
-{
- GObjectClass* gobject_class;
- GParamFlags flags;
-
- signals[ACTIVATE] = g_signal_new (
- "activate",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- MIDORI_TYPE_APP);
-
- signals[DEACTIVATE] = g_signal_new (
- "deactivate",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0,
- G_TYPE_NONE);
-
- /**
- * MidoriExtension::open-preferences:
- *
- * The preferences of the extension should be opened.
- *
- * Since: 0.4.0
- */
- signals[OPEN_PREFERENCES] = g_signal_new (
- "open-preferences",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0,
- G_TYPE_NONE);
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = midori_extension_finalize;
- gobject_class->set_property = midori_extension_set_property;
- gobject_class->get_property = midori_extension_get_property;
-
- flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS;
-
- g_object_class_install_property (gobject_class,
- PROP_STOCK_ID,
- g_param_spec_string (
- "stock-id",
- "Stock ID",
- "An optional icon stock ID",
- NULL,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_NAME,
- g_param_spec_string (
- "name",
- "Name",
- "The name of the extension",
- NULL,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_DESCRIPTION,
- g_param_spec_string (
- "description",
- "Description",
- "The description of the extension",
- NULL,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_USE_MARKUP,
- g_param_spec_boolean (
- "use-markup",
- "Use Markup",
- "Whether to use Pango markup",
- FALSE,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_VERSION,
- g_param_spec_string (
- "version",
- "Version",
- "The version of the extension",
- NULL,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_AUTHORS,
- g_param_spec_string (
- "authors",
- "Authors",
- "The authors of the extension",
- NULL,
- flags));
-
- /**
- * MidoriExtension:website:
- *
- * The website of the extension.
- *
- * Since: 0.1.8
- */
- g_object_class_install_property (gobject_class,
- PROP_WEBSITE,
- g_param_spec_string (
- "website",
- "Website",
- "The website of the extension",
- NULL,
- flags));
-
- /**
- * MidoriExtension:key:
- *
- * The extension key.
- * Needed if there is more than one extension object in a single module.
- *
- * Since: 0.4.5
- */
- g_object_class_install_property (gobject_class,
- PROP_KEY,
- g_param_spec_string (
- "key",
- "Key",
- "The extension key",
- NULL,
- flags));
-
- g_type_class_add_private (class, sizeof (MidoriExtensionPrivate));
-}
-
-static void
-midori_extension_activate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- GList* lsettings;
-
- g_return_if_fail (MIDORI_IS_APP (app));
-
- lsettings = g_list_first (extension->priv->lsettings);
-
- /* If a configuration directory was requested before activation we
- assume we should load and save settings. This is a detail that
- extension writers shouldn't worry about. */
- extension->priv->key_file = lsettings && extension->priv->config_dir
- ? g_key_file_new () : NULL;
- if (extension->priv->key_file)
- {
- gchar* config_file;
- GError* error = NULL;
-
- config_file = g_build_filename (extension->priv->config_dir, "config", NULL);
- if (!g_key_file_load_from_file (extension->priv->key_file, config_file,
- G_KEY_FILE_KEEP_COMMENTS, &error))
- {
- if (error->code == G_FILE_ERROR_NOENT)
- {
- gchar* filename = g_object_get_data (G_OBJECT (extension), "filename");
- katze_assign (config_file,
- midori_paths_get_extension_preset_filename (filename, "config"));
- g_key_file_load_from_file (extension->priv->key_file, config_file,
- G_KEY_FILE_KEEP_COMMENTS, NULL);
- }
- else
- printf (_("The configuration of the extension '%s' couldn't be loaded: %s\n"),
- extension->priv->name, error->message);
- g_error_free (error);
- }
- g_free (config_file);
- }
-
- while (lsettings)
- {
- MESettingString* setting = (MESettingString*)lsettings->data;
-
- if (setting->type == G_TYPE_BOOLEAN)
- {
- MESettingBoolean* setting_ = (MESettingBoolean*)setting;
- if (extension->priv->key_file
- && g_key_file_has_key (extension->priv->key_file, "settings", setting_->name, NULL))
- setting_->value = g_key_file_get_boolean (extension->priv->key_file,
- "settings", setting->name, NULL);
- else
- setting_->value = setting_->default_value;
- }
- else if (setting->type == G_TYPE_INT)
- {
- MESettingInteger* setting_ = (MESettingInteger*)setting;
- if (extension->priv->key_file
- && g_key_file_has_key (extension->priv->key_file, "settings", setting_->name, NULL))
- setting_->value = g_key_file_get_integer (extension->priv->key_file,
- "settings", setting_->name, NULL);
- else
- setting_->value = setting_->default_value;
- }
- else if (setting->type == G_TYPE_STRING)
- {
- if (extension->priv->key_file)
- {
- setting->value = g_key_file_get_string (
- extension->priv->key_file, "settings", setting->name, NULL);
- if (setting->value == NULL)
- setting->value = setting->default_value;
- }
- else
- setting->value = g_strdup (setting->default_value);
- }
- else if (setting->type == G_TYPE_STRV)
- {
- MESettingStringList* setting_ = (MESettingStringList*)setting;
- if (extension->priv->key_file)
- {
- setting_->value = g_key_file_get_string_list (extension->priv->key_file,
- "settings", setting->name, &setting_->length, NULL);
- if (setting_->value == NULL)
- {
- setting_->value = g_strdupv (setting_->default_value);
- setting_->length = setting_->default_length;
- }
- }
- else
- setting_->value = g_strdupv (setting_->default_value);
- }
- else
- g_assert_not_reached ();
-
- lsettings = g_list_next (lsettings);
- }
-
- extension->priv->app = g_object_ref (app);
- extension->priv->active = 1;
- /* FIXME: Disconnect all signal handlers */
-}
-
-static void
-midori_extension_init (MidoriExtension* extension)
-{
- extension->priv = G_TYPE_INSTANCE_GET_PRIVATE (extension,
- MIDORI_TYPE_EXTENSION, MidoriExtensionPrivate);
-
- extension->priv->app = NULL;
- extension->priv->active = 0;
- extension->priv->config_dir = NULL;
- extension->priv->lsettings = NULL;
- extension->priv->settings = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, me_setting_free);
- extension->priv->key_file = NULL;
-
- g_signal_connect (extension, "activate",
- G_CALLBACK (midori_extension_activate_cb), NULL);
-}
-
-static void
-midori_extension_finalize (GObject* object)
-{
- MidoriExtension* extension = MIDORI_EXTENSION (object);
-
- katze_object_assign (extension->priv->app, NULL);
- katze_assign (extension->priv->stock_id, NULL);
- katze_assign (extension->priv->name, NULL);
- katze_assign (extension->priv->description, NULL);
- katze_assign (extension->priv->version, NULL);
- katze_assign (extension->priv->authors, NULL);
- katze_assign (extension->priv->website, NULL);
- katze_assign (extension->priv->key, NULL);
-
- katze_assign (extension->priv->config_dir, NULL);
- g_list_free (extension->priv->lsettings);
- g_hash_table_destroy (extension->priv->settings);
- if (extension->priv->key_file)
- g_key_file_free (extension->priv->key_file);
-}
-
-static void
-midori_extension_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- MidoriExtension* extension = MIDORI_EXTENSION (object);
-
- switch (prop_id)
- {
- case PROP_STOCK_ID:
- katze_assign (extension->priv->stock_id, g_value_dup_string (value));
- break;
- case PROP_NAME:
- katze_assign (extension->priv->name, g_value_dup_string (value));
- break;
- case PROP_DESCRIPTION:
- katze_assign (extension->priv->description, g_value_dup_string (value));
- break;
- case PROP_USE_MARKUP:
- extension->priv->use_markup = g_value_get_boolean (value);
- break;
- case PROP_VERSION:
- {
- /* Don't show version suffix if it matches the running Midori */
- const gchar* version = g_value_get_string (value);
- if (version && g_str_has_suffix (version, MIDORI_VERSION_SUFFIX))
- katze_assign (extension->priv->version,
- g_strndup (version,
- strlen (version) - strlen (MIDORI_VERSION_SUFFIX)));
- /* No version suffix at all, must be 0.4.1 or 0.4.1 git */
- else if (version && !strchr (version, '-') && !strchr (version, '('))
- katze_assign (extension->priv->version,
- g_strconcat (version, " (0.4.1)", NULL));
- else
- katze_assign (extension->priv->version, g_strdup (version));
- break;
- }
- case PROP_AUTHORS:
- katze_assign (extension->priv->authors, g_value_dup_string (value));
- break;
- case PROP_WEBSITE:
- katze_assign (extension->priv->website, g_value_dup_string (value));
- break;
- case PROP_KEY:
- katze_assign (extension->priv->key, g_value_dup_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_extension_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- MidoriExtension* extension = MIDORI_EXTENSION (object);
-
- switch (prop_id)
- {
- case PROP_STOCK_ID:
- g_value_set_string (value, extension->priv->stock_id);
- break;
- case PROP_NAME:
- g_value_set_string (value, extension->priv->name);
- break;
- case PROP_DESCRIPTION:
- g_value_set_string (value, extension->priv->description);
- break;
- case PROP_USE_MARKUP:
- g_value_set_boolean (value, extension->priv->use_markup);
- break;
- case PROP_VERSION:
- g_value_set_string (value, extension->priv->version);
- break;
- case PROP_AUTHORS:
- g_value_set_string (value, extension->priv->authors);
- break;
- case PROP_WEBSITE:
- g_value_set_string (value, extension->priv->website);
- break;
- case PROP_KEY:
- g_value_set_string (value, extension->priv->key);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-void
-midori_extension_load_from_folder (MidoriApp* app,
- gchar** keys,
- gboolean activate)
-{
- if (!g_module_supported ())
- return;
-
- gchar* extension_path = midori_paths_get_lib_path (PACKAGE_NAME);
- if (!extension_path)
- return;
-
- if (activate)
- {
- /* FIXME need proper stock extension mechanism */
- g_assert (midori_extension_activate_gracefully (app, extension_path, "libtransfers." G_MODULE_SUFFIX, activate));
- g_assert (midori_extension_activate_gracefully (app, extension_path, "libapps." G_MODULE_SUFFIX, activate));
- g_assert (midori_extension_activate_gracefully (app, extension_path, "libdelayed-load." G_MODULE_SUFFIX, activate));
- g_assert (midori_extension_activate_gracefully (app, extension_path, "libabout." G_MODULE_SUFFIX, activate));
- g_assert (midori_extension_activate_gracefully (app, extension_path, "libtabby." G_MODULE_SUFFIX, activate));
- g_assert (midori_extension_activate_gracefully (app, extension_path, "libopen-with." G_MODULE_SUFFIX, activate));
- g_assert (midori_extension_activate_gracefully (app, extension_path, "libflummi." G_MODULE_SUFFIX, activate));
-
- gint i = 0;
- const gchar* filename;
- while (keys && (filename = keys[i++]))
- midori_extension_activate_gracefully (app, extension_path, filename, activate);
- }
- else
- {
- GDir* extension_dir = g_dir_open (extension_path, 0, NULL);
- g_return_if_fail (extension_dir != NULL);
- const gchar* filename;
- while ((filename = g_dir_read_name (extension_dir)))
- midori_extension_activate_gracefully (app, extension_path, filename, activate);
- g_dir_close (extension_dir);
- }
-
- g_free (extension_path);
-}
-
-/**
- * midori_extension_load_from_file:
- * @extension_path: the path to use for the extension's data files
- * @filename: the path to the extension's module file
- * @activate: whether to activate the extension
- * @test: whether to run the extension's tests
- *
- * Load an extension from a file.
- *
- * Return value: (transfer none): the loaded extension, or %NULL
- **/
-GObject*
-midori_extension_load_from_file (const gchar* extension_path,
- const gchar* filename,
- gboolean activate,
- gboolean test)
-{
- gchar* fullname;
- GModule* module;
- typedef GObject* (*extension_init_func)(void);
- extension_init_func extension_init;
- static GHashTable* modules = NULL;
- GObject* extension;
-
- g_return_val_if_fail (extension_path != NULL, NULL);
- g_return_val_if_fail (filename != NULL, NULL);
-
- if (strchr (filename, '/'))
- {
- gchar* clean = g_strndup (filename, strchr (filename, '/') - filename);
- fullname = g_build_filename (extension_path, clean, NULL);
- g_free (clean);
- }
- else
- fullname = g_build_filename (extension_path, filename, NULL);
-
- /* Ignore files which don't have the correct suffix */
- if (!g_str_has_suffix (fullname, G_MODULE_SUFFIX))
- {
- g_free (fullname);
- return NULL;
- }
-
- module = g_module_open (fullname, G_MODULE_BIND_LOCAL);
- g_free (fullname);
-
- /* GModule detects repeated loading but exposes no API to check it.
- Skip any modules that were loaded before. */
- if (modules == NULL)
- modules = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref);
- if ((extension = g_hash_table_lookup (modules, module)))
- return extension;
-
- if (module && g_module_symbol (module, "extension_init",
- (gpointer) &extension_init))
- {
- typedef void (*extension_test_func)(void);
- extension_test_func extension_test;
- if ((extension = extension_init ()))
- {
- if (test && g_module_symbol (module, "extension_test", (gpointer) &extension_test))
- extension_test ();
- g_object_set_data_full (G_OBJECT (extension), "filename", g_strdup (filename), g_free);
- g_hash_table_insert (modules, module, extension);
- }
- }
-
- return extension;
-}
-
-/**
- * midori_extension_activate_gracefully:
- * @app: the #MidoriApp for which to load the extension
- * @extension_path: the path to use for the extension's data files
- * @filename: the path to the extension's module file
- * @activate: whether to activate the extension
- *
- * Load an extension into the context of a #MidoriApp.
- *
- * Return value: (transfer none): the loaded extension, or %NULL
- **/
-GObject*
-midori_extension_activate_gracefully (MidoriApp* app,
- const gchar* extension_path,
- const gchar* filename,
- gboolean activate)
-{
- GObject* extension = midori_extension_load_from_file (extension_path, filename, activate, FALSE);
-
- midori_extension_activate (extension, filename, activate, app);
- if (!extension && g_module_error () != NULL)
- {
- KatzeArray* extensions = katze_object_get_object (app, "extensions");
- extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", filename,
- "description", g_module_error (),
- NULL);
- g_warning ("%s", g_module_error ());
- katze_array_add_item (extensions, extension);
- g_object_unref (extensions);
- g_object_unref (extension);
- return NULL;
- }
- else
- return extension;
-}
-
-static void
-midori_extension_add_to_list (MidoriApp* app,
- MidoriExtension* extension,
- const gchar* filename)
-{
- g_return_if_fail (MIDORI_IS_APP (app));
- g_return_if_fail (filename != NULL);
- KatzeArray* extensions = katze_object_get_object (app, "extensions");
- g_return_if_fail (KATZE_IS_ARRAY (extensions));
- if (katze_array_get_item_index (extensions, extension) >= 0)
- return;
- /* FIXME need proper stock extension mechanism */
- if (strcmp (filename, "libtransfers." G_MODULE_SUFFIX)
- && strcmp (filename, "libapps." G_MODULE_SUFFIX)
- && strcmp (filename, "libdelayed-load." G_MODULE_SUFFIX)
- && strcmp (filename, "libabout." G_MODULE_SUFFIX)
- && strcmp (filename, "libtabby." G_MODULE_SUFFIX)
- && strcmp (filename, "libopen-with." G_MODULE_SUFFIX)
- && strcmp (filename, "libflummi." G_MODULE_SUFFIX))
- katze_array_add_item (extensions, extension);
-
- g_object_unref (extensions);
-
- if (midori_paths_is_readonly ())
- return;
-
- /* Signal that we want the extension to load and save */
- if (midori_extension_is_prepared (extension))
- {
- /* This is a sensible check but makes unit testing hard
- g_warn_if_fail (extension->priv->config_dir == NULL);
- */
- extension->priv->config_dir = midori_paths_get_extension_config_dir (filename);
- }
-}
-
-void
-midori_extension_activate (GObject* extension,
- const gchar* filename,
- gboolean activate,
- MidoriApp* app)
-{
- if (MIDORI_IS_EXTENSION (extension))
- {
- if (filename != NULL)
- midori_extension_add_to_list (app, MIDORI_EXTENSION (extension), filename);
- if (activate && !midori_extension_is_active (MIDORI_EXTENSION (extension)))
- g_signal_emit_by_name (extension, "activate", app);
- }
- else if (KATZE_IS_ARRAY (extension))
- {
- gboolean success = FALSE;
- MidoriExtension* extension_item;
- KATZE_ARRAY_FOREACH_ITEM (extension_item, KATZE_ARRAY (extension))
- if (MIDORI_IS_EXTENSION (extension_item))
- {
- gchar* key = extension_item->priv->key;
- g_return_if_fail (key != NULL);
- if (filename != NULL && strchr (filename, '/'))
- {
- gchar* clean = g_strndup (filename, strchr (filename, '/') - filename);
- g_object_set_data_full (G_OBJECT (extension_item), "filename", clean, g_free);
- midori_extension_add_to_list (app, extension_item, clean);
- }
- else if (filename != NULL)
- {
- midori_extension_add_to_list (app, extension_item, filename);
- g_object_set_data_full (G_OBJECT (extension_item), "filename", g_strdup (filename), g_free);
- }
- if (activate && !midori_extension_is_active (MIDORI_EXTENSION (extension_item))
- && filename && strstr (filename, key))
- {
- g_signal_emit_by_name (extension_item, "activate", app);
- success = TRUE;
- }
- }
- /* Passed a multi extension w/o key or non-existing key */
- g_warn_if_fail (!activate || success);
- }
-}
-
-/**
- * midori_extension_is_prepared:
- * @extension: a #MidoriExtension
- *
- * Determines if @extension is prepared for use, for instance
- * by ensuring that all required values are set and that it
- * is actually activatable.
- *
- * Return value: %TRUE if @extension is ready for use
- **/
-gboolean
-midori_extension_is_prepared (MidoriExtension* extension)
-{
- g_return_val_if_fail (MIDORI_IS_EXTENSION (extension), FALSE);
-
- if (extension->priv->name && extension->priv->description
- && extension->priv->version && extension->priv->authors
- && g_signal_has_handler_pending (extension, signals[ACTIVATE], 0, FALSE))
- return TRUE;
- return FALSE;
-}
-
-/**
- * midori_extension_has_preferences:
- * @extension: a #MidoriExtension
- *
- * Determines if @extension has preferences.
- *
- * Return value: %TRUE if @extension has preferences
- **/
-gboolean
-midori_extension_has_preferences (MidoriExtension* extension)
-{
- g_return_val_if_fail (MIDORI_IS_EXTENSION (extension), FALSE);
-
- return g_signal_has_handler_pending (extension, signals[OPEN_PREFERENCES], 0, FALSE);
-}
-
-/**
- * midori_extension_is_active:
- * @extension: a #MidoriExtension
- *
- * Determines if @extension is active.
- *
- * Return value: %TRUE if @extension is active
- *
- * Since: 0.1.2
- **/
-gboolean
-midori_extension_is_active (MidoriExtension* extension)
-{
- g_return_val_if_fail (MIDORI_IS_EXTENSION (extension), FALSE);
-
- return extension->priv->active > 0;
-}
-
-/**
- * midori_extension_deactivate:
- * @extension: a #MidoriExtension
- *
- * Attempts to deactivate @extension.
- **/
-void
-midori_extension_deactivate (MidoriExtension* extension)
-{
- g_return_if_fail (midori_extension_is_active (extension));
-
- g_signal_emit (extension, signals[DEACTIVATE], 0);
- extension->priv->active = 0;
- katze_object_assign (extension->priv->app, NULL);
-}
-
-/**
- * midori_extension_get_app:
- * @extension: a #MidoriExtension
- *
- * Retrieves the #MidoriApp the extension belongs to. The
- * extension has to be active.
- *
- * Return value: (transfer none): the #MidoriApp instance
- *
- * Since 0.1.6
- **/
-MidoriApp*
-midori_extension_get_app (MidoriExtension* extension)
-{
- g_return_val_if_fail (midori_extension_is_active (extension), NULL);
-
- return extension->priv->app;
-}
-
-/**
- * midori_extension_get_config_dir:
- * @extension: a #MidoriExtension
- *
- * Retrieves the path to a directory reserved for configuration
- * files specific to the extension.
- *
- * If settings are installed on the extension, they will be
- * loaded from and saved to a file "config" in this path.
- *
- * Return value: a path, such as ~/.config/midori/extensions/name
- **/
-const gchar*
-midori_extension_get_config_dir (MidoriExtension* extension)
-{
-
- g_return_val_if_fail (midori_extension_is_prepared (extension), NULL);
-
- return extension->priv->config_dir;
-}
-
-/**
- * midori_extension_install_boolean:
- * @extension: a #MidoriExtension
- * @name: the name of the setting
- * @default_value: the default value
- *
- * Installs a boolean that can be used to conveniently
- * store user configuration.
- *
- * Note that all settings have to be installed before
- * the extension is activated.
- *
- * Since: 0.1.3
- **/
-void
-midori_extension_install_boolean (MidoriExtension* extension,
- const gchar* name,
- gboolean default_value)
-{
- MESettingBoolean* setting;
-
- g_return_if_fail (midori_extension_is_prepared (extension));
- midori_extension_can_install_setting (extension, name);
-
- me_setting_install (MESettingBoolean, g_strdup (name), G_TYPE_BOOLEAN,
- default_value, FALSE);
-}
-
-static void
-midori_extension_save_settings (MidoriExtension *extension)
-{
- GError* error = NULL;
- gchar* config_file = g_build_filename (extension->priv->config_dir, "config", NULL);
- katze_mkdir_with_parents (extension->priv->config_dir, 0700);
- sokoke_key_file_save_to_file (extension->priv->key_file, config_file, &error);
- if (error)
- {
- printf (_("The configuration of the extension '%s' couldn't be saved: %s\n"),
- extension->priv->name, error->message);
- g_error_free (error);
- }
- g_free (config_file);
-}
-
-/**
- * midori_extension_get_boolean:
- * @extension: a #MidoriExtension
- * @name: the name of the setting
- *
- * Retrieves the value of the specified setting.
- *
- * Since: 0.1.3
- **/
-gboolean
-midori_extension_get_boolean (MidoriExtension* extension,
- const gchar* name)
-{
- MESettingBoolean* setting;
-
- g_return_val_if_fail (midori_extension_is_prepared (extension), FALSE);
- g_return_val_if_fail (name != NULL, FALSE);
-
- setting = g_hash_table_lookup (extension->priv->settings, name);
-
- me_setting_type (setting, G_TYPE_BOOLEAN, return FALSE);
-
- return setting->value;
-}
-
-/**
- * midori_extension_set_boolean:
- * @extension: a #MidoriExtension
- * @name: the name of the setting
- * @value: the new value
- *
- * Assigns a new value to the specified setting.
- *
- * Since: 0.1.3
- **/
-void
-midori_extension_set_boolean (MidoriExtension* extension,
- const gchar* name,
- gboolean value)
-{
- MESettingBoolean* setting;
-
- g_return_if_fail (midori_extension_is_active (extension));
- g_return_if_fail (name != NULL);
-
- setting = g_hash_table_lookup (extension->priv->settings, name);
-
- me_setting_type (setting, G_TYPE_BOOLEAN, return);
-
- setting->value = value;
- if (extension->priv->key_file)
- {
- g_key_file_set_boolean (extension->priv->key_file,
- "settings", name, value);
- midori_extension_save_settings (extension);
- }
-}
-
-
-
-/**
- * midori_extension_install_integer:
- * @extension: a #MidoriExtension
- * @name: the name of the setting
- * @default_value: the default value
- *
- * Installs an integer that can be used to conveniently
- * store user configuration.
- *
- * Note that all settings have to be installed before
- * the extension is activated.
- *
- * Since: 0.1.3
- **/
-void
-midori_extension_install_integer (MidoriExtension* extension,
- const gchar* name,
- gint default_value)
-{
- MESettingInteger* setting;
-
- g_return_if_fail (midori_extension_is_prepared (extension));
- midori_extension_can_install_setting (extension, name);
-
- me_setting_install (MESettingInteger, g_strdup (name), G_TYPE_INT,
- default_value, 0);
-}
-
-/**
- * midori_extension_get_integer:
- * @extension: a #MidoriExtension
- * @name: the name of the setting
- *
- * Retrieves the value of the specified setting.
- *
- * Since: 0.1.3
- **/
-gint
-midori_extension_get_integer (MidoriExtension* extension,
- const gchar* name)
-{
- MESettingInteger* setting;
-
- g_return_val_if_fail (midori_extension_is_prepared (extension), 0);
- g_return_val_if_fail (name != NULL, 0);
-
- setting = g_hash_table_lookup (extension->priv->settings, name);
-
- me_setting_type (setting, G_TYPE_INT, return 0);
-
- return setting->value;
-}
-
-/**
- * midori_extension_set_integer:
- * @extension: a #MidoriExtension
- * @name: the name of the setting
- * @value: the new value
- *
- * Assigns a new value to the specified setting.
- *
- * Since: 0.1.3
- **/
-void
-midori_extension_set_integer (MidoriExtension* extension,
- const gchar* name,
- gint value)
-{
- MESettingInteger* setting;
-
- g_return_if_fail (midori_extension_is_active (extension));
- g_return_if_fail (name != NULL);
-
- setting = g_hash_table_lookup (extension->priv->settings, name);
-
- me_setting_type (setting, G_TYPE_INT, return);
-
- setting->value = value;
- if (extension->priv->key_file)
- {
- g_key_file_set_integer (extension->priv->key_file,
- "settings", name, value);
- midori_extension_save_settings (extension);
- }
-}
-
-/**
- * midori_extension_install_string:
- * @extension: a #MidoriExtension
- * @name: the name of the setting
- * @default_value: the default value
- *
- * Installs a string that can be used to conveniently
- * store user configuration.
- *
- * Note that all settings have to be installed before
- * the extension is activated.
- *
- * Since: 0.1.3
- **/
-void
-midori_extension_install_string (MidoriExtension* extension,
- const gchar* name,
- const gchar* default_value)
-{
- MESettingString* setting;
-
- g_return_if_fail (midori_extension_is_prepared (extension));
- midori_extension_can_install_setting (extension, name);
-
- me_setting_install (MESettingString, g_strdup (name), G_TYPE_STRING,
- g_strdup (default_value), NULL);
-}
-
-/**
- * midori_extension_get_string:
- * @extension: a #MidoriExtension
- * @name: the name of the setting
- *
- * Retrieves the value of the specified setting.
- *
- * Since: 0.1.3
- **/
-const gchar*
-midori_extension_get_string (MidoriExtension* extension,
- const gchar* name)
-{
- MESettingString* setting;
-
- g_return_val_if_fail (midori_extension_is_prepared (extension), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- setting = g_hash_table_lookup (extension->priv->settings, name);
-
- me_setting_type (setting, G_TYPE_STRING, return NULL);
-
- return setting->value;
-}
-
-/**
- * midori_extension_set_string:
- * @extension: a #MidoriExtension
- * @name: the name of the setting
- * @value: the new value
- *
- * Assigns a new value to the specified setting.
- *
- * Since: 0.1.3
- **/
-void
-midori_extension_set_string (MidoriExtension* extension,
- const gchar* name,
- const gchar* value)
-{
- MESettingString* setting;
-
- g_return_if_fail (midori_extension_is_active (extension));
- g_return_if_fail (name != NULL);
-
- setting = g_hash_table_lookup (extension->priv->settings, name);
-
- me_setting_type (setting, G_TYPE_STRING, return);
-
- katze_assign (setting->value, g_strdup (value));
- if (extension->priv->key_file)
- {
- g_key_file_set_string (extension->priv->key_file,
- "settings", name, value);
- midori_extension_save_settings (extension);
- }
-}
-
-/**
- * midori_extension_install_string_list:
- * @extension: a #MidoriExtension
- * @name: the name of the setting
- * @default_value: the default value
- *
- * Installs a string list that can be used to conveniently
- * store user configuration.
- *
- * Note that all settings have to be installed before
- * the extension is activated.
- *
- * Since: 0.1.7
- **/
-void
-midori_extension_install_string_list (MidoriExtension* extension,
- const gchar* name,
- gchar** default_value,
- gsize default_length)
-{
- MESettingStringList* setting;
-
- g_return_if_fail (midori_extension_is_prepared (extension));
- midori_extension_can_install_setting (extension, name);
-
- me_setting_install (MESettingStringList, g_strdup (name), G_TYPE_STRV,
- g_strdupv (default_value), NULL);
-
- setting->default_length = default_length;
-}
-
-/**
- * midori_extension_get_string_list:
- * @extension: a #MidoriExtension
- * @name: the name of the setting
- * @length: return location to store number of strings, or %NULL
- *
- * Retrieves the value of the specified setting.
- *
- * Return value: (transfer full) (array zero-terminated=1): the list of
- * strings, NULL-terminated and to be freed with g_strfreev()
- *
- * Since: 0.1.7
- **/
-gchar**
-midori_extension_get_string_list (MidoriExtension* extension,
- const gchar* name,
- gsize* length)
-{
- MESettingStringList* setting;
-
- g_return_val_if_fail (midori_extension_is_prepared (extension), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- setting = g_hash_table_lookup (extension->priv->settings, name);
-
- me_setting_type (setting, G_TYPE_STRV, return NULL);
-
- if (length)
- *length = setting->length;
-
- return g_strdupv (setting->value);
-}
-
-/**
- * midori_extension_set_string_list:
- * @extension: a #MidoriExtension
- * @name: the name of the setting
- * @value: the new value
- * @length: number of strings in @value, or G_MAXSIZE
- *
- * Assigns a new value to the specified setting.
- *
- * Since: 0.1.7
- **/
-void
-midori_extension_set_string_list (MidoriExtension* extension,
- const gchar* name,
- gchar** value,
- gsize length)
-{
- MESettingStringList* setting;
-
- g_return_if_fail (midori_extension_is_active (extension));
- g_return_if_fail (name != NULL);
-
- setting = g_hash_table_lookup (extension->priv->settings, name);
-
- me_setting_type (setting, G_TYPE_STRV, return);
-
- katze_strv_assign (setting->value, g_strdupv (value));
- setting->length = length;
-
- if (extension->priv->key_file)
- {
- g_key_file_set_string_list (extension->priv->key_file,
- "settings", name, (const gchar**)value, length);
- midori_extension_save_settings (extension);
- }
-}
diff --git a/midori/midori-extension.h b/midori/midori-extension.h
deleted file mode 100644
index dcb2649e..00000000
--- a/midori/midori-extension.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- Copyright (C) 2008-2013 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 __MIDORI_EXTENSION_H__
-#define __MIDORI_EXTENSION_H__
-
-#include "midori-app.h"
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_EXTENSION \
- (midori_extension_get_type ())
-#define MIDORI_EXTENSION(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_EXTENSION, MidoriExtension))
-#define MIDORI_EXTENSION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_EXTENSION, MidoriExtensionClass))
-#define MIDORI_IS_EXTENSION(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_EXTENSION))
-#define MIDORI_IS_EXTENSION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_EXTENSION))
-#define MIDORI_EXTENSION_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_EXTENSION, MidoriExtensionClass))
-
-typedef struct _MidoriExtension MidoriExtension;
-typedef struct _MidoriExtensionClass MidoriExtensionClass;
-typedef struct _MidoriExtensionPrivate MidoriExtensionPrivate;
-
-struct _MidoriExtension
-{
- GObject parent_instance;
-
- MidoriExtensionPrivate* priv;
-};
-
-struct _MidoriExtensionClass
-{
- GObjectClass parent_class;
-};
-
-GType
-midori_extension_get_type (void) G_GNUC_CONST;
-
-GObject*
-midori_extension_load_from_file (const gchar* extension_path,
- const gchar* filename,
- gboolean activate,
- gboolean test);
-
-void
-midori_extension_activate (GObject* extension,
- const gchar* filename,
- gboolean activate,
- MidoriApp* app);
-
-GObject*
-midori_extension_activate_gracefully (MidoriApp* app,
- const gchar* extension_path,
- const gchar* filename,
- gboolean activate);
-
-gboolean
-midori_extension_is_prepared (MidoriExtension* extension);
-
-gboolean
-midori_extension_has_preferences (MidoriExtension* extension);
-
-gboolean
-midori_extension_is_active (MidoriExtension* extension);
-
-void
-midori_extension_deactivate (MidoriExtension* extension);
-
-MidoriApp*
-midori_extension_get_app (MidoriExtension* extension);
-
-const gchar*
-midori_extension_get_config_dir (MidoriExtension* extension);
-
-void
-midori_extension_install_boolean (MidoriExtension* extension,
- const gchar* name,
- gboolean default_value);
-
-gboolean
-midori_extension_get_boolean (MidoriExtension* extension,
- const gchar* name);
-
-void
-midori_extension_set_boolean (MidoriExtension* extension,
- const gchar* name,
- gboolean value);
-
-void
-midori_extension_install_integer (MidoriExtension* extension,
- const gchar* name,
- gint default_value);
-
-gint
-midori_extension_get_integer (MidoriExtension* extension,
- const gchar* name);
-
-void
-midori_extension_set_integer (MidoriExtension* extension,
- const gchar* name,
- gint value);
-
-void
-midori_extension_install_string (MidoriExtension* extension,
- const gchar* name,
- const gchar* default_value);
-
-const gchar*
-midori_extension_get_string (MidoriExtension* extension,
- const gchar* name);
-
-void
-midori_extension_set_string (MidoriExtension* extension,
- const gchar* name,
- const gchar* value);
-
-void
-midori_extension_install_string_list (MidoriExtension* extension,
- const gchar* name,
- gchar** default_value,
- gsize default_length);
-
-gchar**
-midori_extension_get_string_list (MidoriExtension* extension,
- const gchar* name,
- gsize* length);
-
-void
-midori_extension_set_string_list (MidoriExtension* extension,
- const gchar* name,
- gchar** value,
- gsize length);
-
-void
-midori_extension_load_from_folder (MidoriApp* app,
- gchar** keys,
- gboolean activate);
-
-G_END_DECLS
-
-#endif /* __MIDORI_EXTENSION_H__ */
diff --git a/midori/midori-extensions-column.vala b/midori/midori-extensions-column.vala
deleted file mode 100644
index 49889f17..00000000
--- a/midori/midori-extensions-column.vala
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- Copyright (C) 2012 André Stösel <andre@stoesel.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.
-*/
-
-public class Midori.ExtensionsColumn : Gtk.TreeViewColumn {
- public signal void row_clicked (Gtk.TreeView view, Gtk.TreePath path);
-}
diff --git a/midori/midori-frontend.c b/midori/midori-frontend.c
deleted file mode 100644
index 7b6e0c1d..00000000
--- a/midori/midori-frontend.c
+++ /dev/null
@@ -1,637 +0,0 @@
-/*
- Copyright (C) 2008-2013 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.
-*/
-
-#include "midori-array.h"
-#include "midori-bookmarks-db.h"
-#include "midori-history.h"
-#include "midori-preferences.h"
-#include "midori-privatedata.h"
-#include "midori-session.h"
-#include "midori-searchaction.h"
-#include "midori-panel.h"
-#include "panels/midori-bookmarks.h"
-#include "panels/midori-history.h"
-#include "sokoke.h"
-#include <glib/gi18n-lib.h>
-
-static MidoriBrowser*
-midori_frontend_browser_new_window_cb (MidoriBrowser* browser,
- MidoriBrowser* new_browser,
- gpointer user_data)
-{
- if (new_browser == NULL)
- new_browser = midori_browser_new ();
- g_object_set (new_browser,
- "settings", midori_browser_get_settings (browser),
- NULL);
- gtk_widget_show (GTK_WIDGET (new_browser));
- return new_browser;
-}
-
-static void
-midori_browser_privacy_preferences_cb (MidoriBrowser* browser,
- KatzePreferences* preferences,
- gpointer user_data)
-{
- MidoriWebSettings* settings = midori_browser_get_settings (browser);
- midori_preferences_add_privacy_category (preferences, settings);
-}
-
-MidoriBrowser*
-midori_web_app_new (const gchar* webapp,
- gchar** open_uris,
- gchar** execute_commands,
- gint inactivity_reset,
- const gchar* block_uris)
-{
- guint i;
- g_return_val_if_fail (webapp != NULL, NULL);
-
- midori_paths_init (MIDORI_RUNTIME_MODE_APP, webapp);
- /*
- Set sanitized URI as class name which .desktop files use as StartupWMClass
- So dock type launchers can distinguish different apps with the same executable
- */
- gchar* wm_class = g_strdelimit (g_strdup (webapp), ":.\\/", '_');
- gdk_set_program_class (wm_class);
- g_free (wm_class);
-
- MidoriBrowser* browser = midori_browser_new ();
- g_signal_connect (browser, "new-window",
- G_CALLBACK (midori_frontend_browser_new_window_cb), NULL);
- g_signal_connect (browser, "show-preferences",
- G_CALLBACK (midori_browser_privacy_preferences_cb), NULL);
-
- midori_browser_set_action_visible (browser, "Menubar", FALSE);
- midori_browser_set_action_visible (browser, "CompactMenu", FALSE);
- midori_browser_set_action_visible (browser, "AddSpeedDial", FALSE);
- midori_browser_set_action_visible (browser, "Navigationbar", FALSE);
- GtkActionGroup* action_group = midori_browser_get_action_group (browser);
- GtkAction* action = gtk_action_group_get_action (action_group, "Location");
- gtk_action_set_sensitive (action, FALSE);
-
- MidoriWebSettings* settings = midori_settings_new_full (NULL);
- g_object_set (settings,
- "show-menubar", FALSE,
- "toolbar-items", "Back,Forward,ReloadStop,Location,Homepage,Preferences",
- "show-statusbar", FALSE,
- "show-panel", FALSE,
- "last-window-state", MIDORI_WINDOW_NORMAL,
- "inactivity-reset", inactivity_reset,
- "block-uris", block_uris,
- NULL);
- midori_load_soup_session_full (settings);
-
- KatzeArray* search_engines = midori_search_engines_new_from_folder (NULL);
- g_object_set (browser,
- "show-tabs", open_uris != NULL,
- "settings", settings,
- NULL);
- midori_browser_set_action_visible (browser, "Panel", FALSE);
- g_object_unref (search_engines);
-
- if (webapp != NULL)
- {
- gchar* tmp_uri = sokoke_magic_uri (webapp, FALSE, TRUE);
- g_object_set (settings, "homepage", tmp_uri, NULL);
- midori_browser_add_uri (browser, tmp_uri);
- g_free (tmp_uri);
- }
-
- for (i = 0; open_uris && open_uris[i]; i++)
- {
- gchar* new_uri = sokoke_magic_uri (open_uris[i], FALSE, TRUE);
- midori_browser_add_uri (browser, new_uri);
- g_free (new_uri);
- }
- if (midori_browser_get_n_pages (browser) == 0)
- midori_browser_add_uri (browser, "about:blank");
- gtk_widget_show (GTK_WIDGET (browser));
-
- for (i = 0; execute_commands && execute_commands[i]; i++)
- {
- midori_browser_assert_action (browser, execute_commands[i]);
- midori_browser_activate_action (browser, execute_commands[i]);
- }
- midori_session_persistent_settings (settings, NULL);
- /* FIXME need proper stock extension mechanism */
- midori_browser_activate_action (browser, "libtransfers." G_MODULE_SUFFIX "=true");
- midori_browser_activate_action (browser, "libabout." G_MODULE_SUFFIX "=true");
- midori_browser_activate_action (browser, "libopen-with." G_MODULE_SUFFIX "=true");
- g_assert (g_module_error () == NULL);
- return browser;
-}
-
-static void
-midori_trash_add_item_no_save_cb (KatzeArray* trash,
- GObject* item)
-{
- if (katze_array_get_nth_item (trash, 10))
- {
- KatzeItem* obsolete_item = katze_array_get_nth_item (trash, 0);
- katze_array_remove_item (trash, obsolete_item);
- }
-}
-
-static void
-midori_trash_remove_item_cb (KatzeArray* trash,
- GObject* item)
-{
- gchar* config_file = midori_paths_get_config_filename_for_writing ("tabtrash.xbel");
- GError* error = NULL;
- midori_trash_add_item_no_save_cb (trash, item);
- if (!midori_array_to_file (trash, config_file, "xbel-tiny", &error))
- {
- /* i18n: Trash, or wastebin, containing closed tabs */
- g_warning (_("The trash couldn't be saved. %s"), error->message);
- g_error_free (error);
- }
- g_free (config_file);
-}
-
-static void
-midori_trash_add_item_cb (KatzeArray* trash,
- GObject* item)
-{
- midori_trash_remove_item_cb (trash, item);
-}
-
-MidoriBrowser*
-midori_private_app_new (const gchar* config,
- const gchar* webapp,
- gchar** open_uris,
- gchar** execute_commands,
- gint inactivity_reset,
- const gchar* block_uris)
-{
- guint i;
-
- midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, config);
-#ifndef HAVE_WEBKIT2
- g_object_set_data (G_OBJECT (webkit_get_default_session ()), "pass-through-console", (void*)1);
-#endif
-
- /* Mask the timezone, which can be read by Javascript */
- g_setenv ("TZ", "UTC", TRUE);
-
- MidoriBrowser* browser = midori_browser_new ();
- g_signal_connect (browser, "new-window",
- G_CALLBACK (midori_frontend_browser_new_window_cb), NULL);
-
- MidoriWebSettings* settings = midori_settings_new_full (NULL);
- g_object_set (settings,
- "preferred-languages", "en",
- "enable-private-browsing", TRUE,
- "first-party-cookies-only", TRUE,
- "enable-html5-database", FALSE,
- "enable-html5-local-storage", FALSE,
- "enable-offline-web-application-cache", FALSE,
- /* Arguably DNS prefetching is or isn't a privacy concern. For the
- * lack of more fine-grained control we'll go the safe route. */
- "enable-dns-prefetching", FALSE,
- "strip-referer", TRUE,
- "show-panel", FALSE,
- "last-window-state", MIDORI_WINDOW_NORMAL,
- "inactivity-reset", inactivity_reset,
- "block-uris", block_uris,
- NULL);
- midori_load_soup_session (settings);
-
- /* In-memory trash for re-opening closed tabs */
- KatzeArray* trash = katze_array_new (KATZE_TYPE_ITEM);
- g_signal_connect_after (trash, "add-item",
- G_CALLBACK (midori_trash_add_item_no_save_cb), NULL);
-
- KatzeArray* search_engines = midori_search_engines_new_from_folder (NULL);
- g_object_set (browser,
- "settings", settings,
- "trash", trash,
- "search-engines", search_engines,
- NULL);
- g_object_unref (settings);
- g_object_unref (trash);
- g_object_unref (search_engines);
-
- midori_browser_set_action_visible (browser, "Tools", FALSE);
- midori_browser_set_action_visible (browser, "ClearPrivateData", FALSE);
- midori_browser_set_action_visible (browser, "AddSpeedDial", FALSE);
- #if GTK_CHECK_VERSION (3, 0, 0)
- g_object_set (gtk_widget_get_settings (GTK_WIDGET (browser)),
- "gtk-application-prefer-dark-theme", TRUE,
- NULL);
- #endif
-
- if (webapp != NULL)
- {
- gchar* tmp_uri = sokoke_magic_uri (webapp, FALSE, TRUE);
- g_object_set (settings, "homepage", tmp_uri, NULL);
- midori_browser_add_uri (browser, tmp_uri);
- g_free (tmp_uri);
- }
-
- for (i = 0; open_uris && open_uris[i]; i++)
- {
- gchar* new_uri = sokoke_magic_uri (open_uris[i], FALSE, TRUE);
- midori_browser_add_uri (browser, new_uri);
- g_free (new_uri);
- }
- if (midori_browser_get_n_pages (browser) == 0)
- midori_browser_add_uri (browser, "about:private");
- gtk_widget_show (GTK_WIDGET (browser));
-
- /* FIXME need proper stock extension mechanism */
- midori_browser_activate_action (browser, "libtransfers." G_MODULE_SUFFIX "=true");
- midori_browser_activate_action (browser, "libabout." G_MODULE_SUFFIX "=true");
- midori_browser_activate_action (browser, "libopen-with." G_MODULE_SUFFIX "=true");
- g_assert (g_module_error () == NULL);
-
- for (i = 0; execute_commands && execute_commands[i]; i++)
- {
- midori_browser_assert_action (browser, execute_commands[i]);
- midori_browser_activate_action (browser, execute_commands[i]);
- }
-
- return browser;
-}
-
-static void
-midori_browser_show_preferences_cb (MidoriBrowser* browser,
- KatzePreferences* preferences,
- MidoriApp* app)
-{
- midori_preferences_add_extension_category (preferences, app);
-}
-
-static void
-midori_app_add_browser_cb (MidoriApp* app,
- MidoriBrowser* browser,
- gpointer user_data)
-{
- GtkWidget* panel;
- GtkWidget* addon;
-
- panel = katze_object_get_object (browser, "panel");
-
- addon = g_object_new (MIDORI_TYPE_BOOKMARKS, "app", app, "visible", TRUE, NULL);
- midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));
-
- addon = g_object_new (MIDORI_TYPE_HISTORY, "app", app, "visible", TRUE, NULL);
- midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));
-
- /* Extensions */
- g_signal_connect (browser, "show-preferences",
- G_CALLBACK (midori_browser_privacy_preferences_cb), NULL);
- g_signal_connect (browser, "show-preferences",
- G_CALLBACK (midori_browser_show_preferences_cb), app);
-
- g_object_unref (panel);
-}
-
-static void
-button_disable_extensions_clicked_cb (GtkWidget* button,
- MidoriApp* app)
-{
- /* Reset frozen list of active extensions */
- g_object_set_data (G_OBJECT (app), "extensions", NULL);
- gtk_widget_set_sensitive (button, FALSE);
-}
-
-static void
-button_modify_preferences_clicked_cb (GtkWidget* button,
- MidoriWebSettings* settings)
-{
- GtkWidget* dialog = midori_preferences_new (
- GTK_WINDOW (gtk_widget_get_toplevel (button)), settings);
- if (midori_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_DELETE_EVENT)
- gtk_widget_destroy (dialog);
-}
-
-static void
-midori_frontend_crash_log_cb (GtkWidget* button,
- gchar* crash_log)
-{
- GError* error = NULL;
- if (!gtk_show_uri (gtk_widget_get_screen (button), crash_log, 0, &error))
- {
- sokoke_message_dialog (GTK_MESSAGE_ERROR,
- _("Could not run external program."),
- error->message, FALSE);
- g_error_free (error);
- }
-}
-
-static void
-midori_frontend_debugger_cb (GtkWidget* button,
- GtkDialog* dialog)
-{
- gtk_dialog_response (dialog, GTK_RESPONSE_HELP);
-}
-
-static gint
-midori_frontend_diagnostic_dialog (MidoriApp* app,
- MidoriWebSettings* settings,
- KatzeArray* session)
-{
- GtkWidget* dialog;
- GtkWidget* content_area;
- GtkWidget* align;
- GtkWidget* box;
- GtkWidget* button;
- MidoriStartup load_on_startup = katze_object_get_enum (settings, "load-on-startup");
- gint response;
-
- dialog = gtk_message_dialog_new (
- NULL, 0, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
- _("Midori crashed the last time it was opened. You can report the problem at %s."),
- PACKAGE_BUGREPORT);
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), FALSE);
- gtk_window_set_title (GTK_WINDOW (dialog), g_get_application_name ());
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- align = gtk_alignment_new (0.5, 0.5, 0.5, 0.5);
- gtk_box_pack_start (GTK_BOX (content_area), align, FALSE, TRUE, 0);
- box = gtk_hbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (align), box);
- button = gtk_button_new_with_mnemonic (_("Modify _preferences"));
- g_signal_connect (button, "clicked",
- G_CALLBACK (button_modify_preferences_clicked_cb), settings);
- gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 4);
- button = gtk_button_new_with_mnemonic (_("Disable all _extensions"));
- if (g_object_get_data (G_OBJECT (app), "extensions"))
- g_signal_connect (button, "clicked",
- G_CALLBACK (button_disable_extensions_clicked_cb), app);
- else
- gtk_widget_set_sensitive (button, FALSE);
- gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 4);
- gtk_widget_show_all (align);
- button = katze_property_proxy (settings, "show-crash-dialog", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Show a dialog after Midori crashed"));
- gtk_widget_show (button);
- gtk_box_pack_start (GTK_BOX (content_area), button, FALSE, TRUE, 0);
- gtk_container_set_focus_child (GTK_CONTAINER (dialog), gtk_dialog_get_action_area (GTK_DIALOG (dialog)));
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("Discard old tabs"), MIDORI_STARTUP_BLANK_PAGE,
- _("Show last tabs without loading"), MIDORI_STARTUP_DELAYED_PAGES,
- _("Show last open tabs"), MIDORI_STARTUP_LAST_OPEN_PAGES,
- NULL);
-
- gchar* crash_log = g_build_filename (midori_paths_get_runtime_dir (), "gdb.bt", NULL);
- if (g_file_test (crash_log, G_FILE_TEST_EXISTS))
- {
- GtkWidget* log_button = gtk_button_new_with_mnemonic (_("Show last crash _log"));
- g_signal_connect_data (log_button, "clicked",
- G_CALLBACK (midori_frontend_crash_log_cb), crash_log,
- (GClosureNotify)g_free, 0);
- gtk_widget_show (log_button);
- gtk_box_pack_start (GTK_BOX (box), log_button, FALSE, FALSE, 4);
- }
- else
- g_free (crash_log);
-
- gchar* gdb = g_find_program_in_path ("gdb");
- if (gdb != NULL)
- {
- GtkWidget* gdb_button = gtk_button_new_with_mnemonic (_("Run in _debugger"));
- g_signal_connect (button, "clicked",
- G_CALLBACK (midori_frontend_debugger_cb), dialog);
- gtk_widget_show (gdb_button);
- gtk_box_pack_start (GTK_BOX (box), gdb_button, FALSE, FALSE, 4);
- }
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- load_on_startup == MIDORI_STARTUP_HOMEPAGE
- ? MIDORI_STARTUP_BLANK_PAGE : load_on_startup);
-
- /* GtkLabel can't wrap the text properly. Until some day
- this works, we implement this hack to do it ourselves. */
- GList* ch = gtk_container_get_children (GTK_CONTAINER (content_area));
- GtkWidget* hbox = (GtkWidget*)g_list_nth_data (ch, 0);
- g_list_free (ch);
- ch = gtk_container_get_children (GTK_CONTAINER (hbox));
- GtkWidget* vbox = (GtkWidget*)g_list_nth_data (ch, 1);
- g_list_free (ch);
- ch = gtk_container_get_children (GTK_CONTAINER (vbox));
- GtkWidget* label = (GtkWidget*)g_list_nth_data (ch, 0);
- g_list_free (ch);
- GtkRequisition req;
- gtk_widget_size_request (content_area, &req);
- gtk_widget_set_size_request (label, req.width * 0.9, -1);
-
- response = midori_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- if (response == GTK_RESPONSE_DELETE_EVENT)
- response = G_MAXINT;
- else if (response == GTK_RESPONSE_HELP)
- {
- sokoke_spawn_gdb (gdb, FALSE);
- response = G_MAXINT;
- }
- else if (response == MIDORI_STARTUP_BLANK_PAGE)
- katze_array_clear (session);
- return response;
-}
-
-MidoriApp*
-midori_normal_app_new (const gchar* config,
- gchar* nickname,
- gboolean diagnostic_dialog,
- gchar** open_uris,
- gchar** execute_commands,
- gint inactivity_reset,
- const gchar* block_uris)
-{
- if (g_str_has_suffix (nickname, "portable"))
- midori_paths_init (MIDORI_RUNTIME_MODE_PORTABLE, config);
- else if (g_str_has_suffix (nickname, "normal"))
- midori_paths_init (MIDORI_RUNTIME_MODE_NORMAL, config);
- else
- g_assert_not_reached ();
-
- MidoriApp* app = midori_app_new (nickname);
- if (midori_app_instance_is_running (app))
- {
- /* midori_debug makes no sense on a running instance */
- if (g_getenv ("MIDORI_DEBUG"))
- g_warning ("MIDORI_DEBUG only works for a new instance");
-
- /* It makes no sense to show a crash dialog while running */
- if (!diagnostic_dialog)
- {
- if (execute_commands != NULL)
- midori_app_send_command (app, execute_commands);
- if (open_uris != NULL)
- midori_app_instance_send_uris (app, open_uris);
- if (!execute_commands && !open_uris)
- midori_app_instance_send_new_browser (app);
-
- if (g_application_get_is_registered (G_APPLICATION (app)))
- return NULL;
- }
-
- /* FIXME: We mustn't lose the URL here; either instance is freezing or inside a crash dialog */
- sokoke_message_dialog (GTK_MESSAGE_INFO,
- _("An instance of Midori is already running but not responding.\n"),
- open_uris ? *open_uris : "", TRUE);
- return (void*)0xdeadbeef;
- }
-
- GString* error_messages = g_string_new (NULL);
- GError* error = NULL;
- gchar** extensions;
- MidoriWebSettings* settings = midori_settings_new_full (&extensions);
- g_object_set (settings,
-#ifdef G_OS_WIN32
- "enable-developer-extras", FALSE,
-#else
- "enable-developer-extras", TRUE,
-#endif
- "enable-html5-database", TRUE,
- "block-uris", block_uris,
- NULL);
- if (inactivity_reset > 0)
- g_object_set (settings, "inactivity-reset", inactivity_reset, NULL);
-
- KatzeArray* search_engines = midori_search_engines_new_from_folder (error_messages);
- /* Pick first search engine as default if not set */
- gchar* uri = katze_object_get_string (settings, "location-entry-search");
- if (!(uri && *uri) && !katze_array_is_empty (search_engines))
- {
- KatzeItem* item = katze_array_get_nth_item (search_engines, 0);
- g_object_set (settings, "location-entry-search",
- katze_item_get_uri (item), NULL);
- }
- g_free (uri);
-
- MidoriBookmarksDb* bookmarks;
- gchar* errmsg = NULL;
- if (!(bookmarks = midori_bookmarks_db_new (&errmsg)))
- {
- g_string_append_printf (error_messages,
- _("Bookmarks couldn't be loaded: %s\n"), errmsg);
- katze_assign (errmsg, NULL);
- }
-
- gchar* config_file = NULL;
- KatzeArray* session = katze_array_new (KATZE_TYPE_ITEM);
- MidoriStartup load_on_startup = katze_object_get_enum (settings, "load-on-startup");
- if (load_on_startup >= MIDORI_STARTUP_LAST_OPEN_PAGES)
- {
- katze_assign (config_file, midori_paths_get_config_filename_for_reading ("session.xbel"));
- error = NULL;
- if (!midori_array_from_file (session, config_file, "xbel-tiny", &error))
- {
- if (error->code != G_FILE_ERROR_NOENT)
- g_string_append_printf (error_messages,
- _("The session couldn't be loaded: %s\n"), error->message);
- g_error_free (error);
- }
- }
-
- KatzeArray* trash = katze_array_new (KATZE_TYPE_ITEM);
- g_signal_connect_after (trash, "add-item",
- G_CALLBACK (midori_trash_add_item_cb), NULL);
- g_signal_connect_after (trash, "remove-item",
- G_CALLBACK (midori_trash_remove_item_cb), NULL);
- katze_assign (config_file, g_build_filename (config, "tabtrash.xbel", NULL));
- error = NULL;
- if (!midori_array_from_file (trash, config_file, "xbel-tiny", &error))
- {
- if (error->code != G_FILE_ERROR_NOENT)
- g_string_append_printf (error_messages,
- _("The trash couldn't be loaded: %s\n"), error->message);
- g_error_free (error);
- }
-
- KatzeArray* history;
- if (!(history = midori_history_new (&errmsg)))
- {
- g_string_append_printf (error_messages,
- _("The history couldn't be loaded: %s\n"), errmsg);
- katze_assign (errmsg, NULL);
- }
-
- katze_assign (config_file, midori_paths_get_config_filename_for_reading ("speeddial"));
- MidoriSpeedDial* dial = midori_speed_dial_new (config_file, NULL);
-
- if (error_messages->len)
- {
- GtkWidget* dialog = gtk_message_dialog_new (
- NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE,
- _("The following errors occured:"));
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog), "%s", error_messages->str);
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- _("_Ignore"), GTK_RESPONSE_ACCEPT,
- NULL);
- if (midori_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT)
- return (void*)0xdeadbeef;
- gtk_widget_destroy (dialog);
- }
- g_string_free (error_messages, TRUE);
-
- g_object_set_data (G_OBJECT (app), "execute-commands", execute_commands);
- g_object_set_data (G_OBJECT (app), "open-uris", open_uris);
- g_object_set_data_full (G_OBJECT (app), "extensions", extensions, (GDestroyNotify)g_strfreev);
- katze_item_set_parent (KATZE_ITEM (session), app);
-
- katze_assign (config_file, midori_paths_get_config_filename_for_reading ("search"));
- midori_search_engines_set_filename (search_engines, config_file);
-
- if ((midori_app_get_crashed (app)
- && katze_object_get_boolean (settings, "show-crash-dialog")
- && open_uris && !execute_commands)
- || diagnostic_dialog)
- {
- gint response = midori_frontend_diagnostic_dialog (app, settings, session);
- if (response == G_MAXINT)
- return NULL;
- load_on_startup = response;
- }
- katze_item_set_parent (KATZE_ITEM (session), NULL);
- g_object_unref (session);
- g_object_set_data (G_OBJECT (settings), "load-on-startup", GINT_TO_POINTER (load_on_startup));
-
- g_object_set (app, "settings", settings,
- "bookmarks", bookmarks,
- "trash", trash,
- "search-engines", search_engines,
- "history", history,
- "speed-dial", dial,
- NULL);
- g_signal_connect (app, "add-browser",
- G_CALLBACK (midori_app_add_browser_cb), NULL);
-
- midori_session_persistent_settings (settings, app);
-
- g_idle_add (midori_load_soup_session_full, settings);
- g_idle_add (midori_load_extensions, app);
- return app;
-}
-
-void
-midori_normal_app_on_quit (MidoriApp* app)
-{
- MidoriWebSettings* settings = katze_object_get_object (app, "settings");
- MidoriBookmarksDb* bookmarks = katze_object_get_object (app, "bookmarks");
- KatzeArray* history = katze_object_get_object (app, "history");
-
- g_object_notify (G_OBJECT (settings), "load-on-startup");
- midori_bookmarks_db_on_quit (bookmarks);
- midori_history_on_quit (history, settings);
- midori_private_data_on_quit (settings);
-
- MidoriStartup load_on_startup = katze_object_get_int (settings, "load-on-startup");
- if (load_on_startup < MIDORI_STARTUP_LAST_OPEN_PAGES)
- {
- gchar* config_file = midori_paths_get_config_filename_for_writing ("session.xbel");
- g_unlink (config_file);
- }
-}
-
diff --git a/midori/midori-frontend.h b/midori/midori-frontend.h
deleted file mode 100644
index 51053577..00000000
--- a/midori/midori-frontend.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Copyright (C) 2012-2013 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 __MIDORI_FRONTEND_H__
-#define __MIDORI_FRONTEND_H__
-
-#include "midori/midori-app.h"
-
-MidoriBrowser*
-midori_web_app_new (const gchar* webapp,
- gchar** open_uris,
- gchar** execute_commands,
- gint inactivity_reset,
- const gchar* block_uris);
-
-MidoriBrowser*
-midori_private_app_new (const gchar* config,
- const gchar* webapp,
- gchar** open_uris,
- gchar** execute_commands,
- gint inactivity_reset,
- const gchar* block_uris);
-
-MidoriApp*
-midori_normal_app_new (const gchar* config,
- gchar* nickname,
- gboolean diagnostic_dialog,
- gchar** open_uris,
- gchar** execute_commands,
- gint inactivity_reset,
- const gchar* block_uris);
-
-void
-midori_normal_app_on_quit (MidoriApp* app);
-
-G_END_DECLS
-
-#endif /* __MIDORI_FRONTEND_H__ */
-
diff --git a/midori/midori-history.c b/midori/midori-history.c
deleted file mode 100644
index bb717747..00000000
--- a/midori/midori-history.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- Copyright (C) 2010-2013 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.
-*/
-
-#include "midori/midori-history.h"
-
-#include <glib/gi18n-lib.h>
-#include <midori/midori-core.h>
-
-static void
-midori_history_clear_cb (KatzeArray* array,
- sqlite3* db)
-{
- GError* error = NULL;
- MidoriHistoryDatabase* database = midori_history_database_new (NULL, &error);
- if (error == NULL)
- midori_history_database_clear (database, 0, &error);
- if (error != NULL)
- {
- g_printerr (_("Failed to clear history: %s\n"), error->message);
- g_error_free (error);
- }
- g_object_unref (database);
-}
-
-KatzeArray*
-midori_history_new (char** errmsg)
-{
- MidoriHistoryDatabase* database;
- GError* error = NULL;
- sqlite3* db;
- KatzeArray* array;
-
- g_return_val_if_fail (errmsg != NULL, NULL);
-
- database = midori_history_database_new (NULL, &error);
- if (error != NULL)
- {
- *errmsg = g_strdup (error->message);
- g_error_free (error);
- return NULL;
- }
-
- db = midori_database_get_db (MIDORI_DATABASE (database));
- g_return_val_if_fail (db != NULL, NULL);
-
- array = katze_array_new (KATZE_TYPE_ARRAY);
- g_object_set_data (G_OBJECT (array), "db", db);
- g_signal_connect (array, "clear",
- G_CALLBACK (midori_history_clear_cb), db);
- return array;
-}
-
-void
-midori_history_on_quit (KatzeArray* array,
- MidoriWebSettings* settings)
-{
- gint max_history_age = katze_object_get_int (settings, "maximum-history-age");
- GError* error = NULL;
- MidoriHistoryDatabase* database = midori_history_database_new (NULL, &error);
- if (error == NULL)
- midori_history_database_clear (database, max_history_age, &error);
- if (error != NULL)
- {
- /* i18n: Couldn't remove items that are older than n days */
- g_printerr (_("Failed to remove old history items: %s\n"), error->message);
- g_error_free (error);
- }
- g_object_unref (database);
-}
-
diff --git a/midori/midori-history.h b/midori/midori-history.h
deleted file mode 100644
index ee5b1721..00000000
--- a/midori/midori-history.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- Copyright (C) 2010-2013 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 __MIDORI_HISTORY_H__
-#define __MIDORI_HISTORY_H__ 1
-
-#include <sqlite3.h>
-#include <katze/katze.h>
-#include "midori/midori-websettings.h"
-
-KatzeArray*
-midori_history_new (char** errmsg);
-
-void
-midori_history_on_quit (KatzeArray* array,
- MidoriWebSettings* settings);
-
-#endif /* !__MIDORI_HISTORY_H__ */
-
diff --git a/midori/midori-historycompletion.vala b/midori/midori-historycompletion.vala
deleted file mode 100644
index 27926b03..00000000
--- a/midori/midori-historycompletion.vala
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- Copyright (C) 2012-2013 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.
-*/
-
-namespace Midori {
- public class HistoryCompletion : Completion {
- public HistoryDatabase? database = null;
-
- public HistoryCompletion () {
- GLib.Object (description: _("Bookmarks and History"));
- }
-
- public override void prepare (GLib.Object app) {
- try {
- database = new HistoryDatabase (app);
- }
- catch (Error error) {
- warning (error.message);
- }
- }
-
- public override bool can_complete (string text) {
- return database != null;
- }
-
- public override bool can_action (string action) {
- return false;
- }
-
- public override async List<Suggestion>? complete (string text, string? action, Cancellable cancellable) {
- return_val_if_fail (database != null, null);
-
- List<HistoryItem> items = yield database.list_by_count_with_bookmarks (text, max_items, cancellable);
- if (items == null)
- return null;
-
- var suggestions = new List<Suggestion> ();
- foreach (var item in items) {
- if (item is Midori.HistoryWebsite) {
- var website = item as Midori.HistoryWebsite;
- suggestions.append (new Suggestion (website.uri, website.title,
- true, null, yield Midori.URI.get_icon_fallback (website.uri, null, cancellable), this.position));
- }
- else if (item is Midori.HistorySearch) {
- var search = item as Midori.HistorySearch;
- suggestions.append (new Suggestion (search.uri, search.title + "\n" + search.uri,
- false, "gray", yield Midori.URI.get_icon_fallback (search.uri, null, cancellable), this.position));
- }
- else
- warn_if_reached ();
- }
-
- if (cancellable.is_cancelled ())
- return null;
-
- return suggestions;
- }
- }
-}
diff --git a/midori/midori-historydatabase.vala b/midori/midori-historydatabase.vala
deleted file mode 100644
index 94b9f0e4..00000000
--- a/midori/midori-historydatabase.vala
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- Copyright (C) 2013 Christian Dywan <christian@twotoats.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.
-*/
-
-namespace Midori {
- public class HistoryWebsite : HistoryItem {
- public string uri { get; set; }
- public HistoryWebsite (string uri, string? title, int64 date) {
- GLib.Object (uri: uri,
- title: title,
- date: date);
- }
- }
-
- public class HistorySearch : HistoryItem {
- public string uri { get; set; }
- public string keywords { get; set; }
- public HistorySearch (string uri, string keywords, int64 date) {
- GLib.Object (uri: uri,
- keywords: keywords,
- title: _("Search for %s").printf (keywords),
- date: date);
- }
- }
-
- public class HistoryItem : GLib.Object {
- public string? title { get; set; }
- public int64 date { get; set; }
- }
-
- public class HistoryDatabase : Midori.Database {
- public HistoryDatabase (GLib.Object? app) throws DatabaseError {
- Object (path: "history.db");
- init ();
- Midori.BookmarksDatabase bookmarks_database = new Midori.BookmarksDatabase ();
- attach (bookmarks_database.path, "bookmarks");
-
- try {
- exec ("SELECT day FROM history LIMIT 1");
- } catch (Error error) {
- exec_script ("Day");
- }
- }
-
- public async List<HistoryItem>? query (string sqlcmd, string? filter, int64 day, int64 max_items, Cancellable cancellable) {
- return_val_if_fail (db != null, null);
-
- Midori.DatabaseStatement statement;
-
- try {
- string real_filter = "%" + filter.replace (" ", "%") + "%";
- statement = prepare (sqlcmd,
- ":filter", typeof (string), real_filter,
- ":limit", typeof (int64), max_items);
- } catch (Error error) {
- critical (_("Failed to select from history: %s"), error.message);
- return null;
- }
-
- var items = new List<HistoryItem> ();
- try {
- while (statement.step ()) {
- int64 type = statement.get_int64 ("type");
- int64 date = statement.get_int64 ("date");
- switch (type) {
- case 1:
- string uri = statement.get_string ("uri");
- string title = statement.get_string ("title");
- items.append (new HistoryWebsite (uri, title, date));
- break;
- case 2:
- string uri = statement.get_string ("uri");
- string title = statement.get_string ("title");
- items.append (new HistorySearch (uri, title, date));
- break;
- default:
- warn_if_reached ();
- break;
- }
-
- uint src = Idle.add (query.callback);
- yield;
- Source.remove (src);
-
- if (cancellable.is_cancelled ())
- return null;
- }
- } catch (Error error) {
- critical (_("Failed to select from history: %s"), error.message);
- }
-
- if (cancellable.is_cancelled ())
- return null;
- return items;
- }
-
- public async List<HistoryItem>? list_by_count_with_bookmarks (string? filter, int max_items, Cancellable cancellable) {
- unowned string sqlcmd = """
- SELECT type, date, uri, title FROM (
- SELECT 1 AS type, date, uri, title, count() AS ct FROM history
- WHERE uri LIKE :filter OR title LIKE :filter GROUP BY uri
- UNION ALL
- SELECT 2 AS type, day AS date, replace(uri, '%s', keywords) AS uri,
- keywords AS title, count() AS ct FROM search
- WHERE uri LIKE :filter OR title LIKE :filter GROUP BY uri
- UNION ALL
- SELECT 1 AS type, last_visit AS date, uri, title, 50 AS ct FROM bookmarks
- WHERE title LIKE :filter OR uri LIKE :filter AND uri !='' AND uri NOT LIKE 'javascript:%'
- ) GROUP BY uri ORDER BY ct DESC LIMIT :limit
- """;
- return yield query (sqlcmd, filter, 0, max_items, cancellable);
- }
-
- public bool insert (string uri, string title, int64 date, int64 day) throws DatabaseError {
- unowned string sqlcmd = "INSERT INTO history (uri, title, date, day) VALUES (:uri, :title, :date, :day)";
- var statement = prepare (sqlcmd,
- ":uri", typeof (string), uri,
- ":title", typeof (string), title,
- ":date", typeof (int64), date,
- ":day", typeof (int64), day);
- return statement.exec ();
- }
-
- public bool clear (int64 maximum_age=0) throws DatabaseError {
- unowned string sqlcmd = """
- DELETE FROM history WHERE
- (julianday(date('now')) - julianday(date(date,'unixepoch')))
- >= :maximum_age;
- DELETE FROM search WHERE
- (julianday(date('now')) - julianday(date(date,'unixepoch')))
- >= :maximum_age;
- """;
- var statement = prepare (sqlcmd,
- ":maximum_age", typeof (int64), maximum_age);
- return statement.exec ();
- }
- }
-}
diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c
deleted file mode 100644
index e983cbab..00000000
--- a/midori/midori-locationaction.c
+++ /dev/null
@@ -1,1920 +0,0 @@
-/*
- Copyright (C) 2008-2010 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2008-2010 Dale Whittaker <dayul@users.sf.net>
-
- 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.
-*/
-
-#include "midori-locationaction.h"
-
-#include "marshal.h"
-#include "midori-browser.h"
-#include "midori-searchaction.h"
-#include "midori-app.h"
-#include "midori-platform.h"
-#include <midori/midori-core.h>
-
-#include "config.h"
-#include <string.h>
-#include <glib/gi18n.h>
-#include <gdk/gdkkeysyms.h>
-
-#include <sqlite3.h>
-
-struct _MidoriLocationAction
-{
- GtkAction parent_instance;
-
- GIcon* icon;
- gchar* text;
- KatzeArray* search_engines;
- gdouble progress;
- gchar* secondary_icon;
- gchar* tooltip;
- gchar* placeholder;
-
- gchar* key;
- MidoriAutocompleter* autocompleter;
- GtkWidget* popup;
- GtkWidget* treeview;
- GtkTreeModel* completion_model;
- gint completion_index;
- GtkWidget* entry;
- KatzeArray* history;
-};
-
-struct _MidoriLocationActionClass
-{
- GtkActionClass parent_class;
-};
-
-G_DEFINE_TYPE (MidoriLocationAction, midori_location_action, GTK_TYPE_ACTION)
-
-enum
-{
- PROP_0,
-
- PROP_PROGRESS,
- PROP_SECONDARY_ICON,
- PROP_HISTORY,
- PROP_PLACEHOLDER_TEXT
-};
-
-enum
-{
- ACTIVE_CHANGED,
- FOCUS_IN,
- FOCUS_OUT,
- SECONDARY_ICON_RELEASED,
- RESET_URI,
- SUBMIT_URI,
- KEY_PRESS_EVENT,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-midori_location_action_finalize (GObject* object);
-
-static void
-midori_location_action_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_location_action_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_location_action_activate (GtkAction* object);
-
-static GtkWidget*
-midori_location_action_create_tool_item (GtkAction* action);
-
-static void
-midori_location_action_connect_proxy (GtkAction* action,
- GtkWidget* proxy);
-
-static void
-midori_location_action_disconnect_proxy (GtkAction* action,
- GtkWidget* proxy);
-
-static void
-midori_location_action_popdown_completion (MidoriLocationAction* location_action);
-
-extern GtkMenu*
-midori_search_action_get_menu (GtkWidget* entry,
- MidoriSearchAction *search_action,
- void (*change_cb)(GtkWidget*, MidoriSearchAction*));
-
-static void
-midori_location_action_class_init (MidoriLocationActionClass* class)
-{
- GObjectClass* gobject_class;
- GtkActionClass* action_class;
-
- /**
- * MidoriLocationAction:focus-in:
- *
- * The focus-in signal is emitted when the entry obtains the focus.
- *
- * Since 0.1.8
- */
- signals[FOCUS_IN] = g_signal_new ("focus-in",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags) (G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[FOCUS_OUT] = g_signal_new ("focus-out",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags) (G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /**
- * MidoriLocationAction:secondary-icon-released:
- *
- * The secondary-icon-released signal is emitted when the mouse button
- * is released above the secondary icon.
- *
- * Since 0.1.10 a signal handler can return %TRUE to stop signal
- * emission, for instance to suppress default behavior.
- */
- signals[SECONDARY_ICON_RELEASED] = g_signal_new ("secondary-icon-released",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags) (G_SIGNAL_RUN_LAST),
- 0,
- g_signal_accumulator_true_handled,
- NULL,
- midori_cclosure_marshal_BOOLEAN__OBJECT,
- G_TYPE_BOOLEAN, 1,
- GTK_TYPE_WIDGET);
-
- signals[RESET_URI] = g_signal_new ("reset-uri",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags) (G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[SUBMIT_URI] = g_signal_new ("submit-uri",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags) (G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- midori_cclosure_marshal_VOID__STRING_BOOLEAN,
- G_TYPE_NONE, 2,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN);
-
- /**
- * MidoriLocationAction:key-press-event:
- *
- * A key (combination) was pressed in an entry of the action.
- *
- * Since 0.5.8
- */
- signals[KEY_PRESS_EVENT] = g_signal_new ("key-press-event",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags) (G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- midori_cclosure_marshal_BOOLEAN__POINTER,
- G_TYPE_BOOLEAN, 1,
- GDK_TYPE_EVENT);
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = midori_location_action_finalize;
- gobject_class->set_property = midori_location_action_set_property;
- gobject_class->get_property = midori_location_action_get_property;
-
- action_class = GTK_ACTION_CLASS (class);
- action_class->activate = midori_location_action_activate;
- action_class->create_tool_item = midori_location_action_create_tool_item;
- action_class->connect_proxy = midori_location_action_connect_proxy;
- action_class->disconnect_proxy = midori_location_action_disconnect_proxy;
-
- g_object_class_install_property (gobject_class,
- PROP_PROGRESS,
- g_param_spec_double (
- "progress",
- "Progress",
- "The current progress of the action",
- 0.0, 1.0, 0.0,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_SECONDARY_ICON,
- g_param_spec_string (
- "secondary-icon",
- "Secondary",
- "The stock ID of the secondary icon",
- NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriLocationAction:history:
- *
- * The list of history items.
- *
- * This is actually a reference to a history instance.
- *
- * Since 0.1.8
- */
- g_object_class_install_property (gobject_class,
- PROP_HISTORY,
- g_param_spec_object (
- "history",
- "History",
- "The list of history items",
- KATZE_TYPE_ARRAY,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriLocationAction:placeholder-text:
- *
- * Hint displayed if entry text is empty.
- */
- g_object_class_install_property (gobject_class,
- PROP_PLACEHOLDER_TEXT,
- g_param_spec_string (
- "placeholder-text",
- "Placeholder Text",
- "Hint displayed if entry text is empty",
- NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-}
-
-gchar*
-midori_location_action_render_uri (gchar** keys,
- const gchar* uri_escaped)
-{
- gchar* uri_unescaped = midori_uri_unescape (uri_escaped);
- gchar* uri = g_strescape (uri_unescaped, NULL);
- g_free (uri_unescaped);
-
- gchar* stripped_uri = midori_uri_strip_prefix_for_display (uri);
- gchar* temp;
- gchar* temp_iter = temp = g_utf8_strdown (stripped_uri, -1);
- gchar* desc_iter = stripped_uri;
- gint key_idx = 0;
- gchar* key = keys[key_idx];
- gchar* start;
- gchar* desc_uri = NULL;
- while (key && (start = strstr (temp_iter, key)))
- {
- gsize len = strlen (key);
- if (len)
- {
- gint offset = (start - temp_iter);
- gchar* skey = g_strndup (desc_iter + offset, len);
- gchar** parts = g_strsplit (desc_iter, skey, 2);
- if (parts[0] && parts[1])
- {
- if (desc_uri)
- {
- gchar* temp_markup = g_markup_printf_escaped ("%s<b>%s</b>", parts[0], skey);
- gchar* temp_concat = g_strconcat (desc_uri, temp_markup, NULL);
- g_free (temp_markup);
- katze_assign (desc_uri, temp_concat);
- }
- else
- desc_uri = g_markup_printf_escaped ("%s<b>%s</b>", parts[0], skey);
- }
- g_strfreev (parts);
- g_free (skey);
-
- offset += len;
- temp_iter += offset;
- desc_iter += offset;
- }
- key_idx++;
- key = keys[key_idx];
- if (key == NULL)
- break;
- }
- if (key)
- katze_assign (desc_uri,g_markup_escape_text (stripped_uri, -1));
- else
- {
- gchar* temp_markup = g_markup_escape_text (desc_iter, -1);
- gchar* temp_concat = g_strconcat (desc_uri, temp_markup, NULL);
- g_free (temp_markup);
- katze_assign (desc_uri, temp_concat);
- }
- g_free (temp);
- g_free (stripped_uri);
- return desc_uri;
-}
-
-gchar*
-midori_location_action_render_title (gchar** keys,
- const gchar* title)
-{
- gchar* temp;
- gchar* temp_iter = temp = g_utf8_strdown (title, -1);
- const gchar* desc_iter = title;
- gint key_idx = 0;
- gchar* key = keys[key_idx];
- gchar* start;
- gchar* desc_title = NULL;
- while (key && (start = strstr (temp_iter, key)))
- {
- gsize len = strlen (key);
- if (len)
- {
- gint offset = (start - temp_iter);
- gchar* skey = g_strndup (desc_iter + offset, len);
- gchar** parts = g_strsplit (desc_iter, skey, 2);
- if (parts[0] && parts[1])
- {
- if (desc_title)
- {
- gchar* temp_markup = g_markup_printf_escaped ("%s<b>%s</b>", parts[0], skey);
- gchar* temp_concat = g_strconcat (desc_title, temp_markup, NULL);
- g_free (temp_markup);
- katze_assign (desc_title, temp_concat);
- }
- else
- desc_title = g_markup_printf_escaped ("%s<b>%s</b>", parts[0], skey);
- }
- g_strfreev (parts);
- g_free (skey);
-
- offset += len;
- temp_iter += offset;
- desc_iter += offset;
- }
- key_idx++;
- key = keys[key_idx];
- if (key == NULL)
- break;
- }
- if (key)
- katze_assign (desc_title, g_markup_escape_text (title, -1));
- else
- {
- gchar* temp_markup = g_markup_escape_text (desc_iter, -1);
- gchar* temp_concat = g_strconcat (desc_title, temp_markup, NULL);
- g_free (temp_markup);
- katze_assign (desc_title, temp_concat);
- }
- g_free (temp);
- return desc_title;
-}
-
-static void
-midori_location_entry_render_title_cb (GtkCellLayout* layout,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- gpointer data)
-{
- MidoriLocationAction* action = data;
- gchar* title;
- gchar* desc;
-
- gtk_tree_model_get (model, iter,
- MIDORI_AUTOCOMPLETER_COLUMNS_MARKUP, &title,
- -1);
-
- if (strchr (title, '\n')) /* A search engine or action suggestion */
- {
- gchar** parts = g_strsplit (title, "\n", 2);
- desc = g_strdup (parts[0]);
- g_strfreev (parts);
- }
- else
- {
- gchar* key = g_utf8_strdown (action->key ? action->key : "", -1);
- gchar** keys = g_strsplit_set (key, " %", -1);
- g_free (key);
- desc = midori_location_action_render_title (keys, title);
- g_strfreev (keys);
- }
-
- g_object_set (renderer, "markup", desc,
- "ellipsize-set", TRUE, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- g_free (desc);
- g_free (title);
-}
-
-static void
-midori_location_entry_render_uri_cb (GtkCellLayout* layout,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- gpointer data)
-{
- MidoriLocationAction* action = data;
- gchar* title;
- gchar* uri_escaped;
- gchar* desc;
-
- gtk_tree_model_get (model, iter,
- MIDORI_AUTOCOMPLETER_COLUMNS_MARKUP, &title,
- MIDORI_AUTOCOMPLETER_COLUMNS_URI, &uri_escaped,
- -1);
-
- if (strchr (title, '\n')) /* A search engine or action suggestion */
- {
- gchar** parts = g_strsplit (title, "\n", 2);
- desc = g_strdup (parts[1]);
- g_strfreev (parts);
- }
- else
- {
- gchar* key = g_utf8_strdown (action->key ? action->key : "", -1);
- gchar** keys = g_strsplit_set (key, " %", -1);
- g_free (key);
- desc = midori_location_action_render_uri (keys, uri_escaped);
- g_strfreev (keys);
- g_free (uri_escaped);
- }
-
- g_object_set (renderer, "markup", desc,
- "ellipsize-set", TRUE, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- g_free (desc);
- g_free (title);
-}
-
-static void
-midori_location_action_popup_position (MidoriLocationAction* action,
- gint matches)
-{
- GtkWidget* popup = action->popup;
- GtkWidget* widget = action->entry;
- GdkWindow* window = gtk_widget_get_window (widget);
- gint wx, wy, items;
- GtkRequisition menu_req;
- GtkRequisition widget_req;
- GdkScreen* screen;
- gint monitor_num;
- GdkRectangle monitor;
- GtkAllocation alloc;
- gint height, sep, width, toplevel_height;
- GtkWidget* scrolled = gtk_widget_get_parent (action->treeview);
- GtkWidget* toplevel;
-
- if (!window)
- return;
-
- gtk_widget_get_allocation (widget, &alloc);
- #if GTK_CHECK_VERSION (3, 0, 0)
- gtk_widget_get_preferred_size (widget, &widget_req, NULL);
- #else
- gtk_widget_size_request (widget, &widget_req);
- #endif
- gdk_window_get_origin (window, &wx, &wy);
-
- #if GTK_CHECK_VERSION (3, 0, 0)
- wx += alloc.x;
- wy += alloc.y + (alloc.height - widget_req.height) / 2;
- #endif
-
- gtk_tree_view_column_cell_get_size (
- gtk_tree_view_get_column (GTK_TREE_VIEW (action->treeview), 0),
- NULL, NULL, NULL, NULL, &height);
- if (height == 0)
- return;
- gtk_widget_style_get (action->treeview, "vertical-separator", &sep, NULL);
- height += sep;
-
- /* Constrain to screen/ window size */
- screen = gtk_widget_get_screen (widget);
- monitor_num = gdk_screen_get_monitor_at_window (screen, window);
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
- toplevel = gtk_widget_get_toplevel (widget);
- gtk_window_get_size (GTK_WINDOW (toplevel), NULL, &toplevel_height);
- toplevel_height = MIN (toplevel_height, monitor.height);
- if (wy > toplevel_height / 2)
- items = MIN (matches, ((monitor.y + wy) / height) - 1);
- else
- items = MIN (matches, ((toplevel_height - wy) / height) - 1);
- width = MIN (alloc.width, monitor.width);
-
- gtk_tree_view_columns_autosize (GTK_TREE_VIEW (action->treeview));
- #if GTK_CHECK_VERSION (3, 0, 0)
- gtk_widget_set_size_request (scrolled, width, -1);
- gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (scrolled), width);
- gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (scrolled), items * height);
- gtk_widget_get_preferred_size (popup, &menu_req, NULL);
- #else
- gtk_widget_set_size_request (scrolled, width, items * height);
- gtk_widget_size_request (popup, &menu_req);
- #endif
-
- if (wx < monitor.x)
- wx = monitor.x;
- else if (wx + menu_req.width > monitor.x + monitor.width)
- wx = monitor.x + monitor.width - menu_req.width;
-
- if (wy + widget_req.height + menu_req.height <= monitor.y + monitor.height ||
- wy - monitor.y < (monitor.y + monitor.height) - (wy + widget_req.height))
- wy += widget_req.height;
- else
- wy -= menu_req.height;
-
- gtk_window_move (GTK_WINDOW (popup), wx, wy);
-}
-
-static void
-midori_location_action_entry_set_text (GtkWidget* entry,
- const gchar* text)
-{
- /* Retain selection/ primary clipboard when replacing text ie. switching tabs */
- gchar* selection = NULL;
- GtkClipboard* clipboard;
-
- if (gtk_widget_get_realized (entry))
- {
- clipboard = gtk_widget_get_clipboard (entry, GDK_SELECTION_PRIMARY);
- int start, end;
- if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (entry)
- && gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end))
- selection = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
- }
-
- gtk_entry_set_text (GTK_ENTRY (entry), text);
-
- if (selection != NULL)
- {
- gtk_clipboard_set_text (clipboard, selection, strlen (selection));
- g_free (selection);
- }
-}
-
-static void
-midori_location_action_complete (MidoriLocationAction* action,
- gboolean new_tab,
- const gchar* uri)
-{
- if (midori_autocompleter_can_action (action->autocompleter, uri))
- midori_autocompleter_action (action->autocompleter, uri, action->key, NULL, NULL);
- else
- {
- midori_location_action_popdown_completion (action);
- midori_location_action_entry_set_text (action->entry, uri);
- g_signal_emit (action, signals[SUBMIT_URI], 0, uri, new_tab);
- }
-}
-
-static gboolean
-midori_location_action_treeview_button_press_cb (GtkWidget* treeview,
- GdkEventButton* event,
- MidoriLocationAction* action)
-{
- GtkTreePath* path;
-
- if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview),
- event->x, event->y, &path, NULL, NULL, NULL))
- {
- GtkTreeIter iter;
- gchar* uri;
-
- gtk_tree_model_get_iter (action->completion_model, &iter, path);
- gtk_tree_path_free (path);
- gtk_tree_model_get (action->completion_model, &iter,
- MIDORI_AUTOCOMPLETER_COLUMNS_URI, &uri, -1);
- midori_location_action_complete (action,
- MIDORI_MOD_NEW_TAB (event->state), uri);
- g_free (uri);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-midori_location_action_populated_suggestions_cb (MidoriAutocompleter* autocompleter,
- guint count,
- MidoriLocationAction* action)
-{
- GtkTreePath* path = gtk_tree_path_new_first ();
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (action->treeview), path, NULL,
- FALSE, 0.0, 0.0);
- gtk_tree_path_free (path);
- midori_location_action_popup_position (action, count);
-}
-
-void
-midori_app_set_browsers (MidoriApp* app,
- KatzeArray* browsers,
- MidoriBrowser* browser);
-
-static gboolean
-midori_location_action_popup_timeout_cb (gpointer data)
-{
- MidoriLocationAction* action = data;
- GtkTreeViewColumn* column;
-
- if (!gtk_widget_has_focus (action->entry))
- return FALSE;
-
- /* Empty string or starting with a space means: no completion */
- if (!(action->key && *action->key && *action->key != ' '))
- {
- midori_location_action_popdown_completion (action);
- return FALSE;
- }
-
- if (action->autocompleter == NULL)
- {
- MidoriApp* app = midori_app_new_proxy (NULL);
- MidoriBrowser* browser = midori_browser_get_for_widget (action->entry);
- g_object_set (app,
- "history", action->history,
- "search-engines", action->search_engines,
- NULL);
- /* FIXME: tabs of multiple windows */
- KatzeArray* browsers = katze_array_new (MIDORI_TYPE_BROWSER);
- katze_array_add_item (browsers, browser);
- midori_app_set_browsers (app, browsers, browser);
- action->autocompleter = midori_autocompleter_new (G_OBJECT (app));
- g_signal_connect (action->autocompleter, "populated",
- G_CALLBACK (midori_location_action_populated_suggestions_cb), action);
- g_object_unref (app);
- midori_autocompleter_add (action->autocompleter,
- MIDORI_COMPLETION (midori_view_completion_new ()));
- /* FIXME: Currently HistoryCompletion doesn't work in memory */
- if (action->history != NULL)
- midori_autocompleter_add (action->autocompleter,
- MIDORI_COMPLETION (midori_history_completion_new ()));
- midori_autocompleter_add (action->autocompleter,
- MIDORI_COMPLETION (midori_search_completion_new ()));
- }
-
- if (!midori_autocompleter_can_complete (action->autocompleter, action->key))
- {
- midori_location_action_popdown_completion (action);
- return FALSE;
- }
-
- midori_autocompleter_complete (action->autocompleter, action->key, NULL, NULL);
-
- if (G_UNLIKELY (!action->popup))
- {
- GtkWidget* popup;
- GtkWidget* popup_frame;
- GtkWidget* scrolled;
- GtkWidget* treeview;
- GtkCellRenderer* renderer;
-
- action->completion_model = (GtkTreeModel*)midori_autocompleter_get_model (action->autocompleter);
-
- popup = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_window_set_type_hint (GTK_WINDOW (popup), GDK_WINDOW_TYPE_HINT_COMBO);
- /* Window managers may ignore programmatic resize without this */
- gtk_window_set_resizable (GTK_WINDOW (popup), FALSE);
- popup_frame = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (popup_frame), GTK_SHADOW_ETCHED_IN);
- gtk_container_add (GTK_CONTAINER (popup), popup_frame);
- scrolled = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
- "hscrollbar-policy", GTK_POLICY_NEVER,
- "vscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL);
- gtk_container_add (GTK_CONTAINER (popup_frame), scrolled);
- treeview = gtk_tree_view_new_with_model (action->completion_model);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
- gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (treeview), TRUE);
- gtk_container_add (GTK_CONTAINER (scrolled), treeview);
- g_signal_connect (treeview, "button-press-event",
- G_CALLBACK (midori_location_action_treeview_button_press_cb), action);
- /* a nasty hack to get the completions treeview to size nicely */
- gtk_widget_set_size_request (gtk_scrolled_window_get_vscrollbar (
- GTK_SCROLLED_WINDOW (scrolled)), -1, 0);
- action->treeview = treeview;
- #if !GTK_CHECK_VERSION (3, 4, 0)
- gtk_widget_realize (action->treeview);
- #endif
-
- column = gtk_tree_view_column_new ();
- renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), renderer, FALSE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer,
- "gicon", MIDORI_AUTOCOMPLETER_COLUMNS_ICON,
- "stock-size", MIDORI_AUTOCOMPLETER_COLUMNS_SIZE,
- "yalign", MIDORI_AUTOCOMPLETER_COLUMNS_YALIGN,
- "cell-background", MIDORI_AUTOCOMPLETER_COLUMNS_BACKGROUND,
- NULL);
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), renderer, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer,
- "cell-background", MIDORI_AUTOCOMPLETER_COLUMNS_BACKGROUND,
- NULL);
- gtk_tree_view_column_set_expand (column, TRUE);
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), renderer,
- midori_location_entry_render_title_cb, action, NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), renderer, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer,
- "cell-background", MIDORI_AUTOCOMPLETER_COLUMNS_BACKGROUND, NULL);
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), renderer,
- midori_location_entry_render_uri_cb, action, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
-
- action->popup = popup;
- g_signal_connect (popup, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &action->popup);
- gtk_widget_show_all (popup_frame);
- }
-
- if (!gtk_widget_get_visible (action->popup))
- {
- GtkWidget* toplevel = gtk_widget_get_toplevel (action->entry);
- gtk_window_set_screen (GTK_WINDOW (action->popup),
- gtk_widget_get_screen (action->entry));
- gtk_window_set_transient_for (GTK_WINDOW (action->popup), GTK_WINDOW (toplevel));
- #if GTK_CHECK_VERSION (3, 4, 0)
- gtk_window_set_attached_to (GTK_WINDOW (action->popup), action->entry);
- #endif
- gtk_widget_show (action->popup);
- }
-
- return FALSE;
-}
-
-static void
-midori_location_action_popup_completion (MidoriLocationAction* action,
- GtkWidget* entry,
- gchar* key)
-{
- katze_assign (action->key, key);
- if (action->entry != entry)
- {
- action->entry = entry;
- g_signal_connect (entry, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &action->entry);
- }
- g_idle_add (midori_location_action_popup_timeout_cb, action);
-}
-
-static void
-midori_location_action_popdown_completion (MidoriLocationAction* location_action)
-{
- if (G_LIKELY (location_action->popup))
- {
- gtk_widget_hide (location_action->popup);
- katze_assign (location_action->key, NULL);
- gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (
- GTK_TREE_VIEW (location_action->treeview)));
- }
- location_action->completion_index = -1;
-}
-
-static GtkWidget*
-midori_location_action_entry_for_proxy (GtkWidget* proxy)
-{
- GtkWidget* alignment = gtk_bin_get_child (GTK_BIN (proxy));
- GtkWidget* entry = gtk_bin_get_child (GTK_BIN (alignment));
- return entry;
-}
-
-static void
-midori_location_action_init (MidoriLocationAction* location_action)
-{
- location_action->progress = 0.0;
- location_action->completion_index = -1;
-}
-
-static void
-midori_location_action_finalize (GObject* object)
-{
- MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (object);
-
- katze_object_assign (location_action->icon, NULL);
- katze_assign (location_action->text, NULL);
- katze_assign (location_action->secondary_icon, NULL);
- katze_assign (location_action->tooltip, NULL);
- katze_assign (location_action->placeholder, NULL);
- katze_object_assign (location_action->search_engines, NULL);
- katze_assign (location_action->autocompleter, NULL);
-
- katze_assign (location_action->key, NULL);
- if (location_action->popup)
- {
- gtk_widget_destroy (location_action->popup);
- location_action->popup = NULL;
- }
- katze_object_assign (location_action->history, NULL);
-
- G_OBJECT_CLASS (midori_location_action_parent_class)->finalize (object);
-}
-
-static void
-midori_location_action_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_PROGRESS:
- midori_location_action_set_progress (location_action,
- g_value_get_double (value));
- break;
- case PROP_SECONDARY_ICON:
- midori_location_action_set_secondary_icon (location_action,
- g_value_get_string (value));
- break;
- case PROP_HISTORY:
- {
- katze_assign (location_action->history, g_value_dup_object (value));
- break;
- }
- case PROP_PLACEHOLDER_TEXT:
- katze_assign (location_action->placeholder, g_strdup(g_value_get_string (value)));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_location_action_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_PROGRESS:
- g_value_set_double (value, location_action->progress);
- break;
- case PROP_SECONDARY_ICON:
- g_value_set_string (value, location_action->secondary_icon);
- break;
- case PROP_HISTORY:
- g_value_set_object (value, location_action->history);
- break;
- case PROP_PLACEHOLDER_TEXT:
- g_value_set_string (value, location_action->placeholder);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_location_action_activate (GtkAction* action)
-{
- GSList* proxies;
- GtkWidget* entry;
-
- proxies = gtk_action_get_proxies (action);
-
- for (; proxies != NULL; proxies = g_slist_next (proxies))
- if (GTK_IS_TOOL_ITEM (proxies->data))
- {
- entry = midori_location_action_entry_for_proxy (proxies->data);
-
- /* Obviously only one widget can end up with the focus.
- Yet we can't predict which one that is, can we? */
- gtk_widget_grab_focus (entry);
- }
-
- if (GTK_ACTION_CLASS (midori_location_action_parent_class)->activate)
- GTK_ACTION_CLASS (midori_location_action_parent_class)->activate (action);
-}
-
-static void
-midori_location_action_entry_drag_data_get_cb (GtkWidget* entry,
- GdkDragContext* context,
- GtkSelectionData* data,
- guint info,
- guint32 time,
- GtkAction* action)
-{
- if (gtk_entry_get_current_icon_drag_source (GTK_ENTRY (entry)) == GTK_ENTRY_ICON_PRIMARY)
- {
- const gchar* uri = gtk_entry_get_text (GTK_ENTRY (entry));
- gchar** uris = g_strsplit (uri, uri, 1);
- gtk_selection_data_set_uris (data, uris);
- g_strfreev (uris);
- }
-}
-
-static void
-midori_location_action_entry_set_secondary_icon (GtkEntry* entry,
- const gchar* stock_id)
-{
- GtkStockItem stock_item;
- if (stock_id && gtk_stock_lookup (stock_id, &stock_item))
- gtk_entry_set_icon_from_stock (entry, GTK_ENTRY_ICON_SECONDARY, stock_id);
- else
- gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, stock_id);
-}
-
-static GtkWidget*
-midori_location_action_create_tool_item (GtkAction* action)
-{
- MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);
- GtkWidget* toolitem;
- GtkWidget* alignment;
- GtkWidget* entry;
-
- GtkTargetList *targetlist;
-
- toolitem = GTK_WIDGET (gtk_tool_item_new ());
- gtk_tool_item_set_expand (GTK_TOOL_ITEM (toolitem), TRUE);
-
- alignment = gtk_alignment_new (0.0f, 0.5f, 1.0f, 0.1f);
- gtk_widget_show (alignment);
- gtk_container_add (GTK_CONTAINER (toolitem), alignment);
-
- entry = gtk_entry_new ();
- #if GTK_CHECK_VERSION (3, 6, 0)
- gtk_entry_set_input_purpose (GTK_ENTRY (entry), GTK_INPUT_PURPOSE_URL);
- #endif
- gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY, TRUE);
- gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY, TRUE);
-
- if (location_action->text != NULL)
- gtk_entry_set_text (GTK_ENTRY (entry), location_action->text);
- midori_location_action_entry_set_secondary_icon (GTK_ENTRY (entry), location_action->secondary_icon);
- gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, location_action->icon);
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, location_action->tooltip);
- gtk_entry_set_placeholder_text(GTK_ENTRY (entry), location_action->placeholder);
-
- targetlist = gtk_target_list_new (NULL, 0);
- gtk_target_list_add_uri_targets (targetlist, 0);
- gtk_entry_set_icon_drag_source (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, targetlist, GDK_ACTION_ASK | GDK_ACTION_COPY | GDK_ACTION_LINK);
- gtk_target_list_unref (targetlist);
- g_signal_connect (entry, "drag-data-get",
- G_CALLBACK (midori_location_action_entry_drag_data_get_cb), action);
- gtk_widget_show (entry);
- gtk_container_add (GTK_CONTAINER (alignment), entry);
-
- return toolitem;
-}
-
-static void
-midori_location_action_changed_cb (GtkEntry* entry,
- MidoriLocationAction* location_action)
-{
- if (g_object_get_data (G_OBJECT (entry), "sokoke_showing_default"))
- katze_assign (location_action->text, g_strdup (""));
- else
- katze_assign (location_action->text, g_strdup (gtk_entry_get_text (entry)));
-}
-
-static void
-midori_location_action_move_cursor_cb (GtkEntry* entry,
- GtkMovementStep step,
- gint count,
- gboolean extend_selection,
- MidoriLocationAction* action)
-{
- gchar* text = g_strdup (pango_layout_get_text (gtk_entry_get_layout (entry)));
- /* Update entry with the completed text */
- gtk_entry_set_text (entry, text);
- g_free (text);
- midori_location_action_popdown_completion (action);
-}
-
-static void
-midori_location_action_backspace_cb (GtkWidget* entry,
- MidoriLocationAction* action)
-{
- gchar* key = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
- midori_location_action_popup_completion (action, entry, key);
- action->completion_index = -1;
-}
-
-static void
-midori_location_action_paste_clipboard_cb (GtkWidget* entry,
- MidoriLocationAction* action)
-{
- gchar* key = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
- midori_location_action_popup_completion (action, entry, key);
- action->completion_index = -1;
-}
-
-static gboolean
-midori_location_action_button_press_event_cb (GtkEntry* entry,
- GdkEventKey* event,
- MidoriLocationAction* action)
-{
- if (action->popup && gtk_widget_get_visible (action->popup))
- {
- midori_location_action_popdown_completion (action);
-
- /* Allow button handling, for context menu and selection */
- return FALSE;
- }
-
- return FALSE;
-}
-
-static gboolean
-midori_location_action_key_press_event_cb (GtkEntry* entry,
- GdkEventKey* event,
- GtkAction* action)
-{
- gboolean handled = FALSE;
- g_signal_emit (action, signals[KEY_PRESS_EVENT], 0, event, &handled);
- if (handled)
- return TRUE;
-
- GtkWidget* widget = GTK_WIDGET (entry);
- MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);
- const gchar* text;
- gboolean is_enter = FALSE;
-
- switch (event->keyval)
- {
- case GDK_KEY_ISO_Enter:
- case GDK_KEY_KP_Enter:
- case GDK_KEY_Return:
- is_enter = TRUE;
- case GDK_KEY_Left:
- case GDK_KEY_KP_Left:
- case GDK_KEY_Right:
- case GDK_KEY_KP_Right:
- if (location_action->popup && gtk_widget_get_visible (location_action->popup))
- {
- GtkTreeModel* model = location_action->completion_model;
- GtkTreeIter iter;
- gint selected = location_action->completion_index;
- if (selected > -1 &&
- gtk_tree_model_iter_nth_child (model, &iter, NULL, selected))
- {
- gchar* uri;
- gtk_tree_model_get (model, &iter,
- MIDORI_AUTOCOMPLETER_COLUMNS_URI, &uri, -1);
-
- if (is_enter)
- midori_location_action_complete (location_action,
- MIDORI_MOD_NEW_TAB (event->state), uri);
- else
- {
- midori_location_action_popdown_completion (location_action);
- midori_location_action_entry_set_text (GTK_WIDGET (entry), uri);
- }
-
- g_free (uri);
- return TRUE;
- }
- midori_location_action_popdown_completion (location_action);
- }
-
- if (is_enter && (text = gtk_entry_get_text (entry)) && *text)
- {
- g_signal_emit (action, signals[SUBMIT_URI], 0, text,
- MIDORI_MOD_NEW_TAB (event->state));
- }
- break;
- case GDK_KEY_Escape:
- {
- if (location_action->popup && gtk_widget_get_visible (location_action->popup))
- {
- midori_location_action_popdown_completion (location_action);
- text = gtk_entry_get_text (entry);
- pango_layout_set_text (gtk_entry_get_layout (entry), text, -1);
- return TRUE;
- }
-
- g_signal_emit (action, signals[RESET_URI], 0);
- /* Return FALSE to allow Escape to stop loading */
- return FALSE;
- }
- case GDK_KEY_Delete:
- case GDK_KEY_KP_Delete:
- {
- gint selected = location_action->completion_index;
- GtkTreeModel* model = location_action->completion_model;
- GtkTreeIter iter;
-
- if (selected > -1 &&
- gtk_tree_model_iter_nth_child (model, &iter, NULL, selected))
- {
- gchar* uri;
- gchar* sqlcmd;
- sqlite3* db;
- gchar* errmsg;
- gint result;
-
- gtk_tree_model_get (model, &iter,
- MIDORI_AUTOCOMPLETER_COLUMNS_URI, &uri, -1);
- sqlcmd = sqlite3_mprintf ("DELETE FROM history "
- "WHERE uri = '%q'", uri);
- g_free (uri);
- db = g_object_get_data (G_OBJECT (location_action->history), "db");
- result = sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg);
- sqlite3_free (sqlcmd);
- if (result == SQLITE_ERROR)
- {
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- MIDORI_AUTOCOMPLETER_COLUMNS_URI, errmsg, -1);
- sqlite3_free (errmsg);
- break;
- }
- if (result != SQLITE_OK || sqlite3_changes (db) == 0)
- break;
- if (!gtk_list_store_remove (GTK_LIST_STORE (model), &iter))
- {
- midori_location_action_popdown_completion (location_action);
- break;
- }
- /* Fall through to advance the selection */
- }
- else
- break;
- }
- case GDK_KEY_Down:
- case GDK_KEY_KP_Down:
- case GDK_KEY_Up:
- case GDK_KEY_KP_Up:
- case GDK_KEY_Tab:
- case GDK_KEY_ISO_Left_Tab:
- case GDK_KEY_Page_Down:
- case GDK_KEY_Page_Up:
- {
- if ((event->keyval == GDK_KEY_Page_Up || event->keyval == GDK_KEY_Page_Down) &&
- !(location_action->popup && gtk_widget_get_visible (location_action->popup)))
- return TRUE;
- if (location_action->popup && gtk_widget_get_visible (location_action->popup))
- {
- GtkTreeModel* model = location_action->completion_model;
- gint matches = gtk_tree_model_iter_n_children (model, NULL);
- GtkTreePath* path;
- GtkTreeIter iter;
- gint selected = location_action->completion_index;
-
- if (event->keyval == GDK_KEY_Down || event->keyval == GDK_KEY_KP_Down
- || ((event->keyval == GDK_KEY_Tab || event->keyval == GDK_KEY_ISO_Left_Tab)
- && !(event->state & GDK_SHIFT_MASK)))
- {
- selected = selected + 1;
- if (selected == matches)
- selected = -1;
- }
- else if (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_KP_Up
- || ((event->keyval == GDK_KEY_Tab || event->keyval == GDK_KEY_ISO_Left_Tab)
- && (event->state & GDK_SHIFT_MASK)))
- {
- if (selected == -1)
- selected = matches - 1;
- else
- selected = selected - 1;
- }
- else if (event->keyval == GDK_KEY_Page_Down)
- {
- if (selected == -1)
- selected = 0;
- else if (selected < matches - 1)
- selected = MIN (selected + 14, matches -1);
- else
- selected = -1;
- }
- else if (event->keyval == GDK_KEY_Page_Up)
- {
- if (selected == -1)
- selected = matches - 1;
- else if (selected > 0)
- selected = MAX (selected - 14, 0);
- else
- selected = -1;
- }
- else if (event->keyval != GDK_KEY_KP_Delete && event->keyval != GDK_KEY_Delete)
- g_assert_not_reached ();
-
- if (selected != -1)
- {
- path = gtk_tree_path_new_from_indices (selected, -1);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (location_action->treeview),
- path, NULL, FALSE);
- gtk_tree_path_free (path);
-
- if (gtk_tree_model_iter_nth_child (model, &iter, NULL, selected))
- {
- gchar* uri;
- gtk_tree_model_get (model, &iter,
- MIDORI_AUTOCOMPLETER_COLUMNS_URI, &uri, -1);
- /* Update the layout without actually changing the text */
- pango_layout_set_text (gtk_entry_get_layout (entry), uri, -1);
- g_free (uri);
- }
- }
- else
- gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (location_action->treeview)));
-
- location_action->completion_index = selected;
- return TRUE;
- }
-
- /* Allow Tab to handle focus if the popup is closed */
- if (event->keyval == GDK_KEY_Tab || event->keyval == GDK_KEY_ISO_Left_Tab)
- return FALSE;
- return TRUE;
- }
- default:
- {
- gunichar character;
- gchar buffer[7];
- gint length;
- gchar* key;
-
- character = gdk_keyval_to_unicode (event->keyval);
- /* Don't trigger completion on control characters */
- if (!character || event->is_modifier)
- return FALSE;
-
- length = g_unichar_to_utf8 (character, buffer);
- buffer[length] = '\0';
- key = g_strconcat (gtk_entry_get_text (entry), buffer, NULL);
- midori_location_action_popup_completion (location_action, widget, key);
- location_action->completion_index = -1;
- return FALSE;
- }
- }
- return FALSE;
-}
-
-static void
-midori_location_action_preedit_changed_cb (GtkWidget* entry,
- const gchar* preedit,
- GtkAction* action)
-{
- MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);
- gchar* key = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
- midori_location_action_popup_completion (location_action, entry, key);
-}
-
-static gboolean
-midori_location_action_focus_in_event_cb (GtkWidget* widget,
- GdkEventKey* event,
- GtkAction* action)
-{
- g_signal_emit (action, signals[FOCUS_IN], 0);
- return FALSE;
-}
-
-static gboolean
-midori_location_action_focus_out_event_cb (GtkWidget* widget,
- GdkEventKey* event,
- GtkAction* action)
-{
- midori_location_action_popdown_completion (MIDORI_LOCATION_ACTION (action));
- g_signal_emit (action, signals[FOCUS_OUT], 0);
- return FALSE;
-}
-
-#ifdef HAVE_GCR
- #define GCR_API_SUBJECT_TO_CHANGE
- #include <gcr/gcr.h>
-#endif
-
-#ifndef HAVE_WEBKIT2
-static GHashTable* message_map = NULL;
-void
-midori_map_add_message (SoupMessage* message)
-{
- SoupURI* uri = soup_message_get_uri (message);
- if (message_map == NULL)
- message_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- g_return_if_fail (uri && uri->host);
- g_hash_table_insert (message_map, g_strdup (uri->host), g_object_ref (message));
-}
-
-SoupMessage*
-midori_map_get_message (SoupMessage* message)
-{
- SoupURI* uri = soup_message_get_uri (message);
- SoupMessage* full;
- g_return_val_if_fail (uri && uri->host, message);
- if (message_map == NULL)
- message_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- full = g_hash_table_lookup (message_map, uri->host);
- if (full != NULL)
- return full;
- return message;
-}
-#endif
-
-#ifdef HAVE_GCR
-typedef enum {
- MIDORI_CERT_TRUST,
- MIDORI_CERT_REVOKE,
- MIDORI_CERT_EXPORT,
-} MidoriCertTrust;
-
-static void
-midori_location_action_cert_response_cb (GtkWidget* dialog,
- gint response,
- GcrCertificate* gcr_cert)
-{
- gchar* peer = g_object_get_data (G_OBJECT (gcr_cert), "peer");
- GError* error = NULL;
- if (response == MIDORI_CERT_TRUST)
- gcr_trust_add_pinned_certificate (gcr_cert, GCR_PURPOSE_SERVER_AUTH, peer, NULL, &error);
- else if (response == MIDORI_CERT_REVOKE)
- gcr_trust_remove_pinned_certificate (gcr_cert, GCR_PURPOSE_SERVER_AUTH, peer, NULL, &error);
- else if (response == MIDORI_CERT_EXPORT)
- {
- /* FIXME: Would be nice if GcrCertificateExporter became public */
- gchar* filename = g_strconcat (peer, ".crt", NULL);
- GtkWidget* export_dialog = (GtkWidget*)midori_file_chooser_dialog_new (_("Export certificate"),
- NULL, GTK_FILE_CHOOSER_ACTION_SAVE);
- gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (export_dialog), TRUE);
- gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (export_dialog), filename);
- g_free (filename);
-
- if (gtk_dialog_run (GTK_DIALOG (export_dialog)) == GTK_RESPONSE_OK)
- {
- gsize n_data;
- gconstpointer data = gcr_certificate_get_der_data (gcr_cert, &n_data);
- g_return_if_fail (data);
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (export_dialog));
- g_file_set_contents (filename, data, n_data, NULL);
- g_free (filename);
- }
- gtk_widget_destroy (export_dialog);
- }
- if (error != NULL)
- {
- g_warning ("Error %s trust: %s", response == MIDORI_CERT_TRUST ?
- "granting" : "revoking", error->message);
- g_error_free (error);
- }
- gtk_widget_hide (dialog);
-}
-
-#if GTK_CHECK_VERSION (3, 12, 0)
-static void
-midori_location_action_button_cb (GtkWidget* button,
- GtkWidget* dialog)
-{
- GcrCertificate* gcr_cert = g_object_get_data (G_OBJECT (dialog), "gcr-cert");
- const gchar* label = gtk_button_get_label (GTK_BUTTON (button));
- gint response;
- if (!strcmp (label, _("_Don't trust this website")))
- response = MIDORI_CERT_REVOKE;
- else if (!strcmp (label, _("_Trust this website")))
- response = MIDORI_CERT_TRUST;
- else if (!strcmp (label, _("_Export Certificate")))
- response = MIDORI_CERT_EXPORT;
- else
- g_assert_not_reached ();
- midori_location_action_cert_response_cb (dialog, response, gcr_cert);
-}
-#endif
-#endif
-
-#if GTK_CHECK_VERSION (3, 12, 0)
-static gboolean
-midori_location_action_popover_button_press_event_cb (GtkWidget* widget,
- GdkEventButton* event,
- gpointer user_data)
-{
- return GDK_EVENT_STOP;
-}
-
-static gboolean
-midori_location_action_popover_button_release_event_cb (GtkWidget* widget,
- GdkEventButton* event,
- gpointer user_data)
-{
- /* The default GtkPopOver button-press doesn't work with
- GcrCertificateDetailsWidget and fails with an assertion:
- gtk_widget_is_ancestor: assertion 'GTK_IS_WIDGET (widget)' */
- GtkWidget* child = gtk_bin_get_child (GTK_BIN (widget));
- GtkWidget* event_widget = gtk_get_event_widget ((GdkEvent*)event);
- if (child && event->window == gtk_widget_get_window (widget))
- {
- GtkAllocation child_alloc;
- gtk_widget_get_allocation (child, &child_alloc);
- if (event->x < child_alloc.x ||
- event->x > child_alloc.x + child_alloc.width ||
- event->y < child_alloc.y ||
- event->y > child_alloc.y + child_alloc.height)
- gtk_widget_hide (widget);
- }
- else if (event_widget && !gtk_widget_is_ancestor (event_widget, widget))
- gtk_widget_hide (widget);
- return GDK_EVENT_STOP;
-}
-#endif
-
-const gchar*
-midori_location_action_tls_flags_to_string (GTlsCertificateFlags tls_flags)
-{
- if (tls_flags & G_TLS_CERTIFICATE_UNKNOWN_CA)
- return _("The signing certificate authority is not known.");
- else if (tls_flags & G_TLS_CERTIFICATE_BAD_IDENTITY)
- return _("The certificate does not match the expected identity of the site that it was retrieved from.");
- else if(tls_flags & G_TLS_CERTIFICATE_NOT_ACTIVATED)
- return _("The certificate's activation time is still in the future.");
- else if (tls_flags & G_TLS_CERTIFICATE_EXPIRED)
- return _("The certificate has expired");
- else if (tls_flags & G_TLS_CERTIFICATE_REVOKED)
- return _("The certificate has been revoked according to the GTlsConnection's certificate revocation list.");
- else if (tls_flags & G_TLS_CERTIFICATE_INSECURE)
- return _("The certificate's algorithm is considered insecure.");
- else if (tls_flags & G_TLS_CERTIFICATE_GENERIC_ERROR)
- return _("Some other error occurred validating the certificate.");
- else if (tls_flags == 0)
- g_return_val_if_reached ("GTLSCertificateFlags is 0");
- g_return_val_if_reached ("Unknown GTLSCertificateFlags value");
-}
-
-static void
-midori_location_action_show_page_info (GtkWidget* widget,
- GtkBox* box,
- GtkWidget* dialog)
-{
- GTlsCertificate* tls_cert;
- GTlsCertificateFlags tls_flags;
- gchar* hostname;
-
- MidoriBrowser* browser = midori_browser_get_for_widget (widget);
- MidoriView* view = MIDORI_VIEW (midori_browser_get_current_tab (browser));
- #ifdef HAVE_WEBKIT2
- void* request = NULL;
- #else
- WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view));
- WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (web_view);
- WebKitWebDataSource* source = webkit_web_frame_get_data_source (web_frame);
- WebKitNetworkRequest* request = webkit_web_data_source_get_request (source);
- #endif
- midori_view_get_tls_info (view, request, &tls_cert, &tls_flags, &hostname);
- if (tls_cert == NULL)
- {
- g_free (hostname);
- return;
- }
-
- #ifdef HAVE_GCR
- GByteArray* der_cert;
- GcrCertificate* gcr_cert;
-
- g_object_get (tls_cert, "certificate", &der_cert, NULL);
- gcr_cert = gcr_simple_certificate_new (
- der_cert->data, der_cert->len);
- g_byte_array_unref (der_cert);
-
- #if GTK_CHECK_VERSION (3, 0, 0)
- GtkWidget* details;
- details = (GtkWidget*)gcr_certificate_details_widget_new (gcr_cert);
- gtk_widget_show (details);
- gtk_container_add (GTK_CONTAINER (box), details);
- #endif
-
- #if GTK_CHECK_VERSION (3, 12, 0)
- GtkWidget* button;
- GtkWidget* actions = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start (GTK_BOX (box), actions, FALSE, FALSE, 0);
- if (gcr_trust_is_certificate_pinned (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL))
- {
- button = gtk_button_new_with_mnemonic (_("_Don't trust this website"));
- gtk_box_pack_start (GTK_BOX (actions), button, FALSE, FALSE, 0);
- g_signal_connect (button, "clicked", G_CALLBACK (midori_location_action_button_cb), dialog);
- }
- else if (tls_flags > 0)
- {
- button = gtk_button_new_with_mnemonic (_("_Trust this website"));
- gtk_box_pack_start (GTK_BOX (actions), button, FALSE, FALSE, 0);
- g_signal_connect (button, "clicked", G_CALLBACK (midori_location_action_button_cb), dialog);
- }
- button = gtk_button_new_with_mnemonic (_("_Export certificate"));
- g_signal_connect (button, "clicked", G_CALLBACK (midori_location_action_button_cb), dialog);
- gtk_box_pack_end (GTK_BOX (actions), button, FALSE, FALSE, 0);
- gtk_widget_show_all (actions);
- #else
- if (gcr_trust_is_certificate_pinned (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL))
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- ("_Don't trust this website"), MIDORI_CERT_REVOKE, NULL);
- else if (tls_flags > 0)
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- ("_Trust this website"), MIDORI_CERT_TRUST, NULL);
- gtk_container_child_set (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dialog))),
- gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Export certificate"), MIDORI_CERT_EXPORT),
- "secondary", TRUE, NULL);
- g_signal_connect (dialog, "response",
- G_CALLBACK (midori_location_action_cert_response_cb), gcr_cert);
- #endif
-
- g_object_set_data_full (G_OBJECT (gcr_cert), "peer", hostname, (GDestroyNotify)g_free);
- g_object_set_data_full (G_OBJECT (dialog), "gcr-cert", gcr_cert, (GDestroyNotify)g_object_unref);
- #endif
-
- /* With GTK+2 the scrolled contents can't communicate a natural size to the window */
- #if !GTK_CHECK_VERSION (3, 0, 0)
- gtk_window_set_default_size (GTK_WINDOW (dialog), 250, 200);
- #endif
- if (!g_tls_certificate_get_issuer (tls_cert))
- gtk_box_pack_start (box, gtk_label_new (_("Self-signed")), FALSE, FALSE, 0);
-
- if (tls_flags > 0)
- {
- const gchar* tls_error = midori_location_action_tls_flags_to_string (tls_flags);
- gtk_box_pack_start (box, gtk_label_new (tls_error), FALSE, FALSE, 0);
- }
-
- g_object_unref (tls_cert);
-}
-
-static void
-midori_location_action_engine_activate_cb (GtkWidget* menuitem,
- MidoriSearchAction* search_action)
-{
- KatzeItem* item;
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "engine");
- midori_search_action_set_default_item (search_action, item);
-}
-
-void
-midori_location_action_icon_released_cb (GtkWidget* widget,
- GtkEntryIconPosition icon_pos,
- gint button,
- GtkAction* action)
-{
- /* The dialog should "toggle" like a menu, as far as users go */
- MidoriBrowser* browser = midori_browser_get_for_widget (widget);
- GtkActionGroup* actions = midori_browser_get_action_group (browser);
- MidoriSearchAction *search_action = MIDORI_SEARCH_ACTION (
- gtk_action_group_get_action (actions, "Search")
- );
-
- static GtkWidget* dialog = NULL;
- if (icon_pos == GTK_ENTRY_ICON_PRIMARY && dialog != NULL)
- {
- gtk_widget_destroy (dialog);
- return; // Previously code was running on and the widget was being rebuilt
- }
-
- if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
- {
- /* No "security" window for blank pages */
- if (midori_uri_is_blank (MIDORI_LOCATION_ACTION (action)->text))
- {
- GtkMenu* menu = midori_search_action_get_menu (widget,
- search_action,
- midori_location_action_engine_activate_cb );
- katze_widget_popup (widget, menu, NULL, KATZE_MENU_POSITION_LEFT);
- return;
- }
-
- GtkWidget* content_area;
- GtkWidget* hbox;
-
- #if GTK_CHECK_VERSION (3, 12, 0)
- dialog = gtk_popover_new (widget);
- content_area = gtk_vbox_new (FALSE, 6);
- gtk_container_add (GTK_CONTAINER (dialog), content_area);
- g_signal_connect (dialog, "button-press-event",
- G_CALLBACK (midori_location_action_popover_button_press_event_cb), NULL);
- g_signal_connect (dialog, "button-release-event",
- G_CALLBACK (midori_location_action_popover_button_release_event_cb), NULL);
-
- GdkRectangle icon_rect;
- gtk_entry_get_icon_area (GTK_ENTRY (widget), icon_pos, &icon_rect);
- gtk_popover_set_relative_to (GTK_POPOVER (dialog), widget);
- gtk_popover_set_pointing_to (GTK_POPOVER (dialog), &icon_rect);
- g_signal_connect (dialog, "closed", G_CALLBACK (gtk_widget_destroyed), &dialog);
- #else
- const gchar* title = _("Security details");
- dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (gtk_widget_get_toplevel (widget)),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, NULL, NULL);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- g_signal_connect (dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &dialog);
- #endif
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (hbox), gtk_image_new_from_gicon (
- gtk_entry_get_icon_gicon (GTK_ENTRY (widget), icon_pos), GTK_ICON_SIZE_DIALOG), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox),
- gtk_label_new (gtk_entry_get_icon_tooltip_text (GTK_ENTRY (widget), icon_pos)), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 0);
- midori_location_action_show_page_info (widget, GTK_BOX (content_area), dialog);
- gtk_widget_show_all (dialog);
- }
- if (icon_pos == GTK_ENTRY_ICON_SECONDARY)
- {
- gboolean result;
- g_signal_emit (action, signals[SECONDARY_ICON_RELEASED], 0,
- widget, &result);
- }
-}
-
-static void
-midori_location_action_populate_popup_cb (GtkWidget* entry,
- GtkMenuShell* menu,
- MidoriLocationAction* location_action)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (entry);
- GtkActionGroup* actions = midori_browser_get_action_group (browser);
- GtkWidget* menuitem;
- GtkClipboard* clipboard = gtk_clipboard_get_for_display (
- gtk_widget_get_display (entry),GDK_SELECTION_CLIPBOARD);
-
- menuitem = gtk_separator_menu_item_new ();
- gtk_widget_show (menuitem);
- gtk_menu_shell_append (menu, menuitem);
- menuitem = gtk_action_create_menu_item (
- gtk_action_group_get_action (actions, "ManageSearchEngines"));
- GtkWidget* accel_label = gtk_bin_get_child (GTK_BIN (menuitem));
- if (accel_label != NULL)
- gtk_accel_label_set_accel_closure (GTK_ACCEL_LABEL (accel_label), NULL);
- gtk_menu_shell_append (menu, menuitem);
- menuitem = gtk_action_create_menu_item (
- gtk_action_group_get_action (actions, "PasteProceed"));
- accel_label = gtk_bin_get_child (GTK_BIN (menuitem));
- if (accel_label != NULL)
- gtk_accel_label_set_accel_closure (GTK_ACCEL_LABEL (accel_label), NULL);
- /* Insert menu item after default Paste menu item */
- gtk_menu_shell_insert (menu, menuitem, 3);
- if (!gtk_clipboard_wait_is_text_available (clipboard))
- gtk_widget_set_sensitive (menuitem, FALSE);
-}
-
-static void
-midori_location_action_connect_proxy (GtkAction* action,
- GtkWidget* proxy)
-{
- GTK_ACTION_CLASS (midori_location_action_parent_class)->connect_proxy (
- action, proxy);
-
- if (GTK_IS_TOOL_ITEM (proxy))
- {
- GtkWidget* entry = midori_location_action_entry_for_proxy (proxy);
- gtk_entry_set_progress_fraction (GTK_ENTRY (entry),
- MIDORI_LOCATION_ACTION (action)->progress);
-
- g_object_connect (entry,
- "signal::changed",
- midori_location_action_changed_cb, action,
- "signal::move-cursor",
- midori_location_action_move_cursor_cb, action,
- "signal-after::backspace",
- midori_location_action_backspace_cb, action,
- "signal-after::paste-clipboard",
- midori_location_action_paste_clipboard_cb, action,
- "signal::button-press-event",
- midori_location_action_button_press_event_cb, action,
- "signal::key-press-event",
- midori_location_action_key_press_event_cb, action,
- "signal-after::preedit-changed",
- midori_location_action_preedit_changed_cb, action,
- "signal::focus-in-event",
- midori_location_action_focus_in_event_cb, action,
- "signal::focus-out-event",
- midori_location_action_focus_out_event_cb, action,
- "signal::icon-release",
- midori_location_action_icon_released_cb, action,
- "signal::populate-popup",
- midori_location_action_populate_popup_cb, action,
- NULL);
- }
-}
-
-static void
-midori_location_action_disconnect_proxy (GtkAction* action,
- GtkWidget* proxy)
-{
- /* FIXME: This is wrong */
- g_signal_handlers_disconnect_by_func (proxy,
- G_CALLBACK (gtk_action_activate), action);
-
- GTK_ACTION_CLASS (midori_location_action_parent_class)->disconnect_proxy
- (action, proxy);
-}
-
-/**
- * midori_location_action_get_text:
- * @location_action: a #MidoriLocationAction
- *
- * Retrieves the current text, which may be the current URI or
- * anything typed in the entry.
- *
- * Return value: the current text
- *
- * Since: 0.2.0
- **/
-const gchar*
-midori_location_action_get_text (MidoriLocationAction* location_action)
-{
- g_return_val_if_fail (MIDORI_IS_LOCATION_ACTION (location_action), NULL);
-
- return location_action->text;
-}
-
-/**
- * midori_location_action_set_text:
- * @location_action: a #MidoriLocationAction
- * @text: a string
- *
- * Sets the entry text to @text.
- *
- * Since: 0.2.0
- **/
-void
-midori_location_action_set_text (MidoriLocationAction* location_action,
- const gchar* text)
-{
- GSList* proxies;
-
- g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
- g_return_if_fail (text != NULL);
-
- midori_location_action_popdown_completion (location_action);
-
- katze_assign (location_action->text, g_strdup (text));
-
- if (!(proxies = gtk_action_get_proxies (GTK_ACTION (location_action))))
- return;
-
- for (; proxies != NULL; proxies = g_slist_next (proxies))
- if (GTK_IS_TOOL_ITEM (proxies->data))
- {
- GtkWidget* entry = midori_location_action_entry_for_proxy (proxies->data);
- midori_location_action_entry_set_text (entry, text);
- }
-}
-
-/**
- * midori_location_action_set_search_engines:
- * @location_action: a #MidoriLocationAction
- * @search_engines: a #KatzeArray
- *
- * Assigns the specified search engines to the location action.
- * Search engines will appear as actions in the completion.
- *
- * Since: 0.1.6
- **/
-void
-midori_location_action_set_search_engines (MidoriLocationAction* location_action,
- KatzeArray* search_engines)
-{
- g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
-
- if (search_engines)
- g_object_ref (search_engines);
-
- katze_object_assign (location_action->search_engines, search_engines);
-}
-
-gdouble
-midori_location_action_get_progress (MidoriLocationAction* location_action)
-{
- g_return_val_if_fail (MIDORI_IS_LOCATION_ACTION (location_action), 0.0);
-
- return location_action->progress;
-}
-
-void
-midori_location_action_set_progress (MidoriLocationAction* location_action,
- gdouble progress)
-{
- GSList* proxies;
-
- g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
-
- location_action->progress = CLAMP (progress, 0.0, 1.0);
-
- proxies = gtk_action_get_proxies (GTK_ACTION (location_action));
-
- for (; proxies != NULL; proxies = g_slist_next (proxies))
- if (GTK_IS_TOOL_ITEM (proxies->data))
- {
- GtkWidget* entry = midori_location_action_entry_for_proxy (proxies->data);
- gtk_entry_set_progress_fraction (GTK_ENTRY (entry), location_action->progress);
- }
-}
-
-/**
- * midori_location_action_set_secondary_icon:
- * @location_action: a #MidoriLocationAction
- * @stock_id: a stock ID, or an icon name
- *
- * Sets the secondary, ie right hand side icon.
- *
- * Since 0.4.6 @icon can be a stock ID or an icon name.
- **/
-void
-midori_location_action_set_secondary_icon (MidoriLocationAction* location_action,
- const gchar* stock_id)
-{
- GSList* proxies;
-
- g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
-
- katze_assign (location_action->secondary_icon, g_strdup (stock_id));
-
- proxies = gtk_action_get_proxies (GTK_ACTION (location_action));
-
- for (; proxies != NULL; proxies = g_slist_next (proxies))
- if (GTK_IS_TOOL_ITEM (proxies->data))
- {
- GtkWidget* entry = midori_location_action_entry_for_proxy (proxies->data);
- midori_location_action_entry_set_secondary_icon (GTK_ENTRY (entry), stock_id);
- }
-}
-
-/**
- * midori_location_set_action_primary_icon:
- * @location_action: a #MidoriLocationAction
- * @icon: a list of icon names, preferred icon first
- * @tooltip: The tooltip to show
- *
- * The primary icon is mutually exclusive with the security hint.
- *
- * Since: 0.5.1
- **/
-void
-midori_location_action_set_primary_icon (MidoriLocationAction* location_action,
- GIcon* icon,
- const gchar* tooltip)
-{
- GSList* proxies;
-
- g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
- g_return_if_fail (G_IS_ICON (icon));
- g_return_if_fail (tooltip != NULL);
-
- katze_object_assign (location_action->icon, g_object_ref (icon));
- katze_assign (location_action->tooltip, g_strdup (tooltip));
-
- proxies = gtk_action_get_proxies (GTK_ACTION (location_action));
-
- for (; proxies != NULL; proxies = g_slist_next (proxies))
- if (GTK_IS_TOOL_ITEM (proxies->data))
- {
- GtkWidget* entry = midori_location_action_entry_for_proxy (proxies->data);
- gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, icon);
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, tooltip);
- }
-}
-
-/**
- * midori_location_action_set_security_hint:
- * @location_action: a #MidoriLocationAction
- * @hint: a security hint
- *
- * Sets a security hint on the action, so that the security status
- * can be reflected visually.
- *
- * Since: 0.2.5
- **/
-void
-midori_location_action_set_security_hint (MidoriLocationAction* location_action,
- MidoriSecurity hint)
-{
- GIcon* icon;
- gchar* tooltip;
-
- g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
-
- if (hint == MIDORI_SECURITY_UNKNOWN)
- {
- gchar* icon_names[] = { "channel-insecure-symbolic", "lock-insecure", "dialog-information", NULL };
- icon = g_themed_icon_new_from_names (icon_names, -1);
- tooltip = _("Not verified");
- }
- else if (hint == MIDORI_SECURITY_TRUSTED)
- {
- gchar* icon_names[] = { "channel-secure-symbolic", "lock-secure", "locked", NULL };
- icon = g_themed_icon_new_from_names (icon_names, -1);
- tooltip = _("Verified and encrypted connection");
- }
- else if (hint == MIDORI_SECURITY_NONE)
- {
- icon = g_themed_icon_new_with_default_fallbacks ("text-html-symbolic");
- tooltip = _("Open, unencrypted connection");
- }
- else
- g_assert_not_reached ();
-
- midori_location_action_set_primary_icon (location_action, icon, tooltip);
- g_object_unref (icon);
-}
diff --git a/midori/midori-locationaction.h b/midori/midori-locationaction.h
deleted file mode 100644
index 3b17300a..00000000
--- a/midori/midori-locationaction.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- Copyright (C) 2008-2009 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 __MIDORI_LOCATION_ACTION_H__
-#define __MIDORI_LOCATION_ACTION_H__
-
-#include <katze/katze.h>
-#include "midori-view.h"
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_LOCATION_ACTION \
- (midori_location_action_get_type ())
-#define MIDORI_LOCATION_ACTION(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_LOCATION_ACTION, MidoriLocationAction))
-#define MIDORI_LOCATION_ACTION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_LOCATION_ACTION, MidoriLocationActionClass))
-#define MIDORI_IS_LOCATION_ACTION(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_LOCATION_ACTION))
-#define MIDORI_IS_LOCATION_ACTION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_LOCATION_ACTION))
-#define MIDORI_LOCATION_ACTION_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_LOCATION_ACTION, MidoriLocationActionClass))
-
-typedef struct _MidoriLocationAction MidoriLocationAction;
-typedef struct _MidoriLocationActionClass MidoriLocationActionClass;
-
-GType
-midori_location_action_get_type (void) G_GNUC_CONST;
-
-const gchar*
-midori_location_action_get_text (MidoriLocationAction* location_action);
-
-void
-midori_location_action_set_text (MidoriLocationAction* location_action,
- const gchar* text);
-
-void
-midori_location_action_set_title_for_uri (MidoriLocationAction* location_action,
- const gchar* title,
- const gchar* text);
-
-void
-midori_location_action_set_search_engines (MidoriLocationAction* location_action,
- KatzeArray* search_engines);
-
-gdouble
-midori_location_action_get_progress (MidoriLocationAction* location_action);
-
-void
-midori_location_action_set_progress (MidoriLocationAction* location_action,
- gdouble progress);
-
-void
-midori_location_action_set_secondary_icon (MidoriLocationAction* location_action,
- const gchar* stock_id);
-
-void
-midori_location_action_delete_item_from_uri (MidoriLocationAction* location_action,
- const gchar* uri);
-
-void
-midori_location_action_clear (MidoriLocationAction* location_action);
-
-void
-midori_location_action_set_primary_icon (MidoriLocationAction* location_action,
- GIcon* icon,
- const gchar* tooltip);
-
-void
-midori_location_action_set_security_hint (MidoriLocationAction* location_action,
- MidoriSecurity hint);
-
-gchar*
-midori_location_action_render_uri (gchar** keys,
- const gchar* uri_escaped);
-
-gchar*
-midori_location_action_render_title (gchar** keys,
- const gchar* title);
-
-G_END_DECLS
-
-#endif /* __MIDORI_LOCATION_ACTION_H__ */
diff --git a/midori/midori-notebook.vala b/midori/midori-notebook.vala
deleted file mode 100644
index db338231..00000000
--- a/midori/midori-notebook.vala
+++ /dev/null
@@ -1,576 +0,0 @@
-/*
- Copyright (C) 2013 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.
-*/
-
-namespace Midori {
- internal class Tally : Gtk.EventBox {
- public Midori.Tab tab { get; set; }
- Gtk.Spinner spinner;
- public Gtk.Label label;
- Gtk.HBox box;
- public Gtk.Image icon;
- Gtk.Alignment align;
- Gtk.Button close;
-
- public bool close_button_left { get; set; default = false; }
- public bool close_button_visible { get; set; default = false; }
-
- internal Tally (Midori.Tab tab) {
- this.tab = tab;
- box = new Gtk.HBox (false, 1);
- add (box);
-
- spinner = new Gtk.Spinner ();
- spinner.active = true;
- /* Ensure the spinner is the size of the icon */
- int icon_size = 16;
- Gtk.icon_size_lookup_for_settings (get_settings (),
- Gtk.IconSize.MENU, out icon_size, null);
- spinner.set_size_request (icon_size, icon_size);
- box.pack_start (spinner, false, false, 0);
- label = new Gtk.Label (null);
- label.set_alignment (0.5f, 0.5f);
- label.set_padding (0, 0);
- box.pack_start (label, true, true, 0);
- close = new Gtk.Button ();
- close.relief = Gtk.ReliefStyle.NONE;
- close.set_focus_on_click (false);
-#if !HAVE_GTK3
- close.name = "midori-close-button";
- close.style_set.connect (close_style_set);
-#endif
- icon = new Gtk.Image.from_gicon (new ThemedIcon.with_default_fallbacks ("window-close-symbolic"), Gtk.IconSize.MENU);
- close.add (icon);
- align = new Gtk.Alignment (1.0f, 0.5f, 0.0f, 0.0f);
- align.add (close);
- box.pack_start (align, false, false, 0);
- close.clicked.connect (close_clicked);
- icon = new Gtk.Image.from_gicon (new ThemedIcon.with_default_fallbacks ("text-html-symbolic"), Gtk.IconSize.MENU);
- box.pack_start (icon, false, false, 0);
- box.show_all ();
-
- tab.notify["uri"].connect (uri_changed);
- tab.notify["title"].connect (title_changed);
- tab.notify["icon"].connect (icon_changed);
- tab.notify["minimized"].connect (minimized_changed);
- tab.notify["progress"].connect (progress_changed);
- tab.colors_changed.connect (colors_changed);
- update_label ();
- label.visible = !tab.minimized;
- spinner.visible = tab.progress > 0.0;
- icon.visible = !spinner.visible;
- update_color ();
-
- notify["close-button-left"].connect (close_button_left_changed);
- notify_property ("close-button-left");
- notify["close-button-visible"].connect (close_button_visible_changed);
- notify_property ("close-button-visible");
- }
-
-#if !HAVE_GTK3
- void close_style_set (Gtk.Style? previous_style) {
- Gtk.Requisition size;
- close.child.size_request (out size);
- close.set_size_request (size.width, size.height);
- }
-#endif
-
- void close_clicked () {
- tab.destroy ();
- }
-
- void uri_changed (GLib.ParamSpec pspec) {
- label.label = tab.uri;
- }
-
- void title_changed (GLib.ParamSpec pspec) {
- update_label ();
- }
-
- void update_label () {
- string? title;
- tab.get ("title", out title);
- label.label = Midori.Tab.get_display_title (title, tab.uri);
- /* Use computed label below! */
- label.ellipsize = Midori.Tab.get_display_ellipsize (label.label, tab.uri);
- tooltip_text = label.label;
- }
-
-#if HAVE_GTK3
- GLib.Icon? scale_if_needed (GLib.Icon? icon, int scale) {
- if (icon is Gdk.Pixbuf) {
- var pixbuf = icon as Gdk.Pixbuf;
- int icon_width = 16, icon_height = 16;
- Gtk.icon_size_lookup (Gtk.IconSize.MENU, out icon_width, out icon_height);
- // Apply scale factor which is only automatically applied on ThemedIcon
- icon_width *= scale;
- icon_height *= scale;
- if (pixbuf.width != icon_width || pixbuf.height != icon_height)
- return pixbuf.scale_simple (icon_width, icon_height, Gdk.InterpType.BILINEAR);
- }
- return icon;
- }
-#endif
-
- void icon_changed (GLib.ParamSpec pspec) {
- GLib.Icon? icon;
- tab.get ("icon", out icon);
-#if HAVE_GTK3
- this.icon.set_from_gicon (scale_if_needed (icon, scale_factor), Gtk.IconSize.MENU);
-#else
- this.icon.set_from_gicon (icon, Gtk.IconSize.MENU);
-#endif
- }
-
- void colors_changed () {
- update_color ();
- }
-
- void update_color () {
- visible_window = tab.fg_color != null || tab.bg_color != null;
- label.modify_fg (Gtk.StateType.NORMAL, tab.fg_color);
- label.modify_fg (Gtk.StateType.ACTIVE, tab.fg_color);
- modify_bg (Gtk.StateType.NORMAL, tab.bg_color);
- modify_bg (Gtk.StateType.ACTIVE, tab.bg_color);
- }
-
- void close_button_left_changed (GLib.ParamSpec pspec) {
- if (close_button_left) {
- box.reorder_child (align, 0);
- box.reorder_child (label, 1);
- box.reorder_child (icon, 2);
- box.reorder_child (spinner, 3);
- } else {
- box.reorder_child (spinner, 0);
- box.reorder_child (icon, 1);
- box.reorder_child (label, 2);
- box.reorder_child (align, 3);
- }
- }
-
- void close_button_visible_changed (GLib.ParamSpec pspec) {
- align.visible = !tab.minimized && close_button_visible;
- }
-
- void minimized_changed (GLib.ParamSpec pspec) {
- label.visible = !tab.minimized;
- notify_property ("close-button-visible");
- }
-
- void progress_changed (GLib.ParamSpec pspec) {
- spinner.visible = tab.progress > 0.0;
- icon.visible = !spinner.visible;
- }
- }
-
- public class Notebook : Gtk.EventBox {
- public Gtk.Notebook notebook;
- int last_tab_size = 0;
-
-#if !HAVE_GTK3
- const string style_fixup = """
- style "midori-close-button-style"
- {
- GtkWidget::focus-padding = 0
- GtkWidget::focus-line-width = 0
- xthickness = 0
- ythickness = 0
- }
- widget "*.midori-close-button" style "midori-close-button-style"
- """;
-#endif
-
- /* Since: 0.5.7 */
- public uint count { get; private set; default = 0; }
- /* Since: 0.5.7 */
- public int index { get; set; default = -1; }
- /* Since: 0.5.7 */
- public Midori.Tab? tab { get; set; default = null; }
- /* Since: 0.5.7 */
- private Midori.Tab? previous { get; set; default = null; }
-
- /* Since: 0.5.7 */
- public bool close_buttons_left { get; set; default = true; }
- /* Since: 0.5.7 */
- public bool close_buttons_visible { get; set; default = true; }
- /* Since: 0.5.7 */
- public bool labels_visible { get; set; default = true; }
-
- /* Since: 0.5.7 */
- public signal void tab_context_menu (Midori.Tab tab, ContextAction menu);
- /* Since: 0.5.7 */
- public signal void context_menu (ContextAction menu);
- /* The current tab is about to switch, but the old tab still has focus.
- Since: 0.5.7 */
- public signal void tab_switched (Midori.Tab? old, Midori.Tab @new);
- /* A tab is about to move to a new position.
- Since: 0.5.7 */
- public signal void tab_moved (Midori.Tab tab, uint new_index);
- /* A tab is being dragging out of the window.
- Since: 0.5.7 */
- public signal void tab_detached (Midori.Tab tab, int x, int y);
- /* Since: 0.5.7 */
- public signal void new_tab ();
-
- [CCode (type = "GtkWidget*")]
- public Notebook () {
- visible_window = false;
- notebook = new Gtk.Notebook ();
- notebook.visible = notebook.scrollable = true;
- notebook.show_border = false;
- notebook.set ("group-name", PACKAGE_NAME);
- add (notebook);
-
-#if HAVE_GTK3
- get_style_context ().add_class ("dynamic-notebook");
-#else
- /* Remove the inner border between scrollbars and window border */
- Gtk.RcStyle rcstyle = new Gtk.RcStyle ();
- rcstyle.xthickness = 0;
- notebook.modify_style (rcstyle);
- Gtk.rc_parse_string (style_fixup);
-#endif
- notify["index"].connect (index_changed);
- notify["tab"].connect (tab_changed);
- notify["labels-visible"].connect (labels_visible_changed);
- notify["close-buttons-visible"].connect (close_buttons_visible_changed);
- notify["close-buttons-left"].connect (close_buttons_left_changed);
-
- notebook.size_allocate.connect (size_allocated);
- notebook.switch_page.connect (page_switched);
- notebook.page_reordered.connect (page_moved);
- notebook.create_window.connect (window_created);
-
- var add = new Gtk.Button ();
- add.tooltip_text = _("Open a new tab");
- add.relief = Gtk.ReliefStyle.NONE;
- add.add (new Gtk.Image.from_gicon (new ThemedIcon.with_default_fallbacks ("tab-new-symbolic"), Gtk.IconSize.MENU));
- add.show_all ();
- notebook.set_action_widget (add, Gtk.PackType.START);
- add.clicked.connect (()=>{
- new_tab ();
- });
- take_incoming_uris (add);
-
- button_press_event.connect (button_pressed);
- }
-
- void take_incoming_uris (Gtk.Widget widget) {
- Gtk.drag_dest_set (widget, Gtk.DestDefaults.ALL, (Gtk.TargetEntry[])null, Gdk.DragAction.COPY);
- Gtk.drag_dest_add_text_targets (widget);
- Gtk.drag_dest_add_uri_targets (widget);
- widget.drag_drop.connect (uri_dropped);
- widget.drag_data_received.connect (uri_received);
- }
-
- bool uri_dropped (Gtk.Widget widget, Gdk.DragContext context, int x, int y, uint timestamp) {
- Gtk.drag_finish (context, false, false, timestamp);
- return true;
- }
-
- void uri_received (Gtk.Widget widget, Gdk.DragContext context, int x, int y, Gtk.SelectionData data, uint ttype, uint timestamp) {
- string[] uri = data.get_uris ();
- string drag_uri = uri != null ? uri[0] : data.get_text ();
- Midori.Tab drag_tab;
- if (widget is Tally)
- drag_tab = (widget as Tally).tab;
- else {
- new_tab ();
- // Browser will have focussed the new tab
- drag_tab = tab;
- }
- drag_tab.web_view.load_uri (drag_uri);
- }
-
-
- ~Notebook () {
- notebook.size_allocate.disconnect (size_allocated);
- notebook.switch_page.disconnect (page_switched);
- notebook.page_reordered.disconnect (page_moved);
- notebook.create_window.disconnect (window_created);
- }
-
- /* Since: 0.5.8 */
- public ContextAction get_context_action () {
- var menu = new Midori.ContextAction ("NotebookContextMenu", null, null, null);
- uint counter = 0;
- foreach (var child in notebook.get_children ()) {
- var tab = child as Midori.Tab;
- var tally = notebook.get_tab_label (tab) as Tally;
- var action = new Midori.ContextAction.escaped ("Tab%u".printf (counter), tally.label.label, null, null);
- action.gicon = tally.icon.gicon;
- action.activate.connect (()=>{
- notebook.set_current_page (notebook.page_num (tab));
- });
- menu.add (action);
- counter++;
- }
- context_menu (menu);
- return menu;
- }
-
- bool button_pressed (Gdk.EventButton event) {
- /* Propagate events in logical label area */
- foreach (var child in notebook.get_children ()) {
- var tally = notebook.get_tab_label (tab) as Tally;
- Gtk.Allocation size;
- tally.get_allocation (out size);
- if (tally.get_mapped ()
- && event.x_root >= size.x
- && event.x_root <= (size.x + size.width)) {
- tally.button_press_event (event);
- return true;
- }
- }
-
- if (event.type == Gdk.EventType.2BUTTON_PRESS && event.button == 1
- || event.button == 2) {
- new_tab ();
- return true;
- }
- else if (event.button == 3) {
- var menu = get_context_action ();
- var popup = menu.create_menu (null, false);
- popup.show ();
- popup.attach_to_widget (this, null);
- popup.popup (null, null, null, event.button, event.time);
- return true;
- }
- return false;
- }
-
- public void insert (Midori.Tab tab, int index) {
- var tally = new Tally (tab);
- tally.close_button_left = close_buttons_left;
- tally.close_button_visible = close_buttons_visible;
- tally.button_press_event.connect (tab_button_pressed);
- tally.show ();
- tally.set_size_request (tab.minimized ? -1 : last_tab_size, -1);
- take_incoming_uris (tally);
-
- /* Minimum requirements for any tab */
- tab.can_focus = tab.visible = true;
- notebook.insert_page (tab, tally, index);
- notebook.set_tab_reorderable (tab, true);
- notebook.set_tab_detachable (tab, true);
- tab.destroy.connect (tab_removed);
- tab.notify["minimized"].connect (tab_minimized);
- count++;
- tab.ref ();
- relayout ();
- }
-
- void tab_removed () {
- count--;
- if (count > 0)
- relayout ();
- }
-
- void relayout () {
- Gtk.Allocation size;
- notebook.get_allocation (out size);
- resize (size.width);
- }
-
- /* Since: 0.5.8 */
- public ContextAction get_tab_context_action (Midori.Tab tab) {
- var menu = new Midori.ContextAction ("TabContextMenu", null, null, null);
- tab_context_menu (tab, menu);
- var action_window = new Midori.ContextAction ("TabWindowNew", _("Open in New _Window"), null, "window-new");
- action_window.activate.connect (()=>{
- tab_detached (tab, 128, 128);
- });
- menu.add (action_window);
- var action_minimize = new Midori.ContextAction ("TabMinimize", tab.minimized ? _("Show Tab _Label") : _("Show Tab _Icon Only"), null, null);
- action_minimize.activate.connect (()=>{
- tab.minimized = !tab.minimized;
- });
- menu.add (action_minimize);
- var action_right = new Midori.ContextAction ("TabCloseRight", ngettext ("Close Tab to the R_ight", "Close Tabs to the R_ight", count - 1), null, null);
- action_right.sensitive = count > 1;
- action_right.activate.connect (()=>{
- bool found_tab = false;
- foreach (var child in notebook.get_children ()) {
- if (found_tab)
- child.destroy ();
- else
- found_tab = child == tab;
- }
- });
- menu.add (action_right);
- var action_other = new Midori.ContextAction ("TabCloseOther", ngettext ("Close Ot_her Tab", "Close Ot_her Tabs", count - 1), null, null);
- action_other.sensitive = count > 1;
- action_other.activate.connect (()=>{
- foreach (var child in notebook.get_children ())
- if (child != tab)
- child.destroy ();
- });
- menu.add (action_other);
- var action_close = new Midori.ContextAction ("TabClose", null, null, Gtk.STOCK_CLOSE);
- action_close.activate.connect (()=>{
- tab.destroy ();
- });
- menu.add (action_close);
- return menu;
- }
-
- bool tab_button_pressed (Gtk.Widget label, Gdk.EventButton event) {
- Tally tally = label as Tally;
- if (event.button == 1) {
- /* Leave switching and dragging up to the notebook */
- return false;
- } else if (event.button == 2)
- tally.tab.destroy ();
- else if (event.button == 3) {
- var menu = get_tab_context_action (tally.tab);
- var popup = menu.create_menu (null, false);
- popup.show ();
- popup.attach_to_widget (this, null);
- popup.popup (null, null, null, event.button, event.time);
- }
- return true;
- }
-
- public void move (Midori.Tab tab, int index) {
- notebook.reorder_child (tab, index);
- }
-
- /* Chain up drawing manually to circumvent parent checks */
-#if HAVE_GTK3
- public override bool draw (Cairo.Context cr) {
- notebook.draw (cr);
- return true;
- }
-#else
- public override bool expose_event (Gdk.EventExpose event) {
- notebook.expose_event (event);
- return true;
- }
-#endif
-
- public override void forall_internal (bool include_internal, Gtk.Callback callback) {
- if (include_internal)
- callback (notebook);
- foreach (var child in notebook.get_children ())
- callback (child);
- }
-
- /* Can't override Gtk.Container.remove because it checks the parent */
- public new void remove (Midori.Tab tab) {
- return_if_fail (notebook.get_children ().find (tab) != null);
-
- notebook.remove (tab);
- tab.destroy.disconnect (tab_removed);
- tab.notify["minimized"].disconnect (tab_minimized);
- tab_removed ();
- tab.unref ();
- }
-
- void tab_minimized (GLib.ParamSpec pspec) {
- var tally = notebook.get_tab_label (tab) as Tally;
- tally.set_size_request (tab.minimized ? -1 : last_tab_size, -1);
- }
-
- public Midori.Tab get_nth_tab (int index) {
- return notebook.get_nth_page (index) as Midori.Tab;
- }
-
- public int get_tab_index (Midori.Tab tab) {
- return notebook.page_num (tab);
- }
-
- void index_changed (GLib.ParamSpec pspec) {
- notebook.set_current_page (index);
- }
-
- void tab_changed (GLib.ParamSpec pspec) {
- notebook.set_current_page (notebook.page_num (tab));
- }
-
- void labels_visible_changed (GLib.ParamSpec pspec) {
- notebook.show_tabs = labels_visible;
- }
-
- void close_buttons_visible_changed (GLib.ParamSpec pspec) {
- foreach (var child in notebook.get_children ()) {
- var tally = notebook.get_tab_label (child) as Tally;
- tally.close_button_visible = close_buttons_visible;
- }
- }
-
- void close_buttons_left_changed (GLib.ParamSpec pspec) {
- foreach (var child in notebook.get_children ()) {
- var tally = notebook.get_tab_label (child) as Tally;
- tally.close_button_left = close_buttons_left;
- }
- }
-
-#if HAVE_GTK3
- void size_allocated (Gtk.Allocation allocation) {
-#else
- void size_allocated (Gdk.Rectangle allocation) {
-#endif
- if (labels_visible && count > 0)
- resize (allocation.width);
- }
-
-#if HAVE_GTK3
- void page_switched (Gtk.Widget new_tab, uint new_index) {
-#else
- void page_switched (Gtk.NotebookPage new_tab, uint new_index) {
-#endif
- tab_switched (previous, new_tab as Tab);
- previous = (Midori.Tab)new_tab;
-
- notify["index"].disconnect (index_changed);
- notify["tab"].disconnect (tab_changed);
- index = (int)new_index;
- tab = (Midori.Tab)new_tab;
- notify["index"].connect (index_changed);
- notify["tab"].connect (tab_changed);
- }
-
- void page_moved (Gtk.Widget moving_tab, uint new_index) {
- tab_moved (moving_tab as Midori.Tab, new_index);
- /* Indices change, current tab is not in the same position */
- notify["index"].disconnect (index_changed);
- index = (int)get_tab_index (tab);
- notify["index"].connect (index_changed);
- }
-
- unowned Gtk.Notebook window_created (Gtk.Widget tab, int x, int y) {
- tab_detached (tab as Tab, x, y);
- /* The API allows now, the cast is due to bindings not having ? */
- return (Gtk.Notebook)null;
- }
-
- void resize (int new_size) {
- int n = int.max (1, (int)count);
- new_size /= n;
- int icon_size = 16;
- Gtk.icon_size_lookup_for_settings (get_settings (),
- Gtk.IconSize.MENU, out icon_size, null);
- int max_size = 150;
- int min_size = icon_size;
- if (close_buttons_visible)
- min_size += icon_size;
- new_size = new_size.clamp (min_size, max_size);
- if ((new_size - last_tab_size).abs () < 3)
- return;
-
- last_tab_size = new_size;
- foreach (var child in notebook.get_children ()) {
- var tab = child as Midori.Tab;
- var tally = notebook.get_tab_label (child) as Tally;
- tally.set_size_request (tab.minimized ? -1 : last_tab_size, -1);
- }
- }
- }
-}
diff --git a/midori/midori-panedaction.vala b/midori/midori-panedaction.vala
deleted file mode 100644
index 32cdb764..00000000
--- a/midori/midori-panedaction.vala
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- Copyright (C) 2011 Peter Hatina <phatina@redhat.com>
-
- 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.
-*/
-
-namespace Midori {
- public class PanedAction : Gtk.Action {
- Gtk.HPaned? hpaned = null;
- Gtk.ToolItem? toolitem = null;
- Child child1 = new Child();
- Child child2 = new Child();
-
- public PanedAction () {
- GLib.Object (name: "LocationSearch");
- }
-
- private struct Child {
- public Gtk.Widget widget;
- string name;
- bool resize;
- bool shrink;
- }
-
- public override unowned Gtk.Widget create_tool_item () {
- Gtk.Alignment alignment = new Gtk.Alignment (0.0f, 0.5f, 1.0f, 0.1f);
- hpaned = new Gtk.HPaned ();
- toolitem = new Gtk.ToolItem ();
- toolitem.set_expand (true);
- toolitem.add (alignment);
- alignment.add (hpaned);
-
- hpaned.pack1 (child1.widget, child1.resize, child1.shrink);
- hpaned.pack2 (child2.widget, child2.resize, child2.shrink);
- toolitem.show_all ();
- return toolitem;
- }
-
- public void set_child1 (Gtk.Widget widget, string name, bool resize, bool shrink) {
- child1.widget = widget;
- child1.name = name;
- child1.resize = resize;
- child1.shrink = shrink;
- }
-
- public void set_child2 (Gtk.Widget widget, string name, bool resize, bool shrink) {
- child2.widget = widget;
- child2.name = name;
- child2.resize = resize;
- child2.shrink = shrink;
- }
-
- public Gtk.Widget? get_child1 () {
- return child1.widget;
- }
-
- public Gtk.Widget? get_child2 () {
- return child2.widget;
- }
-
- public Gtk.Widget? get_child_by_name (string name) {
- if (name == child1.name)
- return child1.widget;
- else if (name == child2.name)
- return child2.widget;
- return null;
- }
-
- public string get_child1_name () {
- return child1.name;
- }
-
- public string get_child2_name () {
- return child2.name;
- }
- }
-}
-
diff --git a/midori/midori-panel.c b/midori/midori-panel.c
deleted file mode 100644
index 09cfc7e7..00000000
--- a/midori/midori-panel.c
+++ /dev/null
@@ -1,981 +0,0 @@
-/*
- Copyright (C) 2007-2009 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.
-*/
-
-#include "midori-panel.h"
-
-#include "midori-browser.h"
-#include "midori-platform.h"
-#include "midori-view.h"
-
-#include "marshal.h"
-
-#include <glib/gi18n.h>
-
-#include "config.h"
-
-struct _MidoriPanel
-{
- GtkHBox parent_instance;
-
- GtkWidget* labelbar;
- GtkWidget* toolbar;
- GtkToolItem* button_align;
- GtkWidget* toolbar_label;
- GtkWidget* frame;
- GtkWidget* toolbook;
- GtkWidget* notebook;
- GtkActionGroup* action_group;
-
- gboolean show_titles;
- gboolean show_controls;
- gboolean right_aligned;
- gboolean open_panels_in_windows;
-};
-
-struct _MidoriPanelClass
-{
- GtkHBoxClass parent_class;
-
- /* Signals */
- gboolean
- (*close) (MidoriPanel* panel);
-};
-
-G_DEFINE_TYPE (MidoriPanel, midori_panel, GTK_TYPE_HBOX)
-
-enum
-{
- PROP_0,
-
- PROP_SHADOW_TYPE,
- PROP_ACTION_GROUP,
- PROP_PAGE,
- PROP_SHOW_TITLES,
- PROP_SHOW_CONTROLS,
- PROP_RIGHT_ALIGNED,
- PROP_OPEN_PANELS_IN_WINDOWS,
-};
-
-enum {
- CLOSE,
- SWITCH_PAGE,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-midori_panel_finalize (GObject* object);
-
-static void
-midori_panel_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_panel_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-static gboolean
-midori_panel_close (MidoriPanel* panel)
-{
- gtk_widget_hide (GTK_WIDGET (panel));
- return FALSE;
-}
-
-static void
-midori_panel_class_init (MidoriPanelClass* class)
-{
- GObjectClass* gobject_class;
- GParamFlags flags;
-
- signals[CLOSE] = g_signal_new (
- "close",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- G_STRUCT_OFFSET (MidoriPanelClass, close),
- g_signal_accumulator_true_handled,
- NULL,
- midori_cclosure_marshal_BOOLEAN__VOID,
- G_TYPE_BOOLEAN, 0);
-
- signals[SWITCH_PAGE] = g_signal_new (
- "switch-page",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = midori_panel_finalize;
- gobject_class->set_property = midori_panel_set_property;
- gobject_class->get_property = midori_panel_get_property;
-
- class->close = midori_panel_close;
-
- flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS;
-
- g_object_class_install_property (gobject_class,
- PROP_SHADOW_TYPE,
- g_param_spec_enum (
- "shadow-type",
- "Shadow Type",
- "Appearance of the shadow around each panel",
- GTK_TYPE_SHADOW_TYPE,
- GTK_SHADOW_NONE,
- flags));
-
- /**
- * MidoriWebSettings:action-group:
- *
- * This is the action group the panel will add actions
- * corresponding to pages to.
- *
- * Since: 0.2.1
- */
- g_object_class_install_property (gobject_class,
- PROP_ACTION_GROUP,
- g_param_spec_object (
- "action-group",
- "Action Group",
- "The action group the panel will add actions to",
- GTK_TYPE_ACTION_GROUP,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_PAGE,
- g_param_spec_int (
- "page",
- "Page",
- "The index of the current page",
- -1, G_MAXINT, -1,
- flags));
-
- /**
- * MidoriWebSettings:show-titles:
- *
- * Whether to show panel titles.
- *
- * Deprecated: 0.2.3
- */
- g_object_class_install_property (gobject_class,
- PROP_SHOW_TITLES,
- g_param_spec_boolean (
- "show-titles",
- "Show Titles",
- "Whether to show panel titles",
- TRUE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriWebSettings:show-controls:
- *
- * Whether to show operating controls.
- *
- * Since: 0.1.9
- *
- * Deprecated: 0.3.0
- */
- g_object_class_install_property (gobject_class,
- PROP_SHOW_CONTROLS,
- g_param_spec_boolean (
- "show-controls",
- "Show Controls",
- "Whether to show operating controls",
- TRUE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriWebSettings:right-aligned:
- *
- * Whether to align the panel on the right.
- *
- * Since: 0.1.3
- */
- g_object_class_install_property (gobject_class,
- PROP_RIGHT_ALIGNED,
- g_param_spec_boolean (
- "right-aligned",
- "Right aligned",
- "Whether the panel is aligned to the right",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriWebSettings:open-panels-in-windows:
- *
- * Whether to open panels in separate windows.
- *
- * Since: 0.2.2
- */
- g_object_class_install_property (gobject_class,
- PROP_OPEN_PANELS_IN_WINDOWS,
- g_param_spec_boolean (
- "open-panels-in-windows",
- "Open panels in windows",
- "Whether to open panels in standalone windows by default",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-}
-
-static void
-midori_panel_button_close_clicked_cb (GtkWidget* toolitem,
- MidoriPanel* panel)
-{
- gboolean return_value;
- g_signal_emit (panel, signals[CLOSE], 0, &return_value);
-}
-
-static GtkToolItem*
-midori_panel_construct_tool_item (MidoriPanel* panel,
- MidoriViewable* viewable);
-
-static GtkWidget*
-_midori_panel_child_for_scrolled (MidoriPanel* panel,
- GtkWidget* scrolled);
-
-static void
-midori_panel_widget_destroy_cb (GtkWidget* viewable,
- GtkWidget* widget)
-{
- gtk_widget_destroy (widget);
- g_signal_handlers_disconnect_by_func (
- viewable, midori_panel_widget_destroy_cb, widget);
-}
-
-static void
-midori_panel_button_align_clicked_cb (GtkWidget* toolitem,
- MidoriPanel* panel)
-{
- midori_panel_set_right_aligned (panel, !panel->right_aligned);
-}
-
-static void
-midori_panel_destroy_cb (MidoriPanel* panel)
-{
- /* Destroy pages first, so they don't need special care */
- gtk_container_foreach (GTK_CONTAINER (panel->notebook),
- (GtkCallback) gtk_widget_destroy, NULL);
-}
-
-static void
-midori_panel_init (MidoriPanel* panel)
-{
- GtkWidget* vbox;
- GtkWidget* labelbar;
- GtkToolItem* toolitem;
-
- panel->action_group = NULL;
- panel->show_titles = TRUE;
- panel->show_controls = TRUE;
- panel->right_aligned = FALSE;
-
- /* Create the sidebar */
- panel->toolbar = gtk_toolbar_new ();
- gtk_toolbar_set_icon_size (GTK_TOOLBAR (panel->toolbar), GTK_ICON_SIZE_BUTTON);
- gtk_toolbar_set_show_arrow (GTK_TOOLBAR (panel->toolbar), FALSE);
- gtk_widget_show_all (panel->toolbar);
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (panel), vbox, TRUE, TRUE, 0);
- gtk_box_pack_end (GTK_BOX (vbox), panel->toolbar, FALSE, FALSE, 0);
-
- /* Create the titlebar */
- labelbar = gtk_toolbar_new ();
- katze_widget_add_class (labelbar, "secondary-toolbar");
- panel->labelbar = labelbar;
- gtk_toolbar_set_icon_size (GTK_TOOLBAR (labelbar), GTK_ICON_SIZE_MENU);
- gtk_toolbar_set_style (GTK_TOOLBAR (labelbar), GTK_TOOLBAR_ICONS);
- toolitem = gtk_tool_item_new ();
- gtk_tool_item_set_expand (toolitem, TRUE);
- panel->toolbar_label = gtk_label_new (NULL);
- gtk_label_set_ellipsize (GTK_LABEL (panel->toolbar_label), PANGO_ELLIPSIZE_END);
- gtk_misc_set_alignment (GTK_MISC (panel->toolbar_label), 0, 0.5);
- gtk_container_add (GTK_CONTAINER (toolitem), panel->toolbar_label);
- gtk_container_set_border_width (GTK_CONTAINER (toolitem), 6);
- gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1);
- toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem),
- _("Align sidepanel to the right"));
- gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem),
- _("Align sidepanel to the right"));
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (midori_panel_button_align_clicked_cb), panel);
- #if HAVE_OSX
- gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, 0);
- #else
- gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1);
- #endif
- panel->button_align = toolitem;
- toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_CLOSE);
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), _("Close panel"));
- gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem), _("Close panel"));
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (midori_panel_button_close_clicked_cb), panel);
- #if HAVE_OSX
- gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, 0);
- #else
- gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1);
- #endif
- gtk_box_pack_start (GTK_BOX (vbox), labelbar, FALSE, FALSE, 0);
- gtk_widget_show_all (vbox);
-
- /* Create the toolbook */
- panel->toolbook = gtk_notebook_new ();
- gtk_notebook_set_show_border (GTK_NOTEBOOK (panel->toolbook), FALSE);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (panel->toolbook), FALSE);
- gtk_box_pack_start (GTK_BOX (vbox), panel->toolbook, FALSE, FALSE, 0);
-
- /* Create the notebook */
- panel->notebook = gtk_notebook_new ();
- katze_widget_add_class (panel->notebook, "content-view");
- gtk_notebook_set_show_border (GTK_NOTEBOOK (panel->notebook), FALSE);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (panel->notebook), FALSE);
- panel->frame = gtk_frame_new (NULL);
- gtk_container_add (GTK_CONTAINER (panel->frame), panel->notebook);
- gtk_box_pack_start (GTK_BOX (vbox), panel->frame, TRUE, TRUE, 0);
- gtk_widget_show_all (panel->frame);
-
- g_signal_connect (panel, "destroy",
- G_CALLBACK (midori_panel_destroy_cb), NULL);
-}
-
-static void
-midori_panel_finalize (GObject* object)
-{
- G_OBJECT_CLASS (midori_panel_parent_class)->finalize (object);
-}
-
-static void
-midori_panel_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- MidoriPanel* panel = MIDORI_PANEL (object);
-
- switch (prop_id)
- {
- case PROP_SHADOW_TYPE:
- gtk_frame_set_shadow_type (GTK_FRAME (panel->frame),
- g_value_get_enum (value));
- break;
- case PROP_ACTION_GROUP:
- katze_object_assign (panel->action_group, g_value_dup_object (value));
- break;
- case PROP_PAGE:
- midori_panel_set_current_page (panel, g_value_get_int (value));
- break;
- case PROP_SHOW_TITLES:
- panel->show_titles = g_value_get_boolean (value);
- /* Ignore */
- break;
- case PROP_SHOW_CONTROLS:
- panel->show_controls = g_value_get_boolean (value);
- break;
- case PROP_RIGHT_ALIGNED:
- midori_panel_set_right_aligned (panel, g_value_get_boolean (value));
- break;
- case PROP_OPEN_PANELS_IN_WINDOWS:
- panel->open_panels_in_windows = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_panel_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- MidoriPanel* panel = MIDORI_PANEL (object);
-
- switch (prop_id)
- {
- case PROP_SHADOW_TYPE:
- g_value_set_enum (value,
- gtk_frame_get_shadow_type (GTK_FRAME (panel->frame)));
- break;
- case PROP_ACTION_GROUP:
- g_value_set_object (value, panel->action_group);
- break;
- case PROP_PAGE:
- g_value_set_int (value, midori_panel_get_current_page (panel));
- break;
- case PROP_SHOW_TITLES:
- g_value_set_boolean (value, panel->show_titles);
- break;
- case PROP_SHOW_CONTROLS:
- g_value_set_boolean (value, panel->show_controls);
- break;
- case PROP_RIGHT_ALIGNED:
- g_value_set_boolean (value, panel->right_aligned);
- break;
- case PROP_OPEN_PANELS_IN_WINDOWS:
- g_value_set_boolean (value, panel->open_panels_in_windows);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/**
- * midori_panel_new:
- *
- * Creates a new empty panel.
- *
- * Return value: (transfer full): a new #MidoriPanel
- **/
-GtkWidget*
-midori_panel_new (void)
-{
- MidoriPanel* panel = g_object_new (MIDORI_TYPE_PANEL,
- NULL);
-
- return GTK_WIDGET (panel);
-}
-
-/**
- * midori_panel_set_right_aligned:
- * @right_aligned: %TRUE if the panel should be aligned to the right
- *
- * Determines if the panel should be right aligned.
- *
- * Since: 0.1.3
- **/
-void
-midori_panel_set_right_aligned (MidoriPanel* panel,
- gboolean right_aligned)
-{
- GtkWidget* box;
-
- g_return_if_fail (MIDORI_IS_PANEL (panel));
-
- box = gtk_widget_get_parent (panel->toolbar);
- gtk_box_reorder_child (GTK_BOX (box), panel->toolbar,
- right_aligned ? -1 : 0);
- gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (panel->button_align),
- right_aligned ? GTK_STOCK_GO_BACK : GTK_STOCK_GO_FORWARD);
- panel->right_aligned = right_aligned;
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (panel->button_align),
- !panel->right_aligned ? _("Align sidepanel to the right")
- : _("Align sidepanel to the left"));
- gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (panel->button_align),
- !panel->right_aligned ? _("Align sidepanel to the right")
- : _("Align sidepanel to the left"));
- g_object_notify (G_OBJECT (panel), "right-aligned");
-}
-
-static void
-midori_panel_viewable_destroy_cb (GtkWidget* viewable,
- MidoriPanel* panel)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (panel));
- gint n_pages;
- gchar* action_name;
- GtkAction* action;
- gint i;
-
- i = gtk_notebook_page_num (GTK_NOTEBOOK (panel->notebook),
- g_object_get_data (G_OBJECT (viewable), "parent"));
- if (i > -1)
- gtk_notebook_remove_page (GTK_NOTEBOOK (panel->notebook), i);
- g_signal_handlers_disconnect_by_func (
- viewable, midori_panel_viewable_destroy_cb, panel);
-
- n_pages = midori_panel_get_n_pages (panel);
- if (n_pages > 0 && browser && !g_object_get_data (G_OBJECT (browser), "midori-browser-destroyed"))
- midori_panel_set_current_page (panel, (n_pages-1 > i) ? i : n_pages - 1);
-
- action_name = g_strconcat ("PanelPage",
- midori_viewable_get_stock_id (MIDORI_VIEWABLE (viewable)), NULL);
- action = gtk_action_group_get_action (panel->action_group, action_name);
- g_free (action_name);
-
- gtk_action_group_remove_action (panel->action_group, action);
- g_object_unref (G_OBJECT (action));
-}
-
-static GtkToolItem*
-midori_panel_construct_tool_item (MidoriPanel* panel,
- MidoriViewable* viewable)
-{
- GtkAction* action;
- GtkWidget* toolitem;
-
- action = g_object_get_data (G_OBJECT (viewable), "midori-panel-action");
- toolitem = gtk_action_create_tool_item (action);
- g_object_set_data (G_OBJECT (toolitem), "page", viewable);
- gtk_toolbar_insert (GTK_TOOLBAR (panel->toolbar), GTK_TOOL_ITEM (toolitem), -1);
- g_signal_connect (viewable, "destroy",
- G_CALLBACK (midori_panel_widget_destroy_cb), toolitem);
-
- return GTK_TOOL_ITEM (toolitem);
-}
-
-static void
-midori_panel_action_activate_cb (GtkRadioAction* action,
- MidoriPanel* panel)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (panel));
- GtkActionGroup* actions = midori_browser_get_action_group (browser);
- GtkAction* panel_action = gtk_action_group_get_action (actions, "Panel");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (panel_action), TRUE);
- GtkWidget* viewable = g_object_get_data (G_OBJECT (action), "viewable");
- gint n = midori_panel_page_num (panel, viewable);
-
- midori_panel_set_current_page (panel, n);
- g_signal_emit (panel, signals[SWITCH_PAGE], 0, n);
- gtk_widget_show (GTK_WIDGET (panel));
-}
-
-/**
- * midori_panel_append_page:
- * @panel: a #MidoriPanel
- * @viewable: a viewable widget
- *
- * Appends a new page to the panel. If @toolbar is specified it will
- * be packed above @viewable.
- *
- * Since 0.1.3 destroying the @viewable implicitly removes
- * the page including the menu and eventual toolbar.
- *
- * Since 0.2.1 a hidden @viewable will not be shown in the panel.
- *
- * Since 0.2.1 an action with an accelerator is created implicitly.
- *
- * In the case of an error, -1 is returned.
- *
- * Return value: the index of the new page, or -1
- **/
-gint
-midori_panel_append_page (MidoriPanel* panel,
- MidoriViewable* viewable)
-{
- GtkWidget* scrolled;
- #if !GTK_CHECK_VERSION (3, 0, 0)
- GObjectClass* gobject_class;
- #endif
- GtkWidget* widget;
- GtkWidget* toolbar;
- GtkToolItem* toolitem;
- guint n;
- gchar* action_name;
- GtkAction* action;
-
- g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
- g_return_val_if_fail (MIDORI_IS_VIEWABLE (viewable), -1);
-
- #if GTK_CHECK_VERSION (3, 2, 0)
- if (GTK_IS_ORIENTABLE (viewable))
- gtk_orientable_set_orientation (GTK_ORIENTABLE (viewable),
- GTK_ORIENTATION_VERTICAL);
- #endif
-
- if (GTK_IS_SCROLLED_WINDOW (viewable))
- scrolled = (GtkWidget*)viewable;
- else
- {
- scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
- GTK_POLICY_NEVER,
- GTK_POLICY_AUTOMATIC);
- gtk_widget_set_can_focus (scrolled, TRUE);
- gtk_widget_show (scrolled);
- #if GTK_CHECK_VERSION (3, 0, 0)
- if (GTK_IS_SCROLLABLE (viewable))
- #else
- gobject_class = G_OBJECT_GET_CLASS (viewable);
- if (GTK_WIDGET_CLASS (gobject_class)->set_scroll_adjustments_signal)
- #endif
- widget = (GtkWidget*)viewable;
- else
- {
- widget = gtk_viewport_new (NULL, NULL);
- gtk_widget_show (widget);
- gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (viewable));
- }
- gtk_container_add (GTK_CONTAINER (scrolled), widget);
- }
- gtk_container_add (GTK_CONTAINER (panel->notebook), scrolled);
-
- toolbar = midori_viewable_get_toolbar (viewable);
- gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
- gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
- gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
- gtk_widget_show (toolbar);
- gtk_container_add (GTK_CONTAINER (panel->toolbook), toolbar);
- g_signal_connect (viewable, "destroy",
- G_CALLBACK (midori_panel_widget_destroy_cb), toolbar);
-
- n = midori_panel_get_n_pages (panel) - 1;
- /* FIXME: Use something better than the stock ID */
- action_name = g_strconcat ("PanelPage",
- midori_viewable_get_stock_id (viewable), NULL);
- action = (GtkAction*)gtk_radio_action_new (action_name,
- midori_viewable_get_label (viewable),
- midori_viewable_get_label (viewable),
- midori_viewable_get_stock_id (viewable), n);
- g_object_set_data (G_OBJECT (action), "viewable", viewable);
- g_signal_connect (action, "activate",
- G_CALLBACK (midori_panel_action_activate_cb), panel);
- if (panel->action_group)
- {
- GtkWidget* toplevel = gtk_widget_get_toplevel (GTK_WIDGET (panel));
- GSList* groups = gtk_accel_groups_from_object (G_OBJECT (toplevel));
- gtk_action_set_accel_group (action, g_slist_nth_data (groups, 0));
- gtk_action_group_add_action_with_accel (panel->action_group,
- action, NULL);
- gtk_action_connect_accelerator (action);
- }
- if (n > 0)
- g_object_set (action, "group", g_object_get_data (
- G_OBJECT (midori_panel_get_nth_page (panel, 0)),
- "midori-panel-action"), NULL);
- g_object_set_data (G_OBJECT (viewable), "midori-panel-action", action);
- g_free (action_name);
-
- g_object_set_data (G_OBJECT (viewable), "parent", scrolled);
- toolitem = midori_panel_construct_tool_item (panel, viewable);
- g_signal_connect (viewable, "destroy",
- G_CALLBACK (midori_panel_viewable_destroy_cb), panel);
-
- if (!gtk_widget_get_visible (GTK_WIDGET (viewable)))
- {
- gtk_widget_hide (scrolled);
- gtk_widget_hide (GTK_WIDGET (toolitem));
- }
-
- return n;
-}
-
-/**
- * midori_panel_get_current_page:
- * @panel: a #MidoriPanel
- *
- * Retrieves the index of the currently selected page.
- *
- * If @panel has no children, -1 is returned.
- *
- * Return value: the index of the current page, or -1
- **/
-gint
-midori_panel_get_current_page (MidoriPanel* panel)
-{
- g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
-
- return gtk_notebook_get_current_page (GTK_NOTEBOOK (panel->notebook));
-}
-
-static GtkWidget*
-_midori_panel_child_for_scrolled (MidoriPanel* panel,
- GtkWidget* scrolled)
-{
- GtkWidget* child;
-
- /* This is a lazy hack, we should have a way of determining
- whether the scrolled is the actual child. */
- if (MIDORI_IS_VIEW (scrolled))
- return scrolled;
- child = gtk_bin_get_child (GTK_BIN (scrolled));
- if (GTK_IS_VIEWPORT (child))
- child = gtk_bin_get_child (GTK_BIN (child));
- return child;
-}
-
-/**
- * midori_panel_get_nth_page:
- * @panel: a #MidoriPanel
- *
- * Retrieves the child widget of the nth page.
- *
- * If @panel has no children, %NULL is returned.
- *
- * Return value: (transfer none): the child widget of the new page, or %NULL
- **/
-GtkWidget*
-midori_panel_get_nth_page (MidoriPanel* panel,
- guint page_num)
-{
- GtkWidget* scrolled;
-
- g_return_val_if_fail (MIDORI_IS_PANEL (panel), NULL);
-
- scrolled = gtk_notebook_get_nth_page (
- GTK_NOTEBOOK (panel->notebook), page_num);
- if (scrolled)
- return _midori_panel_child_for_scrolled (panel, scrolled);
- return NULL;
-}
-
-/**
- * midori_panel_get_n_pages:
- * @panel: a #MidoriPanel
- *
- * Retrieves the number of pages contained in the panel.
- *
- * Return value: the number of pages
- **/
-guint
-midori_panel_get_n_pages (MidoriPanel* panel)
-{
- g_return_val_if_fail (MIDORI_IS_PANEL (panel), 0);
-
- return gtk_notebook_get_n_pages (GTK_NOTEBOOK (panel->notebook));
-}
-
-static GtkWidget*
-_midori_panel_scrolled_for_child (MidoriPanel* panel,
- GtkWidget* child)
-{
- GtkWidget* scrolled;
-
- /* This is a lazy hack, we should have a way of determining
- whether the scrolled is the actual child. */
- if (MIDORI_IS_VIEW (child))
- return child;
- scrolled = gtk_widget_get_parent (GTK_WIDGET (child));
- if (GTK_IS_VIEWPORT (scrolled))
- scrolled = gtk_widget_get_parent (scrolled);
- return scrolled;
-}
-
-/**
- * midori_panel_page_num:
- * @panel: a #MidoriPanel
- *
- * Retrieves the index of the page associated to @widget.
- *
- * If @panel has no children, -1 is returned.
- *
- * Return value: the index of page associated to @widget, or -1
- **/
-gint
-midori_panel_page_num (MidoriPanel* panel,
- GtkWidget* child)
-{
- GtkWidget* scrolled;
-
- g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
- g_return_val_if_fail (GTK_IS_WIDGET (child), -1);
-
- scrolled = _midori_panel_scrolled_for_child (panel, child);
- return gtk_notebook_page_num (GTK_NOTEBOOK (panel->notebook), scrolled);
-}
-
-/**
- * midori_panel_set_current_page:
- * @panel: a #MidoriPanel
- * @n: index of the page to switch to, or -1 to mean the last page
- *
- * Switches to the page with the given index.
- *
- * The child must be visible, otherwise the underlying GtkNotebook will
- * silently ignore the attempt to switch the page.
- *
- * Since 0.1.8 the "page" property is notifying changes.
- *
- * Since 0.2.1 switching to hidden pages fails silently.
- **/
-void
-midori_panel_set_current_page (MidoriPanel* panel,
- gint n)
-{
- GtkWidget* viewable;
-
- g_return_if_fail (MIDORI_IS_PANEL (panel));
-
- if ((viewable = midori_panel_get_nth_page (panel, n)))
- {
- GtkWidget* toolbar;
- GList* items;
- const gchar* label;
-
- if (!gtk_widget_get_visible (viewable))
- return;
-
- gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->toolbook), n);
- toolbar = gtk_notebook_get_nth_page (GTK_NOTEBOOK (panel->toolbook), n);
- items = gtk_container_get_children (GTK_CONTAINER (toolbar));
- sokoke_widget_set_visible (panel->toolbook, items != NULL);
- g_list_free (items);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->notebook), n);
- label = midori_viewable_get_label (MIDORI_VIEWABLE (viewable));
- g_object_set (panel->toolbar_label, "label", label, NULL);
- g_object_notify (G_OBJECT (panel), "page");
- }
-}
-
-typedef struct
-{
- GtkAlignment parent_instance;
-
- gchar* label;
- gchar* stock_id;
- GtkWidget* toolbar;
-} MidoriDummyViewable;
-
-typedef struct
-{
- GtkAlignmentClass parent_class;
-} MidoriDummyViewableClass;
-
-GType midori_dummy_viewable_get_type (void) G_GNUC_CONST;
-#define MIDORI_TYPE_DUMMY_VIEWABLE (midori_dummy_viewable_get_type ())
-#define MIDORI_DUMMY_VIEWABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- MIDORI_TYPE_DUMMY_VIEWABLE, MidoriDummyViewable))
-#define MIDORI_IS_DUMMY_VIEWABLE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_DUMMY_VIEWABLE))
-
-static void
-midori_dummy_viewable_iface_init (MidoriViewableIface* iface);
-
-static void
-midori_dummy_viewable_finalize (GObject* object);
-
-G_DEFINE_TYPE_WITH_CODE (MidoriDummyViewable, midori_dummy_viewable,
- GTK_TYPE_ALIGNMENT,
- G_IMPLEMENT_INTERFACE (MIDORI_TYPE_VIEWABLE,
- midori_dummy_viewable_iface_init));
-
-static void
-midori_dummy_viewable_class_init (MidoriDummyViewableClass* class)
-{
- GObjectClass* gobject_class;
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = midori_dummy_viewable_finalize;
-}
-
-static const gchar*
-midori_dummy_viewable_get_label (MidoriViewable* viewable)
-{
- return MIDORI_DUMMY_VIEWABLE (viewable)->label;
-}
-
-static const gchar*
-midori_dummy_viewable_get_stock_id (MidoriViewable* viewable)
-{
- return MIDORI_DUMMY_VIEWABLE (viewable)->stock_id;
-}
-
-static GtkWidget*
-midori_dummy_viewable_get_toolbar (MidoriViewable* viewable)
-{
- return MIDORI_DUMMY_VIEWABLE (viewable)->toolbar;
-}
-
-static void
-midori_dummy_viewable_iface_init (MidoriViewableIface* iface)
-{
- iface->get_stock_id = midori_dummy_viewable_get_stock_id;
- iface->get_label = midori_dummy_viewable_get_label;
- iface->get_toolbar = midori_dummy_viewable_get_toolbar;
-}
-
-static void
-midori_dummy_viewable_init (MidoriDummyViewable* viewable)
-{
- viewable->stock_id = NULL;
- viewable->label = NULL;
- viewable->toolbar = NULL;
-}
-
-static void
-midori_dummy_viewable_finalize (GObject* object)
-{
- MidoriDummyViewable* viewable = MIDORI_DUMMY_VIEWABLE (object);
-
- katze_assign (viewable->stock_id, NULL);
- katze_assign (viewable->label, NULL);
-
- G_OBJECT_CLASS (midori_dummy_viewable_parent_class)->finalize (object);
-}
-
-/* static */ GtkWidget*
-midori_dummy_viewable_new (const gchar* stock_id,
- const gchar* label,
- GtkWidget* toolbar)
-{
- GtkWidget* viewable = g_object_new (MIDORI_TYPE_DUMMY_VIEWABLE, NULL);
-
- MIDORI_DUMMY_VIEWABLE (viewable)->stock_id = g_strdup (stock_id);
- MIDORI_DUMMY_VIEWABLE (viewable)->label = g_strdup (label);
- MIDORI_DUMMY_VIEWABLE (viewable)->toolbar = toolbar;
-
- return viewable;
-}
-
-/**
- * midori_panel_append_widget:
- * @panel: a #MidoriPanel
- * @widget: the child widget
- * @stock_id: a stock ID
- * @label: a string to use as the label, or %NULL
- * @toolbar: a toolbar widget, or %NULL
- *
- * Appends an arbitrary widget to the panel by wrapping it
- * in a #MidoriViewable created on the fly.
- *
- * Actually implementing #MidoriViewable instead of using
- * this convenience is recommended.
- *
- * Since 0.1.3 destroying the @widget implicitly removes
- * the page including the menu and eventual toolbar.
- *
- * In the case of an error, -1 is returned.
- *
- * Return value: the index of the new page, or -1
- **/
-gint
-midori_panel_append_widget (MidoriPanel* panel,
- GtkWidget* widget,
- const gchar* stock_id,
- const gchar* label,
- GtkWidget* toolbar)
-{
- GtkWidget* viewable;
-
- g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
- g_return_val_if_fail (GTK_IS_WIDGET (widget), -1);
-
- g_return_val_if_fail (stock_id != NULL, -1);
- g_return_val_if_fail (!toolbar || GTK_IS_WIDGET (toolbar), -1);
-
- viewable = midori_dummy_viewable_new (stock_id, label, toolbar);
- gtk_widget_show (viewable);
- gtk_container_add (GTK_CONTAINER (viewable), widget);
- g_signal_connect (widget, "destroy",
- G_CALLBACK (midori_panel_widget_destroy_cb), viewable);
- return midori_panel_append_page (panel, MIDORI_VIEWABLE (viewable));
-}
-
-/* Private function, used by MidoriBrowser */
-void
-midori_panel_set_toolbar_style (MidoriPanel* panel,
- GtkToolbarStyle style)
-{
- g_return_if_fail (MIDORI_IS_PANEL (panel));
-
- gtk_toolbar_set_style (GTK_TOOLBAR (panel->toolbar), style);
-}
-
diff --git a/midori/midori-panel.h b/midori/midori-panel.h
deleted file mode 100644
index c5cd2756..00000000
--- a/midori/midori-panel.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- 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 __MIDORI_PANEL_H__
-#define __MIDORI_PANEL_H__
-
-#include "midori-core.h"
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_PANEL \
- (midori_panel_get_type ())
-#define MIDORI_PANEL(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_PANEL, MidoriPanel))
-#define MIDORI_PANEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_PANEL, MidoriPanelClass))
-#define MIDORI_IS_PANEL(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_PANEL))
-#define MIDORI_IS_PANEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_PANEL))
-#define MIDORI_PANEL_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_PANEL, MidoriPanelClass))
-
-typedef struct _MidoriPanel MidoriPanel;
-typedef struct _MidoriPanelClass MidoriPanelClass;
-
-GType
-midori_panel_get_type (void) G_GNUC_CONST;
-
-GtkWidget*
-midori_panel_new (void);
-
-void
-midori_panel_set_right_aligned (MidoriPanel* panel,
- gboolean right_aligned);
-
-gint
-midori_panel_append_page (MidoriPanel* panel,
- MidoriViewable* viewable);
-
-gint
-midori_panel_get_current_page (MidoriPanel* panel);
-
-GtkWidget*
-midori_panel_get_nth_page (MidoriPanel* panel,
- guint page_num);
-
-guint
-midori_panel_get_n_pages (MidoriPanel* panel);
-
-gint
-midori_panel_page_num (MidoriPanel* panel,
- GtkWidget* child);
-
-void
-midori_panel_set_current_page (MidoriPanel* panel,
- gint n);
-
-gint
-midori_panel_append_widget (MidoriPanel* panel,
- GtkWidget* widget,
- const gchar* stock_id,
- const gchar* label,
- GtkWidget* toolbar);
-
-G_END_DECLS
-
-#endif /* __MIDORI_PANEL_H__ */
diff --git a/midori/midori-platform.h b/midori/midori-platform.h
deleted file mode 100644
index a535a51b..00000000
--- a/midori/midori-platform.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Copyright (C) 2010-2013 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 __MIDORI_PLATFORM_H__
-#define __MIDORI_PLATFORM_H__ 1
-
-#include "midori/midori-stock.h"
-#include "katze/gtk3-compat.h"
-#include "midori/sokoke.h"
-
-/* Common behavior modifiers */
-#define MIDORI_MOD_NEW_WINDOW(state) (state & GDK_SHIFT_MASK)
-#define MIDORI_MOD_NEW_TAB(state) (state & GDK_CONTROL_MASK)
-#define MIDORI_MOD_BACKGROUND(state) (state & GDK_SHIFT_MASK)
-#define MIDORI_MOD_SCROLL(state) (state & GDK_CONTROL_MASK)
-
-#ifdef GDK_WINDOWING_QUARTZ
- #define MIDORI_EVENT_CONTEXT_MENU(evt) \
- ((evt && evt->button == 3) \
- || (evt && evt->button == 1 && (evt->state & GDK_CONTROL_MASK)))
-#else
- #define MIDORI_EVENT_CONTEXT_MENU(evt) \
- (evt && evt->button == 3)
-#endif
-
-#define MIDORI_EVENT_NEW_TAB(evt) \
- (evt != NULL \
- && ((((GdkEventButton*)evt)->button == 1 \
- && MIDORI_MOD_NEW_TAB(((GdkEventButton*)evt)->state)) \
- || (((GdkEventButton*)evt)->button == 2)))
-
-#endif /* !__MIDORI_PLATFORM_H__ */
diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c
deleted file mode 100644
index 7e5d0c13..00000000
--- a/midori/midori-preferences.c
+++ /dev/null
@@ -1,637 +0,0 @@
-/*
- Copyright (C) 2007-2009 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.
-*/
-
-#include "midori-preferences.h"
-
-#include "midori-app.h"
-#include "midori-core.h"
-#include "midori-extension.h"
-#include "panels/midori-extensions.h"
-#include "midori-platform.h"
-
-#include <string.h>
-#include <glib/gi18n.h>
-#include <libsoup/soup.h>
-
- #define LIBSOUP_USE_UNSTABLE_REQUEST_API
- #include <libsoup/soup-cache.h>
-
-#include <config.h>
-
-struct _MidoriPreferences
-{
- KatzePreferences parent_instance;
-
- gpointer settings;
-};
-
-G_DEFINE_TYPE (MidoriPreferences, midori_preferences, KATZE_TYPE_PREFERENCES);
-
-enum
-{
- PROP_0,
-
- PROP_SETTINGS
-};
-
-static void
-midori_preferences_finalize (GObject* object);
-
-static void
-midori_preferences_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_preferences_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_preferences_class_init (MidoriPreferencesClass* class)
-{
- GObjectClass* gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = midori_preferences_finalize;
- gobject_class->set_property = midori_preferences_set_property;
- gobject_class->get_property = midori_preferences_get_property;
-
- /**
- * MidoriPreferences:settings:
- *
- * The settings to proxy properties from.
- */
- g_object_class_install_property (gobject_class,
- PROP_SETTINGS,
- g_param_spec_object (
- "settings",
- "Settings",
- "Settings instance to provide properties",
- MIDORI_TYPE_WEB_SETTINGS,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-}
-
-static void
-midori_preferences_init (MidoriPreferences* preferences)
-{
- preferences->settings = NULL;
-}
-
-static void
-midori_preferences_finalize (GObject* object)
-{
- G_OBJECT_CLASS (midori_preferences_parent_class)->finalize (object);
-}
-
-static void
-midori_preferences_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- MidoriPreferences* preferences = MIDORI_PREFERENCES (object);
-
- switch (prop_id)
- {
- case PROP_SETTINGS:
- midori_preferences_set_settings (preferences,
- g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_preferences_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- MidoriPreferences* preferences = MIDORI_PREFERENCES (object);
-
- switch (prop_id)
- {
- case PROP_SETTINGS:
- g_value_set_object (value, preferences->settings);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/**
- * midori_preferences_new:
- * @parent: the parent window
- * @settings: the settings
- *
- * Creates a new preferences dialog.
- *
- * Since 0.1.2 @parent may be %NULL.
- *
- * Return value: (transfer full): a new #MidoriPreferences
- **/
-GtkWidget*
-midori_preferences_new (GtkWindow* parent,
- MidoriWebSettings* settings)
-{
- MidoriPreferences* preferences;
-
- g_return_val_if_fail (!parent || GTK_IS_WINDOW (parent), NULL);
- g_return_val_if_fail (MIDORI_IS_WEB_SETTINGS (settings), NULL);
-
- preferences = g_object_new (MIDORI_TYPE_PREFERENCES,
- "transient-for", parent,
- "settings", settings,
- NULL);
-
- return GTK_WIDGET (preferences);
-}
-
-static void
-midori_preferences_homepage_current_clicked_cb (GtkWidget* button,
- MidoriWebSettings* settings)
-{
- GtkWidget* preferences = gtk_widget_get_toplevel (button);
- GtkWidget* browser = katze_object_get_object (preferences, "transient-for");
-
- if (GTK_IS_WINDOW (browser))
- {
- gchar* uri = katze_object_get_string (browser, "uri");
- if (uri && *uri)
- g_object_set (settings, "homepage", uri, NULL);
- else
- g_object_set (settings, "homepage", "about:blank", NULL);
- g_free (uri);
- }
-}
-
-static void
-midori_preferences_notify_proxy_type_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- GtkWidget* entry)
-{
- MidoriProxy proxy_type = katze_object_get_enum (settings, "proxy-type");
-
- gtk_widget_set_sensitive (entry, proxy_type == MIDORI_PROXY_HTTP);
-}
-
-#if HAVE_OSX
-static void
-midori_preferences_toolbutton_clicked_cb (GtkWidget* toolbutton,
- GtkWidget* page)
-{
- gpointer notebook = g_object_get_data (G_OBJECT (toolbutton), "notebook");
- guint n = gtk_notebook_page_num (notebook, page);
- gtk_notebook_set_current_page (notebook, n);
-}
-#endif
-
-#if 0
-static void
-midori_preferences_list_dicts_cb (const gchar* lang_tag,
- const gchar* provider_name,
- const gchar* provider_desc,
- const gchar* provider_file,
- GList** dicts)
-{
- *dicts = g_list_prepend (*dicts, (gchar*)lang_tag);
-}
-
-static GList*
-midori_preferences_get_spell_languages (void)
-{
- GList* dicts = NULL;
- gpointer broker = enchant_broker_init ();
- enchant_broker_list_dicts (broker, (GCallback)midori_preferences_list_dicts_cb, &dicts);
- enchant_broker_free (broker);
- return dicts;
-}
-#endif
-
-#ifdef G_OS_WIN32
-static void
-midori_preferences_theme_changed_cb (GtkWidget* button,
- gpointer user_data)
-{
- MidoriSettings* settings = user_data;
- midori_settings_set_theme_name (settings,
- gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (button)));
-}
-#endif
-
-/**
- * midori_preferences_set_settings:
- * @settings: the settings
- *
- * Assigns a settings instance to a preferences dialog.
- *
- * Note: This must not be called more than once.
- *
- * Since 0.1.2 this is equal to setting #MidoriPreferences:settings:.
- **/
-void
-midori_preferences_set_settings (MidoriPreferences* preferences,
- MidoriWebSettings* settings)
-{
- GtkWidget* header;
- GtkWindow* parent;
- const gchar* icon_name;
- KatzePreferences* _preferences;
- GtkWidget* label;
- GtkWidget* button;
- GtkWidget* entry;
-
- g_return_if_fail (MIDORI_IS_PREFERENCES (preferences));
- g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings));
-
- g_return_if_fail (!preferences->settings);
-
- preferences->settings = settings;
-
- g_object_get (preferences, "transient-for", &parent, NULL);
- icon_name = parent ? gtk_window_get_icon_name (parent) : NULL;
- if ((header = sokoke_xfce_header_new (icon_name,
- gtk_window_get_title (GTK_WINDOW (preferences)))))
- {
- GtkWidget* vbox = gtk_dialog_get_content_area (GTK_DIALOG (preferences));
- gtk_box_pack_start (GTK_BOX (vbox), header, FALSE, FALSE, 0);
- gtk_widget_show_all (header);
- }
- _preferences = KATZE_PREFERENCES (preferences);
-
- #define PAGE_NEW(__icon, __label) \
- katze_preferences_add_category (_preferences, __label, __icon)
- #define FRAME_NEW(__label) \
- katze_preferences_add_group (_preferences, __label)
- #define FILLED_ADD(__widget) \
- katze_preferences_add_widget (_preferences, __widget, "filled")
- #define INDENTED_ADD(__widget) \
- katze_preferences_add_widget (_preferences, __widget, "indented")
- #define SPANNED_ADD(__widget) \
- katze_preferences_add_widget (_preferences, __widget, "spanned")
- /* Page "General" */
- if (!midori_paths_is_readonly ())
- {
- PAGE_NEW (GTK_STOCK_HOME, _("Startup"));
- FRAME_NEW (NULL);
- label = gtk_label_new (_("When Midori starts:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- INDENTED_ADD (label);
- button = katze_property_proxy (settings, "load-on-startup", NULL);
- SPANNED_ADD (button);
- label = gtk_label_new (_("Homepage:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- INDENTED_ADD (label);
- entry = katze_property_proxy (settings, "homepage", "address");
- SPANNED_ADD (entry);
- if (parent && MIDORI_IS_BROWSER (parent))
- {
- #if 0
- button = gtk_button_new_with_mnemonic (_("Use _current page"));
- #else
- label = gtk_label_new (NULL);
- INDENTED_ADD (label);
- button = gtk_button_new_with_label (_("Use current page as homepage"));
- #endif
- g_signal_connect (button, "clicked",
- G_CALLBACK (midori_preferences_homepage_current_clicked_cb), settings);
- SPANNED_ADD (button);
- }
- }
-
- /* Page "Appearance" */
- PAGE_NEW (GTK_STOCK_SELECT_FONT, _("Fonts"));
- FRAME_NEW (NULL);
- label = gtk_label_new (_("Proportional Font Family"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- INDENTED_ADD (label);
- button = katze_property_proxy (settings, "default-font-family", "font");
- gtk_widget_set_tooltip_text (button, _("The default font family used to display text"));
- SPANNED_ADD (button);
- entry = katze_property_proxy (settings, "default-font-size", NULL);
- gtk_widget_set_tooltip_text (entry, _("The default font size used to display text"));
- SPANNED_ADD (entry);
- label = gtk_label_new (_("Fixed-width Font Family"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- INDENTED_ADD (label);
- button = katze_property_proxy (settings, "monospace-font-family", "font-monospace");
- gtk_widget_set_tooltip_text (button, _("The font family used to display fixed-width text"));
- SPANNED_ADD (button);
- entry = katze_property_proxy (settings, "default-monospace-font-size", NULL);
- gtk_widget_set_tooltip_text (entry, _("The font size used to display fixed-width text"));
- SPANNED_ADD (entry);
- label = gtk_label_new (_("Minimum Font Size"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- INDENTED_ADD (label);
- entry = katze_property_proxy (settings, "minimum-font-size", NULL);
- gtk_widget_set_tooltip_text (entry, _("The minimum font size used to display text"));
- SPANNED_ADD (entry);
- button = katze_property_proxy (settings, "enforce-font-family", NULL);
- INDENTED_ADD (button);
- label = gtk_label_new (_("Preferred Encoding"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- INDENTED_ADD (label);
- button = katze_property_proxy (settings, "preferred-encoding", "custom-default-charset");
- SPANNED_ADD (button);
-
- /* Page "Behavior" */
- PAGE_NEW (GTK_STOCK_SELECT_COLOR, _("Behavior"));
- FRAME_NEW (NULL);
- button = katze_property_proxy (settings, "auto-load-images", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Load images automatically"));
- INDENTED_ADD (button);
- button = katze_property_proxy (settings, "enable-spell-checking", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Enable Spell Checking"));
- SPANNED_ADD (button);
- /* Disable spell check option if there are no enchant modules */
- {
- gchar* enchant_path = midori_paths_get_lib_path ("enchant");
- if (enchant_path == NULL)
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
- gtk_widget_set_sensitive (button, FALSE);
- }
- else
- g_free (enchant_path);
- }
- button = katze_property_proxy (settings, "enable-javascript", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Enable scripts"));
- INDENTED_ADD (button);
- button = katze_property_proxy (settings, "enable-webgl", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Enable WebGL support"));
- #ifndef HAVE_WEBKIT2
- if (parent && MIDORI_IS_BROWSER (parent))
- {
- GtkWidget* tab = midori_browser_get_current_tab (MIDORI_BROWSER (parent));
- WebKitWebView* web_view = midori_tab_get_web_view (MIDORI_TAB (tab));
- WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
- JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
- gchar* supports_web_gl = sokoke_js_script_eval (js_context,
- "!!window.WebGLRenderingContext", NULL);
- if (g_strcmp0 (supports_web_gl, "true"))
- gtk_widget_hide (button);
- g_free (supports_web_gl);
- }
- #endif
- SPANNED_ADD (button);
- button = katze_property_proxy (settings, "zoom-text-and-images", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Zoom Text and Images"));
- INDENTED_ADD (button);
- button = katze_property_proxy (settings, "javascript-can-open-windows-automatically", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Allow scripts to open popups"));
- gtk_widget_set_tooltip_text (button, _("Whether scripts are allowed to open popup windows automatically"));
- SPANNED_ADD (button);
- label = gtk_label_new (_("Default Zoom Level"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- INDENTED_ADD (label);
- button = katze_property_proxy (settings, "zoom-level", NULL);
- gtk_widget_set_tooltip_text (button, _("Initial factor to enlarge newly opened tabs by"));
- SPANNED_ADD (button);
-
- FRAME_NEW (NULL);
- button = gtk_label_new (_("Preferred languages"));
- gtk_misc_set_alignment (GTK_MISC (button), 0.0, 0.5);
- INDENTED_ADD (button);
- entry = katze_property_proxy (settings, "preferred-languages", "languages");
- gtk_widget_set_tooltip_text (entry, _("A comma separated list of languages preferred for rendering multilingual webpages, for example \"de\", \"ru,nl\" or \"en-us;q=1.0, fr-fr;q=0.667\""));
- SPANNED_ADD (entry);
- label = gtk_label_new (_("Save downloaded files to:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- INDENTED_ADD (label);
- button = katze_property_proxy (settings, "download-folder", "folder");
- SPANNED_ADD (button);
-
- /* Page "Interface" */
- PAGE_NEW (GTK_STOCK_CONVERT, _("Browsing"));
- gboolean has_toolbar = parent && MIDORI_IS_BROWSER (parent) && GTK_IS_TOOLBAR (katze_object_get_object (parent, "toolbar"));
- #ifndef G_OS_WIN32
- if (has_toolbar)
- #endif
- FRAME_NEW (NULL);
- #ifdef G_OS_WIN32
- INDENTED_ADD (gtk_label_new (_("Theme:")));
- button = gtk_combo_box_text_new ();
- SPANNED_ADD (button);
- guint i = 0;
- /* On Windows the default theme may be a built-in specific to the
- running system. So we always add the default and skip it later.
- */
- const gchar* default_theme = midori_settings_get_default_theme_name (MIDORI_SETTINGS (settings));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (button), default_theme);
- gtk_combo_box_set_active (GTK_COMBO_BOX (button), i++);
-
- const gchar* current_theme = midori_settings_get_theme_name (MIDORI_SETTINGS (settings));
- gchar* theme_path = midori_paths_get_data_filename ("themes", FALSE);
- GDir* dir;
- if ((dir = g_dir_open (theme_path, 0, NULL)))
- {
- const gchar* name;
- while ((name = g_dir_read_name (dir)))
- {
- if (!g_strcmp0 (name, default_theme))
- continue;
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (button), name);
- if (!g_strcmp0 (name, current_theme))
- gtk_combo_box_set_active (GTK_COMBO_BOX (button), i);
- i++;
- }
- g_dir_close (dir);
- g_signal_connect (button, "changed",
- G_CALLBACK (midori_preferences_theme_changed_cb), settings);
- }
- g_free (theme_path);
- #endif
- if (has_toolbar)
- {
- INDENTED_ADD (gtk_label_new (_("Toolbar Style:")));
- button = katze_property_proxy (settings, "toolbar-style", NULL);
- SPANNED_ADD (button);
- }
- FRAME_NEW (NULL);
- label = gtk_label_new (_("Open new pages in:"));
- INDENTED_ADD (label);
- button = katze_property_proxy (settings, "open-new-pages-in", NULL);
- SPANNED_ADD (button);
- label = gtk_label_new (_("New tab behavior:"));
- INDENTED_ADD (label);
- button = katze_property_proxy (settings, "new-tab-type", "custom-tabhome");
- SPANNED_ADD (button);
- button = katze_property_proxy (settings, "close-buttons-on-tabs", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Close Buttons on Tabs"));
- INDENTED_ADD (button);
- button = katze_property_proxy (settings, "open-tabs-next-to-current", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Open Tabs next to Current"));
- gtk_widget_set_tooltip_text (button, _("Whether to open new tabs next to the current tab or after the last one"));
- INDENTED_ADD (button);
- button = katze_property_proxy (settings, "open-tabs-in-the-background", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Open tabs in the background"));
- SPANNED_ADD (button);
-
- /* Page "Network" */
- PAGE_NEW (GTK_STOCK_NETWORK, _("Network"));
- FRAME_NEW (NULL);
- label = gtk_label_new (_("Proxy server"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- INDENTED_ADD (label);
- button = katze_property_proxy (settings, "proxy-type", NULL);
- SPANNED_ADD (button);
- label = gtk_label_new (_("URI"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- INDENTED_ADD (label);
- entry = katze_property_proxy (settings, "http-proxy", "address");
- SPANNED_ADD (entry);
- g_signal_connect_object (settings, "notify::proxy-type",
- G_CALLBACK (midori_preferences_notify_proxy_type_cb), entry, 0);
- midori_preferences_notify_proxy_type_cb (settings, NULL, entry);
- label = gtk_label_new (_("Port"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- INDENTED_ADD (label);
- entry = katze_property_proxy (settings, "http-proxy-port", NULL);
- SPANNED_ADD (entry);
- g_signal_connect_object (settings, "notify::proxy-type",
- G_CALLBACK (midori_preferences_notify_proxy_type_cb), entry, 0);
- midori_preferences_notify_proxy_type_cb (settings, NULL, entry);
- INDENTED_ADD (gtk_event_box_new ());
- label = gtk_label_new (NULL);
- GString* proxy_types = g_string_new (NULL);
- g_string_append (proxy_types, "<span size=\"smaller\">");
- g_string_append (proxy_types, _("Supported proxy types:"));
- g_string_append_c (proxy_types, ' ');
- /* http is not implemented as a GIO extension */
- g_string_append (proxy_types, "http:// https://");
- GIOExtensionPoint* proxy_extension = g_io_extension_point_lookup ("gio-proxy");
- GList* proxies = g_io_extension_point_get_extensions (proxy_extension);
- for (; proxies; proxies = g_list_next (proxies))
- g_string_append_printf (proxy_types, " %s://", g_io_extension_get_name (proxies->data));
- g_string_append (proxy_types, "</span>");
- gtk_label_set_markup (GTK_LABEL (label), proxy_types->str);
- g_string_free (proxy_types, TRUE);
- SPANNED_ADD (label);
- g_signal_connect_object (settings, "notify::proxy-type",
- G_CALLBACK (midori_preferences_notify_proxy_type_cb), label, 0);
- midori_preferences_notify_proxy_type_cb (settings, NULL, label);
-#ifndef HAVE_WEBKIT2
- if (soup_session_get_feature (webkit_get_default_session (), SOUP_TYPE_CACHE))
- {
- label = gtk_label_new (_("Web Cache"));
- gtk_widget_set_tooltip_text (label, _("The maximum size of cached pages on disk"));
- INDENTED_ADD (label);
- button = katze_property_proxy (settings, "maximum-cache-size", NULL);
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (button), 0, G_MAXINT);
- gtk_widget_set_tooltip_text (button, _("The maximum size of cached pages on disk"));
- SPANNED_ADD (button);
- label = gtk_label_new (_("MB"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- SPANNED_ADD (label);
- }
-#endif
- /* i18n: This refers to an application, not the 'user agent' string */
- label = gtk_label_new (_("Identify as"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- INDENTED_ADD (label);
- button = katze_property_proxy (settings, "identify-as", "custom-user-agent");
- SPANNED_ADD (button);
-}
-
-void
-midori_preferences_add_privacy_category (KatzePreferences* preferences,
- MidoriWebSettings* settings)
-{
- GtkWidget* button;
- GtkWidget* label;
- gchar* markup;
-
- g_return_if_fail (KATZE_IS_PREFERENCES (preferences));
- g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings));
-
- katze_preferences_add_category (preferences, _("Privacy"), GTK_STOCK_INDEX);
- katze_preferences_add_group (preferences, NULL);
- button = gtk_label_new (_("Delete old Cookies after:"));
- gtk_misc_set_alignment (GTK_MISC (button), 0.0, 0.5);
- gtk_widget_set_tooltip_text (button, _("The maximum number of days to save cookies for"));
- katze_preferences_add_widget (preferences, button, "indented");
- button = katze_property_proxy (settings, "maximum-cookie-age", "days");
- gtk_widget_set_tooltip_text (button, _("The maximum number of days to save cookies for"));
- katze_preferences_add_widget (preferences, button, "spanned");
- button = katze_property_proxy (settings, "first-party-cookies-only", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Only accept Cookies from sites you visit"));
- gtk_widget_set_tooltip_text (button, _("Block cookies sent by third-party websites"));
- katze_preferences_add_widget (preferences, button, "filled");
-
- markup = g_strdup_printf ("<span size=\"smaller\">%s</span>",
- _("Cookies store login data, saved games, "
- "or user profiles for advertisement purposes."));
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label), markup);
- g_free (markup);
- katze_preferences_add_widget (preferences, label, "filled");
- button = katze_property_proxy (settings, "enable-offline-web-application-cache", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Enable offline web application cache"));
- katze_preferences_add_widget (preferences, button, "indented");
- button = katze_property_proxy (settings, "enable-html5-local-storage", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Enable HTML5 local storage support"));
- katze_preferences_add_widget (preferences, button, "spanned");
- button = katze_property_proxy (settings, "strip-referer", NULL);
- /* i18n: Reworded: Shorten details propagated when going to another page */
- gtk_button_set_label (GTK_BUTTON (button), _("Strip referrer details sent to websites"));
- /* i18n: Referer here is not a typo but a technical term */
- gtk_widget_set_tooltip_text (button, _("Whether the \"Referer\" header should be shortened to the hostname"));
- katze_preferences_add_widget (preferences, button, "indented");
- katze_preferences_add_widget (preferences, gtk_label_new (NULL), "indented");
- button = gtk_label_new (_("Delete pages from history after:"));
- gtk_misc_set_alignment (GTK_MISC (button), 0.0, 0.5);
- gtk_widget_set_tooltip_text (button, _("The maximum number of days to save the history for"));
- katze_preferences_add_widget (preferences, button, "indented");
- button = katze_property_proxy (settings, "maximum-history-age", "days");
- gtk_widget_set_tooltip_text (button, _("The maximum number of days to save the history for"));
- katze_preferences_add_widget (preferences, button, "spanned");
-}
-
-void
-midori_preferences_add_extension_category (KatzePreferences* preferences,
- MidoriApp* app)
-{
- KatzeArray* array;
- GtkWidget* scrolled;
- GtkWidget* addon;
- GList* children;
- GtkWidget* page;
-
- array = katze_object_get_object (app, "extensions");
-
- midori_extension_load_from_folder (app, NULL, FALSE);
- /* Reset frozen list: allow active extensions to be saved */
- g_object_set_data (G_OBJECT (app), "extensions", NULL);
-
- /* Hide if there are no extensions at all */
- if (!katze_array_get_nth_item (array, 0))
- {
- g_object_unref (array);
- return;
- }
- g_object_unref (array);
-
- scrolled = gtk_scrolled_window_new (NULL, NULL);
- /* For lack of a better way of keeping descriptions visible */
- g_object_set (scrolled, "visible", TRUE, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
- addon = g_object_new (MIDORI_TYPE_EXTENSIONS, "app", app, NULL);
- children = gtk_container_get_children (GTK_CONTAINER (addon));
- gtk_widget_reparent (g_list_nth_data (children, 0), scrolled);
- g_list_free (children);
- page = katze_preferences_add_category (preferences,
- _("Extensions"), STOCK_EXTENSION);
- gtk_box_pack_start (GTK_BOX (page), scrolled, TRUE, TRUE, 4);
-}
-
diff --git a/midori/midori-preferences.h b/midori/midori-preferences.h
deleted file mode 100644
index 601d5a5d..00000000
--- a/midori/midori-preferences.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- 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 __MIDORI_PREFERENCES_H__
-#define __MIDORI_PREFERENCES_H__
-
-#include "midori-app.h"
-#include "midori-websettings.h"
-
-#include <katze/katze.h>
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_PREFERENCES \
- (midori_preferences_get_type ())
-#define MIDORI_PREFERENCES(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_PREFERENCES, MidoriPreferences))
-#define MIDORI_PREFERENCES_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_PREFERENCES, MidoriPreferencesClass))
-#define MIDORI_IS_PREFERENCES(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_PREFERENCES))
-#define MIDORI_IS_PREFERENCES_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_PREFERENCES))
-#define MIDORI_PREFERENCES_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_PREFERENCES, MidoriPreferencesClass))
-
-typedef struct _MidoriPreferences MidoriPreferences;
-typedef struct _MidoriPreferencesClass MidoriPreferencesClass;
-
-struct _MidoriPreferencesClass
-{
- KatzePreferencesClass parent_class;
-};
-
-GType
-midori_preferences_get_type (void) G_GNUC_CONST;
-
-GtkWidget*
-midori_preferences_new (GtkWindow* parent,
- MidoriWebSettings* settings);
-
-void
-midori_preferences_set_settings (MidoriPreferences* preferences,
- MidoriWebSettings* settings);
-
-void
-midori_preferences_add_privacy_category (KatzePreferences* preferences,
- MidoriWebSettings* settings);
-
-void
-midori_preferences_add_extension_category (KatzePreferences* preferences,
- MidoriApp* app);
-
-G_END_DECLS
-
-#endif /* __MIDORI_PREFERENCES_H__ */
diff --git a/midori/midori-privatedata.c b/midori/midori-privatedata.c
deleted file mode 100644
index 302493ab..00000000
--- a/midori/midori-privatedata.c
+++ /dev/null
@@ -1,468 +0,0 @@
-/*
- Copyright (C) 2008-2013 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.
-*/
-
-#include "midori-privatedata.h"
-
-#include "marshal.h"
-#include "midori-platform.h"
-#include "midori-core.h"
-
-#include "config.h"
-#include <string.h>
-#include <glib/gstdio.h>
-#include <glib/gi18n.h>
-#include <gdk/gdkkeysyms.h>
-#include <sqlite3.h>
-
- #define LIBSOUP_USE_UNSTABLE_REQUEST_API
- #include <libsoup/soup-cache.h>
-
-static void
-midori_private_data_dialog_response_cb (GtkWidget* dialog,
- gint response_id,
- MidoriBrowser* browser)
-{
- if (response_id == GTK_RESPONSE_ACCEPT)
- {
- GtkToggleButton* button;
- gint clear_prefs = MIDORI_CLEAR_NONE;
- gint saved_prefs = MIDORI_CLEAR_NONE;
- GList* data_items = midori_private_data_register_item (NULL, NULL, NULL);
- GString* clear_data = g_string_new (NULL);
- MidoriWebSettings* settings = midori_browser_get_settings (browser);
- g_object_get (settings, "clear-private-data", &saved_prefs, NULL);
-
- button = g_object_get_data (G_OBJECT (dialog), "session");
- if (gtk_toggle_button_get_active (button))
- {
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs != NULL; tabs = g_list_next (tabs))
- midori_browser_close_tab (browser, tabs->data);
- g_list_free (tabs);
- clear_prefs |= MIDORI_CLEAR_SESSION;
- }
- button = g_object_get_data (G_OBJECT (dialog), "history");
- if (gtk_toggle_button_get_active (button))
- {
- KatzeArray* history = katze_object_get_object (browser, "history");
- KatzeArray* trash = katze_object_get_object (browser, "trash");
- katze_array_clear (history);
- katze_array_clear (trash);
- g_object_ref (history);
- g_object_ref (trash);
- clear_prefs |= MIDORI_CLEAR_HISTORY;
- clear_prefs |= MIDORI_CLEAR_TRASH; /* For backward-compatibility */
- }
- if (clear_prefs != saved_prefs)
- {
- clear_prefs |= (saved_prefs & MIDORI_CLEAR_ON_QUIT);
- g_object_set (settings, "clear-private-data", clear_prefs, NULL);
- }
- for (; data_items != NULL; data_items = g_list_next (data_items))
- {
- MidoriPrivateDataItem* privacy = data_items->data;
- button = g_object_get_data (G_OBJECT (dialog), privacy->name);
- g_return_if_fail (button != NULL && GTK_IS_TOGGLE_BUTTON (button));
- if (gtk_toggle_button_get_active (button))
- {
- privacy->clear ();
- g_string_append (clear_data, privacy->name);
- g_string_append_c (clear_data, ',');
- }
- }
- g_object_set (settings, "clear-data", clear_data->str, NULL);
- g_string_free (clear_data, TRUE);
- }
- if (response_id != GTK_RESPONSE_DELETE_EVENT)
- gtk_widget_destroy (dialog);
-}
-
-static void
-midori_private_data_clear_on_quit_toggled_cb (GtkToggleButton* button,
- MidoriWebSettings* settings)
-{
- gint clear_prefs = MIDORI_CLEAR_NONE;
- g_object_get (settings, "clear-private-data", &clear_prefs, NULL);
- clear_prefs ^= MIDORI_CLEAR_ON_QUIT;
- g_object_set (settings, "clear-private-data", clear_prefs, NULL);
-}
-
-/**
- * midori_private_data_dialog_is_empty:
- * @dialog: the dialog
- *
- * The dialog is "empty" when none of the relevant checkboxes are activated.
- *
- * This function returns true if the dialog is empty.
- **/
-static bool
-midori_private_data_dialog_is_empty (GtkDialog* dialog)
-{
- GtkToggleButton* button;
- gint count = 0; // Counts the total number of checked boxes
- GList* data_items = midori_private_data_register_item (NULL, NULL, NULL);
-
- // Count these first two special ones
- button = g_object_get_data (G_OBJECT (dialog), "session");
- if (gtk_toggle_button_get_active (button))
- count++;
- button = g_object_get_data (G_OBJECT (dialog), "history");
- if (gtk_toggle_button_get_active (button))
- count++;
-
- // Count each other one
- for (; data_items != NULL; data_items = g_list_next (data_items))
- {
- MidoriPrivateDataItem* privacy = data_items->data;
- button = g_object_get_data (G_OBJECT (dialog), privacy->name);
- g_return_val_if_fail (button != NULL && GTK_IS_TOGGLE_BUTTON (button), false);
- if (gtk_toggle_button_get_active (button))
- count++;
- }
-
- // No checked boxes means the dialog is empty
- if (count == 0)
- return true;
- return false;
-}
-
-/**
- * midori_private_data_clear_button_check_sensitive:
- * @dialog: the dialog to clear
- *
- * When called, sets the sensitivity of the clear private data button depending
- * on whether the dialog is empty (see: midori_private_data_dialog_is_empty())
- **/
-static void
-midori_private_data_clear_button_check_sensitive (GtkDialog* dialog)
-{
- GtkWidget* clear_button;
- clear_button = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_ACCEPT);
- if (midori_private_data_dialog_is_empty (dialog))
- gtk_widget_set_sensitive (clear_button, FALSE);
- else
- gtk_widget_set_sensitive (clear_button, TRUE);
-}
-
-static void
-midori_private_data_checkbox_toggled_cb (GtkToggleButton* button,
- GtkWidget* dialog)
-{
- // This is a separate function so I can invoke it on start too
- midori_private_data_clear_button_check_sensitive (GTK_DIALOG (dialog));
-}
-
-/**
- * midori_private_data_get_dialog:
- * @browser: the browser for which to create a dialog
- *
- * Shows a dialog for the user to configure private data settings
- * and clear some items.
- *
- * Return value: (transfer full): the dialog
- **/
-GtkWidget*
-midori_private_data_get_dialog (MidoriBrowser* browser)
-{
- GtkWidget* dialog;
- GtkWidget* content_area;
- GdkScreen* screen;
- GtkSizeGroup* sizegroup;
- GtkWidget* hbox;
- GtkWidget* alignment;
- GtkWidget* vbox;
- GtkWidget* icon;
- GtkWidget* label;
- GtkWidget* button;
- GList* data_items;
- MidoriWebSettings* settings = midori_browser_get_settings (browser);
- gchar* clear_data = katze_object_get_string (settings, "clear-data");
- gint clear_prefs = MIDORI_CLEAR_NONE;
- g_object_get (settings, "clear-private-data", &clear_prefs, NULL);
-
- /* i18n: Dialog: Clear Private Data, in the Tools menu */
- dialog = gtk_dialog_new_with_buttons (_("Clear Private Data"),
- GTK_WINDOW (browser),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- _("_Clear private data"), GTK_RESPONSE_ACCEPT, NULL);
- button = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), FALSE);
- g_signal_connect (dialog, "response",
- G_CALLBACK (midori_private_data_dialog_response_cb), browser);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
- katze_widget_add_class (button, "destructive-action");
- screen = gtk_widget_get_screen (GTK_WIDGET (browser));
- if (screen)
- gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_CLEAR);
- sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- hbox = gtk_hbox_new (FALSE, 4);
- icon = gtk_image_new_from_icon_name ("edit-clear", GTK_ICON_SIZE_DIALOG);
- gtk_size_group_add_widget (sizegroup, icon);
- gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
- label = gtk_label_new (_("Clear the following data:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 0);
- hbox = gtk_hbox_new (FALSE, 4);
- icon = gtk_image_new ();
- gtk_size_group_add_widget (sizegroup, icon);
- gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
- vbox = gtk_vbox_new (TRUE, 4);
- alignment = gtk_alignment_new (0, 0, 1, 1);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 6, 12, 0);
- button = gtk_check_button_new_with_mnemonic (_("Last open _tabs"));
- if ((clear_prefs & MIDORI_CLEAR_SESSION) == MIDORI_CLEAR_SESSION)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
- g_object_set_data (G_OBJECT (dialog), "session", button);
- gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
- g_signal_connect (button, "toggled",
- G_CALLBACK (midori_private_data_checkbox_toggled_cb), dialog);
- /* i18n: Browsing history, visited web pages, closed tabs */
- button = gtk_check_button_new_with_mnemonic (_("_History"));
- if ((clear_prefs & MIDORI_CLEAR_HISTORY) == MIDORI_CLEAR_HISTORY)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
- g_object_set_data (G_OBJECT (dialog), "history", button);
- gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
- g_signal_connect (button, "toggled",
- G_CALLBACK (midori_private_data_checkbox_toggled_cb), dialog);
-
- data_items = midori_private_data_register_item (NULL, NULL, NULL);
- for (; data_items != NULL; data_items = g_list_next (data_items))
- {
- MidoriPrivateDataItem* privacy = data_items->data;
- button = gtk_check_button_new_with_mnemonic (privacy->label);
- gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
- g_object_set_data (G_OBJECT (dialog), privacy->name, button);
- if (clear_data && strstr (clear_data, privacy->name))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
- g_signal_connect (button, "toggled",
- G_CALLBACK (midori_private_data_checkbox_toggled_cb), dialog);
- }
- midori_private_data_clear_button_check_sensitive (GTK_DIALOG (dialog));
- g_free (clear_data);
- gtk_container_add (GTK_CONTAINER (alignment), vbox);
- gtk_box_pack_start (GTK_BOX (hbox), alignment, TRUE, TRUE, 4);
- gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 8);
- button = gtk_check_button_new_with_mnemonic (_("Clear private data when _quitting Midori"));
- if ((clear_prefs & MIDORI_CLEAR_ON_QUIT) == MIDORI_CLEAR_ON_QUIT)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
- g_signal_connect (button, "toggled",
- G_CALLBACK (midori_private_data_clear_on_quit_toggled_cb), settings);
- alignment = gtk_alignment_new (0, 0, 1, 1);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 2, 0);
- gtk_container_add (GTK_CONTAINER (alignment), button);
- gtk_box_pack_start (GTK_BOX (content_area), alignment, FALSE, FALSE, 0);
- gtk_widget_show_all (content_area);
- return dialog;
-}
-
-static void
-midori_remove_config_file (gint clear_prefs,
- gint flag,
- const gchar* filename)
-{
- if ((clear_prefs & flag) == flag)
- {
- gchar* config_file = midori_paths_get_config_filename_for_writing (filename);
- g_unlink (config_file);
- g_free (config_file);
- }
-}
-
-static void
-midori_clear_web_cookies_cb (void)
-{
-#ifdef HAVE_WEBKIT2
- WebKitWebContext* context = webkit_web_context_get_default ();
- WebKitCookieManager* cookie_manager = webkit_web_context_get_cookie_manager (context);
- webkit_cookie_manager_delete_all_cookies (cookie_manager);
- /* FIXME: site data policy */
-#else
- SoupSession* session = webkit_get_default_session ();
- MidoriWebSettings* settings = g_object_get_data (G_OBJECT (session), "midori-settings");
- SoupSessionFeature* jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR);
- GSList* cookies = soup_cookie_jar_all_cookies (SOUP_COOKIE_JAR (jar));
-
- /* HTTP Cookies/ Web Cookies */
- for (; cookies != NULL; cookies = g_slist_next (cookies))
- {
- const gchar* domain = ((SoupCookie*)cookies->data)->domain;
- if (midori_web_settings_get_site_data_policy (settings, domain)
- == MIDORI_SITE_DATA_PRESERVE)
- continue;
- soup_cookie_jar_delete_cookie ((SoupCookieJar*)jar, cookies->data);
- }
- soup_cookies_free (cookies);
-#endif
-
- /* Local shared objects/ Flash cookies */
- if (midori_web_settings_has_plugin_support ())
- {
- gchar* cache;
- #ifdef GDK_WINDOWING_X11
- cache = g_build_filename (g_get_home_dir (), ".macromedia", "Flash_Player", NULL);
- midori_paths_remove_path (cache);
- g_free (cache);
- #elif defined(GDK_WINDOWING_WIN32)
- cache = g_build_filename (g_get_user_data_dir (), "Macromedia", "Flash Player", NULL);
- midori_paths_remove_path (cache);
- g_free (cache);
- #elif defined(GDK_WINDOWING_QUARTZ)
- cache = g_build_filename (g_get_home_dir (), "Library", "Preferences",
- "Macromedia", "Flash Player", NULL);
- midori_paths_remove_path (cache);
- g_free (cache);
- #endif
- }
-
-#ifdef HAVE_WEBKIT2
- /* TODO: clear databases and offline app caches */
-#else
- /* HTML5 databases */
- webkit_remove_all_web_databases ();
-
- /* HTML5 offline application caches */
- /* Changing the size implies clearing the cache */
- webkit_application_cache_set_maximum_size (
- webkit_application_cache_get_maximum_size () - 1);
-#endif
-}
-
-static void
-midori_clear_saved_logins_cb (void)
-{
- sqlite3* db;
- gchar* filename = midori_paths_get_config_filename_for_writing ("logins");
- g_unlink (filename);
- /* Form History database, written by the extension */
- gchar* path = midori_paths_get_extension_config_dir ("formhistory");
- katze_assign (filename, g_build_filename (path, "forms.db", NULL));
- g_free (path);
- if (sqlite3_open (filename, &db) == SQLITE_OK)
- {
- sqlite3_exec (db, "DELETE FROM forms", NULL, NULL, NULL);
- sqlite3_close (db);
- }
- g_free (filename);
-}
-
-static void
-midori_clear_web_cache_cb (void)
-{
-#ifdef HAVE_WEBKIT2
- webkit_web_context_clear_cache (webkit_web_context_get_default ());
-#else
- SoupSession* session = webkit_get_default_session ();
- SoupSessionFeature* feature = soup_session_get_feature (session, SOUP_TYPE_CACHE);
- gchar* cache = g_build_filename (midori_paths_get_cache_dir (), "web", NULL);
- soup_cache_clear (SOUP_CACHE (feature));
- soup_cache_flush (SOUP_CACHE (feature));
- midori_paths_remove_path (cache);
- g_free (cache);
-#endif
-}
-
-void
-midori_private_data_register_built_ins ()
-{
- /* i18n: Logins and passwords in websites and web forms */
- midori_private_data_register_item ("formhistory", _("Saved logins and _passwords"),
- G_CALLBACK (midori_clear_saved_logins_cb));
- midori_private_data_register_item ("web-cookies", _("Cookies and Website data"),
- G_CALLBACK (midori_clear_web_cookies_cb));
- /* TODO: Preserve page icons of search engines and merge privacy items */
- midori_private_data_register_item ("web-cache", _("Web Cache"),
- G_CALLBACK (midori_clear_web_cache_cb));
- midori_private_data_register_item ("page-icons", _("Website icons"),
- G_CALLBACK (midori_paths_clear_icons));
-}
-
-void
-midori_private_data_clear_all (MidoriBrowser* browser)
-{
- KatzeArray* history = katze_object_get_object (browser, "history");
- KatzeArray* trash = katze_object_get_object (browser, "trash");
- GList* data_items = midori_private_data_register_item (NULL, NULL, NULL);
- GList* tabs = midori_browser_get_tabs (browser);
- for (; tabs; tabs = g_list_next (tabs))
- midori_browser_close_tab (browser, tabs->data);
- g_list_free (tabs);
- if (history != NULL)
- katze_array_clear (history);
- if (trash != NULL)
- katze_array_clear (trash);
- g_object_unref (history);
- g_object_unref (trash);
-
- for (; data_items != NULL; data_items = g_list_next (data_items))
- ((MidoriPrivateDataItem*)(data_items->data))->clear ();
-}
-
-void
-midori_private_data_on_quit (MidoriWebSettings* settings)
-{
- gint clear_prefs = MIDORI_CLEAR_NONE;
- g_object_get (settings, "clear-private-data", &clear_prefs, NULL);
- if (clear_prefs & MIDORI_CLEAR_ON_QUIT)
- {
- GList* data_items = midori_private_data_register_item (NULL, NULL, NULL);
- gchar* clear_data = katze_object_get_string (settings, "clear-data");
-
- midori_remove_config_file (clear_prefs, MIDORI_CLEAR_SESSION, "session.xbel");
- midori_remove_config_file (clear_prefs, MIDORI_CLEAR_HISTORY, "history.db");
- midori_remove_config_file (clear_prefs, MIDORI_CLEAR_HISTORY, "tabtrash.xbel");
-
- for (; data_items != NULL; data_items = g_list_next (data_items))
- {
- MidoriPrivateDataItem* privacy = data_items->data;
- if (clear_data && strstr (clear_data, privacy->name))
- privacy->clear ();
- }
- g_free (clear_data);
- }
-}
-
-/**
- * midori_private_data_register_item:
- * @name: the name of the privacy item
- * @label: a user visible, localized label
- * @clear: (scope async): a callback clearing data
- *
- * Registers an item to clear data, either via the
- * Clear Private Data dialogue or when Midori quits.
- *
- * Return value: (element-type MidoriPrivateDataItem) (transfer none):
- * a #GList of all previously-registered items if all arguments are
- * given as %NULL, %NULL otherwise
- **/
-GList*
-midori_private_data_register_item (const gchar* name,
- const gchar* label,
- GCallback clear)
-{
- static GList* items = NULL;
- MidoriPrivateDataItem* item;
-
- if (name == NULL && label == NULL && clear == NULL)
- return items;
-
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (label != NULL, NULL);
- g_return_val_if_fail (clear != NULL, NULL);
-
- item = g_new (MidoriPrivateDataItem, 1);
- item->name = g_strdup (name);
- item->label = g_strdup (label);
- item->clear = clear;
- items = g_list_append (items, item);
- return NULL;
-}
diff --git a/midori/midori-privatedata.h b/midori/midori-privatedata.h
deleted file mode 100644
index 30f7dc76..00000000
--- a/midori/midori-privatedata.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Copyright (C) 2008-2013 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 __PRIVATE_DATA_H__
-#define __PRIVATE_DATA_H__ 1
-
-#include <midori/midori-browser.h>
-#include "katze/katze.h"
-
-GtkWidget*
-midori_private_data_get_dialog (MidoriBrowser* browser);
-
-void
-midori_private_data_register_built_ins ();
-
-void
-midori_private_data_clear_all (MidoriBrowser* browser);
-
-void
-midori_private_data_on_quit (MidoriWebSettings* settings);
-
-typedef struct
-{
- gchar* name;
- gchar* label;
- GCallback clear;
-} MidoriPrivateDataItem;
-
-GList*
-midori_private_data_register_item (const gchar* name,
- const gchar* label,
- GCallback clear);
-
-#endif /* !__SOKOKE_H__ */
-
diff --git a/midori/midori-searchaction.c b/midori/midori-searchaction.c
deleted file mode 100644
index 705be760..00000000
--- a/midori/midori-searchaction.c
+++ /dev/null
@@ -1,1721 +0,0 @@
-/*
- 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.
-*/
-
-#include "midori-searchaction.h"
-
-#include "marshal.h"
-#include "midori-platform.h"
-#include "midori-core.h"
-
-#include "config.h"
-#include <string.h>
-#include <glib/gi18n.h>
-#include <gdk/gdkkeysyms.h>
-
-struct _MidoriSearchAction
-{
- GtkAction parent_instance;
-
- KatzeArray* search_engines;
- KatzeItem* current_item;
- KatzeItem* default_item;
- gchar* text;
-
- GtkWidget* last_proxy;
-
- GtkWidget* dialog;
- GtkWidget* treeview;
- GtkWidget* edit_button;
- GtkWidget* remove_button;
- GtkWidget* default_button;
-};
-
-struct _MidoriSearchActionClass
-{
- GtkActionClass parent_class;
-};
-
-G_DEFINE_TYPE (MidoriSearchAction, midori_search_action, GTK_TYPE_ACTION)
-
-enum
-{
- PROP_0,
-
- PROP_SEARCH_ENGINES,
- PROP_CURRENT_ITEM,
- PROP_DEFAULT_ITEM,
- PROP_TEXT,
- PROP_DIALOG
-};
-
-enum
-{
- SUBMIT,
- FOCUS_OUT,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-midori_search_action_finalize (GObject* object);
-
-static void
-midori_search_action_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_search_action_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_search_action_activate (GtkAction* object);
-
-static GtkWidget*
-midori_search_action_create_tool_item (GtkAction* action);
-
-static void
-midori_search_action_connect_proxy (GtkAction* action,
- GtkWidget* proxy);
-
-static void
-midori_search_action_disconnect_proxy (GtkAction* action,
- GtkWidget* proxy);
-
-static void
-midori_search_action_class_init (MidoriSearchActionClass* class)
-{
- GObjectClass* gobject_class;
- GtkActionClass* action_class;
-
- signals[SUBMIT] = g_signal_new ("submit",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags) (G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- midori_cclosure_marshal_VOID__STRING_BOOLEAN,
- G_TYPE_NONE, 2,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN);
-
- signals[FOCUS_OUT] = g_signal_new ("focus-out",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags) (G_SIGNAL_RUN_LAST),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = midori_search_action_finalize;
- gobject_class->set_property = midori_search_action_set_property;
- gobject_class->get_property = midori_search_action_get_property;
-
- action_class = GTK_ACTION_CLASS (class);
- action_class->activate = midori_search_action_activate;
- action_class->create_tool_item = midori_search_action_create_tool_item;
- action_class->connect_proxy = midori_search_action_connect_proxy;
- action_class->disconnect_proxy = midori_search_action_disconnect_proxy;
-
- g_object_class_install_property (gobject_class,
- PROP_SEARCH_ENGINES,
- g_param_spec_object (
- "search-engines",
- "Search Engines",
- "The list of search engines",
- KATZE_TYPE_ARRAY,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_CURRENT_ITEM,
- g_param_spec_object (
- "current-item",
- "Current Item",
- "The currently selected item",
- KATZE_TYPE_ITEM,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriSearchAction:default-item:
- *
- * The default search engine.
- *
- * Since: 0.1.6
- */
- g_object_class_install_property (gobject_class,
- PROP_DEFAULT_ITEM,
- g_param_spec_object (
- "default-item",
- "Default Item",
- "The default search engine",
- KATZE_TYPE_ITEM,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_TEXT,
- g_param_spec_string (
- "text",
- "Text",
- "The current text typed in the entry",
- NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_DIALOG,
- g_param_spec_object (
- "dialog",
- "Dialog",
- "A dialog to manage search engines",
- GTK_TYPE_DIALOG,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-}
-
-static void
-midori_search_action_init (MidoriSearchAction* search_action)
-{
- search_action->search_engines = NULL;
- search_action->current_item = NULL;
- search_action->default_item = NULL;
- search_action->text = NULL;
-
- search_action->last_proxy = NULL;
-
- search_action->dialog = NULL;
- search_action->treeview = NULL;
- search_action->edit_button = NULL;
- search_action->remove_button = NULL;
- search_action->default_button = NULL;
-}
-
-static void
-midori_search_action_finalize (GObject* object)
-{
- MidoriSearchAction* search_action = MIDORI_SEARCH_ACTION (object);
-
- katze_assign (search_action->text, NULL);
-
- G_OBJECT_CLASS (midori_search_action_parent_class)->finalize (object);
-}
-
-static void
-midori_search_action_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- MidoriSearchAction* search_action = MIDORI_SEARCH_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_SEARCH_ENGINES:
- midori_search_action_set_search_engines (search_action,
- g_value_get_object (value));
- break;
- case PROP_CURRENT_ITEM:
- midori_search_action_set_current_item (search_action,
- g_value_get_object (value));
- break;
- case PROP_DEFAULT_ITEM:
- midori_search_action_set_default_item (search_action,
- g_value_get_object (value));
- break;
- case PROP_TEXT:
- midori_search_action_set_text (search_action,
- g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_search_action_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- MidoriSearchAction* search_action = MIDORI_SEARCH_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_SEARCH_ENGINES:
- g_value_set_object (value, search_action->search_engines);
- break;
- case PROP_CURRENT_ITEM:
- g_value_set_object (value, search_action->current_item);
- break;
- case PROP_DEFAULT_ITEM:
- g_value_set_object (value, search_action->default_item);
- break;
- case PROP_TEXT:
- g_value_set_string (value, search_action->text);
- break;
- case PROP_DIALOG:
- g_value_set_object (value,
- midori_search_action_get_dialog (search_action));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_search_action_activate (GtkAction* action)
-{
- GSList* proxies;
- GtkWidget* alignment;
- GtkWidget* entry;
-
- proxies = gtk_action_get_proxies (action);
- if (!proxies)
- return;
-
- do
- if (GTK_IS_TOOL_ITEM (proxies->data))
- {
- alignment = gtk_bin_get_child (GTK_BIN (proxies->data));
- entry = gtk_bin_get_child (GTK_BIN (alignment));
-
- /* Obviously only one widget can end up with the focus.
- Yet we can't predict which one that is, can we? */
- gtk_widget_grab_focus (entry);
- MIDORI_SEARCH_ACTION (action)->last_proxy = proxies->data;
- }
- while ((proxies = g_slist_next (proxies)));
-
- if (GTK_ACTION_CLASS (midori_search_action_parent_class)->activate)
- GTK_ACTION_CLASS (midori_search_action_parent_class)->activate (action);
-}
-
-static GtkWidget*
-midori_search_action_create_tool_item (GtkAction* action)
-{
- GtkWidget* toolitem;
- GtkWidget* entry;
- GtkWidget* alignment;
-
- toolitem = GTK_WIDGET (gtk_tool_item_new ());
- entry = sokoke_search_entry_new (NULL);
- gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY, TRUE);
- alignment = gtk_alignment_new (0, 0.5, 1, 0.1);
- gtk_container_add (GTK_CONTAINER (alignment), entry);
- gtk_widget_show (entry);
- gtk_container_add (GTK_CONTAINER (toolitem), alignment);
- gtk_widget_show (alignment);
-
- MIDORI_SEARCH_ACTION (action)->last_proxy = GTK_WIDGET (toolitem);
- return toolitem;
-}
-
-static void
-_midori_search_action_move_index (MidoriSearchAction* search_action,
- guint n)
-{
- gint i;
- KatzeItem* item;
-
- i = katze_array_get_item_index (search_action->search_engines,
- search_action->current_item);
- item = katze_array_get_nth_item (search_action->search_engines, i + n);
- if (item)
- midori_search_action_set_current_item (search_action, item);
-}
-
-static gboolean
-midori_search_action_key_press_event_cb (GtkWidget* entry,
- GdkEventKey* event,
- MidoriSearchAction* search_action)
-{
- const gchar* text;
-
- switch (event->keyval)
- {
- case GDK_KEY_ISO_Enter:
- case GDK_KEY_KP_Enter:
- case GDK_KEY_Return:
- text = gtk_entry_get_text (GTK_ENTRY (entry));
- g_signal_emit (search_action, signals[SUBMIT], 0, text,
- MIDORI_MOD_NEW_TAB (event->state));
- search_action->last_proxy = entry;
- return TRUE;
- case GDK_KEY_Up:
- if (MIDORI_MOD_SCROLL (event->state))
- _midori_search_action_move_index (search_action, - 1);
- return TRUE;
- case GDK_KEY_Down:
- if (MIDORI_MOD_SCROLL (event->state))
- _midori_search_action_move_index (search_action, + 1);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-midori_search_action_focus_out_event_cb (GtkWidget* widget,
- GdkEventKey* event,
- GtkAction* action)
-{
- g_signal_emit (action, signals[FOCUS_OUT], 0);
- return FALSE;
-}
-
-static void
-midori_search_action_engine_activate_cb (GtkWidget* menuitem,
- MidoriSearchAction* search_action)
-{
- KatzeItem* item;
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "engine");
- midori_search_action_set_current_item (search_action, item);
-}
-
-static void
-midori_search_action_manage_activate_cb (GtkWidget* menuitem,
- MidoriSearchAction* search_action)
-{
- GtkWidget* dialog;
-
- dialog = midori_search_action_get_dialog (search_action);
- if (gtk_widget_get_visible (dialog))
- gtk_window_present (GTK_WINDOW (dialog));
- else
- gtk_widget_show (dialog);
-}
-
-GtkMenu*
-midori_search_action_get_menu (GtkWidget* entry,
- MidoriSearchAction *search_action,
- void (*change_cb)(GtkWidget*, MidoriSearchAction*))
-{
- KatzeArray* search_engines;
- GtkWidget* menu;
- GtkWidget* menuitem;
- KatzeItem* item;
- GdkPixbuf* icon;
- GtkWidget* image;
-
- search_engines = search_action->search_engines;
- menu = gtk_menu_new ();
- if (!katze_array_is_empty (search_engines))
- {
- KATZE_ARRAY_FOREACH_ITEM (item, search_engines)
- {
- menuitem = gtk_image_menu_item_new_with_label (
- katze_item_get_name (item));
- image = gtk_image_new ();
- if ((icon = midori_paths_get_icon (katze_item_get_uri (item), NULL)))
- {
- gtk_image_set_from_pixbuf (GTK_IMAGE (image), icon);
- g_object_unref (icon);
- }
- else
- gtk_image_set_from_icon_name (GTK_IMAGE (image), STOCK_EDIT_FIND,
- GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
- gtk_image_menu_item_set_always_show_image (
- GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- g_object_set_data (G_OBJECT (menuitem), "engine", item);
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (change_cb), search_action);
- gtk_widget_show (menuitem);
- }
- }
- else
- {
- menuitem = gtk_image_menu_item_new_with_label (_("Empty"));
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- gtk_widget_show (menuitem);
- }
-
- menuitem = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- gtk_widget_show (menuitem);
- menuitem = gtk_image_menu_item_new_with_mnemonic (_("_Manage Search Engines"));
- image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (midori_search_action_manage_activate_cb), search_action);
- gtk_widget_show (menuitem);
- return GTK_MENU (menu);
-}
-
-static void
-midori_search_action_icon_released_cb (GtkWidget* entry,
- GtkEntryIconPosition icon_pos,
- gint button,
- GtkAction* action)
-{
- /* Only display the search engines when the engine icon, not clear button, is clicked */
- if (icon_pos != GTK_ENTRY_ICON_PRIMARY)
- return;
-
- GtkMenu* menu = midori_search_action_get_menu (entry,
- MIDORI_SEARCH_ACTION (action),
- midori_search_action_engine_activate_cb);
- katze_widget_popup (entry, menu, NULL, KATZE_MENU_POSITION_LEFT);
-}
-
-static gboolean
-midori_search_action_scroll_event_cb (GtkWidget* entry,
- GdkEventScroll* event,
- MidoriSearchAction* search_action)
-{
- if (event->direction == GDK_SCROLL_DOWN)
- _midori_search_action_move_index (search_action, + 1);
- else if (event->direction == GDK_SCROLL_UP)
- _midori_search_action_move_index (search_action, - 1);
- return FALSE;
-}
-
-static void
-midori_search_action_set_entry_icon (MidoriSearchAction* search_action,
- GtkWidget* entry)
-{
- GdkPixbuf* icon;
-
- if (search_action->current_item
- && (icon = midori_paths_get_icon (katze_item_get_uri (search_action->current_item), NULL)))
- {
- gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, icon);
- g_object_unref (icon);
- }
- else
- {
- GIcon* icon = g_themed_icon_new_with_default_fallbacks ("edit-find-option-symbolic");
- gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY, icon);
- }
- gtk_entry_set_placeholder_text (GTK_ENTRY (entry),
- search_action->current_item
- ? katze_item_get_name (search_action->current_item) : "");
-}
-
-static void
-midori_search_action_connect_proxy (GtkAction* action,
- GtkWidget* proxy)
-{
- GtkWidget* alignment;
- GtkWidget* entry;
-
- GTK_ACTION_CLASS (midori_search_action_parent_class)->connect_proxy (
- action, proxy);
-
- if (GTK_IS_TOOL_ITEM (proxy))
- {
- alignment = gtk_bin_get_child (GTK_BIN (proxy));
- entry = gtk_bin_get_child (GTK_BIN (alignment));
-
- midori_search_action_set_entry_icon (MIDORI_SEARCH_ACTION (action),
- entry);
- g_object_connect (entry,
- "signal::key-press-event",
- midori_search_action_key_press_event_cb, action,
- "signal::focus-out-event",
- midori_search_action_focus_out_event_cb, action,
- "signal::icon-release",
- midori_search_action_icon_released_cb, action,
- "signal::scroll-event",
- midori_search_action_scroll_event_cb, action,
- NULL);
- }
-
- MIDORI_SEARCH_ACTION (action)->last_proxy = proxy;
-}
-
-static void
-midori_search_action_disconnect_proxy (GtkAction* action,
- GtkWidget* proxy)
-{
- GSList* proxies;
-
- /* FIXME: This is wrong */
- g_signal_handlers_disconnect_by_func (proxy,
- G_CALLBACK (gtk_action_activate), action);
-
- GTK_ACTION_CLASS (midori_search_action_parent_class)->disconnect_proxy
- (action, proxy);
-
- if (MIDORI_SEARCH_ACTION (action)->last_proxy == proxy)
- {
- proxies = gtk_action_get_proxies (action);
- if (proxies)
- MIDORI_SEARCH_ACTION (action)->last_proxy = proxies->data;
- }
-}
-
-const gchar*
-midori_search_action_get_text (MidoriSearchAction* search_action)
-{
- g_return_val_if_fail (MIDORI_IS_SEARCH_ACTION (search_action), NULL);
-
- return search_action->text;
-}
-
-void
-midori_search_action_set_text (MidoriSearchAction* search_action,
- const gchar* text)
-{
- GSList* proxies;
- GtkWidget* alignment;
- GtkWidget* entry;
-
- g_return_if_fail (MIDORI_IS_SEARCH_ACTION (search_action));
-
- katze_assign (search_action->text, g_strdup (text));
- g_object_notify (G_OBJECT (search_action), "text");
-
- proxies = gtk_action_get_proxies (GTK_ACTION (search_action));
- if (!proxies)
- return;
-
- do
- if (GTK_IS_TOOL_ITEM (proxies->data))
- {
- alignment = gtk_bin_get_child (GTK_BIN (proxies->data));
- entry = gtk_bin_get_child (GTK_BIN (alignment));
-
- gtk_entry_set_text (GTK_ENTRY (entry), text ? text : "");
- search_action->last_proxy = proxies->data;
- }
- while ((proxies = g_slist_next (proxies)));
-}
-
-KatzeArray*
-midori_search_action_get_search_engines (MidoriSearchAction* search_action)
-{
- g_return_val_if_fail (MIDORI_IS_SEARCH_ACTION (search_action), NULL);
-
- return search_action->search_engines;
-}
-
-static void
-midori_search_action_engines_add_item_cb (KatzeArray* list,
- KatzeItem* item,
- MidoriSearchAction* search_action)
-{
- if (!search_action->current_item)
- midori_search_action_set_current_item (search_action, item);
-}
-
-static void
-midori_search_action_engines_remove_item_cb (KatzeArray* list,
- KatzeItem* item,
- MidoriSearchAction* search_action)
-{
- KatzeItem* found_item;
-
- if (search_action->current_item == item)
- {
- found_item = katze_array_get_nth_item (list, 0);
- midori_search_action_set_current_item (search_action, found_item);
- }
-}
-
-void
-midori_search_action_set_search_engines (MidoriSearchAction* search_action,
- KatzeArray* search_engines)
-{
- GSList* proxies;
-
- g_return_if_fail (MIDORI_IS_SEARCH_ACTION (search_action));
- g_return_if_fail (!search_engines ||
- katze_array_is_a (search_engines, KATZE_TYPE_ITEM));
-
- /* FIXME: Disconnect old search engines */
- /* FIXME: Disconnect and reconnect dialog signals */
-
- if (search_engines)
- g_object_ref (search_engines);
- katze_object_assign (search_action->search_engines, search_engines);
- if (!search_engines)
- return;
-
- g_object_connect (search_engines,
- "signal-after::add-item",
- midori_search_action_engines_add_item_cb, search_action,
- "signal-after::remove-item",
- midori_search_action_engines_remove_item_cb, search_action,
- NULL);
-
- g_object_notify (G_OBJECT (search_action), "search-engines");
-
- proxies = gtk_action_get_proxies (GTK_ACTION (search_action));
- if (!proxies)
- return;
-}
-
-KatzeItem*
-midori_search_action_get_current_item (MidoriSearchAction* search_action)
-{
- g_return_val_if_fail (MIDORI_IS_SEARCH_ACTION (search_action), NULL);
-
- return search_action->current_item;
-}
-
-void
-midori_search_action_set_current_item (MidoriSearchAction* search_action,
- KatzeItem* item)
-{
- GSList* proxies;
- GtkWidget* alignment;
- GtkWidget* entry;
-
- g_return_if_fail (MIDORI_IS_SEARCH_ACTION (search_action));
- g_return_if_fail (!item || KATZE_IS_ITEM (item));
-
- if (item)
- g_object_ref (item);
- katze_object_assign (search_action->current_item, item);
-
- g_object_notify (G_OBJECT (search_action), "current-item");
-
- proxies = gtk_action_get_proxies (GTK_ACTION (search_action));
- if (!proxies)
- return;
-
- do
- if (GTK_IS_TOOL_ITEM (proxies->data))
- {
- alignment = gtk_bin_get_child (GTK_BIN (proxies->data));
- entry = gtk_bin_get_child (GTK_BIN (alignment));
-
- midori_search_action_set_entry_icon (search_action, entry);
- }
- while ((proxies = g_slist_next (proxies)));
-}
-
-/**
- * midori_search_action_get_default_item:
- * @search_action: a #MidoriSearchAction
- *
- * Retrieves the default search engine.
- *
- * Since 0.1.6
- *
- * Return value: a #KatzeItem
- **/
-KatzeItem*
-midori_search_action_get_default_item (MidoriSearchAction* search_action)
-{
- g_return_val_if_fail (MIDORI_IS_SEARCH_ACTION (search_action), NULL);
-
- return search_action->default_item;
-}
-
-/**
- * midori_search_action_set_default_item:
- * @search_action: a #MidoriSearchAction
- * @item: a #KatzeItem
- *
- * Sets the default search engine.
- *
- * Since 0.1.6
- **/
-void
-midori_search_action_set_default_item (MidoriSearchAction* search_action,
- KatzeItem* item)
-{
- g_return_if_fail (MIDORI_IS_SEARCH_ACTION (search_action));
- g_return_if_fail (!item || KATZE_IS_ITEM (item));
-
- if (item)
- g_object_ref (item);
- katze_object_assign (search_action->default_item, item);
- g_object_notify (G_OBJECT (search_action), "default-item");
-}
-
-static void
-midori_search_action_dialog_render_tick_cb (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- KatzeItem* item;
- MidoriSearchAction* search_action;
- gint width;
-
- gtk_tree_model_get (model, iter, 0, &item, -1);
-
- search_action = g_object_get_data (G_OBJECT (treeview), "search-action");
- gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (treeview),
- GTK_ICON_SIZE_MENU, &width, NULL);
- g_object_set (renderer, "stock-id",
- search_action->default_item == item ? GTK_STOCK_YES : NULL,
- "width", width + 4, NULL);
- g_object_unref (item);
-}
-
-static void
-midori_search_action_dialog_render_icon_cb (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- KatzeItem* item;
- GdkPixbuf* icon;
-
- gtk_tree_model_get (model, iter, 0, &item, -1);
-
- if ((icon = midori_paths_get_icon (katze_item_get_uri (item), NULL)))
- {
- g_object_set (renderer, "pixbuf", icon, "yalign", 0.25, NULL);
- g_object_unref (icon);
- }
- else
- g_object_set (renderer, "icon-name", STOCK_EDIT_FIND, "yalign", 0.25, NULL);
- g_object_unref (item);
-}
-
-static void
-midori_search_action_dialog_render_text (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- KatzeItem* item;
- const gchar* name;
- const gchar* text;
- gchar* markup;
-
- gtk_tree_model_get (model, iter, 0, &item, -1);
- name = katze_item_get_name (item);
- text = katze_item_get_text (item);
- markup = g_markup_printf_escaped ("<b>%s</b>\n%s", name, text ? text : "");
- g_object_set (renderer, "markup", markup, NULL);
- g_free (markup);
- g_object_unref (item);
-}
-
-static void
-midori_search_action_dialog_render_token (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- KatzeItem* item;
- const gchar* token;
- gchar* markup;
-
- gtk_tree_model_get (model, iter, 0, &item, -1);
- token = katze_item_get_token (item);
- markup = g_markup_printf_escaped ("<b>%s</b>", token ? token : "");
- g_object_set (renderer, "markup", markup, "yalign", 0.0, NULL);
- g_free (markup);
- g_object_unref (item);
-}
-
-static void
-midori_search_action_editor_name_changed_cb (GtkWidget* entry,
- GtkWidget* dialog)
-{
- const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GTK_RESPONSE_ACCEPT, text && *text);
-}
-
-/* generates a search token for a uri by disemvoweling its hostname
-this token is just used as a suggestion in the UI, so if no sane token
-can be found the empty string is returned */
-gchar*
-midori_search_action_token_for_uri (const gchar* uri)
-{
- guint len, i;
- gchar** parts;
- gchar* hostname = NULL, *path = NULL;
-
- /* find the most meaningful component of the qualified hostname */
- path = midori_uri_parse_hostname (uri, NULL);
-
- /* if we can't find a hostname, return an empty string */
- if(!path)
- return g_strdup("");
-
- parts = g_strsplit (path, ".", -1);
- g_free (path);
-
- len = g_strv_length (parts);
- if (len > 2)
- {
- /* work backward from TLD to subdomains */
- for (i = len; i > 0; i--)
- {
- if (parts[i] && *parts[i])
- {
- /* skip short components */
- if (strlen (parts[i]) > 3)
- {
- hostname = g_strdup (parts[i]);
- break;
- }
- }
- }
- }
- else if(parts[0])
- {
- hostname = g_strdup (parts[0]);
- }
- /* no hostname at all */
- if(!hostname)
- hostname = g_strdup ("");
-
- g_strfreev (parts);
-
- /* disemvowel it */
- if (strlen (hostname) > 4)
- {
- GString* str = g_string_new (NULL);
- int j, count = 0;
-
- for (j = 0; count < 4; j++)
- {
- if (hostname[j] == 'a'
- || hostname[j] == 'e'
- || hostname[j] == 'i'
- || hostname[j] == 'o'
- || hostname[j] == 'u')
- continue;
- else
- {
- g_string_append_c (str, hostname[j]);
- count++;
- }
- }
- return g_string_free (str, FALSE);
- }
- return g_strdup (hostname);
-}
-
-KatzeItem*
-midori_search_action_get_engine_for_form (WebKitWebView* web_view,
- PangoEllipsizeMode ellipsize)
-{
-#ifndef HAVE_WEBKIT2
- WebKitWebFrame* focused_frame;
- WebKitDOMDocument* doc;
- WebKitDOMHTMLFormElement* active_form;
- WebKitDOMHTMLCollection* form_nodes;
- WebKitDOMElement* active_element;
- gchar* token_element;
- const gchar* title;
- GString* uri_str;
- gulong form_len;
- const gchar* action;
- guint i;
- KatzeItem* item;
- gchar** parts;
-
- focused_frame = webkit_web_view_get_focused_frame (web_view);
- if (focused_frame == NULL)
- return NULL;
- #if WEBKIT_CHECK_VERSION (1, 9, 5)
- doc = webkit_web_frame_get_dom_document (focused_frame);
- #else
- if (focused_frame != webkit_web_view_get_main_frame (web_view))
- return NULL;
- doc = webkit_web_view_get_dom_document (web_view);
- #endif
-
- active_element = webkit_dom_html_document_get_active_element ((WebKitDOMHTMLDocument*)doc);
- if (!WEBKIT_DOM_IS_HTML_INPUT_ELEMENT (active_element))
- return NULL;
-
- active_form = webkit_dom_html_input_element_get_form ((WebKitDOMHTMLInputElement*)active_element);
- if (!active_form)
- return NULL;
-
- token_element = webkit_dom_element_get_attribute (active_element, "name");
-
- form_nodes = webkit_dom_html_form_element_get_elements (active_form);
- form_len = webkit_dom_html_form_element_get_length (active_form);
-
- /* action NULL or "": relative path */
- if ((action = webkit_dom_html_form_element_get_action (active_form)) && *action)
- uri_str = g_string_new (action);
- else
- {
- gchar* hostname = midori_uri_parse_hostname (webkit_web_view_get_uri (web_view), NULL);
- uri_str = g_string_new ("http://");
- g_string_append (uri_str, hostname);
- g_free (hostname);
- }
- g_string_append_c (uri_str, '?');
-
- for (i = 0; i < form_len; i++)
- {
- WebKitDOMNode* form_node = webkit_dom_html_collection_item (form_nodes, i);
- WebKitDOMElement* form_element = (WebKitDOMElement*) form_node;
- gchar* name = webkit_dom_element_get_attribute (form_element, "name");
-
- if (name && *name)
- {
- if (!g_strcmp0 (token_element, name))
- g_string_append_printf (uri_str, "%s=%s&", name, "\%s");
- else
- {
- gchar* value;
- if (!g_strcmp0 (webkit_dom_element_get_tag_name (form_element), "SELECT"))
- {
- WebKitDOMHTMLSelectElement* select_element = (WebKitDOMHTMLSelectElement*) form_element;
- gulong pos = webkit_dom_html_select_element_get_selected_index (select_element);
- WebKitDOMNode* selected_node = webkit_dom_html_select_element_item (select_element, pos);
- WebKitDOMElement* selected_element = (WebKitDOMElement*) selected_node;
-
- value = webkit_dom_element_get_attribute (selected_element, "value");
- }
- else
- value = webkit_dom_element_get_attribute (form_element, "value");
-
- g_string_append_printf (uri_str, "%s=%s&", name, value);
- g_free (value);
- }
- g_free (name);
- }
- }
-
- if (!(title = webkit_web_view_get_title (web_view)))
- title = webkit_web_view_get_uri (web_view);
-
- item = katze_item_new ();
- item->uri = g_string_free (uri_str, FALSE);
- item->token = midori_search_action_token_for_uri (webkit_web_view_get_uri (web_view));
-
- if (strstr (title, " - "))
- parts = g_strsplit (title, " - ", 2);
- else if (strstr (title, ": "))
- parts = g_strsplit (title, ": ", 2);
- else
- parts = NULL;
- if (parts != NULL)
- {
- /* See midori_view_set_title: title can be first or last */
- if (ellipsize == PANGO_ELLIPSIZE_END)
- {
- katze_item_set_name (item, parts[0]);
- katze_item_set_text (item, parts[1]);
- }
- else
- {
- katze_item_set_name (item, parts[1]);
- katze_item_set_text (item, parts[2]);
- }
- g_strfreev (parts);
- }
- else
- katze_item_set_name (item, title);
-
- g_free (token_element);
- return item;
- #else
- return NULL;
- #endif
-}
-
-void
-midori_search_action_get_editor (MidoriSearchAction* search_action,
- KatzeItem* item,
- gboolean new_engine)
-{
- GtkWidget* toplevel;
- GtkWidget* dialog;
- GtkWidget* content_area;
- GtkSizeGroup* sizegroup;
- GtkWidget* hbox;
- GtkWidget* label;
- GtkTreeModel* liststore;
- GtkTreeIter iter;
- GtkTreeSelection* selection;
- GtkWidget* entry_name;
- GtkWidget* entry_description;
- GtkWidget* entry_uri;
- GtkWidget* entry_token;
-
- toplevel = search_action->treeview ? gtk_widget_get_toplevel (search_action->treeview) : NULL;
- dialog = gtk_dialog_new_with_buttons (
- new_engine ? _("Add search engine") : _("Edit search engine"),
- toplevel ? GTK_WINDOW (toplevel) : NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- new_engine ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_window_set_icon_name (GTK_WINDOW (dialog),
- new_engine ? GTK_STOCK_ADD : GTK_STOCK_REMOVE);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_container_set_border_width (GTK_CONTAINER (content_area), 5);
- sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
- if (new_engine)
- {
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GTK_RESPONSE_ACCEPT, FALSE);
- }
- else
- {
- selection = gtk_tree_view_get_selection (
- GTK_TREE_VIEW (search_action->treeview));
- gtk_tree_selection_get_selected (selection, &liststore, &iter);
- gtk_tree_model_get (liststore, &iter, 0, &item, -1);
- }
-
- hbox = gtk_hbox_new (FALSE, 8);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
- label = gtk_label_new_with_mnemonic (_("_Name:"));
- gtk_size_group_add_widget (sizegroup, label);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- entry_name = gtk_entry_new ();
- g_signal_connect (entry_name, "changed",
- G_CALLBACK (midori_search_action_editor_name_changed_cb), dialog);
- gtk_entry_set_activates_default (GTK_ENTRY (entry_name), TRUE);
- gtk_entry_set_text (GTK_ENTRY (entry_name),
- katze_str_non_null (katze_item_get_name (item)));
- gtk_box_pack_start (GTK_BOX (hbox), entry_name, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, TRUE, 0);
- gtk_widget_show_all (hbox);
-
- hbox = gtk_hbox_new (FALSE, 8);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
- label = gtk_label_new_with_mnemonic (_("_Description:"));
- gtk_size_group_add_widget (sizegroup, label);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- entry_description = gtk_entry_new ();
- gtk_entry_set_activates_default (GTK_ENTRY (entry_description), TRUE);
- gtk_entry_set_text (GTK_ENTRY (entry_description)
- , katze_str_non_null (katze_item_get_text (item)));
- gtk_box_pack_start (GTK_BOX (hbox), entry_description, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, TRUE, 0);
- gtk_widget_show_all (hbox);
-
- hbox = gtk_hbox_new (FALSE, 8);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
- label = gtk_label_new_with_mnemonic (_("_Address:"));
- gtk_size_group_add_widget (sizegroup, label);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- entry_uri = katze_uri_entry_new (
- gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT));
- g_object_set_data (G_OBJECT (entry_uri), "allow_%s", (void*)1);
- gtk_entry_set_activates_default (GTK_ENTRY (entry_uri), TRUE);
- gtk_entry_set_text (GTK_ENTRY (entry_uri),
- katze_str_non_null (katze_item_get_uri (item)));
- gtk_box_pack_start (GTK_BOX (hbox), entry_uri, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, TRUE, 0);
- gtk_widget_show_all (hbox);
-
- hbox = gtk_hbox_new (FALSE, 8);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
- label = gtk_label_new_with_mnemonic (_("_Token:"));
- gtk_size_group_add_widget (sizegroup, label);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- entry_token = gtk_entry_new ();
- gtk_entry_set_activates_default (GTK_ENTRY (entry_token), TRUE);
- gtk_entry_set_text (GTK_ENTRY (entry_token)
- , katze_str_non_null (katze_item_get_token (item)));
- gtk_box_pack_start (GTK_BOX (hbox), entry_token, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, TRUE, 0);
- gtk_widget_show_all (hbox);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
- {
- g_object_set (item,
- "name", gtk_entry_get_text (GTK_ENTRY (entry_name)),
- "text", gtk_entry_get_text (GTK_ENTRY (entry_description)),
- "uri", gtk_entry_get_text (GTK_ENTRY (entry_uri)),
- "token", gtk_entry_get_text (GTK_ENTRY (entry_token)),
- NULL);
-
- if (new_engine)
- katze_array_add_item (search_action->search_engines, item);
- /* If it isn't a new search engine but the old default one,
- we need to update the default search engine after editing it. */
- else if (item == midori_search_action_get_default_item (search_action))
- midori_search_action_set_default_item (search_action, item);
- g_object_unref (item);
- }
- gtk_widget_destroy (dialog);
-}
-
-static void
-midori_search_action_activate_edit_cb (GtkTreeView *treeview,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- MidoriSearchAction* search_action)
-{
- GtkTreeSelection* selection;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- if (gtk_tree_selection_get_selected (selection, NULL, NULL))
- midori_search_action_get_editor (search_action, NULL, FALSE);
-}
-
-
-static void
-midori_search_action_dialog_add_cb (GtkWidget* widget,
- MidoriSearchAction* search_action)
-{
- midori_search_action_get_editor (search_action, katze_item_new (), TRUE);
-}
-
-static void
-midori_search_action_dialog_edit_cb (GtkWidget* widget,
- MidoriSearchAction* search_action)
-{
- GtkWidget* treeview;
- GtkTreeSelection* selection;
-
- treeview = search_action->treeview;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- if (gtk_tree_selection_get_selected (selection, NULL, NULL))
- midori_search_action_get_editor (search_action, NULL, FALSE);
-}
-
-static void
-midori_search_action_dialog_remove_cb (GtkWidget* widget,
- MidoriSearchAction* search_action)
-{
- KatzeArray* search_engines;
- GtkWidget* treeview;
- GtkTreeSelection* selection;
- GtkTreeModel* liststore;
- GtkTreeIter iter;
- KatzeItem* item;
-
- search_engines = search_action->search_engines;
- treeview = search_action->treeview;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- if (gtk_tree_selection_get_selected (selection, &liststore, &iter))
- {
- gtk_tree_model_get (liststore, &iter, 0, &item, -1);
- katze_array_remove_item (search_engines, item);
- g_object_unref (item);
- /* FIXME: we want to allow undo of some kind */
- }
-}
-
-static void
-midori_search_action_dialog_move_up_cb (GtkWidget* widget,
- MidoriSearchAction* search_action)
-{
- KatzeArray* search_engines;
- GtkWidget* treeview;
- GtkTreeSelection* selection;
- GtkTreeModel* liststore;
- GtkTreeIter iter, prev;
- GtkTreePath* path;
- KatzeItem* item;
- gint i;
-
- search_engines = search_action->search_engines;
- treeview = search_action->treeview;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
-
- if (gtk_tree_selection_get_selected (selection, &liststore, &iter))
- {
- path = gtk_tree_model_get_path (liststore, &iter);
- if(gtk_tree_path_prev(path))
- {
- gtk_tree_model_get (liststore, &iter, 0, &item, -1);
- gtk_tree_model_get_iter (liststore, &prev, path);
- gtk_list_store_swap (GTK_LIST_STORE(liststore), &iter, &prev);
-
- i = katze_array_get_item_index (search_engines, item);
- katze_array_move_item (search_engines, item, i - 1);
- g_object_unref (item);
- /* If the index of the current item has changed it needs to be reset */
- g_object_notify (G_OBJECT (search_action), "current-item");
- }
- gtk_tree_path_free (path);
- }
-}
-
-static void
-midori_search_action_dialog_move_down_cb (GtkWidget* widget,
- MidoriSearchAction* search_action)
-{
- KatzeArray* search_engines;
- GtkWidget* treeview;
- GtkTreeSelection* selection;
- GtkTreeModel* liststore;
- GtkTreeIter iter, next;
- KatzeItem* item;
- gint i;
-
- search_engines = search_action->search_engines;
- treeview = search_action->treeview;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- if (gtk_tree_selection_get_selected (selection, &liststore, &iter))
- {
- next = iter;
- if (gtk_tree_model_iter_next (liststore, &next))
- {
- gtk_tree_model_get (liststore, &iter, 0, &item, -1);
- gtk_list_store_swap (GTK_LIST_STORE(liststore), &iter, &next);
-
- i = katze_array_get_item_index (search_engines, item);
- katze_array_move_item (search_engines, item, i + 1);
- g_object_unref (item);
- /* If the index of the current item has changed it needs to be reset */
- g_object_notify (G_OBJECT (search_action), "current-item");
- }
- }
-}
-
-static void
-midori_search_action_dialog_default_cb (GtkWidget* widget,
- MidoriSearchAction* search_action)
-{
- GtkWidget* treeview;
- GtkTreeSelection* selection;
- GtkTreeModel* liststore;
- GtkTreeIter iter;
- KatzeItem* item;
-
- treeview = search_action->treeview;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- if (gtk_tree_selection_get_selected (selection, &liststore, &iter))
- {
- gtk_tree_model_get (liststore, &iter, 0, &item, -1);
- midori_search_action_set_default_item (search_action, item);
- g_object_unref (item);
- gtk_widget_queue_draw (treeview);
- }
-}
-
-static void
-midori_search_action_treeview_selection_cb (GtkTreeSelection* selection,
- MidoriSearchAction* search_action)
-{
- gboolean selected;
-
- selected = gtk_tree_selection_get_selected (selection, NULL, NULL);
-
- gtk_widget_set_sensitive (search_action->edit_button, selected);
- gtk_widget_set_sensitive (search_action->remove_button, selected);
- gtk_widget_set_sensitive (search_action->default_button, selected);
-}
-
-static void
-midori_search_action_dialog_engines_add_item_cb (KatzeArray* list,
- KatzeItem* item,
- GtkAction* action)
-{
- MidoriSearchAction* search_action;
- GtkTreeModel* liststore;
- GtkTreeIter iter;
-
- search_action = MIDORI_SEARCH_ACTION (action);
- liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (search_action->treeview));
- gtk_list_store_append (GTK_LIST_STORE (liststore), &iter);
- gtk_list_store_set (GTK_LIST_STORE (liststore), &iter, 0, item, -1);
-}
-
-static void
-midori_search_action_dialog_engines_remove_item_cb (KatzeArray* list,
- KatzeItem* item,
- GtkAction* action)
-{
- MidoriSearchAction* search_action;
- GtkTreeModel* liststore;
- GtkTreeIter iter;
- gboolean valid;
- KatzeItem* found_item;
-
- search_action = MIDORI_SEARCH_ACTION (action);
- liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (search_action->treeview));
- valid = gtk_tree_model_get_iter_first (liststore, &iter);
- while (valid)
- {
- gtk_tree_model_get (liststore, &iter, 0, &found_item, -1);
- if (found_item == item)
- {
- gtk_list_store_remove (GTK_LIST_STORE (liststore), &iter);
- valid = FALSE;
- }
- else
- valid = gtk_tree_model_iter_next (liststore, &iter);
- g_object_unref (found_item);
- }
-}
-
-static void
-midori_search_action_treeview_destroy_cb (GtkWidget* treeview,
- MidoriSearchAction* search_action)
-{
- if (search_action->search_engines)
- {
- g_signal_handlers_disconnect_by_func (
- search_action->search_engines,
- midori_search_action_dialog_engines_add_item_cb, search_action);
- g_signal_handlers_disconnect_by_func (
- search_action->search_engines,
- midori_search_action_dialog_engines_remove_item_cb, search_action);
- }
-}
-
-/**
- * midori_search_action_get_dialog:
- * @search_action: a #MidoriSearchAction
- *
- * Obtains a dialog that provides an interface for managing
- * the list of search engines.
- *
- * The dialog is created once and this function will return
- * the very same dialog until it is destroyed, in which case
- * a new dialog is created.
- *
- * Return value: (transfer none): a #GtkDialog
- **/
-GtkWidget*
-midori_search_action_get_dialog (MidoriSearchAction* search_action)
-{
- const gchar* dialog_title;
- GtkWidget* toplevel;
- GtkWidget* dialog;
- GtkWidget* content_area;
- gint width, height;
- GtkWidget* xfce_heading;
- GtkWidget* hbox;
- GtkTreeViewColumn* column;
- GtkCellRenderer* renderer_text;
- GtkCellRenderer* renderer_pixbuf;
- GtkListStore* liststore;
- GtkWidget* treeview;
- GtkWidget* scrolled;
- guint i;
- KatzeItem* item;
- GtkWidget* vbox;
- GtkWidget* button;
- GtkWidget* image;
-
- g_return_val_if_fail (MIDORI_IS_SEARCH_ACTION (search_action), NULL);
-
- /* If there is a dialog, use that. We want only one. */
- if (search_action->dialog)
- return search_action->dialog;
-
- dialog_title = _("Manage Search Engines");
- toplevel = search_action->last_proxy ?
- gtk_widget_get_toplevel (search_action->last_proxy) : NULL;
- dialog = gtk_dialog_new_with_buttons (dialog_title,
- toplevel ? GTK_WINDOW (toplevel) : NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
- #if !HAVE_OSX
- GTK_STOCK_HELP, GTK_RESPONSE_HELP,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
- #endif
- NULL);
- katze_widget_add_class (gtk_dialog_get_widget_for_response (
- GTK_DIALOG (dialog), GTK_RESPONSE_HELP), "help_button");
- g_signal_connect (dialog, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &search_action->dialog);
- gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PROPERTIES);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- /* TODO: Implement some kind of help function */
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GTK_RESPONSE_HELP, FALSE);
- sokoke_widget_get_text_size (dialog, "M", &width, &height);
- gtk_window_set_default_size (GTK_WINDOW (dialog), width * 52, -1);
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), dialog);
- /* TODO: Do we want tooltips for explainations or can we omit that?
- We need mnemonics */
- if ((xfce_heading = sokoke_xfce_header_new (
- gtk_window_get_icon_name (GTK_WINDOW (dialog)), dialog_title)))
- gtk_box_pack_start (GTK_BOX (content_area), xfce_heading, FALSE, FALSE, 0);
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 12);
- liststore = gtk_list_store_new (1, KATZE_TYPE_ITEM);
- treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (liststore));
- search_action->treeview = treeview;
- g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)),
- "changed", G_CALLBACK (midori_search_action_treeview_selection_cb),
- search_action);
- g_signal_connect (treeview, "row-activated",
- G_CALLBACK (midori_search_action_activate_edit_cb), search_action);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
- g_object_set_data (G_OBJECT (treeview), "search-action", search_action);
- column = gtk_tree_view_column_new ();
- renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_pixbuf,
- (GtkTreeCellDataFunc)midori_search_action_dialog_render_tick_cb,
- treeview, NULL);
- renderer_text = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer_text, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_text,
- (GtkTreeCellDataFunc)midori_search_action_dialog_render_token,
- treeview, NULL);
- renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_pixbuf,
- (GtkTreeCellDataFunc)midori_search_action_dialog_render_icon_cb,
- treeview, NULL);
- renderer_text = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer_text, TRUE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_text,
- (GtkTreeCellDataFunc)midori_search_action_dialog_render_text,
- treeview, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
- scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_container_add (GTK_CONTAINER (scrolled), treeview);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
- GTK_SHADOW_IN);
- gtk_box_pack_start (GTK_BOX (hbox), scrolled, TRUE, TRUE, 5);
- i = 0;
- if (search_action->search_engines)
- KATZE_ARRAY_FOREACH_ITEM (item, search_action->search_engines)
- gtk_list_store_insert_with_values (GTK_LIST_STORE (liststore),
- NULL, i++, 0, item, -1);
- g_object_unref (liststore);
- g_signal_connect (treeview, "destroy",
- G_CALLBACK (midori_search_action_treeview_destroy_cb), search_action);
- vbox = gtk_vbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 4);
- button = gtk_button_new_from_stock (GTK_STOCK_ADD);
- g_signal_connect (button, "clicked",
- G_CALLBACK (midori_search_action_dialog_add_cb), search_action);
- gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
- button = gtk_button_new_from_stock (GTK_STOCK_EDIT);
- search_action->edit_button = button;
- g_signal_connect (button, "clicked",
- G_CALLBACK (midori_search_action_dialog_edit_cb), search_action);
- gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
- if (!i)
- gtk_widget_set_sensitive (button, FALSE);
- button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
- search_action->remove_button = button;
- g_signal_connect (button, "clicked",
- G_CALLBACK (midori_search_action_dialog_remove_cb), search_action);
- gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
- if (!i)
- gtk_widget_set_sensitive (button, FALSE);
- button = gtk_label_new (""); /* This is an invisible separator */
- gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 8);
- button = gtk_button_new_with_mnemonic (_("Use as _default"));
- image = gtk_image_new_from_stock (GTK_STOCK_YES, GTK_ICON_SIZE_BUTTON);
- gtk_button_set_image (GTK_BUTTON (button), image);
- search_action->default_button = button;
- g_signal_connect (button, "clicked",
- G_CALLBACK (midori_search_action_dialog_default_cb), search_action);
- gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
- if (!i)
- gtk_widget_set_sensitive (button, FALSE);
- button = gtk_label_new (""); /* This is an invisible separator */
- gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 12);
- button = gtk_button_new_from_stock (GTK_STOCK_GO_DOWN);
- g_signal_connect (button, "clicked",
- G_CALLBACK (midori_search_action_dialog_move_down_cb), search_action);
- gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
- button = gtk_button_new_from_stock (GTK_STOCK_GO_UP);
- g_signal_connect (button, "clicked",
- G_CALLBACK (midori_search_action_dialog_move_up_cb), search_action);
- gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
-
- #if HAVE_OSX
- GtkWidget* icon;
- hbox = gtk_hbox_new (FALSE, 0);
- button = gtk_button_new ();
- icon = gtk_image_new_from_stock (GTK_STOCK_HELP, GTK_ICON_SIZE_BUTTON);
- gtk_button_set_image (GTK_BUTTON (button), icon);
- /* TODO: Implement some kind of help function */
- gtk_widget_set_sensitive (button, FALSE);
- /* g_signal_connect (button, "clicked",
- G_CALLBACK (midori_search_action_dialog_help_clicked_cb), dialog); */
- gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 4);
- gtk_box_pack_end (GTK_BOX (content_area), hbox, FALSE, FALSE, 0);
- #endif
- gtk_widget_show_all (content_area);
-
- if (search_action->search_engines)
- g_object_connect (search_action->search_engines,
- "signal-after::add-item",
- midori_search_action_dialog_engines_add_item_cb, search_action,
- "signal-after::remove-item",
- midori_search_action_dialog_engines_remove_item_cb, search_action,
- NULL);
-
- search_action->dialog = dialog;
- return dialog;
-}
-
-KatzeArray*
-midori_search_engines_new_from_file (const gchar* filename,
- GError** error)
-{
- KatzeArray* search_engines;
- GKeyFile* key_file;
- gchar** engines;
- guint i, j, n_properties;
- KatzeItem* item;
- GParamSpec** pspecs;
- const gchar* property;
- gchar* value;
-
- search_engines = katze_array_new (KATZE_TYPE_ITEM);
- key_file = g_key_file_new ();
- g_key_file_load_from_file (key_file, filename,
- G_KEY_FILE_KEEP_COMMENTS, error);
- engines = g_key_file_get_groups (key_file, NULL);
- pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (search_engines),
- &n_properties);
- for (i = 0; engines[i] != NULL; i++)
- {
- item = katze_item_new ();
- for (j = 0; j < n_properties; j++)
- {
- if (!G_IS_PARAM_SPEC_STRING (pspecs[j]))
- continue;
- property = g_param_spec_get_name (pspecs[j]);
- value = g_key_file_get_string (key_file, engines[i], property, NULL);
- g_object_set (item, property, value, NULL);
- g_free (value);
- }
- katze_array_add_item (search_engines, item);
- }
- g_free (pspecs);
- g_strfreev (engines);
- g_key_file_free (key_file);
- return search_engines;
-}
-
-KatzeArray*
-midori_search_engines_new_from_folder (GString* error_messages)
-{
- gchar* config_file = midori_paths_get_config_filename_for_reading ("search");
- GError* error = NULL;
- KatzeArray* search_engines = midori_search_engines_new_from_file (config_file, &error);
- /* We ignore for instance empty files */
- if (error && (error->code == G_KEY_FILE_ERROR_PARSE
- || error->code == G_FILE_ERROR_NOENT))
- {
- g_error_free (error);
- error = NULL;
- }
- if (!error && katze_array_is_empty (search_engines))
- {
- katze_assign (config_file,
- midori_paths_get_preset_filename (NULL, "search"));
- katze_object_assign (search_engines,
- midori_search_engines_new_from_file (config_file, NULL));
- }
- else if (error)
- {
- if (error->code != G_FILE_ERROR_NOENT && error_messages)
- g_string_append_printf (error_messages,
- _("The search engines couldn't be loaded. %s\n"),
- error->message);
- g_error_free (error);
- }
- g_free (config_file);
- return search_engines;
-}
-
-gboolean
-midori_search_engines_save_to_file (KatzeArray* search_engines,
- const gchar* filename,
- GError** error)
-{
- GKeyFile* key_file;
- guint j, n_properties;
- KatzeItem* item;
- const gchar* name;
- GParamSpec** pspecs;
- const gchar* property;
- gchar* value;
- gboolean saved;
-
- key_file = g_key_file_new ();
- pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (search_engines),
- &n_properties);
- KATZE_ARRAY_FOREACH_ITEM (item, search_engines)
- {
- name = katze_item_get_name (item);
- for (j = 0; j < n_properties; j++)
- {
- if (!G_IS_PARAM_SPEC_STRING (pspecs[j]))
- continue;
- property = g_param_spec_get_name (pspecs[j]);
- g_object_get (item, property, &value, NULL);
- if (value)
- g_key_file_set_string (key_file, name, property, value);
- g_free (value);
- }
- }
- g_free (pspecs);
- saved = sokoke_key_file_save_to_file (key_file, filename, error);
- g_key_file_free (key_file);
-
- return saved;
-}
-
-static void
-midori_search_engines_modify_cb (KatzeArray* array,
- gpointer item,
- KatzeArray* search_engines)
-{
- gchar* config_file = g_object_get_data (G_OBJECT (search_engines), "search-engines-filename");
- GError* error = NULL;
- if (!midori_search_engines_save_to_file (search_engines, config_file, &error))
- {
- g_warning (_("The search engines couldn't be saved. %s"),
- error->message);
- g_error_free (error);
- }
-}
-
-static void
-midori_search_engines_move_item_cb (KatzeArray* array,
- gpointer item,
- gint position,
- KatzeArray* search_engines)
-{
- midori_search_engines_modify_cb (array, item, search_engines);
-}
-
-void
-midori_search_engines_set_filename (KatzeArray* search_engines,
- const gchar* filename)
-{
- g_object_set_data_full (G_OBJECT (search_engines), "search-engines-filename",
- g_strdup (filename), (GDestroyNotify)g_free);
- g_signal_connect_after (search_engines, "add-item",
- G_CALLBACK (midori_search_engines_modify_cb), search_engines);
- g_signal_connect_after (search_engines, "remove-item",
- G_CALLBACK (midori_search_engines_modify_cb), search_engines);
- if (!katze_array_is_empty (search_engines))
- {
- KatzeItem* item;
- KATZE_ARRAY_FOREACH_ITEM (item, search_engines)
- g_signal_connect_after (item, "notify",
- G_CALLBACK (midori_search_engines_modify_cb), search_engines);
- g_signal_connect_after (search_engines, "move-item",
- G_CALLBACK (midori_search_engines_move_item_cb), search_engines);
- }
-}
-
diff --git a/midori/midori-searchaction.h b/midori/midori-searchaction.h
deleted file mode 100644
index 56ab9cb4..00000000
--- a/midori/midori-searchaction.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- 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 __MIDORI_SEARCH_ACTION_H__
-#define __MIDORI_SEARCH_ACTION_H__
-
-#include <katze/katze.h>
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_SEARCH_ACTION \
- (midori_search_action_get_type ())
-#define MIDORI_SEARCH_ACTION(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_SEARCH_ACTION, MidoriSearchAction))
-#define MIDORI_SEARCH_ACTION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_SEARCH_ACTION, MidoriSearchActionClass))
-#define MIDORI_IS_SEARCH_ACTION(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_SEARCH_ACTION))
-#define MIDORI_IS_SEARCH_ACTION_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_SEARCH_ACTION))
-#define MIDORI_SEARCH_ACTION_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_SEARCH_ACTION, MidoriSearchActionClass))
-
-typedef struct _MidoriSearchAction MidoriSearchAction;
-typedef struct _MidoriSearchActionClass MidoriSearchActionClass;
-
-GType
-midori_search_action_get_type (void) G_GNUC_CONST;
-
-const gchar*
-midori_search_action_get_text (MidoriSearchAction* action);
-
-void
-midori_search_action_set_text (MidoriSearchAction* search_action,
- const gchar* text);
-
-KatzeArray*
-midori_search_action_get_search_engines (MidoriSearchAction* search_action);
-
-void
-midori_search_action_set_search_engines (MidoriSearchAction* search_action,
- KatzeArray* search_engines);
-
-KatzeItem*
-midori_search_action_get_current_item (MidoriSearchAction* search_action);
-
-void
-midori_search_action_set_current_item (MidoriSearchAction* search_action,
- KatzeItem* item);
-
-KatzeItem*
-midori_search_action_get_default_item (MidoriSearchAction* search_action);
-
-void
-midori_search_action_set_default_item (MidoriSearchAction* search_action,
- KatzeItem* item);
-
-gchar*
-midori_search_action_token_for_uri (const gchar* uri);
-
-GtkWidget*
-midori_search_action_get_dialog (MidoriSearchAction* search_action);
-
-void
-midori_search_action_get_editor (MidoriSearchAction* search_action,
- KatzeItem* item,
- gboolean new_engine);
-
-KatzeItem*
-midori_search_action_get_engine_for_form (WebKitWebView* web_view,
- PangoEllipsizeMode ellipsize);
-
-KatzeArray*
-midori_search_engines_new_from_file (const gchar* filename,
- GError** error);
-
-
-KatzeArray*
-midori_search_engines_new_from_folder (GString* error_messages);
-
-gboolean
-midori_search_engines_save_to_file (KatzeArray* search_engines,
- const gchar* filename,
- GError** error);
-
-void
-midori_search_engines_set_filename (KatzeArray* search_engines,
- const gchar* filename);
-
-G_END_DECLS
-
-#endif /* __MIDORI_SEARCH_ACTION_H__ */
diff --git a/midori/midori-searchcompletion.vala b/midori/midori-searchcompletion.vala
deleted file mode 100644
index 1dc95e27..00000000
--- a/midori/midori-searchcompletion.vala
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- Copyright (C) 2012-2013 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.
-*/
-namespace Katze {
- extern static unowned List<GLib.Object> array_peek_items (GLib.Object array);
-}
-
-namespace Midori {
- public class SearchCompletion : Completion {
- GLib.Object search_engines;
-
- public SearchCompletion () {
- GLib.Object (description: _("Search with…"));
- }
-
- public override void prepare (GLib.Object app) {
- app.get ("search-engines", out search_engines);
- }
-
- public override bool can_complete (string text) {
- return search_engines != null;
- }
-
- public override bool can_action (string action) {
- return action == "complete:more/search";
- }
-
- public override async List<Suggestion>? complete (string text, string? action, Cancellable cancellable) {
- return_val_if_fail (search_engines != null, null);
-
- unowned List<GLib.Object> items = Katze.array_peek_items (search_engines);
- var suggestions = new List<Suggestion> ();
- uint n = 0;
- foreach (var item in items) {
- string uri, title, desc;
- item.get ("uri", out uri);
- item.get ("name", out title);
- item.get ("text", out desc);
- string search_uri = URI.for_search (uri, text);
- string search_title = _("Search with %s").printf (title);
- Icon? icon = yield Midori.URI.get_icon_fallback (uri, null, cancellable);
- string search_desc = search_title + "\n" + desc ?? uri;
- /* FIXME: Theming? Win32? */
- string background = "gray";
- var suggestion = new Suggestion (search_uri, search_desc, false, background, icon);
- suggestions.append (suggestion);
-
- n++;
- if (n == 3 && action == null) {
- suggestion = new Suggestion ("complete:more/search", _("Search with…"), false, background);
- suggestion.action = true;
- suggestion.priority = this.position;
- suggestions.append (suggestion);
- break;
- }
-
- uint src = Idle.add (complete.callback);
- yield;
- Source.remove (src);
- }
-
- if (cancellable.is_cancelled ())
- return null;
-
- return suggestions;
- }
- }
-}
diff --git a/midori/midori-session.c b/midori/midori-session.c
deleted file mode 100644
index f7dc788b..00000000
--- a/midori/midori-session.c
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- Copyright (C) 2008-2013 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.
-*/
-
-#include "midori/midori-session.h"
-
-#include <midori/midori-core.h>
-#include "midori-array.h"
-#include "midori-extension.h"
-#include "sokoke.h"
-
-#include <glib/gi18n-lib.h>
-#include <libsoup/soup-cookie-jar-sqlite.h>
-#include <libsoup/soup-gnome-features.h>
-
- #define LIBSOUP_USE_UNSTABLE_REQUEST_API
- #include <libsoup/soup-cache.h>
-
-#ifndef HAVE_WEBKIT2
-static void
-midori_soup_session_set_proxy_uri (SoupSession* session,
- const gchar* uri)
-{
- SoupURI* proxy_uri;
-
- /* soup_uri_new expects a non-NULL string with a protocol */
- gchar* scheme = uri ? g_uri_parse_scheme (uri): NULL;
- if (scheme)
- {
- proxy_uri = soup_uri_new (uri);
- g_free (scheme);
- }
- else if (uri && *uri)
- {
- gchar* fixed_uri = g_strconcat ("http://", uri, NULL);
- proxy_uri = soup_uri_new (fixed_uri);
- g_free (fixed_uri);
- }
- else
- proxy_uri = NULL;
- g_object_set (session, "proxy-uri", proxy_uri, NULL);
- if (proxy_uri)
- soup_uri_free (proxy_uri);
-}
-
-static void
-soup_session_settings_notify_http_proxy_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- SoupSession* session)
-{
- gboolean uses_proxy = TRUE;
- MidoriProxy proxy_type = katze_object_get_enum (settings, "proxy-type");
- if (proxy_type == MIDORI_PROXY_AUTOMATIC)
- {
- soup_session_add_feature_by_type (session, SOUP_TYPE_PROXY_RESOLVER_GNOME);
-
- GProxyResolver* resolver = g_proxy_resolver_get_default ();
- gchar** proxies = g_proxy_resolver_lookup (resolver, "none", NULL, NULL);
-
- if (!proxies || !g_strcmp0 (proxies[0], "direct://"))
- uses_proxy = FALSE;
- g_strfreev (proxies);
- }
- else if (proxy_type == MIDORI_PROXY_HTTP)
- {
- soup_session_remove_feature_by_type (session, SOUP_TYPE_PROXY_RESOLVER_GNOME);
- gchar* proxy = katze_object_get_string (settings, "http-proxy");
- GString* http_proxy = g_string_new (proxy);
- g_string_append_printf (http_proxy, ":%d", katze_object_get_int (settings, "http-proxy-port"));
- midori_soup_session_set_proxy_uri (session, http_proxy->str);
- g_string_free (http_proxy, TRUE);
- g_free (proxy);
- }
- else
- {
- uses_proxy = FALSE;
- soup_session_remove_feature_by_type (session, SOUP_TYPE_PROXY_RESOLVER_GNOME);
- midori_soup_session_set_proxy_uri (session, NULL);
- }
-
- /* If a proxy server looks to be active, we disable prefetching, otherwise
- libSoup may be prefetching outside the proxy server beyond our control.
- */
-
- if (uses_proxy)
- g_object_set (settings, "enable-dns-prefetching", FALSE, NULL);
-}
-#endif
-
-#if WEBKIT_CHECK_VERSION (1, 1, 21)
-static void
-soup_session_settings_notify_first_party_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- gpointer user_data)
-{
- gboolean yes = katze_object_get_boolean (settings, "first-party-cookies-only");
-#ifdef HAVE_WEBKIT2
- WebKitWebContext* context = webkit_web_context_get_default ();
- WebKitCookieManager* cookie_manager = webkit_web_context_get_cookie_manager (context);
- webkit_cookie_manager_set_accept_policy (cookie_manager,
- yes ? WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY
- : WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
-#else
- SoupSession* session = webkit_get_default_session ();
- gpointer jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR);
- g_object_set (jar, "accept-policy",
- yes ? SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
- : SOUP_COOKIE_JAR_ACCEPT_ALWAYS, NULL);
-#endif
-}
-#endif
-
-#if !defined (HAVE_WEBKIT2)
-/* Implemented in MidoriLocationAction */
-void
-midori_map_add_message (SoupMessage* message);
-
-static void
-midori_soup_session_request_started_cb (SoupSession* session,
- SoupMessage* message,
- SoupSocket* socket,
- gpointer user_data)
-{
- midori_map_add_message (message);
-}
-#endif
-
-#ifndef HAVE_WEBKIT2
-const gchar*
-midori_web_settings_get_accept_language (MidoriWebSettings* settings);
-
-static void
-midori_soup_session_settings_accept_language_cb (SoupSession* session,
- SoupMessage* msg,
- MidoriWebSettings* settings)
-{
- const gchar* accept = midori_web_settings_get_accept_language (settings);
- soup_message_headers_append (msg->request_headers, "Accept-Language", accept);
-
- if (katze_object_get_boolean (settings, "strip-referer"))
- {
- const gchar* referer
- = soup_message_headers_get_one (msg->request_headers, "Referer");
- SoupURI* destination = soup_message_get_uri (msg);
- SoupURI* stripped_uri;
- if (referer && destination && !strstr (referer, destination->host)
- && (stripped_uri = soup_uri_new (referer)))
- {
- gchar* stripped_referer;
- soup_uri_set_path (stripped_uri, "");
- soup_uri_set_query (stripped_uri, NULL);
- stripped_referer = soup_uri_to_string (stripped_uri, FALSE);
- soup_uri_free (stripped_uri);
- if (strcmp (stripped_referer, referer))
- {
- if (midori_debug ("referer"))
- g_message ("Referer '%s' stripped to '%s'", referer, stripped_referer);
- soup_message_headers_replace (msg->request_headers, "Referer",
- stripped_referer);
- }
- g_free (stripped_referer);
- }
-
- /* With HTTP, Host is optional. Strip to outsmart some filter proxies */
- if (destination && destination->scheme == SOUP_URI_SCHEME_HTTP)
- soup_message_headers_remove (msg->request_headers, "Host");
- }
-}
-#endif
-
-gboolean
-midori_load_soup_session (gpointer settings)
-{
- #if WEBKIT_CHECK_VERSION (1, 1, 21)
- g_signal_connect (settings, "notify::first-party-cookies-only",
- G_CALLBACK (soup_session_settings_notify_first_party_cb), NULL);
- #endif
-
-#ifndef HAVE_WEBKIT2
- SoupSession* session = webkit_get_default_session ();
-
- #ifndef G_OS_WIN32
- g_object_set (session,
- "ssl-use-system-ca-file", TRUE,
- "ssl-strict", FALSE,
- NULL);
- #else /* G_OS_WIN32 */
- /* We cannot use "ssl-use-system-ca-file" on Windows
- * some GTLS backend pieces are missing currently.
- * Instead we specify the bundle we ship ourselves */
- gchar* certificate_file = midori_paths_get_res_filename ("ca-bundle.crt");
- g_object_set (session,
- "ssl-ca-file", certificate_file,
- "ssl-strict", FALSE,
- NULL);
- g_free (certificate_file);
- #endif
-
- g_object_set_data (G_OBJECT (session), "midori-settings", settings);
- soup_session_settings_notify_http_proxy_cb (settings, NULL, session);
- g_signal_connect (settings, "notify::http-proxy",
- G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
- g_signal_connect (settings, "notify::proxy-type",
- G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
-
- g_signal_connect (session, "request-started",
- G_CALLBACK (midori_soup_session_request_started_cb), session);
- g_signal_connect (session, "request-queued",
- G_CALLBACK (midori_soup_session_settings_accept_language_cb), settings);
-
- soup_session_add_feature (session, SOUP_SESSION_FEATURE (midori_hsts_new ()));
-
- if (midori_debug ("headers"))
- {
- SoupLogger* logger = soup_logger_new (SOUP_LOGGER_LOG_HEADERS, -1);
- soup_logger_attach (logger, session);
- g_object_unref (logger);
- }
- else if (midori_debug ("body"))
- {
- SoupLogger* logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
- soup_logger_attach (logger, session);
- g_object_unref (logger);
- }
-
- g_object_set_data (G_OBJECT (session), "midori-session-initialized", (void*)1);
-#endif
- return FALSE;
-}
-
-#ifndef HAVE_WEBKIT2
-static void
-midori_session_cookie_jar_changed_cb (SoupCookieJar* jar,
- SoupCookie* old_cookie,
- SoupCookie* new_cookie,
- MidoriWebSettings* settings)
-{
-
- if (midori_debug ("cookies"))
- {
- gchar* old = old_cookie ? soup_cookie_to_cookie_header (old_cookie) : NULL;
- gchar* new = new_cookie ? soup_cookie_to_cookie_header (new_cookie) : NULL;
- g_print ("cookie changed from %s to %s\n", old, new);
- g_free (old);
- g_free (new);
- }
-
- /* Don't allow revival of expiring cookies */
- if (new_cookie && old_cookie && old_cookie->expires)
- soup_cookie_set_expires (new_cookie, old_cookie->expires);
-
- if (new_cookie && new_cookie->expires)
- {
- time_t expires = soup_date_to_time_t (new_cookie->expires);
- gint age = katze_object_get_int (settings, "maximum-cookie-age");
- /* An age of 0 to SoupCookie means already-expired
- A user choosing 0 days probably expects 1 hour.
- */
- int seconds = age > 0 ? age * SOUP_COOKIE_MAX_AGE_ONE_DAY : SOUP_COOKIE_MAX_AGE_ONE_HOUR;
- SoupDate* max_date = soup_date_new_from_now (seconds);
- if (expires > soup_date_to_time_t (max_date))
- {
- if (midori_debug ("cookies"))
- {
- gchar* new_date = soup_date_to_string (max_date, SOUP_DATE_COOKIE);
- g_print ("^^ enforcing expiry: %s\n", new_date);
- g_free (new_date);
- }
- soup_cookie_set_expires (new_cookie, max_date);
- }
- soup_date_free (max_date);
- }
-}
-#endif
-
-gboolean
-midori_load_soup_session_full (gpointer settings)
-{
- #ifndef HAVE_WEBKIT2
- SoupSession* session = webkit_get_default_session ();
- SoupCookieJar* jar;
- gchar* config_file;
- SoupSessionFeature* feature;
-
- midori_load_soup_session (settings);
-
- config_file = midori_paths_get_config_filename_for_writing ("logins");
- feature = g_object_new (KATZE_TYPE_HTTP_AUTH, "filename", config_file, NULL);
- soup_session_add_feature (session, feature);
- g_object_unref (feature);
-
- katze_assign (config_file, midori_paths_get_config_filename_for_writing ("cookies.db"));
- jar = soup_cookie_jar_sqlite_new (config_file, FALSE);
- soup_session_add_feature (session, SOUP_SESSION_FEATURE (jar));
- g_signal_connect (jar, "changed",
- G_CALLBACK (midori_session_cookie_jar_changed_cb), settings);
- g_object_unref (jar);
-
- katze_assign (config_file, g_build_filename (midori_paths_get_cache_dir (), "web", NULL));
- feature = SOUP_SESSION_FEATURE (soup_cache_new (config_file, 0));
- soup_session_add_feature (session, feature);
- soup_cache_set_max_size (SOUP_CACHE (feature),
- katze_object_get_int (settings, "maximum-cache-size") * 1024 * 1024);
- soup_cache_load (SOUP_CACHE (feature));
- g_free (config_file);
- #endif
- return FALSE;
-}
-
-static void
-extensions_update_cb (KatzeArray* extensions,
- MidoriApp* app)
-{
- MidoriWebSettings* settings = katze_object_get_object (app, "settings");
- g_object_notify (G_OBJECT (settings), "load-on-startup");
- g_object_unref (settings);
-}
-
-gboolean
-midori_load_extensions (gpointer data)
-{
- MidoriApp* app = MIDORI_APP (data);
- gchar** keys = g_object_get_data (G_OBJECT (app), "extensions");
- KatzeArray* extensions;
- gboolean startup_timer = midori_debug ("startup");
- GTimer* timer = startup_timer ? g_timer_new () : NULL;
-
- /* Load extensions */
- extensions = katze_array_new (MIDORI_TYPE_EXTENSION);
- g_signal_connect (extensions, "update", G_CALLBACK (extensions_update_cb), app);
- g_object_set (app, "extensions", extensions, NULL);
- midori_extension_load_from_folder (app, keys, TRUE);
-
- if (startup_timer)
- g_debug ("Extensions:\t%f", g_timer_elapsed (timer, NULL));
-
- return FALSE;
-}
-
-static void
-settings_notify_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- MidoriApp* app)
-{
- GError* error = NULL;
- gchar* config_file;
-
- /* Skip state related properties to avoid disk I/ O */
- if (pspec && midori_settings_delay_saving (MIDORI_SETTINGS (settings), pspec->name))
- return;
-
- config_file = midori_paths_get_config_filename_for_writing ("config");
- if (!midori_settings_save_to_file (settings, G_OBJECT (app), config_file, &error))
- {
- g_warning (_("The configuration couldn't be saved. %s"), error->message);
- g_error_free (error);
- }
- g_free (config_file);
-}
-
-static void
-midori_session_accel_map_changed_cb (GtkAccelMap* accel_map,
- gchar* accel_path,
- guint accel_key,
- GdkModifierType accel_mods)
-{
- gchar* config_file = midori_paths_get_config_filename_for_writing ("accels");
- gtk_accel_map_save (config_file);
- g_free (config_file);
-}
-
-void
-midori_session_persistent_settings (MidoriWebSettings* settings,
- MidoriApp* app)
-{
- g_signal_connect_after (settings, "notify", G_CALLBACK (settings_notify_cb), app);
- g_signal_connect_after (gtk_accel_map_get (), "changed",
- G_CALLBACK (midori_session_accel_map_changed_cb), NULL);
-
-}
diff --git a/midori/midori-session.h b/midori/midori-session.h
deleted file mode 100644
index d229de94..00000000
--- a/midori/midori-session.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- Copyright (C) 2008-2013 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 __MIDORI_SESSION_H__
-#define __MIDORI_SESSION_H__
-
-#include <glib/gstdio.h>
-#include "midori-app.h"
-#include "midori-websettings.h"
-
-gboolean
-midori_load_soup_session (gpointer settings);
-
-gboolean
-midori_load_soup_session_full (gpointer settings);
-
-gboolean
-midori_load_extensions (gpointer data);
-
-void
-midori_session_persistent_settings (MidoriWebSettings* settings,
- MidoriApp* app);
-
-#endif /* __MIDORI_SESSION_H__ */
-
diff --git a/midori/midori-settings.vala b/midori/midori-settings.vala
deleted file mode 100644
index 387aafaa..00000000
--- a/midori/midori-settings.vala
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- Copyright (C) 2008-2013 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2011 Peter Hatina <phatina@redhat.com>
-
- 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.
-*/
-
-namespace Midori {
- [CCode (cprefix = "MIDORI_WINDOW_")]
- public enum WindowState {
- NORMAL,
- MINIMIZED,
- MAXIMIZED,
- FULLSCREEN
- }
- /* Since: 0.1.3 */
-#if !HAVE_WEBKIT2
- public class Settings : WebKit.WebSettings {
- /* Since: 0.5.0 */
- public bool enable_javascript { get {
- return enable_scripts;
- } set {
- enable_scripts = value;
- } }
- /* Since: 0.5.1 */
- public string default_charset { owned get {
- return default_encoding;
- } set {
- default_encoding = value;
- } }
- /* Since: 0.1.3 */
- public bool zoom_text_and_images { get; set; default = true; }
-#else
- public class Settings : WebKit.Settings {
- public bool zoom_text_and_images { get {
- return !zoom_text_only;
- } set {
- zoom_text_only = !value;
- } }
- public bool enable_spell_checking { get {
- return WebKit.WebContext.get_default ().get_spell_checking_enabled ();
- } set {
- WebKit.WebContext.get_default ().set_spell_checking_enabled (value);
- } }
-#endif
- public bool remember_last_window_size { get; set; default = true; }
- public int last_window_width { get; set; default = 0; }
- public int last_window_height { get; set; default = 0; }
- public int last_panel_position { get; set; default = 0; }
- public int last_panel_page { get; set; default = 0; }
- public int last_web_search { get; set; default = 0; }
- /* Since: 0.4.3 */
- // [IntegerType (min = 10, max = int.max)]
- public int search_width { get; set; default = 200; }
- /* Since: 0.4.7 */
- public bool last_inspector_attached { get; set; default = false; }
- /* Since: 0.1.3 */
- public WindowState last_window_state { get; set; default = WindowState.NORMAL; }
-
- /* Since: 0.4.8 */
- public uint inactivity_reset { get; set; default = 0; }
-
- string? default_theme_name_ = null;
- /* Since: 0.5.5 */
- public string? default_theme_name { get {
- if (default_theme_name_ == null)
- default_theme_name_ = Gtk.Settings.get_default ().gtk_theme_name;
- return default_theme_name_;
- } }
- string? theme_name_ = null;
- /* Since: 0.5.5 */
- public string? theme_name { get {
- return theme_name_;
- } set {
- if (theme_name != value) {
- if (default_theme_name_ == null)
- default_theme_name_ = Gtk.Settings.get_default ().gtk_theme_name;
- theme_name_ = value;
- Gtk.Settings.get_default ().gtk_theme_name = theme_name_;
- }
- } }
-
- GLib.Regex? block_uris_regex = null;
- /* Since: 0.4.8 */
- public string? block_uris { get {
- return block_uris_regex != null ? block_uris_regex.get_pattern () : null;
- } set {
-#if !HAVE_WEBKIT2
- if (value == null || value == "")
- return;
- if (block_uris_regex == null)
- WebKit.get_default_session ().request_queued.connect ((msg) => {
- if (block_uris_regex.match (msg.uri.to_string (false)))
- msg.uri = new Soup.URI ("http://.invalid");
- });
- try {
- block_uris_regex = new GLib.Regex (value);
- }
- catch (Error error) {
- critical ("block-uris: %s", error.message);
- }
-#endif
- } }
-
- /**
- * Overrides the browser window title if given.
- * Examples are "Help Viewer" or "L:D_N:application_ID:midori_O:URL"
- *
- * Since: 0.5.1
- **/
- public string? custom_title { get; set; default = null; }
-
- public string? location_entry_search { get; set; default = null; }
- /* Since: 0.1.7 */
- public int clear_private_data { get; set; default = 0; }
- /* Since: 0.2.9 */
- public string? clear_data { get; set; default = null; }
-
- public bool compact_sidepanel { get; set; default = false; }
- /* Since: 0.2.2 */
- public bool open_panels_in_windows { get; set; default = false; }
- /* Since: 0.1.3 */
- public bool right_align_sidepanel { get; set; default = false; }
-
- public bool show_menubar { get; set; default = false; }
- public bool show_navigationbar { get; set; default = true; }
- public bool show_bookmarkbar { get; set; default = false; }
- public bool show_panel { get; set; default = false; }
- public bool show_statusbar { get; set; default = true; }
- /* Since: 0.1.2 */
- public bool show_crash_dialog { get; set; default = true; }
- public string toolbar_items { get; set; default =
- "TabNew,Back,NextForward,ReloadStop,BookmarkAdd,Location,Search,Trash,CompactMenu"; }
- /* Since: 0.1.4 */
- // [Deprecated (since = "0.4.7")]
- public bool find_while_typing { get; set; default = false; }
- /* Since: 0.5.4 */
- public double zoom_level { get; set; default = 1.0; }
-
- public bool open_popups_in_tabs { get; set; default = true; }
- /* Since: 0.2.0 */
- // [Deprecated (since = "0.4.9")]
- public bool kinetic_scrolling { get; set; default = true; }
- // [Deprecated (since = "0.5.0")]
- public bool middle_click_opens_selection { get; set; default = true; }
- public bool flash_window_on_new_bg_tabs { get; set; default = false; }
-
- public bool close_buttons_on_tabs { get; set; default = true; }
- public bool open_tabs_in_the_background { get; set; default = true; }
- public bool open_tabs_next_to_current { get; set; default = true; }
- // [Deprecated (since = "0.5.7")]
- public bool always_show_tabbar { get; set; default = true; }
-
- public string homepage { get; set; default = "about:search"; }
- public string tabhome { get; set; default = "about:dial"; }
- static string default_download_folder () {
- return Environment.get_user_special_dir (UserDirectory.DOWNLOAD)
- ?? Environment.get_home_dir ();
- }
- public string download_folder { get; set; default = default_download_folder (); }
- public string? text_editor { get; set; default = null; }
- /* Since: 0.1.6 */
- public string? news_aggregator { get; set; default = null; }
-
- public string http_proxy { get; set; default = null; }
- /* Since: 0.4.2 */
- // [IntegerType (min = 1, max = 65535)]
- public int http_proxy_port { get; set; default = 8080; }
- /* Since: 0.3.4 */
- // [IntegerType (min = 0, int.max)]
- public int maximum_cache_size { get; set; default = 100; }
- /* Since: 0.3.4 */
- public bool strip_referer { get; set; default = true; }
- /* Since: 0.4.2 */
- public bool first_party_cookies_only { get; set; default = true; }
- // [IntegerType (min = 0, int.max)]
- public int maximum_cookie_age { get; set; default = 30; }
- // [IntegerType (min = 0, int.max)]
- public int maximum_history_age { get; set; default = 30; }
-
- /* Since: 0.4.7 */
- public bool delay_saving (string property) {
- return property.has_prefix ("last-")
- || property == "user-stylesheet-uri"
- || property.has_suffix ("-width");
- }
- }
-}
diff --git a/midori/midori-speeddial.vala b/midori/midori-speeddial.vala
deleted file mode 100644
index 9c112f7e..00000000
--- a/midori/midori-speeddial.vala
+++ /dev/null
@@ -1,426 +0,0 @@
-/*
- Copyright (C) 2011-2013 Christian Dywan <christian@twotoats.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.
-*/
-
-namespace Katze {
- extern static string mkdir_with_parents (string pathname, int mode);
-}
-
-namespace Sokoke {
- extern static string js_script_eval (void* ctx, string script, void* error);
-}
-
-namespace Midori {
- public errordomain SpeedDialError {
- INVALID_MESSAGE,
- NO_ACTION,
- NO_ID,
- NO_URL,
- NO_TITLE,
- NO_ID2,
- INVALID_ACTION,
- }
-
- public class SpeedDial : GLib.Object {
- string filename;
- string? html = null;
- List<Spec> thumb_queue = null;
-#if !HAVE_WEBKIT2
- WebKit.WebView thumb_view = null;
- Spec? spec = null;
-#endif
-
- public GLib.KeyFile keyfile;
- public bool close_buttons_left { get; set; default = false; }
- public signal void refresh ();
-
- public class Spec {
- public string dial_id;
- public string uri;
- public Spec (string dial_id, string uri) {
- this.dial_id = dial_id;
- this.uri = uri;
- }
- }
-
- public SpeedDial (string new_filename, string? fallback = null) {
- filename = new_filename;
- thumb_queue = new GLib.List<Spec> ();
- keyfile = new GLib.KeyFile ();
- try {
- keyfile.load_from_file (filename, GLib.KeyFileFlags.NONE);
- }
- catch (GLib.Error io_error) {
- string json;
- size_t len;
- try {
- FileUtils.get_contents (fallback ?? (filename + ".json"),
- out json, out len);
- }
- catch (GLib.Error fallback_error) {
- json = "'{}'";
- len = 4;
- }
-
- var script = new StringBuilder.sized (len);
- script.append ("var json = JSON.parse (");
- script.append_len (json, (ssize_t)len);
- script.append ("""
- );
- var keyfile = '';
- for (var i in json['shortcuts']) {
- var tile = json['shortcuts'][i];
- keyfile += '[Dial ' + tile['id'].substring (1) + ']\n'
- + 'uri=' + tile['href'] + '\n'
- + 'img=' + tile['img'] + '\n'
- + 'title=' + tile['title'] + '\n\n';
- }
- var columns = json['width'] ? json['width'] : 3;
- var rows = json['shortcuts'] ? json['shortcuts'].length / columns : 0;
- keyfile += '[settings]\n'
- + 'columns=' + columns + '\n'
- + 'rows=' + (rows > 3 ? rows : 3) + '\n\n';
- keyfile;
- """);
-
- try {
- keyfile.load_from_data (
- Sokoke.js_script_eval (null, script.str, null),
- -1, 0);
- }
- catch (GLib.Error eval_error) {
- GLib.critical ("Failed to parse %s as speed dial JSON: %s",
- fallback ?? (filename + ".json"), eval_error.message);
- }
- Katze.mkdir_with_parents (
- Path.build_path (Path.DIR_SEPARATOR_S,
- Environment.get_user_cache_dir (),
- PACKAGE_NAME, "thumbnails"), 0700);
-
- foreach (unowned string tile in keyfile.get_groups ()) {
- try {
- string img = keyfile.get_string (tile, "img");
- keyfile.remove_key (tile, "img");
- string uri = keyfile.get_string (tile, "uri");
- if (img != null && uri[0] != '\0' && uri[0] != '#') {
- uchar[] decoded = Base64.decode (img);
- FileUtils.set_data (build_thumbnail_path (uri), decoded);
- }
- }
- catch (GLib.Error img_error) {
- /* img and uri can be missing */
- }
- }
- }
- }
-
- public string get_next_free_slot (out uint count = null) {
- uint slot_count = 0;
- foreach (unowned string tile in keyfile.get_groups ()) {
- try {
- if (keyfile.has_key (tile, "uri"))
- slot_count++;
- }
- catch (KeyFileError error) { }
- }
- count = slot_count;
-
- uint slot = 1;
- while (slot <= slot_count) {
- string tile = "Dial %u".printf (slot);
- if (!keyfile.has_group (tile))
- return tile;
- slot++;
- }
-
- return "Dial %u".printf (slot_count + 1);
- }
-
- public void add (string uri, string title, Gdk.Pixbuf? img) {
- string id = get_next_free_slot ();
- uint slot = id.substring (5, -1).to_int ();
- try {
- save_message ("speed_dial-save-add %u %s".printf (slot, uri));
- }
- catch (Error error) {
- critical ("Failed to add speed dial thumbnail: %s", error.message);
- }
- }
-
- public void add_with_id (string id, string uri, string title, Gdk.Pixbuf? img) {
- keyfile.set_string (id, "uri", uri);
- keyfile.set_string (id, "title", title);
-
- Katze.mkdir_with_parents (Path.build_path (Path.DIR_SEPARATOR_S,
- Paths.get_cache_dir (), "thumbnails"), 0700);
- string filename = build_thumbnail_path (uri);
- try {
- img.save (filename, "png", null, "compression", "7", null);
- }
- catch (Error error) {
- critical ("Failed to save speed dial thumbnail: %s", error.message);
- }
- save ();
- }
-
- string build_thumbnail_path (string filename) {
- string thumbnail = Checksum.compute_for_string (ChecksumType.MD5, filename) + ".png";
- return Path.build_filename (Paths.get_cache_dir (), "thumbnails", thumbnail);
- }
-
- public unowned string get_html () throws Error {
- bool load_missing = true;
-
- if (html != null)
- return html;
-
- string? head = null;
- string filename = Paths.get_res_filename ("speeddial-head.html");
- if (keyfile != null
- && FileUtils.get_contents (filename, out head, null)) {
- string header = head.replace ("{title}", _("Speed Dial")).
- replace ("{click_to_add}", _("Click to add a shortcut")).
- replace ("{enter_shortcut_address}", _("Enter shortcut address")).
- replace ("{are_you_sure}", _("Are you sure you want to delete this shortcut?"));
- var markup = new StringBuilder (header);
-
- uint slot_count = 1;
- string dial_id = get_next_free_slot (out slot_count);
- uint next_slot = dial_id.substring (5, -1).to_int ();
-
- /* Try to guess the best X by X grid size */
- uint grid_index = 3;
- while ((grid_index * grid_index) < slot_count)
- grid_index++;
-
- /* Percent width size of one slot */
- uint slot_size = (100 / grid_index);
-
- /* No editing in private/ app mode or without scripts */
- markup.append_printf (
- "%s<style>.cross { display:none }</style>%s" +
- "<style> div.shortcut { height: %d%%; width: %d%%; }</style>\n",
- Paths.is_readonly () ? "" : "<noscript>",
- Paths.is_readonly () ? "" : "</noscript>",
- slot_size + 1, slot_size - 4);
-
- /* Combined width of slots should always be less than 100%.
- * Use half of the remaining percentage as a margin size */
- uint div_factor;
- if (slot_size * grid_index >= 100 && grid_index > 4)
- div_factor = 8;
- else
- div_factor = 2;
- uint margin = (100 - ((slot_size - 4) * grid_index)) / div_factor;
- if (margin > 9)
- margin = margin % 10;
-
- markup.append_printf (
- "<style> body { overflow:hidden } #content { margin-left: %u%%; }</style>", margin);
- if (close_buttons_left)
- markup.append_printf (
- "<style>.cross { left: -14px }</style>");
-
- foreach (unowned string tile in keyfile.get_groups ()) {
- try {
- string uri = keyfile.get_string (tile, "uri");
- if (uri != null && uri.str ("://") != null && tile.has_prefix ("Dial ")) {
- string title = keyfile.get_string (tile, "title");
- string thumb_filename = build_thumbnail_path (uri);
- uint slot = tile.substring (5, -1).to_int ();
- string encoded;
- try {
- uint8[] thumb;
- FileUtils.get_data (thumb_filename, out thumb);
- encoded = Base64.encode (thumb);
- }
- catch (FileError error) {
- encoded = null;
- if (load_missing)
- get_thumb (tile, uri);
- }
- markup.append_printf ("""
- <div class="shortcut" id="%u"><div class="preview">
- <a class="cross" href="#"></a>
- <a href="%s"><img src="data:image/png;base64,%s" title='%s'></a>
- </div><input type="text" class="title selectable" value="%s"></div>
- """,
- slot, uri, encoded ?? "", title, title ?? "");
- }
- else if (tile != "settings")
- keyfile.remove_group (tile);
- }
- catch (KeyFileError error) { }
- }
-
- markup.append_printf ("""
- <div class="shortcut" id="%u"><div class="preview new">
- <a class="add" href="#"></a>
- </div><div class="title">%s</div></div>
- """,
- next_slot, _("Click to add a shortcut"));
- markup.append_printf ("</div>\n</body>\n</html>\n");
- html = markup.str;
- }
- else
- html = "";
-
- return html;
- }
-
- public void save_message (string message) throws Error {
- if (!message.has_prefix ("speed_dial-save-"))
- throw new SpeedDialError.INVALID_MESSAGE ("Invalid message '%s'", message);
-
- string msg = message.substring (16, -1);
- string[] parts = msg.split (" ", 3);
- if (parts[0] == null)
- throw new SpeedDialError.NO_ACTION ("No action.");
- string action = parts[0];
-
- if (parts[1] == null)
- throw new SpeedDialError.NO_ID ("No ID argument.");
- string dial_id = "Dial " + parts[1];
-
- if (action == "delete") {
- string uri = keyfile.get_string (dial_id, "uri");
- string file_path = build_thumbnail_path (uri);
- keyfile.remove_group (dial_id);
- FileUtils.unlink (file_path);
- }
- else if (action == "add") {
- if (parts[2] == null)
- throw new SpeedDialError.NO_URL ("No URL argument.");
- keyfile.set_string (dial_id, "uri", parts[2]);
- get_thumb (dial_id, parts[2]);
- }
- else if (action == "rename") {
- if (parts[2] == null)
- throw new SpeedDialError.NO_TITLE ("No title argument.");
- string title = parts[2];
- keyfile.set_string (dial_id, "title", title);
- }
- else if (action == "swap") {
- if (parts[2] == null)
- throw new SpeedDialError.NO_ID2 ("No ID2 argument.");
- string dial2_id = "Dial " + parts[2];
-
- string uri = keyfile.get_string (dial_id, "uri");
- string title = keyfile.get_string (dial_id, "title");
- string uri2 = keyfile.get_string (dial2_id, "uri");
- string title2 = keyfile.get_string (dial2_id, "title");
-
- keyfile.set_string (dial_id, "uri", uri2);
- keyfile.set_string (dial2_id, "uri", uri);
- keyfile.set_string (dial_id, "title", title2);
- keyfile.set_string (dial2_id, "title", title);
- }
- else
- throw new SpeedDialError.INVALID_ACTION ("Invalid action '%s'", action);
-
- save ();
- }
-
- void save () {
- html = null;
-
- try {
- FileUtils.set_contents (filename, keyfile.to_data ());
- }
- catch (Error error) {
- critical ("Failed to update speed dial: %s", error.message);
- }
- refresh ();
- }
-
-#if !HAVE_WEBKIT2
- void load_status (GLib.Object thumb_view_, ParamSpec pspec) {
- if (thumb_view.load_status != WebKit.LoadStatus.FINISHED
- && thumb_view.load_status != WebKit.LoadStatus.FAILED)
- return;
- thumb_view.notify["load-status"].disconnect (load_status);
- /* Schedule an idle to give the offscreen time to draw */
- Idle.add (save_thumbnail);
- }
-#endif
-
-#if !HAVE_WEBKIT2
- bool save_thumbnail () {
- return_val_if_fail (spec != null, false);
-
- var offscreen = (thumb_view.parent as Gtk.OffscreenWindow);
- var pixbuf = offscreen.get_pixbuf ();
- int image_width = pixbuf.get_width (), image_height = pixbuf.get_height ();
- int thumb_width = 240, thumb_height = 160;
- float image_ratio = image_width / image_height;
- float thumb_ratio = thumb_width / thumb_height;
- int x_offset, y_offset, computed_width, computed_height;
- if (image_ratio > thumb_ratio) {
- computed_width = (int)(image_height * thumb_ratio);
- computed_height = image_height;
- x_offset = (image_width - computed_width) / 2;
- y_offset = 0;
- }
- else {
- computed_width = image_width;
- computed_height = (int)(image_width / thumb_ratio);
- x_offset = 0;
- y_offset = 0;
- }
- var sub = pixbuf;
- if (y_offset + computed_height <= image_height)
- sub = new Gdk.Pixbuf.subpixbuf (pixbuf, x_offset, y_offset, computed_width, computed_height);
- var scaled = sub.scale_simple (thumb_width, thumb_height, Gdk.InterpType.TILES);
- add_with_id (spec.dial_id, spec.uri, thumb_view.get_title () ?? spec.uri, scaled);
-
- thumb_queue.remove (spec);
- if (thumb_queue.length () > 0) {
- spec = thumb_queue.nth_data (0);
- thumb_view.notify["load-status"].connect (load_status);
- thumb_view.load_uri (spec.uri);
- }
- return false;
- }
-#endif
-
- void get_thumb (string dial_id, string uri) {
-#if !HAVE_WEBKIT2
- if (thumb_view == null) {
- thumb_view = new WebKit.WebView ();
- thumb_view.settings.set (
- "enable-scripts", false,
- "enable-plugins", false,
- "auto-load-images", true,
- "enable-html5-database", false,
- "enable-html5-local-storage", false,
- "enable-java-applet", false);
- var offscreen = new Gtk.OffscreenWindow ();
- offscreen.add (thumb_view);
- thumb_view.set_size_request (800, 600);
- offscreen.show_all ();
- }
-
- /* Don't load thumbnails already queued */
- foreach (var spec_ in thumb_queue)
- if (spec_.dial_id == dial_id)
- return;
-
- thumb_queue.append (new Spec (dial_id, uri));
- if (thumb_queue.length () > 1)
- return;
-
- spec = thumb_queue.nth_data (0);
- thumb_view.notify["load-status"].connect (load_status);
- thumb_view.load_uri (spec.uri);
-#endif
- }
- }
-}
-
diff --git a/midori/midori-stock.h b/midori/midori-stock.h
deleted file mode 100644
index 0ce71847..00000000
--- a/midori/midori-stock.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- Copyright (C) 2007-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 __MIDORI_STOCK_H__
-#define __MIDORI_STOCK_H__ 1
-
-/* Stock items */
-
-#define STOCK_BOOKMARKS "user-bookmarks"
-#define STOCK_EXTENSION "extension"
-#define STOCK_HISTORY "document-open-recent"
-#define MIDORI_STOCK_WEB_BROWSER "web-browser"
-#define STOCK_NEWS_FEED "internet-news-reader"
-#define STOCK_STYLE "preferences-desktop-theme"
-#define MIDORI_STOCK_TRANSFER "package"
-#define MIDORI_STOCK_PLUGINS "application-x-shockwave-flash"
-#define STOCK_BOOKMARK_ADD "bookmark-new"
-#define STOCK_IMAGE "image-x-generic"
-#define STOCK_NETWORK_OFFLINE "network-offline"
-#define STOCK_SCRIPT "text-x-javascript"
-#define STOCK_SEND "mail-send"
-#define STOCK_TAB_NEW "tab-new"
-#define STOCK_USER_TRASH "user-trash"
-#define STOCK_WINDOW_NEW "window-new"
-#define STOCK_FOLDER_NEW "folder-new"
-#define STOCK_EDIT_CLEAR "edit-clear"
-#define STOCK_EDIT_FIND "edit-find"
-#define STOCK_STOP "stop"
-#define STOCK_URL "text-html"
-
-#endif /* !__MIDORI_STOCK_H__ */
diff --git a/midori/midori-tab.vala b/midori/midori-tab.vala
deleted file mode 100644
index a415f8fd..00000000
--- a/midori/midori-tab.vala
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- Copyright (C) 2007-2013 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2009 Jean-François Guchens <zcx000@gmail.com>
- Copyright (C) 2011 Peter Hatina <phatina@redhat.com>
-
- 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.
-*/
-
-namespace Midori {
- public enum NewView {
- TAB,
- BACKGROUND,
- WINDOW,
- }
- /* Since: 0.1.2 */
-
- public enum Security {
- NONE, /* The connection is neither encrypted nor verified. */
- UNKNOWN, /* The security is unknown, due to lack of validation. */
- TRUSTED /* The security is validated and trusted. */
- }
- /* Since: 0.2.5 */
-
- [CCode (cprefix = "MIDORI_LOAD_")]
- public enum LoadStatus {
- FINISHED, /* The current website is fully loaded. */
- COMMITTED, /* Data is being loaded and rendered. */
- PROVISIONAL /* A new URI was scheduled. */
- }
-
- [CCode (cprefix = "MIDORI_LOAD_ERROR_")]
- public enum LoadError {
- NONE,
- DELAYED,
- SECURITY,
- CRASH,
- NETWORK
- }
-
- public class Tab : Gtk.VBox {
- public Tab related { get; set construct; }
- public WebKit.WebView web_view { get; private set; }
-
- private string current_uri = "about:blank";
- public string uri { get {
- return current_uri;
- }
- protected set {
- current_uri = Midori.URI.format_for_display (value);
- }
- }
-
- /* Special is an error, blank or delayed page */
- public bool special { get; protected set; default = false; }
- /* Minimizing a tab indicates that only the icon should be shown.
- Since: 0.1.8 */
- public bool minimized { get; set; default = false; }
- /* Since: 0.4.8 */
- public string mime_type { get; protected set; default = "text/plain"; }
- /* Since: 0.1.2 */
- public Security security { get; protected set; default = Security.NONE; }
- public LoadStatus load_status { get; protected set; default = LoadStatus.FINISHED; }
- public LoadError load_error { get; protected set; default = LoadError.NONE; }
- public string? statusbar_text { get; protected set; default = null; }
- /* Since: 0.5.0 */
-
- public Gdk.Color? fg_color { get; protected set; default = null; }
- private Gdk.Color? bg_color_ = null;
- public Gdk.Color? bg_color { get {
- return bg_color_;
- } protected set {
- bg_color_ = value;
- colors_changed ();
- } }
- /* After fg_color and bg_color have changed.
- Since: 0.5.7 */
- public signal void colors_changed ();
-
- /* Special pages don't convey progress */
- private double current_progress = 0.0;
- public double progress { get {
- return special ? 0.0 : current_progress;
- }
- protected set {
- /* When we are finished, we don't want to *see* progress anymore */
- if (load_status == LoadStatus.FINISHED)
- current_progress = 0.0;
- /* Full progress but not finished: presumably all loaded */
- else if (value == 1.0)
- current_progress = 0.0;
- /* When loading we want to see at minimum 10% progress */
- else
- current_progress = value.clamp (0.1, 1.0);
- }
- }
-
- /* Emitted when a uri is attempted to be loaded.
- Returns FALSE if the URI could not be handled by Midori or any
- external application.
- Since: 0.5.8
- */
- public signal bool open_uri (string uri);
- /* Since: 0.5.8 */
- public signal bool navigation_requested (string uri);
- public signal void console_message (string message, int line, string source_id);
- public signal void attach_inspector (WebKit.WebView inspector_view);
- /* Emitted when an open inspector that was previously
- attached to the window is now detached again.
- Since: 0.3.4
- */
- public signal void detach_inspector (WebKit.WebView inspector_view);
- /* Allow the browser to provide the find bar */
- public signal void search_text (bool found, string typing);
-
- /* Since: 0.5.5 */
- public signal void context_menu (WebKit.HitTestResult hit_test_result, ContextAction menu);
-
- /* A dialog tab has a fixed size, limited GUI and is transient.
- Since: 0.5.6 */
- public bool is_dialog { get; protected set; }
-
- public bool is_blank () {
- return URI.is_blank (uri);
- }
-
- construct {
- #if HAVE_GTK3
- orientation = Gtk.Orientation.VERTICAL;
- #endif
-
-#if HAVE_WEBKIT2_3_91
- web_view = related != null ?
- new WebKit.WebView.with_related_view (related.web_view) : new WebKit.WebView ();
-#else
- web_view = new WebKit.WebView ();
-#endif
- /* Load something to avoid a bug where WebKit might not set a main frame */
- web_view.load_uri ("");
- }
-
- public void inject_stylesheet (string stylesheet) {
-#if !HAVE_WEBKIT2
- var dom = web_view.get_dom_document ();
- return_if_fail (dom.head != null);
- try {
- var style = dom.create_element ("style");
- style.set_attribute ("type", "text/css");
- style.append_child (dom.create_text_node (stylesheet));
- dom.head.append_child (style);
- }
- catch (Error error) {
- critical (_("Failed to inject stylesheet: %s"), error.message);
- }
-#endif
- }
-
- /* Since: 0.5.1
- Deprecated: 0.6.0: The feature is no longer provided by WebKit.
- */
- public bool view_source { get; private set; default = false; }
-
- public bool can_view_source () {
- if (view_source)
- return false;
- string content_type = ContentType.from_mime_type (mime_type);
-#if HAVE_WIN32
- /* On Win32 text/plain maps to ".txt" but is_a expects "text" */
- string text_type = "text";
-#else
- string text_type = ContentType.from_mime_type ("text/plain");
-#endif
- return ContentType.is_a (content_type, text_type);
- }
-
- public static string get_display_title (string? title, string uri) {
- /* Render filename as title of patches */
- if (title == null && (uri.has_suffix (".diff") || uri.has_suffix (".patch")))
- return File.new_for_uri (uri).get_basename ();
-
- /* Work-around libSoup not setting a proper directory title */
- if (title == null || (title == "OMG!" && uri.has_prefix ("file://")))
- return Midori.URI.strip_prefix_for_display (uri);
-
-#if !HAVE_WIN32
- /* If left-to-right text is combined with right-to-left text the default
- behaviour of Pango can result in awkwardly aligned text. For example
- "‪بستيان نوصر (hadess) | An era comes to an end - Midori" becomes
- "hadess) | An era comes to an end - Midori) بستيان نوصر". So to prevent
- this we insert an LRE character before the title which indicates that
- we want left-to-right but retains the direction of right-to-left text. */
- if (!title.has_prefix ("‪"))
- return "‪" + title;
-#endif
- return title;
- }
-
- public static Pango.EllipsizeMode get_display_ellipsize (string title, string uri) {
- if (title == uri)
- return Pango.EllipsizeMode.START;
-
- if (title.has_suffix (".diff") || title.has_suffix (".patch"))
- return Pango.EllipsizeMode.START;
-
- string[] parts = title.split (" ");
- if (parts[0] != null && uri.has_suffix (parts[parts.length - 1].down ()))
- return Pango.EllipsizeMode.START;
-
- return Pango.EllipsizeMode.END;
- }
-
- /* Since: 0.4.3 */
- public bool can_save () {
- if (is_blank () || special)
- return false;
- if (view_source)
- return false;
-#if !HAVE_WEBKIT2
- if (web_view.get_main_frame ().get_data_source ().get_data () == null)
- return false;
-#endif
- return true;
- }
-
- public void stop_loading () {
- web_view.stop_loading ();
- }
-
- public bool can_go_forward () {
- return web_view.can_go_forward ();
- }
-
- public void go_forward () {
- web_view.go_forward ();
- }
-
- public void unmark_text_matches () {
-#if !HAVE_WEBKIT2
- web_view.unmark_text_matches ();
-#endif
- }
-
- public bool find (string text, bool case_sensitive, bool forward) {
-#if HAVE_WEBKIT2
- var controller = web_view.get_find_controller ();
- uint options = WebKit.FindOptions.WRAP_AROUND;
- if (!case_sensitive)
- options += WebKit.FindOptions.CASE_INSENSITIVE;
- if (!forward)
- options += WebKit.FindOptions.BACKWARDS;
- controller.search (text, options, 0);
- // FIXME: mark matches, count matches, not found
- return true;
-#else
- bool found = false;
- found = web_view.search_text (text, case_sensitive, forward, true);
- web_view.mark_text_matches (text, case_sensitive, 0);
- web_view.set_highlight_text_matches (true);
- return found;
-#endif
- }
-
- /*
- Updates all editing actions with regard to text selection.
-
- Since: 0.5.8
- */
- public async void update_actions (Gtk.ActionGroup actions) {
-#if HAVE_WEBKIT2
- try {
- actions.get_action ("Undo").sensitive = yield web_view.can_execute_editing_command ("Undo", null);
- actions.get_action ("Redo").sensitive = yield web_view.can_execute_editing_command ("Redo", null);
- actions.get_action ("Cut").sensitive = yield web_view.can_execute_editing_command ("Cut", null);
- actions.get_action ("Copy").sensitive = yield web_view.can_execute_editing_command ("Copy", null);
- actions.get_action ("Paste").sensitive = yield web_view.can_execute_editing_command ("Paste", null);
- actions.get_action ("Delete").sensitive = yield web_view.can_execute_editing_command ("Cut", null);
- actions.get_action ("SelectAll").sensitive = yield web_view.can_execute_editing_command ("SelectAll", null);
- } catch (Error error) {
- critical ("Failed to update actions: %s", error.message);
- }
-#else
- actions.get_action ("Undo").sensitive = web_view.can_undo ();
- actions.get_action ("Redo").sensitive = web_view.can_redo ();
- actions.get_action ("Cut").sensitive = web_view.can_cut_clipboard ();
- actions.get_action ("Copy").sensitive = web_view.can_copy_clipboard ();
- actions.get_action ("Paste").sensitive = web_view.can_paste_clipboard ();
- actions.get_action ("Delete").sensitive = web_view.can_cut_clipboard ();
- actions.get_action ("SelectAll").sensitive = true;
-#endif
- }
- }
-}
diff --git a/midori/midori-view.c b/midori/midori-view.c
deleted file mode 100644
index 9af39810..00000000
--- a/midori/midori-view.c
+++ /dev/null
@@ -1,5052 +0,0 @@
-/*
- Copyright (C) 2007-2013 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2009 Jean-François Guchens <zcx000@gmail.com>
-
- 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.
-*/
-
-#include "midori-view.h"
-#include "midori-browser.h"
-#include "midori-searchaction.h"
-#include "midori-app.h"
-#include "midori-platform.h"
-#include "midori-core.h"
-#include "midori-findbar.h"
-
-#include "marshal.h"
-
-#include <config.h>
-
-#ifdef HAVE_GCR
- #define GCR_API_SUBJECT_TO_CHANGE
- #include <gcr/gcr.h>
-#endif
-
-#if !defined (HAVE_WEBKIT2)
-SoupMessage*
-midori_map_get_message (SoupMessage* message);
-#endif
-
-#include <string.h>
-#include <stdlib.h>
-#include <glib/gi18n.h>
-#include <glib/gprintf.h>
-#include <glib/gstdio.h>
-#include <gdk/gdkkeysyms.h>
-#include "katze/katze.h"
-
-#if HAVE_UNISTD_H
- #include <unistd.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#ifndef G_OS_WIN32
- #include <sys/utsname.h>
-#endif
-
-static void
-midori_view_item_meta_data_changed (KatzeItem* item,
- const gchar* key,
- MidoriView* view);
-
-static void
-_midori_view_set_settings (MidoriView* view,
- MidoriWebSettings* settings);
-
-#ifdef HAVE_WEBKIT2
-static void
-midori_view_uri_scheme_res (WebKitURISchemeRequest* request,
- gpointer user_data);
-
-static void
-midori_view_download_started_cb (WebKitWebContext* context,
- WebKitDownload* download,
- MidoriView * view);
-static gboolean
-midori_view_download_query_action (MidoriView* view,
- WebKitDownload* download,
- const gchar * suggested_filename );
-#endif
-
-static gboolean
-midori_view_display_error (MidoriView* view,
- const gchar* uri,
- const gchar* error_icon,
- const gchar* title,
- const gchar* message,
- const gchar* description,
- const gchar* suggestions,
- const gchar* try_again,
-#ifndef HAVE_WEBKIT2
- WebKitWebFrame* web_frame);
-#else
- void* web_frame);
-#endif
-
-struct _MidoriView
-{
- MidoriTab parent_instance;
-
- gchar* title;
- GdkPixbuf* icon;
- gchar* icon_uri;
- gboolean minimized;
- WebKitHitTestResult* hit_test;
- gchar* link_uri;
- gboolean button_press_handled;
- gboolean has_selection;
- gchar* selected_text;
- MidoriWebSettings* settings;
- GtkWidget* web_view;
- KatzeArray* news_feeds;
-
- gboolean open_tabs_in_the_background;
- MidoriNewPage open_new_pages_in;
- gint find_links;
- gint alerts;
-
- GtkWidget* tab_label;
- GtkWidget* menu_item;
- PangoEllipsizeMode ellipsize;
- KatzeItem* item;
- gint scrollh, scrollv;
- GtkWidget* scrolled_window;
-
- #if GTK_CHECK_VERSION (3, 2, 0)
- GtkWidget* overlay;
- GtkWidget* overlay_label;
- GtkWidget* overlay_find;
- #endif
-};
-
-struct _MidoriViewClass
-{
- MidoriTabClass parent_class;
-};
-
-G_DEFINE_TYPE (MidoriView, midori_view, MIDORI_TYPE_TAB);
-
-enum
-{
- PROP_0,
-
- PROP_TITLE,
- PROP_ICON,
- PROP_MINIMIZED,
- PROP_ZOOM_LEVEL,
- PROP_NEWS_FEEDS,
- PROP_SETTINGS
-};
-
-enum {
- NEW_TAB,
- NEW_WINDOW,
- NEW_VIEW,
- DOWNLOAD_REQUESTED,
- ADD_BOOKMARK,
- ABOUT_CONTENT,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-midori_view_finalize (GObject* object);
-
-static void
-midori_view_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_view_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-static gboolean
-midori_view_focus_in_event (GtkWidget* widget,
- GdkEventFocus* event);
-
-static void
-midori_view_settings_notify_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- MidoriView* view);
-
-static GObject*
-midori_view_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam* construct_properties);
-
-static void
-midori_view_class_init (MidoriViewClass* class)
-{
- GObjectClass* gobject_class;
- GtkWidgetClass* gtkwidget_class;
- GParamFlags flags;
-
- signals[NEW_TAB] = g_signal_new (
- "new-tab",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- 0,
- NULL,
- midori_cclosure_marshal_VOID__STRING_BOOLEAN,
- G_TYPE_NONE, 2,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN);
-
- signals[NEW_WINDOW] = g_signal_new (
- "new-window",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
- /**
- * MidoriView::new-view:
- * @view: the object on which the signal is emitted
- * @new_view: a newly created view
- * @where: where to open the view
- * @user_initiated: %TRUE if the user actively opened the new view
- *
- * Emitted when a new view is created. The value of
- * @where determines where to open the view according
- * to how it was opened and user preferences.
- *
- * Since: 0.1.2
- *
- * Since 0.3.4 a boolean argument was added.
- */
- signals[NEW_VIEW] = g_signal_new (
- "new-view",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- 0,
- NULL,
- midori_cclosure_marshal_VOID__OBJECT_ENUM_BOOLEAN,
- G_TYPE_NONE, 3,
- MIDORI_TYPE_VIEW,
- MIDORI_TYPE_NEW_VIEW,
- G_TYPE_BOOLEAN);
-
- /**
- * MidoriView::download-requested:
- * @view: the object on which the signal is emitted
- * @download: a new download
- *
- * Emitted when a new download is requested, if a
- * file cannot be displayed or a download was started
- * from the context menu.
- *
- * If the download should be accepted, a callback
- * has to return %TRUE, and the download will also
- * be started automatically.
- *
- * Note: This requires WebKitGTK 1.1.3.
- *
- * Return value: %TRUE if the download was handled
- *
- * Since: 0.1.5
- */
- signals[DOWNLOAD_REQUESTED] = g_signal_new (
- "download-requested",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- g_signal_accumulator_true_handled,
- NULL,
- midori_cclosure_marshal_BOOLEAN__OBJECT,
- G_TYPE_BOOLEAN, 1,
- G_TYPE_OBJECT);
-
- /**
- * MidoriView::add-bookmark:
- * @view: the object on which the signal is emitted
- * @uri: the bookmark URI
- *
- * Emitted when a bookmark is added.
- *
- * Deprecated: 0.2.7
- */
- signals[ADD_BOOKMARK] = g_signal_new (
- "add-bookmark",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- 0,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
- /**
- * MidoriView::about-content:
- * @view: the object on which the signal is emitted
- * @uri: the about URI
- *
- * Emitted when loading the about content
- *
- * Return value: the view content as string
- *
- * Since: 0.5.5
- */
- signals[ABOUT_CONTENT] = g_signal_new (
- "about-content",
- G_TYPE_FROM_CLASS (class),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
- 0,
- g_signal_accumulator_true_handled,
- NULL,
- midori_cclosure_marshal_BOOLEAN__STRING,
- G_TYPE_BOOLEAN, 1,
- G_TYPE_STRING);
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->constructor = midori_view_constructor;
- gobject_class->finalize = midori_view_finalize;
- gobject_class->set_property = midori_view_set_property;
- gobject_class->get_property = midori_view_get_property;
-
- gtkwidget_class = GTK_WIDGET_CLASS (class);
- gtkwidget_class->focus_in_event = midori_view_focus_in_event;
-
- flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS;
-
- g_object_class_install_property (gobject_class,
- PROP_TITLE,
- g_param_spec_string (
- "title",
- "Title",
- "The title of the currently loaded page",
- NULL,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_ICON,
- g_param_spec_object (
- "icon",
- "Icon",
- "The icon of the view",
- G_TYPE_ICON,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_ZOOM_LEVEL,
- g_param_spec_float (
- "zoom-level",
- "Zoom Level",
- "The current zoom level",
- G_MINFLOAT,
- G_MAXFLOAT,
- 1.0f,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriView:news-feeds:
- *
- * The news feeds advertised by the currently loaded page.
- *
- * Since: 0.1.7
- */
- g_object_class_install_property (gobject_class,
- PROP_NEWS_FEEDS,
- g_param_spec_object (
- "news-feeds",
- "News Feeds",
- "The list of available news feeds",
- KATZE_TYPE_ARRAY,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_SETTINGS,
- g_param_spec_object (
- "settings",
- "Settings",
- "The associated settings",
- MIDORI_TYPE_WEB_SETTINGS,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-}
-
-static void
-midori_view_set_title (MidoriView* view, const gchar* title)
-{
- const gchar* uri = midori_tab_get_uri (MIDORI_TAB (view));
- katze_assign (view->title, g_strdup (midori_tab_get_display_title (title, uri)));
- view->ellipsize = midori_tab_get_display_ellipsize (view->title, uri);
- if (view->menu_item)
- gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN (
- view->menu_item))), view->title);
- katze_item_set_name (view->item, view->title);
-}
-
-/**
- * midori_view_apply_icon
- * @view: a #MidoriView
- * @icon: (transfer none): the icon to apply, either a #GThemedIcon or a #GdkPixbuf
- * @icon_name: a string corresponding to the icon to apply, or %NULL.
- *
- * Obtains a #GdkPixbuf from the given #GIcon and sets it as @view's icon.
- */
-static void
-midori_view_apply_icon (MidoriView* view,
- GIcon* icon,
- const gchar* icon_name)
-{
- g_return_if_fail (icon != NULL);
-
- GdkPixbuf* pixbuf = NULL;
-
- /* If the GIcon is a GdkPixbuf (since GdkPixbuf implements the GIcon interface), just use it */
- if (GDK_IS_PIXBUF (icon))
- {
- pixbuf = g_object_ref (GDK_PIXBUF (icon));
- }
- else if (G_IS_THEMED_ICON (icon)) /* The icon is a GThemedIcon; we must use a GtkIconTheme to render it */
- {
- GtkIconTheme* icon_theme;
- GtkIconInfo* icon_info;
- gchar** icon_names = NULL;
- GError* error = NULL;
-
- icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (view)));
- g_object_get (icon, "names", &icon_names, NULL);
-
- icon_info =
-#if GTK_CHECK_VERSION (3, 0, 0)
- gtk_icon_theme_choose_icon_for_scale (
-#else
- gtk_icon_theme_choose_icon (
-#endif
- icon_theme,
- (const char **)icon_names,
- 16, /* Favicon-sized */
-#if GTK_CHECK_VERSION (3, 0, 0)
- gtk_widget_get_scale_factor (GTK_WIDGET (view)),
-#endif
- 0);
-
- if (icon_info)
- pixbuf = gtk_icon_info_load_icon (icon_info, &error);
- g_strfreev (icon_names);
- if (pixbuf == NULL) {
- if (error != NULL) {
- g_warning ("Could not load pixbuf for icon '%s': %s\n", icon_name, error->message);
- g_clear_error (&error);
- }
-
- /* view->icon cannot be set to NULL, so we simply leave it as-is */
- return;
- }
-
- gtk_icon_info_free (icon_info);
- }
- else /* The icon is some other implementation of the GIcon interface, which should be impossible
- since this is internal API and its only callers pass GdkPixbufs or GThemedIcons */
- {
- g_warning ("Could not load pixbuf for icon '%s': unknown GIcon implementation", icon_name);
- }
-
- katze_item_set_icon (view->item, icon_name);
- katze_object_assign (view->icon, pixbuf);
- g_object_notify (G_OBJECT (view), "icon");
-
- if (view->menu_item)
- {
- GtkWidget* image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (view->menu_item), image);
- }
-}
-
-/* Resets the view's icon from a WebKit-provided pixbuf for a certain page to a
-generic filetype-based icon */
-static void
-midori_view_unset_icon (MidoriView* view)
-{
- gchar* content_type;
- GIcon* icon;
-
- katze_assign (view->icon_uri, NULL);
-
- content_type = g_content_type_from_mime_type (
- midori_tab_get_mime_type (MIDORI_TAB (view)));
- icon = g_content_type_get_icon (content_type);
- g_free (content_type);
- g_themed_icon_append_name (G_THEMED_ICON (icon), "text-html");
- g_themed_icon_append_name (G_THEMED_ICON (icon), "text-html-symbolic");
-
- midori_view_apply_icon (view, icon, NULL);
-}
-
-/* Sets the view's icon pixbuf to the one WebKit provides for the current page */
-static void
-_midori_web_view_load_icon (MidoriView* view)
-{
- GdkPixbuf* pixbuf = NULL;
- #ifdef HAVE_WEBKIT2
- cairo_surface_t* surface = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (view->web_view));
- if (surface != NULL
- && (pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0,
- cairo_image_surface_get_width (surface),
- cairo_image_surface_get_height (surface))))
- {
- midori_view_apply_icon (view, G_ICON (pixbuf), view->icon_uri);
- }
- #else
- if ((pixbuf = webkit_web_view_try_get_favicon_pixbuf (
- WEBKIT_WEB_VIEW (view->web_view), 0, 0)))
- midori_view_apply_icon (view, G_ICON (pixbuf), view->icon_uri);
- #endif
-}
-
-static void
-midori_view_update_load_status (MidoriView* view,
- MidoriLoadStatus load_status)
-{
- if (midori_tab_get_load_status (MIDORI_TAB (view)) != load_status)
- midori_tab_set_load_status (MIDORI_TAB (view), load_status);
-}
-
-/**
- * midori_view_get_tls_info
- * @view: a #MidoriView
- * @request: a #WebKitNetworkRequest with WebKit1, otherwise %NULL
- * @tls_cert: variable to store the certificate
- * @tls_flags: variable to store the flags
- * @hostname: variable to store the hostname
- *
- * Returns %TRUE if the the host is secure and trustworthy.
- **/
-gboolean
-midori_view_get_tls_info (MidoriView* view,
- void* request,
- GTlsCertificate** tls_cert,
- GTlsCertificateFlags* tls_flags,
- gchar** hostname)
-{
- #ifdef HAVE_WEBKIT2
- WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view);
- *hostname = midori_uri_parse_hostname (webkit_web_view_get_uri (web_view), NULL);
- gboolean success = webkit_web_view_get_tls_info (web_view, tls_cert, tls_flags);
- if (*tls_cert != NULL)
- g_object_ref (*tls_cert);
- return success && *tls_flags == 0;
- #else
- SoupMessage* message = midori_map_get_message (webkit_network_request_get_message (request));
- if (message != NULL)
- {
- SoupURI* uri = soup_message_get_uri (message);
- *hostname = uri ? g_strdup (uri->host) : NULL;
- g_object_get (message, "tls-certificate", tls_cert, "tls-errors", tls_flags, NULL);
- if (soup_message_get_flags (message) & SOUP_MESSAGE_CERTIFICATE_TRUSTED)
- return TRUE;
- return *tls_flags == 0;
- }
- *tls_cert = NULL;
- *tls_flags = 0;
- *hostname = NULL;
- return FALSE;
- #endif
-}
-
-static gboolean
-midori_view_web_view_navigation_decision_cb (WebKitWebView* web_view,
- #ifdef HAVE_WEBKIT2
- WebKitPolicyDecision* decision,
- WebKitPolicyDecisionType decision_type,
- #else
- WebKitWebFrame* web_frame,
- WebKitNetworkRequest* request,
- WebKitWebNavigationAction* action,
- WebKitWebPolicyDecision* decision,
- #endif
- MidoriView* view)
-{
- #ifdef HAVE_WEBKIT2
- if (decision_type == WEBKIT_POLICY_DECISION_TYPE_RESPONSE)
- {
- WebKitURIResponse* response = webkit_response_policy_decision_get_response (
- WEBKIT_RESPONSE_POLICY_DECISION (decision));
- const gchar* mime_type = webkit_uri_response_get_mime_type (response);
- midori_tab_set_mime_type (MIDORI_TAB (view), mime_type);
- katze_item_set_meta_string (view->item, "mime-type", mime_type);
- if (!webkit_web_view_can_show_mime_type (web_view, mime_type))
- {
- webkit_policy_decision_download (decision);
- return TRUE;
- }
- webkit_policy_decision_use (decision);
- return TRUE;
- }
- else if (decision_type == WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION)
- {
- const gchar* uri = webkit_uri_request_get_uri (
- webkit_navigation_policy_decision_get_request (WEBKIT_NAVIGATION_POLICY_DECISION (decision)));
- g_signal_emit (view, signals[NEW_TAB], 0, uri, FALSE);
- webkit_policy_decision_ignore(decision);
- return FALSE;
- }
- else if (decision_type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION)
- {
- }
- else
- {
- g_debug ("Unhandled policy decision type %d", decision_type);
- return FALSE;
- }
-
- WebKitURIRequest * request = webkit_navigation_policy_decision_get_request (WEBKIT_NAVIGATION_POLICY_DECISION (decision));
- const gchar* uri = webkit_uri_request_get_uri (request);
- #else
- const gchar* uri = webkit_network_request_get_uri (request);
- #endif
- if (g_str_has_prefix (uri, "geo:") && strstr (uri, ","))
- {
- gchar* new_uri = sokoke_magic_uri (uri, TRUE, FALSE);
- midori_view_set_uri (view, new_uri);
- g_free (new_uri);
- return TRUE;
- }
- else if (g_str_has_prefix (uri, "data:image/"))
- {
- /* For security reasons, main content served as data: is limited to images
- http://lcamtuf.coredump.cx/switch/ */
- #ifdef HAVE_WEBKIT2
- webkit_policy_decision_ignore (decision);
- #else
- webkit_web_policy_decision_ignore (decision);
- #endif
- return TRUE;
- }
- #ifdef HAVE_GCR
- else if (/* midori_tab_get_special (MIDORI_TAB (view)) && */ !strncmp (uri, "https", 5))
- {
- /* We show an error page if the certificate is invalid.
- If a "special", unverified page loads a form, it must be that page.
- if (webkit_web_navigation_action_get_reason (action) == WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED)
- FIXME: Verify more stricly that this cannot be eg. a simple Reload */
- #ifdef HAVE_WEBKIT2
- if (decision_type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION)
- #else
- if (webkit_web_navigation_action_get_reason (action) == WEBKIT_WEB_NAVIGATION_REASON_RELOAD)
- #endif
- {
- GTlsCertificate* tls_cert;
- GTlsCertificateFlags tls_flags;
- gchar* hostname;
- if (!midori_view_get_tls_info (view, request, &tls_cert, &tls_flags, &hostname)
- && tls_cert != NULL)
- {
- GcrCertificate* gcr_cert;
- GByteArray* der_cert;
-
- g_object_get (tls_cert, "certificate", &der_cert, NULL);
- gcr_cert = gcr_simple_certificate_new (der_cert->data, der_cert->len);
- g_byte_array_unref (der_cert);
- if (hostname && !gcr_trust_is_certificate_pinned (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL))
- {
- GError* error = NULL;
- gcr_trust_add_pinned_certificate (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, &error);
- if (error != NULL)
- {
- gchar* slots = g_strjoinv (" , ", (gchar**)gcr_pkcs11_get_trust_lookup_uris ());
- gchar* title = g_strdup_printf ("Error granting trust: %s", error->message);
- midori_tab_stop_loading (MIDORI_TAB (view));
- midori_view_display_error (view, NULL, NULL, NULL, title, slots, _("Please look at our "
- "<a href=\"http://midori-browser.org/faqs/\" target=\"_blank\">FAQ</a>, section "
- "\"<a href=\"http://midori-browser.org/faqs/#security_features\" target=\"_blank\">"
- "Security Features</a>\", to understand how you can solve this problem."),
- _("Trust this website"), NULL);
- g_free (title);
- g_free (slots);
- g_error_free (error);
- }
- }
- g_object_unref (gcr_cert);
- }
- if (tls_cert != NULL)
- g_object_unref (tls_cert);
- g_free (hostname);
- }
- }
- #endif
-
- if (katze_item_get_meta_integer (view->item, "delay") == MIDORI_DELAY_PENDING_UNDELAY)
- {
- midori_tab_set_special (MIDORI_TAB (view), FALSE);
- katze_item_set_meta_integer (view->item, "delay", MIDORI_DELAY_UNDELAYED);
- }
-
- #ifndef HAVE_WEBKIT2
- /* Remove link labels */
- JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
- gchar* result = sokoke_js_script_eval (js_context,
- "(function (links) {"
- "if (links != undefined && links.length > 0) {"
- " for (var i = links.length - 1; i >= 0; i--) {"
- " var parent = links[i].parentNode;"
- " parent.removeChild(links[i]); } } }) ("
- "document.getElementsByClassName ('midoriHKD87346'));",
- NULL);
- g_free (result);
- result = sokoke_js_script_eval (js_context,
- "(function (links) {"
- "if (links != undefined && links.length > 0) {"
- " for (var i = links.length - 1; i >= 0; i--) {"
- " var parent = links[i].parentNode;"
- " parent.removeChild(links[i]); } } }) ("
- "document.getElementsByClassName ('midori_access_key_fc04de'));",
- NULL);
- g_free (result);
- view->find_links = -1;
- #endif
-
- gboolean handled = FALSE;
- g_signal_emit_by_name (view, "navigation-requested", uri, &handled);
- if (handled)
- {
- #ifdef HAVE_WEBKIT2
- webkit_policy_decision_ignore (decision);
- #else
- webkit_web_policy_decision_ignore (decision);
- #endif
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-midori_view_load_started (MidoriView* view)
-{
- midori_view_update_load_status (view, MIDORI_LOAD_PROVISIONAL);
- midori_tab_set_progress (MIDORI_TAB (view), 0.0);
- midori_tab_set_load_error (MIDORI_TAB (view), MIDORI_LOAD_ERROR_NONE);
-}
-
-#ifdef HAVE_GCR
-const gchar*
-midori_location_action_tls_flags_to_string (GTlsCertificateFlags flags);
-#endif
-
-static void
-midori_view_load_committed (MidoriView* view)
-{
- GList* children = gtk_container_get_children (GTK_CONTAINER (view));
- for (; children; children = g_list_next (children))
- if (g_object_get_data (G_OBJECT (children->data), "midori-infobar-cb"))
- gtk_widget_destroy (children->data);
- g_list_free (children);
- view->alerts = 0;
-
- const gchar* uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (view->web_view));
- if (g_strcmp0 (uri, katze_item_get_uri (view->item)))
- {
- midori_tab_set_uri (MIDORI_TAB (view), uri);
- katze_item_set_uri (view->item, uri);
- midori_tab_set_special (MIDORI_TAB (view), FALSE);
- }
-
- katze_item_set_added (view->item, time (NULL));
- g_object_set (view, "title", NULL, NULL);
- midori_view_unset_icon (view);
-
- if (!strncmp (uri, "https", 5))
- {
- #ifdef HAVE_WEBKIT2
- void* request = NULL;
- #else
- WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
- WebKitWebDataSource* source = webkit_web_frame_get_data_source (web_frame);
- WebKitNetworkRequest* request = webkit_web_data_source_get_request (source);
- #endif
- GTlsCertificate* tls_cert;
- GTlsCertificateFlags tls_flags;
- gchar* hostname;
- if (midori_view_get_tls_info (view, request, &tls_cert, &tls_flags, &hostname))
- midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_TRUSTED);
- #ifdef HAVE_GCR
- else if (!midori_tab_get_special (MIDORI_TAB (view)) && tls_cert != NULL)
- {
- GcrCertificate* gcr_cert;
- GByteArray* der_cert;
-
- g_object_get (tls_cert, "certificate", &der_cert, NULL);
- gcr_cert = gcr_simple_certificate_new (der_cert->data, der_cert->len);
- g_byte_array_unref (der_cert);
- if (gcr_trust_is_certificate_pinned (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL))
- midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_TRUSTED);
- else
- {
- midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_UNKNOWN);
- midori_tab_stop_loading (MIDORI_TAB (view));
- midori_view_display_error (view, NULL, NULL, NULL, _("Security unknown"),
- midori_location_action_tls_flags_to_string (tls_flags), NULL,
- _("Trust this website"),
- NULL);
- }
- g_object_unref (gcr_cert);
- }
- #endif
- else
- midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_UNKNOWN);
- #ifdef HAVE_GCR
- if (tls_cert != NULL)
- g_object_unref (tls_cert);
- g_free (hostname);
- #endif
- }
- else
- midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_NONE);
-
- view->find_links = -1;
-
- midori_view_update_load_status (view, MIDORI_LOAD_COMMITTED);
-
-}
-
-static void
-webkit_web_view_progress_changed_cb (WebKitWebView* web_view,
- GParamSpec* pspec,
- MidoriView* view)
-{
- gdouble progress = 1.0;
- g_object_get (web_view, pspec->name, &progress, NULL);
- midori_tab_set_progress (MIDORI_TAB (view), progress);
-}
-
-#ifdef HAVE_WEBKIT2
-static void
-midori_view_uri_scheme_res (WebKitURISchemeRequest* request,
- gpointer user_data)
-{
- const gchar* uri = webkit_uri_scheme_request_get_uri (request);
- WebKitWebView* web_view = webkit_uri_scheme_request_get_web_view (request);
- MidoriView* view = midori_view_get_for_widget (GTK_WIDGET (web_view));
-#else
-static void
-midori_view_web_view_resource_request_cb (WebKitWebView* web_view,
- WebKitWebFrame* web_frame,
- WebKitWebResource* web_resource,
- WebKitNetworkRequest* request,
- WebKitNetworkResponse* response,
- MidoriView* view)
-{
- const gchar* uri = webkit_network_request_get_uri (request);
-#endif
-
- /* Only apply custom URIs to special pages for security purposes */
- if (!midori_tab_get_special (MIDORI_TAB (view)))
- return;
-
- if (g_str_has_prefix (uri, "res://"))
- {
- gchar* filepath = midori_paths_get_res_filename (&uri[6]);
- #ifdef HAVE_WEBKIT2
- gchar* contents;
- gsize length;
- if (g_file_get_contents (filepath, &contents, &length, NULL))
- {
- gchar* content_type = g_content_type_guess (filepath, (guchar*)contents, length, NULL);
- gchar* mime_type = g_content_type_get_mime_type (content_type);
- GInputStream* stream = g_memory_input_stream_new_from_data (contents, -1, g_free);
- webkit_uri_scheme_request_finish (request, stream, -1, mime_type);
- g_object_unref (stream);
- g_free (mime_type);
- g_free (content_type);
- }
- #else
- gchar* file_uri = g_filename_to_uri (filepath, NULL, NULL);
- webkit_network_request_set_uri (request, file_uri);
- g_free (file_uri);
- #endif
- g_free (filepath);
- }
- else if (g_str_has_prefix (uri, "stock://"))
- {
- GdkPixbuf* pixbuf;
- const gchar* icon_name = &uri[8] ? &uri[8] : "";
- gint icon_size = GTK_ICON_SIZE_MENU;
- static gint icon_size_large_dialog = 0;
-
- if (!icon_size_large_dialog)
- {
- gint width = 48, height = 48;
- gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &width, &height);
- icon_size_large_dialog = gtk_icon_size_register ("large-dialog", width * 2, height * 2);
- }
-
- if (g_ascii_isalpha (icon_name[0]))
- {
- if (g_str_has_prefix (icon_name, "dialog/"))
- {
- icon_name = &icon_name [strlen("dialog/")];
- icon_size = icon_size_large_dialog;
- }
- else
- icon_size = GTK_ICON_SIZE_BUTTON;
- }
- else if (g_ascii_isdigit (icon_name[0]))
- {
- guint i = 0;
- while (icon_name[i])
- if (icon_name[i++] == '/')
- {
- gchar* size = g_strndup (icon_name, i - 1);
- icon_size = atoi (size);
- /* Compatibility: map pixel to symbolic size */
- if (icon_size == 16)
- icon_size = GTK_ICON_SIZE_MENU;
- g_free (size);
- icon_name = &icon_name[i];
- }
- }
-
- /* Render icon as a PNG at the desired size */
- pixbuf = gtk_widget_render_icon (GTK_WIDGET (view), icon_name, icon_size, NULL);
- if (!pixbuf)
- pixbuf = gtk_widget_render_icon (GTK_WIDGET (view),
- GTK_STOCK_MISSING_IMAGE, icon_size, NULL);
- if (pixbuf)
- {
- gboolean success;
- gchar* buffer;
- gsize buffer_size;
- gchar* encoded;
- gchar* data_uri;
-
- success = gdk_pixbuf_save_to_buffer (pixbuf, &buffer, &buffer_size, "png", NULL, NULL);
- g_object_unref (pixbuf);
- if (!success)
- return;
-
- encoded = g_base64_encode ((guchar*)buffer, buffer_size);
- data_uri = g_strconcat ("data:image/png;base64,", encoded, NULL);
- g_free (encoded);
- #ifdef HAVE_WEBKIT2
- GInputStream* stream = g_memory_input_stream_new_from_data (buffer, buffer_size, g_free);
- webkit_uri_scheme_request_finish (request, stream, -1, "image/png");
- g_object_unref (stream);
- #else
- g_free (buffer);
- webkit_network_request_set_uri (request, data_uri);
- #endif
- g_free (data_uri);
- return;
- }
- }
-}
-
-static void
-midori_view_infobar_response_cb (GtkWidget* infobar,
- gint response,
- gpointer data_object)
-{
- void (*response_cb) (GtkWidget*, gint, gpointer);
- response_cb = g_object_get_data (G_OBJECT (infobar), "midori-infobar-cb");
- if (response_cb != NULL)
- response_cb (infobar, response, data_object);
- gtk_widget_destroy (infobar);
-}
-
-/**
- * midori_view_add_info_bar
- * @view: a #MidoriView
- * @message_type: a #GtkMessageType
- * @message: a message string
- * @response_cb: (scope async): a response callback
- * @user_data: user data passed to the callback
- * @first_button_text: button text or stock ID
- * @...: first response ID, then more text - response ID pairs
- *
- * Adds an infobar (or equivalent) to the view. Activation of a
- * button invokes the specified callback. The infobar is
- * automatically destroyed if the location changes or reloads.
- *
- * Return value: (transfer none): an infobar widget
- *
- * Since: 0.2.9
- **/
-GtkWidget*
-midori_view_add_info_bar (MidoriView* view,
- GtkMessageType message_type,
- const gchar* message,
- GCallback response_cb,
- gpointer data_object,
- const gchar* first_button_text,
- ...)
-{
- GtkWidget* infobar;
- GtkWidget* action_area;
- GtkWidget* content_area;
- GtkWidget* label;
- va_list args;
- const gchar* button_text;
-
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
- g_return_val_if_fail (message != NULL, NULL);
-
- va_start (args, first_button_text);
-
- infobar = gtk_info_bar_new ();
- for (button_text = first_button_text; button_text;
- button_text = va_arg (args, const gchar*))
- {
- gint response_id = va_arg (args, gint);
- gtk_info_bar_add_button (GTK_INFO_BAR (infobar),
- button_text, response_id);
- }
- gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), message_type);
- content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar));
- action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (infobar));
- gtk_orientable_set_orientation (GTK_ORIENTABLE (action_area),
- GTK_ORIENTATION_HORIZONTAL);
- g_signal_connect (infobar, "response",
- G_CALLBACK (midori_view_infobar_response_cb), data_object);
-
- va_end (args);
- label = gtk_label_new (message);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
- gtk_container_add (GTK_CONTAINER (content_area), label);
- gtk_widget_show_all (infobar);
- gtk_box_pack_start (GTK_BOX (view), infobar, FALSE, FALSE, 0);
- gtk_box_reorder_child (GTK_BOX (view), infobar, 0);
- g_object_set_data (G_OBJECT (infobar), "midori-infobar-cb", response_cb);
- if (data_object != NULL)
- g_object_set_data_full (G_OBJECT (infobar), "midori-infobar-da",
- g_object_ref (data_object), g_object_unref);
- return infobar;
-}
-
-#ifdef HAVE_WEBKIT2
-static gboolean
-midori_view_web_view_permission_request_cb (WebKitWebView* web_view,
- WebKitPermissionRequest* decision,
- MidoriView* view)
-{
- /* if (WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST (decision))
- {
- TODO: return TRUE;
- } */
- return FALSE;
-}
-#else
-static void
-midori_view_database_response_cb (GtkWidget* infobar,
- gint response,
- WebKitWebDatabase* database)
-{
- if (response != GTK_RESPONSE_ACCEPT)
- {
- WebKitSecurityOrigin* origin = webkit_web_database_get_security_origin (database);
- webkit_security_origin_set_web_database_quota (origin, 0);
- webkit_web_database_remove (database);
- }
- /* TODO: Remember the decision */
-}
-
-static void
-midori_view_web_view_database_quota_exceeded_cb (WebKitWebView* web_view,
- WebKitWebFrame* web_frame,
- WebKitWebDatabase* database,
- MidoriView* view)
-{
- const gchar* uri = webkit_web_frame_get_uri (web_frame);
- MidoriSiteDataPolicy policy = midori_web_settings_get_site_data_policy (view->settings, uri);
-
- switch (policy)
- {
- case MIDORI_SITE_DATA_BLOCK:
- {
- WebKitSecurityOrigin* origin = webkit_web_database_get_security_origin (database);
- webkit_security_origin_set_web_database_quota (origin, 0);
- webkit_web_database_remove (database);
- }
- case MIDORI_SITE_DATA_ACCEPT:
- case MIDORI_SITE_DATA_PRESERVE:
- return;
- case MIDORI_SITE_DATA_UNDETERMINED:
- {
- gchar* hostname = midori_uri_parse_hostname (uri, NULL);
- gchar* message = g_strdup_printf (_("%s wants to save an HTML5 database."),
- hostname && *hostname ? hostname : uri);
- midori_view_add_info_bar (view, GTK_MESSAGE_QUESTION, message,
- G_CALLBACK (midori_view_database_response_cb), database,
- _("_Deny"), GTK_RESPONSE_REJECT, _("_Allow"), GTK_RESPONSE_ACCEPT,
- NULL);
- g_free (hostname);
- g_free (message);
- }
- }
-}
-
-static void
-midori_view_location_response_cb (GtkWidget* infobar,
- gint response,
- WebKitGeolocationPolicyDecision* decision)
-{
- if (response == GTK_RESPONSE_ACCEPT)
- webkit_geolocation_policy_allow (decision);
- else
- webkit_geolocation_policy_deny (decision);
-}
-
-static gboolean
-midori_view_web_view_geolocation_decision_cb (WebKitWebView* web_view,
- WebKitWebFrame* web_frame,
- WebKitGeolocationPolicyDecision* decision,
- MidoriView* view)
-{
- const gchar* uri = webkit_web_frame_get_uri (web_frame);
- gchar* hostname = midori_uri_parse_hostname (uri, NULL);
- gchar* message = g_strdup_printf (_("%s wants to know your location."),
- hostname && *hostname ? hostname : uri);
- midori_view_add_info_bar (view, GTK_MESSAGE_QUESTION,
- message, G_CALLBACK (midori_view_location_response_cb), decision,
- _("_Deny"), GTK_RESPONSE_REJECT, _("_Allow"), GTK_RESPONSE_ACCEPT,
- NULL);
- g_free (hostname);
- g_free (message);
- return TRUE;
-}
-#endif
-
-void
-midori_view_set_html (MidoriView* view,
- const gchar* data,
- const gchar* uri,
- void* web_frame)
-{
- g_return_if_fail (MIDORI_IS_VIEW (view));
- g_return_if_fail (data != NULL);
-
- WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view);
- if (!uri)
- uri = "about:blank";
-#ifndef HAVE_WEBKIT2
- WebKitWebFrame* main_frame = webkit_web_view_get_main_frame (web_view);
- if (!web_frame)
- web_frame = main_frame;
- if (web_frame == main_frame)
- {
- katze_item_set_uri (view->item, uri);
- midori_tab_set_special (MIDORI_TAB (view), TRUE);
- }
- webkit_web_frame_load_alternate_string (
- web_frame, data, uri, uri);
-#else
- /* XXX: with webkit2 ensure child frames do not set tab URI/special/html */
- katze_item_set_uri (view->item, uri);
- midori_tab_set_special (MIDORI_TAB (view), TRUE);
- webkit_web_view_load_alternate_html (web_view, data, uri, uri);
-#endif
-}
-
-static gboolean
-midori_view_display_error (MidoriView* view,
- const gchar* uri,
- const gchar* error_icon,
- const gchar* title,
- const gchar* message,
- const gchar* description,
- const gchar* suggestions,
- const gchar* try_again,
-#ifndef HAVE_WEBKIT2
- WebKitWebFrame* web_frame)
-#else
- void* web_frame)
-#endif
-{
- gchar* path = midori_paths_get_res_filename ("error.html");
- gchar* template;
-
- if (g_file_get_contents (path, &template, NULL, NULL))
- {
- gchar* title_escaped;
- const gchar* icon;
- gchar* favicon;
- gchar* result;
- gboolean is_main_frame;
-
- #ifdef HAVE_WEBKIT2
- is_main_frame = TRUE;
- #else
- is_main_frame = web_frame && (webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view)) == web_frame);
- #endif
-
- #if !GTK_CHECK_VERSION (3, 0, 0)
- /* g_object_get_valist: object class `GtkSettings' has no property named `gtk-button-images' */
- g_type_class_unref (g_type_class_ref (GTK_TYPE_BUTTON));
- #endif
-
- GtkSettings* gtk_settings = gtk_widget_get_settings (view->web_view);
- gboolean show_button_images = gtk_settings != NULL
- && katze_object_get_boolean (gtk_settings, "gtk-button-images");
- if (uri == NULL)
- uri = midori_tab_get_uri (MIDORI_TAB (view));
- title_escaped = g_markup_escape_text (title ? title : view->title, -1);
- icon = katze_item_get_icon (view->item);
- favicon = icon && !g_str_has_prefix (icon, "stock://")
- ? g_strdup_printf ("<link rel=\"shortcut icon\" href=\"%s\" />", icon) : NULL;
- result = sokoke_replace_variables (template,
- "{dir}", gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL ?
- "rtl" : "ltr",
- "{title}", title_escaped,
- "{favicon}", katze_str_non_null (favicon),
- "{error_icon}", katze_str_non_null (error_icon),
- "{message}", message,
- "{description}", description,
- "{suggestions}", katze_str_non_null (suggestions),
- "{tryagain}", try_again,
- "{uri}", uri,
- "{hide-button-images}", show_button_images ? "" : "display:none",
- "{autofocus}", is_main_frame ? "autofocus=\"true\" " : "",
- NULL);
- g_free (favicon);
- g_free (title_escaped);
- g_free (template);
-
- midori_view_set_html (view, result, uri, web_frame);
-
- g_free (result);
- g_free (path);
-
- return TRUE;
- }
- g_free (path);
-
- return FALSE;
-}
-
-static gboolean
-webkit_web_view_load_error_cb (WebKitWebView* web_view,
-#ifdef HAVE_WEBKIT2
- WebKitLoadEvent load_event,
-#else
- WebKitWebFrame* web_frame,
-#endif
- const gchar* uri,
- GError* error,
- MidoriView* view)
-{
- /*in WebKit2's UIProcess/API/gtk/WebKitLoaderClient.cpp,
- didFailProvisionalLoadWithErrorForFrame early-returns if the frame isn't
- main, so we know that the pertinent frame here is the view's main frame--so
- it's safe for midori_view_display_error to assume it fills in a main frame*/
- #ifdef HAVE_WEBKIT2
- void* web_frame = NULL;
- void* main_frame = NULL;
- #else
- WebKitWebFrame* main_frame = webkit_web_view_get_main_frame (web_view);
- #endif
- gchar* title;
- gchar* message;
- gboolean result;
-
- /* The unholy trinity; also ignored in Webkit's default error handler */
- switch (error->code)
- {
- case WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD:
- /* A plugin will take over. That's expected, it's not fatal. */
- case WEBKIT_NETWORK_ERROR_CANCELLED:
- /* Mostly initiated by JS redirects. */
- case WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE:
- /* A frame load is cancelled because of a download. */
- return FALSE;
- }
-
- if (!g_network_monitor_get_network_available (g_network_monitor_get_default ()))
- {
- title = g_strdup_printf (_("You are not connected to a network"));
- message = g_strdup_printf (_("Your computer must be connected to a network to reach “%s”. "
- "Connect to a wireless access point or attach a network cable and try again."),
- midori_uri_parse_hostname(uri, NULL));
- }
- else if (!g_network_monitor_can_reach (g_network_monitor_get_default (),
- g_network_address_parse_uri ("http://midori-browser.org/", 80, NULL),
- NULL,
- NULL))
- {
- title = g_strdup_printf (_("You are not connected to the Internet"));
- message = g_strdup_printf (_("Your computer appears to be connected to a network, but can't reach “%s”. "
- "Check your network settings and try again."),
- midori_uri_parse_hostname(uri, NULL));
- }
- else
- {
- title = g_strdup_printf (_("Midori can't find the page you're looking for"));
- message = g_strdup_printf (_("The page located at “%s” cannot be found. "
- "Check the web address for misspelled words and try again."),
- midori_uri_parse_hostname(uri, NULL));
- }
-
- result = midori_view_display_error (view, uri, "stock://dialog/network-error", title,
- message, error->message, NULL,
- _("Try Again"), web_frame);
-
- /* if the main frame for the whole tab has a network error, set tab error status */
- if (web_frame == main_frame)
- midori_tab_set_load_error (MIDORI_TAB (view), MIDORI_LOAD_ERROR_NETWORK);
-
- g_free (message);
- g_free (title);
- return result;
-}
-
-static void
-midori_view_apply_scroll_position (MidoriView* view)
-{
- if (view->scrollh > -2)
- {
- if (view->scrollh > 0)
- {
- GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (view->scrolled_window);
- GtkAdjustment* adjustment = gtk_scrolled_window_get_hadjustment (scrolled);
- gtk_adjustment_set_value (adjustment, view->scrollh);
- }
- view->scrollh = -3;
- }
- if (view->scrollv > -2)
- {
- if (view->scrollv > 0)
- {
- GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (view->scrolled_window);
- GtkAdjustment* adjustment = gtk_scrolled_window_get_vadjustment (scrolled);
- gtk_adjustment_set_value (adjustment, view->scrollv);
- }
- view->scrollv = -3;
- }
-}
-
-static void
-midori_view_load_finished (MidoriView* view)
-{
- midori_view_apply_scroll_position (view);
- #ifndef HAVE_WEBKIT2
-
- {
- WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
- JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
- /* Icon: URI, News Feed: $URI|title, Search: :URI|title */
- gchar* value = sokoke_js_script_eval (js_context,
- "(function (l) { var f = new Array (); for (var i in l) "
- "{ var t = l[i].type; var r = l[i].rel; "
- "if (t && (t.indexOf ('rss') != -1 || t.indexOf ('atom') != -1)) "
- "f.push ('$' + l[i].href + '|' + l[i].title);"
- "else if (r == 'search' && t == 'application/opensearchdescription+xml') "
- "f.push (':' + l[i].href + '|' + l[i].title); } "
- "return f; })("
- "document.getElementsByTagName ('link'));", NULL);
-
- /* FIXME: If URI or title contains , parsing will break */
- gchar** items = g_strsplit (value, ",", 0);
- gchar** current_item = items;
- gchar* default_uri = NULL;
-
- if (view->news_feeds != NULL)
- katze_array_clear (view->news_feeds);
- else
- view->news_feeds = katze_array_new (KATZE_TYPE_ITEM);
-
- while (current_item && *current_item)
- {
- const gchar* uri_and_title = *current_item;
- if (uri_and_title[0] == '$')
- {
- const gchar* title;
- gchar* uri;
- KatzeItem* item;
-
- uri_and_title++;
- if (uri_and_title == NULL)
- continue;
- title = strchr (uri_and_title, '|');
- if (title == NULL)
- goto news_feeds_continue;
- title++;
-
- uri = g_strndup (uri_and_title, title - 1 - uri_and_title);
- item = g_object_new (KATZE_TYPE_ITEM,
- "uri", uri, "name", title, NULL);
- katze_array_add_item (view->news_feeds, item);
- g_object_unref (item);
- if (!default_uri)
- default_uri = uri;
- else
- g_free (uri);
- }
- else if (uri_and_title[0] == ':')
- {
- const gchar* title;
-
- uri_and_title++;
- if (uri_and_title == NULL)
- continue;
- title = strchr (uri_and_title, '|');
- if (title == NULL)
- goto news_feeds_continue;
- title++;
- /* TODO: Parse search engine XML
- midori_view_add_info_bar (view, GTK_MESSAGE_INFO, title,
- G_CALLBACK (midori_view_open_search_response_cb), view,
- _("_Save Search engine"), GTK_RESPONSE_ACCEPT, NULL); */
- }
-
- news_feeds_continue:
- current_item++;
- }
- g_strfreev (items);
-
- g_object_set_data_full (G_OBJECT (view), "news-feeds", default_uri, g_free);
- g_free (value);
- }
- #endif
-
- midori_tab_set_progress (MIDORI_TAB (view), 1.0);
- midori_view_update_load_status (view, MIDORI_LOAD_FINISHED);
-}
-
-#ifdef HAVE_WEBKIT2
-static void
-midori_view_web_view_crashed_cb (WebKitWebView* web_view,
- MidoriView* view)
-{
- const gchar* uri = webkit_web_view_get_uri (web_view);
- gchar* title = g_strdup_printf (_("Oops - %s"), uri);
- gchar* message = g_strdup_printf (_("Something went wrong with '%s'."), uri);
- midori_view_display_error (view, uri, NULL, title,
- message, "", NULL, _("Try again"), NULL);
- g_free (message);
- g_free (title);
-}
-
-static void
-midori_view_web_view_load_changed_cb (WebKitWebView* web_view,
- WebKitLoadEvent load_event,
- MidoriView* view)
-{
- g_object_freeze_notify (G_OBJECT (view));
-
- switch (load_event)
- {
- case WEBKIT_LOAD_STARTED:
- midori_view_load_started (view);
- break;
- case WEBKIT_LOAD_REDIRECTED:
- /* Not implemented */
- break;
- case WEBKIT_LOAD_COMMITTED:
- midori_view_load_committed (view);
- break;
- case WEBKIT_LOAD_FINISHED:
- midori_view_load_finished (view);
- break;
- default:
- g_warn_if_reached ();
- }
-
- g_object_thaw_notify (G_OBJECT (view));
-}
-#else
-static void
-midori_view_web_view_notify_load_status_cb (WebKitWebView* web_view,
- GParamSpec* pspec,
- MidoriView* view)
-{
- g_object_freeze_notify (G_OBJECT (view));
-
- switch (webkit_web_view_get_load_status (web_view))
- {
- case WEBKIT_LOAD_PROVISIONAL:
- midori_view_load_started (view);
- break;
- case WEBKIT_LOAD_COMMITTED:
- midori_view_load_committed (view);
- break;
- case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT:
- /* Not implemented */
- break;
- case WEBKIT_LOAD_FINISHED:
- case WEBKIT_LOAD_FAILED:
- midori_view_load_finished (view);
- break;
- default:
- g_warn_if_reached ();
- }
-
- g_object_thaw_notify (G_OBJECT (view));
-}
-#endif
-
-static void
-midori_web_view_notify_icon_uri_cb (WebKitWebView* web_view,
- GParamSpec* pspec,
- MidoriView* view)
-{
-#ifdef HAVE_WEBKIT2
- const gchar* uri = webkit_web_view_get_uri (web_view);
- WebKitWebContext* context = webkit_web_context_get_default ();
- WebKitFaviconDatabase* favicon_database = webkit_web_context_get_favicon_database (context);
- gchar* icon_uri = webkit_favicon_database_get_favicon_uri (favicon_database, uri);
-#else
- gchar* icon_uri = g_strdup (webkit_web_view_get_icon_uri (web_view));
-#endif
- katze_assign (view->icon_uri, icon_uri);
- _midori_web_view_load_icon (view);
-}
-
-static void
-webkit_web_view_notify_title_cb (WebKitWebView* web_view,
- GParamSpec* pspec,
- MidoriView* view)
-{
- const gchar* title = webkit_web_view_get_title (web_view);
- midori_view_set_title (view, title);
- g_object_notify (G_OBJECT (view), "title");
-}
-
-#ifndef HAVE_WEBKIT2
-static void
-webkit_web_view_statusbar_text_changed_cb (WebKitWebView* web_view,
- const gchar* text,
- MidoriView* view)
-{
- midori_tab_set_statusbar_text (MIDORI_TAB (view), text);
-}
-#endif
-
-#if GTK_CHECK_VERSION(3, 2, 0)
-static gboolean
-midori_view_overlay_frame_enter_notify_event_cb (GtkOverlay* overlay,
- GdkEventCrossing* event,
- GtkWidget* frame)
-{
- /* Flip horizontal position of the overlay frame */
- gtk_widget_set_halign (frame,
- gtk_widget_get_halign (frame) == GTK_ALIGN_START
- ? GTK_ALIGN_END : GTK_ALIGN_START);
- return FALSE;
-}
-#endif
-
-static gboolean
-midori_view_web_view_leave_notify_event_cb (WebKitWebView* web_view,
- GdkEventCrossing* event,
- MidoriView* view)
-{
- midori_tab_set_statusbar_text (MIDORI_TAB (view), NULL);
- return FALSE;
-}
-
-static void
-webkit_web_view_hovering_over_link_cb (WebKitWebView* web_view,
- #ifdef HAVE_WEBKIT2
- WebKitHitTestResult* hit_test_result,
- guint modifiers,
- #else
- const gchar* tooltip,
- const gchar* link_uri,
- #endif
- MidoriView* view)
-{
- #ifdef HAVE_WEBKIT2
- katze_object_assign (view->hit_test, g_object_ref (hit_test_result));
- if (!webkit_hit_test_result_context_is_link (hit_test_result))
- {
- katze_assign (view->link_uri, NULL);
- return;
- }
- const gchar* link_uri = webkit_hit_test_result_get_link_uri (hit_test_result);
- #endif
-
- katze_assign (view->link_uri, g_strdup (link_uri));
- if (link_uri && g_str_has_prefix (link_uri, "mailto:"))
- {
- gchar* text = g_strdup_printf (_("Send a message to %s"), &link_uri[7]);
- midori_tab_set_statusbar_text (MIDORI_TAB (view), text);
- g_free (text);
- }
- else
- midori_tab_set_statusbar_text (MIDORI_TAB (view), link_uri);
-}
-
-static gboolean
-midori_view_always_same_tab (const gchar* uri)
-{
- /* No opening in tab, window or app for Javascript or mailto links */
- return g_str_has_prefix (uri, "javascript:") || g_str_has_prefix (uri, "mailto:");
-}
-
-static void
-midori_view_ensure_link_uri (MidoriView* view,
- gint *x,
- gint *y,
- GdkEventButton* event)
-{
-#ifndef HAVE_WEBKIT2
- g_return_if_fail (MIDORI_IS_VIEW (view));
-
- if (gtk_widget_get_window (view->web_view))
- {
-
- if (x != NULL)
- *x = event->x;
- if (y != NULL)
- *y = event->y;
-
- katze_object_assign (view->hit_test,
- g_object_ref (
- webkit_web_view_get_hit_test_result (
- WEBKIT_WEB_VIEW (view->web_view), event)));
- katze_assign (view->link_uri,
- katze_object_get_string (view->hit_test, "link-uri"));
- }
-#endif
-}
-
-#define MIDORI_KEYS_MODIFIER_MASK (GDK_SHIFT_MASK | GDK_CONTROL_MASK \
- | GDK_MOD1_MASK | GDK_META_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK )
-
-static gboolean
-midori_view_web_view_button_press_event_cb (WebKitWebView* web_view,
- GdkEventButton* event,
- MidoriView* view)
-{
- const gchar* link_uri;
- gboolean background;
-
- event->state = event->state & MIDORI_KEYS_MODIFIER_MASK;
- midori_view_ensure_link_uri (view, NULL, NULL, event);
- link_uri = midori_view_get_link_uri (view);
- view->button_press_handled = FALSE;
-
- if (midori_debug ("mouse"))
- g_message ("%s button %d\n", G_STRFUNC, event->button);
-
- switch (event->button)
- {
- case 1:
- if (!link_uri)
- return FALSE;
-
- if (midori_view_always_same_tab (link_uri))
- return FALSE;
-
- if (MIDORI_MOD_NEW_TAB (event->state))
- {
- /* Open link in new tab */
- background = view->open_tabs_in_the_background;
- if (MIDORI_MOD_BACKGROUND (event->state))
- background = !background;
- g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background);
- view->button_press_handled = TRUE;
- return TRUE;
- }
- else if (MIDORI_MOD_NEW_WINDOW (event->state))
- {
- /* Open link in new window */
- g_signal_emit (view, signals[NEW_WINDOW], 0, link_uri);
- view->button_press_handled = TRUE;
- return TRUE;
- }
- break;
- case 2:
- if (link_uri)
- {
- if (midori_view_always_same_tab (link_uri))
- return FALSE;
-
- /* Open link in new tab */
- background = view->open_tabs_in_the_background;
- if (MIDORI_MOD_BACKGROUND (event->state))
- background = !background;
- g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background);
- view->button_press_handled = TRUE;
- return TRUE;
- }
- #if GTK_CHECK_VERSION (3, 4, 0)
- if (katze_object_get_boolean (gtk_widget_get_settings (view->web_view), "gtk-enable-primary-paste"))
- #else
- if (midori_settings_get_middle_click_opens_selection (MIDORI_SETTINGS (view->settings)))
- #endif
- {
- #ifndef HAVE_WEBKIT2
- WebKitHitTestResult* result = webkit_web_view_get_hit_test_result (web_view, event);
- WebKitHitTestResultContext context = katze_object_get_int (result, "context");
- gboolean is_editable = context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
- g_object_unref (result);
- if (!is_editable)
- {
- gchar* uri;
- GtkClipboard* clipboard = gtk_clipboard_get_for_display (
- gtk_widget_get_display (GTK_WIDGET (view)),
- GDK_SELECTION_PRIMARY);
- if ((uri = gtk_clipboard_wait_for_text (clipboard)))
- {
- guint i = 0;
- while (uri[i++] != '\0')
- if (uri[i] == '\n' || uri[i] == '\r')
- uri[i] = ' ';
- g_strstrip (uri);
-
- /* Hold Alt to search for the selected word */
- if (event->state & GDK_MOD1_MASK)
- {
- gchar* new_uri = sokoke_magic_uri (uri, TRUE, FALSE);
- if (!new_uri)
- {
- gchar* search = katze_object_get_string (
- view->settings, "location-entry-search");
- new_uri = midori_uri_for_search (search, uri);
- g_free (search);
- }
- katze_assign (uri, new_uri);
- }
- else if (midori_uri_is_location (uri))
- {
- if (MIDORI_MOD_NEW_TAB (event->state))
- {
- background = view->open_tabs_in_the_background;
- if (MIDORI_MOD_BACKGROUND (event->state))
- background = !background;
- g_signal_emit (view, signals[NEW_TAB], 0, uri, background);
- }
- else
- {
- midori_view_set_uri (MIDORI_VIEW (view), uri);
- gtk_widget_grab_focus (GTK_WIDGET (view));
- }
- g_free (uri);
- view->button_press_handled = TRUE;
- return TRUE;
- }
- else
- {
- g_free (uri);
- }
- }
- }
- #endif
- }
- if (MIDORI_MOD_SCROLL (event->state))
- {
- midori_view_set_zoom_level (MIDORI_VIEW (view), 1.0);
- return FALSE; /* Allow Ctrl + Middle click */
- }
- return FALSE;
- break;
- case 3:
- /* Older versions don't have the context-menu signal */
- #if WEBKIT_CHECK_VERSION (1, 10, 0)
- if (event->state & GDK_CONTROL_MASK)
- #endif
- {
- /* Ctrl + Right-click suppresses javascript button handling */
- GtkWidget* menu = gtk_menu_new ();
- midori_view_populate_popup (view, menu, TRUE);
- katze_widget_popup (GTK_WIDGET (web_view), GTK_MENU (menu), event,
- KATZE_MENU_POSITION_CURSOR);
- view->button_press_handled = TRUE;
- return TRUE;
- }
- break;
-#ifdef G_OS_WIN32
- case 4:
-#else
- case 8:
-#endif
- midori_view_go_back (view);
- view->button_press_handled = TRUE;
- return TRUE;
-#ifdef G_OS_WIN32
- case 5:
-#else
- case 9:
-#endif
- midori_tab_go_forward (MIDORI_TAB (view));
- view->button_press_handled = TRUE;
- return TRUE;
- /*
- * On some fancier mice the scroll wheel can be used to scroll horizontally.
- * A middle click usually registers both a middle click (2) and a
- * horizontal scroll (11 or 12).
- * We catch horizontal scrolls and ignore them to prevent middle clicks from
- * accidentally being interpreted as first button clicks.
- */
- case 11:
- case 12:
- view->button_press_handled = TRUE;
- return TRUE;
- }
-
- /* We propagate the event, since it may otherwise be stuck in WebKit */
- g_signal_emit_by_name (view, "event", event, &background);
- return FALSE;
-}
-
-static gboolean
-midori_view_web_view_button_release_event_cb (WebKitWebView* web_view,
- GdkEventButton* event,
- MidoriView* view)
-{
- gboolean button_press_handled = view->button_press_handled;
- view->button_press_handled = FALSE;
-
- return button_press_handled;
-}
-
-static void
-handle_link_hints (WebKitWebView* web_view,
- GdkEventKey* event,
- MidoriView* view)
-{
-#ifndef HAVE_WEBKIT2
- gint digit = g_ascii_digit_value (event->keyval);
- gunichar uc = gdk_keyval_to_unicode (event->keyval);
- gchar* result = NULL;
- WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (web_view);
- JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
-
- if (view->find_links < 0)
- {
- /* Links are currently off, turn them on */
- midori_tab_inject_stylesheet (MIDORI_TAB (view), ".midoriHKD87346 {"
- " font-size:small !important; font-weight:bold !important;"
- " z-index:500; border-radius:0.3em; line-height:1 !important;"
- " background: white !important; color: black !important;"
- " border:1px solid gray; padding:0 0.1em !important;"
- " position:absolute; display:inline !important; }");
- midori_tab_inject_stylesheet (MIDORI_TAB (view), ".midori_access_key_fc04de {"
- " font-size:small !important; font-weight:bold !important;"
- " z-index:500; border-radius:0.3em; line-height:1 !important;"
- " background: black !important; color: white !important;"
- " border:1px solid gray; padding:0 0.1em 0.2em 0.1em !important;"
- " position:absolute; display:inline !important; }");
- result = sokoke_js_script_eval (js_context,
- " var label_count = 0;"
- " for (i in document.links) {"
- " if (document.links[i].href && document.links[i].insertBefore) {"
- " var child = document.createElement ('span');"
- " if (document.links[i].accessKey && isNaN (document.links[i].accessKey)) {"
- " child.setAttribute ('class', 'midori_access_key_fc04de');"
- " child.appendChild (document.createTextNode (document.links[i].accessKey));"
- " } else {"
- " child.setAttribute ('class', 'midoriHKD87346');"
- " child.appendChild (document.createTextNode (label_count));"
- " label_count++;"
- " }"
- " document.links[i].insertBefore (child); } }",
- NULL);
- view->find_links = 0; /* Links are now on */
- g_free (result);
- return;
- }
-
- if (event->keyval == '.')
- {
- /* Pressed '.' with links on, so turn them off */
- result = sokoke_js_script_eval (js_context,
- "var links = document.getElementsByClassName ('midoriHKD87346');"
- "for (var i = links.length - 1; i >= 0; i--) {"
- " var parent = links[i].parentNode;"
- " parent.removeChild(links[i]); }",
- NULL);
- g_free (result);
- result = sokoke_js_script_eval (js_context,
- "var links = document.getElementsByClassName ('midori_access_key_fc04de');"
- "if (links != undefined && links.length > 0) {"
- " for (var i = links.length - 1; i >= 0; i--) {"
- " var parent = links[i].parentNode;"
- " parent.removeChild(links[i]); } }",
- NULL);
- g_free (result);
- view->find_links = -1;
- return;
- }
-
- /* Links are already on at this point, so process the input character */
-
- if (digit != -1 && event->keyval != GDK_KEY_Return && event->keyval != GDK_KEY_Escape)
- {
- /* Got a digit, add it to the link count/ number */
- if (view->find_links > 0)
- view->find_links *= 10;
- view->find_links += digit;
- return;
- }
-
- if (event->keyval == GDK_KEY_Escape)
- {
- // Clear the link count/number
- view->find_links = 0;
- return;
- }
-
- if (g_unichar_isalpha (uc))
- {
- /* letter pressed if we have a corresponding accessKey and grab URI */
- gchar* script = NULL;
- gchar* utf8 = NULL;
- gulong sz = g_unichar_to_utf8 (uc, NULL);
-
- utf8 = g_malloc0 (sz);
- g_unichar_to_utf8 (uc, utf8);
- script = g_strdup_printf (
- "var l = 'undefined';"
- "for (i in document.links) {"
- " if ( document.links[i].href &&"
- " document.links[i].accessKey == \"%s\" )"
- " {"
- " l = document.links[i].href;"
- " break;"
- " }"
- "}"
- "if (l != 'undefined') { l; }"
- , utf8
- );
- g_free (utf8);
- result = sokoke_js_script_eval (js_context, script, NULL);
- g_free (script);
- }
- else if (event->keyval == GDK_KEY_Return)
- {
- /* Return pressed, grab URI if we have a link with the entered number */
- gchar* script = g_strdup_printf (
- "var links = document.getElementsByClassName ('midoriHKD87346');"
- "var i = %d; var return_key = %d;"
- "if (return_key) {"
- " if (typeof links[i] != 'undefined')"
- " links[i].parentNode.href; }",
- view->find_links, event->keyval == GDK_KEY_Return
- );
- result = sokoke_js_script_eval (js_context, script, NULL);
- g_free (script);
- }
-
- /* Check the URI we grabbed to see if it's valid, if so go there */
- if (midori_uri_is_location (result))
- {
- if (MIDORI_MOD_NEW_TAB (event->state))
- {
- gboolean background = view->open_tabs_in_the_background;
- if (MIDORI_MOD_BACKGROUND (event->state))
- background = !background;
- g_signal_emit (view, signals[NEW_TAB], 0, result, background);
- }
- else
- midori_view_set_uri (view, result);
- view->find_links = -1; /* Turn off link mode */
- }
- else /* Invalid URI, start over... */
- view->find_links = 0;
-
- if (result)
- g_free (result);
- return;
-#endif
-}
-
-static gboolean
-gtk_widget_key_press_event_cb (WebKitWebView* web_view,
- GdkEventKey* event,
- MidoriView* view)
-{
- guint character;
-
- event->state = event->state & MIDORI_KEYS_MODIFIER_MASK;
-
- /* Handle oddities in Russian keyboard layouts */
- if (event->hardware_keycode == ';' || event->hardware_keycode == '=')
- event->keyval = ',';
- else if (event->hardware_keycode == '<')
- event->keyval = '.';
-
- /* Find links by number: . to show links, type number, Return to go */
- if ( event->keyval == '.' || view->find_links > -1 )
- {
- handle_link_hints (web_view, event, view);
- return FALSE;
- }
-
- /* Find inline */
- if (event->keyval == ',' || event->keyval == '/' || event->keyval == GDK_KEY_KP_Divide)
- character = '\0';
- else
- return FALSE;
-
- /* Skip control characters */
- if (character == (event->keyval | 0x01000000))
- return FALSE;
-
- #ifdef HAVE_WEBKIT2
- WebKitHitTestResultContext context = katze_object_get_int (view->hit_test, "context");
- if (!(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE))
- #else
- if (!webkit_web_view_can_cut_clipboard (web_view)
- && !webkit_web_view_can_paste_clipboard (web_view))
- #endif
- {
- gchar* text = character ? g_strdup_printf ("%c", character) : NULL;
- #if GTK_CHECK_VERSION(3, 2, 0)
- midori_findbar_search_text (MIDORI_FINDBAR (view->overlay_find),
- (GtkWidget*)view, TRUE, katze_str_non_null (text));
- #else
- g_signal_emit_by_name (view, "search-text", TRUE, katze_str_non_null (text));
- #endif
- g_free (text);
- return TRUE;
- }
- return FALSE;
-}
-
-static gboolean
-gtk_widget_scroll_event_cb (WebKitWebView* web_view,
- GdkEventScroll* event,
- MidoriView* view)
-{
- event->state = event->state & MIDORI_KEYS_MODIFIER_MASK;
-
- if (MIDORI_MOD_SCROLL (event->state))
- {
- if (event->direction == GDK_SCROLL_DOWN)
- midori_view_set_zoom_level (view,
- midori_view_get_zoom_level (view) - 0.10f);
- else if(event->direction == GDK_SCROLL_UP)
- midori_view_set_zoom_level (view,
- midori_view_get_zoom_level (view) + 0.10f);
- return TRUE;
- }
- else
- return FALSE;
-}
-
-static void
-midori_web_view_menu_new_window_activate_cb (GtkAction* action,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- g_signal_emit (view, signals[NEW_WINDOW], 0, view->link_uri);
-}
-
-static void
-midori_web_view_menu_link_copy_activate_cb (GtkAction* widget,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- if (g_str_has_prefix (view->link_uri, "mailto:"))
- sokoke_widget_copy_clipboard (view->web_view, view->link_uri + 7, NULL, NULL);
- else
- sokoke_widget_copy_clipboard (view->web_view, view->link_uri, NULL, NULL);
-}
-
-static void
-midori_view_download_uri (MidoriView* view,
- MidoriDownloadType type,
- const gchar* uri)
-{
-#ifdef HAVE_WEBKIT2
- WebKitDownload* download = webkit_web_view_download_uri (WEBKIT_WEB_VIEW (view->web_view), uri);
- WebKitWebContext * web_context = webkit_web_view_get_context (WEBKIT_WEB_VIEW (view->web_view));
- midori_download_set_type (download, type);
- g_signal_emit_by_name (web_context, "download-started", download, view);
-#else
- WebKitNetworkRequest* request = webkit_network_request_new (uri);
- WebKitDownload* download = webkit_download_new (request);
- g_object_unref (request);
- midori_download_set_type (download, type);
- gboolean handled;
- g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled);
- #endif
-}
-
-static void
-midori_web_view_menu_save_activate_cb (GtkAction* action,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- midori_view_download_uri (view, MIDORI_DOWNLOAD_SAVE_AS, view->link_uri);
-}
-
-static void
-midori_web_view_menu_image_new_tab_activate_cb (GtkAction* action,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- gchar* uri = katze_object_get_string (view->hit_test, "image-uri");
- if (view->open_new_pages_in == MIDORI_NEW_PAGE_WINDOW)
- g_signal_emit (view, signals[NEW_WINDOW], 0, uri);
- else
- g_signal_emit (view, signals[NEW_TAB], 0, uri,
- view->open_tabs_in_the_background);
- g_free (uri);
-}
-
-/**
- * midori_view_get_resources:
- * @view: a #MidoriView
- *
- * Obtain a list of the resources loaded by the page shown in the view.
- *
- * Return value: (transfer full) (element-type WebKitWebResource): the resources
- **/
-GList*
-midori_view_get_resources (MidoriView* view)
-{
-#ifndef HAVE_WEBKIT2
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view);
- WebKitWebFrame* frame = webkit_web_view_get_main_frame (web_view);
- WebKitWebDataSource* data_source = webkit_web_frame_get_data_source (frame);
- GList* resources = webkit_web_data_source_get_subresources (data_source);
- resources = g_list_prepend (resources, webkit_web_data_source_get_main_resource (data_source));
- g_list_foreach (resources, (GFunc)g_object_ref, NULL);
- return resources;
-#else
- return NULL;
-#endif
-}
-
-static GString*
-midori_view_get_data_for_uri (MidoriView* view,
- const gchar* uri)
-{
- GList* resources = midori_view_get_resources (view);
- GString* result = NULL;
-
-#ifndef HAVE_WEBKIT2
- GList* list;
- for (list = resources; list; list = g_list_next (list))
- {
- WebKitWebResource* resource = WEBKIT_WEB_RESOURCE (list->data);
- GString* data = webkit_web_resource_get_data (resource);
- if (!g_strcmp0 (webkit_web_resource_get_uri (resource), uri))
- {
- result = data;
- break;
- }
- }
-#endif
- g_list_foreach (resources, (GFunc)g_object_unref, NULL);
- g_list_free (resources);
- return result;
-}
-
-static void
-midori_view_clipboard_get_image_cb (GtkClipboard* clipboard,
- GtkSelectionData* selection_data,
- guint info,
- gpointer user_data)
-{
- MidoriView* view = MIDORI_VIEW (g_object_get_data (user_data, "view"));
- WebKitHitTestResult* hit_test = user_data;
- gchar* uri = katze_object_get_string (hit_test, "image-uri");
- GdkAtom target = gtk_selection_data_get_target (selection_data);
- /* if (gtk_selection_data_targets_include_image (selection_data, TRUE)) */
- if (gtk_targets_include_image (&target, 1, TRUE))
- {
- GString* data = midori_view_get_data_for_uri (view, uri);
- if (data != NULL)
- {
- GInputStream* stream = g_memory_input_stream_new_from_data (data->str, data->len, NULL);
- GError* error = NULL;
- GdkPixbuf* pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, &error);
- g_object_unref (stream);
- if (error != NULL)
- {
- g_critical ("Error copying pixbuf: %s\n", error->message);
- g_error_free (error);
- }
- gtk_selection_data_set_pixbuf (selection_data, pixbuf);
- g_object_unref (pixbuf);
- }
- else
- g_warn_if_reached ();
- }
- /* if (gtk_selection_data_targets_include_text (selection_data)) */
- if (gtk_targets_include_text (&target, 1))
- gtk_selection_data_set_text (selection_data, uri, -1);
- g_free (uri);
-}
-
-static void
-midori_web_view_menu_image_copy_activate_cb (GtkAction* action,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- gchar* uri = katze_object_get_string (view->hit_test, "image-uri");
- g_object_set_data (G_OBJECT (view->hit_test), "view", view);
- sokoke_widget_copy_clipboard (view->web_view,
- uri, midori_view_clipboard_get_image_cb, view->hit_test);
- g_free (uri);
-}
-
-static void
-midori_web_view_menu_image_save_activate_cb (GtkAction* action,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- gchar* uri = katze_object_get_string (view->hit_test, "image-uri");
- midori_view_download_uri (view, MIDORI_DOWNLOAD_SAVE_AS, uri);
- g_free (uri);
-}
-
-static void
-midori_web_view_menu_video_copy_activate_cb (GtkAction* action,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- gchar* uri = katze_object_get_string (view->hit_test, "media-uri");
- sokoke_widget_copy_clipboard (view->web_view, uri, NULL, NULL);
- g_free (uri);
-}
-
-static void
-midori_web_view_menu_video_save_activate_cb (GtkAction* action,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- gchar* uri = katze_object_get_string (view->hit_test, "media-uri");
- midori_view_download_uri (view, MIDORI_DOWNLOAD_SAVE_AS, uri);
- g_free (uri);
-}
-
-#ifndef HAVE_WEBKIT2
-static void
-midori_view_menu_open_email_activate_cb (GtkAction* action,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- gchar* data = (gchar*)g_object_get_data (G_OBJECT (action), "uri");
- gchar* uri = g_strconcat ("mailto:", data, NULL);
- gboolean handled = FALSE;
- g_signal_emit_by_name (view, "open-uri", uri, &handled);
- g_free (uri);
-}
-#endif
-
-static void
-midori_view_menu_open_link_tab_activate_cb (GtkAction* action,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- gchar* data = (gchar*)g_object_get_data (G_OBJECT (action), "uri");
- gchar* uri = sokoke_magic_uri (data, TRUE, FALSE);
- if (!uri)
- uri = g_strdup (data);
- g_signal_emit (view, signals[NEW_TAB], 0, uri,
- view->open_tabs_in_the_background);
- g_free (uri);
-}
-
-static void
-midori_web_view_menu_background_tab_activate_cb (GtkAction* action,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- g_signal_emit (view, signals[NEW_TAB], 0, view->link_uri,
- !view->open_tabs_in_the_background);
-}
-
-#ifndef HAVE_WEBKIT2
-static void
-midori_web_view_menu_search_web_activate_cb (GtkAction* action,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- const gchar* search = g_object_get_data (G_OBJECT (action), "search");
- if (search == NULL)
- search = midori_settings_get_location_entry_search (MIDORI_SETTINGS (view->settings));
- gchar* uri = midori_uri_for_search (search, view->selected_text);
-
- if (view->open_new_pages_in == MIDORI_NEW_PAGE_WINDOW)
- g_signal_emit (view, signals[NEW_WINDOW], 0, uri);
- /* FIXME: need a way to override behavior (middle click)
- else if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT)
- midori_view_set_uri (view, uri); */
- else
- g_signal_emit (view, signals[NEW_TAB], 0, uri,
- view->open_tabs_in_the_background);
-
- g_free (uri);
-}
-#endif
-
-static void
-midori_view_tab_label_menu_window_new_cb (GtkAction* action,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- g_signal_emit (view, signals[NEW_WINDOW], 0,
- midori_view_get_display_uri (MIDORI_VIEW (view)));
-}
-
-#ifndef HAVE_WEBKIT2
-static void
-midori_web_view_open_frame_in_new_tab_cb (GtkAction* action,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- WebKitWebFrame* web_frame = webkit_web_view_get_focused_frame (WEBKIT_WEB_VIEW (view->web_view));
- g_signal_emit (view, signals[NEW_TAB], 0,
- webkit_web_frame_get_uri (web_frame), view->open_tabs_in_the_background);
-}
-#endif
-
-static void
-midori_view_inspect_element_activate_cb (GtkAction* action,
- gpointer user_data)
-{
- MidoriView* view = user_data;
- WebKitWebInspector* inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (view->web_view));
- #ifndef HAVE_WEBKIT2
- WebKitHitTestResult* hit_test_result = view->hit_test;
- gint x = katze_object_get_int (hit_test_result, "x");
- gint y = katze_object_get_int (hit_test_result, "y");
- webkit_web_inspector_inspect_coordinates (inspector, x, y);
- #endif
- webkit_web_inspector_show (inspector);
-}
-
-static void
-midori_view_add_search_engine_cb (GtkWidget* widget,
- MidoriView* view)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (view->web_view);
- GtkActionGroup* actions = midori_browser_get_action_group (browser);
- GtkAction* action = gtk_action_group_get_action (actions, "Search");
- KatzeItem* item = g_object_get_data (G_OBJECT (widget), "item");
- midori_search_action_get_editor (MIDORI_SEARCH_ACTION (action), item, TRUE);
-}
-
-/**
- * midori_view_get_page_context_action:
- * @view: a #MidoriView
- * @hit_test_result: a #WebKitHitTestResult
- *
- * Populates actions depending on the hit test result.
- *
- * Since: 0.5.5
- */
-MidoriContextAction*
-midori_view_get_page_context_action (MidoriView* view,
- WebKitHitTestResult* hit_test_result)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
- g_return_val_if_fail (hit_test_result != NULL, NULL);
-
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view));
- GdkWindowState state = gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET (browser)));
- WebKitHitTestResultContext context = katze_object_get_int (hit_test_result, "context");
- GtkActionGroup* actions = midori_browser_get_action_group (browser);
- MidoriContextAction* menu = midori_context_action_new ("PageContextMenu", NULL, NULL, NULL);
- midori_context_action_add_action_group (menu, actions);
-
- if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE)
- {
- /* Enforce update of actions - there's no "selection-changed" signal */
- midori_tab_update_actions (MIDORI_TAB (view), actions, NULL, NULL);
- midori_context_action_add_by_name (menu, "Undo");
- midori_context_action_add_by_name (menu, "Redo");
- midori_context_action_add (menu, NULL);
- midori_context_action_add_by_name (menu, "Cut");
- midori_context_action_add_by_name (menu, "Copy");
- midori_context_action_add_by_name (menu, "Paste");
- midori_context_action_add_by_name (menu, "Delete");
- midori_context_action_add (menu, NULL);
- midori_context_action_add_by_name (menu, "SelectAll");
- midori_context_action_add (menu, NULL);
- KatzeItem* item = midori_search_action_get_engine_for_form (
- WEBKIT_WEB_VIEW (view->web_view), view->ellipsize);
- if (item != NULL)
- {
- GtkAction* action = gtk_action_new ("AddSearchEngine", _("Add _search engine..."), NULL, NULL);
- g_object_set_data (G_OBJECT (action), "item", item);
- g_signal_connect (action, "activate",
- G_CALLBACK (midori_view_add_search_engine_cb), view);
- midori_context_action_add (menu, action);
- }
- /* FIXME: input methods */
- /* FIXME: font */
- /* FIXME: insert unicode character */
- }
-
- if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
- {
- if (midori_paths_get_runtime_mode () == MIDORI_RUNTIME_MODE_APP)
- {
- GtkAction* action = gtk_action_new ("OpenLinkTab", _("Open _Link"), NULL, STOCK_TAB_NEW);
- g_object_set_data_full (G_OBJECT (action), "uri", g_strdup (view->link_uri), (GDestroyNotify)g_free);
- g_signal_connect (action, "activate", G_CALLBACK (midori_view_menu_open_link_tab_activate_cb), view);
- midori_context_action_add (menu, action);
- }
- else if (!midori_view_always_same_tab (view->link_uri))
- {
- GtkAction* action = gtk_action_new ("OpenLinkTab", _("Open Link in New _Tab"), NULL, STOCK_TAB_NEW);
- g_object_set_data_full (G_OBJECT (action), "uri", g_strdup (view->link_uri), (GDestroyNotify)g_free);
- g_signal_connect (action, "activate", G_CALLBACK (midori_view_menu_open_link_tab_activate_cb), view);
- midori_context_action_add (menu, action);
- midori_context_action_add_simple (menu, "OpenLinkForegroundTab",
- view->open_tabs_in_the_background
- ? _("Open Link in _Foreground Tab") : _("Open Link in _Background Tab"), NULL, NULL,
- midori_web_view_menu_background_tab_activate_cb, view);
- midori_context_action_add_simple (menu, "OpenLinkWindow", _("Open Link in New _Window"), NULL, STOCK_WINDOW_NEW,
- midori_web_view_menu_new_window_activate_cb, view);
- }
-
- midori_context_action_add_simple (menu, "CopyLinkDestination", _("Copy Link de_stination"), NULL, NULL,
- midori_web_view_menu_link_copy_activate_cb, view);
-
- if (!midori_view_always_same_tab (view->link_uri))
- {
- /* GTK_STOCK_SAVE_AS is lacking the underline */
- midori_context_action_add_simple (menu, "SaveLinkAs", _("Save _As…"), NULL, GTK_STOCK_SAVE_AS,
- midori_web_view_menu_save_activate_cb, view);
- }
- }
-
- if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE)
- {
- if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
- midori_context_action_add (menu, NULL);
-
- midori_context_action_add_simple (menu, "OpenImageNewTab",
- view->open_new_pages_in == MIDORI_NEW_PAGE_WINDOW
- ? _("Open _Image in New Window") : _("Open _Image in New Tab")
- , NULL, STOCK_TAB_NEW,
- midori_web_view_menu_image_new_tab_activate_cb, view);
- midori_context_action_add_simple (menu, "CopyImage", _("Copy Im_age"), NULL, NULL,
- midori_web_view_menu_image_copy_activate_cb, view);
- midori_context_action_add_simple (menu, "SaveImage", _("Save I_mage"), NULL, GTK_STOCK_SAVE,
- midori_web_view_menu_image_save_activate_cb, view);
- }
-
- if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA)
- {
- midori_context_action_add_simple (menu, "CopyVideoAddress", _("Copy Video _Address"), NULL, NULL,
- midori_web_view_menu_video_copy_activate_cb, view);
- midori_context_action_add_simple (menu, "DownloadVideo", _("Download _Video"), NULL, GTK_STOCK_SAVE,
- midori_web_view_menu_video_save_activate_cb, view);
- }
-
- #ifndef HAVE_WEBKIT2
- if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION)
- {
- if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
- midori_context_action_add (menu, NULL);
-
- /* Ensure view->selected_text */
- midori_view_has_selection (view);
- if (midori_uri_is_valid (view->selected_text))
- {
- /* :// and @ together would mean login credentials */
- if (g_str_has_prefix (view->selected_text, "mailto:")
- || (strchr (view->selected_text, '@') != NULL
- && strstr (view->selected_text, "://") == NULL))
- {
- gchar* text = g_strdup_printf (_("Send a message to %s"), view->selected_text);
- GtkAction* action = (GtkAction*)midori_context_action_new_escaped ("SendMessage", text, NULL, GTK_STOCK_JUMP_TO);
- g_object_set_data_full (G_OBJECT (action), "uri", g_strdup (view->selected_text), (GDestroyNotify)g_free);
- g_signal_connect (action, "activate", G_CALLBACK (midori_view_menu_open_email_activate_cb), view);
- midori_context_action_add (menu, action);
- g_free (text);
- }
- else
- {
- GtkAction* action = gtk_action_new ("OpenAddressInNewTab", _("Open Address in New _Tab"), NULL, GTK_STOCK_JUMP_TO);
- g_object_set_data_full (G_OBJECT (action), "uri", g_strdup (view->selected_text), (GDestroyNotify)g_free);
- g_signal_connect (action, "activate", G_CALLBACK (midori_view_menu_open_link_tab_activate_cb), view);
- midori_context_action_add (menu, action);
- }
- }
-
- KatzeArray* search_engines = katze_object_get_object (browser, "search-engines");
- if (search_engines != NULL)
- {
- MidoriContextAction* searches = midori_context_action_new ("SearchWith", _("Search _with"), NULL, NULL);
- midori_context_action_add (menu, GTK_ACTION (searches));
-
- KatzeItem* item;
- guint i = 0;
- KATZE_ARRAY_FOREACH_ITEM (item, search_engines)
- {
- GdkPixbuf* pixbuf;
- gchar* search_option = g_strdup_printf ("SearchWith%u", i);
- GtkAction* action = (GtkAction*)midori_context_action_new_escaped (search_option, katze_item_get_name (item), NULL, STOCK_EDIT_FIND);
- g_free (search_option);
- midori_context_action_add (searches, action);
- if ((pixbuf = midori_paths_get_icon (katze_item_get_uri (item), NULL)))
- {
- gtk_action_set_gicon (action, G_ICON (pixbuf));
- g_object_unref (pixbuf);
- }
- else
- {
- GIcon* icon = g_themed_icon_new_with_default_fallbacks ("edit-find-option-symbolic");
- gtk_action_set_gicon (action, icon);
- }
- gtk_action_set_always_show_image (GTK_ACTION (action), TRUE);
- g_object_set_data (G_OBJECT (action), "search", (gchar*)katze_item_get_uri (item));
- g_signal_connect (action, "activate",
- G_CALLBACK (midori_web_view_menu_search_web_activate_cb), view);
- i++;
- }
- g_object_unref (search_engines);
- }
- if (midori_settings_get_location_entry_search (MIDORI_SETTINGS (view->settings)) != NULL)
- midori_context_action_add_simple (menu, "SearchWeb", _("_Search the Web"), NULL, GTK_STOCK_FIND,
- midori_web_view_menu_search_web_activate_cb, view);
- }
- #endif
-
- if (context == WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT)
- {
- midori_context_action_add_by_name (menu, "Back");
- midori_context_action_add_by_name (menu, "Forward");
- midori_context_action_add_by_name (menu, "Stop");
- midori_context_action_add_by_name (menu, "Reload");
- }
-
- /* No need to have Copy twice, which is already in the editable menu */
- if (!(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE))
- {
- midori_context_action_add (menu, NULL);
- /* Enforce update of actions - there's no "selection-changed" signal */
- midori_tab_update_actions (MIDORI_TAB (view), actions, NULL, NULL);
- midori_context_action_add_by_name (menu, "Copy");
- midori_context_action_add_by_name (menu, "SelectAll");
- }
-
- if (context == WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT)
- {
- midori_context_action_add (menu, NULL);
- midori_context_action_add_by_name (menu, "UndoTabClose");
- #ifndef HAVE_WEBKIT2
- WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view);
- if (webkit_web_view_get_focused_frame (web_view) != webkit_web_view_get_main_frame (web_view))
- midori_context_action_add_simple (menu, "OpenFrameInNewTab", _("Open _Frame in New Tab"), NULL, NULL,
- midori_web_view_open_frame_in_new_tab_cb, view);
- #endif
- midori_context_action_add_simple (menu, "OpenInNewWindow", _("Open in New _Window"), NULL, STOCK_WINDOW_NEW,
- midori_view_tab_label_menu_window_new_cb, view);
- midori_context_action_add_by_name (menu, "ZoomIn");
- midori_context_action_add_by_name (menu, "ZoomOut");
-
- MidoriContextAction* encodings = midori_context_action_new ("Encoding", _("_Encoding"), NULL, NULL);
- midori_context_action_add (menu, GTK_ACTION (encodings));
- midori_context_action_add_by_name (encodings, "EncodingAutomatic");
- midori_context_action_add_by_name (encodings, "EncodingChinese");
- midori_context_action_add_by_name (encodings, "EncodingChineseSimplified");
- midori_context_action_add_by_name (encodings, "EncodingJapanese");
- midori_context_action_add_by_name (encodings, "EncodingKorean");
- midori_context_action_add_by_name (encodings, "EncodingRussian");
- midori_context_action_add_by_name (encodings, "EncodingUnicode");
- midori_context_action_add_by_name (encodings, "EncodingWestern");
- midori_context_action_add_by_name (encodings, "EncodingCustom");
-
- midori_context_action_add (menu, NULL);
- midori_context_action_add_by_name (menu, "BookmarkAdd");
- midori_context_action_add_by_name (menu, "AddSpeedDial");
- midori_context_action_add_by_name (menu, "SaveAs");
- midori_context_action_add_by_name (menu, "SourceView");
- midori_context_action_add_by_name (menu, "SourceViewDom");
- if (!g_object_get_data (G_OBJECT (browser), "midori-toolbars-visible"))
- midori_context_action_add_by_name (menu, "Navigationbar");
- if (state & GDK_WINDOW_STATE_FULLSCREEN)
- midori_context_action_add_by_name (menu, "Fullscreen");
- }
-
- if (katze_object_get_boolean (view->settings, "enable-developer-extras"))
- midori_context_action_add_simple (menu, "InspectElement", _("Inspect _Element"), NULL, NULL,
- midori_view_inspect_element_activate_cb, view);
-
- g_signal_emit_by_name (view, "context-menu", hit_test_result, menu);
- return menu;
-}
-
-/**
- * midori_view_populate_popup:
- * @view: a #MidoriView
- * @menu: a #GtkMenu
- * @manual: %TRUE if this a manually created popup
- *
- * Populates the given @menu with context menu items
- * according to the position of the mouse pointer. This
- * can be used in situations where a custom hotkey
- * opens the context menu or the default behaviour
- * needs to be intercepted.
- *
- * @manual should usually be %TRUE, except for the
- * case where @menu was created by the #WebKitWebView.
- *
- * Since: 0.2.5
- * Deprecated: 0.5.5: Use midori_view_get_page_context_action().
- */
-void
-midori_view_populate_popup (MidoriView* view,
- GtkWidget* menu,
- gboolean manual)
-{
- g_return_if_fail (MIDORI_IS_VIEW (view));
- g_return_if_fail (GTK_IS_MENU_SHELL (menu));
-
- GdkEvent* event = gtk_get_current_event();
- midori_view_ensure_link_uri (view, NULL, NULL, (GdkEventButton *)event);
- gdk_event_free (event);
- MidoriContextAction* context_action = midori_view_get_page_context_action (view, view->hit_test);
- midori_context_action_create_menu (context_action, GTK_MENU (menu), FALSE);
-}
-
-#if WEBKIT_CHECK_VERSION (1, 10, 0)
-static gboolean
-midori_view_web_view_context_menu_cb (WebKitWebView* web_view,
- #ifdef HAVE_WEBKIT2
- WebKitContextMenu* context_menu,
- GdkEvent* event,
- WebKitHitTestResult* hit_test_result,
- #else
- GtkMenu* default_menu,
- WebKitHitTestResult* hit_test_result,
- gboolean keyboard,
- #endif
- MidoriView* view)
-{
- #ifndef HAVE_WEBKIT2
- GdkEvent* event = gtk_get_current_event();
- midori_view_ensure_link_uri (view, NULL, NULL, (GdkEventButton *)event);
- gdk_event_free (event);
- #endif
- MidoriContextAction* menu = midori_view_get_page_context_action (view, hit_test_result);
- /* Retain specific menu items we can't re-create easily */
- guint guesses = 0, guesses_max = 10; /* Maximum number of spelling suggestions */
- #ifdef HAVE_WEBKIT2
- GList* items = webkit_context_menu_get_items (context_menu), *item, *preserved = NULL;
- for (item = items; item; item = g_list_next (item))
- {
- WebKitContextMenuAction stock_action = webkit_context_menu_item_get_stock_action (item->data);
- if (stock_action == WEBKIT_CONTEXT_MENU_ACTION_SPELLING_GUESS && guesses++ < guesses_max)
- preserved = g_list_append (preserved, g_object_ref (item->data));
- }
- webkit_context_menu_remove_all (context_menu);
- for (item = preserved; item; item = g_list_next (item))
- {
- webkit_context_menu_append (context_menu, item->data);
- g_object_unref (item->data);
- }
- g_list_free (preserved);
- midori_context_action_create_webkit_context_menu (menu, context_menu);
- #else
- GList* items = gtk_container_get_children (GTK_CONTAINER (default_menu)), *item;
- for (item = items; item; item = g_list_next (item))
- {
- /* Private API: Source/WebCore/platform/ContextMenuItem.h */
- int stock_action = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item->data), "webkit-context-menu"));
- const int ContextMenuItemTagSpellingGuess = 30;
- if (stock_action == ContextMenuItemTagSpellingGuess && guesses++ < guesses_max)
- continue;
- else
- gtk_widget_destroy (item->data);
- }
- g_list_free (items);
- midori_context_action_create_menu (menu, default_menu, FALSE);
- #endif
- return FALSE;
-}
-#endif
-
-static gboolean
-midori_view_web_view_close_cb (WebKitWebView* web_view,
- GtkWidget* view)
-{
- midori_browser_close_tab (midori_browser_get_for_widget (view), view);
- return TRUE;
-}
-
-static gboolean
-webkit_web_view_web_view_ready_cb (GtkWidget* web_view,
- MidoriView* view)
-{
- MidoriNewView where = MIDORI_NEW_VIEW_TAB;
- GtkWidget* new_view = GTK_WIDGET (midori_view_get_for_widget (web_view));
-
-#ifdef HAVE_WEBKIT2
- WebKitWindowProperties* features = webkit_web_view_get_window_properties (WEBKIT_WEB_VIEW (web_view));
-#else
- WebKitWebWindowFeatures* features = webkit_web_view_get_window_features (WEBKIT_WEB_VIEW (web_view));
-#endif
- gboolean locationbar_visible, menubar_visible, toolbar_visible;
- gint width, height;
- g_object_get (features,
- "locationbar-visible", &locationbar_visible,
- "menubar-visible", &menubar_visible,
- "toolbar-visible", &toolbar_visible,
- "width", &width,
- "height", &height,
- NULL);
- midori_tab_set_is_dialog (MIDORI_TAB (view),
- !locationbar_visible && !menubar_visible && !toolbar_visible
- && width > 0 && height > 0);
-
- /* Open windows opened by scripts in tabs if they otherwise
- would be replacing the page the user opened. */
- if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT)
- if (!midori_tab_get_is_dialog (MIDORI_TAB (view)))
- return TRUE;
-
- if (view->open_new_pages_in == MIDORI_NEW_PAGE_TAB)
- {
- if (view->open_tabs_in_the_background)
- where = MIDORI_NEW_VIEW_BACKGROUND;
- }
- else if (view->open_new_pages_in == MIDORI_NEW_PAGE_WINDOW)
- where = MIDORI_NEW_VIEW_WINDOW;
-
- gtk_widget_show (new_view);
- g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where, FALSE);
-
- if (midori_tab_get_is_dialog (MIDORI_TAB (view)))
- {
- GtkWidget* toplevel = gtk_widget_get_toplevel (new_view);
- if (width > 0 && height > 0)
- gtk_widget_set_size_request (toplevel, width, height);
-#ifdef HAVE_WEBKIT2
- g_signal_connect (web_view, "close",
- G_CALLBACK (midori_view_web_view_close_cb), new_view);
-#else
- g_signal_connect (web_view, "close-web-view",
- G_CALLBACK (midori_view_web_view_close_cb), new_view);
-#endif
- }
-
- return TRUE;
-}
-
-static GtkWidget*
-webkit_web_view_create_web_view_cb (GtkWidget* web_view,
-#ifndef HAVE_WEBKIT2
- WebKitWebFrame* web_frame,
-#endif
- MidoriView* view)
-{
- MidoriView* new_view;
-
-#ifdef HAVE_WEBKIT2
- const gchar* uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (web_view));
-#else
- const gchar* uri = webkit_web_frame_get_uri (web_frame);
-#endif
- if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT)
- new_view = view;
- else
- {
- KatzeItem* item = katze_item_new ();
- item->uri = g_strdup (uri);
- new_view = (MidoriView*)midori_view_new_from_view (view, item, NULL);
-#ifdef HAVE_WEBKIT2
- g_signal_connect (new_view->web_view, "ready-to-show",
- G_CALLBACK (webkit_web_view_web_view_ready_cb), view);
-#else
- g_signal_connect (new_view->web_view, "web-view-ready",
- G_CALLBACK (webkit_web_view_web_view_ready_cb), view);
-#endif
- }
- g_object_set_data_full (G_OBJECT (new_view), "opener-uri", g_strdup (uri), g_free);
- return new_view->web_view;
-}
-
-#ifndef HAVE_WEBKIT2
-static gboolean
-webkit_web_view_mime_type_decision_cb (GtkWidget* web_view,
- WebKitWebFrame* web_frame,
- WebKitNetworkRequest* request,
- const gchar* mime_type,
- WebKitWebPolicyDecision* decision,
- MidoriView* view)
-{
- /* FIXME: Never download plugins from sub resources */
- if (!strcmp (mime_type, "application/x-shockwave-flash"))
- if (strcmp (midori_tab_get_uri (MIDORI_TAB (view)), webkit_network_request_get_uri (request)))
- return FALSE;
-
- if (webkit_web_view_can_show_mime_type (WEBKIT_WEB_VIEW (web_view), mime_type))
- {
- if (web_frame == webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view)))
- {
- g_warn_if_fail (mime_type != NULL);
- midori_tab_set_mime_type (MIDORI_TAB (view), mime_type);
- katze_item_set_meta_string (view->item, "mime-type", mime_type);
- if (view->icon == NULL)
- midori_view_unset_icon (view);
- }
-
- return FALSE;
- }
-
- g_object_set_data(G_OBJECT (view), "download-mime-type", (gpointer)mime_type);
- webkit_web_policy_decision_download (decision);
- g_object_set_data(G_OBJECT (view), "download-mime-type", NULL);
- return TRUE;
-}
-#endif
-
-gint
-midori_save_dialog (const gchar* title,
- const gchar * hostname,
- const GString* details,
- const gchar *content_type)
-{
- GIcon* icon;
- GtkWidget* image;
- GdkScreen* screen;
- GtkWidget* dialog= NULL;
- GtkIconTheme* icon_theme;
- gint response;
- dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
- _("Open or download file from %s"), hostname);
- icon = g_content_type_get_icon (content_type);
- g_themed_icon_append_name (G_THEMED_ICON (icon), "text-html");
- image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
- gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image);
- g_object_unref (icon);
- gtk_widget_show (image);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s", details->str);
- screen = gtk_widget_get_screen (dialog);
-
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), FALSE);
- if (screen)
- {
- icon_theme = gtk_icon_theme_get_for_screen (screen);
- if (gtk_icon_theme_has_icon (icon_theme, MIDORI_STOCK_TRANSFER))
- gtk_window_set_icon_name (GTK_WINDOW (dialog), MIDORI_STOCK_TRANSFER);
- else
- gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_OPEN);
- }
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- GTK_STOCK_SAVE, MIDORI_DOWNLOAD_SAVE,
- GTK_STOCK_SAVE_AS, MIDORI_DOWNLOAD_SAVE_AS,
- GTK_STOCK_CANCEL, MIDORI_DOWNLOAD_CANCEL,
- GTK_STOCK_OPEN, MIDORI_DOWNLOAD_OPEN,
- NULL);
-
- response = midori_dialog_run (GTK_DIALOG (dialog));
-
- gtk_widget_destroy (dialog);
- if (response == GTK_RESPONSE_DELETE_EVENT)
- response = MIDORI_DOWNLOAD_CANCEL;
- return response;
-}
-
-#ifdef HAVE_WEBKIT2
-static gboolean
-midori_view_download_decide_destination_cb (WebKitDownload* download,
- const gchar * suggested_filename,
- MidoriView* view)
-{
- if(!midori_view_download_query_action (view, download, suggested_filename)) {
- webkit_download_cancel (download);
- }
- return TRUE; //we must return TRUE because we handled the signal
-}
-
-static void
-midori_view_download_started_cb (WebKitWebContext* context,
- WebKitDownload* download,
- MidoriView *view)
-{
- g_signal_connect (download, "decide-destination",
- G_CALLBACK (midori_view_download_decide_destination_cb), view);
-}
-
-static gboolean
-midori_view_download_query_action (MidoriView* view,
- WebKitDownload* download,
- const gchar * suggested_filename)
-{
-#else
-static gboolean
-midori_view_download_requested_cb (GtkWidget* web_view,
- WebKitDownload* download,
- MidoriView* view)
-{
-#endif
- gboolean handled = TRUE;
- gchar* hostname;
- gchar* content_type;
- gchar* description;
- gchar* title;
- gint response;
- GString* details;
- /* Opener may differ from displaying view:
- http://lcamtuf.coredump.cx/fldl/ http://lcamtuf.coredump.cx/switch/ */
- const gchar* opener_uri = g_object_get_data (G_OBJECT (view), "opener-uri");
- hostname = midori_uri_parse_hostname (
- opener_uri ? opener_uri : midori_view_get_display_uri (view), NULL);
-
- #ifdef HAVE_WEBKIT2
- content_type = g_content_type_guess (suggested_filename, NULL ,
- 0 ,NULL);
- if (!content_type)
- content_type = g_strdup ("application/octet-stream");
- midori_download_set_filename (download, g_strdup (suggested_filename));
- #else
- content_type = midori_download_get_content_type (download,
- g_object_get_data (G_OBJECT (view), "download-mime-type"));
- #endif
- description = g_content_type_get_description (content_type);
-
- details = g_string_sized_new (20 * 4);
- #ifdef HAVE_WEBKIT2
- const gchar * suggestion = webkit_uri_response_get_suggested_filename (webkit_download_get_response (download));
- g_string_append_printf (details, _("File Name: %s"),
- suggestion ? suggestion : suggested_filename);
- #else
- g_string_append_printf (details, _("File Name: %s"),
- webkit_download_get_suggested_filename (download));
- #endif
- g_string_append_c (details, '\n');
-
- if (g_strrstr (description, content_type))
- g_string_append_printf (details, _("File Type: '%s'"), content_type);
- else
- g_string_append_printf (details, _("File Type: %s ('%s')"), description, content_type);
- g_string_append_c (details, '\n');
-
- #ifndef HAVE_WEBKIT2
- /* Link Fingerprint */
- /* We look at the original URI because redirection would lose the fragment */
- WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
- WebKitWebDataSource* datasource = webkit_web_frame_get_provisional_data_source (web_frame);
- if (datasource)
- {
- gchar* fingerprint;
- gchar* fplabel;
- WebKitNetworkRequest* original_request = webkit_web_data_source_get_initial_request (datasource);
- const gchar* original_uri = webkit_network_request_get_uri (original_request);
- midori_uri_get_fingerprint (original_uri, &fingerprint, &fplabel);
- if (fplabel && fingerprint)
- {
- WebKitNetworkRequest* request = webkit_download_get_network_request (download);
-
- g_string_append (details, fplabel);
- g_string_append_c (details, ' ');
- g_string_append (details, fingerprint);
- g_string_append_c (details, '\n');
-
- /* Propagate original URI to make it available when the download finishes */
- g_object_set_data_full (G_OBJECT (request), "midori-original-uri",
- g_strdup (original_uri), g_free);
- }
- g_free (fplabel);
- g_free (fingerprint);
-
- }
-
- if (webkit_download_get_total_size (download) > webkit_download_get_current_size (download))
- {
- gchar* total = g_format_size (webkit_download_get_total_size (download));
- g_string_append_printf (details, _("Size: %s"), total);
- g_string_append_c (details, '\n');
- g_free (total);
- }
- #endif
-
- #ifdef HAVE_WEBKIT2
- /* i18n: A file open dialog title, ie. "Open http://fila.com/manual.tgz" */
- title = g_strdup_printf (_("Open %s"), webkit_uri_request_get_uri (webkit_download_get_request (download)));
- #else
- title = g_strdup_printf (_("Open %s"), webkit_download_get_uri (download));
- #endif
- response = midori_save_dialog (title,
- hostname, details, content_type); //We prompt a dialog
- g_free (title);
- g_free (hostname);
- g_free (description);
- g_free (content_type);
- g_string_free (details, TRUE);
- midori_download_set_type (download, response);
- g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled);
- return handled;
-}
-
-#ifndef HAVE_WEBKIT2
-static gboolean
-webkit_web_view_console_message_cb (GtkWidget* web_view,
- const gchar* message,
- guint line,
- const gchar* source_id,
- MidoriView* view)
-{
- if (g_object_get_data (G_OBJECT (webkit_get_default_session ()),
- "pass-through-console"))
- return FALSE;
-
- if (!strncmp (message, "speed_dial-save", 13))
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view));
- MidoriSpeedDial* dial = katze_object_get_object (browser, "speed-dial");
- GError* error = NULL;
- midori_speed_dial_save_message (dial, message, &error);
- if (error != NULL)
- {
- g_critical ("Failed speed dial message: %s\n", error->message);
- g_error_free (error);
- }
- }
- else
- g_signal_emit_by_name (view, "console-message", message, line, source_id);
- return TRUE;
-}
-
-static void
-midori_view_script_response_cb (GtkWidget* infobar,
- gint response,
- MidoriView* view)
-{
- view->alerts--;
-}
-
-static gboolean
-midori_view_web_view_script_alert_cb (GtkWidget* web_view,
- WebKitWebFrame* web_frame,
- const gchar* message,
- MidoriView* view)
-{
- gchar* text;
-
- /* Allow a maximum of 5 alerts */
- if (view->alerts > 4)
- return TRUE;
-
- view->alerts++;
- /* i18n: The text of an infobar for JavaScript alert messages */
- text = g_strdup_printf ("JavaScript: %s", message);
- midori_view_add_info_bar (view, GTK_MESSAGE_WARNING, text,
- G_CALLBACK (midori_view_script_response_cb), view,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
- g_free (text);
- return TRUE;
-}
-
-static gboolean
-midori_view_web_view_print_requested_cb (GtkWidget* web_view,
- WebKitWebFrame* web_frame,
- MidoriView* view)
-{
- midori_view_print (view);
- return TRUE;
-}
-
-static void
-webkit_web_view_window_object_cleared_cb (GtkWidget* web_view,
- WebKitWebFrame* web_frame,
- JSContextRef js_context,
- JSObjectRef js_window,
- MidoriView* view)
-{
- const gchar* page_uri;
-
- page_uri = webkit_web_frame_get_uri (web_frame);
- if (!midori_uri_is_http (page_uri))
- return;
-
- if (midori_paths_get_runtime_mode () == MIDORI_RUNTIME_MODE_PRIVATE)
- {
- /* Mask language, architecture, no plugin list */
- gchar* result = sokoke_js_script_eval (js_context,
- "navigator = { 'appName': 'Netscape',"
- "'appCodeName': 'Mozilla',"
- "'appVersion': '5.0 (X11)',"
- "'userAgent': navigator.userAgent,"
- "'language': 'en-US',"
- "'platform': 'Linux i686',"
- "'cookieEnabled': true,"
- "'javaEnabled': function () { return true; },"
- "'mimeTypes': {},"
- "'plugins': {'refresh': function () { } } };",
- NULL);
- g_free (result);
- }
-}
-
-static void
-midori_view_hadjustment_notify_value_cb (GtkAdjustment* hadjustment,
- GParamSpec* pspec,
- MidoriView* view)
-{
- gint value = (gint)gtk_adjustment_get_value (hadjustment);
- katze_item_set_meta_integer (view->item, "scrollh", value);
-}
-
-static void
-midori_view_notify_hadjustment_cb (MidoriView* view,
- GParamSpec* pspec,
- gpointer data)
-{
- GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (view->scrolled_window);
- GtkAdjustment* hadjustment = gtk_scrolled_window_get_hadjustment (scrolled);
- g_signal_connect (hadjustment, "notify::value",
- G_CALLBACK (midori_view_hadjustment_notify_value_cb), view);
-}
-
-static void
-midori_view_vadjustment_notify_value_cb (GtkAdjustment* vadjustment,
- GParamSpec* pspec,
- MidoriView* view)
-{
- gint value = (gint)gtk_adjustment_get_value (vadjustment);
- katze_item_set_meta_integer (view->item, "scrollv", value);
-}
-
-static void
-midori_view_notify_vadjustment_cb (MidoriView* view,
- GParamSpec* pspec,
- gpointer data)
-{
- GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (view->scrolled_window);
- GtkAdjustment* vadjustment = gtk_scrolled_window_get_vadjustment (scrolled);
- g_signal_connect (vadjustment, "notify::value",
- G_CALLBACK (midori_view_vadjustment_notify_value_cb), view);
-}
-#endif
-
-static void
-midori_view_init (MidoriView* view)
-{
- view->title = NULL;
- view->icon = NULL;
- view->icon_uri = NULL;
- view->hit_test = NULL;
- view->link_uri = NULL;
- view->selected_text = NULL;
- view->news_feeds = NULL;
- view->find_links = -1;
- view->alerts = 0;
-
- view->item = katze_item_new ();
-
- view->scrollh = view->scrollv = -2;
- #ifndef HAVE_WEBKIT2
- /* Adjustments are not created initially, but overwritten later */
- view->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view->scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_NEVER);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view->scrolled_window),
- GTK_SHADOW_NONE);
- g_signal_connect (view->scrolled_window, "notify::hadjustment",
- G_CALLBACK (midori_view_notify_hadjustment_cb), view);
- g_signal_connect (view->scrolled_window, "notify::vadjustment",
- G_CALLBACK (midori_view_notify_vadjustment_cb), view);
- #endif
-
- g_signal_connect (view->item, "meta-data-changed",
- G_CALLBACK (midori_view_item_meta_data_changed), view);
-}
-
-static void
-midori_view_finalize (GObject* object)
-{
- MidoriView* view = MIDORI_VIEW (object);
-
- if (view->settings)
- g_signal_handlers_disconnect_by_func (view->settings,
- midori_view_settings_notify_cb, view);
- g_signal_handlers_disconnect_by_func (view->item,
- midori_view_item_meta_data_changed, view);
-
- katze_assign (view->title, NULL);
- katze_object_assign (view->icon, NULL);
- katze_assign (view->icon_uri, NULL);
-
- katze_assign (view->link_uri, NULL);
- katze_assign (view->selected_text, NULL);
- katze_object_assign (view->news_feeds, NULL);
-
- katze_object_assign (view->settings, NULL);
- katze_object_assign (view->item, NULL);
-
- G_OBJECT_CLASS (midori_view_parent_class)->finalize (object);
-}
-
-static void
-midori_view_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- MidoriView* view = MIDORI_VIEW (object);
-
- switch (prop_id)
- {
- case PROP_TITLE:
- midori_view_set_title (view, g_value_get_string (value));
- break;
- case PROP_MINIMIZED:
- view->minimized = g_value_get_boolean (value);
- g_signal_handlers_block_by_func (view->item,
- midori_view_item_meta_data_changed, view);
- katze_item_set_meta_integer (view->item, "minimized",
- view->minimized ? 1 : -1);
- g_signal_handlers_unblock_by_func (view->item,
- midori_view_item_meta_data_changed, view);
- break;
- case PROP_ZOOM_LEVEL:
- midori_view_set_zoom_level (view, g_value_get_float (value));
- break;
- case PROP_SETTINGS:
- _midori_view_set_settings (view, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_view_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- MidoriView* view = MIDORI_VIEW (object);
-
- switch (prop_id)
- {
- case PROP_TITLE:
- g_value_set_string (value, view->title);
- break;
- case PROP_ICON:
- g_value_set_object (value, view->icon);
- break;
- case PROP_ZOOM_LEVEL:
- g_value_set_float (value, midori_view_get_zoom_level (view));
- break;
- case PROP_NEWS_FEEDS:
- g_value_set_object (value, view->news_feeds);
- break;
- case PROP_SETTINGS:
- g_value_set_object (value, view->settings);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static gboolean
-midori_view_focus_in_event (GtkWidget* widget,
- GdkEventFocus* event)
-{
- /* Always propagate focus to the child web view */
- gtk_widget_grab_focus (midori_view_get_web_view (MIDORI_VIEW (widget)));
- return TRUE;
-}
-
-static void
-_midori_view_set_settings (MidoriView* view,
- MidoriWebSettings* settings)
-{
- gboolean zoom_text_and_images;
- gdouble zoom_level;
-
- if (view->settings)
- g_signal_handlers_disconnect_by_func (view->settings,
- midori_view_settings_notify_cb, view);
-
- katze_object_assign (view->settings, settings);
- if (!settings)
- return;
-
- g_object_ref (settings);
- g_signal_connect (settings, "notify",
- G_CALLBACK (midori_view_settings_notify_cb), view);
-
- g_object_get (view->settings,
- "zoom-level", &zoom_level,
- "zoom-text-and-images", &zoom_text_and_images,
- "open-new-pages-in", &view->open_new_pages_in,
- "open-tabs-in-the-background", &view->open_tabs_in_the_background,
- NULL);
-
- webkit_web_view_set_settings (WEBKIT_WEB_VIEW (view->web_view), (void*)settings);
- #ifndef HAVE_WEBKIT2
- webkit_web_view_set_full_content_zoom (WEBKIT_WEB_VIEW (view->web_view),
- zoom_text_and_images);
- #endif
- midori_view_set_zoom_level (view, zoom_level);
-}
-
-/**
- * midori_view_new_with_title:
- * @title: a title, or %NULL
- * @settings: a #MidoriWebSettings, or %NULL
- * @append: if %TRUE, the view should be appended
- *
- * Creates a new view with the specified parameters that
- * is visible by default.
- *
- * Return value: (transfer full): a new #MidoriView
- *
- * Since: 0.3.0
- * Deprecated: 0.4.3
- **/
-GtkWidget*
-midori_view_new_with_title (const gchar* title,
- MidoriWebSettings* settings,
- gboolean append)
-{
- KatzeItem* item = katze_item_new ();
- item->name = g_strdup (title);
- if (append)
- katze_item_set_meta_integer (item, "append", 1);
- return midori_view_new_with_item (item, settings);
-}
-
-/**
- * midori_view_new_with_item:
- * @item: a #KatzeItem, or %NULL
- * @settings: a #MidoriWebSettings, or %NULL
- *
- * Creates a new view from an item that is visible by default.
- *
- * Return value: (transfer full): a new #MidoriView
- *
- * Since: 0.4.3
- * Deprecated: 0.5.8: Use midori_view_new_from_view instead.
- **/
-GtkWidget*
-midori_view_new_with_item (KatzeItem* item,
- MidoriWebSettings* settings)
-{
- return midori_view_new_from_view (NULL, item, settings);
-}
-
-/**
- * midori_view_new_from_view:
- * @view: a predating, related #MidoriView, or %NULL
- * @item: a #KatzeItem, or %NULL
- * @settings: a #MidoriWebSettings, or %NULL
- *
- * Creates a new view, visible by default.
- *
- * If a @view is specified the returned new view will share
- * its settings and if applicable re-use the rendering process.
- *
- * When @view should be passed:
- * The new one created is a new tab/ window for the old @view
- * A tab was duplicated
- *
- * When @view may be passed:
- * Old and new view belong to the same website or group
- *
- * Don't pass a @view if:
- * The new view is a completely new website
- *
- * The @item may contain title, URI and minimized status and will be copied.
- *
- * Usually @settings should be passed from an existing view or browser.
- *
- * Return value: (transfer full): a new #MidoriView
- *
- * Since: 0.5.8
- **/
-GtkWidget*
-midori_view_new_from_view (MidoriView* related,
- KatzeItem* item,
- MidoriWebSettings* settings)
-{
- MidoriView* view = g_object_new (MIDORI_TYPE_VIEW,
- "related", MIDORI_TAB (related),
- "title", item ? katze_item_get_name (item) : NULL,
- NULL);
- if (!settings && related)
- settings = related->settings;
- if (settings)
- _midori_view_set_settings (view, settings);
- if (item)
- {
- katze_object_assign (view->item, katze_item_copy (item));
- midori_tab_set_minimized (MIDORI_TAB (view),
- katze_item_get_meta_string (view->item, "minimized") != NULL);
- }
- gtk_widget_show ((GtkWidget*)view);
- return (GtkWidget*)view;
-}
-
-static void
-midori_view_settings_notify_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- MidoriView* view)
-{
- const gchar* name;
- GValue value = { 0, };
-
- name = g_intern_string (g_param_spec_get_name (pspec));
- g_value_init (&value, pspec->value_type);
- g_object_get_property (G_OBJECT (view->settings), name, &value);
-
- if (name == g_intern_string ("open-new-pages-in"))
- view->open_new_pages_in = g_value_get_enum (&value);
- #ifndef HAVE_WEBKIT2
- else if (name == g_intern_string ("zoom-text-and-images"))
- {
- if (view->web_view)
- webkit_web_view_set_full_content_zoom (WEBKIT_WEB_VIEW (view->web_view),
- g_value_get_boolean (&value));
- }
- #endif
- else if (name == g_intern_string ("open-tabs-in-the-background"))
- view->open_tabs_in_the_background = g_value_get_boolean (&value);
- else if (name == g_intern_string ("enable-javascript"))
- {
- /* Speed dial is only editable with scripts, so regenerate it */
- if (midori_view_is_blank (view))
- midori_view_reload (view, FALSE);
- }
-
- g_value_unset (&value);
-}
-
-/**
- * midori_view_set_settings:
- * @view: a #MidoriView
- * @settings: a #MidoriWebSettings
- *
- * Assigns a settings instance to the view.
- **/
-void
-midori_view_set_settings (MidoriView* view,
- MidoriWebSettings* settings)
-{
- g_return_if_fail (MIDORI_IS_VIEW (view));
- g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings));
-
- if (view->settings == settings)
- return;
-
- _midori_view_set_settings (view, settings);
- g_object_notify (G_OBJECT (view), "settings");
-}
-
-/**
- * midori_view_load_status:
- * @web_view: a #MidoriView
- *
- * Determines the current loading status of a view. There is no
- * error state, unlike webkit_web_view_get_load_status().
- *
- * Return value: the current #MidoriLoadStatus
- **/
-MidoriLoadStatus
-midori_view_get_load_status (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), MIDORI_LOAD_FINISHED);
-
- return midori_tab_get_load_status (MIDORI_TAB (view));
-}
-
-/**
- * midori_view_get_progress:
- * @view: a #MidoriView
- *
- * Retrieves the current loading progress as
- * a fraction between 0.0 and 1.0.
- *
- * Return value: the current loading progress
- **/
-gdouble
-midori_view_get_progress (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), 0.0);
-
- return midori_tab_get_progress (MIDORI_TAB (view));
-}
-
-#ifndef HAVE_WEBKIT2
-static gboolean
-midori_view_inspector_window_key_press_event_cb (GtkWidget* window,
- GdkEventKey* event,
- gpointer user_data)
-{
- /* Close window on Ctrl+W */
- if (event->keyval == 'w' && (event->state & GDK_CONTROL_MASK))
- gtk_widget_destroy (window);
-
- return FALSE;
-}
-
-static void
-midori_view_web_inspector_construct_window (gpointer inspector,
- WebKitWebView* web_view,
- GtkWidget* inspector_view,
- MidoriView* view)
-{
- gchar* title;
- const gchar* label;
- GtkWidget* window;
- GtkWidget* toplevel;
- const gchar* icon_name;
- GtkIconTheme* icon_theme;
- GdkPixbuf* icon;
- GdkPixbuf* gray_icon;
- #if GTK_CHECK_VERSION (3, 0, 0)
- GtkWidget* scrolled;
- #endif
-
- label = midori_view_get_display_title (view);
- title = g_strdup_printf (_("Inspect page - %s"), label);
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title (GTK_WINDOW (window), title);
- g_free (title);
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
- if (gtk_widget_is_toplevel (toplevel))
- {
- gtk_window_set_screen (GTK_WINDOW (window), gtk_window_get_screen (GTK_WINDOW (toplevel)));
- katze_window_set_sensible_default_size (GTK_WINDOW (window));
- }
-
- /* Attempt to make a gray version of the icon on the fly */
- icon_name = gtk_window_get_icon_name (GTK_WINDOW (toplevel));
- icon_theme = gtk_icon_theme_get_for_screen (
- gtk_widget_get_screen (GTK_WIDGET (view)));
- icon = gtk_icon_theme_load_icon (icon_theme, icon_name, 32,
- GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
- if (icon)
- {
- gray_icon = gdk_pixbuf_copy (icon);
- if (gray_icon)
- {
- gdk_pixbuf_saturate_and_pixelate (gray_icon, gray_icon, 0.1f, FALSE);
- gtk_window_set_icon (GTK_WINDOW (window), gray_icon);
- g_object_unref (gray_icon);
- }
- g_object_unref (icon);
- }
- else
- gtk_window_set_icon_name (GTK_WINDOW (window), icon_name);
- gtk_widget_set_size_request (GTK_WIDGET (inspector_view), 700, 100);
- #if GTK_CHECK_VERSION (3, 0, 0)
- scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (scrolled), inspector_view);
- gtk_container_add (GTK_CONTAINER (window), scrolled);
- gtk_widget_show_all (scrolled);
- #else
- gtk_container_add (GTK_CONTAINER (window), inspector_view);
- gtk_widget_show_all (inspector_view);
- #endif
-
- g_signal_connect (window, "key-press-event",
- G_CALLBACK (midori_view_inspector_window_key_press_event_cb), NULL);
-
- /* FIXME: Update window title with URI */
-}
-
-static WebKitWebView*
-midori_view_web_inspector_inspect_web_view_cb (gpointer inspector,
- WebKitWebView* web_view,
- MidoriView* view)
-{
- GtkWidget* inspector_view = webkit_web_view_new ();
- midori_view_web_inspector_construct_window (inspector,
- web_view, inspector_view, view);
- return WEBKIT_WEB_VIEW (inspector_view);
-}
-
-static gboolean
-midori_view_web_inspector_show_window_cb (WebKitWebInspector* inspector,
- MidoriView* view)
-{
- GtkWidget* inspector_view = GTK_WIDGET (webkit_web_inspector_get_web_view (inspector));
- GtkWidget* window = gtk_widget_get_toplevel (inspector_view);
- if (!window)
- return FALSE;
- if (katze_object_get_boolean (view->settings, "last-inspector-attached"))
- {
- gboolean handled = FALSE;
- g_signal_emit_by_name (inspector, "attach-window", &handled);
- }
- else
- {
- gtk_widget_show (window);
- gtk_window_present (GTK_WINDOW (window));
- }
- return TRUE;
-}
-
-static gboolean
-midori_view_web_inspector_attach_window_cb (gpointer inspector,
- MidoriView* view)
-{
- GtkWidget* inspector_view = GTK_WIDGET (webkit_web_inspector_get_web_view (inspector));
- g_signal_emit_by_name (view, "attach-inspector", inspector_view);
- return TRUE;
-}
-
-/**
- * midori_view_web_inspector_get_own_window:
- * @inspector: the inspector instance
- *
- * Get the widget containing the inspector, generally either a GtkWindow
- * or the container where it is "docked".
- *
- * Return value: (allow-none): the widget containing the inspector, or NULL.
- *
- * Since: 0.5.10
- */
-static GtkWidget*
-midori_view_web_inspector_get_parent (gpointer inspector)
-{
- GtkWidget* inspector_view = GTK_WIDGET (webkit_web_inspector_get_web_view (inspector));
-
- #if defined(HAVE_WEBKIT2) || GTK_CHECK_VERSION (3, 0, 0)
- GtkWidget* scrolled = gtk_widget_get_parent (inspector_view);
- if (!scrolled)
- return NULL;
- return gtk_widget_get_parent (scrolled);
- #else
- return gtk_widget_get_parent (inspector_view);
- #endif
-}
-
-static gboolean
-midori_view_web_inspector_detach_window_cb (gpointer inspector,
- MidoriView* view)
-{
- GtkWidget* inspector_view = GTK_WIDGET (webkit_web_inspector_get_web_view (inspector));
- GtkWidget* parent = midori_view_web_inspector_get_parent (inspector);
-
- if (GTK_IS_WINDOW (parent))
- return FALSE;
-
- gtk_widget_hide (parent);
- g_signal_emit_by_name (view, "detach-inspector", inspector_view);
- midori_view_web_inspector_construct_window (inspector,
- WEBKIT_WEB_VIEW (view->web_view), inspector_view, view);
- return TRUE;
-}
-
-static gboolean
-midori_view_web_inspector_close_window_cb (gpointer inspector,
- MidoriView* view)
-{
- GtkWidget* parent = midori_view_web_inspector_get_parent (inspector);
-
- if (!parent)
- return FALSE;
-
- gtk_widget_hide (parent);
- return TRUE;
-}
-#endif
-
-static GObject*
-midori_view_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam* construct_properties)
-{
- GObject* object = G_OBJECT_CLASS (midori_view_parent_class)->constructor (
- type, n_construct_properties, construct_properties);
- MidoriView* view = MIDORI_VIEW (object);
-
- view->web_view = GTK_WIDGET (midori_tab_get_web_view (MIDORI_TAB (view)));
- g_object_connect (view->web_view,
- #ifdef HAVE_WEBKIT2
- "signal::load-failed",
- webkit_web_view_load_error_cb, view,
- "signal::load-changed",
- midori_view_web_view_load_changed_cb, view,
- "signal::notify::estimated-load-progress",
- webkit_web_view_progress_changed_cb, view,
- "signal::notify::favicon",
- midori_web_view_notify_icon_uri_cb, view,
- "signal::mouse-target-changed",
- webkit_web_view_hovering_over_link_cb, view,
- "signal::decide-policy",
- midori_view_web_view_navigation_decision_cb, view,
- "signal::permission-request",
- midori_view_web_view_permission_request_cb, view,
- "signal::context-menu",
- midori_view_web_view_context_menu_cb, view,
- "signal::create",
- webkit_web_view_create_web_view_cb, view,
- #else
- "signal::notify::load-status",
- midori_view_web_view_notify_load_status_cb, view,
- "signal::notify::progress",
- webkit_web_view_progress_changed_cb, view,
- "signal::script-alert",
- midori_view_web_view_script_alert_cb, view,
- "signal::window-object-cleared",
- webkit_web_view_window_object_cleared_cb, view,
- "signal::create-web-view",
- webkit_web_view_create_web_view_cb, view,
- "signal-after::mime-type-policy-decision-requested",
- webkit_web_view_mime_type_decision_cb, view,
- "signal::print-requested",
- midori_view_web_view_print_requested_cb, view,
- "signal-after::load-error",
- webkit_web_view_load_error_cb, view,
- "signal::navigation-policy-decision-requested",
- midori_view_web_view_navigation_decision_cb, view,
- "signal::resource-request-starting",
- midori_view_web_view_resource_request_cb, view,
- "signal::database-quota-exceeded",
- midori_view_web_view_database_quota_exceeded_cb, view,
- "signal::geolocation-policy-decision-requested",
- midori_view_web_view_geolocation_decision_cb, view,
- "signal::notify::icon-uri",
- midori_web_view_notify_icon_uri_cb, view,
- "signal::hovering-over-link",
- webkit_web_view_hovering_over_link_cb, view,
- "signal::status-bar-text-changed",
- webkit_web_view_statusbar_text_changed_cb, view,
- #if WEBKIT_CHECK_VERSION (1, 10, 0)
- "signal::context-menu",
- midori_view_web_view_context_menu_cb, view,
- #endif
- "signal::console-message",
- webkit_web_view_console_message_cb, view,
- "signal::download-requested",
- midori_view_download_requested_cb, view,
- #endif
-
- "signal::notify::title",
- webkit_web_view_notify_title_cb, view,
- "signal::leave-notify-event",
- midori_view_web_view_leave_notify_event_cb, view,
- "signal::button-press-event",
- midori_view_web_view_button_press_event_cb, view,
- "signal::button-release-event",
- midori_view_web_view_button_release_event_cb, view,
- "signal-after::key-press-event",
- gtk_widget_key_press_event_cb, view,
- "signal::scroll-event",
- gtk_widget_scroll_event_cb, view,
- NULL);
-
- if (view->settings)
- {
- webkit_web_view_set_settings (WEBKIT_WEB_VIEW (view->web_view), (void*)view->settings);
- #ifndef HAVE_WEBKIT2
- webkit_web_view_set_full_content_zoom (WEBKIT_WEB_VIEW (view->web_view),
- katze_object_get_boolean (view->settings, "zoom-text-and-images"));
- #endif
- }
-
- #ifdef HAVE_WEBKIT2
- if (g_signal_lookup ("web-process-crashed", WEBKIT_TYPE_WEB_VIEW))
- g_signal_connect (view->web_view, "web-process-crashed",
- (GCallback)midori_view_web_view_crashed_cb, view);
- view->scrolled_window = view->web_view;
- WebKitWebContext* context = webkit_web_view_get_context (WEBKIT_WEB_VIEW (view->web_view));
- webkit_web_context_register_uri_scheme (context,
- "res", midori_view_uri_scheme_res, NULL, NULL);
- webkit_web_context_register_uri_scheme (context,
- "stock", midori_view_uri_scheme_res, NULL, NULL);
- g_signal_connect (context, "download-started",
- G_CALLBACK (midori_view_download_started_cb), view);
- #endif
-
- #if GTK_CHECK_VERSION(3, 2, 0)
- view->overlay = gtk_overlay_new ();
- gtk_widget_show (view->overlay);
- gtk_container_add (GTK_CONTAINER (view->overlay), view->scrolled_window);
- gtk_box_pack_start (GTK_BOX (view), view->overlay, TRUE, TRUE, 0);
-
- /* Overlays must be created before showing GtkOverlay as of GTK+ 3.2 */
- {
- GtkWidget* frame = gtk_frame_new (NULL);
- gtk_widget_set_no_show_all (frame, TRUE);
- view->overlay_label = gtk_label_new (NULL);
- gtk_widget_show (view->overlay_label);
- gtk_container_add (GTK_CONTAINER (frame), view->overlay_label);
- gtk_widget_set_halign (frame, GTK_ALIGN_START);
- gtk_widget_set_valign (frame, GTK_ALIGN_END);
- gtk_overlay_add_overlay (GTK_OVERLAY (view->overlay), frame);
- /* Enable enter-notify-event signals */
- gtk_widget_add_events (view->overlay, GDK_ENTER_NOTIFY_MASK);
- g_signal_connect (view->overlay, "enter-notify-event",
- G_CALLBACK (midori_view_overlay_frame_enter_notify_event_cb), frame);
- }
- view->overlay_find = g_object_new (MIDORI_TYPE_FINDBAR, NULL);
- gtk_widget_set_halign (view->overlay_find, GTK_ALIGN_END);
- gtk_widget_set_valign (view->overlay_find, GTK_ALIGN_START);
- gtk_overlay_add_overlay (GTK_OVERLAY (view->overlay),
- view->overlay_find);
- gtk_widget_set_no_show_all (view->overlay_find, TRUE);
- #else
- gtk_box_pack_start (GTK_BOX (view), view->scrolled_window, TRUE, TRUE, 0);
- #endif
-
- #ifndef HAVE_WEBKIT2
- gtk_container_add (GTK_CONTAINER (view->scrolled_window), view->web_view);
-
- gpointer inspector = webkit_web_view_get_inspector ((WebKitWebView*)view->web_view);
- g_object_connect (inspector,
- "signal::inspect-web-view",
- midori_view_web_inspector_inspect_web_view_cb, view,
- "signal::show-window",
- midori_view_web_inspector_show_window_cb, view,
- "signal::attach-window",
- midori_view_web_inspector_attach_window_cb, view,
- "signal::detach-window",
- midori_view_web_inspector_detach_window_cb, view,
- "signal::close-window",
- midori_view_web_inspector_close_window_cb, view,
- NULL);
- #endif
- gtk_widget_show_all (view->scrolled_window);
- return object;
-}
-
-static void
-midori_view_add_version (GString* markup,
- gboolean html,
- gchar* text)
-{
- if (html)
- g_string_append (markup, "<tr><td>");
- g_string_append (markup, text);
- if (html)
- g_string_append (markup, "</td></tr>");
- else
- g_string_append_c (markup, '\n');
- g_free (text);
-}
-
-void
-midori_view_list_versions (GString* markup,
- gboolean html)
-{
- midori_view_add_version (markup, html, g_strdup_printf ("%s %s (%s) %s",
- g_get_application_name (), PACKAGE_VERSION, midori_app_get_name (NULL), gdk_get_program_class ()));
- midori_view_add_version (markup, html, g_strdup_printf ("GTK+ %s (%u.%u.%u)\tGlib %s (%u.%u.%u)",
- GTK_VERSION, gtk_major_version, gtk_minor_version, gtk_micro_version,
- GIO_VERSION, glib_major_version, glib_minor_version, glib_micro_version));
-#ifndef HAVE_WEBKIT2
- midori_view_add_version (markup, html, g_strdup_printf ("WebKitGTK+ %s (%u.%u.%u)\tlibSoup %s",
- WEBKIT_VERSION, webkit_major_version (), webkit_minor_version (), webkit_micro_version (),
-#else
- midori_view_add_version (markup, html, g_strdup_printf ("WebKit2GTK+ %s (%u.%u.%u)\tlibSoup %s",
- WEBKIT_VERSION, webkit_get_major_version (), webkit_get_minor_version (), webkit_get_micro_version (),
-#endif
- LIBSOUP_VERSION));
- midori_view_add_version (markup, html, g_strdup_printf ("cairo %s (%s)\tlibnotify %s",
- CAIRO_VERSION_STRING, cairo_version_string (),
- LIBNOTIFY_VERSION));
- midori_view_add_version (markup, html, g_strdup_printf ("gcr %s\tgranite %s",
- GCR_VERSION, GRANITE_VERSION));
-}
-
-#ifdef HAVE_WEBKIT2
-static void
-midori_view_get_plugins_cb (GObject* object,
- GAsyncResult* result,
- MidoriView* view)
-{
- GList* plugins = webkit_web_context_get_plugins_finish (WEBKIT_WEB_CONTEXT (object), result, NULL);
- g_object_set_data (object, "nsplugins", plugins);
- midori_view_reload (view, FALSE);
-}
-#endif
-
-void
-midori_view_list_plugins (MidoriView* view,
- GString* ns_plugins,
- gboolean html)
-{
- if (!midori_web_settings_has_plugin_support ())
- return;
-
- if (html)
- g_string_append (ns_plugins, "<br><h2>Netscape Plugins:</h2>");
- else
- g_string_append_c (ns_plugins, '\n');
-
- #ifdef HAVE_WEBKIT2
- WebKitWebContext* context = webkit_web_context_get_default ();
- GList* plugins = g_object_get_data (G_OBJECT (context), "nsplugins");
- if (plugins == NULL)
- {
- midori_view_add_version (ns_plugins, html, g_strdup ("…"));
- webkit_web_context_get_plugins (context, NULL, (GAsyncReadyCallback)midori_view_get_plugins_cb, view);
- }
- else
- for (; plugins != NULL; plugins = g_list_next (plugins))
- {
- if (!midori_web_settings_skip_plugin (webkit_plugin_get_path (plugins->data)))
- midori_view_add_version (ns_plugins, html, g_strdup_printf ("%s\t%s",
- webkit_plugin_get_name (plugins->data),
- html ? webkit_plugin_get_description (plugins->data) : ""));
- }
- #else
- WebKitWebPluginDatabase* pdb = webkit_get_web_plugin_database ();
- GSList* plugins = webkit_web_plugin_database_get_plugins (pdb);
- GSList* plugin = plugins;
- for (; plugin != NULL; plugin = g_slist_next (plugin))
- {
- if (midori_web_settings_skip_plugin (webkit_web_plugin_get_path (plugin->data)))
- continue;
- midori_view_add_version (ns_plugins, html, g_strdup_printf ("%s\t%s",
- webkit_web_plugin_get_name (plugin->data),
- html ? webkit_web_plugin_get_description (plugin->data) : ""));
- }
- webkit_web_plugin_database_plugins_list_free (plugins);
- #endif
-}
-
-void
-midori_view_list_video_formats (MidoriView* view,
- GString* formats,
- gboolean html)
-{
-#ifndef HAVE_WEBKIT2
- WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
- JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
- gchar* value = sokoke_js_script_eval (js_context,
- "var supported = function (format) { "
- "var video = document.createElement('video');"
- "return !!video.canPlayType && video.canPlayType (format) != 'no' "
- "? 'x' : '&nbsp;&nbsp;'; };"
- "' H264 [' +"
- "supported('video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"') + ']' + "
- "' &nbsp; Ogg Theora [' + "
- "supported('video/ogg; codecs=\"theora, vorbis\"') + ']' + "
- "' &nbsp; WebM [' + "
- "supported('video/webm; codecs=\"vp8, vorbis\"') + ']' "
- "", NULL);
- midori_view_add_version (formats, html, g_strdup_printf ("Video Formats %s", value));
- g_free (value);
-#endif
-}
-
-/**
- * midori_view_set_uri:
- * @view: a #MidoriView
- *
- * Opens the specified URI in the view.
- *
- * Since 0.3.0 a warning is shown if the view is not yet
- * contained in a browser. This is because extensions
- * can't monitor page loading if that happens.
- **/
-void
-midori_view_set_uri (MidoriView* view,
- const gchar* uri)
-{
- g_return_if_fail (MIDORI_IS_VIEW (view));
- g_return_if_fail (uri != NULL);
-
- if (!gtk_widget_get_parent (GTK_WIDGET (view)))
- g_warning ("Calling %s() before adding the view to a browser. This "
- "breaks extensions that monitor page loading.", G_STRFUNC);
-
- midori_uri_recursive_fork_protection (uri, TRUE);
-
- if (!midori_debug ("unarmed"))
- {
- gboolean handled = FALSE;
- if (g_str_has_prefix (uri, "about:"))
- g_signal_emit (view, signals[ABOUT_CONTENT], 0, uri, &handled);
-
- if (handled)
- {
- midori_tab_set_uri (MIDORI_TAB (view), uri);
- midori_tab_set_special (MIDORI_TAB (view), TRUE);
- katze_item_set_meta_integer (view->item, "delay", MIDORI_DELAY_UNDELAYED);
- katze_item_set_uri (view->item, midori_tab_get_uri (MIDORI_TAB (view)));
- return;
- }
-
- if (katze_item_get_meta_integer (view->item, "delay") == MIDORI_DELAY_DELAYED)
- {
- midori_tab_set_uri (MIDORI_TAB (view), uri);
- midori_tab_set_special (MIDORI_TAB (view), TRUE);
- katze_item_set_meta_integer (view->item, "delay", MIDORI_DELAY_PENDING_UNDELAY);
- midori_view_display_error (view, NULL, "stock://dialog/network-idle", NULL,
- _("Page loading delayed:"),
- _("Loading delayed either due to a recent crash or startup preferences."),
- NULL,
- _("Load Page"),
- NULL);
- }
- else if (g_str_has_prefix (uri, "javascript:"))
- {
- gchar* exception = NULL;
- gboolean result = midori_view_execute_script (view, &uri[11], &exception);
- if (!result)
- {
- sokoke_message_dialog (GTK_MESSAGE_ERROR, "javascript:",
- exception, FALSE);
- g_free (exception);
- }
- }
- else
- {
- if (sokoke_external_uri (uri))
- {
- g_signal_emit_by_name (view, "open-uri", uri, &handled);
- if (handled)
- return;
- }
-
- midori_tab_set_uri (MIDORI_TAB (view), uri);
- katze_item_set_uri (view->item, midori_tab_get_uri (MIDORI_TAB (view)));
- katze_assign (view->title, NULL);
- webkit_web_view_load_uri (WEBKIT_WEB_VIEW (view->web_view), uri);
- }
- }
-}
-
-/**
- * midori_view_set_overlay_text:
- * @view: a #MidoriView
- * @text: a URI or text string
- *
- * Show a specified URI or text on top of the view.
- * Has no effect with < GTK+ 3.2.0.
- *
- * Since: 0.4.5
- **/
-void
-midori_view_set_overlay_text (MidoriView* view,
- const gchar* text)
-{
- g_return_if_fail (MIDORI_IS_VIEW (view));
-
- #if GTK_CHECK_VERSION (3, 2, 0)
- if (text == NULL)
- gtk_widget_hide (gtk_widget_get_parent (view->overlay_label));
- else
- {
- gtk_label_set_text (GTK_LABEL (view->overlay_label), text);
- gtk_widget_show (gtk_widget_get_parent (view->overlay_label));
- }
- #endif
-}
-
-/**
- * midori_view_is_blank:
- * @view: a #MidoriView
- *
- * Determines whether the view is currently empty.
- **/
-gboolean
-midori_view_is_blank (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), TRUE);
-
- return midori_tab_is_blank (MIDORI_TAB (view));
-}
-
-/**
- * midori_view_get_icon:
- * @view: a #MidoriView
- *
- * Retrieves the icon of the view, or a default icon. See
- * midori_view_get_icon_uri() if you need to distinguish
- * the origin of an icon.
- *
- * The returned icon is owned by the @view and must not be modified.
- *
- * Return value: (transfer none): a #GdkPixbuf, or %NULL
- **/
-GdkPixbuf*
-midori_view_get_icon (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- return view->icon;
-}
-
-/**
- * midori_view_get_icon_uri:
- * @view: a #MidoriView
- *
- * Retrieves the address of the icon of the view
- * if the loaded website has an icon, otherwise
- * %NULL.
- * Note that if there is no icon uri, midori_view_get_icon()
- * will still return a default icon.
- *
- * The returned string is owned by the @view and must not be freed.
- *
- * Return value: a string, or %NULL
- *
- * Since: 0.2.5
- **/
-const gchar*
-midori_view_get_icon_uri (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- return view->icon_uri;
-}
-
-/**
- * midori_view_get_display_uri:
- * @view: a #MidoriView
- *
- * Retrieves a string that is suitable for displaying.
- *
- * Note that "about:blank" and "about:dial" are represented as "".
- *
- * You can assume that the string is not %NULL.
- *
- * Return value: an URI string
- **/
-const gchar*
-midori_view_get_display_uri (MidoriView* view)
-{
- const gchar* uri;
-
- g_return_val_if_fail (MIDORI_IS_VIEW (view), "");
-
- uri = midori_tab_get_uri (MIDORI_TAB (view));
- /* Something in the stack tends to turn "" into "about:blank".
- Yet for practical purposes we prefer "". */
- if (!strcmp (uri, "about:blank")
- || !strcmp (uri, "about:dial")
- || !strcmp (uri, "about:new")
- || !strcmp (uri, "about:private"))
- return "";
-
- return uri;
-}
-
-/**
- * midori_view_get_display_title:
- * @view: a #MidoriView
- *
- * Retrieves a string that is suitable for displaying
- * as a title. Most of the time this will be the title
- * or the current URI.
- *
- * You can assume that the string is not %NULL.
- *
- * Return value: a title string
- **/
-const gchar*
-midori_view_get_display_title (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), "about:blank");
-
- if (view->title && *view->title)
- return view->title;
- if (midori_view_is_blank (view))
- return _("Blank page");
- return midori_view_get_display_uri (view);
-}
-
-/**
- * midori_view_get_link_uri:
- * @view: a #MidoriView
- *
- * Retrieves the uri of the currently focused link,
- * particularly while the mouse hovers a link or a
- * context menu is being opened.
- *
- * Return value: an URI string, or %NULL if there is no link focussed
- **/
-const gchar*
-midori_view_get_link_uri (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- return view->link_uri;
-}
-
-/**
- * midori_view_has_selection:
- * @view: a #MidoriView
- *
- * Determines whether something in the view is selected.
- *
- * This function returns %FALSE if there is a selection
- * that effectively only consists of whitespace.
- *
- * Return value: %TRUE if effectively there is a selection
- **/
-gboolean
-midori_view_has_selection (MidoriView* view)
-{
-#ifndef HAVE_WEBKIT2
- WebKitDOMDocument* doc;
- WebKitDOMDOMWindow* window;
- WebKitDOMDOMSelection* selection;
- WebKitDOMRange* range;
-
- g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
-
-
- doc = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view->web_view));
- window = webkit_dom_document_get_default_view (doc);
- selection = webkit_dom_dom_window_get_selection (window);
- if (selection == NULL
- || webkit_dom_dom_selection_get_range_count (selection) == 0)
- return FALSE;
-
- range = webkit_dom_dom_selection_get_range_at (selection, 0, NULL);
- if (range == NULL)
- return FALSE;
-
- katze_assign (view->selected_text, webkit_dom_range_get_text (range));
-
- if (view->selected_text && *view->selected_text)
- return TRUE;
- else
- return FALSE;
-#else
- return FALSE;
-#endif
-}
-
-/**
- * midori_view_get_selected_text:
- * @view: a #MidoriView
- *
- * Retrieves the currently selected text.
- *
- * Return value: the selected text, or %NULL
- **/
-const gchar*
-midori_view_get_selected_text (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- if (midori_view_has_selection (view))
- return g_strstrip (view->selected_text);
- return NULL;
-}
-
-/**
- * midori_view_get_proxy_menu_item:
- * @view: a #MidoriView
- *
- * Retrieves a proxy menu item that is typically added to a Window menu
- * and which on activation switches to the right window/ tab.
- *
- * The item is created on the first call and will be updated to reflect
- * changes to the icon and title automatically.
- *
- * The menu item is valid until it is removed from its container.
- *
- * Return value: (transfer none): the proxy #GtkMenuItem
- **/
-GtkWidget*
-midori_view_get_proxy_menu_item (MidoriView* view)
-{
- const gchar* title;
-
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- if (!view->menu_item)
- {
- title = midori_view_get_display_title (view);
- view->menu_item = katze_image_menu_item_new_ellipsized (title);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (view->menu_item),
- gtk_image_new_from_pixbuf (view->icon));
-
- g_signal_connect (view->menu_item, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &view->menu_item);
- }
- return view->menu_item;
-}
-
-/**
- * midori_view_duplicate
- * @view: a #MidoriView
- *
- * Create a new #MidoriView from an existing one by using
- * the item of the old view.
- *
- * Return value: (transfer full): the new #MidoriView
- **/
-GtkWidget*
-midori_view_duplicate (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- MidoriNewView where = MIDORI_NEW_VIEW_TAB;
- GtkWidget* new_view = midori_view_new_with_item (view->item, view->settings);
- g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where, TRUE);
- midori_view_set_uri (MIDORI_VIEW (new_view), midori_tab_get_uri (MIDORI_TAB (view)));
- return new_view;
-}
-
-/**
- * midori_view_get_tab_menu:
- * @view: a #MidoriView
- *
- * Retrieves a menu that is typically shown when right-clicking
- * a tab label or equivalent representation.
- *
- * Return value: (transfer full): a #GtkMenu
- *
- * Since: 0.1.8
- * Deprecated: 0.5.7: Use MidoriNotebook API instead.
- **/
-GtkWidget*
-midori_view_get_tab_menu (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- GtkWidget* notebook = gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET (view)));
- MidoriContextAction* context_action = midori_notebook_get_tab_context_action (MIDORI_NOTEBOOK (notebook), MIDORI_TAB (view));
- GtkMenu* menu = midori_context_action_create_menu (context_action, NULL, FALSE);
- g_object_unref (context_action);
- return GTK_WIDGET (menu);
-}
-
-/**
- * midori_view_get_proxy_tab_label:
- * @view: a #MidoriView
- *
- * Retrieves a proxy tab label that is typically used when
- * adding the view to a notebook.
- *
- * Return value: (transfer none): the proxy #GtkEventBox
- *
- * Deprecated: 0.5.7: Don't use this label.
- **/
-GtkWidget*
-midori_view_get_proxy_tab_label (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- if (!view->tab_label)
- {
- view->tab_label = gtk_label_new ("dummy");
- gtk_widget_show (view->tab_label);
- }
- return view->tab_label;
-}
-
-/**
- * midori_view_get_label_ellipsize:
- * @view: a #MidoriView
- *
- * Determines how labels representing the view should be
- * ellipsized, which is helpful for alternative labels.
- *
- * Return value: how to ellipsize the label
- *
- * Since: 0.1.9
- **/
-PangoEllipsizeMode
-midori_view_get_label_ellipsize (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), PANGO_ELLIPSIZE_END);
-
- return view->ellipsize;
-}
-
-static void
-midori_view_item_meta_data_changed (KatzeItem* item,
- const gchar* key,
- MidoriView* view)
-{
- if (g_str_equal (key, "minimized"))
- g_object_set (view, "minimized",
- katze_item_get_meta_string (item, key) != NULL, NULL);
- else if (g_str_has_prefix (key, "scroll"))
- {
- gint value = katze_item_get_meta_integer (item, key);
- if (view->scrollh == -2 && key[6] == 'h')
- view->scrollh = value > -1 ? value : 0;
- else if (view->scrollv == -2 && key[6] == 'v')
- view->scrollv = value > -1 ? value : 0;
- else
- return;
- }
-}
-
-/**
- * midori_view_get_proxy_item:
- * @view: a #MidoriView
- *
- * Retrieves a proxy item that can be used for bookmark storage as
- * well as session management.
- *
- * The item reflects changes to title (name), URI and MIME type (mime-type).
- *
- * Return value: (transfer none): the proxy #KatzeItem
- **/
-KatzeItem*
-midori_view_get_proxy_item (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- return view->item;
-}
-
-/**
- * midori_view_get_zoom_level:
- * @view: a #MidoriView
- *
- * Determines the current zoom level of the view.
- *
- * Return value: the current zoom level
- **/
-gfloat
-midori_view_get_zoom_level (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), 1.0f);
-
- if (view->web_view != NULL)
- return webkit_web_view_get_zoom_level (WEBKIT_WEB_VIEW (view->web_view));
- return 1.0f;
-}
-
-/**
- * midori_view_set_zoom_level:
- * @view: a #MidoriView
- * @zoom_level: the new zoom level
- *
- * Sets the current zoom level of the view.
- **/
-void
-midori_view_set_zoom_level (MidoriView* view,
- gfloat zoom_level)
-{
- g_return_if_fail (MIDORI_IS_VIEW (view));
-
- webkit_web_view_set_zoom_level (
- WEBKIT_WEB_VIEW (view->web_view), zoom_level);
- g_object_notify (G_OBJECT (view), "zoom-level");
-}
-
-gboolean
-midori_view_can_zoom_in (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
-
- return view->web_view != NULL
- && (katze_object_get_boolean (view->settings, "zoom-text-and-images")
- || !g_str_has_prefix (midori_tab_get_mime_type (MIDORI_TAB (view)), "image/"));
-}
-
-gboolean
-midori_view_can_zoom_out (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
-
- return view->web_view != NULL
- && (katze_object_get_boolean (view->settings, "zoom-text-and-images")
- || !g_str_has_prefix (midori_tab_get_mime_type (MIDORI_TAB (view)), "image/"));
-}
-
-#ifdef HAVE_WEBKIT2
-static void
-midori_web_resource_get_data_cb (WebKitWebResource *resource,
- GAsyncResult *result,
- GOutputStream *output_stream)
-{
- guchar *data;
- gsize data_length;
- GInputStream *input_stream;
- GError *error = NULL;
-
- data = webkit_web_resource_get_data_finish (resource, result, &data_length, &error);
- if (!data) {
- g_printerr ("Failed to save page: %s", error->message);
- g_error_free (error);
- g_object_unref (output_stream);
-
- return;
- }
-
- input_stream = g_memory_input_stream_new_from_data (data, data_length, g_free);
- g_output_stream_splice_async (output_stream, input_stream,
- G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
- G_PRIORITY_DEFAULT,
- NULL, NULL, NULL);
- g_object_unref (input_stream);
- g_object_unref (output_stream);
-}
-
-static void
-midori_web_view_save_main_resource_cb (GFile *file,
- GAsyncResult *result,
- WebKitWebView *view)
-{
- GFileOutputStream *output_stream;
- WebKitWebResource *resource;
- GError *error = NULL;
-
- output_stream = g_file_replace_finish (file, result, &error);
- if (!output_stream) {
- g_printerr ("Failed to save page: %s", error->message);
- g_error_free (error);
- return;
- }
-
- resource = webkit_web_view_get_main_resource (view);
- webkit_web_resource_get_data (resource, NULL,
- (GAsyncReadyCallback)midori_web_resource_get_data_cb,
- output_stream);
-}
-#endif
-
-/**
- * midori_view_save_source:
- * @view: a #MidoriView
- * @uri: an alternative destination URI, or %NULL
- * @outfile: a destination filename, or %NULL
- *
- * Saves the data in the view to disk.
- *
- * Return value: the destination filename
- *
- * Since: 0.4.4
- **/
-gchar*
-midori_view_save_source (MidoriView* view,
- const gchar* uri,
- const gchar* outfile,
- gboolean use_dom)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- if (uri == NULL)
- uri = midori_view_get_display_uri (view);
-
- if (g_str_has_prefix (uri, "file:///"))
- return g_filename_from_uri (uri, NULL, NULL);
-
-#ifndef HAVE_WEBKIT2
- WebKitWebFrame *frame;
- WebKitWebDataSource *data_source;
- const GString *data;
- gchar* unique_filename;
- gint fd;
- FILE* fp;
- size_t ret;
-
- frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
-
- if (use_dom)
- {
- WebKitDOMDocument* doc;
-
- #if WEBKIT_CHECK_VERSION (1, 9, 5)
- doc = webkit_web_frame_get_dom_document (frame);
- #else
- doc = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view->web_view));
- #endif
-
- WebKitDOMElement* root = webkit_dom_document_query_selector (doc, ":root", NULL);
- const gchar* content = webkit_dom_html_element_get_outer_html (WEBKIT_DOM_HTML_ELEMENT (root));
- data = g_string_new (content);
- } else {
- data_source = webkit_web_frame_get_data_source (frame);
- data = webkit_web_data_source_get_data (data_source);
- }
-
- if (!outfile)
- {
- gchar* extension = midori_download_get_extension_for_uri (uri, NULL);
- const gchar* mime_type = midori_tab_get_mime_type (MIDORI_TAB (view));
- unique_filename = g_strdup_printf ("%s/%uXXXXXX%s", midori_paths_get_tmp_dir (),
- g_str_hash (uri), midori_download_fallback_extension (extension, mime_type));
- g_free (extension);
- katze_mkdir_with_parents (midori_paths_get_tmp_dir (), 0700);
- fd = g_mkstemp (unique_filename);
- }
- else
- {
- unique_filename = g_strdup (outfile);
- fd = g_open (unique_filename, O_WRONLY|O_CREAT, 0644);
- }
-
- if (fd != -1)
- {
- if ((fp = fdopen (fd, "w")))
- {
- ret = fwrite (data ? data->str : "", 1, data ? data->len : 0, fp);
- fclose (fp);
- if (ret - (data ? data->len : 0) != 0)
- {
- midori_view_add_info_bar (view, GTK_MESSAGE_ERROR,
- unique_filename, NULL, view,
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
- katze_assign (unique_filename, NULL);
- }
- }
- close (fd);
- }
- return unique_filename;
-#else
- GFile *file;
- char *converted = NULL;
- WebKitWebView * web_view = WEBKIT_WEB_VIEW (view->web_view);
- g_return_val_if_fail (uri,NULL);
-
- if (!outfile)
- converted = g_filename_to_utf8 (uri, -1, NULL, NULL, NULL);
- else
- converted = g_strdup (outfile);
-
- file = g_file_new_for_uri (converted);
-
- if (g_str_has_suffix (uri, ".mht"))
- webkit_web_view_save_to_file (WEBKIT_WEB_VIEW (web_view), file, WEBKIT_SAVE_MODE_MHTML,
- NULL, NULL, NULL);
- else
- g_file_replace_async (file, NULL, FALSE,
- G_FILE_CREATE_REPLACE_DESTINATION | G_FILE_CREATE_PRIVATE,
- G_PRIORITY_DEFAULT, NULL,
- (GAsyncReadyCallback)midori_web_view_save_main_resource_cb,
- web_view);
- g_free (converted);
- g_object_unref (file);
- return converted;
-#endif
-}
-
-/**
- * midori_view_reload:
- * @view: a #MidoriView
- * @from_cache: whether to allow caching
- *
- * Reloads the view.
- **/
-void
-midori_view_reload (MidoriView* view,
- gboolean from_cache)
-{
- g_return_if_fail (MIDORI_IS_VIEW (view));
-
- if (midori_tab_is_blank (MIDORI_TAB (view)))
- {
- /* Duplicate here because the URI pointer might change */
- gchar* uri = g_strdup (midori_tab_get_uri (MIDORI_TAB (view)));
- midori_view_set_uri (view, uri);
- g_free (uri);
- }
- else if (from_cache)
- webkit_web_view_reload (WEBKIT_WEB_VIEW (view->web_view));
- else
- webkit_web_view_reload_bypass_cache (WEBKIT_WEB_VIEW (view->web_view));
-}
-
-/**
- * midori_view_can_go_back
- * @view: a #MidoriView
- *
- * Determines whether the view can go back.
- **/
-gboolean
-midori_view_can_go_back (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
-
- if (view->web_view)
- return webkit_web_view_can_go_back (WEBKIT_WEB_VIEW (view->web_view));
- else
- return FALSE;
-}
-
-/**
- * midori_view_go_back
- * @view: a #MidoriView
- *
- * Goes back one page in the view.
- **/
-void
-midori_view_go_back (MidoriView* view)
-{
- g_return_if_fail (MIDORI_IS_VIEW (view));
-
- webkit_web_view_go_back (WEBKIT_WEB_VIEW (view->web_view));
- /* Force the speed dial to kick in if going back to a blank page */
- if (midori_view_is_blank (view))
- midori_view_set_uri (view, "");
-}
-
-/**
- * midori_view_go_back_or_forward
- * @view: a #MidoriView
- * @steps: number of steps to jump in history
- *
- * Goes back or forward in history.
- *
- * Since: 0.4.5
- **/
-void
-midori_view_go_back_or_forward (MidoriView* view,
- gint steps)
-{
-#ifndef HAVE_WEBKIT2
- g_return_if_fail (MIDORI_IS_VIEW (view));
-
- webkit_web_view_go_back_or_forward (WEBKIT_WEB_VIEW (view->web_view), steps);
- /* Force the speed dial to kick in if going back to a blank page */
- if (midori_view_is_blank (view))
- midori_view_set_uri (view, "");
-#endif
-}
-
-/**
- * midori_view_can_go_back_or_forward
- * @view: a #MidoriView
- * @steps: number of steps to jump in history
- *
- * Determines whether the view can go back or forward by number of steps.
- *
- * Since: 0.4.5
- **/
-gboolean
-midori_view_can_go_back_or_forward (MidoriView* view,
- gint steps)
-{
-#ifndef HAVE_WEBKIT2
- g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
-
- if (view->web_view)
- return webkit_web_view_can_go_back_or_forward (WEBKIT_WEB_VIEW (view->web_view), steps);
- else
- return FALSE;
-#else
- return FALSE;
-#endif
-}
-
-static gchar*
-midori_view_get_related_page (MidoriView* view,
- const gchar* rel,
- const gchar* local)
-{
-#ifndef HAVE_WEBKIT2
- gchar* script;
- static gchar* uri = NULL;
- WebKitWebFrame* web_frame;
- JSContextRef js_context;
-
- if (!view->web_view)
- return NULL;
-
- web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
- js_context = webkit_web_frame_get_global_context (web_frame);
- script = g_strdup_printf (
- "(function (tags) {"
- "for (var tag in tags) {"
- "var l = document.getElementsByTagName (tag);"
- "for (var i in l) { "
- "if ((l[i].rel && l[i].rel.toLowerCase () == '%s') "
- " || (l[i].innerHTML"
- " && (l[i].innerHTML.toLowerCase ().indexOf ('%s') != -1 "
- " || l[i].innerHTML.toLowerCase ().indexOf ('%s') != -1)))"
- "{ return l[i].href; } } } return 0; })("
- "{ link:'link', a:'a' });", rel, rel, local);
- katze_assign (uri, sokoke_js_script_eval (js_context, script, NULL));
- g_free (script);
- return uri && uri[0] != '0' ? uri : NULL;
-#else
- return NULL;
-#endif
-}
-
-/**
- * midori_view_get_previous_page
- * @view: a #MidoriView
- *
- * Determines the previous sub-page in the view.
- *
- * Return value: an URI, or %NULL
- *
- * Since: 0.2.3
- **/
-const gchar*
-midori_view_get_previous_page (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- /* i18n: word stem of "previous page" type links, case is not important */
- return midori_view_get_related_page (view, "prev", _("previous"));
-}
-
-/**
- * midori_view_get_next_page
- * @view: a #MidoriView
- *
- * Determines the next sub-page in the view.
- *
- * Return value: an URI, or %NULL
- *
- * Since: 0.2.3
- **/
-const gchar*
-midori_view_get_next_page (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- /* i18n: word stem of "next page" type links, case is not important */
- return midori_view_get_related_page (view, "next", _("next"));
-}
-
-#ifndef HAVE_WEBKIT2
-static GtkWidget*
-midori_view_print_create_custom_widget_cb (GtkPrintOperation* operation,
- MidoriView* view)
-{
- GtkWidget* box;
- GtkWidget* button;
-
- box = gtk_vbox_new (FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (box), 4);
- button = katze_property_proxy (view->settings, "print-backgrounds", NULL);
- gtk_button_set_label (GTK_BUTTON (button), _("Print background images"));
- gtk_widget_set_tooltip_text (button, _("Whether background images should be printed"));
- gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
- gtk_widget_show_all (box);
-
- return box;
-}
-#endif
-
-/**
- * midori_view_print
- * @view: a #MidoriView
- *
- * Prints the contents of the view.
- **/
-void
-midori_view_print (MidoriView* view)
-{
- g_return_if_fail (MIDORI_IS_VIEW (view));
-
- GtkPrintSettings* settings = gtk_print_settings_new ();
- #if GTK_CHECK_VERSION (3, 6, 0)
- gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_OUTPUT_BASENAME, midori_view_get_display_title (view));
- #endif
-
-#ifdef HAVE_WEBKIT2
- WebKitPrintOperation* operation = webkit_print_operation_new (WEBKIT_WEB_VIEW (view->web_view));
- webkit_print_operation_set_print_settings (operation, settings);
- g_object_unref (settings);
-
- if (katze_object_get_boolean (view->settings, "print-without-dialog")) {
- webkit_print_operation_print (operation);
- }
- else {
- webkit_print_operation_run_dialog (operation,
- GTK_WINDOW (midori_browser_get_for_widget (view->web_view)));
- }
- g_object_unref (operation);
-#else
- WebKitWebFrame* frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
- GtkPrintOperation* operation = gtk_print_operation_new ();
- gtk_print_operation_set_print_settings (operation, settings);
- g_object_unref (settings);
- gtk_print_operation_set_custom_tab_label (operation, _("Features"));
- gtk_print_operation_set_embed_page_setup (operation, TRUE);
- g_signal_connect (operation, "create-custom-widget",
- G_CALLBACK (midori_view_print_create_custom_widget_cb), view);
- GError* error = NULL;
-
- if (katze_object_get_boolean (view->settings, "print-without-dialog")) {
- webkit_web_frame_print_full (frame, operation,
- GTK_PRINT_OPERATION_ACTION_PRINT, &error);
- }
- else {
- webkit_web_frame_print_full (frame, operation,
- GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, &error);
- }
- g_object_unref (operation);
-
- if (error)
- {
- GtkWidget* window = gtk_widget_get_toplevel (GTK_WIDGET (view));
- GtkWidget* dialog = gtk_message_dialog_new (
- gtk_widget_is_toplevel (window) ? GTK_WINDOW (window) : NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE, "%s", error->message);
- g_error_free (error);
-
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), dialog);
- gtk_widget_show (dialog);
- }
-#endif
-}
-
-/**
- * midori_view_search_text
- * @view: a #MidoriView
- * @text: a string
- * @case_sensitive: case sensitivity
- * @forward: whether to search forward
- *
- * Searches a text within the view.
- **/
-void
-midori_view_search_text (MidoriView* view,
- const gchar* text,
- gboolean case_sensitive,
- gboolean forward)
-{
- g_return_if_fail (MIDORI_IS_VIEW (view));
-
- #if GTK_CHECK_VERSION (3, 2, 0)
- if (gtk_widget_get_visible (view->overlay_find))
- {
- text = midori_findbar_get_text (MIDORI_FINDBAR (view->overlay_find));
- midori_tab_find (MIDORI_TAB (view), text, case_sensitive, forward);
- return;
- }
- #endif
- g_signal_emit_by_name (view, "search-text",
- midori_tab_find (MIDORI_TAB (view), text, case_sensitive, forward), NULL);
-}
-
-/**
- * midori_view_execute_script
- * @view: a #MidoriView
- * @script: script code
- * @exception: location to store an exception message
- *
- * Execute a script on the view.
- *
- * Returns: %TRUE if the script was executed successfully
- **/
-gboolean
-midori_view_execute_script (MidoriView* view,
- const gchar* script,
- gchar** exception)
-{
-#ifndef HAVE_WEBKIT2
- WebKitWebFrame* web_frame;
- JSContextRef js_context;
- gchar* script_decoded;
- gchar* result;
- gboolean success;
-
- g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
- g_return_val_if_fail (script != NULL, FALSE);
-
- web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
- js_context = webkit_web_frame_get_global_context (web_frame);
- if ((script_decoded = soup_uri_decode (script)))
- {
- result = sokoke_js_script_eval (js_context, script_decoded, exception);
- g_free (script_decoded);
- }
- else
- result = sokoke_js_script_eval (js_context, script, exception);
- success = result != NULL;
- g_free (result);
- return success;
-#else
- return FALSE;
-#endif
-}
-
-/**
- * midori_view_get_snapshot
- * @view: a #MidoriView
- * @width: the desired width
- * @height: the desired height
- *
- * Take a snapshot of the view at the given dimensions. The
- * view has to be mapped on the screen.
- *
- * If width and height are negative, the resulting
- * image is going to be optimized for speed.
- *
- * Returns: (transfer full): a newly allocated #GdkPixbuf
- *
- * Since: 0.2.1
- * Deprecated: 0.5.4
- **/
-GdkPixbuf*
-midori_view_get_snapshot (MidoriView* view,
- gint width,
- gint height)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- return view->icon ? g_object_ref (view->icon) : NULL;
-}
-
-/**
- * midori_view_get_web_view
- * @view: a #MidoriView
- *
- * Returns: (transfer none): The #WebKitWebView for this view
- *
- * Since: 0.2.5
- * Deprecated: 0.4.8: Use midori_tab_get_web_view() instead.
- **/
-GtkWidget*
-midori_view_get_web_view (MidoriView* view)
-{
- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
-
- return view->web_view;
-}
-
-/**
- * midori_view_get_for_widget:
- * @web_view: a #GtkWidget of type #WebKitWebView
- *
- * Determines the MidoriView for the specified #WebkitWebView widget.
- *
- * Return value: (transfer none): a #MidoriView, or %NULL
- *
- * Since 0.4.5
- **/
-MidoriView*
-midori_view_get_for_widget (GtkWidget* web_view)
-{
- g_return_val_if_fail (GTK_IS_WIDGET (web_view), NULL);
-
- #ifdef HAVE_WEBKIT2
- GtkWidget* scrolled = web_view;
- #else
- GtkWidget* scrolled = gtk_widget_get_parent (web_view);
- #endif
- #if GTK_CHECK_VERSION(3, 2, 0)
- GtkWidget* overlay = gtk_widget_get_parent (scrolled);
- GtkWidget* view = gtk_widget_get_parent (overlay);
- #else
- GtkWidget* view = gtk_widget_get_parent (scrolled);
- #endif
- return MIDORI_VIEW (view);
-}
-/**
- * midori_view_set_colors:
- * @view: a #MidoriView
- * @fg_color: a #GdkColor, or %NULL
- * @bg_color: a #GdkColor, or %NULL
- *
- * Sets colors on the label.
- *
- * Deprecated: 0.5.7: Use fg_color/ bg_color on Midori.Tab.
- **/
-void
-midori_view_set_colors (MidoriView* view,
- GdkColor* fg_color,
- GdkColor* bg_color)
-{
- midori_tab_set_fg_color (MIDORI_TAB (view), fg_color);
- midori_tab_set_bg_color (MIDORI_TAB (view), bg_color);
-}
diff --git a/midori/midori-view.h b/midori/midori-view.h
deleted file mode 100644
index 1cc5e8c3..00000000
--- a/midori/midori-view.h
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- Copyright (C) 2008-2013 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 __MIDORI_VIEW_H__
-#define __MIDORI_VIEW_H__
-
-#include "midori-websettings.h"
-#include "midori-core.h"
-
-#include <katze/katze.h>
-
-G_BEGIN_DECLS
-
-typedef enum
-{
- MIDORI_DELAY_UNDELAYED = -1, /* The view is in a regular undelayed state */
- MIDORI_DELAY_DELAYED = 1, /* The view is delayed but has not displayed any indication of such */
- MIDORI_DELAY_PENDING_UNDELAY = -2 /* The view is delayed and showing a message asking to be undelayed */
-} MidoriDelay;
-
-#define MIDORI_TYPE_VIEW \
- (midori_view_get_type ())
-
-typedef enum
-{
- MIDORI_DOWNLOAD_CANCEL,
- MIDORI_DOWNLOAD_OPEN,
- MIDORI_DOWNLOAD_SAVE,
- MIDORI_DOWNLOAD_SAVE_AS,
- MIDORI_DOWNLOAD_OPEN_IN_VIEWER,
-} MidoriDownloadType;
-
-#define MIDORI_VIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_VIEW, MidoriView))
-#define MIDORI_VIEW_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_VIEW, MidoriViewClass))
-#define MIDORI_IS_VIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_VIEW))
-#define MIDORI_IS_VIEW_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_VIEW))
-#define MIDORI_VIEW_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_VIEW, MidoriViewClass))
-
-typedef struct _MidoriView MidoriView;
-typedef struct _MidoriViewClass MidoriViewClass;
-
-GType
-midori_view_get_type (void) G_GNUC_CONST;
-
-GtkWidget*
-midori_view_new_with_title (const gchar* title,
- MidoriWebSettings* settings,
- gboolean append);
-
-GtkWidget*
-midori_view_new_with_item (KatzeItem* item,
- MidoriWebSettings* settings);
-
-GtkWidget*
-midori_view_new_from_view (MidoriView* view,
- KatzeItem* item,
- MidoriWebSettings* settings);
-
-void
-midori_view_set_settings (MidoriView* view,
- MidoriWebSettings* settings);
-
-gdouble
-midori_view_get_progress (MidoriView* view);
-
-MidoriLoadStatus
-midori_view_get_load_status (MidoriView* view);
-
-void
-midori_view_set_uri (MidoriView* view,
- const gchar* uri);
-
-void
-midori_view_set_html (MidoriView* view,
- const gchar* data,
- const gchar* uri,
- void* web_frame);
-
-void
-midori_view_set_overlay_text (MidoriView* view,
- const gchar* text);
-
-gboolean
-midori_view_is_blank (MidoriView* view);
-
-const gchar*
-midori_view_get_display_uri (MidoriView* view);
-
-const gchar*
-midori_view_get_display_title (MidoriView* view);
-
-GdkPixbuf*
-midori_view_get_icon (MidoriView* view);
-
-const gchar*
-midori_view_get_icon_uri (MidoriView* view);
-
-const gchar*
-midori_view_get_link_uri (MidoriView* view);
-
-gboolean
-midori_view_has_selection (MidoriView* view);
-
-const gchar*
-midori_view_get_selected_text (MidoriView* view);
-
-GtkWidget*
-midori_view_get_proxy_menu_item (MidoriView* view);
-
-GtkWidget*
-midori_view_get_tab_menu (MidoriView* view);
-
-GtkWidget*
-midori_view_duplicate (MidoriView* view);
-
-PangoEllipsizeMode
-midori_view_get_label_ellipsize (MidoriView* view);
-
-GtkWidget*
-midori_view_get_proxy_tab_label (MidoriView* view);
-
-KatzeItem*
-midori_view_get_proxy_item (MidoriView* view);
-
-gfloat
-midori_view_get_zoom_level (MidoriView* view);
-
-gboolean
-midori_view_can_zoom_in (MidoriView* view);
-
-gboolean
-midori_view_can_zoom_out (MidoriView* view);
-
-void
-midori_view_set_zoom_level (MidoriView* view,
- gfloat zoom_level);
-
-void
-midori_view_reload (MidoriView* view,
- gboolean from_cache);
-
-gboolean
-midori_view_can_go_back (MidoriView* view);
-
-void
-midori_view_go_back (MidoriView* view);
-
-gboolean
-midori_view_can_go_forward (MidoriView* view);
-
-void
-midori_view_go_forward (MidoriView* view);
-
-
-void midori_view_go_back_or_forward (MidoriView* view,
- gint steps);
-
-gboolean
-midori_view_can_go_back_or_forward (MidoriView* view,
- gint steps);
-
-const gchar*
-midori_view_get_previous_page (MidoriView* view);
-
-const gchar*
-midori_view_get_next_page (MidoriView* view);
-
-void
-midori_view_print (MidoriView* view);
-
-gboolean
-midori_view_can_view_source (MidoriView* view);
-
-gchar*
-midori_view_save_source (MidoriView* view,
- const gchar* uri,
- const gchar* outfile,
- gboolean use_dom);
-
-void
-midori_view_search_text (MidoriView* view,
- const gchar* text,
- gboolean case_sensitive,
- gboolean forward);
-
-gboolean
-midori_view_execute_script (MidoriView* view,
- const gchar* script,
- gchar** exception);
-
-GdkPixbuf*
-midori_view_get_snapshot (MidoriView* view,
- gint width,
- gint height);
-
-GtkWidget*
-midori_view_get_web_view (MidoriView* view);
-
-MidoriView*
-midori_view_get_for_widget (GtkWidget* web_view);
-
-void
-midori_view_populate_popup (MidoriView* view,
- GtkWidget* menu,
- gboolean manual);
-
-GtkWidget*
-midori_view_add_info_bar (MidoriView* view,
- GtkMessageType message_type,
- const gchar* message,
- GCallback response_cb,
- gpointer user_data,
- const gchar* first_button_text,
- ...);
-
-const gchar*
-midori_view_fallback_extension (MidoriView* view,
- const gchar* extension);
-
-GList*
-midori_view_get_resources (MidoriView* view);
-
-void
-midori_view_list_versions (GString* markup,
- gboolean html);
-
-void
-midori_view_list_plugins (MidoriView* view,
- GString* markup,
- gboolean html);
-
-void
-midori_view_list_video_formats (MidoriView* view,
- GString* formats,
- gboolean html);
-
-void
-midori_view_set_colors (MidoriView* view,
- GdkColor* fg_color,
- GdkColor* bg_color);
-
-gboolean
-midori_view_get_tls_info (MidoriView* view,
- void* request,
- GTlsCertificate** tls_cert,
- GTlsCertificateFlags* tls_flags,
- gchar** hostname);
-
-MidoriContextAction*
-midori_view_get_page_context_action (MidoriView* view,
- WebKitHitTestResult* hit_test_result);
-
-G_END_DECLS
-
-#endif /* __MIDORI_VIEW_H__ */
diff --git a/midori/midori-viewable.vala b/midori/midori-viewable.vala
deleted file mode 100644
index 3fa177ec..00000000
--- a/midori/midori-viewable.vala
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- 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.
-*/
-
-namespace Midori {
- public interface Viewable {
- public abstract unowned string get_stock_id ();
- public abstract unowned string get_label ();
- public abstract Gtk.Widget get_toolbar ();
- /* Emitted when an Option menu is displayed, for instance
- * when the user clicks the Options button in the panel.
- * Deprecated: 0.2.3 */
- public signal void populate_option_menu (Gtk.Menu menu);
- }
-}
-
diff --git a/midori/midori-viewcompletion.vala b/midori/midori-viewcompletion.vala
deleted file mode 100644
index 39b06fb8..00000000
--- a/midori/midori-viewcompletion.vala
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- Copyright (C) 2012-2013 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.
-*/
-
-namespace Midori {
- public class ViewCompletion : Completion {
- GLib.Object app;
- GLib.Object browsers;
-
- public ViewCompletion () {
- GLib.Object (description: _("Open tabs"));
- }
-
- public override void prepare (GLib.Object app) {
- this.app = app;
- app.get ("browsers", out browsers);
- }
-
- public override bool can_complete (string text) {
- return browsers != null;
- }
-
- public override bool can_action (string action) {
- return action == "complete:more/views";
- }
-
- public override async List<Suggestion>? complete (string text, string? action, Cancellable cancellable) {
- return_val_if_fail (browsers != null, null);
-
- unowned List<GLib.Object> browsers_list = Katze.array_peek_items (browsers);
- var suggestions = new List<Suggestion> ();
- uint n = 0;
- string key = text.casefold ();
- foreach (var browser in browsers_list) {
- /* FIXME multiple windows */
- GLib.Object current_browser;
- app.get ("browser", out current_browser);
- if (browser != current_browser)
- continue;
-
- GLib.Object items;
- browser.get ("proxy-items", out items);
- unowned List<GLib.Object> items_list = Katze.array_peek_items (items);
-
- foreach (var item in items_list) {
- string? uri, title;
- item.get ("uri", out uri);
- item.get ("name", out title);
-
- /* Omit speed dial and blank pages */
- if (uri == "about:dial" || uri == "about:blank")
- continue;
-
- if (uri == null) {
- warning ("item.uri != null");
- continue;
- }
- if (title == null) {
- warning ("item.name != null");
- continue;
- }
- if (!(key in uri.casefold () || key in title.casefold ()))
- continue;
-
- Gdk.Pixbuf? icon = Midori.Paths.get_icon (uri, null);
- /* FIXME: Theming? Win32? */
- string background = "gray";
- var suggestion = new Suggestion (uri, title, true, background, icon, this.position);
- suggestions.append (suggestion);
-
- n++;
- if (n == 3 && action == null) {
- suggestion = new Suggestion ("complete:more/views", _("More open tabs…"), false, background);
- suggestion.action = true;
- suggestions.append (suggestion);
- break;
- }
-
- uint src = Idle.add (complete.callback);
- yield;
- Source.remove (src);
- }
- }
-
- if (cancellable.is_cancelled ())
- return null;
-
- return suggestions;
- }
- }
-}
diff --git a/midori/midori-websettings.c b/midori/midori-websettings.c
deleted file mode 100644
index 1a40878f..00000000
--- a/midori/midori-websettings.c
+++ /dev/null
@@ -1,1674 +0,0 @@
-/*
- Copyright (C) 2008-2013 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2011 Peter Hatina <phatina@redhat.com>
-
- 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.
-*/
-
-#include "midori-websettings.h"
-
-#include "midori-app.h"
-#include "midori-extension.h"
-#include "sokoke.h"
-#include <midori/midori-core.h> /* Vala API */
-
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
-#include <string.h>
-
-#include <config.h>
-#if HAVE_UNISTD_H
- #include <unistd.h>
-#endif
-#if defined (G_OS_UNIX)
- #include <sys/utsname.h>
-#endif
-#if defined(__FreeBSD__)
- #include <sys/types.h>
- #include <sys/sysctl.h>
-#endif
-
-#if defined (G_OS_WIN32)
- #include <windows.h>
-#endif
-
-#ifdef HAVE_WEBKIT2
-#define WEB_SETTINGS_STRING(x) "WebKitSettings::"x""
-#else
-#define WEB_SETTINGS_STRING(x) "WebKitWebSettings::"x""
-#endif
-
-struct _MidoriWebSettings
-{
- MidoriSettings parent_instance;
-
- MidoriToolbarStyle toolbar_style : 3;
- MidoriStartup load_on_startup : 2;
- MidoriNewTabType new_tab_type: 3;
- MidoriPreferredEncoding preferred_encoding : 3;
- gint close_buttons_left;
- MidoriNewPage open_new_pages_in : 2;
- gboolean first_party_cookies_only : 1;
- MidoriProxy proxy_type : 2;
- MidoriIdentity identify_as : 3;
-
- gchar* http_accept_language;
- gchar* accept;
- gchar* ident_string;
-
- gint clear_private_data;
- gchar* clear_data;
- gchar* site_data_rules;
- gboolean enforce_font_family;
- gchar* user_stylesheet_uri;
- gchar* user_stylesheet_uri_cached;
- GHashTable* user_stylesheets;
- gboolean print_without_dialog;
-};
-
-struct _MidoriWebSettingsClass
-{
- MidoriSettingsClass parent_class;
-};
-
-G_DEFINE_TYPE (MidoriWebSettings, midori_web_settings, MIDORI_TYPE_SETTINGS);
-
-enum
-{
- PROP_0,
-
- PROP_TOOLBAR_STYLE,
-
- PROP_LOAD_ON_STARTUP,
- PROP_NEW_TAB,
- PROP_PREFERRED_ENCODING,
-
- PROP_CLOSE_BUTTONS_LEFT,
- PROP_OPEN_NEW_PAGES_IN,
- PROP_ENABLE_FULLSCREEN,
-
- PROP_ENABLE_PLUGINS,
- PROP_ENABLE_PAGE_CACHE,
-
- PROP_PROXY_TYPE,
- PROP_IDENTIFY_AS,
- PROP_USER_AGENT,
- PROP_PREFERRED_LANGUAGES,
-
- PROP_SITE_DATA_RULES,
- PROP_ENABLE_DNS_PREFETCHING,
- PROP_ENFORCE_FONT_FAMILY,
- PROP_USER_STYLESHEET_URI,
- PROP_PRINT_WITHOUT_DIALOG,
-};
-
-GType
-midori_startup_get_type (void)
-{
- static GType type = 0;
- if (!type)
- {
- static const GEnumValue values[] = {
- { MIDORI_STARTUP_BLANK_PAGE, "MIDORI_STARTUP_BLANK_PAGE", N_("Show Speed Dial") },
- { MIDORI_STARTUP_HOMEPAGE, "MIDORI_STARTUP_HOMEPAGE", N_("Show Homepage") },
- { MIDORI_STARTUP_LAST_OPEN_PAGES, "MIDORI_STARTUP_LAST_OPEN_PAGES", N_("Show last open tabs") },
- { MIDORI_STARTUP_DELAYED_PAGES, "MIDORI_STARTUP_DELAYED_PAGES", N_("Show last tabs without loading") },
- { 0, NULL, NULL }
- };
- type = g_enum_register_static ("MidoriStartup", values);
- }
- return type;
-}
-
-GType
-midori_newtab_get_type (void)
-{
- static GType type = 0;
- if (!type)
- {
- static const GEnumValue values[] = {
- { MIDORI_NEWTAB_BLANK_PAGE, "MIDORI_NEWTAB_BLANK_PAGE", N_("Show Blank Page") },
- { MIDORI_NEWTAB_HOMEPAGE, "MIDORI_NEWTAB_HOMEPAGE", N_("Show Homepage") },
- { MIDORI_NEWTAB_SEARCH, "MIDORI_NEWTAB_SEARCH", N_("Show default Search Engine") },
- { MIDORI_NEWTAB_SPEED_DIAL, "MIDORI_NEWTAB_SPEED_DIAL", N_("Show Speed Dial") },
- { MIDORI_NEWTAB_CUSTOM, "MIDORI_NEWTAB_CUSTOM", N_("Show custom page") },
- { 0, NULL, NULL }
- };
- type = g_enum_register_static ("MidoriNewTabType", values);
- };
- return type;
-}
-
-GType
-midori_preferred_encoding_get_type (void)
-{
- static GType type = 0;
- if (!type)
- {
- static const GEnumValue values[] = {
- { MIDORI_ENCODING_CHINESE, "MIDORI_ENCODING_CHINESE", N_("Chinese Traditional (BIG5)") },
- { MIDORI_ENCODING_CHINESE_SIMPLIFIED, "MIDORI_ENCODING_CHINESE_SIMPLIFIED", N_("Chinese Simplified (GB18030)") },
- { MIDORI_ENCODING_JAPANESE, "MIDORI_ENCODING_JAPANESE", N_("Japanese (SHIFT_JIS)") },
- { MIDORI_ENCODING_KOREAN, "MIDORI_ENCODING_KOREAN", N_("Korean (EUC-KR)") },
- { MIDORI_ENCODING_RUSSIAN, "MIDORI_ENCODING_RUSSIAN", N_("Russian (KOI8-R)") },
- { MIDORI_ENCODING_UNICODE, "MIDORI_ENCODING_UNICODE", N_("Unicode (UTF-8)") },
- { MIDORI_ENCODING_WESTERN, "MIDORI_ENCODING_WESTERN", N_("Western (ISO-8859-1)") },
- { MIDORI_ENCODING_CUSTOM, "MIDORI_ENCODING_CUSTOM", N_("Custom…") },
- { 0, NULL, NULL }
- };
- type = g_enum_register_static ("MidoriPreferredEncoding", values);
- }
- return type;
-}
-
-GType
-midori_new_page_get_type (void)
-{
- static GType type = 0;
- if (!type)
- {
- static const GEnumValue values[] = {
- { MIDORI_NEW_PAGE_TAB, "MIDORI_NEW_PAGE_TAB", N_("New tab") },
- { MIDORI_NEW_PAGE_WINDOW, "MIDORI_NEW_PAGE_WINDOW", N_("New window") },
- { MIDORI_NEW_PAGE_CURRENT, "MIDORI_NEW_PAGE_CURRENT", N_("Current tab") },
- { 0, NULL, NULL }
- };
- type = g_enum_register_static ("MidoriNewPage", values);
- }
- return type;
-}
-
-GType
-midori_toolbar_style_get_type (void)
-{
- static GType type = 0;
- if (!type)
- {
- static const GEnumValue values[] = {
- { MIDORI_TOOLBAR_DEFAULT, "MIDORI_TOOLBAR_DEFAULT", N_("Default") },
- { MIDORI_TOOLBAR_ICONS, "MIDORI_TOOLBAR_ICONS", N_("Icons") },
- { MIDORI_TOOLBAR_SMALL_ICONS, "MIDORI_TOOLBAR_SMALL_ICONS", N_("Small icons") },
- { MIDORI_TOOLBAR_TEXT, "MIDORI_TOOLBAR_TEXT", N_("Text") },
- { MIDORI_TOOLBAR_BOTH, "MIDORI_TOOLBAR_BOTH", N_("Icons and text") },
- { MIDORI_TOOLBAR_BOTH_HORIZ, "MIDORI_TOOLBAR_BOTH_HORIZ", N_("Text beside icons") },
- { 0, NULL, NULL }
- };
- type = g_enum_register_static ("MidoriToolbarStyle", values);
- }
- return type;
-}
-
-GType
-midori_proxy_get_type (void)
-{
- static GType type = 0;
- if (!type)
- {
- static const GEnumValue values[] = {
- { MIDORI_PROXY_AUTOMATIC, "MIDORI_PROXY_AUTOMATIC", N_("Automatic (GNOME or environment)") },
- { MIDORI_PROXY_HTTP, "MIDORI_PROXY_HTTP", N_("HTTP proxy server") },
- { MIDORI_PROXY_NONE, "MIDORI_PROXY_NONE", N_("No proxy server") },
- { 0, NULL, NULL }
- };
- type = g_enum_register_static ("MidoriProxy", values);
- }
- return type;
-}
-
-GType
-midori_identity_get_type (void)
-{
- static GType type = 0;
- if (!type)
- {
- static const GEnumValue values[] = {
- { MIDORI_IDENT_MIDORI, "MIDORI_IDENT_MIDORI", N_("_Automatic") },
- { MIDORI_IDENT_GENUINE, "MIDORI_IDENT_GENUINE", N_("Midori") },
- { MIDORI_IDENT_CHROME, "MIDORI_IDENT_CHROME", N_("Chrome") },
- { MIDORI_IDENT_SAFARI, "MIDORI_IDENT_SAFARI", N_("Safari") },
- { MIDORI_IDENT_IPHONE, "MIDORI_IDENT_IPHONE", N_("iPhone") },
- { MIDORI_IDENT_FIREFOX, "MIDORI_IDENT_FIREFOX", N_("Firefox") },
- { MIDORI_IDENT_EXPLORER, "MIDORI_IDENT_EXPLORER", N_("Internet Explorer") },
- { MIDORI_IDENT_CUSTOM, "MIDORI_IDENT_CUSTOM", N_("Custom…") },
- { 0, NULL, NULL }
- };
- type = g_enum_register_static ("MidoriIdentity", values);
- }
- return type;
-}
-
-static void
-midori_web_settings_finalize (GObject* object);
-
-static void
-midori_web_settings_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_web_settings_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-/**
- * midori_web_settings_low_memory_profile:
- *
- * Determines if the system has a relatively small amount of memory.
- *
- * Returns: %TRUE if there is relatively little memory available
- **/
-static gboolean
-midori_web_settings_low_memory_profile ()
-{
-#ifdef _WIN32
- /* See http://msdn.microsoft.com/en-us/library/windows/desktop/aa366589(v=vs.85).aspx */
- MEMORYSTATUSEX mem;
- mem.dwLength = sizeof (mem);
- if (GlobalMemoryStatusEx (&mem))
- return mem.ullTotalPhys / 1024 / 1024 < 352;
-#elif defined(__FreeBSD__)
- size_t size;
- int mem_total;
- size = sizeof mem_total;
-
- sysctlbyname("hw.realmem", &mem_total, &size, NULL, 0);
-
- return mem_total / 1048576 < 352;
-#else
- gchar* contents;
- const gchar* total;
- if (g_file_get_contents ("/proc/meminfo", &contents, NULL, NULL)
- && contents && (total = strstr (contents, "MemTotal:")) && *total)
- {
- const gchar* value = katze_skip_whitespace (total + 9);
- gdouble mem_total = g_ascii_strtoll (value, NULL, 0);
- g_free (contents);
- return mem_total / 1024.0 < 352 + 1;
- }
- g_free (contents);
-#endif
- return FALSE;
-}
-
-static void
-midori_web_settings_class_init (MidoriWebSettingsClass* class)
-{
- GObjectClass* gobject_class;
- GParamFlags flags;
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = midori_web_settings_finalize;
- gobject_class->set_property = midori_web_settings_set_property;
- gobject_class->get_property = midori_web_settings_get_property;
-
- flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS;
-
- g_object_class_install_property (gobject_class,
- PROP_TOOLBAR_STYLE,
- g_param_spec_enum (
- "toolbar-style",
- "Toolbar Style:",
- _("The style of the toolbar"),
- MIDORI_TYPE_TOOLBAR_STYLE,
- MIDORI_TOOLBAR_DEFAULT,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_LOAD_ON_STARTUP,
- g_param_spec_enum (
- "load-on-startup",
- "When Midori starts:",
- "What to do when Midori starts",
- MIDORI_TYPE_STARTUP,
- MIDORI_STARTUP_LAST_OPEN_PAGES,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_NEW_TAB,
- g_param_spec_enum (
- "new-tab-type",
- "New tab behavior:",
- "What to show in newly opened tabs",
- MIDORI_TYPE_NEWTAB,
- MIDORI_NEWTAB_SPEED_DIAL,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_PREFERRED_ENCODING,
- g_param_spec_enum (
- "preferred-encoding",
- "Preferred Encoding",
- "The preferred character encoding",
- MIDORI_TYPE_PREFERRED_ENCODING,
- MIDORI_ENCODING_WESTERN,
- flags));
-
- /**
- * MidoriWebSettings:close-buttons-left:
- *
- * Whether to show close buttons on the left side.
- *
- * Since: 0.3.1
- */
- g_object_class_install_property (gobject_class,
- PROP_CLOSE_BUTTONS_LEFT,
- g_param_spec_boolean (
- "close-buttons-left",
- "Close buttons on the left",
- "Whether to show close buttons on the left side",
- FALSE,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
-
- g_object_class_install_property (gobject_class,
- PROP_OPEN_NEW_PAGES_IN,
- g_param_spec_enum (
- "open-new-pages-in",
- "Open new pages in:",
- "Where to open new pages",
- MIDORI_TYPE_NEW_PAGE,
- MIDORI_NEW_PAGE_TAB,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_ENABLE_PLUGINS,
- g_param_spec_boolean (
- "enable-plugins",
- "Enable Netscape plugins",
- "Enable embedded Netscape plugin objects",
- TRUE,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_ENABLE_PAGE_CACHE,
- g_param_spec_boolean ("enable-page-cache",
- "Enable page cache",
- "Whether the page cache should be used",
- !midori_web_settings_low_memory_profile (),
- flags));
-
- if (g_object_class_find_property (gobject_class, "enable-fullscreen"))
- g_object_class_install_property (gobject_class,
- PROP_ENABLE_FULLSCREEN,
- g_param_spec_boolean (
- "enable-fullscreen",
- "Enable Fullscreen",
- "Allow experimental fullscreen API",
- TRUE,
- flags));
-
- /**
- * MidoriWebSettings:proxy-type:
- *
- * The type of proxy server to use.
- *
- * Since: 0.2.5
- */
- g_object_class_install_property (gobject_class,
- PROP_PROXY_TYPE,
- g_param_spec_enum (
- "proxy-type",
- "Proxy server",
- "The type of proxy server to use",
- MIDORI_TYPE_PROXY,
- MIDORI_PROXY_AUTOMATIC,
- flags));
-
- /**
- * MidoriWebSettings:identify-as:
- *
- * What to identify as to web pages.
- *
- * Since: 0.1.2
- */
- g_object_class_install_property (gobject_class,
- PROP_IDENTIFY_AS,
- g_param_spec_enum (
- "identify-as",
- "Identify as",
- "What to identify as to web pages",
- MIDORI_TYPE_IDENTITY,
- MIDORI_IDENT_MIDORI,
- flags));
-
- /**
- * MidoriWebSettings:user-agent:
- *
- * The browser identification string.
- *
- * Since: 0.2.3
- */
- g_object_class_install_property (gobject_class,
- PROP_USER_AGENT,
- g_param_spec_string (
- "user-agent",
- "Identification string",
- "The application identification string",
- NULL,
- flags));
-
- /**
- * MidoriWebSettings:preferred-languages:
- *
- * A comma separated list of languages preferred for rendering multilingual
- * webpages and spell checking.
- *
- * Since: 0.2.3
- */
- g_object_class_install_property (gobject_class,
- PROP_PREFERRED_LANGUAGES,
- g_param_spec_string (
- "preferred-languages",
- "Preferred languages",
- "A comma separated list of languages",
- NULL,
- flags));
-
- /**
- * MidoriWebSettings:site-data-rules:
- *
- * Rules for accepting, denying and preserving cookies and other data.
- * See midori_web_settings_get_site_data_policy() for details.
- *
- * Since: 0.4.4
- */
- g_object_class_install_property (gobject_class,
- PROP_SITE_DATA_RULES,
- g_param_spec_string (
- "site-data-rules",
- "Rules for accepting, denying and preserving cookies and other data",
- "Cookies, HTML5 databases, local storage and application cache blocking",
- NULL,
- flags));
-
- /**
- * MidoriWebSettings:enforce-font-family:
- *
- * Whether to enforce user font preferences with an internal stylesheet.
- *
- * Since: 0.4.2
- */
- g_object_class_install_property (gobject_class,
- PROP_ENFORCE_FONT_FAMILY,
- g_param_spec_boolean (
- "enforce-font-family",
- _("Always use my font choices"),
- _("Override fonts picked by websites with user preferences"),
- FALSE,
- flags));
-
- g_object_class_install_property (gobject_class,
- PROP_PRINT_WITHOUT_DIALOG,
- g_param_spec_boolean (
- "print-without-dialog",
- "Print without dialog",
- "Print without showing a dialog box",
- FALSE,
- flags));
-
-
- g_object_class_install_property (gobject_class,
- PROP_USER_STYLESHEET_URI,
- g_param_spec_string (
- "user-stylesheet-uri",
- "User stylesheet URI",
- "Load stylesheets from a local URI",
- NULL,
- flags));
-}
-
-static void
-notify_default_encoding_cb (GObject* object,
- GParamSpec* pspec)
-{
- MidoriWebSettings* web_settings;
- gchar* string;
- const gchar* encoding;
-
- web_settings = MIDORI_WEB_SETTINGS (object);
-
- g_object_get (object, pspec->name, &string, NULL);
- encoding = string ? string : "";
- if (!strcmp (encoding, "BIG5"))
- web_settings->preferred_encoding = MIDORI_ENCODING_CHINESE;
- else if (!strcmp (encoding, "GB18030"))
- web_settings->preferred_encoding = MIDORI_ENCODING_CHINESE_SIMPLIFIED;
- else if (!strcmp (encoding, "SHIFT_JIS"))
- web_settings->preferred_encoding = MIDORI_ENCODING_JAPANESE;
- else if (!strcmp (encoding, "EUC-KR"))
- web_settings->preferred_encoding = MIDORI_ENCODING_KOREAN;
- else if (!strcmp (encoding, "KOI8-R"))
- web_settings->preferred_encoding = MIDORI_ENCODING_RUSSIAN;
- else if (!strcmp (encoding, "UTF-8"))
- web_settings->preferred_encoding = MIDORI_ENCODING_UNICODE;
- else if (!strcmp (encoding, "ISO-8859-1"))
- web_settings->preferred_encoding = MIDORI_ENCODING_WESTERN;
- else
- web_settings->preferred_encoding = MIDORI_ENCODING_CUSTOM;
- g_free (string);
- g_object_notify (object, "preferred-encoding");
-}
-
-static void
-notify_default_font_family_cb (GObject* object,
- GParamSpec* pspec)
-{
- if (katze_object_get_boolean (object, "enforce-font-family"))
- g_object_set (object, "enforce-font-family", TRUE, NULL);
-}
-static void
-midori_web_settings_init (MidoriWebSettings* web_settings)
-{
- web_settings->user_stylesheet_uri = web_settings->user_stylesheet_uri_cached = NULL;
- web_settings->user_stylesheets = NULL;
-
- #if defined (_WIN32) && !GTK_CHECK_VERSION (3, 0, 0)
- /* Try to work-around black borders on native widgets and GTK+2 on Win32 */
- midori_web_settings_add_style (web_settings, "black-widgets-workaround",
- "input[type='checkbox'] { -webkit-appearance: checkbox !important }"
- " input[type='radio'] { -webkit-appearance: radio !important }"
- " * { -webkit-appearance: none !important }");
- #endif
-
- g_signal_connect (web_settings, "notify::default-charset",
- G_CALLBACK (notify_default_encoding_cb), NULL);
- g_signal_connect (web_settings, "notify::default-font-family",
- G_CALLBACK (notify_default_font_family_cb), NULL);
-}
-
-static void
-midori_web_settings_finalize (GObject* object)
-{
- MidoriWebSettings* web_settings;
-
- web_settings = MIDORI_WEB_SETTINGS (object);
-
- katze_assign (web_settings->http_accept_language, NULL);
- katze_assign (web_settings->accept, NULL);
- katze_assign (web_settings->ident_string, NULL);
- katze_assign (web_settings->user_stylesheet_uri, NULL);
- katze_assign (web_settings->user_stylesheet_uri_cached, NULL);
- if (web_settings->user_stylesheets != NULL)
- g_hash_table_destroy (web_settings->user_stylesheets);
-
- G_OBJECT_CLASS (midori_web_settings_parent_class)->finalize (object);
-}
-
-/**
- * midori_web_settings_has_plugin_support:
- *
- * Determines if Netscape plugins are supported.
- *
- * Returns: %TRUE if Netscape plugins can be used
- *
- * Since: 0.4.4
- **/
-gboolean
-midori_web_settings_has_plugin_support (void)
-{
- return !midori_debug ("unarmed") && g_strcmp0 (g_getenv ("MOZ_PLUGIN_PATH"), "/");
-}
-
-/**
- * midori_web_settings_skip_plugin:
- * @path: the path to the plugin file
- *
- * Tests if a plugin is redundant. WebKit sometimes provides
- * duplicate listings of plugins due to library deployment
- * miscellanea.
- *
- * Returns: %TRUE if the passed plugin shouldn't be shown in UI listings.
- *
- * Since: 0.5.1
- **/
-gboolean
-midori_web_settings_skip_plugin (const gchar* path)
-{
- static GHashTable* plugins = NULL;
- gchar* basename = NULL;
- gchar* plugin_path = NULL;
-
- if (!path)
- return TRUE;
-
- if (!plugins)
- plugins = g_hash_table_new (g_str_hash, g_str_equal);
-
- basename = g_path_get_basename (path);
-
- plugin_path = g_hash_table_lookup (plugins, basename);
- if (g_strcmp0 (path, plugin_path) == 0)
- {
- return FALSE;
- }
-
- if (plugin_path != NULL)
- {
- g_free (basename);
-
- return TRUE;
- }
-
- g_hash_table_insert (plugins, basename, g_strdup (path));
-
- /* Note: do not free basename */
-
- return FALSE;
-}
-
-/**
- * midori_web_settings_get_site_data_policy:
- * @settings: the MidoriWebSettings instance
- * @uri: the URI for which to make the policy decision
- *
- * Tests if @uri may store site data.
- *
- * Returns: a #MidoriSiteDataPolicy
- *
- * Since: 0.4.4
- **/
-MidoriSiteDataPolicy
-midori_web_settings_get_site_data_policy (MidoriWebSettings* settings,
- const gchar* uri)
-{
- MidoriSiteDataPolicy policy = MIDORI_SITE_DATA_UNDETERMINED;
- gchar* hostname;
- const gchar* match;
-
- g_return_val_if_fail (MIDORI_IS_WEB_SETTINGS (settings), policy);
-
- if (!(settings->site_data_rules && *settings->site_data_rules))
- return policy;
-
- /*
- * Values prefixed with "-" are always blocked
- * Values prefixed with "+" are always accepted
- * Values prefixed with "!" are not cleared in Clear Private Data
- * FIXME: "*" is a wildcard
- * FIXME: indicate type of storage the rule applies to
- * FIXME: support matching of the whole URI
- **/
- hostname = midori_uri_parse_hostname (uri, NULL);
- match = strstr (settings->site_data_rules, hostname ? hostname : uri);
- if (match != NULL && match != settings->site_data_rules)
- {
- const gchar* prefix = match - 1;
- if (*prefix == '-')
- policy = MIDORI_SITE_DATA_BLOCK;
- else if (*prefix == '+')
- policy = MIDORI_SITE_DATA_ACCEPT;
- else if (*prefix == '!')
- policy = MIDORI_SITE_DATA_PRESERVE;
- else
- g_warning ("%s: Matched with no prefix '%s'", G_STRFUNC, match);
- }
- g_free (hostname);
- return policy;
-}
-
-#if (!HAVE_OSX && defined (G_OS_UNIX)) || defined (G_OS_WIN32)
-static gchar*
-get_sys_name (gchar** architecture)
-{
- static gchar* sys_name = NULL;
- static gchar* sys_architecture = NULL;
-
- if (!sys_name)
- {
- #ifdef G_OS_WIN32
- /* 6.1 Win7, 6.0 Vista, 5.1 XP and 5.0 Win2k */
- guint version = g_win32_get_windows_version ();
- sys_name = g_strdup_printf ("NT %d.%d", LOBYTE (version), HIBYTE (version));
- #else
- struct utsname name;
- if (uname (&name) != -1)
- {
- sys_name = g_strdup (name.sysname);
- sys_architecture = g_strdup (name.machine);
- }
- else
- sys_name = "Linux";
- #endif
- }
-
- if (architecture != NULL)
- *architecture = sys_architecture;
- return sys_name;
-}
-#endif
-
-/**
- * midori_web_settings_get_system_name:
- * @architecture: (out) (allow-none): location of a string, or %NULL
- * @platform: (out) (allow-none): location of a string, or %NULL
- *
- * Determines the system name, architecture and platform.
- * This function may write a %NULL value to @architecture.
- *
- * Returns: a string
- *
- * Since: 0.4.2
- **/
-const gchar*
-midori_web_settings_get_system_name (gchar** architecture,
- gchar** platform)
-{
- if (architecture != NULL)
- *architecture = NULL;
-
- if (platform != NULL)
- *platform =
- #if defined (G_OS_WIN32)
- "Windows";
- #elif defined(GDK_WINDOWING_QUARTZ)
- "Macintosh;";
- #elif defined(GDK_WINDOWING_DIRECTFB)
- "DirectFB;";
- #else
- "X11;";
- #endif
-
- return
- #if HAVE_OSX
- "Mac OS X";
- #elif defined (G_OS_UNIX) || defined (G_OS_WIN32)
- get_sys_name (architecture);
- #else
- "Linux";
- #endif
-}
-
-static const gchar*
-get_uri_for_new_tab (MidoriWebSettings* web_settings,
- MidoriNewTabType new_tab_type)
-{
- switch (new_tab_type)
- {
- case MIDORI_NEWTAB_BLANK_PAGE:
- return "about:blank";
- case MIDORI_NEWTAB_HOMEPAGE:
- return "about:home";
- case MIDORI_NEWTAB_SEARCH:
- return "about:search";
- case MIDORI_NEWTAB_CUSTOM:
- return midori_settings_get_tabhome (MIDORI_SETTINGS (web_settings));
- case MIDORI_NEWTAB_SPEED_DIAL:
- return "about:dial";
- default:
- g_assert_not_reached ();
- }
-}
-
-static gchar*
-generate_ident_string (MidoriWebSettings* web_settings,
- MidoriIdentity identify_as)
-{
- const gchar* appname = "Midori/"
- G_STRINGIFY (MIDORI_MAJOR_VERSION) "."
- G_STRINGIFY (MIDORI_MINOR_VERSION);
-
- const gchar* lang = pango_language_to_string (gtk_get_default_language ());
- gchar* platform;
- const gchar* os = midori_web_settings_get_system_name (NULL, &platform);
-
- #ifndef HAVE_WEBKIT2
- const int webcore_major = WEBKIT_USER_AGENT_MAJOR_VERSION;
- const int webcore_minor = WEBKIT_USER_AGENT_MINOR_VERSION;
- #else
- const int webcore_major = 537;
- const int webcore_minor = 32;
- #endif
-
- g_object_set (web_settings, "enable-site-specific-quirks",
- identify_as != MIDORI_IDENT_GENUINE, NULL);
-
- switch (identify_as)
- {
- case MIDORI_IDENT_GENUINE:
- return g_strdup_printf ("Mozilla/5.0 (%s %s) AppleWebKit/%d.%d+ %s",
- platform, os, webcore_major, webcore_minor, appname);
- case MIDORI_IDENT_MIDORI:
- case MIDORI_IDENT_CHROME:
- return g_strdup_printf ("Mozilla/5.0 (%s %s) AppleWebKit/%d.%d "
- "(KHTML, like Gecko) Chrome/46.0.2490.86 Safari/%d.%d %s",
- platform, os, webcore_major, webcore_minor, webcore_major, webcore_minor, appname);
- case MIDORI_IDENT_SAFARI:
- return g_strdup_printf ("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; %s) "
- "AppleWebKit/%d+ (KHTML, like Gecko) Version/5.0 Safari/%d.%d+ %s",
- lang, webcore_major, webcore_major, webcore_minor, appname);
- case MIDORI_IDENT_IPHONE:
- return g_strdup_printf ("Mozilla/5.0 (iPhone; U; CPU like Mac OS X; %s) "
- "AppleWebKit/532+ (KHTML, like Gecko) Version/3.0 Mobile/1A538b Safari/419.3 %s",
- lang, appname);
- case MIDORI_IDENT_FIREFOX:
- return g_strdup_printf ("Mozilla/5.0 (%s %s; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 %s",
- platform, os, appname);
- case MIDORI_IDENT_EXPLORER:
- return g_strdup_printf ("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; %s) %s",
- lang, appname);
- default:
- return g_strdup_printf ("%s", appname);
- }
-}
-
-#ifndef HAVE_WEBKIT2
-/* Provide a new way for SoupSession to assume an 'Accept-Language'
- string automatically from the return value of g_get_language_names(),
- properly formatted according to RFC2616.
- Copyright (C) 2009 Mario Sanchez Prada <msanchez@igalia.com>
- Copyright (C) 2009 Dan Winship <danw@gnome.org>
- Mostly copied from libSoup 2.29, coding style adjusted */
-
-/* Converts a language in POSIX format and to be RFC2616 compliant */
-/* Based on code from epiphany-webkit (ephy_langs_append_languages()) */
-
-static gchar *
-sokoke_posix_lang_to_rfc2616 (const gchar *language)
-{
- if (!strchr (language, '.') && !strchr (language, '@') && language[0] != 'C')
- /* change to lowercase and '_' to '-' */
- return g_strdelimit (g_ascii_strdown (language, -1), "_", '-');
-
- return NULL;
-}
-
-/* Adds a quality value to a string (any value between 0 and 1). */
-static gchar *
-sokoke_add_quality_value (const gchar *str,
- float qvalue)
-{
- if ((qvalue >= 0.0) && (qvalue <= 1.0))
- {
- int qv_int = (qvalue * 1000 + 0.5);
- return g_strdup_printf ("%s;q=%d.%d",
- str, (int) (qv_int / 1000), qv_int % 1000);
- }
-
- return g_strdup (str);
-}
-
-/* Returns a RFC2616 compliant languages list from system locales */
-static gchar *
-sokoke_accept_languages (const gchar* const * lang_names)
-{
- GString* langs = NULL;
- char *cur_lang = NULL;
- char *prev_lang = NULL;
- float delta;
- int i, n_lang_names;
-
- /* Calculate delta for setting the quality values */
- n_lang_names = g_strv_length ((gchar **)lang_names);
- delta = 0.999 / (n_lang_names - 1);
-
- /* Build the array of languages */
- langs = g_string_sized_new (n_lang_names);
- for (i = 0; lang_names[i] != NULL; i++)
- {
- cur_lang = sokoke_posix_lang_to_rfc2616 (lang_names[i]);
-
- /* Apart from getting a valid RFC2616 compliant
- language, also get rid of extra variants */
- if (cur_lang && (!prev_lang ||
- (!strcmp (prev_lang, cur_lang) || !strstr (prev_lang, cur_lang))))
- {
-
- gchar *qv_lang = NULL;
-
- /* Save reference for further comparison */
- prev_lang = cur_lang;
-
- /* Add the quality value and append it */
- qv_lang = sokoke_add_quality_value (cur_lang, 1 - i * delta);
- if (langs->len > 0)
- g_string_append_c (langs, ',');
- g_string_append (langs, qv_lang);
- }
- }
-
- /* Fallback: add "en" if list is empty */
- if (langs->len == 0)
- g_string_append (langs, "en");
-
- return g_string_free (langs, FALSE);
-}
-
-
-static void
-midori_web_settings_update_accept_language (MidoriWebSettings* settings)
-{
- gchar* languages = settings->http_accept_language;
- /* Empty, use the system locales */
- if (!(languages && *languages))
- katze_assign (settings->accept, sokoke_accept_languages (g_get_language_names ()));
- /* No =, no ., looks like a list of language names */
- else if (!(strchr (languages, '=') && strchr (languages, '.')))
- {
- gchar ** lang_names = g_strsplit_set (languages, ",; ", -1);
- katze_assign (settings->accept, sokoke_accept_languages ((const gchar* const *)lang_names));
- g_strfreev (lang_names);
- }
- /* Presumably a well formatted list including priorities */
- else
- katze_assign (settings->accept, g_strdup (languages));
-}
-
-/**
- * midori_web_settings_get_accept_language:
- *
- * Returns the value of the accept-language header to send to web servers
- *
- * Returns: the accept-language string
- **/
-const gchar*
-midori_web_settings_get_accept_language (MidoriWebSettings* settings)
-{
- if (!settings->accept)
- midori_web_settings_update_accept_language (settings);
- return settings->accept;
-}
-#endif
-
-static void
-midori_web_settings_process_stylesheets (MidoriWebSettings* settings,
- gint delta_len);
-
-static void
-base64_space_pad (gchar* base64,
- guint len);
-
-static void
-midori_web_settings_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- MidoriWebSettings* web_settings = MIDORI_WEB_SETTINGS (object);
-
- switch (prop_id)
- {
- case PROP_TOOLBAR_STYLE:
- web_settings->toolbar_style = g_value_get_enum (value);
- break;
-
- case PROP_LOAD_ON_STARTUP:
- web_settings->load_on_startup = g_value_get_enum (value);
- break;
- case PROP_PREFERRED_ENCODING:
- web_settings->preferred_encoding = g_value_get_enum (value);
- switch (web_settings->preferred_encoding)
- {
- case MIDORI_ENCODING_CHINESE:
- g_object_set (object, "default-charset", "BIG5", NULL);
- break;
- case MIDORI_ENCODING_CHINESE_SIMPLIFIED:
- g_object_set (object, "default-charset", "GB18030", NULL);
- break;
- case MIDORI_ENCODING_JAPANESE:
- g_object_set (object, "default-charset", "SHIFT_JIS", NULL);
- break;
- case MIDORI_ENCODING_KOREAN:
- g_object_set (object, "default-charset", "EUC-KR", NULL);
- break;
- case MIDORI_ENCODING_RUSSIAN:
- g_object_set (object, "default-charset", "KOI8-R", NULL);
- break;
- case MIDORI_ENCODING_UNICODE:
- g_object_set (object, "default-charset", "UTF-8", NULL);
- break;
- case MIDORI_ENCODING_WESTERN:
- g_object_set (object, "default-charset", "ISO-8859-1", NULL);
- break;
- case MIDORI_ENCODING_CUSTOM:
- g_object_set (object, "default-charset", "", NULL);
- }
- break;
-
- case PROP_OPEN_NEW_PAGES_IN:
- web_settings->open_new_pages_in = g_value_get_enum (value);
- break;
-
- case PROP_ENABLE_PLUGINS:
- g_object_set (web_settings,
- WEB_SETTINGS_STRING ("enable-plugins"), g_value_get_boolean (value),
- #ifdef HAVE_WEBKIT2
- "enable-java", g_value_get_boolean (value),
- #else
- "enable-java-applet", g_value_get_boolean (value),
- #endif
- NULL);
- break;
- case PROP_ENABLE_PAGE_CACHE:
- g_object_set (web_settings, WEB_SETTINGS_STRING ("enable-page-cache"),
- g_value_get_boolean (value), NULL);
- break;
-
- case PROP_PROXY_TYPE:
- web_settings->proxy_type = g_value_get_enum (value);
- break;
- case PROP_IDENTIFY_AS:
- web_settings->identify_as = g_value_get_enum (value);
- if (web_settings->identify_as != MIDORI_IDENT_CUSTOM)
- {
- gchar* string = generate_ident_string (web_settings, web_settings->identify_as);
- katze_assign (web_settings->ident_string, string);
- g_object_set (web_settings, "user-agent", string, NULL);
- }
- break;
- case PROP_USER_AGENT:
- if (web_settings->identify_as == MIDORI_IDENT_CUSTOM)
- katze_assign (web_settings->ident_string, g_value_dup_string (value));
- g_object_set (web_settings, WEB_SETTINGS_STRING ("user-agent"),
- web_settings->ident_string, NULL);
- break;
- case PROP_NEW_TAB:
- web_settings->new_tab_type = g_value_get_enum (value);
- const gchar* tabhome = get_uri_for_new_tab (web_settings, web_settings->new_tab_type);
- midori_settings_set_tabhome (MIDORI_SETTINGS (web_settings), tabhome);
- break;
- case PROP_PREFERRED_LANGUAGES:
- katze_assign (web_settings->http_accept_language, g_value_dup_string (value));
- #ifdef HAVE_WEBKIT2
- WebKitWebContext* context = webkit_web_context_get_default ();
- gchar** languages = web_settings->http_accept_language
- ? g_strsplit_set (web_settings->http_accept_language, ",; ", -1)
- : g_strdupv ((gchar**)g_get_language_names ());
- webkit_web_context_set_preferred_languages (context, (const gchar* const*)languages);
- webkit_web_context_set_spell_checking_languages (context, (const gchar* const*)languages);
- g_strfreev (languages);
- #else
- g_object_set (web_settings, "spell-checking-languages",
- web_settings->http_accept_language, NULL);
- midori_web_settings_update_accept_language (web_settings);
- #endif
- break;
- case PROP_SITE_DATA_RULES:
- katze_assign (web_settings->site_data_rules, g_value_dup_string (value));
- break;
- case PROP_ENFORCE_FONT_FAMILY:
- if ((web_settings->enforce_font_family = g_value_get_boolean (value)))
- {
- gchar* font_family = katze_object_get_string (web_settings,
- "default-font-family");
- gchar* monospace = katze_object_get_string (web_settings,
- "monospace-font-family");
- gchar* css = g_strdup_printf ("body * { font-family: %s !important; } "
- "code, code *, pre, pre *, blockquote, blockquote *, "
- "input, textarea { font-family: %s !important; }",
- font_family, monospace);
- midori_web_settings_add_style (web_settings, "enforce-font-family", css);
- g_free (font_family);
- g_free (monospace);
- g_free (css);
- }
- else
- midori_web_settings_remove_style (web_settings, "enforce-font-family");
- break;
- case PROP_ENABLE_FULLSCREEN:
- g_object_set (web_settings, WEB_SETTINGS_STRING ("enable-fullscreen"),
- g_value_get_boolean (value), NULL);
- break;
- case PROP_USER_STYLESHEET_URI:
- {
- gint old_len = web_settings->user_stylesheet_uri_cached
- ? strlen (web_settings->user_stylesheet_uri_cached) : 0;
- gint new_len = 0;
- if ((web_settings->user_stylesheet_uri = g_value_dup_string (value)))
- {
- gchar* import = g_strdup_printf ("@import url(\"%s\");",
- web_settings->user_stylesheet_uri);
- gchar* encoded = g_base64_encode ((const guchar*)import, strlen (import));
- new_len = strlen (encoded);
- base64_space_pad (encoded, new_len);
- g_free (import);
- katze_assign (web_settings->user_stylesheet_uri_cached, encoded);
- }
- /* Make original user-stylesheet-uri available to main.c */
- g_object_set_data (G_OBJECT (web_settings), "user-stylesheet-uri",
- web_settings->user_stylesheet_uri);
- midori_web_settings_process_stylesheets (web_settings, new_len - old_len);
- }
- break;
- case PROP_PRINT_WITHOUT_DIALOG:
- web_settings->print_without_dialog = g_value_get_boolean(value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_web_settings_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- MidoriWebSettings* web_settings = MIDORI_WEB_SETTINGS (object);
-
- switch (prop_id)
- {
- case PROP_TOOLBAR_STYLE:
- g_value_set_enum (value, web_settings->toolbar_style);
- break;
-
- case PROP_LOAD_ON_STARTUP:
- g_value_set_enum (value, web_settings->load_on_startup);
- break;
- case PROP_PREFERRED_ENCODING:
- g_value_set_enum (value, web_settings->preferred_encoding);
- break;
-
- case PROP_CLOSE_BUTTONS_LEFT:
- #if HAVE_OSX
- g_value_set_boolean (value, TRUE);
- #elif defined (G_OS_WIN32)
- g_value_set_boolean (value, FALSE);
- #else
- if (!web_settings->close_buttons_left)
- {
- /* Look for close button in layout specified in index.theme */
- GdkScreen* screen = gdk_screen_get_default ();
- GtkSettings* settings = gtk_settings_get_for_screen (screen);
- gchar* theme = katze_object_get_string (settings, "gtk-theme-name");
- gchar* theme_file = g_build_filename ("themes", theme, "index.theme", NULL);
- gchar* filename = midori_paths_get_data_filename (theme_file, FALSE);
- g_free (theme_file);
- web_settings->close_buttons_left = 1;
- if (!g_file_test (filename, G_FILE_TEST_EXISTS))
- katze_assign (filename,
- g_build_filename (g_get_home_dir (), ".themes",
- theme, "index.theme", NULL));
- g_free (theme);
- if (g_file_test (filename, G_FILE_TEST_EXISTS))
- {
- GKeyFile* keyfile = g_key_file_new ();
- gchar* button_layout;
- g_key_file_load_from_file (keyfile, filename, 0, NULL);
- button_layout = g_key_file_get_string (keyfile,
- "X-GNOME-Metatheme", "ButtonLayout", NULL);
- if (button_layout && strstr (button_layout, "close:"))
- web_settings->close_buttons_left = 2;
- g_free (button_layout);
- g_key_file_free (keyfile);
- }
- g_free (filename);
- }
- g_value_set_boolean (value, web_settings->close_buttons_left == 2);
- #endif
- break;
- case PROP_OPEN_NEW_PAGES_IN:
- g_value_set_enum (value, web_settings->open_new_pages_in);
- break;
-
- case PROP_ENABLE_PLUGINS:
- g_value_set_boolean (value, katze_object_get_boolean (web_settings,
- WEB_SETTINGS_STRING ("enable-plugins")));
- break;
- case PROP_ENABLE_PAGE_CACHE:
- g_value_set_boolean (value, katze_object_get_boolean (web_settings,
- WEB_SETTINGS_STRING ("enable-page-cache")));
- break;
-
- case PROP_PROXY_TYPE:
- g_value_set_enum (value, web_settings->proxy_type);
- break;
- case PROP_IDENTIFY_AS:
- g_value_set_enum (value, web_settings->identify_as);
- break;
- case PROP_USER_AGENT:
- if (!g_strcmp0 (web_settings->ident_string, ""))
- {
- gchar* string = generate_ident_string (web_settings, web_settings->identify_as);
- katze_assign (web_settings->ident_string, string);
- }
- g_value_set_string (value, web_settings->ident_string);
- break;
- case PROP_NEW_TAB:
- g_value_set_enum (value, web_settings->new_tab_type);
- break;
- case PROP_PREFERRED_LANGUAGES:
- g_value_set_string (value, web_settings->http_accept_language);
- break;
- case PROP_SITE_DATA_RULES:
- g_value_set_string (value, web_settings->site_data_rules);
- break;
- case PROP_ENFORCE_FONT_FAMILY:
- g_value_set_boolean (value, web_settings->enforce_font_family);
- break;
- case PROP_ENABLE_FULLSCREEN:
- g_value_set_boolean (value, katze_object_get_boolean (web_settings,
- WEB_SETTINGS_STRING ("enable-fullscreen")));
- break;
- case PROP_USER_STYLESHEET_URI:
-#ifdef HAVE_WEBKIT2
- g_value_set_string (value, web_settings->user_stylesheet_uri);
-#else
- g_value_take_string (value, katze_object_get_string (web_settings,
- WEB_SETTINGS_STRING ("user-stylesheet-uri")));
-#endif
- break;
- case PROP_PRINT_WITHOUT_DIALOG:
- g_value_set_boolean (value, web_settings->print_without_dialog);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/**
- * midori_web_settings_new:
- *
- * Creates a new #MidoriWebSettings instance with default values.
- *
- * You will typically want to assign this to a #MidoriWebView
- * or #MidoriBrowser.
- *
- * Return value: (transfer full): a new #MidoriWebSettings
- **/
-MidoriWebSettings*
-midori_web_settings_new (void)
-{
- MidoriWebSettings* web_settings = g_object_new (MIDORI_TYPE_WEB_SETTINGS,
- NULL);
-
- return web_settings;
-}
-
-static void
-midori_web_settings_process_stylesheets (MidoriWebSettings* settings,
- gint delta_len)
-{
- GHashTableIter it;
- GString* css;
- gchar* encoded;
- gpointer value;
- static guint length = 0;
-
- g_return_if_fail ((gint)length >= -delta_len);
-
- length += delta_len;
-
- /* Precalculate size to avoid re-allocations */
- css = g_string_sized_new (length);
-
- if (settings->user_stylesheet_uri_cached != NULL)
- g_string_append (css, settings->user_stylesheet_uri_cached);
-
- if (settings->user_stylesheets != NULL)
- {
- g_hash_table_iter_init (&it, settings->user_stylesheets);
- while (g_hash_table_iter_next (&it, NULL, &value))
- g_string_append (css, (gchar*)value);
- }
-
- /* data: uri prefix from Source/WebCore/page/Page.cpp:700 in WebKit */
- encoded = g_strconcat ("data:text/css;charset=utf-8;base64,", css->str, NULL);
- #ifdef HAVE_WEBKIT2
- /* TODO: webkit_web_view_group_add_user_style_sheet */
- #else
- g_object_set (settings, WEB_SETTINGS_STRING ("user-stylesheet-uri"), encoded, NULL);
- #endif
- g_free (encoded);
- g_string_free (css, TRUE);
-}
-
-static void
-base64_space_pad (gchar* base64,
- guint len)
-{
- /* Replace '=' padding at the end with encoded spaces
- so WebKit will accept concatenations to this string */
- if (len > 2 && base64[len - 2] == '=')
- {
- base64[len - 3] += 2;
- base64[len - 2] = 'A';
- }
- if (len > 1 && base64[len - 1] == '=')
- base64[len - 1] = 'g';
-}
-
-/**
- * midori_web_settings_add_style:
- * @settings: the MidoriWebSettings instance to modify
- * @rule_id: a static string identifier
- * @style: a CSS stylesheet
- *
- * Adds or replaces a custom stylesheet.
- *
- * Since: 0.4.2
- **/
-void
-midori_web_settings_add_style (MidoriWebSettings* settings,
- const gchar* rule_id,
- const gchar* style)
-{
- gchar* base64;
- guint len;
-
- g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings));
- g_return_if_fail (rule_id != NULL);
- g_return_if_fail (style != NULL);
-
- len = strlen (style);
- base64 = g_base64_encode ((const guchar*)style, len);
- len = ((len + 2) / 3) * 4;
- base64_space_pad (base64, len);
-
- if (settings->user_stylesheets == NULL)
- settings->user_stylesheets = g_hash_table_new_full (g_str_hash, NULL,
- NULL, g_free);
-
- g_hash_table_insert (settings->user_stylesheets, (gchar*)rule_id, base64);
- midori_web_settings_process_stylesheets (settings, len);
-}
-
-/**
- * midori_web_settings_remove_style:
- * @settings: the MidoriWebSettings instance to modify
- * @rule_id: the string identifier used previously
- *
- * Removes a stylesheet from midori settings.
- *
- * Since: 0.4.2
- **/
-void
-midori_web_settings_remove_style (MidoriWebSettings* settings,
- const gchar* rule_id)
-{
- gchar* str;
-
- g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings));
- g_return_if_fail (rule_id != NULL);
-
- if (settings->user_stylesheets != NULL)
- {
- if ((str = g_hash_table_lookup (settings->user_stylesheets, rule_id)))
- {
- guint len = strlen (str);
- g_hash_table_remove (settings->user_stylesheets, rule_id);
- midori_web_settings_process_stylesheets (settings, -len);
- }
- }
-}
-
-/**
- * midori_settings_new_full:
- * @extensions: (out) (allow-none): a pointer into which
- * to write an array of names of extensions which preferences
- * indicate should be activated, or %NULL.
- *
- * Creates a new #MidoriWebSettings instance, loading
- * configuration from disk according to preferences and
- * invocation mode.
- *
- * You will typically want to assign this to a #MidoriWebView
- * or #MidoriBrowser.
- *
- * Return value: (transfer full): a new #MidoriWebSettings
- **/
-MidoriWebSettings*
-midori_settings_new_full (gchar*** extensions)
-{
- MidoriWebSettings* settings = midori_web_settings_new ();
- gchar* config_file = midori_paths_get_config_filename_for_reading ("config");
- GKeyFile* key_file = g_key_file_new ();
- GError* error = NULL;
- GObjectClass* class;
- guint i, n_properties;
- GParamSpec** pspecs;
- GParamSpec* pspec;
- GType type;
- const gchar* property;
- gchar* str;
- gint integer;
- gfloat number;
- gboolean boolean;
-
- if (!g_key_file_load_from_file (key_file, config_file,
- G_KEY_FILE_KEEP_COMMENTS, &error))
- {
- if (error->code == G_FILE_ERROR_NOENT)
- {
- GError* inner_error = NULL;
- katze_assign (config_file, midori_paths_get_preset_filename (NULL, "config"));
- g_key_file_load_from_file (key_file, config_file,
- G_KEY_FILE_KEEP_COMMENTS, &inner_error);
- if (inner_error != NULL)
- {
- printf (_("The configuration couldn't be loaded: %s\n"),
- inner_error->message);
- g_error_free (inner_error);
- }
- }
- else
- printf (_("The configuration couldn't be loaded: %s\n"),
- error->message);
- g_error_free (error);
- }
-
- class = G_OBJECT_GET_CLASS (settings);
- pspecs = g_object_class_list_properties (class, &n_properties);
- for (i = 0; i < n_properties; i++)
- {
- pspec = pspecs[i];
- if (!(pspec->flags & G_PARAM_WRITABLE))
- continue;
-
- type = G_PARAM_SPEC_TYPE (pspec);
- property = g_param_spec_get_name (pspec);
- if (!g_key_file_has_key (key_file, "settings", property, NULL))
- continue;
-
- if (type == G_TYPE_PARAM_STRING)
- {
- str = g_key_file_get_string (key_file, "settings", property, NULL);
- g_object_set (settings, property, str, NULL);
- g_free (str);
- }
- else if (type == G_TYPE_PARAM_INT || type == G_TYPE_PARAM_UINT)
- {
- integer = g_key_file_get_integer (key_file, "settings", property, NULL);
- g_object_set (settings, property, integer, NULL);
- }
- else if (type == G_TYPE_PARAM_FLOAT || type == G_TYPE_PARAM_DOUBLE)
- {
- number = g_key_file_get_double (key_file, "settings", property, NULL);
- g_object_set (settings, property, number, NULL);
- }
- else if (type == G_TYPE_PARAM_BOOLEAN)
- {
- boolean = g_key_file_get_boolean (key_file, "settings", property, NULL);
- g_object_set (settings, property, boolean, NULL);
- }
- else if (type == G_TYPE_PARAM_ENUM)
- {
- GEnumClass* enum_class = G_ENUM_CLASS (
- g_type_class_peek (pspec->value_type));
- GEnumValue* enum_value;
- str = g_key_file_get_string (key_file, "settings", property, NULL);
- enum_value = g_enum_get_value_by_name (enum_class, str);
- if (enum_value)
- g_object_set (settings, property, enum_value->value, NULL);
- else
- g_warning (_("Value '%s' is invalid for %s"),
- str, property);
- g_free (str);
- }
- else
- g_warning (_("Invalid configuration value '%s'"), property);
- }
- g_free (pspecs);
-
- if (extensions != NULL)
- *extensions = g_key_file_get_keys (key_file, "extensions", NULL, NULL);
- g_key_file_free (key_file);
-
- /* Load accelerators */
- katze_assign (config_file, midori_paths_get_config_filename_for_reading ("accels"));
- if (!g_file_test (config_file, G_FILE_TEST_EXISTS))
- katze_assign (config_file, midori_paths_get_preset_filename (NULL, "accels"));
- gtk_accel_map_load (config_file);
- g_free (config_file);
-
- return settings;
-}
-
-/**
- * midori_settings_save_to_file:
- * @settings: a MidoriWebSettings instance to save
- * @app: (type MidoriApp) (allow-none): a MidoriApp instance
- * @filename: the filename into which to save settings
- * @error: (out) (allow-none): return location for a GError, or %NULL
- *
- * Saves a #MidoriWebSettings instance to disk at the path given by @filename.
- *
- * Also saves the list of activated extensions from @app.
- *
- * Return value: %TRUE if no error occurred; %FALSE if an error
- * occurred, in which case @error will contain detailed information
- **/
-gboolean
-midori_settings_save_to_file (MidoriWebSettings* settings,
- GObject* app,
- const gchar* filename,
- GError** error)
-{
- GKeyFile* key_file;
- GObjectClass* class;
- guint i, n_properties;
- GParamSpec** pspecs;
- GParamSpec* pspec;
- GType type;
- const gchar* property;
- gboolean saved;
-
- key_file = g_key_file_new ();
- class = G_OBJECT_GET_CLASS (settings);
- pspecs = g_object_class_list_properties (class, &n_properties);
- for (i = 0; i < n_properties; i++)
- {
- pspec = pspecs[i];
- type = G_PARAM_SPEC_TYPE (pspec);
- property = g_param_spec_get_name (pspec);
- if (!(pspec->flags & G_PARAM_WRITABLE))
- continue;
- if (type == G_TYPE_PARAM_STRING)
- {
- gchar* string;
- const gchar* def_string = G_PARAM_SPEC_STRING (pspec)->default_value;
- if (!strcmp (property, "user-stylesheet-uri"))
- {
- const gchar* user_stylesheet_uri = g_object_get_data (G_OBJECT (settings), property);
- if (user_stylesheet_uri)
- {
- g_key_file_set_string (key_file, "settings", property,
- user_stylesheet_uri);
- }
- else
- g_key_file_remove_key (key_file, "settings", property, NULL);
- continue;
- }
-
- g_object_get (settings, property, &string, NULL);
- if (!def_string)
- def_string = "";
- if (strcmp (string ? string : "", def_string))
- g_key_file_set_string (key_file, "settings", property, string ? string : "");
- g_free (string);
- }
- else if (type == G_TYPE_PARAM_INT)
- {
- gint integer;
- g_object_get (settings, property, &integer, NULL);
- if (integer != G_PARAM_SPEC_INT (pspec)->default_value)
- g_key_file_set_integer (key_file, "settings", property, integer);
- }
- else if (type == G_TYPE_PARAM_UINT)
- {
- guint integer;
- g_object_get (settings, property, &integer, NULL);
- if (integer != G_PARAM_SPEC_UINT (pspec)->default_value)
- g_key_file_set_integer (key_file, "settings", property, integer);
- }
- else if (type == G_TYPE_PARAM_DOUBLE)
- {
- gdouble number;
- g_object_get (settings, property, &number, NULL);
- if (number != G_PARAM_SPEC_DOUBLE (pspec)->default_value)
- g_key_file_set_double (key_file, "settings", property, number);
- }
- else if (type == G_TYPE_PARAM_FLOAT)
- {
- gfloat number;
- g_object_get (settings, property, &number, NULL);
- if (number != G_PARAM_SPEC_FLOAT (pspec)->default_value)
- g_key_file_set_double (key_file, "settings", property, number);
- }
- else if (type == G_TYPE_PARAM_BOOLEAN)
- {
- gboolean truth;
- g_object_get (settings, property, &truth, NULL);
- if (truth != G_PARAM_SPEC_BOOLEAN (pspec)->default_value)
- g_key_file_set_boolean (key_file, "settings", property, truth);
- }
- else if (type == G_TYPE_PARAM_ENUM)
- {
- GEnumClass* enum_class = G_ENUM_CLASS (
- g_type_class_peek (pspec->value_type));
- gint integer;
- GEnumValue* enum_value;
- g_object_get (settings, property, &integer, NULL);
- enum_value = g_enum_get_value (enum_class, integer);
- if (integer != G_PARAM_SPEC_ENUM (pspec)->default_value)
- g_key_file_set_string (key_file, "settings", property,
- enum_value->value_name);
- }
- else
- g_warning (_("Invalid configuration value '%s'"), property);
- }
- g_free (pspecs);
-
- if (app != NULL)
- {
- /* Take frozen list of active extensions until preferences reset it */
- gchar** _extensions;
- KatzeArray* extensions;
- if ((_extensions = g_object_get_data (G_OBJECT (app), "extensions")))
- {
- i = 0;
- while (_extensions[i])
- g_key_file_set_boolean (key_file, "extensions", _extensions[i++], TRUE);
- }
- else if ((extensions = katze_object_get_object (app, "extensions")))
- {
- MidoriExtension* extension;
- KATZE_ARRAY_FOREACH_ITEM (extension, extensions)
- if (midori_extension_is_active (extension))
- {
- const gchar* extension_filename = g_object_get_data (G_OBJECT (extension), "filename");
- g_return_val_if_fail (extension_filename != NULL, FALSE);
- if (extension_filename && strchr (extension_filename, '/'))
- g_warning ("%s: %s unexpected /", G_STRFUNC, extension_filename);
- gchar* key = katze_object_get_string (extension, "key");
- gchar* subname = key ? g_strdup_printf ("%s/%s", extension_filename, key) : g_strdup (extension_filename);
- g_key_file_set_boolean (key_file, "extensions", subname, TRUE);
- g_free (key);
- g_free (subname);
- }
- g_object_unref (extensions);
- }
- }
-
- saved = sokoke_key_file_save_to_file (key_file, filename, error);
- g_key_file_free (key_file);
- return saved;
-}
diff --git a/midori/midori-websettings.h b/midori/midori-websettings.h
deleted file mode 100644
index a56bd613..00000000
--- a/midori/midori-websettings.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- Copyright (C) 2008-2013 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 __MIDORI_WEB_SETTINGS_H__
-#define __MIDORI_WEB_SETTINGS_H__
-
-#include <katze/katze.h>
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_WEB_SETTINGS \
- (midori_web_settings_get_type ())
-#define MIDORI_WEB_SETTINGS(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_WEB_SETTINGS, MidoriWebSettings))
-#define MIDORI_WEB_SETTINGS_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_WEB_SETTINGS, MidoriWebSettingsClass))
-#define MIDORI_IS_WEB_SETTINGS(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_WEB_SETTINGS))
-#define MIDORI_IS_WEB_SETTINGS_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_WEB_SETTINGS))
-#define MIDORI_WEB_SETTINGS_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_WEB_SETTINGS, MidoriWebSettingsClass))
-
-typedef struct _MidoriWebSettings MidoriWebSettings;
-typedef struct _MidoriWebSettingsClass MidoriWebSettingsClass;
-
-enum
-{
- MIDORI_CLEAR_NONE = 0,
- MIDORI_CLEAR_HISTORY = 1,
- MIDORI_CLEAR_COOKIES = 2, /* deprecated */
- MIDORI_CLEAR_FLASH_COOKIES = 4, /* deprecated */
- MIDORI_CLEAR_WEBSITE_ICONS = 8, /* deprecated */
- MIDORI_CLEAR_TRASH = 16, /* deprecated */
- MIDORI_CLEAR_ON_QUIT = 32,
- MIDORI_CLEAR_WEB_CACHE = 64, /* deprecated */
- MIDORI_CLEAR_SESSION = 128,
-};
-
-/* values >= MIDORI_STARTUP_LAST_OPEN_PAGES mean session is saved */
-typedef enum
-{
- MIDORI_STARTUP_BLANK_PAGE, /* One blank tab or speed dial is opened */
- MIDORI_STARTUP_HOMEPAGE, /* One homepage tab is opened */
- MIDORI_STARTUP_LAST_OPEN_PAGES, /* The session is loaded and saved */
- MIDORI_STARTUP_DELAYED_PAGES /* The session is saved, loading pages is delayed */
-} MidoriStartup;
-
-GType
-midori_startup_get_type (void) G_GNUC_CONST;
-
-#define MIDORI_TYPE_STARTUP \
- (midori_startup_get_type ())
-
-typedef enum
-{
- MIDORI_NEWTAB_BLANK_PAGE,
- MIDORI_NEWTAB_HOMEPAGE,
- MIDORI_NEWTAB_SEARCH,
- MIDORI_NEWTAB_SPEED_DIAL,
- MIDORI_NEWTAB_CUSTOM,
-} MidoriNewTabType;
-
-GType
-midori_newtab_get_type (void) G_GNUC_CONST;
-
-#define MIDORI_TYPE_NEWTAB \
- (midori_newtab_get_type ())
-
-typedef enum
-{
- MIDORI_ENCODING_CHINESE /* Traditional */,
- MIDORI_ENCODING_CHINESE_SIMPLIFIED,
- MIDORI_ENCODING_JAPANESE,
- MIDORI_ENCODING_KOREAN,
- MIDORI_ENCODING_RUSSIAN,
- MIDORI_ENCODING_UNICODE,
- MIDORI_ENCODING_WESTERN,
- MIDORI_ENCODING_CUSTOM
-} MidoriPreferredEncoding;
-
-GType
-midori_preferred_encoding_get_type (void) G_GNUC_CONST;
-
-#define MIDORI_TYPE_PREFERRED_ENCODING \
- (midori_preferred_encoding_get_type ())
-
-typedef enum
-{
- MIDORI_NEW_PAGE_TAB,
- MIDORI_NEW_PAGE_WINDOW,
- MIDORI_NEW_PAGE_CURRENT
-} MidoriNewPage;
-
-GType
-midori_new_page_get_type (void) G_GNUC_CONST;
-
-#define MIDORI_TYPE_NEW_PAGE \
- (midori_new_page_get_type ())
-
-typedef enum
-{
- MIDORI_TOOLBAR_DEFAULT,
- MIDORI_TOOLBAR_ICONS,
- MIDORI_TOOLBAR_SMALL_ICONS,
- MIDORI_TOOLBAR_TEXT,
- MIDORI_TOOLBAR_BOTH,
- MIDORI_TOOLBAR_BOTH_HORIZ
-} MidoriToolbarStyle;
-
-GType
-midori_toolbar_style_get_type (void) G_GNUC_CONST;
-
-#define MIDORI_TYPE_TOOLBAR_STYLE \
- (midori_toolbar_style_get_type ())
-
-typedef enum
-{
- MIDORI_PROXY_AUTOMATIC,
- MIDORI_PROXY_HTTP,
- MIDORI_PROXY_NONE
-} MidoriProxy;
-
-GType
-midori_proxy_get_type (void) G_GNUC_CONST;
-
-#define MIDORI_TYPE_PROXY \
- (midori_proxy_get_type ())
-
-typedef enum
-{
- MIDORI_IDENT_MIDORI /* Automatic */,
- MIDORI_IDENT_GENUINE /* Midori */,
- MIDORI_IDENT_CHROME,
- MIDORI_IDENT_SAFARI,
- MIDORI_IDENT_IPHONE,
- MIDORI_IDENT_FIREFOX,
- MIDORI_IDENT_EXPLORER,
- MIDORI_IDENT_CUSTOM,
-} MidoriIdentity;
-
-GType
-midori_identity_get_type (void) G_GNUC_CONST;
-
-#define MIDORI_TYPE_IDENTITY \
- (midori_identity_get_type ())
-
-GType
-midori_web_settings_get_type (void) G_GNUC_CONST;
-
-MidoriWebSettings*
-midori_web_settings_new (void);
-
-void
-midori_web_settings_add_style (MidoriWebSettings* settings,
- const gchar* rule_id,
- const gchar* style);
-
-void
-midori_web_settings_remove_style (MidoriWebSettings* settings,
- const gchar* rule_id);
-
-const gchar*
-midori_web_settings_get_system_name (gchar** architecture,
- gchar** platform);
-
-gboolean
-midori_web_settings_has_plugin_support (void);
-
-gboolean
-midori_web_settings_skip_plugin (const gchar* path);
-
-typedef enum
-{
- MIDORI_SITE_DATA_UNDETERMINED,
- MIDORI_SITE_DATA_BLOCK,
- MIDORI_SITE_DATA_ACCEPT,
- MIDORI_SITE_DATA_PRESERVE,
-} MidoriSiteDataPolicy;
-
-MidoriSiteDataPolicy
-midori_web_settings_get_site_data_policy (MidoriWebSettings* settings,
- const gchar* uri);
-
-MidoriWebSettings*
-midori_settings_new_full (gchar*** extensions);
-
-gboolean
-midori_settings_save_to_file (MidoriWebSettings* settings,
- GObject* app,
- const gchar* filename,
- GError** error);
-
-G_END_DECLS
-
-#endif /* __MIDORI_WEB_SETTINGS_H__ */
diff --git a/midori/midori-window.vala b/midori/midori-window.vala
deleted file mode 100644
index 2bd9f760..00000000
--- a/midori/midori-window.vala
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- Copyright (C) 2015 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.
-*/
-
-namespace Midori {
- public class Window : Gtk.Window {
- Gtk.Widget? _toolbar = null;
- public Gtk.Widget? toolbar { get {
- if (_toolbar == null) {
-#if HAVE_GTK3
- if (strcmp (Environment.get_variable ("GTK_CSD"), "1") == 0) {
- var toolbar = new Gtk.HeaderBar ();
- toolbar.show_close_button = true;
- toolbar.show ();
- toolbar.get_style_context ().add_class ("midori-titlebar");
- _toolbar = toolbar;
- return _toolbar;
- }
-#endif
- var toolbar = new Gtk.Toolbar ();
- toolbar.show_arrow = true;
-#if HAVE_GTK3
- toolbar.get_style_context ().add_class ("primary-toolbar");
-#endif
- toolbar.popup_context_menu.connect ((x, y, button) => {
- return button == 3 && context_menu (toolbar); });
- _toolbar = toolbar;
- }
- return _toolbar;
- } }
-
- public string actions { get; set; default = ""; }
- string extra_actions { get; set; default = ""; }
- List<Gtk.ActionGroup> action_groups;
- public signal bool context_menu (Gtk.Widget widget, Gtk.Action? action=null);
- Gtk.Box? box = null;
- List<Gtk.Widget> toolbars;
-
- Gtk.Widget? _contents = null;
- public Gtk.Widget? contents { get {
- return _contents;
- } set {
- if (_contents != null)
- box.remove (_contents);
- _contents = value;
- _contents.show ();
- if (box != null)
- box.pack_end (_contents, true, true, 0);
- } }
-
- public void add_action_group (Gtk.ActionGroup action_group) {
- action_groups.append (action_group);
- }
-
- public bool show_menubar { get; set; default = false; }
-
- [CCode (type = "GtkWidget*")]
- public Window () {
- }
-
- public Gtk.ToolItem? get_tool_item (string name) {
- /* Name is the empty string if actions has ,, or trailing , */
- if (name == "")
- return null;
- /* Shown in the notebook, no need to include in the toolbar */
- if (name == "TabNew")
- return null;
- foreach (unowned Gtk.ActionGroup action_group in action_groups) {
- var action = action_group.get_action (name);
- if (action != null) {
- return create_tool_item (action);
- }
- }
- warning ("Action %s not known to Window", name);
- return null;
- }
-
- Gtk.ToolItem create_tool_item (Gtk.Action action) {
- var toolitem = (Gtk.ToolItem)action.create_tool_item ();
- /* Show label if button has no icon of any kind */
- if (action.icon_name == null && action.stock_id == null && action.gicon == null)
- toolitem.is_important = true;
- toolitem.get_child ().button_press_event.connect ((event) => {
- return event.button == 3 && context_menu (toolitem, action); });
- if (action.name == "CompactMenu")
- {
- toolitem.visible = !show_menubar;
- bind_property ("show-menubar", toolitem, "visible",
- BindingFlags.DEFAULT | BindingFlags.INVERT_BOOLEAN);
- }
- return toolitem;
- }
-
- /**
- * Adds an action to the (browser) window.
- * Typically it will be displayed in the primary toolbar or headerbar.
- *
- * If @action is a ContextAction a menu will be displayed.
- *
- * Since: 0.6.0
- **/
- public void add_action (Gtk.Action action) {
- action_groups.nth_data (0).add_action (action);
- extra_actions += "," + action.name;
- update_toolbar ();
- }
-
- /**
- * Remove an action from the (browser) window.
- *
- * Since: 0.6.0
- **/
- public void remove_action (Gtk.Action action) {
- action_groups.nth_data (0).remove_action (action);
- extra_actions = extra_actions.replace ("," + action.name, "");
- update_toolbar ();
- }
-
- void update_toolbar () {
- var container = (Gtk.Container)_toolbar;
- foreach (unowned Gtk.Widget toolitem in container.get_children ())
- container.remove (toolitem);
-
- /* Always include app menu (visible depending on menubar) and extensions. */
- string all_actions;
- if ("CompactMenu" in actions)
- all_actions = actions.replace ("CompactMenu", extra_actions + ",CompactMenu");
- else
- all_actions = actions + "," + extra_actions + ",CompactMenu";
- string[] names = all_actions.split (",");
-
-#if HAVE_GTK3
- var headerbar = _toolbar as Gtk.HeaderBar;
- if (headerbar != null) {
- var tail = new List<Gtk.ToolItem> ();
- foreach (unowned string name in names) {
- var toolitem = get_tool_item (name);
- if (toolitem == null)
- continue;
- var widget = toolitem.get_child ();
- if (widget is Gtk.Alignment)
- widget = ((Gtk.Bin)widget).get_child ();
- if (name == "Location") {
- widget.set ("margin-top", 1, "margin-bottom", 1);
- ((Gtk.Entry)widget).width_chars = 36;
- headerbar.custom_title = toolitem;
- headerbar.custom_title.set (
- "margin-start", 25, "margin-end", 25,
- "margin-top", 5, "margin-bottom", 5);
- } else if (name == "Search") {
- ((Gtk.Entry)widget).width_chars = 12;
- tail.append (toolitem);
- } else if (all_actions.index_of (name) > all_actions.index_of ("Location"))
- tail.append (toolitem);
- else
- headerbar.pack_start (toolitem);
- }
-
- /* Pack end appends, so we need to pack in reverse order */
- tail.reverse ();
- foreach (unowned Gtk.ToolItem toolitem in tail)
- headerbar.pack_end (toolitem);
-
- set_titlebar (headerbar);
- return;
- }
-#endif
-
- var toolbar = (Gtk.Toolbar)_toolbar;
- string? previous = null;
- Gtk.ToolItem? toolitem_previous = null;
- foreach (unowned string name in names) {
- var toolitem = get_tool_item (name);
- if (toolitem == null)
- continue;
- if ((name == "Location" || name == "Search")
- && (previous == "Location" || previous == "Search")) {
- toolitem_previous.ref ();
- toolbar.remove (toolitem_previous);
- var paned = new Midori.PanedAction ();
- paned.set_child1 (toolitem_previous, previous, previous != "Search", true);
- paned.set_child2 (toolitem, name, name != "Search", true);
- /* Midori.Settings.search-width on Midori.Browser.settings */
- Midori.Settings? settings = null;
- get ("settings", ref settings);
- var sizeable = name == "Search" ? toolitem : toolitem_previous;
- sizeable.size_allocate.connect ((allocation) => {
- settings.set ("search-width", allocation.width);
- });
- var requester = previous == "Search" ? toolitem_previous : toolitem;
- requester.set_size_request (settings.search_width, -1);
- toolitem = (Gtk.ToolItem)paned.create_tool_item ();
- previous = null;
- toolitem_previous.unref ();
- toolitem_previous = null;
- } else {
- previous = name;
- toolitem_previous = toolitem;
- }
- toolbar.insert (toolitem, -1);
- }
- }
-
- public void add_toolbar (Gtk.Widget toolbar) {
- var _toolbar = toolbar as Gtk.Toolbar;
- if (_toolbar != null) {
-#if HAVE_GTK3
- get_style_context ().add_class ("secondary-toolbar");
-#endif
- _toolbar.popup_context_menu.connect ((x, y, button) => {
- return button == 3 && context_menu (toolbar);
- });
- }
- if (box == null)
- toolbars.append (toolbar);
- else
- box.pack_start (toolbar, false, false);
- }
-
- construct {
- box = new Gtk.VBox (false, 0);
- box.show ();
- add (box);
- foreach (unowned Gtk.Widget toolbar in toolbars) {
- if (toolbar is Gtk.MenuBar)
- box.pack_start (toolbar, false, false);
- }
- if (toolbar is Gtk.Toolbar)
- box.pack_start (toolbar, false, false);
- foreach (unowned Gtk.Widget toolbar in toolbars) {
- if (!(toolbar is Gtk.MenuBar))
- box.pack_start (toolbar, false, false);
- }
- if (_contents != null)
- box.pack_end (_contents, true, true, 0);
- if (actions != "")
- update_toolbar ();
- notify["actions"].connect ((pspec) => { update_toolbar (); });
- }
- }
-}
diff --git a/midori/midori.h b/midori/midori.h
deleted file mode 100644
index 51403c6f..00000000
--- a/midori/midori.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Copyright (C) 2008-2009 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 __MIDORI_H__
-#define __MIDORI_H__
-
-#include "midori-app.h"
-#include "midori-array.h"
-#include "midori-bookmarks-db.h"
-#include "midori-browser.h"
-#include "midori-extension.h"
-#include "midori-frontend.h"
-#include "midori-locationaction.h"
-#include "midori-panel.h"
-#include "midori-preferences.h"
-#include "midori-privatedata.h"
-#include "midori-searchaction.h"
-#include "midori-view.h"
-#include "midori-websettings.h"
-#include "midori-platform.h"
-#include <midori/midori-core.h> /* Vala API */
-
-/* For convenience, include localization header */
-#include <glib/gi18n-lib.h>
-
-#define MIDORI_CHECK_VERSION(major, minor, micro) \
- (MIDORI_MAJOR_VERSION > (major) || \
- (MIDORI_MAJOR_VERSION == (major) && MIDORI_MINOR_VERSION > (minor)) || \
- (MIDORI_MAJOR_VERSION == (major) && MIDORI_MINOR_VERSION == (minor) && \
- MIDORI_MICRO_VERSION >= (micro)))
-
-#endif /* __MIDORI_H__ */
diff --git a/midori/midori.vapi b/midori/midori.vapi
deleted file mode 100644
index a5659370..00000000
--- a/midori/midori.vapi
+++ /dev/null
@@ -1,295 +0,0 @@
-/* Copyright (C) 2010 Christian Dywan <christian@twotoasts.de>
- This file is licensed under the terms of the expat license, see the file EXPAT. */
-
-public const string PACKAGE_NAME;
-
-[CCode (cprefix = "Midori", lower_case_cprefix = "midori_")]
-namespace Midori {
- public const string VERSION_SUFFIX;
- [CCode (cheader_filename = "midori/midori-stock.h")]
- namespace Stock {
- public const string WEB_BROWSER;
- public const string TRANSFER;
- public const string PLUGINS;
- }
-
- [CCode (cheader_filename = "midori/midori-frontend.h")]
- public static unowned Midori.Browser web_app_new (
- string webapp, [CCode (array_length = false)] string[]? uris, [CCode (array_length = false)] string[]? commands, int reset, string? block);
- public static unowned Midori.Browser private_app_new (string? config,
- string? webapp, [CCode (array_length = false)] string[]? uris, [CCode (array_length = false)] string[]? commands, int reset, string? block);
- public static unowned App normal_app_new (string? config, string nickname, bool diagnostic,
- [CCode (array_length = false)] string[]? uris, [CCode (array_length = false)] string[]? commands, int reset, string? block);
- public static void normal_app_on_quit (App app);
-
- [CCode (cheader_filename = "midori/midori-array.h")]
- public static bool array_from_file (Katze.Array array, string filename, string format) throws GLib.Error;
-
- [CCode (cheader_filename = "midori/midori-app.h")]
- public class App : GLib.Object {
- public App (string? name=null);
- public static void setup ([CCode (array_length_pos = 0.9)] ref unowned string[] args, [CCode (array_length = false)] GLib.OptionEntry[]? entries);
- public static void set_instance_is_running (bool is_running);
- public Browser create_browser ();
- public GLib.List<weak Browser> get_browsers ();
- public void send_notification (string title, string message);
- public bool send_command ([CCode (array_length = false)] string[] command);
-
- [NoAccessorMethod]
- public string name { get; set; }
- [NoAccessorMethod]
- public Midori.WebSettings settings { owned get; set; }
- [NoAccessorMethod]
- public Katze.Array bookmarks { get; set; }
- [NoAccessorMethod]
- public Katze.Array trash { get; set; }
- [NoAccessorMethod]
- public Katze.Array search_engines { get; set; }
- [NoAccessorMethod]
- public Katze.Array history { get; set; }
- [NoAccessorMethod]
- public Katze.Array extensions { owned get; set; }
- [NoAccessorMethod]
- public Katze.Array browsers { get; }
- public Browser? browser { get; }
- public bool crashed { get; }
-
- [HasEmitter]
- public signal void add_browser (Browser browser);
- public signal void remove_browser (Browser browser);
- [HasEmitter]
- public signal void quit ();
- }
-
- [CCode (cheader_filename = "midori/midori-browser.h")]
- public class Browser : Window {
- public Browser ();
- public unowned Gtk.Widget add_item (Katze.Item item);
- public unowned Gtk.Widget add_uri (string uri);
- public unowned View get_nth_tab (int n);
- public GLib.List<weak View> get_tabs ();
- public void block_action (Gtk.Action action);
- public void unblock_action (Gtk.Action action);
- public unowned Gtk.ActionGroup get_action_group ();
- public static unowned Browser get_for_widget (Gtk.Widget widget);
- public unowned string[] get_toolbar_actions ();
- public Katze.Array proxy_array { get; }
-
- [NoAccessorMethod]
- public Gtk.MenuBar menubar { owned get; }
- [NoAccessorMethod]
- public Gtk.Toolbar navigationbar { owned get; }
- [NoAccessorMethod]
- public Gtk.Notebook notebook { owned get; }
- [NoAccessorMethod]
- public Midori.Panel panel { owned get; }
- [NoAccessorMethod]
- public string uri { owned get; set; }
- public Gtk.Widget? tab { get; set; }
- [NoAccessorMethod]
- public uint load_status { get; }
- [NoAccessorMethod]
- public Gtk.Statusbar statusbar { owned get; }
- [NoAccessorMethod]
- public string statusbar_text { owned get; set; }
- [NoAccessorMethod]
- public Midori.WebSettings settings { owned get; set; }
- [NoAccessorMethod]
- public Katze.Array? bookmarks { owned get; set; }
- [NoAccessorMethod]
- public Katze.Array? trash { owned get; set; }
- [NoAccessorMethod]
- public Katze.Array? search_engines { owned get; set; }
- [NoAccessorMethod]
- public Katze.Array? history { owned get; set; }
- [NoAccessorMethod]
- public bool show_tabs { get; set; }
-
- public signal Browser new_window (Browser? browser);
- [HasEmitter]
- public signal void add_tab (View tab);
- public signal void remove_tab (View tab);
- public void close_tab (View tab);
- public signal void switch_tab (View? old_view, View? new_view);
- [HasEmitter]
- public signal void activate_action (string name);
- public signal void add_download (WebKit.Download download);
- public signal void populate_tool_menu (Gtk.Menu menu);
- [HasEmitter]
- public signal void quit ();
- public signal void send_notification (string title, string message);
- public static void update_history (Katze.Item item, string type, string event);
- public signal void show_preferences (Katze.Preferences preferences);
- }
-
- [CCode (cheader_filename = "midori/midori-panel.h")]
- public class Panel : Gtk.HBox {
- public Panel ();
- public int append_page (Midori.Viewable viewable);
- }
-
- [CCode (cheader_filename = "midori/midori-extension.h")]
- public class Extension : GLib.Object {
- [CCode (has_construct_function = false)]
- public Extension ();
- public unowned Midori.App get_app ();
-
- public void install_boolean (string name, bool default_value);
- public void install_integer (string name, int default_value);
- public void install_string (string name, string default_value);
- public void install_string_list (string name, string[]? default_value);
-
- public bool get_boolean (string name);
- public int get_integer (string name);
- public unowned string get_string (string name);
-
- public void set_boolean (string name, bool value);
- public void set_integer (string name, int value);
- public void set_string (string name, string value);
- public unowned string get_config_dir ();
-
- [NoAccessorMethod]
- public string? stock_id { get; set; }
- [NoAccessorMethod]
- public string name { owned get; set; }
- [NoAccessorMethod]
- public string description { owned get; set; }
- [NoAccessorMethod]
- public bool use_markup { get; set; }
- [NoAccessorMethod]
- public string version { owned get; set; }
- [NoAccessorMethod]
- public string authors { owned get; set; }
- [NoAccessorMethod]
- public string website { owned get; set; }
- [NoAccessorMethod]
- public string key { owned get; set; }
-
- public signal void activate (Midori.App app);
- public bool is_prepared ();
- public bool is_active ();
- public signal void deactivate ();
- public signal void open_preferences ();
-
- public static void load_from_folder (Midori.App app, [CCode (array_length = false)] string[]? keys, bool activate);
- }
-
- [CCode (cheader_filename = "midori/midori-view.h")]
- public class View : Tab {
- [CCode (type = "GtkWidget*")]
- public View.with_title (string? title=null, WebSettings? settings=null
- , bool append=false);
- public void set_uri (string uri);
- public void set_html (string data, string? uri=null, GLib.Object? frame=null);
- public unowned string get_display_uri ();
- public unowned string get_display_title ();
- public unowned string get_icon_uri ();
- public unowned string get_link_uri ();
- public bool has_selection ();
- public unowned string get_selected_text ();
- public Gtk.MenuItem get_proxy_menu_item ();
- public Gtk.Widget duplicate ();
- public Gtk.Menu get_tab_menu ();
- public Pango.EllipsizeMode get_label_ellipsize ();
- public Gtk.Label get_proxy_tab_label ();
- public unowned Katze.Item get_proxy_item ();
- public void search_text (string text, bool case_sensitive, bool forward);
- public bool execute_script (string script, out string exception);
- public Gdk.Pixbuf get_snapshot (int width, int height);
- public void populate_popup (Gtk.Menu menu, bool manual);
- public void reload (bool from_cache);
- public Gtk.Widget add_info_bar (Gtk.MessageType type, string message, GLib.Callback? callback, void* object, ...);
- public ContextAction get_page_context_action (WebKit.HitTestResult hit_test_result);
-
- public void list_plugins (GLib.StringBuilder ns_plugins, bool html);
- public void list_video_formats (GLib.StringBuilder formats, bool html);
- public static void list_versions (GLib.StringBuilder markup, bool html);
-
- public string title { get; }
- public Gdk.Pixbuf icon { get; }
- public float zoom_level { get; }
- public Katze.Array news_feeds { get; }
- [NoAccessorMethod]
- public WebSettings settings { owned get; set; }
- public GLib.Object net { get; }
-
- [HasEmitter]
- public signal bool download_requested (WebKit.Download download);
- public signal bool about_content (string uri);
- public signal void new_view (Midori.View new_view, Midori.NewView where, bool user_initiated);
- }
-
- [CCode (cheader_filename = "midori/midori-locationaction.h")]
- public class LocationAction : Gtk.Action {
- public static string render_uri ([CCode (array_length = false)] string[] keys, string uri_escaped);
- public static string render_title ([CCode (array_length = false)] string[] keys, string title);
-
- public double progress { get; set; }
- public string secondary_icon { get; set; }
-
- public unowned string get_text ();
- public void set_text (string text);
-
- public signal void submit_uri (string uri, bool new_tab);
- public signal bool key_press_event (Gdk.EventKey event);
- }
-
- [CCode (cheader_filename = "midori/midori-searchaction.h")]
- public class SearchAction : Gtk.Action {
- public static Katze.Item? get_engine_for_form (WebKit.WebView web_view, Pango.EllipsizeMode ellipsize);
- public static string token_for_uri (string uri);
- }
-
- [CCode (cheader_filename = "midori/midori-view.h", cprefix = "MIDORI_DOWNLOAD_")]
- public enum DownloadType {
- CANCEL,
- OPEN,
- SAVE,
- SAVE_AS,
- OPEN_IN_VIEWER
- }
-
- [CCode (cheader_filename = "midori/midori-view.h", cprefix = "MIDORI_DELAY_")]
- public enum Delay {
- UNDELAYED,
- DELAYED,
- PENDING_UNDELAY,
- }
-
- [CCode (cheader_filename = "midori/midori-websettings.h")]
- public class WebSettings : Midori.Settings {
- public WebSettings ();
- [NoAccessorMethod]
- public MidoriStartup load_on_startup { get; set; }
- public static bool has_plugin_support ();
- public static bool skip_plugin (string path);
- public static unowned string get_system_name (out unowned string? architecture, out unowned string? platform);
- }
-
- [CCode (cheader_filename = "midori/midori-websettings.h", cprefix = "MIDORI_STARTUP_")]
- public enum MidoriStartup {
- BLANK_PAGE,
- HOMEPAGE,
- LAST_OPEN_PAGES,
- DELAYED_PAGES
- }
-
- [CCode (cheader_filename = "midori/sokoke.h", lower_case_cprefix = "sokoke_")]
- namespace Sokoke {
- public static string magic_uri (string uri, bool allow_search, bool allow_relative);
- public static uint gtk_action_count_modifiers (Gtk.Action action);
- #if HAVE_WIN32
- public static string get_win32_desktop_lnk_path_for_filename (string filename);
- public static void create_win32_desktop_lnk (string prefix, string filename, string uri);
- #endif
- }
-
- #if HAVE_EXECINFO_H
- [CCode (lower_case_cprefix = "")]
- namespace Linux {
- [CCode (cheader_filename = "execinfo.h", array_length = false)]
- public unowned string[] backtrace_symbols (void* buffer, int size);
- }
- #endif
-}
-
diff --git a/midori/sokoke.c b/midori/sokoke.c
deleted file mode 100644
index 7db1517e..00000000
--- a/midori/sokoke.c
+++ /dev/null
@@ -1,1021 +0,0 @@
-/*
- Copyright (C) 2007-2013 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2009 Dale Whittaker <dayul@users.sf.net>
- Copyright (C) 2009 Alexander Butenko <a.butenka@gmail.com>
-
- 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.
-*/
-
-#include "sokoke.h"
-
-#include "midori-core.h"
-#include "midori-platform.h"
-#include "midori-app.h"
-
-#include <config.h>
-#if HAVE_UNISTD_H
- #include <unistd.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef GDK_WINDOWING_X11
- #include <gdk/gdkx.h>
-#endif
-
-#include <gdk/gdkkeysyms.h>
-#include <glib/gi18n.h>
-#include <glib/gprintf.h>
-#include <glib/gstdio.h>
-#include "katze/katze.h"
-
-#ifdef G_OS_WIN32
-#include <windows.h>
-#include <shlobj.h>
-#include <gdk/gdkwin32.h>
-#endif
-
-static gchar*
-sokoke_js_string_utf8 (JSStringRef js_string)
-{
- size_t size_utf8;
- gchar* string_utf8;
-
- g_return_val_if_fail (js_string, NULL);
-
- size_utf8 = JSStringGetMaximumUTF8CStringSize (js_string);
- string_utf8 = g_new (gchar, size_utf8);
- JSStringGetUTF8CString (js_string, string_utf8, size_utf8);
- return string_utf8;
-}
-
-gchar*
-sokoke_js_script_eval (JSContextRef js_context,
- const gchar* script,
- gchar** exception)
-{
- JSGlobalContextRef temporary_context = NULL;
- gchar* value;
- JSStringRef js_value_string;
- JSStringRef js_script;
- JSValueRef js_exception = NULL;
- JSValueRef js_value;
-
- g_return_val_if_fail (script, FALSE);
-
- if (!js_context)
- js_context = temporary_context = JSGlobalContextCreateInGroup (NULL, NULL);
-
- js_script = JSStringCreateWithUTF8CString (script);
- js_value = JSEvaluateScript (js_context, js_script,
- JSContextGetGlobalObject (js_context), NULL, 0, &js_exception);
- JSStringRelease (js_script);
-
- if (!js_value)
- {
- JSStringRef js_message = JSValueToStringCopy (js_context,
- js_exception, NULL);
- g_return_val_if_fail (js_message != NULL, NULL);
-
- value = sokoke_js_string_utf8 (js_message);
- if (exception)
- *exception = value;
- else
- {
- g_warning ("%s", value);
- g_free (value);
- }
- JSStringRelease (js_message);
- if (temporary_context)
- JSGlobalContextRelease (temporary_context);
- return NULL;
- }
-
- js_value_string = JSValueToStringCopy (js_context, js_value, NULL);
- value = sokoke_js_string_utf8 (js_value_string);
- JSStringRelease (js_value_string);
- if (temporary_context)
- JSGlobalContextRelease (temporary_context);
- return value;
-}
-
-void
-sokoke_message_dialog (GtkMessageType message_type,
- const gchar* short_message,
- const gchar* detailed_message,
- gboolean modal)
-{
- midori_show_message_dialog (message_type, short_message, detailed_message, modal);
-}
-
-GAppInfo*
-sokoke_default_for_uri (const gchar* uri,
- gchar** scheme_ptr)
-{
- gchar* scheme;
- GAppInfo* info;
-
- scheme = g_uri_parse_scheme (uri);
- if (!scheme)
- return NULL;
-
- info = g_app_info_get_default_for_uri_scheme (scheme);
- if (scheme_ptr != NULL)
- *scheme_ptr = scheme;
- else
- g_free (scheme);
- return info;
-
-}
-
-/**
- * sokoke_prepare_command:
- * @command: the command, properly quoted
- * @argument: any arguments, properly quoted
- * @quote_command: if %TRUE, @command will be quoted
- * @quote_argument: if %TRUE, @argument will be quoted, ie. a URI or filename
- *
- * If @command contains %s, @argument will be quoted and inserted into
- * @command, which is left unquoted regardless of @quote_command.
- *
- * Return value: the command prepared for spawning
- **/
-gchar*
-sokoke_prepare_command (const gchar* command,
- gboolean quote_command,
- const gchar* argument,
- gboolean quote_argument)
-{
- g_return_val_if_fail (command != NULL, FALSE);
- g_return_val_if_fail (argument != NULL, FALSE);
-
- if (midori_debug ("paths"))
- g_print ("Preparing command: %s %d %s %d\n",
- command, quote_command, argument, quote_argument);
-
- {
- gchar* uri_format;
- gchar* real_command;
- gchar* command_ready;
-
- /* .desktop files accept %u, %U, %f, %F as URI/ filename, we treat it like %s */
- real_command = g_strdup (command);
- if ((uri_format = strstr (real_command, "%u"))
- || (uri_format = strstr (real_command, "%U"))
- || (uri_format = strstr (real_command, "%f"))
- || (uri_format = strstr (real_command, "%F")))
- uri_format[1] = 's';
-
-
- if (strstr (real_command, "%s"))
- {
- gchar* argument_quoted = quote_argument ? g_shell_quote (argument) : g_strdup (argument);
- command_ready = g_strdup_printf (real_command, argument_quoted);
- g_free (argument_quoted);
- }
- else if (quote_argument)
- {
- gchar* quoted_command = quote_command ? g_shell_quote (real_command) : g_strdup (real_command);
- gchar* argument_quoted = g_shell_quote (argument);
- command_ready = g_strconcat (quoted_command, " ", argument_quoted, NULL);
- g_free (argument_quoted);
- g_free (quoted_command);
- }
- else
- {
- gchar* quoted_command = quote_command ? g_shell_quote (real_command) : g_strdup (real_command);
- command_ready = g_strconcat (quoted_command, " ", argument, NULL);
- g_free (quoted_command);
- }
- g_free (real_command);
- return command_ready;
- }
-}
-
-/**
- * sokoke_spawn_program:
- * @command: the command, properly quoted
- * @argument: any arguments, properly quoted
- * @quote_command: if %TRUE, @command will be quoted
- * @quote_argument: if %TRUE, @argument will be quoted, ie. a URI or filename
- * @sync: spawn synchronously and wait for command to exit
- *
- * If @command contains %s, @argument will be quoted and inserted into
- * @command, which is left unquoted regardless of @quote_command.
- *
- * Return value: %TRUE on success, %FALSE if an error occurred
- **/
-gboolean
-sokoke_spawn_program (const gchar* command,
- gboolean quote_command,
- const gchar* argument,
- gboolean quote_argument,
- gboolean sync)
-{
- GError* error;
- gchar* command_ready;
- gchar** argv;
-
- g_return_val_if_fail (command != NULL, FALSE);
- g_return_val_if_fail (argument != NULL, FALSE);
-
- command_ready = sokoke_prepare_command (command, quote_command, argument, quote_argument);
- g_print ("Launching command: %s\n", command_ready);
-
- error = NULL;
- if (!g_shell_parse_argv (command_ready, NULL, &argv, &error))
- {
- sokoke_message_dialog (GTK_MESSAGE_ERROR,
- _("Could not run external program."),
- error->message, FALSE);
- g_error_free (error);
- g_free (command_ready);
- return FALSE;
- }
- g_free (command_ready);
-
- error = NULL;
- if (sync)
- g_spawn_sync (NULL, argv, NULL,
- (GSpawnFlags)G_SPAWN_SEARCH_PATH,
- NULL, NULL, NULL, NULL, NULL, &error);
- else
- g_spawn_async (NULL, argv, NULL,
- (GSpawnFlags)G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
- NULL, NULL, NULL, &error);
- if (error != NULL)
- {
- sokoke_message_dialog (GTK_MESSAGE_ERROR,
- _("Could not run external program."),
- error->message, FALSE);
- g_error_free (error);
- }
-
- g_strfreev (argv);
- return TRUE;
-}
-
-void
-sokoke_spawn_gdb (const gchar* gdb,
- gboolean sync)
-{
- gchar* args = midori_paths_get_command_line_str (FALSE);
- const gchar* runtime_dir = midori_paths_get_runtime_dir ();
- gchar* cmd = g_strdup_printf (
- "--batch -ex 'set print thread-events off' -ex run "
- "-ex 'set logging on %s/%s' -ex 'bt' --return-child-result "
- "--args %s",
- runtime_dir, "gdb.bt", args);
- sokoke_spawn_program (gdb, TRUE, cmd, FALSE, sync);
- g_free (cmd);
- g_free (args);
-}
-
-void
-sokoke_spawn_app (const gchar* uri,
- gboolean private)
-{
- const gchar* executable = midori_paths_get_command_line (NULL)[0];
- gchar* uri_quoted = g_shell_quote (uri);
- gchar* argument;
- if (private)
- {
- gchar* config_quoted = g_shell_quote (midori_paths_get_config_dir_for_reading ());
- argument = g_strconcat ("-c ", config_quoted,
- " -p ", uri_quoted, NULL);
- }
- else
- argument = g_strconcat ("-a ", uri_quoted, NULL);
- g_free (uri_quoted);
- sokoke_spawn_program (executable, TRUE, argument, FALSE, FALSE);
- g_free (argument);
-}
-
-static void
-sokoke_resolve_hostname_cb (SoupAddress *address,
- guint status,
- gpointer data)
-{
- if (status == SOUP_STATUS_OK)
- *(gint *)data = 1;
- else
- *(gint *)data = 2;
-}
-
-/**
- * sokoke_resolve_hostname
- * @hostname: a string typed by a user
- *
- * Takes a string that was typed by a user,
- * resolves the hostname, and returns the status.
- *
- * Return value: %TRUE if is a valid host, else %FALSE
- **/
-gboolean
-sokoke_resolve_hostname (const gchar* hostname)
-{
- gchar* uri;
- gint host_resolved = 0;
-
- uri = g_strconcat ("http://", hostname, NULL);
- if (sokoke_prefetch_uri (NULL, uri, G_CALLBACK (sokoke_resolve_hostname_cb),
- &host_resolved))
- {
- GTimer* timer = g_timer_new ();
- while (!host_resolved && g_timer_elapsed (timer, NULL) < 10)
- g_main_context_iteration (NULL, FALSE);
- g_timer_destroy (timer);
- }
- g_free (uri);
- return host_resolved == 1 ? TRUE : FALSE;
-}
-
-gboolean
-sokoke_external_uri (const gchar* uri)
-{
- GAppInfo* info;
-
- /* URI schemes are case-insensitive, followed by ':' - rfc3986 */
- if (!uri || !strncasecmp (uri, "http:", 5)
- || !strncasecmp (uri, "https:", 6)
- || !strncasecmp (uri, "file:", 5)
- || !strncasecmp (uri, "geo:", 4)
- || !strncasecmp (uri, "about:", 6))
- return FALSE;
-
- info = sokoke_default_for_uri (uri, NULL);
- if (info)
- g_object_unref (info);
- return info != NULL;
-}
-
-/**
- * sokoke_magic_uri:
- * @uri: a string typed by a user
- *
- * Takes a string that was typed by a user,
- * guesses what it is, and returns an URI.
- *
- * If it was a search, %NULL will be returned.
- *
- * Return value: a newly allocated URI, or %NULL
- **/
-gchar*
-sokoke_magic_uri (const gchar* uri,
- gboolean allow_search,
- gboolean allow_relative)
-{
- gchar** parts;
- gchar* search;
-
- g_return_val_if_fail (uri, NULL);
-
- /* Add file:// if we have a local path */
- if (g_path_is_absolute (uri))
- return g_filename_to_uri (uri, NULL, NULL);
- if (allow_relative
- && g_file_test (uri, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
- {
- GFile* file = g_file_new_for_commandline_arg (uri);
- gchar* uri_ready = g_file_get_uri (file);
- g_object_unref (file);
- return uri_ready;
- }
- /* Parse geo URI geo:48.202778,16.368472;crs=wgs84;u=40 as a location */
- if (!strncmp (uri, "geo:", 4))
- {
- gchar* comma;
- gchar* semicolon;
- gchar* latitude;
- gchar* longitude;
- gchar* geo;
-
- comma = strchr (&uri[4], ',');
- /* geo:latitude,longitude[,altitude][;u=u][;crs=crs] */
- if (!(comma && *comma))
- return g_strdup (uri);
- semicolon = strchr (comma + 1, ';');
- if (!semicolon)
- semicolon = strchr (comma + 1, ',');
- latitude = g_strndup (&uri[4], comma - &uri[4]);
- if (semicolon)
- longitude = g_strndup (comma + 1, semicolon - comma - 1);
- else
- longitude = g_strdup (comma + 1);
- geo = g_strdup_printf ("http://www.openstreetmap.org/?mlat=%s&mlon=%s",
- latitude, longitude);
- g_free (latitude);
- g_free (longitude);
- return geo;
- }
- if (midori_uri_is_location (uri) || sokoke_external_uri (uri))
- return g_strdup (uri);
- if (midori_uri_is_ip_address (uri))
- return g_strconcat ("http://", uri, NULL);
- search = NULL;
- if (!strchr (uri, ' ') &&
- ((search = strchr (uri, ':')) || (search = strchr (uri, '@'))) &&
- search[0] && g_ascii_isdigit (search[1]))
- return g_strconcat ("http://", uri, NULL);
- if ((!strcmp (uri, "localhost") || strchr (uri, '/'))
- && sokoke_resolve_hostname (uri))
- return g_strconcat ("http://", uri, NULL);
- if (!search)
- {
- parts = g_strsplit (uri, ".", 0);
- if (parts[0] && parts[1])
- {
- if (!(parts[1][1] == '\0' && !g_ascii_isalpha (parts[1][0])))
- if (!strchr (parts[0], ' ') && !strchr (parts[1], ' '))
- {
- search = g_strconcat ("http://", uri, NULL);
- g_strfreev (parts);
- return search;
- }
- }
- g_strfreev (parts);
- }
- if (!allow_search)
- midori_error (_("Invalid URI"));
- return NULL;
-}
-
-void sokoke_widget_set_visible (GtkWidget* widget, gboolean visible)
-{
- /* Show or hide the widget */
- if (visible)
- gtk_widget_show (widget);
- else
- gtk_widget_hide (widget);
-}
-
-typedef enum
-{
- SOKOKE_DESKTOP_UNTESTED,
- SOKOKE_DESKTOP_XFCE,
- SOKOKE_DESKTOP_OSX,
- SOKOKE_DESKTOP_UNKNOWN
-} SokokeDesktop;
-
-static SokokeDesktop
-sokoke_get_desktop (void)
-{
- #if HAVE_OSX
- return SOKOKE_DESKTOP_OSX;
- #elif defined (GDK_WINDOWING_X11)
- static SokokeDesktop desktop = SOKOKE_DESKTOP_UNTESTED;
- if (G_UNLIKELY (desktop == SOKOKE_DESKTOP_UNTESTED))
- {
- desktop = SOKOKE_DESKTOP_UNKNOWN;
-
- /* Are we running in Xfce >= 4.8? */
- if (!g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "xfce"))
- {
- desktop = SOKOKE_DESKTOP_XFCE;
- }
- else
- {
- /* Are we running in Xfce <= 4.6? */
- GdkDisplay* display = gdk_display_get_default ();
- if (GDK_IS_X11_DISPLAY (display))
- {
- Display* xdisplay = GDK_DISPLAY_XDISPLAY (display);
- Window root_window = RootWindow (xdisplay, 0);
- Atom save_mode_atom = gdk_x11_get_xatom_by_name_for_display (
- display, "_DT_SAVE_MODE");
- Atom actual_type;
- int actual_format;
- unsigned long n_items, bytes;
- gchar* value;
- int status = XGetWindowProperty (xdisplay, root_window,
- save_mode_atom, 0, (~0L),
- False, AnyPropertyType, &actual_type, &actual_format,
- &n_items, &bytes, (unsigned char**)&value);
- if (status == Success)
- {
- if (n_items == 6 && !strncmp (value, "xfce4", 6))
- desktop = SOKOKE_DESKTOP_XFCE;
- XFree (value);
- }
- }
- }
- }
-
- return desktop;
- #else
- return SOKOKE_DESKTOP_UNKNOWN;
- #endif
-}
-
-/**
- * sokoke_xfce_header_new:
- * @icon: an icon name
- * @title: the title of the header
- *
- * Creates an Xfce style header *if* Xfce is running.
- *
- * Return value: A #GtkWidget or %NULL
- *
- * Since 0.1.2 @icon may be NULL, and a default is used.
- **/
-GtkWidget*
-sokoke_xfce_header_new (const gchar* icon,
- const gchar* title)
-{
- g_return_val_if_fail (title, NULL);
-
- /* Create an xfce header with icon and title
- This returns NULL if the desktop is not Xfce */
- if (sokoke_get_desktop () == SOKOKE_DESKTOP_XFCE)
- {
- GtkWidget* entry;
- gchar* markup;
- GtkWidget* xfce_heading;
- GtkWidget* hbox;
- GtkWidget* image;
- GtkWidget* label;
- GtkWidget* vbox;
- GtkWidget* separator;
-
- xfce_heading = gtk_event_box_new ();
- entry = gtk_entry_new ();
-
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
- if (icon)
- image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_DIALOG);
- else
- image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES,
- GTK_ICON_SIZE_DIALOG);
- gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
- label = gtk_label_new (NULL);
- markup = g_strdup_printf ("<span size='large' weight='bold'>%s</span>",
- title);
- gtk_label_set_markup (GTK_LABEL (label), markup);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_container_add (GTK_CONTAINER (xfce_heading), hbox);
- g_free (markup);
- gtk_widget_destroy (entry);
-
- #if !GTK_CHECK_VERSION (3, 0, 0)
- {
- GtkStyle* style = gtk_widget_get_style (entry);
- gtk_widget_modify_bg (xfce_heading, GTK_STATE_NORMAL,
- &style->base[GTK_STATE_NORMAL]);
- gtk_widget_modify_fg (label, GTK_STATE_NORMAL
- , &style->text[GTK_STATE_NORMAL]);
- }
- #endif
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), xfce_heading, FALSE, FALSE, 0);
-
- separator = gtk_hseparator_new ();
- gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
-
- return vbox;
- }
- return NULL;
-}
-
-gboolean
-sokoke_key_file_save_to_file (GKeyFile* key_file,
- const gchar* filename,
- GError** error)
-{
- gchar* data;
- gboolean success = FALSE;
-
- data = g_key_file_to_data (key_file, NULL, error);
- if (!data)
- return FALSE;
-
- success = g_file_set_contents (filename, data, -1, error);
- g_free (data);
- return success;
-}
-
-void
-sokoke_widget_get_text_size (GtkWidget* widget,
- const gchar* text,
- gint* width,
- gint* height)
-{
- PangoLayout* layout = gtk_widget_create_pango_layout (widget, text);
- pango_layout_get_pixel_size (layout, width, height);
- g_object_unref (layout);
-}
-
-/**
- * sokoke_time_t_to_julian:
- * @timestamp: a time_t timestamp value
- *
- * Calculates a unix timestamp to a julian day value.
- *
- * Return value: an integer.
- **/
-gint64
-sokoke_time_t_to_julian (const time_t* timestamp)
-{
- GDate* date;
- gint64 julian;
-
- date = g_date_new ();
-
- g_date_set_time_t (date, *timestamp);
- julian = (gint64)g_date_get_julian (date);
-
- g_date_free (date);
-
- return julian;
-}
-
-gchar*
-sokoke_replace_variables (const gchar* template,
- const gchar* variable_first, ...)
-{
- gchar* result = g_strdup (template);
- const gchar* variable;
-
- va_list args;
- va_start (args, variable_first);
-
- for (variable = variable_first; variable; variable = va_arg (args, const gchar*))
- {
- const gchar* value = va_arg (args, const gchar*);
- GRegex* regex = g_regex_new (variable, 0, 0, NULL);
- gchar* replaced = result;
- result = g_regex_replace_literal (regex, replaced, -1, 0, value, 0, NULL);
- g_free (replaced);
- g_regex_unref (regex);
- }
-
- va_end (args);
-
- return result;
-}
-
-/**
- * sokoke_window_activate_key:
- * @window: a #GtkWindow
- * @event: a #GdkEventKey
- *
- * Attempts to activate they key from the event, much
- * like gtk_window_activate_key(), including keys
- * that gtk_accelerator_valid() considers invalid.
- *
- * Return value: %TRUE on success
- **/
-gboolean
-sokoke_window_activate_key (GtkWindow* window,
- GdkEventKey* event)
-{
- gchar *accel_name;
- GQuark accel_quark;
- GObject* object;
- GSList *slist;
-
- if (gtk_window_activate_key (window, event))
- return TRUE;
-
- /* Hack to allow Ctrl + Shift + Tab */
- if (event->keyval == 65056)
- event->keyval = GDK_KEY_Tab;
-
- /* We don't use gtk_accel_groups_activate because it refuses to
- activate anything that gtk_accelerator_valid doesn't like. */
- accel_name = gtk_accelerator_name (event->keyval, (event->state & gtk_accelerator_get_default_mod_mask ()));
- accel_quark = g_quark_from_string (accel_name);
- g_free (accel_name);
- object = G_OBJECT (window);
-
- for (slist = gtk_accel_groups_from_object (object); slist; slist = slist->next)
- if (gtk_accel_group_activate (slist->data, accel_quark,
- object, event->keyval, event->state))
- return TRUE;
-
- return FALSE;
-}
-
-/**
- * sokoke_gtk_action_count_modifiers:
- * @action: a #GtkAction
- *
- * Counts the number of modifiers in the accelerator
- * belonging to the action.
- *
- * Return value: the number of modifiers
- **/
-guint
-sokoke_gtk_action_count_modifiers (GtkAction* action)
-{
- GtkAccelKey key;
- gint mods, cmods = 0;
- const gchar* accel_path;
-
- g_return_val_if_fail (GTK_IS_ACTION (action), 0);
-
- accel_path = gtk_action_get_accel_path (action);
- if (accel_path)
- if (gtk_accel_map_lookup_entry (accel_path, &key))
- {
- mods = key.accel_mods;
- while (mods)
- {
- if (1 & mods >> 0)
- cmods++;
- mods = mods >> 1;
- }
- }
- return cmods;
-}
-
-/**
- * sokoke_prefetch_uri:
- * @settings: a #MidoriWebSettings instance, or %NULL
- * @uri: an URI string
- *
- * Attempts to prefetch the specified URI, that is
- * it tries to resolve the hostname in advance.
- *
- * Return value: %TRUE on success
- **/
-gboolean
-sokoke_prefetch_uri (MidoriWebSettings* settings,
- const char* uri,
- GCallback callback,
- gpointer user_data)
-{
- gchar* hostname;
-#ifndef HAVE_WEBKIT2
- SoupURI* soup_uri;
- SoupSession* session = webkit_get_default_session ();
-
- g_object_get (G_OBJECT (session), "proxy-uri", &soup_uri, NULL);
- if (soup_uri)
- return FALSE;
-#endif
-
- if (settings && !katze_object_get_boolean (settings, "enable-dns-prefetching"))
- return FALSE;
-
- if (!(hostname = midori_uri_parse_hostname (uri, NULL))
- || g_hostname_is_ip_address (hostname)
- || !midori_uri_is_http (uri))
- {
- g_free (hostname);
- return FALSE;
- }
-
-#ifdef HAVE_WEBKIT2
- WebKitWebContext* context = webkit_web_context_get_default ();
- webkit_web_context_prefetch_dns (context, hostname);
- g_free (hostname);
- return FALSE;
-#else
- #define MAXHOSTS 50
- static gchar* hosts = NULL;
- static gint host_count = G_MAXINT;
-
- if (!hosts ||
- !g_regex_match_simple (hostname, hosts,
- G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY))
- {
- SoupAddress* address;
- gchar* new_hosts;
-
- address = soup_address_new (hostname, SOUP_ADDRESS_ANY_PORT);
- soup_address_resolve_async (address, 0, 0, (SoupAddressCallback)callback, user_data);
- g_object_unref (address);
-
- if (host_count > MAXHOSTS)
- {
- katze_assign (hosts, g_strdup (""));
- host_count = 0;
- }
- host_count++;
- new_hosts = g_strdup_printf ("%s|%s", hosts, hostname);
- katze_assign (hosts, new_hosts);
- }
- else if (callback)
- ((SoupAddressCallback)callback) (NULL, SOUP_STATUS_OK, user_data);
- g_free (hostname);
- return TRUE;
-#endif
-}
-
-static void
-sokoke_widget_clipboard_owner_clear_func (GtkClipboard* clipboard,
- gpointer user_data)
-{
- g_object_unref (user_data);
-}
-
-void
-sokoke_widget_copy_clipboard (GtkWidget* widget,
- const gchar* text,
- GtkClipboardGetFunc get_cb,
- gpointer owner)
-{
- GdkDisplay* display = gtk_widget_get_display (widget);
- GtkClipboard* clipboard;
-
- g_return_if_fail (text != NULL);
-
- clipboard = gtk_clipboard_get_for_display (display, GDK_SELECTION_PRIMARY);
- gtk_clipboard_set_text (clipboard, text, -1);
-
- clipboard = gtk_clipboard_get_for_display (display, GDK_SELECTION_CLIPBOARD);
- if (get_cb == NULL)
- gtk_clipboard_set_text (clipboard, text, -1);
- else
- {
- GtkTargetList* target_list = gtk_target_list_new (NULL, 0);
- GtkTargetEntry* targets;
- gint n_targets;
- gtk_target_list_add_text_targets (target_list, 0);
- gtk_target_list_add_image_targets (target_list, 0, TRUE);
- targets = gtk_target_table_new_from_list (target_list, &n_targets);
- gtk_clipboard_set_with_owner (clipboard, targets, n_targets, get_cb,
- sokoke_widget_clipboard_owner_clear_func, owner);
- gtk_target_table_free (targets, n_targets);
- gtk_target_list_unref (target_list);
- }
-}
-
-static gboolean
-sokoke_entry_has_placeholder_text (GtkEntry* entry)
-{
- const gchar* text = gtk_entry_get_text (entry);
- const gchar* hint = gtk_entry_get_placeholder_text (entry);
- if (!gtk_widget_has_focus (GTK_WIDGET (entry))
- && hint != NULL
- && (text == NULL || !strcmp (text, hint)))
- return TRUE;
- return FALSE;
-}
-
-static void
-sokoke_entry_changed_cb (GtkEditable* editable,
- GtkEntry* entry)
-{
- const gchar* text = gtk_entry_get_text (entry);
- gboolean visible = text && *text
- && ! sokoke_entry_has_placeholder_text (entry);
- gtk_entry_set_icon_from_stock (
- entry, GTK_ENTRY_ICON_SECONDARY,
- visible ? GTK_STOCK_CLEAR : NULL);
-}
-
-static gboolean
-sokoke_entry_focus_out_event_cb (GtkEditable* editable,
- GdkEventFocus* event,
- GtkEntry* entry)
-{
- sokoke_entry_changed_cb (editable, entry);
- return FALSE;
-}
-
-static void
-sokoke_entry_icon_released_cb (GtkEntry* entry,
- GtkEntryIconPosition icon_pos,
- GdkEvent* event,
- gpointer user_data)
-{
- if (icon_pos != GTK_ENTRY_ICON_SECONDARY)
- return;
-
- gtk_entry_set_text (entry, "");
- gtk_widget_grab_focus (GTK_WIDGET (entry));
-}
-
-GtkWidget*
-sokoke_search_entry_new (const gchar* placeholder_text)
-{
- GtkWidget* entry = gtk_entry_new ();
- gtk_entry_set_placeholder_text (GTK_ENTRY (entry), placeholder_text);
- gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND);
- gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY, TRUE);
- {
- g_object_connect (entry,
- "signal::icon-release",
- G_CALLBACK (sokoke_entry_icon_released_cb), NULL,
- "signal::focus-in-event",
- G_CALLBACK (sokoke_entry_focus_out_event_cb), entry,
- "signal::focus-out-event",
- G_CALLBACK (sokoke_entry_focus_out_event_cb), entry,
- "signal::changed",
- G_CALLBACK (sokoke_entry_changed_cb), entry, NULL);
- sokoke_entry_changed_cb ((GtkEditable*)entry, GTK_ENTRY (entry));
- }
- return entry;
-}
-
-#ifdef G_OS_WIN32
-const gchar*
-sokoke_get_win32_appdata_dir()
-{
- WCHAR path[MAX_PATH];
- gchar* appdata_dir = NULL;
-
- SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path);
-
- MultiByteToWideChar (CP_UTF8, 0, appdata_dir, -1, path, MAX_PATH);
-
- return g_strdup(path);
-}
-
-
-gchar*
-sokoke_get_win32_desktop_lnk_path_for_filename (gchar* filename)
-{
- const gchar* desktop_dir;
- gchar* lnk_path, *lnk_file;
-
- /* CSIDL_PROGRAMS for "start menu -> programs" instead - needs saner/shorter filename */
- desktop_dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
-
- lnk_file = g_strconcat (filename, ".lnk", NULL);
- lnk_path = g_build_filename (desktop_dir, lnk_file, NULL);
-
- g_free (lnk_file);
-
- return lnk_path;
-}
-
-void
-sokoke_create_win32_desktop_lnk (gchar* prefix, gchar* filename, gchar* uri)
-{
- WCHAR w[MAX_PATH];
-
- gchar* exec_dir, *exec_path, *argument;
- gchar* lnk_path, *launcher_type;
-
- IShellLink* pShellLink;
- IPersistFile* pPersistFile;
-
- exec_dir = g_win32_get_package_installation_directory_of_module (NULL);
- exec_path = g_build_filename (exec_dir, "bin", "midori.exe", NULL);
-
- if (g_str_has_suffix (prefix, " -a "))
- launcher_type = "-a";
- else if (g_str_has_suffix (prefix, " -c "))
- launcher_type = "-c";
- else
- g_assert_not_reached ();
-
- argument = g_strdup_printf ("%s \"%s\"", launcher_type, uri);
-
- /* Create link */
- CoCreateInstance (&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (LPVOID *)&pShellLink);
- pShellLink->lpVtbl->SetPath (pShellLink, exec_path);
- pShellLink->lpVtbl->SetArguments (pShellLink, argument);
- /* TODO: support adding site favicon as webapp icon */
- /* pShellLink->lpVtbl->SetIconLocation (pShellLink, icon_path, icon_index); */
-
- /* Save link */
- lnk_path = sokoke_get_win32_desktop_lnk_path_for_filename (filename);
- pShellLink->lpVtbl->QueryInterface (pShellLink, &IID_IPersistFile, (LPVOID *)&pPersistFile);
- MultiByteToWideChar (CP_UTF8, 0, lnk_path, -1, w, MAX_PATH);
- pPersistFile->lpVtbl->Save (pPersistFile, w, TRUE);
-
- pPersistFile->lpVtbl->Release (pPersistFile);
- pShellLink->lpVtbl->Release (pShellLink);
-
- g_free (exec_dir);
- g_free (exec_path);
- g_free (argument);
- g_free (lnk_path);
- g_free (launcher_type);
-}
-
-GdkPixbuf*
-sokoke_get_gdk_pixbuf_from_win32_executable (gchar* path)
-{
- if (path == NULL)
- return NULL;
-
- GdkPixbuf* pixbuf = NULL;
- HICON hIcon = NULL;
- HINSTANCE hInstance = NULL;
- hIcon = ExtractIcon (hInstance, (LPCSTR)path, 0);
- if (hIcon == NULL)
- return NULL;
-
-#if GTK_CHECK_VERSION (3, 9, 12)
- pixbuf = gdk_win32_icon_to_pixbuf_libgtk_only (hIcon, NULL, NULL);
-#else
- pixbuf = gdk_win32_icon_to_pixbuf_libgtk_only (hIcon);
-#endif
- DestroyIcon (hIcon);
-
- return pixbuf;
-}
-#endif
diff --git a/midori/sokoke.h b/midori/sokoke.h
deleted file mode 100644
index 8322e3f2..00000000
--- a/midori/sokoke.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- Copyright (C) 2007-2008 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2009 Dale Whittaker <dayul@users.sf.net>
-
- 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 __SOKOKE_H__
-#define __SOKOKE_H__ 1
-
-#include <JavaScriptCore/JavaScript.h>
-#include "katze/katze.h"
-#include <midori/midori-websettings.h>
-#include <katze/gtk3-compat.h>
-
-gchar*
-sokoke_js_script_eval (JSContextRef js_context,
- const gchar* script,
- gchar** exception);
-
-void
-sokoke_message_dialog (GtkMessageType message_type,
- const gchar* short_message,
- const gchar* detailed_message,
- gboolean modal);
-
-gchar*
-sokoke_prepare_command (const gchar* command,
- gboolean quote_command,
- const gchar* argument,
- gboolean quote_argument);
-
-gboolean
-sokoke_spawn_program (const gchar* command,
- gboolean quote_command,
- const gchar* argument,
- gboolean quote_argument,
- gboolean sync);
-
-void
-sokoke_spawn_gdb (const gchar* gdb,
- gboolean sync);
-
-void
-sokoke_spawn_app (const gchar* uri,
- gboolean inherit_config);
-
-gboolean
-sokoke_external_uri (const gchar* uri);
-
-gchar*
-sokoke_magic_uri (const gchar* uri,
- gboolean allow_search,
- gboolean allow_realtive);
-
-void
-sokoke_widget_set_visible (GtkWidget* widget,
- gboolean visible);
-
-GtkWidget*
-sokoke_xfce_header_new (const gchar* icon,
- const gchar* title);
-
-gboolean
-sokoke_key_file_save_to_file (GKeyFile* key_file,
- const gchar* filename,
- GError** error);
-
-void
-sokoke_widget_get_text_size (GtkWidget* widget,
- const gchar* text,
- gint* width,
- gint* height);
-
-gint64
-sokoke_time_t_to_julian (const time_t* timestamp);
-
-gchar*
-sokoke_replace_variables (const gchar* template,
- const gchar* variable_first, ...);
-
-gboolean
-sokoke_window_activate_key (GtkWindow* window,
- GdkEventKey* event);
-guint
-sokoke_gtk_action_count_modifiers (GtkAction* action);
-
-gboolean
-sokoke_prefetch_uri (MidoriWebSettings* settings,
- const char* uri,
- GCallback callback,
- gpointer user_data);
-
-gboolean
-sokoke_resolve_hostname (const gchar* hostname);
-
-void
-sokoke_widget_copy_clipboard (GtkWidget* widget,
- const gchar* text,
- GtkClipboardGetFunc get_cb,
- gpointer owner);
-
-GtkWidget*
-sokoke_search_entry_new (const gchar* placeholder_text);
-
-#ifdef G_OS_WIN32
-const gchar*
-sokoke_get_win32_appdata_dir();
-
-gchar*
-sokoke_get_win32_desktop_lnk_path_for_filename (gchar* filename);
-
-void
-sokoke_create_win32_desktop_lnk (gchar* prefix, gchar* filename, gchar* uri);
-#endif
-
-#endif /* !__SOKOKE_H__ */
diff --git a/midori/webkitgtk-3.0.deps b/midori/webkitgtk-3.0.deps
deleted file mode 100644
index 44857384..00000000
--- a/midori/webkitgtk-3.0.deps
+++ /dev/null
@@ -1,6 +0,0 @@
-atk
-gio-2.0
-cairo
-pango
-gdk-pixbuf-2.0
-libsoup-2.4
diff --git a/midori/webkitgtk-3.0.vapi b/midori/webkitgtk-3.0.vapi
deleted file mode 100644
index 46273d48..00000000
--- a/midori/webkitgtk-3.0.vapi
+++ /dev/null
@@ -1,841 +0,0 @@
-/* webkit-1.0.vapi generated by vapigen, do not modify. */
-
-[CCode (cprefix = "WebKit", lower_case_cprefix = "webkit_")]
-namespace WebKit {
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class FaviconDatabase : GLib.Object {
- public signal void icon_loaded (string frame_uri);
- public Gdk.Pixbuf? try_get_favicon_pixbuf (string page_uri, uint width, uint height);
- public async Gdk.Pixbuf? get_favicon_pixbuf (string page_uri, uint width, uint height, GLib.Cancellable? cancellable) throws GLib.Error;
- public void set_path (string? path);
- public void clear ();
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class IconDatabase : GLib.Object {
- public signal void icon_loaded (WebKit.WebFrame web_frame, string frame_uri);
- public Gdk.Pixbuf? get_icon_pixbuf (string page_uri);
- public void set_path (string? path);
- public void clear ();
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class DOMDOMTokenList : GLib.Object {
- [CCode (has_construct_function = false)]
- protected DOMDOMTokenList ();
- [CCode (cname = "webkit_dom_dom_token_list_add")]
- public void add (string token) throws GLib.Error;
- [CCode (cname = "webkit_dom_dom_token_list_contains")]
- public bool contains (string token) throws GLib.Error;
- [CCode (cname = "webkit_dom_dom_token_list_item")]
- public unowned string item (ulong index);
- [CCode (cname = "webkit_dom_dom_token_list_remove")]
- public void remove (string token) throws GLib.Error;
- [CCode (cname = "webkit_dom_dom_token_list_toggle")]
- public bool toggle (string token) throws GLib.Error;
- public ulong length { get; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class DOMHTMLElement : WebKit.DOMElement {
- [CCode (has_construct_function = false)]
- protected DOMHTMLElement ();
- [CCode (cname = "webkit_dom_html_element_insert_adjacent_element")]
- public unowned WebKit.DOMElement insert_adjacent_element (string where, WebKit.DOMElement element) throws GLib.Error;
- [CCode (cname = "webkit_dom_html_element_insert_adjacent_html")]
- public void insert_adjacent_html (string where, string html) throws GLib.Error;
- [CCode (cname = "webkit_dom_html_element_insert_adjacent_text")]
- public void insert_adjacent_text (string where, string text) throws GLib.Error;
- [CCode (cname = "webkit_dom_html_element_set_content_editable")]
- public void set_content_editable (string value) throws GLib.Error;
- [CCode (cname = "webkit_dom_html_element_set_inner_html")]
- public void set_inner_html (string value) throws GLib.Error;
- [CCode (cname = "webkit_dom_html_element_set_inner_text")]
- public void set_inner_text (string value) throws GLib.Error;
- [CCode (cname = "webkit_dom_html_element_set_lang")]
- public void set_lang (string value);
- [CCode (cname = "webkit_dom_html_element_set_outer_html")]
- public void set_outer_html (string value) throws GLib.Error;
- [CCode (cname = "webkit_dom_html_element_set_outer_text")]
- public void set_outer_text (string value) throws GLib.Error;
- public void set_webkitdropzone (string value);
- public WebKit.DOMHTMLCollection children { get; }
- public WebKit.DOMDOMTokenList class_list { get; }
- public string class_name { get; set; }
- public string content_editable { get; set; }
- public string dir { get; set; }
- public bool draggable { get; set; }
- public bool hidden { get; set; }
- public string id { get; set; }
- public string inner_html { get; set; }
- public string inner_text { get; set; }
- public bool is_content_editable { get; }
- public string lang { get; set; }
- public string outer_html { get; set; }
- public string outer_text { get; set; }
- public bool spellcheck { get; set; }
- public long tab_index { get; set; }
- public string title { get; set; }
- public string webkitdropzone { get; set; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class DOMHTMLCollection : GLib.Object {
- [CCode (has_construct_function = false)]
- protected DOMHTMLCollection ();
- [CCode (cname = "webkit_dom_html_collection_item")]
- public unowned WebKit.DOMNode item (ulong index);
- [CCode (cname = "webkit_dom_html_collection_named_item")]
- public unowned WebKit.DOMNode named_item (string name);
- public ulong length { get; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class DOMText : WebKit.DOMNode {
- [CCode (has_construct_function = false)]
- protected DOMText ();
- public unowned WebKit.DOMText replace_whole_text (string content) throws GLib.Error;
- public unowned WebKit.DOMText split_text (ulong offset) throws GLib.Error;
- public string whole_text { get; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class DOMDocument : WebKit.DOMNode {
- [CCode (has_construct_function = false)]
- protected DOMDocument ();
- public unowned WebKit.DOMElement create_element (string tag_name) throws GLib.Error;
- public unowned WebKit.DOMText create_text_node (string data);
- public unowned WebKit.DOMElement get_element_by_id (string element_id);
- public unowned WebKit.DOMNodeList get_elements_by_class_name (string tagname);
- public unowned WebKit.DOMNodeList get_elements_by_name (string element_name);
- public unowned WebKit.DOMNodeList get_elements_by_tag_name (string tagname);
- public bool query_command_enabled (string command);
- public unowned WebKit.DOMElement query_selector (string selectors) throws GLib.Error;
- public unowned WebKit.DOMNodeList query_selector_all (string selectors) throws GLib.Error;
- public WebKit.DOMHTMLCollection anchors { get; }
- public WebKit.DOMHTMLCollection applets { get; }
- public WebKit.DOMHTMLElement body { get; }
- public WebKit.DOMHTMLCollection forms { get; }
- public WebKit.DOMHTMLElement head { get; }
- public WebKit.DOMHTMLCollection images { get; }
- public WebKit.DOMHTMLCollection links { get; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class DOMElement : WebKit.DOMNode {
- [CCode (has_construct_function = false)]
- protected DOMElement ();
- public void blur ();
- public void focus ();
- public unowned string get_attribute (string name);
- public unowned WebKit.DOMNodeList get_elements_by_class_name (string name);
- public unowned WebKit.DOMNodeList get_elements_by_tag_name (string name);
- public bool has_attribute (string name);
- public unowned WebKit.DOMElement query_selector (string selectors) throws GLib.Error;
- public unowned WebKit.DOMNodeList query_selector_all (string selectors) throws GLib.Error;
- public void remove_attribute (string name) throws GLib.Error;
- public void scroll_into_view (bool align_with_top);
- public void scroll_into_view_if_needed (bool center_if_needed);
- public void set_attribute (string name, string value) throws GLib.Error;
- public bool webkit_matches_selector (string selectors) throws GLib.Error;
- public WebKit.DOMElement first_element_child { get; }
- public WebKit.DOMElement last_element_child { get; }
- public WebKit.DOMElement next_element_sibling { get; }
- public WebKit.DOMElement previous_element_sibling { get; }
- public string tag_name { get; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class DOMNodeList : GLib.Object {
- [CCode (has_construct_function = false)]
- protected DOMNodeList ();
- public unowned WebKit.DOMNode item (ulong index);
- public ulong length { get; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class DOMNode : GLib.Object {
- [CCode (has_construct_function = false)]
- protected DOMNode ();
- public unowned WebKit.DOMNode append_child (WebKit.DOMNode new_child) throws GLib.Error;
- public bool contains (WebKit.DOMNode other);
- public unowned WebKit.DOMNode insert_before (WebKit.DOMNode new_child, WebKit.DOMNode ref_child) throws GLib.Error;
- public void normalize ();
- public unowned WebKit.DOMNode remove_child (WebKit.DOMNode old_child) throws GLib.Error;
- public unowned WebKit.DOMNode replace_child (WebKit.DOMNode new_child, WebKit.DOMNode old_child) throws GLib.Error;
- public void set_text_content (string value) throws GLib.Error;
- public WebKit.DOMNodeList child_nodes { get; }
- public WebKit.DOMNode first_child { get; }
- public WebKit.DOMNode last_child { get; }
- public WebKit.DOMNode next_sibling { get; }
- public WebKit.DOMElement parent_element { get; }
- public WebKit.DOMNode parent_node { get; }
- public WebKit.DOMNode previous_sibling { get; }
- public string text_content { get; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class Download : GLib.Object {
- [CCode (has_construct_function = false)]
- public Download (WebKit.NetworkRequest request);
- public void cancel ();
- public uint64 get_current_size ();
- public unowned string get_destination_uri ();
- public double get_elapsed_time ();
- public unowned WebKit.NetworkRequest get_network_request ();
- public unowned WebKit.NetworkResponse get_network_response ();
- public double get_progress ();
- public WebKit.DownloadStatus get_status ();
- public unowned string get_suggested_filename ();
- public uint64 get_total_size ();
- public unowned string get_uri ();
- public void set_destination_uri (string destination_uri);
- public void start ();
- public uint64 current_size { get; }
- public string destination_uri { get; set; }
- public WebKit.NetworkRequest network_request { get; construct; }
- public WebKit.NetworkResponse network_response { get; construct; }
- public double progress { get; }
- public WebKit.DownloadStatus status { get; }
- public string suggested_filename { get; }
- public uint64 total_size { get; }
- public virtual signal bool error (int p0, int p1, string p2);
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class GeolocationPolicyDecision : GLib.Object {
- [CCode (has_construct_function = false)]
- protected GeolocationPolicyDecision ();
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class HitTestResult : GLib.Object {
- [CCode (has_construct_function = false)]
- protected HitTestResult ();
- [NoAccessorMethod]
- public WebKit.HitTestResultContext context { get; construct; }
- [NoAccessorMethod]
- public string image_uri { owned get; construct; }
- [NoAccessorMethod]
- public string link_uri { owned get; construct; }
- [NoAccessorMethod]
- public string media_uri { owned get; construct; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class NetworkRequest : GLib.Object {
- [CCode (has_construct_function = false)]
- public NetworkRequest (string uri);
- public unowned Soup.Message get_message ();
- public unowned string get_uri ();
- public void set_uri (string uri);
- public Soup.Message message { get; construct; }
- public string uri { get; set; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class NetworkResponse : GLib.Object {
- [CCode (has_construct_function = false)]
- public NetworkResponse (string uri);
- public unowned Soup.Message get_message ();
- public unowned string get_uri ();
- public void set_uri (string uri);
- public Soup.Message message { get; construct; }
- public string uri { get; set; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class SecurityOrigin : GLib.Object {
- [CCode (has_construct_function = false)]
- protected SecurityOrigin ();
- public unowned GLib.List<WebKit.WebDatabase> get_all_web_databases ();
- public unowned string get_host ();
- public uint get_port ();
- public unowned string get_protocol ();
- public uint64 get_web_database_quota ();
- public uint64 get_web_database_usage ();
- public void set_web_database_quota (uint64 quota);
- public string host { get; }
- public uint port { get; }
- public string protocol { get; }
- public uint64 web_database_quota { get; set; }
- public uint64 web_database_usage { get; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class SoupAuthDialog : GLib.Object, Soup.SessionFeature {
- [CCode (has_construct_function = false)]
- protected SoupAuthDialog ();
- public virtual signal unowned Gtk.Widget current_toplevel (Soup.Message message);
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class WebBackForwardList : GLib.Object {
- [CCode (has_construct_function = false)]
- protected WebBackForwardList ();
- public void add_item (WebKit.WebHistoryItem history_item);
- public void clear ();
- public bool contains_item (WebKit.WebHistoryItem history_item);
- public unowned WebKit.WebHistoryItem get_back_item ();
- public int get_back_length ();
- public unowned GLib.List<WebKit.WebHistoryItem> get_back_list_with_limit (int limit);
- public unowned WebKit.WebHistoryItem get_current_item ();
- public unowned WebKit.WebHistoryItem get_forward_item ();
- public int get_forward_length ();
- public unowned GLib.List<WebKit.WebHistoryItem> get_forward_list_with_limit (int limit);
- public int get_limit ();
- public unowned WebKit.WebHistoryItem get_nth_item (int index);
- public void go_back ();
- public void go_forward ();
- public void go_to_item (WebKit.WebHistoryItem history_item);
- public void set_limit (int limit);
- [CCode (has_construct_function = false)]
- public WebBackForwardList.with_web_view (WebKit.WebView web_view);
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class WebDataSource : GLib.Object {
- [CCode (has_construct_function = false)]
- public WebDataSource ();
- public unowned GLib.StringBuilder get_data ();
- public unowned string get_encoding ();
- public unowned WebKit.NetworkRequest get_initial_request ();
- public unowned WebKit.WebResource get_main_resource ();
- public unowned WebKit.NetworkRequest get_request ();
- public unowned GLib.List<WebKit.WebResource> get_subresources ();
- public unowned string get_unreachable_uri ();
- public unowned WebKit.WebFrame get_web_frame ();
- public bool is_loading ();
- [CCode (has_construct_function = false)]
- public WebDataSource.with_request (WebKit.NetworkRequest request);
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class WebDatabase : GLib.Object {
- [CCode (has_construct_function = false)]
- protected WebDatabase ();
- public unowned string get_display_name ();
- public uint64 get_expected_size ();
- public unowned string get_filename ();
- public unowned string get_name ();
- public unowned WebKit.SecurityOrigin get_security_origin ();
- public uint64 get_size ();
- public void remove ();
- public string display_name { get; }
- public uint64 expected_size { get; }
- public string filename { get; }
- public string name { get; construct; }
- public WebKit.SecurityOrigin security_origin { get; construct; }
- public uint64 size { get; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class WebFrame : GLib.Object {
- [CCode (has_construct_function = false)]
- public WebFrame (WebKit.WebView web_view);
- public unowned WebKit.WebFrame find_frame (string name);
- public unowned WebKit.WebDataSource get_data_source ();
- public Gtk.PolicyType get_horizontal_scrollbar_policy ();
- public WebKit.LoadStatus get_load_status ();
- public unowned string get_name ();
- public unowned WebKit.NetworkResponse get_network_response ();
- public unowned WebKit.WebFrame get_parent ();
- public unowned WebKit.WebDataSource get_provisional_data_source ();
- public unowned WebKit.SecurityOrigin get_security_origin ();
- public unowned string get_title ();
- public unowned string get_uri ();
- public Gtk.PolicyType get_vertical_scrollbar_policy ();
- public unowned WebKit.WebView get_web_view ();
- public void load_alternate_string (string content, string base_url, string unreachable_url);
- public void load_request (WebKit.NetworkRequest request);
- public void load_string (string content, string mime_type, string encoding, string base_uri);
- public void load_uri (string uri);
- public void print ();
- public Gtk.PrintOperationResult print_full (Gtk.PrintOperation operation, Gtk.PrintOperationAction action) throws GLib.Error;
- public void reload ();
- public void stop_loading ();
- public Gtk.PolicyType horizontal_scrollbar_policy { get; }
- public WebKit.LoadStatus load_status { get; }
- public string name { get; }
- public string title { get; }
- public string uri { get; }
- public Gtk.PolicyType vertical_scrollbar_policy { get; }
- public virtual signal void cleared ();
- public virtual signal void hovering_over_link (string p0, string p1);
- public virtual signal void load_committed ();
- public virtual signal void load_done (bool p0);
- public virtual signal bool scrollbars_policy_changed ();
- public virtual signal void title_changed (string p0);
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class WebHistoryItem : GLib.Object {
- [CCode (has_construct_function = false)]
- public WebHistoryItem ();
- public unowned WebKit.WebHistoryItem copy ();
- public unowned string get_alternate_title ();
- public double get_last_visited_time ();
- public unowned string get_original_uri ();
- public unowned string get_title ();
- public unowned string get_uri ();
- public void set_alternate_title (string title);
- [CCode (has_construct_function = false)]
- public WebHistoryItem.with_data (string uri, string title);
- public string alternate_title { get; set; }
- public double last_visited_time { get; }
- public string original_uri { get; }
- public string title { get; }
- public string uri { get; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class WebInspector : GLib.Object {
- [CCode (has_construct_function = false)]
- protected WebInspector ();
- public void close ();
- public unowned string get_inspected_uri ();
- public unowned WebKit.WebView get_web_view ();
- public void inspect_coordinates (double x, double y);
- public void show ();
- public string inspected_uri { get; }
- [NoAccessorMethod]
- public bool javascript_profiling_enabled { get; set; }
- [NoAccessorMethod]
- public bool timeline_profiling_enabled { get; set; }
- public WebKit.WebView web_view { get; }
- public virtual signal bool attach_window ();
- public virtual signal bool close_window ();
- public virtual signal bool detach_window ();
- public virtual signal void finished ();
- public virtual signal unowned WebKit.WebView inspect_web_view (WebKit.WebView p0);
- public virtual signal bool show_window ();
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class WebNavigationAction : GLib.Object {
- [CCode (has_construct_function = false)]
- protected WebNavigationAction ();
- public int get_button ();
- public int get_modifier_state ();
- public unowned string get_original_uri ();
- public WebKit.WebNavigationReason get_reason ();
- public unowned string get_target_frame ();
- public void set_original_uri (string originalUri);
- public void set_reason (WebKit.WebNavigationReason reason);
- public int button { get; construct; }
- public int modifier_state { get; construct; }
- public string original_uri { get; set construct; }
- public WebKit.WebNavigationReason reason { get; set construct; }
- public string target_frame { get; construct; }
- }
- [CCode (cheader_filename = "webkit/webkit.h", type_id = "webkit_web_plugin_get_type ()")]
- public class WebPlugin : GLib.Object {
- [CCode (has_construct_function = false)]
- protected WebPlugin ();
- public unowned string get_description ();
- public bool get_enabled ();
- public unowned string get_name ();
- public unowned string get_path ();
- public void set_enabled (bool enabled);
- public bool enabled { get; set; }
- }
- [CCode (cheader_filename = "webkit/webkit.h", type_id = "webkit_web_plugin_database_get_type ()")]
- public class WebPluginDatabase : GLib.Object {
- [CCode (has_construct_function = false)]
- protected WebPluginDatabase ();
- public WebKit.WebPlugin get_plugin_for_mimetype (string mime_type);
- public GLib.SList<WebKit.WebPlugin> get_plugins ();
- public void refresh ();
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class WebPolicyDecision : GLib.Object {
- [CCode (has_construct_function = false)]
- protected WebPolicyDecision ();
- public void download ();
- public void ignore ();
- public void use ();
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class WebResource : GLib.Object {
- [CCode (has_construct_function = false)]
- public WebResource (string data, ssize_t size, string uri, string mime_type, string encoding, string frame_name);
- public unowned GLib.StringBuilder get_data ();
- public unowned string get_encoding ();
- public unowned string get_frame_name ();
- public unowned string get_mime_type ();
- public unowned string get_uri ();
- public string encoding { get; }
- public string frame_name { get; }
- public string mime_type { get; }
- public string uri { get; construct; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class WebSettings : GLib.Object {
- [CCode (has_construct_function = false)]
- public WebSettings ();
- public WebKit.WebSettings copy ();
- public unowned string get_user_agent ();
- [NoAccessorMethod]
- public bool auto_load_images { get; set construct; }
- [NoAccessorMethod]
- public bool auto_resize_window { get; set construct; }
- [NoAccessorMethod]
- public bool auto_shrink_images { get; set construct; }
- [NoAccessorMethod]
- public string cursive_font_family { owned get; set construct; }
- [NoAccessorMethod]
- public string default_encoding { owned get; set construct; }
- [NoAccessorMethod]
- public string default_font_family { owned get; set construct; }
- [NoAccessorMethod]
- public int default_font_size { get; set construct; }
- [NoAccessorMethod]
- public int default_monospace_font_size { get; set construct; }
- [NoAccessorMethod]
- public WebKit.EditingBehavior editing_behavior { get; set construct; }
- [NoAccessorMethod]
- public bool enable_caret_browsing { get; set construct; }
- [NoAccessorMethod]
- public bool enable_default_context_menu { get; set construct; }
- [NoAccessorMethod]
- public bool enable_developer_extras { get; set construct; }
- [NoAccessorMethod]
- public bool enable_dom_paste { get; set construct; }
- [NoAccessorMethod]
- public bool enable_file_access_from_file_uris { get; set construct; }
- [NoAccessorMethod]
- public bool enable_html5_database { get; set construct; }
- [NoAccessorMethod]
- public bool enable_html5_local_storage { get; set construct; }
- [NoAccessorMethod]
- public bool enable_java_applet { get; set construct; }
- [NoAccessorMethod]
- public bool enable_offline_web_application_cache { get; set construct; }
- [NoAccessorMethod]
- public bool enable_page_cache { get; set construct; }
- [NoAccessorMethod]
- public bool enable_plugins { get; set construct; }
- [NoAccessorMethod]
- public bool enable_private_browsing { get; set construct; }
- [NoAccessorMethod]
- public bool enable_scripts { get; set construct; }
- [NoAccessorMethod]
- public bool enable_site_specific_quirks { get; set construct; }
- [NoAccessorMethod]
- public bool enable_spatial_navigation { get; set construct; }
- [NoAccessorMethod]
- public bool enable_spell_checking { get; set construct; }
- [NoAccessorMethod]
- public bool enable_universal_access_from_file_uris { get; set construct; }
- [NoAccessorMethod]
- public bool enable_xss_auditor { get; set construct; }
- [NoAccessorMethod]
- public bool enforce_96_dpi { get; set construct; }
- [NoAccessorMethod]
- public string fantasy_font_family { owned get; set construct; }
- [NoAccessorMethod]
- public bool javascript_can_access_clipboard { get; set construct; }
- [NoAccessorMethod]
- public bool javascript_can_open_windows_automatically { get; set construct; }
- [NoAccessorMethod]
- public int minimum_font_size { get; set construct; }
- [NoAccessorMethod]
- public int minimum_logical_font_size { get; set construct; }
- [NoAccessorMethod]
- public string monospace_font_family { owned get; set construct; }
- [NoAccessorMethod]
- public bool print_backgrounds { get; set construct; }
- [NoAccessorMethod]
- public bool resizable_text_areas { get; set construct; }
- [NoAccessorMethod]
- public string sans_serif_font_family { owned get; set construct; }
- [NoAccessorMethod]
- public string serif_font_family { owned get; set construct; }
- [NoAccessorMethod]
- public string spell_checking_languages { owned get; set construct; }
- [NoAccessorMethod]
- public bool tab_key_cycles_through_elements { get; set construct; }
- [NoAccessorMethod]
- public string user_agent { owned get; set construct; }
- [NoAccessorMethod]
- public string user_stylesheet_uri { owned get; set construct; }
- [NoAccessorMethod]
- public float zoom_step { get; set construct; }
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class WebView : Gtk.Container, Atk.Implementor, Gtk.Buildable {
- [CCode (type = "GtkWidget*", has_construct_function = false)]
- public WebView ();
- public bool can_copy_clipboard ();
- public bool can_cut_clipboard ();
- public bool can_go_back ();
- public bool can_go_back_or_forward (int steps);
- public bool can_go_forward ();
- public bool can_paste_clipboard ();
- public bool can_redo ();
- public bool can_show_mime_type (string mime_type);
- public bool can_undo ();
- [NoWrapper]
- public virtual unowned string choose_file (WebKit.WebFrame frame, string old_file);
- public void delete_selection ();
- public void execute_script (string script);
- public unowned WebKit.WebBackForwardList get_back_forward_list ();
- public unowned Gtk.TargetList get_copy_target_list ();
- public unowned string get_custom_encoding ();
- public unowned WebKit.DOMDocument get_dom_document ();
- public bool get_editable ();
- public unowned string get_encoding ();
- public unowned WebKit.WebFrame get_focused_frame ();
- public bool get_full_content_zoom ();
- public unowned WebKit.HitTestResult get_hit_test_result (Gdk.EventButton event);
- public unowned string get_icon_uri ();
- public unowned WebKit.WebInspector get_inspector ();
- public WebKit.LoadStatus get_load_status ();
- public unowned WebKit.WebFrame get_main_frame ();
- public unowned Gtk.TargetList get_paste_target_list ();
- public double get_progress ();
- public unowned WebKit.WebSettings get_settings ();
- public unowned string get_title ();
- public bool get_transparent ();
- public unowned string get_uri ();
- public bool get_view_source_mode ();
- public unowned WebKit.WebWindowFeatures get_window_features ();
- public float get_zoom_level ();
- public void go_back ();
- public void go_back_or_forward (int steps);
- public void go_forward ();
- public bool go_to_back_forward_item (WebKit.WebHistoryItem item);
- public bool has_selection ();
- public void load_html_string (string content, string base_uri);
- public void load_request (WebKit.NetworkRequest request);
- public void load_string (string content, string mime_type, string encoding, string base_uri);
- public void load_uri (string uri);
- public uint mark_text_matches (string str, bool case_sensitive, uint limit);
- public void open (string uri);
- public void reload ();
- public void reload_bypass_cache ();
- public bool search_text (string text, bool case_sensitive, bool forward, bool wrap);
- public void set_custom_encoding (string encoding);
- public void set_editable (bool flag);
- public void set_full_content_zoom (bool full_content_zoom);
- public void set_highlight_text_matches (bool highlight);
- public void set_maintains_back_forward_list (bool flag);
- public void set_settings (WebKit.WebSettings settings);
- public void set_transparent (bool flag);
- public void set_view_source_mode (bool view_source_mode);
- public void set_zoom_level (float zoom_level);
- public void stop_loading ();
- public void unmark_text_matches ();
- public void zoom_in ();
- public void zoom_out ();
- public Gtk.TargetList copy_target_list { get; }
- public string custom_encoding { get; set; }
- public bool editable { get; set; }
- public string encoding { get; }
- public bool full_content_zoom { get; set; }
- public string icon_uri { get; }
- [NoAccessorMethod]
- public Gtk.IMContext im_context { owned get; }
- public WebKit.LoadStatus load_status { get; }
- public Gtk.TargetList paste_target_list { get; }
- public double progress { get; }
- public WebKit.WebSettings settings { get; set; }
- public string title { get; }
- public bool transparent { get; set; }
- public string uri { get; }
- [NoAccessorMethod]
- public WebKit.WebInspector web_inspector { owned get; }
- [NoAccessorMethod]
- public WebKit.WebWindowFeatures window_features { owned get; set; }
- public float zoom_level { get; set; }
- public virtual signal bool close_web_view ();
- public virtual signal bool console_message (string message, int line_number, string source_id);
- [HasEmitter]
- public virtual signal void copy_clipboard ();
- public virtual signal unowned Gtk.Widget create_plugin_widget (string p0, string p1, GLib.HashTable p2);
- public virtual signal WebKit.WebView create_web_view (WebKit.WebFrame web_frame);
- [HasEmitter]
- public virtual signal void cut_clipboard ();
- public virtual signal void database_quota_exceeded (GLib.Object p0, GLib.Object p1);
- public virtual signal void document_load_finished (WebKit.WebFrame p0);
- public virtual signal bool download_requested (GLib.Object p0);
- public virtual signal void geolocation_policy_decision_cancelled (WebKit.WebFrame p0);
- public virtual signal bool geolocation_policy_decision_requested (WebKit.WebFrame p0, WebKit.GeolocationPolicyDecision p1);
- public virtual signal void hovering_over_link (string? p0, string p1);
- public virtual signal void icon_loaded (string p0);
- public virtual signal void load_committed (WebKit.WebFrame p0);
- public virtual signal bool load_error (WebKit.WebFrame p0, string p1, void* p2);
- public virtual signal void load_finished (WebKit.WebFrame p0);
- public virtual signal void load_progress_changed (int p0);
- public virtual signal void load_started (WebKit.WebFrame p0);
- public virtual signal bool mime_type_policy_decision_requested (WebKit.WebFrame p0, WebKit.NetworkRequest p1, string p2, WebKit.WebPolicyDecision p3);
- [HasEmitter]
- public virtual signal bool move_cursor (Gtk.MovementStep step, int count);
- public virtual signal bool navigation_policy_decision_requested (WebKit.WebFrame p0, WebKit.NetworkRequest p1, WebKit.WebNavigationAction p2, WebKit.WebPolicyDecision p3);
- public virtual signal WebKit.NavigationResponse navigation_requested (WebKit.WebFrame frame, WebKit.NetworkRequest request);
- public virtual signal bool new_window_policy_decision_requested (WebKit.WebFrame p0, WebKit.NetworkRequest p1, WebKit.WebNavigationAction p2, WebKit.WebPolicyDecision p3);
- [HasEmitter]
- public virtual signal void paste_clipboard ();
- public virtual signal void populate_popup (Gtk.Menu p0);
- public virtual signal bool print_requested (WebKit.WebFrame p0);
- [HasEmitter]
- public virtual signal void redo ();
- public virtual signal void resource_request_starting (WebKit.WebFrame p0, WebKit.WebResource p1, WebKit.NetworkRequest p2, WebKit.NetworkResponse p3);
- public virtual signal bool script_alert (WebKit.WebFrame frame, string alert_message);
- public virtual signal bool script_confirm (WebKit.WebFrame frame, string confirm_message, void* did_confirm);
- public virtual signal bool script_prompt (WebKit.WebFrame frame, string message, string default_value, void* value);
- [HasEmitter]
- public virtual signal void select_all ();
- public virtual signal void selection_changed ();
- public virtual signal void set_scroll_adjustments (Gtk.Adjustment hadjustment, Gtk.Adjustment vadjustment);
- public virtual signal void status_bar_text_changed (string p0);
- public virtual signal void title_changed (WebKit.WebFrame p0, string p1);
- [HasEmitter]
- public virtual signal void undo ();
- public virtual signal bool web_view_ready ();
- public virtual signal void window_object_cleared (WebKit.WebFrame frame, void* context, void* window_object);
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public class WebWindowFeatures : GLib.Object {
- [CCode (has_construct_function = false)]
- public WebWindowFeatures ();
- public bool equal (WebKit.WebWindowFeatures features2);
- [NoAccessorMethod]
- public bool fullscreen { get; set construct; }
- [NoAccessorMethod]
- public int height { get; set construct; }
- [NoAccessorMethod]
- public bool locationbar_visible { get; set construct; }
- [NoAccessorMethod]
- public bool menubar_visible { get; set construct; }
- [NoAccessorMethod]
- public bool scrollbar_visible { get; set construct; }
- [NoAccessorMethod]
- public bool statusbar_visible { get; set construct; }
- [NoAccessorMethod]
- public bool toolbar_visible { get; set construct; }
- [NoAccessorMethod]
- public int width { get; set construct; }
- [NoAccessorMethod]
- public int x { get; set construct; }
- [NoAccessorMethod]
- public int y { get; set construct; }
- }
- [CCode (cprefix = "WEBKIT_CACHE_MODEL_", cheader_filename = "webkit/webkit.h")]
- public enum CacheModel {
- DOCUMENT_VIEWER,
- WEB_BROWSER
- }
- [CCode (cprefix = "WEBKIT_DOWNLOAD_ERROR_", cheader_filename = "webkit/webkit.h")]
- public enum DownloadError {
- CANCELLED_BY_USER,
- DESTINATION,
- NETWORK
- }
- [CCode (cprefix = "WEBKIT_DOWNLOAD_STATUS_", cheader_filename = "webkit/webkit.h")]
- public enum DownloadStatus {
- ERROR,
- CREATED,
- STARTED,
- CANCELLED,
- FINISHED
- }
- [CCode (cprefix = "WEBKIT_EDITING_BEHAVIOR_", cheader_filename = "webkit/webkit.h")]
- public enum EditingBehavior {
- MAC,
- WINDOWS
- }
- [CCode (cprefix = "WEBKIT_HIT_TEST_RESULT_CONTEXT_", cheader_filename = "webkit/webkit.h")]
- [Flags]
- public enum HitTestResultContext {
- DOCUMENT,
- LINK,
- IMAGE,
- MEDIA,
- SELECTION,
- EDITABLE
- }
- [CCode (cprefix = "WEBKIT_LOAD_", cheader_filename = "webkit/webkit.h")]
- public enum LoadStatus {
- PROVISIONAL,
- COMMITTED,
- FINISHED,
- FIRST_VISUALLY_NON_EMPTY_LAYOUT,
- FAILED
- }
- [CCode (cprefix = "WEBKIT_NAVIGATION_RESPONSE_", cheader_filename = "webkit/webkit.h")]
- public enum NavigationResponse {
- ACCEPT,
- IGNORE,
- DOWNLOAD
- }
- [CCode (cprefix = "WEBKIT_NETWORK_ERROR_", cheader_filename = "webkit/webkit.h")]
- public enum NetworkError {
- FAILED,
- TRANSPORT,
- UNKNOWN_PROTOCOL,
- CANCELLED,
- FILE_DOES_NOT_EXIST
- }
- [CCode (cprefix = "WEBKIT_PLUGIN_ERROR_", cheader_filename = "webkit/webkit.h")]
- public enum PluginError {
- FAILED,
- CANNOT_FIND_PLUGIN,
- CANNOT_LOAD_PLUGIN,
- JAVA_UNAVAILABLE,
- CONNECTION_CANCELLED,
- WILL_HANDLE_LOAD
- }
- [CCode (cprefix = "WEBKIT_POLICY_ERROR_", cheader_filename = "webkit/webkit.h")]
- public enum PolicyError {
- FAILED,
- CANNOT_SHOW_MIME_TYPE,
- CANNOT_SHOW_URL,
- FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE,
- CANNOT_USE_RESTRICTED_PORT
- }
- [CCode (cprefix = "WEBKIT_WEB_NAVIGATION_REASON_", cheader_filename = "webkit/webkit.h")]
- public enum WebNavigationReason {
- LINK_CLICKED,
- FORM_SUBMITTED,
- BACK_FORWARD,
- RELOAD,
- FORM_RESUBMITTED,
- OTHER
- }
- [CCode (cprefix = "WEBKIT_WEB_VIEW_TARGET_INFO_", cheader_filename = "webkit/webkit.h")]
- public enum WebViewTargetInfo {
- HTML,
- TEXT,
- IMAGE,
- URI_LIST,
- NETSCAPE_URL
- }
- [CCode (cheader_filename = "webkit/webkit.h")]
- public const int MAJOR_VERSION;
- [CCode (cheader_filename = "webkit/webkit.h")]
- public const int MICRO_VERSION;
- [CCode (cheader_filename = "webkit/webkit.h")]
- public const int MINOR_VERSION;
- [CCode (cheader_filename = "webkit/webkit.h")]
- public const int USER_AGENT_MAJOR_VERSION;
- [CCode (cheader_filename = "webkit/webkit.h")]
- public const int USER_AGENT_MINOR_VERSION;
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static bool check_version (uint major, uint minor, uint micro);
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static void geolocation_policy_allow (WebKit.GeolocationPolicyDecision decision);
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static void geolocation_policy_deny (WebKit.GeolocationPolicyDecision decision);
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static WebKit.CacheModel get_cache_model ();
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static unowned Soup.Session get_default_session ();
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static uint64 get_default_web_database_quota ();
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static unowned WebKit.FaviconDatabase get_favicon_database ();
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static unowned WebKit.IconDatabase get_icon_database ();
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static unowned string get_web_database_directory_path ();
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static unowned WebKit.WebPluginDatabase get_web_plugin_database ();
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static uint major_version ();
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static uint micro_version ();
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static uint minor_version ();
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static GLib.Quark network_error_quark ();
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static GLib.Quark plugin_error_quark ();
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static GLib.Quark policy_error_quark ();
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static void remove_all_web_databases ();
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static void set_cache_model (WebKit.CacheModel cache_model);
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static void set_default_web_database_quota (uint64 defaultQuota);
- [CCode (cheader_filename = "webkit/webkit.h")]
- public static void set_web_database_directory_path (string path);
-}
diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c
deleted file mode 100644
index 6909a1c6..00000000
--- a/panels/midori-bookmarks.c
+++ /dev/null
@@ -1,1423 +0,0 @@
-/*
- Copyright (C) 2008-2009 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.
-*/
-
-#include "midori-bookmarks.h"
-
-#include "midori-array.h"
-#include "midori-app.h"
-#include "midori-browser.h"
-#include "midori-platform.h"
-#include "midori-view.h"
-#include "midori-core.h"
-#include "midori-bookmarks-db.h"
-
-#include <glib/gi18n.h>
-#include <string.h>
-
-#include <gdk/gdkkeysyms.h>
-
-#define COMPLETION_DELAY 200
-
-gboolean
-midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
- KatzeItem* bookmark_or_parent,
- gboolean new_bookmark,
- gboolean is_folder,
- GtkWidget* proxy);
-
-void
-midori_browser_open_bookmark (MidoriBrowser* browser,
- KatzeItem* item);
-
-struct _MidoriBookmarks
-{
- GtkVBox parent_instance;
- GtkWidget* toolbar;
- GtkWidget* edit;
- GtkWidget* delete;
- GtkWidget* treeview;
- MidoriApp* app;
- MidoriBookmarksDb* bookmarks_db;
-
- gint filter_timeout;
- gchar* filter;
-
- KatzeItem* hovering_item;
-};
-
-struct _MidoriBookmarksClass
-{
- GtkVBoxClass parent_class;
-};
-
-static void
-midori_bookmarks_viewable_iface_init (MidoriViewableIface* iface);
-
-G_DEFINE_TYPE_WITH_CODE (MidoriBookmarks, midori_bookmarks, GTK_TYPE_VBOX,
- G_IMPLEMENT_INTERFACE (MIDORI_TYPE_VIEWABLE,
- midori_bookmarks_viewable_iface_init));
-
-enum
-{
- PROP_0,
-
- PROP_APP
-};
-
-static void
-midori_bookmarks_finalize (GObject* object);
-
-static void
-midori_bookmarks_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_bookmarks_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_bookmarks_row_changed_cb (GtkTreeModel* model,
- GtkTreePath* path,
- GtkTreeIter* iter,
- MidoriBookmarks* bookmarks);
-
-static void
-midori_bookmarks_add_item_cb (KatzeArray* array,
- KatzeItem* item,
- MidoriBookmarks* bookmarks);
-
-static void
-midori_bookmarks_update_item_cb (KatzeArray* array,
- KatzeItem* item,
- MidoriBookmarks* bookmarks);
-
-static void
-midori_bookmarks_remove_item_cb (KatzeArray* array,
- KatzeItem* item,
- MidoriBookmarks* bookmarks);
-
-static void
-midori_bookmarks_update_cb (KatzeArray* array,
- MidoriBookmarks* bookmarks);
-
-static void
-midori_bookmarks_statusbar_update (MidoriBookmarks *bookmarks);
-
-static void
-midori_bookmarks_add_item (KatzeItem* item,
- MidoriBookmarks* bookmarks);
-
-static void
-midori_bookmarks_class_init (MidoriBookmarksClass* class)
-{
- GObjectClass* gobject_class;
- GParamFlags flags;
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = midori_bookmarks_finalize;
- gobject_class->set_property = midori_bookmarks_set_property;
- gobject_class->get_property = midori_bookmarks_get_property;
-
- flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
-
- g_object_class_install_property (gobject_class,
- PROP_APP,
- g_param_spec_object (
- "app",
- "App",
- "The app",
- MIDORI_TYPE_APP,
- flags));
-}
-
-static const gchar*
-midori_bookmarks_get_label (MidoriViewable* viewable)
-{
- return _("Bookmarks");
-}
-
-static const gchar*
-midori_bookmarks_get_stock_id (MidoriViewable* viewable)
-{
- return STOCK_BOOKMARKS;
-}
-
-#if 0 /* Make sure the following function is never used */
-/* TODO: Function never used */
-void
-midori_bookmarks_export_array_db (sqlite3* db,
- KatzeArray* array,
- gint64 parentid)
-{
- KatzeArray* root_array;
- KatzeArray* subarray;
- KatzeItem* item;
- GList* list;
- gchar* parent_id;
-
- parent_id = g_strdup_printf ("%" G_GINT64_FORMAT, parentid);
- if (!(root_array = midori_bookmarks_db_query_recursive (array, "*", "parentid = %q", parent_id, FALSE)))
- {
- g_free (parent_id);
- return;
- }
- KATZE_ARRAY_FOREACH_ITEM_L (item, root_array, list)
- {
- if (KATZE_ITEM_IS_FOLDER (item))
- {
- subarray = katze_array_new (KATZE_TYPE_ARRAY);
- katze_item_set_name (KATZE_ITEM (subarray), katze_item_get_name (item));
- midori_bookmarks_export_array_db (db, subarray,
- katze_item_get_meta_integer (item, "parentid"));
- katze_array_add_item (array, subarray);
- }
- else
- katze_array_add_item (array, item);
- }
-
- g_free (parent_id);
- g_list_free (list);
-}
-#endif /* 0 */
-
-static KatzeArray*
-midori_bookmarks_read_from_db (MidoriBookmarks* bookmarks,
- gint64 parentid,
- const gchar* keyword)
-{
- KatzeArray* array;
-
- if (keyword && *keyword)
- array = midori_bookmarks_db_query_recursive (bookmarks->bookmarks_db,
- "id, parentid, title, uri, desc, app, toolbar, pos_panel, pos_bar", "title LIKE '%%%q%%'", keyword, FALSE);
- else
- {
- if (parentid > 0)
- {
- gchar* parent_id = g_strdup_printf ("%" G_GINT64_FORMAT, parentid);
- array = midori_bookmarks_db_query_recursive (bookmarks->bookmarks_db,
- "id, parentid, title, uri, desc, app, toolbar, pos_panel, pos_bar", "parentid = %q", parent_id, FALSE);
-
- g_free (parent_id);
- }
- else
- array = midori_bookmarks_db_query_recursive (bookmarks->bookmarks_db,
- "id, parentid, title, uri, desc, app, toolbar, pos_panel, pos_bar", "parentid IS NULL", NULL, FALSE);
- }
- return array ? array : katze_array_new (KATZE_TYPE_ITEM);
-}
-
-static void
-midori_bookmarks_read_from_db_to_model (MidoriBookmarks* bookmarks,
- GtkTreeStore* model,
- GtkTreeIter* parent,
- gint64 parentid,
- const gchar* keyword)
-{
- KatzeArray* array;
- gint last;
- KatzeItem* item;
- GtkTreeIter child;
-
- array = midori_bookmarks_read_from_db (bookmarks, parentid, keyword);
- katze_bookmark_populate_tree_view (array, model, parent);
- /* Remove invisible dummy row */
- last = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), parent);
- if (!last)
- return;
- gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (model), &child, parent, last - 1);
- gtk_tree_model_get (GTK_TREE_MODEL (model), &child, 0, &item, -1);
- if (KATZE_ITEM_IS_SEPARATOR (item))
- gtk_tree_store_remove (model, &child);
- else
- g_object_unref (item);
- g_object_unref (G_OBJECT (array));
-}
-
-static gboolean
-midori_bookmarks_reach_item_recurse (GtkTreeModel* model,
- GtkTreeIter* iter,
- gint64 id)
-{
- do
- {
- GtkTreeIter child;
- KatzeItem *item;
- gint64 itemid = -1;
-
- gtk_tree_model_get (model, iter, 0, &item, -1);
-
- if (!KATZE_ITEM_IS_SEPARATOR(item))
- {
- itemid = katze_item_get_meta_integer (item, "id");
- g_object_unref (item);
- }
-
- if (id == itemid)
- return TRUE;
-
- if (gtk_tree_model_iter_children (model, &child, iter))
- {
- if (midori_bookmarks_reach_item_recurse (model, &child, id))
- {
- *iter = child;
- return TRUE;
- }
- }
- }
- while (gtk_tree_model_iter_next(model, iter));
-
- return FALSE;
-}
-
-static gboolean
-midori_bookmarks_reach_item (GtkTreeModel* model,
- GtkTreeIter* iter,
- gint64 id)
-{
- if (!gtk_tree_model_get_iter_first(model, iter))
- return FALSE;
-
- return midori_bookmarks_reach_item_recurse (model, iter, id);
-}
-
-static void
-midori_bookmarks_add_item_to_model(GtkTreeStore* model,
- GtkTreeIter* parent,
- KatzeItem* item)
-{
- if (KATZE_ITEM_IS_BOOKMARK (item))
- {
- gchar* tooltip = g_markup_escape_text (katze_item_get_uri (item), -1);
-
- gtk_tree_store_insert_with_values (model, NULL, parent,
- 0,
- 0, item, 1, tooltip, -1);
- g_free (tooltip);
- }
- else
- {
- GtkTreeIter root_iter;
-
- gtk_tree_store_insert_with_values (model, &root_iter, parent,
- 0, 0, item, -1);
-
- /* That's an invisible dummy, so we always have an expander */
- gtk_tree_store_insert_with_values (model, NULL, &root_iter,
- 0,
- 0, NULL, -1);
- }
-}
-
-static void
-midori_bookmarks_update_item_in_model(MidoriBookmarks* bookmarks,
- GtkTreeStore* model,
- GtkTreeIter* iter,
- KatzeItem* item)
-{
- g_signal_handlers_block_by_func (model,
- midori_bookmarks_row_changed_cb,
- bookmarks);
-
- if (KATZE_ITEM_IS_BOOKMARK (item))
- {
- gchar* tooltip = g_markup_escape_text (katze_item_get_uri (item), -1);
-
- gtk_tree_store_set(model, iter,
- 0, item, 1, tooltip, -1);
-
- g_free (tooltip);
- }
- else
- {
- gtk_tree_store_set(model, iter,
- 0, item, -1);
- }
-
- g_signal_handlers_unblock_by_func (model,
- midori_bookmarks_row_changed_cb,
- bookmarks);
-}
-
-static void
-midori_bookmarks_add_item_cb (KatzeArray* array,
- KatzeItem* item,
- MidoriBookmarks* bookmarks)
-{
- midori_bookmarks_add_item (item, bookmarks);
-}
-
-
-static void
-midori_bookmarks_add_item (KatzeItem* item,
- MidoriBookmarks* bookmarks)
-{
- gint64 parentid = katze_item_get_meta_integer (item, "parentid");
- GtkTreeModel* model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
- GtkTreeIter iter;
-
- if (parentid == -1)
- {
- midori_bookmarks_add_item_to_model (GTK_TREE_STORE (model), NULL, item);
- }
- else if (midori_bookmarks_reach_item (model, &iter, parentid))
- {
- GtkTreePath* path = gtk_tree_model_get_path(model, &iter);
-
- if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (bookmarks->treeview), path))
- {
- midori_bookmarks_add_item_to_model (GTK_TREE_STORE (model), &iter, item);
- }
-
- gtk_tree_path_free (path);
- }
-}
-
-static void
-midori_bookmarks_update_item_cb (KatzeArray* array,
- KatzeItem* item,
- MidoriBookmarks* bookmarks)
-{
- gint64 id = katze_item_get_meta_integer (item, "id");
- gint64 parentid = katze_item_get_meta_integer (item, "parentid");
- GtkTreeModel* model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
- GtkTreeIter iter;
-
- if (midori_bookmarks_reach_item (model, &iter, id))
- {
- gint64 old_parentid = 0;
- GtkTreeIter parent;
-
- if (gtk_tree_model_iter_parent (model, &parent, &iter))
- {
- KatzeItem* old_parent;
-
- gtk_tree_model_get (model, &parent, 0, &old_parent, -1);
-
- old_parentid = katze_item_get_meta_integer (old_parent, "id");
-
- g_object_unref (old_parent);
-
- if (parentid == old_parentid)
- {
- midori_bookmarks_update_item_in_model (bookmarks, GTK_TREE_STORE (model), &iter, item);
- }
- else
- {
- gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
-
- if (!gtk_tree_model_iter_has_child (model, &parent))
- {
- GtkTreePath* path = gtk_tree_model_get_path(model, &parent);
-
- if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (bookmarks->treeview), path))
- gtk_tree_view_collapse_row (GTK_TREE_VIEW (bookmarks->treeview), path);
-
- gtk_tree_path_free (path);
- }
-
- midori_bookmarks_add_item (item, bookmarks);
- }
- }
- else if (parentid == 0)
- {
- midori_bookmarks_update_item_in_model (bookmarks, GTK_TREE_STORE (model), &iter, item);
- }
- else
- {
- gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
-
- midori_bookmarks_add_item (item, bookmarks);
- }
- }
- else
- midori_bookmarks_add_item (item, bookmarks);
-}
-
-static void
-midori_bookmarks_remove_item_cb (KatzeArray* array,
- KatzeItem* item,
- MidoriBookmarks* bookmarks)
-{
- gint64 id = katze_item_get_meta_integer (item, "id");
- GtkTreeModel* model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
- GtkTreeIter iter;
-
- if (midori_bookmarks_reach_item (model, &iter, id))
- {
- GtkTreeIter parent;
-
- if (gtk_tree_model_iter_parent (model, &parent, &iter))
- {
- gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
-
- if (!gtk_tree_model_iter_has_child (model, &parent))
- {
- GtkTreePath* path = gtk_tree_model_get_path(model, &parent);
-
- if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (bookmarks->treeview), path))
- gtk_tree_view_collapse_row (GTK_TREE_VIEW (bookmarks->treeview), path);
-
- gtk_tree_path_free (path);
- }
- }
- else
- {
- gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
- }
- }
-}
-
-static void
-midori_bookmarks_update_cb (KatzeArray* array,
- MidoriBookmarks* bookmarks)
-{
- GtkTreeModel* model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
- gtk_tree_store_clear (GTK_TREE_STORE (model));
- midori_bookmarks_read_from_db_to_model (bookmarks,
- GTK_TREE_STORE (model), NULL, 0, bookmarks->filter);
-}
-
-
-static void
-midori_bookmarks_row_changed_cb (GtkTreeModel* model,
- GtkTreePath* path,
- GtkTreeIter* iter,
- MidoriBookmarks* bookmarks)
-{
- KatzeItem* item;
- GtkTreeIter parent;
- KatzeItem* new_parent = NULL;
- gint64 parentid;
-
- gtk_tree_model_get (model, iter, 0, &item, -1);
-
- if (gtk_tree_model_iter_parent (model, &parent, iter))
- {
- gtk_tree_model_get (model, &parent, 0, &new_parent, -1);
-
- /* Bookmarks must not be moved into non-folder items */
- if (!KATZE_ITEM_IS_FOLDER (new_parent))
- parentid = 0;
- else
- parentid = katze_item_get_meta_integer (new_parent, "id");
- }
- else
- parentid = 0;
-
- katze_item_set_meta_integer (item, "parentid", parentid);
-
- g_signal_handlers_block_by_func (bookmarks->bookmarks_db,
- midori_bookmarks_update_item_cb,
- bookmarks);
-
- midori_bookmarks_db_update_item (bookmarks->bookmarks_db, item);
-
- g_signal_handlers_unblock_by_func (bookmarks->bookmarks_db,
- midori_bookmarks_update_item_cb,
- bookmarks);
-
- g_object_unref (item);
- if (new_parent)
- g_object_unref (new_parent);
-}
-
-static void
-midori_bookmarks_add_clicked_cb (GtkWidget* toolitem,
- MidoriBookmarks* bookmarks)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (toolitem);
- GtkTreeView* treeview = GTK_TREE_VIEW (bookmarks->treeview);
- GtkTreeModel* model;
- GtkTreeIter iter;
- KatzeItem* parent = NULL;
-
- if (katze_tree_view_get_selected_iter (treeview,
- &model, &iter))
- {
- gboolean done = FALSE;
- while (!done)
- {
- gtk_tree_model_get (model, &iter, 0, &parent, -1);
-
- if (KATZE_ITEM_IS_FOLDER (parent))
- {
- GtkTreePath* path = gtk_tree_model_get_path(model, &iter);
-
- if (!gtk_tree_view_row_expanded (treeview, path))
- gtk_tree_view_expand_row (treeview, path, FALSE);
-
- gtk_tree_path_free (path);
- done = TRUE;
- }
- else
- {
- GtkTreeIter child = iter;
-
- if (parent) g_object_unref (parent);
- parent = NULL;
-
- if (!gtk_tree_model_iter_parent (model, &iter, &child))
- {
- done = TRUE;
- }
- }
- }
- }
-
- if (g_str_equal (gtk_widget_get_name (toolitem), "BookmarkFolderAdd"))
- midori_browser_edit_bookmark_dialog_new (browser, parent, TRUE, TRUE, toolitem);
- else
- midori_browser_edit_bookmark_dialog_new (browser, parent, TRUE, FALSE, toolitem);
-
- if (parent)
- g_object_unref (parent);
-}
-
-static void
-midori_bookmarks_edit_clicked_cb (GtkWidget* toolitem,
- MidoriBookmarks* bookmarks)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (bookmarks->treeview),
- &model, &iter))
- {
- KatzeItem* item;
- MidoriBrowser* browser;
-
- gtk_tree_model_get (model, &iter, 0, &item, -1);
-
- g_assert (!KATZE_ITEM_IS_SEPARATOR (item));
-
- browser = midori_browser_get_for_widget (bookmarks->treeview);
- midori_browser_edit_bookmark_dialog_new (
- browser, item, FALSE, KATZE_ITEM_IS_FOLDER (item), NULL);
-
- g_object_unref (item);
- }
-}
-
-static void
-midori_bookmarks_toolbar_update (MidoriBookmarks *bookmarks)
-{
- gboolean selected;
-
- selected = katze_tree_view_get_selected_iter (
- GTK_TREE_VIEW (bookmarks->treeview), NULL, NULL);
- gtk_widget_set_sensitive (GTK_WIDGET (bookmarks->delete), selected);
- gtk_widget_set_sensitive (GTK_WIDGET (bookmarks->edit), selected);
-}
-
-static gchar*
-midori_bookmarks_statusbar_bookmarks_str (gint count)
-{
- if (!count)
- return NULL;
-
- /* i18n: [n] bookmark(s) */
- return g_strdup_printf (ngettext ("%d bookmark", "%d bookmarks", count), count);
-}
-
-static gchar*
-midori_bookmarks_statusbar_subfolders_str (gint count)
-{
- if (!count)
- return NULL;
-
- /* i18n: [n] subfolder(s) */
- return g_strdup_printf (ngettext ("%d subfolder", "%d subfolders", count), count);
-}
-
-static void
-midori_bookmarks_statusbar_update (MidoriBookmarks *bookmarks)
-{
- gchar* text = NULL;
-
- if (bookmarks->hovering_item)
- {
- KatzeItem* item = bookmarks->hovering_item;
-
- g_assert (!KATZE_ITEM_IS_SEPARATOR (item));
-
- if (KATZE_ITEM_IS_FOLDER (item))
- {
- gint child_folders_count = midori_bookmarks_db_count_recursive (bookmarks->bookmarks_db,
- "uri = ''", NULL, item, FALSE);
- gint child_bookmarks_count = midori_bookmarks_db_count_recursive (bookmarks->bookmarks_db,
- "uri <> ''", NULL, item, FALSE);
- gchar* child_folders_str = midori_bookmarks_statusbar_subfolders_str (child_folders_count);
- gchar* child_bookmarks_str = midori_bookmarks_statusbar_bookmarks_str (child_bookmarks_count);
-
- if (!child_bookmarks_count && !child_folders_count)
- /* i18n: Empty folder */
- text = g_strdup_printf (_("Empty folder"));
- else if (!child_bookmarks_count && (child_folders_count >= 1))
- /* i18n: Folder containing [[n] folder(s)] and no bookmark */
- text = g_strdup_printf (_("Folder containing %s and no bookmark"),
- child_folders_str);
- else if ((child_bookmarks_count >= 1) && !child_folders_count)
- /* i18n: Folder containing [[n] bookmark(s)] */
- text = g_strdup_printf (_("Folder containing %s"), child_bookmarks_str);
- else if ((child_bookmarks_count >= 1) && (child_folders_count >= 1))
- /* i18n: Folder containing [[n] bookmark(s)] and [[n] folder(s)] */
- text = g_strdup_printf (_("Folder containing %s and %s"),
- child_bookmarks_str, child_folders_str);
-
- g_free (child_folders_str);
- g_free (child_bookmarks_str);
- }
- else if (KATZE_ITEM_IS_BOOKMARK (item))
- {
- const gchar* uri = katze_item_get_uri (item);
-
- /* i18n: Bookmark leading to: [bookmark uri] */
- text = g_strdup_printf (_("Bookmark leading to: %s"), uri);
- }
- }
- else
- {
- gint child_folders_count = midori_bookmarks_db_count_recursive (bookmarks->bookmarks_db,
- "uri = ''", NULL, NULL, FALSE);
- gint child_bookmarks_count = midori_bookmarks_db_count_recursive (bookmarks->bookmarks_db,
- "uri <> ''", NULL, NULL, FALSE);
- gchar* child_folders_str = midori_bookmarks_statusbar_subfolders_str (child_folders_count);
- gchar* child_bookmarks_str = midori_bookmarks_statusbar_bookmarks_str (child_bookmarks_count);
-
- if (!child_bookmarks_count && (child_folders_count >= 1))
- /* i18n: [[n] folder(s)] and no bookmark */
- text = g_strdup_printf (_("%s and no bookmark"),
- child_folders_str);
- else if ((child_bookmarks_count >= 1) && !child_folders_count)
- text = g_strdup (child_bookmarks_str);
- else if ((child_bookmarks_count >= 1) && (child_folders_count >= 1))
- /* i18n: [[n] bookmark(s)] and [[n] folder(s)] */
- text = g_strdup_printf (_("%s and %s"),
- child_bookmarks_str, child_folders_str);
-
- g_free (child_folders_str);
- g_free (child_bookmarks_str);
- }
-
- if (text)
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (bookmarks->treeview);
-
- g_object_set (browser, "statusbar-text", text, NULL);
-
- g_free(text);
- }
-}
-
-static void
-midori_bookmarks_delete_clicked_cb (GtkWidget* toolitem,
- MidoriBookmarks* bookmarks)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (bookmarks->treeview),
- &model, &iter))
- {
- KatzeItem* item;
-
- gtk_tree_model_get (model, &iter, 0, &item, -1);
-
- midori_bookmarks_db_remove_item (bookmarks->bookmarks_db, item);
-
- g_object_unref (item);
- }
-}
-
-static GtkWidget*
-midori_bookmarks_get_toolbar (MidoriViewable* viewable)
-{
- MidoriBookmarks* bookmarks = MIDORI_BOOKMARKS (viewable);
-
- if (!bookmarks->toolbar)
- {
- GtkWidget* toolbar;
- GtkToolItem* toolitem;
-
- toolbar = gtk_toolbar_new ();
- bookmarks->toolbar = toolbar;
- toolitem = gtk_tool_button_new_from_stock (STOCK_BOOKMARK_ADD);
- gtk_widget_set_name (GTK_WIDGET (toolitem), "BookmarkAdd");
- gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
- _("Add a new bookmark"));
- gtk_tool_item_set_is_important (toolitem, TRUE);
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (midori_bookmarks_add_clicked_cb), bookmarks);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_show (GTK_WIDGET (toolitem));
- toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_EDIT);
- gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
- _("Edit the selected bookmark"));
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (midori_bookmarks_edit_clicked_cb), bookmarks);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_show (GTK_WIDGET (toolitem));
- bookmarks->edit = GTK_WIDGET (toolitem);
- toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DELETE);
- gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
- _("Delete the selected bookmark"));
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (midori_bookmarks_delete_clicked_cb), bookmarks);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_show (GTK_WIDGET (toolitem));
- bookmarks->delete = GTK_WIDGET (toolitem);
- midori_bookmarks_toolbar_update (bookmarks);
- midori_bookmarks_statusbar_update (bookmarks);
- toolitem = gtk_separator_tool_item_new ();
- gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (toolitem), FALSE);
- gtk_tool_item_set_expand (toolitem, TRUE);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_show (GTK_WIDGET (toolitem));
- toolitem = gtk_tool_button_new_from_stock (STOCK_FOLDER_NEW);
- gtk_widget_set_name (GTK_WIDGET (toolitem), "BookmarkFolderAdd");
- gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
- _("Add a new folder"));
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (midori_bookmarks_add_clicked_cb), bookmarks);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_show (GTK_WIDGET (toolitem));
-
- g_signal_connect (bookmarks->edit, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &bookmarks->edit);
- g_signal_connect (bookmarks->delete, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &bookmarks->delete);
- }
-
- return bookmarks->toolbar;
-}
-
-static void
-midori_bookmarks_viewable_iface_init (MidoriViewableIface* iface)
-{
- iface->get_stock_id = midori_bookmarks_get_stock_id;
- iface->get_label = midori_bookmarks_get_label;
- iface->get_toolbar = midori_bookmarks_get_toolbar;
-}
-
-static void
-midori_bookmarks_set_app (MidoriBookmarks* bookmarks,
- MidoriApp* app)
-{
- GtkTreeModel* model;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
- if (bookmarks->bookmarks_db)
- {
- g_object_unref (bookmarks->bookmarks_db);
- gtk_tree_store_clear (GTK_TREE_STORE (model));
- }
- katze_assign (bookmarks->app, app);
- if (!app)
- return;
-
- g_object_ref (app);
- bookmarks->bookmarks_db = katze_object_get_object (app, "bookmarks");
- midori_bookmarks_read_from_db_to_model (bookmarks, GTK_TREE_STORE (model), NULL, 0, NULL);
- g_signal_connect_object (bookmarks->bookmarks_db, "add-item",
- G_CALLBACK (midori_bookmarks_add_item_cb), bookmarks, G_CONNECT_AFTER);
- g_signal_connect_object (bookmarks->bookmarks_db, "update-item",
- G_CALLBACK (midori_bookmarks_update_item_cb), bookmarks, G_CONNECT_AFTER);
- g_signal_connect_object (bookmarks->bookmarks_db, "remove-item",
- G_CALLBACK (midori_bookmarks_remove_item_cb), bookmarks, 0);
- g_signal_connect_object (bookmarks->bookmarks_db, "update",
- G_CALLBACK (midori_bookmarks_update_cb), bookmarks, 0);
- g_signal_connect_object (model, "row-changed",
- G_CALLBACK (midori_bookmarks_row_changed_cb),
- bookmarks, G_CONNECT_AFTER);
-}
-
-static void
-midori_bookmarks_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- MidoriBookmarks* bookmarks = MIDORI_BOOKMARKS (object);
-
- switch (prop_id)
- {
- case PROP_APP:
- midori_bookmarks_set_app (bookmarks, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_bookmarks_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- MidoriBookmarks* bookmarks = MIDORI_BOOKMARKS (object);
-
- switch (prop_id)
- {
- case PROP_APP:
- g_value_set_object (value, bookmarks->app);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_bookmarks_treeview_render_icon_cb (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- KatzeItem* item;
- GdkPixbuf* pixbuf;
-
- gtk_tree_model_get (model, iter, 0, &item, -1);
-
- pixbuf = katze_item_get_pixbuf (item, treeview);
- g_object_set (renderer, "pixbuf", pixbuf, NULL);
-
- if (pixbuf)
- g_object_unref (pixbuf);
- g_object_unref (item);
-}
-
-static void
-midori_bookmarks_treeview_render_text_cb (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- KatzeItem* item;
-
- gtk_tree_model_get (model, iter, 0, &item, -1);
-
- if (item && katze_item_get_name (item))
- {
- g_object_set (renderer, "markup", NULL,
- "ellipsize", PANGO_ELLIPSIZE_END,
- "text", katze_item_get_name (item), NULL);
- }
- else
- g_object_set (renderer, "markup", _("<i>Separator</i>"), NULL);
-
- if (item)
- g_object_unref (item);
-}
-
-static void
-midori_bookmarks_row_activated_cb (GtkTreeView* treeview,
- GtkTreePath* path,
- GtkTreeViewColumn* column,
- MidoriBookmarks* bookmarks)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
- KatzeItem* item;
-
- model = gtk_tree_view_get_model (treeview);
-
- if (gtk_tree_model_get_iter (model, &iter, path))
- {
- gtk_tree_model_get (model, &iter, 0, &item, -1);
- if (KATZE_ITEM_IS_BOOKMARK (item))
- {
- MidoriBrowser* browser;
-
- browser = midori_browser_get_for_widget (GTK_WIDGET (bookmarks));
- midori_browser_open_bookmark (browser, item);
- g_object_unref (item);
- return;
- }
- if (gtk_tree_view_row_expanded (treeview, path))
- gtk_tree_view_collapse_row (treeview, path);
- else
- gtk_tree_view_expand_row (treeview, path, FALSE);
- g_object_unref (item);
- }
-}
-
-static void
-midori_bookmarks_popup_item (GtkWidget* menu,
- const gchar* stock_id,
- const gchar* label,
- KatzeItem* item,
- gpointer callback,
- MidoriBookmarks* bookmarks)
-{
- const gchar* uri;
- GtkWidget* menuitem;
-
- uri = KATZE_ITEM_IS_BOOKMARK (item) ? katze_item_get_uri (item) : NULL;
-
- menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
- if (label)
- gtk_label_set_text_with_mnemonic (GTK_LABEL (gtk_bin_get_child (
- GTK_BIN (menuitem))), label);
- if (!strcmp (stock_id, GTK_STOCK_EDIT))
- gtk_widget_set_sensitive (menuitem,
- !KATZE_ITEM_IS_SEPARATOR (item));
- else if (!KATZE_ITEM_IS_FOLDER (item) && strcmp (stock_id, GTK_STOCK_DELETE))
- gtk_widget_set_sensitive (menuitem, uri != NULL);
- g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
- if (callback)
- g_signal_connect (menuitem, "activate", G_CALLBACK (callback), bookmarks);
- else
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- gtk_widget_show (menuitem);
-}
-
-static void
-midori_bookmarks_open_activate_cb (GtkWidget* menuitem,
- MidoriBookmarks* bookmarks)
-{
- KatzeItem* item;
- const gchar* uri;
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
-
- if ((uri = katze_item_get_uri (item)) && *uri)
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (bookmarks));
- midori_browser_set_current_uri (browser, uri);
- }
-}
-
-static void
-midori_bookmarks_open_in_tab_activate_cb (GtkWidget* menuitem,
- MidoriBookmarks* bookmarks)
-{
- KatzeItem* item;
- const gchar* uri;
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
- if (KATZE_ITEM_IS_FOLDER (item))
- {
- KatzeItem* child;
- KatzeArray* array;
-
- array = midori_bookmarks_read_from_db (bookmarks,
- katze_item_get_meta_integer (item, "id"), NULL);
-
- g_return_if_fail (KATZE_IS_ARRAY (array));
- KATZE_ARRAY_FOREACH_ITEM (child, array)
- {
- if ((uri = katze_item_get_uri (child)) && *uri)
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (bookmarks));
- GtkWidget* view = midori_browser_add_item (browser, child);
- midori_browser_set_current_tab_smartly (browser, view);
- }
- }
- g_object_unref (G_OBJECT (array));
- }
- else if ((uri = katze_item_get_uri (item)) && *uri)
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (bookmarks));
- GtkWidget* view = midori_browser_add_item (browser, item);
- midori_browser_set_current_tab_smartly (browser, view);
- }
-}
-
-static void
-midori_bookmarks_open_in_window_activate_cb (GtkWidget* menuitem,
- MidoriBookmarks* bookmarks)
-{
- KatzeItem* item;
- const gchar* uri;
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
- uri = katze_item_get_uri (item);
-
- if (uri && *uri)
- {
- MidoriBrowser* new_browser = midori_app_create_browser (bookmarks->app);
- midori_app_add_browser (bookmarks->app, new_browser);
- gtk_widget_show (GTK_WIDGET (new_browser));
- midori_browser_add_uri (new_browser, uri);
- }
-}
-
-static void
-midori_bookmarks_popup (GtkWidget* widget,
- GdkEventButton* event,
- KatzeItem* item,
- MidoriBookmarks* bookmarks)
-{
- GtkWidget* menu;
- GtkWidget* menuitem;
-
- menu = gtk_menu_new ();
- if (KATZE_ITEM_IS_FOLDER (item))
- {
- gint child_bookmarks_count = midori_bookmarks_db_count_recursive (bookmarks->bookmarks_db,
- "uri <> ''", NULL, item, FALSE);
-
- midori_bookmarks_popup_item (menu,
- STOCK_TAB_NEW, _("Open all in _Tabs"), item,
- (!child_bookmarks_count ? NULL : midori_bookmarks_open_in_tab_activate_cb),
- bookmarks);
- }
- else
- {
- midori_bookmarks_popup_item (menu, GTK_STOCK_OPEN, NULL,
- item, midori_bookmarks_open_activate_cb, bookmarks);
- midori_bookmarks_popup_item (menu, STOCK_TAB_NEW, _("Open in New _Tab"),
- item, midori_bookmarks_open_in_tab_activate_cb, bookmarks);
- midori_bookmarks_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"),
- item, midori_bookmarks_open_in_window_activate_cb, bookmarks);
- }
- menuitem = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- gtk_widget_show (menuitem);
- midori_bookmarks_popup_item (menu, GTK_STOCK_EDIT, NULL,
- item, midori_bookmarks_edit_clicked_cb, bookmarks);
- midori_bookmarks_popup_item (menu, GTK_STOCK_DELETE, NULL,
- item, midori_bookmarks_delete_clicked_cb, bookmarks);
-
- katze_widget_popup (widget, GTK_MENU (menu), event, KATZE_MENU_POSITION_CURSOR);
-}
-
-static gboolean
-midori_bookmarks_button_release_event_cb (GtkWidget* widget,
- GdkEventButton* event,
- MidoriBookmarks* bookmarks)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- if (event->button != 2 && event->button != 3)
- return FALSE;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
- {
- KatzeItem* item;
-
- gtk_tree_model_get (model, &iter, 0, &item, -1);
-
- if (event->button == 2)
- {
- const gchar* uri;
- if (KATZE_ITEM_IS_BOOKMARK (item) && (uri = katze_item_get_uri (item)) && *uri)
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (widget);
- GtkWidget* view = midori_browser_add_uri (browser, uri);
- midori_browser_set_current_tab (browser, view);
- }
- }
- else
- midori_bookmarks_popup (widget, event, item, bookmarks);
-
- if (item != NULL)
- g_object_unref (item);
- return TRUE;
- }
- return FALSE;
-}
-
-static gboolean
-midori_bookmarks_key_release_event_cb (GtkWidget* widget,
- GdkEventKey* event,
- MidoriBookmarks* bookmarks)
-{
- if (event->keyval == GDK_KEY_Delete)
- midori_bookmarks_delete_clicked_cb (widget, bookmarks);
-
- return FALSE;
-}
-
-static void
-midori_bookmarks_popup_menu_cb (GtkWidget* widget,
- MidoriBookmarks* bookmarks)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
- KatzeItem* item;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
- {
- gtk_tree_model_get (model, &iter, 0, &item, -1);
- midori_bookmarks_popup (widget, NULL, item, bookmarks);
- g_object_unref (item);
- }
-}
-
-static void
-midori_bookmarks_row_expanded_cb (GtkTreeView* treeview,
- GtkTreeIter* iter,
- GtkTreePath* path,
- MidoriBookmarks* bookmarks)
-{
- GtkTreeModel* model;
- KatzeItem* item;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
- gtk_tree_model_get (model, iter, 0, &item, -1);
- midori_bookmarks_read_from_db_to_model (bookmarks, GTK_TREE_STORE (model),
- iter, katze_item_get_meta_integer (item, "id"), NULL);
- g_object_unref (item);
-}
-
-static void
-midori_bookmarks_row_collapsed_cb (GtkTreeView *treeview,
- GtkTreeIter *parent,
- GtkTreePath *path,
- gpointer user_data)
-{
- GtkTreeModel* model;
- GtkTreeStore* treestore;
- GtkTreeIter child;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
- treestore = GTK_TREE_STORE (model);
- while (gtk_tree_model_iter_nth_child (model, &child, parent, 0))
- gtk_tree_store_remove (treestore, &child);
- /* That's an invisible dummy, so we always have an expander */
- gtk_tree_store_insert_with_values (treestore, &child, parent,
- 0, 0, NULL, -1);
-}
-
-static void
-midori_bookmarks_selection_changed_cb (GtkTreeSelection *treeview,
- MidoriBookmarks *bookmarks)
-{
- midori_bookmarks_toolbar_update (bookmarks);
-}
-
-static KatzeItem*
-midori_bookmarks_get_item_at_pos (GtkTreeView *treeview,
- gint x, gint y)
-{
- GtkTreeModel* model = gtk_tree_view_get_model (treeview);
- GtkTreePath* path;
- GtkTreeIter iter;
- KatzeItem* item = NULL;
-
- gtk_tree_view_get_path_at_pos (treeview, x, y,
- &path, NULL, NULL, NULL);
-
- if (!path)
- return NULL;
-
- if (gtk_tree_model_get_iter (model, &iter, path))
- gtk_tree_model_get (model, &iter, 0, &item, -1);
-
- gtk_tree_path_free (path);
-
- return item;
-}
-
-static gboolean
-midori_bookmarks_enter_notify_event_cb (GtkTreeView *treeview,
- GdkEventCrossing *event,
- MidoriBookmarks *bookmarks)
-{
- KatzeItem* item = midori_bookmarks_get_item_at_pos (treeview, event->x, event->y);
-
- if (bookmarks->hovering_item)
- g_object_unref (bookmarks->hovering_item);
-
- bookmarks->hovering_item = item;
-
- midori_bookmarks_statusbar_update (bookmarks);
-
- return FALSE;
-}
-
-static gboolean
-midori_bookmarks_motion_notify_event_cb (GtkTreeView *treeview,
- GdkEventMotion *event,
- MidoriBookmarks *bookmarks)
-{
- gboolean item_changed;
- KatzeItem* item;
- gint x;
- gint y;
-
- if (event->is_hint)
- gtk_widget_get_pointer (GTK_WIDGET (treeview), &x, &y);
- else
- {
- x = event->x;
- y = event->y;
- }
-
- item = midori_bookmarks_get_item_at_pos (treeview, x, y);
-
- item_changed = (bookmarks->hovering_item != item) ? TRUE : FALSE;
-
- if (!item_changed)
- {
- if (item)
- g_object_unref (item);
- }
- else
- {
- if (bookmarks->hovering_item)
- g_object_unref (bookmarks->hovering_item);
-
- bookmarks->hovering_item = item;
-
- midori_bookmarks_statusbar_update (bookmarks);
- }
-
- return FALSE;
-}
-
-static gboolean
-midori_bookmarks_leave_notify_event_cb (GtkTreeView *treeview,
- GdkEventCrossing *event,
- MidoriBookmarks *bookmarks)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (bookmarks->treeview);
-
- if (bookmarks->hovering_item)
- g_object_unref (bookmarks->hovering_item);
-
- bookmarks->hovering_item = NULL;
-
- g_object_set (browser, "statusbar-text", "", NULL);
-
- return FALSE;
-}
-
-static gboolean
-midori_bookmarks_filter_timeout_cb (gpointer data)
-{
- MidoriBookmarks* bookmarks = data;
- GtkTreeModel* model;
- GtkTreeStore* treestore;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
- treestore = GTK_TREE_STORE (model);
-
- gtk_tree_store_clear (treestore);
- midori_bookmarks_read_from_db_to_model (bookmarks,
- treestore, NULL, 0, bookmarks->filter);
-
- return FALSE;
-}
-
-static void
-midori_bookmarks_filter_entry_changed_cb (GtkEntry* entry,
- MidoriBookmarks* bookmarks)
-{
- if (bookmarks->filter_timeout)
- g_source_remove (bookmarks->filter_timeout);
-
- if (!g_object_get_data (G_OBJECT (entry), "sokoke_showing_default"))
- katze_assign (bookmarks->filter, g_strdup (gtk_entry_get_text (entry)));
- else
- katze_assign (bookmarks->filter, NULL);
-
- bookmarks->filter_timeout = midori_timeout_add (COMPLETION_DELAY,
- midori_bookmarks_filter_timeout_cb, bookmarks, NULL);
-}
-
-static void
-midori_bookmarks_init (MidoriBookmarks* bookmarks)
-{
- GtkWidget* entry;
- GtkWidget* box;
- GtkTreeStore* model;
- GtkWidget* treeview;
- GtkTreeViewColumn* column;
- GtkCellRenderer* renderer_pixbuf;
- GtkCellRenderer* renderer_text;
- GtkTreeSelection* selection;
-
- /* Create the filter entry */
- entry = sokoke_search_entry_new (_("Search Bookmarks"));
- g_signal_connect_after (entry, "changed",
- G_CALLBACK (midori_bookmarks_filter_entry_changed_cb), bookmarks);
- box = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 3);
- gtk_widget_show_all (box);
- gtk_box_pack_start (GTK_BOX (bookmarks), box, FALSE, FALSE, 5);
-
- /* Create the treeview */
- model = gtk_tree_store_new (2, KATZE_TYPE_ITEM, G_TYPE_STRING);
- treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
- gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (treeview), 1);
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_expand (column, TRUE);
- renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_pixbuf,
- (GtkTreeCellDataFunc)midori_bookmarks_treeview_render_icon_cb,
- treeview, NULL);
- renderer_text = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer_text, TRUE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_text,
- (GtkTreeCellDataFunc)midori_bookmarks_treeview_render_text_cb,
- treeview, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
- gtk_tree_view_set_reorderable (GTK_TREE_VIEW (treeview), TRUE);
- g_object_unref (model);
- g_object_connect (treeview,
- "signal::row-activated",
- midori_bookmarks_row_activated_cb, bookmarks,
- "signal::button-release-event",
- midori_bookmarks_button_release_event_cb, bookmarks,
- "signal::key-release-event",
- midori_bookmarks_key_release_event_cb, bookmarks,
- "signal::popup-menu",
- midori_bookmarks_popup_menu_cb, bookmarks,
- "signal::row-expanded",
- midori_bookmarks_row_expanded_cb, bookmarks,
- "signal::row-collapsed",
- midori_bookmarks_row_collapsed_cb, bookmarks,
- "signal::enter-notify-event",
- midori_bookmarks_enter_notify_event_cb, bookmarks,
- "signal::motion-notify-event",
- midori_bookmarks_motion_notify_event_cb, bookmarks,
- "signal::leave-notify-event",
- midori_bookmarks_leave_notify_event_cb, bookmarks,
- NULL);
- gtk_widget_add_events (GTK_WIDGET (treeview),
- GDK_POINTER_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- g_signal_connect_after (selection, "changed",
- G_CALLBACK (midori_bookmarks_selection_changed_cb),
- bookmarks);
- gtk_widget_show (treeview);
- gtk_box_pack_start (GTK_BOX (bookmarks), treeview, TRUE, TRUE, 0);
- bookmarks->treeview = treeview;
- bookmarks->hovering_item = NULL;
-}
-
-static void
-midori_bookmarks_finalize (GObject* object)
-{
- MidoriBookmarks* bookmarks = MIDORI_BOOKMARKS (object);
-
- if (bookmarks->app)
- g_object_unref (bookmarks->app);
- if (bookmarks->hovering_item)
- g_object_unref (bookmarks->hovering_item);
-}
diff --git a/panels/midori-bookmarks.h b/panels/midori-bookmarks.h
deleted file mode 100644
index 0c160953..00000000
--- a/panels/midori-bookmarks.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- Copyright (C) 2009 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 __MIDORI_BOOKMARKS_PANEL_H__
-#define __MIDORI_BOOKMARKS_PANEL_H__
-
-#include <sqlite3.h>
-#include <gtk/gtk.h>
-#include <katze/katze.h>
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_BOOKMARKS \
- (midori_bookmarks_get_type ())
-#define MIDORI_BOOKMARKS(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_BOOKMARKS, MidoriBookmarks))
-#define MIDORI_BOOKMARKS_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_BOOKMARKS, MidoriBookmarksClass))
-#define MIDORI_IS_BOOKMARKS(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_BOOKMARKS))
-#define MIDORI_IS_BOOKMARKS_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_BOOKMARKS))
-#define MIDORI_BOOKMARKS_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_BOOKMARKS, MidoriBookmarksClass))
-
-typedef struct _MidoriBookmarks MidoriBookmarks;
-typedef struct _MidoriBookmarksClass MidoriBookmarksClass;
-
-GType
-midori_bookmarks_get_type (void);
-
-G_END_DECLS
-
-#endif /* __MIDORI_BOOKMARKS_PANEL_H__ */
diff --git a/panels/midori-extensions.c b/panels/midori-extensions.c
deleted file mode 100644
index f0ab2c8b..00000000
--- a/panels/midori-extensions.c
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- Copyright (C) 2008-2009 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.
-*/
-
-#include "midori-extensions.h"
-
-#include "midori-app.h"
-#include "midori-extension.h"
-#include "midori-platform.h"
-#include "midori-core.h"
-
-#include <glib/gi18n.h>
-
-struct _MidoriExtensions
-{
- GtkVBox parent_instance;
-
- GtkWidget* toolbar;
- GtkWidget* treeview;
- MidoriApp* app;
-};
-
-struct _MidoriExtensionsClass
-{
- GtkVBoxClass parent_class;
-};
-
-static void
-midori_extensions_viewable_iface_init (MidoriViewableIface* iface);
-
-G_DEFINE_TYPE_WITH_CODE (MidoriExtensions, midori_extensions, GTK_TYPE_VBOX,
- G_IMPLEMENT_INTERFACE (MIDORI_TYPE_VIEWABLE,
- midori_extensions_viewable_iface_init));
-
-enum
-{
- PROP_0,
-
- PROP_APP
-};
-
-static void
-midori_extensions_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_extensions_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_extensions_finalize (GObject* object);
-
-static void
-midori_extensions_class_init (MidoriExtensionsClass* class)
-{
- GObjectClass* gobject_class;
- GParamFlags flags;
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->set_property = midori_extensions_set_property;
- gobject_class->get_property = midori_extensions_get_property;
- gobject_class->finalize = midori_extensions_finalize;
-
- flags = G_PARAM_READWRITE;
-
- g_object_class_install_property (gobject_class,
- PROP_APP,
- g_param_spec_object (
- "app",
- "App",
- "The app",
- MIDORI_TYPE_APP,
- flags));
-}
-
-static const gchar*
-midori_extensions_get_label (MidoriViewable* viewable)
-{
- return _("Extensions");
-}
-
-static const gchar*
-midori_extensions_get_stock_id (MidoriViewable* viewable)
-{
- return STOCK_EXTENSION;
-}
-
-static GtkWidget*
-midori_extensions_get_toolbar (MidoriViewable* extensions)
-{
- if (!MIDORI_EXTENSIONS (extensions)->toolbar)
- {
- GtkWidget* toolbar;
-
- toolbar = gtk_toolbar_new ();
- MIDORI_EXTENSIONS (extensions)->toolbar = toolbar;
- }
-
- return MIDORI_EXTENSIONS (extensions)->toolbar;
-}
-
-static void
-midori_extensions_viewable_iface_init (MidoriViewableIface* iface)
-{
- iface->get_stock_id = midori_extensions_get_stock_id;
- iface->get_label = midori_extensions_get_label;
- iface->get_toolbar = midori_extensions_get_toolbar;
-}
-
-static void
-midori_extensions_extension_activate_cb (MidoriExtension* extension,
- MidoriApp* app,
- MidoriExtensions* extensions)
-{
- gtk_widget_queue_draw (GTK_WIDGET (extensions->treeview));
-}
-
-static void
-midori_extensions_extension_deactivate_cb (MidoriExtension* extension,
- MidoriExtensions* extensions)
-{
- gtk_widget_queue_draw (GTK_WIDGET (extensions->treeview));
-}
-
-static void
-midori_extensions_add_item_cb (KatzeArray* array,
- MidoriExtension* extension,
- MidoriExtensions* extensions)
-{
- GtkTreeIter iter;
- GtkTreeModel* model;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (extensions->treeview));
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, extension, -1);
- g_signal_connect (extension, "activate",
- G_CALLBACK (midori_extensions_extension_activate_cb), extensions);
- g_signal_connect (extension, "deactivate",
- G_CALLBACK (midori_extensions_extension_deactivate_cb), extensions);
-}
-
-static void
-midori_extensions_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- MidoriExtensions* extensions = MIDORI_EXTENSIONS (object);
-
- switch (prop_id)
- {
- case PROP_APP:
- {
- KatzeArray* array;
- MidoriExtension* extension;
-
- /* FIXME: Handle NULL and subsequent assignments */
- extensions->app = g_value_get_object (value);
- array = katze_object_get_object (extensions->app, "extensions");
- g_signal_connect (array, "add-item",
- G_CALLBACK (midori_extensions_add_item_cb), extensions);
-
- KATZE_ARRAY_FOREACH_ITEM (extension, array)
- midori_extensions_add_item_cb (array, extension, extensions);
- g_object_unref (array);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_extensions_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- MidoriExtensions* extensions = MIDORI_EXTENSIONS (object);
-
- switch (prop_id)
- {
- case PROP_APP:
- g_value_set_object (value, extensions->app);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_extensions_treeview_render_tick_cb (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- MidoriExtension* extension;
-
- gtk_tree_model_get (model, iter, 0, &extension, -1);
-
- g_object_set (renderer,
- "activatable", midori_extension_is_prepared (extension),
- "active", midori_extension_is_active (extension) || g_object_get_data (G_OBJECT (extension), "static"),
- "xpad", 4,
- NULL);
-
- g_object_unref (extension);
-}
-
-static void
-midori_extensions_treeview_render_icon_cb (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- MidoriExtension* extension;
- gchar* stock_id;
- gtk_tree_model_get (model, iter, 0, &extension, -1);
-
- stock_id = katze_object_get_object (extension, "stock-id");
- g_object_set (renderer, "stock-id", stock_id ? stock_id : STOCK_EXTENSION,
- "stock-size", GTK_ICON_SIZE_BUTTON,
- "sensitive", midori_extension_is_prepared (extension),
- "xpad", 4, NULL);
- g_free (stock_id);
- g_object_unref (extension);
-}
-
-static void
-midori_extensions_treeview_render_preferences_cb (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- MidoriExtension* extension;
- gtk_tree_model_get (model, iter, 0, &extension, -1);
-
- g_object_set (renderer, "stock-id", GTK_STOCK_PREFERENCES,
- "stock-size", GTK_ICON_SIZE_BUTTON,
- "visible", midori_extension_has_preferences (extension),
- "sensitive", midori_extension_is_active (extension),
- "xpad", 4, NULL);
- g_object_unref (extension);
-}
-
-static void
-midori_extensions_treeview_render_text_cb (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- MidoriExtension* extension;
- gchar* name;
- gchar* version;
- gchar* desc;
- gchar* text;
-
- gtk_tree_model_get (model, iter, 0, &extension, -1);
-
- name = katze_object_get_string (extension, "name");
- version = katze_object_get_string (extension, "version");
- desc = katze_object_get_string (extension, "description");
- if (katze_object_get_boolean (extension, "use-markup"))
- text = g_strdup_printf ("<b>%s</b> %s\n%s",
- name, version && *version ? version : "", desc);
- else
- text = g_markup_printf_escaped ("<b>%s</b> %s\n%s",
- name, version && *version ? version : "", desc);
- g_free (name);
- g_free (version);
- g_free (desc);
-
- g_object_set (renderer,
- "markup", text,
- "ellipsize", PANGO_ELLIPSIZE_END,
- "sensitive", midori_extension_is_prepared (extension),
- NULL);
-
- g_free (text);
- g_object_unref (extension);
-}
-
-static void
-midori_extensions_treeview_row_activated_cb (GtkTreeView* treeview,
- GtkTreePath* path,
- GtkTreeViewColumn* column,
- MidoriExtensions* extensions)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- model = gtk_tree_view_get_model (treeview);
- if (gtk_tree_model_get_iter (model, &iter, path))
- {
- MidoriExtension* extension;
- KatzeArray* array = katze_object_get_object (extensions->app, "extensions");
-
- gtk_tree_model_get (model, &iter, 0, &extension, -1);
- if (midori_extension_is_active (extension))
- midori_extension_deactivate (extension);
- else if (midori_extension_is_prepared (extension))
- g_signal_emit_by_name (extension, "activate", extensions->app);
- /* Make it easy for listeners to see that extensions changed */
- katze_array_update (array);
-
- g_object_unref (array);
- g_object_unref (extension);
- }
-}
-
-static void
-midori_extensions_cell_renderer_toggled_cb (GtkCellRendererToggle* renderer,
- const gchar* path,
- MidoriExtensions* extensions)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (extensions->treeview));
- if (gtk_tree_model_get_iter_from_string (model, &iter, path))
- {
- MidoriExtension* extension;
- KatzeArray* array = katze_object_get_object (extensions->app, "extensions");
-
- gtk_tree_model_get (model, &iter, 0, &extension, -1);
- if (midori_extension_is_active (extension))
- midori_extension_deactivate (extension);
- else if (midori_extension_is_prepared (extension))
- g_signal_emit_by_name (extension, "activate", extensions->app);
- /* Make it easy for listeners to see that extensions changed */
- katze_array_update (array);
-
- g_object_unref (array);
- g_object_unref (extension);
- }
-}
-
-static gint
-midori_extensions_tree_sort_func (GtkTreeModel* model,
- GtkTreeIter* a,
- GtkTreeIter* b,
- gpointer data)
-{
- MidoriExtension* e1, *e2;
- gchar* name1, *name2;
- gint result = 0;
-
- gtk_tree_model_get (model, a, 0, &e1, -1);
- gtk_tree_model_get (model, b, 0, &e2, -1);
-
- name1 = katze_object_get_string (e1, "name");
- name2 = katze_object_get_string (e2, "name");
-
- g_object_unref (e1);
- g_object_unref (e2);
-
- result = g_strcmp0 (name1, name2);
-
- g_free (name1);
- g_free (name2);
-
- return result;
-}
-
-static void
-midori_extensions_treeview_column_preference_clicked_cb (GtkWidget* widget,
- GtkTreeView* treeview,
- GtkTreePath* path)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- model = gtk_tree_view_get_model (treeview);
- if (gtk_tree_model_get_iter (model, &iter, path))
- {
- MidoriExtension* extension;
-
- gtk_tree_model_get (model, &iter, 0, &extension, -1);
- if (midori_extension_is_active (extension))
- g_signal_emit_by_name (extension, "open-preferences");
- g_object_unref (extension);
- }
-
-}
-
-static gboolean
-midori_extensions_treeview_button_pressed_cb (GtkWidget* view,
- GdkEventButton* bevent,
- gpointer data)
-{
- gboolean ret = FALSE;
- GtkTreePath* path;
- GtkTreeViewColumn* column;
- guint signal_id;
-
- if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (view),
- bevent->x, bevent->y, &path, &column, NULL, NULL))
- {
- if (path != NULL)
- {
- if (MIDORI_IS_EXTENSIONS_COLUMN (column))
- {
- signal_id = g_signal_lookup ("row-clicked", G_OBJECT_TYPE (column));
-
- if (signal_id && g_signal_has_handler_pending (column, signal_id, 0, FALSE)) {
- g_signal_emit (column, signal_id, 0, GTK_TREE_VIEW (view), path);
- ret = TRUE;
- }
- }
- gtk_tree_path_free (path);
- }
- }
- return ret;
-}
-
-static gboolean
-extensions_column_search_equal_func (GtkTreeModel* model,
- gint column,
- const gchar* key,
- GtkTreeIter* iter,
- gpointer search_data)
-{
- MidoriExtension* extension;
- gchar* name;
- gchar* lower;
- gboolean match;
-
- gtk_tree_model_get (model, iter, 0, &extension, -1);
- name = katze_object_get_string (extension, "name");
- lower = g_utf8_strdown (name, -1);
- match = !strstr (lower, key);
-
- g_free (lower);
- g_free (name);
-
- return match;
-}
-
-static void
-midori_extensions_init (MidoriExtensions* extensions)
-{
- /* Create the treeview */
- GtkTreeViewColumn* column;
- GtkCellRenderer* renderer_icon;
- GtkCellRenderer* renderer_text;
- GtkCellRenderer* renderer_toggle;
- GtkCellRenderer* renderer_preferences;
- GtkListStore* liststore = gtk_list_store_new (1, G_TYPE_OBJECT);
- extensions->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (liststore));
- g_object_connect (extensions->treeview,
- "signal::button-press-event",
- midori_extensions_treeview_button_pressed_cb, NULL,
- NULL);
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (liststore),
- 0, GTK_SORT_ASCENDING);
- gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (liststore),
- 0, midori_extensions_tree_sort_func, NULL, NULL);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (extensions->treeview), FALSE);
- column = gtk_tree_view_column_new ();
- renderer_toggle = gtk_cell_renderer_toggle_new ();
- gtk_tree_view_column_pack_start (column, renderer_toggle, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_toggle,
- (GtkTreeCellDataFunc)midori_extensions_treeview_render_tick_cb,
- extensions->treeview, NULL);
- g_signal_connect (renderer_toggle, "toggled",
- G_CALLBACK (midori_extensions_cell_renderer_toggled_cb), extensions);
- gtk_tree_view_append_column (GTK_TREE_VIEW (extensions->treeview), column);
- column = gtk_tree_view_column_new ();
- renderer_icon = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, renderer_icon, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_icon,
- (GtkTreeCellDataFunc)midori_extensions_treeview_render_icon_cb,
- extensions->treeview, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (extensions->treeview), column);
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_expand (column, TRUE);
- renderer_text = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer_text, TRUE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_text,
- (GtkTreeCellDataFunc)midori_extensions_treeview_render_text_cb,
- extensions->treeview, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (extensions->treeview), column);
- column = GTK_TREE_VIEW_COLUMN (midori_extensions_column_new ());
- g_signal_connect (column,
- "row-clicked",
- G_CALLBACK (midori_extensions_treeview_column_preference_clicked_cb),
- NULL);
- renderer_preferences = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, renderer_preferences, FALSE);
- gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
- gtk_tree_view_column_set_fixed_width (column, 30);
- gtk_tree_view_column_set_cell_data_func (column, renderer_preferences,
- (GtkTreeCellDataFunc)midori_extensions_treeview_render_preferences_cb,
- extensions->treeview, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (extensions->treeview), column);
- g_object_unref (liststore);
- g_object_connect (extensions->treeview,
- "signal::row-activated",
- midori_extensions_treeview_row_activated_cb, extensions,
- NULL);
- gtk_tree_view_set_search_column (GTK_TREE_VIEW (extensions->treeview), 0);
- gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (extensions->treeview),
- extensions_column_search_equal_func, NULL, NULL);
- gtk_widget_show (extensions->treeview);
- gtk_box_pack_start (GTK_BOX (extensions), extensions->treeview, TRUE, TRUE, 0);
-}
-
-static void
-midori_extensions_finalize (GObject* object)
-{
- MidoriExtensions* extensions = MIDORI_EXTENSIONS (object);
- KatzeArray* array = katze_object_get_object (extensions->app, "extensions");
- MidoriExtension* extension;
-
- KATZE_ARRAY_FOREACH_ITEM (extension, array)
- {
- g_signal_handlers_disconnect_by_func (extension,
- midori_extensions_extension_activate_cb, extensions);
- g_signal_handlers_disconnect_by_func (extension,
- midori_extensions_extension_deactivate_cb, extensions);
- }
- g_signal_handlers_disconnect_by_func (array,
- midori_extensions_add_item_cb, extensions);
-
- g_object_unref (array);
-}
-
diff --git a/panels/midori-extensions.h b/panels/midori-extensions.h
deleted file mode 100644
index 58de7d02..00000000
--- a/panels/midori-extensions.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- 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 __MIDORI_EXTENSIONS_H__
-#define __MIDORI_EXTENSIONS_H__
-
-#include <gtk/gtk.h>
-
-#include <katze/katze.h>
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_EXTENSIONS \
- (midori_extensions_get_type ())
-#define MIDORI_EXTENSIONS(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_EXTENSIONS, MidoriExtensions))
-#define MIDORI_EXTENSIONS_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_EXTENSIONS, MidoriExtensionsClass))
-#define MIDORI_IS_EXTENSIONS(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_EXTENSIONS))
-#define MIDORI_IS_EXTENSIONS_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_EXTENSIONS))
-#define MIDORI_EXTENSIONS_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_EXTENSIONS, MidoriExtensionsClass))
-
-typedef struct _MidoriExtensions MidoriExtensions;
-typedef struct _MidoriExtensionsClass MidoriExtensionsClass;
-
-GType
-midori_extensions_get_type (void);
-
-GtkWidget*
-midori_extensions_new (void);
-
-G_END_DECLS
-
-#endif /* __MIDORI_EXTENSIONS_H__ */
diff --git a/panels/midori-history.c b/panels/midori-history.c
deleted file mode 100644
index 9a50b733..00000000
--- a/panels/midori-history.c
+++ /dev/null
@@ -1,994 +0,0 @@
-/*
- Copyright (C) 2008-2009 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.
-*/
-
-#include "midori-history.h"
-
-#include "midori-app.h"
-#include "midori-array.h"
-#include "midori-browser.h"
-#include "midori-platform.h"
-#include "midori-view.h"
-#include "midori-core.h"
-
-#include <glib/gi18n.h>
-#include <string.h>
-#include <gdk/gdkkeysyms.h>
-
-#define COMPLETION_DELAY 200
-
-void
-midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
- KatzeItem* bookmark,
- gboolean new_bookmark,
- gboolean is_folder,
- GtkWidget* proxy);
-
-
-struct _MidoriHistory
-{
- GtkVBox parent_instance;
-
- GtkWidget* toolbar;
- GtkWidget* bookmark;
- GtkWidget* delete;
- GtkWidget* clear;
- GtkWidget* treeview;
- MidoriApp* app;
- KatzeArray* array;
-
- gint filter_timeout;
- gchar* filter;
-};
-
-struct _MidoriHistoryClass
-{
- GtkVBoxClass parent_class;
-};
-
-static void
-midori_history_viewable_iface_init (MidoriViewableIface* iface);
-
-G_DEFINE_TYPE_WITH_CODE (MidoriHistory, midori_history, GTK_TYPE_VBOX,
- G_IMPLEMENT_INTERFACE (MIDORI_TYPE_VIEWABLE,
- midori_history_viewable_iface_init));
-
-enum
-{
- PROP_0,
-
- PROP_APP
-};
-
-static void
-midori_history_finalize (GObject* object);
-
-static void
-midori_history_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_history_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec);
-
-static void
-midori_history_class_init (MidoriHistoryClass* class)
-{
- GObjectClass* gobject_class;
- GParamFlags flags;
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = midori_history_finalize;
- gobject_class->set_property = midori_history_set_property;
- gobject_class->get_property = midori_history_get_property;
-
- flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
-
- g_object_class_install_property (gobject_class,
- PROP_APP,
- g_param_spec_object (
- "app",
- "App",
- "The app",
- MIDORI_TYPE_APP,
- flags));
-}
-
-static const gchar*
-midori_history_get_label (MidoriViewable* viewable)
-{
- return _("History");
-}
-
-static const gchar*
-midori_history_get_stock_id (MidoriViewable* viewable)
-{
- return STOCK_HISTORY;
-}
-
-static gchar*
-midori_history_format_date (KatzeItem *item)
-{
- gint64 day = katze_item_get_added (item);
- gchar* sdate;
- gint age;
- GDateTime* now = g_date_time_new_now_local ();
- GDateTime* then = g_date_time_new_from_unix_local (day);
- age = g_date_time_get_day_of_year (now) - g_date_time_get_day_of_year (then);
- if (g_date_time_get_year (now) != g_date_time_get_year (then))
- age = 999;
-
- if (age == 0)
- sdate = g_strdup (_("Today"));
- else if (age == 1)
- sdate = g_strdup (_("Yesterday"));
- else if (age < 7)
- sdate = g_strdup_printf (ngettext ("%d day ago",
- "%d days ago", (gint)age), (gint)age);
- else if (age == 7)
- sdate = g_strdup (_("A week ago"));
- else
- sdate = g_date_time_format (then, "%x");
- g_date_time_unref (now);
- g_date_time_unref (then);
-
- return sdate;
-}
-
-static void
-midori_history_toolbar_update (MidoriHistory *history)
-{
- gboolean selected;
-
- selected = katze_tree_view_get_selected_iter (
- GTK_TREE_VIEW (history->treeview), NULL, NULL);
- gtk_widget_set_sensitive (GTK_WIDGET (history->delete), selected);
-}
-
-static void
-midori_history_remove_item_from_db (MidoriHistory* history,
- KatzeItem* item)
-{
- gchar* sqlcmd;
- sqlite3* db;
- char* errmsg = NULL;
-
- db = g_object_get_data (G_OBJECT (history->array), "db");
-
- if (!db)
- return;
-
- if (KATZE_ITEM_IS_BOOKMARK (item))
- sqlcmd = sqlite3_mprintf (
- "DELETE FROM history WHERE uri = '%q' AND"
- " title = '%q' AND date = %llu",
- katze_item_get_uri (item),
- katze_item_get_name (item),
- katze_item_get_added (item));
- else
- sqlcmd = sqlite3_mprintf ("DELETE FROM history WHERE day = %d",
- katze_item_get_meta_integer (item, "day"));
-
- if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK)
- {
- g_printerr (_("Failed to remove history item: %s\n"), errmsg);
- sqlite3_free (errmsg);
- }
-
- sqlite3_free (sqlcmd);
-}
-
-/**
- * midori_history_read_from_db:
- * @history: a #MidoriHistory
- * @req_day: the timestamp of one day, or 0
- * @filter: a filter string to search for
- *
- * Populates the model according to parameters:
- * 1. If @req_day is 0, all dates are added as folders.
- * 2. If @req_day is given, all pages for that day are added.
- * 3. If @filter is given, all pages matching the filter are added.
- **/
-static KatzeArray*
-midori_history_read_from_db (MidoriHistory* history,
- int req_day,
- const gchar* filter)
-{
- sqlite3* db;
- sqlite3_stmt* statement;
- gint result;
- const gchar* sqlcmd;
-
- db = g_object_get_data (G_OBJECT (history->array), "db");
-
- if (!db)
- return katze_array_new (KATZE_TYPE_ITEM);
-
- if (filter && *filter)
- {
- gchar* filterstr;
-
- sqlcmd = "SELECT * FROM ("
- " SELECT uri, title, day, date FROM history"
- " WHERE uri LIKE ?1 OR title LIKE ?1 GROUP BY uri "
- "UNION ALL "
- " SELECT replace (uri, '%s', keywords) AS uri, "
- " keywords AS title, day, 0 AS date FROM search "
- " WHERE uri LIKE ?1 OR keywords LIKE ?1 GROUP BY uri "
- ") ORDER BY day ASC";
- result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL);
- filterstr = g_strdup_printf ("%%%s%%", filter);
- sqlite3_bind_text (statement, 1, filterstr, -1, g_free);
- }
- else if (req_day == 0)
- {
- sqlcmd = "SELECT day, date FROM history GROUP BY day ORDER BY day ASC";
- result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL);
- }
- else
- {
- sqlcmd = "SELECT uri, title, date, day "
- "FROM history WHERE day = ? "
- "GROUP BY uri ORDER BY date ASC";
- result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL);
- sqlite3_bind_int64 (statement, 1, req_day);
- }
-
- if (result != SQLITE_OK)
- return katze_array_new (KATZE_TYPE_ITEM);
-
- return katze_array_from_statement (statement);
-}
-
-static void
-midori_history_read_from_db_to_model (MidoriHistory* history,
- GtkTreeStore* model,
- GtkTreeIter* parent,
- int req_day,
- const gchar* filter)
-{
- KatzeArray* array;
- gint last;
- KatzeItem* item;
- GtkTreeIter child;
-
- array = midori_history_read_from_db (history, req_day, filter);
- katze_bookmark_populate_tree_view (array, model, parent);
-
- /* Remove invisible dummy row */
- last = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), parent);
- if (!last)
- return;
- gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (model), &child, parent, last - 1);
- gtk_tree_model_get (GTK_TREE_MODEL (model), &child, 0, &item, -1);
- if (KATZE_ITEM_IS_SEPARATOR (item))
- gtk_tree_store_remove (model, &child);
- else
- g_object_unref (item);
-}
-
-static void
-midori_history_delete_clicked_cb (GtkWidget* toolitem,
- MidoriHistory* history)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (history->treeview),
- &model, &iter))
- {
- KatzeItem* item;
-
- gtk_tree_model_get (model, &iter, 0, &item, -1);
- midori_history_remove_item_from_db (history, item);
- gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
- g_object_unref (item);
- }
-}
-
-static void
-midori_history_clear_clicked_cb (GtkWidget* toolitem,
- MidoriHistory* history)
-{
- MidoriBrowser* browser;
- GtkWidget* dialog;
- gint result;
-
- browser = midori_browser_get_for_widget (GTK_WIDGET (history));
- dialog = gtk_message_dialog_new (GTK_WINDOW (browser),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
- _("Are you sure you want to remove all history items?"));
- result = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- if (result != GTK_RESPONSE_YES)
- return;
-
- katze_array_clear (history->array);
-}
-
-static void
-midori_history_bookmark_add_cb (GtkWidget* menuitem,
- MidoriHistory* history)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
- KatzeItem* item = NULL;
-
- GtkWidget* proxy = GTK_IS_TOOL_ITEM (menuitem) ? menuitem : NULL;
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (history));
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (history->treeview),
- &model, &iter))
- gtk_tree_model_get (model, &iter, 0, &item, -1);
-
- if (KATZE_IS_ITEM (item) && katze_item_get_uri (item))
- {
- midori_browser_edit_bookmark_dialog_new (browser, item, TRUE, FALSE, proxy);
- g_object_unref (item);
- }
- else
- midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE, proxy);
-}
-
-static GtkWidget*
-midori_history_get_toolbar (MidoriViewable* viewable)
-{
- MidoriHistory* history = MIDORI_HISTORY (viewable);
-
- if (!history->toolbar)
- {
- GtkWidget* toolbar;
- GtkToolItem* toolitem;
-
- toolbar = gtk_toolbar_new ();
- history->toolbar = toolbar;
- toolitem = gtk_tool_button_new_from_stock (STOCK_BOOKMARK_ADD);
- gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
- _("Bookmark the selected history item"));
- gtk_tool_item_set_is_important (toolitem, TRUE);
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (midori_history_bookmark_add_cb), history);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_show (GTK_WIDGET (toolitem));
- history->bookmark = GTK_WIDGET (toolitem);
- toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DELETE);
- gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
- _("Delete the selected history item"));
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (midori_history_delete_clicked_cb), history);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_show (GTK_WIDGET (toolitem));
- history->delete = GTK_WIDGET (toolitem);
- toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_CLEAR);
- gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
- _("Clear the entire history"));
- g_signal_connect (toolitem, "clicked",
- G_CALLBACK (midori_history_clear_clicked_cb), history);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_show (GTK_WIDGET (toolitem));
- history->clear = GTK_WIDGET (toolitem);
- midori_history_toolbar_update (history);
- g_signal_connect (history->bookmark, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &history->bookmark);
- g_signal_connect (history->delete, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &history->delete);
- g_signal_connect (history->clear, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &history->clear);
- }
-
- return history->toolbar;
-}
-
-static void
-midori_history_viewable_iface_init (MidoriViewableIface* iface)
-{
- iface->get_stock_id = midori_history_get_stock_id;
- iface->get_label = midori_history_get_label;
- iface->get_toolbar = midori_history_get_toolbar;
-}
-
-static void
-midori_history_add_item_cb (KatzeArray* array,
- KatzeItem* item,
- MidoriHistory* history)
-{
- GtkTreeView* treeview = GTK_TREE_VIEW (history->treeview);
- GtkTreeModel* model = gtk_tree_view_get_model (treeview);
- GtkTreeIter iter;
- KatzeItem* today;
- time_t current_time = time (NULL);
-
- if (gtk_tree_model_iter_children (model, &iter, NULL))
- {
- gint64 day;
- gboolean has_today;
-
- gtk_tree_model_get (model, &iter, 0, &today, -1);
-
- day = katze_item_get_added (today);
- has_today = g_date_time_get_day_of_month (
- g_date_time_new_from_unix_local (day))
- == g_date_time_get_day_of_month (
- g_date_time_new_from_unix_local (current_time))
- && g_date_time_get_day_of_year (
- g_date_time_new_from_unix_local (day))
- == g_date_time_get_day_of_year (
- g_date_time_new_from_unix_local (current_time));
- g_object_unref (today);
-
- if (has_today)
- {
- gchar* tooltip = g_markup_escape_text (katze_item_get_uri (item), -1);
- KatzeItem* copy = katze_item_copy (item);
- gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), NULL, &iter,
- 0, 0, copy, 1, tooltip, -1);
- g_object_unref (copy);
- g_free (tooltip);
- return;
- }
- }
-
- today = (KatzeItem*)katze_array_new (KATZE_TYPE_ITEM);
- katze_item_set_added (today, current_time);
- katze_item_set_meta_integer (today, "day",
- sokoke_time_t_to_julian (&current_time));
- gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &iter, NULL,
- 0, 0, today, -1);
- /* That's an invisible dummy, so we always have an expander */
- gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), NULL, &iter,
- 0, 0, NULL, -1);
-}
-
-static void
-midori_history_clear_cb (KatzeArray* array,
- MidoriHistory* history)
-{
- GtkTreeView* treeview = GTK_TREE_VIEW (history->treeview);
- GtkTreeModel* model = gtk_tree_view_get_model (treeview);
- gtk_tree_store_clear (GTK_TREE_STORE (model));
-}
-static void
-midori_history_set_app (MidoriHistory* history,
- MidoriApp* app)
-{
- GtkTreeModel* model;
-
- if (history->array)
- {
- g_signal_handlers_disconnect_by_func (history->array,
- midori_history_add_item_cb, history);
- g_signal_handlers_disconnect_by_func (history->array,
- midori_history_clear_cb, history);
- katze_object_assign (history->array, NULL);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (history->treeview));
- gtk_tree_store_clear (GTK_TREE_STORE (model));
- }
-
- katze_object_assign (history->app, app);
- if (!app)
- return;
- g_object_ref (app);
-
- history->array = katze_object_get_object (app, "history");
- g_signal_connect (history->array, "add-item",
- G_CALLBACK (midori_history_add_item_cb), history);
- g_signal_connect (history->array, "clear",
- G_CALLBACK (midori_history_clear_cb), history);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (history->treeview));
- if (history->array)
- midori_history_read_from_db_to_model (history, GTK_TREE_STORE (model), NULL, 0, NULL);
-}
-
-static void
-midori_history_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- MidoriHistory* history = MIDORI_HISTORY (object);
-
- switch (prop_id)
- {
- case PROP_APP:
- midori_history_set_app (history, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_history_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- MidoriHistory* history = MIDORI_HISTORY (object);
-
- switch (prop_id)
- {
- case PROP_APP:
- g_value_set_object (value, history->app);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-midori_history_treeview_render_icon_cb (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- KatzeItem* item;
- GdkPixbuf* pixbuf;
-
- gtk_tree_model_get (model, iter, 0, &item, -1);
-
- pixbuf = katze_item_get_pixbuf (item, treeview);
- g_object_set (renderer, "pixbuf", pixbuf, NULL);
-
- if (pixbuf)
- g_object_unref (pixbuf);
- g_object_unref (item);
-}
-
-static void
-midori_history_treeview_render_text_cb (GtkTreeViewColumn* column,
- GtkCellRenderer* renderer,
- GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkWidget* treeview)
-{
- KatzeItem* item;
-
- gtk_tree_model_get (model, iter, 0, &item, -1);
-
- if (KATZE_ITEM_IS_BOOKMARK (item))
- g_object_set (renderer, "markup", NULL,
- "ellipsize", PANGO_ELLIPSIZE_END,
- "text", katze_item_get_name (item), NULL);
- else if (KATZE_ITEM_IS_FOLDER (item))
- {
- gchar* formatted = midori_history_format_date (item);
- g_object_set (renderer, "markup", NULL, "text", formatted,
- "ellipsize", PANGO_ELLIPSIZE_END,
- NULL);
- g_free (formatted);
- }
- else
- g_object_set (renderer, "markup", _("<i>Separator</i>"), NULL);
-
- if (item)
- g_object_unref (item);
-}
-
-static void
-midori_history_row_activated_cb (GtkTreeView* treeview,
- GtkTreePath* path,
- GtkTreeViewColumn* column,
- MidoriHistory* history)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
- KatzeItem* item;
-
- model = gtk_tree_view_get_model (treeview);
-
- if (gtk_tree_model_get_iter (model, &iter, path))
- {
- gtk_tree_model_get (model, &iter, 0, &item, -1);
- if (KATZE_ITEM_IS_BOOKMARK (item))
- {
- MidoriBrowser* browser;
- const gchar* uri;
-
- uri = katze_item_get_uri (item);
- browser = midori_browser_get_for_widget (GTK_WIDGET (history));
- midori_browser_set_current_uri (browser, uri);
- g_object_unref (item);
- return;
- }
- if (gtk_tree_view_row_expanded (treeview, path))
- gtk_tree_view_collapse_row (treeview, path);
- else
- gtk_tree_view_expand_row (treeview, path, FALSE);
- g_object_unref (item);
- }
-}
-
-static void
-midori_history_popup_item (GtkWidget* menu,
- const gchar* stock_id,
- const gchar* label,
- KatzeItem* item,
- gpointer callback,
- MidoriHistory* history)
-{
- const gchar* uri;
- GtkWidget* menuitem;
-
- uri = katze_item_get_uri (item);
-
- menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
- if (label)
- gtk_label_set_text_with_mnemonic (GTK_LABEL (gtk_bin_get_child (
- GTK_BIN (menuitem))), label);
- if (!strcmp (stock_id, GTK_STOCK_EDIT))
- gtk_widget_set_sensitive (menuitem, uri != NULL);
- else if (katze_item_get_uri (item) && strcmp (stock_id, GTK_STOCK_DELETE))
- gtk_widget_set_sensitive (menuitem, uri != NULL);
- g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
- g_signal_connect (menuitem, "activate", G_CALLBACK (callback), history);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- gtk_widget_show (menuitem);
-}
-
-static void
-midori_history_open_activate_cb (GtkWidget* menuitem,
- MidoriHistory* history)
-{
- KatzeItem* item;
- const gchar* uri;
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
- uri = katze_item_get_uri (item);
-
- if (uri && *uri)
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (history));
- midori_browser_set_current_uri (browser, uri);
- }
-}
-
-static void
-midori_history_open_in_tab_activate_cb (GtkWidget* menuitem,
- MidoriHistory* history)
-{
- KatzeItem* item;
- const gchar* uri;
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
- if (KATZE_ITEM_IS_FOLDER (item))
- {
- sqlite3* db;
- gchar* sqlcmd;
- KatzeItem* child;
- KatzeArray* array;
-
- db = g_object_get_data (G_OBJECT (history->array), "db");
-
- if (!db)
- return;
-
- sqlcmd = g_strdup_printf ("SELECT uri, title, date, day "
- "FROM history WHERE day = %d "
- "GROUP BY uri ORDER BY date ASC",
- (int)katze_item_get_added (item));
- array = katze_array_from_sqlite (db, sqlcmd);
- g_free (sqlcmd);
- KATZE_ARRAY_FOREACH_ITEM (child, KATZE_ARRAY (array))
- {
- if ((uri = katze_item_get_uri (child)) && *uri)
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (history));
- GtkWidget* view = midori_browser_add_item (browser, child);
- midori_browser_set_current_tab_smartly (browser, view);
- }
- }
- }
- else
- {
- if ((uri = katze_item_get_uri (item)) && *uri)
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (history));
- GtkWidget* view = midori_browser_add_item (browser, item);
- midori_browser_set_current_tab_smartly (browser, view);
- }
- }
-}
-
-static void
-midori_history_open_in_window_activate_cb (GtkWidget* menuitem,
- MidoriHistory* history)
-{
- KatzeItem* item;
- const gchar* uri;
-
- item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
- uri = katze_item_get_uri (item);
-
- if (uri && *uri)
- {
- MidoriBrowser* new_browser = midori_app_create_browser (history->app);
- midori_app_add_browser (history->app, new_browser);
- gtk_widget_show (GTK_WIDGET (new_browser));
- midori_browser_add_uri (new_browser, uri);
- }
-}
-
-
-static void
-midori_history_popup (GtkWidget* widget,
- GdkEventButton* event,
- KatzeItem* item,
- MidoriHistory* history)
-{
- GtkWidget* menu;
- GtkWidget* menuitem;
-
- menu = gtk_menu_new ();
- if (!katze_item_get_uri (item))
- midori_history_popup_item (menu,
- STOCK_TAB_NEW, _("Open all in _Tabs"),
- item, midori_history_open_in_tab_activate_cb, history);
- else
- {
- midori_history_popup_item (menu, GTK_STOCK_OPEN, NULL,
- item, midori_history_open_activate_cb, history);
- midori_history_popup_item (menu, STOCK_TAB_NEW, _("Open in New _Tab"),
- item, midori_history_open_in_tab_activate_cb, history);
- midori_history_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"),
- item, midori_history_open_in_window_activate_cb, history);
- midori_history_popup_item (menu, STOCK_BOOKMARK_ADD, NULL,
- item, midori_history_bookmark_add_cb, history);
- }
- menuitem = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- gtk_widget_show (menuitem);
- midori_history_popup_item (menu, GTK_STOCK_DELETE, NULL,
- item, midori_history_delete_clicked_cb, history);
-
- katze_widget_popup (widget, GTK_MENU (menu), event, KATZE_MENU_POSITION_CURSOR);
-}
-
-static gboolean
-midori_history_button_release_event_cb (GtkWidget* widget,
- GdkEventButton* event,
- MidoriHistory* history)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- if (event->button != 2 && event->button != 3)
- return FALSE;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
- {
- KatzeItem* item;
-
- gtk_tree_model_get (model, &iter, 0, &item, -1);
-
- if (!item)
- return FALSE;
-
- if (event->button == 2)
- {
- const gchar* uri = katze_item_get_uri (item);
-
- if (uri && *uri)
- {
- MidoriBrowser* browser = midori_browser_get_for_widget (widget);
- GtkWidget* view = midori_browser_add_uri (browser, uri);
- midori_browser_set_current_tab (browser, view);
- }
- }
- else
- midori_history_popup (widget, event, item, history);
-
- g_object_unref (item);
- return TRUE;
- }
- return FALSE;
-}
-
-static gboolean
-midori_history_key_release_event_cb (GtkWidget* widget,
- GdkEventKey* event,
- MidoriHistory* history)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
-
- if (event->keyval != GDK_KEY_Delete)
- return FALSE;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
- {
- KatzeItem* item;
-
- gtk_tree_model_get (model, &iter, 0, &item, -1);
- midori_history_remove_item_from_db (history, item);
- gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
- g_object_unref (item);
- }
-
- return FALSE;
-}
-
-static void
-midori_history_popup_menu_cb (GtkWidget* widget,
- MidoriHistory* history)
-{
- GtkTreeModel* model;
- GtkTreeIter iter;
- KatzeItem* item;
-
- if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
- {
- gtk_tree_model_get (model, &iter, 0, &item, -1);
- midori_history_popup (widget, NULL, item, history);
- g_object_unref (item);
- }
-}
-
-static void
-midori_history_row_expanded_cb (GtkTreeView* treeview,
- GtkTreeIter* iter,
- GtkTreePath* path,
- MidoriHistory* history)
-{
- GtkTreeModel* model;
- KatzeItem* item;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
- gtk_tree_model_get (model, iter, 0, &item, -1);
- midori_history_read_from_db_to_model (history, GTK_TREE_STORE (model),
- iter, katze_item_get_meta_integer (item, "day"), NULL);
- g_object_unref (item);
-}
-
-static void
-midori_history_row_collapsed_cb (GtkTreeView *treeview,
- GtkTreeIter *parent,
- GtkTreePath *path,
- gpointer user_data)
-{
- GtkTreeModel* model;
- GtkTreeStore* treestore;
- GtkTreeIter child;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
- treestore = GTK_TREE_STORE (model);
- while (gtk_tree_model_iter_nth_child (model, &child, parent, 0))
- gtk_tree_store_remove (treestore, &child);
- /* That's an invisible dummy, so we always have an expander */
- gtk_tree_store_insert_with_values (treestore, &child, parent,
- 0, 0, NULL, -1);
-}
-
-static gboolean
-midori_history_filter_timeout_cb (gpointer data)
-{
- MidoriHistory* history = data;
- GtkTreeModel* model;
- GtkTreeStore* treestore;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (history->treeview));
- treestore = GTK_TREE_STORE (model);
-
- gtk_tree_store_clear (treestore);
- midori_history_read_from_db_to_model (history, treestore, NULL, 0, history->filter);
-
- return FALSE;
-}
-
-static void
-midori_history_filter_entry_changed_cb (GtkEntry* entry,
- MidoriHistory* history)
-{
- if (history->filter_timeout)
- g_source_remove (history->filter_timeout);
- history->filter_timeout = midori_timeout_add (COMPLETION_DELAY,
- midori_history_filter_timeout_cb, history, NULL);
-
- if (!g_object_get_data (G_OBJECT (entry), "sokoke_showing_default"))
- katze_assign (history->filter, g_strdup (gtk_entry_get_text (entry)));
- else
- katze_assign (history->filter, NULL);
-}
-
-static void
-midori_history_selection_changed_cb (GtkTreeView* treeview,
- MidoriHistory* history)
-{
- midori_history_toolbar_update (history);
-}
-
-static void
-midori_history_init (MidoriHistory* history)
-{
- GtkWidget* entry;
- GtkWidget* box;
- GtkTreeStore* model;
- GtkWidget* treeview;
- GtkTreeViewColumn* column;
- GtkCellRenderer* renderer_pixbuf;
- GtkCellRenderer* renderer_text;
- GtkTreeSelection* selection;
-
- /* Create the filter entry */
- entry = sokoke_search_entry_new (_("Search History"));
- g_signal_connect_after (entry, "changed",
- G_CALLBACK (midori_history_filter_entry_changed_cb), history);
- box = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 3);
- gtk_widget_show_all (box);
- gtk_box_pack_start (GTK_BOX (history), box, FALSE, FALSE, 5);
-
- /* Create the treeview */
- model = gtk_tree_store_new (2, KATZE_TYPE_ITEM, G_TYPE_STRING);
- treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
- gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (treeview), 1);
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_expand (column, TRUE);
- renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_pixbuf,
- (GtkTreeCellDataFunc)midori_history_treeview_render_icon_cb,
- treeview, NULL);
- renderer_text = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer_text, TRUE);
- gtk_tree_view_column_set_cell_data_func (column, renderer_text,
- (GtkTreeCellDataFunc)midori_history_treeview_render_text_cb,
- treeview, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
- g_object_unref (model);
- g_object_connect (treeview,
- "signal::row-activated",
- midori_history_row_activated_cb, history,
- "signal::button-release-event",
- midori_history_button_release_event_cb, history,
- "signal::key-release-event",
- midori_history_key_release_event_cb, history,
- "signal::row-expanded",
- midori_history_row_expanded_cb, history,
- "signal::row-collapsed",
- midori_history_row_collapsed_cb, history,
- "signal::popup-menu",
- midori_history_popup_menu_cb, history,
- NULL);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- g_signal_connect_after (selection, "changed",
- G_CALLBACK (midori_history_selection_changed_cb),
- history);
- gtk_widget_show (treeview);
- gtk_box_pack_start (GTK_BOX (history), treeview, TRUE, TRUE, 0);
- history->treeview = treeview;
- /* FIXME: We need to connect a signal here, to add new pages into history */
-
- history->filter = NULL;
-}
-
-static void
-midori_history_finalize (GObject* object)
-{
- MidoriHistory* history = MIDORI_HISTORY (object);
-
- if (history->app)
- g_object_unref (history->app);
-
- g_signal_handlers_disconnect_by_func (history->array,
- midori_history_add_item_cb, history);
- g_signal_handlers_disconnect_by_func (history->array,
- midori_history_clear_cb, history);
- g_object_unref (history->array);
- katze_assign (history->filter, NULL);
-}
-
diff --git a/panels/midori-history.h b/panels/midori-history.h
deleted file mode 100644
index a1c212cf..00000000
--- a/panels/midori-history.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Copyright (C) 2009 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 __MIDORI_HISTORY_PANEL_H__
-#define __MIDORI_HISTORY_PANEL_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_HISTORY \
- (midori_history_get_type ())
-#define MIDORI_HISTORY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_HISTORY, MidoriHistory))
-#define MIDORI_HISTORY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_HISTORY, MidoriHistoryClass))
-#define MIDORI_IS_HISTORY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_HISTORY))
-#define MIDORI_IS_HISTORY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_HISTORY))
-#define MIDORI_HISTORY_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_HISTORY, MidoriHistoryClass))
-
-typedef struct _MidoriHistory MidoriHistory;
-typedef struct _MidoriHistoryClass MidoriHistoryClass;
-
-GType
-midori_history_get_type (void);
-
-G_END_DECLS
-
-#endif /* __MIDORI_HISTORY_PANEL_H__ */
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
index 74202341..9626d966 100644
--- a/po/CMakeLists.txt
+++ b/po/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2013 Christian Dywan <christian@twotoasts.de>
+# Copyright (C) 2013-2018 Christian Dywan <christian@twotoasts.de>
include(FindGettext)
if (GETTEXT_FOUND)
@@ -10,7 +10,7 @@ if (GETTEXT_FOUND)
message(STATUS "gettext found: ${LANGUAGES}")
string(REPLACE " " ";" LANGUAGES ${LANGUAGES})
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_LESS "2.8.8")
- GETTEXT_CREATE_TRANSLATIONS("${CMAKE_CURRENT_SOURCE_DIR}/midori.pot" ALL ${POTFILES})
+ GETTEXT_CREATE_TRANSLATIONS("${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.pot" ALL ${POTFILES})
else()
foreach(LANG ${LANGUAGES})
GETTEXT_PROCESS_PO_FILES(${LANG} ALL PO_FILES ${LANG}.po)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 789c9fe3..27b71da3 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,110 +1,32 @@
# List of source files containing translatable strings.
data/midori.desktop.in
-data/midori-private.desktop.in
-midori/main.c
-midori/midori-app.c
-midori/midori-array.c
-midori/midori-bookmarksdatabase.vala
-midori/midori-browser.c
-midori/midori-window.vala
-midori/midori-database.vala
-midori/midori-extension.c
-midori/midori-locationaction.c
-midori/midori-panel.c
-midori/midori-settings.vala
-midori/midori-websettings.c
-midori/midori-tab.vala
-midori/midori-notebook.vala
-midori/midori-view.c
-midori/midori-download.vala
-midori/midori-speeddial.vala
-midori/midori-preferences.c
-midori/midori-searchaction.c
-midori/midori-historycompletion.vala
-midori/midori-historydatabase.vala
-midori/midori-searchcompletion.vala
-midori/sokoke.c
-toolbars/midori-findbar.c
-panels/midori-bookmarks.c
-panels/midori-extensions.c
-panels/midori-history.c
-katze/katze-http-auth.c
-katze/katze-utils.c
-katze/katze-item.c
-katze/katze-array.c
-katze/katze-arrayaction.c
-katze/katze-preferences.c
-katze/midori-uri.vala
-katze/midori-paths.vala
-extensions/addons.c
-extensions/colorful-tabs.c
-extensions/cookie-manager/cookie-manager.c
-extensions/cookie-manager/cookie-manager-page.c
-extensions/cookie-manager/main.c
-extensions/copy-tabs.c
-extensions/delayed-load.vala
-extensions/about.vala
-extensions/devpet.vala
-extensions/external-download-manager.vala
-extensions/open-with.vala
-extensions/feed-panel/feed-atom.c
-extensions/feed-panel/feed-panel.c
-extensions/feed-panel/feed-parse.c
-extensions/feed-panel/feed-rss.c
-extensions/feed-panel/katze-net.c
-extensions/feed-panel/main.c
-extensions/formhistory/formhistory.c
-extensions/formhistory/formhistory-gdom-frontend.c
-extensions/history-list.vala
-extensions/nojs/nojs-preferences.c
-extensions/nojs/nojs-view.c
-extensions/nojs/nojs.c
-extensions/mouse-gestures.c
-extensions/shortcuts.c
-extensions/status-clock.c
-extensions/statusbar-features.c
-extensions/tab-panel.c
-extensions/tabs-minimized.c
-extensions/tabs2one.c
-extensions/toolbar-editor.c
-katze/katze-cellrenderercomboboxtext.c
-katze/midori-hsts.vala
-katze/katze-separatoraction.vala
-katze/gtk3-compat.c
-midori/midori-panedaction.vala
-midori/midori-privatedata.c
-midori/midori-dialog.vala
-midori/midori-completion.vala
-midori/midori-contextaction.vala
-midori/midori-viewable.vala
-midori/midori-extensions-column.vala
-midori/midori-viewcompletion.vala
-midori/midori-history.c
-midori/midori-bookmarks-db.c
-midori/midori-session.c
-extensions/nsplugin-manager.vala
-midori/midori-frontend.c
-extensions/cookie-permissions/cookie-permission-manager-preferences-window.c
-extensions/cookie-permissions/cookie-permission-manager-preferences-window.h
-extensions/cookie-permissions/cookie-permission-manager.c
-extensions/cookie-permissions/cookie-permission-manager.h
-extensions/cookie-permissions/main.c
-extensions/apps.vala
-extensions/transfers.vala
-extensions/tabby.vala
-extensions/flummi.vala
-extensions/notes.vala
-extensions/adblock/extension.vala
-extensions/adblock/filter.vala
-extensions/adblock/keys.vala
-extensions/adblock/pattern.vala
-extensions/adblock/options.vala
-extensions/adblock/whitelist.vala
-extensions/adblock/subscriptions.vala
-extensions/adblock/config.vala
-extensions/adblock/updater.vala
-extensions/adblock/element.vala
-extensions/adblock/widgets.vala
-extensions/domain-keys.vala
-extensions/webmedia-now-playing.vala
+core/about.vala
+core/app.vala
+core/browser.vala
+core/completion.vala
+core/clear-private-data.vala
+core/database.vala
+core/download-button.vala
+core/favicon.vala
+core/history.vala
+core/loggable.vala
+core/main.vala
+core/network-check.vala
+core/shortcuts.val
+core/statusbar.vala
+core/suggestion-row.vala
+core/switcher.vala
+core/tab.vala
+core/tally.vala
+core/urlbar.vala
+ui/browser.ui
+ui/clear-private-data.ui
+ui/download-button.ui
+ui/download-row.ui
+ui/menus.ui
+ui/network-check.ui
+ui/shortcuts.ui
+ui/suggestion-row.ui
+ui/tally.ui
+ui/urlbar.ui
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index 9acccb96..e097b463 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -1,9 +1,9 @@
name: midori
-version: bzr
+version: git
version-script: |
set -x
- VERSION=$(grep -r "^set(VERSION" CMakeLists.txt | sed -r "s@.+ ([0-9.]+)\)@\1@")
- REVISION=$(bzr revno)
+ VERSION=$(grep -r "^set(CORE_VERSION" CMakeLists.txt | sed -r "s@.+ ([0-9.]+)\)@\1@")
+ REVISION=$(git describe --tags)
echo $VERSION~r$REVISION
summary: a lightweight, fast, and free web browser
description: |
@@ -48,13 +48,12 @@ apps:
LD_LIBRARY_PATH: $SNAP/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/:$LD_LIBRARY_PATH
# Work-around GPU crash https://bugs.webkit.org/show_bug.cgi?id=126122
WEBKIT_DISABLE_COMPOSITING_MODE: 1
- GTK_CSD: 1
# No Netscape plugins
MOZ_PLUGIN_PATH: /
slots:
dbus:
- name: de.twotoasts.midori
+ name: org.midori-browser.midori
bus: session
parts:
@@ -62,25 +61,22 @@ parts:
plugin: cmake
configflags:
- -DCMAKE_INSTALL_DATADIR=/usr/share
- - -DHALF_BRO_INCOM_WEBKIT2=1
- - -DUSE_ZEITGEIST=0
build-packages:
- - bzr
+ - git
- valac
- libwebkit2gtk-4.0-dev
- libsoup-gnome2.4-dev
- libgcr-3-dev
- libsqlite3-dev
- - librsvg2-bin
- intltool
- install: |
- echo "[settings]\n" \
- "toolbar-items=" \
- "TabNew,Back,NextForward,ReloadStop,BookmarkAdd,Location,Trash,CompactMenu\n" \
- "show-statusbar=false\n" \
- > $SNAPCRAFT_PART_INSTALL/etc/xdg/midori/config
+ - ninja-build
stage-packages:
- libwebkit2gtk-4.0-37
+ - libgcr-base-3-1
+ - libgcr-ui-3-1
+ - libgck-1-0
+ - libgpm2
+ - libdb5.3
- libcanberra-gtk3-module
- myspell-en-us
- gnome-icon-theme-symbolic
@@ -93,9 +89,10 @@ parts:
- pulseaudio-module-x11
- libmirclient9
stage:
- - -share/applications/midori-private.desktop
- - -usr/lib/x86_64-linux-gnu/libcups.so.2
+ - -usr/lib/*/libcups.so.2
- -usr/share/doc/libcups2/changelog.Debian.gz
+ - -usr/lib/*/libsoup-2.4.so.1.7.0
+ - -usr/lib/*/libsoup-gnome-2.4.so.1.7.0
- -usr/share/doc
after:
- desktop-gtk3
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index f507ccfd..78a4f226 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,16 +1,15 @@
-# Copyright (C) 2013 Christian Dywan <christian@twotoasts.de>
+# Copyright (C) 2013-2018 Christian Dywan <christian@twotoasts.de>
include(ContainTest)
add_custom_target(check COMMAND "env" "CTEST_OUTPUT_ON_FAILURE=1" "${CMAKE_CTEST_COMMAND}")
include_directories(
"${CMAKE_SOURCE_DIR}"
- "${CMAKE_SOURCE_DIR}/midori"
+ "${CMAKE_SOURCE_DIR}/core"
${DEPS_INCLUDE_DIRS}
- ${OPTS_INCLUDE_DIRS}
${DEPS_GTK_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}
- "${CMAKE_BINARY_DIR}/midori"
+ "${CMAKE_BINARY_DIR}/core"
)
file(GLOB TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.c *.vala)
foreach(UNIT_SRC ${TESTS})
@@ -25,8 +24,7 @@ foreach(UNIT_SRC ${TESTS})
${VALAFLAGS}
CUSTOM_VAPIS
${EXTRA_VAPIS}
- "${CMAKE_SOURCE_DIR}/midori/midori.vapi"
- "${CMAKE_BINARY_DIR}/midori/${LIBMIDORI}.vapi"
+ "${CMAKE_BINARY_DIR}/core/${LIBCORE}.vapi"
)
add_executable(${UNIT} ${UNIT_SRC_C})
@@ -42,23 +40,12 @@ foreach(UNIT_SRC ${TESTS})
endif()
target_link_libraries(${UNIT}
- ${LIBMIDORI}
+ ${LIBCORE}
)
add_test(NAME ${UNIT} COMMAND ${UNIT})
contain_test (${UNIT} ${UNIT})
endforeach ()
-file(GLOB TESTS ${CMAKE_BINARY_DIR}/extensions/lib*.so)
-foreach(UNIT ${TESTS})
- string(REPLACE ${CMAKE_BINARY_DIR} "" TEST ${UNIT})
- string(REPLACE "/" "-" TEST ${TEST})
- string(REPLACE "-extensions-lib" "" TEST ${TEST})
- string(REPLACE ".so" "" TEST ${TEST})
- add_test(NAME ${TEST} COMMAND $<TARGET_FILE:extensions> -e ${UNIT})
- set(exe $<TARGET_FILE:extensions> -e ${UNIT})
- contain_test (${TEST} "${exe}")
-endforeach()
-
file(GLOB TESTS *.sh)
foreach(UNIT_SRC ${TESTS})
string(REPLACE ".sh" "" UNIT ${UNIT_SRC})
diff --git a/tests/actions.vala b/tests/actions.vala
deleted file mode 100644
index 90ae8f62..00000000
--- a/tests/actions.vala
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- Copyright (C) 2013 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.
-*/
-
-void actions_view_page () {
- var browser = new Midori.Browser ();
- var view = new Midori.View.with_title (null, new Midori.WebSettings ());
- browser.add_tab (view);
- browser.show ();
- view.set_html ("<body>The earth is <em>flat</em> for a fact.</body>");
- var loop = MainContext.default ();
- do { loop.iteration (true); } while (view.load_status != Midori.LoadStatus.FINISHED);
-
- var hit_test_result = Object.new (typeof (WebKit.HitTestResult), "context", WebKit.HitTestResultContext.DOCUMENT) as WebKit.HitTestResult;
- var menu = view.get_page_context_action (hit_test_result);
- assert (menu != null);
- assert (menu.name == "PageContextMenu");
- assert (menu.get_by_name ("Back") != null);
-
-#if !HAVE_WEBKIT2
- var hit_test_result2 = Object.new (typeof (WebKit.HitTestResult), "context", WebKit.HitTestResultContext.EDITABLE) as WebKit.HitTestResult;
- var menu2 = view.get_page_context_action (hit_test_result2);
- assert (menu2 != null);
- assert (menu2.name == "PageContextMenu");
- var copy = menu2.get_by_name ("Copy");
- assert (copy != null);
- assert (!copy.sensitive);
- assert (view.web_view.search_text ("flat", true, false, false));
- menu = view.get_page_context_action (hit_test_result);
- copy = menu.get_by_name ("Copy");
- assert (copy.sensitive);
-#endif
-
- /* Reload contents to clear selection */
- view.set_html ("<body>The earth is <em>flat</em> for a fact.</body>");
- do { loop.iteration (true); } while (view.load_status != Midori.LoadStatus.FINISHED);
-
-#if !HAVE_WEBKIT2
- hit_test_result = Object.new (typeof (WebKit.HitTestResult), "context", WebKit.HitTestResultContext.SELECTION) as WebKit.HitTestResult;
- menu = view.get_page_context_action (hit_test_result);
- copy = menu.get_by_name ("Copy");
- assert (!copy.sensitive);
- assert (view.web_view.search_text ("flat", true, false, false));
- menu = view.get_page_context_action (hit_test_result);
- copy = menu.get_by_name ("Copy");
- assert (copy.sensitive);
-#endif
-}
-
-void main (string[] args) {
- Test.init (ref args);
- Midori.App.setup (ref args, null);
- Midori.Paths.init (Midori.RuntimeMode.NORMAL, null);
-#if !HAVE_WEBKIT2
- WebKit.get_default_session ().set_data<bool> ("midori-session-initialized", true);
-#endif
- Test.add_func ("/actions/view/page", actions_view_page);
- Test.run ();
-}
-
diff --git a/tests/app.vala b/tests/app.vala
deleted file mode 100644
index b024f468..00000000
--- a/tests/app.vala
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- Copyright (C) 2012 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.
-*/
-
-bool check_sensible_window_size (Gtk.Window window, Midori.WebSettings settings) {
- Gdk.Rectangle monitor;
- window.screen.get_monitor_geometry (0, out monitor);
- return settings.last_window_width + 1 >= monitor.width / 1.7
- && settings.last_window_height + 1 >= monitor.height / 1.7;
-}
-
-void app_normal () {
- Midori.Test.grab_max_timeout ();
- Midori.Test.idle_timeouts ();
- Midori.Test.log_set_fatal_handler_for_icons ();
- Midori.Paths.Test.reset_runtime_mode ();
- Midori.App.set_instance_is_running (false);
- var app = Midori.normal_app_new (null, "test-normal", false, null, null, -1, null);
- var loop = MainContext.default ();
- do { loop.iteration (true); } while (app.browser == null);
- for (var i = 0 ; i < 3; i++) {
- var tab = app.browser.add_uri ("about:blank") as Midori.View;
- app.browser.close_tab (tab);
- do { loop.iteration (true); } while (loop.pending ());
- }
- Midori.normal_app_on_quit (app);
- Midori.Test.release_max_timeout ();
-}
-
-void app_normal_custom_config () {
- Midori.Test.grab_max_timeout ();
- Midori.Test.idle_timeouts ();
- Midori.Test.log_set_fatal_handler_for_icons ();
- Midori.Paths.Test.reset_runtime_mode ();
- Midori.App.set_instance_is_running (false);
- string? config_dir = null;
- try {
- config_dir = DirUtils.make_tmp ("custom-configXXXXXX");
- } catch (Error error) {
- GLib.error (error.message);
- }
- var app = Midori.normal_app_new (config_dir,
- "test-custom-config-normal", false, null, null, -1, null);
- Midori.normal_app_on_quit (app);
- Midori.Test.release_max_timeout ();
-}
-
-void app_private () {
- Midori.Test.log_set_fatal_handler_for_icons ();
- Midori.Paths.Test.reset_runtime_mode ();
- Midori.App.set_instance_is_running (false);
- var browser = Midori.private_app_new (null, null, null, null, -1, null);
- var loop = MainContext.default ();
- do { loop.iteration (true); } while (loop.pending ());
- assert (check_sensible_window_size (browser, browser.settings));
-}
-
-void app_web () {
- Midori.Paths.Test.reset_runtime_mode ();
- Midori.App.set_instance_is_running (false);
- var browser = Midori.web_app_new ("https://mail.google.com", null, null, -1, null);
- var loop = MainContext.default ();
- do { loop.iteration (true); } while (loop.pending ());
- assert (check_sensible_window_size (browser, browser.settings));
-}
-
-void app_web_custom_config () {
- Midori.Paths.Test.reset_runtime_mode ();
- Midori.App.set_instance_is_running (false);
- var browser = Midori.web_app_new ("https://mail.google.com", null, null, -1, null);
- var loop = MainContext.default ();
- do { loop.iteration (true); } while (loop.pending ());
- assert (check_sensible_window_size (browser, browser.settings));
-}
-
-void main (string[] args) {
- Test.init (ref args);
- Midori.App.setup (ref args, null);
- Test.add_func ("/app/normal", app_normal);
- Test.add_func ("/app/normal-custom-config", app_normal_custom_config);
- Test.add_func ("/app/private", app_private);
- Test.add_func ("/app/web", app_web);
- Test.add_func ("/app/web-custom-config", app_web_custom_config);
- Test.run ();
-}
-
diff --git a/tests/bookmarks.c b/tests/bookmarks.c
deleted file mode 100644
index ad3ccc27..00000000
--- a/tests/bookmarks.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- Copyright (C) 2012 Vincent Cappe <vcappe@gmail.com>
-
- 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.
- */
-
-#include "midori.h"
-#include "midori-bookmarks-db.h"
-
-typedef struct
-{
- MidoriBookmarksDb* db_bookmarks;
- KatzeArray* test_bookmarks;
-} BookmarksFixture;
-
-typedef struct
-{
- gboolean verbose; /* print debug stuff if TRUE */
- char* infile; /* (e.g. to test import), usually NULL */
- char* outfile; /* (e.g. to test export), if it can be avoided it's
- better to not write anything to disk, though */
-} TestParameters;
-
-typedef void (*FixtureFunc)(BookmarksFixture*, const void*);
-
-
-static void
-fixture_setup (BookmarksFixture* fixture,
- const TestParameters* params)
-{
- KatzeItem* item;
- KatzeArray* folder;
- gchar *errmsg = NULL;
-
- if (!(fixture->db_bookmarks = midori_bookmarks_db_new (&errmsg)))
- g_error ("Bookmarks couldn't be loaded: %s\n", errmsg);
- g_assert (errmsg == NULL);
- g_assert (g_object_get_data (G_OBJECT (fixture->db_bookmarks), "db"));
-
- fixture->test_bookmarks = katze_array_new (KATZE_TYPE_ARRAY);
-
- item = (KatzeItem*)katze_array_new (KATZE_TYPE_ARRAY);
- item->name = "i am a folder";
- katze_array_add_item (fixture->test_bookmarks, item);
- folder = (KatzeArray *) item;
-
- item = (KatzeItem*)katze_array_new (KATZE_TYPE_ARRAY);
- item->name = "i am a folder inside a folder";
- katze_array_add_item (folder, item);
- folder = (KatzeArray *) item;
-
- item = g_object_new (KATZE_TYPE_ITEM,
- "uri", "http://xyzzy.invalid",
- "name", "xyzzy", NULL);
- katze_item_set_meta_integer (item, "app", TRUE);
- katze_array_add_item (folder, item);
-
- /* level up */
- folder = katze_item_get_parent ((KatzeItem*)folder);
-
- item = g_object_new (KATZE_TYPE_ITEM,
- "uri", "http://zyxxy.invalid",
- "name", "zyxxy",
- "text", "i have a description and am in a folder", NULL);
- katze_item_set_meta_integer(item, "toolbar", TRUE);
- katze_array_add_item (folder, item);
-
- folder = katze_item_get_parent ((KatzeItem*)folder);
- /* we should be at toplevel, now */
- g_assert (folder == fixture->test_bookmarks);
-
- item = g_object_new (KATZE_TYPE_ITEM,
- "uri", "http://foobarbaz.invalid",
- "name", "i am in the toplevel folder", NULL);
- katze_array_add_item (folder, item);
-}
-
-static void
-fixture_teardown (BookmarksFixture* fixture,
- const TestParameters *params)
-{
- midori_bookmarks_db_on_quit (fixture->db_bookmarks);
- /* g_object_unref (fixture->db_bookmarks); */
- g_object_unref (fixture->test_bookmarks);
-}
-
-static void
-print_bookmark (KatzeItem *bookmark)
-{
- g_print ("title : '%s'\n", katze_item_get_name (bookmark));
- g_print ("uri : '%s'\n", katze_item_get_uri (bookmark));
- g_print ("desc : '%s'\n", katze_item_get_text (bookmark));
- g_print ("app : %d\n", katze_item_get_meta_boolean (bookmark, "app"));
- g_print ("toolbar: %d\n", katze_item_get_meta_boolean (bookmark, "toolbar"));
-}
-
-static void
-compare_items (KatzeItem *a, KatzeItem *b)
-{
- g_assert_cmpstr ( katze_item_get_uri (a), ==, katze_item_get_uri (b));
- g_assert_cmpstr ( katze_item_get_name (a), ==, katze_item_get_name (b));
- g_assert_cmpstr ( katze_str_non_null (katze_item_get_text (a)), ==, katze_str_non_null (katze_item_get_text (b)));
- g_assert_cmpint ( katze_item_get_meta_boolean (a, "app"), ==, katze_item_get_meta_boolean (b, "app"));
- g_assert_cmpint ( katze_item_get_meta_boolean (a, "toolbar"), ==, katze_item_get_meta_boolean (b, "toolbar"));
-}
-
-/* NB: assumes "title" is unique in a set */
-static void
-compare_test_and_db (KatzeArray* test_bookmarks,
- MidoriBookmarksDb* db_bookmarks,
- gboolean verbose)
-{
- KatzeArray* db_items;
- KatzeItem *test_item, *db_item;
- GList* list;
-
- KATZE_ARRAY_FOREACH_ITEM_L (test_item, test_bookmarks, list)
- {
- if (verbose)
- {
- print_bookmark (test_item);
- g_print ("----------\n");
- }
-
- db_items = midori_bookmarks_db_query_recursive (db_bookmarks,
- "*", "title='%q'", katze_item_get_name (test_item), FALSE);
-
- /* FIXME g_assert_cmpint (katze_array_get_length (db_items), ==, 1); */
- db_item = katze_array_get_nth_item (db_items, 0);
-
- compare_items (db_item, test_item);
-
- if (KATZE_ITEM_IS_FOLDER(test_item))
- compare_test_and_db ( KATZE_ARRAY (test_item), db_bookmarks, verbose);
- }
- g_list_free (list);
-}
-
-static void
-print_bookmarks (KatzeArray* test_bookmarks)
-{
- KatzeItem* item;
- GList* list;
- KATZE_ARRAY_FOREACH_ITEM_L (item, test_bookmarks, list)
- {
- print_bookmark (item);
- g_print ("----------\n");
-
- if (KATZE_ITEM_IS_FOLDER(item))
- print_bookmarks (KATZE_ARRAY (item));
- }
- g_list_free (list);
-}
-
-static void
-insert_bookmarks (KatzeArray* test_bookmarks,
- MidoriBookmarksDb* db_bookmarks,
- gboolean verbose)
-{
-
- if (verbose)
- {
- print_bookmarks (test_bookmarks);
- }
-
- midori_bookmarks_db_import_array (db_bookmarks, test_bookmarks, 0);
-}
-
-static void
-simple_test (BookmarksFixture* fixture,
- const TestParameters* params)
-{
- if (params->verbose)
- g_print ("\n===== inserting items in the database =====\n");
- insert_bookmarks (fixture->test_bookmarks, fixture->db_bookmarks, params->verbose);
-
- if (params->verbose)
- g_print ("===== comparing database with the original =====\n");
- compare_test_and_db (fixture->test_bookmarks, fixture->db_bookmarks, params->verbose);
-}
-
-
-int
-main (int argc,
- char** argv)
-{
- /* TestParameters default_params = { TRUE, NULL, NULL }; */
- TestParameters default_params = { FALSE, NULL, NULL };
-
- g_test_init (&argc, &argv, NULL);
- midori_app_setup (&argc, &argv, NULL);
- midori_paths_init (MIDORI_RUNTIME_MODE_NORMAL, NULL);
-
- g_test_add ("/bookmarks/simple test",
- BookmarksFixture, &default_params,
- (FixtureFunc) fixture_setup,
- (FixtureFunc) simple_test,
- (FixtureFunc) fixture_teardown);
-
- return g_test_run ();
-}
diff --git a/tests/browser.c b/tests/browser.c
deleted file mode 100644
index 9497bb84..00000000
--- a/tests/browser.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- Copyright (C) 2009 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.
-*/
-
-#include "midori.h"
-
-#ifndef HAVE_WEBKIT2
-static void
-browser_create (void)
-{
- MidoriApp* app;
- MidoriWebSettings* settings;
- MidoriBrowser* browser;
- gchar* temporary_downloads;
- gchar* temporary_filename;
- GtkWidget* view;
- GFile* file;
- gchar* uri;
- gchar* filename;
- gchar* filename2;
-
- midori_test_log_set_fatal_handler_for_icons ();
-
- app = midori_app_new (NULL);
- settings = midori_web_settings_new ();
- g_object_set (app, "settings", settings, NULL);
- browser = midori_app_create_browser (app);
- file = g_file_new_for_commandline_arg ("./data/about.css");
- uri = g_file_get_uri (file);
- g_object_unref (file);
- view = midori_browser_add_uri (browser, uri);
-
- midori_test_set_dialog_response (GTK_RESPONSE_OK);
- temporary_downloads = midori_paths_make_tmp_dir ("saveXXXXXX");
- temporary_filename = g_build_filename (temporary_downloads, "test.html", NULL);
- midori_test_set_file_chooser_filename (temporary_filename);
- midori_settings_set_download_folder (MIDORI_SETTINGS (settings), temporary_downloads);
- midori_browser_save_uri (browser, MIDORI_VIEW (view), NULL);
-
- filename = midori_view_save_source (MIDORI_VIEW (view), NULL, NULL, FALSE);
- filename2 = g_filename_from_uri (uri, NULL, NULL);
- g_assert_cmpstr (filename, ==, filename2);
- g_free (filename);
- g_free (filename2);
-
- /* View source for local file: should NOT use temporary file */
- view = midori_browser_add_uri (browser, uri);
- midori_browser_set_current_tab (browser, view);
- g_assert_cmpstr (uri, ==, midori_browser_get_current_uri (browser));
- g_free (uri);
- g_free (temporary_downloads);
- g_free (temporary_filename);
-
- gtk_widget_destroy (GTK_WIDGET (browser));
- g_object_unref (settings);
- g_object_unref (app);
-}
-#endif
-
-static void
-browser_tooltips (void)
-{
- MidoriBrowser* browser;
- GtkActionGroup* action_group;
- GList* actions;
- gchar* toolbar;
- guint errors = 0;
-
- browser = midori_browser_new ();
- action_group = midori_browser_get_action_group (browser);
- actions = gtk_action_group_list_actions (action_group);
- toolbar = g_strjoinv (" ", (gchar**)midori_browser_get_toolbar_actions (browser));
-
- while (actions)
- {
- GtkAction* action = actions->data;
- const gchar* name = gtk_action_get_name (action);
-
- if (strstr ("CompactMenu Location Separator", name))
- {
- actions = g_list_next (actions);
- continue;
- }
-
- if (strstr (toolbar, name) != NULL)
- {
- if (!gtk_action_get_tooltip (action))
- {
- printf ("'%s' can be toolbar item but tooltip is unset\n", name);
- errors++;
- }
- }
- else
- {
- if (gtk_action_get_tooltip (action))
- {
- printf ("'%s' is no toolbar item but tooltip is set\n", name);
- errors++;
- }
- }
- actions = g_list_next (actions);
- }
- g_free (toolbar);
- g_list_free (actions);
- gtk_widget_destroy (GTK_WIDGET (browser));
-
- if (errors)
- g_error ("Tooltip errors");
-}
-
-static void
-browser_site_data (void)
-{
- typedef struct
- {
- const gchar* url;
- MidoriSiteDataPolicy policy;
- } PolicyItem;
-
- static const PolicyItem items[] = {
- { "google.com", MIDORI_SITE_DATA_BLOCK },
- { "facebook.com", MIDORI_SITE_DATA_BLOCK },
- { "bugzilla.gnome.org", MIDORI_SITE_DATA_PRESERVE },
- { "bugs.launchpad.net", MIDORI_SITE_DATA_ACCEPT },
- };
-
- const gchar* rules = "-google.com,-facebook.com,!bugzilla.gnome.org,+bugs.launchpad.net";
- MidoriWebSettings* settings = g_object_new (MIDORI_TYPE_WEB_SETTINGS,
- "site-data-rules", rules, NULL);
-
- guint i;
- for (i = 0; i < G_N_ELEMENTS (items); i++)
- {
- MidoriSiteDataPolicy policy = midori_web_settings_get_site_data_policy (
- settings, items[i].url);
- if (policy != items[i].policy)
- g_error ("Match '%s' yields %d but %d expected",
- items[i].url, policy, items[i].policy);
- }
- g_object_unref (settings);
-}
-
-static void
-browser_block_uris (void)
-{
- MidoriWebSettings* settings = g_object_new (MIDORI_TYPE_WEB_SETTINGS, NULL);
- gchar* pattern = katze_object_get_string (settings, "block-uris");
- g_object_set (settings, "block-uris", NULL, NULL);
- g_object_set (settings, "block-uris", "", NULL);
- g_object_set (settings, "block-uris", "^(?!.*?(gmail|mail\\.google|accounts\\.google)).*", NULL);
- g_free (pattern);
- g_object_unref (settings);
-}
-
-static void
-browser_appmenu_visibility (void)
-{
- MidoriApp* app = midori_app_new (NULL);
- MidoriBrowser* browser = midori_app_create_browser (app);
- GtkToolItem* appmenu = midori_window_get_tool_item (MIDORI_WINDOW (browser), "CompactMenu");
- gboolean menubar_visible;
- gboolean appmenu_visible;
-
- midori_test_log_set_fatal_handler_for_icons ();
-
- g_object_get (appmenu, "visible", &appmenu_visible, NULL);
- g_object_get (browser, "show-menubar", &menubar_visible, NULL);
- g_assert (menubar_visible == !appmenu_visible);
-
- g_object_set (browser, "show-menubar", !menubar_visible, NULL);
-
- g_object_get (appmenu, "visible", &appmenu_visible, NULL);
- g_object_get (browser, "show-menubar", &menubar_visible, NULL);
- g_assert (menubar_visible == !appmenu_visible);
-
- g_object_set (browser, "show-menubar", TRUE, NULL);
-
- g_object_get (appmenu, "visible", &appmenu_visible, NULL);
- g_object_get (browser, "show-menubar", &menubar_visible, NULL);
- g_assert (menubar_visible && !appmenu_visible);
-
- g_object_set (browser, "show-menubar", FALSE, NULL);
-
- g_object_get (appmenu, "visible", &appmenu_visible, NULL);
- g_object_get (browser, "show-menubar", &menubar_visible, NULL);
- g_assert (!menubar_visible && appmenu_visible);
-
- gtk_widget_destroy (GTK_WIDGET (browser));
- g_object_unref (app);
-}
-
-int
-main (int argc,
- char** argv)
-{
- g_test_init (&argc, &argv, NULL);
- midori_app_setup (&argc, &argv, NULL);
- midori_paths_init (MIDORI_RUNTIME_MODE_NORMAL, NULL);
-
- #ifndef HAVE_WEBKIT2
- g_object_set_data (G_OBJECT (webkit_get_default_session ()),
- "midori-session-initialized", (void*)1);
- g_test_add_func ("/browser/create", browser_create);
- #endif
-
- g_test_add_func ("/browser/tooltips", browser_tooltips);
- g_test_add_func ("/browser/site_data", browser_site_data);
- g_test_add_func ("/browser/block_uris", browser_block_uris);
- g_test_add_func ("/browser/appmenu_visibility", browser_appmenu_visibility);
-
- return g_test_run ();
-}
diff --git a/tests/completion.vala b/tests/completion.vala
deleted file mode 100644
index 88abcf69..00000000
--- a/tests/completion.vala
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- Copyright (C) 2012 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.
-*/
-
-class TestCompletion : Midori.Completion {
- public bool test_can_complete { get; set; }
- public uint test_suggestions { get; set; }
-
- public TestCompletion () {
- }
-
- public override void prepare (GLib.Object app) {
- }
-
- public override bool can_complete (string text) {
- return test_can_complete;
- }
-
- public override bool can_action (string action) {
- return false;
- }
-
- public override async List<Midori.Suggestion>? complete (string text, string? action, Cancellable cancellable) {
- var suggestions = new List<Midori.Suggestion> ();
- if (test_suggestions == 0)
- return null;
- if (test_suggestions >= 1)
- suggestions.append (new Midori.Suggestion ("about:first", "First"));
- if (test_suggestions >= 2)
- suggestions.append (new Midori.Suggestion ("about:second", "Second"));
- if (test_suggestions >= 3)
- suggestions.append (new Midori.Suggestion ("about:third", "Third"));
- if (cancellable.is_cancelled ())
- return null;
- return suggestions;
- }
-}
-
-class CompletionAutocompleter : Midori.Test.Job {
- public static void test () { new CompletionAutocompleter ().run_sync (); }
- public override async void run (Cancellable cancellable) throws GLib.Error {
- var app = new Midori.App ();
- var autocompleter = new Midori.Autocompleter (app);
- assert (!autocompleter.can_complete (""));
- var completion = new TestCompletion ();
- autocompleter.add (completion);
- completion.test_can_complete = false;
- assert (!autocompleter.can_complete (""));
- completion.test_can_complete = true;
- assert (autocompleter.can_complete (""));
-
- completion.test_suggestions = 0;
- yield autocompleter.complete ("");
- assert (autocompleter.model.iter_n_children (null) == 0);
-
- completion.test_suggestions = 1;
- yield autocompleter.complete ("");
- assert (autocompleter.model.iter_n_children (null) == 1);
-
- /* Order */
- completion.test_suggestions = 2;
- yield autocompleter.complete ("");
- assert (autocompleter.model.iter_n_children (null) == 2);
- Gtk.TreeIter iter_first;
- autocompleter.model.get_iter_first (out iter_first);
- string title;
- autocompleter.model.get (iter_first, Midori.Autocompleter.Columns.MARKUP, out title);
- if (title != "First")
- error ("Expected %s but got %s", "First", title);
-
- /* Cancellation */
- yield autocompleter.complete ("");
- completion.test_suggestions = 3;
- yield autocompleter.complete ("");
- int n = autocompleter.model.iter_n_children (null);
- if (n != 3)
- error ("Expected %d but got %d", 3, n);
- }
-}
-
-class CompletionHistory : Midori.Test.Job {
- public static void test () { new CompletionHistory ().run_sync (); }
- public override async void run (Cancellable cancellable) throws GLib.Error {
- var bookmarks_database = new Midori.BookmarksDatabase ();
- assert (bookmarks_database.db != null);
-
- Midori.HistoryDatabase history = new Midori.HistoryDatabase (null);
- assert (history.db != null);
- history.clear (0);
-
- history.insert ("http://example.com", "Ejemplo", 0, 0);
- var results = yield history.list_by_count_with_bookmarks ("example", 1, cancellable);
- assert (results.length () == 1);
- var first = results.nth_data (0);
- assert (first.title == "Ejemplo");
- results = yield history.list_by_count_with_bookmarks ("ejemplo", 1, cancellable);
- assert (results.length () == 1);
- first = results.nth_data (0);
- assert (first.title == "Ejemplo");
- }
-}
-
-struct TestCaseRender {
- public string keys;
- public string uri;
- public string title;
- public string expected_uri;
- public string expected_title;
-}
-
-const TestCaseRender[] renders = {
- { "debian", "planet.debian.org", "Planet Debian", "planet.<b>debian</b>.org", "Planet <b>Debian</b>" },
- { "p debian o", "planet.debian.org", "Planet Debian", "<b>p</b>lanet.<b>debian</b>.<b>o</b>rg", "Planet Debian" },
- { "pla deb o", "planet.debian.org", "Planet Debian", "<b>pla</b>net.<b>deb</b>ian.<b>o</b>rg", "Planet Debian" },
- { "ebi", "planet.debian.org", "Planet Debian", "planet.d<b>ebi</b>an.org", "Planet D<b>ebi</b>an" },
- { "an ebi", "planet.debian.org", "Planet Debian", "pl<b>an</b>et.d<b>ebi</b>an.org", "Pl<b>an</b>et D<b>ebi</b>an" }
-};
-
-void completion_location_action () {
- foreach (var spec in renders) {
- string uri = Midori.LocationAction.render_uri (spec.keys.split (" ", 0), spec.uri);
- string title = Midori.LocationAction.render_title (spec.keys.split (" ", 0), spec.title);
- if (uri != spec.expected_uri || title != spec.expected_title)
- error ("\nExpected: %s/ %s\nInput : %s/ %s/ %s\nResult : %s/ %s",
- spec.expected_uri, spec.expected_title,
- spec.keys, spec.uri, spec.title, uri, title);
- }
-}
-
-class HistoryMarkup : Midori.Test.Job {
- public static void test () { new HistoryMarkup ().run_sync (); }
- public override async void run (Cancellable cancellable) throws GLib.Error {
- var app = new Midori.App ();
- var autocompleter = new Midori.Autocompleter (app);
- assert (!autocompleter.can_complete (""));
-
- var histcomp = new Midori.HistoryCompletion ();
- assert (!histcomp.can_complete (""));
-
- //this calls histcomp.prepare (app):
- autocompleter.add (histcomp);
-
- //any time the history completion has a db, its can_complete method returns true
- //assert (!histcomp.can_complete (""));
-
- //remove entries from previous tests
- histcomp.database.clear (0);
-
- histcomp.database.insert ("https://duckduckgo.com/?q=%3E&ia=about", "> (Clojure) - DuckDuckGo", 0, 0);
- yield autocompleter.complete ("");
- assert (autocompleter.model.iter_n_children (null) == 2);
-
- histcomp.database.insert ("https://duckduckgo.com/", "DuckDuckGo", 0, 0);
- yield autocompleter.complete ("");
- assert (autocompleter.model.iter_n_children (null) == 3);
-
- histcomp.database.insert ("http://stackoverflow.com/questions/5068951/what-do-lt-and-gt-stand-for",
- "html - What do &lt; and &gt; stand for? - Stack Overflow", 0, 0);
- yield autocompleter.complete ("");
- assert (autocompleter.model.iter_n_children (null) == 4);
-
- Gtk.TreeIter iter;
- string title, expected;
-
- expected = "DuckDuckGo";
- autocompleter.model.iter_nth_child (out iter, null, 2);
- autocompleter.model.get (iter, Midori.Autocompleter.Columns.MARKUP, out title);
- if (title != expected)
- error ("Expected %s but got %s", expected, title);
-
- expected = "> (Clojure) - DuckDuckGo";
- autocompleter.model.iter_nth_child (out iter, null, 3);
- autocompleter.model.get (iter, Midori.Autocompleter.Columns.MARKUP, out title);
- if (title != expected)
- error ("Expected %s but got %s", expected, title);
-
- expected = "html - What do &lt; and &gt; stand for? - Stack Overflow";
- autocompleter.model.iter_nth_child (out iter, null, 1);
- autocompleter.model.get (iter, Midori.Autocompleter.Columns.MARKUP, out title);
- if (title != expected)
- error ("Expected %s but got %s", expected, title);
- }
-}
-
-void main (string[] args) {
- Midori.Test.init (ref args);
- Midori.App.setup (ref args, null);
- Midori.Paths.init (Midori.RuntimeMode.NORMAL, null);
- Test.add_func ("/completion/autocompleter", CompletionAutocompleter.test);
- Test.add_func ("/completion/history", CompletionHistory.test);
- Test.add_func ("/completion/location-action", completion_location_action);
- Test.add_func ("/completion/historymarkup", HistoryMarkup.test);
- Test.run ();
-}
-
diff --git a/tests/database.vala b/tests/database.vala
index f90cc0cd..3579b5b6 100644
--- a/tests/database.vala
+++ b/tests/database.vala
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015 Christian Dywan <christian@twotoasts.de>
+ Copyright (C) 2015-2018 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
@@ -9,29 +9,53 @@
See the file COPYING for the full license text.
*/
-class DatabaseTest : Midori.Test.Job {
- public static void test () { new DatabaseTest ().run_sync (); }
- public override async void run (Cancellable cancellable) throws GLib.Error {
- var database = new Midori.Database ();
- database.exec ("CREATE TABLE cats (cat text, favorite text)");
- database.exec ("INSERT INTO cats (cat, favorite) VALUES ('Henry', 'pillow')");
- var statement = database.prepare ("SELECT cat FROM cats WHERE favorite = :toy");
- /* Missing : should throw an error */
+class DatabaseTest {
+ public static void test_bind () {
try {
+ var database = new Midori.Database ();
+ database.exec ("CREATE TABLE cats (cat text, favorite text)");
+ database.exec ("INSERT INTO cats (cat, favorite) VALUES ('Henry', 'pillow')");
+ var statement = database.prepare ("SELECT cat FROM cats WHERE favorite = :toy");
statement.bind ("toy", typeof (string), "pillow");
- } catch (Midori.DatabaseError error) {
- Katze.assert_str_equal (statement.query, error.message,
- "No such parameter 'toy' in statement: " + statement.query);
+ // Missing : should throw an error
+ assert_not_reached ();
+ } catch (Error error) {
+ var expected = new Midori.DatabaseError.TYPE ("");
+ assert_true (error.domain == expected.domain);
+ assert_true (error.code == expected.code);
+ }
+ }
+
+ public static void test_insert_delete () {
+ var loop = new MainLoop ();
+ test_insert_delete_async.begin ((obj, res) => {
+ test_insert_delete_async.end (res);
+ loop.quit ();
+ });
+ loop.run ();
+ }
+
+ public static async void test_insert_delete_async () {
+ try {
+ var database = new Midori.Database ();
+ var item = new Midori.DatabaseItem ("http://example.com", "Example", 0);
+ yield database.insert (item);
+ assert_true (item.database == database);
+ assert_true (item in database);
+ var items = yield database.query ();
+ assert_true (items.data.uri == item.uri);
+ yield item.delete ();
+ assert_true (!(item in database));
+ } catch (Error error) {
+ critical (error.message);
}
- statement.bind (":toy", typeof (string), "pillow");
}
}
void main (string[] args) {
- Midori.Test.init (ref args);
- Midori.App.setup (ref args, null);
- Midori.Paths.init (Midori.RuntimeMode.NORMAL, null);
- Test.add_func ("/database/bind", DatabaseTest.test);
+ Test.init (ref args);
+ Test.add_func ("/database/bind", DatabaseTest.test_bind);
+ Test.add_func ("/database/insert_delete", DatabaseTest.test_insert_delete);
Test.run ();
}
diff --git a/tests/download.vala b/tests/download.vala
deleted file mode 100644
index 4e2d641c..00000000
--- a/tests/download.vala
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- Copyright (C) 2012 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.
-*/
-
-struct TestCase {
- public string data;
- public string mime_type;
- public string? expected_filename;
- public string? expected_extension;
-}
-
-const TestCase[] filenames = {
- { "file:///tmp/midori-user/tumblr123.jpg", "image/jpg", "tumblr123.jpg", ".jpg" },
- { "https://green.cat/8019B6/a.b/500.jpg", "image/jpg", "500.jpg", ".jpg" },
- { "http://example.com/file.png", "image/png", "file.png", ".png" },
- { "http://svn.sf.net/doc/doxy_to_dev.xsl.m4?rev=253", "application/xslt+xml", "doxy_to_dev.xsl.m4", ".m4" }
-};
-
-static void download_suggestion () {
- foreach (var filename in filenames) {
- string? result = Midori.Download.get_filename_suggestion_for_uri (
- filename.mime_type, filename.data);
- Katze.assert_str_equal (filename.data, result, filename.expected_filename);
- }
-}
-
-static void download_extension () {
- foreach (var filename in filenames) {
- string? result = Midori.Download.get_extension_for_uri (filename.data);
- Katze.assert_str_equal (filename.data, result, filename.expected_extension);
- }
-}
-
-static void download_unique () {
- string folder = Midori.Paths.make_tmp_dir ("cacheXXXXXX");
- string filename = Path.build_path (Path.DIR_SEPARATOR_S, folder, "foo.png");
- string org_filename = Path.build_path (Path.DIR_SEPARATOR_S, folder, "foo.png");
- string unique = Midori.Download.get_unique_filename (org_filename);
- Katze.assert_str_equal (folder, unique, filename);
- try {
- FileUtils.set_contents (filename, "12345");
- unique = Midori.Download.get_unique_filename (org_filename);
- filename = Path.build_path (Path.DIR_SEPARATOR_S, folder, "foo-0.png");
- Katze.assert_str_equal (folder, unique, filename);
- FileUtils.set_contents (filename, "12345");
- unique = Midori.Download.get_unique_filename (org_filename);
- filename = Path.build_path (Path.DIR_SEPARATOR_S, folder, "foo-1.png");
- Katze.assert_str_equal (folder, unique, filename);
-
- for (var i = 0; i < 10; i++) {
- filename = Path.build_path (Path.DIR_SEPARATOR_S, folder, "foo-%d.png".printf (i));
- FileUtils.set_contents (filename, "12345");
- }
- }
- catch (Error error) {
- GLib.error (error.message);
- }
- unique = Midori.Download.get_unique_filename (org_filename);
- filename = Path.build_path (Path.DIR_SEPARATOR_S, folder, "foo-10.png");
- Katze.assert_str_equal (folder, unique, filename);
- DirUtils.remove (folder);
-}
-
-void download_properties () {
-#if HAVE_LIBSOUP_2_48_0
- var test_server = new Soup.Server ("server-header", null, null);
- try {
- test_server.listen_local (0, Soup.ServerListenOptions.IPV4_ONLY);
- }
- catch (Error error) {
- GLib.error (error.message);
- }
- var port = test_server.get_uris ().data.port;
-#else
- var test_address = new Soup.Address ("127.0.0.1", Soup.ADDRESS_ANY_PORT);
- test_address.resolve_sync (null);
- var test_server = new Soup.Server ("interface", test_address, null);
- test_server.run_async ();
- var port = test_server.get_port ();
-#endif
- string test_url = "http://127.0.0.1:%u".printf (port);
- test_server.add_handler ("/", (server, msg, path, query, client)=>{
- Thread.usleep (1000000); /* 1 seconds in µs */
- if ("/not_found/" in path)
- msg.set_status (404);
- else
- msg.set_status (200);
- msg.set_response ("text/html", Soup.MemoryUse.COPY, "<body></body>".data);
- });
-
- string was_found_url = test_url + "/cat.png";
- string not_found_url = test_url + "/not_found/dog.png";
-#if HAVE_WEBKIT2
- var download = WebKit.WebContext.get_default ().download_uri (was_found_url);
-#else
- var download = new WebKit.Download (new WebKit.NetworkRequest (was_found_url));
-#endif
- assert (Midori.Download.get_type (download) == 0);
- Midori.Download.set_type (download, Midori.DownloadType.OPEN);
- assert (Midori.Download.get_type (download) == Midori.DownloadType.OPEN);
- assert (Midori.Download.get_progress (download) == 0.0);
-
- string filename, uri;
- try {
- FileUtils.close (FileUtils.open_tmp ("XXXXXX", out filename));
- uri = Filename.to_uri (filename, null);
- }
- catch (Error error) {
- GLib.error (error.message);
- }
-
-#if HAVE_WEBKIT2
- download.set_destination (uri);
-#else
- download.destination_uri = uri;
- download.start ();
-#endif
- string tee = Midori.Download.calculate_tooltip (download);
- assert (tee.contains (Path.get_basename (filename)));
- assert (Midori.Download.get_progress (download) == 0.0);
-
- download.notify["progress"].connect ((pspec) => {
- string tee2 = Midori.Download.calculate_tooltip (download);
- assert (tee2.contains (Path.get_basename (filename)));
- });
- var loop = MainContext.default ();
- do { loop.iteration (true); } while (!Midori.Download.is_finished (download));
-#if !HAVE_WEBKIT2
- assert (download.status == WebKit.DownloadStatus.FINISHED);
-#endif
-
-#if HAVE_WEBKIT2
- download = WebKit.WebContext.get_default ().download_uri (not_found_url);
-#else
- download = new WebKit.Download (new WebKit.NetworkRequest (not_found_url));
-#endif
-#if HAVE_WEBKIT2
- download.set_destination (uri);
-#else
- download.destination_uri = uri;
- download.start ();
-#endif
- do { loop.iteration (true); } while (!Midori.Download.is_finished (download));
-#if !HAVE_WEBKIT2
- assert (download.status == WebKit.DownloadStatus.ERROR);
-#endif
-}
-
-void main (string[] args) {
- Test.init (ref args);
- Midori.App.setup (ref args, null);
- Midori.Paths.init (Midori.RuntimeMode.NORMAL, null);
- Test.add_func ("/download/suggestion", download_suggestion);
- Test.add_func ("/download/extension", download_extension);
- Test.add_func ("/download/unique", download_unique);
- Test.add_func ("/download/properties", download_properties);
- Test.run ();
-}
-
diff --git a/tests/extensions.c b/tests/extensions.c
deleted file mode 100644
index e31c969a..00000000
--- a/tests/extensions.c
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- Copyright (C) 2009 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.
-*/
-
-#include "midori.h"
-#include <glib/gstdio.h>
-
-const gpointer magic = (gpointer)0xdeadbeef;
-
-static void
-extension_activate_cb (MidoriExtension* extension,
- MidoriApp* app)
-{
- g_object_set_data (G_OBJECT (extension), "activated", magic);
-}
-
-static void
-extension_deactivate_cb (MidoriExtension* extension)
-{
- g_object_set_data (G_OBJECT (extension), "deactivated", magic);
-}
-
-static void
-extension_create (void)
-{
- MidoriApp* app;
- MidoriExtension* extension;
-
- app = midori_app_new (NULL);
- extension = g_object_new (MIDORI_TYPE_EXTENSION, NULL);
- g_assert (!midori_extension_is_prepared (extension));
- g_object_set (extension, "name", "TestExtension",
- "version", "1.0", NULL);
- g_assert (!midori_extension_is_prepared (extension));
- g_object_set (extension, "description", "Nothing but a test.",
- "authors", "John Doe", NULL);
- /* FIXME: We should require to connect to "activate"
- g_assert (!midori_extension_is_prepared (extension)); */
- g_signal_connect (extension, "activate",
- G_CALLBACK (extension_activate_cb), NULL);
- g_assert (midori_extension_is_prepared (extension));
- g_assert (!midori_extension_is_active (extension));
- g_signal_emit_by_name (extension, "activate", app);
- g_assert (midori_extension_is_active (extension));
- g_assert (midori_extension_get_app (extension) == app);
- g_assert (g_object_get_data (G_OBJECT (extension), "activated") == magic);
- g_signal_connect (extension, "deactivate",
- G_CALLBACK (extension_deactivate_cb), NULL);
- midori_extension_deactivate (extension);
- g_assert (!midori_extension_is_active (extension));
- g_assert (g_object_get_data (G_OBJECT (extension), "deactivated") == magic);
- g_object_unref (app);
- g_object_unref (extension);
-}
-
-static MidoriExtension*
-extension_mock_object (void)
-{
- MidoriExtension* extension;
-
- extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", "TestExtension",
- "version", "1.0",
- "description", "Nothing but a test.",
- "authors", "John Doe",
- NULL);
- return extension;
-}
-
-static void
-katze_assert_cmpstrv (gchar** values1,
- gsize length1,
- gchar** values2,
- gsize length2)
-{
- gsize i;
-
- g_assert ((values1 && values2) || (!values1 && !values2));
- /* g_assert_cmpint (length1, ==, length2); */
-
- for (i = 0; i < length1; i++)
- g_assert_cmpstr (values1[i], ==, values2[i]);
-}
-
-static void
-extension_settings (void)
-{
- MidoriApp* app;
- MidoriExtension* extension;
- gboolean nihilist;
- gint age;
- const gchar* lastname;
- gchar* pet_names[] = {"Tiger", "Bonzo", "Streuner", NULL};
- gchar** names;
- gsize names_n;
-
- app = midori_app_new (NULL);
- extension = extension_mock_object ();
- midori_extension_install_boolean (extension, "nihilist", TRUE);
- nihilist = midori_extension_get_boolean (extension, "nihilist");
- g_assert (!nihilist);
- g_signal_connect (extension, "activate",
- G_CALLBACK (extension_activate_cb), NULL);
- g_signal_emit_by_name (extension, "activate", app);
- nihilist = midori_extension_get_boolean (extension, "nihilist");
- g_assert (nihilist);
- midori_extension_set_boolean (extension, "nihilist", FALSE);
- nihilist = midori_extension_get_boolean (extension, "nihilist");
- g_assert (!nihilist);
- midori_extension_deactivate (extension);
- g_object_unref (extension);
-
- extension = extension_mock_object ();
- midori_extension_install_integer (extension, "age", 88);
- age = midori_extension_get_integer (extension, "age");
- g_assert_cmpint (age, ==, 0);
- g_signal_connect (extension, "activate",
- G_CALLBACK (extension_activate_cb), NULL);
- g_signal_emit_by_name (extension, "activate", app);
- age = midori_extension_get_integer (extension, "age");
- g_assert_cmpint (age, ==, 88);
- midori_extension_set_integer (extension, "age", 66);
- age = midori_extension_get_integer (extension, "age");
- g_assert_cmpint (age, ==, 66);
- midori_extension_deactivate (extension);
- g_object_unref (extension);
-
- extension = extension_mock_object ();
- midori_extension_install_string (extension, "lastname", "Thomas Mann");
- lastname = midori_extension_get_string (extension, "lastname");
- g_assert_cmpstr (lastname, ==, NULL);
- g_signal_connect (extension, "activate",
- G_CALLBACK (extension_activate_cb), NULL);
- g_signal_emit_by_name (extension, "activate", app);
- lastname = midori_extension_get_string (extension, "lastname");
- g_assert_cmpstr (lastname, ==, "Thomas Mann");
- midori_extension_set_string (extension, "lastname", "Theodor Fontane");
- lastname = midori_extension_get_string (extension, "lastname");
- g_assert_cmpstr (lastname, ==, "Theodor Fontane");
- midori_extension_deactivate (extension);
- g_object_unref (extension);
-
- extension = extension_mock_object ();
- midori_extension_install_string_list (extension, "pets", pet_names, 3);
- names = midori_extension_get_string_list (extension, "pets", &names_n);
- katze_assert_cmpstrv (NULL, 0, names, names_n);
- g_strfreev (names);
- g_signal_emit_by_name (extension, "activate", app);
- names = midori_extension_get_string_list (extension, "pets", &names_n);
- katze_assert_cmpstrv (pet_names, 3, names, names_n);
- g_strfreev (names);
- /* names = g_strsplit ("Carla,Fluffy,Goro,Kitty", ",", 0);
- midori_extension_set_string_list (extension, "pets", names, G_MAXSIZE);
- g_strfreev (names);
- names = midori_extension_get_string_list (extension, "pets", &names_n);
- g_assert_cmpint (names_n, ==, 4); */
- names = g_strsplit ("Carla,Fluffy,Goro,Kitty", ",", 0);
- midori_extension_set_string_list (extension, "pets", names, 2);
- g_strfreev (names);
- names = midori_extension_get_string_list (extension, "pets", &names_n);
- g_strfreev (names);
- g_assert_cmpint (names_n, ==, 2);
- midori_extension_deactivate (extension);
- g_object_unref (extension);
- g_object_unref (app);
-}
-
-static void
-extension_activate (gconstpointer data)
-{
- MidoriApp* app = midori_app_new (NULL);
- g_object_set (app, "settings", midori_web_settings_new (), NULL);
- midori_extension_activate (G_OBJECT (data), NULL, TRUE, app);
- /* TODO: MidoriCompletion */
- g_object_unref (app);
-}
-
-static GObject*
-extension_load (const gchar* extension_path, gboolean register_tests)
-{
- g_assert (g_file_test (extension_path, G_FILE_TEST_EXISTS) == 1);
- gchar* extension_dir = g_path_get_dirname (extension_path);
- gchar* filename = g_path_get_basename (extension_path);
-
- GObject* extension = midori_extension_load_from_file (extension_dir, filename, FALSE, TRUE);
-
- if (register_tests)
- {
- if (KATZE_IS_ARRAY (extension))
- {
- MidoriExtension* extension_item;
- KATZE_ARRAY_FOREACH_ITEM (extension_item, KATZE_ARRAY (extension))
- if (MIDORI_IS_EXTENSION (extension_item))
- {
- gchar* key = katze_object_get_object (extension_item, "key");
- gchar* path = g_strdup_printf ("/extensions/%s/%s", filename, key);
- g_test_add_data_func (path, extension_item, extension_activate);
- g_free (path);
- g_free (key);
- }
- }
- else if (extension != NULL)
- {
- gchar* path = g_strconcat ("/extensions/", filename, NULL);
- g_test_add_data_func (path, extension, extension_activate);
- g_free (path);
- }
- }
-
- g_free (extension_dir);
- g_free (filename);
- return extension;
-}
-
-static void
-extension_config (void)
-{
- gchar* filename = midori_paths_get_extension_config_dir ("adblock");
- g_assert (g_file_test (filename, G_FILE_TEST_EXISTS) == 1);
- g_free (filename);
-}
-
-int
-main (int argc,
- char** argv)
-{
- midori_test_init (&argc, &argv);
- gchar* extension_path = NULL;
- GOptionEntry entries[] = {
- { "extension", 'e', 0, G_OPTION_ARG_STRING, &extension_path,
- "Execute cases defined in extension_init", "EXTENSION" },
- { NULL }
- };
- midori_app_setup (&argc, &argv, entries);
- midori_paths_init (MIDORI_RUNTIME_MODE_NORMAL, NULL);
- #ifndef HAVE_WEBKIT2
- soup_session_add_feature_by_type (webkit_get_default_session (),
- SOUP_TYPE_COOKIE_JAR);
- #endif
-
- GObject* extension = NULL;
- GObject* extension2 = NULL;
-
- if (extension_path == NULL)
- {
- g_test_add_func ("/extensions/create", extension_create);
- g_test_add_func ("/extensions/settings", extension_settings);
- g_test_add_func ("/extensions/config", extension_config);
- }
- else
- {
- g_assert (g_module_supported ());
- extension = extension_load (extension_path, TRUE);
- /* We require that extensions can be loaded repeatedly */
- extension2 = extension_load (extension_path, FALSE);
- }
-
- int result = g_test_run ();
-
- if (extension)
- {
- midori_extension_deactivate (MIDORI_EXTENSION (extension));
- g_object_unref (extension);
- }
- /* The second copy loaded does not get activated, because no tests are
- registered for it */
- if (extension2)
- g_object_unref (extension2);
-
- return result;
-}
diff --git a/tests/hsts.vala b/tests/hsts.vala
deleted file mode 100644
index 7ba46b4c..00000000
--- a/tests/hsts.vala
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- Copyright (C) 2012 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.
-*/
-
-static void http_hsts () {
- Midori.HSTS.Directive d;
- d = new Midori.HSTS.Directive.from_header ("max-age=31536000");
- assert (d.is_valid () && !d.sub_domains);
- d = new Midori.HSTS.Directive.from_header ("max-age=15768000 ; includeSubDomains");
- assert (d.is_valid () && d.sub_domains);
-
- /* Invalid */
- d = new Midori.HSTS.Directive.from_header ("");
- assert (!d.is_valid () && !d.sub_domains);
- d = new Midori.HSTS.Directive.from_header ("includeSubDomains");
- assert (!d.is_valid () && d.sub_domains);
-}
-
-void main (string[] args) {
- Test.init (ref args);
- Midori.App.setup (ref args, null);
- Test.add_func ("/http/hsts", http_hsts);
- Test.run ();
-}
-
diff --git a/tests/license.sh b/tests/license.sh
index 6320e40f..55bcf622 100755
--- a/tests/license.sh
+++ b/tests/license.sh
@@ -1,5 +1,5 @@
#! /usr/bin/env sh
-# Copyright 2012 Christian Dywan <christian@twotoasts.de>
+# Copyright 2012-2018 Christian Dywan <christian@twotoasts.de>
#
# This script is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -8,6 +8,5 @@
echo Running 'licensecheck'
test -z $(which licensecheck) && echo ...SKIPPED: not installed && exit 0
test -n "$SRCDIR" && cd $SRCDIR
-test -z "$BLDDIR" && BLDDIR=_build
-find . \! -path './.*/*' -a \! -path "./$BLDDIR/*" -a \! -path "./_*/*" -a \! -path "./debian/*" | xargs licensecheck | grep UNKNOWN && exit 1
+git ls-files | xargs licensecheck | grep UNKNOWN && exit 1
echo ...OK
diff --git a/tests/magic-uri.c b/tests/magic-uri.c
deleted file mode 100644
index 518c087b..00000000
--- a/tests/magic-uri.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
- Copyright (C) 2008-2009 Christian Dywan <christian@twotoasts.de>
- Copyright (C) 2009 Alexander Butenko <a.butenka@gmail.com>
-
- 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.
-*/
-
-#include <midori/midori.h>
-
-#define SM "http://www.searchmash.com/search/"
-#define HTTP_PREFIX "midori-unit-test-expected-http-prefix"
-
-static void
-test_input (const gchar* input,
- const gchar* expected)
-{
- static KatzeArray* search_engines = NULL;
- gchar* uri;
- gchar* real_expected = NULL;
-
- if (G_UNLIKELY (!search_engines))
- {
- KatzeItem* item;
-
- search_engines = katze_array_new (KATZE_TYPE_ITEM);
- item = g_object_new (KATZE_TYPE_ITEM,
- "uri", SM "%s",
- "token", "sm", NULL);
- katze_array_add_item (search_engines, item);
- g_object_unref (item);
- item = g_object_new (KATZE_TYPE_ITEM,
- "uri", SM,
- "token", "se", NULL);
- katze_array_add_item (search_engines, item);
- g_object_unref (item);
- item = g_object_new (KATZE_TYPE_ITEM,
- "uri", "ddg.gg",
- "token", "dd", NULL);
- katze_array_add_item (search_engines, item);
- g_object_unref (item);
- item = g_object_new (KATZE_TYPE_ITEM,
- "uri", "google.com",
- "token", "d", NULL);
- katze_array_add_item (search_engines, item);
- g_object_unref (item);
- }
-
- uri = sokoke_magic_uri (input, TRUE, FALSE);
- if (!uri)
- {
- const gchar* keywords = NULL;
- const gchar* search_uri = NULL;
- KatzeItem* item;
-
- /* Do we have a keyword and a string? */
- if ((item = katze_array_find_token (search_engines, input)))
- {
- keywords = strchr (input, ' ');
- if (keywords != NULL)
- keywords++;
- else
- keywords = "";
- search_uri = katze_item_get_uri (item);
- }
-
- uri = search_uri ? midori_uri_for_search (search_uri, keywords) : NULL;
- }
-
- if (!g_strcmp0 (expected, HTTP_PREFIX))
- real_expected = g_strconcat ("http://", input, NULL);
-
- katze_assert_str_equal (input, uri, real_expected ? real_expected : expected);
- g_free (real_expected);
- g_free (uri);
-}
-
-static void
-magic_uri_uri (void)
-{
- const gchar* uri;
- gchar* path;
-
- test_input ("ftp://ftp.mozilla.org", "ftp://ftp.mozilla.org");
- test_input ("ftp://ftp.mozilla.org/pub", "ftp://ftp.mozilla.org/pub");
- test_input ("http://www.example.com", "http://www.example.com");
- test_input ("http://example.com", "http://example.com");
- test_input ("example.com", "http://example.com");
- test_input ("example.com", "http://example.com");
- test_input ("www.google..com", "http://www.google..com");
- test_input ("/home/user/midori.html", "file:///home/user/midori.html");
- test_input ("http://www.google.com/search?q=query test",
- "http://www.google.com/search?q=query test");
- if (sokoke_resolve_hostname ("localhost"))
- {
- test_input ("localhost", "http://localhost");
- test_input ("localhost:8000", "http://localhost:8000");
- test_input ("localhost/rss", "http://localhost/rss");
- }
- test_input ("10.0.0.1", "http://10.0.0.1");
- test_input ("192.168.1.1", "http://192.168.1.1");
- test_input ("192.168.1.1:8000", "http://192.168.1.1:8000");
- test_input ("file:///home/mark/foo/bar.html",
- "file:///home/mark/foo/bar.html");
- test_input ("foo:123@bar.baz", "http://foo:123@bar.baz");
- /* test_input ("foo:f1o2o3@bar.baz", "http://f1o2o3:foo@bar.baz"); */
- /* test_input ("foo:foo@bar.baz", "http://foo:foo@bar.baz"); */
-
- test_input ("2001:0db8:85a3:0000:0000:8a2e:0370:7334", HTTP_PREFIX);
- test_input ("fe80:0:0:0:202:b3ff:fe1e:8329", HTTP_PREFIX);
- test_input ("fe80::202:b3ff:fe1e:8329", HTTP_PREFIX);
- test_input ("fe80::76e5:bff:fe04:38e0/64", HTTP_PREFIX);
- test_input ("content::browser", NULL);
- test_input ("std::copy", NULL);
-
- uri = "http://bugs.launchpad.net/midori";
- g_assert_cmpstr ("bugs.launchpad.net", ==, midori_uri_parse_hostname (uri, NULL));
- uri = "https://bugs.launchpad.net/midori";
- g_assert_cmpstr ("bugs.launchpad.net", ==, midori_uri_parse_hostname (uri, NULL));
- g_assert_cmpstr ("bugs.launchpad.net", ==, midori_uri_parse_hostname (uri, &path));
- g_assert_cmpstr ("/midori", ==, path);
- uri = "http://айкидо.ru/users/kotyata";
- g_assert_cmpstr ("айкидо.ru", ==, midori_uri_parse_hostname (uri, &path));
- g_assert_cmpstr ("/users/kotyata", ==, path);
- uri = "invalid:/uri.like/thing";
- g_assert_cmpstr (NULL, ==, midori_uri_parse_hostname (uri, NULL));
- uri = "invalid-uri.like:thing";
- g_assert_cmpstr (NULL, ==, midori_uri_parse_hostname (uri, NULL));
-}
-
-static void
-magic_uri_idn (void)
-{
- typedef struct
- {
- const gchar* before;
- const gchar* after;
- } URIItem;
-
- static const URIItem items[] = {
- { "http://www.münchhausen.at", "http://www.xn--mnchhausen-9db.at" },
- { "http://www.خداوند.com/", "http://www.xn--mgbndb8il.com/" },
- { "айкидо.com", "xn--80aildf0a.com" },
- { "http://東京理科大学.jp", "http://xn--1lq68wkwbj6ugkpigi.jp" },
- { "https://青のネコ", "https://xn--u9jthzcs263c" },
- { "http://en.wikipedia.org/wiki/Kölsch_language", NULL },
- { "file:///home/mark/frühstück", NULL },
- { "about:version", NULL },
- };
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS (items); i++)
- {
- gchar* result = midori_uri_to_ascii (items[i].before);
- const gchar* after = items[i].after ? items[i].after : items[i].before;
- katze_assert_str_equal (items[i].before, result, after);
- g_free (result);
- }
-
- test_input ("айкидо.com", "http://айкидо.com");
- test_input ("sm Küchenzubehör", SM "Küchenzubehör");
- test_input ("sm 東京理科大学", SM "東京理科大学");
-}
-
-static void
-magic_uri_search (void)
-{
- test_input ("sm midori", SM "midori");
- test_input ("d midori browser", "google.com" "midori%20browser");
- test_input ("dd midori browser", "ddg.gg" "midori%20browser");
- test_input ("sm cats dogs", SM "cats%20dogs");
- test_input ("se cats dogs", SM "cats%20dogs");
- test_input ("dict midori", NULL);
- test_input ("cats", NULL);
- test_input ("cats dogs", NULL);
- test_input ("gtk 2.0", NULL);
- test_input ("gtk2.0", NULL);
- test_input ("pcre++", NULL);
- test_input ("sm pcre++", SM "pcre%2B%2B");
- test_input ("5580", NULL);
- test_input ("sm 5580", SM "5580");
- test_input ("midori0.1.0", NULL);
- test_input ("midori 0.1.0", NULL);
- test_input ("search:cats", NULL);
- test_input ("search:twotoasts.de", NULL);
- test_input ("g cache:127.0.0.1", NULL);
- test_input ("g cache:127.0.0.1/foo", NULL);
- test_input ("g cache:twotoasts.de/foo", NULL);
- test_input ("sm cache:127.0.0.1", SM "cache:127.0.0.1");
- test_input ("sm cache:127.0.0.1/foo", SM "cache:127.0.0.1/foo");
- test_input ("sm cache:twotoasts.de/foo", SM "cache:twotoasts.de/foo");
- test_input ("de.po verbose", NULL);
- test_input ("verbose de.po", NULL);
- test_input ("g de.po verbose", NULL);
- test_input ("sm de.po verbose", SM "de.po%20verbose");
- test_input ("sm warning: configure /dev/net: virtual",
- SM "warning:%20configure%20/dev/net:%20virtual");
- test_input ("g \"ISO 9001:2000 certified\"", NULL);
- test_input ("g conference \"April 2, 7:00 am\"", NULL);
- test_input ("max@mustermann.de", NULL);
- test_input ("g max@mustermann.de", NULL);
- test_input ("g inurl:http://twotoasts.de bug", NULL);
- test_input ("sm", SM);
- /* test_input ("LT_PREREQ(2.2)", NULL); */
-}
-
-static void
-magic_uri_pseudo (void)
-{
- test_input ("javascript:alert(1)", "javascript:alert(1)");
- test_input ("data:text/html;charset=utf-8,<title>Test</title>Test",
- "data:text/html;charset=utf-8,<title>Test</title>Test");
-}
-
-static void
-magic_uri_performance (void)
-{
- gsize i;
-
- g_test_timer_start ();
-
- for (i = 0; i < 1000; i++)
- {
- magic_uri_uri ();
- magic_uri_idn ();
- magic_uri_search ();
- magic_uri_pseudo ();
- }
-
- g_print ("\nTime needed for URI tests: %f ", g_test_timer_elapsed ());
-}
-
-static void
-magic_uri_fingerprint (void)
-{
- const gchar* uri;
- uri = "http://midori-0.4.1.tar.bz2#!md5!33dde203cd71ae2b1d2adcc7f5739f65";
- g_assert_cmpint (midori_uri_get_fingerprint (uri, NULL, NULL), ==, G_CHECKSUM_MD5);
- uri = "http://midori-0.4.1.tar.bz2#!md5!33DDE203CD71AE2B1D2ADCC7F5739F65";
- g_assert_cmpint (midori_uri_get_fingerprint (uri, NULL, NULL), ==, G_CHECKSUM_MD5);
- uri = "http://midori-0.4.1.tar.bz2#!sha1!0c499459b1049feabf86dce89f49020139a9efd9";
- g_assert_cmpint (midori_uri_get_fingerprint (uri, NULL, NULL), ==, G_CHECKSUM_SHA1);
- uri = "http://midori-0.4.1.tar.bz2#!sha256!123456";
- g_assert_cmpint (midori_uri_get_fingerprint (uri, NULL, NULL), ==, G_MAXINT);
- uri = "http://midori-0.4.1.tar.bz2#abcdefg";
- g_assert_cmpint (midori_uri_get_fingerprint (uri, NULL, NULL), ==, G_MAXINT);
- uri = "http://midori-0.4.1.tar.bz2";
- g_assert_cmpint (midori_uri_get_fingerprint (uri, NULL, NULL), ==, G_MAXINT);
-}
-
-static void
-magic_uri_ip (void)
-{
- g_assert (midori_uri_is_ip_address ("192.168.1.1"));
- g_assert (midori_uri_is_ip_address ("192.168.1.1:1234"));
- g_assert (!midori_uri_is_ip_address ("0.168.1.1"));
- g_assert (midori_uri_is_ip_address ("user@192.168.1.1"));
- g_assert (midori_uri_is_ip_address ("user:password@192.168.1.1"));
- g_assert (midori_uri_is_ip_address ("2001:0db8:85a3:0000:0000:8a2e:0370:7334"));
- g_assert (midori_uri_is_ip_address ("fe80:0:0:0:202:b3ff:fe1e:8329"));
- g_assert (midori_uri_is_ip_address ("fe80::202:b3ff:fe1e:8329"));
- g_assert (midori_uri_is_ip_address ("fe80::76e5:bff:fe04:38e0/64"));
-}
-
-static void
-magic_uri_format (void)
-{
- typedef struct
- {
- const gchar* before;
- const gchar* after;
- } URIItem;
-
- static const URIItem items[] = {
- { "http://www.csszengarden.com", NULL },
- { "http://live.gnome.org/GTK+/3.0/Tasks", NULL },
- { "http://www.johannkönig.com/index.php?ausw=home", NULL },
- { "http://en.wikipedia.org/wiki/Fat%20cat", NULL },
- { "http://en.wikipedia.org/wiki/Fat cat",
- "http://en.wikipedia.org/wiki/Fat%20cat" },
- { "http://incomplete.escape/%", NULL },
- { "http://incomplete.escape/%f", NULL },
- { "http://invalid.escape/%xx", NULL },
- { "http://invalid.escape/%gg", NULL },
- { "http://complete.escape/%41",
- "http://complete.escape/A" },
- { "http://complete.escape/%42C",
- "http://complete.escape/BC" },
- { "http://www.google.com/%21%00ok",
- "http://www.google.com/!%00ok" },
- { "http://everything2.com/title/%2526%252364%253B", NULL },
- { "http://www.google.com/get%25100.html", NULL },
- { "http://digilife.bz/wiki/index.php?Python%E3%81%AE%E9%96%8B%E7%99%BA%E6%89%8B%E9%A0%86",
- "http://digilife.bz/wiki/index.php?Pythonの開発手順" },
- { "http://die-welt.net/~evgeni/LenovoBatteryLinux/", NULL },
- { "http://wiki.c3sl.ufpr.br/multiseat/index.php/Xephyr_Solution", NULL },
- { "http://şøñđëřżēıċħęŋđőmæîņĭśŧşũþėŗ.de/char.jpg", NULL },
- { "http://www.ⓖⓝⓞⓜⓔ.org/", "http://www.gnome.org/" },
- { "http://translate.google.com/#en/de/cat%0Adog%0Ahorse",
- "http://translate.google.com/#en/de/cat%0Adog%0Ahorse" },
- };
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS (items); i++)
- {
- gchar* result = midori_uri_format_for_display (items[i].before);
- const gchar* after = items[i].after ? items[i].after : items[i].before;
- katze_assert_str_equal (items[i].before, result, after);
- g_free (result);
- }
-}
-
-static void
-magic_uri_prefix (void)
-{
-
- typedef struct
- {
- const gchar* before;
- const gchar* after;
- } URIItem;
-
- static const URIItem items[] = {
- { "http://www.example.com", "example.com" },
- { "http://example.com", "example.com" },
- { "https://example.com", "example.com" },
- { "file:///path/to/my/heart", "/path/to/my/heart" },
- };
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS (items); i++)
- {
- gchar* result = midori_uri_strip_prefix_for_display (items[i].before);
- const gchar* after = items[i].after ? items[i].after : items[i].before;
- katze_assert_str_equal (items[i].before, result, after);
- g_free (result);
- }
-}
-
-static void
-magic_uri_prefetch (void)
-{
- g_assert (!sokoke_prefetch_uri (NULL, NULL, NULL, NULL));
- g_assert (sokoke_prefetch_uri (NULL, "http://google.com", NULL, NULL));
- g_assert (sokoke_prefetch_uri (NULL, "http://google.com", NULL, NULL));
- g_assert (sokoke_prefetch_uri (NULL, "http://googlecom", NULL, NULL));
- g_assert (sokoke_prefetch_uri (NULL, "http://1kino.com", NULL, NULL));
- g_assert (sokoke_prefetch_uri (NULL, "http://", NULL, NULL));
- g_assert (!sokoke_prefetch_uri (NULL, "http:/", NULL, NULL));
- g_assert (!sokoke_prefetch_uri (NULL, "http", NULL, NULL));
- g_assert (!sokoke_prefetch_uri (NULL, "ftp://ftphost.org", NULL, NULL));
- g_assert (!sokoke_prefetch_uri (NULL, "http://10.0.0.1", NULL, NULL));
- g_assert (!sokoke_prefetch_uri (NULL, "about:blank", NULL, NULL));
- g_assert (!sokoke_prefetch_uri (NULL, "javascript: alert()", NULL, NULL));
-}
-
-static void
-magic_uri_commands (void)
-{
- typedef struct
- {
- const gchar* command;
- gboolean quote;
- const gchar* expected;
- } CommandItem;
-
- static const CommandItem commands[] = {
- { "midori", TRUE, NULL },
- { "/usr/bin/midori", TRUE, NULL },
- { "C:/Program Files/Midori/bin/midori.exe", TRUE, NULL },
- { "C:/Programme/Midori/bin/midori.exe", TRUE, NULL },
- };
- static const CommandItem arguments[] = {
- { "-a 'http://lunduke.com/?p=3606'", FALSE, NULL },
- { "about:private", FALSE, NULL },
- };
- guint i, j;
-
- for (i = 0; i < G_N_ELEMENTS (commands); i++)
- for (j = 0; j < G_N_ELEMENTS (arguments); j++)
- {
- gchar* input = g_strconcat (commands[i].command, " ", arguments[j].command, NULL);
- gchar* ce = commands[i].expected ? (gchar*)commands[i].expected
- : g_strconcat ("'", commands[i].command, "'", NULL);
- gchar* ae = arguments[j].expected ? (gchar*)arguments[j].expected
- : (arguments[j].quote ? g_strconcat ("'", arguments[j].command, "'", NULL)
- : g_strdup (arguments[j].command));
- gchar* expected = g_strconcat (ce, " ", ae, NULL);
- gchar* result = sokoke_prepare_command (commands[i].command,
- commands[i].quote, arguments[j].command, arguments[j].quote);
- katze_assert_str_equal (input, result, expected);
- g_free (input);
- g_free (ce);
- g_free (ae);
- g_free (expected);
- g_free (result);
- }
-}
-
-GAppInfo* sokoke_default_for_uri (const gchar* uri, gchar** scheme_ptr);
-
-static gboolean uri_has_default (const gchar* uri)
-{
- GAppInfo* info = sokoke_default_for_uri (uri, NULL);
- if (info)
- g_object_unref (info);
- return info != NULL;
-}
-
-static void
-magic_uri_protocols (void)
-{
- g_assert (!sokoke_external_uri (NULL));
- g_assert (!sokoke_external_uri (""));
-
- g_assert (!sokoke_external_uri ("http://google.com"));
- g_assert (!sokoke_external_uri ("HTTP://google.com"));
- g_assert (!sokoke_external_uri ("Http://google.com"));
- g_assert (!sokoke_external_uri ("https://google.com"));
- g_assert (!sokoke_external_uri ("httPS://google.com"));
- g_assert (!sokoke_external_uri ("file:///home/"));
- g_assert (!sokoke_external_uri ("geo:100,3000"));
- g_assert (!sokoke_external_uri ("about:blank"));
-
- g_assert (!sokoke_external_uri ("https://"));
- g_assert (!sokoke_external_uri ("http://"));
- g_assert (!sokoke_external_uri ("http:/"));
- g_assert (!sokoke_external_uri ("http"));
- g_assert (sokoke_external_uri ("ftp://ftphost.org") == uri_has_default ("ftp://ftphost.org"));
- g_assert (sokoke_external_uri ("geometry:bar") == uri_has_default ("geometry:bar"));
- g_assert (sokoke_external_uri ("httparty:woo") == uri_has_default ("httparty:woo"));
-}
-
-static void
-magic_uri_base_domain (void)
-{
- #ifdef HAVE_LIBSOUP_2_40_0
- g_assert_cmpstr ("bbc.co.uk", ==, midori_uri_get_base_domain ("http://www.bbc.co.uk"));
- g_assert_cmpstr ("zeit.de", ==, midori_uri_get_base_domain ("http://www.zeit.de"));
- #endif
- g_assert_cmpstr ("123.456.789.100", ==, midori_uri_get_base_domain ("http://123.456.789.100"));
-}
-
-int
-main (int argc,
- char** argv)
-{
- g_test_init (&argc, &argv, NULL);
- midori_app_setup (&argc, &argv, NULL);
-
- g_test_add_func ("/magic-uri/uri", magic_uri_uri);
- g_test_add_func ("/magic-uri/idn", magic_uri_idn);
- g_test_add_func ("/magic-uri/search", magic_uri_search);
- g_test_add_func ("/magic-uri/pseudo", magic_uri_pseudo);
- g_test_add_func ("/magic-uri/performance", magic_uri_performance);
- g_test_add_func ("/magic-uri/fingerprint", magic_uri_fingerprint);
- g_test_add_func ("/magic-uri/ip", magic_uri_ip);
- g_test_add_func ("/magic-uri/format", magic_uri_format);
- g_test_add_func ("/magic-uri/prefix", magic_uri_prefix);
- g_test_add_func ("/magic-uri/prefetch", magic_uri_prefetch);
- g_test_add_func ("/magic-uri/commands", magic_uri_commands);
- g_test_add_func ("/magic-uri/protocols", magic_uri_protocols);
- g_test_add_func ("/magic-uri/base-domain", magic_uri_base_domain);
-
- return g_test_run ();
-}
diff --git a/tests/notebook.vala b/tests/notebook.vala
deleted file mode 100644
index 383d97b0..00000000
--- a/tests/notebook.vala
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- Copyright (C) 2014 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.
-*/
-
-void notebook_menu () {
- var notebook = new Midori.Notebook ();
- /* FIXME: we should just use a Tab but currently it has no title property */
- var tab = new Midori.View.with_title ("a_fairy_tale", new Midori.WebSettings ());
- /*var tab = new Midori.View.with_title (null, new Midori.WebSettings ());
- view.set_html ("<title>a_fairy_tale</title><body>The earth is <em>flat</em> for a fact.</body>");
- var loop = MainContext.default ();
- do { loop.iteration (true); } while (view.load_status != Midori.LoadStatus.FINISHED);*/
- notebook.insert (tab, 0);
- var menu = notebook.get_context_action ();
- var tab_menu = menu.get_by_name ("Tab0");
- assert (tab_menu != null);
- /* The underscores should be escaped */
- Katze.assert_str_equal ("Tab0", tab_menu.label, "‪a__fairy__tale");
-}
-
-void main (string[] args) {
- Test.init (ref args);
- Midori.App.setup (ref args, null);
- Test.add_func ("/notebook/menu", notebook_menu);
- Test.run ();
-}
diff --git a/tests/properties.c b/tests/properties.c
deleted file mode 100644
index e0cc87b5..00000000
--- a/tests/properties.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- Copyright (C) 2009 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.
-*/
-
-#include "midori.h"
-
-#define pspec_is_writable(pspec) (pspec->flags & G_PARAM_WRITABLE \
- && !(pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)))
-
-static void
-properties_object_get_set (GObject* object)
-{
- GObjectClass* class;
- GParamSpec** pspecs;
- guint i, n_properties;
-
- class = G_OBJECT_GET_CLASS (object);
- pspecs = g_object_class_list_properties (class, &n_properties);
- for (i = 0; i < n_properties; i++)
- {
- GParamSpec *pspec = pspecs[i];
- guint j;
-
- /* Skip properties of parent classes */
- if (pspec->owner_type != G_OBJECT_TYPE (object))
- continue;
-
- /* Verify that the ID is unique */
- if (pspecs[i]->owner_type == G_OBJECT_TYPE (object))
- for (j = 0; j < n_properties; j++)
- if (i != j && pspecs[j]->owner_type == G_OBJECT_TYPE (object))
- if (pspec->param_id == pspecs[j]->param_id)
- g_error ("Duplicate ID %d of %s and %s",
- pspec->param_id,
- g_param_spec_get_name (pspec),
- g_param_spec_get_name (pspecs[j]));
- }
- g_free (pspecs);
-}
-
-static void
-properties_object_test (gconstpointer object)
-{
- if (GTK_IS_WIDGET (object))
- g_object_ref_sink ((GObject*)object);
-
- properties_object_get_set ((GObject*)object);
-
- if (GTK_IS_WIDGET (object))
- gtk_widget_destroy (GTK_WIDGET (object));
- g_object_unref ((GObject*)object);
-}
-
-static void
-properties_type_test (gconstpointer type)
-{
- GObject* object;
-
- midori_test_log_set_fatal_handler_for_icons ();
- object = g_object_new ((GType)type, NULL);
- properties_object_test ((gconstpointer)object);
-}
-
-GtkWidget*
-midori_dummy_viewable_new (const gchar* stock_id,
- const gchar* label,
- GtkWidget* toolbar);
-
-GtkWidget* dummy_viewable_new (void)
-{
- GtkWidget* toolbar = gtk_toolbar_new ();
- return midori_dummy_viewable_new (GTK_STOCK_ABOUT, "Test", toolbar);
-}
-
-int
-main (int argc,
- char** argv)
-{
- g_test_init (&argc, &argv, NULL);
- midori_app_setup (&argc, &argv, NULL);
- midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, NULL);
-
- #ifndef HAVE_WEBKIT2
- g_object_set_data (G_OBJECT (webkit_get_default_session ()),
- "midori-session-initialized", (void*)1);
- #endif
-
- g_test_add_data_func ("/properties/app",
- (gconstpointer)MIDORI_TYPE_APP, properties_type_test);
- g_test_add_data_func ("/properties/browser",
- (gconstpointer)MIDORI_TYPE_BROWSER, properties_type_test);
- g_test_add_data_func ("/properties/extension",
- (gconstpointer)MIDORI_TYPE_EXTENSION, properties_type_test);
- g_test_add_data_func ("/properties/location-action",
- (gconstpointer)MIDORI_TYPE_LOCATION_ACTION, properties_type_test);
- g_test_add_data_func ("/properties/panel",
- (gconstpointer)MIDORI_TYPE_PANEL, properties_type_test);
- g_test_add_data_func ("/properties/preferences",
- (gconstpointer)MIDORI_TYPE_PREFERENCES, properties_type_test);
- g_test_add_data_func ("/properties/search-action",
- (gconstpointer)MIDORI_TYPE_SEARCH_ACTION, properties_type_test);
- g_test_add_data_func ("/properties/view",
- (gconstpointer)MIDORI_TYPE_VIEW, properties_type_test);
- g_test_add_data_func ("/properties/viewable",
- (gconstpointer)dummy_viewable_new (), properties_object_test);
- g_test_add_data_func ("/properties/web-settings",
- (gconstpointer)MIDORI_TYPE_WEB_SETTINGS, properties_type_test);
-
- return g_test_run ();
-}
diff --git a/tests/searchaction.vala b/tests/searchaction.vala
deleted file mode 100644
index 530cf5dc..00000000
--- a/tests/searchaction.vala
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- Copyright (C) 2012 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.
-*/
-
-/*
-struct FormSpec {
- public string html;
- public Pango.EllipsizeMode ellipsize;
- public string? uri;
- public string? title;
-}
-
-const FormSpec[] forms = {
- { "<form></form>", Pango.EllipsizeMode.END, null, null },
- { "<form><input></form>", Pango.EllipsizeMode.END, null, null }
-};
-*/
-
-void searchaction_form () {
- /*
- foreach (var form in forms) {
- var view = new Midori.View.with_title ();
- view.get_web_view ().load_html_string (form.html, "");
- Katze.Item? result = Midori.SearchAction.get_engine_for_form (
- view.get_web_view (), form.ellipsize);
- Katze.assert_str_equal (form.html,
- result != null ? result.uri : null, form.uri);
- Katze.assert_str_equal (form.html,
- result != null ? result.name : null, form.title);
- }
- */
-}
-
-struct TokenSpec {
- public string uri;
- public string expected_token;
-}
-
-const TokenSpec[] tokens = {
- { "https://bugs.launchpad.net/midori/+bugs", "lnch" },
- { "https://duckduckgo.com/search", "dckd" },
- { "http://en.wikipedia.org/w/index.php?title=Special:Search&profile=default&search=%s&fulltext=Search&", "wkpd" },
- { "about:blank", "" },
- { "", "" },
- { "file:///", "" },
- { "file:///form.html", "" }
-};
-
-void searchaction_token () {
- foreach(var token in tokens)
- {
- Katze.assert_str_equal (token.uri,
- Midori.SearchAction.token_for_uri(token.uri), token.expected_token);
- }
-}
-
-void main (string[] args) {
- Test.init (ref args);
- Midori.App.setup (ref args, null);
- Test.add_func ("/searchaction/form", searchaction_form);
- Test.add_func ("/searchaction/token", searchaction_token);
- Test.run ();
-}
-
diff --git a/tests/speeddial.vala b/tests/speeddial.vala
deleted file mode 100644
index 20d12485..00000000
--- a/tests/speeddial.vala
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- Copyright (C) 2012 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.
-*/
-static string? tmp_folder = null;
-string get_test_file (string contents) {
- if (tmp_folder == null)
- tmp_folder = Midori.Paths.make_tmp_dir ("speeddialXXXXXX");
- string checksum = Checksum.compute_for_string (ChecksumType.MD5, contents);
- string file = Path.build_path (Path.DIR_SEPARATOR_S, tmp_folder, checksum);
- try {
- FileUtils.set_contents (file, contents, -1);
- } catch (Error file_error) {
- GLib.error (file_error.message);
- }
- return file;
-}
-
-static void speeddial_load () {
- string data = get_test_file ("""
- [Dial 1]
- uri=http://example.com
- title=Example
- [settings]
- columns=3
- rows=3
- """);
-
- string json = get_test_file ("""
- '{"shortcuts":[{"id":"s1","href":"http://example.com","title":"Example","img":"a2F0emU="}]}'
- """);
-
- var dial_data = new Midori.SpeedDial (data, "");
- var dial_json = new Midori.SpeedDial ("", json);
- FileUtils.remove (data);
- FileUtils.remove (json);
-
- Katze.assert_str_equal (json, dial_data.keyfile.to_data (), dial_json.keyfile.to_data ());
- Katze.assert_str_equal (json, dial_data.get_next_free_slot (), "Dial 2");
- Katze.assert_str_equal (json, dial_json.get_next_free_slot (), "Dial 2");
-
- try {
- dial_data.save_message ("SpeedDial");
- assert_not_reached ();
- }
- catch (Error error) { /* Error expected: pass */ }
- try {
- dial_data.save_message ("speed_dial-save-rename ");
- assert_not_reached ();
- }
- catch (Error error) { /* Error expected: pass */ }
- try {
- dial_data.save_message ("speed_dial-save-foo 1");
- assert_not_reached ();
- }
- catch (Error error) { /* Error expected: pass */ }
-
- try {
- dial_data.save_message ("speed_dial-save-rename 1 Lorem");
- Katze.assert_str_equal (data, dial_data.keyfile.get_string ("Dial 1", "title"), "Lorem");
- dial_data.save_message ("speed_dial-save-rename 1 Lorem Ipsum Dolomit");
- Katze.assert_str_equal (data, dial_data.keyfile.get_string ("Dial 1", "title"), "Lorem Ipsum Dolomit");
- dial_data.save_message ("speed_dial-save-delete 1");
- Katze.assert_str_equal (data, dial_data.get_next_free_slot (), "Dial 1");
- } catch (Error message_error) {
- GLib.error (message_error.message);
- }
-
- data = get_test_file ("""
- [settings]
- columns=3
- rows=3
-
- [Dial 2]
- uri=http://green.cat
- title=Green cat is green
-
- [Dial 4]
- uri=http://heise.de
- title=IT-News
- """);
- dial_data = new Midori.SpeedDial (data, "");
- FileUtils.remove (data);
- try {
- Katze.assert_str_equal (data, dial_data.get_next_free_slot (), "Dial 1");
- dial_data.save_message ("speed_dial-save-swap 2 4");
- Katze.assert_str_equal (data, dial_data.keyfile.get_string ("Dial 2", "title"), "IT-News");
- } catch (Error message_error) {
- GLib.error (message_error.message);
- }
-}
-
-void main (string[] args) {
- Test.init (ref args);
- Midori.App.setup (ref args, null);
- Midori.Paths.init (Midori.RuntimeMode.NORMAL, null);
- Test.add_func ("/speeddial/load", speeddial_load);
- Test.run ();
-}
-
diff --git a/tests/tab.vala b/tests/tab.vala
deleted file mode 100644
index 37814e28..00000000
--- a/tests/tab.vala
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- Copyright (C) 2012 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.
-*/
-
-void tab_load_title () {
- /*
- var view = new Midori.View.with_title ();
- view.set_uri ("about:blank");
- do {
- }
- while (view.load_status != Midori.LoadStatus.FINISHED);
- Katze.assert_str_equal ("about:blank", "about:blank", view.uri);
- Katze.assert_str_equal ("about:blank", "", view.get_display_uri ()); */
-}
-
-struct TestCaseEllipsize {
- public string uri;
- public string? title;
- public Pango.EllipsizeMode expected_ellipsize;
- public string expected_title;
-}
-
-const TestCaseEllipsize[] titles = {
- { "http://secure.wikimedia.org/wikipedia/en/wiki/Cat",
- "Cat - Wikipedia, the free encyclopedia",
- Pango.EllipsizeMode.END, null },
- { "https://ar.wikipedia.org/wiki/%D9%82%D8%B7",
- "قط - ويكيبيديا، الموسوعة الحرة",
- Pango.EllipsizeMode.END, null },
- { "https://ar.wikipedia.org/wiki/قط",
- "قط - ويكيبيديا، الموسوعة الحرة",
- Pango.EllipsizeMode.END, null },
- { "http://help.duckduckgo.com/customer/portal/articles/352255-wordpress",
- "DuckDuckGo | WordPress",
- Pango.EllipsizeMode.START, null },
- { "file:///home/user",
- "OMG!",
- Pango.EllipsizeMode.START, "/home/user" },
- { "http://paste.foo/0007-Bump-version-to-0.4.7.patch",
- null,
- Pango.EllipsizeMode.START, "0007-Bump-version-to-0.4.7.patch" },
- { "http://translate.google.com/#en/de/cat%0Adog%0Ahorse",
- "Google Translator",
- Pango.EllipsizeMode.END, null }
-};
-
-static void tab_display_title () {
- foreach (var title in titles) {
- string result = Midori.Tab.get_display_title (title.title, title.uri);
-#if HAVE_WIN32
- string expected = title.expected_title ?? title.title;
-#else
- string expected = title.expected_title ?? "‪" + title.title;
-#endif
- if (result != expected)
- error ("%s expected for %s but got %s",
- expected, title.title, result);
- }
-}
-
-static void tab_display_ellipsize () {
- foreach (var title in titles) {
- Pango.EllipsizeMode result = Midori.Tab.get_display_ellipsize (
- Midori.Tab.get_display_title (title.title, title.uri), title.uri);
- if (result != title.expected_ellipsize)
- error ("%s expected for %s/ %s but got %s",
- title.expected_ellipsize.to_string (), title.title, title.uri, result.to_string ());
- }
-}
-
-void tab_special () {
- Midori.Test.grab_max_timeout ();
-
- Midori.Test.log_set_fatal_handler_for_icons ();
- var browser = new Midori.Browser ();
- /* FIXME need proper stock extension mechanism */
- browser.activate_action ("libabout.so=true");
- var settings = new Midori.WebSettings ();
- browser.set ("settings", settings);
- var tab = new Midori.View.with_title ();
- tab.settings = new Midori.WebSettings ();
- tab.settings.set ("enable-plugins", false);
- browser.add_tab (tab);
- var loop = MainContext.default ();
-
- tab.set_uri ("about:blank");
- do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
- assert (tab.is_blank ());
- assert (tab.can_view_source ());
- assert (!tab.can_save ());
-
- tab.set_uri ("about:private");
- do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
- assert (tab.is_blank ());
- assert (tab.can_view_source ());
- assert (tab.special);
- assert (!tab.can_save ());
-
- tab.set_uri ("http://.invalid");
- do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
- assert (!tab.is_blank ());
- assert (tab.can_view_source ());
- assert (tab.special);
- assert (!tab.can_save ());
-
- Midori.Test.release_max_timeout ();
-}
-
-void tab_alias () {
- Midori.Test.log_set_fatal_handler_for_icons ();
- var browser = new Midori.Browser ();
- var settings = new Midori.WebSettings ();
- /* FIXME need proper stock extension mechanism */
- browser.activate_action ("libabout.so=true");
- browser.set ("settings", settings);
- var tab = new Midori.View.with_title ();
- tab.settings = new Midori.WebSettings ();
- tab.settings.set ("enable-plugins", false);
- browser.add_tab (tab);
- var loop = MainContext.default ();
-
- tab.settings.tabhome = "http://.invalid/";
- tab.set_uri ("about:new");
- do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
- // FIXME: Katze.assert_str_equal ("about:new", tab.uri, tab.settings.tabhome);
-#if !HAVE_WEBKIT2
- // Check that this is the real page, not white page with a URL
- assert (!tab.web_view.search_text ("about:", true, false, false));
-#endif
-
- tab.settings.tabhome = "about:blank";
- tab.set_uri ("about:new");
- do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
- // FIXME: Katze.assert_str_equal ("about:new", tab.uri, tab.settings.tabhome);
-#if !HAVE_WEBKIT2
- // Check that this is the real page, not white page with a URL
- assert (!tab.web_view.search_text ("about:", true, false, false));
-#endif
-
- tab.settings.tabhome = "about:search";
- tab.settings.location_entry_search = "http://.invalid/";
- tab.set_uri ("about:new");
- do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
- // FIXME: Katze.assert_str_equal ("about:new", tab.uri, tab.settings.location_entry_search);
-#if !HAVE_WEBKIT2
- // Check that this is the real page, not white page with a URL
- assert (!tab.web_view.search_text ("about:", true, false, false));
-#endif
-
- tab.settings.tabhome = "about:home";
- tab.settings.homepage = "http://.invalid/";
- tab.set_uri ("about:new");
- do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
- // FIXME: Katze.assert_str_equal ("about:new", tab.uri, tab.settings.homepage);
-#if !HAVE_WEBKIT2
- // Check that this is the real page, not white page with a URL
- assert (!tab.web_view.search_text ("about:", true, false, false));
-#endif
-}
-
-void tab_http () {
- Midori.Test.grab_max_timeout ();
-
- Midori.Test.log_set_fatal_handler_for_icons ();
- var browser = new Midori.Browser ();
- var settings = new Midori.WebSettings ();
- browser.set ("settings", settings);
- var tab = new Midori.View.with_title ();
- tab.settings = new Midori.WebSettings ();
- tab.settings.set ("enable-plugins", false);
- browser.add_tab (tab);
- var loop = MainContext.default ();
-
-#if HAVE_LIBSOUP_2_48_0
- var test_server = new Soup.Server ("server-header", null, null);
- try {
- test_server.listen_local (0, Soup.ServerListenOptions.IPV4_ONLY);
- }
- catch (Error error) {
- GLib.error (error.message);
- }
- var port = test_server.get_uris ().data.port;
-#else
- var test_address = new Soup.Address ("127.0.0.1", Soup.ADDRESS_ANY_PORT);
- test_address.resolve_sync (null);
- var test_server = new Soup.Server ("interface", test_address, null);
- test_server.run_async ();
- var port = test_server.get_port ();
-#endif
- string test_url = "http://127.0.0.1:%u".printf (port);
- test_server.add_handler ("/", (server, msg, path, query, client)=>{
- msg.set_status_full (200, "OK");
- msg.response_body.append_take ("<body></body>".data);
- });
-
- var item = tab.get_proxy_item ();
- item.set_meta_integer ("delay", Midori.Delay.UNDELAYED);
- tab.set_uri (test_url);
- do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
- assert (tab.can_view_source ());
- assert (!tab.special);
- assert (tab.can_save ());
-
- tab.set_uri (test_url);
- do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
- assert (!tab.is_blank ());
- assert (tab.can_view_source ());
- assert (!tab.special);
- assert (tab.can_save ());
-
- Midori.Test.release_max_timeout ();
-}
-
-void tab_movement () {
- Midori.Test.log_set_fatal_handler_for_icons ();
- var browser = new Midori.Browser ();
- var settings = new Midori.WebSettings ();
- browser.set ("settings", settings);
- var tab = new Midori.View.with_title ();
- tab.settings = new Midori.WebSettings ();
- for (var i = 0 ; i < 7; i++)
- browser.add_uri ("about:blank");
-
- browser.activate_action ("TabMoveForward");
- browser.activate_action ("TabMoveBackward");
- browser.activate_action ("TabMoveFirst");
- browser.activate_action ("TabMoveLast");
- browser.activate_action ("TabDuplicate");
- browser.activate_action ("TabCloseOther");
-}
-
-void tab_download_dialog () {
- Midori.Test.log_set_fatal_handler_for_icons ();
- var loop = MainContext.default ();
- var browser = new Gtk.Window (Gtk.WindowType.TOPLEVEL);
- var tab = new Midori.View.with_title ();
- browser.add (tab);
- /* An embedded plugin shouldn't cause a download dialog */
- Midori.Test.set_dialog_response (Gtk.ResponseType.DELETE_EVENT);
- bool did_request_download = false;
- tab.download_requested.connect ((download) => {
- did_request_download = true;
- return true;
- });
- /* png2swf -z -j 1 -o data/midori.swf ./icons/16x16/midori.png */
- tab.set_html ("<embed src=\"res:///midori.swf\">");
- do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
- assert (!did_request_download);
-}
-
-void tab_scroll () {
- /* ensure that no scrolls occur due to error iframes */
- var markup = "<style>p{height: 90%}</style><p></p><iframe src=\"http://.invalid/\" height=\"90%\"/>";
- Midori.Test.grab_max_timeout ();
-
- Midori.Test.idle_timeouts ();
- Midori.Test.log_set_fatal_handler_for_icons ();
- var browser = new Midori.Browser ();
- var settings = new Midori.WebSettings ();
- browser.set ("settings", settings);
- var loop = MainContext.default ();
- do { loop.iteration (true); } while (loop.pending ());
- for (var i = 0 ; i < 7; i++) {
- var tab = browser.add_uri ("data:text/html;charset=utf-8;base64," +
- GLib.Base64.encode (markup.data)) as Midori.Tab;
- #if HAVE_GTK3
- var vadj = (tab.web_view as Gtk.Scrollable).get_vadjustment ();
- #else
- var vadj = (tab.web_view.get_parent () as Gtk.ScrolledWindow).get_vadjustment ();
- #endif
- vadj.value_changed.connect ((vadj) => {
- assert(vadj.get_value () == vadj.get_lower ());
- });
- do { loop.iteration (true); } while (tab.progress != 0.0);
- browser.close_tab (tab as Midori.View);
- }
-
- Midori.Test.release_max_timeout ();
-}
-
-void main (string[] args) {
- Test.init (ref args);
- Midori.App.setup (ref args, null);
- Midori.Paths.init (Midori.RuntimeMode.NORMAL, null);
-#if !HAVE_WEBKIT2
- WebKit.get_default_session ().set_data<bool> ("midori-session-initialized", true);
-#endif
- Test.add_func ("/tab/load-title", tab_load_title);
- Test.add_func ("/tab/display-title", tab_display_title);
- Test.add_func ("/tab/ellipsize", tab_display_ellipsize);
- Test.add_func ("/tab/special", tab_special);
- Test.add_func ("/tab/alias", tab_alias);
- Test.add_func ("/tab/http", tab_http);
- Test.add_func ("/tab/movement", tab_movement);
- Test.add_func ("/tab/download", tab_download_dialog);
- Test.add_func ("/tab/scroll", tab_scroll);
- Test.run ();
-}
-
diff --git a/toolbars/midori-findbar.c b/toolbars/midori-findbar.c
deleted file mode 100644
index f42c15fc..00000000
--- a/toolbars/midori-findbar.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- Copyright (C) 2008-2012 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.
-*/
-
-#include "midori-findbar.h"
-
-#include "midori-browser.h"
-#include "midori-platform.h"
-
-#include <glib/gi18n.h>
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtk.h>
-
-#include "config.h"
-
-struct _MidoriFindbar
-{
- GtkToolbar parent_instance;
- GtkWidget* find_text;
- GtkToolItem* previous;
- GtkToolItem* next;
- GtkToolItem* find_case;
- GtkToolItem* find_close;
- gboolean find_typing;
-};
-
-struct _MidoriFindbarClass
-{
- GtkToolbarClass parent_class;
-};
-
-G_DEFINE_TYPE (MidoriFindbar, midori_findbar, GTK_TYPE_TOOLBAR);
-
-static void
-midori_findbar_class_init (MidoriFindbarClass* class)
-{
- /* Nothing to do */
-}
-
-static void
-midori_findbar_set_icon (MidoriFindbar* findbar,
- GtkEntryIconPosition icon_pos,
- const gchar* icon_name)
-{
- if (icon_name != NULL)
- {
- gchar* symbolic_icon_name = g_strconcat (icon_name, "-symbolic", NULL);
- gtk_entry_set_icon_from_gicon (GTK_ENTRY (findbar->find_text), icon_pos,
- g_themed_icon_new_with_default_fallbacks (symbolic_icon_name));
- g_free (symbolic_icon_name);
- }
- else
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (findbar->find_text),
- icon_pos, NULL);
-}
-
-static void
-midori_findbar_done (MidoriFindbar* findbar)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (findbar));
- GtkWidget* view = midori_browser_get_current_tab (browser);
-
- midori_tab_unmark_text_matches (MIDORI_TAB (view));
- gtk_widget_hide (GTK_WIDGET (findbar));
- findbar->find_typing = FALSE;
- gtk_widget_grab_focus (view);
-}
-
-static gboolean
-midori_findbar_find_key_press_event_cb (MidoriFindbar* findbar,
- GdkEventKey* event)
-{
- if (event->keyval == GDK_KEY_Escape)
- {
- midori_findbar_done (findbar);
- return TRUE;
- }
- else if (event->keyval == GDK_KEY_Return
- && (event->state & GDK_SHIFT_MASK))
- {
- midori_findbar_continue (findbar, FALSE);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-midori_findbar_case_sensitive (MidoriFindbar* findbar)
-{
- /* Smart case while typing: foo or fOO lowercase, Foo or FOO uppercase */
- if (findbar->find_typing)
- {
- const gchar* text = gtk_entry_get_text (GTK_ENTRY (findbar->find_text));
- return g_unichar_isupper (g_utf8_get_char (text));
- }
- return gtk_toggle_tool_button_get_active (
- GTK_TOGGLE_TOOL_BUTTON (findbar->find_case));
-}
-
-void
-midori_findbar_continue (MidoriFindbar* findbar,
- gboolean forward)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (findbar));
- const gchar* text;
- gboolean case_sensitive;
- GtkWidget* view;
-
- if (!(view = midori_browser_get_current_tab (browser)))
- return;
-
- text = gtk_entry_get_text (GTK_ENTRY (findbar->find_text));
- case_sensitive = midori_findbar_case_sensitive (findbar);
- midori_tab_find (MIDORI_TAB (view), text, case_sensitive, forward);
-}
-
-/**
- * midori_findbar_get_text:
- * @findbar: #MidoriFindbar
- *
- * Returns: the text typed in the entry
- *
- * Since: 0.4.5
- **/
-const gchar*
-midori_findbar_get_text (MidoriFindbar* findbar)
-{
- g_return_val_if_fail (MIDORI_IS_FINDBAR (findbar), NULL);
-
- return gtk_entry_get_text (GTK_ENTRY (findbar->find_text));
-}
-
-void
-midori_findbar_invoke (MidoriFindbar* findbar,
- const gchar* selected_text)
-{
- if (gtk_widget_get_visible (GTK_WIDGET (findbar)))
- gtk_widget_grab_focus (GTK_WIDGET (findbar->find_text));
- else
- {
- midori_findbar_set_icon (findbar, GTK_ENTRY_ICON_PRIMARY, STOCK_EDIT_FIND);
- gtk_widget_show (GTK_WIDGET (findbar->find_case));
- gtk_widget_show (GTK_WIDGET (findbar->find_close));
- if (selected_text != NULL)
- gtk_entry_set_text (GTK_ENTRY (findbar->find_text), selected_text);
- gtk_widget_show (GTK_WIDGET (findbar));
- gtk_widget_grab_focus (GTK_WIDGET (findbar->find_text));
- }
-}
-
-static void
-midori_findbar_next_activate_cb (GtkWidget* entry,
- MidoriFindbar* findbar)
-{
- midori_findbar_continue (findbar, TRUE);
-}
-
-static void
-midori_findbar_previous_clicked_cb (GtkWidget* entry,
- MidoriFindbar* findbar)
-{
- midori_findbar_continue (findbar, FALSE);
-}
-
-static void
-midori_findbar_button_close_clicked_cb (GtkWidget* widget,
- MidoriFindbar* findbar)
-{
- midori_findbar_done (findbar);
-}
-
-static void
-midori_findbar_preedit_changed_cb (GtkWidget* entry,
- const gchar* preedit,
- MidoriFindbar* findbar)
-{
- MidoriBrowser* browser = midori_browser_get_for_widget (entry);
- GtkWidget* view = midori_browser_get_current_tab (browser);
- midori_tab_unmark_text_matches (MIDORI_TAB (view));
- if (g_utf8_strlen (preedit, -1) >= 1)
- {
- gboolean case_sensitive = midori_findbar_case_sensitive (findbar);
- midori_findbar_set_icon (findbar, GTK_ENTRY_ICON_SECONDARY, STOCK_EDIT_CLEAR);
- midori_tab_find (MIDORI_TAB (view), preedit, case_sensitive, TRUE);
- }
- else
- midori_findbar_set_icon (findbar, GTK_ENTRY_ICON_SECONDARY, NULL);
-}
-
-static void
-midori_findbar_text_changed_cb (GtkWidget* entry,
- MidoriFindbar* findbar)
-{
- const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
- midori_findbar_preedit_changed_cb (entry, text, findbar);
-}
-
-static gboolean
-midori_findbar_text_focus_out_event_cb (GtkWidget* entry,
- GdkEventFocus* event,
- MidoriFindbar* findbar)
-{
- if (findbar->find_typing)
- midori_findbar_done (findbar);
- return FALSE;
-}
-
-static void
-midori_findbar_init (MidoriFindbar* findbar)
-{
- GtkToolItem* toolitem;
-
- gtk_widget_set_name (GTK_WIDGET (findbar), "MidoriFindbar");
- katze_widget_add_class (GTK_WIDGET (findbar), "bottom-toolbar");
- gtk_toolbar_set_icon_size (GTK_TOOLBAR (findbar), GTK_ICON_SIZE_MENU);
- gtk_toolbar_set_style (GTK_TOOLBAR (findbar), GTK_TOOLBAR_BOTH_HORIZ);
- gtk_toolbar_set_show_arrow (GTK_TOOLBAR (findbar), FALSE);
- g_signal_connect (findbar, "key-press-event",
- G_CALLBACK (midori_findbar_find_key_press_event_cb), NULL);
-
- toolitem = gtk_tool_item_new ();
- gtk_container_set_border_width (GTK_CONTAINER (toolitem), 6);
- gtk_container_add (GTK_CONTAINER (toolitem),
- /* i18n: A panel at the bottom, to search text in pages */
- gtk_label_new_with_mnemonic (_("_Inline Find:")));
- gtk_toolbar_insert (GTK_TOOLBAR (findbar), toolitem, -1);
- findbar->find_text = sokoke_search_entry_new (NULL);
- g_signal_connect (findbar->find_text, "activate",
- G_CALLBACK (midori_findbar_next_activate_cb), findbar);
- g_signal_connect (findbar->find_text, "preedit-changed",
- G_CALLBACK (midori_findbar_preedit_changed_cb), findbar);
- g_signal_connect (findbar->find_text, "changed",
- G_CALLBACK (midori_findbar_text_changed_cb), findbar);
- g_signal_connect (findbar->find_text, "focus-out-event",
- G_CALLBACK (midori_findbar_text_focus_out_event_cb), findbar);
- toolitem = gtk_tool_item_new ();
- gtk_container_add (GTK_CONTAINER (toolitem), findbar->find_text);
- gtk_tool_item_set_expand (GTK_TOOL_ITEM (toolitem), TRUE);
- gtk_toolbar_insert (GTK_TOOLBAR (findbar), toolitem, -1);
- findbar->previous = gtk_tool_button_new_from_stock (GTK_STOCK_GO_BACK);
- g_signal_connect (findbar->previous, "clicked",
- G_CALLBACK (midori_findbar_previous_clicked_cb), findbar);
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (findbar->previous), _("Previous"));
- gtk_tool_item_set_is_important (findbar->previous, TRUE);
- gtk_toolbar_insert (GTK_TOOLBAR (findbar), findbar->previous, -1);
- findbar->next = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
- g_signal_connect (findbar->next, "clicked",
- G_CALLBACK (midori_findbar_next_activate_cb), findbar);
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (findbar->next), _("Next"));
- gtk_tool_item_set_is_important (findbar->next, TRUE);
- gtk_toolbar_insert (GTK_TOOLBAR (findbar), findbar->next, -1);
- findbar->find_case = gtk_toggle_tool_button_new_from_stock (GTK_STOCK_SPELL_CHECK);
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (findbar->find_case), _("Match Case"));
- gtk_tool_item_set_is_important (GTK_TOOL_ITEM (findbar->find_case), TRUE);
- gtk_toolbar_insert (GTK_TOOLBAR (findbar), findbar->find_case, -1);
- toolitem = gtk_separator_tool_item_new ();
- gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (toolitem), FALSE);
- gtk_tool_item_set_expand (GTK_TOOL_ITEM (toolitem), TRUE);
- gtk_toolbar_insert (GTK_TOOLBAR (findbar), toolitem, -1);
- findbar->find_close = gtk_tool_button_new_from_stock (GTK_STOCK_CLOSE);
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (findbar->find_close),
- _("Close Findbar"));
- g_signal_connect (findbar->find_close, "clicked",
- G_CALLBACK (midori_findbar_button_close_clicked_cb), findbar);
- gtk_toolbar_insert (GTK_TOOLBAR (findbar), findbar->find_close, -1);
- gtk_container_foreach (GTK_CONTAINER (findbar),
- (GtkCallback)(gtk_widget_show_all), NULL);
-}
-
-void
-midori_findbar_set_can_find (MidoriFindbar* findbar,
- gboolean can_find)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (findbar->next), can_find);
- gtk_widget_set_sensitive (GTK_WIDGET (findbar->previous), can_find);
-}
-
-void
-midori_findbar_search_text (MidoriFindbar* findbar,
- GtkWidget* view,
- gboolean found,
- const gchar* typing)
-{
- const gchar* text;
- gboolean case_sensitive;
-
- midori_findbar_set_icon (findbar, GTK_ENTRY_ICON_PRIMARY, found ? STOCK_EDIT_FIND : STOCK_STOP);
-
- if (typing)
- {
- gint position = -1;
-
- findbar->find_typing = TRUE;
- gtk_widget_hide (GTK_WIDGET (findbar->find_case));
- gtk_widget_hide (GTK_WIDGET (findbar->find_close));
- if (!gtk_widget_get_visible (GTK_WIDGET (findbar)))
- gtk_entry_set_text (GTK_ENTRY (findbar->find_text), "");
- gtk_widget_show (GTK_WIDGET (findbar));
- gtk_widget_grab_focus (findbar->find_text);
- gtk_editable_insert_text (GTK_EDITABLE (findbar->find_text),
- typing, -1, &position);
- gtk_editable_set_position (GTK_EDITABLE (findbar->find_text), -1);
- }
- if (gtk_widget_get_visible (GTK_WIDGET (findbar)) && !typing)
- {
- text = gtk_entry_get_text (GTK_ENTRY (findbar->find_text));
- case_sensitive = midori_findbar_case_sensitive (findbar);
- midori_tab_find (MIDORI_TAB (view), text, case_sensitive, TRUE);
- }
-}
-
-void
-midori_findbar_set_close_button_left (MidoriFindbar* findbar,
- gboolean close_button_left)
-{
- g_object_ref (findbar->find_close);
- gtk_container_remove (GTK_CONTAINER (findbar),
- GTK_WIDGET (findbar->find_close));
- gtk_toolbar_insert (GTK_TOOLBAR (findbar), findbar->find_close,
- close_button_left ? 0 : -1);
- g_object_unref (findbar->find_close);
-}
-
diff --git a/toolbars/midori-findbar.h b/toolbars/midori-findbar.h
deleted file mode 100644
index 9413e2e2..00000000
--- a/toolbars/midori-findbar.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Copyright (C) 2012 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 __MIDORI_FINDBAR_H__
-#define __MIDORI_FINDBAR_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_FINDBAR \
- (midori_findbar_get_type ())
-#define MIDORI_FINDBAR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_FINDBAR, MidoriFindbar))
-#define MIDORI_FINDBAR_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_FINDBAR, MidoriFindbarClass))
-#define MIDORI_IS_FINDBAR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_FINDBAR))
-#define MIDORI_IS_FINDBAR_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_FINDBAR))
-#define MIDORI_FINDBAR_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_FINDBAR, MidoriFindbarClass))
-
-typedef struct _MidoriFindbar MidoriFindbar;
-typedef struct _MidoriFindbarClass MidoriFindbarClass;
-
-GType
-midori_findbar_get_type (void);
-
-void
-midori_findbar_invoke (MidoriFindbar* findbar,
- const gchar* selected_text);
-
-void
-midori_findbar_continue (MidoriFindbar* findbar,
- gboolean forward);
-
-const gchar*
-midori_findbar_get_text (MidoriFindbar* findbar);
-
-void
-midori_findbar_set_can_find (MidoriFindbar* findbar,
- gboolean can_find);
-
-void
-midori_findbar_search_text (MidoriFindbar* findbar,
- GtkWidget* view,
- gboolean found,
- const gchar* typing);
-
-void
-midori_findbar_set_close_button_left (MidoriFindbar* findbar,
- gboolean close_button_left);
-
-G_END_DECLS
-
-#endif /* __MIDORI_FINDBAR_H__ */
diff --git a/tools/check-style b/tools/check-style
deleted file mode 100755
index e40116ae..00000000
--- a/tools/check-style
+++ /dev/null
@@ -1,173 +0,0 @@
-#! /usr/bin/env python
-
-# Copyright (C) 2010 Christian Dywan <christian@twotoasts.de>
-# Copyright (C) 2010 Arno Renevier <arno@renevier.net>
-#
-# 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.
-#
-# check-style: Verify C source code according to coding style.
-
-import glob, re, string, subprocess, sys, os
-
-if len (sys.argv) < 2:
- name = os.path.basename (sys.argv[0])
- print ('Usage:\n ' + name + ' FILENAMES\n'
- ' Pass "-" to read stdin, eg. "cat my-feature.diff | ' + name + ' -"\n'
- ' Pass "." to mean "git diff ^HEAD | ' + name + ' -"')
- sys.exit (1)
-
-# Coding style violations
-violations = [
- ['.{101}', 'Line longer than 100 columns'],
- ['^[ ]{1,3}[^ ]+', 'Indentation is less than 4 spaces'],
- # FIXME: Don't match empty strings
- # FIXME: Don't match indented function arguments
- # ['^(?!(([ ]{4})*[^ ]+))', 'Indentation is not 4 spaces'],
- ['.*[ ]+$', 'Trailing whitespace'],
- [r"\t+", 'Tabs instead of spaces'],
- ["[^0-9],[^ ][^0-9]", 'No space after comma'],
- # ['(([A-Z][a-z]+)+)\*?[ ][a-z]{2,}', 'Good variable name'],
- # ['(g?char|g(boolean|pointer))\*?[ ][a-z]{2,}', 'Good variable name'],
- # ['(g?int|guint)[ ][a-z]+', 'Good iterator name'],
- # ['(struct)[ ]+[_]?([A-Z][a-z]+)+', 'Good type name'],
- ['^\s*\w+(?<!\\breturn)\s+\*\s*\w*\s*[;,]', 'Space between type and asterisk'],
- ["(\w[+|-|*|/|<|>|=]{1,2}\w)", 'No space around operators'],
- ["\/\*[^ *\n]", 'No space after open comment'],
- ['[^ *]\*\/', 'No space before close comment'],
- ['\)\{', 'No space between ) and {'],
- [';[^ \s]', 'No space or newline after semicolon'],
- # ['(if)( \([^ ].*[^ ]\))$', 'Good if style'],
- ['^#\s+(if(n?def)?|define|else|elif)[ ].*$', 'Space between # and cpp'],
- [r'^\s*\*\w+(\+\+|--);', 'Invalid increment, use (*i)++ or *i += 1'],
- ['[^a-z](asctime|ctime|getgrgid|getprgnam|getlogin \
- |getpwnam|getpwuid|gmtime|localtime \
- |rand|readdir|strtok|ttyname)[^a-z]', 'Not thread-safe posix, use _r variant'],
- ['while.*g_list_nth', 'Use g_list_next() instead of g_list_nth'],
- ['[^a-z]g_new.*1[^0-9]', 'Use g_slice_new() instead of g_new()'],
-]
-# No validation for strings, comments, includes
-omissions = [
- [r'["]{1}.*["]', 'STRING'],
- ["'\\\?.'", 'CHAR'],
- ["^\s*\/\*.*\*\/\s*$", 'COMMENT'],
- ['#include <.*>', 'INCLUDE'],
-]
-
-# Output format
-fmt = '%s - %d: %s'
-
-# Pre-compile expressions
-for violation in violations:
- violation[0] = re.compile (violation[0])
-for omission in omissions:
- omission[0] = re.compile (omission[0])
-
-for filename_or_glob in sys.argv[1:]:
- if filename_or_glob == '-':
- handles = [sys.stdin]
- else:
- handles = []
- for filename in glob.glob (filename_or_glob):
- if os.path.isdir (filename):
- gitdiff = subprocess.Popen (['git', 'diff', '^HEAD',
- '--relative', filename], stdout=subprocess.PIPE)
- handles.append (gitdiff.stdout)
- else:
- handles.append (open (filename))
- if not handles:
- print (filename_or_glob + ' not found')
- sys.exit (1)
-
- for handle in handles:
- previous = ''
- i = 0
- previous_i = 0
- previous_violation = ''
- mode = ''
- filename = handle.name
- comment = False
- curly = []
-
- for line in handle:
- line = line[:-1]
- i += 1
-
- # Parse diff, only validate modified lines
- if i == 1 and 'diff' in line:
- mode = 'diff'
- if mode == 'diff':
- if line[:3] == '+++':
- filename = line[6:]
- comment = False
- curly = []
- previous_violation = ''
- continue
- if line[:2] == '@@':
- i = int (line.split (' ')[2].split (',')[0][1:]) - 1
- curly = []
- if line[0] == '-':
- i = i -1
- if line[0] != '+':
- previous_violation = ''
- continue
- line = line[1:]
-
- # Spurious blank lines
- if previous == line == '':
- print (fmt % (filename, i, 'Spurious blank line'))
- previous = line
- previous_violation = ''
- continue
- previous = line
-
- # Skip multi-line comment blocks
- if '/*' in line and not '*/' in line:
- comment = True
- if comment:
- if '*/' in line and not '/*' in line:
- comment = False
- previous_violation = ''
- continue
-
- cleaned = line
- for omission in omissions:
- cleaned = omission[0].sub (omission[1], cleaned)
-
- # Validate curly bracket indentation
- if '{' in cleaned and not '}' in cleaned:
- curly.append ((cleaned.index ('{'), cleaned))
- if '}' in cleaned and not '{' in cleaned and not '},' in cleaned:
- if len (curly) == 0 or curly[-1][0] != cleaned.index ('}'):
- print (fmt % (filename, i, 'Misindented curly bracket'))
- print (curly[-1][1])
- print (line)
- curly.pop()
- previous_violation = ''
- continue
- curly.pop()
-
- # Validate preprocessor indentation
- # FIXME: Don't warn if the *following* line is a curly
- cpp = cleaned.find ('#if')
- if cpp != -1:
- if len (curly) != 0 and cpp != curly[-1][0] + 4:
- print (fmt % (filename, i, 'Misindented preprocessor #if'))
- print (curly[-1][1])
- print (line)
-
- violated = False
- for violation in violations:
- if violation[0].search (cleaned):
- violated = True
- if previous_violation != '' and violation == previous_violation:
- continue
- previous_violation = violation
- print (fmt % (filename, i, violation[1]))
- if violated:
- print (line)
-
diff --git a/tools/midori-dev b/tools/midori-dev
deleted file mode 100755
index 6da645d5..00000000
--- a/tools/midori-dev
+++ /dev/null
@@ -1,87 +0,0 @@
-#! /bin/bash
-
-# Copyright (C) 2010 David Mohr <david@mcbf.net>
-#
-# 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.
-#
-# midori-dev: Run, update or debug Midori from bzr.
-
-# Adjust this to where you have your bzr sources
-DEVDIR=~/src/xfce/midori/bzr
-
-# Location of stdout and stderr from running midori
-LOG=~/.midori.out
-
-#-----------------------------------------------------------------------------
-
-BIN=_build/default/midori/midori
-BASENAME=`basename $0`
-
-ulimit -c unlimited
-
-cd $DEVDIR
-
-CMD=`echo $BASENAME | sed 's/^midori-//'`
-if [ -z $CMD ]; then
- echo "I'm confused, basename $BASENAME is not in the midori-<FOO> format"
- exit 1
-fi
-
-if [ $CMD == "dev" ]; then
- # No command was given through a symlink,
- # so check the first parameter instead
- CMD=$1
- shift
-fi
-
-case $CMD in
- bzr)
- exec _build/midori/midori "$@" >& $LOG
- ;;
- gdb)
- gdb $BIN core
- ;;
- save)
- NAME=`date '+%Y%m%d-%H%M%S'`
- DESC="$1"
- CAT="$2"
- if [ -z "$1" ]; then
- echo "It is recommended to save a description of the cause of the crash"
- echo "Enter one line now, or press <ENTER> to continue"
- read DESC
- fi
- CRASH=crash/$NAME
-
- echo "Saving crash info..."
- mkdir -p $CRASH
- echo $DESC > $CRASH/description
- echo " (gdb will take some time)"
- gdb $BIN core --batch -ex 'thread apply all bt' >& $CRASH/backtrace
- echo " Backtrace is in $DEVDIR/$CRASH/backtrace."
- cp $BIN $CRASH
- cp core $CRASH
- cp $LOG $CRASH/output
-
- if [ -n "$CAT" ]; then
- cat $CRASH/backtrace
- fi
- ;;
- pull)
- bzr pull
- ;;
- *)
- cat << EOM
-Usage: Create a symlink midori-<CMD>, or run 'midori-dev <CMD>'
-where CMD can be
- bzr: run the current bzr version
- gdb: open the last core dump in gdb
- save: saves relevant information about the last crash
- so that it can be analyzed later
- pull: pulls the latest updates from the repository
-EOM
-esac
diff --git a/tools/release b/tools/release
deleted file mode 100755
index 30e99b73..00000000
--- a/tools/release
+++ /dev/null
@@ -1,57 +0,0 @@
-#! /bin/bash
-
-# Copyright (C) 2013-2014 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.
-
-OLDVER=$(grep -r --color=no '^set(VERSION' CMakeLists.txt | sed -r "s@.+ ([0-9.]+)\)@\1@")
-NEWVER="$2"
-test -z "$NEWVER" && NEWVER=$(python -c "print('0.'+str(float('$OLDVER'[2:])+.1))")
-if [ "x$1" = "xbefore" ]; then
- echo Bumping from $OLDVER to $NEWVER
- sed -i "s@$OLDVER@$NEWVER@g" CMakeLists.txt win32/makedist/midori.nsi
- mv ChangeLog ChangeLog.old || exit 1
- echo This file is licensed under the terms of the expat license, see the file EXPAT. > ChangeLog
- echo >> ChangeLog
- echo v$NEWVER >> ChangeLog
- bzr log --line -rtag:$OLDVER.. \
- | sed -r 's@.+20[0-9][0-9]-[0-9]+-[0-9]+ @ @' \
- | sed 's@\[merge\] @@' \
- | grep -v -E 'l10n|Revert |makedist|tools(/release)?: |nsi|translation|Bump version to|Merge lp:midori|POTFILES.in' \
- >> ChangeLog
- tail -n+2 ChangeLog.old >> ChangeLog
- rm ChangeLog.old
- curl http://wiki.xfce.org/_export/raw/midori/contribute | \
- sed -r 's@\[\[([^|]+)\|([^]]+)\]\]@\1 \2@g' | \
- sed -r 's@<code( bash|)>|</code>@@g' > HACKING.new
- test -s HACKING.new && mv HACKING{.new,} || rm HACKING.new
- curl http://wiki.xfce.org/_export/xhtml/midori/faq | \
- sed 's@This is a list of frequently asked questions@This is <a href="http://wiki.xfce.org/midori/faq">a snapshot of the online FAQ</a>@g' | \
- sed 's@<link rel="style.*>@<link rel="stylesheet" href="faq.css" />@g' > data/faq.html.new
- test -s data/faq.html.new && mv data/faq.html{.new,} || rm data/faq.html.new
- echo -n bzr commit -p -m "'Bump version to $NEWVER'"
- case $SHELL in
- *fish*)
- echo -n '; and ' ;;
- *)
- echo -n ' && ' ;;
- esac
- echo bzr tag $NEWVER
-elif [ "x$1" = "xafter" ]; then
- echo Press RETURN to download tarball now; read yes
- wget http://bazaar.launchpad.net/~midori/midori/trunk/tarball
- echo Press RETURN to update Launchpad bugs now; read yes
- if [ -n $(which bugreleaser 1>/dev/null) ]; then
- bugreleaser midori
- else
- echo bzr branch lp:~mgiuca/+junk/launchpad-tools
- fi
-else
- echo 'Usage: ['$(basename $0)']' 'before|after' [NEW VERSION]
- exit 1
-fi
diff --git a/tools/sanitize_bzr.sh b/tools/sanitize_bzr.sh
deleted file mode 100755
index 60679e51..00000000
--- a/tools/sanitize_bzr.sh
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/bash
-# Copyright (C) 2015 Paweł Forysiuk <tuxator@o2.pl>
-#
-# 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.
-
-BZR_PLUGINS_DIR=${HOME}/.bazaar/plugins/
-if [ ! -d $BZR_PLUGINS_DIR ]; then
- mkdir -p $BZR_PLUGINS_DIR
-fi
- cd $BZR_PLUGINS_DIR
-
- echo
- echo "Fetching pager plugin..."
- bzr branch lp:bzr-pager pager
-
- echo
- echo "Fetching bisect plugin..."
- bzr branch lp:bzr-bisect bisect
-
-# http://blog.mariadb.org/bzr-hacks-and-tricks/
- echo
- echo "Fetching diffoptions plugin..."
- mkdir diffoptions
- cat >> diffoptions/__init__.py << _EOF
- #!/usr/bin/env python
-
-"""global bzr diff options"""
-
-version_info = (0, 0, 1)
-
-from bzrlib import branch
-from bzrlib import diff
-from bzrlib import errors
-
-def get_differ(tree):
- try:
- root = tree.id2path(tree.get_root_id())
- br = branch.Branch.open_containing(root)[0]
- diff_options = br.get_config().get_user_option('diff_options')
- if diff_options is not None:
- opts = diff_options.split()
- def diff_file(olab, olines, nlab, nlines, to_file, path_encoding=None):
- diff.external_diff(olab, olines, nlab, nlines, to_file, opts)
- return diff_file
- except (errors.NoSuchId, NotImplementedError):
- pass
- return None
-
-old_init = diff.DiffText.__init__
-
-def new_init(self, old_tree, new_tree, to_file, path_encoding='utf-8',
- old_label='', new_label='', differ=diff.internal_diff):
-
- if differ == diff.internal_diff:
- differ = get_differ(old_tree) or get_differ(new_tree) or diff.internal_diff
-
- old_init(self, old_tree, new_tree, to_file, path_encoding,
- old_label, new_label, differ)
-
-diff.DiffText.__init__ = new_init
-_EOF
-
-cat <<_EOF
-
-Add this to your ~/.bazaar/bazaar.conf
-
-[DEFAULT]
-diff_options='-u -F ^[[:alpha:]$_].*[^:]$'
-
-_EOF
diff --git a/tools/screenshot b/tools/screenshot
deleted file mode 100755
index 110b9234..00000000
--- a/tools/screenshot
+++ /dev/null
@@ -1,83 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2013 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.
-
-xvfbonce() {
- xvfb-run --server-args='-fbdir /tmp -screen 0 1024x768x16' \
- env LANGUAGE= UBUNTU_MENUPROXY= MOZ_PLUGIN_PATH=/ SCREENCHILD=42 $0 $1 "$2" 2>&1 | grep -v RANDR
-}
-
-if test "$SCREENCHILD" = "42"; then
- (xfwm4 || metacity) 2>&1 | grep -v XRandr | grep -v 'Fatal IO error' &
- sleep 2; kill -0 $! || exit $?
- if test "$1" = "midori"; then
- echo Processing case $2
- CFG=/tmp/midori-scrn/$2
- PNG=$CFG.png
- test -d $CFG && rm -R $CFG; mkdir -p $CFG
- mkdir -p $CFG/midori
- mkdir -p $CFG/gtk-3.0
- echo '[Settings]' > $CFG/gtk-3.0/settings.ini
- test -n "$GTK_THEME" && echo "gtk-theme-name=$GTK_THEME" >> $CFG/gtk-3.0/settings.ini
- test -n "$ICON_THEME" && echo "gtk-icon-theme-name=$ICON_THEME" >> $CFG/gtk-3.0/settings.ini
- export XDG_CONFIG_HOME; XDG_CONFIG_HOME=$CFG
- echo '[settings]' > $CFG/midori/config
- echo 'last-window-state=MIDORI_WINDOW_MAXIMIZED' >> $CFG/midori/config
- EXE="-e toolbar-style=MIDORI_TOOLBAR_ICONS"
- URLS="http://.invalid about:version http://en.wikipedia.org/wiki/Cat"
- if test "$2" = "1"; then
- EXE="$EXE -e BookmarkAdd"
- elif test "$2" = "2"; then
- EXE="$EXE $URLS -e Panel -e libtab-panel.so=true"
- echo 'last-panel-page=3' >> $CFG/config
- elif test "$2" = "3"; then
- EXE="$EXE -e Preferences"
- elif test "$2" = "4"; then
- EXE="$EXE -e ClearPrivateData"
- elif test "$2" = "5"; then
- EXE="$EXE -e Find"
- elif test "$2" = "6"; then
- EXE="$EXE -e ManageSearchEngines"
- fi
- _build/default/midori/midori $EXE 2>&1 \
- | grep -v 'Theme parsing error' \
- | grep -E -v '\[[0-9]{3}:[0-9]{3}\]' \
- | grep -v 'Fatal IO error' \
- | uniq &
- elif test "$1" = "custom"; then
- if test "$2" = ""; then
- echo 'Argument required'
- exit 1
- fi
- PNG=/tmp/screenshot-custom.png
- $2 &
- else
- echo Unknown scenario "$2"
- exit 1
- fi
- sleep 2; kill -0 $! || exit $?
- sleep 14
- # test ! -f /tmp/Xvfb_screen0 && echo Xvfb produced no memory image && exit 1
- # convert /tmp/Xvfb_screen0 $PNG
- WINDOW=$(xprop -root | grep --color=never '_NET_ACTIVE_WINDOW(WINDOW)' | sed 's@_NET_ACTIVE_WINDOW(WINDOW): window id # @@g')
- import -frame -window "$WINDOW" $PNG || exit 1
- echo Screenshot $PNG saved
- exit 0
-elif test "$1" = "midori"; then
- for i in 1 2 3 4 5 6; do
- xvfbonce $1 $i
- done
-elif test "$1" = "custom"; then
- xvfbonce $1 "$2"
-else
- echo Usage:
- echo " $0 midori"
- echo " $0 custom 'commandline --with -a rguments'"
-fi
-
diff --git a/ui/about.ui b/ui/about.ui
new file mode 100644
index 00000000..34dc30b4
--- /dev/null
+++ b/ui/about.ui
@@ -0,0 +1,9 @@
+<interface>
+ <template class="MidoriAbout" parent="GtkAboutDialog">
+ <property name="modal">yes</property>
+ <property name="logo-icon-name">midori</property>
+ <property name="copyright">2007-2018 Christian Dywan</property>
+ <property name="license-type">GTK_LICENSE_LGPL_2_1</property>
+ <property name="comments" translatable="yes">A lightweight web browser.</property>
+ </template>
+</interface>
diff --git a/ui/browser.ui b/ui/browser.ui
new file mode 100644
index 00000000..9c5eca5e
--- /dev/null
+++ b/ui/browser.ui
@@ -0,0 +1,218 @@
+<interface>
+ <!-- Work-around non-expanding allocation in headerbar with GTK+ 3.18.9 -->
+ <object class="GtkSizeGroup">
+ <property name="mode">vertical</property>
+ <widgets>
+ <widget name="scrolled"/>
+ <widget name="profile"/>
+ </widgets>
+ </object>
+ <object class="GtkSizeGroup">
+ <property name="mode">horizontal</property>
+ <widgets>
+ <widget name="scrolled"/>
+ <widget name="urlbar"/>
+ </widgets>
+ </object>
+ <template class="MidoriBrowser" parent="GtkApplicationWindow">
+ <property name="default-width">800</property>
+ <property name="default-height">600</property>
+ <child type="titlebar">
+ <object class="GtkHeaderBar">
+ <property name="show-close-button">yes</property>
+ <property name="visible">yes</property>
+ <child type="title">
+ <object class="GtkScrolledWindow" id="scrolled">
+ <property name="hscrollbar-policy">external</property>
+ <property name="vscrollbar-policy">never</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="MidoriSwitcher">
+ <property name="orientation">horizontal</property>
+ <property name="stack">tabs</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="MidoriDownloadButton" id="downloads">
+ <property name="valign">center</property>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkMenuButton" id="profile">
+ <property name="focus-on-click">no</property>
+ <property name="valign">center</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkImage" id="profile_icon">
+ <property name="icon-name">user-info-symbolic</property>
+ <property name="use-fallback">yes</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="focus-on-click">no</property>
+ <property name="valign">center</property>
+ <property name="action-name">win.tab-new</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">tab-new-symbolic</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkActionBar" id="navigationbar">
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="visible">yes</property>
+ <style>
+ <class name="linked"/>
+ </style>
+ <child>
+ <object class="GtkButton" id="go_back">
+ <property name="focus-on-click">no</property>
+ <property name="action-name">win.go-back</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">go-previous-symbolic</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="go_forward">
+ <property name="focus-on-click">no</property>
+ <property name="action-name">win.go-forward</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">go-next-symbolic</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="reload">
+ <property name="focus-on-click">no</property>
+ <property name="action-name">win.tab-reload</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">view-refresh-symbolic</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="stop_loading">
+ <property name="focus-on-click">no</property>
+ <property name="action-name">win.tab-stop-loading</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">process-stop-symbolic</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="center">
+ <object class="MidoriUrlbar" id="urlbar">
+ <!-- expand has no effect, int.MAX doesn't work -->
+ <property name="max-width-chars">300</property>
+ <property name="margin-left">16</property>
+ <property name="margin-right">16</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuButton" id="menubutton">
+ <property name="valign">center</property>
+ <property name="direction">none</property>
+ <property name="visible">yes</property>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="MidoriNetworkCheck">
+ </object>
+ </child>
+ <child>
+ <object class="GtkOverlay" id="overlay">
+ <property name="hexpand">yes</property>
+ <property name="vexpand">yes</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkStack" id="tabs">
+ <property name="transition-type">over-left-right</property>
+ <property name="visible">yes</property>
+ <property name="hexpand">yes</property>
+ <property name="vexpand">yes</property>
+ </object>
+ </child>
+ <child type="overlay">
+ <object class="GtkSearchBar" id="search">
+ <property name="halign">end</property>
+ <property name="valign">start</property>
+ <property name="margin">0</property>
+ <style>
+ <class name="background"/>
+ </style>
+ <child>
+ <object class="GtkSearchEntry" id="search_entry">
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="overlay">
+ <object class="MidoriStatusbar" id="statusbar">
+ <property name="halign">start</property>
+ <property name="valign">end</property>
+ <property name="margin">0</property>
+ <style>
+ <class name="background"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/ui/clear-private-data.ui b/ui/clear-private-data.ui
new file mode 100644
index 00000000..3afc221e
--- /dev/null
+++ b/ui/clear-private-data.ui
@@ -0,0 +1,101 @@
+<interface>
+ <template class="MidoriClearPrivateData" parent="GtkDialog">
+ <property name="modal">yes</property>
+ <child type="action">
+ <object class="GtkButton" id="abort">
+ <property name="label" translatable="yes">_Cancel</property>
+ <property name="use-underline">yes</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child type="action">
+ <object class="GtkButton" id="proceed">
+ <property name="label" translatable="yes">Clear Private _Data</property>
+ <property name="can-default">yes</property>
+ <property name="use-underline">yes</property>
+ <property name="visible">yes</property>
+ <style>
+ <class name="destructive-action"/>
+ </style>
+ </object>
+ </child>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <property name="margin">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="label" translatable="yes">Lorem ipsum dolor sit amet</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="spacing">4</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkLabel" id="timerange_label">
+ <property name="label" translatable="yes">_Time range to clear</property>
+ <property name="use-underline">yes</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="timerange">
+ <property name="active-id">last-hour</property>
+ <property name="visible">yes</property>
+ <items>
+ <item id="last-hour" translatable="yes">The last hour</item>
+ <item id="today" translatable="yes">Today</item>
+ </items>
+ <accessibility>
+ <relation type="labelled-by" target="timerange_label"/>
+ </accessibility>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="visible">yes</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkCheckButton" id="history">
+ <property name="label" translatable="yes">_History</property>
+ <property name="use-underline">yes</property>
+ <property name="visible">yes</property>
+ <property name="sensitive">no</property>
+ <property name="active">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="websitedata">
+ <property name="label" translatable="yes">Cookies and Website data</property>
+ <property name="use-underline">yes</property>
+ <property name="visible">yes</property>
+ <property name="sensitive">no</property>
+ <property name="active">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="cache">
+ <property name="label" translatable="yes">Web Cache</property>
+ <property name="use-underline">yes</property>
+ <property name="visible">yes</property>
+ <property name="sensitive">no</property>
+ <property name="active">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="cancel">abort</action-widget>
+ <action-widget response="ok" default="true">proceed</action-widget>
+ </action-widgets>
+ </template>
+</interface>
diff --git a/ui/download-button.ui b/ui/download-button.ui
new file mode 100644
index 00000000..af45b7e2
--- /dev/null
+++ b/ui/download-button.ui
@@ -0,0 +1,55 @@
+<interface>
+ <object class="GtkPopover" id="popover">
+ <property name="modal">yes</property>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <property name="margin">12</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="label" translatable="yes">Downloads</property>
+ <property name="hexpand">yes</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="focus-on-click">no</property>
+ <property name="relief">half</property>
+ <property name="label" translatable="yes">_Clear</property>
+ <property name="use-underline">yes</property>
+ <property name="visible">yes</property>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkListBox" id="listbox">
+ <property name="selection-mode">none</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <template class="MidoriDownloadButton" parent="GtkButton">
+ <property name="focus-on-click">no</property>
+ <property name="action-name">win.show-downloads</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">browser-download-symbolic</property>
+ <property name="use-fallback">yes</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/ui/download-row.ui b/ui/download-row.ui
new file mode 100644
index 00000000..5bb04876
--- /dev/null
+++ b/ui/download-row.ui
@@ -0,0 +1,69 @@
+<interface>
+ <template class="MidoriDownloadRow" parent="GtkListBoxRow">
+ <property name="can-focus">no</property>
+ <property name="activatable">no</property>
+ <property name="visible">yes</property>
+ <style>
+ <class name="background"/>
+ </style>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="spacing">4</property>
+ <property name="margin">4</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkImage" id="icon">
+ <!-- menu -->
+ <property name="icon-size">1</property>
+ <property name="valign">center</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="spacing">4</property>
+ <property name="margin">4</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkLabel" id="filename">
+ <property name="ellipsize">end</property>
+ <property name="xalign">0.0</property>
+ <property name="hexpand">yes</property>
+ <!-- As per docs, when ellipsized and expanded max width is the minimum -->
+ <property name="max-width-chars">1</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkProgressBar" id="progress">
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="status">
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel">
+ <property name="focus-on-click">no</property>
+ <property name="relief">none</property>
+ <property name="valign">center</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">cancel-symbolic</property>
+ <property name="use-fallback">yes</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/ui/menus.ui b/ui/menus.ui
new file mode 100644
index 00000000..a8937a57
--- /dev/null
+++ b/ui/menus.ui
@@ -0,0 +1,56 @@
+<interface>
+ <menu id="app-menu">
+ <section>
+ <item>
+ <attribute name="action">app.win-new</attribute>
+ <attribute name="target"></attribute>
+ <attribute name="label" translatable="yes">New _Window</attribute>
+ <attribute name="accel">&lt;Primary&gt;n</attribute>
+ </item>
+ <item>
+ <attribute name="action">app.win-incognito-new</attribute>
+ <attribute name="label" translatable="yes">New P_rivate Browsing Window</attribute>
+ <attribute name="accel">&lt;Primary&gt;&lt;Shift&gt;p</attribute>
+ </item>
+ <item>
+ <attribute name="action">win.show-help-overlay</attribute>
+ <attribute name="hidden-when">action-disabled</attribute>
+ <attribute name="label" translatable="yes">_Shortcuts</attribute>
+ <attribute name="accel">&lt;Primary&gt;&lt;Alt&gt;s</attribute>
+ </item>
+ <item>
+ <attribute name="action">win.about</attribute>
+ <attribute name="label" translatable="yes">_About</attribute>
+ </item>
+ <item>
+ <attribute name="action">app.quit</attribute>
+ <attribute name="label" translatable="yes">_Quit</attribute>
+ <attribute name="accel">&lt;Primary&gt;q</attribute>
+ </item>
+ </section>
+ </menu>
+ <menu id="profile-menu">
+ <section>
+ <item>
+ <attribute name="action">win.clear-private-data</attribute>
+ <attribute name="hidden-when">action-disabled</attribute>
+ <attribute name="label" translatable="yes">_Clear Private Data</attribute>
+ <attribute name="accel">&lt;Primary&gt;&lt;Shift&gt;Delete</attribute>
+ </item>
+ </section>
+ </menu>
+ <menu id="browser-menu">
+ <section>
+ <item>
+ <attribute name="action">win.find</attribute>
+ <attribute name="label" translatable="yes">_Find in Page</attribute>
+ <attribute name="accel">&lt;Primary&gt;f</attribute>
+ </item>
+ <item>
+ <attribute name="action">win.print</attribute>
+ <attribute name="label" translatable="yes">_Print...</attribute>
+ <attribute name="accel">&lt;Primary&gt;p</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/ui/network-check.ui b/ui/network-check.ui
new file mode 100644
index 00000000..6420b696
--- /dev/null
+++ b/ui/network-check.ui
@@ -0,0 +1,22 @@
+<interface>
+ <template class="MidoriNetworkCheck" parent="GtkActionBar">
+ <child type="center">
+ <object class="GtkLabel">
+ <property name="label" translatable="yes">The network requires a login to access the Internet.</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="login">
+ <property name="focus-on-click">no</property>
+ <property name="label" translatable="yes">_Login</property>
+ <property name="use-underline">yes</property>
+ <property name="visible">yes</property>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </template>
+</interface>
+
diff --git a/ui/shortcuts.ui b/ui/shortcuts.ui
new file mode 100644
index 00000000..99a2e9b1
--- /dev/null
+++ b/ui/shortcuts.ui
@@ -0,0 +1,167 @@
+<interface>
+ <object class="GtkShortcutsWindow" id="help_overlay">
+ <property name="modal">no</property>
+ <child>
+ <object class="GtkShortcutsSection">
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="title" translatable="yes">Tabs</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;t</property>
+ <property name="title" translatable="yes">New Tab</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;Tab</property>
+ <property name="title" translatable="yes">Switch to Next Tab</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;&lt;Shift&gt;Tab</property>
+ <property name="title" translatable="yes">Switch to Previous Tab</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;w</property>
+ <property name="title" translatable="yes">Close Tab</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;&lt;Shift&gt;t</property>
+ <property name="title" translatable="yes">Re-open closed Tab</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="title" translatable="yes">Browsing</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;r</property>
+ <property name="title" translatable="yes">Reload current page</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">Escape</property>
+ <property name="title" translatable="yes">Stop loading</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;l</property>
+ <property name="title" translatable="yes">Focus the Urlbar</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Alt&gt;Left</property>
+ <property name="title" translatable="yes">Go back to previous page</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Alt&gt;Right</property>
+ <property name="title" translatable="yes">Go to next page</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="title" translatable="yes">Windows</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;n</property>
+ <property name="title" translatable="yes">New Window</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;&lt;Shift&gt;w</property>
+ <property name="title" translatable="yes">Close Window</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;q</property>
+ <property name="title" translatable="yes">Quit</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="title" translatable="yes">Page</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;plus</property>
+ <property name="title" translatable="yes">Zoom in</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;minus</property>
+ <property name="title" translatable="yes">Zoom out</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;0</property>
+ <property name="title" translatable="yes">Reset zoom level</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;f</property>
+ <property name="title" translatable="yes">Find in Page</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;u</property>
+ <property name="title" translatable="yes">View page source</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="accelerator">&lt;Primary&gt;&lt;Shift;&gt;i</property>
+ <property name="title" translatable="yes">Toggle developer tools</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/ui/suggestion-row.ui b/ui/suggestion-row.ui
new file mode 100644
index 00000000..ce1b4dcb
--- /dev/null
+++ b/ui/suggestion-row.ui
@@ -0,0 +1,46 @@
+<interface>
+ <template class="MidoriSuggestionRow" parent="GtkListBoxRow">
+ <property name="can-focus">no</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkBox" id="box">
+ <property name="orientation">horizontal</property>
+ <property name="spacing">4</property>
+ <property name="margin">4</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="MidoriFavicon" id="icon">
+ <!-- menu -->
+ <property name="icon-size">1</property>
+ <property name="valign">center</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="title">
+ <property name="use-markup">yes</property>
+ <property name="ellipsize">end</property>
+ <property name="xalign">0.0</property>
+ <property name="hexpand">yes</property>
+ <!-- As per docs, when ellipsized and expanded max width is the minimum -->
+ <property name="max-width-chars">1</property>
+ <!-- Ensure space is claimed even by an empty title -->
+ <property name="width-chars">3</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="uri">
+ <property name="use-markup">yes</property>
+ <property name="ellipsize">end</property>
+ <property name="xalign">0.0</property>
+ <property name="hexpand">yes</property>
+ <!-- As per docs, when ellipsized and expanded max width is the minimum -->
+ <property name="max-width-chars">1</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/ui/tab.ui b/ui/tab.ui
new file mode 100644
index 00000000..dcc3d9ea
--- /dev/null
+++ b/ui/tab.ui
@@ -0,0 +1,32 @@
+<interface>
+ <object class="GtkPopover" id="popover">
+ <property name="modal">yes</property>
+ <property name="position">bottom</property>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="spacing">4</property>
+ <property name="margin">4</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkLabel" id="message">
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry">
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="confirm">
+ <property name="focus-on-click">no</property>
+ <property name="label" translatable="yes">_Confirm</property>
+ <property name="use-underline">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <template class="MidoriTab" parent="WebKitWebView">
+ </template>
+</interface>
diff --git a/ui/tally.ui b/ui/tally.ui
new file mode 100644
index 00000000..a0ab6ed2
--- /dev/null
+++ b/ui/tally.ui
@@ -0,0 +1,52 @@
+<interface>
+ <template class="MidoriTally" parent="GtkEventBox">
+ <style>
+ <class name="tab"/>
+ </style>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="MidoriFavicon" id="favicon">
+ <!-- menu -->
+ <property name="icon-size">1</property>
+ <property name="visible">yes</property>
+ <property name="margin-right">4</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSpinner" id="spinner">
+ <property name="active">yes</property>
+ <property name="margin-right">4</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="caption">
+ <property name="ellipsize">end</property>
+ <!-- As per docs, when ellipsized and expanded max width is the minimum -->
+ <property name="width-chars">8</property>
+ <property name="max-width-chars">500</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="close">
+ <property name="relief">none</property>
+ <property name="focus-on-click">no</property>
+ <property name="valign">center</property>
+ <property name="visible">yes</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">window-close-symbolic</property>
+ <!-- menu -->
+ <property name="icon-size">1</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/ui/urlbar.ui b/ui/urlbar.ui
new file mode 100644
index 00000000..9a93fb31
--- /dev/null
+++ b/ui/urlbar.ui
@@ -0,0 +1,25 @@
+<interface>
+ <object class="GtkPopover" id="suggestions">
+ <property name="modal">no</property>
+ <child>
+ <object class="GtkListBox" id="listbox">
+ <property name="selection-mode">single</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ <object class="GtkPopover" id="security">
+ <property name="modal">yes</property>
+ <child>
+ <object class="GtkBox" id="security_box">
+ <property name="margin">4</property>
+ <property name="spacing">4</property>
+ <property name="orientation">vertical</property>
+ <property name="visible">yes</property>
+ </object>
+ </child>
+ </object>
+ <template class="MidoriUrlbar" parent="GtkEntry">
+ <property name="can-default">yes</property>
+ </template>
+</interface>
diff --git a/vapi/config.vapi b/vapi/config.vapi
new file mode 100644
index 00000000..b966df29
--- /dev/null
+++ b/vapi/config.vapi
@@ -0,0 +1,7 @@
+[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")]
+namespace Config {
+ public const string CORE_VERSION;
+ public const string PROJECT_NAME;
+ public const string PROJECT_BUGS;
+ public const string PROJECT_WEBSITE;
+}
diff --git a/vapi/javascriptcoregtk-4.0.vapi b/vapi/javascriptcoregtk-4.0.vapi
new file mode 100644
index 00000000..c937cae1
--- /dev/null
+++ b/vapi/javascriptcoregtk-4.0.vapi
@@ -0,0 +1,150 @@
+/* javascriptcoregtk-4.0.vapi generated by vapigen, do not modify. */
+
+[CCode (cprefix = "JS", gir_namespace = "JavaScriptCore", gir_version = "4.0", lower_case_cprefix = "JS_")]
+namespace JS {
+ [CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "void", free_function = "JSClassRelease", has_type_id = false)]
+ [Compact]
+ public class Class {
+ [CCode (cname = "JSClassRelease")]
+ [DestroysInstance]
+ public void release ();
+ [CCode (cname = "JSClassRetain")]
+ public JS.Class retain ();
+ }
+ [CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "const struct OpaqueJSContext", free_function = "", has_type_id = false)]
+ [Compact]
+ public class Context {
+ [CCode (cname = "JSCheckScriptSyntax")]
+ public bool check_script_syntax (JS.String script, JS.String? source_url = null, int starting_line_number = 1, out JS.Value? exception = null);
+ [CCode (cname = "JSGarbageCollect")]
+ public void collect_garbage ();
+ [CCode (cname = "JSEvaluateScript")]
+ public unowned JS.Value? evaluate_script (JS.String script, JS.Object? this_object = null, JS.String? source_url = null, int starting_line_number = 1, out JS.Value? exception = null);
+ }
+ [CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "struct OpaqueJSContext", free_function = "JSGlobalContextRelease", has_type_id = false)]
+ [Compact]
+ public class GlobalContext : JS.Context {
+ [CCode (cname = "JSGlobalContextCreate")]
+ public GlobalContext (JS.Class? global_object_class = null);
+ [CCode (cname = "JSGlobalContextRelease")]
+ [DestroysInstance]
+ public void release ();
+ [CCode (cname = "JSGlobalContextRetain")]
+ public JS.GlobalContext retain ();
+ }
+ [CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "struct OpaqueJSValue", free_function = "", has_type_id = false)]
+ [Compact]
+ public class Object {
+ [CCode (cname = "JSObjectCallAsFunction", instance_pos = 1.1)]
+ public JS.Value call_as_function (JS.Context ctx, JS.Object? this_object, [CCode (array_length_pos = 2.5)] JS.Value[]? arguments, out JS.Value? exception);
+ [CCode (cname = "JSObjectGetProperty", instance_pos = 1.1)]
+ public JS.Value get_property (JS.Context ctx, JS.String property_name, out JS.Value? exception);
+ [CCode (cname = "JSObjectHasProperty", instance_pos = 1.1)]
+ public bool has_property (JS.Context ctx, JS.String property_name);
+ [CCode (cname = "JSObjectMakeFunction")]
+ public Object.make_function (JS.String? name, [CCode (array_length_pos = 1.5)] JS.String[]? parameter_names, JS.String body, JS.String? source_url, int starting_line_number, out JS.Value? exception);
+ }
+ [CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "struct OpaqueJSString", free_function = "JSStringRelease", has_type_id = false)]
+ [Compact]
+ public class String {
+ [CCode (cname = "JSStringCreateWithUTF8CString")]
+ public String.create_with_utf8_cstring (string str);
+ [CCode (cname = "JSStringGetLength")]
+ public size_t get_length ();
+ [CCode (cname = "JSStringGetMaximumUTF8CStringSize")]
+ public size_t get_maximum_utf8_cstring_size ();
+ [CCode (cname = "JSStringGetUTF8CString")]
+ public size_t get_utf8_cstring ([CCode (array_length_type = "gsize")] ref uint8[] buffer);
+ [CCode (cname = "JSStringIsEqual")]
+ public bool is_equal (JS.String b);
+ [CCode (cname = "JSStringIsEqualToUTF8CString")]
+ public bool is_equal_to_utf8_cstring (string b);
+ [CCode (cname = "JSStringRelease")]
+ [DestroysInstance]
+ public void release ();
+ [CCode (cname = "JSStringRetain")]
+ public JS.String retain ();
+ }
+ [CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "const struct OpaqueJSValue", free_function = "", has_type_id = false)]
+ [Compact]
+ public class Value {
+ [CCode (cname = "JSValueGetType", instance_pos = 1.1)]
+ public JS.Type get_type (JS.Context ctx);
+ [CCode (cname = "JSValueGetTypedArrayType", instance_pos = 1.1)]
+ public JS.TypedArrayType get_typed_array_type (JS.Context ctx);
+ [CCode (cname = "JSValueIsArray", instance_pos = 1.1)]
+ public bool is_array (JS.Context ctx);
+ [CCode (cname = "JSValueIsBoolean", instance_pos = 1.1)]
+ public bool is_boolean (JS.Context ctx);
+ [CCode (cname = "JSValueIsDate", instance_pos = 1.1)]
+ public bool is_date (JS.Context ctx);
+ [CCode (cname = "JSValueIsEqual", instance_pos = 1.1)]
+ public bool is_equal (JS.Context ctx, JS.Value b, out JS.Value? exception = null);
+ [CCode (cname = "JSValueIsNull", instance_pos = 1.1)]
+ public bool is_null (JS.Context ctx);
+ [CCode (cname = "JSValueIsNumber", instance_pos = 1.1)]
+ public bool is_number (JS.Context ctx);
+ [CCode (cname = "JSValueIsObject", instance_pos = 1.1)]
+ public bool is_object (JS.Context ctx);
+ [CCode (cname = "JSValueIsObjectOfClass", instance_pos = 1.1)]
+ public bool is_object_of_class (JS.Context ctx, JS.Class js_class);
+ [CCode (cname = "JSValueIsStrictEqual", instance_pos = 1.1)]
+ public bool is_strict_equal (JS.Context ctx, JS.Value b);
+ [CCode (cname = "JSValueIsString", instance_pos = 1.1)]
+ public bool is_string (JS.Context ctx);
+ [CCode (cname = "JSValueIsUndefined", instance_pos = 1.1)]
+ public bool is_undefined (JS.Context ctx);
+ [CCode (cname = "JSValueProtect", instance_pos = 1.1)]
+ public void protect (JS.Context ctx);
+ [CCode (cname = "JSValueToBoolean", instance_pos = 1.1)]
+ public bool to_boolean (JS.Context ctx);
+ [CCode (cname = "JSValueToNumber", instance_pos = 1.1)]
+ public double to_number (JS.Context ctx, out JS.Value? exception = null);
+ [CCode (cname = "JSValueToObject", instance_pos = 1.1)]
+ public JS.Object to_object (JS.Context ctx, out JS.Value? exception = null);
+ [CCode (cname = "JSValueToStringCopy", instance_pos = 1.1)]
+ public JS.String to_string_copy (JS.Context ctx, out JS.Value? exception = null);
+ [CCode (cname = "JSValueUnprotect", instance_pos = 1.1)]
+ public void unprotect (JS.Context ctx);
+ }
+ [CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "JSType", has_type_id = false)]
+ public enum Type {
+ [CCode (cname = "kJSTypeUndefined")]
+ UNDEFINED,
+ [CCode (cname = "kJSTypeNull")]
+ NULL,
+ [CCode (cname = "kJSTypeBoolean")]
+ BOOLEAN,
+ [CCode (cname = "kJSTypeNumber")]
+ NUMBER,
+ [CCode (cname = "kJSTypeString")]
+ STRING,
+ [CCode (cname = "kJSTypeObject")]
+ OBJECT
+ }
+ [CCode (cheader_filename = "JavaScriptCore/JavaScript.h", cname = "JSTypedArrayType", has_type_id = false)]
+ public enum TypedArrayType {
+ [CCode (cname = "kJSTypedArrayTypeInt8Array")]
+ INT8,
+ [CCode (cname = "kJSTypedArrayTypeInt16Array")]
+ INT16,
+ [CCode (cname = "kJSTypedArrayTypeInt32Array")]
+ INT32,
+ [CCode (cname = "kJSTypedArrayTypeUint8Array")]
+ UINT8,
+ [CCode (cname = "kJSTypedArrayTypeUint8ClampedArray")]
+ UINT8_CLAMPED,
+ [CCode (cname = "kJSTypedArrayTypeUint16Array")]
+ UINT16,
+ [CCode (cname = "kJSTypedArrayTypeUint32Array")]
+ UINT32,
+ [CCode (cname = "kJSTypedArrayTypeFloat32Array")]
+ FLOAT32,
+ [CCode (cname = "kJSTypedArrayTypeFloat64Array")]
+ FLOAT64,
+ [CCode (cname = "kJSTypedArrayTypeArrayBuffer")]
+ BUFFER,
+ [CCode (cname = "kJSTypedArrayTypeNone")]
+ NONE
+ }
+}
diff --git a/midori/webkit2gtk-4.0.vapi b/vapi/webkit2gtk-4.0.vapi
index 158eba46..7d2c35a8 100644
--- a/midori/webkit2gtk-4.0.vapi
+++ b/vapi/webkit2gtk-4.0.vapi
@@ -2,6 +2,18 @@
[CCode (cprefix = "WebKit", gir_namespace = "WebKit2", gir_version = "4.0", lower_case_cprefix = "webkit_")]
namespace WebKit {
+ [CCode (cheader_filename = "webkit2/webkit2.h", ref_function = "webkit_application_info_ref", type_id = "webkit_application_info_get_type ()", unref_function = "webkit_application_info_unref")]
+ [Compact]
+ public class ApplicationInfo {
+ [CCode (has_construct_function = false)]
+ public ApplicationInfo ();
+ public unowned string get_name ();
+ public void get_version (out uint64 major, out uint64 minor, out uint64 micro);
+ public unowned WebKit.ApplicationInfo @ref ();
+ public void set_name (string name);
+ public void set_version (uint64 major, uint64 minor, uint64 micro);
+ public void unref ();
+ }
[CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_authentication_request_get_type ()")]
public class AuthenticationRequest : GLib.Object {
[CCode (has_construct_function = false)]
@@ -18,6 +30,16 @@ namespace WebKit {
public bool is_retry ();
public signal void cancelled ();
}
+ [CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_automation_session_get_type ()")]
+ public class AutomationSession : GLib.Object {
+ [CCode (has_construct_function = false)]
+ protected AutomationSession ();
+ public unowned WebKit.ApplicationInfo get_application_info ();
+ public unowned string get_id ();
+ public void set_application_info (WebKit.ApplicationInfo info);
+ public string id { get; construct; }
+ public signal unowned WebKit.WebView create_web_view ();
+ }
[CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_back_forward_list_get_type ()")]
public class BackForwardList : GLib.Object {
[CCode (has_construct_function = false)]
@@ -76,12 +98,12 @@ namespace WebKit {
[CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_context_menu_item_get_type ()")]
public class ContextMenuItem : GLib.InitiallyUnowned {
[CCode (has_construct_function = false)]
- public ContextMenuItem (Gtk.Action action);
+ public ContextMenuItem.from_gaction (GLib.Action action, string label, GLib.Variant? target);
[CCode (has_construct_function = false)]
public ContextMenuItem.from_stock_action (WebKit.ContextMenuAction action);
[CCode (has_construct_function = false)]
public ContextMenuItem.from_stock_action_with_label (WebKit.ContextMenuAction action, string label);
- public unowned Gtk.Action get_action ();
+ public unowned GLib.Action get_gaction ();
public WebKit.ContextMenuAction get_stock_action ();
public unowned WebKit.ContextMenu get_submenu ();
public bool is_separator ();
@@ -98,7 +120,6 @@ namespace WebKit {
public void delete_all_cookies ();
public void delete_cookies_for_domain (string domain);
public async WebKit.CookieAcceptPolicy get_accept_policy (GLib.Cancellable? cancellable) throws GLib.Error;
- [CCode (array_length = false, array_null_terminated = true)]
public async string[] get_domains_with_cookies (GLib.Cancellable? cancellable) throws GLib.Error;
public void set_accept_policy (WebKit.CookieAcceptPolicy policy);
public void set_persistent_storage (string filename, WebKit.CookiePersistentStorage storage);
@@ -137,10 +158,17 @@ namespace WebKit {
public WebKit.URIResponse response { get; }
public signal void created_destination (string destination);
public virtual signal bool decide_destination (string suggested_filename);
- public signal void failed (void* error);
+ public signal void failed (WebKit.DownloadError error);
public signal void finished ();
public signal void received_data (uint64 data_length);
}
+ [CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_editor_state_get_type ()")]
+ public class EditorState : GLib.Object {
+ [CCode (has_construct_function = false)]
+ protected EditorState ();
+ public uint get_typing_attributes ();
+ public uint typing_attributes { get; }
+ }
[CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_favicon_database_get_type ()")]
public class FaviconDatabase : GLib.Object {
[CCode (has_construct_function = false)]
@@ -196,7 +224,8 @@ namespace WebKit {
public class FormSubmissionRequest : GLib.Object {
[CCode (has_construct_function = false)]
protected FormSubmissionRequest ();
- public unowned GLib.HashTable<void*,void*> get_text_fields ();
+ public unowned GLib.HashTable<void*,void*>? get_text_fields ();
+ public bool list_text_fields (out unowned GLib.GenericArray<string> field_names, out unowned GLib.GenericArray<string> field_values);
public void submit ();
}
[CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_geolocation_permission_request_get_type ()")]
@@ -227,10 +256,18 @@ namespace WebKit {
public string link_uri { get; construct; }
public string media_uri { get; construct; }
}
+ [CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_install_missing_media_plugins_permission_request_get_type ()")]
+ public class InstallMissingMediaPluginsPermissionRequest : GLib.Object, WebKit.PermissionRequest {
+ [CCode (has_construct_function = false)]
+ protected InstallMissingMediaPluginsPermissionRequest ();
+ public unowned string get_description ();
+ }
[CCode (cheader_filename = "webkit2/webkit2.h", ref_function = "webkit_javascript_result_ref", type_id = "webkit_javascript_result_get_type ()", unref_function = "webkit_javascript_result_unref")]
[Compact]
public class JavascriptResult {
- public WebKit.JavascriptResult @ref ();
+ public unowned JS.GlobalContext get_global_context ();
+ public unowned JS.Value get_value ();
+ public unowned WebKit.JavascriptResult @ref ();
public void unref ();
}
[CCode (cheader_filename = "webkit2/webkit2.h", ref_function = "webkit_mime_info_ref", type_id = "webkit_mime_info_get_type ()", unref_function = "webkit_mime_info_unref")]
@@ -240,7 +277,7 @@ namespace WebKit {
[CCode (array_length = false, array_null_terminated = true)]
public unowned string[] get_extensions ();
public unowned string get_mime_type ();
- public WebKit.MimeInfo @ref ();
+ public unowned WebKit.MimeInfo @ref ();
public void unref ();
}
[CCode (cheader_filename = "webkit2/webkit2.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "webkit_navigation_action_get_type ()")]
@@ -259,25 +296,18 @@ namespace WebKit {
[CCode (has_construct_function = false)]
protected NavigationPolicyDecision ();
public unowned string get_frame_name ();
- [Deprecated (since = "2.6")]
- public uint get_modifiers ();
- [Deprecated (since = "2.6")]
- public uint get_mouse_button ();
public unowned WebKit.NavigationAction get_navigation_action ();
- [Deprecated (since = "2.6")]
- public WebKit.NavigationType get_navigation_type ();
- [Deprecated (since = "2.6")]
- public unowned WebKit.URIRequest get_request ();
public string frame_name { get; }
- [Deprecated (since = "2.6")]
- public uint modifiers { get; }
- [Deprecated (since = "2.6")]
- public uint mouse_button { get; }
public WebKit.NavigationAction navigation_action { get; }
- [Deprecated (since = "2.6")]
- public WebKit.NavigationType navigation_type { get; }
- [Deprecated (since = "2.6")]
- public WebKit.URIRequest request { get; }
+ }
+ [CCode (cheader_filename = "webkit2/webkit2.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "webkit_network_proxy_settings_get_type ()")]
+ [Compact]
+ public class NetworkProxySettings {
+ [CCode (has_construct_function = false)]
+ public NetworkProxySettings (string? default_proxy_uri, string? ignore_hosts);
+ public void add_proxy_for_scheme (string scheme, string proxy_uri);
+ public WebKit.NetworkProxySettings copy ();
+ public void free ();
}
[CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_notification_get_type ()")]
public class Notification : GLib.Object {
@@ -286,10 +316,14 @@ namespace WebKit {
public void close ();
public unowned string get_body ();
public uint64 get_id ();
+ public unowned string? get_tag ();
public unowned string get_title ();
public string body { get; }
public uint64 id { get; }
+ public string tag { get; }
public string title { get; }
+ [HasEmitter]
+ public signal void clicked ();
public signal void closed ();
}
[CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_notification_permission_request_get_type ()")]
@@ -297,6 +331,29 @@ namespace WebKit {
[CCode (has_construct_function = false)]
protected NotificationPermissionRequest ();
}
+ [CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_option_menu_get_type ()")]
+ public class OptionMenu : GLib.Object {
+ [CCode (has_construct_function = false)]
+ protected OptionMenu ();
+ public void activate_item (uint index);
+ public unowned WebKit.OptionMenuItem get_item (uint index);
+ public uint get_n_items ();
+ public void select_item (uint index);
+ [HasEmitter]
+ public signal void close ();
+ }
+ [CCode (cheader_filename = "webkit2/webkit2.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "webkit_option_menu_item_get_type ()")]
+ [Compact]
+ public class OptionMenuItem {
+ public WebKit.OptionMenuItem copy ();
+ public void free ();
+ public unowned string get_label ();
+ public unowned string get_tooltip ();
+ public bool is_enabled ();
+ public bool is_group_child ();
+ public bool is_group_label ();
+ public bool is_selected ();
+ }
[CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_plugin_get_type ()")]
public class Plugin : GLib.Object {
[CCode (has_construct_function = false)]
@@ -314,6 +371,17 @@ namespace WebKit {
public void ignore ();
public void use ();
}
+ [CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_print_custom_widget_get_type ()")]
+ public class PrintCustomWidget : GLib.Object {
+ [CCode (has_construct_function = false)]
+ public PrintCustomWidget (Gtk.Widget widget, string title);
+ public unowned string get_title ();
+ public unowned Gtk.Widget get_widget ();
+ public string title { get; construct; }
+ public Gtk.Widget widget { get; construct; }
+ public virtual signal void apply ();
+ public virtual signal void update (Gtk.PageSetup widget, Gtk.PrintSettings page_setup);
+ }
[CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_print_operation_get_type ()")]
public class PrintOperation : GLib.Object {
[CCode (has_construct_function = false)]
@@ -328,7 +396,8 @@ namespace WebKit {
public Gtk.PrintSettings print_settings { get; set; }
[NoAccessorMethod]
public WebKit.WebView web_view { owned get; construct; }
- public signal void failed (void* error);
+ public signal WebKit.PrintCustomWidget create_custom_widget ();
+ public signal void failed (WebKit.PrintError error);
public signal void finished ();
}
[CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_response_policy_decision_get_type ()")]
@@ -367,11 +436,28 @@ namespace WebKit {
public bool uri_scheme_is_no_access (string scheme);
public bool uri_scheme_is_secure (string scheme);
}
+ [CCode (cheader_filename = "webkit2/webkit2.h", ref_function = "webkit_security_origin_ref", type_id = "webkit_security_origin_get_type ()", unref_function = "webkit_security_origin_unref")]
+ [Compact]
+ public class SecurityOrigin {
+ [CCode (has_construct_function = false)]
+ public SecurityOrigin (string protocol, string host, uint16 port);
+ [CCode (has_construct_function = false)]
+ public SecurityOrigin.for_uri (string uri);
+ public unowned string? get_host ();
+ public uint16 get_port ();
+ public unowned string? get_protocol ();
+ public bool is_opaque ();
+ public unowned WebKit.SecurityOrigin @ref ();
+ public string? to_string ();
+ public void unref ();
+ }
[CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_settings_get_type ()")]
public class Settings : GLib.Object {
[CCode (has_construct_function = false)]
public Settings ();
+ public bool get_allow_file_access_from_file_urls ();
public bool get_allow_modal_dialogs ();
+ public bool get_allow_universal_access_from_file_urls ();
public bool get_auto_load_images ();
public unowned string get_cursive_font_family ();
public unowned string get_default_charset ();
@@ -395,7 +481,6 @@ namespace WebKit {
public bool get_enable_offline_web_application_cache ();
public bool get_enable_page_cache ();
public bool get_enable_plugins ();
- public bool get_enable_private_browsing ();
public bool get_enable_resizable_text_areas ();
public bool get_enable_site_specific_quirks ();
public bool get_enable_smooth_scrolling ();
@@ -406,6 +491,7 @@ namespace WebKit {
public bool get_enable_write_console_messages_to_stdout ();
public bool get_enable_xss_auditor ();
public unowned string get_fantasy_font_family ();
+ public WebKit.HardwareAccelerationPolicy get_hardware_acceleration_policy ();
public bool get_javascript_can_access_clipboard ();
public bool get_javascript_can_open_windows_automatically ();
public bool get_load_icons_ignoring_image_load_setting ();
@@ -419,7 +505,9 @@ namespace WebKit {
public unowned string get_serif_font_family ();
public unowned string get_user_agent ();
public bool get_zoom_text_only ();
+ public void set_allow_file_access_from_file_urls (bool allowed);
public void set_allow_modal_dialogs (bool allowed);
+ public void set_allow_universal_access_from_file_urls (bool allowed);
public void set_auto_load_images (bool enabled);
public void set_cursive_font_family (string cursive_font_family);
public void set_default_charset (string default_charset);
@@ -443,7 +531,6 @@ namespace WebKit {
public void set_enable_offline_web_application_cache (bool enabled);
public void set_enable_page_cache (bool enabled);
public void set_enable_plugins (bool enabled);
- public void set_enable_private_browsing (bool enabled);
public void set_enable_resizable_text_areas (bool enabled);
public void set_enable_site_specific_quirks (bool enabled);
public void set_enable_smooth_scrolling (bool enabled);
@@ -454,6 +541,7 @@ namespace WebKit {
public void set_enable_write_console_messages_to_stdout (bool enabled);
public void set_enable_xss_auditor (bool enabled);
public void set_fantasy_font_family (string fantasy_font_family);
+ public void set_hardware_acceleration_policy (WebKit.HardwareAccelerationPolicy policy);
public void set_javascript_can_access_clipboard (bool enabled);
public void set_javascript_can_open_windows_automatically (bool enabled);
public void set_load_icons_ignoring_image_load_setting (bool enabled);
@@ -468,7 +556,9 @@ namespace WebKit {
public void set_user_agent (string? user_agent);
public void set_user_agent_with_application_details (string? application_name, string? application_version);
public void set_zoom_text_only (bool zoom_text_only);
+ public bool allow_file_access_from_file_urls { get; set construct; }
public bool allow_modal_dialogs { get; set construct; }
+ public bool allow_universal_access_from_file_urls { get; set construct; }
public bool auto_load_images { get; set construct; }
public string cursive_font_family { get; set construct; }
public string default_charset { get; set construct; }
@@ -492,7 +582,6 @@ namespace WebKit {
public bool enable_offline_web_application_cache { get; set construct; }
public bool enable_page_cache { get; set construct; }
public bool enable_plugins { get; set construct; }
- public bool enable_private_browsing { get; set construct; }
public bool enable_resizable_text_areas { get; set construct; }
public bool enable_site_specific_quirks { get; set construct; }
public bool enable_smooth_scrolling { get; set construct; }
@@ -503,6 +592,7 @@ namespace WebKit {
public bool enable_write_console_messages_to_stdout { get; set construct; }
public bool enable_xss_auditor { get; set construct; }
public string fantasy_font_family { get; set construct; }
+ public WebKit.HardwareAccelerationPolicy hardware_acceleration_policy { get; set construct; }
public bool javascript_can_access_clipboard { get; set construct; }
public bool javascript_can_open_windows_automatically { get; set construct; }
public bool load_icons_ignoring_image_load_setting { get; set construct; }
@@ -521,7 +611,8 @@ namespace WebKit {
public class URIRequest : GLib.Object {
[CCode (has_construct_function = false)]
public URIRequest (string uri);
- public Soup.MessageHeaders get_http_headers ();
+ public unowned Soup.MessageHeaders get_http_headers ();
+ public unowned string get_http_method ();
public unowned string get_uri ();
public void set_uri (string uri);
public string uri { get; set construct; }
@@ -580,7 +671,7 @@ namespace WebKit {
public class UserScript {
[CCode (has_construct_function = false)]
public UserScript (string source, WebKit.UserContentInjectedFrames injected_frames, WebKit.UserScriptInjectionTime injection_time, [CCode (array_length = false, array_null_terminated = true)] string[]? whitelist, [CCode (array_length = false, array_null_terminated = true)] string[]? blacklist);
- public WebKit.UserScript @ref ();
+ public unowned WebKit.UserScript @ref ();
public void unref ();
}
[CCode (cheader_filename = "webkit2/webkit2.h", ref_function = "webkit_user_style_sheet_ref", type_id = "webkit_user_style_sheet_get_type ()", unref_function = "webkit_user_style_sheet_unref")]
@@ -588,7 +679,7 @@ namespace WebKit {
public class UserStyleSheet {
[CCode (has_construct_function = false)]
public UserStyleSheet (string source, WebKit.UserContentInjectedFrames injected_frames, WebKit.UserStyleLevel level, [CCode (array_length = false, array_null_terminated = true)] string[]? whitelist, [CCode (array_length = false, array_null_terminated = true)] string[]? blacklist);
- public WebKit.UserStyleSheet @ref ();
+ public unowned WebKit.UserStyleSheet @ref ();
public void unref ();
}
[CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_web_context_get_type ()")]
@@ -598,6 +689,8 @@ namespace WebKit {
public void allow_tls_certificate_for_host (GLib.TlsCertificate certificate, string host);
public void clear_cache ();
public WebKit.Download download_uri (string uri);
+ [CCode (has_construct_function = false)]
+ public WebContext.ephemeral ();
public WebKit.CacheModel get_cache_model ();
public unowned WebKit.CookieManager get_cookie_manager ();
public static unowned WebKit.WebContext get_default ();
@@ -610,12 +703,17 @@ namespace WebKit {
[CCode (array_length = false, array_null_terminated = true)]
public unowned string[] get_spell_checking_languages ();
public WebKit.TLSErrorsPolicy get_tls_errors_policy ();
+ public uint get_web_process_count_limit ();
+ public unowned WebKit.WebsiteDataManager get_website_data_manager ();
+ public bool is_automation_allowed ();
+ public bool is_ephemeral ();
public void prefetch_dns (string hostname);
public void register_uri_scheme (string scheme, owned WebKit.URISchemeRequestCallback callback);
public void set_additional_plugins_directory (string directory);
+ public void set_automation_allowed (bool allowed);
public void set_cache_model (WebKit.CacheModel cache_model);
- public void set_disk_cache_directory (string directory);
public void set_favicon_database_directory (string? path);
+ public void set_network_proxy_settings (WebKit.NetworkProxyMode proxy_mode, WebKit.NetworkProxySettings? proxy_settings);
public void set_preferred_languages ([CCode (array_length = false, array_null_terminated = true)] string[]? languages);
public void set_process_model (WebKit.ProcessModel process_model);
public void set_spell_checking_enabled (bool enabled);
@@ -623,9 +721,14 @@ namespace WebKit {
public void set_tls_errors_policy (WebKit.TLSErrorsPolicy policy);
public void set_web_extensions_directory (string directory);
public void set_web_extensions_initialization_user_data (GLib.Variant user_data);
- [NoAccessorMethod]
- public string local_storage_directory { owned get; construct; }
+ public void set_web_process_count_limit (uint limit);
+ [CCode (has_construct_function = false)]
+ public WebContext.with_website_data_manager (WebKit.WebsiteDataManager manager);
+ public WebKit.WebsiteDataManager website_data_manager { get; construct; }
+ public virtual signal void automation_started (WebKit.AutomationSession session);
public virtual signal void download_started (WebKit.Download download);
+ [HasEmitter]
+ public virtual signal void initialize_notification_permissions ();
public virtual signal void initialize_web_extensions ();
}
[CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_web_inspector_get_type ()")]
@@ -659,7 +762,7 @@ namespace WebKit {
public unowned string get_uri ();
public WebKit.URIResponse response { get; }
public string uri { get; }
- public signal void failed (void* error);
+ public signal void failed (GLib.Error error);
public signal void failed_with_tls_errors (GLib.TlsCertificate certificate, GLib.TlsCertificateFlags errors);
public signal void finished ();
public signal void received_data (uint64 data_length);
@@ -675,22 +778,27 @@ namespace WebKit {
public bool can_show_mime_type (string mime_type);
public WebKit.Download download_uri (string uri);
public void execute_editing_command (string command);
+ public void execute_editing_command_with_argument (string command, string argument);
public unowned WebKit.BackForwardList get_back_forward_list ();
public Gdk.RGBA get_background_color ();
public unowned WebKit.WebContext get_context ();
public unowned string get_custom_charset ();
+ public unowned WebKit.EditorState get_editor_state ();
public double get_estimated_load_progress ();
public unowned Cairo.Surface get_favicon ();
public unowned WebKit.FindController get_find_controller ();
public unowned WebKit.WebInspector get_inspector ();
+ public unowned JS.GlobalContext get_javascript_global_context ();
public unowned WebKit.WebResource get_main_resource ();
public uint64 get_page_id ();
+ public WebKit.WebViewSessionState get_session_state ();
public unowned WebKit.Settings get_settings ();
public async Cairo.Surface get_snapshot (WebKit.SnapshotRegion region, WebKit.SnapshotOptions options, GLib.Cancellable? cancellable) throws GLib.Error;
public unowned string get_title ();
public bool get_tls_info (out unowned GLib.TlsCertificate certificate, out GLib.TlsCertificateFlags errors);
public unowned string get_uri ();
public unowned WebKit.UserContentManager get_user_content_manager ();
+ public unowned WebKit.WebsiteDataManager get_website_data_manager ();
public unowned WebKit.WindowProperties get_window_properties ();
public double get_zoom_level ();
public void go_back ();
@@ -703,10 +811,9 @@ namespace WebKit {
public void load_plain_text (string plain_text);
public void load_request (WebKit.URIRequest request);
public void load_uri (string uri);
- [CCode (has_construct_function = false, type = "GtkWidget*")]
- public WebView.with_related_view (WebKit.WebView web_view);
public void reload ();
public void reload_bypass_cache ();
+ public void restore_session_state (WebKit.WebViewSessionState state);
public async WebKit.JavascriptResult run_javascript (string script, GLib.Cancellable? cancellable) throws GLib.Error;
public async WebKit.JavascriptResult run_javascript_from_gresource (string resource, GLib.Cancellable? cancellable) throws GLib.Error;
public async GLib.InputStream save (WebKit.SaveMode save_mode, GLib.Cancellable? cancellable) throws GLib.Error;
@@ -716,10 +823,15 @@ namespace WebKit {
public void set_editable (bool editable);
public void set_settings (WebKit.Settings settings);
public void set_zoom_level (double zoom_level);
+ [NoWrapper]
+ public virtual bool show_option_menu (Gdk.Rectangle rectangle, WebKit.OptionMenu menu);
public void stop_loading ();
+ public void try_close ();
[CCode (has_construct_function = false, type = "GtkWidget*")]
public WebView.with_context (WebKit.WebContext context);
[CCode (has_construct_function = false, type = "GtkWidget*")]
+ public WebView.with_related_view (WebKit.WebView web_view);
+ [CCode (has_construct_function = false, type = "GtkWidget*")]
public WebView.with_settings (WebKit.Settings settings);
[CCode (has_construct_function = false, type = "GtkWidget*")]
public WebView.with_user_content_manager (WebKit.UserContentManager user_content_manager);
@@ -728,9 +840,14 @@ namespace WebKit {
public double estimated_load_progress { get; }
public void* favicon { get; }
[NoAccessorMethod]
+ public bool is_controlled_by_automation { get; construct; }
+ [NoAccessorMethod]
+ public bool is_ephemeral { get; construct; }
+ [NoAccessorMethod]
public bool is_loading { get; }
[NoAccessorMethod]
public bool is_playing_audio { get; }
+ [NoAccessorMethod]
public WebKit.WebView related_view { construct; }
public WebKit.Settings settings { set construct; }
public string title { get; }
@@ -749,9 +866,11 @@ namespace WebKit {
public virtual signal void insecure_content_detected (WebKit.InsecureContentEvent event);
public virtual signal bool leave_fullscreen ();
public virtual signal void load_changed (WebKit.LoadEvent load_event);
- public virtual signal bool load_failed (WebKit.LoadEvent load_event, string failing_uri, void* error);
+ public virtual signal bool load_failed (WebKit.LoadEvent load_event, string failing_uri, GLib.Error error);
public virtual signal bool load_failed_with_tls_errors (string failing_uri, GLib.TlsCertificate certificate, GLib.TlsCertificateFlags errors);
public virtual signal void mouse_target_changed (WebKit.HitTestResult hit_test_result, uint modifiers);
+ [CCode (cname = "show-option-menu")]
+ public signal bool on_show_option_menu (WebKit.OptionMenu menu, Gdk.Event event, Gdk.Rectangle rectangle);
public virtual signal bool permission_request (WebKit.PermissionRequest permission_request);
public virtual signal bool print (WebKit.PrintOperation print_operation);
public virtual signal void ready_to_show ();
@@ -769,6 +888,51 @@ namespace WebKit {
[CCode (has_construct_function = false)]
protected WebViewBase ();
}
+ [CCode (cheader_filename = "webkit2/webkit2.h", ref_function = "webkit_web_view_session_state_ref", type_id = "webkit_web_view_session_state_get_type ()", unref_function = "webkit_web_view_session_state_unref")]
+ [Compact]
+ public class WebViewSessionState {
+ [CCode (has_construct_function = false)]
+ public WebViewSessionState (GLib.Bytes data);
+ public unowned WebKit.WebViewSessionState @ref ();
+ public GLib.Bytes serialize ();
+ public void unref ();
+ }
+ [CCode (cheader_filename = "webkit2/webkit2.h", ref_function = "webkit_website_data_ref", type_id = "webkit_website_data_get_type ()", unref_function = "webkit_website_data_unref")]
+ [Compact]
+ public class WebsiteData {
+ public unowned string get_name ();
+ public uint64 get_size (WebKit.WebsiteDataTypes types);
+ public WebKit.WebsiteDataTypes get_types ();
+ public unowned WebKit.WebsiteData @ref ();
+ public void unref ();
+ }
+ [CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_website_data_manager_get_type ()")]
+ public class WebsiteDataManager : GLib.Object {
+ [CCode (has_construct_function = false)]
+ protected WebsiteDataManager ();
+ public async bool clear (WebKit.WebsiteDataTypes types, GLib.TimeSpan timespan, GLib.Cancellable? cancellable) throws GLib.Error;
+ [CCode (has_construct_function = false)]
+ public WebsiteDataManager.ephemeral ();
+ public async GLib.List<WebKit.WebsiteData> fetch (WebKit.WebsiteDataTypes types, GLib.Cancellable? cancellable) throws GLib.Error;
+ public unowned string? get_base_cache_directory ();
+ public unowned string? get_base_data_directory ();
+ public unowned WebKit.CookieManager get_cookie_manager ();
+ public unowned string? get_disk_cache_directory ();
+ public unowned string? get_indexeddb_directory ();
+ public unowned string? get_local_storage_directory ();
+ public unowned string? get_offline_application_cache_directory ();
+ public unowned string? get_websql_directory ();
+ public async bool remove (WebKit.WebsiteDataTypes types, GLib.List<WebKit.WebsiteData> website_data, GLib.Cancellable? cancellable) throws GLib.Error;
+ public string base_cache_directory { get; construct; }
+ public string base_data_directory { get; construct; }
+ public string disk_cache_directory { get; construct; }
+ public string indexeddb_directory { get; construct; }
+ [NoAccessorMethod]
+ public bool is_ephemeral { get; construct; }
+ public string local_storage_directory { get; construct; }
+ public string offline_application_cache_directory { get; construct; }
+ public string websql_directory { get; construct; }
+ }
[CCode (cheader_filename = "webkit2/webkit2.h", type_id = "webkit_window_properties_get_type ()")]
public class WindowProperties : GLib.Object {
[CCode (has_construct_function = false)]
@@ -782,7 +946,7 @@ namespace WebKit {
public bool get_statusbar_visible ();
public bool get_toolbar_visible ();
public bool fullscreen { get; construct; }
- public Cairo.RectangleInt geometry { get; construct; }
+ public Gdk.Rectangle geometry { get; construct; }
public bool locationbar_visible { get; construct; }
public bool menubar_visible { get; construct; }
public bool resizable { get; construct; }
@@ -878,6 +1042,15 @@ namespace WebKit {
FOR_SESSION,
PERMANENT
}
+ [CCode (cheader_filename = "webkit2/webkit2.h", cprefix = "WEBKIT_EDITOR_TYPING_ATTRIBUTE_", type_id = "webkit_editor_typing_attributes_get_type ()")]
+ [Flags]
+ public enum EditorTypingAttributes {
+ NONE,
+ BOLD,
+ ITALIC,
+ UNDERLINE,
+ STRIKETHROUGH
+ }
[CCode (cheader_filename = "webkit2/webkit2.h", cprefix = "WEBKIT_FIND_OPTIONS_", type_id = "webkit_find_options_get_type ()")]
[Flags]
public enum FindOptions {
@@ -888,6 +1061,12 @@ namespace WebKit {
BACKWARDS,
WRAP_AROUND
}
+ [CCode (cheader_filename = "webkit2/webkit2.h", cprefix = "WEBKIT_HARDWARE_ACCELERATION_POLICY_", type_id = "webkit_hardware_acceleration_policy_get_type ()")]
+ public enum HardwareAccelerationPolicy {
+ ON_DEMAND,
+ ALWAYS,
+ NEVER
+ }
[CCode (cheader_filename = "webkit2/webkit2.h", cprefix = "WEBKIT_HIT_TEST_RESULT_CONTEXT_", type_id = "webkit_hit_test_result_context_get_type ()")]
[Flags]
public enum HitTestResultContext {
@@ -920,6 +1099,12 @@ namespace WebKit {
FORM_RESUBMITTED,
OTHER
}
+ [CCode (cheader_filename = "webkit2/webkit2.h", cprefix = "WEBKIT_NETWORK_PROXY_MODE_", type_id = "webkit_network_proxy_mode_get_type ()")]
+ public enum NetworkProxyMode {
+ DEFAULT,
+ NO_PROXY,
+ CUSTOM
+ }
[CCode (cheader_filename = "webkit2/webkit2.h", cprefix = "WEBKIT_POLICY_DECISION_TYPE_", type_id = "webkit_policy_decision_type_get_type ()")]
public enum PolicyDecisionType {
NAVIGATION_ACTION,
@@ -944,7 +1129,8 @@ namespace WebKit {
public enum ScriptDialogType {
ALERT,
CONFIRM,
- PROMPT
+ PROMPT,
+ BEFORE_UNLOAD_CONFIRM
}
[CCode (cheader_filename = "webkit2/webkit2.h", cprefix = "WEBKIT_SNAPSHOT_OPTIONS_", type_id = "webkit_snapshot_options_get_type ()")]
[Flags]
@@ -978,6 +1164,20 @@ namespace WebKit {
USER,
AUTHOR
}
+ [CCode (cheader_filename = "webkit2/webkit2.h", cprefix = "WEBKIT_WEBSITE_DATA_", type_id = "webkit_website_data_types_get_type ()")]
+ [Flags]
+ public enum WebsiteDataTypes {
+ MEMORY_CACHE,
+ DISK_CACHE,
+ OFFLINE_APPLICATION_CACHE,
+ SESSION_STORAGE,
+ LOCAL_STORAGE,
+ WEBSQL_DATABASES,
+ INDEXEDDB_DATABASES,
+ PLUGIN_DATA,
+ COOKIES,
+ ALL
+ }
[CCode (cheader_filename = "webkit2/webkit2.h", cprefix = "WEBKIT_DOWNLOAD_ERROR_")]
public errordomain DownloadError {
NETWORK,
@@ -1041,8 +1241,12 @@ namespace WebKit {
public delegate void URISchemeRequestCallback (WebKit.URISchemeRequest request);
[CCode (cheader_filename = "webkit2/webkit2.h", cname = "WEBKIT_EDITING_COMMAND_COPY")]
public const string EDITING_COMMAND_COPY;
+ [CCode (cheader_filename = "webkit2/webkit2.h", cname = "WEBKIT_EDITING_COMMAND_CREATE_LINK")]
+ public const string EDITING_COMMAND_CREATE_LINK;
[CCode (cheader_filename = "webkit2/webkit2.h", cname = "WEBKIT_EDITING_COMMAND_CUT")]
public const string EDITING_COMMAND_CUT;
+ [CCode (cheader_filename = "webkit2/webkit2.h", cname = "WEBKIT_EDITING_COMMAND_INSERT_IMAGE")]
+ public const string EDITING_COMMAND_INSERT_IMAGE;
[CCode (cheader_filename = "webkit2/webkit2.h", cname = "WEBKIT_EDITING_COMMAND_PASTE")]
public const string EDITING_COMMAND_PASTE;
[CCode (cheader_filename = "webkit2/webkit2.h", cname = "WEBKIT_EDITING_COMMAND_REDO")]
diff --git a/midori/webkit2gtk-web-extension-4.0.vapi b/vapi/webkit2gtk-web-extension-4.0.vapi
index 04960832..6baed4db 100644
--- a/midori/webkit2gtk-web-extension-4.0.vapi
+++ b/vapi/webkit2gtk-web-extension-4.0.vapi
@@ -8,16 +8,24 @@ namespace WebKit {
public class Attr : WebKit.DOM.Node, WebKit.DOM.EventTarget {
[CCode (has_construct_function = false)]
protected Attr ();
+ [Version (since = "2.14")]
+ public string get_local_name ();
public string get_name ();
+ [Version (since = "2.14")]
+ public string get_namespace_uri ();
public unowned WebKit.DOM.Element get_owner_element ();
+ [Version (since = "2.14")]
+ public string get_prefix ();
public bool get_specified ();
public string get_value ();
public void set_value (string value) throws GLib.Error;
- [NoAccessorMethod]
- public bool is_id { get; }
+ public string local_name { owned get; }
public string name { owned get; }
+ public string namespace_uri { owned get; }
public WebKit.DOM.Element owner_element { get; }
+ public string prefix { owned get; }
public bool specified { get; }
+ [NoAccessorMethod]
public string value { owned get; set; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_blob_get_type ()")]
@@ -27,8 +35,6 @@ namespace WebKit {
protected Blob ();
public uint64 get_size ();
public uint64 size { get; }
- [NoAccessorMethod]
- public string type { owned get; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_cdata_section_get_type ()")]
[GIR (name = "DOMCDATASection")]
@@ -46,6 +52,7 @@ namespace WebKit {
public WebKit.DOM.CSSStyleSheet get_parent_style_sheet ();
public ushort get_rule_type ();
public void set_css_text (string value) throws GLib.Error;
+ [NoAccessorMethod]
public string css_text { owned get; set; }
public WebKit.DOM.CSSRule parent_rule { owned get; }
public WebKit.DOM.CSSStyleSheet parent_style_sheet { owned get; }
@@ -77,6 +84,7 @@ namespace WebKit {
public string remove_property (string propertyName) throws GLib.Error;
public void set_css_text (string value) throws GLib.Error;
public void set_property (string propertyName, string value, string priority) throws GLib.Error;
+ [NoAccessorMethod]
public string css_text { owned get; set; }
public ulong length { get; }
public WebKit.DOM.CSSRule parent_rule { owned get; }
@@ -105,6 +113,7 @@ namespace WebKit {
public string get_css_text ();
public ushort get_css_value_type ();
public void set_css_text (string value) throws GLib.Error;
+ [NoAccessorMethod]
public string css_text { owned get; set; }
public uint css_value_type { get; }
}
@@ -121,9 +130,45 @@ namespace WebKit {
public void replace_data (ulong offset, ulong length, string data) throws GLib.Error;
public void set_data (string value) throws GLib.Error;
public string substring_data (ulong offset, ulong length) throws GLib.Error;
+ [NoAccessorMethod]
public string data { owned get; set; }
public ulong length { get; }
}
+ [CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_client_rect_get_type ()")]
+ [GIR (name = "DOMClientRect")]
+ public class ClientRect : WebKit.DOM.Object {
+ [CCode (has_construct_function = false)]
+ protected ClientRect ();
+ [Version (since = "2.18")]
+ public float get_bottom ();
+ [Version (since = "2.18")]
+ public float get_height ();
+ [Version (since = "2.18")]
+ public float get_left ();
+ [Version (since = "2.18")]
+ public float get_right ();
+ [Version (since = "2.18")]
+ public float get_top ();
+ [Version (since = "2.18")]
+ public float get_width ();
+ public float bottom { get; }
+ public float height { get; }
+ public float left { get; }
+ public float right { get; }
+ public float top { get; }
+ public float width { get; }
+ }
+ [CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_client_rect_list_get_type ()")]
+ [GIR (name = "DOMClientRectList")]
+ public class ClientRectList : WebKit.DOM.Object {
+ [CCode (has_construct_function = false)]
+ protected ClientRectList ();
+ [Version (since = "2.18")]
+ public ulong get_length ();
+ [Version (since = "2.18")]
+ public WebKit.DOM.ClientRect item (ulong index);
+ public ulong length { get; }
+ }
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_comment_get_type ()")]
[GIR (name = "DOMComment")]
public class Comment : WebKit.DOM.CharacterData, WebKit.DOM.EventTarget {
@@ -141,65 +186,229 @@ namespace WebKit {
public unowned WebKit.DOM.HTMLDocument create_html_document (string title);
public bool has_feature (string feature, string version);
}
+ [CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_dom_selection_get_type ()")]
+ [GIR (name = "DOMDOMSelection")]
+ public class DOMSelection : WebKit.DOM.Object {
+ [CCode (has_construct_function = false)]
+ protected DOMSelection ();
+ [Version (since = "2.16")]
+ public void add_range (WebKit.DOM.Range range);
+ [Version (since = "2.16")]
+ public void collapse (WebKit.DOM.Node node, ulong offset);
+ [Version (since = "2.16")]
+ public void collapse_to_end () throws GLib.Error;
+ [Version (since = "2.16")]
+ public void collapse_to_start () throws GLib.Error;
+ [Version (since = "2.16")]
+ public bool contains_node (WebKit.DOM.Node node, bool allowPartial);
+ [Version (since = "2.16")]
+ public void delete_from_document ();
+ [Version (since = "2.16")]
+ public void empty ();
+ [Version (since = "2.16")]
+ public void extend (WebKit.DOM.Node node, ulong offset) throws GLib.Error;
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Node get_anchor_node ();
+ [Version (since = "2.16")]
+ public ulong get_anchor_offset ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Node get_base_node ();
+ [Version (since = "2.16")]
+ public ulong get_base_offset ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Node get_extent_node ();
+ [Version (since = "2.16")]
+ public ulong get_extent_offset ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Node get_focus_node ();
+ [Version (since = "2.16")]
+ public ulong get_focus_offset ();
+ [Version (since = "2.16")]
+ public bool get_is_collapsed ();
+ [Version (since = "2.16")]
+ public WebKit.DOM.Range get_range_at (ulong index) throws GLib.Error;
+ [Version (since = "2.16")]
+ public ulong get_range_count ();
+ [Version (since = "2.16")]
+ public string get_selection_type ();
+ [Version (since = "2.16")]
+ public void modify (string alter, string direction, string granularity);
+ [Version (since = "2.16")]
+ public void remove_all_ranges ();
+ [Version (since = "2.16")]
+ public void select_all_children (WebKit.DOM.Node node);
+ [Version (since = "2.16")]
+ public void set_base_and_extent (WebKit.DOM.Node baseNode, ulong baseOffset, WebKit.DOM.Node extentNode, ulong extentOffset);
+ [Version (since = "2.16")]
+ public void set_position (WebKit.DOM.Node node, ulong offset);
+ public WebKit.DOM.Node anchor_node { get; }
+ public ulong anchor_offset { get; }
+ public WebKit.DOM.Node base_node { get; }
+ public ulong base_offset { get; }
+ public WebKit.DOM.Node extent_node { get; }
+ public ulong extent_offset { get; }
+ public WebKit.DOM.Node focus_node { get; }
+ public ulong focus_offset { get; }
+ public bool is_collapsed { get; }
+ public ulong range_count { get; }
+ [NoAccessorMethod]
+ public string type { owned get; }
+ }
+ [CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_dom_token_list_get_type ()")]
+ [GIR (name = "DOMDOMTokenList")]
+ public class DOMTokenList : WebKit.DOM.Object {
+ [CCode (has_construct_function = false)]
+ protected DOMTokenList ();
+ [Version (since = "2.16")]
+ public bool contains (string token);
+ [Version (since = "2.16")]
+ public ulong get_length ();
+ [Version (since = "2.16")]
+ public string get_value ();
+ [Version (since = "2.16")]
+ public string item (ulong index);
+ [Version (since = "2.16")]
+ public void replace (string token, string newToken) throws GLib.Error;
+ [Version (since = "2.16")]
+ public void set_value (string value);
+ [Version (since = "2.16")]
+ public bool toggle (string token, bool force) throws GLib.Error;
+ public ulong length { get; }
+ public string value { owned get; set; }
+ }
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_dom_window_get_type ()")]
[GIR (name = "DOMDOMWindow")]
public class DOMWindow : WebKit.DOM.Object, WebKit.DOM.EventTarget {
[CCode (has_construct_function = false)]
protected DOMWindow ();
+ [Version (since = "2.16")]
+ public void alert (string message);
+ [Version (since = "2.16")]
+ public void blur ();
+ [Version (since = "2.16")]
+ public void capture_events ();
+ [Version (since = "2.16")]
+ public void close ();
+ [Version (since = "2.16")]
+ public bool confirm (string message);
+ [Version (since = "2.16")]
+ public bool find (string string, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog);
+ [Version (since = "2.16")]
+ public void focus ();
+ [Version (since = "2.16")]
+ public bool get_closed ();
+ [Version (since = "2.16")]
+ public WebKit.DOM.CSSStyleDeclaration get_computed_style (WebKit.DOM.Element element, string? pseudoElement);
+ [Version (since = "2.16")]
+ public string get_default_status ();
+ [Version (since = "2.16")]
+ public double get_device_pixel_ratio ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Document get_document ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Element get_frame_element ();
+ [Version (since = "2.16")]
+ public WebKit.DOM.DOMWindow get_frames ();
+ [Version (since = "2.16")]
+ public long get_inner_height ();
+ [Version (since = "2.16")]
+ public long get_inner_width ();
+ [Version (since = "2.16")]
+ public ulong get_length ();
+ [Version (since = "2.16")]
+ public string get_name ();
+ [Version (since = "2.16")]
+ public bool get_offscreen_buffering ();
+ [Version (since = "2.16")]
+ public WebKit.DOM.DOMWindow get_opener ();
+ [Version (since = "2.16")]
+ public long get_orientation ();
+ [Version (since = "2.16")]
+ public long get_outer_height ();
+ [Version (since = "2.16")]
+ public long get_outer_width ();
+ [Version (since = "2.16")]
+ public long get_page_x_offset ();
+ [Version (since = "2.16")]
+ public long get_page_y_offset ();
+ [Version (since = "2.16")]
+ public WebKit.DOM.DOMWindow get_parent ();
+ [Version (since = "2.16")]
+ public long get_screen_left ();
+ [Version (since = "2.16")]
+ public long get_screen_top ();
+ [Version (since = "2.16")]
+ public long get_screen_x ();
+ [Version (since = "2.16")]
+ public long get_screen_y ();
+ [Version (since = "2.16")]
+ public long get_scroll_x ();
+ [Version (since = "2.16")]
+ public long get_scroll_y ();
+ [Version (since = "2.16")]
+ public WebKit.DOM.DOMSelection get_selection ();
+ [Version (since = "2.16")]
+ public WebKit.DOM.DOMWindow get_self ();
+ [Version (since = "2.16")]
+ public string get_status ();
+ [Version (since = "2.16")]
+ public WebKit.DOM.DOMWindow get_top ();
+ [Version (since = "2.16")]
+ public WebKit.DOM.DOMWindow get_window ();
+ [Version (since = "2.16")]
+ public void move_by (float x, float y);
+ [Version (since = "2.16")]
+ public void move_to (float x, float y);
+ [Version (since = "2.16")]
+ public void print ();
+ [Version (since = "2.16")]
+ public string prompt (string message, string defaultValue);
+ [Version (since = "2.16")]
+ public void release_events ();
+ [Version (since = "2.16")]
+ public void resize_by (float x, float y);
+ [Version (since = "2.16")]
+ public void resize_to (float width, float height);
+ [Version (since = "2.16")]
+ public void scroll_by (double x, double y);
+ [Version (since = "2.16")]
+ public void scroll_to (double x, double y);
+ [Version (since = "2.16")]
+ public void set_default_status (string value);
+ [Version (since = "2.16")]
+ public void set_name (string value);
+ [Version (since = "2.16")]
+ public void set_status (string value);
+ [Version (since = "2.16")]
+ public void stop ();
public bool webkit_message_handlers_post_message (string handler, string message);
- [NoAccessorMethod]
public bool closed { get; }
- [NoAccessorMethod]
public string default_status { owned get; set; }
- [NoAccessorMethod]
public double device_pixel_ratio { get; }
- [NoAccessorMethod]
- public WebKit.DOM.Document document { owned get; }
- [NoAccessorMethod]
- public WebKit.DOM.Element frame_element { owned get; }
- [NoAccessorMethod]
+ public WebKit.DOM.Document document { get; }
+ public WebKit.DOM.Element frame_element { get; }
public WebKit.DOM.DOMWindow frames { owned get; }
- [NoAccessorMethod]
public long inner_height { get; }
- [NoAccessorMethod]
public long inner_width { get; }
- [NoAccessorMethod]
public ulong length { get; }
- [NoAccessorMethod]
public string name { owned get; set; }
- [NoAccessorMethod]
public bool offscreen_buffering { get; }
- [NoAccessorMethod]
public WebKit.DOM.DOMWindow opener { owned get; }
- [NoAccessorMethod]
+ public long orientation { get; }
public long outer_height { get; }
- [NoAccessorMethod]
public long outer_width { get; }
- [NoAccessorMethod]
public long page_x_offset { get; }
- [NoAccessorMethod]
public long page_y_offset { get; }
- [NoAccessorMethod]
public WebKit.DOM.DOMWindow parent { owned get; }
- [NoAccessorMethod]
public long screen_left { get; }
- [NoAccessorMethod]
public long screen_top { get; }
- [NoAccessorMethod]
public long screen_x { get; }
- [NoAccessorMethod]
public long screen_y { get; }
- [NoAccessorMethod]
public long scroll_x { get; }
- [NoAccessorMethod]
public long scroll_y { get; }
- [NoAccessorMethod]
public WebKit.DOM.DOMWindow self { owned get; }
- [NoAccessorMethod]
public string status { owned get; set; }
- [NoAccessorMethod]
public WebKit.DOM.DOMWindow top { owned get; }
- [NoAccessorMethod]
public WebKit.DOM.DOMWindow window { owned get; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_document_get_type ()")]
@@ -208,6 +417,8 @@ namespace WebKit {
[CCode (has_construct_function = false)]
protected Document ();
public unowned WebKit.DOM.Node adopt_node (WebKit.DOM.Node source) throws GLib.Error;
+ [Version (since = "2.16")]
+ public WebKit.DOM.Range caret_range_from_point (long x, long y);
public unowned WebKit.DOM.Attr create_attribute (string name) throws GLib.Error;
public unowned WebKit.DOM.Attr create_attribute_ns (string? namespaceURI, string qualifiedName) throws GLib.Error;
public unowned WebKit.DOM.CDATASection create_cdata_section (string data) throws GLib.Error;
@@ -216,6 +427,7 @@ namespace WebKit {
public unowned WebKit.DOM.DocumentFragment create_document_fragment ();
public unowned WebKit.DOM.Element create_element (string tagName) throws GLib.Error;
public unowned WebKit.DOM.Element create_element_ns (string? namespaceURI, string qualifiedName) throws GLib.Error;
+ [Version (deprecated = true, deprecated_since = "2.12")]
public unowned WebKit.DOM.EntityReference create_entity_reference (string? name) throws GLib.Error;
public WebKit.DOM.Event create_event (string eventType) throws GLib.Error;
public WebKit.DOM.XPathExpression create_expression (string expression, WebKit.DOM.XPathNSResolver resolver) throws GLib.Error;
@@ -228,39 +440,95 @@ namespace WebKit {
public unowned WebKit.DOM.Element element_from_point (long x, long y);
public WebKit.DOM.XPathResult evaluate (string expression, WebKit.DOM.Node contextNode, WebKit.DOM.XPathNSResolver? resolver, ushort type, WebKit.DOM.XPathResult? inResult) throws GLib.Error;
public bool exec_command (string command, bool userInterface, string value);
+ [Version (since = "2.16")]
+ public void exit_pointer_lock ();
public unowned WebKit.DOM.Element get_active_element ();
public WebKit.DOM.HTMLCollection get_anchors ();
public WebKit.DOM.HTMLCollection get_applets ();
public unowned WebKit.DOM.HTMLElement get_body ();
public string get_character_set ();
public string get_charset ();
+ [Version (since = "2.16")]
+ public ulong get_child_element_count ();
+ [Version (since = "2.16")]
+ public WebKit.DOM.HTMLCollection get_children ();
+ [Version (since = "2.14")]
+ public string get_compat_mode ();
+ [Version (since = "2.16")]
+ public string get_content_type ();
public string get_cookie () throws GLib.Error;
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.HTMLScriptElement get_current_script ();
+ [Version (deprecated = true, deprecated_since = "2.14")]
public string get_default_charset ();
public WebKit.DOM.DOMWindow get_default_view ();
+ [Version (since = "2.14")]
+ public string get_design_mode ();
+ [Version (since = "2.16")]
+ public string get_dir ();
public unowned WebKit.DOM.DocumentType get_doctype ();
public unowned WebKit.DOM.Element get_document_element ();
public string get_document_uri ();
public string get_domain ();
public unowned WebKit.DOM.Element get_element_by_id (string elementId);
- public WebKit.DOM.NodeList get_elements_by_class_name (string tagname);
+ [Version (deprecated = true, deprecated_since = "2.12")]
+ public WebKit.DOM.NodeList get_elements_by_class_name (string class_name);
+ [Version (since = "2.12")]
+ public WebKit.DOM.HTMLCollection get_elements_by_class_name_as_html_collection (string classNames);
public WebKit.DOM.NodeList get_elements_by_name (string elementName);
- public WebKit.DOM.NodeList get_elements_by_tag_name (string tagname);
- public WebKit.DOM.NodeList get_elements_by_tag_name_ns (string namespaceURI, string localName);
+ [Version (deprecated = true, deprecated_since = "2.12")]
+ public WebKit.DOM.NodeList get_elements_by_tag_name (string tag_name);
+ [Version (since = "2.12")]
+ public WebKit.DOM.HTMLCollection get_elements_by_tag_name_as_html_collection (string tagname);
+ [Version (deprecated = true, deprecated_since = "2.12")]
+ public WebKit.DOM.NodeList get_elements_by_tag_name_ns (string namespace_uri, string tag_name);
+ [Version (since = "2.12")]
+ public WebKit.DOM.HTMLCollection get_elements_by_tag_name_ns_as_html_collection (string namespaceURI, string localName);
+ [Version (since = "2.14")]
+ public WebKit.DOM.HTMLCollection get_embeds ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Element get_first_element_child ();
public WebKit.DOM.HTMLCollection get_forms ();
public unowned WebKit.DOM.HTMLHeadElement get_head ();
+ [Version (since = "2.16")]
+ public bool get_hidden ();
public WebKit.DOM.HTMLCollection get_images ();
public WebKit.DOM.DOMImplementation get_implementation ();
public string get_input_encoding ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Element get_last_element_child ();
public string get_last_modified ();
public WebKit.DOM.HTMLCollection get_links ();
+ [Version (since = "2.16")]
+ public string get_origin ();
public WebKit.DOM.CSSStyleDeclaration get_override_style (WebKit.DOM.Element element, string? pseudoElement);
+ [Version (since = "2.14")]
+ public WebKit.DOM.HTMLCollection get_plugins ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Element get_pointer_lock_element ();
public string get_preferred_stylesheet_set ();
public string get_ready_state ();
public string get_referrer ();
+ [Version (since = "2.14")]
+ public WebKit.DOM.HTMLCollection get_scripts ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Element get_scrolling_element ();
public string get_selected_stylesheet_set ();
public unowned WebKit.DOM.StyleSheetList get_style_sheets ();
public string get_title ();
public string get_url ();
+ [Version (since = "2.16")]
+ public string get_visibility_state ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Element get_webkit_current_fullscreen_element ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Element get_webkit_fullscreen_element ();
+ [Version (since = "2.16")]
+ public bool get_webkit_fullscreen_enabled ();
+ [Version (since = "2.16")]
+ public bool get_webkit_fullscreen_keyboard_input_allowed ();
+ [Version (since = "2.16")]
+ public bool get_webkit_is_fullscreen ();
public string get_xml_encoding ();
public bool get_xml_standalone ();
public string get_xml_version ();
@@ -276,64 +544,75 @@ namespace WebKit {
public void set_body (WebKit.DOM.HTMLElement value) throws GLib.Error;
public void set_charset (string value);
public void set_cookie (string value) throws GLib.Error;
+ [Version (since = "2.14")]
+ public void set_design_mode (string value);
+ [Version (since = "2.16")]
+ public void set_dir (string value);
public void set_document_uri (string value);
public void set_selected_stylesheet_set (string value);
public void set_title (string value);
public void set_xml_standalone (bool value) throws GLib.Error;
public void set_xml_version (string value) throws GLib.Error;
+ [Version (since = "2.16")]
+ public void webkit_cancel_fullscreen ();
+ [Version (since = "2.16")]
+ public void webkit_exit_fullscreen ();
public WebKit.DOM.Element active_element { get; }
public WebKit.DOM.HTMLCollection anchors { owned get; }
public WebKit.DOM.HTMLCollection applets { owned get; }
public WebKit.DOM.HTMLElement body { get; }
public string character_set { owned get; }
public string charset { owned get; set; }
- [NoAccessorMethod]
+ public ulong child_element_count { get; }
+ public WebKit.DOM.HTMLCollection children { owned get; }
public string compat_mode { owned get; }
- [NoAccessorMethod]
public string content_type { owned get; }
- public string cookie { owned get; set; }
[NoAccessorMethod]
- public WebKit.DOM.HTMLScriptElement current_script { owned get; }
- public string default_charset { owned get; }
+ public string cookie { owned get; set; }
+ public WebKit.DOM.HTMLScriptElement current_script { get; }
public WebKit.DOM.DOMWindow default_view { owned get; }
+ public string design_mode { owned get; set; }
+ public string dir { owned get; set; }
public WebKit.DOM.DocumentType doctype { get; }
public WebKit.DOM.Element document_element { get; }
public string document_uri { owned get; set; }
public string domain { owned get; }
+ public WebKit.DOM.HTMLCollection embeds { owned get; }
+ public WebKit.DOM.Element first_element_child { get; }
public WebKit.DOM.HTMLCollection forms { owned get; }
public WebKit.DOM.HTMLHeadElement head { get; }
- [NoAccessorMethod]
public bool hidden { get; }
public WebKit.DOM.HTMLCollection images { owned get; }
public WebKit.DOM.DOMImplementation implementation { owned get; }
public string input_encoding { owned get; }
+ public WebKit.DOM.Element last_element_child { get; }
public string last_modified { owned get; }
public WebKit.DOM.HTMLCollection links { owned get; }
- [NoAccessorMethod]
public string origin { owned get; }
- [NoAccessorMethod]
- public WebKit.DOM.Element pointer_lock_element { owned get; }
+ public WebKit.DOM.HTMLCollection plugins { owned get; }
+ public WebKit.DOM.Element pointer_lock_element { get; }
public string preferred_stylesheet_set { owned get; }
public string ready_state { owned get; }
public string referrer { owned get; }
+ public WebKit.DOM.HTMLCollection scripts { owned get; }
+ public WebKit.DOM.Element scrolling_element { get; }
public string selected_stylesheet_set { owned get; set; }
public WebKit.DOM.StyleSheetList style_sheets { get; }
public string title { owned get; set; }
public string url { owned get; }
- [NoAccessorMethod]
public string visibility_state { owned get; }
[NoAccessorMethod]
public WebKit.DOM.Element webkit_current_full_screen_element { owned get; }
[NoAccessorMethod]
public bool webkit_full_screen_keyboard_input_allowed { get; }
- [NoAccessorMethod]
- public WebKit.DOM.Element webkit_fullscreen_element { owned get; }
- [NoAccessorMethod]
+ public WebKit.DOM.Element webkit_fullscreen_element { get; }
public bool webkit_fullscreen_enabled { get; }
[NoAccessorMethod]
public bool webkit_is_full_screen { get; }
public string xml_encoding { owned get; }
+ [NoAccessorMethod]
public bool xml_standalone { get; set; }
+ [NoAccessorMethod]
public string xml_version { owned get; set; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_document_fragment_get_type ()")]
@@ -341,6 +620,24 @@ namespace WebKit {
public class DocumentFragment : WebKit.DOM.Node, WebKit.DOM.EventTarget {
[CCode (has_construct_function = false)]
protected DocumentFragment ();
+ [Version (since = "2.16")]
+ public ulong get_child_element_count ();
+ [Version (since = "2.16")]
+ public WebKit.DOM.HTMLCollection get_children ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Element get_element_by_id (string elementId);
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Element get_first_element_child ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Element get_last_element_child ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Element query_selector (string selectors) throws GLib.Error;
+ [Version (since = "2.16")]
+ public WebKit.DOM.NodeList query_selector_all (string selectors) throws GLib.Error;
+ public ulong child_element_count { get; }
+ public WebKit.DOM.HTMLCollection children { owned get; }
+ public WebKit.DOM.Element first_element_child { get; }
+ public WebKit.DOM.Element last_element_child { get; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_document_type_get_type ()")]
[GIR (name = "DOMDocumentType")]
@@ -366,32 +663,59 @@ namespace WebKit {
[CCode (has_construct_function = false)]
protected Element ();
public void blur ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Element closest (string selectors) throws GLib.Error;
public void focus ();
public string get_attribute (string name);
public unowned WebKit.DOM.Attr get_attribute_node (string name);
public unowned WebKit.DOM.Attr get_attribute_node_ns (string namespaceURI, string localName);
public string get_attribute_ns (string namespaceURI, string localName);
public WebKit.DOM.NamedNodeMap get_attributes ();
+ [Version (since = "2.18")]
+ public WebKit.DOM.ClientRect get_bounding_client_rect ();
public ulong get_child_element_count ();
+ [Version (since = "2.10")]
+ public WebKit.DOM.HTMLCollection get_children ();
+ [Version (since = "2.16")]
+ public WebKit.DOM.DOMTokenList get_class_list ();
public string get_class_name ();
public double get_client_height ();
public double get_client_left ();
+ [Version (since = "2.18")]
+ public WebKit.DOM.ClientRectList get_client_rects ();
public double get_client_top ();
public double get_client_width ();
- public WebKit.DOM.NodeList get_elements_by_class_name (string name);
- public WebKit.DOM.NodeList get_elements_by_tag_name (string name);
- public WebKit.DOM.NodeList get_elements_by_tag_name_ns (string namespaceURI, string localName);
+ [Version (deprecated = true, deprecated_since = "2.12")]
+ public WebKit.DOM.NodeList get_elements_by_class_name (string class_name);
+ [Version (since = "2.12")]
+ public WebKit.DOM.HTMLCollection get_elements_by_class_name_as_html_collection (string name);
+ [Version (deprecated = true, deprecated_since = "2.12")]
+ public WebKit.DOM.NodeList get_elements_by_tag_name (string tag_name);
+ [Version (since = "2.12")]
+ public WebKit.DOM.HTMLCollection get_elements_by_tag_name_as_html_collection (string name);
+ [Version (deprecated = true, deprecated_since = "2.12")]
+ public WebKit.DOM.NodeList get_elements_by_tag_name_ns (string namespace_uri, string tag_name);
+ [Version (since = "2.12")]
+ public WebKit.DOM.HTMLCollection get_elements_by_tag_name_ns_as_html_collection (string namespaceURI, string localName);
public unowned WebKit.DOM.Element get_first_element_child ();
public string get_id ();
+ [Version (since = "2.8")]
public string get_inner_html ();
public unowned WebKit.DOM.Element get_last_element_child ();
+ [Version (since = "2.14")]
+ public string get_local_name ();
+ [Version (since = "2.14")]
+ public string get_namespace_uri ();
public unowned WebKit.DOM.Element get_next_element_sibling ();
public double get_offset_height ();
public double get_offset_left ();
public unowned WebKit.DOM.Element get_offset_parent ();
public double get_offset_top ();
public double get_offset_width ();
+ [Version (since = "2.8")]
public string get_outer_html ();
+ [Version (since = "2.14")]
+ public string get_prefix ();
public unowned WebKit.DOM.Element get_previous_element_sibling ();
public long get_scroll_height ();
public long get_scroll_left ();
@@ -399,14 +723,28 @@ namespace WebKit {
public long get_scroll_width ();
public WebKit.DOM.CSSStyleDeclaration get_style ();
public string get_tag_name ();
+ [Version (deprecated = true, deprecated_since = "2.20")]
+ public string get_webkit_region_overset ();
public bool has_attribute (string name);
public bool has_attribute_ns (string namespaceURI, string localName);
public bool has_attributes ();
+ [Version (since = "2.16")]
+ public unowned WebKit.DOM.Element insert_adjacent_element (string where, WebKit.DOM.Element element) throws GLib.Error;
+ [Version (since = "2.16")]
+ public void insert_adjacent_html (string where, string html) throws GLib.Error;
+ [Version (since = "2.16")]
+ public void insert_adjacent_text (string where, string text) throws GLib.Error;
+ [Version (since = "2.16")]
+ public bool matches (string selectors) throws GLib.Error;
public unowned WebKit.DOM.Element query_selector (string selectors) throws GLib.Error;
public WebKit.DOM.NodeList query_selector_all (string selectors) throws GLib.Error;
+ [Version (since = "2.16")]
+ public void remove () throws GLib.Error;
public void remove_attribute (string name);
public unowned WebKit.DOM.Attr remove_attribute_node (WebKit.DOM.Attr oldAttr) throws GLib.Error;
public void remove_attribute_ns (string namespaceURI, string localName);
+ [Version (since = "2.16")]
+ public void request_pointer_lock ();
public void scroll_by_lines (long lines);
public void scroll_by_pages (long pages);
public void scroll_into_view (bool alignWithTop);
@@ -417,12 +755,20 @@ namespace WebKit {
public void set_attribute_ns (string? namespaceURI, string qualifiedName, string value) throws GLib.Error;
public void set_class_name (string value);
public void set_id (string value);
+ [Version (since = "2.8")]
public void set_inner_html (string value) throws GLib.Error;
+ [Version (since = "2.8")]
public void set_outer_html (string value) throws GLib.Error;
public void set_scroll_left (long value);
public void set_scroll_top (long value);
+ [Version (since = "2.16")]
+ public bool webkit_matches_selector (string selectors) throws GLib.Error;
+ [Version (since = "2.16")]
+ public void webkit_request_fullscreen ();
public WebKit.DOM.NamedNodeMap attributes { owned get; }
public ulong child_element_count { get; }
+ public WebKit.DOM.HTMLCollection children { owned get; }
+ public WebKit.DOM.DOMTokenList class_list { owned get; }
public string class_name { owned get; set; }
public double client_height { get; }
public double client_left { get; }
@@ -430,15 +776,20 @@ namespace WebKit {
public double client_width { get; }
public WebKit.DOM.Element first_element_child { get; }
public string id { owned get; set; }
+ [NoAccessorMethod]
public string inner_html { owned get; set; }
public WebKit.DOM.Element last_element_child { get; }
+ public string local_name { owned get; }
+ public string namespace_uri { owned get; }
public WebKit.DOM.Element next_element_sibling { get; }
public double offset_height { get; }
public double offset_left { get; }
public WebKit.DOM.Element offset_parent { get; }
public double offset_top { get; }
public double offset_width { get; }
+ [NoAccessorMethod]
public string outer_html { owned get; set; }
+ public string prefix { owned get; }
public WebKit.DOM.Element previous_element_sibling { get; }
public long scroll_height { get; }
public long scroll_left { get; set; }
@@ -446,7 +797,6 @@ namespace WebKit {
public long scroll_width { get; }
public WebKit.DOM.CSSStyleDeclaration style { owned get; }
public string tag_name { owned get; }
- [NoAccessorMethod]
public string webkit_region_overset { owned get; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_entity_reference_get_type ()")]
@@ -479,8 +829,6 @@ namespace WebKit {
public bool cancel_bubble { get; set; }
public bool cancelable { get; }
public WebKit.DOM.EventTarget current_target { owned get; }
- [NoAccessorMethod]
- public bool default_prevented { get; }
public uint event_phase { get; }
public bool return_value { get; set; }
public WebKit.DOM.EventTarget src_element { owned get; }
@@ -545,22 +893,18 @@ namespace WebKit {
public void set_search (string value);
public void set_shape (string value);
public void set_target (string value);
+ [Version (since = "2.16")]
+ public void set_text (string value);
public void set_type_attr (string value);
public string charset { owned get; set; }
public string coords { owned get; set; }
- [NoAccessorMethod]
- public string download { owned get; set; }
public string hash { owned get; set; }
public string host { owned get; set; }
public string hostname { owned get; set; }
public string href { owned get; set; }
public string hreflang { owned get; set; }
public string name { owned get; set; }
- [NoAccessorMethod]
- public string origin { owned get; }
public string pathname { owned get; set; }
- [NoAccessorMethod]
- public string ping { owned get; set; }
public string port { owned get; set; }
public string protocol { owned get; set; }
public string rel { owned get; set; }
@@ -568,7 +912,6 @@ namespace WebKit {
public string search { owned get; set; }
public string shape { owned get; set; }
public string target { owned get; set; }
- [NoAccessorMethod]
public string text { owned get; set; }
[NoAccessorMethod]
public string type { owned get; set; }
@@ -632,25 +975,34 @@ namespace WebKit {
public string get_target ();
public void set_alt (string value);
public void set_coords (string value);
+ public void set_hash (string value);
+ [Version (since = "2.16")]
+ public void set_host (string value);
+ [Version (since = "2.16")]
+ public void set_hostname (string value);
public void set_href (string value);
public void set_no_href (bool value);
+ [Version (since = "2.16")]
+ public void set_pathname (string value);
+ [Version (since = "2.16")]
+ public void set_port (string value);
+ [Version (since = "2.16")]
+ public void set_protocol (string value);
+ [Version (since = "2.16")]
+ public void set_search (string value);
public void set_shape (string value);
public void set_target (string value);
public string alt { owned get; set; }
public string coords { owned get; set; }
- public string hash { owned get; }
- public string host { owned get; }
- public string hostname { owned get; }
+ public string hash { owned get; set; }
+ public string host { owned get; set; }
+ public string hostname { owned get; set; }
public string href { owned get; set; }
public bool no_href { get; set; }
- public string pathname { owned get; }
- [NoAccessorMethod]
- public string ping { owned get; set; }
- public string port { owned get; }
- public string protocol { owned get; }
- [NoAccessorMethod]
- public string rel { owned get; set; }
- public string search { owned get; }
+ public string pathname { owned get; set; }
+ public string port { owned get; set; }
+ public string protocol { owned get; set; }
+ public string search { owned get; set; }
public string shape { owned get; set; }
public string target { owned get; set; }
}
@@ -680,15 +1032,18 @@ namespace WebKit {
public class HTMLBaseFontElement : WebKit.DOM.HTMLElement, WebKit.DOM.EventTarget {
[CCode (has_construct_function = false)]
protected HTMLBaseFontElement ();
+ [Version (deprecated = true, deprecated_since = "2.12")]
public string get_color ();
+ [Version (deprecated = true, deprecated_since = "2.12")]
public string get_face ();
+ [Version (deprecated = true, deprecated_since = "2.12")]
public long get_size ();
+ [Version (deprecated = true, deprecated_since = "2.12")]
public void set_color (string value);
+ [Version (deprecated = true, deprecated_since = "2.12")]
public void set_face (string value);
+ [Version (deprecated = true, deprecated_since = "2.12")]
public void set_size (long value);
- public string color { owned get; set; }
- public string face { owned get; set; }
- public long size { get; set; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_html_body_element_get_type ()")]
[GIR (name = "DOMHTMLBodyElement")]
@@ -734,23 +1089,9 @@ namespace WebKit {
public bool autofocus { get; set; }
public bool disabled { get; set; }
public WebKit.DOM.HTMLFormElement form { get; }
- [NoAccessorMethod]
- public string form_action { owned get; set; }
- [NoAccessorMethod]
- public string form_enctype { owned get; set; }
- [NoAccessorMethod]
- public string form_method { owned get; set; }
- [NoAccessorMethod]
- public bool form_no_validate { get; set; }
- [NoAccessorMethod]
- public string form_target { owned get; set; }
- [NoAccessorMethod]
- public WebKit.DOM.NodeList labels { owned get; }
public string name { owned get; set; }
[NoAccessorMethod]
public string type { owned get; set; }
- [NoAccessorMethod]
- public string validation_message { owned get; }
public string value { owned get; set; }
public bool will_validate { get; }
}
@@ -813,20 +1154,26 @@ namespace WebKit {
public void close ();
public string get_alink_color ();
public string get_bg_color ();
+ [Version (deprecated = true, deprecated_since = "2.14")]
public string get_compat_mode ();
+ [Version (deprecated = true, deprecated_since = "2.14")]
public string get_design_mode ();
public string get_dir ();
+ [Version (deprecated = true, deprecated_since = "2.14")]
public WebKit.DOM.HTMLCollection get_embeds ();
public string get_fg_color ();
public long get_height ();
public string get_link_color ();
+ [Version (deprecated = true, deprecated_since = "2.14")]
public WebKit.DOM.HTMLCollection get_plugins ();
+ [Version (deprecated = true, deprecated_since = "2.14")]
public WebKit.DOM.HTMLCollection get_scripts ();
public string get_vlink_color ();
public long get_width ();
public void release_events ();
public void set_alink_color (string value);
public void set_bg_color (string value);
+ [Version (deprecated = true, deprecated_since = "2.14")]
public void set_design_mode (string value);
public void set_dir (string value);
public void set_fg_color (string value);
@@ -834,15 +1181,10 @@ namespace WebKit {
public void set_vlink_color (string value);
public string alink_color { owned get; set; }
public string bg_color { owned get; set; }
- public string compat_mode { owned get; }
- public string design_mode { owned get; set; }
public string dir { owned get; set; }
- public WebKit.DOM.HTMLCollection embeds { owned get; }
public string fg_color { owned get; set; }
public long height { get; }
public string link_color { owned get; set; }
- public WebKit.DOM.HTMLCollection plugins { owned get; }
- public WebKit.DOM.HTMLCollection scripts { owned get; }
public string vlink_color { owned get; set; }
public long width { get; }
}
@@ -853,50 +1195,68 @@ namespace WebKit {
protected HTMLElement ();
public void click ();
public string get_access_key ();
+ [Version (deprecated = true, deprecated_since = "2.10")]
public WebKit.DOM.HTMLCollection get_children ();
public string get_content_editable ();
public string get_dir ();
- [Deprecated (since = "2.8")]
+ [Version (since = "2.16")]
+ public bool get_draggable ();
+ [Version (since = "2.16")]
+ public bool get_hidden ();
+ [Version (deprecated = true, deprecated_since = "2.8")]
public string get_inner_html ();
public string get_inner_text ();
public bool get_is_content_editable ();
public string get_lang ();
- [Deprecated (since = "2.8")]
+ [Version (deprecated = true, deprecated_since = "2.8")]
public string get_outer_html ();
public string get_outer_text ();
+ [Version (since = "2.16")]
+ public bool get_spellcheck ();
public long get_tab_index ();
public string get_title ();
+ [Version (since = "2.16")]
+ public bool get_translate ();
+ [Version (since = "2.16")]
+ public string get_webkitdropzone ();
public void set_access_key (string value);
public void set_content_editable (string value) throws GLib.Error;
public void set_dir (string value);
- [Deprecated (since = "2.8")]
+ [Version (since = "2.16")]
+ public void set_draggable (bool value);
+ [Version (since = "2.16")]
+ public void set_hidden (bool value);
+ [Version (deprecated = true, deprecated_since = "2.8")]
public void set_inner_html (string contents) throws GLib.Error;
public void set_inner_text (string value) throws GLib.Error;
public void set_lang (string value);
- [Deprecated (since = "2.8")]
+ [Version (deprecated = true, deprecated_since = "2.8")]
public void set_outer_html (string contents) throws GLib.Error;
public void set_outer_text (string value) throws GLib.Error;
+ [Version (since = "2.16")]
+ public void set_spellcheck (bool value);
public void set_tab_index (long value);
public void set_title (string value);
+ [Version (since = "2.16")]
+ public void set_translate (bool value);
+ [Version (since = "2.16")]
+ public void set_webkitdropzone (string value);
public string access_key { owned get; set; }
- public WebKit.DOM.HTMLCollection children { owned get; }
+ [NoAccessorMethod]
public string content_editable { owned get; set; }
public string dir { owned get; set; }
- [NoAccessorMethod]
public bool draggable { get; set; }
- [NoAccessorMethod]
public bool hidden { get; set; }
+ [NoAccessorMethod]
public string inner_text { owned get; set; }
public bool is_content_editable { get; }
public string lang { owned get; set; }
- public string outer_text { owned get; set; }
[NoAccessorMethod]
+ public string outer_text { owned get; set; }
public bool spellcheck { get; set; }
public long tab_index { get; set; }
public string title { owned get; set; }
- [NoAccessorMethod]
public bool translate { get; set; }
- [NoAccessorMethod]
public string webkitdropzone { owned get; set; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_html_embed_element_get_type ()")]
@@ -930,19 +1290,7 @@ namespace WebKit {
[CCode (has_construct_function = false)]
protected HTMLFieldSetElement ();
public unowned WebKit.DOM.HTMLFormElement get_form ();
- [NoAccessorMethod]
- public bool disabled { get; set; }
- [NoAccessorMethod]
- public WebKit.DOM.HTMLCollection elements { owned get; }
public WebKit.DOM.HTMLFormElement form { get; }
- [NoAccessorMethod]
- public string name { owned get; set; }
- [NoAccessorMethod]
- public string type { owned get; }
- [NoAccessorMethod]
- public string validation_message { owned get; }
- [NoAccessorMethod]
- public bool will_validate { get; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_html_font_element_get_type ()")]
[GIR (name = "DOMHTMLFontElement")]
@@ -984,20 +1332,12 @@ namespace WebKit {
public void submit ();
public string accept_charset { owned get; set; }
public string action { owned get; set; }
- [NoAccessorMethod]
- public string autocapitalize { owned get; set; }
- [NoAccessorMethod]
- public string autocomplete { owned get; set; }
- [NoAccessorMethod]
- public bool autocorrect { get; set; }
public WebKit.DOM.HTMLCollection elements { owned get; }
public string encoding { owned get; set; }
public string enctype { owned get; set; }
public long length { get; }
public string method { owned get; set; }
public string name { owned get; set; }
- [NoAccessorMethod]
- public bool no_validate { get; set; }
public string target { owned get; set; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_html_frame_element_get_type ()")]
@@ -1093,8 +1433,6 @@ namespace WebKit {
protected HTMLHtmlElement ();
public string get_version ();
public void set_version (string value);
- [NoAccessorMethod]
- public string manifest { owned get; set; }
public string version { owned get; set; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", lower_case_cprefix = "webkit_dom_html_iframe_element_", type_id = "webkit_dom_html_iframe_element_get_type ()")]
@@ -1133,12 +1471,8 @@ namespace WebKit {
public string margin_height { owned get; set; }
public string margin_width { owned get; set; }
public string name { owned get; set; }
- [NoAccessorMethod]
- public string sandbox { owned get; set; }
public string scrolling { owned get; set; }
public string src { owned get; set; }
- [NoAccessorMethod]
- public string srcdoc { owned get; set; }
public string width { owned get; set; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_html_image_element_get_type ()")]
@@ -1181,10 +1515,6 @@ namespace WebKit {
public string alt { owned get; set; }
public string border { owned get; set; }
public bool complete { get; }
- [NoAccessorMethod]
- public string cross_origin { owned get; set; }
- [NoAccessorMethod]
- public string current_src { owned get; }
public long height { get; set; }
public long hspace { get; set; }
public bool is_map { get; set; }
@@ -1193,11 +1523,7 @@ namespace WebKit {
public string name { owned get; set; }
public long natural_height { get; }
public long natural_width { get; }
- [NoAccessorMethod]
- public string sizes { owned get; set; }
public string src { owned get; set; }
- [NoAccessorMethod]
- public string srcset { owned get; set; }
public string use_map { owned get; set; }
public long vspace { get; set; }
public long width { get; set; }
@@ -1212,8 +1538,13 @@ namespace WebKit {
public string get_accept ();
public string get_align ();
public string get_alt ();
+ [Version (since = "2.16")]
+ public bool get_auto_filled ();
public bool get_autofocus ();
+ [Version (deprecated = true, deprecated_since = "2.14")]
public bool get_capture ();
+ [Version (since = "2.14")]
+ public string get_capture_type ();
public bool get_checked ();
public bool get_default_checked ();
public string get_default_value ();
@@ -1226,6 +1557,8 @@ namespace WebKit {
public long get_max_length ();
public bool get_multiple ();
public string get_name ();
+ [Version (since = "2.16")]
+ public bool get_read_only ();
public ulong get_size ();
public string get_src ();
public string get_use_map ();
@@ -1237,10 +1570,18 @@ namespace WebKit {
public void set_accept (string value);
public void set_align (string value);
public void set_alt (string value);
+ [Version (since = "2.16")]
+ public void set_auto_filled (bool value);
public void set_autofocus (bool value);
+ [Version (since = "2.16")]
+ public void set_capture_type (string value);
public void set_checked (bool value);
+ [Version (since = "2.16")]
+ public void set_default_checked (bool value);
public void set_default_value (string value);
public void set_disabled (bool value);
+ [Version (since = "2.16")]
+ public void set_editing_value (string value);
public void set_files (WebKit.DOM.FileList value);
public void set_height (ulong value);
public void set_indeterminate (bool value);
@@ -1257,69 +1598,29 @@ namespace WebKit {
public string accept { owned get; set; }
public string align { owned get; set; }
public string alt { owned get; set; }
- [NoAccessorMethod]
- public string autocapitalize { owned get; set; }
- [NoAccessorMethod]
- public string autocomplete { owned get; set; }
- [NoAccessorMethod]
- public bool autocorrect { get; set; }
public bool autofocus { get; set; }
[NoAccessorMethod]
- public bool capture { get; set; }
+ public string capture { owned get; set; }
public bool checked { get; set; }
- [NoAccessorMethod]
public bool default_checked { get; set; }
public string default_value { owned get; set; }
- [NoAccessorMethod]
- public string dir_name { owned get; set; }
public bool disabled { get; set; }
public WebKit.DOM.FileList files { owned get; }
public WebKit.DOM.HTMLFormElement form { get; }
- [NoAccessorMethod]
- public string form_action { owned get; set; }
- [NoAccessorMethod]
- public string form_enctype { owned get; set; }
- [NoAccessorMethod]
- public string form_method { owned get; set; }
- [NoAccessorMethod]
- public bool form_no_validate { get; set; }
- [NoAccessorMethod]
- public string form_target { owned get; set; }
public ulong height { get; set; }
- [NoAccessorMethod]
- public bool incremental { get; set; }
public bool indeterminate { get; set; }
[NoAccessorMethod]
- public WebKit.DOM.NodeList labels { owned get; }
- [NoAccessorMethod]
- public WebKit.DOM.HTMLElement list { owned get; }
- [NoAccessorMethod]
- public string max { owned get; set; }
public long max_length { get; set; }
- [NoAccessorMethod]
- public string min { owned get; set; }
public bool multiple { get; set; }
public string name { owned get; set; }
- [NoAccessorMethod]
- public string pattern { owned get; set; }
- [NoAccessorMethod]
- public string placeholder { owned get; set; }
- [NoAccessorMethod]
public bool read_only { get; set; }
[NoAccessorMethod]
- public bool required { get; set; }
public ulong size { get; set; }
public string src { owned get; set; }
[NoAccessorMethod]
- public string step { owned get; set; }
- [NoAccessorMethod]
public string type { owned get; set; }
public string use_map { owned get; set; }
- [NoAccessorMethod]
- public string validation_message { owned get; }
public string value { owned get; set; }
- [NoAccessorMethod]
- public double value_as_number { get; set; }
public ulong width { get; set; }
public bool will_validate { get; }
}
@@ -1344,8 +1645,6 @@ namespace WebKit {
public unowned WebKit.DOM.HTMLFormElement get_form ();
public string get_html_for ();
public void set_html_for (string value);
- [NoAccessorMethod]
- public WebKit.DOM.HTMLElement control { owned get; }
public WebKit.DOM.HTMLFormElement form { get; }
public string html_for { owned get; set; }
}
@@ -1373,6 +1672,8 @@ namespace WebKit {
public string get_rel ();
public string get_rev ();
public WebKit.DOM.StyleSheet get_sheet ();
+ [Version (since = "2.16")]
+ public WebKit.DOM.DOMTokenList get_sizes ();
public string get_target ();
public string get_type_attr ();
public void set_charset (string value);
@@ -1382,6 +1683,8 @@ namespace WebKit {
public void set_media (string value);
public void set_rel (string value);
public void set_rev (string value);
+ [Version (since = "2.16")]
+ public void set_sizes (string value);
public void set_target (string value);
public void set_type_attr (string value);
public string charset { owned get; set; }
@@ -1392,6 +1695,7 @@ namespace WebKit {
public string rel { owned get; set; }
public string rev { owned get; set; }
public WebKit.DOM.StyleSheet sheet { owned get; }
+ public WebKit.DOM.DOMTokenList sizes { owned get; }
public string target { owned get; set; }
[NoAccessorMethod]
public string type { owned get; set; }
@@ -1414,28 +1718,6 @@ namespace WebKit {
protected HTMLMarqueeElement ();
public void start ();
public void stop ();
- [NoAccessorMethod]
- public string behavior { owned get; set; }
- [NoAccessorMethod]
- public string bg_color { owned get; set; }
- [NoAccessorMethod]
- public string direction { owned get; set; }
- [NoAccessorMethod]
- public string height { owned get; set; }
- [NoAccessorMethod]
- public ulong hspace { get; set; }
- [NoAccessorMethod]
- public long loop { get; set; }
- [NoAccessorMethod]
- public long scroll_amount { get; set; }
- [NoAccessorMethod]
- public long scroll_delay { get; set; }
- [NoAccessorMethod]
- public bool true_speed { get; set; }
- [NoAccessorMethod]
- public ulong vspace { get; set; }
- [NoAccessorMethod]
- public string width { owned get; set; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_html_menu_element_get_type ()")]
[GIR (name = "DOMHTMLMenuElement")]
@@ -1488,8 +1770,6 @@ namespace WebKit {
public void set_start (long value);
public void set_type_attr (string value);
public bool compact { get; set; }
- [NoAccessorMethod]
- public bool reversed { get; set; }
public long start { get; set; }
[NoAccessorMethod]
public string type { owned get; set; }
@@ -1550,12 +1830,8 @@ namespace WebKit {
[NoAccessorMethod]
public string type { owned get; set; }
public string use_map { owned get; set; }
- [NoAccessorMethod]
- public string validation_message { owned get; }
public long vspace { get; set; }
public string width { owned get; set; }
- [NoAccessorMethod]
- public bool will_validate { get; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_html_opt_group_element_get_type ()")]
[GIR (name = "DOMHTMLOptGroupElement")]
@@ -1669,23 +1945,18 @@ namespace WebKit {
public string get_src ();
public string get_text ();
public string get_type_attr ();
+ [Version (since = "2.16")]
+ public void set_charset (string value);
public void set_defer (bool value);
public void set_event (string value);
public void set_html_for (string value);
public void set_src (string value);
public void set_text (string value);
public void set_type_attr (string value);
- [NoAccessorMethod]
- public bool @async { get; set; }
- [NoAccessorMethod]
public string charset { owned get; set; }
- [NoAccessorMethod]
- public string cross_origin { owned get; set; }
public bool defer { get; set; }
public string event { owned get; set; }
public string html_for { owned get; set; }
- [NoAccessorMethod]
- public string nonce { owned get; set; }
public string src { owned get; set; }
public string text { owned get; set; }
[NoAccessorMethod]
@@ -1724,21 +1995,14 @@ namespace WebKit {
public bool disabled { get; set; }
public WebKit.DOM.HTMLFormElement form { get; }
[NoAccessorMethod]
- public WebKit.DOM.NodeList labels { owned get; }
public ulong length { get; set; }
public bool multiple { get; set; }
public string name { owned get; set; }
public WebKit.DOM.HTMLOptionsCollection options { owned get; }
- [NoAccessorMethod]
- public bool required { get; set; }
public long selected_index { get; set; }
- [NoAccessorMethod]
- public WebKit.DOM.HTMLCollection selected_options { owned get; }
public long size { get; set; }
[NoAccessorMethod]
public string type { owned get; }
- [NoAccessorMethod]
- public string validation_message { owned get; }
public string value { owned get; set; }
public bool will_validate { get; }
}
@@ -1886,8 +2150,6 @@ namespace WebKit {
public WebKit.DOM.HTMLTableCaptionElement caption { get; }
public string cell_padding { owned get; set; }
public string cell_spacing { owned get; set; }
- [NoAccessorMethod]
- public string frame { owned get; set; }
public WebKit.DOM.HTMLCollection rows { owned get; }
public string rules { owned get; set; }
public string summary { owned get; set; }
@@ -1978,42 +2240,20 @@ namespace WebKit {
public void set_selection_range (long start, long end, string direction);
public void set_selection_start (long value);
public void set_value (string value);
- [NoAccessorMethod]
- public string autocapitalize { owned get; set; }
- [NoAccessorMethod]
- public bool autocorrect { get; set; }
public bool autofocus { get; set; }
public long cols { get; set; }
public string default_value { owned get; set; }
- [NoAccessorMethod]
- public string dir_name { owned get; set; }
public bool disabled { get; set; }
public WebKit.DOM.HTMLFormElement form { get; }
- [NoAccessorMethod]
- public WebKit.DOM.NodeList labels { owned get; }
- [NoAccessorMethod]
- public long max_length { get; set; }
public string name { owned get; set; }
- [NoAccessorMethod]
- public string placeholder { owned get; set; }
public bool read_only { get; set; }
- [NoAccessorMethod]
- public bool required { get; set; }
public long rows { get; set; }
- [NoAccessorMethod]
- public string selection_direction { owned get; set; }
public long selection_end { get; set; }
public long selection_start { get; set; }
[NoAccessorMethod]
- public ulong text_length { get; }
- [NoAccessorMethod]
public string type { owned get; }
- [NoAccessorMethod]
- public string validation_message { owned get; }
public string value { owned get; set; }
public bool will_validate { get; }
- [NoAccessorMethod]
- public string wrap { owned get; set; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_html_title_element_get_type ()")]
[GIR (name = "DOMHTMLTitleElement")]
@@ -2071,6 +2311,7 @@ namespace WebKit {
public string item (ulong index);
public void set_media_text (string value) throws GLib.Error;
public ulong length { get; }
+ [NoAccessorMethod]
public string media_text { owned get; set; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_mouse_event_get_type ()")]
@@ -2102,10 +2343,6 @@ namespace WebKit {
public bool ctrl_key { get; }
public WebKit.DOM.Node from_element { get; }
public bool meta_key { get; }
- [NoAccessorMethod]
- public long movement_x { get; }
- [NoAccessorMethod]
- public long movement_y { get; }
public long offset_x { get; }
public long offset_y { get; }
public WebKit.DOM.EventTarget related_target { owned get; }
@@ -2137,14 +2374,19 @@ namespace WebKit {
[CCode (has_construct_function = false)]
protected Node ();
public unowned WebKit.DOM.Node append_child (WebKit.DOM.Node newChild) throws GLib.Error;
- public unowned WebKit.DOM.Node clone_node (bool deep);
+ [Version (deprecated = true, deprecated_since = "2.14")]
+ public unowned WebKit.DOM.Node clone_node (bool deep) throws GLib.Error;
+ [Version (since = "2.14")]
+ public unowned WebKit.DOM.Node clone_node_with_error (bool deep) throws GLib.Error;
public ushort compare_document_position (WebKit.DOM.Node other);
public bool contains (WebKit.DOM.Node other);
public string get_base_uri ();
public WebKit.DOM.NodeList get_child_nodes ();
public unowned WebKit.DOM.Node get_first_child ();
public unowned WebKit.DOM.Node get_last_child ();
+ [Version (deprecated = true, deprecated_since = "2.14")]
public string get_local_name ();
+ [Version (deprecated = true, deprecated_since = "2.14")]
public string get_namespace_uri ();
public unowned WebKit.DOM.Node get_next_sibling ();
public string get_node_name ();
@@ -2153,6 +2395,7 @@ namespace WebKit {
public unowned WebKit.DOM.Document get_owner_document ();
public unowned WebKit.DOM.Element get_parent_element ();
public unowned WebKit.DOM.Node get_parent_node ();
+ [Version (deprecated = true, deprecated_since = "2.14")]
public string get_prefix ();
public unowned WebKit.DOM.Node get_previous_sibling ();
public string get_text_content ();
@@ -2168,23 +2411,23 @@ namespace WebKit {
public unowned WebKit.DOM.Node remove_child (WebKit.DOM.Node oldChild) throws GLib.Error;
public unowned WebKit.DOM.Node replace_child (WebKit.DOM.Node newChild, WebKit.DOM.Node oldChild) throws GLib.Error;
public void set_node_value (string value) throws GLib.Error;
+ [Version (deprecated = true, deprecated_since = "2.14")]
public void set_prefix (string value) throws GLib.Error;
public void set_text_content (string value) throws GLib.Error;
public string base_uri { owned get; }
public WebKit.DOM.NodeList child_nodes { owned get; }
public WebKit.DOM.Node first_child { get; }
public WebKit.DOM.Node last_child { get; }
- public string local_name { owned get; }
- public string namespace_uri { owned get; }
public WebKit.DOM.Node next_sibling { get; }
public string node_name { owned get; }
public uint node_type { get; }
+ [NoAccessorMethod]
public string node_value { owned get; set; }
public WebKit.DOM.Document owner_document { get; }
public WebKit.DOM.Element parent_element { get; }
public WebKit.DOM.Node parent_node { get; }
- public string prefix { owned get; set; }
public WebKit.DOM.Node previous_sibling { get; }
+ [NoAccessorMethod]
public string text_content { owned get; set; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_node_iterator_get_type ()")]
@@ -2193,6 +2436,7 @@ namespace WebKit {
[CCode (has_construct_function = false)]
protected NodeIterator ();
public void detach ();
+ [Version (deprecated = true, deprecated_since = "2.12")]
public bool get_expand_entity_references ();
public WebKit.DOM.NodeFilter get_filter ();
public bool get_pointer_before_reference_node ();
@@ -2201,7 +2445,6 @@ namespace WebKit {
public ulong get_what_to_show ();
public unowned WebKit.DOM.Node next_node () throws GLib.Error;
public unowned WebKit.DOM.Node previous_node () throws GLib.Error;
- public bool expand_entity_references { get; }
public WebKit.DOM.NodeFilter filter { owned get; }
public bool pointer_before_reference_node { get; }
public WebKit.DOM.Node reference_node { get; }
@@ -2223,6 +2466,7 @@ namespace WebKit {
public void* coreObject;
[CCode (has_construct_function = false)]
protected Object ();
+ [NoAccessorMethod]
public void* core_object { construct; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_processing_instruction_get_type ()")]
@@ -2249,6 +2493,8 @@ namespace WebKit {
public unowned WebKit.DOM.DocumentFragment create_contextual_fragment (string html) throws GLib.Error;
public void delete_contents () throws GLib.Error;
public void detach () throws GLib.Error;
+ [Version (since = "2.16")]
+ public void expand (string unit) throws GLib.Error;
public unowned WebKit.DOM.DocumentFragment extract_contents () throws GLib.Error;
public bool get_collapsed () throws GLib.Error;
public unowned WebKit.DOM.Node get_common_ancestor_container () throws GLib.Error;
@@ -2270,11 +2516,17 @@ namespace WebKit {
public void set_start_before (WebKit.DOM.Node refNode) throws GLib.Error;
public void surround_contents (WebKit.DOM.Node newParent) throws GLib.Error;
public string to_string () throws GLib.Error;
+ [NoAccessorMethod]
public bool collapsed { get; }
- public WebKit.DOM.Node common_ancestor_container { get; }
- public WebKit.DOM.Node end_container { get; }
+ [NoAccessorMethod]
+ public WebKit.DOM.Node common_ancestor_container { owned get; }
+ [NoAccessorMethod]
+ public WebKit.DOM.Node end_container { owned get; }
+ [NoAccessorMethod]
public long end_offset { get; }
- public WebKit.DOM.Node start_container { get; }
+ [NoAccessorMethod]
+ public WebKit.DOM.Node start_container { owned get; }
+ [NoAccessorMethod]
public long start_offset { get; }
public string text { owned get; }
}
@@ -2315,6 +2567,7 @@ namespace WebKit {
[CCode (has_construct_function = false)]
protected Text ();
public string get_whole_text ();
+ [Version (deprecated = true, deprecated_since = "2.14")]
public unowned WebKit.DOM.Text replace_whole_text (string content) throws GLib.Error;
public unowned WebKit.DOM.Text split_text (ulong offset) throws GLib.Error;
public string whole_text { owned get; }
@@ -2326,6 +2579,7 @@ namespace WebKit {
protected TreeWalker ();
public unowned WebKit.DOM.Node first_child ();
public unowned WebKit.DOM.Node get_current_node ();
+ [Version (deprecated = true, deprecated_since = "2.12")]
public bool get_expand_entity_references ();
public WebKit.DOM.NodeFilter get_filter ();
public unowned WebKit.DOM.Node get_root ();
@@ -2338,7 +2592,6 @@ namespace WebKit {
public unowned WebKit.DOM.Node previous_sibling ();
public void set_current_node (WebKit.DOM.Node value) throws GLib.Error;
public WebKit.DOM.Node current_node { get; }
- public bool expand_entity_references { get; }
public WebKit.DOM.NodeFilter filter { owned get; }
public WebKit.DOM.Node root { get; }
public ulong what_to_show { get; }
@@ -2365,8 +2618,6 @@ namespace WebKit {
public long page_x { get; }
public long page_y { get; }
public WebKit.DOM.DOMWindow view { owned get; }
- [NoAccessorMethod]
- public long which { get; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_wheel_event_get_type ()")]
[GIR (name = "DOMWheelEvent")]
@@ -2377,16 +2628,6 @@ namespace WebKit {
public long get_wheel_delta_x ();
public long get_wheel_delta_y ();
public void init_wheel_event (long wheelDeltaX, long wheelDeltaY, WebKit.DOM.DOMWindow view, long screenX, long screenY, long clientX, long clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
- [NoAccessorMethod]
- public ulong delta_mode { get; }
- [NoAccessorMethod]
- public double delta_x { get; }
- [NoAccessorMethod]
- public double delta_y { get; }
- [NoAccessorMethod]
- public double delta_z { get; }
- [NoAccessorMethod]
- public bool webkit_direction_inverted_from_device { get; }
public long wheel_delta { get; }
public long wheel_delta_x { get; }
public long wheel_delta_y { get; }
@@ -2412,21 +2653,27 @@ namespace WebKit {
public string get_string_value () throws GLib.Error;
public unowned WebKit.DOM.Node iterate_next () throws GLib.Error;
public unowned WebKit.DOM.Node snapshot_item (ulong index) throws GLib.Error;
+ [NoAccessorMethod]
public bool boolean_value { get; }
public bool invalid_iterator_state { get; }
+ [NoAccessorMethod]
public double number_value { get; }
public uint result_type { get; }
- public WebKit.DOM.Node single_node_value { get; }
+ [NoAccessorMethod]
+ public WebKit.DOM.Node single_node_value { owned get; }
+ [NoAccessorMethod]
public ulong snapshot_length { get; }
+ [NoAccessorMethod]
public string string_value { owned get; }
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_event_target_get_type ()")]
[GIR (name = "DOMEventTarget")]
public interface EventTarget : GLib.Object {
- public bool add_event_listener_with_closure (string event_name, [CCode (type = "GClosure*")] owned WebKit.DOM.EventTargetFunc handler, bool use_capture);
+ [CCode (vfunc_name = "add_event_listener")]
+ public abstract bool add_event_listener_with_closure (string event_name, [CCode (type = "GClosure*")] owned WebKit.DOM.EventTargetFunc handler, bool use_capture);
public abstract bool dispatch_event (WebKit.DOM.Event event) throws GLib.Error;
- public abstract bool remove_event_listener (string event_name, GLib.Closure handler, bool use_capture);
- public bool remove_event_listener_with_closure (string event_name, GLib.Closure handler, bool use_capture);
+ [CCode (vfunc_name = "remove_event_listener")]
+ public abstract bool remove_event_listener_with_closure (string event_name, [CCode (type = "GClosure*")] owned WebKit.DOM.EventTargetFunc handler, bool use_capture);
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_dom_node_filter_get_type ()")]
[GIR (name = "DOMNodeFilter")]
@@ -2462,6 +2709,8 @@ namespace WebKit {
public const int _CSS_VALUE_CSS_PRIMITIVE_VALUE;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_CSS_VALUE_CSS_VALUE_LIST")]
public const int _CSS_VALUE_CSS_VALUE_LIST;
+ [CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_ELEMENT_ALLOW_KEYBOARD_INPUT")]
+ public const int _ELEMENT_ALLOW_KEYBOARD_INPUT;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_EVENT_AT_TARGET")]
public const int _EVENT_AT_TARGET;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_EVENT_BLUR")]
@@ -2541,36 +2790,52 @@ namespace WebKit {
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_ENTITY_REFERENCE_NODE")]
public const int _NODE_ENTITY_REFERENCE_NODE;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_ACCEPT")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_ACCEPT;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_REJECT")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_REJECT;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_SHOW_ALL")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_SHOW_ALL;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_SHOW_ATTRIBUTE")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_SHOW_ATTRIBUTE;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_SHOW_CDATA_SECTION")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_SHOW_CDATA_SECTION;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_SHOW_COMMENT")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_SHOW_COMMENT;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_SHOW_DOCUMENT")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_SHOW_DOCUMENT;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_SHOW_DOCUMENT_FRAGMENT")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_SHOW_DOCUMENT_FRAGMENT;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_SHOW_DOCUMENT_TYPE")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_SHOW_DOCUMENT_TYPE;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_SHOW_ELEMENT")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_SHOW_ELEMENT;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_SHOW_ENTITY")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_SHOW_ENTITY;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_SHOW_ENTITY_REFERENCE")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_SHOW_ENTITY_REFERENCE;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_SHOW_NOTATION")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_SHOW_NOTATION;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_SHOW_PROCESSING_INSTRUCTION")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_SHOW_PROCESSING_INSTRUCTION;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_SHOW_TEXT")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_SHOW_TEXT;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_FILTER_SKIP")]
+ [Version (since = "2.6")]
public const int _NODE_FILTER_SKIP;
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_NODE_PROCESSING_INSTRUCTION_NODE")]
public const int _NODE_PROCESSING_INSTRUCTION_NODE;
@@ -2613,33 +2878,68 @@ namespace WebKit {
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cname = "WEBKIT_DOM_XPATH_RESULT_UNORDERED_NODE_SNAPSHOT_TYPE")]
public const int _XPATH_RESULT_UNORDERED_NODE_SNAPSHOT_TYPE;
}
+ [CCode (cheader_filename = "webkit2/webkit-web-extension.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "webkit_console_message_get_type ()")]
+ [Compact]
+ public class ConsoleMessage {
+ [Version (since = "2.12")]
+ public WebKit.ConsoleMessage copy ();
+ [Version (since = "2.12")]
+ public void free ();
+ [Version (since = "2.12")]
+ public WebKit.ConsoleMessageLevel get_level ();
+ [Version (since = "2.12")]
+ public uint get_line ();
+ [Version (since = "2.12")]
+ public WebKit.ConsoleMessageSource get_source ();
+ [Version (since = "2.12")]
+ public unowned string get_source_id ();
+ [Version (since = "2.12")]
+ public unowned string get_text ();
+ }
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_context_menu_get_type ()")]
public class ContextMenu : GLib.Object {
[CCode (has_construct_function = false)]
public ContextMenu ();
public void append (WebKit.ContextMenuItem item);
+ public unowned WebKit.ContextMenuItem first ();
+ public unowned WebKit.ContextMenuItem get_item_at_position (uint position);
+ public unowned GLib.List<WebKit.ContextMenuItem> get_items ();
public uint get_n_items ();
- public GLib.Variant get_user_data ();
+ [Version (since = "2.8")]
+ public unowned GLib.Variant get_user_data ();
public void insert (WebKit.ContextMenuItem item, int position);
+ public unowned WebKit.ContextMenuItem last ();
public void move_item (WebKit.ContextMenuItem item, int position);
public void prepend (WebKit.ContextMenuItem item);
public void remove (WebKit.ContextMenuItem item);
public void remove_all ();
+ [Version (since = "2.8")]
public void set_user_data (GLib.Variant user_data);
+ [CCode (has_construct_function = false)]
+ public ContextMenu.with_items (GLib.List<WebKit.ContextMenuItem> items);
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_context_menu_item_get_type ()")]
public class ContextMenuItem : GLib.InitiallyUnowned {
[CCode (has_construct_function = false)]
+ [Version (deprecated = true, deprecated_since = "2.18")]
public ContextMenuItem (Gtk.Action action);
[CCode (has_construct_function = false)]
+ [Version (since = "2.18")]
+ public ContextMenuItem.from_gaction (GLib.Action action, string label, GLib.Variant? target);
+ [CCode (has_construct_function = false)]
public ContextMenuItem.from_stock_action (WebKit.ContextMenuAction action);
[CCode (has_construct_function = false)]
public ContextMenuItem.from_stock_action_with_label (WebKit.ContextMenuAction action, string label);
+ [Version (deprecated = true, deprecated_since = "2.18")]
+ public unowned Gtk.Action get_action ();
+ [Version (since = "2.18")]
+ public unowned GLib.Action get_gaction ();
public WebKit.ContextMenuAction get_stock_action ();
+ public unowned WebKit.ContextMenu get_submenu ();
public bool is_separator ();
[CCode (has_construct_function = false)]
public ContextMenuItem.separator ();
- public void set_submenu (WebKit.ContextMenu submenu);
+ public void set_submenu (WebKit.ContextMenu? submenu);
[CCode (has_construct_function = false)]
public ContextMenuItem.with_submenu (string label, WebKit.ContextMenu submenu);
}
@@ -2647,9 +2947,13 @@ namespace WebKit {
public class Frame : GLib.Object {
[CCode (has_construct_function = false)]
protected Frame ();
- public void* get_javascript_context_for_script_world (WebKit.ScriptWorld world);
- public void* get_javascript_global_context ();
+ [Version (since = "2.2")]
+ public unowned JS.GlobalContext get_javascript_context_for_script_world (WebKit.ScriptWorld world);
+ [Version (since = "2.2")]
+ public unowned JS.GlobalContext get_javascript_global_context ();
+ [Version (since = "2.2")]
public unowned string get_uri ();
+ [Version (since = "2.2")]
public bool is_main_frame ();
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_hit_test_result_get_type ()")]
@@ -2661,6 +2965,7 @@ namespace WebKit {
public bool context_is_link ();
public bool context_is_media ();
public bool context_is_scrollbar ();
+ [Version (since = "2.8")]
public bool context_is_selection ();
public uint get_context ();
public unowned string get_image_uri ();
@@ -2678,15 +2983,20 @@ namespace WebKit {
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_script_world_get_type ()")]
public class ScriptWorld : GLib.Object {
[CCode (has_construct_function = false)]
+ [Version (since = "2.2")]
public ScriptWorld ();
+ [Version (since = "2.2")]
public static unowned WebKit.ScriptWorld get_default ();
+ [Version (since = "2.2")]
public signal void window_object_cleared (WebKit.WebPage page, WebKit.Frame frame);
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_uri_request_get_type ()")]
public class URIRequest : GLib.Object {
[CCode (has_construct_function = false)]
public URIRequest (string uri);
- public Soup.MessageHeaders get_http_headers ();
+ public unowned Soup.MessageHeaders get_http_headers ();
+ [Version (since = "2.12")]
+ public unowned string get_http_method ();
public unowned string get_uri ();
public void set_uri (string uri);
public string uri { get; set construct; }
@@ -2696,18 +3006,29 @@ namespace WebKit {
[CCode (has_construct_function = false)]
protected URIResponse ();
public uint64 get_content_length ();
- public Soup.MessageHeaders get_http_headers ();
+ [Version (since = "2.6")]
+ public unowned Soup.MessageHeaders get_http_headers ();
public unowned string get_mime_type ();
public uint get_status_code ();
public unowned string get_suggested_filename ();
public unowned string get_uri ();
public uint64 content_length { get; }
- public Soup.MessageHeaders http_headers { owned get; }
+ [Version (since = "2.6")]
+ public Soup.MessageHeaders http_headers { get; }
public string mime_type { get; }
public uint status_code { get; }
public string suggested_filename { get; }
public string uri { get; }
}
+ [CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_web_editor_get_type ()")]
+ public class WebEditor : GLib.Object {
+ [CCode (has_construct_function = false)]
+ protected WebEditor ();
+ [Version (since = "2.10")]
+ public unowned WebKit.WebPage get_page ();
+ [Version (since = "2.10")]
+ public signal void selection_changed ();
+ }
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", type_id = "webkit_web_extension_get_type ()")]
public class WebExtension : GLib.Object {
[CCode (has_construct_function = false)]
@@ -2719,6 +3040,7 @@ namespace WebKit {
public class WebHitTestResult : WebKit.HitTestResult {
[CCode (has_construct_function = false)]
protected WebHitTestResult ();
+ [Version (since = "2.8")]
public unowned WebKit.DOM.Node get_node ();
public WebKit.DOM.Node node { get; construct; }
}
@@ -2727,13 +3049,41 @@ namespace WebKit {
[CCode (has_construct_function = false)]
protected WebPage ();
public unowned WebKit.DOM.Document get_dom_document ();
+ [Version (since = "2.10")]
+ public unowned WebKit.WebEditor get_editor ();
public uint64 get_id ();
+ [Version (since = "2.2")]
public unowned WebKit.Frame get_main_frame ();
public unowned string get_uri ();
public string uri { get; }
+ [Version (since = "2.12")]
+ public signal void console_message_sent (WebKit.ConsoleMessage console_message);
+ [Version (since = "2.8")]
public signal bool context_menu (WebKit.ContextMenu context_menu, WebKit.WebHitTestResult hit_test_result);
public signal void document_loaded ();
+ [Version (since = "2.16")]
+ public signal void form_controls_associated (GLib.GenericArray<WebKit.DOM.Element> elements);
public signal bool send_request (WebKit.URIRequest request, WebKit.URIResponse redirected_response);
+ [Version (since = "2.20")]
+ public signal void will_submit_form (WebKit.DOM.Element form, WebKit.FormSubmissionStep step, WebKit.Frame source_frame, WebKit.Frame target_frame, GLib.GenericArray<string> text_field_names, GLib.GenericArray<string> text_field_values);
+ }
+ [CCode (cheader_filename = "webkit2/webkit-web-extension.h", cprefix = "WEBKIT_CONSOLE_MESSAGE_LEVEL_", type_id = "webkit_console_message_level_get_type ()")]
+ [Version (since = "2.12")]
+ public enum ConsoleMessageLevel {
+ INFO,
+ LOG,
+ WARNING,
+ ERROR,
+ DEBUG
+ }
+ [CCode (cheader_filename = "webkit2/webkit-web-extension.h", cprefix = "WEBKIT_CONSOLE_MESSAGE_SOURCE_", type_id = "webkit_console_message_source_get_type ()")]
+ [Version (since = "2.12")]
+ public enum ConsoleMessageSource {
+ JAVASCRIPT,
+ NETWORK,
+ CONSOLE_API,
+ SECURITY,
+ OTHER
}
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cprefix = "WEBKIT_CONTEXT_MENU_ACTION_", has_type_id = false)]
public enum ContextMenuAction {
@@ -2783,6 +3133,12 @@ namespace WebKit {
DOWNLOAD_AUDIO_TO_DISK,
CUSTOM
}
+ [CCode (cheader_filename = "webkit2/webkit-web-extension.h", cprefix = "WEBKIT_FORM_SUBMISSION_WILL_", type_id = "webkit_form_submission_step_get_type ()")]
+ [Version (since = "2.20")]
+ public enum FormSubmissionStep {
+ SEND_DOM_EVENT,
+ COMPLETE
+ }
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", cprefix = "WEBKIT_HIT_TEST_RESULT_CONTEXT_", has_type_id = false)]
[Flags]
public enum HitTestResultContext {
@@ -2797,5 +3153,6 @@ namespace WebKit {
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", has_target = false)]
public delegate void WebExtensionInitializeFunction (WebKit.WebExtension extension);
[CCode (cheader_filename = "webkit2/webkit-web-extension.h", has_target = false)]
+ [Version (since = "2.4")]
public delegate void WebExtensionInitializeWithUserDataFunction (WebKit.WebExtension extension, GLib.Variant user_data);
}
diff --git a/win32/makedist/makedist.midori b/win32/makedist/makedist.midori
deleted file mode 100755
index 0d3ef438..00000000
--- a/win32/makedist/makedist.midori
+++ /dev/null
@@ -1,394 +0,0 @@
-#! /bin/sh
-
-# Copyright (C) 2010-2011 Peter de Ridder <peter@xfce.org>
-# Copyright (C) 2012 Paweł Forysiuk <tuxator@o2.pl>
-#
-# 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.
-
-# script: makedist.midori [version tag]
-#
-# This script creates an archive containing all required files for
-# midori on windows. The midori version is inserted in the name of
-# the archive and appended to the name of the root directory in the
-# archive.
-# The name of the archive is contructed as follows:
-# midori<version tag>-<timestamp>.extension
-# The archive contains a root directory named:
-# midori<version tag>
-
-# a bit of configuration
-root_dir=$MINGW_PREFIX
-where_am_i=$PWD
-
-if [ "$GSTREAMER_API_VERSION" == "" ]; then
- WEBKIT_VER=$(grep -E '(DEPS_GTK_webkitgtk\-)(.*)(_VERSION)' CMakeCache.txt|cut -d \= -f 2 |cut -c 1)
- if [ "$WEBKIT_VER" == "2" ]; then
- GSTREAMER_API_VERSION=1.0
- else
- GSTREAMER_API_VERSION=0.10
- fi
-fi
-
-if [ "$MINGW_PREFIX" == "" ]; then
- echo "Error: MINGW_PREFIX variable is empty!"
- exit
-fi
-
-# create temporary working directory
-temp_dir=`mktemp -d`
-
-# check if we can use 7zip
-have_7zip=`which 7za`
-
-GTK3_BUILD=1
-# Default to gtk3 but check just in case
-GTK3=$(grep GTK3 CMakeCache.txt | awk -F \= '{print $2}')
-if [ "$GTK3" != "ON" ] && [ "$GTK3" != "1" ];then
- GTK3_BUILD=0
-fi
-
-version=$(grep PACKAGE_VERSION ./midori/CMakeFiles/midori.dir/DependInfo.cmake|sed -e 's/^.*PACKAGE_VERSION=\\"\([^"]*\)\\".*$/\1/')
-
-#strip sha from version if release
-if [ "$RELEASE" != "" ];then
- version=$(echo $version| awk -F \~ '{print $1}')
-fi
-
-if [ "$1" != "" ]; then
- version_tag="$1"
-fi
-
-if [ "$version_tag" != "" ]; then
- version_tag=$version-$version_tag
-else
- version_tag=$version
-fi
-
-if [ "$RELEASE" == "" ]; then
- ARCHIVE_FILENAME=midori-$version_tag-`date +%Y%m%d%H%M`
-else
- ARCHIVE_FILENAME=midori-$version_tag
-fi
-
-# generate archive filename
-if [ "$have_7zip" != "" ]; then
- ARCHIVE=$ARCHIVE_FILENAME.7z
-else
- ARCHIVE=$ARCHIVE_FILENAME.zip
-fi
-
-if [ "NSIS" != "" ];then
- cp -a $where_am_i/../win32/makedist/midori.nsi $temp_dir
- cp -a $where_am_i/../win32/makedist/midori.ico $temp_dir
-fi
-
-# function: dll-recursive <list of exe and dll files ...>
-#
-# recursively search all dll dependencies of the input files.
-# The resulting list of dll files including the input files is
-# printed to stdout.
-dll_recursive ()
-{
- temp_file_new=`mktemp`
- temp_file_old=`mktemp`
-
- while [ "$1" ]
- do
- echo $1 >> $temp_file_new
- shift
- done
-
- while [ "x`sha1sum - < $temp_file_new`" != "x`sha1sum - < $temp_file_old`" ]
- do
- files=`cat $temp_file_new $temp_file_old | sort | uniq -u`
- cp -L $temp_file_new $temp_file_old
- strings $files 2> /dev/null | grep \\.dll | cat - $temp_file_old | sort | uniq > $temp_file_new
- done
-
- cat $temp_file_new
-
- rm $temp_file_new $temp_file_old
-}
-
-grab_files ()
-{
- local dir="$1"
- pushd $root_dir > /dev/null
- shift
- while [ "$1" ]; do
- find $dir "(" -name "$1" ")" -prune -exec mkdir -p $workdir/{} ";" -exec rmdir --ignore-fail-on-non-empty $workdir/{} ";" -exec cp -Lr {} $workdir/{} ";"
- if [ "$?" -ne "0" ]; then
- exit
- fi
- shift
- done
- popd > /dev/null
-}
-
-grab_icons()
-{
- local theme="$1"
- local list="$2"
-
- sizes=$(grep CreateDirectory $list |awk -F '"' '{print $2}' |awk -F '\' '{print $6}')
- categories=$(grep InstallIconTheme $list | awk -F '"' '{print $2}'|sort|uniq)
-
-
- for category in $categories
- do
- category_icons=$(grep InstallIconTheme $list |grep $category|awk -F '"' '{print $4}')
- for size in $sizes
- do
- mkdir -p $workdir/share/icons/$theme/$category/$size
- for icon in $category_icons
- do
- cp -L /usr/share/icons/$theme/$category/$size/$icon.* $workdir/share/icons/$theme/$category/$size/
- done
- done
- done
-
- cp -L /usr/share/icons/$theme/index.theme $workdir/share/icons/$theme
-
-}
-
-echo "Creating $ARCHIVE"
-
-# create destination folder
-workdir=$temp_dir/midori-$version
-mkdir $workdir
-
-echo "<*> Generating dll list..."
-
-# auto generate dll list, only of existing files
-pushd $root_dir/bin > /dev/null
-dll_recursive midori*.exe gspawn-*-helper*.exe libhunspell*.dll > $temp_dir/midori.exe.lst
-dll_recursive ../lib/gio/modules/*.dll >> $temp_dir/midori.exe.lst
-dll_recursive iconv.dll >> $temp_dir/midori.exe.lst
-# we ship gdb now for -g and diagnostic button
-dll_recursive gdb.exe >> $temp_dir/midori.exe.lst
-
-for i in $(cat $temp_dir/midori.exe.lst | grep -v midori | sort | uniq)
-do
- if [ -f $root_dir/bin/$i ]; then
- rpm -qf $root_dir/bin/$i >> $temp_dir/packages_used.lst
- fi
-done
-
-dll_recursive ../lib/gstreamer-$GSTREAMER_API_VERSION/*.dll >> $temp_dir/midori.exe.lst
-rpm -qf $root_dir/lib/gstreamer-$GSTREAMER_API_VERSION/*.dll >> $temp_dir/packages_used.lst
-
-if [ "$DEBUG_BUILD" != "" ]; then
- dll_recursive GtkLauncher.exe >> $temp_dir/midori.exe.lst
-fi
-
-files=`ls | cat - $temp_dir/midori.exe.lst | sort | uniq -d`
-rm $temp_dir/midori.exe.lst
-popd > /dev/null
-
-echo "<*> Copying dlls..."
-
-# copy auto generate dll list
-pushd $root_dir/bin > /dev/null
-mkdir $workdir/bin
-cp -L $files $workdir/bin 2>/dev/null
-popd > /dev/null
-
-mkdir -p $workdir/bin/Plugins
-cat > $workdir/bin/portable.bat << _EOF
-@ECHO OFF
-echo Starting Midori in portable mode!
-start midori.exe --portable
-pause
-_EOF
-
-echo "<*> Copying configuration files..."
-
-# copy etc
-grab_files etc midori
-grab_files etc gtkrc
-
-# If modules are not compiled we need a list of them
-grab_files etc pango
-# Freetype is preferred font backend
-# copy configuration, otherwise webkit will crash
-grab_files etc fonts
-
-
-echo "<*> Copying modules and libraries..."
-
-# copy lib
-if [ "$GTK3_BUILD" == "1" ]; then
- grab_files lib gtk-3.0
-else
- grab_files lib gtk-2.0
-fi
-
-grab_files lib midori
-grab_files lib gdk-pixbuf-2.0
-
-grab_files lib enchant
-grab_files lib gio
-
-# Fedora ships on-demand pango modules, check just in case
-grab_files lib pango
-
-grab_files lib gstreamer-$GSTREAMER_API_VERSION
-
-echo "<*> Copying resources and translations..."
-
-# copy share
-grab_files share midori
-grab_files share mime
-grab_files share midori.mo
-
-grab_icons Faenza $where_am_i/../win32/makedist/midori.nsi
-
-# We need to ship our CA bundle for now
-cp -Lr /etc/pki/tls/certs/ca-bundle.crt $workdir/share/midori/res/
-
-GREYBIRD_VER="1.5.3"
-
-if [ "$GTK3_BUILD" == "1" ]; then
- grab_files share webkitgtk-3.0
- grab_files share schemas
-
- wget --no-verbose "https://github.com/shimmerproject/Greybird/archive/v$GREYBIRD_VER.tar.gz" -P $temp_dir
- tar xf "$temp_dir/v$GREYBIRD_VER.tar.gz" -C $temp_dir
- mkdir -p $workdir/share/themes/Greybird
- cp -Lr $temp_dir/Greybird-$GREYBIRD_VER/gtk-3.0 $workdir/share/themes/Greybird
- MO_VER=30
-else
- grab_files share MS-Windows
- grab_files share webkitgtk-1.0
- MO_VER=20
-fi
-
-if [ "$DEBUG_BUILD" == "" ];then
- pushd $workdir > /dev/null
- find -iname *.debug -exec rm {} \;
- popd > /dev/null
-fi
-
-rpm -qf /etc/pki/tls/certs/ca-bundle.crt >> $temp_dir/packages_used.lst
-rpm -qf /usr/share/icons/Faenza/ >> $temp_dir/packages_used.lst
-echo "https://github.com/shimmerproject/Greybird/archive/v$GREYBIRD_VER.tar.gz" >> $temp_dir/packages_used.lst
-
-pushd $temp_dir > /dev/null
-wget --no-verbose "https://github.com/jrfonseca/drmingw/releases/download/0.7.3/drmingw-0.7.3-win32.zip" -P $temp_dir
-unzip "$temp_dir/drmingw-0.7.3-win32.zip"
-cp -Lr $temp_dir/drmingw-0.7.3-win32/bin/{mgwhelp.dll,exchndl.dll} $workdir/bin
-popd > /dev/null
-
-# copy locales for gtk
-# so we have translated stock items, file dialogs
-
-pushd $root_dir > /dev/null
-find share "(" -name "midori.mo" ")" > $temp_dir/locale.list
-mkdir -p $workdir/share/locale/
-for LOCALE in $(cat $temp_dir/locale.list); do
- LOCALE=$(echo $LOCALE|awk -F/ '{print $3}')
- cp /usr/share/locale/$LOCALE/LC_MESSAGES/gtk$MO_VER.mo $workdir/share/locale/$LOCALE/LC_MESSAGES/
-done
-rm $temp_dir/locale.list
-
-echo "<*> Setting up default gtk settings..."
-# we want to override default gtk settings
-if [ "$GTK3_BUILD" == "1" ]; then
- gtk_etc_dir="$workdir/etc/gtk-3.0/"
- gtk_rc_file="$gtk_etc_dir/settings.ini"
-else
- gtk_etc_dir="$workdir/etc/gtk-2.0/"
- gtk_rc_file="$gtk_etc_dir/gtkrc"
-fi
-
-mkdir -p $gtk_etc_dir
-
-# Use small icons by default and Faenza icon theme
-if [ "$GTK3_BUILD" == "1" ]; then
-
- cat > $gtk_rc_file << _EOF
-[Settings]
-gtk-icon-theme-name = Faenza
-gtk-menu-images = true
-_EOF
-
-else
- cat > $gtk_rc_file << _EOF
-gtk-theme-name = "MS-Windows"
-gtk-icon-theme-name = "Faenza"
-_EOF
-
-fi
-
-cat >> $gtk_rc_file << _EOF
-gtk-toolbar-style = GTK_TOOLBAR_ICONS
-gtk-toolbar-icon-size = GTK_ICON_SIZE_MENU
-_EOF
-
-mkdir -p $workdir/etc/xdg/midori
-
-cat >> $workdir/etc/xdg/midori/config << _EOF
-[settings]
-default-font-family=Times New Roman
-monospace-font-family=Courier New
-default-font-size=14
-default-monospace-font-size=14
-_EOF
-
-# Don't hardcode mingw path, otherwise fontconfig uses fallback settings
-# which tend to look very bad on Windows
-sed -r 's@>.+(conf\.d)<@>\1@g' -i $workdir/etc/fonts/fonts.conf
-
-popd > /dev/null
-
-echo "<*> Copying docs..."
-
-# copy doc files to root
-cp -L $workdir/share/doc/midori/{COPYING,AUTHORS} $workdir
-
-cat $temp_dir/packages_used.lst | sort | uniq > $workdir/share/doc/midori/README.packages
-rm $temp_dir/packages_used.lst
-
-#drop a/la files, we don't do static builds anyway
-find $workdir -iname *.*a -exec rm {} \;
-
-echo "<*> Compressing archive (slow)..."
-ARCHIVE=`pwd`/$ARCHIVE
-
-# store as zip/7z file
-pushd $temp_dir > /dev/null
-if [ "$have_7zip" != "" ]; then
- 7za a -m0=lzma $ARCHIVE midori-$version_tag > /dev/null
-else
- zip -rq $ARCHIVE midori-$version_tag
-fi
-
-if [ "$NSIS" != "" ];then
- nsis_file=Midori-${version}_setup.exe
- echo "Creating $nsis_file"
- makensis -NOCD -V4 ./midori.nsi
- mv $nsis_file $where_am_i
-fi
-popd > /dev/null
-
-echo "<*> Cleaning up..."
-
-# remove working directory
-rm -r $temp_dir
-
-
-echo "<*> Computing checksums..."
-
-sum_file=midori-$version.sha1
-sha1sum $ARCHIVE >> $sum_file
-
-if [ "$NSIS" != "" ]; then
- sha1sum $nsis_file >> $sum_file
-fi
-
-cat $sum_file
diff --git a/win32/makedist/midori.ico b/win32/makedist/midori.ico
deleted file mode 100644
index d0d482bd..00000000
--- a/win32/makedist/midori.ico
+++ /dev/null
Binary files differ
diff --git a/win32/makedist/midori.nsi b/win32/makedist/midori.nsi
deleted file mode 100644
index 39cdf6d6..00000000
--- a/win32/makedist/midori.nsi
+++ /dev/null
@@ -1,626 +0,0 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-; Copyright (C) 2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
-; 2010-2011 Peter de Ridder <peter(at)xfce(dot)org>
-;
-; 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.
-;
-; Installer script for Midori (Windows Installer)
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
-; Do a Cyclic Redundancy Check to make sure the installer was not corrupted by the download
-CRCCheck force
-RequestExecutionLevel admin ; set execution level for Windows Vista
-
-;;;;;;;;;;;;;;;;;;;
-; helper defines ;
-;;;;;;;;;;;;;;;;;;;
-!define PRODUCT_NAME "Midori"
-!define PRODUCT_VERSION "0.5.11"
-!define PRODUCT_BUILD "0"
-!define PRODUCT_VERSION_ID "${PRODUCT_VERSION}.${PRODUCT_BUILD}"
-!define PRODUCT_PUBLISHER "Christian Dywan"
-!define PRODUCT_WEB_SITE "http://www.midori-browser.org"
-!define PRODUCT_DIR_REGKEY "Software\${PRODUCT_NAME}"
-!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
-!define PRODUCT_BROWER_KEY "Software\Clients\StartMenuInternet"
-!define PRODUCT_EXE "$INSTDIR\bin\midori.exe"
-!define UNINSTALL_EXE "$INSTDIR\uninst.exe"
-!define RESOURCEDIR "midori-${PRODUCT_VERSION}"
-!define ICON_THEME "Faenza"
-
-;;;;;;;;;;;;;;;;;;;;;
-; Version resource ;
-;;;;;;;;;;;;;;;;;;;;;
-VIProductVersion "${PRODUCT_VERSION_ID}"
-VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
-VIAddVersionKey "FileVersion" "${PRODUCT_VERSION}"
-VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
-VIAddVersionKey "LegalCopyright" "Copyright 2009-2012 by Christian Dywan"
-VIAddVersionKey "FileDescription" "${PRODUCT_NAME} Installer"
-
-BrandingText "$(^NAME) installer (NSIS ${NSIS_VERSION})"
-InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
-Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
-SetCompressor /SOLID lzma
-ShowInstDetails hide
-ShowUnInstDetails hide
-XPStyle on
-OutFile "${PRODUCT_NAME}-${PRODUCT_VERSION}_setup.exe"
-
-Var Answer
-Var UserName
-Var StartmenuFolder
-Var UNINSTDIR
-Var DefaultBrowser
-
-;;;;;;;;;;;;;;;;
-; MUI Settings ;
-;;;;;;;;;;;;;;;;
-!include "MUI2.nsh"
-
-!define MUI_ABORTWARNING
-!define MUI_ICON "midori.ico"
-!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-full.ico"
-
-; Welcome page
-!insertmacro MUI_PAGE_WELCOME
-; License page
-;!define MUI_LICENSEPAGE_RADIOBUTTONS
-!insertmacro MUI_PAGE_LICENSE "${RESOURCEDIR}\COPYING"
-; Components page
-!insertmacro MUI_PAGE_COMPONENTS
-; Directory page
-!define MUI_PAGE_CUSTOMFUNCTION_LEAVE OnDirLeave
-!insertmacro MUI_PAGE_DIRECTORY
-; Start menu page
-!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Midori"
-!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
-!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
-!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
-!insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} "$StartmenuFolder"
-; Instfiles page
-!insertmacro MUI_PAGE_INSTFILES
-; Finish page
-!define MUI_FINISHPAGE_RUN "${PRODUCT_EXE}"
-!define MUI_FINISHPAGE_RUN_NOTCHECKED
-!define MUI_FINISHPAGE_NOREBOOTSUPPORT
-!insertmacro MUI_PAGE_FINISH
-
-; Uninstaller page
-!insertmacro MUI_UNPAGE_CONFIRM
-!insertmacro MUI_UNPAGE_INSTFILES
-!insertmacro MUI_UNPAGE_FINISH
-
-; Language file
-!insertmacro MUI_LANGUAGE "English"
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;
-; Sections and InstTypes ;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;
-InstType "Full"
-InstType "Minimal"
-
-Section "!Program Files" SEC01
- SectionIn RO 1 2
- SetOverwrite ifnewer
-
- SetOutPath "$INSTDIR"
- File "${RESOURCEDIR}\*"
-
- SetOutPath "$INSTDIR\bin"
- File /r "${RESOURCEDIR}\bin\*"
-
- SetOutPath "$INSTDIR\etc"
- File /r "${RESOURCEDIR}\etc\*"
-
- SetOutPath "$INSTDIR\lib"
- File /r /x "midori" "${RESOURCEDIR}\lib\*"
-
- SetOutPath "$INSTDIR\share"
- File /r /x "locale" /x "user" /x "${ICON_THEME}" "${RESOURCEDIR}\share\*"
-
- SetOutPath "$INSTDIR\share\icons\${ICON_THEME}"
- File "${RESOURCEDIR}\share\icons\${ICON_THEME}\index.theme"
-
- SetOutPath "$INSTDIR"
- CreateShortCut "$INSTDIR\Midori.lnk" "${PRODUCT_EXE}"
-
- !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
- CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
- CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Midori.lnk" "${PRODUCT_EXE}"
- !insertmacro MUI_STARTMENU_WRITE_END
-
-!macro InstallIconTheme ICat IName
- File "/oname=${ICat}\16\${IName}.png" "${RESOURCEDIR}\share\icons\${ICON_THEME}\${ICat}\16\${IName}.png"
- File "/oname=${Icat}\22\${IName}.png" "${RESOURCEDIR}\share\icons\${ICON_THEME}\${ICat}\22\${IName}.png"
- File "/oname=${Icat}\24\${IName}.png" "${RESOURCEDIR}\share\icons\${ICON_THEME}\${ICat}\24\${IName}.png"
- File /nonfatal "/oname=${ICat}\32\${IName}.png" "${RESOURCEDIR}\share\icons\${ICON_THEME}\${ICat}\32\${IName}.png"
- File /nonfatal "/oname=${ICat}\48\${IName}.png" "${RESOURCEDIR}\share\icons\${ICON_THEME}\${ICat}\48\${IName}.png"
- File /nonfatal "/oname=${ICat}\scalable\${IName}.svg" "${RESOURCEDIR}\share\icons\${ICON_THEME}\${ICat}\scalable\${IName}.svg"
-!macroend
-
-!macro CreateIconThemeSectionsSmall SectionPath
- CreateDirectory "$INSTDIR\share\icons\${ICON_THEME}\${SectionPath}\16"
- CreateDirectory "$INSTDIR\share\icons\${ICON_THEME}\${SectionPath}\22"
- CreateDirectory "$INSTDIR\share\icons\${ICON_THEME}\${SectionPath}\24"
- CreateDirectory "$INSTDIR\share\icons\${ICON_THEME}\${SectionPath}\32"
-!macroend
-
-!macro CreateIconThemeSections SectionPath
- !insertmacro CreateIconThemeSectionsSmall ${SectionPath}
- CreateDirectory "$INSTDIR\share\icons\${ICON_THEME}\${SectionPath}\48"
- CreateDirectory "$INSTDIR\share\icons\${ICON_THEME}\${SectionPath}\scalable"
-!macroend
-
- SetOutPath "$INSTDIR\share\icons\${ICON_THEME}"
-
- !insertmacro CreateIconThemeSections "actions"
- #!insertmacro CreateIconThemeSectionsSmall "animations"
- !insertmacro CreateIconThemeSections "apps"
- !insertmacro CreateIconThemeSections "categories"
- !insertmacro CreateIconThemeSections "devices"
- !insertmacro CreateIconThemeSections "mimetypes"
- !insertmacro CreateIconThemeSections "places"
- !insertmacro CreateIconThemeSections "status"
-
- !insertmacro InstallIconTheme "actions" "bookmark-new"
- !insertmacro InstallIconTheme "actions" "document-open"
- !insertmacro InstallIconTheme "actions" "document-open-recent"
- !insertmacro InstallIconTheme "actions" "document-print"
- !insertmacro InstallIconTheme "actions" "document-properties"
- !insertmacro InstallIconTheme "actions" "document-save-as"
- !insertmacro InstallIconTheme "actions" "document-save"
- !insertmacro InstallIconTheme "actions" "edit-clear"
- !insertmacro InstallIconTheme "actions" "edit-copy"
- !insertmacro InstallIconTheme "actions" "edit-cut"
- !insertmacro InstallIconTheme "actions" "edit-delete"
- !insertmacro InstallIconTheme "actions" "edit-find"
- !insertmacro InstallIconTheme "actions" "edit-paste"
- !insertmacro InstallIconTheme "actions" "edit-redo"
- !insertmacro InstallIconTheme "actions" "edit-select-all"
- !insertmacro InstallIconTheme "actions" "edit-undo"
- !insertmacro InstallIconTheme "actions" "folder-new"
- !insertmacro InstallIconTheme "actions" "format-indent-more"
- !insertmacro InstallIconTheme "actions" "go-down"
- !insertmacro InstallIconTheme "actions" "go-home"
- !insertmacro InstallIconTheme "actions" "go-jump"
- !insertmacro InstallIconTheme "actions" "go-next"
- !insertmacro InstallIconTheme "actions" "go-previous"
- !insertmacro InstallIconTheme "actions" "go-up"
- !insertmacro InstallIconTheme "actions" "gtk-cancel"
- !insertmacro InstallIconTheme "actions" "gtk-edit"
- !insertmacro InstallIconTheme "actions" "gtk-no"
- !insertmacro InstallIconTheme "actions" "gtk-ok"
- !insertmacro InstallIconTheme "actions" "gtk-save"
- !insertmacro InstallIconTheme "actions" "gtk-yes"
- !insertmacro InstallIconTheme "actions" "help-about"
- !insertmacro InstallIconTheme "actions" "help-contents"
- !insertmacro InstallIconTheme "actions" "list-add"
- !insertmacro InstallIconTheme "actions" "list-remove"
- !insertmacro InstallIconTheme "actions" "media-skip-backward"
- !insertmacro InstallIconTheme "actions" "media-skip-forward"
- !insertmacro InstallIconTheme "actions" "process-stop"
- !insertmacro InstallIconTheme "actions" "stop"
- !insertmacro InstallIconTheme "actions" "tab-new"
- !insertmacro InstallIconTheme "actions" "tools-check-spelling"
- !insertmacro InstallIconTheme "actions" "view-fullscreen"
- !insertmacro InstallIconTheme "actions" "view-refresh"
- !insertmacro InstallIconTheme "actions" "window-close"
- !insertmacro InstallIconTheme "actions" "window-new"
- !insertmacro InstallIconTheme "actions" "zoom-in"
- !insertmacro InstallIconTheme "actions" "zoom-out"
-
- #!insertmacro InstallIconThemeSmall "animations" "process-working"
-
- !insertmacro InstallIconTheme "apps" "internet-news-reader"
- !insertmacro InstallIconTheme "apps" "midori"
- !insertmacro InstallIconTheme "apps" "preferences-desktop-theme"
- !insertmacro InstallIconTheme "apps" "web-browser"
-
- !insertmacro InstallIconTheme "categories" "gtk-preferences"
-
- !insertmacro InstallIconTheme "devices" "drive-harddisk"
- !insertmacro InstallIconTheme "devices" "media-optical-dvd-rom"
-
- !insertmacro InstallIconTheme "mimetypes" "application-x-shockwave-flash"
- !insertmacro InstallIconTheme "mimetypes" "extension"
- !insertmacro InstallIconTheme "mimetypes" "gtk-file"
- !insertmacro InstallIconTheme "mimetypes" "image-x-generic"
- !insertmacro InstallIconTheme "mimetypes" "package"
- !insertmacro InstallIconTheme "mimetypes" "text-html"
- !insertmacro InstallIconTheme "mimetypes" "text-x-generic"
- !insertmacro InstallIconTheme "mimetypes" "text-x-javascript"
-
- !insertmacro InstallIconTheme "places" "folder-documents"
- !insertmacro InstallIconTheme "places" "folder-downloads"
- !insertmacro InstallIconTheme "places" "folder-music"
- !insertmacro InstallIconTheme "places" "folder-pictures"
- !insertmacro InstallIconTheme "places" "folder"
- !insertmacro InstallIconTheme "places" "folder-videos"
- !insertmacro InstallIconTheme "places" "inode-directory"
- !insertmacro InstallIconTheme "places" "user-bookmarks"
- !insertmacro InstallIconTheme "places" "user-desktop"
- !insertmacro InstallIconTheme "places" "user-home"
- !insertmacro InstallIconTheme "places" "user-trash"
-
- !insertmacro InstallIconTheme "status" "dialog-password"
- !insertmacro InstallIconTheme "status" "gtk-dialog-error"
- !insertmacro InstallIconTheme "status" "gtk-dialog-info"
- !insertmacro InstallIconTheme "status" "gtk-dialog-warning"
- !insertmacro InstallIconTheme "status" "locked"
- !insertmacro InstallIconTheme "status" "network-error"
- !insertmacro InstallIconTheme "status" "network-idle"
-
-SectionEnd
-
-Section "Extensions" SEC04
- SectionIn 1
- SetOverwrite ifnewer
- SetOutPath "$INSTDIR\lib"
- File /r "${RESOURCEDIR}\lib\midori"
-SectionEnd
-
-Section "Language Files" SEC02
- SectionIn 1
- SetOutPath "$INSTDIR\share"
- File /r "${RESOURCEDIR}\share\locale"
-SectionEnd
-
-
-Section "Desktop Shortcuts" SEC03
- SectionIn 1
- # CreateShortCut implicitly sets content of OUTDIR as working directory for shortcut, set it to bin
- SetOutPath "$INSTDIR\bin"
- CreateShortCut "$DESKTOP\Midori.lnk" "${PRODUCT_EXE}"
- CreateShortCut "$QUICKLAUNCH\Midori.lnk" "${PRODUCT_EXE}"
-SectionEnd
-
-Section "Default Browser" SEC05
- SectionIn 1
- StrCpy $DefaultBrowser "yes"
-SectionEnd
-
-Section -AdditionalIcons
- SetOutPath $INSTDIR
- !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
- WriteIniStr "$INSTDIR\Website.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
- CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Website.lnk" "${PRODUCT_EXE}" \
- "${PRODUCT_WEB_SITE}" "${PRODUCT_EXE}"
- CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall.lnk" "${UNINSTALL_EXE}"
- CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Make Default.lnk" "${UNINSTALL_EXE}" \
- "/S /MAKEDEFAULT" "${PRODUCT_EXE}"
- !insertmacro MUI_STARTMENU_WRITE_END
-SectionEnd
-
-Section -Post
- WriteUninstaller "${UNINSTALL_EXE}"
- WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" Path "$INSTDIR"
- WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
- ${if} $Answer == "yes" ; if user is admin
- WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
- WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "${UNINSTALL_EXE}"
- WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "${PRODUCT_EXE}"
- WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
- WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
- WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_WEB_SITE}"
- WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
- WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
- WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
-
- WriteRegStr HKLM "${PRODUCT_BROWER_KEY}\MIDORI.EXE" "" "${PRODUCT_NAME}"
- WriteRegStr HKLM "${PRODUCT_BROWER_KEY}\MIDORI.EXE\DefaultIcon" "" "${PRODUCT_EXE},0"
- WriteRegStr HKLM "${PRODUCT_BROWER_KEY}\MIDORI.EXE\shell\open\command" "" "${PRODUCT_EXE}"
- WriteRegStr HKLM "${PRODUCT_BROWER_KEY}\MIDORI.EXE\InstallInfo" "HideIconsCommand" '"${UNINSTALL_EXE}" /S /HIDE'
- WriteRegDWORD HKLM "${PRODUCT_BROWER_KEY}\MIDORI.EXE\InstallInfo" "IconsVisible" 0x00000000
- WriteRegStr HKLM "${PRODUCT_BROWER_KEY}\MIDORI.EXE\InstallInfo" "ReinstallCommand" '"${UNINSTALL_EXE}" /S /MAKEDEFAULT'
- WriteRegStr HKLM "${PRODUCT_BROWER_KEY}\MIDORI.EXE\InstallInfo" "ShowIconsCommand" '"${UNINSTALL_EXE}" /S /SHOW'
- ${endif}
-
- ${if} $DefaultBrowser == "yes"
- ${if} $Answer == "yes" ; if user is admin
- WriteRegDWORD HKLM "${PRODUCT_BROWER_KEY}\MIDORI.EXE\InstallInfo" "IconsVisible" 0x00000001
- ${endif}
- WriteRegStr HKCU "${PRODUCT_BROWER_KEY}" "" "MIDORI.EXE"
- WriteRegStr HKCR "http\DefaultIcon" "" "${PRODUCT_EXE},0"
- WriteRegStr HKCR "http\shell\open\command" "" '${PRODUCT_EXE} "%1"'
- WriteRegStr HKCR "https\DefaultIcon" "" "${PRODUCT_EXE},0"
- WriteRegStr HKCR "https\shell\open\command" "" '${PRODUCT_EXE} "%1"'
- ${endif}
-SectionEnd
-
-Section Uninstall
- Delete "$INSTDIR\Website.url"
- Delete "${UNINSTALL_EXE}"
- Delete "$INSTDIR\COPYING"
- Delete "$INSTDIR\AUTHORS"
- Delete "$INSTDIR\Midori.lnk"
-
- ; delete start menu entry
- ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu"
- RMDir /r "$0"
-
- Delete "$QUICKLAUNCH\Midori.lnk"
- Delete "$DESKTOP\Midori.lnk"
-
- RMDir /r "$INSTDIR\bin"
- RMDir /r "$INSTDIR\etc"
- RMDir /r "$INSTDIR\lib"
- RMDir /r "$INSTDIR\share"
- RMDir "$INSTDIR"
-
- DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
- DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
- DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
- DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY}"
- DeleteRegKey HKLM "${PRODUCT_BROWER_KEY}\MIDORI.EXE"
-
- SetAutoClose true
-SectionEnd
-
-;;;;;;;;;;;;;;;;;;;;;;;;;
-; Section descriptions ;
-;;;;;;;;;;;;;;;;;;;;;;;;;
-!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
-!insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "Required program files. You cannot skip these files."
-!insertmacro MUI_DESCRIPTION_TEXT ${SEC02} "Various translations of Midori's interface."
-!insertmacro MUI_DESCRIPTION_TEXT ${SEC03} "Create shortcuts for Midori on the desktop and in the Quicklaunch Bar"
-!insertmacro MUI_DESCRIPTION_TEXT ${SEC04} "Available plugins like 'Advertisement Blocker', 'Form history filler' and 'Mouse Gestures'."
-!insertmacro MUI_DESCRIPTION_TEXT ${SEC05} "Make Midori the default browser."
-!insertmacro MUI_FUNCTION_DESCRIPTION_END
-
-;;;;;;;;;;;;;;;;;;;;;
-; helper functions ;
-;;;;;;;;;;;;;;;;;;;;;
-
-; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
-!macro IsUserAdmin Result UName
- ClearErrors
- UserInfo::GetName
- IfErrors Win9x
- Pop $0
- StrCpy ${UName} $0
- UserInfo::GetAccountType
- Pop $1
- ${if} $1 == "Admin"
- StrCpy ${Result} "yes"
- ${else}
- StrCpy ${Result} "no"
- ${endif}
- Goto done
-
-Win9x:
- StrCpy ${Result} "yes"
-done:
-!macroend
-
-; (from http://nsis.sourceforge.net/GetOptions)
-Function un.GetOptions
- !define GetOptions `!insertmacro GetOptionsCall`
-
- !macro GetOptionsCall _PARAMETERS _OPTION _RESULT
- Push `${_PARAMETERS}`
- Push `${_OPTION}`
- Call un.GetOptions
- Pop ${_RESULT}
- !macroend
-
- Exch $1
- Exch
- Exch $0
- Exch
- Push $2
- Push $3
- Push $4
- Push $5
- Push $6
- Push $7
- ClearErrors
-
- StrCpy $2 $1 '' 1
- StrCpy $1 $1 1
- StrLen $3 $2
- StrCpy $7 0
-
- begin:
- StrCpy $4 -1
- StrCpy $6 ''
-
- quote:
- IntOp $4 $4 + 1
- StrCpy $5 $0 1 $4
- StrCmp $5$7 '0' notfound
- StrCmp $5 '' trimright
- StrCmp $5 '"' 0 +7
- StrCmp $6 '' 0 +3
- StrCpy $6 '"'
- goto quote
- StrCmp $6 '"' 0 +3
- StrCpy $6 ''
- goto quote
- StrCmp $5 `'` 0 +7
- StrCmp $6 `` 0 +3
- StrCpy $6 `'`
- goto quote
- StrCmp $6 `'` 0 +3
- StrCpy $6 ``
- goto quote
- StrCmp $5 '`' 0 +7
- StrCmp $6 '' 0 +3
- StrCpy $6 '`'
- goto quote
- StrCmp $6 '`' 0 +3
- StrCpy $6 ''
- goto quote
- StrCmp $6 '"' quote
- StrCmp $6 `'` quote
- StrCmp $6 '`' quote
- StrCmp $5 $1 0 quote
- StrCmp $7 0 trimleft trimright
-
- trimleft:
- IntOp $4 $4 + 1
- StrCpy $5 $0 $3 $4
- StrCmp $5 '' notfound
- StrCmp $5 $2 0 quote
- IntOp $4 $4 + $3
- StrCpy $0 $0 '' $4
- StrCpy $4 $0 1
- StrCmp $4 ' ' 0 +3
- StrCpy $0 $0 '' 1
- goto -3
- StrCpy $7 1
- goto begin
-
- trimright:
- StrCpy $0 $0 $4
- StrCpy $4 $0 1 -1
- StrCmp $4 ' ' 0 +3
- StrCpy $0 $0 -1
- goto -3
- StrCpy $3 $0 1
- StrCpy $4 $0 1 -1
- StrCmp $3 $4 0 end
- StrCmp $3 '"' +3
- StrCmp $3 `'` +2
- StrCmp $3 '`' 0 end
- StrCpy $0 $0 -1 1
- goto end
-
- notfound:
- SetErrors
- StrCpy $0 ''
-
- end:
- Pop $7
- Pop $6
- Pop $5
- Pop $4
- Pop $3
- Pop $2
- Pop $1
- Exch $0
-FunctionEnd
-
-Function .onInit
- StrCpy "$StartmenuFolder" "Midori"
-
- ; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
- ; If the user does *not* have administrator privileges, abort
- StrCpy $Answer ""
- StrCpy $UserName ""
- !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
- ${if} $Answer == "yes"
- SetShellVarContext all ; set that e.g. shortcuts will be created for all users
- ${else}
- MessageBox mb_iconstop "Administrator rights required - use the portable release if that's not possible"
- SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
- Quit
- ${endif}
-
- ; prevent running multiple instances of the installer
- System::Call 'kernel32::CreateMutexA(i 0, i 0, t "midori_installer") i .r1 ?e'
- Pop $R0
- StrCmp $R0 0 +3
- MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." /SD IDOK
- Abort
- ; warn about a new install over an existing installation
- ReadRegStr $R0 SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString"
- StrCmp $R0 "" finish
-
- MessageBox MB_YESNO|MB_ICONEXCLAMATION \
- "Midori has already been installed. $\nDo you want to remove the previous version before installing $(^Name) ?" \
- /SD IDYES IDYES remove IDNO finish
-
-remove:
- ; run the uninstaller
- ClearErrors
- ; we read the installation path of the old installation from the Registry
- ReadRegStr $UNINSTDIR SHCTX "${PRODUCT_DIR_REGKEY}" "Path"
- IfSilent dosilent nonsilent
-dosilent:
- ExecWait '$R0 /S _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
- Goto finish
-nonsilent:
- ExecWait '$R0 _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
-finish:
-FunctionEnd
-
-Function un.onInit
- StrCpy $Answer ""
- !insertmacro IsUserAdmin $Answer $UserName
- ${if} $Answer == "yes"
- SetShellVarContext all
- ${else}
- SetShellVarContext current
- ${endif}
-
- ${GetOptions} "$CMDLINE" "/MAKEDEFAULT" $0
- IfErrors 0 +2
- goto makedefault_next
-
- WriteRegStr HKCU "${PRODUCT_BROWER_KEY}" "" "MIDORI.EXE"
- WriteRegStr HKCR "http\DefaultIcon" "" "${PRODUCT_EXE},0"
- WriteRegStr HKCR "http\shell\open\command" "" '${PRODUCT_EXE} "%1"'
- WriteRegStr HKCR "https\DefaultIcon" "" "${PRODUCT_EXE},0"
- WriteRegStr HKCR "https\shell\open\command" "" '${PRODUCT_EXE} "%1"'
- Abort
-makedefault_next:
-
- ${GetOptions} "$CMDLINE" "/SHOW" $0
- IfErrors 0 +2
- goto show_next
-
- ${if} $Answer == "yes" ; if user is admin
- WriteRegDWORD HKLM "${PRODUCT_BROWER_KEY}\MIDORI.EXE\InstallInfo" "IconsVisible" 0x00000001
- ${endif}
- CreateShortCut "$DESKTOP\Midori.lnk" "${PRODUCT_EXE}"
- CreateShortCut "$QUICKLAUNCH\Midori.lnk" "${PRODUCT_EXE}"
- Abort
-show_next:
-
- ${GetOptions} "$CMDLINE" "/HIDE" $0
- IfErrors 0 +2
- goto hide_next
-
- ${if} $Answer == "yes" ; if user is admin
- WriteRegDWORD HKLM "${PRODUCT_BROWER_KEY}\MIDORI.EXE\InstallInfo" "IconsVisible" 0x00000000
- ${endif}
- Delete "$QUICKLAUNCH\Midori.lnk"
- Delete "$DESKTOP\Midori.lnk"
- Abort
-hide_next:
-
- ; If the user does *not* have administrator privileges, abort
- ${if} $Answer != "yes"
- ; check if the Midori has been installed with admin permisions
- ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
- ${if} $0 != ""
- MessageBox MB_OK|MB_ICONSTOP "You need administrator privileges to uninstall Midori!" \
- /SD IDOK
- Abort
- ${endif}
- ${endif}
-FunctionEnd
-
-Function OnDirLeave
- ClearErrors
- SetOutPath "$INSTDIR" ; what about IfError creating $INSTDIR?
- GetTempFileName $1 "$INSTDIR" ; creates tmp file (or fails)
- FileOpen $0 "$1" "w" ; error to open?
- FileWriteByte $0 "0"
- IfErrors notPossible possible
-
-notPossible:
- RMDir "$INSTDIR" ; removes folder if empty
- MessageBox MB_OK "The given directory is not writeable. Please choose another one!" /SD IDOK
- Abort
-possible:
- FileClose $0
- Delete "$1"
-FunctionEnd
diff --git a/win32/makedist/win32-release b/win32/makedist/win32-release
deleted file mode 100755
index d27713bc..00000000
--- a/win32/makedist/win32-release
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2013 Paweł Forysiuk <tuxator@o2.pl>
-#
-# 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.
-
-
-SRCDIR=$PWD
-CONFIGURE_OPTIONS="-DUSE_ZEITGEIST=0 -DUSE_GTK3=1 -DCMAKE_VERBOSE_MAKEFILE=0 -DEXTRA_WARNINGS=1"
-
-# 32-bit build
-#mingw32-env
-export MINGW_PREFIX="/usr/i686-w64-mingw32/sys-root/mingw"
-eval `rpm --eval %{mingw32_env}`
-
-rm -fr _mingw32
-mkdir _mingw32 && cd _mingw32
-mingw32-cmake -DCMAKE_INSTALL_PREFIX=$MINGW_PREFIX ${CONFIGURE_OPTIONS} $SRCDIR
-make
-sudo make install || exit
-
-
-version=$(grep set\(VERSION $SRCDIR/CMakeLists.txt|head -n1|sed -e 's/^.*set(VERSION \([0-9.]*\)).*$/\1/')
-
-rpmquery -qa mingw32* > $SRCDIR/midori-${version}-deps-i686.txt
-rm -f $SRCDIR/midori-$version.sha1
-
-MINGW_PREFIX=${MINGW_PREFIX} RELEASE=1 NSIS=1 $SRCDIR/win32/makedist/makedist.midori
-mv -v midori-${version}.7z midori_${version}_32_.7z
-mv -v Midori-${version}_setup.exe midori_${version}_32_.exe
-
-if [ "$DO_64BIT" != "" ]; then
- cd $SRCDIR
- # 64-bit build
- #mingw64-env
- export MINGW_PREFIX="/usr/x86_64-w64-mingw32/sys-root/mingw"
- eval `rpm --eval %{mingw64_env}`
-
- rm -fr _mingw64
- mkdir _mingw64 && cd _mingw64
- mingw64-cmake -DCMAKE_INSTALL_PREFIX=$MINGW_PREFIX ${CONFIGURE_OPTIONS} $SRCDIR
- make
- sudo make install || exit
-
- rpmquery -qa mingw64* > $SRCDIR/midori-${version}-deps-x86_64.txt
- MINGW_PREFIX=${MINGW_PREFIX} RELEASE=1 sh $SRCDIR/win32/makedist/makedist.midori x86_64-portable
-fi
-
-cd $SRCDIR
-
-echo
-echo "============================="
-echo "Midori win32 release details:"
-echo "Download links:"
-cat release_links.txt
-echo "Checksums:"
-cat midori-$version.sha1
-echo "============================="
-echo
diff --git a/win32/old/README_OPENSUSE_MINGW.txt b/win32/old/README_OPENSUSE_MINGW.txt
deleted file mode 100644
index ed8a59ad..00000000
--- a/win32/old/README_OPENSUSE_MINGW.txt
+++ /dev/null
@@ -1,92 +0,0 @@
-This file is licensed under the terms of the LGPL 2.1, see the file COPYING.
-
- FILES
-
-README.txt This file, explaining how to build Midori.
-midori-0.3.3.nsi The NSIS installer creation script.
-
-packages.list The suse mingw packages required to build Midori.
-x86-mingw32-opensuse/ Install and update script for the opensuse repository.
-
-makedist/ Scripts to create distribution package
- from cross-compiled binaries and libs.
-
-crossconfig.sh Setup environment for cross build and run
- configure script for cross build.
-
-
- INTRODUCTION
-
-This document will explain how to get Midori compiling for windows, hopefully.
-
-
- REQUIREMENTS
-
-A working tool chain with the mingw compiler is required. This can either be
-native in Windows or a cross-chain.
-This tool chain must have the following applications and all applications
-needed to build Midori:
-- basename, for x86-mingw32-opensuse
-- bash, for the shell scripts
-- cat, for makedist.midori
-- cp, for x86-mingw32-opensuse and makedist.midori
-- cpio, for x86-mingw32-opensuse
-- echo, for x86-mingw32-opensuse and makedist.midori
-- find, for makedist.midori
-- git, to get the development sources
-- grep, for makedist.midori
-- gunzip, for x86-mingw32-opensuse
-- head, for x86-mingw32-opensuse
-- ls, for makedist.midori
-- mkdir, for x86-mingw32-opensuse and makedist.midori
-- mktemp, for makedist.midori
-- pwd, for makedist.midori
-- rm, for x86-mingw32-opensuse and makedist.midori
-- rmdir, for makedist.midori
-- rpm2cpio, for x86-mingw32-opensuse
-- sed, for x86-mingw32-opensuse
-- sha1sum, for makedist.midori
-- sort, for x86-mingw32-opensuse and makedist.midori
-- strings, for makedist.midori
-- tar, to unpack the scripts
-- touch, for x86-mingw32-opensuse
-- uniq, for makedist.midori
-- wget, for x86-mingw32-opensuse
-- xmlgrep, for x86-mingw32-opensuse
-- zip, for makedist.midori
-
-
- PREPARATIONS
-
-Install all the packages needed by Midori and its dependencies. There are two
-ways to do this. Automatically install the dependencies from opensuse.org or
-manually install them.
-To automatically install the packages use the scripts and change configuration
-in header of install.sh file where needed. And run ./install.sh to install all
-necessary packages.
-This script can be also invoked with "update" argument ./install.sh update
-to update the installed packages to newer versions.
-To install the dependencies manually install the packages in packages.list.
-This are all the packages needed by Midori and its dependencies.
-
-Get the Midori sources. Either use git to get them or download a snapshot or a
-release. See http://git.xfce.org/apps/midori or
-http://archive.xfce.org/src/apps/midori/
-
-
- BUILDING
-
-Read the instruction in the source tree. For cross compiling the script
-crossconfig.sh might help.
-
-
- DISTRIBUTION
-
-To create a Windows installer for Midori you need NSIS. See
-http://nsis.sourceforge.net/Main_Page
-Use the makedist.midori script to get all files needed for distribution. Add
-the version number as argument to makedist.midori to create a version number
-in the distribution package. eg. ./makedist.midori -0.3.3
-To complete the installer unzip the file created by the makedist script.
-Compile midori-0.3.3.nsi with NSIS.
-
diff --git a/win32/old/x86-mingw32-opensuse/crossconfig.sh b/win32/old/x86-mingw32-opensuse/crossconfig.sh
deleted file mode 100755
index 169c0940..00000000
--- a/win32/old/x86-mingw32-opensuse/crossconfig.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2010-2011 Peter de Ridder <peter@xfce.org>
-#
-# 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.
-
-export MINGW_PREFIX=~/dev/mingw/mingw32
-export PATH=$MINGW_PREFIX/bin:$PATH
-export PKG_CONFIG_PATH=$MINGW_PREFIX/lib/pkgconfig
-export PKG_CONFIG_LIBDIR=
-export MINGW_BUILD=`gcc -dumpmachine`
-export MINGW_TARGET=i386-mingw32
-
-find_compiler ()
-{
- export CC=$( find /usr/bin -iname *mingw32*gcc )
-}
-
-find_compiler
-if [ "$CC" != "" ]; then
- CC=${CC} ./configure --prefix=$MINGW_PREFIX $@
-else
- echo "Cannot find cross-complier! Please install mingw version of gcc compiler."
-fi
diff --git a/win32/old/x86-mingw32-opensuse/install.sh b/win32/old/x86-mingw32-opensuse/install.sh
deleted file mode 100755
index e9993311..00000000
--- a/win32/old/x86-mingw32-opensuse/install.sh
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2010-2011 Peter de Ridder <peter@xfce.org>
-#
-# 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.
-
-# config variables
-REPO_URL=http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_11.4
-REPO_ARCH=noarch
-DOWNLOAD_PATH=~/dev/mingw/packages/opensuse
-BUILD_PATH=~/tmp/opensuse
-INSTALL_PATH=~/dev/mingw/mingw32
-
-if [[ "$1" == "update" ]]
-then
- UPDATE=yes
-fi
-
-which xmlgrep 2> /dev/null && HAVE_XMLGREP=1 || HAVE_XMLGREP=0
-if [[ "$HAVE_XMLGREP" == "0" ]]; then
- echo -e "\nPlease install xmlclitools http://robur.slu.se/jensl/xmlclitools\n"
- exit
-fi
-
-# create download and build directory
-mkdir -p $DOWNLOAD_PATH
-mkdir -p $BUILD_PATH
-
-rm $DOWNLOAD_PATH/repomd.xml
-wget -nc $REPO_URL/repodata/repomd.xml -P $DOWNLOAD_PATH || exit 1
-OTHER_FILE=`xmlgrep -c -f $DOWNLOAD_PATH/repomd.xml repomd.data:type=other.location | sed 's/.*href="\([^"]*\)".*/\1/'`
-
-wget -nc $REPO_URL/$OTHER_FILE -O $DOWNLOAD_PATH/other.xml.gz || exit 1
-rm $DOWNLOAD_PATH/other.xml
-#gunzip -N $DOWNLOAD_PATH/`basename $OTHER_FILE`
-gunzip -N $DOWNLOAD_PATH/other.xml
-
-rm packages.version
-touch packages.version
-
-# download all packages
-while read line
-do
- VERSION=`xmlgrep -c -f $DOWNLOAD_PATH/other.xml otherdata.package:name="$line":arch="$REPO_ARCH" | awk -F\< '{print $2}' |sed -e 'h' -e 's/^.*ver="\([^"]*\)".*$/\1/p' -e 'g' -e 's/^.*rel="\([^"]*\)".*$/\1/' | sed -e N -e 's/\n/-/' | sort -V -r | head -n 1`
- FILE=$line-$VERSION.$REPO_ARCH.rpm
- test "$UPDATE" == yes || echo $FILE >> packages.version
- if [ ! -f $DOWNLOAD_PATH/$FILE ]
- then
- test "$UPDATE" == yes && echo $FILE >> packages.version
- wget -nc $REPO_URL/$REPO_ARCH/$FILE -P $DOWNLOAD_PATH
- fi
-done < packages.list
-
-# convert and install packages
-while read line
-do
- pushd $BUILD_PATH
- # extract rpm
- rpm2cpio $DOWNLOAD_PATH/$line | cpio -i -d
-
- if [ -d $BUILD_PATH/usr/i686-pc-ming32/sys-root/mingw ]
- then
- # convert pkgconfig files
- if [ -d $BUILD_PATH/usr/i686-pc-mingw32/sys-root/mingw/lib/pkgconfig ]
- then
- sed -i -e 's@^prefix=.*@prefix='$INSTALL_PATH'@' -e 's@/usr/i686-pc-mingw32/sys-root/mingw@${prefix}@' $BUILD_PATH/usr/i686-pc-mingw32/sys-root/mingw/lib/pkgconfig/*.pc
- fi
- # install the package
- cp -rf $BUILD_PATH/usr/i686-pc-mingw32/sys-root/mingw/* $INSTALL_PATH/
- fi
-
- if [ -d $BUILD_PATH/usr/i686-w64-mingw32/sys-root/mingw ]
- then
- # convert pkgconfig files
- if [ -d $BUILD_PATH/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig ]
- then
- sed -i -e 's@^prefix=.*@prefix='$INSTALL_PATH'@' -e 's@/usr/i686-w64-mingw32/sys-root/mingw@${prefix}@' $BUILD_PATH/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/*.pc
- fi
- # install the package
- cp -rf $BUILD_PATH/usr/i686-w64-mingw32/sys-root/mingw/* $INSTALL_PATH/
- fi
-
- # remove the extracted file
- rm -rf $BUILD_PATH/usr
- popd
-done < packages.version
-
-# remove build directory
-rm -rf $BUILD_PATH
diff --git a/win32/old/x86-mingw32-opensuse/packages.list b/win32/old/x86-mingw32-opensuse/packages.list
deleted file mode 100644
index 31c57f36..00000000
--- a/win32/old/x86-mingw32-opensuse/packages.list
+++ /dev/null
@@ -1,89 +0,0 @@
-This file is licensed under the terms of the LGPL 2.1, see the file COPYING.
-
-mingw32-atk
-mingw32-atk-devel
-mingw32-cairo-devel
-mingw32-dbus-1
-mingw32-dbus-1-glib
-mingw32-dbus-1-glib-devel
-mingw32-enchant
-mingw32-enchant-devel
-mingw32-fontconfig
-mingw32-fontconfig-devel
-mingw32-freetype
-mingw32-freetype-devel
-mingw32-gcc-c++
-mingw32-gcc
-mingw32-gdb
-mingw32-gdk-pixbuf
-mingw32-gdk-pixbuf-devel
-mingw32-gettext-runtime
-mingw32-gettext-tools
-mingw32-glib2
-mingw32-glib2-devel
-mingw32-glib-networking
-mingw32-gst-plugins-base-devel
-mingw32-gstreamer-devel
-mingw32-gtk2
-mingw32-gtk2-devel
-mingw32-hunspell
-mingw32-hunspell-devel
-mingw32-libexpat
-mingw32-libexpat-devel
-mingw32-libgcc
-mingw32-libgcrypt
-mingw32-libgcrypt-devel
-mingw32-libcairo2
-mingw32-libgeoclue
-mingw32-libgeoclue-devel
-mingw32-libgnutls
-mingw32-libgnutls-devel
-mingw32-libgpg-error
-mingw32-libgpg-error-devel
-mingw32-libgstinterfaces
-mingw32-libgstreamer
-mingw32-libidn
-mingw32-libidn-devel
-mingw32-libintl
-mingw32-libintl-devel
-mingw32-libjasper
-mingw32-libjasper-devel
-mingw32-libjpeg
-mingw32-libjpeg-devel
-mingw32-libopenssl
-mingw32-libopenssl-devel
-mingw32-libpng
-mingw32-libpng-devel
-mingw32-libsoup
-mingw32-libsoup-devel
-mingw32-libstdc++
-mingw32-libsqlite
-mingw32-libsqlite-devel
-mingw32-libtasn1
-mingw32-libtasn1-devel
-mingw32-libtiff
-mingw32-libtiff-devel
-mingw32-libwebkitgtk
-mingw32-libwebkitgtk-devel
-mingw32-webkit-tools
-mingw32-libxml2
-mingw32-libxml2-devel
-mingw32-libxslt
-mingw32-libxslt-devel
-mingw32-pango
-mingw32-pango-devel
-mingw32-pixman
-mingw32-pixman-devel
-mingw32-pthreads
-mingw32-pthreads-devel
-mingw32-libproxy
-mingw32-libmodman
-mingw32-shared-mime-info
-mingw32-shared-mime-info-devel
-mingw32-win_iconv
-mingw32-win_iconv-devel
-mingw32-zlib
-mingw32-zlib-devel
-mingw32-libunique
-mingw32-libunique-devel
-mingw32-libffi